summaryrefslogtreecommitdiff
path: root/src/legacy_output.c
diff options
context:
space:
mode:
authorEgbert Eich <eich@freedesktop.org>2008-05-20 11:16:15 +0200
committerEgbert Eich <eich@freedesktop.org>2008-05-20 19:52:50 +0200
commit19e97f74e39fc2b35727708ac429de33d0b70162 (patch)
treeffd0bd26042917622e60fafc84590ced07df3a6e /src/legacy_output.c
parenta4f3d0088ba763ed8eab1d331959b5ecde8262e8 (diff)
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.
Diffstat (limited to 'src/legacy_output.c')
-rw-r--r--src/legacy_output.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/legacy_output.c b/src/legacy_output.c
index 337370bc..4df81abd 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));