132b578d3Smrg/* 232b578d3Smrg * Copyright 2003 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org 332b578d3Smrg * 432b578d3Smrg * Permission to use, copy, modify, distribute, and sell this software and its 532b578d3Smrg * documentation for any purpose is hereby granted without fee, provided that 632b578d3Smrg * the above copyright notice appear in all copies and that both that copyright 732b578d3Smrg * notice and this permission notice appear in supporting documentation, and 832b578d3Smrg * that the name of Marc Aurele La France not be used in advertising or 932b578d3Smrg * publicity pertaining to distribution of the software without specific, 1032b578d3Smrg * written prior permission. Marc Aurele La France makes no representations 1132b578d3Smrg * about the suitability of this software for any purpose. It is provided 1232b578d3Smrg * "as-is" without express or implied warranty. 1332b578d3Smrg * 1432b578d3Smrg * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 1532b578d3Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO 1632b578d3Smrg * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR 1732b578d3Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 1832b578d3Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 1932b578d3Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 2032b578d3Smrg * PERFORMANCE OF THIS SOFTWARE. 2132b578d3Smrg */ 2232b578d3Smrg 2332b578d3Smrg#ifdef HAVE_CONFIG_H 2432b578d3Smrg#include "config.h" 2532b578d3Smrg#endif 2632b578d3Smrg 2732b578d3Smrg#include "ati.h" 2832b578d3Smrg#include "aticursor.h" 2932b578d3Smrg#include "atimach64accel.h" 3032b578d3Smrg#include "atimach64io.h" 3132b578d3Smrg 3232b578d3Smrg/* 3332b578d3Smrg * ATIMach64SetCursorColours -- 3432b578d3Smrg * 3532b578d3Smrg * Set hardware cursor foreground and background colours. 3632b578d3Smrg */ 3732b578d3Smrgstatic void 3832b578d3SmrgATIMach64SetCursorColours 3932b578d3Smrg( 4032b578d3Smrg ScrnInfoPtr pScreenInfo, 4132b578d3Smrg int fg, 4232b578d3Smrg int bg 4332b578d3Smrg) 4432b578d3Smrg{ 4532b578d3Smrg ATIPtr pATI = ATIPTR(pScreenInfo); 4632b578d3Smrg 4732b578d3Smrg outr(CUR_CLR0, SetBits(fg, CUR_CLR)); 4832b578d3Smrg outr(CUR_CLR1, SetBits(bg, CUR_CLR)); 4932b578d3Smrg} 5032b578d3Smrg 5132b578d3Smrg/* 5232b578d3Smrg * ATIMach64SetCursorPosition -- 5332b578d3Smrg * 5432b578d3Smrg * Set position of hardware cursor. 5532b578d3Smrg */ 5632b578d3Smrgstatic void 5732b578d3SmrgATIMach64SetCursorPosition 5832b578d3Smrg( 5932b578d3Smrg ScrnInfoPtr pScreenInfo, 6032b578d3Smrg int x, 6132b578d3Smrg int y 6232b578d3Smrg) 6332b578d3Smrg{ 6432b578d3Smrg ATIPtr pATI = ATIPTR(pScreenInfo); 6532b578d3Smrg CARD16 CursorXOffset, CursorYOffset; 6632b578d3Smrg 6732b578d3Smrg /* Adjust x & y when the cursor is partially obscured */ 6832b578d3Smrg if (x < 0) 6932b578d3Smrg { 7032b578d3Smrg if ((CursorXOffset = -x) > 63) 7132b578d3Smrg CursorXOffset = 63; 7232b578d3Smrg x = 0; 7332b578d3Smrg } 7432b578d3Smrg else 7532b578d3Smrg { 7632b578d3Smrg CursorXOffset = pScreenInfo->frameX1 - pScreenInfo->frameX0; 7732b578d3Smrg if (x > CursorXOffset) 7832b578d3Smrg x = CursorXOffset; 7932b578d3Smrg CursorXOffset = 0; 8032b578d3Smrg } 8132b578d3Smrg 8232b578d3Smrg if (y < 0) 8332b578d3Smrg { 8432b578d3Smrg if ((CursorYOffset = -y) > 63) 8532b578d3Smrg CursorYOffset = 63; 8632b578d3Smrg y = 0; 8732b578d3Smrg } 8832b578d3Smrg else 8932b578d3Smrg { 9032b578d3Smrg CursorYOffset = pScreenInfo->frameY1 - pScreenInfo->frameY0; 9132b578d3Smrg if (y > CursorYOffset) 9232b578d3Smrg y = CursorYOffset; 9332b578d3Smrg CursorYOffset = 0; 9432b578d3Smrg } 9532b578d3Smrg 9632b578d3Smrg /* Adjust for multiscanned modes */ 9732b578d3Smrg if (pScreenInfo->currentMode->Flags & V_DBLSCAN) 9832b578d3Smrg y *= 2; 9932b578d3Smrg if (pScreenInfo->currentMode->VScan > 1) 10032b578d3Smrg y *= pScreenInfo->currentMode->VScan; 10132b578d3Smrg 10232b578d3Smrg do 10332b578d3Smrg { 10432b578d3Smrg if (CursorYOffset != pATI->CursorYOffset) 10532b578d3Smrg { 10632b578d3Smrg pATI->CursorYOffset = CursorYOffset; 10732b578d3Smrg outr(CUR_OFFSET, ((CursorYOffset << 4) + pATI->CursorOffset) >> 3); 10832b578d3Smrg } 10932b578d3Smrg else if (CursorXOffset == pATI->CursorXOffset) 11032b578d3Smrg break; 11132b578d3Smrg 11232b578d3Smrg pATI->CursorXOffset = CursorXOffset; 11332b578d3Smrg outr(CUR_HORZ_VERT_OFF, SetBits(CursorXOffset, CUR_HORZ_OFF) | 11432b578d3Smrg SetBits(CursorYOffset, CUR_VERT_OFF)); 11532b578d3Smrg } while (0); 11632b578d3Smrg 11732b578d3Smrg outr(CUR_HORZ_VERT_POSN, 11832b578d3Smrg SetBits(x, CUR_HORZ_POSN) | SetBits(y, CUR_VERT_POSN)); 11932b578d3Smrg} 12032b578d3Smrg 12132b578d3Smrg/* 12232b578d3Smrg * ATIMach64LoadCursorImage -- 12332b578d3Smrg * 12432b578d3Smrg * Copy hardware cursor image into offscreen video memory. 12532b578d3Smrg */ 12632b578d3Smrgstatic void 12732b578d3SmrgATIMach64LoadCursorImage 12832b578d3Smrg( 12932b578d3Smrg ScrnInfoPtr pScreenInfo, 13032b578d3Smrg CARD8 *pImage 13132b578d3Smrg) 13232b578d3Smrg{ 13332b578d3Smrg ATIPtr pATI = ATIPTR(pScreenInfo); 13432b578d3Smrg CARD32 *pSrc = (pointer)pImage; 13532b578d3Smrg volatile CARD32 *pDst = pATI->pCursorImage; 13632b578d3Smrg 13732b578d3Smrg#ifdef XF86DRI_DEVEL 13832b578d3Smrg 13932b578d3Smrg /* XAA Sync requires the DRM lock if DRI enabled */ 14032b578d3Smrg ATIDRILock(pScreenInfo); 14132b578d3Smrg 14232b578d3Smrg#endif /* XF86DRI_DEVEL */ 14332b578d3Smrg 14432b578d3Smrg /* Synchronise video memory accesses */ 14532b578d3Smrg ATIMach64Sync(pScreenInfo); 14632b578d3Smrg 14732b578d3Smrg# if defined(ATIMove32) 14832b578d3Smrg 14932b578d3Smrg { 15032b578d3Smrg ATIMove32(pDst, pSrc, 256); 15132b578d3Smrg } 15232b578d3Smrg 15332b578d3Smrg# else 15432b578d3Smrg 15532b578d3Smrg { 15632b578d3Smrg /* This is lengthy, but it does maximise burst modes */ 15732b578d3Smrg pDst[ 0] = pSrc[ 0]; pDst[ 1] = pSrc[ 1]; 15832b578d3Smrg pDst[ 2] = pSrc[ 2]; pDst[ 3] = pSrc[ 3]; 15932b578d3Smrg pDst[ 4] = pSrc[ 4]; pDst[ 5] = pSrc[ 5]; 16032b578d3Smrg pDst[ 6] = pSrc[ 6]; pDst[ 7] = pSrc[ 7]; 16132b578d3Smrg pDst[ 8] = pSrc[ 8]; pDst[ 9] = pSrc[ 9]; 16232b578d3Smrg pDst[ 10] = pSrc[ 10]; pDst[ 11] = pSrc[ 11]; 16332b578d3Smrg pDst[ 12] = pSrc[ 12]; pDst[ 13] = pSrc[ 13]; 16432b578d3Smrg pDst[ 14] = pSrc[ 14]; pDst[ 15] = pSrc[ 15]; 16532b578d3Smrg pDst[ 16] = pSrc[ 16]; pDst[ 17] = pSrc[ 17]; 16632b578d3Smrg pDst[ 18] = pSrc[ 18]; pDst[ 19] = pSrc[ 19]; 16732b578d3Smrg pDst[ 20] = pSrc[ 20]; pDst[ 21] = pSrc[ 21]; 16832b578d3Smrg pDst[ 22] = pSrc[ 22]; pDst[ 23] = pSrc[ 23]; 16932b578d3Smrg pDst[ 24] = pSrc[ 24]; pDst[ 25] = pSrc[ 25]; 17032b578d3Smrg pDst[ 26] = pSrc[ 26]; pDst[ 27] = pSrc[ 27]; 17132b578d3Smrg pDst[ 28] = pSrc[ 28]; pDst[ 29] = pSrc[ 29]; 17232b578d3Smrg pDst[ 30] = pSrc[ 30]; pDst[ 31] = pSrc[ 31]; 17332b578d3Smrg pDst[ 32] = pSrc[ 32]; pDst[ 33] = pSrc[ 33]; 17432b578d3Smrg pDst[ 34] = pSrc[ 34]; pDst[ 35] = pSrc[ 35]; 17532b578d3Smrg pDst[ 36] = pSrc[ 36]; pDst[ 37] = pSrc[ 37]; 17632b578d3Smrg pDst[ 38] = pSrc[ 38]; pDst[ 39] = pSrc[ 39]; 17732b578d3Smrg pDst[ 40] = pSrc[ 40]; pDst[ 41] = pSrc[ 41]; 17832b578d3Smrg pDst[ 42] = pSrc[ 42]; pDst[ 43] = pSrc[ 43]; 17932b578d3Smrg pDst[ 44] = pSrc[ 44]; pDst[ 45] = pSrc[ 45]; 18032b578d3Smrg pDst[ 46] = pSrc[ 46]; pDst[ 47] = pSrc[ 47]; 18132b578d3Smrg pDst[ 48] = pSrc[ 48]; pDst[ 49] = pSrc[ 49]; 18232b578d3Smrg pDst[ 50] = pSrc[ 50]; pDst[ 51] = pSrc[ 51]; 18332b578d3Smrg pDst[ 52] = pSrc[ 52]; pDst[ 53] = pSrc[ 53]; 18432b578d3Smrg pDst[ 54] = pSrc[ 54]; pDst[ 55] = pSrc[ 55]; 18532b578d3Smrg pDst[ 56] = pSrc[ 56]; pDst[ 57] = pSrc[ 57]; 18632b578d3Smrg pDst[ 58] = pSrc[ 58]; pDst[ 59] = pSrc[ 59]; 18732b578d3Smrg pDst[ 60] = pSrc[ 60]; pDst[ 61] = pSrc[ 61]; 18832b578d3Smrg pDst[ 62] = pSrc[ 62]; pDst[ 63] = pSrc[ 63]; 18932b578d3Smrg pDst[ 64] = pSrc[ 64]; pDst[ 65] = pSrc[ 65]; 19032b578d3Smrg pDst[ 66] = pSrc[ 66]; pDst[ 67] = pSrc[ 67]; 19132b578d3Smrg pDst[ 68] = pSrc[ 68]; pDst[ 69] = pSrc[ 69]; 19232b578d3Smrg pDst[ 70] = pSrc[ 70]; pDst[ 71] = pSrc[ 71]; 19332b578d3Smrg pDst[ 72] = pSrc[ 72]; pDst[ 73] = pSrc[ 73]; 19432b578d3Smrg pDst[ 74] = pSrc[ 74]; pDst[ 75] = pSrc[ 75]; 19532b578d3Smrg pDst[ 76] = pSrc[ 76]; pDst[ 77] = pSrc[ 77]; 19632b578d3Smrg pDst[ 78] = pSrc[ 78]; pDst[ 79] = pSrc[ 79]; 19732b578d3Smrg pDst[ 80] = pSrc[ 80]; pDst[ 81] = pSrc[ 81]; 19832b578d3Smrg pDst[ 82] = pSrc[ 82]; pDst[ 83] = pSrc[ 83]; 19932b578d3Smrg pDst[ 84] = pSrc[ 84]; pDst[ 85] = pSrc[ 85]; 20032b578d3Smrg pDst[ 86] = pSrc[ 86]; pDst[ 87] = pSrc[ 87]; 20132b578d3Smrg pDst[ 88] = pSrc[ 88]; pDst[ 89] = pSrc[ 89]; 20232b578d3Smrg pDst[ 90] = pSrc[ 90]; pDst[ 91] = pSrc[ 91]; 20332b578d3Smrg pDst[ 92] = pSrc[ 92]; pDst[ 93] = pSrc[ 93]; 20432b578d3Smrg pDst[ 94] = pSrc[ 94]; pDst[ 95] = pSrc[ 95]; 20532b578d3Smrg pDst[ 96] = pSrc[ 96]; pDst[ 97] = pSrc[ 97]; 20632b578d3Smrg pDst[ 98] = pSrc[ 98]; pDst[ 99] = pSrc[ 99]; 20732b578d3Smrg pDst[100] = pSrc[100]; pDst[101] = pSrc[101]; 20832b578d3Smrg pDst[102] = pSrc[102]; pDst[103] = pSrc[103]; 20932b578d3Smrg pDst[104] = pSrc[104]; pDst[105] = pSrc[105]; 21032b578d3Smrg pDst[106] = pSrc[106]; pDst[107] = pSrc[107]; 21132b578d3Smrg pDst[108] = pSrc[108]; pDst[109] = pSrc[109]; 21232b578d3Smrg pDst[110] = pSrc[110]; pDst[111] = pSrc[111]; 21332b578d3Smrg pDst[112] = pSrc[112]; pDst[113] = pSrc[113]; 21432b578d3Smrg pDst[114] = pSrc[114]; pDst[115] = pSrc[115]; 21532b578d3Smrg pDst[116] = pSrc[116]; pDst[117] = pSrc[117]; 21632b578d3Smrg pDst[118] = pSrc[118]; pDst[119] = pSrc[119]; 21732b578d3Smrg pDst[120] = pSrc[120]; pDst[121] = pSrc[121]; 21832b578d3Smrg pDst[122] = pSrc[122]; pDst[123] = pSrc[123]; 21932b578d3Smrg pDst[124] = pSrc[124]; pDst[125] = pSrc[125]; 22032b578d3Smrg pDst[126] = pSrc[126]; pDst[127] = pSrc[127]; 22132b578d3Smrg pDst[128] = pSrc[128]; pDst[129] = pSrc[129]; 22232b578d3Smrg pDst[130] = pSrc[130]; pDst[131] = pSrc[131]; 22332b578d3Smrg pDst[132] = pSrc[132]; pDst[133] = pSrc[133]; 22432b578d3Smrg pDst[134] = pSrc[134]; pDst[135] = pSrc[135]; 22532b578d3Smrg pDst[136] = pSrc[136]; pDst[137] = pSrc[137]; 22632b578d3Smrg pDst[138] = pSrc[138]; pDst[139] = pSrc[139]; 22732b578d3Smrg pDst[140] = pSrc[140]; pDst[141] = pSrc[141]; 22832b578d3Smrg pDst[142] = pSrc[142]; pDst[143] = pSrc[143]; 22932b578d3Smrg pDst[144] = pSrc[144]; pDst[145] = pSrc[145]; 23032b578d3Smrg pDst[146] = pSrc[146]; pDst[147] = pSrc[147]; 23132b578d3Smrg pDst[148] = pSrc[148]; pDst[149] = pSrc[149]; 23232b578d3Smrg pDst[150] = pSrc[150]; pDst[151] = pSrc[151]; 23332b578d3Smrg pDst[152] = pSrc[152]; pDst[153] = pSrc[153]; 23432b578d3Smrg pDst[154] = pSrc[154]; pDst[155] = pSrc[155]; 23532b578d3Smrg pDst[156] = pSrc[156]; pDst[157] = pSrc[157]; 23632b578d3Smrg pDst[158] = pSrc[158]; pDst[159] = pSrc[159]; 23732b578d3Smrg pDst[160] = pSrc[160]; pDst[161] = pSrc[161]; 23832b578d3Smrg pDst[162] = pSrc[162]; pDst[163] = pSrc[163]; 23932b578d3Smrg pDst[164] = pSrc[164]; pDst[165] = pSrc[165]; 24032b578d3Smrg pDst[166] = pSrc[166]; pDst[167] = pSrc[167]; 24132b578d3Smrg pDst[168] = pSrc[168]; pDst[169] = pSrc[169]; 24232b578d3Smrg pDst[170] = pSrc[170]; pDst[171] = pSrc[171]; 24332b578d3Smrg pDst[172] = pSrc[172]; pDst[173] = pSrc[173]; 24432b578d3Smrg pDst[174] = pSrc[174]; pDst[175] = pSrc[175]; 24532b578d3Smrg pDst[176] = pSrc[176]; pDst[177] = pSrc[177]; 24632b578d3Smrg pDst[178] = pSrc[178]; pDst[179] = pSrc[179]; 24732b578d3Smrg pDst[180] = pSrc[180]; pDst[181] = pSrc[181]; 24832b578d3Smrg pDst[182] = pSrc[182]; pDst[183] = pSrc[183]; 24932b578d3Smrg pDst[184] = pSrc[184]; pDst[185] = pSrc[185]; 25032b578d3Smrg pDst[186] = pSrc[186]; pDst[187] = pSrc[187]; 25132b578d3Smrg pDst[188] = pSrc[188]; pDst[189] = pSrc[189]; 25232b578d3Smrg pDst[190] = pSrc[190]; pDst[191] = pSrc[191]; 25332b578d3Smrg pDst[192] = pSrc[192]; pDst[193] = pSrc[193]; 25432b578d3Smrg pDst[194] = pSrc[194]; pDst[195] = pSrc[195]; 25532b578d3Smrg pDst[196] = pSrc[196]; pDst[197] = pSrc[197]; 25632b578d3Smrg pDst[198] = pSrc[198]; pDst[199] = pSrc[199]; 25732b578d3Smrg pDst[200] = pSrc[200]; pDst[201] = pSrc[201]; 25832b578d3Smrg pDst[202] = pSrc[202]; pDst[203] = pSrc[203]; 25932b578d3Smrg pDst[204] = pSrc[204]; pDst[205] = pSrc[205]; 26032b578d3Smrg pDst[206] = pSrc[206]; pDst[207] = pSrc[207]; 26132b578d3Smrg pDst[208] = pSrc[208]; pDst[209] = pSrc[209]; 26232b578d3Smrg pDst[210] = pSrc[210]; pDst[211] = pSrc[211]; 26332b578d3Smrg pDst[212] = pSrc[212]; pDst[213] = pSrc[213]; 26432b578d3Smrg pDst[214] = pSrc[214]; pDst[215] = pSrc[215]; 26532b578d3Smrg pDst[216] = pSrc[216]; pDst[217] = pSrc[217]; 26632b578d3Smrg pDst[218] = pSrc[218]; pDst[219] = pSrc[219]; 26732b578d3Smrg pDst[220] = pSrc[220]; pDst[221] = pSrc[221]; 26832b578d3Smrg pDst[222] = pSrc[222]; pDst[223] = pSrc[223]; 26932b578d3Smrg pDst[224] = pSrc[224]; pDst[225] = pSrc[225]; 27032b578d3Smrg pDst[226] = pSrc[226]; pDst[227] = pSrc[227]; 27132b578d3Smrg pDst[228] = pSrc[228]; pDst[229] = pSrc[229]; 27232b578d3Smrg pDst[230] = pSrc[230]; pDst[231] = pSrc[231]; 27332b578d3Smrg pDst[232] = pSrc[232]; pDst[233] = pSrc[233]; 27432b578d3Smrg pDst[234] = pSrc[234]; pDst[235] = pSrc[235]; 27532b578d3Smrg pDst[236] = pSrc[236]; pDst[237] = pSrc[237]; 27632b578d3Smrg pDst[238] = pSrc[238]; pDst[239] = pSrc[239]; 27732b578d3Smrg pDst[240] = pSrc[240]; pDst[241] = pSrc[241]; 27832b578d3Smrg pDst[242] = pSrc[242]; pDst[243] = pSrc[243]; 27932b578d3Smrg pDst[244] = pSrc[244]; pDst[245] = pSrc[245]; 28032b578d3Smrg pDst[246] = pSrc[246]; pDst[247] = pSrc[247]; 28132b578d3Smrg pDst[248] = pSrc[248]; pDst[249] = pSrc[249]; 28232b578d3Smrg pDst[250] = pSrc[250]; pDst[251] = pSrc[251]; 28332b578d3Smrg pDst[252] = pSrc[252]; pDst[253] = pSrc[253]; 28432b578d3Smrg pDst[254] = pSrc[254]; pDst[255] = pSrc[255]; 28532b578d3Smrg } 28632b578d3Smrg 28732b578d3Smrg#endif 28832b578d3Smrg 28932b578d3Smrg#ifdef XF86DRI_DEVEL 29032b578d3Smrg 29132b578d3Smrg ATIDRIUnlock(pScreenInfo); 29232b578d3Smrg 29332b578d3Smrg#endif /* XF86DRI_DEVEL */ 29432b578d3Smrg 29532b578d3Smrg} 29632b578d3Smrg 29732b578d3Smrg/* 29832b578d3Smrg * ATIMach64HideCursor -- 29932b578d3Smrg * 30032b578d3Smrg * Turn off hardware cursor. 30132b578d3Smrg */ 30232b578d3Smrgstatic void 30332b578d3SmrgATIMach64HideCursor 30432b578d3Smrg( 30532b578d3Smrg ScrnInfoPtr pScreenInfo 30632b578d3Smrg) 30732b578d3Smrg{ 30832b578d3Smrg ATIPtr pATI = ATIPTR(pScreenInfo); 30932b578d3Smrg 31032b578d3Smrg if (!(pATI->NewHW.gen_test_cntl & GEN_CUR_EN)) 31132b578d3Smrg return; 31232b578d3Smrg 31332b578d3Smrg pATI->NewHW.gen_test_cntl &= ~GEN_CUR_EN; 31432b578d3Smrg out8(GEN_TEST_CNTL, GetByte(pATI->NewHW.gen_test_cntl, 0)); 31532b578d3Smrg} 31632b578d3Smrg 31732b578d3Smrg/* 31832b578d3Smrg * ATIMach64ShowCursor -- 31932b578d3Smrg * 32032b578d3Smrg * Turn on hardware cursor. 32132b578d3Smrg */ 32232b578d3Smrgstatic void 32332b578d3SmrgATIMach64ShowCursor 32432b578d3Smrg( 32532b578d3Smrg ScrnInfoPtr pScreenInfo 32632b578d3Smrg) 32732b578d3Smrg{ 32832b578d3Smrg ATIPtr pATI = ATIPTR(pScreenInfo); 32932b578d3Smrg 33032b578d3Smrg if (pATI->NewHW.gen_test_cntl & GEN_CUR_EN) 33132b578d3Smrg return; 33232b578d3Smrg 33332b578d3Smrg pATI->NewHW.gen_test_cntl |= GEN_CUR_EN; 33432b578d3Smrg out8(GEN_TEST_CNTL, GetByte(pATI->NewHW.gen_test_cntl, 0)); 33532b578d3Smrg} 33632b578d3Smrg 33732b578d3Smrg/* 33832b578d3Smrg * ATIMach64UseHWCursor -- 33932b578d3Smrg * 34032b578d3Smrg * Notify cursor layer whether a hardware cursor is configured. 34132b578d3Smrg */ 34232b578d3Smrgstatic Bool 34332b578d3SmrgATIMach64UseHWCursor 34432b578d3Smrg( 34532b578d3Smrg ScreenPtr pScreen, 34632b578d3Smrg CursorPtr pCursor 34732b578d3Smrg) 34832b578d3Smrg{ 349e35d4d8eSmrg ScrnInfoPtr pScreenInfo = xf86ScreenToScrn(pScreen); 35032b578d3Smrg ATIPtr pATI = ATIPTR(pScreenInfo); 35132b578d3Smrg 35232b578d3Smrg if (!pATI->CursorBase) 35332b578d3Smrg return FALSE; 35432b578d3Smrg 35532b578d3Smrg return TRUE; 35632b578d3Smrg} 35732b578d3Smrg 35832b578d3Smrg/* 35932b578d3Smrg * ATIMach64CursorInit -- 36032b578d3Smrg * 36132b578d3Smrg * Initialise xf86CursorInfoRec fields with information specific to Mach64 36232b578d3Smrg * variants. 36332b578d3Smrg */ 36432b578d3SmrgBool 36532b578d3SmrgATIMach64CursorInit 36632b578d3Smrg( 36732b578d3Smrg ScreenPtr pScreen 36832b578d3Smrg) 36932b578d3Smrg{ 370e35d4d8eSmrg ScrnInfoPtr pScreenInfo = xf86ScreenToScrn(pScreen); 37132b578d3Smrg ATIPtr pATI = ATIPTR(pScreenInfo); 37232b578d3Smrg xf86CursorInfoPtr pCursorInfo; 37332b578d3Smrg 37432b578d3Smrg /* Initialise software cursor */ 37532b578d3Smrg if (!miDCInitialize(pScreen, xf86GetPointerScreenFuncs())) 37632b578d3Smrg return FALSE; 37732b578d3Smrg 37832b578d3Smrg if (pATI->Cursor == ATI_CURSOR_SOFTWARE) 37932b578d3Smrg return TRUE; 38032b578d3Smrg 38132b578d3Smrg /* Initialise hardware cursor */ 38232b578d3Smrg if (!(pATI->pCursorInfo = xf86CreateCursorInfoRec())) 38332b578d3Smrg return FALSE; 38432b578d3Smrg 38532b578d3Smrg pCursorInfo = pATI->pCursorInfo; 38632b578d3Smrg 38732b578d3Smrg /* 38832b578d3Smrg * For Mach64 variants, toggling hardware cursors off and on causes display 38932b578d3Smrg * artifacts. Ask the cursor support layers to always paint the cursor 39032b578d3Smrg * (whether or not it is entirely transparent) and to not hide the cursor 39132b578d3Smrg * when reloading its image. The two remaining reasons for turning off the 39232b578d3Smrg * hardware cursor are when it moves to a different screen or on a switch 39332b578d3Smrg * to a different virtual console. 39432b578d3Smrg */ 39532b578d3Smrg pCursorInfo->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | 39632b578d3Smrg HARDWARE_CURSOR_INVERT_MASK | 39732b578d3Smrg HARDWARE_CURSOR_SHOW_TRANSPARENT | 39832b578d3Smrg HARDWARE_CURSOR_UPDATE_UNHIDDEN | 39932b578d3Smrg HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | 40032b578d3Smrg 40132b578d3Smrg#if X_BYTE_ORDER != X_LITTLE_ENDIAN 40232b578d3Smrg 40332b578d3Smrg HARDWARE_CURSOR_BIT_ORDER_MSBFIRST | 40432b578d3Smrg 40532b578d3Smrg#endif /* X_BYTE_ORDER */ 40632b578d3Smrg 40732b578d3Smrg HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1; 40832b578d3Smrg pCursorInfo->MaxWidth = pCursorInfo->MaxHeight = 64; 40932b578d3Smrg 41032b578d3Smrg pCursorInfo->SetCursorColors = ATIMach64SetCursorColours; 41132b578d3Smrg pCursorInfo->SetCursorPosition = ATIMach64SetCursorPosition; 41232b578d3Smrg pCursorInfo->LoadCursorImage = ATIMach64LoadCursorImage; 41332b578d3Smrg pCursorInfo->HideCursor = ATIMach64HideCursor; 41432b578d3Smrg pCursorInfo->ShowCursor = ATIMach64ShowCursor; 41532b578d3Smrg pCursorInfo->UseHWCursor = ATIMach64UseHWCursor; 41632b578d3Smrg 41732b578d3Smrg if (!xf86InitCursor(pScreen, pATI->pCursorInfo)) 41832b578d3Smrg { 41932b578d3Smrg xf86DestroyCursorInfoRec(pATI->pCursorInfo); 42032b578d3Smrg pATI->pCursorInfo = NULL; 42132b578d3Smrg return FALSE; 42232b578d3Smrg } 42332b578d3Smrg 42432b578d3Smrg xf86SetSilkenMouse(pScreen); 42532b578d3Smrg return TRUE; 42632b578d3Smrg} 427