summaryrefslogtreecommitdiff
path: root/driver/xf86-video-rendition/src/hwcursor.c
blob: 2c19a6e331fe5f04d96c077504703d11994b5af7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/hwcursor.c,v 1.6 2000/02/25 21:03:00 dawes Exp $ */
/*
 * includes
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "rendition.h"
#include "vtypes.h"
#include "vramdac.h"

#include "hwcursor.h"

/*
 * defines 
 */

#undef DEBUG

/* use a 64x64 cursor, 32x32 otherwise    */
/* note that V2K supports only 64x64 size */
#define BIGCURSOR 1

/*
 * local function prototypes
 */

static Bool RENDITIONUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs);
static void RENDITIONSetCursorColors(ScrnInfoPtr pScreenInfo, int bg, int fg);
static void RENDITIONSetCursorPosition(ScrnInfoPtr pScreenInfo, int x, int y);
static void RENDITIONHideCursor(ScrnInfoPtr pScreenInfo);
static void RENDITIONShowCursor(ScrnInfoPtr pScreenInfo);
static void RENDITIONLoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char* src);


/*
 * This is top-level initialization funtion
 */
void
RenditionHWCursorPreInit (ScrnInfoPtr pScreenInfo)
{
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);

#ifdef DEBUG
    ErrorF ("Rendition: Debug RenditionHWCursorPreInit called\n");
#endif

    pRendition->board.hwcursor_used = TRUE;
    if (pRendition->board.chip==V1000_DEVICE){
      /* V1K uses special space on BT-485 RAMDAC */
      pRendition->board.hwcursor_vmemsize = 0;
      pRendition->board.hwcursor_membase = 0 ; /* Not used on V1K */
    }
    else{
      pRendition->board.hwcursor_vmemsize = 64*64*2/8 /* 1024 bytes used */;
      pRendition->board.hwcursor_membase = (pRendition->board.fbOffset >> 10);
      /* Last but not least, update offset-adress */
      pRendition->board.fbOffset += pRendition->board.hwcursor_vmemsize;
    }
}

void
RenditionHWCursorRelease (ScrnInfoPtr pScreenInfo)
{
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);

#ifdef DEBUG
    ErrorF ("Rendition: Debug RenditionHWCursorRelease called\n");
#endif

    xf86DestroyCursorInfoRec(pRendition->CursorInfoRec);
    pRendition->CursorInfoRec=NULL;
}


Bool
RenditionHWCursorInit(int scrnIndex, ScreenPtr pScreen)
{
    ScrnInfoPtr  pScreenInfo = xf86Screens[scrnIndex];
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
    xf86CursorInfoPtr infoPtr;

#ifdef DEBUG
    ErrorF ("Rendition: Debug RenditionHWCursorInit called\n");
#endif

    infoPtr = xf86CreateCursorInfoRec();
    if(!infoPtr) return FALSE;

    pRendition->CursorInfoRec = infoPtr;

#ifdef BIGCURSOR
    infoPtr->MaxWidth=64;
    infoPtr->MaxHeight=64;
#else
    infoPtr->MaxWidth=32;
    infoPtr->MaxHeight=32;
#endif

    infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST  |
	HARDWARE_CURSOR_TRUECOLOR_AT_8BPP   | 
	HARDWARE_CURSOR_AND_SOURCE_WITH_MASK|
	HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8;


    infoPtr->SetCursorColors      = RENDITIONSetCursorColors;
    infoPtr->SetCursorPosition    = RENDITIONSetCursorPosition;
    infoPtr->LoadCursorImage      = RENDITIONLoadCursorImage;
    infoPtr->HideCursor           = RENDITIONHideCursor;
    infoPtr->ShowCursor           = RENDITIONShowCursor;
    infoPtr->UseHWCursor          = RENDITIONUseHWCursor;

    return xf86InitCursor(pScreen, infoPtr);
}


/*
 * local functions
 */

static Bool
RENDITIONUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
{
#ifdef DEBUG
    ErrorF ("Rendition: Debug RENDITIONUseHWCursor called\n");
#endif

  /* have this return false for DoubleScan and Interlaced ? */
    return TRUE;
}


static void
RENDITIONShowCursor(ScrnInfoPtr pScreenInfo)
{
  /* renditionPtr pRendition = RENDITIONPTR(pScreenInfo); */

#ifdef DEBUG
    ErrorF( "RENDITION: ShowCursor called\n");
#endif

    /* enable cursor - X11 mode */
    verite_enablecursor(pScreenInfo, VERITE_3COLORS,
#ifdef BIGCURSOR
        VERITE_CURSOR64
#else 
        VERITE_CURSOR32
#endif
        );
}



static void
RENDITIONHideCursor(ScrnInfoPtr pScreenInfo)
{
#ifdef DEBUG
    ErrorF( "RENDITION: HideCursor called\n");
#endif

    /* Disable cursor */
    verite_enablecursor(pScreenInfo, VERITE_NOCURSOR, 0);
}



static void
RENDITIONSetCursorPosition(ScrnInfoPtr pScreenInfo, int x, int y)
{
#ifdef DEBUG
    ErrorF( "RENDITION: SetCursorPosition(%d, %d) called\n", x, y);
#endif

    verite_movecursor(pScreenInfo, x, y, 1 /* xorigin */, 1 /* yorigin */);
}



static void
RENDITIONSetCursorColors(ScrnInfoPtr pScreenInfo, int bg, int fg)
{
#ifdef DEBUG
    ErrorF( "RENDITION: SetCursorColors(%x, %x) called\n", fg, bg);
#endif

    verite_setcursorcolor(pScreenInfo, bg, fg);
}



static void
RENDITIONLoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char* src)
{
#ifdef DEBUG
    ErrorF( "RENDITION: loadcursor called\n");
#endif
    verite_loadcursor(pScreenInfo,
#ifdef BIGCURSOR
        VERITE_CURSOR64, 
#else
        VERITE_CURSOR32, 
#endif
        (vu8 *)src);
}


/*
 * end of file hwcursor.c
 */