aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorapatard@mandriva.com <apatard@mandriva.com>2010-05-19 04:44:14 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-06-04 16:38:51 -0400
commitd7636e0b0769e0f4f437ff33168d723f86e7c080 (patch)
tree0c0034d98e4409f5347ce8abbf1af479fd8b150d /drivers
parentad8456361fa19068cf49b50a4f98e41b73c08e76 (diff)
staging: Add framebuffer driver for XGI chipsets
This driver handles XG20, XG21, XG40, XG42 chipsets from XGI. They're also known as Z7,Z9,Z11 chipsets. It's based on the SiS fb driver but has been heavily modified by XGI to support their newer chipsets. Signed-off-by: Arnaud Patard <apatard@mandriva.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/Kconfig2
-rw-r--r--drivers/staging/Makefile1
-rw-r--r--drivers/staging/xgifb/Kconfig11
-rw-r--r--drivers/staging/xgifb/Makefile4
-rw-r--r--drivers/staging/xgifb/TODO15
-rw-r--r--drivers/staging/xgifb/XGI.h10
-rw-r--r--drivers/staging/xgifb/XGI_accel.c596
-rw-r--r--drivers/staging/xgifb/XGI_accel.h511
-rw-r--r--drivers/staging/xgifb/XGI_main.h1023
-rw-r--r--drivers/staging/xgifb/XGI_main_26.c3773
-rw-r--r--drivers/staging/xgifb/XGIfb.h215
-rw-r--r--drivers/staging/xgifb/osdef.h153
-rw-r--r--drivers/staging/xgifb/vb_def.h1017
-rw-r--r--drivers/staging/xgifb/vb_ext.c1370
-rw-r--r--drivers/staging/xgifb/vb_ext.h32
-rw-r--r--drivers/staging/xgifb/vb_init.c3444
-rw-r--r--drivers/staging/xgifb/vb_init.h7
-rw-r--r--drivers/staging/xgifb/vb_setmode.c10736
-rw-r--r--drivers/staging/xgifb/vb_setmode.h40
-rw-r--r--drivers/staging/xgifb/vb_struct.h534
-rw-r--r--drivers/staging/xgifb/vb_table.h4406
-rw-r--r--drivers/staging/xgifb/vb_util.c263
-rw-r--r--drivers/staging/xgifb/vb_util.h15
-rw-r--r--drivers/staging/xgifb/vgatypes.h325
24 files changed, 28503 insertions, 0 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index b5c3b301303..2a1a7c29642 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -141,5 +141,7 @@ source "drivers/staging/ti-st/Kconfig"
141 141
142source "drivers/staging/adis16255/Kconfig" 142source "drivers/staging/adis16255/Kconfig"
143 143
144source "drivers/staging/xgifb/Kconfig"
145
144endif # !STAGING_EXCLUDE_BUILD 146endif # !STAGING_EXCLUDE_BUILD
145endif # STAGING 147endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index e330dd5e843..4a02c0df9ce 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -51,3 +51,4 @@ obj-$(CONFIG_CRYSTALHD) += crystalhd/
51obj-$(CONFIG_CXT1E1) += cxt1e1/ 51obj-$(CONFIG_CXT1E1) += cxt1e1/
52obj-$(CONFIG_TI_ST) += ti-st/ 52obj-$(CONFIG_TI_ST) += ti-st/
53obj-$(CONFIG_ADIS16255) += adis16255/ 53obj-$(CONFIG_ADIS16255) += adis16255/
54obj-$(CONFIG_FB_XGI) += xgifb/
diff --git a/drivers/staging/xgifb/Kconfig b/drivers/staging/xgifb/Kconfig
new file mode 100644
index 00000000000..bb0ca5974ea
--- /dev/null
+++ b/drivers/staging/xgifb/Kconfig
@@ -0,0 +1,11 @@
1config FB_XGI
2 tristate "XGI display support"
3 depends on FB && PCI
4 select FB_CFB_FILLRECT
5 select FB_CFB_COPYAREA
6 select FB_CFB_IMAGEBLIT
7 help
8 This driver supports notebooks with XGI Z7,Z9,Z11 PCI chips.
9 Say Y if you have such a graphics card.
10 To compile this driver as a module, choose M here: the
11 module will be called xgifb.ko
diff --git a/drivers/staging/xgifb/Makefile b/drivers/staging/xgifb/Makefile
new file mode 100644
index 00000000000..2a317707de0
--- /dev/null
+++ b/drivers/staging/xgifb/Makefile
@@ -0,0 +1,4 @@
1obj-$(CONFIG_FB_XGI) += xgifb.o
2
3xgifb-objs := XGI_main_26.o XGI_accel.o vb_init.o vb_setmode.o vb_util.o vb_ext.o
4
diff --git a/drivers/staging/xgifb/TODO b/drivers/staging/xgifb/TODO
new file mode 100644
index 00000000000..7d71019b84c
--- /dev/null
+++ b/drivers/staging/xgifb/TODO
@@ -0,0 +1,15 @@
1This drivers still need a lot of work. I can list all cleanups to do but it's
2going to be long. So, I'm writing "cleanups" and not the list.
3
4Arnaud
5
6TODO:
7- clean ups
8- fix build warnings when module
9- sort out dup ids with SiS driver
10- remove useless/wrong/unused #ifdef/code/...
11- fix printk usages
12- get rid of non-linux related stuff
13
14Please send patches to:
15Arnaud Patard <apatard@mandriva.com>
diff --git a/drivers/staging/xgifb/XGI.h b/drivers/staging/xgifb/XGI.h
new file mode 100644
index 00000000000..87803dd032d
--- /dev/null
+++ b/drivers/staging/xgifb/XGI.h
@@ -0,0 +1,10 @@
1#ifndef _XGI_H
2#define _XGI_H
3
4#if 1
5#define TWDEBUG(x)
6#else
7#define TWDEBUG(x) printk(KERN_INFO x "\n");
8#endif
9
10#endif
diff --git a/drivers/staging/xgifb/XGI_accel.c b/drivers/staging/xgifb/XGI_accel.c
new file mode 100644
index 00000000000..86ec3421942
--- /dev/null
+++ b/drivers/staging/xgifb/XGI_accel.c
@@ -0,0 +1,596 @@
1/*
2 * XGI 300/630/730/540/315/550/650/740 frame buffer driver
3 * for Linux kernels 2.4.x and 2.5.x
4 *
5 * 2D acceleration part
6 *
7 * Based on the X driver's XGI300_accel.c which is
8 * Copyright Xavier Ducoin <x.ducoin@lectra.com>
9 * Copyright 2002 by Thomas Winischhofer, Vienna, Austria
10 * and XGI310_accel.c which is
11 * Copyright 2002 by Thomas Winischhofer, Vienna, Austria
12 *
13 * Author: Thomas Winischhofer <thomas@winischhofer.net>
14 * (see http://www.winischhofer.net/
15 * for more information and updates)
16 */
17
18//#include <linux/config.h>
19#include <linux/version.h>
20#include <linux/module.h>
21#include <linux/kernel.h>
22#include <linux/errno.h>
23#include <linux/string.h>
24#include <linux/mm.h>
25#include <linux/tty.h>
26#include <linux/slab.h>
27#include <linux/delay.h>
28#include <linux/fb.h>
29#include <linux/console.h>
30#include <linux/selection.h>
31#include <linux/ioport.h>
32#include <linux/init.h>
33#include <linux/pci.h>
34#include <linux/vt_kern.h>
35#include <linux/capability.h>
36#include <linux/fs.h>
37#include <linux/agp_backend.h>
38
39#include <linux/types.h>
40/*
41#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
42#include <linux/XGIfb.h>
43#else
44#include <video/XGIfb.h>
45#endif
46*/
47#include <asm/io.h>
48
49#ifdef CONFIG_MTRR
50#include <asm/mtrr.h>
51#endif
52
53#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
54#include <video/fbcon.h>
55#include <video/fbcon-cfb8.h>
56#include <video/fbcon-cfb16.h>
57#include <video/fbcon-cfb24.h>
58#include <video/fbcon-cfb32.h>
59#endif
60
61#include "osdef.h"
62#include "vgatypes.h"
63#include "vb_struct.h"
64#include "XGIfb.h"
65#include "XGI_accel.h"
66
67
68extern struct video_info xgi_video_info;
69extern int XGIfb_accel;
70
71static const int XGIALUConv[] =
72{
73 0x00, /* dest = 0; 0, GXclear, 0 */
74 0x88, /* dest &= src; DSa, GXand, 0x1 */
75 0x44, /* dest = src & ~dest; SDna, GXandReverse, 0x2 */
76 0xCC, /* dest = src; S, GXcopy, 0x3 */
77 0x22, /* dest &= ~src; DSna, GXandInverted, 0x4 */
78 0xAA, /* dest = dest; D, GXnoop, 0x5 */
79 0x66, /* dest = ^src; DSx, GXxor, 0x6 */
80 0xEE, /* dest |= src; DSo, GXor, 0x7 */
81 0x11, /* dest = ~src & ~dest; DSon, GXnor, 0x8 */
82 0x99, /* dest ^= ~src ; DSxn, GXequiv, 0x9 */
83 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */
84 0xDD, /* dest = src|~dest ; SDno, GXorReverse, 0xB */
85 0x33, /* dest = ~src; Sn, GXcopyInverted, 0xC */
86 0xBB, /* dest |= ~src; DSno, GXorInverted, 0xD */
87 0x77, /* dest = ~src|~dest; DSan, GXnand, 0xE */
88 0xFF, /* dest = 0xFF; 1, GXset, 0xF */
89};
90/* same ROP but with Pattern as Source */
91static const int XGIPatALUConv[] =
92{
93 0x00, /* dest = 0; 0, GXclear, 0 */
94 0xA0, /* dest &= src; DPa, GXand, 0x1 */
95 0x50, /* dest = src & ~dest; PDna, GXandReverse, 0x2 */
96 0xF0, /* dest = src; P, GXcopy, 0x3 */
97 0x0A, /* dest &= ~src; DPna, GXandInverted, 0x4 */
98 0xAA, /* dest = dest; D, GXnoop, 0x5 */
99 0x5A, /* dest = ^src; DPx, GXxor, 0x6 */
100 0xFA, /* dest |= src; DPo, GXor, 0x7 */
101 0x05, /* dest = ~src & ~dest; DPon, GXnor, 0x8 */
102 0xA5, /* dest ^= ~src ; DPxn, GXequiv, 0x9 */
103 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */
104 0xF5, /* dest = src|~dest ; PDno, GXorReverse, 0xB */
105 0x0F, /* dest = ~src; Pn, GXcopyInverted, 0xC */
106 0xAF, /* dest |= ~src; DPno, GXorInverted, 0xD */
107 0x5F, /* dest = ~src|~dest; DPan, GXnand, 0xE */
108 0xFF, /* dest = 0xFF; 1, GXset, 0xF */
109};
110
111#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,34)
112static const unsigned char myrops[] = {
113 3, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
114 };
115#endif
116
117/* 300 series */
118#if 0
119static void
120XGI300Sync(void)
121{
122 XGI300Idle
123}
124#endif
125static void
126XGI310Sync(void)
127{
128 XGI310Idle
129}
130#if 0
131static void
132XGI300SetupForScreenToScreenCopy(int xdir, int ydir, int rop,
133 unsigned int planemask, int trans_color)
134{
135 XGI300SetupDSTColorDepth(xgi_video_info.DstColor);
136 XGI300SetupSRCPitch(xgi_video_info.video_linelength)
137 XGI300SetupDSTRect(xgi_video_info.video_linelength, 0xFFF)
138
139 if(trans_color != -1) {
140 XGI300SetupROP(0x0A)
141 XGI300SetupSRCTrans(trans_color)
142 XGI300SetupCMDFlag(TRANSPARENT_BITBLT)
143 } else {
144 XGI300SetupROP(XGIALUConv[rop])
145 }
146 if(xdir > 0) {
147 XGI300SetupCMDFlag(X_INC)
148 }
149 if(ydir > 0) {
150 XGI300SetupCMDFlag(Y_INC)
151 }
152}
153
154static void
155XGI300SubsequentScreenToScreenCopy(int src_x, int src_y, int dst_x, int dst_y,
156 int width, int height)
157{
158 long srcbase, dstbase;
159
160 srcbase = dstbase = 0;
161 if (src_y >= 2048) {
162 srcbase = xgi_video_info.video_linelength * src_y;
163 src_y = 0;
164 }
165 if (dst_y >= 2048) {
166 dstbase = xgi_video_info.video_linelength * dst_y;
167 dst_y = 0;
168 }
169
170 XGI300SetupSRCBase(srcbase);
171 XGI300SetupDSTBase(dstbase);
172
173 if(!(xgi_video_info.CommandReg & X_INC)) {
174 src_x += width-1;
175 dst_x += width-1;
176 }
177 if(!(xgi_video_info.CommandReg & Y_INC)) {
178 src_y += height-1;
179 dst_y += height-1;
180 }
181 XGI300SetupRect(width, height)
182 XGI300SetupSRCXY(src_x, src_y)
183 XGI300SetupDSTXY(dst_x, dst_y)
184 XGI300DoCMD
185}
186
187static void
188XGI300SetupForSolidFill(int color, int rop, unsigned int planemask)
189{
190 XGI300SetupPATFG(color)
191 XGI300SetupDSTRect(xgi_video_info.video_linelength, 0xFFF)
192 XGI300SetupDSTColorDepth(xgi_video_info.DstColor);
193 XGI300SetupROP(XGIPatALUConv[rop])
194 XGI300SetupCMDFlag(PATFG)
195}
196
197static void
198XGI300SubsequentSolidFillRect(int x, int y, int w, int h)
199{
200 long dstbase;
201
202 dstbase = 0;
203 if(y >= 2048) {
204 dstbase = xgi_video_info.video_linelength * y;
205 y = 0;
206 }
207 XGI300SetupDSTBase(dstbase)
208 XGI300SetupDSTXY(x,y)
209 XGI300SetupRect(w,h)
210 XGI300SetupCMDFlag(X_INC | Y_INC | BITBLT)
211 XGI300DoCMD
212}
213#endif
214/* 310/325 series ------------------------------------------------ */
215
216static void
217XGI310SetupForScreenToScreenCopy(int xdir, int ydir, int rop,
218 unsigned int planemask, int trans_color)
219{
220 XGI310SetupDSTColorDepth(xgi_video_info.DstColor);
221 XGI310SetupSRCPitch(xgi_video_info.video_linelength)
222 XGI310SetupDSTRect(xgi_video_info.video_linelength, 0xFFF)
223 if (trans_color != -1) {
224 XGI310SetupROP(0x0A)
225 XGI310SetupSRCTrans(trans_color)
226 XGI310SetupCMDFlag(TRANSPARENT_BITBLT)
227 } else {
228 XGI310SetupROP(XGIALUConv[rop])
229 /* Set command - not needed, both 0 */
230 /* XGISetupCMDFlag(BITBLT | SRCVIDEO) */
231 }
232 XGI310SetupCMDFlag(xgi_video_info.XGI310_AccelDepth)
233 /* TW: The 310/325 series is smart enough to know the direction */
234}
235
236static void
237XGI310SubsequentScreenToScreenCopy(int src_x, int src_y, int dst_x, int dst_y,
238 int width, int height)
239{
240 long srcbase, dstbase;
241 int mymin, mymax;
242
243 srcbase = dstbase = 0;
244 mymin = min(src_y, dst_y);
245 mymax = max(src_y, dst_y);
246
247 /* Although the chip knows the direction to use
248 * if the source and destination areas overlap,
249 * that logic fails if we fiddle with the bitmap
250 * addresses. Therefore, we check if the source
251 * and destination blitting areas overlap and
252 * adapt the bitmap addresses synchronously
253 * if the coordinates exceed the valid range.
254 * The the areas do not overlap, we do our
255 * normal check.
256 */
257 if((mymax - mymin) < height) {
258 if((src_y >= 2048) || (dst_y >= 2048)) {
259 srcbase = xgi_video_info.video_linelength * mymin;
260 dstbase = xgi_video_info.video_linelength * mymin;
261 src_y -= mymin;
262 dst_y -= mymin;
263 }
264 } else {
265 if(src_y >= 2048) {
266 srcbase = xgi_video_info.video_linelength * src_y;
267 src_y = 0;
268 }
269 if(dst_y >= 2048) {
270 dstbase = xgi_video_info.video_linelength * dst_y;
271 dst_y = 0;
272 }
273 }
274
275 XGI310SetupSRCBase(srcbase);
276 XGI310SetupDSTBase(dstbase);
277 XGI310SetupRect(width, height)
278 XGI310SetupSRCXY(src_x, src_y)
279 XGI310SetupDSTXY(dst_x, dst_y)
280 XGI310DoCMD
281}
282
283static void
284XGI310SetupForSolidFill(int color, int rop, unsigned int planemask)
285{
286 XGI310SetupPATFG(color)
287 XGI310SetupDSTRect(xgi_video_info.video_linelength, 0xFFF)
288 XGI310SetupDSTColorDepth(xgi_video_info.DstColor);
289 XGI310SetupROP(XGIPatALUConv[rop])
290 XGI310SetupCMDFlag(PATFG | xgi_video_info.XGI310_AccelDepth)
291}
292
293static void
294XGI310SubsequentSolidFillRect(int x, int y, int w, int h)
295{
296 long dstbase;
297
298 dstbase = 0;
299 if(y >= 2048) {
300 dstbase = xgi_video_info.video_linelength * y;
301 y = 0;
302 }
303 XGI310SetupDSTBase(dstbase)
304 XGI310SetupDSTXY(x,y)
305 XGI310SetupRect(w,h)
306 XGI310SetupCMDFlag(BITBLT)
307 XGI310DoCMD
308}
309
310/* --------------------------------------------------------------------- */
311
312/* The exported routines */
313
314int XGIfb_initaccel(void)
315{
316#ifdef XGIFB_USE_SPINLOCKS
317 spin_lock_init(&xgi_video_info.lockaccel);
318#endif
319 return(0);
320}
321
322void XGIfb_syncaccel(void)
323{
324
325 XGI310Sync();
326
327}
328
329#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,34) /* --- KERNEL 2.5.34 and later --- */
330
331int fbcon_XGI_sync(struct fb_info *info)
332{
333 if(!XGIfb_accel) return 0;
334 CRITFLAGS
335
336 XGI310Sync();
337
338 CRITEND
339 return 0;
340}
341
342void fbcon_XGI_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
343{
344 int col=0;
345 CRITFLAGS
346
347
348 if(!rect->width || !rect->height)
349 return;
350
351 if(!XGIfb_accel) {
352 cfb_fillrect(info, rect);
353 return;
354 }
355
356 switch(info->var.bits_per_pixel) {
357 case 8: col = rect->color;
358 break;
359 case 16: col = ((u32 *)(info->pseudo_palette))[rect->color];
360 break;
361 case 32: col = ((u32 *)(info->pseudo_palette))[rect->color];
362 break;
363 }
364
365
366 CRITBEGIN
367 XGI310SetupForSolidFill(col, myrops[rect->rop], 0);
368 XGI310SubsequentSolidFillRect(rect->dx, rect->dy, rect->width, rect->height);
369 CRITEND
370 XGI310Sync();
371
372
373}
374
375void fbcon_XGI_copyarea(struct fb_info *info, const struct fb_copyarea *area)
376{
377 int xdir, ydir;
378 CRITFLAGS
379
380
381 if(!XGIfb_accel) {
382 cfb_copyarea(info, area);
383 return;
384 }
385
386 if(!area->width || !area->height)
387 return;
388
389 if(area->sx < area->dx) xdir = 0;
390 else xdir = 1;
391 if(area->sy < area->dy) ydir = 0;
392 else ydir = 1;
393
394 CRITBEGIN
395 XGI310SetupForScreenToScreenCopy(xdir, ydir, 3, 0, -1);
396 XGI310SubsequentScreenToScreenCopy(area->sx, area->sy, area->dx, area->dy, area->width, area->height);
397 CRITEND
398 XGI310Sync();
399
400}
401
402#endif
403
404#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,33) /* ------ KERNEL <2.5.34 ------ */
405
406void fbcon_XGI_bmove(struct display *p, int srcy, int srcx,
407 int dsty, int dstx, int height, int width)
408{
409 int xdir, ydir;
410 CRITFLAGS
411
412 if(!xgi_video_info.accel) {
413 switch(xgi_video_info.video_bpp) {
414 case 8:
415#ifdef FBCON_HAS_CFB8
416 fbcon_cfb8_bmove(p, srcy, srcx, dsty, dstx, height, width);
417#endif
418 break;
419 case 16:
420#ifdef FBCON_HAS_CFB16
421 fbcon_cfb16_bmove(p, srcy, srcx, dsty, dstx, height, width);
422#endif
423 break;
424 case 32:
425#ifdef FBCON_HAS_CFB32
426 fbcon_cfb32_bmove(p, srcy, srcx, dsty, dstx, height, width);
427#endif
428 break;
429 }
430 return;
431 }
432
433 srcx *= fontwidth(p);
434 srcy *= fontheight(p);
435 dstx *= fontwidth(p);
436 dsty *= fontheight(p);
437 width *= fontwidth(p);
438 height *= fontheight(p);
439
440 if(srcx < dstx) xdir = 0;
441 else xdir = 1;
442 if(srcy < dsty) ydir = 0;
443 else ydir = 1;
444
445
446 CRITBEGIN
447 XGI310SetupForScreenToScreenCopy(xdir, ydir, 3, 0, -1);
448 XGI310SubsequentScreenToScreenCopy(srcx, srcy, dstx, dsty, width, height);
449 CRITEND
450 XGI310Sync();
451#if 0
452 printk(KERN_INFO "XGI_bmove sx %d sy %d dx %d dy %d w %d h %d\n",
453 srcx, srcy, dstx, dsty, width, height);
454#endif
455
456}
457
458
459static void fbcon_XGI_clear(struct vc_data *conp, struct display *p,
460 int srcy, int srcx, int height, int width, int color)
461{
462 CRITFLAGS
463
464 srcx *= fontwidth(p);
465 srcy *= fontheight(p);
466 width *= fontwidth(p);
467 height *= fontheight(p);
468
469
470 CRITBEGIN
471 XGI310SetupForSolidFill(color, 3, 0);
472 XGI310SubsequentSolidFillRect(srcx, srcy, width, height);
473 CRITEND
474 XGI310Sync();
475
476}
477
478void fbcon_XGI_clear8(struct vc_data *conp, struct display *p,
479 int srcy, int srcx, int height, int width)
480{
481 u32 bgx;
482
483 if(!xgi_video_info.accel) {
484#ifdef FBCON_HAS_CFB8
485 fbcon_cfb8_clear(conp, p, srcy, srcx, height, width);
486#endif
487 return;
488 }
489
490 bgx = attr_bgcol_ec(p, conp);
491 fbcon_XGI_clear(conp, p, srcy, srcx, height, width, bgx);
492}
493
494void fbcon_XGI_clear16(struct vc_data *conp, struct display *p,
495 int srcy, int srcx, int height, int width)
496{
497 u32 bgx;
498 if(!xgi_video_info.accel) {
499#ifdef FBCON_HAS_CFB16
500 fbcon_cfb16_clear(conp, p, srcy, srcx, height, width);
501#endif
502 return;
503 }
504
505 bgx = ((u_int16_t*)p->dispsw_data)[attr_bgcol_ec(p, conp)];
506 fbcon_XGI_clear(conp, p, srcy, srcx, height, width, bgx);
507}
508
509void fbcon_XGI_clear32(struct vc_data *conp, struct display *p,
510 int srcy, int srcx, int height, int width)
511{
512 u32 bgx;
513
514 if(!xgi_video_info.accel) {
515#ifdef FBCON_HAS_CFB32
516 fbcon_cfb32_clear(conp, p, srcy, srcx, height, width);
517#endif
518 return;
519 }
520
521 bgx = ((u_int32_t*)p->dispsw_data)[attr_bgcol_ec(p, conp)];
522 fbcon_XGI_clear(conp, p, srcy, srcx, height, width, bgx);
523}
524
525void fbcon_XGI_revc(struct display *p, int srcx, int srcy)
526{
527 CRITFLAGS
528
529 if(!xgi_video_info.accel) {
530 switch(xgi_video_info.video_bpp) {
531 case 16:
532#ifdef FBCON_HAS_CFB16
533 fbcon_cfb16_revc(p, srcx, srcy);
534#endif
535 break;
536 case 32:
537#ifdef FBCON_HAS_CFB32
538 fbcon_cfb32_revc(p, srcx, srcy);
539#endif
540 break;
541 }
542 return;
543 }
544
545 srcx *= fontwidth(p);
546 srcy *= fontheight(p);
547
548
549 CRITBEGIN
550 XGI310SetupForSolidFill(0, 0x0a, 0);
551 XGI310SubsequentSolidFillRect(srcx, srcy, fontwidth(p), fontheight(p));
552 CRITEND
553 XGI310Sync();
554
555}
556
557#ifdef FBCON_HAS_CFB8
558struct display_switch fbcon_XGI8 = {
559 setup: fbcon_cfb8_setup,
560 bmove: fbcon_XGI_bmove,
561 clear: fbcon_XGI_clear8,
562 putc: fbcon_cfb8_putc,
563 putcs: fbcon_cfb8_putcs,
564 revc: fbcon_cfb8_revc,
565 clear_margins: fbcon_cfb8_clear_margins,
566 fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
567};
568#endif
569#ifdef FBCON_HAS_CFB16
570struct display_switch fbcon_XGI16 = {
571 setup: fbcon_cfb16_setup,
572 bmove: fbcon_XGI_bmove,
573 clear: fbcon_XGI_clear16,
574 putc: fbcon_cfb16_putc,
575 putcs: fbcon_cfb16_putcs,
576 revc: fbcon_XGI_revc,
577 clear_margins: fbcon_cfb16_clear_margins,
578 fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
579};
580#endif
581#ifdef FBCON_HAS_CFB32
582struct display_switch fbcon_XGI32 = {
583 setup: fbcon_cfb32_setup,
584 bmove: fbcon_XGI_bmove,
585 clear: fbcon_XGI_clear32,
586 putc: fbcon_cfb32_putc,
587 putcs: fbcon_cfb32_putcs,
588 revc: fbcon_XGI_revc,
589 clear_margins: fbcon_cfb32_clear_margins,
590 fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
591};
592#endif
593
594#endif /* KERNEL VERSION */
595
596
diff --git a/drivers/staging/xgifb/XGI_accel.h b/drivers/staging/xgifb/XGI_accel.h
new file mode 100644
index 00000000000..04e126772bb
--- /dev/null
+++ b/drivers/staging/xgifb/XGI_accel.h
@@ -0,0 +1,511 @@
1/*
2 * XGI 300/630/730/540/315/550/650/740 frame buffer driver
3 * for Linux kernels 2.4.x and 2.5.x
4 *
5 * 2D acceleration part
6 *
7 * Based on the X driver's XGI300_accel.h which is
8 * Copyright Xavier Ducoin <x.ducoin@lectra.com>
9 * Copyright 2002 by Thomas Winischhofer, Vienna, Austria
10 * and XGI310_accel.h which is
11 * Copyright 2002 by Thomas Winischhofer, Vienna, Austria
12 *
13 * Author: Thomas Winischhofer <thomas@winischhofer.net>:
14 * (see http://www.winischhofer.net/
15 * for more information and updates)
16 */
17
18#ifndef _XGIFB_ACCEL_H
19#define _XGIFB_ACCEL_H
20
21/* Guard accelerator accesses with spin_lock_irqsave? Works well without. */
22#undef XGIFB_USE_SPINLOCKS
23
24#ifdef XGIFB_USE_SPINLOCKS
25#include <linux/spinlock.h>
26#define CRITBEGIN spin_lock_irqsave(&xgi_video_info.lockaccel), critflags);
27#define CRITEND spin_unlock_irqrestore(&xgi_video_info.lockaccel), critflags);
28#define CRITFLAGS unsigned long critflags;
29#else
30#define CRITBEGIN
31#define CRITEND
32#define CRITFLAGS
33#endif
34
35/* Definitions for the XGI engine communication. */
36
37#define PATREGSIZE 384 /* Pattern register size. 384 bytes @ 0x8300 */
38#define BR(x) (0x8200 | (x) << 2)
39#define PBR(x) (0x8300 | (x) << 2)
40
41/* XGI300 engine commands */
42#define BITBLT 0x00000000 /* Blit */
43#define COLOREXP 0x00000001 /* Color expand */
44#define ENCOLOREXP 0x00000002 /* Enhanced color expand */
45#define MULTIPLE_SCANLINE 0x00000003 /* ? */
46#define LINE 0x00000004 /* Draw line */
47#define TRAPAZOID_FILL 0x00000005 /* Fill trapezoid */
48#define TRANSPARENT_BITBLT 0x00000006 /* Transparent Blit */
49
50/* Additional engine commands for 310/325 */
51#define ALPHA_BLEND 0x00000007 /* Alpha blend ? */
52#define A3D_FUNCTION 0x00000008 /* 3D command ? */
53#define CLEAR_Z_BUFFER 0x00000009 /* ? */
54#define GRADIENT_FILL 0x0000000A /* Gradient fill */
55#define STRETCH_BITBLT 0x0000000B /* Stretched Blit */
56
57/* source select */
58#define SRCVIDEO 0x00000000 /* source is video RAM */
59#define SRCSYSTEM 0x00000010 /* source is system memory */
60#define SRCCPUBLITBUF SRCSYSTEM /* source is CPU-driven BitBuffer (for color expand) */
61#define SRCAGP 0x00000020 /* source is AGP memory (?) */
62
63/* Pattern flags */
64#define PATFG 0x00000000 /* foreground color */
65#define PATPATREG 0x00000040 /* pattern in pattern buffer (0x8300) */
66#define PATMONO 0x00000080 /* mono pattern */
67
68/* blitting direction (300 series only) */
69#define X_INC 0x00010000
70#define X_DEC 0x00000000
71#define Y_INC 0x00020000
72#define Y_DEC 0x00000000
73
74/* Clipping flags */
75#define NOCLIP 0x00000000
76#define NOMERGECLIP 0x04000000
77#define CLIPENABLE 0x00040000
78#define CLIPWITHOUTMERGE 0x04040000
79
80/* Transparency */
81#define OPAQUE 0x00000000
82#define TRANSPARENT 0x00100000
83
84/* ? */
85#define DSTAGP 0x02000000
86#define DSTVIDEO 0x02000000
87
88/* Line */
89#define LINE_STYLE 0x00800000
90#define NO_RESET_COUNTER 0x00400000
91#define NO_LAST_PIXEL 0x00200000
92
93/* Subfunctions for Color/Enhanced Color Expansion (310/325 only) */
94#define COLOR_TO_MONO 0x00100000
95#define AA_TEXT 0x00200000
96
97/* Some general registers for 310/325 series */
98#define SRC_ADDR 0x8200
99#define SRC_PITCH 0x8204
100#define AGP_BASE 0x8206 /* color-depth dependent value */
101#define SRC_Y 0x8208
102#define SRC_X 0x820A
103#define DST_Y 0x820C
104#define DST_X 0x820E
105#define DST_ADDR 0x8210
106#define DST_PITCH 0x8214
107#define DST_HEIGHT 0x8216
108#define RECT_WIDTH 0x8218
109#define RECT_HEIGHT 0x821A
110#define PAT_FGCOLOR 0x821C
111#define PAT_BGCOLOR 0x8220
112#define SRC_FGCOLOR 0x8224
113#define SRC_BGCOLOR 0x8228
114#define MONO_MASK 0x822C
115#define LEFT_CLIP 0x8234
116#define TOP_CLIP 0x8236
117#define RIGHT_CLIP 0x8238
118#define BOTTOM_CLIP 0x823A
119#define COMMAND_READY 0x823C
120#define FIRE_TRIGGER 0x8240
121
122#define PATTERN_REG 0x8300 /* 384 bytes pattern buffer */
123
124/* Line registers */
125#define LINE_X0 SRC_Y
126#define LINE_X1 DST_Y
127#define LINE_Y0 SRC_X
128#define LINE_Y1 DST_X
129#define LINE_COUNT RECT_WIDTH
130#define LINE_STYLE_PERIOD RECT_HEIGHT
131#define LINE_STYLE_0 MONO_MASK
132#define LINE_STYLE_1 0x8230
133#define LINE_XN PATTERN_REG
134#define LINE_YN PATTERN_REG+2
135
136/* Transparent bitblit registers */
137#define TRANS_DST_KEY_HIGH PAT_FGCOLOR
138#define TRANS_DST_KEY_LOW PAT_BGCOLOR
139#define TRANS_SRC_KEY_HIGH SRC_FGCOLOR
140#define TRANS_SRC_KEY_LOW SRC_BGCOLOR
141
142/* Queue */
143#define Q_BASE_ADDR 0x85C0 /* Base address of software queue (?) */
144#define Q_WRITE_PTR 0x85C4 /* Current write pointer (?) */
145#define Q_READ_PTR 0x85C8 /* Current read pointer (?) */
146#define Q_STATUS 0x85CC /* queue status */
147
148
149#define MMIO_IN8(base, offset) \
150 *(volatile u8 *)(((u8*)(base)) + (offset))
151#define MMIO_IN16(base, offset) \
152 *(volatile u16 *)(void *)(((u8*)(base)) + (offset))
153#define MMIO_IN32(base, offset) \
154 *(volatile u32 *)(void *)(((u8*)(base)) + (offset))
155#define MMIO_OUT8(base, offset, val) \
156 *(volatile u8 *)(((u8*)(base)) + (offset)) = (val)
157#define MMIO_OUT16(base, offset, val) \
158 *(volatile u16 *)(void *)(((u8*)(base)) + (offset)) = (val)
159#define MMIO_OUT32(base, offset, val) \
160 *(volatile u32 *)(void *)(((u8*)(base)) + (offset)) = (val)
161
162
163
164/* ------------- XGI 300 series -------------- */
165
166/* Macros to do useful things with the XGI BitBLT engine */
167
168/* BR(16) (0x8420):
169
170 bit 31 2D engine: 1 is idle,
171 bit 30 3D engine: 1 is idle,
172 bit 29 Command queue: 1 is empty
173
174 bits 28:24: Current CPU driven BitBlt buffer stage bit[4:0]
175
176 bits 15:0: Current command queue length
177
178*/
179
180/* TW: BR(16)+2 = 0x8242 */
181
182int xgiCmdQueLen;
183
184#define XGI300Idle \
185 { \
186 while( (MMIO_IN16(xgi_video_info.mmio_vbase, BR(16)+2) & 0xE000) != 0xE000){}; \
187 while( (MMIO_IN16(xgi_video_info.mmio_vbase, BR(16)+2) & 0xE000) != 0xE000){}; \
188 while( (MMIO_IN16(xgi_video_info.mmio_vbase, BR(16)+2) & 0xE000) != 0xE000){}; \
189 xgiCmdQueLen=MMIO_IN16(xgi_video_info.mmio_vbase, 0x8240); \
190 }
191/* TW: (do three times, because 2D engine seems quite unsure about whether or not it's idle) */
192
193#define XGI300SetupSRCBase(base) \
194 if (xgiCmdQueLen <= 0) XGI300Idle;\
195 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(0), base);\
196 xgiCmdQueLen --;
197
198#define XGI300SetupSRCPitch(pitch) \
199 if (xgiCmdQueLen <= 0) XGI300Idle;\
200 MMIO_OUT16(xgi_video_info.mmio_vbase, BR(1), pitch);\
201 xgiCmdQueLen --;
202
203#define XGI300SetupSRCXY(x,y) \
204 if (xgiCmdQueLen <= 0) XGI300Idle;\
205 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(2), (x)<<16 | (y) );\
206 xgiCmdQueLen --;
207
208#define XGI300SetupDSTBase(base) \
209 if (xgiCmdQueLen <= 0) XGI300Idle;\
210 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(4), base);\
211 xgiCmdQueLen --;
212
213#define XGI300SetupDSTXY(x,y) \
214 if (xgiCmdQueLen <= 0) XGI300Idle;\
215 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(3), (x)<<16 | (y) );\
216 xgiCmdQueLen --;
217
218#define XGI300SetupDSTRect(x,y) \
219 if (xgiCmdQueLen <= 0) XGI300Idle;\
220 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(5), (y)<<16 | (x) );\
221 xgiCmdQueLen --;
222
223#define XGI300SetupDSTColorDepth(bpp) \
224 if (xgiCmdQueLen <= 0) XGI300Idle;\
225 MMIO_OUT16(xgi_video_info.mmio_vbase, BR(1)+2, bpp);\
226 xgiCmdQueLen --;
227
228#define XGI300SetupRect(w,h) \
229 if (xgiCmdQueLen <= 0) XGI300Idle;\
230 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(6), (h)<<16 | (w) );\
231 xgiCmdQueLen --;
232
233#define XGI300SetupPATFG(color) \
234 if (xgiCmdQueLen <= 0) XGI300Idle;\
235 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(7), color);\
236 xgiCmdQueLen --;
237
238#define XGI300SetupPATBG(color) \
239 if (xgiCmdQueLen <= 0) XGI300Idle;\
240 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(8), color);\
241 xgiCmdQueLen --;
242
243#define XGI300SetupSRCFG(color) \
244 if (xgiCmdQueLen <= 0) XGI300Idle;\
245 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(9), color);\
246 xgiCmdQueLen --;
247
248#define XGI300SetupSRCBG(color) \
249 if (xgiCmdQueLen <= 0) XGI300Idle;\
250 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(10), color);\
251 xgiCmdQueLen --;
252
253/* 0x8224 src colorkey high */
254/* 0x8228 src colorkey low */
255/* 0x821c dest colorkey high */
256/* 0x8220 dest colorkey low */
257#define XGI300SetupSRCTrans(color) \
258 if (xgiCmdQueLen <= 1) XGI300Idle;\
259 MMIO_OUT32(xgi_video_info.mmio_vbase, 0x8224, color);\
260 MMIO_OUT32(xgi_video_info.mmio_vbase, 0x8228, color);\
261 xgiCmdQueLen -= 2;
262
263#define XGI300SetupDSTTrans(color) \
264 if (xgiCmdQueLen <= 1) XGI300Idle;\
265 MMIO_OUT32(xgi_video_info.mmio_vbase, 0x821C, color); \
266 MMIO_OUT32(xgi_video_info.mmio_vbase, 0x8220, color); \
267 xgiCmdQueLen -= 2;
268
269#define XGI300SetupMONOPAT(p0,p1) \
270 if (xgiCmdQueLen <= 1) XGI300Idle;\
271 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(11), p0);\
272 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(12), p1);\
273 xgiCmdQueLen -= 2;
274
275#define XGI300SetupClipLT(left,top) \
276 if (xgiCmdQueLen <= 0) XGI300Idle;\
277 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(13), ((left) & 0xFFFF) | (top)<<16 );\
278 xgiCmdQueLen--;
279
280#define XGI300SetupClipRB(right,bottom) \
281 if (xgiCmdQueLen <= 0) XGI300Idle;\
282 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(14), ((right) & 0xFFFF) | (bottom)<<16 );\
283 xgiCmdQueLen--;
284
285/* General */
286#define XGI300SetupROP(rop) \
287 xgi_video_info.CommandReg = (rop) << 8;
288
289#define XGI300SetupCMDFlag(flags) \
290 xgi_video_info.CommandReg |= (flags);
291
292#define XGI300DoCMD \
293 if (xgiCmdQueLen <= 1) XGI300Idle;\
294 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(15), xgi_video_info.CommandReg); \
295 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(16), 0);\
296 xgiCmdQueLen -= 2;
297
298/* Line */
299#define XGI300SetupX0Y0(x,y) \
300 if (xgiCmdQueLen <= 0) XGI300Idle;\
301 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(2), (y)<<16 | (x) );\
302 xgiCmdQueLen--;
303
304#define XGI300SetupX1Y1(x,y) \
305 if (xgiCmdQueLen <= 0) XGI300Idle;\
306 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(3), (y)<<16 | (x) );\
307 xgiCmdQueLen--;
308
309#define XGI300SetupLineCount(c) \
310 if (xgiCmdQueLen <= 0) XGI300Idle;\
311 MMIO_OUT16(xgi_video_info.mmio_vbase, BR(6), c);\
312 xgiCmdQueLen--;
313
314#define XGI300SetupStylePeriod(p) \
315 if (xgiCmdQueLen <= 0) XGI300Idle;\
316 MMIO_OUT16(xgi_video_info.mmio_vbase, BR(6)+2, p);\
317 xgiCmdQueLen--;
318
319#define XGI300SetupStyleLow(ls) \
320 if (xgiCmdQueLen <= 0) XGI300Idle;\
321 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(11), ls);\
322 xgiCmdQueLen--;
323
324#define XGI300SetupStyleHigh(ls) \
325 if (xgiCmdQueLen <= 0) XGI300Idle;\
326 MMIO_OUT32(xgi_video_info.mmio_vbase, BR(12), ls);\
327 xgiCmdQueLen--;
328
329
330
331/* ----------- XGI 310/325 series --------------- */
332
333/* Q_STATUS:
334 bit 31 = 1: All engines idle and all queues empty
335 bit 30 = 1: Hardware Queue (=HW CQ, 2D queue, 3D queue) empty
336 bit 29 = 1: 2D engine is idle
337 bit 28 = 1: 3D engine is idle
338 bit 27 = 1: HW command queue empty
339 bit 26 = 1: 2D queue empty
340 bit 25 = 1: 3D queue empty
341 bit 24 = 1: SW command queue empty
342 bits 23:16: 2D counter 3
343 bits 15:8: 2D counter 2
344 bits 7:0: 2D counter 1
345
346 Where is the command queue length (current amount of commands the queue
347 can accept) on the 310/325 series? (The current implementation is taken
348 from 300 series and certainly wrong...)
349*/
350
351/* TW: FIXME: xgiCmdQueLen is... where....? */
352#define XGI310Idle \
353 { \
354 while( (MMIO_IN16(xgi_video_info.mmio_vbase, Q_STATUS+2) & 0x8000) != 0x8000){}; \
355 while( (MMIO_IN16(xgi_video_info.mmio_vbase, Q_STATUS+2) & 0x8000) != 0x8000){}; \
356 xgiCmdQueLen=MMIO_IN16(xgi_video_info.mmio_vbase, Q_STATUS); \
357 }
358
359#define XGI310SetupSRCBase(base) \
360 if (xgiCmdQueLen <= 0) XGI310Idle;\
361 MMIO_OUT32(xgi_video_info.mmio_vbase, SRC_ADDR, base);\
362 xgiCmdQueLen--;
363
364#define XGI310SetupSRCPitch(pitch) \
365 if (xgiCmdQueLen <= 0) XGI310Idle;\
366 MMIO_OUT16(xgi_video_info.mmio_vbase, SRC_PITCH, pitch);\
367 xgiCmdQueLen--;
368
369#define XGI310SetupSRCXY(x,y) \
370 if (xgiCmdQueLen <= 0) XGI310Idle;\
371 MMIO_OUT32(xgi_video_info.mmio_vbase, SRC_Y, (x)<<16 | (y) );\
372 xgiCmdQueLen--;
373
374#define XGI310SetupDSTBase(base) \
375 if (xgiCmdQueLen <= 0) XGI310Idle;\
376 MMIO_OUT32(xgi_video_info.mmio_vbase, DST_ADDR, base);\
377 xgiCmdQueLen--;
378
379#define XGI310SetupDSTXY(x,y) \
380 if (xgiCmdQueLen <= 0) XGI310Idle;\
381 MMIO_OUT32(xgi_video_info.mmio_vbase, DST_Y, (x)<<16 | (y) );\
382 xgiCmdQueLen--;
383
384#define XGI310SetupDSTRect(x,y) \
385 if (xgiCmdQueLen <= 0) XGI310Idle;\
386 MMIO_OUT32(xgi_video_info.mmio_vbase, DST_PITCH, (y)<<16 | (x) );\
387 xgiCmdQueLen--;
388
389#define XGI310SetupDSTColorDepth(bpp) \
390 if (xgiCmdQueLen <= 0) XGI310Idle;\
391 MMIO_OUT16(xgi_video_info.mmio_vbase, AGP_BASE, bpp);\
392 xgiCmdQueLen--;
393
394#define XGI310SetupRect(w,h) \
395 if (xgiCmdQueLen <= 0) XGI310Idle;\
396 MMIO_OUT32(xgi_video_info.mmio_vbase, RECT_WIDTH, (h)<<16 | (w) );\
397 xgiCmdQueLen--;
398
399#define XGI310SetupPATFG(color) \
400 if (xgiCmdQueLen <= 0) XGI310Idle;\
401 MMIO_OUT32(xgi_video_info.mmio_vbase, PAT_FGCOLOR, color);\
402 xgiCmdQueLen--;
403
404#define XGI310SetupPATBG(color) \
405 if (xgiCmdQueLen <= 0) XGI310Idle;\
406 MMIO_OUT32(xgi_video_info.mmio_vbase, PAT_BGCOLOR, color);\
407 xgiCmdQueLen--;
408
409#define XGI310SetupSRCFG(color) \
410 if (xgiCmdQueLen <= 0) XGI310Idle;\
411 MMIO_OUT32(xgi_video_info.mmio_vbase, SRC_FGCOLOR, color);\
412 xgiCmdQueLen--;
413
414#define XGI310SetupSRCBG(color) \
415 if (xgiCmdQueLen <= 0) XGI310Idle;\
416 MMIO_OUT32(xgi_video_info.mmio_vbase, SRC_BGCOLOR, color);\
417 xgiCmdQueLen--;
418
419#define XGI310SetupSRCTrans(color) \
420 if (xgiCmdQueLen <= 1) XGI310Idle;\
421 MMIO_OUT32(xgi_video_info.mmio_vbase, TRANS_SRC_KEY_HIGH, color);\
422 MMIO_OUT32(xgi_video_info.mmio_vbase, TRANS_SRC_KEY_LOW, color);\
423 xgiCmdQueLen -= 2;
424
425#define XGI310SetupDSTTrans(color) \
426 if (xgiCmdQueLen <= 1) XGI310Idle;\
427 MMIO_OUT32(xgi_video_info.mmio_vbase, TRANS_DST_KEY_HIGH, color); \
428 MMIO_OUT32(xgi_video_info.mmio_vbase, TRANS_DST_KEY_LOW, color); \
429 xgiCmdQueLen -= 2;
430
431#define XGI310SetupMONOPAT(p0,p1) \
432 if (xgiCmdQueLen <= 1) XGI310Idle;\
433 MMIO_OUT32(xgi_video_info.mmio_vbase, MONO_MASK, p0);\
434 MMIO_OUT32(xgi_video_info.mmio_vbase, MONO_MASK+4, p1);\
435 xgiCmdQueLen -= 2;
436
437#define XGI310SetupClipLT(left,top) \
438 if (xgiCmdQueLen <= 0) XGI310Idle;\
439 MMIO_OUT32(xgi_video_info.mmio_vbase, LEFT_CLIP, ((left) & 0xFFFF) | (top)<<16 );\
440 xgiCmdQueLen--;
441
442#define XGI310SetupClipRB(right,bottom) \
443 if (xgiCmdQueLen <= 0) XGI310Idle;\
444 MMIO_OUT32(xgi_video_info.mmio_vbase, RIGHT_CLIP, ((right) & 0xFFFF) | (bottom)<<16 );\
445 xgiCmdQueLen--;
446
447#define XGI310SetupROP(rop) \
448 xgi_video_info.CommandReg = (rop) << 8;
449
450#define XGI310SetupCMDFlag(flags) \
451 xgi_video_info.CommandReg |= (flags);
452
453#define XGI310DoCMD \
454 if (xgiCmdQueLen <= 1) XGI310Idle;\
455 MMIO_OUT32(xgi_video_info.mmio_vbase, COMMAND_READY, xgi_video_info.CommandReg); \
456 MMIO_OUT32(xgi_video_info.mmio_vbase, FIRE_TRIGGER, 0); \
457 xgiCmdQueLen -= 2;
458
459#define XGI310SetupX0Y0(x,y) \
460 if (xgiCmdQueLen <= 0) XGI310Idle;\
461 MMIO_OUT32(xgi_video_info.mmio_vbase, LINE_X0, (y)<<16 | (x) );\
462 xgiCmdQueLen--;
463
464#define XGI310SetupX1Y1(x,y) \
465 if (xgiCmdQueLen <= 0) XGI310Idle;\
466 MMIO_OUT32(xgi_video_info.mmio_vbase, LINE_X1, (y)<<16 | (x) );\
467 xgiCmdQueLen--;
468
469#define XGI310SetupLineCount(c) \
470 if (xgiCmdQueLen <= 0) XGI310Idle;\
471 MMIO_OUT16(xgi_video_info.mmio_vbase, LINE_COUNT, c);\
472 xgiCmdQueLen--;
473
474#define XGI310SetupStylePeriod(p) \
475 if (xgiCmdQueLen <= 0) XGI310Idle;\
476 MMIO_OUT16(xgi_video_info.mmio_vbase, LINE_STYLE_PERIOD, p);\
477 xgiCmdQueLen--;
478
479#define XGI310SetupStyleLow(ls) \
480 if (xgiCmdQueLen <= 0) XGI310Idle;\
481 MMIO_OUT32(xgi_video_info.mmio_vbase, LINE_STYLE_0, ls);\
482 xgiCmdQueLen--;
483
484#define XGI310SetupStyleHigh(ls) \
485 if (xgiCmdQueLen <= 0) XGI310Idle;\
486 MMIO_OUT32(xgi_video_info.mmio_vbase, LINE_STYLE_1, ls);\
487 xgiCmdQueLen--;
488
489int XGIfb_initaccel(void);
490void XGIfb_syncaccel(void);
491
492extern struct video_info xgi_video_info;
493
494#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,33)
495void fbcon_XGI_bmove(struct display *p, int srcy, int srcx, int dsty,
496 int dstx, int height, int width);
497void fbcon_XGI_revc(struct display *p, int srcy, int srcx);
498void fbcon_XGI_clear8(struct vc_data *conp, struct display *p, int srcy,
499 int srcx, int height, int width);
500void fbcon_XGI_clear16(struct vc_data *conp, struct display *p, int srcy,
501 int srcx, int height, int width);
502void fbcon_XGI_clear32(struct vc_data *conp, struct display *p, int srcy,
503 int srcx, int height, int width);
504#endif
505#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,34)
506extern int XGIfb_accel;
507void fbcon_XGI_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
508void fbcon_XGI_copyarea(struct fb_info *info, const struct fb_copyarea *area);
509#endif
510
511#endif
diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h
new file mode 100644
index 00000000000..4f4171e8a68
--- /dev/null
+++ b/drivers/staging/xgifb/XGI_main.h
@@ -0,0 +1,1023 @@
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 LINUXBIOS /* turn this on when compiling for LINUXBIOS */
13#define AGPOFF /* default is turn off AGP */
14
15#define XGIFAIL(x) do { printk(x "\n"); return -EINVAL; } while(0)
16
17#define VER_MAJOR 0
18#define VER_MINOR 8
19#define VER_LEVEL 1
20
21#define DRIVER_DESC "XGI Volari Frame Buffer Module Version 0.8.1"
22
23#ifndef PCI_VENDOR_ID_XG
24#define PCI_VENDOR_ID_XG 0x18CA
25#endif
26
27#ifndef PCI_DEVICE_ID_XG_40
28#define PCI_DEVICE_ID_XG_40 0x040
29#endif
30#ifndef PCI_DEVICE_ID_XG_41
31#define PCI_DEVICE_ID_XG_41 0x041
32#endif
33#ifndef PCI_DEVICE_ID_XG_42
34#define PCI_DEVICE_ID_XG_42 0x042
35#endif
36#ifndef PCI_DEVICE_ID_XG_20
37#define PCI_DEVICE_ID_XG_20 0x020
38#endif
39#ifndef PCI_DEVICE_ID_XG_27
40#define PCI_DEVICE_ID_XG_27 0x027
41#endif
42
43
44
45#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8)
46#define XGI_IOTYPE1 void __iomem
47#define XGI_IOTYPE2 __iomem
48#define XGIINITSTATIC static
49#else
50#define XGI_IOTYPE1 unsigned char
51#define XGI_IOTYPE2
52#define XGIINITSTATIC
53#endif
54
55#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
56static struct pci_device_id __devinitdata xgifb_pci_table[] = {
57
58 { PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
59 { PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_27, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
60 { PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_40, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
61 { PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_42, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3},
62 { 0 }
63};
64
65MODULE_DEVICE_TABLE(pci, xgifb_pci_table);
66#endif
67/* To be included in fb.h */
68#ifndef FB_ACCEL_XGI_GLAMOUR_2
69#define FB_ACCEL_XGI_GLAMOUR_2 40 /* XGI 315, 650, 740 */
70#endif
71#ifndef FB_ACCEL_XGI_XABRE
72#define FB_ACCEL_XGI_XABRE 41 /* XGI 330 ("Xabre") */
73#endif
74
75#define MAX_ROM_SCAN 0x10000
76
77#define HW_CURSOR_CAP 0x80
78#define TURBO_QUEUE_CAP 0x40
79#define AGP_CMD_QUEUE_CAP 0x20
80#define VM_CMD_QUEUE_CAP 0x10
81#define MMIO_CMD_QUEUE_CAP 0x08
82
83
84
85/* For 315 series */
86
87#define COMMAND_QUEUE_AREA_SIZE 0x80000 /* 512K */
88#define COMMAND_QUEUE_THRESHOLD 0x1F
89
90
91/* TW */
92#define HW_CURSOR_AREA_SIZE_315 0x4000 /* 16K */
93#define HW_CURSOR_AREA_SIZE_300 0x1000 /* 4K */
94
95#define OH_ALLOC_SIZE 4000
96#define SENTINEL 0x7fffffff
97
98#define SEQ_ADR 0x14
99#define SEQ_DATA 0x15
100#define DAC_ADR 0x18
101#define DAC_DATA 0x19
102#define CRTC_ADR 0x24
103#define CRTC_DATA 0x25
104#define DAC2_ADR (0x16-0x30)
105#define DAC2_DATA (0x17-0x30)
106#define VB_PART1_ADR (0x04-0x30)
107#define VB_PART1_DATA (0x05-0x30)
108#define VB_PART2_ADR (0x10-0x30)
109#define VB_PART2_DATA (0x11-0x30)
110#define VB_PART3_ADR (0x12-0x30)
111#define VB_PART3_DATA (0x13-0x30)
112#define VB_PART4_ADR (0x14-0x30)
113#define VB_PART4_DATA (0x15-0x30)
114
115#define XGISR XGI_Pr.P3c4
116#define XGICR XGI_Pr.P3d4
117#define XGIDACA XGI_Pr.P3c8
118#define XGIDACD XGI_Pr.P3c9
119#define XGIPART1 XGI_Pr.Part1Port
120#define XGIPART2 XGI_Pr.Part2Port
121#define XGIPART3 XGI_Pr.Part3Port
122#define XGIPART4 XGI_Pr.Part4Port
123#define XGIPART5 XGI_Pr.Part5Port
124#define XGIDAC2A XGIPART5
125#define XGIDAC2D (XGIPART5 + 1)
126#define XGIMISCR (XGI_Pr.RelIO + 0x1c)
127#define XGIINPSTAT (XGI_Pr.RelIO + 0x2a)
128
129#define IND_XGI_PASSWORD 0x05 /* SRs */
130#define IND_XGI_COLOR_MODE 0x06
131#define IND_XGI_RAMDAC_CONTROL 0x07
132#define IND_XGI_DRAM_SIZE 0x14
133#define IND_XGI_SCRATCH_REG_16 0x16
134#define IND_XGI_SCRATCH_REG_17 0x17
135#define IND_XGI_SCRATCH_REG_1A 0x1A
136#define IND_XGI_MODULE_ENABLE 0x1E
137#define IND_XGI_PCI_ADDRESS_SET 0x20
138#define IND_XGI_TURBOQUEUE_ADR 0x26
139#define IND_XGI_TURBOQUEUE_SET 0x27
140#define IND_XGI_POWER_ON_TRAP 0x38
141#define IND_XGI_POWER_ON_TRAP2 0x39
142#define IND_XGI_CMDQUEUE_SET 0x26
143#define IND_XGI_CMDQUEUE_THRESHOLD 0x27
144
145#define IND_XGI_SCRATCH_REG_CR30 0x30 /* CRs */
146#define IND_XGI_SCRATCH_REG_CR31 0x31
147#define IND_XGI_SCRATCH_REG_CR32 0x32
148#define IND_XGI_SCRATCH_REG_CR33 0x33
149#define IND_XGI_LCD_PANEL 0x36
150#define IND_XGI_SCRATCH_REG_CR37 0x37
151#define IND_XGI_AGP_IO_PAD 0x48
152
153#define IND_BRI_DRAM_STATUS 0x63 /* PCI config memory size offset */
154
155#define MMIO_QUEUE_PHYBASE 0x85C0
156#define MMIO_QUEUE_WRITEPORT 0x85C4
157#define MMIO_QUEUE_READPORT 0x85C8
158
159#define IND_XGI_CRT2_WRITE_ENABLE_300 0x24
160#define IND_XGI_CRT2_WRITE_ENABLE_315 0x2F
161
162#define XGI_PASSWORD 0x86 /* SR05 */
163#define XGI_INTERLACED_MODE 0x20 /* SR06 */
164#define XGI_8BPP_COLOR_MODE 0x0
165#define XGI_15BPP_COLOR_MODE 0x1
166#define XGI_16BPP_COLOR_MODE 0x2
167#define XGI_32BPP_COLOR_MODE 0x4
168
169#define XGI_DRAM_SIZE_MASK 0xF0 /*SR14 */
170#define XGI_DRAM_SIZE_1MB 0x00
171#define XGI_DRAM_SIZE_2MB 0x01
172#define XGI_DRAM_SIZE_4MB 0x02
173#define XGI_DRAM_SIZE_8MB 0x03
174#define XGI_DRAM_SIZE_16MB 0x04
175#define XGI_DRAM_SIZE_32MB 0x05
176#define XGI_DRAM_SIZE_64MB 0x06
177#define XGI_DRAM_SIZE_128MB 0x07
178#define XGI_DRAM_SIZE_256MB 0x08
179#define XGI_DATA_BUS_MASK 0x02
180#define XGI_DATA_BUS_64 0x00
181#define XGI_DATA_BUS_128 0x01
182#define XGI_DUAL_CHANNEL_MASK 0x0C
183#define XGI_SINGLE_CHANNEL_1_RANK 0x0
184#define XGI_SINGLE_CHANNEL_2_RANK 0x1
185#define XGI_ASYM_DDR 0x02
186#define XGI_DUAL_CHANNEL_1_RANK 0x3
187
188#define XGI550_DRAM_SIZE_MASK 0x3F /* 550/650/740 SR14 */
189#define XGI550_DRAM_SIZE_4MB 0x00
190#define XGI550_DRAM_SIZE_8MB 0x01
191#define XGI550_DRAM_SIZE_16MB 0x03
192#define XGI550_DRAM_SIZE_24MB 0x05
193#define XGI550_DRAM_SIZE_32MB 0x07
194#define XGI550_DRAM_SIZE_64MB 0x0F
195#define XGI550_DRAM_SIZE_96MB 0x17
196#define XGI550_DRAM_SIZE_128MB 0x1F
197#define XGI550_DRAM_SIZE_256MB 0x3F
198
199#define XGI_SCRATCH_REG_1A_MASK 0x10
200
201#define XGI_ENABLE_2D 0x40 /* SR1E */
202
203#define XGI_MEM_MAP_IO_ENABLE 0x01 /* SR20 */
204#define XGI_PCI_ADDR_ENABLE 0x80
205
206#define XGI_AGP_CMDQUEUE_ENABLE 0x80 /* 315/650/740 SR26 */
207#define XGI_VRAM_CMDQUEUE_ENABLE 0x40
208#define XGI_MMIO_CMD_ENABLE 0x20
209#define XGI_CMD_QUEUE_SIZE_512k 0x00
210#define XGI_CMD_QUEUE_SIZE_1M 0x04
211#define XGI_CMD_QUEUE_SIZE_2M 0x08
212#define XGI_CMD_QUEUE_SIZE_4M 0x0C
213#define XGI_CMD_QUEUE_RESET 0x01
214#define XGI_CMD_AUTO_CORR 0x02
215
216#define XGI_SIMULTANEOUS_VIEW_ENABLE 0x01 /* CR30 */
217#define XGI_MODE_SELECT_CRT2 0x02
218#define XGI_VB_OUTPUT_COMPOSITE 0x04
219#define XGI_VB_OUTPUT_SVIDEO 0x08
220#define XGI_VB_OUTPUT_SCART 0x10
221#define XGI_VB_OUTPUT_LCD 0x20
222#define XGI_VB_OUTPUT_CRT2 0x40
223#define XGI_VB_OUTPUT_HIVISION 0x80
224
225#define XGI_VB_OUTPUT_DISABLE 0x20 /* CR31 */
226#define XGI_DRIVER_MODE 0x40
227
228#define XGI_VB_COMPOSITE 0x01 /* CR32 */
229#define XGI_VB_SVIDEO 0x02
230#define XGI_VB_SCART 0x04
231#define XGI_VB_LCD 0x08
232#define XGI_VB_CRT2 0x10
233#define XGI_CRT1 0x20
234#define XGI_VB_HIVISION 0x40
235#define XGI_VB_YPBPR 0x80
236#define XGI_VB_TV (XGI_VB_COMPOSITE | XGI_VB_SVIDEO | \
237 XGI_VB_SCART | XGI_VB_HIVISION|XGI_VB_YPBPR)
238
239#define XGI_EXTERNAL_CHIP_MASK 0x0E /* CR37 */
240#define XGI_EXTERNAL_CHIP_XGI301 0x01 /* in CR37 << 1 ! */
241#define XGI_EXTERNAL_CHIP_LVDS 0x02 /* in CR37 << 1 ! */
242#define XGI_EXTERNAL_CHIP_TRUMPION 0x03 /* in CR37 << 1 ! */
243#define XGI_EXTERNAL_CHIP_LVDS_CHRONTEL 0x04 /* in CR37 << 1 ! */
244#define XGI_EXTERNAL_CHIP_CHRONTEL 0x05 /* in CR37 << 1 ! */
245#define XGI310_EXTERNAL_CHIP_LVDS 0x02 /* in CR37 << 1 ! */
246#define XGI310_EXTERNAL_CHIP_LVDS_CHRONTEL 0x03 /* in CR37 << 1 ! */
247
248#define XGI_AGP_2X 0x20 /* CR48 */
249
250#define BRI_DRAM_SIZE_MASK 0x70 /* PCI bridge config data */
251#define BRI_DRAM_SIZE_2MB 0x00
252#define BRI_DRAM_SIZE_4MB 0x01
253#define BRI_DRAM_SIZE_8MB 0x02
254#define BRI_DRAM_SIZE_16MB 0x03
255#define BRI_DRAM_SIZE_32MB 0x04
256#define BRI_DRAM_SIZE_64MB 0x05
257
258#define HW_DEVICE_EXTENSION XGI_HW_DEVICE_INFO
259#define PHW_DEVICE_EXTENSION PXGI_HW_DEVICE_INFO
260
261#define SR_BUFFER_SIZE 5
262#define CR_BUFFER_SIZE 5
263
264/* Useful macros */
265#define inXGIREG(base) inb(base)
266#define outXGIREG(base,val) outb(val,base)
267#define orXGIREG(base,val) do { \
268 unsigned char __Temp = inb(base); \
269 outXGIREG(base, __Temp | (val)); \
270 } while (0)
271#define andXGIREG(base,val) do { \
272 unsigned char __Temp = inb(base); \
273 outXGIREG(base, __Temp & (val)); \
274 } while (0)
275#define inXGIIDXREG(base,idx,var) do { \
276 outb(idx,base); var=inb((base)+1); \
277 } while (0)
278#define outXGIIDXREG(base,idx,val) do { \
279 outb(idx,base); outb((val),(base)+1); \
280 } while (0)
281#define orXGIIDXREG(base,idx,val) do { \
282 unsigned char __Temp; \
283 outb(idx,base); \
284 __Temp = inb((base)+1)|(val); \
285 outXGIIDXREG(base,idx,__Temp); \
286 } while (0)
287#define andXGIIDXREG(base,idx,and) do { \
288 unsigned char __Temp; \
289 outb(idx,base); \
290 __Temp = inb((base)+1)&(and); \
291 outXGIIDXREG(base,idx,__Temp); \
292 } while (0)
293#define setXGIIDXREG(base,idx,and,or) do { \
294 unsigned char __Temp; \
295 outb(idx,base); \
296 __Temp = (inb((base)+1)&(and))|(or); \
297 outXGIIDXREG(base,idx,__Temp); \
298 } while (0)
299
300/* ------------------- Global Variables ----------------------------- */
301
302/* Fbcon variables */
303#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
304static struct fb_info* fb_info;
305#else
306static struct fb_info XGI_fb_info;
307#endif
308
309
310static int video_type = FB_TYPE_PACKED_PIXELS;
311
312static struct fb_var_screeninfo default_var = {
313 .xres = 0,
314 .yres = 0,
315 .xres_virtual = 0,
316 .yres_virtual = 0,
317 .xoffset = 0,
318 .yoffset = 0,
319 .bits_per_pixel = 0,
320 .grayscale = 0,
321 .red = {0, 8, 0},
322 .green = {0, 8, 0},
323 .blue = {0, 8, 0},
324 .transp = {0, 0, 0},
325 .nonstd = 0,
326 .activate = FB_ACTIVATE_NOW,
327 .height = -1,
328 .width = -1,
329 .accel_flags = 0,
330 .pixclock = 0,
331 .left_margin = 0,
332 .right_margin = 0,
333 .upper_margin = 0,
334 .lower_margin = 0,
335 .hsync_len = 0,
336 .vsync_len = 0,
337 .sync = 0,
338 .vmode = FB_VMODE_NONINTERLACED,
339#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
340 .reserved = {0, 0, 0, 0, 0, 0}
341#endif
342};
343
344#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
345static struct fb_fix_screeninfo XGIfb_fix = {
346 .id = "XGI",
347 .type = FB_TYPE_PACKED_PIXELS,
348 .xpanstep = 1,
349 .ypanstep = 1,
350};
351static char myid[20];
352static u32 pseudo_palette[17];
353#endif
354
355#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
356static struct display XGI_disp;
357
358static struct display_switch XGIfb_sw;
359
360static struct {
361 u16 blue, green, red, pad;
362} XGI_palette[256];
363
364static union {
365#ifdef FBCON_HAS_CFB16
366 u16 cfb16[16];
367#endif
368#ifdef FBCON_HAS_CFB32
369 u32 cfb32[16];
370#endif
371} XGI_fbcon_cmap;
372
373static int XGIfb_inverse = 0;
374#endif
375
376/* display status */
377static int XGIfb_off = 0;
378static int XGIfb_crt1off = 0;
379static int XGIfb_forcecrt1 = -1;
380static int XGIvga_enabled = 0;
381static int XGIfb_userom = 0;
382//static int XGIfb_useoem = -1;
383#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
384static int currcon = 0;
385#endif
386
387/* global flags */
388static int XGIfb_registered;
389static int XGIfb_tvmode = 0;
390static int XGIfb_mem = 0;
391static int XGIfb_pdc = 0;
392static int enable_dstn = 0;
393static int XGIfb_ypan = -1;
394
395
396int XGIfb_accel = 0;
397
398
399static int XGIfb_hwcursor_size = 0;
400static int XGIfb_CRT2_write_enable = 0;
401
402int XGIfb_crt2type = -1; /* TW: CRT2 type (for overriding autodetection) */
403int XGIfb_tvplug = -1; /* PR: Tv plug type (for overriding autodetection) */
404
405int XGIfb_queuemode = -1; /* TW: Use MMIO queue mode by default (310/325 series only) */
406
407unsigned char XGIfb_detectedpdc = 0;
408
409unsigned char XGIfb_detectedlcda = 0xff;
410
411
412
413
414/* TW: For ioctl XGIFB_GET_INFO */
415/* XGIfb_info XGIfbinfo; */
416
417/* TW: Hardware extension; contains data on hardware */
418HW_DEVICE_EXTENSION XGIhw_ext;
419
420/* TW: XGI private structure */
421VB_DEVICE_INFO XGI_Pr;
422
423/* card parameters */
424static unsigned long XGIfb_mmio_size = 0;
425static u8 XGIfb_caps = 0;
426
427typedef enum _XGI_CMDTYPE {
428 MMIO_CMD = 0,
429 AGP_CMD_QUEUE,
430 VM_CMD_QUEUE,
431} XGI_CMDTYPE;
432
433#define MD_XGI300 1
434#define MD_XGI315 2
435
436/* mode table */
437/* NOT const - will be patched for 1280x960 mode number chaos reasons */
438struct _XGIbios_mode {
439 char name[15];
440 u8 mode_no;
441 u16 vesa_mode_no_1; /* "XGI defined" VESA mode number */
442 u16 vesa_mode_no_2; /* Real VESA mode numbers */
443 u16 xres;
444 u16 yres;
445 u16 bpp;
446 u16 rate_idx;
447 u16 cols;
448 u16 rows;
449 u8 chipset;
450} XGIbios_mode[] = {
451#define MODE_INDEX_NONE 0 /* TW: index for mode=none */
452 {"none", 0xFF, 0x0000, 0x0000, 0, 0, 0, 0, 0, 0, MD_XGI300|MD_XGI315}, /* TW: for mode "none" */
453 {"320x240x16", 0x56, 0x0000, 0x0000, 320, 240, 16, 1, 40, 15, MD_XGI315},
454 {"320x480x8", 0x5A, 0x0000, 0x0000, 320, 480, 8, 1, 40, 30, MD_XGI315}, /* TW: FSTN */
455 {"320x480x16", 0x5B, 0x0000, 0x0000, 320, 480, 16, 1, 40, 30, MD_XGI315}, /* TW: FSTN */
456 {"640x480x8", 0x2E, 0x0101, 0x0101, 640, 480, 8, 1, 80, 30, MD_XGI300|MD_XGI315},
457 {"640x480x16", 0x44, 0x0111, 0x0111, 640, 480, 16, 1, 80, 30, MD_XGI300|MD_XGI315},
458 {"640x480x24", 0x62, 0x013a, 0x0112, 640, 480, 32, 1, 80, 30, MD_XGI300|MD_XGI315}, /* TW: That's for people who mix up color- and fb depth */
459 {"640x480x32", 0x62, 0x013a, 0x0112, 640, 480, 32, 1, 80, 30, MD_XGI300|MD_XGI315},
460 {"720x480x8", 0x31, 0x0000, 0x0000, 720, 480, 8, 1, 90, 30, MD_XGI300|MD_XGI315},
461 {"720x480x16", 0x33, 0x0000, 0x0000, 720, 480, 16, 1, 90, 30, MD_XGI300|MD_XGI315},
462 {"720x480x24", 0x35, 0x0000, 0x0000, 720, 480, 32, 1, 90, 30, MD_XGI300|MD_XGI315},
463 {"720x480x32", 0x35, 0x0000, 0x0000, 720, 480, 32, 1, 90, 30, MD_XGI300|MD_XGI315},
464 {"720x576x8", 0x32, 0x0000, 0x0000, 720, 576, 8, 1, 90, 36, MD_XGI300|MD_XGI315},
465 {"720x576x16", 0x34, 0x0000, 0x0000, 720, 576, 16, 1, 90, 36, MD_XGI300|MD_XGI315},
466 {"720x576x24", 0x36, 0x0000, 0x0000, 720, 576, 32, 1, 90, 36, MD_XGI300|MD_XGI315},
467 {"720x576x32", 0x36, 0x0000, 0x0000, 720, 576, 32, 1, 90, 36, MD_XGI300|MD_XGI315},
468 {"800x480x8", 0x70, 0x0000, 0x0000, 800, 480, 8, 1, 100, 30, MD_XGI300|MD_XGI315},
469 {"800x480x16", 0x7a, 0x0000, 0x0000, 800, 480, 16, 1, 100, 30, MD_XGI300|MD_XGI315},
470 {"800x480x24", 0x76, 0x0000, 0x0000, 800, 480, 32, 1, 100, 30, MD_XGI300|MD_XGI315},
471 {"800x480x32", 0x76, 0x0000, 0x0000, 800, 480, 32, 1, 100, 30, MD_XGI300|MD_XGI315},
472#define DEFAULT_MODE 21 /* TW: index for 800x600x8 */
473#define DEFAULT_LCDMODE 21 /* TW: index for 800x600x8 */
474#define DEFAULT_TVMODE 21 /* TW: index for 800x600x8 */
475 {"800x600x8", 0x30, 0x0103, 0x0103, 800, 600, 8, 1, 100, 37, MD_XGI300|MD_XGI315},
476 {"800x600x16", 0x47, 0x0114, 0x0114, 800, 600, 16, 1, 100, 37, MD_XGI300|MD_XGI315},
477 {"800x600x24", 0x63, 0x013b, 0x0115, 800, 600, 32, 1, 100, 37, MD_XGI300|MD_XGI315},
478 {"800x600x32", 0x63, 0x013b, 0x0115, 800, 600, 32, 1, 100, 37, MD_XGI300|MD_XGI315},
479 {"1024x576x8", 0x71, 0x0000, 0x0000, 1024, 576, 8, 1, 128, 36, MD_XGI300|MD_XGI315},
480 {"1024x576x16", 0x74, 0x0000, 0x0000, 1024, 576, 16, 1, 128, 36, MD_XGI300|MD_XGI315},
481 {"1024x576x24", 0x77, 0x0000, 0x0000, 1024, 576, 32, 1, 128, 36, MD_XGI300|MD_XGI315},
482 {"1024x576x32", 0x77, 0x0000, 0x0000, 1024, 576, 32, 1, 128, 36, MD_XGI300|MD_XGI315},
483 {"1024x600x8", 0x20, 0x0000, 0x0000, 1024, 600, 8, 1, 128, 37, MD_XGI300 }, /* TW: 300 series only */
484 {"1024x600x16", 0x21, 0x0000, 0x0000, 1024, 600, 16, 1, 128, 37, MD_XGI300 },
485 {"1024x600x24", 0x22, 0x0000, 0x0000, 1024, 600, 32, 1, 128, 37, MD_XGI300 },
486 {"1024x600x32", 0x22, 0x0000, 0x0000, 1024, 600, 32, 1, 128, 37, MD_XGI300 },
487 {"1024x768x8", 0x38, 0x0105, 0x0105, 1024, 768, 8, 1, 128, 48, MD_XGI300|MD_XGI315},
488 {"1024x768x16", 0x4A, 0x0117, 0x0117, 1024, 768, 16, 1, 128, 48, MD_XGI300|MD_XGI315},
489 {"1024x768x24", 0x64, 0x013c, 0x0118, 1024, 768, 32, 1, 128, 48, MD_XGI300|MD_XGI315},
490 {"1024x768x32", 0x64, 0x013c, 0x0118, 1024, 768, 32, 1, 128, 48, MD_XGI300|MD_XGI315},
491 {"1152x768x8", 0x23, 0x0000, 0x0000, 1152, 768, 8, 1, 144, 48, MD_XGI300 }, /* TW: 300 series only */
492 {"1152x768x16", 0x24, 0x0000, 0x0000, 1152, 768, 16, 1, 144, 48, MD_XGI300 },
493 {"1152x768x24", 0x25, 0x0000, 0x0000, 1152, 768, 32, 1, 144, 48, MD_XGI300 },
494 {"1152x768x32", 0x25, 0x0000, 0x0000, 1152, 768, 32, 1, 144, 48, MD_XGI300 },
495 {"1280x720x8", 0x79, 0x0000, 0x0000, 1280, 720, 8, 1, 160, 45, MD_XGI300|MD_XGI315},
496 {"1280x720x16", 0x75, 0x0000, 0x0000, 1280, 720, 16, 1, 160, 45, MD_XGI300|MD_XGI315},
497 {"1280x720x24", 0x78, 0x0000, 0x0000, 1280, 720, 32, 1, 160, 45, MD_XGI300|MD_XGI315},
498 {"1280x720x32", 0x78, 0x0000, 0x0000, 1280, 720, 32, 1, 160, 45, MD_XGI300|MD_XGI315},
499 {"1280x768x8", 0x23, 0x0000, 0x0000, 1280, 768, 8, 1, 160, 48, MD_XGI315}, /* TW: 310/325 series only */
500 {"1280x768x16", 0x24, 0x0000, 0x0000, 1280, 768, 16, 1, 160, 48, MD_XGI315},
501 {"1280x768x24", 0x25, 0x0000, 0x0000, 1280, 768, 32, 1, 160, 48, MD_XGI315},
502 {"1280x768x32", 0x25, 0x0000, 0x0000, 1280, 768, 32, 1, 160, 48, MD_XGI315},
503#define MODEINDEX_1280x960 48
504 {"1280x960x8", 0x7C, 0x0000, 0x0000, 1280, 960, 8, 1, 160, 60, MD_XGI300|MD_XGI315}, /* TW: Modenumbers being patched */
505 {"1280x960x16", 0x7D, 0x0000, 0x0000, 1280, 960, 16, 1, 160, 60, MD_XGI300|MD_XGI315},
506 {"1280x960x24", 0x7E, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60, MD_XGI300|MD_XGI315},
507 {"1280x960x32", 0x7E, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60, MD_XGI300|MD_XGI315},
508 {"1280x1024x8", 0x3A, 0x0107, 0x0107, 1280, 1024, 8, 1, 160, 64, MD_XGI300|MD_XGI315},
509 {"1280x1024x16", 0x4D, 0x011a, 0x011a, 1280, 1024, 16, 1, 160, 64, MD_XGI300|MD_XGI315},
510 {"1280x1024x24", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 1, 160, 64, MD_XGI300|MD_XGI315},
511 {"1280x1024x32", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 1, 160, 64, MD_XGI300|MD_XGI315},
512 {"1400x1050x8", 0x26, 0x0000, 0x0000, 1400, 1050, 8, 1, 175, 65, MD_XGI315}, /* TW: 310/325 series only */
513 {"1400x1050x16", 0x27, 0x0000, 0x0000, 1400, 1050, 16, 1, 175, 65, MD_XGI315},
514 {"1400x1050x24", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65, MD_XGI315},
515 {"1400x1050x32", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65, MD_XGI315},
516 {"1600x1200x8", 0x3C, 0x0130, 0x011c, 1600, 1200, 8, 1, 200, 75, MD_XGI300|MD_XGI315},
517 {"1600x1200x16", 0x3D, 0x0131, 0x011e, 1600, 1200, 16, 1, 200, 75, MD_XGI300|MD_XGI315},
518 {"1600x1200x24", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75, MD_XGI300|MD_XGI315},
519 {"1600x1200x32", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75, MD_XGI300|MD_XGI315},
520 {"1920x1440x8", 0x68, 0x013f, 0x0000, 1920, 1440, 8, 1, 240, 75, MD_XGI300|MD_XGI315},
521 {"1920x1440x16", 0x69, 0x0140, 0x0000, 1920, 1440, 16, 1, 240, 75, MD_XGI300|MD_XGI315},
522 {"1920x1440x24", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_XGI300|MD_XGI315},
523 {"1920x1440x32", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_XGI300|MD_XGI315},
524 {"2048x1536x8", 0x6c, 0x0000, 0x0000, 2048, 1536, 8, 1, 256, 96, MD_XGI315}, /* TW: 310/325 series only */
525 {"2048x1536x16", 0x6d, 0x0000, 0x0000, 2048, 1536, 16, 1, 256, 96, MD_XGI315},
526 {"2048x1536x24", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96, MD_XGI315},
527 {"2048x1536x32", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96, MD_XGI315},
528 {"\0", 0x00, 0, 0, 0, 0, 0, 0, 0}
529};
530
531/* mode-related variables */
532#ifdef MODULE
533#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
534static int xgifb_mode_idx = 1;
535#else
536static int XGIfb_mode_idx = MODE_INDEX_NONE; /* Don't use a mode by default if we are a module */
537#endif
538#else
539#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
540static int xgifb_mode_idx = -1; /* Use a default mode if we are inside the kernel */
541#else
542static int XGIfb_mode_idx = -1;
543#endif
544#endif
545u8 XGIfb_mode_no = 0;
546u8 XGIfb_rate_idx = 0;
547
548/* TW: CR36 evaluation */
549const USHORT XGI300paneltype[] =
550 { LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024,
551 LCD_1280x960, LCD_640x480, LCD_1024x600, LCD_1152x768,
552 LCD_1024x768, LCD_1024x768, LCD_1024x768,
553 LCD_1024x768, LCD_1024x768, LCD_1024x768, LCD_1024x768 };
554
555const USHORT XGI310paneltype[] =
556 { LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024,
557 LCD_640x480, LCD_1024x600, LCD_1152x864, LCD_1280x960,
558 LCD_1152x768, LCD_1400x1050,LCD_1280x768, LCD_1600x1200,
559 LCD_1024x768, LCD_1024x768, LCD_1024x768 };
560
561static const struct _XGI_crt2type {
562 char name[10];
563 int type_no;
564 int tvplug_no;
565} XGI_crt2type[] = {
566 {"NONE", 0, -1},
567 {"LCD", DISPTYPE_LCD, -1},
568 {"TV", DISPTYPE_TV, -1},
569 {"VGA", DISPTYPE_CRT2, -1},
570 {"SVIDEO", DISPTYPE_TV, TVPLUG_SVIDEO},
571 {"COMPOSITE", DISPTYPE_TV, TVPLUG_COMPOSITE},
572 {"SCART", DISPTYPE_TV, TVPLUG_SCART},
573 {"none", 0, -1},
574 {"lcd", DISPTYPE_LCD, -1},
575 {"tv", DISPTYPE_TV, -1},
576 {"vga", DISPTYPE_CRT2, -1},
577 {"svideo", DISPTYPE_TV, TVPLUG_SVIDEO},
578 {"composite", DISPTYPE_TV, TVPLUG_COMPOSITE},
579 {"scart", DISPTYPE_TV, TVPLUG_SCART},
580 {"\0", -1, -1}
581};
582
583/* Queue mode selection for 310 series */
584static const struct _XGI_queuemode {
585 char name[6];
586 int type_no;
587} XGI_queuemode[] = {
588 {"AGP", AGP_CMD_QUEUE},
589 {"VRAM", VM_CMD_QUEUE},
590 {"MMIO", MMIO_CMD},
591 {"agp", AGP_CMD_QUEUE},
592 {"vram", VM_CMD_QUEUE},
593 {"mmio", MMIO_CMD},
594 {"\0", -1}
595};
596
597/* TV standard */
598static const struct _XGI_tvtype {
599 char name[6];
600 int type_no;
601} XGI_tvtype[] = {
602 {"PAL", 1},
603 {"NTSC", 2},
604 {"pal", 1},
605 {"ntsc", 2},
606 {"\0", -1}
607};
608
609static const struct _XGI_vrate {
610 u16 idx;
611 u16 xres;
612 u16 yres;
613 u16 refresh;
614} XGIfb_vrate[] = {
615 {1, 640, 480, 60}, {2, 640, 480, 72}, {3, 640, 480, 75}, {4, 640, 480, 85},
616 {5, 640, 480,100}, {6, 640, 480, 120}, {7, 640, 480, 160}, {8, 640, 480, 200},
617 {1, 720, 480, 60},
618 {1, 720, 576, 58},
619 {1, 800, 480, 60}, {2, 800, 480, 75}, {3, 800, 480, 85},
620 {1, 800, 600, 60}, {2, 800, 600, 72}, {3, 800, 600, 75},
621 {4, 800, 600, 85}, {5, 800, 600, 100}, {6, 800, 600, 120}, {7, 800, 600, 160},
622 {1, 1024, 768, 60}, {2, 1024, 768, 70}, {3, 1024, 768, 75},
623 {4, 1024, 768, 85}, {5, 1024, 768, 100}, {6, 1024, 768, 120},
624 {1, 1024, 576, 60}, {2, 1024, 576, 75}, {3, 1024, 576, 85},
625 {1, 1024, 600, 60},
626 {1, 1152, 768, 60},
627 {1, 1280, 720, 60}, {2, 1280, 720, 75}, {3, 1280, 720, 85},
628 {1, 1280, 768, 60},
629 {1, 1280, 1024, 60}, {2, 1280, 1024, 75}, {3, 1280, 1024, 85},
630 {1, 1280, 960, 70},
631 {1, 1400, 1050, 60},
632 {1, 1600, 1200, 60}, {2, 1600, 1200, 65}, {3, 1600, 1200, 70}, {4, 1600, 1200, 75},
633 {5, 1600, 1200, 85}, {6, 1600, 1200, 100}, {7, 1600, 1200, 120},
634 {1, 1920, 1440, 60}, {2, 1920, 1440, 65}, {3, 1920, 1440, 70}, {4, 1920, 1440, 75},
635 {5, 1920, 1440, 85}, {6, 1920, 1440, 100},
636 {1, 2048, 1536, 60}, {2, 2048, 1536, 65}, {3, 2048, 1536, 70}, {4, 2048, 1536, 75},
637 {5, 2048, 1536, 85},
638 {0, 0, 0, 0}
639};
640
641static const struct _chswtable {
642 int subsysVendor;
643 int subsysCard;
644 char *vendorName;
645 char *cardName;
646} mychswtable[] = {
647 { 0x1631, 0x1002, "Mitachi", "0x1002" },
648 { 0, 0, "" , "" }
649};
650
651#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
652/* Offscreen layout */
653typedef struct _XGI_GLYINFO {
654 unsigned char ch;
655 int fontwidth;
656 int fontheight;
657 u8 gmask[72];
658 int ngmask;
659} XGI_GLYINFO;
660#endif
661
662typedef struct _XGI_OH {
663 struct _XGI_OH *poh_next;
664 struct _XGI_OH *poh_prev;
665 unsigned long offset;
666 unsigned long size;
667} XGI_OH;
668
669typedef struct _XGI_OHALLOC {
670 struct _XGI_OHALLOC *poha_next;
671 XGI_OH aoh[1];
672} XGI_OHALLOC;
673
674typedef struct _XGI_HEAP {
675 XGI_OH oh_free;
676 XGI_OH oh_used;
677 XGI_OH *poh_freelist;
678 XGI_OHALLOC *poha_chain;
679 unsigned long max_freesize;
680} XGI_HEAP;
681
682static unsigned long XGIfb_hwcursor_vbase;
683
684static unsigned long XGIfb_heap_start;
685static unsigned long XGIfb_heap_end;
686static unsigned long XGIfb_heap_size;
687static XGI_HEAP XGIfb_heap;
688
689// Eden Chen
690static const struct _XGI_TV_filter {
691 u8 filter[9][4];
692} XGI_TV_filter[] = {
693 { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_0 */
694 {0x00,0xE0,0x10,0x60},
695 {0x00,0xEE,0x10,0x44},
696 {0x00,0xF4,0x10,0x38},
697 {0xF8,0xF4,0x18,0x38},
698 {0xFC,0xFB,0x14,0x2A},
699 {0x00,0x00,0x10,0x20},
700 {0x00,0x04,0x10,0x18},
701 {0xFF,0xFF,0xFF,0xFF} }},
702 { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_1 */
703 {0x00,0xE0,0x10,0x60},
704 {0x00,0xEE,0x10,0x44},
705 {0x00,0xF4,0x10,0x38},
706 {0xF8,0xF4,0x18,0x38},
707 {0xFC,0xFB,0x14,0x2A},
708 {0x00,0x00,0x10,0x20},
709 {0x00,0x04,0x10,0x18},
710 {0xFF,0xFF,0xFF,0xFF} }},
711 { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_2 */
712 {0xF5,0xEE,0x1B,0x44},
713 {0xF8,0xF4,0x18,0x38},
714 {0xEB,0x04,0x25,0x18},
715 {0xF1,0x05,0x1F,0x16},
716 {0xF6,0x06,0x1A,0x14},
717 {0xFA,0x06,0x16,0x14},
718 {0x00,0x04,0x10,0x18},
719 {0xFF,0xFF,0xFF,0xFF} }},
720 { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_3 */
721 {0xF1,0x04,0x1F,0x18},
722 {0xEE,0x0D,0x22,0x06},
723 {0xF7,0x06,0x19,0x14},
724 {0xF4,0x0B,0x1C,0x0A},
725 {0xFA,0x07,0x16,0x12},
726 {0xF9,0x0A,0x17,0x0C},
727 {0x00,0x07,0x10,0x12},
728 {0xFF,0xFF,0xFF,0xFF} }},
729 { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_4 */
730 {0x00,0xE0,0x10,0x60},
731 {0x00,0xEE,0x10,0x44},
732 {0x00,0xF4,0x10,0x38},
733 {0xF8,0xF4,0x18,0x38},
734 {0xFC,0xFB,0x14,0x2A},
735 {0x00,0x00,0x10,0x20},
736 {0x00,0x04,0x10,0x18},
737 {0xFF,0xFF,0xFF,0xFF} }},
738 { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_5 */
739 {0xF5,0xEE,0x1B,0x44},
740 {0xF8,0xF4,0x18,0x38},
741 {0xEB,0x04,0x25,0x18},
742 {0xF1,0x05,0x1F,0x16},
743 {0xF6,0x06,0x1A,0x14},
744 {0xFA,0x06,0x16,0x14},
745 {0x00,0x04,0x10,0x18},
746 {0xFF,0xFF,0xFF,0xFF} }},
747 { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_6 */
748 {0xEB,0x04,0x25,0x18},
749 {0xE7,0x0E,0x29,0x04},
750 {0xEE,0x0C,0x22,0x08},
751 {0xF6,0x0B,0x1A,0x0A},
752 {0xF9,0x0A,0x17,0x0C},
753 {0xFC,0x0A,0x14,0x0C},
754 {0x00,0x08,0x10,0x10},
755 {0xFF,0xFF,0xFF,0xFF} }},
756 { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_7 */
757 {0xEC,0x02,0x24,0x1C},
758 {0xF2,0x04,0x1E,0x18},
759 {0xEB,0x15,0x25,0xF6},
760 {0xF4,0x10,0x1C,0x00},
761 {0xF8,0x0F,0x18,0x02},
762 {0x00,0x04,0x10,0x18},
763 {0x01,0x06,0x0F,0x14},
764 {0xFF,0xFF,0xFF,0xFF} }},
765 { {{0x00,0x00,0x00,0x40}, /* PALFilter_0 */
766 {0x00,0xE0,0x10,0x60},
767 {0x00,0xEE,0x10,0x44},
768 {0x00,0xF4,0x10,0x38},
769 {0xF8,0xF4,0x18,0x38},
770 {0xFC,0xFB,0x14,0x2A},
771 {0x00,0x00,0x10,0x20},
772 {0x00,0x04,0x10,0x18},
773 {0xFF,0xFF,0xFF,0xFF} }},
774 { {{0x00,0x00,0x00,0x40}, /* PALFilter_1 */
775 {0x00,0xE0,0x10,0x60},
776 {0x00,0xEE,0x10,0x44},
777 {0x00,0xF4,0x10,0x38},
778 {0xF8,0xF4,0x18,0x38},
779 {0xFC,0xFB,0x14,0x2A},
780 {0x00,0x00,0x10,0x20},
781 {0x00,0x04,0x10,0x18},
782 {0xFF,0xFF,0xFF,0xFF} }},
783 { {{0x00,0x00,0x00,0x40}, /* PALFilter_2 */
784 {0xF5,0xEE,0x1B,0x44},
785 {0xF8,0xF4,0x18,0x38},
786 {0xF1,0xF7,0x01,0x32},
787 {0xF5,0xFB,0x1B,0x2A},
788 {0xF9,0xFF,0x17,0x22},
789 {0xFB,0x01,0x15,0x1E},
790 {0x00,0x04,0x10,0x18},
791 {0xFF,0xFF,0xFF,0xFF} }},
792 { {{0x00,0x00,0x00,0x40}, /* PALFilter_3 */
793 {0xF5,0xFB,0x1B,0x2A},
794 {0xEE,0xFE,0x22,0x24},
795 {0xF3,0x00,0x1D,0x20},
796 {0xF9,0x03,0x17,0x1A},
797 {0xFB,0x02,0x14,0x1E},
798 {0xFB,0x04,0x15,0x18},
799 {0x00,0x06,0x10,0x14},
800 {0xFF,0xFF,0xFF,0xFF} }},
801 { {{0x00,0x00,0x00,0x40}, /* PALFilter_4 */
802 {0x00,0xE0,0x10,0x60},
803 {0x00,0xEE,0x10,0x44},
804 {0x00,0xF4,0x10,0x38},
805 {0xF8,0xF4,0x18,0x38},
806 {0xFC,0xFB,0x14,0x2A},
807 {0x00,0x00,0x10,0x20},
808 {0x00,0x04,0x10,0x18},
809 {0xFF,0xFF,0xFF,0xFF} }},
810 { {{0x00,0x00,0x00,0x40}, /* PALFilter_5 */
811 {0xF5,0xEE,0x1B,0x44},
812 {0xF8,0xF4,0x18,0x38},
813 {0xF1,0xF7,0x1F,0x32},
814 {0xF5,0xFB,0x1B,0x2A},
815 {0xF9,0xFF,0x17,0x22},
816 {0xFB,0x01,0x15,0x1E},
817 {0x00,0x04,0x10,0x18},
818 {0xFF,0xFF,0xFF,0xFF} }},
819 { {{0x00,0x00,0x00,0x40}, /* PALFilter_6 */
820 {0xF5,0xEE,0x1B,0x2A},
821 {0xEE,0xFE,0x22,0x24},
822 {0xF3,0x00,0x1D,0x20},
823 {0xF9,0x03,0x17,0x1A},
824 {0xFB,0x02,0x14,0x1E},
825 {0xFB,0x04,0x15,0x18},
826 {0x00,0x06,0x10,0x14},
827 {0xFF,0xFF,0xFF,0xFF} }},
828 { {{0x00,0x00,0x00,0x40}, /* PALFilter_7 */
829 {0xF5,0xEE,0x1B,0x44},
830 {0xF8,0xF4,0x18,0x38},
831 {0xFC,0xFB,0x14,0x2A},
832 {0xEB,0x05,0x25,0x16},
833 {0xF1,0x05,0x1F,0x16},
834 {0xFA,0x07,0x16,0x12},
835 {0x00,0x07,0x10,0x12},
836 {0xFF,0xFF,0xFF,0xFF} }}
837};
838
839static int filter = -1;
840static unsigned char filter_tb;
841
842
843/* ---------------------- Routine prototypes ------------------------- */
844
845/* Interface used by the world */
846#ifndef MODULE
847XGIINITSTATIC int __init XGIfb_setup(char *options);
848#endif
849
850/* Interface to the low level console driver */
851
852
853
854/* fbdev routines */
855#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
856 int XGIfb_init(void);
857static int XGIfb_get_fix(struct fb_fix_screeninfo *fix,
858 int con,
859 struct fb_info *info);
860static int XGIfb_get_var(struct fb_var_screeninfo *var,
861 int con,
862 struct fb_info *info);
863static int XGIfb_set_var(struct fb_var_screeninfo *var,
864 int con,
865 struct fb_info *info);
866static void XGIfb_crtc_to_var(struct fb_var_screeninfo *var);
867static int XGIfb_get_cmap(struct fb_cmap *cmap,
868 int kspc,
869 int con,
870 struct fb_info *info);
871static int XGIfb_set_cmap(struct fb_cmap *cmap,
872 int kspc,
873 int con,
874 struct fb_info *info);
875static int XGIfb_update_var(int con,
876 struct fb_info *info);
877static int XGIfb_switch(int con,
878 struct fb_info *info);
879static void XGIfb_blank(int blank,
880 struct fb_info *info);
881static void XGIfb_set_disp(int con,
882 struct fb_var_screeninfo *var,
883 struct fb_info *info);
884static int XGI_getcolreg(unsigned regno, unsigned *red, unsigned *green,
885 unsigned *blue, unsigned *transp,
886 struct fb_info *fb_info);
887static void XGIfb_do_install_cmap(int con,
888 struct fb_info *info);
889static void XGI_get_glyph(struct fb_info *info,
890 XGI_GLYINFO *gly);
891static int XGIfb_mmap(struct fb_info *info, struct file *file,
892 struct vm_area_struct *vma);
893static int XGIfb_ioctl(struct inode *inode, struct file *file,
894 unsigned int cmd, unsigned long arg, int con,
895 struct fb_info *info);
896#endif
897
898#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
899XGIINITSTATIC int __init xgifb_init(void);
900static int XGIfb_set_par(struct fb_info *info);
901static int XGIfb_blank(int blank,
902 struct fb_info *info);
903/*static int XGIfb_mmap(struct fb_info *info, struct file *file,
904 struct vm_area_struct *vma);
905*/
906extern void fbcon_XGI_fillrect(struct fb_info *info,
907 const struct fb_fillrect *rect);
908extern void fbcon_XGI_copyarea(struct fb_info *info,
909 const struct fb_copyarea *area);
910#if 0
911extern void cfb_imageblit(struct fb_info *info,
912 const struct fb_image *image);
913#endif
914extern int fbcon_XGI_sync(struct fb_info *info);
915
916#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
917static int XGIfb_ioctl(struct fb_info *info, unsigned int cmd,
918 unsigned long arg);
919#else
920static int XGIfb_ioctl(struct inode *inode,
921 struct file *file,
922 unsigned int cmd,
923 unsigned long arg,
924 struct fb_info *info);
925#endif
926
927/*
928extern int XGIfb_mode_rate_to_dclock(VB_DEVICE_INFO *XGI_Pr,
929 PXGI_HW_DEVICE_INFO HwDeviceExtension,
930 unsigned char modeno, unsigned char rateindex);
931extern int XGIfb_mode_rate_to_ddata(VB_DEVICE_INFO *XGI_Pr, PXGI_HW_DEVICE_INFO HwDeviceExtension,
932 unsigned char modeno, unsigned char rateindex,
933 unsigned int *left_margin, unsigned int *right_margin,
934 unsigned int *upper_margin, unsigned int *lower_margin,
935 unsigned int *hsync_len, unsigned int *vsync_len,
936 unsigned int *sync, unsigned int *vmode);
937*/
938#endif
939 extern BOOLEAN XGI_SearchModeID( USHORT ModeNo,USHORT *ModeIdIndex, PVB_DEVICE_INFO );
940static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con,
941 struct fb_info *info);
942
943/* Internal 2D accelerator functions */
944extern int XGIfb_initaccel(void);
945extern void XGIfb_syncaccel(void);
946
947/* Internal general routines */
948static void XGIfb_search_mode(const char *name);
949static int XGIfb_validate_mode(int modeindex);
950static u8 XGIfb_search_refresh_rate(unsigned int rate);
951static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green,
952 unsigned blue, unsigned transp,
953 struct fb_info *fb_info);
954static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
955 struct fb_info *info);
956static void XGIfb_pre_setmode(void);
957static void XGIfb_post_setmode(void);
958
959static BOOLEAN XGIfb_CheckVBRetrace(void);
960static BOOLEAN XGIfbcheckvretracecrt2(void);
961static BOOLEAN XGIfbcheckvretracecrt1(void);
962static BOOLEAN XGIfb_bridgeisslave(void);
963
964struct XGI_memreq {
965 unsigned long offset;
966 unsigned long size;
967};
968
969/* XGI-specific Export functions */
970void XGI_dispinfo(struct ap_data *rec);
971void XGI_malloc(struct XGI_memreq *req);
972void XGI_free(unsigned long base);
973
974/* Internal hardware access routines */
975void XGIfb_set_reg4(u16 port, unsigned long data);
976u32 XGIfb_get_reg3(u16 port);
977
978/* Chipset-dependent internal routines */
979
980
981static int XGIfb_get_dram_size(void);
982static void XGIfb_detect_VB(void);
983static void XGIfb_get_VB_type(void);
984static int XGIfb_has_VB(void);
985
986
987/* Internal heap routines */
988static int XGIfb_heap_init(void);
989static XGI_OH *XGIfb_poh_new_node(void);
990static XGI_OH *XGIfb_poh_allocate(unsigned long size);
991static void XGIfb_delete_node(XGI_OH *poh);
992static void XGIfb_insert_node(XGI_OH *pohList, XGI_OH *poh);
993static XGI_OH *XGIfb_poh_free(unsigned long base);
994static void XGIfb_free_node(XGI_OH *poh);
995
996/* Internal routines to access PCI configuration space */
997BOOLEAN XGIfb_query_VGA_config_space(PXGI_HW_DEVICE_INFO pXGIhw_ext,
998 unsigned long offset, unsigned long set, unsigned long *value);
999//BOOLEAN XGIfb_query_north_bridge_space(PXGI_HW_DEVICE_INFO pXGIhw_ext,
1000// unsigned long offset, unsigned long set, unsigned long *value);
1001
1002
1003/* Routines from init.c/init301.c */
1004extern void InitTo330Pointer(UCHAR,PVB_DEVICE_INFO pVBInfo);
1005extern BOOLEAN XGIInitNew(PXGI_HW_DEVICE_INFO HwDeviceExtension);
1006extern BOOLEAN XGISetModeNew(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo);
1007//extern void XGI_SetEnableDstn(VB_DEVICE_INFO *XGI_Pr);
1008extern void XGI_LongWait(VB_DEVICE_INFO *XGI_Pr);
1009extern USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
1010/* TW: Chrontel TV functions */
1011extern USHORT XGI_GetCH700x(VB_DEVICE_INFO *XGI_Pr, USHORT tempbx);
1012extern void XGI_SetCH700x(VB_DEVICE_INFO *XGI_Pr, USHORT tempbx);
1013extern USHORT XGI_GetCH701x(VB_DEVICE_INFO *XGI_Pr, USHORT tempbx);
1014extern void XGI_SetCH701x(VB_DEVICE_INFO *XGI_Pr, USHORT tempbx);
1015extern void XGI_SetCH70xxANDOR(VB_DEVICE_INFO *XGI_Pr, USHORT tempax,USHORT tempbh);
1016extern void XGI_DDC2Delay(VB_DEVICE_INFO *XGI_Pr, USHORT delaytime);
1017
1018/* TW: Sensing routines */
1019void XGI_Sense30x(void);
1020int XGIDoSense(int tempbl, int tempbh, int tempcl, int tempch);
1021
1022extern XGI21_LVDSCapStruct XGI21_LCDCapList[13];
1023#endif
diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c
new file mode 100644
index 00000000000..867012b48a0
--- /dev/null
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -0,0 +1,3773 @@
1/*
2 * XG20, XG21, XG40, XG42 frame buffer device
3 * for Linux kernels 2.5.x, 2.6.x
4 * Base on TW's sis fbdev code.
5 */
6
7//#include <linux/config.h>
8#include <linux/version.h>
9#include <linux/module.h>
10#include <linux/moduleparam.h>
11#include <linux/kernel.h>
12#include <linux/spinlock.h>
13#include <linux/errno.h>
14#include <linux/string.h>
15#include <linux/mm.h>
16#include <linux/tty.h>
17#include <linux/slab.h>
18#include <linux/delay.h>
19#include <linux/fb.h>
20#include <linux/console.h>
21#include <linux/selection.h>
22#include <linux/ioport.h>
23#include <linux/init.h>
24#include <linux/pci.h>
25#include <linux/vmalloc.h>
26#include <linux/vt_kern.h>
27#include <linux/capability.h>
28#include <linux/fs.h>
29#include <linux/types.h>
30#include <linux/proc_fs.h>
31#include <linux/kernel.h>
32
33#include "osdef.h"
34
35
36#ifndef XGIFB_PAN
37#define XGIFB_PAN
38#endif
39
40#include <asm/io.h>
41#ifdef CONFIG_MTRR
42#include <asm/mtrr.h>
43#endif
44
45#include "XGIfb.h"
46#include "vgatypes.h"
47#include "XGI_main.h"
48#include "vb_util.h"
49
50
51#define Index_CR_GPIO_Reg1 0x48
52#define Index_CR_GPIO_Reg2 0x49
53#define Index_CR_GPIO_Reg3 0x4a
54
55#define GPIOG_EN (1<<6)
56#define GPIOG_WRITE (1<<6)
57#define GPIOG_READ (1<<1)
58int XGIfb_GetXG21DefaultLVDSModeIdx(void);
59
60/* -------------------- Macro definitions ---------------------------- */
61
62#undef XGIFBDEBUG
63
64#ifdef XGIFBDEBUG
65#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
66#else
67#define DPRINTK(fmt, args...)
68#endif
69
70#ifdef XGIFBDEBUG
71static void dumpVGAReg(void)
72{
73 u8 i,reg;
74
75outXGIIDXREG(XGISR, 0x05, 0x86);
76/*
77outXGIIDXREG(XGISR, 0x08, 0x4f);
78outXGIIDXREG(XGISR, 0x0f, 0x20);
79outXGIIDXREG(XGISR, 0x11, 0x4f);
80outXGIIDXREG(XGISR, 0x13, 0x45);
81outXGIIDXREG(XGISR, 0x14, 0x51);
82outXGIIDXREG(XGISR, 0x1e, 0x41);
83outXGIIDXREG(XGISR, 0x1f, 0x0);
84outXGIIDXREG(XGISR, 0x20, 0xa1);
85outXGIIDXREG(XGISR, 0x22, 0xfb);
86outXGIIDXREG(XGISR, 0x26, 0x22);
87outXGIIDXREG(XGISR, 0x3e, 0x07);
88*/
89
90//outXGIIDXREG(XGICR, 0x19, 0x00);
91//outXGIIDXREG(XGICR, 0x1a, 0x3C);
92//outXGIIDXREG(XGICR, 0x22, 0xff);
93//outXGIIDXREG(XGICR, 0x3D, 0x10);
94
95//outXGIIDXREG(XGICR, 0x4a, 0xf3);
96
97//outXGIIDXREG(XGICR, 0x57, 0x0);
98//outXGIIDXREG(XGICR, 0x7a, 0x2c);
99
100//outXGIIDXREG(XGICR, 0x82, 0xcc);
101//outXGIIDXREG(XGICR, 0x8c, 0x0);
102/*
103outXGIIDXREG(XGICR, 0x99, 0x1);
104outXGIIDXREG(XGICR, 0x41, 0x40);
105*/
106
107 for(i=0; i < 0x4f; i++)
108 {
109 inXGIIDXREG(XGISR, i, reg);
110 printk("\no 3c4 %x",i);
111 printk("\ni 3c5 => %x",reg);
112 }
113
114 for(i=0; i < 0xF0; i++)
115 {
116 inXGIIDXREG(XGICR, i, reg);
117 printk("\no 3d4 %x",i);
118 printk("\ni 3d5 => %x",reg);
119 }
120/*
121
122 outXGIIDXREG(XGIPART1,0x2F,1);
123 for(i=1; i < 0x50; i++)
124 {
125 inXGIIDXREG(XGIPART1, i, reg);
126 printk("\no d004 %x",i);
127 printk("\ni d005 => %x",reg);
128 }
129
130 for(i=0; i < 0x50; i++)
131 {
132 inXGIIDXREG(XGIPART2, i, reg);
133 printk("\no d010 %x",i);
134 printk("\ni d011 => %x",reg);
135 }
136 for(i=0; i < 0x50; i++)
137 {
138 inXGIIDXREG(XGIPART3, i, reg);
139 printk("\no d012 %x",i);
140 printk("\ni d013 => %x",reg);
141 }
142 for(i=0; i < 0x50; i++)
143 {
144 inXGIIDXREG(XGIPART4, i, reg);
145 printk("\no d014 %x",i);
146 printk("\ni d015 => %x",reg);
147 }
148*/
149}
150#else
151static inline void dumpVGAReg(void) {}
152#endif
153
154/* data for XGI components */
155struct video_info xgi_video_info;
156
157
158#if 1
159#define DEBUGPRN(x)
160#else
161#define DEBUGPRN(x) printk(KERN_INFO x "\n");
162#endif
163
164
165/* --------------- Hardware Access Routines -------------------------- */
166
167#ifdef LINUX_KERNEL
168int
169XGIfb_mode_rate_to_dclock(VB_DEVICE_INFO *XGI_Pr, PXGI_HW_DEVICE_INFO HwDeviceExtension,
170 unsigned char modeno, unsigned char rateindex)
171{
172 USHORT ModeNo = modeno;
173 USHORT ModeIdIndex = 0, ClockIndex = 0;
174 USHORT RefreshRateTableIndex = 0;
175
176 /*ULONG temp = 0;*/
177 int Clock;
178 XGI_Pr->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
179 InitTo330Pointer( HwDeviceExtension->jChipType, XGI_Pr ) ;
180
181 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, XGI_Pr ) ;
182
183/*
184 temp = XGI_SearchModeID( ModeNo , &ModeIdIndex, XGI_Pr ) ;
185 if(!temp) {
186 printk(KERN_ERR "Could not find mode %x\n", ModeNo);
187 return 65000;
188 }
189
190 RefreshRateTableIndex = XGI_Pr->EModeIDTable[ModeIdIndex].REFindex;
191 RefreshRateTableIndex += (rateindex - 1);
192
193*/
194 ClockIndex = XGI_Pr->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
195 if(HwDeviceExtension->jChipType < XGI_315H) {
196 ClockIndex &= 0x3F;
197 }
198 Clock = XGI_Pr->VCLKData[ClockIndex].CLOCK * 1000 ;
199
200 return(Clock);
201}
202
203int
204XGIfb_mode_rate_to_ddata(VB_DEVICE_INFO *XGI_Pr, PXGI_HW_DEVICE_INFO HwDeviceExtension,
205 unsigned char modeno, unsigned char rateindex,
206 u32 *left_margin, u32 *right_margin,
207 u32 *upper_margin, u32 *lower_margin,
208 u32 *hsync_len, u32 *vsync_len,
209 u32 *sync, u32 *vmode)
210{
211 USHORT ModeNo = modeno;
212 USHORT ModeIdIndex = 0, index = 0;
213 USHORT RefreshRateTableIndex = 0;
214
215 unsigned short VRE, VBE, VRS, VBS, VDE, VT;
216 unsigned short HRE, HBE, HRS, HBS, HDE, HT;
217 unsigned char sr_data, cr_data, cr_data2;
218 unsigned long cr_data3;
219 int A, B, C, D, E, F, temp, j;
220 XGI_Pr->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
221 InitTo330Pointer( HwDeviceExtension->jChipType, XGI_Pr ) ;
222 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, XGI_Pr ) ;
223/*
224 temp = XGI_SearchModeID( ModeNo, &ModeIdIndex, XGI_Pr);
225 if(!temp) return 0;
226
227 RefreshRateTableIndex = XGI_Pr->EModeIDTable[ModeIdIndex].REFindex;
228 RefreshRateTableIndex += (rateindex - 1);
229*/
230 index = XGI_Pr->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
231
232 sr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[5];
233
234 cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[0];
235
236 /* Horizontal total */
237 HT = (cr_data & 0xff) |
238 ((unsigned short) (sr_data & 0x03) << 8);
239 A = HT + 5;
240
241 /*cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[1];
242
243 Horizontal display enable end
244 HDE = (cr_data & 0xff) |
245 ((unsigned short) (sr_data & 0x0C) << 6);*/
246 HDE = (XGI_Pr->RefIndex[RefreshRateTableIndex].XRes >> 3) -1;
247 E = HDE + 1;
248
249 cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[3];
250
251 /* Horizontal retrace (=sync) start */
252 HRS = (cr_data & 0xff) |
253 ((unsigned short) (sr_data & 0xC0) << 2);
254 F = HRS - E - 3;
255
256 cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[1];
257
258 /* Horizontal blank start */
259 HBS = (cr_data & 0xff) |
260 ((unsigned short) (sr_data & 0x30) << 4);
261
262 sr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[6];
263
264 cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[2];
265
266 cr_data2 = XGI_Pr->XGINEWUB_CRT1Table[index].CR[4];
267
268 /* Horizontal blank end */
269 HBE = (cr_data & 0x1f) |
270 ((unsigned short) (cr_data2 & 0x80) >> 2) |
271 ((unsigned short) (sr_data & 0x03) << 6);
272
273 /* Horizontal retrace (=sync) end */
274 HRE = (cr_data2 & 0x1f) | ((sr_data & 0x04) << 3);
275
276 temp = HBE - ((E - 1) & 255);
277 B = (temp > 0) ? temp : (temp + 256);
278
279 temp = HRE - ((E + F + 3) & 63);
280 C = (temp > 0) ? temp : (temp + 64);
281
282 D = B - F - C;
283
284 *left_margin = D * 8;
285 *right_margin = F * 8;
286 *hsync_len = C * 8;
287
288 sr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[14];
289
290 cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[8];
291
292 cr_data2 = XGI_Pr->XGINEWUB_CRT1Table[index].CR[9];
293
294 /* Vertical total */
295 VT = (cr_data & 0xFF) |
296 ((unsigned short) (cr_data2 & 0x01) << 8) |
297 ((unsigned short)(cr_data2 & 0x20) << 4) |
298 ((unsigned short) (sr_data & 0x01) << 10);
299 A = VT + 2;
300
301 //cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[10];
302
303 /* Vertical display enable end */
304/* VDE = (cr_data & 0xff) |
305 ((unsigned short) (cr_data2 & 0x02) << 7) |
306 ((unsigned short) (cr_data2 & 0x40) << 3) |
307 ((unsigned short) (sr_data & 0x02) << 9); */
308 VDE = XGI_Pr->RefIndex[RefreshRateTableIndex].YRes -1;
309 E = VDE + 1;
310
311 cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[10];
312
313 /* Vertical retrace (=sync) start */
314 VRS = (cr_data & 0xff) |
315 ((unsigned short) (cr_data2 & 0x04) << 6) |
316 ((unsigned short) (cr_data2 & 0x80) << 2) |
317 ((unsigned short) (sr_data & 0x08) << 7);
318 F = VRS + 1 - E;
319
320 cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[12];
321
322 cr_data3 = (XGI_Pr->XGINEWUB_CRT1Table[index].CR[14] & 0x80) << 5;
323
324 /* Vertical blank start */
325 VBS = (cr_data & 0xff) |
326 ((unsigned short) (cr_data2 & 0x08) << 5) |
327 ((unsigned short) (cr_data3 & 0x20) << 4) |
328 ((unsigned short) (sr_data & 0x04) << 8);
329
330 cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[13];
331
332 /* Vertical blank end */
333 VBE = (cr_data & 0xff) |
334 ((unsigned short) (sr_data & 0x10) << 4);
335 temp = VBE - ((E - 1) & 511);
336 B = (temp > 0) ? temp : (temp + 512);
337
338 cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[11];
339
340 /* Vertical retrace (=sync) end */
341 VRE = (cr_data & 0x0f) | ((sr_data & 0x20) >> 1);
342 temp = VRE - ((E + F - 1) & 31);
343 C = (temp > 0) ? temp : (temp + 32);
344
345 D = B - F - C;
346
347 *upper_margin = D;
348 *lower_margin = F;
349 *vsync_len = C;
350
351 if(XGI_Pr->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x8000)
352 *sync &= ~FB_SYNC_VERT_HIGH_ACT;
353 else
354 *sync |= FB_SYNC_VERT_HIGH_ACT;
355
356 if(XGI_Pr->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x4000)
357 *sync &= ~FB_SYNC_HOR_HIGH_ACT;
358 else
359 *sync |= FB_SYNC_HOR_HIGH_ACT;
360
361 *vmode = FB_VMODE_NONINTERLACED;
362 if(XGI_Pr->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x0080)
363 *vmode = FB_VMODE_INTERLACED;
364 else {
365 j = 0;
366 while(XGI_Pr->EModeIDTable[j].Ext_ModeID != 0xff) {
367 if(XGI_Pr->EModeIDTable[j].Ext_ModeID ==
368 XGI_Pr->RefIndex[RefreshRateTableIndex].ModeID) {
369 if(XGI_Pr->EModeIDTable[j].Ext_ModeFlag & DoubleScanMode) {
370 *vmode = FB_VMODE_DOUBLE;
371 }
372 break;
373 }
374 j++;
375 }
376 }
377
378#if 0 /* That's bullshit, only the resolution needs to be shifted */
379 if((*vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
380 *upper_margin <<= 1;
381 *lower_margin <<= 1;
382 *vsync_len <<= 1;
383 } else if((*vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
384 *upper_margin >>= 1;
385 *lower_margin >>= 1;
386 *vsync_len >>= 1;
387 }
388#endif
389
390 return 1;
391}
392
393#endif
394
395
396
397void XGIRegInit(VB_DEVICE_INFO *XGI_Pr, ULONG BaseAddr)
398{
399 XGI_Pr->RelIO = BaseAddr;
400 XGI_Pr->P3c4 = BaseAddr + 0x14;
401 XGI_Pr->P3d4 = BaseAddr + 0x24;
402 XGI_Pr->P3c0 = BaseAddr + 0x10;
403 XGI_Pr->P3ce = BaseAddr + 0x1e;
404 XGI_Pr->P3c2 = BaseAddr + 0x12;
405 XGI_Pr->P3ca = BaseAddr + 0x1a;
406 XGI_Pr->P3c6 = BaseAddr + 0x16;
407 XGI_Pr->P3c7 = BaseAddr + 0x17;
408 XGI_Pr->P3c8 = BaseAddr + 0x18;
409 XGI_Pr->P3c9 = BaseAddr + 0x19;
410 XGI_Pr->P3da = BaseAddr + 0x2A;
411 XGI_Pr->Part1Port = BaseAddr + XGI_CRT2_PORT_04; /* Digital video interface registers (LCD) */
412 XGI_Pr->Part2Port = BaseAddr + XGI_CRT2_PORT_10; /* 301 TV Encoder registers */
413 XGI_Pr->Part3Port = BaseAddr + XGI_CRT2_PORT_12; /* 301 Macrovision registers */
414 XGI_Pr->Part4Port = BaseAddr + XGI_CRT2_PORT_14; /* 301 VGA2 (and LCD) registers */
415 XGI_Pr->Part5Port = BaseAddr + XGI_CRT2_PORT_14+2; /* 301 palette address port registers */
416
417}
418
419
420void XGIfb_set_reg4(u16 port, unsigned long data)
421{
422 outl((u32) (data & 0xffffffff), port);
423}
424
425u32 XGIfb_get_reg3(u16 port)
426{
427 u32 data;
428
429 data = inl(port);
430 return (data);
431}
432
433/* ------------ Interface for init & mode switching code ------------- */
434
435BOOLEAN
436XGIfb_query_VGA_config_space(PXGI_HW_DEVICE_INFO pXGIhw_ext,
437 unsigned long offset, unsigned long set, unsigned long *value)
438{
439 static struct pci_dev *pdev = NULL;
440 static unsigned char init = 0, valid_pdev = 0;
441
442 if (!set)
443 DPRINTK("XGIfb: Get VGA offset 0x%lx\n", offset);
444 else
445 DPRINTK("XGIfb: Set offset 0x%lx to 0x%lx\n", offset, *value);
446
447 if (!init) {
448 init = TRUE;
449 pdev = pci_get_device(PCI_VENDOR_ID_XG, xgi_video_info.chip_id, pdev);
450 if (pdev) {
451 valid_pdev = TRUE;
452 pci_dev_put(pdev);
453 }
454 }
455
456 if (!valid_pdev) {
457 printk(KERN_DEBUG "XGIfb: Can't find XGI %d VGA device.\n",
458 xgi_video_info.chip_id);
459 return FALSE;
460 }
461
462 if (set == 0)
463 pci_read_config_dword(pdev, offset, (u32 *)value);
464 else
465 pci_write_config_dword(pdev, offset, (u32)(*value));
466
467 return TRUE;
468}
469
470/*BOOLEAN XGIfb_query_north_bridge_space(PXGI_HW_DEVICE_INFO pXGIhw_ext,
471 unsigned long offset, unsigned long set, unsigned long *value)
472{
473 static struct pci_dev *pdev = NULL;
474 static unsigned char init = 0, valid_pdev = 0;
475 u16 nbridge_id = 0;
476
477 if (!init) {
478 init = TRUE;
479 switch (xgi_video_info.chip) {
480 case XGI_540:
481 nbridge_id = PCI_DEVICE_ID_XG_540;
482 break;
483 case XGI_630:
484 nbridge_id = PCI_DEVICE_ID_XG_630;
485 break;
486 case XGI_730:
487 nbridge_id = PCI_DEVICE_ID_XG_730;
488 break;
489 case XGI_550:
490 nbridge_id = PCI_DEVICE_ID_XG_550;
491 break;
492 case XGI_650:
493 nbridge_id = PCI_DEVICE_ID_XG_650;
494 break;
495 case XGI_740:
496 nbridge_id = PCI_DEVICE_ID_XG_740;
497 break;
498 default:
499 nbridge_id = 0;
500 break;
501 }
502
503 pdev = pci_find_device(PCI_VENDOR_ID_SI, nbridge_id, pdev);
504 if (pdev)
505 valid_pdev = TRUE;
506 }
507
508 if (!valid_pdev) {
509 printk(KERN_DEBUG "XGIfb: Can't find XGI %d North Bridge device.\n",
510 nbridge_id);
511 return FALSE;
512 }
513
514 if (set == 0)
515 pci_read_config_dword(pdev, offset, (u32 *)value);
516 else
517 pci_write_config_dword(pdev, offset, (u32)(*value));
518
519 return TRUE;
520}
521*/
522/* ------------------ Internal helper routines ----------------- */
523
524static void XGIfb_search_mode(const char *name)
525{
526 int i = 0, j = 0, l;
527
528 if(name == NULL) {
529 printk(KERN_ERR "XGIfb: Internal error, using default mode.\n");
530 xgifb_mode_idx = DEFAULT_MODE;
531 if ((xgi_video_info.chip == XG21) && ((xgi_video_info.disp_state & DISPTYPE_DISP2) == DISPTYPE_LCD))
532 {
533 xgifb_mode_idx = XGIfb_GetXG21DefaultLVDSModeIdx();
534 }
535 return;
536 }
537
538
539 if (!strcmp(name, XGIbios_mode[MODE_INDEX_NONE].name)) {
540 printk(KERN_ERR "XGIfb: Mode 'none' not supported anymore. Using default.\n");
541 xgifb_mode_idx = DEFAULT_MODE;
542 if ((xgi_video_info.chip == XG21) && ((xgi_video_info.disp_state & DISPTYPE_DISP2) == DISPTYPE_LCD))
543 {
544 xgifb_mode_idx = XGIfb_GetXG21DefaultLVDSModeIdx();
545 }
546 return;
547 }
548
549 while(XGIbios_mode[i].mode_no != 0) {
550 l = min(strlen(name), strlen(XGIbios_mode[i].name));
551 if (!strncmp(name, XGIbios_mode[i].name, l)) {
552 xgifb_mode_idx = i;
553 j = 1;
554 break;
555 }
556 i++;
557 }
558 if(!j) printk(KERN_INFO "XGIfb: Invalid mode '%s'\n", name);
559}
560
561static void XGIfb_search_vesamode(unsigned int vesamode)
562{
563 int i = 0, j = 0;
564
565 if(vesamode == 0) {
566
567 printk(KERN_ERR "XGIfb: Mode 'none' not supported anymore. Using default.\n");
568 xgifb_mode_idx = DEFAULT_MODE;
569 if ((xgi_video_info.chip == XG21) && ((xgi_video_info.disp_state & DISPTYPE_DISP2) == DISPTYPE_LCD))
570 {
571 xgifb_mode_idx = XGIfb_GetXG21DefaultLVDSModeIdx();
572 }
573 return;
574 }
575
576 vesamode &= 0x1dff; /* Clean VESA mode number from other flags */
577
578 while(XGIbios_mode[i].mode_no != 0) {
579 if( (XGIbios_mode[i].vesa_mode_no_1 == vesamode) ||
580 (XGIbios_mode[i].vesa_mode_no_2 == vesamode) ) {
581 xgifb_mode_idx = i;
582 j = 1;
583 break;
584 }
585 i++;
586 }
587 if(!j) printk(KERN_INFO "XGIfb: Invalid VESA mode 0x%x'\n", vesamode);
588}
589
590int XGIfb_GetXG21LVDSData(void)
591{
592 u8 tmp;
593 unsigned char *pData;
594 int i,j,k;
595
596 inXGIIDXREG(XGISR,0x1e,tmp);
597 outXGIIDXREG(XGISR, 0x1e, tmp|4);
598
599 pData = xgi_video_info.mmio_vbase+0x20000;
600 if ((pData[0x0]==0x55) && (pData[0x1]==0xAA) && (pData[0x65] & 0x1))
601 {
602 i = pData[ 0x316 ] | ( pData[ 0x317 ] << 8 );
603 j = pData[ i-1 ] ;
604 if ( j == 0xff )
605 {
606 j = 1;
607 }
608 k = 0;
609 do
610 {
611 XGI21_LCDCapList[k].LVDS_Capability = pData[ i ] | ( pData[ i + 1 ] << 8 );
612 XGI21_LCDCapList[k].LVDSHT = pData[ i + 2 ] | ( pData[ i + 3 ] << 8 ) ;
613 XGI21_LCDCapList[k].LVDSVT = pData[ i + 4 ] | ( pData[ i + 5 ] << 8 );
614 XGI21_LCDCapList[k].LVDSHDE = pData[ i + 6 ] | ( pData[ i + 7 ] << 8 );
615 XGI21_LCDCapList[k].LVDSVDE = pData[ i + 8 ] | ( pData[ i + 9 ] << 8 );
616 XGI21_LCDCapList[k].LVDSHFP = pData[ i + 10 ] | ( pData[ i + 11 ] << 8 );
617 XGI21_LCDCapList[k].LVDSVFP = pData[ i + 12 ] | ( pData[ i + 13 ] << 8 );
618 XGI21_LCDCapList[k].LVDSHSYNC = pData[ i + 14 ] | ( pData[ i + 15 ] << 8 );
619 XGI21_LCDCapList[k].LVDSVSYNC = pData[ i + 16 ] | ( pData[ i + 17 ] << 8 );
620 XGI21_LCDCapList[k].VCLKData1 = pData[ i + 18 ] ;
621 XGI21_LCDCapList[k].VCLKData2 = pData[ i + 19 ] ;
622 XGI21_LCDCapList[k].PSC_S1 = pData[ i + 20 ] ;
623 XGI21_LCDCapList[k].PSC_S2 = pData[ i + 21 ] ;
624 XGI21_LCDCapList[k].PSC_S3 = pData[ i + 22 ] ;
625 XGI21_LCDCapList[k].PSC_S4 = pData[ i + 23 ] ;
626 XGI21_LCDCapList[k].PSC_S5 = pData[ i + 24 ] ;
627 i += 25;
628 j--;
629 k++;
630 } while ( (j>0) && ( k < (sizeof(XGI21_LCDCapList)/sizeof(XGI21_LVDSCapStruct)) ) );
631 return 1;
632 }
633 return 0;
634}
635
636int XGIfb_GetXG21DefaultLVDSModeIdx(void)
637{
638
639 int found_mode = 0;
640 int XGIfb_mode_idx = 0;
641
642 found_mode = 0;
643 while( (XGIbios_mode[XGIfb_mode_idx].mode_no != 0) &&
644 (XGIbios_mode[XGIfb_mode_idx].xres <= XGI21_LCDCapList[0].LVDSHDE) )
645 {
646 if( (XGIbios_mode[XGIfb_mode_idx].xres == XGI21_LCDCapList[0].LVDSHDE) &&
647 (XGIbios_mode[XGIfb_mode_idx].yres == XGI21_LCDCapList[0].LVDSVDE) &&
648 (XGIbios_mode[XGIfb_mode_idx].bpp == 8))
649 {
650 XGIfb_mode_no = XGIbios_mode[XGIfb_mode_idx].mode_no;
651 found_mode = 1;
652 break;
653 }
654 XGIfb_mode_idx++;
655 }
656 if (!found_mode)
657 XGIfb_mode_idx = 0;
658
659 return (XGIfb_mode_idx);
660}
661
662
663static int XGIfb_validate_mode(int myindex)
664{
665 u16 xres, yres;
666
667 if (xgi_video_info.chip == XG21)
668 {
669 if ((xgi_video_info.disp_state & DISPTYPE_DISP2) == DISPTYPE_LCD)
670 {
671 xres = XGI21_LCDCapList[0].LVDSHDE;
672 yres = XGI21_LCDCapList[0].LVDSVDE;
673 if(XGIbios_mode[myindex].xres > xres)
674 return(-1);
675 if(XGIbios_mode[myindex].yres > yres)
676 return(-1);
677 if ((XGIbios_mode[myindex].xres < xres) && (XGIbios_mode[myindex].yres < yres) )
678 {
679 if (XGIbios_mode[myindex].bpp > 8)
680 return(-1);
681 }
682
683 }
684 return(myindex);
685
686 }
687
688 /* FIXME: for now, all is valid on XG27 */
689 if (xgi_video_info.chip == XG27)
690 return(myindex);
691
692 if(!(XGIbios_mode[myindex].chipset & MD_XGI315))
693 return(-1);
694
695 switch (xgi_video_info.disp_state & DISPTYPE_DISP2) {
696 case DISPTYPE_LCD:
697 switch (XGIhw_ext.ulCRT2LCDType) {
698 case LCD_640x480:
699 xres = 640; yres = 480; break;
700 case LCD_800x600:
701 xres = 800; yres = 600; break;
702 case LCD_1024x600:
703 xres = 1024; yres = 600; break;
704 case LCD_1024x768:
705 xres = 1024; yres = 768; break;
706 case LCD_1152x768:
707 xres = 1152; yres = 768; break;
708 case LCD_1280x960:
709 xres = 1280; yres = 960; break;
710 case LCD_1280x768:
711 xres = 1280; yres = 768; break;
712 case LCD_1280x1024:
713 xres = 1280; yres = 1024; break;
714 case LCD_1400x1050:
715 xres = 1400; yres = 1050; break;
716 case LCD_1600x1200:
717 xres = 1600; yres = 1200; break;
718// case LCD_320x480: // TW: FSTN
719// xres = 320; yres = 480; break;
720 default:
721 xres = 0; yres = 0; break;
722 }
723 if(XGIbios_mode[myindex].xres > xres) {
724 return(-1);
725 }
726 if(XGIbios_mode[myindex].yres > yres) {
727 return(-1);
728 }
729 if((XGIhw_ext.ulExternalChip == 0x01) || // LVDS
730 (XGIhw_ext.ulExternalChip == 0x05)) // LVDS+Chrontel
731 {
732 switch (XGIbios_mode[myindex].xres) {
733 case 512:
734 if(XGIbios_mode[myindex].yres != 512) return -1;
735 if(XGIhw_ext.ulCRT2LCDType == LCD_1024x600) return -1;
736 break;
737 case 640:
738 if((XGIbios_mode[myindex].yres != 400) &&
739 (XGIbios_mode[myindex].yres != 480))
740 return -1;
741 break;
742 case 800:
743 if(XGIbios_mode[myindex].yres != 600) return -1;
744 break;
745 case 1024:
746 if((XGIbios_mode[myindex].yres != 600) &&
747 (XGIbios_mode[myindex].yres != 768))
748 return -1;
749 if((XGIbios_mode[myindex].yres == 600) &&
750 (XGIhw_ext.ulCRT2LCDType != LCD_1024x600))
751 return -1;
752 break;
753 case 1152:
754 if((XGIbios_mode[myindex].yres) != 768) return -1;
755 if(XGIhw_ext.ulCRT2LCDType != LCD_1152x768) return -1;
756 break;
757 case 1280:
758 if((XGIbios_mode[myindex].yres != 768) &&
759 (XGIbios_mode[myindex].yres != 1024))
760 return -1;
761 if((XGIbios_mode[myindex].yres == 768) &&
762 (XGIhw_ext.ulCRT2LCDType != LCD_1280x768))
763 return -1;
764 break;
765 case 1400:
766 if(XGIbios_mode[myindex].yres != 1050) return -1;
767 break;
768 case 1600:
769 if(XGIbios_mode[myindex].yres != 1200) return -1;
770 break;
771 default:
772 return -1;
773 }
774 } else {
775 switch (XGIbios_mode[myindex].xres) {
776 case 512:
777 if(XGIbios_mode[myindex].yres != 512) return -1;
778 break;
779 case 640:
780 if((XGIbios_mode[myindex].yres != 400) &&
781 (XGIbios_mode[myindex].yres != 480))
782 return -1;
783 break;
784 case 800:
785 if(XGIbios_mode[myindex].yres != 600) return -1;
786 break;
787 case 1024:
788 if(XGIbios_mode[myindex].yres != 768) return -1;
789 break;
790 case 1280:
791 if((XGIbios_mode[myindex].yres != 960) &&
792 (XGIbios_mode[myindex].yres != 1024))
793 return -1;
794 if(XGIbios_mode[myindex].yres == 960) {
795 if(XGIhw_ext.ulCRT2LCDType == LCD_1400x1050)
796 return -1;
797 }
798 break;
799 case 1400:
800 if(XGIbios_mode[myindex].yres != 1050) return -1;
801 break;
802 case 1600:
803 if(XGIbios_mode[myindex].yres != 1200) return -1;
804 break;
805 default:
806 return -1;
807 }
808 }
809 break;
810 case DISPTYPE_TV:
811 switch (XGIbios_mode[myindex].xres) {
812 case 512:
813 case 640:
814 case 800:
815 break;
816 case 720:
817 if (xgi_video_info.TV_type == TVMODE_NTSC) {
818 if (XGIbios_mode[myindex].yres != 480) {
819 return(-1);
820 }
821 } else if (xgi_video_info.TV_type == TVMODE_PAL) {
822 if (XGIbios_mode[myindex].yres != 576) {
823 return(-1);
824 }
825 }
826 // TW: LVDS/CHRONTEL does not support 720
827 if (xgi_video_info.hasVB == HASVB_LVDS_CHRONTEL ||
828 xgi_video_info.hasVB == HASVB_CHRONTEL) {
829 return(-1);
830 }
831 break;
832 case 1024:
833 if (xgi_video_info.TV_type == TVMODE_NTSC) {
834 if(XGIbios_mode[myindex].bpp == 32) {
835 return(-1);
836 }
837 }
838 // TW: LVDS/CHRONTEL only supports < 800 (1024 on 650/Ch7019)
839 if (xgi_video_info.hasVB == HASVB_LVDS_CHRONTEL ||
840 xgi_video_info.hasVB == HASVB_CHRONTEL) {
841 if(xgi_video_info.chip < XGI_315H) {
842 return(-1);
843 }
844 }
845 break;
846 default:
847 return(-1);
848 }
849 break;
850 case DISPTYPE_CRT2:
851 if(XGIbios_mode[myindex].xres > 1280) return -1;
852 break;
853 }
854 return(myindex);
855
856}
857
858static void XGIfb_search_crt2type(const char *name)
859{
860 int i = 0;
861
862 if(name == NULL)
863 return;
864
865 while(XGI_crt2type[i].type_no != -1) {
866 if (!strcmp(name, XGI_crt2type[i].name)) {
867 XGIfb_crt2type = XGI_crt2type[i].type_no;
868 XGIfb_tvplug = XGI_crt2type[i].tvplug_no;
869 break;
870 }
871 i++;
872 }
873 if(XGIfb_crt2type < 0)
874 printk(KERN_INFO "XGIfb: Invalid CRT2 type: %s\n", name);
875}
876
877static void XGIfb_search_queuemode(const char *name)
878{
879 int i = 0;
880
881 if(name == NULL)
882 return;
883
884 while (XGI_queuemode[i].type_no != -1) {
885 if (!strcmp(name, XGI_queuemode[i].name)) {
886 XGIfb_queuemode = XGI_queuemode[i].type_no;
887 break;
888 }
889 i++;
890 }
891 if (XGIfb_queuemode < 0)
892 printk(KERN_INFO "XGIfb: Invalid queuemode type: %s\n", name);
893}
894
895static u8 XGIfb_search_refresh_rate(unsigned int rate)
896{
897 u16 xres, yres;
898 int i = 0;
899
900 xres = XGIbios_mode[xgifb_mode_idx].xres;
901 yres = XGIbios_mode[xgifb_mode_idx].yres;
902
903 XGIfb_rate_idx = 0;
904 while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) {
905 if ((XGIfb_vrate[i].xres == xres) && (XGIfb_vrate[i].yres == yres)) {
906 if (XGIfb_vrate[i].refresh == rate) {
907 XGIfb_rate_idx = XGIfb_vrate[i].idx;
908 break;
909 } else if (XGIfb_vrate[i].refresh > rate) {
910 if ((XGIfb_vrate[i].refresh - rate) <= 3) {
911 DPRINTK("XGIfb: Adjusting rate from %d up to %d\n",
912 rate, XGIfb_vrate[i].refresh);
913 XGIfb_rate_idx = XGIfb_vrate[i].idx;
914 xgi_video_info.refresh_rate = XGIfb_vrate[i].refresh;
915 } else if (((rate - XGIfb_vrate[i-1].refresh) <= 2)
916 && (XGIfb_vrate[i].idx != 1)) {
917 DPRINTK("XGIfb: Adjusting rate from %d down to %d\n",
918 rate, XGIfb_vrate[i-1].refresh);
919 XGIfb_rate_idx = XGIfb_vrate[i-1].idx;
920 xgi_video_info.refresh_rate = XGIfb_vrate[i-1].refresh;
921 }
922 break;
923 } else if((rate - XGIfb_vrate[i].refresh) <= 2) {
924 DPRINTK("XGIfb: Adjusting rate from %d down to %d\n",
925 rate, XGIfb_vrate[i].refresh);
926 XGIfb_rate_idx = XGIfb_vrate[i].idx;
927 break;
928 }
929 }
930 i++;
931 }
932 if (XGIfb_rate_idx > 0) {
933 return XGIfb_rate_idx;
934 } else {
935 printk(KERN_INFO
936 "XGIfb: Unsupported rate %d for %dx%d\n", rate, xres, yres);
937 return 0;
938 }
939}
940
941static void XGIfb_search_tvstd(const char *name)
942{
943 int i = 0;
944
945 if(name == NULL)
946 return;
947
948 while (XGI_tvtype[i].type_no != -1) {
949 if (!strcmp(name, XGI_tvtype[i].name)) {
950 XGIfb_tvmode = XGI_tvtype[i].type_no;
951 break;
952 }
953 i++;
954 }
955}
956
957static BOOLEAN XGIfb_bridgeisslave(void)
958{
959 unsigned char usScratchP1_00;
960
961 if(xgi_video_info.hasVB == HASVB_NONE) return FALSE;
962
963 inXGIIDXREG(XGIPART1,0x00,usScratchP1_00);
964 if( (usScratchP1_00 & 0x50) == 0x10) {
965 return TRUE;
966 } else {
967 return FALSE;
968 }
969}
970
971static BOOLEAN XGIfbcheckvretracecrt1(void)
972{
973 unsigned char temp;
974
975 inXGIIDXREG(XGICR,0x17,temp);
976 if(!(temp & 0x80)) return FALSE;
977
978
979 inXGIIDXREG(XGISR,0x1f,temp);
980 if(temp & 0xc0) return FALSE;
981
982
983 if(inXGIREG(XGIINPSTAT) & 0x08) return TRUE;
984 else return FALSE;
985}
986
987static BOOLEAN XGIfbcheckvretracecrt2(void)
988{
989 unsigned char temp;
990 if(xgi_video_info.hasVB == HASVB_NONE) return FALSE;
991 inXGIIDXREG(XGIPART1, 0x30, temp);
992 if(temp & 0x02) return FALSE;
993 else return TRUE;
994}
995
996static BOOLEAN XGIfb_CheckVBRetrace(void)
997{
998 if(xgi_video_info.disp_state & DISPTYPE_DISP2) {
999 if(XGIfb_bridgeisslave()) {
1000 return(XGIfbcheckvretracecrt1());
1001 } else {
1002 return(XGIfbcheckvretracecrt2());
1003 }
1004 }
1005 return(XGIfbcheckvretracecrt1());
1006}
1007
1008/* ----------- FBDev related routines for all series ----------- */
1009
1010
1011static void XGIfb_bpp_to_var(struct fb_var_screeninfo *var)
1012{
1013 switch(var->bits_per_pixel) {
1014 case 8:
1015 var->red.offset = var->green.offset = var->blue.offset = 0;
1016 var->red.length = var->green.length = var->blue.length = 6;
1017 xgi_video_info.video_cmap_len = 256;
1018 break;
1019 case 16:
1020 var->red.offset = 11;
1021 var->red.length = 5;
1022 var->green.offset = 5;
1023 var->green.length = 6;
1024 var->blue.offset = 0;
1025 var->blue.length = 5;
1026 var->transp.offset = 0;
1027 var->transp.length = 0;
1028 xgi_video_info.video_cmap_len = 16;
1029 break;
1030 case 32:
1031 var->red.offset = 16;
1032 var->red.length = 8;
1033 var->green.offset = 8;
1034 var->green.length = 8;
1035 var->blue.offset = 0;
1036 var->blue.length = 8;
1037 var->transp.offset = 24;
1038 var->transp.length = 8;
1039 xgi_video_info.video_cmap_len = 16;
1040 break;
1041 }
1042}
1043
1044
1045
1046static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
1047 struct fb_info *info)
1048{
1049
1050 unsigned int htotal = var->left_margin + var->xres +
1051 var->right_margin + var->hsync_len;
1052 unsigned int vtotal = var->upper_margin + var->yres +
1053 var->lower_margin + var->vsync_len;
1054#if defined(__powerpc__)
1055 u8 sr_data, cr_data;
1056#endif
1057 unsigned int drate = 0, hrate = 0;
1058 int found_mode = 0;
1059 int old_mode;
1060// unsigned char reg,reg1;
1061
1062 DEBUGPRN("Inside do_set_var");
1063// printk(KERN_DEBUG "XGIfb:var->yres=%d, var->upper_margin=%d, var->lower_margin=%d, var->vsync_len=%d\n", var->yres,var->upper_margin,var->lower_margin,var->vsync_len);
1064
1065 info->var.xres_virtual = var->xres_virtual;
1066 info->var.yres_virtual = var->yres_virtual;
1067 info->var.bits_per_pixel = var->bits_per_pixel;
1068
1069 if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED)
1070 vtotal <<= 1;
1071 else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
1072 vtotal <<= 2;
1073 else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED)
1074 {
1075// vtotal <<= 1;
1076// var->yres <<= 1;
1077 }
1078
1079 if(!htotal || !vtotal) {
1080 DPRINTK("XGIfb: Invalid 'var' information\n");
1081 return -EINVAL;
1082 }
1083 printk(KERN_DEBUG "XGIfb: var->pixclock=%d, htotal=%d, vtotal=%d\n",
1084 var->pixclock,htotal,vtotal);
1085
1086
1087
1088 if(var->pixclock && htotal && vtotal) {
1089 drate = 1000000000 / var->pixclock;
1090 hrate = (drate * 1000) / htotal;
1091 xgi_video_info.refresh_rate = (unsigned int) (hrate * 2 / vtotal);
1092 } else {
1093 xgi_video_info.refresh_rate = 60;
1094 }
1095
1096 printk(KERN_DEBUG "XGIfb: Change mode to %dx%dx%d-%dHz\n",
1097 var->xres,var->yres,var->bits_per_pixel,xgi_video_info.refresh_rate);
1098
1099 old_mode = xgifb_mode_idx;
1100 xgifb_mode_idx = 0;
1101
1102 while( (XGIbios_mode[xgifb_mode_idx].mode_no != 0) &&
1103 (XGIbios_mode[xgifb_mode_idx].xres <= var->xres) ) {
1104 if( (XGIbios_mode[xgifb_mode_idx].xres == var->xres) &&
1105 (XGIbios_mode[xgifb_mode_idx].yres == var->yres) &&
1106 (XGIbios_mode[xgifb_mode_idx].bpp == var->bits_per_pixel)) {
1107 XGIfb_mode_no = XGIbios_mode[xgifb_mode_idx].mode_no;
1108 found_mode = 1;
1109 break;
1110 }
1111 xgifb_mode_idx++;
1112 }
1113
1114 if(found_mode)
1115 xgifb_mode_idx = XGIfb_validate_mode(xgifb_mode_idx);
1116 else
1117 xgifb_mode_idx = -1;
1118
1119 if(xgifb_mode_idx < 0) {
1120 printk(KERN_ERR "XGIfb: Mode %dx%dx%d not supported\n", var->xres,
1121 var->yres, var->bits_per_pixel);
1122 xgifb_mode_idx = old_mode;
1123 return -EINVAL;
1124 }
1125
1126 if(XGIfb_search_refresh_rate(xgi_video_info.refresh_rate) == 0) {
1127 XGIfb_rate_idx = XGIbios_mode[xgifb_mode_idx].rate_idx;
1128 xgi_video_info.refresh_rate = 60;
1129 }
1130
1131 if(isactive) {
1132
1133
1134 XGIfb_pre_setmode();
1135 if(XGISetModeNew( &XGIhw_ext, XGIfb_mode_no) == 0) {
1136 printk(KERN_ERR "XGIfb: Setting mode[0x%x] failed\n", XGIfb_mode_no);
1137 return -EINVAL;
1138 }
1139 info->fix.line_length = ((info->var.xres_virtual * info->var.bits_per_pixel)>>6);
1140
1141 outXGIIDXREG(XGISR,IND_XGI_PASSWORD,XGI_PASSWORD);
1142
1143 outXGIIDXREG(XGICR,0x13,(info->fix.line_length & 0x00ff));
1144 outXGIIDXREG(XGISR,0x0E,(info->fix.line_length & 0xff00)>>8);
1145
1146 XGIfb_post_setmode();
1147
1148 DPRINTK("XGIfb: Set new mode: %dx%dx%d-%d \n",
1149 XGIbios_mode[xgifb_mode_idx].xres,
1150 XGIbios_mode[xgifb_mode_idx].yres,
1151 XGIbios_mode[xgifb_mode_idx].bpp,
1152 xgi_video_info.refresh_rate);
1153
1154 xgi_video_info.video_bpp = XGIbios_mode[xgifb_mode_idx].bpp;
1155 xgi_video_info.video_vwidth = info->var.xres_virtual;
1156 xgi_video_info.video_width = XGIbios_mode[xgifb_mode_idx].xres;
1157 xgi_video_info.video_vheight = info->var.yres_virtual;
1158 xgi_video_info.video_height = XGIbios_mode[xgifb_mode_idx].yres;
1159 xgi_video_info.org_x = xgi_video_info.org_y = 0;
1160 xgi_video_info.video_linelength = info->var.xres_virtual * (xgi_video_info.video_bpp >> 3);
1161 xgi_video_info.accel = 0;
1162 if(XGIfb_accel) {
1163 xgi_video_info.accel = (var->accel_flags & FB_ACCELF_TEXT) ? -1 : 0;
1164 }
1165 switch(xgi_video_info.video_bpp)
1166 {
1167 case 8:
1168 xgi_video_info.DstColor = 0x0000;
1169 xgi_video_info.XGI310_AccelDepth = 0x00000000;
1170 xgi_video_info.video_cmap_len = 256;
1171#if defined(__powerpc__)
1172 inXGIIDXREG (XGICR, 0x4D, cr_data);
1173 outXGIIDXREG(XGICR, 0x4D, (cr_data & 0xE0));
1174#endif
1175 break;
1176 case 16:
1177 xgi_video_info.DstColor = 0x8000;
1178 xgi_video_info.XGI310_AccelDepth = 0x00010000;
1179#if defined(__powerpc__)
1180 inXGIIDXREG (XGICR, 0x4D, cr_data);
1181 outXGIIDXREG(XGICR, 0x4D, ((cr_data & 0xE0) | 0x0B));
1182#endif
1183 xgi_video_info.video_cmap_len = 16;
1184 break;
1185 case 32:
1186 xgi_video_info.DstColor = 0xC000;
1187 xgi_video_info.XGI310_AccelDepth = 0x00020000;
1188 xgi_video_info.video_cmap_len = 16;
1189#if defined(__powerpc__)
1190 inXGIIDXREG (XGICR, 0x4D, cr_data);
1191 outXGIIDXREG(XGICR, 0x4D, ((cr_data & 0xE0) | 0x15));
1192#endif
1193 break;
1194 default:
1195 xgi_video_info.video_cmap_len = 16;
1196 printk(KERN_ERR "XGIfb: Unsupported depth %d", xgi_video_info.video_bpp);
1197 xgi_video_info.accel = 0;
1198 break;
1199 }
1200 }
1201 XGIfb_bpp_to_var(var); /*update ARGB info*/
1202 DEBUGPRN("End of do_set_var");
1203
1204 dumpVGAReg();
1205 return 0;
1206}
1207
1208#ifdef XGIFB_PAN
1209static int XGIfb_pan_var(struct fb_var_screeninfo *var)
1210{
1211 unsigned int base;
1212
1213// printk("Inside pan_var");
1214
1215 if (var->xoffset > (var->xres_virtual - var->xres)) {
1216// printk( "Pan: xo: %d xv %d xr %d\n",
1217// var->xoffset, var->xres_virtual, var->xres);
1218 return -EINVAL;
1219 }
1220 if(var->yoffset > (var->yres_virtual - var->yres)) {
1221// printk( "Pan: yo: %d yv %d yr %d\n",
1222// var->yoffset, var->yres_virtual, var->yres);
1223 return -EINVAL;
1224 }
1225 base = var->yoffset * var->xres_virtual + var->xoffset;
1226
1227 /* calculate base bpp dep. */
1228 switch(var->bits_per_pixel) {
1229 case 16:
1230 base >>= 1;
1231 break;
1232 case 32:
1233 break;
1234 case 8:
1235 default:
1236 base >>= 2;
1237 break;
1238 }
1239
1240 outXGIIDXREG(XGISR, IND_XGI_PASSWORD, XGI_PASSWORD);
1241
1242 outXGIIDXREG(XGICR, 0x0D, base & 0xFF);
1243 outXGIIDXREG(XGICR, 0x0C, (base >> 8) & 0xFF);
1244 outXGIIDXREG(XGISR, 0x0D, (base >> 16) & 0xFF);
1245 outXGIIDXREG(XGISR, 0x37, (base >> 24) & 0x03);
1246 setXGIIDXREG(XGISR, 0x37, 0xDF, (base >> 21) & 0x04);
1247
1248 if(xgi_video_info.disp_state & DISPTYPE_DISP2) {
1249 orXGIIDXREG(XGIPART1, XGIfb_CRT2_write_enable, 0x01);
1250 outXGIIDXREG(XGIPART1, 0x06, (base & 0xFF));
1251 outXGIIDXREG(XGIPART1, 0x05, ((base >> 8) & 0xFF));
1252 outXGIIDXREG(XGIPART1, 0x04, ((base >> 16) & 0xFF));
1253 setXGIIDXREG(XGIPART1, 0x02, 0x7F, ((base >> 24) & 0x01) << 7);
1254 }
1255// printk("End of pan_var");
1256 return 0;
1257}
1258#endif
1259
1260
1261void XGI_dispinfo(struct ap_data *rec)
1262{
1263 rec->minfo.bpp = xgi_video_info.video_bpp;
1264 rec->minfo.xres = xgi_video_info.video_width;
1265 rec->minfo.yres = xgi_video_info.video_height;
1266 rec->minfo.v_xres = xgi_video_info.video_vwidth;
1267 rec->minfo.v_yres = xgi_video_info.video_vheight;
1268 rec->minfo.org_x = xgi_video_info.org_x;
1269 rec->minfo.org_y = xgi_video_info.org_y;
1270 rec->minfo.vrate = xgi_video_info.refresh_rate;
1271 rec->iobase = xgi_video_info.vga_base - 0x30;
1272 rec->mem_size = xgi_video_info.video_size;
1273 rec->disp_state = xgi_video_info.disp_state;
1274 rec->version = (VER_MAJOR << 24) | (VER_MINOR << 16) | VER_LEVEL;
1275 rec->hasVB = xgi_video_info.hasVB;
1276 rec->TV_type = xgi_video_info.TV_type;
1277 rec->TV_plug = xgi_video_info.TV_plug;
1278 rec->chip = xgi_video_info.chip;
1279}
1280
1281
1282
1283
1284static int XGIfb_open(struct fb_info *info, int user)
1285{
1286 return 0;
1287}
1288
1289static int XGIfb_release(struct fb_info *info, int user)
1290{
1291 return 0;
1292}
1293
1294static int XGIfb_get_cmap_len(const struct fb_var_screeninfo *var)
1295{
1296 int rc = 16;
1297
1298 switch(var->bits_per_pixel) {
1299 case 8:
1300 rc = 256;
1301 break;
1302 case 16:
1303 rc = 16;
1304 break;
1305 case 32:
1306 rc = 16;
1307 break;
1308 }
1309 return rc;
1310}
1311
1312static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue,
1313 unsigned transp, struct fb_info *info)
1314{
1315 if (regno >= XGIfb_get_cmap_len(&info->var))
1316 return 1;
1317
1318 switch (info->var.bits_per_pixel) {
1319 case 8:
1320 outXGIREG(XGIDACA, regno);
1321 outXGIREG(XGIDACD, (red >> 10));
1322 outXGIREG(XGIDACD, (green >> 10));
1323 outXGIREG(XGIDACD, (blue >> 10));
1324 if (xgi_video_info.disp_state & DISPTYPE_DISP2) {
1325 outXGIREG(XGIDAC2A, regno);
1326 outXGIREG(XGIDAC2D, (red >> 8));
1327 outXGIREG(XGIDAC2D, (green >> 8));
1328 outXGIREG(XGIDAC2D, (blue >> 8));
1329 }
1330 break;
1331 case 16:
1332 ((u32 *)(info->pseudo_palette))[regno] =
1333 ((red & 0xf800)) | ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11);
1334 break;
1335 case 32:
1336 red >>= 8;
1337 green >>= 8;
1338 blue >>= 8;
1339 ((u32 *) (info->pseudo_palette))[regno] =
1340 (red << 16) | (green << 8) | (blue);
1341 break;
1342 }
1343 return 0;
1344}
1345
1346static int XGIfb_set_par(struct fb_info *info)
1347{
1348 int err;
1349
1350// printk("XGIfb: inside set_par\n");
1351 if((err = XGIfb_do_set_var(&info->var, 1, info)))
1352 return err;
1353#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
1354 XGIfb_get_fix(&info->fix, info->currcon, info);
1355#else
1356 XGIfb_get_fix(&info->fix, -1, info);
1357#endif
1358// printk("XGIfb:end of set_par\n");
1359 return 0;
1360}
1361
1362static int XGIfb_check_var(struct fb_var_screeninfo *var,
1363 struct fb_info *info)
1364{
1365 unsigned int htotal =
1366 var->left_margin + var->xres + var->right_margin +
1367 var->hsync_len;
1368 unsigned int vtotal = 0;
1369 unsigned int drate = 0, hrate = 0;
1370 int found_mode = 0;
1371 int refresh_rate, search_idx;
1372
1373 DEBUGPRN("Inside check_var");
1374
1375 if((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) {
1376 vtotal = var->upper_margin + var->yres + var->lower_margin +
1377 var->vsync_len;
1378 vtotal <<= 1;
1379 } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
1380 vtotal = var->upper_margin + var->yres + var->lower_margin +
1381 var->vsync_len;
1382 vtotal <<= 2;
1383 } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
1384 vtotal = var->upper_margin + (var->yres/2) + var->lower_margin +
1385 var->vsync_len;
1386 } else vtotal = var->upper_margin + var->yres + var->lower_margin +
1387 var->vsync_len;
1388
1389 if(!(htotal) || !(vtotal)) {
1390 XGIFAIL("XGIfb: no valid timing data");
1391 }
1392
1393
1394 if(var->pixclock && htotal && vtotal) {
1395 drate = 1000000000 / var->pixclock;
1396 hrate = (drate * 1000) / htotal;
1397 xgi_video_info.refresh_rate = (unsigned int) (hrate * 2 / vtotal);
1398 printk(KERN_DEBUG \
1399 "%s: pixclock = %d ,htotal=%d, vtotal=%d\n" \
1400 "%s: drate=%d, hrate=%d, refresh_rate=%d\n",
1401 __func__,var->pixclock, htotal, vtotal,
1402 __func__, drate, hrate, xgi_video_info.refresh_rate);
1403 } else {
1404 xgi_video_info.refresh_rate = 60;
1405 }
1406
1407/*
1408 if((var->pixclock) && (htotal)) {
1409 drate = 1E12 / var->pixclock;
1410 hrate = drate / htotal;
1411 refresh_rate = (unsigned int) (hrate / vtotal * 2 + 0.5);
1412 } else refresh_rate = 60;
1413*/
1414 /* TW: Calculation wrong for 1024x600 - force it to 60Hz */
1415 if((var->xres == 1024) && (var->yres == 600)) refresh_rate = 60;
1416
1417 search_idx = 0;
1418 while((XGIbios_mode[search_idx].mode_no != 0) &&
1419 (XGIbios_mode[search_idx].xres <= var->xres) ) {
1420 if((XGIbios_mode[search_idx].xres == var->xres) &&
1421 (XGIbios_mode[search_idx].yres == var->yres) &&
1422 (XGIbios_mode[search_idx].bpp == var->bits_per_pixel)) {
1423 if(XGIfb_validate_mode(search_idx) > 0) {
1424 found_mode = 1;
1425 break;
1426 }
1427 }
1428 search_idx++;
1429 }
1430
1431 if(!found_mode) {
1432
1433 printk(KERN_ERR "XGIfb: %dx%dx%d is no valid mode\n",
1434 var->xres, var->yres, var->bits_per_pixel);
1435
1436 search_idx = 0;
1437 while(XGIbios_mode[search_idx].mode_no != 0) {
1438
1439 if( (var->xres <= XGIbios_mode[search_idx].xres) &&
1440 (var->yres <= XGIbios_mode[search_idx].yres) &&
1441 (var->bits_per_pixel == XGIbios_mode[search_idx].bpp) ) {
1442 if(XGIfb_validate_mode(search_idx) > 0) {
1443 found_mode = 1;
1444 break;
1445 }
1446 }
1447 search_idx++;
1448 }
1449 if(found_mode) {
1450 var->xres = XGIbios_mode[search_idx].xres;
1451 var->yres = XGIbios_mode[search_idx].yres;
1452 printk(KERN_DEBUG "XGIfb: Adapted to mode %dx%dx%d\n",
1453 var->xres, var->yres, var->bits_per_pixel);
1454
1455 } else {
1456 printk(KERN_ERR "XGIfb: Failed to find similar mode to %dx%dx%d\n",
1457 var->xres, var->yres, var->bits_per_pixel);
1458 return -EINVAL;
1459 }
1460 }
1461
1462 /* TW: TODO: Check the refresh rate */
1463
1464 /* Adapt RGB settings */
1465 XGIfb_bpp_to_var(var);
1466
1467 /* Sanity check for offsets */
1468 if (var->xoffset < 0)
1469 var->xoffset = 0;
1470 if (var->yoffset < 0)
1471 var->yoffset = 0;
1472
1473
1474 if(!XGIfb_ypan) {
1475 if(var->xres != var->xres_virtual)
1476 var->xres_virtual = var->xres;
1477 if(var->yres != var->yres_virtual)
1478 var->yres_virtual = var->yres;
1479 }/* else {
1480 // TW: Now patch yres_virtual if we use panning
1481 // May I do this?
1482 var->yres_virtual = xgi_video_info.heapstart / (var->xres * (var->bits_per_pixel >> 3));
1483 if(var->yres_virtual <= var->yres) {
1484 // TW: Paranoia check
1485 var->yres_virtual = var->yres;
1486 }
1487 }*/
1488
1489 /* Truncate offsets to maximum if too high */
1490 if (var->xoffset > var->xres_virtual - var->xres)
1491 var->xoffset = var->xres_virtual - var->xres - 1;
1492
1493 if (var->yoffset > var->yres_virtual - var->yres)
1494 var->yoffset = var->yres_virtual - var->yres - 1;
1495
1496 /* Set everything else to 0 */
1497 var->red.msb_right =
1498 var->green.msb_right =
1499 var->blue.msb_right =
1500 var->transp.offset = var->transp.length = var->transp.msb_right = 0;
1501
1502 DEBUGPRN("end of check_var");
1503 return 0;
1504}
1505
1506#ifdef XGIFB_PAN
1507static int XGIfb_pan_display( struct fb_var_screeninfo *var,
1508 struct fb_info* info)
1509{
1510 int err;
1511
1512// printk("\nInside pan_display:");
1513
1514 if (var->xoffset > (var->xres_virtual - var->xres))
1515 return -EINVAL;
1516 if (var->yoffset > (var->yres_virtual - var->yres))
1517 return -EINVAL;
1518
1519 if (var->vmode & FB_VMODE_YWRAP) {
1520 if (var->yoffset < 0
1521 || var->yoffset >= info->var.yres_virtual
1522 || var->xoffset) return -EINVAL;
1523 } else {
1524 if (var->xoffset + info->var.xres > info->var.xres_virtual ||
1525 var->yoffset + info->var.yres > info->var.yres_virtual)
1526 return -EINVAL;
1527 }
1528
1529 if((err = XGIfb_pan_var(var)) < 0) return err;
1530
1531 info->var.xoffset = var->xoffset;
1532 info->var.yoffset = var->yoffset;
1533 if (var->vmode & FB_VMODE_YWRAP)
1534 info->var.vmode |= FB_VMODE_YWRAP;
1535 else
1536 info->var.vmode &= ~FB_VMODE_YWRAP;
1537
1538// printk(" End of pan_display");
1539 return 0;
1540}
1541#endif
1542
1543#if 0
1544static int XGIfb_mmap(struct fb_info *info, struct file *file,
1545 struct vm_area_struct *vma)
1546{
1547 unsigned long start;
1548 unsigned long off;
1549 u32 len, mmio_off;
1550
1551 DEBUGPRN("inside mmap");
1552 if(vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) return -EINVAL;
1553
1554 off = vma->vm_pgoff << PAGE_SHIFT;
1555
1556 start = (unsigned long) xgi_video_info.video_base;
1557 len = PAGE_ALIGN((start & ~PAGE_MASK) + xgi_video_info.video_size);
1558 start &= PAGE_MASK;
1559#if 0
1560 if (off >= len) {
1561 off -= len;
1562#endif
1563 /* By Jake Page: Treat mmap request with offset beyond heapstart
1564 * as request for mapping the mmio area
1565 */
1566 #if 1
1567 mmio_off = PAGE_ALIGN((start & ~PAGE_MASK) + xgi_video_info.heapstart);
1568 if(off >= mmio_off) {
1569 off -= mmio_off;
1570 if(info->var.accel_flags) return -EINVAL;
1571
1572 start = (unsigned long) xgi_video_info.mmio_base;
1573 len = PAGE_ALIGN((start & ~PAGE_MASK) + XGIfb_mmio_size);
1574 }
1575 start &= PAGE_MASK;
1576 #endif
1577 if((vma->vm_end - vma->vm_start + off) > len) return -EINVAL;
1578
1579 off += start;
1580 vma->vm_pgoff = off >> PAGE_SHIFT;
1581 vma->vm_flags |= VM_IO; /* by Jake Page; is that really needed? */
1582
1583#if defined(__i386__) || defined(__x86_64__)
1584 if (boot_cpu_data.x86 > 3)
1585 pgprot_val(vma->vm_page_prot) |= _PAGE_PCD;
1586#endif
1587 if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT, vma->vm_end - vma->vm_start,
1588 vma->vm_page_prot))
1589 return -EAGAIN;
1590
1591 DEBUGPRN("end of mmap");
1592 return 0;
1593}
1594#endif
1595static int XGIfb_blank(int blank, struct fb_info *info)
1596{
1597 u8 reg;
1598
1599 inXGIIDXREG(XGICR, 0x17, reg);
1600
1601 if(blank > 0)
1602 reg &= 0x7f;
1603 else
1604 reg |= 0x80;
1605
1606 outXGIIDXREG(XGICR, 0x17, reg);
1607 outXGIIDXREG(XGISR, 0x00, 0x01); /* Synchronous Reset */
1608 outXGIIDXREG(XGISR, 0x00, 0x03); /* End Reset */
1609 return(0);
1610}
1611
1612
1613#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
1614static int XGIfb_ioctl(struct fb_info *info, unsigned int cmd,
1615 unsigned long arg)
1616#else
1617static int XGIfb_ioctl(struct inode *inode, struct file *file,
1618 unsigned int cmd, unsigned long arg,
1619 struct fb_info *info)
1620#endif
1621
1622{
1623 DEBUGPRN("inside ioctl");
1624 switch (cmd) {
1625 case FBIO_ALLOC:
1626 if (!capable(CAP_SYS_RAWIO))
1627 return -EPERM;
1628 XGI_malloc((struct XGI_memreq *) arg);
1629 break;
1630 case FBIO_FREE:
1631 if (!capable(CAP_SYS_RAWIO))
1632 return -EPERM;
1633 XGI_free(*(unsigned long *) arg);
1634 break;
1635 case FBIOGET_HWCINFO:
1636 {
1637 unsigned long *hwc_offset = (unsigned long *) arg;
1638
1639 if (XGIfb_caps & HW_CURSOR_CAP)
1640 *hwc_offset = XGIfb_hwcursor_vbase -
1641 (unsigned long) xgi_video_info.video_vbase;
1642 else
1643 *hwc_offset = 0;
1644
1645 break;
1646 }
1647 case FBIOPUT_MODEINFO:
1648 {
1649 struct mode_info *x = (struct mode_info *)arg;
1650
1651 xgi_video_info.video_bpp = x->bpp;
1652 xgi_video_info.video_width = x->xres;
1653 xgi_video_info.video_height = x->yres;
1654 xgi_video_info.video_vwidth = x->v_xres;
1655 xgi_video_info.video_vheight = x->v_yres;
1656 xgi_video_info.org_x = x->org_x;
1657 xgi_video_info.org_y = x->org_y;
1658 xgi_video_info.refresh_rate = x->vrate;
1659 xgi_video_info.video_linelength = xgi_video_info.video_vwidth * (xgi_video_info.video_bpp >> 3);
1660 switch(xgi_video_info.video_bpp) {
1661 case 8:
1662 xgi_video_info.DstColor = 0x0000;
1663 xgi_video_info.XGI310_AccelDepth = 0x00000000;
1664 xgi_video_info.video_cmap_len = 256;
1665 break;
1666 case 16:
1667 xgi_video_info.DstColor = 0x8000;
1668 xgi_video_info.XGI310_AccelDepth = 0x00010000;
1669 xgi_video_info.video_cmap_len = 16;
1670 break;
1671 case 32:
1672 xgi_video_info.DstColor = 0xC000;
1673 xgi_video_info.XGI310_AccelDepth = 0x00020000;
1674 xgi_video_info.video_cmap_len = 16;
1675 break;
1676 default:
1677 xgi_video_info.video_cmap_len = 16;
1678 printk(KERN_ERR "XGIfb: Unsupported accel depth %d", xgi_video_info.video_bpp);
1679 xgi_video_info.accel = 0;
1680 break;
1681 }
1682
1683 break;
1684 }
1685 case FBIOGET_DISPINFO:
1686 XGI_dispinfo((struct ap_data *)arg);
1687 break;
1688 case XGIFB_GET_INFO: /* TW: New for communication with X driver */
1689 {
1690 XGIfb_info *x = (XGIfb_info *)arg;
1691
1692 //x->XGIfb_id = XGIFB_ID;
1693 x->XGIfb_version = VER_MAJOR;
1694 x->XGIfb_revision = VER_MINOR;
1695 x->XGIfb_patchlevel = VER_LEVEL;
1696 x->chip_id = xgi_video_info.chip_id;
1697 x->memory = xgi_video_info.video_size / 1024;
1698 x->heapstart = xgi_video_info.heapstart / 1024;
1699 x->fbvidmode = XGIfb_mode_no;
1700 x->XGIfb_caps = XGIfb_caps;
1701 x->XGIfb_tqlen = 512; /* yet unused */
1702 x->XGIfb_pcibus = xgi_video_info.pcibus;
1703 x->XGIfb_pcislot = xgi_video_info.pcislot;
1704 x->XGIfb_pcifunc = xgi_video_info.pcifunc;
1705 x->XGIfb_lcdpdc = XGIfb_detectedpdc;
1706 x->XGIfb_lcda = XGIfb_detectedlcda;
1707 break;
1708 }
1709 case XGIFB_GET_VBRSTATUS:
1710 {
1711 unsigned long *vbrstatus = (unsigned long *) arg;
1712 if(XGIfb_CheckVBRetrace()) *vbrstatus = 1;
1713 else *vbrstatus = 0;
1714 }
1715 default:
1716 return -EINVAL;
1717 }
1718 DEBUGPRN("end of ioctl");
1719 return 0;
1720
1721}
1722
1723
1724
1725/* ----------- FBDev related routines for all series ---------- */
1726
1727static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con,
1728 struct fb_info *info)
1729{
1730 DEBUGPRN("inside get_fix");
1731 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
1732
1733 strcpy(fix->id, myid);
1734
1735 fix->smem_start = xgi_video_info.video_base;
1736
1737 fix->smem_len = xgi_video_info.video_size;
1738
1739
1740/* if((!XGIfb_mem) || (XGIfb_mem > (xgi_video_info.video_size/1024))) {
1741 if (xgi_video_info.video_size > 0x1000000) {
1742 fix->smem_len = 0xD00000;
1743 } else if (xgi_video_info.video_size > 0x800000)
1744 fix->smem_len = 0x800000;
1745 else
1746 fix->smem_len = 0x400000;
1747 } else
1748 fix->smem_len = XGIfb_mem * 1024;
1749*/
1750 fix->type = video_type;
1751 fix->type_aux = 0;
1752 if(xgi_video_info.video_bpp == 8)
1753 fix->visual = FB_VISUAL_PSEUDOCOLOR;
1754 else
1755 fix->visual = FB_VISUAL_DIRECTCOLOR;
1756 fix->xpanstep = 0;
1757#ifdef XGIFB_PAN
1758 if(XGIfb_ypan) fix->ypanstep = 1;
1759#endif
1760 fix->ywrapstep = 0;
1761 fix->line_length = xgi_video_info.video_linelength;
1762 fix->mmio_start = xgi_video_info.mmio_base;
1763 fix->mmio_len = XGIfb_mmio_size;
1764 if(xgi_video_info.chip >= XG40)
1765 fix->accel = FB_ACCEL_XGI_XABRE;
1766 else
1767 fix->accel = FB_ACCEL_XGI_GLAMOUR_2;
1768
1769
1770 DEBUGPRN("end of get_fix");
1771 return 0;
1772}
1773
1774
1775static struct fb_ops XGIfb_ops = {
1776 .owner = THIS_MODULE,
1777 .fb_open = XGIfb_open,
1778 .fb_release = XGIfb_release,
1779 .fb_check_var = XGIfb_check_var,
1780 .fb_set_par = XGIfb_set_par,
1781 .fb_setcolreg = XGIfb_setcolreg,
1782#ifdef XGIFB_PAN
1783 .fb_pan_display = XGIfb_pan_display,
1784#endif
1785 .fb_blank = XGIfb_blank,
1786 .fb_fillrect = fbcon_XGI_fillrect,
1787 .fb_copyarea = fbcon_XGI_copyarea,
1788 .fb_imageblit = cfb_imageblit,
1789#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
1790 .fb_cursor = soft_cursor,
1791#endif
1792 .fb_sync = fbcon_XGI_sync,
1793 .fb_ioctl = XGIfb_ioctl,
1794// .fb_mmap = XGIfb_mmap,
1795};
1796
1797/* ---------------- Chip generation dependent routines ---------------- */
1798
1799
1800/* for XGI 315/550/650/740/330 */
1801
1802static int XGIfb_get_dram_size(void)
1803{
1804
1805 u8 ChannelNum,tmp;
1806 u8 reg = 0;
1807
1808 /* xorg driver sets 32MB * 1 channel */
1809 if (xgi_video_info.chip == XG27)
1810 outXGIIDXREG(XGISR, IND_XGI_DRAM_SIZE, 0x51);
1811
1812 inXGIIDXREG(XGISR, IND_XGI_DRAM_SIZE, reg);
1813 switch ((reg & XGI_DRAM_SIZE_MASK) >> 4) {
1814 case XGI_DRAM_SIZE_1MB:
1815 xgi_video_info.video_size = 0x100000;
1816 break;
1817 case XGI_DRAM_SIZE_2MB:
1818 xgi_video_info.video_size = 0x200000;
1819 break;
1820 case XGI_DRAM_SIZE_4MB:
1821 xgi_video_info.video_size = 0x400000;
1822 break;
1823 case XGI_DRAM_SIZE_8MB:
1824 xgi_video_info.video_size = 0x800000;
1825 break;
1826 case XGI_DRAM_SIZE_16MB:
1827 xgi_video_info.video_size = 0x1000000;
1828 break;
1829 case XGI_DRAM_SIZE_32MB:
1830 xgi_video_info.video_size = 0x2000000;
1831 break;
1832 case XGI_DRAM_SIZE_64MB:
1833 xgi_video_info.video_size = 0x4000000;
1834 break;
1835 case XGI_DRAM_SIZE_128MB:
1836 xgi_video_info.video_size = 0x8000000;
1837 break;
1838 case XGI_DRAM_SIZE_256MB:
1839 xgi_video_info.video_size = 0x10000000;
1840 break;
1841 default:
1842 return -1;
1843 }
1844
1845 tmp = (reg & 0x0c) >> 2;
1846 switch(xgi_video_info.chip)
1847 {
1848 case XG20:
1849 case XG21:
1850 case XG27:
1851 ChannelNum = 1;
1852 break;
1853
1854 case XG42:
1855 if(reg & 0x04)
1856 ChannelNum = 2;
1857 else
1858 ChannelNum = 1;
1859 break;
1860
1861 case XG45:
1862 if(tmp == 1)
1863 ChannelNum = 2;
1864 else
1865 if(tmp == 2)
1866 ChannelNum = 3;
1867 else
1868 if(tmp == 3)
1869 ChannelNum = 4;
1870 else
1871 ChannelNum = 1;
1872 break;
1873
1874 case XG40:
1875 default:
1876 if(tmp == 2)
1877 ChannelNum = 2;
1878 else
1879 if(tmp == 3)
1880 ChannelNum = 3;
1881 else
1882 ChannelNum = 1;
1883 break;
1884 }
1885
1886
1887 xgi_video_info.video_size = xgi_video_info.video_size * ChannelNum;
1888 //PLiad fixed for benchmarking and fb set
1889 //xgi_video_info.video_size = 0x200000;//1024x768x16
1890 //xgi_video_info.video_size = 0x1000000;//benchmark
1891
1892 printk("XGIfb: SR14=%x DramSzie %x ChannelNum %x\n",reg,xgi_video_info.video_size ,ChannelNum );
1893 return 0;
1894
1895}
1896
1897static void XGIfb_detect_VB(void)
1898{
1899 u8 cr32, temp=0;
1900
1901 xgi_video_info.TV_plug = xgi_video_info.TV_type = 0;
1902
1903 switch(xgi_video_info.hasVB) {
1904 case HASVB_LVDS_CHRONTEL:
1905 case HASVB_CHRONTEL:
1906 break;
1907 case HASVB_301:
1908 case HASVB_302:
1909// XGI_Sense30x(); //Yi-Lin TV Sense?
1910 break;
1911 }
1912
1913 inXGIIDXREG(XGICR, IND_XGI_SCRATCH_REG_CR32, cr32);
1914
1915 if ((cr32 & XGI_CRT1) && !XGIfb_crt1off)
1916 XGIfb_crt1off = 0;
1917 else {
1918 if (cr32 & 0x5F)
1919 XGIfb_crt1off = 1;
1920 else
1921 XGIfb_crt1off = 0;
1922 }
1923
1924 if (XGIfb_crt2type != -1)
1925 /* TW: Override with option */
1926 xgi_video_info.disp_state = XGIfb_crt2type;
1927 else if (cr32 & XGI_VB_TV)
1928 xgi_video_info.disp_state = DISPTYPE_TV;
1929 else if (cr32 & XGI_VB_LCD)
1930 xgi_video_info.disp_state = DISPTYPE_LCD;
1931 else if (cr32 & XGI_VB_CRT2)
1932 xgi_video_info.disp_state = DISPTYPE_CRT2;
1933 else
1934 xgi_video_info.disp_state = 0;
1935
1936 if(XGIfb_tvplug != -1)
1937 /* PR/TW: Override with option */
1938 xgi_video_info.TV_plug = XGIfb_tvplug;
1939 else if (cr32 & XGI_VB_HIVISION) {
1940 xgi_video_info.TV_type = TVMODE_HIVISION;
1941 xgi_video_info.TV_plug = TVPLUG_SVIDEO;
1942 }
1943 else if (cr32 & XGI_VB_SVIDEO)
1944 xgi_video_info.TV_plug = TVPLUG_SVIDEO;
1945 else if (cr32 & XGI_VB_COMPOSITE)
1946 xgi_video_info.TV_plug = TVPLUG_COMPOSITE;
1947 else if (cr32 & XGI_VB_SCART)
1948 xgi_video_info.TV_plug = TVPLUG_SCART;
1949
1950 if(xgi_video_info.TV_type == 0) {
1951 /* TW: PAL/NTSC changed for 650 */
1952 if((xgi_video_info.chip <= XGI_315PRO) || (xgi_video_info.chip >= XGI_330)) {
1953
1954 inXGIIDXREG(XGICR, 0x38, temp);
1955 if(temp & 0x10)
1956 xgi_video_info.TV_type = TVMODE_PAL;
1957 else
1958 xgi_video_info.TV_type = TVMODE_NTSC;
1959
1960 } else {
1961
1962 inXGIIDXREG(XGICR, 0x79, temp);
1963 if(temp & 0x20)
1964 xgi_video_info.TV_type = TVMODE_PAL;
1965 else
1966 xgi_video_info.TV_type = TVMODE_NTSC;
1967 }
1968 }
1969
1970 /* TW: Copy forceCRT1 option to CRT1off if option is given */
1971 if (XGIfb_forcecrt1 != -1) {
1972 if (XGIfb_forcecrt1) XGIfb_crt1off = 0;
1973 else XGIfb_crt1off = 1;
1974 }
1975}
1976
1977static void XGIfb_get_VB_type(void)
1978{
1979 u8 reg;
1980
1981 if (!XGIfb_has_VB()) {
1982 inXGIIDXREG(XGICR, IND_XGI_SCRATCH_REG_CR37, reg);
1983 switch ((reg & XGI_EXTERNAL_CHIP_MASK) >> 1) {
1984 case XGI310_EXTERNAL_CHIP_LVDS:
1985 xgi_video_info.hasVB = HASVB_LVDS;
1986 break;
1987 case XGI310_EXTERNAL_CHIP_LVDS_CHRONTEL:
1988 xgi_video_info.hasVB = HASVB_LVDS_CHRONTEL;
1989 break;
1990 default:
1991 break;
1992 }
1993 }
1994}
1995
1996
1997static int XGIfb_has_VB(void)
1998{
1999 u8 vb_chipid;
2000
2001 inXGIIDXREG(XGIPART4, 0x00, vb_chipid);
2002 switch (vb_chipid) {
2003 case 0x01:
2004 xgi_video_info.hasVB = HASVB_301;
2005 break;
2006 case 0x02:
2007 xgi_video_info.hasVB = HASVB_302;
2008 break;
2009 default:
2010 xgi_video_info.hasVB = HASVB_NONE;
2011 return FALSE;
2012 }
2013 return TRUE;
2014}
2015
2016
2017
2018/* ------------------ Sensing routines ------------------ */
2019
2020/* TW: Determine and detect attached devices on XGI30x */
2021int
2022XGIDoSense(int tempbl, int tempbh, int tempcl, int tempch)
2023{
2024 int temp,i;
2025
2026 outXGIIDXREG(XGIPART4,0x11,tempbl);
2027 temp = tempbh | tempcl;
2028 setXGIIDXREG(XGIPART4,0x10,0xe0,temp);
2029 for(i=0; i<10; i++) XGI_LongWait(&XGI_Pr);
2030 tempch &= 0x7f;
2031 inXGIIDXREG(XGIPART4,0x03,temp);
2032 temp ^= 0x0e;
2033 temp &= tempch;
2034 return(temp);
2035}
2036
2037void
2038XGI_Sense30x(void)
2039{
2040 u8 backupP4_0d;
2041 u8 testsvhs_tempbl, testsvhs_tempbh;
2042 u8 testsvhs_tempcl, testsvhs_tempch;
2043 u8 testcvbs_tempbl, testcvbs_tempbh;
2044 u8 testcvbs_tempcl, testcvbs_tempch;
2045 u8 testvga2_tempbl, testvga2_tempbh;
2046 u8 testvga2_tempcl, testvga2_tempch;
2047 int myflag, result;
2048
2049 inXGIIDXREG(XGIPART4,0x0d,backupP4_0d);
2050 outXGIIDXREG(XGIPART4,0x0d,(backupP4_0d | 0x04));
2051
2052
2053
2054 testvga2_tempbh = 0x00; testvga2_tempbl = 0xd1;
2055 testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xb9;
2056 testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xb3;
2057 if((XGIhw_ext.ujVBChipID != VB_CHIP_301) &&
2058 (XGIhw_ext.ujVBChipID != VB_CHIP_302)) {
2059 testvga2_tempbh = 0x01; testvga2_tempbl = 0x90;
2060 testsvhs_tempbh = 0x01; testsvhs_tempbl = 0x6b;
2061 testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x74;
2062 if(XGIhw_ext.ujVBChipID == VB_CHIP_301LV ||
2063 XGIhw_ext.ujVBChipID == VB_CHIP_302LV) {
2064 testvga2_tempbh = 0x00; testvga2_tempbl = 0x00;
2065 testsvhs_tempbh = 0x02; testsvhs_tempbl = 0x00;
2066 testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x00;
2067 }
2068 }
2069 if(XGIhw_ext.ujVBChipID != VB_CHIP_301LV &&
2070 XGIhw_ext.ujVBChipID != VB_CHIP_302LV) {
2071 inXGIIDXREG(XGIPART4,0x01,myflag);
2072 if(myflag & 0x04) {
2073 testvga2_tempbh = 0x00; testvga2_tempbl = 0xfd;
2074 testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xdd;
2075 testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xee;
2076 }
2077 }
2078 if((XGIhw_ext.ujVBChipID == VB_CHIP_301LV) ||
2079 (XGIhw_ext.ujVBChipID == VB_CHIP_302LV) ) {
2080 testvga2_tempbh = 0x00; testvga2_tempbl = 0x00;
2081 testvga2_tempch = 0x00; testvga2_tempcl = 0x00;
2082 testsvhs_tempch = 0x04; testsvhs_tempcl = 0x08;
2083 testcvbs_tempch = 0x08; testcvbs_tempcl = 0x08;
2084 } else {
2085 testvga2_tempch = 0x0e; testvga2_tempcl = 0x08;
2086 testsvhs_tempch = 0x06; testsvhs_tempcl = 0x04;
2087 testcvbs_tempch = 0x08; testcvbs_tempcl = 0x04;
2088 }
2089
2090
2091 if(testvga2_tempch || testvga2_tempcl || testvga2_tempbh || testvga2_tempbl) {
2092 result = XGIDoSense(testvga2_tempbl, testvga2_tempbh,
2093 testvga2_tempcl, testvga2_tempch);
2094 if(result) {
2095 printk(KERN_INFO "XGIfb: Detected secondary VGA connection\n");
2096 orXGIIDXREG(XGICR, 0x32, 0x10);
2097 }
2098 }
2099
2100 result = XGIDoSense(testsvhs_tempbl, testsvhs_tempbh,
2101 testsvhs_tempcl, testsvhs_tempch);
2102 if(result) {
2103 printk(KERN_INFO "XGIfb: Detected TV connected to SVHS output\n");
2104 /* TW: So we can be sure that there IS a SVHS output */
2105 xgi_video_info.TV_plug = TVPLUG_SVIDEO;
2106 orXGIIDXREG(XGICR, 0x32, 0x02);
2107 }
2108
2109 if(!result) {
2110 result = XGIDoSense(testcvbs_tempbl, testcvbs_tempbh,
2111 testcvbs_tempcl, testcvbs_tempch);
2112 if(result) {
2113 printk(KERN_INFO "XGIfb: Detected TV connected to CVBS output\n");
2114 /* TW: So we can be sure that there IS a CVBS output */
2115 xgi_video_info.TV_plug = TVPLUG_COMPOSITE;
2116 orXGIIDXREG(XGICR, 0x32, 0x01);
2117 }
2118 }
2119 XGIDoSense(0, 0, 0, 0);
2120
2121 outXGIIDXREG(XGIPART4,0x0d,backupP4_0d);
2122}
2123
2124
2125
2126/* ------------------------ Heap routines -------------------------- */
2127
2128static int XGIfb_heap_init(void)
2129{
2130 XGI_OH *poh;
2131 u8 temp=0;
2132
2133 int agp_enabled = 1;
2134 u32 agp_size;
2135 unsigned long *cmdq_baseport = 0;
2136 unsigned long *read_port = 0;
2137 unsigned long *write_port = 0;
2138 XGI_CMDTYPE cmd_type;
2139#ifndef AGPOFF
2140 struct agp_kern_info *agp_info;
2141 struct agp_memory *agp;
2142 u32 agp_phys;
2143#endif
2144
2145/* TW: The heap start is either set manually using the "mem" parameter, or
2146 * defaults as follows:
2147 * -) If more than 16MB videoRAM available, let our heap start at 12MB.
2148 * -) If more than 8MB videoRAM available, let our heap start at 8MB.
2149 * -) If 4MB or less is available, let it start at 4MB.
2150 * This is for avoiding a clash with X driver which uses the beginning
2151 * of the videoRAM. To limit size of X framebuffer, use Option MaxXFBMem
2152 * in XF86Config-4.
2153 * The heap start can also be specified by parameter "mem" when starting the XGIfb
2154 * driver. XGIfb mem=1024 lets heap starts at 1MB, etc.
2155 */
2156 if ((!XGIfb_mem) || (XGIfb_mem > (xgi_video_info.video_size/1024))) {
2157 if (xgi_video_info.video_size > 0x1000000) {
2158 xgi_video_info.heapstart = 0xD00000;
2159 } else if (xgi_video_info.video_size > 0x800000) {
2160 xgi_video_info.heapstart = 0x800000;
2161 } else {
2162 xgi_video_info.heapstart = 0x400000;
2163 }
2164 } else {
2165 xgi_video_info.heapstart = XGIfb_mem * 1024;
2166 }
2167 XGIfb_heap_start =
2168 (unsigned long) (xgi_video_info.video_vbase + xgi_video_info.heapstart);
2169 printk(KERN_INFO "XGIfb: Memory heap starting at %dK\n",
2170 (int)(xgi_video_info.heapstart / 1024));
2171
2172 XGIfb_heap_end = (unsigned long) xgi_video_info.video_vbase + xgi_video_info.video_size;
2173 XGIfb_heap_size = XGIfb_heap_end - XGIfb_heap_start;
2174
2175
2176
2177 /* TW: Now initialize the 310 series' command queue mode.
2178 * On 310/325, there are three queue modes available which
2179 * are chosen by setting bits 7:5 in SR26:
2180 * 1. MMIO queue mode (bit 5, 0x20). The hardware will keep
2181 * track of the queue, the FIFO, command parsing and so
2182 * on. This is the one comparable to the 300 series.
2183 * 2. VRAM queue mode (bit 6, 0x40). In this case, one will
2184 * have to do queue management himself. Register 0x85c4 will
2185 * hold the location of the next free queue slot, 0x85c8
2186 * is the "queue read pointer" whose way of working is
2187 * unknown to me. Anyway, this mode would require a
2188 * translation of the MMIO commands to some kind of
2189 * accelerator assembly and writing these commands
2190 * to the memory location pointed to by 0x85c4.
2191 * We will not use this, as nobody knows how this
2192 * "assembly" works, and as it would require a complete
2193 * re-write of the accelerator code.
2194 * 3. AGP queue mode (bit 7, 0x80). Works as 2., but keeps the
2195 * queue in AGP memory space.
2196 *
2197 * SR26 bit 4 is called "Bypass H/W queue".
2198 * SR26 bit 1 is called "Enable Command Queue Auto Correction"
2199 * SR26 bit 0 resets the queue
2200 * Size of queue memory is encoded in bits 3:2 like this:
2201 * 00 (0x00) 512K
2202 * 01 (0x04) 1M
2203 * 10 (0x08) 2M
2204 * 11 (0x0C) 4M
2205 * The queue location is to be written to 0x85C0.
2206 *
2207 */
2208 cmdq_baseport = (unsigned long *)(xgi_video_info.mmio_vbase + MMIO_QUEUE_PHYBASE);
2209 write_port = (unsigned long *)(xgi_video_info.mmio_vbase + MMIO_QUEUE_WRITEPORT);
2210 read_port = (unsigned long *)(xgi_video_info.mmio_vbase + MMIO_QUEUE_READPORT);
2211
2212 DPRINTK("AGP base: 0x%p, read: 0x%p, write: 0x%p\n", cmdq_baseport, read_port, write_port);
2213
2214 agp_size = COMMAND_QUEUE_AREA_SIZE;
2215
2216#ifndef AGPOFF
2217 if (XGIfb_queuemode == AGP_CMD_QUEUE) {
2218 agp_info = vmalloc(sizeof(*agp_info));
2219 memset((void*)agp_info, 0x00, sizeof(*agp_info));
2220 agp_copy_info(agp_info);
2221
2222 agp_backend_acquire();
2223
2224 agp = agp_allocate_memory(COMMAND_QUEUE_AREA_SIZE/PAGE_SIZE,
2225 AGP_NORMAL_MEMORY);
2226 if (agp == NULL) {
2227 DPRINTK("XGIfb: Allocating AGP buffer failed.\n");
2228 agp_enabled = 0;
2229 } else {
2230 if (agp_bind_memory(agp, agp->pg_start) != 0) {
2231 DPRINTK("XGIfb: AGP: Failed to bind memory\n");
2232 /* TODO: Free AGP memory here */
2233 agp_enabled = 0;
2234 } else {
2235 agp_enable(0);
2236 }
2237 }
2238 }
2239#else
2240 agp_enabled = 0;
2241#endif
2242
2243 /* TW: Now select the queue mode */
2244
2245 if ((agp_enabled) && (XGIfb_queuemode == AGP_CMD_QUEUE)) {
2246 cmd_type = AGP_CMD_QUEUE;
2247 printk(KERN_INFO "XGIfb: Using AGP queue mode\n");
2248/* } else if (XGIfb_heap_size >= COMMAND_QUEUE_AREA_SIZE) */
2249 } else if (XGIfb_queuemode == VM_CMD_QUEUE) {
2250 cmd_type = VM_CMD_QUEUE;
2251 printk(KERN_INFO "XGIfb: Using VRAM queue mode\n");
2252 } else {
2253 printk(KERN_INFO "XGIfb: Using MMIO queue mode\n");
2254 cmd_type = MMIO_CMD;
2255 }
2256
2257 switch (agp_size) {
2258 case 0x80000:
2259 temp = XGI_CMD_QUEUE_SIZE_512k;
2260 break;
2261 case 0x100000:
2262 temp = XGI_CMD_QUEUE_SIZE_1M;
2263 break;
2264 case 0x200000:
2265 temp = XGI_CMD_QUEUE_SIZE_2M;
2266 break;
2267 case 0x400000:
2268 temp = XGI_CMD_QUEUE_SIZE_4M;
2269 break;
2270 }
2271
2272 switch (cmd_type) {
2273 case AGP_CMD_QUEUE:
2274#ifndef AGPOFF
2275 DPRINTK("XGIfb: AGP buffer base = 0x%lx, offset = 0x%x, size = %dK\n",
2276 agp_info->aper_base, agp->physical, agp_size/1024);
2277
2278 agp_phys = agp_info->aper_base + agp->physical;
2279
2280 outXGIIDXREG(XGICR, IND_XGI_AGP_IO_PAD, 0);
2281 outXGIIDXREG(XGICR, IND_XGI_AGP_IO_PAD, XGI_AGP_2X);
2282
2283 outXGIIDXREG(XGISR, IND_XGI_CMDQUEUE_THRESHOLD, COMMAND_QUEUE_THRESHOLD);
2284
2285 outXGIIDXREG(XGISR, IND_XGI_CMDQUEUE_SET, XGI_CMD_QUEUE_RESET);
2286
2287 *write_port = *read_port;
2288
2289 temp |= XGI_AGP_CMDQUEUE_ENABLE;
2290 outXGIIDXREG(XGISR, IND_XGI_CMDQUEUE_SET, temp);
2291
2292 *cmdq_baseport = agp_phys;
2293
2294 XGIfb_caps |= AGP_CMD_QUEUE_CAP;
2295#endif
2296 break;
2297
2298 case VM_CMD_QUEUE:
2299 XGIfb_heap_end -= COMMAND_QUEUE_AREA_SIZE;
2300 XGIfb_heap_size -= COMMAND_QUEUE_AREA_SIZE;
2301
2302 outXGIIDXREG(XGISR, IND_XGI_CMDQUEUE_THRESHOLD, COMMAND_QUEUE_THRESHOLD);
2303
2304 outXGIIDXREG(XGISR, IND_XGI_CMDQUEUE_SET, XGI_CMD_QUEUE_RESET);
2305
2306 *write_port = *read_port;
2307
2308 temp |= XGI_VRAM_CMDQUEUE_ENABLE;
2309 outXGIIDXREG(XGISR, IND_XGI_CMDQUEUE_SET, temp);
2310
2311 *cmdq_baseport = xgi_video_info.video_size - COMMAND_QUEUE_AREA_SIZE;
2312
2313 XGIfb_caps |= VM_CMD_QUEUE_CAP;
2314
2315 DPRINTK("XGIfb: VM Cmd Queue offset = 0x%lx, size is %dK\n",
2316 *cmdq_baseport, COMMAND_QUEUE_AREA_SIZE/1024);
2317 break;
2318
2319 default: /* MMIO */
2320
2321// printk("%s:%d - I'm here\n", __FUNCTION__, __LINE__);
2322 /* TW: This previously only wrote XGI_MMIO_CMD_ENABLE
2323 * to IND_XGI_CMDQUEUE_SET. I doubt that this is
2324 * enough. Reserve memory in any way.
2325 */
2326// FIXME XGIfb_heap_end -= COMMAND_QUEUE_AREA_SIZE;
2327// FIXME XGIfb_heap_size -= COMMAND_QUEUE_AREA_SIZE;
2328// FIXME
2329// FIXME outXGIIDXREG(XGISR, IND_XGI_CMDQUEUE_THRESHOLD, COMMAND_QUEUE_THRESHOLD);
2330// FIXME outXGIIDXREG(XGISR, IND_XGI_CMDQUEUE_SET, XGI_CMD_QUEUE_RESET);
2331// FIXME
2332// FIXME *write_port = *read_port;
2333// FIXME
2334// FIXME /* TW: Set Auto_Correction bit */
2335// FIXME temp |= (XGI_MMIO_CMD_ENABLE | XGI_CMD_AUTO_CORR);
2336// FIXME // FIXME outXGIIDXREG(XGISR, IND_XGI_CMDQUEUE_SET, temp);
2337// FIXME
2338// FIXME *cmdq_baseport = xgi_video_info.video_size - COMMAND_QUEUE_AREA_SIZE;
2339// FIXME
2340// FIXME XGIfb_caps |= MMIO_CMD_QUEUE_CAP;
2341// FIXME
2342// FIXME DPRINTK("XGIfb: MMIO Cmd Queue offset = 0x%lx, size is %dK\n",
2343// FIXME *cmdq_baseport, COMMAND_QUEUE_AREA_SIZE/1024);
2344 break;
2345 }
2346
2347
2348
2349
2350 /* TW: Now reserve memory for the HWCursor. It is always located at the very
2351 top of the videoRAM, right below the TB memory area (if used). */
2352 if (XGIfb_heap_size >= XGIfb_hwcursor_size) {
2353 XGIfb_heap_end -= XGIfb_hwcursor_size;
2354 XGIfb_heap_size -= XGIfb_hwcursor_size;
2355 XGIfb_hwcursor_vbase = XGIfb_heap_end;
2356
2357 XGIfb_caps |= HW_CURSOR_CAP;
2358
2359 DPRINTK("XGIfb: Hardware Cursor start at 0x%lx, size is %dK\n",
2360 XGIfb_heap_end, XGIfb_hwcursor_size/1024);
2361 }
2362
2363 XGIfb_heap.poha_chain = NULL;
2364 XGIfb_heap.poh_freelist = NULL;
2365
2366 poh = XGIfb_poh_new_node();
2367
2368 if(poh == NULL) return 1;
2369
2370 poh->poh_next = &XGIfb_heap.oh_free;
2371 poh->poh_prev = &XGIfb_heap.oh_free;
2372 poh->size = XGIfb_heap_end - XGIfb_heap_start + 1;
2373 poh->offset = XGIfb_heap_start - (unsigned long) xgi_video_info.video_vbase;
2374
2375 DPRINTK("XGIfb: Heap start:0x%p, end:0x%p, len=%dk\n",
2376 (char *) XGIfb_heap_start, (char *) XGIfb_heap_end,
2377 (unsigned int) poh->size / 1024);
2378
2379 DPRINTK("XGIfb: First Node offset:0x%x, size:%dk\n",
2380 (unsigned int) poh->offset, (unsigned int) poh->size / 1024);
2381
2382 XGIfb_heap.oh_free.poh_next = poh;
2383 XGIfb_heap.oh_free.poh_prev = poh;
2384 XGIfb_heap.oh_free.size = 0;
2385 XGIfb_heap.max_freesize = poh->size;
2386
2387 XGIfb_heap.oh_used.poh_next = &XGIfb_heap.oh_used;
2388 XGIfb_heap.oh_used.poh_prev = &XGIfb_heap.oh_used;
2389 XGIfb_heap.oh_used.size = SENTINEL;
2390
2391 return 0;
2392}
2393
2394static XGI_OH *XGIfb_poh_new_node(void)
2395{
2396 int i;
2397 unsigned long cOhs;
2398 XGI_OHALLOC *poha;
2399 XGI_OH *poh;
2400
2401 if (XGIfb_heap.poh_freelist == NULL) {
2402 poha = kmalloc(OH_ALLOC_SIZE, GFP_KERNEL);
2403 if(!poha) return NULL;
2404
2405 poha->poha_next = XGIfb_heap.poha_chain;
2406 XGIfb_heap.poha_chain = poha;
2407
2408 cOhs = (OH_ALLOC_SIZE - sizeof(XGI_OHALLOC)) / sizeof(XGI_OH) + 1;
2409
2410 poh = &poha->aoh[0];
2411 for (i = cOhs - 1; i != 0; i--) {
2412 poh->poh_next = poh + 1;
2413 poh = poh + 1;
2414 }
2415
2416 poh->poh_next = NULL;
2417 XGIfb_heap.poh_freelist = &poha->aoh[0];
2418 }
2419
2420 poh = XGIfb_heap.poh_freelist;
2421 XGIfb_heap.poh_freelist = poh->poh_next;
2422
2423 return (poh);
2424}
2425
2426static XGI_OH *XGIfb_poh_allocate(unsigned long size)
2427{
2428 XGI_OH *pohThis;
2429 XGI_OH *pohRoot;
2430 int bAllocated = 0;
2431
2432 if (size > XGIfb_heap.max_freesize) {
2433 DPRINTK("XGIfb: Can't allocate %dk size on offscreen\n",
2434 (unsigned int) size / 1024);
2435 return (NULL);
2436 }
2437
2438 pohThis = XGIfb_heap.oh_free.poh_next;
2439
2440 while (pohThis != &XGIfb_heap.oh_free) {
2441 if (size <= pohThis->size) {
2442 bAllocated = 1;
2443 break;
2444 }
2445 pohThis = pohThis->poh_next;
2446 }
2447
2448 if (!bAllocated) {
2449 DPRINTK("XGIfb: Can't allocate %dk size on offscreen\n",
2450 (unsigned int) size / 1024);
2451 return (NULL);
2452 }
2453
2454 if (size == pohThis->size) {
2455 pohRoot = pohThis;
2456 XGIfb_delete_node(pohThis);
2457 } else {
2458 pohRoot = XGIfb_poh_new_node();
2459
2460 if (pohRoot == NULL) {
2461 return (NULL);
2462 }
2463
2464 pohRoot->offset = pohThis->offset;
2465 pohRoot->size = size;
2466
2467 pohThis->offset += size;
2468 pohThis->size -= size;
2469 }
2470
2471 XGIfb_heap.max_freesize -= size;
2472
2473 pohThis = &XGIfb_heap.oh_used;
2474 XGIfb_insert_node(pohThis, pohRoot);
2475
2476 return (pohRoot);
2477}
2478
2479static void XGIfb_delete_node(XGI_OH *poh)
2480{
2481 XGI_OH *poh_prev;
2482 XGI_OH *poh_next;
2483
2484 poh_prev = poh->poh_prev;
2485 poh_next = poh->poh_next;
2486
2487 poh_prev->poh_next = poh_next;
2488 poh_next->poh_prev = poh_prev;
2489
2490}
2491
2492static void XGIfb_insert_node(XGI_OH *pohList, XGI_OH *poh)
2493{
2494 XGI_OH *pohTemp;
2495
2496 pohTemp = pohList->poh_next;
2497
2498 pohList->poh_next = poh;
2499 pohTemp->poh_prev = poh;
2500
2501 poh->poh_prev = pohList;
2502 poh->poh_next = pohTemp;
2503}
2504
2505static XGI_OH *XGIfb_poh_free(unsigned long base)
2506{
2507 XGI_OH *pohThis;
2508 XGI_OH *poh_freed;
2509 XGI_OH *poh_prev;
2510 XGI_OH *poh_next;
2511 unsigned long ulUpper;
2512 unsigned long ulLower;
2513 int foundNode = 0;
2514
2515 poh_freed = XGIfb_heap.oh_used.poh_next;
2516
2517 while(poh_freed != &XGIfb_heap.oh_used) {
2518 if(poh_freed->offset == base) {
2519 foundNode = 1;
2520 break;
2521 }
2522
2523 poh_freed = poh_freed->poh_next;
2524 }
2525
2526 if (!foundNode) return (NULL);
2527
2528 XGIfb_heap.max_freesize += poh_freed->size;
2529
2530 poh_prev = poh_next = NULL;
2531 ulUpper = poh_freed->offset + poh_freed->size;
2532 ulLower = poh_freed->offset;
2533
2534 pohThis = XGIfb_heap.oh_free.poh_next;
2535
2536 while (pohThis != &XGIfb_heap.oh_free) {
2537 if (pohThis->offset == ulUpper) {
2538 poh_next = pohThis;
2539 }
2540 else if ((pohThis->offset + pohThis->size) ==
2541 ulLower) {
2542 poh_prev = pohThis;
2543 }
2544 pohThis = pohThis->poh_next;
2545 }
2546
2547 XGIfb_delete_node(poh_freed);
2548
2549 if (poh_prev && poh_next) {
2550 poh_prev->size += (poh_freed->size + poh_next->size);
2551 XGIfb_delete_node(poh_next);
2552 XGIfb_free_node(poh_freed);
2553 XGIfb_free_node(poh_next);
2554 return (poh_prev);
2555 }
2556
2557 if (poh_prev) {
2558 poh_prev->size += poh_freed->size;
2559 XGIfb_free_node(poh_freed);
2560 return (poh_prev);
2561 }
2562
2563 if (poh_next) {
2564 poh_next->size += poh_freed->size;
2565 poh_next->offset = poh_freed->offset;
2566 XGIfb_free_node(poh_freed);
2567 return (poh_next);
2568 }
2569
2570 XGIfb_insert_node(&XGIfb_heap.oh_free, poh_freed);
2571
2572 return (poh_freed);
2573}
2574
2575static void XGIfb_free_node(XGI_OH *poh)
2576{
2577 if(poh == NULL) return;
2578
2579 poh->poh_next = XGIfb_heap.poh_freelist;
2580 XGIfb_heap.poh_freelist = poh;
2581
2582}
2583
2584void XGI_malloc(struct XGI_memreq *req)
2585{
2586 XGI_OH *poh;
2587
2588 poh = XGIfb_poh_allocate(req->size);
2589
2590 if(poh == NULL) {
2591 req->offset = 0;
2592 req->size = 0;
2593 DPRINTK("XGIfb: Video RAM allocation failed\n");
2594 } else {
2595 DPRINTK("XGIfb: Video RAM allocation succeeded: 0x%p\n",
2596 (char *) (poh->offset + (unsigned long) xgi_video_info.video_vbase));
2597
2598 req->offset = poh->offset;
2599 req->size = poh->size;
2600 }
2601
2602}
2603
2604void XGI_free(unsigned long base)
2605{
2606 XGI_OH *poh;
2607
2608 poh = XGIfb_poh_free(base);
2609
2610 if(poh == NULL) {
2611 DPRINTK("XGIfb: XGIfb_poh_free() failed at base 0x%x\n",
2612 (unsigned int) base);
2613 }
2614}
2615
2616/* --------------------- SetMode routines ------------------------- */
2617
2618static void XGIfb_pre_setmode(void)
2619{
2620 u8 cr30 = 0, cr31 = 0;
2621
2622 inXGIIDXREG(XGICR, 0x31, cr31);
2623 cr31 &= ~0x60;
2624
2625 switch (xgi_video_info.disp_state & DISPTYPE_DISP2) {
2626 case DISPTYPE_CRT2:
2627 cr30 = (XGI_VB_OUTPUT_CRT2 | XGI_SIMULTANEOUS_VIEW_ENABLE);
2628 cr31 |= XGI_DRIVER_MODE;
2629 break;
2630 case DISPTYPE_LCD:
2631 cr30 = (XGI_VB_OUTPUT_LCD | XGI_SIMULTANEOUS_VIEW_ENABLE);
2632 cr31 |= XGI_DRIVER_MODE;
2633 break;
2634 case DISPTYPE_TV:
2635 if (xgi_video_info.TV_type == TVMODE_HIVISION)
2636 cr30 = (XGI_VB_OUTPUT_HIVISION | XGI_SIMULTANEOUS_VIEW_ENABLE);
2637 else if (xgi_video_info.TV_plug == TVPLUG_SVIDEO)
2638 cr30 = (XGI_VB_OUTPUT_SVIDEO | XGI_SIMULTANEOUS_VIEW_ENABLE);
2639 else if (xgi_video_info.TV_plug == TVPLUG_COMPOSITE)
2640 cr30 = (XGI_VB_OUTPUT_COMPOSITE | XGI_SIMULTANEOUS_VIEW_ENABLE);
2641 else if (xgi_video_info.TV_plug == TVPLUG_SCART)
2642 cr30 = (XGI_VB_OUTPUT_SCART | XGI_SIMULTANEOUS_VIEW_ENABLE);
2643 cr31 |= XGI_DRIVER_MODE;
2644
2645 if (XGIfb_tvmode == 1 || xgi_video_info.TV_type == TVMODE_PAL)
2646 cr31 |= 0x01;
2647 else
2648 cr31 &= ~0x01;
2649 break;
2650 default: /* disable CRT2 */
2651 cr30 = 0x00;
2652 cr31 |= (XGI_DRIVER_MODE | XGI_VB_OUTPUT_DISABLE);
2653 }
2654
2655 outXGIIDXREG(XGICR, IND_XGI_SCRATCH_REG_CR30, cr30);
2656 outXGIIDXREG(XGICR, IND_XGI_SCRATCH_REG_CR31, cr31);
2657 outXGIIDXREG(XGICR, IND_XGI_SCRATCH_REG_CR33, (XGIfb_rate_idx & 0x0F));
2658
2659 if(xgi_video_info.accel) XGIfb_syncaccel();
2660
2661
2662}
2663
2664static void XGIfb_post_setmode(void)
2665{
2666 u8 reg;
2667 BOOLEAN doit = TRUE;
2668#if 0 /* TW: Wrong: Is not in MMIO space, but in RAM */
2669 /* Backup mode number to MMIO space */
2670 if(xgi_video_info.mmio_vbase) {
2671 *(volatile u8 *)(((u8*)xgi_video_info.mmio_vbase) + 0x449) = (unsigned char)XGIfb_mode_no;
2672 }
2673#endif
2674/* outXGIIDXREG(XGISR,IND_XGI_PASSWORD,XGI_PASSWORD);
2675 outXGIIDXREG(XGICR,0x13,0x00);
2676 setXGIIDXREG(XGISR,0x0E,0xF0,0x01);
2677*test**/
2678 if (xgi_video_info.video_bpp == 8) {
2679 /* TW: We can't switch off CRT1 on LVDS/Chrontel in 8bpp Modes */
2680 if ((xgi_video_info.hasVB == HASVB_LVDS) || (xgi_video_info.hasVB == HASVB_LVDS_CHRONTEL)) {
2681 doit = FALSE;
2682 }
2683 /* TW: We can't switch off CRT1 on 301B-DH in 8bpp Modes if using LCD */
2684 if (xgi_video_info.disp_state & DISPTYPE_LCD) {
2685 doit = FALSE;
2686 }
2687 }
2688
2689 /* TW: We can't switch off CRT1 if bridge is in slave mode */
2690 if(xgi_video_info.hasVB != HASVB_NONE) {
2691 inXGIIDXREG(XGIPART1, 0x00, reg);
2692
2693
2694 if((reg & 0x50) == 0x10) {
2695 doit = FALSE;
2696 }
2697
2698 } else XGIfb_crt1off = 0;
2699
2700 inXGIIDXREG(XGICR, 0x17, reg);
2701 if((XGIfb_crt1off) && (doit))
2702 reg &= ~0x80;
2703 else
2704 reg |= 0x80;
2705 outXGIIDXREG(XGICR, 0x17, reg);
2706
2707 andXGIIDXREG(XGISR, IND_XGI_RAMDAC_CONTROL, ~0x04);
2708
2709 if((xgi_video_info.disp_state & DISPTYPE_TV) && (xgi_video_info.hasVB == HASVB_301)) {
2710
2711 inXGIIDXREG(XGIPART4, 0x01, reg);
2712
2713 if(reg < 0xB0) { /* Set filter for XGI301 */
2714
2715 switch (xgi_video_info.video_width) {
2716 case 320:
2717 filter_tb = (xgi_video_info.TV_type == TVMODE_NTSC) ? 4 : 12;
2718 break;
2719 case 640:
2720 filter_tb = (xgi_video_info.TV_type == TVMODE_NTSC) ? 5 : 13;
2721 break;
2722 case 720:
2723 filter_tb = (xgi_video_info.TV_type == TVMODE_NTSC) ? 6 : 14;
2724 break;
2725 case 800:
2726 filter_tb = (xgi_video_info.TV_type == TVMODE_NTSC) ? 7 : 15;
2727 break;
2728 default:
2729 filter = -1;
2730 break;
2731 }
2732
2733 orXGIIDXREG(XGIPART1, XGIfb_CRT2_write_enable, 0x01);
2734
2735 if(xgi_video_info.TV_type == TVMODE_NTSC) {
2736
2737 andXGIIDXREG(XGIPART2, 0x3a, 0x1f);
2738
2739 if (xgi_video_info.TV_plug == TVPLUG_SVIDEO) {
2740
2741 andXGIIDXREG(XGIPART2, 0x30, 0xdf);
2742
2743 } else if (xgi_video_info.TV_plug == TVPLUG_COMPOSITE) {
2744
2745 orXGIIDXREG(XGIPART2, 0x30, 0x20);
2746
2747 switch (xgi_video_info.video_width) {
2748 case 640:
2749 outXGIIDXREG(XGIPART2, 0x35, 0xEB);
2750 outXGIIDXREG(XGIPART2, 0x36, 0x04);
2751 outXGIIDXREG(XGIPART2, 0x37, 0x25);
2752 outXGIIDXREG(XGIPART2, 0x38, 0x18);
2753 break;
2754 case 720:
2755 outXGIIDXREG(XGIPART2, 0x35, 0xEE);
2756 outXGIIDXREG(XGIPART2, 0x36, 0x0C);
2757 outXGIIDXREG(XGIPART2, 0x37, 0x22);
2758 outXGIIDXREG(XGIPART2, 0x38, 0x08);
2759 break;
2760 case 800:
2761 outXGIIDXREG(XGIPART2, 0x35, 0xEB);
2762 outXGIIDXREG(XGIPART2, 0x36, 0x15);
2763 outXGIIDXREG(XGIPART2, 0x37, 0x25);
2764 outXGIIDXREG(XGIPART2, 0x38, 0xF6);
2765 break;
2766 }
2767 }
2768
2769 } else if(xgi_video_info.TV_type == TVMODE_PAL) {
2770
2771 andXGIIDXREG(XGIPART2, 0x3A, 0x1F);
2772
2773 if (xgi_video_info.TV_plug == TVPLUG_SVIDEO) {
2774
2775 andXGIIDXREG(XGIPART2, 0x30, 0xDF);
2776
2777 } else if (xgi_video_info.TV_plug == TVPLUG_COMPOSITE) {
2778
2779 orXGIIDXREG(XGIPART2, 0x30, 0x20);
2780
2781 switch (xgi_video_info.video_width) {
2782 case 640:
2783 outXGIIDXREG(XGIPART2, 0x35, 0xF1);
2784 outXGIIDXREG(XGIPART2, 0x36, 0xF7);
2785 outXGIIDXREG(XGIPART2, 0x37, 0x1F);
2786 outXGIIDXREG(XGIPART2, 0x38, 0x32);
2787 break;
2788 case 720:
2789 outXGIIDXREG(XGIPART2, 0x35, 0xF3);
2790 outXGIIDXREG(XGIPART2, 0x36, 0x00);
2791 outXGIIDXREG(XGIPART2, 0x37, 0x1D);
2792 outXGIIDXREG(XGIPART2, 0x38, 0x20);
2793 break;
2794 case 800:
2795 outXGIIDXREG(XGIPART2, 0x35, 0xFC);
2796 outXGIIDXREG(XGIPART2, 0x36, 0xFB);
2797 outXGIIDXREG(XGIPART2, 0x37, 0x14);
2798 outXGIIDXREG(XGIPART2, 0x38, 0x2A);
2799 break;
2800 }
2801 }
2802 }
2803
2804 if ((filter >= 0) && (filter <=7)) {
2805 DPRINTK("FilterTable[%d]-%d: %02x %02x %02x %02x\n", filter_tb, filter,
2806 XGI_TV_filter[filter_tb].filter[filter][0],
2807 XGI_TV_filter[filter_tb].filter[filter][1],
2808 XGI_TV_filter[filter_tb].filter[filter][2],
2809 XGI_TV_filter[filter_tb].filter[filter][3]
2810 );
2811 outXGIIDXREG(XGIPART2, 0x35, (XGI_TV_filter[filter_tb].filter[filter][0]));
2812 outXGIIDXREG(XGIPART2, 0x36, (XGI_TV_filter[filter_tb].filter[filter][1]));
2813 outXGIIDXREG(XGIPART2, 0x37, (XGI_TV_filter[filter_tb].filter[filter][2]));
2814 outXGIIDXREG(XGIPART2, 0x38, (XGI_TV_filter[filter_tb].filter[filter][3]));
2815 }
2816
2817 }
2818
2819 }
2820
2821}
2822
2823#ifndef MODULE
2824XGIINITSTATIC int __init XGIfb_setup(char *options)
2825{
2826 char *this_opt;
2827
2828
2829
2830 xgi_video_info.refresh_rate = 0;
2831
2832 printk(KERN_INFO "XGIfb: Options %s\n", options);
2833
2834 if (!options || !*options)
2835 return 0;
2836
2837 while((this_opt = strsep(&options, ",")) != NULL) {
2838
2839 if (!*this_opt) continue;
2840
2841 if (!strncmp(this_opt, "mode:", 5)) {
2842 XGIfb_search_mode(this_opt + 5);
2843 } else if (!strncmp(this_opt, "vesa:", 5)) {
2844 XGIfb_search_vesamode(simple_strtoul(this_opt + 5, NULL, 0));
2845 } else if (!strncmp(this_opt, "mode:", 5)) {
2846 XGIfb_search_mode(this_opt + 5);
2847 } else if (!strncmp(this_opt, "vesa:", 5)) {
2848 XGIfb_search_vesamode(simple_strtoul(this_opt + 5, NULL, 0));
2849 } else if (!strncmp(this_opt, "vrate:", 6)) {
2850 xgi_video_info.refresh_rate = simple_strtoul(this_opt + 6, NULL, 0);
2851 } else if (!strncmp(this_opt, "rate:", 5)) {
2852 xgi_video_info.refresh_rate = simple_strtoul(this_opt + 5, NULL, 0);
2853 } else if (!strncmp(this_opt, "off", 3)) {
2854 XGIfb_off = 1;
2855 } else if (!strncmp(this_opt, "crt1off", 7)) {
2856 XGIfb_crt1off = 1;
2857 } else if (!strncmp(this_opt, "filter:", 7)) {
2858 filter = (int)simple_strtoul(this_opt + 7, NULL, 0);
2859 } else if (!strncmp(this_opt, "forcecrt2type:", 14)) {
2860 XGIfb_search_crt2type(this_opt + 14);
2861 } else if (!strncmp(this_opt, "forcecrt1:", 10)) {
2862 XGIfb_forcecrt1 = (int)simple_strtoul(this_opt + 10, NULL, 0);
2863 } else if (!strncmp(this_opt, "tvmode:",7)) {
2864 XGIfb_search_tvstd(this_opt + 7);
2865 } else if (!strncmp(this_opt, "tvstandard:",11)) {
2866 XGIfb_search_tvstd(this_opt + 7);
2867 } else if (!strncmp(this_opt, "mem:",4)) {
2868 XGIfb_mem = simple_strtoul(this_opt + 4, NULL, 0);
2869 } else if (!strncmp(this_opt, "dstn", 4)) {
2870 enable_dstn = 1;
2871 /* TW: DSTN overrules forcecrt2type */
2872 XGIfb_crt2type = DISPTYPE_LCD;
2873 } else if (!strncmp(this_opt, "queuemode:", 10)) {
2874 XGIfb_search_queuemode(this_opt + 10);
2875 } else if (!strncmp(this_opt, "pdc:", 4)) {
2876 XGIfb_pdc = simple_strtoul(this_opt + 4, NULL, 0);
2877 if(XGIfb_pdc & ~0x3c) {
2878 printk(KERN_INFO "XGIfb: Illegal pdc parameter\n");
2879 XGIfb_pdc = 0;
2880 }
2881 } else if (!strncmp(this_opt, "noaccel", 7)) {
2882 XGIfb_accel = 0;
2883 } else if (!strncmp(this_opt, "noypan", 6)) {
2884 XGIfb_ypan = 0;
2885 } else if (!strncmp(this_opt, "userom:", 7)) {
2886 XGIfb_userom = (int)simple_strtoul(this_opt + 7, NULL, 0);
2887// } else if (!strncmp(this_opt, "useoem:", 7)) {
2888// XGIfb_useoem = (int)simple_strtoul(this_opt + 7, NULL, 0);
2889 } else {
2890 XGIfb_search_mode(this_opt);
2891// printk(KERN_INFO "XGIfb: Invalid option %s\n", this_opt);
2892 }
2893
2894 /* TW: Acceleration only with MMIO mode */
2895 if((XGIfb_queuemode != -1) && (XGIfb_queuemode != MMIO_CMD)) {
2896 XGIfb_ypan = 0;
2897 XGIfb_accel = 0;
2898 }
2899 /* TW: Panning only with acceleration */
2900 if(XGIfb_accel == 0) XGIfb_ypan = 0;
2901
2902 }
2903 printk("\nxgifb: outa xgifb_setup 3450");
2904 return 0;
2905}
2906#endif
2907
2908static unsigned char VBIOS_BUF[65535];
2909
2910unsigned char* attempt_map_rom(struct pci_dev *dev,void *copy_address)
2911{
2912 u32 rom_size = 0;
2913 u32 rom_address = 0;
2914 int j;
2915
2916 /* Get the size of the expansion rom */
2917 pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0xFFFFFFFF);
2918 pci_read_config_dword(dev, PCI_ROM_ADDRESS, &rom_size);
2919 if ((rom_size & 0x01) == 0)
2920 {
2921 printk("No ROM\n");
2922 return NULL;
2923 }
2924
2925 rom_size &= 0xFFFFF800;
2926 rom_size = (~rom_size)+1;
2927
2928 rom_address = pci_resource_start(dev, 0);
2929 if (rom_address == 0 || rom_address == 0xFFFFFFF0)
2930 {
2931 printk("No suitable rom address found\n"); return NULL;
2932 }
2933
2934 printk("ROM Size is %dK, Address is %x\n", rom_size/1024, rom_address);
2935
2936 /* Map ROM */
2937 pci_write_config_dword(dev, PCI_ROM_ADDRESS, rom_address | PCI_ROM_ADDRESS_ENABLE);
2938
2939 /* memcpy(copy_address, rom_address, rom_size); */
2940 {
2941 unsigned char *virt_addr = ioremap(rom_address, 0x8000000);
2942
2943 unsigned char *from = (unsigned char *)virt_addr;
2944 unsigned char *to = (unsigned char *)copy_address;
2945 for (j=0; j<65536 /*rom_size*/; j++) *to++ = *from++;
2946 }
2947
2948 pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0);
2949
2950 printk("Copy is done\n");
2951
2952 return copy_address;
2953}
2954
2955int __devinit xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2956{
2957 u16 reg16;
2958 u8 reg, reg1;
2959 u8 CR48,CR38;
2960 if (XGIfb_off)
2961 return -ENXIO;
2962
2963 XGIfb_registered = 0;
2964
2965 memset(&XGIhw_ext, 0, sizeof(HW_DEVICE_EXTENSION));
2966#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,3))
2967 fb_info = framebuffer_alloc(sizeof(struct fb_info), &pdev->dev);
2968 if(!fb_info) return -ENOMEM;
2969#else
2970 XGI_fb_info = kmalloc( sizeof(struct fb_info), GFP_KERNEL);
2971 if(!XGI_fb_info) return -ENOMEM;
2972 memset(XGI_fb_info, 0, sizeof(struct fb_info));
2973#endif
2974
2975 xgi_video_info.chip_id = pdev->device;
2976 pci_read_config_byte(pdev, PCI_REVISION_ID,&xgi_video_info.revision_id);
2977 pci_read_config_word(pdev, PCI_COMMAND, &reg16);
2978 XGIhw_ext.jChipRevision = xgi_video_info.revision_id;
2979 XGIvga_enabled = reg16 & 0x01;
2980
2981 xgi_video_info.pcibus = pdev->bus->number;
2982 xgi_video_info.pcislot = PCI_SLOT(pdev->devfn);
2983 xgi_video_info.pcifunc = PCI_FUNC(pdev->devfn);
2984 xgi_video_info.subsysvendor = pdev->subsystem_vendor;
2985 xgi_video_info.subsysdevice = pdev->subsystem_device;
2986
2987 xgi_video_info.video_base = pci_resource_start(pdev, 0);
2988 xgi_video_info.mmio_base = pci_resource_start(pdev, 1);
2989 XGIfb_mmio_size = pci_resource_len(pdev, 1);
2990 xgi_video_info.vga_base = pci_resource_start(pdev, 2) + 0x30;
2991 XGIhw_ext.pjIOAddress = (PUCHAR)xgi_video_info.vga_base;
2992 //XGI_Pr.RelIO = ioremap(pci_resource_start(pdev, 2), 128) + 0x30;
2993 printk("XGIfb: Relocate IO address: %lx [%08lx] \n", (unsigned long)pci_resource_start(pdev, 2), XGI_Pr.RelIO);
2994
2995 if (pci_enable_device(pdev))
2996 return -EIO;
2997
2998 XGIRegInit(&XGI_Pr, (ULONG)XGIhw_ext.pjIOAddress);
2999
3000 outXGIIDXREG(XGISR, IND_XGI_PASSWORD, XGI_PASSWORD);
3001 inXGIIDXREG(XGISR, IND_XGI_PASSWORD, reg1);
3002
3003 if(reg1 != 0xa1) /*I/O error */
3004 {
3005 printk("\nXGIfb: I/O error!!!");
3006 return -EIO;
3007 }
3008
3009 switch (xgi_video_info.chip_id) {
3010 case PCI_DEVICE_ID_XG_20:
3011 orXGIIDXREG(XGICR, Index_CR_GPIO_Reg3, GPIOG_EN);
3012 inXGIIDXREG(XGICR, Index_CR_GPIO_Reg1, CR48);
3013 if (CR48&GPIOG_READ)
3014 xgi_video_info.chip = XG21;
3015 else
3016 xgi_video_info.chip = XG20;
3017 XGIfb_hwcursor_size = HW_CURSOR_AREA_SIZE_315 * 2;
3018 XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315;
3019 break;
3020 case PCI_DEVICE_ID_XG_40:
3021 xgi_video_info.chip = XG40;
3022 XGIfb_hwcursor_size = HW_CURSOR_AREA_SIZE_315 * 2;
3023 XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315;
3024 break;
3025 case PCI_DEVICE_ID_XG_41:
3026 xgi_video_info.chip = XG41;
3027 XGIfb_hwcursor_size = HW_CURSOR_AREA_SIZE_315 * 2;
3028 XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315;
3029 break;
3030 case PCI_DEVICE_ID_XG_42:
3031 xgi_video_info.chip = XG42;
3032 XGIfb_hwcursor_size = HW_CURSOR_AREA_SIZE_315 * 2;
3033 XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315;
3034 break;
3035 case PCI_DEVICE_ID_XG_27:
3036 xgi_video_info.chip = XG27;
3037 XGIfb_hwcursor_size = HW_CURSOR_AREA_SIZE_315 * 2;
3038 XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315;
3039 break;
3040 default:
3041 return -ENODEV;
3042 }
3043
3044 printk("XGIfb:chipid = %x\n",xgi_video_info.chip);
3045 XGIhw_ext.jChipType = xgi_video_info.chip;
3046
3047 switch (xgi_video_info.chip) {
3048 case XG40:
3049 case XG41:
3050 case XG42:
3051 case XG45:
3052 case XG20:
3053 case XG21:
3054 case XG27:
3055 XGIhw_ext.bIntegratedMMEnabled = TRUE;
3056 break;
3057
3058 default:
3059 break;
3060 }
3061
3062
3063 XGIhw_ext.pDevice = NULL;
3064 if ((xgi_video_info.chip == XG21) || (XGIfb_userom))
3065 {
3066 XGIhw_ext.pjVirtualRomBase = attempt_map_rom(pdev, VBIOS_BUF);
3067
3068 if(XGIhw_ext.pjVirtualRomBase)
3069 printk(KERN_INFO "XGIfb: Video ROM found and mapped to %p\n",XGIhw_ext.pjVirtualRomBase);
3070 else
3071 printk(KERN_INFO "XGIfb: Video ROM not found\n");
3072 } else {
3073 XGIhw_ext.pjVirtualRomBase = NULL;
3074 printk(KERN_INFO "XGIfb: Video ROM usage disabled\n");
3075 }
3076 XGIhw_ext.pjCustomizedROMImage = NULL;
3077 XGIhw_ext.bSkipDramSizing = 0;
3078 XGIhw_ext.pQueryVGAConfigSpace = &XGIfb_query_VGA_config_space;
3079// XGIhw_ext.pQueryNorthBridgeSpace = &XGIfb_query_north_bridge_space;
3080 strcpy(XGIhw_ext.szVBIOSVer, "0.84");
3081
3082
3083 XGIhw_ext.pSR = vmalloc(sizeof(XGI_DSReg) * SR_BUFFER_SIZE);
3084 if (XGIhw_ext.pSR == NULL)
3085 {
3086 printk(KERN_ERR "XGIfb: Fatal error: Allocating SRReg space failed.\n");
3087 return -ENODEV;
3088 }
3089 XGIhw_ext.pSR[0].jIdx = XGIhw_ext.pSR[0].jVal = 0xFF;
3090
3091 XGIhw_ext.pCR = vmalloc(sizeof(XGI_DSReg) * CR_BUFFER_SIZE);
3092 if (XGIhw_ext.pCR == NULL)
3093 {
3094 vfree(XGIhw_ext.pSR);
3095 printk(KERN_ERR "XGIfb: Fatal error: Allocating CRReg space failed.\n");
3096 return -ENODEV;
3097 }
3098 XGIhw_ext.pCR[0].jIdx = XGIhw_ext.pCR[0].jVal = 0xFF;
3099
3100
3101
3102
3103 if (!XGIvga_enabled)
3104 {
3105 /* Mapping Max FB Size for 315 Init */
3106 XGIhw_ext.pjVideoMemoryAddress = ioremap(xgi_video_info.video_base, 0x10000000);
3107 if((xgifb_mode_idx < 0) || ((XGIbios_mode[xgifb_mode_idx].mode_no) != 0xFF))
3108 {
3109#ifdef LINUXBIOS
3110 printk("XGIfb: XGIInit() ...");
3111 /* XGIInitNewt for LINUXBIOS only */
3112 if(XGIInitNew(&XGIhw_ext))
3113 {
3114 printk("OK\n");
3115 }
3116 else
3117 {
3118 printk("Fail\n");
3119 }
3120#endif
3121
3122 outXGIIDXREG(XGISR, IND_XGI_PASSWORD, XGI_PASSWORD);
3123
3124
3125 }
3126 }
3127#ifdef LINUXBIOS
3128 else
3129 {
3130 XGIhw_ext.pjVideoMemoryAddress = ioremap(xgi_video_info.video_base, 0x10000000);
3131 if((xgifb_mode_idx < 0) || ((XGIbios_mode[xgifb_mode_idx].mode_no) != 0xFF))
3132 {
3133
3134 outXGIIDXREG(XGISR, IND_XGI_PASSWORD, XGI_PASSWORD);
3135
3136 // yilin Because no VBIOS DRAM Sizing, Dram size will error.
3137 // Set SR13 ,14 temporarily for UDtech
3138 outXGIIDXREG(XGISR, 0x13, 0x45);
3139 outXGIIDXREG(XGISR, 0x14, 0x51);
3140
3141
3142 }
3143 }
3144#endif
3145 if (XGIfb_get_dram_size())
3146 {
3147 vfree(XGIhw_ext.pSR);
3148 vfree(XGIhw_ext.pCR);
3149 printk(KERN_INFO "XGIfb: Fatal error: Unable to determine RAM size.\n");
3150 return -ENODEV;
3151 }
3152
3153
3154
3155 if((xgifb_mode_idx < 0) || ((XGIbios_mode[xgifb_mode_idx].mode_no) != 0xFF))
3156 {
3157 /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */
3158 orXGIIDXREG(XGISR, IND_XGI_PCI_ADDRESS_SET, (XGI_PCI_ADDR_ENABLE | XGI_MEM_MAP_IO_ENABLE));
3159 /* Enable 2D accelerator engine */
3160 orXGIIDXREG(XGISR, IND_XGI_MODULE_ENABLE, XGI_ENABLE_2D);
3161 }
3162
3163 XGIhw_ext.ulVideoMemorySize = xgi_video_info.video_size;
3164
3165 if (!request_mem_region(xgi_video_info.video_base, xgi_video_info.video_size, "XGIfb FB"))
3166 { printk("unable request memory size %x",xgi_video_info.video_size);
3167 printk(KERN_ERR "XGIfb: Fatal error: Unable to reserve frame buffer memory\n");
3168 printk(KERN_ERR "XGIfb: Is there another framebuffer driver active?\n");
3169 vfree(XGIhw_ext.pSR);
3170 vfree(XGIhw_ext.pCR);
3171 return -ENODEV;
3172 }
3173
3174 if (!request_mem_region(xgi_video_info.mmio_base, XGIfb_mmio_size, "XGIfb MMIO"))
3175 {
3176 printk(KERN_ERR "XGIfb: Fatal error: Unable to reserve MMIO region\n");
3177 release_mem_region(xgi_video_info.video_base, xgi_video_info.video_size);
3178 vfree(XGIhw_ext.pSR);
3179 vfree(XGIhw_ext.pCR);
3180 return -ENODEV;
3181 }
3182
3183 xgi_video_info.video_vbase = XGIhw_ext.pjVideoMemoryAddress =
3184 ioremap(xgi_video_info.video_base, xgi_video_info.video_size);
3185 xgi_video_info.mmio_vbase = ioremap(xgi_video_info.mmio_base, XGIfb_mmio_size);
3186
3187 printk(KERN_INFO "XGIfb: Framebuffer at 0x%lx, mapped to 0x%p, size %dk\n",
3188 xgi_video_info.video_base, xgi_video_info.video_vbase,xgi_video_info.video_size / 1024);
3189
3190 printk(KERN_INFO "XGIfb: MMIO at 0x%lx, mapped to 0x%p, size %ldk\n",
3191 xgi_video_info.mmio_base, xgi_video_info.mmio_vbase,XGIfb_mmio_size / 1024);
3192 printk("XGIfb: XGIInitNew() ...");
3193 if(XGIInitNew(&XGIhw_ext))
3194 {
3195 printk("OK\n");
3196 }
3197 else
3198 {
3199 printk("Fail\n");
3200 }
3201
3202 if(XGIfb_heap_init())
3203 {
3204 printk(KERN_WARNING "XGIfb: Failed to initialize offscreen memory heap\n");
3205 }
3206
3207
3208 xgi_video_info.mtrr = (unsigned int) 0;
3209
3210 if((xgifb_mode_idx < 0) || ((XGIbios_mode[xgifb_mode_idx].mode_no) != 0xFF))
3211 {
3212 xgi_video_info.hasVB = HASVB_NONE;
3213 if((xgi_video_info.chip == XG20)||(xgi_video_info.chip == XG27))
3214 xgi_video_info.hasVB = HASVB_NONE;
3215 else if(xgi_video_info.chip == XG21) {
3216 inXGIIDXREG(XGICR,0x38,CR38);
3217 if ((CR38&0xE0) == 0xC0) {
3218 xgi_video_info.disp_state = DISPTYPE_LCD;
3219 if (!XGIfb_GetXG21LVDSData()) {
3220 int m;
3221 for (m=0; m < sizeof(XGI21_LCDCapList)/sizeof(XGI21_LVDSCapStruct); m++) {
3222 if ((XGI21_LCDCapList[m].LVDSHDE == XGIbios_mode[xgifb_mode_idx].xres) &&
3223 (XGI21_LCDCapList[m].LVDSVDE == XGIbios_mode[xgifb_mode_idx].yres)) {
3224 XGINew_SetReg1( XGI_Pr.P3d4 , 0x36, m) ;
3225 }
3226 }
3227 }
3228 }
3229 else if ((CR38&0xE0) == 0x60)
3230 xgi_video_info.hasVB = HASVB_CHRONTEL ;
3231 else
3232 xgi_video_info.hasVB = HASVB_NONE;
3233 }
3234 else
3235 XGIfb_get_VB_type();
3236
3237 XGIhw_ext.ujVBChipID = VB_CHIP_UNKNOWN;
3238
3239 XGIhw_ext.ulExternalChip = 0;
3240
3241 switch (xgi_video_info.hasVB) {
3242 case HASVB_301:
3243 inXGIIDXREG(XGIPART4, 0x01, reg);
3244 if (reg >= 0xE0) {
3245 XGIhw_ext.ujVBChipID = VB_CHIP_302LV;
3246 printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n",reg);
3247 } else if (reg >= 0xD0) {
3248 XGIhw_ext.ujVBChipID = VB_CHIP_301LV;
3249 printk(KERN_INFO "XGIfb: XGI301LV bridge detected (revision 0x%02x)\n",reg);
3250 }
3251 /* else if (reg >= 0xB0) {
3252 XGIhw_ext.ujVBChipID = VB_CHIP_301B;
3253 inXGIIDXREG(XGIPART4,0x23,reg1);
3254 printk("XGIfb: XGI301B bridge detected\n");
3255 }*/
3256 else {
3257 XGIhw_ext.ujVBChipID = VB_CHIP_301;
3258 printk("XGIfb: XGI301 bridge detected\n");
3259 }
3260 break;
3261 case HASVB_302:
3262 inXGIIDXREG(XGIPART4, 0x01, reg);
3263 if (reg >= 0xE0) {
3264 XGIhw_ext.ujVBChipID = VB_CHIP_302LV;
3265 printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n",reg);
3266 } else if (reg >= 0xD0) {
3267 XGIhw_ext.ujVBChipID = VB_CHIP_301LV;
3268 printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n",reg);
3269 } else if (reg >= 0xB0) {
3270 inXGIIDXREG(XGIPART4,0x23,reg1);
3271
3272 XGIhw_ext.ujVBChipID = VB_CHIP_302B;
3273
3274 } else {
3275 XGIhw_ext.ujVBChipID = VB_CHIP_302;
3276 printk(KERN_INFO "XGIfb: XGI302 bridge detected\n");
3277 }
3278 break;
3279 case HASVB_LVDS:
3280 XGIhw_ext.ulExternalChip = 0x1;
3281 printk(KERN_INFO "XGIfb: LVDS transmitter detected\n");
3282 break;
3283 case HASVB_TRUMPION:
3284 XGIhw_ext.ulExternalChip = 0x2;
3285 printk(KERN_INFO "XGIfb: Trumpion Zurac LVDS scaler detected\n");
3286 break;
3287 case HASVB_CHRONTEL:
3288 XGIhw_ext.ulExternalChip = 0x4;
3289 printk(KERN_INFO "XGIfb: Chrontel TV encoder detected\n");
3290 break;
3291 case HASVB_LVDS_CHRONTEL:
3292 XGIhw_ext.ulExternalChip = 0x5;
3293 printk(KERN_INFO "XGIfb: LVDS transmitter and Chrontel TV encoder detected\n");
3294 break;
3295 default:
3296 printk(KERN_INFO "XGIfb: No or unknown bridge type detected\n");
3297 break;
3298 }
3299
3300 if (xgi_video_info.hasVB != HASVB_NONE) {
3301 XGIfb_detect_VB();
3302 }
3303
3304 if (xgi_video_info.disp_state & DISPTYPE_DISP2) {
3305 if (XGIfb_crt1off)
3306 xgi_video_info.disp_state |= DISPMODE_SINGLE;
3307 else
3308 xgi_video_info.disp_state |= (DISPMODE_MIRROR | DISPTYPE_CRT1);
3309 } else {
3310 xgi_video_info.disp_state = DISPMODE_SINGLE | DISPTYPE_CRT1;
3311 }
3312
3313 if (xgi_video_info.disp_state & DISPTYPE_LCD) {
3314 if (!enable_dstn) {
3315 inXGIIDXREG(XGICR, IND_XGI_LCD_PANEL, reg);
3316 reg &= 0x0f;
3317 XGIhw_ext.ulCRT2LCDType = XGI310paneltype[reg];
3318
3319 } else {
3320 // TW: FSTN/DSTN
3321 XGIhw_ext.ulCRT2LCDType = LCD_320x480;
3322 }
3323 }
3324
3325 XGIfb_detectedpdc = 0;
3326
3327 XGIfb_detectedlcda = 0xff;
3328#ifndef LINUXBIOS
3329
3330 /* TW: Try to find about LCDA */
3331
3332 if((XGIhw_ext.ujVBChipID == VB_CHIP_302B) ||
3333 (XGIhw_ext.ujVBChipID == VB_CHIP_301LV) ||
3334 (XGIhw_ext.ujVBChipID == VB_CHIP_302LV))
3335 {
3336 int tmp;
3337 inXGIIDXREG(XGICR,0x34,tmp);
3338 if(tmp <= 0x13)
3339 {
3340 // Currently on LCDA? (Some BIOSes leave CR38)
3341 inXGIIDXREG(XGICR,0x38,tmp);
3342 if((tmp & 0x03) == 0x03)
3343 {
3344// XGI_Pr.XGI_UseLCDA = TRUE;
3345 }else
3346 {
3347 // Currently on LCDA? (Some newer BIOSes set D0 in CR35)
3348 inXGIIDXREG(XGICR,0x35,tmp);
3349 if(tmp & 0x01)
3350 {
3351// XGI_Pr.XGI_UseLCDA = TRUE;
3352 }else
3353 {
3354 inXGIIDXREG(XGICR,0x30,tmp);
3355 if(tmp & 0x20)
3356 {
3357 inXGIIDXREG(XGIPART1,0x13,tmp);
3358 if(tmp & 0x04)
3359 {
3360// XGI_Pr.XGI_UseLCDA = TRUE;
3361 }
3362 }
3363 }
3364 }
3365 }
3366
3367 }
3368
3369
3370#endif
3371
3372 if (xgifb_mode_idx >= 0)
3373 xgifb_mode_idx = XGIfb_validate_mode(xgifb_mode_idx);
3374
3375 if (xgifb_mode_idx < 0) {
3376 switch (xgi_video_info.disp_state & DISPTYPE_DISP2) {
3377 case DISPTYPE_LCD:
3378 xgifb_mode_idx = DEFAULT_LCDMODE;
3379 if (xgi_video_info.chip == XG21)
3380 {
3381 xgifb_mode_idx = XGIfb_GetXG21DefaultLVDSModeIdx();
3382 }
3383 break;
3384 case DISPTYPE_TV:
3385 xgifb_mode_idx = DEFAULT_TVMODE;
3386 break;
3387 default:
3388 xgifb_mode_idx = DEFAULT_MODE;
3389 break;
3390 }
3391 }
3392
3393 XGIfb_mode_no = XGIbios_mode[xgifb_mode_idx].mode_no;
3394
3395
3396 if( xgi_video_info.refresh_rate == 0)
3397 xgi_video_info.refresh_rate = 60; /*yilin set default refresh rate */
3398 if(XGIfb_search_refresh_rate(xgi_video_info.refresh_rate) == 0)
3399 {
3400 XGIfb_rate_idx = XGIbios_mode[xgifb_mode_idx].rate_idx;
3401 xgi_video_info.refresh_rate = 60;
3402 }
3403
3404 xgi_video_info.video_bpp = XGIbios_mode[xgifb_mode_idx].bpp;
3405 xgi_video_info.video_vwidth = xgi_video_info.video_width = XGIbios_mode[xgifb_mode_idx].xres;
3406 xgi_video_info.video_vheight = xgi_video_info.video_height = XGIbios_mode[xgifb_mode_idx].yres;
3407 xgi_video_info.org_x = xgi_video_info.org_y = 0;
3408 xgi_video_info.video_linelength = xgi_video_info.video_width * (xgi_video_info.video_bpp >> 3);
3409 switch(xgi_video_info.video_bpp) {
3410 case 8:
3411 xgi_video_info.DstColor = 0x0000;
3412 xgi_video_info.XGI310_AccelDepth = 0x00000000;
3413 xgi_video_info.video_cmap_len = 256;
3414 break;
3415 case 16:
3416 xgi_video_info.DstColor = 0x8000;
3417 xgi_video_info.XGI310_AccelDepth = 0x00010000;
3418 xgi_video_info.video_cmap_len = 16;
3419 break;
3420 case 32:
3421 xgi_video_info.DstColor = 0xC000;
3422 xgi_video_info.XGI310_AccelDepth = 0x00020000;
3423 xgi_video_info.video_cmap_len = 16;
3424 break;
3425 default:
3426 xgi_video_info.video_cmap_len = 16;
3427 printk(KERN_INFO "XGIfb: Unsupported depth %d", xgi_video_info.video_bpp);
3428 break;
3429 }
3430
3431
3432
3433 printk(KERN_INFO "XGIfb: Default mode is %dx%dx%d (%dHz)\n",
3434 xgi_video_info.video_width, xgi_video_info.video_height, xgi_video_info.video_bpp,
3435 xgi_video_info.refresh_rate);
3436
3437 default_var.xres = default_var.xres_virtual = xgi_video_info.video_width;
3438 default_var.yres = default_var.yres_virtual = xgi_video_info.video_height;
3439 default_var.bits_per_pixel = xgi_video_info.video_bpp;
3440
3441 XGIfb_bpp_to_var(&default_var);
3442
3443 default_var.pixclock = (u32) (1000000000 /
3444 XGIfb_mode_rate_to_dclock(&XGI_Pr, &XGIhw_ext,
3445 XGIfb_mode_no, XGIfb_rate_idx));
3446
3447 if(XGIfb_mode_rate_to_ddata(&XGI_Pr, &XGIhw_ext,
3448 XGIfb_mode_no, XGIfb_rate_idx,
3449 &default_var.left_margin, &default_var.right_margin,
3450 &default_var.upper_margin, &default_var.lower_margin,
3451 &default_var.hsync_len, &default_var.vsync_len,
3452 &default_var.sync, &default_var.vmode)) {
3453
3454 if((default_var.vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
3455 default_var.yres <<= 1;
3456 default_var.yres_virtual <<= 1;
3457 } else if((default_var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
3458 default_var.pixclock >>= 1;
3459 default_var.yres >>= 1;
3460 default_var.yres_virtual >>= 1;
3461 }
3462
3463 }
3464
3465
3466#if 0
3467#ifdef XGIFB_PAN
3468 if(XGIfb_ypan) {
3469 default_var.yres_virtual =
3470 xgi_video_info.heapstart / (default_var.xres * (default_var.bits_per_pixel >> 3));
3471 if(default_var.yres_virtual <= default_var.yres) {
3472 default_var.yres_virtual = default_var.yres;
3473 }
3474 }
3475#endif
3476#endif
3477
3478
3479 xgi_video_info.accel = 0;
3480 if(XGIfb_accel) {
3481 xgi_video_info.accel = -1;
3482 default_var.accel_flags |= FB_ACCELF_TEXT;
3483 XGIfb_initaccel();
3484 }
3485
3486 fb_info->flags = FBINFO_FLAG_DEFAULT;
3487 fb_info->var = default_var;
3488 fb_info->fix = XGIfb_fix;
3489 fb_info->par = &xgi_video_info;
3490 fb_info->screen_base = xgi_video_info.video_vbase;
3491 fb_info->fbops = &XGIfb_ops;
3492 XGIfb_get_fix(&fb_info->fix, -1, fb_info);
3493 fb_info->pseudo_palette = pseudo_palette;
3494
3495 fb_alloc_cmap(&fb_info->cmap, 256 , 0);
3496
3497
3498#ifdef CONFIG_MTRR
3499 xgi_video_info.mtrr = mtrr_add((unsigned int) xgi_video_info.video_base,
3500 (unsigned int) xgi_video_info.video_size,
3501 MTRR_TYPE_WRCOMB, 1);
3502 if(xgi_video_info.mtrr) {
3503 printk(KERN_INFO "XGIfb: Added MTRRs\n");
3504 }
3505#endif
3506
3507 if(register_framebuffer(fb_info) < 0)
3508 {
3509 return -EINVAL;
3510 }
3511
3512 XGIfb_registered = 1;
3513
3514 printk(KERN_INFO "XGIfb: Installed XGIFB_GET_INFO ioctl (%x)\n", XGIFB_GET_INFO);
3515
3516/* printk(KERN_INFO "XGIfb: 2D acceleration is %s, scrolling mode %s\n",
3517 XGIfb_accel ? "enabled" : "disabled",
3518 XGIfb_ypan ? "ypan" : "redraw");
3519*/
3520 printk(KERN_INFO "fb%d: %s frame buffer device, Version %d.%d.%02d\n",
3521 fb_info->node, myid, VER_MAJOR, VER_MINOR, VER_LEVEL);
3522
3523
3524 }
3525
3526 dumpVGAReg();
3527
3528 return 0;
3529}
3530
3531
3532/*****************************************************/
3533/* PCI DEVICE HANDLING */
3534/*****************************************************/
3535
3536static void __devexit xgifb_remove(struct pci_dev *pdev)
3537{
3538 /* Unregister the framebuffer */
3539// if(xgi_video_info.registered) {
3540 unregister_framebuffer(fb_info);
3541#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,3))
3542 framebuffer_release(fb_info);
3543#else
3544 kfree(fb_info);
3545#endif
3546// }
3547
3548 pci_set_drvdata(pdev, NULL);
3549
3550};
3551
3552static struct pci_driver xgifb_driver = {
3553 .name = "xgifb",
3554 .id_table = xgifb_pci_table,
3555 .probe = xgifb_probe,
3556 .remove = __devexit_p(xgifb_remove)
3557};
3558
3559XGIINITSTATIC int __init xgifb_init(void)
3560{
3561#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8)
3562#ifndef MODULE
3563 char *option = NULL;
3564
3565 if (fb_get_options("xgifb", &option))
3566 return -ENODEV;
3567 XGIfb_setup(option);
3568#endif
3569#endif
3570 return(pci_register_driver(&xgifb_driver));
3571}
3572
3573#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8)
3574#ifndef MODULE
3575module_init(xgifb_init);
3576#endif
3577#endif
3578
3579/*****************************************************/
3580/* MODULE */
3581/*****************************************************/
3582
3583#ifdef MODULE
3584
3585static char *mode = NULL;
3586static int vesa = 0;
3587static unsigned int rate = 0;
3588static unsigned int crt1off = 1;
3589static unsigned int mem = 0;
3590static char *forcecrt2type = NULL;
3591static int forcecrt1 = -1;
3592static int pdc = -1;
3593static int pdc1 = -1;
3594static int noaccel = -1;
3595static int noypan = -1;
3596static int nomax = -1;
3597static int userom = -1;
3598static int useoem = -1;
3599static char *tvstandard = NULL;
3600static int nocrt2rate = 0;
3601static int scalelcd = -1;
3602static char *specialtiming = NULL;
3603static int lvdshl = -1;
3604static int tvxposoffset = 0, tvyposoffset = 0;
3605#if !defined(__i386__) && !defined(__x86_64__)
3606static int resetcard = 0;
3607static int videoram = 0;
3608#endif
3609
3610MODULE_DESCRIPTION("Z7 Z9 Z9S Z11 framebuffer device driver");
3611MODULE_LICENSE("GPL");
3612MODULE_AUTHOR("XGITECH , Others");
3613
3614
3615
3616module_param(mem, int, 0);
3617module_param(noaccel, int, 0);
3618module_param(noypan, int, 0);
3619module_param(nomax, int, 0);
3620module_param(userom, int, 0);
3621module_param(useoem, int, 0);
3622module_param(mode, charp, 0);
3623module_param(vesa, int, 0);
3624module_param(rate, int, 0);
3625module_param(forcecrt1, int, 0);
3626module_param(forcecrt2type, charp, 0);
3627module_param(scalelcd, int, 0);
3628module_param(pdc, int, 0);
3629module_param(pdc1, int, 0);
3630module_param(specialtiming, charp, 0);
3631module_param(lvdshl, int, 0);
3632module_param(tvstandard, charp, 0);
3633module_param(tvxposoffset, int, 0);
3634module_param(tvyposoffset, int, 0);
3635module_param(filter, int, 0);
3636module_param(nocrt2rate, int, 0);
3637#if !defined(__i386__) && !defined(__x86_64__)
3638module_param(resetcard, int, 0);
3639module_param(videoram, int, 0);
3640#endif
3641
3642
3643MODULE_PARM_DESC(mem,
3644 "\nDetermines the beginning of the video memory heap in KB. This heap is used\n"
3645 "for video RAM management for eg. DRM/DRI. On 300 series, the default depends\n"
3646 "on the amount of video RAM available. If 8MB of video RAM or less is available,\n"
3647 "the heap starts at 4096KB, if between 8 and 16MB are available at 8192KB,\n"
3648 "otherwise at 12288KB. On 315 and Xabre series, the heap size is 32KB by default.\n"
3649 "The value is to be specified without 'KB' and must match the MaxXFBMem setting\n"
3650 "for XFree86 4.x/X.org 6.7 and later.\n");
3651
3652MODULE_PARM_DESC(noaccel,
3653 "\nIf set to anything other than 0, 2D acceleration will be disabled.\n"
3654 "(default: 0)\n");
3655
3656MODULE_PARM_DESC(noypan,
3657 "\nIf set to anything other than 0, y-panning will be disabled and scrolling\n"
3658 "will be performed by redrawing the screen. (default: 0)\n");
3659
3660MODULE_PARM_DESC(nomax,
3661 "\nIf y-panning is enabled, xgifb will by default use the entire available video\n"
3662 "memory for the virtual screen in order to optimize scrolling performance. If\n"
3663 "this is set to anything other than 0, xgifb will not do this and thereby \n"
3664 "enable the user to positively specify a virtual Y size of the screen using\n"
3665 "fbset. (default: 0)\n");
3666
3667
3668
3669MODULE_PARM_DESC(mode,
3670 "\nSelects the desired default display mode in the format XxYxDepth,\n"
3671 "eg. 1024x768x16. Other formats supported include XxY-Depth and\n"
3672 "XxY-Depth@Rate. If the parameter is only one (decimal or hexadecimal)\n"
3673 "number, it will be interpreted as a VESA mode number. (default: 800x600x8)\n");
3674
3675MODULE_PARM_DESC(vesa,
3676 "\nSelects the desired default display mode by VESA defined mode number, eg.\n"
3677 "0x117 (default: 0x0103)\n");
3678
3679
3680MODULE_PARM_DESC(rate,
3681 "\nSelects the desired vertical refresh rate for CRT1 (external VGA) in Hz.\n"
3682 "If the mode is specified in the format XxY-Depth@Rate, this parameter\n"
3683 "will be ignored (default: 60)\n");
3684
3685MODULE_PARM_DESC(forcecrt1,
3686 "\nNormally, the driver autodetects whether or not CRT1 (external VGA) is \n"
3687 "connected. With this option, the detection can be overridden (1=CRT1 ON,\n"
3688 "0=CRT1 OFF) (default: [autodetected])\n");
3689
3690MODULE_PARM_DESC(forcecrt2type,
3691 "\nIf this option is omitted, the driver autodetects CRT2 output devices, such as\n"
3692 "LCD, TV or secondary VGA. With this option, this autodetection can be\n"
3693 "overridden. Possible parameters are LCD, TV, VGA or NONE. NONE disables CRT2.\n"
3694 "On systems with a SiS video bridge, parameters SVIDEO, COMPOSITE or SCART can\n"
3695 "be used instead of TV to override the TV detection. Furthermore, on systems\n"
3696 "with a SiS video bridge, SVIDEO+COMPOSITE, HIVISION, YPBPR480I, YPBPR480P,\n"
3697 "YPBPR720P and YPBPR1080I are understood. However, whether or not these work\n"
3698 "depends on the very hardware in use. (default: [autodetected])\n");
3699
3700MODULE_PARM_DESC(scalelcd,
3701 "\nSetting this to 1 will force the driver to scale the LCD image to the panel's\n"
3702 "native resolution. Setting it to 0 will disable scaling; LVDS panels will\n"
3703 "show black bars around the image, TMDS panels will probably do the scaling\n"
3704 "themselves. Default: 1 on LVDS panels, 0 on TMDS panels\n");
3705
3706MODULE_PARM_DESC(pdc,
3707 "\nThis is for manually selecting the LCD panel delay compensation. The driver\n"
3708 "should detect this correctly in most cases; however, sometimes this is not\n"
3709 "possible. If you see 'small waves' on the LCD, try setting this to 4, 32 or 24\n"
3710 "on a 300 series chipset; 6 on a 315 series chipset. If the problem persists,\n"
3711 "try other values (on 300 series: between 4 and 60 in steps of 4; on 315 series:\n"
3712 "any value from 0 to 31). (default: autodetected, if LCD is active during start)\n");
3713
3714MODULE_PARM_DESC(pdc1,
3715 "\nThis is same as pdc, but for LCD-via CRT1. Hence, this is for the 315/330\n"
3716 "series only. (default: autodetected if LCD is in LCD-via-CRT1 mode during\n"
3717 "startup) - Note: currently, this has no effect because LCD-via-CRT1 is not\n"
3718 "implemented yet.\n");
3719
3720MODULE_PARM_DESC(specialtiming,
3721 "\nPlease refer to documentation for more information on this option.\n");
3722
3723MODULE_PARM_DESC(lvdshl,
3724 "\nPlease refer to documentation for more information on this option.\n");
3725
3726MODULE_PARM_DESC(tvstandard,
3727 "\nThis allows overriding the BIOS default for the TV standard. Valid choices are\n"
3728 "pal, ntsc, palm and paln. (default: [auto; pal or ntsc only])\n");
3729
3730MODULE_PARM_DESC(tvxposoffset,
3731 "\nRelocate TV output horizontally. Possible parameters: -32 through 32.\n"
3732 "Default: 0\n");
3733
3734MODULE_PARM_DESC(tvyposoffset,
3735 "\nRelocate TV output vertically. Possible parameters: -32 through 32.\n"
3736 "Default: 0\n");
3737
3738MODULE_PARM_DESC(filter,
3739 "\nSelects TV flicker filter type (only for systems with a SiS301 video bridge).\n"
3740 "(Possible values 0-7, default: [no filter])\n");
3741
3742MODULE_PARM_DESC(nocrt2rate,
3743 "\nSetting this to 1 will force the driver to use the default refresh rate for\n"
3744 "CRT2 if CRT2 type is VGA. (default: 0, use same rate as CRT1)\n");
3745
3746
3747
3748
3749int __init xgifb_init_module(void)
3750{
3751 printk("\nXGIfb_init_module");
3752 if(mode)
3753 XGIfb_search_mode(mode);
3754 else if (vesa != -1)
3755 XGIfb_search_vesamode(vesa);
3756
3757 return(xgifb_init());
3758}
3759
3760static void __exit xgifb_remove_module(void)
3761{
3762 pci_unregister_driver(&xgifb_driver);
3763 printk(KERN_DEBUG "xgifb: Module unloaded\n");
3764}
3765
3766module_init(xgifb_init_module);
3767module_exit(xgifb_remove_module);
3768
3769#endif /* /MODULE */
3770
3771EXPORT_SYMBOL(XGI_malloc);
3772EXPORT_SYMBOL(XGI_free);
3773
diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h
new file mode 100644
index 00000000000..41bf163d4e6
--- /dev/null
+++ b/drivers/staging/xgifb/XGIfb.h
@@ -0,0 +1,215 @@
1#ifndef _LINUX_XGIFB
2#define _LINUX_XGIFB
3#include <linux/spinlock.h>
4#include <asm/ioctl.h>
5#include <asm/types.h>
6
7#define DISPTYPE_CRT1 0x00000008L
8#define DISPTYPE_CRT2 0x00000004L
9#define DISPTYPE_LCD 0x00000002L
10#define DISPTYPE_TV 0x00000001L
11#define DISPTYPE_DISP1 DISPTYPE_CRT1
12#define DISPTYPE_DISP2 (DISPTYPE_CRT2 | DISPTYPE_LCD | DISPTYPE_TV)
13#define DISPMODE_SINGLE 0x00000020L
14#define DISPMODE_MIRROR 0x00000010L
15#define DISPMODE_DUALVIEW 0x00000040L
16
17#define HASVB_NONE 0x00
18#define HASVB_301 0x01
19#define HASVB_LVDS 0x02
20#define HASVB_TRUMPION 0x04
21#define HASVB_LVDS_CHRONTEL 0x10
22#define HASVB_302 0x20
23#define HASVB_303 0x40
24#define HASVB_CHRONTEL 0x80
25
26#ifndef XGIFB_ID
27#define XGIFB_ID 0x53495346 /* Identify myself with 'XGIF' */
28#endif
29
30typedef enum _XGI_CHIP_TYPE {
31 XGI_VGALegacy = 0,
32 XGI_300,
33 XGI_630,
34 XGI_730,
35 XGI_540,
36 XGI_315H,
37 XGI_315,
38 XGI_315PRO,
39 XGI_550,
40 XGI_640,
41 XGI_740,
42 XGI_650,
43 XGI_650M,
44 XGI_330 = 16,
45 XGI_660,
46 XGI_661,
47 XGI_760,
48 XG40 = 32,
49 XG41,
50 XG42,
51 XG45,
52 XG20 = 48,
53 XG21,
54 XG27,
55 MAX_XGI_CHIP
56} XGI_CHIP_TYPE;
57
58typedef enum _TVTYPE {
59 TVMODE_NTSC = 0,
60 TVMODE_PAL,
61 TVMODE_HIVISION,
62 TVTYPE_PALM, // vicki@030226
63 TVTYPE_PALN, // vicki@030226
64 TVTYPE_NTSCJ, // vicki@030226
65 TVMODE_TOTAL
66} XGI_TV_TYPE;
67
68
69typedef struct _XGIFB_INFO XGIfb_info;
70struct _XGIFB_INFO {
71
72unsigned long XGIfb_id;
73 int chip_id; /* PCI ID of detected chip */
74 int memory; /* video memory in KB which XGIfb manages */
75 int heapstart; /* heap start (= XGIfb "mem" argument) in KB */
76 unsigned char fbvidmode; /* current XGIfb mode */
77
78 unsigned char XGIfb_version;
79 unsigned char XGIfb_revision;
80 unsigned char XGIfb_patchlevel;
81
82 unsigned char XGIfb_caps; /* XGIfb capabilities */
83
84 int XGIfb_tqlen; /* turbo queue length (in KB) */
85
86 unsigned int XGIfb_pcibus; /* The card's PCI ID */
87 unsigned int XGIfb_pcislot;
88 unsigned int XGIfb_pcifunc;
89
90 unsigned char XGIfb_lcdpdc; /* PanelDelayCompensation */
91
92 unsigned char XGIfb_lcda; /* Detected status of LCDA for low res/text modes */
93
94 char reserved[235]; /* for future use */
95};
96
97
98
99
100typedef enum _TVPLUGTYPE { // vicki@030226
101// TVPLUG_Legacy = 0,
102// TVPLUG_COMPOSITE,
103// TVPLUG_SVIDEO,
104// TVPLUG_SCART,
105// TVPLUG_TOTAL
106 TVPLUG_UNKNOWN = 0,
107 TVPLUG_COMPOSITE = 1,
108 TVPLUG_SVIDEO = 2,
109 TVPLUG_COMPOSITE_AND_SVIDEO = 3,
110 TVPLUG_SCART = 4,
111 TVPLUG_YPBPR_525i = 5,
112 TVPLUG_YPBPR_525P = 6,
113 TVPLUG_YPBPR_750P = 7,
114 TVPLUG_YPBPR_1080i = 8,
115 TVPLUG_TOTAL
116} XGI_TV_PLUG;
117
118
119struct mode_info {
120 int bpp;
121 int xres;
122 int yres;
123 int v_xres;
124 int v_yres;
125 int org_x;
126 int org_y;
127 unsigned int vrate;
128};
129
130struct ap_data {
131 struct mode_info minfo;
132 unsigned long iobase;
133 unsigned int mem_size;
134 unsigned long disp_state;
135 XGI_CHIP_TYPE chip;
136 unsigned char hasVB;
137 XGI_TV_TYPE TV_type;
138 XGI_TV_PLUG TV_plug;
139 unsigned long version;
140 char reserved[256];
141};
142
143
144
145/* If changing this, vgatypes.h must also be changed (for X driver) */
146
147
148/*
149 * NOTE! The ioctl types used to be "size_t" by mistake, but were
150 * really meant to be __u32. Changed to "__u32" even though that
151 * changes the value on 64-bit architectures, because the value
152 * (with a 4-byte size) is also hardwired in vgatypes.h for user
153 * space exports. So "__u32" is actually more compatible, duh!
154 */
155#define XGIFB_GET_INFO _IOR('n',0xF8,__u32)
156#define XGIFB_GET_VBRSTATUS _IOR('n',0xF9,__u32)
157
158
159
160struct video_info{
161 int chip_id;
162 unsigned int video_size;
163 unsigned long video_base;
164 char * video_vbase;
165 unsigned long mmio_base;
166 char * mmio_vbase;
167 unsigned long vga_base;
168 unsigned long mtrr;
169 unsigned long heapstart;
170
171 int video_bpp;
172 int video_cmap_len;
173 int video_width;
174 int video_height;
175 int video_vwidth;
176 int video_vheight;
177 int org_x;
178 int org_y;
179 int video_linelength;
180 unsigned int refresh_rate;
181
182 unsigned long disp_state;
183 unsigned char hasVB;
184 unsigned char TV_type;
185 unsigned char TV_plug;
186
187 XGI_CHIP_TYPE chip;
188 unsigned char revision_id;
189
190 unsigned short DstColor;
191 unsigned long XGI310_AccelDepth;
192 unsigned long CommandReg;
193
194 spinlock_t lockaccel;
195
196 unsigned int pcibus;
197 unsigned int pcislot;
198 unsigned int pcifunc;
199
200 int accel;
201 unsigned short subsysvendor;
202 unsigned short subsysdevice;
203
204 char reserved[236];
205};
206
207
208extern struct video_info xgi_video_info;
209
210#ifdef __KERNEL__
211//extern void xgi_malloc(struct xgi_memreq *req);
212extern void xgi_free(unsigned long base);
213extern void xgi_dispinfo(struct ap_data *rec);
214#endif
215#endif
diff --git a/drivers/staging/xgifb/osdef.h b/drivers/staging/xgifb/osdef.h
new file mode 100644
index 00000000000..4bc7d3a7440
--- /dev/null
+++ b/drivers/staging/xgifb/osdef.h
@@ -0,0 +1,153 @@
1#ifndef _OSDEF_H_
2#define _OSDEF_H_
3
4/* #define WINCE_HEADER*/
5/*#define WIN2000*/
6/* #define TC */
7#define LINUX_KERNEL
8/* #define LINUX_XF86 */
9
10/**********************************************************************/
11#ifdef LINUX_KERNEL
12//#include <linux/config.h>
13#endif
14
15
16/**********************************************************************/
17#ifdef TC
18#endif
19#ifdef WIN2000
20#endif
21#ifdef WINCE_HEADER
22#endif
23#ifdef LINUX_XF86
24#define LINUX
25#endif
26#ifdef LINUX_KERNEL
27#define LINUX
28#endif
29
30/**********************************************************************/
31#ifdef TC
32#define XGI_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize);
33#endif
34#ifdef WIN2000
35#define XGI_SetMemory(MemoryAddress,MemorySize,value) MemFill((PVOID) MemoryAddress,(ULONG) MemorySize,(UCHAR) value);
36#endif
37#ifdef WINCE_HEADER
38#define XGI_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize);
39#endif
40#ifdef LINUX_XF86
41#define XGI_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize)
42#endif
43#ifdef LINUX_KERNEL
44#define XGI_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize)
45#endif
46/**********************************************************************/
47
48/**********************************************************************/
49
50#ifdef TC
51#define XGI_MemoryCopy(Destination,Soruce,Length) memmove(Destination, Soruce, Length);
52#endif
53#ifdef WIN2000
54#define XGI_MemoryCopy(Destination,Soruce,Length) /*VideoPortMoveMemory((PUCHAR)Destination , Soruce,length);*/
55#endif
56#ifdef WINCE_HEADER
57#define XGI_MemoryCopy(Destination,Soruce,Length) memmove(Destination, Soruce, Length);
58#endif
59#ifdef LINUX_XF86
60#define XGI_MemoryCopy(Destination,Soruce,Length) memcpy(Destination,Soruce,Length)
61#endif
62#ifdef LINUX_KERNEL
63#define XGI_MemoryCopy(Destination,Soruce,Length) memcpy(Destination,Soruce,Length)
64#endif
65
66/**********************************************************************/
67
68#ifdef OutPortByte
69#undef OutPortByte
70#endif /* OutPortByte */
71
72#ifdef OutPortWord
73#undef OutPortWord
74#endif /* OutPortWord */
75
76#ifdef OutPortLong
77#undef OutPortLong
78#endif /* OutPortLong */
79
80#ifdef InPortByte
81#undef InPortByte
82#endif /* InPortByte */
83
84#ifdef InPortWord
85#undef InPortWord
86#endif /* InPortWord */
87
88#ifdef InPortLong
89#undef InPortLong
90#endif /* InPortLong */
91
92/**********************************************************************/
93/* TC */
94/**********************************************************************/
95
96#ifdef TC
97#define OutPortByte(p,v) outp((unsigned short)(p),(unsigned char)(v))
98#define OutPortWord(p,v) outp((unsigned short)(p),(unsigned short)(v))
99#define OutPortLong(p,v) outp((unsigned short)(p),(unsigned long)(v))
100#define InPortByte(p) inp((unsigned short)(p))
101#define InPortWord(p) inp((unsigned short)(p))
102#define InPortLong(p) ((inp((unsigned short)(p+2))<<16) | inp((unsigned short)(p)))
103#endif
104
105/**********************************************************************/
106/* LINUX XF86 */
107/**********************************************************************/
108
109#ifdef LINUX_XF86
110#define OutPortByte(p,v) outb((CARD16)(p),(CARD8)(v))
111#define OutPortWord(p,v) outw((CARD16)(p),(CARD16)(v))
112#define OutPortLong(p,v) outl((CARD16)(p),(CARD32)(v))
113#define InPortByte(p) inb((CARD16)(p))
114#define InPortWord(p) inw((CARD16)(p))
115#define InPortLong(p) inl((CARD16)(p))
116#endif
117
118#ifdef LINUX_KERNEL
119#define OutPortByte(p,v) outb((u8)(v),(p))
120#define OutPortWord(p,v) outw((u16)(v),(p))
121#define OutPortLong(p,v) outl((u32)(v),(p))
122#define InPortByte(p) inb(p)
123#define InPortWord(p) inw(p)
124#define InPortLong(p) inl(p)
125#endif
126
127/**********************************************************************/
128/* WIN 2000 */
129/**********************************************************************/
130
131#ifdef WIN2000
132#define OutPortByte(p,v) VideoPortWritePortUchar ((PUCHAR) (p), (UCHAR) (v))
133#define OutPortWord(p,v) VideoPortWritePortUshort((PUSHORT) (p), (USHORT) (v))
134#define OutPortLong(p,v) VideoPortWritePortUlong ((PULONG) (p), (ULONG) (v))
135#define InPortByte(p) VideoPortReadPortUchar ((PUCHAR) (p))
136#define InPortWord(p) VideoPortReadPortUshort ((PUSHORT) (p))
137#define InPortLong(p) VideoPortReadPortUlong ((PULONG) (p))
138#endif
139
140
141/**********************************************************************/
142/* WIN CE */
143/**********************************************************************/
144
145#ifdef WINCE_HEADER
146#define OutPortByte(p,v) WRITE_PORT_UCHAR ((PUCHAR) (p), (UCHAR) (v))
147#define OutPortWord(p,v) WRITE_PORT_USHORT((PUSHORT) (p), (USHORT) (v))
148#define OutPortLong(p,v) WRITE_PORT_ULONG ((PULONG) (p), (ULONG) (v))
149#define InPortByte(p) READ_PORT_UCHAR ((PUCHAR) (p))
150#define InPortWord(p) READ_PORT_USHORT ((PUSHORT) (p))
151#define InPortLong(p) READ_PORT_ULONG ((PULONG) (p))
152#endif
153#endif // _OSDEF_H_
diff --git a/drivers/staging/xgifb/vb_def.h b/drivers/staging/xgifb/vb_def.h
new file mode 100644
index 00000000000..17a7ada4926
--- /dev/null
+++ b/drivers/staging/xgifb/vb_def.h
@@ -0,0 +1,1017 @@
1/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/xgi/initdef.h,v 1.4 2000/12/02 01:16:17 dawes Exp $ */
2#ifndef _INITDEF_
3#define _INITDEF_
4
5#ifndef NewScratch
6#define NewScratch
7#endif
8/* shampoo */
9#ifdef LINUX_KERNEL
10#define SEQ_ADDRESS_PORT 0x0014
11#define SEQ_DATA_PORT 0x0015
12#define MISC_OUTPUT_REG_READ_PORT 0x001C
13#define MISC_OUTPUT_REG_WRITE_PORT 0x0012
14#define GRAPH_DATA_PORT 0x1F
15#define GRAPH_ADDRESS_PORT 0x1E
16#define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
17#define CRTC_ADDRESS_PORT_COLOR 0x0024
18#define VIDEO_SUBSYSTEM_ENABLE_PORT 0x0013
19#define PCI_COMMAND 0x04
20#endif
21/* ~shampoo */
22
23
24#define VB_XGI301 0x0001 /*301b*/
25#define VB_XGI301B 0x0002
26#define VB_XGI302B 0x0004
27#define VB_XGI301LV 0x0008 /*301lv*/
28#define VB_XGI302LV 0x0010
29#define VB_XGI301C 0x0020 /* for 301C */
30#define VB_NoLCD 0x8000
31/*end 301b*/
32
33#define VB_YPbPrInfo 0x07 /*301lv*/
34#define VB_YPbPr525i 0x00
35#define VB_YPbPr525p 0x01
36#define VB_YPbPr750p 0x02
37#define VB_YPbPr1080i 0x03
38
39/* #define CRT1Len 17 */
40#define LVDSCRT1Len 15
41#define CHTVRegDataLen 5
42
43/* #define ModeInfoFlag 0x07 */
44/* #define IsTextMode 0x07 */
45/* #define ModeText 0x00 */
46/* #define ModeCGA 0x01 */
47/* #define ModeEGA 0x02 */
48/* #define ModeVGA 0x03 */
49/* #define Mode15Bpp 0x04 */
50/* #define Mode16Bpp 0x05 */
51/* #define Mode24Bpp 0x06 */
52/* #define Mode32Bpp 0x07 */
53
54/* #define DACInfoFlag 0x18 */
55/* #define MemoryInfoFlag 0x1E0 */
56/* #define MemorySizeShift 0x05 */
57
58#define Charx8Dot 0x0200
59#define LineCompareOff 0x0400
60#define CRT2Mode 0x0800
61#define HalfDCLK 0x1000
62#define NoSupportSimuTV 0x2000
63#define DoubleScanMode 0x8000
64
65#define SupportAllCRT2 0x0078
66#define SupportTV 0x0008
67#define SupportHiVisionTV 0x0010
68#define SupportLCD 0x0020
69#define SupportRAMDAC2 0x0040
70#define NoSupportTV 0x0070
71#define NoSupportHiVisionTV 0x0060
72#define NoSupportLCD 0x0058
73#define SupportCHTV 0x0800
74#define SupportCRT2in301C 0x0100 /* for 301C */
75#define SupportTV1024 0x0800 /*301b*/
76#define SupportYPbPr 0x1000 /*301lv*/
77#define InterlaceMode 0x0080
78#define SyncPP 0x0000
79#define SyncPN 0x4000
80#define SyncNP 0x8000
81/* #define SyncNN 0xc000 */
82#define ECLKindex0 0x0000
83#define ECLKindex1 0x0100
84#define ECLKindex2 0x0200
85#define ECLKindex3 0x0300
86#define ECLKindex4 0x0400
87
88#define SetSimuScanMode 0x0001
89#define SwitchToCRT2 0x0002
90/* #define SetCRT2ToTV 0x009C */
91#define SetCRT2ToAVIDEO 0x0004
92#define SetCRT2ToSVIDEO 0x0008
93#define SetCRT2ToSCART 0x0010
94#define SetCRT2ToLCD 0x0020
95#define SetCRT2ToRAMDAC 0x0040
96#define SetCRT2ToHiVisionTV 0x0080
97#define SetNTSCTV 0x0000
98/* #define SetPALTV 0x0100 */
99#define SetInSlaveMode 0x0200
100#define SetNotSimuMode 0x0400
101#define SetNotSimuTVMode 0x0400
102#define SetDispDevSwitch 0x0800
103#define LoadDACFlag 0x1000
104#define DisableCRT2Display 0x2000
105#define DriverMode 0x4000
106#define HotKeySwitch 0x8000
107#define SetCHTVOverScan 0x8000
108/* #define SetCRT2ToLCDA 0x8000 301b */
109#define PanelRGB18Bit 0x0100
110#define PanelRGB24Bit 0x0000
111
112#define TVOverScan 0x10
113#define TVOverScanShift 4
114#define ClearBufferFlag 0x20
115#define EnableDualEdge 0x01 /*301b*/
116#define SetToLCDA 0x02
117
118#define YPbPrModeInfo 0x38
119/* #define YPbPrMode525i 0x00 */
120/* #define YPbPrMode525p 0x08 */
121/* #define YPbPrMode750p 0x10 */
122/* #define YPbPrMode1080i 0x18 */
123
124#define SetSCARTOutput 0x01
125#define BoardTVType 0x02
126#define EnablePALMN 0x40
127/* #define ProgrammingCRT2 0x01 */
128/* #define TVSimuMode 0x02 */
129/* #define RPLLDIV2XO 0x04 */
130/* #define LCDVESATiming 0x08 */
131/* #define EnableLVDSDDA 0x10 */
132#define SetDispDevSwitchFlag 0x20
133#define CheckWinDos 0x40
134#define SetJDOSMode 0x80
135
136#define Panel320x480 0x07/*fstn*/
137/* [ycchen] 02/12/03 Modify for Multi-Sync. LCD Support */
138#define PanelResInfo 0x1F /* CR36 Panel Type/LCDResInfo */
139#define PanelRefInfo 0x60
140#define Panel800x600 0x01
141#define Panel1024x768 0x02
142#define Panel1024x768x75 0x22
143#define Panel1280x1024 0x03
144#define Panel1280x1024x75 0x23
145#define Panel640x480 0x04
146#define Panel1024x600 0x05
147#define Panel1152x864 0x06
148#define Panel1280x960 0x07
149#define Panel1152x768 0x08
150#define Panel1400x1050 0x09
151#define Panel1280x768 0x0A
152#define Panel1600x1200 0x0B
153
154#define PanelRef60Hz 0x00
155#define PanelRef75Hz 0x20
156#define LCDRGB18Bit 0x01
157
158#define ExtChipTrumpion 0x06
159#define ExtChipCH7005 0x08
160#define ExtChipMitacTV 0x0a
161#define LCDNonExpanding 0x10
162#define LCDNonExpandingShift 4
163#define LCDSync 0x20
164#define LCDSyncBit 0xe0
165#define LCDSyncShift 6
166
167/* #define DDC2DelayTime 300 */
168
169#define CRT2DisplayFlag 0x2000
170/* #define LCDDataLen 8 */
171/* #define HiTVDataLen 12 */
172/* #define TVDataLen 16 */
173/* #define SetPALTV 0x0100 */
174#define HalfDCLK 0x1000
175#define NTSCHT 1716
176#define NTSCVT 525
177#define PALHT 1728
178#define PALVT 625
179#define StHiTVHT 892
180#define StHiTVVT 1126
181#define StHiTextTVHT 1000
182#define StHiTextTVVT 1126
183#define ExtHiTVHT 2100
184#define ExtHiTVVT 1125
185
186#define St750pTVHT 1716
187#define St750pTVVT 525
188#define Ext750pTVHT 1716
189#define Ext750pTVVT 525
190#define St525pTVHT 1716
191#define St525pTVVT 525
192#define Ext525pTVHT 1716
193#define Ext525pTVVT 525
194#define St525iTVHT 1716
195#define St525iTVVT 525
196#define Ext525iTVHT 1716
197#define Ext525iTVVT 525
198
199#define VCLKStartFreq 25
200#define SoftDramType 0x80
201#define VCLK40 0x04
202
203#define VCLK162 0x21
204
205#define LCDRGB18Bit 0x01
206#define LoadDACFlag 0x1000
207#define AfterLockCRT2 0x4000
208#define SetCRT2ToAVIDEO 0x0004
209#define SetCRT2ToSCART 0x0010
210#define Ext2StructSize 5
211
212
213#define YPbPr525iVCLK 0x03B
214#define YPbPr525iVCLK_2 0x03A
215
216#define SwitchToCRT2 0x0002
217/* #define LCDVESATiming 0x08 */
218#define SetSCARTOutput 0x01
219#define AVIDEOSense 0x01
220#define SVIDEOSense 0x02
221#define SCARTSense 0x04
222#define LCDSense 0x08
223#define Monitor1Sense 0x20
224#define Monitor2Sense 0x10
225#define HiTVSense 0x40
226#define BoardTVType 0x02
227#define HotPlugFunction 0x08
228#define StStructSize 0x06
229
230
231#define XGI_CRT2_PORT_00 0x00 - 0x030
232#define XGI_CRT2_PORT_04 0x04 - 0x030
233#define XGI_CRT2_PORT_10 0x10 - 0x30
234#define XGI_CRT2_PORT_12 0x12 - 0x30
235#define XGI_CRT2_PORT_14 0x14 - 0x30
236
237
238#define LCDNonExpanding 0x10
239#define ADR_CRT2PtrData 0x20E
240#define offset_Zurac 0x210
241#define ADR_LVDSDesPtrData 0x212
242#define ADR_LVDSCRT1DataPtr 0x214
243#define ADR_CHTVVCLKPtr 0x216
244#define ADR_CHTVRegDataPtr 0x218
245
246#define LVDSDataLen 6
247/* #define EnableLVDSDDA 0x10 */
248/* #define LVDSDesDataLen 3 */
249#define ActiveNonExpanding 0x40
250#define ActiveNonExpandingShift 6
251/* #define ActivePAL 0x20 */
252#define ActivePALShift 5
253/* #define ModeSwitchStatus 0x0F */
254#define SoftTVType 0x40
255#define SoftSettingAddr 0x52
256#define ModeSettingAddr 0x53
257
258/* #define SelectCRT1Rate 0x4 */
259
260#define _PanelType00 0x00
261#define _PanelType01 0x08
262#define _PanelType02 0x10
263#define _PanelType03 0x18
264#define _PanelType04 0x20
265#define _PanelType05 0x28
266#define _PanelType06 0x30
267#define _PanelType07 0x38
268#define _PanelType08 0x40
269#define _PanelType09 0x48
270#define _PanelType0A 0x50
271#define _PanelType0B 0x58
272#define _PanelType0C 0x60
273#define _PanelType0D 0x68
274#define _PanelType0E 0x70
275#define _PanelType0F 0x78
276
277
278#define PRIMARY_VGA 0 /* 1: XGI is primary vga 0:XGI is secondary vga */
279#define BIOSIDCodeAddr 0x235
280#define OEMUtilIDCodeAddr 0x237
281#define VBModeIDTableAddr 0x239
282#define OEMTVPtrAddr 0x241
283#define PhaseTableAddr 0x243
284#define NTSCFilterTableAddr 0x245
285#define PALFilterTableAddr 0x247
286#define OEMLCDPtr_1Addr 0x249
287#define OEMLCDPtr_2Addr 0x24B
288#define LCDHPosTable_1Addr 0x24D
289#define LCDHPosTable_2Addr 0x24F
290#define LCDVPosTable_1Addr 0x251
291#define LCDVPosTable_2Addr 0x253
292#define OEMLCDPIDTableAddr 0x255
293
294#define VBModeStructSize 5
295#define PhaseTableSize 4
296#define FilterTableSize 4
297#define LCDHPosTableSize 7
298#define LCDVPosTableSize 5
299#define OEMLVDSPIDTableSize 4
300#define LVDSHPosTableSize 4
301#define LVDSVPosTableSize 6
302
303#define VB_ModeID 0
304#define VB_TVTableIndex 1
305#define VB_LCDTableIndex 2
306#define VB_LCDHIndex 3
307#define VB_LCDVIndex 4
308
309#define OEMLCDEnable 0x0001
310#define OEMLCDDelayEnable 0x0002
311#define OEMLCDPOSEnable 0x0004
312#define OEMTVEnable 0x0100
313#define OEMTVDelayEnable 0x0200
314#define OEMTVFlickerEnable 0x0400
315#define OEMTVPhaseEnable 0x0800
316#define OEMTVFilterEnable 0x1000
317
318#define OEMLCDPanelIDSupport 0x0080
319
320/* #define LCDVESATiming 0x0001 //LCD Info CR37 */
321/* #define EnableLVDSDDA 0x0002 */
322#define EnableScalingLCD 0x0008
323#define SetPWDEnable 0x0004
324#define SetLCDtoNonExpanding 0x0010
325/* #define SetLCDPolarity 0x00E0 */
326#define SetLCDDualLink 0x0100
327#define SetLCDLowResolution 0x0200
328#define SetLCDStdMode 0x0400
329#define SetTVStdMode 0x0200
330#define SetTVLowResolution 0x0400
331/* =============================================================
332 for 310
333============================================================== */
334#define SoftDRAMType 0x80
335#define SoftSetting_OFFSET 0x52
336#define SR07_OFFSET 0x7C
337#define SR15_OFFSET 0x7D
338#define SR16_OFFSET 0x81
339#define SR17_OFFSET 0x85
340#define SR19_OFFSET 0x8D
341#define SR1F_OFFSET 0x99
342#define SR21_OFFSET 0x9A
343#define SR22_OFFSET 0x9B
344#define SR23_OFFSET 0x9C
345#define SR24_OFFSET 0x9D
346#define SR25_OFFSET 0x9E
347#define SR31_OFFSET 0x9F
348#define SR32_OFFSET 0xA0
349#define SR33_OFFSET 0xA1
350
351#define CR40_OFFSET 0xA2
352#define SR25_1_OFFSET 0xF6
353#define CR49_OFFSET 0xF7
354
355#define VB310Data_1_2_Offset 0xB6
356#define VB310Data_4_D_Offset 0xB7
357#define VB310Data_4_E_Offset 0xB8
358#define VB310Data_4_10_Offset 0xBB
359
360#define RGBSenseDataOffset 0xBD
361#define YCSenseDataOffset 0xBF
362#define VideoSenseDataOffset 0xC1
363#define OutputSelectOffset 0xF3
364
365#define ECLK_MCLK_DISTANCE 0x14
366#define VBIOSTablePointerStart 0x200
367#define StandTablePtrOffset VBIOSTablePointerStart+0x02
368#define EModeIDTablePtrOffset VBIOSTablePointerStart+0x04
369#define CRT1TablePtrOffset VBIOSTablePointerStart+0x06
370#define ScreenOffsetPtrOffset VBIOSTablePointerStart+0x08
371#define VCLKDataPtrOffset VBIOSTablePointerStart+0x0A
372#define MCLKDataPtrOffset VBIOSTablePointerStart+0x0E
373#define CRT2PtrDataPtrOffset VBIOSTablePointerStart+0x10
374#define TVAntiFlickPtrOffset VBIOSTablePointerStart+0x12
375#define TVDelayPtr1Offset VBIOSTablePointerStart+0x14
376#define TVPhaseIncrPtr1Offset VBIOSTablePointerStart+0x16
377#define TVYFilterPtr1Offset VBIOSTablePointerStart+0x18
378#define LCDDelayPtr1Offset VBIOSTablePointerStart+0x20
379#define TVEdgePtr1Offset VBIOSTablePointerStart+0x24
380#define CRT2Delay1Offset VBIOSTablePointerStart+0x28
381#define LCDDataDesOffset VBIOSTablePointerStart-0x02
382#define LCDDataPtrOffset VBIOSTablePointerStart+0x2A
383#define LCDDesDataPtrOffset VBIOSTablePointerStart+0x2C
384#define LCDDataList VBIOSTablePointerStart+0x22 /* add for GetLCDPtr */
385#define TVDataList VBIOSTablePointerStart+0x36 /* add for GetTVPtr */
386/* */
387/* Modify from 310.inc */
388/* */
389/* */
390
391
392#define ShowMsgFlag 0x20 /* SoftSetting */
393#define ShowVESAFlag 0x10
394#define HotPlugFunction 0x08
395#define ModeSoftSetting 0x04
396#define TVSoftSetting 0x02
397#define LCDSoftSetting 0x01
398
399#define GatingCRTinLCDA 0x10
400#define SetHiTVOutput 0x08
401#define SetYPbPrOutput 0x04
402#define BoardTVType 0x02
403#define SetSCARTOutput 0x01
404
405#define ModeSettingYPbPr 0x02 /* TVModeSetting, Others as same as CR30 */
406
407/* TVModeSetting same as CR35 */
408
409/* LCDModeSetting same as CR37 */
410
411#define EnableNewTVFont 0x10 /* MiscCapability */
412
413#define EnableLCDOutput 0x80 /* LCDCfgSetting */
414
415#define SoftDRAMType 0x80 /* DRAMSetting */
416#define SoftDRAMConfig 0x40
417#define MosSelDRAMType 0x20
418#define SDRAM 000h
419#define SGRAM 0x01
420#define ESDRAM 0x02
421
422#define EnableAGPCfgSetting 0x01 /* AGPCfgSetting */
423
424/* ---------------- SetMode Stack */
425#define CRT1Len 15
426#define VCLKLen 4
427#define DefThreshold 0x0100
428#define ExtRegsSize (57+8+37+70+63+28+768+1)/64+1
429
430#define VGA_XGI315 0x0001 /* VGA Type Info */
431#define VGA_SNewis315e 0x0002 /* 315 series */
432#define VGA_XGI550 0x0004
433#define VGA_XGI640 0x0008
434#define VGA_XGI740 0x0010
435#define VGA_XGI650 0x0020
436#define VGA_XGI650M 0x0040
437#define VGA_XGI651 0x0080
438#define VGA_XGI340 0x0001 /* 340 series */
439#define VGA_XGI330 0x0001 /* 330 series */
440#define VGA_XGI660 0x0001 /* 660 series */
441
442#define VB_XGI301 0x0001 /* VB Type Info */
443#define VB_XGI301B 0x0002 /* 301 series */
444#define VB_XGI302B 0x0004
445#define VB_NoLCD 0x8000
446#define VB_XGI301LV 0x0008
447#define VB_XGI302LV 0x0010
448#define VB_LVDS_NS 0x0001 /* 3rd party chip */
449#define VB_CH7017 0x0002
450#define VB_CH7007 0x0080 /* [Billy] 07/05/03 */
451/* #define VB_LVDS_SI 0x0004 */
452
453#define ModeInfoFlag 0x0007
454#define IsTextMode 0x0007
455#define ModeText 0x0000
456#define ModeCGA 0x0001
457#define ModeEGA 0x0002 /* 16 colors mode */
458#define ModeVGA 0x0003 /* 256 colors mode */
459#define Mode15Bpp 0x0004 /* 15 Bpp Color Mode */
460#define Mode16Bpp 0x0005 /* 16 Bpp Color Mode */
461#define Mode24Bpp 0x0006 /* 24 Bpp Color Mode */
462#define Mode32Bpp 0x0007 /* 32 Bpp Color Mode */
463
464#define DACInfoFlag 0x0018
465#define MONODAC 0x0000
466#define CGADAC 0x0008
467#define EGADAC 0x0010
468#define VGADAC 0x0018
469
470#define MemoryInfoFlag 0x01e0
471#define MemorySizeShift 5
472#define Need1MSize 0x0000
473#define Need2MSize 0x0020
474#define Need4MSize 0x0060
475#define Need8MSize 0x00e0
476#define Need16MSize 0x01e0
477
478#define Charx8Dot 0x0200
479#define LineCompareOff 0x0400
480#define CRT2Mode 0x0800
481#define HalfDCLK 0x1000
482#define NoSupportSimuTV 0x2000
483#define DoubleScanMode 0x8000
484
485/* -------------- Ext_InfoFlag */
486#define SupportModeInfo 0x0007
487#define Support256 0x0003
488#define Support15Bpp 0x0004
489#define Support16Bpp 0x0005
490#define Support24Bpp 0x0006
491#define Support32Bpp 0x0007
492
493#define SupportAllCRT2 0x0078
494#define SupportTV 0x0008
495#define SupportHiVisionTV 0x0010
496#define SupportLCD 0x0020
497#define SupportRAMDAC2 0x0040
498#define NoSupportTV 0x0070
499#define NoSupportHiVisionTV 0x0060
500#define NoSupportLCD 0x0058
501#define SupportTV1024 0x0800 /* 301btest */
502#define SupportYPbPr 0x1000 /* 301lv */
503#define InterlaceMode 0x0080
504#define SyncPP 0x0000
505#define SyncPN 0x4000
506#define SyncNP 0x8000
507#define SyncNN 0xC000
508
509/* -------------- SetMode Stack/Scratch */
510#define SetSimuScanMode 0x0001 /* VBInfo/CR30 & CR31 */
511#define SwitchToCRT2 0x0002
512#define SetCRT2ToTV1 0x009C
513#define SetCRT2ToTV 0x089C
514#define SetCRT2ToAVIDEO 0x0004
515#define SetCRT2ToSVIDEO 0x0008
516#define SetCRT2ToSCART 0x0010
517#define SetCRT2ToLCD 0x0020
518#define SetCRT2ToRAMDAC 0x0040
519#define SetCRT2ToHiVisionTV 0x0080
520#define SetCRT2ToLCDA 0x0100
521#define SetInSlaveMode 0x0200
522#define SetNotSimuMode 0x0400
523#define HKEventMode 0x0800
524#define SetCRT2ToYPbPr 0x0800
525#define LoadDACFlag 0x1000
526#define DisableCRT2Display 0x2000
527#define DriverMode 0x4000
528#define SetCRT2ToDualEdge 0x8000
529#define HotKeySwitch 0x8000
530
531#define ProgrammingCRT2 0x0001 /* Set Flag */
532#define EnableVCMode 0x0002
533#define SetHKEventMode 0x0004
534#define ReserveTVOption 0x0008
535#define DisableRelocateIO 0x0010
536#define Win9xDOSMode 0x0020
537#define JDOSMode 0x0040
538/* #define SetWin9xforJap 0x0080 // not used now */
539/* #define SetWin9xforKorea 0x0100 // not used now */
540#define GatingCRT 0x0800
541#define DisableChB 0x1000
542#define EnableChB 0x2000
543#define DisableChA 0x4000
544#define EnableChA 0x8000
545
546#define SetNTSCTV 0x0000 /* TV Info */
547#define SetPALTV 0x0001
548#define SetNTSCJ 0x0002
549#define SetPALMTV 0x0004
550#define SetPALNTV 0x0008
551#define SetCHTVUnderScan 0x0000
552/* #define SetCHTVOverScan 0x0010 */
553#define SetYPbPrMode525i 0x0020
554#define SetYPbPrMode525p 0x0040
555#define SetYPbPrMode750p 0x0080
556#define SetYPbPrMode1080i 0x0100
557#define SetTVStdMode 0x0200
558#define SetTVLowResolution 0x0400
559#define SetTVSimuMode 0x0800
560#define TVSimuMode 0x0800
561#define RPLLDIV2XO 0x1000
562#define NTSC1024x768 0x2000
563#define SetTVLockMode 0x4000
564
565#define LCDVESATiming 0x0001 /* LCD Info/CR37 */
566#define EnableLVDSDDA 0x0002
567#define EnableScalingLCD 0x0008
568#define SetPWDEnable 0x0004
569#define SetLCDtoNonExpanding 0x0010
570#define SetLCDPolarity 0x00e0
571#define SetLCDDualLink 0x0100
572#define SetLCDLowResolution 0x0200
573#define SetLCDStdMode 0x0400
574
575#define DefaultLCDCap 0x80ea /* LCD Capability shampoo */
576#define RLVDSDHL00 0x0000
577#define RLVDSDHL01 0x0001
578#define RLVDSDHL10 0x0002 /* default */
579#define RLVDSDHL11 0x0003
580#define EnableLCD24bpp 0x0004 /* default */
581#define DisableLCD24bpp 0x0000
582#define RLVDSClkSFT0 0x0000
583#define RLVDSClkSFT1 0x0008 /* default */
584#define EnableLVDSDCBal 0x0010
585#define DisableLVDSDCBal 0x0000 /* default */
586#define SinglePolarity 0x0020 /* default */
587#define MultiPolarity 0x0000
588#define LCDPolarity 0x00c0 /* default: SyncNN */
589#define LCDSingleLink 0x0000 /* default */
590#define LCDDualLink 0x0100
591#define EnableSpectrum 0x0200
592#define DisableSpectrum 0x0000 /* default */
593#define PWDEnable 0x0400
594#define PWDDisable 0x0000 /* default */
595#define PWMEnable 0x0800
596#define PWMDisable 0x0000 /* default */
597#define EnableVBCLKDRVLOW 0x4000
598#define EnableVBCLKDRVHigh 0x0000 /* default */
599#define EnablePLLSPLOW 0x8000
600#define EnablePLLSPHigh 0x0000 /* default */
601
602#define LCDBToA 0x20 /* LCD SetFlag */
603#define StLCDBToA 0x40
604#define LockLCDBToA 0x80
605#define LCDToFull 0x10
606#define AVIDEOSense 0x01 /* CR32 */
607#define SVIDEOSense 0x02
608#define SCARTSense 0x04
609#define LCDSense 0x08
610#define Monitor2Sense 0x10
611#define Monitor1Sense 0x20
612#define HiTVSense 0x40
613
614#ifdef NewScratch
615#define YPbPrSense 0x80 /* NEW SCRATCH */
616#endif
617
618#define TVSense 0xc7
619
620#define TVOverScan 0x10 /* CR35 */
621#define TVOverScanShift 4
622
623#ifdef NewScratch
624#define NTSCMode 0x00
625#define PALMode 0x00
626#define NTSCJMode 0x02
627#define PALMNMode 0x0c
628#define YPbPrMode 0xe0
629#define YPbPrMode525i 0x00
630#define YPbPrMode525p 0x20
631#define YPbPrMode750p 0x40
632#define YPbPrMode1080i 0x60
633#else /* Old Scratch */
634#define ClearBufferFlag 0x20
635#endif
636
637
638#define LCDRGB18Bit 0x01 /* CR37 */
639#define LCDNonExpanding 0x10
640#define LCDNonExpandingShift 4
641#define LCDSync 0x20
642#define LCDSyncBit 0xe0 /* H/V polarity & sync ID */
643#define LCDSyncShift 6
644
645#ifdef NewScratch
646#define ScalingLCD 0x08
647#else /* Old Scratch */
648#define ExtChipType 0x0e
649#define ExtChip301 0x02
650#define ExtChipLVDS 0x04
651#define ExtChipCH7019 0x06
652#define ScalingLCD 0x10
653#endif
654
655#define EnableDualEdge 0x01 /* CR38 */
656#define SetToLCDA 0x02
657#ifdef NewScratch
658#define SetYPbPr 0x04
659#define DisableChannelA 0x08
660#define DisableChannelB 0x10
661#define ExtChipType 0xe0
662#define ExtChip301 0x20
663#define ExtChipLVDS 0x40
664#define ExtChipCH7019 0x60
665#else /* Old Scratch */
666#define YPbPrSense 0x04
667#define SetYPbPr 0x08
668#define YPbPrMode 0x30
669#define YPbPrMode525i 0x00
670#define YPbPrMode525p 0x10
671#define YPbPrMode750p 0x20
672#define YPbPrMode1080i 0x30
673#define PALMNMode 0xc0
674#endif
675
676#define BacklightControlBit 0x01 /* CR3A */
677#define Win9xforJap 0x40
678#define Win9xforKorea 0x80
679
680#define ForceMDBits 0x07 /* CR3B */
681#define ForceMD_JDOS 0x00
682#define ForceMD_640x400T 0x01
683#define ForceMD_640x350T 0x02
684#define ForceMD_720x400T 0x03
685#define ForceMD_640x480E 0x04
686#define ForceMD_640x400E 0x05
687#define ForceP1Bit 0x10
688#define ForceP2Bit 0x20
689#define EnableForceMDinBIOS 0x40
690#define EnableForceMDinDrv 0x80
691
692#ifdef NewScratch /* New Scratch */
693/* ---------------------- VUMA Information */
694#define LCDSettingFromCMOS 0x04 /* CR3C */
695#define TVSettingFromCMOS 0x08
696#define DisplayDeviceFromCMOS 0x10
697#define HKSupportInSBIOS 0x20
698#define OSDSupportInSBIOS 0x40
699#define DisableLogo 0x80
700
701/* ---------------------- HK Evnet Definition */
702#define HKEvent 0x0f /* CR3D */
703#define HK_ModeSwitch 0x01
704#define HK_Expanding 0x02
705#define HK_OverScan 0x03
706#define HK_Brightness 0x04
707#define HK_Contrast 0x05
708#define HK_Mute 0x06
709#define HK_Volume 0x07
710#define ModeSwitchStatus 0xf0
711#define ActiveCRT1 0x10
712#define ActiveLCD 0x0020
713#define ActiveTV 0x40
714#define ActiveCRT2 0x80
715
716#define TVSwitchStatus 0x1f /* CR3E */
717#define ActiveAVideo 0x01
718#define ActiveSVideo 0x02
719#define ActiveSCART 0x04
720#define ActiveHiTV 0x08
721#define ActiveYPbPr 0x10
722
723#define EnableHKEvent 0x01 /* CR3F */
724#define EnableOSDEvent 0x02
725#define StartOSDEvent 0x04
726#define IgnoreHKEvent 0x08
727#define IgnoreOSDEvent 0x10
728#else /* Old Scratch */
729#define OSD_SBIOS 0x02 /* SR17 */
730#define DisableLogo 0x04
731#define SelectKDOS 0x08
732#define KorWinMode 0x10
733#define KorMode3Bit 0x0020
734#define PSCCtrlBit 0x40
735#define NPSCCtrlBitShift 6
736#define BlueScreenBit 0x80
737
738#define HKEvent 0x0f /* CR79 */
739#define HK_ModeSwitch 0x01
740#define HK_Expanding 0x02
741#define HK_OverScan 0x03
742#define HK_Brightness 0x04
743#define HK_Contrast 0x05
744#define HK_Mute 0x06
745#define HK_Volume 0x07
746#define ActivePAL 0x0020
747#define ActivePALShift 5
748#define ActiveNonExpanding 0x40
749#define ActiveNonExpandingShift 6
750#define ActiveOverScan 0x80
751#define ActiveOverScanShift 7
752
753#define ModeSwitchStatus 0x0b /* SR15 */
754#define ActiveCRT1 0x01
755#define ActiveLCD 0x02
756#define ActiveCRT2 0x08
757
758#define TVSwitchStatus 0xf0 /* SR16 */
759#define TVConfigShift 3
760#define ActiveTV 0x01
761#define ActiveYPbPr 0x04
762#define ActiveAVideo 0x10
763#define ActiveSVideo 0x0020
764#define ActiveSCART 0x40
765#define ActiveHiTV 0x80
766
767#define EnableHKEvent 0x01 /* CR7A */
768#define EnableOSDEvent 0x02
769#define StartOSDEvent 0x04
770#define CMOSSupport 0x08
771#define HotKeySupport 0x10
772#define IngoreHKOSDEvent 0x20
773#endif
774
775/* //------------- Misc. Definition */
776#define SelectCRT1Rate 00h
777/* #define SelectCRT2Rate 04h */
778
779#define DDC1DelayTime 1000
780#ifdef TRUMPION
781#define DDC2DelayTime 15
782#else
783#define DDC2DelayTime 150
784#endif
785
786#define R_FACTOR 04Dh
787#define G_FACTOR 097h
788#define B_FACTOR 01Ch
789/* --------------------------------------------------------- */
790/* translated from asm code 301def.h */
791/* */
792/* --------------------------------------------------------- */
793#define LCDDataLen 8
794#define HiTVDataLen 12
795#define TVDataLen 12
796#define LVDSCRT1Len_H 8
797#define LVDSCRT1Len_V 7
798#define LVDSDataLen 6
799#define LVDSDesDataLen 6
800#define LCDDesDataLen 6
801#define LVDSDesDataLen2 8
802#define LCDDesDataLen2 8
803#define CHTVRegLen 16
804#define CHLVRegLen 12
805
806#define StHiTVHT 892
807#define StHiTVVT 1126
808#define StHiTextTVHT 1000
809#define StHiTextTVVT 1126
810#define ExtHiTVHT 2100
811#define ExtHiTVVT 1125
812#define NTSCHT 1716
813#define NTSCVT 525
814#define NTSC1024x768HT 1908
815#define NTSC1024x768VT 525
816#define PALHT 1728
817#define PALVT 625
818
819#define YPbPrTV525iHT 1716 /* YPbPr */
820#define YPbPrTV525iVT 525
821#define YPbPrTV525pHT 1716
822#define YPbPrTV525pVT 525
823#define YPbPrTV750pHT 1650
824#define YPbPrTV750pVT 750
825
826#define CRT2VCLKSel 0xc0
827
828#define CRT2Delay1 0x04 /* XGI301 */
829#define CRT2Delay2 0x0A /* 301B,302 */
830
831
832#define VCLK25_175 0x00
833#define VCLK28_322 0x01
834#define VCLK31_5 0x02
835#define VCLK36 0x03
836#define VCLK40 0x04
837#define VCLK43_163 0x05
838#define VCLK44_9 0x06
839#define VCLK49_5 0x07
840#define VCLK50 0x08
841#define VCLK52_406 0x09
842#define VCLK56_25 0x0A
843#define VCLK65 0x0B
844#define VCLK67_765 0x0C
845#define VCLK68_179 0x0D
846#define VCLK72_852 0x0E
847#define VCLK75 0x0F
848#define VCLK75_8 0x10
849#define VCLK78_75 0x11
850#define VCLK79_411 0x12
851#define VCLK83_95 0x13
852#define VCLK84_8 0x14
853#define VCLK86_6 0x15
854#define VCLK94_5 0x16
855#define VCLK104_998 0x17
856#define VCLK105_882 0x18
857#define VCLK108_2 0x19
858#define VCLK109_175 0x1A
859#define VCLK113_309 0x1B
860#define VCLK116_406 0x1C
861#define VCLK132_258 0x1D
862#define VCLK135_5 0x1E
863#define VCLK139_054 0x1F
864#define VCLK157_5 0x20
865#define VCLK162 0x21
866#define VCLK175 0x22
867#define VCLK189 0x23
868#define VCLK194_4 0x24
869#define VCLK202_5 0x25
870#define VCLK229_5 0x26
871#define VCLK234 0x27
872#define VCLK252_699 0x28
873#define VCLK254_817 0x29
874#define VCLK265_728 0x2A
875#define VCLK266_952 0x2B
876#define VCLK269_655 0x2C
877#define VCLK272_042 0x2D
878#define VCLK277_015 0x2E
879#define VCLK286_359 0x2F
880#define VCLK291_132 0x30
881#define VCLK291_766 0x31
882#define VCLK309_789 0x32
883#define VCLK315_195 0x33
884#define VCLK323_586 0x34
885#define VCLK330_615 0x35
886#define VCLK332_177 0x36
887#define VCLK340_477 0x37
888#define VCLK375_847 0x38
889#define VCLK388_631 0x39
890#define VCLK125_999 0x51
891#define VCLK148_5 0x52
892#define VCLK178_992 0x54
893#define VCLK217_325 0x55
894#define VCLK299_505 0x56
895#define YPbPr750pVCLK 0x57
896
897#define TVVCLKDIV2 0x3A
898#define TVVCLK 0x3B
899#define HiTVVCLKDIV2 0x3C
900#define HiTVVCLK 0x3D
901#define HiTVSimuVCLK 0x3E
902#define HiTVTextVCLK 0x3F
903#define VCLK39_77 0x40
904/* #define YPbPr750pVCLK 0x0F */
905#define YPbPr525pVCLK 0x3A
906/* #define ;;YPbPr525iVCLK 0x3B */
907/* #define ;;YPbPr525iVCLK_2 0x3A */
908#define NTSC1024VCLK 0x41
909#define VCLK25_175_41 0x42 /* ; ScaleLCD */
910#define VCLK25_175_42 0x43
911#define VCLK28_322_43 0x44
912#define VCLK40_44 0x45
913#define VCLKQVGA_1 0x46 /* ; QVGA */
914#define VCLKQVGA_2 0x47
915#define VCLKQVGA_3 0x48
916#define VCLK35_2 0x49 /* ; 800x480 */
917#define VCLK122_61 0x4A
918#define VCLK80_350 0x4B
919#define VCLK107_385 0x4C
920
921#define CHTVVCLK30_2 0x50 /* ;;CHTV */
922#define CHTVVCLK28_1 0x51
923#define CHTVVCLK43_6 0x52
924#define CHTVVCLK26_4 0x53
925#define CHTVVCLK24_6 0x54
926#define CHTVVCLK47_8 0x55
927#define CHTVVCLK31_5 0x56
928#define CHTVVCLK26_2 0x57
929#define CHTVVCLK39 0x58
930#define CHTVVCLK36 0x59
931
932#define CH7007TVVCLK30_2 0x00 /* [Billy] 2007/05/18 For CH7007 */
933#define CH7007TVVCLK28_1 0x01
934#define CH7007TVVCLK43_6 0x02
935#define CH7007TVVCLK26_4 0x03
936#define CH7007TVVCLK24_6 0x04
937#define CH7007TVVCLK47_8 0x05
938#define CH7007TVVCLK31_5 0x06
939#define CH7007TVVCLK26_2 0x07
940#define CH7007TVVCLK39 0x08
941#define CH7007TVVCLK36 0x09
942
943#define RES320x200 0x00
944#define RES320x240 0x01
945#define RES400x300 0x02
946#define RES512x384 0x03
947#define RES640x400 0x04
948#define RES640x480x60 0x05
949#define RES640x480x72 0x06
950#define RES640x480x75 0x07
951#define RES640x480x85 0x08
952#define RES640x480x100 0x09
953#define RES640x480x120 0x0A
954#define RES640x480x160 0x0B
955#define RES640x480x200 0x0C
956#define RES800x600x56 0x0D
957#define RES800x600x60 0x0E
958#define RES800x600x72 0x0F
959#define RES800x600x75 0x10
960#define RES800x600x85 0x11
961#define RES800x600x100 0x12
962#define RES800x600x120 0x13
963#define RES800x600x160 0x14
964#define RES1024x768x43 0x15
965#define RES1024x768x60 0x16
966#define RES1024x768x70 0x17
967#define RES1024x768x75 0x18
968#define RES1024x768x85 0x19
969#define RES1024x768x100 0x1A
970#define RES1024x768x120 0x1B
971#define RES1280x1024x43 0x1C
972#define RES1280x1024x60 0x1D
973#define RES1280x1024x75 0x1E
974#define RES1280x1024x85 0x1F
975#define RES1600x1200x60 0x20
976#define RES1600x1200x65 0x21
977#define RES1600x1200x70 0x22
978#define RES1600x1200x75 0x23
979#define RES1600x1200x85 0x24
980#define RES1600x1200x100 0x25
981#define RES1600x1200x120 0x26
982#define RES1920x1440x60 0x27
983#define RES1920x1440x65 0x28
984#define RES1920x1440x70 0x29
985#define RES1920x1440x75 0x2A
986#define RES1920x1440x85 0x2B
987#define RES1920x1440x100 0x2C
988#define RES2048x1536x60 0x2D
989#define RES2048x1536x65 0x2E
990#define RES2048x1536x70 0x2F
991#define RES2048x1536x75 0x30
992#define RES2048x1536x85 0x31
993#define RES800x480x60 0x32
994#define RES800x480x75 0x33
995#define RES800x480x85 0x34
996#define RES1024x576x60 0x35
997#define RES1024x576x75 0x36
998#define RES1024x576x85 0x37
999#define RES1280x720x60 0x38
1000#define RES1280x720x75 0x39
1001#define RES1280x720x85 0x3A
1002#define RES1280x960x60 0x3B
1003#define RES720x480x60 0x3C
1004#define RES720x576x56 0x3D
1005#define RES856x480x79I 0x3E
1006#define RES856x480x60 0x3F
1007#define RES1280x768x60 0x40
1008#define RES1400x1050x60 0x41
1009#define RES1152x864x60 0x42
1010#define RES1152x864x75 0x43
1011#define RES1024x768x160 0x44
1012#define RES1280x960x75 0x45
1013#define RES1280x960x85 0x46
1014#define RES1280x960x120 0x47
1015
1016#define LFBDRAMTrap 0x30
1017#endif
diff --git a/drivers/staging/xgifb/vb_ext.c b/drivers/staging/xgifb/vb_ext.c
new file mode 100644
index 00000000000..49b39ee93a8
--- /dev/null
+++ b/drivers/staging/xgifb/vb_ext.c
@@ -0,0 +1,1370 @@
1#include "osdef.h"
2
3
4
5
6#ifdef WIN2000
7
8#include <dderror.h>
9#include <devioctl.h>
10#include <miniport.h>
11#include <ntddvdeo.h>
12#include <video.h>
13#include "xgiv.h"
14#include "dd_i2c.h"
15#include "tools.h"
16#endif /* WIN2000 */
17
18#ifdef LINUX_XF86
19#include "xf86.h"
20#include "xf86PciInfo.h"
21#include "xgi.h"
22#include "xgi_regs.h"
23#endif
24
25#ifdef LINUX_KERNEL
26#include <linux/version.h>
27#include <asm/io.h>
28#include <linux/types.h>
29#include "XGIfb.h"
30/*#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
31#include <video/XGIfb.h>
32#else
33#include <linux/XGIfb.h>
34#endif*/
35#endif
36
37
38
39#include "vb_def.h"
40#include "vgatypes.h"
41#include "vb_struct.h"
42#include "vb_util.h"
43#include "vb_setmode.h"
44#include "vb_ext.h"
45extern UCHAR XGI330_SoftSetting;
46extern UCHAR XGI330_OutputSelect;
47extern USHORT XGI330_RGBSenseData2;
48extern USHORT XGI330_YCSenseData2;
49extern USHORT XGI330_VideoSenseData2;
50#ifdef WIN2000
51extern UCHAR SenseCHTV(PHW_DEVICE_EXTENSION pHWDE); /* 2007/05/17 Billy */
52#endif
53void XGI_GetSenseStatus( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo );
54BOOLEAN XGINew_GetPanelID(PVB_DEVICE_INFO pVBInfo);
55USHORT XGINew_SenseLCD(PXGI_HW_DEVICE_INFO,PVB_DEVICE_INFO pVBInfo);
56BOOLEAN XGINew_GetLCDDDCInfo(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
57void XGISetDPMS( PXGI_HW_DEVICE_INFO pXGIHWDE , ULONG VESA_POWER_STATE ) ;
58BOOLEAN XGINew_BridgeIsEnable(PXGI_HW_DEVICE_INFO,PVB_DEVICE_INFO pVBInfo );
59BOOLEAN XGINew_Sense(USHORT tempbx,USHORT tempcx, PVB_DEVICE_INFO pVBInfo);
60BOOLEAN XGINew_SenseHiTV( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo ) ;
61
62/**************************************************************
63 Dynamic Sense
64*************************************************************/
65
66void XGI_WaitDisplay(void);
67BOOLEAN XGI_Is301C(PVB_DEVICE_INFO);
68BOOLEAN XGI_Is301LV(PVB_DEVICE_INFO);
69
70#ifdef WIN2000
71UCHAR XGI_SenseLCD(PHW_DEVICE_EXTENSION, PVB_DEVICE_INFO);
72UCHAR XGI_GetLCDDDCInfo(PHW_DEVICE_EXTENSION,PVB_DEVICE_INFO);
73
74extern BOOL bGetDdcInfo(
75PHW_DEVICE_EXTENSION pHWDE,
76ULONG ulWhichOne,
77PUCHAR pjQueryBuffer,
78ULONG ulBufferSize
79 );
80
81#endif
82
83
84/* --------------------------------------------------------------------- */
85/* Function : XGINew_Is301B */
86/* Input : */
87/* Output : */
88/* Description : */
89/* --------------------------------------------------------------------- */
90BOOLEAN XGINew_Is301B( PVB_DEVICE_INFO pVBInfo )
91{
92 USHORT flag ;
93
94 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
95
96 if ( flag > 0x0B0 )
97 return( 0 ) ; /* 301b */
98 else
99 return( 1 ) ;
100}
101
102/* --------------------------------------------------------------------- */
103/* Function : XGI_Is301C */
104/* Input : */
105/* Output : */
106/* Description : */
107/* --------------------------------------------------------------------- */
108BOOLEAN XGI_Is301C( PVB_DEVICE_INFO pVBInfo )
109{
110 if ( ( XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) & 0xF0 ) == 0xC0 )
111 return( 1 ) ;
112
113 if ( XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) >= 0xD0 )
114 {
115 if ( XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) == 0xE0 )
116 return( 1 ) ;
117 }
118
119 return( 0 ) ;
120}
121
122
123/* --------------------------------------------------------------------- */
124/* Function : XGI_Is301LV */
125/* Input : */
126/* Output : */
127/* Description : */
128/* --------------------------------------------------------------------- */
129BOOLEAN XGI_Is301LV( PVB_DEVICE_INFO pVBInfo )
130{
131 if ( XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) >= 0xD0 )
132 {
133 if ( XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) == 0xFF )
134 {
135 return( 1 ) ;
136 }
137 }
138 return( 0 ) ;
139}
140
141
142/* --------------------------------------------------------------------- */
143/* Function : XGINew_Sense */
144/* Input : */
145/* Output : */
146/* Description : */
147/* --------------------------------------------------------------------- */
148BOOLEAN XGINew_Sense( USHORT tempbx , USHORT tempcx, PVB_DEVICE_INFO pVBInfo )
149{
150 USHORT temp , i , tempch ;
151
152 temp = tempbx & 0xFF ;
153 XGINew_SetReg1( pVBInfo->Part4Port , 0x11 , temp ) ;
154 temp = ( tempbx & 0xFF00 ) >> 8 ;
155 temp |= ( tempcx & 0x00FF ) ;
156 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x10 , ~0x1F , temp ) ;
157
158 for( i = 0 ; i < 10 ; i++ )
159 XGI_LongWait( pVBInfo) ;
160
161 tempch = ( tempcx & 0x7F00 ) >> 8 ;
162 temp = XGINew_GetReg1( pVBInfo->Part4Port , 0x03 ) ;
163 temp = temp ^ ( 0x0E ) ;
164 temp &= tempch ;
165
166 if ( temp > 0 )
167 return( 1 ) ;
168 else
169 return( 0 ) ;
170}
171
172#ifdef WIN2000
173/* --------------------------------------------------------------------- */
174/* Function : XGI_SenseLCD */
175/* Input : */
176/* Output : */
177/* Description : */
178/* --------------------------------------------------------------------- */
179UCHAR XGI_SenseLCD( PHW_DEVICE_EXTENSION pHWDE, PVB_DEVICE_INFO pVBInfo)
180{
181 USHORT tempax , tempbx , tempcx ;
182 UCHAR SoftSetting = XGI330_SoftSetting ;
183
184 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV ) )
185 return( 1 ) ;
186
187
188 if ( SoftSetting & HotPlugFunction ) /* Hot Plug Detection */
189 {
190 XGINew_SetRegAND( pVBInfo->Part4Port , 0x0F , 0x3F ) ;
191 tempbx = 0 ;
192 tempcx = 0x9010 ;
193 if ( XGINew_Sense( tempbx , tempcx, pVBInfo ) )
194 return( 1 ) ;
195
196 return( 0 ) ;
197 }
198 else /* Get LCD Info from EDID */
199 return(XGI_GetLCDDDCInfo(pHWDE, pVBInfo));
200}
201
202
203/* --------------------------------------------------------------------- */
204/* Function : XGI_GetLCDDDCInfo */
205/* Input : */
206/* Output : */
207/* Description : */
208/* --------------------------------------------------------------------- */
209UCHAR XGI_GetLCDDDCInfo( PHW_DEVICE_EXTENSION pHWDE , PVB_DEVICE_INFO pVBInfo)
210{
211 UCHAR tempah , tempbl , tempbh ;
212 USHORT tempbx , temp ;
213 UCHAR pjEDIDBuf[ 256 ] ;
214 ULONG ulBufferSize = 256 ;
215 UCHAR bMASK_OUTPUTSTATE_CRT2LCD = 2 ; /* 0423 shampoo */
216
217 bGetDdcInfo( pHWDE , MASK_OUTPUTSTATE_CRT2LCD , pjEDIDBuf , ulBufferSize ) ;
218 if ( ( *( ( PULONG )pjEDIDBuf ) == 0xFFFFFF00 ) && ( *( ( PULONG )( pjEDIDBuf + 4 ) ) == 0x00FFFFFF ) )
219 {
220 tempah = Panel1024x768 ;
221 tempbl=( *( pjEDIDBuf + 0x3A ) ) & 0xf0 ;
222
223 if ( tempbl != 0x40 )
224 {
225 tempah = Panel1600x1200 ;
226 if ( tempbl != 0x60 )
227 {
228 tempah = Panel1280x1024 ;
229 tempbh = ( *( pjEDIDBuf + 0x3B ) ) ;
230 if ( tempbh != 0x00 )
231 {
232 tempah = Panel1280x960 ;
233 if ( tempbh != 0x0C0 )
234 {
235 tempbx = ( ( *( pjEDIDBuf + 0x24 ) ) << 8 ) | ( *( pjEDIDBuf + 0x23 ) ) ;
236 tempah = Panel1280x1024 ;
237 if ( !( tempbx & 0x0100 ) )
238 {
239 tempah = Panel1024x768 ;
240 if ( !( tempbx & 0x0E00 ) )
241 {
242 tempah = Panel1280x1024 ;
243 }
244 }
245 }
246
247 if ( tempbx & 0x00FF )
248 {
249 temp = ScalingLCD ;
250 XGINew_SetRegOR( pVBInfo->P3d4 , 0x37 , temp ) ;
251 }
252 }
253 }
254 }
255 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x36 , ( ~0x07 ) , tempah ) ;
256 tempah = ( ( *( pjEDIDBuf + 0x47 ) ) & 0x06 ) ; /* Polarity */
257 tempah = ( tempah ^ 0x06 ) << 4 ;
258 tempah |= LCDSync ;
259 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x37 , ( ~LCDSyncBit ) , tempah ) ;
260 tempbh= XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
261 tempbh &= 0x07 ;
262 if ( tempbh == Panel1280x960 )
263 XGINew_SetRegAND( pVBInfo->P3d4 , 0x37 , 0x0E ) ;
264 }
265 else if ( *pjEDIDBuf == 0x20 )
266 {
267 tempah = Panel1024x768 ;
268 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x36 , ( ~0x07 ) , tempah ) ;
269 }
270 else
271 {
272 return( 0 ) ;
273 }
274
275 return( 1 ) ;
276}
277
278
279/* --------------------------------------------------------------------- */
280/* Function : XGI_DySense */
281/* Input : */
282/* Output : */
283/* Description : */
284/* --------------------------------------------------------------------- */
285BOOLEAN XGI_DySense( PHW_DEVICE_EXTENSION pHWDE , PUCHAR ujConnectStatus)
286{
287 UCHAR pre_CRD,pre_SR1E , pre_Part2_0 , pre_Part4_D ;
288 USHORT tempax , tempbx , tempcx , pushax , temp ;
289 VB_DEVICE_INFO VBINF;
290 PVB_DEVICE_INFO pVBInfo = &VBINF;
291 UCHAR OutputSelect = XGI330_OutputSelect ;
292 PXGI_HW_DEVICE_INFO HwDeviceExtension= pHWDE->pXGIHWDE ;
293 UCHAR bConnectStatus = 0 ;
294 pVBInfo->BaseAddr = HwDeviceExtension->pjIOAddress ;
295 pVBInfo->ROMAddr = pHWDE->pjVirtualRomBase ;
296
297 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
298 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
299 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
300 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
301 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
302 pushax = XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ; /* 0512 Fix Dysense hanged */
303 temp = ( pushax & 0x00FF ) | 0x80 ;
304 XGINew_SetRegOR( pVBInfo->P3d4 , 0x17 , temp ) ;
305 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
306 /* beginning of dynamic sense CRT1 */
307
308 pVBInfo->IF_DEF_CH7007 = 0;
309 if (pHWDE->bCH7007)
310 {
311 InitTo330Pointer( pHWDE->pXGIHWDE->jChipType, pVBInfo ) ;
312 HwDeviceExtension->pDevice = (PVOID)pHWDE;
313 pVBInfo->IF_DEF_CH7007 = 1;
314 /* [Billy] 2007/05/14 For CH7007 */
315 if ( pVBInfo->IF_DEF_CH7007 == 1 )
316 {
317 bConnectStatus = SenseCHTV(HwDeviceExtension->pDevice) ; /* 07/05/28 */
318 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , ~0x03 , (UCHAR)bConnectStatus ) ;
319 }
320 }
321 if(( pHWDE->jChipID >= XG40 ) || ( pHWDE->jChipID >= XG20 ))
322 {
323
324 if ( pHWDE->jChipID >= XG40 )
325 XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x4A ) ; /* write sense pattern 30->4a */
326 else
327 XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x5F ) ; /* write sense pattern */
328
329 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x53 , 0xFF , 0x02 ) ; /* enable sense DAC */
330 XGI_WaitDisply(pVBInfo) ;
331
332 if(XGINew_GetReg2( pVBInfo->P3c2 ) & 0x10 )
333 bConnectStatus |= Monitor1Sense ;
334
335 XGINew_SetRegAND( pVBInfo->P3d4 , 0x53 , 0xFD ) ; /* disable sense DAC */
336 XGINew_SetRegAND( pVBInfo->P3d4 , 0x57 , 0x00 ) ; /* clear sense pattern */
337
338
339 /* ---------- End of dynamic sense CRT1 ----------- */
340
341 /* ---------- beginning of dynamic sense VB ------------ */
342 pre_SR1E = XGINew_GetReg1( pVBInfo->P3c4 , 0x1E ) ;
343 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x20 ) ; /* Enable CRT2,work-a-round for 301B/301LV/302LV */
344 pre_Part2_0 = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
345 pre_Part4_D = XGINew_GetReg1( pVBInfo->Part4Port , 0x0D ) ;
346
347 if ( XGI_Is301C( pVBInfo ) ) /* 301C only */
348 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~0x07 , 0x01 ) ; /* Set Part4 0x0D D[2:0] to 001b */
349
350 /* tempax = 0 ; */
351 if ( !XGI_Is301LV( pVBInfo ) )
352 {
353 tempbx = XGI330_RGBSenseData2 ;
354 tempcx = 0x0E08 ;
355 if(XGINew_Sense( tempbx , tempcx, pVBInfo ) )
356 {
357 bConnectStatus |= Monitor2Sense ;
358 if ( OutputSelect & SetSCARTOutput )
359 {
360 bConnectStatus ^= ( Monitor2Sense | SCARTSense ) ;
361 }
362 }
363 }
364 if ( XGI_Is301C( pVBInfo ) ) /* 301C only */
365 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0D , 0x04 ) ; /* Set Part4 0x0D D[2]=1 for dynamic sense */
366
367 if ( ( XGINew_Is301B( pVBInfo ) ) )
368 XGINew_SetRegOR( pVBInfo->Part2Port , 0x00 , 0x0C ) ; /* ????????? */
369
370 if ( XGINew_SenseHiTV( HwDeviceExtension , pVBInfo) ) /* add by kuku for Dysense HiTV //start */
371 {
372 bConnectStatus|= YPbPrSense ;
373 }
374 else
375 {
376 tempbx = XGI330_YCSenseData2 ; /* Y/C Sense Data Ptr */
377 tempcx = 0x0604 ;
378 if ( XGINew_Sense( tempbx , tempcx , pVBInfo) )
379 bConnectStatus |= SVIDEOSense ;
380
381 if ( OutputSelect & BoardTVType )
382 {
383 tempbx = XGI330_VideoSenseData2 ;
384 tempcx = 0x0804 ;
385 if ( XGINew_Sense(tempbx , tempcx, pVBInfo) )
386 bConnectStatus|= AVIDEOSense ;
387 }
388 else
389 {
390 if ( !( bConnectStatus & SVIDEOSense ) )
391 {
392 tempbx = XGI330_VideoSenseData2 ;
393 tempcx = 0x0804 ;
394 if ( XGINew_Sense( tempbx , tempcx, pVBInfo ) )
395 bConnectStatus |= AVIDEOSense ;
396 }
397 }
398 } /* end */
399 /* DySenseVBCnt */
400
401 tempbx = 0 ;
402 tempcx = 0 ;
403 XGINew_Sense(tempbx , tempcx, pVBInfo ) ;
404
405 if ( !( bConnectStatus & Monitor2Sense ) )
406 {
407 if ( XGI_SenseLCD( pHWDE , pVBInfo ) )
408 bConnectStatus |= LCDSense ;
409 }
410
411 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , ~( AVIDEOSense | SVIDEOSense | LCDSense | Monitor2Sense | Monitor1Sense ) , bConnectStatus ) ;
412
413 XGINew_SetReg1( pVBInfo->Part4Port , 0x0D , pre_Part4_D ) ;
414 XGINew_SetReg1( pVBInfo->Part2Port , 0x00 , pre_Part2_0 ) ;
415 XGINew_SetReg1( pVBInfo->P3c4 , 0x1E , pre_SR1E ) ;
416
417 if ( XGI_Is301C( pVBInfo ) ) /* 301C only */
418 {
419 tempax = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
420 if ( tempax & 0x20 )
421 {
422 /* Reset VBPro */
423 for( tempcx = 2 ; tempcx > 0 ; tempcx-- )
424 {
425 tempax ^= 0x20 ;
426 XGINew_SetReg1( pVBInfo->Part2Port , 0x00 , tempax ) ;
427 }
428 }
429 }
430 /* End of dynamic sense VB */
431 }
432 else
433 {
434 XGI_SenseCRT1(pVBInfo) ;
435 XGI_GetSenseStatus( HwDeviceExtension, pVBInfo ) ; /* sense CRT2 */
436 bConnectStatus = XGINew_GetReg1( pVBInfo->P3d4 , 0x32 ) ;
437 }
438 temp = pushax & 0x00FF ; /* 0512 Fix Dysense hanged */
439 XGINew_SetReg1( pVBInfo->P3d4 , 0x17 , temp ) ;
440 if ( bConnectStatus )
441 {
442 *ujConnectStatus = bConnectStatus ;
443 return( 1 ) ;
444 }
445 else
446 return( 0 ) ;
447}
448
449#endif /* WIN2000 */
450
451/* --------------------------------------------------------------------- */
452/* Function : XGISetDPMS */
453/* Input : */
454/* Output : */
455/* Description : */
456/* --------------------------------------------------------------------- */
457VOID XGISetDPMS( PXGI_HW_DEVICE_INFO pXGIHWDE , ULONG VESA_POWER_STATE )
458{
459 USHORT ModeNo, ModeIdIndex ;
460 UCHAR temp ;
461 VB_DEVICE_INFO VBINF;
462 PVB_DEVICE_INFO pVBInfo = &VBINF;
463 pVBInfo->BaseAddr = (ULONG)pXGIHWDE->pjIOAddress ;
464 pVBInfo->ROMAddr = pXGIHWDE->pjVirtualRomBase ;
465
466
467 pVBInfo->IF_DEF_LVDS = 0 ;
468 pVBInfo->IF_DEF_CH7005 = 0 ;
469 pVBInfo->IF_DEF_HiVision = 1 ;
470 pVBInfo->IF_DEF_LCDA = 1 ;
471 pVBInfo->IF_DEF_CH7017 = 0 ;
472 pVBInfo->IF_DEF_YPbPr = 1 ;
473 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
474 pVBInfo->IF_DEF_VideoCapture = 0 ;
475 pVBInfo->IF_DEF_ScaleLCD = 0 ;
476 pVBInfo->IF_DEF_OEMUtil = 0 ;
477 pVBInfo->IF_DEF_PWD = 0 ;
478
479 InitTo330Pointer( pXGIHWDE->jChipType, pVBInfo ) ;
480 ReadVBIOSTablData( pXGIHWDE->jChipType , pVBInfo) ;
481
482 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
483 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
484 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
485 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
486 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
487 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
488 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
489 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
490 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
491 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
492 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
493 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
494 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
495 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
496 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
497 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
498 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
499
500 if ( pXGIHWDE->jChipType == XG27 )
501 {
502 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
503 {
504 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) & 0x20 )
505 {
506 pVBInfo->IF_DEF_LVDS = 1 ;
507 }
508 }
509 }
510
511 if ( pVBInfo->IF_DEF_CH7007 == 0 )
512 {
513 XGINew_SetModeScratch ( pXGIHWDE , pVBInfo ) ;
514 }
515 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ; /* 1.Openkey */
516 XGI_UnLockCRT2( pXGIHWDE , pVBInfo) ;
517 ModeNo = XGINew_GetReg1( pVBInfo->P3d4 , 0x34 ) ;
518 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
519 XGI_GetVGAType( pXGIHWDE , pVBInfo ) ;
520
521 if ( ( pXGIHWDE->ujVBChipID == VB_CHIP_301 ) || ( pXGIHWDE->ujVBChipID == VB_CHIP_302 ) || ( pVBInfo->IF_DEF_CH7007 == 1 ))
522 {
523 XGI_GetVBType( pVBInfo ) ;
524 XGI_GetVBInfo( ModeNo , ModeIdIndex , pXGIHWDE, pVBInfo ) ;
525 XGI_GetTVInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
526 XGI_GetLCDInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
527 }
528
529 if ( VESA_POWER_STATE == 0x00000400 )
530 XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , ( UCHAR )( XGINew_GetReg1( pVBInfo->Part4Port , 0x31 ) & 0xFE ) ) ;
531 else
532 XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , ( UCHAR )( XGINew_GetReg1( pVBInfo->Part4Port , 0x31 ) | 0x01 ) ) ;
533
534 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x1f ) ;
535 temp &= 0x3f ;
536 switch ( VESA_POWER_STATE )
537 {
538 case 0x00000000: /* on */
539 if ( ( pXGIHWDE->ujVBChipID == VB_CHIP_301 ) || ( pXGIHWDE->ujVBChipID == VB_CHIP_302 ) )
540 {
541 XGINew_SetReg1( pVBInfo->P3c4 , 0x1f , ( UCHAR )( temp | 0x00 ) ) ;
542 XGI_EnableBridge( pXGIHWDE, pVBInfo ) ;
543 }
544 else
545 {
546 if ( pXGIHWDE->jChipType == XG21 )
547 {
548 if ( pVBInfo->IF_DEF_LVDS == 1 )
549 {
550 XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
551 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
552 }
553 }
554 if ( pXGIHWDE->jChipType == XG27 )
555 {
556 if ( pVBInfo->IF_DEF_LVDS == 1 )
557 {
558 XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
559 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
560 }
561 }
562 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , ~0xC0 , 0x00 ) ;
563 XGINew_SetRegAND( pVBInfo->P3c4 , 0x01 , ~0x20 ) ; /* CRT on */
564
565 if ( pXGIHWDE->jChipType == XG21 )
566 {
567 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
568 if ( temp & 0xE0 )
569 {
570 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ; /* DVO ON */
571 XGI_SetXG21FPBits( pVBInfo );
572 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Enable write GPIOF */
573 /*XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~0x20 , 0x20 ) ;*/ /* LCD Display ON */
574 }
575 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
576 XGI_DisplayOn( pXGIHWDE, pVBInfo );
577 }
578 if ( pXGIHWDE->jChipType == XG27 )
579 {
580 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
581 if ( temp & 0xE0 )
582 {
583 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ; /* DVO ON */
584 XGI_SetXG27FPBits( pVBInfo );
585 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Enable write GPIOF */
586 /*XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~0x20 , 0x20 ) ;*/ /* LCD Display ON */
587 }
588 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
589 XGI_DisplayOn( pXGIHWDE, pVBInfo );
590 }
591 }
592 break ;
593 case 0x00000100: /* standby */
594 if ( pXGIHWDE->jChipType >= XG21 )
595 {
596 XGI_DisplayOff( pXGIHWDE, pVBInfo );
597 }
598
599 XGINew_SetReg1( pVBInfo->P3c4 , 0x1f , ( UCHAR )( temp | 0x40 ) ) ;
600 break ;
601 case 0x00000200: /* suspend */
602 if ( pXGIHWDE->jChipType == XG21 )
603 {
604 XGI_DisplayOff( pXGIHWDE, pVBInfo );
605 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
606 }
607 if ( pXGIHWDE->jChipType == XG27 )
608 {
609 XGI_DisplayOff( pXGIHWDE, pVBInfo );
610 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
611 }
612 XGINew_SetReg1( pVBInfo->P3c4 , 0x1f , ( UCHAR )( temp | 0x80 ) ) ;
613 break ;
614 case 0x00000400: /* off */
615 if ( (pXGIHWDE->ujVBChipID == VB_CHIP_301 ) || ( pXGIHWDE->ujVBChipID == VB_CHIP_302 ) )
616 {
617 XGINew_SetReg1( pVBInfo->P3c4 , 0x1f , ( UCHAR )( temp | 0xc0 ) ) ;
618 XGI_DisableBridge( pXGIHWDE, pVBInfo ) ;
619 }
620 else
621 {
622 if ( pXGIHWDE->jChipType == XG21 )
623 {
624 XGI_DisplayOff( pXGIHWDE, pVBInfo );
625
626 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
627
628 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
629 if ( temp & 0xE0 )
630 {
631 XGINew_SetRegAND( pVBInfo->P3c4 , 0x09 , ~0x80 ) ; /* DVO Off */
632 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Enable write GPIOF */
633 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* LCD Display OFF */
634 }
635 }
636 if ( pXGIHWDE->jChipType == XG27 )
637 {
638 XGI_DisplayOff( pXGIHWDE, pVBInfo );
639
640 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
641
642 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
643 if ( temp & 0xE0 )
644 {
645 XGINew_SetRegAND( pVBInfo->P3c4 , 0x09 , ~0x80 ) ; /* DVO Off */
646 }
647 }
648 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , ~0xC0 , 0xC0 ) ;
649 XGINew_SetRegOR( pVBInfo->P3c4 , 0x01 , 0x20 ) ; /* CRT Off */
650
651 if ( ( pXGIHWDE->jChipType == XG21 ) && ( pVBInfo->IF_DEF_LVDS == 1 ) )
652 {
653 XGI_XG21SetPanelDelay( 4,pVBInfo ) ;
654 XGI_XG21BLSignalVDD( 0x01 , 0x00, pVBInfo ) ; /* LVDS VDD off */
655 XGI_XG21SetPanelDelay( 5,pVBInfo ) ;
656 }
657 if ( ( pXGIHWDE->jChipType == XG27 ) && ( pVBInfo->IF_DEF_LVDS == 1 ) )
658 {
659 XGI_XG21SetPanelDelay( 4,pVBInfo ) ;
660 XGI_XG27BLSignalVDD( 0x01 , 0x00, pVBInfo ) ; /* LVDS VDD off */
661 XGI_XG21SetPanelDelay( 5,pVBInfo ) ;
662 }
663 }
664 break ;
665
666 default:
667 break ;
668 }
669 XGI_LockCRT2( pXGIHWDE , pVBInfo ) ;
670}
671
672
673
674/* --------------------------------------------------------------------- */
675/* Function : XGI_GetSenseStatus */
676/* Input : */
677/* Output : */
678/* Description : */
679/* --------------------------------------------------------------------- */
680void XGI_GetSenseStatus( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
681{
682 USHORT tempax = 0 , tempbx , tempcx , temp ,
683 P2reg0 = 0 , SenseModeNo = 0 , OutputSelect = *pVBInfo->pOutputSelect ,
684 ModeIdIndex , i ;
685 pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
686
687 if ( pVBInfo->IF_DEF_LVDS == 1 )
688 {
689 tempax = XGINew_GetReg1( pVBInfo->P3c4 , 0x1A ) ; /* ynlai 02/27/2002 */
690 tempbx = XGINew_GetReg1( pVBInfo->P3c4 , 0x1B ) ;
691 tempax = ( ( tempax & 0xFE ) >> 1 ) | ( tempbx << 8 ) ;
692 if ( tempax == 0x00 )
693 { /* Get Panel id from DDC */
694 temp = XGINew_GetLCDDDCInfo( HwDeviceExtension, pVBInfo ) ;
695 if ( temp == 1 )
696 { /* LCD connect */
697 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x39 , 0xFF , 0x01 ) ; /* set CR39 bit0="1" */
698 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x37 , 0xEF , 0x00 ) ; /* clean CR37 bit4="0" */
699 temp = LCDSense ;
700 }
701 else
702 { /* LCD don't connect */
703 temp = 0 ;
704 }
705 }
706 else
707 {
708 XGINew_GetPanelID(pVBInfo) ;
709 temp = LCDSense ;
710 }
711
712 tempbx = ~( LCDSense | AVIDEOSense | SVIDEOSense ) ;
713 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , tempbx , temp ) ;
714 }
715 else
716 { /* for 301 */
717 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
718 { /* for HiVision */
719 tempax = XGINew_GetReg1( pVBInfo->P3c4 , 0x38 ) ;
720 temp = tempax & 0x01 ;
721 tempax = XGINew_GetReg1( pVBInfo->P3c4 , 0x3A ) ;
722 temp = temp | ( tempax & 0x02 ) ;
723 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xA0 , temp ) ;
724 }
725 else
726 {
727 if ( XGI_BridgeIsOn( pVBInfo ) )
728 {
729 P2reg0 = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
730 if ( !XGINew_BridgeIsEnable( HwDeviceExtension, pVBInfo ) )
731 {
732 SenseModeNo = 0x2e ;
733 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x30 , 0x41 ) ; */
734 /* XGISetModeNew( HwDeviceExtension , 0x2e ) ; // ynlai InitMode */
735
736 temp = XGI_SearchModeID( SenseModeNo , &ModeIdIndex, pVBInfo ) ;
737 XGI_GetVGAType( HwDeviceExtension , pVBInfo) ;
738 XGI_GetVBType( pVBInfo ) ;
739 pVBInfo->SetFlag = 0x00 ;
740 pVBInfo->ModeType = ModeVGA ;
741 pVBInfo->VBInfo = SetCRT2ToRAMDAC | LoadDACFlag | SetInSlaveMode ;
742 XGI_GetLCDInfo( 0x2e , ModeIdIndex, pVBInfo ) ;
743 XGI_GetTVInfo( 0x2e , ModeIdIndex, pVBInfo ) ;
744 XGI_EnableBridge( HwDeviceExtension, pVBInfo ) ;
745 XGI_SetCRT2Group301( SenseModeNo , HwDeviceExtension, pVBInfo ) ;
746 XGI_SetCRT2ModeRegs( 0x2e , HwDeviceExtension, pVBInfo ) ;
747 /* XGI_DisableBridge( HwDeviceExtension, pVBInfo ) ; */
748 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ; /* Display Off 0212 */
749 for( i = 0 ; i < 20 ; i++ )
750 {
751 XGI_LongWait(pVBInfo) ;
752 }
753 }
754 XGINew_SetReg1( pVBInfo->Part2Port , 0x00 , 0x1c ) ;
755 tempax = 0 ;
756 tempbx = *pVBInfo->pRGBSenseData ;
757
758 if ( !( XGINew_Is301B( pVBInfo ) ) )
759 {
760 tempbx = *pVBInfo->pRGBSenseData2 ;
761 }
762
763 tempcx = 0x0E08 ;
764 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
765 {
766 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
767 {
768 tempax |= Monitor2Sense ;
769 }
770 }
771
772 if ( pVBInfo->VBType & VB_XGI301C)
773 {
774 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0d , 0x04 ) ;
775 }
776
777 if ( XGINew_SenseHiTV( HwDeviceExtension , pVBInfo) ) /* add by kuku for Multi-adapter sense HiTV */
778 {
779 tempax |= HiTVSense ;
780 if ( ( pVBInfo->VBType & VB_XGI301C ) )
781 {
782 tempax ^= ( HiTVSense | YPbPrSense ) ;
783 }
784 }
785
786 if ( !( tempax & ( HiTVSense | YPbPrSense ) ) ) /* start */
787 {
788
789 tempbx = *pVBInfo->pYCSenseData ;
790
791 if ( !( XGINew_Is301B( pVBInfo ) ) )
792 {
793 tempbx=*pVBInfo->pYCSenseData2;
794 }
795
796 tempcx = 0x0604 ;
797 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
798 {
799 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
800 {
801 tempax |= SVIDEOSense ;
802 }
803 }
804
805 if ( OutputSelect & BoardTVType )
806 {
807 tempbx = *pVBInfo->pVideoSenseData ;
808
809 if ( !( XGINew_Is301B( pVBInfo ) ) )
810 {
811 tempbx = *pVBInfo->pVideoSenseData2 ;
812 }
813
814 tempcx = 0x0804 ;
815 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
816 {
817 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
818 {
819 tempax |= AVIDEOSense ;
820 }
821 }
822 }
823 else
824 {
825 if ( !( tempax & SVIDEOSense ) )
826 {
827 tempbx = *pVBInfo->pVideoSenseData ;
828
829 if ( !( XGINew_Is301B( pVBInfo ) ) )
830 {
831 tempbx=*pVBInfo->pVideoSenseData2;
832 }
833
834 tempcx = 0x0804 ;
835 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
836 {
837 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
838 {
839 tempax |= AVIDEOSense ;
840 }
841 }
842 }
843 }
844 }
845 } /* end */
846 if ( !( tempax & Monitor2Sense ) )
847 {
848 if ( XGINew_SenseLCD( HwDeviceExtension, pVBInfo ) )
849 {
850 tempax |= LCDSense ;
851 }
852 }
853 tempbx = 0 ;
854 tempcx = 0 ;
855 XGINew_Sense(tempbx , tempcx, pVBInfo ) ;
856
857 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , ~0xDF , tempax ) ;
858 XGINew_SetReg1( pVBInfo->Part2Port , 0x00 , P2reg0 ) ;
859
860 if ( !( P2reg0 & 0x20 ) )
861 {
862 pVBInfo->VBInfo = DisableCRT2Display ;
863 /* XGI_SetCRT2Group301( SenseModeNo , HwDeviceExtension, pVBInfo ) ; */
864 }
865 }
866 }
867 XGI_DisableBridge( HwDeviceExtension, pVBInfo ) ; /* shampoo 0226 */
868
869}
870
871
872
873/* --------------------------------------------------------------------- */
874/* Function : XGINew_SenseLCD */
875/* Input : */
876/* Output : */
877/* Description : */
878/* --------------------------------------------------------------------- */
879USHORT XGINew_SenseLCD( PXGI_HW_DEVICE_INFO HwDeviceExtension ,PVB_DEVICE_INFO pVBInfo)
880{
881 /* USHORT SoftSetting ; */
882 USHORT temp ;
883
884 if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
885 temp = 0 ;
886 else
887 temp=XGINew_GetPanelID(pVBInfo) ;
888
889 if( !temp )
890 temp = XGINew_GetLCDDDCInfo( HwDeviceExtension, pVBInfo ) ;
891
892 return( temp ) ;
893}
894
895
896/* --------------------------------------------------------------------- */
897/* Function : XGINew_GetLCDDDCInfo */
898/* Input : */
899/* Output : */
900/* Description : */
901/* --------------------------------------------------------------------- */
902BOOLEAN XGINew_GetLCDDDCInfo( PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo)
903{
904 USHORT temp ;
905
906 /* add lcd sense */
907 if ( HwDeviceExtension->ulCRT2LCDType == LCD_UNKNOWN )
908 {
909 return( 0 ) ;
910 }
911 else
912 {
913 temp = ( USHORT )HwDeviceExtension->ulCRT2LCDType ;
914 switch( HwDeviceExtension->ulCRT2LCDType )
915 {
916 case LCD_INVALID:
917 case LCD_800x600:
918 case LCD_1024x768:
919 case LCD_1280x1024:
920 break ;
921
922 case LCD_640x480:
923 case LCD_1024x600:
924 case LCD_1152x864:
925 case LCD_1280x960:
926 case LCD_1152x768:
927 temp = 0 ;
928 break ;
929
930 case LCD_1400x1050:
931 case LCD_1280x768:
932 case LCD_1600x1200:
933 break ;
934
935 case LCD_1920x1440:
936 case LCD_2048x1536:
937 temp = 0 ;
938 break ;
939
940 default:
941 break ;
942 }
943 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x36 , 0xF0 , temp ) ;
944 return( 1 ) ;
945 }
946}
947
948
949/* --------------------------------------------------------------------- */
950/* Function : */
951/* Input : */
952/* Output : */
953/* Description : */
954/* --------------------------------------------------------------------- */
955BOOLEAN XGINew_GetPanelID(PVB_DEVICE_INFO pVBInfo )
956{
957 USHORT PanelTypeTable[ 16 ] = { SyncNN | PanelRGB18Bit | Panel800x600 | _PanelType00 ,
958 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType01 ,
959 SyncNN | PanelRGB18Bit | Panel800x600 | _PanelType02 ,
960 SyncNN | PanelRGB18Bit | Panel640x480 | _PanelType03 ,
961 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType04 ,
962 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType05 ,
963 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType06 ,
964 SyncNN | PanelRGB24Bit | Panel1024x768 | _PanelType07 ,
965 SyncNN | PanelRGB18Bit | Panel800x600 | _PanelType08 ,
966 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType09 ,
967 SyncNN | PanelRGB18Bit | Panel800x600 | _PanelType0A ,
968 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType0B ,
969 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType0C ,
970 SyncNN | PanelRGB24Bit | Panel1024x768 | _PanelType0D ,
971 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType0E ,
972 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType0F } ;
973 USHORT tempax , tempbx , temp ;
974 /* USHORT return_flag ; */
975
976 tempax = XGINew_GetReg1( pVBInfo->P3c4 , 0x1A ) ;
977 tempbx = tempax & 0x1E ;
978
979 if ( tempax == 0 )
980 return( 0 ) ;
981 else
982 {
983/*
984 if ( !( tempax & 0x10 ) )
985 {
986 if ( pVBInfo->IF_DEF_LVDS == 1 )
987 {
988 tempbx = 0 ;
989 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x38 ) ;
990 if ( temp & 0x40 )
991 tempbx |= 0x08 ;
992 if ( temp & 0x20 )
993 tempbx |= 0x02 ;
994 if ( temp & 0x01 )
995 tempbx |= 0x01 ;
996
997 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x39 ) ;
998 if ( temp & 0x80 )
999 tempbx |= 0x04 ;
1000 }
1001 else
1002 {
1003 return( 0 ) ;
1004 }
1005 }
1006*/
1007
1008 tempbx = tempbx >> 1 ;
1009 temp = tempbx & 0x00F ;
1010 XGINew_SetReg1( pVBInfo->P3d4 , 0x36 , temp ) ;
1011 tempbx-- ;
1012 tempbx = PanelTypeTable[ tempbx ] ;
1013
1014 temp = ( tempbx & 0xFF00 ) >> 8 ;
1015 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x37 , ~( LCDSyncBit | LCDRGB18Bit ) , temp ) ;
1016 return( 1 ) ;
1017 }
1018}
1019
1020
1021/* --------------------------------------------------------------------- */
1022/* Function : XGINew_BridgeIsEnable */
1023/* Input : */
1024/* Output : */
1025/* Description : */
1026/* --------------------------------------------------------------------- */
1027BOOLEAN XGINew_BridgeIsEnable( PXGI_HW_DEVICE_INFO HwDeviceExtension ,PVB_DEVICE_INFO pVBInfo)
1028{
1029 USHORT flag ;
1030
1031 if ( XGI_BridgeIsOn( pVBInfo ) == 0 )
1032 {
1033 flag = XGINew_GetReg1( pVBInfo->Part1Port , 0x0 ) ;
1034
1035 if ( flag & 0x050 )
1036 {
1037 return( 1 ) ;
1038 }
1039 else
1040 {
1041 return( 0 ) ;
1042 }
1043
1044 }
1045 return( 0 ) ;
1046}
1047
1048/* ------------------------------------------------------ */
1049/* Function : XGINew_SenseHiTV */
1050/* Input : */
1051/* Output : */
1052/* Description : */
1053/* ------------------------------------------------------ */
1054BOOLEAN XGINew_SenseHiTV( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo )
1055{
1056 USHORT tempbx , tempcx , temp , i , tempch;
1057
1058 tempbx = *pVBInfo->pYCSenseData2 ;
1059
1060 tempcx = 0x0604 ;
1061
1062 temp = tempbx & 0xFF ;
1063 XGINew_SetReg1( pVBInfo->Part4Port , 0x11 , temp ) ;
1064 temp = ( tempbx & 0xFF00 ) >> 8 ;
1065 temp |= ( tempcx & 0x00FF ) ;
1066 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x10 , ~0x1F , temp ) ;
1067
1068 for( i = 0 ; i < 10 ; i++ )
1069 XGI_LongWait(pVBInfo) ;
1070
1071 tempch = ( tempcx & 0xFF00 ) >> 8;
1072 temp = XGINew_GetReg1( pVBInfo->Part4Port , 0x03 ) ;
1073 temp = temp ^ ( 0x0E ) ;
1074 temp &= tempch ;
1075
1076 if ( temp != tempch )
1077 return( 0 ) ;
1078
1079 tempbx = *pVBInfo->pVideoSenseData2 ;
1080
1081 tempcx = 0x0804 ;
1082 temp = tempbx & 0xFF ;
1083 XGINew_SetReg1( pVBInfo->Part4Port , 0x11 , temp ) ;
1084 temp = ( tempbx & 0xFF00 ) >> 8 ;
1085 temp |= ( tempcx & 0x00FF ) ;
1086 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x10 , ~0x1F , temp ) ;
1087
1088 for( i = 0 ; i < 10 ; i++ )
1089 XGI_LongWait(pVBInfo) ;
1090
1091 tempch = ( tempcx & 0xFF00 ) >> 8;
1092 temp = XGINew_GetReg1( pVBInfo->Part4Port , 0x03 ) ;
1093 temp = temp ^ ( 0x0E ) ;
1094 temp &= tempch ;
1095
1096 if ( temp != tempch )
1097 return( 0 ) ;
1098 else
1099 {
1100 tempbx = 0x3FF ;
1101 tempcx = 0x0804 ;
1102 temp = tempbx & 0xFF ;
1103 XGINew_SetReg1( pVBInfo->Part4Port , 0x11 , temp ) ;
1104 temp = ( tempbx & 0xFF00 ) >> 8 ;
1105 temp |= ( tempcx & 0x00FF ) ;
1106 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x10 , ~0x1F , temp ) ;
1107
1108 for( i = 0 ; i < 10 ; i++ )
1109 XGI_LongWait(pVBInfo) ;
1110
1111 tempch = ( tempcx & 0xFF00 ) >> 8;
1112 temp = XGINew_GetReg1( pVBInfo->Part4Port , 0x03 ) ;
1113 temp = temp ^ ( 0x0E ) ;
1114 temp &= tempch ;
1115
1116 if ( temp != tempch )
1117 return( 1 ) ;
1118 else
1119 return( 0 ) ;
1120 }
1121}
1122
1123
1124
1125/*
1126;-----------------------------------------------------------------------------
1127; Description: Get Panel support
1128; O/P :
1129; BL: Panel ID=81h for no scaler LVDS
1130; BH: Panel enhanced Mode Count
1131; CX: Panel H. resolution
1132; DX: PAnel V. resolution
1133;-----------------------------------------------------------------------------
1134*/
1135void XGI_XG21Fun14Sub70( PVB_DEVICE_INFO pVBInfo , PX86_REGS pBiosArguments )
1136{
1137
1138 USHORT ModeIdIndex;
1139 USHORT ModeNo;
1140
1141 USHORT EModeCount;
1142 USHORT lvdstableindex;
1143
1144 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
1145 pBiosArguments->h.bl = 0x81;
1146 pBiosArguments->x.cx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
1147 pBiosArguments->x.dx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
1148 EModeCount = 0;
1149
1150 pBiosArguments->x.ax = 0x0014;
1151 for( ModeIdIndex = 0 ; ; ModeIdIndex ++ )
1152 {
1153 ModeNo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeID;
1154 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeID == 0xFF )
1155 {
1156 pBiosArguments->h.bh = (UCHAR) EModeCount;
1157 return;
1158 }
1159 if ( !XGI_XG21CheckLVDSMode( ModeNo , ModeIdIndex, pVBInfo) )
1160 {
1161 continue;
1162 }
1163 EModeCount++ ;
1164 }
1165}
1166/*(
1167;-----------------------------------------------------------------------------
1168;
1169; Description: Get Panel mode ID for enhanced mode
1170; I/P : BH: EModeIndex ( which < Panel enhanced Mode Count )
1171; O/P :
1172; BL: Mode ID
1173; CX: H. resolution of the assigned by the index
1174; DX: V. resolution of the assigned by the index
1175;
1176;-----------------------------------------------------------------------------
1177*/
1178void XGI_XG21Fun14Sub71( PVB_DEVICE_INFO pVBInfo , PX86_REGS pBiosArguments )
1179{
1180
1181 USHORT EModeCount;
1182 USHORT ModeIdIndex,resindex;
1183 USHORT ModeNo;
1184 USHORT EModeIndex = pBiosArguments->h.bh;
1185
1186 EModeCount = 0;
1187 for( ModeIdIndex = 0 ; ; ModeIdIndex ++ )
1188 {
1189 ModeNo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeID;
1190 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeID == 0xFF )
1191 {
1192 pBiosArguments->x.ax = 0x0114;
1193 return;
1194 }
1195 if ( !XGI_XG21CheckLVDSMode( ModeNo , ModeIdIndex, pVBInfo) )
1196 {
1197 continue;
1198 }
1199 if (EModeCount == EModeIndex)
1200 {
1201 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
1202 pBiosArguments->h.bl = (UCHAR) ModeNo;
1203 pBiosArguments->x.cx = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
1204 pBiosArguments->x.dx = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
1205 pBiosArguments->x.ax = 0x0014;
1206 }
1207 EModeCount++ ;
1208
1209 }
1210
1211}
1212/*
1213;-----------------------------------------------------------------------------
1214;
1215; Description: Validate Panel modes ID support
1216; I/P :
1217; BL: ModeID
1218; O/P :
1219; CX: H. resolution of the assigned by the index
1220; DX: V. resolution of the assigned by the index
1221;
1222;-----------------------------------------------------------------------------
1223*/
1224void XGI_XG21Fun14Sub72( PVB_DEVICE_INFO pVBInfo , PX86_REGS pBiosArguments )
1225{
1226 USHORT ModeIdIndex,resindex;
1227 USHORT ModeNo;
1228
1229
1230 ModeNo = pBiosArguments->h.bl ;
1231 XGI_SearchModeID( ModeNo, &ModeIdIndex, pVBInfo);
1232 if ( !XGI_XG21CheckLVDSMode( ModeNo , ModeIdIndex, pVBInfo) )
1233 {
1234 pBiosArguments->x.cx = 0;
1235 pBiosArguments->x.dx = 0;
1236 pBiosArguments->x.ax = 0x0114;
1237 return;
1238 }
1239 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
1240 if ( ModeNo <= 0x13 )
1241 {
1242 pBiosArguments->x.cx = pVBInfo->StResInfo[ resindex ].HTotal ;
1243 pBiosArguments->x.dx = pVBInfo->StResInfo[ resindex ].VTotal ;
1244 }
1245 else
1246 {
1247 pBiosArguments->x.cx = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
1248 pBiosArguments->x.dx = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
1249 }
1250
1251 pBiosArguments->x.ax = 0x0014;
1252
1253}
1254
1255/*
1256;-----------------------------------------------------------------------------
1257; Description: Get Customized Panel misc. information support
1258; I/P : Select
1259; to get panel horizontal timing
1260; to get panel vertical timing
1261; to get channel clock parameter
1262; to get panel misc information
1263;
1264; O/P :
1265; BL: for input Select = 0 ;
1266; BX: *Value1 = Horizontal total
1267; CX: *Value2 = Horizontal front porch
1268; DX: *Value2 = Horizontal sync width
1269; BL: for input Select = 1 ;
1270; BX: *Value1 = Vertical total
1271; CX: *Value2 = Vertical front porch
1272; DX: *Value2 = Vertical sync width
1273; BL: for input Select = 2 ;
1274; BX: Value1 = The first CLK parameter
1275; CX: Value2 = The second CLK parameter
1276; BL: for input Select = 4 ;
1277; BX[15]: *Value1 D[15] VESA V. Polarity
1278; BX[14]: *Value1 D[14] VESA H. Polarity
1279; BX[7]: *Value1 D[7] Panel V. Polarity
1280; BX[6]: *Value1 D[6] Panel H. Polarity
1281;-----------------------------------------------------------------------------
1282*/
1283void XGI_XG21Fun14Sub73( PVB_DEVICE_INFO pVBInfo , PX86_REGS pBiosArguments )
1284{
1285 UCHAR Select;
1286
1287 USHORT lvdstableindex;
1288
1289 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
1290 Select = pBiosArguments->h.bl;
1291
1292 switch (Select)
1293 {
1294 case 0:
1295 pBiosArguments->x.bx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
1296 pBiosArguments->x.cx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
1297 pBiosArguments->x.dx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
1298 break;
1299 case 1:
1300 pBiosArguments->x.bx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
1301 pBiosArguments->x.cx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
1302 pBiosArguments->x.dx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
1303 break;
1304 case 2:
1305 pBiosArguments->x.bx = pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1;
1306 pBiosArguments->x.cx = pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2;
1307 break;
1308 case 4:
1309 pBiosArguments->x.bx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability;
1310 break;
1311 }
1312
1313 pBiosArguments->x.ax = 0x0014;
1314}
1315
1316
1317void XGI_XG21Fun14( PXGI_HW_DEVICE_INFO pXGIHWDE, PX86_REGS pBiosArguments)
1318{
1319 VB_DEVICE_INFO VBINF;
1320 PVB_DEVICE_INFO pVBInfo = &VBINF;
1321
1322 pVBInfo->IF_DEF_LVDS = 0 ;
1323 pVBInfo->IF_DEF_CH7005 = 0 ;
1324 pVBInfo->IF_DEF_HiVision = 1 ;
1325 pVBInfo->IF_DEF_LCDA = 1 ;
1326 pVBInfo->IF_DEF_CH7017 = 0 ;
1327 pVBInfo->IF_DEF_YPbPr = 1 ;
1328 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
1329 pVBInfo->IF_DEF_VideoCapture = 0 ;
1330 pVBInfo->IF_DEF_ScaleLCD = 0 ;
1331 pVBInfo->IF_DEF_OEMUtil = 0 ;
1332 pVBInfo->IF_DEF_PWD = 0 ;
1333
1334 InitTo330Pointer( pXGIHWDE->jChipType, pVBInfo ) ;
1335 ReadVBIOSTablData( pXGIHWDE->jChipType , pVBInfo) ;
1336
1337 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
1338 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
1339 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
1340 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
1341 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
1342 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
1343 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
1344 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
1345 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
1346 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
1347 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
1348 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
1349 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
1350 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
1351 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
1352 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
1353 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
1354
1355 switch(pBiosArguments->x.ax)
1356 {
1357 case 0x1470:
1358 XGI_XG21Fun14Sub70( pVBInfo , pBiosArguments ) ;
1359 break;
1360 case 0x1471:
1361 XGI_XG21Fun14Sub71( pVBInfo , pBiosArguments ) ;
1362 break;
1363 case 0x1472:
1364 XGI_XG21Fun14Sub72( pVBInfo , pBiosArguments ) ;
1365 break;
1366 case 0x1473:
1367 XGI_XG21Fun14Sub73( pVBInfo , pBiosArguments ) ;
1368 break;
1369 }
1370}
diff --git a/drivers/staging/xgifb/vb_ext.h b/drivers/staging/xgifb/vb_ext.h
new file mode 100644
index 00000000000..9a72f5ecb71
--- /dev/null
+++ b/drivers/staging/xgifb/vb_ext.h
@@ -0,0 +1,32 @@
1#ifndef _VBEXT_
2#define _VBEXT_
3
4struct DWORDREGS {
5 ULONG Eax, Ebx, Ecx, Edx, Esi, Edi, Ebp;
6};
7
8struct WORDREGS {
9 USHORT ax, hi_ax, bx, hi_bx, cx, hi_cx, dx, hi_dx, si, hi_si, di ,hi_di, bp, hi_bp;
10};
11
12struct BYTEREGS {
13 UCHAR al, ah, hi_al, hi_ah, bl, bh, hi_bl, hi_bh, cl, ch, hi_cl, hi_ch, dl, dh, hi_dl, hi_dh;
14};
15
16typedef union _X86_REGS {
17 struct DWORDREGS e;
18 struct WORDREGS x;
19 struct BYTEREGS h;
20} X86_REGS, *PX86_REGS;
21
22extern void XGI_XG21Fun14( PXGI_HW_DEVICE_INFO pXGIHWDE, PX86_REGS pBiosArguments);
23extern void XGISetDPMS( PXGI_HW_DEVICE_INFO pXGIHWDE , ULONG VESA_POWER_STATE ) ;
24extern void XGI_GetSenseStatus( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo );
25extern void XGINew_SetModeScratch ( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo ) ;
26extern void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo);
27extern USHORT XGINew_SenseLCD(PXGI_HW_DEVICE_INFO,PVB_DEVICE_INFO pVBInfo);
28#ifdef WIN2000
29extern BOOLEAN XGI_DySense( PHW_DEVICE_EXTENSION pHWDE , PUCHAR ujConnectStatus );
30#endif /* WIN2000 */
31
32#endif
diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c
new file mode 100644
index 00000000000..b85ca9ba807
--- /dev/null
+++ b/drivers/staging/xgifb/vb_init.c
@@ -0,0 +1,3444 @@
1#include "osdef.h"
2#include "vgatypes.h"
3
4
5#ifdef LINUX_KERNEL
6#include <linux/version.h>
7#include <linux/types.h>
8#include <linux/delay.h> /* udelay */
9#include "XGIfb.h"
10/*#if LINUX_VERSxION_CODE >= KERNEL_VERSION(2,5,0)
11#include <video/XGIfb.h>
12#else
13#include <linux/XGIfb.h>
14#endif */
15#endif
16
17#ifdef WIN2000
18#include <dderror.h>
19#include <devioctl.h>
20#include <miniport.h>
21#include <ntddvdeo.h>
22#include <video.h>
23#include "xgiv.h"
24#include "dd_i2c.h"
25#include "tools.h"
26#endif
27
28#include "vb_def.h"
29#include "vb_struct.h"
30#include "vb_util.h"
31#include "vb_setmode.h"
32#include "vb_init.h"
33#include "vb_ext.h"
34
35#ifdef LINUX_XF86
36#include "xf86.h"
37#include "xf86PciInfo.h"
38#include "xgi.h"
39#include "xgi_regs.h"
40#endif
41
42#ifdef LINUX_KERNEL
43#include <asm/io.h>
44#include <linux/types.h>
45#endif
46
47
48
49
50UCHAR XGINew_ChannelAB,XGINew_DataBusWidth;
51
52USHORT XGINew_DRAMType[17][5]={{0x0C,0x0A,0x02,0x40,0x39},{0x0D,0x0A,0x01,0x40,0x48},
53 {0x0C,0x09,0x02,0x20,0x35},{0x0D,0x09,0x01,0x20,0x44},
54 {0x0C,0x08,0x02,0x10,0x31},{0x0D,0x08,0x01,0x10,0x40},
55 {0x0C,0x0A,0x01,0x20,0x34},{0x0C,0x09,0x01,0x08,0x32},
56 {0x0B,0x08,0x02,0x08,0x21},{0x0C,0x08,0x01,0x08,0x30},
57 {0x0A,0x08,0x02,0x04,0x11},{0x0B,0x0A,0x01,0x10,0x28},
58 {0x09,0x08,0x02,0x02,0x01},{0x0B,0x09,0x01,0x08,0x24},
59 {0x0B,0x08,0x01,0x04,0x20},{0x0A,0x08,0x01,0x02,0x10},
60 {0x09,0x08,0x01,0x01,0x00}};
61
62USHORT XGINew_SDRDRAM_TYPE[13][5]=
63{
64{ 2,12, 9,64,0x35},
65{ 1,13, 9,64,0x44},
66{ 2,12, 8,32,0x31},
67{ 2,11, 9,32,0x25},
68{ 1,12, 9,32,0x34},
69{ 1,13, 8,32,0x40},
70{ 2,11, 8,16,0x21},
71{ 1,12, 8,16,0x30},
72{ 1,11, 9,16,0x24},
73{ 1,11, 8, 8,0x20},
74{ 2, 9, 8, 4,0x01},
75{ 1,10, 8, 4,0x10},
76{ 1, 9, 8, 2,0x00}
77};
78
79USHORT XGINew_DDRDRAM_TYPE[4][5]=
80{
81{ 2,12, 9,64,0x35},
82{ 2,12, 8,32,0x31},
83{ 2,11, 8,16,0x21},
84{ 2, 9, 8, 4,0x01}
85};
86USHORT XGINew_DDRDRAM_TYPE340[4][5]=
87{
88{ 2,13, 9,64,0x45},
89{ 2,12, 9,32,0x35},
90{ 2,12, 8,16,0x31},
91{ 2,11, 8, 8,0x21}
92};
93USHORT XGINew_DDRDRAM_TYPE20[12][5]=
94{
95{ 2,14,11,128,0x5D},
96{ 2,14,10,64,0x59},
97{ 2,13,11,64,0x4D},
98{ 2,14, 9,32,0x55},
99{ 2,13,10,32,0x49},
100{ 2,12,11,32,0x3D},
101{ 2,14, 8,16,0x51},
102{ 2,13, 9,16,0x45},
103{ 2,12,10,16,0x39},
104{ 2,13, 8, 8,0x41},
105{ 2,12, 9, 8,0x35},
106{ 2,12, 8, 4,0x31}
107};
108
109void XGINew_SetDRAMSize_340(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO);
110void XGINew_SetDRAMSize_310(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO);
111void XGINew_SetMemoryClock(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
112void XGINew_SetDRAMModeRegister(PVB_DEVICE_INFO );
113void XGINew_SetDRAMModeRegister340( PXGI_HW_DEVICE_INFO HwDeviceExtension );
114void XGINew_SetDRAMDefaultRegister340(PXGI_HW_DEVICE_INFO HwDeviceExtension, ULONG, PVB_DEVICE_INFO );
115UCHAR XGINew_GetXG20DRAMType( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo);
116BOOLEAN XGIInitNew( PXGI_HW_DEVICE_INFO HwDeviceExtension) ;
117
118int XGINew_DDRSizing340( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO );
119void XGINew_DisableRefresh( PXGI_HW_DEVICE_INFO ,PVB_DEVICE_INFO) ;
120void XGINew_CheckBusWidth_310( PVB_DEVICE_INFO) ;
121int XGINew_SDRSizing(PVB_DEVICE_INFO);
122int XGINew_DDRSizing( PVB_DEVICE_INFO );
123void XGINew_EnableRefresh( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO);
124int XGINew_RAMType; /*int ModeIDOffset,StandTable,CRT1Table,ScreenOffset,REFIndex;*/
125ULONG UNIROM; /* UNIROM */
126BOOLEAN ChkLFB( PVB_DEVICE_INFO );
127void XGINew_Delay15us(ULONG);
128void SetPowerConsume (PXGI_HW_DEVICE_INFO HwDeviceExtension,ULONG XGI_P3d4Port);
129void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo);
130void XGINew_DDR1x_MRS_XG20( ULONG P3c4 , PVB_DEVICE_INFO pVBInfo);
131void XGINew_SetDRAMModeRegister_XG20( PXGI_HW_DEVICE_INFO HwDeviceExtension );
132void XGINew_SetDRAMModeRegister_XG27( PXGI_HW_DEVICE_INFO HwDeviceExtension );
133void XGINew_ChkSenseStatus ( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo ) ;
134void XGINew_SetModeScratch ( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo ) ;
135void XGINew_GetXG21Sense(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo) ;
136UCHAR GetXG21FPBits(PVB_DEVICE_INFO pVBInfo);
137void XGINew_GetXG27Sense(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo) ;
138UCHAR GetXG27FPBits(PVB_DEVICE_INFO pVBInfo);
139
140#ifdef WIN2000
141/* [Billy] 2007/05/20 For CH7007 */
142extern UCHAR CH7007TVReg_UNTSC[][8],CH7007TVReg_ONTSC[][8],CH7007TVReg_UPAL[][8],CH7007TVReg_OPAL[][8];
143extern UCHAR XGI7007_CHTVVCLKUNTSC[],XGI7007_CHTVVCLKONTSC[],XGI7007_CHTVVCLKUPAL[],XGI7007_CHTVVCLKOPAL[];
144#endif
145
146#ifdef LINUX_KERNEL
147void DelayUS(ULONG MicroSeconds)
148{
149 udelay(MicroSeconds);
150}
151#endif
152
153/* --------------------------------------------------------------------- */
154/* Function : XGIInitNew */
155/* Input : */
156/* Output : */
157/* Description : */
158/* --------------------------------------------------------------------- */
159BOOLEAN XGIInitNew( PXGI_HW_DEVICE_INFO HwDeviceExtension )
160{
161
162 VB_DEVICE_INFO VBINF;
163 PVB_DEVICE_INFO pVBInfo = &VBINF;
164 UCHAR i , temp = 0 , temp1 ;
165 // VBIOSVersion[ 5 ] ;
166 PUCHAR volatile pVideoMemory;
167
168 /* ULONG j, k ; */
169
170 PXGI_DSReg pSR ;
171
172 ULONG Temp ;
173
174 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
175
176 pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ;
177
178 pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
179
180 pVideoMemory = ( PUCHAR )pVBInfo->ROMAddr;
181
182
183// Newdebugcode( 0x99 ) ;
184
185
186 /* if ( pVBInfo->ROMAddr == 0 ) */
187 /* return( FALSE ) ; */
188
189 if ( pVBInfo->FBAddr == 0 )
190{
191 printk("\n pVBInfo->FBAddr == 0 ");
192 return( FALSE ) ;
193}
194printk("1");
195 if ( pVBInfo->BaseAddr == 0 )
196{
197 printk("\npVBInfo->BaseAddr == 0 ");
198 return( FALSE ) ;
199}
200printk("2");
201
202 XGINew_SetReg3( ( pVBInfo->BaseAddr + 0x12 ) , 0x67 ) ; /* 3c2 <- 67 ,ynlai */
203
204 pVBInfo->ISXPDOS = 0 ;
205printk("3");
206
207if ( !HwDeviceExtension->bIntegratedMMEnabled )
208{
209 return( FALSE ) ; /* alan */
210}
211printk("4");
212
213// XGI_MemoryCopy( VBIOSVersion , HwDeviceExtension->szVBIOSVer , 4 ) ;
214
215 // VBIOSVersion[ 4 ] = 0x0 ;
216
217 /* 09/07/99 modify by domao */
218
219 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
220 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
221 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
222 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
223 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
224 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
225 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
226 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
227 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
228 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
229 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
230 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
231 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
232 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
233 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
234 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
235 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
236printk("5");
237
238 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
239 XGI_GetVBType( pVBInfo ) ; /* Run XGI_GetVBType before InitTo330Pointer */
240
241 InitTo330Pointer( HwDeviceExtension->jChipType, pVBInfo ) ;
242
243 /* ReadVBIOSData */
244 ReadVBIOSTablData( HwDeviceExtension->jChipType , pVBInfo) ;
245
246 /* 1.Openkey */
247 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
248printk("6");
249
250 /* GetXG21Sense (GPIO) */
251 if ( HwDeviceExtension->jChipType == XG21 )
252 {
253 XGINew_GetXG21Sense(HwDeviceExtension, pVBInfo) ;
254 }
255 if ( HwDeviceExtension->jChipType == XG27 )
256 {
257 XGINew_GetXG27Sense(HwDeviceExtension, pVBInfo) ;
258 }
259printk("7");
260
261 /* 2.Reset Extended register */
262
263 for( i = 0x06 ; i < 0x20 ; i++ )
264 XGINew_SetReg1( pVBInfo->P3c4 , i , 0 ) ;
265
266 for( i = 0x21 ; i <= 0x27 ; i++ )
267 XGINew_SetReg1( pVBInfo->P3c4 , i , 0 ) ;
268
269 /* for( i = 0x06 ; i <= 0x27 ; i++ ) */
270 /* XGINew_SetReg1( pVBInfo->P3c4 , i , 0 ) ; */
271
272printk("8");
273
274 if(( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40))
275 {
276 for( i = 0x31 ; i <= 0x3B ; i++ )
277 XGINew_SetReg1( pVBInfo->P3c4 , i , 0 ) ;
278 }
279 else
280 {
281 for( i = 0x31 ; i <= 0x3D ; i++ )
282 XGINew_SetReg1( pVBInfo->P3c4 , i , 0 ) ;
283 }
284printk("9");
285
286 if ( HwDeviceExtension->jChipType == XG42 ) /* [Hsuan] 2004/08/20 Auto over driver for XG42 */
287 XGINew_SetReg1( pVBInfo->P3c4 , 0x3B , 0xC0 ) ;
288
289 /* for( i = 0x30 ; i <= 0x3F ; i++ ) */
290 /* XGINew_SetReg1( pVBInfo->P3d4 , i , 0 ) ; */
291
292 for( i = 0x79 ; i <= 0x7C ; i++ )
293 XGINew_SetReg1( pVBInfo->P3d4 , i , 0 ) ; /* shampoo 0208 */
294
295printk("10");
296
297 if ( HwDeviceExtension->jChipType >= XG20 )
298 XGINew_SetReg1( pVBInfo->P3d4 , 0x97 , *pVBInfo->pXGINew_CR97 ) ;
299
300 /* 3.SetMemoryClock
301
302 if ( HwDeviceExtension->jChipType >= XG40 )
303 XGINew_RAMType = ( int )XGINew_GetXG20DRAMType( HwDeviceExtension , pVBInfo) ;
304
305 if ( HwDeviceExtension->jChipType < XG40 )
306 XGINew_SetMemoryClock( HwDeviceExtension , pVBInfo ) ; */
307
308printk("11");
309
310 /* 4.SetDefExt1Regs begin */
311 XGINew_SetReg1( pVBInfo->P3c4 , 0x07 , *pVBInfo->pSR07 ) ;
312 if ( HwDeviceExtension->jChipType == XG27 )
313 {
314 XGINew_SetReg1( pVBInfo->P3c4 , 0x40 , *pVBInfo->pSR40 ) ;
315 XGINew_SetReg1( pVBInfo->P3c4 , 0x41 , *pVBInfo->pSR41 ) ;
316 }
317 XGINew_SetReg1( pVBInfo->P3c4 , 0x11 , 0x0F ) ;
318 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , *pVBInfo->pSR1F ) ;
319 /* XGINew_SetReg1( pVBInfo->P3c4 , 0x20 , 0x20 ) ; */
320 XGINew_SetReg1( pVBInfo->P3c4 , 0x20 , 0xA0 ) ; /* alan, 2001/6/26 Frame buffer can read/write SR20 */
321 XGINew_SetReg1( pVBInfo->P3c4 , 0x36 , 0x70 ) ; /* Hsuan, 2006/01/01 H/W request for slow corner chip */
322 if ( HwDeviceExtension->jChipType == XG27 ) /* Alan 12/07/2006 */
323 XGINew_SetReg1( pVBInfo->P3c4 , 0x36 , *pVBInfo->pSR36 ) ;
324
325 /* SR11 = 0x0F ; */
326 /* XGINew_SetReg1( pVBInfo->P3c4 , 0x11 , SR11 ) ; */
327
328printk("12");
329
330 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
331 {
332// /* Set AGP Rate */
333// temp1 = XGINew_GetReg1( pVBInfo->P3c4 , 0x3B ) ;
334// temp1 &= 0x02 ;
335// if ( temp1 == 0x02 )
336// {
337// XGINew_SetReg4( 0xcf8 , 0x80000000 ) ;
338// ChipsetID = XGINew_GetReg3( 0x0cfc ) ;
339// XGINew_SetReg4( 0xcf8 , 0x8000002C ) ;
340// VendorID = XGINew_GetReg3( 0x0cfc ) ;
341// VendorID &= 0x0000FFFF ;
342// XGINew_SetReg4( 0xcf8 , 0x8001002C ) ;
343// GraphicVendorID = XGINew_GetReg3( 0x0cfc ) ;
344// GraphicVendorID &= 0x0000FFFF;
345//
346// if ( ChipsetID == 0x7301039 )
347/// XGINew_SetReg1( pVBInfo->P3d4 , 0x5F , 0x09 ) ;
348//
349// ChipsetID &= 0x0000FFFF ;
350///
351// if ( ( ChipsetID == 0x700E ) || ( ChipsetID == 0x1022 ) || ( ChipsetID == 0x1106 ) || ( ChipsetID == 0x10DE ) )
352// {
353// if ( ChipsetID == 0x1106 )
354// {
355// if ( ( VendorID == 0x1019 ) && ( GraphicVendorID == 0x1019 ) )
356// XGINew_SetReg1( pVBInfo->P3d4 , 0x5F , 0x0D ) ;
357// else
358// XGINew_SetReg1( pVBInfo->P3d4 , 0x5F , 0x0B ) ;
359// }
360// else
361// XGINew_SetReg1( pVBInfo->P3d4 , 0x5F , 0x0B ) ;
362// }
363// }
364
365printk("13");
366
367 if ( HwDeviceExtension->jChipType >= XG40 )
368 {
369 /* Set AGP customize registers (in SetDefAGPRegs) Start */
370 for( i = 0x47 ; i <= 0x4C ; i++ )
371 XGINew_SetReg1( pVBInfo->P3d4 , i , pVBInfo->AGPReg[ i - 0x47 ] ) ;
372
373 for( i = 0x70 ; i <= 0x71 ; i++ )
374 XGINew_SetReg1( pVBInfo->P3d4 , i , pVBInfo->AGPReg[ 6 + i - 0x70 ] ) ;
375
376 for( i = 0x74 ; i <= 0x77 ; i++ )
377 XGINew_SetReg1( pVBInfo->P3d4 , i , pVBInfo->AGPReg[ 8 + i - 0x74 ] ) ;
378 /* Set AGP customize registers (in SetDefAGPRegs) End */
379 /*[Hsuan]2004/12/14 AGP Input Delay Adjustment on 850 */
380// XGINew_SetReg4( 0xcf8 , 0x80000000 ) ;
381// ChipsetID = XGINew_GetReg3( 0x0cfc ) ;
382// if ( ChipsetID == 0x25308086 )
383// XGINew_SetReg1( pVBInfo->P3d4 , 0x77 , 0xF0 ) ;
384
385 HwDeviceExtension->pQueryVGAConfigSpace( HwDeviceExtension , 0x50 , 0 , &Temp ) ; /* Get */
386 Temp >>= 20 ;
387 Temp &= 0xF ;
388
389 if ( Temp == 1 )
390 XGINew_SetReg1( pVBInfo->P3d4 , 0x48 , 0x20 ) ; /* CR48 */
391 }
392printk("14");
393
394 if ( HwDeviceExtension->jChipType < XG40 )
395 XGINew_SetReg1( pVBInfo->P3d4 , 0x49 , pVBInfo->CR49[ 0 ] ) ;
396 } /* != XG20 */
397
398 /* Set PCI */
399 XGINew_SetReg1( pVBInfo->P3c4 , 0x23 , *pVBInfo->pSR23 ) ;
400 XGINew_SetReg1( pVBInfo->P3c4 , 0x24 , *pVBInfo->pSR24 ) ;
401 XGINew_SetReg1( pVBInfo->P3c4 , 0x25 , pVBInfo->SR25[ 0 ] ) ;
402printk("15");
403
404 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
405 {
406 /* Set VB */
407 XGI_UnLockCRT2( HwDeviceExtension, pVBInfo) ;
408 XGINew_SetRegANDOR( pVBInfo->Part0Port , 0x3F , 0xEF , 0x00 ) ; /* alan, disable VideoCapture */
409 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , 0x00 ) ;
410 temp1 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x7B ) ; /* chk if BCLK>=100MHz */
411 temp = ( UCHAR )( ( temp1 >> 4 ) & 0x0F ) ;
412
413
414 XGINew_SetReg1( pVBInfo->Part1Port , 0x02 , ( *pVBInfo->pCRT2Data_1_2 ) ) ;
415
416printk("16");
417
418 XGINew_SetReg1( pVBInfo->Part1Port , 0x2E , 0x08 ) ; /* use VB */
419 } /* != XG20 */
420
421
422 XGINew_SetReg1( pVBInfo->P3c4 , 0x27 , 0x1F ) ;
423
424 if ( ( HwDeviceExtension->jChipType == XG42 ) && XGINew_GetXG20DRAMType( HwDeviceExtension , pVBInfo) != 0 ) /* Not DDR */
425 {
426 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , ( *pVBInfo->pSR31 & 0x3F ) | 0x40 ) ;
427 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , ( *pVBInfo->pSR32 & 0xFC ) | 0x01 ) ;
428 }
429 else
430 {
431 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , *pVBInfo->pSR31 ) ;
432 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , *pVBInfo->pSR32 ) ;
433 }
434 XGINew_SetReg1( pVBInfo->P3c4 , 0x33 , *pVBInfo->pSR33 ) ;
435printk("17");
436
437/*
438 if ( HwDeviceExtension->jChipType >= XG40 )
439 SetPowerConsume ( HwDeviceExtension , pVBInfo->P3c4); */
440
441 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
442 {
443 if ( XGI_BridgeIsOn( pVBInfo ) == 1 )
444 {
445 if ( pVBInfo->IF_DEF_LVDS == 0 )
446 {
447 XGINew_SetReg1( pVBInfo->Part2Port , 0x00 , 0x1C ) ;
448 XGINew_SetReg1( pVBInfo->Part4Port , 0x0D , *pVBInfo->pCRT2Data_4_D ) ;
449 XGINew_SetReg1( pVBInfo->Part4Port , 0x0E , *pVBInfo->pCRT2Data_4_E ) ;
450 XGINew_SetReg1( pVBInfo->Part4Port , 0x10 , *pVBInfo->pCRT2Data_4_10 ) ;
451 XGINew_SetReg1( pVBInfo->Part4Port , 0x0F , 0x3F ) ;
452 }
453
454 XGI_LockCRT2( HwDeviceExtension, pVBInfo ) ;
455 }
456 } /* != XG20 */
457printk("18");
458
459 if ( HwDeviceExtension->jChipType < XG40 )
460 XGINew_SetReg1( pVBInfo->P3d4 , 0x83 , 0x00 ) ;
461printk("181");
462
463 if ( HwDeviceExtension->bSkipSense == FALSE )
464 {
465printk("182");
466
467 XGI_SenseCRT1(pVBInfo) ;
468
469printk("183");
470 /* XGINew_DetectMonitor( HwDeviceExtension ) ; */
471pVBInfo->IF_DEF_CH7007 = 0;
472 if ( ( HwDeviceExtension->jChipType == XG21 ) && (pVBInfo->IF_DEF_CH7007) )
473 {
474printk("184");
475 XGI_GetSenseStatus( HwDeviceExtension , pVBInfo ) ; /* sense CRT2 */
476printk("185");
477
478 }
479 if ( HwDeviceExtension->jChipType == XG21 )
480 {
481printk("186");
482
483 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , ~Monitor1Sense , Monitor1Sense ) ; /* Z9 default has CRT */
484 temp = GetXG21FPBits( pVBInfo ) ;
485 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x37 , ~0x01, temp ) ;
486printk("187");
487
488 }
489 if ( HwDeviceExtension->jChipType == XG27 )
490 {
491 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , ~Monitor1Sense , Monitor1Sense ) ; /* Z9 default has CRT */
492 temp = GetXG27FPBits( pVBInfo ) ;
493 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x37 , ~0x03, temp ) ;
494 }
495 }
496printk("19");
497
498 if ( HwDeviceExtension->jChipType >= XG40 )
499 {
500 if ( HwDeviceExtension->jChipType >= XG40 )
501 {
502 XGINew_RAMType = ( int )XGINew_GetXG20DRAMType( HwDeviceExtension , pVBInfo ) ;
503 }
504
505 XGINew_SetDRAMDefaultRegister340( HwDeviceExtension , pVBInfo->P3d4, pVBInfo ) ;
506
507 if ( HwDeviceExtension->bSkipDramSizing == TRUE )
508 {
509 pSR = HwDeviceExtension->pSR ;
510 if ( pSR!=NULL )
511 {
512 while( pSR->jIdx != 0xFF )
513 {
514 XGINew_SetReg1( pVBInfo->P3c4 , pSR->jIdx , pSR->jVal ) ;
515 pSR++ ;
516 }
517 }
518 /* XGINew_SetDRAMModeRegister340( pVBInfo ) ; */
519 } /* SkipDramSizing */
520 else
521 {
522#if 0
523 if ( HwDeviceExtension->jChipType == XG20 )
524 {
525 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , pVBInfo->SR15[0][XGINew_RAMType] ) ;
526 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , pVBInfo->SR15[1][XGINew_RAMType] ) ;
527 XGINew_SetReg1( pVBInfo->P3c4 , 0x20 , 0x20 ) ;
528 }
529 else
530#endif
531{
532printk("20");
533
534 XGINew_SetDRAMSize_340( HwDeviceExtension , pVBInfo) ;
535}
536printk("21");
537
538 }
539 } /* XG40 */
540
541printk("22");
542
543
544 /* SetDefExt2Regs begin */
545/*
546 AGP = 1 ;
547 temp =( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x3A ) ;
548 temp &= 0x30 ;
549 if ( temp == 0x30 )
550 AGP = 0 ;
551
552 if ( AGP == 0 )
553 *pVBInfo->pSR21 &= 0xEF ;
554
555 XGINew_SetReg1( pVBInfo->P3c4 , 0x21 , *pVBInfo->pSR21 ) ;
556 if ( AGP == 1 )
557 *pVBInfo->pSR22 &= 0x20 ;
558 XGINew_SetReg1( pVBInfo->P3c4 , 0x22 , *pVBInfo->pSR22 ) ;
559*/
560
561// base = 0x80000000 ;
562// OutPortLong( 0xcf8 , base ) ;
563// Temp = ( InPortLong( 0xcfc ) & 0xFFFF ) ;
564// if ( Temp == 0x1039 )
565// {
566 XGINew_SetReg1( pVBInfo->P3c4 , 0x22 , ( UCHAR )( ( *pVBInfo->pSR22 ) & 0xFE ) ) ;
567// }
568// else
569// {
570// XGINew_SetReg1( pVBInfo->P3c4 , 0x22 , *pVBInfo->pSR22 ) ;
571// }
572
573 XGINew_SetReg1( pVBInfo->P3c4 , 0x21 , *pVBInfo->pSR21 ) ;
574
575printk("23");
576
577
578 XGINew_ChkSenseStatus ( HwDeviceExtension , pVBInfo ) ;
579 XGINew_SetModeScratch ( HwDeviceExtension , pVBInfo ) ;
580
581printk("24");
582
583
584XGINew_SetReg1( pVBInfo->P3d4 , 0x8c , 0x87);
585XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x31);
586printk("25");
587
588 return( TRUE ) ;
589} /* end of init */
590
591
592
593
594
595/* ============== alan ====================== */
596
597/* --------------------------------------------------------------------- */
598/* Function : XGINew_GetXG20DRAMType */
599/* Input : */
600/* Output : */
601/* Description : */
602/* --------------------------------------------------------------------- */
603UCHAR XGINew_GetXG20DRAMType( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
604{
605 UCHAR data, temp ;
606
607 if ( HwDeviceExtension->jChipType < XG20 )
608 {
609 if ( *pVBInfo->pSoftSetting & SoftDRAMType )
610 {
611 data = *pVBInfo->pSoftSetting & 0x07 ;
612 return( data ) ;
613 }
614 else
615 {
616 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x39 ) & 0x02 ;
617
618 if ( data == 0 )
619 data = ( XGINew_GetReg1( pVBInfo->P3c4 , 0x3A ) & 0x02 ) >> 1 ;
620
621 return( data ) ;
622 }
623 }
624 else if ( HwDeviceExtension->jChipType == XG27 )
625 {
626 if ( *pVBInfo->pSoftSetting & SoftDRAMType )
627 {
628 data = *pVBInfo->pSoftSetting & 0x07 ;
629 return( data ) ;
630 }
631 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x3B ) ;
632
633 if (( temp & 0x88 )==0x80) /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
634 data = 0 ; /*DDR*/
635 else
636 data = 1 ; /*DDRII*/
637 return( data ) ;
638 }
639 else if ( HwDeviceExtension->jChipType == XG21 )
640 {
641 XGINew_SetRegAND( pVBInfo->P3d4 , 0xB4 , ~0x02 ) ; /* Independent GPIO control */
642 DelayUS(800);
643 XGINew_SetRegOR( pVBInfo->P3d4 , 0x4A , 0x80 ) ; /* Enable GPIOH read */
644 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ; /* GPIOF 0:DVI 1:DVO */
645// HOTPLUG_SUPPORT
646// for current XG20 & XG21, GPIOH is floating, driver will fix DDR temporarily
647 if ( temp & 0x01 ) /* DVI read GPIOH */
648 data = 1 ; /*DDRII*/
649 else
650 data = 0 ; /*DDR*/
651//~HOTPLUG_SUPPORT
652 XGINew_SetRegOR( pVBInfo->P3d4 , 0xB4 , 0x02 ) ;
653 return( data ) ;
654 }
655 else
656 {
657 data = XGINew_GetReg1( pVBInfo->P3d4 , 0x97 ) & 0x01 ;
658
659 if ( data == 1 )
660 data ++ ;
661
662 return( data );
663 }
664}
665
666
667/* --------------------------------------------------------------------- */
668/* Function : XGINew_Get310DRAMType */
669/* Input : */
670/* Output : */
671/* Description : */
672/* --------------------------------------------------------------------- */
673UCHAR XGINew_Get310DRAMType(PVB_DEVICE_INFO pVBInfo)
674{
675 UCHAR data ;
676
677 /* index = XGINew_GetReg1( pVBInfo->P3c4 , 0x1A ) ; */
678 /* index &= 07 ; */
679
680 if ( *pVBInfo->pSoftSetting & SoftDRAMType )
681 data = *pVBInfo->pSoftSetting & 0x03 ;
682 else
683 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3a ) & 0x03 ;
684
685 return( data ) ;
686}
687
688
689
690/* --------------------------------------------------------------------- */
691/* Function : XGINew_Delay15us */
692/* Input : */
693/* Output : */
694/* Description : */
695/* --------------------------------------------------------------------- */
696/*
697void XGINew_Delay15us(ULONG ulMicrsoSec)
698{
699}
700*/
701
702
703/* --------------------------------------------------------------------- */
704/* Function : XGINew_SDR_MRS */
705/* Input : */
706/* Output : */
707/* Description : */
708/* --------------------------------------------------------------------- */
709void XGINew_SDR_MRS( PVB_DEVICE_INFO pVBInfo )
710{
711 USHORT data ;
712
713 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x16 ) ;
714 data &= 0x3F ; /* SR16 D7=0,D6=0 */
715 XGINew_SetReg1( pVBInfo->P3c4 , 0x16 , data ) ; /* enable mode register set(MRS) low */
716 /* XGINew_Delay15us( 0x100 ) ; */
717 data |= 0x80 ; /* SR16 D7=1,D6=0 */
718 XGINew_SetReg1( pVBInfo->P3c4 , 0x16 , data ) ; /* enable mode register set(MRS) high */
719 /* XGINew_Delay15us( 0x100 ) ; */
720}
721
722
723/* --------------------------------------------------------------------- */
724/* Function : XGINew_DDR1x_MRS_340 */
725/* Input : */
726/* Output : */
727/* Description : */
728/* --------------------------------------------------------------------- */
729void XGINew_DDR1x_MRS_340( ULONG P3c4 , PVB_DEVICE_INFO pVBInfo)
730{
731 XGINew_SetReg1( P3c4 , 0x18 , 0x01 ) ;
732 XGINew_SetReg1( P3c4 , 0x19 , 0x20 ) ;
733 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ;
734 XGINew_SetReg1( P3c4 , 0x16 , 0x80 ) ;
735
736 if ( *pVBInfo->pXGINew_DRAMTypeDefinition != 0x0C ) /* Samsung F Die */
737 {
738 DelayUS( 3000 ) ; /* Delay 67 x 3 Delay15us */
739 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ;
740 XGINew_SetReg1( P3c4 , 0x19 , 0x20 ) ;
741 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ;
742 XGINew_SetReg1( P3c4 , 0x16 , 0x80 ) ;
743 }
744
745 DelayUS( 60 ) ;
746 XGINew_SetReg1( P3c4 , 0x18 , pVBInfo->SR15[ 2 ][ XGINew_RAMType ] ) ; /* SR18 */
747 XGINew_SetReg1( P3c4 , 0x19 , 0x01 ) ;
748 XGINew_SetReg1( P3c4 , 0x16 , pVBInfo->SR16[ 0 ] ) ;
749 XGINew_SetReg1( P3c4 , 0x16 , pVBInfo->SR16[ 1 ] ) ;
750 DelayUS( 1000 ) ;
751 XGINew_SetReg1( P3c4 , 0x1B , 0x03 ) ;
752 DelayUS( 500 ) ;
753 XGINew_SetReg1( P3c4 , 0x18 , pVBInfo->SR15[ 2 ][ XGINew_RAMType ] ) ; /* SR18 */
754 XGINew_SetReg1( P3c4 , 0x19 , 0x00 ) ;
755 XGINew_SetReg1( P3c4 , 0x16 , pVBInfo->SR16[ 2 ] ) ;
756 XGINew_SetReg1( P3c4 , 0x16 , pVBInfo->SR16[ 3 ] ) ;
757 XGINew_SetReg1( P3c4 , 0x1B , 0x00 ) ;
758}
759
760
761/* --------------------------------------------------------------------- */
762/* Function : XGINew_DDR2x_MRS_340 */
763/* Input : */
764/* Output : */
765/* Description : */
766/* --------------------------------------------------------------------- */
767void XGINew_DDR2x_MRS_340( ULONG P3c4 , PVB_DEVICE_INFO pVBInfo)
768{
769 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ;
770 XGINew_SetReg1( P3c4 , 0x19 , 0x20 ) ;
771 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ;
772 XGINew_SetReg1( P3c4 , 0x16 , 0x80 ) ;
773 DelayUS( 60 ) ;
774 XGINew_SetReg1( P3c4 , 0x18 , pVBInfo->SR15[ 2 ][ XGINew_RAMType ] ) ; /* SR18 */
775 /* XGINew_SetReg1( P3c4 , 0x18 , 0x31 ) ; */
776 XGINew_SetReg1( P3c4 , 0x19 , 0x01 ) ;
777 XGINew_SetReg1( P3c4 , 0x16 , 0x05 ) ;
778 XGINew_SetReg1( P3c4 , 0x16 , 0x85 ) ;
779 DelayUS( 1000 ) ;
780 XGINew_SetReg1( P3c4 , 0x1B , 0x03 ) ;
781 DelayUS( 500 ) ;
782 /* XGINew_SetReg1( P3c4 , 0x18 , 0x31 ) ; */
783 XGINew_SetReg1( P3c4 , 0x18 , pVBInfo->SR15[ 2 ][ XGINew_RAMType ] ) ; /* SR18 */
784 XGINew_SetReg1( P3c4 , 0x19 , 0x00 ) ;
785 XGINew_SetReg1( P3c4 , 0x16 , 0x05 ) ;
786 XGINew_SetReg1( P3c4 , 0x16 , 0x85 ) ;
787 XGINew_SetReg1( P3c4 , 0x1B , 0x00 ) ;
788}
789
790/* --------------------------------------------------------------------- */
791/* Function : XGINew_DDRII_Bootup_XG27 */
792/* Input : */
793/* Output : */
794/* Description : */
795/* --------------------------------------------------------------------- */
796void XGINew_DDRII_Bootup_XG27( PXGI_HW_DEVICE_INFO HwDeviceExtension , ULONG P3c4 , PVB_DEVICE_INFO pVBInfo)
797{
798 ULONG P3d4 = P3c4 + 0x10 ;
799 XGINew_RAMType = ( int )XGINew_GetXG20DRAMType( HwDeviceExtension , pVBInfo ) ;
800 XGINew_SetMemoryClock( HwDeviceExtension , pVBInfo ) ;
801
802 /* Set Double Frequency */
803 /* XGINew_SetReg1( P3d4 , 0x97 , 0x11 ) ; */ /* CR97 */
804 XGINew_SetReg1( P3d4 , 0x97 , *pVBInfo->pXGINew_CR97 ) ; /* CR97 */
805
806 DelayUS( 200 ) ;
807
808 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ; /* Set SR18 */ //EMRS2
809 XGINew_SetReg1( P3c4 , 0x19 , 0x80 ) ; /* Set SR19 */
810 XGINew_SetReg1( P3c4 , 0x16 , 0x20 ) ; /* Set SR16 */
811 DelayUS( 15 ) ;
812 XGINew_SetReg1( P3c4 , 0x16 , 0xA0 ) ; /* Set SR16 */
813 DelayUS( 15 ) ;
814
815 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ; /* Set SR18 */ //EMRS3
816 XGINew_SetReg1( P3c4 , 0x19 , 0xC0 ) ; /* Set SR19 */
817 XGINew_SetReg1( P3c4 , 0x16 , 0x20 ) ; /* Set SR16 */
818 DelayUS( 15 ) ;
819 XGINew_SetReg1( P3c4 , 0x16 , 0xA0 ) ; /* Set SR16 */
820 DelayUS( 15) ;
821
822 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ; /* Set SR18 */ //EMRS1
823 XGINew_SetReg1( P3c4 , 0x19 , 0x40 ) ; /* Set SR19 */
824 XGINew_SetReg1( P3c4 , 0x16 , 0x20 ) ; /* Set SR16 */
825 DelayUS( 30 ) ;
826 XGINew_SetReg1( P3c4 , 0x16 , 0xA0 ) ; /* Set SR16 */
827 DelayUS( 15 ) ;
828
829 XGINew_SetReg1( P3c4 , 0x18 , 0x42 ) ; /* Set SR18 */ //MRS, DLL Enable
830 XGINew_SetReg1( P3c4 , 0x19 , 0x0A ) ; /* Set SR19 */
831 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ; /* Set SR16 */
832 DelayUS( 30 ) ;
833 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ; /* Set SR16 */
834 XGINew_SetReg1( P3c4 , 0x16 , 0x80 ) ; /* Set SR16 */
835 /* DelayUS( 15 ) ; */
836
837 XGINew_SetReg1( P3c4 , 0x1B , 0x04 ) ; /* Set SR1B */
838 DelayUS( 60 ) ;
839 XGINew_SetReg1( P3c4 , 0x1B , 0x00 ) ; /* Set SR1B */
840
841 XGINew_SetReg1( P3c4 , 0x18 , 0x42 ) ; /* Set SR18 */ //MRS, DLL Reset
842 XGINew_SetReg1( P3c4 , 0x19 , 0x08 ) ; /* Set SR19 */
843 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ; /* Set SR16 */
844
845 DelayUS( 30 ) ;
846 XGINew_SetReg1( P3c4 , 0x16 , 0x83 ) ; /* Set SR16 */
847 DelayUS( 15 ) ;
848
849 XGINew_SetReg1( P3c4 , 0x18 , 0x80 ) ; /* Set SR18 */ //MRS, ODT
850 XGINew_SetReg1( P3c4 , 0x19 , 0x46 ) ; /* Set SR19 */
851 XGINew_SetReg1( P3c4 , 0x16 , 0x20 ) ; /* Set SR16 */
852 DelayUS( 30 ) ;
853 XGINew_SetReg1( P3c4 , 0x16 , 0xA0 ) ; /* Set SR16 */
854 DelayUS( 15 ) ;
855
856 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ; /* Set SR18 */ //EMRS
857 XGINew_SetReg1( P3c4 , 0x19 , 0x40 ) ; /* Set SR19 */
858 XGINew_SetReg1( P3c4 , 0x16 , 0x20 ) ; /* Set SR16 */
859 DelayUS( 30 ) ;
860 XGINew_SetReg1( P3c4 , 0x16 , 0xA0 ) ; /* Set SR16 */
861 DelayUS( 15 ) ;
862
863 XGINew_SetReg1( P3c4 , 0x1B , 0x04 ) ; /* Set SR1B refresh control 000:close; 010:open */
864 DelayUS( 200 ) ;
865
866
867}
868/* --------------------------------------------------------------------- */
869/* Function : XGINew_DDR2_MRS_XG20 */
870/* Input : */
871/* Output : */
872/* Description : */
873/* --------------------------------------------------------------------- */
874void XGINew_DDR2_MRS_XG20( PXGI_HW_DEVICE_INFO HwDeviceExtension , ULONG P3c4 , PVB_DEVICE_INFO pVBInfo)
875{
876 ULONG P3d4 = P3c4 + 0x10 ;
877
878 XGINew_RAMType = ( int )XGINew_GetXG20DRAMType( HwDeviceExtension , pVBInfo ) ;
879 XGINew_SetMemoryClock( HwDeviceExtension , pVBInfo ) ;
880
881 XGINew_SetReg1( P3d4 , 0x97 , 0x11 ) ; /* CR97 */
882
883 DelayUS( 200 ) ;
884 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ; /* EMRS2 */
885 XGINew_SetReg1( P3c4 , 0x19 , 0x80 ) ;
886 XGINew_SetReg1( P3c4 , 0x16 , 0x05 ) ;
887 XGINew_SetReg1( P3c4 , 0x16 , 0x85 ) ;
888
889 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ; /* EMRS3 */
890 XGINew_SetReg1( P3c4 , 0x19 , 0xC0 ) ;
891 XGINew_SetReg1( P3c4 , 0x16 , 0x05 ) ;
892 XGINew_SetReg1( P3c4 , 0x16 , 0x85 ) ;
893
894 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ; /* EMRS1 */
895 XGINew_SetReg1( P3c4 , 0x19 , 0x40 ) ;
896 XGINew_SetReg1( P3c4 , 0x16 , 0x05 ) ;
897 XGINew_SetReg1( P3c4 , 0x16 , 0x85 ) ;
898
899 // XGINew_SetReg1( P3c4 , 0x18 , 0x52 ) ; /* MRS1 */
900 XGINew_SetReg1( P3c4 , 0x18 , 0x42 ) ; /* MRS1 */
901 XGINew_SetReg1( P3c4 , 0x19 , 0x02 ) ;
902 XGINew_SetReg1( P3c4 , 0x16 , 0x05 ) ;
903 XGINew_SetReg1( P3c4 , 0x16 , 0x85 ) ;
904
905 DelayUS( 15 ) ;
906 XGINew_SetReg1( P3c4 , 0x1B , 0x04 ) ; /* SR1B */
907 DelayUS( 30 ) ;
908 XGINew_SetReg1( P3c4 , 0x1B , 0x00 ) ; /* SR1B */
909 DelayUS( 100 ) ;
910
911 //XGINew_SetReg1( P3c4 , 0x18 , 0x52 ) ; /* MRS2 */
912 XGINew_SetReg1( P3c4 , 0x18 , 0x42 ) ; /* MRS1 */
913 XGINew_SetReg1( P3c4 , 0x19 , 0x00 ) ;
914 XGINew_SetReg1( P3c4 , 0x16 , 0x05 ) ;
915 XGINew_SetReg1( P3c4 , 0x16 , 0x85 ) ;
916
917 DelayUS( 200 ) ;
918}
919
920/* --------------------------------------------------------------------- */
921/* Function : XGINew_DDR2_MRS_XG20 */
922/* Input : */
923/* Output : */
924/* Description : */
925/* --------------------------------------------------------------------- */
926void XGINew_DDR2_MRS_XG27( PXGI_HW_DEVICE_INFO HwDeviceExtension , ULONG P3c4 , PVB_DEVICE_INFO pVBInfo)
927{
928 ULONG P3d4 = P3c4 + 0x10 ;
929
930 XGINew_RAMType = ( int )XGINew_GetXG20DRAMType( HwDeviceExtension , pVBInfo ) ;
931 XGINew_SetMemoryClock( HwDeviceExtension , pVBInfo ) ;
932
933 XGINew_SetReg1( P3d4 , 0x97 , 0x11 ) ; /* CR97 */
934 DelayUS( 200 ) ;
935 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ; /* EMRS2 */
936 XGINew_SetReg1( P3c4 , 0x19 , 0x80 ) ;
937
938 XGINew_SetReg1( P3c4 , 0x16 , 0x10 ) ;
939 DelayUS( 15 ) ; ////06/11/23 XG27 A0 for CKE enable
940 XGINew_SetReg1( P3c4 , 0x16 , 0x90 ) ;
941
942 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ; /* EMRS3 */
943 XGINew_SetReg1( P3c4 , 0x19 , 0xC0 ) ;
944
945 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ;
946 DelayUS( 15 ) ; ////06/11/22 XG27 A0
947 XGINew_SetReg1( P3c4 , 0x16 , 0x80 ) ;
948
949
950 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ; /* EMRS1 */
951 XGINew_SetReg1( P3c4 , 0x19 , 0x40 ) ;
952
953 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ;
954 DelayUS( 15 ) ; ////06/11/22 XG27 A0
955 XGINew_SetReg1( P3c4 , 0x16 , 0x80 ) ;
956
957 XGINew_SetReg1( P3c4 , 0x18 , 0x42 ) ; /* MRS1 */
958 XGINew_SetReg1( P3c4 , 0x19 , 0x06 ) ; ////[Billy]06/11/22 DLL Reset for XG27 Hynix DRAM
959
960 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ;
961 DelayUS( 15 ) ; ////06/11/23 XG27 A0
962 XGINew_SetReg1( P3c4 , 0x16 , 0x80 ) ;
963
964 DelayUS( 30 ) ; ////06/11/23 XG27 A0 Start Auto-PreCharge
965 XGINew_SetReg1( P3c4 , 0x1B , 0x04 ) ; /* SR1B */
966 DelayUS( 60 ) ;
967 XGINew_SetReg1( P3c4 , 0x1B , 0x00 ) ; /* SR1B */
968
969
970 XGINew_SetReg1( P3c4 , 0x18 , 0x42 ) ; /* MRS1 */
971 XGINew_SetReg1( P3c4 , 0x19 , 0x04 ) ; //// DLL without Reset for XG27 Hynix DRAM
972
973 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ;
974 DelayUS( 30 ) ;
975 XGINew_SetReg1( P3c4 , 0x16 , 0x80 ) ;
976
977 XGINew_SetReg1( P3c4 , 0x18 , 0x80 ); ////XG27 OCD ON
978 XGINew_SetReg1( P3c4 , 0x19 , 0x46 );
979
980 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ;
981 DelayUS( 30 ) ;
982 XGINew_SetReg1( P3c4 , 0x16 , 0x80 ) ;
983
984 XGINew_SetReg1( P3c4 , 0x18 , 0x00 );
985 XGINew_SetReg1( P3c4 , 0x19 , 0x40 );
986
987 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ;
988 DelayUS( 30 ) ;
989 XGINew_SetReg1( P3c4 , 0x16 , 0x80 ) ;
990
991 DelayUS( 15 ) ; ////Start Auto-PreCharge
992 XGINew_SetReg1( P3c4 , 0x1B , 0x04 ) ; /* SR1B */
993 DelayUS( 200 ) ;
994 XGINew_SetReg1( P3c4 , 0x1B , 0x03 ) ; /* SR1B */
995
996}
997
998/* --------------------------------------------------------------------- */
999/* Function : XGINew_DDR1x_DefaultRegister */
1000/* Input : */
1001/* Output : */
1002/* Description : */
1003/* --------------------------------------------------------------------- */
1004void XGINew_DDR1x_DefaultRegister( PXGI_HW_DEVICE_INFO HwDeviceExtension , ULONG Port , PVB_DEVICE_INFO pVBInfo)
1005{
1006 ULONG P3d4 = Port ,
1007 P3c4 = Port - 0x10 ;
1008
1009 if ( HwDeviceExtension->jChipType >= XG20 )
1010 {
1011 XGINew_SetMemoryClock( HwDeviceExtension , pVBInfo ) ;
1012 XGINew_SetReg1( P3d4 , 0x82 , pVBInfo->CR40[ 11 ][ XGINew_RAMType ] ) ; /* CR82 */
1013 XGINew_SetReg1( P3d4 , 0x85 , pVBInfo->CR40[ 12 ][ XGINew_RAMType ] ) ; /* CR85 */
1014 XGINew_SetReg1( P3d4 , 0x86 , pVBInfo->CR40[ 13 ][ XGINew_RAMType ] ) ; /* CR86 */
1015
1016 XGINew_SetReg1( P3d4 , 0x98 , 0x01 ) ;
1017 XGINew_SetReg1( P3d4 , 0x9A , 0x02 ) ;
1018
1019 XGINew_DDR1x_MRS_XG20( P3c4 , pVBInfo) ;
1020 }
1021 else
1022 {
1023 XGINew_SetMemoryClock( HwDeviceExtension , pVBInfo ) ;
1024
1025 switch( HwDeviceExtension->jChipType )
1026 {
1027 case XG41:
1028 case XG42:
1029 XGINew_SetReg1( P3d4 , 0x82 , pVBInfo->CR40[ 11 ][ XGINew_RAMType ] ) ; /* CR82 */
1030 XGINew_SetReg1( P3d4 , 0x85 , pVBInfo->CR40[ 12 ][ XGINew_RAMType ] ) ; /* CR85 */
1031 XGINew_SetReg1( P3d4 , 0x86 , pVBInfo->CR40[ 13 ][ XGINew_RAMType ] ) ; /* CR86 */
1032 break ;
1033 default:
1034 XGINew_SetReg1( P3d4 , 0x82 , 0x88 ) ;
1035 XGINew_SetReg1( P3d4 , 0x86 , 0x00 ) ;
1036 XGINew_GetReg1( P3d4 , 0x86 ) ; /* Insert read command for delay */
1037 XGINew_SetReg1( P3d4 , 0x86 , 0x88 ) ;
1038 XGINew_GetReg1( P3d4 , 0x86 ) ;
1039 XGINew_SetReg1( P3d4 , 0x86 , pVBInfo->CR40[ 13 ][ XGINew_RAMType ] ) ;
1040 XGINew_SetReg1( P3d4 , 0x82 , 0x77 ) ;
1041 XGINew_SetReg1( P3d4 , 0x85 , 0x00 ) ;
1042 XGINew_GetReg1( P3d4 , 0x85 ) ; /* Insert read command for delay */
1043 XGINew_SetReg1( P3d4 , 0x85 , 0x88 ) ;
1044 XGINew_GetReg1( P3d4 , 0x85 ) ; /* Insert read command for delay */
1045 XGINew_SetReg1( P3d4 , 0x85 , pVBInfo->CR40[ 12 ][ XGINew_RAMType ] ) ; /* CR85 */
1046 XGINew_SetReg1( P3d4 , 0x82 , pVBInfo->CR40[ 11 ][ XGINew_RAMType ] ) ; /* CR82 */
1047 break ;
1048 }
1049
1050 XGINew_SetReg1( P3d4 , 0x97 , 0x00 ) ;
1051 XGINew_SetReg1( P3d4 , 0x98 , 0x01 ) ;
1052 XGINew_SetReg1( P3d4 , 0x9A , 0x02 ) ;
1053 XGINew_DDR1x_MRS_340( P3c4 , pVBInfo ) ;
1054 }
1055}
1056
1057
1058/* --------------------------------------------------------------------- */
1059/* Function : XGINew_DDR2x_DefaultRegister */
1060/* Input : */
1061/* Output : */
1062/* Description : */
1063/* --------------------------------------------------------------------- */
1064void XGINew_DDR2x_DefaultRegister( PXGI_HW_DEVICE_INFO HwDeviceExtension , ULONG Port ,PVB_DEVICE_INFO pVBInfo)
1065{
1066 ULONG P3d4 = Port ,
1067 P3c4 = Port - 0x10 ;
1068
1069 XGINew_SetMemoryClock( HwDeviceExtension , pVBInfo ) ;
1070
1071 /* 20040906 Hsuan modify CR82, CR85, CR86 for XG42 */
1072 switch( HwDeviceExtension->jChipType )
1073 {
1074 case XG41:
1075 case XG42:
1076 XGINew_SetReg1( P3d4 , 0x82 , pVBInfo->CR40[ 11 ][ XGINew_RAMType ] ) ; /* CR82 */
1077 XGINew_SetReg1( P3d4 , 0x85 , pVBInfo->CR40[ 12 ][ XGINew_RAMType ] ) ; /* CR85 */
1078 XGINew_SetReg1( P3d4 , 0x86 , pVBInfo->CR40[ 13 ][ XGINew_RAMType ] ) ; /* CR86 */
1079 break ;
1080 default:
1081 /* keep following setting sequence, each setting in the same reg insert idle */
1082 XGINew_SetReg1( P3d4 , 0x82 , 0x88 ) ;
1083 XGINew_SetReg1( P3d4 , 0x86 , 0x00 ) ;
1084 XGINew_GetReg1( P3d4 , 0x86 ) ; /* Insert read command for delay */
1085 XGINew_SetReg1( P3d4 , 0x86 , 0x88 ) ;
1086 XGINew_SetReg1( P3d4 , 0x82 , 0x77 ) ;
1087 XGINew_SetReg1( P3d4 , 0x85 , 0x00 ) ;
1088 XGINew_GetReg1( P3d4 , 0x85 ) ; /* Insert read command for delay */
1089 XGINew_SetReg1( P3d4 , 0x85 , 0x88 ) ;
1090 XGINew_GetReg1( P3d4 , 0x85 ) ; /* Insert read command for delay */
1091 XGINew_SetReg1( P3d4 , 0x85 , pVBInfo->CR40[ 12 ][ XGINew_RAMType ] ) ; /* CR85 */
1092 XGINew_SetReg1( P3d4 , 0x82 , pVBInfo->CR40[ 11 ][ XGINew_RAMType ] ) ; /* CR82 */
1093 }
1094 XGINew_SetReg1( P3d4 , 0x97 , 0x11 ) ;
1095 if ( HwDeviceExtension->jChipType == XG42 )
1096 {
1097 XGINew_SetReg1( P3d4 , 0x98 , 0x01 ) ;
1098 }
1099 else
1100 {
1101 XGINew_SetReg1( P3d4 , 0x98 , 0x03 ) ;
1102 }
1103 XGINew_SetReg1( P3d4 , 0x9A , 0x02 ) ;
1104
1105 XGINew_DDR2x_MRS_340( P3c4 , pVBInfo ) ;
1106}
1107
1108
1109/* --------------------------------------------------------------------- */
1110/* Function : XGINew_DDR2_DefaultRegister */
1111/* Input : */
1112/* Output : */
1113/* Description : */
1114/* --------------------------------------------------------------------- */
1115void XGINew_DDR2_DefaultRegister( PXGI_HW_DEVICE_INFO HwDeviceExtension, ULONG Port , PVB_DEVICE_INFO pVBInfo)
1116{
1117 ULONG P3d4 = Port ,
1118 P3c4 = Port - 0x10 ;
1119
1120 /* keep following setting sequence, each setting in the same reg insert idle */
1121 XGINew_SetReg1( P3d4 , 0x82 , 0x77 ) ;
1122 XGINew_SetReg1( P3d4 , 0x86 , 0x00 ) ;
1123 XGINew_GetReg1( P3d4 , 0x86 ) ; /* Insert read command for delay */
1124 XGINew_SetReg1( P3d4 , 0x86 , 0x88 ) ;
1125 XGINew_GetReg1( P3d4 , 0x86 ) ; /* Insert read command for delay */
1126 XGINew_SetReg1( P3d4 , 0x86 , pVBInfo->CR40[ 13 ][ XGINew_RAMType ] ) ; /* CR86 */
1127 XGINew_SetReg1( P3d4 , 0x82 , 0x77 ) ;
1128 XGINew_SetReg1( P3d4 , 0x85 , 0x00 ) ;
1129 XGINew_GetReg1( P3d4 , 0x85 ) ; /* Insert read command for delay */
1130 XGINew_SetReg1( P3d4 , 0x85 , 0x88 ) ;
1131 XGINew_GetReg1( P3d4 , 0x85 ) ; /* Insert read command for delay */
1132 XGINew_SetReg1( P3d4 , 0x85 , pVBInfo->CR40[ 12 ][ XGINew_RAMType ] ) ; /* CR85 */
1133 if ( HwDeviceExtension->jChipType == XG27 )
1134 XGINew_SetReg1( P3d4 , 0x82 , pVBInfo->CR40[ 11 ][ XGINew_RAMType ] ) ; /* CR82 */
1135 else
1136 XGINew_SetReg1( P3d4 , 0x82 , 0xA8 ) ; /* CR82 */
1137
1138 XGINew_SetReg1( P3d4 , 0x98 , 0x01 ) ;
1139 XGINew_SetReg1( P3d4 , 0x9A , 0x02 ) ;
1140 if ( HwDeviceExtension->jChipType == XG27 )
1141 XGINew_DDRII_Bootup_XG27( HwDeviceExtension , P3c4 , pVBInfo) ;
1142 else
1143 XGINew_DDR2_MRS_XG20( HwDeviceExtension , P3c4, pVBInfo ) ;
1144}
1145
1146
1147/* --------------------------------------------------------------------- */
1148/* Function : XGINew_SetDRAMDefaultRegister340 */
1149/* Input : */
1150/* Output : */
1151/* Description : */
1152/* --------------------------------------------------------------------- */
1153void XGINew_SetDRAMDefaultRegister340( PXGI_HW_DEVICE_INFO HwDeviceExtension , ULONG Port , PVB_DEVICE_INFO pVBInfo)
1154{
1155 UCHAR temp , temp1 , temp2 , temp3 ,
1156 i , j , k ;
1157
1158 ULONG P3d4 = Port ,
1159 P3c4 = Port - 0x10 ;
1160
1161 XGINew_SetReg1( P3d4 , 0x6D , pVBInfo->CR40[ 8 ][ XGINew_RAMType ] ) ;
1162 XGINew_SetReg1( P3d4 , 0x68 , pVBInfo->CR40[ 5 ][ XGINew_RAMType ] ) ;
1163 XGINew_SetReg1( P3d4 , 0x69 , pVBInfo->CR40[ 6 ][ XGINew_RAMType ] ) ;
1164 XGINew_SetReg1( P3d4 , 0x6A , pVBInfo->CR40[ 7 ][ XGINew_RAMType ] ) ;
1165
1166 temp2 = 0 ;
1167 for( i = 0 ; i < 4 ; i++ )
1168 {
1169 temp = pVBInfo->CR6B[ XGINew_RAMType ][ i ] ; /* CR6B DQS fine tune delay */
1170 for( j = 0 ; j < 4 ; j++ )
1171 {
1172 temp1 = ( ( temp >> ( 2 * j ) ) & 0x03 ) << 2 ;
1173 temp2 |= temp1 ;
1174 XGINew_SetReg1( P3d4 , 0x6B , temp2 ) ;
1175 XGINew_GetReg1( P3d4 , 0x6B ) ; /* Insert read command for delay */
1176 temp2 &= 0xF0 ;
1177 temp2 += 0x10 ;
1178 }
1179 }
1180
1181 temp2 = 0 ;
1182 for( i = 0 ; i < 4 ; i++ )
1183 {
1184 temp = pVBInfo->CR6E[ XGINew_RAMType ][ i ] ; /* CR6E DQM fine tune delay */
1185 for( j = 0 ; j < 4 ; j++ )
1186 {
1187 temp1 = ( ( temp >> ( 2 * j ) ) & 0x03 ) << 2 ;
1188 temp2 |= temp1 ;
1189 XGINew_SetReg1( P3d4 , 0x6E , temp2 ) ;
1190 XGINew_GetReg1( P3d4 , 0x6E ) ; /* Insert read command for delay */
1191 temp2 &= 0xF0 ;
1192 temp2 += 0x10 ;
1193 }
1194 }
1195
1196 temp3 = 0 ;
1197 for( k = 0 ; k < 4 ; k++ )
1198 {
1199 XGINew_SetRegANDOR( P3d4 , 0x6E , 0xFC , temp3 ) ; /* CR6E_D[1:0] select channel */
1200 temp2 = 0 ;
1201 for( i = 0 ; i < 8 ; i++ )
1202 {
1203 temp = pVBInfo->CR6F[ XGINew_RAMType ][ 8 * k + i ] ; /* CR6F DQ fine tune delay */
1204 for( j = 0 ; j < 4 ; j++ )
1205 {
1206 temp1 = ( temp >> ( 2 * j ) ) & 0x03 ;
1207 temp2 |= temp1 ;
1208 XGINew_SetReg1( P3d4 , 0x6F , temp2 ) ;
1209 XGINew_GetReg1( P3d4 , 0x6F ) ; /* Insert read command for delay */
1210 temp2 &= 0xF8 ;
1211 temp2 += 0x08 ;
1212 }
1213 }
1214 temp3 += 0x01 ;
1215 }
1216
1217 XGINew_SetReg1( P3d4 , 0x80 , pVBInfo->CR40[ 9 ][ XGINew_RAMType ] ) ; /* CR80 */
1218 XGINew_SetReg1( P3d4 , 0x81 , pVBInfo->CR40[ 10 ][ XGINew_RAMType ] ) ; /* CR81 */
1219
1220 temp2 = 0x80 ;
1221 temp = pVBInfo->CR89[ XGINew_RAMType ][ 0 ] ; /* CR89 terminator type select */
1222 for( j = 0 ; j < 4 ; j++ )
1223 {
1224 temp1 = ( temp >> ( 2 * j ) ) & 0x03 ;
1225 temp2 |= temp1 ;
1226 XGINew_SetReg1( P3d4 , 0x89 , temp2 ) ;
1227 XGINew_GetReg1( P3d4 , 0x89 ) ; /* Insert read command for delay */
1228 temp2 &= 0xF0 ;
1229 temp2 += 0x10 ;
1230 }
1231
1232 temp = pVBInfo->CR89[ XGINew_RAMType ][ 1 ] ;
1233 temp1 = temp & 0x03 ;
1234 temp2 |= temp1 ;
1235 XGINew_SetReg1( P3d4 , 0x89 , temp2 ) ;
1236
1237 temp = pVBInfo->CR40[ 3 ][ XGINew_RAMType ] ;
1238 temp1 = temp & 0x0F ;
1239 temp2 = ( temp >> 4 ) & 0x07 ;
1240 temp3 = temp & 0x80 ;
1241 XGINew_SetReg1( P3d4 , 0x45 , temp1 ) ; /* CR45 */
1242 XGINew_SetReg1( P3d4 , 0x99 , temp2 ) ; /* CR99 */
1243 XGINew_SetRegOR( P3d4 , 0x40 , temp3 ) ; /* CR40_D[7] */
1244 XGINew_SetReg1( P3d4 , 0x41 , pVBInfo->CR40[ 0 ][ XGINew_RAMType ] ) ; /* CR41 */
1245
1246 if ( HwDeviceExtension->jChipType == XG27 )
1247 XGINew_SetReg1( P3d4 , 0x8F , *pVBInfo->pCR8F ) ; /* CR8F */
1248
1249 for( j = 0 ; j <= 6 ; j++ )
1250 XGINew_SetReg1( P3d4 , ( 0x90 + j ) , pVBInfo->CR40[ 14 + j ][ XGINew_RAMType ] ) ; /* CR90 - CR96 */
1251
1252 for( j = 0 ; j <= 2 ; j++ )
1253 XGINew_SetReg1( P3d4 , ( 0xC3 + j ) , pVBInfo->CR40[ 21 + j ][ XGINew_RAMType ] ) ; /* CRC3 - CRC5 */
1254
1255 for( j = 0 ; j < 2 ; j++ )
1256 XGINew_SetReg1( P3d4 , ( 0x8A + j ) , pVBInfo->CR40[ 1 + j ][ XGINew_RAMType ] ) ; /* CR8A - CR8B */
1257
1258 if ( ( HwDeviceExtension->jChipType == XG41 ) || ( HwDeviceExtension->jChipType == XG42 ) )
1259 XGINew_SetReg1( P3d4 , 0x8C , 0x87 ) ;
1260
1261 XGINew_SetReg1( P3d4 , 0x59 , pVBInfo->CR40[ 4 ][ XGINew_RAMType ] ) ; /* CR59 */
1262
1263 XGINew_SetReg1( P3d4 , 0x83 , 0x09 ) ; /* CR83 */
1264 XGINew_SetReg1( P3d4 , 0x87 , 0x00 ) ; /* CR87 */
1265 XGINew_SetReg1( P3d4 , 0xCF , *pVBInfo->pCRCF ) ; /* CRCF */
1266 if ( XGINew_RAMType )
1267 {
1268 //XGINew_SetReg1( P3c4 , 0x17 , 0xC0 ) ; /* SR17 DDRII */
1269 XGINew_SetReg1( P3c4 , 0x17 , 0x80 ) ; /* SR17 DDRII */
1270 if ( HwDeviceExtension->jChipType == XG27 )
1271 XGINew_SetReg1( P3c4 , 0x17 , 0x02 ) ; /* SR17 DDRII */
1272
1273 }
1274 else
1275 XGINew_SetReg1( P3c4 , 0x17 , 0x00 ) ; /* SR17 DDR */
1276 XGINew_SetReg1( P3c4 , 0x1A , 0x87 ) ; /* SR1A */
1277
1278 temp = XGINew_GetXG20DRAMType( HwDeviceExtension, pVBInfo) ;
1279 if( temp == 0 )
1280 XGINew_DDR1x_DefaultRegister( HwDeviceExtension, P3d4, pVBInfo ) ;
1281 else
1282 {
1283 XGINew_SetReg1( P3d4 , 0xB0 , 0x80 ) ; /* DDRII Dual frequency mode */
1284 XGINew_DDR2_DefaultRegister( HwDeviceExtension, P3d4, pVBInfo ) ;
1285 }
1286 XGINew_SetReg1( P3c4 , 0x1B , pVBInfo->SR15[ 3 ][ XGINew_RAMType ] ) ; /* SR1B */
1287}
1288
1289
1290/* --------------------------------------------------------------------- */
1291/* Function : XGINew_DDR_MRS */
1292/* Input : */
1293/* Output : */
1294/* Description : */
1295/* --------------------------------------------------------------------- */
1296void XGINew_DDR_MRS(PVB_DEVICE_INFO pVBInfo)
1297{
1298 USHORT data ;
1299
1300 PUCHAR volatile pVideoMemory = ( PUCHAR )pVBInfo->ROMAddr ;
1301
1302 /* SR16 <- 1F,DF,2F,AF */
1303 /* yriver modified SR16 <- 0F,DF,0F,AF */
1304 /* enable DLL of DDR SD/SGRAM , SR16 D4=1 */
1305 data = pVideoMemory[ 0xFB ] ;
1306 /* data = XGINew_GetReg1( pVBInfo->P3c4 , 0x16 ) ; */
1307
1308 data &= 0x0F ;
1309 XGINew_SetReg1( pVBInfo->P3c4 , 0x16 , data ) ;
1310 data |= 0xC0 ;
1311 XGINew_SetReg1( pVBInfo->P3c4 , 0x16 , data ) ;
1312 data &= 0x0F ;
1313 XGINew_SetReg1( pVBInfo->P3c4 , 0x16 , data ) ;
1314 data |= 0x80 ;
1315 XGINew_SetReg1( pVBInfo->P3c4 , 0x16 , data ) ;
1316 data &= 0x0F ;
1317 XGINew_SetReg1( pVBInfo->P3c4 , 0x16 , data ) ;
1318 data |= 0xD0 ;
1319 XGINew_SetReg1( pVBInfo->P3c4 , 0x16 , data ) ;
1320 data &= 0x0F ;
1321 XGINew_SetReg1( pVBInfo->P3c4 , 0x16 , data ) ;
1322 data |= 0xA0 ;
1323 XGINew_SetReg1( pVBInfo->P3c4 , 0x16 , data ) ;
1324/*
1325 else {
1326 data &= 0x0F;
1327 data |= 0x10;
1328 XGINew_SetReg1(pVBInfo->P3c4,0x16,data);
1329
1330 if (!(pVBInfo->SR15[1][XGINew_RAMType] & 0x10))
1331 {
1332 data &= 0x0F;
1333 }
1334
1335 data |= 0xC0;
1336 XGINew_SetReg1(pVBInfo->P3c4,0x16,data);
1337
1338
1339 data &= 0x0F;
1340 data |= 0x20;
1341 XGINew_SetReg1(pVBInfo->P3c4,0x16,data);
1342 if (!(pVBInfo->SR15[1][XGINew_RAMType] & 0x10))
1343 {
1344 data &= 0x0F;
1345 }
1346
1347 data |= 0x80;
1348 XGINew_SetReg1(pVBInfo->P3c4,0x16,data);
1349 }
1350*/
1351}
1352
1353
1354/* check if read cache pointer is correct */
1355
1356
1357
1358/* --------------------------------------------------------------------- */
1359/* Function : XGINew_VerifyMclk */
1360/* Input : */
1361/* Output : */
1362/* Description : */
1363/* --------------------------------------------------------------------- */
1364void XGINew_VerifyMclk( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
1365{
1366 PUCHAR pVideoMemory = pVBInfo->FBAddr ;
1367 UCHAR i , j ;
1368 USHORT Temp , SR21 ;
1369
1370 pVideoMemory[ 0 ] = 0xaa ; /* alan */
1371 pVideoMemory[ 16 ] = 0x55 ; /* note: PCI read cache is off */
1372
1373 if ( ( pVideoMemory[ 0 ] != 0xaa ) || ( pVideoMemory[ 16 ] != 0x55 ) )
1374 {
1375 for( i = 0 , j = 16 ; i < 2 ; i++ , j += 16 )
1376 {
1377 SR21 = XGINew_GetReg1( pVBInfo->P3c4 , 0x21 ) ;
1378 Temp = SR21 & 0xFB ; /* disable PCI post write buffer empty gating */
1379 XGINew_SetReg1( pVBInfo->P3c4 , 0x21 , Temp ) ;
1380
1381 Temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x3C ) ;
1382 Temp |= 0x01 ; /* MCLK reset */
1383
1384
1385 Temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x3C ) ;
1386 Temp &= 0xFE ; /* MCLK normal operation */
1387
1388 XGINew_SetReg1( pVBInfo->P3c4 , 0x21 , SR21 ) ;
1389
1390 pVideoMemory[ 16 + j ] = j ;
1391 if ( pVideoMemory[ 16 + j ] == j )
1392 {
1393 pVideoMemory[ j ] = j ;
1394 break ;
1395 }
1396 }
1397 }
1398}
1399
1400
1401
1402
1403
1404/* --------------------------------------------------------------------- */
1405/* Function : XGINew_SetDRAMSize_340 */
1406/* Input : */
1407/* Output : */
1408/* Description : */
1409/* --------------------------------------------------------------------- */
1410void XGINew_SetDRAMSize_340( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
1411{
1412 USHORT data ;
1413
1414 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
1415 pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ;
1416
1417 XGISetModeNew( HwDeviceExtension , 0x2e ) ;
1418
1419
1420 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x21 ) ;
1421 XGINew_SetReg1( pVBInfo->P3c4 , 0x21 , ( USHORT )( data & 0xDF ) ) ; /* disable read cache */
1422 XGI_DisplayOff( HwDeviceExtension, pVBInfo );
1423
1424 /*data = XGINew_GetReg1( pVBInfo->P3c4 , 0x1 ) ;*/
1425 /*data |= 0x20 ;*/
1426 /*XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , data ) ;*/ /* Turn OFF Display */
1427 XGINew_DDRSizing340( HwDeviceExtension, pVBInfo ) ;
1428 data=XGINew_GetReg1( pVBInfo->P3c4 , 0x21 ) ;
1429 XGINew_SetReg1( pVBInfo->P3c4 , 0x21 , ( USHORT )( data | 0x20 ) ) ; /* enable read cache */
1430
1431}
1432
1433
1434/* --------------------------------------------------------------------- */
1435/* Function : */
1436/* Input : */
1437/* Output : */
1438/* Description : */
1439/* --------------------------------------------------------------------- */
1440void XGINew_SetDRAMSize_310( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
1441{
1442 USHORT data ;
1443 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ,
1444 pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ;
1445#ifdef XGI301
1446 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x30 , 0x40 ) ; */
1447#endif
1448
1449#ifdef XGI302 /* alan,should change value */
1450 XGINew_SetReg1( pVBInfo->P3d4 , 0x30 , 0x4D ) ;
1451 XGINew_SetReg1( pVBInfo->P3d4 , 0x31 , 0xc0 ) ;
1452 XGINew_SetReg1( pVBInfo->P3d4 , 0x34 , 0x3F ) ;
1453#endif
1454
1455 XGISetModeNew( HwDeviceExtension , 0x2e ) ;
1456
1457 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x21 ) ;
1458 XGINew_SetReg1( pVBInfo->P3c4 , 0x21 , ( USHORT )( data & 0xDF ) ) ; /* disable read cache */
1459
1460 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x1 ) ;
1461 data |= 0x20 ;
1462 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , data ) ; /* Turn OFF Display */
1463
1464 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x16 ) ;
1465
1466
1467 XGINew_SetReg1( pVBInfo->P3c4 , 0x16 , ( USHORT )( data | 0x0F ) ) ; /* assume lowest speed DRAM */
1468
1469 XGINew_SetDRAMModeRegister( pVBInfo ) ;
1470 XGINew_DisableRefresh( HwDeviceExtension, pVBInfo ) ;
1471 XGINew_CheckBusWidth_310( pVBInfo) ;
1472 XGINew_VerifyMclk( HwDeviceExtension, pVBInfo ) ; /* alan 2000/7/3 */
1473
1474
1475
1476 if ( XGINew_Get310DRAMType( pVBInfo ) < 2 )
1477 {
1478 XGINew_SDRSizing( pVBInfo ) ;
1479 }
1480 else
1481 {
1482 XGINew_DDRSizing( pVBInfo) ;
1483 }
1484
1485
1486
1487
1488 XGINew_SetReg1( pVBInfo->P3c4 , 0x16 , pVBInfo->SR15[ 1 ][ XGINew_RAMType ] ) ; /* restore SR16 */
1489
1490 XGINew_EnableRefresh( HwDeviceExtension, pVBInfo ) ;
1491 data=XGINew_GetReg1( pVBInfo->P3c4 ,0x21 ) ;
1492 XGINew_SetReg1( pVBInfo->P3c4 , 0x21 , ( USHORT )( data | 0x20 ) ) ; /* enable read cache */
1493}
1494
1495
1496
1497/* --------------------------------------------------------------------- */
1498/* Function : XGINew_SetDRAMModeRegister340 */
1499/* Input : */
1500/* Output : */
1501/* Description : */
1502/* --------------------------------------------------------------------- */
1503
1504void XGINew_SetDRAMModeRegister340( PXGI_HW_DEVICE_INFO HwDeviceExtension )
1505{
1506 UCHAR data ;
1507 VB_DEVICE_INFO VBINF;
1508 PVB_DEVICE_INFO pVBInfo = &VBINF;
1509 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
1510 pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ;
1511 pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
1512 pVBInfo->ISXPDOS = 0 ;
1513
1514 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
1515 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
1516 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
1517 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
1518 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
1519 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
1520 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
1521 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
1522 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
1523 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
1524 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
1525 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
1526 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
1527 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
1528 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
1529 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
1530 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
1531 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
1532 XGI_GetVBType( pVBInfo ) ; /* Run XGI_GetVBType before InitTo330Pointer */
1533
1534 InitTo330Pointer(HwDeviceExtension->jChipType,pVBInfo);
1535
1536 ReadVBIOSTablData( HwDeviceExtension->jChipType , pVBInfo) ;
1537
1538 if ( XGINew_GetXG20DRAMType( HwDeviceExtension, pVBInfo) == 0 )
1539 {
1540 data = ( XGINew_GetReg1( pVBInfo->P3c4 , 0x39 ) & 0x02 ) >> 1 ;
1541 if ( data == 0x01 )
1542 XGINew_DDR2x_MRS_340( pVBInfo->P3c4, pVBInfo ) ;
1543 else
1544 XGINew_DDR1x_MRS_340( pVBInfo->P3c4, pVBInfo ) ;
1545 }
1546 else
1547 XGINew_DDR2_MRS_XG20( HwDeviceExtension, pVBInfo->P3c4, pVBInfo);
1548
1549 XGINew_SetReg1( pVBInfo->P3c4 , 0x1B , 0x03 ) ;
1550}
1551
1552/* --------------------------------------------------------------------- */
1553/* Function : XGINew_SetDRAMModeRegister */
1554/* Input : */
1555/* Output : */
1556/* Description : */
1557/* --------------------------------------------------------------------- */
1558void XGINew_SetDRAMModeRegister( PVB_DEVICE_INFO pVBInfo)
1559{
1560 if ( XGINew_Get310DRAMType( pVBInfo ) < 2 )
1561 {
1562 XGINew_SDR_MRS(pVBInfo ) ;
1563 }
1564 else
1565 {
1566 /* SR16 <- 0F,CF,0F,8F */
1567 XGINew_DDR_MRS( pVBInfo ) ;
1568 }
1569}
1570
1571
1572/* --------------------------------------------------------------------- */
1573/* Function : XGINew_DisableRefresh */
1574/* Input : */
1575/* Output : */
1576/* Description : */
1577/* --------------------------------------------------------------------- */
1578void XGINew_DisableRefresh( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
1579{
1580 USHORT data ;
1581
1582
1583 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x1B ) ;
1584 data &= 0xF8 ;
1585 XGINew_SetReg1( pVBInfo->P3c4 , 0x1B , data ) ;
1586
1587}
1588
1589
1590/* --------------------------------------------------------------------- */
1591/* Function : XGINew_EnableRefresh */
1592/* Input : */
1593/* Output : */
1594/* Description : */
1595/* --------------------------------------------------------------------- */
1596void XGINew_EnableRefresh( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
1597{
1598
1599 XGINew_SetReg1( pVBInfo->P3c4 , 0x1B , pVBInfo->SR15[ 3 ][ XGINew_RAMType ] ) ; /* SR1B */
1600
1601
1602}
1603
1604
1605/* --------------------------------------------------------------------- */
1606/* Function : XGINew_DisableChannelInterleaving */
1607/* Input : */
1608/* Output : */
1609/* Description : */
1610/* --------------------------------------------------------------------- */
1611void XGINew_DisableChannelInterleaving( int index , USHORT XGINew_DDRDRAM_TYPE[][ 5 ] , PVB_DEVICE_INFO pVBInfo)
1612{
1613 USHORT data ;
1614
1615 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x15 ) ;
1616 data &= 0x1F ;
1617
1618 switch( XGINew_DDRDRAM_TYPE[ index ][ 3 ] )
1619 {
1620 case 64:
1621 data |= 0 ;
1622 break ;
1623 case 32:
1624 data |= 0x20 ;
1625 break ;
1626 case 16:
1627 data |= 0x40 ;
1628 break ;
1629 case 4:
1630 data |= 0x60 ;
1631 break ;
1632 default:
1633 break ;
1634 }
1635 XGINew_SetReg1( pVBInfo->P3c4 , 0x15 , data ) ;
1636}
1637
1638
1639/* --------------------------------------------------------------------- */
1640/* Function : XGINew_SetDRAMSizingType */
1641/* Input : */
1642/* Output : */
1643/* Description : */
1644/* --------------------------------------------------------------------- */
1645void XGINew_SetDRAMSizingType( int index , USHORT DRAMTYPE_TABLE[][ 5 ] ,PVB_DEVICE_INFO pVBInfo)
1646{
1647 USHORT data ;
1648
1649 data = DRAMTYPE_TABLE[ index ][ 4 ] ;
1650 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x13 , 0x80 , data ) ;
1651 DelayUS( 15 ) ;
1652 /* should delay 50 ns */
1653}
1654
1655
1656/* --------------------------------------------------------------------- */
1657/* Function : XGINew_CheckBusWidth_310 */
1658/* Input : */
1659/* Output : */
1660/* Description : */
1661/* --------------------------------------------------------------------- */
1662void XGINew_CheckBusWidth_310( PVB_DEVICE_INFO pVBInfo)
1663{
1664 USHORT data ;
1665 PULONG volatile pVideoMemory ;
1666
1667 pVideoMemory = (PULONG) pVBInfo->FBAddr;
1668
1669 if ( XGINew_Get310DRAMType( pVBInfo ) < 2 )
1670 {
1671 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x00 ) ;
1672 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x12 ) ;
1673 /* should delay */
1674 XGINew_SDR_MRS( pVBInfo ) ;
1675
1676 XGINew_ChannelAB = 0 ;
1677 XGINew_DataBusWidth = 128 ;
1678 pVideoMemory[ 0 ] = 0x01234567L ;
1679 pVideoMemory[ 1 ] = 0x456789ABL ;
1680 pVideoMemory[ 2 ] = 0x89ABCDEFL ;
1681 pVideoMemory[ 3 ] = 0xCDEF0123L ;
1682 pVideoMemory[ 4 ] = 0x55555555L ;
1683 pVideoMemory[ 5 ] = 0x55555555L ;
1684 pVideoMemory[ 6 ] = 0xFFFFFFFFL ;
1685 pVideoMemory[ 7 ] = 0xFFFFFFFFL ;
1686
1687 if ( ( pVideoMemory[ 3 ] != 0xCDEF0123L ) || ( pVideoMemory[ 2 ] != 0x89ABCDEFL ) )
1688 {
1689 /* ChannelA64Bit */
1690 XGINew_DataBusWidth = 64 ;
1691 XGINew_ChannelAB = 0 ;
1692 data=XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ;
1693 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , ( USHORT )( data & 0xFD ) ) ;
1694 }
1695
1696 if ( ( pVideoMemory[ 1 ] != 0x456789ABL ) || ( pVideoMemory[ 0 ] != 0x01234567L ) )
1697 {
1698 /* ChannelB64Bit */
1699 XGINew_DataBusWidth = 64 ;
1700 XGINew_ChannelAB = 1 ;
1701 data=XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ;
1702 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , ( USHORT )( ( data & 0xFD ) | 0x01 ) ) ;
1703 }
1704
1705 return ;
1706 }
1707 else
1708 {
1709 /* DDR Dual channel */
1710 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x00 ) ;
1711 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x02 ) ; /* Channel A, 64bit */
1712 /* should delay */
1713 XGINew_DDR_MRS( pVBInfo ) ;
1714
1715 XGINew_ChannelAB = 0 ;
1716 XGINew_DataBusWidth = 64 ;
1717 pVideoMemory[ 0 ] = 0x01234567L ;
1718 pVideoMemory[ 1 ] = 0x456789ABL ;
1719 pVideoMemory[ 2 ] = 0x89ABCDEFL ;
1720 pVideoMemory[ 3 ] = 0xCDEF0123L ;
1721 pVideoMemory[ 4 ] = 0x55555555L ;
1722 pVideoMemory[ 5 ] = 0x55555555L ;
1723 pVideoMemory[ 6 ] = 0xAAAAAAAAL ;
1724 pVideoMemory[ 7 ] = 0xAAAAAAAAL ;
1725
1726 if ( pVideoMemory[ 1 ] == 0x456789ABL )
1727 {
1728 if ( pVideoMemory[ 0 ] == 0x01234567L )
1729 {
1730 /* Channel A 64bit */
1731 return ;
1732 }
1733 }
1734 else
1735 {
1736 if ( pVideoMemory[ 0 ] == 0x01234567L )
1737 {
1738 /* Channel A 32bit */
1739 XGINew_DataBusWidth = 32 ;
1740 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x00 ) ;
1741 return ;
1742 }
1743 }
1744
1745 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x03 ) ; /* Channel B, 64bit */
1746 XGINew_DDR_MRS( pVBInfo);
1747
1748 XGINew_ChannelAB = 1 ;
1749 XGINew_DataBusWidth = 64 ;
1750 pVideoMemory[ 0 ] = 0x01234567L ;
1751 pVideoMemory[ 1 ] = 0x456789ABL ;
1752 pVideoMemory[ 2 ] = 0x89ABCDEFL ;
1753 pVideoMemory[ 3 ] = 0xCDEF0123L ;
1754 pVideoMemory[ 4 ] = 0x55555555L ;
1755 pVideoMemory[ 5 ] = 0x55555555L ;
1756 pVideoMemory[ 6 ] = 0xAAAAAAAAL ;
1757 pVideoMemory[ 7 ] = 0xAAAAAAAAL ;
1758
1759 if ( pVideoMemory[ 1 ] == 0x456789ABL )
1760 {
1761 /* Channel B 64 */
1762 if ( pVideoMemory[ 0 ] == 0x01234567L )
1763 {
1764 /* Channel B 64bit */
1765 return ;
1766 }
1767 else
1768 {
1769 /* error */
1770 }
1771 }
1772 else
1773 {
1774 if ( pVideoMemory[ 0 ] == 0x01234567L )
1775 {
1776 /* Channel B 32 */
1777 XGINew_DataBusWidth = 32 ;
1778 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x01 ) ;
1779 }
1780 else
1781 {
1782 /* error */
1783 }
1784 }
1785 }
1786}
1787
1788
1789/* --------------------------------------------------------------------- */
1790/* Function : XGINew_SetRank */
1791/* Input : */
1792/* Output : */
1793/* Description : */
1794/* --------------------------------------------------------------------- */
1795int XGINew_SetRank( int index , UCHAR RankNo , UCHAR XGINew_ChannelAB , USHORT DRAMTYPE_TABLE[][ 5 ] , PVB_DEVICE_INFO pVBInfo)
1796{
1797 USHORT data ;
1798 int RankSize ;
1799
1800 if ( ( RankNo == 2 ) && ( DRAMTYPE_TABLE[ index ][ 0 ] == 2 ) )
1801 return 0 ;
1802
1803 RankSize = DRAMTYPE_TABLE[ index ][ 3 ] / 2 * XGINew_DataBusWidth / 32 ;
1804
1805 if ( ( RankNo * RankSize ) <= 128 )
1806 {
1807 data = 0 ;
1808
1809 while( ( RankSize >>= 1 ) > 0 )
1810 {
1811 data += 0x10 ;
1812 }
1813 data |= ( RankNo - 1 ) << 2 ;
1814 data |= ( XGINew_DataBusWidth / 64 ) & 2 ;
1815 data |= XGINew_ChannelAB ;
1816 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , data ) ;
1817 /* should delay */
1818 XGINew_SDR_MRS( pVBInfo ) ;
1819 return( 1 ) ;
1820 }
1821 else
1822 return( 0 ) ;
1823}
1824
1825
1826/* --------------------------------------------------------------------- */
1827/* Function : XGINew_SetDDRChannel */
1828/* Input : */
1829/* Output : */
1830/* Description : */
1831/* --------------------------------------------------------------------- */
1832int XGINew_SetDDRChannel( int index , UCHAR ChannelNo , UCHAR XGINew_ChannelAB , USHORT DRAMTYPE_TABLE[][ 5 ] , PVB_DEVICE_INFO pVBInfo)
1833{
1834 USHORT data ;
1835 int RankSize ;
1836
1837 RankSize = DRAMTYPE_TABLE[index][3]/2 * XGINew_DataBusWidth/32;
1838 /* RankSize = DRAMTYPE_TABLE[ index ][ 3 ] ; */
1839 if ( ChannelNo * RankSize <= 128 )
1840 {
1841 data = 0 ;
1842 while( ( RankSize >>= 1 ) > 0 )
1843 {
1844 data += 0x10 ;
1845 }
1846
1847 if ( ChannelNo == 2 )
1848 data |= 0x0C ;
1849
1850 data |= ( XGINew_DataBusWidth / 32 ) & 2 ;
1851 data |= XGINew_ChannelAB ;
1852 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , data ) ;
1853 /* should delay */
1854 XGINew_DDR_MRS( pVBInfo ) ;
1855 return( 1 ) ;
1856 }
1857 else
1858 return( 0 ) ;
1859}
1860
1861
1862/* --------------------------------------------------------------------- */
1863/* Function : XGINew_CheckColumn */
1864/* Input : */
1865/* Output : */
1866/* Description : */
1867/* --------------------------------------------------------------------- */
1868int XGINew_CheckColumn( int index , USHORT DRAMTYPE_TABLE[][ 5 ], PVB_DEVICE_INFO pVBInfo)
1869{
1870 int i ;
1871 ULONG Increment , Position ;
1872
1873 /* Increment = 1 << ( DRAMTYPE_TABLE[ index ][ 2 ] + XGINew_DataBusWidth / 64 + 1 ) ; */
1874 Increment = 1 << ( 10 + XGINew_DataBusWidth / 64 ) ;
1875
1876 for( i = 0 , Position = 0 ; i < 2 ; i++ )
1877 {
1878 *( ( PULONG )( pVBInfo->FBAddr + Position ) ) = Position ;
1879 Position += Increment ;
1880 }
1881
1882#ifdef WIN2000 /* chiawen for linux solution */
1883 DelayUS( 100 ) ;
1884#endif
1885
1886 for( i = 0 , Position = 0 ; i < 2 ; i++ )
1887 {
1888 /* if ( pVBInfo->FBAddr[ Position ] != Position ) */
1889 if ( ( *( PULONG )( pVBInfo->FBAddr + Position ) ) != Position )
1890 return( 0 ) ;
1891 Position += Increment ;
1892 }
1893 return( 1 ) ;
1894}
1895
1896
1897/* --------------------------------------------------------------------- */
1898/* Function : XGINew_CheckBanks */
1899/* Input : */
1900/* Output : */
1901/* Description : */
1902/* --------------------------------------------------------------------- */
1903int XGINew_CheckBanks( int index , USHORT DRAMTYPE_TABLE[][ 5 ], PVB_DEVICE_INFO pVBInfo)
1904{
1905 int i ;
1906 ULONG Increment , Position ;
1907
1908 Increment = 1 << ( DRAMTYPE_TABLE[ index ][ 2 ] + XGINew_DataBusWidth / 64 + 2 ) ;
1909
1910 for( i = 0 , Position = 0 ; i < 4 ; i++ )
1911 {
1912 /* pVBInfo->FBAddr[ Position ] = Position ; */
1913 *( ( PULONG )( pVBInfo->FBAddr + Position ) ) = Position ;
1914 Position += Increment ;
1915 }
1916
1917 for( i = 0 , Position = 0 ; i < 4 ; i++ )
1918 {
1919 /* if (pVBInfo->FBAddr[ Position ] != Position ) */
1920 if ( ( *( PULONG )( pVBInfo->FBAddr + Position ) ) != Position )
1921 return( 0 ) ;
1922 Position += Increment ;
1923 }
1924 return( 1 ) ;
1925}
1926
1927
1928/* --------------------------------------------------------------------- */
1929/* Function : XGINew_CheckRank */
1930/* Input : */
1931/* Output : */
1932/* Description : */
1933/* --------------------------------------------------------------------- */
1934int XGINew_CheckRank( int RankNo , int index , USHORT DRAMTYPE_TABLE[][ 5 ], PVB_DEVICE_INFO pVBInfo)
1935{
1936 int i ;
1937 ULONG Increment , Position ;
1938
1939 Increment = 1 << ( DRAMTYPE_TABLE[ index ][ 2 ] + DRAMTYPE_TABLE[ index ][ 1 ] +
1940 DRAMTYPE_TABLE[ index ][ 0 ] + XGINew_DataBusWidth / 64 + RankNo ) ;
1941
1942 for( i = 0 , Position = 0 ; i < 2 ; i++ )
1943 {
1944 /* pVBInfo->FBAddr[ Position ] = Position ; */
1945 /* *( ( PULONG )( pVBInfo->FBAddr ) ) = Position ; */
1946 *( ( PULONG )( pVBInfo->FBAddr + Position ) ) = Position ;
1947 Position += Increment ;
1948 }
1949
1950 for( i = 0 , Position = 0 ; i < 2 ; i++ )
1951 {
1952 /* if ( pVBInfo->FBAddr[ Position ] != Position ) */
1953 /* if ( ( *( PULONG )( pVBInfo->FBAddr ) ) != Position ) */
1954 if ( ( *( PULONG )( pVBInfo->FBAddr + Position ) ) != Position )
1955 return( 0 ) ;
1956 Position += Increment ;
1957 }
1958 return( 1 );
1959}
1960
1961
1962/* --------------------------------------------------------------------- */
1963/* Function : XGINew_CheckDDRRank */
1964/* Input : */
1965/* Output : */
1966/* Description : */
1967/* --------------------------------------------------------------------- */
1968int XGINew_CheckDDRRank( int RankNo , int index , USHORT DRAMTYPE_TABLE[][ 5 ], PVB_DEVICE_INFO pVBInfo)
1969{
1970 ULONG Increment , Position ;
1971 USHORT data ;
1972
1973 Increment = 1 << ( DRAMTYPE_TABLE[ index ][ 2 ] + DRAMTYPE_TABLE[ index ][ 1 ] +
1974 DRAMTYPE_TABLE[ index ][ 0 ] + XGINew_DataBusWidth / 64 + RankNo ) ;
1975
1976 Increment += Increment / 2 ;
1977
1978 Position = 0;
1979 *( ( PULONG )( pVBInfo->FBAddr + Position + 0 ) ) = 0x01234567 ;
1980 *( ( PULONG )( pVBInfo->FBAddr + Position + 1 ) ) = 0x456789AB ;
1981 *( ( PULONG )( pVBInfo->FBAddr + Position + 2 ) ) = 0x55555555 ;
1982 *( ( PULONG )( pVBInfo->FBAddr + Position + 3 ) ) = 0x55555555 ;
1983 *( ( PULONG )( pVBInfo->FBAddr + Position + 4 ) ) = 0xAAAAAAAA ;
1984 *( ( PULONG )( pVBInfo->FBAddr + Position + 5 ) ) = 0xAAAAAAAA ;
1985
1986 if ( ( *( PULONG )( pVBInfo->FBAddr + 1 ) ) == 0x456789AB )
1987 return( 1 ) ;
1988
1989 if ( ( *( PULONG )( pVBInfo->FBAddr + 0 ) ) == 0x01234567 )
1990 return( 0 ) ;
1991
1992 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ;
1993 data &= 0xF3 ;
1994 data |= 0x0E ;
1995 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , data ) ;
1996 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x15 ) ;
1997 data += 0x20 ;
1998 XGINew_SetReg1( pVBInfo->P3c4 , 0x15 , data ) ;
1999
2000 return( 1 ) ;
2001}
2002
2003
2004/* --------------------------------------------------------------------- */
2005/* Function : XGINew_CheckRanks */
2006/* Input : */
2007/* Output : */
2008/* Description : */
2009/* --------------------------------------------------------------------- */
2010int XGINew_CheckRanks( int RankNo , int index , USHORT DRAMTYPE_TABLE[][ 5 ], PVB_DEVICE_INFO pVBInfo)
2011{
2012 int r ;
2013
2014 for( r = RankNo ; r >= 1 ; r-- )
2015 {
2016 if ( !XGINew_CheckRank( r , index , DRAMTYPE_TABLE, pVBInfo ) )
2017 return( 0 ) ;
2018 }
2019
2020 if ( !XGINew_CheckBanks( index , DRAMTYPE_TABLE, pVBInfo ) )
2021 return( 0 ) ;
2022
2023 if ( !XGINew_CheckColumn( index , DRAMTYPE_TABLE, pVBInfo ) )
2024 return( 0 ) ;
2025
2026 return( 1 ) ;
2027}
2028
2029
2030/* --------------------------------------------------------------------- */
2031/* Function : XGINew_CheckDDRRanks */
2032/* Input : */
2033/* Output : */
2034/* Description : */
2035/* --------------------------------------------------------------------- */
2036int XGINew_CheckDDRRanks( int RankNo , int index , USHORT DRAMTYPE_TABLE[][ 5 ], PVB_DEVICE_INFO pVBInfo)
2037{
2038 int r ;
2039
2040 for( r = RankNo ; r >= 1 ; r-- )
2041 {
2042 if ( !XGINew_CheckDDRRank( r , index , DRAMTYPE_TABLE, pVBInfo ) )
2043 return( 0 ) ;
2044 }
2045
2046 if ( !XGINew_CheckBanks( index , DRAMTYPE_TABLE, pVBInfo ) )
2047 return( 0 ) ;
2048
2049 if ( !XGINew_CheckColumn( index , DRAMTYPE_TABLE, pVBInfo ) )
2050 return( 0 ) ;
2051
2052 return( 1 ) ;
2053}
2054
2055
2056/* --------------------------------------------------------------------- */
2057/* Function : */
2058/* Input : */
2059/* Output : */
2060/* Description : */
2061/* --------------------------------------------------------------------- */
2062int XGINew_SDRSizing(PVB_DEVICE_INFO pVBInfo)
2063{
2064 int i ;
2065 UCHAR j ;
2066
2067 for( i = 0 ; i < 13 ; i++ )
2068 {
2069 XGINew_SetDRAMSizingType( i , XGINew_SDRDRAM_TYPE , pVBInfo) ;
2070
2071 for( j = 2 ; j > 0 ; j-- )
2072 {
2073 if ( !XGINew_SetRank( i , ( UCHAR )j , XGINew_ChannelAB , XGINew_SDRDRAM_TYPE , pVBInfo) )
2074 continue ;
2075 else
2076 {
2077 if ( XGINew_CheckRanks( j , i , XGINew_SDRDRAM_TYPE, pVBInfo) )
2078 return( 1 ) ;
2079 }
2080 }
2081 }
2082 return( 0 ) ;
2083}
2084
2085
2086/* --------------------------------------------------------------------- */
2087/* Function : XGINew_SetDRAMSizeReg */
2088/* Input : */
2089/* Output : */
2090/* Description : */
2091/* --------------------------------------------------------------------- */
2092USHORT XGINew_SetDRAMSizeReg( int index , USHORT DRAMTYPE_TABLE[][ 5 ], PVB_DEVICE_INFO pVBInfo)
2093{
2094 USHORT data = 0 , memsize = 0 ;
2095 int RankSize ;
2096 UCHAR ChannelNo ;
2097
2098 RankSize = DRAMTYPE_TABLE[ index ][ 3 ] * XGINew_DataBusWidth / 32 ;
2099 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x13 ) ;
2100 data &= 0x80 ;
2101
2102 if ( data == 0x80 )
2103 RankSize *= 2 ;
2104
2105 data = 0 ;
2106
2107 if( XGINew_ChannelAB == 3 )
2108 ChannelNo = 4 ;
2109 else
2110 ChannelNo = XGINew_ChannelAB ;
2111
2112 if ( ChannelNo * RankSize <= 256 )
2113 {
2114 while( ( RankSize >>= 1 ) > 0 )
2115 {
2116 data += 0x10 ;
2117 }
2118
2119 memsize = data >> 4 ;
2120
2121 /* [2004/03/25] Vicent, Fix DRAM Sizing Error */
2122 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , ( XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) & 0x0F ) | ( data & 0xF0 ) ) ;
2123
2124 /* data |= XGINew_ChannelAB << 2 ; */
2125 /* data |= ( XGINew_DataBusWidth / 64 ) << 1 ; */
2126 /* XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , data ) ; */
2127
2128 /* should delay */
2129 /* XGINew_SetDRAMModeRegister340( pVBInfo ) ; */
2130 }
2131 return( memsize ) ;
2132}
2133
2134
2135/* --------------------------------------------------------------------- */
2136/* Function : XGINew_SetDRAMSize20Reg */
2137/* Input : */
2138/* Output : */
2139/* Description : */
2140/* --------------------------------------------------------------------- */
2141USHORT XGINew_SetDRAMSize20Reg( int index , USHORT DRAMTYPE_TABLE[][ 5 ], PVB_DEVICE_INFO pVBInfo)
2142{
2143 USHORT data = 0 , memsize = 0 ;
2144 int RankSize ;
2145 UCHAR ChannelNo ;
2146
2147 RankSize = DRAMTYPE_TABLE[ index ][ 3 ] * XGINew_DataBusWidth / 8 ;
2148 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x13 ) ;
2149 data &= 0x80 ;
2150
2151 if ( data == 0x80 )
2152 RankSize *= 2 ;
2153
2154 data = 0 ;
2155
2156 if( XGINew_ChannelAB == 3 )
2157 ChannelNo = 4 ;
2158 else
2159 ChannelNo = XGINew_ChannelAB ;
2160
2161 if ( ChannelNo * RankSize <= 256 )
2162 {
2163 while( ( RankSize >>= 1 ) > 0 )
2164 {
2165 data += 0x10 ;
2166 }
2167
2168 memsize = data >> 4 ;
2169
2170 /* [2004/03/25] Vicent, Fix DRAM Sizing Error */
2171 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , ( XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) & 0x0F ) | ( data & 0xF0 ) ) ;
2172 DelayUS( 15 ) ;
2173
2174 /* data |= XGINew_ChannelAB << 2 ; */
2175 /* data |= ( XGINew_DataBusWidth / 64 ) << 1 ; */
2176 /* XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , data ) ; */
2177
2178 /* should delay */
2179 /* XGINew_SetDRAMModeRegister340( pVBInfo ) ; */
2180 }
2181 return( memsize ) ;
2182}
2183
2184
2185/* --------------------------------------------------------------------- */
2186/* Function : XGINew_ReadWriteRest */
2187/* Input : */
2188/* Output : */
2189/* Description : */
2190/* --------------------------------------------------------------------- */
2191int XGINew_ReadWriteRest( USHORT StopAddr , USHORT StartAddr, PVB_DEVICE_INFO pVBInfo)
2192{
2193 int i ;
2194 ULONG Position = 0 ;
2195
2196 *( ( PULONG )( pVBInfo->FBAddr + Position ) ) = Position ;
2197
2198 for( i = StartAddr ; i <= StopAddr ; i++ )
2199 {
2200 Position = 1 << i ;
2201 *( ( PULONG )( pVBInfo->FBAddr + Position ) ) = Position ;
2202 }
2203
2204 DelayUS( 500 ) ; /* [Vicent] 2004/04/16. Fix #1759 Memory Size error in Multi-Adapter. */
2205
2206 Position = 0 ;
2207
2208 if ( ( *( PULONG )( pVBInfo->FBAddr + Position ) ) != Position )
2209 return( 0 ) ;
2210
2211 for( i = StartAddr ; i <= StopAddr ; i++ )
2212 {
2213 Position = 1 << i ;
2214 if ( ( *( PULONG )( pVBInfo->FBAddr + Position ) ) != Position )
2215 return( 0 ) ;
2216 }
2217 return( 1 ) ;
2218}
2219
2220
2221/* --------------------------------------------------------------------- */
2222/* Function : XGINew_CheckFrequence */
2223/* Input : */
2224/* Output : */
2225/* Description : */
2226/* --------------------------------------------------------------------- */
2227UCHAR XGINew_CheckFrequence( PVB_DEVICE_INFO pVBInfo )
2228{
2229 UCHAR data ;
2230
2231 data = XGINew_GetReg1( pVBInfo->P3d4 , 0x97 ) ;
2232
2233 if ( ( data & 0x10 ) == 0 )
2234 {
2235 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x39 ) ;
2236 data = ( data & 0x02 ) >> 1 ;
2237 return( data ) ;
2238 }
2239 else
2240 return( data & 0x01 ) ;
2241}
2242
2243
2244/* --------------------------------------------------------------------- */
2245/* Function : XGINew_CheckChannel */
2246/* Input : */
2247/* Output : */
2248/* Description : */
2249/* --------------------------------------------------------------------- */
2250void XGINew_CheckChannel( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
2251{
2252 UCHAR data;
2253
2254 switch( HwDeviceExtension->jChipType )
2255 {
2256 case XG20:
2257 case XG21:
2258 data = XGINew_GetReg1( pVBInfo->P3d4 , 0x97 ) ;
2259 data = data & 0x01;
2260 XGINew_ChannelAB = 1 ; /* XG20 "JUST" one channel */
2261
2262 if ( data == 0 ) /* Single_32_16 */
2263 {
2264
2265 if (( HwDeviceExtension->ulVideoMemorySize - 1 ) > 0x1000000)
2266 {
2267
2268 XGINew_DataBusWidth = 32 ; /* 32 bits */
2269 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0xB1 ) ; /* 22bit + 2 rank + 32bit */
2270 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x52 ) ;
2271 DelayUS( 15 ) ;
2272
2273 if ( XGINew_ReadWriteRest( 24 , 23 , pVBInfo ) == 1 )
2274 return ;
2275
2276 if (( HwDeviceExtension->ulVideoMemorySize - 1 ) > 0x800000)
2277 {
2278 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x31 ) ; /* 22bit + 1 rank + 32bit */
2279 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x42 ) ;
2280 DelayUS( 15 ) ;
2281
2282 if ( XGINew_ReadWriteRest( 23 , 23 , pVBInfo ) == 1 )
2283 return ;
2284 }
2285 }
2286
2287 if (( HwDeviceExtension->ulVideoMemorySize - 1 ) > 0x800000)
2288 {
2289 XGINew_DataBusWidth = 16 ; /* 16 bits */
2290 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0xB1 ) ; /* 22bit + 2 rank + 16bit */
2291 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x41 ) ;
2292 DelayUS( 15 ) ;
2293
2294 if ( XGINew_ReadWriteRest( 23 , 22 , pVBInfo ) == 1 )
2295 return ;
2296 else
2297 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x31 ) ;
2298 DelayUS( 15 ) ;
2299 }
2300
2301 }
2302 else /* Dual_16_8 */
2303 {
2304 if (( HwDeviceExtension->ulVideoMemorySize - 1 ) > 0x800000)
2305 {
2306
2307 XGINew_DataBusWidth = 16 ; /* 16 bits */
2308 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0xB1 ) ; /* (0x31:12x8x2) 22bit + 2 rank */
2309 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x41 ) ; /* 0x41:16Mx16 bit*/
2310 DelayUS( 15 ) ;
2311
2312 if ( XGINew_ReadWriteRest( 23 , 22 , pVBInfo ) == 1 )
2313 return ;
2314
2315 if (( HwDeviceExtension->ulVideoMemorySize - 1 ) > 0x400000)
2316 {
2317 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x31 ) ; /* (0x31:12x8x2) 22bit + 1 rank */
2318 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x31 ) ; /* 0x31:8Mx16 bit*/
2319 DelayUS( 15 ) ;
2320
2321 if ( XGINew_ReadWriteRest( 22 , 22 , pVBInfo ) == 1 )
2322 return ;
2323 }
2324 }
2325
2326
2327 if (( HwDeviceExtension->ulVideoMemorySize - 1 ) > 0x400000)
2328 {
2329 XGINew_DataBusWidth = 8 ; /* 8 bits */
2330 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0xB1 ) ; /* (0x31:12x8x2) 22bit + 2 rank */
2331 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x30 ) ; /* 0x30:8Mx8 bit*/
2332 DelayUS( 15 ) ;
2333
2334 if ( XGINew_ReadWriteRest( 22 , 21 , pVBInfo ) == 1 )
2335 return ;
2336 else
2337 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x31 ) ; /* (0x31:12x8x2) 22bit + 1 rank */
2338 DelayUS( 15 ) ;
2339 }
2340 }
2341 break ;
2342
2343 case XG27:
2344 XGINew_DataBusWidth = 16 ; /* 16 bits */
2345 XGINew_ChannelAB = 1 ; /* Single channel */
2346 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x51 ) ; /* 32Mx16 bit*/
2347 break ;
2348 case XG41:
2349 if ( XGINew_CheckFrequence(pVBInfo) == 1 )
2350 {
2351 XGINew_DataBusWidth = 32 ; /* 32 bits */
2352 XGINew_ChannelAB = 3 ; /* Quad Channel */
2353 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0xA1 ) ;
2354 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x4C ) ;
2355
2356 if ( XGINew_ReadWriteRest( 25 , 23 , pVBInfo ) == 1 )
2357 return ;
2358
2359 XGINew_ChannelAB = 2 ; /* Dual channels */
2360 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x48 ) ;
2361
2362 if ( XGINew_ReadWriteRest( 24 , 23 , pVBInfo ) == 1 )
2363 return ;
2364
2365 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x49 ) ;
2366
2367 if ( XGINew_ReadWriteRest( 24 , 23 , pVBInfo ) == 1 )
2368 return ;
2369
2370 XGINew_ChannelAB = 3 ;
2371 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x21 ) ;
2372 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x3C ) ;
2373
2374 if ( XGINew_ReadWriteRest( 24 , 23 , pVBInfo ) == 1 )
2375 return ;
2376
2377 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x38 ) ;
2378
2379 if ( XGINew_ReadWriteRest( 8 , 4 , pVBInfo ) == 1 )
2380 return ;
2381 else
2382 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x39 ) ;
2383 }
2384 else
2385 { /* DDR */
2386 XGINew_DataBusWidth = 64 ; /* 64 bits */
2387 XGINew_ChannelAB = 2 ; /* Dual channels */
2388 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0xA1 ) ;
2389 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x5A ) ;
2390
2391 if ( XGINew_ReadWriteRest( 25 , 24 , pVBInfo ) == 1 )
2392 return ;
2393
2394 XGINew_ChannelAB = 1 ; /* Single channels */
2395 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x52 ) ;
2396
2397 if ( XGINew_ReadWriteRest( 24 , 23 , pVBInfo ) == 1 )
2398 return ;
2399
2400 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x53 ) ;
2401
2402 if ( XGINew_ReadWriteRest( 24 , 23 , pVBInfo ) == 1 )
2403 return ;
2404
2405 XGINew_ChannelAB = 2 ; /* Dual channels */
2406 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x21 ) ;
2407 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x4A ) ;
2408
2409 if ( XGINew_ReadWriteRest( 24 , 23 , pVBInfo ) == 1 )
2410 return ;
2411
2412 XGINew_ChannelAB = 1 ; /* Single channels */
2413 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x42 ) ;
2414
2415 if ( XGINew_ReadWriteRest( 8 , 4 , pVBInfo ) == 1 )
2416 return ;
2417 else
2418 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x43 ) ;
2419 }
2420
2421 break ;
2422
2423 case XG42:
2424/*
2425 XG42 SR14 D[3] Reserve
2426 D[2] = 1, Dual Channel
2427 = 0, Single Channel
2428
2429 It's Different from Other XG40 Series.
2430*/
2431 if ( XGINew_CheckFrequence(pVBInfo) == 1 ) /* DDRII, DDR2x */
2432 {
2433 XGINew_DataBusWidth = 32 ; /* 32 bits */
2434 XGINew_ChannelAB = 2 ; /* 2 Channel */
2435 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0xA1 ) ;
2436 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x44 ) ;
2437
2438 if ( XGINew_ReadWriteRest( 24 , 23 , pVBInfo ) == 1 )
2439 return ;
2440
2441 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x21 ) ;
2442 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x34 ) ;
2443 if ( XGINew_ReadWriteRest( 23 , 22 , pVBInfo ) == 1 )
2444 return ;
2445
2446 XGINew_ChannelAB = 1 ; /* Single Channel */
2447 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0xA1 ) ;
2448 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x40 ) ;
2449
2450 if ( XGINew_ReadWriteRest( 23 , 22 , pVBInfo ) == 1 )
2451 return ;
2452 else
2453 {
2454 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x21 ) ;
2455 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x30 ) ;
2456 }
2457 }
2458 else
2459 { /* DDR */
2460 XGINew_DataBusWidth = 64 ; /* 64 bits */
2461 XGINew_ChannelAB = 1 ; /* 1 channels */
2462 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0xA1 ) ;
2463 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x52 ) ;
2464
2465 if ( XGINew_ReadWriteRest( 24 , 23 , pVBInfo ) == 1 )
2466 return ;
2467 else
2468 {
2469 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x21 ) ;
2470 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x42 ) ;
2471 }
2472 }
2473
2474 break ;
2475
2476 default: /* XG40 */
2477
2478 if ( XGINew_CheckFrequence(pVBInfo) == 1 ) /* DDRII */
2479 {
2480 XGINew_DataBusWidth = 32 ; /* 32 bits */
2481 XGINew_ChannelAB = 3 ;
2482 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0xA1 ) ;
2483 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x4C ) ;
2484
2485 if ( XGINew_ReadWriteRest( 25 , 23 , pVBInfo ) == 1 )
2486 return ;
2487
2488 XGINew_ChannelAB = 2 ; /* 2 channels */
2489 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x48 ) ;
2490
2491 if ( XGINew_ReadWriteRest( 24 , 23 , pVBInfo ) == 1 )
2492 return ;
2493
2494 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x21 ) ;
2495 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x3C ) ;
2496
2497 if ( XGINew_ReadWriteRest( 24 , 23 , pVBInfo ) == 1 )
2498 XGINew_ChannelAB = 3 ; /* 4 channels */
2499 else
2500 {
2501 XGINew_ChannelAB = 2 ; /* 2 channels */
2502 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x38 ) ;
2503 }
2504 }
2505 else
2506 { /* DDR */
2507 XGINew_DataBusWidth = 64 ; /* 64 bits */
2508 XGINew_ChannelAB = 2 ; /* 2 channels */
2509 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0xA1 ) ;
2510 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x5A ) ;
2511
2512 if ( XGINew_ReadWriteRest( 25 , 24 , pVBInfo ) == 1 )
2513 return ;
2514 else
2515 {
2516 XGINew_SetReg1( pVBInfo->P3c4 , 0x13 , 0x21 ) ;
2517 XGINew_SetReg1( pVBInfo->P3c4 , 0x14 , 0x4A ) ;
2518 }
2519 }
2520 break ;
2521 }
2522}
2523
2524
2525/* --------------------------------------------------------------------- */
2526/* Function : XGINew_DDRSizing340 */
2527/* Input : */
2528/* Output : */
2529/* Description : */
2530/* --------------------------------------------------------------------- */
2531int XGINew_DDRSizing340( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
2532{
2533 int i ;
2534 USHORT memsize , addr ;
2535
2536 XGINew_SetReg1( pVBInfo->P3c4 , 0x15 , 0x00 ) ; /* noninterleaving */
2537 XGINew_SetReg1( pVBInfo->P3c4 , 0x1C , 0x00 ) ; /* nontiling */
2538 XGINew_CheckChannel( HwDeviceExtension, pVBInfo ) ;
2539
2540
2541 if ( HwDeviceExtension->jChipType >= XG20 )
2542 {
2543 for( i = 0 ; i < 12 ; i++ )
2544 {
2545 XGINew_SetDRAMSizingType( i , XGINew_DDRDRAM_TYPE20, pVBInfo ) ;
2546 memsize = XGINew_SetDRAMSize20Reg( i , XGINew_DDRDRAM_TYPE20, pVBInfo ) ;
2547 if ( memsize == 0 )
2548 continue ;
2549
2550 addr = memsize + ( XGINew_ChannelAB - 2 ) + 20 ;
2551 if ( ( HwDeviceExtension->ulVideoMemorySize - 1 ) < ( ULONG )( 1 << addr ) )
2552 continue ;
2553
2554 if ( XGINew_ReadWriteRest( addr , 5, pVBInfo ) == 1 )
2555 return( 1 ) ;
2556 }
2557 }
2558 else
2559 {
2560 for( i = 0 ; i < 4 ; i++ )
2561 {
2562 XGINew_SetDRAMSizingType( i , XGINew_DDRDRAM_TYPE340, pVBInfo ) ;
2563 memsize = XGINew_SetDRAMSizeReg( i , XGINew_DDRDRAM_TYPE340, pVBInfo ) ;
2564
2565 if ( memsize == 0 )
2566 continue ;
2567
2568 addr = memsize + ( XGINew_ChannelAB - 2 ) + 20 ;
2569 if ( ( HwDeviceExtension->ulVideoMemorySize - 1 ) < ( ULONG )( 1 << addr ) )
2570 continue ;
2571
2572 if ( XGINew_ReadWriteRest( addr , 9, pVBInfo ) == 1 )
2573 return( 1 ) ;
2574 }
2575 }
2576 return( 0 ) ;
2577}
2578
2579
2580/* --------------------------------------------------------------------- */
2581/* Function : XGINew_DDRSizing */
2582/* Input : */
2583/* Output : */
2584/* Description : */
2585/* --------------------------------------------------------------------- */
2586int XGINew_DDRSizing(PVB_DEVICE_INFO pVBInfo)
2587{
2588 int i ;
2589 UCHAR j ;
2590
2591 for( i = 0 ; i < 4 ; i++ )
2592 {
2593 XGINew_SetDRAMSizingType( i , XGINew_DDRDRAM_TYPE, pVBInfo ) ;
2594 XGINew_DisableChannelInterleaving( i , XGINew_DDRDRAM_TYPE , pVBInfo) ;
2595 for( j = 2 ; j > 0 ; j-- )
2596 {
2597 XGINew_SetDDRChannel( i , j , XGINew_ChannelAB , XGINew_DDRDRAM_TYPE , pVBInfo ) ;
2598 if ( !XGINew_SetRank( i , ( UCHAR )j , XGINew_ChannelAB , XGINew_DDRDRAM_TYPE, pVBInfo ) )
2599 continue ;
2600 else
2601 {
2602 if ( XGINew_CheckDDRRanks( j , i , XGINew_DDRDRAM_TYPE, pVBInfo ) )
2603 return( 1 ) ;
2604 }
2605 }
2606 }
2607 return( 0 ) ;
2608}
2609
2610/* --------------------------------------------------------------------- */
2611/* Function : XGINew_SetMemoryClock */
2612/* Input : */
2613/* Output : */
2614/* Description : */
2615/* --------------------------------------------------------------------- */
2616void XGINew_SetMemoryClock( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
2617{
2618
2619
2620 XGINew_SetReg1( pVBInfo->P3c4 , 0x28 , pVBInfo->MCLKData[ XGINew_RAMType ].SR28 ) ;
2621 XGINew_SetReg1( pVBInfo->P3c4 , 0x29 , pVBInfo->MCLKData[ XGINew_RAMType ].SR29 ) ;
2622 XGINew_SetReg1( pVBInfo->P3c4 , 0x2A , pVBInfo->MCLKData[ XGINew_RAMType ].SR2A ) ;
2623
2624
2625
2626 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , pVBInfo->ECLKData[ XGINew_RAMType ].SR2E ) ;
2627 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , pVBInfo->ECLKData[ XGINew_RAMType ].SR2F ) ;
2628 XGINew_SetReg1( pVBInfo->P3c4 , 0x30 , pVBInfo->ECLKData[ XGINew_RAMType ].SR30 ) ;
2629
2630 /* [Vicent] 2004/07/07, When XG42 ECLK = MCLK = 207MHz, Set SR32 D[1:0] = 10b */
2631 /* [Hsuan] 2004/08/20, Modify SR32 value, when MCLK=207MHZ, ELCK=250MHz, Set SR32 D[1:0] = 10b */
2632 if ( HwDeviceExtension->jChipType == XG42 )
2633 {
2634 if ( ( pVBInfo->MCLKData[ XGINew_RAMType ].SR28 == 0x1C ) && ( pVBInfo->MCLKData[ XGINew_RAMType ].SR29 == 0x01 )
2635 && ( ( ( pVBInfo->ECLKData[ XGINew_RAMType ].SR2E == 0x1C ) && ( pVBInfo->ECLKData[ XGINew_RAMType ].SR2F == 0x01 ) )
2636 || ( ( pVBInfo->ECLKData[ XGINew_RAMType ].SR2E == 0x22 ) && ( pVBInfo->ECLKData[ XGINew_RAMType ].SR2F == 0x01 ) ) ) )
2637 {
2638 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , ( ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) & 0xFC ) | 0x02 ) ;
2639 }
2640 }
2641}
2642
2643
2644/* --------------------------------------------------------------------- */
2645/* Function : ChkLFB */
2646/* Input : */
2647/* Output : */
2648/* Description : */
2649/* --------------------------------------------------------------------- */
2650BOOLEAN ChkLFB( PVB_DEVICE_INFO pVBInfo )
2651{
2652 if ( LFBDRAMTrap & XGINew_GetReg1( pVBInfo->P3d4 , 0x78 ) )
2653 return( TRUE ) ;
2654 else
2655 return( FALSE );
2656}
2657
2658
2659/* --------------------------------------------------------------------- */
2660/* input : dx ,valid value : CR or second chip's CR */
2661/* */
2662/* SetPowerConsume : */
2663/* Description: reduce 40/43 power consumption in first chip or */
2664/* in second chip, assume CR A1 D[6]="1" in this case */
2665/* output : none */
2666/* --------------------------------------------------------------------- */
2667void SetPowerConsume ( PXGI_HW_DEVICE_INFO HwDeviceExtension , ULONG XGI_P3d4Port )
2668{
2669 ULONG lTemp ;
2670 UCHAR bTemp;
2671
2672 HwDeviceExtension->pQueryVGAConfigSpace( HwDeviceExtension , 0x08 , 0 , &lTemp ) ; /* Get */
2673 if ((lTemp&0xFF)==0)
2674 {
2675 /* set CR58 D[5]=0 D[3]=0 */
2676 XGINew_SetRegAND( XGI_P3d4Port , 0x58 , 0xD7 ) ;
2677 bTemp = (UCHAR) XGINew_GetReg1( XGI_P3d4Port , 0xCB ) ;
2678 if (bTemp&0x20)
2679 {
2680 if (!(bTemp&0x10))
2681 {
2682 XGINew_SetRegANDOR( XGI_P3d4Port , 0x58 , 0xD7 , 0x20 ) ; /* CR58 D[5]=1 D[3]=0 */
2683 }
2684 else
2685 {
2686 XGINew_SetRegANDOR( XGI_P3d4Port , 0x58 , 0xD7 , 0x08 ) ; /* CR58 D[5]=0 D[3]=1 */
2687 }
2688
2689 }
2690
2691 }
2692}
2693
2694
2695
2696#if defined(LINUX_XF86)||defined(LINUX_KERNEL)
2697void XGINew_InitVBIOSData(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
2698{
2699
2700 /* ULONG ROMAddr = (ULONG)HwDeviceExtension->pjVirtualRomBase; */
2701 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
2702 pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ;
2703 pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
2704 pVBInfo->ISXPDOS = 0 ;
2705
2706 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
2707 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
2708 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
2709 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
2710 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
2711 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
2712 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
2713 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
2714 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
2715 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
2716 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
2717 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
2718 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
2719 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
2720 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
2721 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
2722 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
2723 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
2724 XGI_GetVBType( pVBInfo ) ; /* Run XGI_GetVBType before InitTo330Pointer */
2725
2726 switch(HwDeviceExtension->jChipType)
2727 {
2728 case XG40:
2729 case XG41:
2730 case XG42:
2731 case XG20:
2732 case XG21:
2733 default:
2734 InitTo330Pointer(HwDeviceExtension->jChipType,pVBInfo);
2735 return ;
2736 }
2737
2738}
2739#endif /* For Linux */
2740
2741/* --------------------------------------------------------------------- */
2742/* Function : ReadVBIOSTablData */
2743/* Input : */
2744/* Output : */
2745/* Description : */
2746/* --------------------------------------------------------------------- */
2747void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo)
2748{
2749 PUCHAR volatile pVideoMemory = ( PUCHAR )pVBInfo->ROMAddr ;
2750 ULONG i ;
2751 UCHAR j , k ;
2752#if 0
2753 ULONG ii , jj ;
2754 i = pVideoMemory[ 0x1CF ] | ( pVideoMemory[ 0x1D0 ] << 8 ) ; /* UniROM */
2755 if ( i != 0 )
2756 UNIROM = 1 ;
2757
2758 ii = 0x90 ;
2759 for( jj = 0x00 ; jj < 0x08 ; jj++ )
2760 {
2761 pVBInfo->MCLKData[ jj ].SR28 = pVideoMemory[ ii ] ;
2762 pVBInfo->MCLKData[ jj ].SR29 = pVideoMemory[ ii + 1] ;
2763 pVBInfo->MCLKData[ jj ].SR2A = pVideoMemory[ ii + 2] ;
2764 pVBInfo->MCLKData[ jj ].CLOCK = pVideoMemory[ ii + 3 ] | ( pVideoMemory[ ii + 4 ] << 8 ) ;
2765 ii += 0x05 ;
2766 }
2767
2768 ii = 0xB8 ;
2769 for( jj = 0x00 ; jj < 0x08 ; jj++ )
2770 {
2771 pVBInfo->ECLKData[ jj ].SR2E = pVideoMemory[ ii ] ;
2772 pVBInfo->ECLKData[ jj ].SR2F=pVideoMemory[ ii + 1 ] ;
2773 pVBInfo->ECLKData[ jj ].SR30= pVideoMemory[ ii + 2 ] ;
2774 pVBInfo->ECLKData[ jj ].CLOCK= pVideoMemory[ ii + 3 ] | ( pVideoMemory[ ii + 4 ] << 8 ) ;
2775 ii += 0x05 ;
2776 }
2777
2778 /* Volari customize data area start */
2779 /* if ( ChipType == XG40 ) */
2780 if ( ChipType >= XG40 )
2781 {
2782 ii = 0xE0 ;
2783 for( jj = 0x00 ; jj < 0x03 ; jj++ )
2784 {
2785 pVBInfo->SR15[ jj ][ 0 ] = pVideoMemory[ ii ] ; /* SR13, SR14, and SR18 */
2786 pVBInfo->SR15[ jj ][ 1 ] = pVideoMemory[ ii + 1 ] ;
2787 pVBInfo->SR15[ jj ][ 2 ] = pVideoMemory[ ii + 2 ] ;
2788 pVBInfo->SR15[ jj ][ 3 ] = pVideoMemory[ ii + 3 ] ;
2789 pVBInfo->SR15[ jj ][ 4 ] = pVideoMemory[ ii + 4 ] ;
2790 pVBInfo->SR15[ jj ][ 5 ] = pVideoMemory[ ii + 5 ] ;
2791 pVBInfo->SR15[ jj ][ 6 ] = pVideoMemory[ ii + 6 ] ;
2792 pVBInfo->SR15[ jj ][ 7 ] = pVideoMemory[ ii + 7 ] ;
2793 ii += 0x08 ;
2794 }
2795 ii = 0x110 ;
2796 jj = 0x03 ;
2797 pVBInfo->SR15[ jj ][ 0 ] = pVideoMemory[ ii ] ; /* SR1B */
2798 pVBInfo->SR15[ jj ][ 1 ] = pVideoMemory[ ii + 1 ] ;
2799 pVBInfo->SR15[ jj ][ 2 ] = pVideoMemory[ ii + 2 ] ;
2800 pVBInfo->SR15[ jj ][ 3 ] = pVideoMemory[ ii + 3 ] ;
2801 pVBInfo->SR15[ jj ][ 4 ] = pVideoMemory[ ii + 4 ] ;
2802 pVBInfo->SR15[ jj ][ 5 ] = pVideoMemory[ ii + 5 ] ;
2803 pVBInfo->SR15[ jj ][ 6 ] = pVideoMemory[ ii + 6 ] ;
2804 pVBInfo->SR15[ jj ][ 7 ] = pVideoMemory[ ii + 7 ] ;
2805
2806 *pVBInfo->pSR07 = pVideoMemory[ 0x74 ] ;
2807 *pVBInfo->pSR1F = pVideoMemory[ 0x75 ] ;
2808 *pVBInfo->pSR21 = pVideoMemory[ 0x76 ] ;
2809 *pVBInfo->pSR22 = pVideoMemory[ 0x77 ] ;
2810 *pVBInfo->pSR23 = pVideoMemory[ 0x78 ] ;
2811 *pVBInfo->pSR24 = pVideoMemory[ 0x79 ] ;
2812 pVBInfo->SR25[ 0 ] = pVideoMemory[ 0x7A ] ;
2813 *pVBInfo->pSR31 = pVideoMemory[ 0x7B ] ;
2814 *pVBInfo->pSR32 = pVideoMemory[ 0x7C ] ;
2815 *pVBInfo->pSR33 = pVideoMemory[ 0x7D ] ;
2816 ii = 0xF8 ;
2817
2818 for( jj = 0 ; jj < 3 ; jj++ )
2819 {
2820 pVBInfo->CR40[ jj ][ 0 ] = pVideoMemory[ ii ] ;
2821 pVBInfo->CR40[ jj ][ 1 ] = pVideoMemory[ ii + 1 ] ;
2822 pVBInfo->CR40[ jj ][ 2 ] = pVideoMemory[ ii + 2 ] ;
2823 pVBInfo->CR40[ jj ][ 3 ] = pVideoMemory[ ii + 3 ] ;
2824 pVBInfo->CR40[ jj ][ 4 ] = pVideoMemory[ ii + 4 ] ;
2825 pVBInfo->CR40[ jj ][ 5 ] = pVideoMemory[ ii + 5 ] ;
2826 pVBInfo->CR40[ jj ][ 6 ] = pVideoMemory[ ii + 6 ] ;
2827 pVBInfo->CR40[ jj ][ 7 ] = pVideoMemory[ ii + 7 ] ;
2828 ii += 0x08 ;
2829 }
2830
2831 ii = 0x118 ;
2832 for( j = 3 ; j < 24 ; j++ )
2833 {
2834 pVBInfo->CR40[ j ][ 0 ] = pVideoMemory[ ii ] ;
2835 pVBInfo->CR40[ j ][ 1 ] = pVideoMemory[ ii + 1 ] ;
2836 pVBInfo->CR40[ j ][ 2 ] = pVideoMemory[ ii + 2 ] ;
2837 pVBInfo->CR40[ j ][ 3 ] = pVideoMemory[ ii + 3 ] ;
2838 pVBInfo->CR40[ j ][ 4 ] = pVideoMemory[ ii + 4 ] ;
2839 pVBInfo->CR40[ j ][ 5 ] = pVideoMemory[ ii + 5 ] ;
2840 pVBInfo->CR40[ j ][ 6 ] = pVideoMemory[ ii + 6 ] ;
2841 pVBInfo->CR40[ j ][ 7 ] = pVideoMemory[ ii + 7 ] ;
2842 ii += 0x08 ;
2843 }
2844
2845 i = pVideoMemory[ 0x1C0 ] | ( pVideoMemory[ 0x1C1 ] << 8 ) ;
2846
2847 for( j = 0 ; j < 8 ; j++ )
2848 {
2849 for( k = 0 ; k < 4 ; k++ )
2850 pVBInfo->CR6B[ j ][ k ] = pVideoMemory[ i + 4 * j + k ] ;
2851 }
2852
2853 i = pVideoMemory[ 0x1C2 ] | ( pVideoMemory[ 0x1C3 ] << 8 ) ;
2854
2855 for( j = 0 ; j < 8 ; j++ )
2856 {
2857 for( k = 0 ; k < 4 ; k++ )
2858 pVBInfo->CR6E[ j ][ k ] = pVideoMemory[ i + 4 * j + k ] ;
2859 }
2860
2861 i = pVideoMemory[ 0x1C4 ] | ( pVideoMemory[ 0x1C5 ] << 8 ) ;
2862 for( j = 0 ; j < 8 ; j++ )
2863 {
2864 for( k = 0 ; k < 32 ; k++ )
2865 pVBInfo->CR6F[ j ][ k ] = pVideoMemory[ i + 32 * j + k ] ;
2866 }
2867
2868 i = pVideoMemory[ 0x1C6 ] | ( pVideoMemory[ 0x1C7 ] << 8 ) ;
2869
2870 for( j = 0 ; j < 8 ; j++ )
2871 {
2872 for( k = 0 ; k < 2 ; k++ )
2873 pVBInfo->CR89[ j ][ k ] = pVideoMemory[ i + 2 * j + k ] ;
2874 }
2875
2876 i = pVideoMemory[ 0x1C8 ] | ( pVideoMemory[ 0x1C9 ] << 8 ) ;
2877 for( j = 0 ; j < 12 ; j++ )
2878 pVBInfo->AGPReg[ j ] = pVideoMemory[ i + j ] ;
2879
2880 i = pVideoMemory[ 0x1CF ] | ( pVideoMemory[ 0x1D0 ] << 8 ) ;
2881 for( j = 0 ; j < 4 ; j++ )
2882 pVBInfo->SR16[ j ] = pVideoMemory[ i + j ] ;
2883
2884 if ( ChipType == XG21 )
2885 {
2886 if (pVideoMemory[ 0x67 ] & 0x80)
2887 {
2888 *pVBInfo->pDVOSetting = pVideoMemory[ 0x67 ];
2889 }
2890 if ( (pVideoMemory[ 0x67 ] & 0xC0) == 0xC0 )
2891 {
2892 *pVBInfo->pCR2E = pVideoMemory[ i + 4 ] ;
2893 *pVBInfo->pCR2F = pVideoMemory[ i + 5 ] ;
2894 *pVBInfo->pCR46 = pVideoMemory[ i + 6 ] ;
2895 *pVBInfo->pCR47 = pVideoMemory[ i + 7 ] ;
2896 }
2897 }
2898
2899 if ( ChipType == XG27 )
2900 {
2901 jj = i+j;
2902 for( i = 0 ; i <= 0xB ; i++,jj++ )
2903 pVBInfo->pCRD0[i] = pVideoMemory[ jj ] ;
2904 for( i = 0x0 ; i <= 0x1 ; i++,jj++ )
2905 pVBInfo->pCRDE[i] = pVideoMemory[ jj ] ;
2906
2907 *pVBInfo->pSR40 = pVideoMemory[ jj ] ;
2908 jj++;
2909 *pVBInfo->pSR41 = pVideoMemory[ jj ] ;
2910
2911 if (pVideoMemory[ 0x67 ] & 0x80)
2912 {
2913 *pVBInfo->pDVOSetting = pVideoMemory[ 0x67 ];
2914 }
2915 if ( (pVideoMemory[ 0x67 ] & 0xC0) == 0xC0 )
2916 {
2917 jj++;
2918 *pVBInfo->pCR2E = pVideoMemory[ jj ] ;
2919 *pVBInfo->pCR2F = pVideoMemory[ jj + 1 ] ;
2920 *pVBInfo->pCR46 = pVideoMemory[ jj + 2 ] ;
2921 *pVBInfo->pCR47 = pVideoMemory[ jj + 3 ] ;
2922 }
2923
2924 }
2925
2926 *pVBInfo->pCRCF = pVideoMemory[ 0x1CA ] ;
2927 *pVBInfo->pXGINew_DRAMTypeDefinition = pVideoMemory[ 0x1CB ] ;
2928 *pVBInfo->pXGINew_I2CDefinition = pVideoMemory[ 0x1D1 ] ;
2929 if ( ChipType >= XG20 )
2930 {
2931 *pVBInfo->pXGINew_CR97 = pVideoMemory[ 0x1D2 ] ;
2932 if ( ChipType == XG27 )
2933 {
2934 *pVBInfo->pSR36 = pVideoMemory[ 0x1D3 ] ;
2935 *pVBInfo->pCR8F = pVideoMemory[ 0x1D5 ] ;
2936 }
2937 }
2938
2939 }
2940#endif
2941 /* Volari customize data area end */
2942
2943 if ( ChipType == XG21 )
2944 {
2945 pVBInfo->IF_DEF_LVDS = 0 ;
2946 if (pVideoMemory[ 0x65 ] & 0x1)
2947 {
2948 pVBInfo->IF_DEF_LVDS = 1 ;
2949 i = pVideoMemory[ 0x316 ] | ( pVideoMemory[ 0x317 ] << 8 );
2950 j = pVideoMemory[ i-1 ] ;
2951 if ( j != 0xff )
2952 {
2953 k = 0;
2954 do
2955 {
2956 pVBInfo->XG21_LVDSCapList[k].LVDS_Capability = pVideoMemory[ i ] | ( pVideoMemory[ i + 1 ] << 8 );
2957 pVBInfo->XG21_LVDSCapList[k].LVDSHT = pVideoMemory[ i + 2 ] | ( pVideoMemory[ i + 3 ] << 8 ) ;
2958 pVBInfo->XG21_LVDSCapList[k].LVDSVT = pVideoMemory[ i + 4 ] | ( pVideoMemory[ i + 5 ] << 8 );
2959 pVBInfo->XG21_LVDSCapList[k].LVDSHDE = pVideoMemory[ i + 6 ] | ( pVideoMemory[ i + 7 ] << 8 );
2960 pVBInfo->XG21_LVDSCapList[k].LVDSVDE = pVideoMemory[ i + 8 ] | ( pVideoMemory[ i + 9 ] << 8 );
2961 pVBInfo->XG21_LVDSCapList[k].LVDSHFP = pVideoMemory[ i + 10 ] | ( pVideoMemory[ i + 11 ] << 8 );
2962 pVBInfo->XG21_LVDSCapList[k].LVDSVFP = pVideoMemory[ i + 12 ] | ( pVideoMemory[ i + 13 ] << 8 );
2963 pVBInfo->XG21_LVDSCapList[k].LVDSHSYNC = pVideoMemory[ i + 14 ] | ( pVideoMemory[ i + 15 ] << 8 );
2964 pVBInfo->XG21_LVDSCapList[k].LVDSVSYNC = pVideoMemory[ i + 16 ] | ( pVideoMemory[ i + 17 ] << 8 );
2965 pVBInfo->XG21_LVDSCapList[k].VCLKData1 = pVideoMemory[ i + 18 ] ;
2966 pVBInfo->XG21_LVDSCapList[k].VCLKData2 = pVideoMemory[ i + 19 ] ;
2967 pVBInfo->XG21_LVDSCapList[k].PSC_S1 = pVideoMemory[ i + 20 ] ;
2968 pVBInfo->XG21_LVDSCapList[k].PSC_S2 = pVideoMemory[ i + 21 ] ;
2969 pVBInfo->XG21_LVDSCapList[k].PSC_S3 = pVideoMemory[ i + 22 ] ;
2970 pVBInfo->XG21_LVDSCapList[k].PSC_S4 = pVideoMemory[ i + 23 ] ;
2971 pVBInfo->XG21_LVDSCapList[k].PSC_S5 = pVideoMemory[ i + 24 ] ;
2972 i += 25;
2973 j--;
2974 k++;
2975 } while ( (j>0) && ( k < (sizeof(XGI21_LCDCapList)/sizeof(XGI21_LVDSCapStruct)) ) );
2976 }
2977 else
2978 {
2979 pVBInfo->XG21_LVDSCapList[0].LVDS_Capability = pVideoMemory[ i ] | ( pVideoMemory[ i + 1 ] << 8 );
2980 pVBInfo->XG21_LVDSCapList[0].LVDSHT = pVideoMemory[ i + 2 ] | ( pVideoMemory[ i + 3 ] << 8 ) ;
2981 pVBInfo->XG21_LVDSCapList[0].LVDSVT = pVideoMemory[ i + 4 ] | ( pVideoMemory[ i + 5 ] << 8 );
2982 pVBInfo->XG21_LVDSCapList[0].LVDSHDE = pVideoMemory[ i + 6 ] | ( pVideoMemory[ i + 7 ] << 8 );
2983 pVBInfo->XG21_LVDSCapList[0].LVDSVDE = pVideoMemory[ i + 8 ] | ( pVideoMemory[ i + 9 ] << 8 );
2984 pVBInfo->XG21_LVDSCapList[0].LVDSHFP = pVideoMemory[ i + 10 ] | ( pVideoMemory[ i + 11 ] << 8 );
2985 pVBInfo->XG21_LVDSCapList[0].LVDSVFP = pVideoMemory[ i + 12 ] | ( pVideoMemory[ i + 13 ] << 8 );
2986 pVBInfo->XG21_LVDSCapList[0].LVDSHSYNC = pVideoMemory[ i + 14 ] | ( pVideoMemory[ i + 15 ] << 8 );
2987 pVBInfo->XG21_LVDSCapList[0].LVDSVSYNC = pVideoMemory[ i + 16 ] | ( pVideoMemory[ i + 17 ] << 8 );
2988 pVBInfo->XG21_LVDSCapList[0].VCLKData1 = pVideoMemory[ i + 18 ] ;
2989 pVBInfo->XG21_LVDSCapList[0].VCLKData2 = pVideoMemory[ i + 19 ] ;
2990 pVBInfo->XG21_LVDSCapList[0].PSC_S1 = pVideoMemory[ i + 20 ] ;
2991 pVBInfo->XG21_LVDSCapList[0].PSC_S2 = pVideoMemory[ i + 21 ] ;
2992 pVBInfo->XG21_LVDSCapList[0].PSC_S3 = pVideoMemory[ i + 22 ] ;
2993 pVBInfo->XG21_LVDSCapList[0].PSC_S4 = pVideoMemory[ i + 23 ] ;
2994 pVBInfo->XG21_LVDSCapList[0].PSC_S5 = pVideoMemory[ i + 24 ] ;
2995 }
2996 }
2997 }
2998}
2999
3000/* --------------------------------------------------------------------- */
3001/* Function : XGINew_DDR1x_MRS_XG20 */
3002/* Input : */
3003/* Output : */
3004/* Description : */
3005/* --------------------------------------------------------------------- */
3006void XGINew_DDR1x_MRS_XG20( ULONG P3c4 , PVB_DEVICE_INFO pVBInfo)
3007{
3008
3009 XGINew_SetReg1( P3c4 , 0x18 , 0x01 ) ;
3010 XGINew_SetReg1( P3c4 , 0x19 , 0x40 ) ;
3011 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ;
3012 XGINew_SetReg1( P3c4 , 0x16 , 0x80 ) ;
3013 DelayUS( 60 ) ;
3014
3015 XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ;
3016 XGINew_SetReg1( P3c4 , 0x19 , 0x40 ) ;
3017 XGINew_SetReg1( P3c4 , 0x16 , 0x00 ) ;
3018 XGINew_SetReg1( P3c4 , 0x16 , 0x80 ) ;
3019 DelayUS( 60 ) ;
3020 XGINew_SetReg1( P3c4 , 0x18 , pVBInfo->SR15[ 2 ][ XGINew_RAMType ] ) ; /* SR18 */
3021 /* XGINew_SetReg1( P3c4 , 0x18 , 0x31 ) ; */
3022 XGINew_SetReg1( P3c4 , 0x19 , 0x01 ) ;
3023 XGINew_SetReg1( P3c4 , 0x16 , 0x03 ) ;
3024 XGINew_SetReg1( P3c4 , 0x16 , 0x83 ) ;
3025 DelayUS( 1000 ) ;
3026 XGINew_SetReg1( P3c4 , 0x1B , 0x03 ) ;
3027 DelayUS( 500 ) ;
3028 /* XGINew_SetReg1( P3c4 , 0x18 , 0x31 ) ; */
3029 XGINew_SetReg1( P3c4 , 0x18 , pVBInfo->SR15[ 2 ][ XGINew_RAMType ] ) ; /* SR18 */
3030 XGINew_SetReg1( P3c4 , 0x19 , 0x00 ) ;
3031 XGINew_SetReg1( P3c4 , 0x16 , 0x03 ) ;
3032 XGINew_SetReg1( P3c4 , 0x16 , 0x83 ) ;
3033 XGINew_SetReg1( P3c4 , 0x1B , 0x00 ) ;
3034}
3035
3036/* --------------------------------------------------------------------- */
3037/* Function : XGINew_SetDRAMModeRegister_XG20 */
3038/* Input : */
3039/* Output : */
3040/* Description : */
3041/* --------------------------------------------------------------------- */
3042void XGINew_SetDRAMModeRegister_XG20( PXGI_HW_DEVICE_INFO HwDeviceExtension )
3043{
3044 VB_DEVICE_INFO VBINF;
3045 PVB_DEVICE_INFO pVBInfo = &VBINF;
3046 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
3047 pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ;
3048 pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
3049 pVBInfo->ISXPDOS = 0 ;
3050
3051 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
3052 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
3053 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
3054 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
3055 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
3056 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
3057 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
3058 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
3059 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
3060 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
3061 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
3062 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
3063 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
3064 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
3065 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
3066 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
3067 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
3068
3069 InitTo330Pointer(HwDeviceExtension->jChipType,pVBInfo);
3070
3071 ReadVBIOSTablData( HwDeviceExtension->jChipType , pVBInfo) ;
3072
3073 if ( XGINew_GetXG20DRAMType( HwDeviceExtension, pVBInfo) == 0 )
3074 XGINew_DDR1x_MRS_XG20( pVBInfo->P3c4, pVBInfo ) ;
3075 else
3076 XGINew_DDR2_MRS_XG20( HwDeviceExtension , pVBInfo->P3c4 , pVBInfo ) ;
3077
3078 XGINew_SetReg1( pVBInfo->P3c4 , 0x1B , 0x03 ) ;
3079}
3080
3081void XGINew_SetDRAMModeRegister_XG27( PXGI_HW_DEVICE_INFO HwDeviceExtension )
3082{
3083 VB_DEVICE_INFO VBINF;
3084 PVB_DEVICE_INFO pVBInfo = &VBINF;
3085 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
3086 pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ;
3087 pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
3088 pVBInfo->ISXPDOS = 0 ;
3089
3090 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
3091 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
3092 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
3093 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
3094 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
3095 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
3096 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
3097 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
3098 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
3099 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
3100 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
3101 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
3102 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
3103 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
3104 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
3105 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
3106 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
3107
3108 InitTo330Pointer(HwDeviceExtension->jChipType,pVBInfo);
3109
3110 ReadVBIOSTablData( HwDeviceExtension->jChipType , pVBInfo) ;
3111
3112 if ( XGINew_GetXG20DRAMType( HwDeviceExtension, pVBInfo) == 0 )
3113 XGINew_DDR1x_MRS_XG20( pVBInfo->P3c4, pVBInfo ) ;
3114 else
3115 //XGINew_DDR2_MRS_XG27( HwDeviceExtension , pVBInfo->P3c4 , pVBInfo ) ;
3116 XGINew_DDRII_Bootup_XG27( HwDeviceExtension , pVBInfo->P3c4 , pVBInfo) ;
3117
3118 //XGINew_SetReg1( pVBInfo->P3c4 , 0x1B , 0x03 ) ;
3119 XGINew_SetReg1( pVBInfo->P3c4 , 0x1B , pVBInfo->SR15[ 3 ][ XGINew_RAMType ] ) ; /* SR1B */
3120
3121}
3122/*
3123void XGINew_SetDRAMModeRegister_XG27( PXGI_HW_DEVICE_INFO HwDeviceExtension )
3124{
3125#ifndef LINUX_XF86
3126 UCHAR data ;
3127#endif
3128 VB_DEVICE_INFO VBINF;
3129 PVB_DEVICE_INFO pVBInfo = &VBINF;
3130 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
3131 pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ;
3132 pVBInfo->BaseAddr = HwDeviceExtension->pjIOAddress ;
3133 pVBInfo->ISXPDOS = 0 ;
3134
3135 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
3136 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
3137 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
3138 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
3139 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
3140 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
3141 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
3142 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
3143 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
3144 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
3145 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
3146 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
3147 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
3148 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
3149 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
3150 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
3151 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
3152
3153 InitTo330Pointer(HwDeviceExtension->jChipType,pVBInfo);
3154
3155 ReadVBIOSTablData( HwDeviceExtension->jChipType , pVBInfo) ;
3156
3157 if ( XGINew_GetXG20DRAMType( HwDeviceExtension, pVBInfo) == 0 )
3158 XGINew_DDR1x_MRS_XG20( pVBInfo->P3c4, pVBInfo ) ;
3159 else
3160 XGINew_DDR2_MRS_XG27( HwDeviceExtension , pVBInfo->P3c4 , pVBInfo ) ;
3161
3162 XGINew_SetReg1( pVBInfo->P3c4 , 0x1B , 0x03 ) ;
3163}
3164*/
3165/* -------------------------------------------------------- */
3166/* Function : XGINew_ChkSenseStatus */
3167/* Input : */
3168/* Output : */
3169/* Description : */
3170/* -------------------------------------------------------- */
3171void XGINew_ChkSenseStatus ( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
3172{
3173 USHORT tempbx=0 , temp , tempcx , CR3CData;
3174
3175 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x32 ) ;
3176
3177 if ( temp & Monitor1Sense )
3178 tempbx |= ActiveCRT1 ;
3179 if ( temp & LCDSense )
3180 tempbx |= ActiveLCD ;
3181 if ( temp & Monitor2Sense )
3182 tempbx |= ActiveCRT2 ;
3183 if ( temp & TVSense )
3184 {
3185 tempbx |= ActiveTV ;
3186 if ( temp & AVIDEOSense )
3187 tempbx |= ( ActiveAVideo << 8 );
3188 if ( temp & SVIDEOSense )
3189 tempbx |= ( ActiveSVideo << 8 );
3190 if ( temp & SCARTSense )
3191 tempbx |= ( ActiveSCART << 8 );
3192 if ( temp & HiTVSense )
3193 tempbx |= ( ActiveHiTV << 8 );
3194 if ( temp & YPbPrSense )
3195 tempbx |= ( ActiveYPbPr << 8 );
3196 }
3197
3198 tempcx = XGINew_GetReg1( pVBInfo->P3d4 , 0x3d ) ;
3199 tempcx |= ( XGINew_GetReg1( pVBInfo->P3d4 , 0x3e ) << 8 ) ;
3200
3201 if ( tempbx & tempcx )
3202 {
3203 CR3CData = XGINew_GetReg1( pVBInfo->P3d4 , 0x3c ) ;
3204 if ( !( CR3CData & DisplayDeviceFromCMOS ) )
3205 {
3206 tempcx = 0x1FF0 ;
3207 if ( *pVBInfo->pSoftSetting & ModeSoftSetting )
3208 {
3209 tempbx = 0x1FF0 ;
3210 }
3211 }
3212 }
3213 else
3214 {
3215 tempcx = 0x1FF0 ;
3216 if ( *pVBInfo->pSoftSetting & ModeSoftSetting )
3217 {
3218 tempbx = 0x1FF0 ;
3219 }
3220 }
3221
3222 tempbx &= tempcx ;
3223 XGINew_SetReg1( pVBInfo->P3d4, 0x3d , ( tempbx & 0x00FF ) ) ;
3224 XGINew_SetReg1( pVBInfo->P3d4, 0x3e , ( ( tempbx & 0xFF00 ) >> 8 )) ;
3225}
3226/* -------------------------------------------------------- */
3227/* Function : XGINew_SetModeScratch */
3228/* Input : */
3229/* Output : */
3230/* Description : */
3231/* -------------------------------------------------------- */
3232void XGINew_SetModeScratch ( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo )
3233{
3234 USHORT temp , tempcl = 0 , tempch = 0 , CR31Data , CR38Data;
3235
3236 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x3d ) ;
3237 temp |= XGINew_GetReg1( pVBInfo->P3d4 , 0x3e ) << 8 ;
3238 temp |= ( XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) & ( DriverMode >> 8) ) << 8 ;
3239
3240 if ( pVBInfo->IF_DEF_CRT2Monitor == 1)
3241 {
3242 if ( temp & ActiveCRT2 )
3243 tempcl = SetCRT2ToRAMDAC ;
3244 }
3245
3246 if ( temp & ActiveLCD )
3247 {
3248 tempcl |= SetCRT2ToLCD ;
3249 if ( temp & DriverMode )
3250 {
3251 if ( temp & ActiveTV )
3252 {
3253 tempch = SetToLCDA | EnableDualEdge ;
3254 temp ^= SetCRT2ToLCD ;
3255
3256 if ( ( temp >> 8 ) & ActiveAVideo )
3257 tempcl |= SetCRT2ToAVIDEO ;
3258 if ( ( temp >> 8 ) & ActiveSVideo )
3259 tempcl |= SetCRT2ToSVIDEO ;
3260 if ( ( temp >> 8 ) & ActiveSCART )
3261 tempcl |= SetCRT2ToSCART ;
3262
3263 if ( pVBInfo->IF_DEF_HiVision == 1 )
3264 {
3265 if ( ( temp >> 8 ) & ActiveHiTV )
3266 tempcl |= SetCRT2ToHiVisionTV ;
3267 }
3268
3269 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3270 {
3271 if ( ( temp >> 8 ) & ActiveYPbPr )
3272 tempch |= SetYPbPr ;
3273 }
3274 }
3275 }
3276 }
3277 else
3278 {
3279 if ( ( temp >> 8 ) & ActiveAVideo )
3280 tempcl |= SetCRT2ToAVIDEO ;
3281 if ( ( temp >> 8 ) & ActiveSVideo )
3282 tempcl |= SetCRT2ToSVIDEO ;
3283 if ( ( temp >> 8 ) & ActiveSCART )
3284 tempcl |= SetCRT2ToSCART ;
3285
3286 if ( pVBInfo->IF_DEF_HiVision == 1 )
3287 {
3288 if ( ( temp >> 8 ) & ActiveHiTV )
3289 tempcl |= SetCRT2ToHiVisionTV ;
3290 }
3291
3292 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3293 {
3294 if ( ( temp >> 8 ) & ActiveYPbPr )
3295 tempch |= SetYPbPr ;
3296 }
3297 }
3298
3299
3300 tempcl |= SetSimuScanMode ;
3301 if ( (!( temp & ActiveCRT1 )) && ( ( temp & ActiveLCD ) || ( temp & ActiveTV ) || ( temp & ActiveCRT2 ) ) )
3302 tempcl ^= ( SetSimuScanMode | SwitchToCRT2 ) ;
3303 if ( ( temp & ActiveLCD ) && ( temp & ActiveTV ) )
3304 tempcl ^= ( SetSimuScanMode | SwitchToCRT2 ) ;
3305 XGINew_SetReg1( pVBInfo->P3d4, 0x30 , tempcl ) ;
3306
3307 CR31Data = XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
3308 CR31Data &= ~( SetNotSimuMode >> 8 ) ;
3309 if ( !( temp & ActiveCRT1 ) )
3310 CR31Data |= ( SetNotSimuMode >> 8 ) ;
3311 CR31Data &= ~( DisableCRT2Display >> 8 ) ;
3312 if (!( ( temp & ActiveLCD ) || ( temp & ActiveTV ) || ( temp & ActiveCRT2 ) ) )
3313 CR31Data |= ( DisableCRT2Display >> 8 ) ;
3314 XGINew_SetReg1( pVBInfo->P3d4, 0x31 , CR31Data ) ;
3315
3316 CR38Data = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
3317 CR38Data &= ~SetYPbPr ;
3318 CR38Data |= tempch ;
3319 XGINew_SetReg1( pVBInfo->P3d4, 0x38 , CR38Data ) ;
3320
3321}
3322
3323/* -------------------------------------------------------- */
3324/* Function : XGINew_GetXG21Sense */
3325/* Input : */
3326/* Output : */
3327/* Description : */
3328/* -------------------------------------------------------- */
3329void XGINew_GetXG21Sense(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
3330{
3331 UCHAR Temp;
3332 PUCHAR volatile pVideoMemory = ( PUCHAR )pVBInfo->ROMAddr ;
3333
3334 pVBInfo->IF_DEF_LVDS = 0 ;
3335
3336#ifdef WIN2000
3337 pVBInfo->IF_DEF_CH7007 = 0 ;
3338 if ( ( pVideoMemory[ 0x65 ] & 0x02 ) ) /* For XG21 CH7007 */
3339 {
3340 /* VideoDebugPrint((0, "ReadVBIOSTablData: pVideoMemory[ 0x65 ] =%x\n",pVideoMemory[ 0x65 ])); */
3341 pVBInfo->IF_DEF_CH7007 = 1 ; /* [Billy] 07/05/03 */
3342 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x38 , ~0xE0 , 0x60 ) ; /* CH7007 on chip */
3343 }
3344 else
3345#endif
3346#if 1
3347 if (( pVideoMemory[ 0x65 ] & 0x01 ) ) /* For XG21 LVDS */
3348 {
3349 pVBInfo->IF_DEF_LVDS = 1 ;
3350 XGINew_SetRegOR( pVBInfo->P3d4 , 0x32 , LCDSense ) ;
3351 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x38 , ~0xE0 , 0xC0 ) ; /* LVDS on chip */
3352 }
3353 else
3354 {
3355#endif
3356 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x4A , ~0x03 , 0x03 ) ; /* Enable GPIOA/B read */
3357 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) & 0xC0;
3358 if ( Temp == 0xC0 )
3359 { /* DVI & DVO GPIOA/B pull high */
3360 XGINew_SenseLCD( HwDeviceExtension, pVBInfo ) ;
3361 XGINew_SetRegOR( pVBInfo->P3d4 , 0x32 , LCDSense ) ;
3362 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x4A , ~0x20 , 0x20 ) ; /* Enable read GPIOF */
3363 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) & 0x04 ;
3364 if ( !Temp )
3365 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x38 , ~0xE0 , 0x80 ) ; /* TMDS on chip */
3366 else
3367 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x38 , ~0xE0 , 0xA0 ) ; /* Only DVO on chip */
3368 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Disable read GPIOF */
3369 }
3370#if 1
3371 }
3372#endif
3373}
3374
3375/* -------------------------------------------------------- */
3376/* Function : XGINew_GetXG27Sense */
3377/* Input : */
3378/* Output : */
3379/* Description : */
3380/* -------------------------------------------------------- */
3381void XGINew_GetXG27Sense(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
3382{
3383 UCHAR Temp,bCR4A;
3384
3385 pVBInfo->IF_DEF_LVDS = 0 ;
3386 bCR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
3387 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x4A , ~0x07 , 0x07 ) ; /* Enable GPIOA/B/C read */
3388 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) & 0x07;
3389 XGINew_SetReg1( pVBInfo->P3d4, 0x4A , bCR4A ) ;
3390
3391 if ( Temp <= 0x02 )
3392 {
3393 pVBInfo->IF_DEF_LVDS = 1 ;
3394 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x38 , ~0xE0 , 0xC0 ) ; /* LVDS setting */
3395 XGINew_SetReg1( pVBInfo->P3d4, 0x30 , 0x21 ) ;
3396 }
3397 else
3398 {
3399 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x38 , ~0xE0 , 0xA0 ) ; /* TMDS/DVO setting */
3400 }
3401 XGINew_SetRegOR( pVBInfo->P3d4 , 0x32 , LCDSense ) ;
3402
3403}
3404
3405UCHAR GetXG21FPBits(PVB_DEVICE_INFO pVBInfo)
3406{
3407 UCHAR CR38,CR4A,temp;
3408
3409 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
3410 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x4A , ~0x10 , 0x10 ) ; /* enable GPIOE read */
3411 CR38 = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
3412 temp =0;
3413 if ( ( CR38 & 0xE0 ) > 0x80 )
3414 {
3415 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
3416 temp &= 0x08;
3417 temp >>= 3;
3418 }
3419
3420 XGINew_SetReg1( pVBInfo->P3d4, 0x4A , CR4A ) ;
3421
3422 return temp;
3423}
3424
3425UCHAR GetXG27FPBits(PVB_DEVICE_INFO pVBInfo)
3426{
3427 UCHAR CR4A,temp;
3428
3429 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
3430 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x4A , ~0x03 , 0x03 ) ; /* enable GPIOA/B/C read */
3431 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
3432 if ( temp <= 2 )
3433 {
3434 temp &= 0x03;
3435 }
3436 else
3437 {
3438 temp = ((temp&0x04)>>1) || ((~temp)&0x01);
3439 }
3440 XGINew_SetReg1( pVBInfo->P3d4, 0x4A , CR4A ) ;
3441
3442 return temp;
3443}
3444
diff --git a/drivers/staging/xgifb/vb_init.h b/drivers/staging/xgifb/vb_init.h
new file mode 100644
index 00000000000..1f39d9c74cd
--- /dev/null
+++ b/drivers/staging/xgifb/vb_init.h
@@ -0,0 +1,7 @@
1#ifndef _VBINIT_
2#define _VBINIT_
3extern BOOLEAN XGIInitNew( PXGI_HW_DEVICE_INFO HwDeviceExtension ) ;
4extern XGI21_LVDSCapStruct XGI21_LCDCapList[13];
5
6#endif
7
diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c
new file mode 100644
index 00000000000..bd7f7389864
--- /dev/null
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -0,0 +1,10736 @@
1#include "osdef.h"
2
3#ifdef TC
4#include <stdio.h>
5#include <string.h>
6#include <conio.h>
7#include <dos.h>
8#endif
9
10
11#ifdef LINUX_XF86
12#include "xf86.h"
13#include "xf86PciInfo.h"
14#include "xgi.h"
15#include "xgi_regs.h"
16#endif
17
18#ifdef LINUX_KERNEL
19#include <asm/io.h>
20#include <linux/types.h>
21#include <linux/version.h>
22#include "XGIfb.h"
23/*#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
24#include <video/XGIfb.h>
25#else
26#include <linux/XGIfb.h>
27#endif*/
28#endif
29
30#ifdef WIN2000
31#include <dderror.h>
32#include <devioctl.h>
33#include <miniport.h>
34#include <ntddvdeo.h>
35#include <video.h>
36
37#include "xgiv.h"
38#include "dd_i2c.h"
39#include "tools.h"
40#endif
41
42#include "vb_def.h"
43#include "vgatypes.h"
44#include "vb_struct.h"
45#include "vb_util.h"
46#include "vb_table.h"
47
48
49
50#define IndexMask 0xff
51#ifndef XGI_MASK_DUAL_CHIP
52#define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
53#endif
54
55
56
57BOOLEAN XGI_IsLCDDualLink(PVB_DEVICE_INFO pVBInfo);
58BOOLEAN XGI_SetCRT2Group301(USHORT ModeNo, PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
59BOOLEAN XGI_BacklightByDrv(PVB_DEVICE_INFO pVBInfo);
60
61BOOLEAN XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo);
62BOOLEAN XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo);
63BOOLEAN XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo);
64BOOLEAN XGI_AjustCRT2Rate(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,USHORT *i, PVB_DEVICE_INFO pVBInfo);
65BOOLEAN XGI_SearchModeID( USHORT ModeNo,USHORT *ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
66BOOLEAN XGI_GetLCDInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
67BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo ) ;
68BOOLEAN XGI_BridgeIsOn(PVB_DEVICE_INFO pVBInfo);
69UCHAR XGI_GetModePtr( USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
70USHORT XGI_GetOffset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
71USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
72USHORT XGI_GetResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
73USHORT XGI_GetColorDepth(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
74USHORT XGI_GetVGAHT2(PVB_DEVICE_INFO pVBInfo);
75USHORT XGI_GetVCLK2Ptr(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
76void XGI_VBLongWait(PVB_DEVICE_INFO pVBInfo);
77void XGI_SaveCRT2Info(USHORT ModeNo, PVB_DEVICE_INFO pVBInfo);
78void XGI_GetCRT2Data(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
79void XGI_GetCRT2ResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
80void XGI_PreSetGroup1(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
81void XGI_SetGroup1(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
82void XGI_SetLockRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
83void XGI_SetLCDRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
84void XGI_SetGroup2(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
85void XGI_SetGroup3(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
86void XGI_SetGroup4(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
87void XGI_SetGroup5(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
88void* XGI_GetLcdPtr(USHORT BX, USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
89void* XGI_GetTVPtr(USHORT BX, USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
90void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo);
91void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
92void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
93void XGI_SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
94void XGI_SetPanelPower(USHORT tempah,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
95void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo);
96void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo);
97void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo);
98void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo);
99
100void XGI_DisplayOn(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
101void XGI_DisplayOff( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
102void XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
103void XGI_SetXG21CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
104void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo);
105void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
106void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo);
107void XGI_UpdateXG21CRTC(USHORT ModeNo, PVB_DEVICE_INFO pVBInfo, USHORT RefreshRateTableIndex);
108void XGI_WaitDisply(PVB_DEVICE_INFO pVBInfo);
109void XGI_SenseCRT1(PVB_DEVICE_INFO pVBInfo);
110void XGI_SetSeqRegs(USHORT ModeNo,USHORT StandTableIndex,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
111void XGI_SetMiscRegs(USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
112void XGI_SetCRTCRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
113void XGI_SetATTRegs(USHORT ModeNo,USHORT StandTableIndex,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
114void XGI_SetGRCRegs(USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
115void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo);
116
117void XGI_SetSync(USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
118void XGI_SetCRT1CRTC(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
119void XGI_SetCRT1Timing_H(PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
120void XGI_SetCRT1Timing_V(USHORT ModeIdIndex,USHORT ModeNo,PVB_DEVICE_INFO pVBInfo);
121void XGI_SetCRT1DE(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
122void XGI_SetCRT1VCLK(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
123void XGI_SetCRT1FIFO(USHORT ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
124void XGI_SetCRT1ModeRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
125void XGI_SetVCLKState(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
126
127void XGI_LoadDAC(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
128void XGI_WriteDAC(USHORT dl, USHORT ah, USHORT al, USHORT dh, PVB_DEVICE_INFO pVBInfo);
129/*void XGI_ClearBuffer(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,PVB_DEVICE_INFO pVBInfo);*/
130void XGI_SetLCDAGroup(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
131void XGI_GetLVDSResInfo( USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
132void XGI_GetLVDSData(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
133void XGI_ModCRT1Regs(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
134void XGI_SetLVDSRegs(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
135void XGI_UpdateModeInfo(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
136void XGI_GetVGAType(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
137void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo);
138void XGI_GetVBInfo(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
139void XGI_GetTVInfo(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
140void XGI_SetCRT2ECLK( USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
141void InitTo330Pointer(UCHAR,PVB_DEVICE_INFO pVBInfo);
142void XGI_GetLCDSync(USHORT* HSyncWidth, USHORT* VSyncWidth, PVB_DEVICE_INFO pVBInfo);
143void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
144void XGI_EnableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
145void XGI_SetCRT2VCLK(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
146void XGI_OEM310Setting(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
147void XGI_SetDelayComp(PVB_DEVICE_INFO pVBInfo);
148void XGI_SetLCDCap(PVB_DEVICE_INFO pVBInfo);
149void XGI_SetLCDCap_A(USHORT tempcx,PVB_DEVICE_INFO pVBInfo);
150void XGI_SetLCDCap_B(USHORT tempcx,PVB_DEVICE_INFO pVBInfo);
151void SetSpectrum(PVB_DEVICE_INFO pVBInfo);
152void XGI_SetAntiFlicker(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
153void XGI_SetEdgeEnhance(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
154void XGI_SetPhaseIncr(PVB_DEVICE_INFO pVBInfo);
155void XGI_SetYFilter(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
156void XGI_GetTVPtrIndex2(USHORT* tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo);
157USHORT XGI_GetTVPtrIndex( PVB_DEVICE_INFO pVBInfo );
158void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
159void XGI_CloseCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
160void XGI_OpenCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
161void XGI_GetRAMDAC2DATA(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
162void XGI_UnLockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
163void XGI_LockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
164void XGINew_EnableCRT2(PVB_DEVICE_INFO pVBInfo);
165void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo);
166void XGI_LongWait(PVB_DEVICE_INFO pVBInfo);
167void XGI_SetCRT1Offset( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo );
168void XGI_GetLCDVCLKPtr(UCHAR* di_0,UCHAR *di_1, PVB_DEVICE_INFO pVBInfo);
169UCHAR XGI_GetVCLKPtr(USHORT RefreshRateTableIndex,USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
170void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo);
171USHORT XGI_GetLCDCapPtr(PVB_DEVICE_INFO pVBInfo);
172USHORT XGI_GetLCDCapPtr1(PVB_DEVICE_INFO pVBInfo);
173XGI301C_Tap4TimingStruct* XGI_GetTap4Ptr(USHORT tempcx, PVB_DEVICE_INFO pVBInfo);
174void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo);
175void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo);
176UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo);
177UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo);
178void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
179void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
180void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
181BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
182void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
183void XGI_SetXG27LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
184UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo );
185
186extern void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo);
187#ifdef WIN2000
188/* [Billy] 2007/05/17 For CH7007 */
189extern UCHAR CH7007TVReg_UNTSC[][8],CH7007TVReg_ONTSC[][8],CH7007TVReg_UPAL[][8],CH7007TVReg_OPAL[][8];
190extern UCHAR CH7007TVCRT1UNTSC_H[][10],CH7007TVCRT1ONTSC_H[][10],CH7007TVCRT1UPAL_H[][10],CH7007TVCRT1OPAL_H[][10] ;
191extern UCHAR CH7007TVCRT1UNTSC_V[][10],CH7007TVCRT1ONTSC_V[][10],CH7007TVCRT1UPAL_V[][10],CH7007TVCRT1OPAL_V[][10] ;
192extern UCHAR XGI7007_CHTVVCLKUNTSC[],XGI7007_CHTVVCLKONTSC[],XGI7007_CHTVVCLKUPAL[],XGI7007_CHTVVCLKOPAL[];
193
194extern BOOLEAN XGI_XG21CheckCH7007TVMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo ) ;
195extern void SetCH7007Regs(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo ) ;
196extern VP_STATUS TurnOnCH7007(PHW_DEVICE_EXTENSION pHWDE) ;
197extern VP_STATUS TurnOffCH7007(PHW_DEVICE_EXTENSION pHWDE) ;
198extern BOOLEAN IsCH7007TVMode(PVB_DEVICE_INFO pVBInfo) ;
199#endif
200
201/* USHORT XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */
202
203
204
205
206
207USHORT XGINew_MDA_DAC[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
208 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
209 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
210 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
211 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
212 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
213 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
214 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F};
215
216USHORT XGINew_CGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
217 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
218 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
219 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
220 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
221 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
222 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
223 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F};
224
225USHORT XGINew_EGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x05,0x15,
226 0x20,0x30,0x24,0x34,0x21,0x31,0x25,0x35,
227 0x08,0x18,0x0C,0x1C,0x09,0x19,0x0D,0x1D,
228 0x28,0x38,0x2C,0x3C,0x29,0x39,0x2D,0x3D,
229 0x02,0x12,0x06,0x16,0x03,0x13,0x07,0x17,
230 0x22,0x32,0x26,0x36,0x23,0x33,0x27,0x37,
231 0x0A,0x1A,0x0E,0x1E,0x0B,0x1B,0x0F,0x1F,
232 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F};
233
234USHORT XGINew_VGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
235 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
236 0x00,0x05,0x08,0x0B,0x0E,0x11,0x14,0x18,
237 0x1C,0x20,0x24,0x28,0x2D,0x32,0x38,0x3F,
238
239 0x00,0x10,0x1F,0x2F,0x3F,0x1F,0x27,0x2F,
240 0x37,0x3F,0x2D,0x31,0x36,0x3A,0x3F,0x00,
241 0x07,0x0E,0x15,0x1C,0x0E,0x11,0x15,0x18,
242 0x1C,0x14,0x16,0x18,0x1A,0x1C,0x00,0x04,
243 0x08,0x0C,0x10,0x08,0x0A,0x0C,0x0E,0x10,
244 0x0B,0x0C,0x0D,0x0F,0x10};
245
246
247/* --------------------------------------------------------------------- */
248/* Function : InitTo330Pointer */
249/* Input : */
250/* Output : */
251/* Description : */
252/* --------------------------------------------------------------------- */
253void InitTo330Pointer( UCHAR ChipType ,PVB_DEVICE_INFO pVBInfo)
254{
255 pVBInfo->SModeIDTable = (XGI_StStruct *) XGI330_SModeIDTable ;
256 pVBInfo->StandTable = (XGI_StandTableStruct *) XGI330_StandTable ;
257 pVBInfo->EModeIDTable = (XGI_ExtStruct *) XGI330_EModeIDTable ;
258 pVBInfo->RefIndex = (XGI_Ext2Struct *) XGI330_RefIndex ;
259 pVBInfo->XGINEWUB_CRT1Table = (XGI_CRT1TableStruct *) XGI_CRT1Table ;
260
261 /* add for new UNIVGABIOS */
262 /* XGINew_UBLCDDataTable = (XGI_LCDDataTablStruct *) XGI_LCDDataTable ; */
263 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable ; */
264
265
266 if ( ChipType >= XG40 )
267 {
268 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI340New_MCLKData ;
269 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI340_ECLKData ;
270 }
271 else
272 {
273 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI330New_MCLKData ;
274 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI330_ECLKData ;
275 }
276
277 pVBInfo->VCLKData = (XGI_VCLKDataStruct *) XGI_VCLKData ;
278 pVBInfo->VBVCLKData = (XGI_VBVCLKDataStruct *) XGI_VBVCLKData ;
279 pVBInfo->ScreenOffset = XGI330_ScreenOffset ;
280 pVBInfo->StResInfo = (XGI_StResInfoStruct *) XGI330_StResInfo ;
281 pVBInfo->ModeResInfo = (XGI_ModeResInfoStruct *) XGI330_ModeResInfo ;
282
283 pVBInfo->pOutputSelect = &XGI330_OutputSelect ;
284 pVBInfo->pSoftSetting = &XGI330_SoftSetting ;
285 pVBInfo->pSR07 = &XGI330_SR07 ;
286 pVBInfo->LCDResInfo = 0 ;
287 pVBInfo->LCDTypeInfo = 0 ;
288 pVBInfo->LCDInfo = 0 ;
289 pVBInfo->VBInfo = 0 ;
290 pVBInfo->TVInfo = 0;
291
292
293 pVBInfo->SR15 = XGI340_SR13 ;
294 pVBInfo->CR40 = XGI340_cr41 ;
295 pVBInfo->SR25 = XGI330_sr25 ;
296 pVBInfo->pSR31 = &XGI330_sr31 ;
297 pVBInfo->pSR32 = &XGI330_sr32 ;
298 pVBInfo->CR6B = XGI340_CR6B ;
299 pVBInfo->CR6E = XGI340_CR6E ;
300 pVBInfo->CR6F = XGI340_CR6F ;
301 pVBInfo->CR89 = XGI340_CR89 ;
302 pVBInfo->AGPReg = XGI340_AGPReg ;
303 pVBInfo->SR16 = XGI340_SR16 ;
304 pVBInfo->pCRCF = &XG40_CRCF ;
305 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition ;
306
307
308 pVBInfo->CR49 = XGI330_CR49 ;
309 pVBInfo->pSR1F = &XGI330_SR1F ;
310 pVBInfo->pSR21 = &XGI330_SR21 ;
311 pVBInfo->pSR22 = &XGI330_SR22 ;
312 pVBInfo->pSR23 = &XGI330_SR23 ;
313 pVBInfo->pSR24 = &XGI330_SR24 ;
314 pVBInfo->pSR33 = &XGI330_SR33 ;
315
316
317
318 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2 ;
319 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D ;
320 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E ;
321 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10 ;
322 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData ;
323 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData ;
324 pVBInfo->pYCSenseData = &XGI330_YCSenseData ;
325 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2 ;
326 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2 ;
327 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2 ;
328
329 pVBInfo->NTSCTiming = XGI330_NTSCTiming ;
330 pVBInfo->PALTiming = XGI330_PALTiming ;
331 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming ;
332 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing ;
333 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing ;
334 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming ;
335 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming ;
336 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming ;
337 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming ;
338 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data ;
339 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu ;
340 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text ;
341 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3 ;
342 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3 ;
343
344
345 pVBInfo->TimingH = (XGI_TimingHStruct *) XGI_TimingH ;
346 pVBInfo->TimingV = (XGI_TimingVStruct *) XGI_TimingV ;
347 pVBInfo->UpdateCRT1 = (XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table ;
348
349 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC ;
350 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC ;
351 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL ;
352 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL ;
353
354 /* 310 customization related */
355 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
356 pVBInfo->LCDCapList = XGI_LCDDLCapList ;
357 else
358 pVBInfo->LCDCapList = XGI_LCDCapList ;
359
360 if ( ( ChipType == XG21 ) || ( ChipType == XG27 ) )
361 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList ;
362
363 pVBInfo->XGI_TVDelayList = XGI301TVDelayList ;
364 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2 ;
365
366
367 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition ;
368
369 if ( ChipType >= XG20 )
370 pVBInfo->pXGINew_CR97 = &XG20_CR97 ;
371
372 if ( ChipType == XG27 )
373 {
374 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI27New_MCLKData ;
375 pVBInfo->CR40 = XGI27_cr41 ;
376 pVBInfo->pXGINew_CR97 = &XG27_CR97 ;
377 pVBInfo->pSR36 = &XG27_SR36 ;
378 pVBInfo->pCR8F = &XG27_CR8F ;
379 pVBInfo->pCRD0 = XG27_CRD0 ;
380 pVBInfo->pCRDE = XG27_CRDE ;
381 pVBInfo->pSR40 = &XG27_SR40 ;
382 pVBInfo->pSR41 = &XG27_SR41 ;
383
384 }
385
386 if ( ChipType >= XG20 )
387 {
388 pVBInfo->pDVOSetting = &XG21_DVOSetting ;
389 pVBInfo->pCR2E = &XG21_CR2E ;
390 pVBInfo->pCR2F = &XG21_CR2F ;
391 pVBInfo->pCR46 = &XG21_CR46 ;
392 pVBInfo->pCR47 = &XG21_CR47 ;
393 }
394
395}
396
397
398
399
400
401
402/* --------------------------------------------------------------------- */
403/* Function : XGISetModeNew */
404/* Input : */
405/* Output : */
406/* Description : */
407/* --------------------------------------------------------------------- */
408BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo )
409{
410 USHORT ModeIdIndex ;
411 /* PUCHAR pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ; */
412 VB_DEVICE_INFO VBINF;
413 PVB_DEVICE_INFO pVBInfo = &VBINF;
414 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
415 pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
416 pVBInfo->IF_DEF_LVDS = 0 ;
417 pVBInfo->IF_DEF_CH7005 = 0 ;
418 pVBInfo->IF_DEF_LCDA = 1 ;
419 pVBInfo->IF_DEF_CH7017 = 0 ;
420 pVBInfo->IF_DEF_CH7007 = 0 ; /* [Billy] 2007/05/14 */
421 pVBInfo->IF_DEF_VideoCapture = 0 ;
422 pVBInfo->IF_DEF_ScaleLCD = 0 ;
423 pVBInfo->IF_DEF_OEMUtil = 0 ;
424 pVBInfo->IF_DEF_PWD = 0 ;
425
426
427 if ( HwDeviceExtension->jChipType >= XG20 ) /* kuku 2004/06/25 */
428 {
429 pVBInfo->IF_DEF_YPbPr = 0 ;
430 pVBInfo->IF_DEF_HiVision = 0 ;
431 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
432 pVBInfo->VBType = 0 ; /*set VBType default 0*/
433 }
434 else if ( HwDeviceExtension->jChipType >= XG40 )
435 {
436 pVBInfo->IF_DEF_YPbPr = 1 ;
437 pVBInfo->IF_DEF_HiVision = 1 ;
438 pVBInfo->IF_DEF_CRT2Monitor = 1 ;
439 }
440 else
441 {
442 pVBInfo->IF_DEF_YPbPr = 1 ;
443 pVBInfo->IF_DEF_HiVision = 1 ;
444 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
445 }
446
447 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
448 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
449 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
450 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
451 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
452 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C ;
453 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
454 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
455 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
456 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
457 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
458 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
459 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
460 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
461 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
462 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
463 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
464 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
465
466 if ( HwDeviceExtension->jChipType == XG21 ) /* for x86 Linux, XG21 LVDS */
467 {
468 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
469 {
470 pVBInfo->IF_DEF_LVDS = 1 ;
471 }
472 }
473 if ( HwDeviceExtension->jChipType == XG27 )
474 {
475 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
476 {
477 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) & 0x20 )
478 {
479 pVBInfo->IF_DEF_LVDS = 1 ;
480 }
481 }
482 }
483
484 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
485 XGI_GetVBType( pVBInfo ) ;
486
487 InitTo330Pointer( HwDeviceExtension->jChipType, pVBInfo ) ;
488#ifdef WIN2000
489 ReadVBIOSTablData( HwDeviceExtension->jChipType , pVBInfo) ;
490#endif
491 if ( ModeNo & 0x80 )
492 {
493 ModeNo = ModeNo & 0x7F ;
494/* XGINew_flag_clearbuffer = 0 ; */
495 }
496/* else
497 {
498 XGINew_flag_clearbuffer = 1 ;
499 }
500*/
501 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
502
503 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 1.Openkey */
504 XGI_UnLockCRT2( HwDeviceExtension , pVBInfo ) ;
505
506 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
507
508 XGI_GetVGAType(HwDeviceExtension, pVBInfo) ;
509
510 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
511 {
512 XGI_GetVBInfo(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
513 XGI_GetTVInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
514 XGI_GetLCDInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
515 XGI_DisableBridge( HwDeviceExtension,pVBInfo ) ;
516/* XGI_OpenCRTC( HwDeviceExtension, pVBInfo ) ; */
517
518 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA ) )
519 {
520 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
521
522 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
523 {
524 XGI_SetLCDAGroup(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
525 }
526 }
527 else
528 {
529 if ( !( pVBInfo->VBInfo & SwitchToCRT2) )
530 {
531 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
532 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
533 {
534 XGI_SetLCDAGroup( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
535 }
536 }
537 }
538
539 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SwitchToCRT2 ) )
540 {
541 switch( HwDeviceExtension->ujVBChipID )
542 {
543 case VB_CHIP_301:
544 XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
545 break ;
546
547 case VB_CHIP_302:
548 XGI_SetCRT2Group301(ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
549 break ;
550
551 default:
552 break ;
553 }
554 }
555
556 XGI_SetCRT2ModeRegs( ModeNo, HwDeviceExtension,pVBInfo ) ;
557 XGI_OEM310Setting( ModeNo, ModeIdIndex,pVBInfo ) ; /*0212*/
558 XGI_CloseCRTC( HwDeviceExtension, pVBInfo ) ;
559 XGI_EnableBridge( HwDeviceExtension ,pVBInfo) ;
560 } /* !XG20 */
561 else
562 {
563#ifdef WIN2000
564 if ( pVBInfo->IF_DEF_CH7007 == 1 )
565 {
566
567 VideoDebugPrint((0, "XGISetModeNew: pVBIfo->IF_DEF_CH7007==1\n"));
568 pVBInfo->VBType = VB_CH7007 ;
569 XGI_GetVBInfo(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
570 XGI_GetTVInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
571 XGI_GetLCDInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
572 if( !(XGI_XG21CheckCH7007TVMode(ModeNo, ModeIdIndex, pVBInfo )) )
573 {
574 return FALSE;
575 }
576 }
577#endif
578
579
580 if ( pVBInfo->IF_DEF_LVDS == 1 )
581 {
582 if ( !XGI_XG21CheckLVDSMode(ModeNo , ModeIdIndex, pVBInfo) )
583 {
584 return FALSE;
585 }
586 }
587
588 if ( ModeNo <= 0x13 )
589 {
590 pVBInfo->ModeType = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag & ModeInfoFlag;
591 }
592 else
593 {
594 pVBInfo->ModeType = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & ModeInfoFlag;
595 }
596
597 pVBInfo->SetFlag = 0 ;
598 if ( pVBInfo->IF_DEF_CH7007 != 1 )
599 {
600 pVBInfo->VBInfo = DisableCRT2Display ;
601 }
602
603
604 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
605
606 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
607
608 XGI_DisplayOn( HwDeviceExtension, pVBInfo ) ;
609 /*
610 if( HwDeviceExtension->jChipType == XG21 )
611 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ;
612 */
613 }
614
615
616/*
617 if ( ModeNo <= 0x13 )
618 {
619 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
620 }
621 else
622 {
623 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
624 }
625 pVBInfo->ModeType = modeflag&ModeInfoFlag ;
626 pVBInfo->SetFlag = 0x00 ;
627 pVBInfo->VBInfo = DisableCRT2Display ;
628 temp = XGINew_CheckMemorySize( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
629
630 if ( temp == 0 )
631 return( 0 ) ;
632
633 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
634 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
635 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
636*/
637
638 XGI_UpdateModeInfo( HwDeviceExtension, pVBInfo ) ;
639
640 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
641{
642 XGI_LockCRT2( HwDeviceExtension, pVBInfo ) ;
643}
644
645 return( TRUE ) ;
646}
647
648
649/* --------------------------------------------------------------------- */
650/* Function : XGI_SetCRT1Group */
651/* Input : */
652/* Output : */
653/* Description : */
654/* --------------------------------------------------------------------- */
655void XGI_SetCRT1Group( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
656{
657 USHORT StandTableIndex ,
658 RefreshRateTableIndex ,
659 b3CC ,
660 temp ;
661
662 USHORT XGINew_P3cc = pVBInfo->P3cc;
663
664 /* XGINew_CRT1Mode = ModeNo ; // SaveModeID */
665 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
666 /* XGI_SetBIOSData(ModeNo , ModeIdIndex ) ; */
667 /* XGI_ClearBankRegs( ModeNo , ModeIdIndex ) ; */
668 XGI_SetSeqRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
669 XGI_SetMiscRegs( StandTableIndex, pVBInfo ) ;
670 XGI_SetCRTCRegs( HwDeviceExtension , StandTableIndex, pVBInfo) ;
671 XGI_SetATTRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
672 XGI_SetGRCRegs( StandTableIndex, pVBInfo ) ;
673 XGI_ClearExt1Regs(pVBInfo) ;
674
675/* if ( pVBInfo->IF_DEF_ExpLink ) */
676 if ( HwDeviceExtension->jChipType == XG27 )
677 {
678 if ( pVBInfo->IF_DEF_LVDS == 0 )
679 {
680 XGI_SetDefaultVCLK( pVBInfo ) ;
681 }
682 }
683
684 temp = ~ProgrammingCRT2 ;
685 pVBInfo->SetFlag &= temp ;
686 pVBInfo->SelectCRT2Rate = 0 ;
687
688 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
689 {
690 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA | SetInSlaveMode ) )
691 {
692 pVBInfo->SetFlag |= ProgrammingCRT2 ;
693 }
694 }
695
696 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
697 if ( RefreshRateTableIndex != 0xFFFF )
698 {
699 XGI_SetSync( RefreshRateTableIndex, pVBInfo ) ;
700 XGI_SetCRT1CRTC( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo, HwDeviceExtension ) ;
701 XGI_SetCRT1DE( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
702 XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
703 XGI_SetCRT1VCLK( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
704 }
705
706 if ( ( HwDeviceExtension->jChipType >= XG20 )&&
707 ( HwDeviceExtension->jChipType < XG27 ) ) /* fix H/W DCLK/2 bug */
708 {
709 if ( ( ModeNo == 0x00 ) | (ModeNo == 0x01) )
710 {
711 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x4E) ;
712 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE9) ;
713 b3CC =(UCHAR) XGINew_GetReg2(XGINew_P3cc) ;
714 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
715 }
716 else if ( ( ModeNo == 0x04) | ( ModeNo == 0x05) | ( ModeNo == 0x0D) )
717 {
718 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B) ;
719 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE3) ;
720 b3CC = (UCHAR)XGINew_GetReg2(XGINew_P3cc) ;
721 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
722 }
723 }
724
725 if ( HwDeviceExtension->jChipType >= XG21 )
726 {
727 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
728 if ( temp & 0xA0 )
729 {
730
731 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ;*/ /* Enable write GPIOF */
732 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* P. DWN */
733 /* XG21 CRT1 Timing */
734 if ( HwDeviceExtension->jChipType == XG27 )
735 XGI_SetXG27CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
736 else
737 XGI_SetXG21CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
738
739 XGI_UpdateXG21CRTC( ModeNo , pVBInfo , RefreshRateTableIndex) ;
740
741 if ( HwDeviceExtension->jChipType == XG27 )
742 XGI_SetXG27LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
743 else
744 XGI_SetXG21LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
745
746 if ( pVBInfo->IF_DEF_LVDS == 1 )
747 {
748 if ( HwDeviceExtension->jChipType == XG27 )
749 XGI_SetXG27LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
750 else
751 XGI_SetXG21LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
752 }
753 /*XGINew_SetRegOR( pVBInfo->P3d4 , 0x48 , 0x20 ) ;*/ /* P. ON */
754 }
755 }
756
757 pVBInfo->SetFlag &= ( ~ProgrammingCRT2 ) ;
758 XGI_SetCRT1FIFO( ModeNo , HwDeviceExtension, pVBInfo ) ;
759 XGI_SetCRT1ModeRegs( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex , pVBInfo) ;
760
761
762 /* XGI_LoadCharacter(); //dif ifdef TVFont */
763
764 XGI_LoadDAC( ModeNo , ModeIdIndex, pVBInfo ) ;
765 /* XGI_ClearBuffer( HwDeviceExtension , ModeNo, pVBInfo ) ; */
766#ifdef WIN2000
767 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 2007/05/14 */
768 {
769 VideoDebugPrint((0, "XGI_SetCRT1Group: VBInfo->IF_DEF_CH7007==1\n"));
770 SetCH7007Regs(HwDeviceExtension, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo ) ; /* 07/05/28 */
771 }
772#endif
773}
774
775
776/* --------------------------------------------------------------------- */
777/* Function : XGI_GetModePtr */
778/* Input : */
779/* Output : */
780/* Description : */
781/* --------------------------------------------------------------------- */
782UCHAR XGI_GetModePtr( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
783{
784 UCHAR index ;
785
786 if ( ModeNo <= 0x13 )
787 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_StTableIndex ;
788 else
789 {
790 if ( pVBInfo->ModeType <= 0x02 )
791 index = 0x1B ; /* 02 -> ModeEGA */
792 else
793 index = 0x0F ;
794 }
795 return( index ) ; /* Get pVBInfo->StandTable index */
796}
797
798
799/* --------------------------------------------------------------------- */
800/* Function : XGI_SetBIOSData */
801/* Input : */
802/* Output : */
803/* Description : */
804/* --------------------------------------------------------------------- */
805/*UCHAR XGI_SetBIOSData( USHORT ModeNo , USHORT ModeIdIndex )
806{
807 return( 0 ) ;
808}
809*/
810
811/* --------------------------------------------------------------------- */
812/* Function : XGI_ClearBankRegs */
813/* Input : */
814/* Output : */
815/* Description : */
816/* --------------------------------------------------------------------- */
817/*UCHAR XGI_ClearBankRegs( USHORT ModeNo , USHORT ModeIdIndex )
818{
819 return( 0 ) ;
820}
821*/
822
823/* --------------------------------------------------------------------- */
824/* Function : XGI_SetSeqRegs */
825/* Input : */
826/* Output : */
827/* Description : */
828/* --------------------------------------------------------------------- */
829void XGI_SetSeqRegs( USHORT ModeNo , USHORT StandTableIndex , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
830{
831 UCHAR tempah ,
832 SRdata ;
833
834 USHORT i ,
835 modeflag ;
836
837 if ( ModeNo <= 0x13 )
838 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
839 else
840 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
841
842 XGINew_SetReg1( pVBInfo->P3c4 , 0x00 , 0x03 ) ; /* Set SR0 */
843 tempah=pVBInfo->StandTable[ StandTableIndex ].SR[ 0 ] ;
844
845 i = SetCRT2ToLCDA ;
846 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
847 {
848 tempah |= 0x01 ;
849 }
850 else
851 {
852 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
853 {
854 if ( pVBInfo->VBInfo & SetInSlaveMode )
855 tempah |= 0x01 ;
856 }
857 }
858
859 tempah |= 0x20 ; /* screen off */
860 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , tempah ) ; /* Set SR1 */
861
862 for( i = 02 ; i <= 04 ; i++ )
863 {
864 SRdata = pVBInfo->StandTable[ StandTableIndex ].SR[ i - 1 ] ; /* Get SR2,3,4 from file */
865 XGINew_SetReg1( pVBInfo->P3c4 , i , SRdata ) ; /* Set SR2 3 4 */
866 }
867}
868
869
870/* --------------------------------------------------------------------- */
871/* Function : XGI_SetMiscRegs */
872/* Input : */
873/* Output : */
874/* Description : */
875/* --------------------------------------------------------------------- */
876void XGI_SetMiscRegs( USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
877{
878 UCHAR Miscdata ;
879
880 Miscdata = pVBInfo->StandTable[ StandTableIndex ].MISC ; /* Get Misc from file */
881/*
882 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
883 {
884 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
885 {
886 Miscdata |= 0x0C ;
887 }
888 }
889*/
890
891 XGINew_SetReg3( pVBInfo->P3c2 , Miscdata ) ; /* Set Misc(3c2) */
892}
893
894
895/* --------------------------------------------------------------------- */
896/* Function : XGI_SetCRTCRegs */
897/* Input : */
898/* Output : */
899/* Description : */
900/* --------------------------------------------------------------------- */
901void XGI_SetCRTCRegs( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
902{
903 UCHAR CRTCdata ;
904 USHORT i ;
905
906 CRTCdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
907 CRTCdata &= 0x7f ;
908 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , CRTCdata ) ; /* Unlock CRTC */
909
910 for( i = 0 ; i <= 0x18 ; i++ )
911 {
912 CRTCdata = pVBInfo->StandTable[ StandTableIndex ].CRTC[ i ] ; /* Get CRTC from file */
913 XGINew_SetReg1( pVBInfo->P3d4 , i , CRTCdata ) ; /* Set CRTC( 3d4 ) */
914 }
915/*
916 if ( ( HwDeviceExtension->jChipType == XGI_630 )&& ( HwDeviceExtension->jChipRevision == 0x30 ) )
917 {
918 if ( pVBInfo->VBInfo & SetInSlaveMode )
919 {
920 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
921 {
922 XGINew_SetReg1( pVBInfo->P3d4 , 0x18 , 0xFE ) ;
923 }
924 }
925 }
926*/
927}
928
929
930/* --------------------------------------------------------------------- */
931/* Function : */
932/* Input : */
933/* Output : */
934/* Description : */
935/* --------------------------------------------------------------------- */
936void XGI_SetATTRegs( USHORT ModeNo , USHORT StandTableIndex , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
937{
938 UCHAR ARdata ;
939 USHORT i ,
940 modeflag ;
941
942 if ( ModeNo <= 0x13 )
943 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
944 else
945 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
946
947 for( i = 0 ; i <= 0x13 ; i++ )
948 {
949 ARdata = pVBInfo->StandTable[ StandTableIndex ].ATTR[ i ] ;
950 if ( modeflag & Charx8Dot ) /* ifndef Dot9 */
951 {
952 if ( i == 0x13 )
953 {
954 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
955 ARdata = 0 ;
956 else
957 {
958 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
959 {
960 if ( pVBInfo->VBInfo & SetInSlaveMode )
961 ARdata = 0 ;
962 }
963 }
964 }
965 }
966
967 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
968 XGINew_SetReg3( pVBInfo->P3c0 , i ) ; /* set index */
969 XGINew_SetReg3( pVBInfo->P3c0 , ARdata ) ; /* set data */
970 }
971
972 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
973 XGINew_SetReg3( pVBInfo->P3c0 , 0x14 ) ; /* set index */
974 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data */
975 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
976 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
977}
978
979
980/* --------------------------------------------------------------------- */
981/* Function : XGI_SetGRCRegs */
982/* Input : */
983/* Output : */
984/* Description : */
985/* --------------------------------------------------------------------- */
986void XGI_SetGRCRegs( USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
987{
988 UCHAR GRdata ;
989 USHORT i ;
990
991 for( i = 0 ; i <= 0x08 ; i++ )
992 {
993 GRdata = pVBInfo->StandTable[ StandTableIndex ].GRC[ i ] ; /* Get GR from file */
994 XGINew_SetReg1( pVBInfo->P3ce , i , GRdata ) ; /* Set GR(3ce) */
995 }
996
997 if ( pVBInfo->ModeType > ModeVGA )
998 {
999 GRdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3ce , 0x05 ) ;
1000 GRdata &= 0xBF ; /* 256 color disable */
1001 XGINew_SetReg1( pVBInfo->P3ce , 0x05 , GRdata ) ;
1002 }
1003}
1004
1005
1006/* --------------------------------------------------------------------- */
1007/* Function : XGI_ClearExt1Regs */
1008/* Input : */
1009/* Output : */
1010/* Description : */
1011/* --------------------------------------------------------------------- */
1012void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo)
1013{
1014 USHORT i ;
1015
1016 for( i = 0x0A ; i <= 0x0E ; i++ )
1017 XGINew_SetReg1( pVBInfo->P3c4 , i , 0x00 ) ; /* Clear SR0A-SR0E */
1018}
1019
1020
1021/* --------------------------------------------------------------------- */
1022/* Function : XGI_SetDefaultVCLK */
1023/* Input : */
1024/* Output : */
1025/* Description : */
1026/* --------------------------------------------------------------------- */
1027UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo )
1028{
1029
1030 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x20 ) ;
1031 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 0 ].SR2B ) ;
1032 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 0 ].SR2C ) ;
1033
1034 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x10 ) ;
1035 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 1 ].SR2B ) ;
1036 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 1 ].SR2C ) ;
1037
1038 XGINew_SetRegAND( pVBInfo->P3c4 , 0x31 , ~0x30 ) ;
1039 return( 0 ) ;
1040}
1041
1042
1043/* --------------------------------------------------------------------- */
1044/* Function : XGI_GetRatePtrCRT2 */
1045/* Input : */
1046/* Output : */
1047/* Description : */
1048/* --------------------------------------------------------------------- */
1049USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
1050{
1051 SHORT LCDRefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 } ,
1052 LCDARefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 } ;
1053
1054 USHORT RefreshRateTableIndex , i ,
1055 modeflag , index , temp ;
1056
1057 if ( ModeNo <= 0x13 )
1058 {
1059 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1060 }
1061 else
1062 {
1063 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1064 }
1065
1066 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1067 {
1068 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1069 {
1070 if ( modeflag & HalfDCLK )
1071 return( 0 ) ;
1072 }
1073 }
1074
1075 if ( ModeNo < 0x14 )
1076 return( 0xFFFF ) ;
1077
1078 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
1079 index = index >> pVBInfo->SelectCRT2Rate ;
1080 index &= 0x0F ;
1081
1082 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1083 index = 0 ;
1084
1085 if ( index > 0 )
1086 index-- ;
1087
1088 if ( pVBInfo->SetFlag & ProgrammingCRT2 )
1089 {
1090 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1091 {
1092 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1093 {
1094 index = 0 ;
1095 }
1096 }
1097
1098 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
1099 {
1100 if( pVBInfo->IF_DEF_LVDS == 0 )
1101 {
1102 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1103 temp = LCDARefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ; /* 301b */
1104 else
1105 temp = LCDRefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ;
1106
1107 if ( index > temp )
1108 {
1109 index = temp ;
1110 }
1111 }
1112 else
1113 {
1114 index = 0 ;
1115 }
1116 }
1117 }
1118
1119 RefreshRateTableIndex = pVBInfo->EModeIDTable[ ModeIdIndex ].REFindex ;
1120 ModeNo = pVBInfo->RefIndex[ RefreshRateTableIndex ].ModeID ;
1121 if ( pXGIHWDE->jChipType >= XG20 ) /* for XG20, XG21, XG27 */
1122 {
1123 /*
1124 if ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag & XG2xNotSupport )
1125 {
1126 index++;
1127 }
1128 */
1129 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 800 ) &&
1130 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 600 ) )
1131 {
1132 index++;
1133 }
1134/* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
1135 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1024 ) &&
1136 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 768 ) )
1137 {
1138 index++;
1139 }
1140 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1280 ) &&
1141 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 1024 ) )
1142 {
1143 index++;
1144 }
1145 }
1146
1147 i = 0 ;
1148 do
1149 {
1150 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + i ].ModeID != ModeNo )
1151 break ;
1152 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i ].Ext_InfoFlag ;
1153 temp &= ModeInfoFlag ;
1154 if ( temp < pVBInfo->ModeType )
1155 break ;
1156 i++ ;
1157 index-- ;
1158
1159 } while( index != 0xFFFF ) ;
1160 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
1161 {
1162 if ( pVBInfo->VBInfo & SetInSlaveMode )
1163 {
1164 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i - 1 ].Ext_InfoFlag ;
1165 if ( temp & InterlaceMode )
1166 {
1167 i++ ;
1168 }
1169 }
1170 }
1171 i-- ;
1172 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
1173 {
1174 temp = XGI_AjustCRT2Rate( ModeNo , ModeIdIndex , RefreshRateTableIndex , &i, pVBInfo) ;
1175 }
1176 return( RefreshRateTableIndex + i ) ; /*return(0x01|(temp1<<1)); */
1177}
1178
1179
1180/* --------------------------------------------------------------------- */
1181/* Function : XGI_AjustCRT2Rate */
1182/* Input : */
1183/* Output : */
1184/* Description : */
1185/* --------------------------------------------------------------------- */
1186BOOLEAN XGI_AjustCRT2Rate( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , USHORT *i, PVB_DEVICE_INFO pVBInfo )
1187{
1188 USHORT tempax ,
1189 tempbx ,
1190 resinfo ,
1191 modeflag ,
1192 infoflag ;
1193
1194 if ( ModeNo <= 0x13 )
1195 {
1196 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
1197 }
1198 else
1199 {
1200 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1201 }
1202
1203 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
1204 tempbx = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID ;
1205 tempax = 0 ;
1206
1207 if ( pVBInfo->IF_DEF_LVDS == 0 )
1208 {
1209 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
1210 {
1211 tempax |= SupportRAMDAC2 ;
1212
1213 if ( pVBInfo->VBType & VB_XGI301C )
1214 tempax |= SupportCRT2in301C ;
1215 }
1216
1217 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) /* 301b */
1218 {
1219 tempax |= SupportLCD ;
1220
1221 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
1222 {
1223 if ( pVBInfo->LCDResInfo != Panel1280x960 )
1224 {
1225 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1226 {
1227 if ( resinfo >= 9 )
1228 {
1229 tempax = 0 ;
1230 return( 0 ) ;
1231 }
1232 }
1233 }
1234 }
1235 }
1236
1237 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) /* for HiTV */
1238 {
1239 if ( ( pVBInfo->VBType & VB_XGI301LV ) && ( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
1240 {
1241 tempax |= SupportYPbPr ;
1242 if ( pVBInfo->VBInfo & SetInSlaveMode )
1243 {
1244 if ( resinfo == 4 )
1245 return( 0 ) ;
1246
1247 if ( resinfo == 3 )
1248 return( 0 ) ;
1249
1250 if ( resinfo > 7 )
1251 return( 0 ) ;
1252 }
1253 }
1254 else
1255 {
1256 tempax |= SupportHiVisionTV ;
1257 if ( pVBInfo->VBInfo & SetInSlaveMode )
1258 {
1259 if ( resinfo == 4 )
1260 return( 0 ) ;
1261
1262 if ( resinfo == 3 )
1263 {
1264 if ( pVBInfo->SetFlag & TVSimuMode )
1265 return( 0 ) ;
1266 }
1267
1268 if ( resinfo > 7 )
1269 return( 0 ) ;
1270 }
1271 }
1272 }
1273 else
1274 {
1275 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV ) )
1276 {
1277 tempax |= SupportTV ;
1278
1279 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1280 {
1281 tempax |= SupportTV1024 ;
1282 }
1283
1284 if ( !( pVBInfo->VBInfo & SetPALTV ) )
1285 {
1286 if ( modeflag & NoSupportSimuTV )
1287 {
1288 if ( pVBInfo->VBInfo & SetInSlaveMode )
1289 {
1290 if ( !( pVBInfo->VBInfo & SetNotSimuMode ) )
1291 {
1292 return( 0 ) ;
1293 }
1294 }
1295 }
1296 }
1297 }
1298 }
1299 }
1300 else /* for LVDS */
1301 {
1302 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1303 {
1304 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1305 {
1306 tempax |= SupportCHTV ;
1307 }
1308 }
1309
1310 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
1311 {
1312 tempax |= SupportLCD ;
1313
1314 if ( resinfo > 0x08 )
1315 return( 0 ) ; /* 1024x768 */
1316
1317 if ( pVBInfo->LCDResInfo < Panel1024x768 )
1318 {
1319 if ( resinfo > 0x07 )
1320 return( 0 ) ; /* 800x600 */
1321
1322 if ( resinfo == 0x04 )
1323 return( 0 ) ; /* 512x384 */
1324 }
1325 }
1326 }
1327
1328 for( ; pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID == tempbx ; ( *i )-- )
1329 {
1330 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1331 if ( infoflag & tempax )
1332 {
1333 return( 1 ) ;
1334 }
1335 if ( ( *i ) == 0 )
1336 break ;
1337 }
1338
1339 for( ( *i ) = 0 ; ; ( *i )++ )
1340 {
1341 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1342 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID != tempbx )
1343 {
1344 return( 0 ) ;
1345 }
1346
1347 if ( infoflag & tempax )
1348 {
1349 return( 1 ) ;
1350 }
1351 }
1352 return( 1 ) ;
1353}
1354
1355
1356/* --------------------------------------------------------------------- */
1357/* Function : XGI_SetSync */
1358/* Input : */
1359/* Output : */
1360/* Description : */
1361/* --------------------------------------------------------------------- */
1362void XGI_SetSync(USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
1363{
1364 USHORT sync ,
1365 temp ;
1366
1367 sync = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag >> 8 ; /* di+0x00 */
1368 sync &= 0xC0 ;
1369 temp = 0x2F ;
1370 temp |= sync ;
1371 XGINew_SetReg3( pVBInfo->P3c2 , temp ) ; /* Set Misc(3c2) */
1372}
1373
1374
1375/* --------------------------------------------------------------------- */
1376/* Function : XGI_SetCRT1CRTC */
1377/* Input : */
1378/* Output : */
1379/* Description : */
1380/* --------------------------------------------------------------------- */
1381void XGI_SetCRT1CRTC( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1382{
1383 UCHAR index ,
1384 data ;
1385
1386 USHORT i ;
1387
1388 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ; /* Get index */
1389 index = index&IndexMask ;
1390
1391 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1392 data &= 0x7F ;
1393 XGINew_SetReg1(pVBInfo->P3d4,0x11,data); /* Unlock CRTC */
1394
1395 for( i = 0 ; i < 8 ; i++ )
1396 pVBInfo->TimingH[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i ] ;
1397
1398 for( i = 0 ; i < 7 ; i++ )
1399 pVBInfo->TimingV[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i + 8 ] ;
1400
1401 XGI_SetCRT1Timing_H( pVBInfo, HwDeviceExtension ) ;
1402
1403
1404
1405 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo, pVBInfo ) ;
1406
1407
1408 if( pVBInfo->ModeType > 0x03 )
1409 XGINew_SetReg1( pVBInfo->P3d4 , 0x14 , 0x4F ) ;
1410}
1411
1412
1413/* --------------------------------------------------------------------- */
1414/* Function : XGI_SetCRT1Timing_H */
1415/* Input : */
1416/* Output : */
1417/* Description : */
1418/* --------------------------------------------------------------------- */
1419void XGI_SetCRT1Timing_H( PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1420{
1421 UCHAR data , data1, pushax;
1422 USHORT i , j ;
1423
1424 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1425 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1426 /* XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x11 , 0x7f , 0x00 ) ; */
1427
1428 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ; /* unlock cr0-7 */
1429 data &= 0x7F ;
1430 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ;
1431
1432 data = pVBInfo->TimingH[ 0 ].data[ 0 ] ;
1433 XGINew_SetReg1( pVBInfo->P3d4 , 0 , data ) ;
1434
1435 for( i = 0x01 ; i <= 0x04 ; i++ )
1436 {
1437 data = pVBInfo->TimingH[ 0 ].data[ i ] ;
1438 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 1 ) , data ) ;
1439 }
1440
1441 for( i = 0x05 ; i <= 0x06 ; i++ )
1442 {
1443 data = pVBInfo->TimingH[ 0 ].data[ i ];
1444 XGINew_SetReg1( pVBInfo->P3c4 ,( USHORT )( i + 6 ) , data ) ;
1445 }
1446
1447 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1448 j &= 0x1F ;
1449 data = pVBInfo->TimingH[ 0 ].data[ 7 ] ;
1450 data &= 0xE0 ;
1451 data |= j ;
1452 XGINew_SetReg1( pVBInfo->P3c4 , 0x0e , data ) ;
1453
1454 if ( HwDeviceExtension->jChipType >= XG20 )
1455 {
1456 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x04 ) ;
1457 data = data - 1 ;
1458 XGINew_SetReg1( pVBInfo->P3d4 , 0x04 , data ) ;
1459 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x05 ) ;
1460 data1 = data ;
1461 data1 &= 0xE0 ;
1462 data &= 0x1F ;
1463 if ( data == 0 )
1464 {
1465 pushax = data ;
1466 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0c ) ;
1467 data &= 0xFB ;
1468 XGINew_SetReg1( pVBInfo->P3c4 , 0x0c , data ) ;
1469 data = pushax ;
1470 }
1471 data = data - 1 ;
1472 data |= data1 ;
1473 XGINew_SetReg1( pVBInfo->P3d4 , 0x05 , data ) ;
1474 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1475 data = data >> 5 ;
1476 data = data + 3 ;
1477 if ( data > 7 )
1478 data = data - 7 ;
1479 data = data << 5 ;
1480 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0e , ~0xE0 , data ) ;
1481 }
1482}
1483
1484
1485/* --------------------------------------------------------------------- */
1486/* Function : XGI_SetCRT1Timing_V */
1487/* Input : */
1488/* Output : */
1489/* Description : */
1490/* --------------------------------------------------------------------- */
1491void XGI_SetCRT1Timing_V( USHORT ModeIdIndex , USHORT ModeNo,PVB_DEVICE_INFO pVBInfo )
1492{
1493 UCHAR data ;
1494 USHORT i , j ;
1495
1496 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1497 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1498 /* XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , 0x7f , 0x00 ) ; */
1499
1500 for( i = 0x00 ; i <= 0x01 ; i++ )
1501 {
1502 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1503 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 6 ) , data ) ;
1504 }
1505
1506 for( i = 0x02 ; i <= 0x03 ; i++ )
1507 {
1508 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1509 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 0x0e ) , data ) ;
1510 }
1511
1512 for( i = 0x04 ; i <= 0x05 ; i++ )
1513 {
1514 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1515 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 0x11 ) , data ) ;
1516 }
1517
1518 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0a ) ;
1519 j &= 0xC0 ;
1520 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1521 data &= 0x3F ;
1522 data |= j ;
1523 XGINew_SetReg1( pVBInfo->P3c4 , 0x0a , data ) ;
1524
1525 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1526 data &= 0x80 ;
1527 data = data >> 2 ;
1528
1529 if ( ModeNo <= 0x13 )
1530 i = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1531 else
1532 i = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1533
1534 i &= DoubleScanMode ;
1535 if ( i )
1536 data |= 0x80 ;
1537
1538 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x09 ) ;
1539 j &= 0x5F ;
1540 data |= j ;
1541 XGINew_SetReg1( pVBInfo->P3d4 , 0x09 , data ) ;
1542}
1543
1544
1545/* --------------------------------------------------------------------- */
1546/* Function : XGI_SetXG21CRTC */
1547/* Input : Stand or enhance CRTC table */
1548/* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
1549/* Description : Set LCD timing */
1550/* --------------------------------------------------------------------- */
1551void XGI_SetXG21CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
1552{
1553 UCHAR StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
1554 USHORT Temp1, Temp2, Temp3 ;
1555
1556 if ( ModeNo <= 0x13 )
1557 {
1558 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1559 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1560 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1561 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1562 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1563 Tempcx = Tempax ;
1564 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1565 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1566 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1567 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1568 Tempdx <<= 2 ; /* Tempdx << 2 */
1569 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1570 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1571
1572 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR16 VRS */
1573 Tempbx = Tempax ; /* Tempbx=Tempax */
1574 Tempax &= 0x01 ; /* Tempax: VRS[0] */
1575 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS */
1576 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax: CR7 VRS */
1577 Tempdx = Tempbx >> 1 ; /* Tempdx: VRS[7:1] */
1578 Tempcx = Tempax & 0x04 ; /* Tempcx: CR7[2] */
1579 Tempcx <<= 5 ; /* Tempcx[7]: VRS[8] */
1580 Tempdx |= Tempcx ; /* Tempdx: VRS[8:1] */
1581 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempdx ) ; /* SR34[7:0]: VRS[8:1] */
1582
1583 Temp1 = Tempcx << 1 ; /* Temp1[8]: VRS[8] UCHAR -> USHORT */
1584 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1585 Tempax &= 0x80 ; /* Tempax[7]: CR7[7] */
1586 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1587 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1588
1589 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR16 VRE */
1590 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1591 Temp2 = Temp1 & 0x3F0 ; /* Temp2[9:4]: VRS[9:4] */
1592 Temp2 |= Tempax ; /* Temp2[9:0]: VRE[9:0] */
1593 Temp3 = Temp1 & 0x0F ; /* Temp3[3:0]: VRS[3:0] */
1594 if ( Tempax < Temp3 ) /* VRE[3:0]<VRS[3:0] */
1595 Temp2 |= 0x10 ; /* Temp2: VRE + 0x10 */
1596 Temp2 &= 0xFF ; /* Temp2[7:0]: VRE[7:0] */
1597 Tempax = (UCHAR)Temp2 ; /* Tempax[7:0]: VRE[7:0] */
1598 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1599 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1600 Temp1 >>= 9 ; /* [10:9]->[1:0] */
1601 Tempbx = (UCHAR)Temp1 ; /* Tempbx[1:0]: VRS[10:9] */
1602 Tempax |= Tempbx ; /* VRE[5:0]VRS[10:9] */
1603 Tempax &= 0x7F ;
1604 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1605 }
1606 else
1607 {
1608 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1609 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1610 Tempcx = Tempax ; /* Tempcx: HRS */
1611 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1612
1613 Tempdx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SRB */
1614 Tempdx &= 0xC0 ; /* Tempdx[7:6]: SRB[7:6] */
1615 Temp1 = Tempdx ; /* Temp1[7:6]: HRS[9:8] */
1616 Temp1 <<= 2 ; /* Temp1[9:8]: HRS[9:8] */
1617 Temp1 |= Tempax ; /* Temp1[9:0]: HRS[9:0] */
1618
1619 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1620 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1621
1622 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1623 Tempbx &= 0x04 ; /* Tempbx[2]: HRE[5] */
1624 Tempbx <<= 3 ; /* Tempbx[5]: HRE[5] */
1625 Tempax |= Tempbx ; /* Tempax[5:0]: HRE[5:0] */
1626
1627 Temp2 = Temp1 & 0x3C0 ; /* Temp2[9:6]: HRS[9:6] */
1628 Temp2 |= Tempax ; /* Temp2[9:0]: HRE[9:0] */
1629
1630 Tempcx &= 0x3F ; /* Tempcx[5:0]: HRS[5:0] */
1631 if( Tempax < Tempcx ) /* HRE < HRS */
1632 Temp2 |= 0x40 ; /* Temp2 + 0x40 */
1633
1634 Temp2 &= 0xFF ;
1635 Tempax = (UCHAR)Temp2 ; /* Tempax: HRE[7:0] */
1636 Tempax <<= 2 ; /* Tempax[7:2]: HRE[5:0] */
1637 Tempdx >>= 6 ; /* Tempdx[7:6]->[1:0] HRS[9:8] */
1638 Tempax |= Tempdx ; /* HRE[5:0]HRS[9:8] */
1639 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F D[7:2]->HRE, D[1:0]->HRS */
1640 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1641
1642 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1643 Tempbx = Tempax ; /* Tempbx: VRS */
1644 Tempax &= 0x01 ; /* Tempax[0]: VRS[0] */
1645 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS[0] */
1646 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[2][7] VRE */
1647 Tempcx = Tempbx >> 1 ; /* Tempcx[6:0]: VRS[7:1] */
1648 Tempdx = Tempax & 0x04 ; /* Tempdx[2]: CR7[2] */
1649 Tempdx <<= 5 ; /* Tempdx[7]: VRS[8] */
1650 Tempcx |= Tempdx ; /* Tempcx[7:0]: VRS[8:1] */
1651 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempcx ) ; /* SR34[8:1]->VRS */
1652
1653 Temp1 = Tempdx ; /* Temp1[7]: Tempdx[7] */
1654 Temp1 <<= 1 ; /* Temp1[8]: VRS[8] */
1655 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1656 Tempax &= 0x80 ;
1657 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1658 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1659 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SRA */
1660 Tempax &= 0x08 ; /* Tempax[3]: VRS[3] */
1661 Temp2 = Tempax ;
1662 Temp2 <<= 7 ; /* Temp2[10]: VRS[10] */
1663 Temp1 |= Temp2 ; /* Temp1[10:0]: VRS[10:0] */
1664
1665 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1666 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1667 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SRA */
1668 Tempbx &= 0x20 ; /* Tempbx[5]: VRE[5] */
1669 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1670 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1671 Temp2 = Temp1 & 0x7E0 ; /* Temp2[10:5]: VRS[10:5] */
1672 Temp2 |= Tempax ; /* Temp2[10:5]: VRE[10:5] */
1673
1674 Temp3 = Temp1 & 0x1F ; /* Temp3[4:0]: VRS[4:0] */
1675 if ( Tempax < Temp3 ) /* VRE < VRS */
1676 Temp2 |= 0x20 ; /* VRE + 0x20 */
1677
1678 Temp2 &= 0xFF ;
1679 Tempax = (UCHAR)Temp2 ; /* Tempax: VRE[7:0] */
1680 Tempax <<= 2 ; /* Tempax[7:0]; VRE[5:0]00 */
1681 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1682 Temp1 >>= 9 ; /* Temp1[1:0]: VRS[10:9] */
1683 Tempbx = (UCHAR)Temp1 ;
1684 Tempax |= Tempbx ; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
1685 Tempax &= 0x7F ;
1686 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1687 }
1688}
1689
1690void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
1691{
1692 USHORT StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
1693
1694 if ( ModeNo <= 0x13 )
1695 {
1696 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1697 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1698 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1699 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1700 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1701 Tempcx = Tempax ;
1702 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1703 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1704 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1705 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1706 Tempdx <<= 2 ; /* Tempdx << 2 */
1707 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1708 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1709
1710 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR10 VRS */
1711 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS */
1712 Tempcx = Tempax ; /* Tempcx=Tempax=VRS[7:0] */
1713 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
1714 Tempbx = Tempax ; /* Tempbx=CR07 */
1715 Tempax &= 0x04 ; /* Tempax[2]: CR07[2] VRS[8] */
1716 Tempax >>= 2;
1717 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01, Tempax ) ; /* SR35 D[0]->VRS D[8] */
1718 Tempcx |= (Tempax << 8) ; /* Tempcx[8] |= VRS[8] */
1719 Tempcx |= (Tempbx & 0x80)<<2; /* Tempcx[9] |= VRS[9] */
1720
1721
1722 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR11 VRE */
1723 Tempax &= 0x0F ; /* Tempax: VRE[3:0] */
1724 Tempbx = Tempcx ; /* Tempbx=Tempcx=VRS[9:0] */
1725 Tempbx &= 0x3F0 ; /* Tempbx[9:4]: VRS[9:4] */
1726 Tempbx |= Tempax ; /* Tempbx[9:0]: VRE[9:0] */
1727 if ( Tempax <= (Tempcx & 0x0F) ) /* VRE[3:0]<=VRS[3:0] */
1728 Tempbx |= 0x10 ; /* Tempbx: VRE + 0x10 */
1729 Tempax = (UCHAR)Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
1730 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1731 Tempcx = (Tempcx&0x600)>>8; /* Tempcx VRS[10:9] */
1732 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC, Tempax ) ; /* SR3F D[7:2]->VRE D[5:0] */
1733 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x06, Tempcx ) ; /* SR35 D[2:1]->VRS[10:9] */
1734 }
1735 else
1736 {
1737 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1738 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1739 Tempbx = Tempax ; /* Tempbx: HRS[7:0] */
1740 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1741
1742 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1743 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1744 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
1745
1746 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1747 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1748 Tempcx = Tempax ; /* Tempcx: HRE[4:0] */
1749
1750 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1751 Tempax &= 0x04 ; /* Tempax[2]: HRE[5] */
1752 Tempax <<= 3 ; /* Tempax[5]: HRE[5] */
1753 Tempcx |= Tempax ; /* Tempcx[5:0]: HRE[5:0] */
1754
1755 Tempbx = Tempbx & 0x3C0 ; /* Tempbx[9:6]: HRS[9:6] */
1756 Tempbx |= Tempcx ; /* Tempbx: HRS[9:6]HRE[5:0] */
1757
1758 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1759 Tempax &= 0x3F ; /* Tempax: HRS[5:0] */
1760 if( Tempcx <= Tempax ) /* HRE[5:0] < HRS[5:0] */
1761 Tempbx += 0x40 ; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
1762
1763 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1764 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1765 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
1766 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
1767 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
1768 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1769
1770 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1771 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS[7:0] */
1772
1773 Tempcx = Tempax ; /* Tempcx <= VRS[7:0] */
1774 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[7][2] VRS[9][8] */
1775 Tempbx = Tempax ; /* Tempbx <= CR07[7:0] */
1776 Tempax = Tempax & 0x04 ; /* Tempax[2]: CR7[2]: VRS[8] */
1777 Tempax >>= 2 ; /* Tempax[0]: VRS[8] */
1778 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01 , Tempax ) ; /* SR35[0]: VRS[8] */
1779 Tempcx |= (Tempax<<8) ; /* Tempcx <= VRS[8:0] */
1780 Tempcx |= ((Tempbx&0x80)<<2) ; /* Tempcx <= VRS[9:0] */
1781 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SR0A */
1782 Tempax &= 0x08; /* SR0A[3] VRS[10] */
1783 Tempcx |= (Tempax<<7) ; /* Tempcx <= VRS[10:0] */
1784
1785
1786 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1787 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1788 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SR0A */
1789 Tempbx &= 0x20 ; /* Tempbx[5]: SR0A[5]: VRE[4] */
1790 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1791 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1792 Tempbx = Tempcx ; /* Tempbx: VRS[10:0] */
1793 Tempbx &= 0x7E0 ; /* Tempbx[10:5]: VRS[10:5] */
1794 Tempbx |= Tempax ; /* Tempbx: VRS[10:5]VRE[4:0] */
1795
1796 if ( Tempbx <= Tempcx ) /* VRE <= VRS */
1797 Tempbx |= 0x20 ; /* VRE + 0x20 */
1798
1799 Tempax = (Tempbx<<2) & 0xFF ; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
1800 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , Tempax ) ; /* SR3F[7:2]:VRE[5:0] */
1801 Tempax = Tempcx >> 8;
1802 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , Tempax ) ; /* SR35[2:0]:VRS[10:8] */
1803 }
1804}
1805
1806
1807/* --------------------------------------------------------------------- */
1808/* Function : XGI_SetXG21LCD */
1809/* Input : */
1810/* Output : FCLK duty cycle, FCLK delay compensation */
1811/* Description : All values set zero */
1812/* --------------------------------------------------------------------- */
1813void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
1814{
1815 USHORT Data , Temp , b3CC ;
1816 USHORT XGI_P3cc ;
1817
1818 XGI_P3cc = pVBInfo->P3cc ;
1819
1820 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1821 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1822 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1823 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1824 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1825 {
1826 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1827 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1828 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1829 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1830 }
1831
1832 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1833
1834 if ( Temp & 0x01 )
1835 {
1836 XGINew_SetRegOR( pVBInfo->P3c4 , 0x06 , 0x40 ) ; /* 18 bits FP */
1837 XGINew_SetRegOR( pVBInfo->P3c4 , 0x09 , 0x40 ) ;
1838 }
1839
1840 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1841
1842 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ;
1843 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ;
1844
1845 if ( ModeNo <= 0x13 )
1846 {
1847 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1848 if ( b3CC & 0x40 )
1849 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1850 if ( b3CC & 0x80 )
1851 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1852 }
1853 else
1854 {
1855 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1856 if ( Data & 0x4000 )
1857 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1858 if ( Data & 0x8000 )
1859 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1860 }
1861}
1862
1863void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
1864{
1865 USHORT Data , Temp , b3CC ;
1866 USHORT XGI_P3cc ;
1867
1868 XGI_P3cc = pVBInfo->P3cc ;
1869
1870 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1871 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1872 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1873 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1874
1875 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1876 if ( ( Temp & 0x03 ) == 0 ) /* dual 12 */
1877 {
1878 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x13 ) ;
1879 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x13 ) ;
1880 }
1881
1882 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1883 {
1884 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1885 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1886 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1887 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1888 }
1889
1890 XGI_SetXG27FPBits(pVBInfo);
1891
1892 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1893
1894 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ; /* Hsync polarity */
1895 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ; /* Vsync polarity */
1896
1897 if ( ModeNo <= 0x13 )
1898 {
1899 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1900 if ( b3CC & 0x40 )
1901 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1902 if ( b3CC & 0x80 )
1903 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1904 }
1905 else
1906 {
1907 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1908 if ( Data & 0x4000 )
1909 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1910 if ( Data & 0x8000 )
1911 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1912 }
1913}
1914
1915/* --------------------------------------------------------------------- */
1916/* Function : XGI_UpdateXG21CRTC */
1917/* Input : */
1918/* Output : CRT1 CRTC */
1919/* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1920/* --------------------------------------------------------------------- */
1921void XGI_UpdateXG21CRTC( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo , USHORT RefreshRateTableIndex )
1922{
1923 int i , index = -1;
1924
1925 XGINew_SetRegAND( pVBInfo->P3d4 , 0x11 , 0x7F ) ; /* Unlock CR0~7 */
1926 if ( ModeNo <= 0x13 )
1927 {
1928 for( i = 0 ; i < 12 ; i++ )
1929 {
1930 if ( ModeNo == pVBInfo->UpdateCRT1[ i ].ModeID )
1931 index = i ;
1932 }
1933 }
1934 else
1935 {
1936 if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x60 ) )
1937 index = 12 ;
1938 else if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x72 ) )
1939 index = 13 ;
1940 else if ( ModeNo == 0x2F )
1941 index = 14 ;
1942 else if ( ModeNo == 0x50 )
1943 index = 15 ;
1944 else if ( ModeNo == 0x59 )
1945 index = 16 ;
1946 }
1947
1948 if( index != -1 )
1949 {
1950 XGINew_SetReg1( pVBInfo->P3d4 , 0x02 , pVBInfo->UpdateCRT1[ index ].CR02 ) ;
1951 XGINew_SetReg1( pVBInfo->P3d4 , 0x03 , pVBInfo->UpdateCRT1[ index ].CR03 ) ;
1952 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , pVBInfo->UpdateCRT1[ index ].CR15 ) ;
1953 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , pVBInfo->UpdateCRT1[ index ].CR16 ) ;
1954 }
1955}
1956
1957
1958/* --------------------------------------------------------------------- */
1959/* Function : XGI_SetCRT1DE */
1960/* Input : */
1961/* Output : */
1962/* Description : */
1963/* --------------------------------------------------------------------- */
1964void XGI_SetCRT1DE( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo,USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
1965{
1966 USHORT resindex ,
1967 tempax ,
1968 tempbx ,
1969 tempcx ,
1970 temp ,
1971 modeflag ;
1972
1973 UCHAR data ;
1974
1975 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
1976
1977 if ( ModeNo <= 0x13 )
1978 {
1979 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1980 tempax = pVBInfo->StResInfo[ resindex ].HTotal ;
1981 tempbx = pVBInfo->StResInfo[ resindex ].VTotal ;
1982 }
1983 else
1984 {
1985 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1986 tempax = pVBInfo->ModeResInfo[ resindex ].HTotal ;
1987 tempbx = pVBInfo->ModeResInfo[ resindex ].VTotal ;
1988 }
1989
1990 if ( modeflag & HalfDCLK )
1991 tempax = tempax >> 1 ;
1992
1993 if ( ModeNo > 0x13 )
1994 {
1995 if ( modeflag & HalfDCLK )
1996 tempax = tempax << 1 ;
1997
1998 temp = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1999
2000 if ( temp & InterlaceMode )
2001 tempbx = tempbx >> 1 ;
2002
2003 if ( modeflag & DoubleScanMode )
2004 tempbx = tempbx << 1 ;
2005 }
2006
2007 tempcx = 8 ;
2008
2009 /* if ( !( modeflag & Charx8Dot ) ) */
2010 /* tempcx = 9 ; */
2011
2012 tempax /= tempcx ;
2013 tempax -= 1 ;
2014 tempbx -= 1 ;
2015 tempcx = tempax ;
2016 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
2017 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
2018 data &= 0x7F ;
2019 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ; /* Unlock CRTC */
2020 XGINew_SetReg1( pVBInfo->P3d4 , 0x01 , ( USHORT )( tempcx & 0xff ) ) ;
2021 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x0b , ~0x0c , ( USHORT )( ( tempcx & 0x0ff00 ) >> 10 ) ) ;
2022 XGINew_SetReg1( pVBInfo->P3d4 , 0x12 , ( USHORT )( tempbx & 0xff ) ) ;
2023 tempax = 0 ;
2024 tempbx = tempbx >> 8 ;
2025
2026 if ( tempbx & 0x01 )
2027 tempax |= 0x02 ;
2028
2029 if ( tempbx & 0x02 )
2030 tempax |= 0x40 ;
2031
2032 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x42 , tempax ) ;
2033 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x07 ) ;
2034 data &= 0xFF ;
2035 tempax = 0 ;
2036
2037 if ( tempbx & 0x04 )
2038 tempax |= 0x02 ;
2039
2040 XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x0a , ~0x02 , tempax ) ;
2041 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp ) ;
2042}
2043
2044
2045/* --------------------------------------------------------------------- */
2046/* Function : XGI_GetResInfo */
2047/* Input : */
2048/* Output : */
2049/* Description : */
2050/* --------------------------------------------------------------------- */
2051USHORT XGI_GetResInfo(USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
2052{
2053 USHORT resindex ;
2054
2055 if ( ModeNo <= 0x13 )
2056 {
2057 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2058 }
2059 else
2060 {
2061 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2062 }
2063 return( resindex ) ;
2064}
2065
2066
2067/* --------------------------------------------------------------------- */
2068/* Function : XGI_SetCRT1Offset */
2069/* Input : */
2070/* Output : */
2071/* Description : */
2072/* --------------------------------------------------------------------- */
2073void XGI_SetCRT1Offset( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
2074{
2075 USHORT temp ,
2076 ah ,
2077 al ,
2078 temp2 ,
2079 i ,
2080 DisplayUnit ;
2081
2082 /* GetOffset */
2083 temp = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
2084 temp = temp >> 8 ;
2085 temp = pVBInfo->ScreenOffset[ temp ] ;
2086
2087 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2088 temp2 &= InterlaceMode ;
2089
2090 if ( temp2 )
2091 temp = temp << 1;
2092
2093 temp2 = pVBInfo->ModeType - ModeEGA ;
2094
2095 switch( temp2 )
2096 {
2097 case 0:
2098 temp2 = 1 ;
2099 break ;
2100 case 1:
2101 temp2 = 2 ;
2102 break ;
2103 case 2:
2104 temp2 = 4 ;
2105 break ;
2106 case 3:
2107 temp2 = 4 ;
2108 break ;
2109 case 4:
2110 temp2 = 6 ;
2111 break;
2112 case 5:
2113 temp2 = 8 ;
2114 break ;
2115 default:
2116 break ;
2117 }
2118
2119 if ( ( ModeNo >= 0x26 ) && ( ModeNo <= 0x28 ) )
2120 temp = temp * temp2 + temp2 / 2 ;
2121 else
2122 temp *= temp2 ;
2123
2124 /* SetOffset */
2125 DisplayUnit = temp ;
2126 temp2 = temp ;
2127 temp = temp >> 8 ; /* ah */
2128 temp &= 0x0F ;
2129 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x0E ) ;
2130 i &= 0xF0 ;
2131 i |= temp ;
2132 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , i ) ;
2133
2134 temp =( UCHAR )temp2 ;
2135 temp &= 0xFF ; /* al */
2136 XGINew_SetReg1( pVBInfo->P3d4 , 0x13 , temp ) ;
2137
2138 /* SetDisplayUnit */
2139 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2140 temp2 &= InterlaceMode ;
2141 if ( temp2 )
2142 DisplayUnit >>= 1 ;
2143
2144 DisplayUnit = DisplayUnit << 5 ;
2145 ah = ( DisplayUnit & 0xff00 ) >> 8 ;
2146 al = DisplayUnit & 0x00ff ;
2147 if ( al == 0 )
2148 ah += 1 ;
2149 else
2150 ah += 2 ;
2151
2152 if ( HwDeviceExtension->jChipType >= XG20 )
2153 if ( ( ModeNo == 0x4A ) | (ModeNo == 0x49 ) )
2154 ah -= 1 ;
2155
2156 XGINew_SetReg1( pVBInfo->P3c4 , 0x10 , ah ) ;
2157}
2158
2159
2160/* --------------------------------------------------------------------- */
2161/* Function : XGI_SetCRT1VCLK */
2162/* Input : */
2163/* Output : */
2164/* Description : */
2165/* --------------------------------------------------------------------- */
2166void XGI_SetCRT1VCLK( USHORT ModeNo , USHORT ModeIdIndex ,
2167 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2168{
2169 UCHAR index , data ;
2170 USHORT vclkindex ;
2171
2172 if ( pVBInfo->IF_DEF_LVDS == 1 )
2173 {
2174 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2175 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2176 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2177 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2178 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2179 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2180 }
2181 else if ( ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) && ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
2182 {
2183 vclkindex = XGI_GetVCLK2Ptr( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2184 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2185 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2186 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_A ;
2187 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2188 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_B ;
2189 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2190 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2191 }
2192 else
2193 {
2194 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2195 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2196 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2197 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2198 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2199 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2200 }
2201
2202 if ( HwDeviceExtension->jChipType >= XG20 )
2203 {
2204 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & HalfDCLK )
2205 {
2206 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2B ) ;
2207 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2208 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2C ) ;
2209 index = data ;
2210 index &= 0xE0 ;
2211 data &= 0x1F ;
2212 data = data << 1 ;
2213 data += 1 ;
2214 data |= index ;
2215 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2216 }
2217 }
2218}
2219
2220
2221/* --------------------------------------------------------------------- */
2222/* Function : XGI_SetCRT1FIFO */
2223/* Input : */
2224/* Output : */
2225/* Description : */
2226/* --------------------------------------------------------------------- */
2227void XGI_SetCRT1FIFO( USHORT ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
2228{
2229 USHORT data ;
2230
2231 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2232 data &= 0xfe ;
2233 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ; /* diable auto-threshold */
2234
2235 if ( ModeNo > 0x13 )
2236 {
2237 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x34 ) ;
2238 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2239 data &= 0xC0 ;
2240 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x30) ;
2241 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2242 data |= 0x01 ;
2243 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ;
2244 }
2245 else
2246 {
2247 if (HwDeviceExtension->jChipType == XG27)
2248 {
2249 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x0E ) ;
2250 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2251 data &= 0xC0 ;
2252 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x20 ) ;
2253 }
2254 else
2255 {
2256 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0xAE ) ;
2257 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2258 data &= 0xF0 ;
2259 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data ) ;
2260 }
2261 }
2262
2263 if (HwDeviceExtension->jChipType == XG21)
2264 {
2265 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
2266 }
2267}
2268
2269
2270/* --------------------------------------------------------------------- */
2271/* Function : XGI_SetCRT1ModeRegs */
2272/* Input : */
2273/* Output : */
2274/* Description : */
2275/* --------------------------------------------------------------------- */
2276void XGI_SetCRT1ModeRegs( PXGI_HW_DEVICE_INFO HwDeviceExtension ,
2277 USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo )
2278{
2279 USHORT data ,
2280 data2 ,
2281 data3 ,
2282 infoflag = 0 ,
2283 modeflag ,
2284 resindex ,
2285 xres ;
2286
2287 if ( ModeNo > 0x13 )
2288 {
2289 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2290 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2291 }
2292 else
2293 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
2294
2295 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) & 0x01 )
2296 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , 0x3F , 0x00 ) ;
2297
2298 if ( ModeNo > 0x13 )
2299 data = infoflag ;
2300 else
2301 data = 0 ;
2302
2303 data2 = 0 ;
2304
2305 if ( ModeNo > 0x13 )
2306 {
2307 if ( pVBInfo->ModeType > 0x02 )
2308 {
2309 data2 |= 0x02 ;
2310 data3 = pVBInfo->ModeType - ModeVGA ;
2311 data3 = data3 << 2 ;
2312 data2 |= data3 ;
2313 }
2314 }
2315
2316 data &= InterlaceMode ;
2317
2318 if ( data )
2319 data2 |= 0x20 ;
2320
2321 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x3F , data2 ) ;
2322 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
2323 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2324 if ( ModeNo <= 0x13 )
2325 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2326 else
2327 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
2328
2329 data = 0x0000 ;
2330 if ( infoflag & InterlaceMode )
2331 {
2332 if ( xres == 1024 )
2333 data = 0x0035 ;
2334 else if ( xres == 1280 )
2335 data = 0x0048 ;
2336 }
2337
2338 data2 = data & 0x00FF ;
2339 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFF , data2 ) ;
2340 data2 = ( data & 0xFF00 ) >> 8 ;
2341 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFC , data2 ) ;
2342
2343 if( modeflag & HalfDCLK )
2344 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xF7 , 0x08 ) ;
2345
2346 data2 = 0 ;
2347
2348 if ( modeflag & LineCompareOff )
2349 data2 |= 0x08 ;
2350
2351 if ( ModeNo > 0x13 )
2352 {
2353 if ( pVBInfo->ModeType == ModeEGA )
2354 data2 |= 0x40 ;
2355 }
2356
2357 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0F , ~0x48 , data2 ) ;
2358 data = 0x60 ;
2359 if ( pVBInfo->ModeType != ModeText )
2360 {
2361 data = data ^ 0x60 ;
2362 if ( pVBInfo->ModeType != ModeEGA )
2363 {
2364 data = data ^ 0xA0 ;
2365 }
2366 }
2367 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x21 , 0x1F , data ) ;
2368
2369 XGI_SetVCLKState( HwDeviceExtension , ModeNo , RefreshRateTableIndex, pVBInfo) ;
2370
2371 /* if(modeflag&HalfDCLK)//030305 fix lowresolution bug */
2372 /* if(XGINew_IF_DEF_NEW_LOWRES) */
2373 /* XGI_VesaLowResolution(ModeNo,ModeIdIndex);//030305 fix lowresolution bug */
2374
2375 data=XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
2376
2377 if (HwDeviceExtension->jChipType == XG27 )
2378 {
2379 if ( data & 0x40 )
2380 data = 0x2c ;
2381 else
2382 data = 0x6c ;
2383 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2384 XGINew_SetRegOR( pVBInfo->P3d4 , 0x51 , 0x10 ) ;
2385 }
2386 else
2387 if (HwDeviceExtension->jChipType >= XG20 )
2388 {
2389 if ( data & 0x40 )
2390 data = 0x33 ;
2391 else
2392 data = 0x73 ;
2393 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2394 XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0x02 ) ;
2395 }
2396 else
2397 {
2398 if ( data & 0x40 )
2399 data = 0x2c ;
2400 else
2401 data = 0x6c ;
2402 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2403 }
2404
2405}
2406
2407
2408/* --------------------------------------------------------------------- */
2409/* Function : XGI_SetVCLKState */
2410/* Input : */
2411/* Output : */
2412/* Description : */
2413/* --------------------------------------------------------------------- */
2414void XGI_SetVCLKState( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo )
2415{
2416 USHORT data ,
2417 data2 = 0 ;
2418 SHORT VCLK ;
2419
2420 UCHAR index ;
2421
2422 if ( ModeNo <= 0x13 )
2423 VCLK = 0 ;
2424 else
2425 {
2426 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2427 index &= IndexMask ;
2428 VCLK = pVBInfo->VCLKData[ index ].CLOCK ;
2429 }
2430
2431 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
2432 data &= 0xf3 ;
2433 if ( VCLK >= 200 )
2434 data |= 0x0c ; /* VCLK > 200 */
2435
2436 if ( HwDeviceExtension->jChipType >= XG20 )
2437 data &= ~0x04 ; /* 2 pixel mode */
2438
2439 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , data ) ;
2440
2441 if ( HwDeviceExtension->jChipType < XG20 )
2442 {
2443 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
2444 data &= 0xE7 ;
2445 if ( VCLK < 200 )
2446 data |= 0x10 ;
2447 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , data ) ;
2448 }
2449
2450/* Jong for Adavantech LCD ripple issue
2451 if ( ( VCLK >= 0 ) && ( VCLK < 135 ) )
2452 data2 = 0x03 ;
2453 else if ( ( VCLK >= 135 ) && ( VCLK < 160 ) )
2454 data2 = 0x02 ;
2455 else if ( ( VCLK >= 160 ) && ( VCLK < 260 ) )
2456 data2 = 0x01 ;
2457 else if ( VCLK > 260 )
2458 data2 = 0x00 ;
2459*/
2460 data2 = 0x00 ;
2461
2462 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x07 , 0xFC , data2 ) ;
2463 if (HwDeviceExtension->jChipType >= XG27 )
2464 {
2465 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x40 , 0xFC , data2&0x03 ) ;
2466 }
2467
2468
2469}
2470
2471
2472/* --------------------------------------------------------------------- */
2473/* Function : XGI_VesaLowResolution */
2474/* Input : */
2475/* Output : */
2476/* Description : */
2477/* --------------------------------------------------------------------- */
2478/*void XGI_VesaLowResolution( USHORT ModeNo , USHORT ModeIdIndex ,PVB_DEVICE_INFO pVBInfo)
2479{
2480 USHORT modeflag;
2481
2482 if ( ModeNo > 0x13 )
2483 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2484 else
2485 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2486
2487 if ( ModeNo > 0x13 )
2488 {
2489 if ( modeflag & DoubleScanMode )
2490 {
2491 if ( modeflag & HalfDCLK )
2492 {
2493 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
2494 {
2495 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
2496 {
2497 if ( pVBInfo->VBInfo & SetInSlaveMode )
2498 {
2499 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2500 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2501 return ;
2502 }
2503 }
2504 }
2505 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0xff , 0x80 ) ;
2506 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2507 return ;
2508 }
2509 }
2510 }
2511 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2512}
2513*/
2514
2515/* --------------------------------------------------------------------- */
2516/* Function : XGI_LoadDAC */
2517/* Input : */
2518/* Output : */
2519/* Description : */
2520/* --------------------------------------------------------------------- */
2521void XGI_LoadDAC( USHORT ModeNo , USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo )
2522{
2523 USHORT data , data2 , time ,
2524 i , j , k , m , n , o ,
2525 si , di , bx , dl , al , ah , dh ,
2526 *table = NULL ;
2527
2528 if ( ModeNo <= 0x13 )
2529 data = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2530 else
2531 data = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2532
2533 data &= DACInfoFlag ;
2534 time = 64 ;
2535
2536 if ( data == 0x00 )
2537 table = XGINew_MDA_DAC ;
2538 else if ( data == 0x08 )
2539 table = XGINew_CGA_DAC ;
2540 else if ( data == 0x10 )
2541 table = XGINew_EGA_DAC ;
2542 else if ( data == 0x18 )
2543 {
2544 time = 256 ;
2545 table = XGINew_VGA_DAC ;
2546 }
2547
2548 if ( time == 256 )
2549 j = 16 ;
2550 else
2551 j = time ;
2552
2553 XGINew_SetReg3( pVBInfo->P3c6 , 0xFF ) ;
2554 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
2555
2556 for( i = 0 ; i < j ; i++ )
2557 {
2558 data = table[ i ] ;
2559
2560 for( k = 0 ; k < 3 ; k++ )
2561 {
2562 data2 = 0 ;
2563
2564 if ( data & 0x01 )
2565 data2 = 0x2A ;
2566
2567 if ( data & 0x02 )
2568 data2 += 0x15 ;
2569
2570 XGINew_SetReg3( pVBInfo->P3c9 , data2 ) ;
2571 data = data >> 2 ;
2572 }
2573 }
2574
2575 if ( time == 256 )
2576 {
2577 for( i = 16 ; i < 32 ; i++ )
2578 {
2579 data = table[ i ] ;
2580
2581 for( k = 0 ; k < 3 ; k++ )
2582 XGINew_SetReg3( pVBInfo->P3c9 , data ) ;
2583 }
2584
2585 si = 32 ;
2586
2587 for( m = 0 ; m < 9 ; m++ )
2588 {
2589 di = si ;
2590 bx = si + 0x04 ;
2591 dl = 0 ;
2592
2593 for( n = 0 ; n < 3 ; n++ )
2594 {
2595 for( o = 0 ; o < 5 ; o++ )
2596 {
2597 dh = table[ si ] ;
2598 ah = table[ di ] ;
2599 al = table[ bx ] ;
2600 si++ ;
2601 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2602 }
2603
2604 si -= 2 ;
2605
2606 for( o = 0 ; o < 3 ; o++ )
2607 {
2608 dh = table[ bx ] ;
2609 ah = table[ di ] ;
2610 al = table[ si ] ;
2611 si-- ;
2612 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2613 }
2614
2615 dl++ ;
2616 }
2617
2618 si += 5 ;
2619 }
2620 }
2621}
2622
2623
2624/* --------------------------------------------------------------------- */
2625/* Function : XGI_WriteDAC */
2626/* Input : */
2627/* Output : */
2628/* Description : */
2629/* --------------------------------------------------------------------- */
2630void XGI_WriteDAC( USHORT dl , USHORT ah , USHORT al , USHORT dh,PVB_DEVICE_INFO pVBInfo )
2631{
2632 USHORT temp , bh , bl ;
2633
2634 bh = ah ;
2635 bl = al ;
2636
2637 if ( dl != 0 )
2638 {
2639 temp = bh ;
2640 bh = dh ;
2641 dh = temp ;
2642 if ( dl == 1 )
2643 {
2644 temp = bl ;
2645 bl = dh ;
2646 dh = temp ;
2647 }
2648 else
2649 {
2650 temp = bl ;
2651 bl = bh ;
2652 bh = temp ;
2653 }
2654 }
2655 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )dh ) ;
2656 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )bh ) ;
2657 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )bl ) ;
2658}
2659
2660#if 0
2661/* --------------------------------------------------------------------- */
2662/* Function : XGI_ClearBuffer */
2663/* Input : */
2664/* Output : */
2665/* Description : */
2666/* --------------------------------------------------------------------- */
2667void XGI_ClearBuffer( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo, PVB_DEVICE_INFO pVBInfo)
2668{
2669 PVOID VideoMemoryAddress = ( PVOID )HwDeviceExtension->pjVideoMemoryAddress ;
2670 ULONG AdapterMemorySize = ( ULONG )HwDeviceExtension->ulVideoMemorySize ;
2671 PUSHORT pBuffer ;
2672#ifndef LINUX_XF86
2673 int i ;
2674#endif
2675
2676 if ( pVBInfo->ModeType >= ModeEGA )
2677 {
2678 if ( ModeNo > 0x13 )
2679 {
2680 AdapterMemorySize = 0x40000 ; /* clear 256k */
2681 /* GetDRAMSize( HwDeviceExtension ) ; */
2682 XGI_SetMemory( VideoMemoryAddress , AdapterMemorySize , 0 ) ;
2683 }
2684 else
2685 {
2686/*
2687 pBuffer = VideoMemoryAddress ;
2688 for( i = 0 ; i < 0x4000 ; i++ )
2689 pBuffer[ i ] = 0x0000 ;
2690*/
2691 }
2692 }
2693 else
2694 {
2695 pBuffer = VideoMemoryAddress ;
2696 if ( pVBInfo->ModeType < ModeCGA )
2697 {
2698/*
2699 for ( i = 0 ; i < 0x4000 ; i++ )
2700 pBuffer[ i ] = 0x0720 ;
2701*/
2702 }
2703 else
2704 XGI_SetMemory( VideoMemoryAddress , 0x8000 , 0 ) ;
2705 }
2706}
2707
2708#endif
2709/* --------------------------------------------------------------------- */
2710/* Function : XGI_SetLCDAGroup */
2711/* Input : */
2712/* Output : */
2713/* Description : */
2714/* --------------------------------------------------------------------- */
2715void XGI_SetLCDAGroup( USHORT ModeNo , USHORT ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
2716{
2717 USHORT RefreshRateTableIndex ;
2718 /* USHORT temp ; */
2719
2720 /* pVBInfo->SelectCRT2Rate = 0 ; */
2721
2722 pVBInfo->SetFlag |= ProgrammingCRT2 ;
2723 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
2724 XGI_GetLVDSResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2725 XGI_GetLVDSData( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo);
2726 XGI_ModCRT1Regs( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2727 XGI_SetLVDSRegs( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2728 XGI_SetCRT2ECLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2729}
2730
2731
2732/* --------------------------------------------------------------------- */
2733/* Function : XGI_GetLVDSResInfo */
2734/* Input : */
2735/* Output : */
2736/* Description : */
2737/* --------------------------------------------------------------------- */
2738void XGI_GetLVDSResInfo( USHORT ModeNo , USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo )
2739{
2740 USHORT resindex , xres , yres , modeflag ;
2741
2742 if ( ModeNo <= 0x13 )
2743 {
2744 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2745 }
2746 else
2747 {
2748 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2749 }
2750
2751
2752 /* if ( ModeNo > 0x13 ) */
2753 /* modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; */
2754 /* else */
2755 /* modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; */
2756
2757 if ( ModeNo <= 0x13 )
2758 {
2759 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2760 }
2761 else
2762 {
2763 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2764 }
2765
2766 /* resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ; */
2767
2768 if ( ModeNo <= 0x13 )
2769 {
2770 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2771 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
2772 }
2773 else
2774 {
2775 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ;
2776 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ;
2777 }
2778 if ( ModeNo > 0x13 )
2779 {
2780 if ( modeflag & HalfDCLK )
2781 xres = xres << 1 ;
2782
2783 if ( modeflag & DoubleScanMode )
2784 yres = yres << 1 ;
2785 }
2786 /* if ( modeflag & Charx8Dot ) */
2787 /* { */
2788
2789 if ( xres == 720 )
2790 xres = 640 ;
2791
2792 /* } */
2793 pVBInfo->VGAHDE = xres ;
2794 pVBInfo->HDE = xres ;
2795 pVBInfo->VGAVDE = yres ;
2796 pVBInfo->VDE = yres ;
2797}
2798
2799
2800/* --------------------------------------------------------------------- */
2801/* Function : XGI_GetLVDSData */
2802/* Input : */
2803/* Output : */
2804/* Description : */
2805/* --------------------------------------------------------------------- */
2806void XGI_GetLVDSData( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2807{
2808 USHORT tempbx ;
2809 XGI330_LVDSDataStruct *LCDPtr = NULL ;
2810 XGI330_CHTVDataStruct *TVPtr = NULL ;
2811
2812 tempbx = 2 ;
2813
2814 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2815 {
2816 LCDPtr = ( XGI330_LVDSDataStruct * )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo) ;
2817 pVBInfo->VGAHT = LCDPtr->VGAHT ;
2818 pVBInfo->VGAVT = LCDPtr->VGAVT ;
2819 pVBInfo->HT = LCDPtr->LCDHT ;
2820 pVBInfo->VT = LCDPtr->LCDVT ;
2821 }
2822 if ( pVBInfo->IF_DEF_CH7017 == 1 )
2823 {
2824 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2825 {
2826 TVPtr = ( XGI330_CHTVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2827 pVBInfo->VGAHT = TVPtr->VGAHT ;
2828 pVBInfo->VGAVT = TVPtr->VGAVT ;
2829 pVBInfo->HT = TVPtr->LCDHT ;
2830 pVBInfo->VT = TVPtr->LCDVT ;
2831 }
2832 }
2833
2834 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2835 {
2836 if ( !( pVBInfo->LCDInfo & ( SetLCDtoNonExpanding | EnableScalingLCD ) ) )
2837 {
2838 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2839 {
2840 pVBInfo->HDE = 1024 ;
2841 pVBInfo->VDE = 768 ;
2842 }
2843 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2844 {
2845 pVBInfo->HDE = 1280 ;
2846 pVBInfo->VDE = 1024 ;
2847 }
2848 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2849 {
2850 pVBInfo->HDE = 1400 ;
2851 pVBInfo->VDE = 1050 ;
2852 }
2853 else
2854 {
2855 pVBInfo->HDE = 1600 ;
2856 pVBInfo->VDE = 1200 ;
2857 }
2858 }
2859 }
2860}
2861
2862
2863/* --------------------------------------------------------------------- */
2864/* Function : XGI_ModCRT1Regs */
2865/* Input : */
2866/* Output : */
2867/* Description : */
2868/* --------------------------------------------------------------------- */
2869void XGI_ModCRT1Regs( USHORT ModeNo , USHORT ModeIdIndex ,
2870 USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
2871{
2872 UCHAR index ;
2873 USHORT tempbx , i ;
2874 XGI_LVDSCRT1HDataStruct *LCDPtr = NULL ;
2875 XGI_LVDSCRT1VDataStruct *LCDPtr1 =NULL ;
2876 /* XGI330_CHTVDataStruct *TVPtr = NULL ; */
2877 XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2878 XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2879
2880 if( ModeNo <= 0x13 )
2881 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
2882 else
2883 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2884
2885 index= index & IndexMask ;
2886
2887 if ( ( pVBInfo->IF_DEF_ScaleLCD == 0 ) || ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) ) )
2888 {
2889 tempbx = 0 ;
2890
2891 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2892 {
2893 LCDPtr = ( XGI_LVDSCRT1HDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2894
2895 for( i = 0 ; i < 8 ; i++ )
2896 pVBInfo->TimingH[ 0 ].data[ i ] = LCDPtr[ 0 ].Reg[ i ] ;
2897 }
2898
2899 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2900 {
2901 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2902 {
2903 CH7007TV_TimingHPtr = ( XGI_CH7007TV_TimingHStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2904
2905 for( i = 0 ; i < 8 ; i++ )
2906 pVBInfo->TimingH[ 0 ].data[ i ] = CH7007TV_TimingHPtr[ 0 ].data[ i ] ;
2907 }
2908 }
2909
2910 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2911 {
2912 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2913 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2914 } */
2915
2916 XGI_SetCRT1Timing_H(pVBInfo,HwDeviceExtension) ;
2917
2918 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2919 {
2920 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , CH7007TV_TimingHPtr[ 0 ].data[ 8 ] ) ;
2921 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , CH7007TV_TimingHPtr[ 0 ].data[ 9 ] ) ;
2922 }
2923
2924 tempbx = 1 ;
2925
2926 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2927 {
2928 LCDPtr1 = ( XGI_LVDSCRT1VDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2929 for( i = 0 ; i < 7 ; i++ )
2930 pVBInfo->TimingV[ 0 ].data[ i ] = LCDPtr1[ 0 ].Reg[ i ] ;
2931 }
2932
2933 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2934 {
2935 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2936 {
2937 CH7007TV_TimingVPtr = ( XGI_CH7007TV_TimingVStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2938
2939 for( i = 0 ; i < 7 ; i++ )
2940 pVBInfo->TimingV[ 0 ].data[ i ] = CH7007TV_TimingVPtr[ 0 ].data[ i ] ;
2941 }
2942 }
2943 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2944 {
2945 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2946 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2947 } */
2948
2949 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo , pVBInfo) ;
2950
2951 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2952 {
2953 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x33 , ~0x01 , CH7007TV_TimingVPtr[ 0 ].data[ 7 ]&0x01 ) ;
2954 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , CH7007TV_TimingVPtr[ 0 ].data[8 ] ) ;
2955 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , CH7007TV_TimingVPtr[ 0 ].data[9 ] ) ;
2956
2957 }
2958 }
2959}
2960
2961
2962
2963/* --------------------------------------------------------------------- */
2964/* Function : XGI_SetLVDSRegs */
2965/* Input : */
2966/* Output : */
2967/* Description : */
2968/* --------------------------------------------------------------------- */
2969void XGI_SetLVDSRegs( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2970{
2971 USHORT tempbx , tempax , tempcx , tempdx , push1 , push2 , modeflag ;
2972 unsigned long temp , temp1 , temp2 , temp3 , push3 ;
2973 XGI330_LCDDataDesStruct *LCDPtr = NULL ;
2974 XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL ;
2975
2976 if ( ModeNo > 0x13 )
2977 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2978 else
2979 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2980
2981 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
2982 {
2983 if ( ( pVBInfo->IF_DEF_CH7017 == 0 ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
2984 {
2985 if ( pVBInfo->IF_DEF_OEMUtil == 1 )
2986 {
2987 tempbx = 8 ;
2988 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2989 }
2990
2991 if ( ( pVBInfo->IF_DEF_OEMUtil == 0 ) || ( LCDPtr == 0 ) )
2992 {
2993 tempbx = 3 ;
2994 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2995 LCDPtr1 = ( XGI330_LCDDataDesStruct2 * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2996 else
2997 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2998 }
2999
3000 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
3001 push1 = tempbx ;
3002 push2 = tempax ;
3003
3004 /* GetLCDResInfo */
3005 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
3006 {
3007 tempax = 1024 ;
3008 tempbx = 768 ;
3009 }
3010 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
3011 {
3012 tempax = 1280 ;
3013 tempbx = 1024 ;
3014 }
3015 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
3016 {
3017 tempax = 1400 ;
3018 tempbx = 1050 ;
3019 }
3020 else
3021 {
3022 tempax = 1600 ;
3023 tempbx = 1200 ;
3024 }
3025
3026 if ( pVBInfo->LCDInfo & SetLCDtoNonExpanding )
3027 {
3028 pVBInfo->HDE=tempax;
3029 pVBInfo->VDE=tempbx;
3030 pVBInfo->VGAHDE=tempax;
3031 pVBInfo->VGAVDE=tempbx;
3032 }
3033
3034 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( pVBInfo->LCDInfo & EnableScalingLCD ) )
3035 {
3036 tempax=pVBInfo->HDE;
3037 tempbx=pVBInfo->VDE;
3038 }
3039
3040 tempax = pVBInfo->HT ;
3041
3042 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3043 tempbx = LCDPtr1->LCDHDES ;
3044 else
3045 tempbx = LCDPtr->LCDHDES ;
3046
3047 tempcx = pVBInfo->HDE ;
3048 tempbx = tempbx & 0x0fff ;
3049 tempcx += tempbx ;
3050
3051 if ( tempcx >= tempax )
3052 tempcx -= tempax ;
3053
3054 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , tempbx & 0x07 ) ;
3055
3056 tempcx = tempcx >> 3 ;
3057 tempbx = tempbx >> 3 ;
3058
3059 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , ( USHORT )( tempbx & 0xff ) ) ;
3060 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , ( USHORT )( tempcx & 0xff ) ) ;
3061
3062 tempax = pVBInfo->HT ;
3063
3064 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3065 tempbx = LCDPtr1->LCDHRS ;
3066 else
3067 tempbx = LCDPtr->LCDHRS ;
3068
3069 tempcx = push2 ;
3070
3071 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3072 tempcx = LCDPtr1->LCDHSync ;
3073
3074 tempcx += tempbx ;
3075
3076 if ( tempcx >= tempax )
3077 tempcx -= tempax ;
3078
3079 tempax = tempbx & 0x07 ;
3080 tempax = tempax >> 5 ;
3081 tempcx = tempcx >> 3 ;
3082 tempbx = tempbx >> 3 ;
3083
3084 tempcx &= 0x1f ;
3085 tempax |= tempcx ;
3086
3087 XGINew_SetReg1( pVBInfo->Part1Port , 0x15 , tempax ) ;
3088 XGINew_SetReg1( pVBInfo->Part1Port , 0x14 , ( USHORT )( tempbx & 0xff ) ) ;
3089
3090 tempax = pVBInfo->VT ;
3091 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3092 tempbx = LCDPtr1->LCDVDES ;
3093 else
3094 tempbx = LCDPtr->LCDVDES ;
3095 tempcx = pVBInfo->VDE ;
3096
3097 tempbx = tempbx & 0x0fff ;
3098 tempcx += tempbx ;
3099 if ( tempcx >= tempax )
3100 tempcx -= tempax ;
3101
3102 XGINew_SetReg1( pVBInfo->Part1Port , 0x1b , ( USHORT )( tempbx & 0xff ) ) ;
3103 XGINew_SetReg1( pVBInfo->Part1Port , 0x1c , ( USHORT )( tempcx & 0xff ) ) ;
3104
3105 tempbx = ( tempbx >> 8 ) & 0x07 ;
3106 tempcx = ( tempcx >> 8 ) & 0x07 ;
3107
3108 XGINew_SetReg1( pVBInfo->Part1Port , 0x1d , ( USHORT )( ( tempcx << 3 ) | tempbx ) ) ;
3109
3110 tempax = pVBInfo->VT ;
3111 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3112 tempbx = LCDPtr1->LCDVRS ;
3113 else
3114 tempbx = LCDPtr->LCDVRS ;
3115
3116 /* tempbx = tempbx >> 4 ; */
3117 tempcx = push1 ;
3118
3119 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3120 tempcx = LCDPtr1->LCDVSync ;
3121
3122 tempcx += tempbx ;
3123 if ( tempcx >= tempax )
3124 tempcx -= tempax ;
3125
3126 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , ( USHORT )( tempbx & 0xff ) ) ;
3127 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , ~0x0f , ( USHORT )( tempcx & 0x0f ) ) ;
3128
3129 tempax = ( ( tempbx >> 8 ) & 0x07 ) << 3 ;
3130
3131 tempbx = pVBInfo->VGAVDE ;
3132 if ( tempbx != pVBInfo->VDE )
3133 tempax |= 0x40 ;
3134
3135 if ( pVBInfo->LCDInfo & EnableLVDSDDA )
3136 tempax |= 0x40 ;
3137
3138 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1a , 0x07 , tempax ) ;
3139
3140 tempcx = pVBInfo->VGAVT ;
3141 tempbx = pVBInfo->VDE ;
3142 tempax = pVBInfo->VGAVDE ;
3143 tempcx -= tempax ;
3144
3145 temp = tempax ; /* 0430 ylshieh */
3146 temp1 = ( temp << 18 ) / tempbx ;
3147
3148 tempdx = ( USHORT )( ( temp << 18 ) % tempbx ) ;
3149
3150 if ( tempdx != 0 )
3151 temp1 += 1 ;
3152
3153 temp2 = temp1 ;
3154 push3 = temp2 ;
3155
3156 XGINew_SetReg1( pVBInfo->Part1Port , 0x37 , ( USHORT )( temp2 & 0xff ) ) ;
3157 XGINew_SetReg1( pVBInfo->Part1Port , 0x36 , ( USHORT )( ( temp2 >> 8 ) & 0xff ) ) ;
3158
3159 tempbx = ( USHORT )( temp2 >> 16 ) ;
3160 tempax = tempbx & 0x03 ;
3161
3162 tempbx = pVBInfo->VGAVDE ;
3163 if ( tempbx == pVBInfo->VDE )
3164 tempax |= 0x04 ;
3165
3166 XGINew_SetReg1( pVBInfo->Part1Port , 0x35 , tempax ) ;
3167
3168 if ( pVBInfo->VBType & VB_XGI301C )
3169 {
3170 temp2 = push3 ;
3171 XGINew_SetReg1( pVBInfo->Part4Port , 0x3c , ( USHORT )( temp2 & 0xff ) ) ;
3172 XGINew_SetReg1( pVBInfo->Part4Port , 0x3b , ( USHORT )( ( temp2 >> 8 ) & 0xff ) ) ;
3173 tempbx = ( USHORT )( temp2 >> 16 ) ;
3174 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x3a , ~0xc0 , ( USHORT )( ( tempbx & 0xff ) << 6 ) ) ;
3175
3176 tempcx = pVBInfo->VGAVDE ;
3177 if ( tempcx == pVBInfo->VDE )
3178 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x00 ) ;
3179 else
3180 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x08 ) ;
3181 }
3182
3183 tempcx = pVBInfo->VGAHDE ;
3184 tempbx = pVBInfo->HDE ;
3185
3186 temp1 = tempcx << 16 ;
3187
3188 tempax = ( USHORT )( temp1 / tempbx ) ;
3189
3190 if ( ( tempbx & 0xffff ) == ( tempcx & 0xffff ) )
3191 tempax = 65535 ;
3192
3193 temp3 = tempax ;
3194 temp1 = pVBInfo->VGAHDE << 16 ;
3195
3196 temp1 /= temp3 ;
3197 temp3 = temp3 << 16 ;
3198 temp1 -= 1 ;
3199
3200 temp3 = ( temp3 & 0xffff0000 ) + ( temp1 & 0xffff ) ;
3201
3202 tempax = ( USHORT )( temp3 & 0xff ) ;
3203 XGINew_SetReg1( pVBInfo->Part1Port , 0x1f , tempax ) ;
3204
3205 temp1 = pVBInfo->VGAVDE << 18 ;
3206 temp1 = temp1 / push3 ;
3207 tempbx = ( USHORT )( temp1 & 0xffff ) ;
3208
3209 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3210 tempbx -= 1 ;
3211
3212 tempax = ( ( tempbx >> 8 ) & 0xff ) << 3 ;
3213 tempax |= ( USHORT )( ( temp3 >> 8 ) & 0x07 ) ;
3214 XGINew_SetReg1( pVBInfo->Part1Port , 0x20 , ( USHORT )( tempax & 0xff ) ) ;
3215 XGINew_SetReg1( pVBInfo->Part1Port , 0x21 , ( USHORT )( tempbx & 0xff ) ) ;
3216
3217 temp3 = temp3 >> 16 ;
3218
3219 if ( modeflag & HalfDCLK )
3220 temp3 = temp3 >> 1 ;
3221
3222 XGINew_SetReg1(pVBInfo->Part1Port , 0x22 , ( USHORT )( ( temp3 >> 8 ) & 0xff ) ) ;
3223 XGINew_SetReg1(pVBInfo->Part1Port , 0x23 , ( USHORT )( temp3 & 0xff ) ) ;
3224 }
3225 }
3226}
3227
3228
3229/* --------------------------------------------------------------------- */
3230/* Function : XGI_SetCRT2ECLK */
3231/* Input : */
3232/* Output : */
3233/* Description : */
3234/* --------------------------------------------------------------------- */
3235void XGI_SetCRT2ECLK( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
3236{
3237 UCHAR di_0 , di_1 , tempal ;
3238 int i ;
3239
3240 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
3241 XGI_GetVCLKLen( tempal , &di_0 , &di_1, pVBInfo ) ;
3242 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
3243
3244 for( i = 0 ; i < 4 ; i++ )
3245 {
3246 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , ~0x30 , ( USHORT )( 0x10 * i ) ) ;
3247 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3248 {
3249 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3250 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3251 }
3252 else if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
3253 {
3254 XGINew_SetReg1( pVBInfo->P3c4 , 0x2e , di_0 ) ;
3255 XGINew_SetReg1( pVBInfo->P3c4 , 0x2f , di_1 ) ;
3256 }
3257 else
3258 {
3259 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3260 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3261 }
3262 }
3263}
3264
3265
3266/* --------------------------------------------------------------------- */
3267/* Function : XGI_UpdateModeInfo */
3268/* Input : */
3269/* Output : */
3270/* Description : */
3271/* --------------------------------------------------------------------- */
3272void XGI_UpdateModeInfo( PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
3273{
3274 USHORT tempcl ,
3275 tempch ,
3276 temp ,
3277 tempbl ,
3278 tempax ;
3279
3280 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3281 {
3282 tempcl = 0 ;
3283 tempch = 0 ;
3284 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
3285
3286 if ( !( temp & 0x20 ) )
3287 {
3288 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
3289 if ( temp & 0x80 )
3290 {
3291 if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
3292 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) ;
3293 else
3294 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
3295
3296 if ( !( temp & 0x40 ) )
3297 tempcl |= ActiveCRT1 ;
3298 }
3299 }
3300
3301 temp = XGINew_GetReg1( pVBInfo->Part1Port , 0x2e ) ;
3302 temp &= 0x0f ;
3303
3304 if ( !( temp == 0x08 ) )
3305 {
3306 tempax = XGINew_GetReg1( pVBInfo->Part1Port , 0x13 ) ; /* Check ChannelA by Part1_13 [2003/10/03] */
3307 if ( tempax & 0x04 )
3308 tempcl = tempcl | ActiveLCD ;
3309
3310 temp &= 0x05 ;
3311
3312 if ( !( tempcl & ActiveLCD ) )
3313 if ( temp == 0x01 )
3314 tempcl |= ActiveCRT2 ;
3315
3316 if ( temp == 0x04 )
3317 tempcl |= ActiveLCD ;
3318
3319 if ( temp == 0x05 )
3320 {
3321 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
3322
3323 if( !( temp & 0x08 ) )
3324 tempch |= ActiveAVideo ;
3325
3326 if ( !( temp & 0x04 ) )
3327 tempch |= ActiveSVideo ;
3328
3329 if ( temp & 0x02 )
3330 tempch |= ActiveSCART ;
3331
3332 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3333 {
3334 if ( temp & 0x01 )
3335 tempch |= ActiveHiTV ;
3336 }
3337
3338 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3339 {
3340 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x4d ) ;
3341
3342 if ( temp & 0x10 )
3343 tempch |= ActiveYPbPr ;
3344 }
3345
3346 if ( tempch != 0 )
3347 tempcl |= ActiveTV ;
3348 }
3349 }
3350
3351 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x3d ) ;
3352 if ( tempcl & ActiveLCD )
3353 {
3354 if ( ( pVBInfo->SetFlag & ReserveTVOption ) )
3355 {
3356 if ( temp & ActiveTV )
3357 tempcl |= ActiveTV ;
3358 }
3359 }
3360 temp = tempcl ;
3361 tempbl = ~ModeSwitchStatus ;
3362 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x3d , tempbl , temp ) ;
3363
3364 if ( !( pVBInfo->SetFlag & ReserveTVOption ) )
3365 XGINew_SetReg1( pVBInfo->P3d4 , 0x3e , tempch ) ;
3366 }
3367 else
3368 {
3369 return ;
3370 }
3371}
3372
3373
3374/* --------------------------------------------------------------------- */
3375/* Function : XGI_GetVGAType */
3376/* Input : */
3377/* Output : */
3378/* Description : */
3379/* --------------------------------------------------------------------- */
3380void XGI_GetVGAType( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
3381{
3382 /*
3383 if ( HwDeviceExtension->jChipType >= XG20 )
3384 {
3385 pVBInfo->Set_VGAType = XG20;
3386 }
3387 else if ( HwDeviceExtension->jChipType >= XG40 )
3388 {
3389 pVBInfo->Set_VGAType = VGA_XGI340 ;
3390 }
3391 */
3392 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3393}
3394
3395
3396/* --------------------------------------------------------------------- */
3397/* Function : XGI_GetVBType */
3398/* Input : */
3399/* Output : */
3400/* Description : */
3401/* --------------------------------------------------------------------- */
3402void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo)
3403{
3404 USHORT flag , tempbx , tempah ;
3405
3406 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3407 {
3408 pVBInfo->VBType = VB_CH7007 ;
3409 return;
3410 }
3411 if ( pVBInfo->IF_DEF_LVDS == 0 )
3412 {
3413 tempbx = VB_XGI302B ;
3414 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
3415 if ( flag != 0x02 )
3416 {
3417 tempbx = VB_XGI301 ;
3418 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
3419 if ( flag >= 0xB0 )
3420 {
3421 tempbx = VB_XGI301B ;
3422 if ( flag >= 0xC0 )
3423 {
3424 tempbx = VB_XGI301C ;
3425 if ( flag >= 0xD0 )
3426 {
3427 tempbx = VB_XGI301LV ;
3428 if ( flag >= 0xE0 )
3429 {
3430 tempbx = VB_XGI302LV ;
3431 tempah = XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) ;
3432 if ( tempah != 0xFF )
3433 tempbx = VB_XGI301C ;
3434 }
3435 }
3436 }
3437
3438 if ( tempbx & ( VB_XGI301B | VB_XGI302B ) )
3439 {
3440 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x23 ) ;
3441
3442 if ( !( flag & 0x02 ) )
3443 tempbx = tempbx | VB_NoLCD ;
3444 }
3445 }
3446 }
3447 pVBInfo->VBType = tempbx ;
3448 }
3449/*
3450 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3451 pVBInfo->VBType = VB_CH7017 ;
3452 else //LVDS
3453 pVBInfo->VBType = VB_LVDS_NS ;
3454*/
3455
3456}
3457
3458
3459/* --------------------------------------------------------------------- */
3460/* Function : XGI_GetVBInfo */
3461/* Input : */
3462/* Output : */
3463/* Description : */
3464/* --------------------------------------------------------------------- */
3465void XGI_GetVBInfo( USHORT ModeNo , USHORT ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
3466{
3467 USHORT tempax ,
3468 push ,
3469 tempbx ,
3470 temp ,
3471 modeflag ;
3472
3473 if ( ModeNo <= 0x13 )
3474 {
3475 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
3476 }
3477 else
3478 {
3479 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3480 }
3481
3482 pVBInfo->SetFlag = 0 ;
3483 pVBInfo->ModeType = modeflag & ModeInfoFlag ;
3484 tempbx = 0 ;
3485
3486 if ( pVBInfo->VBType & 0xFFFF )
3487 {
3488 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) ; /* Check Display Device */
3489 tempbx = tempbx | temp ;
3490 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
3491 push = temp ;
3492 push = push << 8 ;
3493 tempax = temp << 8 ;
3494 tempbx = tempbx | tempax ;
3495 temp = ( SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA | SetInSlaveMode | DisableCRT2Display ) ;
3496 temp = 0xFFFF ^ temp ;
3497 tempbx &= temp ;
3498
3499 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
3500
3501 if ( pVBInfo->IF_DEF_LCDA == 1 )
3502 {
3503
3504 if ( ( pVBInfo->Set_VGAType >= XG20 ) || ( pVBInfo->Set_VGAType >= XG40 ))
3505 {
3506 if ( pVBInfo->IF_DEF_LVDS == 0 )
3507 {
3508 /* if ( ( pVBInfo->VBType & VB_XGI302B ) || ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) */
3509 if ( pVBInfo->VBType & ( VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3510 {
3511 if ( temp & EnableDualEdge )
3512 {
3513 tempbx |= SetCRT2ToDualEdge ;
3514
3515 if ( temp & SetToLCDA )
3516 tempbx |= SetCRT2ToLCDA ;
3517 }
3518 }
3519 }
3520 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3521 {
3522 if ( pVBInfo->VBType & VB_CH7017 )
3523 {
3524 if ( temp & EnableDualEdge )
3525 {
3526 tempbx |= SetCRT2ToDualEdge ;
3527
3528 if ( temp & SetToLCDA )
3529 tempbx |= SetCRT2ToLCDA ;
3530 }
3531 }
3532 }
3533 }
3534 }
3535
3536 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3537 {
3538 if ( ( ( pVBInfo->IF_DEF_LVDS == 0 ) && ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) )
3539 || ( ( pVBInfo->IF_DEF_CH7017 == 1 ) && ( pVBInfo->VBType&VB_CH7017 ) ) || ( (pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType&VB_CH7007) ) ) /* [Billy] 07/05/04 */
3540 {
3541 if ( temp & SetYPbPr ) /* temp = CR38 */
3542 {
3543 if ( pVBInfo->IF_DEF_HiVision == 1 )
3544 {
3545 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ; /* shampoo add for new scratch */
3546 temp &= YPbPrMode ;
3547 tempbx |= SetCRT2ToHiVisionTV ;
3548
3549 if ( temp != YPbPrMode1080i ) {
3550 tempbx &= ( ~SetCRT2ToHiVisionTV ) ;
3551 tempbx |= SetCRT2ToYPbPr ; }
3552 }
3553
3554 /* tempbx |= SetCRT2ToYPbPr ; */
3555 }
3556 }
3557 }
3558
3559 tempax = push ; /* restore CR31 */
3560
3561 if ( pVBInfo->IF_DEF_LVDS == 0 )
3562 {
3563 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3564 {
3565 if ( pVBInfo->IF_DEF_HiVision == 1 )
3566 temp = 0x09FC ;
3567 else
3568 temp = 0x097C ;
3569 }
3570 else
3571 {
3572 if ( pVBInfo->IF_DEF_HiVision == 1 )
3573 temp = 0x01FC ;
3574 else
3575 temp = 0x017C ;
3576 }
3577 }
3578 else /* 3nd party chip */
3579 {
3580 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3581 temp = ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) ;
3582 else if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/03 */
3583 {
3584 temp = SetCRT2ToTV ;
3585 }
3586 else
3587 temp = SetCRT2ToLCD ;
3588 }
3589
3590 if ( !( tempbx & temp ) )
3591 {
3592 tempax |= DisableCRT2Display ;
3593 tempbx = 0 ;
3594 }
3595
3596 if ( pVBInfo->IF_DEF_LCDA == 1 ) /* Select Display Device */
3597 {
3598 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3599 {
3600 if ( tempbx & SetCRT2ToLCDA )
3601 {
3602 if ( tempbx & SetSimuScanMode )
3603 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SwitchToCRT2 ) ) ;
3604 else
3605 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SetCRT2ToTV | SwitchToCRT2 ) ) ;
3606 }
3607 }
3608 }
3609
3610 /* shampoo add */
3611 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) ) /* for driver abnormal */
3612 {
3613 if ( pVBInfo->IF_DEF_CRT2Monitor == 1 )
3614 {
3615 if ( tempbx & SetCRT2ToRAMDAC )
3616 {
3617 tempbx &= ( 0xFF00 | SetCRT2ToRAMDAC | SwitchToCRT2 | SetSimuScanMode ) ;
3618 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3619 }
3620 }
3621 else
3622 tempbx &= ( ~( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ;
3623 }
3624
3625 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3626 {
3627 if ( tempbx & SetCRT2ToLCD )
3628 {
3629 tempbx &= ( 0xFF00 | SetCRT2ToLCD | SwitchToCRT2 | SetSimuScanMode ) ;
3630 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3631 }
3632 }
3633
3634 if ( tempbx & SetCRT2ToSCART )
3635 {
3636 tempbx &= ( 0xFF00 | SetCRT2ToSCART | SwitchToCRT2 | SetSimuScanMode ) ;
3637 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3638 }
3639
3640 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3641 {
3642 if ( tempbx & SetCRT2ToYPbPr )
3643 tempbx &= ( 0xFF00 | SwitchToCRT2 | SetSimuScanMode ) ;
3644 }
3645
3646 if ( pVBInfo->IF_DEF_HiVision == 1 )
3647 {
3648 if ( tempbx & SetCRT2ToHiVisionTV )
3649 tempbx &= ( 0xFF00 | SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode ) ;
3650 }
3651
3652 if ( tempax & DisableCRT2Display ) /* Set Display Device Info */
3653 {
3654 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) )
3655 tempbx = DisableCRT2Display ;
3656 }
3657
3658 if ( !( tempbx & DisableCRT2Display ) )
3659 {
3660 if ( ( !( tempbx & DriverMode ) ) || ( !( modeflag & CRT2Mode ) ) )
3661 {
3662 if ( pVBInfo->IF_DEF_LCDA == 1 )
3663 {
3664 if ( !( tempbx & SetCRT2ToLCDA ) )
3665 tempbx |= ( SetInSlaveMode | SetSimuScanMode ) ;
3666 }
3667
3668 if ( pVBInfo->IF_DEF_VideoCapture == 1 )
3669 {
3670 if ( ( ( HwDeviceExtension->jChipType == XG40 ) && ( pVBInfo->Set_VGAType == XG40 ) )
3671 || ( ( HwDeviceExtension->jChipType == XG41 ) && ( pVBInfo->Set_VGAType == XG41 ) )
3672 || ( ( HwDeviceExtension->jChipType == XG42 ) && ( pVBInfo->Set_VGAType == XG42 ) )
3673 || ( ( HwDeviceExtension->jChipType == XG45 ) && ( pVBInfo->Set_VGAType == XG45 ) ) )
3674 {
3675 if ( ModeNo <= 13 )
3676 {
3677 if ( !( tempbx & SetCRT2ToRAMDAC ) ) /*CRT2 not need to support*/
3678 {
3679 tempbx &= ( 0x00FF | ( ~SetInSlaveMode ) ) ;
3680 pVBInfo->SetFlag |= EnableVCMode ;
3681 }
3682 }
3683 }
3684 }
3685 }
3686
3687 /*LCD+TV can't support in slave mode (Force LCDA+TV->LCDB)*/
3688 if ( ( tempbx & SetInSlaveMode ) && ( tempbx & SetCRT2ToLCDA ) )
3689 {
3690 tempbx ^= ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToDualEdge ) ;
3691 pVBInfo->SetFlag |= ReserveTVOption ;
3692 }
3693 }
3694 }
3695
3696 pVBInfo->VBInfo = tempbx ;
3697}
3698
3699
3700/* --------------------------------------------------------------------- */
3701/* Function : XGI_GetTVInfo */
3702/* Input : */
3703/* Output : */
3704/* Description : */
3705/* --------------------------------------------------------------------- */
3706void XGI_GetTVInfo( USHORT ModeNo , USHORT ModeIdIndex ,PVB_DEVICE_INFO pVBInfo )
3707{
3708 USHORT temp ,
3709 tempbx = 0 ,
3710 resinfo = 0 ,
3711 modeflag ,
3712 index1 ;
3713
3714 tempbx = 0 ;
3715 resinfo = 0 ;
3716
3717 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3718 {
3719 if ( ModeNo <= 0x13 )
3720 {
3721 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
3722 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
3723 }
3724 else
3725 {
3726 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3727 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
3728 }
3729
3730 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3731 {
3732 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3733 tempbx = temp;
3734 if ( tempbx & SetPALTV )
3735 {
3736 tempbx &= ( SetCHTVOverScan | SetPALMTV | SetPALNTV | SetPALTV ) ;
3737 if ( tempbx & SetPALMTV )
3738 tempbx &= ~SetPALTV ; /* set to NTSC if PAL-M */
3739 }
3740 else
3741 tempbx &= ( SetCHTVOverScan | SetNTSCJ | SetPALTV ) ;
3742/*
3743 if ( pVBInfo->IF_DEF_LVDS == 0 )
3744 {
3745 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ; //PAL-M/PAL-N Info
3746 temp2 = ( index1 & 0xC0 ) >> 5 ; //00:PAL, 01:PAL-M, 10:PAL-N
3747 tempbx |= temp2 ;
3748 if ( temp2 & 0x02 ) //PAL-M
3749 tempbx &= ( ~SetPALTV ) ;
3750 }
3751*/
3752 }
3753
3754 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3755 {
3756 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3757
3758 if ( tempbx & TVOverScan )
3759 tempbx |= SetCHTVOverScan ;
3760 }
3761
3762 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/04 */
3763 {
3764 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3765
3766 if ( tempbx & TVOverScan )
3767 {
3768 tempbx |= SetCHTVOverScan ;
3769 }
3770 }
3771
3772
3773 if ( pVBInfo->IF_DEF_LVDS == 0 )
3774 {
3775 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
3776 tempbx |= SetPALTV ;
3777 }
3778
3779 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3780 {
3781 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3782 {
3783 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3784 index1 &= YPbPrMode ;
3785
3786 if ( index1 == YPbPrMode525i )
3787 tempbx |= SetYPbPrMode525i ;
3788
3789 if ( index1 == YPbPrMode525p )
3790 tempbx = tempbx | SetYPbPrMode525p;
3791 if ( index1 == YPbPrMode750p)
3792 tempbx = tempbx | SetYPbPrMode750p;
3793 }
3794 }
3795
3796 if ( pVBInfo->IF_DEF_HiVision == 1 )
3797 {
3798 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3799 {
3800 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV ;
3801 }
3802 }
3803
3804 if ( pVBInfo->IF_DEF_LVDS == 0 )
3805 { /* shampoo */
3806 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->VBInfo & SetNotSimuMode ) ) )
3807 tempbx |= TVSimuMode ;
3808
3809 if ( !( tempbx & SetPALTV ) && ( modeflag > 13 ) && ( resinfo == 8 ) ) /* NTSC 1024x768, */
3810 tempbx |= NTSC1024x768 ;
3811
3812 tempbx |= RPLLDIV2XO ;
3813
3814 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3815 {
3816 if ( pVBInfo->VBInfo & SetInSlaveMode )
3817 tempbx &=( ~RPLLDIV2XO ) ;
3818 }
3819 else
3820 {
3821 if ( tempbx & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
3822 tempbx &= ( ~RPLLDIV2XO ) ;
3823 else if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
3824 {
3825 if ( tempbx & TVSimuMode )
3826 tempbx &= ( ~RPLLDIV2XO ) ;
3827 }
3828 }
3829 }
3830 }
3831 pVBInfo->TVInfo = tempbx ;
3832}
3833
3834
3835/* --------------------------------------------------------------------- */
3836/* Function : XGI_GetLCDInfo */
3837/* Input : */
3838/* Output : */
3839/* Description : */
3840/* --------------------------------------------------------------------- */
3841BOOLEAN XGI_GetLCDInfo( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
3842{
3843 USHORT temp ,
3844 tempax ,
3845 tempbx ,
3846 modeflag ,
3847 resinfo = 0 ,
3848 LCDIdIndex ;
3849
3850 pVBInfo->LCDResInfo = 0 ;
3851 pVBInfo->LCDTypeInfo = 0 ;
3852 pVBInfo->LCDInfo = 0 ;
3853
3854 if ( ModeNo <= 0x13 )
3855 {
3856 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag // */
3857 }
3858 else
3859 {
3860 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3861 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo// */
3862 }
3863
3864 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ; /* Get LCD Res.Info */
3865 tempbx = temp & 0x0F ;
3866
3867 if ( tempbx == 0 )
3868 tempbx = Panel1024x768 ; /* default */
3869
3870 /* LCD75 [2003/8/22] Vicent */
3871 if ( ( tempbx == Panel1024x768 ) || ( tempbx == Panel1280x1024 ) )
3872 {
3873 if ( pVBInfo->VBInfo & DriverMode )
3874 {
3875 tempax = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
3876 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
3877 tempax &= 0x0F ;
3878 else
3879 tempax = tempax >> 4 ;
3880
3881 if ( ( resinfo == 6 ) || ( resinfo == 9 ) )
3882 {
3883 if ( tempax >= 3 )
3884 tempbx |= PanelRef75Hz ;
3885 }
3886 else if ( ( resinfo == 7 ) || ( resinfo == 8 ) )
3887 {
3888 if ( tempax >= 4 )
3889 tempbx |= PanelRef75Hz ;
3890 }
3891 }
3892 }
3893
3894 pVBInfo->LCDResInfo = tempbx ;
3895
3896 /* End of LCD75 */
3897
3898 if( pVBInfo->IF_DEF_OEMUtil == 1 )
3899 {
3900 pVBInfo->LCDTypeInfo = ( temp & 0xf0 ) >> 4 ;
3901 }
3902
3903 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
3904 {
3905 return 0;
3906 }
3907
3908 tempbx = 0 ;
3909
3910 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
3911
3912 temp &= ( ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable ) ;
3913
3914 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( temp & LCDNonExpanding ) )
3915 temp &= ~EnableScalingLCD ;
3916
3917 tempbx |= temp ;
3918
3919 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo) ;
3920
3921 tempax = pVBInfo->LCDCapList[ LCDIdIndex ].LCD_Capability ;
3922
3923 if ( pVBInfo->IF_DEF_LVDS == 0 ) /* shampoo */
3924 {
3925 if ( ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) && ( tempax & LCDDualLink ) )
3926 {
3927 tempbx |= SetLCDDualLink ;
3928 }
3929 }
3930
3931 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3932 {
3933 if ( tempax & LCDDualLink )
3934 {
3935 tempbx |= SetLCDDualLink ;
3936 }
3937 }
3938
3939 if ( pVBInfo->IF_DEF_LVDS == 0 )
3940 {
3941 if ( ( pVBInfo->LCDResInfo == Panel1400x1050 ) && ( pVBInfo->VBInfo & SetCRT2ToLCD ) && ( ModeNo > 0x13 ) && ( resinfo == 9 ) && ( !( tempbx & EnableScalingLCD ) ) )
3942 tempbx |= SetLCDtoNonExpanding ; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3943 }
3944
3945/*
3946 if ( tempax & LCDBToA )
3947 {
3948 tempbx |= SetLCDBToA ;
3949 }
3950*/
3951
3952 if ( pVBInfo->IF_DEF_ExpLink == 1 )
3953 {
3954 if ( modeflag & HalfDCLK )
3955 {
3956 /* if ( !( pVBInfo->LCDInfo&LCDNonExpanding ) ) */
3957 if ( !( tempbx & SetLCDtoNonExpanding ) )
3958 {
3959 tempbx |= EnableLVDSDDA ;
3960 }
3961 else
3962 {
3963 if ( ModeNo > 0x13 )
3964 {
3965 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3966 {
3967 if ( resinfo == 4 )
3968 { /* 512x384 */
3969 tempbx |= EnableLVDSDDA ;
3970 }
3971 }
3972 }
3973 }
3974 }
3975 }
3976
3977 if ( pVBInfo->VBInfo & SetInSlaveMode )
3978 {
3979 if ( pVBInfo->VBInfo & SetNotSimuMode )
3980 {
3981 tempbx |= LCDVESATiming ;
3982 }
3983 }
3984 else
3985 {
3986 tempbx |= LCDVESATiming ;
3987 }
3988
3989 pVBInfo->LCDInfo = tempbx ;
3990
3991 if ( pVBInfo->IF_DEF_PWD == 1 )
3992 {
3993 if ( pVBInfo->LCDInfo & SetPWDEnable )
3994 {
3995 if ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) )
3996 {
3997 if ( !( tempax & PWDEnable ) )
3998 {
3999 pVBInfo->LCDInfo &= ~SetPWDEnable ;
4000 }
4001 }
4002 }
4003 }
4004
4005 if ( pVBInfo->IF_DEF_LVDS == 0 )
4006 {
4007 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
4008 {
4009 if ( pVBInfo->VBInfo & SetInSlaveMode )
4010 {
4011 if ( !( tempax & LockLCDBToA ) )
4012 {
4013 if ( ModeNo <= 0x13 )
4014 {
4015 pVBInfo->VBInfo &= ~( SetSimuScanMode | SetInSlaveMode | SetCRT2ToLCD ) ;
4016 pVBInfo->VBInfo |= SetCRT2ToLCDA | SetCRT2ToDualEdge ;
4017 }
4018 }
4019 }
4020 }
4021 }
4022
4023/*
4024 if ( pVBInfo->IF_DEF_LVDS == 0 )
4025 {
4026 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
4027 {
4028 if ( pVBInfo->VBInfo & SetInSlaveMode )
4029 {
4030 if ( !( ( !( tempax & LockLCDBToA ) ) && ( ModeNo > 0x13 ) ) )
4031 {
4032 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
4033 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
4034 }
4035 }
4036 }
4037 }
4038*/
4039
4040 return( 1 ) ;
4041}
4042
4043
4044/* --------------------------------------------------------------------- */
4045/* Function : XGI_SearchModeID */
4046/* Input : */
4047/* Output : */
4048/* Description : */
4049/* --------------------------------------------------------------------- */
4050BOOLEAN XGI_SearchModeID( USHORT ModeNo , USHORT *ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
4051{
4052
4053#ifdef TC
4054
4055 if ( ModeNo <= 5 )
4056 ModeNo |= 1 ;
4057
4058 if ( ModeNo <= 0x13 )
4059 {
4060 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(XGI_StStruct);(*ModeIdIndex)++) */
4061 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4062 {
4063 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == ModeNo )
4064 break ;
4065 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == 0xFF )
4066 return( FALSE ) ;
4067 }
4068
4069 VGA_INFO = ( PUCHAR )MK_FP( 0 , 0x489 ) ;
4070
4071 if ( ModeNo == 0x07 )
4072 {
4073 if ( ( *VGA_INFO & 0x10 ) != 0 )
4074 ( *ModeIdIndex )++ ; /* 400 lines */
4075 /* else 350 lines */
4076 }
4077
4078 if ( ModeNo <= 3 )
4079 {
4080 if ( ( *VGA_INFO & 0x80 ) == 0 )
4081 {
4082 ( *ModeIdIndex )++ ;
4083 if ( ( *VGA_INFO & 0x10 ) != 0 )
4084 ( *ModeIdIndex )++ ; /* 400 lines */
4085 /* else 350 lines */
4086 }
4087 /* else 200 lines */
4088 }
4089 }
4090 else
4091 {
4092 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(XGI_ExtStruct);(*ModeIdIndex)++) */
4093 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4094 {
4095 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == ModeNo )
4096 break ;
4097 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == 0xFF )
4098 return( FALSE ) ;
4099 }
4100 }
4101
4102
4103#endif
4104
4105#ifdef WIN2000
4106
4107 if ( ModeNo <= 5 )
4108 ModeNo |= 1 ;
4109 if ( ModeNo <= 0x13 )
4110 {
4111 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(XGI_StStruct);(*ModeIdIndex)++) */
4112 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4113 {
4114 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == ModeNo )
4115 break ;
4116 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == 0xFF )
4117 return( FALSE ) ;
4118 }
4119
4120 if ( ModeNo == 0x07 )
4121 ( *ModeIdIndex )++ ; /* 400 lines */
4122
4123 if ( ModeNo <=3 )
4124 ( *ModeIdIndex ) += 2 ; /* 400 lines */
4125 /* else 350 lines */
4126 }
4127 else
4128 {
4129 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(XGI_ExtStruct);(*ModeIdIndex)++) */
4130 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4131 {
4132 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == ModeNo )
4133 break ;
4134 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == 0xFF )
4135 return( FALSE ) ;
4136 }
4137 }
4138
4139#endif
4140
4141#ifdef LINUX /* chiawen for linux solution */
4142
4143 if ( ModeNo <= 5 )
4144 ModeNo |= 1 ;
4145 if ( ModeNo <= 0x13 )
4146 {
4147 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(XGI_StStruct);(*ModeIdIndex)++) */
4148 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4149 {
4150 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == ModeNo )
4151 break ;
4152 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == 0xFF )
4153 return( FALSE ) ;
4154 }
4155
4156 if ( ModeNo == 0x07 )
4157 ( *ModeIdIndex )++ ; /* 400 lines */
4158
4159 if ( ModeNo <= 3 )
4160 ( *ModeIdIndex ) += 2 ; /* 400 lines */
4161 /* else 350 lines */
4162 }
4163 else
4164 {
4165 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(XGI_ExtStruct);(*ModeIdIndex)++) */
4166 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4167 {
4168 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == ModeNo )
4169 break ;
4170 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == 0xFF )
4171 return( FALSE ) ;
4172 }
4173 }
4174
4175#endif
4176
4177 return( TRUE ) ;
4178}
4179
4180
4181
4182
4183/* win2000 MM adapter not support standard mode! */
4184
4185/* --------------------------------------------------------------------- */
4186/* Function : */
4187/* Input : */
4188/* Output : */
4189/* Description : */
4190/* --------------------------------------------------------------------- */
4191BOOLEAN XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
4192{
4193 USHORT memorysize ,
4194 modeflag ,
4195 temp ,
4196 temp1 ,
4197 tmp ;
4198
4199/* if ( ( HwDeviceExtension->jChipType == XGI_650 ) ||
4200 ( HwDeviceExtension->jChipType == XGI_650M ) )
4201 {
4202 return( TRUE ) ;
4203 } */
4204
4205 if ( ModeNo <= 0x13 )
4206 {
4207 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
4208 }
4209 else {
4210 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4211 }
4212
4213 /* ModeType = modeflag&ModeInfoFlag ; // Get mode type */
4214
4215 memorysize = modeflag & MemoryInfoFlag ;
4216 memorysize = memorysize > MemorySizeShift ;
4217 memorysize++ ; /* Get memory size */
4218
4219 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ; /* Get DRAM Size */
4220 tmp = temp ;
4221
4222 if ( HwDeviceExtension->jChipType == XG40 )
4223 {
4224 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4225 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4226 {
4227 temp <<= 2 ;
4228 }
4229 else if ( ( tmp & 0x0c ) == 0x08 ) /* Dual channels */
4230 {
4231 temp <<= 1 ;
4232 }
4233 }
4234 else if ( HwDeviceExtension->jChipType == XG42 )
4235 {
4236 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4237 if ( ( tmp & 0x04 ) == 0x04 ) /* Dual channels */
4238 {
4239 temp <<= 1 ;
4240 }
4241 }
4242 else if ( HwDeviceExtension->jChipType == XG45 )
4243 {
4244 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4245 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4246 {
4247 temp <<= 2 ;
4248 }
4249 else if ( ( tmp & 0x0c ) == 0x08 ) /* triple channels */
4250 {
4251 temp1 = temp ;
4252 temp <<= 1 ;
4253 temp += temp1 ;
4254 }
4255 else if ( ( tmp & 0x0c ) == 0x04 ) /* Dual channels */
4256 {
4257 temp <<= 1 ;
4258 }
4259 }
4260 if ( temp < memorysize )
4261 return( FALSE ) ;
4262 else
4263 return( TRUE ) ;
4264}
4265
4266
4267/* --------------------------------------------------------------------- */
4268/* Function : XGINew_IsLowResolution */
4269/* Input : */
4270/* Output : */
4271/* Description : */
4272/* --------------------------------------------------------------------- */
4273/*void XGINew_IsLowResolution( USHORT ModeNo , USHORT ModeIdIndex, BOOLEAN XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
4274{
4275 USHORT data ;
4276 USHORT ModeFlag ;
4277
4278 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4279 data &= 0x7F ;
4280 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4281
4282 if ( ModeNo > 0x13 )
4283 {
4284 ModeFlag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4285 if ( ( ModeFlag & HalfDCLK ) && ( ModeFlag & DoubleScanMode ) )
4286 {
4287 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4288 data |= 0x80 ;
4289 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4290 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4291 data &= 0xF7 ;
4292 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , data ) ;
4293 }
4294 }
4295}
4296
4297*/
4298
4299/* --------------------------------------------------------------------- */
4300/* Function : XGI_DisplayOn */
4301/* Input : */
4302/* Output : */
4303/* Description : */
4304/* --------------------------------------------------------------------- */
4305void XGI_DisplayOn( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4306{
4307
4308 XGINew_SetRegANDOR(pVBInfo->P3c4,0x01,0xDF,0x00);
4309 if ( pXGIHWDE->jChipType == XG21 )
4310 {
4311 if ( pVBInfo->IF_DEF_LVDS == 1 )
4312 {
4313 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x1))
4314 {
4315 XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4316 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4317 }
4318 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x20))
4319 {
4320 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4321 }
4322 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4323 XGI_XG21BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4324 }
4325 else
4326 {
4327 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4328 }
4329
4330 }
4331
4332 if (pVBInfo->IF_DEF_CH7007 == 1) /* [Billy] 07/05/23 For CH7007 */
4333 {
4334#ifdef WIN2000
4335 if ( IsCH7007TVMode( pVBInfo ) )
4336 {
4337 TurnOnCH7007(pXGIHWDE->pDevice) ; /* 07/05/28 */
4338 }
4339#endif
4340
4341 }
4342
4343
4344 if ( pXGIHWDE->jChipType == XG27 )
4345 {
4346 if ( pVBInfo->IF_DEF_LVDS == 1 )
4347 {
4348 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x1))
4349 {
4350 XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4351 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4352 }
4353 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x20))
4354 {
4355 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4356 }
4357 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4358 XGI_XG27BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4359 }
4360 else
4361 {
4362 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4363 }
4364
4365 }
4366}
4367
4368
4369/* --------------------------------------------------------------------- */
4370/* Function : XGI_DisplayOff */
4371/* Input : */
4372/* Output : */
4373/* Description : */
4374/* --------------------------------------------------------------------- */
4375void XGI_DisplayOff( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4376{
4377
4378 if ( pXGIHWDE->jChipType == XG21 )
4379 {
4380 if ( pVBInfo->IF_DEF_LVDS == 1 )
4381 {
4382 XGI_XG21BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4383 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4384 }
4385 else
4386 {
4387 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4388 }
4389 }
4390
4391 if (pVBInfo->IF_DEF_CH7007 == 1) /*[Billy] 07/05/23 For CH7007 */
4392 {
4393 /* if( IsCH7007TVMode( pVBInfo ) == 0 ) */
4394 {
4395#ifdef WIN2000
4396 TurnOffCH7007(pXGIHWDE->pDevice) ; /* 07/05/28 */
4397#endif
4398 }
4399 }
4400
4401
4402 if ( pXGIHWDE->jChipType == XG27 )
4403 {
4404 if ((XGI_XG27GetPSCValue( pVBInfo )&0x2))
4405 {
4406 XGI_XG27BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4407 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4408 }
4409
4410 if ( pVBInfo->IF_DEF_LVDS == 0 )
4411 {
4412 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4413 }
4414 }
4415
4416 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ;
4417}
4418
4419
4420/* --------------------------------------------------------------------- */
4421/* Function : XGI_WaitDisply */
4422/* Input : */
4423/* Output : */
4424/* Description : chiawen for sensecrt1 */
4425/* --------------------------------------------------------------------- */
4426void XGI_WaitDisply( PVB_DEVICE_INFO pVBInfo )
4427{
4428 while( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4429 break ;
4430
4431 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4432 break ;
4433}
4434
4435/* --------------------------------------------------------------------- */
4436/* Function : XGI_SenseCRT1 */
4437/* Input : */
4438/* Output : */
4439/* Description : */
4440/* --------------------------------------------------------------------- */
4441
4442void XGI_SenseCRT1( PVB_DEVICE_INFO pVBInfo )
4443{
4444 UCHAR CRTCData[ 17 ] = { 0x5F , 0x4F , 0x50 , 0x82 , 0x55 , 0x81 ,
4445 0x0B , 0x3E , 0xE9 , 0x0B , 0xDF , 0xE7 ,
4446 0x04 , 0x00 , 0x00 , 0x05 , 0x00 } ;
4447
4448 UCHAR SR01 = 0 , SR1F = 0 , SR07 = 0 , SR06 = 0 ;
4449
4450 UCHAR CR17 , CR63 , SR31 ;
4451 USHORT temp ;
4452 UCHAR DAC_TEST_PARMS[ 3 ] = { 0x0F , 0x0F , 0x0F } ;
4453
4454 int i ;
4455 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
4456
4457 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
4458 XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x4A ) ;
4459 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) | 0x02 ) ) ;
4460
4461 SR31 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) ;
4462 CR63 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
4463 SR01 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4464
4465 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , ( UCHAR )( SR01 & 0xDF ) ) ;
4466 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , ( UCHAR )( CR63 & 0xBF ) ) ;
4467
4468 CR17 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
4469 XGINew_SetReg1( pVBInfo->P3d4 , 0x17 , ( UCHAR )( CR17 | 0x80 ) ) ;
4470
4471 SR1F = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
4472 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR )( SR1F | 0x04 ) ) ;
4473
4474 SR07 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x07 ) ;
4475 XGINew_SetReg1( pVBInfo->P3c4 , 0x07 , ( UCHAR )( SR07 & 0xFB ) ) ;
4476 SR06 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x06 ) ;
4477 XGINew_SetReg1( pVBInfo->P3c4 , 0x06 , ( UCHAR )( SR06 & 0xC3 ) ) ;
4478
4479 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , 0x00 ) ;
4480
4481 for( i = 0 ; i < 8 ; i++ )
4482 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )i , CRTCData[ i ] ) ;
4483
4484 for( i = 8 ; i < 11 ; i++ )
4485 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 8 ) , CRTCData[ i ] ) ;
4486
4487 for( i = 11 ; i < 13 ; i++ )
4488 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 4 ) , CRTCData[ i ] ) ;
4489
4490 for( i = 13 ; i < 16 ; i++ )
4491 XGINew_SetReg1( pVBInfo->P3c4 , ( USHORT )( i - 3 ) , CRTCData[ i ] ) ;
4492
4493 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , ( UCHAR )( CRTCData[ 16 ] & 0xE0 ) ) ;
4494
4495 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , 0x00 ) ;
4496 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B ) ;
4497 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE1 ) ;
4498
4499 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4500
4501 for( i = 0 ; i < 256 ; i++ )
4502 {
4503 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 0 ] ) ;
4504 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 1 ] ) ;
4505 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 2 ] ) ;
4506 }
4507
4508 XGI_VBLongWait( pVBInfo ) ;
4509 XGI_VBLongWait( pVBInfo ) ;
4510 XGI_VBLongWait( pVBInfo ) ;
4511
4512 XGINew_LCD_Wait_Time( 0x01 , pVBInfo ) ;
4513
4514 XGI_WaitDisply( pVBInfo ) ;
4515 temp = XGINew_GetReg2( pVBInfo->P3c2 ) ;
4516
4517 if( temp & 0x10 )
4518 {
4519 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x20 ) ;
4520 }
4521 else
4522 {
4523 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x00 ) ;
4524 }
4525
4526 /* alan, avoid display something, set BLACK DAC if not restore DAC */
4527 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4528
4529 for( i = 0 ; i < 256 ; i++ )
4530 {
4531 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4532 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4533 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4534 }
4535
4536 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , SR01 ) ;
4537 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , CR63 ) ;
4538 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , SR31 ) ;
4539
4540 /* [2004/05/11] Vicent */
4541 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) & 0xFD ) ) ;
4542 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR ) SR1F ) ;
4543}
4544
4545
4546
4547
4548
4549#ifdef TC
4550/* --------------------------------------------------------------------- */
4551/* Function : INT1AReturnCode */
4552/* Input : */
4553/* Output : */
4554/* Description : */
4555/* --------------------------------------------------------------------- */
4556int INT1AReturnCode( union REGS regs )
4557{
4558 if ( regs.x.cflag )
4559 {
4560 /* printf( "Error to find pci device!\n" ) ; */
4561 return( 1 ) ;
4562 }
4563
4564 switch(regs.h.ah)
4565 {
4566 case 0: return 0;
4567 break ;
4568 case 0x81:
4569 printf( "Function not support\n" ) ;
4570 break ;
4571 case 0x83:
4572 printf( "bad vendor id\n" ) ;
4573 break ;
4574 case 0x86:
4575 printf( "device not found\n" ) ;
4576 break ;
4577 case 0x87:
4578 printf( "bad register number\n" ) ;
4579 break ;
4580 case 0x88:
4581 printf( "set failed\n" ) ;
4582 break ;
4583 case 0x89:
4584 printf( "buffer too small" ) ;
4585 break ;
4586 default:
4587 break ;
4588 }
4589 return( 1 ) ;
4590}
4591
4592
4593/* --------------------------------------------------------------------- */
4594/* Function : FindPCIIOBase */
4595/* Input : */
4596/* Output : */
4597/* Description : */
4598/* --------------------------------------------------------------------- */
4599unsigned FindPCIIOBase( unsigned index , unsigned deviceid )
4600{
4601 union REGS regs ;
4602
4603 regs.h.ah = 0xb1 ; /* PCI_FUNCTION_ID */
4604 regs.h.al = 0x02 ; /* FIND_PCI_DEVICE */
4605 regs.x.cx = deviceid ;
4606 regs.x.dx = 0x1039 ;
4607 regs.x.si = index ; /* find n-th device */
4608
4609 int86( 0x1A , &regs , &regs ) ;
4610
4611 if ( INT1AReturnCode( regs ) != 0 )
4612 return( 0 ) ;
4613
4614 /* regs.h.bh bus number */
4615 /* regs.h.bl device number */
4616 regs.h.ah = 0xb1 ; /* PCI_FUNCTION_ID */
4617 regs.h.al = 0x09 ; /* READ_CONFIG_WORD */
4618 regs.x.cx = deviceid ;
4619 regs.x.dx = 0x1039 ;
4620 regs.x.di = 0x18 ; /* register number */
4621 int86( 0x1A , &regs , &regs ) ;
4622
4623 if ( INT1AReturnCode( regs ) != 0 )
4624 return( 0 ) ;
4625
4626 return( regs.x.cx ) ;
4627}
4628
4629#endif
4630
4631
4632
4633#ifdef TC
4634/* --------------------------------------------------------------------- */
4635/* Function : main */
4636/* Input : */
4637/* Output : */
4638/* Description : */
4639/* --------------------------------------------------------------------- */
4640void main(int argc, char *argv[])
4641{
4642 XGI_HW_DEVICE_INFO HwDeviceExtension ;
4643 USHORT temp ;
4644 USHORT ModeNo ;
4645
4646 /* HwDeviceExtension.pjVirtualRomBase =(PUCHAR) MK_FP(0xC000,0); */
4647 /* HwDeviceExtension.pjVideoMemoryAddress = (PUCHAR)MK_FP(0xA000,0); */
4648
4649
4650 HwDeviceExtension.pjIOAddress = ( FindPCIIOBase( 0 ,0x6300 ) & 0xFF80 ) + 0x30 ;
4651 HwDeviceExtension.jChipType = XGI_340 ;
4652
4653
4654
4655 /* HwDeviceExtension.pjIOAddress = ( FindPCIIOBase( 0 , 0x5315 ) & 0xFF80 ) + 0x30 ; */
4656
4657 HwDeviceExtension.pjIOAddress = ( FindPCIIOBase( 0 , 0x330 ) & 0xFF80 ) + 0x30 ;
4658 HwDeviceExtension.jChipType = XGI_340 ;
4659
4660
4661 HwDeviceExtension.ujVBChipID = VB_CHIP_301 ;
4662 StrCpy(HwDeviceExtension.szVBIOSVer , "0.84" ) ;
4663 HwDeviceExtension.bSkipDramSizing = FALSE ;
4664 HwDeviceExtension.ulVideoMemorySize = 0 ;
4665
4666 if ( argc == 2 )
4667 {
4668 ModeNo = atoi( argv[ 1 ] ) ;
4669 }
4670 else
4671 {
4672 ModeNo = 0x2e ;
4673 /* ModeNo = 0x37 ; 1024x768x 4bpp */
4674 /* ModeNo = 0x38 ; 1024x768x 8bpp */
4675 /* ModeNo = 0x4A ; 1024x768x 16bpp */
4676 /* ModeNo = 0x47 ; 800x600x 16bpp */
4677 }
4678
4679 /* XGIInitNew( &HwDeviceExtension ) ; */
4680 XGISetModeNew( &HwDeviceExtension , ModeNo ) ;
4681}
4682#endif
4683
4684
4685/* --------------------------------------------------------------------- */
4686/* Function : XGI_WaitDisplay */
4687/* Input : */
4688/* Output : */
4689/* Description : */
4690/* --------------------------------------------------------------------- */
4691void XGI_WaitDisplay( PVB_DEVICE_INFO pVBInfo )
4692{
4693 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ) ;
4694
4695 while( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ;
4696}
4697
4698
4699
4700
4701/* --------------------------------------------------------------------- */
4702/* Function : XGI_SetCRT2Group301 */
4703/* Input : */
4704/* Output : */
4705/* Description : */
4706/* --------------------------------------------------------------------- */
4707BOOLEAN XGI_SetCRT2Group301( USHORT ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
4708{
4709 USHORT tempbx ,
4710 ModeIdIndex ,
4711 RefreshRateTableIndex ;
4712
4713 tempbx=pVBInfo->VBInfo ;
4714 pVBInfo->SetFlag |= ProgrammingCRT2 ;
4715 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
4716 pVBInfo->SelectCRT2Rate = 4 ;
4717 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
4718 XGI_SaveCRT2Info( ModeNo, pVBInfo ) ;
4719 XGI_GetCRT2ResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4720 XGI_GetCRT2Data( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4721 XGI_PreSetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4722 XGI_SetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4723 XGI_SetLockRegs( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4724 XGI_SetGroup2( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4725 XGI_SetLCDRegs(ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4726 XGI_SetTap4Regs(pVBInfo) ;
4727 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
4728 XGI_SetGroup4( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4729 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4730 XGI_SetGroup5( ModeNo , ModeIdIndex, pVBInfo) ;
4731 XGI_AutoThreshold( pVBInfo) ;
4732 return 1 ;
4733}
4734
4735
4736/* --------------------------------------------------------------------- */
4737/* Function : XGI_AutoThreshold */
4738/* Input : */
4739/* Output : */
4740/* Description : */
4741/* --------------------------------------------------------------------- */
4742void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo )
4743{
4744 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
4745 XGINew_SetRegOR( pVBInfo->Part1Port , 0x01 , 0x40 ) ;
4746}
4747
4748
4749/* --------------------------------------------------------------------- */
4750/* Function : XGI_SaveCRT2Info */
4751/* Input : */
4752/* Output : */
4753/* Description : */
4754/* --------------------------------------------------------------------- */
4755void XGI_SaveCRT2Info( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo)
4756{
4757 USHORT temp1 ,
4758 temp2 ;
4759
4760 XGINew_SetReg1( pVBInfo->P3d4 , 0x34 , ModeNo ) ; /* reserve CR34 for CRT1 Mode No */
4761 temp1 = ( pVBInfo->VBInfo&SetInSlaveMode ) >> 8 ;
4762 temp2 = ~( SetInSlaveMode >> 8 ) ;
4763 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , temp2 , temp1 ) ;
4764}
4765
4766
4767/* --------------------------------------------------------------------- */
4768/* Function : XGI_GetCRT2ResInfo */
4769/* Input : */
4770/* Output : */
4771/* Description : */
4772/* --------------------------------------------------------------------- */
4773void XGI_GetCRT2ResInfo( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
4774{
4775 USHORT xres ,
4776 yres ,
4777 modeflag ,
4778 resindex ;
4779
4780 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4781 if ( ModeNo <= 0x13 )
4782 {
4783 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
4784 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
4785 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4786 }
4787 else
4788 {
4789 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
4790 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
4791 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
4792
4793/* if ( pVBInfo->IF_DEF_FSTN )
4794 {
4795 xres *= 2 ;
4796 yres *= 2 ;
4797 }
4798 else
4799 {
4800*/
4801 if ( modeflag & HalfDCLK )
4802 xres *= 2;
4803
4804 if ( modeflag & DoubleScanMode )
4805 yres *= 2 ;
4806/* } */
4807 }
4808
4809 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4810 {
4811 if ( pVBInfo->IF_DEF_LVDS == 0 )
4812 {
4813 if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4814 {
4815 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4816 {
4817 if ( yres == 1024 )
4818 yres = 1056 ;
4819 }
4820 }
4821
4822 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4823 {
4824 if ( yres == 400 )
4825 yres = 405 ;
4826 else if ( yres == 350 )
4827 yres = 360 ;
4828
4829 if ( pVBInfo->LCDInfo & LCDVESATiming )
4830 {
4831 if ( yres == 360 )
4832 yres = 375 ;
4833 }
4834 }
4835
4836 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4837 {
4838 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4839 {
4840 if ( !( pVBInfo->LCDInfo & LCDNonExpanding ) )
4841 {
4842 if ( yres == 350 )
4843 yres = 357 ;
4844 else if ( yres == 400 )
4845 yres = 420 ;
4846 else if ( yres == 480 )
4847 yres = 525 ;
4848 }
4849 }
4850 }
4851 }
4852
4853 if ( xres == 720 )
4854 xres = 640 ;
4855 }
4856
4857 pVBInfo->VGAHDE = xres ;
4858 pVBInfo->HDE = xres ;
4859 pVBInfo->VGAVDE = yres ;
4860 pVBInfo->VDE = yres ;
4861}
4862
4863
4864/* --------------------------------------------------------------------- */
4865/* Function : XGI_IsLCDDualLink */
4866/* Input : */
4867/* Output : */
4868/* Description : */
4869/* --------------------------------------------------------------------- */
4870BOOLEAN XGI_IsLCDDualLink( PVB_DEVICE_INFO pVBInfo )
4871{
4872
4873 if ( ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) && ( pVBInfo->LCDInfo & SetLCDDualLink ) ) /* shampoo0129 */
4874 return ( 1 ) ;
4875
4876 return( 0 ) ;
4877}
4878
4879
4880/* --------------------------------------------------------------------- */
4881/* Function : XGI_GetCRT2Data */
4882/* Input : */
4883/* Output : */
4884/* Description : */
4885/* --------------------------------------------------------------------- */
4886void XGI_GetCRT2Data( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
4887{
4888 USHORT tempax = 0,
4889 tempbx ,
4890 modeflag ,
4891 resinfo ;
4892
4893 XGI_LCDDataStruct *LCDPtr = NULL ;
4894 XGI_TVDataStruct *TVPtr = NULL ;
4895
4896 if ( ModeNo <= 0x13 )
4897 {
4898 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4899 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
4900 }
4901 else
4902 {
4903 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
4904 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
4905 }
4906
4907 pVBInfo->NewFlickerMode = 0 ;
4908 pVBInfo->RVBHRS = 50 ;
4909
4910 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4911 {
4912 XGI_GetRAMDAC2DATA( ModeNo , ModeIdIndex , RefreshRateTableIndex,pVBInfo ) ;
4913 return ;
4914 }
4915
4916 tempbx = 4 ;
4917
4918 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4919 {
4920 LCDPtr = (XGI_LCDDataStruct* )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4921
4922 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX ;
4923 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT ;
4924 pVBInfo->VGAHT = LCDPtr->VGAHT ;
4925 pVBInfo->VGAVT = LCDPtr->VGAVT ;
4926 pVBInfo->HT = LCDPtr->LCDHT ;
4927 pVBInfo->VT = LCDPtr->LCDVT ;
4928
4929 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4930 {
4931 tempax = 1024 ;
4932 tempbx = 768 ;
4933
4934 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4935 {
4936 if ( pVBInfo->VGAVDE == 357 )
4937 tempbx = 527 ;
4938 else if ( pVBInfo->VGAVDE == 420 )
4939 tempbx = 620 ;
4940 else if ( pVBInfo->VGAVDE == 525 )
4941 tempbx = 775 ;
4942 else if ( pVBInfo->VGAVDE == 600 )
4943 tempbx = 775 ;
4944 /* else if(pVBInfo->VGAVDE==350) tempbx=560; */
4945 /* else if(pVBInfo->VGAVDE==400) tempbx=640; */
4946 else
4947 tempbx = 768 ;
4948 }
4949 else
4950 tempbx = 768 ;
4951 }
4952 else if ( pVBInfo->LCDResInfo == Panel1024x768x75 )
4953 {
4954 tempax = 1024 ;
4955 tempbx = 768 ;
4956 }
4957 else if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4958 {
4959 tempax = 1280 ;
4960 if ( pVBInfo->VGAVDE == 360 )
4961 tempbx = 768 ;
4962 else if ( pVBInfo->VGAVDE == 375 )
4963 tempbx = 800 ;
4964 else if ( pVBInfo->VGAVDE == 405 )
4965 tempbx = 864 ;
4966 else
4967 tempbx = 1024 ;
4968 }
4969 else if ( pVBInfo->LCDResInfo == Panel1280x1024x75 )
4970 {
4971 tempax = 1280 ;
4972 tempbx = 1024 ;
4973 }
4974 else if ( pVBInfo->LCDResInfo == Panel1280x960 )
4975 {
4976 tempax = 1280 ;
4977 if ( pVBInfo->VGAVDE == 350 )
4978 tempbx = 700 ;
4979 else if ( pVBInfo->VGAVDE == 400 )
4980 tempbx = 800 ;
4981 else if ( pVBInfo->VGAVDE == 1024 )
4982 tempbx = 960 ;
4983 else
4984 tempbx = 960 ;
4985 }
4986 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
4987 {
4988 tempax = 1400 ;
4989 tempbx = 1050 ;
4990
4991 if ( pVBInfo->VGAVDE == 1024 )
4992 {
4993 tempax = 1280 ;
4994 tempbx = 1024 ;
4995 }
4996 }
4997 else if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4998 {
4999 tempax = 1600 ;
5000 tempbx = 1200 ; /* alan 10/14/2003 */
5001 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
5002 {
5003 if ( pVBInfo->VGAVDE == 350 )
5004 tempbx = 875 ;
5005 else if ( pVBInfo->VGAVDE == 400 )
5006 tempbx = 1000 ;
5007 }
5008 }
5009
5010 if ( pVBInfo->LCDInfo & LCDNonExpanding )
5011 {
5012 tempax = pVBInfo->VGAHDE ;
5013 tempbx = pVBInfo->VGAVDE ;
5014 }
5015
5016 pVBInfo->HDE = tempax ;
5017 pVBInfo->VDE = tempbx ;
5018 return ;
5019 }
5020
5021 if ( pVBInfo->VBInfo & ( SetCRT2ToTV ) )
5022 {
5023 tempbx = 4 ;
5024 TVPtr = ( XGI_TVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
5025
5026 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX ;
5027 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT ;
5028 pVBInfo->VGAHT = TVPtr->VGAHT ;
5029 pVBInfo->VGAVT = TVPtr->VGAVT ;
5030 pVBInfo->HDE = TVPtr->TVHDE ;
5031 pVBInfo->VDE = TVPtr->TVVDE ;
5032 pVBInfo->RVBHRS = TVPtr->RVBHRS ;
5033 pVBInfo->NewFlickerMode = TVPtr->FlickerMode ;
5034
5035 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5036 {
5037 if ( resinfo == 0x08 )
5038 pVBInfo->NewFlickerMode = 0x40 ;
5039 else if ( resinfo == 0x09 )
5040 pVBInfo->NewFlickerMode = 0x40 ;
5041 else if ( resinfo == 0x12 )
5042 pVBInfo->NewFlickerMode = 0x40 ;
5043
5044 if ( pVBInfo->VGAVDE == 350 )
5045 pVBInfo->TVInfo |= TVSimuMode ;
5046
5047 tempax = ExtHiTVHT ;
5048 tempbx = ExtHiTVVT ;
5049
5050 if ( pVBInfo->VBInfo & SetInSlaveMode )
5051 {
5052 if ( pVBInfo->TVInfo & TVSimuMode )
5053 {
5054 tempax = StHiTVHT ;
5055 tempbx = StHiTVVT ;
5056
5057 if ( !( modeflag & Charx8Dot ) )
5058 {
5059 tempax = StHiTextTVHT ;
5060 tempbx = StHiTextTVVT ;
5061 }
5062 }
5063 }
5064 }
5065 else if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
5066 {
5067 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
5068 {
5069 tempax = YPbPrTV750pHT ; /* Ext750pTVHT */
5070 tempbx = YPbPrTV750pVT ; /* Ext750pTVVT */
5071 }
5072
5073 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
5074 {
5075 tempax = YPbPrTV525pHT ; /* Ext525pTVHT */
5076 tempbx = YPbPrTV525pVT ; /* Ext525pTVVT */
5077 }
5078 else if ( pVBInfo->TVInfo & SetYPbPrMode525i )
5079 {
5080 tempax = YPbPrTV525iHT ; /* Ext525iTVHT */
5081 tempbx = YPbPrTV525iVT ; /* Ext525iTVVT */
5082 if ( pVBInfo->TVInfo & NTSC1024x768 )
5083 tempax = NTSC1024x768HT ;
5084 }
5085 }
5086 else
5087 {
5088 tempax = PALHT ;
5089 tempbx = PALVT ;
5090 if ( !( pVBInfo->TVInfo & SetPALTV ) )
5091 {
5092 tempax = NTSCHT ;
5093 tempbx = NTSCVT ;
5094 if ( pVBInfo->TVInfo & NTSC1024x768 )
5095 tempax = NTSC1024x768HT ;
5096 }
5097 }
5098
5099 pVBInfo->HT = tempax ;
5100 pVBInfo->VT = tempbx ;
5101 return ;
5102 }
5103}
5104
5105
5106/* --------------------------------------------------------------------- */
5107/* Function : XGI_SetCRT2VCLK */
5108/* Input : */
5109/* Output : */
5110/* Description : */
5111/* --------------------------------------------------------------------- */
5112void XGI_SetCRT2VCLK( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5113{
5114 UCHAR di_0 ,
5115 di_1 ,
5116 tempal ;
5117
5118 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
5119 XGI_GetVCLKLen( tempal, &di_0 , &di_1, pVBInfo ) ;
5120 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
5121
5122 if ( pVBInfo->VBType & VB_XGI301 ) /* shampoo 0129 */
5123 { /* 301 */
5124 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , 0x10 ) ;
5125 XGINew_SetReg1(pVBInfo->Part4Port , 0x0B , di_1 ) ;
5126 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , di_0 ) ;
5127 }
5128 else
5129 { /* 301b/302b/301lv/302lv */
5130 XGINew_SetReg1( pVBInfo->Part4Port , 0x0A , di_0 ) ;
5131 XGINew_SetReg1( pVBInfo->Part4Port , 0x0B , di_1 ) ;
5132 }
5133
5134 XGINew_SetReg1( pVBInfo->Part4Port , 0x00 , 0x12 ) ;
5135
5136 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5137 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x28 ) ;
5138 else
5139 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x08 ) ;
5140}
5141
5142
5143/* --------------------------------------------------------------------- */
5144/* Function : XGI_GETLCDVCLKPtr */
5145/* Input : */
5146/* Output : al -> VCLK Index */
5147/* Description : */
5148/* --------------------------------------------------------------------- */
5149void XGI_GetLCDVCLKPtr( UCHAR* di_0 , UCHAR *di_1, PVB_DEVICE_INFO pVBInfo )
5150{
5151 USHORT index ;
5152
5153 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
5154 {
5155 if ( pVBInfo->IF_DEF_ScaleLCD == 1 )
5156 {
5157 if ( pVBInfo->LCDInfo & EnableScalingLCD )
5158 return ;
5159 }
5160
5161 /* index = XGI_GetLCDCapPtr(pVBInfo) ; */
5162 index = XGI_GetLCDCapPtr1( pVBInfo) ;
5163
5164 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
5165 { /* LCDB */
5166 *di_0 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData1 ;
5167 *di_1 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData2 ;
5168 }
5169 else
5170 { /* LCDA */
5171 *di_0 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData1 ;
5172 *di_1 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData2 ;
5173 }
5174 }
5175 return ;
5176}
5177
5178
5179/* --------------------------------------------------------------------- */
5180/* Function : XGI_GetVCLKPtr */
5181/* Input : */
5182/* Output : */
5183/* Description : */
5184/* --------------------------------------------------------------------- */
5185UCHAR XGI_GetVCLKPtr(USHORT RefreshRateTableIndex,USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
5186{
5187
5188 USHORT index ,
5189 modeflag ;
5190#ifndef LINUX_XF86
5191 USHORT tempbx ;
5192#endif
5193
5194 UCHAR tempal ;
5195 UCHAR *CHTVVCLKPtr = NULL ;
5196
5197 if ( ModeNo <= 0x13 )
5198 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5199 else
5200 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5201
5202
5203 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) )
5204 { /* {LCDA/LCDB} */
5205 index = XGI_GetLCDCapPtr(pVBInfo) ;
5206 tempal = pVBInfo->LCDCapList[ index ].LCD_VCLK ;
5207
5208 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
5209 return tempal ;
5210
5211 /* {TV} */
5212 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV| VB_XGI302LV| VB_XGI301C ) )
5213 {
5214 if(pVBInfo->VBInfo&SetCRT2ToHiVisionTV)
5215 {
5216 tempal = HiTVVCLKDIV2;
5217 if(!(pVBInfo->TVInfo & RPLLDIV2XO))
5218 tempal = HiTVVCLK;
5219 if(pVBInfo->TVInfo & TVSimuMode)
5220 {
5221 tempal = HiTVSimuVCLK;
5222 if(!(modeflag & Charx8Dot))
5223 tempal = HiTVTextVCLK;
5224
5225 }
5226 return tempal;
5227 }
5228
5229 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
5230 {
5231 tempal = YPbPr750pVCLK ;
5232 return tempal ;
5233 }
5234
5235 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
5236 {
5237 tempal = YPbPr525pVCLK ;
5238 return tempal ;
5239 }
5240
5241 tempal = NTSC1024VCLK ;
5242
5243 if ( !( pVBInfo->TVInfo & NTSC1024x768 ) )
5244 {
5245 tempal = TVVCLKDIV2 ;
5246 if ( !( pVBInfo->TVInfo & RPLLDIV2XO ) )
5247 tempal = TVVCLK ;
5248 }
5249
5250 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5251 return tempal ;
5252 }
5253 /*else
5254 if((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017))
5255 {
5256 if(ModeNo<=0x13)
5257 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5258 else
5259 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5260 *tempal = *tempal & 0x1F;
5261
5262 tempbx = 0;
5263 if(pVBInfo->TVInfo & SetPALTV)
5264 tempbx = tempbx + 2;
5265 if(pVBInfo->TVInfo & SetCHTVOverScan)
5266 tempbx++;
5267 tempbx = tempbx << 1;
5268 } */
5269 } /* {End of VB} */
5270
5271 if((pVBInfo->IF_DEF_CH7007==1)&&(pVBInfo->VBType&VB_CH7007)) /* [Billy] 07/05/08 CH7007 */
5272 {
5273 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
5274 if ( (pVBInfo->VBInfo & SetCRT2ToTV) )
5275 {
5276 if( ModeNo <= 0x13 )
5277 {
5278 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5279 }
5280 else
5281 {
5282 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5283 }
5284
5285 tempal = tempal & 0x0F;
5286 tempbx = 0;
5287
5288 if(pVBInfo->TVInfo & SetPALTV)
5289 {
5290 tempbx = tempbx + 2;
5291 }
5292 if(pVBInfo->TVInfo & SetCHTVOverScan)
5293 {
5294 tempbx++;
5295 }
5296 /** tempbx = tempbx << 1; CH7007 ? **/
5297
5298/*[Billy]07/05/29 CH7007*/
5299 if ( pVBInfo->IF_DEF_CH7007 == 1 )
5300 {
5301 switch( tempbx )
5302 {
5303 case 0:
5304 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC ;
5305 break ;
5306 case 1:
5307 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC ;
5308 break ;
5309 case 2:
5310 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL ;
5311 break ;
5312 case 3:
5313 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL ;
5314 break ;
5315 default:
5316 break ;
5317
5318 }
5319 }
5320 /*else
5321 {
5322 switch( tempbx )
5323 {
5324 case 0:
5325 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
5326 break ;
5327 case 1:
5328 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
5329 break ;
5330 case 2:
5331 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
5332 break ;
5333 case 3:
5334 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
5335 break ;
5336 default:
5337 break ;
5338 }
5339 }*/
5340
5341 tempal = CHTVVCLKPtr[ tempal ] ;
5342 return tempal ;
5343 }
5344
5345 }
5346
5347 tempal = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ;
5348 tempal = tempal >> 2 ;
5349 tempal &= 0x03 ;
5350
5351 if ( ( pVBInfo->LCDInfo & EnableScalingLCD ) && ( modeflag & Charx8Dot ) ) /* for Dot8 Scaling LCD */
5352 tempal = tempal ^ tempal ; /* ; set to VCLK25MHz always */
5353
5354 if ( ModeNo <= 0x13 )
5355 return tempal ;
5356
5357 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
5358 return tempal ;
5359}
5360
5361
5362/* --------------------------------------------------------------------- */
5363/* Function : XGI_GetVCLKLen */
5364/* Input : */
5365/* Output : */
5366/* Description : */
5367/* --------------------------------------------------------------------- */
5368void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo)
5369{
5370 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 2007/05/16 */
5371 {
5372 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
5373 *di_0 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2B ;
5374 *di_1 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2C ;
5375 }
5376 else if ( pVBInfo->VBType & ( VB_XGI301 | VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5377 {
5378 if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
5379 {
5380 *di_0 = ( UCHAR )XGI_VBVCLKData[ tempal ].SR2B ;
5381 *di_1 = XGI_VBVCLKData[ tempal ].SR2C ;
5382 }
5383 }
5384 else
5385 {
5386 *di_0 = XGI_VCLKData[ tempal ].SR2B ;
5387 *di_1 = XGI_VCLKData[ tempal ].SR2C ;
5388 }
5389}
5390
5391
5392/* --------------------------------------------------------------------- */
5393/* Function : XGI_SetCRT2Offset */
5394/* Input : */
5395/* Output : */
5396/* Description : */
5397/* --------------------------------------------------------------------- */
5398void XGI_SetCRT2Offset( USHORT ModeNo ,
5399 USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
5400{
5401 USHORT offset ;
5402 UCHAR temp ;
5403
5404 if ( pVBInfo->VBInfo & SetInSlaveMode )
5405 {
5406 return ;
5407 }
5408
5409 offset = XGI_GetOffset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5410 temp = ( UCHAR )( offset & 0xFF ) ;
5411 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ;
5412 temp =( UCHAR)( ( offset & 0xFF00 ) >> 8 ) ;
5413 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , temp ) ;
5414 temp =( UCHAR )( ( ( offset >> 3 ) & 0xFF ) + 1 ) ;
5415 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5416}
5417
5418
5419/* --------------------------------------------------------------------- */
5420/* Function : XGI_GetOffset */
5421/* Input : */
5422/* Output : */
5423/* Description : */
5424/* --------------------------------------------------------------------- */
5425USHORT XGI_GetOffset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo)
5426{
5427 USHORT temp ,
5428 colordepth ,
5429 modeinfo ,
5430 index ,
5431 infoflag ,
5432 ColorDepth[] = { 0x01 , 0x02 , 0x04 } ;
5433
5434 modeinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
5435 if ( ModeNo <= 0x14 )
5436 infoflag = 0 ;
5437 else
5438 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
5439
5440
5441 index = ( modeinfo >> 8 ) & 0xFF ;
5442
5443 temp = pVBInfo->ScreenOffset[ index ] ;
5444
5445 if ( infoflag & InterlaceMode )
5446 {
5447 temp = temp << 1 ;
5448 }
5449
5450 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
5451
5452 if ( ( ModeNo >= 0x7C ) && ( ModeNo <= 0x7E ) )
5453 {
5454 temp = ModeNo - 0x7C ;
5455 colordepth = ColorDepth[ temp ] ;
5456 temp = 0x6B ;
5457 if ( infoflag & InterlaceMode )
5458 {
5459 temp = temp << 1 ;
5460 }
5461 return( temp * colordepth ) ;
5462 }
5463 else
5464 return( temp * colordepth ) ;
5465}
5466
5467
5468/* --------------------------------------------------------------------- */
5469/* Function : XGI_SetCRT2FIFO */
5470/* Input : */
5471/* Output : */
5472/* Description : */
5473/* --------------------------------------------------------------------- */
5474void XGI_SetCRT2FIFO( PVB_DEVICE_INFO pVBInfo)
5475{
5476 XGINew_SetReg1( pVBInfo->Part1Port , 0x01 , 0x3B ) ; /* threshold high ,disable auto threshold */
5477 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x02 , ~( 0x3F ) , 0x04 ) ; /* threshold low default 04h */
5478}
5479
5480
5481/* --------------------------------------------------------------------- */
5482/* Function : XGI_PreSetGroup1 */
5483/* Input : */
5484/* Output : */
5485/* Description : */
5486/* --------------------------------------------------------------------- */
5487void XGI_PreSetGroup1(USHORT ModeNo , USHORT ModeIdIndex ,PXGI_HW_DEVICE_INFO HwDeviceExtension,
5488 USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5489{
5490 USHORT tempcx = 0 ,
5491 CRT1Index = 0 ,
5492 resinfo = 0 ;
5493
5494 if ( ModeNo > 0x13 )
5495 {
5496 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5497 CRT1Index &= IndexMask ;
5498 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5499 }
5500
5501 XGI_SetCRT2Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5502 XGI_SetCRT2FIFO(pVBInfo) ;
5503 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
5504
5505 for( tempcx = 4 ; tempcx < 7 ; tempcx++ )
5506 {
5507 XGINew_SetReg1( pVBInfo->Part1Port , tempcx , 0x0 ) ;
5508 }
5509
5510 XGINew_SetReg1( pVBInfo->Part1Port , 0x50 , 0x00 ) ;
5511 XGINew_SetReg1( pVBInfo->Part1Port , 0x02 , 0x44 ) ; /* temp 0206 */
5512}
5513
5514
5515/* --------------------------------------------------------------------- */
5516/* Function : XGI_SetGroup1 */
5517/* Input : */
5518/* Output : */
5519/* Description : */
5520/* --------------------------------------------------------------------- */
5521void XGI_SetGroup1( USHORT ModeNo , USHORT ModeIdIndex ,
5522 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5523{
5524 USHORT temp = 0 ,
5525 tempax = 0 ,
5526 tempbx = 0 ,
5527 tempcx = 0 ,
5528 pushbx = 0 ,
5529 CRT1Index = 0 ,
5530 modeflag ,
5531 resinfo = 0 ;
5532
5533 if ( ModeNo > 0x13 )
5534 {
5535 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5536 CRT1Index &= IndexMask ;
5537 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5538 }
5539
5540 if ( ModeNo <= 0x13 )
5541 {
5542 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
5543 }
5544 else
5545 {
5546 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
5547 }
5548
5549 /* bainy change table name */
5550 if ( modeflag & HalfDCLK )
5551 {
5552 temp = ( pVBInfo->VGAHT / 2 - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5553 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5554 temp = ( ( ( pVBInfo->VGAHT / 2 - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5555 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5556 temp = ( pVBInfo->VGAHDE / 2 + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5557 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5558 tempcx = ( ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) / 2 ) >> 2 ;
5559 pushbx = pVBInfo->VGAHDE / 2 + 16 ;
5560 tempcx = tempcx >> 1 ;
5561 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5562 tempcx += tempbx ;
5563
5564 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5565 {
5566 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5567 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] & 0xC0 ) << 2 ) ;
5568 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5569 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[ 5 ] ;
5570 tempcx &= 0x1F ;
5571 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 15 ] ;
5572 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5573 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5574 }
5575
5576 tempbx += 4 ;
5577 tempcx += 4 ;
5578
5579 if ( tempcx > ( pVBInfo->VGAHT / 2 ) )
5580 tempcx = pVBInfo->VGAHT / 2 ;
5581
5582 temp = tempbx & 0x00FF ;
5583
5584 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5585 }
5586 else
5587 {
5588 temp = ( pVBInfo->VGAHT - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5589 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5590 temp = ( ( ( pVBInfo->VGAHT - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5591 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5592 temp = ( pVBInfo->VGAHDE + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5593 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5594 tempcx = ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) >> 2 ; /* cx */
5595 pushbx = pVBInfo->VGAHDE + 16 ;
5596 tempcx = tempcx >> 1 ;
5597 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5598 tempcx += tempbx ;
5599
5600 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5601 {
5602 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 3 ] ;
5603 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] & 0xC0 ) << 2 ) ;
5604 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5605 tempcx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5606 tempcx &= 0x1F ;
5607 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 6 ] ;
5608 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5609 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5610 tempbx += 16 ;
5611 tempcx += 16 ;
5612 }
5613
5614 if ( tempcx > pVBInfo->VGAHT )
5615 tempcx = pVBInfo->VGAHT ;
5616
5617 temp = tempbx & 0x00FF ;
5618 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5619 }
5620
5621 tempax = ( tempax & 0x00FF ) | ( tempbx & 0xFF00 ) ;
5622 tempbx = pushbx ;
5623 tempbx = ( tempbx & 0x00FF ) | ( ( tempbx & 0xFF00 ) << 4 ) ;
5624 tempax |= ( tempbx & 0xFF00 ) ;
5625 temp = ( tempax & 0xFF00 ) >> 8 ;
5626 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5627 temp = tempcx & 0x00FF ;
5628 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ;
5629 tempcx = ( pVBInfo->VGAVT - 1 ) ;
5630 temp = tempcx & 0x00FF ;
5631
5632 if ( pVBInfo->IF_DEF_CH7005 == 1 )
5633 {
5634 if ( pVBInfo->VBInfo & 0x0C )
5635 {
5636 temp-- ;
5637 }
5638 }
5639
5640 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5641 tempbx = pVBInfo->VGAVDE - 1 ;
5642 temp = tempbx & 0x00FF ;
5643 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , temp ) ;
5644 temp = ( ( tempbx & 0xFF00 ) << 3 ) >> 8 ;
5645 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
5646 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , temp ) ;
5647
5648 tempax = pVBInfo->VGAVDE ;
5649 tempbx = pVBInfo->VGAVDE ;
5650 tempcx = pVBInfo->VGAVT ;
5651 tempbx = ( pVBInfo->VGAVT + pVBInfo->VGAVDE ) >> 1 ; /* BTVGA2VRS 0x10,0x11 */
5652 tempcx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) >> 4 ) + tempbx + 1 ; /* BTVGA2VRE 0x11 */
5653
5654 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5655 {
5656 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 10 ] ;
5657 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
5658
5659 if ( temp & 0x04 )
5660 tempbx |= 0x0100 ;
5661
5662 if ( temp & 0x080 )
5663 tempbx |= 0x0200 ;
5664
5665 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] ;
5666
5667 if ( temp & 0x08 )
5668 tempbx |= 0x0400 ;
5669
5670 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 11 ] ;
5671 tempcx = ( tempcx & 0xFF00 ) | ( temp & 0x00FF ) ;
5672 }
5673
5674 temp = tempbx & 0x00FF ;
5675 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5676 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
5677 temp = ( ( tempcx & 0x000F ) | ( temp ) ) ;
5678 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , temp ) ;
5679 tempax = 0 ;
5680
5681 if ( modeflag & DoubleScanMode )
5682 tempax |= 0x80 ;
5683
5684 if ( modeflag & HalfDCLK )
5685 tempax |= 0x40 ;
5686
5687 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2C , ~0x0C0 , tempax ) ;
5688}
5689
5690
5691/* --------------------------------------------------------------------- */
5692/* Function : XGI_SetLockRegs */
5693/* Input : */
5694/* Output : */
5695/* Description : */
5696/* --------------------------------------------------------------------- */
5697void XGI_SetLockRegs( USHORT ModeNo , USHORT ModeIdIndex ,
5698 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5699{
5700 USHORT push1 ,
5701 push2 ,
5702 tempax ,
5703 tempbx = 0 ,
5704 tempcx ,
5705 temp ,
5706 resinfo ,
5707 modeflag ,
5708 CRT1Index ;
5709
5710 if ( ModeNo <= 0x13 )
5711 {
5712 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5713 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5714 }
5715 else
5716 {
5717 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5718 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5719 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5720 CRT1Index &= IndexMask;
5721 }
5722
5723 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
5724 {
5725 return ;
5726 }
5727
5728 temp = 0xFF ; /* set MAX HT */
5729 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5730 /* if ( modeflag & Charx8Dot ) tempcx = 0x08 ; */
5731 /* else */
5732 tempcx=0x08;
5733
5734 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5735 modeflag |= Charx8Dot ;
5736
5737 tempax = pVBInfo->VGAHDE ; /* 0x04 Horizontal Display End */
5738
5739 if ( modeflag & HalfDCLK )
5740 tempax = tempax >> 1 ;
5741
5742 tempax = ( tempax / tempcx ) - 1 ;
5743 tempbx |= ( ( tempax & 0x00FF ) << 8 ) ;
5744 temp = tempax & 0x00FF ;
5745 XGINew_SetReg1( pVBInfo->Part1Port , 0x04 , temp ) ;
5746
5747 temp = ( tempbx & 0xFF00 ) >> 8 ;
5748
5749 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5750 {
5751 if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
5752 temp += 2 ;
5753
5754 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5755 {
5756 if ( pVBInfo->VBType & VB_XGI301LV )
5757 {
5758 if ( pVBInfo->VBExtInfo == VB_YPbPr1080i )
5759 {
5760 if ( resinfo == 7 )
5761 temp -= 2 ;
5762 }
5763 }
5764 else
5765 if ( resinfo == 7 )
5766 temp -= 2 ;
5767 }
5768 }
5769
5770 XGINew_SetReg1( pVBInfo->Part1Port , 0x05 , temp ) ; /* 0x05 Horizontal Display Start */
5771 XGINew_SetReg1( pVBInfo->Part1Port , 0x06 , 0x03 ) ; /* 0x06 Horizontal Blank end */
5772
5773 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
5774 { /* 030226 bainy */
5775 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5776 tempax = pVBInfo->VGAHT ;
5777 else
5778 tempax = XGI_GetVGAHT2( pVBInfo) ;
5779 }
5780
5781 if ( tempax >= pVBInfo->VGAHT )
5782 {
5783 tempax = pVBInfo->VGAHT ;
5784 }
5785
5786 if ( modeflag & HalfDCLK )
5787 {
5788 tempax = tempax >> 1 ;
5789 }
5790
5791 tempax = ( tempax / tempcx ) - 5 ;
5792 tempcx = tempax ; /* 20030401 0x07 horizontal Retrace Start */
5793 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5794 {
5795 temp = ( tempbx & 0x00FF ) - 1 ;
5796 if ( !( modeflag & HalfDCLK ) )
5797 {
5798 temp -= 6 ;
5799 if ( pVBInfo->TVInfo & TVSimuMode )
5800 {
5801 temp -= 4 ;
5802 if ( ModeNo > 0x13 )
5803 temp -= 10 ;
5804 }
5805 }
5806 }
5807 else
5808 {
5809 /* tempcx = tempbx & 0x00FF ; */
5810 tempbx = ( tempbx & 0xFF00 ) >> 8 ;
5811 tempcx = ( tempcx + tempbx ) >> 1 ;
5812 temp = ( tempcx & 0x00FF ) + 2 ;
5813
5814 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5815 {
5816 temp -= 1 ;
5817 if ( !( modeflag & HalfDCLK ) )
5818 {
5819 if ( ( modeflag & Charx8Dot ) )
5820 {
5821 temp += 4 ;
5822 if ( pVBInfo->VGAHDE >= 800 )
5823 {
5824 temp -= 6 ;
5825 }
5826 }
5827 }
5828 }
5829 else
5830 {
5831 if ( !( modeflag & HalfDCLK ) )
5832 {
5833 temp -= 4 ;
5834 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5835 {
5836 if( pVBInfo->VGAHDE >= 800 )
5837 {
5838 temp -= 7 ;
5839 if ( pVBInfo->ModeType == ModeEGA )
5840 {
5841 if ( pVBInfo->VGAVDE == 1024 )
5842 {
5843 temp += 15 ;
5844 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
5845 {
5846 temp += 7 ;
5847 }
5848 }
5849 }
5850
5851 if ( pVBInfo->VGAHDE >= 1280 )
5852 {
5853 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5854 {
5855 if ( pVBInfo->LCDInfo & LCDNonExpanding )
5856 {
5857 temp += 28 ;
5858 }
5859 }
5860 }
5861 }
5862 }
5863 }
5864 }
5865 }
5866
5867 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ; /* 0x07 Horizontal Retrace Start */
5868 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0 ) ; /* 0x08 Horizontal Retrace End */
5869
5870 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5871 {
5872 if ( pVBInfo->TVInfo & TVSimuMode )
5873 {
5874 if ( ( ModeNo == 0x06 ) || ( ModeNo == 0x10 ) || ( ModeNo == 0x11 ) || ( ModeNo == 0x13 ) || ( ModeNo == 0x0F ) )
5875 {
5876 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x5b ) ;
5877 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5878 }
5879
5880 if ( ( ModeNo == 0x00 ) || ( ModeNo == 0x01 ) )
5881 {
5882 if ( pVBInfo->TVInfo & SetNTSCTV )
5883 {
5884 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5885 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x61 ) ;
5886 }
5887 else
5888 {
5889 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5890 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x41 ) ;
5891 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5892 }
5893 }
5894
5895 if ( ( ModeNo == 0x02 ) || ( ModeNo == 0x03 ) || ( ModeNo == 0x07 ) )
5896 {
5897 if ( pVBInfo->TVInfo & SetNTSCTV )
5898 {
5899 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x54 ) ;
5900 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5901 }
5902 else
5903 {
5904 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x55 ) ;
5905 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5906 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5907 }
5908 }
5909
5910 if ( ( ModeNo == 0x04 ) || ( ModeNo == 0x05 ) || ( ModeNo == 0x0D ) || ( ModeNo == 0x50 ) )
5911 {
5912 if ( pVBInfo->TVInfo & SetNTSCTV )
5913 {
5914 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x30 ) ;
5915 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5916 }
5917 else
5918 {
5919 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2f ) ;
5920 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x02 ) ;
5921 }
5922 }
5923 }
5924 }
5925
5926 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , 0x03 ) ; /* 0x18 SR0B */
5927 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0xF0 , 0x00 ) ;
5928 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , 0xFF ) ; /* 0x09 Set Max VT */
5929
5930 tempbx = pVBInfo->VGAVT ;
5931 push1 = tempbx ;
5932 tempcx = 0x121 ;
5933 tempbx = pVBInfo->VGAVDE ; /* 0x0E Virtical Display End */
5934
5935 if ( tempbx == 357 )
5936 tempbx = 350 ;
5937 if ( tempbx == 360 )
5938 tempbx =350 ;
5939 if ( tempbx == 375 )
5940 tempbx = 350 ;
5941 if ( tempbx == 405 )
5942 tempbx = 400 ;
5943 if ( tempbx == 525 )
5944 tempbx = 480 ;
5945
5946 push2 = tempbx ;
5947
5948 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
5949 {
5950 if ( pVBInfo->LCDResInfo == Panel1024x768 )
5951 {
5952 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
5953 {
5954 if ( tempbx == 350 )
5955 tempbx += 5 ;
5956 if ( tempbx == 480 )
5957 tempbx += 5 ;
5958 }
5959 }
5960 }
5961 tempbx-- ;
5962 temp = tempbx & 0x00FF ;
5963 tempbx-- ;
5964 temp = tempbx & 0x00FF ;
5965 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 ,temp ) ; /* 0x10 vertical Blank Start */
5966 tempbx = push2 ;
5967 tempbx-- ;
5968 temp = tempbx & 0x00FF ;
5969 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5970
5971 if ( tempbx & 0x0100 )
5972 {
5973 tempcx |= 0x0002 ;
5974 }
5975
5976 tempax = 0x000B ;
5977
5978 if ( modeflag & DoubleScanMode )
5979 {
5980 tempax |= 0x08000 ;
5981 }
5982
5983 if ( tempbx & 0x0200 )
5984 {
5985 tempcx |= 0x0040 ;
5986 }
5987
5988 temp = ( tempax & 0xFF00 ) >> 8 ;
5989 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5990
5991 if ( tempbx & 0x0400 )
5992 {
5993 tempcx |= 0x0600 ;
5994 }
5995
5996 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , 0x00 ) ; /* 0x11 Vertival Blank End */
5997
5998 tempax = push1 ;
5999 tempax -= tempbx ; /* 0x0C Vertical Retrace Start */
6000 tempax = tempax >> 2 ;
6001 push1 = tempax ; /* push ax */
6002
6003 if ( resinfo != 0x09 )
6004 {
6005 tempax = tempax << 1 ;
6006 tempbx += tempax ;
6007 }
6008
6009 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6010 {
6011 if ( pVBInfo->VBType & VB_XGI301LV )
6012 {
6013 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6014 tempbx -= 10 ;
6015 else
6016 {
6017 if ( pVBInfo->TVInfo & TVSimuMode )
6018 {
6019 if ( pVBInfo->TVInfo & SetPALTV )
6020 {
6021 if ( pVBInfo->VBType & VB_XGI301LV )
6022 {
6023 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
6024 tempbx += 40 ;
6025 }
6026 else
6027 tempbx += 40 ;
6028 }
6029 }
6030 }
6031 }
6032 else
6033 tempbx -= 10 ;
6034 }
6035 else
6036 {
6037 if ( pVBInfo->TVInfo & TVSimuMode )
6038 {
6039 if ( pVBInfo->TVInfo & SetPALTV )
6040 {
6041 if ( pVBInfo->VBType & VB_XGI301LV )
6042 {
6043 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
6044 tempbx += 40 ;
6045 }
6046 else
6047 tempbx += 40 ;
6048 }
6049 }
6050 }
6051 tempax = push1 ;
6052 tempax = tempax >> 2 ;
6053 tempax++ ;
6054 tempax += tempbx ;
6055 push1 = tempax ; /* push ax */
6056
6057 if ( ( pVBInfo->TVInfo & SetPALTV ) )
6058 {
6059 if ( tempbx <= 513 )
6060 {
6061 if ( tempax >= 513 )
6062 {
6063 tempbx = 513 ;
6064 }
6065 }
6066 }
6067
6068 temp = tempbx & 0x00FF ;
6069 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
6070 tempbx-- ;
6071 temp = tempbx & 0x00FF ;
6072 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
6073
6074 if ( tempbx & 0x0100 )
6075 {
6076 tempcx |= 0x0008 ;
6077 }
6078
6079 if ( tempbx & 0x0200 )
6080 {
6081 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x0B , 0x0FF , 0x20 ) ;
6082 }
6083
6084 tempbx++ ;
6085
6086 if ( tempbx & 0x0100 )
6087 {
6088 tempcx |= 0x0004 ;
6089 }
6090
6091 if ( tempbx & 0x0200 )
6092 {
6093 tempcx |= 0x0080 ;
6094 }
6095
6096 if ( tempbx & 0x0400 )
6097 {
6098 tempcx |= 0x0C00 ;
6099 }
6100
6101 tempbx = push1 ; /* pop ax */
6102 temp = tempbx & 0x00FF ;
6103 temp &= 0x0F ;
6104 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ; /* 0x0D vertical Retrace End */
6105
6106 if ( tempbx & 0x0010 )
6107 {
6108 tempcx |= 0x2000 ;
6109 }
6110
6111 temp = tempcx & 0x00FF ;
6112 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ; /* 0x0A CR07 */
6113 temp = ( tempcx & 0x0FF00 ) >> 8 ;
6114 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , temp ) ; /* 0x17 SR0A */
6115 tempax = modeflag ;
6116 temp = ( tempax & 0xFF00 ) >> 8 ;
6117
6118 temp = ( temp >> 1 ) & 0x09 ;
6119
6120 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6121 temp |= 0x01 ;
6122
6123 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , temp ) ; /* 0x16 SR01 */
6124 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , 0 ) ; /* 0x0F CR14 */
6125 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , 0 ) ; /* 0x12 CR17 */
6126
6127 if ( pVBInfo->LCDInfo & LCDRGB18Bit )
6128 temp = 0x80 ;
6129 else
6130 temp = 0x00 ;
6131
6132 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , temp ) ; /* 0x1A SR0E */
6133
6134 return ;
6135}
6136
6137
6138/* --------------------------------------------------------------------- */
6139/* Function : XGI_SetGroup2 */
6140/* Input : */
6141/* Output : */
6142/* Description : */
6143/* --------------------------------------------------------------------- */
6144void XGI_SetGroup2( USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex,
6145 PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
6146{
6147 USHORT i ,
6148 j ,
6149 tempax ,
6150 tempbx ,
6151 tempcx ,
6152 temp ,
6153 push1 ,
6154 push2 ,
6155 modeflag ,
6156 resinfo ,
6157 crt2crtc ;
6158 UCHAR *TimingPoint ;
6159
6160 ULONG longtemp ,
6161 tempeax ,
6162 tempebx ,
6163 temp2 ,
6164 tempecx ;
6165
6166 if ( ModeNo <= 0x13 )
6167 {
6168 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6169 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
6170 crt2crtc = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
6171 }
6172 else
6173 {
6174 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6175 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
6176 crt2crtc = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
6177 }
6178
6179 tempax = 0 ;
6180
6181 if ( !( pVBInfo->VBInfo & SetCRT2ToAVIDEO ) )
6182 tempax |= 0x0800 ;
6183
6184 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6185 tempax |= 0x0400 ;
6186
6187 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
6188 tempax |= 0x0200 ;
6189
6190 if ( !( pVBInfo->TVInfo & SetPALTV ) )
6191 tempax |= 0x1000 ;
6192
6193 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6194 tempax |= 0x0100 ;
6195
6196 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
6197 tempax &= 0xfe00 ;
6198
6199 tempax = ( tempax & 0xff00 ) >> 8 ;
6200
6201 XGINew_SetReg1( pVBInfo->Part2Port , 0x0 , tempax ) ;
6202 TimingPoint = pVBInfo->NTSCTiming ;
6203
6204 if ( pVBInfo->TVInfo & SetPALTV )
6205 {
6206 TimingPoint = pVBInfo->PALTiming ;
6207 }
6208
6209 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6210 {
6211 TimingPoint = pVBInfo->HiTVExtTiming ;
6212
6213 if ( pVBInfo->VBInfo & SetInSlaveMode )
6214 TimingPoint = pVBInfo->HiTVSt2Timing ;
6215
6216 if ( pVBInfo->SetFlag & TVSimuMode )
6217 TimingPoint = pVBInfo->HiTVSt1Timing ;
6218
6219 if ( !(modeflag & Charx8Dot) )
6220 TimingPoint = pVBInfo->HiTVTextTiming ;
6221 }
6222
6223 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6224 {
6225 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
6226 TimingPoint = pVBInfo->YPbPr525iTiming ;
6227
6228 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6229 TimingPoint = pVBInfo->YPbPr525pTiming ;
6230
6231 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6232 TimingPoint = pVBInfo->YPbPr750pTiming ;
6233 }
6234
6235 for( i = 0x01 , j = 0 ; i <= 0x2D ; i++ , j++ )
6236 {
6237 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
6238 }
6239
6240 for( i = 0x39 ; i <= 0x45 ; i++ , j++ )
6241 {
6242 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ; /* di->temp2[j] */
6243 }
6244
6245 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6246 {
6247 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , 0x00 ) ;
6248 }
6249
6250 temp = pVBInfo->NewFlickerMode ;
6251 temp &= 0x80 ;
6252 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xFF , temp ) ;
6253
6254 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6255 tempax = 950 ;
6256
6257 if ( pVBInfo->TVInfo & SetPALTV )
6258 tempax = 520 ;
6259 else
6260 tempax = 440 ;
6261
6262 if ( pVBInfo->VDE <= tempax )
6263 {
6264 tempax -= pVBInfo->VDE ;
6265 tempax = tempax >> 2 ;
6266 tempax = ( tempax & 0x00FF ) | ( ( tempax & 0x00FF ) << 8 ) ;
6267 push1 = tempax ;
6268 temp = ( tempax & 0xFF00 ) >> 8 ;
6269 temp += ( USHORT )TimingPoint[ 0 ] ;
6270
6271 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6272 {
6273 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) )
6274 {
6275 tempcx=pVBInfo->VGAHDE;
6276 if ( tempcx >= 1024 )
6277 {
6278 temp = 0x17 ; /* NTSC */
6279 if ( pVBInfo->TVInfo & SetPALTV )
6280 temp = 0x19 ; /* PAL */
6281 }
6282 }
6283 }
6284
6285 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6286 tempax = push1 ;
6287 temp = ( tempax & 0xFF00 ) >> 8 ;
6288 temp += TimingPoint[ 1 ] ;
6289
6290 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6291 {
6292 if ( ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) ) )
6293 {
6294 tempcx = pVBInfo->VGAHDE ;
6295 if ( tempcx >= 1024 )
6296 {
6297 temp = 0x1D ; /* NTSC */
6298 if ( pVBInfo->TVInfo & SetPALTV )
6299 temp = 0x52 ; /* PAL */
6300 }
6301 }
6302 }
6303 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , temp ) ;
6304 }
6305
6306 /* 301b */
6307 tempcx = pVBInfo->HT ;
6308
6309 if ( XGI_IsLCDDualLink( pVBInfo ) )
6310 tempcx = tempcx >> 1 ;
6311
6312 tempcx -= 2 ;
6313 temp = tempcx & 0x00FF ;
6314 XGINew_SetReg1( pVBInfo->Part2Port , 0x1B , temp ) ;
6315
6316 temp = ( tempcx & 0xFF00 ) >> 8 ;
6317 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F , temp ) ;
6318
6319 tempcx = pVBInfo->HT >> 1 ;
6320 push1 = tempcx ; /* push cx */
6321 tempcx += 7 ;
6322
6323 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6324 {
6325 tempcx -= 4 ;
6326 }
6327
6328 temp = tempcx & 0x00FF ;
6329 temp = temp << 4 ;
6330 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x22 , 0x0F , temp ) ;
6331
6332 tempbx = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6333 tempbx += tempcx ;
6334 push2 = tempbx ;
6335 temp = tempbx & 0x00FF ;
6336 XGINew_SetReg1( pVBInfo->Part2Port , 0x24 , temp ) ;
6337 temp = ( tempbx & 0xFF00 ) >> 8 ;
6338 temp = temp << 4 ;
6339 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x25,0x0F,temp);
6340
6341 tempbx=push2;
6342 tempbx=tempbx+8;
6343 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6344 {
6345 tempbx=tempbx-4;
6346 tempcx=tempbx;
6347 }
6348
6349 temp = ( tempbx & 0x00FF ) << 4 ;
6350 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x29 , 0x0F , temp ) ;
6351
6352 j += 2 ;
6353 tempcx += ( TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ) ;
6354 temp = tempcx & 0x00FF ;
6355 XGINew_SetReg1( pVBInfo->Part2Port , 0x27 , temp ) ;
6356 temp = ( ( tempcx & 0xFF00 ) >> 8 ) << 4 ;
6357 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x28 , 0x0F , temp ) ;
6358
6359 tempcx += 8 ;
6360 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6361 {
6362 tempcx -= 4 ;
6363 }
6364
6365 temp = tempcx & 0xFF ;
6366 temp = temp << 4 ;
6367 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2A , 0x0F , temp ) ;
6368
6369 tempcx = push1 ; /* pop cx */
6370 j += 2 ;
6371 temp = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6372 tempcx -= temp ;
6373 temp = tempcx & 0x00FF ;
6374 temp = temp << 4 ;
6375 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2D , 0x0F ,temp ) ;
6376
6377 tempcx -= 11 ;
6378
6379 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6380 {
6381 tempax = XGI_GetVGAHT2( pVBInfo) ;
6382 tempcx = tempax - 1 ;
6383 }
6384 temp = tempcx & 0x00FF ;
6385 XGINew_SetReg1( pVBInfo->Part2Port , 0x2E , temp ) ;
6386
6387 tempbx = pVBInfo->VDE ;
6388
6389 if ( pVBInfo->VGAVDE == 360 )
6390 tempbx = 746 ;
6391 if ( pVBInfo->VGAVDE == 375 )
6392 tempbx = 746 ;
6393 if ( pVBInfo->VGAVDE == 405 )
6394 tempbx = 853 ;
6395
6396 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6397 {
6398 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6399 {
6400 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6401 tempbx = tempbx >> 1 ;
6402 }
6403 else
6404 tempbx = tempbx >> 1 ;
6405 }
6406
6407 tempbx -= 2 ;
6408 temp = tempbx & 0x00FF ;
6409
6410 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6411 {
6412 if ( pVBInfo->VBType & VB_XGI301LV )
6413 {
6414 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6415 {
6416 if ( pVBInfo->VBInfo & SetInSlaveMode )
6417 {
6418 if ( ModeNo == 0x2f )
6419 temp += 1 ;
6420 }
6421 }
6422 }
6423 else
6424 {
6425 if ( pVBInfo->VBInfo & SetInSlaveMode )
6426 {
6427 if ( ModeNo == 0x2f )
6428 temp += 1 ;
6429 }
6430 }
6431 }
6432
6433 XGINew_SetReg1( pVBInfo->Part2Port , 0x2F , temp ) ;
6434
6435 temp = ( tempcx & 0xFF00 ) >> 8 ;
6436 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) << 6 ;
6437
6438 if ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) )
6439 {
6440 if ( pVBInfo->VBType & VB_XGI301LV )
6441 {
6442 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6443 {
6444 temp |= 0x10 ;
6445
6446 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6447 temp |= 0x20 ;
6448 }
6449 }
6450 else
6451 {
6452 temp |= 0x10 ;
6453 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6454 temp |= 0x20 ;
6455 }
6456 }
6457
6458 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , temp ) ;
6459
6460 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) /* TV gatingno */
6461 {
6462 tempbx = pVBInfo->VDE ;
6463 tempcx = tempbx - 2 ;
6464
6465 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6466 {
6467 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6468 tempbx = tempbx >> 1 ;
6469 }
6470
6471 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
6472 {
6473 temp=0;
6474 if( tempcx & 0x0400 )
6475 temp |= 0x20 ;
6476
6477 if ( tempbx & 0x0400 )
6478 temp |= 0x40 ;
6479
6480 XGINew_SetReg1( pVBInfo->Part4Port , 0x10 , temp ) ;
6481 }
6482
6483 temp = ( ( ( tempbx - 3 ) & 0x0300 ) >> 8 ) << 5 ;
6484 XGINew_SetReg1( pVBInfo->Part2Port , 0x46 , temp ) ;
6485 temp = ( tempbx - 3 ) & 0x00FF ;
6486 XGINew_SetReg1( pVBInfo->Part2Port , 0x47 , temp ) ;
6487 }
6488
6489 tempbx = tempbx & 0x00FF ;
6490
6491 if ( !( modeflag & HalfDCLK ) )
6492 {
6493 tempcx = pVBInfo->VGAHDE ;
6494 if ( tempcx >= pVBInfo->HDE )
6495 {
6496 tempbx |= 0x2000 ;
6497 tempax &= 0x00FF ;
6498 }
6499 }
6500
6501 tempcx = 0x0101 ;
6502
6503 if( pVBInfo->VBInfo & SetCRT2ToTV ) { /*301b*/
6504 if(pVBInfo->VGAHDE>=1024)
6505 {
6506 tempcx=0x1920;
6507 if(pVBInfo->VGAHDE>=1280)
6508 {
6509 tempcx=0x1420;
6510 tempbx=tempbx&0xDFFF;
6511 }
6512 }
6513 }
6514
6515 if ( !( tempbx & 0x2000 ) )
6516 {
6517 if ( modeflag & HalfDCLK )
6518 {
6519 tempcx = ( tempcx & 0xFF00 ) | ( ( tempcx & 0x00FF ) << 1 ) ;
6520 }
6521
6522 push1 = tempbx ;
6523 tempeax = pVBInfo->VGAHDE ;
6524 tempebx = ( tempcx & 0xFF00 ) >> 8 ;
6525 longtemp = tempeax * tempebx ;
6526 tempecx = tempcx & 0x00FF ;
6527 longtemp = longtemp / tempecx ;
6528
6529 /* 301b */
6530 tempecx = 8 * 1024 ;
6531
6532 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6533 {
6534 tempecx = tempecx * 8 ;
6535 }
6536
6537 longtemp = longtemp * tempecx ;
6538 tempecx = pVBInfo->HDE ;
6539 temp2 = longtemp % tempecx ;
6540 tempeax = longtemp / tempecx ;
6541 if ( temp2 != 0 )
6542 {
6543 tempeax += 1 ;
6544 }
6545
6546 tempax = ( USHORT )tempeax ;
6547
6548 /* 301b */
6549 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6550 {
6551 tempcx = ( ( tempax & 0xFF00 ) >> 5 ) >> 8 ;
6552 }
6553 /* end 301b */
6554
6555 tempbx = push1 ;
6556 tempbx =( USHORT )( ( ( tempeax & 0x0000FF00 ) & 0x1F00 ) | ( tempbx & 0x00FF ) ) ;
6557 tempax =( USHORT )( ( ( tempeax & 0x000000FF ) << 8 ) | ( tempax & 0x00FF ) ) ;
6558 temp = ( tempax & 0xFF00 ) >> 8 ;
6559 }
6560 else
6561 {
6562 temp = ( tempax & 0x00FF ) >> 8 ;
6563 }
6564
6565 XGINew_SetReg1( pVBInfo->Part2Port , 0x44 , temp ) ;
6566 temp = ( tempbx & 0xFF00 ) >> 8 ;
6567 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x45 , ~0x03F , temp ) ;
6568 temp = tempcx & 0x00FF ;
6569
6570 if ( tempbx & 0x2000 )
6571 temp = 0 ;
6572
6573 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6574 temp |= 0x18 ;
6575
6576 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x46,~0x1F,temp);
6577 if ( pVBInfo->TVInfo & SetPALTV )
6578 {
6579 tempbx = 0x0382 ;
6580 tempcx = 0x007e ;
6581 }
6582 else
6583 {
6584 tempbx = 0x0369 ;
6585 tempcx = 0x0061 ;
6586 }
6587
6588 temp = tempbx & 0x00FF ;
6589 XGINew_SetReg1( pVBInfo->Part2Port , 0x4b , temp ) ;
6590 temp = tempcx & 0x00FF ;
6591 XGINew_SetReg1( pVBInfo->Part2Port , 0x4c , temp ) ;
6592
6593 temp = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x03 ;
6594 temp = temp << 2 ;
6595 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) & 0x03 ;
6596
6597 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6598 {
6599 temp |= 0x10 ;
6600
6601 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6602 temp |= 0x20 ;
6603
6604 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6605 temp |= 0x60 ;
6606 }
6607
6608 XGINew_SetReg1( pVBInfo->Part2Port , 0x4d , temp ) ;
6609 temp=XGINew_GetReg1( pVBInfo->Part2Port , 0x43 ) ; /* 301b change */
6610 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , ( USHORT )( temp - 3 ) ) ;
6611
6612 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6613 {
6614 if ( pVBInfo->TVInfo & NTSC1024x768 )
6615 {
6616 TimingPoint = XGI_NTSC1024AdjTime ;
6617 for( i = 0x1c , j = 0 ; i <= 0x30 ; i++ , j++ )
6618 {
6619 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
6620 }
6621 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , 0x72 ) ;
6622 }
6623 }
6624
6625 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
6626 if ( pVBInfo->VBType & VB_XGI301C )
6627 {
6628 if ( pVBInfo->TVInfo & SetPALMTV )
6629 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x08 , 0x08 ) ; /* PALM Mode */
6630 }
6631
6632 if ( pVBInfo->TVInfo & SetPALMTV )
6633 {
6634 tempax = ( UCHAR )XGINew_GetReg1( pVBInfo->Part2Port , 0x01 ) ;
6635 tempax-- ;
6636 XGINew_SetRegAND( pVBInfo->Part2Port , 0x01 , tempax ) ;
6637
6638 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
6639 XGINew_SetRegAND( pVBInfo->Part2Port , 0x00 , 0xEF ) ;
6640 }
6641
6642 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6643 {
6644 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
6645 {
6646 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , 0x00 ) ;
6647 }
6648 }
6649
6650 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6651 {
6652 return ;
6653 }
6654}
6655
6656
6657/* --------------------------------------------------------------------- */
6658/* Function : XGI_SetLCDRegs */
6659/* Input : */
6660/* Output : */
6661/* Description : */
6662/* --------------------------------------------------------------------- */
6663void XGI_SetLCDRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
6664{
6665 USHORT push1 ,
6666 push2 ,
6667 pushbx ,
6668 tempax ,
6669 tempbx ,
6670 tempcx ,
6671 temp ,
6672 tempah ,
6673 tempbh ,
6674 tempch ,
6675 resinfo ,
6676 modeflag ,
6677 CRT1Index ;
6678
6679 XGI_LCDDesStruct *LCDBDesPtr = NULL ;
6680
6681
6682 if ( ModeNo <= 0x13 )
6683 {
6684 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6685 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
6686 }
6687 else
6688 {
6689 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6690 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
6691 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
6692 CRT1Index &= IndexMask ;
6693 }
6694
6695 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6696 {
6697 return ;
6698 }
6699
6700 tempbx = pVBInfo->HDE ; /* RHACTE=HDE-1 */
6701
6702 if ( XGI_IsLCDDualLink( pVBInfo ) )
6703 tempbx = tempbx >> 1 ;
6704
6705 tempbx -= 1 ;
6706 temp = tempbx & 0x00FF ;
6707 XGINew_SetReg1( pVBInfo->Part2Port , 0x2C , temp ) ;
6708 temp = ( tempbx & 0xFF00 ) >> 8 ;
6709 temp = temp << 4 ;
6710 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2B , 0x0F , temp ) ;
6711 temp = 0x01 ;
6712
6713 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
6714 {
6715 if ( pVBInfo->ModeType == ModeEGA )
6716 {
6717 if ( pVBInfo->VGAHDE >= 1024 )
6718 {
6719 temp = 0x02 ;
6720 if ( pVBInfo->LCDInfo & LCDVESATiming )
6721 temp = 0x01 ;
6722 }
6723 }
6724 }
6725
6726 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , temp ) ;
6727 tempbx = pVBInfo->VDE ; /* RTVACTEO=(VDE-1)&0xFF */
6728 push1 = tempbx ;
6729 tempbx-- ;
6730 temp = tempbx & 0x00FF ;
6731 XGINew_SetReg1( pVBInfo->Part2Port , 0x03 , temp ) ;
6732 temp = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6733 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0C , ~0x07 , temp ) ;
6734
6735 tempcx = pVBInfo->VT - 1 ;
6736 push2 = tempcx + 1 ;
6737 temp = tempcx & 0x00FF ; /* RVTVT=VT-1 */
6738 XGINew_SetReg1( pVBInfo->Part2Port , 0x19 , temp ) ;
6739 temp = ( tempcx & 0xFF00 ) >> 8 ;
6740 temp = temp << 5 ;
6741 XGINew_SetReg1( pVBInfo->Part2Port , 0x1A , temp ) ;
6742 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x09 , 0xF0 , 0x00 ) ;
6743 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xF0 , 0x00 ) ;
6744 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x17 , 0xFB , 0x00 ) ;
6745 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x18 , 0xDF , 0x00 ) ;
6746
6747 /* Customized LCDB Des no add */
6748 tempbx = 5 ;
6749 LCDBDesPtr = ( XGI_LCDDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
6750 tempah = pVBInfo->LCDResInfo ;
6751 tempah &= PanelResInfo ;
6752
6753 if ( ( tempah == Panel1024x768 ) || ( tempah == Panel1024x768x75 ) )
6754 {
6755 tempbx = 1024 ;
6756 tempcx = 768 ;
6757 }
6758 else if ( ( tempah == Panel1280x1024 ) || ( tempah == Panel1280x1024x75 ) )
6759 {
6760 tempbx = 1280 ;
6761 tempcx = 1024 ;
6762 }
6763 else if ( tempah == Panel1400x1050 )
6764 {
6765 tempbx = 1400 ;
6766 tempcx = 1050 ;
6767 }
6768 else
6769 {
6770 tempbx = 1600 ;
6771 tempcx = 1200 ;
6772 }
6773
6774 if ( pVBInfo->LCDInfo & EnableScalingLCD )
6775 {
6776 tempbx = pVBInfo->HDE ;
6777 tempcx = pVBInfo->VDE ;
6778 }
6779
6780 pushbx = tempbx ;
6781 tempax = pVBInfo->VT ;
6782 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES ;
6783 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS ;
6784 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES ;
6785 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS ;
6786 tempbx = pVBInfo->LCDVDES ;
6787 tempcx += tempbx ;
6788
6789 if ( tempcx >= tempax )
6790 tempcx -= tempax ; /* lcdvdes */
6791
6792 temp = tempbx & 0x00FF ; /* RVEQ1EQ=lcdvdes */
6793 XGINew_SetReg1( pVBInfo->Part2Port , 0x05 , temp ) ;
6794 temp = tempcx & 0x00FF ;
6795 XGINew_SetReg1( pVBInfo->Part2Port , 0x06 , temp ) ;
6796 tempch = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x07 ;
6797 tempbh = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6798 tempah = tempch ;
6799 tempah = tempah << 3 ;
6800 tempah |= tempbh ;
6801 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , tempah ) ;
6802
6803 /* getlcdsync() */
6804 XGI_GetLCDSync( &tempax , &tempbx,pVBInfo ) ;
6805 tempcx = tempbx ;
6806 tempax = pVBInfo->VT ;
6807 tempbx = pVBInfo->LCDVRS ;
6808
6809 /* if ( SetLCD_Info & EnableScalingLCD ) */
6810 tempcx += tempbx ;
6811 if ( tempcx >= tempax )
6812 tempcx -= tempax ;
6813
6814 temp = tempbx & 0x00FF ; /* RTVACTEE=lcdvrs */
6815 XGINew_SetReg1( pVBInfo->Part2Port , 0x04 , temp ) ;
6816 temp = ( tempbx & 0xFF00 ) >> 8 ;
6817 temp = temp << 4 ;
6818 temp |= ( tempcx & 0x000F ) ;
6819 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6820 tempcx = pushbx ;
6821 tempax = pVBInfo->HT ;
6822 tempbx = pVBInfo->LCDHDES ;
6823 tempbx &= 0x0FFF ;
6824
6825 if ( XGI_IsLCDDualLink( pVBInfo ) )
6826 {
6827 tempax = tempax >> 1 ;
6828 tempbx = tempbx >> 1 ;
6829 tempcx = tempcx >> 1 ;
6830 }
6831
6832 if ( pVBInfo->VBType & VB_XGI302LV )
6833 tempbx += 1 ;
6834
6835 if ( pVBInfo->VBType & VB_XGI301C ) /* tap4 */
6836 tempbx += 1 ;
6837
6838 tempcx += tempbx ;
6839
6840 if ( tempcx >= tempax )
6841 tempcx -= tempax ;
6842
6843 temp = tempbx & 0x00FF ;
6844 XGINew_SetReg1( pVBInfo->Part2Port , 0x1F , temp ) ; /* RHBLKE=lcdhdes */
6845 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
6846 XGINew_SetReg1( pVBInfo->Part2Port , 0x20 , temp ) ;
6847 temp = tempcx & 0x00FF ;
6848 XGINew_SetReg1( pVBInfo->Part2Port , 0x23 , temp ) ; /* RHEQPLE=lcdhdee */
6849 temp = ( tempcx & 0xFF00 ) >> 8 ;
6850 XGINew_SetReg1( pVBInfo->Part2Port , 0x25 , temp ) ;
6851
6852 /* getlcdsync() */
6853 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
6854 tempcx = tempax ;
6855 tempax = pVBInfo->HT ;
6856 tempbx = pVBInfo->LCDHRS ;
6857 /* if ( SetLCD_Info & EnableScalingLCD) */
6858 if ( XGI_IsLCDDualLink( pVBInfo) )
6859 {
6860 tempax = tempax >> 1 ;
6861 tempbx = tempbx >> 1 ;
6862 tempcx = tempcx >> 1 ;
6863 }
6864
6865 if ( pVBInfo->VBType & VB_XGI302LV )
6866 tempbx += 1 ;
6867
6868 tempcx += tempbx ;
6869
6870 if ( tempcx >= tempax )
6871 tempcx -= tempax ;
6872
6873 temp = tempbx & 0x00FF ; /* RHBURSTS=lcdhrs */
6874 XGINew_SetReg1( pVBInfo->Part2Port , 0x1C , temp ) ;
6875
6876 temp = ( tempbx & 0xFF00 ) >> 8 ;
6877 temp = temp << 4 ;
6878 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F0 , temp ) ;
6879 temp = tempcx & 0x00FF ; /* RHSYEXP2S=lcdhre */
6880 XGINew_SetReg1( pVBInfo->Part2Port , 0x21 , temp ) ;
6881
6882 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
6883 {
6884 if ( pVBInfo->VGAVDE == 525 )
6885 {
6886 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6887 {
6888 temp = 0xC6 ;
6889 }
6890 else
6891 temp = 0xC4 ;
6892
6893 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6894 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , 0xB3 ) ;
6895 }
6896
6897 if ( pVBInfo->VGAVDE == 420 )
6898 {
6899 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6900 {
6901 temp = 0x4F ;
6902 }
6903 else
6904 temp = 0x4E ;
6905 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6906 }
6907 }
6908}
6909
6910
6911/* --------------------------------------------------------------------- */
6912/* Function : XGI_GetTap4Ptr */
6913/* Input : */
6914/* Output : di -> Tap4 Reg. Setting Pointer */
6915/* Description : */
6916/* --------------------------------------------------------------------- */
6917XGI301C_Tap4TimingStruct* XGI_GetTap4Ptr(USHORT tempcx, PVB_DEVICE_INFO pVBInfo)
6918{
6919 USHORT tempax ,
6920 tempbx ,
6921 i ;
6922
6923 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6924
6925 if ( tempcx == 0 )
6926 {
6927 tempax = pVBInfo->VGAHDE ;
6928 tempbx = pVBInfo->HDE ;
6929 }
6930 else
6931 {
6932 tempax = pVBInfo->VGAVDE ;
6933 tempbx = pVBInfo->VDE ;
6934 }
6935
6936 if ( tempax < tempbx )
6937 return &EnlargeTap4Timing[ 0 ] ;
6938 else if( tempax == tempbx )
6939 return &NoScaleTap4Timing[ 0 ] ; /* 1:1 */
6940 else
6941 Tap4TimingPtr = NTSCTap4Timing ; /* NTSC */
6942
6943 if ( pVBInfo->TVInfo & SetPALTV )
6944 Tap4TimingPtr = PALTap4Timing ;
6945
6946
6947 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6948 {
6949 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
6950 Tap4TimingPtr = YPbPr525iTap4Timing ;
6951 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6952 Tap4TimingPtr = YPbPr525pTap4Timing ;
6953 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6954 Tap4TimingPtr = YPbPr750pTap4Timing ;
6955 }
6956
6957 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6958 Tap4TimingPtr = HiTVTap4Timing ;
6959
6960 i = 0 ;
6961 while( Tap4TimingPtr[ i ].DE != 0xFFFF )
6962 {
6963 if ( Tap4TimingPtr[ i ].DE == tempax )
6964 break ;
6965 i++ ;
6966 }
6967 return &Tap4TimingPtr[ i ] ;
6968}
6969
6970
6971/* --------------------------------------------------------------------- */
6972/* Function : XGI_SetTap4Regs */
6973/* Input : */
6974/* Output : */
6975/* Description : */
6976/* --------------------------------------------------------------------- */
6977void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo)
6978{
6979 USHORT i ,
6980 j ;
6981
6982 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6983
6984 if ( !( pVBInfo->VBType & VB_XGI301C ) )
6985 return ;
6986
6987#ifndef Tap4
6988 XGINew_SetRegAND( pVBInfo->Part2Port , 0x4E , 0xEB ) ; /* Disable Tap4 */
6989#else /* Tap4 Setting */
6990
6991 Tap4TimingPtr = XGI_GetTap4Ptr( 0 , pVBInfo) ; /* Set Horizontal Scaling */
6992 for( i = 0x80 , j = 0 ; i <= 0xBF ; i++ , j++ )
6993 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6994
6995 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6996 {
6997 Tap4TimingPtr = XGI_GetTap4Ptr( 1 , pVBInfo); /* Set Vertical Scaling */
6998 for( i = 0xC0 , j = 0 ; i < 0xFF ; i++ , j++ )
6999 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
7000 }
7001
7002 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
7003 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x04 ) ; /* Enable V.Scaling */
7004 else
7005 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x10 ) ; /* Enable H.Scaling */
7006#endif
7007}
7008
7009/* --------------------------------------------------------------------- */
7010/* Function : XGI_SetGroup3 */
7011/* Input : */
7012/* Output : */
7013/* Description : */
7014/* --------------------------------------------------------------------- */
7015void XGI_SetGroup3(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
7016{
7017 USHORT i;
7018 UCHAR *tempdi;
7019 USHORT modeflag;
7020
7021 if(ModeNo<=0x13)
7022 {
7023 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
7024 }
7025 else
7026 {
7027 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
7028 }
7029
7030
7031 XGINew_SetReg1(pVBInfo->Part3Port,0x00,0x00);
7032 if(pVBInfo->TVInfo&SetPALTV)
7033 {
7034 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
7035 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
7036 }
7037 else
7038 {
7039 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xF5);
7040 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xB7);
7041 }
7042
7043 if(!(pVBInfo->VBInfo&SetCRT2ToTV))
7044 {
7045 return;
7046 }
7047
7048 if(pVBInfo->TVInfo&SetPALMTV)
7049 {
7050 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
7051 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
7052 XGINew_SetReg1(pVBInfo->Part3Port,0x3D,0xA8);
7053 }
7054
7055 if((pVBInfo->VBInfo&SetCRT2ToHiVisionTV)|| (pVBInfo->VBInfo&SetCRT2ToYPbPr))
7056 {
7057 if(pVBInfo->TVInfo & SetYPbPrMode525i)
7058 {
7059 return;
7060 }
7061 tempdi=pVBInfo->HiTVGroup3Data;
7062 if(pVBInfo->SetFlag&TVSimuMode)
7063 {
7064 tempdi=pVBInfo->HiTVGroup3Simu;
7065 if(!(modeflag&Charx8Dot))
7066 {
7067 tempdi=pVBInfo->HiTVGroup3Text;
7068 }
7069 }
7070
7071 if(pVBInfo->TVInfo & SetYPbPrMode525p)
7072 {
7073 tempdi=pVBInfo->Ren525pGroup3;
7074 }
7075 if(pVBInfo->TVInfo & SetYPbPrMode750p)
7076 {
7077 tempdi=pVBInfo->Ren750pGroup3;
7078 }
7079
7080 for(i=0;i<=0x3E;i++)
7081 {
7082 XGINew_SetReg1(pVBInfo->Part3Port,i,tempdi[i]);
7083 }
7084 if(pVBInfo->VBType&VB_XGI301C) /* Marcovision */
7085 {
7086 if(pVBInfo->TVInfo & SetYPbPrMode525p)
7087 {
7088 XGINew_SetReg1(pVBInfo->Part3Port,0x28,0x3f);
7089 }
7090 }
7091 }
7092 return;
7093} /* {end of XGI_SetGroup3} */
7094
7095
7096/* --------------------------------------------------------------------- */
7097/* Function : XGI_SetGroup4 */
7098/* Input : */
7099/* Output : */
7100/* Description : */
7101/* --------------------------------------------------------------------- */
7102void XGI_SetGroup4(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
7103{
7104 USHORT tempax ,
7105 tempcx ,
7106 tempbx ,
7107 modeflag ,
7108 temp ,
7109 temp2 ;
7110
7111 ULONG tempebx ,
7112 tempeax ,
7113 templong ;
7114
7115
7116 if ( ModeNo <= 0x13 )
7117 {
7118 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
7119 }
7120 else
7121 {
7122 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
7123 }
7124
7125 temp = pVBInfo->RVBHCFACT ;
7126 XGINew_SetReg1( pVBInfo->Part4Port , 0x13 , temp ) ;
7127
7128 tempbx = pVBInfo->RVBHCMAX ;
7129 temp = tempbx & 0x00FF ;
7130 XGINew_SetReg1( pVBInfo->Part4Port , 0x14 , temp ) ;
7131 temp2 = ( ( tempbx & 0xFF00 ) >> 8 ) << 7 ;
7132 tempcx = pVBInfo->VGAHT - 1 ;
7133 temp = tempcx & 0x00FF ;
7134 XGINew_SetReg1( pVBInfo->Part4Port , 0x16 , temp ) ;
7135
7136 temp =( ( tempcx & 0xFF00 ) >> 8 ) << 3 ;
7137 temp2 |= temp ;
7138
7139 tempcx = pVBInfo->VGAVT - 1 ;
7140 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
7141 {
7142 tempcx -= 5 ;
7143 }
7144
7145 temp = tempcx & 0x00FF ;
7146 XGINew_SetReg1( pVBInfo->Part4Port , 0x17 , temp ) ;
7147 temp = temp2 | ( ( tempcx & 0xFF00 ) >> 8 ) ;
7148 XGINew_SetReg1( pVBInfo->Part4Port , 0x15 , temp ) ;
7149 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0D , 0x08 ) ;
7150 tempcx = pVBInfo->VBInfo ;
7151 tempbx = pVBInfo->VGAHDE ;
7152
7153 if ( modeflag & HalfDCLK )
7154 {
7155 tempbx = tempbx >> 1 ;
7156 }
7157
7158 if ( XGI_IsLCDDualLink( pVBInfo ) )
7159 tempbx = tempbx >> 1 ;
7160
7161 if(tempcx&SetCRT2ToHiVisionTV)
7162 {
7163 temp=0;
7164 if(tempbx<=1024)
7165 temp=0xA0;
7166 if(tempbx == 1280)
7167 temp = 0xC0;
7168 }
7169 else if(tempcx&SetCRT2ToTV)
7170 {
7171 temp=0xA0;
7172 if(tempbx <= 800)
7173 temp=0x80;
7174 }
7175 else
7176 {
7177 temp=0x80;
7178 if(pVBInfo->VBInfo&SetCRT2ToLCD)
7179 {
7180 temp=0;
7181 if(tempbx>800)
7182 temp=0x60;
7183 }
7184 }
7185
7186 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
7187 {
7188 temp = 0x00 ;
7189 if ( pVBInfo->VGAHDE == 1280 )
7190 temp = 0x40 ;
7191 if ( pVBInfo->VGAHDE == 1024 )
7192 temp = 0x20 ;
7193 }
7194 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0E , ~0xEF , temp ) ;
7195
7196 tempebx = pVBInfo->VDE ;
7197
7198 if ( tempcx & SetCRT2ToHiVisionTV )
7199 {
7200 if ( !( temp & 0xE000 ) )
7201 tempbx = tempbx >> 1 ;
7202 }
7203
7204 tempcx = pVBInfo->RVBHRS ;
7205 temp = tempcx & 0x00FF ;
7206 XGINew_SetReg1( pVBInfo->Part4Port , 0x18 , temp );
7207
7208 tempeax = pVBInfo->VGAVDE ;
7209 tempcx |= 0x04000 ;
7210
7211
7212 if ( tempeax <= tempebx )
7213 {
7214 tempcx=(tempcx&(~0x4000));
7215 tempeax = pVBInfo->VGAVDE ;
7216 }
7217 else
7218 {
7219 tempeax -= tempebx ;
7220 }
7221
7222
7223 templong = ( tempeax * 256 * 1024 ) % tempebx ;
7224 tempeax = ( tempeax * 256 * 1024 ) / tempebx ;
7225 tempebx = tempeax ;
7226
7227 if ( templong != 0 )
7228 {
7229 tempebx++ ;
7230 }
7231
7232
7233 temp = ( USHORT )( tempebx & 0x000000FF ) ;
7234 XGINew_SetReg1( pVBInfo->Part4Port , 0x1B , temp ) ;
7235
7236 temp = ( USHORT )( ( tempebx & 0x0000FF00 ) >> 8 ) ;
7237 XGINew_SetReg1( pVBInfo->Part4Port , 0x1A , temp ) ;
7238 tempbx = ( USHORT )( tempebx >> 16 ) ;
7239 temp = tempbx & 0x00FF ;
7240 temp = temp << 4 ;
7241 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
7242 XGINew_SetReg1( pVBInfo->Part4Port , 0x19 , temp ) ;
7243
7244 /* 301b */
7245 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
7246 {
7247 temp = 0x0028 ;
7248 XGINew_SetReg1( pVBInfo->Part4Port , 0x1C , temp ) ;
7249 tempax = pVBInfo->VGAHDE ;
7250 if ( modeflag & HalfDCLK )
7251 {
7252 tempax = tempax >> 1 ;
7253 }
7254
7255 if ( XGI_IsLCDDualLink( pVBInfo ) )
7256 tempax = tempax >> 1 ;
7257
7258 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
7259 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
7260 {
7261 if ( tempax > 800 )
7262 tempax -= 800 ;
7263 }
7264 else
7265 {
7266 if ( pVBInfo->VGAHDE > 800 )
7267 {
7268 if ( pVBInfo->VGAHDE == 1024 )
7269 tempax = ( tempax * 25 / 32 ) - 1 ;
7270 else
7271 tempax = ( tempax * 20 / 32 ) - 1 ;
7272 }
7273 }
7274 tempax -= 1 ;
7275
7276/*
7277 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7278 {
7279 if ( pVBInfo->VBType & VB_XGI301LV )
7280 {
7281 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7282 {
7283 if ( pVBInfo->VGAHDE > 800 )
7284 {
7285 if ( pVBInfo->VGAHDE == 1024 )
7286 tempax = ( tempax * 25 / 32 ) - 1 ;
7287 else
7288 tempax = ( tempax * 20 / 32 ) - 1 ;
7289 }
7290 }
7291 }
7292 else
7293 {
7294 if ( pVBInfo->VGAHDE > 800 )
7295 {
7296 if ( pVBInfo->VGAHDE == 1024 )
7297 tempax = ( tempax * 25 / 32 ) - 1 ;
7298 else
7299 tempax = ( tempax * 20 / 32 ) - 1 ;
7300 }
7301 }
7302 }
7303*/
7304
7305 temp = ( tempax & 0xFF00 ) >> 8 ;
7306 temp = ( ( temp & 0x0003 ) << 4 ) ;
7307 XGINew_SetReg1( pVBInfo->Part4Port , 0x1E , temp ) ;
7308 temp = ( tempax & 0x00FF ) ;
7309 XGINew_SetReg1( pVBInfo->Part4Port , 0x1D , temp ) ;
7310
7311 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7312 {
7313 if ( pVBInfo->VGAHDE > 800 )
7314 {
7315 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1E , 0x08 ) ;
7316 }
7317 }
7318 temp = 0x0036 ;
7319
7320 if ( pVBInfo->VBInfo & SetCRT2ToTV )
7321 {
7322 if ( !( pVBInfo->TVInfo & ( NTSC1024x768 | SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7323 {
7324 temp |= 0x0001 ;
7325 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->TVInfo & TVSimuMode ) ) )
7326 temp &= ( ~0x0001 ) ;
7327 }
7328 }
7329
7330 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x1F , 0x00C0 , temp ) ;
7331 tempbx = pVBInfo->HT ;
7332 if ( XGI_IsLCDDualLink( pVBInfo ) )
7333 tempbx = tempbx >> 1 ;
7334 tempbx = ( tempbx >> 1 ) - 2 ;
7335 temp = ( ( tempbx & 0x0700 ) >> 8 ) << 3 ;
7336 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , 0x00C0 , temp ) ;
7337 temp = tempbx & 0x00FF ;
7338 XGINew_SetReg1( pVBInfo->Part4Port , 0x22 , temp ) ;
7339 }
7340 /* end 301b */
7341
7342 if ( pVBInfo->ISXPDOS == 0 )
7343 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
7344}
7345
7346
7347/* --------------------------------------------------------------------- */
7348/* Function : XGI_SetGroup5 */
7349/* Input : */
7350/* Output : */
7351/* Description : */
7352/* --------------------------------------------------------------------- */
7353void XGI_SetGroup5( USHORT ModeNo , USHORT ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
7354{
7355 USHORT Pindex ,
7356 Pdata ;
7357
7358 Pindex = pVBInfo->Part5Port ;
7359 Pdata = pVBInfo->Part5Port + 1 ;
7360 if ( pVBInfo->ModeType == ModeVGA )
7361 {
7362 if ( !( pVBInfo->VBInfo & ( SetInSlaveMode | LoadDACFlag | CRT2DisplayFlag ) ) )
7363 {
7364 XGINew_EnableCRT2(pVBInfo) ;
7365 /* LoadDAC2(pVBInfo->Part5Port,ModeNo,ModeIdIndex); */
7366 }
7367 }
7368 return ;
7369}
7370
7371
7372/* --------------------------------------------------------------------- */
7373/* Function : XGI_GetLcdPtr */
7374/* Input : */
7375/* Output : */
7376/* Description : */
7377/* --------------------------------------------------------------------- */
7378void* XGI_GetLcdPtr( USHORT BX , USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
7379{
7380 USHORT i ,
7381 tempdx ,
7382 tempcx ,
7383 tempbx ,
7384 tempal ,
7385 modeflag ,
7386 table ;
7387
7388 XGI330_LCDDataTablStruct *tempdi = 0 ;
7389
7390
7391 tempbx = BX;
7392
7393 if ( ModeNo <= 0x13 )
7394 {
7395 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7396 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7397 }
7398 else
7399 {
7400 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7401 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7402 }
7403
7404 tempal = tempal & 0x0f ;
7405
7406 if ( tempbx <= 1 ) /* ExpLink */
7407 {
7408 if ( ModeNo <= 0x13 )
7409 {
7410 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ; /* find no Ext_CRT2CRTC2 */
7411 }
7412 else
7413 {
7414 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7415 }
7416
7417 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
7418 {
7419 if ( ModeNo <= 0x13 )
7420 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC2 ;
7421 else
7422 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC2 ;
7423 }
7424
7425 if ( tempbx & 0x01 )
7426 tempal = ( tempal >> 4 ) ;
7427
7428 tempal = ( tempal & 0x0f ) ;
7429 }
7430
7431 tempcx = LCDLenList[ tempbx ] ; /* mov cl,byte ptr cs:LCDLenList[bx] */
7432
7433 if ( pVBInfo->LCDInfo & EnableScalingLCD ) /* ScaleLCD */
7434 {
7435 if ( ( tempbx == 5 ) || ( tempbx ) == 7 )
7436 tempcx = LCDDesDataLen2 ;
7437 else if ( ( tempbx == 3 ) || ( tempbx == 8 ) )
7438 tempcx = LVDSDesDataLen2 ;
7439 }
7440 /* mov di, word ptr cs:LCDDataList[bx] */
7441 /* tempdi=pVideoMemory[LCDDataList+tempbx*2]|(pVideoMemory[LCDDataList+tempbx*2+1]<<8); */
7442
7443 switch( tempbx )
7444 {
7445 case 0:
7446 tempdi = XGI_EPLLCDCRT1Ptr_H ;
7447 break ;
7448 case 1:
7449 tempdi = XGI_EPLLCDCRT1Ptr_V ;
7450 break ;
7451 case 2:
7452 tempdi = XGI_EPLLCDDataPtr ;
7453 break ;
7454 case 3:
7455 tempdi = XGI_EPLLCDDesDataPtr ;
7456 break ;
7457 case 4:
7458 tempdi = XGI_LCDDataTable ;
7459 break ;
7460 case 5:
7461 tempdi = XGI_LCDDesDataTable ;
7462 break ;
7463 case 6:
7464 tempdi = XGI_EPLCHLCDRegPtr ;
7465 break ;
7466 case 7:
7467 case 8:
7468 case 9:
7469 tempdi = 0 ;
7470 break ;
7471 default:
7472 break ;
7473 }
7474
7475 if ( tempdi == 0x00 ) /* OEMUtil */
7476 return 0 ;
7477
7478 table = tempbx ;
7479 i = 0 ;
7480
7481 while( tempdi[ i ].PANELID != 0xff )
7482 {
7483 tempdx = pVBInfo->LCDResInfo ;
7484 if ( tempbx & 0x0080 ) /* OEMUtil */
7485 {
7486 tempbx &= ( ~0x0080 ) ;
7487 tempdx = pVBInfo->LCDTypeInfo ;
7488 }
7489
7490 if ( pVBInfo->LCDInfo & EnableScalingLCD )
7491 tempdx &= ( ~PanelResInfo ) ;
7492
7493 if ( tempdi[ i ].PANELID == tempdx )
7494 {
7495 tempbx = tempdi[ i ].MASK ;
7496 tempdx = pVBInfo->LCDInfo ;
7497
7498 if ( ModeNo <= 0x13 ) /* alan 09/10/2003 */
7499 tempdx |= SetLCDStdMode ;
7500
7501 if ( modeflag & HalfDCLK )
7502 tempdx |= SetLCDLowResolution ;
7503
7504 tempbx &= tempdx;
7505 if ( tempbx == tempdi[ i ].CAP )
7506 break ;
7507 }
7508 i++ ;
7509 }
7510
7511 if ( table == 0 )
7512 {
7513 switch( tempdi[ i ].DATAPTR )
7514 {
7515 case 0:
7516 return &XGI_LVDSCRT11024x768_1_H[ tempal ] ;
7517 break ;
7518 case 1:
7519 return &XGI_LVDSCRT11024x768_2_H[ tempal ] ;
7520 break ;
7521 case 2:
7522 return &XGI_LVDSCRT11280x1024_1_H[ tempal ] ;
7523 break ;
7524 case 3:
7525 return &XGI_LVDSCRT11280x1024_2_H[ tempal ] ;
7526 break ;
7527 case 4:
7528 return &XGI_LVDSCRT11400x1050_1_H[ tempal ] ;
7529 break ;
7530 case 5:
7531 return &XGI_LVDSCRT11400x1050_2_H[ tempal ] ;
7532 break ;
7533 case 6:
7534 return &XGI_LVDSCRT11600x1200_1_H[ tempal ] ;
7535 break ;
7536 case 7:
7537 return &XGI_LVDSCRT11024x768_1_Hx75[ tempal ] ;
7538 break ;
7539 case 8:
7540 return &XGI_LVDSCRT11024x768_2_Hx75[ tempal ] ;
7541 break ;
7542 case 9:
7543 return &XGI_LVDSCRT11280x1024_1_Hx75[ tempal ] ;
7544 break ;
7545 case 10:
7546 return &XGI_LVDSCRT11280x1024_2_Hx75[ tempal ] ;
7547 break ;
7548 default:
7549 break ;
7550 }
7551 }
7552 else if ( table == 1 )
7553 {
7554 switch( tempdi[ i ].DATAPTR )
7555 {
7556 case 0:
7557 return &XGI_LVDSCRT11024x768_1_V[ tempal ] ;
7558 break ;
7559 case 1:
7560 return &XGI_LVDSCRT11024x768_2_V[ tempal ] ;
7561 break ;
7562 case 2:
7563 return &XGI_LVDSCRT11280x1024_1_V[ tempal ] ;
7564 break ;
7565 case 3:
7566 return &XGI_LVDSCRT11280x1024_2_V[ tempal ] ;
7567 break ;
7568 case 4:
7569 return &XGI_LVDSCRT11400x1050_1_V[ tempal ] ;
7570 break ;
7571 case 5:
7572 return &XGI_LVDSCRT11400x1050_2_V[ tempal ] ;
7573 break ;
7574 case 6:
7575 return &XGI_LVDSCRT11600x1200_1_V[ tempal ] ;
7576 break ;
7577 case 7:
7578 return &XGI_LVDSCRT11024x768_1_Vx75[ tempal ] ;
7579 break ;
7580 case 8:
7581 return &XGI_LVDSCRT11024x768_2_Vx75[ tempal ] ;
7582 break ;
7583 case 9:
7584 return &XGI_LVDSCRT11280x1024_1_Vx75[ tempal ] ;
7585 break ;
7586 case 10:
7587 return &XGI_LVDSCRT11280x1024_2_Vx75[ tempal ] ;
7588 break ;
7589 default:
7590 break ;
7591 }
7592 }
7593 else if ( table == 2 )
7594 {
7595 switch( tempdi[ i ].DATAPTR )
7596 {
7597 case 0:
7598 return &XGI_LVDS1024x768Data_1[ tempal ] ;
7599 break ;
7600 case 1:
7601 return &XGI_LVDS1024x768Data_2[ tempal ] ;
7602 break ;
7603 case 2:
7604 return &XGI_LVDS1280x1024Data_1[ tempal ] ;
7605 break ;
7606 case 3:
7607 return &XGI_LVDS1280x1024Data_2[ tempal ] ;
7608 break ;
7609 case 4:
7610 return &XGI_LVDS1400x1050Data_1[ tempal ] ;
7611 break ;
7612 case 5:
7613 return &XGI_LVDS1400x1050Data_2[ tempal ] ;
7614 break ;
7615 case 6:
7616 return &XGI_LVDS1600x1200Data_1[ tempal ] ;
7617 break ;
7618 case 7:
7619 return &XGI_LVDSNoScalingData[ tempal ] ;
7620 break ;
7621 case 8:
7622 return &XGI_LVDS1024x768Data_1x75[ tempal ] ;
7623 break ;
7624 case 9:
7625 return &XGI_LVDS1024x768Data_2x75[ tempal ] ;
7626 break ;
7627 case 10:
7628 return &XGI_LVDS1280x1024Data_1x75[ tempal ] ;
7629 break ;
7630 case 11:
7631 return &XGI_LVDS1280x1024Data_2x75[ tempal ] ;
7632 break ;
7633 case 12:
7634 return &XGI_LVDSNoScalingDatax75[ tempal ] ;
7635 break ;
7636 default:
7637 break ;
7638 }
7639 }
7640 else if ( table == 3 )
7641 {
7642 switch( tempdi[ i ].DATAPTR )
7643 {
7644 case 0:
7645 return &XGI_LVDS1024x768Des_1[ tempal ] ;
7646 break ;
7647 case 1:
7648 return &XGI_LVDS1024x768Des_3[ tempal ] ;
7649 break ;
7650 case 2:
7651 return &XGI_LVDS1024x768Des_2[ tempal ] ;
7652 break ;
7653 case 3:
7654 return &XGI_LVDS1280x1024Des_1[ tempal ] ;
7655 break ;
7656 case 4:
7657 return &XGI_LVDS1280x1024Des_2[ tempal ] ;
7658 break ;
7659 case 5:
7660 return &XGI_LVDS1400x1050Des_1[ tempal ] ;
7661 break ;
7662 case 6:
7663 return &XGI_LVDS1400x1050Des_2[ tempal ] ;
7664 break ;
7665 case 7:
7666 return &XGI_LVDS1600x1200Des_1[ tempal ] ;
7667 break ;
7668 case 8:
7669 return &XGI_LVDSNoScalingDesData[ tempal ] ;
7670 break ;
7671 case 9:
7672 return &XGI_LVDS1024x768Des_1x75[ tempal ] ;
7673 break ;
7674 case 10:
7675 return &XGI_LVDS1024x768Des_3x75[ tempal ] ;
7676 break ;
7677 case 11:
7678 return &XGI_LVDS1024x768Des_2x75[ tempal ] ;
7679 break;
7680 case 12:
7681 return &XGI_LVDS1280x1024Des_1x75[ tempal ] ;
7682 break ;
7683 case 13:
7684 return &XGI_LVDS1280x1024Des_2x75[ tempal ] ;
7685 break ;
7686 case 14:
7687 return &XGI_LVDSNoScalingDesDatax75[ tempal ] ;
7688 break ;
7689 default:
7690 break ;
7691 }
7692 }
7693 else if ( table == 4 )
7694 {
7695 switch( tempdi[ i ].DATAPTR )
7696 {
7697 case 0:
7698 return &XGI_ExtLCD1024x768Data[ tempal ] ;
7699 break ;
7700 case 1:
7701 return &XGI_StLCD1024x768Data[ tempal ] ;
7702 break ;
7703 case 2:
7704 return &XGI_CetLCD1024x768Data[ tempal ] ;
7705 break ;
7706 case 3:
7707 return &XGI_ExtLCD1280x1024Data[ tempal ] ;
7708 break ;
7709 case 4:
7710 return &XGI_StLCD1280x1024Data[ tempal ] ;
7711 break ;
7712 case 5:
7713 return &XGI_CetLCD1280x1024Data[ tempal ] ;
7714 break ;
7715 case 6:
7716 return &XGI_ExtLCD1400x1050Data[ tempal ] ;
7717 break ;
7718 case 7:
7719 return &XGI_StLCD1400x1050Data[ tempal ] ;
7720 break ;
7721 case 8:
7722 return &XGI_CetLCD1400x1050Data[ tempal ] ;
7723 break ;
7724 case 9:
7725 return &XGI_ExtLCD1600x1200Data[ tempal ] ;
7726 break ;
7727 case 10:
7728 return &XGI_StLCD1600x1200Data[ tempal ] ;
7729 break ;
7730 case 11:
7731 return &XGI_NoScalingData[ tempal ] ;
7732 break ;
7733 case 12:
7734 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7735 break ;
7736 case 13:
7737 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7738 break ;
7739 case 14:
7740 return &XGI_CetLCD1024x768x75Data[ tempal ] ;
7741 break ;
7742 case 15:
7743 return &XGI_ExtLCD1280x1024x75Data[ tempal ] ;
7744 break ;
7745 case 16:
7746 return &XGI_StLCD1280x1024x75Data[ tempal ] ;
7747 break;
7748 case 17:
7749 return &XGI_CetLCD1280x1024x75Data[ tempal ] ;
7750 break;
7751 case 18:
7752 return &XGI_NoScalingDatax75[ tempal ] ;
7753 break ;
7754 default:
7755 break ;
7756 }
7757 }
7758 else if ( table == 5 )
7759 {
7760 switch( tempdi[ i ].DATAPTR )
7761 {
7762 case 0:
7763 return &XGI_ExtLCDDes1024x768Data[ tempal ] ;
7764 break ;
7765 case 1:
7766 return &XGI_StLCDDes1024x768Data[ tempal ] ;
7767 break ;
7768 case 2:
7769 return &XGI_CetLCDDes1024x768Data[ tempal ] ;
7770 break ;
7771 case 3:
7772 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7773 return &XGI_ExtLCDDLDes1280x1024Data[ tempal ] ;
7774 else
7775 return &XGI_ExtLCDDes1280x1024Data[ tempal ] ;
7776 break ;
7777 case 4:
7778 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7779 return &XGI_StLCDDLDes1280x1024Data[ tempal ] ;
7780 else
7781 return &XGI_StLCDDes1280x1024Data[ tempal ] ;
7782 break ;
7783 case 5:
7784 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7785 return &XGI_CetLCDDLDes1280x1024Data[ tempal ] ;
7786 else
7787 return &XGI_CetLCDDes1280x1024Data[ tempal ] ;
7788 break ;
7789 case 6:
7790 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7791 return &XGI_ExtLCDDLDes1400x1050Data[ tempal ] ;
7792 else
7793 return &XGI_ExtLCDDes1400x1050Data[ tempal ] ;
7794 break ;
7795 case 7:
7796 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7797 return &XGI_StLCDDLDes1400x1050Data[ tempal ] ;
7798 else
7799 return &XGI_StLCDDes1400x1050Data[ tempal ] ;
7800 break ;
7801 case 8:
7802 return &XGI_CetLCDDes1400x1050Data[ tempal ] ;
7803 break ;
7804 case 9:
7805 return &XGI_CetLCDDes1400x1050Data2[ tempal ] ;
7806 break ;
7807 case 10:
7808 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7809 return &XGI_ExtLCDDLDes1600x1200Data[ tempal ] ;
7810 else
7811 return &XGI_ExtLCDDes1600x1200Data[ tempal ] ;
7812 break ;
7813 case 11:
7814 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7815 return &XGI_StLCDDLDes1600x1200Data[ tempal ] ;
7816 else
7817 return &XGI_StLCDDes1600x1200Data[ tempal ] ;
7818 break ;
7819 case 12:
7820 return &XGI_NoScalingDesData[ tempal ] ;
7821 break;
7822 case 13:
7823 return &XGI_ExtLCDDes1024x768x75Data[ tempal ] ;
7824 break ;
7825 case 14:
7826 return &XGI_StLCDDes1024x768x75Data[ tempal ] ;
7827 break ;
7828 case 15:
7829 return &XGI_CetLCDDes1024x768x75Data[ tempal ] ;
7830 break ;
7831 case 16:
7832 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7833 return &XGI_ExtLCDDLDes1280x1024x75Data[ tempal ] ;
7834 else
7835 return &XGI_ExtLCDDes1280x1024x75Data[ tempal ] ;
7836 break ;
7837 case 17:
7838 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7839 return &XGI_StLCDDLDes1280x1024x75Data[ tempal ] ;
7840 else
7841 return &XGI_StLCDDes1280x1024x75Data[ tempal ] ;
7842 break ;
7843 case 18:
7844 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7845 return &XGI_CetLCDDLDes1280x1024x75Data[ tempal ] ;
7846 else
7847 return &XGI_CetLCDDes1280x1024x75Data[ tempal ] ;
7848 break ;
7849 case 19:
7850 return &XGI_NoScalingDesDatax75[ tempal ] ;
7851 break ;
7852 default:
7853 break ;
7854 }
7855 }
7856 else if ( table == 6 )
7857 {
7858 switch( tempdi[ i ].DATAPTR )
7859 {
7860 case 0:
7861 return &XGI_CH7017LV1024x768[ tempal ] ;
7862 break ;
7863 case 1:
7864 return &XGI_CH7017LV1400x1050[ tempal ] ;
7865 break ;
7866 default:
7867 break ;
7868 }
7869 }
7870 return 0 ;
7871}
7872
7873
7874/* --------------------------------------------------------------------- */
7875/* Function : XGI_GetTVPtr */
7876/* Input : */
7877/* Output : */
7878/* Description : */
7879/* --------------------------------------------------------------------- */
7880void* XGI_GetTVPtr (USHORT BX,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
7881{
7882 USHORT i , tempdx , tempbx , tempal , modeflag , table ;
7883 XGI330_TVDataTablStruct *tempdi = 0 ;
7884
7885 tempbx = BX ;
7886
7887 if ( ModeNo <= 0x13 )
7888 {
7889 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7890 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7891 }
7892 else
7893 {
7894 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7895 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7896 }
7897
7898 tempal = tempal & 0x3f ;
7899 table = tempbx ;
7900
7901 switch( tempbx )
7902 {
7903 case 0:
7904 tempdi = 0 ; /*EPLCHTVCRT1Ptr_H;*/
7905 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7906 {
7907 tempdi = XGI_EPLCHTVCRT1Ptr;
7908 }
7909 break ;
7910 case 1:
7911 tempdi = 0 ; /*EPLCHTVCRT1Ptr_V;*/
7912 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7913 {
7914 tempdi = XGI_EPLCHTVCRT1Ptr;
7915 }
7916 break ;
7917 case 2:
7918 tempdi = XGI_EPLCHTVDataPtr ;
7919 break ;
7920 case 3:
7921 tempdi = 0 ;
7922 break ;
7923 case 4:
7924 tempdi = XGI_TVDataTable ;
7925 break ;
7926 case 5:
7927 tempdi = 0 ;
7928 break ;
7929 case 6:
7930 tempdi = XGI_EPLCHTVRegPtr ;
7931 break ;
7932 default:
7933 break ;
7934 }
7935
7936 if ( tempdi == 0x00 ) /* OEMUtil */
7937 return( 0 ) ;
7938
7939 tempdx = pVBInfo->TVInfo ;
7940
7941 if ( pVBInfo->VBInfo & SetInSlaveMode )
7942 tempdx = tempdx | SetTVLockMode ;
7943
7944 if ( modeflag & HalfDCLK )
7945 tempdx = tempdx | SetTVLowResolution ;
7946
7947 i = 0 ;
7948
7949 while( tempdi[ i ].MASK != 0xffff )
7950 {
7951 if ( ( tempdx & tempdi[ i ].MASK ) == tempdi[ i ].CAP )
7952 break ;
7953 i++ ;
7954 }
7955
7956 if ( table == 0x00 ) /* 07/05/22 */
7957 {
7958#ifdef WIN2000
7959 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7960 {
7961 switch( tempdi[ i ].DATAPTR )
7962 {
7963 case 0:
7964 return &CH7007TVCRT1UNTSC_H[ tempal ] ;
7965 break ;
7966 case 1:
7967 return &CH7007TVCRT1ONTSC_H[ tempal ] ;
7968 break ;
7969 case 2:
7970 return &CH7007TVCRT1UPAL_H[ tempal ] ;
7971 break ;
7972 case 3:
7973 return &CH7007TVCRT1OPAL_H[ tempal ] ;
7974 break ;
7975 default:
7976 break ;
7977 }
7978 }
7979#endif
7980 }
7981 else if ( table == 0x01 )
7982 {
7983#ifdef WIN2000
7984 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7985 {
7986 switch( tempdi[ i ].DATAPTR )
7987 {
7988 case 0:
7989 return &CH7007TVCRT1UNTSC_V[ tempal ] ;
7990 break ;
7991 case 1:
7992 return &CH7007TVCRT1ONTSC_V[ tempal ] ;
7993 break ;
7994 case 2:
7995 return &CH7007TVCRT1UPAL_V[ tempal ] ;
7996 break ;
7997 case 3:
7998 return &CH7007TVCRT1OPAL_V[ tempal ] ;
7999 break ;
8000 default:
8001 break ;
8002 }
8003 }
8004#endif
8005 }
8006 else if ( table == 0x04 )
8007 {
8008 switch( tempdi[ i ].DATAPTR )
8009 {
8010 case 0:
8011 return &XGI_ExtPALData[ tempal ] ;
8012 break ;
8013 case 1:
8014 return &XGI_ExtNTSCData[ tempal ] ;
8015 break ;
8016 case 2:
8017 return &XGI_StPALData[ tempal ] ;
8018 break ;
8019 case 3:
8020 return &XGI_StNTSCData[ tempal ] ;
8021 break ;
8022 case 4:
8023 return &XGI_ExtHiTVData[ tempal ] ;
8024 break ;
8025 case 5:
8026 return &XGI_St2HiTVData[ tempal ] ;
8027 break ;
8028 case 6:
8029 return &XGI_ExtYPbPr525iData[ tempal ] ;
8030 break ;
8031 case 7:
8032 return &XGI_ExtYPbPr525pData[ tempal ] ;
8033 break ;
8034 case 8:
8035 return &XGI_ExtYPbPr750pData[ tempal ] ;
8036 break ;
8037 case 9:
8038 return &XGI_StYPbPr525iData[ tempal ] ;
8039 break ;
8040 case 10:
8041 return &XGI_StYPbPr525pData[ tempal ] ;
8042 break ;
8043 case 11:
8044 return &XGI_StYPbPr750pData[ tempal ] ;
8045 break;
8046 case 12: /* avoid system hang */
8047 return &XGI_ExtNTSCData[ tempal ] ;
8048 break ;
8049 case 13:
8050 return &XGI_St1HiTVData[ tempal ] ;
8051 break ;
8052 default:
8053 break ;
8054 }
8055 }
8056 else if( table == 0x02 )
8057 {
8058 switch( tempdi[ i ].DATAPTR )
8059 {
8060 case 0:
8061 return &XGI_CHTVUNTSCData[ tempal ] ;
8062 break ;
8063 case 1:
8064 return &XGI_CHTVONTSCData[ tempal ] ;
8065 break ;
8066 case 2:
8067 return &XGI_CHTVUPALData[ tempal ] ;
8068 break ;
8069 case 3:
8070 return &XGI_CHTVOPALData[ tempal ] ;
8071 break ;
8072 default:
8073 break ;
8074 }
8075 }
8076 else if( table == 0x06 )
8077 {
8078#ifdef WIN2000
8079 if ( pVBInfo->IF_DEF_CH7007 == 1 )
8080 {
8081 /* VideoDebugPrint((0, "XGI_GetTVPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
8082 switch( tempdi[ i ].DATAPTR )
8083 {
8084 case 0:
8085 return &CH7007TVReg_UNTSC[ tempal ] ;
8086 break ;
8087 case 1:
8088 return &CH7007TVReg_ONTSC[ tempal ] ;
8089 break ;
8090 case 2:
8091 return &CH7007TVReg_UPAL[ tempal ] ;
8092 break ;
8093 case 3:
8094 return &CH7007TVReg_OPAL[ tempal ] ;
8095 break ;
8096 default:
8097 break ;
8098 }
8099 }
8100 else
8101 {
8102 switch( tempdi[ i ].DATAPTR )
8103 {
8104 case 0:
8105 return &XGI_CHTVRegUNTSC[ tempal ] ;
8106 break ;
8107 case 1:
8108 return &XGI_CHTVRegONTSC[ tempal ] ;
8109 break ;
8110 case 2:
8111 return &XGI_CHTVRegUPAL[ tempal ] ;
8112 break ;
8113 case 3:
8114 return &XGI_CHTVRegOPAL[ tempal ] ;
8115 break ;
8116 default:
8117 break ;
8118 }
8119 }
8120#endif
8121 }
8122 return( 0 ) ;
8123}
8124
8125
8126/* --------------------------------------------------------------------- */
8127/* Function : XGI_BacklightByDrv */
8128/* Input : */
8129/* Output : TRUE -> Skip backlight control */
8130/* Description : */
8131/* --------------------------------------------------------------------- */
8132BOOLEAN XGI_BacklightByDrv( PVB_DEVICE_INFO pVBInfo )
8133{
8134 UCHAR tempah ;
8135
8136 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x3A ) ;
8137 if ( tempah & BacklightControlBit )
8138 return TRUE ;
8139 else
8140 return FALSE ;
8141}
8142
8143
8144/* --------------------------------------------------------------------- */
8145/* Function : XGI_FirePWDDisable */
8146/* Input : */
8147/* Output : */
8148/* Description : Turn off VDD & Backlight : Fire disable procedure */
8149/* --------------------------------------------------------------------- */
8150/*
8151void XGI_FirePWDDisable( PVB_DEVICE_INFO pVBInfo )
8152{
8153 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x00 , 0xFC ) ;
8154}
8155*/
8156
8157/* --------------------------------------------------------------------- */
8158/* Function : XGI_FirePWDEnable */
8159/* Input : */
8160/* Output : */
8161/* Description : Turn on VDD & Backlight : Fire enable procedure */
8162/* --------------------------------------------------------------------- */
8163void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo )
8164{
8165 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x03 , 0xFC ) ;
8166}
8167
8168
8169/* --------------------------------------------------------------------- */
8170/* Function : XGI_EnableGatingCRT */
8171/* Input : */
8172/* Output : */
8173/* Description : */
8174/* --------------------------------------------------------------------- */
8175void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
8176{
8177 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x40 ) ;
8178}
8179
8180
8181/* --------------------------------------------------------------------- */
8182/* Function : XGI_DisableGatingCRT */
8183/* Input : */
8184/* Output : */
8185/* Description : */
8186/* --------------------------------------------------------------------- */
8187void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
8188{
8189
8190 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x00 ) ;
8191}
8192
8193
8194/* --------------------------------------------------------------------- */
8195/* Function : XGI_SetPanelDelay */
8196/* Input : */
8197/* Output : */
8198/* Description : */
8199/* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
8200/* : bl : 2 ; T2 : the duration signal on and Vdd on */
8201/* : bl : 3 ; T3 : the duration between CPL off and signal off */
8202/* : bl : 4 ; T4 : the duration signal off and Vdd off */
8203/* --------------------------------------------------------------------- */
8204void XGI_SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
8205{
8206 USHORT index ;
8207
8208 index = XGI_GetLCDCapPtr(pVBInfo) ;
8209
8210 if ( tempbl == 1 )
8211 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S1, pVBInfo ) ;
8212
8213 if ( tempbl == 2 )
8214 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S2, pVBInfo ) ;
8215
8216 if ( tempbl == 3 )
8217 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S3, pVBInfo ) ;
8218
8219 if ( tempbl == 4 )
8220 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S4, pVBInfo ) ;
8221}
8222
8223
8224/* --------------------------------------------------------------------- */
8225/* Function : XGI_SetPanelPower */
8226/* Input : */
8227/* Output : */
8228/* Description : */
8229/* I/O : ah = 0011b = 03h ; Backlight on, Power on */
8230/* = 0111b = 07h ; Backlight on, Power off */
8231/* = 1011b = 0Bh ; Backlight off, Power on */
8232/* = 1111b = 0Fh ; Backlight off, Power off */
8233/* --------------------------------------------------------------------- */
8234void XGI_SetPanelPower(USHORT tempah,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
8235{
8236 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8237 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x26 , tempbl , tempah ) ;
8238 else
8239 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x11 , tempbl , tempah ) ;
8240}
8241
8242UCHAR XG21GPIODataTransfer(UCHAR ujDate)
8243{
8244 UCHAR ujRet = 0;
8245 UCHAR i = 0;
8246
8247 for (i=0; i<8; i++)
8248 {
8249 ujRet = ujRet << 1;
8250 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
8251 ujRet |= (ujDate >> i) & 1;
8252 }
8253
8254 return ujRet;
8255}
8256
8257/*----------------------------------------------------------------------------*/
8258/* output */
8259/* bl[5] : LVDS signal */
8260/* bl[1] : LVDS backlight */
8261/* bl[0] : LVDS VDD */
8262/*----------------------------------------------------------------------------*/
8263UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo)
8264{
8265 UCHAR CR4A,temp;
8266
8267 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
8268 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x23 ) ; /* enable GPIO write */
8269
8270 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
8271
8272 temp = XG21GPIODataTransfer(temp);
8273 temp &= 0x23;
8274 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
8275 return temp;
8276}
8277
8278/*----------------------------------------------------------------------------*/
8279/* output */
8280/* bl[5] : LVDS signal */
8281/* bl[1] : LVDS backlight */
8282/* bl[0] : LVDS VDD */
8283/*----------------------------------------------------------------------------*/
8284UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo)
8285{
8286 UCHAR CR4A,CRB4,temp;
8287
8288 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
8289 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x0C ) ; /* enable GPIO write */
8290
8291 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
8292
8293 temp &= 0x0C;
8294 temp >>= 2;
8295 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
8296 CRB4 = XGINew_GetReg1( pVBInfo->P3d4 , 0xB4 ) ;
8297 temp |= ((CRB4&0x04)<<3);
8298 return temp;
8299}
8300/*----------------------------------------------------------------------------*/
8301/* input */
8302/* bl[5] : 1;LVDS signal on */
8303/* bl[1] : 1;LVDS backlight on */
8304/* bl[0] : 1:LVDS VDD on */
8305/* bh: 100000b : clear bit 5, to set bit5 */
8306/* 000010b : clear bit 1, to set bit1 */
8307/* 000001b : clear bit 0, to set bit0 */
8308/*----------------------------------------------------------------------------*/
8309void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
8310{
8311 UCHAR CR4A,temp;
8312
8313 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
8314 tempbh &= 0x23;
8315 tempbl &= 0x23;
8316 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
8317
8318 if (tempbh&0x20)
8319 {
8320 temp = (tempbl>>4)&0x02;
8321
8322 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
8323
8324 }
8325
8326 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
8327
8328 temp = XG21GPIODataTransfer(temp);
8329 temp &= ~tempbh;
8330 temp |= tempbl;
8331 XGINew_SetReg1( pVBInfo->P3d4 , 0x48 , temp ) ;
8332}
8333
8334void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
8335{
8336 UCHAR CR4A,temp;
8337 USHORT tempbh0,tempbl0;
8338
8339 tempbh0 = tempbh;
8340 tempbl0 = tempbl;
8341 tempbh0 &= 0x20;
8342 tempbl0 &= 0x20;
8343 tempbh0 >>= 3;
8344 tempbl0 >>= 3;
8345
8346 if (tempbh&0x20)
8347 {
8348 temp = (tempbl>>4)&0x02;
8349
8350 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
8351
8352 }
8353 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~tempbh0 , tempbl0 ) ;
8354
8355 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
8356 tempbh &= 0x03;
8357 tempbl &= 0x03;
8358 tempbh <<= 2;
8359 tempbl <<= 2; /* GPIOC,GPIOD */
8360 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
8361 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~tempbh , tempbl ) ;
8362}
8363
8364/* --------------------------------------------------------------------- */
8365USHORT XGI_GetLVDSOEMTableIndex(PVB_DEVICE_INFO pVBInfo)
8366{
8367 USHORT index ;
8368
8369 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8370 if (index<sizeof(XGI21_LCDCapList)/sizeof(XGI21_LVDSCapStruct))
8371 {
8372 return index;
8373 }
8374 return 0;
8375}
8376
8377/* --------------------------------------------------------------------- */
8378/* Function : XGI_XG21SetPanelDelay */
8379/* Input : */
8380/* Output : */
8381/* Description : */
8382/* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
8383/* : bl : 2 ; T2 : the duration signal on and Vdd on */
8384/* : bl : 3 ; T3 : the duration between CPL off and signal off */
8385/* : bl : 4 ; T4 : the duration signal off and Vdd off */
8386/* --------------------------------------------------------------------- */
8387void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
8388{
8389 USHORT index ;
8390
8391 index = XGI_GetLVDSOEMTableIndex( pVBInfo );
8392 if ( tempbl == 1 )
8393 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S1, pVBInfo ) ;
8394
8395 if ( tempbl == 2 )
8396 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S2, pVBInfo ) ;
8397
8398 if ( tempbl == 3 )
8399 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S3, pVBInfo ) ;
8400
8401 if ( tempbl == 4 )
8402 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S4, pVBInfo ) ;
8403}
8404
8405BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8406{
8407 USHORT xres ,
8408 yres ,
8409 colordepth ,
8410 modeflag ,
8411 resindex ,
8412 lvdstableindex;
8413
8414 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8415 if ( ModeNo <= 0x13 )
8416 {
8417 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8418 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8419 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8420 }
8421 else
8422 {
8423 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8424 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8425 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8426 }
8427
8428 if ( !( modeflag & Charx8Dot ) )
8429 {
8430 xres /= 9;
8431 xres *= 8;
8432 }
8433
8434 if ( ModeNo > 0x13 )
8435 {
8436 if ( ( ModeNo>0x13 ) && ( modeflag & HalfDCLK ) )
8437 {
8438 xres *= 2 ;
8439 }
8440 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8441 {
8442 yres *= 2 ;
8443 }
8444 }
8445
8446 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8447 if ( xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) )
8448 return FALSE;
8449
8450 if ( yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE) )
8451 return FALSE;
8452
8453 if ( ModeNo > 0x13 )
8454 {
8455 if ( ( xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) ) ||
8456 ( yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) )
8457 {
8458 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
8459 if ( colordepth > 2 )
8460 {
8461 return FALSE;
8462 }
8463 }
8464 }
8465 return TRUE;
8466}
8467
8468void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo)
8469{
8470 UCHAR temp;
8471
8472 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[0] 1: 18bit */
8473 temp = ( temp & 1 ) << 6;
8474 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x40 , temp ) ; /* SR06[6] 18bit Dither */
8475 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
8476
8477}
8478
8479void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo)
8480{
8481 UCHAR temp;
8482
8483 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
8484 temp = ( temp & 3 ) << 6;
8485 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0xc0 , temp & 0x80 ) ; /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
8486 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
8487
8488}
8489
8490void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8491{
8492 UCHAR temp,Miscdata;
8493 USHORT xres ,
8494 yres ,
8495 modeflag ,
8496 resindex ,
8497 lvdstableindex ;
8498 USHORT LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8499 USHORT LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8500 USHORT value;
8501
8502 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8503
8504 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8505 temp &= LCDPolarity;
8506 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8507
8508 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8509
8510 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8511 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8512 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8513
8514 XGI_SetXG21FPBits(pVBInfo);
8515 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8516 if ( ModeNo <= 0x13 )
8517 {
8518 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8519 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8520 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8521 }
8522 else
8523 {
8524 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8525 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8526 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8527 }
8528
8529 if (!( modeflag & Charx8Dot ))
8530 xres = xres * 8 / 9;
8531
8532 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8533
8534 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8535 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8536 {
8537 LVDSHBS -= xres/4 ;
8538 }
8539 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8540
8541 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8542 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8543
8544 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8545 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8546
8547 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8548
8549 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8550
8551 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8552 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8553 {
8554 LVDSVBS += yres/2 ;
8555 }
8556 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8557
8558 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8559 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8560
8561 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8562 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8563
8564 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8565
8566 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8567 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8568
8569 if (!( modeflag & Charx8Dot ))
8570 {
8571 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8572 }
8573
8574 /* HT SR0B[1:0] CR00 */
8575 value = ( LVDSHT >> 3 ) - 5;
8576 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8577 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8578
8579 /* HBS SR0B[5:4] CR02 */
8580 value = ( LVDSHBS >> 3 ) - 1;
8581 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8582 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8583
8584 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8585 value = ( LVDSHBE >> 3 ) - 1;
8586 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8587 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8588 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8589
8590 /* HRS SR0B[7:6] CR04 */
8591 value = ( LVDSHRS >> 3 ) + 2;
8592 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8593 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8594
8595 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8596 value--;
8597 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8598 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8599
8600 /* HRE SR0C[2] CR05[4:0] */
8601 value = ( LVDSHRE >> 3 ) + 2;
8602 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8603 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8604
8605 /* Panel HRE SR2F[7:2] */
8606 value--;
8607 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8608
8609 /* VT SR0A[0] CR07[5][0] CR06 */
8610 value = LVDSVT - 2 ;
8611 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8612 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8613 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8614 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8615
8616 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8617 value = LVDSVBS - 1 ;
8618 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8619 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8620 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8621 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8622
8623 /* VBE SR0A[4] CR16 */
8624 value = LVDSVBE - 1;
8625 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8626 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8627
8628 /* VRS SR0A[3] CR7[7][2] CR10 */
8629 value = LVDSVRS - 1 ;
8630 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8631 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8632 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8633 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8634
8635 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
8636 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0x03 , ( value & 0x600 ) >> 9 ) ;
8637 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , (value >> 1) & 0xFF ) ;
8638 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x33 , ~0x01 , value & 0x01 ) ;
8639
8640 /* VRE SR0A[5] CR11[3:0] */
8641 value = LVDSVRE - 1;
8642 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8643 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8644
8645 /* Panel VRE SR3F[7:2] */ /* SR3F[7] has to be 0, h/w bug */
8646 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0x7C ) ;
8647
8648 for ( temp=0, value = 0; temp < 3; temp++)
8649 {
8650
8651 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8652 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8653 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8654 value += 0x10;
8655 }
8656
8657 if (!( modeflag & Charx8Dot ))
8658 {
8659 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8660 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8661 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8662
8663 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8664 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8665
8666 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8667 }
8668
8669
8670}
8671
8672/* no shadow case */
8673void XGI_SetXG27LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8674{
8675 UCHAR temp,Miscdata;
8676 USHORT xres ,
8677 yres ,
8678 modeflag ,
8679 resindex ,
8680 lvdstableindex ;
8681 USHORT LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8682 USHORT LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8683 USHORT value;
8684
8685 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8686 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8687 temp &= LCDPolarity;
8688 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8689
8690 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8691
8692 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8693 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8694 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8695
8696 XGI_SetXG27FPBits(pVBInfo);
8697 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8698 if ( ModeNo <= 0x13 )
8699 {
8700 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8701 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8702 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8703 }
8704 else
8705 {
8706 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8707 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8708 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8709 }
8710
8711 if (!( modeflag & Charx8Dot ))
8712 xres = xres * 8 / 9;
8713
8714 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8715
8716 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8717 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8718 {
8719 LVDSHBS -= xres/4 ;
8720 }
8721 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8722
8723 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8724 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8725
8726 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8727 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8728
8729 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8730
8731 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8732
8733 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8734 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8735 {
8736 LVDSVBS += yres/2 ;
8737 }
8738 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8739
8740 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8741 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8742
8743 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8744 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8745
8746 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8747
8748 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8749 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8750
8751 if (!( modeflag & Charx8Dot ))
8752 {
8753 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8754 }
8755
8756 /* HT SR0B[1:0] CR00 */
8757 value = ( LVDSHT >> 3 ) - 5;
8758 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8759 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8760
8761 /* HBS SR0B[5:4] CR02 */
8762 value = ( LVDSHBS >> 3 ) - 1;
8763 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8764 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8765
8766 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8767 value = ( LVDSHBE >> 3 ) - 1;
8768 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8769 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8770 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8771
8772 /* HRS SR0B[7:6] CR04 */
8773 value = ( LVDSHRS >> 3 ) + 2;
8774 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8775 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8776
8777 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8778 value--;
8779 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8780 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8781
8782 /* HRE SR0C[2] CR05[4:0] */
8783 value = ( LVDSHRE >> 3 ) + 2;
8784 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8785 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8786
8787 /* Panel HRE SR2F[7:2] */
8788 value--;
8789 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8790
8791 /* VT SR0A[0] CR07[5][0] CR06 */
8792 value = LVDSVT - 2 ;
8793 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8794 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8795 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8796 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8797
8798 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8799 value = LVDSVBS - 1 ;
8800 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8801 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8802 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8803 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8804
8805 /* VBE SR0A[4] CR16 */
8806 value = LVDSVBE - 1;
8807 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8808 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8809
8810 /* VRS SR0A[3] CR7[7][2] CR10 */
8811 value = LVDSVRS - 1 ;
8812 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8813 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8814 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8815 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8816
8817 /* Panel VRS SR35[2:0] SR34[7:0] */
8818 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , ( value & 0x700 ) >> 8 ) ;
8819 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , value & 0xFF ) ;
8820
8821 /* VRE SR0A[5] CR11[3:0] */
8822 value = LVDSVRE - 1;
8823 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8824 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8825
8826 /* Panel VRE SR3F[7:2] */
8827 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0xFC ) ;
8828
8829 for ( temp=0, value = 0; temp < 3; temp++)
8830 {
8831
8832 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8833 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8834 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8835 value += 0x10;
8836 }
8837
8838 if (!( modeflag & Charx8Dot ))
8839 {
8840 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8841 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8842 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8843
8844 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8845 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8846
8847 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8848 }
8849
8850
8851}
8852
8853/* --------------------------------------------------------------------- */
8854/* Function : XGI_IsLCDON */
8855/* Input : */
8856/* Output : FALSE : Skip PSC Control */
8857/* TRUE: Disable PSC */
8858/* Description : */
8859/* --------------------------------------------------------------------- */
8860BOOLEAN XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo)
8861{
8862 USHORT tempax ;
8863
8864 tempax = pVBInfo->VBInfo ;
8865 if ( tempax & SetCRT2ToDualEdge )
8866 return FALSE ;
8867 else if ( tempax & ( DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode ) )
8868 return TRUE ;
8869
8870 return FALSE ;
8871}
8872
8873
8874/* --------------------------------------------------------------------- */
8875/* Function : XGI_EnablePWD */
8876/* Input : */
8877/* Output : */
8878/* Description : */
8879/* --------------------------------------------------------------------- */
8880void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo )
8881{
8882 USHORT index ,
8883 temp ;
8884
8885 index = XGI_GetLCDCapPtr(pVBInfo) ;
8886 temp = pVBInfo->LCDCapList[ index ].PWD_2B ;
8887 XGINew_SetReg1( pVBInfo->Part4Port , 0x2B , temp ) ;
8888 XGINew_SetReg1( pVBInfo->Part4Port , 0x2C , pVBInfo->LCDCapList[ index ].PWD_2C ) ;
8889 XGINew_SetReg1( pVBInfo->Part4Port , 0x2D , pVBInfo->LCDCapList[ index ].PWD_2D ) ;
8890 XGINew_SetReg1( pVBInfo->Part4Port , 0x2E , pVBInfo->LCDCapList[ index ].PWD_2E ) ;
8891 XGINew_SetReg1( pVBInfo->Part4Port , 0x2F , pVBInfo->LCDCapList[ index ].PWD_2F ) ;
8892 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x80 ) ; /* enable PWD */
8893}
8894
8895
8896/* --------------------------------------------------------------------- */
8897/* Function : XGI_DisablePWD */
8898/* Input : */
8899/* Output : */
8900/* Description : */
8901/* --------------------------------------------------------------------- */
8902void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo )
8903{
8904 XGINew_SetRegAND( pVBInfo->Part4Port , 0x27 , 0x7F ) ; /* disable PWD */
8905}
8906
8907
8908/* --------------------------------------------------------------------- */
8909/* Function : XGI_DisableChISLCD */
8910/* Input : */
8911/* Output : FALSE -> Not LCD Mode */
8912/* Description : */
8913/* --------------------------------------------------------------------- */
8914BOOLEAN XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo)
8915{
8916 USHORT tempbx ,
8917 tempah ;
8918
8919 tempbx = pVBInfo->SetFlag & ( DisableChA | DisableChB ) ;
8920 tempah = ~( ( USHORT )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8921
8922 if ( tempbx & ( EnableChA | DisableChA ) )
8923 {
8924 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8925 return FALSE ;
8926 }
8927
8928 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8929 return FALSE ;
8930
8931 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8932 return TRUE ;
8933
8934 return FALSE ;
8935}
8936
8937
8938/* --------------------------------------------------------------------- */
8939/* Function : XGI_EnableChISLCD */
8940/* Input : */
8941/* Output : 0 -> Not LCD mode */
8942/* Description : */
8943/* --------------------------------------------------------------------- */
8944BOOLEAN XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo)
8945{
8946 USHORT tempbx ,
8947 tempah ;
8948
8949
8950 tempbx = pVBInfo->SetFlag & ( EnableChA | EnableChB ) ;
8951 tempah = ~( ( USHORT )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8952
8953 if ( tempbx & ( EnableChA | DisableChA ) )
8954 {
8955 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8956 return FALSE ;
8957 }
8958
8959 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8960 return FALSE ;
8961
8962 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8963 return TRUE ;
8964
8965 return FALSE ;
8966}
8967
8968
8969/* --------------------------------------------------------------------- */
8970/* Function : XGI_GetLCDCapPtr */
8971/* Input : */
8972/* Output : */
8973/* Description : */
8974/* --------------------------------------------------------------------- */
8975USHORT XGI_GetLCDCapPtr( PVB_DEVICE_INFO pVBInfo )
8976{
8977 UCHAR tempal ,
8978 tempah ,
8979 tempbl ,
8980 i ;
8981
8982 tempah = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8983 tempal = tempah & 0x0F ;
8984 tempah = tempah & 0xF0 ;
8985 i = 0 ;
8986 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8987
8988 while( tempbl != 0xFF )
8989 {
8990 if ( tempbl & 0x80 ) /* OEMUtil */
8991 {
8992 tempal = tempah ;
8993 tempbl = tempbl & ~( 0x80 ) ;
8994 }
8995
8996 if ( tempal == tempbl )
8997 break ;
8998
8999 i++ ;
9000
9001 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
9002 }
9003
9004 return i ;
9005}
9006
9007
9008/* --------------------------------------------------------------------- */
9009/* Function : XGI_GetLCDCapPtr1 */
9010/* Input : */
9011/* Output : */
9012/* Description : */
9013/* --------------------------------------------------------------------- */
9014USHORT XGI_GetLCDCapPtr1( PVB_DEVICE_INFO pVBInfo )
9015{
9016 USHORT tempah ,
9017 tempal ,
9018 tempbl ,
9019 i ;
9020
9021 tempal = pVBInfo->LCDResInfo ;
9022 tempah = pVBInfo->LCDTypeInfo ;
9023
9024 i = 0 ;
9025 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID;
9026
9027 while( tempbl != 0xFF )
9028 {
9029 if ( ( tempbl & 0x80 ) && ( tempbl != 0x80 ) )
9030 {
9031 tempal = tempah ;
9032 tempbl &= ~0x80 ;
9033 }
9034
9035 if ( tempal == tempbl )
9036 break ;
9037
9038 i++ ;
9039 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
9040 }
9041
9042 if ( tempbl == 0xFF )
9043 {
9044 pVBInfo->LCDResInfo = Panel1024x768 ;
9045 pVBInfo->LCDTypeInfo = 0 ;
9046 i = 0 ;
9047 }
9048
9049 return i ;
9050}
9051
9052
9053/* --------------------------------------------------------------------- */
9054/* Function : XGI_GetLCDSync */
9055/* Input : */
9056/* Output : */
9057/* Description : */
9058/* --------------------------------------------------------------------- */
9059void XGI_GetLCDSync( USHORT* HSyncWidth , USHORT* VSyncWidth, PVB_DEVICE_INFO pVBInfo )
9060{
9061 USHORT Index ;
9062
9063 Index = XGI_GetLCDCapPtr(pVBInfo) ;
9064 *HSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_HSyncWidth ;
9065 *VSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_VSyncWidth ;
9066
9067 return ;
9068}
9069
9070
9071
9072/* --------------------------------------------------------------------- */
9073/* Function : XGI_EnableBridge */
9074/* Input : */
9075/* Output : */
9076/* Description : */
9077/* --------------------------------------------------------------------- */
9078void XGI_EnableBridge( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
9079{
9080 USHORT tempbl ,
9081 tempah ;
9082
9083 if ( pVBInfo->SetFlag == Win9xDOSMode )
9084 {
9085 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9086 {
9087 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
9088 return ;
9089 }
9090 else /* LVDS or CH7017 */
9091 return ;
9092 }
9093
9094
9095 if ( HwDeviceExtension->jChipType < XG40 )
9096 {
9097 if ( !XGI_DisableChISLCD(pVBInfo) )
9098 {
9099 if ( ( XGI_EnableChISLCD(pVBInfo) ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
9100 {
9101 if ( pVBInfo->LCDInfo & SetPWDEnable )
9102 {
9103 XGI_EnablePWD( pVBInfo);
9104 }
9105 else
9106 {
9107 pVBInfo->LCDInfo &= ( ~SetPWDEnable ) ;
9108 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9109 {
9110 tempbl = 0xFD ;
9111 tempah = 0x02 ;
9112 }
9113 else
9114 {
9115 tempbl = 0xFB ;
9116 tempah = 0x00 ;
9117 }
9118
9119 XGI_SetPanelPower( tempah , tempbl, pVBInfo ) ;
9120 XGI_SetPanelDelay( 1,pVBInfo ) ;
9121 }
9122 }
9123 }
9124 } /* Not 340 */
9125
9126
9127
9128 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9129 {
9130 if ( !( pVBInfo->SetFlag & DisableChA ) )
9131 {
9132 if ( pVBInfo->SetFlag & EnableChA )
9133 {
9134 XGINew_SetReg1( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* Power on */
9135 }
9136 else
9137 {
9138 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge ) /* SetCRT2ToLCDA ) */
9139 {
9140 XGINew_SetReg1(pVBInfo->Part1Port,0x1E,0x20); /* Power on */
9141 }
9142 }
9143 }
9144
9145 if ( !( pVBInfo->SetFlag & DisableChB ) )
9146 {
9147 if ( ( pVBInfo->SetFlag & EnableChB ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV | SetCRT2ToRAMDAC ) ) )
9148 {
9149 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
9150 tempah &= 0xDF;
9151 if ( pVBInfo->VBInfo & SetInSlaveMode )
9152 {
9153 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
9154 tempah |= 0x20 ;
9155 }
9156 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , tempah ) ;
9157 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x20 ) ;
9158
9159
9160 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
9161
9162 if ( !( tempah & 0x80 ) )
9163 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
9164
9165 XGINew_SetRegAND( pVBInfo->Part1Port , 0x00 , 0x7F ) ; /* BScreenOFF = 0 */
9166 }
9167 }
9168
9169 if ( ( pVBInfo->SetFlag & ( EnableChA | EnableChB ) ) || ( !( pVBInfo->VBInfo & DisableCRT2Display ) ) )
9170 {
9171 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x00 , ~0xE0 , 0x20 ) ; /* shampoo 0129 */
9172 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9173 {
9174 if ( !XGI_DisableChISLCD(pVBInfo) )
9175 {
9176 if ( XGI_EnableChISLCD( pVBInfo) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
9177 XGINew_SetRegAND( pVBInfo->Part4Port ,0x2A , 0x7F ) ; /* LVDS PLL power on */
9178 }
9179 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x7F ) ; /* LVDS Driver power on */
9180 }
9181 }
9182
9183 tempah = 0x00 ;
9184
9185 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9186 {
9187 tempah = 0xc0 ;
9188
9189 if ( !( pVBInfo->VBInfo & SetSimuScanMode ) )
9190 {
9191 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9192 {
9193 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9194 {
9195 tempah = tempah & 0x40;
9196 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9197 tempah = tempah ^ 0xC0 ;
9198
9199 if ( pVBInfo->SetFlag & DisableChB )
9200 tempah &= 0xBF ;
9201
9202 if ( pVBInfo->SetFlag & DisableChA )
9203 tempah &= 0x7F ;
9204
9205 if ( pVBInfo->SetFlag & EnableChB )
9206 tempah |= 0x40 ;
9207
9208 if ( pVBInfo->SetFlag & EnableChA )
9209 tempah |= 0x80 ;
9210 }
9211 }
9212 }
9213 }
9214
9215 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1F , tempah ) ; /* EnablePart4_1F */
9216
9217 if ( pVBInfo->SetFlag & Win9xDOSMode )
9218 {
9219 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
9220 return ;
9221 }
9222
9223 if ( !( pVBInfo->SetFlag & DisableChA ) )
9224 {
9225 XGI_VBLongWait( pVBInfo) ;
9226 if ( !( pVBInfo->SetFlag & GatingCRT ) )
9227 {
9228 XGI_DisableGatingCRT( HwDeviceExtension, pVBInfo ) ;
9229 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
9230 XGI_VBLongWait( pVBInfo) ;
9231 }
9232 }
9233 } /* 301 */
9234 else /* LVDS */
9235 {
9236 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9237 XGINew_SetRegOR( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* enable CRT2 */
9238
9239
9240
9241 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
9242 if ( !( tempah & 0x80 ) )
9243 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
9244
9245 XGINew_SetRegAND(pVBInfo->Part1Port,0x00,0x7F);
9246 XGI_DisplayOn( HwDeviceExtension, pVBInfo);
9247 } /* End of VB */
9248
9249
9250 if ( HwDeviceExtension->jChipType < XG40 )
9251 {
9252 if ( !XGI_EnableChISLCD(pVBInfo) )
9253 {
9254 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9255 {
9256 if ( XGI_BacklightByDrv(pVBInfo) )
9257 return ;
9258 }
9259 else
9260 return ;
9261 }
9262
9263 if ( pVBInfo->LCDInfo & SetPWDEnable )
9264 {
9265 XGI_FirePWDEnable(pVBInfo) ;
9266 return ;
9267 }
9268
9269 XGI_SetPanelDelay( 2,pVBInfo ) ;
9270
9271 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9272 {
9273 tempah = 0x01 ;
9274 tempbl = 0xFE ; /* turn on backlght */
9275 }
9276 else
9277 {
9278 tempbl = 0xF7 ;
9279 tempah = 0x00 ;
9280 }
9281 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
9282 }
9283}
9284
9285
9286/* --------------------------------------------------------------------- */
9287/* Function : XGI_DisableBridge */
9288/* Input : */
9289/* Output : */
9290/* Description : */
9291/* --------------------------------------------------------------------- */
9292void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
9293{
9294 USHORT tempax ,
9295 tempbx ,
9296 tempah = 0 ,
9297 tempbl = 0 ;
9298
9299 if ( pVBInfo->SetFlag == Win9xDOSMode )
9300 return ;
9301
9302
9303 if ( HwDeviceExtension->jChipType < XG40 )
9304 {
9305 if ( ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
9306 {
9307 if ( !XGI_IsLCDON(pVBInfo) )
9308 {
9309 if ( pVBInfo->LCDInfo & SetPWDEnable )
9310 XGI_EnablePWD( pVBInfo) ;
9311 else
9312 {
9313 pVBInfo->LCDInfo &= ~SetPWDEnable ;
9314 XGI_DisablePWD(pVBInfo) ;
9315 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9316 {
9317 tempbx = 0xFE ; /* not 01h */
9318 tempax = 0 ;
9319 }
9320 else
9321 {
9322 tempbx = 0xF7 ; /* not 08h */
9323 tempax = 0x08 ;
9324 }
9325 XGI_SetPanelPower( tempax , tempbx , pVBInfo) ;
9326 XGI_SetPanelDelay( 3,pVBInfo ) ;
9327 }
9328 } /* end if(!XGI_IsLCDON(pVBInfo)) */
9329 }
9330 }
9331
9332/* if ( CH7017 )
9333 {
9334 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2toLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
9335 {
9336 if ( !XGI_IsLCDON(pVBInfo) )
9337 {
9338 if ( DISCHARGE )
9339 {
9340 tempbx = XGINew_GetCH7005( 0x61 ) ;
9341 if ( tempbx < 0x01 ) //first time we power up
9342 XGINew_SetCH7005( 0x0066 ) ; //and disable power sequence
9343 else
9344 XGINew_SetCH7005( 0x5f66 ) ; //leave VDD on - disable power
9345 }
9346 }
9347 }
9348 } */
9349
9350 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B| VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9351 {
9352 tempah = 0x3F ;
9353 if ( !( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) ) )
9354 {
9355 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9356 {
9357 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9358 {
9359 tempah = 0x7F; /* Disable Channel A */
9360 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9361 tempah = 0xBF ; /* Disable Channel B */
9362
9363 if ( pVBInfo->SetFlag & DisableChB )
9364 tempah &= 0xBF ; /* force to disable Cahnnel */
9365
9366 if ( pVBInfo->SetFlag & DisableChA )
9367 tempah &= 0x7F ; /* Force to disable Channel B */
9368 }
9369 }
9370 }
9371
9372 XGINew_SetRegAND( pVBInfo->Part4Port , 0x1F , tempah ) ; /* disable part4_1f */
9373
9374 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9375 {
9376 if ( ( ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9377 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x80 ) ; /* LVDS Driver power down */
9378 }
9379
9380 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) ) )
9381 {
9382 if ( pVBInfo->SetFlag & GatingCRT )
9383 XGI_EnableGatingCRT( HwDeviceExtension, pVBInfo ) ;
9384 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9385 }
9386
9387 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9388 {
9389 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9390 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1e , 0xdf ) ; /* Power down */
9391 }
9392
9393 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xdf ) ; /* disable TV as primary VGA swap */
9394
9395 if ( ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToDualEdge ) ) )
9396 XGINew_SetRegAND(pVBInfo->Part2Port,0x00,0xdf);
9397
9398 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9399 || ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ) )
9400 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9401
9402 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9403 || ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) || ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) )
9404 {
9405 tempah= XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ; /* save Part1 index 0 */
9406 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x10 ) ; /* BTDAC = 1, avoid VB reset */
9407 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* disable CRT2 */
9408 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ; /* restore Part1 index 0 */
9409 }
9410 }
9411 else /* {301} */
9412 {
9413 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
9414 {
9415 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9416 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* Disable CRT2 */
9417 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xDF ) ; /* Disable TV asPrimary VGA swap */
9418 }
9419
9420 if ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) )
9421 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9422 }
9423
9424
9425
9426
9427 if ( HwDeviceExtension->jChipType < XG40 )
9428 {
9429 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9430 {
9431 if ( pVBInfo->LCDInfo & SetPWDEnable )
9432 {
9433 if ( pVBInfo->LCDInfo & SetPWDEnable )
9434 XGI_BacklightByDrv(pVBInfo) ;
9435 else
9436 {
9437 XGI_SetPanelDelay( 4 ,pVBInfo) ;
9438 if ( pVBInfo->VBType & VB_XGI301LV )
9439 {
9440 tempbl = 0xFD ;
9441 tempah = 0x00 ;
9442 }
9443 else
9444 {
9445 tempbl = 0xFB ;
9446 tempah = 0x04 ;
9447 }
9448 }
9449 }
9450 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
9451 }
9452 }
9453}
9454
9455
9456/* --------------------------------------------------------------------- */
9457/* Function : XGI_GetTVPtrIndex */
9458/* Input : */
9459/* Output : */
9460/* Description : bx 0 : ExtNTSC */
9461/* 1 : StNTSC */
9462/* 2 : ExtPAL */
9463/* 3 : StPAL */
9464/* 4 : ExtHiTV */
9465/* 5 : StHiTV */
9466/* 6 : Ext525i */
9467/* 7 : St525i */
9468/* 8 : Ext525p */
9469/* 9 : St525p */
9470/* A : Ext750p */
9471/* B : St750p */
9472/* --------------------------------------------------------------------- */
9473USHORT XGI_GetTVPtrIndex( PVB_DEVICE_INFO pVBInfo )
9474{
9475 USHORT tempbx = 0 ;
9476
9477 if ( pVBInfo->TVInfo & SetPALTV )
9478 tempbx = 2 ;
9479 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
9480 tempbx = 4 ;
9481 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
9482 tempbx = 6 ;
9483 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
9484 tempbx = 8 ;
9485 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
9486 tempbx = 10 ;
9487 if ( pVBInfo->TVInfo & TVSimuMode )
9488 tempbx++ ;
9489
9490 return tempbx ;
9491}
9492
9493
9494/* --------------------------------------------------------------------- */
9495/* Function : XGI_OEM310Setting */
9496/* Input : */
9497/* Output : */
9498/* Description : Customized Param. for 301 */
9499/* --------------------------------------------------------------------- */
9500void XGI_OEM310Setting( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9501{
9502 if ( pVBInfo->SetFlag & Win9xDOSMode )
9503 return ;
9504
9505 /* GetPart1IO(); */
9506 XGI_SetDelayComp(pVBInfo) ;
9507
9508 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9509 XGI_SetLCDCap(pVBInfo) ;
9510
9511 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9512 {
9513 /* GetPart2IO() */
9514 XGI_SetPhaseIncr(pVBInfo) ;
9515 XGI_SetYFilter( ModeNo , ModeIdIndex,pVBInfo ) ;
9516 XGI_SetAntiFlicker( ModeNo , ModeIdIndex,pVBInfo ) ;
9517
9518 if ( pVBInfo->VBType&VB_XGI301)
9519 XGI_SetEdgeEnhance( ModeNo , ModeIdIndex ,pVBInfo) ;
9520 }
9521}
9522
9523
9524/* --------------------------------------------------------------------- */
9525/* Function : XGI_SetDelayComp */
9526/* Input : */
9527/* Output : */
9528/* Description : */
9529/* --------------------------------------------------------------------- */
9530void XGI_SetDelayComp( PVB_DEVICE_INFO pVBInfo )
9531{
9532 USHORT index ;
9533
9534 UCHAR tempah ,
9535 tempbl ,
9536 tempbh ;
9537
9538 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9539 {
9540 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToTV | SetCRT2ToRAMDAC ) )
9541 {
9542 tempbl = 0;
9543 tempbh = 0;
9544
9545 index = XGI_GetTVPtrIndex(pVBInfo ) ; /* Get TV Delay */
9546 tempbl = pVBInfo->XGI_TVDelayList[ index ] ;
9547
9548 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9549 tempbl = pVBInfo->XGI_TVDelayList2[ index ] ;
9550
9551 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9552 tempbl = tempbl >> 4 ;
9553/*
9554 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
9555 tempbl = CRT2Delay1 ; // Get CRT2 Delay
9556
9557 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9558 tempbl = CRT2Delay2 ;
9559*/
9560 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9561 {
9562 index = XGI_GetLCDCapPtr(pVBInfo) ; /* Get LCD Delay */
9563 tempbh=pVBInfo->LCDCapList[ index ].LCD_DelayCompensation ;
9564
9565 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9566 tempbl = tempbh ;
9567 }
9568
9569 tempbl &= 0x0F ;
9570 tempbh &= 0xF0 ;
9571 tempah = XGINew_GetReg1( pVBInfo->Part1Port , 0x2D ) ;
9572
9573 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) /* Channel B */
9574 {
9575 tempah &= 0xF0 ;
9576 tempah |= tempbl ;
9577 }
9578
9579 if ( pVBInfo->VBInfo & SetCRT2ToLCDA ) /* Channel A */
9580 {
9581 tempah &= 0x0F ;
9582 tempah |= tempbh ;
9583 }
9584 XGINew_SetReg1(pVBInfo->Part1Port,0x2D,tempah);
9585 }
9586 }
9587 else if ( pVBInfo->IF_DEF_LVDS == 1 )
9588 {
9589 tempbl = 0;
9590 tempbh = 0;
9591 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9592 {
9593 tempah = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_DelayCompensation ; /* / Get LCD Delay */
9594 tempah &= 0x0f ;
9595 tempah = tempah << 4 ;
9596 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2D , 0x0f , tempah ) ;
9597 }
9598 }
9599}
9600
9601
9602/* --------------------------------------------------------------------- */
9603/* Function : XGI_SetLCDCap */
9604/* Input : */
9605/* Output : */
9606/* Description : */
9607/* --------------------------------------------------------------------- */
9608void XGI_SetLCDCap( PVB_DEVICE_INFO pVBInfo )
9609{
9610 USHORT tempcx ;
9611
9612 tempcx = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_Capability ;
9613
9614 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9615 {
9616 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9617 { /* 301LV/302LV only */
9618 /* Set 301LV Capability */
9619 XGINew_SetReg1( pVBInfo->Part4Port , 0x24 , ( UCHAR )( tempcx & 0x1F ) ) ;
9620 }
9621 /* VB Driving */
9622 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~( ( EnableVBCLKDRVLOW | EnablePLLSPLOW ) >> 8 ) , ( USHORT )( ( tempcx & ( EnableVBCLKDRVLOW | EnablePLLSPLOW ) ) >> 8 ) ) ;
9623 }
9624
9625 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9626 {
9627 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9628 XGI_SetLCDCap_B( tempcx,pVBInfo ) ;
9629 else if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9630 XGI_SetLCDCap_A( tempcx,pVBInfo ) ;
9631
9632 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9633 {
9634 if ( tempcx & EnableSpectrum )
9635 SetSpectrum( pVBInfo) ;
9636 }
9637 }
9638 else /* LVDS,CH7017 */
9639 XGI_SetLCDCap_A( tempcx, pVBInfo ) ;
9640}
9641
9642
9643/* --------------------------------------------------------------------- */
9644/* Function : XGI_SetLCDCap_A */
9645/* Input : */
9646/* Output : */
9647/* Description : */
9648/* --------------------------------------------------------------------- */
9649void XGI_SetLCDCap_A(USHORT tempcx,PVB_DEVICE_INFO pVBInfo)
9650{
9651 USHORT temp ;
9652
9653 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
9654
9655 if ( temp & LCDRGB18Bit )
9656 {
9657 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0x0F , ( USHORT )( 0x20 | ( tempcx & 0x00C0 ) ) ) ; /* Enable Dither */
9658 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x80 ) ;
9659 }
9660 else
9661 {
9662 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0x0F , ( USHORT )( 0x30 | ( tempcx & 0x00C0 ) ) ) ;
9663 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x00 ) ;
9664 }
9665
9666/*
9667 if ( tempcx & EnableLCD24bpp ) // 24bits
9668 {
9669 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(USHORT)(0x30|(tempcx&0x00C0)) );
9670 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x00);
9671 }
9672 else
9673 {
9674 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(USHORT)(0x20|(tempcx&0x00C0)) );//Enable Dither
9675 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x80);
9676 }
9677*/
9678}
9679
9680
9681/* --------------------------------------------------------------------- */
9682/* Function : XGI_SetLCDCap_B */
9683/* Input : cx -> LCD Capability */
9684/* Output : */
9685/* Description : */
9686/* --------------------------------------------------------------------- */
9687void XGI_SetLCDCap_B(USHORT tempcx,PVB_DEVICE_INFO pVBInfo)
9688{
9689 if ( tempcx & EnableLCD24bpp ) /* 24bits */
9690 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1A , 0xE0 , ( USHORT )( ( ( tempcx & 0x00ff ) >> 6 ) | 0x0c ) ) ;
9691 else
9692 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1A , 0xE0 , ( USHORT )( ( ( tempcx & 0x00ff ) >> 6 ) | 0x18 ) ) ; /* Enable Dither */
9693}
9694
9695
9696/* --------------------------------------------------------------------- */
9697/* Function : SetSpectrum */
9698/* Input : */
9699/* Output : */
9700/* Description : */
9701/* --------------------------------------------------------------------- */
9702void SetSpectrum( PVB_DEVICE_INFO pVBInfo )
9703{
9704 USHORT index ;
9705
9706 index = XGI_GetLCDCapPtr(pVBInfo) ;
9707
9708 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x8F ) ; /* disable down spectrum D[4] */
9709 XGI_LongWait(pVBInfo) ;
9710 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x20 ) ; /* reset spectrum */
9711 XGI_LongWait(pVBInfo) ;
9712
9713 XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , pVBInfo->LCDCapList[ index ].Spectrum_31 ) ;
9714 XGINew_SetReg1( pVBInfo->Part4Port , 0x32 , pVBInfo->LCDCapList[ index ].Spectrum_32 ) ;
9715 XGINew_SetReg1( pVBInfo->Part4Port , 0x33 , pVBInfo->LCDCapList[ index ].Spectrum_33 ) ;
9716 XGINew_SetReg1( pVBInfo->Part4Port , 0x34 , pVBInfo->LCDCapList[ index ].Spectrum_34 ) ;
9717 XGI_LongWait(pVBInfo) ;
9718 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x40 ) ; /* enable spectrum */
9719}
9720
9721
9722/* --------------------------------------------------------------------- */
9723/* Function : XGI_SetAntiFlicker */
9724/* Input : */
9725/* Output : */
9726/* Description : Set TV Customized Param. */
9727/* --------------------------------------------------------------------- */
9728void XGI_SetAntiFlicker( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
9729{
9730 USHORT tempbx ,
9731 index ;
9732
9733 UCHAR tempah ;
9734
9735 if (pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
9736 return ;
9737
9738 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9739 tempbx &= 0xFE ;
9740
9741 if ( ModeNo <= 0x13 )
9742 {
9743 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVFlickerIndex ;
9744 }
9745 else
9746 {
9747 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVFlickerIndex ;
9748 }
9749
9750 tempbx += index ;
9751 tempah = TVAntiFlickList[ tempbx ] ;
9752 tempah = tempah << 4 ;
9753
9754 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0x8F , tempah ) ;
9755}
9756
9757
9758/* --------------------------------------------------------------------- */
9759/* Function : XGI_SetEdgeEnhance */
9760/* Input : */
9761/* Output : */
9762/* Description : */
9763/* --------------------------------------------------------------------- */
9764void XGI_SetEdgeEnhance( USHORT ModeNo , USHORT ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
9765{
9766 USHORT tempbx ,
9767 index ;
9768
9769 UCHAR tempah ;
9770
9771
9772 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9773 tempbx &= 0xFE ;
9774
9775 if ( ModeNo <= 0x13 )
9776 {
9777 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVEdgeIndex ;
9778 }
9779 else
9780 {
9781 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVEdgeIndex ;
9782 }
9783
9784 tempbx += index ;
9785 tempah = TVEdgeList[ tempbx ] ;
9786 tempah = tempah << 5 ;
9787
9788 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , tempah ) ;
9789}
9790
9791
9792/* --------------------------------------------------------------------- */
9793/* Function : XGI_SetPhaseIncr */
9794/* Input : */
9795/* Output : */
9796/* Description : */
9797/* --------------------------------------------------------------------- */
9798void XGI_SetPhaseIncr( PVB_DEVICE_INFO pVBInfo )
9799{
9800 USHORT tempbx ;
9801
9802 UCHAR tempcl ,
9803 tempch ;
9804
9805 ULONG tempData ;
9806
9807 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9808 tempData = TVPhaseList[ tempbx ] ;
9809
9810 XGINew_SetReg1( pVBInfo->Part2Port , 0x31 , ( USHORT )( tempData & 0x000000FF ) ) ;
9811 XGINew_SetReg1( pVBInfo->Part2Port , 0x32 , ( USHORT )( ( tempData & 0x0000FF00 ) >> 8 ) ) ;
9812 XGINew_SetReg1( pVBInfo->Part2Port , 0x33 , ( USHORT )( ( tempData & 0x00FF0000 ) >> 16 ) ) ;
9813 XGINew_SetReg1( pVBInfo->Part2Port , 0x34 , ( USHORT )( ( tempData & 0xFF000000 ) >> 24 ) ) ;
9814}
9815
9816
9817/* --------------------------------------------------------------------- */
9818/* Function : XGI_SetYFilter */
9819/* Input : */
9820/* Output : */
9821/* Description : */
9822/* --------------------------------------------------------------------- */
9823void XGI_SetYFilter( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9824{
9825 USHORT tempbx ,
9826 index ;
9827
9828 UCHAR tempcl ,
9829 tempch ,
9830 tempal ,
9831 *filterPtr ;
9832
9833 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9834
9835 switch( tempbx )
9836 {
9837 case 0x00:
9838 case 0x04:
9839 filterPtr = NTSCYFilter1 ;
9840 break ;
9841
9842 case 0x01:
9843 filterPtr = PALYFilter1 ;
9844 break ;
9845
9846 case 0x02:
9847 case 0x05:
9848 case 0x0D:
9849 filterPtr = PALMYFilter1 ;
9850 break ;
9851
9852 case 0x03:
9853 filterPtr = PALNYFilter1 ;
9854 break ;
9855
9856 case 0x08:
9857 case 0x0C:
9858 filterPtr = NTSCYFilter2 ;
9859 break ;
9860
9861 case 0x0A:
9862 filterPtr = PALMYFilter2 ;
9863 break ;
9864
9865 case 0x0B:
9866 filterPtr = PALNYFilter2 ;
9867 break ;
9868
9869 case 0x09:
9870 filterPtr = PALYFilter2 ;
9871 break ;
9872
9873 default:
9874 return ;
9875 }
9876
9877 if ( ModeNo <= 0x13 )
9878 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVYFilterIndex ;
9879 else
9880 tempal = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVYFilterIndex ;
9881
9882 if ( tempcl == 0 )
9883 index = tempal * 4;
9884 else
9885 index = tempal * 7;
9886
9887 if ( ( tempcl == 0 ) && ( tempch == 1 ) )
9888 {
9889 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , 0 ) ;
9890 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , 0 ) ;
9891 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , 0 ) ;
9892 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9893 }
9894 else
9895 {
9896 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , filterPtr[ index++ ] ) ;
9897 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , filterPtr[ index++ ] ) ;
9898 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , filterPtr[ index++ ] ) ;
9899 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9900 }
9901
9902 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9903 {
9904 XGINew_SetReg1( pVBInfo->Part2Port , 0x48 , filterPtr[ index++ ] ) ;
9905 XGINew_SetReg1( pVBInfo->Part2Port , 0x49 , filterPtr[ index++ ] ) ;
9906 XGINew_SetReg1( pVBInfo->Part2Port , 0x4A , filterPtr[ index++ ] ) ;
9907 }
9908}
9909
9910
9911/* --------------------------------------------------------------------- */
9912/* Function : XGI_GetTVPtrIndex2 */
9913/* Input : */
9914/* Output : bx 0 : NTSC */
9915/* 1 : PAL */
9916/* 2 : PALM */
9917/* 3 : PALN */
9918/* 4 : NTSC1024x768 */
9919/* 5 : PAL-M 1024x768 */
9920/* 6-7: reserved */
9921/* cl 0 : YFilter1 */
9922/* 1 : YFilter2 */
9923/* ch 0 : 301A */
9924/* 1 : 301B/302B/301LV/302LV */
9925/* Description : */
9926/* --------------------------------------------------------------------- */
9927void XGI_GetTVPtrIndex2(USHORT* tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo)
9928{
9929 *tempbx = 0 ;
9930 *tempcl = 0 ;
9931 *tempch = 0 ;
9932
9933 if ( pVBInfo->TVInfo & SetPALTV )
9934 *tempbx = 1 ;
9935
9936 if ( pVBInfo->TVInfo & SetPALMTV )
9937 *tempbx = 2 ;
9938
9939 if ( pVBInfo->TVInfo & SetPALNTV )
9940 *tempbx = 3 ;
9941
9942 if ( pVBInfo->TVInfo & NTSC1024x768 )
9943 {
9944 *tempbx = 4 ;
9945 if ( pVBInfo->TVInfo & SetPALMTV )
9946 *tempbx = 5 ;
9947 }
9948
9949 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9950 {
9951 if ( ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) || ( pVBInfo->TVInfo & TVSimuMode ) )
9952 {
9953 *tempbx += 8 ;
9954 *tempcl += 1 ;
9955 }
9956 }
9957
9958 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9959 (*tempch)++ ;
9960}
9961
9962
9963/* --------------------------------------------------------------------- */
9964/* Function : XGI_SetCRT2ModeRegs */
9965/* Input : */
9966/* Output : */
9967/* Description : Origin code for crt2group */
9968/* --------------------------------------------------------------------- */
9969void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
9970{
9971 USHORT tempbl ;
9972 SHORT tempcl ;
9973
9974 UCHAR tempah ;
9975
9976 /* XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , 0x00 ) ; // fix write part1 index 0 BTDRAM bit Bug */
9977 tempah=0;
9978 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9979 {
9980 tempah=XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ;
9981 tempah &= ~0x10 ; /* BTRAMDAC */
9982 tempah |= 0x40 ; /* BTRAM */
9983
9984 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9985 {
9986 tempah=0x40; /* BTDRAM */
9987 if ( ModeNo > 0x13 )
9988 {
9989 tempcl = pVBInfo->ModeType ;
9990 tempcl -= ModeVGA ;
9991 if ( tempcl >= 0 )
9992 {
9993 tempah = ( 0x008 >> tempcl ) ; /* BT Color */
9994 if ( tempah == 0 )
9995 tempah = 1 ;
9996 tempah |= 0x040 ;
9997 }
9998 }
9999 if ( pVBInfo->VBInfo & SetInSlaveMode )
10000 tempah ^= 0x50 ; /* BTDAC */
10001 }
10002 }
10003
10004/* 0210 shampoo
10005 if ( pVBInfo->VBInfo & DisableCRT2Display )
10006 {
10007 tempah = 0 ;
10008 }
10009
10010 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
10011 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
10012 {
10013 tempcl = pVBInfo->ModeType ;
10014 if ( ModeNo > 0x13 )
10015 {
10016 tempcl -= ModeVGA ;
10017 if ( ( tempcl > 0 ) || ( tempcl == 0 ) )
10018 {
10019 tempah=(0x008>>tempcl) ;
10020 if ( tempah == 0 )
10021 tempah = 1 ;
10022 tempah |= 0x040;
10023 }
10024 }
10025 else
10026 {
10027 tempah = 0x040 ;
10028 }
10029
10030 if ( pVBInfo->VBInfo & SetInSlaveMode )
10031 {
10032 tempah = ( tempah ^ 0x050 ) ;
10033 }
10034 }
10035*/
10036
10037 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
10038 tempah = 0x08 ;
10039 tempbl = 0xf0 ;
10040
10041 if ( pVBInfo->VBInfo & DisableCRT2Display )
10042 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
10043 else
10044 {
10045 tempah = 0x00 ;
10046 tempbl = 0xff ;
10047
10048 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
10049 {
10050 if ( ( pVBInfo->VBInfo & SetCRT2ToLCDA ) && ( !( pVBInfo->VBInfo & SetSimuScanMode ) ) )
10051 {
10052 tempbl &= 0xf7 ;
10053 tempah |= 0x01 ;
10054 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
10055 }
10056 else
10057 {
10058 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
10059 {
10060 tempbl &= 0xf7 ;
10061 tempah |= 0x01 ;
10062 }
10063
10064 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
10065 {
10066 tempbl &= 0xf8 ;
10067 tempah = 0x01 ;
10068
10069 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
10070 tempah |= 0x02 ;
10071
10072 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
10073 {
10074 tempah = tempah ^ 0x05 ;
10075 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
10076 tempah = tempah ^ 0x01 ;
10077 }
10078
10079 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
10080 tempah |= 0x08 ;
10081 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
10082 }
10083 else
10084 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
10085 }
10086 }
10087 else
10088 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
10089 }
10090
10091 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
10092 {
10093 tempah &= ( ~0x08 ) ;
10094 if ( ( pVBInfo->ModeType == ModeVGA ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
10095 {
10096 tempah |= 0x010 ;
10097 }
10098 tempah |= 0x080 ;
10099
10100 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10101 {
10102 /* if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) */
10103 /* { */
10104 tempah |= 0x020 ;
10105 if ( ModeNo > 0x13 )
10106 {
10107 if ( pVBInfo->VBInfo & DriverMode )
10108 tempah = tempah ^ 0x20 ;
10109 }
10110 /* } */
10111 }
10112
10113 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~0x0BF , tempah ) ;
10114 tempah = 0 ;
10115
10116 if ( pVBInfo->LCDInfo & SetLCDDualLink )
10117 tempah |= 0x40 ;
10118
10119 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10120 {
10121 /* if ( ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) && ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) ) */
10122 /* { */
10123 if ( pVBInfo->TVInfo & RPLLDIV2XO )
10124 tempah |= 0x40 ;
10125 /* } */
10126 }
10127
10128 if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
10129 tempah |= 0x80 ;
10130
10131 if ( pVBInfo->LCDResInfo == Panel1280x960 )
10132 tempah |= 0x80 ;
10133
10134 XGINew_SetReg1( pVBInfo->Part4Port , 0x0C , tempah ) ;
10135 }
10136
10137 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
10138 {
10139 tempah = 0 ;
10140 tempbl = 0xfb ;
10141
10142 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
10143 {
10144 tempbl=0xff;
10145 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
10146 tempah |= 0x04 ; /* shampoo 0129 */
10147 }
10148
10149 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x13 , tempbl , tempah ) ;
10150 tempah = 0x00 ;
10151 tempbl = 0xcf ;
10152 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
10153 {
10154 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
10155 tempah |= 0x30 ;
10156 }
10157
10158 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2c , tempbl , tempah ) ;
10159 tempah = 0 ;
10160 tempbl = 0x3f ;
10161
10162 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
10163 {
10164 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
10165 tempah |= 0xc0 ;
10166 }
10167 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , tempbl , tempah ) ;
10168 }
10169
10170 tempah = 0 ;
10171 tempbl = 0x7f ;
10172 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
10173 {
10174 tempbl = 0xff ;
10175 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
10176 tempah |= 0x80 ;
10177 }
10178
10179 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x23 , tempbl , tempah ) ;
10180
10181 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
10182 {
10183 if ( pVBInfo->LCDInfo & SetLCDDualLink )
10184 {
10185 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x20 ) ;
10186 XGINew_SetRegOR( pVBInfo->Part4Port , 0x34 , 0x10 ) ;
10187 }
10188 }
10189}
10190
10191
10192/* --------------------------------------------------------------------- */
10193/* Function : XGI_CloseCRTC */
10194/* Input : */
10195/* Output : */
10196/* Description : */
10197/* --------------------------------------------------------------------- */
10198void XGI_CloseCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
10199{
10200 USHORT tempbx ;
10201
10202 tempbx = 0 ;
10203
10204 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
10205 tempbx = 0x08A0 ;
10206
10207
10208}
10209
10210
10211/* --------------------------------------------------------------------- */
10212/* Function : XGI_OpenCRTC */
10213/* Input : */
10214/* Output : */
10215/* Description : */
10216/* --------------------------------------------------------------------- */
10217void XGI_OpenCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
10218{
10219 USHORT tempbx ;
10220
10221 tempbx = 0 ;
10222
10223
10224}
10225
10226
10227/* --------------------------------------------------------------------- */
10228/* Function : XGI_GetRAMDAC2DATA */
10229/* Input : */
10230/* Output : */
10231/* Description : */
10232/* --------------------------------------------------------------------- */
10233void XGI_GetRAMDAC2DATA(USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
10234{
10235 USHORT tempax ,
10236 tempbx ,
10237 temp1 ,
10238 temp2 ,
10239 modeflag = 0 ,
10240 tempcx ,
10241 StandTableIndex ,
10242 CRT1Index ;
10243
10244 pVBInfo->RVBHCMAX = 1 ;
10245 pVBInfo->RVBHCFACT = 1 ;
10246
10247 if ( ModeNo <= 0x13 )
10248 {
10249 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
10250 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
10251 tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 0 ] ;
10252 tempbx = pVBInfo->StandTable[StandTableIndex ].CRTC[ 6 ] ;
10253 temp1 = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ;
10254 }
10255 else
10256 {
10257 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
10258 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
10259 CRT1Index &= IndexMask ;
10260 temp1 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 0 ] ;
10261 temp2 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] ;
10262 tempax = ( temp1 & 0xFF ) | ( ( temp2 & 0x03 ) << 8 ) ;
10263 tempbx = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 8 ] ;
10264 tempcx = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] << 8 ;
10265 tempcx &= 0x0100 ;
10266 tempcx = tempcx << 2 ;
10267 tempbx |= tempcx;
10268 temp1 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
10269 }
10270
10271 if ( temp1 & 0x01 )
10272 tempbx |= 0x0100 ;
10273
10274 if ( temp1 & 0x20 )
10275 tempbx |= 0x0200 ;
10276 tempax += 5 ;
10277
10278 if ( modeflag & Charx8Dot )
10279 tempax *= 8 ;
10280 else
10281 tempax *= 9 ;
10282
10283 pVBInfo->VGAHT = tempax ;
10284 pVBInfo->HT = tempax ;
10285 tempbx++ ;
10286 pVBInfo->VGAVT = tempbx ;
10287 pVBInfo->VT = tempbx ;
10288}
10289
10290
10291
10292/* --------------------------------------------------------------------- */
10293/* Function : XGI_GetColorDepth */
10294/* Input : */
10295/* Output : */
10296/* Description : */
10297/* --------------------------------------------------------------------- */
10298USHORT XGI_GetColorDepth(USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
10299{
10300 USHORT ColorDepth[ 6 ] = { 1 , 2 , 4 , 4 , 6 , 8 } ;
10301 SHORT index ;
10302 USHORT modeflag ;
10303
10304 if ( ModeNo <= 0x13 )
10305 {
10306 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
10307 }
10308 else
10309 {
10310 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
10311 }
10312
10313 index=(modeflag&ModeInfoFlag)-ModeEGA;
10314
10315 if ( index < 0 )
10316 index = 0 ;
10317
10318 return( ColorDepth[ index ] ) ;
10319}
10320
10321
10322
10323/* --------------------------------------------------------------------- */
10324/* Function : XGI_UnLockCRT2 */
10325/* Input : */
10326/* Output : */
10327/* Description : */
10328/* --------------------------------------------------------------------- */
10329void XGI_UnLockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
10330{
10331
10332 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2f , 0xFF , 0x01 ) ;
10333
10334}
10335
10336
10337/* --------------------------------------------------------------------- */
10338/* Function : XGI_LockCRT2 */
10339/* Input : */
10340/* Output : */
10341/* Description : */
10342/* --------------------------------------------------------------------- */
10343void XGI_LockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
10344{
10345
10346 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2F , 0xFE , 0x00 ) ;
10347
10348
10349}
10350
10351
10352/* --------------------------------------------------------------------- */
10353/* Function : XGINew_EnableCRT2 */
10354/* Input : */
10355/* Output : */
10356/* Description : */
10357/* --------------------------------------------------------------------- */
10358void XGINew_EnableCRT2( PVB_DEVICE_INFO pVBInfo)
10359{
10360 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1E , 0xFF , 0x20 ) ;
10361}
10362
10363
10364
10365/* --------------------------------------------------------------------- */
10366/* Function : */
10367/* Input : */
10368/* Output : */
10369/* Description : */
10370/* --------------------------------------------------------------------- */
10371void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo)
10372{
10373 USHORT i ,
10374 j ;
10375
10376 ULONG temp ,
10377 flag ;
10378
10379 flag = 0 ;
10380//printk("XGINew_LCD_Wait_Time");
10381//return;
10382 for( i = 0 ; i < DelayTime ; i++ )
10383 {
10384 for( j = 0 ; j < 66 ; j++ )
10385 {
10386
10387 temp = XGINew_GetReg3( 0x61 ) ;
10388
10389 //temp &= 0x10000000;
10390 temp &= 0x10;
10391 if ( temp == flag )
10392 continue ;
10393
10394 flag = temp ;
10395 }
10396 }
10397}
10398
10399
10400
10401
10402/* --------------------------------------------------------------------- */
10403/* Function : XGI_BridgeIsOn */
10404/* Input : */
10405/* Output : */
10406/* Description : */
10407/* --------------------------------------------------------------------- */
10408BOOLEAN XGI_BridgeIsOn( PVB_DEVICE_INFO pVBInfo )
10409{
10410 USHORT flag ;
10411
10412 if ( pVBInfo->IF_DEF_LVDS == 1 )
10413 {
10414 return( 1 ) ;
10415 }
10416 else
10417 {
10418 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
10419 if ( ( flag == 1 ) || ( flag == 2 ) )
10420 return( 1 ) ; /* 301b */
10421 else
10422 return( 0 ) ;
10423 }
10424}
10425
10426
10427
10428/* --------------------------------------------------------------------- */
10429/* Function : XGI_LongWait */
10430/* Input : */
10431/* Output : */
10432/* Description : */
10433/* --------------------------------------------------------------------- */
10434void XGI_LongWait(PVB_DEVICE_INFO pVBInfo)
10435{
10436 USHORT i ;
10437
10438 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
10439
10440 if ( !( i & 0xC0 ) )
10441 {
10442 for( i = 0 ; i < 0xFFFF ; i++ )
10443 {
10444 if ( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10445 break ;
10446 }
10447
10448 for( i = 0 ; i < 0xFFFF ; i++ )
10449 {
10450 if ( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10451 break ;
10452 }
10453 }
10454}
10455
10456
10457/* --------------------------------------------------------------------- */
10458/* Function : XGI_VBLongWait */
10459/* Input : */
10460/* Output : */
10461/* Description : */
10462/* --------------------------------------------------------------------- */
10463void XGI_VBLongWait( PVB_DEVICE_INFO pVBInfo )
10464{
10465 USHORT tempal ,
10466 temp ,
10467 i ,
10468 j ;
10469return ;
10470 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
10471 {
10472 temp = 0 ;
10473 for( i = 0 ; i < 3 ; i++ )
10474 {
10475 for( j = 0 ; j < 100 ; j++ )
10476 {
10477 tempal = XGINew_GetReg2( pVBInfo->P3da ) ;
10478 if ( temp & 0x01 )
10479 { /* VBWaitMode2 */
10480 if ( ( tempal & 0x08 ) )
10481 {
10482 continue ;
10483 }
10484
10485 if ( !( tempal & 0x08 ) )
10486 {
10487 break ;
10488 }
10489 }
10490 else
10491 { /* VBWaitMode1 */
10492 if ( !( tempal & 0x08 ) )
10493 {
10494 continue ;
10495 }
10496
10497 if ( ( tempal & 0x08 ) )
10498 {
10499 break ;
10500 }
10501 }
10502 }
10503 temp = temp ^ 0x01 ;
10504 }
10505 }
10506 else
10507 {
10508 XGI_LongWait(pVBInfo) ;
10509 }
10510 return ;
10511}
10512
10513
10514
10515
10516/* --------------------------------------------------------------------- */
10517/* Function : XGI_GetVGAHT2 */
10518/* Input : */
10519/* Output : */
10520/* Description : */
10521/* --------------------------------------------------------------------- */
10522USHORT XGI_GetVGAHT2( PVB_DEVICE_INFO pVBInfo )
10523{
10524 ULONG tempax ,
10525 tempbx ;
10526
10527 tempbx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) * pVBInfo->RVBHCMAX ) & 0xFFFF ;
10528 tempax = ( pVBInfo->VT - pVBInfo->VDE ) * pVBInfo->RVBHCFACT ;
10529 tempax = ( tempax * pVBInfo->HT ) /tempbx ;
10530
10531 return( ( USHORT )tempax ) ;
10532}
10533
10534
10535/* --------------------------------------------------------------------- */
10536/* Function : XGI_GetVCLK2Ptr */
10537/* Input : */
10538/* Output : */
10539/* Description : */
10540/* --------------------------------------------------------------------- */
10541USHORT XGI_GetVCLK2Ptr( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension ,PVB_DEVICE_INFO pVBInfo)
10542{
10543 USHORT tempbx ;
10544
10545 USHORT LCDXlat1VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10546 USHORT LCDXlat2VCLK[ 4 ] = { VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 } ;
10547 USHORT LVDSXlat1VCLK[ 4 ] = { VCLK40 , VCLK40 , VCLK40 , VCLK40 } ;
10548 USHORT LVDSXlat2VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10549 USHORT LVDSXlat3VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10550
10551 USHORT CRT2Index , VCLKIndex ;
10552 USHORT modeflag , resinfo ;
10553 UCHAR *CHTVVCLKPtr = NULL ;
10554
10555 if ( ModeNo <= 0x13 )
10556 {
10557 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
10558 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
10559 CRT2Index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
10560 }
10561 else
10562 {
10563 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
10564 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
10565 CRT2Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
10566 }
10567
10568 if ( pVBInfo->IF_DEF_LVDS == 0 )
10569 {
10570 CRT2Index = CRT2Index >> 6 ; /* for LCD */
10571 if ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) /*301b*/
10572 {
10573 if ( pVBInfo->LCDResInfo != Panel1024x768 )
10574 {
10575 VCLKIndex = LCDXlat2VCLK[ CRT2Index ] ;
10576 }
10577 else
10578 {
10579 VCLKIndex = LCDXlat1VCLK[ CRT2Index ] ;
10580 }
10581 }
10582 else /* for TV */
10583 {
10584 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10585 {
10586 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
10587 {
10588 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10589 {
10590 VCLKIndex = HiTVVCLKDIV2 ;
10591
10592
10593 VCLKIndex += 25 ;
10594
10595 }
10596 else
10597 {
10598 VCLKIndex = HiTVVCLK ;
10599
10600
10601 VCLKIndex += 25 ;
10602
10603 }
10604
10605 if ( pVBInfo->SetFlag & TVSimuMode )
10606 {
10607 if( modeflag & Charx8Dot )
10608 {
10609 VCLKIndex = HiTVSimuVCLK ;
10610
10611
10612 VCLKIndex += 25 ;
10613
10614 }
10615 else
10616 {
10617 VCLKIndex = HiTVTextVCLK ;
10618
10619
10620 VCLKIndex += 25 ;
10621
10622 }
10623 }
10624
10625 if ( pVBInfo->VBType & VB_XGI301LV ) /* 301lv */
10626 {
10627 if ( !( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
10628 {
10629 VCLKIndex = YPbPr750pVCLK ;
10630 if ( !( pVBInfo->VBExtInfo == VB_YPbPr750p ) )
10631 {
10632 VCLKIndex = YPbPr525pVCLK ;
10633 if ( !( pVBInfo->VBExtInfo == VB_YPbPr525p ) )
10634 {
10635 VCLKIndex = YPbPr525iVCLK_2 ;
10636 if ( !( pVBInfo->SetFlag & RPLLDIV2XO ) )
10637 VCLKIndex = YPbPr525iVCLK ;
10638 }
10639 }
10640 }
10641 }
10642 }
10643 else
10644 {
10645 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10646 {
10647 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10648 {
10649 VCLKIndex = TVVCLKDIV2 ;
10650
10651
10652 VCLKIndex += 25 ;
10653
10654 }
10655 else
10656 {
10657 VCLKIndex = TVVCLK ;
10658
10659
10660 VCLKIndex += 25 ;
10661
10662 }
10663 }
10664 }
10665 }
10666 else
10667 { /* for CRT2 */
10668 VCLKIndex = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ; /* Port 3cch */
10669 VCLKIndex = ( ( VCLKIndex >> 2 ) & 0x03 ) ;
10670 if ( ModeNo > 0x13 )
10671 {
10672 VCLKIndex = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ; /* di+Ext_CRTVCLK */
10673 VCLKIndex &= IndexMask ;
10674 }
10675 }
10676 }
10677 }
10678 else
10679 { /* LVDS */
10680 if ( ModeNo <= 0x13 )
10681 VCLKIndex = CRT2Index ;
10682 else
10683 VCLKIndex = CRT2Index ;
10684
10685 if ( pVBInfo->IF_DEF_CH7005 == 1 )
10686 {
10687 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
10688 {
10689 VCLKIndex &= 0x1f ;
10690 tempbx = 0 ;
10691
10692 if ( pVBInfo->VBInfo & SetPALTV )
10693 tempbx += 2 ;
10694
10695 if ( pVBInfo->VBInfo & SetCHTVOverScan )
10696 tempbx += 1 ;
10697
10698 switch( tempbx )
10699 {
10700 case 0:
10701 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
10702 break ;
10703 case 1:
10704 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
10705 break;
10706 case 2:
10707 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
10708 break ;
10709 case 3:
10710 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
10711 break ;
10712 default:
10713 break ;
10714 }
10715
10716 VCLKIndex = CHTVVCLKPtr[ VCLKIndex ] ;
10717 }
10718 }
10719 else
10720 {
10721 VCLKIndex = VCLKIndex >> 6 ;
10722 if ( ( pVBInfo->LCDResInfo == Panel800x600 ) || ( pVBInfo->LCDResInfo == Panel320x480 ) )
10723 VCLKIndex = LVDSXlat1VCLK[ VCLKIndex ] ;
10724 else if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
10725 VCLKIndex = LVDSXlat2VCLK[ VCLKIndex ] ;
10726 else
10727 VCLKIndex = LVDSXlat3VCLK[ VCLKIndex ] ;
10728 }
10729 }
10730 /* VCLKIndex = VCLKIndex&IndexMask ; */
10731
10732
10733
10734 return( VCLKIndex ) ;
10735}
10736
diff --git a/drivers/staging/xgifb/vb_setmode.h b/drivers/staging/xgifb/vb_setmode.h
new file mode 100644
index 00000000000..09753d70666
--- /dev/null
+++ b/drivers/staging/xgifb/vb_setmode.h
@@ -0,0 +1,40 @@
1#ifndef _VBSETMODE_
2#define _VBSETMODE_
3
4extern void InitTo330Pointer(UCHAR,PVB_DEVICE_INFO);
5extern void XGI_UnLockCRT2(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
6extern void XGI_LockCRT2(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
7extern void XGI_LongWait( PVB_DEVICE_INFO );
8extern void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO );
9extern void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
10extern void XGI_EnableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
11extern void XGI_DisplayOff( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO );
12extern void XGI_DisplayOn( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO );
13extern void XGI_GetVBType(PVB_DEVICE_INFO);
14extern void XGI_SenseCRT1(PVB_DEVICE_INFO );
15extern void XGI_GetVGAType(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
16extern void XGI_GetVBInfo(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
17extern void XGI_GetTVInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO );
18extern void XGI_SetCRT1Offset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
19extern void XGI_SetLCDAGroup(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
20extern void XGI_WaitDisply( PVB_DEVICE_INFO );
21extern USHORT XGI_GetResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
22
23extern BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo ) ;
24
25extern BOOLEAN XGI_SearchModeID( USHORT ModeNo,USHORT *ModeIdIndex, PVB_DEVICE_INFO );
26extern BOOLEAN XGI_GetLCDInfo(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO );
27extern BOOLEAN XGI_BridgeIsOn( PVB_DEVICE_INFO );
28extern BOOLEAN XGI_SetCRT2Group301(USHORT ModeNo, PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO);
29extern USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO );
30
31extern void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo);
32extern void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo);
33extern void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
34extern void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
35extern void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
36extern BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
37extern void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
38extern USHORT XGI_GetLVDSOEMTableIndex(PVB_DEVICE_INFO pVBInfo);
39
40#endif
diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h
new file mode 100644
index 00000000000..bb25c0e2785
--- /dev/null
+++ b/drivers/staging/xgifb/vb_struct.h
@@ -0,0 +1,534 @@
1#ifndef _VB_STRUCT_
2#define _VB_STRUCT_
3
4#ifdef _INITNEW_
5#define EXTERN
6#else
7#define EXTERN extern
8#endif
9
10
11
12
13typedef struct _XGI_PanelDelayTblStruct
14{
15 UCHAR timer[2];
16} XGI_PanelDelayTblStruct;
17
18typedef struct _XGI_LCDDataStruct
19{
20 USHORT RVBHCMAX;
21 USHORT RVBHCFACT;
22 USHORT VGAHT;
23 USHORT VGAVT;
24 USHORT LCDHT;
25 USHORT LCDVT;
26} XGI_LCDDataStruct;
27
28
29typedef struct _XGI_LVDSCRT1HDataStruct
30{
31 UCHAR Reg[8];
32} XGI_LVDSCRT1HDataStruct;
33typedef struct _XGI_LVDSCRT1VDataStruct
34{
35 UCHAR Reg[7];
36} XGI_LVDSCRT1VDataStruct;
37
38
39typedef struct _XGI_TVDataStruct
40{
41 USHORT RVBHCMAX;
42 USHORT RVBHCFACT;
43 USHORT VGAHT;
44 USHORT VGAVT;
45 USHORT TVHDE;
46 USHORT TVVDE;
47 USHORT RVBHRS;
48 UCHAR FlickerMode;
49 USHORT HALFRVBHRS;
50 UCHAR RY1COE;
51 UCHAR RY2COE;
52 UCHAR RY3COE;
53 UCHAR RY4COE;
54} XGI_TVDataStruct;
55
56typedef struct _XGI_LVDSDataStruct
57{
58 USHORT VGAHT;
59 USHORT VGAVT;
60 USHORT LCDHT;
61 USHORT LCDVT;
62} XGI_LVDSDataStruct;
63
64typedef struct _XGI_LVDSDesStruct
65{
66 USHORT LCDHDES;
67 USHORT LCDVDES;
68} XGI_LVDSDesStruct;
69
70typedef struct _XGI_LVDSCRT1DataStruct
71{
72 UCHAR CR[15];
73} XGI_LVDSCRT1DataStruct;
74
75/*add for LCDA*/
76
77
78typedef struct _XGI_StStruct
79{
80 UCHAR St_ModeID;
81 USHORT St_ModeFlag;
82 UCHAR St_StTableIndex;
83 UCHAR St_CRT2CRTC;
84 UCHAR St_CRT2CRTC2;
85 UCHAR St_ResInfo;
86 UCHAR VB_StTVFlickerIndex;
87 UCHAR VB_StTVEdgeIndex;
88 UCHAR VB_StTVYFilterIndex;
89} XGI_StStruct;
90
91typedef struct _XGI_StandTableStruct
92{
93 UCHAR CRT_COLS;
94 UCHAR ROWS;
95 UCHAR CHAR_HEIGHT;
96 USHORT CRT_LEN;
97 UCHAR SR[4];
98 UCHAR MISC;
99 UCHAR CRTC[0x19];
100 UCHAR ATTR[0x14];
101 UCHAR GRC[9];
102} XGI_StandTableStruct;
103
104typedef struct _XGI_ExtStruct
105{
106 UCHAR Ext_ModeID;
107 USHORT Ext_ModeFlag;
108 USHORT Ext_ModeInfo;
109 USHORT Ext_Point;
110 USHORT Ext_VESAID;
111 UCHAR Ext_VESAMEMSize;
112 UCHAR Ext_RESINFO;
113 UCHAR VB_ExtTVFlickerIndex;
114 UCHAR VB_ExtTVEdgeIndex;
115 UCHAR VB_ExtTVYFilterIndex;
116 UCHAR REFindex;
117} XGI_ExtStruct;
118
119typedef struct _XGI_Ext2Struct
120{
121 USHORT Ext_InfoFlag;
122 UCHAR Ext_CRT1CRTC;
123 UCHAR Ext_CRTVCLK;
124 UCHAR Ext_CRT2CRTC;
125 UCHAR Ext_CRT2CRTC2;
126 UCHAR ModeID;
127 USHORT XRes;
128 USHORT YRes;
129 /* USHORT ROM_OFFSET; */
130} XGI_Ext2Struct;
131
132
133typedef struct _XGI_MCLKDataStruct
134{
135 UCHAR SR28,SR29,SR2A;
136 USHORT CLOCK;
137} XGI_MCLKDataStruct;
138
139typedef struct _XGI_ECLKDataStruct
140{
141 UCHAR SR2E,SR2F,SR30;
142 USHORT CLOCK;
143} XGI_ECLKDataStruct;
144
145typedef struct _XGI_VCLKDataStruct
146{
147 UCHAR SR2B,SR2C;
148 USHORT CLOCK;
149} XGI_VCLKDataStruct;
150
151typedef struct _XGI_VBVCLKDataStruct
152{
153 UCHAR Part4_A,Part4_B;
154 USHORT CLOCK;
155} XGI_VBVCLKDataStruct;
156
157typedef struct _XGI_StResInfoStruct
158{
159 USHORT HTotal;
160 USHORT VTotal;
161} XGI_StResInfoStruct;
162
163typedef struct _XGI_ModeResInfoStruct
164{
165 USHORT HTotal;
166 USHORT VTotal;
167 UCHAR XChar;
168 UCHAR YChar;
169} XGI_ModeResInfoStruct;
170
171typedef struct _XGI_LCDNBDesStruct
172{
173 UCHAR NB[12];
174} XGI_LCDNBDesStruct;
175 /*add for new UNIVGABIOS*/
176typedef struct _XGI_LCDDesStruct
177{
178 USHORT LCDHDES;
179 USHORT LCDHRS;
180 USHORT LCDVDES;
181 USHORT LCDVRS;
182} XGI_LCDDesStruct;
183
184typedef struct _XGI_LCDDataTablStruct
185{
186 UCHAR PANELID;
187 USHORT MASK;
188 USHORT CAP;
189 USHORT DATAPTR;
190} XGI_LCDDataTablStruct;
191
192typedef struct _XGI_TVTablDataStruct
193{
194 USHORT MASK;
195 USHORT CAP;
196 USHORT DATAPTR;
197} XGI_TVDataTablStruct;
198
199typedef struct _XGI330_LCDDesDataStruct
200{
201 USHORT LCDHDES;
202 USHORT LCDHRS;
203 USHORT LCDVDES;
204 USHORT LCDVRS;
205} XGI330_LCDDataDesStruct;
206
207
208typedef struct _XGI330_LVDSDataStruct
209{
210 USHORT VGAHT;
211 USHORT VGAVT;
212 USHORT LCDHT;
213 USHORT LCDVT;
214} XGI330_LVDSDataStruct;
215
216typedef struct _XGI330_LCDDesDataStruct2
217{
218 USHORT LCDHDES;
219 USHORT LCDHRS;
220 USHORT LCDVDES;
221 USHORT LCDVRS;
222 USHORT LCDHSync;
223 USHORT LCDVSync;
224} XGI330_LCDDataDesStruct2;
225
226typedef struct _XGI330_LCDDataStruct
227{
228 USHORT RVBHCMAX;
229 USHORT RVBHCFACT;
230 USHORT VGAHT;
231 USHORT VGAVT;
232 USHORT LCDHT;
233 USHORT LCDVT;
234} XGI330_LCDDataStruct;
235
236
237typedef struct _XGI330_TVDataStruct
238{
239 USHORT RVBHCMAX;
240 USHORT RVBHCFACT;
241 USHORT VGAHT;
242 USHORT VGAVT;
243 USHORT TVHDE;
244 USHORT TVVDE;
245 USHORT RVBHRS;
246 UCHAR FlickerMode;
247 USHORT HALFRVBHRS;
248} XGI330_TVDataStruct;
249
250typedef struct _XGI330_LCDDataTablStruct
251{
252 UCHAR PANELID;
253 USHORT MASK;
254 USHORT CAP;
255 USHORT DATAPTR;
256} XGI330_LCDDataTablStruct;
257
258typedef struct _XGI330_TVDataTablStruct
259{
260 USHORT MASK;
261 USHORT CAP;
262 USHORT DATAPTR;
263} XGI330_TVDataTablStruct;
264
265
266typedef struct _XGI330_CHTVDataStruct
267{
268 USHORT VGAHT;
269 USHORT VGAVT;
270 USHORT LCDHT;
271 USHORT LCDVT;
272} XGI330_CHTVDataStruct;
273
274typedef struct _XGI_TimingHStruct
275{
276 UCHAR data[8];
277} XGI_TimingHStruct;
278
279typedef struct _XGI_TimingVStruct
280{
281 UCHAR data[7];
282} XGI_TimingVStruct;
283
284typedef struct _XGI_CH7007TV_TimingHStruct
285{
286 UCHAR data[10];
287} XGI_CH7007TV_TimingHStruct;
288
289typedef struct _XGI_CH7007TV_TimingVStruct
290{
291 UCHAR data[10];
292} XGI_CH7007TV_TimingVStruct;
293
294typedef struct _XGI_XG21CRT1Struct
295{
296 UCHAR ModeID,CR02,CR03,CR15,CR16;
297} XGI_XG21CRT1Struct;
298
299typedef struct _XGI330_CHTVRegDataStruct
300{
301 UCHAR Reg[16];
302} XGI330_CHTVRegDataStruct;
303
304typedef struct _XGI330_LCDCapStruct
305{
306 UCHAR LCD_ID;
307 USHORT LCD_Capability;
308 UCHAR LCD_SetFlag;
309 UCHAR LCD_DelayCompensation;
310 UCHAR LCD_HSyncWidth;
311 UCHAR LCD_VSyncWidth;
312 UCHAR LCD_VCLK;
313 UCHAR LCDA_VCLKData1;
314 UCHAR LCDA_VCLKData2;
315 UCHAR LCUCHAR_VCLKData1;
316 UCHAR LCUCHAR_VCLKData2;
317 UCHAR PSC_S1;
318 UCHAR PSC_S2;
319 UCHAR PSC_S3;
320 UCHAR PSC_S4;
321 UCHAR PSC_S5;
322 UCHAR PWD_2B;
323 UCHAR PWD_2C;
324 UCHAR PWD_2D;
325 UCHAR PWD_2E;
326 UCHAR PWD_2F;
327 UCHAR Spectrum_31;
328 UCHAR Spectrum_32;
329 UCHAR Spectrum_33;
330 UCHAR Spectrum_34;
331} XGI330_LCDCapStruct;
332
333typedef struct _XGI21_LVDSCapStruct
334{
335 USHORT LVDS_Capability;
336 USHORT LVDSHT;
337 USHORT LVDSVT;
338 USHORT LVDSHDE;
339 USHORT LVDSVDE;
340 USHORT LVDSHFP;
341 USHORT LVDSVFP;
342 USHORT LVDSHSYNC;
343 USHORT LVDSVSYNC;
344 UCHAR VCLKData1;
345 UCHAR VCLKData2;
346 UCHAR PSC_S1;
347 UCHAR PSC_S2;
348 UCHAR PSC_S3;
349 UCHAR PSC_S4;
350 UCHAR PSC_S5;
351} XGI21_LVDSCapStruct;
352
353typedef struct _XGI_CRT1TableStruct
354{
355 UCHAR CR[16];
356} XGI_CRT1TableStruct;
357
358
359typedef struct _XGI330_VCLKDataStruct
360{
361 UCHAR SR2B,SR2C;
362 USHORT CLOCK;
363} XGI330_VCLKDataStruct;
364
365typedef struct _XGI301C_Tap4TimingStruct
366{
367 USHORT DE;
368 UCHAR Reg[64]; /* C0-FF */
369} XGI301C_Tap4TimingStruct;
370
371typedef struct _XGI_New_StandTableStruct
372{
373 UCHAR CRT_COLS;
374 UCHAR ROWS;
375 UCHAR CHAR_HEIGHT;
376 USHORT CRT_LEN;
377 UCHAR SR[4];
378 UCHAR MISC;
379 UCHAR CRTC[0x19];
380 UCHAR ATTR[0x14];
381 UCHAR GRC[9];
382} XGI_New_StandTableStruct;
383
384typedef UCHAR DRAM8Type[8];
385typedef UCHAR DRAM4Type[4];
386typedef UCHAR DRAM32Type[32];
387typedef UCHAR DRAM2Type[2];
388
389typedef struct _VB_DEVICE_INFO VB_DEVICE_INFO;
390typedef VB_DEVICE_INFO * PVB_DEVICE_INFO;
391
392struct _VB_DEVICE_INFO
393{
394 BOOLEAN ISXPDOS;
395 ULONG P3c4,P3d4,P3c0,P3ce,P3c2,P3cc;
396 ULONG P3ca,P3c6,P3c7,P3c8,P3c9,P3da;
397 ULONG Part0Port,Part1Port,Part2Port;
398 ULONG Part3Port,Part4Port,Part5Port;
399 USHORT RVBHCFACT,RVBHCMAX,RVBHRS;
400 USHORT VGAVT,VGAHT,VGAVDE,VGAHDE;
401 USHORT VT,HT,VDE,HDE;
402 USHORT LCDHRS,LCDVRS,LCDHDES,LCDVDES;
403
404 USHORT ModeType;
405 USHORT IF_DEF_LVDS,IF_DEF_TRUMPION,IF_DEF_DSTN;/* ,IF_DEF_FSTN; add for dstn */
406 USHORT IF_DEF_CRT2Monitor,IF_DEF_VideoCapture;
407 USHORT IF_DEF_LCDA,IF_DEF_CH7017,IF_DEF_YPbPr,IF_DEF_ScaleLCD,IF_DEF_OEMUtil,IF_DEF_PWD;
408 USHORT IF_DEF_ExpLink;
409 USHORT IF_DEF_CH7005,IF_DEF_HiVision;
410 USHORT IF_DEF_CH7007; /* Billy 2007/05/03 */
411 USHORT LCDResInfo,LCDTypeInfo, VBType;/*301b*/
412 USHORT VBInfo,TVInfo,LCDInfo, Set_VGAType;
413 USHORT VBExtInfo;/*301lv*/
414 USHORT SetFlag;
415 USHORT NewFlickerMode;
416 USHORT SelectCRT2Rate;
417
418 PUCHAR ROMAddr;
419 PUCHAR FBAddr;
420 ULONG BaseAddr;
421 ULONG RelIO;
422
423 DRAM4Type *CR6B;
424 DRAM4Type *CR6E;
425 DRAM32Type *CR6F;
426 DRAM2Type *CR89;
427
428 DRAM8Type *SR15; /* pointer : point to array */
429 DRAM8Type *CR40;
430 UCHAR *pSoftSetting;
431 UCHAR *pOutputSelect;
432
433 USHORT *pRGBSenseData;
434 USHORT *pRGBSenseData2; /*301b*/
435 USHORT *pVideoSenseData;
436 USHORT *pVideoSenseData2;
437 USHORT *pYCSenseData;
438 USHORT *pYCSenseData2;
439
440 UCHAR *pSR07;
441 UCHAR *CR49;
442 UCHAR *pSR1F;
443 UCHAR *AGPReg;
444 UCHAR *SR16;
445 UCHAR *pSR21;
446 UCHAR *pSR22;
447 UCHAR *pSR23;
448 UCHAR *pSR24;
449 UCHAR *SR25;
450 UCHAR *pSR31;
451 UCHAR *pSR32;
452 UCHAR *pSR33;
453 UCHAR *pSR36; /* alan 12/07/2006 */
454 UCHAR *pCRCF;
455 UCHAR *pCRD0; /* alan 12/07/2006 */
456 UCHAR *pCRDE; /* alan 12/07/2006 */
457 UCHAR *pCR8F; /* alan 12/07/2006 */
458 UCHAR *pSR40; /* alan 12/07/2006 */
459 UCHAR *pSR41; /* alan 12/07/2006 */
460 UCHAR *pDVOSetting;
461 UCHAR *pCR2E;
462 UCHAR *pCR2F;
463 UCHAR *pCR46;
464 UCHAR *pCR47;
465 UCHAR *pCRT2Data_1_2;
466 UCHAR *pCRT2Data_4_D;
467 UCHAR *pCRT2Data_4_E;
468 UCHAR *pCRT2Data_4_10;
469 XGI_MCLKDataStruct *MCLKData;
470 XGI_ECLKDataStruct *ECLKData;
471
472 UCHAR *XGI_TVDelayList;
473 UCHAR *XGI_TVDelayList2;
474 UCHAR *CHTVVCLKUNTSC;
475 UCHAR *CHTVVCLKONTSC;
476 UCHAR *CHTVVCLKUPAL;
477 UCHAR *CHTVVCLKOPAL;
478 UCHAR *NTSCTiming;
479 UCHAR *PALTiming;
480 UCHAR *HiTVExtTiming;
481 UCHAR *HiTVSt1Timing;
482 UCHAR *HiTVSt2Timing;
483 UCHAR *HiTVTextTiming;
484 UCHAR *YPbPr750pTiming;
485 UCHAR *YPbPr525pTiming;
486 UCHAR *YPbPr525iTiming;
487 UCHAR *HiTVGroup3Data;
488 UCHAR *HiTVGroup3Simu;
489 UCHAR *HiTVGroup3Text;
490 UCHAR *Ren525pGroup3;
491 UCHAR *Ren750pGroup3;
492 UCHAR *ScreenOffset;
493 UCHAR *pXGINew_DRAMTypeDefinition;
494 UCHAR *pXGINew_I2CDefinition ;
495 UCHAR *pXGINew_CR97 ;
496
497 XGI330_LCDCapStruct *LCDCapList;
498 XGI21_LVDSCapStruct *XG21_LVDSCapList;
499
500 XGI_TimingHStruct *TimingH;
501 XGI_TimingVStruct *TimingV;
502
503 XGI_StStruct *SModeIDTable;
504 XGI_StandTableStruct *StandTable;
505 XGI_ExtStruct *EModeIDTable;
506 XGI_Ext2Struct *RefIndex;
507 /* XGINew_CRT1TableStruct *CRT1Table; */
508 XGI_CRT1TableStruct *XGINEWUB_CRT1Table;
509 XGI_VCLKDataStruct *VCLKData;
510 XGI_VBVCLKDataStruct *VBVCLKData;
511 XGI_StResInfoStruct *StResInfo;
512 XGI_ModeResInfoStruct *ModeResInfo;
513 XGI_XG21CRT1Struct *UpdateCRT1;
514}; /* _VB_DEVICE_INFO */
515
516
517typedef struct
518{
519 USHORT Horizontal_ACTIVE;
520 USHORT Horizontal_FP;
521 USHORT Horizontal_SYNC;
522 USHORT Horizontal_BP;
523 USHORT Vertical_ACTIVE;
524 USHORT Vertical_FP;
525 USHORT Vertical_SYNC;
526 USHORT Vertical_BP;
527 double DCLK;
528 UCHAR FrameRate;
529 UCHAR Interlace;
530 USHORT Margin;
531} TimingInfo;
532
533#define _VB_STRUCT_
534#endif /* _VB_STRUCT_ */
diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h
new file mode 100644
index 00000000000..781caefc56b
--- /dev/null
+++ b/drivers/staging/xgifb/vb_table.h
@@ -0,0 +1,4406 @@
1#define Tap4
2
3
4XGI_MCLKDataStruct XGI330New_MCLKData[]=
5{
6 { 0x5c,0x23,0x01,166},
7 { 0x5c,0x23,0x01,166},
8 { 0x7C,0x08,0x80,200},
9 { 0x79,0x06,0x80,250},
10 { 0x29,0x01,0x81,300},
11 { 0x29,0x01,0x81,300},
12 { 0x29,0x01,0x81,300},
13 { 0x29,0x01,0x81,300}
14};
15//yilin modify for xgi20
16XGI_MCLKDataStruct XGI340New_MCLKData[]=
17{
18 { 0x16,0x01,0x01,166},
19 { 0x19,0x02,0x01,124},
20 { 0x7C,0x08,0x01,200},
21 { 0x79,0x06,0x01,250},
22 { 0x29,0x01,0x81,301},
23 { 0x5c,0x23,0x01,166},
24 { 0x5c,0x23,0x01,166},
25 { 0x5c,0x23,0x01,166}
26};
27
28XGI_MCLKDataStruct XGI27New_MCLKData[]=
29{
30 { 0x5c,0x23,0x01,166},
31 { 0x19,0x02,0x01,124},
32 { 0x7C,0x08,0x80,200},
33 { 0x79,0x06,0x80,250},
34 { 0x29,0x01,0x81,300},
35 { 0x5c,0x23,0x01,166},
36 { 0x5c,0x23,0x01,166},
37 { 0x5c,0x23,0x01,166}
38};
39
40XGI_ECLKDataStruct XGI330_ECLKData[]=
41{
42 { 0x7c,0x08,0x01,200},
43 { 0x7c,0x08,0x01,200},
44 { 0x7C,0x08,0x80,200},
45 { 0x79,0x06,0x80,250},
46 { 0x29,0x01,0x81,300},
47 { 0x29,0x01,0x81,300},
48 { 0x29,0x01,0x81,300},
49 { 0x29,0x01,0x81,300}
50};
51//yilin modify for xgi20
52XGI_ECLKDataStruct XGI340_ECLKData[]=
53{
54 { 0x5c,0x23,0x01,166},
55 { 0x55,0x84,0x01,123},
56 { 0x7C,0x08,0x01,200},
57 { 0x79,0x06,0x01,250},
58 { 0x29,0x01,0x81,301},
59 { 0x5c,0x23,0x01,166},
60 { 0x5c,0x23,0x01,166},
61 { 0x5c,0x23,0x01,166}
62};
63
64
65
66UCHAR XGI340_SR13[4][8]={
67{0x35,0x45,0xb1,0x00,0x00,0x00,0x00,0x00},/* SR13 */
68{0x41,0x51,0x5c,0x00,0x00,0x00,0x00,0x00},/* SR14 */
69{0x31,0x42,0x42,0x00,0x00,0x00,0x00,0x00},/* SR18 */
70{0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00}/* SR1B */
71};
72
73UCHAR XGI340_cr41[24][8]=
74{{0x20,0x50,0x60,0x00,0x00,0x00,0x00,0x00},/* 0 CR41 */
75{0xc4,0x40,0x84,0x00,0x00,0x00,0x00,0x00},/* 1 CR8A */
76{0xc4,0x40,0x84,0x00,0x00,0x00,0x00,0x00},/* 2 CR8B */
77{0xb5,0xa4,0xa4,0x00,0x00,0x00,0x00,0x00},
78{0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00,0x00},
79{0x90,0x90,0x24,0x00,0x00,0x00,0x00,0x00},/* 5 CR68 */
80{0x77,0x77,0x44,0x00,0x00,0x00,0x00,0x00},/* 6 CR69 */
81{0x77,0x77,0x44,0x00,0x00,0x00,0x00,0x00},/* 7 CR6A */
82{0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00},/* 8 CR6D */
83{0x55,0x55,0x55,0x00,0x00,0x00,0x00,0x00},/* 9 CR80 */
84{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/* 10 CR81 */
85{0x88,0xa8,0x48,0x00,0x00,0x00,0x00,0x00},/* 11 CR82 */
86{0x44,0x44,0x77,0x00,0x00,0x00,0x00,0x00},/* 12 CR85 */
87{0x48,0x48,0x88,0x00,0x00,0x00,0x00,0x00},/* 13 CR86 */
88{0x54,0x54,0x44,0x00,0x00,0x00,0x00,0x00},/* 14 CR90 */
89{0x54,0x54,0x44,0x00,0x00,0x00,0x00,0x00},/* 15 CR91 */
90{0x0a,0x0a,0x07,0x00,0x00,0x00,0x00,0x00},/* 16 CR92 */
91{0x44,0x44,0x44,0x00,0x00,0x00,0x00,0x00},/* 17 CR93 */
92{0x10,0x10,0x0A,0x00,0x00,0x00,0x00,0x00},/* 18 CR94 */
93{0x11,0x11,0x0a,0x00,0x00,0x00,0x00,0x00},/* 19 CR95 */
94{0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00},/* 20 CR96 */
95{0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00,0x00},/* 21 CRC3 */
96{0x05,0x00,0x02,0x00,0x00,0x00,0x00,0x00},/* 22 CRC4 */
97{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}/* 23 CRC5 */
98};
99
100
101UCHAR XGI27_cr41[24][8]=
102{
103{0x20,0x40,0x60,0x00,0x00,0x00,0x00,0x00},/* 0 CR41 */
104{0xC4,0x40,0x84,0x00,0x00,0x00,0x00,0x00},/* 1 CR8A */
105{0xC4,0x40,0x84,0x00,0x00,0x00,0x00,0x00},/* 2 CR8B */
106{0xB5,0x13,0xa4,0x00,0x00,0x00,0x00,0x00},/* 3 CR40[7],CR99[2:0],CR45[3:0]*/
107{0xf0,0xf5,0xf0,0x00,0x00,0x00,0x00,0x00},/* 4 CR59 */
108{0x90,0x90,0x24,0x00,0x00,0x00,0x00,0x00},/* 5 CR68 */
109{0x77,0x67,0x44,0x00,0x00,0x00,0x00,0x00},/* 6 CR69 */
110{0x77,0x77,0x44,0x00,0x00,0x00,0x00,0x00},/* 7 CR6A */
111{0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00},/* 8 CR6D */
112{0x55,0x55,0x55,0x00,0x00,0x00,0x00,0x00},/* 9 CR80 */
113{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/* 10 CR81 */
114{0x88,0xcc,0x48,0x00,0x00,0x00,0x00,0x00},/* 11 CR82 */
115{0x44,0x88,0x77,0x00,0x00,0x00,0x00,0x00},/* 12 CR85 */
116{0x48,0x88,0x88,0x00,0x00,0x00,0x00,0x00},/* 13 CR86 */
117{0x54,0x32,0x44,0x00,0x00,0x00,0x00,0x00},/* 14 CR90 */
118{0x54,0x33,0x44,0x00,0x00,0x00,0x00,0x00},/* 15 CR91 */
119{0x0a,0x07,0x07,0x00,0x00,0x00,0x00,0x00},/* 16 CR92 */
120{0x44,0x63,0x44,0x00,0x00,0x00,0x00,0x00},/* 17 CR93 */
121{0x10,0x14,0x0A,0x00,0x00,0x00,0x00,0x00},/* 18 CR94 */
122{0x11,0x0B,0x0C,0x00,0x00,0x00,0x00,0x00},/* 19 CR95 */
123{0x05,0x22,0x05,0x00,0x00,0x00,0x00,0x00},/* 20 CR96 */
124{0xf0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00},/* 21 CRC3 */
125{0x05,0x00,0x02,0x00,0x00,0x00,0x00,0x00},/* 22 CRC4 */
126{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}/* 23 CRC5 */
127};
128
129
130#if 0
131UCHAR XGI27_cr41[24][8]=
132{
133{0x20,0x60,0x60,0x00,0x00,0x00,0x00,0x00},/* 0 CR41 */
134{0x04,0x44,0x84,0x00,0x00,0x00,0x00,0x00},/* 1 CR8A */
135{0x04,0x40,0x84,0x00,0x00,0x00,0x00,0x00},/* 2 CR8B */
136{0xb5,0x03,0xa4,0x00,0x00,0x00,0x00,0x00},/* 3 CR40[7],CR99[2:0],CR45[3:0]*/
137{0xf0,0xf5,0xf0,0x00,0x00,0x00,0x00,0x00},/* 4 CR59 */
138{0xa4,0x1C,0x24,0x00,0x00,0x00,0x00,0x00},/* 5 CR68 */
139{0x77,0x77,0x44,0x00,0x00,0x00,0x00,0x00},/* 6 CR69 */
140{0x77,0x77,0x44,0x00,0x00,0x00,0x00,0x00},/* 7 CR6A */
141{0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00},/* 8 CR6D */
142{0x55,0x55,0x55,0x00,0x00,0x00,0x00,0x00},/* 9 CR80 */
143{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/* 10 CR81 */
144{0x48,0xa8,0x48,0x00,0x00,0x00,0x00,0x00},/* 11 CR82 */
145{0x77,0x88,0x77,0x00,0x00,0x00,0x00,0x00},/* 12 CR85 */
146{0x88,0x88,0x88,0x00,0x00,0x00,0x00,0x00},/* 13 CR86 */
147{0x44,0x32,0x44,0x00,0x00,0x00,0x00,0x00},/* 14 CR90 */
148{0x44,0x33,0x44,0x00,0x00,0x00,0x00,0x00},/* 15 CR91 */
149{0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00},/* 16 CR92 */
150{0x44,0x63,0x44,0x00,0x00,0x00,0x00,0x00},/* 17 CR93 */
151{0x0A,0x14,0x0A,0x00,0x00,0x00,0x00,0x00},/* 18 CR94 */
152{0x0C,0x0B,0x0C,0x00,0x00,0x00,0x00,0x00},/* 19 CR95 */
153{0x05,0x22,0x05,0x00,0x00,0x00,0x00,0x00},/* 20 CR96 */
154{0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00,0x00},/* 21 CRC3 */
155{0x03,0x00,0x02,0x00,0x00,0x00,0x00,0x00},/* 22 CRC4 */
156{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}/* 23 CRC5 */
157};
158#endif
159UCHAR XGI340_CR6B[8][4]={
160{0xaa,0xaa,0xaa,0xaa},
161{0xaa,0xaa,0xaa,0xaa},
162{0xaa,0xaa,0xaa,0xaa},
163{0x00,0x00,0x00,0x00},
164{0x00,0x00,0x00,0x00},
165{0x00,0x00,0x00,0x00},
166{0x00,0x00,0x00,0x00},
167{0x00,0x00,0x00,0x00}
168};
169
170UCHAR XGI340_CR6E[8][4]={
171{0x00,0x00,0x00,0x00},
172{0x00,0x00,0x00,0x00},
173{0x00,0x00,0x00,0x00},
174{0x00,0x00,0x00,0x00},
175{0x00,0x00,0x00,0x00},
176{0x00,0x00,0x00,0x00},
177{0x00,0x00,0x00,0x00},
178{0x00,0x00,0x00,0x00}
179};
180
181UCHAR XGI340_CR6F[8][32]={
182{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
183{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
184{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
185{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
186{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
187{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
188{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
189{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
190};
191
192UCHAR XGI340_CR89[8][2]={
193{0x00,0x00},
194{0x00,0x00},
195{0x00,0x00},
196{0x00,0x00},
197{0x00,0x00},
198{0x00,0x00},
199{0x00,0x00},
200{0x00,0x00}
201};
202 /* CR47,CR48,CR49,CR4A,CR4B,CR4C,CR70,CR71,CR74,CR75,CR76,CR77 */
203UCHAR XGI340_AGPReg[12]={0x28,0x23,0x00,0x20,0x00,0x20,0x00,0x05,0xd0,0x10,0x10,0x00};
204
205UCHAR XGI340_SR16[4]={0x03,0x83,0x03,0x83};
206
207UCHAR XGI330_SR15_1[8][8]={
208{0x0,0x0,0x00,0x00,0x20,0x20,0x00,0x00},
209{0x5,0x15,0x15,0x15,0x15,0x15,0x00,0x00},
210{0xba,0xba,0xba,0xba,0xBA,0xBA,0x00,0x00},
211{0x55,0x57,0x57,0xAB,0xAB,0xAB,0x00,0x00},
212{0x60,0x34,0x34,0x34,0x34,0x34,0x00,0x00},
213{0x0,0x80,0x80,0x80,0x83,0x83,0x00,0x00},
214{0x50,0x50,0x50,0x3C,0x3C,0x3C,0x00,0x00},
215{0x0,0xa5,0xfb,0xf6,0xF6,0xF6,0x00,0x00}
216};
217
218UCHAR XGI330_cr40_1[15][8]={
219{0x66,0x40,0x40,0x28,0x24,0x24,0x00,0x00},
220{0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
221{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
222{0x00,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00},
223{0x00,0xf0,0xf0,0xf0,0xF0,0xF0,0x00,0x00},
224{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
225{0x10,0x10,0x10,0x10,0x20,0x20,0x00,0x00},
226{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
227{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
228{0x88,0x88,0x88,0xAA,0xAC,0xAC,0x00,0x00},
229{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
230{0x00,0x00,0x00,0x00,0x77,0x77,0x00,0x00},
231{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
232{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
233{0x00,0xA2,0x00,0x00,0xA2,0xA2,0x00,0x00},
234};
235
236UCHAR XGI330_sr25[]={0x00,0x0};
237UCHAR XGI330_sr31=0xc0;
238UCHAR XGI330_sr32=0x11;
239UCHAR XGI330_SR33=0x00;
240UCHAR XG40_CRCF=0x13;
241UCHAR XG40_DRAMTypeDefinition=0xFF ;
242
243XGI_StStruct XGI330_SModeIDTable[]=
244{
245 {0x01,0x9208,0x01,0x00,0x10,0x00,0x00,0x01,0x00},
246 {0x01,0x1210,0x14,0x01,0x00,0x01,0x00,0x01,0x00},
247 {0x01,0x1010,0x17,0x02,0x11,0x00,0x00,0x01,0x01},
248 {0x03,0x8208,0x03,0x00,0x14,0x00,0x00,0x01,0x02},
249 {0x03,0x0210,0x16,0x01,0x04,0x01,0x00,0x01,0x02},
250 {0x03,0x0010,0x18,0x02,0x15,0x00,0x00,0x01,0x03},
251 {0x05,0x9209,0x05,0x00,0x10,0x00,0x00,0x00,0x04},
252 {0x06,0x8209,0x06,0x00,0x14,0x00,0x00,0x00,0x05},
253 {0x07,0x0000,0x07,0x03,0x05,0x03,0x00,0x01,0x03},
254 {0x07,0x0000,0x19,0x02,0x15,0x02,0x00,0x01,0x03},
255 {0x0d,0x920a,0x0d,0x00,0x10,0x00,0x00,0x00,0x04},
256 {0x0e,0x820a,0x0e,0x00,0x14,0x00,0x00,0x00,0x05},
257 {0x0f,0x0202,0x11,0x01,0x04,0x01,0x00,0x00,0x05},
258 {0x10,0x0212,0x12,0x01,0x04,0x01,0x00,0x00,0x05},
259 {0x11,0x0212,0x1a,0x04,0x24,0x04,0x00,0x00,0x05},
260 {0x12,0x0212,0x1b,0x04,0x24,0x04,0x00,0x00,0x05},
261 {0x13,0x021b,0x1c,0x00,0x14,0x00,0x00,0x00,0x04},
262 {0x12,0x0010,0x18,0x02,0x24,0x02,0x00,0x00,0x05},/* St_CRT2CRTC2 not sure */
263 {0x12,0x0210,0x18,0x01,0x24,0x01,0x00,0x00,0x05},/* St_CRT2CRTC2 not sure */
264 {0xff,0x0000,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
265};
266
267
268XGI_ExtStruct XGI330_EModeIDTable[]=
269{
270 {0x6a,0x2212,0x0407,0x3a81,0x0102,0x08,0x07,0x00,0x00,0x07,0x0e},
271 {0x2e,0x0a1b,0x0306,0x3a57,0x0101,0x08,0x06,0x00,0x00,0x05,0x06},
272 {0x2f,0x0a1b,0x0305,0x3a50,0x0100,0x08,0x05,0x00,0x00,0x05,0x05},
273 {0x30,0x2a1b,0x0407,0x3a81,0x0103,0x08,0x07,0x00,0x00,0x07,0x0e},
274 {0x31,0x0a1b,0x030d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x3d},
275 {0x32,0x0a1b,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x3e},
276 {0x33,0x0a1d,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x3d},
277 {0x34,0x2a1d,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x3e},
278 {0x35,0x0a1f,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x3d},
279 {0x36,0x2a1f,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x3e},
280 {0x37,0x0212,0x0508,0x3aab,0x0104,0x08,0x08,0x00,0x00,0x00,0x16},
281 {0x38,0x0a1b,0x0508,0x3aab,0x0105,0x08,0x08,0x00,0x00,0x00,0x16},
282 {0x3a,0x0e3b,0x0609,0x3adc,0x0107,0x08,0x09,0x00,0x00,0x00,0x1e},
283 {0x3c,0x0e3b,0x070a,0x3af2,0x0130,0x08,0x0a,0x00,0x00,0x00,0x22}, /* mode 1600x1200 add CRT2MODE [2003/10/07] */
284 {0x3d,0x0e7d,0x070a,0x3af2,0x0131,0x08,0x0a,0x00,0x00,0x00,0x22}, /* mode 1600x1200 add CRT2MODE */
285 {0x40,0x9a1c,0x0000,0x3a34,0x010d,0x08,0x00,0x00,0x00,0x04,0x00},
286 {0x41,0x9a1d,0x0000,0x3a34,0x010e,0x08,0x00,0x00,0x00,0x04,0x00}, /* ModeIdIndex = 0x10 */
287 {0x43,0x0a1c,0x0306,0x3a57,0x0110,0x08,0x06,0x00,0x00,0x05,0x06},
288 {0x44,0x0a1d,0x0306,0x3a57,0x0111,0x08,0x06,0x00,0x00,0x05,0x06},
289 {0x46,0x2a1c,0x0407,0x3a81,0x0113,0x08,0x07,0x00,0x00,0x07,0x0e},
290 {0x47,0x2a1d,0x0407,0x3a81,0x0114,0x08,0x07,0x00,0x00,0x07,0x0e},
291 {0x49,0x0a3c,0x0508,0x3aab,0x0116,0x08,0x08,0x00,0x00,0x00,0x16},
292 {0x4a,0x0a3d,0x0508,0x3aab,0x0117,0x08,0x08,0x00,0x00,0x00,0x16},
293 {0x4c,0x0e7c,0x0609,0x3adc,0x0119,0x08,0x09,0x00,0x00,0x00,0x1e},
294 {0x4d,0x0e7d,0x0609,0x3adc,0x011a,0x08,0x09,0x00,0x00,0x00,0x1e},
295 {0x50,0x9a1b,0x0001,0x3a3b,0x0132,0x08,0x01,0x00,0x00,0x04,0x02},
296 {0x51,0xba1b,0x0103,0x3a42,0x0133,0x08,0x03,0x00,0x00,0x07,0x03},
297 {0x52,0x9a1b,0x0204,0x3a49,0x0134,0x08,0x04,0x00,0x00,0x00,0x04},
298 {0x56,0x9a1d,0x0001,0x3a3b,0x0135,0x08,0x01,0x00,0x00,0x04,0x02},
299 {0x57,0xba1d,0x0103,0x3a42,0x0136,0x08,0x03,0x00,0x00,0x07,0x03},
300 {0x58,0x9a1d,0x0204,0x3a49,0x0137,0x08,0x04,0x00,0x00,0x00,0x04},
301 {0x59,0x9a1b,0x0000,0x3a34,0x0138,0x08,0x00,0x00,0x00,0x04,0x00},
302 {0x5A,0x021b,0x0014,0x3b83,0x0138,0x08,0x01,0x00,0x00,0x04,0x3f}, /* ModeIdIndex = 0x20 */
303 {0x5B,0x0a1d,0x0014,0x3b83,0x0135,0x08,0x01,0x00,0x00,0x04,0x3f},
304 {0x5d,0x0a1d,0x0305,0x3a50,0x0139,0x08,0x05,0x00,0x00,0x07,0x05},
305 {0x62,0x0a3f,0x0306,0x3a57,0x013a,0x08,0x06,0x00,0x00,0x05,0x06},
306 {0x63,0x2a3f,0x0407,0x3a81,0x013b,0x08,0x07,0x00,0x00,0x07,0x0e},
307 {0x64,0x0a7f,0x0508,0x3aab,0x013c,0x08,0x08,0x00,0x00,0x00,0x16},
308 {0x65,0x0eff,0x0609,0x3adc,0x013d,0x08,0x09,0x00,0x00,0x00,0x1e},
309 {0x66,0x0eff,0x070a,0x3af2,0x013e,0x08,0x0a,0x00,0x00,0x00,0x22}, /* mode 1600x1200 add CRT2MODE */
310 {0x68,0x067b,0x080b,0x3b17,0x013f,0x08,0x0b,0x00,0x00,0x00,0x29},
311 {0x69,0x06fd,0x080b,0x3b17,0x0140,0x08,0x0b,0x00,0x00,0x00,0x29},
312 {0x6b,0x07ff,0x080b,0x3b17,0x0141,0x10,0x0b,0x00,0x00,0x00,0x29},
313 {0x6c,0x067b,0x090c,0x3b37,0x0000,0x08,0x0c,0x00,0x00,0x00,0x2f},
314 {0x6d,0x06fd,0x090c,0x3b37,0x0000,0x10,0x0c,0x00,0x00,0x00,0x2f},
315 {0x6e,0x07ff,0x090c,0x3b37,0x0000,0x10,0x0c,0x00,0x00,0x00,0x2f},
316 {0x70,0x2a1b,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34},
317 {0x71,0x0a1b,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37},
318 {0x74,0x0a1d,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37}, /* ModeIdIndex = 0x30 */
319 {0x75,0x0a3d,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a},
320 {0x76,0x2a1f,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34},
321 {0x77,0x0a1f,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37},
322 {0x78,0x0a3f,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a},
323 {0x79,0x0a3b,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a},
324 {0x7a,0x2a1d,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34},
325 {0x7b,0x0e3b,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x1d},
326 {0x7c,0x0e7d,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x1d},
327 {0x7d,0x0eff,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x1d},
328 {0x20,0x0e3b,0x0D16,0x49e0,0x0000,0x08,0x16,0x00,0x00,0x00,0x43},
329 {0x21,0x0e7d,0x0D16,0x49e0,0x0000,0x08,0x16,0x00,0x00,0x00,0x43},
330 {0x22,0x0eff,0x0D16,0x49e0,0x0000,0x08,0x16,0x00,0x00,0x00,0x43},
331 {0x23,0x0e3b,0x0614,0x49d5,0x0000,0x08,0x14,0x00,0x00,0x00,0x41},
332 {0x24,0x0e7d,0x0614,0x49d5,0x0000,0x08,0x14,0x00,0x00,0x00,0x41},
333 {0x25,0x0eff,0x0614,0x49d5,0x0000,0x08,0x14,0x00,0x00,0x00,0x41},
334 {0x26,0x063b,0x0c15,0x49dc,0x0000,0x08,0x15,0x00,0x00,0x00,0x42}, /* ModeIdIndex = 0x40 */
335 {0x27,0x067d,0x0c15,0x49dc,0x0000,0x08,0x15,0x00,0x00,0x00,0x42},
336 {0x28,0x06ff,0x0c15,0x49dc,0x0000,0x08,0x15,0x00,0x00,0x00,0x42},
337 {0xff,0x0000,0x0000,0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00}
338};
339
340XGI_StandTableStruct XGI330_StandTable[]=
341{
342/* MD_0_200 */
343 {
344 0x28,0x18,0x08,0x0800,
345 {0x09,0x03,0x00,0x02},
346 0x63,
347 {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
348 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
349 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
350 0xff},
351 {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
352 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
353 0x08,0x00,0x0f,0x00},
354 {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
355 0xff}
356 },
357/* MD_1_200 */
358 {
359 0x28,0x18,0x08,0x0800,
360 {0x09,0x03,0x00,0x02},
361 0x63,
362 {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
363 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
364 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
365 0xff},
366 {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
367 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
368 0x08,0x00,0x0f,0x00},
369 {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
370 0xff}
371 },
372/* MD_2_200 */
373 {
374 0x50,0x18,0x08,0x1000,
375 {0x01,0x03,0x00,0x02},
376 0x63,
377 {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
378 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
379 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
380 0xff},
381 {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
382 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
383 0x08,0x00,0x0f,0x00},
384 {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
385 0xff}
386 },
387/* MD_3_200 */
388 {
389 0x50,0x18,0x08,0x1000,
390 {0x01,0x03,0x00,0x02},
391 0x63,
392 {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
393 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
394 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
395 0xff},
396 {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
397 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
398 0x08,0x00,0x0f,0x00},
399 {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
400 0xff}
401 },
402/* MD_4 */
403 {
404 0x28,0x18,0x08,0x4000,
405 {0x09,0x03,0x00,0x02},
406 0x63,
407 {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,
408 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
409 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
410 0xff},
411 {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
412 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
413 0x01,0x00,0x03,0x00},
414 {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
415 0xff}
416 },
417/* MD_5 */
418 {
419 0x28,0x18,0x08,0x4000,
420 {0x09,0x03,0x00,0x02},
421 0x63,
422 {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,
423 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
424 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
425 0xff},
426 {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
427 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
428 0x01,0x00,0x03,0x00},
429 {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
430 0xff}
431 },
432/* MD_6 */
433 {
434 0x50,0x18,0x08,0x4000,
435 {0x01,0x01,0x00,0x06},
436 0x63,
437 {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
438 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
439 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2,
440 0xff},
441 {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
442 0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
443 0x01,0x00,0x01,0x00},
444 {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00,
445 0xff}
446 },
447/* MD_7 */
448 {
449 0x50,0x18,0x0e,0x1000,
450 {0x00,0x03,0x00,0x03},
451 0xa6,
452 {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
453 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
454 0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3,
455 0xff},
456 {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
457 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
458 0x0e,0x00,0x0f,0x08},
459 {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
460 0xff}
461 },
462/* MDA_DAC */
463 {
464 0x00,0x00,0x00,0x0000,
465 {0x00,0x00,0x00,0x15},
466 0x15,
467 {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
468 0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f,
469 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,
470 0x00},
471 {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15,
472 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
473 0x15,0x15,0x15,0x15},
474 {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
475 0x3f}
476 },
477/* CGA_DAC */
478 {
479 0x00,0x10,0x04,0x0114,
480 {0x11,0x09,0x15,0x00},
481 0x10,
482 {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,
483 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a,
484 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10,
485 0x04},
486 {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04,
487 0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e,
488 0x3e,0x2b,0x3b,0x2f},
489 {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
490 0x3f}
491 },
492/* EGA_DAC */
493 {
494 0x00,0x10,0x04,0x0114,
495 {0x11,0x05,0x15,0x20},
496 0x30,
497 {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18,
498 0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38,
499 0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12,
500 0x06},
501 {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26,
502 0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e,
503 0x1e,0x0b,0x1b,0x0f},
504 {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
505 0x3f}
506 },
507/* VGA_DAC */
508 {
509 0x00,0x10,0x04,0x0114,
510 {0x11,0x09,0x15,0x2a},
511 0x3a,
512 {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05,
513 0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20,
514 0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10,
515 0x1f},
516 {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d,
517 0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15,
518 0x1c,0x0e,0x11,0x15},
519 {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00,
520 0x04}
521 },
522 {
523 0x08,0x0c,0x10,0x0a08,
524 {0x0c,0x0e,0x10,0x0b},
525 0x0c,
526 {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00,
527 0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00,
528 0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00,
529 0x06},
530 {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08,
531 0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00,
532 0x00,0x00,0x00,0x00},
533 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
534 0x00}
535 },
536/* MD_D */
537 {
538 0x28,0x18,0x08,0x2000,
539 {0x09,0x0f,0x00,0x06},
540 0x63,
541 {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,
542 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
543 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3,
544 0xff},
545 {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
546 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
547 0x01,0x00,0x0f,0x00},
548 {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
549 0xff}
550 },
551/* MD_E */
552 {
553 0x50,0x18,0x08,0x4000,
554 {0x01,0x0f,0x00,0x06},
555 0x63,
556 {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
557 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
558 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3,
559 0xff},
560 {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
561 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
562 0x01,0x00,0x0f,0x00},
563 {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
564 0xff}
565 },
566/* ExtVGATable */
567 {
568 0x00,0x00,0x00,0x0000,
569 {0x01,0x0f,0x00,0x0e},
570 0x23,
571 {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e,
572 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
573 0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3,
574 0xff},
575 {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
576 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
577 0x01,0x00,0x00,0x00},
578 {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
579 0xff}
580 },
581/* ROM_SAVEPTR */
582 {
583 0x9f,0x3b,0x00,0x00c0,
584 {0x00,0x00,0x00,0x00},
585 0x00,
586 {0x00,0x00,0x00,0x00,0x00,0x00,0xbb,0x3f,
587 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
588 0x00,0x00,0x1a,0x00,0xac,0x3e,0x00,0xc0,
589 0x00},
590 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
591 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
592 0x00,0x00,0x00,0x00},
593 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
594 0x00}
595 },
596/* MD_F */
597 {
598 0x50,0x18,0x0e,0x8000,
599 {0x01,0x0f,0x00,0x06},
600 0xa2,
601 {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
602 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
603 0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3,
604 0xff},
605 {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00,
606 0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00,
607 0x0b,0x00,0x05,0x00},
608 {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,
609 0xff}
610 },
611/* MD_10 */
612 {
613 0x50,0x18,0x0e,0x8000,
614 {0x01,0x0f,0x00,0x06},
615 0xa3,
616 {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
617 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
618 0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3,
619 0xff},
620 {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
621 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
622 0x01,0x00,0x0f,0x00},
623 {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
624 0xff}
625 },
626/* MD_0_350 */
627 {
628 0x28,0x18,0x0e,0x0800,
629 {0x09,0x03,0x00,0x02},
630 0xa3,
631 {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f,
632 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
633 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
634 0xff},
635 {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
636 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
637 0x08,0x00,0x0f,0x00},
638 {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
639 0xff}
640 },
641/* MD_1_350 */
642 {
643 0x28,0x18,0x0e,0x0800,
644 {0x09,0x03,0x00,0x02},
645 0xa3,
646 {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
647 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
648 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
649 0xff},
650 {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
651 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
652 0x08,0x00,0x0f,0x00},
653 {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
654 0xff}
655 },
656/* MD_2_350 */
657 {
658 0x50,0x18,0x0e,0x1000,
659 {0x01,0x03,0x00,0x02},
660 0xa3,
661 {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
662 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
663 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
664 0xff},
665 {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
666 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
667 0x08,0x00,0x0f,0x00},
668 {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
669 0xff}
670 },
671/* MD_3_350 */
672 {
673 0x50,0x18,0x0e,0x1000,
674 {0x01,0x03,0x00,0x02},
675 0xa3,
676 {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
677 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
678 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
679 0xff},
680 {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
681 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
682 0x08,0x00,0x0f,0x00},
683 {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
684 0xff}
685 },
686/* MD_0_1_400 */
687 {
688 0x28,0x18,0x10,0x0800,
689 {0x08,0x03,0x00,0x02},
690 0x67,
691 {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f,
692 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
693 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
694 0xff},
695 {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
696 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
697 0x0c,0x00,0x0f,0x08},
698 {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
699 0xff}
700 },
701/* MD_2_3_400 */
702 {
703 0x50,0x18,0x10,0x1000,
704 {0x00,0x03,0x00,0x02},
705 0x67,
706 {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
707 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
708 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
709 0xff},
710 {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
711 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
712 0x0c,0x00,0x0f,0x08},
713 {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
714 0xff}
715 },
716/* MD_7_400 */
717 {
718 0x50,0x18,0x10,0x1000,
719 {0x00,0x03,0x00,0x02},
720 0x66,
721 {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
722 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
723 0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3,
724 0xff},
725 {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
726 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
727 0x0e,0x00,0x0f,0x08},
728 {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
729 0xff}
730 },
731/* MD_11 */
732 {
733 0x50,0x1d,0x10,0xa000,
734 {0x01,0x0f,0x00,0x06},
735 0xe3,
736 {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,
737 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
738 0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xc3,
739 0xff},
740 {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
741 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
742 0x01,0x00,0x0f,0x00},
743 {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01,
744 0xff}
745 },
746/* ExtEGATable */
747 {
748 0x50,0x1d,0x10,0xa000,
749 {0x01,0x0f,0x00,0x06},
750 0xe3,
751 {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,
752 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
753 0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xe3,
754 0xff},
755 {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
756 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
757 0x01,0x00,0x0f,0x00},
758 {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
759 0xff}
760 },
761/* MD_13 */
762 {
763 0x28,0x18,0x08,0x2000,
764 {0x01,0x0f,0x00,0x0e},
765 0x63,
766 {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
767 0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,
768 0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3,
769 0xff},
770 {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
771 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
772 0x41,0x00,0x0f,0x00},
773 {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
774 0xff}
775 }
776};
777
778XGI_TimingHStruct XGI_TimingH[]=
779{{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}};
780
781XGI_TimingVStruct XGI_TimingV[]=
782{{{0x00,0x00,0x00,0x00,0x00,0x00,0x00}}};
783
784XGI_XG21CRT1Struct XGI_UpdateCRT1Table[]=
785{
786 {0x01,0x27,0x91,0x8f,0xc0}, /* 00 */
787 {0x03,0x4f,0x83,0x8f,0xc0}, /* 01 */
788 {0x05,0x27,0x91,0x8f,0xc0}, /* 02 */
789 {0x06,0x4f,0x83,0x8f,0xc0}, /* 03 */
790 {0x07,0x4f,0x83,0x8f,0xc0}, /* 04 */
791 {0x0d,0x27,0x91,0x8f,0xc0}, /* 05 */
792 {0x0e,0x4f,0x83,0x8f,0xc0}, /* 06 */
793 {0x0f,0x4f,0x83,0x5d,0xc0}, /* 07 */
794 {0x10,0x4f,0x83,0x5d,0xc0}, /* 08 */
795 {0x11,0x4f,0x83,0xdf,0x0c}, /* 09 */
796 {0x12,0x4f,0x83,0xdf,0x0c}, /* 10 */
797 {0x13,0x4f,0x83,0x8f,0xc0}, /* 11 */
798 {0x2e,0x4f,0x83,0xdf,0x0c}, /* 12 */
799 {0x2e,0x4f,0x87,0xdf,0xc0}, /* 13 */
800 {0x2f,0x4f,0x83,0x8f,0xc0}, /* 14 */
801 {0x50,0x27,0x91,0xdf,0x0c}, /* 15 */
802 {0x59,0x27,0x91,0x8f,0xc0} /* 16 */
803};
804
805XGI_CRT1TableStruct XGI_CRT1Table[]=
806{
807 {{0x2d,0x28,0x90,0x2c,0x90,0x00,0x04,0x00,
808 0xbf,0x1f,0x9c,0x8e,0x96,0xb9,0x30}}, /* 0x0 */
809 {{0x2d,0x28,0x90,0x2c,0x90,0x00,0x04,0x00,
810 0x0b,0x3e,0xe9,0x8b,0xe7,0x04,0x00}}, /* 0x1 */
811 {{0x3D,0x31,0x81,0x37,0x1F,0x00,0x05,0x00,
812 0x72,0xF0,0x58,0x8C,0x57,0x73,0xA0}}, /* 0x2 */
813 {{0x4F,0x3F,0x93,0x45,0x0D,0x00,0x01,0x00,
814 0x24,0xF5,0x02,0x88,0xFF,0x25,0x90}}, /* 0x3 */
815 {{0x5F,0x50,0x82,0x55,0x81,0x00,0x05,0x00,
816 0xBF,0x1F,0x9C,0x8E,0x96,0xB9,0x30}}, /* 0x4 */
817 {{0x5F,0x50,0x82,0x55,0x81,0x00,0x05,0x00,
818 0x0B,0x3E,0xE9,0x8B,0xE7,0x04,0x00}}, /* 0x5 */
819 {{0x63,0x50,0x86,0x56,0x9B,0x00,0x01,0x00,
820 0x06,0x3E,0xE8,0x8B,0xE7,0xFF,0x10}}, /* 0x6 */
821 {{0x64,0x4F,0x88,0x55,0x9D,0x00,0x01,0x00,
822 0xF2,0x1F,0xE0,0x83,0xDF,0xF3,0x10}}, /* 0x7 */
823 {{0x63,0x4F,0x87,0x5A,0x81,0x00,0x05,0x00,
824 0xFB,0x1F,0xE0,0x83,0xDF,0xFC,0x10}}, /* 0x8 */
825 {{0x65,0x4F,0x89,0x58,0x80,0x00,0x05,0x60,
826 0xFB,0x1F,0xE0,0x83,0xDF,0xFC,0x80}}, /* 0x9 */
827 {{0x65,0x4F,0x89,0x58,0x80,0x00,0x05,0x60,
828 0x01,0x3E,0xE0,0x83,0xDF,0x02,0x80}}, /* 0xa */
829 {{0x67,0x4F,0x8B,0x58,0x81,0x00,0x05,0x60,
830 0x0D,0x3E,0xE0,0x83,0xDF,0x0E,0x90}}, /* 0xb */
831 {{0x65,0x4F,0x89,0x57,0x9F,0x00,0x01,0x00,
832 0xFB,0x1F,0xE6,0x8A,0xDF,0xFC,0x10}}, /* 0xc */
833 {{0x7B,0x63,0x9F,0x6A,0x93,0x00,0x05,0x00, /* ; 0D (800x600,56Hz) */
834 0x6F,0xF0,0x58,0x8A,0x57,0x70,0xA0}}, /* ; (VCLK 36.0MHz) */
835 {{0x7F,0x63,0x83,0x6C,0x1C,0x00,0x06,0x00, /* ; 0E (800x600,60Hz) */
836 0x72,0xF0,0x58,0x8C,0x57,0x73,0xA0}}, /* ; (VCLK 40.0MHz) */
837 {{0x7D,0x63,0x81,0x6E,0x1D,0x00,0x06,0x00, /* ; 0F (800x600,72Hz) */
838 0x98,0xF0,0x7C,0x82,0x57,0x99,0x80}}, /* ; (VCLK 50.0MHz) */
839 {{0x7F,0x63,0x83,0x69,0x13,0x00,0x06,0x00, /* ; 10 (800x600,75Hz) */
840 0x6F,0xF0,0x58,0x8B,0x57,0x70,0xA0}}, /* ; (VCLK 49.5MHz) */
841 {{0x7E,0x63,0x82,0x6B,0x13,0x00,0x06,0x00, /* ; 11 (800x600,85Hz) */
842 0x75,0xF0,0x58,0x8B,0x57,0x76,0xA0}}, /* ; (VCLK 56.25MHz) */
843 {{0x81,0x63,0x85,0x6D,0x18,0x00,0x06,0x60, /* ; 12 (800x600,100Hz) */
844 0x7A,0xF0,0x58,0x8B,0x57,0x7B,0xA0}}, /* ; (VCLK 75.8MHz) */
845 {{0x83,0x63,0x87,0x6E,0x19,0x00,0x06,0x60, /* ; 13 (800x600,120Hz) */
846 0x81,0xF0,0x58,0x8B,0x57,0x82,0xA0}}, /* ; (VCLK 79.411MHz) */
847 {{0x85,0x63,0x89,0x6F,0x1A,0x00,0x06,0x60, /* ; 14 (800x600,160Hz) */
848 0x91,0xF0,0x58,0x8B,0x57,0x92,0xA0}}, /* ; (VCLK 105.822MHz) */
849 {{0x99,0x7F,0x9D,0x84,0x1A,0x00,0x02,0x00,
850 0x96,0x1F,0x7F,0x83,0x7F,0x97,0x10}}, /* 0x15 */
851 {{0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00,
852 0x24,0xF5,0x02,0x88,0xFF,0x25,0x90}}, /* 0x16 */
853 {{0xA1,0x7F,0x85,0x86,0x97,0x00,0x02,0x00,
854 0x24,0xF5,0x02,0x88,0xFF,0x25,0x90}}, /* 0x17 */
855 {{0x9F,0x7F,0x83,0x85,0x91,0x00,0x02,0x00,
856 0x1E,0xF5,0x00,0x83,0xFF,0x1F,0x90}}, /* 0x18 */
857 {{0xA7,0x7F,0x8B,0x89,0x95,0x00,0x02,0x00,
858 0x26,0xF5,0x00,0x83,0xFF,0x27,0x90}}, /* 0x19 */
859 {{0xA9,0x7F,0x8D,0x8C,0x9A,0x00,0x02,0x62,
860 0x2C,0xF5,0x00,0x83,0xFF,0x2D,0x14}}, /* 0x1a */
861 {{0xAB,0x7F,0x8F,0x8D,0x9B,0x00,0x02,0x62,
862 0x35,0xF5,0x00,0x83,0xFF,0x36,0x14}}, /* 0x1b */
863 {{0xCF,0x9F,0x93,0xB2,0x01,0x00,0x03,0x00,
864 0x14,0xBA,0x00,0x83,0xFF,0x15,0x00}}, /* 0x1c */
865 {{0xCE,0x9F,0x92,0xA9,0x17,0x00,0x07,0x00,
866 0x28,0x5A,0x00,0x83,0xFF,0x29,0x89}}, /* 0x1d */
867 {{0xCE,0x9F,0x92,0xA5,0x17,0x00,0x07,0x00,
868 0x28,0x5A,0x00,0x83,0xFF,0x29,0x89}}, /* 0x1e */
869 {{0xD3,0x9F,0x97,0xAB,0x1F,0x00,0x07,0x00,
870 0x2E,0x5A,0x00,0x83,0xFF,0x2F,0x89}}, /* 0x1f */
871 {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
872 0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x20 */
873 {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
874 0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x21 */
875 {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
876 0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x22 */
877 {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
878 0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x23 */
879 {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
880 0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x24 */
881 {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
882 0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x25 */
883 {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
884 0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x26 */
885 {{0x40,0xEF,0x84,0x03,0x1D,0x41,0x01,0x00,
886 0xDA,0x1F,0xA0,0x83,0x9F,0xDB,0x1F}}, /* 0x27 */
887 {{0x43,0xEF,0x87,0x06,0x00,0x41,0x05,0x62,
888 0xD4,0x1F,0xA0,0x83,0x9F,0xD5,0x9F}}, /* 0x28 */
889 {{0x45,0xEF,0x89,0x07,0x01,0x41,0x05,0x62,
890 0xD9,0x1F,0xA0,0x83,0x9F,0xDA,0x9F}}, /* 0x29 */
891 {{0x40,0xEF,0x84,0x03,0x1D,0x41,0x01,0x00,
892 0xDA,0x1F,0xA0,0x83,0x9F,0xDB,0x1F}}, /* 0x2a */
893 {{0x40,0xEF,0x84,0x03,0x1D,0x41,0x01,0x00,
894 0xDA,0x1F,0xA0,0x83,0x9F,0xDB,0x1F}}, /* 0x2b */
895 {{0x40,0xEF,0x84,0x03,0x1D,0x41,0x01,0x00,
896 0xDA,0x1F,0xA0,0x83,0x9F,0xDB,0x1F}}, /* 0x2c */
897 {{0x59,0xFF,0x9D,0x17,0x13,0x41,0x05,0x44,
898 0x33,0xBA,0x00,0x83,0xFF,0x34,0x0F}}, /* 0x2d */
899 {{0x5B,0xFF,0x9F,0x18,0x14,0x41,0x05,0x44,
900 0x38,0xBA,0x00,0x83,0xFF,0x39,0x0F}}, /* 0x2e */
901 {{0x5B,0xFF,0x9F,0x18,0x14,0x41,0x05,0x44,
902 0x3D,0xBA,0x00,0x83,0xFF,0x3E,0x0F}}, /* 0x2f */
903 {{0x5D,0xFF,0x81,0x19,0x95,0x41,0x05,0x44,
904 0x41,0xBA,0x00,0x84,0xFF,0x42,0x0F}}, /* 0x30 */
905 {{0x55,0xFF,0x99,0x0D,0x0C,0x41,0x05,0x00,
906 0x3E,0xBA,0x00,0x84,0xFF,0x3F,0x0F}}, /* 0x31 */
907 {{0x7F,0x63,0x83,0x6C,0x1C,0x00,0x06,0x00,
908 0x72,0xBA,0x27,0x8B,0xDF,0x73,0x80}}, /* 0x32 */
909 {{0x7F,0x63,0x83,0x69,0x13,0x00,0x06,0x00,
910 0x6F,0xBA,0x26,0x89,0xDF,0x6F,0x80}}, /* 0x33 */
911 {{0x7F,0x63,0x82,0x6B,0x13,0x00,0x06,0x00,
912 0x75,0xBA,0x29,0x8C,0xDF,0x75,0x80}}, /* 0x34 */
913 {{0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00,
914 0x24,0xF1,0xAF,0x85,0x3F,0x25,0xB0}}, /* 0x35 */
915 {{0x9F,0x7F,0x83,0x85,0x91,0x00,0x02,0x00,
916 0x1E,0xF1,0xAD,0x81,0x3F,0x1F,0xB0}}, /* 0x36 */
917 {{0xA7,0x7F,0x88,0x89,0x15,0x00,0x02,0x00,
918 0x26,0xF1,0xB1,0x85,0x3F,0x27,0xB0}}, /* 0x37 */
919 {{0xCE,0x9F,0x92,0xA9,0x17,0x00,0x07,0x00,
920 0x28,0xC4,0x7A,0x8E,0xCF,0x29,0xA1}}, /* 0x38 */
921 {{0xCE,0x9F,0x92,0xA5,0x17,0x00,0x07,0x00,
922 0x28,0xD4,0x7A,0x8E,0xCF,0x29,0xA1}}, /* 0x39 */
923 {{0xD3,0x9F,0x97,0xAB,0x1F,0x00,0x07,0x00,
924 0x2E,0xD4,0x7D,0x81,0xCF,0x2F,0xA1}}, /* 0x3a */
925 {{0xDC,0x9F,0x00,0xAB,0x19,0x00,0x07,0x00,
926 0xE6,0xEF,0xC0,0xC3,0xBF,0xE7,0x90}}, /* 0x3b */
927 {{0x6B,0x59,0x8F,0x5E,0x8C,0x00,0x05,0x00,
928 0x0B,0x3E,0xE9,0x8B,0xE7,0x04,0x00}}, /* 0x3c */
929 {{0x7B,0x63,0x9F,0x6A,0x93,0x00,0x05,0x00,
930 0x6F,0xF0,0x58,0x8A,0x57,0x70,0xA0}}, /* 0x3d */
931 {{0x86,0x6A,0x8a,0x74,0x06,0x00,0x02,0x00,
932 0x8c,0x15,0x4f,0x83,0xef,0x8d,0x30}}, /* 0x3e */
933 {{0x81,0x6A,0x85,0x70,0x00,0x00,0x02,0x00,
934 0x0f,0x3e,0xeb,0x8e,0xdf,0x10,0x00}}, /* 0x3f */
935 {{0xCE,0x9F,0x92,0xA9,0x17,0x00,0x07,0x00,
936 0x20,0xF5,0x03,0x88,0xFF,0x21,0x90}}, /* 0x40 */
937 {{0xE6,0xAE,0x8A,0xBD,0x90,0x00,0x03,0x00,
938 0x3D,0x10,0x1A,0x8D,0x19,0x3E,0x2F}}, /* 0x41 */
939 {{0xB9,0x8F,0x9D,0x9B,0x8A,0x00,0x06,0x00,
940 0x7D,0xFF,0x60,0x83,0x5F,0x7E,0x90}}, /* 0x42 */
941 {{0xC3,0x8F,0x87,0x9B,0x0B,0x00,0x07,0x00,
942 0x82,0xFF,0x60,0x83,0x5F,0x83,0x90}}, /* 0x43 */
943 {{0xAD,0x7F,0x91,0x8E,0x9C,0x00,0x02,0x82,
944 0x49,0xF5,0x00,0x83,0xFF,0x4A,0x90}}, /* 0x44 */
945 {{0xCD,0x9F,0x91,0xA7,0x19,0x00,0x07,0x60,
946 0xE6,0xFF,0xC0,0x83,0xBF,0xE7,0x90}}, /* 0x45 */
947 {{0xD3,0x9F,0x97,0xAB,0x1F,0x00,0x07,0x60,
948 0xF1,0xFF,0xC0,0x83,0xBF,0xF2,0x90}}, /* 0x46 */
949 {{0xD7,0x9F,0x9B,0xAC,0x1E,0x00,0x07,0x00,
950 0x03,0xDE,0xC0,0x84,0xBF,0x04,0x90}} /* 0x47 */
951};
952
953XGI330_CHTVRegDataStruct XGI_CHTVRegUNTSC[] = {
954 /* Index:000h,001h,002h,004h,003h,005h,006h,007h,008h,015h,01Fh,00Ch,00Dh,00Eh,00Fh,010h */
955 {{ 0x4A,0x77,0xBB,0x94,0x84,0x48,0xFE,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 00 (640x200,640x400) */
956 {{ 0x4A,0x77,0xBB,0x94,0x84,0x48,0xFE,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 01 (640x350) */
957 {{ 0x4A,0x77,0xBB,0x94,0x84,0x48,0xFE,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 02 (720x400) */
958 {{ 0x4A,0x77,0xBB,0x94,0x84,0x48,0xFE,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 03 (720x350) */
959 {{ 0x6A,0x77,0xBB,0x6E,0x84,0x2E,0x02,0x5A,0x04,0x00,0x80,0x20,0x7E,0x80,0x97,0x00 }},/* 04 (640x480) ;;5/6/02 */
960 {{ 0xCF,0x77,0xB7,0xC8,0x84,0x3B,0x02,0x5A,0x04,0x00,0x80,0x19,0x88,0xAE,0xA3,0x00 }},/* 05 (800x600) ;;1/12/02 */
961 {{ 0xEE,0x77,0xBB,0x66,0x87,0x32,0x01,0x5A,0x04,0x00,0x80,0x1B,0xD4,0x2F,0x6F,0x00 }}/* 06 (1024x768) ;;5/6/02 */
962 };
963
964XGI330_CHTVRegDataStruct XGI_CHTVRegONTSC[]= {
965 /* Index:000h,001h,002h,004h,003h,005h,006h,007h,008h,015h,01Fh,00Ch,00Dh,00Eh,00Fh,010h */
966 {{ 0x49,0x77,0xBB,0x7B,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 00 (640x200,640x400) */
967 {{ 0x49,0x77,0xBB,0x7B,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 01 (640x350) */
968 {{ 0x49,0x77,0xBB,0x7B,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 02 (720x400) */
969 {{ 0x49,0x77,0xBB,0x7B,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 03 (720x350) */
970 {{ 0x69,0x77,0xBB,0x6E,0x84,0x1E,0x00,0x5A,0x04,0x00,0x80,0x25,0x1A,0x80,0x26,0x00 }},/* 04 (640x480) ;;5/6/02 */
971 {{ 0xCE,0x77,0xB7,0xB6,0x83,0x2C,0x02,0x5A,0x04,0x00,0x80,0x1C,0x00,0x82,0x97,0x00 }},/* 05 (800x600) ;;5/6/02 */
972 {{ 0xED,0x77,0xBB,0x66,0x8C,0x21,0x02,0x5A,0x04,0x00,0x80,0x1F,0xA0,0x7E,0x73,0x00 }}/* 06 (1024x768) ;;5/6/02 */
973 };
974
975XGI330_CHTVRegDataStruct XGI_CHTVRegUPAL[]= {
976 /* Index:000h,001h,002h,004h,003h,005h,006h,007h,008h,015h,01Fh,00Ch,00Dh,00Eh,00Fh,010h */
977 {{ 0x41,0x7F,0xB7,0x34,0xAD,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* ; 00 (640x200,640x400) */
978 {{ 0x41,0x7F,0xB7,0x80,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* ; 01 (640x350) */
979 {{ 0x41,0x7F,0xB7,0x34,0xAD,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* ; 02 (720x400) */
980 {{ 0x41,0x7F,0xB7,0x12,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* ; 03 (720x350) */
981 {{ 0x61,0x7F,0xB7,0x99,0x84,0x35,0x04,0x5A,0x05,0x00,0x80,0x26,0x2A,0x55,0x5D,0x00 }},/* ; 04 (640x480) */
982 {{ 0xC3,0x7F,0xB7,0x7A,0x84,0x40,0x02,0x5A,0x05,0x00,0x80,0x1F,0x84,0x3D,0x28,0x00 }},/* ; 05 (800x600) ;;1/12/02 */
983 {{ 0xE5,0x7F,0xB7,0x1D,0xA7,0x3E,0x04,0x5A,0x05,0x00,0x80,0x20,0x3E,0xE4,0x22,0x00 }}/* ; 06 (1024x768) ;;1/12/02 */
984 };
985
986XGI330_CHTVRegDataStruct XGI_CHTVRegOPAL[]={
987 /* Index:000,0x01,0x02,0x04,0x03,0x05,0x06,0x07,0x08,0x15,0x1F,0x0C,0x0D,0x0E,0x0F,0x10h */
988 {{ 0x41,0x7F,0xB7,0x36,0xAD,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 00 (640x200,640x400) */
989 {{ 0x41,0x7F,0xB7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 01 (640x350) */
990 {{ 0x41,0x7F,0xB7,0x36,0xAD,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 02 (720x400) */
991 {{ 0x41,0x7F,0xB7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 03 (720x350) */
992 {{ 0x61,0x7F,0xB7,0x99,0x84,0x35,0x04,0x5A,0x05,0x00,0x80,0x26,0x2A,0x55,0x5D,0x00 }},/* 04 (640x480) */
993 {{ 0xC1,0x7F,0xB7,0x4D,0x8C,0x1E,0x31,0x5A,0x05,0x00,0x80,0x26,0x78,0x19,0x34,0x00 }},/* 05 (800x600) ;;1/12/02 */
994 {{ 0xE4,0x7F,0xB7,0x1E,0xAF,0x29,0x37,0x5A,0x05,0x00,0x80,0x25,0x8C,0xB2,0x2A,0x00 }}/* 06 (1024x768) ;;1/12/02 */
995 };
996
997UCHAR XGI_CH7017LV1024x768[]={0x60,0x02,0x00,0x07,0x40,0xED,0xA3,
998 0xC8,0xC7,0xAC,0xE0,0x02};
999UCHAR XGI_CH7017LV1400x1050[]={0x60,0x03,0x11,0x00,0x40,0xE3,0xAD,
1000 0xDB,0xF6,0xAC,0xE0,0x02};
1001
1002
1003/*add for new UNIVGABIOS*/
1004XGI330_LCDDataStruct XGI_StLCD1024x768Data[]=
1005{
1006 { 62, 25, 800, 546,1344, 806},
1007 { 32, 15, 930, 546,1344, 806},
1008 { 62, 25, 800, 546,1344, 806}, /* chiawen for dot9 -> dot8 */
1009 { 104, 45, 945, 496,1344, 806},
1010 { 62, 25, 800, 546,1344, 806},
1011 { 31, 18,1008, 624,1344, 806},
1012 { 1, 1,1344, 806,1344, 806}
1013};
1014
1015XGI330_LCDDataStruct XGI_ExtLCD1024x768Data[]=
1016{
1017 { 42, 25,1536, 419,1344, 806}, /* { 12, 5, 896, 512,1344, 806}, // alan 09/12/2003 */
1018 { 48, 25,1536, 369,1344, 806}, /* { 12, 5, 896, 510,1344, 806}, // alan 09/12/2003 */
1019 { 42, 25,1536, 419,1344, 806}, /* { 32, 15,1008, 505,1344, 806}, // alan 09/12/2003 */
1020 { 48, 25,1536, 369,1344, 806}, /* { 32, 15,1008, 514,1344, 806}, // alan 09/12/2003 */
1021 { 12, 5, 896, 500,1344, 806},
1022 { 42, 25,1024, 625,1344, 806},
1023 { 1, 1,1344, 806,1344, 806},
1024 { 12, 5, 896, 500,1344, 806},
1025 { 42, 25,1024, 625,1344, 806},
1026 { 1, 1,1344, 806,1344, 806},
1027 { 12, 5, 896, 500,1344, 806},
1028 { 42, 25,1024, 625,1344, 806},
1029 { 1, 1,1344, 806,1344, 806}
1030};
1031
1032/*XGI330_LCDDataStruct XGI_St2LCD1024x768Data[]=
1033{
1034 { 62, 25, 800, 546,1344, 806},
1035 { 32, 15, 930, 546,1344, 806},
1036 { 62, 25, 800, 546,1344, 806},
1037 { 104, 45, 945, 496,1344, 806},
1038 { 62, 25, 800, 546,1344, 806},
1039 { 31, 18,1008, 624,1344, 806},
1040 { 1, 1,1344, 806,1344, 806}
1041};*/
1042
1043XGI330_LCDDataStruct XGI_CetLCD1024x768Data[]=
1044{
1045 { 1,1,1344,806,1344,806 }, /* ; 00 (320x200,320x400,640x200,640x400) */
1046 { 1,1,1344,806,1344,806 }, /* 01 (320x350,640x350) */
1047 { 1,1,1344,806,1344,806 }, /* 02 (360x400,720x400) */
1048 { 1,1,1344,806,1344,806 }, /* 03 (720x350) */
1049 { 1,1,1344,806,1344,806 }, /* 04 (640x480x60Hz) */
1050 { 1,1,1344,806,1344,806 }, /* 05 (800x600x60Hz) */
1051 { 1,1,1344,806,1344,806 } /* 06 (1024x768x60Hz) */
1052};
1053
1054XGI330_LCDDataStruct XGI_StLCD1280x1024Data[]=
1055{
1056 { 22, 5, 800, 510,1650,1088},
1057 { 22, 5, 800, 510,1650,1088},
1058 { 176, 45, 900, 510,1650,1088},
1059 { 176, 45, 900, 510,1650,1088},
1060 { 22, 5, 800, 510,1650,1088},
1061 { 13, 5,1024, 675,1560,1152},
1062 { 16, 9,1266, 804,1688,1072},
1063 { 1, 1,1688,1066,1688,1066}
1064};
1065
1066XGI330_LCDDataStruct XGI_ExtLCD1280x1024Data[]=
1067{
1068 { 211, 60,1024, 501,1688,1066},
1069 { 211, 60,1024, 508,1688,1066},
1070 { 211, 60,1024, 501,1688,1066},
1071 { 211, 60,1024, 508,1688,1066},
1072 { 211, 60,1024, 500,1688,1066},
1073 { 211, 75,1024, 625,1688,1066},
1074 { 211, 120,1280, 798,1688,1066},
1075 { 1, 1,1688,1066,1688,1066}
1076};
1077
1078XGI330_LCDDataStruct XGI_St2LCD1280x1024Data[]=
1079{
1080 { 22, 5, 800, 510,1650,1088},
1081 { 22, 5, 800, 510,1650,1088},
1082 { 176, 45, 900, 510,1650,1088},
1083 { 176, 45, 900, 510,1650,1088},
1084 { 22, 5, 800, 510,1650,1088},
1085 { 13, 5,1024, 675,1560,1152},
1086 { 16, 9,1266, 804,1688,1072},
1087 { 1, 1,1688,1066,1688,1066}
1088};
1089
1090XGI330_LCDDataStruct XGI_CetLCD1280x1024Data[]=
1091{
1092 { 1,1,1688,1066,1688,1066 }, /* 00 (320x200,320x400,640x200,640x400) */
1093 { 1,1,1688,1066,1688,1066 }, /* 01 (320x350,640x350) */
1094 { 1,1,1688,1066,1688,1066 }, /* 02 (360x400,720x400) */
1095 { 1,1,1688,1066,1688,1066 }, /* 03 (720x350) */
1096 { 1,1,1688,1066,1688,1066 }, /* 04 (640x480x60Hz) */
1097 { 1,1,1688,1066,1688,1066 }, /* 05 (800x600x60Hz) */
1098 { 1,1,1688,1066,1688,1066 }, /* 06 (1024x768x60Hz) */
1099 { 1,1,1688,1066,1688,1066 }, /* 07 (1280x1024x60Hz) */
1100 { 1,1,1688,1066,1688,1066 } /* 08 (1400x1050x60Hz) */
1101};
1102
1103XGI330_LCDDataStruct XGI_StLCD1400x1050Data[]=
1104{
1105 { 211,100,2100,408,1688,1066 }, /* 00 (320x200,320x400,640x200,640x400) */
1106 { 211,64,1536,358,1688,1066 }, /* 01 (320x350,640x350) */
1107 { 211,100,2100,408,1688,1066 }, /* 02 (360x400,720x400) */
1108 { 211,64,1536,358,1688,1066 }, /* 03 (720x350) */
1109 { 211,48,840,488,1688,1066 }, /* 04 (640x480x60Hz) */
1110 { 211,72,1008,609,1688,1066 }, /* 05 (800x600x60Hz) */
1111 { 211,128,1400,776,1688,1066 }, /* 06 (1024x768x60Hz) */
1112 { 1,1,1688,1066,1688,1066 }, /* 07 (1280x1024x60Hz w/o Scaling) */
1113 { 1,1,1688,1066,1688,1066 } /* 08 (1400x1050x60Hz) */
1114};
1115
1116XGI330_LCDDataStruct XGI_ExtLCD1400x1050Data[]=
1117{
1118 { 211,100,2100,408,1688,1066 }, /* 00 (320x200,320x400,640x200,640x400) */
1119 { 211,64,1536,358,1688,1066 }, /* 01 (320x350,640x350) */
1120 { 211,100,2100,408,1688,1066 }, /* 02 (360x400,720x400) */
1121 { 211,64,1536,358,1688,1066 }, /* 03 (720x350) */
1122 { 211,48,840,488,1688,1066 }, /* 04 (640x480x60Hz) */
1123 { 211,72,1008,609,1688,1066 }, /* 05 (800x600x60Hz) */
1124 { 211,128,1400,776,1688,1066 }, /* 06 (1024x768x60Hz) */
1125 { 1,1,1688,1066,1688,1066 }, /* 07 (1280x1024x60Hz w/o Scaling) */
1126 { 1,1,1688,1066,1688,1066 } /* 08 (1400x1050x60Hz) */
1127};
1128
1129XGI330_LCDDataStruct XGI_ExtLCD1600x1200Data[]=
1130{
1131 { 4,1,1620,420,2160,1250 }, /* { 3,1,2160,425,2160,1250 }, // 00 (320x200,320x400,640x200,640x400) // alan 10/14/2003 */
1132 { 27,7,1920,375,2160,1250 }, /* 01 (320x350,640x350) */
1133 { 4,1,1620,420,2160,1250 }, /* { 3,1,2160,425,2160,1250 }, // 02 (360x400,720x400) // alan 10/14/2003 */
1134 { 27,7,1920,375,2160,1250 }, /* 03 (720x350) */
1135 { 27,4,800,500,2160,1250 }, /* 04 (640x480x60Hz) */
1136 { 4,1,1080,625,2160,1250 }, /* 05 (800x600x60Hz) */
1137 { 5,2,1350,800,2160,1250 }, /* 06 (1024x768x60Hz) */
1138 { 27,16,1500,1064,2160,1250 }, /* 07 (1280x1024x60Hz) */
1139 { 9,7,1920,1106,2160,1250 }, /* 08 (1400x1050x60Hz) */
1140 { 1,1,2160,1250,2160,1250 } /* 09 (1600x1200x60Hz) ;302lv */
1141};
1142
1143XGI330_LCDDataStruct XGI_StLCD1600x1200Data[]=
1144{
1145 { 27,4,800,500,2160,1250 },/* 00 (320x200,320x400,640x200,640x400) */
1146 { 27,4,800,500,2160,1250 },/* 01 (320x350,640x350) */
1147 { 27,4,800,500,2160,1250 },/* 02 (360x400,720x400) */
1148 { 27,4,800,500,2160,1250 },/* 03 (720x350) */
1149 { 27,4,800,500,2160,1250 },/* 04 (320x240,640x480) */
1150 { 4,1,1080,625,2160,1250 },/* 05 (400x300,800x600) */
1151 { 5,2,1350,800,2160,1250 },/* 06 (512x384,1024x768) */
1152 { 135,88,1600,1100,2160,1250 },/* 07 (1280x1024) */
1153 { 1,1,1800,1500,2160,1250 },/* 08 (1400x1050) */
1154 { 1,1,2160,1250,2160,1250 } /* 09 (1600x1200) */
1155};
1156
1157XGI330_LCDDataStruct XGI_CetLCD1400x1050Data[]=
1158{
1159 { 1,1,1688,1066,1688,1066 }, /* 00 (320x200,320x400,640x200,640x400) */
1160 { 1,1,1688,1066,1688,1066 }, /* 01 (320x350,640x350) */
1161 { 1,1,1688,1066,1688,1066 }, /* 02 (360x400,720x400) */
1162 { 1,1,1688,1066,1688,1066 }, /* 03 (720x350) */
1163 { 1,1,1688,1066,1688,1066 }, /* 04 (640x480x60Hz) */
1164 { 1,1,1688,1066,1688,1066 }, /* 05 (800x600x60Hz) */
1165 { 1,1,1688,1066,1688,1066 }, /* 06 (1024x768x60Hz) */
1166 { 1,1,1688,1066,1688,1066 }, /* 07 (1280x1024x60Hz) */
1167 { 1,1,1688,1066,1688,1066 } /* 08 (1400x1050x60Hz) */
1168};
1169
1170XGI330_LCDDataStruct XGI_NoScalingData[]=
1171{
1172 { 1, 1, 800, 449, 800, 449},
1173 { 1, 1, 800, 449, 800, 449},
1174 { 1, 1, 900, 449, 900, 449},
1175 { 1, 1, 900, 449, 900, 449},
1176 { 1, 1, 800, 525, 800, 525},
1177 { 1, 1,1056, 628,1056, 628},
1178 { 1, 1,1344, 806,1344, 806},
1179 { 1, 1,1688,1066,1688,1066}
1180};
1181
1182XGI330_LCDDataStruct XGI_ExtLCD1024x768x75Data[]=
1183{
1184 {42,25,1536,419,1344,806 }, /* ; 00 (320x200,320x400,640x200,640x400) */
1185 {48,25,1536,369,1344,806 }, /* ; 01 (320x350,640x350) */
1186 {42,25,1536,419,1344,806 }, /* ; 02 (360x400,720x400) */
1187 {48,25,1536,369,1344,806 }, /* ; 03 (720x350) */
1188 {8,5,1312,500,1312,800 }, /* ; 04 (640x480x75Hz) */
1189 {41,25,1024,625,1312,800 }, /* ; 05 (800x600x75Hz) */
1190 {1,1,1312,800,1312,800 } /* ; 06 (1024x768x75Hz) */
1191};
1192
1193XGI330_LCDDataStruct XGI_StLCD1024x768x75Data[]=
1194{
1195 {42,25,1536,419,1344,806 }, /* ; 00 (320x200,320x400,640x200,640x400) */
1196 {48,25,1536,369,1344,806 }, /* ; 01 (320x350,640x350) */
1197 {42,25,1536,419,1344,806 }, /* ; 02 (360x400,720x400) */
1198 {48,25,1536,369,1344,806 }, /* ; 03 (720x350) */
1199 {8,5,1312,500,1312,800 }, /* ; 04 (640x480x75Hz) */
1200 {41,25,1024,625,1312,800 }, /* ; 05 (800x600x75Hz) */
1201 {1,1,1312,800,1312,800 } /* ; 06 (1024x768x75Hz) */
1202};
1203
1204XGI330_LCDDataStruct XGI_CetLCD1024x768x75Data[]=
1205{
1206 {1,1,1312,800,1312,800}, /* ; 00 (320x200,320x400,640x200,640x400) */
1207 {1,1,1312,800,1312,800}, /* ; 01 (320x350,640x350) */
1208 {1,1,1312,800,1312,800}, /* ; 02 (360x400,720x400) */
1209 {1,1,1312,800,1312,800}, /* ; 03 (720x350) */
1210 {1,1,1312,800,1312,800}, /* ; 04 (640x480x75Hz) */
1211 {1,1,1312,800,1312,800}, /* ; 05 (800x600x75Hz) */
1212 {1,1,1312,800,1312,800} /* ; 06 (1024x768x75Hz) */
1213};
1214
1215XGI330_LCDDataStruct XGI_ExtLCD1280x1024x75Data[]=
1216{
1217 {211,60,1024,501,1688,1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
1218 {211,60,1024,508,1688,1066 }, /* ; 01 (320x350,640x350) */
1219 {211,60,1024,501,1688,1066 }, /* ; 02 (360x400,720x400) */
1220 {211,60,1024,508,1688,1066 }, /* ; 03 (720x350) */
1221 {211,45,768,498,1688,1066 }, /* ; 04 (640x480x75Hz) */
1222 {211,75,1024,625,1688,1066 }, /* ; 05 (800x600x75Hz) */
1223 {211,120,1280,798,1688,1066 }, /* ; 06 (1024x768x75Hz) */
1224 {1,1,1688,1066,1688,1066 } /* ; 07 (1280x1024x75Hz) */
1225};
1226
1227XGI330_LCDDataStruct XGI_StLCD1280x1024x75Data[]=
1228{
1229 {211,60,1024,501,1688,1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
1230 {211,60,1024,508,1688,1066 }, /* ; 01 (320x350,640x350) */
1231 {211,60,1024,501,1688,1066 }, /* ; 02 (360x400,720x400) */
1232 {211,60,1024,508,1688,1066 }, /* ; 03 (720x350) */
1233 {211,45,768,498,1688,1066 }, /* ; 04 (640x480x75Hz) */
1234 {211,75,1024,625,1688,1066 }, /* ; 05 (800x600x75Hz) */
1235 {211,120,1280,798,1688,1066}, /* ; 06 (1024x768x75Hz) */
1236 {1,1,1688,1066,1688,1066 } /* ; 07 (1280x1024x75Hz) */
1237};
1238
1239XGI330_LCDDataStruct XGI_CetLCD1280x1024x75Data[]=
1240{
1241 {1,1,1688,1066,1688,1066}, /* ; 00 (320x200,320x400,640x200,640x400) */
1242 {1,1,1688,1066,1688,1066}, /* ; 01 (320x350,640x350) */
1243 {1,1,1688,1066,1688,1066}, /* ; 02 (360x400,720x400) */
1244 {1,1,1688,1066,1688,1066}, /* ; 03 (720x350) */
1245 {1,1,1688,1066,1688,1066}, /* ; 04 (640x480x75Hz) */
1246 {1,1,1688,1066,1688,1066}, /* ; 05 (800x600x75Hz) */
1247 {1,1,1688,1066,1688,1066}, /* ; 06 (1024x768x75Hz) */
1248 {1,1,1688,1066,1688,1066} /* ; 07 (1280x1024x75Hz) */
1249};
1250
1251XGI330_LCDDataStruct XGI_NoScalingDatax75[]=
1252{
1253 {1,1,800,449,800,449 }, /* ; 00 (320x200,320x400,640x200,640x400) */
1254 {1,1,800,449,800,449 }, /* ; 01 (320x350,640x350) */
1255 {1,1,900,449,900,449 }, /* ; 02 (360x400,720x400) */
1256 {1,1,900,449,900,449 }, /* ; 03 (720x350) */
1257 {1,1,840,500,840,500 }, /* ; 04 (640x480x75Hz) */
1258 {1,1,1056,625,1056,625 }, /* ; 05 (800x600x75Hz) */
1259 {1,1,1312,800,1312,800 }, /* ; 06 (1024x768x75Hz) */
1260 {1,1,1688,1066,1688,1066}, /* ; 07 (1280x1024x75Hz) */
1261 {1,1,1688,1066,1688,1066}, /* ; 08 (1400x1050x75Hz) ;;[ycchen] 12/19/02 */
1262 {1,1,2160,1250,2160,1250}, /* ; 09 (1600x1200x75Hz) */
1263 {1,1,1688,806,1688,806 } /* ; 0A (1280x768x75Hz) */
1264};
1265
1266XGI330_LCDDataDesStruct XGI_ExtLCDDes1024x768Data[]=
1267{
1268 { 9,1057,0, 771 }, /* ; 00 (320x200,320x400,640x200,640x400) */
1269 { 9,1057,0, 771 }, /* ; 01 (320x350,640x350) */
1270 { 9,1057,0, 771 }, /* ; 02 (360x400,720x400) */
1271 { 9,1057,0, 771 }, /* ; 03 (720x350) */
1272 { 9,1057,0, 771 }, /* ; 04 (640x480x60Hz) */
1273 { 9,1057,0, 771 }, /* ; 05 (800x600x60Hz) */
1274 { 9,1057,805, 770 } /* ; 06 (1024x768x60Hz) */
1275};
1276
1277XGI330_LCDDataDesStruct XGI_StLCDDes1024x768Data[]=
1278{
1279 { 9,1057,737,703 }, /* ; 00 (320x200,320x400,640x200,640x400) */
1280 { 9,1057,686,651 }, /* ; 01 (320x350,640x350) */
1281 { 9,1057,737,703 }, /* ; 02 (360x400,720x400) */
1282 { 9,1057,686,651 }, /* ; 03 (720x350) */
1283 { 9,1057,776,741 }, /* ; 04 (640x480x60Hz) */
1284 { 9,1057, 0 ,771 }, /* ; 05 (800x600x60Hz) */
1285 { 9,1057,805,770 } /* ; 06 (1024x768x60Hz) */
1286};
1287
1288XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768Data[]=
1289{
1290 { 1152,856,622,587 }, /* ; 00 (320x200,320x400,640x200,640x400) */
1291 { 1152,856,597,562 }, /* ; 01 (320x350,640x350) */
1292 { 1152,856,622,587 }, /* ; 02 (360x400,720x400) */
1293 { 1152,856,597,562 }, /* ; 03 (720x350) */
1294 { 1152,856,662,627 }, /* ; 04 (640x480x60Hz) */
1295 { 1232,936,722,687 }, /* ; 05 (800x600x60Hz) */
1296 { 0,1048,805,770 } /* ; 06 (1024x768x60Hz) */
1297};
1298
1299XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024Data[]=
1300{
1301 { 18,1346,981,940 },/* 00 (320x200,320x400,640x200,640x400) */
1302 { 18,1346,926,865 },/* 01 (320x350,640x350) */
1303 { 18,1346,981,940 },/* 02 (360x400,720x400) */
1304 { 18,1346,926,865 },/* 03 (720x350) */
1305 { 18,1346,0,1025 },/* 04 (640x480x60Hz) */
1306 { 18,1346,0,1025 },/* 05 (800x600x60Hz) */
1307 { 18,1346,1065,1024 },/* 06 (1024x768x60Hz) */
1308 { 18,1346,1065,1024 }/* 07 (1280x1024x60Hz) */
1309};
1310
1311XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024Data[]=
1312{
1313 { 18,1346,970,907 },/* 00 (320x200,320x400,640x200,640x400) */
1314 { 18,1346,917,854 },/* 01 (320x350,640x350) */
1315 { 18,1346,970,907 },/* 02 (360x400,720x400) */
1316 { 18,1346,917,854 },/* 03 (720x350) */
1317 { 18,1346,0,1025 },/* 04 (640x480x60Hz) */
1318 { 18,1346,0,1025 },/* 05 (800x600x60Hz) */
1319 { 18,1346,1065,1024 },/* 06 (1024x768x60Hz) */
1320 { 18,1346,1065,1024 }/* 07 (1280x1024x60Hz) */
1321};
1322
1323XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024Data[]=
1324{
1325 { 1368,1008,752,711 }, /* 00 (320x200,320x400,640x200,640x400) */
1326 { 1368,1008,729,688 }, /* 01 (320x350,640x350) */
1327 { 1368,1008,752,711 }, /* 02 (360x400,720x400) */
1328 { 1368,1008,729,688 }, /* 03 (720x350) */
1329 { 1368,1008,794,753 }, /* 04 (640x480x60Hz) */
1330 { 1448,1068,854,813 }, /* 05 (800x600x60Hz) */
1331 { 1560,1200,938,897 }, /* 06 (1024x768x60Hz) */
1332 { 18,1346,1065,1024 } /* 07 (1280x1024x60Hz) */
1333};
1334
1335XGI330_LCDDataDesStruct XGI_ExtLCDDes1280x1024Data[]=
1336{
1337 { 9,1337,981,940 }, /* ; 00 (320x200,320x400,640x200,640x400) */
1338 { 9,1337,926,884 }, /* ; 01 (320x350,640x350) alan, 2003/09/30 */
1339 { 9,1337,981,940 }, /* ; 02 (360x400,720x400) */
1340 { 9,1337,926,884 }, /* ; 03 (720x350) alan, 2003/09/30 */
1341 { 9,1337,0,1025 }, /* ; 04 (640x480x60Hz) */
1342 { 9,1337,0,1025 }, /* ; 05 (800x600x60Hz) */
1343 { 9,1337,1065,1024 }, /* ; 06 (1024x768x60Hz) */
1344 { 9,1337,1065,1024 } /* ; 07 (1280x1024x60Hz) */
1345};
1346
1347XGI330_LCDDataDesStruct XGI_StLCDDes1280x1024Data[]=
1348{
1349 { 9,1337,970,907 }, /* ; 00 (320x200,320x400,640x200,640x400) */
1350 { 9,1337,917,854 }, /* ; 01 (320x350,640x350) */
1351 { 9,1337,970,907 }, /* ; 02 (360x400,720x400) */
1352 { 9,1337,917,854 }, /* ; 03 (720x350) */
1353 { 9,1337,0,1025 }, /* ; 04 (640x480x60Hz) */
1354 { 9,1337,0,1025 }, /* ; 05 (800x600x60Hz) */
1355 { 9,1337,1065,1024 }, /* ; 06 (1024x768x60Hz) */
1356 { 9,1337,1065,1024 } /* ; 07 (1280x1024x60Hz) */
1357};
1358
1359XGI330_LCDDataDesStruct XGI_CetLCDDes1280x1024Data[]=
1360{
1361 { 1368,1008,752,711 }, /* 00 (320x200,320x400,640x200,640x400) */
1362 { 1368,1008,729,688 }, /* 01 (320x350,640x350) */
1363 { 1368,1008,752,711 }, /* 02 (360x400,720x400) */
1364 { 1368,1008,729,688 }, /* 03 (720x350) */
1365 { 1368,1008,794,753 }, /* 04 (640x480x60Hz) */
1366 { 1448,1068,854,813 }, /* 05 (800x600x60Hz) */
1367 { 1560,1200,938,897 }, /* 06 (1024x768x60Hz) */
1368 { 9,1337,1065,1024 } /* 07 (1280x1024x60Hz) */
1369};
1370
1371XGI330_LCDDataDesStruct XGI_StLCDDLDes1400x1050Data[]=
1372{
1373 { 18,1464,0,1051 }, /* 00 (320x200,320x400,640x200,640x400) */
1374 { 18,1464,0,1051 }, /* 01 (320x350,640x350) */
1375 { 18,1464,0,1051 }, /* 02 (360x400,720x400) */
1376 { 18,1464,0,1051 }, /* 03 (720x350) */
1377 { 18,1464,0,1051 }, /* 04 (640x480x60Hz) */
1378 { 18,1464,0,1051 }, /* 05 (800x600x60Hz) */
1379 { 18,1464,0,1051 }, /* 06 (1024x768x60Hz) */
1380 { 1646,1406,1053,1038 }, /* 07 (1280x1024x60Hz) */
1381 { 18,1464,0,1051 } /* 08 (1400x1050x60Hz) */
1382};
1383
1384XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1400x1050Data[]=
1385{
1386 { 18,1464,0,1051 }, /* 00 (320x200,320x400,640x200,640x400) */
1387 { 18,1464,0,1051 }, /* 01 (320x350,640x350) */
1388 { 18,1464,0,1051 }, /* 02 (360x400,720x400) */
1389 { 18,1464,0,1051 }, /* 03 (720x350) */
1390 { 18,1464,0,1051 }, /* 04 (640x480x60Hz) */
1391 { 18,1464,0,1051 }, /* 05 (800x600x60Hz) */
1392 { 18,1464,0,1051 }, /* 06 (1024x768x60Hz) */
1393 { 1646,1406,1053,1038 }, /* 07 (1280x1024x60Hz) */
1394 { 18,1464,0,1051 } /* 08 (1400x1050x60Hz) */
1395};
1396
1397XGI330_LCDDataDesStruct XGI_StLCDDes1400x1050Data[]=
1398{
1399 { 9,1455,0,1051 },/* 00 (320x200,320x400,640x200,640x400) */
1400 { 9,1455,0,1051 },/* 01 (320x350,640x350) */
1401 { 9,1455,0,1051 },/* 02 (360x400,720x400) */
1402 { 9,1455,0,1051 },/* 03 (720x350) */
1403 { 9,1455,0,1051 },/* 04 (640x480x60Hz) */
1404 { 9,1455,0,1051 },/* 05 (800x600x60Hz) */
1405 { 9,1455,0,1051 },/* 06 (1024x768x60Hz) */
1406 { 1637,1397,1053,1038 },/* 07 (1280x1024x60Hz) */
1407 { 9,1455,0,1051 } /* 08 (1400x1050x60Hz) */
1408};
1409
1410XGI330_LCDDataDesStruct XGI_ExtLCDDes1400x1050Data[]=
1411{
1412 { 9,1455,0,1051 },/* 00 (320x200,320x400,640x200,640x400) */
1413 { 9,1455,0,1051 },/* 01 (320x350,640x350) */
1414 { 9,1455,0,1051 },/* 02 (360x400,720x400) */
1415 { 9,1455,0,1051 },/* 03 (720x350) */
1416 { 9,1455,0,1051 },/* 04 (640x480x60Hz) */
1417 { 9,1455,0,1051 },/* 05 (800x600x60Hz) */
1418 { 9,1455,0,1051 },/* 06 (1024x768x60Hz) */
1419 { 1637,1397,1053,1038 },/* 07 (1280x1024x60Hz) */
1420 { 9,1455,0,1051 } /* 08 (1400x1050x60Hz) */
1421};
1422
1423XGI330_LCDDataDesStruct XGI_CetLCDDes1400x1050Data[]=
1424{
1425 { 1308,1068,781,766 }, /* 00 (320x200,320x400,640x200,640x400) */
1426 { 1308,1068,781,766 }, /* 01 (320x350,640x350) */
1427 { 1308,1068,781,766 }, /* 02 (360x400,720x400) */
1428 { 1308,1068,781,766 }, /* 03 (720x350) */
1429 { 1308,1068,781,766 }, /* 04 (640x480x60Hz) */
1430 { 1388,1148,841,826 }, /* 05 (800x600x60Hz) */
1431 { 1490,1250,925,910 }, /* 06 (1024x768x60Hz) */
1432 { 1646,1406,1053,1038 }, /* 07 (1280x1024x60Hz) */
1433 { 18,1464,0,1051 } /* 08 (1400x1050x60Hz) */
1434};
1435
1436XGI330_LCDDataDesStruct XGI_CetLCDDes1400x1050Data2[]=
1437{
1438 { 0,1448,0,1051 }, /* 00 (320x200,320x400,640x200,640x400) */
1439 { 0,1448,0,1051 }, /* 01 (320x350,640x350) */
1440 { 0,1448,0,1051 }, /* 02 (360x400,720x400) */
1441 { 0,1448,0,1051 }, /* 03 (720x350) */
1442 { 0,1448,0,1051 } /* 04 (640x480x60Hz) */
1443};
1444
1445
1446
1447XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1600x1200Data[]=
1448{
1449 { 18,1682,0,1201 }, /* 00 (320x200,320x400,640x200,640x400) */
1450 { 18,1682,0,1201 }, /* 01 (320x350,640x350) */
1451 { 18,1682,0,1201 }, /* 02 (360x400,720x400) */
1452 { 18,1682,0,1201 }, /* 03 (720x350) */
1453 { 18,1682,0,1201 }, /* 04 (640x480x60Hz) */
1454 { 18,1682,0,1201 }, /* 05 (800x600x60Hz) */
1455 { 18,1682,0,1201 }, /* 06 (1024x768x60Hz) */
1456 { 18,1682,0,1201 }, /* 07 (1280x1024x60Hz) */
1457 { 18,1682,0,1201 }, /* 08 (1400x1050x60Hz) */
1458 { 18,1682,0,1201 } /* 09 (1600x1200x60Hz) */
1459};
1460
1461XGI330_LCDDataDesStruct XGI_StLCDDLDes1600x1200Data[]=
1462{
1463 { 18,1682,1150,1101 }, /* 00 (320x200,320x400,640x200,640x400) */
1464 { 18,1682,1083,1034 }, /* 01 (320x350,640x350) */
1465 { 18,1682,1150,1101 }, /* 02 (360x400,720x400) */
1466 { 18,1682,1083,1034 }, /* 03 (720x350) */
1467 { 18,1682,0,1201 }, /* 04 (640x480x60Hz) */
1468 { 18,1682,0,1201 }, /* 05 (800x600x60Hz) */
1469 { 18,1682,0,1201 }, /* 06 (1024x768x60Hz) */
1470 { 18,1682,1232,1183 }, /* 07 (1280x1024x60Hz) */
1471 { 18,1682,0,1201 }, /* 08 (1400x1050x60Hz) */
1472 { 18,1682,0,1201 } /* 09 (1600x1200x60Hz) */
1473};
1474
1475XGI330_LCDDataDesStruct XGI_ExtLCDDes1600x1200Data[]=
1476{
1477 { 9,1673,0,1201 },/* 00 (320x200,320x400,640x200,640x400) */
1478 { 9,1673,0,1201 },/* 01 (320x350,640x350) */
1479 { 9,1673,0,1201 },/* 02 (360x400,720x400) */
1480 { 9,1673,0,1201 },/* 03 (720x350) */
1481 { 9,1673,0,1201 },/* 04 (640x480x60Hz) */
1482 { 9,1673,0,1201 },/* 05 (800x600x60Hz) */
1483 { 9,1673,0,1201 },/* 06 (1024x768x60Hz) */
1484 { 9,1673,0,1201 },/* 07 (1280x1024x60Hz) */
1485 { 9,1673,0,1201 },/* 08 (1400x1050x60Hz) */
1486 { 9,1673,0,1201 } /* 09 (1600x1200x60Hz) */
1487};
1488
1489XGI330_LCDDataDesStruct XGI_StLCDDes1600x1200Data[]=
1490{
1491 { 9,1673,1150,1101 },/* 00 (320x200,320x400,640x200,640x400) */
1492 { 9,1673,1083,1034 },/* 01 (320x350,640x350) */
1493 { 9,1673,1150,1101 },/* 02 (360x400,720x400) */
1494 { 9,1673,1083,1034 },/* 03 (720x350) */
1495 { 9,1673,0,1201 },/* 04 (640x480x60Hz) */
1496 { 9,1673,0,1201 },/* 05 (800x600x60Hz) */
1497 { 9,1673,0,1201 },/* 06 (1024x768x60Hz) */
1498 { 9,1673,1232,1183 },/* 07 (1280x1024x60Hz) */
1499 { 9,1673,0,1201 },/* 08 (1400x1050x60Hz) */
1500 { 9,1673,0,1201 } /* 09 (1600x1200x60Hz) */
1501};
1502
1503XGI330_LCDDataDesStruct2 XGI_NoScalingDesData[]=
1504{
1505 { 9,657,448,405,96,2 }, /* 00 (320x200,320x400,640x200,640x400) */
1506 { 9,657,448,355,96,2 }, /* 01 (320x350,640x350) */
1507 { 9,657,448,405,96,2 }, /* 02 (360x400,720x400) */
1508 { 9,657,448,355,96,2 }, /* 03 (720x350) */
1509 { 9,657,1,483,96,2 }, /* 04 (640x480x60Hz) */
1510 { 9,849,627,600,128,4 }, /* 05 (800x600x60Hz) */
1511 { 9,1057,805,770,0136,6 }, /* 06 (1024x768x60Hz) */
1512 { 9,1337,0,1025,112,3 }, /* 07 (1280x1024x60Hz) */
1513 { 9,1457,0,1051,112,3 }, /* 08 (1400x1050x60Hz) }, //;[ycchen] 12/19/02 */
1514 { 9,1673,0,1201,192,3 }, /* 09 (1600x1200x60Hz) */
1515 { 9,1337,0,771,112,6 } /* 0A (1280x768x60Hz) */
1516};
1517
1518XGI330_LCDDataDesStruct XGI_ExtLCDDes1024x768x75Data[]= /* ;;1024x768x75Hz */
1519{
1520 {9,1049,0,769}, /* ; 00 (320x200,320x400,640x200,640x400) */
1521 {9,1049,0,769}, /* ; 01 (320x350,640x350) */
1522 {9,1049,0,769}, /* ; 02 (360x400,720x400) */
1523 {9,1049,0,769}, /* ; 03 (720x350) */
1524 {9,1049,0,769}, /* ; 04 (640x480x75Hz) */
1525 {9,1049,0,769}, /* ; 05 (800x600x75Hz) */
1526 {9,1049,0,769} /* ; 06 (1024x768x75Hz) */
1527};
1528
1529XGI330_LCDDataDesStruct XGI_StLCDDes1024x768x75Data[]=
1530{
1531 {9,1049,0,769}, /* ; 00 (320x200,320x400,640x200,640x400) */
1532 {9,1049,0,769}, /* ; 01 (320x350,640x350) */
1533 {9,1049,0,769}, /* ; 02 (360x400,720x400) */
1534 {9,1049,0,769}, /* ; 03 (720x350) */
1535 {9,1049,0,769}, /* ; 04 (640x480x75Hz) */
1536 {9,1049,0,769}, /* ; 05 (800x600x75Hz) */
1537 {9,1049,0,769} /* ; 06 (1024x768x75Hz) */
1538};
1539
1540XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768x75Data[]= /* ;;1024x768x75Hz */
1541{
1542 {1152,856,622,587}, /* ; 00 (320x200,320x400,640x200,640x400) */
1543 {1152,856,597,562}, /* ; 01 (320x350,640x350) */
1544 {1192,896,622,587}, /* ; 02 (360x400,720x400) */
1545 {1192,896,597,562}, /* ; 03 (720x350) */
1546 {1129,857,656,625}, /* ; 04 (640x480x75Hz) */
1547 {1209,937,716,685}, /* ; 05 (800x600x75Hz) */
1548 {9,1049,0,769} /* ; 06 (1024x768x75Hz) */
1549};
1550
1551XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024x75Data[]= /* ;;1280x1024x75Hz */
1552{
1553 {18,1314,0,1025 },/* ; 00 (320x200,320x400,640x200,640x400) */
1554 {18,1314,0,1025 },/* ; 01 (320x350,640x350) */
1555 {18,1314,0,1025 },/* ; 02 (360x400,720x400) */
1556 {18,1314,0,1025 },/* ; 03 (720x350) */
1557 {18,1314,0,1025 },/* ; 04 (640x480x60Hz) */
1558 {18,1314,0,1025 },/* ; 05 (800x600x60Hz) */
1559 {18,1314,0,1025 },/* ; 06 (1024x768x60Hz) */
1560 {18,1314,0,1025 }/* ; 07 (1280x1024x60Hz) */
1561};
1562
1563XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024x75Data[]=
1564{
1565 {18,1314,0,1025 },/* ; 00 (320x200,320x400,640x200,640x400) */
1566 {18,1314,0,1025 },/* ; 01 (320x350,640x350) */
1567 {18,1314,0,1025 },/* ; 02 (360x400,720x400) */
1568 {18,1314,0,1025 },/* ; 03 (720x350) */
1569 {18,1314,0,1025 },/* ; 04 (640x480x60Hz) */
1570 {18,1314,0,1025 },/* ; 05 (800x600x60Hz) */
1571 {18,1314,0,1025 },/* ; 06 (1024x768x60Hz) */
1572 {18,1314,0,1025 }/* ; 07 (1280x1024x60Hz) */
1573};
1574
1575XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024x75Data[]= /* 1280x1024x75Hz */
1576{
1577 {1368,1008,752,711}, /* ; 00 (320x200,320x400,640x200,640x400) */
1578 {1368,1008,729,688}, /* ; 01 (320x350,640x350) */
1579 {1408,1048,752,711}, /* ; 02 (360x400,720x400) */
1580 {1408,1048,729,688}, /* ; 03 (720x350) */
1581 {1377,985,794,753}, /* ; 04 (640x480x75Hz) */
1582 {1457,1065,854,813}, /* ; 05 (800x600x75Hz) */
1583 {1569,1177,938,897}, /* ; 06 (1024x768x75Hz) */
1584 {18,1314,0,1025} /* ; 07 (1280x1024x75Hz) */
1585};
1586
1587XGI330_LCDDataDesStruct XGI_ExtLCDDes1280x1024x75Data[]= /* ;;1280x1024x75Hz */
1588{
1589 {9,1305,0,1025},/* ; 00 (320x200,320x400,640x200,640x400) */
1590 {9,1305,0,1025},/* ; 01 (320x350,640x350) */
1591 {9,1305,0,1025},/* ; 02 (360x400,720x400) */
1592 {9,1305,0,1025},/* ; 03 (720x350) */
1593 {9,1305,0,1025},/* ; 04 (640x480x60Hz) */
1594 {9,1305,0,1025},/* ; 05 (800x600x60Hz) */
1595 {9,1305,0,1025},/* ; 06 (1024x768x60Hz) */
1596 {9,1305,0,1025} /* ; 07 (1280x1024x60Hz) */
1597};
1598
1599XGI330_LCDDataDesStruct XGI_StLCDDes1280x1024x75Data[]=
1600{
1601 {9,1305,0,1025},/* ; 00 (320x200,320x400,640x200,640x400) */
1602 {9,1305,0,1025},/* ; 01 (320x350,640x350) */
1603 {9,1305,0,1025},/* ; 02 (360x400,720x400) */
1604 {9,1305,0,1025},/* ; 03 (720x350) */
1605 {9,1305,0,1025},/* ; 04 (640x480x60Hz) */
1606 {9,1305,0,1025},/* ; 05 (800x600x60Hz) */
1607 {9,1305,0,1025},/* ; 06 (1024x768x60Hz) */
1608 {9,1305,0,1025} /* ; 07 (1280x1024x60Hz) */
1609};
1610
1611XGI330_LCDDataDesStruct XGI_CetLCDDes1280x1024x75Data[]= /* 1280x1024x75Hz */
1612{
1613 {1368,1008,752,711}, /* ; 00 (320x200,320x400,640x200,640x400) */
1614 {1368,1008,729,688}, /* ; 01 (320x350,640x350) */
1615 {1408,1048,752,711}, /* ; 02 (360x400,720x400) */
1616 {1408,1048,729,688}, /* ; 03 (720x350) */
1617 {1377,985,794,753}, /* ; 04 (640x480x75Hz) */
1618 {1457,1065,854,813}, /* ; 05 (800x600x75Hz) */
1619 {1569,1177,938,897}, /* ; 06 (1024x768x75Hz) */
1620 {9,1305,0,1025} /* ; 07 (1280x1024x75Hz) */
1621};
1622
1623XGI330_LCDDataDesStruct2 XGI_NoScalingDesDatax75[]= /* Scaling LCD 75Hz */
1624{
1625 {9,657,448,405,96,2}, /* ; 00 (320x200,320x400,640x200,640x400) */
1626 {9,657,448,355,96,2}, /* ; 01 (320x350,640x350) */
1627 {9,738,448,405,108,2}, /* ; 02 (360x400,720x400) */
1628 {9,738,448,355,108,2}, /* ; 03 (720x350) */
1629 {9,665,0,481,64,3}, /* ; 04 (640x480x75Hz) */
1630 {9,825,0,601,80,3}, /* ; 05 (800x600x75Hz) */
1631 {9,1049,0,769,96,3}, /* ; 06 (1024x768x75Hz) */
1632 {9,1305,0,1025,144,3}, /* ; 07 (1280x1024x75Hz) */
1633 {9,1457,0,1051,112,3}, /* ; 08 (1400x1050x60Hz) ;;[ycchen] 12/19/02 */
1634 {9,1673,0,1201,192,3}, /* ; 09 (1600x1200x75Hz) */
1635 {9,1337,0,771,112,6} /* ; 0A (1280x768x60Hz) */
1636};
1637
1638XGI330_TVDataStruct XGI_StPALData[]=
1639{
1640 { 1, 1, 864, 525,1270, 400, 100, 0, 760},
1641 { 1, 1, 864, 525,1270, 350, 100, 0, 760},
1642 { 1, 1, 864, 525,1270, 400, 0, 0, 720},
1643 { 1, 1, 864, 525,1270, 350, 0, 0, 720},
1644 { 1, 1, 864, 525,1270, 480, 50, 0, 760},
1645 { 1, 1, 864, 525,1270, 600, 50, 0, 0}
1646};
1647
1648XGI330_TVDataStruct XGI_ExtPALData[]=
1649{
1650 { 2, 1,1080, 463,1270, 500, 50, 0, 50},
1651 { 15, 7,1152, 413,1270, 500, 50, 0, 50},
1652 { 2, 1,1080, 463,1270, 500, 50, 0, 50},
1653 { 15, 7,1152, 413,1270, 500, 50, 0, 50},
1654 { 2, 1, 900, 543,1270, 500, 0, 0, 50},
1655 { 4, 3,1080, 663,1270, 500, 438, 0, 438},
1656 { 1, 1,1125, 831,1270, 500, 686, 0, 686}, /*301b*/
1657 { 3, 2,1080, 619,1270, 540, 438, 0, 438}
1658};
1659
1660XGI330_TVDataStruct XGI_StNTSCData[]=
1661{
1662 { 1, 1, 858, 525,1270, 400, 50, 0, 760},
1663 { 1, 1, 858, 525,1270, 350, 50, 0, 640},
1664 { 1, 1, 858, 525,1270, 400, 0, 0, 720},
1665 { 1, 1, 858, 525,1270, 350, 0, 0, 720},
1666 { 1, 1, 858, 525,1270, 480, 0, 0, 760}
1667};
1668
1669XGI330_TVDataStruct XGI_ExtNTSCData[]=
1670{
1671 { 9, 5, 1001, 453,1270, 420, 171, 0, 171},
1672 { 12, 5, 858, 403,1270, 420, 171, 0, 171},
1673 { 9, 5, 1001, 453,1270, 420, 171, 0, 171},
1674 { 12, 5, 858, 403,1270, 420, 171, 0, 171},
1675 { 143, 80, 836, 523,1270, 420, 224, 0, 0},
1676 { 143, 120,1008, 643,1270, 420, 0, 1, 0},
1677 { 1, 1,1120, 821,1516, 420, 0, 1, 0}, /*301b*/
1678 { 2, 1, 858, 503,1584, 480, 0, 1, 0},
1679 { 3, 2,1001, 533,1270, 420, 0, 0, 0}
1680};
1681
1682XGI330_TVDataStruct XGI_St1HiTVData[]=
1683{
1684 { 1,1,892,563,690,800,0,0,0 }, /* 00 (320x200,320x400,640x200,640x400) */
1685 { 1,1,892,563,690,700,0,0,0 }, /* 01 (320x350,640x350) */
1686 { 1,1,1000,563,785,800,0,0,0 }, /* 02 (360x400,720x400) */
1687 { 1,1,1000,563,785,700,0,0,0 }, /* 03 (720x350) */
1688 { 1,1,892,563,690,960,0,0,0 }, /* 04 (320x240,640x480) */
1689 { 8,5,1050,683,1648,960,0x150,1,0 } /* 05 (400x300,800x600) */
1690};
1691
1692XGI330_TVDataStruct XGI_St2HiTVData[]=
1693{
1694 { 3,1,840,483,1648,960,0x032,0,0 }, /* 00 (320x200,320x400,640x200,640x400) */
1695 { 1,1,892,563,690,700,0,0,0 }, /* 01 (320x350,640x350) */
1696 { 3,1,840,483,1648,960,0x032,0,0 }, /* 02 (360x400,720x400) */
1697 { 1,1,1000,563,785,700,0,0,0 }, /* 03 (720x350) */
1698 { 5,2,840,563,1648,960,0x08D,1,0 }, /* 04 (320x240,640x480) */
1699 { 8,5,1050,683,1648,960,0x17C,1,0 } /* 05 (400x300,800x600) */
1700
1701};
1702
1703XGI330_TVDataStruct XGI_ExtHiTVData[]=
1704{
1705 { 6,1,840,563,1632,960,0,0,0 }, /* 00 (320x200,320x400,640x200,640x400) */
1706 { 3,1,960,563,1632,960,0,0,0 }, /* 01 (320x350,640x350) */
1707 { 3,1,840,483,1632,960,0,0,0 }, /* 02 (360x400,720x400) */
1708 { 3,1,960,563,1632,960,0,0,0 }, /* 03 (720x350) */
1709 { 5,1,840,563,1648,960,0x166,1,0 }, /* 04 (320x240,640x480) */
1710 { 16,5,1050,683,1648,960,0x143,1,0 }, /* 05 (400x300,800x600) */
1711 { 25,12,1260,851,1648,960,0x032,0,0 }, /* 06 (512x384,1024x768) */
1712 { 5,4,1575,1124,1648,960,0x128,0,0 }, /* 07 (1280x1024) */
1713 { 4,1,1050,563,1548,960,0x143,1,0 }, /* 08 (800x480) */
1714 { 5,2,1400,659,1648,960,0x032,0,0 }, /* 09 (1024x576) */
1715 { 8,5,1750,803,1648,960,0x128,0,0 } /* 0A (1280x720) */
1716
1717};
1718
1719XGI330_TVDataStruct XGI_ExtYPbPr525iData[]=
1720{
1721 { 9, 5, 1001, 453,1270, 420, 171, 0, 171},
1722 { 12, 5, 858, 403,1270, 420, 171, 0, 171},
1723 { 9, 5, 1001, 453,1270, 420, 171, 0, 171},
1724 { 12, 5, 858, 403,1270, 420, 171, 0, 171},
1725 { 143, 80, 836, 523,1250, 420, 224, 0, 0},
1726 { 143, 120,1008, 643,1250, 420, 0, 1, 0},
1727 { 1, 1,1120, 821,1516, 420, 0, 1, 0}, /*301b*/
1728 { 2, 1, 858, 503,1584, 480, 0, 1, 0},
1729 { 3, 2,1001, 533,1250, 420, 0, 0, 0}
1730};
1731
1732XGI330_TVDataStruct XGI_StYPbPr525iData[]=
1733{
1734 { 1, 1, 858, 525,1270, 400, 50, 0, 760},
1735 { 1, 1, 858, 525,1270, 350, 50, 0, 640},
1736 { 1, 1, 858, 525,1270, 400, 0, 0, 720},
1737 { 1, 1, 858, 525,1270, 350, 0, 0, 720},
1738 { 1, 1, 858, 525,1270, 480, 0, 0, 760},
1739};
1740
1741XGI330_TVDataStruct XGI_ExtYPbPr525pData[]=
1742{
1743 { 9, 5, 1001, 453,1270, 420, 171, 0, 171},
1744 { 12, 5, 858, 403,1270, 420, 171, 0, 171},
1745 { 9, 5, 1001, 453,1270, 420, 171, 0, 171},
1746 { 12, 5, 858, 403,1270, 420, 171, 0, 171},
1747 { 143, 80, 836, 523,1270, 420, 224, 0, 0},
1748 { 143, 120,1008, 643,1270, 420, 0, 1, 0},
1749 { 1, 1,1120, 821,1516, 420, 0, 1, 0}, /*301b*/
1750 { 2, 1, 858, 503,1584, 480, 0, 1, 0},
1751 { 3, 2,1001, 533,1270, 420, 0, 0, 0}
1752 };
1753
1754XGI330_TVDataStruct XGI_StYPbPr525pData[]=
1755{
1756 { 1, 1,1716, 525,1270, 400, 50, 0, 760},
1757 { 1, 1,1716, 525,1270, 350, 50, 0, 640},
1758 { 1, 1,1716, 525,1270, 400, 0, 0, 720},
1759 { 1, 1,1716, 525,1270, 350, 0, 0, 720},
1760 { 1, 1,1716, 525,1270, 480, 0, 0, 760},
1761};
1762
1763XGI330_TVDataStruct XGI_ExtYPbPr750pData[]=
1764{
1765 { 3, 1, 935, 470,1130, 680, 50, 0, 0}, /* 00 (320x200,320x400,640x200,640x400) */
1766 { 24, 7, 935, 420,1130, 680, 50, 0, 0}, /* 01 (320x350,640x350) */
1767 { 3, 1, 935, 470,1130, 680, 50, 0, 0}, /* 02 (360x400,720x400) */
1768 { 24, 7, 935, 420,1130, 680, 50, 0, 0}, /* 03 (720x350) */
1769 { 2, 1,1100, 590,1130, 640, 50, 0, 0}, /* 04 (320x240,640x480) */
1770 { 3, 2,1210, 690,1130, 660, 50, 0, 0}, /* 05 (400x300,800x600) */
1771 { 1, 1,1375, 878,1130, 640, 638, 0, 0}, /* 06 (1024x768) */
1772 { 2, 1, 858, 503,1130, 480, 0, 1, 0}, /* 07 (720x480) */
1773 { 5, 4,1815, 570,1130, 660, 50, 0, 0},
1774 { 5, 3,1100, 686,1130, 640, 50, 1, 0},
1775 { 10, 9,1320, 830,1130, 640, 50, 0, 0}
1776};
1777
1778XGI330_TVDataStruct XGI_StYPbPr750pData[]=
1779{
1780 { 1, 1,1650, 750,1280, 400, 50, 0, 760},
1781 { 1, 1,1650, 750,1280, 350, 50, 0, 640},
1782 { 1, 1,1650, 750,1280, 400, 0, 0, 720},
1783 { 1, 1,1650, 750,1280, 350, 0, 0, 720},
1784 { 1, 1,1650, 750,1280, 480, 0, 0, 760},
1785};
1786
1787UCHAR XGI330_NTSCTiming[] = {
1788 0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c,
1789 0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a,
1790 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b,
1791 0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17,
1792 0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02,
1793 0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40,
1794 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50,
1795 0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00};
1796
1797UCHAR XGI330_PALTiming[] = {
1798 0x21,0x5A,0x35,0x6e,0x04,0x38,0x3d,0x70,
1799 0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d,
1800 0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b,
1801 0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17,
1802 0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02,
1803 0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40,
1804 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63,
1805 0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00};
1806
1807UCHAR XGI330_HiTVExtTiming[] =
1808{
1809 0x2D,0x60,0x2C,0x5F,0x08,0x31,0x3A,0x64,
1810 0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D,
1811 0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F,
1812 0x64,0x90,0x33,0x8C,0x18,0x36,0x3E,0x13,
1813 0x2A,0xDE,0x2A,0x44,0x40,0x2A,0x44,0x40,
1814 0x8E,0x8E,0x82,0x07,0x0B,
1815 0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C,
1816 0x60,0x14,0x3D,0x63,0x4F,
1817 0x27,0x00,0xfc,0xff,0x6a,0x00
1818
1819};
1820
1821UCHAR XGI330_HiTVSt1Timing[] =
1822{
1823 0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x65,
1824 0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D,
1825 0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F,
1826 0x65,0x90,0x7B,0xA8,0x03,0xF0,0x87,0x03,
1827 0x11,0x15,0x11,0xCF,0x10,0x11,0xCF,0x10,
1828 0x35,0x35,0x3B,0x69,0x1D,
1829 0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C,
1830 0x60,0x04,0x86,0xAF,0x5D,
1831 0x0E,0x00,0xfc,0xff,0x2d,0x00
1832};
1833
1834UCHAR XGI330_HiTVSt2Timing[] =
1835{
1836 0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x64,
1837 0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D,
1838 0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F,
1839 0x64,0x90,0x33,0x8C,0x18,0x36,0x3E,0x13,
1840 0x2A,0xDE,0x2A,0x44,0x40,0x2A,0x44,0x40,
1841 0x8E,0x8E,0x82,0x07,0x0B,
1842 0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C,
1843 0x60,0x14,0x3D,0x63,0x4F,
1844 0x27,0x00,0xFC,0xff,0x6a,0x00
1845};
1846
1847UCHAR XGI330_HiTVTextTiming[] =
1848{
1849 0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x65,
1850 0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D,
1851 0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F,
1852 0x65,0x90,0xE7,0xBC,0x03,0x0C,0x97,0x03,
1853 0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20,
1854 0xC8,0xC8,0x3B,0xD2,0x26,
1855 0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C,
1856 0x60,0x04,0x96,0x72,0x5C,
1857 0x11,0x00,0xFC,0xFF,0x32,0x00
1858};
1859
1860UCHAR XGI330_YPbPr750pTiming[] =
1861{
1862 0x30,0x1d,0xe8,0x09,0x09,0xed,0x0c,0x0c,
1863 0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a,
1864 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
1865 0xed,0x50,0x70,0x9f,0x16,0x59,0x60,0x13,
1866 0x27,0x0b,0x27,0xfc,0x30,0x27,0x1c,0xb0,
1867 0x4b,0x4b,0x6f,0x2f,0x63,
1868 0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C,
1869 0x60,0x14,0x73,0x00,0x40,
1870 0x11,0x00,0xfc,0xff,0x32,0x00
1871};
1872
1873UCHAR XGI330_YPbPr525pTiming[] =
1874{
1875 0x3E,0x11,0x06,0x09,0x0b,0x0c,0x0c,0x0c,
1876 0x98,0x0a,0x01,0x0d,0x06,0x0d,0x04,0x0a,
1877 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
1878 0x0c,0x50,0xb2,0x9f,0x16,0x59,0x4f,0x13,
1879 0xad,0x11,0xad,0x1d,0x40,0x8a,0x3d,0xb8,
1880 0x51,0x5e,0x60,0x49,0x7d,
1881 0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C,
1882 0x60,0x14,0x4B,0x43,0x41,
1883 0x11,0x00,0xFC,0xFF,0x32,0x00
1884};
1885
1886UCHAR XGI330_YPbPr525iTiming[] =
1887{
1888 0x1B,0x21,0x03,0x09,0x05,0x06,0x0C,0x0C,
1889 0x94,0x49,0x01,0x0A,0x06,0x0D,0x04,0x0A,
1890 0x06,0x14,0x0D,0x04,0x0A,0x00,0x85,0x1B,
1891 0x0C,0x50,0x00,0x97,0x00,0xDA,0x4A,0x17,
1892 0x7D,0x05,0x4B,0x00,0x00,0xE2,0x00,0x02,
1893 0x03,0x0A,0x65,0x9D,0x08,
1894 0x92,0x8F,0x40,0x60,0x80,0x14,0x90,0x8C,
1895 0x60,0x14,0x4B,0x00,0x40,
1896 0x44,0x00,0xDB,0x02,0x3B,0x00
1897
1898};
1899
1900UCHAR XGI330_HiTVGroup3Data[] =
1901{
1902 0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0x5F,
1903 0x05,0x21,0xB2,0xB2,0x55,0x77,0x2A,0xA6,
1904 0x25,0x2F,0x47,0xFA,0xC8,0xFF,0x8E,0x20,
1905 0x8C,0x6E,0x60,0x2E,0x58,0x48,0x72,0x44,
1906 0x56,0x36,0x4F,0x6E,0x3F,0x80,0x00,0x80,
1907 0x4F,0x7F,0x03,0xA8,0x7D,0x20,0x1A,0xA9,
1908 0x14,0x05,0x03,0x7E,0x64,0x31,0x14,0x75,
1909 0x18,0x05,0x18,0x05,0x4C,0xA8,0x01
1910};
1911
1912UCHAR XGI330_HiTVGroup3Simu[] =
1913{
1914 0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0x95,
1915 0xDB,0x20,0xB8,0xB8,0x55,0x47,0x2A,0xA6,
1916 0x25,0x2F,0x47,0xFA,0xC8,0xFF,0x8E,0x20,
1917 0x8C,0x6E,0x60,0x15,0x26,0xD3,0xE4,0x11,
1918 0x56,0x36,0x4F,0x6E,0x3F,0x80,0x00,0x80,
1919 0x67,0x36,0x01,0x47,0x0E,0x10,0xBE,0xB4,
1920 0x01,0x05,0x03,0x7E,0x65,0x31,0x14,0x75,
1921 0x18,0x05,0x18,0x05,0x4C,0xA8,0x01
1922};
1923
1924UCHAR XGI330_HiTVGroup3Text[] =
1925{
1926 0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0xA7,
1927 0xF5,0x20,0xCE,0xCE,0x55,0x47,0x2A,0xA6,
1928 0x25,0x2F,0x47,0xFA,0xC8,0xFF,0x8E,0x20,
1929 0x8C,0x6E,0x60,0x18,0x2C,0x0C,0x20,0x22,
1930 0x56,0x36,0x4F,0x6E,0x3F,0x80,0x00,0x80,
1931 0x93,0x3C,0x01,0x50,0x2F,0x10,0xF4,0xCA,
1932 0x01,0x05,0x03,0x7E,0x65,0x31,0x14,0x75,
1933 0x18,0x05,0x18,0x05,0x4C,0xA8,0x01
1934};
1935
1936UCHAR XGI330_Ren525pGroup3[] =
1937{
1938 0x00,0x14,0x15,0x25,0x55,0x15,0x0b,0x13,
1939 0xB1,0x41,0x62,0x62,0xFF,0xF4,0x45,0xa6,
1940 0x25,0x2F,0x67,0xF6,0xbf,0xFF,0x8E,0x20,
1941 0xAC,0xDA,0x60,0xFe,0x6A,0x9A,0x06,0x10,
1942 0xd1,0x04,0x18,0x0a,0xFF,0x80,0x00,0x80,
1943 0x3c,0x77,0x00,0xEF,0xE0,0x10,0xB0,0xE0,
1944 0x10,0x4F,0x0F,0x0F,0x05,0x0F,0x08,0x6E,
1945 0x1a,0x1F,0x25,0x2a,0x4C,0xAA,0x01
1946};
1947
1948UCHAR XGI330_Ren750pGroup3[] =
1949{
1950 0x00,0x14,0x15,0x25,0x55,0x15,0x0b,0x7a,
1951 0x54,0x41,0xE7,0xE7,0xFF,0xF4,0x45,0xa6,
1952 0x25,0x2F,0x67,0xF6,0xbf,0xFF,0x8E,0x20,
1953 0xAC,0x6A,0x60,0x2b,0x52,0xCD,0x61,0x10,
1954 0x51,0x04,0x18,0x0a,0x1F,0x80,0x00,0x80,
1955 0xFF,0xA4,0x04,0x2B,0x94,0x21,0x72,0x94,
1956 0x26,0x05,0x01,0x0F,0xed,0x0F,0x0A,0x64,
1957 0x18,0x1D,0x23,0x28,0x4C,0xAA,0x01
1958};
1959
1960XGI_PanelDelayTblStruct XGI330_PanelDelayTbl[]=
1961{
1962{{0x00,0x00}},
1963{{0x00,0x00}},
1964{{0x00,0x00}},
1965{{0x00,0x00}},
1966{{0x00,0x00}},
1967{{0x00,0x00}},
1968{{0x00,0x00}},
1969{{0x00,0x00}},
1970{{0x00,0x00}},
1971{{0x00,0x00}},
1972{{0x00,0x00}},
1973{{0x00,0x00}},
1974{{0x00,0x00}},
1975{{0x00,0x00}},
1976{{0x00,0x00}},
1977{{0x00,0x00}}
1978};
1979
1980XGI330_LVDSDataStruct XGI330_LVDS320x480Data_1[]=
1981{
1982 {848, 433,400,525},
1983 {848, 389,400,525},
1984 {848, 433,400,525},
1985 {848, 389,400,525},
1986 {848, 518,400, 525},
1987 {1056, 628,400,525},
1988 {400, 525,400,525},
1989 {800, 449,1000, 644},
1990 {800, 525,1000, 635}
1991};
1992
1993XGI330_LVDSDataStruct XGI330_LVDS800x600Data_1[]=
1994{
1995 {848, 433,1060, 629},
1996 {848, 389,1060, 629},
1997 {848, 433,1060, 629},
1998 {848, 389,1060, 629},
1999 {848, 518,1060, 629},
2000 {1056, 628,1056, 628},
2001 {1056, 628,1056, 628},
2002 {800, 449,1000, 644},
2003 {800, 525,1000, 635}
2004};
2005
2006XGI330_LVDSDataStruct XGI330_LVDS800x600Data_2[]=
2007{
2008 {1056, 628,1056, 628},
2009 {1056, 628,1056, 628},
2010 {1056, 628,1056, 628},
2011 {1056, 628,1056, 628},
2012 {1056, 628,1056, 628},
2013 {1056, 628,1056, 628},
2014 {1056, 628,1056, 628},
2015 {800, 449,1000, 644},
2016 {800, 525,1000, 635}
2017};
2018
2019XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1[]=
2020{
2021 { 960 , 438 , 1344 , 806 } , /* 00 (320x200,320x400,640x200,640x400) */
2022 { 960 , 388 , 1344 , 806 } , /* 01 (320x350,640x350) */
2023 { 1040, 438 , 1344 , 806 } , /* 02 (360x400,720x400) */
2024 { 1040, 388 , 1344 , 806 } , /* 03 (720x350) */
2025 { 960 , 518 , 1344 , 806 } , /* 04 (320x240,640x480) */
2026 {1120 , 638 , 1344 , 806 } , /* 05 (400x300,800x600) */
2027 {1344 , 806 , 1344 , 806 } /* 06 (512x384,1024x768) */
2028};
2029
2030
2031XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2[]=
2032{
2033 {1344, 806,1344, 806},
2034 {1344, 806,1344, 806},
2035 {1344, 806,1344, 806},
2036 {1344, 806,1344, 806},
2037 {1344, 806,1344, 806},
2038 {1344, 806,1344, 806},
2039 {1344, 806,1344, 806},
2040 {800, 449,1280, 801},
2041 {800, 525,1280, 813}
2042};
2043
2044XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1[]=
2045{
2046 {1048, 442,1688, 1066},
2047 {1048, 392,1688, 1066},
2048 {1048, 442,1688, 1066},
2049 {1048, 392,1688, 1066},
2050 {1048, 522,1688, 1066},
2051 {1208, 642,1688, 1066},
2052 {1432, 810,1688, 1066},
2053 {1688, 1066,1688, 1066}
2054};
2055
2056XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2[]=
2057{
2058 {1344, 806,1344, 806},
2059 {1344, 806,1344, 806},
2060 {1344, 806,1344, 806},
2061 {1344, 806,1344, 806},
2062 {1344, 806,1344, 806},
2063 {1344, 806,1344, 806},
2064 {1344, 806,1344, 806},
2065 {800, 449,1280, 801},
2066 {800, 525,1280, 813}
2067};
2068/*
2069XGI330_LVDSDataStruct XGI_LVDS1280x768Data_1[]=
2070{
2071 {768,438,1408,806},
2072 {768,388,1408,806},
2073 {768,438,1408,806},
2074 {768,388,1408,806},
2075 {768,518,1408,806},
2076 {928,638,1408,806},
2077 {1408,806,1408,806},
2078 {1408,806,1408,806},
2079 {1408,806,1408,806}
2080};
2081
2082XGI330_LVDSDataStruct XGI_LVDS1280x768Data_2[]=
2083{
2084 {1408, 806,1408, 806},
2085 {1408, 806,1408, 806},
2086 {1408, 806,1408, 806},
2087 {1408, 806,1408, 806},
2088 {1408, 806,1408, 806},
2089 {1408, 806,1408, 806},
2090 {1408, 806,1408, 806},
2091 {1408, 806,1408, 806},
2092 {1408, 806,1408, 806}
2093};
2094
2095XGI330_LVDSDataStruct XGI_LVDS1280x768NData_1[]=
2096{
2097 {704, 438,1344, 806},
2098 {704, 388,1344, 806},
2099 {704, 438,1344, 806},
2100 {704, 388,1344, 806},
2101 {704, 518,1344, 806},
2102 {864, 638,1344, 806},
2103 {1088, 806,1344, 806},
2104 {1344, 806,1344, 806},
2105 {1344, 806,1344, 806}
2106};
2107
2108XGI330_LVDSDataStruct XGI_LVDS1280x768NData_2[]=
2109{
2110 {1344, 806,1344, 806},
2111 {1344, 806,1344, 806},
2112 {1344, 806,1344, 806},
2113 {1344, 806,1344, 806},
2114 {1344, 806,1344, 806},
2115 {1344, 806,1344, 806},
2116 {1344, 806,1344, 806},
2117 {1344, 806,1344, 806},
2118 {1344, 806,1344, 806}
2119};
2120
2121XGI330_LVDSDataStruct XGI_LVDS1280x768SData_1[]=
2122{
2123 {1048,438,1688,806},
2124 {1048,388,1688,806},
2125 {1148,438,1688,806},
2126 {1148,388,1688,806},
2127 {1048,518,1688,806},
2128 {1208,638,1688,806},
2129 {1432,806,1688,806},
2130 {1688,806,1688,806},
2131 {1688,806,1688,806}
2132};
2133
2134XGI330_LVDSDataStruct XGI_LVDS1280x768SData_2[]=
2135{
2136 {1688,806,1688,806},
2137 {1688,806,1688,806},
2138 {1688,806,1688,806},
2139 {1688,806,1688,806},
2140 {1688,806,1688,806},
2141 {1688,806,1688,806},
2142 {1688,806,1688,806},
2143 {1688,806,1688,806},
2144 {1688,806,1688,806}
2145};
2146*/
2147XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_1[]=
2148{
2149 {928,416,1688,1066},
2150 {928,366,1688,1066},
2151 {928,416,1688,1066},
2152 {928,366,1688,1066},
2153 {928,496,1688,1066},
2154 {1088,616,1688,1066},
2155 {1312,784,1688,1066},
2156 {1568,1040,1688,1066},
2157 {1688,1066,1688,1066}
2158};
2159
2160XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_2[]=
2161{
2162 {1688,1066,1688,1066},
2163 {1688,1066,1688,1066},
2164 {1688,1066,1688,1066},
2165 {1688,1066,1688,1066},
2166 {1688,1066,1688,1066},
2167 {1688,1066,1688,1066},
2168 {1688,1066,1688,1066},
2169 {1688,1066,1688,1066},
2170 {1688,1066,1688,1066}
2171};
2172
2173XGI330_LVDSDataStruct XGI_LVDS1600x1200Data_1[]=
2174{ /* ;;[ycchen] 12/05/02 LCDHTxLCDVT=2048x1320 */
2175 { 1088,520,2048,1320 },/* 00 (320x200,320x400,640x200,640x400) */
2176 { 1088,470,2048,1320 },/* 01 (320x350,640x350) */
2177 { 1088,520,2048,1320 },/* 02 (360x400,720x400) */
2178 { 1088,470,2048,1320 },/* 03 (720x350) */
2179 { 1088,600,2048,1320 },/* 04 (320x240,640x480) */
2180 { 1248,720,2048,1320 },/* 05 (400x300,800x600) */
2181 { 1472,888,2048,1320 },/* 06 (512x384,1024x768) */
2182 { 1728,1144,2048,1320 },/* 07 (640x512,1280x1024) */
2183 { 1848,1170,2048,1320 },/* 08 (1400x1050) */
2184 { 2048,1320,2048,1320 } /* 09 (1600x1200) */
2185};
2186
2187XGI330_LVDSDataStruct XGI_LVDSNoScalingData[]=
2188{
2189 { 800,449,800,449 }, /* 00 (320x200,320x400,640x200,640x400) */
2190 { 800,449,800,449 }, /* 01 (320x350,640x350) */
2191 { 800,449,800,449 }, /* 02 (360x400,720x400) */
2192 { 800,449,800,449 }, /* 03 (720x350) */
2193 { 800,525,800,525 }, /* 04 (640x480x60Hz) */
2194 { 1056,628,1056,628 }, /* 05 (800x600x60Hz) */
2195 { 1344,806,1344,806 }, /* 06 (1024x768x60Hz) */
2196 { 1688,1066,1688,1066 }, /* 07 (1280x1024x60Hz) */
2197 { 1688,1066,1688,1066 }, /* 08 (1400x1050x60Hz) ;;[ycchen] 12/19/02 */
2198 { 2160,1250,2160,1250 }, /* 09 (1600x1200x60Hz) */
2199 { 1688,806,1688,806 } /* 0A (1280x768x60Hz) */
2200};
2201
2202XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1x75[]=
2203{
2204 {960,438,1312,800 }, /* 00 (320x200,320x400,640x200,640x400) */
2205 {960,388,1312,800 }, /* 01 (320x350,640x350) */
2206 {1040,438,1312,800 }, /* 02 (360x400,720x400) */
2207 {1040,388,1312,800 }, /* 03 (720x350) */
2208 {928,512,1312,800 }, /* 04 (320x240,640x480) */
2209 {1088,632,1312,800 }, /* 05 (400x300,800x600) */
2210 {1312,800,1312,800 }, /* 06 (512x384,1024x768) */
2211};
2212
2213
2214XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2x75[]=
2215{
2216 {1312,800,1312,800}, /* ; 00 (320x200,320x400,640x200,640x400) */
2217 {1312,800,1312,800}, /* ; 01 (320x350,640x350) */
2218 {1312,800,1312,800}, /* ; 02 (360x400,720x400) */
2219 {1312,800,1312,800}, /* ; 03 (720x350) */
2220 {1312,800,1312,800}, /* ; 04 (320x240,640x480) */
2221 {1312,800,1312,800}, /* ; 05 (400x300,800x600) */
2222 {1312,800,1312,800}, /* ; 06 (512x384,1024x768) */
2223};
2224
2225XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1x75[]=
2226{
2227 {1048,442,1688,1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
2228 {1048,392,1688,1066 }, /* ; 01 (320x350,640x350) */
2229 {1128,442,1688,1066 }, /* ; 02 (360x400,720x400) */
2230 {1128,392,1688,1066 }, /* ; 03 (720x350) */
2231 {1048,522,1688,1066 }, /* ; 04 (320x240,640x480) */
2232 {1208,642,1688,1066 }, /* ; 05 (400x300,800x600) */
2233 {1432,810,1688,1066 }, /* ; 06 (512x384,1024x768) */
2234 {1688,1066,1688,1066 }, /* ; 06; 07 (640x512,1280x1024) */
2235};
2236
2237XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2x75[]=
2238{
2239 {1688,1066,1688,1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
2240 {1688,1066,1688,1066 }, /* ; 01 (320x350,640x350) */
2241 {1688,1066,1688,1066 }, /* ; 02 (360x400,720x400) */
2242 {1688,1066,1688,1066 }, /* ; 03 (720x350) */
2243 {1688,1066,1688,1066 }, /* ; 04 (320x240,640x480) */
2244 {1688,1066,1688,1066 }, /* ; 05 (400x300,800x600) */
2245 {1688,1066,1688,1066 }, /* ; 06 (512x384,1024x768) */
2246 {1688,1066,1688,1066 }, /* ; 06; 07 (640x512,1280x1024) */
2247};
2248
2249XGI330_LVDSDataStruct XGI_LVDSNoScalingDatax75[]=
2250{
2251 {800,449,800,449 }, /* ; 00 (320x200,320x400,640x200,640x400) */
2252 {800,449,800,449 }, /* ; 01 (320x350,640x350) */
2253 {900,449,900,449 }, /* ; 02 (360x400,720x400) */
2254 {900,449,900,449 }, /* ; 03 (720x350) */
2255 {800,500,800,500 }, /* ; 04 (640x480x75Hz) */
2256 {1056,625,1056,625 }, /* ; 05 (800x600x75Hz) */
2257 {1312,800,1312,800 }, /* ; 06 (1024x768x75Hz) */
2258 {1688,1066,1688,1066 }, /* ; 07 (1280x1024x75Hz) */
2259 {1688,1066,1688,1066 }, /* ; 08 (1400x1050x75Hz) ;;[ycchen] 12/19/02 */
2260 {2160,1250,2160,1250 }, /* ; 09 (1600x1200x75Hz) */
2261 {1688,806,1688,806 }, /* ; 0A (1280x768x75Hz) */
2262};
2263
2264XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1[]=
2265{
2266 { 0,1048, 0, 771 }, /* 00 (320x200,320x400,640x200,640x400) */
2267 { 0,1048, 0, 771 }, /* 01 (320x350,640x350) */
2268 { 0,1048, 0, 771 }, /* 02 (360x400,720x400) */
2269 { 0,1048, 0, 771 }, /* 03 (720x350) */
2270 { 0,1048, 0, 771 }, /* 04 (640x480x60Hz) */
2271 { 0,1048, 0, 771 }, /* 05 (800x600x60Hz) */
2272 { 0,1048, 805, 770 } /* 06 (1024x768x60Hz) */
2273} ;
2274
2275XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2[]=
2276{
2277 { 1142, 856, 622, 587 }, /* 00 (320x200,320x400,640x200,640x400) */
2278 { 1142, 856, 597, 562 }, /* 01 (320x350,640x350) */
2279 { 1142, 856, 622, 587 }, /* 02 (360x400,720x400) */
2280 { 1142, 856, 597, 562 }, /* 03 (720x350) */
2281 { 1142,1048, 722, 687 }, /* 04 (640x480x60Hz) */
2282 { 1232, 936, 722, 687 }, /* 05 (800x600x60Hz) */
2283 { 0,1048, 805, 771 } /* 06 (1024x768x60Hz) */
2284};
2285
2286XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3[]=
2287{
2288 { 320, 24, 622, 587 }, /* 00 (320x200,320x400,640x200,640x400) */
2289 { 320, 24, 597, 562 }, /* 01 (320x350,640x350) */
2290 { 320, 24, 622, 587 }, /* 02 (360x400,720x400) */
2291 { 320, 24, 597, 562 }, /* 03 (720x350) */
2292 { 320, 24, 722, 687 } /* 04 (640x480x60Hz) */
2293};
2294
2295XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1[]=
2296{
2297 { 0,1328, 0, 1025 }, /* 00 (320x200,320x400,640x200,640x400) */
2298 { 0,1328, 0, 1025 }, /* 01 (320x350,640x350) */
2299 { 0,1328, 0, 1025 }, /* 02 (360x400,720x400) */
2300 { 0,1328, 0, 1025 }, /* 03 (720x350) */
2301 { 0,1328, 0, 1025 }, /* 04 (640x480x60Hz) */
2302 { 0,1328, 0, 1025 }, /* 05 (800x600x60Hz) */
2303 { 0,1328, 0, 1025 }, /* 06 (1024x768x60Hz) */
2304 { 0,1328, 1065, 1024 } /* 07 (1280x1024x60Hz) */
2305};
2306
2307 /* The Display setting for DE Mode Panel */
2308XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2[]=
2309{
2310 { 1368,1008,752,711 }, /* 00 (320x200,320x400,640x200,640x400) */
2311 { 1368,1008,729,688 }, /* 01 (320x350,640x350) */
2312 { 1408,1048,752,711 }, /* 02 (360x400,720x400) */
2313 { 1408,1048,729,688 }, /* 03 (720x350) */
2314 { 1368,1008,794,753 }, /* 04 (640x480x60Hz) */
2315 { 1448,1068,854,813 }, /* 05 (800x600x60Hz) */
2316 { 1560,1200,938,897 }, /* 06 (1024x768x60Hz) */
2317 { 0000,1328,0,1025 } /* 07 (1280x1024x60Hz) */
2318};
2319
2320XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_1[]=
2321{
2322 { 0,1448,0,1051 }, /* 00 (320x200,320x400,640x200,640x400) */
2323 { 0,1448,0,1051 }, /* 01 (320x350,640x350) */
2324 { 0,1448,0,1051 }, /* 02 (360x400,720x400) */
2325 { 0,1448,0,1051 }, /* 03 (720x350) */
2326 { 0,1448,0,1051 }, /* 04 (640x480x60Hz) */
2327 { 0,1448,0,1051 }, /* 05 (800x600x60Hz) */
2328 { 0,1448,0,1051 }, /* 06 (1024x768x60Hz) */
2329 { 0,1448,0,1051 }, /* 07 (1280x1024x60Hz) */
2330 { 0,1448,0,1051 } /* 08 (1400x1050x60Hz) */
2331};
2332
2333XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_2[]=
2334{
2335 { 1308,1068, 781, 766 }, /* 00 (320x200,320x400,640x200,640x400) */
2336 { 1308,1068, 781, 766 }, /* 01 (320x350,640x350) */
2337 { 1308,1068, 781, 766 }, /* 02 (360x400,720x400) */
2338 { 1308,1068, 781, 766 }, /* 03 (720x350) */
2339 { 1308,1068, 781, 766 }, /* 04 (640x480x60Hz) */
2340 { 1388,1148, 841, 826 }, /* 05 (800x600x60Hz) */
2341 { 1490,1250, 925, 910 }, /* 06 (1024x768x60Hz) */
2342 { 1608,1368,1053,1038 }, /* 07 (1280x1024x60Hz) */
2343 { 0,1448,0,1051 } /* 08 (1400x1050x60Hz) */
2344};
2345
2346XGI330_LVDSDataStruct XGI_LVDS1600x1200Des_1[]=
2347{
2348 { 0,1664,0,1201 }, /* 00 (320x200,320x400,640x200,640x400) */
2349 { 0,1664,0,1201 }, /* 01 (320x350,640x350) */
2350 { 0,1664,0,1201 }, /* 02 (360x400,720x400) */
2351 { 0,1664,0,1201 }, /* 03 (720x350) */
2352 { 0,1664,0,1201 }, /* 04 (640x480x60Hz) */
2353 { 0,1664,0,1201 }, /* 05 (800x600x60Hz) */
2354 { 0,1664,0,1201 }, /* 06 (1024x768x60Hz) */
2355 { 0,1664,0,1201 }, /* 07 (1280x1024x60Hz) */
2356 { 0,1664,0,1201 }, /* 08 (1400x1050x60Hz) */
2357 { 0,1664,0,1201 } /* 09 (1600x1200x60Hz) */
2358};
2359
2360
2361
2362XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesData[]=
2363{
2364 { 0, 648, 448, 405, 96, 2 }, /* 00 (320x200,320x400,640x200,640x400) */
2365 { 0, 648, 448, 355, 96, 2 }, /* 01 (320x350,640x350) */
2366 { 0, 648, 448, 405, 96, 2 }, /* 02 (360x400,720x400) */
2367 { 0, 648, 448, 355, 96, 2 }, /* 03 (720x350) */
2368 { 0, 648, 1, 483, 96, 2 }, /* 04 (640x480x60Hz) */
2369 { 0, 840, 627, 600, 128, 4 }, /* 05 (800x600x60Hz) */
2370 { 0,1048, 805, 770, 136, 6 }, /* 06 (1024x768x60Hz) */
2371 { 0,1328,0,1025, 112, 3 }, /* 07 (1280x1024x60Hz) */
2372 { 0,1438,0,1051, 112, 3 }, /* 08 (1400x1050x60Hz) ;;[ycchen] 12/19/02 */
2373 { 0,1664,0,1201, 192, 3 }, /* 09 (1600x1200x60Hz) */
2374 { 0,1328,0,0771, 112, 6 } /* 0A (1280x768x60Hz) */
2375};
2376
2377XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1x75[]= /* ; 1024x768 Full-screen */
2378{
2379 {0,1040,0,769}, /* ; 00 (320x200,320x400,640x200,640x400) */
2380 {0,1040,0,769}, /* ; 01 (320x350,640x350) */
2381 {0,1040,0,769}, /* ; 02 (360x400,720x400) */
2382 {0,1040,0,769}, /* ; 03 (720x350) */
2383 {0,1040,0,769}, /* ; 04 (640x480x75Hz) */
2384 {0,1040,0,769}, /* ; 05 (800x600x75Hz) */
2385 {0,1040,0,769} /* ; 06 (1024x768x75Hz) */
2386};
2387
2388XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2x75[]= /* ; 1024x768 center-screen (Enh. Mode) */
2389{
2390 {1142, 856,622,587 }, /* 00 (320x200,320x400,640x200,640x400) */
2391 {1142, 856,597,562 }, /* 01 (320x350,640x350) */
2392 {1142, 856,622,587 }, /* 02 (360x400,720x400) */
2393 {1142, 856,597,562 }, /* 03 (720x350) */
2394 {1142,1048,722,687 }, /* 04 (640x480x60Hz) */
2395 {1232, 936,722,687 }, /* 05 (800x600x60Hz) */
2396 { 0,1048,805,771 } /* 06 (1024x768x60Hz) */
2397};
2398
2399XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3x75[]= /* ; 1024x768 center-screen (St.Mode) */
2400{
2401 {320,24,622,587 }, /* ; 00 (320x200,320x400,640x200,640x400) */
2402 {320,24,597,562 }, /* ; 01 (320x350,640x350) */
2403 {320,24,622,587 }, /* ; 02 (360x400,720x400) */
2404 {320,24,597,562 }, /* ; 03 (720x350) */
2405 {320,24,722,687 } /* ; 04 (640x480x60Hz) */
2406};
2407
2408XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1x75[]=
2409{
2410 {0,1296,0,1025}, /* ; 00 (320x200,320x400,640x200,640x400) */
2411 {0,1296,0,1025}, /* ; 01 (320x350,640x350) */
2412 {0,1296,0,1025}, /* ; 02 (360x400,720x400) */
2413 {0,1296,0,1025}, /* ; 03 (720x350) */
2414 {0,1296,0,1025}, /* ; 04 (640x480x75Hz) */
2415 {0,1296,0,1025}, /* ; 05 (800x600x75Hz) */
2416 {0,1296,0,1025}, /* ; 06 (1024x768x75Hz) */
2417 {0,1296,0,1025} /* ; 07 (1280x1024x75Hz) */
2418};
2419
2420/* The Display setting for DE Mode Panel */
2421XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2x75[]= /* [ycchen] 02/18/03 Set DE as default */
2422{
2423 {1368,976,752,711 }, /* ; 00 (320x200,320x400,640x200,640x400) */
2424 {1368,976,729,688 }, /* ; 01 (320x350,640x350) */
2425 {1408,976,752,711 }, /* ; 02 (360x400,720x400) */
2426 {1408,976,729,688 }, /* ; 03 (720x350) */
2427 {1368,976,794,753 }, /* ; 04 (640x480x75Hz) */
2428 {1448,1036,854,813}, /* ; 05 (800x600x75Hz) */
2429 {1560,1168,938,897}, /* ; 06 (1024x768x75Hz) */
2430 {0,1296,0,1025 } /* ; 07 (1280x1024x75Hz) */
2431};
2432
2433XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesDatax75[]= /* Scaling LCD 75Hz */
2434{
2435 { 0,648,448,405,96,2 }, /* ; 00 (320x200,320x400,640x200,640x400) */
2436 { 0,648,448,355,96,2 }, /* ; 01 (320x350,640x350) */
2437 { 0,729,448,405,108,2 }, /* ; 02 (360x400,720x400) */
2438 { 0,729,448,355,108,2 }, /* ; 03 (720x350) */
2439 { 0,656,0,481,64,3 }, /* ; 04 (640x480x75Hz) */
2440 { 0,816,0,601,80,3 }, /* ; 05 (800x600x75Hz) */
2441 { 0,1040,0,769,96,3 }, /* ; 06 (1024x768x75Hz) */
2442 { 0,1296,0,1025,144,3 }, /* ; 07 (1280x1024x75Hz) */
2443 { 0,1448,0,1051,112,3 }, /* ; 08 (1400x1050x75Hz) ;;[ycchen] 12/19/02 */
2444 { 0,1664,0,1201,192,3 }, /* ; 09 (1600x1200x75Hz) */
2445 { 0,1328,0,771,112,6 } /* ; 0A (1280x768x75Hz) */
2446};
2447
2448XGI330_LVDSDataStruct XGI330_LVDS640x480Data_1[]=
2449{
2450 {800, 449, 800, 449},
2451 {800, 449, 800, 449},
2452 {800, 449, 800, 449},
2453 {800, 449, 800, 449},
2454 {800, 525, 800, 525},
2455 {1056, 628,1056, 628},
2456 {1056, 628,1056, 628},
2457 {1056, 628,1056, 628},
2458 {1056, 628,1056, 628}
2459};
2460
2461XGI330_CHTVDataStruct XGI_CHTVUNTSCData[]=
2462{
2463 {840, 600, 840, 600},
2464 {840, 600, 840, 600},
2465 {840, 600, 840, 600},
2466 {840, 600, 840, 600},
2467 {784, 600, 784, 600},
2468 {1064, 750,1064, 750}
2469};
2470
2471XGI330_CHTVDataStruct XGI_CHTVONTSCData[]=
2472{
2473 {840, 525, 840, 525},
2474 {840, 525, 840, 525},
2475 {840, 525, 840, 525},
2476 {840, 525, 840, 525},
2477 {784, 525, 784, 525},
2478 {1040, 700,1040, 700}
2479};
2480
2481XGI330_CHTVDataStruct XGI_CHTVUPALData[]=
2482{
2483 {1008, 625,1008, 625},
2484 {1008, 625,1008, 625},
2485 {1008, 625,1008, 625},
2486 {1008, 625,1008, 625},
2487 {840, 750, 840, 750},
2488 {936, 836, 936, 836}
2489};
2490
2491XGI330_CHTVDataStruct XGI_CHTVOPALData[]=
2492{
2493 {1008, 625,1008, 625},
2494 {1008, 625,1008, 625},
2495 {1008, 625,1008, 625},
2496 {1008, 625,1008, 625},
2497 {840, 625, 840, 625},
2498 {960, 750, 960, 750}
2499};
2500
2501XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_1_H[]=
2502{
2503 /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
2504 {{ 0x4B,0x27,0x8F,0x32,0x1B,0x00,0x45,0x00 }}, /* 00 (320x) */
2505 {{ 0x4B,0x27,0x8F,0x2B,0x03,0x00,0x44,0x00 }}, /* 01 (360x) */
2506 {{ 0x55,0x31,0x99,0x46,0x1D,0x00,0x55,0x00 }}, /* 02 (400x) */
2507 {{ 0x63,0x3F,0x87,0x4A,0x93,0x00,0x01,0x00 }}, /* 03 (512x) */
2508 {{ 0x73,0x4F,0x97,0x55,0x86,0x00,0x05,0x00 }}, /* 04 (640x) */
2509 {{ 0x73,0x4F,0x97,0x55,0x86,0x00,0x05,0x00 }}, /* 05 (720x) */
2510 {{ 0x87,0x63,0x8B,0x69,0x1A,0x00,0x26,0x00 }}, /* 06 (800x) */
2511 {{ 0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00 }} /* 07 (1024x) */
2512};
2513
2514XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_1_H[]=
2515{
2516 /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
2517 {{ 0x56,0x27,0x9A,0x30,0x1E,0x00,0x05,0x00 }}, /* 00 (320x) */
2518 {{ 0x56,0x27,0x9A,0x30,0x1E,0x00,0x05,0x00 }}, /* 01 (360x) */
2519 {{ 0x60,0x31,0x84,0x3A,0x88,0x00,0x01,0x00 }}, /* 02 (400x) */
2520 {{ 0x6E,0x3F,0x92,0x48,0x96,0x00,0x01,0x00 }}, /* 03 (512x) */
2521 {{ 0x7E,0x4F,0x82,0x58,0x06,0x00,0x06,0x00 }}, /* 04 (640x) */
2522 {{ 0x7E,0x4F,0x82,0x58,0x06,0x00,0x06,0x00 }}, /* 05 (720x) */
2523 {{ 0x92,0x63,0x96,0x6C,0x1A,0x00,0x06,0x00 }}, /* 06 (800x) */
2524 {{ 0xAE,0x7F,0x92,0x88,0x96,0x00,0x02,0x00 }}, /* 07 (1024x) */
2525 {{ 0xCE,0x9F,0x92,0xA8,0x16,0x00,0x07,0x00 }} /* 08 (1280x) */
2526};
2527
2528XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_2_H[]=
2529{
2530 /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
2531 {{ 0x63,0x27,0x87,0x3B,0x8C,0x00,0x01,0x00 }}, /* 00 (320x) */
2532 {{ 0x63,0x27,0x87,0x3B,0x8C,0x00,0x01,0x00 }}, /* 01 (360x) */
2533 {{ 0x63,0x31,0x87,0x3D,0x8E,0x00,0x01,0x00 }}, /* 02 (400x) */
2534 {{ 0x63,0x3F,0x87,0x45,0x96,0x00,0x01,0x00 }}, /* 03 (512x) */
2535 {{ 0xA3,0x4F,0x87,0x6E,0x9F,0x00,0x06,0x00 }}, /* 04 (640x) */
2536 {{ 0xA3,0x4F,0x87,0x6E,0x9F,0x00,0x06,0x00 }}, /* 05 (720x) */
2537 {{ 0xA3,0x63,0x87,0x78,0x89,0x00,0x02,0x00 }}, /* 06 (800x) */
2538 {{ 0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00 }} /* 07 (1024x) */
2539};
2540
2541XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_2_H[]=
2542{
2543 /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
2544 {{ 0x7E,0x3B,0x9A,0x44,0x12,0x00,0x01,0x00 }}, /* 00 (320x) */
2545 {{ 0x7E,0x3B,0x9A,0x44,0x12,0x00,0x01,0x00 }}, /* 01 (360x) */
2546 {{ 0x7E,0x40,0x84,0x49,0x91,0x00,0x01,0x00 }}, /* 02 (400x) */
2547 {{ 0x7E,0x47,0x93,0x50,0x9E,0x00,0x01,0x00 }}, /* 03 (512x) */
2548 {{ 0xCE,0x77,0x8A,0x80,0x8E,0x00,0x02,0x00 }}, /* 04 (640x) */
2549 {{ 0xCE,0x77,0x8A,0x80,0x8E,0x00,0x02,0x00 }}, /* 05 (720x) */
2550 {{ 0xCE,0x81,0x94,0x8A,0x98,0x00,0x02,0x00 }}, /* 06 (800x) */
2551 {{ 0xCE,0x8F,0x82,0x98,0x06,0x00,0x07,0x00 }}, /* 07 (1024x) */
2552 {{ 0xCE,0x9F,0x92,0xA8,0x16,0x00,0x07,0x00 }} /* 08 (1280x) */
2553};
2554
2555XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11400x1050_1_H[]=
2556{ /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
2557 {{ 0x47,0x27,0x8B,0x2C,0x1A,0x00,0x05,0x00 }}, /* 00 (320x) */
2558 {{ 0x47,0x27,0x8B,0x30,0x1E,0x00,0x05,0x00 }}, /* 01 (360x) */
2559 {{ 0x51,0x31,0x95,0x36,0x04,0x00,0x01,0x00 }}, /* 02 (400x) */
2560 {{ 0x5F,0x3F,0x83,0x44,0x92,0x00,0x01,0x00 }}, /* 03 (512x) */
2561 {{ 0x6F,0x4F,0x93,0x54,0x82,0x00,0x05,0x00 }}, /* 04 (640x) */
2562 {{ 0x6F,0x4F,0x93,0x54,0x82,0x00,0x05,0x00 }}, /* 05 (720x) */
2563 {{ 0x83,0x63,0x87,0x68,0x16,0x00,0x06,0x00 }}, /* 06 (800x) */
2564 {{ 0x9F,0x7F,0x83,0x84,0x92,0x00,0x02,0x00 }}, /* 07 (1024x) */
2565 {{ 0xBF,0x9F,0x83,0xA4,0x12,0x00,0x07,0x00 }}, /* 08 (1280x) */
2566 {{ 0xCE,0xAE,0x92,0xB3,0x01,0x00,0x03,0x00 }} /* 09 (1400x) */
2567};
2568
2569XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11400x1050_2_H[]=
2570{ /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
2571 {{ 0x76,0x3F,0x83,0x45,0x8C,0x00,0x41,0x00 }}, /* 00 (320x) */
2572 {{ 0x76,0x3F,0x83,0x45,0x8C,0x00,0x41,0x00 }}, /* 01 (360x) */
2573 {{ 0x76,0x31,0x9A,0x48,0x9F,0x00,0x41,0x00 }}, /* 02 (400x) */
2574 {{ 0x76,0x3F,0x9A,0x4F,0x96,0x00,0x41,0x00 }}, /* 03 (512x) */
2575 {{ 0xCE,0x7E,0x82,0x87,0x9E,0x00,0x02,0x00 }}, /* 04 (640x) */
2576 {{ 0xCE,0x7E,0x82,0x87,0x9E,0x00,0x02,0x00 }}, /* 05 (720x) */
2577 {{ 0xCE,0x63,0x92,0x96,0x04,0x00,0x07,0x00 }}, /* 06 (800x) */
2578 {{ 0xCE,0x7F,0x92,0xA4,0x12,0x00,0x07,0x00 }}, /* 07 (1024x) */
2579 {{ 0xCE,0x9F,0x92,0xB4,0x02,0x00,0x03,0x00 }}, /* 08 (1280x) */
2580 {{ 0xCE,0xAE,0x92,0xBC,0x0A,0x00,0x03,0x00 }} /* 09 (1400x) */
2581};
2582
2583XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11600x1200_1_H[]=
2584/* ;302lv channelA [ycchen] 12/05/02 LCDHT=2048 */
2585{ /* ; CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
2586 {{ 0x5B,0x27,0x9F,0x32,0x0A,0x00,0x01,0x00 }},/* 00 (320x) */
2587 {{ 0x5B,0x27,0x9F,0x32,0x0A,0x00,0x01,0x00 }},/* 01 (360x) */
2588 {{ 0x65,0x31,0x89,0x3C,0x94,0x00,0x01,0x00 }},/* 02 (400x) */
2589 {{ 0x73,0x3F,0x97,0x4A,0x82,0x00,0x05,0x00 }},/* 03 (512x) */
2590 {{ 0x83,0x4F,0x87,0x51,0x09,0x00,0x06,0x00 }},/* 04 (640x) */
2591 {{ 0x83,0x4F,0x87,0x51,0x09,0x00,0x06,0x00 }},/* 05 (720x) */
2592 {{ 0x97,0x63,0x9B,0x65,0x1D,0x00,0x06,0xF0 }},/* 06 (800x) */
2593 {{ 0xB3,0x7F,0x97,0x81,0x99,0x00,0x02,0x00 }},/* 07 (1024x) */
2594 {{ 0xD3,0x9F,0x97,0xA1,0x19,0x00,0x07,0x00 }},/* 08 (1280x) */
2595 {{ 0xE2,0xAE,0x86,0xB9,0x91,0x00,0x03,0x00 }},/* 09 (1400x) */
2596 {{ 0xFB,0xC7,0x9F,0xC9,0x81,0x00,0x07,0x00 }} /* 0A (1600x) */
2597};
2598
2599XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_1_V[]=
2600{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A+CR09(5->7) */
2601 {{ 0x97,0x1F,0x60,0x87,0x5D,0x83,0x10 }}, /* 00 (x350) */
2602 {{ 0xB4,0x1F,0x92,0x89,0x8F,0xB5,0x30 }}, /* 01 (x400) */
2603 {{ 0x04,0x3E,0xE2,0x89,0xDF,0x05,0x00 }}, /* 02 (x480) */
2604 {{ 0x7C,0xF0,0x5A,0x8F,0x57,0x7D,0xA0 }}, /* 03 (x600) */
2605 {{ 0x24,0xF5,0x02,0x88,0xFF,0x25,0x90 }} /* 04 (x768) */
2606};
2607
2608XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_2_V[]=
2609{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
2610 {{ 0x24,0xBB,0x31,0x87,0x5D,0x25,0x30 }}, /* 00 (x350) */
2611 {{ 0x24,0xBB,0x4A,0x80,0x8F,0x25,0x30 }}, /* 01 (x400) */
2612 {{ 0x24,0xBB,0x72,0x88,0xDF,0x25,0x30 }}, /* 02 (x480) */
2613 {{ 0x24,0xF1,0xAE,0x84,0x57,0x25,0xB0 }}, /* 03 (x600) */
2614 {{ 0x24,0xF5,0x02,0x88,0xFF,0x25,0x90 }} /* 04 (x768) */
2615};
2616
2617XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_1_V[]=
2618{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
2619 {{ 0x86,0x1F,0x5E,0x82,0x5D,0x87,0x00 }}, /* 00 (x350) */
2620 {{ 0xB8,0x1F,0x90,0x84,0x8F,0xB9,0x30 }}, /* 01 (x400) */
2621 {{ 0x08,0x3E,0xE0,0x84,0xDF,0x09,0x00 }}, /* 02 (x480) */
2622 {{ 0x80,0xF0,0x58,0x8C,0x57,0x81,0xA0 }}, /* 03 (x600) */
2623 {{ 0x28,0xF5,0x00,0x84,0xFF,0x29,0x90 }}, /* 04 (x768) */
2624 {{ 0x28,0x5A,0x13,0x87,0xFF,0x29,0xA9 }} /* 05 (x1024) */
2625};
2626
2627XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_V[]=
2628{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
2629 {{ 0x28,0xD2,0xAF,0x83,0xAE,0xD8,0xA1 }}, /* 00 (x350) */
2630 {{ 0x28,0xD2,0xC8,0x8C,0xC7,0xF2,0x81 }}, /* 01 (x400) */
2631 {{ 0x28,0xD2,0xF0,0x84,0xEF,0x1A,0xB1 }}, /* 02 (x480) */
2632 {{ 0x28,0xDE,0x2C,0x8F,0x2B,0x56,0x91 }}, /* 03 (x600) */
2633 {{ 0x28,0xDE,0x80,0x83,0x7F,0xAA,0x91 }}, /* 04 (x768) */
2634 {{ 0x28,0x5A,0x13,0x87,0xFF,0x29,0xA9 }} /* 05 (x1024) */
2635};
2636
2637XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11400x1050_1_V[]=
2638{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
2639 {{ 0x6C,0x1F,0x60,0x84,0x5D,0x6D,0x10 }}, /* 00 (x350) */
2640 {{ 0x9E,0x1F,0x93,0x86,0x8F,0x9F,0x30 }}, /* 01 (x400) */
2641 {{ 0xEE,0x1F,0xE2,0x86,0xDF,0xEF,0x10 }}, /* 02 (x480) */
2642 {{ 0x66,0xF0,0x5A,0x8e,0x57,0x67,0xA0 }}, /* 03 (x600) */
2643 {{ 0x0E,0xF5,0x02,0x86,0xFF,0x0F,0x90 }}, /* 04 (x768) */
2644 {{ 0x0E,0x5A,0x02,0x86,0xFF,0x0F,0x89 }}, /* 05 (x1024) */
2645 {{ 0x28,0x10,0x1A,0x80,0x19,0x29,0x0F }} /* 06 (x1050) */
2646};
2647
2648XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11400x1050_2_V[]=
2649{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
2650 {{ 0x28,0x92,0xB6,0x83,0xB5,0xCF,0x81 }}, /* 00 (x350) */
2651 {{ 0x28,0x92,0xD5,0x82,0xD4,0xEE,0x81 }}, /* 01 (x400) */
2652 {{ 0x28,0x92,0xFD,0x8A,0xFC,0x16,0xB1 }}, /* 02 (x480) */
2653 {{ 0x28,0xD4,0x39,0x86,0x57,0x29,0x81 }}, /* 03 (x600) */
2654 {{ 0x28,0xD4,0x8D,0x9A,0xFF,0x29,0xA1 }}, /* 04 (x768) */
2655 {{ 0x28,0x5A,0x0D,0x9A,0xFF,0x29,0xA9 }}, /* 05 (x1024) */
2656 {{ 0x28,0x10,0x1A,0x87,0x19,0x29,0x8F }} /* 06 (x1050) */
2657};
2658
2659XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11600x1200_1_V[]=
2660{
2661 /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A+CR09(5->7) */
2662 {{ 0xd4,0x1F,0x81,0x84,0x5D,0xd5,0x10 }}, /* 00 (x350) */
2663 {{ 0x06,0x3e,0xb3,0x86,0x8F,0x07,0x20 }}, /* 01 (x400) */
2664 {{ 0x56,0xba,0x03,0x86,0xDF,0x57,0x00 }}, /* 02 (x480) */
2665 {{ 0xce,0xF0,0x7b,0x8e,0x57,0xcf,0xa0 }}, /* 03 (x600) */
2666 {{ 0x76,0xF5,0x23,0x86,0xFF,0x77,0x90 }}, /* 04 (x768) */
2667 {{ 0x76,0x5A,0x23,0x86,0xFF,0x77,0x89 }}, /* 05 (x1024) */
2668 {{ 0x90,0x10,0x1A,0x8E,0x19,0x91,0x2F }}, /* 06 (x1050) */
2669 {{ 0x26,0x11,0xd3,0x86,0xaF,0x27,0x3f }} /* 07 (x1200) */
2670};
2671
2672XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_1_Hx75[]=
2673{ /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
2674 {{ 0x4B,0x27,0x8F,0x32,0x1B,0x00,0x45,0x00 }},/* ; 00 (320x) */
2675 {{ 0x4B,0x27,0x8F,0x2B,0x03,0x00,0x44,0x00 }},/* ; 01 (360x) */
2676 {{ 0x55,0x31,0x99,0x46,0x1D,0x00,0x55,0x00 }},/* ; 02 (400x) */
2677 {{ 0x63,0x3F,0x87,0x4A,0x93,0x00,0x01,0x00 }},/* ; 03 (512x) */
2678 {{ 0x6F,0x4F,0x93,0x54,0x80,0x00,0x05,0x00 }},/* ; 04 (640x) */
2679 {{ 0x6F,0x4F,0x93,0x54,0x80,0x00,0x05,0x00 }},/* ; 05 (720x) */
2680 {{ 0x83,0x63,0x87,0x68,0x14,0x00,0x26,0x00 }},/* ; 06 (800x) */
2681 {{ 0x9F,0x7F,0x83,0x85,0x91,0x00,0x02,0x00 }} /* ; 07 (1024x) */
2682};
2683
2684XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_1_Vx75[]=
2685{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A+CR09(5->7) */
2686 {{ 0x97,0x1F,0x60,0x87,0x5D,0x83,0x10 }},/* ; 00 (x350) */
2687 {{ 0xB4,0x1F,0x92,0x89,0x8F,0xB5,0x30 }},/* ; 01 (x400) */
2688 {{ 0xFE,0x1F,0xE0,0x84,0xDF,0xFF,0x10 }},/* ; 02 (x480) */
2689 {{ 0x76,0xF0,0x58,0x8C,0x57,0x77,0xA0 }},/* ; 03 (x600) */
2690 {{ 0x1E,0xF5,0x00,0x83,0xFF,0x1F,0x90 }} /* ; 04 (x768) */
2691};
2692
2693XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_2_Hx75[]=
2694{ /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
2695 {{ 0x63,0x27,0x87,0x3B,0x8C,0x00,0x01,0x00 }},/* ; 00 (320x) */
2696 {{ 0x63,0x27,0x87,0x3B,0x8C,0x00,0x01,0x00 }},/* ; 01 (360x) */
2697 {{ 0x63,0x31,0x87,0x3D,0x8E,0x00,0x01,0x00 }},/* ; 02 (400x) */
2698 {{ 0x63,0x3F,0x87,0x45,0x96,0x00,0x01,0x00 }},/* ; 03 (512x) */
2699 {{ 0xA3,0x4F,0x87,0x6E,0x9F,0x00,0x06,0x00 }},/* ; 04 (640x) */
2700 {{ 0xA3,0x4F,0x87,0x6E,0x9F,0x00,0x06,0x00 }},/* ; 05 (720x) */
2701 {{ 0xA3,0x63,0x87,0x78,0x89,0x00,0x02,0x00 }},/* ; 06 (800x) */
2702 {{ 0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00 }} /* ; 07 (1024x) */
2703};
2704
2705XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_2_Vx75[]=
2706{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
2707 {{ 0x24,0xBB,0x31,0x87,0x5D,0x25,0x30 }},/* ; 00 (x350) */
2708 {{ 0x24,0xBB,0x4A,0x80,0x8F,0x25,0x30 }},/* ; 01 (x400) */
2709 {{ 0x24,0xBB,0x72,0x88,0xDF,0x25,0x30 }},/* ; 02 (x480) */
2710 {{ 0x24,0xF1,0xAE,0x84,0x57,0x25,0xB0 }},/* ; 03 (x600) */
2711 {{ 0x24,0xF5,0x02,0x88,0xFF,0x25,0x90 }} /* ; 04 (x768) */
2712};
2713
2714XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_1_Hx75[]=
2715{ /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
2716 {{ 0x56,0x27,0x9A,0x30,0x1E,0x00,0x05,0x00 }},/* ; 00 (320x) */
2717 {{ 0x56,0x27,0x9A,0x30,0x1E,0x00,0x05,0x00 }},/* ; 01 (360x) */
2718 {{ 0x60,0x31,0x84,0x3A,0x88,0x00,0x01,0x00 }},/* ; 02 (400x) */
2719 {{ 0x6E,0x3F,0x92,0x48,0x96,0x00,0x01,0x00 }},/* ; 03 (512x) */
2720 {{ 0x7E,0x4F,0x82,0x54,0x06,0x00,0x06,0x00 }},/* ; 04 (640x) */
2721 {{ 0x7E,0x4F,0x82,0x54,0x06,0x00,0x06,0x00 }},/* ; 05 (720x) */
2722 {{ 0x92,0x63,0x96,0x68,0x1A,0x00,0x06,0x00 }},/* ; 06 (800x) */
2723 {{ 0xAE,0x7F,0x92,0x84,0x96,0x00,0x02,0x00 }},/* ; 07 (1024x) */
2724 {{ 0xCE,0x9F,0x92,0xA5,0x17,0x00,0x07,0x00 }} /* ; 08 (1280x) */
2725};
2726
2727XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_1_Vx75[]=
2728{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
2729 {{ 0x86,0xD1,0xBC,0x80,0xBB,0xE5,0x00 }},/* ; 00 (x350) */
2730 {{ 0xB8,0x1F,0x90,0x84,0x8F,0xB9,0x30 }},/* ; 01 (x400) */
2731 {{ 0x08,0x3E,0xE0,0x84,0xDF,0x09,0x00 }},/* ; 02 (x480) */
2732 {{ 0x80,0xF0,0x58,0x8C,0x57,0x81,0xA0 }},/* ; 03 (x600) */
2733 {{ 0x28,0xF5,0x00,0x84,0xFF,0x29,0x90 }},/* ; 04 (x768) */
2734 {{ 0x28,0x5A,0x13,0x87,0xFF,0x29,0xA9 }} /* ; 05 (x1024) */
2735};
2736
2737XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_2_Hx75[]=
2738{
2739 /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
2740 {{ 0x7E,0x3B,0x9A,0x44,0x12,0x00,0x01,0x00 }},/* ; 00 (320x) */
2741 {{ 0x7E,0x3B,0x9A,0x44,0x12,0x00,0x01,0x00 }},/* ; 01 (360x) */
2742 {{ 0x7E,0x40,0x84,0x49,0x91,0x00,0x01,0x00 }},/* ; 02 (400x) */
2743 {{ 0x7E,0x47,0x93,0x50,0x9E,0x00,0x01,0x00 }},/* ; 03 (512x) */
2744 {{ 0xCE,0x77,0x8A,0x80,0x8E,0x00,0x02,0x00 }},/* ; 04 (640x) */
2745 {{ 0xCE,0x77,0x8A,0x80,0x8E,0x00,0x02,0x00 }},/* ; 05 (720x) */
2746 {{ 0xCE,0x81,0x94,0x8A,0x98,0x00,0x02,0x00 }},/* ; 06 (800x) */
2747 {{ 0xCE,0x8F,0x82,0x98,0x06,0x00,0x07,0x00 }},/* ; 07 (1024x) */
2748 {{ 0xCE,0x9F,0x92,0xA8,0x16,0x00,0x07,0x00 }} /* ; 08 (1280x) */
2749};
2750
2751XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_Vx75[]=
2752{
2753 /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
2754 {{ 0x28,0xD2,0xAF,0x83,0xAE,0xD8,0xA1 }},/* ; 00 (x350) */
2755 {{ 0x28,0xD2,0xC8,0x8C,0xC7,0xF2,0x81 }},/* ; 01 (x400) */
2756 {{ 0x28,0xD2,0xF0,0x84,0xEF,0x1A,0xB1 }},/* ; 02 (x480) */
2757 {{ 0x28,0xDE,0x2C,0x8F,0x2B,0x56,0x91 }},/* ; 03 (x600) */
2758 {{ 0x28,0xDE,0x80,0x83,0x7F,0xAA,0x91 }},/* ; 04 (x768) */
2759 {{ 0x28,0x5A,0x13,0x87,0xFF,0x29,0xA9 }} /* ; 05 (x1024) */
2760};
2761
2762XGI_LVDSCRT1DataStruct XGI_CHTVCRT1UNTSC[]=
2763{
2764 {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e,
2765 0xe8,0x84,0x8f,0x57,0x20,0x00,0x01,0x00 }},
2766 {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e,
2767 0xd0,0x82,0x5d,0x57,0x00,0x00,0x01,0x00 }},
2768 {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e,
2769 0xe8,0x84,0x8f,0x57,0x20,0x00,0x01,0x00 }},
2770 {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e,
2771 0xd0,0x82,0x5d,0x57,0x00,0x00,0x01,0x00 }},
2772 {{0x5d,0x4f,0x81,0x53,0x9c,0x56,0xba,
2773 0x18,0x84,0xdf,0x57,0x00,0x00,0x01,0x00 }},
2774 {{0x80,0x63,0x84,0x6c,0x17,0xec,0xf0,
2775 0x90,0x8c,0x57,0xed,0x20,0x00,0x06,0x01 }}
2776};
2777
2778XGI_LVDSCRT1DataStruct XGI_CHTVCRT1ONTSC[]=
2779{
2780 {{0x64,0x4f,0x88,0x5a,0x9f,0x0b,0x3e,
2781 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01,0x00 }},
2782 {{0x64,0x4f,0x88,0x5a,0x9f,0x0b,0x3e,
2783 0xb0,0x8d,0x5d,0x0c,0x00,0x00,0x01,0x00 }},
2784 {{0x64,0x4f,0x88,0x5a,0x9f,0x0b,0x3e,
2785 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01,0x00 }},
2786 {{0x64,0x4f,0x88,0x5a,0x9f,0x0b,0x3e,
2787 0xb0,0x8d,0x5d,0x0c,0x00,0x00,0x01,0x00 }},
2788 {{0x5d,0x4f,0x81,0x56,0x9c,0x0b,0x3e,
2789 0xe8,0x84,0xdf,0x0c,0x00,0x00,0x01,0x00 }},
2790 {{0x7d,0x63,0x81,0x6a,0x16,0xba,0xf0,
2791 0x7f,0x86,0x57,0xbb,0x00,0x00,0x06,0x01 }}
2792};
2793
2794XGI_LVDSCRT1DataStruct XGI_CHTVCRT1UPAL[]=
2795{
2796 {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
2797 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05,0x00 }},
2798 {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
2799 0xde,0x81,0x5d,0x70,0x00,0x00,0x05,0x00 }},
2800 {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
2801 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05,0x00 }},
2802 {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
2803 0xde,0x81,0x5d,0x70,0x00,0x00,0x05,0x00 }},
2804 {{0x64,0x4f,0x88,0x55,0x80,0xec,0xba,
2805 0x50,0x84,0xdf,0xed,0x00,0x00,0x05,0x00 }},
2806 {{0x70,0x63,0x94,0x68,0x8d,0x42,0xf1,
2807 0xc8,0x8c,0x57,0xe9,0x20,0x00,0x05,0x01 }}
2808};
2809
2810XGI_LVDSCRT1DataStruct XGI_CHTVCRT1OPAL[]=
2811{
2812 {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
2813 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05,0x00 }},
2814 {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
2815 0xde,0x81,0x5d,0x70,0x00,0x00,0x05,0x00 }},
2816 {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
2817 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05,0x00 }},
2818 {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
2819 0xde,0x81,0x5d,0x70,0x00,0x00,0x05,0x00 }},
2820 {{0x64,0x4f,0x88,0x55,0x80,0x6f,0xba,
2821 0x20,0x83,0xdf,0x70,0x00,0x00,0x05,0x00 }},
2822 {{0x73,0x63,0x97,0x69,0x8e,0xec,0xf0,
2823 0x90,0x8c,0x57,0xed,0x20,0x00,0x05,0x01 }}
2824};
2825
2826/*add for new UNIVGABIOS*/
2827XGI330_LCDDataTablStruct XGI_LCDDataTable[]=
2828{
2829 {Panel1024x768,0x0019,0x0001,0}, /* XGI_ExtLCD1024x768Data */
2830 {Panel1024x768,0x0019,0x0000,1}, /* XGI_StLCD1024x768Data */
2831 {Panel1024x768,0x0018,0x0010,2}, /* XGI_CetLCD1024x768Data */
2832 {Panel1280x1024,0x0019,0x0001,3}, /* XGI_ExtLCD1280x1024Data */
2833 {Panel1280x1024,0x0019,0x0000,4}, /* XGI_StLCD1280x1024Data */
2834 {Panel1280x1024,0x0018,0x0010,5}, /* XGI_CetLCD1280x1024Data */
2835 {Panel1400x1050,0x0019,0x0001,6}, /* XGI_ExtLCD1400x1050Data */
2836 {Panel1400x1050,0x0019,0x0000,7}, /* XGI_StLCD1400x1050Data */
2837 {Panel1400x1050,0x0018,0x0010,8}, /* XGI_CetLCD1400x1050Data */
2838 {Panel1600x1200,0x0019,0x0001,9}, /* XGI_ExtLCD1600x1200Data */
2839 {Panel1600x1200,0x0019,0x0000,10}, /* XGI_StLCD1600x1200Data */
2840 {PanelRef60Hz,0x0008,0x0008,11}, /* XGI_NoScalingData */
2841 {Panel1024x768x75,0x0019,0x0001,12}, /* XGI_ExtLCD1024x768x75Data */
2842 {Panel1024x768x75,0x0019,0x0000,13}, /* XGI_StLCD1024x768x75Data */
2843 {Panel1024x768x75,0x0018,0x0010,14}, /* XGI_CetLCD1024x768x75Data */
2844 {Panel1280x1024x75,0x0019,0x0001,15}, /* XGI_ExtLCD1280x1024x75Data */
2845 {Panel1280x1024x75,0x0019,0x0000,16}, /* XGI_StLCD1280x1024x75Data */
2846 {Panel1280x1024x75,0x0018,0x0010,17}, /* XGI_CetLCD1280x1024x75Data */
2847 {PanelRef75Hz,0x0008,0x0008,18}, /* XGI_NoScalingDatax75 */
2848 {0xFF,0x0000,0x0000,0} /* End of table */
2849};
2850
2851XGI330_LCDDataTablStruct XGI_LCDDesDataTable[]=
2852{
2853 {Panel1024x768,0x0019,0x0001,0}, /* XGI_ExtLCDDes1024x768Data */
2854 {Panel1024x768,0x0019,0x0000,1}, /* XGI_StLCDDes1024x768Data */
2855 {Panel1024x768,0x0018,0x0010,2}, /* XGI_CetLCDDes1024x768Data */
2856 {Panel1280x1024,0x0019,0x0001,3}, /* XGI_ExtLCDDes1280x1024Data */
2857 {Panel1280x1024,0x0019,0x0000,4}, /* XGI_StLCDDes1280x1024Data */
2858 {Panel1280x1024,0x0018,0x0010,5}, /* XGI_CetLCDDes1280x1024Data */
2859 {Panel1400x1050,0x0019,0x0001,6}, /* XGI_ExtLCDDes1400x1050Data */
2860 {Panel1400x1050,0x0019,0x0000,7}, /* XGI_StLCDDes1400x1050Data */
2861 {Panel1400x1050,0x0418,0x0010,8}, /* XGI_CetLCDDes1400x1050Data */
2862 {Panel1400x1050,0x0418,0x0410,9}, /* XGI_CetLCDDes1400x1050Data2 */
2863 {Panel1600x1200,0x0019,0x0001,10}, /* XGI_ExtLCDDes1600x1200Data */
2864 {Panel1600x1200,0x0019,0x0000,11}, /* XGI_StLCDDes1600x1200Data */
2865 {PanelRef60Hz,0x0008,0x0008,12}, /* XGI_NoScalingDesData */
2866 {Panel1024x768x75,0x0019,0x0001,13}, /* XGI_ExtLCDDes1024x768x75Data */
2867 {Panel1024x768x75,0x0019,0x0000,14}, /* XGI_StLCDDes1024x768x75Data */
2868 {Panel1024x768x75,0x0018,0x0010,15}, /* XGI_CetLCDDes1024x768x75Data */
2869 {Panel1280x1024x75,0x0019,0x0001,16}, /* XGI_ExtLCDDes1280x1024x75Data */
2870 {Panel1280x1024x75,0x0019,0x0000,17}, /* XGI_StLCDDes1280x1024x75Data */
2871 {Panel1280x1024x75,0x0018,0x0010,18}, /* XGI_CetLCDDes1280x1024x75Data */
2872 {PanelRef75Hz,0x0008,0x0008,19}, /* XGI_NoScalingDesDatax75 */
2873 {0xFF,0x0000,0x0000,0}
2874};
2875
2876XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_H[]=
2877{
2878 {Panel1024x768,0x0018,0x0000,0}, /* XGI_LVDSCRT11024x768_1_H */
2879 {Panel1024x768,0x0018,0x0010,1}, /* XGI_LVDSCRT11024x768_2_H */
2880 {Panel1280x1024,0x0018,0x0000,2}, /* XGI_LVDSCRT11280x1024_1_H */
2881 {Panel1280x1024,0x0018,0x0010,3}, /* XGI_LVDSCRT11280x1024_2_H */
2882 {Panel1400x1050,0x0018,0x0000,4}, /* XGI_LVDSCRT11400x1050_1_H */
2883 {Panel1400x1050,0x0018,0x0010,5}, /* XGI_LVDSCRT11400x1050_2_H */
2884 {Panel1600x1200,0x0018,0x0000,6}, /* XGI_LVDSCRT11600x1200_1_H */
2885 {Panel1024x768x75,0x0018,0x0000,7}, /* XGI_LVDSCRT11024x768_1_Hx75 */
2886 {Panel1024x768x75,0x0018,0x0010,8}, /* XGI_LVDSCRT11024x768_2_Hx75 */
2887 {Panel1280x1024x75,0x0018,0x0000,9}, /* XGI_LVDSCRT11280x1024_1_Hx75 */
2888 {Panel1280x1024x75,0x0018,0x0010,10}, /* XGI_LVDSCRT11280x1024_2_Hx75 */
2889 {0xFF,0x0000,0x0000,0}
2890};
2891
2892XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_V[]=
2893{
2894 {Panel1024x768,0x0018,0x0000,0}, /* XGI_LVDSCRT11024x768_1_V */
2895 {Panel1024x768,0x0018,0x0010,1}, /* XGI_LVDSCRT11024x768_2_V */
2896 {Panel1280x1024,0x0018,0x0000,2}, /* XGI_LVDSCRT11280x1024_1_V */
2897 {Panel1280x1024,0x0018,0x0010,3}, /* XGI_LVDSCRT11280x1024_2_V */
2898 {Panel1400x1050,0x0018,0x0000,4}, /* XGI_LVDSCRT11400x1050_1_V */
2899 {Panel1400x1050,0x0018,0x0010,5}, /* XGI_LVDSCRT11400x1050_2_V */
2900 {Panel1600x1200,0x0018,0x0000,6}, /* XGI_LVDSCRT11600x1200_1_V */
2901 {Panel1024x768x75,0x0018,0x0000,7}, /* XGI_LVDSCRT11024x768_1_Vx75 */
2902 {Panel1024x768x75,0x0018,0x0010,8}, /* XGI_LVDSCRT11024x768_2_Vx75 */
2903 {Panel1280x1024x75,0x0018,0x0000,9}, /* XGI_LVDSCRT11280x1024_1_Vx75 */
2904 {Panel1280x1024x75,0x0018,0x0010,10}, /* XGI_LVDSCRT11280x1024_2_Vx75 */
2905 {0xFF,0x0000,0x0000,0}
2906};
2907
2908XGI330_LCDDataTablStruct XGI_EPLLCDDataPtr[]=
2909{
2910 {Panel1024x768,0x0018,0x0000,0}, /* XGI_LVDS1024x768Data_1 */
2911 {Panel1024x768,0x0018,0x0010,1}, /* XGI_LVDS1024x768Data_2 */
2912 {Panel1280x1024,0x0018,0x0000,2}, /* XGI_LVDS1280x1024Data_1 */
2913 {Panel1280x1024,0x0018,0x0010,3}, /* XGI_LVDS1280x1024Data_2 */
2914 {Panel1400x1050,0x0018,0x0000,4}, /* XGI_LVDS1400x1050Data_1 */
2915 {Panel1400x1050,0x0018,0x0010,5}, /* XGI_LVDS1400x1050Data_2 */
2916 {Panel1600x1200,0x0018,0x0000,6}, /* XGI_LVDS1600x1200Data_1 */
2917 {PanelRef60Hz,0x0008,0x0008,7}, /* XGI_LVDSNoScalingData */
2918 {Panel1024x768x75,0x0018,0x0000,8}, /* XGI_LVDS1024x768Data_1x75 */
2919 {Panel1024x768x75,0x0018,0x0010,9}, /* XGI_LVDS1024x768Data_2x75 */
2920 {Panel1280x1024x75,0x0018,0x0000,10}, /* XGI_LVDS1280x1024Data_1x75 */
2921 {Panel1280x1024x75,0x0018,0x0010,11}, /* XGI_LVDS1280x1024Data_2x75 */
2922 {PanelRef75Hz,0x0008,0x0008,12}, /* XGI_LVDSNoScalingDatax75 */
2923 {0xFF,0x0000,0x0000,0}
2924};
2925
2926XGI330_LCDDataTablStruct XGI_EPLLCDDesDataPtr[]=
2927{
2928 {Panel1024x768,0x0018,0x0000,0}, /* XGI_LVDS1024x768Des_1 */
2929 {Panel1024x768,0x0618,0x0410,1}, /* XGI_LVDS1024x768Des_3 */
2930 {Panel1024x768,0x0018,0x0010,2}, /* XGI_LVDS1024x768Des_2 */
2931 {Panel1280x1024,0x0018,0x0000,3}, /* XGI_LVDS1280x1024Des_1 */
2932 {Panel1280x1024,0x0018,0x0010,4}, /* XGI_LVDS1280x1024Des_2 */
2933 {Panel1400x1050,0x0018,0x0000,5}, /* XGI_LVDS1400x1050Des_1 */
2934 {Panel1400x1050,0x0018,0x0010,6}, /* XGI_LVDS1400x1050Des_2 */
2935 {Panel1600x1200,0x0018,0x0000,7}, /* XGI_LVDS1600x1200Des_1 */
2936 {PanelRef60Hz,0x0008,0x0008,8}, /* XGI_LVDSNoScalingDesData */
2937 {Panel1024x768x75,0x0018,0x0000,9}, /* XGI_LVDS1024x768Des_1x75 */
2938 {Panel1024x768x75,0x0618,0x0410,10}, /* XGI_LVDS1024x768Des_3x75 */
2939 {Panel1024x768x75,0x0018,0x0010,11}, /* XGI_LVDS1024x768Des_2x75 */
2940 {Panel1280x1024x75,0x0018,0x0000,12}, /* XGI_LVDS1280x1024Des_1x75 */
2941 {Panel1280x1024x75,0x0018,0x0010,13}, /* XGI_LVDS1280x1024Des_2x75 */
2942 {PanelRef75Hz,0x0008,0x0008,14}, /* XGI_LVDSNoScalingDesDatax75 */
2943 {0xFF,0x0000,0x0000,0}
2944};
2945
2946XGI330_LCDDataTablStruct XGI_EPLCHLCDRegPtr[]=
2947{
2948 {Panel1024x768,0x0000,0x0000,0}, /* XGI_CH7017LV1024x768 */
2949 {Panel1400x1050,0x0000,0x0000,1}, /* XGI_CH7017LV1400x1050 */
2950 {0xFF,0x0000,0x0000,0}
2951};
2952
2953XGI330_TVDataTablStruct XGI_TVDataTable[]=
2954{
2955 {0x09E1,0x0001,0}, /* XGI_ExtPALData */
2956 {0x09E1,0x0000,1}, /* XGI_ExtNTSCData */
2957 {0x09E1,0x0801,2}, /* XGI_StPALData */
2958 {0x09E1,0x0800,3}, /* XGI_StNTSCData */
2959 {0x49E0,0x0100,4}, /* XGI_ExtHiTVData */
2960 {0x49E0,0x4100,5}, /* XGI_St2HiTVData */
2961 {0x49E0,0x4900,13}, /* XGI_St1HiTVData */
2962 {0x09E0,0x0020,6}, /* XGI_ExtYPbPr525iData */
2963 {0x09E0,0x0040,7}, /* XGI_ExtYPbPr525pData */
2964 {0x09E0,0x0080,8}, /* XGI_ExtYPbPr750pData */
2965 {0x09E0,0x0820,9}, /* XGI_StYPbPr525iData */
2966 {0x09E0,0x0840,10}, /* XGI_StYPbPr525pData */
2967 {0x09E0,0x0880,11}, /* XGI_StYPbPr750pData */
2968 {0xffff,0x0000,12} /* END */
2969};
2970
2971USHORT TVLenList[]=
2972{
2973 LVDSCRT1Len_H,
2974 LVDSCRT1Len_V,
2975 LVDSDataLen,
2976 0,
2977 TVDataLen,
2978 0,
2979 0,
2980 CHTVRegLen
2981} ;
2982
2983/* Chrontel 7017 TV CRT1 Timing List */
2984XGI330_TVDataTablStruct XGI_EPLCHTVCRT1Ptr[]=
2985{
2986 {0x0011,0x0000,0}, /* XGI_CHTVCRT1UNTSC */
2987 {0x0011,0x0010,1}, /* XGI_CHTVCRT1ONTSC */
2988 {0x0011,0x0001,2}, /* XGI_CHTVCRT1UPAL */
2989 {0x0011,0x0011,3}, /* XGI_CHTVCRT1OPAL */
2990 {0xFFFF,0x0000,4}
2991};
2992
2993/* ;;Chrontel 7017 TV Timing List */
2994XGI330_TVDataTablStruct XGI_EPLCHTVDataPtr[]=
2995{
2996 {0x0011,0x0000,0}, /* XGI_CHTVUNTSCData */
2997 {0x0011,0x0010,1}, /* XGI_CHTVONTSCData */
2998 {0x0011,0x0001,2}, /* XGI_CHTVUPALData */
2999 {0x0011,0x0011,3}, /* XGI_CHTVOPALData */
3000 {0xFFFF,0x0000,4}
3001};
3002
3003/* ;;Chrontel 7017 TV Reg. List */
3004XGI330_TVDataTablStruct XGI_EPLCHTVRegPtr[]=
3005{
3006 {0x0011,0x0000,0}, /* XGI_CHTVRegUNTSC */
3007 {0x0011,0x0010,1}, /* XGI_CHTVRegONTSC */
3008 {0x0011,0x0001,2}, /* XGI_CHTVRegUPAL */
3009 {0x0011,0x0011,3}, /* XGI_CHTVRegOPAL */
3010 {0xFFFF,0x0000,4}
3011};
3012
3013USHORT LCDLenList[]=
3014{
3015 LVDSCRT1Len_H,
3016 LVDSCRT1Len_V,
3017 LVDSDataLen,
3018 LCDDesDataLen,
3019 LCDDataLen,
3020 LCDDesDataLen,
3021 0,
3022 LCDDesDataLen,
3023 LCDDesDataLen,
3024 0
3025} ;
3026
3027XGI330_LCDCapStruct XGI660_LCDDLCapList[]= /* 660, Dual link */
3028{
3029/* LCDCap1024x768 */
3030 {Panel1024x768, DefaultLCDCap, 0, 0x014, 0x88, 0x06, VCLK65,
3031 0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
3032 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
3033/* LCDCap1280x1024 */
3034 {Panel1280x1024, LCDDualLink+DefaultLCDCap, StLCDBToA, 0x053, 0x70, 0x03, VCLK108_2,
3035 0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
3036 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3037/* LCDCap1400x1050 */
3038 {Panel1400x1050, LCDDualLink+DefaultLCDCap, StLCDBToA, 0x053, 0x70, 0x03, VCLK108_2,
3039 0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
3040 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3041/* LCDCap1600x1200 */
3042 {Panel1600x1200, LCDDualLink+DefaultLCDCap, LCDToFull, 0x053, 0xC0, 0x03, VCLK162,
3043 0x43, 0x22, 0x70, 0x24, 0x02, 0x14, 0x0A, 0x02, 0x00,
3044 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3045/* LCDCap1024x768x75 */
3046 {Panel1024x768x75, DefaultLCDCap, 0, 0x014, 0x60, 0, VCLK78_75,
3047 0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
3048 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
3049/* LCDCap1280x1024x75 */
3050 {Panel1280x1024x75, LCDDualLink+DefaultLCDCap, StLCDBToA, 0x053, 0x90, 0x03, VCLK135_5,
3051 0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
3052 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3053/* LCDCapDefault */
3054 {0xFF, DefaultLCDCap, 0, 0x053, 0x88, 0x06, VCLK65,
3055 0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
3056 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
3057};
3058
3059XGI330_LCDCapStruct XGI_LCDDLCapList[]= /* Dual link only */
3060{
3061/* LCDCap1024x768 */
3062 {Panel1024x768, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
3063 0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
3064 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
3065/* LCDCap1280x1024 */
3066 {Panel1280x1024, LCDDualLink+DefaultLCDCap, StLCDBToA, 0x012, 0x70, 0x03, VCLK108_2,
3067 0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
3068 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3069/* LCDCap1400x1050 */
3070 {Panel1400x1050, LCDDualLink+DefaultLCDCap, StLCDBToA, 0x012, 0x70, 0x03, VCLK108_2,
3071 0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
3072 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3073/* LCDCap1600x1200 */
3074 {Panel1600x1200, LCDDualLink+DefaultLCDCap, LCDToFull, 0x012, 0xC0, 0x03, VCLK162,
3075 0x43, 0x22, 0x70, 0x24, 0x02, 0x14, 0x0A, 0x02, 0x00,
3076 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3077/* LCDCap1024x768x75 */
3078 {Panel1024x768x75, DefaultLCDCap, 0, 0x012, 0x60, 0, VCLK78_75,
3079 0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
3080 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
3081/* LCDCap1280x1024x75 */
3082 {Panel1280x1024x75, LCDDualLink+DefaultLCDCap, StLCDBToA, 0x012, 0x90, 0x03, VCLK135_5,
3083 0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
3084 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3085/* LCDCapDefault */
3086 {0xFF, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
3087 0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
3088 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
3089};
3090
3091XGI330_LCDCapStruct XGI660_LCDCapList[]=
3092{
3093/* LCDCap1024x768 */
3094 {Panel1024x768, DefaultLCDCap, 0, 0x014, 0x88, 0x06, VCLK65,
3095 0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
3096 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
3097/* LCDCap1280x1024 */
3098 {Panel1280x1024, DefaultLCDCap, StLCDBToA, 0x053, 0x70, 0x03, VCLK108_2,
3099 0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
3100 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3101/* LCDCap1400x1050 */
3102 {Panel1400x1050, DefaultLCDCap, StLCDBToA, 0x053, 0x70, 0x03, VCLK108_2,
3103 0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
3104 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3105/* LCDCap1600x1200 */
3106 {Panel1600x1200, DefaultLCDCap, LCDToFull, 0x053, 0xC0, 0x03, VCLK162,
3107 0x5A, 0x23, 0x5A, 0x23, 0x02, 0x14, 0x0A, 0x02, 0x00,
3108 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3109/* LCDCap1024x768x75 */
3110 {Panel1024x768x75, DefaultLCDCap, 0, 0x014, 0x60, 0, VCLK78_75,
3111 0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
3112 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
3113/* LCDCap1280x1024x75 */
3114 {Panel1280x1024x75,+DefaultLCDCap, StLCDBToA, 0x053, 0x90, 0x03, VCLK135_5,
3115 0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
3116 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3117/* LCDCapDefault */
3118 {0xFF, DefaultLCDCap, 0, 0x053, 0x88, 0x06, VCLK65,
3119 0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
3120 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
3121};
3122
3123XGI330_LCDCapStruct XGI_LCDCapList[]=
3124{
3125/* LCDCap1024x768 */
3126 {Panel1024x768, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
3127 0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
3128 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
3129/* LCDCap1280x1024 */
3130 {Panel1280x1024, DefaultLCDCap, StLCDBToA, 0x012, 0x70, 0x03, VCLK108_2,
3131 0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
3132 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3133/* LCDCap1400x1050 */
3134 {Panel1400x1050, DefaultLCDCap, StLCDBToA, 0x012, 0x70, 0x03, VCLK108_2,
3135 0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
3136 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3137/* LCDCap1600x1200 */
3138 {Panel1600x1200, DefaultLCDCap, LCDToFull, 0x012, 0xC0, 0x03, VCLK162,
3139 0x5A, 0x23, 0x5A, 0x23, 0x02, 0x14, 0x0A, 0x02, 0x00,
3140 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3141/* LCDCap1024x768x75 */
3142 {Panel1024x768x75, DefaultLCDCap, 0, 0x012, 0x60, 0, VCLK78_75,
3143 0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
3144 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
3145/* LCDCap1280x1024x75 */
3146 {Panel1280x1024x75, DefaultLCDCap, StLCDBToA, 0x012, 0x90, 0x03, VCLK135_5,
3147 0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
3148 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
3149/* LCDCapDefault */
3150 {0xFF, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
3151 0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
3152 0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
3153};
3154
3155XGI21_LVDSCapStruct XGI21_LCDCapList[]=
3156{
3157 {DisableLCD24bpp + LCDPolarity,
3158 2160,1250,1600,1200, 64, 1, 192, 3,
3159 0x70,0x24,0x20,0x04,0x0A,0x02,0xC8
3160 },
3161 {DisableLCD24bpp + LCDPolarity,
3162 1688,1066,1280,1024, 48, 1, 112, 3,
3163 0x70,0x44,0x20,0x04,0x0A,0x02,0xC8
3164 },
3165 {DisableLCD24bpp + LCDPolarity + (LCDPolarity << 8),
3166 1344, 806,1024, 768, 24, 3, 136, 6,
3167 0x6C,0x65,0x20,0x04,0x0A,0x02,0xC8
3168 },
3169 {DisableLCD24bpp + LCDPolarity,
3170 1056, 628, 800, 600, 40, 1, 128, 4,
3171 0x42,0xE2,0x20,0x14,0x0A,0x02,0x00
3172 },
3173 {DisableLCD24bpp + LCDPolarity,
3174 928, 525, 800, 480, 40, 13, 48, 3,
3175 0x52,0xC5,0x20,0x14,0x0A,0x02,0x00
3176 },
3177 {DisableLCD24bpp + LCDPolarity + (LCDPolarity << 8),
3178 800, 525, 640, 480, 16, 10, 96, 2,
3179 0x1B,0xE1,0x20,0x04,0x0A,0x02,0xC8
3180 }
3181
3182};
3183
3184XGI_Ext2Struct XGI330_RefIndex[]=
3185{
3186{Support32Bpp + SupportAllCRT2 + SyncPN, RES320x200, VCLK25_175, 0x00,0x10,0x59, 320, 200},/* 00 */
3187{Support32Bpp + SupportAllCRT2 + SyncPN, RES320x200, VCLK25_175, 0x00,0x10,0x00, 320, 400},/* 01 */
3188{Support32Bpp + SupportAllCRT2 + SyncNN, RES320x240, VCLK25_175, 0x04,0x20,0x50, 320, 240},/* 02 */
3189{Support32Bpp + SupportAllCRT2 + SyncPP, RES400x300, VCLK40, 0x05,0x32,0x51, 400, 300},/* 03 */
3190{Support32Bpp + NoSupportTV + SyncNN + SupportTV1024, RES512x384, VCLK65, 0x06,0x43,0x52, 512, 384},/* 04 */
3191{Support32Bpp + SupportAllCRT2 + SyncPN, RES640x400, VCLK25_175, 0x00,0x14,0x2f, 640, 400},/* 05 */
3192{Support32Bpp + SupportAllCRT2 + SyncNN, RES640x480x60, VCLK25_175, 0x04,0x24,0x2e, 640, 480},/* 06 640x480x60Hz (LCD 640x480x60z) */
3193{Support32Bpp + NoSupportHiVisionTV + SyncNN, RES640x480x72, VCLK31_5, 0x04,0x24,0x2e, 640, 480},/* 07 640x480x72Hz (LCD 640x480x70Hz) */
3194{Support32Bpp + NoSupportHiVisionTV + SyncNN, RES640x480x75, VCLK31_5, 0x47,0x24,0x2e, 640, 480},/* 08 640x480x75Hz (LCD 640x480x75Hz) */
3195{Support32Bpp + SupportRAMDAC2 + SyncNN, RES640x480x85, VCLK36, 0x8A,0x24,0x2e, 640, 480},/* 09 640x480x85Hz */
3196{Support32Bpp + SupportRAMDAC2 + SyncPN, RES640x480x100, VCLK43_163, 0x00,0x24,0x2e, 640, 480},/* 0a 640x480x100Hz */
3197{Support32Bpp + SupportRAMDAC2 + SyncPN, RES640x480x120, VCLK52_406, 0x00,0x24,0x2e, 640, 480},/* 0b 640x480x120Hz */
3198{Support32Bpp + SupportRAMDAC2 + SyncPN, RES640x480x160, VCLK72_852, 0x00,0x24,0x2e, 640, 480},/* 0c 640x480x160Hz */
3199{Support32Bpp + SupportRAMDAC2 + SyncNN, RES640x480x200, VCLK86_6, 0x00,0x24,0x2e, 640, 480},/* 0d 640x480x200Hz */
3200{Support32Bpp + NoSupportLCD + SyncPP, RES800x600x56, VCLK36, 0x05,0x36,0x6a, 800, 600},/* 0e 800x600x56Hz */
3201{Support32Bpp + NoSupportTV + SyncPP, RES800x600x60, VCLK40, 0x05,0x36,0x6a, 800, 600},/* 0f 800x600x60Hz (LCD 800x600x60Hz) */
3202{Support32Bpp + NoSupportHiVisionTV + SyncPP, RES800x600x72, VCLK50, 0x48,0x36,0x6a, 800, 600},/* 10 800x600x72Hz (LCD 800x600x70Hz) */
3203{Support32Bpp + NoSupportHiVisionTV + SyncPP, RES800x600x75, VCLK49_5, 0x8B,0x36,0x6a, 800, 600},/* 11 800x600x75Hz (LCD 800x600x75Hz) */
3204{Support32Bpp + SupportRAMDAC2 + SyncPP, RES800x600x85, VCLK56_25, 0x00,0x36,0x6a, 800, 600},/* 12 800x600x85Hz */
3205{Support32Bpp + SupportRAMDAC2 + SyncPN, RES800x600x100, VCLK68_179, 0x00,0x36,0x6a, 800, 600},/* 13 800x600x100Hz */
3206{Support32Bpp + SupportRAMDAC2 + SyncPN, RES800x600x120, VCLK83_95, 0x00,0x36,0x6a, 800, 600},/* 14 800x600x120Hz */
3207{Support32Bpp + SupportRAMDAC2 + SyncPN, RES800x600x160, VCLK116_406,0x00,0x36,0x6a, 800, 600},/* 15 800x600x160Hz */
3208{Support32Bpp + InterlaceMode + SyncPP, RES1024x768x43, VCLK44_9, 0x00,0x47,0x37,1024, 768},/* 16 1024x768x43Hz */
3209{Support32Bpp + NoSupportTV + SyncNN + SupportTV1024, RES1024x768x60, VCLK65, 0x06,0x47,0x37,1024, 768},/* 17 1024x768x60Hz (LCD 1024x768x60Hz) */
3210{Support32Bpp + NoSupportHiVisionTV + SyncNN, RES1024x768x70, VCLK75, 0x49,0x47,0x37,1024, 768},/* 18 1024x768x70Hz (LCD 1024x768x70Hz) */
3211{Support32Bpp + NoSupportHiVisionTV + SyncPP, RES1024x768x75, VCLK78_75, 0x00,0x47,0x37,1024, 768},/* 19 1024x768x75Hz (LCD 1024x768x75Hz) */
3212{Support32Bpp + SupportRAMDAC2 + SyncPP, RES1024x768x85, VCLK94_5, 0x8C,0x47,0x37,1024, 768},/* 1a 1024x768x85Hz */
3213{Support32Bpp + SupportRAMDAC2 + SyncPN, RES1024x768x100, VCLK113_309,0x00,0x47,0x37,1024, 768},/* 1b 1024x768x100Hz */
3214{Support32Bpp + SupportRAMDAC2 + SyncPN, RES1024x768x120, VCLK139_054,0x00,0x47,0x37,1024, 768},/* 1c 1024x768x120Hz */
3215{Support32Bpp + SupportLCD + SyncPP, RES1280x960x60, VCLK108_2, 0x08,0x58,0x7b,1280, 960},/* 1d 1280x960x60Hz */
3216{Support32Bpp + InterlaceMode + SyncPP, RES1280x1024x43, VCLK78_75, 0x00,0x58,0x3a,1280,1024},/* 1e 1280x1024x43Hz */
3217{Support32Bpp + NoSupportTV + SyncPP, RES1280x1024x60, VCLK108_2, 0x07,0x58,0x3a,1280,1024},/* 1f 1280x1024x60Hz (LCD 1280x1024x60Hz) */
3218{Support32Bpp + NoSupportTV + SyncPP, RES1280x1024x75, VCLK135_5, 0x00,0x58,0x3a,1280,1024},/* 20 1280x1024x75Hz (LCD 1280x1024x75Hz) */
3219{Support32Bpp + SyncPP, RES1280x1024x85, VCLK157_5, 0x00,0x58,0x3a,1280,1024},/* 21 1280x1024x85Hz */
3220{Support32Bpp + SupportLCD + SyncPP + SupportCRT2in301C, RES1600x1200x60, VCLK162, 0x09,0x7A,0x3c,1600,1200},/* 22 1600x1200x60Hz */
3221{Support32Bpp + SyncPP + SupportCRT2in301C, RES1600x1200x65, VCLK175, 0x00,0x69,0x3c,1600,1200},/* 23 1600x1200x65Hz */
3222{Support32Bpp + SyncPP + SupportCRT2in301C, RES1600x1200x70, VCLK189, 0x00,0x69,0x3c,1600,1200},/* 24 1600x1200x70Hz */
3223{Support32Bpp + SyncPP + SupportCRT2in301C, RES1600x1200x75, VCLK202_5, 0x00,0x69,0x3c,1600,1200},/* 25 1600x1200x75Hz */
3224{Support32Bpp + SyncPP, RES1600x1200x85, VCLK229_5, 0x00,0x69,0x3c,1600,1200},/* 26 1600x1200x85Hz */
3225{Support32Bpp + SyncPP, RES1600x1200x100,VCLK269_655,0x00,0x69,0x3c,1600,1200},/* 27 1600x1200x100Hz */
3226{Support32Bpp + SyncPP, RES1600x1200x120,VCLK323_586,0x00,0x69,0x3c,1600,1200},/* 28 1600x1200x120Hz */
3227{Support32Bpp + SupportLCD + SyncNP, RES1920x1440x60, VCLK234, 0x00,0x00,0x68,1920,1440},/* 29 1920x1440x60Hz */
3228{Support32Bpp + SyncPN, RES1920x1440x65, VCLK254_817,0x00,0x00,0x68,1920,1440},/* 2a 1920x1440x65Hz */
3229{Support32Bpp + SyncPN, RES1920x1440x70, VCLK277_015,0x00,0x00,0x68,1920,1440},/* 2b 1920x1440x70Hz */
3230{Support32Bpp + SyncPN, RES1920x1440x75, VCLK291_132,0x00,0x00,0x68,1920,1440},/* 2c 1920x1440x75Hz */
3231{Support32Bpp + SyncPN, RES1920x1440x85, VCLK330_615,0x00,0x00,0x68,1920,1440},/* 2d 1920x1440x85Hz */
3232{Support16Bpp + SyncPN, RES1920x1440x100,VCLK388_631,0x00,0x00,0x68,1920,1440},/* 2e 1920x1440x100Hz */
3233{Support32Bpp + SupportLCD + SyncPN, RES2048x1536x60, VCLK266_952,0x00,0x00,0x6c,2048,1536},/* 2f 2048x1536x60Hz */
3234{Support32Bpp + SyncPN, RES2048x1536x65, VCLK291_766,0x00,0x00,0x6c,2048,1536},/* 30 2048x1536x65Hz */
3235{Support32Bpp + SyncPN, RES2048x1536x70, VCLK315_195,0x00,0x00,0x6c,2048,1536},/* 31 2048x1536x70Hz */
3236{Support32Bpp + SyncPN, RES2048x1536x75, VCLK340_477,0x00,0x00,0x6c,2048,1536},/* 32 2048x1536x75Hz */
3237{Support16Bpp + SyncPN, RES2048x1536x85, VCLK375_847,0x00,0x00,0x6c,2048,1536},/* 33 2048x1536x85Hz */
3238{Support32Bpp + SupportHiVisionTV + SupportRAMDAC2 + SyncPP + SupportYPbPr, RES800x480x60, VCLK39_77, 0x08,0x00,0x70, 800, 480},/* 34 800x480x60Hz */
3239{Support32Bpp + SupportRAMDAC2 + SyncPP, RES800x480x75, VCLK49_5, 0x08,0x00,0x70, 800, 480},/* 35 800x480x75Hz */
3240{Support32Bpp + SupportRAMDAC2 + SyncPP, RES800x480x85, VCLK56_25, 0x08,0x00,0x70, 800, 480},/* 36 800x480x85Hz */
3241{Support32Bpp + SupportHiVisionTV + SupportRAMDAC2 + SyncPP + SupportYPbPr, RES1024x576x60, VCLK65, 0x09,0x00,0x71,1024, 576},/* 37 1024x576x60Hz */
3242{Support32Bpp + SupportRAMDAC2 + SyncPP, RES1024x576x75, VCLK78_75, 0x09,0x00,0x71,1024, 576},/* 38 1024x576x75Hz */
3243{Support32Bpp + SupportRAMDAC2 + SyncPP, RES1024x576x85, VCLK94_5, 0x09,0x00,0x71,1024, 576},/* 39 1024x576x85Hz */
3244{Support32Bpp + SupportHiVisionTV + SupportRAMDAC2 + SyncPP + SupportYPbPr, RES1280x720x60, VCLK108_2, 0x0A,0x00,0x75,1280, 720},/* 3a 1280x720x60Hz */
3245{Support32Bpp + SupportRAMDAC2 + SyncPP, RES1280x720x75, VCLK135_5, 0x0A,0x00,0x75,1280, 720},/* 3b 1280x720x75Hz */
3246{Support32Bpp + SupportRAMDAC2 + SyncPP, RES1280x720x85, VCLK157_5, 0x0A,0x00,0x75,1280, 720},/* 3c 1280x720x85Hz */
3247{Support32Bpp + SupportTV + SyncNN, RES720x480x60, VCLK28_322, 0x06,0x00,0x31, 720, 480},/* 3d 720x480x60Hz */
3248{Support32Bpp + SupportTV + SyncPP, RES720x576x56, VCLK36, 0x06,0x00,0x32, 720, 576},/* 3e 720x576x56Hz */
3249{Support32Bpp + InterlaceMode + NoSupportLCD + SyncPP, RES856x480x79I, VCLK35_2, 0x00,0x00,0x00, 856, 480},/* 3f 856x480x79I */
3250{Support32Bpp + NoSupportLCD + SyncNN, RES856x480x60, VCLK35_2, 0x00,0x00,0x00, 856, 480},/* 40 856x480x60Hz */
3251{Support32Bpp + NoSupportHiVisionTV + SyncPP, RES1280x768x60, VCLK79_411, 0x08,0x48,0x23,1280, 768},/* 41 1280x768x60Hz */
3252{Support32Bpp + NoSupportHiVisionTV + SyncPP, RES1400x1050x60, VCLK122_61, 0x08,0x69,0x26,1400,1050},/* 42 1400x1050x60Hz */
3253{Support32Bpp + SupportRAMDAC2 + SyncPP, RES1152x864x60, VCLK80_350, 0x37,0x00,0x20,1152, 864},/* 43 1152x864x60Hz */
3254{Support32Bpp + SupportRAMDAC2 + SyncPP, RES1152x864x75, VCLK107_385,0x37,0x00,0x20,1152, 864},/* 44 1152x864x75Hz */
3255{Support32Bpp + SupportLCD + SupportRAMDAC2 + SyncPP, RES1280x960x75, VCLK125_999,0x3A,0x88,0x7b,1280, 960},/* 45 1280x960x75Hz */
3256{Support32Bpp + SupportLCD + SupportRAMDAC2 + SyncPP, RES1280x960x85, VCLK148_5, 0x0A,0x88,0x7b,1280, 960},/* 46 1280x960x85Hz */
3257{Support32Bpp + SupportLCD + SupportRAMDAC2 + SyncPP, RES1280x960x120, VCLK217_325,0x3A,0x88,0x7b,1280, 960},/* 47 1280x960x120Hz */
3258{Support32Bpp + SupportRAMDAC2 + SyncPN, RES1024x768x160, VCLK139_054,0x30,0x47,0x37,1024, 768},/* 48 1024x768x160Hz */
3259};
3260
3261
3262
3263XGI330_VCLKDataStruct XGI330_VCLKData[]=
3264{
3265 { 0x1b,0xe1, 25}, /* 0x0 */
3266 { 0x4e,0xe4, 28}, /* 0x1 */
3267 { 0x57,0xe4, 31}, /* 0x2 */
3268 { 0xc3,0xc8, 36}, /* 0x3 */
3269 { 0x42,0xe2, 40}, /* 0x4 */
3270 { 0xfe,0xcd, 43}, /* 0x5 */
3271 { 0x5d,0xc4, 44}, /* 0x6 */
3272 { 0x52,0xe2, 49}, /* 0x7 */
3273 { 0x53,0xe2, 50}, /* 0x8 */
3274 { 0x74,0x67, 52}, /* 0x9 */
3275 { 0x6d,0x66, 56}, /* 0xa */
3276 { 0x6c,0xc3, 65}, /* 0xb */
3277 { 0x46,0x44, 67}, /* 0xc */
3278 { 0xb1,0x46, 68}, /* 0xd */
3279 { 0xd3,0x4a, 72}, /* 0xe */
3280 { 0x29,0x61, 75}, /* 0xf */
3281 { 0x6e,0x46, 76}, /* 0x10 */
3282 { 0x2b,0x61, 78}, /* 0x11 */
3283 { 0x31,0x42, 79}, /* 0x12 */
3284 { 0xab,0x44, 83}, /* 0x13 */
3285 { 0x46,0x25, 84}, /* 0x14 */
3286 { 0x78,0x29, 86}, /* 0x15 */
3287 { 0x62,0x44, 94}, /* 0x16 */
3288 { 0x2b,0x41,104}, /* 0x17 */
3289 { 0x3a,0x23,105}, /* 0x18 */
3290 { 0x70,0x44,108}, /* 0x19 */
3291 { 0x3c,0x23,109}, /* 0x1a */
3292 { 0x5e,0x43,113}, /* 0x1b */
3293 { 0xbc,0x44,116}, /* 0x1c */
3294 { 0xe0,0x46,132}, /* 0x1d */
3295 { 0x54,0x42,135}, /* 0x1e */
3296 { 0xea,0x2a,139}, /* 0x1f */
3297 { 0x41,0x22,157}, /* 0x20 */
3298 { 0x70,0x24,162}, /* 0x21 */
3299 { 0x30,0x21,175}, /* 0x22 */
3300 { 0x4e,0x22,189}, /* 0x23 */
3301 { 0xde,0x26,194}, /* 0x24 */
3302 { 0x62,0x06,202}, /* 0x25 */
3303 { 0x3f,0x03,229}, /* 0x26 */
3304 { 0xb8,0x06,234}, /* 0x27 */
3305 { 0x34,0x02,253}, /* 0x28 */
3306 { 0x58,0x04,255}, /* 0x29 */
3307 { 0x24,0x01,265}, /* 0x2a */
3308 { 0x9b,0x02,267}, /* 0x2b */
3309 { 0x70,0x05,270}, /* 0x2c */
3310 { 0x25,0x01,272}, /* 0x2d */
3311 { 0x9c,0x02,277}, /* 0x2e */
3312 { 0x27,0x01,286}, /* 0x2f */
3313 { 0x3c,0x02,291}, /* 0x30 */
3314 { 0xef,0x0a,292}, /* 0x31 */
3315 { 0xf6,0x0a,310}, /* 0x32 */
3316 { 0x95,0x01,315}, /* 0x33 */
3317 { 0xf0,0x09,324}, /* 0x34 */
3318 { 0xfe,0x0a,331}, /* 0x35 */
3319 { 0xf3,0x09,332}, /* 0x36 */
3320 { 0xea,0x08,340}, /* 0x37 */
3321 { 0xe8,0x07,376}, /* 0x38 */
3322 { 0xde,0x06,389}, /* 0x39 */
3323 { 0x52,0x2a, 54}, /* 0x3a */
3324 { 0x52,0x6a, 27}, /* 0x3b */
3325 { 0x62,0x24, 70}, /* 0x3c */
3326 { 0x62,0x64, 70}, /* 0x3d */
3327 { 0xa8,0x4c, 30}, /* 0x3e */
3328 { 0x20,0x26, 33}, /* 0x3f */
3329 { 0x31,0xc2, 39}, /* 0x40 */
3330 { 0x60,0x36, 30}, /* 0x41 */
3331 { 0x40,0x4A, 28}, /* 0x42 */
3332 { 0x9F,0x46, 44}, /* 0x43 */
3333 { 0x97,0x2C, 26}, /* 0x44 */
3334 { 0x44,0xE4, 25}, /* 0x45 */
3335 { 0x7E,0x32, 47}, /* 0x46 */
3336 { 0x08,0x24, 31}, /* 0x47 */
3337 { 0x97,0x2c, 26}, /* 0x48 */
3338 { 0xCE,0x3c, 39}, /* 0x49 */
3339 { 0x52,0x4A, 36}, /* 0x4a */
3340 { 0x2C,0x61, 95}, /* 0x4b */
3341 { 0x78,0x27,108}, /* 0x4c */
3342 { 0x66,0x43,123}, /* 0x4d */
3343 { 0x2c,0x61, 80}, /* 0x4e */
3344 { 0x3b,0x61,108} /* 0x4f */
3345};
3346
3347XGI_VBVCLKDataStruct XGI330_VBVCLKData[]=
3348{
3349 { 0x1b,0xe1, 25}, /* 0x0 */
3350 { 0x4e,0xe4, 28}, /* 0x1 */
3351 { 0x57,0xe4, 31}, /* 0x2 */
3352 { 0xc3,0xc8, 36}, /* 0x3 */
3353 { 0x42,0x47, 40}, /* 0x4 */
3354 { 0xfe,0xcd, 43}, /* 0x5 */
3355 { 0x5d,0xc4, 44}, /* 0x6 */
3356 { 0x52,0x47, 49}, /* 0x7 */
3357 { 0x53,0x47, 50}, /* 0x8 */
3358 { 0x74,0x67, 52}, /* 0x9 */
3359 { 0x6d,0x66, 56}, /* 0xa */
3360 { 0x5a,0x64, 65}, /* 0xb */
3361 { 0x46,0x44, 67}, /* 0xc */
3362 { 0xb1,0x46, 68}, /* 0xd */
3363 { 0xd3,0x4a, 72}, /* 0xe */
3364 { 0x29,0x61, 75}, /* 0xf */
3365 { 0x6d,0x46, 75}, /* 0x10 */
3366 { 0x41,0x43, 78}, /* 0x11 */
3367 { 0x31,0x42, 79}, /* 0x12 */
3368 { 0xab,0x44, 83}, /* 0x13 */
3369 { 0x46,0x25, 84}, /* 0x14 */
3370 { 0x78,0x29, 86}, /* 0x15 */
3371 { 0x62,0x44, 94}, /* 0x16 */
3372 { 0x2b,0x22,104}, /* 0x17 */
3373 { 0x49,0x24,105}, /* 0x18 */
3374 { 0xf8,0x2f,108}, /* 0x19 */
3375 { 0x3c,0x23,109}, /* 0x1a */
3376 { 0x5e,0x43,113}, /* 0x1b */
3377 { 0xbc,0x44,116}, /* 0x1c */
3378 { 0xe0,0x46,132}, /* 0x1d */
3379 { 0xd4,0x28,135}, /* 0x1e */
3380 { 0xea,0x2a,139}, /* 0x1f */
3381 { 0x41,0x22,157}, /* 0x20 */
3382 { 0x70,0x24,162}, /* 0x21 */
3383 { 0x30,0x21,175}, /* 0x22 */
3384 { 0x4e,0x22,189}, /* 0x23 */
3385 { 0xde,0x26,194}, /* 0x24 */
3386 { 0x70,0x07,202}, /* 0x25 */
3387 { 0x3f,0x03,229}, /* 0x26 */
3388 { 0xb8,0x06,234}, /* 0x27 */
3389 { 0x34,0x02,253}, /* 0x28 */
3390 { 0x58,0x04,255}, /* 0x29 */
3391 { 0x24,0x01,265}, /* 0x2a */
3392 { 0x9b,0x02,267}, /* 0x2b */
3393 { 0x70,0x05,270}, /* 0x2c */
3394 { 0x25,0x01,272}, /* 0x2d */
3395 { 0x9c,0x02,277}, /* 0x2e */
3396 { 0x27,0x01,286}, /* 0x2f */
3397 { 0x3c,0x02,291}, /* 0x30 */
3398 { 0xef,0x0a,292}, /* 0x31 */
3399 { 0xf6,0x0a,310}, /* 0x32 */
3400 { 0x95,0x01,315}, /* 0x33 */
3401 { 0xf0,0x09,324}, /* 0x34 */
3402 { 0xfe,0x0a,331}, /* 0x35 */
3403 { 0xf3,0x09,332}, /* 0x36 */
3404 { 0xea,0x08,340}, /* 0x37 */
3405 { 0xe8,0x07,376}, /* 0x38 */
3406 { 0xde,0x06,389}, /* 0x39 */
3407 { 0x52,0x2a, 54}, /* 0x3a */
3408 { 0x52,0x6a, 27}, /* 0x3b */
3409 { 0x62,0x24, 70}, /* 0x3c */
3410 { 0x62,0x64, 70}, /* 0x3d */
3411 { 0xa8,0x4c, 30}, /* 0x3e */
3412 { 0x20,0x26, 33}, /* 0x3f */
3413 { 0x31,0xc2, 39}, /* 0x40 */
3414 { 0x2e,0x48, 25}, /* 0x41 */
3415 { 0x24,0x46, 25}, /* 0x42 */
3416 { 0x26,0x64, 28}, /* 0x43 */
3417 { 0x37,0x64, 40}, /* 0x44 */
3418 { 0xa1,0x42,108}, /* 0x45 */
3419 { 0x37,0x61,100}, /* 0x46 */
3420 { 0x78,0x27,108}, /* 0x47 */
3421 { 0x5e,0x64,68}, /* 0x48 chiawen for fuj1280x768*/
3422 { 0x70,0x44,108}, /* 0x49 chiawen for 1400x1050*/
3423};
3424
3425UCHAR XGI330_ScreenOffset[]={ 0x14,0x19,0x20,0x28,0x32,0x40,0x50,0x64,0x78,0x80,0x2d,0x35,0x57,0x48 };
3426
3427XGI_StResInfoStruct XGI330_StResInfo[]=
3428{
3429 { 640,400},
3430 { 640,350},
3431 { 720,400},
3432 { 720,350},
3433 { 640,480}
3434};
3435
3436XGI_ModeResInfoStruct XGI330_ModeResInfo[]=
3437{
3438 { 320, 200, 8, 8},
3439 { 320, 240, 8, 8},
3440 { 320, 400, 8, 8},
3441 { 400, 300, 8, 8},
3442 { 512, 384, 8, 8},
3443 { 640, 400, 8,16},
3444 { 640, 480, 8,16},
3445 { 800, 600, 8,16},
3446 { 1024, 768, 8,16},
3447 { 1280,1024, 8,16},
3448 { 1600,1200, 8,16},
3449 { 1920,1440, 8,16},
3450 { 2048,1536, 8,16},
3451 { 720, 480, 8,16},
3452 { 720, 576, 8,16},
3453 { 1280, 960, 8,16},
3454 { 800, 480, 8,16},
3455 { 1024, 576, 8,16},
3456 { 1280, 720, 8,16},
3457 { 856, 480, 8,16},
3458 { 1280, 768, 8,16},
3459 { 1400,1050, 8,16},
3460 { 1152, 864, 8,16}
3461};
3462
3463UCHAR XGI330_OutputSelect =0x40;
3464UCHAR XGI330_SoftSetting = 0x30;
3465UCHAR XGI330_SR07=0x18;
3466UCHAR XGI330New_SR15[8][8]={
3467{0x0,0x4,0x60,0x60},
3468{0xf,0xf,0xf,0xf},
3469{0xba,0xba,0xba,0xba},
3470{0xa9,0xa9,0xac,0xac},
3471{0xa0,0xa0,0xa0,0xa8},
3472{0x0,0x0,0x2,0x2},
3473{0x30,0x30,0x40,0x40},
3474{0x0,0xa5,0xfb,0xf6}
3475};
3476
3477UCHAR XGI330New_CR40[5][8]={
3478{0x77,0x77,0x44,0x44},
3479{0x77,0x77,0x44,0x44},
3480{0x0,0x0,0x0,0x0},
3481{0x5b,0x5b,0xab,0xab},
3482{0x0,0x0,0xf0,0xf8}
3483};
3484
3485UCHAR XGI330_CR49[]={0xaa,0x88};
3486UCHAR XGI330_SR1F=0x0;
3487UCHAR XGI330_SR21=0xa3;
3488UCHAR XGI330_650_SR21=0xa7;
3489UCHAR XGI330_SR22=0xfb;
3490UCHAR XGI330_SR23=0xf6;
3491UCHAR XGI330_SR24=0xd;
3492
3493UCHAR XGI660_SR21=0xa3;/* 2003.0312 */
3494UCHAR XGI660_SR22=0xf3;/* 2003.0312 */
3495
3496UCHAR XGI330_LVDS_SR32=0x00; /* ynlai for 650 LVDS */
3497UCHAR XGI330_LVDS_SR33=0x00; /* chiawen for 650 LVDS */
3498UCHAR XGI330_650_SR31=0x40;
3499UCHAR XGI330_650_SR33=0x04;
3500UCHAR XGI330_CRT2Data_1_2 = 0x0;
3501UCHAR XGI330_CRT2Data_4_D = 0x0;
3502UCHAR XGI330_CRT2Data_4_E = 0x0;
3503UCHAR XGI330_CRT2Data_4_10 = 0x80;
3504USHORT XGI330_RGBSenseData = 0xd1;
3505USHORT XGI330_VideoSenseData = 0xb9;
3506USHORT XGI330_YCSenseData = 0xb3;
3507USHORT XGI330_RGBSenseData2 = 0x0190; /*301b*/
3508USHORT XGI330_VideoSenseData2 = 0x0110;
3509USHORT XGI330_YCSenseData2 = 0x016B;
3510UCHAR XGI330_NTSCPhase[] = {0x21,0xed,0x8a,0x8};
3511UCHAR XGI330_PALPhase[] = {0x2a,0x5,0xd3,0x0};
3512UCHAR XGI330_NTSCPhase2[] = {0x21,0xF0,0x7B,0xD6};/*301b*/
3513UCHAR XGI330_PALPhase2[] = {0x2a,0x09,0x86,0xe9};
3514UCHAR XGI330_PALMPhase[] = {0x21,0xE4,0x2E,0x9B}; /*palmn*/
3515UCHAR XGI330_PALNPhase[] = {0x21,0xF4,0x3E,0xBA};
3516UCHAR XG40_I2CDefinition = 0x00 ;
3517UCHAR XG20_CR97 = 0x10 ;
3518
3519UCHAR XG21_DVOSetting = 0x00 ;
3520UCHAR XG21_CR2E = 0x00 ;
3521UCHAR XG21_CR2F = 0x00 ;
3522UCHAR XG21_CR46 = 0x00 ;
3523UCHAR XG21_CR47 = 0x00 ;
3524
3525UCHAR XG27_CR97 = 0xC1 ;
3526UCHAR XG27_SR36 = 0x30 ;
3527UCHAR XG27_CR8F = 0x0C ;
3528UCHAR XG27_CRD0[] = {0,0,0,0,0,0,0,0x82,0x00,0x66,0x01,0x00} ;
3529UCHAR XG27_CRDE[] = {0,0} ;
3530UCHAR XG27_SR40 = 0x04 ;
3531UCHAR XG27_SR41 = 0x00 ;
3532
3533UCHAR XGI330_CHTVVCLKUNTSC[]={0x00 };
3534
3535UCHAR XGI330_CHTVVCLKONTSC[]={0x00 };
3536
3537UCHAR XGI330_CHTVVCLKUPAL[]={0x00 };
3538
3539UCHAR XGI330_CHTVVCLKOPAL[]={0x00 };
3540
3541UCHAR XGI7007_CHTVVCLKUNTSC[]={CH7007TVVCLK30_2,
3542 CH7007TVVCLK30_2,
3543 CH7007TVVCLK30_2,
3544 CH7007TVVCLK30_2,
3545 CH7007TVVCLK28_1,
3546 CH7007TVVCLK47_8
3547 };
3548
3549UCHAR XGI7007_CHTVVCLKONTSC[]={CH7007TVVCLK26_4,
3550 CH7007TVVCLK26_4,
3551 CH7007TVVCLK26_4,
3552 CH7007TVVCLK26_4,
3553 CH7007TVVCLK24_6,
3554 CH7007TVVCLK43_6
3555 };
3556
3557UCHAR XGI7007_CHTVVCLKUPAL[]={CH7007TVVCLK31_5,
3558 CH7007TVVCLK31_5,
3559 CH7007TVVCLK31_5,
3560 CH7007TVVCLK31_5,
3561 CH7007TVVCLK26_2,
3562 CH7007TVVCLK39
3563 };
3564
3565UCHAR XGI7007_CHTVVCLKOPAL[]={CH7007TVVCLK31_5,
3566 CH7007TVVCLK31_5,
3567 CH7007TVVCLK31_5,
3568 CH7007TVVCLK31_5,
3569 CH7007TVVCLK26_2,
3570 CH7007TVVCLK36
3571 };
3572
3573XGI330_VCLKDataStruct XGI_CH7007VCLKData[]=
3574{
3575 { 0x60,0x36,30}, /* 0 30.2 MHZ */
3576 { 0x40,0x4A,28}, /* 1 28.19 MHZ */
3577 { 0x9F,0x46,44}, /* 2 43.6 MHZ */
3578 { 0x97,0x2C,26}, /* 3 26.4 MHZ */
3579 { 0x44,0xE4,25}, /* 4 24.6 MHZ */
3580 { 0x7E,0x32,47}, /* 5 47.832 MHZ */
3581 { 0x8A,0x24,31}, /* 6 31.5 MHZ */
3582 { 0x97,0x2C,26}, /* 7 26.2 MHZ */
3583 { 0xCE,0x3C,39}, /* 8 39 MHZ */
3584 { 0x52,0x4A,36}, /* 9 36 MHZ */
3585 { 0xFF,0x00,0 } /* End mark */
3586};
3587
3588XGI330_VCLKDataStruct XGI_VCLKData[]=
3589{
3590 /* SR2B,SR2C,SR2D */
3591 { 0x1B,0xE1,25 },/* 00 (25.175MHz) */
3592
3593 { 0x4E,0xE4,28 },/* 01 (28.322MHz) */
3594
3595 { 0x57,0xE4,31 },/* 02 (31.500MHz) */
3596
3597 { 0xC3,0xC8,36 },/* 03 (36.000MHz) */
3598
3599 { 0x42,0xE2,40 },/* 04 (40.000MHz) */
3600
3601 { 0xFE,0xCD,43 },/* 05 (43.163MHz) */
3602
3603 { 0x5D,0xC4,44 },/* 06 (44.900MHz) */
3604
3605 { 0x52,0xE2,49 },/* 07 (49.500MHz) */
3606
3607 { 0x53,0xE2,50 },/* 08 (50.000MHz) */
3608
3609 { 0x74,0x67,52 },/* 09 (52.406MHz) */
3610
3611 { 0x6D,0x66,56 },/* 0A (56.250MHz) */
3612
3613 { 0x6C,0xC3,65 },/* 0B (65.000MHz) */
3614
3615 { 0x46,0x44,67 },/* 0C (67.765MHz) */
3616
3617 { 0xB1,0x46,68 },/* 0D (68.179MHz) */
3618
3619 { 0xD3,0x4A,72 },/* 0E (72.852MHz) */
3620
3621 { 0x29,0x61,75 },/* 0F (75.000MHz) */
3622
3623 { 0x6E,0x46,76 },/* 10 (75.800MHz) */
3624
3625 { 0x2B,0x61,78 },/* 11 (78.750MHz) */
3626
3627 { 0x31,0x42,79 },/* 12 (79.411MHz) */
3628
3629 { 0xAB,0x44,83 },/* 13 (83.950MHz) */
3630
3631 { 0x46,0x25,84 },/* 14 (84.800MHz) */
3632
3633 { 0x78,0x29,86 },/* 15 (86.600MHz) */
3634
3635 { 0x62,0x44,94 },/* 16 (94.500MHz) */
3636
3637 { 0x2B,0x41,104 },/* 17 (104.998MHz) */
3638
3639 { 0x3A,0x23,105 },/* 18 (105.882MHz) */
3640
3641 { 0x70,0x44,108 },/* 19 (107.862MHz) */
3642
3643 { 0x3C,0x23,109 },/* 1A (109.175MHz) */
3644
3645 { 0x5E,0x43,113 },/* 1B (113.309MHz) */
3646
3647 { 0xBC,0x44,116 },/* 1C (116.406MHz) */
3648
3649 { 0xE0,0x46,132 },/* 1D (132.258MHz) */
3650
3651 { 0x54,0x42,135 },/* 1E (135.500MHz) */
3652
3653 { 0x9C,0x22,139 },/* 1F (139.275MHz) */
3654
3655 { 0x41,0x22,157 },/* 20 (157.500MHz) */
3656
3657 { 0x70,0x24,162 },/* 21 (161.793MHz) */
3658
3659 { 0x30,0x21,175 },/* 22 (175.000MHz) */
3660
3661 { 0x4E,0x22,189 },/* 23 (188.520MHz) */
3662
3663 { 0xDE,0x26,194 },/* 24 (194.400MHz) */
3664
3665 { 0x62,0x06,202 },/* 25 (202.500MHz) */
3666
3667 { 0x3F,0x03,229 },/* 26 (229.500MHz) */
3668
3669 { 0xB8,0x06,234 },/* 27 (233.178MHz) */
3670
3671 { 0x34,0x02,253 },/* 28 (252.699MHz) */
3672
3673 { 0x58,0x04,255 },/* 29 (254.817MHz) */
3674
3675 { 0x24,0x01,265 },/* 2A (265.728MHz) */
3676
3677 { 0x9B,0x02,267 },/* 2B (266.952MHz) */
3678
3679 { 0x70,0x05,270 },/* 2C (269.65567MHz) */
3680
3681 { 0x25,0x01,272 },/* 2D (272.04199MHz) */
3682
3683 { 0x9C,0x02,277 },/* 2E (277.015MHz) */
3684
3685 { 0x27,0x01,286 },/* 2F (286.359985MHz) */
3686
3687 { 0xB3,0x04,291 },/* 30 (291.13266MHz) */
3688
3689 { 0xBC,0x05,292 },/* 31 (291.766MHz) */
3690
3691 { 0xF6,0x0A,310 },/* 32 (309.789459MHz) */
3692
3693 { 0x95,0x01,315 },/* 33 (315.195MHz) */
3694
3695 { 0xF0,0x09,324 },/* 34 (323.586792MHz) */
3696
3697 { 0xFE,0x0A,331 },/* 35 (330.615631MHz) */
3698
3699 { 0xF3,0x09,332 },/* 36 (332.177612MHz) */
3700
3701 { 0x5E,0x03,340 },/* 37 (340.477MHz) */
3702
3703 { 0xE8,0x07,376 },/* 38 (375.847504MHz) */
3704
3705 { 0xDE, 0x06,389 },/* 39 (388.631439MHz) */
3706
3707 { 0x52,0x2A,54 },/* 3A (54.000MHz) */
3708
3709 { 0x52,0x6A,27 },/* 3B (27.000MHz) */
3710
3711 { 0x62,0x24,70 },/* 3C (70.874991MHz) */
3712
3713 { 0x62,0x64,70 },/* 3D (70.1048912MHz) */
3714
3715 { 0xA8,0x4C,30 },/* 3E (30.1048912MHz) */
3716
3717 { 0x20,0x26,33 },/* 3F (33.7499957MHz) */
3718
3719 { 0x31,0xc2,39 },/* 40 (39.77MHz) */
3720
3721 { 0x11,0x21,30 },/* 41 (30MHz) }// NTSC 1024X768 */
3722
3723 { 0x2E,0x48,25 },/* 42 (25.175MHz) }// ScaleLCD */
3724
3725 { 0x24,0x46,25 },/* 43 (25.175MHz) */
3726
3727 { 0x26,0x64,28 },/* 44 (28.322MHz) */
3728
3729 { 0x37,0x64,40 },/* 45 (40.000MHz) */
3730
3731 { 0xA1,0x42,108 },/* 46 (95.000MHz) }// QVGA */
3732
3733 { 0x37,0x61,100 },/* 47 (100.00MHz) */
3734
3735 { 0x78,0x27,108 },/* 48 (108.200MHz) */
3736
3737 { 0xBF,0xC8,35 },/* 49 (35.2MHz) */
3738
3739 { 0x66,0x43,123 },/* 4A (122.61Mhz) */
3740
3741 { 0x2C,0x61,80 },/* 4B (80.350Mhz) */
3742
3743 { 0x3B,0x61,108 },/* 4C (107.385Mhz) */
3744
3745
3746/* { 0x60,0x36,30 },// 4D (30.200MHz) }// No use
3747
3748 { 0x60,0x36,30 },// 4E (30.200MHz) }// No use
3749
3750 { 0x60,0x36,30 },// 4F (30.200MHz) }// No use
3751
3752 { 0x60,0x36,30 },// 50 (30.200MHz) }// CHTV
3753
3754 { 0x40,0x4A,28 },// 51 (28.190MHz)
3755
3756 { 0x9F,0x46,44 },// 52 (43.600MHz)
3757
3758 { 0x97,0x2C,26 },// 53 (26.400MHz)
3759
3760 { 0x44,0xE4,25 },// 54 (24.600MHz)
3761
3762 { 0x7E,0x32,47 },// 55 (47.832MHz)
3763
3764 { 0x8A,0x24,31 },// 56 (31.500MHz)
3765
3766 { 0x97,0x2C,26 },// 57 (26.200MHz)
3767
3768 { 0xCE,0x3C,39 },// 58 (39.000MHz)
3769
3770 { 0x52,0x4A,36 },// 59 (36.000MHz)
3771
3772*/
3773 { 0x69,0x61,191 }, /* 4D (190.96MHz ) */
3774 { 0x4F,0x22,192 }, /* 4E (192.069MHz) */
3775 { 0x28,0x26,322 }, /* 4F (322.273MHz) */
3776 { 0x5C,0x6B,27 }, /* 50 (27.74HMz) */
3777 { 0x57,0x24,126 }, /* 51 (125.999MHz) */
3778 { 0x5C,0x42,148 }, /* 52 (148.5MHz) */
3779 { 0x42,0x61,120 }, /* 53 (120.839MHz) */
3780 { 0x62,0x61,178 }, /* 54 (178.992MHz) */
3781 { 0x59,0x22,217 }, /* 55 (217.325MHz) */
3782 { 0x29,0x01,300 }, /* 56 (299.505Mhz) */
3783 { 0x52,0x63,74 }, /* 57 (74.25MHz) */
3784
3785
3786 { 0xFF,0x00,0 }/* End mark */
3787 } ;
3788
3789XGI330_VCLKDataStruct XGI_VBVCLKData[]=
3790{
3791 { 0x1B,0xE1,25 },/* 00 (25.175MHz) */
3792
3793 { 0x4E,0xE4,28 },/* 01 (28.322MHz) */
3794
3795 { 0x57,0xE4,31 },/* 02 (31.500MHz) */
3796
3797 { 0xC3,0xC8,36 },/* 03 (36.000MHz) */
3798
3799 { 0x42,0x47,40 },/* 04 (40.000MHz) */
3800
3801 { 0xFE,0xCD,43 },/* 05 (43.163MHz) */
3802
3803 { 0x5D,0xC4,44 },/* 06 (44.900MHz) */
3804
3805 { 0x52,0x47,49 },/* 07 (49.500MHz) */
3806
3807 { 0x53,0x47,50 },/* 08 (50.000MHz) */
3808
3809 { 0x74,0x67,52 },/* 09 (52.406MHz) */
3810
3811 { 0x6D,0x66,56 },/* 0A (56.250MHz) */
3812
3813 { 0x35,0x62,65 },/* 0B (65.000MHz) */
3814
3815 { 0x46,0x44,67 },/* 0C (67.765MHz) */
3816
3817 { 0xB1,0x46,68 },/* 0D (68.179MHz) */
3818
3819 { 0xD3,0x4A,72 },/* 0E (72.852MHz) */
3820
3821 { 0x29,0x61,75 },/* 0F (75.000MHz) */
3822
3823 { 0x6D,0x46,75 },/* 10 (75.800MHz) */
3824
3825 { 0x41,0x43,78 },/* 11 (78.750MHz) */
3826
3827 { 0x31,0x42,79 },/* 12 (79.411MHz) */
3828
3829 { 0xAB,0x44,83 },/* 13 (83.950MHz) */
3830
3831 { 0x46,0x25,84 },/* 14 (84.800MHz) */
3832
3833 { 0x78,0x29,86 },/* 15 (86.600MHz) */
3834
3835 { 0x62,0x44,94 },/* 16 (94.500MHz) */
3836
3837 { 0x2B,0x22,104 },/* 17 (104.998MHz) */
3838
3839 { 0x49,0x24,105 },/* 18 (105.882MHz) */
3840
3841 { 0xF8,0x2F,108 },/* 19 (108.279MHz) */
3842
3843 { 0x3C,0x23,109 },/* 1A (109.175MHz) */
3844
3845 { 0x5E,0x43,113 },/* 1B (113.309MHz) */
3846
3847 { 0xBC,0x44,116 },/* 1C (116.406MHz) */
3848
3849 { 0xE0,0x46,132 },/* 1D (132.258MHz) */
3850
3851 { 0xD4,0x28,135 },/* 1E (135.220MHz) */
3852
3853 { 0xEA,0x2A,139 },/* 1F (139.275MHz) */
3854
3855 { 0x41,0x22,157 },/* 20 (157.500MHz) */
3856
3857 { 0x70,0x24,162 },/* 21 (161.793MHz) */
3858
3859 { 0x30,0x21,175 },/* 22 (175.000MHz) */
3860
3861 { 0x4E,0x22,189 },/* 23 (188.520MHz) */
3862
3863 { 0xDE,0x26,194 },/* 24 (194.400MHz) */
3864
3865 { 0x70,0x07,202 },/* 25 (202.500MHz) */
3866
3867 { 0x3F,0x03,229 },/* 26 (229.500MHz) */
3868
3869 { 0xB8,0x06,234 },/* 27 (233.178MHz) */
3870
3871 { 0x34,0x02,253 },/* 28 (252.699997 MHz) */
3872
3873 { 0x58,0x04,255 },/* 29 (254.817MHz) */
3874
3875 { 0x24,0x01,265 },/* 2A (265.728MHz) */
3876
3877 { 0x9B,0x02,267 },/* 2B (266.952MHz) */
3878
3879 { 0x70,0x05,270 },/* 2C (269.65567 MHz) */
3880
3881 { 0x25,0x01,272 },/* 2D (272.041992 MHz) */
3882
3883 { 0x9C,0x02,277 },/* 2E (277.015MHz) */
3884
3885 { 0x27,0x01,286 },/* 2F (286.359985 MHz) */
3886
3887 { 0x3C,0x02,291 },/* 30 (291.132660 MHz) */
3888
3889 { 0xEF,0x0A,292 },/* 31 (291.766MHz) */
3890
3891 { 0xF6,0x0A,310 },/* 32 (309.789459 MHz) */
3892
3893 { 0x95,0x01,315 },/* 33 (315.195MHz) */
3894
3895 { 0xF0,0x09,324 },/* 34 (323.586792 MHz) */
3896
3897 { 0xFE,0x0A,331 },/* 35 (330.615631 MHz) */
3898
3899 { 0xF3,0x09,332 },/* 36 (332.177612 MHz) */
3900
3901 { 0xEA,0x08,340 },/* 37 (340.477MHz) */
3902
3903 { 0xE8,0x07,376 },/* 38 (375.847504 MHz) */
3904
3905 { 0xDE,0x06,389 },/* 39 (388.631439 MHz) */
3906
3907 { 0x52,0x2A,54 },/* 3A (54.000MHz) */
3908
3909 { 0x52,0x6A,27 },/* 3B (27.000MHz) */
3910
3911
3912 { 0x62,0x24,70 },/* 3C (70.874991MHz) */
3913
3914
3915 { 0x62,0x64,70 },/* 3D (70.1048912MHz) */
3916
3917 { 0xA8,0x4C,30 },/* 3E (30.1048912MHz) */
3918
3919 { 0x20,0x26,33 },/* 3F (33.7499957MHz) */
3920
3921 { 0x31,0xc2,39 },/* 40 (39.77MHz) */
3922
3923 { 0x11,0x21,30 },/* 41 (30MHz) }// NTSC 1024X768 */
3924
3925 { 0x2E,0x48,25 },/* 42 (25.175MHz) }// ScaleLCD */
3926
3927 { 0x24,0x46,25 },/* 43 (25.175MHz) */
3928
3929 { 0x26,0x64,28 },/* 44 (28.322MHz) */
3930
3931 { 0x37,0x64,40 },/* 45 (40.000MHz) */
3932
3933 { 0xA1,0x42,108 },/* 46 (95.000MHz) }// QVGA */
3934
3935 { 0x37,0x61,100 },/* 47 (100.00MHz) */
3936
3937 { 0x78,0x27,108 },/* 48 (108.200MHz) */
3938
3939 { 0xBF,0xC8,35 },/* 49 (35.2MHz) */
3940
3941 { 0x66,0x43,123 },/* 4A (122.61Mhz) */
3942
3943 { 0x2C,0x61,80 },/* 4B (80.350Mhz) */
3944
3945 { 0x3B,0x61,108 },/* 4C (107.385Mhz) */
3946
3947/*
3948 { 0x60,0x36,30 },// 4D (30.200MHz) }// No use
3949
3950 { 0x60,0x36,30 },// 4E (30.200MHz) }// No use
3951
3952 { 0x60,0x36,30 },// 4F (30.200MHz) }// No use
3953
3954 { 0x60,0x36,30 },// 50 (30.200MHz) }// CHTV
3955
3956 { 0x40,0x4A,28 },// 51 (28.190MHz)
3957
3958 { 0x9F,0x46,44 },// 52 (43.600MHz)
3959
3960 { 0x97,0x2C,26 },// 53 (26.400MHz)
3961
3962 { 0x44,0xE4,25 },// 54 (24.600MHz)
3963
3964 { 0x7E,0x32,47 },// 55 (47.832MHz)
3965
3966 { 0x8A,0x24,31 },// 56 (31.500MHz)
3967
3968 { 0x97,0x2C,26 },// 57 (26.200MHz)
3969
3970 { 0xCE,0x3C,39 },// 58 (39.000MHz)
3971
3972 { 0x52,0x4A,36 },// 59 (36.000MHz)
3973*/
3974 { 0x69,0x61,191 }, /* 4D (190.96MHz ) */
3975 { 0x4F,0x22,192 }, /* 4E (192.069MHz) */
3976 { 0x28,0x26,322 }, /* 4F (322.273MHz) */
3977 { 0x5C,0x6B,27 }, /* 50 (27.74HMz) */
3978 { 0x57,0x24,126 }, /* 51 (125.999MHz) */
3979 { 0x5C,0x42,148 }, /* 52 (148.5MHz) */
3980 { 0x42,0x61,120 }, /* 53 (120.839MHz) */
3981 { 0x62,0x61,178 }, /* 54 (178.992MHz) */
3982 { 0x59,0x22,217 }, /* 55 (217.325MHz) */
3983 { 0x29,0x01,300 }, /* 56 (299.505Mhz) */
3984 { 0x52,0x63,74 }, /* 57 (74.25MHz) */
3985
3986
3987 { 0xFF,0x00,0 } /* End mark */
3988};
3989
3990UCHAR XGI660_TVDelayList[]=
3991{
3992 0x44, /* ; 0 ExtNTSCDelay */
3993 0x44, /* ; 1 StNTSCDelay */
3994 0x44, /* ; 2 ExtPALDelay */
3995 0x44, /* ; 3 StPALDelay */
3996 0x44, /* ; 4 ExtHiTVDelay(1080i) */
3997 0x44, /* ; 5 StHiTVDelay(1080i) */
3998 0x44, /* ; 6 ExtYPbPrDelay(525i) */
3999 0x44, /* ; 7 StYPbPrDealy(525i) */
4000 0x44, /* ; 8 ExtYPbPrDelay(525p) */
4001 0x44, /* ; 9 StYPbPrDealy(525p) */
4002 0x44, /* ; A ExtYPbPrDelay(750p) */
4003 0x44 /* ; B StYPbPrDealy(750p) */
4004};
4005
4006UCHAR XGI660_TVDelayList2[]=
4007{
4008 0x44, /* ; 0 ExtNTSCDelay */
4009 0x44, /* ; 1 StNTSCDelay */
4010 0x44, /* ; 2 ExtPALDelay */
4011 0x44, /* ; 3 StPALDelay */
4012 0x44, /* ; 4 ExtHiTVDelay */
4013 0x44, /* ; 5 StHiTVDelay */
4014 0x44, /* ; 6 ExtYPbPrDelay(525i) */
4015 0x44, /* ; 7 StYPbPrDealy(525i) */
4016 0x44, /* ; 8 ExtYPbPrDelay(525p) */
4017 0x44, /* ; 9 StYPbPrDealy(525p) */
4018 0x44, /* ; A ExtYPbPrDelay(750p) */
4019 0x44 /* ; B StYPbPrDealy(750p) */
4020};
4021
4022UCHAR XGI301TVDelayList[]=
4023{
4024 0x22, /* ; 0 ExtNTSCDelay */
4025 0x22, /* ; 1 StNTSCDelay */
4026 0x22, /* ; 2 ExtPALDelay */
4027 0x22, /* ; 3 StPALDelay */
4028 0x88, /* ; 4 ExtHiTVDelay(1080i) */
4029 0xBB, /* ; 5 StHiTVDelay(1080i) */
4030 0x22, /* ; 6 ExtYPbPrDelay(525i) */
4031 0x22, /* ; 7 StYPbPrDealy(525i) */
4032 0x22, /* ; 8 ExtYPbPrDelay(525p) */
4033 0x22, /* ; 9 StYPbPrDealy(525p) */
4034 0x22, /* ; A ExtYPbPrDelay(750p) */
4035 0x22 /* B StYPbPrDealy(750p) */
4036};
4037
4038UCHAR XGI301TVDelayList2[]=
4039{
4040 0x22, /* ; 0 ExtNTSCDelay */
4041 0x22, /* ; 1 StNTSCDelay */
4042 0x22, /* ; 2 ExtPALDelay */
4043 0x22, /* ; 3 StPALDelay */
4044 0x22, /* ; 4 ExtHiTVDelay */
4045 0x22, /* ; 5 StHiTVDelay */
4046 0x22, /* ; 6 ExtYPbPrDelay(525i) */
4047 0x22, /* ; 7 StYPbPrDealy(525i) */
4048 0x22, /* ; 8 ExtYPbPrDelay(525p) */
4049 0x22, /* ; 9 StYPbPrDealy(525p) */
4050 0x22, /* ; A ExtYPbPrDelay(750p) */
4051 0x22 /* ; B StYPbPrDealy(750p) */
4052};
4053
4054
4055UCHAR TVAntiFlickList[]=
4056{/* NTSCAntiFlicker */
4057 0x04, /* ; 0 Adaptive */
4058 0x00, /* ; 1 new anti-flicker ? */
4059/* PALAntiFlicker */
4060 0x04, /* ; 0 Adaptive */
4061 0x08, /* ; 1 new anti-flicker ? */
4062/* HiTVAntiFlicker */
4063 0x04, /* ; 0 ? */
4064 0x00 /* ; 1 new anti-flicker ? */
4065};
4066
4067
4068UCHAR TVEdgeList[]=
4069{
4070 0x00, /* ; 0 NTSC No Edge enhance */
4071 0x04, /* ; 1 NTSC Adaptive Edge enhance */
4072 0x00, /* ; 0 PAL No Edge enhance */
4073 0x04, /* ; 1 PAL Adaptive Edge enhance */
4074 0x00, /* ; 0 HiTV */
4075 0x00 /* ; 1 HiTV */
4076};
4077
4078ULONG TVPhaseList[]=
4079{ 0x08BAED21, /* ; 0 NTSC phase */
4080 0x00E3052A, /* ; 1 PAL phase */
4081 0x9B2EE421, /* ; 2 PAL-M phase */
4082 0xBA3EF421, /* ; 3 PAL-N phase */
4083 0xA7A28B1E, /* ; 4 NTSC 1024x768 */
4084 0xE00A831E, /* ; 5 PAL-M 1024x768 */
4085 0x00000000, /* ; 6 reserved */
4086 0x00000000, /* ; 7 reserved */
4087 0xD67BF021, /* ; 8 NTSC phase */
4088 0xE986092A, /* ; 9 PAL phase */
4089 0xA4EFE621, /* ; A PAL-M phase */
4090 0x4694F621, /* ; B PAL-N phase */
4091 0x8BDE711C, /* ; C NTSC 1024x768 */
4092 0xE00A831E /* ; D PAL-M 1024x768 */
4093};
4094
4095UCHAR NTSCYFilter1[]=
4096{
4097 0x00,0xF4,0x10,0x38 ,/* 0 : 320x text mode */
4098 0x00,0xF4,0x10,0x38 ,/* 1 : 360x text mode */
4099 0xEB,0x04,0x25,0x18 ,/* 2 : 640x text mode */
4100 0xF1,0x04,0x1F,0x18 ,/* 3 : 720x text mode */
4101 0x00,0xF4,0x10,0x38 ,/* 4 : 320x gra. mode */
4102 0xEB,0x04,0x25,0x18 ,/* 5 : 640x gra. mode */
4103 0xEB,0x15,0x25,0xF6 /* 6 : 800x gra. mode */
4104};
4105
4106UCHAR PALYFilter1[]=
4107{
4108 0x00,0xF4,0x10,0x38, /* 0 : 320x text mode */
4109 0x00,0xF4,0x10,0x38 ,/* 1 : 360x text mode */
4110 0xF1,0xF7,0x1F,0x32 ,/* 2 : 640x text mode */
4111 0xF3,0x00,0x1D,0x20 ,/* 3 : 720x text mode */
4112 0x00,0xF4,0x10,0x38 ,/* 4 : 320x gra. mode */
4113 0xF1,0xF7,0x1F,0x32 ,/* 5 : 640x gra. mode */
4114 0xFC,0xFB,0x14,0x2A /* 6 : 800x gra. mode */
4115};
4116
4117UCHAR PALMYFilter1[]=
4118{
4119 0x00,0xF4,0x10,0x38, /* 0 : 320x text mode */
4120 0x00,0xF4,0x10,0x38, /* 1 : 360x text mode */
4121 0xEB,0x04,0x10,0x18, /* 2 : 640x text mode */
4122 0xF7,0x06,0x19,0x14, /* 3 : 720x text mode */
4123 0x00,0xF4,0x10,0x38, /* 4 : 320x gra. mode */
4124 0xEB,0x04,0x25,0x18, /* 5 : 640x gra. mode */
4125 0xEB,0x15,0x25,0xF6, /* 6 : 800x gra. mode */
4126 0xFF,0xFF,0xFF,0xFF /* End of Table */
4127};
4128
4129UCHAR PALNYFilter1[]=
4130{
4131 0x00,0xF4,0x10,0x38, /* 0 : 320x text mode */
4132 0x00,0xF4,0x10,0x38, /* 1 : 360x text mode */
4133 0xEB,0x04,0x10,0x18, /* 2 : 640x text mode */
4134 0xF7,0x06,0x19,0x14, /* 3 : 720x text mode */
4135 0x00,0xF4,0x10,0x38, /* 4 : 320x gra. mode */
4136 0xEB,0x04,0x25,0x18, /* 5 : 640x gra. mode */
4137 0xEB,0x15,0x25,0xF6, /* 6 : 800x gra. mode */
4138 0xFF,0xFF,0xFF,0xFF /* End of Table */
4139};
4140
4141UCHAR NTSCYFilter2[]=
4142{
4143 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 0 : 320x text mode */
4144 0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 1 : 360x text mode */
4145 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 2 : 640x text mode */
4146 0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 3 : 720x text mode */
4147 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 4 : 320x gra. mode */
4148 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 5 : 640x gra. mode */
4149 0x01,0x01,0xFC,0xF8,0x08,0x26,0x38, /* 6 : 800x gra. mode */
4150 0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28 /* 7 : 1024xgra. mode */
4151};
4152
4153UCHAR PALYFilter2[]=
4154{
4155 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 0 : 320x text mode */
4156 0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 1 : 360x text mode */
4157 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 2 : 640x text mode */
4158 0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 3 : 720x text mode */
4159 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 4 : 320x gra. mode */
4160 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 5 : 640x gra. mode */
4161 0x01,0x01,0xFC,0xF8,0x08,0x26,0x38, /* 6 : 800x gra. mode */
4162 0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28 /* 7 : 1024xgra. mode */
4163};
4164
4165UCHAR PALMYFilter2[]=
4166{
4167 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 0 : 320x text mode */
4168 0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 1 : 360x text mode */
4169 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 2 : 640x text mode */
4170 0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 3 : 720x text mode */
4171 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 4 : 320x gra. mode */
4172 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 5 : 640x gra. mode */
4173 0x01,0x01,0xFC,0xF8,0x08,0x26,0x38, /* 6 : 800x gra. mode */
4174 0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28 /* 7 : 1024xgra. mode */
4175};
4176
4177UCHAR PALNYFilter2[]=
4178{
4179 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 0 : 320x text mode */
4180 0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 1 : 360x text mode */
4181 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 2 : 640x text mode */
4182 0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 3 : 720x text mode */
4183 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 4 : 320x gra. mode */
4184 0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 5 : 640x gra. mode */
4185 0x01,0x01,0xFC,0xF8,0x08,0x26,0x38, /* 6 : 800x gra. mode */
4186 0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28 /* 7 : 1024xgra. mode */
4187};
4188
4189UCHAR XGI_NTSC1024AdjTime[]=
4190{
4191 0xa7,0x07,0xf2,0x6e,0x17,0x8b,0x73,0x53,
4192 0x13,0x40,0x34,0xF4,0x63,0xBB,0xCC,0x7A,
4193 0x58,0xe4,0x73,0xd0,0x13
4194};
4195
4196XGI301C_Tap4TimingStruct HiTVTap4Timing[]=
4197{
4198 {0,{
4199 0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F, /* ; C0-C7 */
4200 0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, /* ; C8-CF */
4201 0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E, /* ; D0-D7 */
4202 0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, /* ; D8-DF */
4203 0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C, /* ; E0-E7 */
4204 0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C, /* ; EA-EF */
4205 0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C, /* ; F0-F7 */
4206 0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E /* ; F8-FF */
4207 }
4208 }
4209};
4210
4211XGI301C_Tap4TimingStruct EnlargeTap4Timing[]=
4212{
4213 {0,{
4214 0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F, /* ; C0-C7 */
4215 0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, /* ; C8-CF */
4216 0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E, /* ; D0-D7 */
4217 0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, /* ; D8-DF */
4218 0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C, /* ; E0-E7 */
4219 0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C, /* ; EA-EF */
4220 0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C, /* ; F0-F7 */
4221 0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E /* ; F8-FF */
4222 }
4223 }
4224};
4225
4226XGI301C_Tap4TimingStruct NoScaleTap4Timing[]=
4227{
4228 {0,{
4229 0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F, /* ; C0-C7 */
4230 0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, /* ; C8-CF */
4231 0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E, /* ; D0-D7 */
4232 0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, /* ; D8-DF */
4233 0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C, /* ; E0-E7 */
4234 0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C, /* ; EA-EF */
4235 0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C, /* ; F0-F7 */
4236 0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E /* ; F8-FF */
4237 }
4238 }
4239};
4240
4241XGI301C_Tap4TimingStruct PALTap4Timing[]=
4242{
4243 {600, {
4244 0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E, /* ; C0-C7 */
4245 0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D, /* ; C8-CF */
4246 0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C, /* ; D0-D7 */
4247 0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D, /* ; D8-DF */
4248 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E, /* ; E0-E7 */
4249 0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E, /* ; EA-EF */
4250 0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01, /* ; F0-F7 */
4251 0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04 /* ; F8-FF */
4252 }
4253 },
4254 {768, {
4255 0x08,0x12,0x08,0x7E,0x07,0x12,0x09,0x7E, /* ; C0-C7 */
4256 0x06,0x12,0x0A,0x7E,0x05,0x11,0x0B,0x7F, /* ; C8-CF */
4257 0x04,0x11,0x0C,0x7F,0x03,0x11,0x0C,0x00, /* ; D0-D7 */
4258 0x03,0x10,0x0D,0x00,0x02,0x0F,0x0E,0x01, /* ; D8-DF */
4259 0x01,0x0F,0x0F,0x01,0x01,0x0E,0x0F,0x02, /* ; E0-E7 */
4260 0x00,0x0D,0x10,0x03,0x7F,0x0C,0x11,0x04, /* ; EA-EF */
4261 0x7F,0x0C,0x11,0x04,0x7F,0x0B,0x11,0x05, /* ; F0-F7 */
4262 0x7E,0x0A,0x12,0x06,0x7E,0x09,0x12,0x07 /* ; F8-FF */
4263 }
4264 },
4265 {0xFFFF,
4266 {
4267 0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E, /* ; C0-C7 */
4268 0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D, /* ; C8-CF */
4269 0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D, /* ; D0-D7 */
4270 0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C, /* ; D8-DF */
4271 0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D, /* ; E0-E7 */
4272 0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x18,0x7F, /* ; EA-EF */
4273 0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00, /* ; F0-F7 */
4274 0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1B,0x02 /* ; F8-FF */
4275 }
4276 }
4277};
4278
4279XGI301C_Tap4TimingStruct NTSCTap4Timing[]=
4280{
4281 {480, {
4282 0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D, /* ; C0-C7 */
4283 0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D, /* ; C8-CF */
4284 0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C, /* ; D0-D7 */
4285 0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C, /* ; D8-DF */
4286 0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D, /* ; E0-E7 */
4287 0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E, /* ; EA-EF */
4288 0x7D,0x0C,0x19,0x7E,0x7D,0x0A,0x19,0x00, /* ; F0-F7 */
4289 0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02 /* ; F8-FF */
4290 }
4291 },
4292 {600, {
4293 0x07,0x14,0x07,0x7E,0x06,0x14,0x09,0x7D, /* ; C0-C7 */
4294 0x05,0x14,0x0A,0x7D,0x04,0x13,0x0B,0x7E, /* ; C8-CF */
4295 0x03,0x13,0x0C,0x7E,0x02,0x12,0x0D,0x7F, /* ; D0-D7 */
4296 0x01,0x12,0x0E,0x7F,0x01,0x11,0x0F,0x7F, /* ; D8-DF */
4297 0x01,0x10,0x10,0x00,0x7F,0x0F,0x11,0x01, /* ; E0-E7 */
4298 0x7F,0x0E,0x12,0x01,0x7E,0x0D,0x12,0x03, /* ; EA-EF */
4299 0x7E,0x0C,0x13,0x03,0x7E,0x0B,0x13,0x04, /* ; F0-F7 */
4300 0x7E,0x0A,0x14,0x04,0x7D,0x09,0x14,0x06 /* ; F8-FF */
4301 }
4302 },
4303 {0xFFFF,
4304 {
4305 0x09,0x0F,0x09,0x7F,0x08,0x0F,0x09,0x00, /* ; C0-C7 */
4306 0x07,0x0F,0x0A,0x00,0x06,0x0F,0x0A,0x01, /* ; C8-CF */
4307 0x06,0x0E,0x0B,0x01,0x05,0x0E,0x0B,0x02, /* ; D0-D7 */
4308 0x04,0x0E,0x0C,0x02,0x04,0x0D,0x0C,0x03, /* ; D8-DF */
4309 0x03,0x0D,0x0D,0x03,0x02,0x0C,0x0D,0x05, /* ; E0-E7 */
4310 0x02,0x0C,0x0E,0x04,0x01,0x0B,0x0E,0x06, /* ; EA-EF */
4311 0x01,0x0B,0x0E,0x06,0x00,0x0A,0x0F,0x07, /* ; F0-F7 */
4312 0x00,0x0A,0x0F,0x07,0x00,0x09,0x0F,0x08 /* ; F8-FF */
4313 }
4314 }
4315};
4316
4317XGI301C_Tap4TimingStruct YPbPr525pTap4Timing[]=
4318{
4319 {480, {
4320 0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D, /* ; C0-C7 */
4321 0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D, /* ; C8-CF */
4322 0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C, /* ; D0-D7 */
4323 0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C, /* ; D8-DF */
4324 0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D, /* ; E0-E7 */
4325 0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E, /* ; EA-EF */
4326 0x7D,0x0C,0x19,0x7E,0x7D,0x0A,0x19,0x00, /* ; F0-F7 */
4327 0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02 /* ; F8-FF */
4328 }
4329 },
4330 {600, {
4331 0x07,0x14,0x07,0x7E,0x06,0x14,0x09,0x7D, /* ; C0-C7 */
4332 0x05,0x14,0x0A,0x7D,0x04,0x13,0x0B,0x7E, /* ; C8-CF */
4333 0x03,0x13,0x0C,0x7E,0x02,0x12,0x0D,0x7F, /* ; D0-D7 */
4334 0x01,0x12,0x0E,0x7F,0x01,0x11,0x0F,0x7F, /* ; D8-DF */
4335 0x01,0x10,0x10,0x00,0x7F,0x0F,0x11,0x01, /* ; E0-E7 */
4336 0x7F,0x0E,0x12,0x01,0x7E,0x0D,0x12,0x03, /* ; EA-EF */
4337 0x7E,0x0C,0x13,0x03,0x7E,0x0B,0x13,0x04, /* ; F0-F7 */
4338 0x7E,0x0A,0x14,0x04,0x7D,0x09,0x14,0x06 /* ; F8-FF */
4339 }
4340 },
4341 {0xFFFF,
4342 {
4343 0x09,0x0F,0x09,0x7F,0x08,0x0F,0x09,0x00, /* ; C0-C7 */
4344 0x07,0x0F,0x0A,0x00,0x06,0x0F,0x0A,0x01, /* ; C8-CF */
4345 0x06,0x0E,0x0B,0x01,0x05,0x0E,0x0B,0x02, /* ; D0-D7 */
4346 0x04,0x0E,0x0C,0x02,0x04,0x0D,0x0C,0x03, /* ; D8-DF */
4347 0x03,0x0D,0x0D,0x03,0x02,0x0C,0x0D,0x05, /* ; E0-E7 */
4348 0x02,0x0C,0x0E,0x04,0x01,0x0B,0x0E,0x06, /* ; EA-EF */
4349 0x01,0x0B,0x0E,0x06,0x00,0x0A,0x0F,0x07, /* ; F0-F7 */
4350 0x00,0x0A,0x0F,0x07,0x00,0x09,0x0F,0x08 /* ; F8-FF */
4351 }
4352 }
4353};
4354
4355XGI301C_Tap4TimingStruct YPbPr525iTap4Timing[]=
4356{
4357 {480, {
4358 0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D, /* ; C0-C7 */
4359 0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D, /* ; C8-CF */
4360 0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C, /* ; D0-D7 */
4361 0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C, /* ; D8-DF */
4362 0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D, /* ; E0-E7 */
4363 0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E, /* ; EA-EF */
4364 0x7D,0x0C,0x19,0x7E,0x7D,0x0A,0x19,0x00, /* ; F0-F7 */
4365 0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02 /* ; F8-FF */
4366 }
4367 },
4368 {600, {
4369 0x07,0x14,0x07,0x7E,0x06,0x14,0x09,0x7D, /* ; C0-C7 */
4370 0x05,0x14,0x0A,0x7D,0x04,0x13,0x0B,0x7E, /* ; C8-CF */
4371 0x03,0x13,0x0C,0x7E,0x02,0x12,0x0D,0x7F, /* ; D0-D7 */
4372 0x01,0x12,0x0E,0x7F,0x01,0x11,0x0F,0x7F, /* ; D8-DF */
4373 0x01,0x10,0x10,0x00,0x7F,0x0F,0x11,0x01, /* ; E0-E7 */
4374 0x7F,0x0E,0x12,0x01,0x7E,0x0D,0x12,0x03, /* ; EA-EF */
4375 0x7E,0x0C,0x13,0x03,0x7E,0x0B,0x13,0x04, /* ; F0-F7 */
4376 0x7E,0x0A,0x14,0x04,0x7D,0x09,0x14,0x06 /* ; F8-FF */
4377 }
4378 },
4379 {0xFFFF,
4380 {
4381 0x09,0x0F,0x09,0x7F,0x08,0x0F,0x09,0x00, /* ; C0-C7 */
4382 0x07,0x0F,0x0A,0x00,0x06,0x0F,0x0A,0x01, /* ; C8-CF */
4383 0x06,0x0E,0x0B,0x01,0x05,0x0E,0x0B,0x02, /* ; D0-D7 */
4384 0x04,0x0E,0x0C,0x02,0x04,0x0D,0x0C,0x03, /* ; D8-DF */
4385 0x03,0x0D,0x0D,0x03,0x02,0x0C,0x0D,0x05, /* ; E0-E7 */
4386 0x02,0x0C,0x0E,0x04,0x01,0x0B,0x0E,0x06, /* ; EA-EF */
4387 0x01,0x0B,0x0E,0x06,0x00,0x0A,0x0F,0x07, /* ; F0-F7 */
4388 0x00,0x0A,0x0F,0x07,0x00,0x09,0x0F,0x08 /* ; F8-FF */
4389 }
4390 }
4391};
4392
4393XGI301C_Tap4TimingStruct YPbPr750pTap4Timing[]=
4394{ {0xFFFF,
4395 {
4396 0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E, /* ; C0-C7 */
4397 0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D, /* ; C8-CF */
4398 0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C, /* ; D0-D7 */
4399 0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D, /* ; D8-DF */
4400 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E, /* ; E0-E7 */
4401 0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E, /* ; EA-EF */
4402 0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01, /* ; F0-F7 */
4403 0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04 /* F8-FF */
4404 }
4405 }
4406};
diff --git a/drivers/staging/xgifb/vb_util.c b/drivers/staging/xgifb/vb_util.c
new file mode 100644
index 00000000000..87531b49b73
--- /dev/null
+++ b/drivers/staging/xgifb/vb_util.c
@@ -0,0 +1,263 @@
1#include "osdef.h"
2#include "vb_def.h"
3#include "vgatypes.h"
4#include "vb_struct.h"
5
6#ifdef LINUX_KERNEL
7#include "XGIfb.h"
8#include <asm/io.h>
9#include <linux/types.h>
10#endif
11
12#ifdef TC
13#include <stdio.h>
14#include <string.h>
15#include <conio.h>
16#include <dos.h>
17#endif
18
19#ifdef WIN2000
20#include <dderror.h>
21#include <devioctl.h>
22#include <miniport.h>
23#include <ntddvdeo.h>
24#include <video.h>
25
26#include "xgiv.h"
27#include "dd_i2c.h"
28#include "tools.h"
29#endif
30
31#ifdef LINUX_XF86
32#include "xf86.h"
33#include "xf86PciInfo.h"
34#include "xgi.h"
35#include "xgi_regs.h"
36#endif
37
38
39
40
41void XGINew_SetReg1( ULONG , USHORT , USHORT ) ;
42void XGINew_SetReg2( ULONG , USHORT , USHORT ) ;
43void XGINew_SetReg3( ULONG , USHORT ) ;
44void XGINew_SetReg4( ULONG , ULONG ) ;
45UCHAR XGINew_GetReg1( ULONG , USHORT) ;
46UCHAR XGINew_GetReg2( ULONG ) ;
47ULONG XGINew_GetReg3( ULONG ) ;
48void XGINew_ClearDAC( PUCHAR ) ;
49void XGINew_SetRegANDOR(ULONG Port,USHORT Index,USHORT DataAND,USHORT DataOR);
50void XGINew_SetRegOR(ULONG Port,USHORT Index,USHORT DataOR);
51void XGINew_SetRegAND(ULONG Port,USHORT Index,USHORT DataAND);
52
53
54/* --------------------------------------------------------------------- */
55/* Function : XGINew_SetReg1 */
56/* Input : */
57/* Output : */
58/* Description : SR CRTC GR */
59/* --------------------------------------------------------------------- */
60void XGINew_SetReg1( ULONG port , USHORT index , USHORT data )
61{
62#ifdef LINUX_XF86
63 OutPortByte( ( PUCHAR )(ULONG)port , index ) ;
64 OutPortByte( ( PUCHAR )(ULONG)port + 1 , data ) ;
65#else
66 OutPortByte( port , index ) ;
67 OutPortByte( port + 1 , data ) ;
68#endif
69}
70
71
72/* --------------------------------------------------------------------- */
73/* Function : XGINew_SetReg2 */
74/* Input : */
75/* Output : */
76/* Description : AR( 3C0 ) */
77/* --------------------------------------------------------------------- */
78/*void XGINew_SetReg2( ULONG port , USHORT index , USHORT data )
79{
80 InPortByte( ( PUCHAR )port + 0x3da - 0x3c0 ) ;
81 OutPortByte( XGINew_P3c0 , index ) ;
82 OutPortByte( XGINew_P3c0 , data ) ;
83 OutPortByte( XGINew_P3c0 , 0x20 ) ;
84}*/
85
86
87/* --------------------------------------------------------------------- */
88/* Function : */
89/* Input : */
90/* Output : */
91/* Description : */
92/* --------------------------------------------------------------------- */
93void XGINew_SetReg3( ULONG port , USHORT data )
94{
95 OutPortByte( port , data ) ;
96}
97
98
99/* --------------------------------------------------------------------- */
100/* Function : XGINew_SetReg4 */
101/* Input : */
102/* Output : */
103/* Description : */
104/* --------------------------------------------------------------------- */
105void XGINew_SetReg4( ULONG port , ULONG data )
106{
107 OutPortLong( port , data ) ;
108}
109
110
111/* --------------------------------------------------------------------- */
112/* Function : XGINew_GetReg1 */
113/* Input : */
114/* Output : */
115/* Description : */
116/* --------------------------------------------------------------------- */
117UCHAR XGINew_GetReg1( ULONG port , USHORT index )
118{
119 UCHAR data ;
120
121#ifdef LINUX_XF86
122 OutPortByte( ( PUCHAR )(ULONG)port , index ) ;
123 data = InPortByte( ( PUCHAR )(ULONG)port + 1 ) ;
124#else
125 OutPortByte( port , index ) ;
126 data = InPortByte( port + 1 ) ;
127#endif
128
129 return( data ) ;
130}
131
132
133/* --------------------------------------------------------------------- */
134/* Function : XGINew_GetReg2 */
135/* Input : */
136/* Output : */
137/* Description : */
138/* --------------------------------------------------------------------- */
139UCHAR XGINew_GetReg2( ULONG port )
140{
141 UCHAR data ;
142
143 data = InPortByte( port ) ;
144
145 return( data ) ;
146}
147
148
149/* --------------------------------------------------------------------- */
150/* Function : XGINew_GetReg3 */
151/* Input : */
152/* Output : */
153/* Description : */
154/* --------------------------------------------------------------------- */
155ULONG XGINew_GetReg3( ULONG port )
156{
157 ULONG data ;
158
159 data = InPortLong( port ) ;
160
161 return( data ) ;
162}
163
164
165
166/* --------------------------------------------------------------------- */
167/* Function : XGINew_SetRegANDOR */
168/* Input : */
169/* Output : */
170/* Description : */
171/* --------------------------------------------------------------------- */
172void XGINew_SetRegANDOR( ULONG Port , USHORT Index , USHORT DataAND , USHORT DataOR )
173{
174 USHORT temp ;
175
176 temp = XGINew_GetReg1( Port , Index ) ; /* XGINew_Part1Port index 02 */
177 temp = ( temp & ( DataAND ) ) | DataOR ;
178 XGINew_SetReg1( Port , Index , temp ) ;
179}
180
181
182/* --------------------------------------------------------------------- */
183/* Function : XGINew_SetRegAND */
184/* Input : */
185/* Output : */
186/* Description : */
187/* --------------------------------------------------------------------- */
188void XGINew_SetRegAND(ULONG Port,USHORT Index,USHORT DataAND)
189{
190 USHORT temp ;
191
192 temp = XGINew_GetReg1( Port , Index ) ; /* XGINew_Part1Port index 02 */
193 temp &= DataAND ;
194 XGINew_SetReg1( Port , Index , temp ) ;
195}
196
197
198/* --------------------------------------------------------------------- */
199/* Function : XGINew_SetRegOR */
200/* Input : */
201/* Output : */
202/* Description : */
203/* --------------------------------------------------------------------- */
204void XGINew_SetRegOR( ULONG Port , USHORT Index , USHORT DataOR )
205{
206 USHORT temp ;
207
208 temp = XGINew_GetReg1( Port , Index ) ; /* XGINew_Part1Port index 02 */
209 temp |= DataOR ;
210 XGINew_SetReg1( Port , Index , temp ) ;
211}
212
213
214/* --------------------------------------------------------------------- */
215/* Function : NewDelaySecond */
216/* Input : */
217/* Output : */
218/* Description : */
219/* --------------------------------------------------------------------- */
220void NewDelaySeconds( int seconds )
221{
222#ifdef WIN2000
223 int j ;
224#endif
225 int i ;
226
227
228 for( i = 0 ; i < seconds ; i++ )
229 {
230#ifdef TC
231 delay( 1000 ) ;
232#endif
233
234#ifdef WIN2000
235
236 for ( j = 0 ; j < 20000 ; j++ )
237 VideoPortStallExecution( 50 ) ;
238#endif
239
240#ifdef WINCE_HEADER
241#endif
242
243#ifdef LINUX_KERNEL
244#endif
245 }
246}
247
248
249/* --------------------------------------------------------------------- */
250/* Function : Newdebugcode */
251/* Input : */
252/* Output : */
253/* Description : */
254/* --------------------------------------------------------------------- */
255void Newdebugcode( UCHAR code )
256{
257// OutPortByte ( 0x80 , code ) ;
258 /* OutPortByte ( 0x300 , code ) ; */
259 /* NewDelaySeconds( 0x3 ) ; */
260}
261
262
263
diff --git a/drivers/staging/xgifb/vb_util.h b/drivers/staging/xgifb/vb_util.h
new file mode 100644
index 00000000000..91779d8cfdc
--- /dev/null
+++ b/drivers/staging/xgifb/vb_util.h
@@ -0,0 +1,15 @@
1#ifndef _VBUTIL_
2#define _VBUTIL_
3extern void NewDelaySeconds( int );
4extern void Newdebugcode( UCHAR );
5extern void XGINew_SetReg1(ULONG, USHORT, USHORT);
6extern void XGINew_SetReg3(ULONG, USHORT);
7extern UCHAR XGINew_GetReg1(ULONG, USHORT);
8extern UCHAR XGINew_GetReg2(ULONG);
9extern void XGINew_SetReg4(ULONG, ULONG);
10extern ULONG XGINew_GetReg3(ULONG);
11extern void XGINew_SetRegOR(ULONG Port,USHORT Index,USHORT DataOR);
12extern void XGINew_SetRegAND(ULONG Port,USHORT Index,USHORT DataAND);
13extern void XGINew_SetRegANDOR(ULONG Port,USHORT Index,USHORT DataAND,USHORT DataOR);
14#endif
15
diff --git a/drivers/staging/xgifb/vgatypes.h b/drivers/staging/xgifb/vgatypes.h
new file mode 100644
index 00000000000..295ea860ae4
--- /dev/null
+++ b/drivers/staging/xgifb/vgatypes.h
@@ -0,0 +1,325 @@
1
2#ifndef _VGATYPES_
3#define _VGATYPES_
4
5#include "osdef.h"
6
7#ifdef LINUX_XF86
8#include "xf86Version.h"
9#include "xf86Pci.h"
10#endif
11
12#ifdef LINUX_KERNEL /* We don't want the X driver to depend on kernel source */
13#include <linux/ioctl.h>
14#endif
15
16#ifndef FALSE
17#define FALSE 0
18#endif
19
20#ifndef TRUE
21#define TRUE 1
22#endif
23
24#ifndef NULL
25#define NULL 0
26#endif
27
28#ifndef CHAR
29typedef char CHAR;
30#endif
31
32#ifndef SHORT
33typedef short SHORT;
34#endif
35
36#ifndef LONG
37typedef long LONG;
38#endif
39
40#ifndef UCHAR
41typedef unsigned char UCHAR;
42#endif
43
44#ifndef USHORT
45typedef unsigned short USHORT;
46#endif
47
48#ifndef ULONG
49typedef unsigned long ULONG;
50#endif
51
52#ifndef PUCHAR
53typedef UCHAR *PUCHAR;
54#endif
55
56#ifndef PUSHORT
57typedef USHORT *PUSHORT;
58#endif
59
60#ifndef PLONGU
61typedef ULONG *PULONG;
62#endif
63
64#ifndef VOID
65typedef void VOID;
66#endif
67
68#ifndef PVOID
69typedef void *PVOID;
70#endif
71
72#ifndef BOOLEAN
73typedef UCHAR BOOLEAN;
74#endif
75/*
76#ifndef bool
77typedef UCHAR bool;
78#endif
79*/
80#ifdef LINUX_KERNEL
81typedef unsigned long XGIIOADDRESS;
82#endif
83
84#ifdef LINUX_XF86
85#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,0,0,0)
86typedef unsigned char IOADDRESS;
87typedef unsigned char XGIIOADDRESS;
88#else
89typedef IOADDRESS XGIIOADDRESS;
90#endif
91#endif
92
93#ifndef VBIOS_VER_MAX_LENGTH
94#define VBIOS_VER_MAX_LENGTH 4
95#endif
96
97#ifndef WIN2000
98
99#ifndef LINUX_KERNEL /* For the linux kernel, this is defined in xgifb.h */
100#ifndef XGI_CHIP_TYPE
101typedef enum _XGI_CHIP_TYPE {
102 XGI_VGALegacy = 0,
103#ifdef LINUX_XF86
104 XGI_530,
105 XGI_OLD,
106#endif
107 XGI_300,
108 XGI_630,
109 XGI_640,
110 XGI_315H,
111 XGI_315,
112 XGI_315PRO,
113 XGI_550,
114 XGI_650,
115 XGI_650M,
116 XGI_740,
117 XGI_330,
118 XGI_661,
119 XGI_660,
120 XGI_760,
121 XG40 = 32,
122 XG41,
123 XG42,
124 XG45,
125 XG20 = 48,
126 XG21,
127 XG27,
128 MAX_XGI_CHIP
129} XGI_CHIP_TYPE;
130#endif
131#endif
132
133#ifndef XGI_VB_CHIP_TYPE
134typedef enum _XGI_VB_CHIP_TYPE {
135 VB_CHIP_Legacy = 0,
136 VB_CHIP_301,
137 VB_CHIP_301B,
138 VB_CHIP_301LV,
139 VB_CHIP_302,
140 VB_CHIP_302B,
141 VB_CHIP_302LV,
142 VB_CHIP_301C,
143 VB_CHIP_302ELV,
144 VB_CHIP_UNKNOWN, /* other video bridge or no video bridge */
145 MAX_VB_CHIP
146} XGI_VB_CHIP_TYPE;
147#endif
148
149#ifndef XGI_LCD_TYPE
150typedef enum _XGI_LCD_TYPE {
151 LCD_INVALID = 0,
152 LCD_320x480, /* FSTN, DSTN */
153 LCD_640x480,
154 LCD_640x480_2, /* FSTN, DSTN */
155 LCD_640x480_3, /* FSTN, DSTN */
156 LCD_800x600,
157 LCD_848x480,
158 LCD_1024x600,
159 LCD_1024x768,
160 LCD_1152x768,
161 LCD_1152x864,
162 LCD_1280x720,
163 LCD_1280x768,
164 LCD_1280x800,
165 LCD_1280x960,
166 LCD_1280x1024,
167 LCD_1400x1050,
168 LCD_1600x1200,
169 LCD_1680x1050,
170 LCD_1920x1440,
171 LCD_2048x1536,
172 LCD_CUSTOM,
173 LCD_UNKNOWN
174} XGI_LCD_TYPE;
175#endif
176
177#endif /* not WIN2000 */
178
179#ifndef PXGI_DSReg
180typedef struct _XGI_DSReg
181{
182 UCHAR jIdx;
183 UCHAR jVal;
184} XGI_DSReg, *PXGI_DSReg;
185#endif
186
187#ifndef XGI_HW_DEVICE_INFO
188
189typedef struct _XGI_HW_DEVICE_INFO XGI_HW_DEVICE_INFO, *PXGI_HW_DEVICE_INFO;
190
191typedef BOOLEAN (*PXGI_QUERYSPACE) (PXGI_HW_DEVICE_INFO, ULONG, ULONG, ULONG *);
192
193struct _XGI_HW_DEVICE_INFO
194{
195 ULONG ulExternalChip; /* NO VB or other video bridge*/
196 /* if ujVBChipID = VB_CHIP_UNKNOWN, */
197#ifdef LINUX_XF86
198 PCITAG PciTag; /* PCI Tag */
199#endif
200
201 PUCHAR pjVirtualRomBase; /* ROM image */
202
203 BOOLEAN UseROM; /* Use the ROM image if provided */
204
205 PVOID pDevice;
206
207 PUCHAR pjVideoMemoryAddress;/* base virtual memory address */
208 /* of Linear VGA memory */
209
210 ULONG ulVideoMemorySize; /* size, in bytes, of the memory on the board */
211
212 PUCHAR pjIOAddress; /* base I/O address of VGA ports (0x3B0) */
213
214 PUCHAR pjCustomizedROMImage;
215
216 PUCHAR pj2ndVideoMemoryAddress;
217 ULONG ul2ndVideoMemorySize;
218
219 PUCHAR pj2ndIOAddress;
220/*#ifndef WIN2000
221 XGIIOADDRESS pjIOAddress; // base I/O address of VGA ports (0x3B0)
222#endif */
223 UCHAR jChipType; /* Used to Identify Graphics Chip */
224 /* defined in the data structure type */
225 /* "XGI_CHIP_TYPE" */
226
227 UCHAR jChipRevision; /* Used to Identify Graphics Chip Revision */
228
229 UCHAR ujVBChipID; /* the ID of video bridge */
230 /* defined in the data structure type */
231 /* "XGI_VB_CHIP_TYPE" */
232
233 BOOLEAN bNewScratch;
234
235 ULONG ulCRT2LCDType; /* defined in the data structure type */
236
237 ULONG usExternalChip; /* NO VB or other video bridge (other than */
238 /* video bridge) */
239
240 BOOLEAN bIntegratedMMEnabled;/* supporting integration MM enable */
241
242 BOOLEAN bSkipDramSizing; /* True: Skip video memory sizing. */
243
244 BOOLEAN bSkipSense;
245
246 BOOLEAN bIsPowerSaving; /* True: XGIInit() is invoked by power management,
247 otherwise by 2nd adapter's initialzation */
248
249 PXGI_DSReg pSR; /* restore SR registers in initial function. */
250 /* end data :(idx, val) = (FF, FF). */
251 /* Note : restore SR registers if */
252 /* bSkipDramSizing = TRUE */
253
254 PXGI_DSReg pCR; /* restore CR registers in initial function. */
255 /* end data :(idx, val) = (FF, FF) */
256 /* Note : restore cR registers if */
257 /* bSkipDramSizing = TRUE */
258/*
259#endif
260*/
261
262 PXGI_QUERYSPACE pQueryVGAConfigSpace;
263
264 PXGI_QUERYSPACE pQueryNorthBridgeSpace;
265
266 UCHAR szVBIOSVer[VBIOS_VER_MAX_LENGTH];
267
268};
269#endif
270
271/* Addtional IOCTL for communication xgifb <> X driver */
272/* If changing this, xgifb.h must also be changed (for xgifb) */
273
274#ifdef LINUX_XF86 /* We don't want the X driver to depend on the kernel source */
275
276/* ioctl for identifying and giving some info (esp. memory heap start) */
277#define XGIFB_GET_INFO 0x80046ef8 /* Wow, what a terrible hack... */
278
279/* Structure argument for XGIFB_GET_INFO ioctl */
280typedef struct _XGIFB_INFO xgifb_info, *pxgifb_info;
281
282struct _XGIFB_INFO {
283 CARD32 xgifb_id; /* for identifying xgifb */
284#ifndef XGIFB_ID
285#define XGIFB_ID 0x53495346 /* Identify myself with 'XGIF' */
286#endif
287 CARD32 chip_id; /* PCI ID of detected chip */
288 CARD32 memory; /* video memory in KB which xgifb manages */
289 CARD32 heapstart; /* heap start (= xgifb "mem" argument) in KB */
290 CARD8 fbvidmode; /* current xgifb mode */
291
292 CARD8 xgifb_version;
293 CARD8 xgifb_revision;
294 CARD8 xgifb_patchlevel;
295
296 CARD8 xgifb_caps; /* xgifb's capabilities */
297
298 CARD32 xgifb_tqlen; /* turbo queue length (in KB) */
299
300 CARD32 xgifb_pcibus; /* The card's PCI ID */
301 CARD32 xgifb_pcislot;
302 CARD32 xgifb_pcifunc;
303
304 CARD8 xgifb_lcdpdc;
305
306 CARD8 xgifb_lcda;
307
308 CARD32 xgifb_vbflags;
309 CARD32 xgifb_currentvbflags;
310
311 CARD32 xgifb_scalelcd;
312 CARD32 xgifb_specialtiming;
313
314 CARD8 xgifb_haveemi;
315 CARD8 xgifb_emi30,xgifb_emi31,xgifb_emi32,xgifb_emi33;
316 CARD8 xgifb_haveemilcd;
317
318 CARD8 xgifb_lcdpdca;
319
320 CARD8 reserved[212]; /* for future use */
321};
322#endif
323
324#endif
325