1 #ifndef LYNXDRV_H_
2 #define LYNXDRV_H_
3
4
5
6 #define FB_ACCEL_SMI 0xab
7 /* please use revision id to distinguish sm750le and sm750*/
8 #define SPC_SM750 0
9
10 //#define SPC_SM750LE 8
11
12 #define MB(x) ((x)<<20)
13 #define MHZ(x) ((x) * 1000000)
14 /* align should be 2,4,8,16 */
15 #define PADDING(align,data) (((data)+(align)-1)&(~((align) -1)))
16 extern int smi_indent;
17
18
19 struct lynx_accel{
20 /* base virtual address of DPR registers */
21 volatile unsigned char __iomem * dprBase;
22 /* base virtual address of de data port */
23 volatile unsigned char __iomem * dpPortBase;
24
25 /* function fointers */
26 void (*de_init)(struct lynx_accel *);
27
28 int (*de_wait)(void);/* see if hardware ready to work */
29
30 int (*de_fillrect)(struct lynx_accel *,u32,u32,u32,
31 u32,u32,u32,u32,u32,u32);
32
33 int (*de_copyarea)(struct lynx_accel *,u32,u32,u32,u32,
34 u32,u32,u32,u32,
35 u32,u32,u32,u32);
36
37 int (*de_imageblit)(struct lynx_accel *,const char *,u32,u32,u32,
38 u32,u32,u32,u32,u32,u32,u32,u32,u32);
39
40 };
41
42 /* lynx_share stands for a presentation of two frame buffer
43 that use one smi adaptor , it is similar to a basic class of C++
44 */
45 struct lynx_share{
46 /* common members */
47 u16 devid;
48 u8 revid;
49 struct pci_dev * pdev;
50 struct fb_info * fbinfo[2];
51 struct lynx_accel accel;
52 int accel_off;
53 int dual;
54 #ifdef CONFIG_MTRR
55 int mtrr_off;
56 struct{
57 int vram;
58 int vram_added;
59 }mtrr;
60 #endif
61 /* all smi graphic adaptor got below attributes */
62 unsigned long vidmem_start;
63 unsigned long vidreg_start;
64 __u32 vidmem_size;
65 __u32 vidreg_size;
66 void __iomem * pvReg;
67 unsigned char __iomem * pvMem;
68 /* locks*/
69 spinlock_t slock;
70 /* function pointers */
71 void (*suspend)(struct lynx_share*);
72 void (*resume)(struct lynx_share*);
73 };
74
75 struct lynx_cursor{
76 /* cursor width ,height and size */
77 int w;
78 int h;
79 int size;
80 /* hardware limitation */
81 int maxW;
82 int maxH;
83 /* base virtual address and offset of cursor image */
84 char __iomem * vstart;
85 int offset;
86 /* mmio addr of hw cursor */
87 volatile char __iomem * mmio;
88 /* the lynx_share of this adaptor */
89 struct lynx_share * share;
90 /* proc_routines */
91 void (*enable)(struct lynx_cursor *);
92 void (*disable)(struct lynx_cursor *);
93 void (*setSize)(struct lynx_cursor *,int,int);
94 void (*setPos)(struct lynx_cursor *,int,int);
95 void (*setColor)(struct lynx_cursor *,u32,u32);
96 void (*setData)(struct lynx_cursor *,u16,const u8*,const u8*);
97 };
98
99 struct lynxfb_crtc{
100 unsigned char __iomem * vCursor;//virtual address of cursor
101 unsigned char __iomem * vScreen;//virtual address of on_screen
102 int oCursor;//cursor address offset in vidmem
103 int oScreen;//onscreen address offset in vidmem
104 int channel;/* which channel this crtc stands for*/
105 resource_size_t vidmem_size;/* this view's video memory max size */
106
107 /* below attributes belong to info->fix, their value depends on specific adaptor*/
108 u16 line_pad;/* padding information:0,1,2,4,8,16,... */
109 u16 xpanstep;
110 u16 ypanstep;
111 u16 ywrapstep;
112
113 void * priv;
114
115 int(*proc_setMode)(struct lynxfb_crtc*,
116 struct fb_var_screeninfo*,
117 struct fb_fix_screeninfo*);
118
119 int(*proc_checkMode)(struct lynxfb_crtc*,struct fb_var_screeninfo*);
120 int(*proc_setColReg)(struct lynxfb_crtc*,ushort,ushort,ushort,ushort);
121 void (*clear)(struct lynxfb_crtc*);
122 /* pan display */
123 int (*proc_panDisplay)(struct lynxfb_crtc *,
124 const struct fb_var_screeninfo *,
125 const struct fb_info *);
126 /* cursor information */
127 struct lynx_cursor cursor;
128 };
129
130 struct lynxfb_output{
131 int dpms;
132 int paths;
133 /* which paths(s) this output stands for,for sm750:
134 paths=1:means output for panel paths
135 paths=2:means output for crt paths
136 paths=3:means output for both panel and crt paths
137 */
138
139 int * channel;
140 /* which channel these outputs linked with,for sm750:
141 *channel=0 means primary channel
142 *channel=1 means secondary channel
143 output->channel ==> &crtc->channel
144 */
145 void * priv;
146
147 int(*proc_setMode)(struct lynxfb_output*,
148 struct fb_var_screeninfo*,
149 struct fb_fix_screeninfo*);
150
151 int(*proc_checkMode)(struct lynxfb_output*,struct fb_var_screeninfo*);
152 int(*proc_setBLANK)(struct lynxfb_output*,int);
153 void (*clear)(struct lynxfb_output*);
154 };
155
156 struct lynxfb_par{
157 /* either 0 or 1 for dual head adaptor,0 is the older one registered */
158 int index;
159 unsigned int pseudo_palette[256];
160 struct lynxfb_crtc crtc;
161 struct lynxfb_output output;
162 struct fb_info * info;
163 struct lynx_share * share;
164 };
165
166 #ifndef offsetof
167 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
168 #endif
169
170
171 #define PS_TO_HZ(ps) \
172 ({ \
173 unsigned long long hz = 1000*1000*1000*1000ULL; \
174 do_div(hz,ps); \
175 (unsigned long)hz;})
176
ps_to_hz(unsigned int psvalue)177 static inline unsigned long ps_to_hz(unsigned int psvalue)
178 {
179 unsigned long long numerator=1000*1000*1000*1000ULL;
180 /* 10^12 / picosecond period gives frequency in Hz */
181 do_div(numerator, psvalue);
182 return (unsigned long)numerator;
183 }
184
185
186 #endif
187