xf86-video-ati: Branch 'ati-6.7-branch' - 3 commits

Michel Daenzer daenzer at kemper.freedesktop.org
Thu Aug 23 03:18:10 PDT 2007


 src/radeon.h        |   21 +++++++++++++++++++++
 src/radeon_driver.c |   45 +++++++++++++++++++++++----------------------
 2 files changed, 44 insertions(+), 22 deletions(-)

New commits:
diff-tree d0f900c857585804fedd501bcf0a603fead271ce (from 732880bfaab2224fd6d38086237e17de843def7d)
Author: Alon Ziv <alonz at nolaviz.org>
Date:   Mon Jul 30 22:47:59 2007 +0300

    radeon: Sane handling of timeouts in WaitForVerticalSync(2).
    
    RADEONWaitForVerticalSync() and RADEONWaitForVerticalSync2() need to wait
    for a timeout specified in milliseconds; looping around usleep() causes
    the timeout to be unnecessarily long, as the OS may sleep longer than
    requested (on Linux the minimum actual sleep value may be several ms).
    
    The new logic uses gettimeofday() in the loop to see when the (absolute)
    timeout has arrived.
    
    Signed-off-by: Alon Ziv <alonz at nolaviz.org>

diff --git a/src/radeon.h b/src/radeon.h
index b19b017..9e70ab5 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -39,6 +39,8 @@
 
 #include <stdlib.h>		/* For abs() */
 #include <unistd.h>		/* For usleep() */
+#include <sys/time.h>		/* For
+#include <time.h>		 * gettimeofday() */
 
 #include "xf86str.h"
 #include "compiler.h"
@@ -189,6 +191,8 @@ typedef struct _region {
 #define RADEON_IDLE_RETRY      16 /* Fall out of idle loops after this count */
 #define RADEON_TIMEOUT    2000000 /* Fall out of wait loops after this count */
 
+#define RADEON_VSYNC_TIMEOUT	20000 /* Maximum wait for VSYNC (in usecs) */
+
 /* Buffer are aligned on 4096 byte boundaries */
 #define RADEON_BUFFER_ALIGN 0x00000fff
 #define RADEON_VBIOS_SIZE 0x00010000
@@ -1175,4 +1179,21 @@ static __inline__ void RADEON_SYNC(RADEO
 #endif
 }
 
+static __inline__ void radeon_init_timeout(struct timeval *endtime,
+    unsigned int timeout)
+{
+    gettimeofday(endtime, NULL);
+    endtime->tv_usec += timeout;
+    endtime->tv_sec += endtime->tv_usec / 1000000;
+    endtime->tv_usec %= 1000000;
+}
+
+static __inline__ int radeon_timedout(const struct timeval *endtime)
+{
+    struct timeval now;
+    gettimeofday(&now, NULL);
+    return now.tv_sec == endtime->tv_sec ?
+        now.tv_usec > endtime->tv_usec : now.tv_sec > endtime->tv_sec;
+}
+
 #endif /* _RADEON_H_ */
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index 894131f..418b39d 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -759,7 +759,7 @@ void RADEONWaitForVerticalSync(ScrnInfoP
     RADEONInfoPtr  info       = RADEONPTR(pScrn);
     unsigned char *RADEONMMIO = info->MMIO;
     CARD32         crtc_gen_cntl;
-    int            i;
+    struct timeval timeout;
 
     crtc_gen_cntl = INREG(RADEON_CRTC_GEN_CNTL);
     if ((crtc_gen_cntl & RADEON_CRTC_DISP_REQ_EN_B) ||
@@ -770,10 +770,10 @@ void RADEONWaitForVerticalSync(ScrnInfoP
     OUTREG(RADEON_CRTC_STATUS, RADEON_CRTC_VBLANK_SAVE_CLEAR);
 
     /* Wait for it to go back up */
-    for (i = 0; i < RADEON_TIMEOUT/1000; i++) {
-	if (INREG(RADEON_CRTC_STATUS) & RADEON_CRTC_VBLANK_SAVE) break;
-	usleep(1);
-    }
+    radeon_init_timeout(&timeout, RADEON_VSYNC_TIMEOUT);
+    while (!(INREG(RADEON_CRTC_STATUS) & RADEON_CRTC_VBLANK_SAVE) &&
+        !radeon_timedout(&timeout))
+	usleep(100);
 }
 
 /* Wait for vertical sync on secondary CRTC */
@@ -782,7 +782,7 @@ void RADEONWaitForVerticalSync2(ScrnInfo
     RADEONInfoPtr  info       = RADEONPTR(pScrn);
     unsigned char *RADEONMMIO = info->MMIO;
     CARD32         crtc2_gen_cntl;
-    int            i;
+    struct timeval timeout;
  
     crtc2_gen_cntl = INREG(RADEON_CRTC2_GEN_CNTL);
     if ((crtc2_gen_cntl & RADEON_CRTC2_DISP_REQ_EN_B) ||
@@ -793,10 +793,10 @@ void RADEONWaitForVerticalSync2(ScrnInfo
     OUTREG(RADEON_CRTC2_STATUS, RADEON_CRTC2_VBLANK_SAVE_CLEAR);
 
     /* Wait for it to go back up */
-    for (i = 0; i < RADEON_TIMEOUT/1000; i++) {
-	if (INREG(RADEON_CRTC2_STATUS) & RADEON_CRTC2_VBLANK_SAVE) break;
-	usleep(1);
-    }
+    radeon_init_timeout(&timeout, RADEON_VSYNC_TIMEOUT);
+    while (!(INREG(RADEON_CRTC2_STATUS) & RADEON_CRTC2_VBLANK_SAVE) &&
+        !radeon_timedout(&timeout))
+	usleep(100);
 }
 
 
diff-tree 732880bfaab2224fd6d38086237e17de843def7d (from 6b736a5c25d968bb09e229e0fbb82162e8447783)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Wed Aug 22 15:32:23 2007 +0200

    radeon: Remove declarations of unused variables.

diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index 8d868f5..894131f 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -1994,7 +1994,7 @@ static Bool RADEONPreInitModes(ScrnInfoP
     int            modesFound;
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
     char           *s;
-    RADEONConnector *connector;
+
     /* This option has two purposes:
      *
      * 1. For CRT, if this option is on, xf86ValidateModes (to
@@ -5135,7 +5135,6 @@ static void RADEONRestoreMode(ScrnInfoPt
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
     RADEONController* pCRTC1 = pRADEONEnt->Controller[0];
     RADEONController* pCRTC2 = pRADEONEnt->Controller[1];
-    RADEONConnector *pPort;
 
     xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
 		   "RADEONRestoreMode(%p)\n", restore);
diff-tree 6b736a5c25d968bb09e229e0fbb82162e8447783 (from 26aacfd90e2502c6e2a6c10761b4b2da7971b2bc)
Author: Sascha Sommer <saschasommer at freenet.de>
Date:   Wed Aug 22 15:28:58 2007 +0200

    radeon: Round down RMX stretch ratios.
    
    Fixes issues with RMX scaling, see
    https://bugs.freedesktop.org/show_bug.cgi?id=8983 .

diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index 466fd46..8d868f5 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -5797,21 +5797,23 @@ static void RADEONInitRMXRegisters(ScrnI
     if (Hratio == 1.0 || !(mode->Flags & RADEON_USE_RMX)) {
 	save->fp_horz_stretch |= ((xres/8-1)<<16);
     } else {
-	save->fp_horz_stretch |= ((((unsigned long)(Hratio * RADEON_HORZ_STRETCH_RATIO_MAX +
-				     0.5)) & RADEON_HORZ_STRETCH_RATIO_MASK) |
-				    RADEON_HORZ_STRETCH_BLEND |
-				    RADEON_HORZ_STRETCH_ENABLE |
-				    ((info->PanelXRes/8-1)<<16));
+	save->fp_horz_stretch |= ((((unsigned long)
+				    (Hratio * RADEON_HORZ_STRETCH_RATIO_MAX)) &
+				   RADEON_HORZ_STRETCH_RATIO_MASK) |
+				  RADEON_HORZ_STRETCH_BLEND |
+				  RADEON_HORZ_STRETCH_ENABLE |
+				  ((info->PanelXRes/8-1)<<16));
     }
 
     if (Vratio == 1.0 || !(mode->Flags & RADEON_USE_RMX)) {
 	save->fp_vert_stretch |= ((yres-1)<<12);
     } else {
-	save->fp_vert_stretch |= ((((unsigned long)(Vratio * RADEON_VERT_STRETCH_RATIO_MAX +
-						0.5)) & RADEON_VERT_STRETCH_RATIO_MASK) |
-				      RADEON_VERT_STRETCH_ENABLE |
-				      RADEON_VERT_STRETCH_BLEND |
-				      ((info->PanelYRes-1)<<12));
+	save->fp_vert_stretch |= ((((unsigned long)
+				    (Vratio * RADEON_VERT_STRETCH_RATIO_MAX)) &
+				   RADEON_VERT_STRETCH_RATIO_MASK) |
+				  RADEON_VERT_STRETCH_ENABLE |
+				  RADEON_VERT_STRETCH_BLEND |
+				  ((info->PanelYRes-1)<<12));
     }
 
 }


More information about the xorg-commit mailing list