Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
81dee67e SM |
2 | #ifndef LYNXDRV_H_ |
3 | #define LYNXDRV_H_ | |
4 | ||
81dee67e | 5 | #define FB_ACCEL_SMI 0xab |
81dee67e | 6 | |
81dee67e | 7 | #define MHZ(x) ((x) * 1000000) |
81dee67e | 8 | |
05407e15 MR |
9 | #define DEFAULT_SM750_CHIP_CLOCK 290 |
10 | #define DEFAULT_SM750LE_CHIP_CLOCK 333 | |
11 | #ifndef SM750LE_REVISION_ID | |
12 | #define SM750LE_REVISION_ID ((unsigned char)0xfe) | |
13 | #endif | |
14 | ||
15 | enum sm750_pnltype { | |
16 | sm750_24TFT = 0, /* 24bit tft */ | |
17 | sm750_dualTFT = 2, /* dual 18 bit tft */ | |
18 | sm750_doubleTFT = 1, /* 36 bit double pixel tft */ | |
19 | }; | |
20 | ||
21 | /* vga channel is not concerned */ | |
22 | enum sm750_dataflow { | |
23 | sm750_simul_pri, /* primary => all head */ | |
24 | sm750_simul_sec, /* secondary => all head */ | |
25 | sm750_dual_normal, /* primary => panel head and secondary => crt */ | |
26 | sm750_dual_swap, /* primary => crt head and secondary => panel */ | |
27 | }; | |
28 | ||
29 | enum sm750_channel { | |
30 | sm750_primary = 0, | |
31 | /* enum value equal to the register filed data */ | |
32 | sm750_secondary = 1, | |
33 | }; | |
34 | ||
35 | enum sm750_path { | |
36 | sm750_panel = 1, | |
37 | sm750_crt = 2, | |
38 | sm750_pnc = 3, /* panel and crt */ | |
39 | }; | |
40 | ||
41 | struct init_status { | |
42 | ushort powerMode; | |
43 | /* below three clocks are in unit of MHZ*/ | |
44 | ushort chip_clk; | |
45 | ushort mem_clk; | |
46 | ushort master_clk; | |
47 | ushort setAllEngOff; | |
48 | ushort resetMemory; | |
49 | }; | |
50 | ||
5d14c13a | 51 | struct lynx_accel { |
81dee67e | 52 | /* base virtual address of DPR registers */ |
cc6c16df | 53 | volatile unsigned char __iomem *dprBase; |
81dee67e | 54 | /* base virtual address of de data port */ |
cc6c16df | 55 | volatile unsigned char __iomem *dpPortBase; |
81dee67e | 56 | |
fbb8c963 | 57 | /* function pointers */ |
bf2fbc2a | 58 | void (*de_init)(struct lynx_accel *); |
81dee67e SM |
59 | |
60 | int (*de_wait)(void);/* see if hardware ready to work */ | |
61 | ||
e8b976da IA |
62 | int (*de_fillrect)(struct lynx_accel *, u32, u32, u32, u32, |
63 | u32, u32, u32, u32, u32); | |
81dee67e | 64 | |
e8b976da IA |
65 | int (*de_copyarea)(struct lynx_accel *, u32, u32, u32, u32, |
66 | u32, u32, u32, u32, | |
67 | u32, u32, u32, u32); | |
81dee67e | 68 | |
e8b976da IA |
69 | int (*de_imageblit)(struct lynx_accel *, const char *, u32, u32, u32, u32, |
70 | u32, u32, u32, u32, | |
71 | u32, u32, u32, u32); | |
81dee67e SM |
72 | |
73 | }; | |
74 | ||
e359b6a8 | 75 | struct sm750_dev { |
81dee67e SM |
76 | /* common members */ |
77 | u16 devid; | |
78 | u8 revid; | |
eb0f4271 GD |
79 | struct pci_dev *pdev; |
80 | struct fb_info *fbinfo[2]; | |
81dee67e SM |
81 | struct lynx_accel accel; |
82 | int accel_off; | |
a3f92cc9 | 83 | int fb_count; |
e359b6a8 MR |
84 | int mtrr_off; |
85 | struct{ | |
86 | int vram; | |
87 | } mtrr; | |
81dee67e | 88 | /* all smi graphic adaptor got below attributes */ |
e936351a SM |
89 | unsigned long vidmem_start; |
90 | unsigned long vidreg_start; | |
91 | __u32 vidmem_size; | |
92 | __u32 vidreg_size; | |
eb0f4271 GD |
93 | void __iomem *pvReg; |
94 | unsigned char __iomem *pvMem; | |
81dee67e SM |
95 | /* locks*/ |
96 | spinlock_t slock; | |
1757d106 MR |
97 | |
98 | struct init_status initParm; | |
99 | enum sm750_pnltype pnltype; | |
100 | enum sm750_dataflow dataflow; | |
101 | int nocrt; | |
05407e15 MR |
102 | |
103 | /* | |
104 | * 0: no hardware cursor | |
105 | * 1: primary crtc hw cursor enabled, | |
106 | * 2: secondary crtc hw cursor enabled | |
107 | * 3: both ctrc hw cursor enabled | |
108 | */ | |
109 | int hwCursor; | |
110 | }; | |
111 | ||
5d14c13a | 112 | struct lynx_cursor { |
81dee67e SM |
113 | /* cursor width ,height and size */ |
114 | int w; | |
115 | int h; | |
116 | int size; | |
117 | /* hardware limitation */ | |
118 | int maxW; | |
119 | int maxH; | |
120 | /* base virtual address and offset of cursor image */ | |
eb0f4271 | 121 | char __iomem *vstart; |
81dee67e SM |
122 | int offset; |
123 | /* mmio addr of hw cursor */ | |
cc6c16df | 124 | volatile char __iomem *mmio; |
81dee67e SM |
125 | }; |
126 | ||
5d14c13a | 127 | struct lynxfb_crtc { |
eb0f4271 GD |
128 | unsigned char __iomem *vCursor; /* virtual address of cursor */ |
129 | unsigned char __iomem *vScreen; /* virtual address of on_screen */ | |
5ee35ea7 JL |
130 | int oCursor; /* cursor address offset in vidmem */ |
131 | int oScreen; /* onscreen address offset in vidmem */ | |
81dee67e SM |
132 | int channel;/* which channel this crtc stands for*/ |
133 | resource_size_t vidmem_size;/* this view's video memory max size */ | |
134 | ||
135 | /* below attributes belong to info->fix, their value depends on specific adaptor*/ | |
136 | u16 line_pad;/* padding information:0,1,2,4,8,16,... */ | |
137 | u16 xpanstep; | |
138 | u16 ypanstep; | |
139 | u16 ywrapstep; | |
140 | ||
eb0f4271 | 141 | void *priv; |
81dee67e | 142 | |
81dee67e SM |
143 | /* cursor information */ |
144 | struct lynx_cursor cursor; | |
145 | }; | |
146 | ||
5d14c13a | 147 | struct lynxfb_output { |
81dee67e SM |
148 | int dpms; |
149 | int paths; | |
f5016082 ES |
150 | /* |
151 | * which paths(s) this output stands for,for sm750: | |
35e4d8ca EF |
152 | * paths=1:means output for panel paths |
153 | * paths=2:means output for crt paths | |
154 | * paths=3:means output for both panel and crt paths | |
155 | */ | |
81dee67e | 156 | |
eb0f4271 | 157 | int *channel; |
f5016082 ES |
158 | /* |
159 | * which channel these outputs linked with,for sm750: | |
35e4d8ca EF |
160 | * *channel=0 means primary channel |
161 | * *channel=1 means secondary channel | |
162 | * output->channel ==> &crtc->channel | |
163 | */ | |
eb0f4271 | 164 | void *priv; |
81dee67e | 165 | |
f7d8b69a | 166 | int (*proc_setBLANK)(struct lynxfb_output*, int); |
81dee67e SM |
167 | }; |
168 | ||
5d14c13a | 169 | struct lynxfb_par { |
81dee67e SM |
170 | /* either 0 or 1 for dual head adaptor,0 is the older one registered */ |
171 | int index; | |
172 | unsigned int pseudo_palette[256]; | |
173 | struct lynxfb_crtc crtc; | |
174 | struct lynxfb_output output; | |
eb0f4271 | 175 | struct fb_info *info; |
f11fa2a9 | 176 | struct sm750_dev *dev; |
81dee67e SM |
177 | }; |
178 | ||
81dee67e SM |
179 | static inline unsigned long ps_to_hz(unsigned int psvalue) |
180 | { | |
dca633d4 | 181 | unsigned long long numerator = 1000 * 1000 * 1000 * 1000ULL; |
81dee67e SM |
182 | /* 10^12 / picosecond period gives frequency in Hz */ |
183 | do_div(numerator, psvalue); | |
184 | return (unsigned long)numerator; | |
185 | } | |
186 | ||
700591a9 | 187 | int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev); |
d228cf87 AS |
188 | int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev); |
189 | void hw_sm750_initAccel(struct sm750_dev *sm750_dev); | |
05407e15 MR |
190 | int hw_sm750_deWait(void); |
191 | int hw_sm750le_deWait(void); | |
192 | ||
3fa4b5e5 DR |
193 | int hw_sm750_output_setMode(struct lynxfb_output *output, |
194 | struct fb_var_screeninfo *var, | |
195 | struct fb_fix_screeninfo *fix); | |
196 | ||
197 | int hw_sm750_crtc_checkMode(struct lynxfb_crtc *crtc, | |
198 | struct fb_var_screeninfo *var); | |
199 | ||
200 | int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc, | |
201 | struct fb_var_screeninfo *var, | |
202 | struct fb_fix_screeninfo *fix); | |
203 | ||
204 | int hw_sm750_setColReg(struct lynxfb_crtc *crtc, ushort index, | |
205 | ushort red, ushort green, ushort blue); | |
206 | ||
207 | int hw_sm750_setBLANK(struct lynxfb_output *output, int blank); | |
208 | int hw_sm750le_setBLANK(struct lynxfb_output *output, int blank); | |
05407e15 MR |
209 | int hw_sm750_pan_display(struct lynxfb_crtc *crtc, |
210 | const struct fb_var_screeninfo *var, | |
211 | const struct fb_info *info); | |
81dee67e SM |
212 | |
213 | #endif |