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