Commit d7636e0b authored by apatard@mandriva.com's avatar apatard@mandriva.com Committed by Greg Kroah-Hartman

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: default avatarArnaud Patard <apatard@mandriva.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ad845636
......@@ -141,5 +141,7 @@ source "drivers/staging/ti-st/Kconfig"
source "drivers/staging/adis16255/Kconfig"
source "drivers/staging/xgifb/Kconfig"
endif # !STAGING_EXCLUDE_BUILD
endif # STAGING
......@@ -51,3 +51,4 @@ obj-$(CONFIG_CRYSTALHD) += crystalhd/
obj-$(CONFIG_CXT1E1) += cxt1e1/
obj-$(CONFIG_TI_ST) += ti-st/
obj-$(CONFIG_ADIS16255) += adis16255/
obj-$(CONFIG_FB_XGI) += xgifb/
config FB_XGI
tristate "XGI display support"
depends on FB && PCI
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
help
This driver supports notebooks with XGI Z7,Z9,Z11 PCI chips.
Say Y if you have such a graphics card.
To compile this driver as a module, choose M here: the
module will be called xgifb.ko
obj-$(CONFIG_FB_XGI) += xgifb.o
xgifb-objs := XGI_main_26.o XGI_accel.o vb_init.o vb_setmode.o vb_util.o vb_ext.o
This drivers still need a lot of work. I can list all cleanups to do but it's
going to be long. So, I'm writing "cleanups" and not the list.
Arnaud
TODO:
- clean ups
- fix build warnings when module
- sort out dup ids with SiS driver
- remove useless/wrong/unused #ifdef/code/...
- fix printk usages
- get rid of non-linux related stuff
Please send patches to:
Arnaud Patard <apatard@mandriva.com>
#ifndef _XGI_H
#define _XGI_H
#if 1
#define TWDEBUG(x)
#else
#define TWDEBUG(x) printk(KERN_INFO x "\n");
#endif
#endif
/*
* XGI 300/630/730/540/315/550/650/740 frame buffer driver
* for Linux kernels 2.4.x and 2.5.x
*
* 2D acceleration part
*
* Based on the X driver's XGI300_accel.c which is
* Copyright Xavier Ducoin <x.ducoin@lectra.com>
* Copyright 2002 by Thomas Winischhofer, Vienna, Austria
* and XGI310_accel.c which is
* Copyright 2002 by Thomas Winischhofer, Vienna, Austria
*
* Author: Thomas Winischhofer <thomas@winischhofer.net>
* (see http://www.winischhofer.net/
* for more information and updates)
*/
//#include <linux/config.h>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/tty.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/fb.h>
#include <linux/console.h>
#include <linux/selection.h>
#include <linux/ioport.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/vt_kern.h>
#include <linux/capability.h>
#include <linux/fs.h>
#include <linux/agp_backend.h>
#include <linux/types.h>
/*
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
#include <linux/XGIfb.h>
#else
#include <video/XGIfb.h>
#endif
*/
#include <asm/io.h>
#ifdef CONFIG_MTRR
#include <asm/mtrr.h>
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
#include <video/fbcon.h>
#include <video/fbcon-cfb8.h>
#include <video/fbcon-cfb16.h>
#include <video/fbcon-cfb24.h>
#include <video/fbcon-cfb32.h>
#endif
#include "osdef.h"
#include "vgatypes.h"
#include "vb_struct.h"
#include "XGIfb.h"
#include "XGI_accel.h"
extern struct video_info xgi_video_info;
extern int XGIfb_accel;
static const int XGIALUConv[] =
{
0x00, /* dest = 0; 0, GXclear, 0 */
0x88, /* dest &= src; DSa, GXand, 0x1 */
0x44, /* dest = src & ~dest; SDna, GXandReverse, 0x2 */
0xCC, /* dest = src; S, GXcopy, 0x3 */
0x22, /* dest &= ~src; DSna, GXandInverted, 0x4 */
0xAA, /* dest = dest; D, GXnoop, 0x5 */
0x66, /* dest = ^src; DSx, GXxor, 0x6 */
0xEE, /* dest |= src; DSo, GXor, 0x7 */
0x11, /* dest = ~src & ~dest; DSon, GXnor, 0x8 */
0x99, /* dest ^= ~src ; DSxn, GXequiv, 0x9 */
0x55, /* dest = ~dest; Dn, GXInvert, 0xA */
0xDD, /* dest = src|~dest ; SDno, GXorReverse, 0xB */
0x33, /* dest = ~src; Sn, GXcopyInverted, 0xC */
0xBB, /* dest |= ~src; DSno, GXorInverted, 0xD */
0x77, /* dest = ~src|~dest; DSan, GXnand, 0xE */
0xFF, /* dest = 0xFF; 1, GXset, 0xF */
};
/* same ROP but with Pattern as Source */
static const int XGIPatALUConv[] =
{
0x00, /* dest = 0; 0, GXclear, 0 */
0xA0, /* dest &= src; DPa, GXand, 0x1 */
0x50, /* dest = src & ~dest; PDna, GXandReverse, 0x2 */
0xF0, /* dest = src; P, GXcopy, 0x3 */
0x0A, /* dest &= ~src; DPna, GXandInverted, 0x4 */
0xAA, /* dest = dest; D, GXnoop, 0x5 */
0x5A, /* dest = ^src; DPx, GXxor, 0x6 */
0xFA, /* dest |= src; DPo, GXor, 0x7 */
0x05, /* dest = ~src & ~dest; DPon, GXnor, 0x8 */
0xA5, /* dest ^= ~src ; DPxn, GXequiv, 0x9 */
0x55, /* dest = ~dest; Dn, GXInvert, 0xA */
0xF5, /* dest = src|~dest ; PDno, GXorReverse, 0xB */
0x0F, /* dest = ~src; Pn, GXcopyInverted, 0xC */
0xAF, /* dest |= ~src; DPno, GXorInverted, 0xD */
0x5F, /* dest = ~src|~dest; DPan, GXnand, 0xE */
0xFF, /* dest = 0xFF; 1, GXset, 0xF */
};
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,34)
static const unsigned char myrops[] = {
3, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
};
#endif
/* 300 series */
#if 0
static void
XGI300Sync(void)
{
XGI300Idle
}
#endif
static void
XGI310Sync(void)
{
XGI310Idle
}
#if 0
static void
XGI300SetupForScreenToScreenCopy(int xdir, int ydir, int rop,
unsigned int planemask, int trans_color)
{
XGI300SetupDSTColorDepth(xgi_video_info.DstColor);
XGI300SetupSRCPitch(xgi_video_info.video_linelength)
XGI300SetupDSTRect(xgi_video_info.video_linelength, 0xFFF)
if(trans_color != -1) {
XGI300SetupROP(0x0A)
XGI300SetupSRCTrans(trans_color)
XGI300SetupCMDFlag(TRANSPARENT_BITBLT)
} else {
XGI300SetupROP(XGIALUConv[rop])
}
if(xdir > 0) {
XGI300SetupCMDFlag(X_INC)
}
if(ydir > 0) {
XGI300SetupCMDFlag(Y_INC)
}
}
static void
XGI300SubsequentScreenToScreenCopy(int src_x, int src_y, int dst_x, int dst_y,
int width, int height)
{
long srcbase, dstbase;
srcbase = dstbase = 0;
if (src_y >= 2048) {
srcbase = xgi_video_info.video_linelength * src_y;
src_y = 0;
}
if (dst_y >= 2048) {
dstbase = xgi_video_info.video_linelength * dst_y;
dst_y = 0;
}
XGI300SetupSRCBase(srcbase);
XGI300SetupDSTBase(dstbase);
if(!(xgi_video_info.CommandReg & X_INC)) {
src_x += width-1;
dst_x += width-1;
}
if(!(xgi_video_info.CommandReg & Y_INC)) {
src_y += height-1;
dst_y += height-1;
}
XGI300SetupRect(width, height)
XGI300SetupSRCXY(src_x, src_y)
XGI300SetupDSTXY(dst_x, dst_y)
XGI300DoCMD
}
static void
XGI300SetupForSolidFill(int color, int rop, unsigned int planemask)
{
XGI300SetupPATFG(color)
XGI300SetupDSTRect(xgi_video_info.video_linelength, 0xFFF)
XGI300SetupDSTColorDepth(xgi_video_info.DstColor);
XGI300SetupROP(XGIPatALUConv[rop])
XGI300SetupCMDFlag(PATFG)
}
static void
XGI300SubsequentSolidFillRect(int x, int y, int w, int h)
{
long dstbase;
dstbase = 0;
if(y >= 2048) {
dstbase = xgi_video_info.video_linelength * y;
y = 0;
}
XGI300SetupDSTBase(dstbase)
XGI300SetupDSTXY(x,y)
XGI300SetupRect(w,h)
XGI300SetupCMDFlag(X_INC | Y_INC | BITBLT)
XGI300DoCMD
}
#endif
/* 310/325 series ------------------------------------------------ */
static void
XGI310SetupForScreenToScreenCopy(int xdir, int ydir, int rop,
unsigned int planemask, int trans_color)
{
XGI310SetupDSTColorDepth(xgi_video_info.DstColor);
XGI310SetupSRCPitch(xgi_video_info.video_linelength)
XGI310SetupDSTRect(xgi_video_info.video_linelength, 0xFFF)
if (trans_color != -1) {
XGI310SetupROP(0x0A)
XGI310SetupSRCTrans(trans_color)
XGI310SetupCMDFlag(TRANSPARENT_BITBLT)
} else {
XGI310SetupROP(XGIALUConv[rop])
/* Set command - not needed, both 0 */
/* XGISetupCMDFlag(BITBLT | SRCVIDEO) */
}
XGI310SetupCMDFlag(xgi_video_info.XGI310_AccelDepth)
/* TW: The 310/325 series is smart enough to know the direction */
}
static void
XGI310SubsequentScreenToScreenCopy(int src_x, int src_y, int dst_x, int dst_y,
int width, int height)
{
long srcbase, dstbase;
int mymin, mymax;
srcbase = dstbase = 0;
mymin = min(src_y, dst_y);
mymax = max(src_y, dst_y);
/* Although the chip knows the direction to use
* if the source and destination areas overlap,
* that logic fails if we fiddle with the bitmap
* addresses. Therefore, we check if the source
* and destination blitting areas overlap and
* adapt the bitmap addresses synchronously
* if the coordinates exceed the valid range.
* The the areas do not overlap, we do our
* normal check.
*/
if((mymax - mymin) < height) {
if((src_y >= 2048) || (dst_y >= 2048)) {
srcbase = xgi_video_info.video_linelength * mymin;
dstbase = xgi_video_info.video_linelength * mymin;
src_y -= mymin;
dst_y -= mymin;
}
} else {
if(src_y >= 2048) {
srcbase = xgi_video_info.video_linelength * src_y;
src_y = 0;
}
if(dst_y >= 2048) {
dstbase = xgi_video_info.video_linelength * dst_y;
dst_y = 0;
}
}
XGI310SetupSRCBase(srcbase);
XGI310SetupDSTBase(dstbase);
XGI310SetupRect(width, height)
XGI310SetupSRCXY(src_x, src_y)
XGI310SetupDSTXY(dst_x, dst_y)
XGI310DoCMD
}
static void
XGI310SetupForSolidFill(int color, int rop, unsigned int planemask)
{
XGI310SetupPATFG(color)
XGI310SetupDSTRect(xgi_video_info.video_linelength, 0xFFF)
XGI310SetupDSTColorDepth(xgi_video_info.DstColor);
XGI310SetupROP(XGIPatALUConv[rop])
XGI310SetupCMDFlag(PATFG | xgi_video_info.XGI310_AccelDepth)
}
static void
XGI310SubsequentSolidFillRect(int x, int y, int w, int h)
{
long dstbase;
dstbase = 0;
if(y >= 2048) {
dstbase = xgi_video_info.video_linelength * y;
y = 0;
}
XGI310SetupDSTBase(dstbase)
XGI310SetupDSTXY(x,y)
XGI310SetupRect(w,h)
XGI310SetupCMDFlag(BITBLT)
XGI310DoCMD
}
/* --------------------------------------------------------------------- */
/* The exported routines */
int XGIfb_initaccel(void)
{
#ifdef XGIFB_USE_SPINLOCKS
spin_lock_init(&xgi_video_info.lockaccel);
#endif
return(0);
}
void XGIfb_syncaccel(void)
{
XGI310Sync();
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,34) /* --- KERNEL 2.5.34 and later --- */
int fbcon_XGI_sync(struct fb_info *info)
{
if(!XGIfb_accel) return 0;
CRITFLAGS
XGI310Sync();
CRITEND
return 0;
}
void fbcon_XGI_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
{
int col=0;
CRITFLAGS
if(!rect->width || !rect->height)
return;
if(!XGIfb_accel) {
cfb_fillrect(info, rect);
return;
}
switch(info->var.bits_per_pixel) {
case 8: col = rect->color;
break;
case 16: col = ((u32 *)(info->pseudo_palette))[rect->color];
break;
case 32: col = ((u32 *)(info->pseudo_palette))[rect->color];
break;
}
CRITBEGIN
XGI310SetupForSolidFill(col, myrops[rect->rop], 0);
XGI310SubsequentSolidFillRect(rect->dx, rect->dy, rect->width, rect->height);
CRITEND
XGI310Sync();
}
void fbcon_XGI_copyarea(struct fb_info *info, const struct fb_copyarea *area)
{
int xdir, ydir;
CRITFLAGS
if(!XGIfb_accel) {
cfb_copyarea(info, area);
return;
}
if(!area->width || !area->height)
return;
if(area->sx < area->dx) xdir = 0;
else xdir = 1;
if(area->sy < area->dy) ydir = 0;
else ydir = 1;
CRITBEGIN
XGI310SetupForScreenToScreenCopy(xdir, ydir, 3, 0, -1);
XGI310SubsequentScreenToScreenCopy(area->sx, area->sy, area->dx, area->dy, area->width, area->height);
CRITEND
XGI310Sync();
}
#endif
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,33) /* ------ KERNEL <2.5.34 ------ */
void fbcon_XGI_bmove(struct display *p, int srcy, int srcx,
int dsty, int dstx, int height, int width)
{
int xdir, ydir;
CRITFLAGS
if(!xgi_video_info.accel) {
switch(xgi_video_info.video_bpp) {
case 8:
#ifdef FBCON_HAS_CFB8
fbcon_cfb8_bmove(p, srcy, srcx, dsty, dstx, height, width);
#endif
break;
case 16:
#ifdef FBCON_HAS_CFB16
fbcon_cfb16_bmove(p, srcy, srcx, dsty, dstx, height, width);
#endif
break;
case 32:
#ifdef FBCON_HAS_CFB32
fbcon_cfb32_bmove(p, srcy, srcx, dsty, dstx, height, width);
#endif
break;
}
return;
}
srcx *= fontwidth(p);
srcy *= fontheight(p);
dstx *= fontwidth(p);
dsty *= fontheight(p);
width *= fontwidth(p);
height *= fontheight(p);
if(srcx < dstx) xdir = 0;
else xdir = 1;
if(srcy < dsty) ydir = 0;
else ydir = 1;
CRITBEGIN
XGI310SetupForScreenToScreenCopy(xdir, ydir, 3, 0, -1);
XGI310SubsequentScreenToScreenCopy(srcx, srcy, dstx, dsty, width, height);
CRITEND
XGI310Sync();
#if 0
printk(KERN_INFO "XGI_bmove sx %d sy %d dx %d dy %d w %d h %d\n",
srcx, srcy, dstx, dsty, width, height);
#endif
}
static void fbcon_XGI_clear(struct vc_data *conp, struct display *p,
int srcy, int srcx, int height, int width, int color)
{
CRITFLAGS
srcx *= fontwidth(p);
srcy *= fontheight(p);
width *= fontwidth(p);
height *= fontheight(p);
CRITBEGIN
XGI310SetupForSolidFill(color, 3, 0);
XGI310SubsequentSolidFillRect(srcx, srcy, width, height);
CRITEND
XGI310Sync();
}
void fbcon_XGI_clear8(struct vc_data *conp, struct display *p,
int srcy, int srcx, int height, int width)
{
u32 bgx;
if(!xgi_video_info.accel) {
#ifdef FBCON_HAS_CFB8
fbcon_cfb8_clear(conp, p, srcy, srcx, height, width);
#endif
return;
}
bgx = attr_bgcol_ec(p, conp);
fbcon_XGI_clear(conp, p, srcy, srcx, height, width, bgx);
}
void fbcon_XGI_clear16(struct vc_data *conp, struct display *p,
int srcy, int srcx, int height, int width)
{
u32 bgx;
if(!xgi_video_info.accel) {
#ifdef FBCON_HAS_CFB16
fbcon_cfb16_clear(conp, p, srcy, srcx, height, width);
#endif
return;
}
bgx = ((u_int16_t*)p->dispsw_data)[attr_bgcol_ec(p, conp)];
fbcon_XGI_clear(conp, p, srcy, srcx, height, width, bgx);
}
void fbcon_XGI_clear32(struct vc_data *conp, struct display *p,
int srcy, int srcx, int height, int width)
{
u32 bgx;
if(!xgi_video_info.accel) {
#ifdef FBCON_HAS_CFB32
fbcon_cfb32_clear(conp, p, srcy, srcx, height, width);
#endif
return;
}
bgx = ((u_int32_t*)p->dispsw_data)[attr_bgcol_ec(p, conp)];
fbcon_XGI_clear(conp, p, srcy, srcx, height, width, bgx);
}
void fbcon_XGI_revc(struct display *p, int srcx, int srcy)
{
CRITFLAGS
if(!xgi_video_info.accel) {
switch(xgi_video_info.video_bpp) {
case 16:
#ifdef FBCON_HAS_CFB16
fbcon_cfb16_revc(p, srcx, srcy);
#endif
break;
case 32:
#ifdef FBCON_HAS_CFB32
fbcon_cfb32_revc(p, srcx, srcy);
#endif
break;
}
return;
}
srcx *= fontwidth(p);
srcy *= fontheight(p);
CRITBEGIN
XGI310SetupForSolidFill(0, 0x0a, 0);
XGI310SubsequentSolidFillRect(srcx, srcy, fontwidth(p), fontheight(p));
CRITEND
XGI310Sync();
}
#ifdef FBCON_HAS_CFB8
struct display_switch fbcon_XGI8 = {
setup: fbcon_cfb8_setup,
bmove: fbcon_XGI_bmove,
clear: fbcon_XGI_clear8,
putc: fbcon_cfb8_putc,
putcs: fbcon_cfb8_putcs,
revc: fbcon_cfb8_revc,
clear_margins: fbcon_cfb8_clear_margins,
fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
};
#endif
#ifdef FBCON_HAS_CFB16
struct display_switch fbcon_XGI16 = {
setup: fbcon_cfb16_setup,
bmove: fbcon_XGI_bmove,
clear: fbcon_XGI_clear16,
putc: fbcon_cfb16_putc,
putcs: fbcon_cfb16_putcs,
revc: fbcon_XGI_revc,
clear_margins: fbcon_cfb16_clear_margins,
fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
};
#endif
#ifdef FBCON_HAS_CFB32
struct display_switch fbcon_XGI32 = {
setup: fbcon_cfb32_setup,
bmove: fbcon_XGI_bmove,
clear: fbcon_XGI_clear32,
putc: fbcon_cfb32_putc,
putcs: fbcon_cfb32_putcs,
revc: fbcon_XGI_revc,
clear_margins: fbcon_cfb32_clear_margins,
fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
};
#endif
#endif /* KERNEL VERSION */
/*
* XGI 300/630/730/540/315/550/650/740 frame buffer driver
* for Linux kernels 2.4.x and 2.5.x
*
* 2D acceleration part
*
* Based on the X driver's XGI300_accel.h which is
* Copyright Xavier Ducoin <x.ducoin@lectra.com>
* Copyright 2002 by Thomas Winischhofer, Vienna, Austria
* and XGI310_accel.h which is
* Copyright 2002 by Thomas Winischhofer, Vienna, Austria
*
* Author: Thomas Winischhofer <thomas@winischhofer.net>:
* (see http://www.winischhofer.net/
* for more information and updates)
*/
#ifndef _XGIFB_ACCEL_H
#define _XGIFB_ACCEL_H
/* Guard accelerator accesses with spin_lock_irqsave? Works well without. */
#undef XGIFB_USE_SPINLOCKS
#ifdef XGIFB_USE_SPINLOCKS
#include <linux/spinlock.h>
#define CRITBEGIN spin_lock_irqsave(&xgi_video_info.lockaccel), critflags);
#define CRITEND spin_unlock_irqrestore(&xgi_video_info.lockaccel), critflags);
#define CRITFLAGS unsigned long critflags;
#else
#define CRITBEGIN
#define CRITEND
#define CRITFLAGS
#endif
/* Definitions for the XGI engine communication. */
#define PATREGSIZE 384 /* Pattern register size. 384 bytes @ 0x8300 */
#define BR(x) (0x8200 | (x) << 2)
#define PBR(x) (0x8300 | (x) << 2)
/* XGI300 engine commands */
#define BITBLT 0x00000000 /* Blit */
#define COLOREXP 0x00000001 /* Color expand */
#define ENCOLOREXP 0x00000002 /* Enhanced color expand */
#define MULTIPLE_SCANLINE 0x00000003 /* ? */
#define LINE 0x00000004 /* Draw line */
#define TRAPAZOID_FILL 0x00000005 /* Fill trapezoid */
#define TRANSPARENT_BITBLT 0x00000006 /* Transparent Blit */
/* Additional engine commands for 310/325 */
#define ALPHA_BLEND 0x00000007 /* Alpha blend ? */
#define A3D_FUNCTION 0x00000008 /* 3D command ? */
#define CLEAR_Z_BUFFER 0x00000009 /* ? */
#define GRADIENT_FILL 0x0000000A /* Gradient fill */
#define STRETCH_BITBLT 0x0000000B /* Stretched Blit */
/* source select */
#define SRCVIDEO 0x00000000 /* source is video RAM */
#define SRCSYSTEM 0x00000010 /* source is system memory */
#define SRCCPUBLITBUF SRCSYSTEM /* source is CPU-driven BitBuffer (for color expand) */
#define SRCAGP 0x00000020 /* source is AGP memory (?) */
/* Pattern flags */
#define PATFG 0x00000000 /* foreground color */
#define PATPATREG 0x00000040 /* pattern in pattern buffer (0x8300) */
#define PATMONO 0x00000080 /* mono pattern */
/* blitting direction (300 series only) */
#define X_INC 0x00010000
#define X_DEC 0x00000000
#define Y_INC 0x00020000
#define Y_DEC 0x00000000
/* Clipping flags */
#define NOCLIP 0x00000000
#define NOMERGECLIP 0x04000000
#define CLIPENABLE 0x00040000
#define CLIPWITHOUTMERGE 0x04040000
/* Transparency */
#define OPAQUE 0x00000000
#define TRANSPARENT 0x00100000
/* ? */
#define DSTAGP 0x02000000
#define DSTVIDEO 0x02000000
/* Line */
#define LINE_STYLE 0x00800000
#define NO_RESET_COUNTER 0x00400000
#define NO_LAST_PIXEL 0x00200000
/* Subfunctions for Color/Enhanced Color Expansion (310/325 only) */
#define COLOR_TO_MONO 0x00100000
#define AA_TEXT 0x00200000
/* Some general registers for 310/325 series */
#define SRC_ADDR 0x8200
#define SRC_PITCH 0x8204
#define AGP_BASE 0x8206 /* color-depth dependent value */
#define SRC_Y 0x8208
#define SRC_X 0x820A
#define DST_Y 0x820C
#define DST_X 0x820E
#define DST_ADDR 0x8210
#define DST_PITCH 0x8214
#define DST_HEIGHT 0x8216
#define RECT_WIDTH 0x8218
#define RECT_HEIGHT 0x821A
#define PAT_FGCOLOR 0x821C
#define PAT_BGCOLOR 0x8220
#define SRC_FGCOLOR 0x8224
#define SRC_BGCOLOR 0x8228
#define MONO_MASK 0x822C
#define LEFT_CLIP 0x8234
#define TOP_CLIP 0x8236
#define RIGHT_CLIP 0x8238
#define BOTTOM_CLIP 0x823A
#define COMMAND_READY 0x823C
#define FIRE_TRIGGER 0x8240
#define PATTERN_REG 0x8300 /* 384 bytes pattern buffer */
/* Line registers */
#define LINE_X0 SRC_Y
#define LINE_X1 DST_Y
#define LINE_Y0 SRC_X
#define LINE_Y1 DST_X
#define LINE_COUNT RECT_WIDTH
#define LINE_STYLE_PERIOD RECT_HEIGHT
#define LINE_STYLE_0 MONO_MASK
#define LINE_STYLE_1 0x8230
#define LINE_XN PATTERN_REG
#define LINE_YN PATTERN_REG+2
/* Transparent bitblit registers */
#define TRANS_DST_KEY_HIGH PAT_FGCOLOR
#define TRANS_DST_KEY_LOW PAT_BGCOLOR
#define TRANS_SRC_KEY_HIGH SRC_FGCOLOR
#define TRANS_SRC_KEY_LOW SRC_BGCOLOR
/* Queue */
#define Q_BASE_ADDR 0x85C0 /* Base address of software queue (?) */
#define Q_WRITE_PTR 0x85C4 /* Current write pointer (?) */
#define Q_READ_PTR 0x85C8 /* Current read pointer (?) */
#define Q_STATUS 0x85CC /* queue status */
#define MMIO_IN8(base, offset) \
*(volatile u8 *)(((u8*)(base)) + (offset))
#define MMIO_IN16(base, offset) \
*(volatile u16 *)(void *)(((u8*)(base)) + (offset))
#define MMIO_IN32(base, offset) \
*(volatile u32 *)(void *)(((u8*)(base)) + (offset))
#define MMIO_OUT8(base, offset, val) \
*(volatile u8 *)(((u8*)(base)) + (offset)) = (val)
#define MMIO_OUT16(base, offset, val) \
*(volatile u16 *)(void *)(((u8*)(base)) + (offset)) = (val)
#define MMIO_OUT32(base, offset, val) \
*(volatile u32 *)(void *)(((u8*)(base)) + (offset)) = (val)
/* ------------- XGI 300 series -------------- */
/* Macros to do useful things with the XGI BitBLT engine */
/* BR(16) (0x8420):
bit 31 2D engine: 1 is idle,
bit 30 3D engine: 1 is idle,
bit 29 Command queue: 1 is empty
bits 28:24: Current CPU driven BitBlt buffer stage bit[4:0]
bits 15:0: Current command queue length
*/
/* TW: BR(16)+2 = 0x8242 */
int xgiCmdQueLen;
#define XGI300Idle \
{ \
while( (MMIO_IN16(xgi_video_info.mmio_vbase, BR(16)+2) & 0xE000) != 0xE000){}; \
while( (MMIO_IN16(xgi_video_info.mmio_vbase, BR(16)+2) & 0xE000) != 0xE000){}; \
while( (MMIO_IN16(xgi_video_info.mmio_vbase, BR(16)+2) & 0xE000) != 0xE000){}; \
xgiCmdQueLen=MMIO_IN16(xgi_video_info.mmio_vbase, 0x8240); \
}
/* TW: (do three times, because 2D engine seems quite unsure about whether or not it's idle) */
#define XGI300SetupSRCBase(base) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(0), base);\
xgiCmdQueLen --;
#define XGI300SetupSRCPitch(pitch) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT16(xgi_video_info.mmio_vbase, BR(1), pitch);\
xgiCmdQueLen --;
#define XGI300SetupSRCXY(x,y) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(2), (x)<<16 | (y) );\
xgiCmdQueLen --;
#define XGI300SetupDSTBase(base) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(4), base);\
xgiCmdQueLen --;
#define XGI300SetupDSTXY(x,y) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(3), (x)<<16 | (y) );\
xgiCmdQueLen --;
#define XGI300SetupDSTRect(x,y) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(5), (y)<<16 | (x) );\
xgiCmdQueLen --;
#define XGI300SetupDSTColorDepth(bpp) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT16(xgi_video_info.mmio_vbase, BR(1)+2, bpp);\
xgiCmdQueLen --;
#define XGI300SetupRect(w,h) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(6), (h)<<16 | (w) );\
xgiCmdQueLen --;
#define XGI300SetupPATFG(color) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(7), color);\
xgiCmdQueLen --;
#define XGI300SetupPATBG(color) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(8), color);\
xgiCmdQueLen --;
#define XGI300SetupSRCFG(color) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(9), color);\
xgiCmdQueLen --;
#define XGI300SetupSRCBG(color) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(10), color);\
xgiCmdQueLen --;
/* 0x8224 src colorkey high */
/* 0x8228 src colorkey low */
/* 0x821c dest colorkey high */
/* 0x8220 dest colorkey low */
#define XGI300SetupSRCTrans(color) \
if (xgiCmdQueLen <= 1) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, 0x8224, color);\
MMIO_OUT32(xgi_video_info.mmio_vbase, 0x8228, color);\
xgiCmdQueLen -= 2;
#define XGI300SetupDSTTrans(color) \
if (xgiCmdQueLen <= 1) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, 0x821C, color); \
MMIO_OUT32(xgi_video_info.mmio_vbase, 0x8220, color); \
xgiCmdQueLen -= 2;
#define XGI300SetupMONOPAT(p0,p1) \
if (xgiCmdQueLen <= 1) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(11), p0);\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(12), p1);\
xgiCmdQueLen -= 2;
#define XGI300SetupClipLT(left,top) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(13), ((left) & 0xFFFF) | (top)<<16 );\
xgiCmdQueLen--;
#define XGI300SetupClipRB(right,bottom) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(14), ((right) & 0xFFFF) | (bottom)<<16 );\
xgiCmdQueLen--;
/* General */
#define XGI300SetupROP(rop) \
xgi_video_info.CommandReg = (rop) << 8;
#define XGI300SetupCMDFlag(flags) \
xgi_video_info.CommandReg |= (flags);
#define XGI300DoCMD \
if (xgiCmdQueLen <= 1) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(15), xgi_video_info.CommandReg); \
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(16), 0);\
xgiCmdQueLen -= 2;
/* Line */
#define XGI300SetupX0Y0(x,y) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(2), (y)<<16 | (x) );\
xgiCmdQueLen--;
#define XGI300SetupX1Y1(x,y) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(3), (y)<<16 | (x) );\
xgiCmdQueLen--;
#define XGI300SetupLineCount(c) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT16(xgi_video_info.mmio_vbase, BR(6), c);\
xgiCmdQueLen--;
#define XGI300SetupStylePeriod(p) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT16(xgi_video_info.mmio_vbase, BR(6)+2, p);\
xgiCmdQueLen--;
#define XGI300SetupStyleLow(ls) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(11), ls);\
xgiCmdQueLen--;
#define XGI300SetupStyleHigh(ls) \
if (xgiCmdQueLen <= 0) XGI300Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, BR(12), ls);\
xgiCmdQueLen--;
/* ----------- XGI 310/325 series --------------- */
/* Q_STATUS:
bit 31 = 1: All engines idle and all queues empty
bit 30 = 1: Hardware Queue (=HW CQ, 2D queue, 3D queue) empty
bit 29 = 1: 2D engine is idle
bit 28 = 1: 3D engine is idle
bit 27 = 1: HW command queue empty
bit 26 = 1: 2D queue empty
bit 25 = 1: 3D queue empty
bit 24 = 1: SW command queue empty
bits 23:16: 2D counter 3
bits 15:8: 2D counter 2
bits 7:0: 2D counter 1
Where is the command queue length (current amount of commands the queue
can accept) on the 310/325 series? (The current implementation is taken
from 300 series and certainly wrong...)
*/
/* TW: FIXME: xgiCmdQueLen is... where....? */
#define XGI310Idle \
{ \
while( (MMIO_IN16(xgi_video_info.mmio_vbase, Q_STATUS+2) & 0x8000) != 0x8000){}; \
while( (MMIO_IN16(xgi_video_info.mmio_vbase, Q_STATUS+2) & 0x8000) != 0x8000){}; \
xgiCmdQueLen=MMIO_IN16(xgi_video_info.mmio_vbase, Q_STATUS); \
}
#define XGI310SetupSRCBase(base) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, SRC_ADDR, base);\
xgiCmdQueLen--;
#define XGI310SetupSRCPitch(pitch) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT16(xgi_video_info.mmio_vbase, SRC_PITCH, pitch);\
xgiCmdQueLen--;
#define XGI310SetupSRCXY(x,y) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, SRC_Y, (x)<<16 | (y) );\
xgiCmdQueLen--;
#define XGI310SetupDSTBase(base) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, DST_ADDR, base);\
xgiCmdQueLen--;
#define XGI310SetupDSTXY(x,y) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, DST_Y, (x)<<16 | (y) );\
xgiCmdQueLen--;
#define XGI310SetupDSTRect(x,y) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, DST_PITCH, (y)<<16 | (x) );\
xgiCmdQueLen--;
#define XGI310SetupDSTColorDepth(bpp) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT16(xgi_video_info.mmio_vbase, AGP_BASE, bpp);\
xgiCmdQueLen--;
#define XGI310SetupRect(w,h) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, RECT_WIDTH, (h)<<16 | (w) );\
xgiCmdQueLen--;
#define XGI310SetupPATFG(color) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, PAT_FGCOLOR, color);\
xgiCmdQueLen--;
#define XGI310SetupPATBG(color) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, PAT_BGCOLOR, color);\
xgiCmdQueLen--;
#define XGI310SetupSRCFG(color) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, SRC_FGCOLOR, color);\
xgiCmdQueLen--;
#define XGI310SetupSRCBG(color) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, SRC_BGCOLOR, color);\
xgiCmdQueLen--;
#define XGI310SetupSRCTrans(color) \
if (xgiCmdQueLen <= 1) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, TRANS_SRC_KEY_HIGH, color);\
MMIO_OUT32(xgi_video_info.mmio_vbase, TRANS_SRC_KEY_LOW, color);\
xgiCmdQueLen -= 2;
#define XGI310SetupDSTTrans(color) \
if (xgiCmdQueLen <= 1) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, TRANS_DST_KEY_HIGH, color); \
MMIO_OUT32(xgi_video_info.mmio_vbase, TRANS_DST_KEY_LOW, color); \
xgiCmdQueLen -= 2;
#define XGI310SetupMONOPAT(p0,p1) \
if (xgiCmdQueLen <= 1) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, MONO_MASK, p0);\
MMIO_OUT32(xgi_video_info.mmio_vbase, MONO_MASK+4, p1);\
xgiCmdQueLen -= 2;
#define XGI310SetupClipLT(left,top) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, LEFT_CLIP, ((left) & 0xFFFF) | (top)<<16 );\
xgiCmdQueLen--;
#define XGI310SetupClipRB(right,bottom) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, RIGHT_CLIP, ((right) & 0xFFFF) | (bottom)<<16 );\
xgiCmdQueLen--;
#define XGI310SetupROP(rop) \
xgi_video_info.CommandReg = (rop) << 8;
#define XGI310SetupCMDFlag(flags) \
xgi_video_info.CommandReg |= (flags);
#define XGI310DoCMD \
if (xgiCmdQueLen <= 1) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, COMMAND_READY, xgi_video_info.CommandReg); \
MMIO_OUT32(xgi_video_info.mmio_vbase, FIRE_TRIGGER, 0); \
xgiCmdQueLen -= 2;
#define XGI310SetupX0Y0(x,y) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, LINE_X0, (y)<<16 | (x) );\
xgiCmdQueLen--;
#define XGI310SetupX1Y1(x,y) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, LINE_X1, (y)<<16 | (x) );\
xgiCmdQueLen--;
#define XGI310SetupLineCount(c) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT16(xgi_video_info.mmio_vbase, LINE_COUNT, c);\
xgiCmdQueLen--;
#define XGI310SetupStylePeriod(p) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT16(xgi_video_info.mmio_vbase, LINE_STYLE_PERIOD, p);\
xgiCmdQueLen--;
#define XGI310SetupStyleLow(ls) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, LINE_STYLE_0, ls);\
xgiCmdQueLen--;
#define XGI310SetupStyleHigh(ls) \
if (xgiCmdQueLen <= 0) XGI310Idle;\
MMIO_OUT32(xgi_video_info.mmio_vbase, LINE_STYLE_1, ls);\
xgiCmdQueLen--;
int XGIfb_initaccel(void);
void XGIfb_syncaccel(void);
extern struct video_info xgi_video_info;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,33)
void fbcon_XGI_bmove(struct display *p, int srcy, int srcx, int dsty,
int dstx, int height, int width);
void fbcon_XGI_revc(struct display *p, int srcy, int srcx);
void fbcon_XGI_clear8(struct vc_data *conp, struct display *p, int srcy,
int srcx, int height, int width);
void fbcon_XGI_clear16(struct vc_data *conp, struct display *p, int srcy,
int srcx, int height, int width);
void fbcon_XGI_clear32(struct vc_data *conp, struct display *p, int srcy,
int srcx, int height, int width);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,34)
extern int XGIfb_accel;
void fbcon_XGI_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
void fbcon_XGI_copyarea(struct fb_info *info, const struct fb_copyarea *area);
#endif
#endif
#ifndef _XGIFB_MAIN
#define _XGIFB_MAIN
/* ------------------- Constant Definitions ------------------------- */
#include "XGIfb.h"
#include "vb_struct.h"
#include "vb_def.h"
//#define LINUXBIOS /* turn this on when compiling for LINUXBIOS */
#define AGPOFF /* default is turn off AGP */
#define XGIFAIL(x) do { printk(x "\n"); return -EINVAL; } while(0)
#define VER_MAJOR 0
#define VER_MINOR 8
#define VER_LEVEL 1
#define DRIVER_DESC "XGI Volari Frame Buffer Module Version 0.8.1"
#ifndef PCI_VENDOR_ID_XG
#define PCI_VENDOR_ID_XG 0x18CA
#endif
#ifndef PCI_DEVICE_ID_XG_40
#define PCI_DEVICE_ID_XG_40 0x040
#endif
#ifndef PCI_DEVICE_ID_XG_41
#define PCI_DEVICE_ID_XG_41 0x041
#endif
#ifndef PCI_DEVICE_ID_XG_42
#define PCI_DEVICE_ID_XG_42 0x042
#endif
#ifndef PCI_DEVICE_ID_XG_20
#define PCI_DEVICE_ID_XG_20 0x020
#endif
#ifndef PCI_DEVICE_ID_XG_27
#define PCI_DEVICE_ID_XG_27 0x027
#endif
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8)
#define XGI_IOTYPE1 void __iomem
#define XGI_IOTYPE2 __iomem
#define XGIINITSTATIC static
#else
#define XGI_IOTYPE1 unsigned char
#define XGI_IOTYPE2
#define XGIINITSTATIC
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
static struct pci_device_id __devinitdata xgifb_pci_table[] = {
{ PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{ PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_27, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
{ PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_40, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
{ PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_42, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3},
{ 0 }
};
MODULE_DEVICE_TABLE(pci, xgifb_pci_table);
#endif
/* To be included in fb.h */
#ifndef FB_ACCEL_XGI_GLAMOUR_2
#define FB_ACCEL_XGI_GLAMOUR_2 40 /* XGI 315, 650, 740 */
#endif
#ifndef FB_ACCEL_XGI_XABRE
#define FB_ACCEL_XGI_XABRE 41 /* XGI 330 ("Xabre") */
#endif
#define MAX_ROM_SCAN 0x10000
#define HW_CURSOR_CAP 0x80
#define TURBO_QUEUE_CAP 0x40
#define AGP_CMD_QUEUE_CAP 0x20
#define VM_CMD_QUEUE_CAP 0x10
#define MMIO_CMD_QUEUE_CAP 0x08
/* For 315 series */
#define COMMAND_QUEUE_AREA_SIZE 0x80000 /* 512K */
#define COMMAND_QUEUE_THRESHOLD 0x1F
/* TW */
#define HW_CURSOR_AREA_SIZE_315 0x4000 /* 16K */
#define HW_CURSOR_AREA_SIZE_300 0x1000 /* 4K */
#define OH_ALLOC_SIZE 4000
#define SENTINEL 0x7fffffff
#define SEQ_ADR 0x14
#define SEQ_DATA 0x15
#define DAC_ADR 0x18
#define DAC_DATA 0x19
#define CRTC_ADR 0x24
#define CRTC_DATA 0x25
#define DAC2_ADR (0x16-0x30)
#define DAC2_DATA (0x17-0x30)
#define VB_PART1_ADR (0x04-0x30)
#define VB_PART1_DATA (0x05-0x30)
#define VB_PART2_ADR (0x10-0x30)
#define VB_PART2_DATA (0x11-0x30)
#define VB_PART3_ADR (0x12-0x30)
#define VB_PART3_DATA (0x13-0x30)
#define VB_PART4_ADR (0x14-0x30)
#define VB_PART4_DATA (0x15-0x30)
#define XGISR XGI_Pr.P3c4
#define XGICR XGI_Pr.P3d4
#define XGIDACA XGI_Pr.P3c8
#define XGIDACD XGI_Pr.P3c9
#define XGIPART1 XGI_Pr.Part1Port
#define XGIPART2 XGI_Pr.Part2Port
#define XGIPART3 XGI_Pr.Part3Port
#define XGIPART4 XGI_Pr.Part4Port
#define XGIPART5 XGI_Pr.Part5Port
#define XGIDAC2A XGIPART5
#define XGIDAC2D (XGIPART5 + 1)
#define XGIMISCR (XGI_Pr.RelIO + 0x1c)
#define XGIINPSTAT (XGI_Pr.RelIO + 0x2a)
#define IND_XGI_PASSWORD 0x05 /* SRs */
#define IND_XGI_COLOR_MODE 0x06
#define IND_XGI_RAMDAC_CONTROL 0x07
#define IND_XGI_DRAM_SIZE 0x14
#define IND_XGI_SCRATCH_REG_16 0x16
#define IND_XGI_SCRATCH_REG_17 0x17
#define IND_XGI_SCRATCH_REG_1A 0x1A
#define IND_XGI_MODULE_ENABLE 0x1E
#define IND_XGI_PCI_ADDRESS_SET 0x20
#define IND_XGI_TURBOQUEUE_ADR 0x26
#define IND_XGI_TURBOQUEUE_SET 0x27
#define IND_XGI_POWER_ON_TRAP 0x38
#define IND_XGI_POWER_ON_TRAP2 0x39
#define IND_XGI_CMDQUEUE_SET 0x26
#define IND_XGI_CMDQUEUE_THRESHOLD 0x27
#define IND_XGI_SCRATCH_REG_CR30 0x30 /* CRs */
#define IND_XGI_SCRATCH_REG_CR31 0x31
#define IND_XGI_SCRATCH_REG_CR32 0x32
#define IND_XGI_SCRATCH_REG_CR33 0x33
#define IND_XGI_LCD_PANEL 0x36
#define IND_XGI_SCRATCH_REG_CR37 0x37
#define IND_XGI_AGP_IO_PAD 0x48
#define IND_BRI_DRAM_STATUS 0x63 /* PCI config memory size offset */
#define MMIO_QUEUE_PHYBASE 0x85C0
#define MMIO_QUEUE_WRITEPORT 0x85C4
#define MMIO_QUEUE_READPORT 0x85C8
#define IND_XGI_CRT2_WRITE_ENABLE_300 0x24
#define IND_XGI_CRT2_WRITE_ENABLE_315 0x2F
#define XGI_PASSWORD 0x86 /* SR05 */
#define XGI_INTERLACED_MODE 0x20 /* SR06 */
#define XGI_8BPP_COLOR_MODE 0x0
#define XGI_15BPP_COLOR_MODE 0x1
#define XGI_16BPP_COLOR_MODE 0x2
#define XGI_32BPP_COLOR_MODE 0x4
#define XGI_DRAM_SIZE_MASK 0xF0 /*SR14 */
#define XGI_DRAM_SIZE_1MB 0x00
#define XGI_DRAM_SIZE_2MB 0x01
#define XGI_DRAM_SIZE_4MB 0x02
#define XGI_DRAM_SIZE_8MB 0x03
#define XGI_DRAM_SIZE_16MB 0x04
#define XGI_DRAM_SIZE_32MB 0x05
#define XGI_DRAM_SIZE_64MB 0x06
#define XGI_DRAM_SIZE_128MB 0x07
#define XGI_DRAM_SIZE_256MB 0x08
#define XGI_DATA_BUS_MASK 0x02
#define XGI_DATA_BUS_64 0x00
#define XGI_DATA_BUS_128 0x01
#define XGI_DUAL_CHANNEL_MASK 0x0C
#define XGI_SINGLE_CHANNEL_1_RANK 0x0
#define XGI_SINGLE_CHANNEL_2_RANK 0x1
#define XGI_ASYM_DDR 0x02
#define XGI_DUAL_CHANNEL_1_RANK 0x3
#define XGI550_DRAM_SIZE_MASK 0x3F /* 550/650/740 SR14 */
#define XGI550_DRAM_SIZE_4MB 0x00
#define XGI550_DRAM_SIZE_8MB 0x01
#define XGI550_DRAM_SIZE_16MB 0x03
#define XGI550_DRAM_SIZE_24MB 0x05
#define XGI550_DRAM_SIZE_32MB 0x07
#define XGI550_DRAM_SIZE_64MB 0x0F
#define XGI550_DRAM_SIZE_96MB 0x17
#define XGI550_DRAM_SIZE_128MB 0x1F
#define XGI550_DRAM_SIZE_256MB 0x3F
#define XGI_SCRATCH_REG_1A_MASK 0x10
#define XGI_ENABLE_2D 0x40 /* SR1E */
#define XGI_MEM_MAP_IO_ENABLE 0x01 /* SR20 */
#define XGI_PCI_ADDR_ENABLE 0x80
#define XGI_AGP_CMDQUEUE_ENABLE 0x80 /* 315/650/740 SR26 */
#define XGI_VRAM_CMDQUEUE_ENABLE 0x40
#define XGI_MMIO_CMD_ENABLE 0x20
#define XGI_CMD_QUEUE_SIZE_512k 0x00
#define XGI_CMD_QUEUE_SIZE_1M 0x04
#define XGI_CMD_QUEUE_SIZE_2M 0x08
#define XGI_CMD_QUEUE_SIZE_4M 0x0C
#define XGI_CMD_QUEUE_RESET 0x01
#define XGI_CMD_AUTO_CORR 0x02
#define XGI_SIMULTANEOUS_VIEW_ENABLE 0x01 /* CR30 */
#define XGI_MODE_SELECT_CRT2 0x02
#define XGI_VB_OUTPUT_COMPOSITE 0x04
#define XGI_VB_OUTPUT_SVIDEO 0x08
#define XGI_VB_OUTPUT_SCART 0x10
#define XGI_VB_OUTPUT_LCD 0x20
#define XGI_VB_OUTPUT_CRT2 0x40
#define XGI_VB_OUTPUT_HIVISION 0x80
#define XGI_VB_OUTPUT_DISABLE 0x20 /* CR31 */
#define XGI_DRIVER_MODE 0x40
#define XGI_VB_COMPOSITE 0x01 /* CR32 */
#define XGI_VB_SVIDEO 0x02
#define XGI_VB_SCART 0x04
#define XGI_VB_LCD 0x08
#define XGI_VB_CRT2 0x10
#define XGI_CRT1 0x20
#define XGI_VB_HIVISION 0x40
#define XGI_VB_YPBPR 0x80
#define XGI_VB_TV (XGI_VB_COMPOSITE | XGI_VB_SVIDEO | \
XGI_VB_SCART | XGI_VB_HIVISION|XGI_VB_YPBPR)
#define XGI_EXTERNAL_CHIP_MASK 0x0E /* CR37 */
#define XGI_EXTERNAL_CHIP_XGI301 0x01 /* in CR37 << 1 ! */
#define XGI_EXTERNAL_CHIP_LVDS 0x02 /* in CR37 << 1 ! */
#define XGI_EXTERNAL_CHIP_TRUMPION 0x03 /* in CR37 << 1 ! */
#define XGI_EXTERNAL_CHIP_LVDS_CHRONTEL 0x04 /* in CR37 << 1 ! */
#define XGI_EXTERNAL_CHIP_CHRONTEL 0x05 /* in CR37 << 1 ! */
#define XGI310_EXTERNAL_CHIP_LVDS 0x02 /* in CR37 << 1 ! */
#define XGI310_EXTERNAL_CHIP_LVDS_CHRONTEL 0x03 /* in CR37 << 1 ! */
#define XGI_AGP_2X 0x20 /* CR48 */
#define BRI_DRAM_SIZE_MASK 0x70 /* PCI bridge config data */
#define BRI_DRAM_SIZE_2MB 0x00
#define BRI_DRAM_SIZE_4MB 0x01
#define BRI_DRAM_SIZE_8MB 0x02
#define BRI_DRAM_SIZE_16MB 0x03
#define BRI_DRAM_SIZE_32MB 0x04
#define BRI_DRAM_SIZE_64MB 0x05
#define HW_DEVICE_EXTENSION XGI_HW_DEVICE_INFO
#define PHW_DEVICE_EXTENSION PXGI_HW_DEVICE_INFO
#define SR_BUFFER_SIZE 5
#define CR_BUFFER_SIZE 5
/* Useful macros */
#define inXGIREG(base) inb(base)
#define outXGIREG(base,val) outb(val,base)
#define orXGIREG(base,val) do { \
unsigned char __Temp = inb(base); \
outXGIREG(base, __Temp | (val)); \
} while (0)
#define andXGIREG(base,val) do { \
unsigned char __Temp = inb(base); \
outXGIREG(base, __Temp & (val)); \
} while (0)
#define inXGIIDXREG(base,idx,var) do { \
outb(idx,base); var=inb((base)+1); \
} while (0)
#define outXGIIDXREG(base,idx,val) do { \
outb(idx,base); outb((val),(base)+1); \
} while (0)
#define orXGIIDXREG(base,idx,val) do { \
unsigned char __Temp; \
outb(idx,base); \
__Temp = inb((base)+1)|(val); \
outXGIIDXREG(base,idx,__Temp); \
} while (0)
#define andXGIIDXREG(base,idx,and) do { \
unsigned char __Temp; \
outb(idx,base); \
__Temp = inb((base)+1)&(and); \
outXGIIDXREG(base,idx,__Temp); \
} while (0)
#define setXGIIDXREG(base,idx,and,or) do { \
unsigned char __Temp; \
outb(idx,base); \
__Temp = (inb((base)+1)&(and))|(or); \
outXGIIDXREG(base,idx,__Temp); \
} while (0)
/* ------------------- Global Variables ----------------------------- */
/* Fbcon variables */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
static struct fb_info* fb_info;
#else
static struct fb_info XGI_fb_info;
#endif
static int video_type = FB_TYPE_PACKED_PIXELS;
static struct fb_var_screeninfo default_var = {
.xres = 0,
.yres = 0,
.xres_virtual = 0,
.yres_virtual = 0,
.xoffset = 0,
.yoffset = 0,
.bits_per_pixel = 0,
.grayscale = 0,
.red = {0, 8, 0},
.green = {0, 8, 0},
.blue = {0, 8, 0},
.transp = {0, 0, 0},
.nonstd = 0,
.activate = FB_ACTIVATE_NOW,
.height = -1,
.width = -1,
.accel_flags = 0,
.pixclock = 0,
.left_margin = 0,
.right_margin = 0,
.upper_margin = 0,
.lower_margin = 0,
.hsync_len = 0,
.vsync_len = 0,
.sync = 0,
.vmode = FB_VMODE_NONINTERLACED,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
.reserved = {0, 0, 0, 0, 0, 0}
#endif
};
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
static struct fb_fix_screeninfo XGIfb_fix = {
.id = "XGI",
.type = FB_TYPE_PACKED_PIXELS,
.xpanstep = 1,
.ypanstep = 1,
};
static char myid[20];
static u32 pseudo_palette[17];
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
static struct display XGI_disp;
static struct display_switch XGIfb_sw;
static struct {
u16 blue, green, red, pad;
} XGI_palette[256];
static union {
#ifdef FBCON_HAS_CFB16
u16 cfb16[16];
#endif
#ifdef FBCON_HAS_CFB32
u32 cfb32[16];
#endif
} XGI_fbcon_cmap;
static int XGIfb_inverse = 0;
#endif
/* display status */
static int XGIfb_off = 0;
static int XGIfb_crt1off = 0;
static int XGIfb_forcecrt1 = -1;
static int XGIvga_enabled = 0;
static int XGIfb_userom = 0;
//static int XGIfb_useoem = -1;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
static int currcon = 0;
#endif
/* global flags */
static int XGIfb_registered;
static int XGIfb_tvmode = 0;
static int XGIfb_mem = 0;
static int XGIfb_pdc = 0;
static int enable_dstn = 0;
static int XGIfb_ypan = -1;
int XGIfb_accel = 0;
static int XGIfb_hwcursor_size = 0;
static int XGIfb_CRT2_write_enable = 0;
int XGIfb_crt2type = -1; /* TW: CRT2 type (for overriding autodetection) */
int XGIfb_tvplug = -1; /* PR: Tv plug type (for overriding autodetection) */
int XGIfb_queuemode = -1; /* TW: Use MMIO queue mode by default (310/325 series only) */
unsigned char XGIfb_detectedpdc = 0;
unsigned char XGIfb_detectedlcda = 0xff;
/* TW: For ioctl XGIFB_GET_INFO */
/* XGIfb_info XGIfbinfo; */
/* TW: Hardware extension; contains data on hardware */
HW_DEVICE_EXTENSION XGIhw_ext;
/* TW: XGI private structure */
VB_DEVICE_INFO XGI_Pr;
/* card parameters */
static unsigned long XGIfb_mmio_size = 0;
static u8 XGIfb_caps = 0;
typedef enum _XGI_CMDTYPE {
MMIO_CMD = 0,
AGP_CMD_QUEUE,
VM_CMD_QUEUE,
} XGI_CMDTYPE;
#define MD_XGI300 1
#define MD_XGI315 2
/* mode table */
/* NOT const - will be patched for 1280x960 mode number chaos reasons */
struct _XGIbios_mode {
char name[15];
u8 mode_no;
u16 vesa_mode_no_1; /* "XGI defined" VESA mode number */
u16 vesa_mode_no_2; /* Real VESA mode numbers */
u16 xres;
u16 yres;
u16 bpp;
u16 rate_idx;
u16 cols;
u16 rows;
u8 chipset;
} XGIbios_mode[] = {
#define MODE_INDEX_NONE 0 /* TW: index for mode=none */
{"none", 0xFF, 0x0000, 0x0000, 0, 0, 0, 0, 0, 0, MD_XGI300|MD_XGI315}, /* TW: for mode "none" */
{"320x240x16", 0x56, 0x0000, 0x0000, 320, 240, 16, 1, 40, 15, MD_XGI315},
{"320x480x8", 0x5A, 0x0000, 0x0000, 320, 480, 8, 1, 40, 30, MD_XGI315}, /* TW: FSTN */
{"320x480x16", 0x5B, 0x0000, 0x0000, 320, 480, 16, 1, 40, 30, MD_XGI315}, /* TW: FSTN */
{"640x480x8", 0x2E, 0x0101, 0x0101, 640, 480, 8, 1, 80, 30, MD_XGI300|MD_XGI315},
{"640x480x16", 0x44, 0x0111, 0x0111, 640, 480, 16, 1, 80, 30, MD_XGI300|MD_XGI315},
{"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 */
{"640x480x32", 0x62, 0x013a, 0x0112, 640, 480, 32, 1, 80, 30, MD_XGI300|MD_XGI315},
{"720x480x8", 0x31, 0x0000, 0x0000, 720, 480, 8, 1, 90, 30, MD_XGI300|MD_XGI315},
{"720x480x16", 0x33, 0x0000, 0x0000, 720, 480, 16, 1, 90, 30, MD_XGI300|MD_XGI315},
{"720x480x24", 0x35, 0x0000, 0x0000, 720, 480, 32, 1, 90, 30, MD_XGI300|MD_XGI315},
{"720x480x32", 0x35, 0x0000, 0x0000, 720, 480, 32, 1, 90, 30, MD_XGI300|MD_XGI315},
{"720x576x8", 0x32, 0x0000, 0x0000, 720, 576, 8, 1, 90, 36, MD_XGI300|MD_XGI315},
{"720x576x16", 0x34, 0x0000, 0x0000, 720, 576, 16, 1, 90, 36, MD_XGI300|MD_XGI315},
{"720x576x24", 0x36, 0x0000, 0x0000, 720, 576, 32, 1, 90, 36, MD_XGI300|MD_XGI315},
{"720x576x32", 0x36, 0x0000, 0x0000, 720, 576, 32, 1, 90, 36, MD_XGI300|MD_XGI315},
{"800x480x8", 0x70, 0x0000, 0x0000, 800, 480, 8, 1, 100, 30, MD_XGI300|MD_XGI315},
{"800x480x16", 0x7a, 0x0000, 0x0000, 800, 480, 16, 1, 100, 30, MD_XGI300|MD_XGI315},
{"800x480x24", 0x76, 0x0000, 0x0000, 800, 480, 32, 1, 100, 30, MD_XGI300|MD_XGI315},
{"800x480x32", 0x76, 0x0000, 0x0000, 800, 480, 32, 1, 100, 30, MD_XGI300|MD_XGI315},
#define DEFAULT_MODE 21 /* TW: index for 800x600x8 */
#define DEFAULT_LCDMODE 21 /* TW: index for 800x600x8 */
#define DEFAULT_TVMODE 21 /* TW: index for 800x600x8 */
{"800x600x8", 0x30, 0x0103, 0x0103, 800, 600, 8, 1, 100, 37, MD_XGI300|MD_XGI315},
{"800x600x16", 0x47, 0x0114, 0x0114, 800, 600, 16, 1, 100, 37, MD_XGI300|MD_XGI315},
{"800x600x24", 0x63, 0x013b, 0x0115, 800, 600, 32, 1, 100, 37, MD_XGI300|MD_XGI315},
{"800x600x32", 0x63, 0x013b, 0x0115, 800, 600, 32, 1, 100, 37, MD_XGI300|MD_XGI315},
{"1024x576x8", 0x71, 0x0000, 0x0000, 1024, 576, 8, 1, 128, 36, MD_XGI300|MD_XGI315},
{"1024x576x16", 0x74, 0x0000, 0x0000, 1024, 576, 16, 1, 128, 36, MD_XGI300|MD_XGI315},
{"1024x576x24", 0x77, 0x0000, 0x0000, 1024, 576, 32, 1, 128, 36, MD_XGI300|MD_XGI315},
{"1024x576x32", 0x77, 0x0000, 0x0000, 1024, 576, 32, 1, 128, 36, MD_XGI300|MD_XGI315},
{"1024x600x8", 0x20, 0x0000, 0x0000, 1024, 600, 8, 1, 128, 37, MD_XGI300 }, /* TW: 300 series only */
{"1024x600x16", 0x21, 0x0000, 0x0000, 1024, 600, 16, 1, 128, 37, MD_XGI300 },
{"1024x600x24", 0x22, 0x0000, 0x0000, 1024, 600, 32, 1, 128, 37, MD_XGI300 },
{"1024x600x32", 0x22, 0x0000, 0x0000, 1024, 600, 32, 1, 128, 37, MD_XGI300 },
{"1024x768x8", 0x38, 0x0105, 0x0105, 1024, 768, 8, 1, 128, 48, MD_XGI300|MD_XGI315},
{"1024x768x16", 0x4A, 0x0117, 0x0117, 1024, 768, 16, 1, 128, 48, MD_XGI300|MD_XGI315},
{"1024x768x24", 0x64, 0x013c, 0x0118, 1024, 768, 32, 1, 128, 48, MD_XGI300|MD_XGI315},
{"1024x768x32", 0x64, 0x013c, 0x0118, 1024, 768, 32, 1, 128, 48, MD_XGI300|MD_XGI315},
{"1152x768x8", 0x23, 0x0000, 0x0000, 1152, 768, 8, 1, 144, 48, MD_XGI300 }, /* TW: 300 series only */
{"1152x768x16", 0x24, 0x0000, 0x0000, 1152, 768, 16, 1, 144, 48, MD_XGI300 },
{"1152x768x24", 0x25, 0x0000, 0x0000, 1152, 768, 32, 1, 144, 48, MD_XGI300 },
{"1152x768x32", 0x25, 0x0000, 0x0000, 1152, 768, 32, 1, 144, 48, MD_XGI300 },
{"1280x720x8", 0x79, 0x0000, 0x0000, 1280, 720, 8, 1, 160, 45, MD_XGI300|MD_XGI315},
{"1280x720x16", 0x75, 0x0000, 0x0000, 1280, 720, 16, 1, 160, 45, MD_XGI300|MD_XGI315},
{"1280x720x24", 0x78, 0x0000, 0x0000, 1280, 720, 32, 1, 160, 45, MD_XGI300|MD_XGI315},
{"1280x720x32", 0x78, 0x0000, 0x0000, 1280, 720, 32, 1, 160, 45, MD_XGI300|MD_XGI315},
{"1280x768x8", 0x23, 0x0000, 0x0000, 1280, 768, 8, 1, 160, 48, MD_XGI315}, /* TW: 310/325 series only */
{"1280x768x16", 0x24, 0x0000, 0x0000, 1280, 768, 16, 1, 160, 48, MD_XGI315},
{"1280x768x24", 0x25, 0x0000, 0x0000, 1280, 768, 32, 1, 160, 48, MD_XGI315},
{"1280x768x32", 0x25, 0x0000, 0x0000, 1280, 768, 32, 1, 160, 48, MD_XGI315},
#define MODEINDEX_1280x960 48
{"1280x960x8", 0x7C, 0x0000, 0x0000, 1280, 960, 8, 1, 160, 60, MD_XGI300|MD_XGI315}, /* TW: Modenumbers being patched */
{"1280x960x16", 0x7D, 0x0000, 0x0000, 1280, 960, 16, 1, 160, 60, MD_XGI300|MD_XGI315},
{"1280x960x24", 0x7E, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60, MD_XGI300|MD_XGI315},
{"1280x960x32", 0x7E, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60, MD_XGI300|MD_XGI315},
{"1280x1024x8", 0x3A, 0x0107, 0x0107, 1280, 1024, 8, 1, 160, 64, MD_XGI300|MD_XGI315},
{"1280x1024x16", 0x4D, 0x011a, 0x011a, 1280, 1024, 16, 1, 160, 64, MD_XGI300|MD_XGI315},
{"1280x1024x24", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 1, 160, 64, MD_XGI300|MD_XGI315},
{"1280x1024x32", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 1, 160, 64, MD_XGI300|MD_XGI315},
{"1400x1050x8", 0x26, 0x0000, 0x0000, 1400, 1050, 8, 1, 175, 65, MD_XGI315}, /* TW: 310/325 series only */
{"1400x1050x16", 0x27, 0x0000, 0x0000, 1400, 1050, 16, 1, 175, 65, MD_XGI315},
{"1400x1050x24", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65, MD_XGI315},
{"1400x1050x32", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65, MD_XGI315},
{"1600x1200x8", 0x3C, 0x0130, 0x011c, 1600, 1200, 8, 1, 200, 75, MD_XGI300|MD_XGI315},
{"1600x1200x16", 0x3D, 0x0131, 0x011e, 1600, 1200, 16, 1, 200, 75, MD_XGI300|MD_XGI315},
{"1600x1200x24", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75, MD_XGI300|MD_XGI315},
{"1600x1200x32", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75, MD_XGI300|MD_XGI315},
{"1920x1440x8", 0x68, 0x013f, 0x0000, 1920, 1440, 8, 1, 240, 75, MD_XGI300|MD_XGI315},
{"1920x1440x16", 0x69, 0x0140, 0x0000, 1920, 1440, 16, 1, 240, 75, MD_XGI300|MD_XGI315},
{"1920x1440x24", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_XGI300|MD_XGI315},
{"1920x1440x32", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_XGI300|MD_XGI315},
{"2048x1536x8", 0x6c, 0x0000, 0x0000, 2048, 1536, 8, 1, 256, 96, MD_XGI315}, /* TW: 310/325 series only */
{"2048x1536x16", 0x6d, 0x0000, 0x0000, 2048, 1536, 16, 1, 256, 96, MD_XGI315},
{"2048x1536x24", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96, MD_XGI315},
{"2048x1536x32", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96, MD_XGI315},
{"\0", 0x00, 0, 0, 0, 0, 0, 0, 0}
};
/* mode-related variables */
#ifdef MODULE
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
static int xgifb_mode_idx = 1;
#else
static int XGIfb_mode_idx = MODE_INDEX_NONE; /* Don't use a mode by default if we are a module */
#endif
#else
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
static int xgifb_mode_idx = -1; /* Use a default mode if we are inside the kernel */
#else
static int XGIfb_mode_idx = -1;
#endif
#endif
u8 XGIfb_mode_no = 0;
u8 XGIfb_rate_idx = 0;
/* TW: CR36 evaluation */
const USHORT XGI300paneltype[] =
{ LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024,
LCD_1280x960, LCD_640x480, LCD_1024x600, LCD_1152x768,
LCD_1024x768, LCD_1024x768, LCD_1024x768,
LCD_1024x768, LCD_1024x768, LCD_1024x768, LCD_1024x768 };
const USHORT XGI310paneltype[] =
{ LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024,
LCD_640x480, LCD_1024x600, LCD_1152x864, LCD_1280x960,
LCD_1152x768, LCD_1400x1050,LCD_1280x768, LCD_1600x1200,
LCD_1024x768, LCD_1024x768, LCD_1024x768 };
static const struct _XGI_crt2type {
char name[10];
int type_no;
int tvplug_no;
} XGI_crt2type[] = {
{"NONE", 0, -1},
{"LCD", DISPTYPE_LCD, -1},
{"TV", DISPTYPE_TV, -1},
{"VGA", DISPTYPE_CRT2, -1},
{"SVIDEO", DISPTYPE_TV, TVPLUG_SVIDEO},
{"COMPOSITE", DISPTYPE_TV, TVPLUG_COMPOSITE},
{"SCART", DISPTYPE_TV, TVPLUG_SCART},
{"none", 0, -1},
{"lcd", DISPTYPE_LCD, -1},
{"tv", DISPTYPE_TV, -1},
{"vga", DISPTYPE_CRT2, -1},
{"svideo", DISPTYPE_TV, TVPLUG_SVIDEO},
{"composite", DISPTYPE_TV, TVPLUG_COMPOSITE},
{"scart", DISPTYPE_TV, TVPLUG_SCART},
{"\0", -1, -1}
};
/* Queue mode selection for 310 series */
static const struct _XGI_queuemode {
char name[6];
int type_no;
} XGI_queuemode[] = {
{"AGP", AGP_CMD_QUEUE},
{"VRAM", VM_CMD_QUEUE},
{"MMIO", MMIO_CMD},
{"agp", AGP_CMD_QUEUE},
{"vram", VM_CMD_QUEUE},
{"mmio", MMIO_CMD},
{"\0", -1}
};
/* TV standard */
static const struct _XGI_tvtype {
char name[6];
int type_no;
} XGI_tvtype[] = {
{"PAL", 1},
{"NTSC", 2},
{"pal", 1},
{"ntsc", 2},
{"\0", -1}
};
static const struct _XGI_vrate {
u16 idx;
u16 xres;
u16 yres;
u16 refresh;
} XGIfb_vrate[] = {
{1, 640, 480, 60}, {2, 640, 480, 72}, {3, 640, 480, 75}, {4, 640, 480, 85},
{5, 640, 480,100}, {6, 640, 480, 120}, {7, 640, 480, 160}, {8, 640, 480, 200},
{1, 720, 480, 60},
{1, 720, 576, 58},
{1, 800, 480, 60}, {2, 800, 480, 75}, {3, 800, 480, 85},
{1, 800, 600, 60}, {2, 800, 600, 72}, {3, 800, 600, 75},
{4, 800, 600, 85}, {5, 800, 600, 100}, {6, 800, 600, 120}, {7, 800, 600, 160},
{1, 1024, 768, 60}, {2, 1024, 768, 70}, {3, 1024, 768, 75},
{4, 1024, 768, 85}, {5, 1024, 768, 100}, {6, 1024, 768, 120},
{1, 1024, 576, 60}, {2, 1024, 576, 75}, {3, 1024, 576, 85},
{1, 1024, 600, 60},
{1, 1152, 768, 60},
{1, 1280, 720, 60}, {2, 1280, 720, 75}, {3, 1280, 720, 85},
{1, 1280, 768, 60},
{1, 1280, 1024, 60}, {2, 1280, 1024, 75}, {3, 1280, 1024, 85},
{1, 1280, 960, 70},
{1, 1400, 1050, 60},
{1, 1600, 1200, 60}, {2, 1600, 1200, 65}, {3, 1600, 1200, 70}, {4, 1600, 1200, 75},
{5, 1600, 1200, 85}, {6, 1600, 1200, 100}, {7, 1600, 1200, 120},
{1, 1920, 1440, 60}, {2, 1920, 1440, 65}, {3, 1920, 1440, 70}, {4, 1920, 1440, 75},
{5, 1920, 1440, 85}, {6, 1920, 1440, 100},
{1, 2048, 1536, 60}, {2, 2048, 1536, 65}, {3, 2048, 1536, 70}, {4, 2048, 1536, 75},
{5, 2048, 1536, 85},
{0, 0, 0, 0}
};
static const struct _chswtable {
int subsysVendor;
int subsysCard;
char *vendorName;
char *cardName;
} mychswtable[] = {
{ 0x1631, 0x1002, "Mitachi", "0x1002" },
{ 0, 0, "" , "" }
};
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
/* Offscreen layout */
typedef struct _XGI_GLYINFO {
unsigned char ch;
int fontwidth;
int fontheight;
u8 gmask[72];
int ngmask;
} XGI_GLYINFO;
#endif
typedef struct _XGI_OH {
struct _XGI_OH *poh_next;
struct _XGI_OH *poh_prev;
unsigned long offset;
unsigned long size;
} XGI_OH;
typedef struct _XGI_OHALLOC {
struct _XGI_OHALLOC *poha_next;
XGI_OH aoh[1];
} XGI_OHALLOC;
typedef struct _XGI_HEAP {
XGI_OH oh_free;
XGI_OH oh_used;
XGI_OH *poh_freelist;
XGI_OHALLOC *poha_chain;
unsigned long max_freesize;
} XGI_HEAP;
static unsigned long XGIfb_hwcursor_vbase;
static unsigned long XGIfb_heap_start;
static unsigned long XGIfb_heap_end;
static unsigned long XGIfb_heap_size;
static XGI_HEAP XGIfb_heap;
// Eden Chen
static const struct _XGI_TV_filter {
u8 filter[9][4];
} XGI_TV_filter[] = {
{ {{0x00,0x00,0x00,0x40}, /* NTSCFilter_0 */
{0x00,0xE0,0x10,0x60},
{0x00,0xEE,0x10,0x44},
{0x00,0xF4,0x10,0x38},
{0xF8,0xF4,0x18,0x38},
{0xFC,0xFB,0x14,0x2A},
{0x00,0x00,0x10,0x20},
{0x00,0x04,0x10,0x18},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* NTSCFilter_1 */
{0x00,0xE0,0x10,0x60},
{0x00,0xEE,0x10,0x44},
{0x00,0xF4,0x10,0x38},
{0xF8,0xF4,0x18,0x38},
{0xFC,0xFB,0x14,0x2A},
{0x00,0x00,0x10,0x20},
{0x00,0x04,0x10,0x18},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* NTSCFilter_2 */
{0xF5,0xEE,0x1B,0x44},
{0xF8,0xF4,0x18,0x38},
{0xEB,0x04,0x25,0x18},
{0xF1,0x05,0x1F,0x16},
{0xF6,0x06,0x1A,0x14},
{0xFA,0x06,0x16,0x14},
{0x00,0x04,0x10,0x18},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* NTSCFilter_3 */
{0xF1,0x04,0x1F,0x18},
{0xEE,0x0D,0x22,0x06},
{0xF7,0x06,0x19,0x14},
{0xF4,0x0B,0x1C,0x0A},
{0xFA,0x07,0x16,0x12},
{0xF9,0x0A,0x17,0x0C},
{0x00,0x07,0x10,0x12},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* NTSCFilter_4 */
{0x00,0xE0,0x10,0x60},
{0x00,0xEE,0x10,0x44},
{0x00,0xF4,0x10,0x38},
{0xF8,0xF4,0x18,0x38},
{0xFC,0xFB,0x14,0x2A},
{0x00,0x00,0x10,0x20},
{0x00,0x04,0x10,0x18},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* NTSCFilter_5 */
{0xF5,0xEE,0x1B,0x44},
{0xF8,0xF4,0x18,0x38},
{0xEB,0x04,0x25,0x18},
{0xF1,0x05,0x1F,0x16},
{0xF6,0x06,0x1A,0x14},
{0xFA,0x06,0x16,0x14},
{0x00,0x04,0x10,0x18},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* NTSCFilter_6 */
{0xEB,0x04,0x25,0x18},
{0xE7,0x0E,0x29,0x04},
{0xEE,0x0C,0x22,0x08},
{0xF6,0x0B,0x1A,0x0A},
{0xF9,0x0A,0x17,0x0C},
{0xFC,0x0A,0x14,0x0C},
{0x00,0x08,0x10,0x10},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* NTSCFilter_7 */
{0xEC,0x02,0x24,0x1C},
{0xF2,0x04,0x1E,0x18},
{0xEB,0x15,0x25,0xF6},
{0xF4,0x10,0x1C,0x00},
{0xF8,0x0F,0x18,0x02},
{0x00,0x04,0x10,0x18},
{0x01,0x06,0x0F,0x14},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* PALFilter_0 */
{0x00,0xE0,0x10,0x60},
{0x00,0xEE,0x10,0x44},
{0x00,0xF4,0x10,0x38},
{0xF8,0xF4,0x18,0x38},
{0xFC,0xFB,0x14,0x2A},
{0x00,0x00,0x10,0x20},
{0x00,0x04,0x10,0x18},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* PALFilter_1 */
{0x00,0xE0,0x10,0x60},
{0x00,0xEE,0x10,0x44},
{0x00,0xF4,0x10,0x38},
{0xF8,0xF4,0x18,0x38},
{0xFC,0xFB,0x14,0x2A},
{0x00,0x00,0x10,0x20},
{0x00,0x04,0x10,0x18},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* PALFilter_2 */
{0xF5,0xEE,0x1B,0x44},
{0xF8,0xF4,0x18,0x38},
{0xF1,0xF7,0x01,0x32},
{0xF5,0xFB,0x1B,0x2A},
{0xF9,0xFF,0x17,0x22},
{0xFB,0x01,0x15,0x1E},
{0x00,0x04,0x10,0x18},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* PALFilter_3 */
{0xF5,0xFB,0x1B,0x2A},
{0xEE,0xFE,0x22,0x24},
{0xF3,0x00,0x1D,0x20},
{0xF9,0x03,0x17,0x1A},
{0xFB,0x02,0x14,0x1E},
{0xFB,0x04,0x15,0x18},
{0x00,0x06,0x10,0x14},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* PALFilter_4 */
{0x00,0xE0,0x10,0x60},
{0x00,0xEE,0x10,0x44},
{0x00,0xF4,0x10,0x38},
{0xF8,0xF4,0x18,0x38},
{0xFC,0xFB,0x14,0x2A},
{0x00,0x00,0x10,0x20},
{0x00,0x04,0x10,0x18},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* PALFilter_5 */
{0xF5,0xEE,0x1B,0x44},
{0xF8,0xF4,0x18,0x38},
{0xF1,0xF7,0x1F,0x32},
{0xF5,0xFB,0x1B,0x2A},
{0xF9,0xFF,0x17,0x22},
{0xFB,0x01,0x15,0x1E},
{0x00,0x04,0x10,0x18},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* PALFilter_6 */
{0xF5,0xEE,0x1B,0x2A},
{0xEE,0xFE,0x22,0x24},
{0xF3,0x00,0x1D,0x20},
{0xF9,0x03,0x17,0x1A},
{0xFB,0x02,0x14,0x1E},
{0xFB,0x04,0x15,0x18},
{0x00,0x06,0x10,0x14},
{0xFF,0xFF,0xFF,0xFF} }},
{ {{0x00,0x00,0x00,0x40}, /* PALFilter_7 */
{0xF5,0xEE,0x1B,0x44},
{0xF8,0xF4,0x18,0x38},
{0xFC,0xFB,0x14,0x2A},
{0xEB,0x05,0x25,0x16},
{0xF1,0x05,0x1F,0x16},
{0xFA,0x07,0x16,0x12},
{0x00,0x07,0x10,0x12},
{0xFF,0xFF,0xFF,0xFF} }}
};
static int filter = -1;
static unsigned char filter_tb;
/* ---------------------- Routine prototypes ------------------------- */
/* Interface used by the world */
#ifndef MODULE
XGIINITSTATIC int __init XGIfb_setup(char *options);
#endif
/* Interface to the low level console driver */
/* fbdev routines */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
int XGIfb_init(void);
static int XGIfb_get_fix(struct fb_fix_screeninfo *fix,
int con,
struct fb_info *info);
static int XGIfb_get_var(struct fb_var_screeninfo *var,
int con,
struct fb_info *info);
static int XGIfb_set_var(struct fb_var_screeninfo *var,
int con,
struct fb_info *info);
static void XGIfb_crtc_to_var(struct fb_var_screeninfo *var);
static int XGIfb_get_cmap(struct fb_cmap *cmap,
int kspc,
int con,
struct fb_info *info);
static int XGIfb_set_cmap(struct fb_cmap *cmap,
int kspc,
int con,
struct fb_info *info);
static int XGIfb_update_var(int con,
struct fb_info *info);
static int XGIfb_switch(int con,
struct fb_info *info);
static void XGIfb_blank(int blank,
struct fb_info *info);
static void XGIfb_set_disp(int con,
struct fb_var_screeninfo *var,
struct fb_info *info);
static int XGI_getcolreg(unsigned regno, unsigned *red, unsigned *green,
unsigned *blue, unsigned *transp,
struct fb_info *fb_info);
static void XGIfb_do_install_cmap(int con,
struct fb_info *info);
static void XGI_get_glyph(struct fb_info *info,
XGI_GLYINFO *gly);
static int XGIfb_mmap(struct fb_info *info, struct file *file,
struct vm_area_struct *vma);
static int XGIfb_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg, int con,
struct fb_info *info);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
XGIINITSTATIC int __init xgifb_init(void);
static int XGIfb_set_par(struct fb_info *info);
static int XGIfb_blank(int blank,
struct fb_info *info);
/*static int XGIfb_mmap(struct fb_info *info, struct file *file,
struct vm_area_struct *vma);
*/
extern void fbcon_XGI_fillrect(struct fb_info *info,
const struct fb_fillrect *rect);
extern void fbcon_XGI_copyarea(struct fb_info *info,
const struct fb_copyarea *area);
#if 0
extern void cfb_imageblit(struct fb_info *info,
const struct fb_image *image);
#endif
extern int fbcon_XGI_sync(struct fb_info *info);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
static int XGIfb_ioctl(struct fb_info *info, unsigned int cmd,
unsigned long arg);
#else
static int XGIfb_ioctl(struct inode *inode,
struct file *file,
unsigned int cmd,
unsigned long arg,
struct fb_info *info);
#endif
/*
extern int XGIfb_mode_rate_to_dclock(VB_DEVICE_INFO *XGI_Pr,
PXGI_HW_DEVICE_INFO HwDeviceExtension,
unsigned char modeno, unsigned char rateindex);
extern int XGIfb_mode_rate_to_ddata(VB_DEVICE_INFO *XGI_Pr, PXGI_HW_DEVICE_INFO HwDeviceExtension,
unsigned char modeno, unsigned char rateindex,
unsigned int *left_margin, unsigned int *right_margin,
unsigned int *upper_margin, unsigned int *lower_margin,
unsigned int *hsync_len, unsigned int *vsync_len,
unsigned int *sync, unsigned int *vmode);
*/
#endif
extern BOOLEAN XGI_SearchModeID( USHORT ModeNo,USHORT *ModeIdIndex, PVB_DEVICE_INFO );
static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info);
/* Internal 2D accelerator functions */
extern int XGIfb_initaccel(void);
extern void XGIfb_syncaccel(void);
/* Internal general routines */
static void XGIfb_search_mode(const char *name);
static int XGIfb_validate_mode(int modeindex);
static u8 XGIfb_search_refresh_rate(unsigned int rate);
static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp,
struct fb_info *fb_info);
static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
struct fb_info *info);
static void XGIfb_pre_setmode(void);
static void XGIfb_post_setmode(void);
static BOOLEAN XGIfb_CheckVBRetrace(void);
static BOOLEAN XGIfbcheckvretracecrt2(void);
static BOOLEAN XGIfbcheckvretracecrt1(void);
static BOOLEAN XGIfb_bridgeisslave(void);
struct XGI_memreq {
unsigned long offset;
unsigned long size;
};
/* XGI-specific Export functions */
void XGI_dispinfo(struct ap_data *rec);
void XGI_malloc(struct XGI_memreq *req);
void XGI_free(unsigned long base);
/* Internal hardware access routines */
void XGIfb_set_reg4(u16 port, unsigned long data);
u32 XGIfb_get_reg3(u16 port);
/* Chipset-dependent internal routines */
static int XGIfb_get_dram_size(void);
static void XGIfb_detect_VB(void);
static void XGIfb_get_VB_type(void);
static int XGIfb_has_VB(void);
/* Internal heap routines */
static int XGIfb_heap_init(void);
static XGI_OH *XGIfb_poh_new_node(void);
static XGI_OH *XGIfb_poh_allocate(unsigned long size);
static void XGIfb_delete_node(XGI_OH *poh);
static void XGIfb_insert_node(XGI_OH *pohList, XGI_OH *poh);
static XGI_OH *XGIfb_poh_free(unsigned long base);
static void XGIfb_free_node(XGI_OH *poh);
/* Internal routines to access PCI configuration space */
BOOLEAN XGIfb_query_VGA_config_space(PXGI_HW_DEVICE_INFO pXGIhw_ext,
unsigned long offset, unsigned long set, unsigned long *value);
//BOOLEAN XGIfb_query_north_bridge_space(PXGI_HW_DEVICE_INFO pXGIhw_ext,
// unsigned long offset, unsigned long set, unsigned long *value);
/* Routines from init.c/init301.c */
extern void InitTo330Pointer(UCHAR,PVB_DEVICE_INFO pVBInfo);
extern BOOLEAN XGIInitNew(PXGI_HW_DEVICE_INFO HwDeviceExtension);
extern BOOLEAN XGISetModeNew(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo);
//extern void XGI_SetEnableDstn(VB_DEVICE_INFO *XGI_Pr);
extern void XGI_LongWait(VB_DEVICE_INFO *XGI_Pr);
extern USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
/* TW: Chrontel TV functions */
extern USHORT XGI_GetCH700x(VB_DEVICE_INFO *XGI_Pr, USHORT tempbx);
extern void XGI_SetCH700x(VB_DEVICE_INFO *XGI_Pr, USHORT tempbx);
extern USHORT XGI_GetCH701x(VB_DEVICE_INFO *XGI_Pr, USHORT tempbx);
extern void XGI_SetCH701x(VB_DEVICE_INFO *XGI_Pr, USHORT tempbx);
extern void XGI_SetCH70xxANDOR(VB_DEVICE_INFO *XGI_Pr, USHORT tempax,USHORT tempbh);
extern void XGI_DDC2Delay(VB_DEVICE_INFO *XGI_Pr, USHORT delaytime);
/* TW: Sensing routines */
void XGI_Sense30x(void);
int XGIDoSense(int tempbl, int tempbh, int tempcl, int tempch);
extern XGI21_LVDSCapStruct XGI21_LCDCapList[13];
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef _LINUX_XGIFB
#define _LINUX_XGIFB
#include <linux/spinlock.h>
#include <asm/ioctl.h>
#include <asm/types.h>
#define DISPTYPE_CRT1 0x00000008L
#define DISPTYPE_CRT2 0x00000004L
#define DISPTYPE_LCD 0x00000002L
#define DISPTYPE_TV 0x00000001L
#define DISPTYPE_DISP1 DISPTYPE_CRT1
#define DISPTYPE_DISP2 (DISPTYPE_CRT2 | DISPTYPE_LCD | DISPTYPE_TV)
#define DISPMODE_SINGLE 0x00000020L
#define DISPMODE_MIRROR 0x00000010L
#define DISPMODE_DUALVIEW 0x00000040L
#define HASVB_NONE 0x00
#define HASVB_301 0x01
#define HASVB_LVDS 0x02
#define HASVB_TRUMPION 0x04
#define HASVB_LVDS_CHRONTEL 0x10
#define HASVB_302 0x20
#define HASVB_303 0x40
#define HASVB_CHRONTEL 0x80
#ifndef XGIFB_ID
#define XGIFB_ID 0x53495346 /* Identify myself with 'XGIF' */
#endif
typedef enum _XGI_CHIP_TYPE {
XGI_VGALegacy = 0,
XGI_300,
XGI_630,
XGI_730,
XGI_540,
XGI_315H,
XGI_315,
XGI_315PRO,
XGI_550,
XGI_640,
XGI_740,
XGI_650,
XGI_650M,
XGI_330 = 16,
XGI_660,
XGI_661,
XGI_760,
XG40 = 32,
XG41,
XG42,
XG45,
XG20 = 48,
XG21,
XG27,
MAX_XGI_CHIP
} XGI_CHIP_TYPE;
typedef enum _TVTYPE {
TVMODE_NTSC = 0,
TVMODE_PAL,
TVMODE_HIVISION,
TVTYPE_PALM, // vicki@030226
TVTYPE_PALN, // vicki@030226
TVTYPE_NTSCJ, // vicki@030226
TVMODE_TOTAL
} XGI_TV_TYPE;
typedef struct _XGIFB_INFO XGIfb_info;
struct _XGIFB_INFO {
unsigned long XGIfb_id;
int chip_id; /* PCI ID of detected chip */
int memory; /* video memory in KB which XGIfb manages */
int heapstart; /* heap start (= XGIfb "mem" argument) in KB */
unsigned char fbvidmode; /* current XGIfb mode */
unsigned char XGIfb_version;
unsigned char XGIfb_revision;
unsigned char XGIfb_patchlevel;
unsigned char XGIfb_caps; /* XGIfb capabilities */
int XGIfb_tqlen; /* turbo queue length (in KB) */
unsigned int XGIfb_pcibus; /* The card's PCI ID */
unsigned int XGIfb_pcislot;
unsigned int XGIfb_pcifunc;
unsigned char XGIfb_lcdpdc; /* PanelDelayCompensation */
unsigned char XGIfb_lcda; /* Detected status of LCDA for low res/text modes */
char reserved[235]; /* for future use */
};
typedef enum _TVPLUGTYPE { // vicki@030226
// TVPLUG_Legacy = 0,
// TVPLUG_COMPOSITE,
// TVPLUG_SVIDEO,
// TVPLUG_SCART,
// TVPLUG_TOTAL
TVPLUG_UNKNOWN = 0,
TVPLUG_COMPOSITE = 1,
TVPLUG_SVIDEO = 2,
TVPLUG_COMPOSITE_AND_SVIDEO = 3,
TVPLUG_SCART = 4,
TVPLUG_YPBPR_525i = 5,
TVPLUG_YPBPR_525P = 6,
TVPLUG_YPBPR_750P = 7,
TVPLUG_YPBPR_1080i = 8,
TVPLUG_TOTAL
} XGI_TV_PLUG;
struct mode_info {
int bpp;
int xres;
int yres;
int v_xres;
int v_yres;
int org_x;
int org_y;
unsigned int vrate;
};
struct ap_data {
struct mode_info minfo;
unsigned long iobase;
unsigned int mem_size;
unsigned long disp_state;
XGI_CHIP_TYPE chip;
unsigned char hasVB;
XGI_TV_TYPE TV_type;
XGI_TV_PLUG TV_plug;
unsigned long version;
char reserved[256];
};
/* If changing this, vgatypes.h must also be changed (for X driver) */
/*
* NOTE! The ioctl types used to be "size_t" by mistake, but were
* really meant to be __u32. Changed to "__u32" even though that
* changes the value on 64-bit architectures, because the value
* (with a 4-byte size) is also hardwired in vgatypes.h for user
* space exports. So "__u32" is actually more compatible, duh!
*/
#define XGIFB_GET_INFO _IOR('n',0xF8,__u32)
#define XGIFB_GET_VBRSTATUS _IOR('n',0xF9,__u32)
struct video_info{
int chip_id;
unsigned int video_size;
unsigned long video_base;
char * video_vbase;
unsigned long mmio_base;
char * mmio_vbase;
unsigned long vga_base;
unsigned long mtrr;
unsigned long heapstart;
int video_bpp;
int video_cmap_len;
int video_width;
int video_height;
int video_vwidth;
int video_vheight;
int org_x;
int org_y;
int video_linelength;
unsigned int refresh_rate;
unsigned long disp_state;
unsigned char hasVB;
unsigned char TV_type;
unsigned char TV_plug;
XGI_CHIP_TYPE chip;
unsigned char revision_id;
unsigned short DstColor;
unsigned long XGI310_AccelDepth;
unsigned long CommandReg;
spinlock_t lockaccel;
unsigned int pcibus;
unsigned int pcislot;
unsigned int pcifunc;
int accel;
unsigned short subsysvendor;
unsigned short subsysdevice;
char reserved[236];
};
extern struct video_info xgi_video_info;
#ifdef __KERNEL__
//extern void xgi_malloc(struct xgi_memreq *req);
extern void xgi_free(unsigned long base);
extern void xgi_dispinfo(struct ap_data *rec);
#endif
#endif
#ifndef _OSDEF_H_
#define _OSDEF_H_
/* #define WINCE_HEADER*/
/*#define WIN2000*/
/* #define TC */
#define LINUX_KERNEL
/* #define LINUX_XF86 */
/**********************************************************************/
#ifdef LINUX_KERNEL
//#include <linux/config.h>
#endif
/**********************************************************************/
#ifdef TC
#endif
#ifdef WIN2000
#endif
#ifdef WINCE_HEADER
#endif
#ifdef LINUX_XF86
#define LINUX
#endif
#ifdef LINUX_KERNEL
#define LINUX
#endif
/**********************************************************************/
#ifdef TC
#define XGI_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize);
#endif
#ifdef WIN2000
#define XGI_SetMemory(MemoryAddress,MemorySize,value) MemFill((PVOID) MemoryAddress,(ULONG) MemorySize,(UCHAR) value);
#endif
#ifdef WINCE_HEADER
#define XGI_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize);
#endif
#ifdef LINUX_XF86
#define XGI_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize)
#endif
#ifdef LINUX_KERNEL
#define XGI_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize)
#endif
/**********************************************************************/
/**********************************************************************/
#ifdef TC
#define XGI_MemoryCopy(Destination,Soruce,Length) memmove(Destination, Soruce, Length);
#endif
#ifdef WIN2000
#define XGI_MemoryCopy(Destination,Soruce,Length) /*VideoPortMoveMemory((PUCHAR)Destination , Soruce,length);*/
#endif
#ifdef WINCE_HEADER
#define XGI_MemoryCopy(Destination,Soruce,Length) memmove(Destination, Soruce, Length);
#endif
#ifdef LINUX_XF86
#define XGI_MemoryCopy(Destination,Soruce,Length) memcpy(Destination,Soruce,Length)
#endif
#ifdef LINUX_KERNEL
#define XGI_MemoryCopy(Destination,Soruce,Length) memcpy(Destination,Soruce,Length)
#endif
/**********************************************************************/
#ifdef OutPortByte
#undef OutPortByte
#endif /* OutPortByte */
#ifdef OutPortWord
#undef OutPortWord
#endif /* OutPortWord */
#ifdef OutPortLong
#undef OutPortLong
#endif /* OutPortLong */
#ifdef InPortByte
#undef InPortByte
#endif /* InPortByte */
#ifdef InPortWord
#undef InPortWord
#endif /* InPortWord */
#ifdef InPortLong
#undef InPortLong
#endif /* InPortLong */
/**********************************************************************/
/* TC */
/**********************************************************************/
#ifdef TC
#define OutPortByte(p,v) outp((unsigned short)(p),(unsigned char)(v))
#define OutPortWord(p,v) outp((unsigned short)(p),(unsigned short)(v))
#define OutPortLong(p,v) outp((unsigned short)(p),(unsigned long)(v))
#define InPortByte(p) inp((unsigned short)(p))
#define InPortWord(p) inp((unsigned short)(p))
#define InPortLong(p) ((inp((unsigned short)(p+2))<<16) | inp((unsigned short)(p)))
#endif
/**********************************************************************/
/* LINUX XF86 */
/**********************************************************************/
#ifdef LINUX_XF86
#define OutPortByte(p,v) outb((CARD16)(p),(CARD8)(v))
#define OutPortWord(p,v) outw((CARD16)(p),(CARD16)(v))
#define OutPortLong(p,v) outl((CARD16)(p),(CARD32)(v))
#define InPortByte(p) inb((CARD16)(p))
#define InPortWord(p) inw((CARD16)(p))
#define InPortLong(p) inl((CARD16)(p))
#endif
#ifdef LINUX_KERNEL
#define OutPortByte(p,v) outb((u8)(v),(p))
#define OutPortWord(p,v) outw((u16)(v),(p))
#define OutPortLong(p,v) outl((u32)(v),(p))
#define InPortByte(p) inb(p)
#define InPortWord(p) inw(p)
#define InPortLong(p) inl(p)
#endif
/**********************************************************************/
/* WIN 2000 */
/**********************************************************************/
#ifdef WIN2000
#define OutPortByte(p,v) VideoPortWritePortUchar ((PUCHAR) (p), (UCHAR) (v))
#define OutPortWord(p,v) VideoPortWritePortUshort((PUSHORT) (p), (USHORT) (v))
#define OutPortLong(p,v) VideoPortWritePortUlong ((PULONG) (p), (ULONG) (v))
#define InPortByte(p) VideoPortReadPortUchar ((PUCHAR) (p))
#define InPortWord(p) VideoPortReadPortUshort ((PUSHORT) (p))
#define InPortLong(p) VideoPortReadPortUlong ((PULONG) (p))
#endif
/**********************************************************************/
/* WIN CE */
/**********************************************************************/
#ifdef WINCE_HEADER
#define OutPortByte(p,v) WRITE_PORT_UCHAR ((PUCHAR) (p), (UCHAR) (v))
#define OutPortWord(p,v) WRITE_PORT_USHORT((PUSHORT) (p), (USHORT) (v))
#define OutPortLong(p,v) WRITE_PORT_ULONG ((PULONG) (p), (ULONG) (v))
#define InPortByte(p) READ_PORT_UCHAR ((PUCHAR) (p))
#define InPortWord(p) READ_PORT_USHORT ((PUSHORT) (p))
#define InPortLong(p) READ_PORT_ULONG ((PULONG) (p))
#endif
#endif // _OSDEF_H_
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/xgi/initdef.h,v 1.4 2000/12/02 01:16:17 dawes Exp $ */
#ifndef _INITDEF_
#define _INITDEF_
#ifndef NewScratch
#define NewScratch
#endif
/* shampoo */
#ifdef LINUX_KERNEL
#define SEQ_ADDRESS_PORT 0x0014
#define SEQ_DATA_PORT 0x0015
#define MISC_OUTPUT_REG_READ_PORT 0x001C
#define MISC_OUTPUT_REG_WRITE_PORT 0x0012
#define GRAPH_DATA_PORT 0x1F
#define GRAPH_ADDRESS_PORT 0x1E
#define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
#define CRTC_ADDRESS_PORT_COLOR 0x0024
#define VIDEO_SUBSYSTEM_ENABLE_PORT 0x0013
#define PCI_COMMAND 0x04
#endif
/* ~shampoo */
#define VB_XGI301 0x0001 /*301b*/
#define VB_XGI301B 0x0002
#define VB_XGI302B 0x0004
#define VB_XGI301LV 0x0008 /*301lv*/
#define VB_XGI302LV 0x0010
#define VB_XGI301C 0x0020 /* for 301C */
#define VB_NoLCD 0x8000
/*end 301b*/
#define VB_YPbPrInfo 0x07 /*301lv*/
#define VB_YPbPr525i 0x00
#define VB_YPbPr525p 0x01
#define VB_YPbPr750p 0x02
#define VB_YPbPr1080i 0x03
/* #define CRT1Len 17 */
#define LVDSCRT1Len 15
#define CHTVRegDataLen 5
/* #define ModeInfoFlag 0x07 */
/* #define IsTextMode 0x07 */
/* #define ModeText 0x00 */
/* #define ModeCGA 0x01 */
/* #define ModeEGA 0x02 */
/* #define ModeVGA 0x03 */
/* #define Mode15Bpp 0x04 */
/* #define Mode16Bpp 0x05 */
/* #define Mode24Bpp 0x06 */
/* #define Mode32Bpp 0x07 */
/* #define DACInfoFlag 0x18 */
/* #define MemoryInfoFlag 0x1E0 */
/* #define MemorySizeShift 0x05 */
#define Charx8Dot 0x0200
#define LineCompareOff 0x0400
#define CRT2Mode 0x0800
#define HalfDCLK 0x1000
#define NoSupportSimuTV 0x2000
#define DoubleScanMode 0x8000
#define SupportAllCRT2 0x0078
#define SupportTV 0x0008
#define SupportHiVisionTV 0x0010
#define SupportLCD 0x0020
#define SupportRAMDAC2 0x0040
#define NoSupportTV 0x0070
#define NoSupportHiVisionTV 0x0060
#define NoSupportLCD 0x0058
#define SupportCHTV 0x0800
#define SupportCRT2in301C 0x0100 /* for 301C */
#define SupportTV1024 0x0800 /*301b*/
#define SupportYPbPr 0x1000 /*301lv*/
#define InterlaceMode 0x0080
#define SyncPP 0x0000
#define SyncPN 0x4000
#define SyncNP 0x8000
/* #define SyncNN 0xc000 */
#define ECLKindex0 0x0000
#define ECLKindex1 0x0100
#define ECLKindex2 0x0200
#define ECLKindex3 0x0300
#define ECLKindex4 0x0400
#define SetSimuScanMode 0x0001
#define SwitchToCRT2 0x0002
/* #define SetCRT2ToTV 0x009C */
#define SetCRT2ToAVIDEO 0x0004
#define SetCRT2ToSVIDEO 0x0008
#define SetCRT2ToSCART 0x0010
#define SetCRT2ToLCD 0x0020
#define SetCRT2ToRAMDAC 0x0040
#define SetCRT2ToHiVisionTV 0x0080
#define SetNTSCTV 0x0000
/* #define SetPALTV 0x0100 */
#define SetInSlaveMode 0x0200
#define SetNotSimuMode 0x0400
#define SetNotSimuTVMode 0x0400
#define SetDispDevSwitch 0x0800
#define LoadDACFlag 0x1000
#define DisableCRT2Display 0x2000
#define DriverMode 0x4000
#define HotKeySwitch 0x8000
#define SetCHTVOverScan 0x8000
/* #define SetCRT2ToLCDA 0x8000 301b */
#define PanelRGB18Bit 0x0100
#define PanelRGB24Bit 0x0000
#define TVOverScan 0x10
#define TVOverScanShift 4
#define ClearBufferFlag 0x20
#define EnableDualEdge 0x01 /*301b*/
#define SetToLCDA 0x02
#define YPbPrModeInfo 0x38
/* #define YPbPrMode525i 0x00 */
/* #define YPbPrMode525p 0x08 */
/* #define YPbPrMode750p 0x10 */
/* #define YPbPrMode1080i 0x18 */
#define SetSCARTOutput 0x01
#define BoardTVType 0x02
#define EnablePALMN 0x40
/* #define ProgrammingCRT2 0x01 */
/* #define TVSimuMode 0x02 */
/* #define RPLLDIV2XO 0x04 */
/* #define LCDVESATiming 0x08 */
/* #define EnableLVDSDDA 0x10 */
#define SetDispDevSwitchFlag 0x20
#define CheckWinDos 0x40
#define SetJDOSMode 0x80
#define Panel320x480 0x07/*fstn*/
/* [ycchen] 02/12/03 Modify for Multi-Sync. LCD Support */
#define PanelResInfo 0x1F /* CR36 Panel Type/LCDResInfo */
#define PanelRefInfo 0x60
#define Panel800x600 0x01
#define Panel1024x768 0x02
#define Panel1024x768x75 0x22
#define Panel1280x1024 0x03
#define Panel1280x1024x75 0x23
#define Panel640x480 0x04
#define Panel1024x600 0x05
#define Panel1152x864 0x06
#define Panel1280x960 0x07
#define Panel1152x768 0x08
#define Panel1400x1050 0x09
#define Panel1280x768 0x0A
#define Panel1600x1200 0x0B
#define PanelRef60Hz 0x00
#define PanelRef75Hz 0x20
#define LCDRGB18Bit 0x01
#define ExtChipTrumpion 0x06
#define ExtChipCH7005 0x08
#define ExtChipMitacTV 0x0a
#define LCDNonExpanding 0x10
#define LCDNonExpandingShift 4
#define LCDSync 0x20
#define LCDSyncBit 0xe0
#define LCDSyncShift 6
/* #define DDC2DelayTime 300 */
#define CRT2DisplayFlag 0x2000
/* #define LCDDataLen 8 */
/* #define HiTVDataLen 12 */
/* #define TVDataLen 16 */
/* #define SetPALTV 0x0100 */
#define HalfDCLK 0x1000
#define NTSCHT 1716
#define NTSCVT 525
#define PALHT 1728
#define PALVT 625
#define StHiTVHT 892
#define StHiTVVT 1126
#define StHiTextTVHT 1000
#define StHiTextTVVT 1126
#define ExtHiTVHT 2100
#define ExtHiTVVT 1125
#define St750pTVHT 1716
#define St750pTVVT 525
#define Ext750pTVHT 1716
#define Ext750pTVVT 525
#define St525pTVHT 1716
#define St525pTVVT 525
#define Ext525pTVHT 1716
#define Ext525pTVVT 525
#define St525iTVHT 1716
#define St525iTVVT 525
#define Ext525iTVHT 1716
#define Ext525iTVVT 525
#define VCLKStartFreq 25
#define SoftDramType 0x80
#define VCLK40 0x04
#define VCLK162 0x21
#define LCDRGB18Bit 0x01
#define LoadDACFlag 0x1000
#define AfterLockCRT2 0x4000
#define SetCRT2ToAVIDEO 0x0004
#define SetCRT2ToSCART 0x0010
#define Ext2StructSize 5
#define YPbPr525iVCLK 0x03B
#define YPbPr525iVCLK_2 0x03A
#define SwitchToCRT2 0x0002
/* #define LCDVESATiming 0x08 */
#define SetSCARTOutput 0x01
#define AVIDEOSense 0x01
#define SVIDEOSense 0x02
#define SCARTSense 0x04
#define LCDSense 0x08
#define Monitor1Sense 0x20
#define Monitor2Sense 0x10
#define HiTVSense 0x40
#define BoardTVType 0x02
#define HotPlugFunction 0x08
#define StStructSize 0x06
#define XGI_CRT2_PORT_00 0x00 - 0x030
#define XGI_CRT2_PORT_04 0x04 - 0x030
#define XGI_CRT2_PORT_10 0x10 - 0x30
#define XGI_CRT2_PORT_12 0x12 - 0x30
#define XGI_CRT2_PORT_14 0x14 - 0x30
#define LCDNonExpanding 0x10
#define ADR_CRT2PtrData 0x20E
#define offset_Zurac 0x210
#define ADR_LVDSDesPtrData 0x212
#define ADR_LVDSCRT1DataPtr 0x214
#define ADR_CHTVVCLKPtr 0x216
#define ADR_CHTVRegDataPtr 0x218
#define LVDSDataLen 6
/* #define EnableLVDSDDA 0x10 */
/* #define LVDSDesDataLen 3 */
#define ActiveNonExpanding 0x40
#define ActiveNonExpandingShift 6
/* #define ActivePAL 0x20 */
#define ActivePALShift 5
/* #define ModeSwitchStatus 0x0F */
#define SoftTVType 0x40
#define SoftSettingAddr 0x52
#define ModeSettingAddr 0x53
/* #define SelectCRT1Rate 0x4 */
#define _PanelType00 0x00
#define _PanelType01 0x08
#define _PanelType02 0x10
#define _PanelType03 0x18
#define _PanelType04 0x20
#define _PanelType05 0x28
#define _PanelType06 0x30
#define _PanelType07 0x38
#define _PanelType08 0x40
#define _PanelType09 0x48
#define _PanelType0A 0x50
#define _PanelType0B 0x58
#define _PanelType0C 0x60
#define _PanelType0D 0x68
#define _PanelType0E 0x70
#define _PanelType0F 0x78
#define PRIMARY_VGA 0 /* 1: XGI is primary vga 0:XGI is secondary vga */
#define BIOSIDCodeAddr 0x235
#define OEMUtilIDCodeAddr 0x237
#define VBModeIDTableAddr 0x239
#define OEMTVPtrAddr 0x241
#define PhaseTableAddr 0x243
#define NTSCFilterTableAddr 0x245
#define PALFilterTableAddr 0x247
#define OEMLCDPtr_1Addr 0x249
#define OEMLCDPtr_2Addr 0x24B
#define LCDHPosTable_1Addr 0x24D
#define LCDHPosTable_2Addr 0x24F
#define LCDVPosTable_1Addr 0x251
#define LCDVPosTable_2Addr 0x253
#define OEMLCDPIDTableAddr 0x255
#define VBModeStructSize 5
#define PhaseTableSize 4
#define FilterTableSize 4
#define LCDHPosTableSize 7
#define LCDVPosTableSize 5
#define OEMLVDSPIDTableSize 4
#define LVDSHPosTableSize 4
#define LVDSVPosTableSize 6
#define VB_ModeID 0
#define VB_TVTableIndex 1
#define VB_LCDTableIndex 2
#define VB_LCDHIndex 3
#define VB_LCDVIndex 4
#define OEMLCDEnable 0x0001
#define OEMLCDDelayEnable 0x0002
#define OEMLCDPOSEnable 0x0004
#define OEMTVEnable 0x0100
#define OEMTVDelayEnable 0x0200
#define OEMTVFlickerEnable 0x0400
#define OEMTVPhaseEnable 0x0800
#define OEMTVFilterEnable 0x1000
#define OEMLCDPanelIDSupport 0x0080
/* #define LCDVESATiming 0x0001 //LCD Info CR37 */
/* #define EnableLVDSDDA 0x0002 */
#define EnableScalingLCD 0x0008
#define SetPWDEnable 0x0004
#define SetLCDtoNonExpanding 0x0010
/* #define SetLCDPolarity 0x00E0 */
#define SetLCDDualLink 0x0100
#define SetLCDLowResolution 0x0200
#define SetLCDStdMode 0x0400
#define SetTVStdMode 0x0200
#define SetTVLowResolution 0x0400
/* =============================================================
for 310
============================================================== */
#define SoftDRAMType 0x80
#define SoftSetting_OFFSET 0x52
#define SR07_OFFSET 0x7C
#define SR15_OFFSET 0x7D
#define SR16_OFFSET 0x81
#define SR17_OFFSET 0x85
#define SR19_OFFSET 0x8D
#define SR1F_OFFSET 0x99
#define SR21_OFFSET 0x9A
#define SR22_OFFSET 0x9B
#define SR23_OFFSET 0x9C
#define SR24_OFFSET 0x9D
#define SR25_OFFSET 0x9E
#define SR31_OFFSET 0x9F
#define SR32_OFFSET 0xA0
#define SR33_OFFSET 0xA1
#define CR40_OFFSET 0xA2
#define SR25_1_OFFSET 0xF6
#define CR49_OFFSET 0xF7
#define VB310Data_1_2_Offset 0xB6
#define VB310Data_4_D_Offset 0xB7
#define VB310Data_4_E_Offset 0xB8
#define VB310Data_4_10_Offset 0xBB
#define RGBSenseDataOffset 0xBD
#define YCSenseDataOffset 0xBF
#define VideoSenseDataOffset 0xC1
#define OutputSelectOffset 0xF3
#define ECLK_MCLK_DISTANCE 0x14
#define VBIOSTablePointerStart 0x200
#define StandTablePtrOffset VBIOSTablePointerStart+0x02
#define EModeIDTablePtrOffset VBIOSTablePointerStart+0x04
#define CRT1TablePtrOffset VBIOSTablePointerStart+0x06
#define ScreenOffsetPtrOffset VBIOSTablePointerStart+0x08
#define VCLKDataPtrOffset VBIOSTablePointerStart+0x0A
#define MCLKDataPtrOffset VBIOSTablePointerStart+0x0E
#define CRT2PtrDataPtrOffset VBIOSTablePointerStart+0x10
#define TVAntiFlickPtrOffset VBIOSTablePointerStart+0x12
#define TVDelayPtr1Offset VBIOSTablePointerStart+0x14
#define TVPhaseIncrPtr1Offset VBIOSTablePointerStart+0x16
#define TVYFilterPtr1Offset VBIOSTablePointerStart+0x18
#define LCDDelayPtr1Offset VBIOSTablePointerStart+0x20
#define TVEdgePtr1Offset VBIOSTablePointerStart+0x24
#define CRT2Delay1Offset VBIOSTablePointerStart+0x28
#define LCDDataDesOffset VBIOSTablePointerStart-0x02
#define LCDDataPtrOffset VBIOSTablePointerStart+0x2A
#define LCDDesDataPtrOffset VBIOSTablePointerStart+0x2C
#define LCDDataList VBIOSTablePointerStart+0x22 /* add for GetLCDPtr */
#define TVDataList VBIOSTablePointerStart+0x36 /* add for GetTVPtr */
/* */
/* Modify from 310.inc */
/* */
/* */
#define ShowMsgFlag 0x20 /* SoftSetting */
#define ShowVESAFlag 0x10
#define HotPlugFunction 0x08
#define ModeSoftSetting 0x04
#define TVSoftSetting 0x02
#define LCDSoftSetting 0x01
#define GatingCRTinLCDA 0x10
#define SetHiTVOutput 0x08
#define SetYPbPrOutput 0x04
#define BoardTVType 0x02
#define SetSCARTOutput 0x01
#define ModeSettingYPbPr 0x02 /* TVModeSetting, Others as same as CR30 */
/* TVModeSetting same as CR35 */
/* LCDModeSetting same as CR37 */
#define EnableNewTVFont 0x10 /* MiscCapability */
#define EnableLCDOutput 0x80 /* LCDCfgSetting */
#define SoftDRAMType 0x80 /* DRAMSetting */
#define SoftDRAMConfig 0x40
#define MosSelDRAMType 0x20
#define SDRAM 000h
#define SGRAM 0x01
#define ESDRAM 0x02
#define EnableAGPCfgSetting 0x01 /* AGPCfgSetting */
/* ---------------- SetMode Stack */
#define CRT1Len 15
#define VCLKLen 4
#define DefThreshold 0x0100
#define ExtRegsSize (57+8+37+70+63+28+768+1)/64+1
#define VGA_XGI315 0x0001 /* VGA Type Info */
#define VGA_SNewis315e 0x0002 /* 315 series */
#define VGA_XGI550 0x0004
#define VGA_XGI640 0x0008
#define VGA_XGI740 0x0010
#define VGA_XGI650 0x0020
#define VGA_XGI650M 0x0040
#define VGA_XGI651 0x0080
#define VGA_XGI340 0x0001 /* 340 series */
#define VGA_XGI330 0x0001 /* 330 series */
#define VGA_XGI660 0x0001 /* 660 series */
#define VB_XGI301 0x0001 /* VB Type Info */
#define VB_XGI301B 0x0002 /* 301 series */
#define VB_XGI302B 0x0004
#define VB_NoLCD 0x8000
#define VB_XGI301LV 0x0008
#define VB_XGI302LV 0x0010
#define VB_LVDS_NS 0x0001 /* 3rd party chip */
#define VB_CH7017 0x0002
#define VB_CH7007 0x0080 /* [Billy] 07/05/03 */
/* #define VB_LVDS_SI 0x0004 */
#define ModeInfoFlag 0x0007
#define IsTextMode 0x0007
#define ModeText 0x0000
#define ModeCGA 0x0001
#define ModeEGA 0x0002 /* 16 colors mode */
#define ModeVGA 0x0003 /* 256 colors mode */
#define Mode15Bpp 0x0004 /* 15 Bpp Color Mode */
#define Mode16Bpp 0x0005 /* 16 Bpp Color Mode */
#define Mode24Bpp 0x0006 /* 24 Bpp Color Mode */
#define Mode32Bpp 0x0007 /* 32 Bpp Color Mode */
#define DACInfoFlag 0x0018
#define MONODAC 0x0000
#define CGADAC 0x0008
#define EGADAC 0x0010
#define VGADAC 0x0018
#define MemoryInfoFlag 0x01e0
#define MemorySizeShift 5
#define Need1MSize 0x0000
#define Need2MSize 0x0020
#define Need4MSize 0x0060
#define Need8MSize 0x00e0
#define Need16MSize 0x01e0
#define Charx8Dot 0x0200
#define LineCompareOff 0x0400
#define CRT2Mode 0x0800
#define HalfDCLK 0x1000
#define NoSupportSimuTV 0x2000
#define DoubleScanMode 0x8000
/* -------------- Ext_InfoFlag */
#define SupportModeInfo 0x0007
#define Support256 0x0003
#define Support15Bpp 0x0004
#define Support16Bpp 0x0005
#define Support24Bpp 0x0006
#define Support32Bpp 0x0007
#define SupportAllCRT2 0x0078
#define SupportTV 0x0008
#define SupportHiVisionTV 0x0010
#define SupportLCD 0x0020
#define SupportRAMDAC2 0x0040
#define NoSupportTV 0x0070
#define NoSupportHiVisionTV 0x0060
#define NoSupportLCD 0x0058
#define SupportTV1024 0x0800 /* 301btest */
#define SupportYPbPr 0x1000 /* 301lv */
#define InterlaceMode 0x0080
#define SyncPP 0x0000
#define SyncPN 0x4000
#define SyncNP 0x8000
#define SyncNN 0xC000
/* -------------- SetMode Stack/Scratch */
#define SetSimuScanMode 0x0001 /* VBInfo/CR30 & CR31 */
#define SwitchToCRT2 0x0002
#define SetCRT2ToTV1 0x009C
#define SetCRT2ToTV 0x089C
#define SetCRT2ToAVIDEO 0x0004
#define SetCRT2ToSVIDEO 0x0008
#define SetCRT2ToSCART 0x0010
#define SetCRT2ToLCD 0x0020
#define SetCRT2ToRAMDAC 0x0040
#define SetCRT2ToHiVisionTV 0x0080
#define SetCRT2ToLCDA 0x0100
#define SetInSlaveMode 0x0200
#define SetNotSimuMode 0x0400
#define HKEventMode 0x0800
#define SetCRT2ToYPbPr 0x0800
#define LoadDACFlag 0x1000
#define DisableCRT2Display 0x2000
#define DriverMode 0x4000
#define SetCRT2ToDualEdge 0x8000
#define HotKeySwitch 0x8000
#define ProgrammingCRT2 0x0001 /* Set Flag */
#define EnableVCMode 0x0002
#define SetHKEventMode 0x0004
#define ReserveTVOption 0x0008
#define DisableRelocateIO 0x0010
#define Win9xDOSMode 0x0020
#define JDOSMode 0x0040
/* #define SetWin9xforJap 0x0080 // not used now */
/* #define SetWin9xforKorea 0x0100 // not used now */
#define GatingCRT 0x0800
#define DisableChB 0x1000
#define EnableChB 0x2000
#define DisableChA 0x4000
#define EnableChA 0x8000
#define SetNTSCTV 0x0000 /* TV Info */
#define SetPALTV 0x0001
#define SetNTSCJ 0x0002
#define SetPALMTV 0x0004
#define SetPALNTV 0x0008
#define SetCHTVUnderScan 0x0000
/* #define SetCHTVOverScan 0x0010 */
#define SetYPbPrMode525i 0x0020
#define SetYPbPrMode525p 0x0040
#define SetYPbPrMode750p 0x0080
#define SetYPbPrMode1080i 0x0100
#define SetTVStdMode 0x0200
#define SetTVLowResolution 0x0400
#define SetTVSimuMode 0x0800
#define TVSimuMode 0x0800
#define RPLLDIV2XO 0x1000
#define NTSC1024x768 0x2000
#define SetTVLockMode 0x4000
#define LCDVESATiming 0x0001 /* LCD Info/CR37 */
#define EnableLVDSDDA 0x0002
#define EnableScalingLCD 0x0008
#define SetPWDEnable 0x0004
#define SetLCDtoNonExpanding 0x0010
#define SetLCDPolarity 0x00e0
#define SetLCDDualLink 0x0100
#define SetLCDLowResolution 0x0200
#define SetLCDStdMode 0x0400
#define DefaultLCDCap 0x80ea /* LCD Capability shampoo */
#define RLVDSDHL00 0x0000
#define RLVDSDHL01 0x0001
#define RLVDSDHL10 0x0002 /* default */
#define RLVDSDHL11 0x0003
#define EnableLCD24bpp 0x0004 /* default */
#define DisableLCD24bpp 0x0000
#define RLVDSClkSFT0 0x0000
#define RLVDSClkSFT1 0x0008 /* default */
#define EnableLVDSDCBal 0x0010
#define DisableLVDSDCBal 0x0000 /* default */
#define SinglePolarity 0x0020 /* default */
#define MultiPolarity 0x0000
#define LCDPolarity 0x00c0 /* default: SyncNN */
#define LCDSingleLink 0x0000 /* default */
#define LCDDualLink 0x0100
#define EnableSpectrum 0x0200
#define DisableSpectrum 0x0000 /* default */
#define PWDEnable 0x0400
#define PWDDisable 0x0000 /* default */
#define PWMEnable 0x0800
#define PWMDisable 0x0000 /* default */
#define EnableVBCLKDRVLOW 0x4000
#define EnableVBCLKDRVHigh 0x0000 /* default */
#define EnablePLLSPLOW 0x8000
#define EnablePLLSPHigh 0x0000 /* default */
#define LCDBToA 0x20 /* LCD SetFlag */
#define StLCDBToA 0x40
#define LockLCDBToA 0x80
#define LCDToFull 0x10
#define AVIDEOSense 0x01 /* CR32 */
#define SVIDEOSense 0x02
#define SCARTSense 0x04
#define LCDSense 0x08
#define Monitor2Sense 0x10
#define Monitor1Sense 0x20
#define HiTVSense 0x40
#ifdef NewScratch
#define YPbPrSense 0x80 /* NEW SCRATCH */
#endif
#define TVSense 0xc7
#define TVOverScan 0x10 /* CR35 */
#define TVOverScanShift 4
#ifdef NewScratch
#define NTSCMode 0x00
#define PALMode 0x00
#define NTSCJMode 0x02
#define PALMNMode 0x0c
#define YPbPrMode 0xe0
#define YPbPrMode525i 0x00
#define YPbPrMode525p 0x20
#define YPbPrMode750p 0x40
#define YPbPrMode1080i 0x60
#else /* Old Scratch */
#define ClearBufferFlag 0x20
#endif
#define LCDRGB18Bit 0x01 /* CR37 */
#define LCDNonExpanding 0x10
#define LCDNonExpandingShift 4
#define LCDSync 0x20
#define LCDSyncBit 0xe0 /* H/V polarity & sync ID */
#define LCDSyncShift 6
#ifdef NewScratch
#define ScalingLCD 0x08
#else /* Old Scratch */
#define ExtChipType 0x0e
#define ExtChip301 0x02
#define ExtChipLVDS 0x04
#define ExtChipCH7019 0x06
#define ScalingLCD 0x10
#endif
#define EnableDualEdge 0x01 /* CR38 */
#define SetToLCDA 0x02
#ifdef NewScratch
#define SetYPbPr 0x04
#define DisableChannelA 0x08
#define DisableChannelB 0x10
#define ExtChipType 0xe0
#define ExtChip301 0x20
#define ExtChipLVDS 0x40
#define ExtChipCH7019 0x60
#else /* Old Scratch */
#define YPbPrSense 0x04
#define SetYPbPr 0x08
#define YPbPrMode 0x30
#define YPbPrMode525i 0x00
#define YPbPrMode525p 0x10
#define YPbPrMode750p 0x20
#define YPbPrMode1080i 0x30
#define PALMNMode 0xc0
#endif
#define BacklightControlBit 0x01 /* CR3A */
#define Win9xforJap 0x40
#define Win9xforKorea 0x80
#define ForceMDBits 0x07 /* CR3B */
#define ForceMD_JDOS 0x00
#define ForceMD_640x400T 0x01
#define ForceMD_640x350T 0x02
#define ForceMD_720x400T 0x03
#define ForceMD_640x480E 0x04
#define ForceMD_640x400E 0x05
#define ForceP1Bit 0x10
#define ForceP2Bit 0x20
#define EnableForceMDinBIOS 0x40
#define EnableForceMDinDrv 0x80
#ifdef NewScratch /* New Scratch */
/* ---------------------- VUMA Information */
#define LCDSettingFromCMOS 0x04 /* CR3C */
#define TVSettingFromCMOS 0x08
#define DisplayDeviceFromCMOS 0x10
#define HKSupportInSBIOS 0x20
#define OSDSupportInSBIOS 0x40
#define DisableLogo 0x80
/* ---------------------- HK Evnet Definition */
#define HKEvent 0x0f /* CR3D */
#define HK_ModeSwitch 0x01
#define HK_Expanding 0x02
#define HK_OverScan 0x03
#define HK_Brightness 0x04
#define HK_Contrast 0x05
#define HK_Mute 0x06
#define HK_Volume 0x07
#define ModeSwitchStatus 0xf0
#define ActiveCRT1 0x10
#define ActiveLCD 0x0020
#define ActiveTV 0x40
#define ActiveCRT2 0x80
#define TVSwitchStatus 0x1f /* CR3E */
#define ActiveAVideo 0x01
#define ActiveSVideo 0x02
#define ActiveSCART 0x04
#define ActiveHiTV 0x08
#define ActiveYPbPr 0x10
#define EnableHKEvent 0x01 /* CR3F */
#define EnableOSDEvent 0x02
#define StartOSDEvent 0x04
#define IgnoreHKEvent 0x08
#define IgnoreOSDEvent 0x10
#else /* Old Scratch */
#define OSD_SBIOS 0x02 /* SR17 */
#define DisableLogo 0x04
#define SelectKDOS 0x08
#define KorWinMode 0x10
#define KorMode3Bit 0x0020
#define PSCCtrlBit 0x40
#define NPSCCtrlBitShift 6
#define BlueScreenBit 0x80
#define HKEvent 0x0f /* CR79 */
#define HK_ModeSwitch 0x01
#define HK_Expanding 0x02
#define HK_OverScan 0x03
#define HK_Brightness 0x04
#define HK_Contrast 0x05
#define HK_Mute 0x06
#define HK_Volume 0x07
#define ActivePAL 0x0020
#define ActivePALShift 5
#define ActiveNonExpanding 0x40
#define ActiveNonExpandingShift 6
#define ActiveOverScan 0x80
#define ActiveOverScanShift 7
#define ModeSwitchStatus 0x0b /* SR15 */
#define ActiveCRT1 0x01
#define ActiveLCD 0x02
#define ActiveCRT2 0x08
#define TVSwitchStatus 0xf0 /* SR16 */
#define TVConfigShift 3
#define ActiveTV 0x01
#define ActiveYPbPr 0x04
#define ActiveAVideo 0x10
#define ActiveSVideo 0x0020
#define ActiveSCART 0x40
#define ActiveHiTV 0x80
#define EnableHKEvent 0x01 /* CR7A */
#define EnableOSDEvent 0x02
#define StartOSDEvent 0x04
#define CMOSSupport 0x08
#define HotKeySupport 0x10
#define IngoreHKOSDEvent 0x20
#endif
/* //------------- Misc. Definition */
#define SelectCRT1Rate 00h
/* #define SelectCRT2Rate 04h */
#define DDC1DelayTime 1000
#ifdef TRUMPION
#define DDC2DelayTime 15
#else
#define DDC2DelayTime 150
#endif
#define R_FACTOR 04Dh
#define G_FACTOR 097h
#define B_FACTOR 01Ch
/* --------------------------------------------------------- */
/* translated from asm code 301def.h */
/* */
/* --------------------------------------------------------- */
#define LCDDataLen 8
#define HiTVDataLen 12
#define TVDataLen 12
#define LVDSCRT1Len_H 8
#define LVDSCRT1Len_V 7
#define LVDSDataLen 6
#define LVDSDesDataLen 6
#define LCDDesDataLen 6
#define LVDSDesDataLen2 8
#define LCDDesDataLen2 8
#define CHTVRegLen 16
#define CHLVRegLen 12
#define StHiTVHT 892
#define StHiTVVT 1126
#define StHiTextTVHT 1000
#define StHiTextTVVT 1126
#define ExtHiTVHT 2100
#define ExtHiTVVT 1125
#define NTSCHT 1716
#define NTSCVT 525
#define NTSC1024x768HT 1908
#define NTSC1024x768VT 525
#define PALHT 1728
#define PALVT 625
#define YPbPrTV525iHT 1716 /* YPbPr */
#define YPbPrTV525iVT 525
#define YPbPrTV525pHT 1716
#define YPbPrTV525pVT 525
#define YPbPrTV750pHT 1650
#define YPbPrTV750pVT 750
#define CRT2VCLKSel 0xc0
#define CRT2Delay1 0x04 /* XGI301 */
#define CRT2Delay2 0x0A /* 301B,302 */
#define VCLK25_175 0x00
#define VCLK28_322 0x01
#define VCLK31_5 0x02
#define VCLK36 0x03
#define VCLK40 0x04
#define VCLK43_163 0x05
#define VCLK44_9 0x06
#define VCLK49_5 0x07
#define VCLK50 0x08
#define VCLK52_406 0x09
#define VCLK56_25 0x0A
#define VCLK65 0x0B
#define VCLK67_765 0x0C
#define VCLK68_179 0x0D
#define VCLK72_852 0x0E
#define VCLK75 0x0F
#define VCLK75_8 0x10
#define VCLK78_75 0x11
#define VCLK79_411 0x12
#define VCLK83_95 0x13
#define VCLK84_8 0x14
#define VCLK86_6 0x15
#define VCLK94_5 0x16
#define VCLK104_998 0x17
#define VCLK105_882 0x18
#define VCLK108_2 0x19
#define VCLK109_175 0x1A
#define VCLK113_309 0x1B
#define VCLK116_406 0x1C
#define VCLK132_258 0x1D
#define VCLK135_5 0x1E
#define VCLK139_054 0x1F
#define VCLK157_5 0x20
#define VCLK162 0x21
#define VCLK175 0x22
#define VCLK189 0x23
#define VCLK194_4 0x24
#define VCLK202_5 0x25
#define VCLK229_5 0x26
#define VCLK234 0x27
#define VCLK252_699 0x28
#define VCLK254_817 0x29
#define VCLK265_728 0x2A
#define VCLK266_952 0x2B
#define VCLK269_655 0x2C
#define VCLK272_042 0x2D
#define VCLK277_015 0x2E
#define VCLK286_359 0x2F
#define VCLK291_132 0x30
#define VCLK291_766 0x31
#define VCLK309_789 0x32
#define VCLK315_195 0x33
#define VCLK323_586 0x34
#define VCLK330_615 0x35
#define VCLK332_177 0x36
#define VCLK340_477 0x37
#define VCLK375_847 0x38
#define VCLK388_631 0x39
#define VCLK125_999 0x51
#define VCLK148_5 0x52
#define VCLK178_992 0x54
#define VCLK217_325 0x55
#define VCLK299_505 0x56
#define YPbPr750pVCLK 0x57
#define TVVCLKDIV2 0x3A
#define TVVCLK 0x3B
#define HiTVVCLKDIV2 0x3C
#define HiTVVCLK 0x3D
#define HiTVSimuVCLK 0x3E
#define HiTVTextVCLK 0x3F
#define VCLK39_77 0x40
/* #define YPbPr750pVCLK 0x0F */
#define YPbPr525pVCLK 0x3A
/* #define ;;YPbPr525iVCLK 0x3B */
/* #define ;;YPbPr525iVCLK_2 0x3A */
#define NTSC1024VCLK 0x41
#define VCLK25_175_41 0x42 /* ; ScaleLCD */
#define VCLK25_175_42 0x43
#define VCLK28_322_43 0x44
#define VCLK40_44 0x45
#define VCLKQVGA_1 0x46 /* ; QVGA */
#define VCLKQVGA_2 0x47
#define VCLKQVGA_3 0x48
#define VCLK35_2 0x49 /* ; 800x480 */
#define VCLK122_61 0x4A
#define VCLK80_350 0x4B
#define VCLK107_385 0x4C
#define CHTVVCLK30_2 0x50 /* ;;CHTV */
#define CHTVVCLK28_1 0x51
#define CHTVVCLK43_6 0x52
#define CHTVVCLK26_4 0x53
#define CHTVVCLK24_6 0x54
#define CHTVVCLK47_8 0x55
#define CHTVVCLK31_5 0x56
#define CHTVVCLK26_2 0x57
#define CHTVVCLK39 0x58
#define CHTVVCLK36 0x59
#define CH7007TVVCLK30_2 0x00 /* [Billy] 2007/05/18 For CH7007 */
#define CH7007TVVCLK28_1 0x01
#define CH7007TVVCLK43_6 0x02
#define CH7007TVVCLK26_4 0x03
#define CH7007TVVCLK24_6 0x04
#define CH7007TVVCLK47_8 0x05
#define CH7007TVVCLK31_5 0x06
#define CH7007TVVCLK26_2 0x07
#define CH7007TVVCLK39 0x08
#define CH7007TVVCLK36 0x09
#define RES320x200 0x00
#define RES320x240 0x01
#define RES400x300 0x02
#define RES512x384 0x03
#define RES640x400 0x04
#define RES640x480x60 0x05
#define RES640x480x72 0x06
#define RES640x480x75 0x07
#define RES640x480x85 0x08
#define RES640x480x100 0x09
#define RES640x480x120 0x0A
#define RES640x480x160 0x0B
#define RES640x480x200 0x0C
#define RES800x600x56 0x0D
#define RES800x600x60 0x0E
#define RES800x600x72 0x0F
#define RES800x600x75 0x10
#define RES800x600x85 0x11
#define RES800x600x100 0x12
#define RES800x600x120 0x13
#define RES800x600x160 0x14
#define RES1024x768x43 0x15
#define RES1024x768x60 0x16
#define RES1024x768x70 0x17
#define RES1024x768x75 0x18
#define RES1024x768x85 0x19
#define RES1024x768x100 0x1A
#define RES1024x768x120 0x1B
#define RES1280x1024x43 0x1C
#define RES1280x1024x60 0x1D
#define RES1280x1024x75 0x1E
#define RES1280x1024x85 0x1F
#define RES1600x1200x60 0x20
#define RES1600x1200x65 0x21
#define RES1600x1200x70 0x22
#define RES1600x1200x75 0x23
#define RES1600x1200x85 0x24
#define RES1600x1200x100 0x25
#define RES1600x1200x120 0x26
#define RES1920x1440x60 0x27
#define RES1920x1440x65 0x28
#define RES1920x1440x70 0x29
#define RES1920x1440x75 0x2A
#define RES1920x1440x85 0x2B
#define RES1920x1440x100 0x2C
#define RES2048x1536x60 0x2D
#define RES2048x1536x65 0x2E
#define RES2048x1536x70 0x2F
#define RES2048x1536x75 0x30
#define RES2048x1536x85 0x31
#define RES800x480x60 0x32
#define RES800x480x75 0x33
#define RES800x480x85 0x34
#define RES1024x576x60 0x35
#define RES1024x576x75 0x36
#define RES1024x576x85 0x37
#define RES1280x720x60 0x38
#define RES1280x720x75 0x39
#define RES1280x720x85 0x3A
#define RES1280x960x60 0x3B
#define RES720x480x60 0x3C
#define RES720x576x56 0x3D
#define RES856x480x79I 0x3E
#define RES856x480x60 0x3F
#define RES1280x768x60 0x40
#define RES1400x1050x60 0x41
#define RES1152x864x60 0x42
#define RES1152x864x75 0x43
#define RES1024x768x160 0x44
#define RES1280x960x75 0x45
#define RES1280x960x85 0x46
#define RES1280x960x120 0x47
#define LFBDRAMTrap 0x30
#endif
#include "osdef.h"
#ifdef WIN2000
#include <dderror.h>
#include <devioctl.h>
#include <miniport.h>
#include <ntddvdeo.h>
#include <video.h>
#include "xgiv.h"
#include "dd_i2c.h"
#include "tools.h"
#endif /* WIN2000 */
#ifdef LINUX_XF86
#include "xf86.h"
#include "xf86PciInfo.h"
#include "xgi.h"
#include "xgi_regs.h"
#endif
#ifdef LINUX_KERNEL
#include <linux/version.h>
#include <asm/io.h>
#include <linux/types.h>
#include "XGIfb.h"
/*#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
#include <video/XGIfb.h>
#else
#include <linux/XGIfb.h>
#endif*/
#endif
#include "vb_def.h"
#include "vgatypes.h"
#include "vb_struct.h"
#include "vb_util.h"
#include "vb_setmode.h"
#include "vb_ext.h"
extern UCHAR XGI330_SoftSetting;
extern UCHAR XGI330_OutputSelect;
extern USHORT XGI330_RGBSenseData2;
extern USHORT XGI330_YCSenseData2;
extern USHORT XGI330_VideoSenseData2;
#ifdef WIN2000
extern UCHAR SenseCHTV(PHW_DEVICE_EXTENSION pHWDE); /* 2007/05/17 Billy */
#endif
void XGI_GetSenseStatus( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo );
BOOLEAN XGINew_GetPanelID(PVB_DEVICE_INFO pVBInfo);
USHORT XGINew_SenseLCD(PXGI_HW_DEVICE_INFO,PVB_DEVICE_INFO pVBInfo);
BOOLEAN XGINew_GetLCDDDCInfo(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
void XGISetDPMS( PXGI_HW_DEVICE_INFO pXGIHWDE , ULONG VESA_POWER_STATE ) ;
BOOLEAN XGINew_BridgeIsEnable(PXGI_HW_DEVICE_INFO,PVB_DEVICE_INFO pVBInfo );
BOOLEAN XGINew_Sense(USHORT tempbx,USHORT tempcx, PVB_DEVICE_INFO pVBInfo);
BOOLEAN XGINew_SenseHiTV( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo ) ;
/**************************************************************
Dynamic Sense
*************************************************************/
void XGI_WaitDisplay(void);
BOOLEAN XGI_Is301C(PVB_DEVICE_INFO);
BOOLEAN XGI_Is301LV(PVB_DEVICE_INFO);
#ifdef WIN2000
UCHAR XGI_SenseLCD(PHW_DEVICE_EXTENSION, PVB_DEVICE_INFO);
UCHAR XGI_GetLCDDDCInfo(PHW_DEVICE_EXTENSION,PVB_DEVICE_INFO);
extern BOOL bGetDdcInfo(
PHW_DEVICE_EXTENSION pHWDE,
ULONG ulWhichOne,
PUCHAR pjQueryBuffer,
ULONG ulBufferSize
);
#endif
/* --------------------------------------------------------------------- */
/* Function : XGINew_Is301B */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
BOOLEAN XGINew_Is301B( PVB_DEVICE_INFO pVBInfo )
{
USHORT flag ;
flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
if ( flag > 0x0B0 )
return( 0 ) ; /* 301b */
else
return( 1 ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGI_Is301C */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
BOOLEAN XGI_Is301C( PVB_DEVICE_INFO pVBInfo )
{
if ( ( XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) & 0xF0 ) == 0xC0 )
return( 1 ) ;
if ( XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) >= 0xD0 )
{
if ( XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) == 0xE0 )
return( 1 ) ;
}
return( 0 ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGI_Is301LV */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
BOOLEAN XGI_Is301LV( PVB_DEVICE_INFO pVBInfo )
{
if ( XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) >= 0xD0 )
{
if ( XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) == 0xFF )
{
return( 1 ) ;
}
}
return( 0 ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGINew_Sense */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
BOOLEAN XGINew_Sense( USHORT tempbx , USHORT tempcx, PVB_DEVICE_INFO pVBInfo )
{
USHORT temp , i , tempch ;
temp = tempbx & 0xFF ;
XGINew_SetReg1( pVBInfo->Part4Port , 0x11 , temp ) ;
temp = ( tempbx & 0xFF00 ) >> 8 ;
temp |= ( tempcx & 0x00FF ) ;
XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x10 , ~0x1F , temp ) ;
for( i = 0 ; i < 10 ; i++ )
XGI_LongWait( pVBInfo) ;
tempch = ( tempcx & 0x7F00 ) >> 8 ;
temp = XGINew_GetReg1( pVBInfo->Part4Port , 0x03 ) ;
temp = temp ^ ( 0x0E ) ;
temp &= tempch ;
if ( temp > 0 )
return( 1 ) ;
else
return( 0 ) ;
}
#ifdef WIN2000
/* --------------------------------------------------------------------- */
/* Function : XGI_SenseLCD */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
UCHAR XGI_SenseLCD( PHW_DEVICE_EXTENSION pHWDE, PVB_DEVICE_INFO pVBInfo)
{
USHORT tempax , tempbx , tempcx ;
UCHAR SoftSetting = XGI330_SoftSetting ;
if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV ) )
return( 1 ) ;
if ( SoftSetting & HotPlugFunction ) /* Hot Plug Detection */
{
XGINew_SetRegAND( pVBInfo->Part4Port , 0x0F , 0x3F ) ;
tempbx = 0 ;
tempcx = 0x9010 ;
if ( XGINew_Sense( tempbx , tempcx, pVBInfo ) )
return( 1 ) ;
return( 0 ) ;
}
else /* Get LCD Info from EDID */
return(XGI_GetLCDDDCInfo(pHWDE, pVBInfo));
}
/* --------------------------------------------------------------------- */
/* Function : XGI_GetLCDDDCInfo */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
UCHAR XGI_GetLCDDDCInfo( PHW_DEVICE_EXTENSION pHWDE , PVB_DEVICE_INFO pVBInfo)
{
UCHAR tempah , tempbl , tempbh ;
USHORT tempbx , temp ;
UCHAR pjEDIDBuf[ 256 ] ;
ULONG ulBufferSize = 256 ;
UCHAR bMASK_OUTPUTSTATE_CRT2LCD = 2 ; /* 0423 shampoo */
bGetDdcInfo( pHWDE , MASK_OUTPUTSTATE_CRT2LCD , pjEDIDBuf , ulBufferSize ) ;
if ( ( *( ( PULONG )pjEDIDBuf ) == 0xFFFFFF00 ) && ( *( ( PULONG )( pjEDIDBuf + 4 ) ) == 0x00FFFFFF ) )
{
tempah = Panel1024x768 ;
tempbl=( *( pjEDIDBuf + 0x3A ) ) & 0xf0 ;
if ( tempbl != 0x40 )
{
tempah = Panel1600x1200 ;
if ( tempbl != 0x60 )
{
tempah = Panel1280x1024 ;
tempbh = ( *( pjEDIDBuf + 0x3B ) ) ;
if ( tempbh != 0x00 )
{
tempah = Panel1280x960 ;
if ( tempbh != 0x0C0 )
{
tempbx = ( ( *( pjEDIDBuf + 0x24 ) ) << 8 ) | ( *( pjEDIDBuf + 0x23 ) ) ;
tempah = Panel1280x1024 ;
if ( !( tempbx & 0x0100 ) )
{
tempah = Panel1024x768 ;
if ( !( tempbx & 0x0E00 ) )
{
tempah = Panel1280x1024 ;
}
}
}
if ( tempbx & 0x00FF )
{
temp = ScalingLCD ;
XGINew_SetRegOR( pVBInfo->P3d4 , 0x37 , temp ) ;
}
}
}
}
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x36 , ( ~0x07 ) , tempah ) ;
tempah = ( ( *( pjEDIDBuf + 0x47 ) ) & 0x06 ) ; /* Polarity */
tempah = ( tempah ^ 0x06 ) << 4 ;
tempah |= LCDSync ;
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x37 , ( ~LCDSyncBit ) , tempah ) ;
tempbh= XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
tempbh &= 0x07 ;
if ( tempbh == Panel1280x960 )
XGINew_SetRegAND( pVBInfo->P3d4 , 0x37 , 0x0E ) ;
}
else if ( *pjEDIDBuf == 0x20 )
{
tempah = Panel1024x768 ;
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x36 , ( ~0x07 ) , tempah ) ;
}
else
{
return( 0 ) ;
}
return( 1 ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGI_DySense */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
BOOLEAN XGI_DySense( PHW_DEVICE_EXTENSION pHWDE , PUCHAR ujConnectStatus)
{
UCHAR pre_CRD,pre_SR1E , pre_Part2_0 , pre_Part4_D ;
USHORT tempax , tempbx , tempcx , pushax , temp ;
VB_DEVICE_INFO VBINF;
PVB_DEVICE_INFO pVBInfo = &VBINF;
UCHAR OutputSelect = XGI330_OutputSelect ;
PXGI_HW_DEVICE_INFO HwDeviceExtension= pHWDE->pXGIHWDE ;
UCHAR bConnectStatus = 0 ;
pVBInfo->BaseAddr = HwDeviceExtension->pjIOAddress ;
pVBInfo->ROMAddr = pHWDE->pjVirtualRomBase ;
pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
pushax = XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ; /* 0512 Fix Dysense hanged */
temp = ( pushax & 0x00FF ) | 0x80 ;
XGINew_SetRegOR( pVBInfo->P3d4 , 0x17 , temp ) ;
XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
/* beginning of dynamic sense CRT1 */
pVBInfo->IF_DEF_CH7007 = 0;
if (pHWDE->bCH7007)
{
InitTo330Pointer( pHWDE->pXGIHWDE->jChipType, pVBInfo ) ;
HwDeviceExtension->pDevice = (PVOID)pHWDE;
pVBInfo->IF_DEF_CH7007 = 1;
/* [Billy] 2007/05/14 For CH7007 */
if ( pVBInfo->IF_DEF_CH7007 == 1 )
{
bConnectStatus = SenseCHTV(HwDeviceExtension->pDevice) ; /* 07/05/28 */
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , ~0x03 , (UCHAR)bConnectStatus ) ;
}
}
if(( pHWDE->jChipID >= XG40 ) || ( pHWDE->jChipID >= XG20 ))
{
if ( pHWDE->jChipID >= XG40 )
XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x4A ) ; /* write sense pattern 30->4a */
else
XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x5F ) ; /* write sense pattern */
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x53 , 0xFF , 0x02 ) ; /* enable sense DAC */
XGI_WaitDisply(pVBInfo) ;
if(XGINew_GetReg2( pVBInfo->P3c2 ) & 0x10 )
bConnectStatus |= Monitor1Sense ;
XGINew_SetRegAND( pVBInfo->P3d4 , 0x53 , 0xFD ) ; /* disable sense DAC */
XGINew_SetRegAND( pVBInfo->P3d4 , 0x57 , 0x00 ) ; /* clear sense pattern */
/* ---------- End of dynamic sense CRT1 ----------- */
/* ---------- beginning of dynamic sense VB ------------ */
pre_SR1E = XGINew_GetReg1( pVBInfo->P3c4 , 0x1E ) ;
XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x20 ) ; /* Enable CRT2,work-a-round for 301B/301LV/302LV */
pre_Part2_0 = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
pre_Part4_D = XGINew_GetReg1( pVBInfo->Part4Port , 0x0D ) ;
if ( XGI_Is301C( pVBInfo ) ) /* 301C only */
XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~0x07 , 0x01 ) ; /* Set Part4 0x0D D[2:0] to 001b */
/* tempax = 0 ; */
if ( !XGI_Is301LV( pVBInfo ) )
{
tempbx = XGI330_RGBSenseData2 ;
tempcx = 0x0E08 ;
if(XGINew_Sense( tempbx , tempcx, pVBInfo ) )
{
bConnectStatus |= Monitor2Sense ;
if ( OutputSelect & SetSCARTOutput )
{
bConnectStatus ^= ( Monitor2Sense | SCARTSense ) ;
}
}
}
if ( XGI_Is301C( pVBInfo ) ) /* 301C only */
XGINew_SetRegOR( pVBInfo->Part4Port , 0x0D , 0x04 ) ; /* Set Part4 0x0D D[2]=1 for dynamic sense */
if ( ( XGINew_Is301B( pVBInfo ) ) )
XGINew_SetRegOR( pVBInfo->Part2Port , 0x00 , 0x0C ) ; /* ????????? */
if ( XGINew_SenseHiTV( HwDeviceExtension , pVBInfo) ) /* add by kuku for Dysense HiTV //start */
{
bConnectStatus|= YPbPrSense ;
}
else
{
tempbx = XGI330_YCSenseData2 ; /* Y/C Sense Data Ptr */
tempcx = 0x0604 ;
if ( XGINew_Sense( tempbx , tempcx , pVBInfo) )
bConnectStatus |= SVIDEOSense ;
if ( OutputSelect & BoardTVType )
{
tempbx = XGI330_VideoSenseData2 ;
tempcx = 0x0804 ;
if ( XGINew_Sense(tempbx , tempcx, pVBInfo) )
bConnectStatus|= AVIDEOSense ;
}
else
{
if ( !( bConnectStatus & SVIDEOSense ) )
{
tempbx = XGI330_VideoSenseData2 ;
tempcx = 0x0804 ;
if ( XGINew_Sense( tempbx , tempcx, pVBInfo ) )
bConnectStatus |= AVIDEOSense ;
}
}
} /* end */
/* DySenseVBCnt */
tempbx = 0 ;
tempcx = 0 ;
XGINew_Sense(tempbx , tempcx, pVBInfo ) ;
if ( !( bConnectStatus & Monitor2Sense ) )
{
if ( XGI_SenseLCD( pHWDE , pVBInfo ) )
bConnectStatus |= LCDSense ;
}
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , ~( AVIDEOSense | SVIDEOSense | LCDSense | Monitor2Sense | Monitor1Sense ) , bConnectStatus ) ;
XGINew_SetReg1( pVBInfo->Part4Port , 0x0D , pre_Part4_D ) ;
XGINew_SetReg1( pVBInfo->Part2Port , 0x00 , pre_Part2_0 ) ;
XGINew_SetReg1( pVBInfo->P3c4 , 0x1E , pre_SR1E ) ;
if ( XGI_Is301C( pVBInfo ) ) /* 301C only */
{
tempax = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
if ( tempax & 0x20 )
{
/* Reset VBPro */
for( tempcx = 2 ; tempcx > 0 ; tempcx-- )
{
tempax ^= 0x20 ;
XGINew_SetReg1( pVBInfo->Part2Port , 0x00 , tempax ) ;
}
}
}
/* End of dynamic sense VB */
}
else
{
XGI_SenseCRT1(pVBInfo) ;
XGI_GetSenseStatus( HwDeviceExtension, pVBInfo ) ; /* sense CRT2 */
bConnectStatus = XGINew_GetReg1( pVBInfo->P3d4 , 0x32 ) ;
}
temp = pushax & 0x00FF ; /* 0512 Fix Dysense hanged */
XGINew_SetReg1( pVBInfo->P3d4 , 0x17 , temp ) ;
if ( bConnectStatus )
{
*ujConnectStatus = bConnectStatus ;
return( 1 ) ;
}
else
return( 0 ) ;
}
#endif /* WIN2000 */
/* --------------------------------------------------------------------- */
/* Function : XGISetDPMS */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
VOID XGISetDPMS( PXGI_HW_DEVICE_INFO pXGIHWDE , ULONG VESA_POWER_STATE )
{
USHORT ModeNo, ModeIdIndex ;
UCHAR temp ;
VB_DEVICE_INFO VBINF;
PVB_DEVICE_INFO pVBInfo = &VBINF;
pVBInfo->BaseAddr = (ULONG)pXGIHWDE->pjIOAddress ;
pVBInfo->ROMAddr = pXGIHWDE->pjVirtualRomBase ;
pVBInfo->IF_DEF_LVDS = 0 ;
pVBInfo->IF_DEF_CH7005 = 0 ;
pVBInfo->IF_DEF_HiVision = 1 ;
pVBInfo->IF_DEF_LCDA = 1 ;
pVBInfo->IF_DEF_CH7017 = 0 ;
pVBInfo->IF_DEF_YPbPr = 1 ;
pVBInfo->IF_DEF_CRT2Monitor = 0 ;
pVBInfo->IF_DEF_VideoCapture = 0 ;
pVBInfo->IF_DEF_ScaleLCD = 0 ;
pVBInfo->IF_DEF_OEMUtil = 0 ;
pVBInfo->IF_DEF_PWD = 0 ;
InitTo330Pointer( pXGIHWDE->jChipType, pVBInfo ) ;
ReadVBIOSTablData( pXGIHWDE->jChipType , pVBInfo) ;
pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
if ( pXGIHWDE->jChipType == XG27 )
{
if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
{
if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) & 0x20 )
{
pVBInfo->IF_DEF_LVDS = 1 ;
}
}
}
if ( pVBInfo->IF_DEF_CH7007 == 0 )
{
XGINew_SetModeScratch ( pXGIHWDE , pVBInfo ) ;
}
XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ; /* 1.Openkey */
XGI_UnLockCRT2( pXGIHWDE , pVBInfo) ;
ModeNo = XGINew_GetReg1( pVBInfo->P3d4 , 0x34 ) ;
XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
XGI_GetVGAType( pXGIHWDE , pVBInfo ) ;
if ( ( pXGIHWDE->ujVBChipID == VB_CHIP_301 ) || ( pXGIHWDE->ujVBChipID == VB_CHIP_302 ) || ( pVBInfo->IF_DEF_CH7007 == 1 ))
{
XGI_GetVBType( pVBInfo ) ;
XGI_GetVBInfo( ModeNo , ModeIdIndex , pXGIHWDE, pVBInfo ) ;
XGI_GetTVInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
XGI_GetLCDInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
}
if ( VESA_POWER_STATE == 0x00000400 )
XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , ( UCHAR )( XGINew_GetReg1( pVBInfo->Part4Port , 0x31 ) & 0xFE ) ) ;
else
XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , ( UCHAR )( XGINew_GetReg1( pVBInfo->Part4Port , 0x31 ) | 0x01 ) ) ;
temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x1f ) ;
temp &= 0x3f ;
switch ( VESA_POWER_STATE )
{
case 0x00000000: /* on */
if ( ( pXGIHWDE->ujVBChipID == VB_CHIP_301 ) || ( pXGIHWDE->ujVBChipID == VB_CHIP_302 ) )
{
XGINew_SetReg1( pVBInfo->P3c4 , 0x1f , ( UCHAR )( temp | 0x00 ) ) ;
XGI_EnableBridge( pXGIHWDE, pVBInfo ) ;
}
else
{
if ( pXGIHWDE->jChipType == XG21 )
{
if ( pVBInfo->IF_DEF_LVDS == 1 )
{
XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
}
}
if ( pXGIHWDE->jChipType == XG27 )
{
if ( pVBInfo->IF_DEF_LVDS == 1 )
{
XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
}
}
XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , ~0xC0 , 0x00 ) ;
XGINew_SetRegAND( pVBInfo->P3c4 , 0x01 , ~0x20 ) ; /* CRT on */
if ( pXGIHWDE->jChipType == XG21 )
{
temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
if ( temp & 0xE0 )
{
XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ; /* DVO ON */
XGI_SetXG21FPBits( pVBInfo );
XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Enable write GPIOF */
/*XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~0x20 , 0x20 ) ;*/ /* LCD Display ON */
}
XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
XGI_DisplayOn( pXGIHWDE, pVBInfo );
}
if ( pXGIHWDE->jChipType == XG27 )
{
temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
if ( temp & 0xE0 )
{
XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ; /* DVO ON */
XGI_SetXG27FPBits( pVBInfo );
XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Enable write GPIOF */
/*XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~0x20 , 0x20 ) ;*/ /* LCD Display ON */
}
XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
XGI_DisplayOn( pXGIHWDE, pVBInfo );
}
}
break ;
case 0x00000100: /* standby */
if ( pXGIHWDE->jChipType >= XG21 )
{
XGI_DisplayOff( pXGIHWDE, pVBInfo );
}
XGINew_SetReg1( pVBInfo->P3c4 , 0x1f , ( UCHAR )( temp | 0x40 ) ) ;
break ;
case 0x00000200: /* suspend */
if ( pXGIHWDE->jChipType == XG21 )
{
XGI_DisplayOff( pXGIHWDE, pVBInfo );
XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
}
if ( pXGIHWDE->jChipType == XG27 )
{
XGI_DisplayOff( pXGIHWDE, pVBInfo );
XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
}
XGINew_SetReg1( pVBInfo->P3c4 , 0x1f , ( UCHAR )( temp | 0x80 ) ) ;
break ;
case 0x00000400: /* off */
if ( (pXGIHWDE->ujVBChipID == VB_CHIP_301 ) || ( pXGIHWDE->ujVBChipID == VB_CHIP_302 ) )
{
XGINew_SetReg1( pVBInfo->P3c4 , 0x1f , ( UCHAR )( temp | 0xc0 ) ) ;
XGI_DisableBridge( pXGIHWDE, pVBInfo ) ;
}
else
{
if ( pXGIHWDE->jChipType == XG21 )
{
XGI_DisplayOff( pXGIHWDE, pVBInfo );
XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
if ( temp & 0xE0 )
{
XGINew_SetRegAND( pVBInfo->P3c4 , 0x09 , ~0x80 ) ; /* DVO Off */
XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Enable write GPIOF */
/*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* LCD Display OFF */
}
}
if ( pXGIHWDE->jChipType == XG27 )
{
XGI_DisplayOff( pXGIHWDE, pVBInfo );
XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
if ( temp & 0xE0 )
{
XGINew_SetRegAND( pVBInfo->P3c4 , 0x09 , ~0x80 ) ; /* DVO Off */
}
}
XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , ~0xC0 , 0xC0 ) ;
XGINew_SetRegOR( pVBInfo->P3c4 , 0x01 , 0x20 ) ; /* CRT Off */
if ( ( pXGIHWDE->jChipType == XG21 ) && ( pVBInfo->IF_DEF_LVDS == 1 ) )
{
XGI_XG21SetPanelDelay( 4,pVBInfo ) ;
XGI_XG21BLSignalVDD( 0x01 , 0x00, pVBInfo ) ; /* LVDS VDD off */
XGI_XG21SetPanelDelay( 5,pVBInfo ) ;
}
if ( ( pXGIHWDE->jChipType == XG27 ) && ( pVBInfo->IF_DEF_LVDS == 1 ) )
{
XGI_XG21SetPanelDelay( 4,pVBInfo ) ;
XGI_XG27BLSignalVDD( 0x01 , 0x00, pVBInfo ) ; /* LVDS VDD off */
XGI_XG21SetPanelDelay( 5,pVBInfo ) ;
}
}
break ;
default:
break ;
}
XGI_LockCRT2( pXGIHWDE , pVBInfo ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGI_GetSenseStatus */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
void XGI_GetSenseStatus( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
{
USHORT tempax = 0 , tempbx , tempcx , temp ,
P2reg0 = 0 , SenseModeNo = 0 , OutputSelect = *pVBInfo->pOutputSelect ,
ModeIdIndex , i ;
pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
if ( pVBInfo->IF_DEF_LVDS == 1 )
{
tempax = XGINew_GetReg1( pVBInfo->P3c4 , 0x1A ) ; /* ynlai 02/27/2002 */
tempbx = XGINew_GetReg1( pVBInfo->P3c4 , 0x1B ) ;
tempax = ( ( tempax & 0xFE ) >> 1 ) | ( tempbx << 8 ) ;
if ( tempax == 0x00 )
{ /* Get Panel id from DDC */
temp = XGINew_GetLCDDDCInfo( HwDeviceExtension, pVBInfo ) ;
if ( temp == 1 )
{ /* LCD connect */
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x39 , 0xFF , 0x01 ) ; /* set CR39 bit0="1" */
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x37 , 0xEF , 0x00 ) ; /* clean CR37 bit4="0" */
temp = LCDSense ;
}
else
{ /* LCD don't connect */
temp = 0 ;
}
}
else
{
XGINew_GetPanelID(pVBInfo) ;
temp = LCDSense ;
}
tempbx = ~( LCDSense | AVIDEOSense | SVIDEOSense ) ;
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , tempbx , temp ) ;
}
else
{ /* for 301 */
if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
{ /* for HiVision */
tempax = XGINew_GetReg1( pVBInfo->P3c4 , 0x38 ) ;
temp = tempax & 0x01 ;
tempax = XGINew_GetReg1( pVBInfo->P3c4 , 0x3A ) ;
temp = temp | ( tempax & 0x02 ) ;
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xA0 , temp ) ;
}
else
{
if ( XGI_BridgeIsOn( pVBInfo ) )
{
P2reg0 = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
if ( !XGINew_BridgeIsEnable( HwDeviceExtension, pVBInfo ) )
{
SenseModeNo = 0x2e ;
/* XGINew_SetReg1( pVBInfo->P3d4 , 0x30 , 0x41 ) ; */
/* XGISetModeNew( HwDeviceExtension , 0x2e ) ; // ynlai InitMode */
temp = XGI_SearchModeID( SenseModeNo , &ModeIdIndex, pVBInfo ) ;
XGI_GetVGAType( HwDeviceExtension , pVBInfo) ;
XGI_GetVBType( pVBInfo ) ;
pVBInfo->SetFlag = 0x00 ;
pVBInfo->ModeType = ModeVGA ;
pVBInfo->VBInfo = SetCRT2ToRAMDAC | LoadDACFlag | SetInSlaveMode ;
XGI_GetLCDInfo( 0x2e , ModeIdIndex, pVBInfo ) ;
XGI_GetTVInfo( 0x2e , ModeIdIndex, pVBInfo ) ;
XGI_EnableBridge( HwDeviceExtension, pVBInfo ) ;
XGI_SetCRT2Group301( SenseModeNo , HwDeviceExtension, pVBInfo ) ;
XGI_SetCRT2ModeRegs( 0x2e , HwDeviceExtension, pVBInfo ) ;
/* XGI_DisableBridge( HwDeviceExtension, pVBInfo ) ; */
XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ; /* Display Off 0212 */
for( i = 0 ; i < 20 ; i++ )
{
XGI_LongWait(pVBInfo) ;
}
}
XGINew_SetReg1( pVBInfo->Part2Port , 0x00 , 0x1c ) ;
tempax = 0 ;
tempbx = *pVBInfo->pRGBSenseData ;
if ( !( XGINew_Is301B( pVBInfo ) ) )
{
tempbx = *pVBInfo->pRGBSenseData2 ;
}
tempcx = 0x0E08 ;
if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
{
if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
{
tempax |= Monitor2Sense ;
}
}
if ( pVBInfo->VBType & VB_XGI301C)
{
XGINew_SetRegOR( pVBInfo->Part4Port , 0x0d , 0x04 ) ;
}
if ( XGINew_SenseHiTV( HwDeviceExtension , pVBInfo) ) /* add by kuku for Multi-adapter sense HiTV */
{
tempax |= HiTVSense ;
if ( ( pVBInfo->VBType & VB_XGI301C ) )
{
tempax ^= ( HiTVSense | YPbPrSense ) ;
}
}
if ( !( tempax & ( HiTVSense | YPbPrSense ) ) ) /* start */
{
tempbx = *pVBInfo->pYCSenseData ;
if ( !( XGINew_Is301B( pVBInfo ) ) )
{
tempbx=*pVBInfo->pYCSenseData2;
}
tempcx = 0x0604 ;
if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
{
if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
{
tempax |= SVIDEOSense ;
}
}
if ( OutputSelect & BoardTVType )
{
tempbx = *pVBInfo->pVideoSenseData ;
if ( !( XGINew_Is301B( pVBInfo ) ) )
{
tempbx = *pVBInfo->pVideoSenseData2 ;
}
tempcx = 0x0804 ;
if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
{
if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
{
tempax |= AVIDEOSense ;
}
}
}
else
{
if ( !( tempax & SVIDEOSense ) )
{
tempbx = *pVBInfo->pVideoSenseData ;
if ( !( XGINew_Is301B( pVBInfo ) ) )
{
tempbx=*pVBInfo->pVideoSenseData2;
}
tempcx = 0x0804 ;
if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
{
if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
{
tempax |= AVIDEOSense ;
}
}
}
}
}
} /* end */
if ( !( tempax & Monitor2Sense ) )
{
if ( XGINew_SenseLCD( HwDeviceExtension, pVBInfo ) )
{
tempax |= LCDSense ;
}
}
tempbx = 0 ;
tempcx = 0 ;
XGINew_Sense(tempbx , tempcx, pVBInfo ) ;
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , ~0xDF , tempax ) ;
XGINew_SetReg1( pVBInfo->Part2Port , 0x00 , P2reg0 ) ;
if ( !( P2reg0 & 0x20 ) )
{
pVBInfo->VBInfo = DisableCRT2Display ;
/* XGI_SetCRT2Group301( SenseModeNo , HwDeviceExtension, pVBInfo ) ; */
}
}
}
XGI_DisableBridge( HwDeviceExtension, pVBInfo ) ; /* shampoo 0226 */
}
/* --------------------------------------------------------------------- */
/* Function : XGINew_SenseLCD */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
USHORT XGINew_SenseLCD( PXGI_HW_DEVICE_INFO HwDeviceExtension ,PVB_DEVICE_INFO pVBInfo)
{
/* USHORT SoftSetting ; */
USHORT temp ;
if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
temp = 0 ;
else
temp=XGINew_GetPanelID(pVBInfo) ;
if( !temp )
temp = XGINew_GetLCDDDCInfo( HwDeviceExtension, pVBInfo ) ;
return( temp ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGINew_GetLCDDDCInfo */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
BOOLEAN XGINew_GetLCDDDCInfo( PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo)
{
USHORT temp ;
/* add lcd sense */
if ( HwDeviceExtension->ulCRT2LCDType == LCD_UNKNOWN )
{
return( 0 ) ;
}
else
{
temp = ( USHORT )HwDeviceExtension->ulCRT2LCDType ;
switch( HwDeviceExtension->ulCRT2LCDType )
{
case LCD_INVALID:
case LCD_800x600:
case LCD_1024x768:
case LCD_1280x1024:
break ;
case LCD_640x480:
case LCD_1024x600:
case LCD_1152x864:
case LCD_1280x960:
case LCD_1152x768:
temp = 0 ;
break ;
case LCD_1400x1050:
case LCD_1280x768:
case LCD_1600x1200:
break ;
case LCD_1920x1440:
case LCD_2048x1536:
temp = 0 ;
break ;
default:
break ;
}
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x36 , 0xF0 , temp ) ;
return( 1 ) ;
}
}
/* --------------------------------------------------------------------- */
/* Function : */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
BOOLEAN XGINew_GetPanelID(PVB_DEVICE_INFO pVBInfo )
{
USHORT PanelTypeTable[ 16 ] = { SyncNN | PanelRGB18Bit | Panel800x600 | _PanelType00 ,
SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType01 ,
SyncNN | PanelRGB18Bit | Panel800x600 | _PanelType02 ,
SyncNN | PanelRGB18Bit | Panel640x480 | _PanelType03 ,
SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType04 ,
SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType05 ,
SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType06 ,
SyncNN | PanelRGB24Bit | Panel1024x768 | _PanelType07 ,
SyncNN | PanelRGB18Bit | Panel800x600 | _PanelType08 ,
SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType09 ,
SyncNN | PanelRGB18Bit | Panel800x600 | _PanelType0A ,
SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType0B ,
SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType0C ,
SyncNN | PanelRGB24Bit | Panel1024x768 | _PanelType0D ,
SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType0E ,
SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType0F } ;
USHORT tempax , tempbx , temp ;
/* USHORT return_flag ; */
tempax = XGINew_GetReg1( pVBInfo->P3c4 , 0x1A ) ;
tempbx = tempax & 0x1E ;
if ( tempax == 0 )
return( 0 ) ;
else
{
/*
if ( !( tempax & 0x10 ) )
{
if ( pVBInfo->IF_DEF_LVDS == 1 )
{
tempbx = 0 ;
temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x38 ) ;
if ( temp & 0x40 )
tempbx |= 0x08 ;
if ( temp & 0x20 )
tempbx |= 0x02 ;
if ( temp & 0x01 )
tempbx |= 0x01 ;
temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x39 ) ;
if ( temp & 0x80 )
tempbx |= 0x04 ;
}
else
{
return( 0 ) ;
}
}
*/
tempbx = tempbx >> 1 ;
temp = tempbx & 0x00F ;
XGINew_SetReg1( pVBInfo->P3d4 , 0x36 , temp ) ;
tempbx-- ;
tempbx = PanelTypeTable[ tempbx ] ;
temp = ( tempbx & 0xFF00 ) >> 8 ;
XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x37 , ~( LCDSyncBit | LCDRGB18Bit ) , temp ) ;
return( 1 ) ;
}
}
/* --------------------------------------------------------------------- */
/* Function : XGINew_BridgeIsEnable */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
BOOLEAN XGINew_BridgeIsEnable( PXGI_HW_DEVICE_INFO HwDeviceExtension ,PVB_DEVICE_INFO pVBInfo)
{
USHORT flag ;
if ( XGI_BridgeIsOn( pVBInfo ) == 0 )
{
flag = XGINew_GetReg1( pVBInfo->Part1Port , 0x0 ) ;
if ( flag & 0x050 )
{
return( 1 ) ;
}
else
{
return( 0 ) ;
}
}
return( 0 ) ;
}
/* ------------------------------------------------------ */
/* Function : XGINew_SenseHiTV */
/* Input : */
/* Output : */
/* Description : */
/* ------------------------------------------------------ */
BOOLEAN XGINew_SenseHiTV( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo )
{
USHORT tempbx , tempcx , temp , i , tempch;
tempbx = *pVBInfo->pYCSenseData2 ;
tempcx = 0x0604 ;
temp = tempbx & 0xFF ;
XGINew_SetReg1( pVBInfo->Part4Port , 0x11 , temp ) ;
temp = ( tempbx & 0xFF00 ) >> 8 ;
temp |= ( tempcx & 0x00FF ) ;
XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x10 , ~0x1F , temp ) ;
for( i = 0 ; i < 10 ; i++ )
XGI_LongWait(pVBInfo) ;
tempch = ( tempcx & 0xFF00 ) >> 8;
temp = XGINew_GetReg1( pVBInfo->Part4Port , 0x03 ) ;
temp = temp ^ ( 0x0E ) ;
temp &= tempch ;
if ( temp != tempch )
return( 0 ) ;
tempbx = *pVBInfo->pVideoSenseData2 ;
tempcx = 0x0804 ;
temp = tempbx & 0xFF ;
XGINew_SetReg1( pVBInfo->Part4Port , 0x11 , temp ) ;
temp = ( tempbx & 0xFF00 ) >> 8 ;
temp |= ( tempcx & 0x00FF ) ;
XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x10 , ~0x1F , temp ) ;
for( i = 0 ; i < 10 ; i++ )
XGI_LongWait(pVBInfo) ;
tempch = ( tempcx & 0xFF00 ) >> 8;
temp = XGINew_GetReg1( pVBInfo->Part4Port , 0x03 ) ;
temp = temp ^ ( 0x0E ) ;
temp &= tempch ;
if ( temp != tempch )
return( 0 ) ;
else
{
tempbx = 0x3FF ;
tempcx = 0x0804 ;
temp = tempbx & 0xFF ;
XGINew_SetReg1( pVBInfo->Part4Port , 0x11 , temp ) ;
temp = ( tempbx & 0xFF00 ) >> 8 ;
temp |= ( tempcx & 0x00FF ) ;
XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x10 , ~0x1F , temp ) ;
for( i = 0 ; i < 10 ; i++ )
XGI_LongWait(pVBInfo) ;
tempch = ( tempcx & 0xFF00 ) >> 8;
temp = XGINew_GetReg1( pVBInfo->Part4Port , 0x03 ) ;
temp = temp ^ ( 0x0E ) ;
temp &= tempch ;
if ( temp != tempch )
return( 1 ) ;
else
return( 0 ) ;
}
}
/*
;-----------------------------------------------------------------------------
; Description: Get Panel support
; O/P :
; BL: Panel ID=81h for no scaler LVDS
; BH: Panel enhanced Mode Count
; CX: Panel H. resolution
; DX: PAnel V. resolution
;-----------------------------------------------------------------------------
*/
void XGI_XG21Fun14Sub70( PVB_DEVICE_INFO pVBInfo , PX86_REGS pBiosArguments )
{
USHORT ModeIdIndex;
USHORT ModeNo;
USHORT EModeCount;
USHORT lvdstableindex;
lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
pBiosArguments->h.bl = 0x81;
pBiosArguments->x.cx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
pBiosArguments->x.dx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
EModeCount = 0;
pBiosArguments->x.ax = 0x0014;
for( ModeIdIndex = 0 ; ; ModeIdIndex ++ )
{
ModeNo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeID;
if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeID == 0xFF )
{
pBiosArguments->h.bh = (UCHAR) EModeCount;
return;
}
if ( !XGI_XG21CheckLVDSMode( ModeNo , ModeIdIndex, pVBInfo) )
{
continue;
}
EModeCount++ ;
}
}
/*(
;-----------------------------------------------------------------------------
;
; Description: Get Panel mode ID for enhanced mode
; I/P : BH: EModeIndex ( which < Panel enhanced Mode Count )
; O/P :
; BL: Mode ID
; CX: H. resolution of the assigned by the index
; DX: V. resolution of the assigned by the index
;
;-----------------------------------------------------------------------------
*/
void XGI_XG21Fun14Sub71( PVB_DEVICE_INFO pVBInfo , PX86_REGS pBiosArguments )
{
USHORT EModeCount;
USHORT ModeIdIndex,resindex;
USHORT ModeNo;
USHORT EModeIndex = pBiosArguments->h.bh;
EModeCount = 0;
for( ModeIdIndex = 0 ; ; ModeIdIndex ++ )
{
ModeNo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeID;
if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeID == 0xFF )
{
pBiosArguments->x.ax = 0x0114;
return;
}
if ( !XGI_XG21CheckLVDSMode( ModeNo , ModeIdIndex, pVBInfo) )
{
continue;
}
if (EModeCount == EModeIndex)
{
resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
pBiosArguments->h.bl = (UCHAR) ModeNo;
pBiosArguments->x.cx = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
pBiosArguments->x.dx = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
pBiosArguments->x.ax = 0x0014;
}
EModeCount++ ;
}
}
/*
;-----------------------------------------------------------------------------
;
; Description: Validate Panel modes ID support
; I/P :
; BL: ModeID
; O/P :
; CX: H. resolution of the assigned by the index
; DX: V. resolution of the assigned by the index
;
;-----------------------------------------------------------------------------
*/
void XGI_XG21Fun14Sub72( PVB_DEVICE_INFO pVBInfo , PX86_REGS pBiosArguments )
{
USHORT ModeIdIndex,resindex;
USHORT ModeNo;
ModeNo = pBiosArguments->h.bl ;
XGI_SearchModeID( ModeNo, &ModeIdIndex, pVBInfo);
if ( !XGI_XG21CheckLVDSMode( ModeNo , ModeIdIndex, pVBInfo) )
{
pBiosArguments->x.cx = 0;
pBiosArguments->x.dx = 0;
pBiosArguments->x.ax = 0x0114;
return;
}
resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
if ( ModeNo <= 0x13 )
{
pBiosArguments->x.cx = pVBInfo->StResInfo[ resindex ].HTotal ;
pBiosArguments->x.dx = pVBInfo->StResInfo[ resindex ].VTotal ;
}
else
{
pBiosArguments->x.cx = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
pBiosArguments->x.dx = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
}
pBiosArguments->x.ax = 0x0014;
}
/*
;-----------------------------------------------------------------------------
; Description: Get Customized Panel misc. information support
; I/P : Select
; to get panel horizontal timing
; to get panel vertical timing
; to get channel clock parameter
; to get panel misc information
;
; O/P :
; BL: for input Select = 0 ;
; BX: *Value1 = Horizontal total
; CX: *Value2 = Horizontal front porch
; DX: *Value2 = Horizontal sync width
; BL: for input Select = 1 ;
; BX: *Value1 = Vertical total
; CX: *Value2 = Vertical front porch
; DX: *Value2 = Vertical sync width
; BL: for input Select = 2 ;
; BX: Value1 = The first CLK parameter
; CX: Value2 = The second CLK parameter
; BL: for input Select = 4 ;
; BX[15]: *Value1 D[15] VESA V. Polarity
; BX[14]: *Value1 D[14] VESA H. Polarity
; BX[7]: *Value1 D[7] Panel V. Polarity
; BX[6]: *Value1 D[6] Panel H. Polarity
;-----------------------------------------------------------------------------
*/
void XGI_XG21Fun14Sub73( PVB_DEVICE_INFO pVBInfo , PX86_REGS pBiosArguments )
{
UCHAR Select;
USHORT lvdstableindex;
lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
Select = pBiosArguments->h.bl;
switch (Select)
{
case 0:
pBiosArguments->x.bx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
pBiosArguments->x.cx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
pBiosArguments->x.dx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
break;
case 1:
pBiosArguments->x.bx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
pBiosArguments->x.cx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
pBiosArguments->x.dx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
break;
case 2:
pBiosArguments->x.bx = pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1;
pBiosArguments->x.cx = pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2;
break;
case 4:
pBiosArguments->x.bx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability;
break;
}
pBiosArguments->x.ax = 0x0014;
}
void XGI_XG21Fun14( PXGI_HW_DEVICE_INFO pXGIHWDE, PX86_REGS pBiosArguments)
{
VB_DEVICE_INFO VBINF;
PVB_DEVICE_INFO pVBInfo = &VBINF;
pVBInfo->IF_DEF_LVDS = 0 ;
pVBInfo->IF_DEF_CH7005 = 0 ;
pVBInfo->IF_DEF_HiVision = 1 ;
pVBInfo->IF_DEF_LCDA = 1 ;
pVBInfo->IF_DEF_CH7017 = 0 ;
pVBInfo->IF_DEF_YPbPr = 1 ;
pVBInfo->IF_DEF_CRT2Monitor = 0 ;
pVBInfo->IF_DEF_VideoCapture = 0 ;
pVBInfo->IF_DEF_ScaleLCD = 0 ;
pVBInfo->IF_DEF_OEMUtil = 0 ;
pVBInfo->IF_DEF_PWD = 0 ;
InitTo330Pointer( pXGIHWDE->jChipType, pVBInfo ) ;
ReadVBIOSTablData( pXGIHWDE->jChipType , pVBInfo) ;
pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
switch(pBiosArguments->x.ax)
{
case 0x1470:
XGI_XG21Fun14Sub70( pVBInfo , pBiosArguments ) ;
break;
case 0x1471:
XGI_XG21Fun14Sub71( pVBInfo , pBiosArguments ) ;
break;
case 0x1472:
XGI_XG21Fun14Sub72( pVBInfo , pBiosArguments ) ;
break;
case 0x1473:
XGI_XG21Fun14Sub73( pVBInfo , pBiosArguments ) ;
break;
}
}
#ifndef _VBEXT_
#define _VBEXT_
struct DWORDREGS {
ULONG Eax, Ebx, Ecx, Edx, Esi, Edi, Ebp;
};
struct WORDREGS {
USHORT ax, hi_ax, bx, hi_bx, cx, hi_cx, dx, hi_dx, si, hi_si, di ,hi_di, bp, hi_bp;
};
struct BYTEREGS {
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;
};
typedef union _X86_REGS {
struct DWORDREGS e;
struct WORDREGS x;
struct BYTEREGS h;
} X86_REGS, *PX86_REGS;
extern void XGI_XG21Fun14( PXGI_HW_DEVICE_INFO pXGIHWDE, PX86_REGS pBiosArguments);
extern void XGISetDPMS( PXGI_HW_DEVICE_INFO pXGIHWDE , ULONG VESA_POWER_STATE ) ;
extern void XGI_GetSenseStatus( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo );
extern void XGINew_SetModeScratch ( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo ) ;
extern void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo);
extern USHORT XGINew_SenseLCD(PXGI_HW_DEVICE_INFO,PVB_DEVICE_INFO pVBInfo);
#ifdef WIN2000
extern BOOLEAN XGI_DySense( PHW_DEVICE_EXTENSION pHWDE , PUCHAR ujConnectStatus );
#endif /* WIN2000 */
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef _VBINIT_
#define _VBINIT_
extern BOOLEAN XGIInitNew( PXGI_HW_DEVICE_INFO HwDeviceExtension ) ;
extern XGI21_LVDSCapStruct XGI21_LCDCapList[13];
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef _VBSETMODE_
#define _VBSETMODE_
extern void InitTo330Pointer(UCHAR,PVB_DEVICE_INFO);
extern void XGI_UnLockCRT2(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
extern void XGI_LockCRT2(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
extern void XGI_LongWait( PVB_DEVICE_INFO );
extern void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO );
extern void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
extern void XGI_EnableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
extern void XGI_DisplayOff( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO );
extern void XGI_DisplayOn( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO );
extern void XGI_GetVBType(PVB_DEVICE_INFO);
extern void XGI_SenseCRT1(PVB_DEVICE_INFO );
extern void XGI_GetVGAType(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
extern void XGI_GetVBInfo(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
extern void XGI_GetTVInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO );
extern void XGI_SetCRT1Offset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
extern void XGI_SetLCDAGroup(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO );
extern void XGI_WaitDisply( PVB_DEVICE_INFO );
extern USHORT XGI_GetResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
extern BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo ) ;
extern BOOLEAN XGI_SearchModeID( USHORT ModeNo,USHORT *ModeIdIndex, PVB_DEVICE_INFO );
extern BOOLEAN XGI_GetLCDInfo(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO );
extern BOOLEAN XGI_BridgeIsOn( PVB_DEVICE_INFO );
extern BOOLEAN XGI_SetCRT2Group301(USHORT ModeNo, PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO);
extern USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO );
extern void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo);
extern void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo);
extern void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
extern void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
extern void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
extern BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
extern void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
extern USHORT XGI_GetLVDSOEMTableIndex(PVB_DEVICE_INFO pVBInfo);
#endif
#ifndef _VB_STRUCT_
#define _VB_STRUCT_
#ifdef _INITNEW_
#define EXTERN
#else
#define EXTERN extern
#endif
typedef struct _XGI_PanelDelayTblStruct
{
UCHAR timer[2];
} XGI_PanelDelayTblStruct;
typedef struct _XGI_LCDDataStruct
{
USHORT RVBHCMAX;
USHORT RVBHCFACT;
USHORT VGAHT;
USHORT VGAVT;
USHORT LCDHT;
USHORT LCDVT;
} XGI_LCDDataStruct;
typedef struct _XGI_LVDSCRT1HDataStruct
{
UCHAR Reg[8];
} XGI_LVDSCRT1HDataStruct;
typedef struct _XGI_LVDSCRT1VDataStruct
{
UCHAR Reg[7];
} XGI_LVDSCRT1VDataStruct;
typedef struct _XGI_TVDataStruct
{
USHORT RVBHCMAX;
USHORT RVBHCFACT;
USHORT VGAHT;
USHORT VGAVT;
USHORT TVHDE;
USHORT TVVDE;
USHORT RVBHRS;
UCHAR FlickerMode;
USHORT HALFRVBHRS;
UCHAR RY1COE;
UCHAR RY2COE;
UCHAR RY3COE;
UCHAR RY4COE;
} XGI_TVDataStruct;
typedef struct _XGI_LVDSDataStruct
{
USHORT VGAHT;
USHORT VGAVT;
USHORT LCDHT;
USHORT LCDVT;
} XGI_LVDSDataStruct;
typedef struct _XGI_LVDSDesStruct
{
USHORT LCDHDES;
USHORT LCDVDES;
} XGI_LVDSDesStruct;
typedef struct _XGI_LVDSCRT1DataStruct
{
UCHAR CR[15];
} XGI_LVDSCRT1DataStruct;
/*add for LCDA*/
typedef struct _XGI_StStruct
{
UCHAR St_ModeID;
USHORT St_ModeFlag;
UCHAR St_StTableIndex;
UCHAR St_CRT2CRTC;
UCHAR St_CRT2CRTC2;
UCHAR St_ResInfo;
UCHAR VB_StTVFlickerIndex;
UCHAR VB_StTVEdgeIndex;
UCHAR VB_StTVYFilterIndex;
} XGI_StStruct;
typedef struct _XGI_StandTableStruct
{
UCHAR CRT_COLS;
UCHAR ROWS;
UCHAR CHAR_HEIGHT;
USHORT CRT_LEN;
UCHAR SR[4];
UCHAR MISC;
UCHAR CRTC[0x19];
UCHAR ATTR[0x14];
UCHAR GRC[9];
} XGI_StandTableStruct;
typedef struct _XGI_ExtStruct
{
UCHAR Ext_ModeID;
USHORT Ext_ModeFlag;
USHORT Ext_ModeInfo;
USHORT Ext_Point;
USHORT Ext_VESAID;
UCHAR Ext_VESAMEMSize;
UCHAR Ext_RESINFO;
UCHAR VB_ExtTVFlickerIndex;
UCHAR VB_ExtTVEdgeIndex;
UCHAR VB_ExtTVYFilterIndex;
UCHAR REFindex;
} XGI_ExtStruct;
typedef struct _XGI_Ext2Struct
{
USHORT Ext_InfoFlag;
UCHAR Ext_CRT1CRTC;
UCHAR Ext_CRTVCLK;
UCHAR Ext_CRT2CRTC;
UCHAR Ext_CRT2CRTC2;
UCHAR ModeID;
USHORT XRes;
USHORT YRes;
/* USHORT ROM_OFFSET; */
} XGI_Ext2Struct;
typedef struct _XGI_MCLKDataStruct
{
UCHAR SR28,SR29,SR2A;
USHORT CLOCK;
} XGI_MCLKDataStruct;
typedef struct _XGI_ECLKDataStruct
{
UCHAR SR2E,SR2F,SR30;
USHORT CLOCK;
} XGI_ECLKDataStruct;
typedef struct _XGI_VCLKDataStruct
{
UCHAR SR2B,SR2C;
USHORT CLOCK;
} XGI_VCLKDataStruct;
typedef struct _XGI_VBVCLKDataStruct
{
UCHAR Part4_A,Part4_B;
USHORT CLOCK;
} XGI_VBVCLKDataStruct;
typedef struct _XGI_StResInfoStruct
{
USHORT HTotal;
USHORT VTotal;
} XGI_StResInfoStruct;
typedef struct _XGI_ModeResInfoStruct
{
USHORT HTotal;
USHORT VTotal;
UCHAR XChar;
UCHAR YChar;
} XGI_ModeResInfoStruct;
typedef struct _XGI_LCDNBDesStruct
{
UCHAR NB[12];
} XGI_LCDNBDesStruct;
/*add for new UNIVGABIOS*/
typedef struct _XGI_LCDDesStruct
{
USHORT LCDHDES;
USHORT LCDHRS;
USHORT LCDVDES;
USHORT LCDVRS;
} XGI_LCDDesStruct;
typedef struct _XGI_LCDDataTablStruct
{
UCHAR PANELID;
USHORT MASK;
USHORT CAP;
USHORT DATAPTR;
} XGI_LCDDataTablStruct;
typedef struct _XGI_TVTablDataStruct
{
USHORT MASK;
USHORT CAP;
USHORT DATAPTR;
} XGI_TVDataTablStruct;
typedef struct _XGI330_LCDDesDataStruct
{
USHORT LCDHDES;
USHORT LCDHRS;
USHORT LCDVDES;
USHORT LCDVRS;
} XGI330_LCDDataDesStruct;
typedef struct _XGI330_LVDSDataStruct
{
USHORT VGAHT;
USHORT VGAVT;
USHORT LCDHT;
USHORT LCDVT;
} XGI330_LVDSDataStruct;
typedef struct _XGI330_LCDDesDataStruct2
{
USHORT LCDHDES;
USHORT LCDHRS;
USHORT LCDVDES;
USHORT LCDVRS;
USHORT LCDHSync;
USHORT LCDVSync;
} XGI330_LCDDataDesStruct2;
typedef struct _XGI330_LCDDataStruct
{
USHORT RVBHCMAX;
USHORT RVBHCFACT;
USHORT VGAHT;
USHORT VGAVT;
USHORT LCDHT;
USHORT LCDVT;
} XGI330_LCDDataStruct;
typedef struct _XGI330_TVDataStruct
{
USHORT RVBHCMAX;
USHORT RVBHCFACT;
USHORT VGAHT;
USHORT VGAVT;
USHORT TVHDE;
USHORT TVVDE;
USHORT RVBHRS;
UCHAR FlickerMode;
USHORT HALFRVBHRS;
} XGI330_TVDataStruct;
typedef struct _XGI330_LCDDataTablStruct
{
UCHAR PANELID;
USHORT MASK;
USHORT CAP;
USHORT DATAPTR;
} XGI330_LCDDataTablStruct;
typedef struct _XGI330_TVDataTablStruct
{
USHORT MASK;
USHORT CAP;
USHORT DATAPTR;
} XGI330_TVDataTablStruct;
typedef struct _XGI330_CHTVDataStruct
{
USHORT VGAHT;
USHORT VGAVT;
USHORT LCDHT;
USHORT LCDVT;
} XGI330_CHTVDataStruct;
typedef struct _XGI_TimingHStruct
{
UCHAR data[8];
} XGI_TimingHStruct;
typedef struct _XGI_TimingVStruct
{
UCHAR data[7];
} XGI_TimingVStruct;
typedef struct _XGI_CH7007TV_TimingHStruct
{
UCHAR data[10];
} XGI_CH7007TV_TimingHStruct;
typedef struct _XGI_CH7007TV_TimingVStruct
{
UCHAR data[10];
} XGI_CH7007TV_TimingVStruct;
typedef struct _XGI_XG21CRT1Struct
{
UCHAR ModeID,CR02,CR03,CR15,CR16;
} XGI_XG21CRT1Struct;
typedef struct _XGI330_CHTVRegDataStruct
{
UCHAR Reg[16];
} XGI330_CHTVRegDataStruct;
typedef struct _XGI330_LCDCapStruct
{
UCHAR LCD_ID;
USHORT LCD_Capability;
UCHAR LCD_SetFlag;
UCHAR LCD_DelayCompensation;
UCHAR LCD_HSyncWidth;
UCHAR LCD_VSyncWidth;
UCHAR LCD_VCLK;
UCHAR LCDA_VCLKData1;
UCHAR LCDA_VCLKData2;
UCHAR LCUCHAR_VCLKData1;
UCHAR LCUCHAR_VCLKData2;
UCHAR PSC_S1;
UCHAR PSC_S2;
UCHAR PSC_S3;
UCHAR PSC_S4;
UCHAR PSC_S5;
UCHAR PWD_2B;
UCHAR PWD_2C;
UCHAR PWD_2D;
UCHAR PWD_2E;
UCHAR PWD_2F;
UCHAR Spectrum_31;
UCHAR Spectrum_32;
UCHAR Spectrum_33;
UCHAR Spectrum_34;
} XGI330_LCDCapStruct;
typedef struct _XGI21_LVDSCapStruct
{
USHORT LVDS_Capability;
USHORT LVDSHT;
USHORT LVDSVT;
USHORT LVDSHDE;
USHORT LVDSVDE;
USHORT LVDSHFP;
USHORT LVDSVFP;
USHORT LVDSHSYNC;
USHORT LVDSVSYNC;
UCHAR VCLKData1;
UCHAR VCLKData2;
UCHAR PSC_S1;
UCHAR PSC_S2;
UCHAR PSC_S3;
UCHAR PSC_S4;
UCHAR PSC_S5;
} XGI21_LVDSCapStruct;
typedef struct _XGI_CRT1TableStruct
{
UCHAR CR[16];
} XGI_CRT1TableStruct;
typedef struct _XGI330_VCLKDataStruct
{
UCHAR SR2B,SR2C;
USHORT CLOCK;
} XGI330_VCLKDataStruct;
typedef struct _XGI301C_Tap4TimingStruct
{
USHORT DE;
UCHAR Reg[64]; /* C0-FF */
} XGI301C_Tap4TimingStruct;
typedef struct _XGI_New_StandTableStruct
{
UCHAR CRT_COLS;
UCHAR ROWS;
UCHAR CHAR_HEIGHT;
USHORT CRT_LEN;
UCHAR SR[4];
UCHAR MISC;
UCHAR CRTC[0x19];
UCHAR ATTR[0x14];
UCHAR GRC[9];
} XGI_New_StandTableStruct;
typedef UCHAR DRAM8Type[8];
typedef UCHAR DRAM4Type[4];
typedef UCHAR DRAM32Type[32];
typedef UCHAR DRAM2Type[2];
typedef struct _VB_DEVICE_INFO VB_DEVICE_INFO;
typedef VB_DEVICE_INFO * PVB_DEVICE_INFO;
struct _VB_DEVICE_INFO
{
BOOLEAN ISXPDOS;
ULONG P3c4,P3d4,P3c0,P3ce,P3c2,P3cc;
ULONG P3ca,P3c6,P3c7,P3c8,P3c9,P3da;
ULONG Part0Port,Part1Port,Part2Port;
ULONG Part3Port,Part4Port,Part5Port;
USHORT RVBHCFACT,RVBHCMAX,RVBHRS;
USHORT VGAVT,VGAHT,VGAVDE,VGAHDE;
USHORT VT,HT,VDE,HDE;
USHORT LCDHRS,LCDVRS,LCDHDES,LCDVDES;
USHORT ModeType;
USHORT IF_DEF_LVDS,IF_DEF_TRUMPION,IF_DEF_DSTN;/* ,IF_DEF_FSTN; add for dstn */
USHORT IF_DEF_CRT2Monitor,IF_DEF_VideoCapture;
USHORT IF_DEF_LCDA,IF_DEF_CH7017,IF_DEF_YPbPr,IF_DEF_ScaleLCD,IF_DEF_OEMUtil,IF_DEF_PWD;
USHORT IF_DEF_ExpLink;
USHORT IF_DEF_CH7005,IF_DEF_HiVision;
USHORT IF_DEF_CH7007; /* Billy 2007/05/03 */
USHORT LCDResInfo,LCDTypeInfo, VBType;/*301b*/
USHORT VBInfo,TVInfo,LCDInfo, Set_VGAType;
USHORT VBExtInfo;/*301lv*/
USHORT SetFlag;
USHORT NewFlickerMode;
USHORT SelectCRT2Rate;
PUCHAR ROMAddr;
PUCHAR FBAddr;
ULONG BaseAddr;
ULONG RelIO;
DRAM4Type *CR6B;
DRAM4Type *CR6E;
DRAM32Type *CR6F;
DRAM2Type *CR89;
DRAM8Type *SR15; /* pointer : point to array */
DRAM8Type *CR40;
UCHAR *pSoftSetting;
UCHAR *pOutputSelect;
USHORT *pRGBSenseData;
USHORT *pRGBSenseData2; /*301b*/
USHORT *pVideoSenseData;
USHORT *pVideoSenseData2;
USHORT *pYCSenseData;
USHORT *pYCSenseData2;
UCHAR *pSR07;
UCHAR *CR49;
UCHAR *pSR1F;
UCHAR *AGPReg;
UCHAR *SR16;
UCHAR *pSR21;
UCHAR *pSR22;
UCHAR *pSR23;
UCHAR *pSR24;
UCHAR *SR25;
UCHAR *pSR31;
UCHAR *pSR32;
UCHAR *pSR33;
UCHAR *pSR36; /* alan 12/07/2006 */
UCHAR *pCRCF;
UCHAR *pCRD0; /* alan 12/07/2006 */
UCHAR *pCRDE; /* alan 12/07/2006 */
UCHAR *pCR8F; /* alan 12/07/2006 */
UCHAR *pSR40; /* alan 12/07/2006 */
UCHAR *pSR41; /* alan 12/07/2006 */
UCHAR *pDVOSetting;
UCHAR *pCR2E;
UCHAR *pCR2F;
UCHAR *pCR46;
UCHAR *pCR47;
UCHAR *pCRT2Data_1_2;
UCHAR *pCRT2Data_4_D;
UCHAR *pCRT2Data_4_E;
UCHAR *pCRT2Data_4_10;
XGI_MCLKDataStruct *MCLKData;
XGI_ECLKDataStruct *ECLKData;
UCHAR *XGI_TVDelayList;
UCHAR *XGI_TVDelayList2;
UCHAR *CHTVVCLKUNTSC;
UCHAR *CHTVVCLKONTSC;
UCHAR *CHTVVCLKUPAL;
UCHAR *CHTVVCLKOPAL;
UCHAR *NTSCTiming;
UCHAR *PALTiming;
UCHAR *HiTVExtTiming;
UCHAR *HiTVSt1Timing;
UCHAR *HiTVSt2Timing;
UCHAR *HiTVTextTiming;
UCHAR *YPbPr750pTiming;
UCHAR *YPbPr525pTiming;
UCHAR *YPbPr525iTiming;
UCHAR *HiTVGroup3Data;
UCHAR *HiTVGroup3Simu;
UCHAR *HiTVGroup3Text;
UCHAR *Ren525pGroup3;
UCHAR *Ren750pGroup3;
UCHAR *ScreenOffset;
UCHAR *pXGINew_DRAMTypeDefinition;
UCHAR *pXGINew_I2CDefinition ;
UCHAR *pXGINew_CR97 ;
XGI330_LCDCapStruct *LCDCapList;
XGI21_LVDSCapStruct *XG21_LVDSCapList;
XGI_TimingHStruct *TimingH;
XGI_TimingVStruct *TimingV;
XGI_StStruct *SModeIDTable;
XGI_StandTableStruct *StandTable;
XGI_ExtStruct *EModeIDTable;
XGI_Ext2Struct *RefIndex;
/* XGINew_CRT1TableStruct *CRT1Table; */
XGI_CRT1TableStruct *XGINEWUB_CRT1Table;
XGI_VCLKDataStruct *VCLKData;
XGI_VBVCLKDataStruct *VBVCLKData;
XGI_StResInfoStruct *StResInfo;
XGI_ModeResInfoStruct *ModeResInfo;
XGI_XG21CRT1Struct *UpdateCRT1;
}; /* _VB_DEVICE_INFO */
typedef struct
{
USHORT Horizontal_ACTIVE;
USHORT Horizontal_FP;
USHORT Horizontal_SYNC;
USHORT Horizontal_BP;
USHORT Vertical_ACTIVE;
USHORT Vertical_FP;
USHORT Vertical_SYNC;
USHORT Vertical_BP;
double DCLK;
UCHAR FrameRate;
UCHAR Interlace;
USHORT Margin;
} TimingInfo;
#define _VB_STRUCT_
#endif /* _VB_STRUCT_ */
This source diff could not be displayed because it is too large. You can view the blob instead.
#include "osdef.h"
#include "vb_def.h"
#include "vgatypes.h"
#include "vb_struct.h"
#ifdef LINUX_KERNEL
#include "XGIfb.h"
#include <asm/io.h>
#include <linux/types.h>
#endif
#ifdef TC
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <dos.h>
#endif
#ifdef WIN2000
#include <dderror.h>
#include <devioctl.h>
#include <miniport.h>
#include <ntddvdeo.h>
#include <video.h>
#include "xgiv.h"
#include "dd_i2c.h"
#include "tools.h"
#endif
#ifdef LINUX_XF86
#include "xf86.h"
#include "xf86PciInfo.h"
#include "xgi.h"
#include "xgi_regs.h"
#endif
void XGINew_SetReg1( ULONG , USHORT , USHORT ) ;
void XGINew_SetReg2( ULONG , USHORT , USHORT ) ;
void XGINew_SetReg3( ULONG , USHORT ) ;
void XGINew_SetReg4( ULONG , ULONG ) ;
UCHAR XGINew_GetReg1( ULONG , USHORT) ;
UCHAR XGINew_GetReg2( ULONG ) ;
ULONG XGINew_GetReg3( ULONG ) ;
void XGINew_ClearDAC( PUCHAR ) ;
void XGINew_SetRegANDOR(ULONG Port,USHORT Index,USHORT DataAND,USHORT DataOR);
void XGINew_SetRegOR(ULONG Port,USHORT Index,USHORT DataOR);
void XGINew_SetRegAND(ULONG Port,USHORT Index,USHORT DataAND);
/* --------------------------------------------------------------------- */
/* Function : XGINew_SetReg1 */
/* Input : */
/* Output : */
/* Description : SR CRTC GR */
/* --------------------------------------------------------------------- */
void XGINew_SetReg1( ULONG port , USHORT index , USHORT data )
{
#ifdef LINUX_XF86
OutPortByte( ( PUCHAR )(ULONG)port , index ) ;
OutPortByte( ( PUCHAR )(ULONG)port + 1 , data ) ;
#else
OutPortByte( port , index ) ;
OutPortByte( port + 1 , data ) ;
#endif
}
/* --------------------------------------------------------------------- */
/* Function : XGINew_SetReg2 */
/* Input : */
/* Output : */
/* Description : AR( 3C0 ) */
/* --------------------------------------------------------------------- */
/*void XGINew_SetReg2( ULONG port , USHORT index , USHORT data )
{
InPortByte( ( PUCHAR )port + 0x3da - 0x3c0 ) ;
OutPortByte( XGINew_P3c0 , index ) ;
OutPortByte( XGINew_P3c0 , data ) ;
OutPortByte( XGINew_P3c0 , 0x20 ) ;
}*/
/* --------------------------------------------------------------------- */
/* Function : */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
void XGINew_SetReg3( ULONG port , USHORT data )
{
OutPortByte( port , data ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGINew_SetReg4 */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
void XGINew_SetReg4( ULONG port , ULONG data )
{
OutPortLong( port , data ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGINew_GetReg1 */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
UCHAR XGINew_GetReg1( ULONG port , USHORT index )
{
UCHAR data ;
#ifdef LINUX_XF86
OutPortByte( ( PUCHAR )(ULONG)port , index ) ;
data = InPortByte( ( PUCHAR )(ULONG)port + 1 ) ;
#else
OutPortByte( port , index ) ;
data = InPortByte( port + 1 ) ;
#endif
return( data ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGINew_GetReg2 */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
UCHAR XGINew_GetReg2( ULONG port )
{
UCHAR data ;
data = InPortByte( port ) ;
return( data ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGINew_GetReg3 */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
ULONG XGINew_GetReg3( ULONG port )
{
ULONG data ;
data = InPortLong( port ) ;
return( data ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGINew_SetRegANDOR */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
void XGINew_SetRegANDOR( ULONG Port , USHORT Index , USHORT DataAND , USHORT DataOR )
{
USHORT temp ;
temp = XGINew_GetReg1( Port , Index ) ; /* XGINew_Part1Port index 02 */
temp = ( temp & ( DataAND ) ) | DataOR ;
XGINew_SetReg1( Port , Index , temp ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGINew_SetRegAND */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
void XGINew_SetRegAND(ULONG Port,USHORT Index,USHORT DataAND)
{
USHORT temp ;
temp = XGINew_GetReg1( Port , Index ) ; /* XGINew_Part1Port index 02 */
temp &= DataAND ;
XGINew_SetReg1( Port , Index , temp ) ;
}
/* --------------------------------------------------------------------- */
/* Function : XGINew_SetRegOR */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
void XGINew_SetRegOR( ULONG Port , USHORT Index , USHORT DataOR )
{
USHORT temp ;
temp = XGINew_GetReg1( Port , Index ) ; /* XGINew_Part1Port index 02 */
temp |= DataOR ;
XGINew_SetReg1( Port , Index , temp ) ;
}
/* --------------------------------------------------------------------- */
/* Function : NewDelaySecond */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
void NewDelaySeconds( int seconds )
{
#ifdef WIN2000
int j ;
#endif
int i ;
for( i = 0 ; i < seconds ; i++ )
{
#ifdef TC
delay( 1000 ) ;
#endif
#ifdef WIN2000
for ( j = 0 ; j < 20000 ; j++ )
VideoPortStallExecution( 50 ) ;
#endif
#ifdef WINCE_HEADER
#endif
#ifdef LINUX_KERNEL
#endif
}
}
/* --------------------------------------------------------------------- */
/* Function : Newdebugcode */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
void Newdebugcode( UCHAR code )
{
// OutPortByte ( 0x80 , code ) ;
/* OutPortByte ( 0x300 , code ) ; */
/* NewDelaySeconds( 0x3 ) ; */
}
#ifndef _VBUTIL_
#define _VBUTIL_
extern void NewDelaySeconds( int );
extern void Newdebugcode( UCHAR );
extern void XGINew_SetReg1(ULONG, USHORT, USHORT);
extern void XGINew_SetReg3(ULONG, USHORT);
extern UCHAR XGINew_GetReg1(ULONG, USHORT);
extern UCHAR XGINew_GetReg2(ULONG);
extern void XGINew_SetReg4(ULONG, ULONG);
extern ULONG XGINew_GetReg3(ULONG);
extern void XGINew_SetRegOR(ULONG Port,USHORT Index,USHORT DataOR);
extern void XGINew_SetRegAND(ULONG Port,USHORT Index,USHORT DataAND);
extern void XGINew_SetRegANDOR(ULONG Port,USHORT Index,USHORT DataAND,USHORT DataOR);
#endif
#ifndef _VGATYPES_
#define _VGATYPES_
#include "osdef.h"
#ifdef LINUX_XF86
#include "xf86Version.h"
#include "xf86Pci.h"
#endif
#ifdef LINUX_KERNEL /* We don't want the X driver to depend on kernel source */
#include <linux/ioctl.h>
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef NULL
#define NULL 0
#endif
#ifndef CHAR
typedef char CHAR;
#endif
#ifndef SHORT
typedef short SHORT;
#endif
#ifndef LONG
typedef long LONG;
#endif
#ifndef UCHAR
typedef unsigned char UCHAR;
#endif
#ifndef USHORT
typedef unsigned short USHORT;
#endif
#ifndef ULONG
typedef unsigned long ULONG;
#endif
#ifndef PUCHAR
typedef UCHAR *PUCHAR;
#endif
#ifndef PUSHORT
typedef USHORT *PUSHORT;
#endif
#ifndef PLONGU
typedef ULONG *PULONG;
#endif
#ifndef VOID
typedef void VOID;
#endif
#ifndef PVOID
typedef void *PVOID;
#endif
#ifndef BOOLEAN
typedef UCHAR BOOLEAN;
#endif
/*
#ifndef bool
typedef UCHAR bool;
#endif
*/
#ifdef LINUX_KERNEL
typedef unsigned long XGIIOADDRESS;
#endif
#ifdef LINUX_XF86
#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,0,0,0)
typedef unsigned char IOADDRESS;
typedef unsigned char XGIIOADDRESS;
#else
typedef IOADDRESS XGIIOADDRESS;
#endif
#endif
#ifndef VBIOS_VER_MAX_LENGTH
#define VBIOS_VER_MAX_LENGTH 4
#endif
#ifndef WIN2000
#ifndef LINUX_KERNEL /* For the linux kernel, this is defined in xgifb.h */
#ifndef XGI_CHIP_TYPE
typedef enum _XGI_CHIP_TYPE {
XGI_VGALegacy = 0,
#ifdef LINUX_XF86
XGI_530,
XGI_OLD,
#endif
XGI_300,
XGI_630,
XGI_640,
XGI_315H,
XGI_315,
XGI_315PRO,
XGI_550,
XGI_650,
XGI_650M,
XGI_740,
XGI_330,
XGI_661,
XGI_660,
XGI_760,
XG40 = 32,
XG41,
XG42,
XG45,
XG20 = 48,
XG21,
XG27,
MAX_XGI_CHIP
} XGI_CHIP_TYPE;
#endif
#endif
#ifndef XGI_VB_CHIP_TYPE
typedef enum _XGI_VB_CHIP_TYPE {
VB_CHIP_Legacy = 0,
VB_CHIP_301,
VB_CHIP_301B,
VB_CHIP_301LV,
VB_CHIP_302,
VB_CHIP_302B,
VB_CHIP_302LV,
VB_CHIP_301C,
VB_CHIP_302ELV,
VB_CHIP_UNKNOWN, /* other video bridge or no video bridge */
MAX_VB_CHIP
} XGI_VB_CHIP_TYPE;
#endif
#ifndef XGI_LCD_TYPE
typedef enum _XGI_LCD_TYPE {
LCD_INVALID = 0,
LCD_320x480, /* FSTN, DSTN */
LCD_640x480,
LCD_640x480_2, /* FSTN, DSTN */
LCD_640x480_3, /* FSTN, DSTN */
LCD_800x600,
LCD_848x480,
LCD_1024x600,
LCD_1024x768,
LCD_1152x768,
LCD_1152x864,
LCD_1280x720,
LCD_1280x768,
LCD_1280x800,
LCD_1280x960,
LCD_1280x1024,
LCD_1400x1050,
LCD_1600x1200,
LCD_1680x1050,
LCD_1920x1440,
LCD_2048x1536,
LCD_CUSTOM,
LCD_UNKNOWN
} XGI_LCD_TYPE;
#endif
#endif /* not WIN2000 */
#ifndef PXGI_DSReg
typedef struct _XGI_DSReg
{
UCHAR jIdx;
UCHAR jVal;
} XGI_DSReg, *PXGI_DSReg;
#endif
#ifndef XGI_HW_DEVICE_INFO
typedef struct _XGI_HW_DEVICE_INFO XGI_HW_DEVICE_INFO, *PXGI_HW_DEVICE_INFO;
typedef BOOLEAN (*PXGI_QUERYSPACE) (PXGI_HW_DEVICE_INFO, ULONG, ULONG, ULONG *);
struct _XGI_HW_DEVICE_INFO
{
ULONG ulExternalChip; /* NO VB or other video bridge*/
/* if ujVBChipID = VB_CHIP_UNKNOWN, */
#ifdef LINUX_XF86
PCITAG PciTag; /* PCI Tag */
#endif
PUCHAR pjVirtualRomBase; /* ROM image */
BOOLEAN UseROM; /* Use the ROM image if provided */
PVOID pDevice;
PUCHAR pjVideoMemoryAddress;/* base virtual memory address */
/* of Linear VGA memory */
ULONG ulVideoMemorySize; /* size, in bytes, of the memory on the board */
PUCHAR pjIOAddress; /* base I/O address of VGA ports (0x3B0) */
PUCHAR pjCustomizedROMImage;
PUCHAR pj2ndVideoMemoryAddress;
ULONG ul2ndVideoMemorySize;
PUCHAR pj2ndIOAddress;
/*#ifndef WIN2000
XGIIOADDRESS pjIOAddress; // base I/O address of VGA ports (0x3B0)
#endif */
UCHAR jChipType; /* Used to Identify Graphics Chip */
/* defined in the data structure type */
/* "XGI_CHIP_TYPE" */
UCHAR jChipRevision; /* Used to Identify Graphics Chip Revision */
UCHAR ujVBChipID; /* the ID of video bridge */
/* defined in the data structure type */
/* "XGI_VB_CHIP_TYPE" */
BOOLEAN bNewScratch;
ULONG ulCRT2LCDType; /* defined in the data structure type */
ULONG usExternalChip; /* NO VB or other video bridge (other than */
/* video bridge) */
BOOLEAN bIntegratedMMEnabled;/* supporting integration MM enable */
BOOLEAN bSkipDramSizing; /* True: Skip video memory sizing. */
BOOLEAN bSkipSense;
BOOLEAN bIsPowerSaving; /* True: XGIInit() is invoked by power management,
otherwise by 2nd adapter's initialzation */
PXGI_DSReg pSR; /* restore SR registers in initial function. */
/* end data :(idx, val) = (FF, FF). */
/* Note : restore SR registers if */
/* bSkipDramSizing = TRUE */
PXGI_DSReg pCR; /* restore CR registers in initial function. */
/* end data :(idx, val) = (FF, FF) */
/* Note : restore cR registers if */
/* bSkipDramSizing = TRUE */
/*
#endif
*/
PXGI_QUERYSPACE pQueryVGAConfigSpace;
PXGI_QUERYSPACE pQueryNorthBridgeSpace;
UCHAR szVBIOSVer[VBIOS_VER_MAX_LENGTH];
};
#endif
/* Addtional IOCTL for communication xgifb <> X driver */
/* If changing this, xgifb.h must also be changed (for xgifb) */
#ifdef LINUX_XF86 /* We don't want the X driver to depend on the kernel source */
/* ioctl for identifying and giving some info (esp. memory heap start) */
#define XGIFB_GET_INFO 0x80046ef8 /* Wow, what a terrible hack... */
/* Structure argument for XGIFB_GET_INFO ioctl */
typedef struct _XGIFB_INFO xgifb_info, *pxgifb_info;
struct _XGIFB_INFO {
CARD32 xgifb_id; /* for identifying xgifb */
#ifndef XGIFB_ID
#define XGIFB_ID 0x53495346 /* Identify myself with 'XGIF' */
#endif
CARD32 chip_id; /* PCI ID of detected chip */
CARD32 memory; /* video memory in KB which xgifb manages */
CARD32 heapstart; /* heap start (= xgifb "mem" argument) in KB */
CARD8 fbvidmode; /* current xgifb mode */
CARD8 xgifb_version;
CARD8 xgifb_revision;
CARD8 xgifb_patchlevel;
CARD8 xgifb_caps; /* xgifb's capabilities */
CARD32 xgifb_tqlen; /* turbo queue length (in KB) */
CARD32 xgifb_pcibus; /* The card's PCI ID */
CARD32 xgifb_pcislot;
CARD32 xgifb_pcifunc;
CARD8 xgifb_lcdpdc;
CARD8 xgifb_lcda;
CARD32 xgifb_vbflags;
CARD32 xgifb_currentvbflags;
CARD32 xgifb_scalelcd;
CARD32 xgifb_specialtiming;
CARD8 xgifb_haveemi;
CARD8 xgifb_emi30,xgifb_emi31,xgifb_emi32,xgifb_emi33;
CARD8 xgifb_haveemilcd;
CARD8 xgifb_lcdpdca;
CARD8 reserved[212]; /* for future use */
};
#endif
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment