diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2007-04-02 01:37:38 -0700 |
---|---|---|
committer | root <root@treble.(none)> | 2007-04-02 01:37:38 -0700 |
commit | 5c03bd8acfcc814890fb13c891be4f135ea800d4 (patch) | |
tree | 591254322ffe71d2af282fdf5f17650049f196da /src | |
parent | 8f7769aadf175e8298f27387428214d6de49e6a5 (diff) |
G80: Get HW cursor working with RandR 1.2.
Diffstat (limited to 'src')
-rw-r--r-- | src/g80_cursor.c | 153 | ||||
-rw-r--r-- | src/g80_cursor.h | 8 | ||||
-rw-r--r-- | src/g80_display.c | 45 | ||||
-rw-r--r-- | src/g80_driver.c | 19 | ||||
-rw-r--r-- | src/g80_type.h | 5 |
5 files changed, 68 insertions, 162 deletions
diff --git a/src/g80_cursor.c b/src/g80_cursor.c index f416860..98a2736 100644 --- a/src/g80_cursor.c +++ b/src/g80_cursor.c @@ -21,8 +21,6 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#if 0 - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -37,36 +35,10 @@ #define CURSOR_PTR ((CARD32*)pNv->mem + pNv->videoRam * 256 - 0x1000) -static void G80SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) +void G80SetCursorPosition(xf86CrtcPtr crtc, int x, int y) { - G80Ptr pNv = G80PTR(pScrn); - CARD32 *dst = CURSOR_PTR; - CARD32 *src = pNv->tmpCursor; - int i, j; - - fg |= 0xff000000; - bg |= 0xff000000; - - for(i = 0; i < 128; i++) { - CARD32 b = *src++; - CARD32 m = *src++; - - for(j = 0; j < 32; j++) { - if(m & 1) - *dst = (b & 1) ? fg : bg; - else - *dst = 0; - b >>= 1; - m >>= 1; - dst++; - } - } -} - -static void G80SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) -{ - G80Ptr pNv = G80PTR(pScrn); - const int headOff = 0x1000*pNv->head; + G80Ptr pNv = G80PTR(crtc->scrn); + const int headOff = 0x1000*G80CrtcGetHead(crtc); x &= 0xffff; y &= 0xffff; @@ -74,115 +46,58 @@ static void G80SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) pNv->reg[(0x00647080 + headOff)/4] = 0; } -static void G80LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *bits) +void G80LoadCursorARGB(xf86CrtcPtr crtc, CARD32 *src) { - G80Ptr pNv = G80PTR(pScrn); - memcpy(pNv->tmpCursor, bits, sizeof(pNv->tmpCursor)); -} - -static void G80HideCursor(ScrnInfoPtr pScrn) -{ - G80Ptr pNv = G80PTR(pScrn); + G80Ptr pNv = G80PTR(crtc->scrn); + CARD32 *dst = CURSOR_PTR; - pNv->cursorVisible = FALSE; - G80DispHideCursor(G80PTR(pScrn), TRUE); + /* Assume cursor is 64x64 */ + memcpy(dst, src, 64 * 64 * 4); } -static void G80ShowCursor(ScrnInfoPtr pScrn) +Bool G80CursorAcquire(ScrnInfoPtr pScrn) { G80Ptr pNv = G80PTR(pScrn); + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int i; - pNv->cursorVisible = TRUE; - G80DispShowCursor(G80PTR(pScrn), TRUE); -} + if(!pNv->HWCursor) return TRUE; -static Bool G80UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) -{ - return TRUE; -} + /* Initialize the cursor on each head */ + for(i = 0; i < xf86_config->num_crtc; i++) { + const int headOff = 0x10 * G80CrtcGetHead(xf86_config->crtc[i]); -#ifdef ARGB_CURSOR -static Bool G80UseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs) -{ - if((pCurs->bits->width <= 64) && (pCurs->bits->height <= 64)) - return TRUE; + pNv->reg[(0x00610270+headOff)/4] = 0x2000; + while(pNv->reg[(0x00610270+headOff)/4] & 0x30000); - return FALSE; -} - -static void G80LoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) -{ - G80Ptr pNv = G80PTR(pScrn); - CARD32 *dst = CURSOR_PTR, *src = pCurs->bits->argb; - int y; - - for(y = 0; y < pCurs->bits->height; y++) { - memcpy(dst, src, pCurs->bits->width * 4); - memset(dst + pCurs->bits->width, 0, (64 - pCurs->bits->width) * 4); - src += pCurs->bits->width; - dst += 64; + pNv->reg[(0x00610270+headOff)/4] = 1; + while((pNv->reg[(0x00610270+headOff)/4] & 0x30000) != 0x10000); } - memset(dst, 0, (64 - y) * 64 * 4); -} -#endif - -Bool G80CursorAcquire(G80Ptr pNv) -{ - const int headOff = 0x10 * pNv->head; - - if(!pNv->HWCursor) return TRUE; - - pNv->reg[(0x00610270+headOff)/4] = 0x2000; - while(pNv->reg[(0x00610270+headOff)/4] & 0x30000); - - pNv->reg[(0x00610270+headOff)/4] = 1; - while((pNv->reg[(0x00610270+headOff)/4] & 0x30000) != 0x10000); - return TRUE; } -void G80CursorRelease(G80Ptr pNv) +void G80CursorRelease(ScrnInfoPtr pScrn) { - const int headOff = 0x10 * pNv->head; + G80Ptr pNv = G80PTR(pScrn); + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int i; if(!pNv->HWCursor) return; - pNv->reg[(0x00610270+headOff)/4] = 0; - while(pNv->reg[(0x00610270+headOff)/4] & 0x30000); + /* Release the cursor on each head */ + for(i = 0; i < xf86_config->num_crtc; i++) { + const int headOff = 0x10 * G80CrtcGetHead(xf86_config->crtc[i]); + + pNv->reg[(0x00610270+headOff)/4] = 0; + while(pNv->reg[(0x00610270+headOff)/4] & 0x30000); + } } Bool G80CursorInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - G80Ptr pNv = G80PTR(pScrn); - xf86CursorInfoPtr infoPtr; - - if(!pNv->HWCursor) - return TRUE; - - infoPtr = xf86CreateCursorInfoRec(); - if(!infoPtr) return FALSE; - - pNv->CursorInfo = infoPtr; - pNv->cursorVisible = FALSE; - - infoPtr->MaxWidth = infoPtr->MaxHeight = 64; - infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | - HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32; - infoPtr->SetCursorColors = G80SetCursorColors; - infoPtr->SetCursorPosition = G80SetCursorPosition; - infoPtr->LoadCursorImage = G80LoadCursorImage; - infoPtr->HideCursor = G80HideCursor; - infoPtr->ShowCursor = G80ShowCursor; - infoPtr->UseHWCursor = G80UseHWCursor; - -#ifdef ARGB_CURSOR - infoPtr->UseHWCursorARGB = G80UseHWCursorARGB; - infoPtr->LoadCursorARGB = G80LoadCursorARGB; -#endif - - return xf86InitCursor(pScreen, infoPtr); + return xf86_cursors_init(pScreen, 64, 64, + HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | + HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 | + HARDWARE_CURSOR_ARGB); } - -#endif diff --git a/src/g80_cursor.h b/src/g80_cursor.h index 9cd56ee..4d81d80 100644 --- a/src/g80_cursor.h +++ b/src/g80_cursor.h @@ -1,3 +1,7 @@ Bool G80CursorInit(ScreenPtr); -Bool G80CursorAcquire(G80Ptr); -void G80CursorRelease(G80Ptr); +Bool G80CursorAcquire(ScrnInfoPtr); +void G80CursorRelease(ScrnInfoPtr); + +/* CRTC cursor functions */ +void G80SetCursorPosition(xf86CrtcPtr crtc, int x, int y); +void G80LoadCursorARGB(xf86CrtcPtr crtc, CARD32 *src); diff --git a/src/g80_display.c b/src/g80_display.c index 2442e96..a5a1bc8 100644 --- a/src/g80_display.c +++ b/src/g80_display.c @@ -32,6 +32,7 @@ #include <unistd.h> #include "g80_type.h" +#include "g80_cursor.h" #include "g80_display.h" #include "g80_output.h" @@ -41,8 +42,11 @@ typedef struct G80CrtcPrivRec { Head head; int pclk; /* Target pixel clock in kHz */ + Bool cursorVisible; } G80CrtcPrivRec, *G80CrtcPrivPtr; +static void G80CrtcShowHideCursor(xf86CrtcPtr crtc, Bool show, Bool update); + /* * PLL calculation. pclk is in kHz. */ @@ -383,10 +387,11 @@ G80CrtcBlankScreen(xf86CrtcPtr crtc, Bool blank) { ScrnInfoPtr pScrn = crtc->scrn; G80Ptr pNv = G80PTR(pScrn); - const int headOff = 0x400 * G80CrtcGetHead(crtc); + G80CrtcPrivPtr pPriv = crtc->driver_private; + const int headOff = 0x400 * pPriv->head; if(blank) { - // G80DispHideCursor(pNv, FALSE); + G80CrtcShowHideCursor(crtc, FALSE, FALSE); C(0x00000840 + headOff, 0); C(0x00000844 + headOff, 0); @@ -405,8 +410,8 @@ G80CrtcBlankScreen(xf86CrtcPtr crtc, Bool blank) C(0x00000884 + headOff, (pNv->videoRam << 2) - 0x40); if(pNv->architecture != 0x50) C(0x0000089C + headOff, 1); - // if(pNv->cursorVisible) - // G80DispShowCursor(pNv, FALSE); + if(pPriv->cursorVisible) + G80CrtcShowHideCursor(crtc, TRUE, FALSE); C(0x00000840 + headOff, pScrn->depth == 8 ? 0x80000000 : 0xc0000000); C(0x00000844 + headOff, (pNv->videoRam * 1024 - 0x5000) >> 8); if(pNv->architecture != 0x50) @@ -470,33 +475,27 @@ G80CrtcDPMSSet(xf86CrtcPtr crtc, int mode) } /******************************** Cursor stuff ********************************/ -void G80CrtcShowCursor(xf86CrtcPtr crtc, Bool update) +static void G80CrtcShowHideCursor(xf86CrtcPtr crtc, Bool show, Bool update) { ScrnInfoPtr pScrn = crtc->scrn; + G80CrtcPrivPtr pPriv = crtc->driver_private; const int headOff = 0x400 * G80CrtcGetHead(crtc); - C(0x00000880 + headOff, 0x85000000); - if(update) C(0x00000080, 0); + C(0x00000880 + headOff, show ? 0x85000000 : 0x5000000); + if(update) { + pPriv->cursorVisible = show; + C(0x00000080, 0); + } } -void G80CrtcHideCursor(xf86CrtcPtr crtc, Bool update) +void G80CrtcShowCursor(xf86CrtcPtr crtc) { - ScrnInfoPtr pScrn = crtc->scrn; - const int headOff = 0x400 * G80CrtcGetHead(crtc); - - C(0x00000880 + headOff, 0x5000000); - if(update) C(0x00000080, 0); + G80CrtcShowHideCursor(crtc, TRUE, TRUE); } -void G80CrtcSetCursorPosition(xf86CrtcPtr crtc, int x, int y) +void G80CrtcHideCursor(xf86CrtcPtr crtc) { - G80Ptr pNv = G80PTR(crtc->scrn); - const int headOff = 0x647000 + 0x1000*G80CrtcGetHead(crtc); - - x &= 0xffff; - y &= 0xffff; - pNv->reg[(0x84 + headOff)/4] = y << 16 | x; - pNv->reg[(0x80 + headOff)/4] = 0; + G80CrtcShowHideCursor(crtc, FALSE, TRUE); } /******************************** CRTC stuff ********************************/ @@ -564,6 +563,10 @@ static const xf86CrtcFuncsRec g80_crtc_funcs = { .commit = G80CrtcCommit, .shadow_create = NULL, .shadow_destroy = NULL, + .set_cursor_position = G80SetCursorPosition, + .show_cursor = G80CrtcShowCursor, + .hide_cursor = G80CrtcHideCursor, + .load_cursor_argb = G80LoadCursorARGB, .destroy = NULL, }; diff --git a/src/g80_driver.c b/src/g80_driver.c index 2a5fceb..6ab92ee 100644 --- a/src/g80_driver.c +++ b/src/g80_driver.c @@ -397,15 +397,11 @@ fail: static Bool AcquireDisplay(ScrnInfoPtr pScrn) { -// G80Ptr pNv = G80PTR(pScrn); - if(!G80DispInit(pScrn)) return FALSE; -#if 0 - if(!G80CursorAcquire(pNv)) - return FALSE; - if(!G80DispSetMode(pScrn, pScrn->currentMode)) + if(!G80CursorAcquire(pScrn)) return FALSE; +#if 0 G80DispDPMSSet(pScrn, DPMSModeOn, 0); #endif xf86SetDesiredModes(pScrn); @@ -421,9 +417,7 @@ ReleaseDisplay(ScrnInfoPtr pScrn) { G80Ptr pNv = G80PTR(pScrn); -#if 0 - G80CursorRelease(pNv); -#endif + G80CursorRelease(pScrn); G80DispShutdown(pScrn); if(pNv->int10 && pNv->int10Mode) { @@ -451,10 +445,7 @@ G80CloseScreen(int scrnIndex, ScreenPtr pScreen) if(pNv->xaa) XAADestroyInfoRec(pNv->xaa); -#if 0 - if(pNv->HWCursor) - xf86DestroyCursorInfoRec(pNv->CursorInfo); -#endif + xf86_cursors_fini(pScreen); if(xf86ServerIsExiting()) { if(pNv->int10) xf86FreeInt10(pNv->int10); @@ -795,13 +786,11 @@ G80ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); /* Initialize hardware cursor. Must follow software cursor initialization. */ -#if 0 if(pNv->HWCursor && !G80CursorInit(pScreen)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Hardware cursor initialization failed\n"); pNv->HWCursor = FALSE; } -#endif /* Initialize default colormap */ if(!miCreateDefColormap(pScreen)) diff --git a/src/g80_type.h b/src/g80_type.h index a8788bc..95517e3 100644 --- a/src/g80_type.h +++ b/src/g80_type.h @@ -47,11 +47,6 @@ typedef struct G80Rec { Bool HWCursor; Bool NoAccel; - /* Cursor */ - xf86CursorInfoPtr CursorInfo; - Bool cursorVisible; - CARD32 tmpCursor[256]; /* Temporary 1bpp cursor image */ - /* XAA */ XAAInfoRecPtr xaa; CARD32 currentRop; |