1
/* Copyright (c) 2003-2006 Advanced Micro Devices, Inc.
3
* Permission is hereby granted, free of charge, to any person obtaining a copy
4
* of this software and associated documentation files (the "Software"), to
5
* deal in the Software without restriction, including without limitation the
6
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
* sell copies of the Software, and to permit persons to whom the Software is
8
* furnished to do so, subject to the following conditions:
10
* The above copyright notice and this permission notice shall be included in
11
* all copies or substantial portions of the Software.
13
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
* Neither the name of the Advanced Micro Devices, Inc. nor the names of its
22
* contributors may be used to endorse or promote products derived from this
23
* software without specific prior written permission.
27
* File Contents: Xfree cursor implementation routines for geode HWcursor
28
* init.setting cursor color,image etc. are done here.
30
* Project: Geode Xfree Frame buffer device driver.
38
#include "xf86_OSproc.h"
40
#include "xf86PciInfo.h"
43
/* Forward declarations of the functions */
44
static void GXSetCursorColors(ScrnInfoPtr pScrni, int bg, int fg);
45
static void GXSetCursorPosition(ScrnInfoPtr pScrni, int x, int y);
46
static Bool GXUseHWCursor(ScreenPtr pScrn, CursorPtr pCurs);
47
extern void GXSetVideoPosition(int x, int y, int width, int height,
48
short src_w, short src_h, short drw_w,
49
short drw_h, int id, int offset,
52
/*----------------------------------------------------------------------------
55
* Description :This function sets the cursor information by probing the
59
* pScrn :Screeen pointer structure.
61
* Returns :TRUE on success and FALSE on Failure
63
* Comments :Geode supports the hardware_cursor,no need to enable SW
65
*----------------------------------------------------------------------------
68
GXHWCursorInit(ScreenPtr pScrn)
70
ScrnInfoPtr pScrni = xf86ScreenToScrn(pScrn);
71
GeodeRec *pGeode = GEODEPTR(pScrni);
72
xf86CursorInfoPtr infoPtr;
74
infoPtr = xf86CreateCursorInfoRec();
77
/* the geode structure is intiallized with the cursor infoRec */
78
pGeode->CursorInfo = infoPtr;
79
infoPtr->MaxWidth = 32;
80
infoPtr->MaxHeight = 32;
81
/* seeting up the cursor flags */
82
infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
83
HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
84
HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
85
/* cursor info ptr is intiallized with the values obtained from
88
infoPtr->SetCursorColors = GXSetCursorColors;
89
infoPtr->SetCursorPosition = GXSetCursorPosition;
90
infoPtr->LoadCursorImage = GXLoadCursorImage;
91
infoPtr->HideCursor = GXHideCursor;
92
infoPtr->ShowCursor = GXShowCursor;
93
infoPtr->UseHWCursor = GXUseHWCursor;
94
return (xf86InitCursor(pScrn, infoPtr));
97
/*----------------------------------------------------------------------------
100
* Description :This function sets the cursor foreground and background
103
* pScrn: Screeen pointer structure.
104
* bg: Specifies the color value of cursor background color.
105
* fg: Specifies the color value of cursor foreground color.
109
* Comments: The integer color value passed by this function is
110
* converted into * RGB value by the gfx_set_color routines.
111
*----------------------------------------------------------------------------
114
GXSetCursorColors(ScrnInfoPtr pScrni, int bg, int fg)
116
GFX(set_cursor_colors(bg, fg));
119
/*----------------------------------------------------------------------------
120
* GXSetCursorPosition.
122
* Description :This function sets the cursor co -ordinates and enable the
126
* pScrn: Screeen pointer structure.
127
* x: Specifies the x-cordinates of the cursor.
128
* y: Specifies the y co-ordinate of the cursor.
132
*----------------------------------------------------------------------------
135
GXSetCursorPosition(ScrnInfoPtr pScrni, int x, int y)
137
static unsigned long panOffset = 0;
138
GeodeRec *pGeode = GEODEPTR(pScrni);
142
/* Adjust xf86HWCursor messing about */
144
savex = x + pScrni->frameX0;
145
savey = y + pScrni->frameY0;
147
switch (pGeode->rotation) {
149
ErrorF("%s:%d invalid rotation %d\n", __func__, __LINE__,
158
newY = pScrni->pScreen->width - savex;
162
newX = pScrni->pScreen->width - savex;
163
newY = pScrni->pScreen->height - savey;
167
newX = pScrni->pScreen->height - savey;
172
newX += pScrni->frameX0;
173
newY += pScrni->frameY0;
175
//ErrorF("Turned (%d,%d) into (%d,%d)\n", x,y,newX, newY);
182
gfx_set_cursor_position(pGeode->CursorStartOffset, newX + 31, newY + 31,
184
gfx_set_cursor_enable(1);
186
if ((pGeode->OverlayON) && (pGeode->Panel)) {
187
pGeode->PrevDisplayOffset = gfx_get_display_offset();
188
if (pGeode->PrevDisplayOffset != panOffset) {
189
GXSetVideoPosition(pGeode->video_x, pGeode->video_y,
190
pGeode->video_w, pGeode->video_h,
191
pGeode->video_srcw, pGeode->video_srch,
192
pGeode->video_dstw, pGeode->video_dsth,
193
pGeode->video_id, pGeode->video_offset,
194
pGeode->video_scrnptr);
195
panOffset = pGeode->PrevDisplayOffset;
200
/*----------------------------------------------------------------------------
203
* Description: This function loads the 32x32 cursor pattern.The shape
204
* and color is set by AND and XOR masking of arrays of 32
207
* pScrn: Screeen pointer structure.
208
* src: Specifies cursor data.
212
*----------------------------------------------------------------------------
215
GXLoadCursorImage(ScrnInfoPtr pScrni, unsigned char *src)
217
int i, n, x, y, newX, newY;
218
unsigned long andMask[32], xorMask[32];
219
GeodeRec *pGeode = GEODEPTR(pScrni);
220
unsigned long mskb, rowb;
221
unsigned char *rowp = &src[0];
222
unsigned char *mskp = &src[128];
226
for (y = 32; --y >= 0;)
227
andMask[y] = xorMask[y] = 0;
228
for (y = 0; y < 32; ++y) {
229
for (x = 0; x < 32; ++x) {
230
if ((i = x & 7) == 0) {
231
rowb = (*rowp & *mskp);
237
switch (pGeode->rotation) {
239
ErrorF("%s:%d invalid rotation %d\n", __func__, __LINE__,
261
andMask[newY] |= (((mskb >> i) & 1) << n);
262
xorMask[newY] |= (((rowb >> i) & 1) << n);
267
for (y = 32; --y >= 0;) {
273
gfx_set_cursor_shape32(pGeode->CursorStartOffset, &andMask[0], &xorMask[0]);
276
/*----------------------------------------------------------------------------
279
* Description: This function will disable the cursor.
282
* pScrn: Handles to the Screeen pointer structure.
286
* Comments: gfx_set_cursor enable function is hardcoded to disable
288
*----------------------------------------------------------------------------
291
GXHideCursor(ScrnInfoPtr pScrni)
293
gfx_set_cursor_enable(0);
296
/*----------------------------------------------------------------------------
299
* Description :This function will enable the cursor.
302
* pScrn :Handles to the Screeen pointer structure.
306
* Comments :gfx_set_cursor enable function is hardcoded to enable the
308
*----------------------------------------------------------------------------
311
GXShowCursor(ScrnInfoPtr pScrni)
313
GFX(set_cursor_enable(1));
316
/*----------------------------------------------------------------------------
319
* Description :This function will sets the hardware cursor flag in
323
* pScrn :Handles to the Screeen pointer structure.
329
*----------------------------------------------------------------------------
332
GXUseHWCursor(ScreenPtr pScrn, CursorPtr pCurs)
334
ScrnInfoPtr pScrni = XF86SCRNINFO(pScrn);
335
GeodeRec *pGeode = GEODEPTR(pScrni);
337
return pGeode->HWCursor;