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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/errno.h>
#include<linux/string.h>
#include<linux/mm.h>
#include<linux/slab.h>
#include<linux/delay.h>
#include<linux/fb.h>
#include<linux/ioport.h>
#include<linux/init.h>
#include<linux/pci.h>
#include<linux/vmalloc.h>
#include<linux/pagemap.h>
#include <linux/console.h>
#include<linux/platform_device.h>
#include<linux/screen_info.h>
#include "sm750.h"
#include "sm750_help.h"
#include "sm750_cursor.h"
#define PEEK32(addr) \
readl(cursor->mmio + (addr))
#define POKE32(addr, data) \
writel((data), cursor->mmio + (addr))
/* cursor control for voyager and 718/750*/
#define HWC_ADDRESS 0x0
#define HWC_ADDRESS_ENABLE 31:31
#define HWC_ADDRESS_ENABLE_DISABLE 0
#define HWC_ADDRESS_ENABLE_ENABLE 1
#define HWC_ADDRESS_EXT 27:27
#define HWC_ADDRESS_EXT_LOCAL 0
#define HWC_ADDRESS_EXT_EXTERNAL 1
#define HWC_ADDRESS_CS 26:26
#define HWC_ADDRESS_CS_0 0
#define HWC_ADDRESS_CS_1 1
#define HWC_ADDRESS_ADDRESS 25:0
#define HWC_LOCATION 0x4
#define HWC_LOCATION_TOP 27:27
#define HWC_LOCATION_TOP_INSIDE 0
#define HWC_LOCATION_TOP_OUTSIDE 1
#define HWC_LOCATION_Y 26:16
#define HWC_LOCATION_LEFT 11:11
#define HWC_LOCATION_LEFT_INSIDE 0
#define HWC_LOCATION_LEFT_OUTSIDE 1
#define HWC_LOCATION_X 10:0
#define HWC_COLOR_12 0x8
#define HWC_COLOR_12_2_RGB565 31:16
#define HWC_COLOR_12_1_RGB565 15:0
#define HWC_COLOR_3 0xC
#define HWC_COLOR_3_RGB565 15:0
/* hw_cursor_xxx works for voyager,718 and 750 */
void hw_cursor_enable(struct lynx_cursor *cursor)
{
u32 reg;
reg = FIELD_VALUE(0, HWC_ADDRESS, ADDRESS, cursor->offset)|
FIELD_SET(0, HWC_ADDRESS, EXT, LOCAL)|
FIELD_SET(0, HWC_ADDRESS, ENABLE, ENABLE);
POKE32(HWC_ADDRESS, reg);
}
void hw_cursor_disable(struct lynx_cursor *cursor)
{
POKE32(HWC_ADDRESS, 0);
}
void hw_cursor_setSize(struct lynx_cursor *cursor,
int w, int h)
{
cursor->w = w;
cursor->h = h;
}
void hw_cursor_setPos(struct lynx_cursor *cursor,
int x, int y)
{
u32 reg;
reg = FIELD_VALUE(0, HWC_LOCATION, Y, y)|
FIELD_VALUE(0, HWC_LOCATION, X, x);
POKE32(HWC_LOCATION, reg);
}
void hw_cursor_setColor(struct lynx_cursor *cursor,
u32 fg, u32 bg)
{
POKE32(HWC_COLOR_12, (fg<<16)|(bg&0xffff));
POKE32(HWC_COLOR_3, 0xffe0);
}
void hw_cursor_setData(struct lynx_cursor *cursor,
u16 rop, const u8* pcol, const u8* pmsk)
{
int i, j, count, pitch, offset;
u8 color, mask, opr;
u16 data;
void __iomem *pbuffer, *pstart;
/* in byte*/
pitch = cursor->w >> 3;
/* in byte */
count = pitch * cursor->h;
/* in byte */
offset = cursor->maxW * 2 / 8;
data = 0;
pstart = cursor->vstart;
pbuffer = pstart;
/*
if(odd &1){
hw_cursor_setData2(cursor,rop,pcol,pmsk);
}
odd++;
if(odd > 0xfffffff0)
odd=0;
*/
for (i = 0; i < count; i++)
{
color = *pcol++;
mask = *pmsk++;
data = 0;
/* either method below works well,
* but method 2 shows no lag
* and method 1 seems a bit wrong*/
#if 0
if (rop == ROP_XOR)
opr = mask ^ color;
else
opr = mask & color;
for (j = 0; j < 8; j++)
{
if (opr & (0x80 >> j))
{ /* use fg color,id = 2 */
data |= 2 << (j*2);
} else {
/* use bg color,id = 1 */
data |= 1 << (j*2);
}
}
#else
for (j = 0; j < 8; j++) {
if (mask & (0x80>>j)) {
if (rop == ROP_XOR)
opr = mask ^ color;
else
opr = mask & color;
/* 2 stands for forecolor and 1 for backcolor */
data |= ((opr & (0x80>>j))?2:1)<<(j*2);
}
}
#endif
iowrite16(data, pbuffer);
/* assume pitch is 1,2,4,8,...*/
#if 0
if (!((i+1)&(pitch-1))) /* below line equal to is line */
#else
if ((i+1) % pitch == 0)
#endif
{
/* need a return */
pstart += offset;
pbuffer = pstart;
} else {
pbuffer += sizeof(u16);
}
}
}
void hw_cursor_setData2(struct lynx_cursor *cursor,
u16 rop, const u8* pcol, const u8* pmsk)
{
int i, j, count, pitch, offset;
u8 color, mask;
u16 data;
void __iomem *pbuffer, *pstart;
/* in byte*/
pitch = cursor->w >> 3;
/* in byte */
count = pitch * cursor->h;
/* in byte */
offset = cursor->maxW * 2 / 8;
data = 0;
pstart = cursor->vstart;
pbuffer = pstart;
for (i = 0; i < count; i++)
{
color = *pcol++;
mask = *pmsk++;
data = 0;
/* either method below works well, but method 2 shows no lag */
#if 0
if (rop == ROP_XOR)
opr = mask ^ color;
else
opr = mask & color;
for (j = 0; j < 8; j++)
{
if (opr & (0x80 >> j))
{ /* use fg color,id = 2 */
data |= 2 << (j*2);
} else {
/* use bg color,id = 1 */
data |= 1 << (j*2);
}
}
#else
for (j = 0; j < 8; j++) {
if (mask & (1<<j))
data |= ((color & (1<<j))?1:2)<<(j*2);
}
#endif
iowrite16(data, pbuffer);
/* assume pitch is 1,2,4,8,...*/
if (!(i&(pitch-1)))
{
/* need a return */
pstart += offset;
pbuffer = pstart;
} else {
pbuffer += sizeof(u16);
}
}
}
|