]> Pileus Git - ~andy/linux/blob - drivers/staging/xgifb/XGI_main.h
Merge branch 'integration' into for-linus
[~andy/linux] / drivers / staging / xgifb / XGI_main.h
1 #ifndef _XGIFB_MAIN
2 #define _XGIFB_MAIN
3
4
5 /* ------------------- Constant Definitions ------------------------- */
6
7
8 #include "XGIfb.h"
9 #include "vb_struct.h"
10 #include "vb_def.h"
11
12 #define XGIFAIL(x) do { printk(x "\n"); return -EINVAL; } while (0)
13
14 #define VER_MAJOR                 0
15 #define VER_MINOR                 8
16 #define VER_LEVEL                 1
17
18 #define DRIVER_DESC  "XGI Volari Frame Buffer Module Version 0.8.1"
19
20 #ifndef PCI_VENDOR_ID_XG
21 #define PCI_VENDOR_ID_XG          0x18CA
22 #endif
23
24 #ifndef PCI_DEVICE_ID_XG_40
25 #define PCI_DEVICE_ID_XG_40      0x040
26 #endif
27 #ifndef PCI_DEVICE_ID_XG_41
28 #define PCI_DEVICE_ID_XG_41      0x041
29 #endif
30 #ifndef PCI_DEVICE_ID_XG_42
31 #define PCI_DEVICE_ID_XG_42      0x042
32 #endif
33 #ifndef PCI_DEVICE_ID_XG_20
34 #define PCI_DEVICE_ID_XG_20      0x020
35 #endif
36 #ifndef PCI_DEVICE_ID_XG_27
37 #define PCI_DEVICE_ID_XG_27      0x027
38 #endif
39
40
41
42 #define XGI_IOTYPE1 void __iomem
43 #define XGI_IOTYPE2 __iomem
44 #define XGIINITSTATIC static
45
46 static DEFINE_PCI_DEVICE_TABLE(xgifb_pci_table) = {
47         {PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_20, PCI_ANY_ID, PCI_ANY_ID,
48          0, 0, 0},
49         {PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_27, PCI_ANY_ID, PCI_ANY_ID,
50          0, 0, 1},
51         {PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_40, PCI_ANY_ID, PCI_ANY_ID,
52          0, 0, 2},
53         {PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_42, PCI_ANY_ID, PCI_ANY_ID,
54          0, 0, 3},
55         {0}
56 };
57
58 MODULE_DEVICE_TABLE(pci, xgifb_pci_table);
59
60 /* To be included in fb.h */
61 #ifndef FB_ACCEL_XGI_GLAMOUR_2
62 #define FB_ACCEL_XGI_GLAMOUR_2  40      /* XGI 315, 650, 740            */
63 #endif
64 #ifndef FB_ACCEL_XGI_XABRE
65 #define FB_ACCEL_XGI_XABRE      41      /* XGI 330 ("Xabre")            */
66 #endif
67
68 #define MAX_ROM_SCAN              0x10000
69
70 #define SEQ_ADR                   0x14
71 #define SEQ_DATA                  0x15
72 #define DAC_ADR                   0x18
73 #define DAC_DATA                  0x19
74 #define CRTC_ADR                  0x24
75 #define CRTC_DATA                 0x25
76 #define DAC2_ADR                  (0x16-0x30)
77 #define DAC2_DATA                 (0x17-0x30)
78 #define VB_PART1_ADR              (0x04-0x30)
79 #define VB_PART1_DATA             (0x05-0x30)
80 #define VB_PART2_ADR              (0x10-0x30)
81 #define VB_PART2_DATA             (0x11-0x30)
82 #define VB_PART3_ADR              (0x12-0x30)
83 #define VB_PART3_DATA             (0x13-0x30)
84 #define VB_PART4_ADR              (0x14-0x30)
85 #define VB_PART4_DATA             (0x15-0x30)
86
87 #define XGISR                     XGI_Pr.P3c4
88 #define XGICR                     XGI_Pr.P3d4
89 #define XGIDACA                   XGI_Pr.P3c8
90 #define XGIDACD                   XGI_Pr.P3c9
91 #define XGIPART1                  XGI_Pr.Part1Port
92 #define XGIPART2                  XGI_Pr.Part2Port
93 #define XGIPART3                  XGI_Pr.Part3Port
94 #define XGIPART4                  XGI_Pr.Part4Port
95 #define XGIPART5                  XGI_Pr.Part5Port
96 #define XGIDAC2A                  XGIPART5
97 #define XGIDAC2D                  (XGIPART5 + 1)
98 #define XGIMISCR                  (XGI_Pr.RelIO + 0x1c)
99 #define XGIINPSTAT                (XGI_Pr.RelIO + 0x2a)
100
101 #define IND_XGI_PASSWORD          0x05  /* SRs */
102 #define IND_XGI_COLOR_MODE        0x06
103 #define IND_XGI_RAMDAC_CONTROL    0x07
104 #define IND_XGI_DRAM_SIZE         0x14
105 #define IND_XGI_SCRATCH_REG_16    0x16
106 #define IND_XGI_SCRATCH_REG_17    0x17
107 #define IND_XGI_SCRATCH_REG_1A    0x1A
108 #define IND_XGI_MODULE_ENABLE     0x1E
109 #define IND_XGI_PCI_ADDRESS_SET   0x20
110 #define IND_XGI_TURBOQUEUE_ADR    0x26
111 #define IND_XGI_TURBOQUEUE_SET    0x27
112 #define IND_XGI_POWER_ON_TRAP     0x38
113 #define IND_XGI_POWER_ON_TRAP2    0x39
114 #define IND_XGI_CMDQUEUE_SET      0x26
115 #define IND_XGI_CMDQUEUE_THRESHOLD  0x27
116
117 #define IND_XGI_SCRATCH_REG_CR30  0x30  /* CRs */
118 #define IND_XGI_SCRATCH_REG_CR31  0x31
119 #define IND_XGI_SCRATCH_REG_CR32  0x32
120 #define IND_XGI_SCRATCH_REG_CR33  0x33
121 #define IND_XGI_LCD_PANEL         0x36
122 #define IND_XGI_SCRATCH_REG_CR37  0x37
123 #define IND_XGI_AGP_IO_PAD        0x48
124
125 #define IND_BRI_DRAM_STATUS       0x63 /* PCI config memory size offset */
126
127 #define MMIO_QUEUE_PHYBASE        0x85C0
128 #define MMIO_QUEUE_WRITEPORT      0x85C4
129 #define MMIO_QUEUE_READPORT       0x85C8
130
131 #define IND_XGI_CRT2_WRITE_ENABLE_300 0x24
132 #define IND_XGI_CRT2_WRITE_ENABLE_315 0x2F
133
134 #define XGI_PASSWORD              0x86  /* SR05 */
135 #define XGI_INTERLACED_MODE       0x20  /* SR06 */
136 #define XGI_8BPP_COLOR_MODE       0x0
137 #define XGI_15BPP_COLOR_MODE      0x1
138 #define XGI_16BPP_COLOR_MODE      0x2
139 #define XGI_32BPP_COLOR_MODE      0x4
140
141 #define XGI_DRAM_SIZE_MASK     0xF0  /*SR14 */
142 #define XGI_DRAM_SIZE_1MB      0x00
143 #define XGI_DRAM_SIZE_2MB      0x01
144 #define XGI_DRAM_SIZE_4MB      0x02
145 #define XGI_DRAM_SIZE_8MB      0x03
146 #define XGI_DRAM_SIZE_16MB     0x04
147 #define XGI_DRAM_SIZE_32MB     0x05
148 #define XGI_DRAM_SIZE_64MB     0x06
149 #define XGI_DRAM_SIZE_128MB    0x07
150 #define XGI_DRAM_SIZE_256MB    0x08
151 #define XGI_DATA_BUS_MASK      0x02
152 #define XGI_DATA_BUS_64        0x00
153 #define XGI_DATA_BUS_128       0x01
154 #define XGI_DUAL_CHANNEL_MASK  0x0C
155 #define XGI_SINGLE_CHANNEL_1_RANK 0x0
156 #define XGI_SINGLE_CHANNEL_2_RANK 0x1
157 #define XGI_ASYM_DDR              0x02
158 #define XGI_DUAL_CHANNEL_1_RANK   0x3
159
160 #define XGI550_DRAM_SIZE_MASK     0x3F  /* 550/650/740 SR14 */
161 #define XGI550_DRAM_SIZE_4MB      0x00
162 #define XGI550_DRAM_SIZE_8MB      0x01
163 #define XGI550_DRAM_SIZE_16MB     0x03
164 #define XGI550_DRAM_SIZE_24MB     0x05
165 #define XGI550_DRAM_SIZE_32MB     0x07
166 #define XGI550_DRAM_SIZE_64MB     0x0F
167 #define XGI550_DRAM_SIZE_96MB     0x17
168 #define XGI550_DRAM_SIZE_128MB    0x1F
169 #define XGI550_DRAM_SIZE_256MB    0x3F
170
171 #define XGI_SCRATCH_REG_1A_MASK   0x10
172
173 #define XGI_ENABLE_2D             0x40  /* SR1E */
174
175 #define XGI_MEM_MAP_IO_ENABLE     0x01  /* SR20 */
176 #define XGI_PCI_ADDR_ENABLE       0x80
177
178 #define XGI_SIMULTANEOUS_VIEW_ENABLE  0x01  /* CR30 */
179 #define XGI_MODE_SELECT_CRT2      0x02
180 #define XGI_VB_OUTPUT_COMPOSITE   0x04
181 #define XGI_VB_OUTPUT_SVIDEO      0x08
182 #define XGI_VB_OUTPUT_SCART       0x10
183 #define XGI_VB_OUTPUT_LCD         0x20
184 #define XGI_VB_OUTPUT_CRT2        0x40
185 #define XGI_VB_OUTPUT_HIVISION    0x80
186
187 #define XGI_VB_OUTPUT_DISABLE     0x20  /* CR31 */
188 #define XGI_DRIVER_MODE           0x40
189
190 #define XGI_VB_COMPOSITE          0x01  /* CR32 */
191 #define XGI_VB_SVIDEO             0x02
192 #define XGI_VB_SCART              0x04
193 #define XGI_VB_LCD                0x08
194 #define XGI_VB_CRT2               0x10
195 #define XGI_CRT1                  0x20
196 #define XGI_VB_HIVISION           0x40
197 #define XGI_VB_YPBPR              0x80
198 #define XGI_VB_TV                 (XGI_VB_COMPOSITE | XGI_VB_SVIDEO | \
199                                    XGI_VB_SCART | XGI_VB_HIVISION|XGI_VB_YPBPR)
200
201 #define XGI_EXTERNAL_CHIP_MASK             0x0E  /* CR37 */
202 #define XGI_EXTERNAL_CHIP_XGI301           0x01  /* in CR37 << 1 ! */
203 #define XGI_EXTERNAL_CHIP_LVDS             0x02  /* in CR37 << 1 ! */
204 #define XGI_EXTERNAL_CHIP_TRUMPION         0x03  /* in CR37 << 1 ! */
205 #define XGI_EXTERNAL_CHIP_LVDS_CHRONTEL    0x04  /* in CR37 << 1 ! */
206 #define XGI_EXTERNAL_CHIP_CHRONTEL         0x05  /* in CR37 << 1 ! */
207 #define XGI310_EXTERNAL_CHIP_LVDS          0x02  /* in CR37 << 1 ! */
208 #define XGI310_EXTERNAL_CHIP_LVDS_CHRONTEL 0x03  /* in CR37 << 1 ! */
209
210 #define XGI_AGP_2X                0x20  /* CR48 */
211
212 #define BRI_DRAM_SIZE_MASK        0x70  /* PCI bridge config data */
213 #define BRI_DRAM_SIZE_2MB         0x00
214 #define BRI_DRAM_SIZE_4MB         0x01
215 #define BRI_DRAM_SIZE_8MB         0x02
216 #define BRI_DRAM_SIZE_16MB        0x03
217 #define BRI_DRAM_SIZE_32MB        0x04
218 #define BRI_DRAM_SIZE_64MB        0x05
219
220 #define SR_BUFFER_SIZE            5
221 #define CR_BUFFER_SIZE            5
222
223 /* ------------------- Global Variables ----------------------------- */
224
225 /* Fbcon variables */
226 static struct fb_info *fb_info;
227
228
229 static int    video_type = FB_TYPE_PACKED_PIXELS;
230
231 static struct fb_var_screeninfo default_var = {
232         .xres           = 0,
233         .yres           = 0,
234         .xres_virtual   = 0,
235         .yres_virtual   = 0,
236         .xoffset        = 0,
237         .yoffset        = 0,
238         .bits_per_pixel = 0,
239         .grayscale      = 0,
240         .red            = {0, 8, 0},
241         .green          = {0, 8, 0},
242         .blue           = {0, 8, 0},
243         .transp         = {0, 0, 0},
244         .nonstd         = 0,
245         .activate       = FB_ACTIVATE_NOW,
246         .height         = -1,
247         .width          = -1,
248         .accel_flags    = 0,
249         .pixclock       = 0,
250         .left_margin    = 0,
251         .right_margin   = 0,
252         .upper_margin   = 0,
253         .lower_margin   = 0,
254         .hsync_len      = 0,
255         .vsync_len      = 0,
256         .sync           = 0,
257         .vmode          = FB_VMODE_NONINTERLACED,
258 };
259
260 static struct fb_fix_screeninfo XGIfb_fix = {
261         .id             = "XGI",
262         .type           = FB_TYPE_PACKED_PIXELS,
263         .xpanstep       = 1,
264         .ypanstep       = 1,
265 };
266 static char myid[20];
267 static u32 pseudo_palette[17];
268
269
270 /* display status */
271 static int XGIfb_off = 0;
272 static int XGIfb_crt1off = 0;
273 static int XGIfb_forcecrt1 = -1;
274 static int XGIfb_userom = 0;
275 /*static int XGIfb_useoem = -1; */
276
277 /* global flags */
278 static int XGIfb_registered;
279 static int XGIfb_tvmode = 0;
280 static int XGIfb_pdc = 0;
281 static int enable_dstn = 0;
282 static int XGIfb_ypan = -1;
283
284
285 static int XGIfb_CRT2_write_enable = 0;
286
287 /* TW: CRT2 type (for overriding autodetection) */
288 static int XGIfb_crt2type = -1;
289 /* PR: Tv plug type (for overriding autodetection) */
290 static int XGIfb_tvplug = -1;
291
292 static unsigned char XGIfb_detectedpdc = 0;
293
294 static unsigned char XGIfb_detectedlcda = 0xff;
295
296
297
298
299 /* TW: For ioctl XGIFB_GET_INFO */
300 /* XGIfb_info XGIfbinfo; */
301
302 /* TW: Hardware extension; contains data on hardware */
303 static struct xgi_hw_device_info XGIhw_ext;
304
305 /* TW: XGI private structure */
306 static struct vb_device_info  XGI_Pr;
307
308 #define MD_XGI300 1
309 #define MD_XGI315 2
310
311 /* mode table */
312 /* NOT const - will be patched for 1280x960 mode number chaos reasons */
313 static struct _XGIbios_mode {
314         char name[15];
315         u8 mode_no;
316         u16 vesa_mode_no_1;  /* "XGI defined" VESA mode number */
317         u16 vesa_mode_no_2;  /* Real VESA mode numbers */
318         u16 xres;
319         u16 yres;
320         u16 bpp;
321         u16 rate_idx;
322         u16 cols;
323         u16 rows;
324         u8  chipset;
325 } XGIbios_mode[] = {
326 #define MODE_INDEX_NONE           0  /* TW: index for mode=none */
327         {"none",         0xFF, 0x0000, 0x0000,    0,    0,  0, 0,   0,  0,
328          MD_XGI300|MD_XGI315},  /* TW: for mode "none" */
329         {"320x240x16",   0x56, 0x0000, 0x0000,  320,  240, 16, 1,  40, 15,
330          MD_XGI315},
331         {"320x480x8",    0x5A, 0x0000, 0x0000,  320,  480,  8, 1,  40, 30,
332          MD_XGI315},  /* TW: FSTN */
333         {"320x480x16",   0x5B, 0x0000, 0x0000,  320,  480, 16, 1,  40, 30,
334          MD_XGI315},  /* TW: FSTN */
335         {"640x480x8",    0x2E, 0x0101, 0x0101,  640,  480,  8, 1,  80, 30,
336          MD_XGI300|MD_XGI315},
337         {"640x480x16",   0x44, 0x0111, 0x0111,  640,  480, 16, 1,  80, 30,
338          MD_XGI300|MD_XGI315},
339         {"640x480x24",   0x62, 0x013a, 0x0112,  640,  480, 32, 1,  80, 30,
340          MD_XGI300|MD_XGI315},  /* TW: That's for people who mix up color-
341                                         and fb depth */
342         {"640x480x32",   0x62, 0x013a, 0x0112,  640,  480, 32, 1,  80, 30,
343          MD_XGI300|MD_XGI315},
344         {"720x480x8",    0x31, 0x0000, 0x0000,  720,  480,  8, 1,  90, 30,
345          MD_XGI300|MD_XGI315},
346         {"720x480x16",   0x33, 0x0000, 0x0000,  720,  480, 16, 1,  90, 30,
347          MD_XGI300|MD_XGI315},
348         {"720x480x24",   0x35, 0x0000, 0x0000,  720,  480, 32, 1,  90, 30,
349          MD_XGI300|MD_XGI315},
350         {"720x480x32",   0x35, 0x0000, 0x0000,  720,  480, 32, 1,  90, 30,
351          MD_XGI300|MD_XGI315},
352         {"720x576x8",    0x32, 0x0000, 0x0000,  720,  576,  8, 1,  90, 36,
353          MD_XGI300|MD_XGI315},
354         {"720x576x16",   0x34, 0x0000, 0x0000,  720,  576, 16, 1,  90, 36,
355          MD_XGI300|MD_XGI315},
356         {"720x576x24",   0x36, 0x0000, 0x0000,  720,  576, 32, 1,  90, 36,
357          MD_XGI300|MD_XGI315},
358         {"720x576x32",   0x36, 0x0000, 0x0000,  720,  576, 32, 1,  90, 36,
359          MD_XGI300|MD_XGI315},
360         {"800x480x8",    0x70, 0x0000, 0x0000,  800,  480,  8, 1, 100, 30,
361          MD_XGI300|MD_XGI315},
362         {"800x480x16",   0x7a, 0x0000, 0x0000,  800,  480, 16, 1, 100, 30,
363          MD_XGI300|MD_XGI315},
364         {"800x480x24",   0x76, 0x0000, 0x0000,  800,  480, 32, 1, 100, 30,
365          MD_XGI300|MD_XGI315},
366         {"800x480x32",   0x76, 0x0000, 0x0000,  800,  480, 32, 1, 100, 30,
367          MD_XGI300|MD_XGI315},
368 #define DEFAULT_MODE              21 /* TW: index for 800x600x8 */
369 #define DEFAULT_LCDMODE           21 /* TW: index for 800x600x8 */
370 #define DEFAULT_TVMODE            21 /* TW: index for 800x600x8 */
371         {"800x600x8",    0x30, 0x0103, 0x0103,  800,  600,  8, 1, 100, 37,
372          MD_XGI300|MD_XGI315},
373         {"800x600x16",   0x47, 0x0114, 0x0114,  800,  600, 16, 1, 100, 37,
374          MD_XGI300|MD_XGI315},
375         {"800x600x24",   0x63, 0x013b, 0x0115,  800,  600, 32, 1, 100, 37,
376          MD_XGI300|MD_XGI315},
377         {"800x600x32",   0x63, 0x013b, 0x0115,  800,  600, 32, 1, 100, 37,
378          MD_XGI300|MD_XGI315},
379         {"1024x576x8",   0x71, 0x0000, 0x0000, 1024,  576,  8, 1, 128, 36,
380          MD_XGI300|MD_XGI315},
381         {"1024x576x16",  0x74, 0x0000, 0x0000, 1024,  576, 16, 1, 128, 36,
382          MD_XGI300|MD_XGI315},
383         {"1024x576x24",  0x77, 0x0000, 0x0000, 1024,  576, 32, 1, 128, 36,
384          MD_XGI300|MD_XGI315},
385         {"1024x576x32",  0x77, 0x0000, 0x0000, 1024,  576, 32, 1, 128, 36,
386          MD_XGI300|MD_XGI315},
387         {"1024x600x8",   0x20, 0x0000, 0x0000, 1024,  600,  8, 1, 128, 37,
388          MD_XGI300          },  /* TW: 300 series only */
389         {"1024x600x16",  0x21, 0x0000, 0x0000, 1024,  600, 16, 1, 128, 37,
390          MD_XGI300          },
391         {"1024x600x24",  0x22, 0x0000, 0x0000, 1024,  600, 32, 1, 128, 37,
392          MD_XGI300          },
393         {"1024x600x32",  0x22, 0x0000, 0x0000, 1024,  600, 32, 1, 128, 37,
394          MD_XGI300          },
395         {"1024x768x8",   0x38, 0x0105, 0x0105, 1024,  768,  8, 1, 128, 48,
396          MD_XGI300|MD_XGI315},
397         {"1024x768x16",  0x4A, 0x0117, 0x0117, 1024,  768, 16, 1, 128, 48,
398          MD_XGI300|MD_XGI315},
399         {"1024x768x24",  0x64, 0x013c, 0x0118, 1024,  768, 32, 1, 128, 48,
400          MD_XGI300|MD_XGI315},
401         {"1024x768x32",  0x64, 0x013c, 0x0118, 1024,  768, 32, 1, 128, 48,
402          MD_XGI300|MD_XGI315},
403         {"1152x768x8",   0x23, 0x0000, 0x0000, 1152,  768,  8, 1, 144, 48,
404          MD_XGI300          },  /* TW: 300 series only */
405         {"1152x768x16",  0x24, 0x0000, 0x0000, 1152,  768, 16, 1, 144, 48,
406          MD_XGI300          },
407         {"1152x768x24",  0x25, 0x0000, 0x0000, 1152,  768, 32, 1, 144, 48,
408          MD_XGI300          },
409         {"1152x768x32",  0x25, 0x0000, 0x0000, 1152,  768, 32, 1, 144, 48,
410          MD_XGI300          },
411         {"1280x720x8",   0x79, 0x0000, 0x0000, 1280,  720,  8, 1, 160, 45,
412          MD_XGI300|MD_XGI315},
413         {"1280x720x16",  0x75, 0x0000, 0x0000, 1280,  720, 16, 1, 160, 45,
414          MD_XGI300|MD_XGI315},
415         {"1280x720x24",  0x78, 0x0000, 0x0000, 1280,  720, 32, 1, 160, 45,
416          MD_XGI300|MD_XGI315},
417         {"1280x720x32",  0x78, 0x0000, 0x0000, 1280,  720, 32, 1, 160, 45,
418          MD_XGI300|MD_XGI315},
419         {"1280x768x8",   0x23, 0x0000, 0x0000, 1280,  768,  8, 1, 160, 48,
420          MD_XGI315},  /* TW: 310/325 series only */
421         {"1280x768x16",  0x24, 0x0000, 0x0000, 1280,  768, 16, 1, 160, 48,
422          MD_XGI315},
423         {"1280x768x24",  0x25, 0x0000, 0x0000, 1280,  768, 32, 1, 160, 48,
424          MD_XGI315},
425         {"1280x768x32",  0x25, 0x0000, 0x0000, 1280,  768, 32, 1, 160, 48,
426          MD_XGI315},
427 #define MODEINDEX_1280x960 48
428         {"1280x960x8",   0x7C, 0x0000, 0x0000, 1280,  960,  8, 1, 160, 60,
429          MD_XGI300|MD_XGI315},  /* TW: Modenumbers being patched */
430         {"1280x960x16",  0x7D, 0x0000, 0x0000, 1280,  960, 16, 1, 160, 60,
431          MD_XGI300|MD_XGI315},
432         {"1280x960x24",  0x7E, 0x0000, 0x0000, 1280,  960, 32, 1, 160, 60,
433          MD_XGI300|MD_XGI315},
434         {"1280x960x32",  0x7E, 0x0000, 0x0000, 1280,  960, 32, 1, 160, 60,
435          MD_XGI300|MD_XGI315},
436         {"1280x1024x8",  0x3A, 0x0107, 0x0107, 1280, 1024,  8, 1, 160, 64,
437          MD_XGI300|MD_XGI315},
438         {"1280x1024x16", 0x4D, 0x011a, 0x011a, 1280, 1024, 16, 1, 160, 64,
439          MD_XGI300|MD_XGI315},
440         {"1280x1024x24", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 1, 160, 64,
441          MD_XGI300|MD_XGI315},
442         {"1280x1024x32", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 1, 160, 64,
443          MD_XGI300|MD_XGI315},
444         {"1400x1050x8",  0x26, 0x0000, 0x0000, 1400, 1050,  8, 1, 175, 65,
445          MD_XGI315},  /* TW: 310/325 series only */
446         {"1400x1050x16", 0x27, 0x0000, 0x0000, 1400, 1050, 16, 1, 175, 65,
447          MD_XGI315},
448         {"1400x1050x24", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65,
449          MD_XGI315},
450         {"1400x1050x32", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65,
451          MD_XGI315},
452         {"1600x1200x8",  0x3C, 0x0130, 0x011c, 1600, 1200,  8, 1, 200, 75,
453          MD_XGI300|MD_XGI315},
454         {"1600x1200x16", 0x3D, 0x0131, 0x011e, 1600, 1200, 16, 1, 200, 75,
455          MD_XGI300|MD_XGI315},
456         {"1600x1200x24", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75,
457          MD_XGI300|MD_XGI315},
458         {"1600x1200x32", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75,
459          MD_XGI300|MD_XGI315},
460         {"1920x1440x8",  0x68, 0x013f, 0x0000, 1920, 1440,  8, 1, 240, 75,
461          MD_XGI300|MD_XGI315},
462         {"1920x1440x16", 0x69, 0x0140, 0x0000, 1920, 1440, 16, 1, 240, 75,
463          MD_XGI300|MD_XGI315},
464         {"1920x1440x24", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75,
465          MD_XGI300|MD_XGI315},
466         {"1920x1440x32", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75,
467          MD_XGI300|MD_XGI315},
468         {"2048x1536x8",  0x6c, 0x0000, 0x0000, 2048, 1536,  8, 1, 256, 96,
469          MD_XGI315},  /* TW: 310/325 series only */
470         {"2048x1536x16", 0x6d, 0x0000, 0x0000, 2048, 1536, 16, 1, 256, 96,
471          MD_XGI315},
472         {"2048x1536x24", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96,
473          MD_XGI315},
474         {"2048x1536x32", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96,
475          MD_XGI315},
476         {"\0", 0x00, 0, 0, 0, 0, 0, 0, 0}
477 };
478
479 /* mode-related variables */
480 #ifdef MODULE
481 static int xgifb_mode_idx = 1;
482 #else
483 static int xgifb_mode_idx = -1; /* Use a default mode if we are
484                                         inside the kernel */
485 #endif
486 static u8  XGIfb_mode_no  = 0;
487 static u8  XGIfb_rate_idx = 0;
488
489 /* TW: CR36 evaluation */
490 static const unsigned short XGI300paneltype[] = {
491          LCD_UNKNOWN,  LCD_800x600, LCD_1024x768, LCD_1280x1024,
492         LCD_1280x960,  LCD_640x480, LCD_1024x600, LCD_1152x768,
493         LCD_1024x768, LCD_1024x768, LCD_1024x768,
494         LCD_1024x768, LCD_1024x768, LCD_1024x768, LCD_1024x768};
495
496 static const unsigned short XGI310paneltype[] = {
497          LCD_UNKNOWN,   LCD_800x600, LCD_1024x768, LCD_1280x1024,
498          LCD_640x480,  LCD_1024x600, LCD_1152x864, LCD_1280x960,
499         LCD_1152x768, LCD_1400x1050, LCD_1280x768, LCD_1600x1200,
500         LCD_1024x768,  LCD_1024x768, LCD_1024x768};
501
502 static const struct _XGI_crt2type {
503         char name[10];
504         int type_no;
505         int tvplug_no;
506 } XGI_crt2type[] = {
507         {"NONE",        0,              -1},
508         {"LCD",         DISPTYPE_LCD,   -1},
509         {"TV",          DISPTYPE_TV,    -1},
510         {"VGA",         DISPTYPE_CRT2,  -1},
511         {"SVIDEO",      DISPTYPE_TV,    TVPLUG_SVIDEO},
512         {"COMPOSITE",   DISPTYPE_TV,    TVPLUG_COMPOSITE},
513         {"SCART",       DISPTYPE_TV,    TVPLUG_SCART},
514         {"none",        0,              -1},
515         {"lcd",         DISPTYPE_LCD,   -1},
516         {"tv",          DISPTYPE_TV,    -1},
517         {"vga",         DISPTYPE_CRT2,  -1},
518         {"svideo",      DISPTYPE_TV,    TVPLUG_SVIDEO},
519         {"composite",   DISPTYPE_TV,    TVPLUG_COMPOSITE},
520         {"scart",       DISPTYPE_TV,    TVPLUG_SCART},
521         {"\0",          -1,             -1}
522 };
523
524 /* TV standard */
525 static const struct _XGI_tvtype {
526         char name[6];
527         int type_no;
528 } XGI_tvtype[] = {
529         {"PAL",         1},
530         {"NTSC",        2},
531         {"pal",         1},
532         {"ntsc",        2},
533         {"\0",          -1}
534 };
535
536 static const struct _XGI_vrate {
537         u16 idx;
538         u16 xres;
539         u16 yres;
540         u16 refresh;
541 } XGIfb_vrate[] = {
542         {1,  640,  480, 60}, {2,  640,  480,  72},
543         {3, 640,   480,  75}, {4,  640, 480,  85},
544
545         {5,  640,  480, 100}, {6,  640,  480, 120},
546         {7, 640,   480, 160}, {8,  640, 480, 200},
547
548         {1,  720,  480, 60},
549         {1,  720,  576, 58},
550         {1,  800,  480, 60}, {2,  800,  480,  75}, {3, 800,   480,  85},
551         {1,  800,  600,  60}, {2, 800,   600,  72}, {3,  800, 600,  75},
552         {4,  800,  600, 85}, {5,  800,  600, 100},
553         {6, 800,   600, 120}, {7,  800, 600, 160},
554
555         {1, 1024,  768,  60}, {2, 1024,  768,  70}, {3, 1024, 768,  75},
556         {4, 1024,  768, 85}, {5, 1024,  768, 100}, {6, 1024,  768, 120},
557         {1, 1024,  576, 60}, {2, 1024,  576,  75}, {3, 1024,  576,  85},
558         {1, 1024,  600, 60},
559         {1, 1152,  768, 60},
560         {1, 1280,  720, 60}, {2, 1280,  720,  75}, {3, 1280,  720,  85},
561         {1, 1280,  768, 60},
562         {1, 1280, 1024,  60}, {2, 1280, 1024,  75}, {3, 1280, 1024,  85},
563         {1, 1280,  960, 70},
564         {1, 1400, 1050, 60},
565         {1, 1600, 1200, 60}, {2, 1600, 1200,  65},
566         {3, 1600, 1200,  70}, {4, 1600, 1200,  75},
567
568         {5, 1600, 1200, 85}, {6, 1600, 1200, 100},
569         {7, 1600, 1200, 120},
570
571         {1, 1920, 1440, 60}, {2, 1920, 1440,  65},
572         {3, 1920, 1440,  70}, {4, 1920, 1440,  75},
573
574         {5, 1920, 1440, 85}, {6, 1920, 1440, 100},
575         {1, 2048, 1536, 60}, {2, 2048, 1536,  65},
576         {3, 2048, 1536,  70}, {4, 2048, 1536,  75},
577
578         {5, 2048, 1536, 85},
579         {0, 0, 0, 0}
580 };
581
582 static const struct _chswtable {
583         int subsysVendor;
584         int subsysCard;
585         char *vendorName;
586         char *cardName;
587 } mychswtable[] = {
588         { 0x1631, 0x1002, "Mitachi", "0x1002" },
589         { 0,      0,      ""       , ""       }
590 };
591
592 /* Eden Chen */
593 static const struct _XGI_TV_filter {
594         u8 filter[9][4];
595 } XGI_TV_filter[] = {
596         { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_0 */
597             {0x00, 0xE0, 0x10, 0x60},
598             {0x00, 0xEE, 0x10, 0x44},
599             {0x00, 0xF4, 0x10, 0x38},
600             {0xF8, 0xF4, 0x18, 0x38},
601             {0xFC, 0xFB, 0x14, 0x2A},
602             {0x00, 0x00, 0x10, 0x20},
603             {0x00, 0x04, 0x10, 0x18},
604             {0xFF, 0xFF, 0xFF, 0xFF} } },
605         { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_1 */
606             {0x00, 0xE0, 0x10, 0x60},
607             {0x00, 0xEE, 0x10, 0x44},
608             {0x00, 0xF4, 0x10, 0x38},
609             {0xF8, 0xF4, 0x18, 0x38},
610             {0xFC, 0xFB, 0x14, 0x2A},
611             {0x00, 0x00, 0x10, 0x20},
612             {0x00, 0x04, 0x10, 0x18},
613             {0xFF, 0xFF, 0xFF, 0xFF} } },
614         { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_2 */
615             {0xF5, 0xEE, 0x1B, 0x44},
616             {0xF8, 0xF4, 0x18, 0x38},
617             {0xEB, 0x04, 0x25, 0x18},
618             {0xF1, 0x05, 0x1F, 0x16},
619             {0xF6, 0x06, 0x1A, 0x14},
620             {0xFA, 0x06, 0x16, 0x14},
621             {0x00, 0x04, 0x10, 0x18},
622             {0xFF, 0xFF, 0xFF, 0xFF} } },
623         { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_3 */
624             {0xF1, 0x04, 0x1F, 0x18},
625             {0xEE, 0x0D, 0x22, 0x06},
626             {0xF7, 0x06, 0x19, 0x14},
627             {0xF4, 0x0B, 0x1C, 0x0A},
628             {0xFA, 0x07, 0x16, 0x12},
629             {0xF9, 0x0A, 0x17, 0x0C},
630             {0x00, 0x07, 0x10, 0x12},
631             {0xFF, 0xFF, 0xFF, 0xFF} } },
632         { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_4 */
633             {0x00, 0xE0, 0x10, 0x60},
634             {0x00, 0xEE, 0x10, 0x44},
635             {0x00, 0xF4, 0x10, 0x38},
636             {0xF8, 0xF4, 0x18, 0x38},
637             {0xFC, 0xFB, 0x14, 0x2A},
638             {0x00, 0x00, 0x10, 0x20},
639             {0x00, 0x04, 0x10, 0x18},
640             {0xFF, 0xFF, 0xFF, 0xFF} } },
641         { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_5 */
642             {0xF5, 0xEE, 0x1B, 0x44},
643             {0xF8, 0xF4, 0x18, 0x38},
644             {0xEB, 0x04, 0x25, 0x18},
645             {0xF1, 0x05, 0x1F, 0x16},
646             {0xF6, 0x06, 0x1A, 0x14},
647             {0xFA, 0x06, 0x16, 0x14},
648             {0x00, 0x04, 0x10, 0x18},
649             {0xFF, 0xFF, 0xFF, 0xFF} } },
650         { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_6 */
651             {0xEB, 0x04, 0x25, 0x18},
652             {0xE7, 0x0E, 0x29, 0x04},
653             {0xEE, 0x0C, 0x22, 0x08},
654             {0xF6, 0x0B, 0x1A, 0x0A},
655             {0xF9, 0x0A, 0x17, 0x0C},
656             {0xFC, 0x0A, 0x14, 0x0C},
657             {0x00, 0x08, 0x10, 0x10},
658             {0xFF, 0xFF, 0xFF, 0xFF} } },
659         { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_7 */
660             {0xEC, 0x02, 0x24, 0x1C},
661             {0xF2, 0x04, 0x1E, 0x18},
662             {0xEB, 0x15, 0x25, 0xF6},
663             {0xF4, 0x10, 0x1C, 0x00},
664             {0xF8, 0x0F, 0x18, 0x02},
665             {0x00, 0x04, 0x10, 0x18},
666             {0x01, 0x06, 0x0F, 0x14},
667             {0xFF, 0xFF, 0xFF, 0xFF} } },
668         { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_0 */
669             {0x00, 0xE0, 0x10, 0x60},
670             {0x00, 0xEE, 0x10, 0x44},
671             {0x00, 0xF4, 0x10, 0x38},
672             {0xF8, 0xF4, 0x18, 0x38},
673             {0xFC, 0xFB, 0x14, 0x2A},
674             {0x00, 0x00, 0x10, 0x20},
675             {0x00, 0x04, 0x10, 0x18},
676             {0xFF, 0xFF, 0xFF, 0xFF} } },
677         { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_1 */
678             {0x00, 0xE0, 0x10, 0x60},
679             {0x00, 0xEE, 0x10, 0x44},
680             {0x00, 0xF4, 0x10, 0x38},
681             {0xF8, 0xF4, 0x18, 0x38},
682             {0xFC, 0xFB, 0x14, 0x2A},
683             {0x00, 0x00, 0x10, 0x20},
684             {0x00, 0x04, 0x10, 0x18},
685             {0xFF, 0xFF, 0xFF, 0xFF} } },
686         { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_2 */
687             {0xF5, 0xEE, 0x1B, 0x44},
688             {0xF8, 0xF4, 0x18, 0x38},
689             {0xF1, 0xF7, 0x01, 0x32},
690             {0xF5, 0xFB, 0x1B, 0x2A},
691             {0xF9, 0xFF, 0x17, 0x22},
692             {0xFB, 0x01, 0x15, 0x1E},
693             {0x00, 0x04, 0x10, 0x18},
694             {0xFF, 0xFF, 0xFF, 0xFF} } },
695         { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_3 */
696             {0xF5, 0xFB, 0x1B, 0x2A},
697             {0xEE, 0xFE, 0x22, 0x24},
698             {0xF3, 0x00, 0x1D, 0x20},
699             {0xF9, 0x03, 0x17, 0x1A},
700             {0xFB, 0x02, 0x14, 0x1E},
701             {0xFB, 0x04, 0x15, 0x18},
702             {0x00, 0x06, 0x10, 0x14},
703             {0xFF, 0xFF, 0xFF, 0xFF} } },
704         { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_4 */
705             {0x00, 0xE0, 0x10, 0x60},
706             {0x00, 0xEE, 0x10, 0x44},
707             {0x00, 0xF4, 0x10, 0x38},
708             {0xF8, 0xF4, 0x18, 0x38},
709             {0xFC, 0xFB, 0x14, 0x2A},
710             {0x00, 0x00, 0x10, 0x20},
711             {0x00, 0x04, 0x10, 0x18},
712             {0xFF, 0xFF, 0xFF, 0xFF} } },
713         { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_5 */
714             {0xF5, 0xEE, 0x1B, 0x44},
715             {0xF8, 0xF4, 0x18, 0x38},
716             {0xF1, 0xF7, 0x1F, 0x32},
717             {0xF5, 0xFB, 0x1B, 0x2A},
718             {0xF9, 0xFF, 0x17, 0x22},
719             {0xFB, 0x01, 0x15, 0x1E},
720             {0x00, 0x04, 0x10, 0x18},
721             {0xFF, 0xFF, 0xFF, 0xFF} } },
722         { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_6 */
723             {0xF5, 0xEE, 0x1B, 0x2A},
724             {0xEE, 0xFE, 0x22, 0x24},
725             {0xF3, 0x00, 0x1D, 0x20},
726             {0xF9, 0x03, 0x17, 0x1A},
727             {0xFB, 0x02, 0x14, 0x1E},
728             {0xFB, 0x04, 0x15, 0x18},
729             {0x00, 0x06, 0x10, 0x14},
730             {0xFF, 0xFF, 0xFF, 0xFF} } },
731         { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_7 */
732             {0xF5, 0xEE, 0x1B, 0x44},
733             {0xF8, 0xF4, 0x18, 0x38},
734             {0xFC, 0xFB, 0x14, 0x2A},
735             {0xEB, 0x05, 0x25, 0x16},
736             {0xF1, 0x05, 0x1F, 0x16},
737             {0xFA, 0x07, 0x16, 0x12},
738             {0x00, 0x07, 0x10, 0x12},
739             {0xFF, 0xFF, 0xFF, 0xFF} } }
740 };
741
742 static int           filter = -1;
743 static unsigned char filter_tb;
744
745 #endif