From caf2e920f18cad1c57e945a4e474e63a65ec6a43 Mon Sep 17 00:00:00 2001 From: Stuart Bennett Date: Thu, 9 Oct 2008 17:07:30 +0100 Subject: [PATCH] Move cursor show/hide funcs to nv_hw, document nv40 bug, and set curctl2 before applying nv40 fix --- src/nv_crtc.c | 4 ++-- src/nv_cursor.c | 27 ++------------------------- src/nv_hw.c | 24 ++++++++++++++++++++++++ src/nv_proto.h | 4 ++-- src/nv_type.h | 6 +----- 5 files changed, 31 insertions(+), 34 deletions(-) diff --git a/src/nv_crtc.c b/src/nv_crtc.c index 36563bd..075b6d8 100644 --- a/src/nv_crtc.c +++ b/src/nv_crtc.c @@ -1439,9 +1439,9 @@ static void nv_crtc_load_state_ext(xf86CrtcPtr crtc, RIVA_HW_STATE *state, Bool NVWriteVgaCrtc(pNv, nv_crtc->head, NV_VGA_CRTCX_CURCTL0, regp->CRTC[NV_VGA_CRTCX_CURCTL0]); NVWriteVgaCrtc(pNv, nv_crtc->head, NV_VGA_CRTCX_CURCTL1, regp->CRTC[NV_VGA_CRTCX_CURCTL1]); - if (pNv->Architecture == NV_ARCH_40) /* HW bug */ - nv_crtc_fix_nv40_hw_cursor(pScrn, nv_crtc->head); NVWriteVgaCrtc(pNv, nv_crtc->head, NV_VGA_CRTCX_CURCTL2, regp->CRTC[NV_VGA_CRTCX_CURCTL2]); + if (pNv->Architecture == NV_ARCH_40) + nv_fix_nv40_hw_cursor(pNv, nv_crtc->head); NVWriteVgaCrtc(pNv, nv_crtc->head, NV_VGA_CRTCX_INTERLACE, regp->CRTC[NV_VGA_CRTCX_INTERLACE]); NVWriteVgaCrtc(pNv, nv_crtc->head, NV_VGA_CRTCX_26, regp->CRTC[NV_VGA_CRTCX_26]); diff --git a/src/nv_cursor.c b/src/nv_cursor.c index 09b0296..e1eaf39 100644 --- a/src/nv_cursor.c +++ b/src/nv_cursor.c @@ -330,41 +330,18 @@ Bool NVCursorInitRandr12(ScreenPtr pScreen) return xf86_cursors_init(pScreen, cursor_size, cursor_size, flags); } -void nv_crtc_fix_nv40_hw_cursor(ScrnInfoPtr pScrn, uint8_t head) -{ - NVPtr pNv = NVPTR(pScrn); - volatile uint32_t curpos = NVReadRAMDAC(pNv, head, NV_RAMDAC_CURSOR_POS); - NVWriteRAMDAC(pNv, head, NV_RAMDAC_CURSOR_POS, curpos); -} - -void nv_crtc_show_hide_cursor(ScrnInfoPtr pScrn, uint8_t head, Bool show) -{ - NVPtr pNv = NVPTR(pScrn); - int curctl1 = NVReadVgaCrtc(pNv, head, NV_VGA_CRTCX_CURCTL1); - - if (show) - NVWriteVgaCrtc(pNv, head, NV_VGA_CRTCX_CURCTL1, curctl1 | 1); - else - NVWriteVgaCrtc(pNv, head, NV_VGA_CRTCX_CURCTL1, curctl1 & ~1); - - if (pNv->Architecture == NV_ARCH_40) /* HW bug */ - nv_crtc_fix_nv40_hw_cursor(pScrn, head); -} - void nv_crtc_show_cursor(xf86CrtcPtr crtc) { struct nouveau_crtc *nv_crtc = to_nouveau_crtc(crtc); - ScrnInfoPtr pScrn = crtc->scrn; - nv_crtc_show_hide_cursor(pScrn, nv_crtc->head, TRUE); + nv_show_cursor(NVPTR(crtc->scrn), nv_crtc->head, true); } void nv_crtc_hide_cursor(xf86CrtcPtr crtc) { struct nouveau_crtc *nv_crtc = to_nouveau_crtc(crtc); - ScrnInfoPtr pScrn = crtc->scrn; - nv_crtc_show_hide_cursor(pScrn, nv_crtc->head, FALSE); + nv_show_cursor(NVPTR(crtc->scrn), nv_crtc->head, false); } void nv_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y) diff --git a/src/nv_hw.c b/src/nv_hw.c index 22b4751..89a7171 100644 --- a/src/nv_hw.c +++ b/src/nv_hw.c @@ -291,6 +291,30 @@ void NVBlankScreen(ScrnInfoPtr pScrn, int head, bool blank) NVVgaSeqReset(pNv, head, FALSE); } +void nv_fix_nv40_hw_cursor(NVPtr pNv, int head) +{ + /* on some nv40 (such as the "true" (in the NV_PFB_BOOT_0 sense) nv40, + * the gf6800gt) a hardware bug requires a write to PRAMDAC_CURSOR_POS + * for changes to the CRTC CURCTL regs to take effect, whether changing + * the pixmap location, or just showing/hiding the cursor + */ + volatile uint32_t curpos = NVReadRAMDAC(pNv, head, NV_RAMDAC_CURSOR_POS); + NVWriteRAMDAC(pNv, head, NV_RAMDAC_CURSOR_POS, curpos); +} + +void nv_show_cursor(NVPtr pNv, int head, bool show) +{ + int curctl1 = NVReadVgaCrtc(pNv, head, NV_VGA_CRTCX_CURCTL1); + + if (show) + NVWriteVgaCrtc(pNv, head, NV_VGA_CRTCX_CURCTL1, curctl1 | 1); + else + NVWriteVgaCrtc(pNv, head, NV_VGA_CRTCX_CURCTL1, curctl1 & ~1); + + if (pNv->Architecture == NV_ARCH_40) + nv_fix_nv40_hw_cursor(pNv, head); +} + int nv_decode_pll_highregs(NVPtr pNv, uint32_t pll1, uint32_t pll2, bool force_single, int refclk) { int M1, N1, M2 = 1, N2 = 1, log2P; diff --git a/src/nv_proto.h b/src/nv_proto.h index 892cfc3..f88757b 100644 --- a/src/nv_proto.h +++ b/src/nv_proto.h @@ -48,8 +48,6 @@ void nv_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y); void nv_crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg); void nv_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *image); void nv_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image); -void nv_crtc_fix_nv40_hw_cursor(ScrnInfoPtr pScrn, uint8_t head); -void nv_crtc_show_hide_cursor(ScrnInfoPtr pScrn, uint8_t head, Bool show); /* in nv_dma.c */ void NVSync(ScrnInfoPtr pScrn); @@ -115,6 +113,8 @@ void NVVgaProtect(NVPtr pNv, int head, bool protect); void NVSetOwner(ScrnInfoPtr pScrn, int head); void NVLockVgaCrtc(NVPtr pNv, int head, bool lock); void NVBlankScreen(ScrnInfoPtr pScrn, int head, bool blank); +void nv_fix_nv40_hw_cursor(NVPtr pNv, int head); +void nv_show_cursor(NVPtr pNv, int head, bool show); int nv_decode_pll_highregs(NVPtr pNv, uint32_t pll1, uint32_t pll2, bool force_single, int refclk); void nv4_10UpdateArbitrationSettings(ScrnInfoPtr pScrn, int VClk, int bpp, uint8_t *burst, uint16_t *lwm); void nv30UpdateArbitrationSettings(uint8_t *burst, uint16_t *lwm); diff --git a/src/nv_type.h b/src/nv_type.h index 1c72a61..5b40cf9 100644 --- a/src/nv_type.h +++ b/src/nv_type.h @@ -522,11 +522,7 @@ typedef struct _NVRec { #define NVPTR(p) ((NVPtr)((p)->driverPrivate)) -#define NVShowHideCursor(pScrn, show) do { \ - NVPtr pNv = NVPTR(pScrn); \ - nv_crtc_show_hide_cursor(pScrn, pNv->cur_head, show); \ -} while(0) - +#define NVShowHideCursor(pScrn, show) nv_show_cursor(NVPTR(pScrn), NVPTR(pScrn)->cur_head, show) #define NVLockUnlock(pScrn, lock) NVLockVgaCrtc(NVPTR(pScrn), NVPTR(pScrn)->cur_head, lock) #define nvReadCurVGA(pNv, reg) NVReadVgaCrtc(pNv, pNv->cur_head, reg) -- 2.32.0.93.g670b81a890