1 #include<linux/module.h>
2 #include<linux/kernel.h>
3 #include<linux/errno.h>
4 #include<linux/string.h>
7 #include<linux/delay.h>
9 #include<linux/ioport.h>
10 #include<linux/init.h>
12 #include<linux/vmalloc.h>
13 #include<linux/pagemap.h>
14 #include <linux/console.h>
15 #include<linux/platform_device.h>
16 #include<linux/screen_info.h>
19 #include "sm750_help.h"
20 #include "sm750_cursor.h"
23 #define PEEK32(addr) \
24 readl(cursor->mmio + (addr))
26 #define POKE32(addr,data) \
27 writel((data),cursor->mmio + (addr))
29 /* cursor control for voyager and 718/750*/
30 #define HWC_ADDRESS 0x0
31 #define HWC_ADDRESS_ENABLE 31:31
32 #define HWC_ADDRESS_ENABLE_DISABLE 0
33 #define HWC_ADDRESS_ENABLE_ENABLE 1
34 #define HWC_ADDRESS_EXT 27:27
35 #define HWC_ADDRESS_EXT_LOCAL 0
36 #define HWC_ADDRESS_EXT_EXTERNAL 1
37 #define HWC_ADDRESS_CS 26:26
38 #define HWC_ADDRESS_CS_0 0
39 #define HWC_ADDRESS_CS_1 1
40 #define HWC_ADDRESS_ADDRESS 25:0
42 #define HWC_LOCATION 0x4
43 #define HWC_LOCATION_TOP 27:27
44 #define HWC_LOCATION_TOP_INSIDE 0
45 #define HWC_LOCATION_TOP_OUTSIDE 1
46 #define HWC_LOCATION_Y 26:16
47 #define HWC_LOCATION_LEFT 11:11
48 #define HWC_LOCATION_LEFT_INSIDE 0
49 #define HWC_LOCATION_LEFT_OUTSIDE 1
50 #define HWC_LOCATION_X 10:0
52 #define HWC_COLOR_12 0x8
53 #define HWC_COLOR_12_2_RGB565 31:16
54 #define HWC_COLOR_12_1_RGB565 15:0
56 #define HWC_COLOR_3 0xC
57 #define HWC_COLOR_3_RGB565 15:0
60 /* hw_cursor_xxx works for voyager,718 and 750 */
61 void hw_cursor_enable(struct lynx_cursor * cursor)
64 reg = FIELD_VALUE(0,HWC_ADDRESS,ADDRESS,cursor->offset)|
65 FIELD_SET(0,HWC_ADDRESS,EXT,LOCAL)|
66 FIELD_SET(0,HWC_ADDRESS,ENABLE,ENABLE);
67 POKE32(HWC_ADDRESS,reg);
69 void hw_cursor_disable(struct lynx_cursor * cursor)
71 POKE32(HWC_ADDRESS,0);
74 void hw_cursor_setSize(struct lynx_cursor * cursor,
80 void hw_cursor_setPos(struct lynx_cursor * cursor,
84 reg = FIELD_VALUE(0,HWC_LOCATION,Y,y)|
85 FIELD_VALUE(0,HWC_LOCATION,X,x);
86 POKE32(HWC_LOCATION,reg);
88 void hw_cursor_setColor(struct lynx_cursor * cursor,
91 POKE32(HWC_COLOR_12,(fg<<16)|(bg&0xffff));
92 POKE32(HWC_COLOR_3,0xffe0);
95 void hw_cursor_setData(struct lynx_cursor * cursor,
96 u16 rop,const u8* pcol,const u8* pmsk)
98 int i,j,count,pitch,offset;
101 void __iomem *pbuffer, *pstart;
104 pitch = cursor->w >> 3;
107 count = pitch * cursor->h;
110 offset = cursor->maxW * 2 / 8;
113 pstart = cursor->vstart;
118 hw_cursor_setData2(cursor,rop,pcol,pmsk);
131 /* either method below works well,
132 * but method 2 shows no lag
133 * and method 1 seems a bit wrong*/
143 if(opr & (0x80 >> j))
144 { //use fg color,id = 2
147 //use bg color,id = 1
153 if(mask & (0x80>>j)){
159 /* 2 stands for forecolor and 1 for backcolor */
160 data |= ((opr & (0x80>>j))?2:1)<<(j*2);
164 iowrite16(data, pbuffer);
166 /* assume pitch is 1,2,4,8,...*/
168 if(!((i+1)&(pitch-1))) /* below line equal to is line */
170 if((i+1) % pitch == 0)
177 pbuffer += sizeof(u16);
186 void hw_cursor_setData2(struct lynx_cursor * cursor,
187 u16 rop,const u8* pcol,const u8* pmsk)
189 int i,j,count,pitch,offset;
192 void __iomem *pbuffer, *pstart;
195 pitch = cursor->w >> 3;
198 count = pitch * cursor->h;
201 offset = cursor->maxW * 2 / 8;
204 pstart = cursor->vstart;
213 /* either method below works well, but method 2 shows no lag */
223 if(opr & (0x80 >> j))
224 { //use fg color,id = 2
227 //use bg color,id = 1
234 data |= ((color & (1<<j))?1:2)<<(j*2);
237 iowrite16(data, pbuffer);
239 /* assume pitch is 1,2,4,8,...*/
241 //if((i+1) % pitch == 0)
247 pbuffer += sizeof(u16);