• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _XGIFB_MAIN
2 #define _XGIFB_MAIN
3 /* ------------------- Constant Definitions ------------------------- */
4 #include "XGIfb.h"
5 #include "vb_def.h"
6 
7 #define PCI_DEVICE_ID_XGI_42      0x042
8 #define PCI_DEVICE_ID_XGI_27      0x027
9 
10 static const struct pci_device_id xgifb_pci_table[] = {
11 	{PCI_DEVICE(PCI_VENDOR_ID_XGI, PCI_DEVICE_ID_XGI_20)},
12 	{PCI_DEVICE(PCI_VENDOR_ID_XGI, PCI_DEVICE_ID_XGI_27)},
13 	{PCI_DEVICE(PCI_VENDOR_ID_XGI, PCI_DEVICE_ID_XGI_40)},
14 	{PCI_DEVICE(PCI_VENDOR_ID_XGI, PCI_DEVICE_ID_XGI_42)},
15 	{0}
16 };
17 
18 MODULE_DEVICE_TABLE(pci, xgifb_pci_table);
19 
20 /* To be included in fb.h */
21 #define XGISR			  (xgifb_info->dev_info.P3c4)
22 #define XGICR			  (xgifb_info->dev_info.P3d4)
23 #define XGIDACA			  (xgifb_info->dev_info.P3c8)
24 #define XGIDACD			  (xgifb_info->dev_info.P3c9)
25 #define XGIPART1		  (xgifb_info->dev_info.Part1Port)
26 #define XGIPART2		  (xgifb_info->dev_info.Part2Port)
27 #define XGIPART3		  (xgifb_info->dev_info.Part3Port)
28 #define XGIPART4		  (xgifb_info->dev_info.Part4Port)
29 #define XGIPART5		  (xgifb_info->dev_info.Part5Port)
30 #define XGIDAC2A                  XGIPART5
31 #define XGIDAC2D                  (XGIPART5 + 1)
32 
33 #define IND_XGI_SCRATCH_REG_CR30  0x30  /* CRs */
34 #define IND_XGI_SCRATCH_REG_CR31  0x31
35 #define IND_XGI_SCRATCH_REG_CR32  0x32
36 #define IND_XGI_SCRATCH_REG_CR33  0x33
37 #define IND_XGI_LCD_PANEL         0x36
38 #define IND_XGI_SCRATCH_REG_CR37  0x37
39 
40 #define XGI_DRAM_SIZE_MASK     0xF0  /*SR14 */
41 #define XGI_DRAM_SIZE_1MB      0x00
42 #define XGI_DRAM_SIZE_2MB      0x01
43 #define XGI_DRAM_SIZE_4MB      0x02
44 #define XGI_DRAM_SIZE_8MB      0x03
45 #define XGI_DRAM_SIZE_16MB     0x04
46 #define XGI_DRAM_SIZE_32MB     0x05
47 #define XGI_DRAM_SIZE_64MB     0x06
48 #define XGI_DRAM_SIZE_128MB    0x07
49 #define XGI_DRAM_SIZE_256MB    0x08
50 
51 /* ------------------- Global Variables ----------------------------- */
52 
53 /* display status */
54 static int XGIfb_crt1off;
55 static int XGIfb_forcecrt1 = -1;
56 
57 /* global flags */
58 static int XGIfb_tvmode;
59 static int enable_dstn;
60 static int XGIfb_ypan = -1;
61 
62 /* TW: CRT2 type (for overriding autodetection) */
63 static int XGIfb_crt2type = -1;
64 /* PR: Tv plug type (for overriding autodetection) */
65 static int XGIfb_tvplug = -1;
66 
67 #define MD_XGI315 1
68 
69 /* mode table */
70 static const struct _XGIbios_mode {
71 	u8 mode_no;
72 	u16 vesa_mode_no_1;  /* "XGI defined" VESA mode number */
73 	u16 vesa_mode_no_2;  /* Real VESA mode numbers */
74 	u16 xres;
75 	u16 yres;
76 	u16 bpp;
77 	u8  chipset;
78 } XGIbios_mode[] = {
79 	{ 0x56, 0x0000, 0x0000,  320,  240, 16, MD_XGI315 },
80 	{ 0x5A, 0x0000, 0x0000,  320,  480,  8, MD_XGI315 },
81 	{ 0x5B, 0x0000, 0x0000,  320,  480, 16, MD_XGI315 },
82 	{ 0x2E, 0x0101, 0x0101,  640,  480,  8, MD_XGI315 },
83 	{ 0x44, 0x0111, 0x0111,  640,  480, 16, MD_XGI315 },
84 	{ 0x62, 0x013a, 0x0112,  640,  480, 32, MD_XGI315 },
85 	{ 0x31, 0x0000, 0x0000,  720,  480,  8, MD_XGI315 },
86 	{ 0x33, 0x0000, 0x0000,  720,  480, 16, MD_XGI315 },
87 	{ 0x35, 0x0000, 0x0000,  720,  480, 32, MD_XGI315 },
88 	{ 0x32, 0x0000, 0x0000,  720,  576,  8, MD_XGI315 },
89 	{ 0x34, 0x0000, 0x0000,  720,  576, 16, MD_XGI315 },
90 	{ 0x36, 0x0000, 0x0000,  720,  576, 32, MD_XGI315 },
91 	{ 0x36, 0x0000, 0x0000,  720,  576, 32, MD_XGI315 },
92 	{ 0x70, 0x0000, 0x0000,  800,  480,  8, MD_XGI315 },
93 	{ 0x7a, 0x0000, 0x0000,  800,  480, 16, MD_XGI315 },
94 	{ 0x76, 0x0000, 0x0000,  800,  480, 32, MD_XGI315 },
95 	{ 0x30, 0x0103, 0x0103,  800,  600,  8, MD_XGI315 },
96 #define DEFAULT_MODE              17 /* index for 800x600x16 */
97 	{ 0x47, 0x0114, 0x0114,  800,  600, 16, MD_XGI315 },
98 	{ 0x63, 0x013b, 0x0115,  800,  600, 32, MD_XGI315 },
99 	{ 0x71, 0x0000, 0x0000, 1024,  576,  8, MD_XGI315 },
100 	{ 0x74, 0x0000, 0x0000, 1024,  576, 16, MD_XGI315 },
101 	{ 0x77, 0x0000, 0x0000, 1024,  576, 32, MD_XGI315 },
102 	{ 0x77, 0x0000, 0x0000, 1024,  576, 32, MD_XGI315 },
103 	{ 0x20, 0x0000, 0x0000, 1024,  600,  8, },
104 	{ 0x21, 0x0000, 0x0000, 1024,  600, 16, },
105 	{ 0x22, 0x0000, 0x0000, 1024,  600, 32, },
106 	{ 0x38, 0x0105, 0x0105, 1024,  768,  8, MD_XGI315 },
107 	{ 0x4A, 0x0117, 0x0117, 1024,  768, 16, MD_XGI315 },
108 	{ 0x64, 0x013c, 0x0118, 1024,  768, 32, MD_XGI315 },
109 	{ 0x64, 0x013c, 0x0118, 1024,  768, 32, MD_XGI315 },
110 	{ 0x23, 0x0000, 0x0000, 1152,  768,  8, },
111 	{ 0x24, 0x0000, 0x0000, 1152,  768, 16, },
112 	{ 0x25, 0x0000, 0x0000, 1152,  768, 32, },
113 	{ 0x79, 0x0000, 0x0000, 1280,  720,  8, MD_XGI315 },
114 	{ 0x75, 0x0000, 0x0000, 1280,  720, 16, MD_XGI315 },
115 	{ 0x78, 0x0000, 0x0000, 1280,  720, 32, MD_XGI315 },
116 	{ 0x23, 0x0000, 0x0000, 1280,  768,  8, MD_XGI315 },
117 	{ 0x24, 0x0000, 0x0000, 1280,  768, 16, MD_XGI315 },
118 	{ 0x25, 0x0000, 0x0000, 1280,  768, 32, MD_XGI315 },
119 	{ 0x7C, 0x0000, 0x0000, 1280,  960,  8, MD_XGI315 },
120 	{ 0x7D, 0x0000, 0x0000, 1280,  960, 16, MD_XGI315 },
121 	{ 0x7E, 0x0000, 0x0000, 1280,  960, 32, MD_XGI315 },
122 	{ 0x3A, 0x0107, 0x0107, 1280, 1024,  8, MD_XGI315 },
123 	{ 0x4D, 0x011a, 0x011a, 1280, 1024, 16, MD_XGI315 },
124 	{ 0x65, 0x013d, 0x011b, 1280, 1024, 32, MD_XGI315 },
125 	{ 0x26, 0x0000, 0x0000, 1400, 1050,  8, MD_XGI315 },
126 	{ 0x27, 0x0000, 0x0000, 1400, 1050, 16, MD_XGI315 },
127 	{ 0x28, 0x0000, 0x0000, 1400, 1050, 32, MD_XGI315 },
128 	{ 0x3C, 0x0130, 0x011c, 1600, 1200,  8, MD_XGI315 },
129 	{ 0x3D, 0x0131, 0x011e, 1600, 1200, 16, MD_XGI315 },
130 	{ 0x66, 0x013e, 0x011f, 1600, 1200, 32, MD_XGI315 },
131 	{ 0x68, 0x013f, 0x0000, 1920, 1440,  8, MD_XGI315 },
132 	{ 0x69, 0x0140, 0x0000, 1920, 1440, 16, MD_XGI315 },
133 	{ 0x6B, 0x0141, 0x0000, 1920, 1440, 32, MD_XGI315 },
134 	{ 0x6c, 0x0000, 0x0000, 2048, 1536,  8, MD_XGI315 },
135 	{ 0x6d, 0x0000, 0x0000, 2048, 1536, 16, MD_XGI315 },
136 	{ 0x6e, 0x0000, 0x0000, 2048, 1536, 32, MD_XGI315 },
137 	{ 0 },
138 };
139 
140 static const unsigned short XGI310paneltype[] = {
141 	 LCD_UNKNOWN,   LCD_800x600, LCD_1024x768, LCD_1280x1024,
142 	 LCD_640x480,  LCD_1024x600, LCD_1152x864, LCD_1280x960,
143 	LCD_1152x768, LCD_1400x1050, LCD_1280x768, LCD_1600x1200,
144 	LCD_1024x768,  LCD_1024x768, LCD_1024x768};
145 
146 static const struct _XGI_crt2type {
147 	char name[10];
148 	int type_no;
149 	int tvplug_no;
150 } XGI_crt2type[] = {
151 	{"NONE",	0,		-1},
152 	{"LCD",		XGIFB_DISP_LCD,	-1},
153 	{"TV",		XGIFB_DISP_TV,	-1},
154 	{"VGA",		XGIFB_DISP_CRT,	-1},
155 	{"SVIDEO",	XGIFB_DISP_TV,	TVPLUG_SVIDEO},
156 	{"COMPOSITE",	XGIFB_DISP_TV,	TVPLUG_COMPOSITE},
157 	{"SCART",	XGIFB_DISP_TV,	TVPLUG_SCART},
158 	{"none",	0,		-1},
159 	{"lcd",		XGIFB_DISP_LCD,	-1},
160 	{"tv",		XGIFB_DISP_TV,	-1},
161 	{"vga",		XGIFB_DISP_CRT,	-1},
162 	{"svideo",	XGIFB_DISP_TV,	TVPLUG_SVIDEO},
163 	{"composite",	XGIFB_DISP_TV,	TVPLUG_COMPOSITE},
164 	{"scart",	XGIFB_DISP_TV,	TVPLUG_SCART},
165 	{"\0",		-1,		-1}
166 };
167 
168 /* TV standard */
169 static const struct _XGI_tvtype {
170 	char name[6];
171 	int type_no;
172 } XGI_tvtype[] = {
173 	{"PAL",		1},
174 	{"NTSC",	2},
175 	{"pal",		1},
176 	{"ntsc",	2},
177 	{"\0",		-1}
178 };
179 
180 static const struct _XGI_vrate {
181 	u16 idx;
182 	u16 xres;
183 	u16 yres;
184 	u16 refresh;
185 } XGIfb_vrate[] = {
186 	{1,  640,  480, 60}, {2,  640,  480,  72},
187 	{3, 640,   480,  75}, {4,  640, 480,  85},
188 
189 	{5,  640,  480, 100}, {6,  640,  480, 120},
190 	{7, 640,   480, 160}, {8,  640, 480, 200},
191 
192 	{1,  720,  480, 60},
193 	{1,  720,  576, 58},
194 	{1,  800,  480, 60}, {2,  800,  480,  75}, {3, 800,   480,  85},
195 	{1,  800,  600,  60}, {2, 800,   600,  72}, {3,  800, 600,  75},
196 	{4,  800,  600, 85}, {5,  800,  600, 100},
197 	{6, 800,   600, 120}, {7,  800, 600, 160},
198 
199 	{1, 1024,  768,  60}, {2, 1024,  768,  70}, {3, 1024, 768,  75},
200 	{4, 1024,  768, 85}, {5, 1024,  768, 100}, {6, 1024,  768, 120},
201 	{1, 1024,  576, 60}, {2, 1024,  576,  75}, {3, 1024,  576,  85},
202 	{1, 1024,  600, 60},
203 	{1, 1152,  768, 60},
204 	{1, 1280,  720, 60}, {2, 1280,  720,  75}, {3, 1280,  720,  85},
205 	{1, 1280,  768, 60},
206 	{1, 1280, 1024,  60}, {2, 1280, 1024,  75}, {3, 1280, 1024,  85},
207 	{1, 1280,  960, 70},
208 	{1, 1400, 1050, 60},
209 	{1, 1600, 1200, 60}, {2, 1600, 1200,  65},
210 	{3, 1600, 1200,  70}, {4, 1600, 1200,  75},
211 
212 	{5, 1600, 1200, 85}, {6, 1600, 1200, 100},
213 	{7, 1600, 1200, 120},
214 
215 	{1, 1920, 1440, 60}, {2, 1920, 1440,  65},
216 	{3, 1920, 1440,  70}, {4, 1920, 1440,  75},
217 
218 	{5, 1920, 1440, 85}, {6, 1920, 1440, 100},
219 	{1, 2048, 1536, 60}, {2, 2048, 1536,  65},
220 	{3, 2048, 1536,  70}, {4, 2048, 1536,  75},
221 
222 	{5, 2048, 1536, 85},
223 	{0, 0, 0, 0}
224 };
225 
226 static const struct _XGI_TV_filter {
227 	u8 filter[9][4];
228 } XGI_TV_filter[] = {
229 	{ { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_0 */
230 	    {0x00, 0xE0, 0x10, 0x60},
231 	    {0x00, 0xEE, 0x10, 0x44},
232 	    {0x00, 0xF4, 0x10, 0x38},
233 	    {0xF8, 0xF4, 0x18, 0x38},
234 	    {0xFC, 0xFB, 0x14, 0x2A},
235 	    {0x00, 0x00, 0x10, 0x20},
236 	    {0x00, 0x04, 0x10, 0x18},
237 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
238 	{ { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_1 */
239 	    {0x00, 0xE0, 0x10, 0x60},
240 	    {0x00, 0xEE, 0x10, 0x44},
241 	    {0x00, 0xF4, 0x10, 0x38},
242 	    {0xF8, 0xF4, 0x18, 0x38},
243 	    {0xFC, 0xFB, 0x14, 0x2A},
244 	    {0x00, 0x00, 0x10, 0x20},
245 	    {0x00, 0x04, 0x10, 0x18},
246 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
247 	{ { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_2 */
248 	    {0xF5, 0xEE, 0x1B, 0x44},
249 	    {0xF8, 0xF4, 0x18, 0x38},
250 	    {0xEB, 0x04, 0x25, 0x18},
251 	    {0xF1, 0x05, 0x1F, 0x16},
252 	    {0xF6, 0x06, 0x1A, 0x14},
253 	    {0xFA, 0x06, 0x16, 0x14},
254 	    {0x00, 0x04, 0x10, 0x18},
255 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
256 	{ { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_3 */
257 	    {0xF1, 0x04, 0x1F, 0x18},
258 	    {0xEE, 0x0D, 0x22, 0x06},
259 	    {0xF7, 0x06, 0x19, 0x14},
260 	    {0xF4, 0x0B, 0x1C, 0x0A},
261 	    {0xFA, 0x07, 0x16, 0x12},
262 	    {0xF9, 0x0A, 0x17, 0x0C},
263 	    {0x00, 0x07, 0x10, 0x12},
264 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
265 	{ { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_4 */
266 	    {0x00, 0xE0, 0x10, 0x60},
267 	    {0x00, 0xEE, 0x10, 0x44},
268 	    {0x00, 0xF4, 0x10, 0x38},
269 	    {0xF8, 0xF4, 0x18, 0x38},
270 	    {0xFC, 0xFB, 0x14, 0x2A},
271 	    {0x00, 0x00, 0x10, 0x20},
272 	    {0x00, 0x04, 0x10, 0x18},
273 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
274 	{ { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_5 */
275 	    {0xF5, 0xEE, 0x1B, 0x44},
276 	    {0xF8, 0xF4, 0x18, 0x38},
277 	    {0xEB, 0x04, 0x25, 0x18},
278 	    {0xF1, 0x05, 0x1F, 0x16},
279 	    {0xF6, 0x06, 0x1A, 0x14},
280 	    {0xFA, 0x06, 0x16, 0x14},
281 	    {0x00, 0x04, 0x10, 0x18},
282 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
283 	{ { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_6 */
284 	    {0xEB, 0x04, 0x25, 0x18},
285 	    {0xE7, 0x0E, 0x29, 0x04},
286 	    {0xEE, 0x0C, 0x22, 0x08},
287 	    {0xF6, 0x0B, 0x1A, 0x0A},
288 	    {0xF9, 0x0A, 0x17, 0x0C},
289 	    {0xFC, 0x0A, 0x14, 0x0C},
290 	    {0x00, 0x08, 0x10, 0x10},
291 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
292 	{ { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_7 */
293 	    {0xEC, 0x02, 0x24, 0x1C},
294 	    {0xF2, 0x04, 0x1E, 0x18},
295 	    {0xEB, 0x15, 0x25, 0xF6},
296 	    {0xF4, 0x10, 0x1C, 0x00},
297 	    {0xF8, 0x0F, 0x18, 0x02},
298 	    {0x00, 0x04, 0x10, 0x18},
299 	    {0x01, 0x06, 0x0F, 0x14},
300 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
301 	{ { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_0 */
302 	    {0x00, 0xE0, 0x10, 0x60},
303 	    {0x00, 0xEE, 0x10, 0x44},
304 	    {0x00, 0xF4, 0x10, 0x38},
305 	    {0xF8, 0xF4, 0x18, 0x38},
306 	    {0xFC, 0xFB, 0x14, 0x2A},
307 	    {0x00, 0x00, 0x10, 0x20},
308 	    {0x00, 0x04, 0x10, 0x18},
309 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
310 	{ { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_1 */
311 	    {0x00, 0xE0, 0x10, 0x60},
312 	    {0x00, 0xEE, 0x10, 0x44},
313 	    {0x00, 0xF4, 0x10, 0x38},
314 	    {0xF8, 0xF4, 0x18, 0x38},
315 	    {0xFC, 0xFB, 0x14, 0x2A},
316 	    {0x00, 0x00, 0x10, 0x20},
317 	    {0x00, 0x04, 0x10, 0x18},
318 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
319 	{ { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_2 */
320 	    {0xF5, 0xEE, 0x1B, 0x44},
321 	    {0xF8, 0xF4, 0x18, 0x38},
322 	    {0xF1, 0xF7, 0x01, 0x32},
323 	    {0xF5, 0xFB, 0x1B, 0x2A},
324 	    {0xF9, 0xFF, 0x17, 0x22},
325 	    {0xFB, 0x01, 0x15, 0x1E},
326 	    {0x00, 0x04, 0x10, 0x18},
327 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
328 	{ { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_3 */
329 	    {0xF5, 0xFB, 0x1B, 0x2A},
330 	    {0xEE, 0xFE, 0x22, 0x24},
331 	    {0xF3, 0x00, 0x1D, 0x20},
332 	    {0xF9, 0x03, 0x17, 0x1A},
333 	    {0xFB, 0x02, 0x14, 0x1E},
334 	    {0xFB, 0x04, 0x15, 0x18},
335 	    {0x00, 0x06, 0x10, 0x14},
336 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
337 	{ { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_4 */
338 	    {0x00, 0xE0, 0x10, 0x60},
339 	    {0x00, 0xEE, 0x10, 0x44},
340 	    {0x00, 0xF4, 0x10, 0x38},
341 	    {0xF8, 0xF4, 0x18, 0x38},
342 	    {0xFC, 0xFB, 0x14, 0x2A},
343 	    {0x00, 0x00, 0x10, 0x20},
344 	    {0x00, 0x04, 0x10, 0x18},
345 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
346 	{ { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_5 */
347 	    {0xF5, 0xEE, 0x1B, 0x44},
348 	    {0xF8, 0xF4, 0x18, 0x38},
349 	    {0xF1, 0xF7, 0x1F, 0x32},
350 	    {0xF5, 0xFB, 0x1B, 0x2A},
351 	    {0xF9, 0xFF, 0x17, 0x22},
352 	    {0xFB, 0x01, 0x15, 0x1E},
353 	    {0x00, 0x04, 0x10, 0x18},
354 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
355 	{ { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_6 */
356 	    {0xF5, 0xEE, 0x1B, 0x2A},
357 	    {0xEE, 0xFE, 0x22, 0x24},
358 	    {0xF3, 0x00, 0x1D, 0x20},
359 	    {0xF9, 0x03, 0x17, 0x1A},
360 	    {0xFB, 0x02, 0x14, 0x1E},
361 	    {0xFB, 0x04, 0x15, 0x18},
362 	    {0x00, 0x06, 0x10, 0x14},
363 	    {0xFF, 0xFF, 0xFF, 0xFF} } },
364 	{ { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_7 */
365 	    {0xF5, 0xEE, 0x1B, 0x44},
366 	    {0xF8, 0xF4, 0x18, 0x38},
367 	    {0xFC, 0xFB, 0x14, 0x2A},
368 	    {0xEB, 0x05, 0x25, 0x16},
369 	    {0xF1, 0x05, 0x1F, 0x16},
370 	    {0xFA, 0x07, 0x16, 0x12},
371 	    {0x00, 0x07, 0x10, 0x12},
372 	    {0xFF, 0xFF, 0xFF, 0xFF} } }
373 };
374 
375 static int           filter = -1;
376 
377 #endif
378