xf86-video-ati: Branch 'master'

Egbert Eich eich at kemper.freedesktop.org
Tue May 20 10:55:50 PDT 2008


 src/legacy_output.c |   34 +++++++++++++++++++++-------------
 src/radeon_reg.h    |    3 ++-
 2 files changed, 23 insertions(+), 14 deletions(-)

New commits:
commit 19e97f74e39fc2b35727708ac429de33d0b70162
Author: Egbert Eich <eich at freedesktop.org>
Date:   Tue May 20 11:16:15 2008 +0200

    Change RMX code to follow the programming algorithm suggested by ATI.
    
    ATI provides the following algorithm to calculate the RMX scaling ratios
    in its programming specs:
    when RMX_AUTO_RATIO_HORZ_INC set to 1,Horizontal auto ratio result trucated,
    and then incremented by 1.
    Horz_Ratio = ( ((Active display width in characters (including overscan) + 1)
    / (Panel width in characters)) x 4096 + 1 )
    else
    Horz_Ratio = ( ((Active display width in characters (including overscan))
    / (Panel width in characters)) x 4096 + 1 )
    
    when RMX_AUTO_RATIO_VERT_INC set to 1, Vertical auto ratio result trucated,
    and then incremented by 1.
    Vert_Ration = ( ((Active display width in characters (including overscan) + 1)
    / (Panel width in characters)) x 4096 + 1)
    else
    Vert_Ration = ( ((Active display width in characters (including overscan))
    / (Panel width in characters)) x 4096 + 1)
    
    This patch implements this behavor. Additionally it avoids the use of floats.

diff --git a/src/legacy_output.c b/src/legacy_output.c
index 337370b..4df81ab 100644
--- a/src/legacy_output.c
+++ b/src/legacy_output.c
@@ -1116,14 +1116,15 @@ RADEONInitRMXRegisters(xf86OutputPtr output, RADEONSavePtr save,
     RADEONOutputPrivatePtr radeon_output = output->driver_private;
     int    xres = mode->HDisplay;
     int    yres = mode->VDisplay;
-    float  Hratio, Vratio;
+    Bool   Hscale = TRUE, Vscale = TRUE;
     int    hsync_wid;
     int    vsync_wid;
     int    hsync_start;
 
 
     save->fp_vert_stretch = info->SavedReg->fp_vert_stretch &
-	                    RADEON_VERT_STRETCH_RESERVED;
+	                    (RADEON_VERT_STRETCH_RESERVED |
+			     RADEON_VERT_AUTO_RATIO_INC);
     save->fp_horz_stretch = info->SavedReg->fp_horz_stretch &
 	                    (RADEON_HORZ_FP_LOOP_STRETCH |
 	                     RADEON_HORZ_AUTO_RATIO_INC);
@@ -1170,34 +1171,41 @@ RADEONInitRMXRegisters(xf86OutputPtr output, RADEONSavePtr save,
 	return;
 
     if (radeon_output->PanelXRes == 0 || radeon_output->PanelYRes == 0) {
-	Hratio = 1.0;
-	Vratio = 1.0;
+	Hscale = FALSE;
+	Vscale = FALSE;
     } else {
 	if (xres > radeon_output->PanelXRes) xres = radeon_output->PanelXRes;
 	if (yres > radeon_output->PanelYRes) yres = radeon_output->PanelYRes;
 
-	Hratio = (float)xres/(float)radeon_output->PanelXRes;
-	Vratio = (float)yres/(float)radeon_output->PanelYRes;
+	if (xres == radeon_output->PanelXRes)
+	    Hscale = FALSE;
+	if (yres == radeon_output->PanelYRes)
+	    Vscale = FALSE;
     }
 
-    if ((Hratio == 1.0) || (!(radeon_output->Flags & RADEON_USE_RMX)) ||
+    if ((!Hscale) || (!(radeon_output->Flags & RADEON_USE_RMX)) ||
 	(radeon_output->rmx_type == RMX_CENTER)) {
 	save->fp_horz_stretch |= ((xres/8-1)<<16);
     } else {
-	save->fp_horz_stretch |= ((((unsigned long)
-				    (Hratio * RADEON_HORZ_STRETCH_RATIO_MAX)) &
-				   RADEON_HORZ_STRETCH_RATIO_MASK) |
+	CARD32 scale, inc;
+	inc = (save->fp_horz_stretch & RADEON_HORZ_AUTO_RATIO_INC) ? 1 : 0;
+	scale = ((xres + inc) * RADEON_HORZ_STRETCH_RATIO_MAX)
+	    / radeon_output->PanelXRes + 1;
+	save->fp_horz_stretch |= (((scale) & RADEON_HORZ_STRETCH_RATIO_MASK) |
 				  RADEON_HORZ_STRETCH_BLEND |
 				  RADEON_HORZ_STRETCH_ENABLE |
 				  ((radeon_output->PanelXRes/8-1)<<16));
     }
 
-    if ((Vratio == 1.0) || (!(radeon_output->Flags & RADEON_USE_RMX)) ||
+    if ((!Vscale) || (!(radeon_output->Flags & RADEON_USE_RMX)) ||
 	(radeon_output->rmx_type == RMX_CENTER)) {
 	save->fp_vert_stretch |= ((yres-1)<<12);
     } else {
-	save->fp_vert_stretch |= ((((unsigned long)(Vratio * RADEON_VERT_STRETCH_RATIO_MAX)) &
-				   RADEON_VERT_STRETCH_RATIO_MASK) |
+	CARD32 scale, inc;
+	inc = (save->fp_vert_stretch & RADEON_VERT_AUTO_RATIO_INC) ? 1 : 0;
+	scale = ((yres + inc) * RADEON_VERT_STRETCH_RATIO_MAX)
+	    / radeon_output->PanelYRes + 1;
+	save->fp_vert_stretch |= (((scale) & RADEON_VERT_STRETCH_RATIO_MASK) |
 				  RADEON_VERT_STRETCH_ENABLE |
 				  RADEON_VERT_STRETCH_BLEND |
 				  ((radeon_output->PanelYRes-1)<<12));
diff --git a/src/radeon_reg.h b/src/radeon_reg.h
index 9988ec6..c5ab0de 100644
--- a/src/radeon_reg.h
+++ b/src/radeon_reg.h
@@ -886,7 +886,8 @@
 #       define RADEON_VERT_STRETCH_LINEREP     (0     << 26)
 #       define RADEON_VERT_STRETCH_BLEND       (1     << 26)
 #       define RADEON_VERT_AUTO_RATIO_EN       (1     << 27)
-#       define RADEON_VERT_STRETCH_RESERVED    0xf1000000
+#	define RADEON_VERT_AUTO_RATIO_INC      (1     << 31)
+#       define RADEON_VERT_STRETCH_RESERVED    0x71000000
 #define RS400_FP_2ND_GEN_CNTL               0x0384
 #       define RS400_FP_2ND_ON              (1 << 0)
 #       define RS400_FP_2ND_BLANK_EN        (1 << 1)


More information about the xorg-commit mailing list