diff options
author | Michel Dänzer <michel@tungstengraphics.com> | 2007-07-06 09:50:50 +0200 |
---|---|---|
committer | Michel Dänzer <michel@tungstengraphics.com> | 2007-07-06 09:50:50 +0200 |
commit | 5b726b63906419ccb3de2e065f9bf7ae875ccdf3 (patch) | |
tree | 878856fa98b298073bd38c5ef31fa6985e1307b4 | |
parent | 7f2a1cf2753c0c97b1290469a15322f7549f78ae (diff) |
radeon: Improve vblank counter.
The frame counter seems to increase only at the end of vertical blank, so we
need to add 1 while in vertical blank.
-rw-r--r-- | shared-core/radeon_drv.h | 3 | ||||
-rw-r--r-- | shared-core/radeon_irq.c | 12 |
2 files changed, 10 insertions, 5 deletions
diff --git a/shared-core/radeon_drv.h b/shared-core/radeon_drv.h index bb69c106..418b6e78 100644 --- a/shared-core/radeon_drv.h +++ b/shared-core/radeon_drv.h @@ -512,6 +512,9 @@ extern int r300_do_cp_cmdbuf(drm_device_t *dev, DRMFILE filp, #define RADEON_CRTC_CRNT_FRAME 0x0214 #define RADEON_CRTC2_CRNT_FRAME 0x0314 +#define RADEON_CRTC_STATUS 0x005c +#define RADEON_CRTC2_STATUS 0x03fc + #define RADEON_GEN_INT_CNTL 0x0040 # define RADEON_CRTC_VBLANK_MASK (1 << 0) # define RADEON_CRTC2_VBLANK_MASK (1 << 9) diff --git a/shared-core/radeon_irq.c b/shared-core/radeon_irq.c index d7f10f93..4ff8a5c3 100644 --- a/shared-core/radeon_irq.c +++ b/shared-core/radeon_irq.c @@ -178,16 +178,18 @@ static int radeon_wait_irq(drm_device_t * dev, int swi_nr) u32 radeon_get_vblank_counter(drm_device_t *dev, int crtc) { drm_radeon_private_t *dev_priv = dev->dev_private; - u32 crtc_cnt_reg; + u32 crtc_cnt_reg, crtc_status_reg; - if (crtc == 0) + if (crtc == 0) { crtc_cnt_reg = RADEON_CRTC_CRNT_FRAME; - else if (crtc == 1) + crtc_status_reg = RADEON_CRTC_STATUS; + } else if (crtc == 1) { crtc_cnt_reg = RADEON_CRTC2_CRNT_FRAME; - else + crtc_status_reg = RADEON_CRTC2_STATUS; + } else return 0; - return RADEON_READ(crtc_cnt_reg); + return RADEON_READ(crtc_cnt_reg) + (RADEON_READ(crtc_status_reg) & 1); } /* Needs the lock as it touches the ring. |