From: Thomas Winischhofer sisfb is simply broken in current 2.6.x. This patch updates sisfb to the current development version which no less than 11 months ahead of the version in the kernel. Updated includes - many fixes (duh) - support for new chipsets (661, 741, 760) - support for new video bridges (301C, 302ELV) - removal of all offending fp code (as discussed earlier this month) - a lot of code clean-up (which is the main reason for its size) --- drivers/video/Kconfig | 21 drivers/video/sis/300vtbl.h | 2718 +----- drivers/video/sis/310vtbl.h | 4971 +++-------- drivers/video/sis/init.c | 7835 ++++++++--------- drivers/video/sis/init.h | 2909 ++++++ drivers/video/sis/init301.c |18511 +++++++++++++++++++++--------------------- drivers/video/sis/init301.h | 591 - drivers/video/sis/initdef.h | 452 - drivers/video/sis/oem300.h | 565 - drivers/video/sis/oem310.h | 524 - drivers/video/sis/osdef.h | 174 drivers/video/sis/sis_accel.c | 176 drivers/video/sis/sis_accel.h | 44 drivers/video/sis/sis_main.c | 4178 +++++---- drivers/video/sis/sis_main.h | 729 + drivers/video/sis/vgatypes.h | 285 drivers/video/sis/vstruct.h | 228 include/video/sisfb.h | 289 18 files changed, 23176 insertions(+), 22024 deletions(-) diff -puN drivers/video/Kconfig~sisfb-update drivers/video/Kconfig --- 25/drivers/video/Kconfig~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/Kconfig 2004-01-22 03:06:55.000000000 -0800 @@ -673,26 +673,27 @@ config FB_ATY_XL_INIT Say Y here to support booting a Rage XL without BIOS support. config FB_SIS - tristate "SIS acceleration" + tristate "SiS acceleration" depends on FB && PCI help - This is the frame buffer device driver for the SiS 630 and 640 Super - Socket 7 UMA cards. Specs available at . + This is the frame buffer device driver for the SiS 300, 315 and + 330 series VGA chipsets. Specs available at http://www.sis.com + + To compile this driver as a module, choose M here; the module + will be called sisfb. config FB_SIS_300 - bool "SIS 630/540/730 support" + bool "SiS 300 series support" depends on FB_SIS help - This is the frame buffer device driver for the SiS 630 and related - Super Socket 7 UMA cards. Specs available at - . + Say Y here to support use of the SiS 300/305, 540, 630 and 730. config FB_SIS_315 - bool "SIS 315H/315 support" + bool "SiS 315/330 series support" depends on FB_SIS help - This is the frame buffer device driver for the SiS 315 graphics - card. Specs available at . + Say Y here to support use of the SiS 315 and 330 series + (315/H/PRO, 55x, 650, 651, 740, 330, 661, 741, 760). config FB_NEOMAGIC tristate "NeoMagic display support" diff -puN drivers/video/sis/300vtbl.h~sisfb-update drivers/video/sis/300vtbl.h --- 25/drivers/video/sis/300vtbl.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/300vtbl.h 2004-01-22 03:06:55.000000000 -0800 @@ -1,7 +1,56 @@ - - -/* Register settings for SiS 300 series */ - +/* $XFree86$ */ +/* + * Register settings for SiS 300 series + * + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the Linux kernel, the following license terms + * apply: + * + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Otherwise, the following license terms apply: + * + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) All advertising materials mentioning features or use of this software + * * must display the following acknowledgement: "This product includes + * * software developed by Thomas Winischhofer, Vienna, Austria." + * * 4) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * + */ typedef struct _SiS300_StStruct { @@ -13,577 +62,220 @@ typedef struct _SiS300_StStruct UCHAR VB_StTVFlickerIndex; UCHAR VB_StTVEdgeIndex; UCHAR VB_StTVYFilterIndex; + UCHAR St_PDC; } SiS300_StStruct; static const SiS300_StStruct SiS300_SModeIDTable[] = { - {0x01,0x9208,0x01,0x00,0x00,0x00,0x00,0x00}, - {0x01,0x1210,0x14,0x01,0x01,0x00,0x00,0x00}, - {0x01,0x1010,0x17,0x02,0x02,0x00,0x00,0x00}, - {0x03,0x8208,0x03,0x00,0x00,0x00,0x00,0x00}, - {0x03,0x0210,0x16,0x01,0x01,0x00,0x00,0x00}, - {0x03,0x0010,0x18,0x02,0x02,0x00,0x00,0x00}, - {0x05,0x9209,0x05,0x00,0x00,0x00,0x00,0x00}, - {0x06,0x8209,0x06,0x00,0x00,0x00,0x00,0x00}, - {0x07,0x0000,0x07,0x03,0x03,0x00,0x00,0x00}, - {0x07,0x0000,0x19,0x02,0x02,0x00,0x00,0x00}, - {0x0d,0x920a,0x0d,0x00,0x00,0x00,0x00,0x00}, - {0x0e,0x820a,0x0e,0x00,0x00,0x00,0x00,0x00}, - {0x0f,0x0202,0x11,0x01,0x01,0x00,0x00,0x00}, - {0x10,0x0212,0x12,0x01,0x01,0x00,0x00,0x00}, - {0x11,0x0212,0x1a,0x04,0x04,0x00,0x00,0x00}, - {0x12,0x0212,0x1b,0x04,0x04,0x00,0x00,0x00}, - {0x13,0x021b,0x1c,0x00,0x00,0x00,0x00,0x00}, - {0x12,0x0010,0x18,0x02,0x02,0x00,0x00,0x00}, - {0x12,0x0210,0x18,0x01,0x01,0x00,0x00,0x00}, - {0xff, 0, 0, 0, 0, 0, 0, 0} -}; - -typedef struct _SiS300_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]; -} SiS300_StandTableStruct; - -static const SiS300_StandTableStruct SiS300_StandTable[] = -{ - {0x28,0x18,0x08,0x0800, /* 0x00 */ - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x28,0x18,0x08,0x0800, /* 0x01 */ - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x50,0x18,0x08,0x1000, /* 0x02 */ - {0x01,0x03,0x00,0x02}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x50,0x18,0x08,0x1000, /* 0x03 */ - {0x01,0x03,0x00,0x02}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x28,0x18,0x08,0x4000, /* 0x04 */ - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0x80,0xbf,0x1f, - 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2, - 0xff}, - {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x03,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00, - 0xff} }, - {0x28,0x18,0x08,0x4000, /* 0x05 */ - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0x80,0xbf,0x1f, - 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2, - 0xff}, - {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x03,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00, - 0xff} }, - {0x50,0x18,0x08,0x4000, /* 0x06 */ - {0x01,0x01,0x00,0x06}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f, - 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2, - 0xff}, - {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17, - 0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17, - 0x01,0x00,0x01,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00, - 0xff} }, - {0x50,0x18,0x0e,0x1000, /* 0x07 */ - {0x00,0x03,0x00,0x03}, - 0xa6, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3, - 0xff}, - {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08, - 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18, - 0x0e,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00, - 0xff} }, -/* MDA_DAC*/ - {0x00,0x00,0x00,0x0000, /* 0x08 */ - {0x00,0x00,0x00,0x15}, - 0x15, - {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, - 0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00, - 0x00}, - {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15, - 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, - 0x15,0x15,0x15,0x15}, - {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f} }, -/* CGA_DAC*/ - {0x00,0x10,0x04,0x0114, /* 0x09 */ - {0x11,0x09,0x15,0x00}, - 0x10, - {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a, - 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a, - 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10, - 0x04}, - {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04, - 0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e, - 0x3e,0x2b,0x3b,0x2f}, - {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f, - 0x3f} }, -/* EGA_DAC*/ - {0x00,0x10,0x04,0x0114, /* 0x0a */ - {0x11,0x05,0x15,0x20}, - 0x30, - {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18, - 0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38, - 0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12, - 0x06}, - {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26, - 0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e, - 0x1e,0x0b,0x1b,0x0f}, - {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f, - 0x3f} }, -/* VGA_DAC*/ - {0x00,0x10,0x04,0x0114, /* 0x0b */ - {0x11,0x09,0x15,0x2a}, - 0x3a, - {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05, - 0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20, - 0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10, - 0x1f}, - {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d, - 0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15, - 0x1c,0x0e,0x11,0x15}, - {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00, - 0x04} }, - {0x08,0x0c,0x10,0x0a08, /* 0x0c */ - {0x0c,0x0e,0x10,0x0b}, - 0x0c, - {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00, - 0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00, - 0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00, - 0x06}, - {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08, - 0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00, - 0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00} }, - {0x28,0x18,0x08,0x2000, /* 0x0d */ - {0x09,0x0f,0x00,0x06}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0x80,0xbf,0x1f, - 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} }, - {0x50,0x18,0x08,0x4000, /* 0x0e */ - {0x01,0x0f,0x00,0x06}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f, - 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} }, - {0x00,0x00,0x00,0x0000, /* 0x0f */ /* TW: Standtable for VGA modes */ - {0x01,0x0f,0x00,0x0e}, - 0x23, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, - 0x01,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, - 0xff} }, - {0x4a,0x36,0x00,0x00c0, /* 0x10 */ - {0x00,0x00,0x00,0x00}, - 0x00, - {0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x3a, - 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x1a,0x00,0x57,0x39,0x00,0xc0, - 0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00} }, - {0x50,0x18,0x0e,0x8000, /* 0x11 */ - {0x01,0x0f,0x00,0x06}, - 0xa2, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x0f,0x63,0xba,0xe3, - 0xff}, - {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00, - 0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00, - 0x0b,0x00,0x05,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05, - 0xff} }, - {0x50,0x18,0x0e,0x8000, /* 0x12 */ - {0x01,0x0f,0x00,0x06}, - 0xa3, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x0f,0x63,0xba,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} }, - {0x28,0x18,0x0e,0x0800, /* 0x13 */ - {0x09,0x03,0x00,0x02}, - 0xa3, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x28,0x18,0x0e,0x0800, /* 0x14 */ - {0x09,0x03,0x00,0x02}, - 0xa3, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x50,0x18,0x0e,0x1000, /* 0x15 */ - {0x01,0x03,0x00,0x02}, - 0xa3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x50,0x18,0x0e,0x1000, /* 0x16 */ - {0x01,0x03,0x00,0x02}, - 0xa3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x28,0x18,0x10,0x0800, /* 0x17 */ - {0x08,0x03,0x00,0x02}, - 0x67, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x0c,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x50,0x18,0x10,0x1000, /* 0x18 */ - {0x00,0x03,0x00,0x02}, - 0x67, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x0c,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x50,0x18,0x10,0x1000, /* 0x19 */ - {0x00,0x03,0x00,0x02}, - 0x66, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08, - 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18, - 0x0e,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00, - 0xff} }, - {0x50,0x1d,0x10,0xa000, /* 0x1a */ - {0x01,0x0f,0x00,0x06}, - 0xe3, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0xea,0x8c,0xdf,0x28,0x00,0xe7,0x04,0xc3, - 0xff}, - {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01, - 0xff} }, - {0x50,0x1d,0x10,0xa000, /* 0x1b */ - {0x01,0x0f,0x00,0x06}, - 0xe3, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0xea,0x8c,0xdf,0x28,0x00,0xe7,0x04,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} }, - {0x28,0x18,0x08,0x2000, /* 0x1c */ - {0x01,0x0f,0x00,0x0e}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f, - 0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, - 0x41,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, - 0xff} } + {0x01,0x9208,0x01,0x00,0x00,0x00,0x00,0x00, 0}, + {0x01,0x1210,0x14,0x01,0x01,0x00,0x00,0x00, 0}, + {0x01,0x1010,0x17,0x02,0x02,0x00,0x00,0x00, 0}, + {0x03,0x8208,0x03,0x00,0x00,0x00,0x00,0x00, 0}, + {0x03,0x0210,0x16,0x01,0x01,0x00,0x00,0x00, 0}, + {0x03,0x0010,0x18,0x02,0x02,0x00,0x00,0x00, 0}, + {0x05,0x9209,0x05,0x00,0x00,0x00,0x00,0x00, 0}, + {0x06,0x8209,0x06,0x00,0x00,0x00,0x00,0x00, 0}, + {0x07,0x0000,0x07,0x03,0x03,0x00,0x00,0x00, 0}, + {0x07,0x0000,0x19,0x02,0x02,0x00,0x00,0x00, 0}, + {0x0d,0x920a,0x0d,0x00,0x00,0x00,0x00,0x00, 0}, + {0x0e,0x820a,0x0e,0x00,0x00,0x00,0x00,0x00, 0}, + {0x0f,0x0202,0x11,0x01,0x01,0x00,0x00,0x00, 0}, + {0x10,0x0212,0x12,0x01,0x01,0x00,0x00,0x00, 0}, + {0x11,0x0212,0x1a,0x04,0x04,0x00,0x00,0x00, 0}, + {0x12,0x0212,0x1b,0x04,0x04,0x00,0x00,0x00, 0}, + {0x13,0x021b,0x1c,0x00,0x00,0x00,0x00,0x00, 0}, + {0x12,0x0010,0x18,0x02,0x02,0x00,0x00,0x00, 0}, + {0x12,0x0210,0x18,0x01,0x01,0x00,0x00,0x00, 0}, + {0xff, 0, 0, 0, 0, 0, 0, 0, 0} }; typedef struct _SiS300_ExtStruct { - UCHAR Ext_ModeID; + UCHAR Ext_ModeID; USHORT Ext_ModeFlag; - USHORT Ext_ModeInfo; - USHORT Ext_Point; + UCHAR Ext_ModeOffset; USHORT Ext_VESAID; - UCHAR Ext_VESAMEMSize; - UCHAR Ext_RESINFO; - UCHAR VB_ExtTVFlickerIndex; - UCHAR VB_ExtTVEdgeIndex; - UCHAR VB_ExtTVYFilterIndex; - UCHAR REFindex; + UCHAR Ext_RESINFO; + UCHAR VB_ExtTVFlickerIndex; + UCHAR VB_ExtTVEdgeIndex; + UCHAR VB_ExtTVYFilterIndex; + UCHAR VB_ExtTVYFilterIndexROM661; + UCHAR REFindex; } SiS300_ExtStruct; static const SiS300_ExtStruct SiS300_EModeIDTable[] = { - {0x6a,0x2212,0x47,0x3563,0x0102,0x08,0x07,0x00,0x00,0x00,0x00}, /* 800x600x? */ - {0x2e,0x0a1b,0x36,0x3539,0x0101,0x08,0x06,0x00,0x00,0x00,0x08}, - {0x2f,0x021b,0x35,0x3532,0x0100,0x08,0x05,0x00,0x00,0x00,0x10}, /* 640x400x8 */ - {0x30,0x2a1b,0x47,0x3563,0x0103,0x08,0x07,0x00,0x00,0x00,0x00}, - {0x31,0x0a1b,0xad,0x3630,0x0000,0x08,0x0c,0x00,0x00,0x00,0x11}, /* 720x480x8 */ - {0x32,0x2a1b,0xae,0x3637,0x0000,0x08,0x0d,0x00,0x00,0x00,0x12}, /* 720x576x8 */ - {0x33,0x0a1d,0xad,0x3630,0x0000,0x08,0x0c,0x00,0x00,0x00,0x11}, /* 720x480x16 */ - {0x34,0x2a1d,0xae,0x3637,0x0000,0x08,0x0d,0x00,0x00,0x00,0x12}, /* 720x576x16 */ - {0x35,0x0a1f,0xad,0x3630,0x0000,0x08,0x0c,0x00,0x00,0x00,0x11}, /* 720x480x32 */ - {0x36,0x2a1f,0xae,0x3637,0x0000,0x08,0x0d,0x00,0x00,0x00,0x12}, /* 720x576x32 */ - {0x37,0x0212,0x58,0x358d,0x0104,0x08,0x08,0x00,0x00,0x00,0x13}, /* 1024x768x? */ - {0x38,0x0a1b,0x58,0x358d,0x0105,0x08,0x08,0x00,0x00,0x00,0x13}, /* 1024x768x8 */ - {0x3a,0x0e3b,0x69,0x35be,0x0107,0x08,0x09,0x00,0x00,0x00,0x1a}, /* 1280x1024x8 */ - {0x3c,0x063b,0x7a,0x35d4,0x0130,0x08,0x0a,0x00,0x00,0x00,0x1e}, - {0x3d,0x067d,0x7a,0x35d4,0x0131,0x08,0x0a,0x00,0x00,0x00,0x1e}, - {0x40,0x921c,0x00,0x3516,0x010d,0x08,0x00,0x00,0x00,0x00,0x23}, - {0x41,0x921d,0x00,0x3516,0x010e,0x08,0x00,0x00,0x00,0x00,0x23}, - {0x43,0x0a1c,0x36,0x3539,0x0110,0x08,0x06,0x00,0x00,0x00,0x08}, - {0x44,0x0a1d,0x36,0x3539,0x0111,0x08,0x06,0x00,0x00,0x00,0x08}, - {0x46,0x2a1c,0x47,0x3563,0x0113,0x08,0x07,0x00,0x00,0x00,0x00}, /* 800x600 */ - {0x47,0x2a1d,0x47,0x3563,0x0114,0x08,0x07,0x00,0x00,0x00,0x00}, /* 800x600 */ - {0x49,0x0a3c,0x58,0x358d,0x0116,0x08,0x08,0x00,0x00,0x00,0x13}, - {0x4a,0x0a3d,0x58,0x358d,0x0117,0x08,0x08,0x00,0x00,0x00,0x13}, - {0x4c,0x0e7c,0x69,0x35be,0x0119,0x08,0x09,0x00,0x00,0x00,0x1a}, - {0x4d,0x0e7d,0x69,0x35be,0x011a,0x08,0x09,0x00,0x00,0x00,0x1a}, - {0x50,0x921b,0x01,0x351d,0x0132,0x08,0x01,0x00,0x00,0x00,0x24}, - {0x51,0xb21b,0x13,0x3524,0x0133,0x08,0x03,0x00,0x00,0x00,0x25}, /* 400x300 */ - {0x52,0x921b,0x24,0x352b,0x0134,0x08,0x04,0x00,0x00,0x00,0x26}, - {0x56,0x921d,0x01,0x351d,0x0135,0x08,0x01,0x00,0x00,0x00,0x24}, - {0x57,0xb21d,0x13,0x3524,0x0136,0x08,0x03,0x00,0x00,0x00,0x25}, /* 400x300 */ - {0x58,0x921d,0x24,0x352b,0x0137,0x08,0x04,0x00,0x00,0x00,0x26}, - {0x59,0x921b,0x00,0x3516,0x0138,0x08,0x00,0x00,0x00,0x00,0x23}, - {0x5c,0x921f,0x24,0x352b,0x0000,0x08,0x04,0x00,0x00,0x00,0x26}, /* TW: inserted 512x384x32 */ - {0x5d,0x021d,0x35,0x3532,0x0139,0x08,0x05,0x00,0x00,0x00,0x10}, /* 640x400x16 */ - {0x5e,0x021f,0x35,0x3532,0x0000,0x08,0x05,0x00,0x00,0x00,0x10}, /* TW: inserted 640x400x32 */ - {0x62,0x0a3f,0x36,0x3539,0x013a,0x08,0x06,0x00,0x00,0x00,0x08}, - {0x63,0x2a3f,0x47,0x3563,0x013b,0x08,0x07,0x00,0x00,0x00,0x00}, /* 800x600 */ - {0x64,0x0a7f,0x58,0x358d,0x013c,0x08,0x08,0x00,0x00,0x00,0x13}, - {0x65,0x0eff,0x69,0x35be,0x013d,0x08,0x09,0x00,0x00,0x00,0x1a}, - {0x66,0x06ff,0x7a,0x35d4,0x013e,0x08,0x0a,0x00,0x00,0x00,0x1e}, - {0x68,0x067b,0x8b,0x35ef,0x013f,0x08,0x0b,0x00,0x00,0x00,0x27}, - {0x69,0x06fd,0x8b,0x35ef,0x0140,0x08,0x0b,0x00,0x00,0x00,0x27}, - {0x6b,0x07ff,0x8b,0x35ef,0x0000,0x10,0x0b,0x00,0x00,0x00,0x27}, - {0x6c,0x067b,0x9c,0x35f6,0x0000,0x08,0x11,0x00,0x00,0x00,0x28}, /* TW: 2048x1536x8 - not in BIOS! */ - {0x6d,0x06fd,0x9c,0x35f6,0x0000,0x10,0x11,0x00,0x00,0x00,0x28}, /* TW: 2048x1536x16 - not in BIOS! */ - {0x6e,0x0a3b,0x6f,0x35b2,0x0000,0x08,0x0e,0x00,0x00,0x00,0x29}, /* 1280x960x8 */ - {0x6f,0x0a7d,0x6f,0x35b2,0x0000,0x08,0x0e,0x00,0x00,0x00,0x29}, /* 1280x960x16 */ - /* TW: 16:9 modes copied from 310/325 series - not in ANY BIOS */ - {0x70,0x2a1b,0x40,0x3b52,0x0000,0x08,0x12,0x00,0x00,0x07,0x2d}, /* 800x480x8 */ - {0x71,0x0a1b,0x51,0x3b63,0x0000,0x08,0x13,0x00,0x00,0x00,0x30}, /* 1024x576x8 */ - {0x74,0x0a1d,0x51,0x3b63,0x0000,0x08,0x13,0x00,0x00,0x00,0x30}, /* 1024x576x16 */ - {0x75,0x0e3d,0x62,0x3b74,0x0000,0x08,0x14,0x00,0x00,0x00,0x33}, /* 1280x720x16 */ - {0x76,0x2a1f,0x40,0x3b52,0x0000,0x08,0x12,0x00,0x00,0x07,0x2d}, /* 800x480x32 */ - {0x77,0x0a3f,0x51,0x3b63,0x0000,0x08,0x13,0x00,0x00,0x00,0x30}, /* 1024x576x32 */ - {0x78,0x0eff,0x62,0x3b74,0x0000,0x08,0x14,0x00,0x00,0x00,0x33}, /* 1280x720x32 */ - {0x79,0x0e3b,0x62,0x3b74,0x0000,0x08,0x14,0x00,0x00,0x00,0x33}, /* 1280x720x8 */ - {0x7a,0x2a1d,0x40,0x3b52,0x0000,0x08,0x12,0x00,0x00,0x07,0x2d}, /* 800x480x16 */ - /* TW: End of new 16:9 modes */ - {0x7b,0x0aff,0x6f,0x35b2,0x0000,0x08,0x0e,0x00,0x00,0x00,0x29}, /* 1280x960x32 */ - {0x20,0x0a1b,0x54,0x0000,0x0000,0x08,0x0f,0x00,0x00,0x00,0x2b}, /* 1024x600 */ - {0x21,0x0a3d,0x54,0x0000,0x0000,0x08,0x0f,0x00,0x00,0x00,0x2b}, - {0x22,0x0a7f,0x54,0x0000,0x0000,0x08,0x0f,0x00,0x00,0x00,0x2b}, - {0x23,0x0a1b,0xc5,0x0000,0x0000,0x08,0x10,0x00,0x00,0x00,0x2c}, /* 1152x768 */ - {0x24,0x0a3d,0xc5,0x431d,0x0000,0x08,0x10,0x00,0x00,0x00,0x2c}, - {0x25,0x0a7f,0xc5,0x431d,0x0000,0x08,0x10,0x00,0x00,0x00,0x2c}, - {0x29,0x0e1b,0xc5,0x0000,0x0000,0x08,0x15,0x00,0x00,0x00,0x36}, /* TW: NEW 1152x864 - not in BIOS */ - {0x2a,0x0e3d,0xc5,0x0000,0x0000,0x08,0x15,0x00,0x00,0x00,0x36}, - {0x2b,0x0e7f,0xc5,0x0000,0x0000,0x08,0x15,0x00,0x00,0x00,0x36}, - {0x39,0x2a1b,0xd6,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x38}, /* TW: NEW 848x480 - not in BIOS */ - {0x3b,0x2a3d,0xd6,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x38}, - {0x3e,0x2a7f,0xd6,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x38}, - {0x3f,0x2a1b,0xd7,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x3a}, /* TW: NEW 856x480 - not in BIOS */ - {0x42,0x2a3d,0xd7,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x3a}, - {0x45,0x2a7f,0xd7,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x3a}, - {0x48,0x223b,0xe8,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x3c}, /* TW: NEW 1360x768 - not in BIOS */ - {0x4b,0x227d,0xe8,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x3c}, - {0x4e,0x22ff,0xe8,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x3c}, - {0xff,0x0000,0x00,0x0000,0xffff,0x00,0x00,0x00,0x00,0x00,0x00} + {0x6a,0x2212,0x04,0x0102,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00}, /* 800x600x? */ + {0x2e,0x0a1b,0x03,0x0101,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08}, + {0x2f,0x021b,0x03,0x0100,SIS_RI_640x400, 0x00,0x00,0x00,0x00,0x10}, /* 640x400x8 */ + {0x30,0x2a1b,0x04,0x0103,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00}, + {0x31,0x0a1b,0x0a,0x0000,SIS_RI_720x480, 0x00,0x00,0x00,0x00,0x11}, /* 720x480x8 */ + {0x32,0x2a1b,0x0a,0x0000,SIS_RI_720x576, 0x00,0x00,0x00,0x00,0x12}, /* 720x576x8 */ + {0x33,0x0a1d,0x0a,0x0000,SIS_RI_720x480, 0x00,0x00,0x00,0x00,0x11}, /* 720x480x16 */ + {0x34,0x2a1d,0x0a,0x0000,SIS_RI_720x576, 0x00,0x00,0x00,0x00,0x12}, /* 720x576x16 */ + {0x35,0x0a1f,0x0a,0x0000,SIS_RI_720x480, 0x00,0x00,0x00,0x00,0x11}, /* 720x480x32 */ + {0x36,0x2a1f,0x0a,0x0000,SIS_RI_720x576, 0x00,0x00,0x00,0x00,0x12}, /* 720x576x32 */ + {0x37,0x0212,0x05,0x0104,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13}, /* 1024x768x? */ + {0x38,0x0a1b,0x05,0x0105,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13}, /* 1024x768x8 */ + {0x3a,0x0e3b,0x06,0x0107,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, /* 1280x1024x8 */ + {0x3c,0x063b,0x07,0x0130,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e}, + {0x3d,0x067d,0x07,0x0131,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e}, + {0x40,0x921c,0x00,0x010d,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23}, /* 320x200x15 */ + {0x41,0x921d,0x00,0x010e,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23}, /* 320x200x16 */ + {0x43,0x0a1c,0x03,0x0110,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08}, + {0x44,0x0a1d,0x03,0x0111,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08}, + {0x46,0x2a1c,0x04,0x0113,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00}, /* 800x600x15 */ + {0x47,0x2a1d,0x04,0x0114,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00}, /* 800x600x16 */ + {0x49,0x0a3c,0x05,0x0116,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13}, + {0x4a,0x0a3d,0x05,0x0117,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13}, + {0x4c,0x0e7c,0x06,0x0119,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, + {0x4d,0x0e7d,0x06,0x011a,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, + {0x50,0x921b,0x00,0x0132,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x24}, /* 320x240x8 */ + {0x51,0xb21b,0x01,0x0133,SIS_RI_400x300, 0x00,0x00,0x00,0x00,0x25}, /* 400x300x8 */ + {0x52,0x921b,0x02,0x0134,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x26}, /* 512x384x8 */ + {0x56,0x921d,0x00,0x0135,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x24}, /* 320x240x16 */ + {0x57,0xb21d,0x01,0x0136,SIS_RI_400x300, 0x00,0x00,0x00,0x00,0x25}, /* 400x300x16 */ + {0x58,0x921d,0x02,0x0137,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x26}, /* 512x384x16 */ + {0x59,0x921b,0x00,0x0138,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23}, /* 320x200x8 */ + {0x5c,0x921f,0x02,0x0000,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x26}, /* 512x384x32 */ + {0x5d,0x021d,0x03,0x0139,SIS_RI_640x400, 0x00,0x00,0x00,0x00,0x10}, /* 640x400x16 */ + {0x5e,0x021f,0x03,0x0000,SIS_RI_640x400, 0x00,0x00,0x00,0x00,0x10}, /* 640x400x32 */ + {0x62,0x0a3f,0x03,0x013a,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08}, + {0x63,0x2a3f,0x04,0x013b,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00}, /* 800x600x32 */ + {0x64,0x0a7f,0x05,0x013c,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13}, + {0x65,0x0eff,0x06,0x013d,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, + {0x66,0x06ff,0x07,0x013e,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e}, + {0x68,0x067b,0x08,0x013f,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x27}, + {0x69,0x06fd,0x08,0x0140,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x27}, + {0x6b,0x07ff,0x08,0x0000,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x27}, + {0x6c,0x067b,0x09,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x28}, /* 2048x1536x8 - not in BIOS! */ + {0x6d,0x06fd,0x09,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x28}, /* 2048x1536x16 - not in BIOS! */ + {0x70,0x2a1b,0x04,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x00,0x2d}, /* 800x480x8 */ + {0x71,0x0a1b,0x05,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x30}, /* 1024x576x8 */ + {0x74,0x0a1d,0x05,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x30}, /* 1024x576x16 */ + {0x75,0x0e3d,0x06,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x33}, /* 1280x720x16 */ + {0x76,0x2a1f,0x04,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x00,0x2d}, /* 800x480x32 */ + {0x77,0x0a3f,0x05,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x30}, /* 1024x576x32 */ + {0x78,0x0eff,0x06,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x33}, /* 1280x720x32 */ + {0x79,0x0e3b,0x06,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x33}, /* 1280x720x8 */ + {0x7a,0x2a1d,0x04,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x00,0x2d}, /* 800x480x16 */ + {0x7c,0x0a3b,0x06,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x29}, /* 1280x960x8 */ + {0x7d,0x0a7d,0x06,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x29}, /* 1280x960x16 */ + {0x7e,0x0aff,0x06,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x29}, /* 1280x960x32 */ + {0x20,0x0a1b,0x05,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x00,0x2b}, /* 1024x600 */ + {0x21,0x0a3d,0x05,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x00,0x2b}, + {0x22,0x0a7f,0x05,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x00,0x2b}, + {0x23,0x0a1b,0x0c,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x00,0x2c}, /* 1152x768 */ + {0x24,0x0a3d,0x0c,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x00,0x2c}, + {0x25,0x0a7f,0x0c,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x00,0x2c}, + {0x29,0x0e1b,0x0c,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x36}, /* 1152x864 */ + {0x2a,0x0e3d,0x0c,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x36}, + {0x2b,0x0e7f,0x0c,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x36}, + {0x39,0x2a1b,0x0d,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x38}, /* 848x480 */ + {0x3b,0x2a3d,0x0d,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x38}, + {0x3e,0x2a7f,0x0d,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x38}, + {0x3f,0x2a1b,0x0d,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x3a}, /* 856x480 */ + {0x42,0x2a3d,0x0d,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x3a}, + {0x45,0x2a7f,0x0d,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x3a}, + {0x48,0x223b,0x0e,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x3c}, /* 1360x768 */ + {0x4b,0x227d,0x0e,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x3c}, + {0x4e,0x22ff,0x0e,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x3c}, + {0x4f,0x921f,0x00,0x0000,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23}, /* 320x200x32 */ + {0x53,0x921f,0x00,0x0000,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x24}, /* 320x240x32 */ + {0x54,0xb21f,0x01,0x0000,SIS_RI_400x300, 0x00,0x00,0x00,0x00,0x25}, /* 400x300x32 */ + {0x55,0x2e3b,0x06,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x3d}, /* 1280x768 */ + {0x5a,0x2e7d,0x06,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x3d}, + {0x5b,0x2eff,0x06,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x3d}, + {0x5f,0x2a1b,0x0f,0x0000,SIS_RI_768x576, 0x00,0x00,0x00,0x00,0x3e}, /* 768x576x8 */ + {0x60,0x2a1d,0x0f,0x0000,SIS_RI_768x576, 0x00,0x00,0x00,0x00,0x3e}, /* 768x576x16 */ + {0x61,0x2a1f,0x0f,0x0000,SIS_RI_768x576, 0x00,0x00,0x00,0x00,0x3e}, /* 768x576x32 */ + {0x67,0x2e3b,0x0e,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x00,0x3f}, /* 1360x1024x8 (BARCO) */ + {0x6f,0x2e7d,0x0e,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x00,0x3f}, /* 1360x1024x16 (BARCO) */ + {0x72,0x2eff,0x0e,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x00,0x3f}, /* 1360x1024x32 (BARCO) */ + {0xff,0x0000,0x00,0xffff,0, 0x00,0x00,0x00,0x00,0x00} }; typedef struct _SiS300_Ext2Struct { USHORT Ext_InfoFlag; - UCHAR Ext_CRT1CRTC; /* TW: Index in SiS300_CRT1Table */ - UCHAR Ext_CRTVCLK; /* TW: Index in VCLK array */ - UCHAR Ext_CRT2CRTC; /* TW: Index in LCD Paneltype arrays (&3f) */ + UCHAR Ext_CRT1CRTC; /* Index in SiS300_CRT1Table */ + UCHAR Ext_CRTVCLK; /* Index in VCLK array */ + UCHAR Ext_CRT2CRTC; /* Index in LCD Paneltype arrays (&3f) */ UCHAR ModeID; USHORT XRes; USHORT YRes; - USHORT ROM_OFFSET; + UCHAR Ext_PDC; } SiS300_Ext2Struct; static const SiS300_Ext2Struct SiS300_RefIndex[] = -{ /* TW: Don't ever insert anything here, table is indexed */ - {0x085f,0x0d,0x03,0x05,0x6a, 800, 600,0x3563}, /* 00 */ - {0x0467,0x0e,0x44,0x05,0x6a, 800, 600,0x3568}, /* 01 */ - {0x0067,0x0f,0x07,0x48,0x6a, 800, 600,0x356d}, /* 02 - CRT1CRTC was 0x4f */ - {0x0067,0x10,0x06,0x8b,0x6a, 800, 600,0x3572}, /* 03 */ - {0x0147,0x11,0x08,0x00,0x6a, 800, 600,0x3577}, /* 04 */ - {0x0147,0x12,0x0c,0x00,0x6a, 800, 600,0x357c}, /* 05 */ - {0x0047,0x11,0x4e,0x00,0x6a, 800, 600,0x3581}, /* 06 - CRT1CRTC was 0x51 */ - {0x0047,0x11,0x13,0x00,0x6a, 800, 600,0x3586}, /* 07 */ - {0xc85f,0x05,0x00,0x04,0x2e, 640, 480,0x3539}, /* 08 */ - {0xc067,0x06,0x02,0x04,0x2e, 640, 480,0x353e}, /* 09 */ - {0xc067,0x07,0x02,0x47,0x2e, 640, 480,0x3543}, /* 0a */ - {0xc067,0x08,0x03,0x8a,0x2e, 640, 480,0x3548}, /* 0b */ - {0xc047,0x09,0x05,0x00,0x2e, 640, 480,0x354d}, /* 0c */ - {0xc047,0x0a,0x08,0x00,0x2e, 640, 480,0x3552}, /* 0d */ - {0xc047,0x0b,0x0a,0x00,0x2e, 640, 480,0x3557}, /* 0e */ - {0xc047,0x0c,0x10,0x00,0x2e, 640, 480,0x355c}, /* 0f */ - {0x487f,0x04,0x00,0x00,0x2f, 640, 400,0x3532}, /* 10 */ - {0xc00f,0x31,0x01,0x06,0x31, 720, 480,0x3630}, /* 11 */ - {0x000f,0x32,0x03,0x06,0x32, 720, 576,0x3637}, /* 12 */ - {0x0187,0x15,0x05,0x00,0x37,1024, 768,0x358d}, /* 13 */ - {0xc877,0x16,0x09,0x06,0x37,1024, 768,0x3592}, /* 14 */ - {0xc067,0x17,0x0b,0x49,0x37,1024, 768,0x3597}, /* 15 - CRT1CRTC was 0x97 */ - {0x0267,0x18,0x0d,0x00,0x37,1024, 768,0x359c}, /* 16 */ - {0x0047,0x19,0x11,0x8c,0x37,1024, 768,0x35a1}, /* 17 - CRT1CRTC was 0x59 */ - {0x0047,0x1a,0x52,0x00,0x37,1024, 768,0x35a6}, /* 18 */ - {0x0007,0x1b,0x16,0x00,0x37,1024, 768,0x35ab}, /* 19 - CRT1CRTC was 0x5b */ - {0x0387,0x1c,0x4d,0x00,0x3a,1280,1024,0x35be}, /* 1a - CRT1CRTC was 0x5c */ - {0x0077,0x1d,0x14,0x07,0x3a,1280,1024,0x35c3}, /* 1b */ - {0x0047,0x1e,0x17,0x00,0x3a,1280,1024,0x35c8}, /* 1c */ - {0x0007,0x1f,0x98,0x00,0x3a,1280,1024,0x35cd}, /* 1d */ - {0x0007,0x20,0x59,0x00,0x3c,1600,1200,0x35d4}, /* 1e - CRT1CRTC was 0x60 */ - {0x0007,0x21,0x5a,0x00,0x3c,1600,1200,0x35d9}, /* 1f */ - {0x0007,0x22,0x1b,0x00,0x3c,1600,1200,0x35de}, /* 20 */ - {0x0007,0x23,0x1d,0x00,0x3c,1600,1200,0x35e3}, /* 21 - CRT1CRTC was 0x63 */ - {0x0007,0x24,0x1e,0x00,0x3c,1600,1200,0x35e8}, /* 22 */ - {0x407f,0x00,0x00,0x00,0x40, 320, 200,0x3516}, /* 23 */ - {0xc07f,0x01,0x00,0x04,0x50, 320, 240,0x351d}, /* 24 */ - {0x0077,0x02,0x04,0x05,0x51, 400, 300,0x3524}, /* 25 */ - {0xc877,0x03,0x09,0x06,0x52, 512, 384,0x352b}, /* 26 */ /* was c077 */ - {0x8207,0x25,0x1f,0x00,0x68,1920,1440,0x35ef}, /* 27 */ - {0x0007,0x26,0x20,0x00,0x6c,2048,1536,0x35f6}, /* 28 */ - {0x0067,0x27,0x14,0x08,0x6e,1280, 960,0x35b7}, /* 29 - TW: 1280x960-60 */ - {0x0027,0x45,0x3c,0x08,0x6e,1280, 960,0x35b7}, /* 2a - TW: 1280x960-85 */ - {0xc077,0x33,0x09,0x06,0x20,1024, 600,0x0000}, /* 2b */ - {0xc077,0x34,0x0b,0x06,0x23,1152, 768,0x0000}, /* 2c */ /* VCLK 0x09 */ - {0x0057,0x35,0x27,0x08,0x70, 800, 480,0x3b52}, /* 2d - TW: 16:9 modes */ - {0x0047,0x36,0x37,0x08,0x70, 800, 480,0x3b57}, /* 2e */ - {0x0047,0x37,0x08,0x08,0x70, 800, 480,0x3b5c}, /* 2f */ - {0x0057,0x38,0x09,0x09,0x71,1024, 576,0x3b63}, /* 30 */ - {0x0047,0x39,0x38,0x09,0x71,1024, 576,0x3b68}, /* 31 */ - {0x0047,0x3a,0x11,0x09,0x71,1024, 576,0x3b6d}, /* 32 */ - {0x0057,0x3b,0x39,0x0a,0x75,1280, 720,0x3b74}, /* 33 */ - {0x0047,0x3c,0x3a,0x0a,0x75,1280, 720,0x3b79}, /* 34 */ - {0x0007,0x3d,0x3b,0x0a,0x75,1280, 720,0x3b7e}, /* 35 - TW: END of 16:9 modes */ - {0x0047,0x3e,0x34,0x06,0x29,1152, 864,0x0000}, /* 36 TW: 1152x864-75Hz - Non-BIOS, new */ - {0x0047,0x44,0x3a,0x06,0x29,1152, 864,0x0000}, /* 37 TW: 1152x864-85Hz - Non-BIOS, new */ - {0x00c7,0x3f,0x28,0x00,0x39, 848, 480,0x0000}, /* 38 TW: 848x480-38Hzi - Non-BIOS, new */ - {0xc047,0x40,0x3d,0x00,0x39, 848, 480,0x0000}, /* 39 TW: 848x480-60Hz - Non-BIOS, new */ - {0x00c7,0x41,0x28,0x00,0x3f, 856, 480,0x0000}, /* 3a TW: 856x480-38Hzi - Non-BIOS, new */ - {0xc047,0x42,0x28,0x00,0x3f, 856, 480,0x0000}, /* 3b TW: 856x480-60Hz - Non-BIOS, new */ - {0x0047,0x43,0x3e,0x00,0x48,1360, 768,0x0000}, /* 3c TW: 1360x768-60Hz - Non-BIOS, new */ - {0xffff,0,0,0,0,0,0,0} +{ + {0x085f,0x0d,0x03,0x05,0x6a, 800, 600, 0}, /* 00 */ + {0x0467,0x0e,0x44,0x05,0x6a, 800, 600, 0}, /* 01 */ + {0x0067,0x0f,0x07,0x48,0x6a, 800, 600, 0}, /* 02 - CRT1CRTC was 0x4f */ + {0x0067,0x10,0x06,0x8b,0x6a, 800, 600, 0}, /* 03 */ + {0x0147,0x11,0x08,0x00,0x6a, 800, 600, 0}, /* 04 */ + {0x0147,0x12,0x0c,0x00,0x6a, 800, 600, 0}, /* 05 */ + {0x0047,0x11,0x4e,0x00,0x6a, 800, 600, 0}, /* 06 - CRT1CRTC was 0x51 */ + {0x0047,0x11,0x13,0x00,0x6a, 800, 600, 0}, /* 07 */ + {0xc85f,0x05,0x00,0x04,0x2e, 640, 480, 0}, /* 08 */ + {0xc067,0x06,0x02,0x04,0x2e, 640, 480, 0}, /* 09 */ + {0xc067,0x07,0x02,0x47,0x2e, 640, 480, 0}, /* 0a */ + {0xc067,0x08,0x03,0x8a,0x2e, 640, 480, 0}, /* 0b */ + {0xc047,0x09,0x05,0x00,0x2e, 640, 480, 0}, /* 0c */ + {0xc047,0x0a,0x08,0x00,0x2e, 640, 480, 0}, /* 0d */ + {0xc047,0x0b,0x0a,0x00,0x2e, 640, 480, 0}, /* 0e */ + {0xc047,0x0c,0x10,0x00,0x2e, 640, 480, 0}, /* 0f */ + {0x487f,0x04,0x00,0x00,0x2f, 640, 400, 0}, /* 10 */ + {0xc04f,0x31,0x01,0x06,0x31, 720, 480, 0}, /* 11 */ + {0x004f,0x32,0x03,0x06,0x32, 720, 576, 0}, /* 12 */ + {0x0187,0x15,0x05,0x00,0x37,1024, 768, 0}, /* 13 */ + {0xc877,0x16,0x09,0x06,0x37,1024, 768, 0}, /* 14 */ + {0xc067,0x17,0x0b,0x49,0x37,1024, 768, 0}, /* 15 - CRT1CRTC was 0x97 */ + {0x0267,0x18,0x0d,0x00,0x37,1024, 768, 0}, /* 16 */ + {0x0047,0x19,0x11,0x8c,0x37,1024, 768, 0}, /* 17 - CRT1CRTC was 0x59 */ + {0x0047,0x1a,0x52,0x00,0x37,1024, 768, 0}, /* 18 */ + {0x0007,0x1b,0x16,0x00,0x37,1024, 768, 0}, /* 19 - CRT1CRTC was 0x5b */ + {0x0387,0x1c,0x4d,0x00,0x3a,1280,1024, 0}, /* 1a - CRT1CRTC was 0x5c */ + {0x0077,0x1d,0x14,0x07,0x3a,1280,1024, 0}, /* 1b */ + {0x0047,0x1e,0x17,0x00,0x3a,1280,1024, 0}, /* 1c */ + {0x0007,0x1f,0x98,0x00,0x3a,1280,1024, 0}, /* 1d */ + {0x0007,0x20,0x59,0x00,0x3c,1600,1200, 0}, /* 1e - CRT1CRTC was 0x60 */ + {0x0007,0x21,0x5a,0x00,0x3c,1600,1200, 0}, /* 1f */ + {0x0007,0x22,0x1b,0x00,0x3c,1600,1200, 0}, /* 20 */ + {0x0007,0x23,0x1d,0x00,0x3c,1600,1200, 0}, /* 21 - CRT1CRTC was 0x63 */ + {0x0007,0x24,0x1e,0x00,0x3c,1600,1200, 0}, /* 22 */ + {0x407f,0x00,0x00,0x00,0x40, 320, 200, 0}, /* 23 */ + {0xc07f,0x01,0x00,0x04,0x50, 320, 240, 0}, /* 24 */ + {0x0077,0x02,0x04,0x05,0x51, 400, 300, 0}, /* 25 */ + {0xc877,0x03,0x09,0x06,0x52, 512, 384, 0}, /* 26 */ /* was c077 */ + {0x8207,0x25,0x1f,0x00,0x68,1920,1440, 0}, /* 27 */ + {0x0007,0x26,0x20,0x00,0x6c,2048,1536, 0}, /* 28 */ + {0x0067,0x27,0x14,0x08,0x6e,1280, 960, 0}, /* 29 - TW: 1280x960-60 */ + {0x0027,0x45,0x3c,0x08,0x6e,1280, 960, 0}, /* 2a - TW: 1280x960-85 */ + {0xc077,0x33,0x09,0x06,0x20,1024, 600, 0}, /* 2b */ + {0xc077,0x34,0x0b,0x06,0x23,1152, 768, 0}, /* 2c */ /* VCLK 0x09 */ + {0x0057,0x35,0x27,0x08,0x70, 800, 480, 0}, /* 2d */ + {0x0047,0x36,0x37,0x08,0x70, 800, 480, 0}, /* 2e */ + {0x0047,0x37,0x08,0x08,0x70, 800, 480, 0}, /* 2f */ + {0x0057,0x38,0x09,0x09,0x71,1024, 576, 0}, /* 30 */ + {0x0047,0x39,0x38,0x09,0x71,1024, 576, 0}, /* 31 */ + {0x0047,0x3a,0x11,0x09,0x71,1024, 576, 0}, /* 32 */ + {0x0057,0x3b,0x39,0x0a,0x75,1280, 720, 0}, /* 33 */ + {0x0047,0x3c,0x3a,0x0a,0x75,1280, 720, 0}, /* 34 */ + {0x0007,0x3d,0x3b,0x0a,0x75,1280, 720, 0}, /* 35 */ + {0x0047,0x3e,0x34,0x06,0x29,1152, 864, 0}, /* 36 1152x864-75Hz */ + {0x0047,0x44,0x3a,0x06,0x29,1152, 864, 0}, /* 37 1152x864-85Hz */ + {0x00c7,0x3f,0x28,0x00,0x39, 848, 480, 0}, /* 38 848x480-38Hzi */ + {0xc067,0x40,0x3d,0x0b,0x39, 848, 480, 0}, /* 39 848x480-60Hz */ + {0x00c7,0x41,0x28,0x00,0x3f, 856, 480, 0}, /* 3a 856x480-38Hzi */ + {0xc047,0x42,0x28,0x00,0x3f, 856, 480, 0}, /* 3b 856x480-60Hz */ + {0x0067,0x43,0x3e,0x0c,0x48,1360, 768, 0}, /* 3c 1360x768-60Hz */ + {0x0077,0x46,0x3f,0x08,0x55,1280, 768, 0}, /* 3d 1280x768-60Hz */ + {0x004f,0x47,0x03,0x06,0x5f, 768, 576, 0}, /* 3e 768x576 */ + {0x0027,0x48,0x13,0x08,0x67,1360,1024, 0}, /* 3f 1360x1024-59Hz (BARCO1366 only) */ + {0xffff, 0, 0, 0, 0, 0, 0, 0} }; -/*add for 300 oem util*/ typedef struct _SiS_VBModeIDTableStruct { UCHAR ModeID; @@ -621,6 +313,10 @@ static const SiS_VBModeIDTableStruct Si {0x30,0x00,0x00,0x01,0x07,0x00,0x08,0x0a}, {0x31,0x00,0x00,0x01,0x06,0x00,0x00,0x00}, {0x32,0x00,0x00,0x01,0x06,0x00,0x00,0x00}, + {0x33,0x00,0x00,0x01,0x06,0x00,0x00,0x00}, + {0x34,0x00,0x00,0x01,0x06,0x00,0x00,0x00}, + {0x35,0x00,0x00,0x01,0x06,0x00,0x00,0x00}, + {0x36,0x00,0x00,0x01,0x06,0x00,0x00,0x00}, {0x37,0x00,0x00,0x01,0x00,0x00,0x0a,0x0c}, {0x38,0x00,0x00,0x01,0x00,0x00,0x0a,0x0c}, {0x3a,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, @@ -634,24 +330,30 @@ static const SiS_VBModeIDTableStruct Si {0x4a,0x00,0x00,0x01,0x00,0x00,0x0a,0x0c}, {0x4c,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, {0x4d,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, + {0x4f,0x00,0x00,0x01,0x04,0x00,0x05,0x05}, {0x50,0x00,0x00,0x01,0x04,0x00,0x05,0x07}, {0x51,0x00,0x00,0x01,0x07,0x00,0x07,0x09}, {0x52,0x00,0x00,0x01,0x00,0x00,0x09,0x0b}, + {0x53,0x00,0x00,0x01,0x04,0x00,0x05,0x07}, + {0x54,0x00,0x00,0x01,0x07,0x00,0x07,0x09}, {0x56,0x00,0x00,0x01,0x04,0x00,0x05,0x07}, {0x57,0x00,0x00,0x01,0x07,0x00,0x07,0x09}, {0x58,0x00,0x00,0x01,0x00,0x00,0x09,0x0b}, {0x59,0x00,0x00,0x01,0x04,0x00,0x05,0x05}, - {0x5d,0x00,0x00,0x01,0x07,0x00,0x06,0x06}, + {0x5c,0x00,0x00,0x01,0x00,0x00,0x09,0x0b}, + {0x5d,0x00,0x00,0x01,0x05,0x00,0x06,0x06}, + {0x5e,0x00,0x00,0x01,0x05,0x00,0x06,0x06}, + {0x5f,0x00,0x00,0x01,0x06,0x00,0x00,0x00}, + {0x60,0x00,0x00,0x01,0x06,0x00,0x00,0x00}, + {0x61,0x00,0x00,0x01,0x06,0x00,0x00,0x00}, {0x62,0x00,0x00,0x01,0x05,0x00,0x06,0x08}, {0x63,0x00,0x00,0x01,0x07,0x00,0x08,0x0a}, {0x64,0x00,0x00,0x01,0x00,0x00,0x0a,0x0c}, {0x65,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, - {0x6e,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, - {0x6f,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, - {0x7b,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, - {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00} /* TW: added! */ + {0x6c,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, + {0x6d,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, + {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00} }; -/*end*/ typedef struct _SiS300_CRT1TableStruct { @@ -660,15 +362,32 @@ typedef struct _SiS300_CRT1TableStruct static const SiS300_CRT1TableStruct SiS300_CRT1Table[] = { - {{0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, /* 0x00 */ - 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x00, +#if 1 + {{0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, /* 0x00 - 320x200 */ + 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x00, /* HRE [4],[15] is invalid - but correcting it does not work */ + 0x00}}, +#endif +#if 0 + {{0x2d,0x27,0x27,0x91,0x2c,0x92,0xbf,0x1f, /* 0x00 - corrected 320x200-72 - does not work */ + 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x04, + 0x00}}, +#endif + {{0x2d,0x27,0x28,0x90,0x2c,0x80,0x0b,0x3e, /* 0x01 */ + 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x00, /* HRE [4],[15] is invalid - but correcting it does not work */ 0x00}}, - {{0x2d,0x27,0x28,0x90,0x2c,0x80,0x0b,0x3e, - 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x00, +#if 0 + {{0x2d,0x27,0x27,0x91,0x2c,0x92,0x0b,0x3e, /* 0x01 - corrected 320x240-60 - does not work */ + 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x04, 0x00}}, - {{0x3d,0x31,0x31,0x81,0x37,0x1f,0x72,0xf0, +#endif + {{0x3d,0x31,0x31,0x81,0x37,0x1f,0x72,0xf0, /* 0x02 */ + 0x58,0x8c,0x57,0x57,0x73,0x20,0x00,0x05, + 0x01}}, +#if 0 + {{0x3d,0x31,0x31,0x81,0x37,0x1f,0x72,0xf0, /* 0x02 - corrected 400x300-60 */ 0x58,0x8c,0x57,0x57,0x73,0x20,0x00,0x05, 0x01}}, +#endif {{0x4f,0x3f,0x3f,0x93,0x45,0x0d,0x24,0xf5, 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x01, 0x01}}, @@ -683,7 +402,7 @@ static const SiS300_CRT1TableStruct SiS {{0x5f,0x4f,0x4f,0x83,0x55,0x81,0x0b,0x3e, /* 0x05 - corrected 640x480-60 */ 0xe9,0x8b,0xdf,0xe8,0x0c,0x00,0x00,0x05, 0x00}}, - #if 0 +#if 0 {{0x63,0x4f,0x50,0x86,0x56,0x9b,0x06,0x3e, /* 0x06 */ 0xe8,0x8b,0xdf,0xe7,0xff,0x10,0x00,0x01, 0x00}}, @@ -841,15 +560,10 @@ static const SiS300_CRT1TableStruct SiS {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x1e,0xf1, /* 0x33 - 1024x600 */ 0xae,0x85,0x57,0x57,0x1f,0x30,0x00,0x02, 0x01}}, -#if 0 - {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, /* 0x34 - 1152x768 */ - 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, - 0x01}}, -#endif - {{0xa3,0x8f,0x8f,0x97,0x96,0x97,0x24,0xf5, /* 0x34 - 1152x768 - TW: corrected */ + {{0xa3,0x8f,0x8f,0x97,0x96,0x97,0x24,0xf5, /* 0x34 - 1152x768 - corrected */ 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, 0x01}}, - {{0x7f,0x63,0x63,0x83,0x6c,0x1c,0x72,0xba, /* 0x35 - NEW 16:9 modes, not in BIOS ------ */ + {{0x7f,0x63,0x63,0x83,0x6c,0x1c,0x72,0xba, /* 0x35 */ 0x27,0x8b,0xdf,0xdf,0x73,0x00,0x00,0x06, 0x01}}, /* 0x35 */ {{0x7f,0x63,0x63,0x83,0x69,0x13,0x6f,0xba, @@ -864,7 +578,7 @@ static const SiS300_CRT1TableStruct SiS {{0x9f,0x7f,0x7f,0x83,0x85,0x91,0x1e,0xf1, 0xad,0x81,0x3f,0x3f,0x1f,0x30,0x00,0x02, 0x01}}, /* 0x39 */ - {{0xa7,0x7f,0x7f,0x88,0x89,0x95,0x26,0xf1, /* TW: 95 was 15 - illegal HBE! */ + {{0xa7,0x7f,0x7f,0x88,0x89,0x95,0x26,0xf1, /* 95 was 15 - illegal HBE! */ 0xb1,0x85,0x3f,0x3f,0x27,0x30,0x00,0x02, 0x01}}, /* 0x3a */ {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x28,0xc4, @@ -875,36 +589,40 @@ static const SiS300_CRT1TableStruct SiS 0x01}}, /* 0x3c */ {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0x2e,0xd4, 0x7d,0x81,0xcf,0xcf,0x2f,0x21,0x00,0x07, - 0x01}}, /* 0x3d */ /* TW: End of 16:9 modes --------------- */ - {{0xc3,0x8f,0x8f,0x87,0x9b,0x0b,0x82,0xef, /* TW: New, 1152x864-75 (not in any BIOS) */ + 0x01}}, /* 0x3d */ + {{0xc3,0x8f,0x8f,0x87,0x9b,0x0b,0x82,0xef, /* 1152x864-75 */ 0x60,0x83,0x5f,0x5f,0x83,0x10,0x00,0x07, 0x01}}, /* 0x3e */ - {{0x86,0x69,0x69,0x8A,0x74,0x06,0x8C,0x15, /* TW: New, 848x480-38i, not in BIOS */ + {{0x86,0x69,0x69,0x8A,0x74,0x06,0x8C,0x15, /* 848x480-38i */ 0x4F,0x83,0xEF,0xEF,0x8D,0x30,0x00,0x02, 0x00}}, /* 0x3f */ -#if 0 - {{0x81,0x69,0x69,0x85,0x70,0x00,0x0F,0x3E, /* TW: New, 848x480-60, not in BIOS - incorrect for Philips panel */ - 0xEB,0x8E,0xDF,0xDF,0x10,0x00,0x00,0x02, - 0x00}}, /* 0x40 */ -#endif - {{0x83,0x69,0x69,0x87,0x6f,0x1d,0x03,0x3E, /* TW: New, 848x480-60, not in BIOS */ + {{0x83,0x69,0x69,0x87,0x6f,0x1d,0x03,0x3E, /* 848x480-60 */ 0xE5,0x8d,0xDF,0xe4,0x04,0x00,0x00,0x06, 0x00}}, /* 0x40 */ - {{0x86,0x6A,0x6A,0x8A,0x74,0x06,0x8C,0x15, /* TW: New, 856x480-38i, not in BIOS */ + {{0x86,0x6A,0x6A,0x8A,0x74,0x06,0x8C,0x15, /* 856x480-38i */ 0x4F,0x83,0xEF,0xEF,0x8D,0x30,0x00,0x02, 0x00}}, /* 0x41 */ - {{0x81,0x6A,0x6A,0x85,0x70,0x00,0x0F,0x3E, /* TW: New, 856x480-60, not in BIOS */ + {{0x81,0x6A,0x6A,0x85,0x70,0x00,0x0F,0x3E, /* 856x480-60 */ 0xEB,0x8E,0xDF,0xDF,0x10,0x00,0x00,0x02, 0x00}}, /* 0x42 */ - {{0xdd,0xa9,0xa9,0x81,0xb4,0x97,0x26,0xfd, /* TW: New, 1360x768-60, not in BIOS */ + {{0xdd,0xa9,0xa9,0x81,0xb4,0x97,0x26,0xfd, /* 1360x768-60 */ 0x01,0x8d,0xff,0x00,0x27,0x10,0x00,0x03, 0x01}}, /* 0x43 */ - {{0xd9,0x8f,0x8f,0x9d,0xba,0x0a,0x8a,0xff, /* TW: New, 1152x864-84 (not in any BIOS) */ + {{0xd9,0x8f,0x8f,0x9d,0xba,0x0a,0x8a,0xff, /* 1152x864-84 */ 0x60,0x8b,0x5f,0x5f,0x8b,0x10,0x00,0x03, - 0x01}}, /* 0x44 */ - {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0xf1,0xff, /* TW: New, 1280x960-85 (not in any BIOS) */ + 0x01}}, /* 0x44 */ + {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0xf1,0xff, /* 1280x960-85 */ 0xc0,0x83,0xbf,0xbf,0xf2,0x10,0x00,0x07, - 0x01}} /* 0x45 */ + 0x01}}, /* 0x45 */ + {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x20,0xf5, /* 1280x768-60 */ + 0x03,0x88,0xff,0xff,0x21,0x10,0x00,0x07, + 0x01}}, /* 0x46 */ + {{0x7b,0x5f,0x63,0x9f,0x6a,0x93,0x6f,0xf0, /* 768x576 */ + 0x58,0x8a,0x3f,0x57,0x70,0x20,0x00,0x05, + 0x01}}, /* 0x47 */ + {{0xce,0xa9,0xa9,0x92,0xb1,0x07,0x28,0x52, /* 1360x1024 (Barco iQ Pro R300) */ + 0x02,0x8e,0xff,0x00,0x29,0x0d,0x00,0x03, + 0x00}} /* 0x48 */ }; typedef struct _SiS300_MCLKDataStruct @@ -913,8 +631,8 @@ typedef struct _SiS300_MCLKDataStruct USHORT CLOCK; } SiS300_MCLKDataStruct; -static const SiS300_MCLKDataStruct SiS300_MCLKData_630[] = /* 630 */ -{ /* TW: at 0x54 in BIOS */ +static const SiS300_MCLKDataStruct SiS300_MCLKData_630[] = +{ { 0x5a,0x64,0x80, 66}, { 0xb3,0x45,0x80, 83}, { 0x37,0x61,0x80,100}, @@ -925,8 +643,8 @@ static const SiS300_MCLKDataStruct SiS3 { 0x37,0x61,0x80,100} }; -static const SiS300_MCLKDataStruct SiS300_MCLKData_300[] = /* 300 */ -{ /* TW: at 0x54 in BIOS */ +static const SiS300_MCLKDataStruct SiS300_MCLKData_300[] = +{ { 0x68,0x43,0x80,125}, { 0x68,0x43,0x80,125}, { 0x68,0x43,0x80,125}, @@ -937,24 +655,6 @@ static const SiS300_MCLKDataStruct SiS3 { 0x37,0x61,0x80,100} }; -typedef struct _SiS300_ECLKDataStruct -{ - UCHAR SR2E,SR2F,SR30; - USHORT CLOCK; -} SiS300_ECLKDataStruct; - -static const SiS300_ECLKDataStruct SiS300_ECLKData[] = -{ - { 0x54,0x43,0x80,100}, - { 0x53,0x43,0x80,100}, - { 0x55,0x43,0x80,100}, - { 0x52,0x43,0x80,100}, - { 0x3f,0x42,0x80,100}, - { 0x54,0x43,0x80,100}, - { 0x54,0x43,0x80,100}, - { 0x54,0x43,0x80,100} -}; - typedef struct _SiS300_VCLKDataStruct { UCHAR SR2B,SR2C; @@ -964,196 +664,93 @@ typedef struct _SiS300_VCLKDataStruct static const SiS300_VCLKDataStruct SiS300_VCLKData[] = { { 0x1b,0xe1, 25}, /* 0x00 */ - { 0x4e,0xe4, 28}, + { 0x4e,0xe4, 28}, /* 0x01 */ { 0x57,0xe4, 32}, /* 0x02 */ - { 0xc3,0xc8, 36}, + { 0xc3,0xc8, 36}, /* 0x03 */ { 0x42,0xc3, 40}, /* 0x04 */ - { 0x5d,0xc4, 45}, + { 0x5d,0xc4, 45}, /* 0x05 */ { 0x52,0x65, 50}, /* 0x06 */ - { 0x53,0x65, 50}, + { 0x53,0x65, 50}, /* 0x07 */ { 0x6d,0x66, 56}, /* 0x08 */ - { 0x5a,0x64, 65}, + { 0x5a,0x64, 65}, /* 0x09 */ { 0x46,0x44, 68}, /* 0x0a */ - { 0x3e,0x43, 75}, - { 0x6d,0x46, 76}, /* 0x0c: 800x600 | LVDS_2(CH), MITAC(CH); - 730, A901(301B): 0xb1,0x46, 76 */ - { 0x41,0x43, 79}, + { 0x3e,0x43, 75}, /* 0x0b */ + { 0x6d,0x46, 76}, /* 0x0c */ /* 800x600 | LVDS_2(CH), MITAC(CH); - 730, A901(301B): 0xb1,0x46, 76 */ + { 0x41,0x43, 79}, /* 0x0d */ { 0x31,0x42, 79}, /* 0x0e */ - { 0x46,0x25, 85}, + { 0x46,0x25, 85}, /* 0x0f */ { 0x78,0x29, 87}, /* 0x10 */ - { 0x62,0x44, 95}, + { 0x62,0x44, 95}, /* 0x11 */ { 0x2b,0x22,105}, /* 0x12 */ - { 0x49,0x24,106}, + { 0x49,0x24,106}, /* 0x13 */ { 0xc3,0x28,108}, /* 0x14 */ - { 0x3c,0x23,109}, + { 0x3c,0x23,109}, /* 0x15 */ { 0xf7,0x2c,132}, /* 0x16 */ - { 0xd4,0x28,136}, + { 0xd4,0x28,136}, /* 0x17 */ { 0x41,0x05,158}, /* 0x18 */ - { 0x43,0x05,162}, + { 0x43,0x05,162}, /* 0x19 */ { 0xe1,0x0f,175}, /* 0x1a */ { 0xfc,0x12,189}, /* 0x1b */ { 0xde,0x26,194}, /* 0x1c */ - { 0x54,0x05,203}, + { 0x54,0x05,203}, /* 0x1d */ { 0x3f,0x03,230}, /* 0x1e */ - { 0x30,0x02,234}, + { 0x30,0x02,234}, /* 0x1f */ { 0x24,0x01,266}, /* 0x20 */ - { 0x52,0x2a, 54}, /* 301 TV */ - { 0x52,0x6a, 27}, /* 301 TV */ - { 0x62,0x24, 70}, /* 301 TV */ - { 0x62,0x64, 70}, /* 301 TV */ - { 0xa8,0x4c, 30}, /* 301 TV */ - { 0x20,0x26, 33}, /* 301 TV */ - { 0x31,0xc2, 39}, - { 0xbf,0xc8, 35}, /* 0x28 - 856x480 */ - { 0x60,0x36, 30}, /* 0x29 CH/UNTSC TEXT | LVDS_2(CH) - 730, A901(301B), Mitac(CH): 0xe0, 0xb6, 30 */ - { 0x40,0x4a, 28}, - { 0x9f,0x46, 44}, - { 0x97,0x2c, 26}, - { 0x44,0xe4, 25}, - { 0x7e,0x32, 47}, - { 0x8a,0x24, 31}, /* 0x2f CH/PAL TEXT | LVDS_2(CH), Mitac(CH) - 730, A901(301B): 0x57, 0xe4, 31 */ - { 0x97,0x2c, 26}, - { 0xce,0x3c, 39}, - { 0x52,0x4a, 36}, /* 0x32 CH/PAL 800x600 5/6 */ - { 0x34,0x61, 95}, - { 0x78,0x27,108}, - { 0xce,0x25,189}, /* 0x35 */ - { 0x45,0x6b, 21}, /* 0x36 */ /* TW: Added from Mitac */ - { 0x52,0xe2, 49}, /* 0x37 - added for 16:9 modes (not in any BIOS) */ - { 0x2b,0x61, 78}, /* 0x38 - added for 16:9 modes (not in any BIOS) */ - { 0x70,0x44,108}, /* 0x39 - added for 16:9 modes (not in any BIOS) */ - { 0x54,0x42,135}, /* 0x3a - added for 16:9 modes (not in any BIOS) */ - { 0x41,0x22,157}, /* 0x3b - added for 16:9 modes (not in any BIOS) */ - { 0x52,0x07,149}, /* 0x3c - added for 1280x960-85 (not in any BIOS)*/ - { 0x62,0xc6, 34}, /* 0x3d - added for 848x480-60 (not in any BIOS) */ - { 0x30,0x23, 88}, /* 0x3e - added for 1360x768-60 (not in any BIOS)*/ - { 0x3f,0x64, 46}, /* 0x3f - added for 640x480-100 (not in any BIOS)*/ - { 0x72,0x2a, 76}, /* 0x40 - test for SiS730 */ - { 0x15,0x21, 79}, /* 0x41 - test for SiS730 */ - { 0xff,0x00, 0} -}; - -#if 0 /* TW: This table is in all BIOSes, but not used */ -static const SiS300_VCLKDataStruct SiS300_VBVCLKData[] = -{ - { 0x1b,0xe1, 25}, - { 0x4e,0xe4, 28}, - { 0x57,0xe4, 31}, - { 0xc3,0xc8, 36}, - { 0x42,0x47, 40}, - { 0x5d,0xc4, 44}, - { 0x52,0x47, 49}, - { 0x53,0x47, 50}, - { 0x6d,0x66, 56}, - { 0x5a,0x64, 65}, - { 0x46,0x44, 67}, - { 0x29,0x61, 75}, - { 0x6d,0x46, 75}, - { 0x41,0x43, 78}, - { 0x31,0x42, 79}, - { 0x46,0x25, 84}, - { 0x78,0x29, 86}, /* 0x10 */ - { 0x62,0x44, 94}, - { 0x2b,0x22,104}, - { 0x49,0x24,105}, - { 0x43,0x42,108}, - { 0x3c,0x23,109}, - { 0xe0,0x46,132}, - { 0x70,0x25,135}, - { 0x41,0x22,157}, - { 0x43,0x22,162}, - { 0x30,0x21,175}, - { 0xc1,0x24,189}, - { 0xde,0x26,194}, - { 0x70,0x07,202}, - { 0x3f,0x03,229}, - { 0x30,0x02,234}, /* 0x1f */ - { 0x24,0x01,265}, /* 0x20 */ - { 0x52,0x2a, 54}, - { 0x52,0x6a, 27}, - { 0x62,0x24, 70}, - { 0x62,0x64, 70}, - { 0xa8,0x4c, 30}, - { 0x20,0x26, 33}, - { 0x31,0xc2, 39}, - { 0x2e,0x48, 25}, /* 0x28 */ - { 0x24,0x46, 25}, /* 0x29 */ - { 0x26,0x64, 28}, - { 0x37,0x64, 40}, - { 0xa1,0x42,108}, - { 0x37,0x61,100}, - { 0x78,0x27,108}, + { 0x52,0x2a, 54}, /* 0x21 */ /* 301 TV */ + { 0x52,0x6a, 27}, /* 0x22 */ /* 301 TV */ + { 0x62,0x24, 70}, /* 0x23 */ /* 301 TV */ + { 0x62,0x64, 70}, /* 0x24 */ /* 301 TV */ + { 0xa8,0x4c, 30}, /* 0x25 */ /* 301 TV */ + { 0x20,0x26, 33}, /* 0x26 */ /* 301 TV */ + { 0x31,0xc2, 39}, /* 0x27 */ + { 0xbf,0xc8, 35}, /* 0x28 */ /* 856x480 */ + { 0x60,0x36, 30}, /* 0x29 */ /* CH/UNTSC TEXT | LVDS_2(CH) - 730, A901(301B), Mitac(CH): 0xe0, 0xb6, 30 */ + { 0x40,0x4a, 28}, /* 0x2a */ /* CH-TV */ + { 0x9f,0x46, 44}, /* 0x2b */ /* CH-TV */ + { 0x97,0x2c, 26}, /* 0x2c */ /* CH-TV */ + { 0x44,0xe4, 25}, /* 0x2d */ /* CH-TV */ + { 0x7e,0x32, 47}, /* 0x2e */ /* CH-TV */ + { 0x8a,0x24, 31}, /* 0x2f */ /* CH/PAL TEXT | LVDS_2(CH), Mitac(CH) - 730, A901(301B): 0x57, 0xe4, 31 */ + { 0x97,0x2c, 26}, /* 0x30 */ /* CH-TV */ + { 0xce,0x3c, 39}, /* 0x31 */ /* CH-TV */ + { 0x52,0x4a, 36}, /* 0x32 */ /* CH/PAL 800x600 5/6 */ + { 0x34,0x61, 95}, /* 0x33 */ + { 0x78,0x27,108}, /* 0x34 */ /* Replacement for index 0x14 for 630 (?) */ + { 0xce,0x25,189}, /* 0x35 */ /* Replacement for index 0x1b for 730 (and 540?) */ + { 0x45,0x6b, 21}, /* 0x36 */ /* Chrontel SuperOverscan */ + { 0x52,0xe2, 49}, /* 0x37 */ /* 16:9 modes */ + { 0x2b,0x61, 78}, /* 0x38 */ /* 16:9 modes */ + { 0x70,0x44,108}, /* 0x39 */ /* 16:9 modes */ + { 0x54,0x42,135}, /* 0x3a */ /* 16:9 modes */ + { 0x41,0x22,157}, /* 0x3b */ /* 16:9 modes */ + { 0x52,0x07,149}, /* 0x3c */ /* 1280x960-85 */ + { 0x62,0xc6, 34}, /* 0x3d */ /* 848x480-60 */ + { 0x30,0x23, 88}, /* 0x3e */ /* 1360x768-60 */ +#if 0 + { 0x3f,0x64, 46}, /* 0x3f */ /* 640x480-100 */ +#endif + { 0x70,0x29, 81}, /* 0x3f */ /* 1280x768-60 */ + { 0x72,0x2a, 76}, /* 0x40 */ /* test for SiS730 */ + { 0x15,0x21, 79}, /* 0x41 */ /* test for SiS730 */ + { 0xa1,0x42,108}, /* 0x42 */ /* 1280x960 LCD */ + { 0x37,0x61,100}, /* 0x43 */ /* 1280x960 LCD */ + { 0xe3,0x9a,106}, /* 0x44 */ /* 1360x1024 - special for Barco iQ R300 */ + { 0xe2,0x46,135}, /* 0x45 */ /* 1280x1024-75, better clock for VGA2 */ { 0xff,0x00, 0} }; -#endif static const UCHAR SiS300_ScreenOffset[] = { 0x14,0x19,0x20,0x28,0x32,0x40,0x50, - 0x64,0x78,0x80,0x2d,0x35,0x48,0x35, /* 0x35 for 848 and 856 */ - 0x55,0xff /* 0x55 for 1360 */ -}; - -typedef struct _SiS300_StResInfoStruct -{ - USHORT HTotal; - USHORT VTotal; -} SiS300_StResInfoStruct; - -static const SiS300_StResInfoStruct SiS300_StResInfo[] = -{ - { 640,400}, - { 640,350}, - { 720,400}, - { 720,350}, - { 640,480} -}; - -typedef struct _SiS300_ModeResInfoStruct -{ - USHORT HTotal; - USHORT VTotal; - UCHAR XChar; - UCHAR YChar; -} SiS300_ModeResInfoStruct; - -static const SiS300_ModeResInfoStruct SiS300_ModeResInfo[] = -{ - { 320, 200, 8, 8}, /* 0x00 */ - { 320, 240, 8, 8}, /* 0x01 */ - { 320, 400, 8, 8}, /* 0x02 */ - { 400, 300, 8, 8}, /* 0x03 */ - { 512, 384, 8, 8}, /* 0x04 */ - { 640, 400, 8,16}, /* 0x05 */ - { 640, 480, 8,16}, /* 0x06 */ - { 800, 600, 8,16}, /* 0x07 */ - { 1024, 768, 8,16}, /* 0x08 */ - { 1280,1024, 8,16}, /* 0x09 */ - { 1600,1200, 8,16}, /* 0x0a */ - { 1920,1440, 8,16}, /* 0x0b */ - { 720, 480, 8,16}, /* 0x0c */ - { 720, 576, 8,16}, /* 0x0d */ - { 1280, 960, 8,16}, /* 0x0e */ - { 1024, 600, 8,16}, /* 0x0f */ - { 1152, 768, 8,16}, /* 0x10 */ - { 2048,1536, 8,16}, /* 0x11 - TW: Not in BIOS! */ - { 800, 480, 8,16}, /* 0x12 - TW: New, not in any BIOS */ - { 1024, 576, 8,16}, /* 0x13 - TW: New, not in any BIOS */ - { 1280, 720, 8,16}, /* 0x14 - TW: New, not in any BIOS */ - { 1152, 864, 8,16}, /* 0x15 - TW: New, not in any BIOS */ - { 848, 480, 8,16}, /* 0x16 - TW: New, not in any BIOS */ - { 856, 480, 8,16}, /* 0x17 - TW: New, not in any BIOS */ - { 1360, 768, 8,16} /* 0x18 - TW: New, not in any BIOS */ + 0x64,0x78,0x80,0x2d,0x35,0x48,0x35, + 0x55,0x30,0xff }; -static const UCHAR SiS300_OutputSelect = 0x40; - -static const UCHAR SiS300_SoftSetting = 0x30; - #ifndef LINUX_XF86 static UCHAR SiS300_SR07 = 0x10; #endif -static const UCHAR SiS300_SR15[8][4] = +static const DRAM4Type SiS300_SR15[8] = { {0x01,0x09,0xa3,0x00}, {0x43,0x43,0x43,0x00}, @@ -1183,24 +780,15 @@ static UCHAR SiS300_CRT2Data_4_10 = 0x80 static const USHORT SiS300_RGBSenseData = 0xd1; static const USHORT SiS300_VideoSenseData = 0xb3; static const USHORT SiS300_YCSenseData = 0xb9; -static const USHORT SiS300_RGBSenseData2 = 0x0190; /*301b*/ +static const USHORT SiS300_RGBSenseData2 = 0x0190; static const USHORT SiS300_VideoSenseData2 = 0x0174; static const USHORT SiS300_YCSenseData2 = 0x016b; -static const UCHAR SiS300_CR40[5][4]; +static const DRAM4Type SiS300_CR40[5]; static UCHAR SiS300_CR49[2]; #endif -static const UCHAR SiS300_NTSCPhase[] = {0x21,0xed,0xba,0x08}; /* TW: Was {0x21,0xed,0x8a,0x08}; */ -static const UCHAR SiS300_PALPhase[] = {0x2a,0x05,0xe3,0x00}; /* TW: Was {0x2a,0x05,0xd3,0x00}; */ -static const UCHAR SiS300_PALMPhase[] = {0x21,0xE4,0x2E,0x9B}; /* palmn */ -static const UCHAR SiS300_PALNPhase[] = {0x21,0xF4,0x3E,0xBA}; -static const UCHAR SiS300_NTSCPhase2[] = {0x21,0xF0,0x7B,0xD6}; /* 301b */ -static const UCHAR SiS300_PALPhase2[] = {0x2a,0x09,0x86,0xe9}; /* 301b */ -static const UCHAR SiS300_PALMPhase2[] = {0x21,0xE6,0xEF,0xA4}; /* TW: palm 301b*/ -static const UCHAR SiS300_PALNPhase2[] = {0x21,0xF6,0x94,0x46}; /* TW: paln 301b*/ - typedef struct _SiS300_PanelDelayTblStruct { UCHAR timer[2]; @@ -1208,7 +796,7 @@ typedef struct _SiS300_PanelDelayTblStru static const SiS300_PanelDelayTblStruct SiS300_PanelDelayTbl[] = { - {{0x05,0xaa}}, /* TW: From 2.04.5a */ + {{0x05,0xaa}}, {{0x05,0x14}}, {{0x05,0x36}}, {{0x05,0x14}}, @@ -1226,6 +814,7 @@ static const SiS300_PanelDelayTblStruct {{0x05,0x60}} }; +#if 0 static const SiS300_PanelDelayTblStruct SiS300_PanelDelayTblLVDS[] = { {{0x05,0xaa}}, @@ -1245,6 +834,11 @@ static const SiS300_PanelDelayTblStruct {{0x05,0x14}}, /* Some BIOSes: 05, 40 */ {{0x05,0x60}} }; +#endif + +/**************************************************************/ +/* SIS VIDEO BRIDGE ----------------------------------------- */ +/**************************************************************/ typedef struct _SiS300_LCDDataStruct { @@ -1355,309 +949,87 @@ static const SiS300_LCDDataStruct SiS30 { 1, 1,1688,1066,1688,1066} }; -static const SiS300_LCDDataStruct SiS300_LCD1280x960Data[] = +typedef struct _SiS300_Part2PortTblStruct { - { 9, 2, 800, 500,1800,1000}, - { 9, 2, 800, 500,1800,1000}, - { 4, 1, 900, 500,1800,1000}, - { 4, 1, 900, 500,1800,1000}, - { 9, 2, 800, 500,1800,1000}, - { 30, 11,1056, 625,1800,1000}, - { 5, 3,1350, 800,1800,1000}, - { 1, 1,1576,1050,1576,1050}, - { 1, 1,1800,1000,1800,1000} -}; - -static const SiS300_LCDDataStruct SiS300_ExtLCD1400x1050Data[] = /* TW: New */ -{ - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS300_LCDDataStruct SiS300_ExtLCD1600x1200Data[] = /* TW: New */ -{ - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS300_LCDDataStruct SiS300_StLCD1400x1050Data[] = /* TW: New */ -{ - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS300_LCDDataStruct SiS300_StLCD1600x1200Data[] = /* TW: New */ -{ - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS300_LCDDataStruct SiS300_NoScaleData1400x1050[] = /* TW: New */ -{ - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS300_LCDDataStruct SiS300_NoScaleData1600x1200[] = /* TW: New */ -{ - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0} + UCHAR CR[12]; +} SiS300_Part2PortTblStruct; + +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1024x768_1[] = +{ /* VESA Timing */ + {{0x21,0x12,0xbf,0xe4,0xc0,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, + {{0x2c,0x12,0x9a,0xae,0x88,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, + {{0x21,0x12,0xbf,0xe4,0xc0,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}}, + {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}}, + {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}} }; +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_1[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} +}; -typedef struct _SiS300_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; -} SiS300_TVDataStruct; - -static const SiS300_TVDataStruct SiS300_StPALData[] = -{ - { 1, 1, 864, 525,1270, 400, 100, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 350, 100, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, - { 1, 1, 864, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, - { 1, 1, 864, 525,1270, 480, 50, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 600, 50, 0, 0,0xf4,0xff,0x1c,0x22} -}; - -static const SiS300_TVDataStruct SiS300_ExtPALData[] = -{ - { 27, 10, 848, 448,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, - { 108, 35, 848, 398,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, - { 12, 5, 954, 448,1270, 530, 50, 0, 50,0xf1,0x04,0x1f,0x18}, - { 9, 4, 960, 463,1644, 438, 50, 0, 50,0xf4,0x0b,0x1c,0x0a}, - { 9, 4, 848, 528,1270, 530, 0, 0, 50,0xf5,0xfb,0x1b,0x2a}, - { 36, 25,1060, 648,1316, 530, 438, 0, 438,0xeb,0x05,0x25,0x16}, - { 3, 2,1080, 619,1270, 540, 438, 0, 438,0xf3,0x00,0x1d,0x20}, - { 1, 1,1170, 821,1270, 520, 686, 0, 686,0xF3,0x00,0x1D,0x20} +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1400x1050_1[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} +}; +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1600x1200_1[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -static const SiS300_TVDataStruct SiS300_StNTSCData[] = -{ - { 1, 1, 858, 525,1270, 400, 50, 0, 760,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 350, 50, 0, 640,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, - { 1, 1, 858, 525,1270, 480, 0, 0, 760,0xf1,0x04,0x1f,0x18} -}; - -static const SiS300_TVDataStruct SiS300_ExtNTSCData[] = -{ - { 143, 65, 858, 443,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, - { 88, 35, 858, 393,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, - { 143, 70, 924, 443,1270, 440, 92, 0, 92,0xf1,0x04,0x1f,0x18}, - { 143, 70, 924, 393,1270, 440, 92, 0, 92,0xf4,0x0b,0x1c,0x0a}, - { 143, 76, 836, 523,1270, 440, 224, 0, 0,0xf1,0x05,0x1f,0x16}, - { 143, 120,1056, 643,1270, 440, 0, 128, 0,0xf4,0x10,0x1c,0x00}, - { 143, 76, 836, 523,1270, 440, 0, 128, 0,0xee,0x0c,0x22,0x08}, - { 65, 64,1056, 791,1270, 480, 638, 0, 0,0xf1,0x04,0x1f,0x18} +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1024x768_2[] = +{ /* Non-VESA */ + {{0x28,0x12,0xa3,0xd0,0xaa,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x2c,0x12,0x9a,0xae,0x88,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x28,0x12,0xa3,0xd0,0xaa,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x2c,0x12,0x9a,0xae,0x88,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x28,0x13,0xe7,0x0b,0xe8,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x38,0x18,0x16,0x00,0x00,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x36,0x13,0x13,0x25,0xff,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}} }; -#if 0 -static const SiS300_TVDataStruct SiS300_St1HiTVData[]= +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_2[] = { - + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -#endif -static const SiS300_TVDataStruct SiS300_St2HiTVData[]= +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1400x1050_2[] = { - { 3, 1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 3, 1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x3e8,0x233,0x311,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 5, 2, 0x348,0x233,0x670,0x3c0,0x08d,128, 0, 0x00,0x00,0x00,0x00}, - { 8, 5, 0x41a,0x2ab,0x670,0x3c0,0x17c,128, 0, 0x00,0x00,0x00,0x00} -}; - -static const SiS300_TVDataStruct SiS300_ExtHiTVData[]= -{ - { 6, 1, 0x348,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 3, 1, 0x3c0,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 3, 1, 0x348,0x1e3,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 3, 1, 0x3c0,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 5, 1, 0x348,0x233,0x670,0x3c0,0x166,128, 0, 0x00,0x00,0x00,0x00}, - { 16, 5, 0x41a,0x2ab,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00}, - { 25, 12, 0x4ec,0x353,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, - { 5, 4, 0x627,0x464,0x670,0x3c0,0x128, 0, 0, 0x00,0x00,0x00,0x00}, - { 4, 1, 0x41a,0x233,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00}, - { 5, 2, 0x578,0x293,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, - { 8, 5, 0x6d6,0x323,0x670,0x3c0,0x128, 0, 0, 0x00,0x00,0x00,0x00} -}; - -static const UCHAR SiS300_NTSCTiming[] = -{ - 0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c, - 0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a, - 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b, - 0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17, /* (in 2.06.50) */ -/* 0x0c,0x50,0x00,0x99,0x00,0xec,0x4a,0x17, (in 2.04.5a) */ - 0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02, /* (in 2.06.50) */ -/* 0x88,0x00,0x4b,0x00,0x00,0xe2,0x00,0x02, (in 2.04.5a) */ - 0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50, - 0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00 -}; - -static const UCHAR SiS300_PALTiming[] = -{ - 0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70, - 0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b, - 0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17, /* (in 2.06.50) */ -/* 0x70,0x50,0x00,0x97,0x00,0xd7,0x5d,0x17, (in 2.04.5a) */ - 0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02, /* (in 2.06.50) */ -/* 0x88,0x00,0x45,0x00,0x00,0xe8,0x00,0x02, (in 2.04.5a) */ - 0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63, - 0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00 -}; - -static const UCHAR SiS300_HiTVExtTiming[] = /* TW: New */ -{ - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, - 0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40, - 0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d, - 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 -}; - -static const UCHAR SiS300_HiTVSt1Timing[] = /* TW: New */ -{ - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x65,0x90,0x7b,0xa8,0x03,0xf0,0x87,0x03, - 0x11,0x15,0x11,0xcf,0x10,0x11,0xcf,0x10, - 0x35,0x35,0x3b,0x69,0x1d,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x86, - 0xaf,0x5d,0x0e,0x00,0xfc,0xff,0x2d,0x00 -}; - -static const UCHAR SiS300_HiTVSt2Timing[] = /* TW: New */ -{ - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, - 0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40, - 0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d, - 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 -}; - -static const UCHAR SiS300_HiTVTextTiming[] = /* TW: New */ -{ - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x65,0x90,0xe7,0xbc,0x03,0x0c,0x97,0x03, - 0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20, - 0xc8,0xc8,0x3b,0xd2,0x26,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96, - 0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00 -}; - -static const UCHAR SiS300_HiTVGroup3Data[] = /* TW: New */ -{ - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f, - 0x05,0x21,0xb2,0xb2,0x55,0x77,0x2a,0xa6, - 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, - 0x8c,0x6e,0x60,0x2e,0x58,0x48,0x72,0x44, - 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, - 0x4f,0x7f,0x03,0xa8,0x7d,0x20,0x1a,0xa9, - 0x14,0x05,0x03,0x7e,0x64,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 -}; - -static const UCHAR SiS300_HiTVGroup3Simu[] = /* TW: New */ -{ - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95, - 0xdb,0x20,0xb8,0xb8,0x55,0x47,0x2a,0xa6, - 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, - 0x8c,0x6e,0x60,0x15,0x26,0xd3,0xe4,0x11, - 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, - 0x67,0x36,0x01,0x47,0x0e,0x10,0xbe,0xb4, - 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 -}; - -static const UCHAR SiS300_HiTVGroup3Text[] = /* TW: New */ -{ - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7, - 0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6, - 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, - 0x8c,0x6e,0x60,0x18,0x2c,0x0c,0x20,0x22, - 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, - 0x93,0x3c,0x01,0x50,0x2f,0x10,0xf4,0xca, - 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} +}; + +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1600x1200_2[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} +}; + +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1024x768_3[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} +}; + +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_3[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} +}; + +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1400x1050_3[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} +}; + +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1600x1200_3[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; +/**************************************************************/ +/* LVDS/Chrontel -------------------------------------------- */ +/**************************************************************/ + typedef struct _SiS300_LVDSDataStruct { USHORT VGAHT; @@ -1666,366 +1038,14 @@ typedef struct _SiS300_LVDSDataStruct USHORT LCDVT; } SiS300_LVDSDataStruct; -static const SiS300_LVDSDataStruct SiS300_LVDS320x480Data_1[] = -{ - {848, 433,400, 525}, - {848, 389,400, 525}, - {848, 433,400, 525}, - {848, 389,400, 525}, - {848, 518,400, 525}, - {1056,628,400, 525}, - {400, 525,400, 525}, - {800, 449,1000, 644}, - {800, 525,1000, 635} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS800x600Data_1[] = -{ - {848, 433,1060, 629}, - {848, 389,1060, 629}, - {848, 433,1060, 629}, - {848, 389,1060, 629}, - {848, 518,1060, 629}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {800, 449,1000, 644}, - {800, 525,1000, 635} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS800x600Data_2[] = -{ - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {800, 449,1000, 644}, - {800, 525,1000, 635} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1024x768Data_1[] = -{ - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1024x768Data_2[] = -{ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1280x1024Data_1[]= -{ - {1048, 442,1688,1066}, - {1048, 392,1688,1066}, - {1048, 442,1688,1066}, - {1048, 392,1688,1066}, - {1048, 522,1688,1066}, - {1208, 642,1688,1066}, - {1432, 810,1688,1066}, - {1688,1066,1688,1066} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1280x1024Data_2[]= -{ - {1688,1066,1688,1066}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1400x1050Data_1[] = -{ - {928, 416, 1688, 1066}, - {928, 366, 1688, 1066}, - {928, 416, 1688, 1066}, - {928, 366, 1688, 1066}, - {928, 496, 1688, 1066}, - {1088, 616, 1688, 1066}, - {1312, 784, 1688, 1066}, - {1568, 1040, 1688, 1066}, - {1688, 1066, 1688, 1066} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1400x1050Data_2[] = -{ - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1600x1200Data_1[]= -{ - {1088, 450, 2048,1250}, - {1088, 400, 2048,1250}, - {1088, 450, 2048,1250}, - {1088, 400, 2048,1250}, - {1088, 530, 2048,1250}, - {1248, 650, 2048,1250}, - {1472, 818, 2048,1250}, - {1728,1066, 2048,1250}, - {1848,1066, 2048,1250}, - {2048,1250, 2048,1250} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1600x1200Data_2[]= -{ - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1280x768Data_1[]= -{ - { 768, 438, 1408, 806}, - { 768, 388, 1408, 806}, - { 768, 438, 1408, 806}, - { 768, 388, 1408, 806}, - { 768, 518, 1408, 806}, - { 928, 638, 1408, 806}, - {1152, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1280x768Data_2[]= -{ - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1024x600Data_1[] = -{ - {840, 604,1344, 800}, - {840, 560,1344, 800}, - {840, 604,1344, 800}, - {840, 560,1344, 800}, - {840, 689,1344, 800}, - {1050, 800,1344, 800}, - {1344, 800,1344, 800}, - {800, 449,1280, 789}, - {800, 525,1280, 785} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1024x600Data_2[] = -{ - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1152x768Data_1[] = -{ - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1152x768Data_2[] = -{ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -/* TW: pass 1:1 data */ -static const SiS300_LVDSDataStruct SiS300_LVDSXXXxXXXData_1[]= -{ - { 800, 449, 800, 449}, - { 800, 449, 800, 449}, - { 900, 449, 900, 449}, - { 900, 449, 900, 449}, - { 800, 525, 800, 525}, /* 640x480 */ - {1056, 628, 1056, 628}, /* 800x600 */ - {1344, 806, 1344, 806}, /* 1024x768 */ - {1344,1066, 1344,1066}, /* 1280x1024 */ /* INSERTED ! */ - {1688, 806, 1688, 806}, /* 1280x768 ! */ - /* No other panels ! */ -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS640x480Data_1[] = -{ - {800, 449, 800, 449}, - {800, 449, 800, 449}, - {800, 449, 800, 449}, - {800, 449, 800, 449}, - {800, 525, 800, 525}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1280x960Data_1[] = /* TW: New */ -{ - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1280x960Data_2[] = /* TW: New */ -{ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LCDA1400x1050Data_1[] = /* TW: New */ -{ /* TW: Might be temporary (invalid) data */ - {928, 416, 1688, 1066}, - {928, 366, 1688, 1066}, - {1008, 416, 1688, 1066}, - {1008, 366, 1688, 1066}, - {1200, 530, 1688, 1066}, - {1088, 616, 1688, 1066}, - {1312, 784, 1688, 1066}, - {1568, 1040, 1688, 1066}, - {1688, 1066, 1688, 1066} -}; - -static const SiS300_LVDSDataStruct SiS300_LCDA1400x1050Data_2[] = /* TW: New */ -{ /* TW: Temporary data. Not valid */ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LCDA1600x1200Data_1[] = /* TW: New */ -{ /* TW: Temporary data. Not valid */ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LCDA1600x1200Data_2[] = /* TW: New */ -{ /* TW: Temporary data. Not valid */ - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0} -}; - - -/* TW: New: */ -static const SiS300_LVDSDataStruct SiS300_CHTVUNTSCData[] = -{ - {840, 600, 840, 600}, - {840, 600, 840, 600}, - {840, 600, 840, 600}, - {840, 600, 840, 600}, - {784, 600, 784, 600}, - {1064, 750,1064, 750} -}; - -static const SiS300_LVDSDataStruct SiS300_CHTVONTSCData[] = -{ - {840, 525, 840, 525}, - {840, 525, 840, 525}, - {840, 525, 840, 525}, - {840, 525, 840, 525}, - {784, 525, 784, 525}, - {1040, 700,1040, 700} -}; - static const SiS300_LVDSDataStruct SiS300_CHTVUPALData[] = { {1008, 625,1008, 625}, {1008, 625,1008, 625}, {1008, 625,1008, 625}, {1008, 625,1008, 625}, - {840, 750, 840, 750}, - {936, 836, 936, 836} + { 840, 750, 840, 750}, + { 936, 836, 936, 836} }; static const SiS300_LVDSDataStruct SiS300_CHTVOPALData[] = @@ -2034,8 +1054,8 @@ static const SiS300_LVDSDataStruct SiS3 {1008, 625,1008, 625}, {1008, 625,1008, 625}, {1008, 625,1008, 625}, - {840, 625, 840, 625}, - {960, 750, 960, 750} + { 840, 625, 840, 625}, + { 960, 750, 960, 750} }; static const SiS300_LVDSDataStruct SiS300_CHTVSOPALData[] = @@ -2044,12 +1064,10 @@ static const SiS300_LVDSDataStruct SiS3 {1008, 625,1008, 625}, {1008, 625,1008, 625}, {1008, 625,1008, 625}, - {840, 500, 840, 500}, - {944, 625, 944, 625} + { 840, 500, 840, 500}, + { 944, 625, 944, 625} }; -/* TW: new end */ - typedef struct _SiS300_LVDSDesStruct { USHORT LCDHDES; @@ -2058,57 +1076,90 @@ typedef struct _SiS300_LVDSDesStruct static const SiS300_LVDSDesStruct SiS300_PanelType00_1[] = { + { 1059, 626 }, /* 2.08 */ + { 1059, 624 }, + { 1059, 626 }, + { 1059, 624 }, + { 1059, 624 }, + { 0, 627 }, + { 0, 627 }, + { 0, 0 }, + { 0, 0 } +#if 0 {0, 626}, {0, 624}, {0, 626}, {0, 624}, {0, 624}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} + {0, 627}, + {0, 627}, + {0, 0}, + {0, 0} +#endif }; static const SiS300_LVDSDesStruct SiS300_PanelType01_1[] = { + { 0, 0 }, /* 2.08 */ + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 } +#if 0 {1343, 798}, {1343, 794}, {1343, 798}, {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} +#endif }; static const SiS300_LVDSDesStruct SiS300_PanelType02_1[] = { + { 1059, 626 }, /* 2.08 */ + { 1059, 624 }, + { 1059, 626 }, + { 1059, 624 }, + { 1059, 624 }, + { 0, 627 }, + { 0, 627 }, + { 0, 0 }, + { 0, 0 } +#if 0 {0, 626}, {0, 624}, {0, 626}, {0, 624}, {0, 624}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} + {0, 627}, + {0, 627}, + {0, 0}, + {0, 0} +#endif }; static const SiS300_LVDSDesStruct SiS300_PanelType03_1[] = { - { 8, 436}, - { 8, 440}, - { 8, 436}, - { 8, 440}, - { 8, 512}, + { 8, 436}, + { 8, 440}, + { 8, 436}, + { 8, 440}, + { 8, 512}, {1343, 798}, {1343, 794}, {1343, 798}, {1343, 794} }; -static const SiS300_LVDSDesStruct SiS300_PanelType04_1[] = +static const SiS300_LVDSDesStruct SiS300_PanelType04_1[] = /* 1280x1024 */ { {1343, 798}, {1343, 794}, @@ -2116,9 +1167,9 @@ static const SiS300_LVDSDesStruct SiS30 {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType05_1[] = @@ -2129,9 +1180,9 @@ static const SiS300_LVDSDesStruct SiS30 {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType06_1[] = @@ -2142,9 +1193,9 @@ static const SiS300_LVDSDesStruct SiS30 {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType07_1[] = @@ -2155,9 +1206,9 @@ static const SiS300_LVDSDesStruct SiS30 {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType08_1[] = @@ -2167,10 +1218,10 @@ static const SiS300_LVDSDesStruct SiS30 {1059, 626}, {1059, 624}, {1059, 624}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} + { 0, 627}, + { 0, 627}, + { 0, 0}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType09_1[] = @@ -2181,9 +1232,9 @@ static const SiS300_LVDSDesStruct SiS30 {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType0a_1[] = @@ -2193,23 +1244,23 @@ static const SiS300_LVDSDesStruct SiS30 {1059, 626}, {1059, 624}, {1059, 624}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} + { 0, 627}, + { 0, 627}, + { 0, 0}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType0b_1[] = { - {1343, 0}, - {1343, 0}, - {1343, 0}, - {1343, 0}, - {1343, 0}, /* 640x480 - BIOS 1343, 0 */ - {1343, 0}, - { 0, 799}, - { 0, 0}, - { 0, 0} + {1343, 0}, + {1343, 0}, + {1343, 0}, + {1343, 0}, + {1343, 0}, + {1343, 0}, + { 0, 799}, + { 0, 0}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType0c_1[] = @@ -2220,9 +1271,9 @@ static const SiS300_LVDSDesStruct SiS30 {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType0d_1[] = @@ -2233,9 +1284,9 @@ static const SiS300_LVDSDesStruct SiS30 {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType0e_1[] = @@ -2244,11 +1295,11 @@ static const SiS300_LVDSDesStruct SiS30 {1343, 794}, {1343, 798}, {1343, 794}, - {1343, 0}, /* 640x480 */ - {1343, 0}, /* 800x600 */ - { 0, 805}, /* 1024x768 */ - { 0, 794}, /* 1280x1024 */ - { 0, 0} /* 1280x960 - not applicable */ + {1343, 0}, /* 640x480 */ + {1343, 0}, /* 800x600 */ + { 0, 805}, /* 1024x768 */ + { 0, 794}, /* 1280x1024 */ + { 0, 0} /* 1280x960 - not applicable */ }; static const SiS300_LVDSDesStruct SiS300_PanelType0f_1[] = @@ -2259,9 +1310,9 @@ static const SiS300_LVDSDesStruct SiS30 {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType00_2[] = @@ -2271,10 +1322,10 @@ static const SiS300_LVDSDesStruct SiS30 {976, 527}, {976, 502}, {976, 567}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} + { 0, 627}, + { 0, 627}, + { 0, 0}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType01_2[] = @@ -2285,9 +1336,9 @@ static const SiS300_LVDSDesStruct SiS30 {1152, 597}, {1152, 662}, {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType02_2[] = @@ -2297,10 +1348,10 @@ static const SiS300_LVDSDesStruct SiS30 {976, 527}, {976, 502}, {976, 567}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} + { 0, 627}, + { 0, 627}, + { 0, 0}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType03_2[] = @@ -2472,232 +1523,57 @@ static const SiS300_LVDSDesStruct SiS30 { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelTypeNS_1[]= -{ - { 8, 0}, - { 8, 0}, - { 8, 0}, - { 8, 0}, - { 8, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 806}, - { 0, 0 } -}; - -static const SiS300_LVDSDesStruct SiS300_PanelTypeNS_2[] = -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS300_LVDSDesStruct SiS300_PanelType1076_1[] = /* TW: New */ -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS300_LVDSDesStruct SiS300_PanelType1076_2[] = /* TW: New */ -{ - { 1152, 622 }, - { 1152, 597 }, - { 1152, 622 }, - { 1152, 597 }, - { 1152, 622 }, - { 1232, 722 }, - { 0, 0 }, - { 0, 794 }, - { 0, 0 } -}; - -static const SiS300_LVDSDesStruct SiS300_PanelType1210_1[] = /* TW: New */ -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS300_LVDSDesStruct SiS300_PanelType1210_2[] = /* TW: New */ -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS300_LVDSDesStruct SiS300_PanelType1296_1[] = /* TW: New */ -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS300_LVDSDesStruct SiS300_PanelType1296_2[] = /* TW: New */ -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - - -/* TW: New */ -static const SiS300_LVDSDesStruct SiS300_CHTVUNTSCDesData[] = -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS300_LVDSDesStruct SiS300_CHTVONTSCDesData[] = -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS300_LVDSDesStruct SiS300_CHTVUPALDesData[] = -{ - {256, 0}, - {256, 0}, - {256, 0}, - {256, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS300_LVDSDesStruct SiS300_CHTVOPALDesData[] = +/* Custom data for Barco iQ R200/300/400 (BIOS 2.00.07) */ +static const SiS300_LVDSDesStruct SiS300_PanelType04_1a[] = /* 1280x1024 (1366x1024) */ { - {256, 0}, - {256, 0}, - {256, 0}, - {256, 0}, - { 0, 0}, - { 0, 0} + {1330, 798}, /* 320x200 */ + {1330, 794}, + {1330, 798}, + {1330, 794}, + {1330, 0}, /* 640x480 / 320x240 */ + {1343, 0}, /* 800x600 / 400x300 */ + { 0, 805}, /* 1024x768 / 512x384 */ + {1688,1066}, /* 1280x1024 */ + { 0, 0} /* 1360x1024 */ }; -/* TW: New end */ -/* TW: New for SiS300+301LV */ -typedef struct _SiS300_Part2PortTblStruct +static const SiS300_LVDSDesStruct SiS300_PanelType04_2a[] = { - UCHAR CR[12]; -} SiS300_Part2PortTblStruct; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1024x768_1[] = -{ /* VESA Timing */ - {{0x21,0x12,0xbf,0xe4,0xc0,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, - {{0x21,0x12,0xbf,0xe4,0xc0,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}}, - {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}}, - {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_1[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1400x1050_1[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1600x1200_1[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1024x768_2[] = -{ /* Non-VESA */ - {{0x28,0x12,0xa3,0xd0,0xaa,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x28,0x12,0xa3,0xd0,0xaa,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x28,0x13,0xe7,0x0b,0xe8,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x38,0x18,0x16,0x00,0x00,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x36,0x13,0x13,0x25,0xff,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}} + {1152, 622}, + {1152, 597}, + {1152, 622}, + {1152, 597}, + {1152, 662}, + {1232, 722}, + { 0, 805}, + {1688,1066}, + { 0, 0} }; -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_2[] = +/* Custom data for Barco iQ G200/300/400 (BIOS 2.00.07) */ +static const SiS300_LVDSDesStruct SiS300_PanelType04_1b[] = /* 1024x768 */ { - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} + {1330, 798}, /* 320x200 */ + {1330, 794}, + {1330, 798}, + {1330, 794}, + {1330, 0}, /* 640x480 / 320x240 */ + {1343, 0}, /* 800x600 / 400x300 */ + { 0, 805} /* 1024x768 / 512x384 */ }; -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1400x1050_2[] = +static const SiS300_LVDSDesStruct SiS300_PanelType04_2b[] = { - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1600x1200_2[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1024x768_3[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_3[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1400x1050_3[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} + {1152, 622}, + {1152, 597}, + {1152, 622}, + {1152, 597}, + {1152, 662}, + {1232, 722}, + { 0, 805} }; -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1600x1200_3[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; +/* CRT1 CRTC for slave modes */ typedef struct _SiS300_LVDSCRT1DataStruct { @@ -2726,56 +1602,6 @@ static const SiS300_LVDSCRT1DataStruct 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1[] = -{ - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, - 0x00}}, - {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1[] = -{ - {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x54,0x9f,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, - 0x00 }}, - {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, - 0x01 }}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01 }} -}; - static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_1_H[] = { {{0x30,0x27,0x94,0x2c,0x92,0xaf,0x1f, @@ -2798,8 +1624,56 @@ static const SiS300_LVDSCRT1DataStruct 0x01 }} }; +static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1[] = +{ + {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e, + 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, + 0x00}}, + {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, + 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, + 0x01}}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01}} +}; + static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1_H[] = { + {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, + 0x00 }}, + {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, + 0x60,0x87,0x5D,0x83,0x10,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, + 0x60,0x87,0x5D,0x83,0x10,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, + 0xE2,0x89,0xdf,0x05,0x00,0x00,0x44, + 0x00}}, + {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, + 0x5A,0x8F,0x57,0x7D,0x20,0x00,0x55, + 0x01}}, + {{0x4f,0x3F,0x93,0x45,0x0D,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x01, + 0x01 }} + +#if 0 {{0x37,0x27,0x9B,0x2b,0x94,0xc4,0x1f, 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, 0x00 }}, @@ -2821,6 +1695,32 @@ static const SiS300_LVDSCRT1DataStruct {{0x4f,0x3F,0x93,0x45,0x0D,0x24,0xf5, 0x02,0x88,0xFf,0x25,0x10,0x00,0x01, 0x01 }} +#endif +}; + +static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1[] = +{ + {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x54,0x9f,0x04,0x3e, + 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, + 0x00 }}, + {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, + 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, + 0x01 }}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01 }} }; static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1_H[] = @@ -2870,32 +1770,29 @@ static const SiS300_LVDSCRT1DataStruct 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2[] = +static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2_H[] = { - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, + 0xf4,0x88,0x8f,0x73,0x20,0x00,0x05, 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, + 0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05, 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, + 0xf4,0x88,0x8f,0x73,0x20,0x00,0x05, 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + {{0x3d,0x27,0x81,0x3a,0x1a,0x72,0x3e, + 0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05, 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, + {{0x3d,0x27,0x81,0x32,0x1a,0x72,0xba, + 0x1c,0x80,0xdf,0x73,0x00,0x00,0x05, 0x00 }}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01 }}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + {{0x3d,0x31,0x81,0x37,0x1f,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x05, 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2[] = +static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2[] = { {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, @@ -2920,28 +1817,6 @@ static const SiS300_LVDSCRT1DataStruct 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2_H[] = -{ - {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, - 0xf4,0x88,0x8f,0x73,0x20,0x00,0x05, - 0x00 }}, - {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, - 0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05, - 0x00 }}, - {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, - 0xf4,0x88,0x8f,0x73,0x20,0x00,0x05, - 0x00 }}, - {{0x3d,0x27,0x81,0x3a,0x1a,0x72,0x3e, - 0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05, - 0x00 }}, - {{0x3d,0x27,0x81,0x32,0x1a,0x72,0xba, - 0x1c,0x80,0xdf,0x73,0x00,0x00,0x05, - 0x00 }}, - {{0x3d,0x31,0x81,0x37,0x1f,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x05, - 0x01 }} -}; - static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2_H[] = { {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, @@ -2967,6 +1842,31 @@ static const SiS300_LVDSCRT1DataStruct 0x01 }} }; +static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2[] = +{ + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + 0x00 }}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + 0x00 }}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + 0x00 }}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + 0x00 }}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, + 0x00 }}, + {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, + 0xae,0x84,0x57,0x25,0x30,0x00,0x02, + 0x01 }}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01 }} +}; + static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2_H[] = { {{0x4f,0x27,0x93,0x39,0x81,0x24,0xbb, @@ -2992,207 +1892,6 @@ static const SiS300_LVDSCRT1DataStruct 0x01}} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x600_1[] = -{ - {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, - 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, - 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, - 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, - 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0xaf,0xba, - 0x3b,0x82,0xdf,0xb0,0x00,0x00,0x01, - 0x00}}, - {{0x7e,0x63,0x82,0x68,0x15,0x1e,0xf1, - 0xae,0x85,0x57,0x1f,0x30,0x00,0x26, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x1e,0xf1, - 0xae,0x85,0x57,0x1f,0x30,0x00,0x02, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x600_1_H[] = -{ - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, - 0x00}}, - {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x600_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x600_2_H[] = -{ - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x01, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11152x768_1[] = -{ - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, - 0x00}}, - {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11152x768_1_H[] = -{ - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, - 0x00}}, - {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11152x768_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11152x768_2_H[] = -{ - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x01, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -/* TW: New */ static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1UNTSC[] = { {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, @@ -3302,9 +2001,7 @@ static const SiS300_LVDSCRT1DataStruct 0x90,0x8c,0x57,0xed,0x20,0x00,0x05, 0x01 }} }; -/* TW: New end */ -/* TW: New */ typedef struct _SiS300_CHTVRegDataStruct { UCHAR Reg[16]; @@ -3354,16 +2051,14 @@ static const SiS300_CHTVRegDataStruct Si static const SiS300_CHTVRegDataStruct SiS300_CHTVReg_SOPAL[] = { - {{0x41,0x12,0x01,0x50,0x34,0,0,0,0,0,0,0,0,0,0,0}}, /* Mode 9: 640x400 PAL 5/4 */ + {{0x41,0x12,0x01,0x50,0x34,0,0,0,0,0,0,0,0,0,0,0}}, /* Mode 9: 640x400 PAL 1/1 */ {{0x41,0x12,0x00,0x50,0x00,0,0,0,0,0,0,0,0,0,0,0}}, {{0x41,0x12,0x01,0x50,0x34,0,0,0,0,0,0,0,0,0,0,0}}, {{0x41,0x12,0x00,0x50,0x00,0,0,0,0,0,0,0,0,0,0,0}}, {{0x60,0x30,0x00,0x10,0x00,0,0,0,0,0,0,0,0,0,0,0}}, /* TW: Mode 13: 640x480 PAL 5/4 */ {{0x81,0x50,0x00,0x1b,0x00,0,0,0,0,0,0,0,0,0,0,0}} /* TW: Mode 19: 800x600 PAL 1/1 */ }; -/* TW: New end */ -/* TW: New */ static const UCHAR SiS300_CHTVVCLKUNTSC[] = {0x29,0x29,0x29,0x29,0x2a,0x2e}; static const UCHAR SiS300_CHTVVCLKONTSC[] = {0x2c,0x2c,0x2c,0x2c,0x2d,0x2b}; @@ -3375,6 +2070,5 @@ static const UCHAR SiS300_CHTVVCLKUPAL[] static const UCHAR SiS300_CHTVVCLKOPAL[] = {0x2f,0x2f,0x2f,0x2f,0x30,0x32}; static const UCHAR SiS300_CHTVVCLKSOPAL[] = {0x2f,0x2f,0x2f,0x2f,0x36,0x29}; -/* TW: New end */ diff -puN drivers/video/sis/310vtbl.h~sisfb-update drivers/video/sis/310vtbl.h --- 25/drivers/video/sis/310vtbl.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/310vtbl.h 2004-01-22 03:06:55.000000000 -0800 @@ -1,7 +1,56 @@ - - -/* Register settings for SiS 310/325/330 series */ - +/* $XFree86$ */ +/* + * Register settings for SiS 315/330 series + * + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the Linux kernel, the following license terms + * apply: + * + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Otherwise, the following license terms apply: + * + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) All advertising materials mentioning features or use of this software + * * must display the following acknowledgement: "This product includes + * * software developed by Thomas Winischhofer, Vienna, Austria." + * * 4) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * + */ typedef struct _SiS310_StStruct { @@ -13,680 +62,227 @@ typedef struct _SiS310_StStruct UCHAR VB_StTVFlickerIndex; UCHAR VB_StTVEdgeIndex; UCHAR VB_StTVYFilterIndex; + UCHAR St_PDC; } SiS310_StStruct; static const SiS310_StStruct SiS310_SModeIDTable[]= { - {0x01,0x9208,0x01,0x00,0x00,0x00,0x01,0x00}, - {0x01,0x1210,0x14,0x01,0x01,0x00,0x01,0x00}, - {0x01,0x1010,0x17,0x02,0x02,0x00,0x01,0x01}, - {0x03,0x8208,0x03,0x00,0x00,0x00,0x01,0x02}, - {0x03,0x0210,0x16,0x01,0x01,0x00,0x01,0x02}, - {0x03,0x0010,0x18,0x02,0x02,0x00,0x01,0x03}, - {0x05,0x9209,0x05,0x00,0x00,0x00,0x00,0x04}, - {0x06,0x8209,0x06,0x00,0x00,0x00,0x00,0x05}, - {0x07,0x0000,0x07,0x03,0x03,0x00,0x01,0x03}, - {0x07,0x0000,0x19,0x02,0x02,0x00,0x01,0x03}, - {0x0d,0x920a,0x0d,0x00,0x00,0x00,0x00,0x04}, - {0x0e,0x820a,0x0e,0x00,0x00,0x00,0x00,0x05}, - {0x0f,0x0202,0x11,0x01,0x01,0x00,0x00,0x05}, - {0x10,0x0212,0x12,0x01,0x01,0x00,0x00,0x05}, - {0x11,0x0212,0x1a,0x04,0x04,0x00,0x00,0x05}, - {0x12,0x0212,0x1b,0x04,0x04,0x00,0x00,0x05}, - {0x13,0x021b,0x1c,0x00,0x00,0x00,0x00,0x04}, - {0x12,0x0010,0x18,0x02,0x02,0x00,0x00,0x05}, - {0x12,0x0210,0x18,0x01,0x01,0x00,0x00,0x05}, - {0xff,0x0000,0x00,0x00,0x00,0x00,0x00,0x00} -}; - -typedef struct _SiS310_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]; -} SiS310_StandTableStruct; - -static const SiS310_StandTableStruct SiS310_StandTable[]= -{ -/* 0x00: MD_0_200 */ - { - 0x28,0x18,0x08,0x0800, - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* 0x01: MD_1_200 */ - { - 0x28,0x18,0x08,0x0800, - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* 0x02: MD_2_200 */ - { - 0x50,0x18,0x08,0x1000, - {0x01,0x03,0x00,0x02}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* 0x03: MD_3_200 - mode 0x03 - 0 */ - { - 0x50,0x18,0x08,0x1000, - {0x01,0x03,0x00,0x02}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* 0x04: MD_4 */ - { - 0x28,0x18,0x08,0x4000, - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, - 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2, - 0xff}, - {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x03,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00, - 0xff} - }, -/* 0x05: MD_5 */ - { - 0x28,0x18,0x08,0x4000, - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, - 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2, - 0xff}, - {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x03,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00, - 0xff} - }, -/* 0x06: MD_6 */ - { - 0x50,0x18,0x08,0x4000, - {0x01,0x01,0x00,0x06}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2, - 0xff}, - {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17, - 0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17, - 0x01,0x00,0x01,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00, - 0xff} - }, -/* 0x07: MD_7 */ - { - 0x50,0x18,0x0e,0x1000, - {0x00,0x03,0x00,0x03}, - 0xa6, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3, - 0xff}, - {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08, - 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18, - 0x0e,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00, - 0xff} - }, -/* 0x08: MDA_DAC */ - { - 0x00,0x00,0x00,0x0000, - {0x00,0x00,0x00,0x15}, - 0x15, - {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, - 0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00, - 0x00}, - {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15, - 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, - 0x15,0x15,0x15,0x15}, - {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f} - }, -/* 0x09: CGA_DAC */ - { - 0x00,0x10,0x04,0x0114, - {0x11,0x09,0x15,0x00}, - 0x10, - {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a, - 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a, - 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10, - 0x04}, - {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04, - 0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e, - 0x3e,0x2b,0x3b,0x2f}, - {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f, - 0x3f} - }, -/* 0x0a: EGA_DAC */ - { - 0x00,0x10,0x04,0x0114, - {0x11,0x05,0x15,0x20}, - 0x30, - {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18, - 0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38, - 0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12, - 0x06}, - {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26, - 0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e, - 0x1e,0x0b,0x1b,0x0f}, - {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f, - 0x3f} - }, -/* 0x0b: VGA_DAC */ - { - 0x00,0x10,0x04,0x0114, - {0x11,0x09,0x15,0x2a}, - 0x3a, - {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05, - 0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20, - 0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10, - 0x1f}, - {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d, - 0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15, - 0x1c,0x0e,0x11,0x15}, - {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00, - 0x04} - }, -/* 0x0c */ - { - 0x08,0x0c,0x10,0x0a08, - {0x0c,0x0e,0x10,0x0b}, - 0x0c, - {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00, - 0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00, - 0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00, - 0x06}, - {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08, - 0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00, - 0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00} - }, -/* 0x0d: MD_D */ - { - 0x28,0x18,0x08,0x2000, - {0x09,0x0f,0x00,0x06}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, - 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} - }, -/* 0x0e: MD_E */ - { - 0x50,0x18,0x08,0x4000, - {0x01,0x0f,0x00,0x06}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} - }, -/* 0x0f: ExtVGATable - modes > 0x13 */ - { - 0x00,0x00,0x00,0x0000, - {0x01,0x0f,0x00,0x0e}, - 0x23, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, - 0x01,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, - 0xff} - }, -/* 0x10: ROM_SAVEPTR */ - { - 0x9f,0x3b,0x00,0x00c0, - {0x00,0x00,0x00,0x00}, - 0x00, - {0x00,0x00,0x00,0x00,0x00,0x00,0xbb,0x3f, - 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x1a,0x00,0xac,0x3e,0x00,0xc0, - 0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00} - }, -/* 0x11: MD_F */ - { - 0x50,0x18,0x0e,0x8000, - {0x01,0x0f,0x00,0x06}, - 0xa2, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3, - 0xff}, - {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00, - 0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00, - 0x0b,0x00,0x05,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05, - 0xff} - }, -/* 0x12: MD_10 */ - { - 0x50,0x18,0x0e,0x8000, - {0x01,0x0f,0x00,0x06}, - 0xa3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} - }, -/* 0x13: MD_0_350 */ - { - 0x28,0x18,0x0e,0x0800, - {0x09,0x03,0x00,0x02}, - 0xa3, - {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* 0x14: MD_1_350 */ - { - 0x28,0x18,0x0e,0x0800, - {0x09,0x03,0x00,0x02}, - 0xa3, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* 0x15: MD_2_350 */ - { - 0x50,0x18,0x0e,0x1000, - {0x01,0x03,0x00,0x02}, - 0xa3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* 0x16: MD_3_350 - mode 0x03 - 1 */ - { - 0x50,0x18,0x0e,0x1000, - {0x01,0x03,0x00,0x02}, - 0xa3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* 0x17: MD_0_1_400 */ - { - 0x28,0x18,0x10,0x0800, - {0x08,0x03,0x00,0x02}, - 0x67, - {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f, - 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x0c,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* 0x18: MD_2_3_400 - mode 0x03 - 2 */ - { - 0x50,0x18,0x10,0x1000, - {0x00,0x03,0x00,0x02}, - 0x67, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x0c,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* 0x19: MD_7_400 */ - { - 0x50,0x18,0x10,0x1000, - {0x00,0x03,0x00,0x02}, - 0x66, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08, - 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18, - 0x0e,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00, - 0xff} - }, -/* 0x1a: MD_11 */ - { - 0x50,0x1d,0x10,0xa000, - {0x01,0x0f,0x00,0x06}, - 0xe3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xc3, - 0xff}, - {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01, - 0xff} - }, -/* 0x1b: ExtEGATable - Modes <= 0x02 */ - { - 0x50,0x1d,0x10,0xa000, - {0x01,0x0f,0x00,0x06}, - 0xe3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} - }, -/* 0x1c: MD_13 */ - { - 0x28,0x18,0x08,0x2000, - {0x01,0x0f,0x00,0x0e}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, - 0x41,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, - 0xff} - } + {0x01,0x9208,0x01,0x00,0x00,0x00,0x01,0x00, 0x40}, + {0x01,0x1210,0x14,0x01,0x01,0x00,0x01,0x00, 0x40}, + {0x01,0x1010,0x17,0x02,0x02,0x00,0x01,0x01, 0x40}, + {0x03,0x8208,0x03,0x00,0x00,0x00,0x01,0x02, 0x40}, + {0x03,0x0210,0x16,0x01,0x01,0x00,0x01,0x02, 0x40}, + {0x03,0x0010,0x18,0x02,0x02,0x00,0x01,0x03, 0x40}, + {0x05,0x9209,0x05,0x00,0x00,0x00,0x00,0x04, 0x40}, + {0x06,0x8209,0x06,0x00,0x00,0x00,0x00,0x05, 0x40}, + {0x07,0x0000,0x07,0x03,0x03,0x00,0x01,0x03, 0x40}, + {0x07,0x0000,0x19,0x02,0x02,0x00,0x01,0x03, 0x40}, + {0x0d,0x920a,0x0d,0x00,0x00,0x00,0x00,0x04, 0x40}, + {0x0e,0x820a,0x0e,0x00,0x00,0x00,0x00,0x05, 0x40}, + {0x0f,0x0202,0x11,0x01,0x01,0x00,0x00,0x05, 0x40}, + {0x10,0x0212,0x12,0x01,0x01,0x00,0x00,0x05, 0x40}, + {0x11,0x0212,0x1a,0x04,0x04,0x00,0x00,0x05, 0x40}, + {0x12,0x0212,0x1b,0x04,0x04,0x00,0x00,0x05, 0x40}, + {0x13,0x021b,0x1c,0x00,0x00,0x00,0x00,0x04, 0x40}, + {0x12,0x0010,0x18,0x02,0x02,0x00,0x00,0x05, 0x40}, + {0x12,0x0210,0x18,0x01,0x01,0x00,0x00,0x05, 0x40}, + {0xff,0x0000,0x00,0x00,0x00,0x00,0x00,0x00, 0x40} }; typedef struct _SiS310_ExtStruct { - UCHAR Ext_ModeID; + UCHAR Ext_ModeID; USHORT Ext_ModeFlag; - USHORT Ext_ModeInfo; - USHORT Ext_Point; /* TW: Address of table entry in (older) BIOS image */ + UCHAR Ext_ModeOffset; USHORT Ext_VESAID; - UCHAR Ext_VESAMEMSize; - UCHAR Ext_RESINFO; - UCHAR VB_ExtTVFlickerIndex; - UCHAR VB_ExtTVEdgeIndex; - UCHAR VB_ExtTVYFilterIndex; - UCHAR REFindex; + UCHAR Ext_RESINFO; + UCHAR VB_ExtTVFlickerIndex; + UCHAR VB_ExtTVEdgeIndex; + UCHAR VB_ExtTVYFilterIndex; + UCHAR VB_ExtTVYFilterIndexROM661; + UCHAR REFindex; } SiS310_ExtStruct; -/* TW: Checked with 650/LVDS and 650/301LVx 1.10.6s */ static const SiS310_ExtStruct SiS310_EModeIDTable[]= { - {0x6a,0x2212,0x0407,0x3a81,0x0102,0x08,0x07,0x00,0x00,0x07,0x00}, /* 800x600x? */ - {0x2e,0x0a1b,0x0306,0x3a57,0x0101,0x08,0x06,0x00,0x00,0x05,0x08}, /* 640x480x8 */ -/* {0x2e,0x021b,0x0306,0x3a57,0x0101,0x08,0x06,0x00,0x00,0x05,0x08}, */ /* 640x480x8 - 650/LVDS BIOS (no CRt2Mode) */ - {0x2f,0x0a1b,0x0305,0x3a50,0x0100,0x08,0x05,0x00,0x00,0x05,0x10}, /* 640x400x8 */ -/* {0x2f,0x021b,0x0305,0x3a50,0x0100,0x08,0x05,0x00,0x00,0x05,0x10}, */ /* 640x400x8 - 650/LVDS BIOS (no CRt2Mode) */ - {0x30,0x2a1b,0x0407,0x3a81,0x0103,0x08,0x07,0x00,0x00,0x07,0x00}, /* 800x600x8 */ -/* {0x30,0x221b,0x0407,0x3a81,0x0103,0x08,0x07,0x00,0x00,0x07,0x00}, */ /* 800x600x8 - 650/LVDS BIOS (no CRt2Mode) */ -/* {0x31,0x0a1b,0x030d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x11}, */ /* 720x480x8 */ - {0x31,0x0a1b,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x11}, /* 720x480x8 BIOS (301/LVDS) */ - {0x32,0x0a1b,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x12}, /* 720x576x8 */ - {0x33,0x0a1d,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x11}, /* 720x480x16 */ - {0x34,0x2a1d,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x12}, /* 720x576x16 */ - {0x35,0x0a1f,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x11}, /* 720x480x32 */ - {0x36,0x2a1f,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x12}, /* 720x576x32 */ - {0x37,0x0212,0x0508,0x3aab,0x0104,0x08,0x08,0x00,0x00,0x08,0x13}, /* 1024x768x? */ - {0x38,0x0a1b,0x0508,0x3aab,0x0105,0x08,0x08,0x00,0x00,0x08,0x13}, /* 1024x768x8 */ - {0x3a,0x0e3b,0x0609,0x3adc,0x0107,0x08,0x09,0x00,0x00,0x00,0x1a}, /* 1280x1024x8 */ - {0x3c,0x0e3b,0x070a,0x3af2,0x0130,0x08,0x0a,0x00,0x00,0x00,0x1e}, /* 1600x1200x8 */ - {0x3d,0x0e7d,0x070a,0x3af2,0x0131,0x08,0x0a,0x00,0x00,0x00,0x1e}, /* 1600x1200x16 - 650/301LVx - no CRT2Mode? */ - {0x40,0x9a1c,0x0000,0x3a34,0x010d,0x08,0x00,0x00,0x00,0x04,0x25}, - {0x41,0x9a1d,0x0000,0x3a34,0x010e,0x08,0x00,0x00,0x00,0x04,0x25}, - {0x43,0x0a1c,0x0306,0x3a57,0x0110,0x08,0x06,0x00,0x00,0x05,0x08}, - {0x44,0x0a1d,0x0306,0x3a57,0x0111,0x08,0x06,0x00,0x00,0x05,0x08}, /* 640x480x16 */ - {0x46,0x2a1c,0x0407,0x3a81,0x0113,0x08,0x07,0x00,0x00,0x07,0x00}, - {0x47,0x2a1d,0x0407,0x3a81,0x0114,0x08,0x07,0x00,0x00,0x07,0x00}, /* 800x600x16 */ - {0x49,0x0a3c,0x0508,0x3aab,0x0116,0x08,0x08,0x00,0x00,0x00,0x13}, - {0x4a,0x0a3d,0x0508,0x3aab,0x0117,0x08,0x08,0x00,0x00,0x08,0x13}, /* 1024x768x16 */ - {0x4c,0x0e7c,0x0609,0x3adc,0x0119,0x08,0x09,0x00,0x00,0x00,0x1a}, - {0x4d,0x0e7d,0x0609,0x3adc,0x011a,0x08,0x09,0x00,0x00,0x00,0x1a}, /* 1280x1024x16 */ - {0x50,0x9a1b,0x0001,0x3a3b,0x0132,0x08,0x01,0x00,0x00,0x04,0x26}, /* 320x240 */ - {0x51,0xba1b,0x0103,0x3a42,0x0133,0x08,0x03,0x00,0x00,0x07,0x27}, - {0x52,0xba1b,0x0204,0x3a49,0x0134,0x08,0x04,0x00,0x00,0x00,0x28}, /* 650/301 BIOS */ - {0x56,0x9a1d,0x0001,0x3a3b,0x0135,0x08,0x01,0x00,0x00,0x04,0x26}, - {0x57,0xba1d,0x0103,0x3a42,0x0136,0x08,0x03,0x00,0x00,0x07,0x27}, - {0x58,0xba1d,0x0204,0x3a49,0x0137,0x08,0x04,0x00,0x00,0x00,0x28}, /* BIOS (301+LVDS) */ - {0x59,0x9a1b,0x0000,0x3a34,0x0138,0x08,0x00,0x00,0x00,0x04,0x25}, /* 320x200 */ - {0x5A,0x021b,0x0014,0x3b83,0x0138,0x08,0x01,0x00,0x00,0x04,0x3f}, /* 320x480x8 fstn add new mode*/ - {0x5B,0x0a1d,0x0014,0x3b83,0x0135,0x08,0x01,0x00,0x00,0x04,0x3f}, /* 320x480x16 fstn add new mode*/ - {0x5c,0xba1f,0x0204,0x3a49,0x0000,0x08,0x04,0x00,0x00,0x00,0x28}, /* TW: inserted 512x384x32 */ - {0x5d,0x0a1d,0x0305,0x3a50,0x0139,0x08,0x05,0x00,0x00,0x07,0x10}, - {0x5e,0x0a1f,0x0305,0x3a50,0x0000,0x08,0x05,0x00,0x00,0x07,0x10}, /* TW: Inserted 640x400x32 */ - {0x62,0x0a3f,0x0306,0x3a57,0x013a,0x08,0x06,0x00,0x00,0x05,0x08}, /* 640x480x32 */ - {0x63,0x2a3f,0x0407,0x3a81,0x013b,0x08,0x07,0x00,0x00,0x07,0x00}, /* 800x600x32 */ - {0x64,0x0a7f,0x0508,0x3aab,0x013c,0x08,0x08,0x00,0x00,0x08,0x13}, /* 1024x768x32 */ - {0x65,0x0eff,0x0609,0x3adc,0x013d,0x08,0x09,0x00,0x00,0x00,0x1a}, /* 1280x1024x32 */ - {0x66,0x0eff,0x070a,0x3af2,0x013e,0x08,0x0a,0x00,0x00,0x00,0x1e}, /* 1600x1200x32 */ - {0x68,0x067b,0x080b,0x3b17,0x013f,0x08,0x0b,0x00,0x00,0x00,0x29}, /* 1920x1440x8 */ - {0x69,0x06fd,0x080b,0x3b17,0x0140,0x08,0x0b,0x00,0x00,0x00,0x29}, /* 1920x1440x16 */ - {0x6b,0x07ff,0x080b,0x3b17,0x0141,0x10,0x0b,0x00,0x00,0x00,0x29}, /* 1920x1440x32 */ - {0x6c,0x067b,0x090c,0x3b37,0x0000,0x08,0x0c,0x00,0x00,0x00,0x2f}, /* 2048x1536x8 */ - {0x6d,0x06fd,0x090c,0x3b37,0x0000,0x10,0x0c,0x00,0x00,0x00,0x2f}, /* 2048x1536x16 */ - {0x6e,0x07ff,0x090c,0x3b37,0x0000,0x10,0x0c,0x00,0x00,0x00,0x2f}, /* 2048x1536x32 */ - {0x70,0x2a1b,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34}, /* 800x480x8 */ - {0x71,0x0a1b,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37}, /* 1024x576x8 */ - {0x74,0x0a1d,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37}, /* 1024x576x16 */ - {0x75,0x0a3d,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a}, /* 1280x720x16 */ - {0x76,0x2a1f,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34}, /* 800x480x32 */ - {0x77,0x0a1f,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37}, /* 1024x576x32 */ - {0x78,0x0a3f,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a}, /* 1280x720x32 */ - {0x79,0x0a3b,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a}, /* 1280x720x8 */ - {0x7a,0x2a1d,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34}, /* 800x480x16 */ - {0x7c,0x0e3b,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x3d}, /* 1280x960x8 - TW */ - {0x7d,0x0e7d,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x3d}, /* 1280x960x16 - TW */ - {0x7e,0x0eff,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x3d}, /* 1280x960x32 - TW */ - /* TW: 650/LVDS BIOS new modes */ - {0x23,0x0e3b,0x0614,0x36f7,0x0000,0x08,0x14,0x00,0x00,0x00,0x40}, /* 1280x768x8 */ - {0x24,0x0e7d,0x0614,0x36f7,0x0000,0x08,0x14,0x00,0x00,0x00,0x40}, /* 1280x768x16 */ - {0x25,0x0eff,0x0614,0x36f7,0x0000,0x08,0x14,0x00,0x00,0x00,0x40}, /* 1280x768x32 */ - {0x26,0x0e3b,0x0c15,0x36fe,0x0000,0x08,0x15,0x00,0x00,0x00,0x41}, /* 1400x1050x8 */ - {0x27,0x0e7d,0x0c15,0x36fe,0x0000,0x08,0x15,0x00,0x00,0x00,0x41}, /* 1400x1050x16 */ - {0x28,0x0eff,0x0c15,0x36fe,0x0000,0x08,0x15,0x00,0x00,0x00,0x41}, /* 1400x1050x32*/ - {0x29,0x0e1b,0x0d16,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x43}, /* TW: NEW 1152x864 - not in BIOS */ - {0x2a,0x0e3d,0x0d16,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x43}, - {0x2b,0x0e7f,0x0d16,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x43}, - {0x39,0x2a1b,0x0b17,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x45}, /* TW: NEW 848x480 - not in BIOS */ - {0x3b,0x2a3d,0x0b17,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x45}, - {0x3e,0x2a7f,0x0b17,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x45}, - {0x3f,0x2a1b,0x0b13,0x0000,0x0000,0x08,0x13,0x00,0x00,0x00,0x47}, /* TW: NEW 856x480 - not in BIOS */ - {0x42,0x2a3d,0x0b13,0x0000,0x0000,0x08,0x13,0x00,0x00,0x00,0x47}, - {0x45,0x2a7f,0x0b13,0x0000,0x0000,0x08,0x13,0x00,0x00,0x00,0x47}, - {0x48,0x2a1b,0x0e18,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x49}, /* TW: NEW 1360x768 - not in BIOS */ - {0x4b,0x2a3d,0x0e18,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x49}, - {0x4e,0x2a7f,0x0e18,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x49}, - {0xff,0x0000,0x0000,0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00} + {0x6a,0x2212,0x04,0x0102,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00}, /* 800x600x? */ + {0x2e,0x0a1b,0x03,0x0101,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08}, /* 640x480x8 */ + {0x2f,0x0a1b,0x03,0x0100,SIS_RI_640x400, 0x00,0x00,0x05,0x05,0x10}, /* 640x400x8 */ + {0x30,0x2a1b,0x04,0x0103,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00}, /* 800x600x8 */ + {0x31,0x0a1b,0x0a,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x06,0x11}, /* 720x480x8 */ + {0x32,0x0a1b,0x0a,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x06,0x12}, /* 720x576x8 */ + {0x33,0x0a1d,0x0a,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x06,0x11}, /* 720x480x16 */ + {0x34,0x2a1d,0x0a,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x06,0x12}, /* 720x576x16 */ + {0x35,0x0a1f,0x0a,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x06,0x11}, /* 720x480x32 */ + {0x36,0x2a1f,0x0a,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x06,0x12}, /* 720x576x32 */ + {0x37,0x0212,0x05,0x0104,SIS_RI_1024x768, 0x00,0x00,0x08,0x07,0x13}, /* 1024x768x? */ + {0x38,0x0a1b,0x05,0x0105,SIS_RI_1024x768, 0x00,0x00,0x08,0x07,0x13}, /* 1024x768x8 */ + {0x3a,0x0e3b,0x06,0x0107,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, /* 1280x1024x8 */ + {0x3c,0x0e3b,0x07,0x0130,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e}, /* 1600x1200x8 */ + {0x3d,0x0e7d,0x07,0x0131,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e}, /* 1600x1200x16 */ + {0x40,0x9a1c,0x00,0x010d,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25}, /* 320x200x15 */ + {0x41,0x9a1d,0x00,0x010e,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25}, /* 320x200x16 */ + {0x43,0x0a1c,0x03,0x0110,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08}, + {0x44,0x0a1d,0x03,0x0111,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08}, /* 640x480x16 */ + {0x46,0x2a1c,0x04,0x0113,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00}, + {0x47,0x2a1d,0x04,0x0114,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00}, /* 800x600x16 */ + {0x49,0x0a3c,0x05,0x0116,SIS_RI_1024x768, 0x00,0x00,0x00,0x07,0x13}, + {0x4a,0x0a3d,0x05,0x0117,SIS_RI_1024x768, 0x00,0x00,0x08,0x07,0x13}, /* 1024x768x16 */ + {0x4c,0x0e7c,0x06,0x0119,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, + {0x4d,0x0e7d,0x06,0x011a,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, /* 1280x1024x16 */ + {0x50,0x9a1b,0x00,0x0132,SIS_RI_320x240, 0x00,0x00,0x04,0x04,0x26}, /* 320x240x8 */ + {0x51,0xba1b,0x01,0x0133,SIS_RI_400x300, 0x00,0x00,0x07,0x07,0x27}, /* 400x300x8 */ + {0x52,0xba1b,0x02,0x0134,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28}, /* 512x384x8 */ + {0x56,0x9a1d,0x00,0x0135,SIS_RI_320x240, 0x00,0x00,0x04,0x04,0x26}, /* 320x240x16 */ + {0x57,0xba1d,0x01,0x0136,SIS_RI_400x300, 0x00,0x00,0x07,0x07,0x27}, /* 400x300x16 */ + {0x58,0xba1d,0x02,0x0137,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28}, /* 512x384x16 */ + {0x59,0x9a1b,0x00,0x0138,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25}, /* 320x200x8 */ + {0x5a,0x021b,0x00,0x0138,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x3f}, /* 320x240x8 fstn */ + {0x5b,0x0a1d,0x00,0x0135,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x3f}, /* 320x240x16 fstn */ + {0x5c,0xba1f,0x02,0x0000,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28}, /* 512x384x32 */ + {0x5d,0x0a1d,0x03,0x0139,SIS_RI_640x400, 0x00,0x00,0x05,0x07,0x10}, + {0x5e,0x0a1f,0x03,0x0000,SIS_RI_640x400, 0x00,0x00,0x05,0x07,0x10}, /* 640x400x32 */ + {0x62,0x0a3f,0x03,0x013a,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08}, /* 640x480x32 */ + {0x63,0x2a3f,0x04,0x013b,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00}, /* 800x600x32 */ + {0x64,0x0a7f,0x05,0x013c,SIS_RI_1024x768, 0x00,0x00,0x08,0x07,0x13}, /* 1024x768x32 */ + {0x65,0x0eff,0x06,0x013d,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, /* 1280x1024x32 */ + {0x66,0x0eff,0x07,0x013e,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e}, /* 1600x1200x32 */ + {0x68,0x067b,0x08,0x013f,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x29}, /* 1920x1440x8 */ + {0x69,0x06fd,0x08,0x0140,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x29}, /* 1920x1440x16 */ + {0x6b,0x07ff,0x08,0x0141,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x29}, /* 1920x1440x32 */ + {0x6c,0x067b,0x09,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x2f}, /* 2048x1536x8 */ + {0x6d,0x06fd,0x09,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x2f}, /* 2048x1536x16 */ + {0x6e,0x07ff,0x09,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x2f}, /* 2048x1536x32 */ + {0x70,0x2a1b,0x04,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x07,0x34}, /* 800x480x8 */ + {0x71,0x0a1b,0x05,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x37}, /* 1024x576x8 */ + {0x74,0x0a1d,0x05,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x37}, /* 1024x576x16 */ + {0x75,0x0a3d,0x06,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x3a}, /* 1280x720x16 */ + {0x76,0x2a1f,0x04,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x07,0x34}, /* 800x480x32 */ + {0x77,0x0a1f,0x05,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x37}, /* 1024x576x32 */ + {0x78,0x0a3f,0x06,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x3a}, /* 1280x720x32 */ + {0x79,0x0a3b,0x06,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x3a}, /* 1280x720x8 */ + {0x7a,0x2a1d,0x04,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x07,0x34}, /* 800x480x16 */ + {0x7c,0x0e3b,0x06,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x3d}, /* 1280x960x8 */ + {0x7d,0x0e7d,0x06,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x3d}, /* 1280x960x16 */ + {0x7e,0x0eff,0x06,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x3d}, /* 1280x960x32 */ + {0x23,0x0e3b,0x06,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x40}, /* 1280x768x8 */ + {0x24,0x0e7d,0x06,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x40}, /* 1280x768x16 */ + {0x25,0x0eff,0x06,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x40}, /* 1280x768x32 */ + {0x26,0x0e3b,0x0c,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x41}, /* 1400x1050x8 */ + {0x27,0x0e7d,0x0c,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x41}, /* 1400x1050x16 */ + {0x28,0x0eff,0x0c,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x41}, /* 1400x1050x32*/ + {0x29,0x0e1b,0x0d,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x43}, /* 1152x864 */ + {0x2a,0x0e3d,0x0d,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x43}, + {0x2b,0x0e7f,0x0d,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x43}, + {0x39,0x2a1b,0x0b,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x45}, /* 848x480 */ + {0x3b,0x2a3d,0x0b,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x45}, + {0x3e,0x2a7f,0x0b,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x45}, + {0x3f,0x2a1b,0x0b,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x47}, /* 856x480 */ + {0x42,0x2a3d,0x0b,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x47}, + {0x45,0x2a7f,0x0b,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x47}, + {0x48,0x2a1b,0x0e,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x49}, /* 1360x768 */ + {0x4b,0x2a3d,0x0e,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x49}, + {0x4e,0x2a7f,0x0e,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x49}, + {0x4f,0x9a1f,0x00,0x0000,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25}, /* 320x200x32 */ + {0x53,0x9a1f,0x00,0x0000,SIS_RI_320x240, 0x00,0x00,0x04,0x04,0x26}, /* 320x240x32 */ + {0x54,0xba1f,0x01,0x0000,SIS_RI_400x300, 0x00,0x00,0x07,0x07,0x27}, /* 400x300x32 */ + {0x5f,0x2a1b,0x0f,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4a}, /* 768x576x8 */ + {0x60,0x2a1d,0x0f,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4a}, /* 768x576x16 */ + {0x61,0x2a1f,0x0f,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4a}, /* 768x576x32 */ + {0xff,0x0000,0x00,0x0000,0, 0x00,0x00,0x00,0x00,0x00} }; typedef struct _SiS310_Ext2Struct { USHORT Ext_InfoFlag; - UCHAR Ext_CRT1CRTC; - UCHAR Ext_CRTVCLK; - UCHAR Ext_CRT2CRTC; + UCHAR Ext_CRT1CRTC; + UCHAR Ext_CRTVCLK; + UCHAR Ext_CRT2CRTC; UCHAR ModeID; USHORT XRes; USHORT YRes; - USHORT ROM_OFFSET; + UCHAR Ext_PDC; } SiS310_Ext2Struct; static const SiS310_Ext2Struct SiS310_RefIndex[]= { -/* {0x005f,0x0d,0x03,0x05,0x6a, 800, 600,0x3a81}, 0x0 - TW: Patch for Chrontel 7019 */ - {0x085f,0x0d,0x03,0x05,0x6a, 800, 600,0x3a81}, /* 0x0 */ - {0x0467,0x0e,0x04,0x05,0x6a, 800, 600,0x3a86}, /* 0x1 */ - {0x0067,0x0f,0x08,0x48,0x6a, 800, 600,0x3a8b}, /* 0x2 */ - {0x0067,0x10,0x07,0x8b,0x6a, 800, 600,0x3a90}, /* 0x3 */ - {0x0147,0x11,0x0a,0x00,0x6a, 800, 600,0x3a95}, /* 0x4 */ - {0x0147,0x12,0x0d,0x00,0x6a, 800, 600,0x3a9a}, /* 0x5 - 4147 TW: Test sync change */ - {0x0047,0x13,0x13,0x00,0x6a, 800, 600,0x3a9f}, /* 0x6 - 4047 */ - {0x0047,0x14,0x1c,0x00,0x6a, 800, 600,0x3aa4}, /* 0x7 - 4047 */ -/* {0xc05f,0x05,0x00,0x04,0x2e, 640, 480,0x3a57}, 0x8 - TW: Patch for Chrontel 7019 */ - {0xc85f,0x05,0x00,0x04,0x2e, 640, 480,0x3a57}, /* 0x8 */ - {0xc067,0x06,0x02,0x04,0x2e, 640, 480,0x3a5c}, /* 0x9 */ - {0xc067,0x07,0x02,0x47,0x2e, 640, 480,0x3a61}, /* 0xa */ - {0xc067,0x08,0x03,0x8a,0x2e, 640, 480,0x3a66}, /* 0xb */ - {0xc047,0x09,0x05,0x00,0x2e, 640, 480,0x3a6b}, /* 0xc - 4047 */ - {0xc047,0x0a,0x09,0x00,0x2e, 640, 480,0x3a70}, /* 0xd - 4047 */ - {0xc047,0x0b,0x0e,0x00,0x2e, 640, 480,0x3a75}, /* 0xe - 4047 */ - {0xc047,0x0c,0x15,0x00,0x2e, 640, 480,0x3a7a}, /* 0xf */ - {0x407f,0x04,0x00,0x00,0x2f, 640, 400,0x3a50}, /* 0x10 */ - {0xc00f,0x3c,0x01,0x06,0x31, 720, 480,0x3b85}, /* 0x11 */ - {0x000f,0x3d,0x03,0x06,0x32, 720, 576,0x3b8c}, /* 0x12 */ - {0x0187,0x15,0x06,0x00,0x37,1024, 768,0x3aab}, /* 0x13 */ - {0xc877,0x16,0x0b,0x06,0x37,1024, 768,0x3ab0}, /* 0x14 */ - {0xc067,0x17,0x0f,0x49,0x37,1024, 768,0x3ab5}, /* 0x15 */ - {0x0267,0x18,0x11,0x00,0x37,1024, 768,0x3aba}, /* 0x16 */ - {0x0047,0x19,0x16,0x8c,0x37,1024, 768,0x3abf}, /* 0x17 */ - {0x0047,0x1a,0x1b,0x00,0x37,1024, 768,0x3ac4}, /* 0x18 - 4047 */ - {0x0007,0x1b,0x1f,0x00,0x37,1024, 768,0x3ac9}, /* 0x19 - 4047 */ - {0x0387,0x1c,0x11,0x00,0x3a,1280,1024,0x3adc}, /* 0x1a */ - {0x0077,0x1d,0x19,0x07,0x3a,1280,1024,0x3ae1}, /* 0x1b */ - {0x0047,0x1e,0x1e,0x00,0x3a,1280,1024,0x3ae6}, /* 0x1c */ - {0x0007,0x1f,0x20,0x00,0x3a,1280,1024,0x3aeb}, /* 0x1d */ - {0x0027,0x20,0x21,0x09,0x3c,1600,1200,0x3af2}, /* 0x1e */ - {0x0007,0x21,0x22,0x00,0x3c,1600,1200,0x3af7}, /* 0x1f */ - {0x0007,0x22,0x23,0x00,0x3c,1600,1200,0x3afc}, /* 0x20 */ - {0x0007,0x23,0x25,0x00,0x3c,1600,1200,0x3b01}, /* 0x21 */ - {0x0007,0x24,0x26,0x00,0x3c,1600,1200,0x3b06}, /* 0x22 */ - {0x0007,0x25,0x2c,0x00,0x3c,1600,1200,0x3b0b}, /* 0x23 */ - {0x0007,0x26,0x34,0x00,0x3c,1600,1200,0x3b10}, /* 0x24 */ - {0x407f,0x00,0x00,0x00,0x40, 320, 200,0x3a34}, /* 0x25 */ - {0xc07f,0x01,0x00,0x04,0x50, 320, 240,0x3a3b}, /* 0x26 */ - {0x007f,0x02,0x04,0x05,0x51, 400, 300,0x3a42}, /* 0x27 */ - {0xc077,0x03,0x0b,0x06,0x52, 512, 384,0x3a49}, /* 0x28 */ - {0x8007,0x27,0x27,0x00,0x68,1920,1440,0x3b17}, /* 0x29 */ - {0x4007,0x28,0x29,0x00,0x68,1920,1440,0x3b1c}, /* 0x2a */ - {0x4007,0x29,0x2e,0x00,0x68,1920,1440,0x3b21}, /* 0x2b */ - {0x4007,0x2a,0x30,0x00,0x68,1920,1440,0x3b26}, /* 0x2c */ - {0x4007,0x2b,0x35,0x00,0x68,1920,1440,0x3b2b}, /* 0x2d */ - {0x4005,0x2c,0x39,0x00,0x68,1920,1440,0x3b30}, /* 0x2e */ - {0x4007,0x2d,0x2b,0x00,0x6c,2048,1536,0x3b37}, /* 0x2f */ - {0x4007,0x2e,0x31,0x00,0x6c,2048,1536,0x3b3c}, /* 0x30 */ - {0x4007,0x2f,0x33,0x00,0x6c,2048,1536,0x3b41}, /* 0x31 */ - {0x4007,0x30,0x37,0x00,0x6c,2048,1536,0x3b46}, /* 0x32 */ - {0x4005,0x31,0x38,0x00,0x6c,2048,1536,0x3b4b}, /* 0x33 */ - {0x0057,0x32,0x40,0x08,0x70, 800, 480,0x3b52}, /* 0x34 */ - {0x0047,0x33,0x07,0x08,0x70, 800, 480,0x3b57}, /* 0x35 */ - {0x0047,0x34,0x0a,0x08,0x70, 800, 480,0x3b5c}, /* 0x36 */ - {0x0057,0x35,0x0b,0x09,0x71,1024, 576,0x3b63}, /* 0x37 */ - {0x0047,0x36,0x11,0x09,0x71,1024, 576,0x3b68}, /* 0x38 */ - {0x0047,0x37,0x16,0x09,0x71,1024, 576,0x3b6d}, /* 0x39 */ - {0x0057,0x38,0x19,0x0a,0x75,1280, 720,0x3b74}, /* 0x3a */ - {0x0047,0x39,0x1e,0x0a,0x75,1280, 720,0x3b79}, /* 0x3b */ - {0x0007,0x3a,0x20,0x0a,0x75,1280, 720,0x3b7e}, /* 0x3c */ - {0x0067,0x3b,0x19,0x08,0x7c,1280, 960,0x3ad0}, /* 0x3d */ - {0x0027,0x4c,0x59,0x08,0x7c,1280, 960,0x3ad0}, /* 0x3e */ - {0xc07f,0x01,0x00,0x06,0x5a, 320, 480,0x3b83}, /* 0x3f */ /* FSTN mode */ - {0x0077,0x42,0x12,0x08,0x23,1280, 768,0x0000}, /* 0x40 */ - {0x0067,0x43,0x4d,0x08,0x26,1400,1050,0x0000}, /* 0x41 */ - {0x0007,0x4b,0x5a,0x08,0x26,1400,1050,0x0000}, /* 0x42 */ /* TW: new, not in any BIOS */ - {0x0047,0x44,0x19,0x00,0x29,1152, 864,0x0000}, /* 0x43 TW: Non-BIOS, new */ - {0x0047,0x4a,0x1e,0x00,0x29,1152, 864,0x0000}, /* 0x44 TW: Non-BIOS, new */ - {0x00c7,0x45,0x57,0x00,0x39, 848, 480,0x0000}, /* 0x45 TW: 848x480-38Hzi - Non-BIOS, new */ - {0xc047,0x46,0x55,0x00,0x39, 848, 480,0x0000}, /* 0x46 TW: 848x480-60Hz - Non-BIOS, new */ - {0x00c7,0x47,0x57,0x00,0x3f, 856, 480,0x0000}, /* 0x47 TW: 856x480-38Hzi - Non-BIOS, new */ - {0xc047,0x48,0x57,0x00,0x3f, 856, 480,0x0000}, /* 0x48 TW: 856x480-60Hz - Non-BIOS, new */ - {0x0047,0x49,0x58,0x00,0x48,1360, 768,0x0000}, /* 0x49 TW: 1360x768-60Hz - Non-BIOS, new */ - {0xffff,0x00,0x00,0x00,0x00, 0, 0,0x0000} -}; + {0x085f,0x0d,0x03,0x05,0x6a, 800, 600, 0x40}, /* 0x0 */ + {0x0067,0x0e,0x04,0x05,0x6a, 800, 600, 0x40}, /* 0x1 */ + {0x0067,0x0f,0x08,0x48,0x6a, 800, 600, 0x40}, /* 0x2 */ + {0x0067,0x10,0x07,0x8b,0x6a, 800, 600, 0x40}, /* 0x3 */ + {0x0047,0x11,0x0a,0x00,0x6a, 800, 600, 0x40}, /* 0x4 */ + {0x0047,0x12,0x0d,0x00,0x6a, 800, 600, 0x40}, /* 0x5 */ + {0x0047,0x13,0x13,0x00,0x6a, 800, 600, 0x20}, /* 0x6 */ + {0x0107,0x14,0x1c,0x00,0x6a, 800, 600, 0x20}, /* 0x7 */ + {0xc85f,0x05,0x00,0x04,0x2e, 640, 480, 0x40}, /* 0x8 */ + {0xc067,0x06,0x02,0x04,0x2e, 640, 480, 0x40}, /* 0x9 */ + {0xc067,0x07,0x02,0x47,0x2e, 640, 480, 0x40}, /* 0xa */ + {0xc067,0x08,0x03,0x8a,0x2e, 640, 480, 0x40}, /* 0xb */ + {0xc047,0x09,0x05,0x00,0x2e, 640, 480, 0x40}, /* 0xc */ + {0xc047,0x0a,0x09,0x00,0x2e, 640, 480, 0x40}, /* 0xd */ + {0xc047,0x0b,0x0e,0x00,0x2e, 640, 480, 0x40}, /* 0xe */ + {0xc047,0x0c,0x15,0x00,0x2e, 640, 480, 0x40}, /* 0xf */ + {0x487f,0x04,0x00,0x00,0x2f, 640, 400, 0x30}, /* 0x10 */ + {0xc04f,0x3c,0x01,0x06,0x31, 720, 480, 0x30}, /* 0x11 */ + {0x004f,0x3d,0x03,0x06,0x32, 720, 576, 0x30}, /* 0x12 */ + {0x0087,0x15,0x06,0x00,0x37,1024, 768, 0x30}, /* 0x13 */ + {0xc877,0x16,0x0b,0x06,0x37,1024, 768, 0x20}, /* 0x14 */ + {0xc067,0x17,0x0f,0x49,0x37,1024, 768, 0x20}, /* 0x15 */ + {0x0067,0x18,0x11,0x00,0x37,1024, 768, 0x20}, /* 0x16 */ + {0x0047,0x19,0x16,0x8c,0x37,1024, 768, 0x20}, /* 0x17 */ + {0x0107,0x1a,0x1b,0x00,0x37,1024, 768, 0x10}, /* 0x18 */ + {0x0107,0x1b,0x1f,0x00,0x37,1024, 768, 0x10}, /* 0x19 */ + {0x0087,0x1c,0x11,0x00,0x3a,1280,1024, 0x30}, /* 0x1a */ + {0x0137,0x1d,0x19,0x07,0x3a,1280,1024, 0x00}, /* 0x1b */ + {0x0107,0x1e,0x1e,0x00,0x3a,1280,1024, 0x00}, /* 0x1c */ + {0x0207,0x1f,0x20,0x00,0x3a,1280,1024, 0x00}, /* 0x1d */ + {0x0227,0x20,0x21,0x09,0x3c,1600,1200, 0x00}, /* 0x1e */ + {0x0407,0x21,0x22,0x00,0x3c,1600,1200, 0x00}, /* 0x1f */ + {0x0407,0x22,0x23,0x00,0x3c,1600,1200, 0x00}, /* 0x20 */ + {0x0407,0x23,0x25,0x00,0x3c,1600,1200, 0x00}, /* 0x21 */ + {0x0007,0x24,0x26,0x00,0x3c,1600,1200, 0x00}, /* 0x22 */ + {0x0007,0x25,0x2c,0x00,0x3c,1600,1200, 0x00}, /* 0x23 */ + {0x0007,0x26,0x34,0x00,0x3c,1600,1200, 0x00}, /* 0x24 */ + {0x407f,0x00,0x00,0x00,0x40, 320, 200, 0x30}, /* 0x25 */ + {0xc07f,0x01,0x00,0x04,0x50, 320, 240, 0x30}, /* 0x26 */ + {0x007f,0x02,0x04,0x05,0x51, 400, 300, 0x30}, /* 0x27 */ + {0xc077,0x03,0x0b,0x06,0x52, 512, 384, 0x30}, /* 0x28 */ + {0x8007,0x27,0x27,0x00,0x68,1920,1440, 0x00}, /* 0x29 */ + {0x4007,0x28,0x29,0x00,0x68,1920,1440, 0x00}, /* 0x2a */ + {0x4007,0x29,0x2e,0x00,0x68,1920,1440, 0x00}, /* 0x2b */ + {0x4007,0x2a,0x30,0x00,0x68,1920,1440, 0x00}, /* 0x2c */ + {0x4007,0x2b,0x35,0x00,0x68,1920,1440, 0x00}, /* 0x2d */ + {0x4005,0x2c,0x39,0x00,0x68,1920,1440, 0x00}, /* 0x2e */ + {0x4007,0x2d,0x2b,0x00,0x6c,2048,1536, 0x00}, /* 0x2f */ + {0x4007,0x2e,0x31,0x00,0x6c,2048,1536, 0x00}, /* 0x30 */ + {0x4007,0x2f,0x33,0x00,0x6c,2048,1536, 0x00}, /* 0x31 */ + {0x4007,0x30,0x37,0x00,0x6c,2048,1536, 0x00}, /* 0x32 */ + {0x4005,0x31,0x38,0x00,0x6c,2048,1536, 0x00}, /* 0x33 */ + {0x0057,0x32,0x40,0x08,0x70, 800, 480, 0x30}, /* 0x34 */ + {0x0047,0x33,0x07,0x08,0x70, 800, 480, 0x30}, /* 0x35 */ + {0x0047,0x34,0x0a,0x08,0x70, 800, 480, 0x30}, /* 0x36 */ + {0x0057,0x35,0x0b,0x09,0x71,1024, 576, 0x30}, /* 0x37 */ + {0x0047,0x36,0x11,0x09,0x71,1024, 576, 0x30}, /* 0x38 */ + {0x0047,0x37,0x16,0x09,0x71,1024, 576, 0x30}, /* 0x39 */ + {0x0117,0x38,0x19,0x0a,0x75,1280, 720, 0x30}, /* 0x3a */ + {0x0107,0x39,0x1e,0x0a,0x75,1280, 720, 0x30}, /* 0x3b */ + {0x0207,0x3a,0x20,0x0a,0x75,1280, 720, 0x30}, /* 0x3c */ + {0x0127,0x3b,0x19,0x08,0x7c,1280, 960, 0x30}, /* 0x3d */ + {0x0227,0x4c,0x59,0x08,0x7c,1280, 960, 0x20}, /* 0x3e */ + {0xc07f,0x4e,0x00,0x06,0x5a, 320, 240, 0x30}, /* 0x3f */ /* FSTN 320x240 */ + {0x0077,0x42,0x5b,0x08,0x23,1280, 768, 0x30}, /* 0x40 */ /* TW: 0x5b was 0x12 */ + {0x0127,0x43,0x4d,0x08,0x26,1400,1050, 0x30}, /* 0x41 */ + {0x0207,0x4b,0x5a,0x08,0x26,1400,1050, 0x30}, /* 0x42 Non-BIOS, new */ + {0x0107,0x44,0x19,0x00,0x29,1152, 864, 0x30}, /* 0x43 Non-BIOS, new */ + {0x0107,0x4a,0x1e,0x00,0x29,1152, 864, 0x30}, /* 0x44 Non-BIOS, new */ + {0x0087,0x45,0x57,0x00,0x39, 848, 480, 0x30}, /* 0x45 848x480-38Hzi - Non-BIOS, new */ + {0xc067,0x46,0x55,0x0b,0x39, 848, 480, 0x30}, /* 0x46 848x480-60Hz - Non-BIOS, new */ + {0x0087,0x47,0x57,0x00,0x3f, 856, 480, 0x30}, /* 0x47 856x480-38Hzi - Non-BIOS, new */ + {0xc047,0x48,0x57,0x00,0x3f, 856, 480, 0x30}, /* 0x48 856x480-60Hz - Non-BIOS, new */ + {0x0067,0x49,0x58,0x0c,0x48,1360, 768, 0x30}, /* 0x49 1360x768-60Hz - Non-BIOS, new */ + {0x004f,0x4d,0x03,0x06,0x5f, 768, 576, 0x30}, /* 0x4a 768x576 */ + {0xffff,0x00,0x00,0x00,0x00, 0, 0, 0} +}; typedef struct _SiS310_CRT1TableStruct { @@ -710,7 +306,7 @@ static const SiS310_CRT1TableStruct SiS3 {{0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x05, 0x00}}, /* 0x4 */ -#if 0 +#if 0 {{0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x05, 0x00}}, /* 0x5 */ @@ -914,36 +510,41 @@ static const SiS310_CRT1TableStruct SiS3 {{0xe6,0xae,0xae,0x8a,0xbd,0x90,0x3d,0x10, 0x1a,0x8d,0x19,0x19,0x3e,0x2f,0x00,0x03, 0x00}}, /* 0x43 */ - {{0xc3,0x8f,0x8f,0x87,0x9b,0x0b,0x82,0xef, /* TW: New, 1152x864-75, not in any BIOS */ + {{0xc3,0x8f,0x8f,0x87,0x9b,0x0b,0x82,0xef, /* New, 1152x864-75, not in BIOS */ 0x60,0x83,0x5f,0x5f,0x83,0x10,0x00,0x07, 0x01}}, /* 0x44 */ - {{0x86,0x69,0x69,0x8A,0x74,0x06,0x8C,0x15, /* TW: New, 848x480-38i, not in BIOS */ + {{0x86,0x69,0x69,0x8A,0x74,0x06,0x8C,0x15, /* New, 848x480-38i, not in BIOS */ 0x4F,0x83,0xEF,0xEF,0x8D,0x30,0x00,0x02, 0x00}}, /* 0x45 */ - {{0x83,0x69,0x69,0x87,0x6f,0x1d,0x03,0x3E, /* TW: New, 848x480-60, not in BIOS */ + {{0x83,0x69,0x69,0x87,0x6f,0x1d,0x03,0x3E, /* New, 848x480-60, not in BIOS */ 0xE5,0x8d,0xDF,0xe4,0x04,0x00,0x00,0x06, 0x00}}, /* 0x46 */ - {{0x86,0x6A,0x6A,0x8A,0x74,0x06,0x8C,0x15, /* TW: New, 856x480-38i, not in BIOS */ + {{0x86,0x6A,0x6A,0x8A,0x74,0x06,0x8C,0x15, /* New, 856x480-38i, not in BIOS */ 0x4F,0x83,0xEF,0xEF,0x8D,0x30,0x00,0x02, 0x00}}, /* 0x47 */ - {{0x81,0x6A,0x6A,0x85,0x70,0x00,0x0F,0x3E, /* TW: New, 856x480-60, not in BIOS */ + {{0x81,0x6A,0x6A,0x85,0x70,0x00,0x0F,0x3E, /* New, 856x480-60, not in BIOS */ 0xEB,0x8E,0xDF,0xDF,0x10,0x00,0x00,0x02, 0x00}}, /* 0x48 */ - {{0xdd,0xa9,0xa9,0x81,0xb4,0x97,0x26,0xfd, /* TW: New, 1360x768-60, not in BIOS */ + {{0xdd,0xa9,0xa9,0x81,0xb4,0x97,0x26,0xfd, /* New, 1360x768-60, not in BIOS */ 0x01,0x8d,0xff,0x00,0x27,0x10,0x00,0x03, 0x01}}, /* 0x49 */ - {{0xd9,0x8f,0x8f,0x9d,0xba,0x0a,0x8a,0xff, /* TW: New, 1152x864-84, not in any BIOS */ + {{0xd9,0x8f,0x8f,0x9d,0xba,0x0a,0x8a,0xff, /* New, 1152x864-84, not in any BIOS */ 0x60,0x8b,0x5f,0x5f,0x8b,0x10,0x00,0x03, 0x01}}, /* 0x4a */ - {{0xea,0xae,0xae,0x8e,0xba,0x82,0x40,0x10, /* TW: New, 1400x1050-75, not in any BIOS */ + {{0xea,0xae,0xae,0x8e,0xba,0x82,0x40,0x10, /* New, 1400x1050-75, not in any BIOS */ 0x1b,0x87,0x19,0x1a,0x41,0x0f,0x00,0x03, - 0x00}}, /* 0x4b */ - {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0xf1,0xff, /* TW: New, 1280x960-85, not in any BIOS */ + 0x00}}, /* 0x4b */ + {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0xf1,0xff, /* New, 1280x960-85, not in any BIOS */ 0xc0,0x83,0xbf,0xbf,0xf2,0x10,0x00,0x07, - 0x01}} /* 0x4c */ + 0x01}}, /* 0x4c */ + {{0x7b,0x5f,0x63,0x9f,0x6a,0x93,0x6f,0xf0, /* 768x576 */ + 0x58,0x8a,0x3f,0x57,0x70,0x20,0x00,0x05, + 0x01}}, /* 0x4d */ + {{0x2d,0x27,0x28,0x90,0x2c,0x80,0x0b,0x3e, /* FSTN 320x480, TEMP - possibly invalid */ + 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x00, + 0x00}} /* 0x4e */ }; - typedef struct _SiS310_MCLKDataStruct { UCHAR SR28,SR29,SR2A; @@ -952,7 +553,7 @@ typedef struct _SiS310_MCLKDataStruct static const SiS310_MCLKDataStruct SiS310_MCLKData_0_315[] = { - { 0x3b,0x22,0x01,143}, /* TW: Was { 0x5c,0x23,0x01,166}, */ + { 0x3b,0x22,0x01,143}, { 0x5c,0x23,0x01,166}, { 0x5c,0x23,0x01,166}, { 0x5c,0x23,0x01,166}, @@ -962,7 +563,7 @@ static const SiS310_MCLKDataStruct SiS31 { 0x5c,0x23,0x01,166} }; -static const SiS310_MCLKDataStruct SiS310_MCLKData_0_650[] = /* @ 0x54 */ +static const SiS310_MCLKDataStruct SiS310_MCLKData_0_650[] = { { 0x5a,0x64,0x82, 66}, { 0xb3,0x45,0x82, 83}, @@ -974,7 +575,7 @@ static const SiS310_MCLKDataStruct SiS31 { 0x37,0x22,0x82,133} }; -static const SiS310_MCLKDataStruct SiS310_MCLKData_0_330[] = /* @ 0x54 */ +static const SiS310_MCLKDataStruct SiS310_MCLKData_0_330[] = { { 0x5c,0x23,0x01,166}, { 0x5c,0x23,0x01,166}, @@ -986,7 +587,19 @@ static const SiS310_MCLKDataStruct SiS31 { 0x79,0x06,0x01,250} }; -static const SiS310_MCLKDataStruct SiS310_MCLKData_1[] = /* @ 0x155 */ +static const SiS310_MCLKDataStruct SiS310_MCLKData_0_660[] = /* TODO */ +{ + { 0x5c,0x23,0x82,166}, + { 0x5c,0x23,0x82,166}, + { 0x37,0x21,0x82,200}, + { 0x37,0x22,0x82,133}, + { 0x29,0x21,0x82,150}, + { 0x5c,0x23,0x82,166}, + { 0x65,0x23,0x82,183}, + { 0x37,0x21,0x82,200} +}; + +static const SiS310_MCLKDataStruct SiS310_MCLKData_1[] = { { 0x29,0x21,0x82,150}, { 0x5c,0x23,0x82,166}, @@ -998,20 +611,6 @@ static const SiS310_MCLKDataStruct SiS31 { 0x37,0x22,0x82,133} }; -typedef struct _SiS310_ECLKDataStruct -{ - UCHAR SR2E,SR2F,SR30; - USHORT CLOCK; -} SiS310_ECLKDataStruct; - -static const SiS310_ECLKDataStruct SiS310_ECLKData[]= -{ - { 0x5c,0x23,0x01,166}, - { 0x5c,0x23,0x01,166}, - { 0x5c,0x23,0x01,166}, - { 0x5c,0x23,0x01,166} -}; - typedef struct _SiS310_VCLKDataStruct { UCHAR SR2B,SR2C; @@ -1020,22 +619,22 @@ typedef struct _SiS310_VCLKDataStruct static const SiS310_VCLKDataStruct SiS310_VCLKData[]= { - { 0x1b,0xe1, 25}, /* 0x0 */ /* 650/LVDS BIOS: @ 0x5647 */ - { 0x4e,0xe4, 28}, /* 0x1 */ - { 0x57,0xe4, 31}, /* 0x2 */ - { 0xc3,0xc8, 36}, /* 0x3 */ - { 0x42,0xe2, 40}, /* 0x4 */ - { 0xfe,0xcd, 43}, /* 0x5 */ - { 0x5d,0xc4, 44}, /* 0x6 */ - { 0x52,0xe2, 49}, /* 0x7 */ - { 0x53,0xe2, 50}, /* 0x8 */ - { 0x74,0x67, 52}, /* 0x9 */ - { 0x6d,0x66, 56}, /* 0xa */ - { 0x5a,0x64, 65}, /* 0xb */ /* TW: was 6c c3 - WRONG */ - { 0x46,0x44, 67}, /* 0xc */ - { 0xb1,0x46, 68}, /* 0xd */ - { 0xd3,0x4a, 72}, /* 0xe */ - { 0x29,0x61, 75}, /* 0xf */ + { 0x1b,0xe1, 25}, /* 0x00 */ + { 0x4e,0xe4, 28}, /* 0x01 */ + { 0x57,0xe4, 31}, /* 0x02 */ + { 0xc3,0xc8, 36}, /* 0x03 */ + { 0x42,0xe2, 40}, /* 0x04 */ + { 0xfe,0xcd, 43}, /* 0x05 */ + { 0x5d,0xc4, 44}, /* 0x06 */ + { 0x52,0xe2, 49}, /* 0x07 */ + { 0x53,0xe2, 50}, /* 0x08 */ + { 0x74,0x67, 52}, /* 0x09 */ + { 0x6d,0x66, 56}, /* 0x0a */ + { 0x5a,0x64, 65}, /* 0x0b */ /* TW: was 6c c3 - WRONG */ + { 0x46,0x44, 67}, /* 0x0c */ + { 0xb1,0x46, 68}, /* 0x0d */ + { 0xd3,0x4a, 72}, /* 0x0e */ + { 0x29,0x61, 75}, /* 0x0f */ { 0x6e,0x46, 76}, /* 0x10 */ { 0x2b,0x61, 78}, /* 0x11 */ { 0x31,0x42, 79}, /* 0x12 */ @@ -1078,12 +677,12 @@ static const SiS310_VCLKDataStruct SiS31 { 0xea,0x08,340}, /* 0x37 */ { 0xe8,0x07,376}, /* 0x38 */ { 0xde,0x06,389}, /* 0x39 */ - { 0x52,0x2a, 54}, /* 0x3a */ - { 0x52,0x6a, 27}, /* 0x3b */ - { 0x62,0x24, 70}, /* 0x3c */ - { 0x62,0x64, 70}, /* 0x3d */ - { 0xa8,0x4c, 30}, /* 0x3e */ - { 0x20,0x26, 33}, /* 0x3f */ + { 0x52,0x2a, 54}, /* 0x3a */ /* 301 TV */ + { 0x52,0x6a, 27}, /* 0x3b */ /* 301 TV */ + { 0x62,0x24, 70}, /* 0x3c */ /* 301 TV */ + { 0x62,0x64, 70}, /* 0x3d */ /* 301 TV */ + { 0xa8,0x4c, 30}, /* 0x3e */ /* 301 TV */ + { 0x20,0x26, 33}, /* 0x3f */ /* 301 TV */ { 0x31,0xc2, 39}, /* 0x40 */ { 0x60,0x36, 30}, /* 0x41 */ /* Chrontel */ { 0x40,0x4a, 28}, /* 0x42 */ /* Chrontel */ @@ -1096,7 +695,7 @@ static const SiS310_VCLKDataStruct SiS31 { 0xce,0x3c, 39}, /* 0x49 */ { 0x52,0x4a, 36}, /* 0x4a */ /* Chrontel */ { 0x34,0x61, 95}, /* 0x4b */ - { 0x78,0x27,108}, /* 0x4c - was 102 */ /* TW: Last entry in 650/301 BIOS */ + { 0x78,0x27,108}, /* 0x4c - was 102 */ { 0x66,0x43,123}, /* 0x4d */ /* Modes 0x26-0x28 (1400x1050) */ { 0x41,0x4e, 21}, /* 0x4e */ { 0xa1,0x4a, 29}, /* 0x4f */ /* Chrontel */ @@ -1110,7 +709,8 @@ static const SiS310_VCLKDataStruct SiS31 { 0xbf,0xc8, 35}, /* 0x57 - added for 856x480-38i,60 (not in any BIOS) */ { 0x30,0x23, 88}, /* 0x58 - added for 1360x768-62 (is 60Hz!) (not in any BIOS) */ { 0x52,0x07,149}, /* 0x59 - added for 1280x960-85 (Not in any BIOS) */ - { 0x56,0x07,156} /* 0x5a - added for 1400x1050-75 */ + { 0x56,0x07,156}, /* 0x5a - added for 1400x1050-75 */ + { 0x70,0x29, 81} /* 0x5b - added for 1280x768 LCD */ }; typedef struct _SiS310_VBVCLKDataStruct @@ -1121,22 +721,22 @@ typedef struct _SiS310_VBVCLKDataStruct static const SiS310_VBVCLKDataStruct SiS310_VBVCLKData[]= { - { 0x1b,0xe1, 25}, /* 0x0 */ /* 650/LVDS BIOS: @ 0x579c */ - { 0x4e,0xe4, 28}, /* 0x1 */ - { 0x57,0xe4, 31}, /* 0x2 */ - { 0xc3,0xc8, 36}, /* 0x3 */ - { 0x42,0x47, 40}, /* 0x4 */ - { 0xfe,0xcd, 43}, /* 0x5 */ - { 0x5d,0xc4, 44}, /* 0x6 */ - { 0x52,0x47, 49}, /* 0x7 */ - { 0x53,0x47, 50}, /* 0x8 */ - { 0x74,0x67, 52}, /* 0x9 */ - { 0x6d,0x66, 56}, /* 0xa */ - { 0x35,0x62, 65}, /* 0xb */ /* Was 0x5a,0x64 - 650/LVDS+301 bios: 35,62 */ - { 0x46,0x44, 67}, /* 0xc */ - { 0xb1,0x46, 68}, /* 0xd */ - { 0xd3,0x4a, 72}, /* 0xe */ - { 0x29,0x61, 75}, /* 0xf */ + { 0x1b,0xe1, 25}, /* 0x00 */ + { 0x4e,0xe4, 28}, /* 0x01 */ + { 0x57,0xe4, 31}, /* 0x02 */ + { 0xc3,0xc8, 36}, /* 0x03 */ + { 0x42,0x47, 40}, /* 0x04 */ + { 0xfe,0xcd, 43}, /* 0x05 */ + { 0x5d,0xc4, 44}, /* 0x06 */ + { 0x52,0x47, 49}, /* 0x07 */ + { 0x53,0x47, 50}, /* 0x08 */ + { 0x74,0x67, 52}, /* 0x09 */ + { 0x6d,0x66, 56}, /* 0x0a */ + { 0x35,0x62, 65}, /* 0x0b */ /* Was 0x5a,0x64 - 650/LVDS+301 bios: 35,62 */ + { 0x46,0x44, 67}, /* 0x0c */ + { 0xb1,0x46, 68}, /* 0x0d */ + { 0xd3,0x4a, 72}, /* 0x0e */ + { 0x29,0x61, 75}, /* 0x0f */ { 0x6d,0x46, 75}, /* 0x10 */ { 0x41,0x43, 78}, /* 0x11 */ { 0x31,0x42, 79}, /* 0x12 */ @@ -1146,15 +746,21 @@ static const SiS310_VBVCLKDataStruct SiS { 0x62,0x44, 94}, /* 0x16 */ { 0x2b,0x22,104}, /* 0x17 */ { 0x49,0x24,105}, /* 0x18 */ - { 0xf8,0x2f,108}, /* 0x19 */ + { 0xf8,0x2f,108}, /* 0x19 */ /* 1400x1050 LCD */ { 0x3c,0x23,109}, /* 0x1a */ { 0x5e,0x43,113}, /* 0x1b */ { 0xbc,0x44,116}, /* 0x1c */ { 0xe0,0x46,132}, /* 0x1d */ +#if 0 { 0xd4,0x28,135}, /* 0x1e */ { 0xea,0x2a,139}, /* 0x1f */ { 0x41,0x22,157}, /* 0x20 */ { 0x70,0x24,162}, /* 0x21 */ +#endif + { 0xe2,0x46,135}, /* 0x1e */ /* 1280x1024-75, better clock for VGA2 */ + { 0xe5,0x46,139}, /* 0x1f */ /* 1024x768-120, better clock for VGA2 */ + { 0x15,0x01,157}, /* 0x20 */ /* 1280x1024-85, better clock for VGA2 */ + { 0x70,0x09,162}, /* 0x21 */ /* 1600x1200-60, better clock for VGA2 */ { 0x30,0x21,175}, /* 0x22 */ { 0x4e,0x22,189}, /* 0x23 */ { 0xde,0x26,194}, /* 0x24 */ @@ -1179,19 +785,19 @@ static const SiS310_VBVCLKDataStruct SiS { 0xea,0x08,340}, /* 0x37 */ { 0xe8,0x07,376}, /* 0x38 */ { 0xde,0x06,389}, /* 0x39 */ - { 0x52,0x2a, 54}, /* 0x3a */ - { 0x52,0x6a, 27}, /* 0x3b */ - { 0x62,0x24, 70}, /* 0x3c */ - { 0x62,0x64, 70}, /* 0x3d */ - { 0xa8,0x4c, 30}, /* 0x3e */ - { 0x20,0x26, 33}, /* 0x3f */ + { 0x52,0x2a, 54}, /* 0x3a */ /* 301 TV */ + { 0x52,0x6a, 27}, /* 0x3b */ /* 301 TV */ + { 0x62,0x24, 70}, /* 0x3c */ /* 301 TV */ + { 0x62,0x64, 70}, /* 0x3d */ /* 301 TV */ + { 0xa8,0x4c, 30}, /* 0x3e */ /* 301 TV */ + { 0x20,0x26, 33}, /* 0x3f */ /* 301 TV */ { 0x31,0xc2, 39}, /* 0x40 */ - { 0x2e,0x48, 25}, /* 0x41 */ - { 0x24,0x46, 25}, /* 0x42 */ - { 0x26,0x64, 28}, /* 0x43 */ - { 0x37,0x64, 40}, /* 0x44 */ - { 0xa1,0x42,108}, /* 0x45 */ - { 0x37,0x61,100}, /* 0x46 */ + { 0x2e,0x48, 25}, /* 0x41 */ /* Replacement for LCD on 315 for index 0 */ + { 0x24,0x46, 25}, /* 0x42 */ /* Replacement for LCD on 315 for modes 0x01, 0x03, 0x0f, 0x10, 0x12 */ + { 0x26,0x64, 28}, /* 0x43 */ /* Replacement for LCD on 315 for index 1 */ + { 0x37,0x64, 40}, /* 0x44 */ /* Replacement for LCD on 315 for index 4 */ + { 0xa1,0x42,108}, /* 0x45 */ /* 1280x960 LCD */ + { 0x37,0x61,100}, /* 0x46 */ /* 1280x960 LCD */ { 0x78,0x27,108}, /* 0x47 */ { 0x97,0x2c, 26}, /* 0x48 */ /* UNUSED - Entries from here new, not in any BIOS */ { 0xce,0x3c, 39}, /* 0x49 */ /* UNUSED */ @@ -1210,74 +816,19 @@ static const SiS310_VBVCLKDataStruct SiS { 0x6a,0xc6, 37}, /* 0x56 */ /* 848x480-75 - TEMP, UNUSED */ { 0xbf,0xc8, 35}, /* 0x57 */ /* 856x480-38i,60 */ { 0x30,0x23, 88}, /* 0x58 */ /* 1360x768-62 (is 60Hz!) TEMP, UNUSED */ - { 0x52,0x07,149}, /* 0x59 */ /* 1280x960-85 - UNUSED */ - { 0x56,0x07,156} /* 0x5a */ /* 1400x1050-75 - UNUSED */ + { 0x52,0x07,149}, /* 0x59 */ /* 1280x960-85 */ + { 0x56,0x07,156}, /* 0x5a */ /* 1400x1050-75 */ + { 0x70,0x29, 81} /* 0x5b */ /* 1280x768 LCD */ }; -static const UCHAR SiS310_ScreenOffset[] = +static const UCHAR SiS310_ScreenOffset[] = { 0x14,0x19,0x20,0x28,0x32,0x40,0x50,0x64, - 0x78,0x80,0x2d,0x35,0x57,0x48,0x55, + 0x78,0x80,0x2d,0x35,0x57,0x48,0x55,0x30, 0xff -}; /* TW: Added 1400x1050, 1152x864, 848/856x480, 1360x768 */ - -typedef struct _SiS310_StResInfoStruct -{ - USHORT HTotal; - USHORT VTotal; -} SiS310_StResInfoStruct; - -static const SiS310_StResInfoStruct SiS310_StResInfo[]= -{ - { 640,400}, - { 640,350}, - { 720,400}, - { 720,350}, - { 640,480} -}; - -typedef struct _SiS310_ModeResInfoStruct -{ - USHORT HTotal; - USHORT VTotal; - UCHAR XChar; - UCHAR YChar; -} SiS310_ModeResInfoStruct; - -static const SiS310_ModeResInfoStruct SiS310_ModeResInfo[] = -{ - { 320, 200, 8, 8}, /* 0x00 */ - { 320, 240, 8, 8}, /* 0x01 */ - { 320, 400, 8, 8}, /* 0x02 */ - { 400, 300, 8, 8}, /* 0x03 */ - { 512, 384, 8, 8}, /* 0x04 */ - { 640, 400, 8,16}, /* 0x05 */ - { 640, 480, 8,16}, /* 0x06 */ - { 800, 600, 8,16}, /* 0x07 */ - { 1024, 768, 8,16}, /* 0x08 */ - { 1280,1024, 8,16}, /* 0x09 */ - { 1600,1200, 8,16}, /* 0x0a */ - { 1920,1440, 8,16}, /* 0x0b */ - { 2048,1536, 8,16}, /* 0x0c */ - { 720, 480, 8,16}, /* 0x0d */ - { 720, 576, 8,16}, /* 0x0e */ - { 1280, 960, 8,16}, /* 0x0f */ - { 800, 480, 8,16}, /* 0x10 */ - { 1024, 576, 8,16}, /* 0x11 */ - { 1280, 720, 8,16}, /* 0x12 */ - { 856, 480, 8,16}, /* 0x13 - TW: New, not in any BIOS */ - { 1280, 768, 8,16}, /* 0x14 20; TW: New */ - { 1400,1050, 8,16}, /* 0x15 21; TW: New */ - { 1152, 864, 8,16}, /* 0x16 - TW: New, not in any BIOS */ - { 848, 480, 8,16}, /* 0x17 - TW: New, not in any BIOS */ - { 1360, 768, 8,16} /* 0x18 - TW: New, not in any BIOS */ }; -static const UCHAR SiS310_OutputSelect = 0x40; - -static const UCHAR SiS310_SoftSetting = 0x30; /* TW: RAM setting */ - -static const UCHAR SiS310_SR15[8][4]={ +static const DRAM4Type SiS310_SR15[8] = { {0x00,0x04,0x60,0x60}, {0x0f,0x0f,0x0f,0x0f}, {0xba,0xba,0xba,0xba}, @@ -1292,7 +843,7 @@ static const UCHAR SiS310_SR15[8][4]={ static UCHAR SiS310_SR07 = 0x18; -static const UCHAR SiS310_CR40[5][4]={ +static const DRAM4Type SiS310_CR40[5] = { {0x77,0x77,0x33,0x33}, {0x77,0x77,0x33,0x33}, {0x00,0x00,0x00,0x00}, @@ -1322,15 +873,54 @@ static const USHORT SiS310_VideoSenseDat static const USHORT SiS310_YCSenseData2 = 0x016b; #endif -static const UCHAR SiS310_NTSCPhase[] = {0x21,0xed,0xba,0x08}; /* TW: Was {0x21,0xed,0x8a,0x08}; */ -static const UCHAR SiS310_PALPhase[] = {0x2a,0x05,0xe3,0x00}; /* TW: Was {0x2a,0x05,0xd3,0x00}; */ -static const UCHAR SiS310_PALMPhase[] = {0x21,0xE4,0x2E,0x9B}; /* TW: palm*/ -static const UCHAR SiS310_PALNPhase[] = {0x21,0xF4,0x3E,0xBA}; /* TW: paln*/ -static const UCHAR SiS310_NTSCPhase2[] = {0x21,0xF0,0x7B,0xD6}; -static const UCHAR SiS310_PALPhase2[] = {0x2a,0x09,0x86,0xe9}; -static const UCHAR SiS310_PALMPhase2[] = {0x21,0xE6,0xEF,0xA4}; /* TW: palm 301b*/ -static const UCHAR SiS310_PALNPhase2[] = {0x21,0xF6,0x94,0x46}; /* TW: paln 301b*/ -static const UCHAR SiS310_SpecialPhase[] = {0x1e,0x8c,0x5c,0x7a}; +typedef struct _SiS310_PanelDelayTblStruct +{ + UCHAR timer[2]; +} SiS310_PanelDelayTblStruct; + +static const SiS310_PanelDelayTblStruct SiS310_PanelDelayTbl[]= +{ + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}} +}; + +static const SiS310_PanelDelayTblStruct SiS310_PanelDelayTblLVDS[]= +{ + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}} +}; + +/**************************************************************/ +/* SIS VIDEO BRIDGE ----------------------------------------- */ +/**************************************************************/ typedef struct _SiS310_LCDDataStruct { @@ -1353,25 +943,6 @@ static const SiS310_LCDDataStruct SiS31 { 1, 1,1344, 806,1344, 806} }; -#if 0 /* Seems out-dated, all BIOSes since 03/27/2002 have the other version */ -static const SiS310_LCDDataStruct SiS310_ExtLCD1024x768Data[] = -{ - { 12, 5, 896, 512,1344, 806}, - { 12, 5, 896, 510,1344, 806}, - { 32, 15,1008, 505,1344, 806}, - { 32, 15,1008, 514,1344, 806}, - { 12, 5, 896, 500,1344, 806}, - { 42, 25,1024, 625,1344, 806}, - { 1, 1,1344, 806,1344, 806}, - { 12, 5, 896, 500,1344, 806}, - { 42, 25,1024, 625,1344, 806}, - { 1, 1,1344, 806,1344, 806}, - { 12, 5, 896, 500,1344, 806}, - { 42, 25,1024, 625,1344, 806}, - { 1, 1,1344, 806,1344, 806} -}; -#endif - static const SiS310_LCDDataStruct SiS310_ExtLCD1024x768Data[] = { { 42, 25,1536, 419,1344, 806}, @@ -1413,7 +984,7 @@ static const SiS310_LCDDataStruct SiS31 { 1, 1,1688,1066,1688,1066} }; -static const SiS310_LCDDataStruct SiS310_ExtLCD1280x1024Data[] = +static const SiS310_LCDDataStruct SiS310_ExtLCD1280x1024Data[] = { { 211, 60,1024, 501,1688,1066}, { 211, 60,1024, 508,1688,1066}, @@ -1450,7 +1021,7 @@ static const SiS310_LCDDataStruct SiS31 { 1, 1,1344, 806,1344, 806} }; -static const SiS310_LCDDataStruct SiS310_NoScaleData1280x1024[] = +static const SiS310_LCDDataStruct SiS310_NoScaleData1280x1024[] = { { 1, 1,1688,1066,1688,1066}, { 1, 1,1688,1066,1688,1066}, @@ -1463,829 +1034,796 @@ static const SiS310_LCDDataStruct SiS31 { 1, 1,1688,1066,1688,1066} }; -static const SiS310_LCDDataStruct SiS310_LCD1280x960Data[] = +typedef struct _SiS310_Part2PortTblStruct { - { 9, 2, 800, 500,1800,1000}, - { 9, 2, 800, 500,1800,1000}, - { 4, 1, 900, 500,1800,1000}, - { 4, 1, 900, 500,1800,1000}, - { 9, 2, 800, 500,1800,1000}, - { 30, 11,1056, 625,1800,1000}, - { 5, 3,1350, 800,1800,1000}, - { 1, 1,1576,1050,1576,1050}, - { 1, 1,1800,1000,1800,1000} -}; - -static const SiS310_LCDDataStruct SiS310_StLCD1400x1050Data[] = -{ /* TW: New from 1.11.6s */ - { 211, 100, 2100, 408, 1688, 1066 }, - { 211, 64, 1536, 358, 1688, 1066 }, - { 211, 100, 2100, 408, 1688, 1066 }, - { 211, 64, 1536, 358, 1688, 1066 }, - { 211, 48, 840, 488, 1688, 1066 }, - { 211, 72, 1008, 609, 1688, 1066 }, - { 211, 128, 1400, 776, 1688, 1066 }, - { 211, 205, 1680, 1041, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 } -}; - -static const SiS310_LCDDataStruct SiS310_ExtLCD1400x1050Data[] = -{ /* TW: New from 1.11.6s */ - { 211, 100, 2100, 408, 1688, 1066 }, - { 211, 64, 1536, 358, 1688, 1066 }, - { 211, 100, 2100, 408, 1688, 1066 }, - { 211, 64, 1536, 358, 1688, 1066 }, - { 211, 48, 840, 488, 1688, 1066 }, - { 211, 72, 1008, 609, 1688, 1066 }, - { 211, 128, 1400, 776, 1688, 1066 }, - { 211, 205, 1680, 1041, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 } -}; - -static const SiS310_LCDDataStruct SiS310_NoScaleData1400x1050[] = -{ /* TW: To be checked (BIOS uses 1280x1024 data, one line too short) */ - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 } -}; - -static const SiS310_LCDDataStruct SiS310_StLCD1600x1200Data[] = -{ /* TODO */ - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS310_LCDDataStruct SiS310_ExtLCD1600x1200Data[] = -{ /* TODO */ - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS310_LCDDataStruct SiS310_NoScaleData1600x1200[] = -{ /* TODO */ - { 0, 0, 0, 0, 0, 0} -}; + UCHAR CR[12]; +} SiS310_Part2PortTblStruct; -typedef struct _SiS310_TVDataStruct +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_1[] = { - 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; -} SiS310_TVDataStruct; - -static const SiS310_TVDataStruct SiS310_StPALData[]= -{ - { 1, 1, 864, 525,1270, 400, 100, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 350, 100, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, - { 1, 1, 864, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, - { 1, 1, 864, 525,1270, 480, 50, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 600, 50, 0, 0,0xf4,0xff,0x1c,0x22} -}; - -static const SiS310_TVDataStruct SiS310_ExtPALData[] = -{ - { 27, 10, 848, 448,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, - { 108, 35, 848, 398,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, - { 12, 5, 954, 448,1270, 530, 50, 0, 50,0xf1,0x04,0x1f,0x18}, - { 9, 4, 960, 463,1644, 438, 50, 0, 50,0xf4,0x0b,0x1c,0x0a}, - { 9, 4, 848, 528,1270, 530, 0, 0, 50,0xf5,0xfb,0x1b,0x2a}, /* 640x480 */ - { 36, 25,1060, 648,1316, 530, 438, 0, 438,0xeb,0x05,0x25,0x16}, /* 800x600 */ - { 3, 2,1080, 619,1270, 540, 438, 0, 438,0xf3,0x00,0x1d,0x20}, /* 720x480/576 */ - { 1, 1,1170, 821,1270, 520, 686, 0, 686,0xF3,0x00,0x1D,0x20} /* 1024x768 */ -}; - -static const SiS310_TVDataStruct SiS310_StNTSCData[]= -{ - { 1, 1, 858, 525,1270, 400, 50, 0, 760,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 350, 50, 0, 640,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, - { 1, 1, 858, 525,1270, 480, 0, 0, 760,0xf1,0x04,0x1f,0x18} -}; - -static const SiS310_TVDataStruct SiS310_ExtNTSCData[]= -{ - { 143, 65, 858, 443,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, - { 88, 35, 858, 393,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, - { 143, 70, 924, 443,1270, 440, 92, 0, 92,0xf1,0x04,0x1f,0x18}, - { 143, 70, 924, 393,1270, 440, 92, 0, 92,0xf4,0x0b,0x1c,0x0a}, - { 143, 76, 836, 523,1270, 440, 224, 0, 0,0xf1,0x05,0x1f,0x16}, /* 640x480 */ - { 143, 120,1056, 643,1270, 440, 0, 128, 0,0xf4,0x10,0x1c,0x00}, /* 800x600 */ - { 2, 1, 858, 503,1270, 480, 0, 128, 0,0xee,0x0c,0x22,0x08}, /* 720x480/576 */ - { 65, 64,1056, 791,1270, 480, 638, 0, 0,0xEE,0x0C,0x22,0x08} /* 1024x768 */ + {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x2c,0x12,0x9a,0xae,0x88,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x38,0x13,0x16,0x0c,0xe6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}} }; -#if 0 -static const SiS310_TVDataStruct SiS310_St1HiTVData[]= +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_2[] = { - + {{0x25,0x12,0x51,0x6e,0x48,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}}, + {{0x2c,0x12,0x38,0x55,0x2f,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}}, + {{0x25,0x12,0x51,0x6e,0x48,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}}, + {{0x2c,0x12,0x38,0x55,0x2f,0xc1,0x35,0xb1,0x47,0xe9,0x71,0x33}}, + {{0x2d,0x12,0x79,0x96,0x70,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}}, + {{0x29,0x12,0xb5,0xd2,0xac,0xe9,0x35,0xd9,0x47,0x11,0x99,0x33}}, + {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, /* others */ +/* 0x36,0x13,0x02,0x25,0xff,0x03,0x45,0x09,0x07,0xf9,0x00,0x24 my */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -#endif -static const SiS310_TVDataStruct SiS310_St2HiTVData[]= +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_3[] = { - { 3, 1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 3, 1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x3e8,0x233,0x311,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 5, 2, 0x348,0x233,0x670,0x3c0,0x08d,128, 0, 0x00,0x00,0x00,0x00}, - { 8, 5, 0x41a,0x2ab,0x670,0x3c0,0x17c,128, 0, 0x00,0x00,0x00,0x00} -}; - -static const SiS310_TVDataStruct SiS310_ExtHiTVData[]= -{ - { 6, 1, 0x348,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 3, 1, 0x3c0,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 3, 1, 0x348,0x1e3,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 3, 1, 0x3c0,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 5, 1, 0x348,0x233,0x670,0x3c0,0x166,128, 0, 0x00,0x00,0x00,0x00}, - { 16, 5, 0x41a,0x2ab,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00}, - { 25, 12, 0x4ec,0x353,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, - { 5, 4, 0x627,0x464,0x670,0x3c0,0x128, 0, 0, 0x00,0x00,0x00,0x00}, - { 4, 1, 0x41a,0x233,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00}, - { 5, 2, 0x578,0x293,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, - { 8, 5, 0x6d6,0x323,0x670,0x3c0,0x128, 0, 0, 0x00,0x00,0x00,0x00} -}; - -static const UCHAR SiS310_NTSCTiming[] = { - 0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c, - 0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a, - 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b, - 0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17, - 0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02, - 0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50, - 0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00 -}; - -static const UCHAR SiS310_PALTiming[] = { - 0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70, - 0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b, - 0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17, - 0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02, - 0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63, - 0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00 -}; - -static const UCHAR SiS310_HiTVExtTiming[] = { - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, - 0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40, - 0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d, - 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 -}; - -static const UCHAR SiS310_HiTVSt1Timing[] = { - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x65,0x90,0x7b,0xa8,0x03,0xf0,0x87,0x03, - 0x11,0x15,0x11,0xcf,0x10,0x11,0xcf,0x10, - 0x35,0x35,0x3b,0x69,0x1d,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x86, - 0xaf,0x5d,0x0e,0x00,0xfc,0xff,0x2d,0x00 -}; - -static const UCHAR SiS310_HiTVSt2Timing[] = { - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, - 0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40, - 0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d, - 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 -}; - -static const UCHAR SiS310_HiTVTextTiming[] = { - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x65,0x90,0xe7,0xbc,0x03,0x0c,0x97,0x03, - 0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20, - 0xc8,0xc8,0x3b,0xd2,0x26,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96, - 0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00 -}; - -static const UCHAR SiS310_HiTVGroup3Data[] = { - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f, - 0x05,0x21,0xb2,0xb2,0x55,0x77,0x2a,0xa6, - 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, - 0x8c,0x6e,0x60,0x2e,0x58,0x48,0x72,0x44, - 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, - 0x4f,0x7f,0x03,0xa8,0x7d,0x20,0x1a,0xa9, - 0x14,0x05,0x03,0x7e,0x64,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 -}; - -static const UCHAR SiS310_HiTVGroup3Simu[] = { - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95, - 0xdb,0x20,0xb8,0xb8,0x55,0x47,0x2a,0xa6, - 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, - 0x8c,0x6e,0x60,0x15,0x26,0xd3,0xe4,0x11, - 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, - 0x67,0x36,0x01,0x47,0x0e,0x10,0xbe,0xb4, - 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 -}; - -static const UCHAR SiS310_HiTVGroup3Text[] = { - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7, - 0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6, - 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, - 0x8c,0x6e,0x60,0x18,0x2c,0x0c,0x20,0x22, - 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, - 0x93,0x3c,0x01,0x50,0x2f,0x10,0xf4,0xca, - 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 +#if 1 /* Data from 650/301LVx 1.10.6s and others */ + {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x2c,0x13,0x9a,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x25,0x13,0xc9,0x24,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x38,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x25,0x13,0xc9,0x25,0xff,0xf9,0x45,0x09,0x07,0xf9,0x09,0x24}} +#endif +#if 0 /* Data from my 301LV */ + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}}, /* TEST */ + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}}, + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}}, + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}}, + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}}, + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}}, + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}}, + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}}, + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}} +#endif }; -typedef struct _SiS310_PanelDelayTblStruct -{ - UCHAR timer[2]; -} SiS310_PanelDelayTblStruct; +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_1[] = +{ /* Acer; BIOS data invalid, last row taken from _3 */ + {{0x25,0x12,0x51,0x6E,0x48,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x2C,0x12,0x38,0x55,0x2F,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x25,0x12,0x51,0x6E,0x48,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x2C,0x12,0x38,0x55,0x2F,0xC1,0x35,0xB1,0x47,0xE9,0x71,0x33}}, + {{0x2D,0x12,0x79,0x96,0x70,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x29,0x12,0xB5,0xD2,0xAC,0xE9,0x35,0xD9,0x47,0x11,0x99,0x33}}, + {{0x36,0x13,0x02,0x25,0xFF,0x03,0x45,0x09,0x07,0xF9,0x00,0x24}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}} +}; -static const SiS310_PanelDelayTblStruct SiS310_PanelDelayTbl[]= -{ - {{0x10,0x40}}, /* TW: from 650/301LVx 1.10.6s BIOS */ - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}} -#if 0 - {{0x28,0xc8}}, /* TW: from 650/301LV BIOS */ - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}} -#endif +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_2[] = +{ /* Acer */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -static const SiS310_PanelDelayTblStruct SiS310_PanelDelayTblLVDS[]= -{ - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}} +/* 1 2 4 5 6 1c 1d 1f 20 21 23 25 */ +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_3[] = +{ /* Acer */ + {{0x31,0x1B,0xC4,0xDA,0xB0,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x34,0x1B,0x9F,0xC0,0x80,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x3E,0x1B,0xCF,0xF0,0xB0,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x48,0x1C,0x15,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x48,0x1C,0x15,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x48,0x1C,0x15,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}} }; -typedef struct _SiS310_LVDSDataStruct +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_1[] = { - USHORT VGAHT; - USHORT VGAVT; - USHORT LCDHT; - USHORT LCDVT; -} SiS310_LVDSDataStruct; + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} +}; -static const SiS310_LVDSDataStruct SiS310_LVDS320x480Data_1[]= +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_2[] = { - { 848, 433, 400, 525}, - { 848, 389, 400, 525}, - { 848, 433, 400, 525}, - { 848, 389, 400, 525}, - { 848, 518, 400, 525}, - {1056, 628, 400, 525}, - { 400, 525, 400, 525}, - { 800, 449,1000, 644}, - { 800, 525,1000, 635} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS800x600Data_1[]= -{ - { 848, 433,1060, 629}, - { 848, 389,1060, 629}, - { 848, 433,1060, 629}, - { 848, 389,1060, 629}, - { 848, 518,1060, 629}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - { 800, 449,1000, 644}, - { 800, 525,1000, 635} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS800x600Data_2[]= -{ - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - { 800, 449,1000, 644}, - { 800, 525,1000, 635} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1024x768Data_1[]= -{ - { 840, 438,1344, 806}, - { 840, 409,1344, 806}, - { 840, 438,1344, 806}, - { 840, 409,1344, 806}, - { 840, 518,1344, 806}, /* 640x480 */ - {1050, 638,1344, 806}, /* 800x600 */ - {1344, 806,1344, 806}, /* 1024x768 */ - { 800, 449,1280, 801}, - { 800, 525,1280, 813} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1024x768Data_2[]= -{ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - { 800, 449,1280, 801}, - { 800, 525,1280, 813} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1280x1024Data_1[]= -{ - {1048, 442,1688,1066}, - {1048, 392,1688,1066}, - {1048, 442,1688,1066}, - {1048, 392,1688,1066}, - {1048, 522,1688,1066}, - {1208, 642,1688,1066}, - {1432, 810,1688,1066}, - {1688,1066,1688,1066} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1280x1024Data_2[]= -{ - {1688,1066,1688,1066}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1400x1050Data_1[]= -{ - { 928, 416, 1688,1066}, - { 928, 366, 1688,1066}, - { 928, 416, 1688,1066}, - { 928, 366, 1688,1066}, - { 928, 496, 1688,1066}, - {1088, 616, 1688,1066}, - {1312, 784, 1688,1066}, - {1568,1040, 1688,1066}, - {1688,1066, 1688,1066} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1400x1050Data_2[]= -{ - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1600x1200Data_1[]= -{ - {1088, 450, 2048,1250}, - {1088, 400, 2048,1250}, - {1088, 450, 2048,1250}, - {1088, 400, 2048,1250}, - {1088, 530, 2048,1250}, - {1248, 650, 2048,1250}, - {1472, 818, 2048,1250}, - {1728,1066, 2048,1250}, - {1848,1066, 2048,1250}, - {2048,1250, 2048,1250} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1600x1200Data_2[]= -{ - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250}, - {2048,1250, 2048,1250} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1280x768Data_1[]= -{ - { 768, 438, 1408, 806}, - { 768, 388, 1408, 806}, - { 768, 438, 1408, 806}, - { 768, 388, 1408, 806}, - { 768, 518, 1408, 806}, - { 928, 638, 1408, 806}, - {1152, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1280x768Data_2[]= -{ - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1024x600Data_1[]= -{ - { 840, 604, 1344, 800}, - { 840, 560, 1344, 800}, - { 840, 604, 1344, 800}, - { 840, 560, 1344, 800}, - { 840, 689, 1344, 800}, - {1050, 800, 1344, 800}, - {1344, 800, 1344, 800}, - { 800, 449, 1280, 801}, - { 800, 525, 1280, 813} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1024x600Data_2[]= -{ - {1344, 800, 1344, 800}, - {1344, 800, 1344, 800}, - {1344, 800, 1344, 800}, - {1344, 800, 1344, 800}, - {1344, 800, 1344, 800}, - {1344, 800, 1344, 800}, - {1344, 800, 1344, 800}, - { 800, 449, 1280, 801}, - { 800, 525, 1280, 813} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1152x768Data_1[]= -{ - { 840, 438, 1344, 806}, - { 840, 409, 1344, 806}, - { 840, 438, 1344, 806}, - { 840, 409, 1344, 806}, - { 840, 518, 1344, 806}, - {1050, 638, 1344, 806}, - {1344, 806, 1344, 806}, - { 800, 449, 1280, 801}, - { 800, 525, 1280, 813} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1152x768Data_2[]= -{ - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - {1344, 806, 1344, 806}, - { 800, 449, 1280, 801}, - { 800, 525, 1280, 813} -}; - -/* TW: Pass 1:1 data */ -static const SiS310_LVDSDataStruct SiS310_LVDSXXXxXXXData_1[]= -{ - { 800, 449, 800, 449}, - { 800, 449, 800, 449}, - { 900, 449, 900, 449}, - { 900, 449, 900, 449}, - { 800, 525, 800, 525}, /* 640x480 */ - {1056, 628, 1056, 628}, /* 800x600 */ - {1344, 806, 1344, 806}, /* 1024x768 */ - {1344,1066, 1344,1066}, /* 1280x1024 */ /* INSERTED ! */ - {1688, 806, 1688, 806}, /* 1280x768 ! */ - /* No other panels ! */ -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS640x480Data_1[]= -{ - { 800, 449, 800, 449}, - { 800, 449, 800, 449}, - { 800, 449, 800, 449}, - { 800, 449, 800, 449}, - { 800, 525, 800, 525}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1280x960Data_1[]= -{ - { 840, 438,1344, 806}, - { 840, 409,1344, 806}, - { 840, 438,1344, 806}, - { 840, 409,1344, 806}, - { 840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - { 800, 449,1280, 801}, - { 800, 525,1280, 813} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1280x960Data_2[]= -{ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - { 800, 449,1280, 801}, - { 800, 525,1280, 813} -}; - -/* LCDA */ - -static const SiS310_LVDSDataStruct SiS310_LCDA1400x1050Data_1[]= -{ /* TW: Might be temporary (invalid) data */ - { 928, 416, 1688,1066}, - { 928, 366, 1688,1066}, - {1008, 416, 1688,1066}, - {1008, 366, 1688,1066}, - {1200, 530, 1688,1066}, - {1088, 616, 1688,1066}, - {1312, 784, 1688,1066}, - {1568,1040, 1688,1066}, - {1688,1066, 1688,1066} -}; - -static const SiS310_LVDSDataStruct SiS310_LCDA1400x1050Data_2[]= -{ /* TW: Temporary data. Not valid */ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - { 800, 449,1280, 801}, - { 800, 525,1280, 813} -}; - -static const SiS310_LVDSDataStruct SiS310_LCDA1600x1200Data_1[]= -{ /* TW: Temporary data. Not valid */ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - { 800, 449,1280, 801}, - { 800, 525,1280, 813} -}; - -static const SiS310_LVDSDataStruct SiS310_LCDA1600x1200Data_2[]= -{ /* TW: Temporary data. Not valid */ - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0} + {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, + {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, + {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, + {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, + {{0x33,0x13,0x01,0x0d,0xfd,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, + {{0x3f,0x1b,0x3d,0x49,0x39,0x54,0x23,0xc0,0x27,0x66,0x30,0x42}}, + {{0x33,0x1b,0x91,0x9d,0x8d,0x8c,0x23,0xf8,0x27,0x9e,0x68,0x42}}, + {{0x43,0x24,0x11,0x1d,0x0d,0xcc,0x23,0x38,0x37,0xde,0xa8,0x42}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} }; -/* Chrontel TV */ +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_3[] = +{ + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}} +}; -static const SiS310_LVDSDataStruct SiS310_CHTVUNTSCData[]= +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_1[] = { - { 840, 600, 840, 600}, - { 840, 600, 840, 600}, - { 840, 600, 840, 600}, - { 840, 600, 840, 600}, - { 784, 600, 784, 600}, - {1064, 750,1064, 750}, - {1160, 945,1160, 945} /* TW: For Ch7019 1024 */ + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}} }; -static const SiS310_LVDSDataStruct SiS310_CHTVONTSCData[]= +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_2[] = { - { 840, 525, 840, 525}, - { 840, 525, 840, 525}, - { 840, 525, 840, 525}, - { 840, 525, 840, 525}, - { 784, 525, 784, 525}, - {1040, 700,1040, 700}, - {1160, 840,1160, 840} /* TW: For Ch7019 1024 */ + {{0x32,0x1B,0x2C,0x52,0x20,0x80,0x20,0x52,0x30,0xA3,0x3A,0x02}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x32,0x1B,0x2C,0x52,0x20,0x80,0x20,0x52,0x30,0xA3,0x3A,0x02}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x3A,0x1B,0x54,0x7A,0x48,0x80,0x24,0x52,0x30,0xA3,0x3A,0x02}}, + {{0x36,0x1B,0x90,0xB6,0x84,0xA8,0x24,0x7A,0x30,0xCB,0x62,0x02}}, + {{0x3A,0x1C,0xE4,0x0A,0xD8,0xE0,0x24,0xB2,0x30,0x03,0x9A,0x02}}, + {{0x4A,0x24,0x64,0x8A,0x58,0x20,0x34,0xF2,0x30,0x43,0xDA,0x52}}, + {{0x47,0x24,0x71,0x97,0x65,0x3E,0x34,0x10,0x40,0x61,0xF8,0x02}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}} }; -static const SiS310_LVDSDataStruct SiS310_CHTVUPALData[]= +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_3[] = { - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - { 840, 625, 840, 625}, - { 960, 750, 960, 750}, - {1400,1000,1400,1000} /* TW: For Ch7019 1024 */ + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}} }; -static const SiS310_LVDSDataStruct SiS310_CHTVOPALData[]= +/* CRT1 CRTC for LCDA */ + +typedef struct _SiS310_LCDACRT1DataStruct { - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - { 840, 625, 840, 625}, - { 944, 625, 944, 625}, - {1400, 875,1400, 875} /* TW: For Ch7019 1024 */ -}; + UCHAR CR[17]; +}SiS310_LCDACRT1DataStruct; -static const SiS310_LVDSDataStruct SiS310_CHTVUPALMData[]= +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_1[]= { - { 840, 600, 840, 600}, - { 840, 600, 840, 600}, - { 840, 600, 840, 600}, - { 840, 600, 840, 600}, - { 784, 600, 784, 600}, - {1064, 750,1064, 750}, - {1160, 945,1160, 945} /* TW: For Ch7019 1024 */ + {{0x73,0x4f,0x4f,0x97,0x59,0x84,0xb4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x59,0x84,0x82,0x1f, + 0x60,0x87,0x5d,0x5d,0x83,0x10,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x59,0x84,0xb4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x59,0x84,0x82,0x1f, + 0x60,0x87,0x5d,0x5d,0x83,0x10,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x59,0x84,0x04,0x3e, + 0xE2,0x89,0xdf,0xdf,0x05,0x00,0x00,0x05, + 0x00}}, + {{0x87,0x63,0x63,0x8B,0x6D,0x18,0x7c,0xf0, + 0x5A,0x81,0x57,0x57,0x7D,0x00,0x00,0x06, + 0x01}}, + {{0xA3,0x7f,0x7f,0x87,0x89,0x94,0x24,0xf5, + 0x02,0x89,0xff,0xff,0x25,0x10,0x00,0x02, + 0x01}} }; -static const SiS310_LVDSDataStruct SiS310_CHTVOPALMData[]= +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_1_H[]= { - { 840, 525, 840, 525}, - { 840, 525, 840, 525}, - { 840, 525, 840, 525}, - { 840, 525, 840, 525}, - { 784, 525, 784, 525}, - {1040, 700,1040, 700}, - {1160, 840,1160, 840} /* TW: For Ch7019 1024 */ + {{0x4b,0x27,0x27,0x8f,0x31,0x1c,0xb4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x31,0x1c,0x82,0x1f, + 0x60,0x87,0x5D,0x5D,0x83,0x10,0x00,0x05, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x31,0x1c,0xb4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x31,0x1c,0x82,0x1f, + 0x60,0x87,0x5D,0x5D,0x83,0x10,0x00,0x05, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x31,0x1c,0x04,0x3e, + 0xE2,0x89,0xDf,0xDf,0x05,0x00,0x00,0x05, + 0x00}}, + {{0x55,0x31,0x31,0x99,0x3b,0x06,0x7c,0xf0, + 0x5A,0x81,0x57,0x57,0x7D,0x00,0x00,0x01, + 0x01}}, + {{0x63,0x3F,0x3F,0x87,0x49,0x94,0x24,0xF5, + 0x02,0x89,0xFF,0xFF,0x25,0x10,0x00,0x01, + 0x01}} }; -static const SiS310_LVDSDataStruct SiS310_CHTVUPALNData[]= +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_2[]= { - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - { 840, 625, 840, 625}, - { 960, 750, 960, 750}, - {1400,1000,1400,1000} /* TW: For Ch7019 1024 */ + {{0xa3,0x4f,0x4f,0x0f,0x6e,0x1f,0x24,0xbb, + 0x4a,0x81,0x8f,0xdb,0xda,0x20,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x0f,0x6e,0x1f,0x24,0xbb, + 0x31,0x88,0x5d,0xc2,0xc1,0x20,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x0f,0x6e,0x1f,0x24,0xbb, + 0x4a,0x81,0x8f,0xdb,0xda,0x20,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x0f,0x6e,0x1f,0x24,0xbb, + 0x31,0x88,0x5d,0xc2,0xc1,0x20,0x00,0x06, + 0x01}}, + {{0xa3,0x4f,0x4f,0x0f,0x6e,0x1f,0x24,0xb3, + 0x72,0x89,0xdf,0x03,0x02,0x30,0x00,0x06, + 0x01}}, + {{0xa3,0x63,0x63,0x98,0x78,0x19,0x24,0xf1, + 0xbb,0x82,0x57,0x57,0x25,0x10,0x00,0x02, + 0x01}}, + {{0xa3,0x7f,0x7f,0x87,0x89,0x94,0x24,0xf5, + 0x02,0x89,0xff,0xff,0x25,0x10,0x00,0x02, + 0x01}} }; -static const SiS310_LVDSDataStruct SiS310_CHTVOPALNData[]= +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_2_H[]= { - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - { 840, 625, 840, 625}, - { 944, 625, 944, 625}, - {1400, 875,1400, 875} /* TW: For Ch7019 1024 */ + {{0x7b,0x27,0x27,0x0f,0x46,0x97,0x24,0xbb, + 0x4a,0x81,0x8f,0xdb,0xda,0x20,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x0f,0x46,0x97,0x24,0xbb, + 0x31,0x88,0x5d,0xc2,0xc1,0x20,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x0f,0x46,0x97,0x24,0xbb, + 0x4a,0x81,0x8f,0xdb,0xda,0x20,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x0f,0x46,0x97,0x24,0xbb, + 0x31,0x88,0x5d,0xc2,0xc1,0x20,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x0f,0x46,0x97,0x24,0xb3, + 0x72,0x89,0xdf,0x03,0x02,0x30,0x00,0x01, + 0x01 }}, + {{0x71,0x31,0x31,0x98,0x46,0x17,0x24,0xf1, + 0xbb,0x82,0x57,0x57,0x25,0x10,0x00,0x02, + 0x01 }}, + {{0x63,0x3f,0x3f,0x87,0x4c,0x97,0x24,0xf5, + 0x0f,0x86,0xff,0xff,0x25,0x30,0x00,0x01, + 0x01 }} }; -static const SiS310_LVDSDataStruct SiS310_CHTVSOPALData[]= /* TW: (super overscan - no effect on 7019) */ -{ - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - {1008, 625,1008, 625}, - { 840, 625, 840, 625}, - { 944, 625, 944, 625}, - {1400, 875,1400, 875} +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_1[]= +{ /* Acer */ + {{0x7e,0x4f,0x4f,0x82,0x58,0x04,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x04,0x86,0x1f, + 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x04,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x04,0x86,0x1f, + 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x04,0x08,0x3e, + 0xe0,0x84,0xdf,0xdf,0x09,0x00,0x00,0x06, + 0x00}}, + {{0x92,0x63,0x63,0x96,0x6c,0x18,0x80,0xf0, + 0x58,0x8c,0x57,0x57,0x81,0x20,0x00,0x06, + 0x01}}, + {{0xae,0x7f,0x7f,0x92,0x88,0x94,0x28,0xf5, + 0x00,0x84,0xff,0xff,0x29,0x10,0x00,0x02, + 0x01}}, + {{0xce,0x9f,0x9f,0x92,0xa8,0x14,0x28,0x5a, + 0x00,0x84,0xff,0xff,0x29,0x01,0x00,0x07, + 0x01}} }; -typedef struct _SiS310_LVDSDesStruct -{ - USHORT LCDHDES; - USHORT LCDVDES; -} SiS310_LVDSDesStruct; +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_1_H[]= +{ /* Acer */ + {{0x56,0x27,0x27,0x9a,0x31,0x1c,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x56,0x27,0x27,0x9a,0x31,0x1c,0x86,0x1f, + 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x05, + 0x00}}, + {{0x56,0x27,0x27,0x9a,0x31,0x1c,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x56,0x27,0x27,0x9a,0x31,0x1c,0x86,0x1f, + 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x05, + 0x01}}, + {{0x56,0x27,0x27,0x9a,0x31,0x1c,0x08,0x3e, + 0xe0,0x84,0xdf,0xdf,0x09,0x00,0x00,0x05, + 0x00}}, + {{0x60,0x31,0x31,0x84,0x3a,0x86,0x80,0xf0, + 0x58,0x8c,0x57,0x57,0x81,0x20,0x00,0x01, + 0x01}}, + {{0x6e,0x3f,0x3f,0x92,0x48,0x94,0x28,0xf5, + 0x00,0x84,0xff,0xff,0x29,0x10,0x00,0x01, + 0x01}} +}; -static const SiS310_LVDSDesStruct SiS310_PanelType00_1[]= -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_2[]= +{ /* Illegal data in BIOS (Acer, Compaq) */ + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x63,0x63,0x87,0x78,0x89,0x24,0xf1, + 0xae,0x84,0x57,0x57,0x25,0x30,0x00,0x02, + 0x01}}, + {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, + 0x01}} }; -static const SiS310_LVDSDesStruct SiS310_PanelType01_1[]= -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 805}, - { 0, 0}, - { 0, 0} +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_2_H[]= +{ /* Illegal data in BIOS (Acer, Compaq) */ + {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, + 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, + 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, + 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, + 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, + 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x4f,0x31,0x31,0x93,0x3e,0x86,0x24,0xf1, + 0xae,0x84,0x57,0x57,0x25,0x30,0x00,0x01, + 0x01 }}, + {{0x4f,0x3f,0x3f,0x93,0x45,0x0d,0x24,0xf5, + 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x01, + 0x01 }} }; -static const SiS310_LVDSDesStruct SiS310_PanelType02_1[]= +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_1[]= { - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 1065}, - { 0, 0}, - { 0, 0} + {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x9e,0x1f, + 0x93,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05, + 0x00}}, + {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x6c,0x1f, + 0x60,0x84,0x5d,0x5d,0x6d,0x10,0x00,0x05, + 0x00}}, + {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x9e,0x1f, + 0x93,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05, + 0x00}}, + {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x6c,0x1f, + 0x60,0x84,0x5d,0x5d,0x6d,0x10,0x00,0x05, + 0x00}}, + {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0xee,0x1f, + 0xe2,0x86,0xdf,0xdf,0xef,0x10,0x00,0x05, + 0x00}}, + {{0x83,0x63,0x63,0x87,0x68,0x16,0x66,0xf0, + 0x5a,0x8e,0x57,0x57,0x67,0x20,0x00,0x06, + 0x01}}, + {{0x9f,0x7f,0x7f,0x83,0x84,0x92,0x0e,0xf5, + 0x02,0x86,0xff,0xff,0x0f,0x10,0x00,0x02, + 0x01}}, + {{0xbf,0x9f,0x9f,0x83,0xa4,0x12,0x0e,0x5a, + 0x02,0x86,0xff,0xff,0x0f,0x09,0x00,0x07, + 0x01}}, + {{0xce,0xae,0xae,0x92,0xb3,0x01,0x28,0x10, + 0x1a,0x80,0x19,0x19,0x29,0x0f,0x00,0x03, + 0x00}} }; - -static const SiS310_LVDSDesStruct SiS310_PanelType03_1[]= +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_1_H[]= { - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} + {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, + 0x93,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, + 0x60,0x84,0x5d,0x5d,0x6d,0x10,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x27,0x8b,0x30,0x1e,0x9e,0x1f, + 0x92,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, + 0x60,0x84,0x5d,0x5d,0x6d,0x10,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0xee,0x1f, + 0xe2,0x86,0xdf,0xdf,0xef,0x10,0x00,0x05, + 0x00}}, + {{0x51,0x31,0x31,0x95,0x36,0x04,0x66,0xf0, + 0x5a,0x8e,0x57,0x57,0x67,0x20,0x00,0x01, + 0x01}}, + {{0x5f,0x3f,0x3f,0x83,0x44,0x92,0x0e,0xf5, + 0x02,0x86,0xff,0xff,0x0f,0x10,0x00,0x01, + 0x01}}, + {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x0e,0x5a, + 0x02,0x86,0xff,0xff,0x0f,0x09,0x00,0x05, + 0x01}}, + {{0x76,0x56,0x56,0x9a,0x5b,0x89,0x28,0x10, + 0x1c,0x80,0x19,0x19,0x29,0x0b,0x00,0x05, + 0x00}} }; -static const SiS310_LVDSDesStruct SiS310_PanelType04_1[]= +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_2[]= +{ + {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a, + 0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x03, + 0x00}}, + {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a, + 0xc2,0x86,0x5d,0x5d,0x29,0x01,0x00,0x03, + 0x01}}, + {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a, + 0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x03, + 0x00}}, + {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a, + 0xc2,0x86,0x5d,0x5d,0x29,0x01,0x00,0x03, + 0x00}}, + {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9e, + 0x03,0x87,0xdf,0xdf,0x29,0x01,0x00,0x03, + 0x00}}, + {{0xce,0x63,0x63,0x92,0x96,0x04,0x28,0xd4, + 0x3f,0x83,0x57,0x57,0x29,0x01,0x00,0x07, + 0x01}}, + {{0xce,0x7f,0x7f,0x92,0xa4,0x12,0x28,0xd4, + 0x93,0x87,0xff,0xff,0x29,0x21,0x00,0x07, + 0x01}}, + {{0xce,0x9f,0x9f,0x92,0xb4,0x02,0x28,0x5a, + 0x13,0x87,0xff,0xff,0x29,0x29,0x00,0x03, + 0x01}}, + {{0xce,0xae,0xae,0x92,0xbc,0x0a,0x28,0x10, + 0x20,0x84,0x19,0x19,0x29,0x0f,0x00,0x03, + 0x00}} +}; + +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_2_H[]= +{ + {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a, + 0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x06, + 0x00}}, + {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a, + 0xc2,0x86,0x5d,0x5d,0x29,0x01,0x00,0x06, + 0x00}}, + {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a, + 0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x06, + 0x00}}, + {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a, + 0xc2,0x86,0x5d,0x5d,0x29,0x01,0x00,0x06, + 0x00}}, + {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9e, + 0x03,0x87,0xdf,0xdf,0x29,0x01,0x00,0x06, + 0x00}}, + {{0x9c,0x31,0x31,0x80,0x64,0x92,0x28,0xd4, + 0x3f,0x83,0x57,0x57,0x29,0x01,0x00,0x06, + 0x01}}, + {{0x8e,0x3f,0x3f,0x92,0x64,0x12,0x28,0xd4, + 0x93,0x87,0xff,0xff,0x29,0x21,0x00,0x06, + 0x01}}, + {{0x7e,0x4f,0x4f,0x82,0x64,0x12,0x28,0x5a, + 0x13,0x87,0xff,0xff,0x29,0x29,0x00,0x06, + 0x01}}, + {{0x76,0x56,0x56,0x9a,0x64,0x92,0x28,0x10, + 0x20,0x84,0x19,0x19,0x29,0x0f,0x00,0x05, + 0x00}} +}; + +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_1[]= +{ + {{0x83,0x4F,0x4F,0x87,0x51,0x09,0xC0,0x1F, + 0x90,0x84,0x8F,0x8F,0xC1,0x30,0x00,0x06, + 0x00}}, + {{0x83,0x4F,0x4F,0x87,0x51,0x09,0x8E,0x1F, + 0x5E,0x82,0x5D,0x5D,0x8F,0x10,0x00,0x06, + 0x00}}, + {{0x83,0x4F,0x4F,0x87,0x51,0x09,0xC0,0x1F, + 0x90,0x84,0x8F,0x8F,0xC1,0x30,0x00,0x06, + 0x00}}, + {{0x83,0x4F,0x4F,0x87,0x51,0x09,0x8E,0x1F, + 0x5E,0x82,0x5D,0x5D,0x8F,0x10,0x00,0x06, + 0x00}}, + {{0x83,0x4F,0x4F,0x87,0x51,0x09,0x10,0x3E, + 0xE0,0x84,0xDF,0xDF,0x11,0x00,0x00,0x06, + 0x00}}, + {{0x97,0x63,0x63,0x9B,0x65,0x1D,0x88,0xF0, + 0x58,0x8C,0x57,0x57,0x89,0x20,0x00,0x06, + 0x01}}, + {{0xB3,0x7F,0x7F,0x97,0x81,0x99,0x30,0xF5, + 0x00,0x84,0xFF,0xFF,0x31,0x10,0x00,0x02, + 0x01}}, + {{0xD3,0x9F,0x9F,0x97,0xA1,0x19,0x30,0x5A, + 0x00,0x84,0xFF,0xFF,0x31,0x09,0x00,0x07, + 0x01}}, + {{0xE2,0xAE,0xAE,0x86,0xB0,0x88,0x4A,0x10, + 0x1A,0x8E,0x19,0x19,0x4B,0x2F,0x00,0x03, + 0x00}}, + {{0xFB,0xC7,0xC7,0x9F,0xC9,0x81,0xE0,0x10, + 0xB0,0x84,0xAF,0xAF,0xE1,0x2F,0x00,0x07, + 0x00}} +}; + +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_1_H[]= +{ + {{0x69,0x27,0x27,0x8D,0x30,0x88,0xC0,0x1F, + 0x90,0x84,0x8F,0x8F,0xC1,0x30,0x00,0x01, + 0x00}}, + {{0x69,0x27,0x27,0x8D,0x30,0x88,0x8E,0x1F, + 0x5E,0x82,0x5D,0x5D,0x87,0x10,0x00,0x01, + 0x00}}, + {{0x69,0x27,0x27,0x8D,0x30,0x88,0xC0,0x1F, + 0x90,0x84,0x8F,0x8F,0xC1,0x30,0x00,0x01, + 0x00}}, + {{0x69,0x27,0x27,0x8D,0x30,0x88,0x8E,0x1F, + 0x5E,0x82,0x5D,0x5D,0x87,0x10,0x00,0x01, + 0x00}}, + {{0x69,0x27,0x27,0x8D,0x30,0x88,0x10,0x3E, + 0xE0,0x84,0xDF,0xDF,0x11,0x00,0x00,0x01, + 0x00}}, + {{0x73,0x31,0x31,0x97,0x3A,0x92,0x88,0xF0, + 0x58,0x8C,0x57,0x57,0x89,0x20,0x00,0x01, + 0x01}}, + {{0x81,0x3F,0x3F,0x85,0x48,0x00,0x30,0xF5, + 0x00,0x84,0xFF,0xFF,0x31,0x10,0x00,0x06, + 0x01}}, + {{0x91,0x4F,0x4F,0x95,0x58,0x10,0x30,0x5A, + 0x00,0x84,0xFF,0xFF,0x31,0x09,0x00,0x06, + 0x01}}, + {{0xD4,0x9F,0x9F,0x98,0xA8,0x00,0x30,0x5A, + 0x00,0x84,0xFF,0xFF,0x31,0x09,0x00,0x03, + 0x01}}, + {{0xA5,0x63,0x63,0x89,0x6C,0x84,0xE0,0x10, + 0xB0,0x84,0xAF,0xAF,0xE1,0x2F,0x00,0x02, + 0x00}} +}; + +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_2[]= +{ + {{0x09,0x4F,0x4F,0x8D,0xA3,0x1B,0xE0,0x9E, + 0x37,0x8B,0x8F,0x8F,0xE1,0x21,0x01,0x04, + 0x00}}, + {{0x09,0x4F,0x4F,0x8D,0xA3,0x1B,0xE0,0x9E, + 0x1E,0x82,0x5D,0x5D,0xE1,0x01,0x01,0x04, + 0x00}}, + {{0x09,0x4F,0x4F,0x8D,0xA3,0x1B,0xE0,0x9E, + 0x37,0x8B,0x8F,0x8F,0xE1,0x21,0x01,0x04, + 0x00}}, + {{0x09,0x4F,0x4F,0x8D,0xA3,0x1B,0xE0,0x9E, + 0x1E,0x82,0x5D,0x5D,0xE1,0x01,0x01,0x04, + 0x00}}, + {{0x09,0x4F,0x4F,0x8D,0xA3,0x1B,0xE0,0x9E, + 0x5F,0x83,0xDF,0xDF,0xE1,0x01,0x01,0x04, + 0x00}}, + {{0x09,0x63,0x63,0x8D,0xAD,0x05,0xE0,0xD4, + 0x9B,0x8F,0x57,0x57,0xE1,0x21,0x01,0x00, + 0x01}}, + {{0x09,0x7F,0x7F,0x8D,0xBB,0x13,0xE0,0xD4, + 0xEF,0x83,0xFF,0xFF,0xE1,0x21,0x01,0x00, + 0x01}}, + {{0x09,0x9F,0x9F,0x8D,0xCB,0x03,0xE0,0x5A, + 0x6F,0x83,0xFF,0xFF,0xE1,0x29,0x01,0x04, + 0x01}}, + {{0xD4,0x9F,0x9F,0x98,0xA8,0x00,0x30,0x5A, + 0x00,0x84,0xFF,0xFF,0x31,0x09,0x00,0x03, + 0x01}}, + {{0x09,0xC7,0xC7,0x8D,0xDF,0x17,0xE0,0x10, + 0xC7,0x8B,0xAF,0xAF,0xE1,0x0F,0x01,0x04, + 0x00}} +}; + +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_2_H[]= +{ + {{0xE1,0x27,0x27,0x85,0x7B,0x93,0xE0,0x9E, + 0x37,0x8B,0x8F,0x8F,0xE1,0x21,0x00,0x03, + 0x00}}, + {{0xE1,0x27,0x27,0x85,0x7B,0x93,0xE0,0x9E, + 0x1E,0x82,0x5D,0x5D,0xE1,0x01,0x00,0x03, + 0x00}}, + {{0xE1,0x27,0x27,0x85,0x7B,0x93,0xE0,0x9E, + 0x37,0x8B,0x8F,0x8F,0xE1,0x21,0x00,0x03, + 0x00}}, + {{0xE1,0x27,0x27,0x85,0x7B,0x93,0xE0,0x9E, + 0x1E,0x82,0x5D,0x5D,0xE1,0x01,0x00,0x03, + 0x00}}, + {{0xE1,0x27,0x27,0x85,0x7B,0x93,0xE0,0x9E, + 0x5F,0x83,0xDF,0xDF,0xE1,0x01,0x00,0x03, + 0x00}}, + {{0xD7,0x31,0x31,0x9B,0x7B,0x13,0xE0,0xD4, + 0x9B,0x8F,0x57,0x57,0xE1,0x21,0x00,0x03, + 0x01}}, + {{0xC9,0x3F,0x3F,0x8D,0x7B,0x13,0xE0,0xD4, + 0xEF,0x83,0xFF,0xFF,0xE1,0x21,0x00,0x03, + 0x01}}, + {{0xB9,0x4F,0x4F,0x9D,0x7B,0x93,0xE0,0x5A, + 0x6F,0x83,0xFF,0xFF,0xE1,0x29,0x00,0x02, + 0x01}}, + {{0xD4,0x9F,0x9F,0x98,0xA8,0x00,0x30,0x5A, + 0x00,0x84,0xFF,0xFF,0x31,0x09,0x00,0x03, + 0x01}}, + {{0xA5,0x63,0x63,0x89,0x7B,0x93,0xE0,0x10, + 0xC7,0x8B,0xAF,0xAF,0xE1,0x0F,0x00,0x02, + 0x00}} +}; + + +/**************************************************************/ +/* LVDS, CHRONTEL ------------------------------------------- */ +/**************************************************************/ + +typedef struct _SiS310_LVDSDataStruct +{ + USHORT VGAHT; + USHORT VGAVT; + USHORT LCDHT; + USHORT LCDVT; +} SiS310_LVDSDataStruct; + +static const SiS310_LVDSDataStruct SiS310_CHTVUPALData[]= +{ + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + { 840, 625, 840, 625}, + { 960, 750, 960, 750}, + {1400,1000,1400,1000} +}; + +static const SiS310_LVDSDataStruct SiS310_CHTVOPALData[]= +{ + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + { 840, 625, 840, 625}, + { 944, 625, 944, 625}, + {1400, 875,1400, 875} +}; + +static const SiS310_LVDSDataStruct SiS310_CHTVUPALMData[]= +{ + { 840, 600, 840, 600}, + { 840, 600, 840, 600}, + { 840, 600, 840, 600}, + { 840, 600, 840, 600}, + { 784, 600, 784, 600}, + {1064, 750,1064, 750}, + {1160, 945,1160, 945} +}; + +static const SiS310_LVDSDataStruct SiS310_CHTVOPALMData[]= +{ + { 840, 525, 840, 525}, + { 840, 525, 840, 525}, + { 840, 525, 840, 525}, + { 840, 525, 840, 525}, + { 784, 525, 784, 525}, + {1040, 700,1040, 700}, + {1160, 840,1160, 840} +}; + +static const SiS310_LVDSDataStruct SiS310_CHTVUPALNData[]= +{ + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + { 840, 625, 840, 625}, + { 960, 750, 960, 750}, + {1400,1000,1400,1000} +}; + +static const SiS310_LVDSDataStruct SiS310_CHTVOPALNData[]= +{ + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + { 840, 625, 840, 625}, + { 944, 625, 944, 625}, + {1400, 875,1400, 875} +}; + +static const SiS310_LVDSDataStruct SiS310_CHTVSOPALData[]= /* TW: (super overscan - no effect on 7019) */ +{ + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + {1008, 625,1008, 625}, + { 840, 625, 840, 625}, + { 944, 625, 944, 625}, + {1400, 875,1400, 875} +}; + +typedef struct _SiS310_LVDSDesStruct +{ + USHORT LCDHDES; + USHORT LCDVDES; +} SiS310_LVDSDesStruct; + +static const SiS310_LVDSDesStruct SiS310_PanelType00_1[]= /* 800x600 */ +{ + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0} +}; + +static const SiS310_LVDSDesStruct SiS310_PanelType01_1[]= /* 1024x768 */ +{ + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 805}, + { 0, 0}, + { 0, 0} +}; + +static const SiS310_LVDSDesStruct SiS310_PanelType02_1[]= /* 1280x1024 */ +{ + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 1065}, + { 0, 0}, + { 0, 0} +}; + + +static const SiS310_LVDSDesStruct SiS310_PanelType03_1[]= +{ + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0} +}; + +static const SiS310_LVDSDesStruct SiS310_PanelType04_1[]= { {1343, 798}, {1343, 794}, @@ -2298,7 +1836,7 @@ static const SiS310_LVDSDesStruct SiS31 { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType05_1[]= +static const SiS310_LVDSDesStruct SiS310_PanelType05_1[]= { {1343, 798}, {1343, 794}, @@ -2311,7 +1849,7 @@ static const SiS310_LVDSDesStruct SiS31 { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType06_1[]= +static const SiS310_LVDSDesStruct SiS310_PanelType06_1[]= { {1343, 798}, {1343, 794}, @@ -2324,7 +1862,7 @@ static const SiS310_LVDSDesStruct SiS31 { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType07_1[]= +static const SiS310_LVDSDesStruct SiS310_PanelType07_1[]= { {1343, 798}, {1343, 794}, @@ -2382,20 +1920,31 @@ static const SiS310_LVDSDesStruct SiS31 { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0b_1[]= +static const SiS310_LVDSDesStruct SiS310_PanelType0b_1[]= /* 640x480_2 */ { - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 8, 524}, + { 0, 524} +}; + +static const SiS310_LVDSDesStruct SiS310_PanelType0c_1[]= /* 640x480_3 */ +{ + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 8, 524}, + { 0, 524} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0c_1[]= +static const SiS310_LVDSDesStruct SiS310_PanelType0d_1[]= { {1343, 798}, {1343, 794}, @@ -2408,7 +1957,7 @@ static const SiS310_LVDSDesStruct SiS31 { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0d_1[]= +static const SiS310_LVDSDesStruct SiS310_PanelType0e_1[]= { {1343, 798}, {1343, 794}, @@ -2421,7 +1970,7 @@ static const SiS310_LVDSDesStruct SiS31 { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0e_1[]= +static const SiS310_LVDSDesStruct SiS310_PanelType0f_1[]= { {1343, 798}, {1343, 794}, @@ -2434,20 +1983,7 @@ static const SiS310_LVDSDesStruct SiS31 { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0f_1[]= -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType00_2[]= +static const SiS310_LVDSDesStruct SiS310_PanelType00_2[]= { {980, 528}, {980, 503}, @@ -2564,17 +2100,6 @@ static const SiS310_LVDSDesStruct SiS31 { 0,1065}, { 0, 0}, { 0, 0} -#if 0 - {976, 527}, - {976, 502}, - {976, 527}, - {976, 502}, - {976, 567}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} -#endif }; static const SiS310_LVDSDesStruct SiS310_PanelType09_2[]= /* 1280x768 */ @@ -2592,6 +2117,17 @@ static const SiS310_LVDSDesStruct SiS31 static const SiS310_LVDSDesStruct SiS310_PanelType0a_2[]= /* 1600x1200 */ { + {1568, 920}, + {1568, 895}, + {1568, 920}, + {1568, 895}, + {1568, 960}, + {1648,1020}, + {1760,1104}, + {1888,1232}, + {1948,1245}, + { 0, 0} +#if 0 {1568, 850}, {1568, 825}, {1568, 850}, @@ -2602,9 +2138,10 @@ static const SiS310_LVDSDesStruct SiS31 {1888,1162}, {1948,1175}, { 0, 0} +#endif }; -static const SiS310_LVDSDesStruct SiS310_PanelType0b_2[]= +static const SiS310_LVDSDesStruct SiS310_PanelType0b_2[]= /* 640x480_2 */ { {1152, 622}, {1152, 597}, @@ -2617,7 +2154,7 @@ static const SiS310_LVDSDesStruct SiS31 { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0c_2[]= +static const SiS310_LVDSDesStruct SiS310_PanelType0c_2[]= /* 640x480_3 */ { {1152, 622}, {1152, 597}, @@ -2637,1022 +2174,134 @@ static const SiS310_LVDSDesStruct SiS31 {1152, 622}, {1152, 597}, {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType0e_2[]= -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType0f_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelTypeNS_1[]= -{ - { 8, 0}, - { 8, 0}, - { 8, 0}, - { 8, 0}, - { 8, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 806}, - { 0, 0 } -}; - -static const SiS310_LVDSDesStruct SiS310_PanelTypeNS_2[] = -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1076_1[]= -{ /* 1024x768 - Checked (1.10.6s) */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1076_2[]= -{ /* 1024x768 - Checked (1.10.6s) */ - { 1184, 622 }, - { 1184, 597 }, - { 1184, 622 }, - { 1184, 597 }, - { 1152, 622 }, - { 1232, 722 }, - { 0, 0 }, - { 0, 794 }, - { 0, 0 } -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1210_1[]= -{ /* 1280x1024 - Checked (1.10.6s) */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1210_2[]= -{ /* 1280x1024 - Checked (1.10.6s) */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1296_1[]= -{ /* 1400x1050 - Checked (1.10.6s) */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1296_2[]= -{ /* 1400x1050 - Checked (1.10.6s) - looks heavily invalid */ - { 808 , 740}, - { 0 , 715}, - { 632 , 740}, - { 632 , 715}, - { 1307, 780}, - { 1387,1157}, - { 1499, 924}, - { 1627,1052}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1600_1[]= -{ /* 1600x1200 - Checked (1.10.6s) */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1600_2[]= -{ /* 1600x1200 - Checked (1.10.6s) - looks heavily invalid, not copied */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_CHTVUNTSCDesData[]= -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS310_LVDSDesStruct SiS310_CHTVONTSCDesData[]= -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS310_LVDSDesStruct SiS310_CHTVUPALDesData[]= -{ - {256, 0}, - {256, 0}, - {256, 0}, - {256, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS310_LVDSDesStruct SiS310_CHTVOPALDesData[]= -{ - {256, 0}, - {256, 0}, - {256, 0}, - {256, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -typedef struct _SiS310_Part2PortTblStruct -{ - UCHAR CR[12]; -} SiS310_Part2PortTblStruct; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_1[] = -{ - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x38,0x13,0x16,0x0c,0xe6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_1[] = -{ /* TW: Temporary data, invalid */ - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_1[] = -{ /* TW: Temporary data, invalid */ - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_1[] = -{ /* TW: Temporary data, invalid */ - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_2[] = -{ - {{0x25,0x12,0x51,0x6e,0x48,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}}, - {{0x2c,0x12,0x38,0x55,0x2f,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}}, - {{0x25,0x12,0x51,0x6e,0x48,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}}, - {{0x2c,0x12,0x38,0x55,0x2f,0xc1,0x35,0xb1,0x47,0xe9,0x71,0x33}}, - {{0x2d,0x12,0x79,0x96,0x70,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}}, - {{0x29,0x12,0xb5,0xd2,0xac,0xe9,0x35,0xd9,0x47,0x11,0x99,0x33}}, - {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_2[] = -{ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_2[] = -{ - {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x33,0x13,0x01,0x0d,0xfd,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x3f,0x1b,0x3d,0x49,0x39,0x54,0x23,0xc0,0x27,0x66,0x30,0x42}}, - {{0x33,0x1b,0x91,0x9d,0x8d,0x8c,0x23,0xf8,0x27,0x9e,0x68,0x42}}, - {{0x43,0x24,0x11,0x1d,0x0d,0xcc,0x23,0x38,0x37,0xde,0xa8,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_2[] = -{ /* TW: Temporary data, invalid */ - {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x33,0x13,0x01,0x0d,0xfd,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x3f,0x1b,0x3d,0x49,0x39,0x54,0x23,0xc0,0x27,0x66,0x30,0x42}}, - {{0x33,0x1b,0x91,0x9d,0x8d,0x8c,0x23,0xf8,0x27,0x9e,0x68,0x42}}, - {{0x43,0x24,0x11,0x1d,0x0d,0xcc,0x23,0x38,0x37,0xde,0xa8,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} -}; - - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_3[] = -{ /* TW: Data from 650/301LVx 1.10.6s */ - {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x2c,0x13,0x9a,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x25,0x13,0xc9,0x24,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x38,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x25,0x13,0xc9,0x25,0xff,0xf9,0x45,0x09,0x07,0xf9,0x09,0x24}} -#if 0 /* TW: Data from 650/301LV */ - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x38,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -#endif -}; - -/* 1 2 4 5 6 1c 1d 1f 20 21 23 25 */ -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_3[] = -{ /* TW: Temporary data, invalid */ - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_3[] = -{ - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_3[] = -{ /* TW: Temporary data, invalid */ - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}} -}; - -typedef struct _SiS310_LCDACRT1DataStruct -{ - UCHAR CR[17]; -}SiS310_LCDACRT1DataStruct; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT1800x600_1[] = -{ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_1[]= -{ /* TW: Checked (1.10.6s) */ - {{0x73,0x4f,0x4f,0x97,0x55,0x86,0xc4,0x1f, - 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, - 0x00}}, - {{0x73,0x4f,0x4f,0x97,0x55,0x86,0x97,0x1f, - 0x60,0x87,0x5d,0x5d,0x83,0x10,0x00,0x05, - 0x00}}, - {{0x73,0x4f,0x4f,0x97,0x55,0x86,0xc4,0x1f, - 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, - 0x00}}, - {{0x73,0x4f,0x4f,0x97,0x55,0x86,0x97,0x1f, - 0x60,0x87,0x5d,0x5d,0x83,0x10,0x00,0x05, - 0x00}}, - {{0x73,0x4f,0x4f,0x97,0x55,0x86,0x04,0x3e, - 0xE2,0x89,0xDf,0xDf,0x05,0x00,0x00,0x05, - 0x00}}, - {{0x87,0x63,0x63,0x8B,0x69,0x1A,0x7c,0xf0, - 0x5A,0x8F,0x57,0x57,0x7D,0x20,0x00,0x26, - 0x01}}, - {{0xA3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xFf,0xFf,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_1[]= -{ /* Checked (1.10.6s) */ - {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0xb8,0x1f, - 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0x86,0x1f, - 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0xb8,0x1f, - 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0x86,0x1f, - 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0x08,0x3e, - 0xe0,0x84,0xdf,0xdf,0x09,0x00,0x00,0x06, - 0x00}}, - {{0x92,0x63,0x63,0x96,0x6c,0x1a,0x80,0xf0, - 0x58,0x8c,0x57,0x57,0x81,0x20,0x00,0x06, - 0x01}}, - {{0xae,0x7f,0x7f,0x92,0x88,0x96,0x28,0xf5, - 0x00,0x84,0xff,0xff,0x29,0x10,0x00,0x02, - 0x01}}, - {{0xce,0x9f,0x9f,0x92,0xa8,0x16,0x28,0x5a, - 0x00,0x84,0xff,0xff,0x29,0x01,0x00,0x07, - 0x01}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_1[]= -{ /* Checked (1.10.6s) */ - {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x9e,0x1f, - 0x93,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x6c,0x1f, - 0x60,0x84,0x5d,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x9e,0x1f, - 0x93,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x6c,0x1f, - 0x60,0x84,0x5d,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0xee,0x1f, - 0xe2,0x86,0xdf,0xdf,0xef,0x10,0x00,0x05, - 0x00}}, - {{0x83,0x63,0x63,0x87,0x68,0x16,0x66,0xf0, - 0x5a,0x8e,0x57,0x57,0x67,0x20,0x00,0x06, - 0x01}}, - {{0x9f,0x7f,0x7f,0x83,0x84,0x92,0x0e,0xf5, - 0x02,0x86,0xff,0xff,0x0f,0x10,0x00,0x02, - 0x01}}, - {{0xbf,0x9f,0x9f,0x83,0xa4,0x12,0x0e,0x5a, - 0x02,0x86,0xff,0xff,0x0f,0x09,0x00,0x07, - 0x01}}, - {{0xce,0xae,0xae,0x92,0xb3,0x01,0x28,0x10, - 0x1a,0x80,0x19,0x19,0x29,0x0f,0x00,0x03, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_1[]= -{ /* MISSING */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT1800x600_1_H[]= -{ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_1_H[]= -{ /* TW: Checked (1.10.6s) */ - {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0xc4,0x1f, - 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0x97,0x1f, - 0x60,0x87,0x5D,0x5D,0x83,0x01,0x00,0x44, - 0x00}}, - {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0xc4,0x1f, - 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0x97,0x1f, - 0x60,0x87,0x5D,0x5D,0x83,0x01,0x00,0x44, - 0x00}}, - {{0x4b,0x27,0x27,0x8f,0x32,0x1b,0x04,0x3e, - 0xE2,0x89,0xDf,0xDf,0x05,0x00,0x00,0x45, - 0x00}}, - {{0x55,0x31,0x31,0x99,0x46,0x1d,0x7c,0xf0, - 0x5A,0x8F,0x57,0x57,0x7D,0x20,0x00,0x55, - 0x01}}, - {{0x63,0x3F,0x3F,0x87,0x4a,0x93,0x24,0xf5, - 0x02,0x88,0xFf,0xFf,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_1_H[]= -{ /* Checked (1.10.6s) */ - {{0x56,0x27,0x27,0x9a,0x30,0x1e,0xb8,0x1f, - 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x3c,0x4f,0x4f,0x82,0x58,0x06,0x86,0xd1, /* <-- Invalid data - one byte missing in BIOS */ - 0xbc,0x80,0xbb,0xbb,0xe5,0x00,0x00,0x06, - 0x01}}, - {{0x56,0x27,0x27,0x9a,0x30,0x1e,0xb8,0x1f, - 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x3c,0x4f,0x4f,0x82,0x58,0x06,0x86,0xd1, - 0xbc,0x80,0xbb,0xbb,0xe5,0x00,0x00,0x06, - 0x01}}, - {{0x56,0x27,0x27,0x9a,0x30,0x1e,0x08,0x3e, - 0xe0,0x84,0xdf,0xdf,0x09,0x00,0x00,0x05, - 0x00}}, - {{0x60,0x31,0x31,0x84,0x3a,0x88,0x80,0xf0, - 0x58,0x8c,0x57,0x57,0x81,0x20,0x00,0x01, - 0x01}}, - {{0x6e,0x3f,0x3f,0x92,0x48,0x96,0x28,0xf5, - 0x00,0x84,0xff,0xff,0x29,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_1_H[]= -{ /* Checked (1.10.6s) */ - {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, - 0x93,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x27,0x8b,0x30,0x1e,0x9e,0x1f, - 0x92,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0xee,0x1f, - 0xe2,0x86,0xdf,0xdf,0xef,0x10,0x00,0x05, - 0x00}}, - {{0x51,0x31,0x31,0x95,0x36,0x04,0x66,0xf0, - 0x5a,0x8e,0x57,0x57,0x67,0x20,0x00,0x01, - 0x01}}, - {{0x5f,0x3f,0x3f,0x83,0x44,0x92,0x0e,0xf5, - 0x02,0x86,0xff,0xff,0x0f,0x10,0x00,0x01, - 0x01}}, - {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x0e,0x5a, - 0x02,0x86,0xff,0xff,0x0f,0x09,0x00,0x05, - 0x01}}, - {{0x76,0x56,0x56,0x9a,0x5b,0x89,0x28,0x10, - 0x1c,0x80,0x19,0x19,0x29,0x0b,0x00,0x05, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_1_H[]= -{ /* MISSING */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT1800x600_2[]= -{ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_2[]= -{ /* Checked (1.10.6s) */ - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_2[]= -{ /* Checked (1.10.6s) */ - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_2[]= -{ /* Checked (1.10.6s) */ - {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x03, - 0x00}}, - {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xc2,0x86,0x5d,0x5d,0x29,0x01,0x00,0x03, - 0x01}}, - {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x03, - 0x00}}, - {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xc2,0x86,0x5d,0x5d,0x29,0x01,0x00,0x03, - 0x00}}, - {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9e, - 0x03,0x87,0xdf,0xdf,0x29,0x01,0x00,0x03, - 0x00}}, - {{0xce,0x63,0x63,0x92,0x96,0x04,0x28,0xd4, - 0x3f,0x83,0x57,0x57,0x29,0x01,0x00,0x07, - 0x01}}, - {{0xce,0x7f,0x7f,0x92,0xa4,0x12,0x28,0xd4, - 0x93,0x87,0xff,0xff,0x29,0x21,0x00,0x07, - 0x01}}, - {{0xce,0x9f,0x9f,0x92,0xb4,0x02,0x28,0x5a, - 0x13,0x87,0xff,0xff,0x29,0x29,0x00,0x03, - 0x01}}, - {{0xce,0xae,0xae,0x92,0xbc,0x0a,0x28,0x10, - 0x20,0x84,0x19,0x19,0x29,0x0f,0x00,0x03, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_2[]= -{ /* MISSING */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT1800x600_2_H[]= -{ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_2_H[]= -{ /* Checked (1.10.6s) */ - {{0x4f,0x27,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x8d,0x5d,0x25,0x30,0x00,0x01, /* <-- invalid data */ - 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x31,0x31,0x93,0x3e,0x06,0x24,0xf1, - 0xae,0x84,0x57,0x57,0x25,0x30,0x00,0x01, /* <-- invalid data */ - 0x01 }}, - {{0x4f,0x3f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x01, - 0x01 }} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_2_H[]= -{ /* Checked (1.10.6s) */ - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x31,0x31,0x93,0x3e,0x86,0x24,0xf1, - 0xae,0x84,0x57,0x57,0x25,0x30,0x00,0x01, - 0x01 }}, - {{0x4f,0x3f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x01, - 0x01 }} + {1232, 722}, + { 0, 805}, + { 0, 794}, + { 0, 0} }; -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_2_H[]= -{ /* Checked (1.10.6s) */ - {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x06, - 0x00}}, - {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xc2,0x86,0x5d,0x5d,0x29,0x01,0x00,0x06, - 0x00}}, - {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x06, - 0x00}}, - {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xc2,0x86,0x5d,0x5d,0x29,0x01,0x00,0x06, - 0x00}}, - {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9e, - 0x03,0x87,0xdf,0xdf,0x29,0x01,0x00,0x06, - 0x00}}, - {{0x9c,0x31,0x31,0x80,0x64,0x92,0x28,0xd4, - 0x3f,0x83,0x57,0x57,0x29,0x01,0x00,0x06, - 0x01}}, - {{0x8e,0x3f,0x3f,0x92,0x64,0x12,0x28,0xd4, - 0x93,0x87,0xff,0xff,0x29,0x21,0x00,0x06, - 0x01}}, - {{0x7e,0x4f,0x4f,0x82,0x64,0x12,0x28,0x5a, - 0x13,0x87,0xff,0xff,0x29,0x29,0x00,0x06, - 0x01}}, - {{0x76,0x56,0x56,0x9a,0x64,0x92,0x28,0x10, - 0x20,0x84,0x19,0x19,0x29,0x0f,0x00,0x05, - 0x00}} +static const SiS310_LVDSDesStruct SiS310_PanelType0e_2[]= +{ + {1152, 622}, + {1152, 597}, + {1152, 622}, + {1152, 597}, + {1152, 662}, + {1232, 722}, + { 0, 805}, + { 0, 794}, + { 0, 0} }; -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_2_H[]= -{ /* MISSING */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} +static const SiS310_LVDSDesStruct SiS310_PanelType0f_2[] = +{ + {1152, 622}, + {1152, 597}, + {1152, 622}, + {1152, 597}, + {1152, 662}, + {1232, 722}, + { 0, 805}, + { 0, 794}, + { 0, 0} }; +/* CRT1 CRTC for SlaveModes and LCDA */ + typedef struct _SiS310_LVDSCRT1DataStruct { UCHAR CR[15]; } SiS310_LVDSCRT1DataStruct; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1320x480_1[] = +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1[] = { - {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f, + {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f, 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, 0x00 }}, - {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + {{0x6b,0x4f,0x8f,0x55,0x85,0x78,0x1f, 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, 0x00 }}, - {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, 0x00 }}, - {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + {{0x6b,0x4f,0x8f,0x55,0x85,0x78,0x1f, 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, 0x00 }}, - {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e, + {{0x6b,0x4f,0x8f,0x55,0x85,0xfa,0x1f, 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, 0x00 }}, - {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + {{0x7f,0x63,0x83,0x69,0x19,0x72,0xf0, 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, - 0x01 }}, - {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e, - 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, - 0x00 }} + 0x01 }} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1[] = +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1_H[] = { - {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f, + {{0x43,0x27,0x87,0x2d,0x1d,0xaa,0x1f, 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, 0x00 }}, - {{0x6b,0x4f,0x8f,0x55,0x85,0x78,0x1f, + {{0x43,0x27,0x87,0x2d,0x1d,0x78,0x1f, 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, 0x00 }}, - {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + {{0x43,0x27,0x87,0x2d,0x1d,0xfa,0x1f, + 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, 0x00 }}, - {{0x6b,0x4f,0x8f,0x55,0x85,0x78,0x1f, + {{0x43,0x27,0x87,0x2d,0x1d,0x78,0x1f, 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, 0x00 }}, - {{0x6b,0x4f,0x8f,0x55,0x85,0xfa,0x1f, + {{0x43,0x27,0x87,0x2d,0x1d,0xfa,0x1f, 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, 0x00 }}, + {{0x4d,0x31,0x91,0x37,0x07,0x72,0xf0, + 0x58,0x8d,0x57,0x73,0x20,0x00,0x01, + 0x01 }} +}; + +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_2[]= +{ + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, + 0xff,0x84,0x8f,0x73,0x00,0x00,0x06, + 0x00 }}, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, + 0xe6,0x8b,0x5d,0x73,0x00,0x00,0x06, + 0x00 }}, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, + 0xff,0x84,0x8f,0x73,0x00,0x00,0x06, + 0x00 }}, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, + 0xe6,0x8b,0x5d,0x73,0x00,0x00,0x06, + 0x00 }}, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0xba, + 0x27,0x8c,0xdf,0x73,0x00,0x00,0x06, + 0x00 }}, {{0x7f,0x63,0x83,0x69,0x19,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x58,0x8d,0x57,0x73,0x20,0x00,0x06, + 0x01 }} +}; + +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_2_H[] = +{ + {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, + 0xff,0x84,0x8f,0x73,0x00,0x00,0x01, + 0x00 }}, + {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, + 0xd6,0x8b,0x5d,0x73,0x00,0x00,0x01, + 0x00 }}, + {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, + 0xff,0x84,0x8f,0x73,0x00,0x00,0x01, + 0x00 }}, + {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, + 0xd6,0x8b,0x5d,0x73,0x00,0x00,0x01, + 0x00 }}, + {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0xba, + 0x27,0x8c,0xdf,0x73,0x00,0x00,0x01, + 0x00 }}, + {{0x4d,0x31,0x91,0x3a,0x0a,0x72,0xf0, + 0x63,0x88,0x57,0x73,0x00,0x00,0x01, 0x01 }} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1[] = +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1[] = { {{0x73,0x4f,0x97,0x53,0x84,0xb4,0x1f, 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, @@ -3677,57 +2326,7 @@ static const SiS310_LVDSCRT1DataStruct 0x01}} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1[] = -{ - {{0x7e,0x4f,0x82,0x58,0x04,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x82,0x58,0x04,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x82,0x58,0x04,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x82,0x58,0x04,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x82,0x58,0x04,0x08,0x3e, - 0xe0,0x84,0xdf,0x09,0x00,0x00,0x06, - 0x00}}, - {{0x92,0x63,0x96,0x6c,0x18,0x80,0xf0, - 0x58,0x8c,0x57,0x81,0x20,0x00,0x06, - 0x01}}, - {{0xae,0x7f,0x92,0x88,0x94,0x28,0xf5, - 0x00,0x84,0xff,0x29,0x10,0x00,0x02, - 0x01}}, - {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a, - 0x00,0x84,0xff,0x29,0x09,0x00,0x07, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1_H[] = -{ - {{0x43,0x27,0x87,0x2d,0x1d,0xaa,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, - 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0x78,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, - 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0xfa,0x1f, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, - 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0x78,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, - 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0xfa,0x1f, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, - 0x00 }}, - {{0x4d,0x31,0x91,0x37,0x07,0x72,0xf0, - 0x58,0x8d,0x57,0x73,0x20,0x00,0x01, - 0x01 }} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1_H[] = +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1_H[] = { {{0x4b,0x27,0x8f,0x2b,0x1c,0xb4,0x1f, 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, @@ -3752,55 +2351,8 @@ static const SiS310_LVDSCRT1DataStruct 0x01 }} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1_H[] = -{ - {{0x56,0x27,0x9a,0x31,0x1c,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x56,0x27,0x9a,0x31,0x1c,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x05, - 0x00}}, - {{0x56,0x27,0x9a,0x31,0x1c,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x56,0x27,0x9a,0x31,0x1c,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x05, - 0x01}}, - {{0x56,0x27,0x9a,0x31,0x1c,0x08,0x3e, - 0xe0,0x84,0xdf,0x09,0x00,0x00,0x05, - 0x00}}, - {{0x60,0x31,0x84,0x3a,0x86,0x80,0xf0, - 0x58,0x8c,0x57,0x81,0x20,0x00,0x01, - 0x01}}, - {{0x6e,0x3f,0x92,0x48,0x94,0x28,0xf5, - 0x00,0x84,0xff,0x29,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_2[]= +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_2[] = { - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xff,0x84,0x8f,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xe6,0x8b,0x5d,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xff,0x84,0x8f,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xe6,0x8b,0x5d,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0xba, - 0x27,0x8c,0xdf,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x63,0x83,0x69,0x19,0x72,0xf0, - 0x58,0x8d,0x57,0x73,0x20,0x00,0x06, - 0x01 }} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_2[] = -{ {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, 0x57,0x8e,0x8f,0x25,0x30,0x00,0x06, 0x00 }}, @@ -3824,6 +2376,84 @@ static const SiS310_LVDSCRT1DataStruct 0x01 }} }; +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_2_H[] = +{ + {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x57,0x8e,0x8f,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x3e,0x85,0x5d,0x25,0x10,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x57,0x8e,0x8f,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x3e,0x85,0x5d,0x25,0x10,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x7f,0x86,0xdf,0x25,0x10,0x00,0x01, + 0x00 }}, + {{0x71,0x31,0x95,0x46,0x97,0x24,0xf1, + 0xbb,0x82,0x57,0x25,0x10,0x00,0x01, + 0x01 }}, + {{0x63,0x3f,0x87,0x46,0x97,0x24,0xf5, + 0x0f,0x86,0xff,0x25,0x30,0x00,0x01, + 0x01 }} +}; + +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1[] = +{ + {{0x7e,0x4f,0x82,0x58,0x04,0xb8,0x1f, + 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x82,0x58,0x04,0x86,0x1f, + 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x82,0x58,0x04,0xb8,0x1f, + 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x82,0x58,0x04,0x86,0x1f, + 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x82,0x58,0x04,0x08,0x3e, + 0xe0,0x84,0xdf,0x09,0x00,0x00,0x06, + 0x00}}, + {{0x92,0x63,0x96,0x6c,0x18,0x80,0xf0, + 0x58,0x8c,0x57,0x81,0x20,0x00,0x06, + 0x01}}, + {{0xae,0x7f,0x92,0x88,0x94,0x28,0xf5, + 0x00,0x84,0xff,0x29,0x10,0x00,0x02, + 0x01}}, + {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a, + 0x00,0x84,0xff,0x29,0x09,0x00,0x07, + 0x01}} +}; + +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1_H[] = +{ + {{0x56,0x27,0x9a,0x31,0x1c,0xb8,0x1f, + 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x56,0x27,0x9a,0x31,0x1c,0x86,0x1f, + 0x5e,0x82,0x5d,0x87,0x10,0x00,0x05, + 0x00}}, + {{0x56,0x27,0x9a,0x31,0x1c,0xb8,0x1f, + 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x56,0x27,0x9a,0x31,0x1c,0x86,0x1f, + 0x5e,0x82,0x5d,0x87,0x10,0x00,0x05, + 0x01}}, + {{0x56,0x27,0x9a,0x31,0x1c,0x08,0x3e, + 0xe0,0x84,0xdf,0x09,0x00,0x00,0x05, + 0x00}}, + {{0x60,0x31,0x84,0x3a,0x86,0x80,0xf0, + 0x58,0x8c,0x57,0x81,0x20,0x00,0x01, + 0x01}}, + {{0x6e,0x3f,0x92,0x48,0x94,0x28,0xf5, + 0x00,0x84,0xff,0x29,0x10,0x00,0x01, + 0x01}} +}; + static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2[] = { {{0xce,0x72,0x91,0x81,0x8f,0x28,0x92, @@ -3852,53 +2482,6 @@ static const SiS310_LVDSCRT1DataStruct 0x01}} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_2_H[] = -{ - {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, - 0xff,0x84,0x8f,0x73,0x00,0x00,0x01, - 0x00 }}, - {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, - 0xd6,0x8b,0x5d,0x73,0x00,0x00,0x01, - 0x00 }}, - {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, - 0xff,0x84,0x8f,0x73,0x00,0x00,0x01, - 0x00 }}, - {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, - 0xd6,0x8b,0x5d,0x73,0x00,0x00,0x01, - 0x00 }}, - {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0xba, - 0x27,0x8c,0xdf,0x73,0x00,0x00,0x01, - 0x00 }}, - {{0x4d,0x31,0x91,0x3a,0x0a,0x72,0xf0, - 0x63,0x88,0x57,0x73,0x00,0x00,0x01, - 0x01 }} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_2_H[] = -{ - {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, - 0x57,0x8e,0x8f,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, - 0x3e,0x85,0x5d,0x25,0x10,0x00,0x01, - 0x00 }}, - {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, - 0x57,0x8e,0x8f,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, - 0x3e,0x85,0x5d,0x25,0x10,0x00,0x01, - 0x00 }}, - {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, - 0x7f,0x86,0xdf,0x25,0x10,0x00,0x01, - 0x00 }}, - {{0x71,0x31,0x95,0x46,0x97,0x24,0xf1, - 0xbb,0x82,0x57,0x25,0x10,0x00,0x01, - 0x01 }}, - {{0x63,0x3f,0x87,0x46,0x97,0x24,0xf5, - 0x0f,0x86,0xff,0x25,0x30,0x00,0x01, - 0x01 }} -}; - static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2_H[] = { {{0xa6,0x4a,0x89,0x59,0x07,0x28,0x92, @@ -3924,63 +2507,7 @@ static const SiS310_LVDSCRT1DataStruct 0x01}} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1XXXxXXX_1[] = -{ - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, - 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x05, - 0x00}}, - {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}}, - {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a, - 0x00,0x84,0xff,0x29,0x09,0x00,0x07, - 0x01}}, - {{0xce,0x9f,0x92,0xa9,0x17,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x07, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1XXXxXXX_1_H[] = -{ - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0x0b,0x3e, - 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, - 0x00}}, - {{0x4d,0x31,0x91,0x3b,0x03,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x01, - 0x01}}, - {{0x63,0x3f,0x87,0x4a,0x92,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1[] = +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1[] = { {{0x6f,0x4f,0x93,0x54,0x82,0x9e,0x1f, 0x8f,0x81,0x8f,0x9f,0x30,0x00,0x05, @@ -4220,332 +2747,39 @@ static const SiS310_LVDSCRT1DataStruct #endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x768_1[] = -{ - {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f, - 0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01, - 0x00}}, - {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f, - 0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01, - 0x00}}, - {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f, - 0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01, - 0x00}}, - {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f, - 0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01, - 0x00}}, - {{0x5b,0x4f,0x9f,0x55,0x19,0x04,0x3e, - 0xec,0x8e,0xdf,0x05,0x20,0x00,0x01, - 0x00}}, - {{0x6f,0x63,0x93,0x69,0x8d,0x7c,0xf0, - 0x64,0x86,0x57,0x7d,0x20,0x00,0x05, - 0x01}}, - {{0x8b,0x7f,0x8f,0x85,0x09,0x24,0xf5, - 0x0c,0x8e,0xff,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5, - 0x0c,0x8e,0xff,0x25,0x30,0x00,0x06, - 0x01}}, - {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5, - 0x0c,0x8e,0xff,0x25,0x30,0x00,0x06, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x768_1_H[] = +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1[] = { - {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, - 0x93,0x86,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x30,0x1e,0x9e,0x1f, - 0x92,0x86,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0xee,0x1f, - 0xe2,0x86,0xdf,0xef,0x10,0x00,0x05, + {{0x83,0x4F,0x87,0x5B,0x13,0x06,0x3E, + 0xB3,0x86,0x8F,0x07,0x20,0x00,0x06, 0x00}}, - {{0x51,0x31,0x95,0x36,0x04,0x66,0xf0, - 0x5a,0x8e,0x57,0x67,0x20,0x00,0x01, - 0x01}}, - {{0x5f,0x3f,0x83,0x44,0x92,0x0e,0xf5, - 0x02,0x86,0xff,0x0f,0x10,0x00,0x01, - 0x01}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a, - 0x02,0x86,0xff,0x0f,0x09,0x00,0x05, - 0x01}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a, - 0x02,0x86,0xff,0x0f,0x09,0x00,0x05, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x768_2[] = -{ - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, - 0x54,0x86,0xdb,0xda,0x00,0x00,0x02, + {{0x83,0x4F,0x87,0x5B,0x13,0xD4,0x1F, + 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, 0x00}}, - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, - 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02, + {{0x83,0x4F,0x87,0x5B,0x13,0x06,0x3E, + 0xB3,0x86,0x8F,0x07,0x20,0x00,0x06, 0x00}}, - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, - 0x54,0x86,0xdb,0xda,0x00,0x00,0x02, + {{0x83,0x4F,0x87,0x5B,0x13,0xD4,0x1F, + 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, 0x00}}, - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, - 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02, + {{0x83,0x4F,0x87,0x5B,0x13,0x56,0xBA, + 0x03,0x86,0xDF,0x57,0x00,0x00,0x06, 0x00}}, - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xb3, - 0x7c,0x8e,0x03,0x02,0x10,0x00,0x02, - 0x01}}, - {{0xab,0x63,0x8f,0x8a,0x8e,0x24,0xf1, - 0xb6,0x88,0x57,0x25,0x10,0x00,0x02, + {{0x97,0x63,0x9B,0x6F,0x07,0xCE,0xF0, + 0x7B,0x8E,0x57,0xCF,0x20,0x00,0x02, 0x01}}, - {{0xab,0x7f,0x8f,0x98,0x9c,0x24,0xf5, - 0x0a,0x8c,0xff,0x25,0x30,0x00,0x02, + {{0xB3,0x7F,0x97,0x8B,0x83,0x76,0xF5, + 0x23,0x86,0xFF,0x77,0x10,0x00,0x06, 0x01}}, - {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, - 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, + {{0xD3,0x9F,0x97,0xAB,0x03,0x76,0x5A, + 0x23,0x86,0xFF,0x77,0x09,0x00,0x03, 0x01}}, - {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, - 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x768_2_H[] = -{ - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, - 0x54,0x86,0xdb,0xda,0x00,0x00,0x01, + {{0xE2,0xAE,0x86,0xBA,0x92,0x90,0x10, + 0x3D,0x80,0x19,0x91,0x0F,0x00,0x03, 0x00}}, - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, - 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01, - 0x00}}, - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, - 0x54,0x86,0xdb,0xda,0x00,0x00,0x01, - 0x00}}, - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, - 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01, - 0x00}}, - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xb3, - 0x7c,0x8e,0x03,0x02,0x10,0x00,0x01, - 0x01}}, - {{0x79,0x31,0x9d,0x58,0x9c,0x24,0xf1, - 0xb6,0x88,0x57,0x25,0x10,0x00,0x01, - 0x01}}, - {{0x6b,0x3f,0x8f,0x58,0x9c,0x24,0xf5, - 0x0a,0x8c,0xff,0x25,0x30,0x00,0x01, - 0x01}}, - {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, - 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, - 0x01}}, - {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, - 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x600_1[] = -{ - {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, - 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, - 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, - 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, - 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0xaf,0xba, - 0x3b,0x82,0xdf,0xb0,0x00,0x00,0x01, - 0x00}}, - {{0x7e,0x63,0x82,0x68,0x15,0x1e,0xf1, - 0xae,0x85,0x57,0x1f,0x30,0x00,0x26, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x1e,0xf1, - 0xae,0x85,0x57,0x1f,0x30,0x00,0x02, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x600_1_H[] = -{ - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, - 0x00}}, - {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x600_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x600_2_H[] = -{ - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x01, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11152x768_1[] = -{ - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, - 0x00}}, - {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11152x768_1_H[] = -{ - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, - 0x00}}, - {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11152x768_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11152x768_2_H[] = -{ - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x01, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1[] = -{ + {{0xFB,0xC7,0x9F,0xD3,0x8B,0x26,0x11, + 0xD3,0x86,0xAF,0x27,0x3F,0x00,0x07, + 0x00}} +#if 0 {{0x83,0x4f,0x87,0x51,0x09,0xc0,0x1f, 0x90,0x84,0x8f,0xc1,0x30,0x00,0x06, 0x00}}, @@ -4576,10 +2810,42 @@ static const SiS310_LVDSCRT1DataStruct {{0xfb,0xc7,0x9f,0xc9,0x81,0xe0,0x10, 0xb0,0x84,0xaf,0xe1,0x2f,0x00,0x07, 0x00}} +#endif }; static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1_H[] = -{ +{ + {{0x5B,0x27,0x9F,0x33,0x0B,0x06,0x2E, + 0xB3,0x86,0x8F,0x07,0x20,0x00,0x01, + 0x00}}, + {{0x5B,0x27,0x9F,0x29,0x01,0x8E,0x1F, + 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, + 0x00}}, + {{0x5B,0x27,0x9F,0x33,0x0B,0x06,0x2E, + 0xB3,0x86,0x8F,0x07,0x20,0x00,0x01, + 0x00}}, + {{0x83,0x4F,0x87,0x5B,0x13,0xD4,0x1F, + 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, + 0x00}}, + {{0x5B,0x27,0x9F,0x33,0x0B,0x56,0xBA, + 0x03,0x86,0xDF,0x57,0x00,0x00,0x01, + 0x00}}, + {{0x65,0x31,0x89,0x3D,0x95,0xCE,0xF0, + 0x7B,0x8E,0x57,0xCF,0x20,0x00,0x01, + 0x01}}, + {{0x73,0x3F,0x97,0x4B,0x83,0x76,0xF5, + 0x23,0x86,0xFF,0x77,0x10,0x00,0x05, + 0x01}}, + {{0xD3,0x9F,0x97,0xAB,0x03,0x76,0x5A, + 0x23,0x86,0xFF,0x77,0x09,0x00,0x03, + 0x01}}, + {{0xE2,0xAE,0x86,0xBA,0x92,0x90,0x10, + 0x3D,0x80,0x19,0x91,0x0F,0x00,0x03, + 0x00}}, + {{0x97,0x63,0x9B,0x6F,0x07,0xE0,0x10, + 0xB0,0x84,0xAF,0xE1,0x2F,0x00,0x06, + 0x00}} +#if 0 {{0x5b,0x27,0x9f,0x29,0x01,0xc0,0x1f, 0x90,0x84,0x8f,0xc1,0x30,0x00,0x01, 0x00}}, @@ -4610,10 +2876,42 @@ static const SiS310_LVDSCRT1DataStruct {{0x97,0x63,0x9b,0x65,0x1d,0xe0,0x10, 0xb0,0x84,0xaf,0xe1,0x2f,0x00,0x06, 0x00}} +#endif }; static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_2[] = -{ +{ + {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x97, + 0x43,0x86,0xDB,0xDA,0x11,0x00,0x07, + 0x01}}, + {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x97, + 0x2A,0x8D,0xC2,0xC1,0x11,0x00,0x07, + 0x01}}, + {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x97, + 0x43,0x86,0xDB,0xDA,0x11,0x00,0x07, + 0x01}}, + {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x97, + 0x2A,0x8D,0xC2,0xC1,0x11,0x00,0x07, + 0x01}}, + {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x9F, + 0x6B,0x8E,0x03,0x02,0x01,0x00,0x07, + 0x01}}, + {{0xFB,0x63,0x9F,0xA1,0x99,0x26,0xD5, + 0xA7,0x8A,0xBF,0xBE,0x01,0x00,0x07, + 0x01}}, + {{0xFB,0x7F,0x9F,0xAF,0x87,0x26,0xDD, + 0xFB,0x8E,0x13,0x12,0x31,0x00,0x03, + 0x01}}, + {{0xFB,0x9F,0x9F,0xBF,0x97,0x26,0x5B, + 0x7B,0x8E,0xFF,0x27,0x39,0x00,0x03, + 0x01}}, + {{0xFB,0xAE,0x9F,0xC6,0x9E,0x26,0x11, + 0x88,0x8B,0x19,0x27,0x1F,0x00,0x03, + 0x00}}, + {{0xFB,0xC7,0x9F,0xD3,0x8B,0x26,0x11, + 0xD3,0x86,0xAF,0x27,0x3F,0x00,0x07, + 0x00}} +#if 0 {{0xfb,0x88,0x87,0x90,0x08,0xe0,0x96, 0x20,0x84,0xb9,0xb8,0x01,0x00,0x07, 0x01}}, @@ -4644,10 +2942,42 @@ static const SiS310_LVDSCRT1DataStruct {{0xfb,0xc7,0x9f,0xc9,0x84,0xe0,0x10, 0xc7,0x8b,0xaf,0xe1,0x0f,0x00,0x07, 0x00}} +#endif }; static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_2_H[] = -{ +{ + {{0xD3,0x5F,0x9E,0x6F,0x07,0x26,0x97, + 0x43,0x86,0xDB,0xDA,0x11,0x00,0x02, + 0x01}}, + {{0xD3,0x27,0x97,0x6F,0x07,0x26,0x97, + 0x6B,0x8E,0x83,0x82,0x01,0x00,0x03, + 0x01}}, + {{0xD3,0x5F,0x9E,0x6F,0x07,0x26,0x97, + 0x43,0x86,0xDB,0xDA,0x11,0x00,0x02, + 0x01}}, + {{0xD3,0x27,0x97,0x6F,0x07,0x26,0x97, + 0x07,0x8B,0xA0,0x9F,0x01,0x00,0x02, + 0x01}}, + {{0xD3,0x27,0x97,0x6F,0x07,0x26,0x97, + 0x6B,0x8E,0x83,0x82,0x01,0x00,0x03, + 0x01}}, + {{0xC9,0x31,0x8D,0x6F,0x07,0x26,0xD5, + 0xA7,0x8A,0xBF,0xBE,0x01,0x00,0x03, + 0x01}}, + {{0xBB,0x3F,0x9F,0x6F,0x87,0x26,0xDD, + 0xFB,0x8E,0x13,0x12,0x31,0x00,0x02, + 0x01}}, + {{0xAB,0x4F,0x8F,0x68,0x80,0xE0,0x5A, + 0x6F,0x83,0xFF,0xE1,0x29,0x00,0x02, + 0x01}}, + {{0xA3,0x56,0x87,0x67,0x9F,0xE0,0x10, + 0x7C,0x80,0x19,0xE1,0x0F,0x00,0x06, + 0x00}}, + {{0x97,0x63,0x9B,0x68,0x00,0xE0,0x10, + 0xC7,0x8B,0xAF,0xE1,0x0F,0x00,0x02, + 0x00}} +#if 0 {{0xd3,0x60,0x9f,0x68,0x00,0xe0,0x96, 0x20,0x84,0xb9,0xb8,0x01,0x00,0x02, 0x01}}, @@ -4678,135 +3008,111 @@ static const SiS310_LVDSCRT1DataStruct {{0x97,0x63,0x9b,0x68,0x00,0xe0,0x10, 0xc7,0x8b,0xaf,0xe1,0x0f,0x00,0x02, 0x00}} +#endif }; +/* CRT1 CRTC for Chrontel TV slave modes */ static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1UNTSC[] = { - {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, - 0xe8,0x84,0x8f,0x57,0x20,0x00,0x01, - 0x00 }}, - {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, - 0xd0,0x82,0x5d,0x57,0x00,0x00,0x01, - 0x00 }}, - {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, - 0xe8,0x84,0x8f,0x57,0x20,0x00,0x01, - 0x00 }}, - {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, - 0xd0,0x82,0x5d,0x57,0x00,0x00,0x01, - 0x00 }}, - {{0x5d,0x4f,0x81,0x56,0x99,0x56,0xba, - 0x0a,0x84,0xdf,0x57,0x00,0x00,0x01, - 0x00 }}, - {{0x80,0x63,0x84,0x6d,0x0f,0xec,0xf0, - 0x7a,0x8f,0x57,0xed,0x20,0x00,0x06, - 0x01 }}, - {{0x8c,0x7f,0x90,0x86,0x09,0xaf,0xf5, /* TW: 1024x768 */ - 0x36,0x88,0xff,0xb0,0x10,0x00,0x02, - 0x01}} + {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, + 0xe8,0x84,0x8f,0x57,0x20,0x00,0x01, + 0x00 }}, + {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, + 0xd0,0x82,0x5d,0x57,0x00,0x00,0x01, + 0x00 }}, + {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, + 0xe8,0x84,0x8f,0x57,0x20,0x00,0x01, + 0x00 }}, + {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, + 0xd0,0x82,0x5d,0x57,0x00,0x00,0x01, + 0x00 }}, + {{0x5d,0x4f,0x81,0x56,0x99,0x56,0xba, + 0x0a,0x84,0xdf,0x57,0x00,0x00,0x01, + 0x00 }}, + {{0x80,0x63,0x84,0x6d,0x0f,0xec,0xf0, + 0x7a,0x8f,0x57,0xed,0x20,0x00,0x06, + 0x01 }}, + {{0x8c,0x7f,0x90,0x86,0x09,0xaf,0xf5, + 0x36,0x88,0xff,0xb0,0x10,0x00,0x02, + 0x01}} }; -static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1ONTSC[] = -{ - {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, - 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, - 0xb0,0x8d,0x5d,0x0c,0x00,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, - 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, - 0xb0,0x8d,0x5d,0x0c,0x00,0x00,0x01, - 0x00 }}, - {{0x5d,0x4f,0x81,0x58,0x9d,0x0b,0x3e, - 0xe8,0x84,0xdf,0x0c,0x00,0x00,0x01, - 0x00 }}, - {{0x7d,0x63,0x81,0x68,0x0e,0xba,0xf0, - 0x78,0x8a,0x57,0xbb,0x20,0x00,0x06, - 0x01 }}, - {{0x8c,0x7f,0x90,0x82,0x06,0x46,0xf5, /* TW: 1024x768 */ - 0x15,0x88,0xff,0x47,0x70,0x00,0x02, - 0x01 }} +static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1ONTSC[] = +{ + {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, + 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, + 0xb0,0x8d,0x5d,0x0c,0x00,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, + 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, + 0xb0,0x8d,0x5d,0x0c,0x00,0x00,0x01, + 0x00 }}, + {{0x5d,0x4f,0x81,0x58,0x9d,0x0b,0x3e, + 0xe8,0x84,0xdf,0x0c,0x00,0x00,0x01, + 0x00 }}, + {{0x7d,0x63,0x81,0x68,0x0e,0xba,0xf0, + 0x78,0x8a,0x57,0xbb,0x20,0x00,0x06, + 0x01 }}, + {{0x8c,0x7f,0x90,0x82,0x06,0x46,0xf5, + 0x15,0x88,0xff,0x47,0x70,0x00,0x02, + 0x01 }} }; static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1UPAL[] = { - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, - 0x00 }}, - {{0x64,0x4f,0x88,0x5a,0x9f,0x6f,0xba, - 0x15,0x83,0xdf,0x70,0x00,0x00,0x01, - 0x00 }}, - {{0x73,0x63,0x97,0x69,0x8b,0xec,0xf0, - 0x90,0x8c,0x57,0xed,0x20,0x00,0x05, - 0x01 }}, - {{0xaa,0x7f,0x8e,0x8e,0x96,0xe6,0xf5, /* TW: 1024x768 */ - 0x50,0x88,0xff,0xe7,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1OPAL[] = -{ - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, - 0x00 }}, - {{0x64,0x4f,0x88,0x58,0x9d,0x6f,0xba, - 0x15,0x83,0xdf,0x70,0x00,0x00,0x01, - 0x00 }}, - {{0x71,0x63,0x95,0x69,0x8c,0x6f,0xf0, - 0x5a,0x8b,0x57,0x70,0x20,0x00,0x05, - 0x01 }}, - {{0xaa,0x7f,0x8e,0x8f,0x96,0x69,0xf5, /* TW: 1024x768 */ - 0x28,0x88,0xff,0x6a,0x10,0x00,0x02, - 0x01 }} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1SOPAL[] = -{ - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, - 0x00 }}, - {{0x64,0x4f,0x88,0x58,0x9d,0x6f,0xba, - 0x15,0x83,0xdf,0x70,0x00,0x00,0x01, - 0x00 }}, - {{0x71,0x63,0x95,0x69,0x8c,0x6f,0xf0, - 0x5a,0x8b,0x57,0x70,0x20,0x00,0x05, - 0x01 }}, - {{0xaa,0x7f,0x8e,0x8f,0x96,0x69,0xf5, /* TW: 1024x768 */ - 0x28,0x88,0xff,0x6a,0x10,0x00,0x02, - 0x01 }} + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05, + 0x00 }}, + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, + 0x00 }}, + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05, + 0x00 }}, + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, + 0x00 }}, + {{0x64,0x4f,0x88,0x5a,0x9f,0x6f,0xba, + 0x15,0x83,0xdf,0x70,0x00,0x00,0x01, + 0x00 }}, + {{0x73,0x63,0x97,0x69,0x8b,0xec,0xf0, + 0x90,0x8c,0x57,0xed,0x20,0x00,0x05, + 0x01 }}, + {{0xaa,0x7f,0x8e,0x8e,0x96,0xe6,0xf5, + 0x50,0x88,0xff,0xe7,0x10,0x00,0x02, + 0x01}} +}; + +static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1OPAL[] = +{ + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, + 0x00 }}, + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, + 0x00 }}, + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, + 0x00 }}, + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, + 0x00 }}, + {{0x64,0x4f,0x88,0x58,0x9d,0x6f,0xba, + 0x15,0x83,0xdf,0x70,0x00,0x00,0x01, + 0x00 }}, + {{0x71,0x63,0x95,0x69,0x8c,0x6f,0xf0, + 0x5a,0x8b,0x57,0x70,0x20,0x00,0x05, + 0x01 }}, + {{0xaa,0x7f,0x8e,0x8f,0x96,0x69,0xf5, + 0x28,0x88,0xff,0x6a,0x10,0x00,0x02, + 0x01 }} }; -/* TW: Data for Chrontel 7019 */ typedef struct _SiS310_CHTVRegDataStruct { UCHAR Reg[16]; @@ -4814,118 +3120,131 @@ typedef struct _SiS310_CHTVRegDataStruct static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_UNTSC[] = { - {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x6a,0x77,0xbb,0x6e,0x84,0x2e,0x02,0x5a,0x04,0x00,0x80,0x20,0x7e,0x80,0x98,0x00}}, - {{0xcf,0x77,0xb7,0xc8,0x84,0x3b,0x02,0x5a,0x04,0x00,0x80,0x19,0x88,0x30,0x7f,0x00}}, - {{0xee,0x77,0xbb,0x66,0x87,0x32,0x01,0x5a,0x04,0x00,0x80,0x1b,0xd3,0xf2,0x36,0x00}} -}; + {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x6a,0x77,0xbb,0x6e,0x84,0x2e,0x02,0x5a,0x04,0x00,0x80,0x20,0x7e,0x80,0x98,0x00}}, + {{0xcf,0x77,0xb7,0xc8,0x84,0x3b,0x02,0x5a,0x04,0x00,0x80,0x19,0x88,0x30,0x7f,0x00}}, + {{0xee,0x77,0xbb,0x66,0x87,0x32,0x01,0x5a,0x04,0x00,0x80,0x1b,0xd3,0xf2,0x36,0x00}} +}; /* WRONG: 0x02: should be 0xfx, because if CIVEnable is clear, this should be set; + 0x07: Blacklevel: NTSC/PAL-M: Should be 131 (0x83), and not 0x50/0x5a + PAL/PAL-N: 110 (0x6e) + NTSC-J: 102 (0x66) + 0x0c-0x0f: CIV is not default as in datasheet + MISSING: 0x21: Should set D1 to ZERO (for NTSC, PAL-M) or ONE (PAL, NTSC-J) + Most of this is wrong in all NTSC and PAL register arrays. But I won't correct + it as long as it works. For NTSC-J, the blacklevel is corrected in init301.c; + for PAL-M and PAL-N all above is corrected. + */ static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_ONTSC[] = { - {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x69,0x77,0xbb,0x6e,0x84,0x1e,0x00,0x5a,0x04,0x00,0x80,0x25,0x1a,0x43,0x04,0x00}}, - {{0xce,0x77,0xb7,0xb6,0x83,0x2c,0x02,0x5a,0x04,0x00,0x80,0x1c,0x00,0x82,0x97,0x00}}, - {{0xed,0x77,0xbb,0x66,0x8c,0x21,0x02,0x5a,0x04,0x00,0x80,0x1f,0x9f,0xc1,0x0c,0x00}} + {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x69,0x77,0xbb,0x6e,0x84,0x1e,0x00,0x5a,0x04,0x00,0x80,0x25,0x1a,0x43,0x04,0x00}}, + {{0xce,0x77,0xb7,0xb6,0x83,0x2c,0x02,0x5a,0x04,0x00,0x80,0x1c,0x00,0x82,0x97,0x00}}, + {{0xed,0x77,0xbb,0x66,0x8c,0x21,0x02,0x5a,0x04,0x00,0x80,0x1f,0x9f,0xc1,0x0c,0x00}} }; static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_UPAL[] = { - {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x80,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x12,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x26,0x2a,0x55,0x5d,0x00}}, - {{0xc3,0x7f,0xb7,0x7a,0x84,0x40,0x02,0x5a,0x05,0x00,0x80,0x1f,0x84,0x3d,0x28,0x00}}, - {{0xe5,0x7f,0xb7,0x1d,0xa7,0x3e,0x04,0x5a,0x05,0x00,0x80,0x20,0x3e,0xe4,0x22,0x00}} + {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x41,0x7f,0xb7,0x80,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x41,0x7f,0xb7,0x12,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x26,0x2a,0x55,0x5d,0x00}}, + {{0xc3,0x7f,0xb7,0x7a,0x84,0x40,0x02,0x5a,0x05,0x00,0x80,0x1f,0x84,0x3d,0x28,0x00}}, + {{0xe5,0x7f,0xb7,0x1d,0xa7,0x3e,0x04,0x5a,0x05,0x00,0x80,0x20,0x3e,0xe4,0x22,0x00}} }; static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_OPAL[] = { - {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x26,0x2a,0x55,0x5d,0x00}}, - {{0xc1,0x7f,0xb7,0x4d,0x8c,0x1e,0x31,0x5a,0x05,0x00,0x80,0x26,0x78,0x19,0x34,0x00}}, - {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x5a,0x05,0x00,0x80,0x25,0x8c,0xb2,0x2a,0x00}} -}; - -static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_SOPAL[] = -{ - {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x26,0x2a,0x55,0x5d,0x00}}, - {{0xc1,0x7f,0xb7,0x4d,0x8c,0x1e,0x31,0x5a,0x05,0x00,0x80,0x26,0x78,0x19,0x34,0x00}}, - {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x5a,0x05,0x00,0x80,0x25,0x8c,0xb2,0x2a,0x00}} + {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x26,0x2a,0x55,0x5d,0x00}}, + {{0xc1,0x7f,0xb7,0x4d,0x8c,0x1e,0x31,0x5a,0x05,0x00,0x80,0x26,0x78,0x19,0x34,0x00}}, + {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x5a,0x05,0x00,0x80,0x25,0x8c,0xb2,0x2a,0x00}} }; static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_UPALM[] = { - {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x72,0x77,0xbb,0x6e,0x84,0x2e,0x02,0x5a,0x04,0x00,0x80,0x20,0x76,0xdb,0x6e,0x00}}, - {{0xd7,0x77,0xb7,0xc8,0x84,0x3b,0x02,0x5a,0x04,0x00,0x80,0x19,0x84,0x0a,0xc7,0x00}}, - {{0xf6,0x77,0xbb,0x66,0x87,0x32,0x01,0x5a,0x04,0x00,0x80,0x1b,0xdc,0xb0,0x8d,0x00}} + {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x72,0x77,0xfb,0x6e,0x84,0x2e,0x02,0x83,0x04,0x00,0x80,0x20,0x76,0xdb,0x6e,0x00}}, + {{0xd7,0x77,0xf7,0xc8,0x84,0x3b,0x02,0x83,0x04,0x00,0x80,0x19,0x84,0x0a,0xc7,0x00}}, + {{0xf6,0x77,0xfb,0x66,0x87,0x32,0x01,0x83,0x04,0x00,0x80,0x1b,0xdc,0xb0,0x8d,0x00}} +#if 0 /* Correct blacklevel and CFRB */ + {{0x72,0x77,0xbb,0x6e,0x84,0x2e,0x02,0x5a,0x04,0x00,0x80,0x20,0x76,0xdb,0x6e,0x00}}, + {{0xd7,0x77,0xb7,0xc8,0x84,0x3b,0x02,0x5a,0x04,0x00,0x80,0x19,0x84,0x0a,0xc7,0x00}}, + {{0xf6,0x77,0xbb,0x66,0x87,0x32,0x01,0x5a,0x04,0x00,0x80,0x1b,0xdc,0xb0,0x8d,0x00}} +#endif }; static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_OPALM[] = { - {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x71,0x77,0xbb,0x6e,0x84,0x1e,0x00,0x5a,0x04,0x00,0x80,0x25,0x1a,0x1f,0x59,0x00}}, - {{0xd6,0x77,0xb7,0xb6,0x83,0x2c,0x02,0x5a,0x04,0x00,0x80,0x1b,0xf8,0x1f,0x82,0x00}}, - {{0xf5,0x77,0xbb,0x66,0x8c,0x21,0x02,0x5a,0x04,0x00,0x80,0x1f,0x58,0x46,0x9f,0x00}} + {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x71,0x77,0xfb,0x6e,0x84,0x1e,0x00,0x83,0x04,0x00,0x80,0x25,0x1a,0x1f,0x59,0x00}}, + {{0xd6,0x77,0xf7,0xb6,0x83,0x2c,0x02,0x83,0x04,0x00,0x80,0x1b,0xf8,0x1f,0x82,0x00}}, + {{0xf5,0x77,0xfb,0x66,0x8c,0x21,0x02,0x83,0x04,0x00,0x80,0x1f,0x58,0x46,0x9f,0x00}} +#if 0 /* Correct blacklevel and CFRB */ + {{0x71,0x77,0xbb,0x6e,0x84,0x1e,0x00,0x5a,0x04,0x00,0x80,0x25,0x1a,0x1f,0x59,0x00}}, + {{0xd6,0x77,0xb7,0xb6,0x83,0x2c,0x02,0x5a,0x04,0x00,0x80,0x1b,0xf8,0x1f,0x82,0x00}}, + {{0xf5,0x77,0xbb,0x66,0x8c,0x21,0x02,0x5a,0x04,0x00,0x80,0x1f,0x58,0x46,0x9f,0x00}} +#endif }; static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_UPALN[] = { - {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x80,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x12,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x1f,0x0d,0x54,0x5e,0x00}}, - {{0xc3,0x7f,0xb7,0x7a,0x84,0x40,0x02,0x5a,0x05,0x00,0x80,0x19,0x78,0xef,0x35,0x00}}, - {{0xe5,0x7f,0xb7,0x1d,0xa7,0x3e,0x04,0x5a,0x05,0x00,0x80,0x1a,0x33,0x3f,0x2f,0x00}} + {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x41,0x7f,0xb7,0x80,0x85,0x50,0x00,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x41,0x7f,0xb7,0x12,0x85,0x50,0x00,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0xc3,0x7f,0xb7,0x7a,0x84,0x40,0x02,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0xe5,0x7f,0xb7,0x1d,0xa7,0x3e,0x04,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}} +#if 0 /* Correct blacklevel, CIV and CFRB */ + {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x1f,0x0d,0x54,0x5e,0x00}}, + {{0xc3,0x7f,0xb7,0x7a,0x84,0x40,0x02,0x5a,0x05,0x00,0x80,0x19,0x78,0xef,0x35,0x00}}, + {{0xe5,0x7f,0xb7,0x1d,0xa7,0x3e,0x04,0x5a,0x05,0x00,0x80,0x1a,0x33,0x3f,0x2f,0x00}} +#endif }; static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_OPALN[] = { - {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x1f,0x0d,0x54,0x5e,0x00}}, - {{0xc1,0x7f,0xb7,0x4d,0x8c,0x1e,0x31,0x5a,0x05,0x00,0x80,0x1f,0x15,0xc0,0x1e,0x00}}, - {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x5a,0x05,0x00,0x80,0x1d,0xf1,0x6c,0xcb,0x00}} + {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0xc1,0x7f,0xb7,0x4d,0x8c,0x1e,0x31,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}} +#if 0 /* Correct blacklevel, CIV and CFRB */ + {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x1f,0x0d,0x54,0x5e,0x00}}, + {{0xc1,0x7f,0xb7,0x4d,0x8c,0x1e,0x31,0x5a,0x05,0x00,0x80,0x1f,0x15,0xc0,0x1e,0x00}}, + {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x5a,0x05,0x00,0x80,0x1d,0xf1,0x6c,0xcb,0x00}} +#endif }; static const UCHAR SiS310_CHTVVCLKUNTSC[] = {0x41,0x41,0x41,0x41,0x42,0x46,0x53}; - static const UCHAR SiS310_CHTVVCLKONTSC[] = {0x48,0x48,0x48,0x48,0x45,0x43,0x51}; static const UCHAR SiS310_CHTVVCLKUPAL[] = {0x47,0x47,0x47,0x47,0x48,0x4a,0x54}; - static const UCHAR SiS310_CHTVVCLKOPAL[] = {0x47,0x47,0x47,0x47,0x48,0x4f,0x52}; -static const UCHAR SiS310_CHTVVCLKSOPAL[] = {0x47,0x47,0x47,0x47,0x48,0x4f,0x52}; - static const UCHAR SiS310_CHTVVCLKUPALM[] = {0x41,0x41,0x41,0x41,0x42,0x46,0x53}; - static const UCHAR SiS310_CHTVVCLKOPALM[] = {0x48,0x48,0x48,0x48,0x45,0x43,0x51}; static const UCHAR SiS310_CHTVVCLKUPALN[] = {0x47,0x47,0x47,0x47,0x48,0x4a,0x54}; - static const UCHAR SiS310_CHTVVCLKOPALN[] = {0x47,0x47,0x47,0x47,0x48,0x4f,0x52}; + diff -puN drivers/video/sis/init301.c~sisfb-update drivers/video/sis/init301.c --- 25/drivers/video/sis/init301.c~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/init301.c 2004-01-22 03:06:55.000000000 -0800 @@ -1,45 +1,60 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c,v 1.3 2002/22/04 01:16:16 dawes Exp $ */ +/* $XFree86$ */ /* - * Mode switching code (CRT2 section) for SiS 300/540/630/730/315/550/650/740/330 - * (Universal module for Linux kernel framebuffer, XFree86 4.x) + * Mode initializing code (CRT2 section) + * for SiS 300/305/540/630/730 and + * SiS 315/550/650/M650/651/661FX/M661xX/740/741/M741/330/660/M660/760/M760 + * (Universal module for Linux kernel framebuffer and XFree86 4.x) * - * Assembler-To-C translation - * Copyright 2002, 2003 by Thomas Winischhofer - * Minor parts Copyright SiS, Inc. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * Based on BIOS - * 1.10.07, 1.10a for 650/CH7019 - * 1.11.21a for 740/CH7019 - * 1.11.05 for 650/LVDS (w/o Chrontel) - * 1.07.1b, 1.10.6s, 1.11.6w, 1.11.7w, 1.11.8r for 650/301(B/LV), 650/302LV - * 2.04.50 (I) and 2.04.5c (II) for 630/301(B) - * 2.02.3b, 2.03.02, 2.04.2c, 2.04.5c, 2.07a and 2.08.b3 for 630/LVDS/LVDS+CH7005 - * 2.04.5c, 2.04.6c for 730+LVDS+CH7005 - * 1.09b for 315/301(B) - * 1.16.51 for 300+301LV (ECS A907) - * 1.01.03 for 330 (Xabre 400) + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * Known bugs: - * 1024x768 panel, expanding (CR37=1): Mode 640x480 does not work on SOME panels - * therefore, we always do the scaling ourselves for now. + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the copyright holder not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The copyright holder makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. + * Otherwise, the following license terms apply: * - * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) All advertising materials mentioning features or use of this software + * * must display the following acknowledgement: "This product includes + * * software developed by Thomas Winischhofer, Vienna, Austria." + * * 4) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * + * Formerly based on non-functional code-fragements for 300 series by SiS, Inc. + * Used by permission. * * TW says: This code looks awful, I know. But please don't do anything about * this otherwise debugging will be hell. @@ -47,14 +62,18 @@ * video bridges and combinations thereof. If anything is changed, extreme * care has to be taken that that change doesn't break it for other chipsets, * bridges or combinations thereof. - * All comments in this file are by me, regardless if they are marked TW or not. + * All comments in this file are by me, regardless if marked TW or not. * */ - -#if 1 -#define NEWCH701x + +#if 1 +#define SET_EMI /* 302LV/ELV: Set EMI values */ #endif +#define COMPAL_HACK /* Needed for Compal 1400x1050 (EMI) */ +#define COMPAQ_HACK /* Needed for Inventec/Compaq 1280x1024 (EMI) */ +#define ASUS_HACK /* Needed for Asus A2H 1024x768 (EMI) */ + #include "init301.h" #if 0 @@ -72,2563 +91,3451 @@ #define SiS_I2CDELAY 1000 #define SiS_I2CDELAYSHORT 150 -BOOLEAN -SiS_SetCRT2Group301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +/*********************************************/ +/* HELPER: Lock/Unlock CRT2 */ +/*********************************************/ + +void +SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - USHORT ModeIdIndex; - USHORT RefreshRateTableIndex; + if(HwInfo->jChipType >= SIS_315H) + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2f,0x01); + else + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01); +} - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; +void +SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + if(HwInfo->jChipType >= SIS_315H) + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2F,0xFE); + else + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x24,0xFE); +} - if(!SiS_Pr->UseCustomMode) { - SiS_SearchModeID(SiS_Pr,ROMAddr,&ModeNo,&ModeIdIndex); - } else { - ModeIdIndex = 0; - } +/*********************************************/ +/* HELPER: Enable CRT2 */ +/*********************************************/ - /* TW: Used for shifting CR33 */ - SiS_Pr->SiS_SelectCRT2Rate = 4; +void +SiS_EnableCRT2(SiS_Private *SiS_Pr) +{ + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); +} - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); +/*********************************************/ +/* HELPER: Write SR11 */ +/*********************************************/ - RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr, ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); +static void +SiS_SetRegSR11ANDOR(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DataAND, USHORT DataOR) +{ + if(HwInfo->jChipType >= SIS_661) DataAND &= 0x0f; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,DataAND,DataOR); +} - SiS_SaveCRT2Info(SiS_Pr,ModeNo); +/*********************************************/ +/* HELPER: Get Pointer to LCD structure */ +/*********************************************/ - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - SiS_DisableBridge(SiS_Pr,HwDeviceExtension,BaseAddr); - if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (HwDeviceExtension->jChipType == SIS_730)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,0x80); - } - SiS_SetCRT2ModeRegs(SiS_Pr,BaseAddr,ModeNo,ModeIdIndex,HwDeviceExtension); - } +/* For 661 series only */ +#ifdef SIS315H +#if 0 /* Need to wait until hardware using this really exists */ +static UCHAR * +GetLCDPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, int tabletype, + USHORT ModeNo, USHORT ModeIdIndex, USHORT RRTI) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + UCHAR *tableptr = NULL; + UCHAR tablelengths[] = { 8, 7, 6, 6, 8, 6, 0, 0, 0 }; + USHORT modeflag, CRT2Index, tablelength, lcdid, myid, tableptri; - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - SiS_LockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); - SiS_DisplayOn(SiS_Pr); - return(TRUE); - } + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + CRT2Index = SiS_Pr->SiS_RefIndex[RRTI].Ext_CRT2CRTC; + /* This is total bullshit: */ + if(SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO == SIS_RI_720x576) CRT2Index = 10; + } - if(SiS_Pr->UseCustomMode) return(FALSE); - - SiS_GetCRT2Data(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); + if(tabletype <= 1) { +#if 0 /* Not yet implemented */ + if(ModeNo <= 0x13) { + CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex]. + 5; + } else { + CRT2Index = SiS_Pr->SiS_RefIndex[RRTI]. + 5; + } + if(tabletype & 1) CRT2Index >>= 4; +#endif + } - /* Set up Panel Link for LVDS, 301BDH and 650/30xLV(for LCDA) */ - if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || - ((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) || - ((HwDeviceExtension->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) { - SiS_GetLVDSDesData(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); + CRT2Index &= 0x0f; + + tablelength = tablelengths[tabletype]; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + if((tabletype == 5) || (tabletype == 7)) tablelength = 8; + if((tabletype == 3) || (tabletype == 8)) tablelength = 8; + } + + if(!tablelength) return NULL; + + tableptri = ROMAddr[0x222] | (ROMAddr[0x223] << 8); + tableptri += (tabletype << 1); + if(!tableptri) return NULL; + tableptr = &ROMAddr[tableptri]; + + do { + lcdid = tableptr[0]; + if(lcdid == 0xff) break; + myid = SiS_Pr->SiS_LCDResInfo; + if((lcdid & 0x80) && (lcdid != 0x80)) { + lcdid &= 0x7f; + myid = SiS_Pr->SiS_LCDTypeInfo; + } + if(SiS_Pr->SiS_LCDInfo & LCDPass11) myid &= ~0x1f; + + if(myid == lcdid) { + lcdid = tableptr[1] | (tableptr[2] << 8); + myid = SiS_Pr->SiS_LCDInfo661; + if(modeflag & HalfDCLK) myid |= 0x200; + if(ModeNo <= 0x13) myid |= 0x400; + lcdid &= myid; + myid = tableptr[3] | (tableptr[4] << 8); + if(lcdid == myid) break; + } + tableptr += 7; + } while (1); + + if(lcdid == myid) { + lcdid = tableptr[5] | (tableptr[6] << 8); + lcdid += (tablelength * CRT2Index); + return((UCHAR *)&ROMAddr[lcdid]); + } + + return NULL; +} +#endif + +static UCHAR * +GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT lcdres = SiS_Pr->SiS_LCDResInfo; + USHORT lcdtype = SiS_Pr->SiS_LCDTypeInfo; + USHORT romindex=0; + UCHAR *myptr = NULL; + UCHAR lcdid; + + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + romindex = ROMAddr[0x256] | (ROMAddr[0x257] << 8); + } + if(romindex) { + myptr = &ROMAddr[romindex]; } else { - SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; + myptr = (UCHAR *)SiS_LCDStruct661; } -#ifdef LINUX_XF86 -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "(init301: LCDHDES 0x%03x LCDVDES 0x%03x)\n", SiS_Pr->SiS_LCDHDES, SiS_Pr->SiS_LCDVDES); - xf86DrvMsg(0, X_INFO, "(init301: HDE 0x%03x VDE 0x%03x)\n", SiS_Pr->SiS_HDE, SiS_Pr->SiS_VDE); - xf86DrvMsg(0, X_INFO, "(init301: VGAHDE 0x%03x VGAVDE 0x%03x)\n", SiS_Pr->SiS_VGAHDE, SiS_Pr->SiS_VGAVDE); - xf86DrvMsg(0, X_INFO, "(init301: HT 0x%03x VT 0x%03x)\n", SiS_Pr->SiS_HT, SiS_Pr->SiS_VT); - xf86DrvMsg(0, X_INFO, "(init301: VGAHT 0x%03x VGAVT 0x%03x)\n", SiS_Pr->SiS_VGAHT, SiS_Pr->SiS_VGAVT); -#endif + while(myptr[0] != 0xff) { + lcdid = myptr[0]; + if((lcdid & 0x80) && (lcdid != 0x80)) { + lcdres = lcdtype; + lcdid &= 0x7f; + } + if(lcdid == lcdres) break; + myptr += 26; + } + if(myptr[0] == 0xff) return NULL; + + return myptr; +} #endif - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - SiS_SetGroup1(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); - } +/*********************************************/ +/* Adjust Rate for CRT2 */ +/*********************************************/ - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { +static BOOLEAN +SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, USHORT *i, + PSIS_HW_INFO HwInfo) +{ + USHORT tempax,tempbx,infoflag; - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { + tempbx = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].ModeID; - SiS_SetGroup2(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - SiS_SetGroup3(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension); - SiS_SetGroup4(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - SiS_SetGroup5(SiS_Pr,HwDeviceExtension, BaseAddr,ROMAddr, - ModeNo,ModeIdIndex); + tempax = 0; - /* TW: For 301BDH (Panel link initialization): */ - if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - if(!((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo = 0x10)))) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SiS_ModCRT1CRTC(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - } - } - } - SiS_SetCRT2ECLK(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - } - } + if(SiS_Pr->SiS_VBType & VB_SISVB) { - } else { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { - SiS_ModCRT1CRTC(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); + tempax |= SupportRAMDAC2; + if(HwInfo->jChipType >= SIS_315H) { + tempax |= SupportRAMDAC2_135; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + tempax |= SupportRAMDAC2_162; + if(SiS_Pr->SiS_VBType & VB_SIS301C) { + tempax |= SupportRAMDAC2_202; + } } } - if(SiS_Pr->SiS_IF_DEF_FSTN == 0) { - SiS_SetCRT2ECLK(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - } - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { -#ifdef SIS315H - SiS_SetCH701xForLCD(SiS_Pr,HwDeviceExtension,BaseAddr); -#endif + + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + + tempax |= SupportLCD; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(tempbx == 0x2e) { /* 640x480 */ + tempax |= Support64048060Hz; } } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_SetCHTVReg(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex); - } - } + } } - } + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { -#ifdef SIS300 - if ( (HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) || - (HwDeviceExtension->jChipType == SIS_300) ) - { - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - if(SiS_Pr->SiS_UseOEM) { - if((SiS_Pr->SiS_UseROM) && ROMAddr && (SiS_Pr->SiS_UseOEM == -1)) { - if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - SiS_OEM300Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo); - } - } else { - SiS_OEM300Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo); - } - } + tempax |= SupportHiVision; + + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750|SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) { + + tempax |= SupportTV; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + tempax |= SupportTV1024; } - } -#endif -#ifdef SIS315H - if ( (HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO)|| - (HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_330) ) - { - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - SiS_FinalizeLCD(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, HwDeviceExtension); -#if 0 /* Instead of FinalizeLCD(), older BIOSes (A92x) used OEMLCD() */ - SiS_OEMLCD(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); -#endif - if(SiS_Pr->SiS_UseOEM) { - SiS_OEM310Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - } - SiS_CRT2AutoThreshold(SiS_Pr,BaseAddr); - } - } -#endif + } - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(HwDeviceExtension->jChipType != SIS_730) { - SiS_DisplayOn(SiS_Pr); - } - } - } + } else { /* for LVDS */ - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(HwDeviceExtension->jChipType == SIS_730) { - SiS_DisplayOn(SiS_Pr); - } - } - SiS_EnableBridge(SiS_Pr,HwDeviceExtension,BaseAddr); - } + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tempax |= SupportCHTV; + } + } - SiS_DisplayOn(SiS_Pr); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + tempax |= SupportLCD; + } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - /* TW: Disable LCD panel when using TV */ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x11,0x0C); - } else { - /* TW: Disable TV when using LCD */ - SiS_SetCH70xxANDOR(SiS_Pr,0x010E,0xF8); - } - } + } - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - SiS_LockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); - } + /* Look backwards in table for matching CRT2 mode */ + for(; SiS_Pr->SiS_RefIndex[RefreshRateTableIndex+(*i)].ModeID == tempbx; (*i)--) { + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].Ext_InfoFlag; + if(infoflag & tempax) return(1); + if((*i) == 0) break; + } - return 1; + /* Look through the whole mode-section of the table from the beginning + * for a matching CRT2 mode if no mode was found yet. + */ + for((*i) = 0; ; (*i)++) { + if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].ModeID != tempbx) { + return(0); + } + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].Ext_InfoFlag; + if(infoflag & tempax) return(1); + } + return(1); } -BOOLEAN -SiS_LowModeStuff(SiS_Private *SiS_Pr, USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +/*********************************************/ +/* Get rate pointer */ +/*********************************************/ + +USHORT +SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { - USHORT temp,temp1,temp2; + SHORT LCDRefreshIndex[] = { 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00 }; + USHORT RefreshRateTableIndex,i,backup_i; + USHORT modeflag,index,temp,backupindex; - if((ModeNo != 0x03) && (ModeNo != 0x10) && (ModeNo != 0x12)) - return(1); - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x11); - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x11,0x80); - temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x00); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x00,0x55); - temp2 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x00); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x00,temp1); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x11,temp); - if((HwDeviceExtension->jChipType >= SIS_315H) || - (HwDeviceExtension->jChipType == SIS_300)) { - if(temp2 == 0x55) return(0); - else return(1); - } else { - if(temp2 != 0x55) return(1); - else { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); - return(0); - } - } -} + /* Do NOT check for UseCustomMode here, will skrew up FIFO */ + if(ModeNo == 0xfe) return 0; -/* TW: Set Part1 registers */ -void -SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT RefreshRateTableIndex) -{ - USHORT temp=0, tempax=0, tempbx=0, tempcx=0; - USHORT pushbx=0, CRT1Index=0; -#ifdef SIS315H - USHORT pushcx=0, tempbl=0; -#endif - USHORT modeflag, resinfo=0; + if(ModeNo <= 0x13) + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + else + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(modeflag & HalfDCLK) return(0); + } } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + if(ModeNo < 0x14) return(0xFFFF); - SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo, - RefreshRateTableIndex,HwDeviceExtension); -#ifdef SIS315H - SiS_SetGroup1_LCDA(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); -#endif - } else { + /* CR33 holds refresh rate index for CRT1 [3:0] and CRT2 [7:4]. */ - if( (HwDeviceExtension->jChipType >= SIS_315H) && - (SiS_Pr->SiS_IF_DEF_LVDS == 1) && - (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + index = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x33) >> SiS_Pr->SiS_SelectCRT2Rate) & 0x0F; + backupindex = index; - SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo, - RefreshRateTableIndex,HwDeviceExtension); + if(index > 0) index--; + if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_VBType & VB_NoLCD) index = 0; + else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index = backupindex = 0; + } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) { + temp = LCDRefreshIndex[SiS_Pr->SiS_LCDResInfo]; + if(index > temp) index = temp; + } + } } else { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0; + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) index = 0; + } + } + } - SiS_SetCRT2Offset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); + RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; + ModeNo = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].ModeID; - if (HwDeviceExtension->jChipType < SIS_315H ) { -#ifdef SIS300 - SiS_SetCRT2FIFO_300(SiS_Pr,ROMAddr,ModeNo,HwDeviceExtension); -#endif - } else { -#ifdef SIS315H - SiS_SetCRT2FIFO_310(SiS_Pr,ROMAddr,ModeNo,HwDeviceExtension); -#endif - } + if(HwInfo->jChipType >= SIS_315H) { + if(!(SiS_Pr->SiS_VBInfo & DriverMode)) { + if( (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x105) || + (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x107) ) { + if(backupindex <= 1) RefreshRateTableIndex++; + } + } + } - SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo, - RefreshRateTableIndex,HwDeviceExtension); + i = 0; + do { + if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + i].ModeID != ModeNo) break; + temp = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag; + temp &= ModeInfoFlag; + if(temp < SiS_Pr->SiS_ModeType) break; + i++; + index--; + } while(index != 0xFFFF); - /* 1. Horizontal setup */ + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + temp = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + i - 1].Ext_InfoFlag; + if(temp & InterlaceMode) i++; + } + } - if (HwDeviceExtension->jChipType < SIS_315H ) { + i--; -#ifdef SIS300 /* ------------- 300 series --------------*/ + if((SiS_Pr->SiS_SetFlag & ProgrammingCRT2) && (!(SiS_Pr->SiS_VBInfo & DisableCRT2Display))) { + backup_i = i; + if(!(SiS_AdjustCRT2Rate(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, &i, HwInfo))) { + i = backup_i; + } + } - temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,temp); /* TW: CRT2 Horizontal Total */ + return(RefreshRateTableIndex + i); +} - temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* TW: CRT2 Horizontal Total Overflow [7:4] */ +/*********************************************/ +/* STORE CRT2 INFO in CR34 */ +/*********************************************/ - temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp); /* TW: CRT2 Horizontal Display Enable End */ +static void +SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo) +{ + USHORT temp1,temp2; - pushbx = SiS_Pr->SiS_VGAHDE + 12; /* bx BTVGA@HRS 0x0B,0x0C */ - tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2; - tempbx = pushbx + tempcx; - tempcx <<= 1; - tempcx += tempbx; + /* Store CRT1 ModeNo in CR34 */ + SiS_SetReg(SiS_Pr->SiS_P3d4,0x34,ModeNo); + temp1 = (SiS_Pr->SiS_VBInfo & SetInSlaveMode) >> 8; + temp2 = ~(SetInSlaveMode >> 8); + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x31,temp2,temp1); +} - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){ - /* CRT1Index &= 0x3F; - Not any longer */ - tempbx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4]; - tempbx |= ((SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14] & 0xC0) << 2); - tempbx = (tempbx - 1) << 3; - tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5]; - tempcx &= 0x1F; - temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15]; - temp = (temp & 0x04) << (6-2); - tempcx = (tempcx | temp); - tempcx--; - tempcx <<= 3; - } - - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == 0x08)){ - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)){ - tempbx = 1040; - tempcx = 1042; - } - } - } +/*********************************************/ +/* HELPER: GET SOME DATA FROM BIOS ROM */ +/*********************************************/ - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp); /* TW: CRT2 Horizontal Retrace Start */ -#endif /* SIS300 */ +static BOOLEAN +SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT temp,temp1; + UCHAR *ROMAddr; - } else { + if((ROMAddr = (UCHAR *)HwInfo->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xff) >> 4); + temp1 = (ROMAddr[0x23c] << 8) | ROMAddr[0x23b]; + if(temp1 & temp) return(1); + } + } + return(0); +} -#ifdef SIS315H /* ----------------- 310/325/330 series ------------- */ - - tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HT 0x08,0x09 */ - pushcx = tempcx; - if(modeflag & HalfDCLK) { -#ifndef NEWCH701x - if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_IF_DEF_CH70xx == 0)) { -#endif - tempax = SiS_Pr->SiS_VGAHDE >> 1; - tempcx = SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE + tempax; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - tempcx = SiS_Pr->SiS_HT - tempax; - } -#ifndef NEWCH701x - } else { - tempcx >>= 1; - } -#endif - } - tempcx--; +static BOOLEAN +SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT temp,temp1; + UCHAR *ROMAddr; - temp = tempcx & 0xff; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,temp); /* TW: CRT2 Horizontal Total */ + if((ROMAddr = (UCHAR *)HwInfo->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xff) >> 4); + temp1 = (ROMAddr[0x23e] << 8) | ROMAddr[0x23d]; + if(temp1 & temp) return(1); + } + } + return(0); +} - temp = ((tempcx & 0xff00) >> 8) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0F,temp); /* TW: CRT2 Horizontal Total Overflow [7:4] */ +/*********************************************/ +/* HELPER: DELAY FUNCTIONS */ +/*********************************************/ - tempcx = pushcx; /* BTVGA2HDEE 0x0A,0x0C */ - tempbx = SiS_Pr->SiS_VGAHDE; - tempcx -= tempbx; - tempcx >>= 2; - if(modeflag & HalfDCLK) { - tempbx >>= 1; - tempcx >>= 1; - } - tempbx += 16; +void +SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime) +{ + USHORT i, j; - temp = tempbx & 0xff; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp); /* TW: CRT2 Horizontal Display Enable End */ + for(i=0; iSiS_P3c4,0x05); + } +} - pushbx = tempbx; - tempcx >>= 1; - tempbx += tempcx; - tempcx += tempbx; +static void +SiS_GenericDelay(SiS_Private *SiS_Pr, USHORT delay) +{ + USHORT temp,flag; - if(SiS_Pr->SiS_IF_DEF_LVDS==0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { - tempbx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4]; - tempbx |= ((SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14] & 0xC0) << 2); - tempbx = (tempbx - 3) << 3; /*(VGAHRS-3)*8 */ - tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5]; - tempcx &= 0x1F; - temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15]; - temp = (temp & 0x04) << (5-2); /* VGAHRE D[5] */ - tempcx = (tempcx | temp); /* (VGAHRE-3)*8 */ - tempcx -= 3; - tempcx <<= 3; - tempcx &= 0x00FF; - tempcx |= (tempbx & 0xFF00); - tempbx += 16; - tempcx += 16; - tempax = SiS_Pr->SiS_VGAHT; - if(modeflag & HalfDCLK) tempax >>= 1; - tempax--; - if(tempcx > tempax) tempcx = tempax; - } - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == 0x08)){ - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)){ - tempbx = 1040; - tempcx = 1042; - } - } - /* TW: Makes no sense, but is in 650/302LV 1.10.6s */ - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == 0x08)){ - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - tempbx = 1040; - tempcx = 1042; - } - } - } - } + flag = SiS_GetRegByte(0x61) & 0x10; - temp = tempbx & 0xff; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp); /* TW: CRT2 Horizontal Retrace Start */ -#endif /* SIS315H */ + while(delay) { + temp = SiS_GetRegByte(0x61) & 0x10; + if(temp == flag) continue; + flag = temp; + delay--; + } +} - } /* 310/325/330 series */ +#ifdef SIS315H +static void +SiS_LongDelay(SiS_Private *SiS_Pr, USHORT delay) +{ + while(delay--) { + SiS_GenericDelay(SiS_Pr,0x19df); + } +} +#endif - /* TW: The following is done for all bridge/chip types/series */ +static void +SiS_ShortDelay(SiS_Private *SiS_Pr, USHORT delay) +{ + while(delay--) { + SiS_GenericDelay(SiS_Pr,0x42); + } +} - tempax = tempbx & 0xFF00; - tempbx = pushbx; - tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); - tempax |= (tempbx & 0xFF00); - temp = (tempax & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0C,temp); /* TW: Overflow */ +static void +SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT PanelID, DelayIndex, Delay=0; - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0D,temp); /* TW: CRT2 Horizontal Retrace End */ + if(HwInfo->jChipType < SIS_315H) { - /* 2. Vertical setup */ +#ifdef SIS300 - tempcx = SiS_Pr->SiS_VGAVT - 1; - temp = tempcx & 0x00FF; + PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x18) & 0x10)) PanelID = 0x12; + } + DelayIndex = PanelID >> 4; + if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { + Delay = 3; + } else { + if(DelayTime >= 2) DelayTime -= 2; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) { - temp--; - } - } - } else { - temp--; - } - } else if(HwDeviceExtension->jChipType >= SIS_315H) { - /* TW: 650/30xLV 1.10.6s */ - temp--; - } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0E,temp); /* TW: CRT2 Vertical Total */ + if(!(DelayTime & 0x01)) { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; + } else { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; + } + if((ROMAddr) && (SiS_Pr->SiS_UseROM)) { + if(ROMAddr[0x220] & 0x40) { + if(!(DelayTime & 0x01)) { + Delay = (USHORT)ROMAddr[0x225]; + } else { + Delay = (USHORT)ROMAddr[0x226]; + } + } + } + } + SiS_ShortDelay(SiS_Pr,Delay); - tempbx = SiS_Pr->SiS_VGAVDE - 1; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0F,temp); /* TW: CRT2 Vertical Display Enable End */ +#endif /* SIS300 */ - temp = ((tempbx & 0xFF00) << 3) >> 8; - temp |= ((tempcx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x12,temp); /* TW: Overflow (and HWCursor Test Mode) */ + } else { - /* TW: 650/LVDS (1.10.07), 650/30xLV (1.10.6s) */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - tempbx++; - tempax = tempbx; - tempcx++; - tempcx -= tempax; - tempcx >>= 2; - tempbx += tempcx; - if(tempcx < 4) tempcx = 4; - tempcx >>= 2; - tempcx += tempbx; - tempcx++; - } else { - /* TW: 300 series, LVDS/301B: */ - tempbx = (SiS_Pr->SiS_VGAVT + SiS_Pr->SiS_VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */ - tempcx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */ - } +#ifdef SIS315H - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){ - tempbx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[8]; - temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7]; - if(temp & 0x04) tempbx |= 0x0100; - if(temp & 0x80) tempbx |= 0x0200; - temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]; - if(temp & 0x08) tempbx |= 0x0400; - temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9]; - tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); - } - } - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp); /* TW: CRT2 Vertical Retrace Start */ + if(HwInfo->jChipType >= SIS_330) return; - temp = ((tempbx & 0xFF00) >> 8) << 4; - temp |= (tempcx & 0x000F); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x11,temp); /* TW: CRT2 Vert. Retrace End; Overflow; "Enable CRTC Check" */ + if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { /* 315 series, LVDS; Special */ + + if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { + PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); + if(SiS_Pr->SiS_CustomT == CUT_CLEVO1400) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1b) & 0x10)) PanelID = 0x12; + } + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + DelayIndex = PanelID & 0x0f; + } else { + DelayIndex = PanelID >> 4; + } + if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { + Delay = 3; + } else { + if(DelayTime >= 2) DelayTime -= 2; + if(!(DelayTime & 0x01)) { + Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[0]; + } else { + Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[1]; + } + if((ROMAddr) && (SiS_Pr->SiS_UseROM)) { + if(ROMAddr[0x13c] & 0x40) { + if(!(DelayTime & 0x01)) { + Delay = (USHORT)ROMAddr[0x17e]; + } else { + Delay = (USHORT)ROMAddr[0x17f]; + } + } + } + } + SiS_ShortDelay(SiS_Pr,Delay); + } - /* 3. Panel compensation delay */ + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 315 series, all bridges */ - if(HwDeviceExtension->jChipType < SIS_315H) { + DelayIndex = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4; + if(!(DelayTime & 0x01)) { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; + } else { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; + } + Delay <<= 8; + SiS_DDC2Delay(SiS_Pr, Delay); -#ifdef SIS300 /* ---------- 300 series -------------- */ + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - temp = 0x20; +#endif /* SIS315H */ - if(HwDeviceExtension->jChipType == SIS_300) { - temp = 0x10; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) temp = 0x2c; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) temp = 0x24; - } - if(SiS_Pr->SiS_VBType & VB_SIS301) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20; - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) temp = 0x24; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x08; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c; - else temp = 0x20; - } - if((ROMAddr) && (SiS_Pr->SiS_UseROM) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - if(ROMAddr[0x220] & 0x80) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV-SetCRT2ToHiVisionTV)) - temp = ROMAddr[0x221]; - else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) - temp = ROMAddr[0x222]; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) - temp = ROMAddr[0x223]; - else - temp = ROMAddr[0x224]; - temp &= 0x3c; - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(HwDeviceExtension->pdc) { - temp = HwDeviceExtension->pdc & 0x3c; - } - } - } else { - temp = 0x20; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) temp = 0x04; - } - if((ROMAddr) && SiS_Pr->SiS_UseROM) { - if(ROMAddr[0x220] & 0x80) { - temp = ROMAddr[0x220] & 0x3c; - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(HwDeviceExtension->pdc) { - temp = HwDeviceExtension->pdc & 0x3c; - } - } - } + } +} - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x03C,temp); /* TW: Panel Link Delay Compensation; (Software Command Reset; Power Saving) */ +#ifdef SIS315H +static void +SiS_PanelDelayLoop(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT DelayTime, USHORT DelayLoop) +{ + int i; + for(i=0; iSiS_P3c4,0x1f) & 0xc0) return; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - temp = 0x10; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) temp = 0x2c; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) temp = 0x24; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - temp = 0x08; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - switch(SiS_Pr->SiS_HiVision) { - case 2: - case 1: - case 0: - temp = 0x08; - break; - default: - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c; - else temp = 0x20; - } - } - } - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { - tempbl = 0x00; - if((ROMAddr) && (SiS_Pr->SiS_UseROM)) { - if(HwDeviceExtension->jChipType < SIS_330) { - if(ROMAddr[0x13c] & 0x80) tempbl = 0xf0; - } else { - if(ROMAddr[0x1bc] & 0x80) tempbl = 0xf0; - } - } - } else { /* LV (550/301LV checks ROM byte, other LV BIOSes do not) */ - tempbl = 0xF0; - } - } else { - if(HwDeviceExtension->jChipType == SIS_740) { - temp = 0x03; - } else { - temp = 0x00; - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x0a; - tempbl = 0xF0; - if(HwDeviceExtension->jChipType == SIS_650) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempbl = 0x0F; - } - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,tempbl,temp); /* TW: Panel Link Delay Compensation */ + if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80)) return; - tempax = 0; - if (modeflag & DoubleScanMode) tempax |= 0x80; - if (modeflag & HalfDCLK) tempax |= 0x40; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax); + watchdog = 65535; + while((SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08) && --watchdog); + watchdog = 65535; + while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); +} -#endif /* SIS315H */ +static void +SiS_WaitRetrace2(SiS_Private *SiS_Pr, USHORT reg) +{ + USHORT watchdog; - } + watchdog = 65535; + while((SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02) && --watchdog); + watchdog = 65535; + while((!(SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02)) && --watchdog); +} - } /* Slavemode */ +static void +SiS_WaitVBRetrace(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + if(HwInfo->jChipType < SIS_315H) { +#ifdef SIS300 + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return; + } + if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x80)) { + SiS_WaitRetrace1(SiS_Pr); + } else { + SiS_WaitRetrace2(SiS_Pr, 0x25); + } +#endif + } else { +#ifdef SIS315H + if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) { + SiS_WaitRetrace1(SiS_Pr); + } else { + SiS_WaitRetrace2(SiS_Pr, 0x30); + } +#endif + } +} - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { +static void +SiS_VBWait(SiS_Private *SiS_Pr) +{ + USHORT tempal,temp,i,j; - /* TW: For 301BDH, we set up the Panel Link */ - if( (SiS_Pr->SiS_VBType & VB_NoLCD) && - (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) { + temp = 0; + for(i=0; i<3; i++) { + for(j=0; j<100; j++) { + tempal = SiS_GetRegByte(SiS_Pr->SiS_P3da); + if(temp & 0x01) { + if((tempal & 0x08)) continue; + if(!(tempal & 0x08)) break; + } else { + if(!(tempal & 0x08)) continue; + if((tempal & 0x08)) break; + } + } + temp ^= 0x01; + } +} - SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); +static void +SiS_VBLongWait(SiS_Private *SiS_Pr) +{ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SiS_VBWait(SiS_Pr); + } else { + SiS_WaitRetrace1(SiS_Pr); + } +} - } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { +/*********************************************/ +/* HELPER: MISC */ +/*********************************************/ - SiS_SetGroup1_301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); - } +static BOOLEAN +SiS_Is301B(SiS_Private *SiS_Pr) +{ + USHORT flag; - } else { + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); + if(flag >= 0xb0) return TRUE; + return FALSE; +} - if(HwDeviceExtension->jChipType < SIS_315H) { - - SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); - } else { - - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); - } - } else { - SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); - } - - } +static BOOLEAN +SiS_CRT2IsLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - } - } /* LCDA */ + if(HwInfo->jChipType == SIS_730) { + flag = SiS_GetReg(SiS_Pr->SiS_P3c4,0x13); + if(flag & 0x20) return TRUE; + } + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & 0x20) return TRUE; + return FALSE; } -void -SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex) +BOOLEAN +SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - USHORT push1,push2; - USHORT tempax,tempbx,tempcx,temp; - USHORT resinfo,modeflag; - - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } - - /* TW: The following is only done if bridge is in slave mode: */ - - tempax = 0xFFFF; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempax = SiS_GetVGAHT2(SiS_Pr); +#ifdef SIS315H + USHORT flag; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - modeflag |= Charx8Dot; + if(HwInfo->jChipType >= SIS_315H) { + if((HwInfo->jChipType != SIS_650) || (SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & EnableDualEdge) return TRUE; + } } +#endif + return FALSE; +} - if(modeflag & Charx8Dot) tempcx = 0x08; - else tempcx = 0x09; - - if(tempax >= SiS_Pr->SiS_VGAHT) tempax = SiS_Pr->SiS_VGAHT; - - if(modeflag & HalfDCLK) tempax >>= 1; - - tempax = (tempax / tempcx) - 5; - tempbx = tempax & 0x00FF; - - temp = 0xFF; /* set MAX HT */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,temp); - - tempax = SiS_Pr->SiS_VGAHDE; /* 0x04 Horizontal Display End */ - if(modeflag & HalfDCLK) tempax >>= 1; - tempax = (tempax / tempcx) - 1; - tempbx |= ((tempax & 0x00FF) << 8); - temp = tempax & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x04,temp); +BOOLEAN +SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ +#ifdef SIS315H + USHORT flag; - temp = (tempbx & 0xFF00) >> 8; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - temp += 2; - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(SiS_Pr->SiS_HiVision == 3) { - if(resinfo == 7) temp -= 2; - } - } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x05,temp); /* 0x05 Horizontal Display Start */ - - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x06,0x03); /* 0x06 Horizontal Blank end */ - - if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (SiS_Pr->SiS_HiVision == 3)) { - temp = (tempbx & 0x00FF) - 1; - if(!(modeflag & HalfDCLK)) { - temp -= 6; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - temp -= 2; - if(ModeNo > 0x13) temp -= 10; - } - } - } else { - tempcx = tempbx & 0x00FF; - tempbx = (tempbx & 0xFF00) >> 8; - tempcx = (tempcx + tempbx) >> 1; - temp = (tempcx & 0x00FF) + 2; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV){ - temp--; - if(!(modeflag & HalfDCLK)){ - if((modeflag & Charx8Dot)){ - temp += 4; - if(SiS_Pr->SiS_VGAHDE >= 800) temp -= 6; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VGAHDE == 800) temp += 2; - } - } - } - } else { - if(!(modeflag & HalfDCLK)) { - temp -= 4; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) { - if(SiS_Pr->SiS_VGAHDE >= 800) { - temp -= 7; - if(HwDeviceExtension->jChipType < SIS_315H) { - /* 650/301LV(x) does not do this, 630/301B, 300/301LV do */ - if(SiS_Pr->SiS_ModeType == ModeEGA) { - if(SiS_Pr->SiS_VGAVDE == 1024) { - temp += 15; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) - temp += 7; - } - } - } - if(SiS_Pr->SiS_VGAHDE >= 1280) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) { - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) temp += 28; - } - } - } - } - } - } + if(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if((flag & EnableDualEdge) && (flag & SetToLCDA)) return TRUE; } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,temp); /* 0x07 Horizontal Retrace Start */ - - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x00); /* 0x08 Horizontal Retrace End */ - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - if(ModeNo <= 0x01) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x2a); - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x61); - } else { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x41); - } - } else if(SiS_Pr->SiS_ModeType == ModeText) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x54); - } else { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x55); - } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x00); - } else if(ModeNo <= 0x13) { - if(modeflag & HalfDCLK) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x30); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x03); - } else { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x2f); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x02); - } - } else { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x5b); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x03); - } - } else if( ((HwDeviceExtension->jChipType >= SIS_315H) && (ModeNo == 0x50)) || - ((HwDeviceExtension->jChipType < SIS_315H) && (resinfo == 0 || resinfo == 1)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x30); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x03); - } else { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x2f); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x03); - } - } +#endif + return FALSE; +} +static BOOLEAN +SiS_IsDualLink(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ +#ifdef SIS315H + if(HwInfo->jChipType >= SIS_315H) { + if((SiS_CRT2IsLCD(SiS_Pr, HwInfo)) || + (SiS_IsVAMode(SiS_Pr, HwInfo))) { + if(SiS_Pr->SiS_LCDInfo & LCDDualLink) return TRUE; } } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(SiS_Pr->SiS_HiVision & 0x03) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0xb2); - if(SiS_Pr->SiS_HiVision & 0x02) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0xab); - } - } - } - - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x03); /* 0x18 SR08 (FIFO Threshold?) */ - - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x19,0xF0); - - tempbx = SiS_Pr->SiS_VGAVT; - push1 = tempbx; - - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x09,0xFF); /* 0x09 Set Max VT */ - - tempcx = 0x121; - tempbx = SiS_Pr->SiS_VGAVDE; /* 0x0E Vertical Display End */ - if(tempbx == 357) tempbx = 350; - if(tempbx == 360) tempbx = 350; - if(tempbx == 375) tempbx = 350; - if(tempbx == 405) tempbx = 400; - if(tempbx == 420) tempbx = 400; - if(tempbx == 525) tempbx = 480; - push2 = tempbx; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if(tempbx == 350) tempbx += 5; - if(tempbx == 480) tempbx += 5; - } - } - } - tempbx--; - temp = tempbx & 0x00FF; - tempbx--; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp); /* 0x10 vertical Blank Start */ +#endif + return FALSE; +} - tempbx = push2; - tempbx--; - temp = tempbx & 0x00FF; -#if 0 - /* TW: Missing code from 630/301B 2.04.5a and 650/302LV 1.10.6s (calles int 2f) */ - if(xxx()) { - if(temp == 0xdf) temp = 0xda; +#ifdef SIS315H +static BOOLEAN +SiS_TVEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + if((SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) != 0x0c) return TRUE; + if(SiS_Pr->SiS_VBType & (VB_301C | VB_SIS301LV302LV)) { + if(SiS_GetReg(SiS_Pr->SiS_Part2Port,0x4d) & 0x10) return TRUE; } + return FALSE; +} #endif - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0E,temp); - if(tempbx & 0x0100) { - tempcx |= 0x0002; - if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x000a; - } +#ifdef SIS315H +static BOOLEAN +SiS_LCDAEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) return TRUE; + return FALSE; +} +#endif - tempax = 0x000B; - if(modeflag & DoubleScanMode) tempax |= 0x8000; +#ifdef SIS315H +static BOOLEAN +SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - if(tempbx & 0x0200) { - tempcx |= 0x0040; - if(SiS_Pr->SiS_VBType & VB_SIS301) tempax |= 0x2000; + if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x79); + if(flag & 0x10) return TRUE; } + return FALSE; +} +#endif - if(SiS_Pr->SiS_VBType & VB_SIS301) { - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - if(SiS_Pr->SiS_VGAVDE == 480) { - tempax = (tempax & 0x00ff) | 0x2000; - if(modeflag & DoubleScanMode) tempax |= 0x8000; - } - } - } +#ifdef SIS315H +static BOOLEAN +SiS_IsNotM650orLater(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - temp = (tempax & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp); + if(HwInfo->jChipType == SIS_650) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f); + flag &= 0xF0; + /* Check for revision != A0 only */ + if((flag == 0xe0) || (flag == 0xc0) || + (flag == 0xb0) || (flag == 0x90)) return FALSE; + } else if(HwInfo->jChipType >= SIS_661) return FALSE; + return TRUE; +} +#endif - if(tempbx & 0x0400) tempcx |= 0x0600; +#ifdef SIS315H +static BOOLEAN +SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x11,0x00); /* 0x11 Vertical Blank End */ + if(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */ + } + return FALSE; +} +#endif - tempax = push1; - tempax -= tempbx; - tempax >>= 2; - push1 = tempax; +#ifdef SIS315H +static BOOLEAN +SiS_IsChScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - if(HwDeviceExtension->jChipType >= SIS_315H) { - /* TW: 650/30xLV 1.10.6s */ - if(ModeNo > 0x13) { - if(resinfo != 0x09) { /* 1280x1024 */ - tempax <<= 1; - tempbx += tempax; - } - } else { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) { - tempax <<= 1; - tempbx += tempax; - } - } - } else if((resinfo != 0x09) || (SiS_Pr->SiS_VBType & VB_SIS301)) { - tempax <<= 1; - tempbx += tempax; + if(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 */ } + return FALSE; +} +#endif - if( (SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (SiS_Pr->SiS_HiVision == 3) ) { - tempbx -= 10; - } else { - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - if(!(SiS_Pr->SiS_HiVision & 0x03)) { - tempbx += 40; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VGAHDE == 800) tempbx += 10; - } - } - } - } - } - tempax = push1; - tempax >>= 2; - tempax++; - tempax += tempbx; - push1 = tempax; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - if(tempbx <= 513) { - if(tempax >= 513) tempbx = 513; - } +#ifdef SIS315H +static BOOLEAN +SiS_IsTVOrYPbPrOrScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; + + if(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToTV) return TRUE; + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */ + if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 - TW */ + } else { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToTV) return TRUE; } - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0C,temp); /* 0x0C Vertical Retrace Start */ + return FALSE; +} +#endif - if(!(SiS_Pr->SiS_VBType & VB_SIS301)) { - tempbx--; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp); +#ifdef SIS315H +static BOOLEAN +SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - if(tempbx & 0x0100) tempcx |= 0x0008; + if(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToLCD) return TRUE; + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & SetToLCDA) return TRUE; + } else { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToLCD) return TRUE; + } + return FALSE; +} +#endif - if(tempbx & 0x0200) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20); - } +static BOOLEAN +SiS_BridgeIsOn(SiS_Private *SiS_Pr) +{ + USHORT flag; - tempbx++; - } - if(tempbx & 0x0100) tempcx |= 0x0004; - if(tempbx & 0x0200) tempcx |= 0x0080; - if(tempbx & 0x0400) { - if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x0800; - else tempcx |= 0x0C00; + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + return FALSE; + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); + if((flag == 1) || (flag == 2)) return FALSE; } + return TRUE; +} - tempbx = push1; - temp = tempbx & 0x00FF; - temp &= 0x0F; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0D,temp); /* 0x0D vertical Retrace End */ - - if(tempbx & 0x0010) tempcx |= 0x2000; +static BOOLEAN +SiS_BridgeIsEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - temp = tempcx & 0x00FF; - if(SiS_Pr->SiS_VBType & VB_SIS301) { - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - if(SiS_Pr->SiS_VGAVDE == 480) temp = 0xa3; - } + if(!(SiS_BridgeIsOn(SiS_Pr))) { + flag = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + if(HwInfo->jChipType < SIS_315H) { + flag &= 0xa0; + if((flag == 0x80) || (flag == 0x20)) return FALSE; + } else { + flag &= 0x50; + if((flag == 0x40) || (flag == 0x10)) return FALSE; + } } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp); /* 0x0A CR07 */ + return TRUE; +} - temp = (tempcx & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,temp); /* 0x17 SR0A */ +static BOOLEAN +SiS_BridgeInSlave(SiS_Private *SiS_Pr) +{ + USHORT flag1; - tempax = modeflag; - temp = (tempax & 0xFF00) >> 8; - temp = (temp >> 1) & 0x09; - if(!(SiS_Pr->SiS_VBType & VB_SIS301)) { - /* Only use 8 dot clock */ - temp |= 0x01; - } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,temp); /* 0x16 SR01 */ + flag1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); + if(flag1 & (SetInSlaveMode >> 8)) return TRUE; + return FALSE; +} - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* 0x0F CR14 */ +/*********************************************/ +/* GET VIDEO BRIDGE CONFIG INFO */ +/*********************************************/ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x12,0x00); /* 0x12 CR17 */ +/* Setup general purpose IO for Chrontel communication */ +void +SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo) +{ + unsigned long acpibase; + unsigned short temp; - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(IS_SIS650) { - /* TW: 650/30xLV 1.10.6s */ - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { - temp = 0x80; - } - } else temp = 0x80; - } else temp = 0x00; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1A,temp); /* 0x1A SR0E */ + if(!(SiS_Pr->SiS_ChSW)) return; - return; +#ifndef LINUX_XF86 + SiS_SetRegLong(0xcf8,0x80000874); /* get ACPI base */ + acpibase = SiS_GetRegLong(0xcfc); +#else + acpibase = pciReadLong(0x00000800, 0x74); +#endif + acpibase &= 0xFFFF; + temp = SiS_GetRegShort((USHORT)(acpibase + 0x3c)); /* ACPI register 0x3c: GP Event 1 I/O mode select */ + temp &= 0xFEFF; + SiS_SetRegShort((USHORT)(acpibase + 0x3c), temp); + temp = SiS_GetRegShort((USHORT)(acpibase + 0x3c)); + temp = SiS_GetRegShort((USHORT)(acpibase + 0x3a)); /* ACPI register 0x3a: GP Pin Level (low/high) */ + temp &= 0xFEFF; + if(!(myvbinfo & SetCRT2ToTV)) temp |= 0x0100; + SiS_SetRegShort((USHORT)(acpibase + 0x3a), temp); + temp = SiS_GetRegShort((USHORT)(acpibase + 0x3a)); } void -SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT RefreshRateTableIndex) +SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, + USHORT ModeIdIndex,PSIS_HW_INFO HwInfo, + int checkcrt2mode) { - USHORT modeflag, resinfo; - USHORT push1, push2, tempax, tempbx, tempcx, temp; -#ifdef SIS315H - USHORT pushcx; -#endif - ULONG tempeax=0, tempebx, tempecx, tempvcfact=0; + USHORT tempax,tempbx,temp; + USHORT modeflag, resinfo=0; if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } } - /* TW: Set up Panel Link */ - - /* 1. Horizontal setup */ - - tempax = SiS_Pr->SiS_LCDHDES; - - if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) && - (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) { - tempax -= 8; - } + SiS_Pr->SiS_SetFlag = 0; - tempcx = SiS_Pr->SiS_HT; /* Horiz. Total */ + SiS_Pr->SiS_ModeType = modeflag & ModeInfoFlag; - tempbx = SiS_Pr->SiS_HDE; /* Horiz. Display End */ + tempbx = 0; + if(SiS_BridgeIsOn(SiS_Pr) == 0) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); +#if 0 + if(HwInfo->jChipType < SIS_661) { + /* NO - YPbPr not set yet ! */ + if(SiS_Pr->SiS_YPbPr & ) { + temp &= (SetCRT2ToHiVision | SwitchCRT2 | SetSimuScanMode); /* 0x83 */ + temp |= SetCRT2ToHiVision; /* 0x80 */ + } + if(SiS_Pr->SiS_YPbPr & ) { + temp &= (SetCRT2ToHiVision | SwitchCRT2 | SetSimuScanMode); /* 0x83 */ + temp |= SetCRT2ToSVIDEO; /* 0x08 */ + } + } +#endif + tempbx |= temp; + tempax = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) << 8; + tempax &= (DriverMode | LoadDACFlag | SetNotSimuMode | SetPALTV); + tempbx |= tempax; - if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - if((!SiS_Pr->SiS_IF_DEF_DSTN) && (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480)) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempbx = 800; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempbx = 1024; /* TW */ - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx = 1024; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) tempbx = 1152; /* TW */ - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempbx = 1280; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempbx = 1280; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempbx = 1400; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 1600; - } - } - } - tempcx = (tempcx - tempbx) >> 2; /* HT-HDE / 4 */ +#ifdef SIS315H + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & (VB_SIS301C|VB_SIS302B|VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV)) { + if(ModeNo == 0x03) { + /* Mode 0x03 is never in driver mode */ + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x31,0xbf); + } + if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8))) { + /* Reset LCDA setting */ + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); + } + if(IS_SIS650) { + if(SiS_Pr->SiS_UseLCDA) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xF0) { + if((ModeNo <= 0x13) || (!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8)))) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA)); + } + } + } + } + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) { + tempbx |= SetCRT2ToLCDA; + } + } + if(HwInfo->jChipType >= SIS_661) { + tempbx &= ~(SetCRT2ToYPbPr525750 | SetCRT2ToHiVision); + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(SiS_Pr->SiS_VBType & (VB_SIS301C|VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV)) { + if(temp & 0x04) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0; + if(temp == 0x60) tempbx |= SetCRT2ToHiVision; + else tempbx |= SetCRT2ToYPbPr525750; + } + } else if(SiS_Pr->SiS_VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B)) { + if(temp & 0x04) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0; + if(temp == 0x60) tempbx |= SetCRT2ToHiVision; + } + } + } - push1 = tempax; + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(temp & SetToLCDA) { + tempbx |= SetCRT2ToLCDA; + } + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(temp & EnableCHYPbPr) { + tempbx |= SetCRT2ToCHYPbPr; + } + } + } + } - tempax += tempbx; +#endif /* SIS315H */ - if(tempax >= SiS_Pr->SiS_HT) tempax -= SiS_Pr->SiS_HT; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp = SetCRT2ToSVIDEO | + SetCRT2ToAVIDEO | + SetCRT2ToSCART | + SetCRT2ToLCDA | + SetCRT2ToLCD | + SetCRT2ToRAMDAC | + SetCRT2ToHiVision | + SetCRT2ToYPbPr525750; + } else { + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + temp = SetCRT2ToAVIDEO | + SetCRT2ToSVIDEO | + SetCRT2ToSCART | + SetCRT2ToLCDA | + SetCRT2ToLCD | + SetCRT2ToCHYPbPr; + } else { + temp = SetCRT2ToLCDA | + SetCRT2ToLCD; + } + } else { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + temp = SetCRT2ToTV | SetCRT2ToLCD; + } else { + temp = SetCRT2ToLCD; + } + } + } - push2 = tempax; - - if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if((!SiS_Pr->SiS_IF_DEF_DSTN) && (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480)) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x0028; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempcx = 0x0018; - else if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) ) { - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - tempcx = 0x0017; -#ifdef TWNEWPANEL - tempcx = 0x0018; -#endif - } else { - tempcx = 0x0017; /* A901; sometimes 0x0018; */ - } - } else { - tempcx = 0x0018; - } + if(!(tempbx & temp)) { + tempax = DisableCRT2Display; + tempbx = 0; + } + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + USHORT clearmask = ( DriverMode | + DisableCRT2Display | + LoadDACFlag | + SetNotSimuMode | + SetInSlaveMode | + SetPALTV | + SwitchCRT2 | + SetSimuScanMode ); + if(tempbx & SetCRT2ToLCDA) { + tempbx &= (clearmask | SetCRT2ToLCDA); + } + if(tempbx & SetCRT2ToRAMDAC) { + tempbx &= (clearmask | SetCRT2ToRAMDAC); + } + if(tempbx & SetCRT2ToLCD) { + tempbx &= (clearmask | SetCRT2ToLCD); + } + if(tempbx & SetCRT2ToSCART) { + tempbx &= (clearmask | SetCRT2ToSCART); + } + if(tempbx & SetCRT2ToHiVision) { + tempbx &= (clearmask | SetCRT2ToHiVision); + } + if(tempbx & SetCRT2ToYPbPr525750) { + tempbx &= (clearmask | SetCRT2ToYPbPr525750); + } + } else { + if(HwInfo->jChipType >= SIS_315H) { + if(tempbx & SetCRT2ToLCDA) { + tempbx &= (0xFF00|SwitchCRT2|SetSimuScanMode); + } } - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 0x0028; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0030; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0030; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0040; - } - } - } + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(tempbx & SetCRT2ToTV) { + tempbx &= (0xFF00|SetCRT2ToTV|SwitchCRT2|SetSimuScanMode); + } + } + if(tempbx & SetCRT2ToLCD) { + tempbx &= (0xFF00|SetCRT2ToLCD|SwitchCRT2|SetSimuScanMode); + } + if(HwInfo->jChipType >= SIS_315H) { + if(tempbx & SetCRT2ToLCDA) { + tempbx |= SetCRT2ToLCD; + } + } + } - tempcx += tempax; /* lcdhrs */ - if(tempcx >= SiS_Pr->SiS_HT) tempcx -= SiS_Pr->SiS_HT; + if(tempax & DisableCRT2Display) { + if(!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { + tempbx = SetSimuScanMode | DisableCRT2Display; + } + } - tempax = tempcx >> 3; /* BPLHRS */ - temp = tempax & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,temp); /* Part1_14h; TW: Panel Link Horizontal Retrace Start */ + if(!(tempbx & DriverMode)){ + tempbx |= SetSimuScanMode; + } - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - temp = (tempax & 0x00FF) + 2; - } else { - temp = (tempax & 0x00FF) + 10; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(!SiS_Pr->SiS_IF_DEF_DSTN) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - temp += 6; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) { - temp++; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1024x768) { - temp += 7; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) { - temp -= 0x14; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x768) { - temp -= 10; - } + /* LVDS/CHRONTEL (LCD/TV) and 301BDH (LCD) can only be slave in 8bpp modes */ + if(SiS_Pr->SiS_ModeType <= ModeVGA) { + if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || + ((tempbx & SetCRT2ToLCD) && (SiS_Pr->SiS_VBType & VB_NoLCD)) ) { + modeflag &= (~CRT2Mode); + } + } + + if(!(tempbx & SetSimuScanMode)) { + if(tempbx & SwitchCRT2) { + if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { + if( (HwInfo->jChipType >= SIS_315H) && + (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { + if(resinfo != SIS_RI_1600x1200) { + tempbx |= SetSimuScanMode; + } + } else { + tempbx |= SetSimuScanMode; + } + } + } else { + if(!(SiS_BridgeIsEnabled(SiS_Pr,HwInfo))) { + if(!(tempbx & DriverMode)) { + if(SiS_BridgeInSlave(SiS_Pr)) { + tempbx |= SetSimuScanMode; + } + } + } + } + } + + if(!(tempbx & DisableCRT2Display)) { + if(tempbx & DriverMode) { + if(tempbx & SetSimuScanMode) { + if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { + if( (HwInfo->jChipType >= SIS_315H) && + (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { + if(resinfo != SIS_RI_1600x1200) { + tempbx |= SetInSlaveMode; } - } + } else { + tempbx |= SetInSlaveMode; + } } - } - } - } - } + } + } else { + tempbx |= SetInSlaveMode; + } + } + } - temp &= 0x1F; - temp |= ((tempcx & 0x0007) << 5); - if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0x20; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x15,temp); /* Part1_15h; TW: Panel Link Horizontal Retrace End/Skew */ + SiS_Pr->SiS_VBInfo = tempbx; - tempbx = push2; - tempcx = push1; /* lcdhdes */ + if(HwInfo->jChipType == SIS_630) { + SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo); + } - temp = (tempcx & 0x0007); /* BPLHDESKEW */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1A,temp); /* Part1_1Ah; TW: Panel Link Vertical Retrace Start (2:0) */ +#ifdef TWDEBUG +#ifdef LINUX_KERNEL + printk(KERN_DEBUG "sisfb: (VBInfo= 0x%04x, SetFlag=0x%04x)\n", + SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag); +#endif +#ifdef LINUX_XF86 + xf86DrvMsgVerb(0, X_PROBED, 3, "(init301: VBInfo=0x%04x, SetFlag=0x%04x)\n", + SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag); +#endif +#endif +} - tempcx >>= 3; /* BPLHDES */ - temp = (tempcx & 0x00FF); - if(ModeNo == 0x5b) temp--; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,temp); /* Part1_16h; TW: Panel Link Horizontal Display Enable Start */ +/*********************************************/ +/* DETERMINE YPbPr MODE */ +/*********************************************/ - if(HwDeviceExtension->jChipType < SIS_315H) { - if(tempbx & 0x07) tempbx += 8; - } - tempbx >>= 3; /* BPLHDEE */ - temp = tempbx & 0x00FF; - if(ModeNo == 0x5b) temp--; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,temp); /* Part1_17h; TW: Panel Link Horizontal Display Enable End */ +void +SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ - /* 2. Vertical setup */ + UCHAR temp; - if(HwDeviceExtension->jChipType < SIS_315H) { - tempcx = SiS_Pr->SiS_VGAVT; - tempbx = SiS_Pr->SiS_VGAVDE; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempbx = 600; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempbx = 600; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx = 768; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) tempbx = 768; - else tempbx = 1024; - } - } - tempcx -= tempbx; + /* Note: This variable is only used on 30xLV systems. + * CR38 has a different meaning on LVDS/CH7019 systems. + * On 661 and later, these bits moved to CR35. + * + * On 301, 301B, only HiVision 1080i is supported. + * On 30xLV, 301C, only YPbPr 1080i is supported. + */ - } else { + SiS_Pr->SiS_YPbPr = 0; + if(HwInfo->jChipType >= SIS_661) return; - tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE; /* VGAVT-VGAVDE */ + if(SiS_Pr->SiS_VBType) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + SiS_Pr->SiS_YPbPr = YPbPrHiVision; + } + } + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV | VB_SIS301C)) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(temp & 0x08) { + switch((temp >> 4)) { + case 0x00: SiS_Pr->SiS_YPbPr = YPbPr525i; break; + case 0x01: SiS_Pr->SiS_YPbPr = YPbPr525p; break; + case 0x02: SiS_Pr->SiS_YPbPr = YPbPr750p; break; + case 0x03: SiS_Pr->SiS_YPbPr = YPbPrHiVision; break; + } + } + } } - tempbx = SiS_Pr->SiS_LCDVDES; /* VGAVDES */ - push1 = tempbx; +} - tempax = SiS_Pr->SiS_VGAVDE; +/*********************************************/ +/* DETERMINE TVMode flag */ +/*********************************************/ - if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { - if( (SiS_Pr->SiS_IF_DEF_TRUMPION == 0) && - (!(SiS_Pr->SiS_LCDInfo & LCDPass11)) && - (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) ) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempax = 600; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempax = 600; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempax = 768; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) tempax = 768; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempax = 768; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempax = 1024; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempax = 1050; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempax = 1200; - } - } +void +SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT temp, temp1, resinfo = 0, romindex = 0; + UCHAR OutputSelect = *SiS_Pr->pSiS_OutputSelect; - tempbx += tempax; - if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; + SiS_Pr->SiS_TVMode = 0; - push2 = tempbx; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; + if(SiS_Pr->UseCustomMode) return; - tempcx >>= 1; + if(ModeNo > 0x13) { + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } - if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480)) { - if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { - if(!SiS_Pr->SiS_IF_DEF_DSTN) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x0001; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempcx = 0x0001; - else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768)) { - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - tempcx = 0x0002; -#ifdef TWNEWPANEL - tempcx = 0x0003; -#endif - } else { - tempcx = 0x0002; /* TW: A901; sometimes 0x0003; */ - } - } else tempcx = 0x0003; + if(HwInfo->jChipType < SIS_661) { + + if(SiS_Pr->SiS_VBInfo & SetPALTV) SiS_Pr->SiS_TVMode |= TVSetPAL; + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp = 0; + if((HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730)) { + temp = 0x35; + romindex = 0xfe; + } else if(HwInfo->jChipType >= SIS_315H) { + temp = 0x38; + romindex = 0xf3; + if(HwInfo->jChipType >= SIS_330) romindex = 0x11b; + } + if(temp) { + if(romindex && ROMAddr && SiS_Pr->SiS_UseROM) { + OutputSelect = ROMAddr[romindex]; + if(!(OutputSelect & EnablePALMN)) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,temp,0x3F); + } + } + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,temp); + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + if(temp1 & EnablePALM) { /* 0x40 */ + SiS_Pr->SiS_TVMode |= TVSetPALM; + SiS_Pr->SiS_TVMode &= ~TVSetPAL; + } else if(temp1 & EnablePALN) { /* 0x80 */ + SiS_Pr->SiS_TVMode |= TVSetPALN; + } + } else { + if(temp1 & EnableNTSCJ) { /* 0x40 */ + SiS_Pr->SiS_TVMode |= TVSetNTSCJ; + } + } + } + /* Translate HiVision/YPbPr to our new flags */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + if(SiS_Pr->SiS_YPbPr == YPbPr750p) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; + else if(SiS_Pr->SiS_YPbPr == YPbPr525p) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; + else if(SiS_Pr->SiS_YPbPr == YPbPrHiVision) SiS_Pr->SiS_TVMode |= TVSetHiVision; + else SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p | TVSetYPbPr525i)) { + SiS_Pr->SiS_VBInfo &= ~SetCRT2ToHiVision; + SiS_Pr->SiS_VBInfo |= SetCRT2ToYPbPr525750; + } else if(SiS_Pr->SiS_TVMode & TVSetHiVision) { + SiS_Pr->SiS_TVMode |= TVSetPAL; + } + } + } else if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_CHOverScan) { + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + if((temp & TVOverScan) || (SiS_Pr->SiS_CHOverScan == 1)) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x79); + if((temp & 0x80) || (SiS_Pr->SiS_CHOverScan == 1)) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } + if(SiS_Pr->SiS_CHSOverScan) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; } - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 0x0003; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0001; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0001; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0001; - else tempcx = 0x0057; + } + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + if(temp & EnablePALM) SiS_Pr->SiS_TVMode |= TVSetPALM; + else if(temp & EnablePALN) SiS_Pr->SiS_TVMode |= TVSetPALN; + } else { + if(temp & EnableNTSCJ) { + SiS_Pr->SiS_TVMode |= TVSetNTSCJ; + } + } } } - } - tempbx += tempcx; /* BPLVRS */ + } else { /* 661 and later */ - if(HwDeviceExtension->jChipType < SIS_315H) { - tempbx++; + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + if(temp1 & 0x01) { + SiS_Pr->SiS_TVMode |= TVSetPAL; + if(temp1 & 0x08) { + SiS_Pr->SiS_TVMode |= TVSetPALN; + } else if(temp1 & 0x04) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_Pr->SiS_TVMode &= ~TVSetPAL; + } + SiS_Pr->SiS_TVMode |= TVSetPALM; + } + } else { + if(temp1 & 0x02) { + SiS_Pr->SiS_TVMode |= TVSetNTSCJ; + } + } + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(SiS_Pr->SiS_CHOverScan) { + if((temp1 & 0x10) || (SiS_Pr->SiS_CHOverScan == 1)) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } + } + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + temp1 &= 0xe0; + if(temp1 == 0x00) SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; + else if(temp1 == 0x20) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; + else if(temp1 == 0x40) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + SiS_Pr->SiS_TVMode |= (TVSetHiVision | TVSetPAL); + } + } } - if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) SiS_Pr->SiS_TVMode |= TVSetPAL; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,temp); /* Part1_18h; TW: Panel Link Vertical Retrace Start */ + if(SiS_Pr->SiS_VBType & VB_SISVB) { - tempcx >>= 3; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + SiS_Pr->SiS_TVMode |= TVSetPAL; + SiS_Pr->SiS_TVMode &= ~(TVSetPALM | TVSetPALN | TVSetNTSCJ); + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525i | TVSetYPbPr525p | TVSetYPbPr750p)) { + SiS_Pr->SiS_TVMode &= ~(TVSetPAL | TVSetNTSCJ | TVSetPALM | TVSetPALN); + } + } - if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if( (HwDeviceExtension->jChipType < SIS_315H) && - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) ) tempcx = 0x0001; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x0003; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempcx = 0x0005; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) tempcx = 0x0005; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 0x0011; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0005; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0002; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0011; - else if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - tempcx = 0x0004; -#ifdef TWNEWPANEL - tempcx = 0x0005; -#endif - } else { - tempcx = 0x0004; /* A901; Other BIOS sets 0x0005; */ - } - } else { - tempcx = 0x0005; - } + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { + SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; } } - } - tempcx = tempcx + tempbx + 1; /* BPLVRE */ - temp = tempcx & 0x000F; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xf0,temp); /* Part1_19h; TW: Panel Link Vertical Retrace End (3:0); Misc. */ + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + /* BIOS sets TVNTSC1024 without checking 525p here. Wrong? */ + if(!(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr525p | TVSetYPbPr750p))) { + if(resinfo == SIS_RI_1024x768) { + SiS_Pr->SiS_TVMode |= TVSetNTSC1024; + } + } + } + + SiS_Pr->SiS_TVMode |= TVRPLLDIV2XO; + if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) && + (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; + } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { + SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; + } else if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; + } + } - temp = ((tempbx & 0x0700) >> 8) << 3; /* BPLDESKEW =0 */ - if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40; - if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40; - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { - temp |= 0x80; - } - } else { - if( (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) ) { - if(HwDeviceExtension->jChipRevision >= 0x30) { - temp |= 0x80; - } - } - } } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x87,temp); /* Part1_1Ah; TW: Panel Link Control Signal (7:3); Vertical Retrace Start (2:0) */ - if (HwDeviceExtension->jChipType < SIS_315H) { + SiS_Pr->SiS_VBInfo &= ~SetPALTV; -#ifdef SIS300 /* 300 series */ +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "(init301: TVMode %x, VBInfo %x)\n", SiS_Pr->SiS_TVMode, SiS_Pr->SiS_VBInfo); +#endif - tempeax = SiS_Pr->SiS_VGAVDE << 6; - temp = (USHORT)(tempeax % (ULONG)SiS_Pr->SiS_VDE); - tempeax = tempeax / (ULONG)SiS_Pr->SiS_VDE; - if(temp != 0) tempeax++; - tempebx = tempeax; /* BPLVCFACT */ +} - if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) { - tempebx = 0x003F; - } +/*********************************************/ +/* GET LCD INFO */ +/*********************************************/ - temp = (USHORT)(tempebx & 0x00FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1E,temp); /* Part1_1Eh; TW: Panel Link Vertical Scaling Factor */ +void +SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) +{ +#ifdef SIS300 + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; +#endif +#ifdef SIS315H + UCHAR *myptr = NULL; +#endif + USHORT temp,modeflag,resinfo=0; + const unsigned char SiS300SeriesLCDRes[] = + { 0, 1, 2, 3, 7, 4, 5, 8, + 0, 0, 10, 0, 0, 0, 0, 15 }; -#endif /* SIS300 */ + SiS_Pr->SiS_LCDResInfo = 0; + SiS_Pr->SiS_LCDTypeInfo = 0; + SiS_Pr->SiS_LCDInfo = 0; + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; } else { + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } + } -#ifdef SIS315H /* 310/325 series */ - -#ifdef NEWCH701x - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x03); -#else - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1E,0x23); -#endif - - tempeax = SiS_Pr->SiS_VGAVDE << 18; - temp = (USHORT)(tempeax % (ULONG)SiS_Pr->SiS_VDE); - tempeax = tempeax / SiS_Pr->SiS_VDE; - if(temp != 0) tempeax++; - tempebx = tempeax; /* BPLVCFACT */ - tempvcfact = tempeax; - temp = (USHORT)(tempebx & 0x00FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x37,temp); /* Part1_37h; TW: Panel Link Vertical Scaling Factor */ - temp = (USHORT)((tempebx & 0x00FF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x36,temp); /* Part1_36h; TW: Panel Link Vertical Scaling Factor */ - temp = (USHORT)((tempebx & 0x00030000) >> 16); - if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x35,temp); /* Part1_35h; TW: Panel Link Vertical Scaling Factor */ + if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return; -#endif /* SIS315H */ + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); + if((HwInfo->jChipType < SIS_315H) || (HwInfo->jChipType >= SIS_661)) { + SiS_Pr->SiS_LCDTypeInfo = temp >> 4; + } else { + SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1; } + temp &= 0x0f; + if(HwInfo->jChipType < SIS_315H) { + /* Translate 300 series LCDRes to 315 series for unified usage */ + temp = SiS300SeriesLCDRes[temp]; + } + SiS_Pr->SiS_LCDResInfo = temp; - tempbx = push2; /* BPLVDEE */ - tempcx = push1; - - push1 = temp; - - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(!SiS_Pr->SiS_IF_DEF_DSTN){ - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - if(resinfo == 15) tempcx++; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - if(resinfo == 7) tempcx++; - } - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - if(resinfo == 7) tempcx++; - if(resinfo == 8) tempcx++; /* TW: Doesnt make sense anyway... */ - } else if(resinfo == 8) tempcx++; - } else { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - if(resinfo == 7) tempcx++; - } - } - } + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMin301) + SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMin301; + } else { + if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMinLVDS) + SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMinLVDS; } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - tempcx = SiS_Pr->SiS_VGAVDE; - tempbx = SiS_Pr->SiS_VGAVDE - 1; + if((!SiS_Pr->CP_HaveCustomData) || (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_PanelCustom)) { + if(SiS_Pr->SiS_LCDResInfo > SiS_Pr->SiS_PanelMax) + SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_Panel1024x768; } - temp = ((tempbx & 0x0700) >> 8) << 3; - temp |= ((tempcx & 0x0700) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1D,temp); /* Part1_1Dh; TW: Vertical Display Overflow; Control Signal */ + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + SiS_Pr->SiS_LCDResInfo = Panel_Barco1366; + } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { + SiS_Pr->SiS_LCDResInfo = Panel_848x480; + } + } - temp = tempbx & 0x00FF; - if(SiS_Pr->SiS_IF_DEF_FSTN) temp++; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1C,temp); /* Part1_1Ch; TW: Panel Link Vertical Display Enable End */ + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_800x600: SiS_Pr->PanelXRes = 800; SiS_Pr->PanelYRes = 600; break; + case Panel_1024x768: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; break; + case Panel_1280x1024: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 1024; break; + case Panel_640x480_3: + case Panel_640x480_2: + case Panel_640x480: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; break; + case Panel_1024x600: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 600; break; + case Panel_1152x864: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 864; break; + case Panel_1280x960: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 960; break; + case Panel_1152x768: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 768; break; + case Panel_1400x1050: SiS_Pr->PanelXRes = 1400; SiS_Pr->PanelYRes = 1050; break; + case Panel_1280x768: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; break; + case Panel_1600x1200: SiS_Pr->PanelXRes = 1600; SiS_Pr->PanelYRes = 1200; break; + case Panel_320x480: SiS_Pr->PanelXRes = 320; SiS_Pr->PanelYRes = 480; break; + case Panel_Custom: SiS_Pr->PanelXRes = SiS_Pr->CP_MaxX; + SiS_Pr->PanelYRes = SiS_Pr->CP_MaxY; + break; + case Panel_Barco1366: SiS_Pr->PanelXRes = 1360; SiS_Pr->PanelYRes = 1024; break; + case Panel_848x480: SiS_Pr->PanelXRes = 848; SiS_Pr->PanelYRes = 480; break; + default: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; break; + } + + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + if(HwInfo->jChipType < SIS_661) { + temp &= ~0xe; + } else { +#ifdef SIS315H + if(!(temp & 0x10)) { + if(temp & 0x08) temp |= LCDPass11; + } + temp &= ~0xe; + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + myptr = GetLCDStructPtr661(SiS_Pr, HwInfo); + if(myptr) { + if(myptr[2] & 0x01) temp |= LCDDualLink; + } + } +#endif + } + SiS_Pr->SiS_LCDInfo = temp; - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1B,temp); /* Part1_1Bh; TW: Panel Link Vertical Display Enable Start */ + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { + SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20; /* neg h/v sync, RGB24 */ + } + } - /* 3. Additional horizontal setup (scaling, etc) */ + if(!(SiS_Pr->UsePanelScaler)) SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; + else if(SiS_Pr->UsePanelScaler == 1) SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - tempecx = SiS_Pr->SiS_VGAHDE; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(modeflag & HalfDCLK) - tempecx >>= 1; - } - tempebx = SiS_Pr->SiS_HDE; - if(tempecx == tempebx) tempeax = 0xFFFF; - else { - tempeax = tempecx; - tempeax <<= 16; - temp = (USHORT)(tempeax % tempebx); - tempeax = tempeax / tempebx; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(temp) tempeax++; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) { + /* For non-standard LCD resolution, we let the panel scale */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + if(ModeNo == 0x7c || ModeNo == 0x7d || ModeNo == 0x7e) { + /* We do not scale to 1280x960 (B/C bridges only) */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + if(((HwInfo->jChipType >= SIS_315H) && (ModeNo == 0x23 || ModeNo == 0x24 || ModeNo == 0x25)) || + ((HwInfo->jChipType < SIS_315H) && (ModeNo == 0x55 || ModeNo == 0x5a || ModeNo == 0x5b))) { + /* We do not scale to 1280x768 (B/C bridges only) */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + /* No non-scaling data available for LV bridges */ + SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { + /* No idea about the timing and zoom factors */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + if(ModeNo == 0x3a || ModeNo == 0x4d || ModeNo == 0x65) { + /* We do not scale to 1280x1024 (all bridges) */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + /* No idea about the timing and zoom factors (C bridge only) */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; + } + } + } } } - tempecx = tempeax; - if(HwDeviceExtension->jChipType >= SIS_315H) { - tempeax = SiS_Pr->SiS_VGAHDE; - if(modeflag & HalfDCLK) tempeax >>= 1; - tempeax <<= 16; - tempeax = (tempeax / tempecx) - 1; + if(HwInfo->jChipType >= SIS_315H) { +#ifdef SIS315H + if(HwInfo->jChipType < SIS_661) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x01) { + SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); + SiS_Pr->SiS_LCDInfo |= LCDPass11; + } + } +#endif } else { - tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1; +#ifdef SIS300 + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + if(!(ROMAddr[0x235] & 0x02)) { + SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); + } + } + } + } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10))) { + SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); + } + } +#endif } - tempecx <<= 16; - tempecx |= (tempeax & 0xFFFF); - temp = (USHORT)(tempecx & 0x00FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1F,temp); /* Part1_1Fh; TW: Panel Link DDA Operational Number in each horiz. line */ - tempbx = SiS_Pr->SiS_VDE; - if(HwDeviceExtension->jChipType >= SIS_315H) { - tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact; - tempbx = (USHORT)(tempeax & 0x0FFFF); - } else { - tempax = SiS_Pr->SiS_VGAVDE << 6; - tempbx = push1; - tempbx &= 0x3f; - if(tempbx == 0) tempbx = 64; - tempax = tempax / tempbx; - tempbx = tempax; + /* Trumpion: Assume non-expanding */ + if(SiS_Pr->SiS_IF_DEF_TRUMPION != 0) { + SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx--; - if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempbx = 1; - temp = ((tempbx & 0xFF00) >> 8) << 3; - temp |= (USHORT)((tempecx & 0x0700) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x20,temp); /* Part1_20h; TW: Overflow register */ - - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x21,temp); /* Part1_21h; TW: Panel Link Vertical Accumulator Register */ + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + SiS_Pr->SiS_LCDInfo &= (~LCDPass11); + } - tempecx >>= 16; /* BPLHCFACT */ - if(HwDeviceExtension->jChipType < SIS_315H) { - if(modeflag & HalfDCLK) tempecx >>= 1; +#ifdef SIS315H + if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + /* Enable 302LV/302ELV dual link mode. + * For 661, this is done above. + */ + if((SiS_Pr->SiS_CustomT == CUT_CLEVO1024) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)) { + /* (Sets this in SenseLCD; new paneltypes) */ + SiS_Pr->SiS_LCDInfo |= LCDDualLink; + } + if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) { + SiS_Pr->SiS_LCDInfo |= LCDDualLink; + } + } } - temp = (USHORT)((tempecx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x22,temp); /* Part1_22h; TW: Panel Link Horizontal Scaling Factor High */ +#endif - temp = (USHORT)(tempecx & 0x00FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x23,temp); /* Part1_22h; TW: Panel Link Horizontal Scaling Factor Low */ + if(!((HwInfo->jChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) { - /* 630/301B and 630/LVDS do something for 640x480 panels here */ + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { + if(ModeNo > 0x13) { + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + if((resinfo == SIS_RI_800x600) || (resinfo == SIS_RI_400x300)) { + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } + } + } + } + if(ModeNo == 0x12) { + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } + } + } + + if(modeflag & HalfDCLK) { + if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + if(!(((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (HwInfo->jChipType < SIS_315H)) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480))) { + if(ModeNo > 0x13) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(resinfo == SIS_RI_512x384) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { + if(resinfo == SIS_RI_400x300) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } + } + } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } -#ifdef SIS315H - /* TW: DSTN/FSTN initialisation - hardcoded for 320x480 panel */ - if(SiS_Pr->SiS_IF_DEF_DSTN) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1E,0x01); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x25,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x26,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x27,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x28,0x87); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x29,0x5A); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2A,0x4B); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x007,0x03); - tempbx = SiS_Pr->SiS_HDE + 64; /*Blps = lcdhdee(lcdhdes+HDE) + 64*/ - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x38,temp); - temp=((tempbx & 0xFF00) >> 8) << 3; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,~0x078,temp); - tempbx += 32; /*Blpe=lBlps+32*/ - temp = tempbx & 0x00FF; - if(SiS_Pr->SiS_IF_DEF_FSTN) temp=0; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x39,temp); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3A,0x00); /*Bflml=0*/ - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x007,0x00); - tempbx = SiS_Pr->SiS_VDE / 2; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3B,temp); - temp = ((tempbx & 0xFF00) >> 8) << 3; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x038,temp); - tempeax = SiS_Pr->SiS_HDE << 2; /* BDxFIFOSTOP = (HDE*4)/128 */ - tempebx = 128; - temp = (USHORT)(tempeax % tempebx); - tempeax = tempeax / tempebx; - if(temp != 0) tempeax++; - temp = (USHORT)(tempeax & 0x003F); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x45,~0x0FF,temp); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3F,0x00); /* BDxWadrst0 */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3E,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3D,0x10); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x040,0x00); - tempax = SiS_Pr->SiS_HDE >> 4; /* BDxWadroff = HDE*4/8/8 */ - pushcx = tempax; - temp = tempax & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x43,temp); - temp = ((tempax & 0xFF00) >> 8) << 3; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x0F8,temp); - tempax = SiS_Pr->SiS_VDE; /*BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */ - tempeax = (tempax * pushcx); - tempebx = 0x00100000 + tempeax; - temp = (USHORT)tempebx & 0x000000FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x42,temp); - temp = (USHORT)((tempebx & 0x0000FF00)>>8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x41,temp); - temp = (USHORT)((tempebx & 0x00FF0000)>>16); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x40,temp); - temp = (USHORT)(((tempebx & 0x01000000)>>24) << 7); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x080,temp); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2F,0x03); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,0x50); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x04,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2F,0x01); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x13,0x00); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); /* Unlock */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1e,0x62); - if(SiS_Pr->SiS_IF_DEF_FSTN){ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2b,0x1b); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2c,0xe3); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1e,0x62); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2e,0x04); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2f,0x42); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,0x01); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2b,0x02); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2c,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2d,0x00); - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0f,0x30); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1e,0x7d); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2e,0xe0); } -#endif /* SIS315H */ - return; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) { + SiS_Pr->SiS_SetFlag |= LCDVESATiming; + } + } else { + SiS_Pr->SiS_SetFlag |= LCDVESATiming; + } -} + SiS_Pr->SiS_LCDInfo661 = 0; + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) SiS_Pr->SiS_LCDInfo661 |= 0x0001; + if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) SiS_Pr->SiS_LCDInfo661 |= 0x0002; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) SiS_Pr->SiS_LCDInfo661 |= 0x0008; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) SiS_Pr->SiS_LCDInfo661 |= 0x0010; + SiS_Pr->SiS_LCDInfo661 |= (SiS_Pr->SiS_LCDInfo & 0xe0); + if(SiS_Pr->SiS_LCDInfo & LCDDualLink) SiS_Pr->SiS_LCDInfo661 |= 0x0100; -#ifdef SIS315H -void -SiS_CRT2AutoThreshold(SiS_Private *SiS_Pr, USHORT BaseAddr) -{ - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40); -} +#ifdef LINUX_KERNEL +#ifdef TWDEBUG + printk(KERN_DEBUG "sisfb: (LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)\n", + SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo); #endif +#endif +#ifdef LINUX_XF86 + xf86DrvMsgVerb(0, X_PROBED, 4, + "(init301: LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x SetFlag=0x%04x)\n", + SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo, SiS_Pr->SiS_SetFlag); +#endif +} +/*********************************************/ +/* GET VCLK */ +/*********************************************/ -#ifdef SIS315H -/* TW: For LVDS / 302B/30xLV - LCDA (this must only be called on 310/325 series!) */ -void -SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex) +USHORT +SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { + USHORT tempbx; + const USHORT LCDXlat0VCLK[4] = {VCLK40, VCLK40, VCLK40, VCLK40}; + const USHORT LVDSXlat1VCLK[4] = {VCLK40, VCLK40, VCLK40, VCLK40}; + const USHORT LVDSXlat4VCLK[4] = {VCLK28, VCLK28, VCLK28, VCLK28}; +#ifdef SIS300 + const USHORT LCDXlat1VCLK300[4] = {VCLK65_300, VCLK65_300, VCLK65_300, VCLK65_300}; + const USHORT LCDXlat2VCLK300[4] = {VCLK108_2_300,VCLK108_2_300,VCLK108_2_300,VCLK108_2_300}; + const USHORT LVDSXlat2VCLK300[4]= {VCLK65_300, VCLK65_300, VCLK65_300, VCLK65_300}; + const USHORT LVDSXlat3VCLK300[4]= {VCLK65_300, VCLK65_300, VCLK65_300, VCLK65_300}; +#endif +#ifdef SIS315H + const USHORT LCDXlat1VCLK310[4] = {VCLK65_315, VCLK65_315, VCLK65_315, VCLK65_315}; + const USHORT LCDXlat2VCLK310[4] = {VCLK108_2_315,VCLK108_2_315,VCLK108_2_315,VCLK108_2_315}; + const USHORT LVDSXlat2VCLK310[4]= {VCLK65_315, VCLK65_315, VCLK65_315, VCLK65_315}; + const USHORT LVDSXlat3VCLK310[4]= {VCLK108_2_315,VCLK108_2_315,VCLK108_2_315,VCLK108_2_315}; +#endif + USHORT CRT2Index,VCLKIndex=0; USHORT modeflag,resinfo; - USHORT push1,push2,tempax,tempbx,tempcx,temp; - ULONG tempeax=0,tempebx,tempecx,tempvcfact; + const UCHAR *CHTVVCLKPtr = NULL; + const USHORT *LCDXlatVCLK1 = NULL; + const USHORT *LCDXlatVCLK2 = NULL; + const USHORT *LVDSXlatVCLK2 = NULL; + const USHORT *LVDSXlatVCLK3 = NULL; - if(IS_SIS330) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); /* Xabre 1.01.03 */ - } else if(IS_SIS740) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 740/LVDS */ - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04); /* 740/LVDS */ - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x03); - } else { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); /* 740/301LV 1.10.1i */ - } + if(HwInfo->jChipType >= SIS_315H) { +#ifdef SIS315H + LCDXlatVCLK1 = LCDXlat1VCLK310; + LCDXlatVCLK2 = LCDXlat2VCLK310; + LVDSXlatVCLK2 = LVDSXlat2VCLK310; + LVDSXlatVCLK3 = LVDSXlat3VCLK310; +#endif } else { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 650/LVDS */ - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04); /* 650/LVDS */ - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x00); /* 650/LVDS 1.10.07 */ - } else { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2D,0x0f); /* 650/30xLv 1.10.6s */ - } +#ifdef SIS300 + LCDXlatVCLK1 = LCDXlat1VCLK300; + LCDXlatVCLK2 = LCDXlat2VCLK300; + LVDSXlatVCLK2 = LVDSXlat2VCLK300; + LVDSXlatVCLK3 = LVDSXlat3VCLK300; +#endif } if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } - - tempax = SiS_Pr->SiS_LCDHDES; - tempbx = SiS_Pr->SiS_HDE; - tempcx = SiS_Pr->SiS_HT; - - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx = 1024; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempbx = 1400; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 1600; - else tempbx = 1280; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + CRT2Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; } - tempcx -= tempbx; /* HT-HDE */ - push1 = tempax; - tempax += tempbx; /* lcdhdee */ - tempbx = SiS_Pr->SiS_HT; - if(tempax >= tempbx) tempax -= tempbx; - - push2 = tempax; /* push ax lcdhdee */ - tempcx >>= 2; + if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 30x/B/LV */ - /* TW: 650/30xLV 1.10.6s, 740/LVDS */ - if( ((SiS_Pr->SiS_IF_DEF_LVDS == 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) || - ((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) ) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x28; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempcx = 0x18; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x30; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x40; - else tempcx = 0x30; - } - } + if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - tempcx += tempax; /* lcdhrs */ - if(tempcx >= tempbx) tempcx -= tempbx; - /* v ah,cl */ - tempax = tempcx; - tempax >>= 3; /* BPLHRS */ - temp = tempax & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,temp); /* Part1_14h */ + CRT2Index >>= 6; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* LCD */ - temp += 10; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - temp += 6; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) { - temp++; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1024x768) { - temp += 7; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) { - temp -= 10; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { + VCLKIndex = LCDXlat0VCLK[CRT2Index]; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + VCLKIndex = LCDXlatVCLK1[CRT2Index]; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { + VCLKIndex = LCDXlatVCLK1[CRT2Index]; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { + VCLKIndex = LCDXlatVCLK1[CRT2Index]; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { + VCLKIndex = VCLK81_300; /* guessed */ + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { + VCLKIndex = VCLK108_3_300; + if(resinfo == SIS_RI_1280x1024) VCLKIndex = VCLK100_300; + } else { + VCLKIndex = LCDXlatVCLK2[CRT2Index]; + } + } else { + if( (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) || + (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + VCLKIndex = VCLK108_2_315; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { + VCLKIndex = VCLK81_315; /* guessed */ + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + VCLKIndex = VCLK108_2_315; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + VCLKIndex = VCLK162_315; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { + VCLKIndex = VCLK108_3_315; + if(resinfo == SIS_RI_1280x1024) VCLKIndex = VCLK100_315; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + VCLKIndex = LCDXlatVCLK1[CRT2Index]; + } else { + VCLKIndex = LCDXlatVCLK2[CRT2Index]; + } + } else { + VCLKIndex = (UCHAR)SiS_GetRegByte((USHORT)(SiS_Pr->SiS_P3ca+0x02)); /* Port 3cch */ + VCLKIndex = ((VCLKIndex >> 2) & 0x03); + if(ModeNo > 0x13) { + VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + } + if(ModeNo <= 0x13) { + if(HwInfo->jChipType <= SIS_315PRO) { + if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42; + } else { + if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x00; + } + } + if(HwInfo->jChipType <= SIS_315PRO) { + if(VCLKIndex == 0) VCLKIndex = 0x41; + if(VCLKIndex == 1) VCLKIndex = 0x43; + if(VCLKIndex == 4) VCLKIndex = 0x44; } } } - } - } - } - temp &= 0x1F; - temp |= ((tempcx & 0x07) << 5); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x15,temp); /* Part1_15h */ - tempbx = push2; /* lcdhdee */ - tempcx = push1; /* lcdhdes */ - temp = (tempcx & 0x00FF); - temp &= 0x07; /* BPLHDESKEW */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1A,temp); /* Part1_1Ah */ + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */ - tempcx >>= 3; /* BPLHDES */ - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,temp); /* Part1_16h */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = HiTVVCLKDIV2; + else VCLKIndex = HiTVVCLK; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + if(modeflag & Charx8Dot) VCLKIndex = HiTVSimuVCLK; + else VCLKIndex = HiTVTextVCLK; + } + } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) VCLKIndex = YPbPr750pVCLK - TVCLKBASE_315; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) VCLKIndex = TVVCLKDIV2; + else if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = TVVCLKDIV2; + else VCLKIndex = TVVCLK; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(tempbx & 0x07) tempbx += 8; - } - tempbx >>= 3; /* BPLHDEE */ - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,temp); /* Part1_17h */ + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex += TVCLKBASE_300; + } else { + VCLKIndex += TVCLKBASE_315; + } - tempcx = SiS_Pr->SiS_VGAVT; - tempbx = SiS_Pr->SiS_VGAVDE; - tempcx -= tempbx; /* GAVT-VGAVDE */ - tempbx = SiS_Pr->SiS_LCDVDES; /* VGAVDES */ - push1 = tempbx; - if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempax = 768; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempax = 768; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempax = 1024; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempax = 1050; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempax = 1200; - else tempax = 960; - } else tempax = SiS_Pr->SiS_VGAVDE; /* Trumpion */ + } else { /* VGA2 */ - tempbx += tempax; - tempax = SiS_Pr->SiS_VT; /* VT */ - if(tempbx >= tempax) tempbx -= tempax; + VCLKIndex = (UCHAR)SiS_GetRegByte((USHORT)(SiS_Pr->SiS_P3ca+0x02)); + VCLKIndex = ((VCLKIndex >> 2) & 0x03); + if(ModeNo > 0x13) { + VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex &= 0x3f; + if( (HwInfo->jChipType == SIS_630) && + (HwInfo->jChipRevision >= 0x30)) { + if(VCLKIndex == 0x14) VCLKIndex = 0x34; + } + /* Better VGA2 clock for 1280x1024@75 */ + if(VCLKIndex == 0x17) VCLKIndex = 0x45; + } + } + } - push2 = tempbx; - - tempcx >>= 2; + } else { /* If not programming CRT2 */ - /* TW: 650/30xLV 1.10.6s, 740/LVDS */ - if( ((SiS_Pr->SiS_IF_DEF_LVDS == 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) || - ((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) ) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 1; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempcx = 3; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 3; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 1; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 1; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 1; - else tempcx = 0x0057; + VCLKIndex = (UCHAR)SiS_GetRegByte((USHORT)(SiS_Pr->SiS_P3ca+0x02)); + VCLKIndex = ((VCLKIndex >> 2) & 0x03); + if(ModeNo > 0x13) { + VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex &= 0x3f; + if( (HwInfo->jChipType != SIS_630) && + (HwInfo->jChipType != SIS_300) ) { + if(VCLKIndex == 0x1b) VCLKIndex = 0x35; + } + } + } } - } - tempbx += tempcx; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - tempbx++; /* BPLVRS */ - } - if(tempbx >= tempax) tempbx -= tempax; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,temp); /* Part1_18h */ + } else { /* LVDS */ - tempcx >>= 3; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 3; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempcx = 5; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 5; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 5; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 2; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 2; - } - } - } - tempcx += tempbx; - tempcx++; /* BPLVRE */ - temp = tempcx & 0x00FF; - temp &= 0x0F; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp); - } else { - /* TW: 650/30xLV 1.10.6s, Xabre */ - temp |= 0xC0; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp); /* Part1_19h */ - } + VCLKIndex = CRT2Index; - temp = (tempbx & 0xFF00) >> 8; - temp &= 0x07; - temp <<= 3; /* BPLDESKEW =0 */ - tempbx = SiS_Pr->SiS_VGAVDE; - if(tempbx != SiS_Pr->SiS_VDE) temp |= 0x40; - if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) temp |= 0x80; - } - } else { - if(IS_SIS650) { - /* TW: 650/30xLV 1.10.6s */ - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) temp |= 0x80; + if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { /* programming CRT2 */ + + if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { + + VCLKIndex &= 0x1f; + tempbx = 0; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + tempbx += 2; + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) tempbx = 8; + } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + tempbx = 4; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { + tempbx = 6; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + } + } + switch(tempbx) { + case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break; + case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break; + case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break; + case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; + case 4: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALM; break; + case 5: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALM; break; + case 6: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALN; break; + case 7: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALN; break; + case 8: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKSOPAL; break; + default: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; + } + VCLKIndex = CHTVVCLKPtr[VCLKIndex]; + + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + + VCLKIndex >>= 6; + if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480)) + VCLKIndex = LVDSXlat1VCLK[VCLKIndex]; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) + VCLKIndex = LVDSXlat4VCLK[VCLKIndex]; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) + VCLKIndex = LVDSXlatVCLK2[VCLKIndex]; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) + VCLKIndex = LVDSXlatVCLK2[VCLKIndex]; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) + VCLKIndex = LVDSXlatVCLK2[VCLKIndex]; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) + VCLKIndex = VCLK68_315; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) + VCLKIndex = VCLK162_315; + else + VCLKIndex = LVDSXlatVCLK3[VCLKIndex]; + + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + /* Special Timing: Barco iQ Pro R series */ + VCLKIndex = 0x44; + } + + if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex = VCLK34_300; + /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ + } else { + VCLKIndex = VCLK34_315; + /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ + } + } + + } else { + + VCLKIndex = (UCHAR)SiS_GetRegByte((USHORT)(SiS_Pr->SiS_P3ca+0x02)); + VCLKIndex = ((VCLKIndex >> 2) & 0x03); + if(ModeNo > 0x13) { + VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex &= 0x3F; + } + if( (HwInfo->jChipType == SIS_630) && + (HwInfo->jChipRevision >= 0x30) ) { + if(VCLKIndex == 0x14) VCLKIndex = 0x2e; + } + } } - } else { - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) temp |= 0x80; + + } else { /* if not programming CRT2 */ + + VCLKIndex = (UCHAR)SiS_GetRegByte((USHORT)(SiS_Pr->SiS_P3ca+0x02)); + VCLKIndex = ((VCLKIndex >> 2) & 0x03); + if(ModeNo > 0x13) { + VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex &= 0x3F; + if( (HwInfo->jChipType != SIS_630) && + (HwInfo->jChipType != SIS_300) ) { + if(VCLKIndex == 0x1b) VCLKIndex = 0x35; + } +#if 0 + if(HwInfo->jChipType == SIS_730) { + if(VCLKIndex == 0x0b) VCLKIndex = 0x40; /* 1024x768-70 */ + if(VCLKIndex == 0x0d) VCLKIndex = 0x41; /* 1024x768-75 */ + } +#endif + } + } + } + } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x87,temp); /* Part1_1Ah */ - tempbx = push2; /* BPLVDEE */ - tempcx = push1; /* NPLVDES */ - push1 = (USHORT)(tempeax & 0xFFFF); +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "VCLKIndex %d (0x%x)\n", VCLKIndex, VCLKIndex); +#endif - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - if(resinfo == 7) tempcx++; - } - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - tempbx = SiS_Pr->SiS_VGAVDE; - tempcx = tempbx; - tempbx--; - } + return(VCLKIndex); +} - temp = (tempbx & 0xFF00) >> 8; - temp &= 0x07; - temp <<= 3; - temp = temp | (((tempcx & 0xFF00) >> 8) & 0x07); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1D,temp); /* Part1_1Dh */ +/*********************************************/ +/* SET CRT2 MODE TYPE REGISTERS */ +/*********************************************/ - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1C,temp); /* Part1_1Ch */ +static void +SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT i,j,modeflag; + USHORT tempcl,tempah=0; +#ifdef SIS300 + USHORT temp; +#endif +#ifdef SIS315H + USHORT tempbl, tempah2, tempbl2; +#endif - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1B,temp); /* Part1_1Bh */ + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } + } - tempecx = SiS_Pr->SiS_VGAVT; - tempebx = SiS_Pr->SiS_VDE; - tempeax = SiS_Pr->SiS_VGAVDE; - tempecx -= tempeax; /* VGAVT-VGAVDE */ - tempeax <<= 18; - temp = (USHORT)(tempeax % tempebx); - tempeax = tempeax / tempebx; - if(temp) tempeax++; - tempebx = tempeax; /* BPLVCFACT */ - tempvcfact = tempeax; - temp = (USHORT)(tempebx & 0x00FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x37,temp); + /* BIOS does not do this (neither 301 nor LVDS) */ + /* (But it's harmless; see SetCRT2Offset) */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0x00); /* fix write part1 index 0 BTDRAM bit Bug */ - temp = (USHORT)((tempebx & 0x00FF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x36,temp); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - temp = (USHORT)((tempebx & 0x00030000) >> 16); - if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x35,temp); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xAF,0x40); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2E,0xF7); - tempecx = SiS_Pr->SiS_VGAHDE; - if(modeflag & HalfDCLK) tempecx >>= 1; - tempebx = SiS_Pr->SiS_HDE; - tempeax = tempecx; - tempeax <<= 16; - temp = tempeax % tempebx; - tempeax = tempeax / tempebx; - if(temp) tempeax++; - if(tempebx == tempecx) tempeax = 0xFFFF; - tempecx = tempeax; - tempeax = SiS_Pr->SiS_VGAHDE; - if(modeflag & HalfDCLK) tempeax >>= 1; - tempeax <<= 16; - tempeax = tempeax / tempecx; - tempecx <<= 16; - tempeax--; - tempecx = tempecx | (tempeax & 0xFFFF); - temp = (USHORT)(tempecx & 0x00FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1F,temp); /* Part1_1Fh */ + } else { - tempeax = SiS_Pr->SiS_VGAVDE; - tempeax <<= 18; - tempeax = tempeax / tempvcfact; - tempbx = (USHORT)(tempeax & 0x0FFFF); + for(i=0,j=4; i<3; i++,j++) SiS_SetReg(SiS_Pr->SiS_Part1Port,j,0); - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx--; + tempcl = SiS_Pr->SiS_ModeType; - if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempbx = 1; + if(HwInfo->jChipType < SIS_315H) { - temp = ((tempbx & 0xFF00) >> 8) << 3; - temp = temp | (USHORT)(((tempecx & 0x0000FF00) >> 8) & 0x07); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x20,temp); /* Part1_20h */ +#ifdef SIS300 /* ---- 300 series ---- */ - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x21,temp); /* Part1_21h */ + /* For 301BDH: (with LCD via LVDS) */ + if(SiS_Pr->SiS_VBType & VB_NoLCD) { + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32); + temp &= 0xef; + temp |= 0x02; + if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) || (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + temp |= 0x10; + temp &= 0xfd; + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); + } - tempecx >>= 16; /* BPLHCFACT */ - if(modeflag & HalfDCLK) tempecx >>= 1; - temp = (USHORT)((tempecx & 0x0000FF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x22,temp); /* Part1_22h */ + if(ModeNo > 0x13) { + tempcl -= ModeVGA; + if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */ + tempah = ((0x10 >> tempcl) | 0x80); + } + } else tempah = 0x80; - temp=(USHORT)(tempecx & 0x000000FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x23,temp); + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0; -#if 0 - /* TW: Missing code (calles int 2f) (650/302LV 1.10.6s; 1.10.7w doesn't do this) */ - if(xxx()) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0e,0xda); - } -#endif +#endif /* SIS300 */ - /* TW: Only for LVDS and 301LV/302LV */ - if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBInfo & VB_SIS301LV302LV)){ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1e,0x20); - } + } else { - return; -} -#endif /* SIS 315 */ +#ifdef SIS315H /* ------- 315/330 series ------ */ -void SiS_SetCRT2Offset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex ,USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT offset; - UCHAR temp; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x08); + } + } - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) return; + if(ModeNo > 0x13) { + tempcl -= ModeVGA; + if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */ + tempah = (0x08 >> tempcl); + if (tempah == 0) tempah = 1; + tempah |= 0x40; + } + } else tempah = 0x40; - offset = SiS_GetOffset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); -#if 0 - if(SiS_Pr->LCDResInfo == 13) offset >>= 1; - if(SiS_Pr->LCDResInfo == 12) offset >>= 1; -#endif - temp = (UCHAR)(offset & 0xFF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,temp); - temp = (UCHAR)((offset & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x09,temp); - temp = (UCHAR)(((offset >> 3) & 0xFF) + 1); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,temp); -} + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50; -USHORT -SiS_GetOffset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp,colordepth; - USHORT modeinfo,index,infoflag; +#endif /* SIS315H */ - if(SiS_Pr->UseCustomMode) { - infoflag = SiS_Pr->CInfoFlag; - temp = SiS_Pr->CHDisplay / 16; - } else { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - modeinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeInfo; - - if(HwDeviceExtension->jChipType < SIS_315H ) { - index = (modeinfo >> 4) & 0xFF; - } else { - index = (modeinfo >> 8) & 0xFF; } - temp = SiS_Pr->SiS_ScreenOffset[index]; - } - - colordepth = SiS_GetColorDepth(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex); + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; - if(infoflag & InterlaceMode) temp <<= 1; + if(HwInfo->jChipType < SIS_315H) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); + } else { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(IS_SIS740) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); + } + } + } - temp *= colordepth; + if(SiS_Pr->SiS_VBType & VB_SISVB) { - /* TW: For 1400x1050 and 856x480 */ - if( ( ((ModeNo >= 0x26) && (ModeNo <= 0x28)) || - ModeNo == 0x3f || - ModeNo == 0x42 || - ModeNo == 0x45 ) || - (SiS_Pr->UseCustomMode && (SiS_Pr->CHDisplay % 16)) ) { - colordepth >>= 1; - temp += colordepth; - } + tempah = 0x01; + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + tempah |= 0x02; + } + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + tempah ^= 0x05; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + tempah ^= 0x01; + } + } - return(temp); -} + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; -USHORT -SiS_GetColorDepth(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) -{ - USHORT ColorDepth[6] = { 1, 2, 4, 4, 6, 8}; - SHORT index; - USHORT modeflag; + if(HwInfo->jChipType < SIS_315H) { - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - if(ModeNo <= 0x13) - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - else - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } + tempah = (tempah << 5) & 0xFF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); + tempah = (tempah >> 5) & 0xFF; - index = (modeflag & ModeInfoFlag) - ModeEGA; - if(index < 0) index = 0; - return(ColorDepth[index]); -} + } else { -void -SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT tempah=0,tempbl,infoflag,flag; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF8,tempah); - flag = 0; - tempbl = 0xC0; + } - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; + if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { + tempah |= 0x10; + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */ + if((HwInfo->jChipType < SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301)) { + if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960)) { + tempah |= 0x80; + } + } else { + tempah |= 0x80; + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - tempah = 0; - } else if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDInfo & LCDSync)) { - tempah = SiS_Pr->SiS_LCDInfo; - } else tempah = infoflag >> 8; - - tempah &= 0xC0; - - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p))) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + tempah |= 0x20; + } + } + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - tempah >>= 3; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xE7,tempah); - } - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah); - } else { + tempah = 0; - if(HwDeviceExtension->jChipType < SIS_315H) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempah |= 0x40; -#ifdef SIS300 /* ---- 300 series --- */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) { + tempah |= 0x40; + } + } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 630 - 301B(-DH) */ + if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) || + ((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) && + (SiS_Pr->CP_MaxX >= 1280) && (SiS_Pr->CP_MaxY >= 960))) { + tempah |= 0x80; + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - tempah = SiS_Pr->SiS_LCDInfo; - if(SiS_Pr->SiS_LCDInfo & LCDSync) { - flag = 1; - } - } - if(flag != 1) tempah = infoflag >> 8; - tempah &= 0xC0; - - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0C,tempah); - if (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - /* TW: BIOS does something here @@@ */ - } + } else { /* LVDS */ - tempah &= 0x3f; - tempah |= tempbl; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - - } else { /* 630 - 301 */ - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - tempah = SiS_Pr->SiS_LCDInfo; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCDShift) { /* ! */ - flag = 1; - } - } - if(flag != 1) tempah = infoflag >> 8; - tempah &= 0xC0; - tempah |= 0x30; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x3F,tempah); + if(HwInfo->jChipType >= SIS_315H) { - } + /* LVDS can only be slave in 8bpp modes */ + tempah = 0x80; + if((modeflag & CRT2Mode) && (SiS_Pr->SiS_ModeType > ModeVGA)) { + if(SiS_Pr->SiS_VBInfo & DriverMode) { + tempah |= 0x02; + } + } -#endif /* SIS300 */ + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + tempah |= 0x02; + } - } else { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tempah ^= 0x01; + } -#ifdef SIS315H /* ----- 310/325 series ---- */ + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { + tempah = 1; + } - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* 310/325 - 30xLV */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah); + + } else { + + tempah = 0; + if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { + tempah |= 0x02; + } + tempah <<= 5; + + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); + + } + + } + + } /* LCDA */ + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + if(HwInfo->jChipType >= SIS_315H) { + +#ifdef SIS315H + + unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01);; + + /* The following is nearly unpreditable and varies from machine + * to machine. Especially the 301DH seems to be a real trouble + * maker. Some BIOSes simply set the registers (like in the + * NoLCD-if-statements here), some set them according to the + * LCDA stuff. It is very likely that some machines are not + * treated correctly in the following, very case-orientated + * code. What do I do then...? + */ + + /* 740 variants match for 30xB, 301B-DH, 30xLV */ + + if(!(IS_SIS740)) { + tempah = 0x04; /* For all bridges */ + tempbl = 0xfb; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + tempah = 0x00; + if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { + tempbl = 0xff; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); + } + + /* The following two are responsible for eventually wrong colors + * in TV output. The DH (VB_NoLCD) conditions are unknown; the + * b0 was found in some 651 machine (Pim; P4_23=0xe5); the b1 version + * in a 650 box (Jake). What is the criteria? + */ + + if((IS_SIS740) || (HwInfo->jChipType >= SIS_661)) { + tempah = 0x30; + tempbl = 0xc0; + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { + tempah = 0x00; + tempbl = 0x00; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xcf,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,tempbl); + } else if(SiS_Pr->SiS_VBType & VB_SIS301) { + /* Fixes "TV-blue-bug" on 315+301 */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xcf); /* For 301 */ + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); + } else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xLV */ + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0); + } else if((SiS_Pr->SiS_VBType & VB_NoLCD) && (bridgerev == 0xb0)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xB-DH rev b0 (or "DH on 651"?) */ + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0); + } else { + tempah = 0x30; tempah2 = 0xc0; /* For 30xB (and 301BDH rev b1) */ + tempbl = 0xcf; tempbl2 = 0x3f; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + tempah = tempah2 = 0x00; + if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { + tempbl = tempbl2 = 0xff; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl2,tempah2); + } + + if(IS_SIS740) { + tempah = 0x80; + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { + tempah = 0x00; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,0x7f,tempah); + } else { + tempah = 0x00; + tempbl = 0x7f; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + tempbl = 0xff; + if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) { + tempah = 0x80; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah); + } + + /* 661: Sets p4 27 and 34 here, done in SetGroup4 here */ + +#endif /* SIS315H */ + + } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); + + if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || + ( (SiS_Pr->SiS_VBType & VB_NoLCD) && + (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) ) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x23,0x7F); + } else { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x23,0x80); + } + + } + + } else { /* LVDS */ + +#ifdef SIS315H + if(HwInfo->jChipType >= SIS_315H) { + + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + + tempah = 0x04; + tempbl = 0xfb; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + tempah = 0x00; + if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { + tempbl = 0xff; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); + + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); + } + + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); + + } else if(HwInfo->jChipType == SIS_550) { + + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); + + } + + } +#endif + + } + +} + +/*********************************************/ +/* GET RESOLUTION DATA */ +/*********************************************/ + +USHORT +SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex) +{ + USHORT resindex; + + if(ModeNo <= 0x13) + resindex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + else + resindex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + + return(resindex); +} + +static void +SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT xres,yres,modeflag=0,resindex; + + if(SiS_Pr->UseCustomMode) { + SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = SiS_Pr->CHDisplay; + SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = SiS_Pr->CVDisplay; + return; + } + + resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex); + + if(ModeNo <= 0x13) { + xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; + yres = SiS_Pr->SiS_StResInfo[resindex].VTotal; + } else { + xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; + yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } + + if((!SiS_Pr->SiS_IF_DEF_DSTN) && (!SiS_Pr->SiS_IF_DEF_FSTN)) { + + if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) { + if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) { + if(yres == 350) yres = 400; + } + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x3a) & 0x01) { + if(ModeNo == 0x12) yres = 400; + } + } + + if(ModeNo > 0x13) { + if(modeflag & HalfDCLK) xres *= 2; + if(modeflag & DoubleScanMode) yres *= 2; + } + + } + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + if(xres == 720) xres = 640; + } else { + if(SiS_Pr->SiS_VBType & VB_NoLCD) { /* 301BDH */ + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVision)) { + if(xres == 720) xres = 640; + } + if(SiS_Pr->SiS_SetFlag & SetDOSMode) { + yres = 400; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480; + } else { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480; + } + } + } else { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVision)) { + if(xres == 720) xres = 640; + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + if(yres == 1024) yres = 1056; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + /* BIOS bug - does this regardless of scaling */ + if(yres == 400) yres = 405; + } + if(yres == 350) yres = 360; + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + if(yres == 360) yres = 375; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + if(yres == 350) yres = 357; + if(yres == 400) yres = 420; + if(yres == 480) yres = 525; + } + } + } + } + } + } + } else { + if(xres == 720) xres = 640; + if(SiS_Pr->SiS_SetFlag & SetDOSMode) { + yres = 400; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480; + } else { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480; + } + if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) { + yres = 480; + } + } + } + SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; + SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; +} + +/*********************************************/ +/* GET CRT2 TIMING DATA */ +/*********************************************/ + +static BOOLEAN +SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, USHORT *ResIndex, + USHORT *DisplayType) + { + USHORT tempbx,modeflag=0; + USHORT Flag,CRT2CRTC; + + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return FALSE; + } + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return FALSE; + } else + return FALSE; + + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + CRT2CRTC = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + CRT2CRTC = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + } + + Flag = 1; + tempbx = 0; + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + Flag = 0; + tempbx = 18; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx++; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + tempbx += 2; + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; + } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + tempbx = 18; /* PALM uses NTSC data */ + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx++; + } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { + tempbx = 20; /* PALN uses PAL data */ + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx++; + } + } + } + } + if(Flag) { + tempbx = SiS_Pr->SiS_LCDResInfo; + tempbx -= SiS_Pr->SiS_PanelMinLVDS; + if(SiS_Pr->SiS_LCDResInfo <= SiS_Pr->SiS_Panel1280x1024) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 6; + if(modeflag & HalfDCLK) tempbx += 3; + } else { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + tempbx = 14; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { + tempbx = 23; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { + tempbx = 27; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + tempbx = 36; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { + tempbx = 40; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) { + tempbx = 54; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2) { + tempbx = 52; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { + tempbx = 50; + if(modeflag & HalfDCLK) tempbx++; + } + + } + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + tempbx = 12; + if(modeflag & HalfDCLK) tempbx++; + } + } - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37); - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - - } else { /* 310/325 - 301, 301B */ - - tempah = infoflag >> 8; - tempah &= 0xC0; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDInfo & LCDSync) { - tempah = SiS_Pr->SiS_LCDInfo; - tempah &= 0xC0; - } - } - - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; #if 0 - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - /* TW: BIOS does something here @@@ */ - } -#endif - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if(SiS_Pr->SiS_IF_DEF_FSTN) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){ + tempbx = 22; + } + } +#endif + + *ResIndex = CRT2CRTC & 0x3F; + *DisplayType = tempbx; + return TRUE; +} + +static void +SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT tempbx=0,tempal=0; + USHORT Flag,resinfo=0; + + if(ModeNo <= 0x13) { + tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } + + if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_IF_DEF_LVDS == 0)) { + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */ + + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { + tempbx = 15; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + tempbx = 20; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 21; + else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 22; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + tempbx = 23; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 24; + else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 25; +#if 0 + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { + tempbx = 26; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 27; + else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 28; +#endif + } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx = 13; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempbx = 14; + else { + tempbx = 29; + if(ModeNo >= 0x13) { + /* see below */ + if(resinfo == SIS_RI_1280x960) tempal = 10; + } + } + } else { + tempbx = 29; + if(ModeNo >= 0x13) { + /* 1280x768 and 1280x960 have same CRT2CRTC, + * so we change it here if 1280x960 is chosen + */ + if(resinfo == SIS_RI_1280x960) tempal = 10; + } + } + } else { + tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_Panel1024x768; + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + tempbx += 10; + } + } + +#ifdef SIS315H + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + tempbx = 50; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 51; + else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 52; + } + } +#endif + + } else { /* TV */ + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + /* if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_TVMode &= (~TVSetTVSimuMode); */ + tempbx = 2; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + tempbx = 13; + if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) tempbx = 14; + } + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempbx = 7; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempbx = 6; + else tempbx = 5; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; + } else { + if(SiS_Pr->SiS_TVMode & TVSetPAL) tempbx = 3; + else tempbx = 4; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; + } - } - -#endif /* SIS315H */ + } + + tempal &= 0x3F; + + if(ModeNo > 0x13) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) { + if(tempal == 6) tempal = 7; + if((resinfo == SIS_RI_720x480) || + (resinfo == SIS_RI_720x576) || + (resinfo == SIS_RI_768x576)) { + tempal = 6; + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { + if(resinfo == SIS_RI_1024x768) { + tempal = 8; + } + } + } + } + } + + *CRT2Index = tempbx; + *ResIndex = tempal; + + } else { /* LVDS, 301B-DH (if running on LCD) */ + + Flag = 1; + tempbx = 0; + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + Flag = 0; + tempbx = 10; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + tempbx += 2; + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; + } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + tempbx = 90; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { + tempbx = 92; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + } + } + } + } + + if(Flag) { + + if(SiS_Pr->SiS_LCDResInfo <= SiS_Pr->SiS_Panel1280x1024) { + tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_PanelMinLVDS; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 3; + + if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { + tempbx = 82; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { + tempbx = 18; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { + tempbx = 6; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2) { + tempbx = 30; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) { + tempbx = 30; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { + tempbx = 15; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { + tempbx = 16; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + tempbx = 8; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + tempbx = 21; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelBarco1366) { + tempbx = 80; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } + + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + tempbx = 7; + } + + if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { + tempbx = 84; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } + + } + + if(SiS_Pr->SiS_SetFlag & SetDOSMode) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) tempal = 7; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) tempal++; + } + } + + *CRT2Index = tempbx; + *ResIndex = tempal & 0x1F; + } +} + +#ifdef SIS315H +static void +SiS_GetCRT2PtrA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,USHORT *CRT2Index, + USHORT *ResIndex) +{ + USHORT tempbx,tempal; + + tempbx = SiS_Pr->SiS_LCDResInfo; + + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 4; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempbx = 3; + else tempbx -= SiS_Pr->SiS_Panel1024x768; + + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 5; + + if(ModeNo <= 0x13) + tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + else + tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + + /* No customs required yet (Clevo, Compaq, etc) */ + + *CRT2Index = tempbx; + *ResIndex = tempal & 0x1F; +} +#endif + +static void +SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo) +{ + USHORT tempax=0,tempbx=0; + USHORT temp1=0,modeflag=0,tempcx=0; + USHORT index; + + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; + + if(ModeNo <= 0x13) { + + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + index = SiS_GetModePtr(SiS_Pr,ModeNo,ModeIdIndex); + + tempax = SiS_Pr->SiS_StandTable[index].CRTC[0]; + tempbx = SiS_Pr->SiS_StandTable[index].CRTC[6]; + temp1 = SiS_Pr->SiS_StandTable[index].CRTC[7]; + + } else { + + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; + + tempax = SiS_Pr->SiS_CRT1Table[index].CR[0]; + tempax |= (SiS_Pr->SiS_CRT1Table[index].CR[14] << 8); + tempax &= 0x03FF; + tempbx = SiS_Pr->SiS_CRT1Table[index].CR[6]; + tempcx = SiS_Pr->SiS_CRT1Table[index].CR[13] << 8; + tempcx &= 0x0100; + tempcx <<= 2; + tempbx |= tempcx; + temp1 = SiS_Pr->SiS_CRT1Table[index].CR[7]; + + } + + if(temp1 & 0x01) tempbx |= 0x0100; + if(temp1 & 0x20) tempbx |= 0x0200; + + tempax += 5; + + /* Charx8Dot is no more used (and assumed), so we set it */ + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + modeflag |= Charx8Dot; + } + + if(modeflag & Charx8Dot) tempax *= 8; + else tempax *= 9; + + if(modeflag & HalfDCLK) tempax <<= 1; + + tempbx++; + + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = tempbx; +} + +static void +SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT CRT2Index, ResIndex; + const SiS_LVDSDataStruct *LVDSData = NULL; + + SiS_GetCRT2ResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; + SiS_Pr->SiS_NewFlickerMode = 0; + SiS_Pr->SiS_RVBHRS = 50; + SiS_Pr->SiS_RY1COE = 0; + SiS_Pr->SiS_RY2COE = 0; + SiS_Pr->SiS_RY3COE = 0; + SiS_Pr->SiS_RY4COE = 0; + } + + if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + +#ifdef SIS315H + SiS_GetCRT2PtrA(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, + &CRT2Index,&ResIndex); + + switch (CRT2Index) { + case 0: LVDSData = SiS_Pr->SiS_LCDA1024x768Data_1; break; + case 1: LVDSData = SiS_Pr->SiS_LCDA1280x1024Data_1; break; + case 3: LVDSData = SiS_Pr->SiS_LCDA1400x1050Data_1; break; + case 4: LVDSData = SiS_Pr->SiS_LCDA1600x1200Data_1; break; + case 5: LVDSData = SiS_Pr->SiS_LCDA1024x768Data_2; break; + case 6: LVDSData = SiS_Pr->SiS_LCDA1280x1024Data_2; break; + case 8: LVDSData = SiS_Pr->SiS_LCDA1400x1050Data_2; break; + case 9: LVDSData = SiS_Pr->SiS_LCDA1600x1200Data_2; break; + default: LVDSData = SiS_Pr->SiS_LCDA1024x768Data_1; break; + } +#endif + + } else { + + /* 301BDH needs LVDS Data */ + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + SiS_Pr->SiS_IF_DEF_LVDS = 1; + } + + SiS_GetCRT2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + &CRT2Index, &ResIndex, HwInfo); + + /* 301BDH needs LVDS Data */ + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + SiS_Pr->SiS_IF_DEF_LVDS = 0; + } + + switch (CRT2Index) { + case 0: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break; + case 1: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; + case 2: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_1; break; + case 3: LVDSData = SiS_Pr->SiS_LVDS800x600Data_2; break; + case 4: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_2; break; + case 5: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_2; break; + case 6: LVDSData = SiS_Pr->SiS_LVDS640x480Data_1; break; + case 7: LVDSData = SiS_Pr->SiS_LVDSXXXxXXXData_1; break; + case 8: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_1; break; + case 9: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_2; break; + case 10: LVDSData = SiS_Pr->SiS_CHTVUNTSCData; break; + case 11: LVDSData = SiS_Pr->SiS_CHTVONTSCData; break; + case 12: LVDSData = SiS_Pr->SiS_CHTVUPALData; break; + case 13: LVDSData = SiS_Pr->SiS_CHTVOPALData; break; + case 14: LVDSData = SiS_Pr->SiS_LVDS320x480Data_1; break; + case 15: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_1; break; + case 16: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_1; break; + case 17: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_2; break; + case 18: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_2; break; + case 19: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_1; break; + case 20: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_2; break; + case 21: LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_1; break; + case 22: LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_2; break; + case 30: LVDSData = SiS_Pr->SiS_LVDS640x480Data_2; break; + case 80: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_1; break; + case 81: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_2; break; + case 82: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_1; break; + case 83: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_2; break; + case 84: LVDSData = SiS_Pr->SiS_LVDS848x480Data_1; break; + case 85: LVDSData = SiS_Pr->SiS_LVDS848x480Data_2; break; + case 90: LVDSData = SiS_Pr->SiS_CHTVUPALMData; break; + case 91: LVDSData = SiS_Pr->SiS_CHTVOPALMData; break; + case 92: LVDSData = SiS_Pr->SiS_CHTVUPALNData; break; + case 93: LVDSData = SiS_Pr->SiS_CHTVOPALNData; break; + case 99: LVDSData = SiS_Pr->SiS_CHTVSOPALData; break; /* Super Overscan */ + default: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; + } + } + + SiS_Pr->SiS_VGAHT = (LVDSData+ResIndex)->VGAHT; + SiS_Pr->SiS_VGAVT = (LVDSData+ResIndex)->VGAVT; + SiS_Pr->SiS_HT = (LVDSData+ResIndex)->LCDHT; + SiS_Pr->SiS_VT = (LVDSData+ResIndex)->LCDVT; + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; + SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; + } + + } else { + + if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { + if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (SiS_Pr->SiS_SetFlag & SetDOSMode)) { + SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; + SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; + + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + if(ResIndex < 0x08) { + SiS_Pr->SiS_HDE = 1280; + SiS_Pr->SiS_VDE = 1024; + } + } + } + } + } } } } -/* TW: Set CRT2 FIFO on 300/630/730 */ -#ifdef SIS300 -void -SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, + PSIS_HW_INFO HwInfo) { - USHORT temp,index; - USHORT modeidindex,refreshratetableindex; - USHORT VCLK=0,MCLK,colorth=0,data2=0; - USHORT tempal, tempah, tempbx, tempcl, tempax; - USHORT CRT1ModeNo,CRT2ModeNo; - USHORT SelectRate_backup; - ULONG data,eax; - const UCHAR LatencyFactor[] = { - 97, 88, 86, 79, 77, 00, /*; 64 bit BQ=2 */ - 00, 87, 85, 78, 76, 54, /*; 64 bit BQ=1 */ - 97, 88, 86, 79, 77, 00, /*; 128 bit BQ=2 */ - 00, 79, 77, 70, 68, 48, /*; 128 bit BQ=1 */ - 80, 72, 69, 63, 61, 00, /*; 64 bit BQ=2 */ - 00, 70, 68, 61, 59, 37, /*; 64 bit BQ=1 */ - 86, 77, 75, 68, 66, 00, /*; 128 bit BQ=2 */ - 00, 68, 66, 59, 57, 37 /*; 128 bit BQ=1 */ - }; - const UCHAR LatencyFactor730[] = { - 69, 63, 61, - 86, 79, 77, - 103, 96, 94, - 120,113,111, - 137,130,128, /* <-- last entry, data below */ - 137,130,128, /* to avoid using illegal values */ - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - }; - const UCHAR ThLowB[] = { - 81, 4, 72, 6, 88, 8,120,12, - 55, 4, 54, 6, 66, 8, 90,12, - 42, 4, 45, 6, 55, 8, 75,12 - }; - const UCHAR ThTiming[] = { - 1, 2, 2, 3, 0, 1, 1, 2 - }; + USHORT tempax,tempbx,modeflag; + USHORT resinfo; + USHORT CRT2Index,ResIndex; + const SiS_LCDDataStruct *LCDPtr = NULL; + const SiS_TVDataStruct *TVPtr = NULL; + + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + } else { + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + resinfo = 0; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } + } - SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate; + SiS_Pr->SiS_NewFlickerMode = 0; + SiS_Pr->SiS_RVBHRS = 50; + SiS_Pr->SiS_RY1COE = 0; + SiS_Pr->SiS_RY2COE = 0; + SiS_Pr->SiS_RY3COE = 0; + SiS_Pr->SiS_RY4COE = 0; + + SiS_GetCRT2ResInfo(SiS_Pr,ModeNo,ModeIdIndex,HwInfo); + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){ + + if(SiS_Pr->UseCustomMode) { + + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; + SiS_Pr->SiS_VGAHT = SiS_Pr->CHTotal; + SiS_Pr->SiS_VGAVT = SiS_Pr->CVTotal; + SiS_Pr->SiS_HT = SiS_Pr->CHTotal; + SiS_Pr->SiS_VT = SiS_Pr->CVTotal; + SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE; + SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; - if(!SiS_Pr->CRT1UsesCustomMode) { - - CRT1ModeNo = SiS_Pr->SiS_CRT1Mode; /* get CRT1 ModeNo */ - SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT1ModeNo,&modeidindex); - SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); - SiS_Pr->SiS_SelectCRT2Rate = 0; - refreshratetableindex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT1ModeNo, - modeidindex,HwDeviceExtension); + } else { - if(CRT1ModeNo >= 0x13) { - index = SiS_Pr->SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK; - index &= 0x3F; - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ - data2 = SiS_Pr->SiS_ModeType - 2; + SiS_GetRAMDAC2DATA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); } - - } else { - - CRT1ModeNo = 0xfe; - VCLK = SiS_Pr->CSRClock; /* Get VCLK */ - data2 = (SiS_Pr->CModeFlag & ModeInfoFlag) - 2; - - } - - if(CRT1ModeNo >= 0x13) { - if(HwDeviceExtension->jChipType == SIS_300) { - index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A); - } else { - index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); - } - index &= 0x07; - MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: CRT1Mode 0x%x VCLK %d MCLK %d modetype-2 = %d\n", - CRT1ModeNo, VCLK, MCLK, data2); -#endif - - switch(data2) { /* Get color depth */ - case 0 : colorth = 1; break; - case 1 : colorth = 1; break; - case 2 : colorth = 2; break; - case 3 : colorth = 2; break; - case 4 : colorth = 3; break; - case 5 : colorth = 4; break; - default: colorth = 2; break; - } - data2 = (colorth * VCLK) / MCLK; - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - temp = ((temp & 0x00FF) >> 6) << 1; - if(temp == 0) temp = 1; - temp <<= 2; - temp &= 0xff; + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - data2 = temp - data2; - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: data2 (step1) = %d\n", - data2); -#endif + SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, + &CRT2Index,&ResIndex,HwInfo); - if((28 * 16) % data2) { - data2 = (28 * 16) / data2; - data2++; - } else { - data2 = (28 * 16) / data2; - } - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: data2 (step2) = %d\n", - data2); -#endif + switch(CRT2Index) { + case 2: TVPtr = SiS_Pr->SiS_ExtHiTVData; break; + case 3: TVPtr = SiS_Pr->SiS_ExtPALData; break; + case 4: TVPtr = SiS_Pr->SiS_ExtNTSCData; break; + case 5: TVPtr = SiS_Pr->SiS_Ext525iData; break; + case 6: TVPtr = SiS_Pr->SiS_Ext525pData; break; + case 7: TVPtr = SiS_Pr->SiS_Ext750pData; break; + case 8: TVPtr = SiS_Pr->SiS_StPALData; break; + case 9: TVPtr = SiS_Pr->SiS_StNTSCData; break; + case 10: TVPtr = SiS_Pr->SiS_St525iData; break; + case 11: TVPtr = SiS_Pr->SiS_St525pData; break; + case 12: TVPtr = SiS_Pr->SiS_St750pData; break; + case 13: TVPtr = SiS_Pr->SiS_St1HiTVData; break; + case 14: TVPtr = SiS_Pr->SiS_St2HiTVData; break; + default: TVPtr = SiS_Pr->SiS_StPALData; break; + } + + SiS_Pr->SiS_RVBHCMAX = (TVPtr+ResIndex)->RVBHCMAX; + SiS_Pr->SiS_RVBHCFACT = (TVPtr+ResIndex)->RVBHCFACT; + SiS_Pr->SiS_VGAHT = (TVPtr+ResIndex)->VGAHT; + SiS_Pr->SiS_VGAVT = (TVPtr+ResIndex)->VGAVT; + SiS_Pr->SiS_HDE = (TVPtr+ResIndex)->TVHDE; + SiS_Pr->SiS_VDE = (TVPtr+ResIndex)->TVVDE; + SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->RVBHRS; + SiS_Pr->SiS_NewFlickerMode = (TVPtr+ResIndex)->FlickerMode; + if(modeflag & HalfDCLK) { + SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->HALFRVBHRS; + } - if(HwDeviceExtension->jChipType == SIS_300) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18); - tempah &= 0x62; - tempah >>= 1; - tempal = tempah; - tempah >>= 3; - tempal |= tempah; - tempal &= 0x07; - tempcl = ThTiming[tempal]; - tempbx = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - tempbx >>= 6; - tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - tempah >>= 4; - tempah &= 0x0c; - tempbx |= tempah; - tempbx <<= 1; - tempal = ThLowB[tempbx + 1]; - tempal *= tempcl; - tempal += ThLowB[tempbx]; - data = tempal; + if((resinfo == SIS_RI_1024x768) || + (resinfo == SIS_RI_1280x1024) || + (resinfo == SIS_RI_1280x720)) { + SiS_Pr->SiS_NewFlickerMode = 0x40; + } - } else if(HwDeviceExtension->jChipType == SIS_730) { - -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x80000050); - eax = SiS_GetReg3(0xcfc); -#else - eax = pciReadLong(0x00000000, 0x50); -#endif - tempal = (USHORT)(eax >> 8); - tempal &= 0x06; - tempal <<= 5; + if(SiS_Pr->SiS_VGAVDE == 350) SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x800000A0); - eax = SiS_GetReg3(0xcfc); -#else - eax = pciReadLong(0x00000000, 0xA0); + SiS_Pr->SiS_HT = ExtHiTVHT; + SiS_Pr->SiS_VT = ExtHiTVVT; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + SiS_Pr->SiS_HT = StHiTVHT; + SiS_Pr->SiS_VT = StHiTVVT; +#if 0 + if(!(modeflag & Charx8Dot)) { + SiS_Pr->SiS_HT = StHiTextTVHT; + SiS_Pr->SiS_VT = StHiTextTVVT; + } #endif - temp = (USHORT)(eax >> 28); - temp &= 0x0F; - tempal |= temp; + } + } -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: Latencyfactorindex = 0x%x\n", tempal); -#endif - - tempbx = tempal; /* BIOS BUG (2.04.5d, 2.04.6a use ah here, which is unset!) */ - tempbx = 0; /* -- do it like the BIOS anyway... */ - tempax = tempbx; - tempbx &= 0xc0; - tempbx >>= 6; - tempax &= 0x0f; - tempax *= 3; - tempbx += tempax; - - data = LatencyFactor730[tempbx]; - data += 15; - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - if(!(temp & 0x80)) data += 5; - - } else { + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - index = 0; - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - if(temp & 0x0080) index += 12; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { + SiS_Pr->SiS_HT = 1650; + SiS_Pr->SiS_VT = 750; + } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { + SiS_Pr->SiS_HT = NTSCHT; + SiS_Pr->SiS_VT = NTSCVT; + } else { + SiS_Pr->SiS_HT = NTSCHT; + if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT; + SiS_Pr->SiS_VT = NTSCVT; + } -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x800000A0); - eax = SiS_GetReg3(0xcfc); -#else - /* TW: We use pci functions X offers. We use tag 0, because - * we want to read/write to the host bridge (which is always - * 00:00.0 on 630, 730 and 540), not the VGA device. - */ - eax = pciReadLong(0x00000000, 0xA0); -#endif - temp = (USHORT)(eax >> 24); - if(!(temp&0x01)) index += 24; + } else { -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x80000050); - eax = SiS_GetReg3(0xcfc); -#else - eax = pciReadLong(0x00000000, 0x50); -#endif - temp=(USHORT)(eax >> 24); - if(temp & 0x01) index += 6; + SiS_Pr->SiS_RY1COE = (TVPtr+ResIndex)->RY1COE; + SiS_Pr->SiS_RY2COE = (TVPtr+ResIndex)->RY2COE; + SiS_Pr->SiS_RY3COE = (TVPtr+ResIndex)->RY3COE; + SiS_Pr->SiS_RY4COE = (TVPtr+ResIndex)->RY4COE; + + if(modeflag & HalfDCLK) { + SiS_Pr->SiS_RY1COE = 0x00; + SiS_Pr->SiS_RY2COE = 0xf4; + SiS_Pr->SiS_RY3COE = 0x10; + SiS_Pr->SiS_RY4COE = 0x38; + } + + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + SiS_Pr->SiS_HT = NTSCHT; + if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT; + SiS_Pr->SiS_VT = NTSCVT; + } else { + SiS_Pr->SiS_HT = PALHT; + SiS_Pr->SiS_VT = PALVT; + } - temp = (temp & 0x0F) >> 1; - index += temp; - - data = LatencyFactor[index]; - data += 15; - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - if(!(temp & 0x80)) data += 5; - } - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: latencyfactor (CRT1) = %d\n", data); -#endif + } - data += data2; /* CRT1 Request Period */ - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: CRT1 request period = %d\n", data); -#endif + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - CRT2ModeNo = ModeNo; - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; - SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT2ModeNo,&modeidindex); + if(SiS_Pr->UseCustomMode) { - refreshratetableindex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT2ModeNo, - modeidindex,HwDeviceExtension); + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; + SiS_Pr->SiS_VGAHT = SiS_Pr->CHTotal; + SiS_Pr->SiS_VGAVT = SiS_Pr->CVTotal; + SiS_Pr->SiS_HT = SiS_Pr->CHTotal; + SiS_Pr->SiS_VT = SiS_Pr->CVTotal; + SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE; + SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,CRT2ModeNo,modeidindex, - refreshratetableindex,HwDeviceExtension); - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ - - data2 = SiS_Pr->SiS_ModeType - 2; - switch(data2) { /* Get color depth */ - case 0 : colorth = 1; break; - case 1 : colorth = 1; break; - case 2 : colorth = 2; break; - case 3 : colorth = 2; break; - case 4 : colorth = 3; break; - case 5 : colorth = 4; break; - default: colorth = 2; break; - } - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: CRT2Mode 0x%x VCLK %d MCLK %d modetype-2 = %d, colorth %d\n", - CRT2ModeNo, VCLK, MCLK, data2, colorth); -#endif + } else { - data = data * VCLK * colorth; - if(data % (MCLK << 4)) { - data = data / (MCLK << 4); - data++; - } else { - data = data / (MCLK << 4); - } - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: data (unclipped) = 0x%x\n", data); -#endif - - if(data <= 6) data = 6; - if(data > 0x14) data = 0x14; + SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, + &CRT2Index,&ResIndex,HwInfo); - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x01); - if(HwDeviceExtension->jChipType == SIS_300) { - if(data <= 0x0f) temp = (temp & (~0x1F)) | 0x13; - else temp = (temp & (~0x1F)) | 0x16; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - temp = (temp & (~0x1F)) | 0x13; - } - } else { - if( ( (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) ) && - (HwDeviceExtension->jChipRevision >= 0x30) ) /* 630s or 730(s?) */ - { - temp = (temp & (~0x1F)) | 0x1b; - } else { - temp = (temp & (~0x1F)) | 0x16; - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0xe0,temp); + switch(CRT2Index) { + case 0: LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; /* VESA Timing */ + case 1: LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data; break; /* VESA Timing */ + case 5: LCDPtr = SiS_Pr->SiS_StLCD1024x768Data; break; /* Obviously unused */ + case 6: LCDPtr = SiS_Pr->SiS_StLCD1280x1024Data; break; /* Obviously unused */ + case 10: LCDPtr = SiS_Pr->SiS_St2LCD1024x768Data; break; /* Non-VESA Timing */ + case 11: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; /* Non-VESA Timing */ + case 13: LCDPtr = SiS_Pr->SiS_NoScaleData1024x768; break; /* Non-expanding */ + case 14: LCDPtr = SiS_Pr->SiS_NoScaleData1280x1024; break; /* Non-expanding */ + case 15: LCDPtr = SiS_Pr->SiS_LCD1280x960Data; break; /* 1280x960 */ + case 20: LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data; break; /* VESA Timing */ + case 21: LCDPtr = SiS_Pr->SiS_NoScaleData1400x1050; break; /* Non-expanding (let panel scale) */ + case 22: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break; /* Non-VESA Timing (let panel scale) */ + case 23: LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break; /* VESA Timing */ + case 24: LCDPtr = SiS_Pr->SiS_NoScaleData1600x1200; break; /* Non-expanding */ + case 25: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break; /* Non-VESA Timing */ + case 26: LCDPtr = SiS_Pr->SiS_ExtLCD1280x768Data; break; /* VESA Timing */ + case 27: LCDPtr = SiS_Pr->SiS_NoScaleData1280x768; break; /* Non-expanding */ + case 28: LCDPtr = SiS_Pr->SiS_StLCD1280x768Data; break; /* Non-VESA Timing */ + case 29: LCDPtr = SiS_Pr->SiS_NoScaleData; break; /* Generic no-scale data */ +#ifdef SIS315H + case 50: LCDPtr = (SiS_LCDDataStruct *)SiS310_ExtCompaq1280x1024Data; break; + case 51: LCDPtr = SiS_Pr->SiS_NoScaleData1280x1024; break; + case 52: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; +#endif + default: LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; + } + + SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX; + SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT; + SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT; + SiS_Pr->SiS_VGAVT = (LCDPtr+ResIndex)->VGAVT; + SiS_Pr->SiS_HT = (LCDPtr+ResIndex)->LCDHT; + SiS_Pr->SiS_VT = (LCDPtr+ResIndex)->LCDVT; - if( (HwDeviceExtension->jChipType == SIS_630) && - (HwDeviceExtension->jChipRevision >= 0x30) ) /* 630s, NOT 730 */ - { - if(data > 0x13) data = 0x13; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,0xe0,data); - - } else { /* If mode <= 0x13, we just restore everything */ - - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; - +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, + "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex); +#endif + + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + tempax = 1024; + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + if(HwInfo->jChipType < SIS_315H) { + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; + else tempbx = 768; + } else { + tempbx = 768; + } + } else { + if (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527; + else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620; + else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775; + else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775; + else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; + else tempbx = 768; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + tempax = 1280; + if (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768; + else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800; + else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864; + else tempbx = 1024; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { + tempax = 1280; + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 700; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 800; + else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960; + else tempbx = 960; + } else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) && + (HwInfo->jChipType >= SIS_661)) { + tempax = 1400; + tempbx = 1050; + if(SiS_Pr->SiS_VGAVDE == 1024) { + tempax = 1280; + tempbx = 1024; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + tempax = 1600; + tempbx = 1200; + if((HwInfo->jChipType < SIS_661) || (!(SiS_Pr->SiS_SetFlag & LCDVESATiming))) { + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 875; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 1000; + } + } else { + tempax = SiS_Pr->PanelXRes; + tempbx = SiS_Pr->PanelYRes; + } + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempax = SiS_Pr->SiS_VGAHDE; + tempbx = SiS_Pr->SiS_VGAVDE; + } + SiS_Pr->SiS_HDE = tempax; + SiS_Pr->SiS_VDE = tempbx; + } } } -#endif -/* TW: Set FIFO on 310/325/330 series */ -#ifdef SIS315H -void -SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_GetCRT2Data(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { - UCHAR CombCode[] = { 1, 1, 1, 4, 3, 1, 3, 4, - 4, 1, 4, 4, 5, 1, 5, 4}; - UCHAR CRT2ThLow[] = { 39, 63, 55, 79, 78,102, 90,114, - 55, 87, 84,116,103,135,119,151}; - USHORT temp3,tempax,tempbx,tempcx; - USHORT tempcl, tempch; - USHORT index; - USHORT CRT1ModeNo,CRT2ModeNo; - USHORT ModeIdIndex; - USHORT RefreshRateTableIndex; - USHORT SelectRate_backup; - - SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate; - - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x01,0x3B); + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(!SiS_Pr->CRT1UsesCustomMode) { - - CRT1ModeNo = SiS_Pr->SiS_CRT1Mode; /* get CRT1 ModeNo */ - SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT1ModeNo,&ModeIdIndex); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); - SiS_Pr->SiS_SelectCRT2Rate = 0; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - /* Get REFIndex for crt1 refreshrate */ - RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT1ModeNo, - ModeIdIndex,HwDeviceExtension); - - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,CRT1ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - tempax = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ - - tempbx = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT1ModeNo,ModeIdIndex); /* Get colordepth */ - tempbx >>= 1; - if(!tempbx) tempbx++; - - } else { - - tempax = SiS_Pr->CSRClock; /* Get VCLK */ - tempbx = (SiS_Pr->CModeFlag & ModeInfoFlag) - 2; - switch(tempbx) { /* Get color depth */ - case 0 : tempbx = 1; break; - case 1 : tempbx = 1; break; - case 2 : tempbx = 2; break; - case 3 : tempbx = 2; break; - case 4 : tempbx = 3; break; - case 5 : tempbx = 4; break; - default: tempbx = 2; break; - } - - } - - tempax *= tempbx; + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + + } else { - tempbx = SiS_GetMCLK(SiS_Pr,ROMAddr, HwDeviceExtension); /* Get MCLK */ + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - tempax /= tempbx; + /* Need LVDS Data for LCD on 301B-DH */ + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - tempbx = tempax; + } else { -#if 0 /* TW: BIOS code is skrewed */ - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14) & 0x02) { - tempax = 16; - } else { - tempax = 8; - } -#endif - tempax = 16; + SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + + } - tempax -= tempbx; + } - tempbx = tempax; /* tempbx = 16-DRamBus - DCLK*BytePerPixel/MCLK */ + } else { - tempax = ((52 * 16) / tempbx); + SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - if ((52*16 % tempbx) != 0) { - tempax++; - } - tempcx = tempax; - tempcx += 40; + } - /* get DRAM latency */ - tempcl = (SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) >> 3) & 0x7; /* SR17[5:3] DRAM Queue depth */ - tempch = (SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) >> 6) & 0x3; /* SR17[7:6] DRAM Grant length */ - - for (temp3 = 0; temp3 < 16; temp3 += 2) { - if ((CombCode[temp3] == tempcl) && (CombCode[temp3+1] == tempch)) { - temp3 = CRT2ThLow[temp3 >> 1]; - } - } + } else { - tempcx += temp3; /* CRT1 Request Period */ + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - CRT2ModeNo = ModeNo; /* get CRT2 ModeNo */ - SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT2ModeNo,&ModeIdIndex); /* Get ModeID Table */ + } +} - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; +/*********************************************/ +/* GET LVDS DES DATA */ +/*********************************************/ - RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT2ModeNo, - ModeIdIndex,HwDeviceExtension); +static void +SiS_GetLVDSDesPtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, USHORT *PanelIndex, + USHORT *ResIndex, PSIS_HW_INFO HwInfo) +{ + USHORT tempbx,tempal,modeflag; - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,CRT2ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - tempax = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; } else { - tempax = SiS_Pr->SiS_VBVCLKData[index].CLOCK; /* Get VCLK */ + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + } + + tempbx = 0; + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tempbx = 50; + if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) tempbx += 2; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + /* Nothing special needed for SOverscan */ + /* PALM uses NTSC data, PALN uses PAL data */ + } } - tempbx = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT2ModeNo,ModeIdIndex); /* Get colordepth */ - tempbx >>= 1; - if(!tempbx) tempbx++; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + tempbx = SiS_Pr->SiS_LCDTypeInfo; + if(HwInfo->jChipType >= SIS_661) { + /* As long as we don's use the BIOS tables, we + * need to convert the TypeInfo as for 315 series + */ + tempbx = SiS_Pr->SiS_LCDResInfo - 1; + } + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 16; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + tempbx = 32; + if(modeflag & HalfDCLK) tempbx++; + } + } - tempax *= tempbx; + if(SiS_Pr->SiS_SetFlag & SetDOSMode) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + tempal = 0x07; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) tempal++; + } + } + } - tempax *= tempcx; + *PanelIndex = tempbx; + *ResIndex = tempal & 0x1F; +} - tempbx = SiS_GetMCLK(SiS_Pr,ROMAddr, HwDeviceExtension); /* Get MCLK */ - tempbx <<= 4; +#ifdef SIS315H +static void +SiS_GetLVDSDesPtrA(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, USHORT *PanelIndex, USHORT *ResIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT tempbx=0,tempal; - tempcx = tempax; - tempax /= tempbx; - if(tempcx % tempbx) tempax++; /* CRT1 Request period * TCLK * BytePerPixel / (MCLK*16) */ + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempbx = 2; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 3; + else tempbx = SiS_Pr->SiS_LCDResInfo - 2; - if (tempax > 0x37) tempax = 0x37; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 4; - /* TW: 650/LVDS (1.10.07, 1.10.00), 650/301LV, 740, 330 overrule calculated value; 315 does not */ - if(HwDeviceExtension->jChipType >= SIS_650) { - tempax = 0x04; + if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + tempbx = 80; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } + } + } + if((SiS_Pr->SiS_CustomT == CUT_UNIWILL1024) || + (SiS_Pr->SiS_CustomT == CUT_UNIWILL10242)) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + tempbx = 82; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } + } + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + tempbx = 84; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } + } + if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + tempbx = 86; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } } - - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,~0x3F,tempax); -} -USHORT -SiS_GetMCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT index; + if(ModeNo <= 0x13) + tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + else + tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - index = SiS_Get310DRAMType(SiS_Pr,ROMAddr,HwDeviceExtension); - if(index >= 4) { - index -= 4; - return(SiS_Pr->SiS_MCLKData_1[index].CLOCK); - } else { - return(SiS_Pr->SiS_MCLKData_0[index].CLOCK); - } + *PanelIndex = tempbx; + *ResIndex = tempal & 0x1F; } #endif -/* TW: Checked against 650/LVDS 1.10.07 BIOS */ -void -SiS_GetLVDSDesData(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_GetLVDSDesData(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { USHORT modeflag; USHORT PanelIndex,ResIndex; const SiS_LVDSDesStruct *PanelDesPtr = NULL; - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ) { + if((SiS_Pr->UseCustomMode) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) || + (SiS_Pr->SiS_CustomT == CUT_PANEL848)) { + SiS_Pr->SiS_LCDHDES = 0; + SiS_Pr->SiS_LCDVDES = 0; + return; + } + + if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + +#ifdef SIS315H + SiS_GetLVDSDesPtrA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + &PanelIndex, &ResIndex, HwInfo); -#ifdef SIS315H - SiS_GetLVDSDesPtrA(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &PanelIndex,&ResIndex); - switch (PanelIndex) { case 0: PanelDesPtr = SiS_Pr->LVDS1024x768Des_1; break; /* --- expanding --- */ @@ -2639,14 +3546,22 @@ SiS_GetLVDSDesData(SiS_Private *SiS_Pr, case 5: PanelDesPtr = SiS_Pr->LVDS1280x1024Des_2; break; case 6: PanelDesPtr = SiS_Pr->LVDS1400x1050Des_2; break; case 7: PanelDesPtr = SiS_Pr->LVDS1600x1200Des_2; break; + case 80: PanelDesPtr = (SiS_LVDSDesStruct *)Clevo1024x768Des_1; break; /* custom */ + case 81: PanelDesPtr = (SiS_LVDSDesStruct *)Clevo1024x768Des_2; break; + case 82: PanelDesPtr = (SiS_LVDSDesStruct *)Uniwill1024x768Des_1; break; + case 83: PanelDesPtr = (SiS_LVDSDesStruct *)Uniwill1024x768Des_2; break; + case 84: PanelDesPtr = (SiS_LVDSDesStruct *)Compaq1280x1024Des_1; break; + case 85: PanelDesPtr = (SiS_LVDSDesStruct *)Compaq1280x1024Des_2; break; + case 86: PanelDesPtr = (SiS_LVDSDesStruct *)Asus1024x768Des_1; break; /* custom */ + case 87: PanelDesPtr = (SiS_LVDSDesStruct *)Asus1024x768Des_2; break; default: PanelDesPtr = SiS_Pr->LVDS1024x768Des_1; break; } #endif } else { - SiS_GetLVDSDesPtr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &PanelIndex,&ResIndex,HwDeviceExtension); + SiS_GetLVDSDesPtr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + &PanelIndex, &ResIndex, HwInfo); switch (PanelIndex) { @@ -2689,11 +3604,11 @@ SiS_GetLVDSDesData(SiS_Private *SiS_Pr, case 52: PanelDesPtr = SiS_Pr->SiS_CHTVUPALDesData; break; case 53: PanelDesPtr = SiS_Pr->SiS_CHTVOPALDesData; break; default: - if(HwDeviceExtension->jChipType < SIS_315H) - PanelDesPtr = SiS_Pr->SiS_PanelType0e_1; - else - PanelDesPtr = SiS_Pr->SiS_PanelType01_1; - break; + if(HwInfo->jChipType < SIS_315H) + PanelDesPtr = SiS_Pr->SiS_PanelType0e_1; + else + PanelDesPtr = SiS_Pr->SiS_PanelType01_1; + break; } } SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES; @@ -2709,12 +3624,11 @@ SiS_GetLVDSDesData(SiS_Private *SiS_Pr, } } else { if(!(SiS_Pr->SiS_SetFlag & SetDOSMode)) { - if( (HwDeviceExtension->jChipType < SIS_315H) || - (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) ) { - if(SiS_Pr->SiS_LCDResInfo >= SiS_Pr->SiS_Panel1024x768){ + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) { + if(SiS_Pr->SiS_LCDResInfo >= SiS_Pr->SiS_Panel1024x768) { if(ModeNo <= 0x13) { modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - if(HwDeviceExtension->jChipType < SIS_315H) { + if(HwInfo->jChipType < SIS_315H) { if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 320; } else { if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) @@ -2737,4472 +3651,3810 @@ SiS_GetLVDSDesData(SiS_Private *SiS_Pr, } } } - return; } -void -SiS_GetLVDSDesPtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *PanelIndex, - USHORT *ResIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT tempbx,tempal,modeflag; - - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - } - - tempbx = 0; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - tempbx = 50; - if((SiS_Pr->SiS_VBInfo & SetPALTV) && (!SiS_Pr->SiS_CHPALM)) tempbx += 2; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - /* TW: Nothing special needed for SOverscan */ - /* PALM uses NTSC data, PALN uses PAL data */ - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - tempbx = SiS_Pr->SiS_LCDTypeInfo; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 16; - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - tempbx = 32; - if(modeflag & HalfDCLK) tempbx++; - } - } - /* TW: 630/LVDS and 650/LVDS (1.10.07) BIOS */ - if(SiS_Pr->SiS_SetFlag & SetDOSMode) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - tempal = 0x07; - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) tempal++; - } - } - } - - *PanelIndex = tempbx; - *ResIndex = tempal & 0x1F; -} +/*********************************************/ +/* SET CRT2 AUTO-THRESHOLD */ +/*********************************************/ #ifdef SIS315H -void -SiS_GetLVDSDesPtrA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *PanelIndex,USHORT *ResIndex) +static void +SiS_CRT2AutoThreshold(SiS_Private *SiS_Pr) { - USHORT tempbx=0,tempal; - - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempbx = 2; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 3; - else tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_PanelMinLVDS; - - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 4; - - if(ModeNo <= 0x13) - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - else - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - - *PanelIndex = tempbx; - *ResIndex = tempal & 0x1F; + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40); } #endif +/*********************************************/ +/* DISABLE VIDEO BRIDGE */ +/*********************************************/ + +/* NEVER use any variables (VBInfo), this will be called + * from outside the context of modeswitch! + * MUST call getVBType before calling this + */ void -SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT BaseAddr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - USHORT i,j,modeflag; - USHORT tempcl,tempah=0; -#ifdef SIS300 - USHORT temp; -#endif #ifdef SIS315H - USHORT tempbl; + USHORT tempah,pushax=0,modenum; #endif + USHORT temp=0; - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - } - - /* TW: BIOS does not do this (neither 301 nor LVDS) */ - /* (But it's harmless; see SetCRT2Offset) */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,0x00); /* fix write part1 index 0 BTDRAM bit Bug */ + if(SiS_Pr->SiS_VBType & VB_SISVB) { - /* TW: Removed 301B302B301LV302LV check here to match 650/LVDS BIOS */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ===== For 30xB/LV ===== */ - /* TW: 1. for LVDS/302B/302LV **LCDA** */ + if(HwInfo->jChipType < SIS_315H) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xAF,0x40); /* FUNCTION CONTROL */ - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2E,0xF7); +#ifdef SIS300 /* 300 series */ - } else { + if(HwInfo->jChipType == SIS_300) { /* For 300+301LV (A907) */ + + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } + } + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0x3f); + SiS_ShortDelay(SiS_Pr,1); + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); + SiS_DisplayOff(SiS_Pr); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) ) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); + } + } - for(i=0,j=4; i<3; i++,j++) SiS_SetReg1(SiS_Pr->SiS_Part1Port,j,0); + } else { - tempcl = SiS_Pr->SiS_ModeType; + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } + if(SiS_Is301B(SiS_Pr)) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0x3f); + SiS_ShortDelay(SiS_Pr,1); + } + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); + SiS_DisplayOff(SiS_Pr); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); + SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); + if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) ) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + } + } - if(HwDeviceExtension->jChipType < SIS_315H) { +#endif /* SIS300 */ -#ifdef SIS300 /* ---- 300 series ---- */ + } else { - /* For 301BDH: */ - if(SiS_Pr->SiS_VBType & VB_NoLCD) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32); - temp &= 0xef; - temp |= 0x02; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) || (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { - temp |= 0x10; - temp &= 0xfd; - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); - } +#ifdef SIS315H /* 315 series */ - if(ModeNo > 0x13) { - tempcl -= ModeVGA; - if((tempcl > 0) || (tempcl == 0)) { /* TW: tempcl is USHORT -> always true! */ - tempah = ((0x10 >> tempcl) | 0x80); - } - } else tempah = 0x80; + if(IS_SIS550650740660) { /* 550, 650, 740, 660 */ - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0; + modenum = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34) & 0x7f; -#endif /* SIS300 */ + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* LV */ +#ifdef SET_EMI + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); + } + } +#endif + if( (modenum <= 0x13) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (SiS_IsVAMode(SiS_Pr,HwInfo)) ) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); + if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } + } - } else { + if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { + SiS_DDC2Delay(SiS_Pr,0xff00); + SiS_DDC2Delay(SiS_Pr,0xe000); -#ifdef SIS315H /* ---- 310/325/330 series ---- */ + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & CRT2DisplayFlag) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x08); - } - } + pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06); - if(ModeNo > 0x13) { - tempcl -= ModeVGA; - if((tempcl > 0) || (tempcl == 0)) { /* TW: tempcl is USHORT -> always true! */ - tempah = (0x08 >> tempcl); - if (tempah == 0) tempah = 1; - tempah |= 0x40; - } - } else tempah = 0x40; + if(IS_SIS740) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); + } - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50; + SiS_PanelDelay(SiS_Pr, HwInfo, 3); -#endif /* SIS315H */ + if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { + tempah = 0xef; + if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + tempah = 0xf7; + } + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); + } + } - } + } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { /* B-DH */ - if(SiS_Pr->SiS_VBInfo & CRT2DisplayFlag) tempah = 0; + if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,0xef); + } - if(HwDeviceExtension->jChipType < SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,tempah); /* FUNCTION CONTROL */ - } else { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); /* FUNCTION CONTROL */ - } else { - if(IS_SIS740) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,tempah); /* FUNCTION CONTROL */ - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); /* FUNCTION CONTROL */ - } - } - } + } + + if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,0xef); + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + tempah = 0x3f; + if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + tempah = 0x7f; + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + tempah = 0xbf; + } + } + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); + } - /* TW: 2. for 301 (301B, 302B 301LV, 302LV non-LCDA) */ + if((SiS_IsVAMode(SiS_Pr,HwInfo)) || + ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) { - tempah = 0x01; - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - tempah |= 0x02; - } - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { - tempah ^= 0x05; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - tempah ^= 0x01; - } - } + if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF); + SiS_DisplayOff(SiS_Pr); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + } else { + SiS_DisplayOff(SiS_Pr); + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF); + if((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13)) { + SiS_DisplayOff(SiS_Pr); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); + } + } - if(SiS_Pr->SiS_VBInfo & CRT2DisplayFlag) tempah = 0; + } else { - if(HwDeviceExtension->jChipType < SIS_315H) { + if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + if(!(SiS_IsDualEdge(SiS_Pr,HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf); + SiS_DisplayOff(SiS_Pr); + } + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + } else { + SiS_DisplayOff(SiS_Pr); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + } - /* --- 300 series --- */ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); - tempah = (tempah << 5) & 0xFF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x01,tempah); - tempah = (tempah >> 5) & 0xFF; + } - } else { + if((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && + (SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { - /* --- 310 series --- */ + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,~0x10); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF8,tempah); + tempah = 0x3f; + if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + tempah = 0x7f; + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + tempah = 0xbf; + } + } + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); - } + if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); + } - if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { - tempah |= 0x10; - } + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf); + if(!(SiS_CRT2IsLCD(SiS_Pr,HwInfo))) { + if(!(SiS_IsDualEdge(SiS_Pr,HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); + } + } + } - /* TW: 630/301 BIOS */ - if((HwDeviceExtension->jChipType < SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301)) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - tempah |= 0x80; - } - } else { - tempah |= 0x80; - } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(!(SiS_Pr->SiS_HiVision & 0x03)) { - tempah |= 0x20; - } - } - } + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if( (SiS_IsVAMode(SiS_Pr, HwInfo)) || + (SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 20); + } + } + + } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { + + /* NIL */ + + } else if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + + if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { + tempah = 0xef; + if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + if(modenum > 0x13) { + tempah = 0xf7; + } + } + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); + } + if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + if((SiS_IsVAMode(SiS_Pr,HwInfo)) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo)))) { + if((!(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo))) || + (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo)))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); + SiS_PanelDelay(SiS_Pr, HwInfo, 4); + } + } + } + + } + + } else { /* 315, 330 - all bridge types */ - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah); + if(SiS_Is301B(SiS_Pr)) { + tempah = 0x3f; + if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + tempah = 0x7f; + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + tempah = 0xbf; + } + } + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); + if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + SiS_DisplayOff(SiS_Pr); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + } + } + if( (!(SiS_Is301B(SiS_Pr))) || + (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { - tempah = 0; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_HiVision & 0x03)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_Pr->SiS_SetFlag |= RPLLDIV2XO; - tempah |= 0x40; - } else { - if(!(SiS_Pr->SiS_SetFlag & TVSimuMode)) { - SiS_Pr->SiS_SetFlag |= RPLLDIV2XO; - tempah |= 0x40; - } - } - } - } else { - SiS_Pr->SiS_SetFlag |= RPLLDIV2XO; - tempah |= 0x40; - } - } - } - /* TW: For 302LV dual-channel */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) - tempah |= 0x40; - } - } + if( (!(SiS_Is301B(SiS_Pr))) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ) { - if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960)) { - tempah |= 0x80; - } + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); + SiS_DisplayOff(SiS_Pr); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0C,tempah); + } - } else { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - /* TW: 3. for LVDS */ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - if(HwDeviceExtension->jChipType >= SIS_315H) { + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); - /* TW: Inserted this entire section (BIOS 650/LVDS); added ModeType check - * (LVDS can only be slave in 8bpp modes) - */ - tempah = 0x80; - if( (modeflag & CRT2Mode) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { - if (SiS_Pr->SiS_VBInfo & DriverMode) { - tempah |= 0x02; - } - } + } - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - tempah |= 0x02; - } + } /* 315/330 */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - tempah ^= 0x01; - } +#endif /* SIS315H */ - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - tempah = 1; - } + } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah); + } else { /* ============ For 301 ================ */ - } else { + if(HwInfo->jChipType < SIS_315H) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } + } - /* TW: (added ModeType check) */ - tempah = 0; - if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { - tempah |= 0x02; - } - tempah <<= 5; + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */ + SiS_DisplayOff(SiS_Pr); - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x01,tempah); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */ + if(HwInfo->jChipType >= SIS_315H) { + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); + } else { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */ + if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) ) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + } } - } + } - } + } else { /* ============ For LVDS =============*/ - /* TW: Inserted the entire following section */ + if(HwInfo->jChipType < SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { +#ifdef SIS300 /* 300 series */ - if(HwDeviceExtension->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { + SiS_SetCH700x(SiS_Pr,0x090E); + } -#ifdef SIS315H - if(!(IS_SIS740)) { - tempah = 0x04; /* For all bridges */ - tempbl = 0xfb; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempah = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) - tempbl = 0xff; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); - } - - if(IS_SIS740) { - tempah = 0x30; - tempbl = 0xcf; - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - tempah = 0x00; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah); - } else { - /* TW: This in order to fix "TV-blue-bug" on 315+301 */ - if(SiS_Pr->SiS_VBType & VB_SIS301) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xCF); /* For 301 */ - } else { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xCF,0x30); /* For 30xLV */ - } else { - tempah = 0x30; /* For 301B */ - tempbl = 0xcf; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempah = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) { - tempbl = 0xff; - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah); - } - } - } + if(HwInfo->jChipType == SIS_730) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { + SiS_WaitVBRetrace(SiS_Pr,HwInfo); + } + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } + } else { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + SiS_WaitVBRetrace(SiS_Pr,HwInfo); + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) { + SiS_DisplayOff(SiS_Pr); + } + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } + } + } + } - if(IS_SIS740) { - tempah = 0xc0; - tempbl = 0x3f; - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - tempah = 0x00; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl,tempah); - } else { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* For 30xLV */ - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,0xc0); - } else { /* For 301, 301B */ - tempah = 0xc0; - tempbl = 0x3f; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempah = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) { - tempbl = 0xff; - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl,tempah); - } - } + SiS_DisplayOff(SiS_Pr); - if(IS_SIS740) { - tempah = 0x80; - tempbl = 0x7f; - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - tempah = 0x00; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah); - } else { - tempah = 0x00; /* For all bridges */ - tempbl = 0x7f; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempbl = 0xff; - if(!(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr))) - tempah |= 0x80; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah); - } + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); -#endif /* SIS315H */ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); + SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); - } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) ) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + } - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); +#endif /* SIS300 */ - if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || - ( (SiS_Pr->SiS_VBType & VB_NoLCD) && - (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) ) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x23,0x7F); - } else { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x23,0x80); - } + } else { - } +#ifdef SIS315H /* 315 series */ - } else { /* LVDS */ + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { -#ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { + if(HwInfo->jChipType == SIS_740) { + temp = SiS_GetCH701x(SiS_Pr,0x61); + if(temp < 1) { + SiS_SetCH701x(SiS_Pr,0xac76); + SiS_SetCH701x(SiS_Pr,0x0066); + } - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) ) { + SiS_SetCH701x(SiS_Pr,0x3e49); + } + } - tempah = 0x04; - tempbl = 0xfb; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempah = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) - tempbl = 0xff; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); + if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (SiS_IsVAMode(SiS_Pr,HwInfo)) ) { + SiS_Chrontel701xBLOff(SiS_Pr); + SiS_Chrontel701xOff(SiS_Pr,HwInfo); + } - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x00); + if(HwInfo->jChipType != SIS_740) { + if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) ) { + SiS_SetCH701x(SiS_Pr,0x0149); + } + } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xcf,0x30); + } - } + if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } - } -#endif + if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (!(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo))) ) { + SiS_DisplayOff(SiS_Pr); + } - } + if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + } -} + if(HwInfo->jChipType == SIS_740) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); + } -void -SiS_GetCRT2Data(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); + } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); + if(HwInfo->jChipType == SIS_550) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xbf); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xef); + } + } + } else { + if(HwInfo->jChipType == SIS_740) { + if(SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); + } + } else if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); + } + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + /* SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xff); */ + } else { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); + } + } - SiS_GetCRT2DataLVDS(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } else { + SiS_UnLockCRT2(SiS_Pr,HwInfo); - if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && - (SiS_Pr->SiS_VBType & VB_NoLCD) ) { - - /* TW: Need LVDS Data for LCD on 301BDH */ - SiS_GetCRT2DataLVDS(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - - } else { - - SiS_GetCRT2Data301(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } + if(HwInfo->jChipType == SIS_550) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); /* DirectDVD PAL?*/ + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); /* VB clock / 4 ? */ + } else if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); + } + if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + } + } } - } else { +#endif /* SIS315H */ - SiS_GetCRT2Data301(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } + } /* 315 series */ + + } /* LVDS */ - } else { - - SiS_GetCRT2DataLVDS(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } } -/* Checked with 650/LVDS 1.10.07 BIOS */ +/*********************************************/ +/* ENABLE VIDEO BRIDGE */ +/*********************************************/ + +/* NEVER use any variables (VBInfo), this will be called + * from outside the context of a mode switch! + * MUST call getVBType before calling this + */ void -SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - USHORT CRT2Index, ResIndex; - const SiS_LVDSDataStruct *LVDSData = NULL; - - SiS_GetCRT2ResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_Pr->SiS_RVBHCMAX = 1; - SiS_Pr->SiS_RVBHCFACT = 1; - SiS_Pr->SiS_NewFlickerMode = 0; - SiS_Pr->SiS_RVBHRS = 50; - SiS_Pr->SiS_RY1COE = 0; - SiS_Pr->SiS_RY2COE = 0; - SiS_Pr->SiS_RY3COE = 0; - SiS_Pr->SiS_RY4COE = 0; - } + USHORT temp=0,tempah; +#ifdef SIS315H + USHORT temp1,pushax=0; + BOOLEAN delaylong = FALSE; +#endif - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { -#ifdef SIS315H - SiS_GetCRT2PtrA(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex); + if(SiS_Pr->SiS_VBType & VB_SISVB) { - switch (CRT2Index) { - case 0: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; - case 1: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_1; break; - case 2: LVDSData = SiS_Pr->SiS_LVDS1280x960Data_1; break; - case 3: LVDSData = SiS_Pr->SiS_LCDA1400x1050Data_1; break; - case 4: LVDSData = SiS_Pr->SiS_LCDA1600x1200Data_1; break; - case 5: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_2; break; - case 6: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_2; break; - case 7: LVDSData = SiS_Pr->SiS_LVDS1280x960Data_2; break; - case 8: LVDSData = SiS_Pr->SiS_LCDA1400x1050Data_2; break; - case 9: LVDSData = SiS_Pr->SiS_LCDA1600x1200Data_2; break; - default: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; - } -#endif + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ====== For 301B et al ====== */ - } else { + if(HwInfo->jChipType < SIS_315H) { - /* TW: 301BDH needs LVDS Data */ - if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && - (SiS_Pr->SiS_VBType & VB_NoLCD) ) { - SiS_Pr->SiS_IF_DEF_LVDS = 1; - } +#ifdef SIS300 /* 300 series */ - SiS_GetCRT2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex,HwDeviceExtension); - - /* TW: 301BDH needs LVDS Data */ - if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && - (SiS_Pr->SiS_VBType & VB_NoLCD) ) { - SiS_Pr->SiS_IF_DEF_LVDS = 0; - } + if(HwInfo->jChipType == SIS_300) { - switch (CRT2Index) { - case 0: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break; - case 1: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; - case 2: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_1; break; - case 3: LVDSData = SiS_Pr->SiS_LVDS800x600Data_2; break; - case 4: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_2; break; - case 5: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_2; break; - case 6: LVDSData = SiS_Pr->SiS_LVDS640x480Data_1; break; - case 7: LVDSData = SiS_Pr->SiS_LVDSXXXxXXXData_1; break; - case 8: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_1; break; - case 9: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_2; break; - case 10: LVDSData = SiS_Pr->SiS_CHTVUNTSCData; break; - case 11: LVDSData = SiS_Pr->SiS_CHTVONTSCData; break; - case 12: LVDSData = SiS_Pr->SiS_CHTVUPALData; break; - case 13: LVDSData = SiS_Pr->SiS_CHTVOPALData; break; - case 14: LVDSData = SiS_Pr->SiS_LVDS320x480Data_1; break; - case 15: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_1; break; - case 16: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_1; break; - case 17: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_2; break; - case 18: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_2; break; - case 19: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_1; break; - case 20: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_2; break; - case 21: LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_1; break; - case 22: LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_2; break; - case 90: LVDSData = SiS_Pr->SiS_CHTVUPALMData; break; - case 91: LVDSData = SiS_Pr->SiS_CHTVOPALMData; break; - case 92: LVDSData = SiS_Pr->SiS_CHTVUPALNData; break; - case 93: LVDSData = SiS_Pr->SiS_CHTVOPALNData; break; - case 99: LVDSData = SiS_Pr->SiS_CHTVSOPALData; break; /* TW: Super Overscan */ - default: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; - } - } + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); + if(!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } + } + } + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ + if(SiS_BridgeInSlave(SiS_Pr)) { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0); + SiS_DisplayOn(SiS_Pr); + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + } + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); + } + } + } - SiS_Pr->SiS_VGAHT = (LVDSData+ResIndex)->VGAHT; - SiS_Pr->SiS_VGAVT = (LVDSData+ResIndex)->VGAVT; - SiS_Pr->SiS_HT = (LVDSData+ResIndex)->LCDHT; - SiS_Pr->SiS_VT = (LVDSData+ResIndex)->LCDVT; + } else { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + if((SiS_Pr->SiS_VBType & VB_NoLCD) && + (SiS_CRT2IsLCD(SiS_Pr, HwInfo))) { + /* This is only for LCD output on 301B-DH via LVDS */ + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); + if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* Enable CRT2 */ + SiS_DisplayOn(SiS_Pr); + SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); + if(SiS_BridgeInSlave(SiS_Pr)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); + } + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + } + SiS_WaitVBRetrace(SiS_Pr,HwInfo); + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); + } + } + } else { + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ + if(SiS_BridgeInSlave(SiS_Pr)) { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0); + SiS_DisplayOn(SiS_Pr); + } - if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)){ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768){ - SiS_Pr->SiS_HDE = 1024; - SiS_Pr->SiS_VDE = 768; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024){ - SiS_Pr->SiS_HDE = 1280; - SiS_Pr->SiS_VDE = 1024; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050){ - SiS_Pr->SiS_HDE = 1400; - SiS_Pr->SiS_VDE = 1050; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200){ - SiS_Pr->SiS_HDE = 1600; - SiS_Pr->SiS_VDE = 1200; - } else { - SiS_Pr->SiS_HDE = 1280; - SiS_Pr->SiS_VDE = 960; - } - } + } +#endif /* SIS300 */ - } else { + } else { - if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { - if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (SiS_Pr->SiS_SetFlag & SetDOSMode)) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - SiS_Pr->SiS_HDE = 800; - SiS_Pr->SiS_VDE = 600; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - SiS_Pr->SiS_HDE = 1024; - SiS_Pr->SiS_VDE = 600; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - SiS_Pr->SiS_HDE = 1024; - SiS_Pr->SiS_VDE = 768; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { - SiS_Pr->SiS_HDE = 1152; - SiS_Pr->SiS_VDE = 768; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x864) { - SiS_Pr->SiS_HDE = 1152; - SiS_Pr->SiS_VDE = 864; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { - SiS_Pr->SiS_HDE = 1280; - SiS_Pr->SiS_VDE = 768; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - SiS_Pr->SiS_HDE = 1280; - SiS_Pr->SiS_VDE = 1024; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - SiS_Pr->SiS_HDE = 1400; - SiS_Pr->SiS_VDE = 1050; - } else { - SiS_Pr->SiS_HDE = 1600; - SiS_Pr->SiS_VDE = 1200; - } - if(SiS_Pr->SiS_IF_DEF_FSTN) { - SiS_Pr->SiS_HDE = 320; - SiS_Pr->SiS_VDE = 480; - } - } - } - } - } - } -} +#ifdef SIS315H /* 315 series */ -void -SiS_GetCRT2Data301(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT tempax,tempbx,modeflag; - USHORT resinfo; - USHORT CRT2Index,ResIndex; - const SiS_LCDDataStruct *LCDPtr = NULL; - const SiS_TVDataStruct *TVPtr = NULL; + if(IS_SIS550650740660) { /* 550, 650, 740, 660 */ - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } - - SiS_Pr->SiS_NewFlickerMode = 0; - SiS_Pr->SiS_RVBHRS = 50; - SiS_Pr->SiS_RY1COE = 0; - SiS_Pr->SiS_RY2COE = 0; - SiS_Pr->SiS_RY3COE = 0; - SiS_Pr->SiS_RY4COE = 0; + UCHAR r30=0, r31=0, r32=0, r33=0, cr36=0; - SiS_GetCRT2ResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - /* TW: For VGA2 ("RAMDAC2") */ + if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0xef); +#ifdef SET_EMI + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); + } +#endif + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){ - SiS_GetRAMDAC2DATA(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - return; - } + if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { + tempah = 0x10; + if(SiS_LCDAEnabled(SiS_Pr, HwInfo)) { + if(SiS_TVEnabled(SiS_Pr, HwInfo)) tempah = 0x18; + else tempah = 0x08; + } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4c,tempah); + } - /* TW: For TV */ + if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); + SiS_DisplayOff(SiS_Pr); + pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06); + if(IS_SIS740) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); + } + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || + (SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ) { + if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { + if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_GenericDelay(SiS_Pr, 0x4500); + } + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2); + } else { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } + } + } - SiS_GetCRT2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex,HwDeviceExtension); + if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40)) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + delaylong = TRUE; + } + } - switch (CRT2Index) { - case 2: TVPtr = SiS_Pr->SiS_ExtHiTVData; break; -/* case 7: TVPtr = SiS_Pr->SiS_St1HiTVData; break; */ - case 12: TVPtr = SiS_Pr->SiS_St2HiTVData; break; - case 3: TVPtr = SiS_Pr->SiS_ExtPALData; break; - case 4: TVPtr = SiS_Pr->SiS_ExtNTSCData; break; - case 8: TVPtr = SiS_Pr->SiS_StPALData; break; - case 9: TVPtr = SiS_Pr->SiS_StNTSCData; break; - default: TVPtr = SiS_Pr->SiS_StPALData; break; /* TW: Just to avoid a crash */ - } + } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { - SiS_Pr->SiS_RVBHCMAX = (TVPtr+ResIndex)->RVBHCMAX; - SiS_Pr->SiS_RVBHCFACT = (TVPtr+ResIndex)->RVBHCFACT; - SiS_Pr->SiS_VGAHT = (TVPtr+ResIndex)->VGAHT; - SiS_Pr->SiS_VGAVT = (TVPtr+ResIndex)->VGAVT; - SiS_Pr->SiS_HDE = (TVPtr+ResIndex)->TVHDE; - SiS_Pr->SiS_VDE = (TVPtr+ResIndex)->TVVDE; - SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->RVBHRS; - SiS_Pr->SiS_NewFlickerMode = (TVPtr+ResIndex)->FlickerMode; - if(modeflag & HalfDCLK) { - SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->HALFRVBHRS; - } + if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x10); + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - - if(SiS_Pr->SiS_HiVision != 3) { - - if(resinfo == 0x08) SiS_Pr->SiS_NewFlickerMode = 0x40; - if(resinfo == 0x09) SiS_Pr->SiS_NewFlickerMode = 0x40; - if(resinfo == 0x12) SiS_Pr->SiS_NewFlickerMode = 0x40; - - } - - switch(SiS_Pr->SiS_HiVision) { - case 2: - case 1: - case 0: - SiS_Pr->SiS_HT = 0x6b4; - SiS_Pr->SiS_VT = 0x20d; - /* Don't care about TVSimuMode */ - break; - default: - if(SiS_Pr->SiS_VGAVDE == 350) SiS_Pr->SiS_SetFlag |= TVSimuMode; - - SiS_Pr->SiS_HT = ExtHiTVHT; - SiS_Pr->SiS_VT = ExtHiTVVT; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - SiS_Pr->SiS_HT = StHiTVHT; - SiS_Pr->SiS_VT = StHiTVVT; - if(!(modeflag & Charx8Dot)){ - SiS_Pr->SiS_HT = StHiTextTVHT; - SiS_Pr->SiS_VT = StHiTextTVVT; - } - } - } - } + } else if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { - } else { + if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { + tempah = 0x10; + if(SiS_LCDAEnabled(SiS_Pr, HwInfo)) { + if(SiS_TVEnabled(SiS_Pr, HwInfo)) tempah = 0x18; + else tempah = 0x08; + } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4c,tempah); + } - SiS_Pr->SiS_RY1COE = (TVPtr+ResIndex)->RY1COE; - SiS_Pr->SiS_RY2COE = (TVPtr+ResIndex)->RY2COE; - SiS_Pr->SiS_RY3COE = (TVPtr+ResIndex)->RY3COE; - SiS_Pr->SiS_RY4COE = (TVPtr+ResIndex)->RY4COE; - - if(modeflag & HalfDCLK) { - SiS_Pr->SiS_RY1COE = 0x00; - SiS_Pr->SiS_RY2COE = 0xf4; - SiS_Pr->SiS_RY3COE = 0x10; - SiS_Pr->SiS_RY4COE = 0x38; - } - - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - SiS_Pr->SiS_HT = NTSCHT; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if((ModeNo == 0x4a) || (ModeNo == 0x38)) SiS_Pr->SiS_HT = NTSC2HT; - } - SiS_Pr->SiS_VT = NTSCVT; - } else { - SiS_Pr->SiS_HT = PALHT; - SiS_Pr->SiS_VT = PALVT; - } + } - } + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; + if(SiS_BridgeInSlave(SiS_Pr)) { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) { + if(!(SiS_LCDAEnabled(SiS_Pr, HwInfo))) temp |= 0x20; + } + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); - return; - } + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ - /* TW: For LCD */ + if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2e); + if(!(temp & 0x80)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); + } + } else { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + } + } else { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x20); + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); - SiS_GetCRT2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex,HwDeviceExtension); + if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2e); + if(!(temp & 0x80)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); + } + } - switch (CRT2Index) { - case 0: LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; /* VESA Timing */ - case 1: LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data; break; /* VESA Timing */ - case 5: LCDPtr = SiS_Pr->SiS_StLCD1024x768Data; break; /* Obviously unused */ - case 6: LCDPtr = SiS_Pr->SiS_StLCD1280x1024Data; break; /* Obviously unused */ - case 10: LCDPtr = SiS_Pr->SiS_St2LCD1024x768Data; break; /* Non-VESA Timing */ - case 11: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; /* Non-VESA Timing */ - case 13: LCDPtr = SiS_Pr->SiS_NoScaleData1024x768; break; /* Non-expanding */ - case 14: LCDPtr = SiS_Pr->SiS_NoScaleData1280x1024; break; /* Non-expanding */ - case 15: LCDPtr = SiS_Pr->SiS_LCD1280x960Data; break; /* 1280x960 */ - case 20: LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data; break; /* VESA Timing */ - case 21: LCDPtr = SiS_Pr->SiS_NoScaleData1400x1050; break; /* Non-expanding (let panel scale) */ - case 22: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break; /* Non-VESA Timing (let panel scale) */ - case 23: LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break; /* VESA Timing */ - case 24: LCDPtr = SiS_Pr->SiS_NoScaleData1600x1200; break; /* Non-expanding */ - case 25: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break; /* Non-VESA Timing */ - default: LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; /* Just to avoid a crash */ - } + tempah = 0xc0; + if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { + tempah = 0x80; + if(!(SiS_IsVAMode(SiS_Pr, HwInfo))) { + tempah = 0x40; + } + } + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah); - SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX; - SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT; - SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT; - SiS_Pr->SiS_VGAVT = (LCDPtr+ResIndex)->VGAVT; - SiS_Pr->SiS_HT = (LCDPtr+ResIndex)->LCDHT; - SiS_Pr->SiS_VT = (LCDPtr+ResIndex)->LCDVT; - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, - "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex); -#endif - - tempax = 1024; - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - if(HwDeviceExtension->jChipType < SIS_315H) { - if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; - else tempbx = 768; - } else { - tempbx = 768; - } - } else { - if (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527; - else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620; - else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775; - else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775; - else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; - else tempbx = 768; - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - tempax = 1280; - if (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768; - else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800; - else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864; - else tempbx = 1024; - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { - tempax = 1280; - if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 700; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 800; - else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960; - else tempbx = 960; - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - tempax = 1400; - tempbx = 1050; - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { - tempax = 1600; - tempbx = 1200; - } - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - tempax = SiS_Pr->SiS_VGAHDE; - tempbx = SiS_Pr->SiS_VGAVDE; - } - SiS_Pr->SiS_HDE = tempax; - SiS_Pr->SiS_VDE = tempbx; - return; - } -} + if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || + (((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) && + (!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + } -USHORT -SiS_GetResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) -{ - USHORT resindex; + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(ModeNo <= 0x13) - resindex=SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; - else - resindex=SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + } +#ifdef COMPAQ_HACK + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + } +#endif - return(resindex); -} + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1f,0x10); -void -SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT xres,yres,modeflag=0,resindex; + if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { +#ifdef SET_EMI + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); + } +#endif + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c); +#ifdef SET_EMI + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + + cr36 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); + + /* (P4_30|0x40) */ + /* Compal 1400x1050: 0x05, 0x60, 0x00 YES (1.10.7w; CR36=69) */ + /* Compal 1400x1050: 0x0d, 0x70, 0x40 YES (1.10.7x; CR36=69) */ + /* Acer 1280x1024: 0x12, 0xd0, 0x6b NO (1.10.9k; CR36=73) */ + /* Compaq 1280x1024: 0x0d, 0x70, 0x6b YES (1.12.04b; CR36=03) */ + /* Clevo 1024x768: 0x05, 0x60, 0x33 NO (1.10.8e; CR36=12, DL!) */ + /* Clevo 1024x768: 0x0d, 0x70, 0x40 (if type == 3) YES (1.10.8y; CR36=?2) */ + /* Clevo 1024x768: 0x05, 0x60, 0x33 (if type != 3) YES (1.10.8y; CR36=?2) */ + /* Asus 1024x768: ? ? (1.10.8o; CR36=?2) */ + /* Asus 1024x768: 0x08, 0x10, 0x3c (problematic) YES (1.10.8q; CR36=22) */ + + if(SiS_Pr->HaveEMI) { + r30 = SiS_Pr->EMI_30; + r31 = SiS_Pr->EMI_31; + r32 = SiS_Pr->EMI_32; + r33 = SiS_Pr->EMI_33; + } else { + r30 = 0; + } - resindex = SiS_GetResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex); + /* EMI_30 is read at driver start; however, the BIOS sets this + * (if it is used) only if the LCD is in use. In case we caught + * the machine while on TV output, this bit is not set and we + * don't know if it should be set - hence our detection is wrong. + * Work-around this here: + */ + + if((!SiS_Pr->HaveEMI) || (!SiS_Pr->HaveEMILCD)) { + if((cr36 & 0x0f) == 0x02) { /* 1024x768 */ + r30 |= 0x40; + if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { + r30 &= ~0x40; + } + } else if((cr36 & 0x0f) == 0x03) { /* 1280x1024 */ + r30 |= 0x40; + if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) { + r30 &= ~0x40; + } + } else if((cr36 & 0x0f) == 0x09) { /* 1400x1050 */ + r30 |= 0x40; + } else if((cr36 & 0x0f) == 0x0b) { /* 1600x1200 - unknown */ + r30 |= 0x40; + } + } - if(ModeNo <= 0x13) { - xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; - yres = SiS_Pr->SiS_StResInfo[resindex].VTotal; - } else { - xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; - yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal; - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } + if(!SiS_Pr->HaveEMI) { + if((cr36 & 0x0f) == 0x02) { + if((cr36 & 0xf0) == 0x30) { + r31 = 0x0d; r32 = 0x70; r33 = 0x40; + } else { + r31 = 0x05; r32 = 0x60; r33 = 0x33; + } + } else if((cr36 & 0x0f) == 0x03) { + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + r31 = 0x0d; r32 = 0x70; r33 = 0x6b; + } else { + r31 = 0x12; r32 = 0xd0; r33 = 0x6b; + } + } else if((cr36 & 0x0f) == 0x09) { + if(SiS_Pr->SiS_CustomT == CUT_COMPAL1400_2) { + r31 = 0x0d; r32 = 0x70; r33 = 0x40; /* BIOS values */ + } else { + r31 = 0x05; r32 = 0x60; r33 = 0x00; + } + } else { + r31 = 0x05; r32 = 0x60; r33 = 0x00; + } + } - if((HwDeviceExtension->jChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) { - if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) { - if(yres == 350) yres = 400; - } - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x3a) & 0x01) { - if(ModeNo == 0x12) yres = 400; - } - } + /* BIOS values don't work so well sometimes */ + if(!SiS_Pr->OverruleEMI) { +#ifdef COMPAL_HACK + if(SiS_Pr->SiS_CustomT == CUT_COMPAL1400_2) { + if((cr36 & 0x0f) == 0x09) { + r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x00; + } + } +#endif +#ifdef COMPAQ_HACK + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + if((cr36 & 0x0f) == 0x03) { + r30 = 0x20; r31 = 0x12; r32 = 0xd0; r33 = 0x6b; /* rev 1 */ + } + } +#endif +#ifdef ASUS_HACK + if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { + if((cr36 & 0x0f) == 0x02) { + /* r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 2 */ + /* r30 = 0x20; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 3 */ + /* r30 = 0x60; r31 = 0x0d; r32 = 0x70; r33 = 0x40; */ /* rev 4 */ + /* r30 = 0x20; r31 = 0x0d; r32 = 0x70; r33 = 0x40; */ /* rev 5 */ + } + } +#endif + } + if(!(SiS_Pr->OverruleEMI && (!r30) && (!r31) && (!r32) && (!r33))) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); + } + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,r31); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,r32); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x33,r33); + if(!(SiS_Pr->OverruleEMI && (!r30) && (!r31) && (!r32) && (!r33))) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + } else { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x00); + } + if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || + (SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ) { + if(r30 & 0x40) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 5); + if(delaylong) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 5); + delaylong = FALSE; + } + SiS_WaitVBRetrace(SiS_Pr,HwInfo); + if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { + SiS_GenericDelay(SiS_Pr, 0x500); + } + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); + } + } + } +#endif + } - if(ModeNo > 0x13) { - if(SiS_Pr->SiS_IF_DEF_FSTN == 1){ - xres *= 2; - yres *= 2; - } else { - if(modeflag & HalfDCLK) xres *= 2; - if(modeflag & DoubleScanMode) yres *= 2; - } - } + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - if(xres == 720) xres = 640; - } else { - if(SiS_Pr->SiS_VBType & VB_NoLCD) { /* TW: 301BDH */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(xres == 720) xres = 640; - } - if(SiS_Pr->SiS_SetFlag & SetDOSMode) { - yres = 400; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480; - } else { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480; - } - } - } else { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToAVIDEO | /* (Allow 720 for VGA2) */ - SetCRT2ToSVIDEO | - SetCRT2ToSCART | - SetCRT2ToLCD | - SetCRT2ToHiVisionTV)) { - if(xres == 720) xres = 640; - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(ModeNo <= 0x13) { - /* TW: This is wrong for 640x400 *graphics* mode */ - if(yres == 400) yres = 405; - } - if(yres == 350) yres = 360; - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - if(yres == 360) yres = 375; - } - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768){ - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - if(yres == 350) yres = 357; - if(yres == 400) yres = 420; - if(yres == 480) yres = 525; - } - } - } - } - } - } - } else { - if(xres == 720) xres = 640; - if(SiS_Pr->SiS_SetFlag & SetDOSMode) { - yres = 400; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480; - } else { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480; - } - } - } - SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; - SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; -} + if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || + (SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ) { + SiS_DisplayOn(SiS_Pr); + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + SiS_WaitVBRetrace(SiS_Pr, HwInfo); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); + } + } -void -SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT tempbx=0,tempal=0; - USHORT Flag,resinfo=0; + } else if(SiS_Pr->SiS_CustomT == CUT_CLEVO1400) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + if( (SiS_IsVAMode(SiS_Pr, HwInfo)) || + (SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ) { + SiS_DisplayOn(SiS_Pr); + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + SiS_WaitVBRetrace(SiS_Pr,HwInfo); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); + } + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */ + } else { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { - tempbx = 15; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - tempbx = 20; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 21; - else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 22; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { - tempbx = 23; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 24; - else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 25; - } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - tempbx = 13; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempbx++; - } else { - tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_Panel1024x768; - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - tempbx += 5; - /* GetRevisionID(); */ - /* TW: BIOS only adds 5 once */ - tempbx += 5; - } - } + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || + ((SiS_CRT2IsLCD(SiS_Pr, HwInfo))) ) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + if(delaylong) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + } + SiS_WaitVBRetrace(SiS_Pr,HwInfo); + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_GenericDelay(SiS_Pr, 0x500); + } + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); + } + } - } else { /* TV */ - - if((SiS_Pr->SiS_VBType & VB_SIS301B302B) && - (SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) { - if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_SetFlag &= (~TVSimuMode); - tempbx = 2; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(!(SiS_Pr->SiS_SetFlag & TVSimuMode)) tempbx = 12; - } - } else { - if(SiS_Pr->SiS_VBInfo & SetPALTV) tempbx = 3; - else tempbx = 4; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) tempbx += 5; - } - - } - - if(ModeNo <= 0x13) { - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } - - tempal &= 0x3F; - - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - (SiS_Pr->SiS_VBInfo & (SetCRT2ToTV-SetCRT2ToHiVisionTV))) { - if(tempal == 0x06) tempal = 0x07; - } - - /* TW: 300/301LV BIOS */ - if((HwDeviceExtension->jChipType == SIS_300) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - if(ModeNo > 0x13) { - if((resinfo == 0x0c) || (resinfo == 0x0d)) /* 720 (index diff. on 310/325!) */ - tempal = 6; - } - } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); + SiS_DisplayOn(SiS_Pr); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xff); - if(HwDeviceExtension->jChipType != SIS_300) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if((ModeNo == 0x31) || (ModeNo == 0x32)) tempal = 6; - } - } + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + } - *CRT2Index = tempbx; - *ResIndex = tempal; + } - } else { /* LVDS, 301B-DH (if running on LCD) */ + } - Flag = 1; - tempbx = 0; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - Flag = 0; - tempbx = 10; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - tempbx += 2; - if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; - if(SiS_Pr->SiS_CHPALM) { - tempbx = 90; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - } else if(SiS_Pr->SiS_CHPALN) { - tempbx = 92; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - } - - } - } - - } + } else { /* 315, 330 */ - if(Flag) { - - if(SiS_Pr->SiS_LCDResInfo <= SiS_Pr->SiS_Panel1280x1024) { - tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_PanelMinLVDS; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 3; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { - tempbx = 18; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - tempbx = 6; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - tempbx = 15; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { - tempbx = 16; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - tempbx = 8; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { - tempbx = 21; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; - } - - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - tempbx = 7; - } - - } - - if(ModeNo <= 0x13) - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - else { - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } - - if(SiS_Pr->SiS_IF_DEF_FSTN){ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){ - tempbx = 14; - tempal = 6; - } - } + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; + if(SiS_BridgeInSlave(SiS_Pr)) { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); - if(SiS_Pr->SiS_SetFlag & SetDOSMode) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) tempal = 7; - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) tempal++; - } + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ - } + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); + if(!(temp & 0x80)) + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(ModeNo > 0x13) { - if(HwDeviceExtension->jChipType < SIS_315H) { - if((resinfo == 0x0c) || (resinfo == 0x0d)) /* 720 */ - tempal = 6; - } else { - if((resinfo == 0x0d) || (resinfo == 0x0e)) /* 720 */ - tempal = 6; - } - } - } + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); - *CRT2Index = tempbx; - *ResIndex = tempal & 0x1F; - } -} + if(SiS_Is301B(SiS_Pr)) { -#ifdef SIS315H -void -SiS_GetCRT2PtrA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index, - USHORT *ResIndex) -{ - USHORT tempbx,tempal; + temp=SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); + if(!(temp & 0x80)) + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + + tempah = 0xc0; + if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + tempah = 0x80; + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + tempah = 0x40; + } + } + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah); - tempbx = SiS_Pr->SiS_LCDResInfo; + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 4; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempbx = 3; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) tempbx = 2; - else tempbx -= SiS_Pr->SiS_Panel1024x768; + } else { - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 5; + SiS_VBLongWait(SiS_Pr); + SiS_DisplayOn(SiS_Pr); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7F); + SiS_VBLongWait(SiS_Pr); - if(ModeNo <= 0x13) - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - else - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + } - *CRT2Index = tempbx; - *ResIndex = tempal & 0x1F; -} -#endif + } /* 315, 330 */ -void -SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index, - USHORT *ResIndex) -{ - USHORT tempbx,tempal; +#endif /* SIS315H */ - if(ModeNo <= 0x13) - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - else - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + } - tempbx = SiS_Pr->SiS_LCDResInfo; + } else { /* ============ For 301 ================ */ - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 16; - else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx += 32; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } + } - *CRT2Index = tempbx; - *ResIndex = tempal & 0x3F; -} + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ + if(SiS_BridgeInSlave(SiS_Pr)) { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); -USHORT -SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - SHORT LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01 }; - USHORT RefreshRateTableIndex,i,backup_i; - USHORT modeflag,index,temp,backupindex; + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ - if(SiS_Pr->UseCustomMode) return 0; - - if(ModeNo <= 0x13) - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - else - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + if(HwInfo->jChipType >= SIS_315H) { + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); + if(!(temp & 0x80)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); /* BVBDOENABLE=1 */ + } + } - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(modeflag & HalfDCLK) return(0); - } - } + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ - if(ModeNo < 0x14) return(0xFFFF); + SiS_VBLongWait(SiS_Pr); + SiS_DisplayOn(SiS_Pr); + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + } + SiS_VBLongWait(SiS_Pr); - /* TW: CR33 holds refresh rate index for CRT1 [3:0] and CRT2 [7:4]. - * On LVDS machines, CRT2 index is always 0 and will be - * set to 0 by the following code; this causes the function - * to take the first non-interlaced mode in SiS_Ext2Struct - */ - - index = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x33); - index >>= SiS_Pr->SiS_SelectCRT2Rate; - index &= 0x0F; - backupindex = index; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); + } + } - if(index > 0) index--; + } - if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0; - } else { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_VBType & VB_NoLCD) - index = 0; - else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) - index = backupindex = 0; - } - } - } + } else { /* =================== For LVDS ================== */ - if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - index = 0; - } - } - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) { - temp = LCDRefreshIndex[SiS_Pr->SiS_LCDResInfo]; - if(index > temp) index = temp; - } - } else { - index = 0; - } - } - } + if(HwInfo->jChipType < SIS_315H) { - RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; - ModeNo = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].ModeID; +#ifdef SIS300 /* 300 series */ - /* TW: 650/LVDS 1.10.07, 650/30xLV 1.10.6s */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(!(SiS_Pr->SiS_VBInfo & DriverMode)) { - if( (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x105) || - (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x107) ) { - if(backupindex <= 1) RefreshRateTableIndex++; - } - } - } + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + if(HwInfo->jChipType == SIS_730) { + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + } + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); + if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } + } - i = 0; - do { - if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + i].ModeID != ModeNo) break; - temp = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag; - temp &= ModeInfoFlag; - if(temp < SiS_Pr->SiS_ModeType) break; - i++; - index--; - } while(index != 0xFFFF); + SiS_EnableCRT2(SiS_Pr); + SiS_DisplayOn(SiS_Pr); + SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); + if(SiS_BridgeInSlave(SiS_Pr)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); + } - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - temp = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + i - 1].Ext_InfoFlag; - if(temp & InterlaceMode) { - i++; - } - } - } + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { + if(!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) { + SiS_WaitVBRetrace(SiS_Pr, HwInfo); + SiS_SetCH700x(SiS_Pr,0x0B0E); + } + } - i--; + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + } + SiS_WaitVBRetrace(SiS_Pr, HwInfo); + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); + } + } + } - if((SiS_Pr->SiS_SetFlag & ProgrammingCRT2) && (!(SiS_Pr->SiS_VBInfo & DisableCRT2Display))) { - backup_i = i; - if (!(SiS_AdjustCRT2Rate(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,&i,HwDeviceExtension))) { - /* TW: This is for avoiding random data to be used; i is - * in an undefined state if no matching CRT2 mode is - * found. - */ - i = backup_i; - } - } +#endif /* SIS300 */ - return(RefreshRateTableIndex + i); -} + } else { -/* Checked against all (incl 650/LVDS (1.10.07), 630/301) BIOSes */ -BOOLEAN -SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *i,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT tempax,tempbx,resinfo; - USHORT modeflag,infoflag; +#ifdef SIS315H /* 315 series */ - if (ModeNo <= 0x13) - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - else - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } + } - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - tempbx = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].ModeID; + SiS_EnableCRT2(SiS_Pr); + SiS_UnLockCRT2(SiS_Pr,HwInfo); - tempax = 0; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { - tempax |= SupportRAMDAC2; - if(HwDeviceExtension->jChipType >= SIS_315H) { - tempax |= SupportTV; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == 0x0a) tempax |= SupportTV1024; - } - } - } - } - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - tempax |= SupportLCD; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) { - if((resinfo == 6) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - (*i) = 0; - return(1); - } else { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) { - if((resinfo == 6) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - return(0); - } else { - if((resinfo >= 9) && (resinfo != 0x14)) { - return(0); - } - } - } - } - } - } - } - } else { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - if((resinfo != 0x0f) && ((resinfo == 4) || (resinfo >= 8))) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { - if((resinfo != 0x10) && (resinfo > 8)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { - if((resinfo != 0x0e) && (resinfo > 8)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(resinfo > 9) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(resinfo > 8) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - if((resinfo == 4) || (resinfo > 7)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - if((resinfo == 4) || (resinfo == 3) || (resinfo > 6)) return(0); - } - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(SiS_Pr->SiS_HiVision == 3) { - tempax |= SupportHiVisionTV2; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode){ - if(resinfo == 4) return(0); - if(resinfo == 3) return(0); - if(resinfo == 7) { - if(SiS_Pr->SiS_SetFlag & TVSimuMode) return(0); - } - if(resinfo > 7) return(0); - } - } else { - tempax |= SupportHiVisionTV; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode){ - if(resinfo == 4) return(0); - if((resinfo == 3) || (resinfo == 7)) { - if(SiS_Pr->SiS_SetFlag & TVSimuMode) return(0); - } - if(resinfo > 7) return(0); - } - } - } else { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) { - tempax |= SupportTV; - tempax |= SupportTV1024; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if((SiS_Pr->SiS_VBInfo & SetNotSimuMode) && (SiS_Pr->SiS_VBInfo & SetPALTV)) { - if(resinfo != 8) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 4)) ) { - tempax &= ~(SupportTV1024); - if(HwDeviceExtension->jChipType >= SIS_315H) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else { - if( (resinfo != 3) || - (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == 3) return(0); - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0); - } - } - } else return(0); - } - } - } - } else { - tempax &= ~(SupportTV1024); - if(HwDeviceExtension->jChipType >= SIS_315H) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else { - if( (resinfo != 3) || - (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == 3) return(0); - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0); - } - } - } else return(0); - } - } - } else { /* slavemode */ - if(resinfo != 8) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 4) ) ) { - tempax &= ~(SupportTV1024); - if(HwDeviceExtension->jChipType >= SIS_315H) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else { - if( (resinfo != 3) || - (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == 3) return(0); - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0); - } - } - } else return(0); - } - } - } - } - } else { /* 301 */ - tempax &= ~(SupportTV1024); - if(HwDeviceExtension->jChipType >= SIS_315H) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else { - if( (resinfo != 3) || - (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == 3) return(0); - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0); - } - } - } else return(0); - } - } - } - } - - } else { /* TW: for LVDS */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - tempax |= SupportCHTV; - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - tempax |= SupportLCD; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { - if((resinfo != 0x14) && (resinfo > 0x09)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - if((resinfo != 0x0f) && (resinfo > 0x08)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { - if((resinfo != 0x10) && (resinfo > 0x08)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - if((resinfo != 0x15) && (resinfo > 0x09)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(resinfo > 0x09) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(resinfo > 0x08) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600){ - if(resinfo > 0x07) return(0); - if(resinfo == 0x04) return(0); - } - } - } - /* TW: Look backwards in table for matching CRT2 mode */ - for(; SiS_Pr->SiS_RefIndex[RefreshRateTableIndex+(*i)].ModeID == tempbx; (*i)--) { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].Ext_InfoFlag; - if(infoflag & tempax) { - return(1); - } - if ((*i) == 0) break; - } - /* TW: Look through the whole mode-section of the table from the beginning - * for a matching CRT2 mode if no mode was found yet. - */ - for((*i) = 0; ; (*i)++) { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].Ext_InfoFlag; - if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].ModeID != tempbx) { - return(0); - } - if(infoflag & tempax) { - return(1); - } - } - return(1); -} + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp &= 0x20; + SiS_Chrontel701xBLOff(SiS_Pr); + } -void -SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo) -{ - USHORT temp1,temp2; + if(HwInfo->jChipType != SIS_550) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); + } - /* TW: We store CRT1 ModeNo in CR34 */ - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x34,ModeNo); - temp1 = (SiS_Pr->SiS_VBInfo & SetInSlaveMode) >> 8; - temp2 = ~(SetInSlaveMode >> 8); - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x31,temp2,temp1); -} + if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(SiS_IsLCDOrLCDA(SiS_Pr, HwInfo)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); + } + } + } -void -SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension, - int checkcrt2mode) -{ - USHORT tempax,tempbx,temp; - USHORT modeflag, resinfo=0; - UCHAR OutputSelect = *SiS_Pr->pSiS_OutputSelect; + temp1 = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); + if(!(temp1 & 0x80)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + } - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - if (ModeNo <= 0x13) - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } - } + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(temp) { + SiS_Chrontel701xBLOn(SiS_Pr, HwInfo); + } + } - SiS_Pr->SiS_SetFlag = 0; + if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); + if(HwInfo->jChipType == SIS_550) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x40); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x10); + } + } + } else if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + if(HwInfo->jChipType != SIS_740) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); + } + } - SiS_Pr->SiS_ModeType = modeflag & ModeInfoFlag; + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + } - tempbx = 0; - if(SiS_BridgeIsOn(SiS_Pr,BaseAddr,HwDeviceExtension) == 0) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); -#if 0 - /* SiS_HiVision is only used on 310/325/330+30xLV */ - if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV)) { - if(SiS_Pr->SiS_HiVision & 0x03) { /* TW: New from 650/30xLV 1.10.6s */ - temp &= (SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode); /* 0x83 */ - temp |= SetCRT2ToHiVisionTV; /* 0x80 */ - } - if(SiS_Pr->SiS_HiVision & 0x04) { /* TW: New from 650/30xLV 1.10.6s */ - temp &= (SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode); /* 0x83 */ - temp |= SetCRT2ToSVIDEO; /* 0x08 */ - } - } -#endif - if(SiS_Pr->SiS_IF_DEF_FSTN) { /* fstn must set CR30=0x21 */ - temp = (SetCRT2ToLCD | SetSimuScanMode); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,temp); - } - tempbx |= temp; - tempax = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) << 8; - tempax &= (LoadDACFlag | DriverMode | SetDispDevSwitch | SetNotSimuMode | SetPALTV); - tempbx |= tempax; - tempbx &= ~(SetCHTVOverScan | SetInSlaveMode | DisableCRT2Display);; + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) { + SiS_Chrontel701xOn(SiS_Pr,HwInfo); + } + if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || + (SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) ) { + SiS_ChrontelDoSomething1(SiS_Pr,HwInfo); + } + } -#ifdef SIS315H + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || + (SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) ) { + SiS_Chrontel701xBLOn(SiS_Pr, HwInfo); + SiS_ChrontelInitTVVSync(SiS_Pr,HwInfo); + } + } + } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); + } + } + } - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & (VB_SIS302B | VB_SIS301LV | VB_SIS302LV)) { - /* From 1.10.7w, not in 1.10.8r */ - if(ModeNo == 0x03) { - /* Mode 0x03 is never in driver mode */ - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x31,0xbf); - } - /* From 1.10.7w, not in 1.10.8r */ - if(!(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8))) { - /* Reset LCDA setting */ - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); - } - if(IS_SIS650) { - if(SiS_Pr->SiS_UseLCDA) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f) & 0xF0) { - if((ModeNo <= 0x13) || (!(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8)))) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA)); /* 3 */ - } - } - } -#if 0 /* We can't detect it this way; there are machines which do not use LCDA despite - * the chip revision - */ - if((tempbx & SetCRT2ToLCD) && (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD)) { - if((SiS_GetReg1(SiS_Pr->SiS_P3d4, 0x36) & 0x0f) == SiS_Pr->SiS_Panel1400x1050) { - if((ModeNo <= 0x13) || (!(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8)))) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f) & 0xF0) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA)); /* 3 */ - } - } - } else { - if((ModeNo <= 0x13) || (!(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8)))) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f) & 0xF0) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA)); /* 3 */ - } - } - } - } -#endif - } - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) { - tempbx |= SetCRT2ToLCDA; - } - } +#endif /* SIS315H */ + + } /* 310 series */ + + } /* LVDS */ + +} - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if(temp & SetToLCDA) - tempbx |= SetCRT2ToLCDA; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(temp & EnableLVDSHiVision) - tempbx |= SetCRT2ToHiVisionTV; - } - } - } +/*********************************************/ +/* SET PART 1 REGISTER GROUP */ +/*********************************************/ -#endif /* SIS315H */ +/********** Set CRT2 OFFSET / PITCH **********/ +static void +SiS_SetCRT2Offset(SiS_Private *SiS_Pr,USHORT ModeNo, + USHORT ModeIdIndex ,USHORT RefreshRateTableIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT offset; + UCHAR temp; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - temp = SetCRT2ToLCDA | SetCRT2ToSCART | SetCRT2ToLCD | - SetCRT2ToRAMDAC | SetCRT2ToSVIDEO | SetCRT2ToAVIDEO | /* = 0x807C; */ - SetCRT2ToHiVisionTV; /* = 0x80FC; */ - } else { - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) - temp = SetCRT2ToLCDA | SetCRT2ToSCART | - SetCRT2ToLCD | SetCRT2ToHiVisionTV | - SetCRT2ToAVIDEO | SetCRT2ToSVIDEO; /* = 0x80bc */ - else - temp = SetCRT2ToLCDA | SetCRT2ToLCD; - } else { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) - temp = SetCRT2ToTV | SetCRT2ToLCD; - else - temp = SetCRT2ToLCD; - } - } + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) return; - if(!(tempbx & temp)) { - tempax = DisableCRT2Display; - tempbx = 0; - } + offset = SiS_GetOffset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + HwInfo); - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(tempbx & SetCRT2ToLCDA) { - tempbx &= (0xFF00|SwitchToCRT2|SetSimuScanMode); - } - if(tempbx & SetCRT2ToRAMDAC) { - tempbx &= (0xFF00|SetCRT2ToRAMDAC|SwitchToCRT2|SetSimuScanMode); - } - if((tempbx & SetCRT2ToLCD) /* && (!(SiS_Pr->SiS_VBType & VB_NoLCD)) */ ) { - /* We initialize the Panel Link of the type of bridge is DH */ - tempbx &= (0xFF00|SetCRT2ToLCD|SwitchToCRT2|SetSimuScanMode); - } - if(tempbx & SetCRT2ToSCART) { - tempbx &= (0xFF00|SetCRT2ToSCART|SwitchToCRT2|SetSimuScanMode); - tempbx |= SetPALTV; - } - if(tempbx & SetCRT2ToHiVisionTV) { - tempbx &= (0xFF00|SetCRT2ToHiVisionTV|SwitchToCRT2|SetSimuScanMode); - tempbx |= SetPALTV; - } - } else { /* LVDS */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(tempbx & SetCRT2ToLCDA) - tempbx &= (0xFF00|SwitchToCRT2|SetSimuScanMode); - } - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(tempbx & SetCRT2ToTV) - tempbx &= (0xFF00|SetCRT2ToTV|SwitchToCRT2|SetSimuScanMode); - } - if(tempbx & SetCRT2ToLCD) { - tempbx &= (0xFF00|SetCRT2ToLCD|SwitchToCRT2|SetSimuScanMode); - } - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(tempbx & SetCRT2ToLCDA) - tempbx |= SetCRT2ToLCD; - } - } + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) offset >>= 1; - if(tempax & DisableCRT2Display) { - if(!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { - tempbx = SetSimuScanMode | DisableCRT2Display; - } - } + temp = (UCHAR)(offset & 0xFF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,temp); + temp = (UCHAR)(offset >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,temp); + temp = (UCHAR)(((offset >> 3) & 0xFF) + 1); + if(offset % 8) temp++; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,temp); +} - if(!(tempbx & DriverMode)){ - tempbx |= SetSimuScanMode; - } +/************* Set CRT2 Sync *************/ +static void +SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT RefreshRateTableIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT tempah=0,tempbl,infoflag; - /* TW: LVDS (LCD/TV) and 301BDH (LCD) can only be slave in 8bpp modes */ - if(SiS_Pr->SiS_ModeType <= ModeVGA) { - if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || - ((tempbx & SetCRT2ToLCD) && (SiS_Pr->SiS_VBType & VB_NoLCD)) ) { - modeflag &= (~CRT2Mode); - } - } - - if(!(tempbx & SetSimuScanMode)){ - if(tempbx & SwitchToCRT2) { - if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { - if( (HwDeviceExtension->jChipType >= SIS_315H) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { - if(resinfo != 0x0a) - tempbx |= SetSimuScanMode; - } else { - tempbx |= SetSimuScanMode; - } - } - } else { - if(!(SiS_BridgeIsEnable(SiS_Pr,BaseAddr,HwDeviceExtension))) { - if(!(tempbx & DriverMode)) { - if(SiS_BridgeInSlave(SiS_Pr)) { - tempbx |= SetSimuScanMode; - } - } - } - } - } + tempbl = 0xC0; - if(!(tempbx & DisableCRT2Display)) { - if(tempbx & DriverMode) { - if(tempbx & SetSimuScanMode) { - if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { - if( (HwDeviceExtension->jChipType >= SIS_315H) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { - if(resinfo != 0x0a) { /* TW: 650/301 BIOS */ - tempbx |= SetInSlaveMode; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(tempbx & SetCRT2ToTV) { - if(!(tempbx & SetNotSimuMode)) - SiS_Pr->SiS_SetFlag |= TVSimuMode; - } - } - } /* TW: 650/301 BIOS */ - } else { - tempbx |= SetInSlaveMode; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(tempbx & SetCRT2ToTV) { - if(!(tempbx & SetNotSimuMode)) - SiS_Pr->SiS_SetFlag |= TVSimuMode; - } - } - } - } - } - } else { - tempbx |= SetInSlaveMode; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(tempbx & SetCRT2ToTV) { - if(!(tempbx & SetNotSimuMode)) - SiS_Pr->SiS_SetFlag |= TVSimuMode; - } - } - } - } - - if(SiS_Pr->SiS_CHOverScan) { - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35); - if((temp & TVOverScan) || (SiS_Pr->SiS_CHOverScan == 1) ) - tempbx |= SetCHTVOverScan; - } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x79); - if( (temp & 0x80) || (SiS_Pr->SiS_CHOverScan == 1) ) - tempbx |= SetCHTVOverScan; - } - } + if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; + } else { + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; } - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { -#ifdef SIS300 - if((HwDeviceExtension->jChipType==SIS_630) || - (HwDeviceExtension->jChipType==SIS_730)) { - if(ROMAddr && SiS_Pr->SiS_UseROM) { - OutputSelect = ROMAddr[0xfe]; - } - if(!(OutputSelect & EnablePALMN)) - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0x3F); - if(tempbx & SetCRT2ToTV) { - if(tempbx & SetPALTV) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35); - if(temp & EnablePALM) tempbx &= (~SetPALTV); - } - } - } -#endif -#ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(ROMAddr && SiS_Pr->SiS_UseROM) { - OutputSelect = ROMAddr[0xf3]; - if(HwDeviceExtension->jChipType == SIS_330) { - OutputSelect = ROMAddr[0x11b]; - } - } - if(!(OutputSelect & EnablePALMN)) - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0x3F); - if(tempbx & SetCRT2ToTV) { - if(tempbx & SetPALTV) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if(temp & EnablePALM) tempbx &= (~SetPALTV); - } - } - } -#endif - } - - /* PALM/PALN on Chrontel 7019 */ - SiS_Pr->SiS_CHPALM = SiS_Pr->SiS_CHPALN = FALSE; - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(tempbx & SetCRT2ToTV) { - if(tempbx & SetPALTV) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if(temp & EnablePALM) SiS_Pr->SiS_CHPALM = TRUE; - else if(temp & EnablePALN) SiS_Pr->SiS_CHPALN = TRUE; - } - } - } + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */ - SiS_Pr->SiS_VBInfo = tempbx; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tempah = 0; + } else if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDInfo & LCDSync)) { + tempah = SiS_Pr->SiS_LCDInfo; + } else tempah = infoflag >> 8; - if(HwDeviceExtension->jChipType == SIS_630) { - SiS_WhatIsThis(SiS_Pr, SiS_Pr->SiS_VBInfo); - } + tempah &= 0xC0; -#ifdef TWDEBUG -#ifdef LINUX_KERNEL - printk(KERN_DEBUG "sisfb: (VBInfo= 0x%04x, SetFlag=0x%04x)\n", - SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag); -#endif -#ifdef LINUX_XF86 - xf86DrvMsgVerb(0, X_PROBED, 3, "(init301: VBInfo=0x%04x, SetFlag=0x%04x)\n", - SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag); -#endif -#endif + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; -#if 0 /* TW: Incomplete! (But does not seem to be required) */ - if(HwDeviceExtension->jChipType < SIS_315H) { - /* TW: From A901/630+301B BIOS */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + tempah |= 0xc0; + } } - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) - if( [si] == 3) ModeIdIndex = 0x3f2b; - } + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(HwInfo->jChipType >= SIS_315H) { + tempah >>= 3; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xE7,tempah); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,0xe0); + } + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); } - SiS_SetRegAND(SiS_Pr->SiS_P3d4, 0x31, 0xF7); - if(ModeNo == 0x13) bp+4 = 0x03; - } else { - /* From 650/30xLV BIOS: */ - SiS_SetRegAND(SiS_Pr->SiS_P3d4, 0x31, 0xF7); - if(ModeNo == 0x13) bp+4 = 0x03; - else bp+4 = ModeNo; - } -#endif - /* TW: 630/301B and 650/301 (not 301LV!) BIOSes do more here, but this seems for DOS mode */ + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { -} + if(HwInfo->jChipType < SIS_315H) { -void -SiS_WhatIsThis(SiS_Private *SiS_Pr, USHORT myvbinfo) -{ - unsigned long eax, temp; - unsigned short temp1; +#ifdef SIS300 /* ---- 300 series --- */ - if(!(SiS_Pr->SiS_ChSW)) return; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 630 - 301B(-DH) */ -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x80000874); - eax = SiS_GetReg3(0xcfc); -#else - eax = pciReadLong(0x00000800, 0x74); -#endif - eax &= 0xFFFF; - temp = eax; - eax += 0x3c; - temp1 = SiS_GetReg4((USHORT)eax); - temp1 &= 0xFEFF; - SiS_SetReg5((USHORT)eax, temp1); - temp1 = SiS_GetReg4((USHORT)eax); - eax = temp; - eax += 0x3a; - temp1 = SiS_GetReg4((USHORT)eax); - temp1 &= 0xFEFF; - if(!(myvbinfo & SetCRT2ToTV)) { - temp1 |= 0x0100; + tempah = infoflag >> 8; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + tempah = SiS_Pr->SiS_LCDInfo; + } + } + tempah &= 0xC0; + + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + + tempah &= 0x3f; + tempah |= tempbl; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + + } else { /* 630 - 301 */ + + tempah = infoflag >> 8; + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + + } + +#endif /* SIS300 */ + + } else { + +#ifdef SIS315H /* ------- 315 series ------ */ + + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* 315 - 30xLV */ + + if(((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024)) || + ((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050))) { + tempah = infoflag >> 8; + } else { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + } + tempah &= 0xC0; + + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + + } else { /* 315 - 301, 301B */ + + tempah = infoflag >> 8; + if(!SiS_Pr->UseCustomMode) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + tempah = SiS_Pr->SiS_LCDInfo; + } + } + } + tempah &= 0xC0; + + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + + if(SiS_Pr->SiS_VBType & VB_NoLCD) { /* TEST, imitate BIOS bug */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tempah |= 0xc0; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + + } +#endif /* SIS315H */ + } } - SiS_SetReg5((USHORT)eax, temp1); - temp1 = SiS_GetReg4((USHORT)eax); } -void -SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) +/******** Set CRT2 FIFO on 300/630/730 *******/ +#ifdef SIS300 +static void +SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo, + PSIS_HW_INFO HwInfo) { - USHORT tempax=0,tempbx=0; - USHORT temp1=0,modeflag=0,tempcx=0; - USHORT StandTableIndex,CRT1Index; -#ifdef SIS315H - USHORT ResInfo,DisplayType,temp=0; - const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr = NULL; -#endif + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT temp,index; + USHORT modeidindex,refreshratetableindex; + USHORT VCLK=0,MCLK,colorth=0,data2=0; + USHORT tempal, tempah, tempbx, tempcl, tempax; + USHORT CRT1ModeNo,CRT2ModeNo; + USHORT SelectRate_backup; + ULONG data,eax; + const UCHAR LatencyFactor[] = { + 97, 88, 86, 79, 77, 00, /*; 64 bit BQ=2 */ + 00, 87, 85, 78, 76, 54, /*; 64 bit BQ=1 */ + 97, 88, 86, 79, 77, 00, /*; 128 bit BQ=2 */ + 00, 79, 77, 70, 68, 48, /*; 128 bit BQ=1 */ + 80, 72, 69, 63, 61, 00, /*; 64 bit BQ=2 */ + 00, 70, 68, 61, 59, 37, /*; 64 bit BQ=1 */ + 86, 77, 75, 68, 66, 00, /*; 128 bit BQ=2 */ + 00, 68, 66, 59, 57, 37 /*; 128 bit BQ=1 */ + }; + const UCHAR LatencyFactor730[] = { + 69, 63, 61, + 86, 79, 77, + 103, 96, 94, + 120,113,111, + 137,130,128, /* <-- last entry, data below */ + 137,130,128, /* to avoid using illegal values */ + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + }; + const UCHAR ThLowB[] = { + 81, 4, 72, 6, 88, 8,120,12, + 55, 4, 54, 6, 66, 8, 90,12, + 42, 4, 45, 6, 55, 8, 75,12 + }; + const UCHAR ThTiming[] = { + 1, 2, 2, 3, 0, 1, 1, 2 + }; - SiS_Pr->SiS_RVBHCMAX = 1; - SiS_Pr->SiS_RVBHCFACT = 1; + SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate; - if(ModeNo <= 0x13){ + if(!SiS_Pr->CRT1UsesCustomMode) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - StandTableIndex = SiS_GetModePtr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex); - tempax = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[0]; - tempbx = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[6]; - temp1 = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[7]; + CRT1ModeNo = SiS_Pr->SiS_CRT1Mode; /* get CRT1 ModeNo */ + SiS_SearchModeID(SiS_Pr, &CRT1ModeNo, &modeidindex); + SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); + SiS_Pr->SiS_SelectCRT2Rate = 0; + refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT1ModeNo, modeidindex, HwInfo); + + if(CRT1ModeNo >= 0x13) { + index = SiS_Pr->SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK; + index &= 0x3F; + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ + + colorth = SiS_GetColorDepth(SiS_Pr,CRT1ModeNo,modeidindex); /* Get colordepth */ + colorth >>= 1; + if(!colorth) colorth++; + } } else { - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ) { - -#ifdef SIS315H - temp = SiS_GetLVDSCRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,&ResInfo,&DisplayType); - - if(temp == 0) return; - - switch(DisplayType) { - case 0 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1; break; - case 1 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; - case 2 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1; break; - case 3 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1_H; break; - case 4 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1_H; break; - case 5 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1_H; break; - case 6 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2; break; - case 7 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2; break; - case 8 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2; break; - case 9 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2_H; break; - case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2_H; break; - case 11: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2_H; break; - case 12: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1; break; - case 13: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H; break; - case 14: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1; break; - case 15: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1_H; break; - case 16: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2; break; - case 17: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2_H; break; - case 18: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UNTSC; break; - case 19: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1ONTSC; break; - case 20: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UPAL; break; - case 21: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break; - case 22: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x480_1; break; - case 23: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1; break; - case 24: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1_H; break; - case 25: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2; break; - case 26: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2_H; break; - case 27: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1; break; - case 28: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1_H; break; - case 29: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2; break; - case 30: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2_H; break; - case 36: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1; break; - case 37: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1_H; break; - case 38: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2; break; - case 39: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2_H; break; - case 99: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break; - default: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; - } - tempax = (LVDSCRT1Ptr+ResInfo)->CR[0]; - tempax |= (LVDSCRT1Ptr+ResInfo)->CR[14] << 8; - tempax &= 0x03FF; - tempbx = (LVDSCRT1Ptr+ResInfo)->CR[6]; - tempcx = (LVDSCRT1Ptr+ResInfo)->CR[13] << 8; - tempcx &= 0x0100; - tempcx <<= 2; - tempbx |= tempcx; - temp1 = (LVDSCRT1Ptr+ResInfo)->CR[7]; -#endif + CRT1ModeNo = 0xfe; + VCLK = SiS_Pr->CSRClock_CRT1; /* Get VCLK */ + data2 = (SiS_Pr->CModeFlag_CRT1 & ModeInfoFlag) - 2; + switch(data2) { /* Get color depth */ + case 0 : colorth = 1; break; + case 1 : colorth = 1; break; + case 2 : colorth = 2; break; + case 3 : colorth = 2; break; + case 4 : colorth = 3; break; + case 5 : colorth = 4; break; + default: colorth = 2; + } + + } + if(CRT1ModeNo >= 0x13) { + if(HwInfo->jChipType == SIS_300) { + index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A); } else { + index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A); + } + index &= 0x07; + MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; -#if 0 /* Not any longer */ - if(HwDeviceExtension->jChipType < SIS_315H) CRT1Index &= 0x3F; -#endif - tempax = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[0]; - tempax |= SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14] << 8; - tempax &= 0x03FF; - tempbx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[6]; - tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13] << 8; - tempcx &= 0x0100; - tempcx <<= 2; - tempbx |= tempcx; - temp1 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7]; + data2 = (colorth * VCLK) / MCLK; + + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + temp = ((temp & 0x00FF) >> 6) << 1; + if(temp == 0) temp = 1; + temp <<= 2; + temp &= 0xff; + + data2 = temp - data2; + if((28 * 16) % data2) { + data2 = (28 * 16) / data2; + data2++; + } else { + data2 = (28 * 16) / data2; } - } + if(HwInfo->jChipType == SIS_300) { - if(temp1 & 0x01) tempbx |= 0x0100; - if(temp1 & 0x20) tempbx |= 0x0200; - - tempax += 5; + tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x18); + tempah &= 0x62; + tempah >>= 1; + tempal = tempah; + tempah >>= 3; + tempal |= tempah; + tempal &= 0x07; + tempcl = ThTiming[tempal]; + tempbx = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16); + tempbx >>= 6; + tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + tempah >>= 4; + tempah &= 0x0c; + tempbx |= tempah; + tempbx <<= 1; + tempal = ThLowB[tempbx + 1]; + tempal *= tempcl; + tempal += ThLowB[tempbx]; + data = tempal; - /* Charx8Dot is no more used (and assumed), so we set it */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - modeflag |= Charx8Dot; - } + } else if(HwInfo->jChipType == SIS_730) { - if(modeflag & Charx8Dot) tempax *= 8; - else tempax *= 9; +#ifndef LINUX_XF86 + SiS_SetRegLong(0xcf8,0x80000050); + eax = SiS_GetRegLong(0xcfc); +#else + eax = pciReadLong(0x00000000, 0x50); +#endif + tempal = (USHORT)(eax >> 8); + tempal &= 0x06; + tempal <<= 5; - /* TW: From 650/30xLV 1.10.6s */ - if(modeflag & HalfDCLK) tempax <<= 1; +#ifndef LINUX_XF86 + SiS_SetRegLong(0xcf8,0x800000A0); + eax = SiS_GetRegLong(0xcfc); +#else + eax = pciReadLong(0x00000000, 0xA0); +#endif + temp = (USHORT)(eax >> 28); + temp &= 0x0F; + tempal |= temp; - SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; - tempbx++; - SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = tempbx; -} + tempbx = tempal; /* BIOS BUG (2.04.5d, 2.04.6a use ah here, which is unset!) */ + tempbx = 0; /* -- do it like the BIOS anyway... */ + tempax = tempbx; + tempbx &= 0xc0; + tempbx >>= 6; + tempax &= 0x0f; + tempax *= 3; + tempbx += tempax; -void -SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr) -{ - if(HwDeviceExtension->jChipType >= SIS_315H) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2f,0x01); - else - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01); -} + data = LatencyFactor730[tempbx]; + data += 15; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + if(!(temp & 0x80)) data += 5; -void -SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr) -{ - if(HwDeviceExtension->jChipType >= SIS_315H) - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2F,0xFE); - else - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x24,0xFE); -} + } else { -void -SiS_EnableCRT2(SiS_Private *SiS_Pr) -{ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); -} + index = 0; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + if(temp & 0x0080) index += 12; -/* Checked against all BIOSes */ -void -SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT tempah,pushax=0,modenum; +#ifndef LINUX_XF86 + SiS_SetRegLong(0xcf8,0x800000A0); + eax = SiS_GetRegLong(0xcfc); +#else + /* We use pci functions X offers. We use tag 0, because + * we want to read/write to the host bridge (which is always + * 00:00.0 on 630, 730 and 540), not the VGA device. + */ + eax = pciReadLong(0x00000000, 0xA0); #endif - USHORT temp=0; - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; + temp = (USHORT)(eax >> 24); + if(!(temp&0x01)) index += 24; - if (SiS_Pr->SiS_IF_DEF_LVDS == 0) { +#ifndef LINUX_XF86 + SiS_SetRegLong(0xcf8,0x80000050); + eax = SiS_GetRegLong(0xcfc); +#else + eax = pciReadLong(0x00000000, 0x50); +#endif + temp=(USHORT)(eax >> 24); + if(temp & 0x01) index += 6; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ===== TW: For 30xB/LV ===== */ + temp = (temp & 0x0F) >> 1; + index += temp; - if(HwDeviceExtension->jChipType < SIS_315H) { + data = LatencyFactor[index]; + data += 15; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + if(!(temp & 0x80)) data += 5; + } -#ifdef SIS300 /* 300 series */ + data += data2; /* CRT1 Request Period */ - if(HwDeviceExtension->jChipType == SIS_300) { /* New for 300+301LV */ + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - } - } - if(SiS_Is301B(SiS_Pr,BaseAddr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0x3f); - SiS_ShortDelay(SiS_Pr,1); - } - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); - SiS_DisplayOff(SiS_Pr); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - if( (!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) || - (!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) ) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xFB,0x04); - } + if(!SiS_Pr->UseCustomMode) { - } else { + CRT2ModeNo = ModeNo; + SiS_SearchModeID(SiS_Pr, &CRT2ModeNo, &modeidindex); - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - } - if(SiS_Is301B(SiS_Pr,BaseAddr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0x3f); - SiS_ShortDelay(SiS_Pr,1); - } - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); - SiS_DisplayOff(SiS_Pr); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); - if( (!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) || - (!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) ) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xFB,0x04); - } - } + refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT2ModeNo, modeidindex, HwInfo); -#endif /* SIS300 */ + index = SiS_GetVCLK2Ptr(SiS_Pr,CRT2ModeNo,modeidindex, + refreshratetableindex,HwInfo); + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ - } else { + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + if(ROMAddr[0x220] & 0x01) { + VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8); + } + } + } -#ifdef SIS315H /* 310/325 series */ + } else { - if(IS_SIS650740) { /* 650, 740 */ + CRT2ModeNo = 0xfe; + VCLK = SiS_Pr->CSRClock; /* Get VCLK */ -#if 0 - if(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00) != 1) return; /* From 1.10.7w */ -#endif + } - modenum = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34); + colorth = SiS_GetColorDepth(SiS_Pr,CRT2ModeNo,modeidindex); /* Get colordepth */ + colorth >>= 1; + if(!colorth) colorth++; - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - - if( (modenum <= 0x13) || - (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) || - (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00); - } - SiS_DDC2Delay(SiS_Pr,0xff00); - SiS_DDC2Delay(SiS_Pr,0x6000); - SiS_DDC2Delay(SiS_Pr,0x8000); - - SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00); - - pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06); - - if(IS_SIS740) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); - } + data = data * VCLK * colorth; + if(data % (MCLK << 4)) { + data = data / (MCLK << 4); + data++; + } else { + data = data / (MCLK << 4); + } - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - - if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) { - tempah = 0xef; - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - tempah = 0xf7; - } - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); - } + if(data <= 6) data = 6; + if(data > 0x14) data = 0x14; - } + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x01); + if(HwInfo->jChipType == SIS_300) { + if(data <= 0x0f) temp = (temp & (~0x1F)) | 0x13; + else temp = (temp & (~0x1F)) | 0x16; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + temp = (temp & (~0x1F)) | 0x13; + } + } else { + if( ( (HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730) ) && + (HwInfo->jChipRevision >= 0x30) ) /* 630s or 730(s?) */ + { + temp = (temp & (~0x1F)) | 0x1b; + } else { + temp = (temp & (~0x1F)) | 0x16; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0xe0,temp); - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { - tempah = 0x3f; - if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) { - tempah = 0x7f; - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - tempah = 0xbf; - } - } - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); - } + if( (HwInfo->jChipType == SIS_630) && + (HwInfo->jChipRevision >= 0x30) ) /* 630s, NOT 730 */ + { + if(data > 0x13) data = 0x13; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,0xe0,data); - if((SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) { + } else { /* If mode <= 0x13, we just restore everything */ - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF); - SiS_DisplayOff(SiS_Pr); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - } else { - SiS_DisplayOff(SiS_Pr); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF); - if((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13)) { - SiS_DisplayOff(SiS_Pr); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp); - } - } + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; - } else { + } +} +#endif - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf); - SiS_DisplayOff(SiS_Pr); - } - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp); - } else { - SiS_DisplayOff(SiS_Pr); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp); - } +/**** Set CRT2 FIFO on 315/330 series ****/ +#ifdef SIS315H +static void +SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr) +{ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,0x3B); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,~0x3F,0x04); +} +#endif - } +/*************** Set LCD-A ***************/ +#ifdef SIS315H +static void +SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) +{ + USHORT modeflag,resinfo; + USHORT push2,tempax,tempbx,tempcx,temp; + ULONG tempeax=0,tempebx,tempecx,tempvcfact; - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + /* This is not supported with LCDA */ + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return; + if(SiS_Pr->UseCustomMode) return; - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,~0x10); /* 1.10.8r */ - - tempah = 0x3f; - if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) { - tempah = 0x7f; - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - tempah = 0xbf; - } - } - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); + if(IS_SIS330) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); /* Xabre 1.01.03 */ + } else if(IS_SIS740) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 740/LVDS */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04); /* 740/LVDS */ + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x03); + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); /* 740/301LV, 301BDH */ + } + } else { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 650/LVDS */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04); /* 650/LVDS */ + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x00); /* 650/LVDS 1.10.07 */ + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2D,0x0f); /* 650/30xLv 1.10.6s */ + } + } - if(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr)) { /* 1.10.8r */ - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); - } /* 1.10.8r */ + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf); - } + tempax = SiS_Pr->SiS_LCDHDES; - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) { - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFD,0x00); - } - } - } + temp = (tempax & 0x0007); /* BPLHDESKEW[2:0] */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* Part1_1Ah */ + temp = (tempax >> 3) & 0x00FF; /* BPLHDESKEW[10:3] */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* Part1_16h */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax); + tempbx = SiS_Pr->SiS_HDE; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempbx = SiS_Pr->PanelXRes; + } - } + tempax += tempbx; /* HDE + HSKEW = lcdhdee */ + if(tempax >= SiS_Pr->SiS_HT) tempax -= SiS_Pr->SiS_HT; -#if 0 - } else if(IS_SIS740) { /* 740 */ - - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* 30xLV */ - - if( (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) || - (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00); - } - - SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00); + temp = tempax; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(temp & 0x07) temp += 8; + } + temp >>= 3; /* BPLHDEE */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* Part1_17h */ - pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06); - - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); - - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_DisplayOff(SiS_Pr); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF); - } else { - SiS_DisplayOff(SiS_Pr); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp); - } - - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,0x3F); - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,0xEF); /* (from 650) */ - - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); - - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf); - } - - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) { - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFD,0x00); - } - } - } - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax); - - } else { /* (301,) 301B */ - - if(SiS_Is301B(SiS_Pr,BaseAddr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,0x3F); - } - - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); - SiS_DisplayOff(SiS_Pr); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + tempcx = (SiS_Pr->SiS_HT - tempbx) >> 2; /* (HT-HDE) / 4 */ - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp); - - } -#endif - } else { /* 315, 330 - all bridge types */ + /* 650/30xLV 1.10.6s, 740/LVDS */ + if( ((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) || + ((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) ) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x28; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempcx = 0x18; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x30; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x40; + else tempcx = 0x30; + } + } - if(SiS_Is301B(SiS_Pr,BaseAddr)) { - tempah = 0x3f; - if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) { - tempah = 0x7f; - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - tempah = 0xbf; - } - } - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_DisplayOff(SiS_Pr); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - } - } - if( (!(SiS_Is301B(SiS_Pr,BaseAddr))) || - (!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) ) { + tempcx += tempax; /* lcdhrs */ + if(tempcx >= SiS_Pr->SiS_HT) tempcx -= SiS_Pr->SiS_HT; - if( (!(SiS_Is301B(SiS_Pr,BaseAddr))) || - (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) ) { + temp = (tempcx >> 3) & 0x00FF; /* BPLHRS */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,temp); /* Part1_14h */ - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); - SiS_DisplayOff(SiS_Pr); + temp += 10; + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + temp += 6; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) { + temp++; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1024x768) { + temp += 7; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) { + temp -= 10; + } + } + } + } + } + } + temp &= 0x1F; + temp |= ((tempcx & 0x07) << 5); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,temp); /* Part1_15h */ - } + if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { + tempax = SiS_Pr->PanelYRes; + } else { + tempax = SiS_Pr->SiS_VGAVDE; + } - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + tempbx = SiS_Pr->SiS_LCDVDES + tempax; + if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; + push2 = tempbx; - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + tempcx = (SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 2; - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp); + if( ((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) || + ((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) ) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 1; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempcx = 3; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 3; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 1; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 1; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 1; + else tempcx = 0x0057; + } + } - } + tempbx += tempcx; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + tempbx++; /* BPLVRS */ + } + if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); /* Part1_18h */ - } /* 315/330 */ + tempcx >>= 3; + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 3; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempcx = 5; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 5; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 5; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 2; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 2; + } + } + } + tempcx += tempbx; + tempcx++; /* BPLVRE */ + temp = tempcx & 0x000F; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp |= 0xC0; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp); /* Part1_19h */ + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp); + } -#endif /* SIS315H */ + temp = ((tempbx >> 8) & 0x07) << 3; + if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40; + if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + /* Don't check Part1Port,0x00 -> is not being set if LCDA! */ + /* We check SR06 instead here: */ + if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x10) temp |= 0x80; + } + } else { + if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) temp |= 0x80; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x07,temp); /* Part1_1Ah */ - } + tempbx = push2; /* BPLVDEE */ - } else { /* ============ TW: For 301 ================ */ + tempcx = SiS_Pr->SiS_LCDVDES; /* NPLVDES */ + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { + if(resinfo == SIS_RI_800x600) tempcx++; + } + } + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { + tempbx = tempcx = SiS_Pr->SiS_VGAVDE; + tempbx--; + } - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF0,0x0B); - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 1); - } - } + temp = ((tempbx >> 8) & 0x07) << 3; + temp = temp | ((tempcx >> 8) & 0x07); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1D,temp); /* Part1_1Dh */ + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1C,temp); /* Part1_1Ch */ + temp = tempcx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1B,temp); /* Part1_1Bh */ - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */ - SiS_DisplayOff(SiS_Pr); + tempeax = SiS_Pr->SiS_VGAVDE << 18; + tempebx = SiS_Pr->SiS_VDE; + temp = (USHORT)(tempeax % tempebx); + tempeax = tempeax / tempebx; + if(temp) tempeax++; + tempvcfact = tempeax; - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - } + temp = (USHORT)(tempeax & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,temp); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */ + temp = (USHORT)((tempeax & 0x00FF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,temp); - if(HwDeviceExtension->jChipType >= SIS_315H) { - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp); - } else { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */ - } + temp = (USHORT)((tempeax & 0x00030000) >> 16); + if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,temp); - } + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) { + temp = (USHORT)(tempeax & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3c,temp); + temp = (USHORT)((tempeax & 0x00FF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3b,temp); + temp = (USHORT)(((tempeax & 0x00030000) >> 16) << 6); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0x3f,temp); + temp = 0; + if(SiS_Pr->SiS_VDE != SiS_Pr->SiS_VGAVDE) temp |= 0x08; + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x30,0xf3,temp); + } - } else { /* ============ TW: For LVDS =============*/ + tempeax = SiS_Pr->SiS_VGAHDE << 16; + tempebx = SiS_Pr->SiS_HDE; + temp = tempeax % tempebx; + tempeax /= tempebx; + if(temp) tempeax++; + if(tempebx == SiS_Pr->SiS_VGAHDE) tempeax = 0xFFFF; + tempecx = tempeax; + tempeax = ((SiS_Pr->SiS_VGAHDE << 16) / tempecx) - 1; + tempecx = (tempecx << 16) | (tempeax & 0xFFFF); + temp = (USHORT)(tempecx & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1F,temp); /* Part1_1Fh */ - if(HwDeviceExtension->jChipType < SIS_315H) { + tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact; + tempbx = (USHORT)(tempeax & 0x0FFFF); -#ifdef SIS300 /* 300 series */ + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx--; - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - SiS_SetCH700x(SiS_Pr,0x090E); - } + if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempbx = 1; - if(HwDeviceExtension->jChipType == SIS_730) { - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - } - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - } - } else { - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { + temp = ((tempbx >> 8) & 0x07) << 3; + temp = temp | ((tempecx >> 8) & 0x07); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x20,temp); /* Part1_20h */ - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { - - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x21,temp); /* Part1_21h */ - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); + tempecx >>= 16; /* BPLHCFACT */ + if(modeflag & HalfDCLK) tempecx >>= 1; + temp = (USHORT)((tempecx & 0x0000FF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x22,temp); /* Part1_22h */ - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) { - SiS_DisplayOff(SiS_Pr); - } + temp = (USHORT)(tempecx & 0x000000FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - } - } - } - } + if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBInfo & VB_SIS301LV302LV)) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x20); + } +} +#endif /* SIS 315 */ - SiS_DisplayOff(SiS_Pr); +static USHORT +SiS_GetVGAHT2(SiS_Private *SiS_Pr) +{ + ULONG tempax,tempbx; - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + tempbx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) * SiS_Pr->SiS_RVBHCMAX) & 0xFFFF; + tempax = (SiS_Pr->SiS_VT - SiS_Pr->SiS_VDE) * SiS_Pr->SiS_RVBHCFACT; + tempax = (tempax * SiS_Pr->SiS_HT) / tempbx; + return((USHORT) tempax); +} - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); +/******* Set Part 1 / SiS bridge *********/ +static void +SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo,USHORT RefreshRateTableIndex) +{ + USHORT push1,push2; + USHORT tempax,tempbx,tempcx,temp; + USHORT resinfo,modeflag; + unsigned char p1_7, p1_8; - if( (!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) || - (!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) ) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xFB,0x04); - } + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + } else { + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + resinfo = 0; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } + } -#endif /* SIS300 */ + /* The following is only done if bridge is in slave mode: */ - } else { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0xff); /* set MAX HT */ -#ifdef SIS315H /* 310/325 series */ + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) modeflag |= Charx8Dot; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - temp = SiS_GetCH701x(SiS_Pr,0x61); - if(temp < 1) { - SiS_SetCH701x(SiS_Pr,0xac76); - SiS_SetCH701x(SiS_Pr,0x0066); - } - - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetCH701x(SiS_Pr,0x3e49); - } else if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetCH701x(SiS_Pr,0x3e49); - } - - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_Chrontel701xBLOff(SiS_Pr); - SiS_Chrontel701xOff(SiS_Pr); - } else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_Chrontel701xBLOff(SiS_Pr); - SiS_Chrontel701xOff(SiS_Pr); - } - - } + if(modeflag & Charx8Dot) tempcx = 0x08; + else tempcx = 0x09; - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - } + tempax = SiS_Pr->SiS_VGAHDE; /* 0x04 Horizontal Display End */ + if(modeflag & HalfDCLK) tempax >>= 1; + tempax = ((tempax / tempcx) - 1) & 0xff; + tempbx = tempax; - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - SiS_DisplayOff(SiS_Pr); - } else if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_DisplayOff(SiS_Pr); - } else if(!(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_DisplayOff(SiS_Pr); - } + temp = tempax; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x04,temp); - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - } else if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - } else if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { + temp += 2; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + if(resinfo == SIS_RI_800x600) temp -= 2; + } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x05,temp); /* 0x05 Horizontal Display Start */ - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x06,0x03); /* 0x06 Horizontal Blank end */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - } else if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - } else if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - } + tempax = 0xFFFF; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempax = SiS_GetVGAHT2(SiS_Pr); + if(tempax >= SiS_Pr->SiS_VGAHT) tempax = SiS_Pr->SiS_VGAHT; + if(modeflag & HalfDCLK) tempax >>= 1; + tempax = (tempax / tempcx) - 5; + tempcx = tempax; - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, BaseAddr,HwDeviceExtension)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); - } - } else if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + temp = tempcx - 1; + if(!(modeflag & HalfDCLK)) { + temp -= 6; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + temp -= 2; + if(ModeNo > 0x13) temp -= 10; + } + } + } else { + tempcx = (tempcx + tempbx) >> 1; + temp = (tempcx & 0x00FF) + 2; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + temp--; + if(!(modeflag & HalfDCLK)) { + if((modeflag & Charx8Dot)) { + temp += 4; + if(SiS_Pr->SiS_VGAHDE >= 800) temp -= 6; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VGAHDE == 800) temp += 2; + } + } + } + } else { + if(!(modeflag & HalfDCLK)) { + temp -= 4; + if((SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) && + (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200)) { + if(SiS_Pr->SiS_VGAHDE >= 800) { + temp -= 7; + if(HwInfo->jChipType < SIS_315H) { + /* 650/301LV(x) does not do this, 630/301B, 300/301LV do */ + if(SiS_Pr->SiS_ModeType == ModeEGA) { + if(SiS_Pr->SiS_VGAVDE == 1024) { + temp += 15; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) + temp += 7; + } + } + } + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) { + if(SiS_Pr->SiS_VGAHDE >= 1280) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) temp += 28; + } + } + } + } + } + } + } - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xff); - } else { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); - } - } + p1_7 = temp; + p1_8 = 0x00; - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + if(ModeNo <= 0x01) { + p1_7 = 0x2a; + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) p1_8 = 0x61; + else p1_8 = 0x41; + } else if(SiS_Pr->SiS_ModeType == ModeText) { + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) p1_7 = 0x54; + else p1_7 = 0x55; + p1_8 = 0x00; + } else if(ModeNo <= 0x13) { + if(modeflag & HalfDCLK) { + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + p1_7 = 0x30; + p1_8 = 0x03; + } else { + p1_7 = 0x2f; + p1_8 = 0x02; + } + } else { + p1_7 = 0x5b; + p1_8 = 0x03; + } + } else if( ((HwInfo->jChipType >= SIS_315H) && + ((ModeNo == 0x50) || (ModeNo == 0x56) || (ModeNo == 0x53))) || + ((HwInfo->jChipType < SIS_315H) && + (resinfo == SIS_RI_320x200 || resinfo == SIS_RI_320x240)) ) { + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + p1_7 = 0x30, + p1_8 = 0x03; + } else { + p1_7 = 0x2f; + p1_8 = 0x03; + } + } + } + } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); - } else if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); - } else if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p)) { + p1_7 = 0x63; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) p1_7 = 0x55; + } + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + if(!(modeflag & HalfDCLK)) { + p1_7 = 0xb2; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { + p1_7 = 0xab; + } } + } + } -#if 0 /* TW: BIOS code makes no sense */ - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { - /* Nothing there! */ - } - } - } -#endif - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, BaseAddr,HwDeviceExtension)) { - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xFB,0x04); - } - } - } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,p1_7); /* 0x07 Horizontal Retrace Start */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,p1_8); /* 0x08 Horizontal Retrace End */ -#endif /* SIS315H */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x03); /* 0x18 SR08 (FIFO Threshold?) */ - } /* 310 series */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x19,0xF0); - } /* LVDS */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,0xFF); /* 0x09 Set Max VT */ -} + tempcx = 0x121; + tempbx = SiS_Pr->SiS_VGAVDE; /* 0x0E Vertical Display End */ + if (tempbx == 357) tempbx = 350; + else if(tempbx == 360) tempbx = 350; + else if(tempbx == 375) tempbx = 350; + else if(tempbx == 405) tempbx = 400; + else if(tempbx == 420) tempbx = 400; + else if(tempbx == 525) tempbx = 480; + push2 = tempbx; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + if (tempbx == 350) tempbx += 5; + else if(tempbx == 480) tempbx += 5; + } + } + } + tempbx -= 2; + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp); /* 0x10 vertical Blank Start */ -/* TW: Checked against all BIOSes */ -void -SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ - USHORT temp=0,tempah; -#ifdef SIS315H - USHORT temp1,pushax=0; - BOOLEAN delaylong = FALSE; + tempbx = push2; + tempbx--; + temp = tempbx & 0x00FF; +#if 0 + /* Missing code from 630/301B 2.04.5a and 650/302LV 1.10.6s (calles int 2f) */ + if(xxx()) { + if(temp == 0xdf) temp = 0xda; + } #endif - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0E,temp); - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* TW: ====== For 301B et al ====== */ + temp = 0; + if(modeflag & DoubleScanMode) temp |= 0x80; + if(HwInfo->jChipType >= SIS_661) { + if(tempbx & 0x0200) temp |= 0x20; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x0B,0x5F,temp); + if(tempbx & 0x0100) tempcx |= 0x000a; + if(tempbx & 0x0400) tempcx |= 0x1200; + } else { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,temp); + if(tempbx & 0x0100) tempcx |= 0x0002; + if(tempbx & 0x0400) tempcx |= 0x0600; + } - if(HwDeviceExtension->jChipType < SIS_315H) { + if(tempbx & 0x0200) tempcx |= 0x0040; -#ifdef SIS300 /* 300 series */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x11,0x00); /* 0x11 Vertical Blank End */ - if(HwDeviceExtension->jChipType == SIS_300) { + tempax = (SiS_Pr->SiS_VGAVT - tempbx) >> 2; - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) { - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 0); - } - } - } - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ - if(SiS_BridgeInSlave(SiS_Pr)) { - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ - if(SiS_Is301B(SiS_Pr,BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0); - SiS_DisplayOn(SiS_Pr); - } else { - SiS_VBLongWait(SiS_Pr); - SiS_DisplayOn(SiS_Pr); - SiS_VBLongWait(SiS_Pr); - } - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1); - } - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfe,0x01); - } - } - } - } + if((ModeNo > 0x13) || (HwInfo->jChipType < SIS_315H)) { + if(resinfo != SIS_RI_1280x1024) { + tempbx += (tempax << 1); + } + } else if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) { + tempbx += (tempax << 1); + } + } - } else { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + tempbx -= 10; + } else { + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + tempbx += 40; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VGAHDE == 800) tempbx += 10; + } + } + } + } + tempax >>= 2; + tempax++; + tempax += tempbx; + push1 = tempax; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + if(tempbx <= 513) { + if(tempax >= 513) tempbx = 513; + } + } + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0C,temp); /* 0x0C Vertical Retrace Start */ - if((SiS_Pr->SiS_VBType & VB_NoLCD) && - (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) { - /* This is only for LCD output on 301B-DH via LVDS */ - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xFB); - if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) { - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 0); - } - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* Enable CRT2 */ -/* DoSomeThingPCI_On(SiS_Pr) */ - SiS_DisplayOn(SiS_Pr); - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); - if(SiS_BridgeInSlave(SiS_Pr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); - } - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1); - } - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x00); - } - } - } else { - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ - if(SiS_BridgeInSlave(SiS_Pr)) { - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ - if(SiS_Is301B(SiS_Pr,BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0); - SiS_DisplayOn(SiS_Pr); - } else { - SiS_VBLongWait(SiS_Pr); - SiS_DisplayOn(SiS_Pr); - SiS_VBLongWait(SiS_Pr); - } - } + tempbx--; + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp); - } -#endif /* SIS300 */ + if(tempbx & 0x0100) tempcx |= 0x0008; - } else { + if(tempbx & 0x0200) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20); + } + tempbx++; -#ifdef SIS315H /* 310/325 series */ + if(tempbx & 0x0100) tempcx |= 0x0004; + if(tempbx & 0x0200) tempcx |= 0x0080; + if(tempbx & 0x0400) { + if(HwInfo->jChipType >= SIS_661) tempcx |= 0x0800; + else if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x0800; + else tempcx |= 0x0C00; + } - if(IS_SIS650740) { /* 650 */ + tempbx = push1; + temp = tempbx & 0x000F; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,temp); /* 0x0D vertical Retrace End */ -#if 0 - if(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00) != 1) return; /* From 1.10.7w */ -#endif + if(tempbx & 0x0010) tempcx |= 0x2000; - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0xef); /* 1.10.7u */ - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); /* 1.10.7u */ - - if(!(IS_SIS740)) { - if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) { - tempah = 0x10; - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - tempah = 0x08; - } - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,tempah); - } - } + temp = tempcx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* 0x0A CR07 */ - SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00); - SiS_DisplayOff(SiS_Pr); - pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06); - if(IS_SIS740) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); - } + temp = (tempcx & 0xFF00) >> 8; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* 0x17 SR0A */ - if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) { - if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { - SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 2); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 2); - } - } + tempax = modeflag; + temp = (tempax & 0xFF00) >> 8; + temp = (temp >> 1) & 0x09; + if(!(SiS_Pr->SiS_VBType & VB_SIS301)) temp |= 0x01; /* Always 8 dotclock */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* 0x16 SR01 */ - if(!(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x40)) { - SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10); - delaylong = TRUE; - } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* 0x0F CR14 */ - } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,0x00); /* 0x12 CR17 */ - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF; - if(SiS_BridgeInSlave(SiS_Pr)) { - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); + temp = 0x00; + if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { + temp = 0x80; + } + } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* 0x1A SR0E */ +} - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ - - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2e); - if(!(temp & 0x80)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); - } - } else { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - } - } +/*********** Set Part 1 / LVDS ***********/ +static void +SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) +{ + USHORT modeflag, resinfo; + USHORT push1, push2, tempax, tempbx, tempcx, temp; +#ifdef SIS315H + USHORT pushcx; +#endif + ULONG tempeax=0, tempebx, tempecx, tempvcfact=0; - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x20); - } + /* This is not supported on LVDS */ + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return; + if(SiS_Pr->UseCustomMode) return; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2e); - if(!(temp & 0x80)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); - } - } + /* Set up Panel Link */ - tempah = 0xc0; - if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) { - tempah = 0x80; - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - tempah = 0x40; - } - } - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah); + /* 1. Horizontal setup */ - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); - } + tempax = SiS_Pr->SiS_LCDHDES; - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); /* All this from 1.10.7u */ - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x05); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x60); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); - - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1f,0x10); /* 1.10.8r */ - - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); - - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - ((SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) ) { - SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10); - if(delaylong) { - SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10); - } - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfe,0x01); - } - } + if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { + if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) && + (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) { + tempax -= 8; + } + } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax); - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff); + tempcx = SiS_Pr->SiS_HT; /* Horiz. Total */ - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); - } -#if 0 - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x05); /* 1.10.8r: 0x0d */ - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x60); /* 1.10.8r: 0x70 */ - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x00); /* 1.10.8r: 0x40 */ - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); -#endif + tempbx = SiS_Pr->SiS_HDE; /* Horiz. Display End */ - } + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) { + tempbx >>= 1; + } -#if 0 - } else if(IS_SIS740) { /* 740 */ - - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* 30xLV */ - - SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00); - SiS_DisplayOff(SiS_Pr); - pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); - - if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) { - if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - } + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) { + tempbx = SiS_Pr->PanelXRes; + } else if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + tempbx = SiS_Pr->PanelXRes; + if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { + tempbx = 800; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) { + tempbx = 1024; } - - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF; - if(SiS_BridgeInSlave(SiS_Pr)) { - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); + } + } + } + } + tempcx = (tempcx - tempbx) >> 2; /* HT-HDE / 4 */ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - } - - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); - } - - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0x10); /* (taken from 650 1.10.8r) */ - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); - - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) { - SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10); - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x40) { - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfe,0x01); - SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10); - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - } - } - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax); - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff); - - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); - } - - } else { /* (301), 301B */ - - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF; - if(SiS_BridgeInSlave(SiS_Pr)) { - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); + push1 = tempax; - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ + tempax += tempbx; - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E); - if(!(temp & 0x80)) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); - } + if(tempax >= SiS_Pr->SiS_HT) tempax -= SiS_Pr->SiS_HT; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); + push2 = tempax; - if(SiS_Is301B(SiS_Pr,BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); - } else { - SiS_VBLongWait(SiS_Pr); - SiS_DisplayOn(SiS_Pr); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7F); - SiS_VBLongWait(SiS_Pr); + if((!SiS_Pr->SiS_IF_DEF_FSTN) && + (!SiS_Pr->SiS_IF_DEF_DSTN) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1366) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1024) && + (SiS_Pr->SiS_CustomT != CUT_PANEL848)) { + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x0028; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempcx = 0x0018; + else if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) ) { + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + tempcx = 0x0017; /* A901; sometimes 0x0018; */ + } else { + tempcx = 0x0017; +#ifdef TWNEWPANEL + tempcx = 0x0018; +#endif + } + } else { + tempcx = 0x0018; + } } - + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 0x0028; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0030; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0030; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0040; } -#endif - - } else { /* 315, 330 */ + } + } + } - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF; - if(SiS_BridgeInSlave(SiS_Pr)) { - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); + tempcx += tempax; /* lcdhrs */ + if(tempcx >= SiS_Pr->SiS_HT) tempcx -= SiS_Pr->SiS_HT; - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ + tempax = tempcx >> 3; /* BPLHRS */ + temp = tempax & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,temp); /* Part1_14h; Panel Link Horizontal Retrace Start */ - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E); - if(!(temp & 0x80)) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + temp = (tempax & 0x00FF) + 2; + } else { + temp = (tempax & 0x00FF) + 10; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if((!SiS_Pr->SiS_IF_DEF_DSTN) && + (!SiS_Pr->SiS_IF_DEF_FSTN) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1366) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1024) && + (SiS_Pr->SiS_CustomT != CUT_PANEL848)) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + temp += 6; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) { + temp++; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1024x768) { + temp += 7; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) { + temp -= 0x14; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x768) { + temp -= 10; + } + } + } + } + } } + } + } + } - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); - - if(SiS_Is301B(SiS_Pr,BaseAddr)) { - - temp=SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E); - if (!(temp & 0x80)) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + temp &= 0x1F; + temp |= ((tempcx & 0x0007) << 5); +#if 0 + if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0x20; /* WRONG? BIOS loads cl, not ah */ +#endif + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,temp); /* Part1_15h; Panel Link Horizontal Retrace End/Skew */ - tempah = 0xc0; - if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) { - tempah = 0x80; - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - tempah = 0x40; - } - } - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah); + tempbx = push2; + tempcx = push1; /* lcdhdes */ - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + temp = (tempcx & 0x0007); /* BPLHDESKEW */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* Part1_1Ah; Panel Link Vertical Retrace Start (2:0) */ - } else { - - SiS_VBLongWait(SiS_Pr); - SiS_DisplayOn(SiS_Pr); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7F); - SiS_VBLongWait(SiS_Pr); + tempcx >>= 3; /* BPLHDES */ + temp = (tempcx & 0x00FF); +#if 0 /* Not 550 FSTN */ + if(HwInfo->jChipType >= SIS_315H) { + if(ModeNo == 0x5b) temp--; */ + } +#endif + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* Part1_16h; Panel Link Horizontal Display Enable Start */ - } + if((HwInfo->jChipType < SIS_315H) || + (SiS_Pr->SiS_IF_DEF_FSTN) || + (SiS_Pr->SiS_IF_DEF_DSTN)) { + if(tempbx & 0x07) tempbx += 8; + } + tempbx >>= 3; /* BPLHDEE */ + temp = tempbx & 0x00FF; +#if 0 /* Not 550 FSTN */ + if(HwInfo->jChipType >= SIS_315H) { + if(ModeNo == 0x5b) temp--; + } +#endif + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* Part1_17h; Panel Link Horizontal Display Enable End */ - } /* 315, 330 */ + /* 2. Vertical setup */ -#endif /* SIS315H */ + if(HwInfo->jChipType < SIS_315H) { + tempcx = SiS_Pr->SiS_VGAVT; + tempbx = SiS_Pr->SiS_VGAVDE; + if((SiS_Pr->SiS_CustomT != CUT_BARCO1366) && (SiS_Pr->SiS_CustomT != CUT_BARCO1024)) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + tempbx = SiS_Pr->PanelYRes; + } + } + } + tempcx -= tempbx; - } + } else { - } else { /* ============ TW: For 301 ================ */ + tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE; /* VGAVT-VGAVDE */ - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF0,0x0B); - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 0); - } - } + } - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ - if(SiS_BridgeInSlave(SiS_Pr)) { - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); + tempbx = SiS_Pr->SiS_LCDVDES; /* VGAVDES */ + push1 = tempbx; - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ + tempax = SiS_Pr->SiS_VGAVDE; - if(HwDeviceExtension->jChipType >= SIS_315H) { - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E); - if(!(temp & 0x80)) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); /* BVBDOENABLE=1 */ - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + tempax = 600; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) { + tempax = 768; + } + } + } else if( (SiS_Pr->SiS_IF_DEF_TRUMPION == 0) && + (!(SiS_Pr->SiS_LCDInfo & LCDPass11)) && + ((SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) || + (SiS_Pr->SiS_IF_DEF_FSTN) || + (SiS_Pr->SiS_IF_DEF_DSTN)) ) { + tempax = SiS_Pr->PanelYRes; + } + } - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ + tempbx += tempax; + if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; - SiS_VBLongWait(SiS_Pr); - SiS_DisplayOn(SiS_Pr); - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); - } - SiS_VBLongWait(SiS_Pr); + push2 = tempbx; - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 1); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF0,0x03); - } - } + tempcx >>= 1; - } + if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && + (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1366) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1024) && + (SiS_Pr->SiS_CustomT != CUT_PANEL848)) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) { + tempcx = 0x0017; + } else if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x0003; + else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768)) tempcx = 0x0003; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0001; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0001; + else tempcx = 0x0057; + } else { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x0001; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempcx = 0x0001; + else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768)) { + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + tempcx = 0x0002; /* A901; sometimes 0x0003; */ + } else { + tempcx = 0x0002; +#ifdef TWNEWPANEL + tempcx = 0x0003; +#endif + } + } else tempcx = 0x0003; + } + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 0x0003; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0001; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0001; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0001; + else tempcx = 0x0057; + } + } + } - } else { /* =================== TW: For LVDS ================== */ + tempbx += tempcx; /* BPLVRS */ - if(HwDeviceExtension->jChipType < SIS_315H) { + if((HwInfo->jChipType < SIS_315H) || + (SiS_Pr->SiS_IF_DEF_FSTN) || + (SiS_Pr->SiS_IF_DEF_DSTN)) { + tempbx++; + } -#ifdef SIS300 /* 300 series */ + if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - if(HwDeviceExtension->jChipType == SIS_730) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1); - } - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xFB); - if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 0); - } - } + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); /* Part1_18h; Panel Link Vertical Retrace Start */ - SiS_EnableCRT2(SiS_Pr); - SiS_DisplayOn(SiS_Pr); - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); - if(SiS_BridgeInSlave(SiS_Pr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); - } + tempcx >>= 3; - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) { - SiS_SetCH700x(SiS_Pr,0x0B0E); + if((!(SiS_Pr->SiS_LCDInfo & LCDPass11)) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1366) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1024) && + (SiS_Pr->SiS_CustomT != CUT_PANEL848)) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if( (HwInfo->jChipType < SIS_315H) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) ) tempcx = 0x0001; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2) tempcx = 0x0002; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempcx = 0x0002; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x0003; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempcx = 0x0005; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) tempcx = 0x0005; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 0x0011; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0005; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0002; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0011; + else if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + tempcx = 0x0004; /* A901; Other BIOS sets 0x0005; */ + } else { + tempcx = 0x0004; +#ifdef TWNEWPANEL + tempcx = 0x0005; +#endif + } + } else { + tempcx = 0x0005; + } } - } - - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1); - } - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xF7); - } - } - } + } + } -#endif /* SIS300 */ + tempcx = tempcx + tempbx + 1; /* BPLVRE */ + temp = tempcx & 0x000F; + if(SiS_Pr->SiS_IF_DEF_FSTN || + SiS_Pr->SiS_IF_DEF_DSTN || + (SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || + (SiS_Pr->SiS_CustomT == CUT_PANEL848)) { + temp |= 0x30; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xf0,temp); /* Part1_19h; Panel Link Vertical Retrace End (3:0); Misc. */ - } else { + temp = ((tempbx & 0x0700) >> 8) << 3; /* BPLDESKEW =0 */ + if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) { + if(SiS_Pr->SiS_HDE != 640) { + if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40; + } + } else if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40; + if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40; + if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { + temp |= 0x80; + } + } else { + if( (HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730) ) { + if(HwInfo->jChipRevision >= 0x30) { + temp |= 0x80; + } + } + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x87,temp); /* Part1_1Ah; Panel Link Control Signal (7:3); Vertical Retrace Start (2:0) */ -#ifdef SIS315H /* 310/325 series */ + if (HwInfo->jChipType < SIS_315H) { -#if 0 /* BIOS code makes no sense */ - if(SiS_IsVAMode()) { - if(SiS_IsLCDOrLCDA()) { - } - } -#endif +#ifdef SIS300 /* 300 series */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xFB); - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 0); - } - } + tempeax = SiS_Pr->SiS_VGAVDE << 6; + temp = (USHORT)(tempeax % (ULONG)SiS_Pr->SiS_VDE); + tempeax = tempeax / (ULONG)SiS_Pr->SiS_VDE; + if(temp != 0) tempeax++; + tempebx = tempeax; /* BPLVCFACT */ - SiS_EnableCRT2(SiS_Pr); - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); + if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) { + tempebx = 0x003F; + } - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); + temp = (USHORT)(tempebx & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1E,temp); /* Part1_1Eh; Panel Link Vertical Scaling Factor */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp &= 0x20; - SiS_Chrontel701xBLOff(SiS_Pr); - } +#endif /* SIS300 */ - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); - -#ifdef NEWCH701x - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension,BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); - } - } -#endif + } else { - temp1 = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E); - if (!(temp1 & 0x80)) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); +#ifdef SIS315H /* 315 series */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(temp) { - SiS_Chrontel701xBLOn(SiS_Pr); - } - } + if(HwInfo->jChipType == SIS_740) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x03); + } else { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1E,0x23); + } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); - } - } -#ifndef NEWCH701x - else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); - } -#endif + tempeax = SiS_Pr->SiS_VGAVDE << 18; + temp = (USHORT)(tempeax % (ULONG)SiS_Pr->SiS_VDE); + tempeax = tempeax / SiS_Pr->SiS_VDE; + if(temp != 0) tempeax++; + tempebx = tempeax; /* BPLVCFACT */ + tempvcfact = tempeax; + temp = (USHORT)(tempebx & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,temp); /* Part1_37h; Panel Link Vertical Scaling Factor */ + temp = (USHORT)((tempebx & 0x00FF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,temp); /* Part1_36h; Panel Link Vertical Scaling Factor */ + temp = (USHORT)((tempebx & 0x00030000) >> 16); + temp &= 0x03; + if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,temp); /* Part1_35h; Panel Link Vertical Scaling Factor */ - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); - } +#endif /* SIS315H */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + } - if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_Chrontel701xOn(SiS_Pr,HwDeviceExtension, BaseAddr); - } - - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_ChrontelDoSomething1(SiS_Pr,HwDeviceExtension, BaseAddr); - } else if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_ChrontelDoSomething1(SiS_Pr,HwDeviceExtension, BaseAddr); - } + tempbx = push2; /* BPLVDEE */ + tempcx = push1; - } + push1 = temp; - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_Chrontel701xBLOn(SiS_Pr); - SiS_ChrontelDoSomething4(SiS_Pr,HwDeviceExtension, BaseAddr); - } else if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_Chrontel701xBLOn(SiS_Pr); - SiS_ChrontelDoSomething4(SiS_Pr,HwDeviceExtension, BaseAddr); - } - } - } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 1); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xF7); + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(!SiS_Pr->SiS_IF_DEF_FSTN && !SiS_Pr->SiS_IF_DEF_DSTN) { + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { + if(resinfo == SIS_RI_1024x600) tempcx++; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(resinfo == SIS_RI_800x600) tempcx++; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { + if(resinfo == SIS_RI_800x600) tempcx++; + if(resinfo == SIS_RI_1024x768) tempcx++; /* Doesnt make sense anyway... */ + } else if(resinfo == SIS_RI_1024x768) tempcx++; + } else { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { + if(resinfo == SIS_RI_800x600) tempcx++; } } - } + } + } -#endif /* SIS315H */ + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { + if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { + tempcx = SiS_Pr->SiS_VGAVDE; + tempbx = SiS_Pr->SiS_VGAVDE - 1; + } + } - } /* 310 series */ + temp = ((tempbx & 0x0700) >> 8) << 3; + temp |= ((tempcx & 0x0700) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1D,temp); /* Part1_1Dh; Vertical Display Overflow; Control Signal */ - } /* LVDS */ + temp = tempbx & 0x00FF; + /* if(SiS_Pr->SiS_IF_DEF_FSTN) temp++; */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1C,temp); /* Part1_1Ch; Panel Link Vertical Display Enable End */ -} + temp = tempcx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1B,temp); /* Part1_1Bh; Panel Link Vertical Display Enable Start */ -void -SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; + /* 3. Additional horizontal setup (scaling, etc) */ - /* TW: Switch on LCD backlight on SiS30xLV */ - if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) { - if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - } - if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x01)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); - } + tempecx = SiS_Pr->SiS_VGAHDE; + if(HwInfo->jChipType >= SIS_315H) { + if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { + if(modeflag & HalfDCLK) tempecx >>= 1; + } } -} - -void -SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; + tempebx = SiS_Pr->SiS_HDE; + if(tempecx == tempebx) tempeax = 0xFFFF; + else { + tempeax = tempecx; + tempeax <<= 16; + temp = (USHORT)(tempeax % tempebx); + tempeax = tempeax / tempebx; + if(HwInfo->jChipType >= SIS_315H) { + if(temp) tempeax++; + } + } + tempecx = tempeax; - /* TW: Switch off LCD backlight on SiS30xLV */ - if( (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) || - (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00); + if(HwInfo->jChipType >= SIS_315H) { + tempeax = SiS_Pr->SiS_VGAHDE; + if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { + if(modeflag & HalfDCLK) tempeax >>= 1; + } + tempeax <<= 16; + tempeax = (tempeax / tempecx) - 1; + } else { + tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1; } + tempecx <<= 16; + tempecx |= (tempeax & 0xFFFF); + temp = (USHORT)(tempecx & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1F,temp); /* Part1_1Fh; Panel Link DDA Operational Number in each horiz. line */ - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) { - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFD,0x00); - } - } + tempbx = SiS_Pr->SiS_VDE; + if(HwInfo->jChipType >= SIS_315H) { + tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact; + tempbx = (USHORT)(tempeax & 0x0FFFF); + } else { + tempeax = SiS_Pr->SiS_VGAVDE << 6; + tempbx = push1 & 0x3f; + if(tempbx == 0) tempbx = 64; + tempeax /= tempbx; + tempbx = (USHORT)(tempeax & 0x0FFFF); + } + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx--; + if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) { + if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) tempbx = 1; + else if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) tempbx = 1; } -} -BOOLEAN -SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp,temp1; - UCHAR *ROMAddr; + temp = ((tempbx & 0xFF00) >> 8) << 3; + temp |= (USHORT)((tempecx & 0x0700) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x20,temp); /* Part1_20h; Overflow register */ - if((ROMAddr = (UCHAR *)HwDeviceExtension->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xff; - temp >>= 4; - temp = 1 << temp; - temp1 = (ROMAddr[0x23c] << 8) | ROMAddr[0x23b]; - if(temp1 & temp) return(1); - else return(0); - } else { - return(0); + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x21,temp); /* Part1_21h; Panel Link Vertical Accumulator Register */ + + tempecx >>= 16; /* BPLHCFACT */ + if((HwInfo->jChipType < SIS_315H) || (SiS_Pr->SiS_IF_DEF_FSTN) || (SiS_Pr->SiS_IF_DEF_DSTN)) { + if(modeflag & HalfDCLK) tempecx >>= 1; } -} + temp = (USHORT)((tempecx & 0xFF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x22,temp); /* Part1_22h; Panel Link Horizontal Scaling Factor High */ -BOOLEAN -SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp,temp1; - UCHAR *ROMAddr; + temp = (USHORT)(tempecx & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp); /* Part1_22h; Panel Link Horizontal Scaling Factor Low */ - if((ROMAddr = (UCHAR *)HwDeviceExtension->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xff; - temp >>= 4; - temp = 1 << temp; - temp1 = (ROMAddr[0x23e] << 8) | ROMAddr[0x23d]; - if(temp1 & temp) return(1); - else return(0); - } else { - return(0); + /* 630/301B and 630/LVDS do something for 640x480 panels here */ + +#ifdef SIS315H + if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x25,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x26,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x27,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x28,0x87); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x29,0x5A); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2A,0x4B); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x007,0x03); + tempax = SiS_Pr->SiS_HDE; /* Blps = lcdhdee(lcdhdes+HDE) + 64 */ + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempax >>= 1; + tempax += 64; + temp = tempax & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,temp); + temp = ((tempax & 0xFF00) >> 8) << 3; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,~0x078,temp); + tempax += 32; /* Blpe=lBlps+32 */ + temp = tempax & 0x00FF; + if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3A,0x00); /* Bflml=0 */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x007,0x00); + + tempax = SiS_Pr->SiS_VDE; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempax >>= 1; + tempax >>= 1; + temp = tempax & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3B,temp); + temp = ((tempax & 0xFF00) >> 8) << 3; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x038,temp); + + tempeax = SiS_Pr->SiS_HDE; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempeax >>= 1; + tempeax <<= 2; /* BDxFIFOSTOP = (HDE*4)/128 */ + tempebx = 128; + temp = (USHORT)(tempeax % tempebx); + tempeax = tempeax / tempebx; + if(temp) tempeax++; + temp = (USHORT)(tempeax & 0x003F); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x45,~0x0FF,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3F,0x00); /* BDxWadrst0 */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3E,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3D,0x10); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x040,0x00); + + tempax = SiS_Pr->SiS_HDE; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempax >>= 1; + tempax >>= 4; /* BDxWadroff = HDE*4/8/8 */ + pushcx = tempax; + temp = tempax & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,temp); + temp = ((tempax & 0xFF00) >> 8) << 3; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x0F8,temp); + + tempax = SiS_Pr->SiS_VDE; /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */ + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempax >>= 1; + tempeax = (tempax * pushcx); + tempebx = 0x00100000 + tempeax; + temp = (USHORT)tempebx & 0x000000FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x42,temp); + temp = (USHORT)((tempebx & 0x0000FF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x41,temp); + temp = (USHORT)((tempebx & 0x00FF0000) >> 16); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,temp); + temp = (USHORT)(((tempebx & 0x01000000) >> 24) << 7); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x080,temp); + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x03); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0x50); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x04,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x01); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0x38); + + if(SiS_Pr->SiS_IF_DEF_FSTN) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2b,0x02); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2c,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,0x0c); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,0x80); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,0xA0); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3a,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3b,0xf0); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3c,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3d,0x10); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3e,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3f,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,0x10); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x41,0x25); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x42,0x80); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,0x14); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x44,0x03); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x45,0x0a); + } } -} +#endif /* SIS315H */ -void -SiS_SetPanelDelayLoop(SiS_Private *SiS_Pr, UCHAR *ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT DelayTime, USHORT DelayLoop) -{ - int i; - for(i=0; ipjVirtualRomBase; + USHORT temp=0, tempax=0, tempbx=0, tempcx=0; + USHORT pushbx=0, CRT1Index=0; +#ifdef SIS315H + USHORT tempbl=0; #endif + USHORT modeflag, resinfo=0; - if(HwDeviceExtension->jChipType < SIS_315H) { - -#ifdef SIS300 + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + } else { + CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 300 series, LVDS */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); +#ifdef SIS315H + SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); + SiS_SetGroup1_LCDA(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); +#endif - DelayIndex = PanelID >> 4; + } else { - if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { - Delay = 3; - } else { - if(DelayTime >= 2) DelayTime -= 2; + if( (HwInfo->jChipType >= SIS_315H) && + (SiS_Pr->SiS_IF_DEF_LVDS == 1) && + (SiS_Pr->SiS_VBInfo & SetInSlaveMode) ) { - if(!(DelayTime & 0x01)) { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; - } else { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; - } - if((ROMAddr) && (SiS_Pr->SiS_UseROM)) { - if(ROMAddr[0x220] & 0x40) { - if(!(DelayTime & 0x01)) { - Delay = (USHORT)ROMAddr[0x225]; - } else { - Delay = (USHORT)ROMAddr[0x226]; - } - } - } - } - SiS_ShortDelay(SiS_Pr,Delay); + SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); - } else { /* 300 series, 301(B) */ + } else { - PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18); - if(!(temp & 0x10)) PanelID = 0x12; + SiS_SetCRT2Offset(SiS_Pr, ModeNo, ModeIdIndex, + RefreshRateTableIndex, HwInfo); - DelayIndex = PanelID >> 4; + if (HwInfo->jChipType < SIS_315H ) { +#ifdef SIS300 + SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo, HwInfo); +#endif + } else { +#ifdef SIS315H + SiS_SetCRT2FIFO_310(SiS_Pr); +#endif + } - if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { - Delay = 3; - } else { - if(DelayTime >= 2) DelayTime -= 2; + SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); - if(!(DelayTime & 0x01)) { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; - } else { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; - } - if((ROMAddr) && (SiS_Pr->SiS_UseROM)) { - if(ROMAddr[0x220] & 0x40) { - if(!(DelayTime & 0x01)) { - Delay = (USHORT)ROMAddr[0x225]; - } else { - Delay = (USHORT)ROMAddr[0x226]; - } - } - } - } - SiS_ShortDelay(SiS_Pr,Delay); + /* 1. Horizontal setup */ - } + if(HwInfo->jChipType < SIS_315H ) { -#endif /* SIS300 */ +#ifdef SIS300 /* ------------- 300 series --------------*/ - } else { + temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ - if(HwDeviceExtension->jChipType == SIS_330) return; + temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */ -#ifdef SIS315H + temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */ - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 310/325 series, LVDS */ + pushbx = SiS_Pr->SiS_VGAHDE + 12; /* bx BTVGA@HRS 0x0B,0x0C */ + tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2; + tempbx = pushbx + tempcx; + tempcx <<= 1; + tempcx += tempbx; - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); - DelayIndex = PanelID >> 4; - if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { - Delay = 3; - } else { - if(DelayTime >= 2) DelayTime -= 2; + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(!(DelayTime & 0x01)) { - Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[0]; - } else { - Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[1]; - } - if((ROMAddr) && (SiS_Pr->SiS_UseROM)) { - if(ROMAddr[0x13c] & 0x40) { - if(!(DelayTime & 0x01)) { - Delay = (USHORT)ROMAddr[0x17e]; - } else { - Delay = (USHORT)ROMAddr[0x17f]; - } - } - } - } - SiS_ShortDelay(SiS_Pr,Delay); - } + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CHSyncStart + 12; + tempcx = SiS_Pr->CHSyncEnd + 12; + } - } else { /* 310/325 series, 301(B) */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { + unsigned char cr4, cr14, cr5, cr15; + if(SiS_Pr->UseCustomMode) { + cr4 = SiS_Pr->CCRT1CRTC[4]; + cr14 = SiS_Pr->CCRT1CRTC[14]; + cr5 = SiS_Pr->CCRT1CRTC[5]; + cr15 = SiS_Pr->CCRT1CRTC[15]; + } else { + cr4 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4]; + cr14 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14]; + cr5 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5]; + cr15 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15]; + } + tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 1) << 3; + tempcx = (((cr5 & 0x1F) | ((cr15 & 0x04) << (6-2))) - 1) << 3; + } - PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); - DelayIndex = PanelID >> 4; - if(!(DelayTime & 0x01)) { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; - } else { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; - } - SiS_DDC2Delay(SiS_Pr, Delay * 4); + if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == SIS_RI_1024x768)){ + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)){ + tempbx = 1040; + tempcx = 1042; + } + } + } - } + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,temp); /* CRT2 Horizontal Retrace Start */ +#endif /* SIS300 */ -#endif /* SIS315H */ + } else { - } +#ifdef SIS315H /* ------------------- 315/330 series --------------- */ -} + tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HT 0x08,0x09 */ + if(modeflag & HalfDCLK) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + tempcx >>= 1; + } else { + tempax = SiS_Pr->SiS_VGAHDE >> 1; + tempcx = SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE + tempax; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempcx = SiS_Pr->SiS_HT - tempax; + } + } + } + tempcx--; -void -SiS_LongDelay(SiS_Private *SiS_Pr, USHORT delay) -{ - while(delay--) { - SiS_GenericDelay(SiS_Pr,0x19df); - } -} + temp = tempcx & 0xff; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ -void -SiS_ShortDelay(SiS_Private *SiS_Pr, USHORT delay) -{ - while(delay--) { - SiS_GenericDelay(SiS_Pr,0x42); - } -} + temp = ((tempcx & 0xff00) >> 8) << 4; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0F,temp); /* CRT2 Horizontal Total Overflow [7:4] */ -void -SiS_GenericDelay(SiS_Private *SiS_Pr, USHORT delay) -{ - USHORT temp,flag; + tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HDEE 0x0A,0x0C */ + tempbx = SiS_Pr->SiS_VGAHDE; + tempcx -= tempbx; + tempcx >>= 2; + if(modeflag & HalfDCLK) { + tempbx >>= 1; + tempcx >>= 1; + } + tempbx += 16; - flag = SiS_GetReg3(0x61) & 0x10; + temp = tempbx & 0xff; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */ - while(delay) { - temp = SiS_GetReg3(0x61) & 0x10; - if(temp == flag) continue; - flag = temp; - delay--; - } -} + pushbx = tempbx; + tempcx >>= 1; + tempbx += tempcx; + tempcx += tempbx; -BOOLEAN -SiS_Is301B(SiS_Private *SiS_Pr, USHORT BaseAddr) -{ - USHORT flag; + if(SiS_Pr->SiS_VBType & VB_SISVB) { - flag = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x01); - if(flag >= 0x0B0) return(1); - else return(0); -} + if(HwInfo->jChipType >= SIS_661) { + if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024)) { + if(resinfo == SIS_RI_1280x1024) { + tempcx = 0x30; + } else if(resinfo == SIS_RI_1600x1200) { + tempcx = 0xff; + } + } + } -BOOLEAN -SiS_CRT2IsLCD(SiS_Private *SiS_Pr, USHORT BaseAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT flag; + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CHSyncStart + 16; + tempcx = SiS_Pr->CHSyncEnd + 16; + tempax = SiS_Pr->SiS_VGAHT; + if(modeflag & HalfDCLK) tempax >>= 1; + tempax--; + if(tempcx > tempax) tempcx = tempax; + } - if(HwDeviceExtension->jChipType == SIS_730) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13); - if(flag & 0x20) return(1); - } - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(flag & 0x20) return(1); - else return(0); -} + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { + unsigned char cr4, cr14, cr5, cr15; + if(SiS_Pr->UseCustomMode) { + cr4 = SiS_Pr->CCRT1CRTC[4]; + cr14 = SiS_Pr->CCRT1CRTC[14]; + cr5 = SiS_Pr->CCRT1CRTC[5]; + cr15 = SiS_Pr->CCRT1CRTC[15]; + } else { + cr4 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4]; + cr14 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14]; + cr5 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5]; + cr15 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15]; + } + tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 3) << 3; /* (VGAHRS-3)*8 */ + tempcx = (((cr5 & 0x1f) | ((cr15 & 0x04) << (5-2))) - 3) << 3; /* (VGAHRE-3)*8 */ + tempcx &= 0x00FF; + tempcx |= (tempbx & 0xFF00); + tempbx += 16; + tempcx += 16; + tempax = SiS_Pr->SiS_VGAHT; + if(modeflag & HalfDCLK) tempax >>= 1; + tempax--; + if(tempcx > tempax) tempcx = tempax; + } -BOOLEAN -SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { + tempbx = 1040; + tempcx = 1042; + } - if(HwDeviceExtension->jChipType >= SIS_315H) { - if((HwDeviceExtension->jChipType != SIS_650) || (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if(flag & EnableDualEdge) return(1); - else return(0); - } else return(0); - } else -#endif - return(0); -} + } -BOOLEAN -SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + temp = tempbx & 0xff; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,temp); /* CRT2 Horizontal Retrace Start */ +#endif /* SIS315H */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if((flag & EnableDualEdge) && (flag & SetToLCDA)) return(1); -#if 0 /* Not done in 650/30xLV 1.10.6s, but in 650/301LV */ - else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(flag) return(1); - else return(0); - } -#endif - else - return(0); - } else -#endif - return(0); - } + } /* 315/330 series */ -BOOLEAN -SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + /* The following is done for all bridge/chip types/series */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x79); - if(flag & 0x10) return(1); - else return(0); - } else -#endif - return(0); - } + tempax = tempbx & 0xFF00; + tempbx = pushbx; + tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); + tempax |= (tempbx & 0xFF00); + temp = (tempax & 0xFF00) >> 8; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0C,temp); /* Overflow */ -#if 0 -BOOLEAN -SiS_Is315E(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + temp = tempcx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,temp); /* CRT2 Horizontal Retrace End */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f); - if(flag & 0x10) return(1); - else return(0); - } else -#endif - return(0); -} -#endif + /* 2. Vertical setup */ -BOOLEAN -SiS_IsNotM650or651(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + tempcx = SiS_Pr->SiS_VGAVT - 1; + temp = tempcx & 0x00FF; - if(HwDeviceExtension->jChipType == SIS_650) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f); - flag &= 0xF0; - if((flag == 0xb0) || (flag == 0x90)) return 0; - else return 1; - } else -#endif - return 1; -} + if(HwInfo->jChipType < SIS_661) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) { + temp--; + } + } + } else { + temp--; + } + } else if(HwInfo->jChipType >= SIS_315H) { + temp--; + } + } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0E,temp); /* CRT2 Vertical Total */ -BOOLEAN -SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + tempbx = SiS_Pr->SiS_VGAVDE - 1; + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,temp); /* CRT2 Vertical Display Enable End */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if(flag & EnableLVDSHiVision) return(1); /* = YPrPb = 0x08 */ - else return(0); - } else -#endif - return(0); -} + temp = ((tempbx & 0xFF00) << 3) >> 8; + temp |= ((tempcx & 0xFF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,temp); /* Overflow (and HWCursor Test Mode) */ -BOOLEAN -SiS_IsChScart(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { + tempbx++; + tempax = tempbx; + tempcx++; + tempcx -= tempax; + tempcx >>= 2; + tempbx += tempcx; + if(tempcx < 4) tempcx = 4; + tempcx >>= 2; + tempcx += tempbx; + tempcx++; + } else { + tempbx = (SiS_Pr->SiS_VGAVT + SiS_Pr->SiS_VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */ + tempcx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */ + } - if(HwDeviceExtension->jChipType >= SIS_315H) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if(flag & EnableLVDSScart) return(1); /* = Scart = 0x04 */ - else return(0); - } else -#endif - return(0); -} + if(SiS_Pr->SiS_VBType & VB_SISVB) { -BOOLEAN -SiS_IsTVOrYPbPrOrScart(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ - USHORT flag; + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CVSyncStart; + tempcx = (tempcx & 0xFF00) | (SiS_Pr->CVSyncEnd & 0x00FF); + } -#ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToTV) return(1); - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if(flag & EnableLVDSHiVision) return(1); /* = YPrPb = 0x08 */ - if(flag & EnableLVDSScart) return(1); /* = Scart = 0x04- TW inserted */ - else return(0); - } else -#endif - { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToTV) return(1); - } - return(0); -} + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { + unsigned char cr8, cr7, cr13, cr9; + if(SiS_Pr->UseCustomMode) { + cr8 = SiS_Pr->CCRT1CRTC[8]; + cr7 = SiS_Pr->CCRT1CRTC[7]; + cr13 = SiS_Pr->CCRT1CRTC[13]; + cr9 = SiS_Pr->CCRT1CRTC[9]; + } else { + cr8 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[8]; + cr7 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7]; + cr13 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]; + cr9 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9]; + } + tempbx = cr8; + if(cr7 & 0x04) tempbx |= 0x0100; + if(cr7 & 0x80) tempbx |= 0x0200; + if(cr13 & 0x08) tempbx |= 0x0400; + tempcx = (tempcx & 0xFF00) | (cr9 & 0x00FF); + } + } + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp); /* CRT2 Vertical Retrace Start */ -BOOLEAN -SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ - USHORT flag; + temp = ((tempbx & 0xFF00) >> 8) << 4; + temp |= (tempcx & 0x000F); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x11,temp); /* CRT2 Vert. Retrace End; Overflow; "Enable CRTC Check" */ -#ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToLCD) return(1); - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if(flag & SetToLCDA) return(1); - else return(0); - } else -#endif - { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToLCD) return(1); - } - return(0); + /* 3. Panel compensation delay */ -} + if(HwInfo->jChipType < SIS_315H) { -BOOLEAN -SiS_IsDisableCRT2(SiS_Private *SiS_Pr, USHORT BaseAddr) -{ - USHORT flag; +#ifdef SIS300 /* ---------- 300 series -------------- */ - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(flag & 0x20) return(0); - else return(1); -} + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp = 0x20; -BOOLEAN -SiS_BridgeIsOn(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT flag; + if(HwInfo->jChipType == SIS_300) { + temp = 0x10; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) temp = 0x2c; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20; + } + if(SiS_Pr->SiS_VBType & VB_SIS301) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20; + } + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) temp = 0x24; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) temp = 0x2c; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x08; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c; + else temp = 0x20; + } + if((ROMAddr) && (SiS_Pr->SiS_UseROM)) { + if(ROMAddr[0x220] & 0x80) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) + temp = ROMAddr[0x221]; + else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) + temp = ROMAddr[0x222]; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) + temp = ROMAddr[0x223]; + else + temp = ROMAddr[0x224]; + temp &= 0x3c; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->PDC) { + temp = SiS_Pr->PDC & 0x3c; + } + } + } else { + temp = 0x20; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) temp = 0x04; + } + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + if(ROMAddr[0x220] & 0x80) { + temp = ROMAddr[0x220] & 0x3c; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->PDC) { + temp = SiS_Pr->PDC & 0x3c; + } + } + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - return(0); - } else { - flag = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00); - if((flag == 1) || (flag == 2)) return(0); - else return(1); - } -} + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x03C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */ -BOOLEAN -SiS_BridgeIsEnable(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT flag; +#endif /* SIS300 */ - if(!(SiS_BridgeIsOn(SiS_Pr,BaseAddr,HwDeviceExtension))) { - flag = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00); - if(HwDeviceExtension->jChipType < SIS_315H) { - /* 300 series (630/301B 2.04.5a) */ - flag &= 0xa0; - if((flag == 0x80) || (flag == 0x20)) return 0; - else return 1; - } else { - /* 310/325 series (650/30xLV 1.10.6s) */ - flag &= 0x50; - if((flag == 0x40) || (flag == 0x10)) return 0; - else return 1; - } - } - return 1; -} + } else { -BOOLEAN -SiS_BridgeInSlave(SiS_Private *SiS_Pr) -{ - USHORT flag1; +#ifdef SIS315H /* --------------- 315/330 series ---------------*/ - flag1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31); - if(flag1 & (SetInSlaveMode >> 8)) return 1; - else return 0; -} + if(HwInfo->jChipType < SIS_661) { -void -SiS_SetHiVision(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ -#ifdef SIS315H - USHORT temp; -#endif + if(SiS_Pr->SiS_VBType & VB_SISVB) { - /* Note: This variable is only used on 30xLV systems. - CR38 has a different meaning on LVDS/CH7019 systems. - */ + temp = 0x10; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) temp = 0x2c; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) temp = 0x24; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) temp = 0x2c; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + temp = 0x08; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c; + else temp = 0x20; + } + } + if((SiS_Pr->SiS_VBType & VB_SIS301B302B) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { + tempbl = 0x00; + if((ROMAddr) && (SiS_Pr->SiS_UseROM)) { + if(HwInfo->jChipType < SIS_330) { + if(ROMAddr[0x13c] & 0x80) tempbl = 0xf0; + } else { + if(ROMAddr[0x1bc] & 0x80) tempbl = 0xf0; + } + } + } else { /* LV (550/301LV checks ROM byte, other LV BIOSes do not) */ + tempbl = 0xF0; + } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD|SetCRT2ToLCDA)) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->PDC) { + temp = SiS_Pr->PDC; + tempbl = 0; + } + } + } - SiS_Pr->SiS_HiVision = 0; - if(HwDeviceExtension->jChipType >= SIS_315H) { -#ifdef SIS315H - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - temp &= 0x38; - SiS_Pr->SiS_HiVision = (temp >> 3); - } - } -#endif /* SIS315H */ - } -} + } else { /* LVDS */ -BOOLEAN -SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp,modeflag,resinfo=0; - const unsigned char SiS300SeriesLCDRes[] = - { 0, 1, 2, 3, 7, 4, 5, 8, - 0, 0, 0, 0, 0, 0, 0, 0 }; + if(HwInfo->jChipType == SIS_740) { + temp = 0x03; + } else { + temp = 0x00; + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x0a; + tempbl = 0xF0; + if(HwInfo->jChipType == SIS_650) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempbl = 0x0F; + } + } - SiS_Pr->SiS_LCDResInfo = 0; - SiS_Pr->SiS_LCDTypeInfo = 0; - SiS_Pr->SiS_LCDInfo = 0; + if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) { + temp = 0x08; + tempbl = 0; + if((ROMAddr) && (SiS_Pr->SiS_UseROM)) { + if(ROMAddr[0x13c] & 0x80) tempbl = 0xf0; + } + } + } - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } - } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,tempbl,temp); /* Panel Link Delay Compensation */ - if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return 0; + } /* < 661 */ - if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2))) return 0; + tempax = 0; + if (modeflag & DoubleScanMode) tempax |= 0x80; + if (modeflag & HalfDCLK) tempax |= 0x40; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax); - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); +#endif /* SIS315H */ - /* FSTN: Fake CR36 (TypeInfo 2, ResInfo SiS_Panel320x480) */ - if(SiS_Pr->SiS_IF_DEF_FSTN) { - temp = 0x20 | SiS_Pr->SiS_Panel320x480; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,temp); - } + } - if(HwDeviceExtension->jChipType < SIS_315H) { - SiS_Pr->SiS_LCDTypeInfo = temp >> 4; - } else { - SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1; - } - temp &= 0x0f; - if(HwDeviceExtension->jChipType < SIS_315H) { - /* TW: Translate 300 series LCDRes to 310/325 series for unified usage */ - temp = SiS300SeriesLCDRes[temp]; - } - SiS_Pr->SiS_LCDResInfo = temp; + } /* Slavemode */ - if(SiS_Pr->SiS_IF_DEF_FSTN){ - SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_Panel320x480; - } + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMin301) - SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMin301; - } else { - if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMinLVDS) - SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMinLVDS; - } + /* For 301BDH with LCD, we set up the Panel Link */ + if( (SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) { - if(SiS_Pr->SiS_LCDResInfo > SiS_Pr->SiS_PanelMax) - SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_Panel1024x768; + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, + HwInfo, RefreshRateTableIndex); - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37); - if(SiS_Pr->SiS_IF_DEF_FSTN){ - /* TW: Fake LVDS bridge for FSTN */ - temp = 0x04; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,temp); - } - SiS_Pr->SiS_LCDInfo = temp; - - if(!(SiS_Pr->UsePanelScaler)) SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; - else if(SiS_Pr->UsePanelScaler == 1) SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - /* TW: Inserted entire 315-block from 650/LVDS/30xLV BIOSes */ - if(HwDeviceExtension->jChipType >= SIS_315H) { -#ifdef SIS315H - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - if(ModeNo == 0x3a || ModeNo == 0x4d || ModeNo == 0x65) { - /* Bridge does not scale to 1280x1024 */ - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(ModeNo == 0x7c || ModeNo == 0x7d || ModeNo == 0x7e) { - /* TW: Bridge does not scale to 1280x960 */ - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - if(ModeNo == 0x2f || ModeNo == 0x5d || ModeNo == 0x5e) { - /* TW: Bridge does not scale to 640x400 */ - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(ModeNo == 0x2f || ModeNo == 0x5d || ModeNo == 0x5e) { - /* TW: Most panels can't scale to 640x400 */ - SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; - } - } - } - } - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x01) { - SiS_Pr->SiS_LCDInfo &= 0xFFEF; - SiS_Pr->SiS_LCDInfo |= LCDPass11; - } -#endif - } else { -#ifdef SIS300 - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if((ROMAddr) && SiS_Pr->SiS_UseROM) { - if(!(ROMAddr[0x235] & 0x02)) { - SiS_Pr->SiS_LCDInfo &= 0xEF; - } + SiS_SetGroup1_301(SiS_Pr, ModeNo, ModeIdIndex, + HwInfo, RefreshRateTableIndex); } + } else { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10))) { - SiS_Pr->SiS_LCDInfo &= 0xEF; - } - } - } -#endif - } - - /* TW: With Trumpion, always Expanding */ - if(SiS_Pr->SiS_IF_DEF_TRUMPION != 0){ - SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); - } - if(!((HwDeviceExtension->jChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) { + if(HwInfo->jChipType < SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - if(ModeNo > 0x13) { - if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - if((resinfo == 7) || (resinfo == 3)) { - SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, + HwInfo, RefreshRateTableIndex); + } else { + + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex, + HwInfo,RefreshRateTableIndex); } - } - } - if(ModeNo == 0x12) { - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else { + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex, + HwInfo,RefreshRateTableIndex); } + } - } - if(modeflag & HalfDCLK) { - if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { - if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - if(!(((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (HwDeviceExtension->jChipType < SIS_315H)) && - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480))) { - if(ModeNo > 0x13) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(resinfo == 4) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; /* 512x384 */ - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - if(resinfo == 3) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; /* 400x300 */ - } - } - } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; } - - } - - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) { - SiS_Pr->SiS_SetFlag |= LCDVESATiming; - } - } else { - SiS_Pr->SiS_SetFlag |= LCDVESATiming; - } - -#ifdef SIS315H - /* TW: 650/30xLV 1.10.6s */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & (VB_SIS302B | VB_SIS302LV)) { - /* Enable 302B/302LV dual link mode */ - /* (302B is a theory - not in any BIOS */ - temp = 0x00; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) temp = 0x04; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x04; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) temp = 0x04; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x39,temp); - } else if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x39,0x00); - } - } -#endif - -#ifdef LINUX_KERNEL -#ifdef TWDEBUG - printk(KERN_DEBUG "sisfb: (LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)\n", - SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo); -#endif -#endif -#ifdef LINUX_XF86 - xf86DrvMsgVerb(0, X_PROBED, 3, - "(init301: LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x SetFlag=0x%04x)\n", - SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo, SiS_Pr->SiS_SetFlag); -#endif - - return 1; + } /* LCDA */ } -void -SiS_PresetScratchregister(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - return; - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,0x21); */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x31,0x41); */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x32,0x28); */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x33,0x22); */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x35,0x43); */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,0x01); */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,0x00); */ -} +/*********************************************/ +/* SET PART 2 REGISTER GROUP */ +/*********************************************/ -void -SiS_LongWait(SiS_Private *SiS_Pr) +#ifdef SIS315H +static UCHAR * +SiS_GetGroup2CLVXPtr(SiS_Private *SiS_Pr, int tabletype, PSIS_HW_INFO HwInfo) { - USHORT i; - - i = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1F); + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + const UCHAR *tableptr = NULL; + USHORT a, b, p = 0; - if(!(i & 0xC0)) { - for(i=0; i<0xFFFF; i++) { - if(!(SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08)) - break; - } - for(i=0; i<0xFFFF; i++) { - if((SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08)) - break; - } - } -} + a = SiS_Pr->SiS_VGAHDE; + b = SiS_Pr->SiS_HDE; + if(tabletype) { + a = SiS_Pr->SiS_VGAVDE; + b = SiS_Pr->SiS_VDE; + } -void -SiS_VBLongWait(SiS_Private *SiS_Pr) -{ - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { - SiS_VBWait(SiS_Pr); - } else { - SiS_LongWait(SiS_Pr); - } - return; -} + if((HwInfo->jChipType >= SIS_661) && (ROMAddr = (UCHAR *)HwInfo->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) { -void -SiS_VBWait(SiS_Private *SiS_Pr) -{ - USHORT tempal,temp,i,j; + if(a < b) { + p = ROMAddr[0x278] | (ROMAddr[0x279] << 8); + } else if(a == b) { + p = ROMAddr[0x27a] | (ROMAddr[0x27b] << 8); + } else { + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + p = ROMAddr[0x27e] | (ROMAddr[0x27f] << 8); + } else { + p = ROMAddr[0x27c] | (ROMAddr[0x27d] << 8); + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525i) p = ROMAddr[0x280] | (ROMAddr[0x281] << 8); + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) p = ROMAddr[0x282] | (ROMAddr[0x283] << 8); + else p = ROMAddr[0x284] | (ROMAddr[0x285] << 8); + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + p = ROMAddr[0x286] | (ROMAddr[0x287] << 8); + } + do { + if((ROMAddr[p] | ROMAddr[p+1] << 8) == a) break; + p += 0x42; + } while((ROMAddr[p] | ROMAddr[p+1] << 8) != 0xffff); + if((ROMAddr[p] | ROMAddr[p+1] << 8) == 0xffff) p -= 0x42; + } + p += 2; + return(&ROMAddr[p]); - temp = 0; - for(i=0; i<3; i++) { - for(j=0; j<100; j++) { - tempal = SiS_GetReg2(SiS_Pr->SiS_P3da); - if(temp & 0x01) { - if((tempal & 0x08)) continue; - if(!(tempal & 0x08)) break; - } else { - if(!(tempal & 0x08)) continue; - if((tempal & 0x08)) break; - } - } - temp ^= 0x01; - } -} + } else { -void -SiS_WaitVBRetrace(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - if(HwDeviceExtension->jChipType < SIS_315H) { -#ifdef SIS300 - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return; - } - if(!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x80)) { - SiS_WaitRetrace1(SiS_Pr,HwDeviceExtension); - } else { - SiS_WaitRetrace2(SiS_Pr,HwDeviceExtension); - } -#endif - } else { -#ifdef SIS315H - if(!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) { - SiS_WaitRetrace1(SiS_Pr,HwDeviceExtension); - } else { - SiS_WaitRetrace2(SiS_Pr,HwDeviceExtension); - } -#endif - } + if(a < b) { + tableptr = SiS_Part2CLVX_1; + } else if(a == b) { + tableptr = SiS_Part2CLVX_2; + } else { + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + tableptr = SiS_Part2CLVX_4; + } else { + tableptr = SiS_Part2CLVX_3; + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525i) tableptr = SiS_Part2CLVX_3; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tableptr = SiS_Part2CLVX_3; + else tableptr = SiS_Part2CLVX_5; + + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + tableptr = SiS_Part2CLVX_6; + } + do { + if((tableptr[p] | tableptr[p+1] << 8) == a) break; + p += 0x42; + } while((tableptr[p] | tableptr[p+1] << 8) != 0xffff); + if((tableptr[p] | tableptr[p+1] << 8) == 0xffff) p -= 0x42; + } + p += 2; + return((UCHAR *)&tableptr[p]); + } } -void -SiS_WaitRetrace1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT watchdog; -#ifdef SIS300 - USHORT i; -#endif - if(HwDeviceExtension->jChipType >= SIS_315H) { -#ifdef SIS315H - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return; - watchdog = 65535; - while( (SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08) && --watchdog); - watchdog = 65535; - while( (!(SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); -#endif - } else { -#ifdef SIS300 -#if 0 /* TW: Not done in A901 BIOS */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return; - } -#endif - for(i=0; i<10; i++) { - watchdog = 65535; - while( (SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08) && --watchdog); - if(watchdog) break; - } - for(i=0; i<10; i++) { - watchdog = 65535; - while( (!(SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); - if(watchdog) break; - } -#endif - } +static void +SiS_SetGroup2_C_ELV(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +{ + UCHAR *tableptr; + int i, j; + UCHAR temp; + + if(!(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV))) return; + + tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 0, HwInfo); + for(i = 0x80, j = 0; i <= 0xbf; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]); + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 1, HwInfo); + for(i = 0xc0, j = 0; i <= 0xff; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]); + } + } + temp = 0x10; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp |= 0x04; + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4e,0xeb,temp); } -void -SiS_WaitRetraceDDC(SiS_Private *SiS_Pr) +static void +SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,USHORT *CRT2Index, + USHORT *ResIndex,PSIS_HW_INFO HwInfo) { - USHORT watchdog; + USHORT tempbx,tempal; - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return; - watchdog = 65535; - while( (SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08) && --watchdog); - watchdog = 65535; - while( (!(SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); -} + if(ModeNo <= 0x13) + tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + else + tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; -void -SiS_WaitRetrace2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT watchdog; -#ifdef SIS300 - USHORT i; -#endif + tempbx = SiS_Pr->SiS_LCDResInfo; - if(HwDeviceExtension->jChipType >= SIS_315H) { -#ifdef SIS315H - watchdog = 65535; - while( (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x30) & 0x02) && --watchdog); - watchdog = 65535; - while( (!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x30) & 0x02)) && --watchdog); -#endif - } else { -#ifdef SIS300 - for(i=0; i<10; i++) { - watchdog = 65535; - while( (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x25) & 0x02) && --watchdog); - if(watchdog) break; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 16; + else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx += 32; + + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + tempbx = 100; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 101; + else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx = 102; + } + } else if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + tempbx = 103; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 104; + else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx = 105; + } } - for(i=0; i<10; i++) { - watchdog = 65535; - while( (!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x25) & 0x02)) && --watchdog); - if(watchdog) break; + } else if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx = 106; } -#endif } -} -/* =========== Set and Get register routines ========== */ + *CRT2Index = tempbx; + *ResIndex = tempal & 0x3F; +} +#endif -void -SiS_SetRegANDOR(USHORT Port,USHORT Index,USHORT DataAND,USHORT DataOR) +#ifdef SIS300 +/* For ECS A907. Highly preliminary. */ +static void +SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeIdIndex, USHORT RefreshRateTableIndex, + USHORT ModeNo) { - USHORT temp; + USHORT crt2crtc, resindex; + int i,j; + const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; - temp = SiS_GetReg1(Port,Index); - temp = (temp & (DataAND)) | DataOR; - SiS_SetReg1(Port,Index,temp); -} + if(HwInfo->jChipType != SIS_300) return; + if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; + if(SiS_Pr->UseCustomMode) return; -void -SiS_SetRegAND(USHORT Port,USHORT Index,USHORT DataAND) -{ - USHORT temp; + if(ModeNo <= 0x13) { + crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + } + + resindex = crt2crtc & 0x3F; + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; + else CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_2; + + /* The BIOS code (1.16.51,56) is obviously a fragment! */ + if(ModeNo > 0x13) { + CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; + resindex = 4; + } - temp = SiS_GetReg1(Port,Index); - temp &= DataAND; - SiS_SetReg1(Port,Index,temp); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]); + for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + } + for(j = 0x1c; j <= 0x1d; i++, j++ ) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + } + for(j = 0x1f; j <= 0x21; i++, j++ ) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]); } +#endif -void SiS_SetRegOR(USHORT Port,USHORT Index,USHORT DataOR) +static void +SiS_SetTVSpecial(SiS_Private *SiS_Pr, USHORT ModeNo) { - USHORT temp; + if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) return; + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) return; - temp = SiS_GetReg1(Port,Index); - temp |= DataOR; - SiS_SetReg1(Port,Index,temp); + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { + const UCHAR specialtv[] = { + 0xa7,0x07,0xf2,0x6e,0x17,0x8b,0x73,0x53, + 0x13,0x40,0x34,0xf4,0x63,0xbb,0xcc,0x7a, + 0x58,0xe4,0x73,0xda,0x13 + }; + int i, j; + for(i = 0x1c, j = 0; i <= 0x30; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,specialtv[j]); + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,0x72); + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750)) { + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x14); + } else { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x15); + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1b); + } + } + } else { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x21); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x5a); + } } -/* ========================================================= */ - -/* TW: Set 301 TV Encoder (and some LCD relevant) registers */ -void -SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo, - USHORT ModeIdIndex,USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT RefreshRateTableIndex, + PSIS_HW_INFO HwInfo) { - USHORT i, j, tempax, tempbx, tempcx, temp, temp1; - USHORT push1, push2; + USHORT i, j, tempax, tempbx, tempcx, temp; + USHORT push1, push2, modeflag, crt2crtc; + ULONG longtemp, tempeax; const UCHAR *PhasePoint; const UCHAR *TimingPoint; -#ifdef SIS315H - const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; +#ifdef SIS315H USHORT resindex, CRT2Index; -#endif - USHORT modeflag, resinfo, crt2crtc; - ULONG longtemp, tempeax, tempebx, temp2, tempecx; + const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; +#endif +#ifdef SIS300 const UCHAR atable[] = { - 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02, - 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02 + 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02, + 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02 }; +#endif #ifdef SIS315H - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - /* TW: 650/30xLV 1.10.6s: (Is at end of SetGroup2!) */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xfc,0x03); - temp = 1; - if(ModeNo <= 0x13) temp = 3; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0b,temp); - } - } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((ModeNo == 0x4a) || (ModeNo == 0x38)) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1c,0xa7); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1d,0x07); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1e,0xf2); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1f,0x6e); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x20,0x17); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x21,0x8b); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x22,0x73); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,0x53); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,0x13); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x25,0x40); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x26,0x34); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,0xf4); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x28,0x63); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x29,0xbb); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2a,0xcc); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2b,0x7a); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2c,0x58); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2d,0xe4); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2e,0x73); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,0xda); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0x13); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,0x72); - } - } - } - } - return; - } -#endif + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; +#endif - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */ - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; - crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */ - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + crt2crtc = 0; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + } } - tempcx = SiS_Pr->SiS_VBInfo; - tempax = (tempcx & 0x00FF) << 8; - tempbx = (tempcx & 0x00FF) | ((tempcx & 0x00FF) << 8); - tempbx &= 0x0410; - temp = (tempax & 0x0800) >> 8; - temp >>= 1; - temp |= (((tempbx & 0xFF00) >> 8) << 1); - temp |= ((tempbx & 0x00FF) >> 3); - temp ^= 0x0C; - - /* TW: From 1.10.7w (no vb check there; don't care - this only disables SVIDEO and CVBS signal) */ - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - temp |= 0x0c; - } + temp = 0; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToAVIDEO)) temp |= 0x08; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) temp |= 0x04; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) temp |= 0x02; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) temp |= 0x01; + + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) temp |= 0x10; + + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x00,temp); PhasePoint = SiS_Pr->SiS_PALPhase; TimingPoint = SiS_Pr->SiS_PALTiming; - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - - temp ^= 0x01; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - TimingPoint = SiS_Pr->SiS_HiTVSt2Timing; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - if(modeflag & Charx8Dot) TimingPoint = SiS_Pr->SiS_HiTVSt1Timing; - else TimingPoint = SiS_Pr->SiS_HiTVTextTiming; - } - } else TimingPoint = SiS_Pr->SiS_HiTVExtTiming; - - if(SiS_Pr->SiS_HiVision & 0x03) temp &= 0xfe; - - } else { - - if(SiS_Pr->SiS_VBInfo & SetPALTV){ - TimingPoint = SiS_Pr->SiS_PALTiming; - PhasePoint = SiS_Pr->SiS_PALPhase; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - if( (SiS_Pr->SiS_VBType & VB_SIS301B302B) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALPhase2; - } + TimingPoint = SiS_Pr->SiS_HiTVExtTiming; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + TimingPoint = SiS_Pr->SiS_HiTVSt2Timing; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + TimingPoint = SiS_Pr->SiS_HiTVSt1Timing; +#if 0 + if(!(modeflag & Charx8Dot)) TimingPoint = SiS_Pr->SiS_HiTVTextTiming; +#endif + } + } - } else { + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - temp |= 0x10; - TimingPoint = SiS_Pr->SiS_NTSCTiming; - PhasePoint = SiS_Pr->SiS_NTSCPhase; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) TimingPoint = &SiS_YPbPrTable[2][0]; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) TimingPoint = &SiS_YPbPrTable[1][0]; + else TimingPoint = &SiS_YPbPrTable[0][0]; - if( (SiS_Pr->SiS_VBType & VB_SIS301B302B) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_NTSCPhase2; - } + PhasePoint = SiS_Pr->SiS_NTSCPhase; + + } else if(SiS_Pr->SiS_TVMode & TVSetPAL) { + + if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && + ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { + PhasePoint = SiS_Pr->SiS_PALPhase2; + } + + } else { + + TimingPoint = SiS_Pr->SiS_NTSCTiming; + PhasePoint = SiS_Pr->SiS_NTSCPhase; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { + PhasePoint = SiS_Pr->SiS_PALPhase; + } + + if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && + ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { + PhasePoint = SiS_Pr->SiS_NTSCPhase2; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { + PhasePoint = SiS_Pr->SiS_PALPhase2; + } + } - } - } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,temp); - temp = 0; - if((HwDeviceExtension->jChipType == SIS_630)|| - (HwDeviceExtension->jChipType == SIS_730)) { - temp = 0x35; - } - if(HwDeviceExtension->jChipType >= SIS_315H) { - temp = 0x38; - } - if(temp) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) { - temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,temp); - if(temp1 & EnablePALM) { /* 0x40 */ - PhasePoint = SiS_Pr->SiS_PALMPhase; - if( (SiS_Pr->SiS_VBType & VB_SIS301B302B) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALMPhase2; - } - } - if(temp1 & EnablePALN) { /* 0x80 */ - PhasePoint = SiS_Pr->SiS_PALNPhase; - if( (SiS_Pr->SiS_VBType & VB_SIS301B302B) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALNPhase2; - } - } - } - } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + PhasePoint = SiS_Pr->SiS_PALMPhase; + if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && + ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { + PhasePoint = SiS_Pr->SiS_PALMPhase2; + } } -#ifdef SIS315H - /* TW: 650/301LV BIOS */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((ModeNo == 0x4a) || (ModeNo == 0x38)) { - PhasePoint = SiS_Pr->SiS_SpecialPhase; - } - } - } + if(SiS_Pr->SiS_TVMode & TVSetPALN) { + PhasePoint = SiS_Pr->SiS_PALNPhase; + if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && + ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { + PhasePoint = SiS_Pr->SiS_PALNPhase2; + } + } + + if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { + PhasePoint = SiS_Pr->SiS_SpecialPhase; + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + PhasePoint = SiS_Pr->SiS_SpecialPhaseM; + } else if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { + PhasePoint = SiS_Pr->SiS_SpecialPhaseJ; } } -#endif for(i=0x31, j=0; i<=0x34; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,PhasePoint[j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,PhasePoint[j]); } for(i=0x01, j=0; i<=0x2D; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); } for(i=0x39; i<=0x45; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); } if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(!(SiS_Pr->SiS_ModeType & 0x07)) + if(SiS_Pr->SiS_ModeType != ModeText) { SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F); - } else { - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F); - } + } } SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x0A,SiS_Pr->SiS_NewFlickerMode); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x35,SiS_Pr->SiS_RY1COE); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x36,SiS_Pr->SiS_RY2COE); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x37,SiS_Pr->SiS_RY3COE); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x38,SiS_Pr->SiS_RY4COE); - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(SiS_Pr->SiS_HiVision == 3) tempax = 950; - else tempax = 440; - } else { - if(SiS_Pr->SiS_VBInfo & SetPALTV) tempax = 520; - else tempax = 440; - } - - if( ( ( (!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_HiVision == 3) ) && (SiS_Pr->SiS_VDE <= tempax) ) || - ( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (SiS_Pr->SiS_HiVision != 3) && - ( (SiS_Pr->SiS_VGAHDE == 1024) || ((SiS_Pr->SiS_VGAHDE != 1024) && (SiS_Pr->SiS_VDE <= tempax)) ) ) ) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x35,SiS_Pr->SiS_RY1COE); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x36,SiS_Pr->SiS_RY2COE); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x37,SiS_Pr->SiS_RY3COE); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x38,SiS_Pr->SiS_RY4COE); + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempax = 950; + else if(SiS_Pr->SiS_TVMode & TVSetPAL) tempax = 520; + else tempax = 440; + + if( ( (!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) && (SiS_Pr->SiS_VDE <= tempax) ) || + ( (SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) && + ((SiS_Pr->SiS_VGAHDE == 1024) || (SiS_Pr->SiS_VDE <= tempax)) ) ) { tempax -= SiS_Pr->SiS_VDE; tempax >>= 2; - tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); + tempax &= 0x00ff; + + temp = tempax + (USHORT)TimingPoint[0]; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); + + temp = tempax + (USHORT)TimingPoint[1]; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp); - temp = (tempax & 0xFF00) >> 8; - temp += (USHORT)TimingPoint[0]; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,temp); - - temp = (tempax & 0xFF00) >> 8; - temp += (USHORT)TimingPoint[1]; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,temp); - - if( (SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) && - (SiS_Pr->SiS_HiVision != 3) && - (SiS_Pr->SiS_VGAHDE >= 1024) ) { - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x19); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x52); + if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) && (SiS_Pr->SiS_VGAHDE >= 1024)) { + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x19); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x52); } else { - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x17); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x1d); - } else { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x0b); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x11); - } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x17); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1d); } } } tempcx = SiS_Pr->SiS_HT; - - /* TW: 650/30xLV 1.10.6s */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) { - tempcx >>= 1; - } - } - + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; tempcx--; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - tempcx--; - } + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) tempcx--; temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1B,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1B,temp); temp = (tempcx & 0xFF00) >> 8; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0xF0,temp); tempcx++; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - tempcx++; - } + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) tempcx++; tempcx >>= 1; push1 = tempcx; tempcx += 7; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (SiS_Pr->SiS_HiVision == 3)) { - tempcx -= 4; - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4; temp = (tempcx & 0x00FF) << 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x22,0x0F,temp); tempbx = TimingPoint[j] | ((TimingPoint[j+1]) << 8); tempbx += tempcx; - push2 = tempbx; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x24,temp); temp = ((tempbx & 0xFF00) >> 8) << 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0F,temp); - tempbx = push2; - tempbx += 8; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (SiS_Pr->SiS_HiVision == 3)) { - tempbx -= 4; - tempcx = tempbx; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + tempbx -= 4; + tempcx = tempbx; } temp = (tempbx & 0x00FF) << 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x29,0x0F,temp); @@ -7210,15 +7462,12 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR j += 2; tempcx += ((TimingPoint[j] | ((TimingPoint[j+1]) << 8))); temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x27,temp); temp = ((tempcx & 0xFF00) >> 8) << 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x28,0x0F,temp); tempcx += 8; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (SiS_Pr->SiS_HiVision == 3)) { - tempcx -= 4; - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4; temp = (tempcx & 0x00FF) << 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2A,0x0F,temp); @@ -7231,363 +7480,265 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR tempcx -= 11; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { - tempax = SiS_GetVGAHT2(SiS_Pr) - 1; - tempcx = tempax; + tempcx = SiS_GetVGAHT2(SiS_Pr) - 1; } temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2E,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2E,temp); tempbx = SiS_Pr->SiS_VDE; if(SiS_Pr->SiS_VGAVDE == 360) tempbx = 746; if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 746; if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 853; - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempbx >>= 1; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempbx >>= 1; } else { - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) { - tempbx >>= 1; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - if(ModeNo <= 0x13) { - if(crt2crtc == 1) { - tempbx++; - } - } - } else { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(crt2crtc == 4) /* TW: BIOS calls GetRatePtrCRT2 here - does not make sense */ - if(SiS_Pr->SiS_ModeType <= 3) tempbx++; - } + if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && + (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p))) ) { + tempbx >>= 1; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + if(ModeNo <= 0x13) { + if(crt2crtc == 1) tempbx++; + } + } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(crt2crtc == 4) { + if(SiS_Pr->SiS_ModeType <= 3) tempbx++; } - } + } + } } tempbx -= 2; temp = tempbx & 0x00FF; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (SiS_Pr->SiS_HiVision == 3)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(ModeNo == 0x2f) temp++; - } - } - /* TW: From 1.10.7w - doesn't make sense */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { /* SetFlag?? */ - if(ModeNo == 0x03) temp++; - } - } + if((ModeNo == 0x2f) || (ModeNo == 0x5d) || (ModeNo == 0x5e)) temp++; } } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2F,temp); - tempax = (tempcx & 0xFF00) | (tempax & 0x00FF); - tempbx = ((tempbx & 0xFF00) << 6) | (tempbx & 0x00FF); - tempax |= (tempbx & 0xFF00); - if(HwDeviceExtension->jChipType < SIS_315H) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART)) { /* TW: New from 630/301B (II) BIOS */ - tempax |= 0x1000; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) tempax |= 0x2000; + if(HwInfo->jChipType < SIS_661) { + /* From 1.10.7w - doesn't make sense */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { /* SetFlag?? */ + if(ModeNo == 0x03) temp++; + } + } } } - } else { - /* TODO Check this with other BIOSes */ - if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) && - (SiS_Pr->SiS_HiVision == 3)) { - tempax |= 0x1000; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) tempax |= 0x2000; - } } - temp = (tempax & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2F,temp); + + temp = (tempcx >> 8) & 0x0F; + temp |= (((tempbx >> 8) << 6) & 0xC0); + if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToHiVision | SetCRT2ToYPbPr525750 | SetCRT2ToSCART))) { + temp |= 0x10; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) temp |= 0x20; + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,temp); - /* TW: 650/30xLV 1.10.6s */ - if(HwDeviceExtension->jChipType > SIS_315H) { + if((HwInfo->jChipType > SIS_315H) && (HwInfo->jChipType < SIS_661)) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) ) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x10,0x60); + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) { + if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) ) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x10,0x60); + } } } } - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(SiS_Pr->SiS_HiVision != 3) { - for(i=0, j=0; i<=0x2d; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS_HiVisionTable[SiS_Pr->SiS_HiVision][j]); + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + tempbx = SiS_Pr->SiS_VDE; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) { + tempbx >>= 1; } - for(i=0x39; i<=0x45; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS_HiVisionTable[SiS_Pr->SiS_HiVision][j]); + } + tempbx -= 3; + if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) { /* Why not 301B/LV? */ + temp = 0; + if(tempcx & 0x0400) temp |= 0x20; + if(tempbx & 0x0400) temp |= 0x40; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x10,temp); } } - } + tempbx &= 0x03ff; + temp = ((tempbx & 0xFF00) >> 8) << 5; + temp |= 0x18; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x46,temp); + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x47,temp); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - tempbx = SiS_Pr->SiS_VDE; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) { - tempbx >>= 1; - } - tempbx -= 3; - tempbx &= 0x03ff; - temp = ((tempbx & 0xFF00) >> 8) << 5; - temp |= 0x18; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x46,temp); - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x47,temp); /* tv gatingno */ - if(HwDeviceExtension->jChipType >= SIS_315H) { /* TW: 650/30xLV 1.10.6s */ - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - tempax = 0; - if(SiS_Pr->SiS_HiVision & 0x03) { - tempax = 0x3000; - if(SiS_Pr->SiS_HiVision & 0x01) tempax = 0x5000; - } - temp = (tempax & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4d,temp); - } - } } - tempbx &= 0x00FF; + tempbx = 0; if(!(modeflag & HalfDCLK)) { - tempcx = SiS_Pr->SiS_VGAHDE; - if(tempcx >= SiS_Pr->SiS_HDE) { - tempbx |= 0x2000; - tempax &= 0x00FF; - } + if(SiS_Pr->SiS_VGAHDE >= SiS_Pr->SiS_HDE) { + tempax = 0; + tempbx |= 0x2000; + } } tempcx = 0x0101; -/*if(SiS_Pr->SiS_VBInfo & (SetPALTV | SetCRT2ToTV)) { */ /*301b- TW: BIOS BUG? */ - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) { - if(!(SiS_Pr->SiS_HiVision & 0x03)) { - if(SiS_Pr->SiS_VGAHDE >= 1024) { - if((!(modeflag & HalfDCLK)) || (HwDeviceExtension->jChipType < SIS_315H)) { /* TW: This check not in 630/301B */ - tempcx = 0x1920; - if(SiS_Pr->SiS_VGAHDE >= 1280) { - tempcx = 0x1420; - tempbx &= 0xDFFF; - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_VGAHDE >= 1024) { + if((!(modeflag & HalfDCLK)) || (HwInfo->jChipType < SIS_315H)) { + tempcx = 0x1920; + if(SiS_Pr->SiS_VGAHDE >= 1280) { + tempcx = 0x1420; + tempbx &= ~0x2000; + } } - } - } + } } if(!(tempbx & 0x2000)) { - if(modeflag & HalfDCLK) { - tempcx = (tempcx & 0xFF00) | (((tempcx & 0x00FF) << 1) & 0xff); - } - push1 = tempbx; - tempeax = SiS_Pr->SiS_VGAHDE; - tempebx = (tempcx & 0xFF00) >> 8; - longtemp = tempeax * tempebx; - tempecx = tempcx & 0x00FF; - longtemp /= tempecx; - longtemp <<= 0x0d; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(modeflag & HalfDCLK) { + tempcx = (tempcx & 0xFF00) | ((tempcx << 1) & 0x00FF); + } + longtemp = (SiS_Pr->SiS_VGAHDE * ((tempcx & 0xFF00) >> 8)) / (tempcx & 0x00FF); + longtemp <<= 13; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { longtemp <<= 3; - } - tempecx = SiS_Pr->SiS_HDE; - temp2 = longtemp % tempecx; - tempeax = longtemp / tempecx; - if(temp2 != 0) tempeax++; - tempax = (USHORT)tempeax; - tempbx = push1; - tempcx = (tempcx & 0xff00) | (((tempax & 0xFF00) >> 8) >> 5); - tempbx |= (tempax & 0x1F00); - tempax = ((tempax & 0x00FF) << 8) | (tempax & 0x00FF); + } + tempeax = longtemp / SiS_Pr->SiS_HDE; + if(longtemp % SiS_Pr->SiS_HDE) tempeax++; + tempax = (USHORT)tempeax; + tempbx |= (tempax & 0x1F00); + tempcx = (tempax & 0xFF00) >> (8 + 5); } - temp = (tempax & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x44,temp); - temp = (tempbx & 0xFF00) >> 8; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x44,tempax); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,(tempbx >> 8)); if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - temp = tempcx & 0x00FF; - if(tempbx & 0x2000) temp = 0; - temp |= 0x18; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x46,0xE0,temp); - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - tempbx = 0x0382; - tempcx = 0x007e; - } else { - tempbx = 0x0369; - tempcx = 0x0061; - } - temp = (tempbx & 0x00FF) ; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4B,temp); - temp = (tempcx & 0x00FF) ; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4C,temp); - tempbx &= 0x03FF; - temp = (tempcx & 0xFF00) >> 8; - temp = (temp & 0x0003) << 2; - temp |= (tempbx >> 8); - if(HwDeviceExtension->jChipType < SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4D,temp); - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4D,0xF0,temp); - } - temp = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x43); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,(USHORT)(temp - 3)); - } + temp = tempcx & 0x0007; + if(tempbx & 0x2000) temp = 0; + if((HwInfo->jChipType < SIS_661) || (!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD))) { + temp |= 0x18; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x46,0xE0,temp); + + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + tempbx = 0x0382; + tempcx = 0x007e; + } else { + tempbx = 0x0369; + tempcx = 0x0061; + } + temp = (tempbx & 0x00FF) ; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4B,temp); + temp = (tempcx & 0x00FF) ; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4C,temp); + temp = (tempcx & 0x0300) >> (8 - 2); + temp |= ((tempbx >> 8) & 0x03); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + temp |= 0x10; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) temp |= 0x20; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) temp |= 0x40; + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4D,temp); - temp = 0; - if((HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730)) { - temp = 0x35; - } else if(HwDeviceExtension->jChipType >= SIS_315H) { - temp = 0x38; - } - if(temp) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,temp) & EnablePALM) { /* 0x40 */ - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xEF); - temp = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x01); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,temp - 1); - } - } - } - } + temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,(USHORT)(temp - 3)); + + SiS_SetTVSpecial(SiS_Pr, ModeNo); + + if(SiS_Pr->SiS_VBType & VB_SIS301C) { + temp = 0; + if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 8; + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4e,0xf7,temp); + } - if( (SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0B,0x00); - } } - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_Set300Part2Regs(SiS_Pr, HwDeviceExtension, ModeIdIndex, - RefreshRateTableIndex, BaseAddr, ModeNo); - return; + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + if(!(SiS_Pr->SiS_TVMode & TVSetNTSC1024)) { + temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x01); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp - 1); } - } else { - /* TW: !!! The following is a duplicate, done for LCDA as well (see above) */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((ModeNo == 0x4a) || (ModeNo == 0x38)) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1c,0xa7); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1d,0x07); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1e,0xf2); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1f,0x6e); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x20,0x17); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x21,0x8b); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x22,0x73); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,0x53); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,0x13); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x25,0x40); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x26,0x34); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,0xf4); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x28,0x63); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x29,0xbb); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2a,0xcc); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2b,0x7a); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2c,0x58); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2d,0xe4); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2e,0x73); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,0xda); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0x13); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,0x72); - } - } - } - } - return; + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xEF); + } + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0B,0x00); } } - /* TW: From here: Part2 LCD setup */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) return; + + /* From here: Part2 LCD setup */ tempbx = SiS_Pr->SiS_HDE; - if(HwDeviceExtension->jChipType >= SIS_315H) { - /* TW: 650/30xLV 1.10.6s */ - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempbx >>= 1; - } - tempbx--; /* RHACTE=HDE-1 */ + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + tempbx--; /* RHACTE = HDE - 1 */ temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2C,temp); - temp = (tempbx & 0xFF00) >> 8; - temp <<= 4; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2C,temp); + temp = (tempbx & 0xFF00) >> 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,temp); temp = 0x01; if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(SiS_Pr->SiS_ModeType == ModeEGA) { - if(SiS_Pr->SiS_VGAHDE >= 1024) { - temp = 0x02; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - temp = 0x01; + if(SiS_Pr->SiS_ModeType == ModeEGA) { + if(SiS_Pr->SiS_VGAHDE >= 1024) { + temp = 0x02; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + temp = 0x01; + } } - } - } - } + } + } } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0B,temp); - - tempbx = SiS_Pr->SiS_VDE; /* RTVACTEO=(VDE-1)&0xFF */ - push1 = tempbx; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0B,temp); - tempbx--; + tempbx = SiS_Pr->SiS_VDE - 1; temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x03,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x03,temp); temp = ((tempbx & 0xFF00) >> 8) & 0x07; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0C,0xF8,temp); - tempcx = SiS_Pr->SiS_VT; - push2 = tempcx; + tempcx = SiS_Pr->SiS_VT - 1; + temp = tempcx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x19,temp); - tempcx--; - temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x19,temp); + temp = ((tempcx & 0xFF00) >> 8) << 5; - temp = (tempcx & 0xFF00) >> 8; - temp <<= 5; - - /* Enable dithering; newer versions only do this for 32bpp mode */ - if((HwDeviceExtension->jChipType == SIS_300) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) temp |= 0x10; - } else if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp |= 0x10; - else { - if(SiS_Pr->SiS_LCDInfo & LCDSync) /* TW: 630/301 BIOS checks this */ - temp |= 0x10; - } - } else { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - /* TW: 650/30xLV 1.10.6s */ - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { /* 32bpp mode? */ - temp |= 0x10; - } - } - } else { - temp |= 0x10; - } + /* Enable dithering; only do this for 32bpp mode */ + if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { + temp |= 0x10; + } } - /* 630/301 does not do all this */ + /* Must do special for Compaq1280; Acer1280 OK, Clevo1400 OK, COMPAL1400 OK */ + /* Compaq1280 panel loses sync if using CR37 sync info. */ if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - if((HwDeviceExtension->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { - /* TW: 650/30xLV 1.10.6s */ - temp |= (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37) >> 6); - temp |= 0x08; /* From 1.10.7w */ - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) temp |= 0x04; /* From 1.10.7w */ + if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024)) { + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + temp |= ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6); + } + } else if((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050)) { + temp |= 0x03; + } else { + temp |= (SiS_GetReg(SiS_Pr->SiS_P3d4,0x37) >> 6); + temp |= 0x08; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) temp |= 0x04; + } } else { - tempbx = (tempbx & 0xFF00) | (SiS_Pr->SiS_LCDInfo & 0x0FF); - if(tempbx & LCDSync) { - tempbx &= 0xFFE0; - tempbx = (tempbx & 0xFF00) | ((tempbx & 0x00FF) >> 6); - temp |= (tempbx & 0x00FF); - } + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + temp |= ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6); + } } } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1A,temp); + + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1A,temp); SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x09,0xF0); SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x0A,0xF0); @@ -7595,24 +7746,132 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x17,0xFB); SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x18,0xDF); - /* 1280x960, 1280x1024 and 1600x1200 data invalid/missing in tables, use old calculation */ - if((HwDeviceExtension->jChipType >= SIS_315H) && - (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && - (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) && - (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) && - (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960)) { - -#ifdef SIS315H /* ------------- 310/325/330 series ------------ */ - - /* TW: Inserted this entire section from 650/301LV(x) BIOS */ - - /* Using this on the 301B with an auto-expanding 1024 panel (CR37=1) results - * in a black bar in modes < 1024; if the panel is non-expanding, the bridge - * scales all modes to 1024. All modes in both variants (exp/non-exp) work. +#if 0 /* Use the 315/330 series code for now */ + if((HwInfo->jChipType >= SIS_661) && + (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && + (ROMAddr && SiS_Pr->SiS_UseROM)) { + + /* This is done for the LVDS bridges only, since + * the TMDS panels already work correctly with + * the old code. Besides, we only do that if + * we can get the data from the ROM, I am tired + * of carrying a lot of tables around. */ - SiS_GetCRT2Part2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&resindex); +#ifdef SIS315H /* ------------ 661/741/760 series --------- */ + UCHAR *myptr = NULL, myptr1 = NULL; + + myptr = (UCHAR *)GetLCDPtr661(SiS_Pr, HwInfo, 6, ModeNo, ModeIdIndex, RefreshRateTableIndex); + myptr1 = (UCHAR *)GetLCDStructPtr661(SiS_Pr, HwInfo); + + tempbx = (myptr[3] | (myptr[4] << 8)) & 0x0fff; + tempcx = SiS_Pr->PanelYRes; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + tempcx = SiS_Pr->SiS_VDE; + } + + tempcx += tempbx; + if(tempcx >= SiS_Pr->SiS_VT) tempcx -= SiS_Pr->SiS_VT; + + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,tempbx); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,tempcx); + + tempcx &= 0x07ff; + tempbx &= 0x07ff; + temp = (tempcx >> 8) << 3; + temp |= (tempbx >> 8); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp); + + tempbx = (myptr[4] | (myptr[5] << 8)) >> 4; + tempcx = myptr1[6]; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempcx = myptr[7]; + + tempcx += tempbx; + if(tempcx >= SiS_Pr->SiS_VT) tempcx -= SiS_Pr->SiS_VT; + + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,tempbx); + temp = tempcx & 0x000f; + temp |= ((tempbx & 0x0f00) >> 4); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); + + tempax = SiS_Pr->SiS_HT; + tempbx = (myptr[0] | (myptr[1] << 8)) & 0x0fff; + tempcx = SiS_Pr->PanelXRes; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempcx = SiS_Pr->SiS_HDE; + + if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + tempax >>= 1; + tempbx >>= 1; + tempcx >>= 1; + } + if(SiS_Pr->SiS_VBType & VB_SIS302LV) tempbx++; + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) tempbx++; + + tempcx += tempbx; + if(tempcx >= tempax) tempcx -= tempax; + + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1f,tempbx); + temp = ((tempbx & 0xff00) >> 8) << 4; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x20,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,tempcx); + temp = tempcx >> 8; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x25,temp); + + tempax = SiS_Pr->SiS_HT; + tempbx = (myptr[1] | (myptr[2] << 8)) >> 4; + tempcx = myptr1[5]; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + tempcx = myptr[6]; + } + if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + tempax >>= 1; + tempbx >>= 1; + tempcx >>= 1; + } + if(SiS_Pr->SiS_VBType & VB_SIS302LV) tempbx++; + + tempcx += tempbx; + if(tempcx >= tempax) tempcx -= tempax; + + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1c,tempbx); + temp = (tempbx & 0x0f00) >> 4; + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1d,0x0f,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,tempcx); + + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + if(SiS_Pr->SiS_VGAVDE == 525) { + temp = 0xc3; + if(SiS_Pr->SiS_ModeType <= ModeVGA) { + temp++; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp += 2; + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,0xb3); + } else if(SiS_Pr->SiS_VGAVDE == 420) { + temp = 0x4d; + if(SiS_Pr->SiS_ModeType <= ModeVGA) { + temp++; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp++; + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); + } + } + +#endif + + } else +#endif + if((HwInfo->jChipType >= SIS_315H) && + (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && + ((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) ) { + +#ifdef SIS315H /* ------------- 315/330 series ------------ */ + + SiS_GetCRT2Part2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + &CRT2Index, &resindex, HwInfo); switch(CRT2Index) { case Panel_1024x768 : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; break; /* "Normal" */ @@ -7627,21 +7886,28 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR case Panel_1280x1024 + 32: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1280x1024_3; break; case Panel_1400x1050 + 32: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1400x1050_3; break; case Panel_1600x1200 + 32: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1600x1200_3; break; + case 100: CRT2Part2Ptr = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_Compaq1280x1024_1; break; /* Custom */ + case 101: CRT2Part2Ptr = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_Compaq1280x1024_2; break; + case 102: CRT2Part2Ptr = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_Compaq1280x1024_3; break; + case 103: CRT2Part2Ptr = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_Clevo1024x768_1; break; /* Custom */ + case 104: CRT2Part2Ptr = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_Clevo1024x768_2; break; + case 105: CRT2Part2Ptr = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_Clevo1024x768_3; break; + case 106: CRT2Part2Ptr = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_Asus1024x768_3; break; default: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_3; break; } SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]); for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); } for(j = 0x1c; j <= 0x1d; i++, j++ ) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); } for(j = 0x1f; j <= 0x21; i++, j++ ) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]); if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { @@ -7651,27 +7917,24 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR temp++; if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp += 2; } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0xb3); - } - if(SiS_Pr->SiS_VGAVDE == 420) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,0xb3); + } else if(SiS_Pr->SiS_VGAVDE == 420) { temp = 0x4d; if(SiS_Pr->SiS_ModeType <= ModeVGA) { temp++; if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp++; } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); } } - /* TW: 650/30xLV 1.10.6s: */ - /* !!! This is a duplicate, done for LCDA as well - see above */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xfc,0x03); /* Not done in 1.10.7w */ + /* See Sync above, 0x1a */ temp = 1; if(ModeNo <= 0x13) temp = 3; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0b,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0b,temp); } } #endif @@ -7679,401 +7942,459 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR } else { /* ------ 300 series and other bridges, other LCD resolutions ------ */ /* Using this on the 301B with an auto-expanding 1024 panel (CR37=1) makes - * the panel scale at modes < 1024 (no black bars); if the panel is non-expanding, + * the panel scale at modes < 1024 (no black bars); if the panel is non-expanding, * the bridge scales all modes to 1024. * !!! Malfunction at 640x480 and 640x400 when panel is auto-expanding - black screen !!! */ - - tempcx++; - - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx = 768; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempbx = 1024; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 1200; - else if(SiS_Pr->SiS_VDE != 1024) tempbx = 960; - else tempbx = 1024; - -#if 0 /* old */ - tempbx = 768; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1024x768) { - tempbx = 1024; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) { - tempbx = 1200; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) { - if(tempbx != SiS_Pr->SiS_VDE) { - tempbx = 960; - } - } - } - } -#endif - + + tempcx = SiS_Pr->SiS_VT; + tempbx = SiS_Pr->PanelYRes; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - tempbx = SiS_Pr->SiS_VDE - 1; - tempcx--; + tempbx = SiS_Pr->SiS_VDE - 1; + tempcx--; } - + tempax = 1; if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - if(tempbx != SiS_Pr->SiS_VDE) { - tempax = tempbx; -/* if(SiS_Pr->SiS_VGAVDE == 525) tempax += 60; in 650/301B BIOS */ - if(tempax < SiS_Pr->SiS_VDE) { - tempax = 0; - tempcx = 0; - } else { - tempax -= SiS_Pr->SiS_VDE; - } - tempax >>= 1; - } - tempcx -= tempax; /* lcdvdes */ - tempbx -= tempax; /* lcdvdee */ - } else { - tempax >>= 1; - tempcx -= tempax; /* lcdvdes */ - tempbx -= tempax; /* lcdvdee */ + if(tempbx != SiS_Pr->SiS_VDE) { + tempax = tempbx; + if(tempax < SiS_Pr->SiS_VDE) { + tempax = 0; + tempcx = 0; + } else { + tempax -= SiS_Pr->SiS_VDE; + } + tempax >>= 1; + } + tempcx -= tempax; /* lcdvdes */ + tempbx -= tempax; /* lcdvdee */ } - + + /* Non-expanding: lcdvdees = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */ + #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "lcdvds 0x%x lcdvde 0x%x\n", tempcx, tempbx); -#endif + xf86DrvMsg(0, X_INFO, "lcdvdes 0x%x lcdvdee 0x%x\n", tempcx, tempbx); +#endif temp = tempcx & 0x00FF; /* RVEQ1EQ=lcdvdes */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,temp); temp = tempbx & 0x00FF; /* RVEQ2EQ=lcdvdee */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,temp); temp = ((tempbx & 0xFF00) >> 8) << 3; temp |= ((tempcx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp); - tempbx = push2; - tempax = push1; - tempcx = tempbx; - tempcx -= tempax; - tempcx >>= 4; + tempbx = SiS_Pr->SiS_VT; /* push2; */ + tempax = SiS_Pr->SiS_VDE; /* push1; */ + tempcx = (tempbx - tempax) >> 4; tempbx += tempax; tempbx >>= 1; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx -= 10; - + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx -= 10; + + /* non-expanding: lcdvrs = tempbx = ((VT + VDE) / 2) - 10 */ + + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CVSyncStart; + } + #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdvrs 0x%x\n", tempbx); #endif - temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,temp); + temp = tempbx & 0x00FF; /* RTVACTEE = lcdvrs */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,temp); temp = ((tempbx & 0xFF00) >> 8) << 4; tempbx += (tempcx + 1); temp |= (tempbx & 0x000F); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,temp); - /* TW: Code from 630/301B (I+II) BIOS */ - - if( ( ( (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) ) && - (HwDeviceExtension->jChipRevision > 2) ) && - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) && - (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) && - (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) { - if(ModeNo == 0x13) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,0xB9); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,0xCC); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xA6); - } else { - if((crt2crtc & 0x3F) == 4) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x2B); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x13); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,0xE5); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,0x08); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xE2); - } - } + if(SiS_Pr->UseCustomMode) { + temp &= 0xf0; + temp |= (SiS_Pr->CVSyncEnd & 0x0f); } - /* TW: Inserted missing code from 630/301B BIOS; - * Strangely, this is done in all 650 BIOSes as - * well (although LCDTypeInfo is not used there - * in the same way as on 300 series) - */ +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "lcdvre[3:0] 0x%x\n", (temp & 0x0f)); +#endif - if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) { - crt2crtc &= 0x1f; - tempcx = 0; - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { - if (SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - tempcx += 7; - } - } - tempcx += crt2crtc; - if (crt2crtc >= 4) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xff); - } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(crt2crtc == 4) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x28); + /* Code from 630/301B (I+II) BIOS */ + +#ifdef SIS300 + if(!SiS_Pr->UseCustomMode) { + if( ( ( (HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730) ) && + (HwInfo->jChipRevision > 2) ) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) && + (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) && + (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) { + if(ModeNo == 0x13) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xB9); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0xCC); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xA6); + } else { + if((crt2crtc & 0x3F) == 4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x2B); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x13); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xE5); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0x08); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xE2); } - } - } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x18); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]); + } + } + + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) { + crt2crtc &= 0x1f; + tempcx = 0; + if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + tempcx += 7; + } + } + tempcx += crt2crtc; + if(crt2crtc >= 4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xff); + } + + if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(crt2crtc == 4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x28); + } + } + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x18); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]); + } + } } +#endif - tempcx = (SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE) >> 2; /* (HT-HDE)>>2 */ + tempcx = (SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE) >> 2; /* (HT - HDE) >> 2 */ tempbx = SiS_Pr->SiS_HDE + 7; /* lcdhdee */ if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - tempbx += 2; + tempbx += 2; } push1 = tempbx; + #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "lcdhde 0x%x\n", tempbx); -#endif - temp = tempbx & 0x00FF; /* RHEQPLE=lcdhdee */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,temp); + xf86DrvMsg(0, X_INFO, "lcdhdee 0x%x\n", tempbx); +#endif + + temp = tempbx & 0x00FF; /* RHEQPLE = lcdhdee */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,temp); temp = (tempbx & 0xFF00) >> 8; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0xF0,temp); temp = 7; if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - temp += 2; + temp += 2; } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1F,temp); /* RHBLKE=lcdhdes[7:0] */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1F,temp); /* RHBLKE = lcdhdes[7:0] */ SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x20,0x0F); /* lcdhdes [11:8] */ tempbx += tempcx; push2 = tempbx; + + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CHSyncStart + 7; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + tempbx += 2; + } + } + #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdhrs 0x%x\n", tempbx); #endif - temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - if(SiS_Pr->SiS_HDE == 1280) temp = 0x47; + + temp = tempbx & 0x00FF; /* RHBURSTS = lcdhrs */ + if(!SiS_Pr->UseCustomMode) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->SiS_HDE == 1280) temp = 0x47; + } } } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1C,temp); - temp = ((tempbx & 0xFF00) >> 8) << 4; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1C,temp); + temp = (tempbx & 0x0F00) >> 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,temp); tempbx = push2; tempcx <<= 1; tempbx += tempcx; + + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CHSyncEnd + 7; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + tempbx += 2; + } + } + #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdhre 0x%x\n", tempbx); -#endif - temp = tempbx & 0x00FF; /* RHSYEXP2S=lcdhre */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x21,temp); +#endif + + temp = tempbx & 0x00FF; /* RHSYEXP2S = lcdhre */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,temp); if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if(SiS_Pr->SiS_VGAVDE == 525) { - if(SiS_Pr->SiS_ModeType <= ModeVGA) - temp=0xC6; - else - temp=0xC3; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0xB3); - } else if(SiS_Pr->SiS_VGAVDE == 420) { - if(SiS_Pr->SiS_ModeType <= ModeVGA) - temp=0x4F; - else - temp=0x4D; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp); - } + if(SiS_Pr->SiS_VGAVDE == 525) { + if(SiS_Pr->SiS_ModeType <= ModeVGA) + temp=0xC6; + else + temp=0xC3; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,0xB3); + } else if(SiS_Pr->SiS_VGAVDE == 420) { + if(SiS_Pr->SiS_ModeType <= ModeVGA) + temp=0x4F; + else + temp=0x4D; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); + } } - SiS_Set300Part2Regs(SiS_Pr, HwDeviceExtension, ModeIdIndex, - RefreshRateTableIndex, BaseAddr, ModeNo); - - } /* HwDeviceExtension */ -} -USHORT -SiS_GetVGAHT2(SiS_Private *SiS_Pr) -{ - ULONG tempax,tempbx; +#ifdef SIS300 + SiS_Set300Part2Regs(SiS_Pr, HwInfo, ModeIdIndex, + RefreshRateTableIndex, ModeNo); +#endif - tempbx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) * SiS_Pr->SiS_RVBHCMAX) & 0xFFFF; - tempax = (SiS_Pr->SiS_VT - SiS_Pr->SiS_VDE) * SiS_Pr->SiS_RVBHCFACT; - tempax = (tempax * SiS_Pr->SiS_HT) / tempbx; - return((USHORT) tempax); + } /* HwInfo */ } -/* TW: New from 300/301LV BIOS 1.16.51 for ECS A907. Seems highly preliminary. */ -void -SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeIdIndex, USHORT RefreshRateTableIndex, - USHORT BaseAddr, USHORT ModeNo) +/*********************************************/ +/* SET PART 3 REGISTER GROUP */ +/*********************************************/ + +static void +SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { - USHORT crt2crtc, resindex; - int i,j; - const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; + USHORT modeflag, i; + const UCHAR *tempdi; - if(HwDeviceExtension->jChipType != SIS_300) return; - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; if(ModeNo<=0x13) { - crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; } else { - crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } } - resindex = crt2crtc & 0x3F; - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; - else CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_2; +#ifndef SIS_CP + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x00,0x00); +#endif - /* TW: The BIOS code (1.16.51) is obviously a fragment! */ - if(ModeNo > 0x13) { - CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; - resindex = 4; +#ifdef SIS_CP + SIS_CP_INIT301_CP +#endif + + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xFA); + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xC8); + } else { + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xF5); + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xB7); } - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]); - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]); - for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xFA); + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xC8); + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x3D,0xA8); } - for(j = 0x1c; j <= 0x1d; i++, j++ ) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + + tempdi = NULL; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + tempdi = SiS_Pr->SiS_HiTVGroup3Data; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + tempdi = SiS_Pr->SiS_HiTVGroup3Simu; +#if 0 + if(!(modeflag & Charx8Dot)) { + tempdi = SiS_Pr->SiS_HiTVGroup3Text; + } +#endif + } + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(!(SiS_Pr->SiS_TVMode & TVSetYPbPr525i)) { + tempdi = SiS_HiTVGroup3_1; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempdi = SiS_HiTVGroup3_2; + } } - for(j = 0x1f; j <= 0x21; i++, j++ ) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + if(tempdi) { + for(i=0; i<=0x3E; i++){ + SiS_SetReg(SiS_Pr->SiS_Part3Port,i,tempdi[i]); + } + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x28,0x3f); + } + } } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]); - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]); -} - -/* TW: Set 301 Macrovision(tm) registers */ -void -SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp; - USHORT i; - const UCHAR *tempdi; - USHORT modeflag; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; + if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToHiVision | SetCRT2ToYPbPr525750))) { +#ifdef SIS_CP + SIS_CP_INIT301_CP2 +#endif + } +} - if(ModeNo<=0x13) - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - else - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; +/*********************************************/ +/* SET PART 4 REGISTER GROUP */ +/*********************************************/ - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x00,0x00); +#ifdef SIS315H +static void +SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT temp, temp1; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xFA); - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xC8); - } else { - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xF5); - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xB7); - } else { - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xF6); - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xBf); - } - } + if(!(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV))) return; - temp = 0; - if((HwDeviceExtension->jChipType == SIS_630)|| - (HwDeviceExtension->jChipType == SIS_730)) { - temp = 0x35; - } else if(HwDeviceExtension->jChipType >= SIS_315H) { - temp = 0x38; - } - if(temp) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,temp) & EnablePALM){ /* 0x40 */ - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xFA); - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xC8); - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x3D,0xA8); - } - } + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x3a,0x08); + temp = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x3a); + if(!(temp & 0x01)) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3a,0xdf); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xfc); + if(HwInfo->jChipType < SIS_661) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xf8); + } + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x0f,0xfb); + temp = 0; + if(!(SiS_Pr->SiS_TVMode & TVSetYPbPr750p)) { + temp |= 0x0002; + if(!(SiS_Pr->SiS_TVMode & TVSetYPbPr525p)) { + temp ^= 0x0402; + if(!(SiS_Pr->SiS_TVMode & TVSetHiVision)) { + temp ^= 0x0002; + } + } } - } + if(HwInfo->jChipType >= SIS_661) { + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x39); + if(temp1 & 0x01) temp |= 0x10; + if(temp1 & 0x02) temp |= 0x01; + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xec,(temp & 0xff)); + } else { + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x3b) & 0x03; + if(temp1 == 0x01) temp |= 0x01; + if(temp1 == 0x03) temp |= 0x04; /* ? why not 0x10? */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xea,(temp & 0xff)); + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8)); + } +} +#endif + +static void +SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +{ + USHORT vclkindex; + USHORT temp, reg1, reg2; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - tempdi = SiS_Pr->SiS_HiTVGroup3Data; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - tempdi = SiS_Pr->SiS_HiTVGroup3Simu; - if(!(modeflag & Charx8Dot)) { - tempdi = SiS_Pr->SiS_HiTVGroup3Text; - } - } - if(SiS_Pr->SiS_HiVision & 0x03) { - tempdi = SiS_HiTVGroup3_1; - if(SiS_Pr->SiS_HiVision & 0x02) tempdi = SiS_HiTVGroup3_2; - } - for(i=0; i<=0x3E; i++){ - SiS_SetReg1(SiS_Pr->SiS_Part3Port,i,tempdi[i]); - } + if(SiS_Pr->UseCustomMode) { + reg1 = SiS_Pr->CSR2B; + reg2 = SiS_Pr->CSR2C; + } else { + vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + HwInfo); + reg1 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A; + reg2 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B; } - return; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,0x57); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,0x46); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1f,0xf6); + } else { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,reg1); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,reg2); + } + } else { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,0x01); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,reg2); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,reg1); + } + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x12,0x00); + temp = 0x08; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) temp |= 0x20; + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x12,temp); } -/* TW: Set 301 VGA2 registers */ -void -SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex,USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +/* Set 301 VGA2 registers */ +static void +SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { USHORT tempax,tempcx,tempbx,modeflag,temp,temp2,resinfo; ULONG tempebx,tempeax,templong; - - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; } else { + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + resinfo = 0; + } else { modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } } - if(HwDeviceExtension->jChipType >= SIS_315H) { - /* TW: From 650/302LV 1.10.6s (not for 300/301LV - no LCDA on this combination) */ + if(HwInfo->jChipType >= SIS_315H) { if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x24,0x0e); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); } } } - if(SiS_Pr->SiS_VBType & VB_SIS302LV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f); - } + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV)) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f); + } } - if(HwDeviceExtension->jChipType >= SIS_315H) { + if(HwInfo->jChipType >= SIS_315H) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - /* TW: From 650/301LV (any, incl. 1.10.6s, 1.10.7w) */ - /* TW: This is a duplicate; done at the end, too */ - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); - } - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); + if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); + } +#ifdef SET_EMI + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + } +#endif } return; } } temp = SiS_Pr->SiS_RVBHCFACT; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x13,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x13,temp); tempbx = SiS_Pr->SiS_RVBHCMAX; temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x14,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x14,temp); temp2 = (((tempbx & 0xFF00) >> 8) << 7) & 0x00ff; tempcx = SiS_Pr->SiS_VGAHT - 1; temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x16,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x16,temp); temp = (((tempcx & 0xFF00) >> 8) << 3) & 0x00ff; temp2 |= temp; @@ -8082,47 +8403,46 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHOR if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempcx -= 5; temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x17,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x17,temp); temp = temp2 | ((tempcx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x15,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x15,temp); tempbx = SiS_Pr->SiS_VGAHDE; if(modeflag & HalfDCLK) tempbx >>= 1; + if(HwInfo->jChipType >= SIS_661) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + } - /* TW: New for 650/301LV and 630/301B */ temp = 0xA0; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - temp = 0; - if(tempbx > 800) { - temp = 0xA0; - if(tempbx != 1024) { - temp = 0xC0; - if(tempbx != 1280) temp = 0; - } - } - } else - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(tempbx <= 800) { - temp = 0x80; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - temp = 0; - if(tempbx > 800) temp = 0x60; - } - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + temp = 0; + if(tempbx > 800) { + temp = 0xA0; + if(tempbx != 1024) { + temp = 0xC0; + if(tempbx != 1280) temp = 0; + } + } + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(tempbx <= 800) { + temp = 0x80; + } } else { - temp = 0x80; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - temp = 0; - if(tempbx > 800) temp = 0x60; - } - } - if(SiS_Pr->SiS_HiVision & 0x03) { + temp = 0x80; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { temp = 0; - if(SiS_Pr->SiS_VGAHDE == 1024) temp = 0x20; + if(tempbx > 800) temp = 0x60; + } + } + + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { + temp = 0; + if(SiS_Pr->SiS_VGAHDE == 1024) temp = 0x20; } - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) temp = 0; + + if(HwInfo->jChipType < SIS_661) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) temp = 0; } if(SiS_Pr->SiS_VBType & VB_SIS301) { @@ -8134,20 +8454,20 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHOR tempebx = SiS_Pr->SiS_VDE; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { if(!(temp & 0xE0)) tempebx >>=1; } tempcx = SiS_Pr->SiS_RVBHRS; temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x18,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x18,temp); tempeax = SiS_Pr->SiS_VGAVDE; tempcx |= 0x4000; - if(tempeax <= tempebx){ - tempcx ^= 0x4000; + if(tempeax <= tempebx) { + tempcx ^= 0x4000; } else { - tempeax -= tempebx; + tempeax -= tempebx; } templong = (tempeax * 256 * 1024) % tempebx; @@ -8156,446 +8476,153 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHOR if(templong != 0) tempebx++; temp = (USHORT)(tempebx & 0x000000FF); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1B,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1B,temp); temp = (USHORT)((tempebx & 0x0000FF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1A,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1A,temp); tempbx = (USHORT)(tempebx >> 16); temp = tempbx & 0x00FF; temp <<= 4; temp |= ((tempcx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x19,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x19,temp); if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1C,0x28); - tempbx = 0; - tempax = SiS_Pr->SiS_VGAHDE; - if(modeflag & HalfDCLK) tempax >>= 1; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) || (SiS_Pr->SiS_HiVision & 0x03)) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempax >>= 1; - else if(tempax > 800) tempax -= 800; - } else { - if(tempax > 800) tempax -= 800; - } - } - -/* if((SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetPALTV)) && (!(SiS_Pr->SiS_HiVision & 0x03))) { */ - if((SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) && (!(SiS_Pr->SiS_HiVision & 0x03))) { - if(tempax > 800) { - tempbx = 8; - if(tempax == 1024) - tempax *= 25; - else - tempax *= 20; - - temp = tempax % 32; - tempax /= 32; - tempax--; - if (temp!=0) tempax++; - } - } - tempax--; - temp = (tempax & 0xFF00) >> 8; - temp &= 0x03; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* From 1.10.7w */ - if(ModeNo > 0x13) { /* From 1.10.7w */ - if(resinfo == 8) tempax = 0x1f; /* From 1.10.7w */ - } /* From 1.10.7w */ - } /* From 1.10.7w */ - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1D,tempax & 0x00FF); - temp <<= 4; - temp |= tempbx; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1E,temp); - - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(IS_SIS650740) { - temp = 0x0026; /* 1.10.7w; 1.10.8r; needs corresponding code in Dis/EnableBridge! */ - } else { - temp = 0x0036; - } - } else { - temp = 0x0036; - } - if((SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) && - (!(SiS_Pr->SiS_HiVision & 0x03))) { - temp |= 0x01; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(!(SiS_Pr->SiS_SetFlag & TVSimuMode)) - temp &= 0xFE; - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0,temp); - - tempbx = SiS_Pr->SiS_HT; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempbx >>= 1; - } - tempbx >>= 1; - tempbx -= 2; - temp = ((tempbx & 0x0700) >> 8) << 3; - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp); - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x22,temp); - - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x24,0x0e); - } - } - - if(HwDeviceExtension->jChipType >= SIS_315H) { - /* TW: 650/LV BIOS does this for all bridge types - assumingly wrong */ - /* 315, 330, 650+301B BIOS don't do this at all */ - /* TW: This is a duplicate; done for LCDA as well (see above) */ - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); - } - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); - } - } else if(HwDeviceExtension->jChipType == SIS_300) { - /* TW: 300/301LV BIOS does this for all bridge types - assumingly wrong */ - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); - } - } - - } /* 301B */ - - SiS_SetCRT2VCLK(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); -} - + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1C,0x28); -void -SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT vclkindex; - USHORT tempah; - - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); + tempbx = 0; + tempax = SiS_Pr->SiS_VGAHDE; + if(modeflag & HalfDCLK) tempax >>= 1; + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempax >>= 1; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(tempax > 800) tempax -= 800; + } else { + if(tempax > 800) { + tempbx = 8; + if(tempax == 1024) + tempax *= 25; + else + tempax *= 20; + + temp = tempax % 32; + tempax /= 32; + tempax--; + if (temp!=0) tempax++; + } + } + tempax--; + temp = ((tempax & 0xFF00) >> 8) & 0x03; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* From 1.10.7w */ + if(ModeNo > 0x13) { /* From 1.10.7w */ + if(resinfo == SIS_RI_1024x768) tempax = 0x1f; /* From 1.10.7w */ + } /* From 1.10.7w */ + } /* From 1.10.7w */ + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1D,tempax & 0x00FF); + temp <<= 4; + temp |= tempbx; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1E,temp); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,tempah); - tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0B,tempah); - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((ModeNo == 0x4a) || (ModeNo == 0x38)) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0a,0x57); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0b,0x46); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1f,0xf6); - } - } - } + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(IS_SIS550650740660) { + temp = 0x0026; /* 1.10.7w; 1.10.8r; needs corresponding code in Dis/EnableBridge! */ + } else { + temp = 0x0036; } + } else { + temp = 0x0036; } - } else { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,0x01); - tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0B,tempah); - tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,tempah); - } - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x12,0x00); - tempah = 0x08; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) tempah |= 0x20; - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x12,tempah); -} - -USHORT -SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT tempbx; - const USHORT LCDXlat0VCLK[4] = {VCLK40, VCLK40, VCLK40, VCLK40}; - const USHORT LVDSXlat1VCLK[4] = {VCLK40, VCLK40, VCLK40, VCLK40}; -#ifdef SIS300 - const USHORT LCDXlat1VCLK300[4] = {VCLK65, VCLK65, VCLK65, VCLK65}; - const USHORT LCDXlat2VCLK300[4] = {VCLK108_2,VCLK108_2,VCLK108_2,VCLK108_2}; - const USHORT LVDSXlat2VCLK300[4]= {VCLK65, VCLK65, VCLK65, VCLK65}; - const USHORT LVDSXlat3VCLK300[4]= {VCLK65, VCLK65, VCLK65, VCLK65}; -#endif -#ifdef SIS315H - const USHORT LCDXlat1VCLK310[4] = {VCLK65+2, VCLK65+2, VCLK65+2, VCLK65+2}; - const USHORT LCDXlat2VCLK310[4] = {VCLK108_2+5,VCLK108_2+5,VCLK108_2+5,VCLK108_2+5}; - const USHORT LVDSXlat2VCLK310[4]= {VCLK65+2, VCLK65+2, VCLK65+2, VCLK65+2}; - const USHORT LVDSXlat3VCLK310[4]= {VCLK108_2+5,VCLK108_2+5,VCLK108_2+5,VCLK108_2+5}; -#endif - USHORT CRT2Index,VCLKIndex=0; - USHORT modeflag,resinfo; - const UCHAR *CHTVVCLKPtr=NULL; - const USHORT *LCDXlatVCLK1 = NULL; - const USHORT *LCDXlatVCLK2 = NULL; - const USHORT *LVDSXlatVCLK2 = NULL; - const USHORT *LVDSXlatVCLK3 = NULL; - - if(HwDeviceExtension->jChipType >= SIS_315H) { -#ifdef SIS315H - LCDXlatVCLK1 = LCDXlat1VCLK310; - LCDXlatVCLK2 = LCDXlat2VCLK310; - LVDSXlatVCLK2 = LVDSXlat2VCLK310; - LVDSXlatVCLK3 = LVDSXlat3VCLK310; -#endif - } else { -#ifdef SIS300 - LCDXlatVCLK1 = LCDXlat1VCLK300; - LCDXlatVCLK2 = LCDXlat2VCLK300; - LVDSXlatVCLK2 = LVDSXlat2VCLK300; - LVDSXlatVCLK3 = LVDSXlat3VCLK300; -#endif - } - - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; - CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - CRT2Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - } - - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { /* 30x/B/LV */ - - if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - - CRT2Index >>= 6; - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)){ /* LCD */ - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) - VCLKIndex = LCDXlat0VCLK[CRT2Index]; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) - VCLKIndex = LCDXlatVCLK1[CRT2Index]; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) - VCLKIndex = LCDXlatVCLK1[CRT2Index]; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) - VCLKIndex = LCDXlatVCLK1[CRT2Index]; - else - VCLKIndex = LCDXlatVCLK2[CRT2Index]; - } else { - /* TW: 330, 650/301LV BIOS does not check expanding, 315 does */ - if( (HwDeviceExtension->jChipType > SIS_315PRO) || - (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - VCLKIndex = 0x19; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - VCLKIndex = 0x19; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { - VCLKIndex = 0x21; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - VCLKIndex = LCDXlatVCLK1[CRT2Index]; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { - VCLKIndex = 0x45; /* TW: in VBVCLK table */ - if(resinfo == 0x09) VCLKIndex++; - } else { - VCLKIndex = LCDXlatVCLK2[CRT2Index]; - } - } else { - VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02)); /* Port 3cch */ - VCLKIndex = ((VCLKIndex >> 2) & 0x03); - if(ModeNo > 0x13) { - VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - } - if(ModeNo <= 0x13) { /* TW: 315 BIOS */ - if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42; - } - if(VCLKIndex == 0) VCLKIndex = 0x41; - if(VCLKIndex == 1) VCLKIndex = 0x43; - if(VCLKIndex == 4) VCLKIndex = 0x44; - } - } - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */ - if( (SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) ) { - if(SiS_Pr->SiS_SetFlag & RPLLDIV2XO) VCLKIndex = HiTVVCLKDIV2; - else VCLKIndex = HiTVVCLK; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - if(modeflag & Charx8Dot) VCLKIndex = HiTVSimuVCLK; - else VCLKIndex = HiTVTextVCLK; - } - } else { - if(SiS_Pr->SiS_SetFlag & RPLLDIV2XO) VCLKIndex = TVVCLKDIV2; - else VCLKIndex = TVVCLK; - } - if(HwDeviceExtension->jChipType >= SIS_315H) { - VCLKIndex += 25; - } - } else { /* RAMDAC2 */ - VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02)); - VCLKIndex = ((VCLKIndex >> 2) & 0x03); - if(ModeNo > 0x13) { - VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - if(HwDeviceExtension->jChipType < SIS_315H) { - VCLKIndex &= 0x3f; - if( (HwDeviceExtension->jChipType == SIS_630) && - (HwDeviceExtension->jChipRevision >= 0x30)) { - if(VCLKIndex == 0x14) VCLKIndex = 0x2e; - } - } - } - } - - } else { /* If not programming CRT2 */ - - VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02)); - VCLKIndex = ((VCLKIndex >> 2) & 0x03); - if(ModeNo > 0x13) { - VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - if(HwDeviceExtension->jChipType < SIS_315H) { - VCLKIndex &= 0x3f; - if( (HwDeviceExtension->jChipType != SIS_630) && - (HwDeviceExtension->jChipType != SIS_300) ) { - if(VCLKIndex == 0x1b) VCLKIndex = 0x35; - } - } - } - } - - } else { /* LVDS */ - - VCLKIndex = CRT2Index; - - if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { /* programming CRT2 */ - - if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { - - VCLKIndex &= 0x1f; - tempbx = 0; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - tempbx += 2; - if(SiS_Pr->SiS_CHSOverScan) tempbx = 8; - if(SiS_Pr->SiS_CHPALM) { - tempbx = 4; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - } else if(SiS_Pr->SiS_CHPALN) { - tempbx = 6; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - } - } - switch(tempbx) { - case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break; - case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break; - case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break; - case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; - case 4: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALM; break; - case 5: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALM; break; - case 6: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALN; break; - case 7: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALN; break; - case 8: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKSOPAL; break; - default: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; - } - VCLKIndex = CHTVVCLKPtr[VCLKIndex]; - - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - - VCLKIndex >>= 6; - if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480)) - VCLKIndex = LVDSXlat1VCLK[VCLKIndex]; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) - VCLKIndex = LVDSXlatVCLK2[VCLKIndex]; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) - VCLKIndex = LVDSXlatVCLK2[VCLKIndex]; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) - VCLKIndex = LVDSXlatVCLK2[VCLKIndex]; - else VCLKIndex = LVDSXlatVCLK3[VCLKIndex]; - - } else { - - VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02)); - VCLKIndex = ((VCLKIndex >> 2) & 0x03); - if(ModeNo > 0x13) { - VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - if(HwDeviceExtension->jChipType < SIS_315H) { - VCLKIndex &= 0x3F; - } - if( (HwDeviceExtension->jChipType == SIS_630) && - (HwDeviceExtension->jChipRevision >= 0x30) ) { - if(VCLKIndex == 0x14) VCLKIndex = 0x2e; - } - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(!(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSetHiVision | TVSetYPbPr750p | TVSetYPbPr525p))) { + temp |= 0x01; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) { + temp &= 0xFE; + } } + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0,temp); - } else { /* if not programming CRT2 */ + tempbx = SiS_Pr->SiS_HT; + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + tempbx >>= 1; + tempbx -= 2; + temp = ((tempbx & 0x0700) >> 8) << 3; + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp); + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x22,temp); - VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02)); - VCLKIndex = ((VCLKIndex >> 2) & 0x03); - if(ModeNo > 0x13) { - VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - if(HwDeviceExtension->jChipType < SIS_315H) { - VCLKIndex &= 0x3F; - if( (HwDeviceExtension->jChipType != SIS_630) && - (HwDeviceExtension->jChipType != SIS_300) ) { - if(VCLKIndex == 0x1b) VCLKIndex = 0x35; - } -#if 0 - if(HwDeviceExtension->jChipType == SIS_730) { - if(VCLKIndex == 0x0b) VCLKIndex = 0x40; /* 1024x768-70 */ - if(VCLKIndex == 0x0d) VCLKIndex = 0x41; /* 1024x768-75 */ - } -#endif - } + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); + /* LCD-too-dark-error-source, see FinalizeLCD() */ + } + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); } - } - - } -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "VCLKIndex %d (0x%x)\n", VCLKIndex, VCLKIndex); +#ifdef SET_EMI + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + } #endif - return (VCLKIndex); + } + + } /* 301B */ + + SiS_SetCRT2VCLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); } -/* TW: Set 301 Palette address port registers */ -/* TW: Checked against 650/301LV BIOS */ -void -SiS_SetGroup5(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr, - UCHAR *ROMAddr, USHORT ModeNo, USHORT ModeIdIndex) +/*********************************************/ +/* SET PART 5 REGISTER GROUP */ +/*********************************************/ + +/* Set 301 Palette address port registers */ +static void +SiS_SetGroup5(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; - if(SiS_Pr->SiS_ModeType == ModeVGA){ - if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))){ + if(SiS_Pr->SiS_ModeType == ModeVGA) { + if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))) { SiS_EnableCRT2(SiS_Pr); - SiS_LoadDAC(SiS_Pr,HwDeviceExtension,ROMAddr,ModeNo,ModeIdIndex); + SiS_LoadDAC(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); } } } -void -SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) +/*********************************************/ +/* MODIFY CRT1 GROUP FOR SLAVE MODE */ +/*********************************************/ + +static void +SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { - USHORT temp,tempah,i,modeflag,j; - USHORT ResInfo,DisplayType; + USHORT tempah,i,modeflag,j; + USHORT ResIndex,DisplayType; const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr=NULL; if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; } - temp = SiS_GetLVDSCRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &ResInfo,&DisplayType); + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || + (SiS_Pr->SiS_CustomT == CUT_PANEL848)) + return; - if(temp == 0) return; + if(!(SiS_GetLVDSCRT1Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + &ResIndex, &DisplayType))) return; - if(HwDeviceExtension->jChipType < SIS_315H) { + if(HwInfo->jChipType < SIS_315H) { if(SiS_Pr->SiS_SetFlag & SetDOSMode) return; } @@ -8639,216 +8666,121 @@ SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCH case 41: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_1_H; break; case 42: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2; break; case 43: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2_H; break; + case 50: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1; break; + case 51: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1_H; break; + case 52: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2; break; + case 53: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2_H; break; + case 54: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3; break; + case 55: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3_H; break; case 99: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1SOPAL; break; default: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; } SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /*unlock cr0-7 */ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[0]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x00,tempah); + tempah = (LVDSCRT1Ptr + ResIndex)->CR[0]; + SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,tempah); for(i=0x02,j=1;i<=0x05;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; + SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); } for(i=0x06,j=5;i<=0x07;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; + SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); } for(i=0x10,j=7;i<=0x11;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; + SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); } for(i=0x15,j=9;i<=0x16;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; + SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); } for(i=0x0A,j=11;i<=0x0C;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,tempah); + tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; + SiS_SetReg(SiS_Pr->SiS_P3c4,i,tempah); } - tempah = (LVDSCRT1Ptr+ResInfo)->CR[14]; + tempah = (LVDSCRT1Ptr + ResIndex)->CR[14]; tempah &= 0xE0; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah); - tempah = (LVDSCRT1Ptr+ResInfo)->CR[14]; + tempah = (LVDSCRT1Ptr + ResIndex)->CR[14]; tempah &= 0x01; tempah <<= 5; if(modeflag & DoubleScanMode) tempah |= 0x080; SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah); - /* TW: 650/LVDS BIOS - doesn't make sense */ + /* 650/LVDS BIOS - doesn't make sense */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { if(modeflag & HalfDCLK) SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); } } -BOOLEAN -SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *ResInfo, - USHORT *DisplayType) - { - USHORT tempbx,modeflag=0; - USHORT Flag,CRT2CRTC; - - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return 0; - } - } else { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return 0; - } - - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - CRT2CRTC = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - CRT2CRTC = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - } - - Flag = 1; - tempbx = 0; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - Flag = 0; - tempbx = 18; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx++; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - tempbx += 2; - if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; - if(SiS_Pr->SiS_CHPALM) { - tempbx = 18; /* PALM uses NTSC data */ - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx++; - } else if(SiS_Pr->SiS_CHPALN) { - tempbx = 20; /* PALN uses PAL data */ - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx++; - } - } - } - } - if(Flag) { - tempbx = SiS_Pr->SiS_LCDResInfo; - tempbx -= SiS_Pr->SiS_PanelMinLVDS; - if(SiS_Pr->SiS_LCDResInfo <= SiS_Pr->SiS_Panel1280x1024) { - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 6; - if(modeflag & HalfDCLK) tempbx += 3; - } else { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - tempbx = 14; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; - if(modeflag & HalfDCLK) tempbx++; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - tempbx = 23; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; - if(modeflag & HalfDCLK) tempbx++; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { - tempbx = 27; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; - if(modeflag & HalfDCLK) tempbx++; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { - tempbx = 36; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; - if(modeflag & HalfDCLK) tempbx++; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { - tempbx = 40; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; - if(modeflag & HalfDCLK) tempbx++; - } - } - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - tempbx = 12; - if(modeflag & HalfDCLK) tempbx++; - } - } - if(SiS_Pr->SiS_IF_DEF_FSTN){ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){ - tempbx = 22; - } - } - *ResInfo = CRT2CRTC & 0x3F; - *DisplayType = tempbx; - return 1; -} - -void -SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) +/*********************************************/ +/* SET CRT2 ECLK */ +/*********************************************/ + +static void +SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { - USHORT tempah,tempal,pushax; - USHORT vclkindex=0; - + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT clkbase, vclkindex=0; + UCHAR sr2b, sr2c; + if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) || (SiS_Pr->SiS_IF_DEF_TRUMPION == 1)) { SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - tempal &= 0x3F; - if(tempal == 2) RefreshRateTableIndex--; - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); + if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK & 0x3f) == 2) { + RefreshRateTableIndex--; + } + vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, + RefreshRateTableIndex, HwInfo); SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; } else { - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); + vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, + RefreshRateTableIndex, HwInfo); } - - tempal = 0x02B; + + sr2b = SiS_Pr->SiS_VCLKData[vclkindex].SR2B; + sr2c = SiS_Pr->SiS_VCLKData[vclkindex].SR2C; + + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + if(ROMAddr[0x220] & 0x01) { + sr2b = ROMAddr[0x227]; + sr2c = ROMAddr[0x228]; + } + } + } + + clkbase = 0x02B; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - tempal += 3; + clkbase += 3; } } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); - pushax = tempal; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x20); - tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2B; - SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah); - tempal++; - tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2C; - SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x10); - tempal = pushax; - tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2B; - SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah); - tempal++; - tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2C; - SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x00); - tempal = pushax; - tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2B; - SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah); - tempal++; - tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2C; - SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah); - return; -} - -#if 0 /* TW: Not used */ -void -SiS_SetDefCRT2ExtRegs(SiS_Private *SiS_Pr, USHORT BaseAddr) -{ - USHORT temp; - if(SiS_Pr->SiS_IF_DEF_LVDS==0) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x02,0x40); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x10,0x80); - temp=(UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - temp &= 0xC3; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x35,temp); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x32,0x02); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x02,0x00); - } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x20); + SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase,sr2b); + SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase+1,sr2c); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x10); + SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase,sr2b); + SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase+1,sr2c); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x00); + SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase,sr2b); + SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase+1,sr2c); } -#endif -/* TW: Start of Chrontel 70xx functions ---------------------- */ +/*********************************************/ +/* SET UP CHRONTEL CHIPS */ +/*********************************************/ -/* Set-up the Chrontel Registers */ -void -SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, +static void +SiS_SetCHTVReg(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex) { USHORT temp, tempbx, tempcl; @@ -8861,16 +8793,18 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHA tempcl = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; TVType = 0; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) TVType += 1; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { TVType += 2; - if(SiS_Pr->SiS_CHSOverScan) TVType = 8; - if(SiS_Pr->SiS_CHPALM) { + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) TVType = 8; + } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { TVType = 4; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) TVType += 1; - } else if(SiS_Pr->SiS_CHPALN) { + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; + } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { TVType = 6; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) TVType += 1; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; } } switch(TVType) { @@ -8890,44 +8824,44 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHA if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { #ifdef SIS300 - - /* Chrontel 7005 - I assume that it does not come with a 310/325 series chip */ - /* TW: We don't support modes >800x600 */ + /* Chrontel 7005 - I assume that it does not come with a 315 series chip */ + + /* We don't support modes >800x600 */ if (resindex > 5) return; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - SiS_SetCH700x(SiS_Pr,0x4304); /* TW: 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/ - SiS_SetCH700x(SiS_Pr,0x6909); /* TW: Black level for PAL (105)*/ + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + SiS_SetCH700x(SiS_Pr,0x4304); /* 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/ + SiS_SetCH700x(SiS_Pr,0x6909); /* Black level for PAL (105)*/ } else { - SiS_SetCH700x(SiS_Pr,0x0304); /* TW: upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/ - SiS_SetCH700x(SiS_Pr,0x7109); /* TW: Black level for NTSC (113)*/ + SiS_SetCH700x(SiS_Pr,0x0304); /* upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/ + SiS_SetCH700x(SiS_Pr,0x7109); /* Black level for NTSC (113)*/ } temp = CHTVRegData[resindex].Reg[0]; - tempbx=((temp&0x00FF)<<8)|0x00; /* TW: Mode register */ + tempbx=((temp&0x00FF)<<8)|0x00; /* Mode register */ SiS_SetCH700x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[1]; - tempbx=((temp&0x00FF)<<8)|0x07; /* TW: Start active video register */ + tempbx=((temp&0x00FF)<<8)|0x07; /* Start active video register */ SiS_SetCH700x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[2]; - tempbx=((temp&0x00FF)<<8)|0x08; /* TW: Position overflow register */ + tempbx=((temp&0x00FF)<<8)|0x08; /* Position overflow register */ SiS_SetCH700x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[3]; - tempbx=((temp&0x00FF)<<8)|0x0A; /* TW: Horiz Position register */ + tempbx=((temp&0x00FF)<<8)|0x0A; /* Horiz Position register */ SiS_SetCH700x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[4]; - tempbx=((temp&0x00FF)<<8)|0x0B; /* TW: Vertical Position register */ + tempbx=((temp&0x00FF)<<8)|0x0B; /* Vertical Position register */ SiS_SetCH700x(SiS_Pr,tempbx); - /* TW: Set minimum flicker filter for Luma channel (SR1-0=00), + /* Set minimum flicker filter for Luma channel (SR1-0=00), minimum text enhancement (S3-2=10), maximum flicker filter for Chroma channel (S5-4=10) =00101000=0x28 (When reading, S1-0->S3-2, and S3-2->S1-0!) */ SiS_SetCH700x(SiS_Pr,0x2801); - /* TW: Set video bandwidth + /* Set video bandwidth High bandwith Luma composite video filter(S0=1) low bandwith Luma S-video filter (S2-1=00) disable peak filter in S-video channel (S3=0) @@ -8936,66 +8870,68 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHA */ SiS_SetCH700x(SiS_Pr,0xb103); /* old: 3103 */ - /* TW: Register 0x3D does not exist in non-macrovision register map + /* Register 0x3D does not exist in non-macrovision register map (Maybe this is a macrovision register?) */ - /* SiS_SetCH70xx(SiS_Pr,0x003D); */ +#ifndef SIS_CP + SiS_SetCH70xx(SiS_Pr,0x003D); +#endif - /* TW: Register 0x10 only contains 1 writable bit (S0) for sensing, + /* Register 0x10 only contains 1 writable bit (S0) for sensing, all other bits a read-only. Macrovision? */ SiS_SetCH70xxANDOR(SiS_Pr,0x0010,0x1F); - /* TW: Register 0x11 only contains 3 writable bits (S0-S2) for + /* Register 0x11 only contains 3 writable bits (S0-S2) for contrast enhancement (set to 010 -> gain 1 Yout = 17/16*(Yin-30) ) */ SiS_SetCH70xxANDOR(SiS_Pr,0x0211,0xF8); - /* TW: Clear DSEN + /* Clear DSEN */ SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xEF); - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { /* ---- NTSC ---- */ - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) { + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { /* ---- NTSC ---- */ + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) { if(resindex == 0x04) { /* 640x480 overscan: Mode 16 */ SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on, no need to set FSCI */ - } else { - if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0C19,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001A,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001B,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001D,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001E,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001F,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x0120,0xEF); /* Loop filter on for mode 23 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ - } + } else if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0C19,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x001A,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x001B,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x001D,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x001E,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x001F,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x0120,0xEF); /* Loop filter on for mode 23 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ } } else { if(resindex == 0x04) { /* ----- 640x480 underscan; Mode 17 */ SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); - } else { - if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0919,0xF0); /* FSCI for mode 24 is 428,554,851 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x081A,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x0b1B,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x031C,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x0a1D,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x061E,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x031F,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off for mode 24 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ - } + } else if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */ +#if 0 + SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0919,0xF0); /* FSCI for mode 24 is 428,554,851 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x081A,0xF0); /* 198b3a63 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0b1B,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x041C,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x011D,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x061E,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x051F,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off for mode 24 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ +#endif /* All alternatives wrong (datasheet wrong?), don't use FSCI */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); } } - } else { /* ---- PAL ---- */ - /* TW: We don't play around with FSCI in PAL mode */ - if (resindex == 0x04) { + } else { /* ---- PAL ---- */ + /* We don't play around with FSCI in PAL mode */ + if(resindex == 0x04) { SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */ } else { @@ -9012,96 +8948,113 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHA #ifdef SIS315H - /* TW: We don't support modes >1024x768 */ + /* We don't support modes >1024x768 */ if (resindex > 6) return; temp = CHTVRegData[resindex].Reg[0]; - tempbx=((temp & 0x00FF) <<8 ) | 0x00; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { + temp |= 0x10; + } + tempbx=((temp & 0x00FF) << 8) | 0x00; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[1]; - tempbx=((temp & 0x00FF) <<8 ) | 0x01; + tempbx=((temp & 0x00FF) << 8) | 0x01; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[2]; - tempbx=((temp & 0x00FF) <<8 ) | 0x02; + tempbx=((temp & 0x00FF) << 8) | 0x02; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[3]; - tempbx=((temp & 0x00FF) <<8 ) | 0x04; + tempbx=((temp & 0x00FF) << 8) | 0x04; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[4]; - tempbx=((temp & 0x00FF) <<8 ) | 0x03; + tempbx=((temp & 0x00FF) << 8) | 0x03; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[5]; - tempbx=((temp & 0x00FF) <<8 ) | 0x05; + tempbx=((temp & 0x00FF) << 8) | 0x05; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[6]; - tempbx=((temp & 0x00FF) <<8 ) | 0x06; + tempbx=((temp & 0x00FF) << 8) | 0x06; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[7]; - tempbx=((temp & 0x00FF) <<8 ) | 0x07; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { + temp = 0x66; + } + tempbx=((temp & 0x00FF) << 8) | 0x07; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[8]; - tempbx=((temp & 0x00FF) <<8 ) | 0x08; + tempbx=((temp & 0x00FF) << 8) | 0x08; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[9]; - tempbx=((temp & 0x00FF) <<8 ) | 0x15; + tempbx=((temp & 0x00FF) << 8) | 0x15; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[10]; - tempbx=((temp & 0x00FF) <<8 ) | 0x1f; + tempbx=((temp & 0x00FF) << 8) | 0x1f; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[11]; - tempbx=((temp & 0x00FF) <<8 ) | 0x0c; + tempbx=((temp & 0x00FF) << 8) | 0x0c; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[12]; - tempbx=((temp & 0x00FF) <<8 ) | 0x0d; + tempbx=((temp & 0x00FF) << 8) | 0x0d; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[13]; - tempbx=((temp & 0x00FF) <<8 ) | 0x0e; + tempbx=((temp & 0x00FF) << 8) | 0x0e; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[14]; - tempbx=((temp & 0x00FF) <<8 ) | 0x0f; + tempbx=((temp & 0x00FF) << 8) | 0x0f; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[15]; - tempbx=((temp & 0x00FF) <<8 ) | 0x10; + tempbx=((temp & 0x00FF) << 8) | 0x10; SiS_SetCH701x(SiS_Pr,tempbx); - + + temp = SiS_GetCH701x(SiS_Pr,0x21) & ~0x02; + /* D1 should be set for PAL, PAL-N and NTSC-J, + but I won't do that for PAL unless somebody + tells me to do so. Since the BIOS uses + non-default CIV values and blacklevels, + this might be compensated anyway. + */ + if(SiS_Pr->SiS_TVMode & (TVSetPALN | TVSetNTSCJ)) temp |= 0x02; + SiS_SetCH701x(SiS_Pr,((temp << 8) | 0x21)); + #endif /* 315 */ } -} -/* TW: Chrontel 701x functions ================================= */ +#ifdef SIS_CP + SIS_CP_INIT301_CP3 +#endif + +} void -SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr) +SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { -#ifndef NEWCH701x USHORT temp; -#endif - /* TW: Enable Chrontel 7019 LCD panel backlight */ + /* Enable Chrontel 7019 LCD panel backlight */ if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { -#ifdef NEWCH701x + if(HwInfo->jChipType == SIS_740) { SiS_SetCH701x(SiS_Pr,0x6566); -#else + } else { temp = SiS_GetCH701x(SiS_Pr,0x66); temp |= 0x20; SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); -#endif + } } } @@ -9110,55 +9063,102 @@ SiS_Chrontel701xBLOff(SiS_Private *SiS_P { USHORT temp; - /* TW: Disable Chrontel 7019 LCD panel backlight */ + /* Disable Chrontel 7019 LCD panel backlight */ if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp &= 0xDF; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp &= 0xDF; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); } } -#ifdef SIS315H /* -------- 310/325 series only --------- */ +#ifdef SIS315H /* ----------- 315 series only ---------- */ -void -SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr) +static void +SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { -#ifdef NEWCH701x - UCHAR regtable[] = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71, - 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66 }; - UCHAR table1024[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, - 0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44 }; - UCHAR table1280[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 }; - UCHAR table1400[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 }; - UCHAR table1600[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44 }; -#else - UCHAR regtable[] = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71, - 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d }; - UCHAR table1024[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, - 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 }; - UCHAR table1280[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02 }; - UCHAR table1400[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xef, - 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 }; - UCHAR table1600[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a }; -#endif + UCHAR regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b }; + UCHAR table1024_740[] = { 0x01, 0x02, 0x01, 0x01, 0x01 }; + UCHAR table1400_740[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 }; + UCHAR asus1024_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; + UCHAR asus1400_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; + UCHAR table1024_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; + UCHAR table1400_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; + UCHAR *tableptr = NULL; + int i; + + /* Set up Power up/down timing */ + + if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1024_740; + else tableptr = table1024_740; + } else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) { + if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1400_740; + else tableptr = table1400_740; + } else return; + } else { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + tableptr = table1024_650; + } else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) { + tableptr = table1400_650; + } else return; + } + + for(i=0; i<5; i++) { + SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]); + } +} + +static void +SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR regtable[] = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71, + 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66 }; + UCHAR table1024_740[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, + 0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44 }; + UCHAR table1280_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 }; + UCHAR table1400_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 }; + UCHAR table1600_740[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44 }; + UCHAR table1024_650[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, + 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 }; + UCHAR table1280_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02 }; + UCHAR table1400_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xef, + 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 }; + UCHAR table1600_650[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a }; UCHAR *tableptr = NULL; USHORT tempbh; int i; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - tableptr = table1024; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - tableptr = table1280; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - tableptr = table1400; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { - tableptr = table1600; - } else return; + if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + tableptr = table1024_740; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + tableptr = table1280_740; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + tableptr = table1400_740; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + tableptr = table1600_740; + } else return; + } else { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + tableptr = table1024_650; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + tableptr = table1280_650; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + tableptr = table1400_650; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + tableptr = table1600_650; + } else return; + } tempbh = SiS_GetCH701x(SiS_Pr,0x74); if((tempbh == 0xf6) || (tempbh == 0xc7)) { @@ -9169,595 +9169,780 @@ SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) return; if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) return; } else if(tempbh == 0xde) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) return; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) return; } } -#ifdef NEWCH701x /* New from 740/LVDS: */ - for(i=0; i<0x0d; i++) { -#else - for(i=0; i<0x0c; i++) { -#endif + + if(HwInfo->jChipType == SIS_740) { + tempbh = 0x0d; + } else { + tempbh = 0x0c; + } + for(i = 0; i < tempbh; i++) { SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]); } - SiS_ChrontelPowerSequencing(SiS_Pr); + SiS_ChrontelPowerSequencing(SiS_Pr,HwInfo); tempbh = SiS_GetCH701x(SiS_Pr,0x1e); tempbh |= 0xc0; SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1e); - -#ifdef NEWCH701x /* 740/LVDS: */ - tempbh = SiS_GetCH701x(SiS_Pr,0x1c); - tempbh &= 0xfb; - SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1c); - SiS_SetReg1(SiS_Pr->SiS_Part1Port, 0x2d, 0x03); - tempbh = SiS_GetCH701x(SiS_Pr,0x64); - tempbh |= 0x40; - SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x64); - tempbh = SiS_GetCH701x(SiS_Pr,0x03); - tempbh &= 0x3f; - SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x03); -#endif /* End 740/LVDS */ + + if(HwInfo->jChipType == SIS_740) { + tempbh = SiS_GetCH701x(SiS_Pr,0x1c); + tempbh &= 0xfb; + SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1c); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); + tempbh = SiS_GetCH701x(SiS_Pr,0x64); + tempbh |= 0x40; + SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x64); + tempbh = SiS_GetCH701x(SiS_Pr,0x03); + tempbh &= 0x3f; + SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x03); + } } -void -SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr) +static void +SiS_ChrontelResetVSync(SiS_Private *SiS_Pr) { - UCHAR regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b }; -#ifdef NEWCH701x - UCHAR table1024[] = { 0x01, 0x02, 0x01, 0x01, 0x01 }; - UCHAR table1400[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 }; -#else - UCHAR table1024[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; - UCHAR table1400[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; -#endif - UCHAR *tableptr = NULL; - int i; + unsigned char temp, temp1; - /* Set up Power up/down timing */ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - tableptr = table1024; - } else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) { - tableptr = table1400; - } else return; - - for(i=0; i<5; i++) { - SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]); - } + temp1 = SiS_GetCH701x(SiS_Pr,0x49); + SiS_SetCH701x(SiS_Pr,0x3e49); + temp = SiS_GetCH701x(SiS_Pr,0x47); + temp &= 0x7f; /* Use external VSYNC */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); + SiS_LongDelay(SiS_Pr,3); + temp = SiS_GetCH701x(SiS_Pr,0x47); + temp |= 0x80; /* Use internal VSYNC */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); + SiS_SetCH701x(SiS_Pr,(temp1 << 8) | 0x49); } void -SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr) +SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { USHORT temp; if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { -#ifdef NEWCH701x - temp = SiS_GetCH701x(SiS_Pr,0x1c); - temp |= 0x04; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); -#endif - if(SiS_IsYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) { + if(HwInfo->jChipType == SIS_740) { + temp = SiS_GetCH701x(SiS_Pr,0x1c); + temp |= 0x04; /* Invert XCLK phase */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); + } + if(SiS_IsYPbPr(SiS_Pr, HwInfo)) { temp = SiS_GetCH701x(SiS_Pr,0x01); temp &= 0x3f; - temp |= 0x80; /* TW: Enable YPrPb (HDTV) */ + temp |= 0x80; /* Enable YPrPb (HDTV) */ SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01); } - if(SiS_IsChScart(SiS_Pr,HwDeviceExtension, BaseAddr)) { + if(SiS_IsChScart(SiS_Pr, HwInfo)) { temp = SiS_GetCH701x(SiS_Pr,0x01); temp &= 0x3f; - temp |= 0xc0; /* TW: Enable SCART + CVBS */ + temp |= 0xc0; /* Enable SCART + CVBS */ SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01); } -#ifdef NEWCH701x - SiS_ChrontelDoSomething5(SiS_Pr); - SiS_SetCH701x(SiS_Pr,0x2049); /* TW: Enable TV path */ -#else - SiS_SetCH701x(SiS_Pr,0x2049); /* TW: Enable TV path */ - temp = SiS_GetCH701x(SiS_Pr,0x49); - if(SiS_IsYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) { - temp = SiS_GetCH701x(SiS_Pr,0x73); - temp |= 0x60; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x73); - } - temp = SiS_GetCH701x(SiS_Pr,0x47); - temp &= 0x7f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); - SiS_LongDelay(SiS_Pr,2); - temp = SiS_GetCH701x(SiS_Pr,0x47); - temp |= 0x80; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); -#endif + if(HwInfo->jChipType == SIS_740) { + SiS_ChrontelResetVSync(SiS_Pr); + SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */ + } else { + SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */ + temp = SiS_GetCH701x(SiS_Pr,0x49); + if(SiS_IsYPbPr(SiS_Pr,HwInfo)) { + temp = SiS_GetCH701x(SiS_Pr,0x73); + temp |= 0x60; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x73); + } + temp = SiS_GetCH701x(SiS_Pr,0x47); + temp &= 0x7f; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); + SiS_LongDelay(SiS_Pr,2); + temp = SiS_GetCH701x(SiS_Pr,0x47); + temp |= 0x80; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); + } } } void -SiS_Chrontel701xOff(SiS_Private *SiS_Pr) +SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { USHORT temp; + /* Complete power down of LVDS */ if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(HwInfo->jChipType == SIS_740) { + SiS_LongDelay(SiS_Pr,1); + SiS_GenericDelay(SiS_Pr,0x16ff); + SiS_SetCH701x(SiS_Pr,0xac76); + SiS_SetCH701x(SiS_Pr,0x0066); + } else { SiS_LongDelay(SiS_Pr,2); - /* TW: Complete power down of LVDS */ temp = SiS_GetCH701x(SiS_Pr,0x76); temp &= 0xfc; SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); SiS_SetCH701x(SiS_Pr,0x0066); + } } } -#ifdef NEWCH701x -void -SiS_ChrontelDoSomething5(SiS_Private *SiS_Pr) +static void +SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - unsigned char temp, temp1; - - temp1 = SiS_GetCH701x(SiS_Pr,0x49); - SiS_SetCH701x(SiS_Pr,0x3e49); - temp = SiS_GetCH701x(SiS_Pr,0x47); - temp &= 0x7f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); - SiS_LongDelay(SiS_Pr,3); - temp = SiS_GetCH701x(SiS_Pr,0x47); - temp |= 0x80; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); - SiS_SetCH701x(SiS_Pr,(temp1 << 8) | 0x49); + USHORT temp; + + if(HwInfo->jChipType == SIS_740) { + + temp = SiS_GetCH701x(SiS_Pr,0x4a); /* Version ID */ + temp &= 0x01; + if(!temp) { + + if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) { + temp = SiS_GetCH701x(SiS_Pr,0x49); + SiS_SetCH701x(SiS_Pr,0x3e49); + } + /* Reset Chrontel 7019 datapath */ + SiS_SetCH701x(SiS_Pr,0x1048); + SiS_LongDelay(SiS_Pr,1); + SiS_SetCH701x(SiS_Pr,0x1848); + + if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) { + SiS_ChrontelResetVSync(SiS_Pr); + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x49); + } + + } else { + + /* Clear/set/clear GPIO */ + temp = SiS_GetCH701x(SiS_Pr,0x5c); + temp &= 0xef; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); + temp = SiS_GetCH701x(SiS_Pr,0x5c); + temp |= 0x10; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); + temp = SiS_GetCH701x(SiS_Pr,0x5c); + temp &= 0xef; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); + temp = SiS_GetCH701x(SiS_Pr,0x61); + if(!temp) { + SiS_SetCH701xForLCD(SiS_Pr, HwInfo); + } + } + + } else { /* 650 */ + /* Reset Chrontel 7019 datapath */ + SiS_SetCH701x(SiS_Pr,0x1048); + SiS_LongDelay(SiS_Pr,1); + SiS_SetCH701x(SiS_Pr,0x1848); + } } -#endif void -SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) +SiS_ChrontelInitTVVSync(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { -#ifdef NEWCH701x USHORT temp; - - /* 740/LVDS: */ - temp = SiS_GetCH701x(SiS_Pr,0x4a); - temp &= 0x01; - if(!(temp)) { - - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { - temp = SiS_GetCH701x(SiS_Pr,0x49); - SiS_SetCH701x(SiS_Pr,0x3e49); - } - /* TW: Reset Chrontel 7019 datapath */ - SiS_SetCH701x(SiS_Pr,0x1048); - SiS_LongDelay(SiS_Pr,1); - SiS_SetCH701x(SiS_Pr,0x1848); - - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_ChrontelDoSomething5(SiS_Pr); - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x49); - } + + if(HwInfo->jChipType == SIS_740) { + + if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) { + SiS_ChrontelResetVSync(SiS_Pr); + } + } else { - - temp = SiS_GetCH701x(SiS_Pr,0x5c); - temp &= 0xef; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); - temp = SiS_GetCH701x(SiS_Pr,0x5c); - temp |= 0x10; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); - temp = SiS_GetCH701x(SiS_Pr,0x5c); - temp &= 0xef; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); - temp = SiS_GetCH701x(SiS_Pr,0x61); - if(!temp) { - SiS_SetCH701xForLCD(SiS_Pr,HwDeviceExtension,BaseAddr); - } - } -#else /* pre 740/LVDS code */ - /* TW: Reset Chrontel 7019 datapath */ - SiS_SetCH701x(SiS_Pr,0x1048); - SiS_LongDelay(SiS_Pr,1); - SiS_SetCH701x(SiS_Pr,0x1848); -#endif + + SiS_SetCH701x(SiS_Pr,0xaf76); /* Power up LVDS block */ + temp = SiS_GetCH701x(SiS_Pr,0x49); + temp &= 1; + if(temp != 1) { /* TV block powered? (0 = yes, 1 = no) */ + temp = SiS_GetCH701x(SiS_Pr,0x47); + temp &= 0x70; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* enable VSYNC */ + SiS_LongDelay(SiS_Pr,3); + temp = SiS_GetCH701x(SiS_Pr,0x47); + temp |= 0x80; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* disable VSYNC */ + } + + } } -void -SiS_ChrontelDoSomething4(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) +static void +SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo) { -#ifdef NEWCH701x - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_ChrontelDoSomething5(SiS_Pr); + USHORT temp,temp1; + + if(HwInfo->jChipType == SIS_740) { + + temp = SiS_GetCH701x(SiS_Pr,0x61); + if(temp < 1) { + temp++; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); + } + SiS_SetCH701x(SiS_Pr,0x4566); /* Panel power on */ + SiS_SetCH701x(SiS_Pr,0xaf76); /* All power on */ + SiS_LongDelay(SiS_Pr,1); + SiS_GenericDelay(SiS_Pr,0x16ff); + + } else { /* 650 */ + + temp1 = 0; + temp = SiS_GetCH701x(SiS_Pr,0x61); + if(temp < 2) { + temp++; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); + temp1 = 1; + } + SiS_SetCH701x(SiS_Pr,0xac76); + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp |= 0x5f; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); + if(ModeNo > 0x13) { + if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) { + SiS_GenericDelay(SiS_Pr,0x3ff); + } else { + SiS_GenericDelay(SiS_Pr,0x2ff); + } + } else { + if(!temp1) + SiS_GenericDelay(SiS_Pr,0x2ff); + } + temp = SiS_GetCH701x(SiS_Pr,0x76); + temp |= 0x03; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp &= 0x7f; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); + SiS_LongDelay(SiS_Pr,1); + } -#else +} + +static void +SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT temp,tempcl,tempch; + + SiS_LongDelay(SiS_Pr, 1); + tempcl = 3; + tempch = 0; + + do { + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp &= 0x04; /* PLL stable? -> bail out */ + if(temp == 0x04) break; + + if(HwInfo->jChipType == SIS_740) { + /* Power down LVDS output, PLL normal operation */ + SiS_SetCH701x(SiS_Pr,0xac76); + } + + SiS_SetCH701xForLCD(SiS_Pr,HwInfo); + + if(tempcl == 0) { + if(tempch == 3) break; + SiS_ChrontelResetDB(SiS_Pr,HwInfo); + tempcl = 3; + tempch++; + } + tempcl--; + temp = SiS_GetCH701x(SiS_Pr,0x76); + temp &= 0xfb; /* Reset PLL */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); + SiS_LongDelay(SiS_Pr,2); + temp = SiS_GetCH701x(SiS_Pr,0x76); + temp |= 0x04; /* PLL normal operation */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); + if(HwInfo->jChipType == SIS_740) { + SiS_SetCH701x(SiS_Pr,0xe078); /* PLL loop filter */ + } else { + SiS_SetCH701x(SiS_Pr,0x6078); + } + SiS_LongDelay(SiS_Pr,2); + } while(0); + + SiS_SetCH701x(SiS_Pr,0x0077); /* MV? */ +} + +void +SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ USHORT temp; - SiS_SetCH701x(SiS_Pr,0xaf76); /* Power up LVDS block */ - temp = SiS_GetCH701x(SiS_Pr,0x49); - temp &= 1; - if(temp != 1) { /* TV block powered? (0 = yes, 1 = no) */ - temp = SiS_GetCH701x(SiS_Pr,0x47); - temp &= 0x70; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* enable VSYNC */ - SiS_LongDelay(SiS_Pr,3); - temp = SiS_GetCH701x(SiS_Pr,0x47); - temp |= 0x80; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* disable VSYNC */ - } -#endif -} + temp = SiS_GetCH701x(SiS_Pr,0x03); + temp |= 0x80; /* Set datapath 1 to TV */ + temp &= 0xbf; /* Set datapath 2 to LVDS */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); + + if(HwInfo->jChipType == SIS_740) { + + temp = SiS_GetCH701x(SiS_Pr,0x1c); + temp &= 0xfb; /* Normal XCLK phase */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); + + temp = SiS_GetCH701x(SiS_Pr,0x64); + temp |= 0x40; /* ? Bit not defined */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x64); + + temp = SiS_GetCH701x(SiS_Pr,0x03); + temp &= 0x3f; /* D1 input to both LVDS and TV */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); + + if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) { + SiS_SetCH701x(SiS_Pr,0x4063); /* LVDS off */ + SiS_LongDelay(SiS_Pr, 1); + SiS_SetCH701x(SiS_Pr,0x0063); /* LVDS on */ + SiS_ChrontelResetDB(SiS_Pr, HwInfo); + SiS_ChrontelDoSomething2(SiS_Pr, HwInfo); + SiS_ChrontelDoSomething3(SiS_Pr, 0, HwInfo); + } else { + temp = SiS_GetCH701x(SiS_Pr,0x66); + if(temp != 0x45) { + SiS_ChrontelResetDB(SiS_Pr, HwInfo); + SiS_ChrontelDoSomething2(SiS_Pr, HwInfo); + SiS_ChrontelDoSomething3(SiS_Pr, 0, HwInfo); + } + } + + } else { /* 650 */ + + SiS_ChrontelResetDB(SiS_Pr,HwInfo); + SiS_ChrontelDoSomething2(SiS_Pr,HwInfo); + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34); + SiS_ChrontelDoSomething3(SiS_Pr,temp,HwInfo); + SiS_SetCH701x(SiS_Pr,0xaf76); /* All power on, LVDS normal operation */ + + } + +} +#endif /* 315 series */ + +/*********************************************/ +/* MAIN: SET CRT2 REGISTER GROUP */ +/*********************************************/ + +BOOLEAN +SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) +{ +#ifdef SIS300 + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; +#endif + USHORT ModeIdIndex, RefreshRateTableIndex; +#if 0 + USHORT temp; +#endif + + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + + if(!SiS_Pr->UseCustomMode) { + SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex); + } else { + ModeIdIndex = 0; + } + + /* Used for shifting CR33 */ + SiS_Pr->SiS_SelectCRT2Rate = 4; + + SiS_UnLockCRT2(SiS_Pr, HwInfo); + + RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + + SiS_SaveCRT2Info(SiS_Pr,ModeNo); + + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + SiS_DisableBridge(SiS_Pr,HwInfo); + if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (HwInfo->jChipType == SIS_730)) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,0x80); + } + SiS_SetCRT2ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + } + + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { + SiS_LockCRT2(SiS_Pr, HwInfo); + SiS_DisplayOn(SiS_Pr); + return TRUE; + } + + SiS_GetCRT2Data(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + + /* Set up Panel Link for LVDS, 301BDH and 30xLV(for LCDA) */ + if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || + ((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) || + ((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) { + SiS_GetLVDSDesData(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + } else { + SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; + } + +#ifdef LINUX_XF86 +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "(init301: LCDHDES 0x%03x LCDVDES 0x%03x)\n", SiS_Pr->SiS_LCDHDES, SiS_Pr->SiS_LCDVDES); + xf86DrvMsg(0, X_INFO, "(init301: HDE 0x%03x VDE 0x%03x)\n", SiS_Pr->SiS_HDE, SiS_Pr->SiS_VDE); + xf86DrvMsg(0, X_INFO, "(init301: VGAHDE 0x%03x VGAVDE 0x%03x)\n", SiS_Pr->SiS_VGAHDE, SiS_Pr->SiS_VGAVDE); + xf86DrvMsg(0, X_INFO, "(init301: HT 0x%03x VT 0x%03x)\n", SiS_Pr->SiS_HT, SiS_Pr->SiS_VT); + xf86DrvMsg(0, X_INFO, "(init301: VGAHT 0x%03x VGAVT 0x%03x)\n", SiS_Pr->SiS_VGAHT, SiS_Pr->SiS_VGAVT); +#endif +#endif + + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + SiS_SetGroup1(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + } + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + if(SiS_Pr->SiS_SetFlag & LowModeTests) { -void -SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT BaseAddr) -{ -#ifdef NEWCH701x - USHORT temp; - - temp = SiS_GetCH701x(SiS_Pr,0x61); - if(temp < 1) { - temp++; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); - } - SiS_SetCH701x(SiS_Pr,0x4566); - SiS_SetCH701x(SiS_Pr,0xaf76); - SiS_LongDelay(SiS_Pr,1); - SiS_GenericDelay(SiS_Pr,0x16ff); + SiS_SetGroup2(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); +#ifdef SIS315H + SiS_SetGroup2_C_ELV(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); +#endif + SiS_SetGroup3(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_SetGroup4(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); +#ifdef SIS315H + SiS_SetGroup4_C_ELV(SiS_Pr, HwInfo); +#endif + SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); -#else - USHORT temp,temp1; - - temp1 = 0; - temp = SiS_GetCH701x(SiS_Pr,0x61); - if(temp < 2) { - temp++; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); - temp1 = 1; - } - SiS_SetCH701x(SiS_Pr,0xac76); - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp |= 0x5f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); - if(ModeNo > 0x13) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_GenericDelay(SiS_Pr,0x3ff); - } else { - SiS_GenericDelay(SiS_Pr,0x2ff); - } - } else { - if(!temp1) - SiS_GenericDelay(SiS_Pr,0x2ff); - } - temp = SiS_GetCH701x(SiS_Pr,0x76); - temp |= 0x03; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp &= 0x7f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); - SiS_LongDelay(SiS_Pr,1); -#endif -} + /* For 301BDH (Panel link initialization): */ + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(!((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10)))) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + } + } + } + SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + } + } -void -SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ - USHORT temp,tempcl,tempch; + } else { - SiS_LongDelay(SiS_Pr, 1); - tempcl = 3; - tempch = 0; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { + SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + } + } - do { - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp &= 0x04; - if(temp == 0x04) break; - -#ifdef NEWCH701x - SiS_SetCH701x(SiS_Pr,0xac76); /* 740/LVDS */ -#endif + SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); - SiS_SetCH701xForLCD(SiS_Pr,HwDeviceExtension,BaseAddr); + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { +#ifdef SIS315H + SiS_SetCH701xForLCD(SiS_Pr,HwInfo); +#endif + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SiS_SetCHTVReg(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex); + } + } + } - if(tempcl == 0) { - if(tempch == 3) break; - SiS_ChrontelResetDB(SiS_Pr,HwDeviceExtension,BaseAddr); - tempcl = 3; - tempch++; - } - tempcl--; - temp = SiS_GetCH701x(SiS_Pr,0x76); - temp &= 0xfb; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); - SiS_LongDelay(SiS_Pr,2); - temp = SiS_GetCH701x(SiS_Pr,0x76); - temp |= 0x04; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); -#ifdef NEWCH701x - SiS_SetCH701x(SiS_Pr,0xe078); -#else - SiS_SetCH701x(SiS_Pr,0x6078); -#endif - SiS_LongDelay(SiS_Pr,2); - } while(0); + } - SiS_SetCH701x(SiS_Pr,0x0077); -} +#ifdef SIS300 + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + if(SiS_Pr->SiS_UseOEM) { + if((SiS_Pr->SiS_UseROM) && ROMAddr && (SiS_Pr->SiS_UseOEM == -1)) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + SiS_OEM300Setting(SiS_Pr,HwInfo,ModeNo,ModeIdIndex, + RefreshRateTableIndex); + } + } else { + SiS_OEM300Setting(SiS_Pr,HwInfo,ModeNo,ModeIdIndex, + RefreshRateTableIndex); + } + } + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + SetOEMLCDData2(SiS_Pr, HwInfo, ModeNo, ModeIdIndex,RefreshRateTableIndex); + } + if(HwInfo->jChipType == SIS_730) { + SiS_DisplayOn(SiS_Pr); + } + } + } + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(HwInfo->jChipType != SIS_730) { + SiS_DisplayOn(SiS_Pr); + } + } + } +#endif -void -SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT BaseAddr) -{ - USHORT temp; +#ifdef SIS315H + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + if(HwInfo->jChipType < SIS_661) { + SiS_FinalizeLCD(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + if(SiS_Pr->SiS_UseOEM) { + SiS_OEM310Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + } + } else { + SiS_OEM661Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } + SiS_CRT2AutoThreshold(SiS_Pr); + } + } +#endif - temp = SiS_GetCH701x(SiS_Pr,0x03); - temp |= 0x80; /* Set datapath 1 to TV */ - temp &= 0xbf; /* Set datapath 2 to LVDS */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); - -#ifdef NEWCH701x /* 740/LVDS: */ + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + SiS_EnableBridge(SiS_Pr, HwInfo); + } - temp = SiS_GetCH701x(SiS_Pr,0x1c); - temp &= 0xfb; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); - - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2d,0x03); - - temp = SiS_GetCH701x(SiS_Pr,0x64); - temp |= 0x40; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x64); - - temp = SiS_GetCH701x(SiS_Pr,0x03); - temp &= 0x3f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); - - temp = SiS_GetCH701x(SiS_Pr,0x66); - if(temp != 0x45) { - SiS_ChrontelResetDB(SiS_Pr,HwDeviceExtension,BaseAddr); - SiS_ChrontelDoSomething2(SiS_Pr,HwDeviceExtension,BaseAddr); - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34); - SiS_ChrontelDoSomething3(SiS_Pr,temp,HwDeviceExtension,BaseAddr); - } + SiS_DisplayOn(SiS_Pr); + + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + /* Disable LCD panel when using TV */ + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFF,0x0C); + } else { + /* Disable TV when using LCD */ + SiS_SetCH70xxANDOR(SiS_Pr,0x010E,0xF8); + } + } -#else /* pre-740/LVDS: */ + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + SiS_LockCRT2(SiS_Pr,HwInfo); + } - SiS_ChrontelResetDB(SiS_Pr); + return TRUE; +} - SiS_ChrontelDoSomething2(SiS_Pr,HwDeviceExtension,BaseAddr); - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34); - SiS_ChrontelDoSomething3(SiS_Pr,temp,HwDeviceExtension,BaseAddr); +/*********************************************/ +/* ENABLE/DISABLE LCD BACKLIGHT (SIS) */ +/*********************************************/ - SiS_SetCH701x(SiS_Pr,0xaf76); - -#endif /* End of pre-740/LVDS */ +void +SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + /* Switch on LCD backlight on SiS30xLV */ + SiS_DDC2Delay(SiS_Pr,0xff00); + if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); + SiS_WaitVBRetrace(SiS_Pr,HwInfo); + } + if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x01)) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); + } } -#endif /* 310/325 series --------------------------------- */ +void +SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + /* Switch off LCD backlight on SiS30xLV */ + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); + SiS_DDC2Delay(SiS_Pr,0xe000); +} -/* TW: End of Chrontel 701x functions ==================================== */ +/*********************************************/ +/* DDC RELATED FUNCTIONS */ +/*********************************************/ -/* TW: Generic Read/write routines for Chrontel ========================== */ +static void +SiS_SetupDDCN(SiS_Private *SiS_Pr) +{ + SiS_Pr->SiS_DDC_NData = ~SiS_Pr->SiS_DDC_Data; + SiS_Pr->SiS_DDC_NClk = ~SiS_Pr->SiS_DDC_Clk; + if((SiS_Pr->SiS_DDC_Index == 0x11) && (SiS_Pr->SiS_SensibleSR11)) { + SiS_Pr->SiS_DDC_NData &= 0x0f; + SiS_Pr->SiS_DDC_NClk &= 0x0f; + } +} -/* TW: The Chrontel is connected to the 630/730 via +/* The Chrontel 700x is connected to the 630/730 via * the 630/730's DDC/I2C port. * - * On 630(S)T chipset, the index changed from 0x11 to 0x0a, - * possibly for working around the DDC problems + * On 630(S)T chipset, the index changed from 0x11 to + * 0x0a, possibly for working around the DDC problems */ -void -SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +static BOOLEAN +SiS_SetChReg(SiS_Private *SiS_Pr, USHORT tempbx, USHORT myor) { - if (SiS_Pr->SiS_IF_DEF_CH70xx == 1) - SiS_SetCH700x(SiS_Pr,tempbx); - else - SiS_SetCH701x(SiS_Pr,tempbx); + USHORT tempah,temp,i; + + for(i=0; i<20; i++) { /* Do 20 attempts to write */ + if(i) { + SiS_SetStop(SiS_Pr); + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); + } + if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ + tempah = SiS_Pr->SiS_DDC_DeviceAddr; + temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write DAB (S0=0=write) */ + if(temp) continue; /* (ERROR: no ack) */ + tempah = tempbx & 0x00FF; /* Write RAB */ + tempah |= myor; /* (700x: set bit 7, see datasheet) */ + temp = SiS_WriteDDC2Data(SiS_Pr,tempah); + if(temp) continue; /* (ERROR: no ack) */ + tempah = (tempbx & 0xFF00) >> 8; + temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write data */ + if(temp) continue; /* (ERROR: no ack) */ + if(SiS_SetStop(SiS_Pr)) continue; /* Set stop condition */ + SiS_Pr->SiS_ChrontelInit = 1; + return TRUE; + } + return FALSE; } -/* TW: Write to Chrontel 700x */ +/* Write to Chrontel 700x */ /* Parameter is [Data (S15-S8) | Register no (S7-S0)] */ void SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempbx) { - USHORT tempah,temp,i; + SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ if(!(SiS_Pr->SiS_ChrontelInit)) { - SiS_Pr->SiS_DDC_Index = 0x11; /* TW: Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ - SiS_Pr->SiS_DDC_DataShift = 0x00; - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB (Device Address Byte) */ - } - - for(i=0;i<10;i++) { /* TW: Do only 10 attempts to write */ - /* SiS_SetSwitchDDC2(SiS_Pr); */ - if(SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = tempbx & 0x00FF; /* TW: Write RAB */ - tempah |= 0x80; /* TW: (set bit 7, see datasheet) */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = (tempbx & 0xFF00) >> 8; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write data */ - if(temp) continue; /* TW: (ERROR: no ack) */ - if(SiS_SetStop(SiS_Pr)) continue; /* TW: Set stop condition */ - SiS_Pr->SiS_ChrontelInit = 1; - return; + SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ + SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ + SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ + SiS_SetupDDCN(SiS_Pr); } - /* TW: For 630ST */ - if(!(SiS_Pr->SiS_ChrontelInit)) { - SiS_Pr->SiS_DDC_Index = 0x0a; /* TW: Bit 7 = SC; Bit 6 = SD */ + if( (!(SiS_SetChReg(SiS_Pr, tempbx, 0x80))) && + (!(SiS_Pr->SiS_ChrontelInit)) ) { + SiS_Pr->SiS_DDC_Index = 0x0a; /* Bit 7 = SC; Bit 6 = SD */ SiS_Pr->SiS_DDC_Data = 0x80; /* Bitmask in IndexReg for Data */ SiS_Pr->SiS_DDC_Clk = 0x40; /* Bitmask in IndexReg for Clk */ - SiS_Pr->SiS_DDC_DataShift = 0x00; - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB (Device Address Byte) */ + SiS_SetupDDCN(SiS_Pr); - for(i=0;i<10;i++) { /* TW: Do only 10 attempts to write */ - /* SiS_SetSwitchDDC2(SiS_Pr); */ - if (SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = tempbx & 0x00FF; /* TW: Write RAB */ - tempah |= 0x80; /* TW: (set bit 7, see datasheet) */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = (tempbx & 0xFF00) >> 8; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write data */ - if(temp) continue; /* TW: (ERROR: no ack) */ - if(SiS_SetStop(SiS_Pr)) continue; /* TW: Set stop condition */ - SiS_Pr->SiS_ChrontelInit = 1; - return; - } + SiS_SetChReg(SiS_Pr, tempbx, 0x80); } } -/* TW: Write to Chrontel 701x */ +/* Write to Chrontel 701x */ /* Parameter is [Data (S15-S8) | Register no (S7-S0)] */ void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx) { - USHORT tempah,temp,i; - - SiS_Pr->SiS_DDC_Index = 0x11; /* TW: Bit 0 = SC; Bit 1 = SD */ + SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ - SiS_Pr->SiS_DDC_DataShift = 0x00; - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB (Device Address Byte) */ + SiS_SetupDDCN(SiS_Pr); + SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ - for(i=0;i<10;i++) { /* TW: Do only 10 attempts to write */ - if (SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = tempbx & 0x00FF; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write RAB */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = (tempbx & 0xFF00) >> 8; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write data */ - if(temp) continue; /* TW: (ERROR: no ack) */ - if(SiS_SetStop(SiS_Pr)) continue; /* TW: Set stop condition */ - return; - } + SiS_SetChReg(SiS_Pr, tempbx, 0); } -/* TW: Read from Chrontel 70xx */ -/* Parameter is [Register no (S7-S0)] */ -USHORT -SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +void +SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) { - if (SiS_Pr->SiS_IF_DEF_CH70xx == 1) - return(SiS_GetCH700x(SiS_Pr,tempbx)); + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) + SiS_SetCH700x(SiS_Pr,tempbx); else - return(SiS_GetCH701x(SiS_Pr,tempbx)); + SiS_SetCH701x(SiS_Pr,tempbx); +} + +static USHORT +SiS_GetChReg(SiS_Private *SiS_Pr, USHORT myor) +{ + USHORT tempah,temp,i; + + for(i=0; i<20; i++) { /* Do 20 attempts to read */ + if(i) { + SiS_SetStop(SiS_Pr); + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); + } + if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ + tempah = SiS_Pr->SiS_DDC_DeviceAddr; + temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write DAB (S0=0=write) */ + if(temp) continue; /* (ERROR: no ack) */ + tempah = SiS_Pr->SiS_DDC_ReadAddr | myor; /* Write RAB (700x: | 0x80) */ + temp = SiS_WriteDDC2Data(SiS_Pr,tempah); + if(temp) continue; /* (ERROR: no ack) */ + if (SiS_SetStart(SiS_Pr)) continue; /* Re-start */ + tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01;/* DAB | 0x01 = Read */ + temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* DAB (S0=1=read) */ + if(temp) continue; /* (ERROR: no ack) */ + tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* Read byte */ + if(SiS_SetStop(SiS_Pr)) continue; /* Stop condition */ + SiS_Pr->SiS_ChrontelInit = 1; + return(tempah); + } + return 0xFFFF; } -/* TW: Read from Chrontel 700x */ +/* Read from Chrontel 700x */ /* Parameter is [Register no (S7-S0)] */ USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx) { - USHORT tempah,temp,i; + USHORT result; + + SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ if(!(SiS_Pr->SiS_ChrontelInit)) { - SiS_Pr->SiS_DDC_Index = 0x11; /* TW: Bit 0 = SC; Bit 1 = SD */ + SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ - SiS_Pr->SiS_DDC_DataShift = 0x00; - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB */ + SiS_SetupDDCN(SiS_Pr); } SiS_Pr->SiS_DDC_ReadAddr = tempbx; - for(i=0;i<20;i++) { /* TW: Do only 20 attempts to read */ - /* SiS_SetSwitchDDC2(SiS_Pr); */ - if(SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = SiS_Pr->SiS_DDC_ReadAddr | 0x80; /* TW: Write RAB | 0x80 */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* TW: (ERROR: no ack) */ - if (SiS_SetStart(SiS_Pr)) continue; /* TW: Re-start */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01; /* DAB | 0x01 = Read */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: DAB (S0=1=read) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* TW: Read byte */ - if (SiS_SetStop(SiS_Pr)) continue; /* TW: Stop condition */ - SiS_Pr->SiS_ChrontelInit = 1; - return(tempah); - } - - /* TW: For 630ST */ - if(!SiS_Pr->SiS_ChrontelInit) { - SiS_Pr->SiS_DDC_Index = 0x0a; /* TW: Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x80; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x40; /* Bitmask in IndexReg for Clk */ - SiS_Pr->SiS_DDC_DataShift = 0x00; - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB (Device Address Byte) */ + if( ((result = SiS_GetChReg(SiS_Pr,0x80)) == 0xFFFF) && + (!SiS_Pr->SiS_ChrontelInit) ) { - for(i=0;i<20;i++) { /* TW: Do only 20 attempts to read */ - /* SiS_SetSwitchDDC2(SiS_Pr); */ - if(SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = SiS_Pr->SiS_DDC_ReadAddr | 0x80; /* TW: Write RAB | 0x80 */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* TW: (ERROR: no ack) */ - if (SiS_SetStart(SiS_Pr)) continue; /* TW: Re-start */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01; /* DAB | 0x01 = Read */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: DAB (S0=1=read) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* TW: Read byte */ - if (SiS_SetStop(SiS_Pr)) continue; /* TW: Stop condition */ - SiS_Pr->SiS_ChrontelInit = 1; - return(tempah); - } + SiS_Pr->SiS_DDC_Index = 0x0a; + SiS_Pr->SiS_DDC_Data = 0x80; + SiS_Pr->SiS_DDC_Clk = 0x40; + SiS_SetupDDCN(SiS_Pr); + + result = SiS_GetChReg(SiS_Pr,0x80); } - return(0xFFFF); + return(result); } -/* TW: Read from Chrontel 701x */ +/* Read from Chrontel 701x */ /* Parameter is [Register no (S7-S0)] */ USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx) { - USHORT tempah,temp,i; - - SiS_Pr->SiS_DDC_Index = 0x11; /* TW: Bit 0 = SC; Bit 1 = SD */ + SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ - SiS_Pr->SiS_DDC_DataShift = 0x00; - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB */ + SiS_SetupDDCN(SiS_Pr); + SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ + SiS_Pr->SiS_DDC_ReadAddr = tempbx; - for(i=0;i<20;i++) { /* TW: Do only 20 attempts to read */ - if(SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = SiS_Pr->SiS_DDC_ReadAddr; /* TW: Write RAB */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* TW: (ERROR: no ack) */ - if (SiS_SetStart(SiS_Pr)) continue; /* TW: Re-start */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01; /* DAB | 0x01 = Read */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: DAB (S0=1=read) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* TW: Read byte */ - SiS_SetStop(SiS_Pr); /* TW: Stop condition */ - return(tempah); - } - return 0xFFFF; + return(SiS_GetChReg(SiS_Pr,0)); } -#ifdef LINUX_XF86 -/* TW: Our own DDC functions */ +/* Read from Chrontel 70xx */ +/* Parameter is [Register no (S7-S0)] */ +USHORT +SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +{ + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) + return(SiS_GetCH700x(SiS_Pr, tempbx)); + else + return(SiS_GetCH701x(SiS_Pr, tempbx)); +} + +/* Our own DDC functions */ USHORT -SiS_InitDDCRegs(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, USHORT DDCdatatype, - BOOLEAN checkcr32) +SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, + USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32) { unsigned char ddcdtype[] = { 0xa0, 0xa0, 0xa0, 0xa2, 0xa6 }; unsigned char flag, cr32; USHORT temp = 0, myadaptnum = adaptnum; if(adaptnum != 0) { - if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_302B))) return 0xFFFF; - if((pSiS->VBFlags & VB_30xBDH) && (adaptnum == 1)) return 0xFFFF; + if(!(VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0xFFFF; + if((VBFlags & VB_30xBDH) && (adaptnum == 1)) return 0xFFFF; } /* adapternum for SiS bridges: 0 = CRT1, 1 = LCD, 2 = VGA2 */ @@ -9770,9 +9955,10 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SIS SiS_Pr->SiS_DDC_Index = 0x11; flag = 0xff; - cr32 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x32); - - if(pSiS->VBFlags & VB_SISBRIDGE) { + cr32 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x32); + +#if 0 + if(VBFlags & VB_SISBRIDGE) { if(myadaptnum == 0) { if(!(cr32 & 0x20)) { myadaptnum = 2; @@ -9785,18 +9971,19 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SIS } } } +#endif - if(pSiS->VGAEngine == SIS_300_VGA) { /* 300 series */ + if(VGAEngine == SIS_300_VGA) { /* 300 series */ if(myadaptnum != 0) { flag = 0; - if(pSiS->VBFlags & VB_SISBRIDGE) { + if(VBFlags & VB_SISBRIDGE) { SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port; SiS_Pr->SiS_DDC_Index = 0x0f; } } - if(!(pSiS->VBFlags & VB_301)) { + if(!(VBFlags & VB_301)) { if((cr32 & 0x80) && (checkcr32)) { if(myadaptnum >= 1) { if(!(cr32 & 0x08)) { @@ -9810,11 +9997,11 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SIS temp = 4 - (myadaptnum * 2); if(flag) temp = 0; - } else { /* 310/325/330 series */ + } else { /* 315/330 series */ /* here we simplify: 0 = CRT1, 1 = CRT2 (VGA, LCD) */ - - if(pSiS->VBFlags & VB_SISBRIDGE) { + + if(VBFlags & VB_SISBRIDGE) { if(myadaptnum == 2) { myadaptnum = 1; } @@ -9822,7 +10009,7 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SIS if(myadaptnum == 1) { flag = 0; - if(pSiS->VBFlags & VB_SISBRIDGE) { + if(VBFlags & VB_SISBRIDGE) { SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port; SiS_Pr->SiS_DDC_Index = 0x0f; } @@ -9840,7 +10027,7 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SIS temp = myadaptnum; if(myadaptnum == 1) { temp = 0; - if(pSiS->VBFlags & VB_LVDS) flag = 0xff; + if(VBFlags & VB_LVDS) flag = 0xff; } if(flag) temp = 0; @@ -9849,10 +10036,12 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SIS SiS_Pr->SiS_DDC_Data = 0x02 << temp; SiS_Pr->SiS_DDC_Clk = 0x01 << temp; + SiS_SetupDDCN(SiS_Pr); + #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "DDC Port %x Index %x Shift %d\n", SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index, temp); -#endif +#endif return 0; } @@ -9862,15 +10051,9 @@ SiS_WriteDABDDC(SiS_Private *SiS_Pr) { if(SiS_SetStart(SiS_Pr)) return 0xFFFF; if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr)) { -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "WriteDAB 1 failed\n"); -#endif return 0xFFFF; } if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_SecAddr)) { -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "WriteDAB 2 failed\n"); -#endif return 0xFFFF; } return(0); @@ -9881,9 +10064,6 @@ SiS_PrepareReadDDC(SiS_Private *SiS_Pr) { if(SiS_SetStart(SiS_Pr)) return 0xFFFF; if(SiS_WriteDDC2Data(SiS_Pr, (SiS_Pr->SiS_DDC_DeviceAddr | 0x01))) { -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "PrepareReadDDC 1 failed\n"); -#endif return 0xFFFF; } return(0); @@ -9902,11 +10082,15 @@ SiS_SendACK(SiS_Private *SiS_Pr, USHORT { SiS_SetSCLKLow(SiS_Pr); if(yesno) { - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data, SiS_Pr->SiS_DDC_Data); + SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); } else { - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data, 0); + SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + 0); } SiS_SetSCLKHigh(SiS_Pr); } @@ -9922,8 +10106,8 @@ SiS_DoProbeDDC(SiS_Private *SiS_Pr) if(SiS_PrepareDDC(SiS_Pr)) { SiS_SetStop(SiS_Pr); #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "DoProbeDDC 1 failed at PrepareDDC\n"); -#endif + xf86DrvMsg(0, X_INFO, "Probe: Prepare failed\n"); +#endif return(0xFFFF); } mask = 0xf0; @@ -9937,6 +10121,9 @@ SiS_DoProbeDDC(SiS_Private *SiS_Pr) } else { failed = TRUE; ret = 0xFFFF; +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "Probe: Read 1 failed\n"); +#endif } } if(failed == FALSE) { @@ -9946,6 +10133,9 @@ SiS_DoProbeDDC(SiS_Private *SiS_Pr) if(temp == value) ret = 0; else { ret = 0xFFFF; +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "Probe: Read 2 failed\n"); +#endif if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { if(temp == 0x30) ret = 0; } @@ -9972,7 +10162,7 @@ SiS_ProbeDDC(SiS_Private *SiS_Pr) } USHORT -SiS_ReadDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT DDCdatatype, unsigned char *buffer) +SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer) { USHORT flag, length, i; unsigned char chksum,gotcha; @@ -10004,28 +10194,7 @@ SiS_ReadDDC(SiS_Private *SiS_Pr, SISPtr return(flag); } -USHORT -SiS_ReadLCDDDC(SiS_Private *SiS_Pr, USHORT length, unsigned char *buffer) -{ - USHORT i=0, flag=0; - - length--; - - SiS_SetSwitchDDC2(SiS_Pr); - if(!(SiS_PrepareDDC(SiS_Pr))) { - for(i=0; i 2) return 0xFFFF; if(DDCdatatype > 4) return 0xFFFF; - if((!(pSiS->VBFlags & VB_VIDEOBRIDGE)) && (adaptnum > 0)) return 0xFFFF; - if(SiS_InitDDCRegs(SiS_Pr, pSiS, adaptnum, DDCdatatype, TRUE) == 0xFFFF) return 0xFFFF; + if((!(VBFlags & VB_VIDEOBRIDGE)) && (adaptnum > 0)) return 0xFFFF; + if(SiS_InitDDCRegs(SiS_Pr, VBFlags, VGAEngine, adaptnum, DDCdatatype, FALSE) == 0xFFFF) return 0xFFFF; + + sr1f = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f); + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1f,0x3f,0x04); + if(VGAEngine == SIS_300_VGA) { + cr17 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80; + if(!cr17) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x17,0x80); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x01); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x03); + } + } + if((sr1f) || (!cr17)) { + SiS_WaitRetrace1(SiS_Pr); + SiS_WaitRetrace1(SiS_Pr); + SiS_WaitRetrace1(SiS_Pr); + SiS_WaitRetrace1(SiS_Pr); + } + if(DDCdatatype == 0) { - return(SiS_ProbeDDC(SiS_Pr)); + result = SiS_ProbeDDC(SiS_Pr); } else { - return(SiS_ReadDDC(SiS_Pr, pSiS, DDCdatatype, buffer)); + result = SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer); } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x1f,sr1f); + if(VGAEngine == SIS_300_VGA) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x17,0x7f,cr17); + } + return result; +} + +#ifdef LINUX_XF86 + +static BOOLEAN +checkedid1(unsigned char *buffer) +{ + /* Check header */ + if((buffer[0] != 0x00) || + (buffer[1] != 0xff) || + (buffer[2] != 0xff) || + (buffer[3] != 0xff) || + (buffer[4] != 0xff) || + (buffer[5] != 0xff) || + (buffer[6] != 0xff) || + (buffer[7] != 0x00)) + return FALSE; + + /* Check EDID version and revision */ + if((buffer[0x12] != 1) || (buffer[0x13] > 4)) return FALSE; + + /* Check week of manufacture for sanity */ + if(buffer[0x10] > 53) return FALSE; + + /* Check year of manufacture for sanity */ + if(buffer[0x11] > 40) return FALSE; + + return TRUE; +} + +static BOOLEAN +checkedid2(unsigned char *buffer) +{ + USHORT year = buffer[6] | (buffer[7] << 8); + + /* Check EDID version */ + if((buffer[0] & 0xf0) != 0x20) return FALSE; + + /* Check week of manufacture for sanity */ + if(buffer[5] > 53) return FALSE; + + /* Check year of manufacture for sanity */ + if((year != 0) && ((year < 1990) || (year > 2030))) return FALSE; + + return TRUE; } /* Sense the LCD parameters (CR36, CR37) via DDC */ @@ -10065,24 +10305,28 @@ SiS_HandleDDC(SiS_Private *SiS_Pr, SISPt USHORT SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) { - USHORT DDCdatatype, paneltype, flag, xres, yres; + USHORT DDCdatatype, paneltype, flag, xres=0, yres=0; USHORT index, myindex, lumsize, numcodes; unsigned char cr37=0, seekcode; BOOLEAN checkexpand = FALSE; int retry, i; unsigned char buffer[256]; - - if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_302B))) return 0; + + for(i=0; i<7; i++) SiS_Pr->CP_DataValid[i] = FALSE; + SiS_Pr->CP_HaveCustomData = FALSE; + SiS_Pr->CP_MaxX = SiS_Pr->CP_MaxY = SiS_Pr->CP_MaxClock = 0; + + if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; if(pSiS->VBFlags & VB_30xBDH) return 0; - if(SiS_InitDDCRegs(SiS_Pr, pSiS, 1, 0, FALSE) == 0xFFFF) return 0; + if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 1, 0, FALSE) == 0xFFFF) return 0; SiS_Pr->SiS_DDC_SecAddr = 0x00; /* Probe supported DA's */ flag = SiS_ProbeDDC(SiS_Pr); -#ifdef TWDEBUG - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, +#ifdef TWDEBUG + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, "CRT2 DDC capabilities 0x%x\n", flag); #endif if(flag & 0x10) { @@ -10099,18 +10343,18 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SIS /* Read the entire EDID */ retry = 2; do { - if(SiS_ReadDDC(SiS_Pr, pSiS, DDCdatatype, buffer)) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, - "CRT2: DDC read failed (attempt %d), %s\n", + if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: DDC read failed (attempt %d), %s\n", (3-retry), (retry == 1) ? "giving up" : "retrying"); retry--; if(retry == 0) return 0xFFFF; } else break; } while(1); - -#ifdef TWDEBUG + +#ifdef TWDEBUG for(i=0; i<256; i+=16) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", buffer[i], buffer[i+1], buffer[i+2], buffer[i+3], buffer[i+4], buffer[i+5], buffer[i+6], buffer[i+7], @@ -10124,119 +10368,261 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SIS switch(DDCdatatype) { case 1: /* Analyze EDID V1 */ /* Catch a few clear cases: */ + if(!(checkedid1(buffer))) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: EDID corrupt\n"); + return 0; + } + if(!(buffer[0x14] & 0x80)) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, "CRT2: Attached display expects analog input (0x%02x)\n", buffer[0x14]); return 0; } - + if((buffer[0x18] & 0x18) != 0x08) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "CRT2: Attached display is not of RGB but of %s type (0x%02x)\n", + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: Attached display is not of RGB but of %s type (0x%02x)\n", ((buffer[0x18] & 0x18) == 0x00) ? "monochrome/greyscale" : - ( ((buffer[0x18] & 0x18) == 0x10) ? "non-RGB multicolor" : + ( ((buffer[0x18] & 0x18) == 0x10) ? "non-RGB multicolor" : "undefined"), buffer[0x18]); return 0; } - - /* Now analyze the first Detailed Timing Block and hope - * that the preferred timing mode is stored there. - */ - xres = buffer[0x38] | ((buffer[0x3a] & 0xf0) << 4); - yres = buffer[0x3b] | ((buffer[0x3d] & 0xf0) << 4); + + /* Now analyze the first Detailed Timing Block and see + * if the preferred timing mode is stored there. If so, + * check if this is a standard panel for which we already + * know the timing. + */ + + paneltype = Panel_Custom; checkexpand = FALSE; - switch(xres) { - case 800: - if(yres == 600) { - paneltype = Panel310_800x600; - checkexpand = TRUE; - } - break; - case 1024: - if(yres == 768) { - paneltype = Panel310_1024x768; - checkexpand = FALSE; /* expand causes error at 640x480, should otherwise be TRUE; */ - } - break; - case 1280: - if(yres == 960) { - if(pSiS->VGAEngine == SIS_300_VGA) { - paneltype = Panel300_1280x960; - } else { - paneltype = Panel310_1280x960; - } - } else if(yres == 1024) { - paneltype = Panel310_1280x1024; - checkexpand = TRUE; - } else if(pSiS->VGAEngine == SIS_315_VGA) { + + if(buffer[0x18] & 0x02) { + + xres = buffer[0x38] | ((buffer[0x3a] & 0xf0) << 4); + yres = buffer[0x3b] | ((buffer[0x3d] & 0xf0) << 4); + + SiS_Pr->CP_PreferredX = xres; + SiS_Pr->CP_PreferredY = yres; + + switch(xres) { + case 800: + if(yres == 600) { + paneltype = Panel_800x600; + checkexpand = TRUE; + } + break; + case 1024: if(yres == 768) { - paneltype = Panel310_1280x768; /* Panel size 1280x768 not supported yet */ - checkexpand = TRUE; - } - } - break; - case 1400: - if(pSiS->VGAEngine == SIS_315_VGA) { - if(yres == 1050) { - paneltype = Panel310_1400x1050; - checkexpand = TRUE; - } - } - break; - case 1600: - if(pSiS->VGAEngine == SIS_315_VGA) { - if(yres == 1200) { - paneltype = Panel310_1600x1200; + paneltype = Panel_1024x768; + checkexpand = TRUE; + } + break; + case 1280: + if(yres == 1024) { + paneltype = Panel_1280x1024; checkexpand = TRUE; - } - } - break; + } else if(yres == 960) { + if(pSiS->VGAEngine == SIS_300_VGA) { + paneltype = Panel300_1280x960; + } else { + paneltype = Panel310_1280x960; + } + } else if(yres == 768) { + if( ((buffer[0x36] | (buffer[0x37] << 8)) == 8100) && + ((buffer[0x39] | ((buffer[0x3a] & 0x0f) << 8)) == (1688 - 1280)) && + ((buffer[0x3c] | ((buffer[0x3d] & 0x0f) << 8)) == (802 - 768)) ) { + paneltype = Panel_1280x768; + checkexpand = FALSE; + cr37 |= 0x10; + } + } + break; + case 1400: + if(pSiS->VGAEngine == SIS_315_VGA) { + if(yres == 1050) { + paneltype = Panel310_1400x1050; + checkexpand = TRUE; + } + } + break; +#if 0 /* Treat this as custom, as we have no valid timing data yet */ + case 1600: + if(pSiS->VGAEngine == SIS_315_VGA) { + if(yres == 1200) { + paneltype = Panel310_1600x1200; + checkexpand = TRUE; + } + } + break; +#endif + } + + if(paneltype != Panel_Custom) { + if((buffer[0x47] & 0x18) == 0x18) { + cr37 |= ((((buffer[0x47] & 0x06) ^ 0x06) << 5) | 0x20); + } else { + /* What now? There is no digital separate output timing... */ + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, + "CRT2: Unable to retrieve Sync polarity information\n"); + cr37 |= 0xc0; /* Default */ + } + } + } - if(buffer[0x18] & 0x02) { - /* If the preferred timing mode is stored in the first - * detailed timing block, we now can extract the sync - * polarisation information as well. This only works - * if the Flags indicate a digital separate output. - */ - if((buffer[0x47] & 0x18) == 0x18) { - cr37 |= ((((buffer[0x47] & 0x06) ^ 0x06) << 5) | 0x20); - } else { - /* What now? There is no digital separate output timing... */ - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, - "CRT2: Unable to retrieve Sync polarity information\n"); - } - - } else { - /* If the preferred timing mode is *not* stored in the first - * detailed timing block, we need to guess the resolution - * from the supported Established Timings and assume the - * default sync polarity - */ + /* If we still don't know what panel this is, we take it + * as a custom panel and derive the timing data from the + * detailed timing blocks + */ + if(paneltype == Panel_Custom) { + + BOOLEAN havesync = FALSE; + int i, temp, base = 0x36; + unsigned long estpack; + unsigned short estx[] = { + 720, 720, 640, 640, 640, 640, 800, 800, + 800, 800, 832,1024,1024,1024,1024,1280, + 1152 + }; + unsigned short esty[] = { + 400, 400, 480, 480, 480, 480, 600, 600, + 600, 600, 624, 768, 768, 768, 768,1024, + 870 + }; + paneltype = 0; - if(buffer[0x24] & 0x01) { - paneltype = Panel310_1280x1024; - checkexpand = TRUE; - cr37 |= 0x20; - } else if(buffer[0x24] & 0x0e) { - paneltype = Panel310_1024x768; - cr37 |= 0xe0; - checkexpand = FALSE; /* Bug at 640x480 */ - } else if(buffer[0x23] & 0x01) { - paneltype = Panel310_800x600; - cr37 |= 0xe0; - checkexpand = TRUE; - } + SiS_Pr->CP_Supports64048075 = TRUE; + + /* Find the maximum resolution */ + + /* 1. From Established timings */ + estpack = (buffer[0x23] << 9) | (buffer[0x24] << 1) | ((buffer[0x25] >> 7) & 0x01); + for(i=16; i>=0; i--) { + if(estpack & (1 << i)) { + if(estx[16 - i] > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = estx[16 - i]; + if(esty[16 - i] > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = esty[16 - i]; + } + } + + /* 2. From Standard Timings */ + for(i=0x26; i < 0x36; i+=2) { + if((buffer[i] != 0x01) && (buffer[i+1] != 0x01)) { + temp = (buffer[i] + 31) * 8; + if(temp > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = temp; + switch((buffer[i+1] & 0xc0) >> 6) { + case 0x03: temp = temp * 9 / 16; break; + case 0x02: temp = temp * 4 / 5; break; + case 0x01: temp = temp * 3 / 4; break; + } + if(temp > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = temp; + } + } + + /* Now extract the Detailed Timings and convert them into modes */ + + for(i = 0; i < 4; i++, base += 18) { + + /* Is this a detailed timing block or a monitor descriptor? */ + if(buffer[base] || buffer[base+1] || buffer[base+2]) { + + xres = buffer[base+2] | ((buffer[base+4] & 0xf0) << 4); + yres = buffer[base+5] | ((buffer[base+7] & 0xf0) << 4); + + SiS_Pr->CP_HDisplay[i] = xres; + SiS_Pr->CP_HSyncStart[i] = xres + (buffer[base+8] | ((buffer[base+11] & 0xc0) << 2)); + SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[base+9] | ((buffer[base+11] & 0x30) << 4)); + SiS_Pr->CP_HTotal[i] = xres + (buffer[base+3] | ((buffer[base+4] & 0x0f) << 8)); + SiS_Pr->CP_HBlankStart[i] = xres + 1; + SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i]; + + SiS_Pr->CP_VDisplay[i] = yres; + SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[base+10] & 0xf0) >> 4) | ((buffer[base+11] & 0x0c) << 2)); + SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[base+10] & 0x0f) | ((buffer[base+11] & 0x03) << 4)); + SiS_Pr->CP_VTotal[i] = yres + (buffer[base+6] | ((buffer[base+7] & 0x0f) << 8)); + SiS_Pr->CP_VBlankStart[i] = yres + 1; + SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i]; + + SiS_Pr->CP_Clock[i] = (buffer[base] | (buffer[base+1] << 8)) * 10; + + SiS_Pr->CP_DataValid[i] = TRUE; + + /* Sort out invalid timings, interlace and too high clocks */ + if((SiS_Pr->CP_HDisplay[i] & 7) || + (SiS_Pr->CP_HDisplay[i] > SiS_Pr->CP_HSyncStart[i]) || + (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HSyncEnd[i]) || + (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HTotal[i]) || + (SiS_Pr->CP_HSyncStart[i] >= SiS_Pr->CP_HSyncEnd[i]) || + (SiS_Pr->CP_HSyncStart[i] > SiS_Pr->CP_HTotal[i]) || + (SiS_Pr->CP_HSyncEnd[i] > SiS_Pr->CP_HTotal[i]) || + (SiS_Pr->CP_VDisplay[i] > SiS_Pr->CP_VSyncStart[i]) || + (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VSyncEnd[i]) || + (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VTotal[i]) || + (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VSyncEnd[i]) || + (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VTotal[i]) || + (SiS_Pr->CP_VSyncEnd[i] > SiS_Pr->CP_VTotal[i]) || + (((pSiS->VBFlags & VB_301C) && (SiS_Pr->CP_Clock[i] > 162500)) || + ((!(pSiS->VBFlags & VB_301C)) && (SiS_Pr->CP_Clock[i] > 108200))) || + (buffer[base+17] & 0x80)) { + + SiS_Pr->CP_DataValid[i] = FALSE; + + } else { + + paneltype = Panel_Custom; + + SiS_Pr->CP_HaveCustomData = TRUE; + + if(xres > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = xres; + if(yres > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = yres; + if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i]; + + SiS_Pr->CP_Vendor = buffer[9] | (buffer[8] << 8); + SiS_Pr->CP_Product = buffer[10] | (buffer[11] << 8); + + /* By default we drive the LCD at 75Hz in 640x480 mode; if + * the panel does not provide this mode, use 60hz + */ + if(!(buffer[0x23] & 0x04)) SiS_Pr->CP_Supports64048075 = FALSE; + + /* We must assume the panel can scale, since we have + * no scaling data + */ + checkexpand = FALSE; + cr37 |= 0x10; + + /* Extract the sync polarisation information. This only works + * if the Flags indicate a digital separate output. + */ + if((buffer[base+17] & 0x18) == 0x18) { + SiS_Pr->CP_HSync_P[i] = (buffer[base+17] & 0x02) ? TRUE : FALSE; + SiS_Pr->CP_VSync_P[i] = (buffer[base+17] & 0x04) ? TRUE : FALSE; + SiS_Pr->CP_SyncValid[i] = TRUE; + if(!havesync) { + cr37 |= ((((buffer[base+17] & 0x06) ^ 0x06) << 5) | 0x20); + havesync = TRUE; + } + } else { + SiS_Pr->CP_SyncValid[i] = FALSE; + } + } + } + } + if(!havesync) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, + "CRT2: Unable to retrieve Sync polarity information\n"); + } } - - if(checkexpand) { - /* If any of the Established low-res modes is supported, the + + if(paneltype && checkexpand) { + /* If any of the Established low-res modes is supported, the * panel can scale automatically. For 800x600 panels, we only * check the even lower ones. */ - if(paneltype == Panel310_800x600) { + if(paneltype == Panel_800x600) { if(buffer[0x23] & 0xfc) cr37 |= 0x10; } else { if(buffer[0x23]) cr37 |= 0x10; @@ -10248,6 +10634,13 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SIS case 3: /* Analyze EDID V2 */ case 4: index = 0; + + if(!(checkedid2(buffer))) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: EDID corrupt\n"); + return 0; + } + if((buffer[0x41] & 0x0f) == 0x03) { index = 0x42 + 3; xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, @@ -10262,20 +10655,31 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SIS buffer[0x41]); return 0; } - - xres = buffer[0x76] | (buffer[0x77] << 8); - yres = buffer[0x78] | (buffer[0x79] << 8); + + paneltype = Panel_Custom; + SiS_Pr->CP_MaxX = xres = buffer[0x76] | (buffer[0x77] << 8); + SiS_Pr->CP_MaxY = yres = buffer[0x78] | (buffer[0x79] << 8); switch(xres) { case 800: if(yres == 600) { - paneltype = Panel310_800x600; + paneltype = Panel_800x600; checkexpand = TRUE; } break; case 1024: if(yres == 768) { - paneltype = Panel310_1024x768; - checkexpand = FALSE; /* Bug at 640x480; we do the scaling ourselves */ + paneltype = Panel_1024x768; + checkexpand = TRUE; + } + break; + case 1152: + if(yres == 768) { + if(pSiS->VGAEngine == SIS_300_VGA) { + paneltype = Panel300_1152x768; + } else { + paneltype = Panel310_1152x768; + } + checkexpand = TRUE; } break; case 1280: @@ -10286,51 +10690,49 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SIS paneltype = Panel300_1280x960; } } else if(yres == 1024) { - paneltype = Panel310_1280x1024; + paneltype = Panel_1280x1024; checkexpand = TRUE; - } else if(pSiS->VGAEngine == SIS_315_VGA) { - if(yres == 768) { - paneltype = Panel310_1280x768; /* Panel size 1280x768 not supported yet */ - checkexpand = TRUE; - } - } + } + /* 1280x768 treated as custom here */ break; case 1400: if(pSiS->VGAEngine == SIS_315_VGA) { if(yres == 1050) { paneltype = Panel310_1400x1050; checkexpand = TRUE; - } + } } break; +#if 0 /* Treat this one as custom since we have no timing data yet */ case 1600: if(pSiS->VGAEngine == SIS_315_VGA) { if(yres == 1200) { paneltype = Panel310_1600x1200; checkexpand = TRUE; - } + } } break; +#endif } - + /* Determine if RGB18 or RGB24 */ if(index) { if((buffer[index] == 0x20) || (buffer[index] == 0x34)) { cr37 |= 0x01; } } - + if(checkexpand) { /* TODO - for now, we let the panel scale */ cr37 |= 0x10; } - + /* Now seek 4-Byte Timing codes and extract sync pol info */ index = 0x80; if(buffer[0x7e] & 0x20) { /* skip Luminance Table (if provided) */ lumsize = buffer[0x80] & 0x1f; if(buffer[0x80] & 0x80) lumsize *= 3; - lumsize++; + lumsize++; /* luminance header byte */ index += lumsize; } index += (((buffer[0x7e] & 0x1c) >> 2) * 8); /* skip Frequency Ranges */ @@ -10346,34 +10748,127 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SIS if(buffer[myindex] == seekcode) { cr37 |= ((((buffer[myindex + 1] & 0x0c) ^ 0x0c) << 4) | 0x20); } else { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, - "CRT2: Unable to retrieve Sync polarity information\n"); + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, + "CRT2: Unable to retrieve Sync polarity information\n"); } } else { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, - "CRT2: Unable to retrieve Sync polarity information\n"); + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, + "CRT2: Unable to retrieve Sync polarity information\n"); + } + + /* Now seek the detailed timing descriptions for custom panels */ + if(paneltype == Panel_Custom) { + + SiS_Pr->CP_Supports64048075 = TRUE; + + index += (numcodes * 4); + numcodes = buffer[0x7f] & 0x07; + for(i=0; iCP_HDisplay[i] = xres; + SiS_Pr->CP_HSyncStart[i] = xres + (buffer[index+8] | ((buffer[index+11] & 0xc0) << 2)); + SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[index+9] | ((buffer[index+11] & 0x30) << 4)); + SiS_Pr->CP_HTotal[i] = xres + (buffer[index+3] | ((buffer[index+4] & 0x0f) << 8)); + SiS_Pr->CP_HBlankStart[i] = xres + 1; + SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i]; + + SiS_Pr->CP_VDisplay[i] = yres; + SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[index+10] & 0xf0) >> 4) | ((buffer[index+11] & 0x0c) << 2)); + SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[index+10] & 0x0f) | ((buffer[index+11] & 0x03) << 4)); + SiS_Pr->CP_VTotal[i] = yres + (buffer[index+6] | ((buffer[index+7] & 0x0f) << 8)); + SiS_Pr->CP_VBlankStart[i] = yres + 1; + SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i]; + + SiS_Pr->CP_Clock[i] = (buffer[index] | (buffer[index+1] << 8)) * 10; + + SiS_Pr->CP_DataValid[i] = TRUE; + + if((SiS_Pr->CP_HDisplay[i] & 7) || + (SiS_Pr->CP_HDisplay[i] > SiS_Pr->CP_HSyncStart[i]) || + (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HSyncEnd[i]) || + (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HTotal[i]) || + (SiS_Pr->CP_HSyncStart[i] >= SiS_Pr->CP_HSyncEnd[i]) || + (SiS_Pr->CP_HSyncStart[i] > SiS_Pr->CP_HTotal[i]) || + (SiS_Pr->CP_HSyncEnd[i] > SiS_Pr->CP_HTotal[i]) || + (SiS_Pr->CP_VDisplay[i] > SiS_Pr->CP_VSyncStart[i]) || + (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VSyncEnd[i]) || + (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VTotal[i]) || + (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VSyncEnd[i]) || + (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VTotal[i]) || + (SiS_Pr->CP_VSyncEnd[i] > SiS_Pr->CP_VTotal[i]) || + (((pSiS->VBFlags & VB_301C) && (SiS_Pr->CP_Clock[i] > 162500)) || + ((!(pSiS->VBFlags & VB_301C)) && (SiS_Pr->CP_Clock[i] > 108200))) || + (buffer[index + 17] & 0x80)) { + + SiS_Pr->CP_DataValid[i] = FALSE; + + } else { + + SiS_Pr->CP_HaveCustomData = TRUE; + + if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i]; + + SiS_Pr->CP_HSync_P[i] = (buffer[index + 17] & 0x02) ? TRUE : FALSE; + SiS_Pr->CP_VSync_P[i] = (buffer[index + 17] & 0x04) ? TRUE : FALSE; + SiS_Pr->CP_SyncValid[i] = TRUE; + + SiS_Pr->CP_Vendor = buffer[2] | (buffer[1] << 8); + SiS_Pr->CP_Product = buffer[3] | (buffer[4] << 8); + + /* We must assume the panel can scale, since we have + * no scaling data + */ + cr37 |= 0x10; + + } + } + } break; - + } - + /* 1280x960 panels are always RGB24, unable to scale and use * high active sync polarity */ if(pSiS->VGAEngine == SIS_315_VGA) { - if(paneltype == Panel310_1280x960) cr37 &= 0x0e; + if(paneltype == Panel310_1280x960) cr37 &= 0x0e; } else { - if(paneltype == Panel300_1280x960) cr37 &= 0x0e; + if(paneltype == Panel300_1280x960) cr37 &= 0x0e; } - + + for(i = 0; i < 7; i++) { + if(SiS_Pr->CP_DataValid[i]) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "Non-standard LCD timing data no. %d:\n", i); + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + " HDisplay %d HSync %d HSyncEnd %d HTotal %d\n", + SiS_Pr->CP_HDisplay[i], SiS_Pr->CP_HSyncStart[i], + SiS_Pr->CP_HSyncEnd[i], SiS_Pr->CP_HTotal[i]); + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + " VDisplay %d VSync %d VSyncEnd %d VTotal %d\n", + SiS_Pr->CP_VDisplay[i], SiS_Pr->CP_VSyncStart[i], + SiS_Pr->CP_VSyncEnd[i], SiS_Pr->CP_VTotal[i]); + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + " Pixel clock: %3.3fMhz\n", (float)SiS_Pr->CP_Clock[i] / 1000); + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, + " To use this, add \"%dx%d\" to the list of Modes in the Screen section\n", + SiS_Pr->CP_HDisplay[i], + SiS_Pr->CP_VDisplay[i]); + } + } + if(paneltype) { + if(!SiS_Pr->CP_PreferredX) SiS_Pr->CP_PreferredX = SiS_Pr->CP_MaxX; + if(!SiS_Pr->CP_PreferredY) SiS_Pr->CP_PreferredY = SiS_Pr->CP_MaxY; cr37 &= 0xf1; - cr37 |= 0x02; /* SiS301 */ SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x36,0xf0,paneltype); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,cr37); + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,0xf1,cr37); SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x08); -#ifdef TWDEBUG +#ifdef TWDEBUG xf86DrvMsgVerb(pSiS->pScrn->scrnIndex, X_PROBED, 3, "CRT2: [DDC LCD results: 0x%02x, 0x%02x]\n", paneltype, cr37); #endif @@ -10389,10 +10884,9 @@ SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SI int retry; unsigned char buffer[256]; - if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_302B))) return 0; -/* if(pSiS->VBFlags & VB_30xBDH) return 0; */ - - if(SiS_InitDDCRegs(SiS_Pr, pSiS, 2, 0, FALSE) == 0xFFFF) return 0; + if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; + + if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 2, 0, FALSE) == 0xFFFF) return 0; SiS_Pr->SiS_DDC_SecAddr = 0x00; @@ -10408,346 +10902,163 @@ SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SI SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */ DDCdatatype = 1; } else { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, - "Do DDC answer\n"); - return 0; /* no DDC support (or no device attached) */ - } - - /* Read the entire EDID */ - retry = 2; - do { - if(SiS_ReadDDC(SiS_Pr, pSiS, DDCdatatype, buffer)) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, - "CRT2: DDC read failed (attempt %d), %s\n", - (3-retry), (retry == 1) ? "giving up" : "retrying"); - retry--; - if(retry == 0) return 0xFFFF; - } else break; - } while(1); - - /* Analyze EDID. We don't have many chances to - * distinguish a flat panel from a CRT... - */ - switch(DDCdatatype) { - case 1: - if(buffer[0x14] & 0x80) { /* Display uses digital input */ - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "CRT2: Attached display expects digital input\n"); - return 0; - } - foundcrt = TRUE; - break; - case 3: - case 4: - if( ((buffer[0x41] & 0x0f) != 0x01) && /* Display does not support analog input */ - ((buffer[0x41] & 0x0f) != 0x02) && - ((buffer[0x41] & 0xf0) != 0x10) && - ((buffer[0x41] & 0xf0) != 0x20) ) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "CRT2: Attached display does not support analog input (0x%02x)\n", - buffer[0x41]); - return 0; - } - foundcrt = TRUE; - break; - } - - if(foundcrt) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x10); - } - return(0); -} - -#if 0 - /* ----- */ -USHORT -SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) -{ - USHORT DDCdatatype, paneltype, flag; - unsigned char cr36=0, cr37=0; - unsigned char tempal, tempah, tempbl, tempbh; - USHORT tempax, tempbx, tempcx, push1, push2, push3; - unsigned char addresstable[] = { 0x00, 0x22, 0x30, 0x40 }; - int i; - unsigned char buffer[256]; - - if(pSiS->VGAEngine != SIS_315_VGA) return 0xFFFF; - if(!(pSiS->VBFlags & (VB_301B|VB_302B))) return 0xFFFF; - - if(SiS_InitDDCRegs(SiS_Pr, pSiS, 1, 0, FALSE) == 0xFFFF) return 0xFFFF; - - flag = SiS_ProbeDDC(SiS_Pr); - if(flag & 0x02) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */ - DDCdatatype = 1; - SiS_Pr->SiS_DDC_SecAddr = 0x3a; - } else if(flag & 0x08) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; /* EDID V2 (P&D-D Monitor) */ - DDCdatatype = 3; - SiS_Pr->SiS_DDC_SecAddr = 0x76; - } else if(flag & 0x10) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; /* EDID V2 (FP) */ - DDCdatatype = 4; - SiS_Pr->SiS_DDC_SecAddr = 0x76; - } else return 0xFFFF; - - - SiS_ReadLCDDDC(SiS_Pr, 4, buffer); - tempbl = buffer[0]; /* 3a - 76 */ - tempbh = buffer[1]; /* 3b - 77 */ - - if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { - - /* Read and analyze EDID V1 (res) */ - - tempah = 0x02; /* 1024x768 by default */ - tempbl &= 0xf0; - if(tempbl != 0x40) { - tempah = 0x03; /* 1280x1024 by default */ - if(tempbl == 0x50) { - if(!tempbh) { - tempbh = buffer[3] & 0xf0; - if(tempbh == 0x30) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; - SiS_Pr->SiS_DDC_SecAddr = 0x23; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempbl = buffer[0]; /* 0x23 */ - tempbh = buffer[1]; /* 0x24 */ - if(tempbl) cr37 |= 0x10; - tempah = 0x0a; /* 1280x768 */ - } - if(tempbh == 0x40) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; - SiS_Pr->SiS_DDC_SecAddr = 0x23; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempbl = buffer[0]; /* 0x23 */ - tempbh = buffer[1]; /* 0x24 */ - if(tempbl) cr37 |= 0x10; - tempah = 0x03; /* 1280x1024 */ - } - tempbh = 0x00; - } - } - if(tempbh == 0x00) goto cr36ready; - tempah = 0x07; /* 1280x960 */ - if(tempbh == 0xc0) goto cr36ready; - } - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; - SiS_Pr->SiS_DDC_SecAddr = 0x18; /* feature support */ - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempbl = buffer[0]; - tempbh = buffer[1]; - if(tempbl & 0x02) goto cr36ready; - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; - SiS_Pr->SiS_DDC_SecAddr = 0x23; /* Established Timings */ - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempbl = buffer[0]; - tempbh = buffer[1]; - tempah = 0x03; - if(!(tempbh & 0x01)) tempah = 0x02; - if(!tempbl) cr37 |= 0x10; - - } else { - - /* Read and analyze EDID V2 (res) */ - - tempah = 0x02; - tempbx = tempbl | (tempbh << 8); - if(tempbx != 1024) tempah = 0x03; - - } - -cr36ready: - cr36 = tempah; - - if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { - - /* Read and analyze EDID V1 (pol) */ - - SiS_Pr->SiS_DDC_SecAddr = 0x47; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempah = buffer[0]; - tempah &= 0x06; - tempah ^= 0x06; - tempah <<= 5; - tempah |= 0x20; - cr37 &= 0x1f; - cr37 |= tempah; - if((cr36 & 0x07) == 0x07) cr37 &= 0x0e; - - } else { - - /* Read and analyze EDID V2 (depth, pol) */ - - push1 = tempah; - SiS_Pr->SiS_DDC_SecAddr = 0x45; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempah = 0x01; - if((buffer[0] != 0x20) && (buffer[0] != 0x34)) { /* RGB18 or 24? */ - tempah = 0x00; - } - cr37 &= 0xfe; - cr37 |= tempah; - - SiS_Pr->SiS_DDC_SecAddr = 0x7e; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempax = (USHORT)(buffer[0] | (buffer[1] << 8)); - push2 = tempax; - tempax &= 0x0003; - tempax *= 0x1b; - push3 = tempax; - tempax = (USHORT)buffer[0]; - tempax &= 0x001c; - tempax >>= 2; - tempax *= 8; - tempbx = push3; - tempbx += tempax; - if(buffer[0] & 0x20) { /* Luminance table provided? */ - SiS_Pr->SiS_DDC_SecAddr = 0x80; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempax = buffer[0] | (buffer[1] << 8); - tempax &= 0x1f; - if(buffer[0] & 0x70) tempax <<= 1; - tempax++; - tempbx += tempax; /* yes -> skip it */ - } - tempcx = push2; - tempax = push1 << 8; - tempbx = (tempbx & 0xff00) | (((tempbx & 0x00ff) + 0x80) & 0x00ff); - if(tempcx & 0xf800) { - tempal = addresstable[((tempax & 0xff00) >> 8)]; - tempcx &= 0xf8ff; - tempcx >>= 11; - for(i=0; iSiS_DDC_SecAddr = (tempbx & 0x00ff); - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempbx += 0x04; - if(buffer[0] == tempal) break; - } - tempah = buffer[1]; - tempah &= 0x0c; - tempah ^= 0x0c; - tempah <<= 4; - tempah |= 0x20; - cr37 &= 0x1f; - cr37 |= tempah; - if((cr36 & 0x07) == 0x07) cr37 &= 0x0e; - } - } - xf86DrvMsg(0, X_INFO, "DDC: cr36 = 0x%02x, cr37 = 0x%02x\n", cr36, cr37); - return 0; -} -#endif - -/* TW: Generic I2C functions (compliant to i2c library) */ - -#if 0 -USHORT -SiS_I2C_GetByte(SiS_Private *SiS_Pr) -{ - return(SiS_ReadDDC2Data(SiS_Pr,0)); -} + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "Do DDC answer\n"); + return 0; /* no DDC support (or no device attached) */ + } -Bool -SiS_I2C_PutByte(SiS_Private *SiS_Pr, USHORT data) -{ - if(SiS_WriteDDC2Data(SiS_Pr,data)) return FALSE; - return TRUE; -} + /* Read the entire EDID */ + retry = 2; + do { + if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: DDC read failed (attempt %d), %s\n", + (3-retry), (retry == 1) ? "giving up" : "retrying"); + retry--; + if(retry == 0) return 0xFFFF; + } else break; + } while(1); -Bool -SiS_I2C_Address(SiS_Private *SiS_Pr, USHORT addr) -{ - if(SiS_SetStart(SiS_Pr)) return FALSE; - if(SiS_WriteDDC2Data(SiS_Pr,addr)) return FALSE; - return TRUE; -} + /* Analyze EDID. We don't have many chances to + * distinguish a flat panel from a CRT... + */ + switch(DDCdatatype) { + case 1: + if(!(checkedid1(buffer))) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: EDID corrupt\n"); + return 0; + } + if(buffer[0x14] & 0x80) { /* Display uses digital input */ + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: Attached display expects digital input\n"); + return 0; + } + SiS_Pr->CP_Vendor = buffer[9] | (buffer[8] << 8); + SiS_Pr->CP_Product = buffer[10] | (buffer[11] << 8); + foundcrt = TRUE; + break; + case 3: + case 4: + if(!(checkedid2(buffer))) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: EDID corrupt\n"); + return 0; + } + if( ((buffer[0x41] & 0x0f) != 0x01) && /* Display does not support analog input */ + ((buffer[0x41] & 0x0f) != 0x02) && + ((buffer[0x41] & 0xf0) != 0x10) && + ((buffer[0x41] & 0xf0) != 0x20) ) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: Attached display does not support analog input (0x%02x)\n", + buffer[0x41]); + return 0; + } + SiS_Pr->CP_Vendor = buffer[2] | (buffer[1] << 8); + SiS_Pr->CP_Product = buffer[3] | (buffer[4] << 8); + foundcrt = TRUE; + break; + } -void -SiS_I2C_Stop(SiS_Private *SiS_Pr) -{ - SiS_SetStop(SiS_Pr); + if(foundcrt) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x10); + } + return(0); } -#endif #endif void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh) { - USHORT tempal,tempah,tempbl; + USHORT tempbl; - tempal = tempax & 0x00FF; - tempah =(tempax >> 8) & 0x00FF; - tempbl = SiS_GetCH70xx(SiS_Pr,tempal); - tempbl = (((tempbl & tempbh) | tempah) << 8 | tempal); + tempbl = SiS_GetCH70xx(SiS_Pr,(tempax & 0x00FF)); + tempbl = (((tempbl & tempbh) << 8) | tempax); SiS_SetCH70xx(SiS_Pr,tempbl); } -/* TW: Generic I2C functions for Chrontel --------- */ +/* Generic I2C functions for Chrontel & DDC --------- */ void SiS_SetSwitchDDC2(SiS_Private *SiS_Pr) { SiS_SetSCLKHigh(SiS_Pr); - /* SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAY); */ - SiS_WaitRetraceDDC(SiS_Pr); + SiS_WaitRetrace1(SiS_Pr); SiS_SetSCLKLow(SiS_Pr); - /* SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAY); */ - SiS_WaitRetraceDDC(SiS_Pr); + SiS_WaitRetrace1(SiS_Pr); +} + +USHORT +SiS_ReadDDC1Bit(SiS_Private *SiS_Pr) +{ + SiS_WaitRetrace1(SiS_Pr); + return((SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x02) >> 1); } -/* TW: Set I2C start condition */ -/* TW: This is done by a SD high-to-low transition while SC is high */ +/* Set I2C start condition */ +/* This is done by a SD high-to-low transition while SC is high */ USHORT SiS_SetStart(SiS_Private *SiS_Pr) { - if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* TW: (SC->low) */ - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* TW: SD->high */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* TW: SC->high */ - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data,0x00); /* TW: SD->low = start condition */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* TW: (SC->low) */ + if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ + SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); /* SD->high */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ + SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + 0x00); /* SD->low = start condition */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->low) */ return 0; } -/* TW: Set I2C stop condition */ -/* TW: This is done by a SD low-to-high transition while SC is high */ +/* Set I2C stop condition */ +/* This is done by a SD low-to-high transition while SC is high */ USHORT SiS_SetStop(SiS_Private *SiS_Pr) { - if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* TW: (SC->low) */ - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data,0x00); /* TW: SD->low */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* TW: SC->high */ - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* TW: SD->high = stop condition */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* TW: (SC->high) */ + if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ + SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + 0x00); /* SD->low */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ + SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); /* SD->high = stop condition */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->high) */ return 0; } -/* TW: Write 8 bits of data */ +/* Write 8 bits of data */ USHORT SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) { USHORT i,flag,temp; - flag=0x80; - for(i=0;i<8;i++) { - SiS_SetSCLKLow(SiS_Pr); /* TW: SC->low */ + flag = 0x80; + for(i=0; i<8; i++) { + SiS_SetSCLKLow(SiS_Pr); /* SC->low */ if(tempax & flag) { - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* TW: Write bit (1) to SD */ + SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); /* Write bit (1) to SD */ } else { - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data,0x00); /* TW: Write bit (0) to SD */ + SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + 0x00); /* Write bit (0) to SD */ } - SiS_SetSCLKHigh(SiS_Pr); /* TW: SC->high */ + SiS_SetSCLKHigh(SiS_Pr); /* SC->high */ flag >>= 1; } - temp = SiS_CheckACK(SiS_Pr); /* TW: Check acknowledge */ + temp = SiS_CheckACK(SiS_Pr); /* Check acknowledge */ return(temp); } @@ -10760,10 +11071,12 @@ SiS_ReadDDC2Data(SiS_Private *SiS_Pr, US for(i=0; i<8; i++) { getdata <<= 1; SiS_SetSCLKLow(SiS_Pr); - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); + SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); SiS_SetSCLKHigh(SiS_Pr); - temp = SiS_GetReg1(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); + temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); if(temp & SiS_Pr->SiS_DDC_Data) getdata |= 0x01; } return(getdata); @@ -10772,8 +11085,10 @@ SiS_ReadDDC2Data(SiS_Private *SiS_Pr, US USHORT SiS_SetSCLKLow(SiS_Private *SiS_Pr) { - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Clk,0x00); /* SetSCLKLow() */ + SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NClk, + 0x00); /* SetSCLKLow() */ SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); return 0; } @@ -10781,68 +11096,63 @@ SiS_SetSCLKLow(SiS_Private *SiS_Pr) USHORT SiS_SetSCLKHigh(SiS_Private *SiS_Pr) { - USHORT temp,watchdog=1000; + USHORT temp, watchdog=1000; - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Clk,SiS_Pr->SiS_DDC_Clk); /* SetSCLKHigh() */ + SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NClk, + SiS_Pr->SiS_DDC_Clk); /* SetSCLKHigh() */ do { - temp = SiS_GetReg1(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); + temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); } while((!(temp & SiS_Pr->SiS_DDC_Clk)) && --watchdog); if (!watchdog) { #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "SetClkHigh failed\n"); -#endif +#endif return 0xFFFF; } SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); return 0; } -void -SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime) -{ - USHORT i; - - for(i=0; iSiS_P3c4,0x05); - } -} - -/* TW: Check I2C acknowledge */ +/* Check I2C acknowledge */ /* Returns 0 if ack ok, non-0 if ack not ok */ USHORT SiS_CheckACK(SiS_Private *SiS_Pr) { USHORT tempah; - SiS_SetSCLKLow(SiS_Pr); /* TW: (SC->low) */ - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* TW: (SD->high) */ - SiS_SetSCLKHigh(SiS_Pr); /* TW: SC->high = clock impulse for ack */ - tempah = SiS_GetReg1(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);/* TW: Read SD */ - SiS_SetSCLKLow(SiS_Pr); /* TW: SC->low = end of clock impulse */ - if(tempah & SiS_Pr->SiS_DDC_Data) return(1); /* TW: Ack OK if bit = 0 */ + SiS_SetSCLKLow(SiS_Pr); /* (SC->low) */ + SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); /* (SD->high) */ + SiS_SetSCLKHigh(SiS_Pr); /* SC->high = clock impulse for ack */ + tempah = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); /* Read SD */ + SiS_SetSCLKLow(SiS_Pr); /* SC->low = end of clock impulse */ + if(tempah & SiS_Pr->SiS_DDC_Data) return(1); /* Ack OK if bit = 0 */ else return(0); } -/* TW: End of I2C functions ----------------------- */ +/* End of I2C functions ----------------------- */ -/* =============== SiS 310/325/330 O.E.M. ================= */ +/* =============== SiS 315/330 O.E.M. ================= */ #ifdef SIS315H static USHORT -GetRAMDACromptr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR *ROMAddr) +GetRAMDACromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT romptr; - if(HwDeviceExtension->jChipType < SIS_330) { - romptr = ROMAddr[0x128] | (ROMAddr[0x129] << 8); + if(HwInfo->jChipType < SIS_330) { + romptr = ROMAddr[0x128] | (ROMAddr[0x129] << 8); if(SiS_Pr->SiS_VBType & VB_SIS301B302B) romptr = ROMAddr[0x12a] | (ROMAddr[0x12b] << 8); } else { - romptr = ROMAddr[0x1a8] | (ROMAddr[0x1a9] << 8); + romptr = ROMAddr[0x1a8] | (ROMAddr[0x1a9] << 8); if(SiS_Pr->SiS_VBType & VB_SIS301B302B) romptr = ROMAddr[0x1aa] | (ROMAddr[0x1ab] << 8); } @@ -10850,16 +11160,17 @@ GetRAMDACromptr(SiS_Private *SiS_Pr, PSI } static USHORT -GetLCDromptr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR *ROMAddr) +GetLCDromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT romptr; - if(HwDeviceExtension->jChipType < SIS_330) { - romptr = ROMAddr[0x120] | (ROMAddr[0x121] << 8); + if(HwInfo->jChipType < SIS_330) { + romptr = ROMAddr[0x120] | (ROMAddr[0x121] << 8); if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) romptr = ROMAddr[0x122] | (ROMAddr[0x123] << 8); } else { - romptr = ROMAddr[0x1a0] | (ROMAddr[0x1a1] << 8); + romptr = ROMAddr[0x1a0] | (ROMAddr[0x1a1] << 8); if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) romptr = ROMAddr[0x1a2] | (ROMAddr[0x1a3] << 8); } @@ -10867,11 +11178,12 @@ GetLCDromptr(SiS_Private *SiS_Pr, PSIS_H } static USHORT -GetTVromptr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR *ROMAddr) +GetTVromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT romptr; - if(HwDeviceExtension->jChipType < SIS_330) { + if(HwInfo->jChipType < SIS_330) { romptr = ROMAddr[0x114] | (ROMAddr[0x115] << 8); if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) romptr = ROMAddr[0x11a] | (ROMAddr[0x11b] << 8); @@ -10884,10 +11196,22 @@ GetTVromptr(SiS_Private *SiS_Pr, PSIS_HW } static USHORT -GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr) +GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { USHORT index; - + + if((IS_SIS650) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { + if((index = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0)) { + index >>= 4; + index *= 3; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; + else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++; + return index; + } + } + } + index = SiS_Pr->SiS_LCDResInfo & 0x0F; if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) index -= 5; else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) index -= 6; @@ -10895,7 +11219,6 @@ GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr) index *= 3; if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++; - return index; } @@ -10913,44 +11236,82 @@ GetLCDPtrIndex(SiS_Private *SiS_Pr) return index; } -/* ---------------------------------------------------------- - GetTVPtrIndex() - return 0 : NTSC Enhanced/Standard - 1 : NTSC Standard TVSimuMode - 2 : PAL Enhanced/Standard - 3 : PAL Standard TVSimuMode - 4 : HiVision Enhanced/Standard - 5 : HiVision Standard TVSimuMode ---------------------------------------------------------- -*/ static USHORT GetTVPtrIndex(SiS_Private *SiS_Pr) { USHORT index; index = 0; - if(SiS_Pr->SiS_VBInfo & SetPALTV) index++; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) index++; /* Hivision TV use PAL */ + if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) index = 2; + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) index = 0; index <<= 1; - if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (SiS_Pr->SiS_SetFlag & TVSimuMode)) - index++; + if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) { + index++; + } return index; } +static ULONG +GetOEMTVPtr661_2(SiS_Private *SiS_Pr) +{ + USHORT index = 0, temp = 0; + + if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1; + if(SiS_Pr->SiS_TVMode & TVSetPALM) index = 2; + if(SiS_Pr->SiS_TVMode & TVSetPALN) index = 3; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) index = 6; + if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { + index = 4; + if(SiS_Pr->SiS_TVMode & TVSetPALM) index++; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) index = 7; + } + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) { + index += 8; + temp++; + } + temp += 0x0100; + } + return(ULONG)(index | (temp << 16)); +} + +static int +GetOEMTVPtr661(SiS_Private *SiS_Pr) +{ + int index = 0; + + if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 2; + if(SiS_Pr->SiS_TVMode & TVSetHiVision) index = 4; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525i) index = 6; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) index = 8; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) index = 10; + + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) index++; + + return index; +} + static void -SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr, USHORT ModeNo) +SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) { - USHORT delay,index,myindex,temp,romptr=0; - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { /* VGA */ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT delay=0,index,myindex,temp,romptr=0; + BOOLEAN dochiptest = TRUE; + + /* Find delay (from ROM, internal tables, PCI subsystem) */ + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { /* ------------ VGA */ if((ROMAddr) && SiS_Pr->SiS_UseROM) { - romptr = GetRAMDACromptr(SiS_Pr, HwDeviceExtension, ROMAddr); + romptr = GetRAMDACromptr(SiS_Pr, HwInfo); if(!romptr) return; delay = ROMAddr[romptr]; } else { @@ -10960,121 +11321,232 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_H delay = 0x0a; } else if(IS_SIS740) { delay = 0x00; - } else if(HwDeviceExtension->jChipType < SIS_330) { + } else if(HwInfo->jChipType < SIS_330) { delay = 0x0c; } else { delay = 0x0c; } } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { delay = 0x00; + } } - - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */ - - index = GetLCDPtrIndexBIOS(SiS_Pr); - myindex = GetLCDPtrIndex(SiS_Pr); - - if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { /* 650+30xLV */ - if(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr)) { - if((ROMAddr) && SiS_Pr->SiS_UseROM) { -#if 0 /* Always use the second pointer on 650; some BIOSes */ - /* still carry old 301 data at the first location */ - romptr = ROMAddr[0x120] | (ROMAddr[0x121] << 8); - if(SiS_Pr->SiS_VBType & VB_SIS302LV) -#endif - romptr = ROMAddr[0x122] | (ROMAddr[0x123] << 8); - if(!romptr) return; - delay = ROMAddr[(romptr + index)]; - } else { - delay = SiS310_LCDDelayCompensation_650301B[myindex]; -#if 0 - if(SiS_Pr->SiS_VBType & VB_SIS302LV) - delay = SiS310_LCDDelayCompensation_650301B[myindex]; -#endif - } - } else { - delay = SiS310_LCDDelayCompensation_651301LV[myindex]; - if(SiS_Pr->SiS_VBType & VB_SIS302LV) - delay = SiS310_LCDDelayCompensation_651302LV[myindex]; - } - } else { - if((ROMAddr) && SiS_Pr->SiS_UseROM && /* 315, 330, 740, 650+301B */ - (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024)) { - romptr = GetLCDromptr(SiS_Pr, HwDeviceExtension, ROMAddr); + + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD|SetCRT2ToLCDA)) { /* ---------- LCD/LCDA */ + + BOOLEAN gotitfrompci = FALSE; + + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return; + + /* Could we detect a PDC for LCD? If yes, use it */ + + if(SiS_Pr->PDC) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,((SiS_Pr->PDC & 0x0f) << 4)); + } + return; + } + + /* This is a piece of typical SiS crap: They code the OEM LCD + * delay into the code, at no defined place in the BIOS. + * We now have to start doing a PCI subsystem check here. + */ + + switch(SiS_Pr->SiS_CustomT) { + case CUT_COMPAQ1280: + case CUT_COMPAQ12802: + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + gotitfrompci = TRUE; + dochiptest = FALSE; + delay = 0x03; + } + break; + case CUT_CLEVO1400: + case CUT_CLEVO14002: + /* if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { */ + gotitfrompci = TRUE; + dochiptest = FALSE; + delay = 0x02; + /* } */ + break; + case CUT_CLEVO1024: + case CUT_CLEVO10242: + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + gotitfrompci = TRUE; + dochiptest = FALSE; + delay = 0x33; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2D,delay); + delay &= 0x0f; + } + break; + } + + /* Could we find it through the PCI ID? If no, use ROM or table */ + + if(!gotitfrompci) { + + index = GetLCDPtrIndexBIOS(SiS_Pr, HwInfo); + myindex = GetLCDPtrIndex(SiS_Pr); + + if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + + if(SiS_IsNotM650orLater(SiS_Pr, HwInfo)) { + + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + /* Always use the second pointer on 650; some BIOSes */ + /* still carry old 301 data at the first location */ + /* romptr = ROMAddr[0x120] | (ROMAddr[0x121] << 8); */ + /* if(SiS_Pr->SiS_VBType & VB_SIS302LV) */ + romptr = ROMAddr[0x122] | (ROMAddr[0x123] << 8); + if(!romptr) return; + delay = ROMAddr[(romptr + index)]; + } else { + delay = SiS310_LCDDelayCompensation_650301LV[myindex]; + } + + } else { + + delay = SiS310_LCDDelayCompensation_651301LV[myindex]; + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) + delay = SiS310_LCDDelayCompensation_651302LV[myindex]; + + } + + } else if((ROMAddr) && SiS_Pr->SiS_UseROM && + (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024)) { + + /* Data for 1280x1024 wrong in BIOS */ + romptr = GetLCDromptr(SiS_Pr, HwInfo); if(!romptr) return; delay = ROMAddr[(romptr + index)]; - } else { + + } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + + if(IS_SIS740) delay = 0x03; + else delay = 0x00; + + } else { + delay = SiS310_LCDDelayCompensation_301[myindex]; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { -#if 0 /* This data is (like the one in the BIOS) wrong. */ - if(IS_SIS650740) { /* V */ - delay = SiS310_LCDDelayCompensation_650301B[myindex]; - } else { -#endif - delay = SiS310_LCDDelayCompensation_3xx301B[myindex]; -#if 0 - } -#endif - } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(IS_SIS650) { - delay = SiS310_LCDDelayCompensation_LVDS650[myindex]; - } else { - delay = SiS310_LCDDelayCompensation_LVDS740[myindex]; - } + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(IS_SIS740) delay = 0x01; + else delay = SiS310_LCDDelayCompensation_650301LV[myindex]; + } else if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + if(IS_SIS740) delay = 0x01; + else delay = SiS310_LCDDelayCompensation_3xx301B[myindex]; } + } + + } /* got it from PCI */ + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,((delay << 4) & 0xf0)); + dochiptest = FALSE; } - } else { /* TV */ - + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* ------------ TV */ + index = GetTVPtrIndex(SiS_Pr); if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { - if(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr)) { - if((ROMAddr) && SiS_Pr->SiS_UseROM) { -#if 0 /* Always use the second pointer on 650; some BIOSes */ - /* still carry old 301 data at the first location */ - romptr = ROMAddr[0x114] | (ROMAddr[0x115] << 8); - if(SiS_Pr->SiS_VBType & VB_SIS302LV) -#endif - romptr = ROMAddr[0x11a] | (ROMAddr[0x11b] << 8); - if(!romptr) return; - delay = ROMAddr[romptr + index]; - } else { - delay = SiS310_TVDelayCompensation_301B[index]; -#if 0 - if(SiS_Pr->SiS_VBType & VB_SIS302LV) - delay = SiS310_TVDelayCompensation_301B[index]; -#endif - } - } else { - delay = SiS310_TVDelayCompensation_651301LV[index]; - if(SiS_Pr->SiS_VBType & VB_SIS302LV) - delay = SiS310_TVDelayCompensation_651302LV[index]; - } + + if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) { + + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + /* Always use the second pointer on 650; some BIOSes */ + /* still carry old 301 data at the first location */ + /* romptr = ROMAddr[0x114] | (ROMAddr[0x115] << 8); */ + /* if(SiS_Pr->SiS_VBType & VB_SIS302LV) */ + romptr = ROMAddr[0x11a] | (ROMAddr[0x11b] << 8); + if(!romptr) return; + delay = ROMAddr[romptr + index]; + + } else { + + delay = SiS310_TVDelayCompensation_301B[index]; + + } + + } else { + + switch(SiS_Pr->SiS_CustomT) { + case CUT_COMPAQ1280: + case CUT_COMPAQ12802: + case CUT_CLEVO1400: + case CUT_CLEVO14002: + delay = 0x02; + dochiptest = FALSE; + break; + case CUT_CLEVO1024: + case CUT_CLEVO10242: + delay = 0x03; + dochiptest = FALSE; + break; + default: + delay = SiS310_TVDelayCompensation_651301LV[index]; + if(SiS_Pr->SiS_VBType & VB_SIS302LV) { + delay = SiS310_TVDelayCompensation_651302LV[index]; + } + } + } + + } else if((ROMAddr) && SiS_Pr->SiS_UseROM) { + + romptr = GetTVromptr(SiS_Pr, HwInfo); + if(!romptr) return; + delay = ROMAddr[romptr + index]; + + } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + + delay = SiS310_TVDelayCompensation_LVDS[index]; + } else { - if((ROMAddr) && SiS_Pr->SiS_UseROM) { - romptr = GetTVromptr(SiS_Pr, HwDeviceExtension, ROMAddr); - if(!romptr) return; - delay = ROMAddr[romptr + index]; - } else { - delay = SiS310_TVDelayCompensation_301[index]; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(IS_SIS740) - delay = SiS310_TVDelayCompensation_740301B[index]; - else - delay = SiS310_TVDelayCompensation_301B[index]; - } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) - delay = SiS310_TVDelayCompensation_LVDS[index]; - } + + delay = SiS310_TVDelayCompensation_301[index]; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(IS_SIS740) { + delay = SiS310_TVDelayCompensation_740301B[index]; + } else { + delay = SiS310_TVDelayCompensation_301B[index]; + } + } + + } + + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) { /* LCDA */ + delay &= 0x0f; + dochiptest = FALSE; } - } + } else return; + + /* Write delay */ + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && dochiptest) { + + temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0) >> 4; + if(temp == 8) { /* 1400x1050 BIOS (COMPAL) */ + delay &= 0x0f; + delay |= 0xb0; + } else if(temp == 6) { + delay &= 0x0f; + delay |= 0xc0; + } else if(temp > 7) { /* 1280x1024 BIOS (which one?) */ + delay = 0x35; + } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2D,delay); + + } else { + + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); + + } + + } else { /* LVDS */ - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); } else { @@ -11085,47 +11557,44 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_H SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); } } - } else { - if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { - temp = (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xf0) >> 4; - if(temp == 8) { - delay &= 0x0f; - delay |= 0xb0; - } else if(temp == 6) { - delay &= 0x0f; - delay |= 0xc0; - } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2D,delay); /* index 2D D[3:0] */ - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); - } + } + } static void -SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { - USHORT index,temp,romptr=0; + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT index,temp,temp1,romptr=0; - temp = GetTVPtrIndex(SiS_Pr); - temp >>= 1; /* 0: NTSC, 1: PAL, 2: HiTV */ + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p|TVSetYPbPr525p)) return; if(ModeNo<=0x13) index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex; else index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex; + temp = GetTVPtrIndex(SiS_Pr); + temp >>= 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */ + temp1 = temp; + if(ROMAddr && SiS_Pr->SiS_UseROM) { - romptr = ROMAddr[0x112] | (ROMAddr[0x113] << 8); - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_661) { + romptr = ROMAddr[0x260] | (ROMAddr[0x261] << 8); + temp1 = GetOEMTVPtr661(SiS_Pr); + temp1 >>= 1; + } else if(HwInfo->jChipType >= SIS_330) { romptr = ROMAddr[0x192] | (ROMAddr[0x193] << 8); + } else { + romptr = ROMAddr[0x112] | (ROMAddr[0x113] << 8); } } if(romptr) { - temp <<= 1; - temp = ROMAddr[romptr + temp + index]; + temp1 <<= 1; + temp = ROMAddr[romptr + temp1 + index]; } else { temp = SiS310_TVAntiFlick1[temp][index]; } @@ -11135,13 +11604,15 @@ SetAntiFlicker(SiS_Private *SiS_Pr, PSIS } static void -SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { - USHORT index,temp,romptr=0; + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT index,temp,temp1,romptr=0; temp = GetTVPtrIndex(SiS_Pr); - temp >>= 1; /* 0: NTSC, 1: PAL, 2: HiTV */ + temp >>= 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */ + temp1 = temp; if(ModeNo<=0x13) index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex; @@ -11149,15 +11620,20 @@ SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; if(ROMAddr && SiS_Pr->SiS_UseROM) { - romptr = ROMAddr[0x124] | (ROMAddr[0x125] << 8); - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_661) { + romptr = ROMAddr[0x26c] | (ROMAddr[0x26d] << 8); + temp1 = GetOEMTVPtr661(SiS_Pr); + temp1 >>= 1; + } else if(HwInfo->jChipType >= SIS_330) { romptr = ROMAddr[0x1a4] | (ROMAddr[0x1a5] << 8); + } else { + romptr = ROMAddr[0x124] | (ROMAddr[0x125] << 8); } } if(romptr) { - temp <<= 1; - temp = ROMAddr[romptr + temp + index]; + temp1 <<= 1; + temp = ROMAddr[romptr + temp1 + index]; } else { temp = SiS310_TVEdge1[temp][index]; } @@ -11166,94 +11642,124 @@ SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS } static void -SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { - USHORT index, temp, i, j; - UCHAR OutputSelect = *SiS_Pr->pSiS_OutputSelect; - - temp = GetTVPtrIndex(SiS_Pr); - temp >>= 1; /* 0: NTSC, 1: PAL, 2: HiTV */ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT index, myindex, oldindex,temp, i, j, flag1 = 0, flag2 = 0, romptr = 0; + ULONG lindex; - if (ModeNo<=0x13) { + if(ModeNo<=0x13) { index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex; } else { index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) temp = 1; /* Hivision TV uses PAL */ + oldindex = index; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); - } - for(i=0x48; i<=0x4A; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); - } - } else { - for(i=0x35, j=0; i<=0x38; i++, j++){ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter1[temp][index][j]); - } + if((HwInfo->jChipType >= SIS_661) && ROMAddr && SiS_Pr->SiS_UseROM) { + if(ModeNo > 0x13) { + index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndexROM661; + } + lindex = GetOEMTVPtr661_2(SiS_Pr); + if(lindex & 0x00ff0000) flag1 = 1; + if(lindex & 0xff000000) flag2 = 1; + lindex &= 0xffff; + + /* NTSC-J: Use PAL filters */ + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) lindex = 1; + + romptr = ROMAddr[0x268] | (ROMAddr[0x269] << 8); + if(flag1) myindex = index * 7; + else myindex = index << 2; + + if(romptr) { + romptr += (lindex << 1); + romptr = (ROMAddr[romptr] | (ROMAddr[romptr+1] << 8)) + myindex; + if(romptr) { + if((!flag1) && (flag2)) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x35,0x00); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x36,0x00); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x37,0x00); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x38,ROMAddr[romptr++]); + } else { + for(i=0x35; i<=0x38; i++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr++]); + } + } + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + for(j=0, i=0x48; i<=0x4a; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr++]); + } + } + return; + } + } } - if(ROMAddr && SiS_Pr->SiS_UseROM) { - OutputSelect = ROMAddr[0xf3]; - if(HwDeviceExtension->jChipType == SIS_330) { - OutputSelect = ROMAddr[0x11b]; - } - } - if(OutputSelect & EnablePALMN) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - temp &= (EnablePALM | EnablePALN); - if(temp == EnablePALM) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALMFilter2[index][j]); - } - for(i=0x48; i<=0x4A; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALMFilter2[index][j]); - } - } else { - for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALMFilter[index][j]); - } - } - } - if(temp == EnablePALN) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALNFilter2[index][j]); - } - for(i=0x48, j=0; i<=0x4A; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALNFilter2[index][j]); - } - } else { - for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALNFilter[index][j]); - } - } - } - } + index = oldindex; + + temp = GetTVPtrIndex(SiS_Pr); + temp >>= 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */ + + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) temp = 1; /* NTSC-J uses PAL */ + else if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 3; /* PAL-M */ + else if(SiS_Pr->SiS_TVMode & TVSetPALN) temp = 4; /* PAL-N */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) temp = 1; /* HiVision uses PAL */ + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + for(i=0x35, j=0; i<=0x38; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); + } + for(i=0x48; i<=0x4A; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); + } + } else { + for(i=0x35, j=0; i<=0x38; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter1[temp][index][j]); + } } } static void -SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { - USHORT index,temp,temp1,i,j,resinfo,romptr=0; + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT index,temp,i,j,resinfo,romptr=0; + ULONG lindex; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; - temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); /* if PALM/N not set */ - temp1 &= (EnablePALM | EnablePALN); - if(temp1) return; + /* NTSC-J data not in BIOS, and already set in SetGroup2 */ + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) return; + + if(HwInfo->jChipType >= SIS_661) { + lindex = GetOEMTVPtr661_2(SiS_Pr) & 0xffff; + lindex <<= 2; + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + romptr = ROMAddr[0x264] | (ROMAddr[0x265] << 8); + } + if(romptr) { + romptr += lindex; + for(j=0, i=0x31; i<=0x34; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); + } + } else { + for(j=0, i=0x31; i<=0x34; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS661_TVPhase[lindex + j]); + } + } + return; + } + + /* PAL-M, PAL-N not in BIOS, and already set in SetGroup2 */ + if(SiS_Pr->SiS_TVMode & (TVSetPALM | TVSetPALN)) return; - if (ModeNo<=0x13) { - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + if(ModeNo<=0x13) { + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; } else { - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; } temp = GetTVPtrIndex(SiS_Pr); @@ -11262,17 +11768,17 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_H */ if((ROMAddr) && SiS_Pr->SiS_UseROM) { romptr = ROMAddr[0x116] | (ROMAddr[0x117] << 8); - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_330) { romptr = ROMAddr[0x196] | (ROMAddr[0x197] << 8); } if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { romptr = ROMAddr[0x11c] | (ROMAddr[0x11d] << 8); - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_330) { romptr = ROMAddr[0x19c] | (ROMAddr[0x19d] << 8); } - if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_SetFlag & TVSimuMode))) { + if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode))) { romptr = ROMAddr[0x116] | (ROMAddr[0x117] << 8); - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_330) { romptr = ROMAddr[0x196] | (ROMAddr[0x197] << 8); } } @@ -11281,295 +11787,463 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_H if(romptr) { romptr += (temp << 2); for(j=0, i=0x31; i<=0x34; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); } } else { index = temp % 2; temp >>= 1; /* 0:NTSC, 1:PAL, 2:HiTV */ for(j=0, i=0x31; i<=0x34; i++, j++) { if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]); - else if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || (SiS_Pr->SiS_SetFlag & TVSimuMode)) - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr2[temp][index][j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]); + else if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr2[temp][index][j]); else - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]); } } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* TW: 650/301LV: (VB_SIS301LV | VB_SIS302LV)) */ - if((!(SiS_Pr->SiS_VBInfo & SetPALTV)) && (ModeNo > 0x13)) { - if(resinfo == 6) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x31,0x21); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x32,0xf0); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x33,0xf5); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x34,0x7f); - } else if (resinfo == 7) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x31,0x21); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x32,0xf0); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x33,0xf5); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x34,0x7f); - } else if (resinfo == 8) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x31,0x1e); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x32,0x8b); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x33,0xfb); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x34,0x7b); + if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision))) { + if((!(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetYPbPr525p | TVSetYPbPr750p))) && (ModeNo > 0x13)) { + if((resinfo == SIS_RI_640x480) || + (resinfo == SIS_RI_800x600)) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x31,0x21); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x32,0xf0); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x33,0xf5); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x34,0x7f); + } else if(resinfo == SIS_RI_1024x768) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x31,0x1e); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x32,0x8b); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x33,0xfb); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x34,0x7b); } } } } void -SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { - SetDelayComp(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo); - /* TW: The TV functions are not for LVDS */ - if( (SiS_Pr->SiS_IF_DEF_LVDS == 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { - SetAntiFlicker(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - SetPhaseIncr(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - SetYFilter(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - SetEdgeEnhance(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - } + SetDelayComp(SiS_Pr,HwInfo,ModeNo); + + if(SiS_Pr->UseCustomMode) return; + + if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { + SetAntiFlicker(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetPhaseIncr(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetYFilter(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { + SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + } + } +} + +static void +SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, + USHORT ModeIdIndex, USHORT RTI) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT delay = 0, romptr = 0, index; + UCHAR *myptr = NULL; + UCHAR temp; + + if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToRAMDAC))) + return; + + delay = SiS_Pr->SiS_RefIndex[RTI].Ext_PDC; + + delay &= 0xf0; + delay >>= 4; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) delay <<= 12; /* BIOS: 8, wrong */ + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + index = GetOEMTVPtr661(SiS_Pr); + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + romptr = ROMAddr[0x25c] | (ROMAddr[0x25d] << 8); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + romptr = ROMAddr[0x25e] | (ROMAddr[0x25f] << 8); + } + } + if(romptr) myptr = &ROMAddr[romptr]; + if(!myptr) { + myptr = (UCHAR *)SiS_TVDelay661_301; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + myptr = (UCHAR *)SiS_TVDelay661_301B; + } + } + delay = myptr[index]; + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) delay >>= 4; /* Should test dual edge */ + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(SiS_Pr->PDC) { + delay = SiS_Pr->PDC & 0x0f; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + delay |= (delay << 12); + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) { + delay = 0x4444; /* TEST THIS */ + } else if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + myptr = GetLCDStructPtr661(SiS_Pr, HwInfo); + if(myptr) delay = myptr[4]; + else delay = 0x44; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + delay |= (delay << 8); + } + } + } + + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2d); + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToRAMDAC)) { + temp &= 0xf0; + temp |= (delay & 0x000f); + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + temp &= 0x0f; + temp |= ((delay & 0xf000) >> 8); + } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,temp); +} + +static void +SetCRT2SyncDither661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT RTI) +{ + USHORT infoflag; + UCHAR temp; + + infoflag = SiS_Pr->SiS_RefIndex[RTI].Ext_InfoFlag; + if(ModeNo <= 0x13) { + infoflag = SiS_GetRegByte(SiS_Pr->SiS_P3ca+2); + } + infoflag &= 0xc0; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + if(temp & 0x20) infoflag = temp; + if(temp & 0x01) infoflag |= 0x01; + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + temp = 0x0c; + if(infoflag & 0x01) temp ^= 0x14; /* BIOS: 18, wrong */ + temp |= (infoflag >> 6); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xe0,temp); + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + temp = 0; + if(infoflag & 0x01) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1a,0x7f,temp); + temp = 0x30; + if(infoflag & 0x01) temp = 0x20; + infoflag &= 0xc0; + temp |= infoflag; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0f,temp); + } +} + +static void +SetPanelParms661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *myptr; + + if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->LVDSHL != -1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,SiS_Pr->LVDSHL); + } + } + + myptr = GetLCDStructPtr661(SiS_Pr, HwInfo); + if(myptr) { + if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->LVDSHL == -1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xE0,myptr[1] & 0x1f); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xE3,myptr[1] & 0x1c); + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0d,0x3f,myptr[2] & 0xc0); + } +} + +void +SiS_OEM661Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex, USHORT RRTI) +{ + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + SetDelayComp661(SiS_Pr,HwInfo,ModeNo,ModeIdIndex,RRTI); + + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + SetCRT2SyncDither661(SiS_Pr,HwInfo,ModeNo,RRTI); + SetPanelParms661(SiS_Pr,HwInfo); + } + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SetPhaseIncr(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetYFilter(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetAntiFlicker(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { + SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + } + } } } /* FinalizeLCD - * This finalizes some Part1 registers for the very panel used. + * This finalizes some CRT2 registers for the very panel used. * If we have a backup if these registers, we use it; otherwise * we set the register according to most BIOSes. However, this * function looks quite different in every BIOS, so you better * pray that we have a backup... */ void -SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { USHORT tempcl,tempch,tempbl,tempbh,tempbx,tempax,temp; USHORT resinfo,modeflag; if(!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) return; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(SiS_Pr->LVDSHL != -1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,SiS_Pr->LVDSHL); + } + } + + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return; + if(SiS_Pr->UseCustomMode) return; + + switch(SiS_Pr->SiS_CustomT) { + case CUT_COMPAQ1280: + case CUT_COMPAQ12802: + case CUT_CLEVO1400: + case CUT_CLEVO14002: + return; + } + if(ModeNo <= 0x13) { - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; } else { - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } + + if(IS_SIS650) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3d4, 0x5f) & 0xf0)) { + if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x02); + } else { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x03); + } + } + } + + if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + /* Maybe all panels? */ + if(SiS_Pr->LVDSHL == -1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01); + } + return; + } + } + + if(SiS_Pr->SiS_CustomT == CUT_CLEVO10242) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(SiS_Pr->LVDSHL == -1) { + /* Maybe all panels? */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01); + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + tempch = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4; + if(tempch == 3) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x25); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x1b); + } + } + return; + } + } } if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); - } - tempch = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); - tempch &= 0xf0; - tempch >>= 4; +#ifdef SET_EMI + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + } +#endif + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + if(SiS_Pr->LVDSHL == -1) { + /* Maybe ACER only? */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01); + } + } + tempch = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4; if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1f,0x76); - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1f,0x76); + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(tempch == 0x03) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x25); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x1b); + } if((SiS_Pr->Backup == TRUE) && (SiS_Pr->Backup_Mode == ModeNo)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,SiS_Pr->Backup_14); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x15,SiS_Pr->Backup_15); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,SiS_Pr->Backup_16); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,SiS_Pr->Backup_17); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,SiS_Pr->Backup_18); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x19,SiS_Pr->Backup_19); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1a,SiS_Pr->Backup_1a); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,SiS_Pr->Backup_1b); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1c,SiS_Pr->Backup_1c); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1d,SiS_Pr->Backup_1d); - } else if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { /* From 1.10.8w */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,0x90); - if(ModeNo <= 0x13) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x11); - if((resinfo == 0) && (resinfo == 2)) return; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x18); - if((resinfo == 1) && (resinfo == 3)) return; - } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x02); - if((ModeNo > 0x13) && (resinfo == 8)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x02); /* 1.10.7u */ -#if 0 - tempbx = 806; /* 0x326 */ /* other older BIOSes */ - tempbx--; - temp = tempbx & 0xff; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,temp); - temp = (tempbx >> 8) & 0x03; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1d,0xf8,temp); -#endif - } - } else { - if(ModeNo <= 0x13) { - if(ModeNo <= 1) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x70); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x19,0xff); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,0x48); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1d,0x12); - } - if(!(modeflag & HalfDCLK)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,0x20); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x15,0x1a); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,0x28); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x4c); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x19,0xdc); - if(ModeNo == 0x12) { - switch(tempch) { - case 0: - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x95); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x19,0xdc); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1a,0x10); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,0x95); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1c,0x48); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1d,0x12); - break; - case 2: - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x95); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,0x48); - break; - case 3: - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,0x95); - break; - } - } - } - } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,SiS_Pr->Backup_14); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,SiS_Pr->Backup_15); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,SiS_Pr->Backup_16); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,SiS_Pr->Backup_17); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,SiS_Pr->Backup_18); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,SiS_Pr->Backup_19); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1a,SiS_Pr->Backup_1a); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,SiS_Pr->Backup_1b); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,SiS_Pr->Backup_1c); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,SiS_Pr->Backup_1d); + } else if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { /* 1.10.8w */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,0x90); + if(ModeNo <= 0x13) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x11); + if((resinfo == 0) || (resinfo == 2)) return; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x18); + if((resinfo == 1) || (resinfo == 3)) return; + } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); + if((ModeNo > 0x13) && (resinfo == SIS_RI_1024x768)) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); /* 1.10.7u */ +#if 0 + tempbx = 806; /* 0x326 */ /* other older BIOSes */ + tempbx--; + temp = tempbx & 0xff; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); + temp = (tempbx >> 8) & 0x03; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1d,0xf8,temp); +#endif + } + } else if(ModeNo <= 0x13) { + if(ModeNo <= 1) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x70); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0xff); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x48); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x12); + } + if(!(modeflag & HalfDCLK)) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,0x20); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,0x1a); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,0x28); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x4c); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0xdc); + if(ModeNo == 0x12) { + switch(tempch) { + case 0: + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x95); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0xdc); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1a,0x10); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x95); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,0x48); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x12); + break; + case 2: + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x95); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x48); + break; + case 3: + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x95); + break; + } + } + } } } } else { - tempcl = tempbh = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x01); + tempcl = tempbh = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x01); tempcl &= 0x0f; tempbh &= 0x70; tempbh >>= 4; - tempbl = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x04); + tempbl = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x04); tempbx = (tempbh << 8) | tempbl; if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if((resinfo == 8) || (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD))) { + if((resinfo == SIS_RI_1024x768) || (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD))) { if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - tempbx = 770; + tempbx = 770; } else { - if(tempbx > 770) tempbx = 770; - if(SiS_Pr->SiS_VGAVDE < 600) { - tempax = 768 - SiS_Pr->SiS_VGAVDE; - tempax >>= 4; /* From 1.10.7w; 1.10.6s: 3; */ - if(SiS_Pr->SiS_VGAVDE <= 480) tempax >>= 4; /* From 1.10.7w; 1.10.6s: < 480; >>=1; */ - tempbx -= tempax; - } + if(tempbx > 770) tempbx = 770; + if(SiS_Pr->SiS_VGAVDE < 600) { + tempax = 768 - SiS_Pr->SiS_VGAVDE; + tempax >>= 4; /* 1.10.7w; 1.10.6s: 3; */ + if(SiS_Pr->SiS_VGAVDE <= 480) tempax >>= 4; /* 1.10.7w; 1.10.6s: < 480; >>=1; */ + tempbx -= tempax; + } } } else return; } -#if 0 - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - } -#endif temp = tempbx & 0xff; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,temp); - temp = (tempbx & 0xff00) >> 8; - temp <<= 4; - temp |= tempcl; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,temp); + temp = ((tempbx & 0xff00) >> 4) | tempcl; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,temp); } } } -#if 0 -/* TW: New and checked from 650/301LV BIOS */ -/* This might clash with newer "FinalizeLCD()" function */ -void -SiS_OEMLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) -{ - USHORT tempbx,tempah,tempbl,tempbh,tempcl; - - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr); - tempbh = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x1a); - tempbh &= 0x38; - tempbh >>= 3; - tempbl = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x18); - tempbx = (tempbh << 8) | tempbl; - if(SiS_Pr->SiS_LCDTypeInfo == 1) tempbx -= 0x12; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,tempbx & 0x00ff); - tempah = (tempbx & 0xff00) >> 8; - tempah &= 0x07; - tempah <<= 3; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1a,0xc7,tempah); - tempah = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x19); - tempah &= 0x0f; - if(SiS_Pr->SiS_LCDTypeInfo == 1) tempah -= 2; - tempah &= 0x0f; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,tempah); - tempah = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x14); - if(SiS_Pr->SiS_LCDTypeInfo == 1) tempah++; - tempah -= 8; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,tempah); - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - tempcl = tempbh = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x01); - tempbh &= 0x70; - tempbh >>= 4; - tempbl = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x04); - tempbx = (tempbh << 8) | tempbl; - if(SiS_Pr->SiS_LCDTypeInfo == 1) { - tempbx -= 0x1e; - tempcl &= 0x0f; - tempcl -= 4; - tempcl &= 0x0f; - } - tempbl = tempbx & 0x00ff; - tempbh = (tempbx >> 8) & 0x00ff; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,tempbl); - tempbh <<= 4; - tempbh |= tempcl; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,tempbh); - } -} -#endif - #endif - /* ================= SiS 300 O.E.M. ================== */ #ifdef SIS300 -#if 0 /* Not used */ -static USHORT -GetRevisionID(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +void +SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex, USHORT RefTabIndex) { - ULONG temp1; -#ifndef LINUX_XF86 - ULONG base; -#endif - USHORT temp2 = 0; + USHORT crt2crtc=0, modeflag, myindex=0; + UCHAR temp; + int i; - if((HwDeviceExtension->jChipType==SIS_540)|| - (HwDeviceExtension->jChipType==SIS_630)|| - (HwDeviceExtension->jChipType==SIS_730)) { -#ifndef LINUX_XF86 - base = 0x80000008; - OutPortLong(base,0xcf8); - temp1 = InPortLong(0xcfc); -#else - temp1=pciReadLong(0x00000000, 0x08); -#endif - temp1 &= 0x000000FF; - temp2 = (USHORT)(temp1); - return temp2; - } - return 0; + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + crt2crtc = SiS_Pr->SiS_RefIndex[RefTabIndex].Ext_CRT2CRTC; + } + + crt2crtc &= 0x3f; + + if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xdf); + } + + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + if(modeflag & HalfDCLK) myindex = 1; + + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + for(i=0; i<7; i++) { + if(barco_p1[myindex][crt2crtc][i][0]) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port, + barco_p1[myindex][crt2crtc][i][0], + barco_p1[myindex][crt2crtc][i][2], + barco_p1[myindex][crt2crtc][i][1]); + } + } + } + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + if(temp & 0x80) { + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x18); + temp++; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); + } + } } -#endif static USHORT -GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR *ROMAddr, int Flag) +GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, int Flag) { + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT tempbx=0,romptr=0; UCHAR customtable300[] = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, @@ -11580,9 +12254,9 @@ GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_H 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }; - if(HwDeviceExtension->jChipType == SIS_300) { + if(HwInfo->jChipType == SIS_300) { - tempbx = SiS_Pr->SiS_LCDResInfo - 2; + tempbx = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0x0f) - 2; if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx += 4; if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 3; @@ -11591,13 +12265,13 @@ GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_H if(ROMAddr[0x235] & 0x80) { tempbx = SiS_Pr->SiS_LCDTypeInfo; if(Flag) { - romptr = ROMAddr[0x255] | (ROMAddr[0x256] << 8); - if(romptr) { + romptr = ROMAddr[0x255] | (ROMAddr[0x256] << 8); + if(romptr) { tempbx = ROMAddr[romptr + SiS_Pr->SiS_LCDTypeInfo]; - } else { + } else { tempbx = customtable300[SiS_Pr->SiS_LCDTypeInfo]; - } - if(tempbx == 0xFF) return 0xFFFF; + } + if(tempbx == 0xFF) return 0xFFFF; } tempbx <<= 1; if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++; @@ -11607,21 +12281,21 @@ GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_H } else { if(Flag) { - if((ROMAddr) && SiS_Pr->SiS_UseROM) { - romptr = ROMAddr[0x255] | (ROMAddr[0x256] << 8); - if(romptr) { - tempbx = ROMAddr[romptr + SiS_Pr->SiS_LCDTypeInfo]; - } else { - tempbx = 0xff; - } - } else { - tempbx = customtable630[SiS_Pr->SiS_LCDTypeInfo]; - } - if(tempbx == 0xFF) return 0xFFFF; - tempbx <<= 2; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempbx += 2; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; - return tempbx; + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + romptr = ROMAddr[0x255] | (ROMAddr[0x256] << 8); + if(romptr) { + tempbx = ROMAddr[romptr + SiS_Pr->SiS_LCDTypeInfo]; + } else { + tempbx = 0xff; + } + } else { + tempbx = customtable630[SiS_Pr->SiS_LCDTypeInfo]; + } + if(tempbx == 0xFF) return 0xFFFF; + tempbx <<= 2; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempbx += 2; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + return tempbx; } tempbx = SiS_Pr->SiS_LCDTypeInfo << 2; if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempbx += 2; @@ -11631,78 +12305,85 @@ GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_H } static void -SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT index,temp,romptr=0; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return; + if((ROMAddr) && SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x237] & 0x01)) return; if(!(ROMAddr[0x237] & 0x02)) return; romptr = ROMAddr[0x24b] | (ROMAddr[0x24c] << 8); } - /* TW: The Panel Compensation Delay should be set according to tables - * here. Unfortunately, various BIOS versions don't case about - * a uniform way using eg. ROM byte 0x220, but use different - * hard coded delays (0x04, 0x20, 0x18) in SetGroup1(). - * Thus we don't set this if the user select a custom pdc or if - * we otherwise detected a valid pdc. + /* The Panel Compensation Delay should be set according to tables + * here. Unfortunately, various BIOS versions don't case about + * a uniform way using eg. ROM byte 0x220, but use different + * hard coded delays (0x04, 0x20, 0x18) in SetGroup1(). + * Thus we don't set this if the user select a custom pdc or if + * we otherwise detected a valid pdc. */ - if(HwDeviceExtension->pdc) return; + if(SiS_Pr->PDC) return; - temp = GetOEMLCDPtr(SiS_Pr,HwDeviceExtension, ROMAddr, 0); + temp = GetOEMLCDPtr(SiS_Pr,HwInfo, 0); - index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex; + if(SiS_Pr->UseCustomMode) + index = 0; + else + index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex; - if(HwDeviceExtension->jChipType != SIS_300) { + if(HwInfo->jChipType != SIS_300) { + if(romptr) { + romptr += (temp * 2); + romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); + romptr += index; + temp = ROMAddr[romptr]; + } else { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp = SiS300_OEMLCDDelay2[temp][index]; + } else { + temp = SiS300_OEMLCDDelay3[temp][index]; + } + } + } else { + if((ROMAddr) && SiS_Pr->SiS_UseROM && (ROMAddr[0x235] & 0x80)) { if(romptr) { romptr += (temp * 2); romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); romptr += index; temp = ROMAddr[romptr]; } else { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - temp = SiS300_OEMLCDDelay2[temp][index]; + temp = SiS300_OEMLCDDelay5[temp][index]; + } + } else { + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + romptr = ROMAddr[0x249] | (ROMAddr[0x24a] << 8); + if(romptr) { + romptr += (temp * 2); + romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); + romptr += index; + temp = ROMAddr[romptr]; } else { - temp = SiS300_OEMLCDDelay3[temp][index]; - } + temp = SiS300_OEMLCDDelay4[temp][index]; + } + } else { + temp = SiS300_OEMLCDDelay4[temp][index]; } - } else { - if((ROMAddr) && SiS_Pr->SiS_UseROM && (ROMAddr[0x235] & 0x80)) { - if(romptr) { - romptr += (temp * 2); - romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); - romptr += index; - temp = ROMAddr[romptr]; - } else { - temp = SiS300_OEMLCDDelay5[temp][index]; - } - } else { - if((ROMAddr) && SiS_Pr->SiS_UseROM) { - romptr = ROMAddr[0x249] | (ROMAddr[0x24a] << 8); - if(romptr) { - romptr += (temp * 2); - romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); - romptr += index; - temp = ROMAddr[romptr]; - } else { - temp = SiS300_OEMLCDDelay4[temp][index]; - } - } else { - temp = SiS300_OEMLCDDelay4[temp][index]; - } - } + } } temp &= 0x3c; SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* index 0A D[6:4] */ } static void -SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { -#if 0 /* TW: Unfinished; VData table missing */ +#if 0 /* Unfinished; Data table missing */ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT index,temp; if((ROMAddr) && SiS_Pr->SiS_UseROM) { @@ -11711,21 +12392,21 @@ SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_ /* No rom pointer in BIOS header! */ } - temp = GetOEMLCDPtr(SiS_Pr,HwDeviceExtension, ROMAddr, 1); - if(temp == 0xFFFF) return; + temp = GetOEMLCDPtr(SiS_Pr,HwInfo, 1); + if(temp = 0xFFFF) return; index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex]._VB_LCDHIndex; for(i=0x14, j=0; i<=0x17; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,i,SiS300_LCDHData[temp][index][j]); + SiS_SetReg(SiS_Pr->SiS_Part1Port,i,SiS300_LCDHData[temp][index][j]); } SiS_SetRegANDOR(SiS_SiS_Part1Port,0x1a, 0xf8, (SiS300_LCDHData[temp][index][j] & 0x07)); index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex]._VB_LCDVIndex; - SiS_SetReg1(SiS_SiS_Part1Port,0x18, SiS300_LCDVData[temp][index][0]); + SiS_SetReg(SiS_SiS_Part1Port,0x18, SiS300_LCDVData[temp][index][0]); SiS_SetRegANDOR(SiS_SiS_Part1Port,0x19, 0xF0, SiS300_LCDVData[temp][index][1]); SiS_SetRegANDOR(SiS_SiS_Part1Port,0x1A, 0xC7, (SiS300_LCDVData[temp][index][2] & 0x38)); for(i=0x1b, j=3; i<=0x1d; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,i,SiS300_LCDVData[temp][index][j]); + SiS_SetReg(SiS_Pr->SiS_Part1Port,i,SiS300_LCDVData[temp][index][j]); } #endif } @@ -11737,21 +12418,22 @@ GetOEMTVPtr(SiS_Private *SiS_Pr) index = 0; if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) index += 4; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) index += 2; - else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) index += 3; - else if(SiS_Pr->SiS_VBInfo & SetPALTV) index += 1; + else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) index += 3; + else if(SiS_Pr->SiS_TVMode & TVSetPAL) index += 1; } else { - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) index += 2; - if(SiS_Pr->SiS_VBInfo & SetPALTV) index += 1; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) index += 2; + if(SiS_Pr->SiS_TVMode & TVSetPAL) index += 1; } return index; } static void -SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT index,temp,romptr=0; if((ROMAddr) && SiS_Pr->SiS_UseROM) { @@ -11770,7 +12452,7 @@ SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_ romptr += index; temp = ROMAddr[romptr]; } else { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { temp = SiS300_OEMTVDelay301[temp][index]; } else { temp = SiS300_OEMTVDelayLVDS[temp][index]; @@ -11781,10 +12463,10 @@ SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_ } static void -SetOEMAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex) +SetOEMAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex) { + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT index,temp,romptr=0; if((ROMAddr) && SiS_Pr->SiS_UseROM) { @@ -11810,12 +12492,15 @@ SetOEMAntiFlicker(SiS_Private *SiS_Pr, P } static void -SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT index,i,j,temp,romptr=0; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) return; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) return; + + if(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSetNTSCJ | TVSetPALM | TVSetPALN)) return; if((ROMAddr) && SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x238] & 0x01)) return; @@ -11828,32 +12513,33 @@ SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSI index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVPhaseIndex; if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - for(i=0x31, j=0; i<=0x34; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Phase2[temp][index][j]); - } + for(i=0x31, j=0; i<=0x34; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Phase2[temp][index][j]); + } } else { - if(romptr) { - romptr += (temp * 2); - romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); - romptr += (index * 4); - for(i=0x31, j=0; i<=0x34; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); - } - } else { - for(i=0x31, j=0; i<=0x34; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Phase1[temp][index][j]); - } - } + if(romptr) { + romptr += (temp * 2); + romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); + romptr += (index * 4); + for(i=0x31, j=0; i<=0x34; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); + } + } else { + for(i=0x31, j=0; i<=0x34; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Phase1[temp][index][j]); + } + } } } static void -SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { - USHORT index,temp,temp1,i,j,romptr=0; + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT index,temp,i,j,romptr=0; - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSCART | SetCRT2ToHiVisionTV)) return; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSCART | SetCRT2ToHiVision | SetCRT2ToYPbPr525750)) return; if((ROMAddr) && SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x238] & 0x01)) return; @@ -11863,64 +12549,85 @@ SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_ temp = GetOEMTVPtr(SiS_Pr); + if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 8; + else if(SiS_Pr->SiS_TVMode & TVSetPALN) temp = 9; + /* NTSCJ uses NTSC filters */ + index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVYFilterIndex; - if(HwDeviceExtension->jChipType > SIS_300) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) { - temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35); - if(temp1 & (EnablePALM | EnablePALN)) { - temp = 8; - if(!(temp1 & EnablePALM)) temp = 9; - } - } - } if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); } for(i=0x48; i<=0x4A; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); } } else { - if(romptr) { + if((romptr) && (!(SiS_Pr->SiS_TVMode & (TVSetPALM|TVSetPALN)))) { romptr += (temp * 2); romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); romptr += (index * 4); for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); } } else { for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Filter1[temp][index][j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter1[temp][index][j]); } } } } +static USHORT +SiS_SearchVBModeID(SiS_Private *SiS_Pr, USHORT *ModeNo) +{ + USHORT ModeIdIndex; + UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; + + if(*ModeNo <= 5) *ModeNo |= 1; + + for(ModeIdIndex=0; ; ModeIdIndex++) { + if(SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == *ModeNo) break; + if(SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == 0xFF) return 0; + } + + if(*ModeNo != 0x07) { + if(*ModeNo > 0x03) return ModeIdIndex; + if(VGAINFO & 0x80) return ModeIdIndex; + ModeIdIndex++; + } + + if(VGAINFO & 0x10) ModeIdIndex++; /* 400 lines */ + /* else 350 lines */ + return ModeIdIndex; +} + void -SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo) +SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex, USHORT RefTableIndex) { - USHORT ModeIdIndex; + USHORT OEMModeIdIndex=0; - ModeIdIndex = SiS_SearchVBModeID(SiS_Pr,ROMAddr,&ModeNo); - if(!(ModeIdIndex)) return; + if(!SiS_Pr->UseCustomMode) { + OEMModeIdIndex = SiS_SearchVBModeID(SiS_Pr,&ModeNo); + if(!(OEMModeIdIndex)) return; + } if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - SetOEMLCDDelay(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - SetOEMLCDData(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - } + SetOEMLCDDelay(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + SetOEMLCDData(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + } } + if(SiS_Pr->UseCustomMode) return; if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SetOEMTVDelay(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - SetOEMAntiFlicker(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - SetOEMPhaseIncr(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - SetOEMYFilter(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - } + SetOEMTVDelay(SiS_Pr, HwInfo, ModeNo,OEMModeIdIndex); + if(SiS_Pr->SiS_VBType & VB_SISVB) { + SetOEMAntiFlicker(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + SetOEMPhaseIncr(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + SetOEMYFilter(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + } } } #endif - diff -puN drivers/video/sis/init301.h~sisfb-update drivers/video/sis/init301.h --- 25/drivers/video/sis/init301.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/init301.h 2004-01-22 03:06:55.000000000 -0800 @@ -1,20 +1,66 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.h,v 1.4 2000/12/02 01:16:17 dawes Exp $ */ +/* $XFree86$ */ +/* + * Data and prototypes for init301.c + * + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the Linux kernel, the following license terms + * apply: + * + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Otherwise, the following license terms apply: + * + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) All advertising materials mentioning features or use of this software + * * must display the following acknowledgement: "This product includes + * * software developed by Thomas Winischhofer, Vienna, Austria." + * * 4) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * + */ + #ifndef _INIT301_ #define _INIT301_ #include "osdef.h" + #include "initdef.h" #include "vgatypes.h" #include "vstruct.h" -#ifdef TC -#include -#include -#include -#include -#include -#endif - #ifdef LINUX_XF86 #include "xf86.h" #include "xf86Pci.h" @@ -24,6 +70,9 @@ #endif #ifdef LINUX_KERNEL +#ifdef SIS_CP +#undef SIS_CP +#endif #include #include #include @@ -35,304 +84,36 @@ #endif #endif -#ifdef WIN2000 -#include -#include -#include -#include "dderror.h" -#include "devioctl.h" -#include "miniport.h" -#include "ntddvdeo.h" -#include "video.h" -#include "sisv.h" -#endif - -#if 0 -extern const USHORT SiS_MDA_DAC[]; -extern const USHORT SiS_CGA_DAC[]; -extern const USHORT SiS_EGA_DAC[]; -extern const USHORT SiS_VGA_DAC[]; -#endif - -extern BOOLEAN SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *RomAddr, USHORT *); - -BOOLEAN SiS_Is301B(SiS_Private *SiS_Pr, USHORT BaseAddr); -BOOLEAN SiS_IsNotM650or651(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_IsDisableCRT2(SiS_Private *SiS_Pr, USHORT BaseAddr); -BOOLEAN SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_CRT2IsLCD(SiS_Private *SiS_Pr, USHORT BaseAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetDefCRT2ExtRegs(SiS_Private *SiS_Pr, USHORT BaseAddr); -USHORT SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -BOOLEAN SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT MODEIdIndex, - USHORT RefreshRateTableIndex,USHORT *i,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo); -void SiS_GetCRT2Data(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -#ifdef SIS315H -void SiS_GetCRT2PtrA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex); -#endif -void SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index, USHORT *ResIndex); -void SiS_GetCRT2Data301(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -USHORT SiS_GetResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -void SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT BaseAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO ); -void SiS_SetHiVision(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_GetLVDSDesData(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCRT2Offset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -USHORT SiS_GetOffset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -USHORT SiS_GetMCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -USHORT SiS_CalcDelayVB(SiS_Private *SiS_Pr); -USHORT SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetRegANDOR(USHORT Port,USHORT Index,USHORT DataAND,USHORT DataOR); -void SiS_SetRegOR(USHORT Port,USHORT Index,USHORT DataOR); -void SiS_SetRegAND(USHORT Port,USHORT Index,USHORT DataAND); -USHORT SiS_GetVGAHT2(SiS_Private *SiS_Pr); -void SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeIdIndex, USHORT RefreshRateTableIndex, - USHORT BaseAddr, USHORT ModeNo); -void SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetGroup5(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex); -void SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_EnableCRT2(SiS_Private *SiS_Pr); -void SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension, int checkcrt2mode); -BOOLEAN SiS_BridgeIsOn(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO); -BOOLEAN SiS_BridgeIsEnable(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO); -BOOLEAN SiS_BridgeInSlave(SiS_Private *SiS_Pr); -void SiS_PresetScratchregister(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetTVSystem(SiS_Private *SiS_Pr); -void SiS_LongWait(SiS_Private *SiS_Pr); -USHORT SiS_GetQueueConfig(SiS_Private *SiS_Pr); -void SiS_VBLongWait(SiS_Private *SiS_Pr); -USHORT SiS_GetVCLKLen(SiS_Private *SiS_Pr, UCHAR *ROMAddr); -void SiS_WaitVBRetrace(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_WaitRetrace1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_WaitRetrace2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_WaitRetraceDDC(SiS_Private *SiS_Pr); -void SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_GetLVDSDesPtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *PanelIndex,USHORT *ResIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -#ifdef SIS315H -void SiS_GetLVDSDesPtrA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *PanelIndex,USHORT *ResIndex); -#endif -void SiS_SetTPData(SiS_Private *SiS_Pr); -void SiS_WhatIsThis(SiS_Private *SiS_Pr, USHORT myvbinfo); -void SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex); -void SiS_GetCHTVRegPtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex); -void SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempax); -USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax); -void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempax); -USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempax); -void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempax); -USHORT SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempax); -#ifdef LINUX_XF86 -USHORT SiS_I2C_GetByte(SiS_Private *SiS_Pr); -Bool SiS_I2C_PutByte(SiS_Private *SiS_Pr, USHORT data); -Bool SiS_I2C_Address(SiS_Private *SiS_Pr, USHORT addr); -void SiS_I2C_Stop(SiS_Private *SiS_Pr); -#endif -void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh); -void SiS_SetSwitchDDC2(SiS_Private *SiS_Pr); -USHORT SiS_SetStart(SiS_Private *SiS_Pr); -USHORT SiS_SetStop(SiS_Private *SiS_Pr); -void SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime); -USHORT SiS_SetSCLKLow(SiS_Private *SiS_Pr); -USHORT SiS_SetSCLKHigh(SiS_Private *SiS_Pr); -USHORT SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax); -USHORT SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax); -USHORT SiS_CheckACK(SiS_Private *SiS_Pr); -USHORT SiS_ReadLCDDDC(SiS_Private *SiS_Pr, USHORT length, unsigned char *buffer); -#ifdef LINUX_XF86 -USHORT SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS); -USHORT SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS); -#endif -#ifdef SIS315H -void SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -void SiS_OEMLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -#endif -#ifdef SIS300 -void SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo); -#endif -BOOLEAN SiS_LowModeStuff(SiS_Private *SiS_Pr, USHORT ModeNo,PSIS_HW_DEVICE_INFO HwDeviceExtension); - -BOOLEAN SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -/* void SiS_CHACRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex); */ - -BOOLEAN SiS_SetCRT2Group301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex); -void SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex); -#ifdef SIS315H -void SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex); -#endif -void SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex); -#ifdef SIS300 -void SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -#endif -#ifdef SIS315H -void SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_CRT2AutoThreshold(SiS_Private *SiS_Pr, USHORT BaseAddr); -#endif -BOOLEAN SiS_GetLCDDDCInfo(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT BaseAddr); -void SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT BaseAddr); -void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT BaseAddr); -void SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT BaseAddr); -void SiS_SetPanelDelay(SiS_Private *SiS_Pr, UCHAR* ROMAddr,PSIS_HW_DEVICE_INFO,USHORT DelayTime); -void SiS_SetPanelDelayLoop(SiS_Private *SiS_Pr, UCHAR *ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT DelayTime, USHORT DelayLoop); -void SiS_ShortDelay(SiS_Private *SiS_Pr, USHORT delay); -void SiS_LongDelay(SiS_Private *SiS_Pr, USHORT delay); -void SiS_GenericDelay(SiS_Private *SiS_Pr, USHORT delay); -void SiS_VBWait(SiS_Private *SiS_Pr); - -void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); - -void SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr); -void SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr); -#ifdef SIS315H -void SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT BaseAddr); -void SiS_Chrontel701xOff(SiS_Private *SiS_Pr); -void SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -void SiS_ChrontelDoSomething4(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -void SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -void SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -void SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -void SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr); -void SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -#ifdef NEWCH701x -void SiS_ChrontelDoSomething5(SiS_Private *SiS_Pr); -#endif -#endif /* 315 */ -#if 0 -BOOLEAN SiS_IsSomethingCR5F(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -#endif -BOOLEAN SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_IsChScart(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_IsTVOrYPbPrOrScart(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -BOOLEAN SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -BOOLEAN SiS_IsSR13_CR30(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); - -extern void SiS_SetReg1(USHORT, USHORT, USHORT); -extern void SiS_SetReg3(USHORT, USHORT); -extern UCHAR SiS_GetReg1(USHORT, USHORT); -extern UCHAR SiS_GetReg2(USHORT); -extern BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo,USHORT *ModeIdIndex); -extern BOOLEAN SiS_GetRatePtr(SiS_Private *SiS_Pr, ULONG, USHORT); -extern void SiS_SetReg4(USHORT, ULONG); -extern ULONG SiS_GetReg3(USHORT); -extern void SiS_SetReg5(USHORT, USHORT); -extern USHORT SiS_GetReg4(USHORT); -extern void SiS_DisplayOff(SiS_Private *SiS_Pr); -extern void SiS_DisplayOn(SiS_Private *SiS_Pr); -extern UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex); -extern BOOLEAN SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *ResInfo,USHORT *DisplayType); -extern BOOLEAN SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *ResInfo,USHORT *DisplayType); -extern void SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO, UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex); -#ifdef SIS315H -extern UCHAR SiS_Get310DRAMType(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -#endif - -#ifdef LINUX_XF86 -/* DDC functions */ -USHORT SiS_InitDDCRegs(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32); -USHORT SiS_WriteDABDDC(SiS_Private *SiS_Pr); -USHORT SiS_PrepareReadDDC(SiS_Private *SiS_Pr); -USHORT SiS_PrepareDDC(SiS_Private *SiS_Pr); -void SiS_SendACK(SiS_Private *SiS_Pr, USHORT yesno); -USHORT SiS_DoProbeDDC(SiS_Private *SiS_Pr); -USHORT SiS_ProbeDDC(SiS_Private *SiS_Pr); -USHORT SiS_ReadDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT DDCdatatype, unsigned char *buffer); -USHORT SiS_HandleDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, - USHORT DDCdatatype, unsigned char *buffer); -#endif - -const UCHAR SiS_HiVisionTable[3][64] = { - { - 0x17, 0x1d, 0x03, 0x09, 0x05, 0x06, 0x0c, 0x0c, - 0x94, 0x49, 0x01, 0x0a, 0x06, 0x0d, 0x04, 0x0a, - 0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x1b, - 0x0c, 0x50, 0x00, 0x97, 0x00, 0xd4, 0x4a, 0x17, - 0x7d, 0x05, 0x4b, 0x00, 0x00, 0xe2, 0x00, 0x02, - 0x03, 0x0a, 0x65, 0x9d, 0x08, 0x92, 0x8f, 0x40, - 0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x14, 0x53, - 0x00, 0x40, 0x44, 0x00, 0xdb, 0x02, 0x3b, 0x00 +const UCHAR SiS_YPbPrTable[3][64] = { + { + 0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c, + 0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a, + 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b, + 0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17, + 0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02, + 0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x53, + 0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00 }, - { - 0x1d, 0x1d, 0x06, 0x09, 0x0b, 0x0c, 0x0c, 0x0c, - 0x98, 0x0a, 0x01, 0x0d, 0x06, 0x0d, 0x04, 0x0a, - 0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x3f, - 0x0c, 0x50, 0xb2, 0x2e, 0x16, 0xb5, 0xf4, 0x03, - 0x7d, 0x11, 0x7d, 0xea, 0x30, 0x36, 0x18, 0x96, - 0x21, 0x0a, 0x58, 0xee, 0x42, 0x92, 0x0f, 0x40, - 0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x04, 0xf3, - 0x00, 0x40, 0x11, 0x00, 0xfc, 0xff, 0x32, 0x00 + { + 0x1d,0x11,0x06,0x09,0x0b,0x0c,0x0c,0x0c, + 0x98,0x0a,0x01,0x0d,0x06,0x0d,0x04,0x0a, + 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f, + 0x0c,0x50,0xb2,0x9f,0x16,0x59,0x4f,0x13, + 0xad,0x11,0xad,0x1d,0x40,0x8a,0x3d,0xb8, + 0x51,0x5e,0x60,0x49,0x7d,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x4b, + 0x43,0x41,0x11,0x00,0xfc,0xff,0x32,0x00 }, - { - 0x13, 0x1d, 0xe8, 0x09, 0x09, 0xed, 0x0c, 0x0c, - 0x98, 0x0a, 0x01, 0x0c, 0x06, 0x0d, 0x04, 0x0a, - 0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x3f, - 0xed, 0x50, 0x70, 0x9f, 0x16, 0x59, 0x2b, 0x13, - 0x27, 0x0b, 0x27, 0xfc, 0x30, 0x27, 0x1c, 0xb0, - 0x4b, 0x4b, 0x6f, 0x2f, 0x63, 0x92, 0x0f, 0x40, - 0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x14, 0x2a, - 0x00, 0x40, 0x11, 0x00, 0xfc, 0xff, 0x32, 0x00 + { + 0x13,0x1d,0xe8,0x09,0x09,0xed,0x0c,0x0c, + 0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a, + 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f, + 0xed,0x50,0x70,0x9f,0x16,0x59,0x2b,0x13, + 0x27,0x0b,0x27,0xfc,0x30,0x27,0x1c,0xb0, + 0x4b,0x4b,0x6f,0x2f,0x63,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x27, + 0x00,0x40,0x11,0x00,0xfc,0xff,0x32,0x00 } }; @@ -358,4 +139,204 @@ const UCHAR SiS_HiTVGroup3_2[] = { 0x18, 0x1d, 0x23, 0x28, 0x4c, 0xaa, 0x01 }; +/* 301C / 302ELV (?) extended Part2 TV registers */ + +static const UCHAR SiS_Part2CLVX_1[] = { + 0x00,0x00, + 0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, + 0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, + 0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C, + 0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E +}; + +static const UCHAR SiS_Part2CLVX_2[] = { + 0x00,0x00, + 0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, + 0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, + 0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C, + 0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E +}; + +static const UCHAR SiS_Part2CLVX_3[] = { /* NTSC, 525i, 525p */ + 0xE0,0x01, + 0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D,0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D, + 0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C,0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C, + 0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E, + 0x7D,0x0C,0x19,0x7E,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02, + 0x58,0x02, + 0x07,0x14,0x07,0x7E,0x06,0x14,0x09,0x7D,0x05,0x14,0x0A,0x7D,0x04,0x13,0x0B,0x7E, + 0x03,0x13,0x0C,0x7E,0x02,0x12,0x0D,0x7F,0x01,0x12,0x0E,0x7F,0x01,0x11,0x0F,0x7F, + 0x00,0x10,0x10,0x00,0x7F,0x0F,0x11,0x01,0x7F,0x0E,0x12,0x01,0x7E,0x0D,0x12,0x03, + 0x7E,0x0C,0x13,0x03,0x7E,0x0B,0x13,0x04,0x7E,0x0A,0x14,0x04,0x7D,0x09,0x14,0x06, + 0x00,0x03, + 0x09,0x0F,0x09,0x7F,0x08,0x0F,0x09,0x00,0x07,0x0F,0x0A,0x00,0x06,0x0F,0x0A,0x01, + 0x06,0x0E,0x0B,0x01,0x05,0x0E,0x0B,0x02,0x04,0x0E,0x0C,0x02,0x04,0x0D,0x0C,0x03, + 0x03,0x0D,0x0D,0x03,0x02,0x0C,0x0D,0x05,0x02,0x0C,0x0E,0x04,0x01,0x0B,0x0E,0x06, + 0x01,0x0B,0x0E,0x06,0x00,0x0A,0x0F,0x07,0x00,0x0A,0x0F,0x07,0x00,0x09,0x0F,0x08, + 0xFF,0xFF +}; + +static const UCHAR SiS_Part2CLVX_4[] = { /* PAL */ + 0x58,0x02, + 0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D, + 0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D, + 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E, + 0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04, + 0x00,0x03, + 0x08,0x12,0x08,0x7E,0x07,0x12,0x09,0x7E,0x06,0x12,0x0A,0x7E,0x05,0x11,0x0B,0x7F, + 0x04,0x11,0x0C,0x7F,0x03,0x11,0x0C,0x00,0x03,0x10,0x0D,0x00,0x02,0x0F,0x0E,0x01, + 0x01,0x0F,0x0F,0x01,0x01,0x0E,0x0F,0x02,0x00,0x0D,0x10,0x03,0x7F,0x0C,0x11,0x04, + 0x7F,0x0C,0x11,0x04,0x7F,0x0B,0x11,0x05,0x7E,0x0A,0x12,0x06,0x7E,0x09,0x12,0x07, + 0x40,0x02, + 0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E,0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D, + 0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C, + 0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x18,0x7F, + 0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1B,0x02, + 0xFF,0xFF +}; + +static const UCHAR SiS_Part2CLVX_5[] = { /* 750p */ + 0x00,0x03, + 0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D, + 0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D, + 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E, + 0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04, + 0xFF,0xFF +}; + +static const UCHAR SiS_Part2CLVX_6[] = { /* 1080i */ + 0x00,0x04, + 0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E,0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D, + 0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C, + 0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x1D /* 0x7D? */ ,0x7C,0x0D,0x18,0x7F, + 0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1B,0x02, + 0xFF,0xFF, +}; + + +#ifdef SIS315H +/* 661 et al LCD data structure */ +static const UCHAR SiS_LCDStruct661[] = { + /* 1600x1200 */ + 0x0B,0xEA,0x81,0x10,0x00,0xC0,0x03,0x21,0x5A,0x23,0x5A,0x23,0x02, + 0x14,0x0A,0x02,0x00,0x30,0x10,0x5A,0x10,0x10,0x0A,0xC0,0x30,0x10, + /* 1400x1050 */ + 0x09,0xEA,0x81,0x80,0xA3,0x70,0x03,0x19,0xD2,0x2A,0xF8,0x2F,0x02, + 0x14,0x0A,0x02,0x00,0x30,0x10,0x5A,0x10,0x10,0x0A,0xC0,0x30,0x10, + /* 1280x1024 */ + 0x03,0xEA,0x81,0x40,0xA1,0x70,0x03,0x19,0xD2,0x2A,0xF8,0x2F,0x02, + 0x14,0x0A,0x02,0x00,0x30,0x10,0x5A,0x10,0x10,0x0A,0xC0,0x30,0x10, + /* 1024x768 */ + 0x02,0xEA,0x80,0x00,0x11,0x88,0x06,0x0B,0xF5,0x6C,0x35,0x62,0x02, + 0x14,0x0A,0x02,0x00,0x30,0x10,0x5A,0x10,0x10,0x0A,0xC0,0x28,0x10, + 0xFF, +}; +#endif + +void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_EnableCRT2(SiS_Private *SiS_Pr); +USHORT SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); +void SiS_WaitRetrace1(SiS_Private *SiS_Pr); +BOOLEAN SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +BOOLEAN SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo); +void SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, + USHORT ModeIdIndex,PSIS_HW_INFO HwInfo, + int checkcrt2mode); +void SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); +void SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); +USHORT SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo); +USHORT SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex); +void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +BOOLEAN SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo); +void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); + +void SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempax); +USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax); +void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempax); +USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempax); +void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempax); +USHORT SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempax); +void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh); +#ifdef SIS315H +void SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_ChrontelInitTVVSync(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr); +#endif /* 315 */ + +USHORT SiS_ReadDDC1Bit(SiS_Private *SiS_Pr); +void SiS_SetSwitchDDC2(SiS_Private *SiS_Pr); +USHORT SiS_SetStart(SiS_Private *SiS_Pr); +USHORT SiS_SetStop(SiS_Private *SiS_Pr); +void SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime); +USHORT SiS_SetSCLKLow(SiS_Private *SiS_Pr); +USHORT SiS_SetSCLKHigh(SiS_Private *SiS_Pr); +USHORT SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax); +USHORT SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax); +USHORT SiS_CheckACK(SiS_Private *SiS_Pr); + +USHORT SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, + USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32); +USHORT SiS_WriteDABDDC(SiS_Private *SiS_Pr); +USHORT SiS_PrepareReadDDC(SiS_Private *SiS_Pr); +USHORT SiS_PrepareDDC(SiS_Private *SiS_Pr); +void SiS_SendACK(SiS_Private *SiS_Pr, USHORT yesno); +USHORT SiS_DoProbeDDC(SiS_Private *SiS_Pr); +USHORT SiS_ProbeDDC(SiS_Private *SiS_Pr); +USHORT SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer); +USHORT SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, + USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer); +#ifdef LINUX_XF86 +USHORT SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS); +USHORT SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS); +#endif + +#ifdef SIS315H +void SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex); +void SiS_OEM661Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex, USHORT RRTI); +void SiS_FinalizeLCD(SiS_Private *, USHORT, USHORT, PSIS_HW_INFO); +#endif +#ifdef SIS300 +void SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex, USHORT RefTabindex); +void SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex,USHORT RefTableIndex); +#endif + +extern void SiS_SetReg(SISIOADDRESS, USHORT, USHORT); +extern void SiS_SetRegByte(SISIOADDRESS, USHORT); +extern void SiS_SetRegShort(SISIOADDRESS, USHORT); +extern void SiS_SetRegLong(SISIOADDRESS, ULONG); +extern UCHAR SiS_GetReg(SISIOADDRESS, USHORT); +extern UCHAR SiS_GetRegByte(SISIOADDRESS); +extern USHORT SiS_GetRegShort(SISIOADDRESS); +extern ULONG SiS_GetRegLong(SISIOADDRESS); +extern void SiS_SetRegANDOR(SISIOADDRESS Port,USHORT Index,USHORT DataAND,USHORT DataOR); +extern void SiS_SetRegOR(SISIOADDRESS Port,USHORT Index,USHORT DataOR); +extern void SiS_SetRegAND(SISIOADDRESS Port,USHORT Index,USHORT DataAND); + +extern void SiS_DisplayOff(SiS_Private *SiS_Pr); +extern void SiS_DisplayOn(SiS_Private *SiS_Pr); + +extern BOOLEAN SiS_SearchModeID(SiS_Private *, USHORT *, USHORT *); +extern UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex); + +extern USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex); +extern USHORT SiS_GetOffset(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo); + +extern void SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO,USHORT ModeNo, + USHORT ModeIdIndex); + + #endif diff -puN drivers/video/sis/init.c~sisfb-update drivers/video/sis/init.c --- 25/drivers/video/sis/init.c~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/init.c 2004-01-22 03:06:55.000000000 -0800 @@ -1,42 +1,60 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.c,v 1.3 2002/24/04 01:16:16 dawes Exp $ */ +/* $XFree86$ */ /* - * Mode switching code (CRT1 section) for SiS 300/540/630/730/315/550/650/740/330 + * Mode initializing code (CRT1 section) for + * for SiS 300/305/540/630/730 and + * SiS 315/550/650/M650/651/661FX/M661FX/740/741/M741/330/660/M660/760/M760 * (Universal module for Linux kernel framebuffer and XFree86 4.x) * - * Assembler-To-C translation - * Copyright 2002 by Thomas Winischhofer - * Minor parts Copyright SiS, Inc. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * Based on BIOS - * 1.10.07, 1.10a for 650/CH7019 - * 1.11.21a for 740/CH7019 - * 1.11.05 for 650/LVDS (w/o Chrontel) - * 1.07.1b, 1.11.6s, 1.11.6w, 1.11.7w, 1.11.8r for 650/301(B/LV) - * 2.04.50 (I) and 2.04.5c (II) for 630/301(B) - * 2.06.50 for 630/301B (dual VGA) - * 2.02.3b, 2.03.02, 2.04.5c, 2.07a and 2.08.b3 for 630/LVDS/LVDS+CH7005 - * 2.04.5c, 2.04.6c for 730+LVDS+CH7005 - * 1.09b for 315/301(B) - * 1.16.51 for 300+301LV (ECS A907) - * 1.01.03 for 330 (Xabre 400) + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the copyright holder not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The copyright holder makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA * - * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. + * Otherwise, the following license terms apply: + * + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) All advertising materials mentioning features or use of this software + * * must display the following acknowledgement: "This product includes + * * software developed by Thomas Winischhofer, Vienna, Austria." + * * 4) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * + * Formerly based on non-functional code-fragements for 300 series by SiS, Inc. + * Used by permission. * * TW says: This code looks awful, I know. But please don't do anything about * this otherwise debugging will be hell. @@ -58,98 +76,208 @@ #include "310vtbl.h" #endif -#ifdef LINUX_XF86 -BOOLEAN SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom); -DisplayModePtr SiSBuildBuiltInModeList(ScrnInfoPtr pScrn); -#ifdef SISDUALHEAD /* TW: For dual head */ -BOOLEAN SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom); -BOOLEAN SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - ScrnInfoPtr pScrn, DisplayModePtr mode); -#endif /* dual head */ -#endif /* linux_xf86 */ - -#ifdef LINUXBIOS -BOOLEAN SiSInit(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -#endif - -#ifdef LINUX_XF86 -BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch); -#else -BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo); -#endif - #if defined(ALLOC_PRAGMA) #pragma alloc_text(PAGE,SiSSetMode) #pragma alloc_text(PAGE,SiSInit) #endif -static ULONG GetDRAMSize(SiS_Private *SiS_Pr, - PSIS_HW_DEVICE_INFO HwDeviceExtension); - -static void DelaySeconds(int seconds); -void SiS_DebugCode(SiS_Private *SiS_Pr, UCHAR code); +/*********************************************/ +/* POINTER INITIALIZATION */ +/*********************************************/ static void -DelaySeconds(int seconds) +InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - int i; -#ifdef WIN2000 - int j; -#endif - - for (i=0;iSiS_StResInfo = SiS_StResInfo; + SiS_Pr->SiS_ModeResInfo = SiS_ModeResInfo; + SiS_Pr->SiS_StandTable = SiS_StandTable; + + SiS_Pr->SiS_NTSCPhase = SiS_NTSCPhase; + SiS_Pr->SiS_PALPhase = SiS_PALPhase; + SiS_Pr->SiS_NTSCPhase2 = SiS_NTSCPhase2; + SiS_Pr->SiS_PALPhase2 = SiS_PALPhase2; + SiS_Pr->SiS_PALMPhase = SiS_PALMPhase; + SiS_Pr->SiS_PALNPhase = SiS_PALNPhase; + SiS_Pr->SiS_PALMPhase2 = SiS_PALMPhase2; + SiS_Pr->SiS_PALNPhase2 = SiS_PALNPhase2; + SiS_Pr->SiS_SpecialPhase = SiS_SpecialPhase; + SiS_Pr->SiS_SpecialPhaseM = SiS_SpecialPhaseM; + SiS_Pr->SiS_SpecialPhaseJ = SiS_SpecialPhaseJ; + + SiS_Pr->SiS_NTSCTiming = SiS_NTSCTiming; + SiS_Pr->SiS_PALTiming = SiS_PALTiming; + SiS_Pr->SiS_HiTVSt1Timing = SiS_HiTVSt1Timing; + SiS_Pr->SiS_HiTVSt2Timing = SiS_HiTVSt2Timing; + + SiS_Pr->SiS_HiTVExtTiming = SiS_HiTVExtTiming; + SiS_Pr->SiS_HiTVGroup3Data = SiS_HiTVGroup3Data; + SiS_Pr->SiS_HiTVGroup3Simu = SiS_HiTVGroup3Simu; +#if 0 + SiS_Pr->SiS_HiTVTextTiming = SiS_HiTVTextTiming; + SiS_Pr->SiS_HiTVGroup3Text = SiS_HiTVGroup3Text; #endif - } -} -void -SiS_DebugCode(SiS_Private *SiS_Pr, UCHAR code) -{ - OutPortByte(0x80, code); - DelaySeconds(0x3); + SiS_Pr->SiS_StPALData = SiS_StPALData; + SiS_Pr->SiS_ExtPALData = SiS_ExtPALData; + SiS_Pr->SiS_StNTSCData = SiS_StNTSCData; + SiS_Pr->SiS_ExtNTSCData = SiS_ExtNTSCData; + SiS_Pr->SiS_St1HiTVData = SiS_StHiTVData; + SiS_Pr->SiS_St2HiTVData = SiS_St2HiTVData; + SiS_Pr->SiS_ExtHiTVData = SiS_ExtHiTVData; + SiS_Pr->SiS_St525iData = SiS_StNTSCData; + SiS_Pr->SiS_St525pData = SiS_St525pData; + SiS_Pr->SiS_St750pData = SiS_St750pData; + SiS_Pr->SiS_Ext525iData = SiS_ExtNTSCData; + SiS_Pr->SiS_Ext525pData = SiS_ExtNTSCData; + SiS_Pr->SiS_Ext750pData = SiS_Ext750pData; + + SiS_Pr->pSiS_OutputSelect = &SiS_OutputSelect; + SiS_Pr->pSiS_SoftSetting = &SiS_SoftSetting; + + SiS_Pr->SiS_LCD1280x960Data = SiS_LCD1280x960Data; + SiS_Pr->SiS_ExtLCD1400x1050Data = SiS_ExtLCD1400x1050Data; + SiS_Pr->SiS_ExtLCD1600x1200Data = SiS_ExtLCD1600x1200Data; + SiS_Pr->SiS_StLCD1400x1050Data = SiS_StLCD1400x1050Data; + SiS_Pr->SiS_StLCD1600x1200Data = SiS_StLCD1600x1200Data; + SiS_Pr->SiS_NoScaleData1400x1050 = SiS_NoScaleData1400x1050; + SiS_Pr->SiS_NoScaleData1600x1200 = SiS_NoScaleData1600x1200; + SiS_Pr->SiS_ExtLCD1280x768Data = SiS_ExtLCD1280x768Data; + SiS_Pr->SiS_StLCD1280x768Data = SiS_StLCD1280x768Data; + SiS_Pr->SiS_NoScaleData1280x768 = SiS_NoScaleData1280x768; + SiS_Pr->SiS_NoScaleData = SiS_NoScaleData; + + SiS_Pr->SiS_LVDS320x480Data_1 = SiS_LVDS320x480Data_1; + SiS_Pr->SiS_LVDS800x600Data_1 = SiS_LVDS800x600Data_1; + SiS_Pr->SiS_LVDS800x600Data_2 = SiS_LVDS800x600Data_2; + SiS_Pr->SiS_LVDS1024x768Data_1 = SiS_LVDS1024x768Data_1; + SiS_Pr->SiS_LVDS1024x768Data_2 = SiS_LVDS1024x768Data_2; + SiS_Pr->SiS_LVDS1280x1024Data_1 = SiS_LVDS1280x1024Data_1; + SiS_Pr->SiS_LVDS1280x1024Data_2 = SiS_LVDS1280x1024Data_2; + SiS_Pr->SiS_LVDS1400x1050Data_1 = SiS_LVDS1400x1050Data_1; + SiS_Pr->SiS_LVDS1400x1050Data_2 = SiS_LVDS1400x1050Data_2; + SiS_Pr->SiS_LVDS1600x1200Data_1 = SiS_LVDS1600x1200Data_1; + SiS_Pr->SiS_LVDS1600x1200Data_2 = SiS_LVDS1600x1200Data_2; + SiS_Pr->SiS_LVDS1280x768Data_1 = SiS_LVDS1280x768Data_1; + SiS_Pr->SiS_LVDS1280x768Data_2 = SiS_LVDS1280x768Data_2; + SiS_Pr->SiS_LVDS1024x600Data_1 = SiS_LVDS1024x600Data_1; + SiS_Pr->SiS_LVDS1024x600Data_2 = SiS_LVDS1024x600Data_2; + SiS_Pr->SiS_LVDS1152x768Data_1 = SiS_LVDS1152x768Data_1; + SiS_Pr->SiS_LVDS1152x768Data_2 = SiS_LVDS1152x768Data_2; + SiS_Pr->SiS_LVDSXXXxXXXData_1 = SiS_LVDSXXXxXXXData_1; + SiS_Pr->SiS_LVDS1280x960Data_1 = SiS_LVDS1280x960Data_1; + SiS_Pr->SiS_LVDS1280x960Data_2 = SiS_LVDS1280x960Data_2; + SiS_Pr->SiS_LVDS640x480Data_1 = SiS_LVDS640x480Data_1; + SiS_Pr->SiS_LVDS1280x960Data_1 = SiS_LVDS1280x1024Data_1; + SiS_Pr->SiS_LVDS1280x960Data_2 = SiS_LVDS1280x1024Data_2; + SiS_Pr->SiS_LVDS640x480Data_1 = SiS_LVDS640x480Data_1; + SiS_Pr->SiS_LVDS640x480Data_2 = SiS_LVDS640x480Data_2; + + SiS_Pr->SiS_LVDSBARCO1366Data_1 = SiS_LVDSBARCO1366Data_1; + SiS_Pr->SiS_LVDSBARCO1366Data_2 = SiS_LVDSBARCO1366Data_2; + SiS_Pr->SiS_LVDSBARCO1024Data_1 = SiS_LVDSBARCO1024Data_1; + SiS_Pr->SiS_LVDSBARCO1024Data_2 = SiS_LVDSBARCO1024Data_2; + SiS_Pr->SiS_LVDS848x480Data_1 = SiS_LVDS848x480Data_1; + SiS_Pr->SiS_LVDS848x480Data_2 = SiS_LVDS848x480Data_2; + + SiS_Pr->SiS_CHTVUNTSCData = SiS_CHTVUNTSCData; + SiS_Pr->SiS_CHTVONTSCData = SiS_CHTVONTSCData; + + SiS_Pr->SiS_LCDA1024x768Data_1 = SiS_LCDA1024x768Data_1; + SiS_Pr->SiS_LCDA1024x768Data_2 = SiS_LCDA1024x768Data_2; + SiS_Pr->SiS_LCDA1280x1024Data_1 = SiS_LCDA1280x1024Data_1; + SiS_Pr->SiS_LCDA1280x1024Data_2 = SiS_LCDA1280x1024Data_2; + SiS_Pr->SiS_LCDA1400x1050Data_1 = SiS_LCDA1400x1050Data_1; + SiS_Pr->SiS_LCDA1400x1050Data_2 = SiS_LCDA1400x1050Data_2; + SiS_Pr->SiS_LCDA1600x1200Data_1 = SiS_LCDA1600x1200Data_1; + SiS_Pr->SiS_LCDA1600x1200Data_2 = SiS_LCDA1600x1200Data_2; + + SiS_Pr->LVDS1024x768Des_1 = SiS_PanelType1076_1; + SiS_Pr->LVDS1280x1024Des_1 = SiS_PanelType1210_1; + SiS_Pr->LVDS1400x1050Des_1 = SiS_PanelType1296_1; + SiS_Pr->LVDS1600x1200Des_1 = SiS_PanelType1600_1; + SiS_Pr->LVDS1024x768Des_2 = SiS_PanelType1076_2; + SiS_Pr->LVDS1280x1024Des_2 = SiS_PanelType1210_2; + SiS_Pr->LVDS1400x1050Des_2 = SiS_PanelType1296_2; + SiS_Pr->LVDS1600x1200Des_2 = SiS_PanelType1600_2; + + SiS_Pr->SiS_PanelTypeNS_1 = SiS_PanelTypeNS_1; + SiS_Pr->SiS_PanelTypeNS_2 = SiS_PanelTypeNS_2; + + SiS_Pr->SiS_CHTVUNTSCDesData = SiS_CHTVUNTSCDesData; + SiS_Pr->SiS_CHTVONTSCDesData = SiS_CHTVONTSCDesData; + SiS_Pr->SiS_CHTVUPALDesData = SiS_CHTVUPALDesData; + SiS_Pr->SiS_CHTVOPALDesData = SiS_CHTVOPALDesData; + + SiS_Pr->SiS_LVDSCRT11280x768_1 = SiS_LVDSCRT11280x768_1; + SiS_Pr->SiS_LVDSCRT11024x600_1 = SiS_LVDSCRT11024x600_1; + SiS_Pr->SiS_LVDSCRT11152x768_1 = SiS_LVDSCRT11152x768_1; + SiS_Pr->SiS_LVDSCRT11280x768_1_H = SiS_LVDSCRT11280x768_1_H; + SiS_Pr->SiS_LVDSCRT11024x600_1_H = SiS_LVDSCRT11024x600_1_H; + SiS_Pr->SiS_LVDSCRT11152x768_1_H = SiS_LVDSCRT11152x768_1_H; + SiS_Pr->SiS_LVDSCRT11280x768_2 = SiS_LVDSCRT11280x768_2; + SiS_Pr->SiS_LVDSCRT11024x600_2 = SiS_LVDSCRT11024x600_2; + SiS_Pr->SiS_LVDSCRT11152x768_2 = SiS_LVDSCRT11152x768_2; + SiS_Pr->SiS_LVDSCRT11280x768_2_H = SiS_LVDSCRT11280x768_2_H; + SiS_Pr->SiS_LVDSCRT11024x600_2_H = SiS_LVDSCRT11024x600_2_H; + SiS_Pr->SiS_LVDSCRT11152x768_2_H = SiS_LVDSCRT11152x768_2_H; + SiS_Pr->SiS_LVDSCRT1320x480_1 = SiS_LVDSCRT1320x480_1; + SiS_Pr->SiS_LVDSCRT1XXXxXXX_1 = SiS_LVDSCRT1XXXxXXX_1; + SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H = SiS_LVDSCRT1XXXxXXX_1_H; + SiS_Pr->SiS_LVDSCRT1640x480_1 = SiS_LVDSCRT1640x480_1; + SiS_Pr->SiS_LVDSCRT1640x480_1_H = SiS_LVDSCRT1640x480_1_H; + SiS_Pr->SiS_LVDSCRT1640x480_2 = SiS_LVDSCRT1640x480_2; + SiS_Pr->SiS_LVDSCRT1640x480_2_H = SiS_LVDSCRT1640x480_2_H; + SiS_Pr->SiS_LVDSCRT1640x480_3 = SiS_LVDSCRT1640x480_3; + SiS_Pr->SiS_LVDSCRT1640x480_3_H = SiS_LVDSCRT1640x480_3_H; } #ifdef SIS300 static void -InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { + InitCommonPointer(SiS_Pr, HwInfo); + + SiS_StandTable[0x04].CRTC[4] = 0x2b; + SiS_StandTable[0x05].CRTC[4] = 0x2b; + SiS_StandTable[0x06].CRTC[4] = 0x54; + SiS_StandTable[0x06].CRTC[5] = 0x80; + SiS_StandTable[0x0d].CRTC[4] = 0x2b; + SiS_StandTable[0x0e].CRTC[4] = 0x54; + SiS_StandTable[0x0e].CRTC[5] = 0x80; + SiS_StandTable[0x11].CRTC[4] = 0x54; + SiS_StandTable[0x11].CRTC[5] = 0x80; + SiS_StandTable[0x11].CRTC[16] = 0x83; + SiS_StandTable[0x11].CRTC[17] = 0x85; + SiS_StandTable[0x12].CRTC[4] = 0x54; + SiS_StandTable[0x12].CRTC[5] = 0x80; + SiS_StandTable[0x12].CRTC[16] = 0x83; + SiS_StandTable[0x12].CRTC[17] = 0x85; + SiS_StandTable[0x13].CRTC[5] = 0xa0; + SiS_StandTable[0x17].CRTC[5] = 0xa0; + SiS_StandTable[0x1a].CRTC[4] = 0x54; + SiS_StandTable[0x1a].CRTC[5] = 0x80; + SiS_StandTable[0x1a].CRTC[16] = 0xea; + SiS_StandTable[0x1a].CRTC[17] = 0x8c; + SiS_StandTable[0x1b].CRTC[4] = 0x54; + SiS_StandTable[0x1b].CRTC[5] = 0x80; + SiS_StandTable[0x1b].CRTC[16] = 0xea; + SiS_StandTable[0x1b].CRTC[17] = 0x8c; + SiS_StandTable[0x1c].CRTC[4] = 0x54; + SiS_StandTable[0x1c].CRTC[5] = 0x80; + SiS_Pr->SiS_SModeIDTable = (SiS_StStruct *)SiS300_SModeIDTable; SiS_Pr->SiS_VBModeIDTable = (SiS_VBModeStruct *)SiS300_VBModeIDTable; - SiS_Pr->SiS_StandTable = (SiS_StandTableStruct *)SiS300_StandTable; SiS_Pr->SiS_EModeIDTable = (SiS_ExtStruct *)SiS300_EModeIDTable; SiS_Pr->SiS_RefIndex = (SiS_Ext2Struct *)SiS300_RefIndex; SiS_Pr->SiS_CRT1Table = (SiS_CRT1TableStruct *)SiS300_CRT1Table; - if(HwDeviceExtension->jChipType == SIS_300) { + if(HwInfo->jChipType == SIS_300) { SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS300_MCLKData_300; /* 300 */ } else { SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS300_MCLKData_630; /* 630, 730 */ } - SiS_Pr->SiS_ECLKData = (SiS_ECLKDataStruct *)SiS300_ECLKData; SiS_Pr->SiS_VCLKData = (SiS_VCLKDataStruct *)SiS300_VCLKData; SiS_Pr->SiS_VBVCLKData = (SiS_VBVCLKDataStruct *)SiS300_VCLKData; SiS_Pr->SiS_ScreenOffset = SiS300_ScreenOffset; - SiS_Pr->SiS_StResInfo = (SiS_StResInfoStruct *)SiS300_StResInfo; - SiS_Pr->SiS_ModeResInfo = (SiS_ModeResInfoStruct *)SiS300_ModeResInfo; - - SiS_Pr->pSiS_OutputSelect = &SiS300_OutputSelect; - SiS_Pr->pSiS_SoftSetting = &SiS300_SoftSetting; SiS_Pr->SiS_SR15 = SiS300_SR15; @@ -178,15 +306,6 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->pSiS_YCSenseData2 = &SiS300_YCSenseData2; #endif - SiS_Pr->SiS_NTSCPhase = SiS300_NTSCPhase; - SiS_Pr->SiS_PALPhase = SiS300_PALPhase; - SiS_Pr->SiS_NTSCPhase2 = SiS300_NTSCPhase2; - SiS_Pr->SiS_PALPhase2 = SiS300_PALPhase2; - SiS_Pr->SiS_PALMPhase = SiS300_PALMPhase; - SiS_Pr->SiS_PALNPhase = SiS300_PALNPhase; - SiS_Pr->SiS_PALMPhase2 = SiS300_PALMPhase2; - SiS_Pr->SiS_PALNPhase2 = SiS300_PALNPhase2; - SiS_Pr->SiS_StLCD1024x768Data = (SiS_LCDDataStruct *)SiS300_StLCD1024x768Data; SiS_Pr->SiS_ExtLCD1024x768Data = (SiS_LCDDataStruct *)SiS300_ExtLCD1024x768Data; SiS_Pr->SiS_St2LCD1024x768Data = (SiS_LCDDataStruct *)SiS300_St2LCD1024x768Data; @@ -195,68 +314,21 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->SiS_St2LCD1280x1024Data = (SiS_LCDDataStruct *)SiS300_St2LCD1280x1024Data; SiS_Pr->SiS_NoScaleData1024x768 = (SiS_LCDDataStruct *)SiS300_NoScaleData1024x768; SiS_Pr->SiS_NoScaleData1280x1024 = (SiS_LCDDataStruct *)SiS300_NoScaleData1280x1024; - SiS_Pr->SiS_LCD1280x960Data = (SiS_LCDDataStruct *)SiS300_LCD1280x960Data; - SiS_Pr->SiS_ExtLCD1400x1050Data = (SiS_LCDDataStruct *)SiS300_ExtLCD1400x1050Data; - SiS_Pr->SiS_ExtLCD1600x1200Data = (SiS_LCDDataStruct *)SiS300_ExtLCD1600x1200Data; - SiS_Pr->SiS_StLCD1400x1050Data = (SiS_LCDDataStruct *)SiS300_StLCD1400x1050Data; - SiS_Pr->SiS_StLCD1600x1200Data = (SiS_LCDDataStruct *)SiS300_StLCD1600x1200Data; - SiS_Pr->SiS_NoScaleData1400x1050 = (SiS_LCDDataStruct *)SiS300_NoScaleData1400x1050; - SiS_Pr->SiS_NoScaleData1600x1200 = (SiS_LCDDataStruct *)SiS300_NoScaleData1600x1200; - - SiS_Pr->SiS_StPALData = (SiS_TVDataStruct *)SiS300_StPALData; - SiS_Pr->SiS_ExtPALData = (SiS_TVDataStruct *)SiS300_ExtPALData; - SiS_Pr->SiS_StNTSCData = (SiS_TVDataStruct *)SiS300_StNTSCData; - SiS_Pr->SiS_ExtNTSCData = (SiS_TVDataStruct *)SiS300_ExtNTSCData; -/* SiS_Pr->SiS_St1HiTVData = (SiS_TVDataStruct *)SiS300_St1HiTVData; */ - SiS_Pr->SiS_St2HiTVData = (SiS_TVDataStruct *)SiS300_St2HiTVData; - SiS_Pr->SiS_ExtHiTVData = (SiS_TVDataStruct *)SiS300_ExtHiTVData; - - SiS_Pr->SiS_NTSCTiming = SiS300_NTSCTiming; - SiS_Pr->SiS_PALTiming = SiS300_PALTiming; - SiS_Pr->SiS_HiTVSt1Timing = SiS300_HiTVSt1Timing; - SiS_Pr->SiS_HiTVSt2Timing = SiS300_HiTVSt2Timing; - SiS_Pr->SiS_HiTVTextTiming = SiS300_HiTVTextTiming; - SiS_Pr->SiS_HiTVGroup3Data = SiS300_HiTVGroup3Data; - SiS_Pr->SiS_HiTVGroup3Simu = SiS300_HiTVGroup3Simu; - SiS_Pr->SiS_HiTVGroup3Text = SiS300_HiTVGroup3Text; SiS_Pr->SiS_PanelDelayTbl = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTbl; + SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTbl; +#if 0 SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTblLVDS; +#endif - SiS_Pr->SiS_LVDS800x600Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS800x600Data_1; - SiS_Pr->SiS_LVDS800x600Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS800x600Data_2; - SiS_Pr->SiS_LVDS1024x768Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1024x768Data_1; - SiS_Pr->SiS_LVDS1024x768Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1024x768Data_2; - SiS_Pr->SiS_LVDS1280x1024Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x1024Data_1; - SiS_Pr->SiS_LVDS1280x1024Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x1024Data_2; - SiS_Pr->SiS_LVDS1280x960Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x1024Data_1; - SiS_Pr->SiS_LVDS1280x960Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x1024Data_2; - SiS_Pr->SiS_LVDS1400x1050Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1400x1050Data_1; - SiS_Pr->SiS_LVDS1400x1050Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1400x1050Data_2; - SiS_Pr->SiS_LVDS1600x1200Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1600x1200Data_1; - SiS_Pr->SiS_LVDS1600x1200Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1600x1200Data_2; - SiS_Pr->SiS_LVDS1280x768Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x768Data_1; - SiS_Pr->SiS_LVDS1280x768Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x768Data_2; - SiS_Pr->SiS_LVDS1024x600Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1024x600Data_1; - SiS_Pr->SiS_LVDS1024x600Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1024x600Data_2; - SiS_Pr->SiS_LVDS1152x768Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1152x768Data_1; - SiS_Pr->SiS_LVDS1152x768Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1152x768Data_2; - SiS_Pr->SiS_LVDSXXXxXXXData_1 = (SiS_LVDSDataStruct *)SiS300_LVDSXXXxXXXData_1; - SiS_Pr->SiS_LVDS320x480Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS320x480Data_1; - SiS_Pr->SiS_LVDS640x480Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS640x480Data_1; - SiS_Pr->SiS_LCDA1400x1050Data_1 = (SiS_LVDSDataStruct *)SiS300_LCDA1400x1050Data_1; - SiS_Pr->SiS_LCDA1400x1050Data_2 = (SiS_LVDSDataStruct *)SiS300_LCDA1400x1050Data_2; - SiS_Pr->SiS_LCDA1600x1200Data_1 = (SiS_LVDSDataStruct *)SiS300_LCDA1600x1200Data_1; - SiS_Pr->SiS_LCDA1600x1200Data_2 = (SiS_LVDSDataStruct *)SiS300_LCDA1600x1200Data_2; - SiS_Pr->SiS_CHTVUNTSCData = (SiS_LVDSDataStruct *)SiS300_CHTVUNTSCData; - SiS_Pr->SiS_CHTVONTSCData = (SiS_LVDSDataStruct *)SiS300_CHTVONTSCData; SiS_Pr->SiS_CHTVUPALData = (SiS_LVDSDataStruct *)SiS300_CHTVUPALData; SiS_Pr->SiS_CHTVOPALData = (SiS_LVDSDataStruct *)SiS300_CHTVOPALData; - SiS_Pr->SiS_CHTVUPALMData = (SiS_LVDSDataStruct *)SiS300_CHTVUNTSCData; /* not supported on 300 series */ - SiS_Pr->SiS_CHTVOPALMData = (SiS_LVDSDataStruct *)SiS300_CHTVONTSCData; /* not supported on 300 series */ + SiS_Pr->SiS_CHTVUPALMData = SiS_CHTVUNTSCData; /* not supported on 300 series */ + SiS_Pr->SiS_CHTVOPALMData = SiS_CHTVONTSCData; /* not supported on 300 series */ SiS_Pr->SiS_CHTVUPALNData = (SiS_LVDSDataStruct *)SiS300_CHTVUPALData; /* not supported on 300 series */ SiS_Pr->SiS_CHTVOPALNData = (SiS_LVDSDataStruct *)SiS300_CHTVOPALData; /* not supported on 300 series */ SiS_Pr->SiS_CHTVSOPALData = (SiS_LVDSDataStruct *)SiS300_CHTVSOPALData; + SiS_Pr->SiS_PanelType00_1 = (SiS_LVDSDesStruct *)SiS300_PanelType00_1; SiS_Pr->SiS_PanelType01_1 = (SiS_LVDSDesStruct *)SiS300_PanelType01_1; SiS_Pr->SiS_PanelType02_1 = (SiS_LVDSDesStruct *)SiS300_PanelType02_1; @@ -289,32 +361,28 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->SiS_PanelType0d_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0d_2; SiS_Pr->SiS_PanelType0e_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0e_2; SiS_Pr->SiS_PanelType0f_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0f_2; - SiS_Pr->SiS_PanelTypeNS_1 = (SiS_LVDSDesStruct *)SiS300_PanelTypeNS_1; - SiS_Pr->SiS_PanelTypeNS_2 = (SiS_LVDSDesStruct *)SiS300_PanelTypeNS_2; - SiS_Pr->SiS_CHTVUNTSCDesData = (SiS_LVDSDesStruct *)SiS300_CHTVUNTSCDesData; - SiS_Pr->SiS_CHTVONTSCDesData = (SiS_LVDSDesStruct *)SiS300_CHTVONTSCDesData; - SiS_Pr->SiS_CHTVUPALDesData = (SiS_LVDSDesStruct *)SiS300_CHTVUPALDesData; - SiS_Pr->SiS_CHTVOPALDesData = (SiS_LVDSDesStruct *)SiS300_CHTVOPALDesData; + + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1a; + SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2a; + } + if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { + SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1b; + SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2b; + } + SiS_Pr->SiS_LVDSCRT1800x600_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_1; SiS_Pr->SiS_LVDSCRT11024x768_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_1; SiS_Pr->SiS_LVDSCRT11280x1024_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_1; - SiS_Pr->SiS_LVDSCRT11024x600_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x600_1; - SiS_Pr->SiS_LVDSCRT11152x768_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11152x768_1; SiS_Pr->SiS_LVDSCRT1800x600_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_1_H; SiS_Pr->SiS_LVDSCRT11024x768_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_1_H; SiS_Pr->SiS_LVDSCRT11280x1024_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_1_H; - SiS_Pr->SiS_LVDSCRT11024x600_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x600_1_H; - SiS_Pr->SiS_LVDSCRT11152x768_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11152x768_1_H; SiS_Pr->SiS_LVDSCRT1800x600_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_2; SiS_Pr->SiS_LVDSCRT11024x768_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_2; SiS_Pr->SiS_LVDSCRT11280x1024_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_2; - SiS_Pr->SiS_LVDSCRT11024x600_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x600_2; - SiS_Pr->SiS_LVDSCRT11152x768_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11152x768_2; SiS_Pr->SiS_LVDSCRT1800x600_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_2_H; SiS_Pr->SiS_LVDSCRT11024x768_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_2_H; SiS_Pr->SiS_LVDSCRT11280x1024_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_2_H; - SiS_Pr->SiS_LVDSCRT11024x600_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x600_2_H; - SiS_Pr->SiS_LVDSCRT11152x768_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11152x768_2_H; SiS_Pr->SiS_CHTVCRT1UNTSC = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1UNTSC; SiS_Pr->SiS_CHTVCRT1ONTSC = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1ONTSC; SiS_Pr->SiS_CHTVCRT1UPAL = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1UPAL; @@ -339,7 +407,6 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->SiS_CHTVVCLKOPALN = SiS300_CHTVVCLKOPAL; /* not supported on 300 series */ SiS_Pr->SiS_CHTVVCLKSOPAL = SiS300_CHTVVCLKSOPAL; - /* TW: New from 300/301LV BIOS */ SiS_Pr->SiS_CRT2Part2_1024x768_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1024x768_1; SiS_Pr->SiS_CRT2Part2_1280x1024_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1280x1024_1; SiS_Pr->SiS_CRT2Part2_1400x1050_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_1; @@ -353,7 +420,7 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->SiS_CRT2Part2_1400x1050_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_3; SiS_Pr->SiS_CRT2Part2_1600x1200_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1600x1200_3; - /* TW: LCDResInfo will on 300 series be translated to 310/325 series definitions */ + /* LCDResInfo will on 300 series be translated to 315 series definitions */ SiS_Pr->SiS_Panel320x480 = Panel_320x480; SiS_Pr->SiS_Panel640x480 = Panel_640x480; SiS_Pr->SiS_Panel800x600 = Panel_800x600; @@ -362,43 +429,71 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->SiS_Panel1280x960 = Panel_1280x960; SiS_Pr->SiS_Panel1024x600 = Panel_1024x600; SiS_Pr->SiS_Panel1152x768 = Panel_1152x768; - SiS_Pr->SiS_Panel1600x1200 = 16; /* TW: Something illegal */ - SiS_Pr->SiS_Panel1400x1050 = 16; /* TW: Something illegal */ - SiS_Pr->SiS_Panel1152x864 = 16; /* TW: Something illegal */ - SiS_Pr->SiS_Panel1280x768 = 16; /* TW: Something illegal */ - SiS_Pr->SiS_PanelMax = Panel_320x480; /* TW: highest value */ - SiS_Pr->SiS_PanelMinLVDS = Panel_800x600; /* TW: Lowest value LVDS */ - SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* TW: lowest value 301 */ + SiS_Pr->SiS_Panel1280x768 = Panel_1280x768; + SiS_Pr->SiS_Panel1600x1200 = 255; /* Something illegal */ + SiS_Pr->SiS_Panel1400x1050 = 255; + SiS_Pr->SiS_Panel640x480_2 = 255; + SiS_Pr->SiS_Panel640x480_3 = 255; + SiS_Pr->SiS_Panel1152x864 = 255; + SiS_Pr->SiS_PanelMax = Panel_320x480; /* highest value */ + SiS_Pr->SiS_PanelMinLVDS = Panel_800x600; /* Lowest value LVDS */ + SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* lowest value 301 */ + SiS_Pr->SiS_PanelCustom = Panel_Custom; + SiS_Pr->SiS_PanelBarco1366 = Panel_Barco1366; } #endif #ifdef SIS315H static void -InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { + InitCommonPointer(SiS_Pr, HwInfo); + + SiS_StandTable[0x04].CRTC[4] = 0x2c; + SiS_StandTable[0x05].CRTC[4] = 0x2c; + SiS_StandTable[0x06].CRTC[4] = 0x55; + SiS_StandTable[0x06].CRTC[5] = 0x81; + SiS_StandTable[0x0d].CRTC[4] = 0x2c; + SiS_StandTable[0x0e].CRTC[4] = 0x55; + SiS_StandTable[0x0e].CRTC[5] = 0x81; + SiS_StandTable[0x11].CRTC[4] = 0x55; + SiS_StandTable[0x11].CRTC[5] = 0x81; + SiS_StandTable[0x11].CRTC[16] = 0x82; + SiS_StandTable[0x11].CRTC[17] = 0x84; + SiS_StandTable[0x12].CRTC[4] = 0x55; + SiS_StandTable[0x12].CRTC[5] = 0x81; + SiS_StandTable[0x12].CRTC[16] = 0x82; + SiS_StandTable[0x12].CRTC[17] = 0x84; + SiS_StandTable[0x13].CRTC[5] = 0xb1; + SiS_StandTable[0x17].CRTC[5] = 0xb1; + SiS_StandTable[0x1a].CRTC[4] = 0x55; + SiS_StandTable[0x1a].CRTC[5] = 0x81; + SiS_StandTable[0x1a].CRTC[16] = 0xe9; + SiS_StandTable[0x1a].CRTC[17] = 0x8b; + SiS_StandTable[0x1b].CRTC[4] = 0x55; + SiS_StandTable[0x1b].CRTC[5] = 0x81; + SiS_StandTable[0x1b].CRTC[16] = 0xe9; + SiS_StandTable[0x1b].CRTC[17] = 0x8b; + SiS_StandTable[0x1c].CRTC[4] = 0x55; + SiS_StandTable[0x1c].CRTC[5] = 0x81; + SiS_Pr->SiS_SModeIDTable = (SiS_StStruct *)SiS310_SModeIDTable; - SiS_Pr->SiS_StandTable = (SiS_StandTableStruct *)SiS310_StandTable; SiS_Pr->SiS_EModeIDTable = (SiS_ExtStruct *)SiS310_EModeIDTable; SiS_Pr->SiS_RefIndex = (SiS_Ext2Struct *)SiS310_RefIndex; SiS_Pr->SiS_CRT1Table = (SiS_CRT1TableStruct *)SiS310_CRT1Table; - /* TW: MCLK is different */ - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_661) { + SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_660; /* 661/741/760 */ + } else if(HwInfo->jChipType == SIS_330) { SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_330; /* 330 */ - } else if(HwDeviceExtension->jChipType > SIS_315PRO) { + } else if(HwInfo->jChipType > SIS_315PRO) { SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_650; /* 550, 650, 740 */ } else { SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_315; /* 315 */ } SiS_Pr->SiS_MCLKData_1 = (SiS_MCLKDataStruct *)SiS310_MCLKData_1; - SiS_Pr->SiS_ECLKData = (SiS_ECLKDataStruct *)SiS310_ECLKData; SiS_Pr->SiS_VCLKData = (SiS_VCLKDataStruct *)SiS310_VCLKData; SiS_Pr->SiS_VBVCLKData = (SiS_VBVCLKDataStruct *)SiS310_VBVCLKData; SiS_Pr->SiS_ScreenOffset = SiS310_ScreenOffset; - SiS_Pr->SiS_StResInfo = (SiS_StResInfoStruct *)SiS310_StResInfo; - SiS_Pr->SiS_ModeResInfo = (SiS_ModeResInfoStruct *)SiS310_ModeResInfo; - - SiS_Pr->pSiS_OutputSelect = &SiS310_OutputSelect; - SiS_Pr->pSiS_SoftSetting = &SiS310_SoftSetting; SiS_Pr->SiS_SR15 = SiS310_SR15; @@ -427,16 +522,6 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->pSiS_YCSenseData2 = &SiS310_YCSenseData2; #endif - SiS_Pr->SiS_NTSCPhase = SiS310_NTSCPhase; - SiS_Pr->SiS_PALPhase = SiS310_PALPhase; - SiS_Pr->SiS_NTSCPhase2 = SiS310_NTSCPhase2; - SiS_Pr->SiS_PALPhase2 = SiS310_PALPhase2; - SiS_Pr->SiS_PALMPhase = SiS310_PALMPhase; - SiS_Pr->SiS_PALNPhase = SiS310_PALNPhase; - SiS_Pr->SiS_PALMPhase2 = SiS310_PALMPhase2; - SiS_Pr->SiS_PALNPhase2 = SiS310_PALNPhase2; - SiS_Pr->SiS_SpecialPhase = SiS310_SpecialPhase; - SiS_Pr->SiS_StLCD1024x768Data = (SiS_LCDDataStruct *)SiS310_StLCD1024x768Data; SiS_Pr->SiS_ExtLCD1024x768Data = (SiS_LCDDataStruct *)SiS310_ExtLCD1024x768Data; SiS_Pr->SiS_St2LCD1024x768Data = (SiS_LCDDataStruct *)SiS310_St2LCD1024x768Data; @@ -445,62 +530,10 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->SiS_St2LCD1280x1024Data = (SiS_LCDDataStruct *)SiS310_St2LCD1280x1024Data; SiS_Pr->SiS_NoScaleData1024x768 = (SiS_LCDDataStruct *)SiS310_NoScaleData1024x768; SiS_Pr->SiS_NoScaleData1280x1024 = (SiS_LCDDataStruct *)SiS310_NoScaleData1280x1024; - SiS_Pr->SiS_LCD1280x960Data = (SiS_LCDDataStruct *)SiS310_LCD1280x960Data; - SiS_Pr->SiS_ExtLCD1400x1050Data = (SiS_LCDDataStruct *)SiS310_ExtLCD1400x1050Data; - SiS_Pr->SiS_ExtLCD1600x1200Data = (SiS_LCDDataStruct *)SiS310_ExtLCD1600x1200Data; - SiS_Pr->SiS_StLCD1400x1050Data = (SiS_LCDDataStruct *)SiS310_StLCD1400x1050Data; - SiS_Pr->SiS_StLCD1600x1200Data = (SiS_LCDDataStruct *)SiS310_StLCD1600x1200Data; - SiS_Pr->SiS_NoScaleData1400x1050 = (SiS_LCDDataStruct *)SiS310_NoScaleData1400x1050; - SiS_Pr->SiS_NoScaleData1600x1200 = (SiS_LCDDataStruct *)SiS310_NoScaleData1600x1200; - - SiS_Pr->SiS_StPALData = (SiS_TVDataStruct *)SiS310_StPALData; - SiS_Pr->SiS_ExtPALData = (SiS_TVDataStruct *)SiS310_ExtPALData; - SiS_Pr->SiS_StNTSCData = (SiS_TVDataStruct *)SiS310_StNTSCData; - SiS_Pr->SiS_ExtNTSCData = (SiS_TVDataStruct *)SiS310_ExtNTSCData; -/* SiS_Pr->SiS_St1HiTVData = (SiS_TVDataStruct *)SiS310_St1HiTVData; */ - SiS_Pr->SiS_St2HiTVData = (SiS_TVDataStruct *)SiS310_St2HiTVData; - SiS_Pr->SiS_ExtHiTVData = (SiS_TVDataStruct *)SiS310_ExtHiTVData; - - SiS_Pr->SiS_NTSCTiming = SiS310_NTSCTiming; - SiS_Pr->SiS_PALTiming = SiS310_PALTiming; - SiS_Pr->SiS_HiTVSt1Timing = SiS310_HiTVSt1Timing; - SiS_Pr->SiS_HiTVSt2Timing = SiS310_HiTVSt2Timing; - SiS_Pr->SiS_HiTVTextTiming = SiS310_HiTVTextTiming; - SiS_Pr->SiS_HiTVExtTiming = SiS310_HiTVExtTiming; - SiS_Pr->SiS_HiTVGroup3Data = SiS310_HiTVGroup3Data; - SiS_Pr->SiS_HiTVGroup3Simu = SiS310_HiTVGroup3Simu; - SiS_Pr->SiS_HiTVGroup3Text = SiS310_HiTVGroup3Text; - SiS_Pr->SiS_PanelDelayTbl = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTbl; + SiS_Pr->SiS_PanelDelayTbl = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTbl; SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTblLVDS; - SiS_Pr->SiS_LVDS800x600Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS800x600Data_1; - SiS_Pr->SiS_LVDS800x600Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS800x600Data_2; - SiS_Pr->SiS_LVDS1024x768Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1024x768Data_1; - SiS_Pr->SiS_LVDS1024x768Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1024x768Data_2; - SiS_Pr->SiS_LVDS1280x1024Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x1024Data_1; - SiS_Pr->SiS_LVDS1280x1024Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x1024Data_2; - SiS_Pr->SiS_LVDS1280x960Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x960Data_1; - SiS_Pr->SiS_LVDS1280x960Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x960Data_2; - SiS_Pr->SiS_LVDS1400x1050Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1400x1050Data_1; - SiS_Pr->SiS_LVDS1400x1050Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1400x1050Data_2; - SiS_Pr->SiS_LVDS1600x1200Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1600x1200Data_1; - SiS_Pr->SiS_LVDS1600x1200Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1600x1200Data_2; - SiS_Pr->SiS_LVDS1280x768Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x768Data_1; - SiS_Pr->SiS_LVDS1280x768Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x768Data_2; - SiS_Pr->SiS_LVDS1024x600Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1024x600Data_1; - SiS_Pr->SiS_LVDS1024x600Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1024x600Data_2; - SiS_Pr->SiS_LVDS1152x768Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1152x768Data_1; - SiS_Pr->SiS_LVDS1152x768Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1152x768Data_2; - SiS_Pr->SiS_LVDSXXXxXXXData_1 = (SiS_LVDSDataStruct *)SiS310_LVDSXXXxXXXData_1; - SiS_Pr->SiS_LVDS320x480Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS320x480Data_1; - SiS_Pr->SiS_LVDS640x480Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS640x480Data_1; - SiS_Pr->SiS_LCDA1400x1050Data_1 = (SiS_LVDSDataStruct *)SiS310_LCDA1400x1050Data_1; - SiS_Pr->SiS_LCDA1400x1050Data_2 = (SiS_LVDSDataStruct *)SiS310_LCDA1400x1050Data_2; - SiS_Pr->SiS_LCDA1600x1200Data_1 = (SiS_LVDSDataStruct *)SiS310_LCDA1600x1200Data_1; - SiS_Pr->SiS_LCDA1600x1200Data_2 = (SiS_LVDSDataStruct *)SiS310_LCDA1600x1200Data_2; - SiS_Pr->SiS_CHTVUNTSCData = (SiS_LVDSDataStruct *)SiS310_CHTVUNTSCData; - SiS_Pr->SiS_CHTVONTSCData = (SiS_LVDSDataStruct *)SiS310_CHTVONTSCData; SiS_Pr->SiS_CHTVUPALData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALData; SiS_Pr->SiS_CHTVOPALData = (SiS_LVDSDataStruct *)SiS310_CHTVOPALData; SiS_Pr->SiS_CHTVUPALMData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALMData; @@ -508,6 +541,7 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->SiS_CHTVUPALNData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALNData; SiS_Pr->SiS_CHTVOPALNData = (SiS_LVDSDataStruct *)SiS310_CHTVOPALNData; SiS_Pr->SiS_CHTVSOPALData = (SiS_LVDSDataStruct *)SiS310_CHTVSOPALData; + SiS_Pr->SiS_PanelType00_1 = (SiS_LVDSDesStruct *)SiS310_PanelType00_1; SiS_Pr->SiS_PanelType01_1 = (SiS_LVDSDesStruct *)SiS310_PanelType01_1; SiS_Pr->SiS_PanelType02_1 = (SiS_LVDSDesStruct *)SiS310_PanelType02_1; @@ -540,19 +574,7 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->SiS_PanelType0d_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0d_2; SiS_Pr->SiS_PanelType0e_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0e_2; SiS_Pr->SiS_PanelType0f_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0f_2; - SiS_Pr->SiS_PanelTypeNS_1 = (SiS_LVDSDesStruct *)SiS310_PanelTypeNS_1; - SiS_Pr->SiS_PanelTypeNS_2 = (SiS_LVDSDesStruct *)SiS310_PanelTypeNS_2; - - SiS_Pr->LVDS1024x768Des_1 = (SiS_LVDSDesStruct *)SiS310_PanelType1076_1; - SiS_Pr->LVDS1280x1024Des_1 = (SiS_LVDSDesStruct *)SiS310_PanelType1210_1; - SiS_Pr->LVDS1400x1050Des_1 = (SiS_LVDSDesStruct *)SiS310_PanelType1296_1 ; - SiS_Pr->LVDS1600x1200Des_1 = (SiS_LVDSDesStruct *)SiS310_PanelType1600_1 ; - SiS_Pr->LVDS1024x768Des_2 = (SiS_LVDSDesStruct *)SiS310_PanelType1076_2; - SiS_Pr->LVDS1280x1024Des_2 = (SiS_LVDSDesStruct *)SiS310_PanelType1210_2; - SiS_Pr->LVDS1400x1050Des_2 = (SiS_LVDSDesStruct *)SiS310_PanelType1296_2; - SiS_Pr->LVDS1600x1200Des_2 = (SiS_LVDSDesStruct *)SiS310_PanelType1600_2 ; - /* TW: New from 650/301LV BIOS */ SiS_Pr->SiS_CRT2Part2_1024x768_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1024x768_1; SiS_Pr->SiS_CRT2Part2_1280x1024_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1280x1024_1; SiS_Pr->SiS_CRT2Part2_1400x1050_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_1; @@ -566,51 +588,32 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->SiS_CRT2Part2_1400x1050_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_3; SiS_Pr->SiS_CRT2Part2_1600x1200_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1600x1200_3; - SiS_Pr->SiS_CHTVUNTSCDesData = (SiS_LVDSDesStruct *)SiS310_CHTVUNTSCDesData; - SiS_Pr->SiS_CHTVONTSCDesData = (SiS_LVDSDesStruct *)SiS310_CHTVONTSCDesData; - SiS_Pr->SiS_CHTVUPALDesData = (SiS_LVDSDesStruct *)SiS310_CHTVUPALDesData; - SiS_Pr->SiS_CHTVOPALDesData = (SiS_LVDSDesStruct *)SiS310_CHTVOPALDesData; - SiS_Pr->SiS_LVDSCRT1800x600_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_1; SiS_Pr->SiS_LVDSCRT11024x768_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_1; SiS_Pr->SiS_LVDSCRT11280x1024_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_1; SiS_Pr->SiS_LVDSCRT11400x1050_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_1; - SiS_Pr->SiS_LVDSCRT11280x768_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x768_1; - SiS_Pr->SiS_LVDSCRT11024x600_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x600_1; - SiS_Pr->SiS_LVDSCRT11152x768_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11152x768_1; SiS_Pr->SiS_LVDSCRT11600x1200_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_1; SiS_Pr->SiS_LVDSCRT1800x600_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_1_H; SiS_Pr->SiS_LVDSCRT11024x768_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_1_H; SiS_Pr->SiS_LVDSCRT11280x1024_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_1_H; SiS_Pr->SiS_LVDSCRT11400x1050_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_1_H; - SiS_Pr->SiS_LVDSCRT11280x768_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x768_1_H; - SiS_Pr->SiS_LVDSCRT11024x600_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x600_1_H; - SiS_Pr->SiS_LVDSCRT11152x768_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11152x768_1_H; SiS_Pr->SiS_LVDSCRT11600x1200_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_1_H; SiS_Pr->SiS_LVDSCRT1800x600_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_2; SiS_Pr->SiS_LVDSCRT11024x768_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_2; SiS_Pr->SiS_LVDSCRT11280x1024_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_2; SiS_Pr->SiS_LVDSCRT11400x1050_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_2; - SiS_Pr->SiS_LVDSCRT11280x768_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x768_2; - SiS_Pr->SiS_LVDSCRT11024x600_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x600_2; - SiS_Pr->SiS_LVDSCRT11152x768_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11152x768_2; SiS_Pr->SiS_LVDSCRT11600x1200_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_2; SiS_Pr->SiS_LVDSCRT1800x600_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_2_H; SiS_Pr->SiS_LVDSCRT11024x768_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_2_H; SiS_Pr->SiS_LVDSCRT11280x1024_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_2_H; SiS_Pr->SiS_LVDSCRT11400x1050_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_2_H; - SiS_Pr->SiS_LVDSCRT11280x768_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x768_2_H; - SiS_Pr->SiS_LVDSCRT11024x600_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x600_2_H; - SiS_Pr->SiS_LVDSCRT11152x768_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11152x768_2_H; SiS_Pr->SiS_LVDSCRT11600x1200_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_2_H; - SiS_Pr->SiS_LVDSCRT1XXXxXXX_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1XXXxXXX_1; - SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1XXXxXXX_1_H; - SiS_Pr->SiS_LVDSCRT1320x480_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1320x480_1; - SiS_Pr->SiS_CHTVCRT1UNTSC = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UNTSC; - SiS_Pr->SiS_CHTVCRT1ONTSC = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1ONTSC; - SiS_Pr->SiS_CHTVCRT1UPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UPAL; - SiS_Pr->SiS_CHTVCRT1OPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1OPAL; - SiS_Pr->SiS_CHTVCRT1SOPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1SOPAL; + SiS_Pr->SiS_CHTVCRT1UNTSC = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UNTSC; + SiS_Pr->SiS_CHTVCRT1ONTSC = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1ONTSC; + SiS_Pr->SiS_CHTVCRT1UPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UPAL; + SiS_Pr->SiS_CHTVCRT1OPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1OPAL; + SiS_Pr->SiS_CHTVCRT1SOPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1OPAL; + SiS_Pr->SiS_CHTVReg_UNTSC = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UNTSC; SiS_Pr->SiS_CHTVReg_ONTSC = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_ONTSC; SiS_Pr->SiS_CHTVReg_UPAL = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPAL; @@ -619,27 +622,25 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->SiS_CHTVReg_OPALM = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPALM; SiS_Pr->SiS_CHTVReg_UPALN = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPALN; SiS_Pr->SiS_CHTVReg_OPALN = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPALN; - SiS_Pr->SiS_CHTVReg_SOPAL = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_SOPAL; - SiS_Pr->SiS_LCDACRT1800x600_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_1; + SiS_Pr->SiS_CHTVReg_SOPAL = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPAL; + SiS_Pr->SiS_LCDACRT11024x768_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_1; SiS_Pr->SiS_LCDACRT11280x1024_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_1; SiS_Pr->SiS_LCDACRT11400x1050_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_1; SiS_Pr->SiS_LCDACRT11600x1200_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_1; - SiS_Pr->SiS_LCDACRT1800x600_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_1_H; SiS_Pr->SiS_LCDACRT11024x768_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_1_H; SiS_Pr->SiS_LCDACRT11280x1024_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_1_H; SiS_Pr->SiS_LCDACRT11400x1050_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_1_H; SiS_Pr->SiS_LCDACRT11600x1200_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_1_H; - SiS_Pr->SiS_LCDACRT1800x600_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_2; SiS_Pr->SiS_LCDACRT11024x768_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_2; SiS_Pr->SiS_LCDACRT11280x1024_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_2; SiS_Pr->SiS_LCDACRT11400x1050_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_2; SiS_Pr->SiS_LCDACRT11600x1200_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_2; - SiS_Pr->SiS_LCDACRT1800x600_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_2_H; SiS_Pr->SiS_LCDACRT11024x768_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_2_H; SiS_Pr->SiS_LCDACRT11280x1024_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_2_H; SiS_Pr->SiS_LCDACRT11400x1050_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_2_H; SiS_Pr->SiS_LCDACRT11600x1200_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_2_H; + SiS_Pr->SiS_CHTVVCLKUNTSC = SiS310_CHTVVCLKUNTSC; SiS_Pr->SiS_CHTVVCLKONTSC = SiS310_CHTVVCLKONTSC; SiS_Pr->SiS_CHTVVCLKUPAL = SiS310_CHTVVCLKUPAL; @@ -648,7 +649,7 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->SiS_CHTVVCLKOPALM = SiS310_CHTVVCLKOPALM; SiS_Pr->SiS_CHTVVCLKUPALN = SiS310_CHTVVCLKUPALN; SiS_Pr->SiS_CHTVVCLKOPALN = SiS310_CHTVVCLKOPALN; - SiS_Pr->SiS_CHTVVCLKSOPAL = SiS310_CHTVVCLKSOPAL; + SiS_Pr->SiS_CHTVVCLKSOPAL = SiS310_CHTVVCLKOPAL; SiS_Pr->SiS_Panel320x480 = Panel_320x480; SiS_Pr->SiS_Panel640x480 = Panel_640x480; @@ -662,1245 +663,1122 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS SiS_Pr->SiS_Panel1152x864 = Panel_1152x864; SiS_Pr->SiS_Panel1280x768 = Panel_1280x768; SiS_Pr->SiS_Panel1024x600 = Panel_1024x600; - SiS_Pr->SiS_PanelMax = Panel_320x480; /* TW: highest value */ - SiS_Pr->SiS_PanelMinLVDS = Panel_800x600; /* TW: lowest value LVDS/LCDA */ - SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* TW: lowest value 301 */ + SiS_Pr->SiS_Panel640x480_2 = Panel_640x480_2; + SiS_Pr->SiS_Panel640x480_3 = Panel_640x480_3; + SiS_Pr->SiS_PanelMax = Panel_320x480; /* highest value */ + SiS_Pr->SiS_PanelMinLVDS = Panel_800x600; /* lowest value LVDS/LCDA */ + SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* lowest value 301 */ + SiS_Pr->SiS_PanelCustom = Panel_Custom; + SiS_Pr->SiS_PanelBarco1366 = 255; } #endif -#ifdef LINUXBIOS -/* -------------- SiSInit -----------------*/ -/* TW: I degraded this for LINUXBIOS only, because we - * don't need this otherwise. Under normal - * circumstances, the video BIOS has initialized - * the adapter for us. BTW, this code is incomplete - * and very possibly not working on newer chipsets. - */ -BOOLEAN -SiSInit(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - ULONG FBAddr = (ULONG)HwDeviceExtension->pjVideoMemoryAddress; - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; - UCHAR i, temp=0; - UCHAR SR11; -#ifdef LINUX_KERNEL - UCHAR temp1; - ULONG base; -#endif - UCHAR SR13=0, SR14=0, SR16=0 - UCHAR SR17=0, SR19=0, SR1A=0; -#ifdef SIS300 - UCHAR SR18=0, SR12=0; -#endif -#ifdef SIS315H - UCHAR CR37=0, CR38=0, CR79=0, - UCHAR CR7A=0, CR7B=0, CR7C=0; - UCHAR SR1B=0, SR15=0; - PSIS_DSReg pSR; - ULONG Temp; -#endif - UCHAR VBIOSVersion[5]; - - if(FBAddr==0) return (FALSE); - if(BaseAddr==0) return (FALSE); - - SiS_SetReg3((USHORT)(BaseAddr+0x12), 0x67); /* Misc */ - -#ifdef SIS315H - if(HwDeviceExtension->jChipType > SIS_315PRO) { - if(!HwDeviceExtension->bIntegratedMMEnabled) - return (FALSE); - } -#endif - - SiS_MemoryCopy(VBIOSVersion,HwDeviceExtension->szVBIOSVer,4); - VBIOSVersion[4]= 0x00; - - SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr); - - /* TW: Init pointers */ -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) - InitTo310Pointer(SiS_Pr, HwDeviceExtension); -#endif - -#ifdef SIS300 - if((HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) || - (HwDeviceExtension->jChipType == SIS_300)) - InitTo300Pointer(SiS_Pr, HwDeviceExtension); -#endif - - /* TW: Set SiS Register definitions */ - SiSRegInit(SiS_Pr, BaseAddr); - - /* TW: Determine LVDS/CH70xx/TRUMPION */ - SiS_Set_LVDS_TRUMPION(SiS_Pr, HwDeviceExtension); - - /* TW: Unlock registers */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); - -#ifdef LINUX_KERNEL - -#ifdef SIS300 /* Set SR14 */ - if((HwDeviceExtension->jChipType==SIS_540) || - (HwDeviceExtension->jChipType==SIS_630) || - (HwDeviceExtension->jChipType==SIS_730)) { - base=0x80000060; - OutPortLong(base,0xcf8); - temp1 = InPortLong(0xcfc); - temp1 >>= (16+8+4); - temp1 &= 0x07; - temp1++; - temp1 = 1 << temp1; - SR14 = temp1 - 1; - base = 0x80000064; - OutPortLong(base,0xcf8); - temp1 = InPortLong(0xcfc); - temp1 &= 0x00000020; - if(temp1) SR14 |= 0x80; - else SR14 |= 0x40; - } -#endif - -#ifdef SIS315H /* Set SR14 */ - if(HwDeviceExtension->jChipType == SIS_550) { - base = 0x80000060; - OutPortLong(base,0xcf8); - temp1 = InPortLong(0xcfc); - temp1 >>= (16+8+4); - temp1 &= 0x07; - temp1++; - temp1 = 1 << temp1; - SR14 = temp1 - 1; - base = 0x80000064; - OutPortLong(base,0xcf8); - temp1 = InPortLong(0xcfc); - temp1 &= 0x00000020; - if(temp1) SR14 |= 0x80; - else SR14 |= 0x40; - } - - if((HwDeviceExtension->jChipType == SIS_740) || /* Set SR14 */ - (HwDeviceExtension->jChipType == SIS_650)) { - base = 0x80000064; - OutPortLong(base,0xcf8); - temp1=InPortLong(0xcfc); - temp1 >>= 4; - temp1 &= 0x07; - if(temp1 > 2) { - temp = temp1; - switch(temp) { - case 3: temp1 = 0x07; break; - case 4: temp1 = 0x0F; break; - case 5: temp1 = 0x1F; break; - case 6: temp1 = 0x05; break; - case 7: temp1 = 0x17; break; - case 8: break; - case 9: break; - } - } - SR14 = temp1; - base = 0x8000007C; - OutPortLong(base,0xcf8); - temp1 = InPortLong(0xcfc); - temp1 &= 0x00000020; - if(temp1) SR14 |= 0x80; - } -#endif - -#endif /* Linux kernel */ - -#ifdef SIS300 - if((HwDeviceExtension->jChipType == SIS_540)|| - (HwDeviceExtension->jChipType == SIS_630)|| - (HwDeviceExtension->jChipType == SIS_730)) { - SR12 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x12); - SR13 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13); - SR14 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - SR16 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - SR17 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17); - SR18 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18); - SR19 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x19); - SR1A = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); - } else if(HwDeviceExtension->jChipType == SIS_300){ - SR13 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13); - SR14 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - } -#endif + switch(HwInfo->jChipType) { #ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_650)) { - SR19 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x19); - SR19 = (SR19)||0x01; /* TW: ??? || ??? */ - if(SR19==0x00) { - SR13 = 0x22; - SR14 = 0x00; - SR15 = 0x01; - SR16 = 0x00; - SR17 = 0x00; - SR1A = 0x00; - SR1B = 0x00; - CR37 = 0x00; - CR38 = 0x00; - CR79 = 0x00; - CR7A = 0x00; - CR7B = 0x00; - CR7C = 0x00; - } else { - SR13 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13); - SR14 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - SR15 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15); - SR16 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - SR17 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17); - SR1A = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); - SR1B = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1B); - CR37 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37); /* TW: Was 0x02 - why? */ - CR38 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - CR79 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x79); - CR7A = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x7A); - CR7B = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x7B); - CR7C = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x7C); - } - } + case SIS_315H: + case SIS_315: + case SIS_315PRO: + case SIS_550: + case SIS_650: + case SIS_740: + case SIS_330: + case SIS_661: + case SIS_741: + case SIS_660: + case SIS_760: + InitTo310Pointer(SiS_Pr, HwInfo); + break; #endif - - /* Reset extended registers */ - - for(i=0x06; i< 0x20; i++) SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0); - for(i=0x21; i<=0x27; i++) SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0); - for(i=0x31; i<=0x3D; i++) SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0); - #ifdef SIS300 - if((HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) || - (HwDeviceExtension->jChipType == SIS_300)) { - for(i=0x38; i<=0x3F; i++) SiS_SetReg1(SiS_Pr->SiS_P3d4,i,0); - } + case SIS_300: + case SIS_540: + case SIS_630: + case SIS_730: + InitTo300Pointer(SiS_Pr, HwInfo); + break; #endif - -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) { - for(i=0x12; i<=0x1B; i++) SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0); - for(i=0x79; i<=0x7C; i++) SiS_SetReg1(SiS_Pr->SiS_P3d4,i,0); + default: + break; } -#endif - - /* Restore Extended Registers */ +} -#ifdef SIS300 - if((HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730)) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x12,SR12); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,SR13); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,SR14); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,SR16); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,SR17); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x18,SR18); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x19,SR19); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1A,SR1A); - } -#endif +/*********************************************/ +/* HELPER: Get ModeID */ +/*********************************************/ -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_650)) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,SR13); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,SR14); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x15,SR15); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,SR16); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,SR17); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x19,SR19); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1A,SR1A); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1B,SR1B); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,CR37); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x38,CR38); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x79,CR79); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x7A,CR7A); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x7B,CR7B); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x7C,CR7C); - } -#endif +USHORT +SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, BOOLEAN FSTN) +{ + USHORT ModeIndex = 0; -#ifdef SIS300 - if((HwDeviceExtension->jChipType==SIS_540) || - (HwDeviceExtension->jChipType==SIS_630) || - (HwDeviceExtension->jChipType==SIS_730)) { - temp = (UCHAR)SR1A & 0x03; - } else if(HwDeviceExtension->jChipType == SIS_300) { - /* TW: Nothing */ - } -#endif -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_330) ) { - if((*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) == 0) { - temp = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A) & 0x03; - } - } - if((HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_650)) { - if((*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) == 0) { - temp = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x07; - } + switch(HDisplay) + { + case 320: + if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; + else if(VDisplay == 240) { + if(FSTN) ModeIndex = ModeIndex_320x240_FSTN[Depth]; + else ModeIndex = ModeIndex_320x240[Depth]; + } + break; + case 400: + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + break; + case 512: + if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; + break; + case 640: + if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; + else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; + break; + case 720: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth]; + else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth]; + } + break; + case 768: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; + } + break; + case 800: + if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; + else if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth]; + } + break; + case 848: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; + } + break; + case 856: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; + } + break; + case 1024: + if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + else if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; + else if(VGAEngine == SIS_300_VGA) { + if(VDisplay == 600) ModeIndex = ModeIndex_1024x600[Depth]; + } + } + break; + case 1152: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; + else if(VGAEngine == SIS_300_VGA) { + if(VDisplay == 768) ModeIndex = ModeIndex_1152x768[Depth]; + } + } + break; + case 1280: + if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; + else if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 960) ModeIndex = ModeIndex_1280x960[Depth]; + else if(VDisplay == 720) ModeIndex = ModeIndex_1280x720[Depth]; + else if(VDisplay == 768) { + if(VGAEngine == SIS_300_VGA) { + ModeIndex = ModeIndex_300_1280x768[Depth]; + } else { + ModeIndex = ModeIndex_310_1280x768[Depth]; + } + } + } + break; + case 1360: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; + else if(VGAEngine == SIS_300_VGA) { + if(VDisplay == 1024) ModeIndex = ModeIndex_300_1360x1024[Depth]; + } + } + break; + case 1400: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; + } + break; + case 1600: + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + break; + case 1920: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 1440) ModeIndex = ModeIndex_1920x1440[Depth]; + } + break; + case 2048: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 1536) { + if(VGAEngine == SIS_300_VGA) { + ModeIndex = ModeIndex_300_2048x1536[Depth]; + } else { + ModeIndex = ModeIndex_310_2048x1536[Depth]; + } + } + } + break; } -#endif - - SiS_Pr->SiS_RAMType = temp; - SiS_SetMemoryClock(SiS_Pr, ROMAddr, HwDeviceExtension); - - /* Set default register contents */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x07,*SiS_Pr->pSiS_SR07); /* DAC speed */ - - if((HwDeviceExtension->jChipType != SIS_540) && - (HwDeviceExtension->jChipType != SIS_630) && - (HwDeviceExtension->jChipType != SIS_730)){ - for(i=0x15;i<0x1C;i++) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,SiS_Pr->SiS_SR15[i-0x15][SiS_Pr->SiS_RAMType]); - } - } + return(ModeIndex); +} -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_330)) { - for(i=0x40;i<=0x44;i++) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,SiS_Pr->SiS_CR40[i-0x40][SiS_Pr->SiS_RAMType]); - } - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x48,0x23); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x49,SiS_Pr->SiS_CR49[0]); - /* SiS_SetReg1(SiS_Pr->SiS_P3c4,0x25,SiS_Pr->SiS_SR25[0]); */ - } -#endif +USHORT +SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, + int Depth, BOOLEAN FSTN, USHORT CustomT, int LCDwidth, int LCDheight) +{ + USHORT ModeIndex = 0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1F,*SiS_Pr->pSiS_SR1F); /* DAC pedestal */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x20,0xA0); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x23,*SiS_Pr->pSiS_SR23); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x24,*SiS_Pr->pSiS_SR24); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x25,SiS_Pr->SiS_SR25[0]); + if(VBFlags & (VB_LVDS | VB_30xBDH)) { -#ifdef SIS300 - if(HwDeviceExtension->jChipType == SIS_300) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x21,0x84); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x22,0x00); + switch(HDisplay) + { + case 320: + if(CustomT != CUT_PANEL848) { + if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; + else if(VDisplay == 240) { + if(!FSTN) ModeIndex = ModeIndex_320x240[Depth]; + else if(VGAEngine == SIS_315_VGA) { + ModeIndex = ModeIndex_320x240_FSTN[Depth]; + } + } + } + break; + case 400: + if(CustomT != CUT_PANEL848) { + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + } + break; + case 512: + if(CustomT != CUT_PANEL848) { + if(VDisplay == 384) { + if(LCDwidth != 1024 || LCDheight != 600) { + ModeIndex = ModeIndex_512x384[Depth]; + } + } + } + break; + case 640: + if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; + else if(VDisplay == 400) { + if(CustomT != CUT_PANEL848) ModeIndex = ModeIndex_640x400[Depth]; + } + break; + case 800: + if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; + break; + case 848: + if(CustomT == CUT_PANEL848) { + if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; + } + break; + case 1024: + if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + else if(VGAEngine == SIS_300_VGA) { + if((VDisplay == 600) && (LCDheight == 600)) { + ModeIndex = ModeIndex_1024x600[Depth]; + } + } + break; + case 1152: + if(VGAEngine == SIS_300_VGA) { + if((VDisplay == 768) && (LCDheight == 768)) { + ModeIndex = ModeIndex_1152x768[Depth]; + } + } + break; + case 1280: + if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; + else if(VGAEngine == SIS_315_VGA) { + if((VDisplay == 768) && (LCDheight == 768)) { + ModeIndex = ModeIndex_310_1280x768[Depth]; + } + } + break; + case 1360: + if(VGAEngine == SIS_300_VGA) { + if(CustomT == CUT_BARCO1366) { + if(VDisplay == 1024) ModeIndex = ModeIndex_300_1360x1024[Depth]; + } + } + if(CustomT == CUT_PANEL848) { + if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; + } + break; + case 1400: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; + } + break; + case 1600: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + } + break; + } + + } else if(VBFlags & VB_SISBRIDGE) { + + switch(HDisplay) + { + case 320: + if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; + else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth]; + break; + case 400: + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + break; + case 512: + if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; + break; + case 640: + if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; + else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; + break; + case 800: + if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; + break; + case 1024: + if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + break; + case 1280: + if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; + else if(VDisplay == 768) { + if((LCDheight == 768) || + ((LCDheight == 1024) && (VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)))) { + if(VGAEngine == SIS_300_VGA) { + ModeIndex = ModeIndex_300_1280x768[Depth]; + } else { + ModeIndex = ModeIndex_310_1280x768[Depth]; + } + } + } else if(VDisplay == 960) { + if((LCDheight == 960) || + ((LCDheight == 1024) && (VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)))) { + ModeIndex = ModeIndex_1280x960[Depth]; + } + } + break; + case 1400: + if(VGAEngine == SIS_315_VGA) { + if(VBFlags & (VB_301B | VB_301C | VB_302B | VB_302LV | VB_302ELV)) { + if(LCDheight != 1200) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; + } + } + } + break; + case 1600: + if(VBFlags & (VB_301C | VB_302B | VB_302LV | VB_302ELV)) { + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + } + break; + } } -#endif - SR11 = 0x0F; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x11,SR11); /* Power Management & DDC port */ - - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x02,*SiS_Pr->pSiS_CRT2Data_1_2); - -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2E,0x08); /* use VB */ -#endif + return ModeIndex; +} - temp = *SiS_Pr->pSiS_SR32; - if(SiS_BridgeIsOn(SiS_Pr, BaseAddr)) { - temp &= 0xEF; - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); +USHORT +SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth) +{ + USHORT ModeIndex = 0; -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_330)) { - HwDeviceExtension->pQueryVGAConfigSpace(HwDeviceExtension,0x50,0,&Temp); - Temp >>= 20; - Temp &= 0xF; - if (Temp != 1) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x25,SiS_Pr->SiS_SR25[1]); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x49,SiS_Pr->SiS_CR49[1]); - } - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x27,0x1F); - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,*SiS_Pr->pSiS_SR31); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,*SiS_Pr->pSiS_SR32); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x33,*SiS_Pr->pSiS_SR33); - } -#endif + if(VBFlags & VB_CHRONTEL) { - if (SiS_BridgeIsOn(SiS_Pr, BaseAddr) == 0) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,0x1C); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0D,*SiS_Pr->pSiS_CRT2Data_4_D); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0E,*SiS_Pr->pSiS_CRT2Data_4_E); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x10,*SiS_Pr->pSiS_CRT2Data_4_10); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0F,0x3F); - } - SiS_LockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); + switch(HDisplay) + { + case 512: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; + } + break; + case 640: + if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; + else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; + break; + case 800: + if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; + break; + case 1024: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + } + break; + } + + } else if(VBFlags & VB_SISTVBRIDGE) { + + switch(HDisplay) + { + case 320: + if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; + else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth]; + break; + case 400: + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + break; + case 512: + if( ((VBFlags & TV_YPBPR) && (VBFlags & (TV_YPBPR525P | TV_YPBPR750P | TV_YPBPR1080I))) || + (VBFlags & TV_HIVISION) || + ((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) ) { + if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; + } + break; + case 640: + if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; + else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; + break; + case 720: + if((!(VBFlags & TV_HIVISION)) && (!((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I)))) { + if(VDisplay == 480) { + if((VBFlags & TV_YPBPR) || (VBFlags & (TV_NTSC | TV_PALM))) + ModeIndex = ModeIndex_720x480[Depth]; + } else if(VDisplay == 576) { + if((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) + ModeIndex = ModeIndex_720x576[Depth]; + } + } + break; + case 768: + if((!(VBFlags & TV_HIVISION)) && (!((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I)))) { + if((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) { + if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; + } + } + break; + case 800: + if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; + else if(VDisplay == 480) { + if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) { + ModeIndex = ModeIndex_800x480[Depth]; + } + } + break; + case 1024: + if(VDisplay == 768) { + if(VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)) { + ModeIndex = ModeIndex_1024x768[Depth]; + } + } else if(VDisplay == 576) { + if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) { + ModeIndex = ModeIndex_1024x576[Depth]; + } + } + break; + case 1280: + if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) { + if(VDisplay == 720) ModeIndex = ModeIndex_1280x720[Depth]; + else if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; + } + break; + } } - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x83,0x00); + return ModeIndex; +} -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_330)) { - if(HwDeviceExtension->bSkipDramSizing==TRUE) { - SiS_SetDRAMModeRegister(SiS_Pr, ROMAddr,HwDeviceExtension); - pSR = HwDeviceExtension->pSR; - if(pSR != NULL) { - while(pSR->jIdx != 0xFF) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,pSR->jIdx,pSR->jVal); - pSR++; - } - } - } else SiS_SetDRAMSize_310(SiS_Pr, HwDeviceExtension); - } -#endif +USHORT +SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth) +{ + USHORT ModeIndex = 0; -#ifdef SIS315H - if(HwDeviceExtension->jChipType == SIS_550) { - /* SetDRAMConfig begin */ -/* SiS_SetReg1(SiS_Pr->SiS_P3c4,0x12,SR12); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,SR13); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,SR14); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,SR16); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,SR17); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x18,SR18); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x19,SR19); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1A,SR1A); */ - /* SetDRAMConfig end */ - } -#endif + if(!(VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; -#ifdef SIS300 - if(HwDeviceExtension->jChipType == SIS_300) { - if (HwDeviceExtension->bSkipDramSizing == TRUE) { -/* SiS_SetDRAMModeRegister(ROMAddr,HwDeviceExtension); - temp = (HwDeviceExtension->pSR)->jVal; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,temp); - temp = (HwDeviceExtension->pSR)->jVal; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,temp); */ - } else { -#ifdef TC - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,SR13); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,SR14); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x15,0xFF,0x04); -#else - SiS_SetDRAMSize_300(SiS_Pr, HwDeviceExtension); - SiS_SetDRAMSize_300(SiS_Pr, HwDeviceExtension); -#endif - } - } - if((HwDeviceExtension->jChipType==SIS_540)|| - (HwDeviceExtension->jChipType==SIS_630)|| - (HwDeviceExtension->jChipType==SIS_730)) { -#if 0 - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x12,SR12); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,SR13); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,SR14); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,SR16); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,SR17); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x18,SR18); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x19,SR19); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1A,SR1A); -#endif + switch(HDisplay) + { + case 320: + if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; + else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth]; + break; + case 400: + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + break; + case 512: + if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; + break; + case 640: + if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; + else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; + break; + case 720: + if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth]; + else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth]; + break; + case 768: + if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; + break; + case 800: + if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; + else if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth]; + break; + case 848: + if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; + break; + case 856: + if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; + break; + case 1024: + if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + else if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; + break; + case 1152: + if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; + else if(VGAEngine == SIS_300_VGA) { + if(VDisplay == 768) ModeIndex = ModeIndex_1152x768[Depth]; + } + break; + case 1280: + if(VDisplay == 768) { + if(VGAEngine == SIS_300_VGA) { + ModeIndex = ModeIndex_300_1280x768[Depth]; + } else { + ModeIndex = ModeIndex_310_1280x768[Depth]; + } + } else if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; + else if(VDisplay == 720) ModeIndex = ModeIndex_1280x720[Depth]; + else if(VDisplay == 960) ModeIndex = ModeIndex_1280x960[Depth]; + break; + case 1360: + if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; + break; + case 1400: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; + } + break; + case 1600: + if(VGAEngine == SIS_315_VGA) { + if(VBFlags & (VB_301B|VB_301C|VB_302B)) { + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + } + } + break; } -/* SetDRAMSize end */ -#endif /* SIS300 */ - - /* Set default Ext2Regs */ -#if 0 - AGP=1; - temp=(UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A); - temp &= 0x30; - if(temp == 0x30) AGP=0; - if(AGP == 0) *SiS_Pr->pSiS_SR21 &= 0xEF; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x21,*SiS_Pr->pSiS_SR21); - if(AGP == 1) *SiS_Pr->pSiS_SR22 &= 0x20; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x22,*SiS_Pr->pSiS_SR22); -#endif - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x21,*SiS_Pr->pSiS_SR21); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x22,*SiS_Pr->pSiS_SR22); -#if 0 - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff); - SiS_ClearDAC(SiS_Pr, SiS_Pr->SiS_P3c8); -#endif + return ModeIndex; +} -#ifdef LINUXBIOS /* TW: This is not needed for our purposes */ - SiS_DetectMonitor(SiS_Pr, HwDeviceExtension,BaseAddr); /* Sense CRT1 */ - SiS_GetSenseStatus(SiS_Pr, HwDeviceExtension,ROMAddr); /* Sense CRT2 */ -#endif - return(TRUE); -} +/*********************************************/ +/* HELPER: SetReg, GetReg */ +/*********************************************/ void -SiS_Set_LVDS_TRUMPION(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_SetReg(SISIOADDRESS port, USHORT index, USHORT data) { - USHORT temp = 0; - -#ifdef SiS300 - if((HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730)) { - /* TW: Read POWER_ON_TRAP and copy to CR37 */ - temp = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); - temp = (temp & 0xE0) >> 4; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,0xF1,temp); - } -#endif -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) { -#if 0 /* TW: This is not required */ - /* TW: Read POWER_ON_TRAP and copy to CR37 */ - temp = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); - temp = (temp & 0xE0) >> 4; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,0xF1,temp); -#endif - } -#endif - - SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, 0); + OutPortByte(port,index); + OutPortByte(port + 1,data); } -/* =============== SiS 300 dram sizing begin =============== */ -#ifdef SIS300 void -SiS_SetDRAMSize_300(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_SetRegByte(SISIOADDRESS port, USHORT data) { - ULONG FBAddr = (ULONG)HwDeviceExtension->pjVideoMemoryAddress; - USHORT SR13, SR14=0, buswidth, Done; - SHORT i, j, k; - USHORT data, TotalCapacity, PhysicalAdrOtherPage=0; - ULONG Addr; - UCHAR temp; - int PseudoRankCapacity, PseudoTotalCapacity, PseudoAdrPinCount; - int RankCapacity, AdrPinCount, BankNumHigh, BankNumMid, MB2Bank; - int PageCapacity, PhysicalAdrHigh, PhysicalAdrHalfPage; - - SiSSetMode(SiS_Pr, HwDeviceExtension, 0x2e); - - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x20); /* Turn OFF Display */ - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,0x00); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0xBF); - - buswidth = SiS_ChkBUSWidth_300(SiS_Pr, FBAddr); - - MB2Bank = 16; - Done = 0; - for(i=6; i>=0; i--) { - if(Done == 1) break; - PseudoRankCapacity = 1 << i; - for(j=4; j>=1; j--) { - if(Done == 1) break; - PseudoTotalCapacity = PseudoRankCapacity * j; - PseudoAdrPinCount = 15 - j; - if(PseudoTotalCapacity <= 64) { - for(k=0; k<=16; k++) { - if(Done == 1) break; - RankCapacity = buswidth * SiS_DRAMType[k][3]; - AdrPinCount = SiS_DRAMType[k][2] + SiS_DRAMType[k][0]; - if(RankCapacity == PseudoRankCapacity) - if(AdrPinCount <= PseudoAdrPinCount) { - if(j == 3) { /* Rank No */ - BankNumHigh = RankCapacity * MB2Bank * 3 - 1; - BankNumMid = RankCapacity * MB2Bank * 1 - 1; - } else { - BankNumHigh = RankCapacity * MB2Bank * j - 1; - BankNumMid = RankCapacity * MB2Bank * j / 2 - 1; - } - PageCapacity = (1 << SiS_DRAMType[k][1]) * buswidth * 4; - PhysicalAdrHigh = BankNumHigh; - PhysicalAdrHalfPage = (PageCapacity / 2 + PhysicalAdrHigh) % PageCapacity; - PhysicalAdrOtherPage = PageCapacity * SiS_DRAMType[k][2] + PhysicalAdrHigh; - /* Write data */ - /*Test*/ - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x15,0xFB); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x15,0x04); - /*/Test*/ - TotalCapacity = SiS_DRAMType[k][3] * buswidth; - SR13 = SiS_DRAMType[k][4]; - if(buswidth == 4) SR14 = (TotalCapacity - 1) | 0x80; - if(buswidth == 2) SR14 = (TotalCapacity - 1) | 0x40; - if(buswidth == 1) SR14 = (TotalCapacity - 1) | 0x00; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,SR13); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,SR14); - - Addr = FBAddr + (BankNumHigh) * 64 * 1024 + PhysicalAdrHigh; - *((USHORT *)(Addr)) = (USHORT)PhysicalAdrHigh; - Addr = FBAddr + (BankNumMid) * 64 * 1024 + PhysicalAdrHigh; - *((USHORT *)(Addr)) = (USHORT)BankNumMid; - Addr = FBAddr + (BankNumHigh) * 64 * 1024 + PhysicalAdrHalfPage; - *((USHORT *)(Addr)) = (USHORT)PhysicalAdrHalfPage; - Addr = FBAddr + (BankNumHigh) * 64 * 1024 + PhysicalAdrOtherPage; - *((USHORT *)(Addr)) = PhysicalAdrOtherPage; - - /* Read data */ - Addr = FBAddr + (BankNumHigh) * 64 * 1024 + PhysicalAdrHigh; - data = *((USHORT *)(Addr)); - if(data == PhysicalAdrHigh) Done = 1; - } /* if struct */ - } /* for loop (k) */ - } /* if struct */ - } /* for loop (j) */ - } /* for loop (i) */ + OutPortByte(port,data); } -USHORT -SiS_ChkBUSWidth_300(SiS_Private *SiS_Pr, ULONG FBAddress) +void +SiS_SetRegShort(SISIOADDRESS port, USHORT data) { - PULONG pVideoMemory; - - pVideoMemory = (PULONG)FBAddress; - - pVideoMemory[0] = 0x01234567L; - pVideoMemory[1] = 0x456789ABL; - pVideoMemory[2] = 0x89ABCDEFL; - pVideoMemory[3] = 0xCDEF0123L; - if (pVideoMemory[3]==0xCDEF0123L) { /* Channel A 128bit */ - return(4); - } - if (pVideoMemory[1]==0x456789ABL) { /* Channel B 64bit */ - return(2); - } - return(1); + OutPortWord(port,data); } -#endif -/* =============== SiS 300 dram sizing end =============== */ - -/* ============ SiS 310/325 dram sizing begin ============== */ -#ifdef SIS315H - -/* TW: Moved Get310DRAMType further down */ void -SiS_Delay15us(SiS_Private *SiS_Pr, ULONG ulMicrsoSec) +SiS_SetRegLong(SISIOADDRESS port, ULONG data) { + OutPortLong(port,data); } -void -SiS_SDR_MRS(SiS_Private *SiS_Pr, ) +UCHAR +SiS_GetReg(SISIOADDRESS port, USHORT index) { - USHORT data; - - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - data &= 0x3F; /* SR16 D7=0, D6=0 */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,data); /* enable mode register set(MRS) low */ - SiS_Delay15us(SiS_Pr, 0x100); - data |= 0x80; /* SR16 D7=1, D6=0 */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,data); /* enable mode register set(MRS) high */ - SiS_Delay15us(SiS_Pr, 0x100); + OutPortByte(port,index); + return(InPortByte(port + 1)); } -void -SiS_DDR_MRS(SiS_Private *SiS_Pr) +UCHAR +SiS_GetRegByte(SISIOADDRESS port) { - USHORT data; - - /* SR16 <- 1F,DF,2F,AF */ - - /* enable DLL of DDR SD/SGRAM , SR16 D4=1 */ - data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - data &= 0x0F; - data |= 0x10; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,data); - - if (!(SiS_Pr->SiS_SR15[1][SiS_Pr->SiS_RAMType] & 0x10)) - data &= 0x0F; - - /* SR16 D7=1,D6=1 */ - data |= 0xC0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,data); - - /* SR16 D7=1,D6=0,D5=1,D4=0 */ - data &= 0x0F; - data |= 0x20; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,data); - if (!(SiS_Pr->SiS_SR15[1][SiS_Pr->SiS_RAMType] & 0x10)) - data &= 0x0F; - - /* SR16 D7=1 */ - data |= 0x80; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,data); + return(InPortByte(port)); } -void -SiS_SetDRAMModeRegister(SiS_Private *SiS_Pr, UCHAR *ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +USHORT +SiS_GetRegShort(SISIOADDRESS port) { - if (SiS_Get310DRAMType(ROMAddr,HwDeviceExtension) < 2) - SiS_SDR_MRS(SiS_Pr); - else - /* SR16 <- 0F,CF,0F,8F */ - SiS_DDR_MRS(SiS_Pr); + return(InPortWord(port)); } -void -SiS_DisableRefresh(SiS_Private *SiS_Pr) +ULONG +SiS_GetRegLong(SISIOADDRESS port) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x17,0xF8); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x19,0x03); + return(InPortLong(port)); } void -SiS_EnableRefresh(SiS_Private *SiS_Pr, UCHAR *ROMAddr) +SiS_SetRegANDOR(SISIOADDRESS Port,USHORT Index,USHORT DataAND,USHORT DataOR) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,SiS_Pr->SiS_SR15[2][SiS_Pr->SiS_RAMType]); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x19,SiS_Pr->SiS_SR15[4][SiS_Pr->SiS_RAMType]); + USHORT temp; + + temp = SiS_GetReg(Port,Index); + temp = (temp & (DataAND)) | DataOR; + SiS_SetReg(Port,Index,temp); } void -SiS_DisableChannelInterleaving(SiS_Private *SiS_Pr, int index, - USHORT SiS_DDRDRAM_TYPE[][5]) +SiS_SetRegAND(SISIOADDRESS Port,USHORT Index,USHORT DataAND) { - USHORT data; + USHORT temp; - data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15); - data &= 0x1F; - switch (SiS_DDRDRAM_TYPE[index][3]) - { - case 64: data |= 0; break; - case 32: data |= 0x20; break; - case 16: data |= 0x40; break; - case 4: data |= 0x60; break; - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x15,data); + temp = SiS_GetReg(Port,Index); + temp &= DataAND; + SiS_SetReg(Port,Index,temp); } void -SiS_SetDRAMSizingType(SiS_Private *SiS_Pr, int index, USHORT DRAMTYPE_TABLE[][5]) +SiS_SetRegOR(SISIOADDRESS Port,USHORT Index,USHORT DataOR) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,DRAMTYPE_TABLE[index][4]); - /* should delay 50 ns */ + USHORT temp; + + temp = SiS_GetReg(Port,Index); + temp |= DataOR; + SiS_SetReg(Port,Index,temp); } +/*********************************************/ +/* HELPER: DisplayOn, DisplayOff */ +/*********************************************/ + void -SiS_CheckBusWidth_310(SiS_Private *SiS_Pr, UCHAR *ROMAddress,ULONG FBAddress, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_DisplayOn(SiS_Private *SiS_Pr) { - USHORT data, temp; - PULONG volatile pVideoMemory; - - pVideoMemory = (PULONG)FBAddress; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x01,0xDF,0x00); +} - if(HwDeviceExtension->jChipType == SIS_330) temp = 1; - else temp = 2; +void +SiS_DisplayOff(SiS_Private *SiS_Pr) +{ + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x01,0xDF,0x20); +} - if(SiS_Get310DRAMType(ROMAddress,HwDeviceExtension) < temp) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,0x00); - if(HwDeviceExtension->jChipType != SIS_330) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0x12); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0x02); - } - /* should delay */ - SiS_SDR_MRS(SiS_Pr); +/*********************************************/ +/* HELPER: Init Port Addresses */ +/*********************************************/ - SiS_Pr->SiS_ChannelAB = 0; - SiS_Pr->SiS_DataBusWidth = 128; - pVideoMemory[0] = 0x01234567L; - pVideoMemory[1] = 0x456789ABL; - pVideoMemory[2] = 0x89ABCDEFL; - pVideoMemory[3] = 0xCDEF0123L; - pVideoMemory[4] = 0x55555555L; - pVideoMemory[5] = 0x55555555L; - pVideoMemory[6] = 0xFFFFFFFFL; - pVideoMemory[7] = 0xFFFFFFFFL; - if((pVideoMemory[3] != 0xCDEF0123L) || (pVideoMemory[2] != 0x89ABCDEFL)) { - /* Channel A 64Bit */ - SiS_Pr->SiS_DataBusWidth = 64; - SiS_Pr->SiS_ChannelAB = 0; - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x14, 0xFD); - } - if((pVideoMemory[1] != 0x456789ABL) || (pVideoMemory[0] != 0x01234567L)) { - /* Channel B 64Bit */ - SiS_Pr->SiS_DataBusWidth = 64; - SiS_Pr->SiS_ChannelAB = 1; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x14,0xfd,0x01); - } - return; +void +SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr) +{ + SiS_Pr->SiS_P3c4 = BaseAddr + 0x14; + SiS_Pr->SiS_P3d4 = BaseAddr + 0x24; + SiS_Pr->SiS_P3c0 = BaseAddr + 0x10; + SiS_Pr->SiS_P3ce = BaseAddr + 0x1e; + SiS_Pr->SiS_P3c2 = BaseAddr + 0x12; + SiS_Pr->SiS_P3ca = BaseAddr + 0x1a; + SiS_Pr->SiS_P3c6 = BaseAddr + 0x16; + SiS_Pr->SiS_P3c7 = BaseAddr + 0x17; + SiS_Pr->SiS_P3c8 = BaseAddr + 0x18; + SiS_Pr->SiS_P3c9 = BaseAddr + 0x19; + SiS_Pr->SiS_P3cb = BaseAddr + 0x1b; + SiS_Pr->SiS_P3cd = BaseAddr + 0x1d; + SiS_Pr->SiS_P3da = BaseAddr + 0x2a; + SiS_Pr->SiS_Part1Port = BaseAddr + SIS_CRT2_PORT_04; /* Digital video interface registers (LCD) */ + SiS_Pr->SiS_Part2Port = BaseAddr + SIS_CRT2_PORT_10; /* 301 TV Encoder registers */ + SiS_Pr->SiS_Part3Port = BaseAddr + SIS_CRT2_PORT_12; /* 301 Macrovision registers */ + SiS_Pr->SiS_Part4Port = BaseAddr + SIS_CRT2_PORT_14; /* 301 VGA2 (and LCD) registers */ + SiS_Pr->SiS_Part5Port = BaseAddr + SIS_CRT2_PORT_14 + 2; /* 301 palette address port registers */ + SiS_Pr->SiS_DDC_Port = BaseAddr + 0x14; /* DDC Port ( = P3C4, SR11/0A) */ + SiS_Pr->SiS_VidCapt = BaseAddr + SIS_VIDEO_CAPTURE; + SiS_Pr->SiS_VidPlay = BaseAddr + SIS_VIDEO_PLAYBACK; +} + +/*********************************************/ +/* HELPER: GetSysFlags */ +/*********************************************/ - } else { +static void +SiS_GetSysFlags(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + unsigned char cr5f, temp1, temp2; - /* DDR Dual channel */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,0x00); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0x02); /* Channel A, 64bit */ - /* should delay */ - SiS_DDR_MRS(SiS_Pr); - - SiS_Pr->SiS_ChannelAB = 0; - SiS_Pr->SiS_DataBusWidth = 64; - pVideoMemory[0] = 0x01234567L; - pVideoMemory[1] = 0x456789ABL; - pVideoMemory[2] = 0x89ABCDEFL; - pVideoMemory[3] = 0xCDEF0123L; - pVideoMemory[4] = 0x55555555L; - pVideoMemory[5] = 0x55555555L; - pVideoMemory[6] = 0xAAAAAAAAL; - pVideoMemory[7] = 0xAAAAAAAAL; - - if (pVideoMemory[1] == 0x456789ABL) { - if (pVideoMemory[0] == 0x01234567L) { - /* Channel A 64bit */ - return; - } - } else { - if (pVideoMemory[0] == 0x01234567L) { - /* Channel A 32bit */ - SiS_Pr->SiS_DataBusWidth = 32; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0x00); - return; - } - } + /* 661 and newer: NEVER write non-zero to SR11[7:4] */ + /* (SR11 is used for DDC and in enable/disablebridge) */ + SiS_Pr->SiS_SensibleSR11 = FALSE; + SiS_Pr->SiS_MyCR63 = 0x63; + if(HwInfo->jChipType >= SIS_661) { + SiS_Pr->SiS_SensibleSR11 = TRUE; + SiS_Pr->SiS_MyCR63 = 0x53; + } + + /* You should use the macros, not these flags directly */ + + SiS_Pr->SiS_SysFlags = 0; + if(HwInfo->jChipType == SIS_650) { + cr5f = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0; + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x5c,0x07); + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x5c,0xf8); + temp2 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; + if((!temp1) || (temp2)) { + switch(cr5f) { + case 0x80: + case 0x90: + case 0xc0: + SiS_Pr->SiS_SysFlags |= SF_IsM650; break; + case 0xa0: + case 0xb0: + case 0xe0: + SiS_Pr->SiS_SysFlags |= SF_Is651; break; + } + } else { + switch(cr5f) { + case 0x90: + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; + switch(temp1) { + case 0x00: SiS_Pr->SiS_SysFlags |= SF_IsM652; break; + case 0x40: SiS_Pr->SiS_SysFlags |= SF_IsM653; break; + default: SiS_Pr->SiS_SysFlags |= SF_IsM650; break; + } + break; + case 0xb0: + SiS_Pr->SiS_SysFlags |= SF_Is652; break; + default: + SiS_Pr->SiS_SysFlags |= SF_IsM650; break; + } + } + } +} - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0x03); /* Channel B, 64bit */ - SiS_DDR_MRS(SiS_Pr); +/*********************************************/ +/* HELPER: Init PCI & Engines */ +/*********************************************/ - SiS_Pr->SiS_ChannelAB = 1; - SiS_Pr->SiS_DataBusWidth = 64; - pVideoMemory[0] = 0x01234567L; - pVideoMemory[1] = 0x456789ABL; - pVideoMemory[2] = 0x89ABCDEFL; - pVideoMemory[3] = 0xCDEF0123L; - pVideoMemory[4] = 0x55555555L; - pVideoMemory[5] = 0x55555555L; - pVideoMemory[6] = 0xAAAAAAAAL; - pVideoMemory[7] = 0xAAAAAAAAL; - if(pVideoMemory[1] == 0x456789ABL) { - /* Channel B 64 */ - if(pVideoMemory[0] == 0x01234567L) { - /* Channel B 64bit */ - return; - } else { - /* error */ - } - } else { - if(pVideoMemory[0] == 0x01234567L) { - /* Channel B 32 */ - SiS_Pr->SiS_DataBusWidth = 32; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0x01); - } else { - /* error */ - } - } +static void +SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + switch(HwInfo->jChipType) { + case SIS_300: + case SIS_540: + case SIS_630: + case SIS_730: + /* Set - PCI LINEAR ADDRESSING ENABLE (0x80) + * - RELOCATED VGA IO (0x20) + * - MMIO ENABLE (0x1) + */ + SiS_SetReg(SiS_Pr->SiS_P3c4,0x20,0xa1); + /* - Enable 2D (0x40) + * - Enable 3D (0x02) + * - Enable 3D Vertex command fetch (0x10) ? + * - Enable 3D command parser (0x08) ? + */ + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x5A); + break; + case SIS_315H: + case SIS_315: + case SIS_315PRO: + case SIS_650: + case SIS_740: + case SIS_330: + case SIS_661: + case SIS_741: + case SIS_660: + case SIS_760: + SiS_SetReg(SiS_Pr->SiS_P3c4,0x20,0xa1); + /* - Enable 2D (0x40) + * - Enable 3D (0x02) + * - Enable 3D vertex command fetch (0x10) + * - Enable 3D command parser (0x08) + * - Enable 3D G/L transformation engine (0x80) + */ + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0xDA); + break; + case SIS_550: + SiS_SetReg(SiS_Pr->SiS_P3c4,0x20,0xa1); + /* No 3D engine ! */ + /* - Enable 2D (0x40) + */ + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x40); } } -int -SiS_SetRank(SiS_Private *SiS_Pr, int index,UCHAR RankNo,USHORT DRAMTYPE_TABLE[][5]) +/*********************************************/ +/* HELPER: SetLVDSetc */ +/*********************************************/ + +void +SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - USHORT data; - int RankSize; + ULONG temp; - if ((RankNo==2)&&(DRAMTYPE_TABLE[index][0]==2)) - return 0; + SiS_Pr->SiS_IF_DEF_LVDS = 0; + SiS_Pr->SiS_IF_DEF_TRUMPION = 0; + SiS_Pr->SiS_IF_DEF_CH70xx = 0; + SiS_Pr->SiS_IF_DEF_DSTN = 0; + SiS_Pr->SiS_IF_DEF_FSTN = 0; + SiS_Pr->SiS_IF_DEF_CONEX = 0; - RankSize = DRAMTYPE_TABLE[index][3]/2 * SiS_Pr->SiS_DataBusWidth / 32; + SiS_Pr->SiS_ChrontelInit = 0; - if (RankNo * RankSize <= 128) { - data = 0; - while((RankSize >>= 1) > 0) { - data += 0x10; - } - data |= (RankNo - 1) << 2; - data |= (SiS_Pr->SiS_DataBusWidth / 64) & 2; - data |= SiS_Pr->SiS_ChannelAB; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,data); - /* should delay */ - SiS_SDR_MRS(SiS_Pr); - return 1; - } else - return 0; + switch(HwInfo->jChipType) { +#ifdef SIS300 + case SIS_540: + case SIS_630: + case SIS_730: + /* Check for SiS30x first */ + temp = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); + if((temp == 1) || (temp == 2)) return; + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + temp = (temp & 0x0E) >> 1; + if((temp >= 2) && (temp <= 5)) SiS_Pr->SiS_IF_DEF_LVDS = 1; + if(temp == 3) SiS_Pr->SiS_IF_DEF_TRUMPION = 1; + if((temp == 4) || (temp == 5)) { + /* Save power status (and error check) - UNUSED */ + SiS_Pr->SiS_Backup70xx = SiS_GetCH700x(SiS_Pr, 0x0e); + SiS_Pr->SiS_IF_DEF_CH70xx = 1; + } + break; +#endif +#ifdef SIS315H + case SIS_550: + case SIS_650: + case SIS_740: + case SIS_330: + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + temp = (temp & 0x0E) >> 1; + if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1; + if(temp == 3) SiS_Pr->SiS_IF_DEF_CH70xx = 2; + break; + case SIS_661: + case SIS_741: + case SIS_660: + case SIS_760: + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + temp = (temp & 0xe0) >> 5; + if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1; + if(temp == 3) SiS_Pr->SiS_IF_DEF_CH70xx = 2; + if(temp == 4) SiS_Pr->SiS_IF_DEF_CONEX = 1; /* Not yet supported */ + break; +#endif + default: + break; + } } -int -SiS_SetDDRChannel(SiS_Private *SiS_Pr, int index,UCHAR ChannelNo, - USHORT DRAMTYPE_TABLE[][5]) -{ - USHORT data; - int RankSize; +/*********************************************/ +/* HELPER: Enable DSTN/FSTN */ +/*********************************************/ - RankSize = DRAMTYPE_TABLE[index][3]/2 * SiS_Pr->SiS_DataBusWidth / 32; - /* RankSize = DRAMTYPE_TABLE[index][3]; */ - if (ChannelNo * RankSize <= 128) { - data = 0; - while((RankSize >>= 1) > 0) { - data += 0x10; - } - if(ChannelNo == 2) data |= 0x0C; - data |= (SiS_Pr->SiS_DataBusWidth / 32) & 2; - data |= SiS_Pr->SiS_ChannelAB; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,data); - /* should delay */ - SiS_DDR_MRS(SiS_Pr); - return 1; - } else - return 0; +void +SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable) +{ + SiS_Pr->SiS_IF_DEF_DSTN = enable ? 1 : 0; } -int -SiS_CheckColumn(SiS_Private *SiS_Pr, int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress) +void +SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable) { - int i; - ULONG Increment,Position; - - /*Increment = 1<<(DRAMTYPE_TABLE[index][2] + SiS_Pr->SiS_DataBusWidth / 64 + 1); */ - Increment = 1 << (10 + SiS_Pr->SiS_DataBusWidth / 64); - - for (i=0,Position=0;i<2;i++) { - *((PULONG)(FBAddress + Position)) = Position; - Position += Increment; - } - - for (i=0,Position=0;i<2;i++) { -/* if (FBAddress[Position]!=Position) */ - if((*(PULONG)(FBAddress + Position)) != Position) - return 0; - Position += Increment; - } - return 1; + SiS_Pr->SiS_IF_DEF_FSTN = enable ? 1 : 0; } -int -SiS_CheckBanks(SiS_Private *SiS_Pr, int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress) +/*********************************************/ +/* HELPER: Determine ROM usage */ +/*********************************************/ + +static void +SiSDetermineROMUsage(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - int i; - ULONG Increment,Position; - Increment = 1 << (DRAMTYPE_TABLE[index][2] + SiS_Pr->SiS_DataBusWidth / 64 + 2); + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - for (i=0,Position=0;i<4;i++) { -/* FBAddress[Position]=Position; */ - *((PULONG)(FBAddress + Position)) = Position; - Position += Increment; - } + if((ROMAddr) && (HwInfo->UseROM)) { + if((ROMAddr[0x00] != 0x55) || (ROMAddr[0x01] != 0xAA)) { + SiS_Pr->SiS_UseROM = FALSE; + } else if(HwInfo->jChipType == SIS_300) { + /* 300: We check if the code starts below 0x220 by + * checking the jmp instruction at the beginning + * of the BIOS image. + */ + if((ROMAddr[3] == 0xe9) && + ((ROMAddr[5] << 8) | ROMAddr[4]) > 0x21a) + SiS_Pr->SiS_UseROM = TRUE; + else + SiS_Pr->SiS_UseROM = FALSE; + } else if(HwInfo->jChipType < SIS_315H) { +#if 0 + /* Rest of 300 series: We don't use the ROM image if + * the BIOS version < 2.0.0 as such old BIOSes don't + * have the needed data at the expected locations. + */ + if(ROMAddr[0x06] < '2') SiS_Pr->SiS_UseROM = FALSE; + else SiS_Pr->SiS_UseROM = TRUE; +#else + /* Sony's VAIO BIOS 1.09 follows the standard, so perhaps + * the others do as well + */ + SiS_Pr->SiS_UseROM = TRUE; +#endif + } else { + /* 315/330 series stick to the standard */ + SiS_Pr->SiS_UseROM = TRUE; + } + } else SiS_Pr->SiS_UseROM = FALSE; - for (i=0,Position=0;i<4;i++) { -/* if (FBAddress[Position]!=Position) */ - if((*(PULONG)(FBAddress + Position)) != Position) - return 0; - Position += Increment; - } - return 1; } -int -SiS_CheckRank(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress) -{ - int i; - ULONG Increment,Position; - Increment = 1<<(DRAMTYPE_TABLE[index][2] + DRAMTYPE_TABLE[index][1] + - DRAMTYPE_TABLE[index][0] + SiS_Pr->SiS_DataBusWidth / 64 + RankNo); - - for (i=0,Position=0;i<2;i++) { -/* FBAddress[Position]=Position; */ - *((PULONG)(FBAddress+Position))=Position; - /* *((PULONG)(FBAddress))=Position; */ - Position += Increment; - } - - for (i=0,Position=0;i<2;i++) { -/* if (FBAddress[Position]!=Position) */ - if ( (*(PULONG) (FBAddress + Position)) !=Position) - /*if ( (*(PULONG) (FBAddress )) !=Position) */ - return 0; - Position += Increment; - } - return 1; -} +/*********************************************/ +/* HELPER: SET SEGMENT REGISTERS */ +/*********************************************/ -int -SiS_CheckDDRRank(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress) +static void +SiS_SetSegRegLower(SiS_Private *SiS_Pr, USHORT value) { - ULONG Increment,Position; - USHORT data; - - Increment = 1<<(DRAMTYPE_TABLE[index][2] + DRAMTYPE_TABLE[index][1] + - DRAMTYPE_TABLE[index][0] + SiS_Pr->SiS_DataBusWidth / 64 + RankNo); + USHORT temp; - Increment += Increment/2; - - Position =0; - *((PULONG)(FBAddress+Position + 0)) = 0x01234567; - *((PULONG)(FBAddress+Position + 1)) = 0x456789AB; - *((PULONG)(FBAddress+Position + 2)) = 0x55555555; - *((PULONG)(FBAddress+Position + 3)) = 0x55555555; - *((PULONG)(FBAddress+Position + 4)) = 0xAAAAAAAA; - *((PULONG)(FBAddress+Position + 5)) = 0xAAAAAAAA; - - if ( (*(PULONG) (FBAddress + 1)) == 0x456789AB) - return 1; - - if ( (*(PULONG) (FBAddress + 0)) == 0x01234567) - return 0; - - data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - data &= 0xF3; - data |= 0x08; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,data); - data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15); - data += 0x20; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x15,data); - - return 1; + value &= 0x00ff; + temp = SiS_GetRegByte(SiS_Pr->SiS_P3cb) & 0xf0; + temp |= (value >> 4); + SiS_SetRegByte(SiS_Pr->SiS_P3cb, temp); + temp = SiS_GetRegByte(SiS_Pr->SiS_P3cd) & 0xf0; + temp |= (value & 0x0f); + SiS_SetRegByte(SiS_Pr->SiS_P3cd, temp); } -int -SiS_CheckRanks(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress) +static void +SiS_SetSegRegUpper(SiS_Private *SiS_Pr, USHORT value) { - int r; + USHORT temp; - for (r=RankNo;r>=1;r--) { - if (!SiS_CheckRank(SiS_Pr, r, index, DRAMTYPE_TABLE, FBAddress)) - return 0; - } - if (!SiS_CheckBanks(SiS_Pr, index, DRAMTYPE_TABLE, FBAddress)) - return 0; - - if (!SiS_CheckColumn(SiS_Pr, index, DRAMTYPE_TABLE, FBAddress)) - return 0; - - return 1; + value &= 0x00ff; + temp = SiS_GetRegByte(SiS_Pr->SiS_P3cb) & 0x0f; + temp |= (value & 0xf0); + SiS_SetRegByte(SiS_Pr->SiS_P3cb, temp); + temp = SiS_GetRegByte(SiS_Pr->SiS_P3cd) & 0x0f; + temp |= (value << 4); + SiS_SetRegByte(SiS_Pr->SiS_P3cd, temp); } -int -SiS_CheckDDRRanks(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5], - ULONG FBAddress) +static void +SiS_SetSegmentReg(SiS_Private *SiS_Pr, USHORT value) { - int r; - - for (r=RankNo;r>=1;r--) { - if (!SiS_CheckDDRRank(SiS_Pr, r,index,DRAMTYPE_TABLE,FBAddress)) - return 0; - } - if (!SiS_CheckBanks(SiS_Pr, index,DRAMTYPE_TABLE,FBAddress)) - return 0; - - if (!SiS_CheckColumn(SiS_Pr, index,DRAMTYPE_TABLE,FBAddress)) - return 0; - - return 1; + SiS_SetSegRegLower(SiS_Pr, value); + SiS_SetSegRegUpper(SiS_Pr, value); } -int -SiS_SDRSizing(SiS_Private *SiS_Pr, ULONG FBAddress) +static void +SiS_ResetSegmentReg(SiS_Private *SiS_Pr) { - int i; - UCHAR j; - - for (i=0;i<13;i++) { - SiS_SetDRAMSizingType(SiS_Pr, i, SiS_SDRDRAM_TYPE); - for (j=2;j>0;j--) { - if (!SiS_SetRank(SiS_Pr, i,(UCHAR) j, SiS_SDRDRAM_TYPE)) - continue; - else { - if (SiS_CheckRanks(SiS_Pr, j,i,SiS_SDRDRAM_TYPE, FBAddress)) - return 1; - } - } - } - return 0; + SiS_SetSegmentReg(SiS_Pr, 0); } -int -SiS_DDRSizing(SiS_Private *SiS_Pr, ULONG FBAddress) +static void +SiS_SetSegmentRegOver(SiS_Private *SiS_Pr, USHORT value) { + USHORT temp = value >> 8; - int i; - UCHAR j; - - for (i=0; i<4; i++){ - SiS_SetDRAMSizingType(SiS_Pr, i, SiS_DDRDRAM_TYPE); - SiS_DisableChannelInterleaving(SiS_Pr, i, SiS_DDRDRAM_TYPE); - for (j=2; j>0; j--) { - SiS_SetDDRChannel(SiS_Pr, i, j, SiS_DDRDRAM_TYPE); - if (!SiS_SetRank(SiS_Pr, i, (UCHAR) j, SiS_DDRDRAM_TYPE)) - continue; - else { - if (SiS_CheckDDRRanks(SiS_Pr, j, i, SiS_DDRDRAM_TYPE, FBAddress)) - return 1; - } - } - } - return 0; + temp &= 0x07; + temp |= (temp << 4); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x1d,temp); + SiS_SetSegmentReg(SiS_Pr, value); } -/* - check if read cache pointer is correct -*/ -void -SiS_VerifyMclk(SiS_Private *SiS_Pr, ULONG FBAddr) +static void +SiS_ResetSegmentRegOver(SiS_Private *SiS_Pr) { - PUCHAR pVideoMemory = (PUCHAR) FBAddr; - UCHAR i, j; - USHORT Temp,SR21; - - pVideoMemory[0] = 0xaa; /* alan */ - pVideoMemory[16] = 0x55; /* note: PCI read cache is off */ - - if((pVideoMemory[0] != 0xaa) || (pVideoMemory[16] != 0x55)) { - for (i=0,j=16; i<2; i++,j+=16) { - SR21 = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x21); - Temp = SR21 & 0xFB; /* disable PCI post write buffer empty gating */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x21,Temp); - - Temp = SiS_GetReg1(SiS_Pr->SiS_P3c4, 0x3C); - Temp |= 0x01; /* MCLK reset */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x3C,Temp); - Temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3C); - Temp &= 0xFE; /* MCLK normal operation */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x3C,Temp); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x21,SR21); - - pVideoMemory[16+j] = j; - if(pVideoMemory[16+j] == j) { - pVideoMemory[j] = j; - break; - } - } - } + SiS_SetSegmentRegOver(SiS_Pr, 0); } -/* TW: Is this a 315E? */ -int -Is315E(SiS_Private *SiS_Pr) +static void +SiS_ResetSegmentRegisters(SiS_Private *SiS_Pr,PSIS_HW_INFO HwInfo) { - USHORT data; - - data = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5F); - if(data & 0x10) return 1; - else return 0; + if((IS_SIS65x) || (HwInfo->jChipType >= SIS_661)) { + SiS_ResetSegmentReg(SiS_Pr); + SiS_ResetSegmentRegOver(SiS_Pr); + } } -/* TW: For 315 only */ +/*********************************************/ +/* HELPER: GetVBType */ +/*********************************************/ + void -SiS_SetDRAMSize_310(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - ULONG FBAddr = (ULONG)HwDeviceExtension->pjVideoMemoryAddress; - USHORT data; + USHORT flag=0, rev=0, nolcd=0; -#ifdef SIS301 /* TW: SIS301 ??? */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,0x40); */ -#endif -#ifdef SIS302 /* TW: SIS302 ??? */ - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,0x4D); /* alan,should change value */ - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x31,0xc0); /* alan,should change value */ - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x34,0x3F); /* alan,should change value */ -#endif + SiS_Pr->SiS_VBType = 0; - SiSSetMode(SiS_Pr, HwDeviceExtension, 0x2e); + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) return; - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x21); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x21,0xDF); /* disable read cache */ + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x20); /* Turn OFF Display */ + if(flag > 3) return; - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x16,0x0F); /* assume lowest speed DRAM */ + rev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); - SiS_SetDRAMModeRegister(SiS_Pr, ROMAddr, HwDeviceExtension); - SiS_DisableRefresh(SiS_Pr); - SiS_CheckBusWidth_310(SiS_Pr, ROMAddr, FBAddr, HwDeviceExtension); + if(flag >= 2) { + SiS_Pr->SiS_VBType = VB_SIS302B; + } else if(flag == 1) { + SiS_Pr->SiS_VBType = VB_SIS301; + if(rev >= 0xC0) { + SiS_Pr->SiS_VBType = VB_SIS301C; + } else if(rev >= 0xB0) { + SiS_Pr->SiS_VBType = VB_SIS301B; + /* Check if 30xB DH version (no LCD support, use Panel Link instead) */ + nolcd = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x23); + if(!(nolcd & 0x02)) SiS_Pr->SiS_VBType |= VB_NoLCD; + } + } + if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS301C | VB_SIS302B)) { + if(rev >= 0xD0) { + SiS_Pr->SiS_VBType &= ~(VB_SIS301B | VB_SIS301C | VB_SIS302B | VB_NoLCD); + if(rev >= 0xE0) { + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x39); + if(flag == 0xff) + SiS_Pr->SiS_VBType |= VB_SIS302LV; + else + SiS_Pr->SiS_VBType |= VB_SIS302ELV; + } else { + SiS_Pr->SiS_VBType |= VB_SIS301LV; + } + } + } +} - SiS_VerifyMclk(SiS_Pr, FBAddr); +/*********************************************/ +/* HELPER: GetDRAMSize */ +/*********************************************/ - if(HwDeviceExtension->jChipType == SIS_330) temp = 1; - else temp = 2; +#ifndef LINUX_XF86 +static ULONG +GetDRAMSize(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + ULONG AdapterMemorySize = 0; +#ifdef SIS315H + USHORT counter; +#endif - if(SiS_Get310DRAMType(SiS_Pr, ROMAddr, HwDeviceExtension) < temp) - SiS_SDRSizing(SiS_Pr, FBAddr); - else - SiS_DDRSizing(SiS_Pr, FBAddr); + switch(HwInfo->jChipType) { +#ifdef SIS315H + case SIS_315H: + case SIS_315: + case SIS_315PRO: + counter = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + AdapterMemorySize = 1 << ((counter & 0xF0) >> 4); + counter >>= 2; + counter &= 0x03; + if(counter == 0x02) { + AdapterMemorySize += (AdapterMemorySize / 2); /* DDR asymetric */ + } else if(counter != 0) { + AdapterMemorySize <<= 1; /* SINGLE_CHANNEL_2_RANK or DUAL_CHANNEL_1_RANK */ + } + AdapterMemorySize *= (1024*1024); + break; - if(HwDeviceExtension->jChipType != SIS_330) { - if(Is315E(SiS_Pr)) { - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - if((data & 0x0C) == 0x0C) { /* dual channel */ - if((data & 0xF0) > 0x40) - data = (data & 0x0F) | 0x40; - } else { /* single channel */ - if((data & 0xF0) > 0x50) - data = (data & 0x0F) | 0x50; - } - } - } + case SIS_330: + counter = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + AdapterMemorySize = 1 << ((counter & 0xF0) >> 4); + counter &= 0x0c; + if(counter != 0) { + AdapterMemorySize <<= 1; + } + AdapterMemorySize *= (1024*1024); + break; + + case SIS_550: + case SIS_650: + case SIS_740: + counter = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x3F; + counter++; + AdapterMemorySize = counter * 4; + AdapterMemorySize *= (1024*1024); + break; + + case SIS_661: + case SIS_741: + case SIS_660: + case SIS_760: + counter = (SiS_GetReg(SiS_Pr->SiS_P3c4,0x79) & 0xf0) >> 4; + AdapterMemorySize = 1 << counter; + AdapterMemorySize *= (1024*1024); + break; +#endif - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,SiS_Pr->SiS_SR15[1][SiS_Pr->SiS_RAMType]); /* restore SR16 */ +#ifdef SIS300 + case SIS_300: + case SIS_540: + case SIS_630: + case SIS_730: + AdapterMemorySize = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x3F; + AdapterMemorySize++; + AdapterMemorySize *= (1024*1024); + break; +#endif + default: + break; + } - SiS_EnableRefresh(SiS_Pr, ROMAddr); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x21,0x20); /* enable read cache */ + return AdapterMemorySize; } #endif -void -SiS_SetMemoryClock(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) +/*********************************************/ +/* HELPER: Check RAM size */ +/*********************************************/ + +#ifndef LINUX_XF86 +static BOOLEAN +SiS_CheckMemorySize(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x28,SiS_Pr->SiS_MCLKData_0[SiS_Pr->SiS_RAMType].SR28); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x29,SiS_Pr->SiS_MCLKData_0[SiS_Pr->SiS_RAMType].SR29); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2A,SiS_Pr->SiS_MCLKData_0[SiS_Pr->SiS_RAMType].SR2A); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2E,SiS_Pr->SiS_ECLKData[SiS_Pr->SiS_RAMType].SR2E); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2F,SiS_Pr->SiS_ECLKData[SiS_Pr->SiS_RAMType].SR2F); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x30,SiS_Pr->SiS_ECLKData[SiS_Pr->SiS_RAMType].SR30); + USHORT memorysize,modeflag; + ULONG temp; -#ifdef SIS315H - if (Is315E(SiS_Pr)) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x28,0x3B); /* 143 */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x29,0x22); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2E,0x3B); /* 143 */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2F,0x22); - } -#endif + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + } else { + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } + } + + memorysize = modeflag & MemoryInfoFlag; + memorysize >>= MemorySizeShift; /* Get required memory size */ + memorysize++; + + temp = GetDRAMSize(SiS_Pr, HwInfo); /* Get adapter memory size (in MB) */ + temp /= (1024*1024); + + if(temp < memorysize) return(FALSE); + else return(TRUE); } +#endif -#endif /* ifdef LINUXBIOS */ +/*********************************************/ +/* HELPER: Get DRAM type */ +/*********************************************/ #ifdef SIS315H -UCHAR -SiS_Get310DRAMType(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) +static UCHAR +SiS_Get310DRAMType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { UCHAR data, temp; if(*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) { data = *SiS_Pr->pSiS_SoftSetting & 0x03; } else { - if((HwDeviceExtension->jChipType > SIS_315PRO) && - (HwDeviceExtension->jChipType < SIS_330)) { - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x07; - } else { /* TW: 315, 330 */ - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3a) & 0x03; - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_661) { + data = SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0x07; + } else if(IS_SIS550650740) { + data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x07; + } else { /* 315, 330 */ + data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3a) & 0x03; + if(HwInfo->jChipType == SIS_330) { if(data > 1) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f) & 0x30; + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0x30; switch(temp) { case 0x00: data = 1; break; case 0x10: data = 3; break; @@ -1916,1560 +1794,1244 @@ SiS_Get310DRAMType(SiS_Private *SiS_Pr, return data; } -#endif -/* SiSInit END */ +USHORT +SiS_GetMCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT index; + + index = SiS_Get310DRAMType(SiS_Pr, HwInfo); + if(HwInfo->jChipType >= SIS_661) { + return(SiS_Pr->SiS_MCLKData_0[index].CLOCK); + } else if(index >= 4) { + index -= 4; + return(SiS_Pr->SiS_MCLKData_1[index].CLOCK); + } else { + return(SiS_Pr->SiS_MCLKData_0[index].CLOCK); + } +} +#endif -/* ----------------------------------------- */ +/*********************************************/ +/* HELPER: ClearBuffer */ +/*********************************************/ -void SiSRegInit(SiS_Private *SiS_Pr, USHORT BaseAddr) +#ifndef LINUX_XF86 +static void +SiS_ClearBuffer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) { - SiS_Pr->SiS_P3c4 = BaseAddr + 0x14; - SiS_Pr->SiS_P3d4 = BaseAddr + 0x24; - SiS_Pr->SiS_P3c0 = BaseAddr + 0x10; - SiS_Pr->SiS_P3ce = BaseAddr + 0x1e; - SiS_Pr->SiS_P3c2 = BaseAddr + 0x12; - SiS_Pr->SiS_P3ca = BaseAddr + 0x1a; - SiS_Pr->SiS_P3c6 = BaseAddr + 0x16; - SiS_Pr->SiS_P3c7 = BaseAddr + 0x17; - SiS_Pr->SiS_P3c8 = BaseAddr + 0x18; - SiS_Pr->SiS_P3c9 = BaseAddr + 0x19; - SiS_Pr->SiS_P3da = BaseAddr + 0x2A; - SiS_Pr->SiS_Part1Port = BaseAddr + SIS_CRT2_PORT_04; /* Digital video interface registers (LCD) */ - SiS_Pr->SiS_Part2Port = BaseAddr + SIS_CRT2_PORT_10; /* 301 TV Encoder registers */ - SiS_Pr->SiS_Part3Port = BaseAddr + SIS_CRT2_PORT_12; /* 301 Macrovision registers */ - SiS_Pr->SiS_Part4Port = BaseAddr + SIS_CRT2_PORT_14; /* 301 VGA2 (and LCD) registers */ - SiS_Pr->SiS_Part5Port = BaseAddr + SIS_CRT2_PORT_14+2; /* 301 palette address port registers */ - SiS_Pr->SiS_DDC_Port = BaseAddr + 0x14; /* DDC Port ( = P3C4, SR11/0A) */ -} + UCHAR *VideoMemoryAddress = HwInfo->pjVideoMemoryAddress; + ULONG AdapterMemorySize = (ULONG)HwInfo->ulVideoMemorySize; + USHORT *pBuffer; + int i; -void -SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ -/* #ifdef LINUX_XF86 */ - if ((HwDeviceExtension->jChipType == SIS_540)|| - (HwDeviceExtension->jChipType == SIS_630)|| - (HwDeviceExtension->jChipType == SIS_730)|| - (HwDeviceExtension->jChipType == SIS_300)) { - /* TW: Set - PCI LINEAR ADDRESSING ENABLE (0x80) - - PCI IO ENABLE (0x20) - - MMIO ENABLE (0x1) - */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x20,0xa1); - /* TW: Enable 2D (0x42) & 3D accelerator (0x18) */ - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1E,0xFF,0x5A); - } - if((HwDeviceExtension->jChipType == SIS_315H)|| - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO)|| - (HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) { - /* TW: This seems to be done the same way on these chipsets */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x20,0xa1); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1E,0xFF,0x5A); - } -/* #endif */ + if(SiS_Pr->SiS_ModeType >= ModeEGA) { + if(ModeNo > 0x13) { + AdapterMemorySize = GetDRAMSize(SiS_Pr, HwInfo); + SiS_SetMemory(VideoMemoryAddress,AdapterMemorySize,0); + } else { + pBuffer = (USHORT *)VideoMemoryAddress; + for(i=0; i<0x4000; i++) + pBuffer[i] = 0x0000; + } + } else { + pBuffer = (USHORT *)VideoMemoryAddress; + if(SiS_Pr->SiS_ModeType < ModeCGA) { + for(i=0; i<0x4000; i++) + pBuffer[i] = 0x0720; + } else { + SiS_SetMemory(VideoMemoryAddress,0x8000,0); + } + } } +#endif -void -SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo) +/*********************************************/ +/* HELPER: SearchModeID */ +/*********************************************/ + +BOOLEAN +SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex) { - ULONG temp; + UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; - SiS_Pr->SiS_IF_DEF_LVDS = 0; - SiS_Pr->SiS_IF_DEF_TRUMPION = 0; - SiS_Pr->SiS_IF_DEF_CH70xx = 0; - SiS_Pr->SiS_IF_DEF_HiVision = 0; - SiS_Pr->SiS_IF_DEF_DSTN = 0; - SiS_Pr->SiS_IF_DEF_FSTN = 0; + if(*ModeNo <= 0x13) { - SiS_Pr->SiS_ChrontelInit = 0; + if((*ModeNo) <= 0x05) (*ModeNo) |= 0x01; - if((ModeNo == 0x5a) || (ModeNo == 0x5b)) { - SiS_Pr->SiS_IF_DEF_DSTN = 1; /* for 550 dstn */ - SiS_Pr->SiS_IF_DEF_FSTN = 1; /* for fstn */ - } + for(*ModeIdIndex = 0; ;(*ModeIdIndex)++) { + if(SiS_Pr->SiS_SModeIDTable[*ModeIdIndex].St_ModeID == (*ModeNo)) break; + if(SiS_Pr->SiS_SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF) return FALSE; + } -#ifdef SIS300 - if((HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730)) - { - /* TW: Check for SiS30x first */ - temp = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00); - if((temp == 1) || (temp == 2)) return; - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37); - temp = (temp & 0x0E) >> 1; - if((temp >= 2) && (temp <= 5)) SiS_Pr->SiS_IF_DEF_LVDS = 1; - if(temp == 3) SiS_Pr->SiS_IF_DEF_TRUMPION = 1; - if((temp == 4) || (temp == 5)) { - /* TW: Save power status (and error check) - UNUSED */ - SiS_Pr->SiS_Backup70xx = SiS_GetCH700x(SiS_Pr, 0x0e); - SiS_Pr->SiS_IF_DEF_CH70xx = 1; - } - } -#endif -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) - { - /* TW: CR37 is different on 310/325 series */ - if(SiS_Pr->SiS_IF_DEF_FSTN) /* fstn: set CR37=0x04 */ - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,0x04); /* (fake LVDS bridge) */ + if(*ModeNo == 0x07) { + if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */ + /* else 350 lines */ + } + if(*ModeNo <= 0x03) { + if(!(VGAINFO & 0x80)) (*ModeIdIndex)++; + if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */ + /* else 350 lines */ + } + /* else 200 lines */ - temp=SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37); - temp = (temp & 0x0E) >> 1; - if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1; - if(temp == 3) { - SiS_Pr->SiS_IF_DEF_CH70xx = 2; - } - - /* HiVision (HDTV) is done differently now. */ - /* SiS_Pr->SiS_IF_DEF_HiVision = 1; */ - } -#endif -} + } else { -void -SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) - InitTo310Pointer(SiS_Pr, HwDeviceExtension); -#endif + for(*ModeIdIndex = 0; ;(*ModeIdIndex)++) { + if(SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == (*ModeNo)) break; + if(SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF) return FALSE; + } -#ifdef SIS300 - if ((HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) || - (HwDeviceExtension->jChipType == SIS_300)) - InitTo300Pointer(SiS_Pr, HwDeviceExtension); -#endif + } + return TRUE; } -void -SiSDetermineROMUsage(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR *ROMAddr) -{ - if((ROMAddr) && (HwDeviceExtension->UseROM)) { - if((ROMAddr[0x00] != 0x55) || (ROMAddr[0x01] != 0xAA)) { - SiS_Pr->SiS_UseROM = FALSE; - } else if(HwDeviceExtension->jChipType == SIS_300) { - /* TW: 300: We check if the code starts below 0x220 by - * checking the jmp instruction at the beginning - * of the BIOS image. - */ - if((ROMAddr[3] == 0xe9) && - ((ROMAddr[5] << 8) | ROMAddr[4]) > 0x21a) - SiS_Pr->SiS_UseROM = TRUE; - else SiS_Pr->SiS_UseROM = FALSE; - } else if(HwDeviceExtension->jChipType < SIS_315H) { - /* TW: Rest of 300 series: We don't use the ROM image if - * the BIOS version < 2.0.0 as such old BIOSes don't - * have the needed data at the expected locations. - */ - if(ROMAddr[0x06] < '2') SiS_Pr->SiS_UseROM = FALSE; - else SiS_Pr->SiS_UseROM = TRUE; - } else { - /* TW: 310/325/330 series stick to the standard */ - SiS_Pr->SiS_UseROM = TRUE; - } - } else SiS_Pr->SiS_UseROM = FALSE; - -} +/*********************************************/ +/* HELPER: GetModePtr */ +/*********************************************/ -/* - ========================================= - ======== SiS SetMode Functions ========== - ========================================= -*/ -#ifdef LINUX_XF86 -/* TW: This is used for non-Dual-Head mode from X */ -BOOLEAN -SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, ScrnInfoPtr pScrn, - DisplayModePtr mode, BOOLEAN IsCustom) +UCHAR +SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex) { - SISPtr pSiS = SISPTR(pScrn); - UShort ModeNo=0; - - SiS_Pr->UseCustomMode = FALSE; + UCHAR index; - if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { - - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting custom mode %dx%d\n", - SiS_Pr->CHDisplay, SiS_Pr->CVDisplay); - - return(SiSSetMode(SiS_Pr, HwDeviceExtension, pScrn, ModeNo, TRUE)); - + if(ModeNo <= 0x13) { + index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_StTableIndex; + } else { + if(SiS_Pr->SiS_ModeType <= 0x02) index = 0x1B; /* 02 -> ModeEGA */ + else index = 0x0F; } - - ModeNo = SiS_CalcModeIndex(pScrn, mode); - if(!ModeNo) return FALSE; + return index; +} - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting mode 0x%x\n", ModeNo); +/*********************************************/ +/* HELPER: LowModeTests */ +/*********************************************/ + +static BOOLEAN +SiS_DoLowModeTest(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo) +{ + USHORT temp,temp1,temp2; + + if((ModeNo != 0x03) && (ModeNo != 0x10) && (ModeNo != 0x12)) + return(1); + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x11); + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x11,0x80); + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x00); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,0x55); + temp2 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x00); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,temp1); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x11,temp); + if((HwInfo->jChipType >= SIS_315H) || + (HwInfo->jChipType == SIS_300)) { + if(temp2 == 0x55) return(0); + else return(1); + } else { + if(temp2 != 0x55) return(1); + else { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); + return(0); + } + } +} - return(SiSSetMode(SiS_Pr, HwDeviceExtension, pScrn, ModeNo, TRUE)); +static void +SiS_SetLowModeTest(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo) +{ + if(SiS_DoLowModeTest(SiS_Pr, ModeNo, HwInfo)) { + SiS_Pr->SiS_SetFlag |= LowModeTests; + } } -#ifdef SISDUALHEAD -/* TW: Set CRT1 mode (used for dual head) */ -BOOLEAN -SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, ScrnInfoPtr pScrn, - DisplayModePtr mode, BOOLEAN IsCustom) +/*********************************************/ +/* HELPER: GetColorDepth */ +/*********************************************/ + +USHORT +SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex) { - ULONG temp; - USHORT ModeIdIndex; - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; - SISPtr pSiS = SISPTR(pScrn); - SISEntPtr pSiSEnt = pSiS->entityPrivate; - unsigned char backupreg=0; - BOOLEAN backupcustom; + USHORT ColorDepth[6] = { 1, 2, 4, 4, 6, 8}; + SHORT index; + USHORT modeflag; - UShort ModeNo=0; - - SiS_Pr->UseCustomMode = FALSE; - - if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { - - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting custom mode %dx%d in CRT1\n", - SiS_Pr->CHDisplay, SiS_Pr->CVDisplay); - ModeNo = 0xfe; - - } else { + /* Do NOT check UseCustomMode, will skrew up FIFO */ + if(ModeNo == 0xfe) { + modeflag = SiS_Pr->CModeFlag; + } else { + if(ModeNo <= 0x13) + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + else + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } - ModeNo = SiS_CalcModeIndex(pScrn, mode); - if(!ModeNo) return FALSE; + index = (modeflag & ModeInfoFlag) - ModeEGA; + if(index < 0) index = 0; + return(ColorDepth[index]); +} - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting mode 0x%x on CRT1\n", ModeNo); - } +/*********************************************/ +/* HELPER: GetOffset */ +/*********************************************/ - SiSInitPtr(SiS_Pr, HwDeviceExtension); +USHORT +SiS_GetOffset(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo) +{ + USHORT temp,colordepth,infoflag; - SiSRegInit(SiS_Pr, BaseAddr); + if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; + temp = SiS_Pr->CHDisplay / 16; + } else { + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; + temp = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeOffset; + temp = SiS_Pr->SiS_ScreenOffset[temp]; + } - SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); + colordepth = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex); - SiSInitPCIetc(SiS_Pr, HwDeviceExtension); + if(infoflag & InterlaceMode) temp <<= 1; - SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, ModeNo); + temp *= colordepth; - SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr); + if( ( ((ModeNo >= 0x26) && (ModeNo <= 0x28)) || + ModeNo == 0x3f || + ModeNo == 0x42 || + ModeNo == 0x45 ) || + (SiS_Pr->UseCustomMode && (SiS_Pr->CHDisplay % 16)) ) { + colordepth >>= 1; + temp += colordepth; + } - /* TW: We don't clear the buffer under X */ - SiS_Pr->SiS_flag_clearbuffer = 0; + return(temp); +} - /* 1.Openkey */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); +/*********************************************/ +/* SEQ */ +/*********************************************/ - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); +static void +SiS_SetSeqRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, PSIS_HW_INFO HwInfo) +{ + UCHAR SRdata; + USHORT i; - if(!SiS_Pr->UseCustomMode) { - /* 2.Get ModeID Table */ - temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&ModeNo,&ModeIdIndex); - if(temp == 0) return(0); - } else { - ModeIdIndex = 0; - } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x03); /* Set SR0 */ - /* TW: Determine VBType (301,301B,301LV,302B,302LV) */ - SiS_GetVBType(SiS_Pr, BaseAddr,HwDeviceExtension); + SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[0]; if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - } else { - backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SRdata |= 0x01; + } + if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SRdata |= 0x01; /* 8 dot clock */ + } + } + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_VBType & VB_NoLCD) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SRdata |= 0x01; /* 8 dot clock */ + } + } } } - /* TW: Get VB information (connectors, connected devices) */ - /* (We don't care if the current mode is a CRT2 mode) */ - SiS_GetVBInfo(SiS_Pr, BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,0); - SiS_SetHiVision(SiS_Pr, BaseAddr,HwDeviceExtension); - SiS_GetLCDResInfo(SiS_Pr, ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); - - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08) { - if(ModeNo != 0x10) SiS_Pr->SiS_SetFlag |= SetDOSMode; + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SRdata |= 0x01; /* 8 dot clock */ + } } } - - /* TW: New from 650/LV 1.10.6x */ - if(IS_SIS650) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SRdata |= 0x01; /* 8 dot clock */ + } } } - /* TW: Set mode on CRT1 */ - SiS_SetCRT1Group(SiS_Pr, ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,BaseAddr); - - pSiSEnt->CRT1ModeNo = ModeNo; - pSiSEnt->CRT1DMode = mode; - - /* TW: SetPitch: Adapt to virtual size & position */ - SiS_SetPitchCRT1(SiS_Pr, pScrn, BaseAddr); - - /* We have to reset CRT2 if changing mode on CRT1 */ - if(pSiSEnt->CRT2ModeNo != -1) { - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "(Re-)Setting mode 0x%x on CRT2\n", - pSiSEnt->CRT2ModeNo); - backupcustom = SiS_Pr->UseCustomMode; - if(SiS_Pr->UseCustomMode) { - SiS_Pr->CRT1UsesCustomMode = TRUE; - } else { - SiS_Pr->CRT1UsesCustomMode = FALSE; - } - SiSBIOSSetModeCRT2(SiS_Pr, HwDeviceExtension, pSiSEnt->pScrn_1, - pSiSEnt->CRT2DMode); - SiS_Pr->UseCustomMode = backupcustom; - SiS_Pr->CRT1UsesCustomMode = FALSE; - } - - SiS_HandleCRT1(SiS_Pr); + SRdata |= 0x20; /* screen off */ - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x01,SRdata); - /* TW: New from 650/LV 1.10.6x and 1.10.7w, 630/301B 2.06.50 */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x38,backupreg); - } else if((HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730)) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x35,backupreg); - } + for(i = 2; i <= 4; i++) { + SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i-1]; + SiS_SetReg(SiS_Pr->SiS_P3c4,i,SRdata); } - - /* Backup/Set ModeNo in BIOS scratch area */ - SiS_GetSetModeID(pScrn,ModeNo); - - return TRUE; } -/* TW: Set CRT2 mode (used for dual head) */ -BOOLEAN -SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, ScrnInfoPtr pScrn, - DisplayModePtr mode) +/*********************************************/ +/* MISC */ +/*********************************************/ + +static void +SiS_SetMiscRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, PSIS_HW_INFO HwInfo) { - ULONG temp; - USHORT ModeIdIndex; - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; - UShort ModeNo = 0; - SISPtr pSiS = SISPTR(pScrn); - SISEntPtr pSiSEnt = pSiS->entityPrivate; - unsigned char tempr1, tempr2, backupreg=0; - - SiS_Pr->UseCustomMode = FALSE; - - ModeNo = SiS_CalcModeIndex(pScrn, mode); - if(!ModeNo) return FALSE; + UCHAR Miscdata; - SiSInitPtr(SiS_Pr, HwDeviceExtension); + Miscdata = SiS_Pr->SiS_StandTable[StandTableIndex].MISC; - SiSRegInit(SiS_Pr, BaseAddr); + if(HwInfo->jChipType < SIS_661) { + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + Miscdata |= 0x0C; + } + } + } - SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); + SiS_SetRegByte(SiS_Pr->SiS_P3c2,Miscdata); +} - SiSInitPCIetc(SiS_Pr, HwDeviceExtension); +/*********************************************/ +/* CRTC */ +/*********************************************/ - SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, ModeNo); +static void +SiS_SetCRTCRegs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT StandTableIndex) +{ + UCHAR CRTCdata; + USHORT i; - SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /* Unlock CRTC */ - /* TW: We don't clear the buffer under X */ - SiS_Pr->SiS_flag_clearbuffer=0; + for(i = 0; i <= 0x18; i++) { + CRTCdata = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i]; + SiS_SetReg(SiS_Pr->SiS_P3d4,i,CRTCdata); /* Set CRTC(3d4) */ + } + if( ( (HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730) ) && + (HwInfo->jChipRevision >= 0x30) ) { /* for 630S0 */ + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x18,0xFE); + } + } + } +} - /* TW: Save ModeNo so we can set it from within SetMode for CRT1 */ - pSiSEnt->CRT2ModeNo = ModeNo; - pSiSEnt->CRT2DMode = mode; - - /* TW: We can't set CRT2 mode before CRT1 mode is set */ - if(pSiSEnt->CRT1ModeNo == -1) { - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting CRT2 mode delayed until after setting CRT1 mode\n"); - return TRUE; - } +/*********************************************/ +/* ATT */ +/*********************************************/ - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting mode 0x%x on CRT2\n", ModeNo); +static void +SiS_SetATTRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, + PSIS_HW_INFO HwInfo) +{ + UCHAR ARdata; + USHORT i; - /* 1.Openkey */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); + for(i = 0; i <= 0x13; i++) { + ARdata = SiS_Pr->SiS_StandTable[StandTableIndex].ATTR[i]; +#if 0 + if((i <= 0x0f) || (i == 0x11)) { + if(ds:489 & 0x08) { + continue; + } + } +#endif + if(i == 0x13) { + /* Pixel shift. If screen on LCD or TV is shifted left or right, + * this might be the cause. + */ + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ARdata=0; + } + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0; + } + } + } + if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0; + } + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(HwInfo->jChipType >= SIS_315H) { + if(IS_SIS550650740660) { + /* 315, 330 don't do this */ + if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0; + } else { + ARdata = 0; + } + } + } else { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0; + } + } + } + SiS_GetRegByte(SiS_Pr->SiS_P3da); /* reset 3da */ + SiS_SetRegByte(SiS_Pr->SiS_P3c0,i); /* set index */ + SiS_SetRegByte(SiS_Pr->SiS_P3c0,ARdata); /* set data */ + } + SiS_GetRegByte(SiS_Pr->SiS_P3da); /* reset 3da */ + SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x14); /* set index */ + SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x00); /* set data */ + + SiS_GetRegByte(SiS_Pr->SiS_P3da); + SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x20); /* Enable Attribute */ + SiS_GetRegByte(SiS_Pr->SiS_P3da); +} + +/*********************************************/ +/* GRC */ +/*********************************************/ - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); +static void +SiS_SetGRCRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex) +{ + UCHAR GRdata; + USHORT i; - /* 2.Get ModeID */ - temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&ModeNo,&ModeIdIndex); - if(temp == 0) return(0); + for(i = 0; i <= 0x08; i++) { + GRdata = SiS_Pr->SiS_StandTable[StandTableIndex].GRC[i]; + SiS_SetReg(SiS_Pr->SiS_P3ce,i,GRdata); + } - /* TW: Determine VBType (301,301B,301LV,302B,302LV) */ - SiS_GetVBType(SiS_Pr, BaseAddr,HwDeviceExtension); + if(SiS_Pr->SiS_ModeType > ModeVGA) { + /* 256 color disable */ + SiS_SetRegAND(SiS_Pr->SiS_P3ce,0x05,0xBF); + } +} - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr); - if(HwDeviceExtension->jChipType < SIS_330) { - if(ROMAddr && SiS_Pr->SiS_UseROM) { - temp = ROMAddr[VB310Data_1_2_Offset]; - temp |= 0x40; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x02,temp); - } - } - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10); +/*********************************************/ +/* CLEAR EXTENDED REGISTERS */ +/*********************************************/ - SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x02,0x0c); +static void +SiS_ClearExt1Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT i; - backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - } else { - backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35); - } - } + for(i = 0x0A; i <= 0x0E; i++) { + SiS_SetReg(SiS_Pr->SiS_P3c4,i,0x00); + } + + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x37,0xFE); + } +} - /* TW: Get VB information (connectors, connected devices) */ - SiS_GetVBInfo(SiS_Pr, BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,1); - SiS_SetHiVision(SiS_Pr, BaseAddr,HwDeviceExtension); - SiS_GetLCDResInfo(SiS_Pr, ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); +/*********************************************/ +/* RESET VCLK */ +/*********************************************/ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08) { - if(ModeNo != 0x10) SiS_Pr->SiS_SetFlag |= SetDOSMode; - } +static void +SiS_ResetCRT1VCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + if(HwInfo->jChipType >= SIS_315H) { + if(HwInfo->jChipType < SIS_661) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 0) return; + } + } else { + if((SiS_Pr->SiS_IF_DEF_LVDS == 0) && + (!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) { + return; } } - /* Set mode on CRT2 */ - switch (HwDeviceExtension->ujVBChipID) { - case VB_CHIP_301: - case VB_CHIP_301B: - case VB_CHIP_301LV: - case VB_CHIP_302: - case VB_CHIP_302B: - case VB_CHIP_302LV: - SiS_SetCRT2Group301(SiS_Pr, BaseAddr,ROMAddr,ModeNo,HwDeviceExtension); - break; - case VB_CHIP_UNKNOWN: - if (SiS_Pr->SiS_IF_DEF_LVDS == 1 || - SiS_Pr->SiS_IF_DEF_CH70xx != 0 || - SiS_Pr->SiS_IF_DEF_TRUMPION != 0) { - SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension); - } - break; + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xCF,0x20); + } else { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x20); + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[1].SR2B); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[1].SR2C); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80); + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xcf,0x10); + } else { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x10); } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[0].SR2B); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[0].SR2C); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80); +} - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF); +/*********************************************/ +/* SYNC */ +/*********************************************/ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(!(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); - } - } - } +static void +SiS_SetCRT1Sync(SiS_Private *SiS_Pr, USHORT RefreshRateTableIndex) +{ + USHORT sync; - /* TW: New from 650/LV 1.10.6x and 1.10.7w, 630 2.06.50 */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); - } else { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); - } + if(SiS_Pr->UseCustomMode) { + sync = SiS_Pr->CInfoFlag >> 8; + } else { + sync = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; + } - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x38,backupreg); + sync &= 0xC0; + sync |= 0x2f; + SiS_SetRegByte(SiS_Pr->SiS_P3c2,sync); +} - tempr1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - tempr2 = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x00); - if(tempr1 & SetCRT2ToAVIDEO) tempr2 &= 0xF7; - if(tempr1 & SetCRT2ToSVIDEO) tempr2 &= 0xFB; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,tempr2); +/*********************************************/ +/* CRTC/2 */ +/*********************************************/ - if(tempr1 & SetCRT2ToLCD) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); - } - } else if((HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730)) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x35,backupreg); - } - } +#ifdef SIS315H +static void +SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, USHORT *ResIndex, + USHORT *DisplayType) + { + USHORT modeflag = 0; + + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + *ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + *ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + } - /* TW: SetPitch: Adapt to virtual size & position */ - SiS_SetPitchCRT2(SiS_Pr, pScrn, BaseAddr); + *ResIndex &= 0x3F; - return TRUE; -} -#endif /* Dualhead */ -#endif /* Linux_XF86 */ + *DisplayType = SiS_Pr->SiS_LCDResInfo; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) *DisplayType += 32; + if(modeflag & HalfDCLK) *DisplayType += 16; -#ifdef LINUX_XF86 -/* TW: We need pScrn for setting the pitch correctly */ -BOOLEAN -SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch) -#else -BOOLEAN -SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo) + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + *DisplayType = 100; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) *DisplayType += 2; + if(modeflag & HalfDCLK) *DisplayType += 1; + } + } else if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + *DisplayType = 104; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) *DisplayType += 2; + if(modeflag & HalfDCLK) *DisplayType += 1; + } + } + +} #endif -{ - ULONG temp; - USHORT ModeIdIndex,KeepLockReg; - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; - unsigned char backupreg=0, tempr1, tempr2; -#ifndef LINUX_XF86 - SiS_Pr->UseCustomMode = FALSE; - SiS_Pr->CRT1UsesCustomMode = FALSE; +static void +SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, + PSIS_HW_INFO HwInfo) +{ + UCHAR index; + USHORT temp,i,j,modeflag; +#ifdef SIS315H + USHORT ResIndex,DisplayType; + const SiS_LCDACRT1DataStruct *LCDACRT1Ptr = NULL; #endif - - if(SiS_Pr->UseCustomMode) { - ModeNo = 0xfe; - } - - SiSInitPtr(SiS_Pr, HwDeviceExtension); - SiSRegInit(SiS_Pr, BaseAddr); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /* unlock cr0-7 */ -#ifdef LINUX_XF86 - if(pScrn) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); - else -#endif - SiS_Pr->SiS_VGAINFO = 0x11; + if(SiS_Pr->UseCustomMode) { -#ifdef LINUX_XF86 -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "VGAInfo 0x%02x\n", SiS_Pr->SiS_VGAINFO); -#endif -#endif + modeflag = SiS_Pr->CModeFlag; - SiSInitPCIetc(SiS_Pr, HwDeviceExtension); + for(i=0,j=0;i<=07;i++,j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); + } + for(j=0x10;i<=10;i++,j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); + } + for(j=0x15;i<=12;i++,j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); + } + for(j=0x0A;i<=15;i++,j++) { + SiS_SetReg(SiS_Pr->SiS_P3c4,j,SiS_Pr->CCRT1CRTC[i]); + } - SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, ModeNo); + temp = SiS_Pr->CCRT1CRTC[16] & 0xE0; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp); - SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr); + temp = (SiS_Pr->CCRT1CRTC[16] & 0x01) << 5; + if(modeflag & DoubleScanMode) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,temp); - if(!SiS_Pr->UseCustomMode) { - /* TW: Shift the clear-buffer-bit away */ - ModeNo = ((ModeNo & 0x80) << 8) | (ModeNo & 0x7f); - } + } else { -#ifdef LINUX_XF86 - /* TW: We never clear the buffer in X */ - ModeNo |= 0x8000; -#endif + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } - if(ModeNo & 0x8000) { - ModeNo &= 0x7fff; - SiS_Pr->SiS_flag_clearbuffer = 0; - } else { - SiS_Pr->SiS_flag_clearbuffer = 1; - } + if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - /* 1.Openkey */ - KeepLockReg = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x05); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); +#ifdef SIS315H - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); + SiS_GetLCDACRT1Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, &ResIndex, &DisplayType); - if(!SiS_Pr->UseCustomMode) { - - /* 2.Get ModeID Table */ - temp = SiS_SearchModeID(SiS_Pr,ROMAddr,&ModeNo,&ModeIdIndex); - if(temp == 0) return(0); - - } else { - - ModeIdIndex = 0; - - } - - /* TW: Determine VBType (301,301B,301LV,302B,302LV) */ - SiS_GetVBType(SiS_Pr,BaseAddr,HwDeviceExtension); + switch(DisplayType) { + case Panel_1024x768 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1; break; + case Panel_1280x1024 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_1; break; + case Panel_1400x1050 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_1; break; + case Panel_1600x1200 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_1; break; + case Panel_1024x768 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1_H; break; + case Panel_1280x1024 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_1_H; break; + case Panel_1400x1050 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_1_H; break; + case Panel_1600x1200 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_1_H; break; + case Panel_1024x768 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_2; break; + case Panel_1280x1024 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2; break; + case Panel_1400x1050 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_2; break; + case Panel_1600x1200 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_2; break; + case Panel_1024x768 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_2_H; break; + case Panel_1280x1024 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2_H; break; + case Panel_1400x1050 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_2_H; break; + case Panel_1600x1200 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_2_H; break; + case 100: LCDACRT1Ptr = Compaq1280x1024_LCDACRT1_1; break; + case 101: LCDACRT1Ptr = Compaq1280x1024_LCDACRT1_1_H; break; + case 102: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2; break; + case 103: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2_H; break; + case 104: LCDACRT1Ptr = Clevo1024x768_LCDACRT1_1; break; + case 105: LCDACRT1Ptr = Clevo1024x768_LCDACRT1_1_H; break; + case 106: LCDACRT1Ptr = Clevo1024x768_LCDACRT1_2; break; + case 107: LCDACRT1Ptr = Clevo1024x768_LCDACRT1_2_H; break; + default: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1; break; + } - /* TW: Init/restore some VB registers */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr); - if(HwDeviceExtension->jChipType < SIS_330) { - if(ROMAddr && SiS_Pr->SiS_UseROM) { - temp = ROMAddr[VB310Data_1_2_Offset]; - temp |= 0x40; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x02,temp); - } - } - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10); + for(i=0, j=0; i<=0x07; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,i,(LCDACRT1Ptr+ResIndex)->CR[j]); + } + for(i=0x10, j=8; i<=0x12; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,i,(LCDACRT1Ptr+ResIndex)->CR[j]); + } + for(i=0x15, j=11; i<=0x16; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,i,(LCDACRT1Ptr+ResIndex)->CR[j]); + } + for(i=0x0A, j=13; i<=0x0C; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_P3c4,i,(LCDACRT1Ptr+ResIndex)->CR[j]); + } - SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x02,0x0c); + temp = (LCDACRT1Ptr+ResIndex)->CR[16] & 0xE0; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp); - backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - } else { - backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35); - } - } - - /* TW: Get VB information (connectors, connected devices) */ - SiS_GetVBInfo(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,1); - SiS_SetHiVision(SiS_Pr,BaseAddr,HwDeviceExtension); - SiS_GetLCDResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); + temp = ((LCDACRT1Ptr+ResIndex)->CR[16] & 0x01) << 5; + if(modeflag & DoubleScanMode) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,temp); - /* 3. Check memory size */ - temp = SiS_CheckMemorySize(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex); - if(!temp) return(0); +#endif - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08) { - if(ModeNo != 0x10) SiS_Pr->SiS_SetFlag |= SetDOSMode; - } - } + } else { - /* TW: New from 650/LV 1.10.6x; not in any BIOS for other chipsets */ - if(IS_SIS650) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); - } - } - } + index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; - /* TW: Set mode on CRT1 */ - if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) { - SiS_SetCRT1Group(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,BaseAddr); - } else { - if(!(SiS_Pr->SiS_VBInfo & SwitchToCRT2)) { - SiS_SetCRT1Group(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,BaseAddr); - } - } + for(i=0,j=0;i<=07;i++,j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]); + } + for(j=0x10;i<=10;i++,j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]); + } + for(j=0x15;i<=12;i++,j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]); + } + for(j=0x0A;i<=15;i++,j++) { + SiS_SetReg(SiS_Pr->SiS_P3c4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]); + } - /* TW: Set mode on CRT2 */ - if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2 | SetCRT2ToLCDA)) { - switch (HwDeviceExtension->ujVBChipID) { - case VB_CHIP_301: - case VB_CHIP_301B: - case VB_CHIP_301LV: - case VB_CHIP_302: - case VB_CHIP_302B: - case VB_CHIP_302LV: - SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension); - break; - case VB_CHIP_UNKNOWN: - if(SiS_Pr->SiS_IF_DEF_LVDS == 1 || - SiS_Pr->SiS_IF_DEF_CH70xx != 0 || - SiS_Pr->SiS_IF_DEF_TRUMPION != 0) - SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension); - break; - } - } - - SiS_HandleCRT1(SiS_Pr); - - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF); + temp = SiS_Pr->SiS_CRT1Table[index].CR[16] & 0xE0; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp); - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(!(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); - } - } - } + temp = ((SiS_Pr->SiS_CRT1Table[index].CR[16]) & 0x01) << 5; + if(modeflag & DoubleScanMode) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,temp); - /* TW: New from 650/LV 1.10.6x and 1.10.7w */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); - } else { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); - } + } + } - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x38,backupreg); + if(SiS_Pr->SiS_ModeType > ModeVGA) SiS_SetReg(SiS_Pr->SiS_P3d4,0x14,0x4F); +} - tempr1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - tempr2 = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x00); - if(tempr1 & SetCRT2ToAVIDEO) tempr2 &= 0xF7; - if(tempr1 & SetCRT2ToSVIDEO) tempr2 &= 0xFB; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,tempr2); +/*********************************************/ +/* OFFSET & PITCH */ +/*********************************************/ +/* (partly overruled by SetPitch() in XF86) */ +/*********************************************/ - if((IS_SIS650) && (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30) & 0xfc)) { - if((ModeNo == 0x03) || (ModeNo == 0x10)) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x80); - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x56,0x08); - } - } +static void +SiS_SetCRT1Offset(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT temp, DisplayUnit, infoflag; - if(tempr1 & SetCRT2ToLCD) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); - } - } else if((HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730)) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x35,backupreg); - } + if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; + } else { + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; } -#ifdef LINUX_XF86 - if(pScrn) { - /* TW: SetPitch: Adapt to virtual size & position */ - if((ModeNo > 0x13) && (dosetpitch)) { - SiS_SetPitch(SiS_Pr, pScrn, BaseAddr); - } + DisplayUnit = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); - /* Backup/Set ModeNo in BIOS scratch area */ - SiS_GetSetModeID(pScrn, ModeNo); - } -#endif + temp = (DisplayUnit >> 8) & 0x0f; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,temp); -#ifndef LINUX_XF86 /* TW: We never lock registers in XF86 */ - if(KeepLockReg == 0xA1) SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); - else SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x00); -#endif + temp = DisplayUnit & 0xFF; + SiS_SetReg(SiS_Pr->SiS_P3d4,0x13,temp); - return TRUE; -} + if(infoflag & InterlaceMode) DisplayUnit >>= 1; -void -SiS_SetEnableDstn(SiS_Private *SiS_Pr) /* TW: Called from sis_main.c */ -{ - /* For 550 dstn */ - SiS_Pr->SiS_IF_DEF_DSTN = 1; + DisplayUnit <<= 5; + temp = (DisplayUnit & 0xff00) >> 8; + if (DisplayUnit & 0xff) temp++; + temp++; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x10,temp); } -void -SiS_HandleCRT1(SiS_Private *SiS_Pr) +/*********************************************/ +/* VCLK */ +/*********************************************/ + +static void +SiS_SetCRT1VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) { - /* TW: We don't do this at all. There is a new - * CRT1-is-connected-at-boot-time logic in the 650 BIOS, which - * confuses our own. So just clear the bit and skip the rest. - */ + USHORT index=0, clka, clkb; - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x63,0xbf); + if(SiS_Pr->UseCustomMode) { + clka = SiS_Pr->CSR2B; + clkb = SiS_Pr->CSR2C; + } else { + index = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + clka = SiS_Pr->SiS_VBVCLKData[index].Part4_A; + clkb = SiS_Pr->SiS_VBVCLKData[index].Part4_B; + } else { + clka = SiS_Pr->SiS_VCLKData[index].SR2B; + clkb = SiS_Pr->SiS_VCLKData[index].SR2C; + } + } -#if 0 - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15) & 0x01)) - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x63,0x40); + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF); + } else { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x00); } -#endif -} -void -SiS_SetCRT1Group(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT ModeIdIndex,USHORT BaseAddr) -{ - USHORT StandTableIndex,RefreshRateTableIndex; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2B,clka); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,clkb); - SiS_Pr->SiS_CRT1Mode = ModeNo; - StandTableIndex = SiS_GetModePtr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex); - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2)) { - SiS_DisableBridge(SiS_Pr,HwDeviceExtension,BaseAddr); - } + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x01); + } else { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80); } +} - SiS_SetSeqRegs(SiS_Pr,ROMAddr,StandTableIndex); - SiS_SetMiscRegs(SiS_Pr,ROMAddr,StandTableIndex); - SiS_SetCRTCRegs(SiS_Pr,ROMAddr,HwDeviceExtension,StandTableIndex); - SiS_SetATTRegs(SiS_Pr,ROMAddr,StandTableIndex,HwDeviceExtension); - SiS_SetGRCRegs(SiS_Pr,ROMAddr,StandTableIndex); - SiS_ClearExt1Regs(SiS_Pr,HwDeviceExtension); - SiS_ResetCRT1VCLK(SiS_Pr,ROMAddr,HwDeviceExtension); - - SiS_Pr->SiS_SelectCRT2Rate = 0; - SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); - -#ifdef LINUX_XF86 - xf86DrvMsgVerb(0, X_PROBED, 3, "(init: VBType=0x%04x, VBInfo=0x%04x)\n", - SiS_Pr->SiS_VBType, SiS_Pr->SiS_VBInfo); -#endif - - if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - } - } - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - } - - RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); - - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - SiS_Pr->SiS_SetFlag &= ~ProgrammingCRT2; - } - - if(RefreshRateTableIndex != 0xFFFF) { - SiS_SetSync(SiS_Pr,ROMAddr,RefreshRateTableIndex); - SiS_SetCRT1CRTC(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwDeviceExtension); - SiS_SetCRT1Offset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwDeviceExtension); - SiS_SetCRT1VCLK(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,RefreshRateTableIndex); - } +/*********************************************/ +/* FIFO */ +/*********************************************/ #ifdef SIS300 - if(HwDeviceExtension->jChipType == SIS_300) { - SiS_SetCRT1FIFO_300(SiS_Pr,ROMAddr,ModeNo,HwDeviceExtension,RefreshRateTableIndex); - } - if((HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) || - (HwDeviceExtension->jChipType == SIS_540)) { - SiS_SetCRT1FIFO_630(SiS_Pr,ROMAddr,ModeNo,HwDeviceExtension,RefreshRateTableIndex); - } -#endif -#ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetCRT1FIFO_310(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); - } -#endif +static USHORT +SiS_DoCalcDelay(SiS_Private *SiS_Pr, USHORT MCLK, USHORT VCLK, USHORT colordepth, USHORT key) +{ + const UCHAR ThLowA[] = { 61, 3,52, 5,68, 7,100,11, + 43, 3,42, 5,54, 7, 78,11, + 34, 3,37, 5,47, 7, 67,11 }; - SiS_SetCRT1ModeRegs(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,RefreshRateTableIndex); + const UCHAR ThLowB[] = { 81, 4,72, 6,88, 8,120,12, + 55, 4,54, 6,66, 8, 90,12, + 42, 4,45, 6,55, 8, 75,12 }; - SiS_LoadDAC(SiS_Pr,HwDeviceExtension,ROMAddr,ModeNo,ModeIdIndex); + const UCHAR ThTiming[] = { 1, 2, 2, 3, 0, 1, 1, 2 }; -#ifndef LINUX_XF86 - if(SiS_Pr->SiS_flag_clearbuffer) { - SiS_ClearBuffer(SiS_Pr,HwDeviceExtension,ModeNo); - } -#endif + USHORT tempah, tempal, tempcl, tempbx, temp; + ULONG longtemp; - if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2 | SetCRT2ToLCDA))) { - SiS_LongWait(SiS_Pr); - SiS_DisplayOn(SiS_Pr); + tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x18); + tempah &= 0x62; + tempah >>= 1; + tempal = tempah; + tempah >>= 3; + tempal |= tempah; + tempal &= 0x07; + tempcl = ThTiming[tempal]; + tempbx = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16); + tempbx >>= 6; + tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + tempah >>= 4; + tempah &= 0x0c; + tempbx |= tempah; + tempbx <<= 1; + if(key == 0) { + tempal = ThLowA[tempbx + 1]; + tempal *= tempcl; + tempal += ThLowA[tempbx]; + } else { + tempal = ThLowB[tempbx + 1]; + tempal *= tempcl; + tempal += ThLowB[tempbx]; } + longtemp = tempal * VCLK * colordepth; + temp = longtemp % (MCLK * 16); + longtemp /= (MCLK * 16); + if(temp) longtemp++; + return((USHORT)longtemp); } -#ifdef LINUX_XF86 -void -SiS_SetPitch(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr) +static USHORT +SiS_CalcDelay(SiS_Private *SiS_Pr, USHORT VCLK, USHORT colordepth, USHORT MCLK) { - SISPtr pSiS = SISPTR(pScrn); + USHORT tempax, tempbx; - /* TW: We need to set pitch for CRT1 if bridge is in SlaveMode, too */ - if( (pSiS->VBFlags & DISPTYPE_DISP1) || - ( (pSiS->VBFlags & VB_VIDEOBRIDGE) && - ( ((pSiS->VGAEngine == SIS_300_VGA) && (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0xa0) == 0x20) || - ((pSiS->VGAEngine == SIS_315_VGA) && (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x50) == 0x10) ) ) ) { - SiS_SetPitchCRT1(SiS_Pr, pScrn, BaseAddr); - } - if (pSiS->VBFlags & DISPTYPE_DISP2) { - SiS_SetPitchCRT2(SiS_Pr, pScrn, BaseAddr); - } + tempbx = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 0); + tempax = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 1); + if(tempax < 4) tempax = 4; + tempax -= 4; + if(tempbx < tempax) tempbx = tempax; + return(tempbx); } -void -SiS_SetPitchCRT1(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr) +static void +SiS_SetCRT1FIFO_300(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo, + USHORT RefreshRateTableIndex) { - SISPtr pSiS = SISPTR(pScrn); - ULong HDisplay,temp; + USHORT ThresholdLow = 0; + USHORT index, VCLK, MCLK, colorth=0; + USHORT tempah, temp; - HDisplay = pSiS->scrnPitch / 8; - SiS_SetReg1(SiS_Pr->SiS_P3d4, 0x13, (HDisplay & 0xFF)); - temp = (SiS_GetReg1(SiS_Pr->SiS_P3c4, 0x0E) & 0xF0) | (HDisplay>>8); - SiS_SetReg1(SiS_Pr->SiS_P3c4, 0x0E, temp); -} + if(ModeNo > 0x13) { -void -SiS_SetPitchCRT2(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr) -{ - SISPtr pSiS = SISPTR(pScrn); - ULong HDisplay,temp; + if(SiS_Pr->UseCustomMode) { + VCLK = SiS_Pr->CSRClock; + } else { + index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + index &= 0x3F; + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ + } - HDisplay = pSiS->scrnPitch / 8; + switch (SiS_Pr->SiS_ModeType - ModeEGA) { /* Get half colordepth */ + case 0 : colorth = 1; break; + case 1 : colorth = 1; break; + case 2 : colorth = 2; break; + case 3 : colorth = 2; break; + case 4 : colorth = 3; break; + case 5 : colorth = 4; break; + } - /* Unlock CRT2 */ - if (pSiS->VGAEngine == SIS_315_VGA) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2F, 0x01); - else - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24, 0x01); + index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A); + index &= 0x07; + MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07, (HDisplay & 0xFF)); - temp = (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x09) & 0xF0) | ((HDisplay >> 8) & 0xFF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x09, temp); -} -#endif + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + tempah &= 0xc3; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3c,tempah); -void -SiS_GetVBType(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT flag=0, rev=0, nolcd=0; + do { + ThresholdLow = SiS_CalcDelay(SiS_Pr, VCLK, colorth, MCLK); + ThresholdLow++; + if(ThresholdLow < 0x13) break; + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x16,0xfc); + ThresholdLow = 0x13; + tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16); + tempah >>= 6; + if(!(tempah)) break; + tempah--; + tempah <<= 6; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3f,tempah); + } while(0); - SiS_Pr->SiS_VBType = 0; + } else ThresholdLow = 2; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) return; + /* Write CRT/CPU threshold low, CRT/Engine threshold high */ + temp = (ThresholdLow << 4) | 0x0f; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,temp); - flag = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00); + temp = (ThresholdLow & 0x10) << 1; + if(ModeNo > 0x13) temp |= 0x40; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0f,0x9f,temp); - /* TW: Illegal values not welcome... */ - if(flag > 3) return; + /* What is this? */ + SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09); - rev = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x01); + /* Write CRT/CPU threshold high */ + temp = ThresholdLow + 3; + if(temp > 0x0f) temp = 0x0f; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x09,temp); +} - if (flag >= 2) { - SiS_Pr->SiS_VBType = VB_SIS302B; - } else if (flag == 1) { - SiS_Pr->SiS_VBType = VB_SIS301; - if(rev >= 0xB0) { - SiS_Pr->SiS_VBType = VB_SIS301B; - /* Check if 30xB DH version (no LCD support, use Panel Link instead) */ - nolcd = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x23); - if(!(nolcd & 0x02)) SiS_Pr->SiS_VBType |= VB_NoLCD; - } - } - if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) { - if(rev >= 0xD0) { - SiS_Pr->SiS_VBType &= ~(VB_SIS301B | VB_SIS302B); - SiS_Pr->SiS_VBType |= VB_SIS301LV; - SiS_Pr->SiS_VBType &= ~(VB_NoLCD); - if(rev >= 0xE0) { - SiS_Pr->SiS_VBType &= ~(VB_SIS301LV); - SiS_Pr->SiS_VBType |= VB_SIS302LV; - } - } +static USHORT +SiS_CalcDelay2(SiS_Private *SiS_Pr, UCHAR key, PSIS_HW_INFO HwInfo) +{ + USHORT data,index; + const UCHAR LatencyFactor[] = { + 97, 88, 86, 79, 77, 00, /*; 64 bit BQ=2 */ + 00, 87, 85, 78, 76, 54, /*; 64 bit BQ=1 */ + 97, 88, 86, 79, 77, 00, /*; 128 bit BQ=2 */ + 00, 79, 77, 70, 68, 48, /*; 128 bit BQ=1 */ + 80, 72, 69, 63, 61, 00, /*; 64 bit BQ=2 */ + 00, 70, 68, 61, 59, 37, /*; 64 bit BQ=1 */ + 86, 77, 75, 68, 66, 00, /*; 128 bit BQ=2 */ + 00, 68, 66, 59, 57, 37 /*; 128 bit BQ=1 */ + }; + const UCHAR LatencyFactor730[] = { + 69, 63, 61, + 86, 79, 77, + 103, 96, 94, + 120,113,111, + 137,130,128, /* --- Table ends with this entry, data below */ + 137,130,128, /* to avoid using illegal values */ + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + 137,130,128, + }; + + if(HwInfo->jChipType == SIS_730) { + index = ((key & 0x0f) * 3) + ((key & 0xC0) >> 6); + data = LatencyFactor730[index]; + } else { + index = (key & 0xE0) >> 5; + if(key & 0x10) index +=6; + if(!(key & 0x01)) index += 24; + data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + if(data & 0x0080) index += 12; + data = LatencyFactor[index]; } + return(data); } -BOOLEAN -SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT *ModeNo,USHORT *ModeIdIndex) +static void +SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, USHORT ModeNo, + PSIS_HW_INFO HwInfo, + USHORT RefreshRateTableIndex) { - UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; - - if(*ModeNo <= 0x13) { + USHORT i,index,data,VCLK,MCLK,colorth=0; + ULONG B,eax,bl,data2; + USHORT ThresholdLow=0; + UCHAR FQBQData[]= { + 0x01,0x21,0x41,0x61,0x81, + 0x31,0x51,0x71,0x91,0xb1, + 0x00,0x20,0x40,0x60,0x80, + 0x30,0x50,0x70,0x90,0xb0, + 0xFF + }; + UCHAR FQBQData730[]= { + 0x34,0x74,0xb4, + 0x23,0x63,0xa3, + 0x12,0x52,0x92, + 0x01,0x41,0x81, + 0x00,0x40,0x80, + 0xff + }; - if((*ModeNo) <= 0x05) (*ModeNo) |= 0x01; + i=0; + if(ModeNo > 0x13) { + if(SiS_Pr->UseCustomMode) { + VCLK = SiS_Pr->CSRClock; + } else { + index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + index &= 0x3F; + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ + } - for(*ModeIdIndex = 0; ;(*ModeIdIndex)++) { - if(SiS_Pr->SiS_SModeIDTable[*ModeIdIndex].St_ModeID == (*ModeNo)) break; - if(SiS_Pr->SiS_SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF) return FALSE; - } + index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A); + index &= 0x07; + MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ - if(*ModeNo == 0x07) { - if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */ - /* else 350 lines */ - } - if(*ModeNo <= 0x03) { - if(!(VGAINFO & 0x80)) (*ModeIdIndex)++; - if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */ - /* else 350 lines */ - } - /* else 200 lines */ + data2 = SiS_Pr->SiS_ModeType - ModeEGA; /* Get half colordepth */ + switch (data2) { + case 0 : colorth = 1; break; + case 1 : colorth = 1; break; + case 2 : colorth = 2; break; + case 3 : colorth = 2; break; + case 4 : colorth = 3; break; + case 5 : colorth = 4; break; + } - } else { + if(HwInfo->jChipType == SIS_730) { - for(*ModeIdIndex = 0; ;(*ModeIdIndex)++) { - if(SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == (*ModeNo)) break; - if(SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF) return FALSE; - } + do { + B = SiS_CalcDelay2(SiS_Pr, FQBQData730[i], HwInfo) * VCLK * colorth; + bl = B / (MCLK * 16); - } - return TRUE; -} + if(B == bl * 16 * MCLK) { + bl = bl + 1; + } else { + bl = bl + 2; + } -/* For SiS 300 oem util: Search VBModeID */ -BOOLEAN -SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo) -{ - USHORT ModeIdIndex; - UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; - - if(*ModeNo <= 5) *ModeNo |= 1; - - for(ModeIdIndex=0; ; ModeIdIndex++) { - if(SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == *ModeNo) break; - if(SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == 0xFF) return FALSE; - } - - if(*ModeNo != 0x07) { - if(*ModeNo > 0x03) return ((BOOLEAN)ModeIdIndex); - if(VGAINFO & 0x80) return ((BOOLEAN)ModeIdIndex); - ModeIdIndex++; - } - if(VGAINFO & 0x10) ModeIdIndex++; /* 400 lines */ - /* else 350 lines */ - return ((BOOLEAN)ModeIdIndex); -} - -BOOLEAN -SiS_CheckMemorySize(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT ModeIdIndex) -{ - USHORT memorysize,modeflag; - ULONG temp; - - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - } - - memorysize = modeflag & MemoryInfoFlag; - memorysize >>= MemorySizeShift; /* Get required memory size */ - memorysize++; - - temp = GetDRAMSize(SiS_Pr, HwDeviceExtension); /* Get adapter memory size */ - temp /= (1024*1024); /* (in MB) */ - - if(temp < memorysize) return(FALSE); - else return(TRUE); -} - -UCHAR -SiS_GetModePtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) -{ - UCHAR index; - - if(ModeNo <= 0x13) { - index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_StTableIndex; - } else { - if(SiS_Pr->SiS_ModeType <= 0x02) index = 0x1B; /* 02 -> ModeEGA */ - else index = 0x0F; - } - return index; -} - -void -SiS_SetSeqRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex) -{ - UCHAR SRdata; - USHORT i; - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x00,0x03); /* Set SR0 */ - - SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[0]; - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SRdata |= 0x01; - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_VBType & VB_NoLCD) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SRdata |= 0x01; /* 8 dot clock */ - } - } - } - } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SRdata |= 0x01; /* 8 dot clock */ - } - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SRdata |= 0x01; /* 8 dot clock */ - } - } - } - - SRdata |= 0x20; /* screen off */ - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x01,SRdata); - - for(i = 2; i <= 4; i++) { - SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i-1]; - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,SRdata); - } -} - -void -SiS_SetMiscRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex) -{ - UCHAR Miscdata; - - Miscdata = SiS_Pr->SiS_StandTable[StandTableIndex].MISC; - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - Miscdata |= 0x0C; - } - } + if(bl > 0x13) { + if(FQBQData730[i+1] == 0xFF) { + ThresholdLow = 0x13; + break; + } + i++; + } else { + ThresholdLow = bl; + break; + } + } while(FQBQData730[i] != 0xFF); - SiS_SetReg3(SiS_Pr->SiS_P3c2,Miscdata); -} + } else { -void -SiS_SetCRTCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT StandTableIndex) -{ - UCHAR CRTCdata; - USHORT i; + do { + B = SiS_CalcDelay2(SiS_Pr, FQBQData[i], HwInfo) * VCLK * colorth; + bl = B / (MCLK * 16); - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /* Unlock CRTC */ + if(B == bl * 16 * MCLK) { + bl = bl + 1; + } else { + bl = bl + 2; + } - for(i = 0; i <= 0x18; i++) { - CRTCdata = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,CRTCdata); /* Set CRTC(3d4) */ - } - if( ( (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) ) && - (HwDeviceExtension->jChipRevision >= 0x30) ) { /* for 630S0 */ - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x18,0xFE); - } + if(bl > 0x13) { + if(FQBQData[i+1] == 0xFF) { + ThresholdLow = 0x13; + break; + } + i++; + } else { + ThresholdLow = bl; + break; + } + } while(FQBQData[i] != 0xFF); } } -} - -void -SiS_SetATTRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - UCHAR ARdata; - USHORT i; - - for(i = 0; i <= 0x13; i++) { - ARdata = SiS_Pr->SiS_StandTable[StandTableIndex].ATTR[i]; -#if 0 - if((i <= 0x0f) || (i == 0x11)) { - if(ds:489 & 0x08) { - continue; - } - } -#endif - if(i == 0x13) { - /* Pixel shift. If screen on LCD or TV is shifted left or right, - * this might be the cause. - */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ARdata=0; - } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0; - } - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(IS_SIS650740 || IS_SIS550) { - /* 315, 330 don't do this */ - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0; - } else { - ARdata = 0; - } - } - } else { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0; - } - } + else { + if(HwInfo->jChipType == SIS_730) { + } else { + i = 9; } - SiS_GetReg2(SiS_Pr->SiS_P3da); /* reset 3da */ - SiS_SetReg3(SiS_Pr->SiS_P3c0,i); /* set index */ - SiS_SetReg3(SiS_Pr->SiS_P3c0,ARdata); /* set data */ - } - SiS_GetReg2(SiS_Pr->SiS_P3da); /* reset 3da */ - SiS_SetReg3(SiS_Pr->SiS_P3c0,0x14); /* set index */ - SiS_SetReg3(SiS_Pr->SiS_P3c0,0x00); /* set data */ - - SiS_GetReg2(SiS_Pr->SiS_P3da); - SiS_SetReg3(SiS_Pr->SiS_P3c0,0x20); /* Enable Attribute */ - SiS_GetReg2(SiS_Pr->SiS_P3da); -} - -void -SiS_SetGRCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex) -{ - UCHAR GRdata; - USHORT i; - - for(i = 0; i <= 0x08; i++) { - GRdata = SiS_Pr->SiS_StandTable[StandTableIndex].GRC[i]; - SiS_SetReg1(SiS_Pr->SiS_P3ce,i,GRdata); /* Set GR(3ce) */ - } - - if(SiS_Pr->SiS_ModeType > ModeVGA) { - SiS_SetRegAND(SiS_Pr->SiS_P3ce,0x05,0xBF); /* 256 color disable */ - } -} - -void -SiS_ClearExt1Regs(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT i; - - for(i = 0x0A; i <= 0x0E; i++) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0x00); /* Clear SR0A-SR0E */ - } - - /* TW: 330, 650/LVDS/301LV, 740/LVDS */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x37,0xFE); + ThresholdLow = 0x02; } -} - -void -SiS_SetSync(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT RefreshRateTableIndex) -{ - USHORT sync; - USHORT temp; - - if(SiS_Pr->UseCustomMode) { - sync = SiS_Pr->CInfoFlag >> 8; - } else { - sync = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; - } - - sync &= 0xC0; - temp = 0x2F | sync; - SiS_SetReg3(SiS_Pr->SiS_P3c2,temp); /* Set Misc(3c2) */ -} - -void -SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - UCHAR index; - USHORT tempah,i,modeflag,j; -#ifdef SIS315H - USHORT temp; - USHORT ResInfo,DisplayType; - const SiS_LCDACRT1DataStruct *LCDACRT1Ptr = NULL; -#endif - - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /*unlock cr0-7 */ - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - } - - if((SiS_Pr->SiS_IF_DEF_LVDS == 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - -#ifdef SIS315H - - /* LCDA */ - - temp = SiS_GetLCDACRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,&ResInfo,&DisplayType); + /* Write foreground and background queue */ + if(HwInfo->jChipType == SIS_730) { - switch(DisplayType) { - case Panel_800x600 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT1800x600_1; break; - case Panel_1024x768 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1; break; - case Panel_1280x1024 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_1; break; - case Panel_1400x1050 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_1; break; - case Panel_1600x1200 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_1; break; - case Panel_800x600 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT1800x600_1_H; break; - case Panel_1024x768 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1_H; break; - case Panel_1280x1024 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_1_H; break; - case Panel_1400x1050 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_1_H; break; - case Panel_1600x1200 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_1_H; break; - case Panel_800x600 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT1800x600_2; break; - case Panel_1024x768 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_2; break; - case Panel_1280x1024 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2; break; - case Panel_1400x1050 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_2; break; - case Panel_1600x1200 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_2; break; - case Panel_800x600 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT1800x600_2_H; break; - case Panel_1024x768 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_2_H; break; - case Panel_1280x1024 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2_H; break; - case Panel_1400x1050 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_2_H; break; - case Panel_1600x1200 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_2_H; break; - default: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1; break; - } - - tempah = (LCDACRT1Ptr+ResInfo)->CR[0]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x00,tempah); - for(i=0x01,j=1;i<=0x07;i++,j++){ - tempah = (LCDACRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x10,j=8;i<=0x12;i++,j++){ - tempah = (LCDACRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x15,j=11;i<=0x16;i++,j++){ - tempah =(LCDACRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x0A,j=13;i<=0x0C;i++,j++){ - tempah = (LCDACRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,tempah); - } - - tempah = (LCDACRT1Ptr+ResInfo)->CR[16]; - tempah &= 0x0E0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x0E,tempah); - - tempah = (LCDACRT1Ptr+ResInfo)->CR[16]; - tempah &= 0x01; - tempah <<= 5; - if(modeflag & DoubleScanMode) tempah |= 0x080; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah); + data2 = FQBQData730[i]; + data2 = (data2 & 0xC0) >> 5; + data2 <<= 8; +#ifndef LINUX_XF86 + SiS_SetRegLong(0xcf8,0x80000050); + eax = SiS_GetRegLong(0xcfc); + eax &= 0xfffff9ff; + eax |= data2; + SiS_SetRegLong(0xcfc,eax); +#else + /* We use pci functions X offers. We use pcitag 0, because + * we want to read/write to the host bridge (which is always + * 00:00.0 on 630, 730 and 540), not the VGA device. + */ + eax = pciReadLong(0x00000000, 0x50); + eax &= 0xfffff9ff; + eax |= data2; + pciWriteLong(0x00000000, 0x50, eax); #endif - } else { - - /* LVDS, 301, 301B, 301LV, 302LV, ... (non-LCDA) */ - - if(SiS_Pr->UseCustomMode) { - - for(i=0,j=0;i<=07;i++,j++) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); - } - for(j=0x10;i<=10;i++,j++) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); - } - for(j=0x15;i<=12;i++,j++) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); - } - for(j=0x0A;i<=15;i++,j++) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,j,SiS_Pr->CCRT1CRTC[i]); - } - - tempah = SiS_Pr->CCRT1CRTC[16] & 0xE0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x0E,tempah); + /* Write GUI grant timer (PCI config 0xA3) */ + data2 = FQBQData730[i] << 8; + data2 = (data2 & 0x0f00) | ((data2 & 0x3000) >> 8); + data2 <<= 20; - tempah = SiS_Pr->CCRT1CRTC[16]; - tempah &= 0x01; - tempah <<= 5; - if(modeflag & DoubleScanMode) tempah |= 0x80; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,tempah); - - - } else { - - index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */ -#if 0 /* Not any longer... */ - if(HwDeviceExtension->jChipType < SIS_315H) { - index &= 0x3F; - } +#ifndef LINUX_XF86 + SiS_SetRegLong(0xcf8,0x800000A0); + eax = SiS_GetRegLong(0xcfc); + eax &= 0x00ffffff; + eax |= data2; + SiS_SetRegLong(0xcfc,eax); +#else + eax = pciReadLong(0x00000000, 0xA0); + eax &= 0x00ffffff; + eax |= data2; + pciWriteLong(0x00000000, 0xA0, eax); #endif - for(i=0,j=0;i<=07;i++,j++) { - tempah=SiS_Pr->SiS_CRT1Table[index].CR[i]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,j,tempah); - } - for(j=0x10;i<=10;i++,j++) { - tempah=SiS_Pr->SiS_CRT1Table[index].CR[i]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,j,tempah); - } - for(j=0x15;i<=12;i++,j++) { - tempah=SiS_Pr->SiS_CRT1Table[index].CR[i]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,j,tempah); - } - for(j=0x0A;i<=15;i++,j++) { - tempah=SiS_Pr->SiS_CRT1Table[index].CR[i]; - SiS_SetReg1(SiS_Pr->SiS_P3c4,j,tempah); - } - - tempah = SiS_Pr->SiS_CRT1Table[index].CR[16]; - tempah &= 0xE0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x0E,tempah); + } else { - tempah = SiS_Pr->SiS_CRT1Table[index].CR[16]; - tempah &= 0x01; - tempah <<= 5; - if(modeflag & DoubleScanMode) tempah |= 0x80; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,tempah); + data2 = FQBQData[i]; + data2 = (data2 & 0xf0) >> 4; + data2 <<= 24; - } - } +#ifndef LINUX_XF86 + SiS_SetRegLong(0xcf8,0x80000050); + eax = SiS_GetRegLong(0xcfc); + eax &= 0xf0ffffff; + eax |= data2; + SiS_SetRegLong(0xcfc,eax); +#else + eax = pciReadLong(0x00000000, 0x50); + eax &= 0xf0ffffff; + eax |= data2; + pciWriteLong(0x00000000, 0x50, eax); +#endif - if(SiS_Pr->SiS_ModeType > ModeVGA) SiS_SetReg1(SiS_Pr->SiS_P3d4,0x14,0x4F); -} + /* Write GUI grant timer (PCI config 0xA3) */ + data2 = FQBQData[i]; + data2 &= 0x0f; + data2 <<= 24; -BOOLEAN -SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *ResInfo, - USHORT *DisplayType) - { - USHORT tempbx=0,modeflag=0; - USHORT CRT2CRTC=0; +#ifndef LINUX_XF86 + SiS_SetRegLong(0xcf8,0x800000A0); + eax = SiS_GetRegLong(0xcfc); + eax &= 0xf0ffffff; + eax |= data2; + SiS_SetRegLong(0xcfc,eax); +#else + eax = pciReadLong(0x00000000, 0xA0); + eax &= 0xf0ffffff; + eax |= data2; + pciWriteLong(0x00000000, 0xA0, eax); +#endif - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - CRT2CRTC = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - CRT2CRTC = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; } - tempbx = SiS_Pr->SiS_LCDResInfo; + /* Write CRT/CPU threshold low, CRT/Engine threshold high */ + data = ((ThresholdLow & 0x0f) << 4) | 0x0f; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,data); - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 32; - if(modeflag & HalfDCLK) tempbx += 16; + data = (ThresholdLow & 0x10) << 1; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xDF,data); - *ResInfo = CRT2CRTC & 0x3F; - *DisplayType = tempbx; + /* What is this? */ + SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09); - return 1; + /* Write CRT/CPU threshold high (gap = 3) */ + data = ThresholdLow + 3; + if(data > 0x0f) data = 0x0f; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x09,0x80,data); } +#endif -/* TW: Set offset and pitch - partly overruled by SetPitch() in XF86 */ -void -SiS_SetCRT1Offset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +#ifdef SIS315H +static void +SiS_SetCRT1FIFO_310(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { - USHORT temp, DisplayUnit, infoflag; - - if(SiS_Pr->UseCustomMode) { - infoflag = SiS_Pr->CInfoFlag; - } else { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - } - - DisplayUnit = SiS_GetOffset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - - temp = (DisplayUnit >> 8) & 0x0f; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,temp); + USHORT modeflag; - temp = DisplayUnit & 0xFF; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x13,temp); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x3D,0xFE); /* disable auto-threshold */ - if(infoflag & InterlaceMode) DisplayUnit >>= 1; + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } - DisplayUnit <<= 5; - temp = (DisplayUnit & 0xff00) >> 8; - if (DisplayUnit & 0xff) temp++; - temp++; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x10,temp); + if(HwInfo->jChipType >= SIS_661) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); + if(ModeNo > 0x13) { + if(!(modeflag & HalfDCLK)) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); + if(ModeNo != 0x38) { + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); + } + } + } + } else { + if(ModeNo > 0x13) { + if( (!(modeflag & DoubleScanMode)) || (!(modeflag & HalfDCLK))) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); + } else { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); + } + } else { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); + } + } } +#endif -/* TW: New from 650/LVDS 1.10.07, 630/301B and 630/LVDS BIOS */ -void -SiS_ResetCRT1VCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT index; - - /* TW: We only need to do this if Panel Link is to be - * initialized, thus on 630/LVDS/301BDH, and 650/LVDS - */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) return; - } else { - if( (SiS_Pr->SiS_IF_DEF_LVDS == 0) && - (!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) { - return; - } - } - - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xCF,0x20); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x20); - } - index = 1; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[index].SR2B); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[index].SR2C); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80); - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xcf,0x10); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x10); - } - index = 0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[index].SR2B); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[index].SR2C); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80); -} +/*********************************************/ +/* MODE REGISTERS */ +/*********************************************/ -void -SiS_SetCRT1VCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT RefreshRateTableIndex) +static void +SiS_SetVCLKState(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT RefreshRateTableIndex, + USHORT ModeIdIndex) { - USHORT index=0; - - if(!SiS_Pr->UseCustomMode) { - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - } - - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ){ + USHORT data, data2=0; + USHORT VCLK, index=0; - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF); + if(ModeNo <= 0x13) VCLK = 0; + else { + if(SiS_Pr->UseCustomMode) { + VCLK = SiS_Pr->CSRClock; + } else { + index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; + } + } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VBVCLKData[index].Part4_A); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VBVCLKData[index].Part4_B); + if(HwInfo->jChipType < SIS_315H) { /* 300 series */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x01); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80); - } + data2 = 0x00; + if(VCLK > 150) data2 |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data2); - } else { + data2 = 0x00; + if(VCLK >= 150) data2 |= 0x08; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data2); - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x00); - } + } else { /* 315 series */ - if(SiS_Pr->UseCustomMode) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->CSR2B); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->CSR2C); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[index].SR2B); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[index].SR2C); - } + data = 0; + if(VCLK >= 166) data |= 0x0c; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x01); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80); - } + if(VCLK >= 166) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1f,0xe7); + } } -} -#if 0 /* TW: Not used */ -void -SiS_IsLowResolution(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) -{ - USHORT ModeFlag; + data2 = 0x03; + if((VCLK >= 135) && (VCLK < 160)) data2 = 0x02; + else if((VCLK >= 160) && (VCLK < 260)) data2 = 0x01; + else if(VCLK >= 260) data2 = 0x00; - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0x7F); + if(HwInfo->jChipType == SIS_540) { + if((VCLK == 203) || (VCLK < 234)) data2 = 0x02; + } - if(ModeNo > 0x13) { - ModeFlag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) { - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x80); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x01,0xF7); - } + if(HwInfo->jChipType < SIS_315H) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xFC,data2); /* DAC speed */ + } else { + if(HwInfo->jChipType > SIS_315PRO) { + /* This "if" is done in 330 and 650/LVDS/301LV BIOSes; Not in 315 BIOS */ + if(ModeNo > 0x13) data2 &= 0xfc; + } + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xF8,data2); /* DAC speed */ } } -#endif -void -SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, +static void +SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex) { - USHORT data,data2,data3; + USHORT data,data2; USHORT infoflag=0,modeflag; USHORT resindex,xres; +#ifdef SIS315H + USHORT data3; + ULONG longdata; +#if 0 + resinfo = 0; +#endif +#endif if(SiS_Pr->UseCustomMode) { modeflag = SiS_Pr->CModeFlag; @@ -3478,35 +3040,42 @@ SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, if(ModeNo > 0x13) { modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; +#ifdef SIS315H +#if 0 + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; +#endif +#endif } else { modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; } } - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1F,0x3F); /* DAC pedestal */ + /* Disable DPMS */ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1F,0x3F); if(ModeNo > 0x13) data = infoflag; else data = 0; data2 = 0; if(ModeNo > 0x13) { - if(SiS_Pr->SiS_ModeType > 0x02) { - data2 |= 0x02; - data3 = (SiS_Pr->SiS_ModeType - ModeVGA) << 2; - data2 |= data3; - } + if(SiS_Pr->SiS_ModeType > 0x02) { + data2 |= 0x02; + data2 |= ((SiS_Pr->SiS_ModeType - ModeVGA) << 2); + } } + #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "Debug: Mode infoflag = %x, Chiptype %d\n", - data, HwDeviceExtension->jChipType); -#endif + xf86DrvMsg(0, X_INFO, "Debug: Mode infoflag = %x, Chiptype %d\n", + data, HwInfo->jChipType); +#endif + if(data & InterlaceMode) data2 |= 0x20; SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x06,0xC0,data2); if(SiS_Pr->UseCustomMode) { xres = SiS_Pr->CHDisplay; } else { - resindex = SiS_GetResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex); + resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex); if(ModeNo <= 0x13) { xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; } else { @@ -3514,44 +3083,33 @@ SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, } } - if(HwDeviceExtension->jChipType != SIS_300) { + if(HwInfo->jChipType != SIS_300) { data = 0x0000; if(infoflag & InterlaceMode) { - if(xres == 1024) data = 0x0035; + if(xres <= 800) data = 0x0020; + else if(xres <= 1024) data = 0x0035; else data = 0x0048; } - data2 = data & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x19,data2); - data2 = (data & 0xFF00) >> 8; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x1a,0xFC,data2); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x19,(data & 0x00FF)); + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x1a,0xFC,(data >> 8)); } if(modeflag & HalfDCLK) { SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x08); } - if(HwDeviceExtension->jChipType == SIS_300) { + if(HwInfo->jChipType == SIS_300) { if(modeflag & LineCompareOff) { SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x08); } else { SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xF7); } - } else if(HwDeviceExtension->jChipType < SIS_315H) { - if(modeflag & LineCompareOff) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,0x08); - } else { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xB7); - } - /* 630 BIOS does something for mode 0x12 here */ } else { if(modeflag & LineCompareOff) { SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,0x08); } else { SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xB7); } - } - - if(HwDeviceExtension->jChipType != SIS_300) { if(SiS_Pr->SiS_ModeType == ModeEGA) { if(ModeNo > 0x13) { SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x40); @@ -3560,1434 +3118,1184 @@ SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, } #ifdef SIS315H - /* TW: 315 BIOS sets SR17 at this point */ - if(HwDeviceExtension->jChipType == SIS_315PRO) { - data = SiS_Get310DRAMType(SiS_Pr,ROMAddr,HwDeviceExtension); - data = SiS_Pr->SiS_SR15[2][data]; - if(SiS_Pr->SiS_ModeType == ModeText) { - data &= 0xc7; - } else { - data2 = SiS_GetOffset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - data2 >>= 1; - if(infoflag & InterlaceMode) data2 >>= 1; - data3 = SiS_GetColorDepth(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex); - data3 >>= 1; - if(data3 == 0) data3++; - data2 /= data3; - if(data2 >= 0x50) { - data &= 0x0f; - data |= 0x50; - } - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,data); + /* 315 BIOS sets SR17 at this point */ + if(HwInfo->jChipType == SIS_315PRO) { + data = SiS_Get310DRAMType(SiS_Pr, HwInfo); + data = SiS_Pr->SiS_SR15[2][data]; + if(SiS_Pr->SiS_ModeType == ModeText) { + data &= 0xc7; + } else { + data2 = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + data2 >>= 1; + if(infoflag & InterlaceMode) data2 >>= 1; + data3 = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex) >> 1; + if(!data3) data3++; + data2 /= data3; + if(data2 >= 0x50) { + data &= 0x0f; + data |= 0x50; + } + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x17,data); } - /* TW: 330 BIOS sets SR17 at this point */ - if(HwDeviceExtension->jChipType == SIS_330) { - data = SiS_Get310DRAMType(SiS_Pr,ROMAddr,HwDeviceExtension); - data = SiS_Pr->SiS_SR15[2][data]; - if(SiS_Pr->SiS_ModeType <= ModeEGA) { - data &= 0xc7; - } else { - if(SiS_Pr->UseCustomMode) { - data2 = SiS_Pr->CSRClock; - } else { - data2 = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - data2 = SiS_Pr->SiS_VCLKData[data2].CLOCK; - } + /* 330 BIOS sets SR17 at this point */ + if(HwInfo->jChipType == SIS_330) { + data = SiS_Get310DRAMType(SiS_Pr, HwInfo); + data = SiS_Pr->SiS_SR15[2][data]; + if(SiS_Pr->SiS_ModeType <= ModeEGA) { + data &= 0xc7; + } else { + if(SiS_Pr->UseCustomMode) { + data2 = SiS_Pr->CSRClock; + } else { + data2 = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + data2 = SiS_Pr->SiS_VCLKData[data2].CLOCK; + } - data3 = SiS_GetColorDepth(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex); - data3 >>= 1; + data3 = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex) >> 1; + if(!data3) data3++; - data2 *= data3; + data2 *= data3; - data3 = SiS_GetMCLK(SiS_Pr,ROMAddr, HwDeviceExtension); - data3 *= 1024; + longdata = SiS_GetMCLK(SiS_Pr, HwInfo) * 1024; - data2 = data3 / data2; - - if(SiS_Pr->SiS_ModeType != Mode16Bpp) { - if(data2 >= 0x19c) data = 0xba; - else if(data2 >= 0x140) data = 0x7a; - else if(data2 >= 0x101) data = 0x3a; - else if(data2 >= 0xf5) data = 0x32; - else if(data2 >= 0xe2) data = 0x2a; - else if(data2 >= 0xc4) data = 0x22; - else if(data2 >= 0xac) data = 0x1a; - else if(data2 >= 0x9e) data = 0x12; - else if(data2 >= 0x8e) data = 0x0a; - else data = 0x02; - } else { - if(data2 >= 0x127) data = 0xba; - else data = 0x7a; - } + data2 = longdata / data2; + + if(SiS_Pr->SiS_ModeType != Mode16Bpp) { + if(data2 >= 0x19c) data = 0xba; + else if(data2 >= 0x140) data = 0x7a; + else if(data2 >= 0x101) data = 0x3a; + else if(data2 >= 0xf5) data = 0x32; + else if(data2 >= 0xe2) data = 0x2a; + else if(data2 >= 0xc4) data = 0x22; + else if(data2 >= 0xac) data = 0x1a; + else if(data2 >= 0x9e) data = 0x12; + else if(data2 >= 0x8e) data = 0x0a; + else data = 0x02; + } else { + if(data2 >= 0x127) data = 0xba; + else data = 0x7a; + } } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,data); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x17,data); } #endif data = 0x60; if(SiS_Pr->SiS_ModeType != ModeText) { - data ^= 0x60; - if(SiS_Pr->SiS_ModeType != ModeEGA) { - data ^= 0xA0; - } + data ^= 0x60; + if(SiS_Pr->SiS_ModeType != ModeEGA) { + data ^= 0xA0; + } } SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x21,0x1F,data); - SiS_SetVCLKState(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,RefreshRateTableIndex,ModeIdIndex); + SiS_SetVCLKState(SiS_Pr, HwInfo, ModeNo, RefreshRateTableIndex, ModeIdIndex); #ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x40) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x52,0x2c); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x52,0x6c); - } - } -#endif -} - -void -SiS_SetVCLKState(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT RefreshRateTableIndex, - USHORT ModeIdIndex) -{ - USHORT data, data2=0; - USHORT VCLK, index=0; - - if (ModeNo <= 0x13) VCLK = 0; - else { - if(SiS_Pr->UseCustomMode) { - VCLK = SiS_Pr->CSRClock; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x2c); } else { - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; - } - } - - if(HwDeviceExtension->jChipType < SIS_315H) { /* 300 series */ - - data2 = 0x00; - if(VCLK > 150) data2 |= 0x80; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data2); /* DAC speed */ - - data2 = 0x00; - if(VCLK >= 150) data2 |= 0x08; /* VCLK > 150 */ - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data2); - - } else { /* 310/325 series */ - - data = 0; - if(VCLK >= 166) data |= 0x0c; /* TW: Was 200; is 166 in 650, 315 and 330 BIOSes */ - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); - - if(VCLK >= 166) { /* TW: Was 200, is 166 in 650, 315 and 330 BIOSes */ - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1f,0xe7); - } -#if 0 /* Not done in 315 and 650/301LV/LVDS BIOSes: */ - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1F); /* DAC pedestal */ - data &= 0xE7; - if(VCLK<200) data |= 0x10; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1F,data); /* DAC pedestal */ -#endif - } - - data2 = 0x03; - if((VCLK >= 135) && (VCLK < 160)) data2 = 0x02; - if((VCLK >= 160) && (VCLK < 260)) data2 = 0x01; - if(VCLK >= 260) data2 = 0x00; - - if(HwDeviceExtension->jChipType == SIS_540) { - if((VCLK == 203) || (VCLK < 234)) data2 = 0x02; - } - - if(HwDeviceExtension->jChipType < SIS_315H) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xFC,data2); /* DAC speed */ - } else { - if(HwDeviceExtension->jChipType > SIS_315PRO) { - /* TW: This "if" is done in 330 and 650/LVDS/301LV BIOSes; Not in 315 BIOS */ - if(ModeNo > 0x13) data2 &= 0xfc; - } - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xF8,data2); /* DAC speed */ - } -} - -void -SiS_LoadDAC(SiS_Private *SiS_Pr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) -{ - USHORT data,data2; - USHORT time,i,j,k; - USHORT m,n,o; - USHORT si,di,bx,dl; - USHORT al,ah,dh; - USHORT DACAddr, DACData, shiftflag; - const USHORT *table = NULL; -#if 0 - USHORT tempah,tempch,tempcl,tempdh,tempal,tempbx; -#endif - - if(ModeNo <= 0x13) { - data = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - if(SiS_Pr->UseCustomMode) { - data = SiS_Pr->CModeFlag; - } else { - data = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - } - -#if 0 - if(!(ds:489 & 0x08)) { -#endif - - data &= DACInfoFlag; - time = 64; - if(data == 0x00) table = SiS_MDA_DAC; - if(data == 0x08) table = SiS_CGA_DAC; - if(data == 0x10) table = SiS_EGA_DAC; - if(data == 0x18) { - time = 256; - table = SiS_VGA_DAC; - } - if(time == 256) j = 16; - else j = time; - - if( ( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && /* 301B-DH LCD */ - (SiS_Pr->SiS_VBType & VB_NoLCD) ) || - (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) || /* LCDA */ - (!(SiS_Pr->SiS_SetFlag & ProgrammingCRT2)) ) { /* Programming CRT1 */ - DACAddr = SiS_Pr->SiS_P3c8; - DACData = SiS_Pr->SiS_P3c9; - shiftflag = 0; - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF); - } else { - shiftflag = 1; - DACAddr = SiS_Pr->SiS_Part5Port; - DACData = SiS_Pr->SiS_Part5Port + 1; - } - - SiS_SetReg3(DACAddr,0x00); - - for(i=0; i>= 2; - } + SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x6c); + } +#if 0 /* What is SR0E[D5:6]? */ + if(HwInfo->jChipType >= SIS_661) { + data = 0; + if((ModeNo == 6) || ((ModeNo >= 0x0e) && (ModeNo <= 0x13))) { + data |= 0x20; } - - if(time == 256) { - for(i = 16; i < 32; i++) { - data = table[i]; - if(shiftflag) data <<= 2; - for(k=0; k<3; k++) SiS_SetReg3(DACData,data); + if(SiS_Pr->SiS_ModeType != ModeVGA) { + if(SiS_Pr->UseCustomMode) { + if((xres >= 640) && (SiS_Pr->CVDisplay >= 480)) { + data |= 0x40; + } + if((xres > 1280) && (SiS_Pr->CVDisplay > 1024)) { + data |= 0x60; + } } - si = 32; - for(m = 0; m < 9; m++) { - di = si; - bx = si + 4; - dl = 0; - for(n = 0; n < 3; n++) { - for(o = 0; o < 5; o++) { - dh = table[si]; - ah = table[di]; - al = table[bx]; - si++; - SiS_WriteDAC(SiS_Pr,DACData,shiftflag,dl,ah,al,dh); - } - si -= 2; - for(o = 0; o < 3; o++) { - dh = table[bx]; - ah = table[di]; - al = table[si]; - si--; - SiS_WriteDAC(SiS_Pr,DACData,shiftflag,dl,ah,al,dh); + } else if(ModeNo > 0x13) { /* These are in the CRT1 table, and set by CRT1CRTC */ + if(resinfo >= SIS_RI_640x480) { + if(resinfo <= SIS_RI_2048x1536) { + data |= 0x40; + if(resinfo > SIS_RI_1280x1024) { + data |= 0x60; + if(resinfo != SIS_RI_1600x1200) { + data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x0e); + data += 0x60; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0e); + data = 0; + } } - dl++; - } /* for n < 3 */ - si += 5; - } /* for m < 9 */ + } + if(resinfo == SIS_RI_1152x864) { + data = 0x40; + } + if(resinfo == SIS_RI_1400x1050) { /* TW */ + data = 0x60; + } + } } -#if 0 - } /* ds:489 & 0x08 */ + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0e,data); + } #endif + } +#endif +} + +/*********************************************/ +/* LOAD DAC */ +/*********************************************/ #if 0 - if((!(ds:489 & 0x08)) && (ds:489 & 0x06)) { - tempbx = 0; - for(i=0; i< 256; i++) { - SiS_SetReg3(SiS_Pr->SiS_P3c8-1,tempbx); /* 7f87 */ - tempah = SiS_GetReg3(SiS_Pr->SiS_P3c8+1); /* 7f83 */ - tempch = SiS_GetReg3(SiS_Pr->SiS_P3c8+1); - tempcl = SiS_GetReg3(SiS_Pr->SiS_P3c8+1); - tempdh = tempah; - tempal = 0x4d * tempdh; /* 7fb8 */ - tempbx += tempal; - tempal = 0x97 * tempch; - tempbx += tempal; - tempal = 0x1c * tempcl; - tempbx += tempal; - if((tempbx & 0x00ff) > 0x80) tempbx += 0x100; - tempdh = (tempbx & 0x00ff) >> 8; - tempch = tempdh; - tempcl = tempdh; - SiS_SetReg3(SiS_Pr->SiS_P3c8,(tempbx & 0xff)); /* 7f7c */ - SiS_SetReg3(SiS_Pr->SiS_P3c8+1,tempdh); /* 7f92 */ - SiS_SetReg3(SiS_Pr->SiS_P3c8+1,tempch); - SiS_SetReg3(SiS_Pr->SiS_P3c8+1,tempcl); - } - } -#endif +static void +SiS_ClearDAC(SiS_Private *SiS_Pr, ULONG port) +{ + int i; + + OutPortByte(port, 0); + port++; + for (i=0; i < (256 * 3); i++) { + OutPortByte(port, 0); + } } +#endif -void -SiS_WriteDAC(SiS_Private *SiS_Pr, USHORT DACData, USHORT shiftflag, +static void +SiS_WriteDAC(SiS_Private *SiS_Pr, SISIOADDRESS DACData, USHORT shiftflag, USHORT dl, USHORT ah, USHORT al, USHORT dh) { - USHORT temp; - USHORT bh,bl; + USHORT temp,bh,bl; bh = ah; bl = al; if(dl != 0) { - temp = bh; - bh = dh; - dh = temp; - if(dl == 1) { - temp = bl; - bl = dh; - dh = temp; - } else { - temp = bl; - bl = bh; - bh = temp; - } + temp = bh; + bh = dh; + dh = temp; + if(dl == 1) { + temp = bl; + bl = dh; + dh = temp; + } else { + temp = bl; + bl = bh; + bh = temp; + } } if(shiftflag) { dh <<= 2; bh <<= 2; bl <<= 2; } - SiS_SetReg3(DACData,(USHORT)dh); - SiS_SetReg3(DACData,(USHORT)bh); - SiS_SetReg3(DACData,(USHORT)bl); + SiS_SetRegByte(DACData,(USHORT)dh); + SiS_SetRegByte(DACData,(USHORT)bh); + SiS_SetRegByte(DACData,(USHORT)bl); } -static ULONG -GetDRAMSize(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +void +SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex) { - ULONG AdapterMemorySize = 0; -#ifdef SIS315H - USHORT counter; -#endif + USHORT data,data2; + USHORT time,i,j,k,m,n,o; + USHORT si,di,bx,dl,al,ah,dh; + USHORT shiftflag; + SISIOADDRESS DACAddr, DACData; + const USHORT *table = NULL; -#ifdef SIS315H - if ((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO)) { + if(ModeNo <= 0x13) { + data = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + if(SiS_Pr->UseCustomMode) { + data = SiS_Pr->CModeFlag; + } else { + data = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } + } - counter = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - AdapterMemorySize = 1 << ((counter & 0xF0) >> 4); - counter >>= 2; - counter &= 0x03; - if(counter == 0x02) { - AdapterMemorySize += (AdapterMemorySize / 2); /* DDR asymetric */ - } else if(counter != 0) { - AdapterMemorySize <<= 1; /* SINGLE_CHANNEL_2_RANK or DUAL_CHANNEL_1_RANK */ - } - AdapterMemorySize *= (1024*1024); + data &= DACInfoFlag; + time = 64; + if(data == 0x00) table = SiS_MDA_DAC; + if(data == 0x08) table = SiS_CGA_DAC; + if(data == 0x10) table = SiS_EGA_DAC; + if(data == 0x18) { + time = 256; + table = SiS_VGA_DAC; + } + if(time == 256) j = 16; + else j = time; + + if( ( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && /* 301B-DH LCD */ + (SiS_Pr->SiS_VBType & VB_NoLCD) ) || + (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) || /* LCDA */ + (!(SiS_Pr->SiS_SetFlag & ProgrammingCRT2)) ) { /* Programming CRT1 */ + DACAddr = SiS_Pr->SiS_P3c8; + DACData = SiS_Pr->SiS_P3c9; + shiftflag = 0; + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); + } else { + shiftflag = 1; + DACAddr = SiS_Pr->SiS_Part5Port; + DACData = SiS_Pr->SiS_Part5Port + 1; + } + + SiS_SetRegByte(DACAddr,0x00); + + for(i=0; i>= 2; + } + } - } else if(HwDeviceExtension->jChipType == SIS_330) { + if(time == 256) { + for(i = 16; i < 32; i++) { + data = table[i]; + if(shiftflag) data <<= 2; + for(k = 0; k < 3; k++) SiS_SetRegByte(DACData, data); + } + si = 32; + for(m = 0; m < 9; m++) { + di = si; + bx = si + 4; + dl = 0; + for(n = 0; n < 3; n++) { + for(o = 0; o < 5; o++) { + dh = table[si]; + ah = table[di]; + al = table[bx]; + si++; + SiS_WriteDAC(SiS_Pr, DACData, shiftflag, dl, ah, al, dh); + } + si -= 2; + for(o = 0; o < 3; o++) { + dh = table[bx]; + ah = table[di]; + al = table[si]; + si--; + SiS_WriteDAC(SiS_Pr, DACData, shiftflag, dl, ah, al, dh); + } + dl++; + } /* for n < 3 */ + si += 5; + } /* for m < 9 */ + } +} - counter = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - AdapterMemorySize = 1 << ((counter & 0xF0) >> 4); - counter &= 0x0c; - if(counter != 0) { - AdapterMemorySize <<= 1; - } - AdapterMemorySize *= (1024*1024); +/*********************************************/ +/* SET CRT1 REGISTER GROUP */ +/*********************************************/ - } else if((HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_650)) { +static void +SiS_SetCRT1Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex) +{ + USHORT StandTableIndex,RefreshRateTableIndex; - counter = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14) & 0x3F; - counter++; - AdapterMemorySize = counter * 4; - AdapterMemorySize *= (1024*1024); + SiS_Pr->SiS_CRT1Mode = ModeNo; + StandTableIndex = SiS_GetModePtr(SiS_Pr, ModeNo, ModeIdIndex); + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2)) { + SiS_DisableBridge(SiS_Pr, HwInfo); + } } + + SiS_ResetSegmentRegisters(SiS_Pr, HwInfo); + + SiS_SetSeqRegs(SiS_Pr, StandTableIndex, HwInfo); + SiS_SetMiscRegs(SiS_Pr, StandTableIndex, HwInfo); + SiS_SetCRTCRegs(SiS_Pr, HwInfo, StandTableIndex); + SiS_SetATTRegs(SiS_Pr, StandTableIndex, HwInfo); + SiS_SetGRCRegs(SiS_Pr, StandTableIndex); + SiS_ClearExt1Regs(SiS_Pr,HwInfo); + SiS_ResetCRT1VCLK(SiS_Pr, HwInfo); + + SiS_Pr->SiS_SelectCRT2Rate = 0; + SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); + +#ifdef LINUX_XF86 + xf86DrvMsgVerb(0, X_PROBED, 4, "(init: VBType=0x%04x, VBInfo=0x%04x)\n", + SiS_Pr->SiS_VBType, SiS_Pr->SiS_VBInfo); #endif -#ifdef SIS300 - if ((HwDeviceExtension->jChipType==SIS_300) || - (HwDeviceExtension->jChipType==SIS_540) || - (HwDeviceExtension->jChipType==SIS_630) || - (HwDeviceExtension->jChipType==SIS_730)) { + if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + } + } - AdapterMemorySize = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14) & 0x3F; - AdapterMemorySize++; - AdapterMemorySize *= (1024*1024); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + } + + RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + SiS_Pr->SiS_SetFlag &= ~ProgrammingCRT2; + } + + if(RefreshRateTableIndex != 0xFFFF) { + SiS_SetCRT1Sync(SiS_Pr, RefreshRateTableIndex); + SiS_SetCRT1CRTC(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetCRT1Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetCRT1VCLK(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + } +#ifdef SIS300 + if(HwInfo->jChipType == SIS_300) { + SiS_SetCRT1FIFO_300(SiS_Pr, ModeNo,HwInfo,RefreshRateTableIndex); + } else if((HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730) || + (HwInfo->jChipType == SIS_540)) { + SiS_SetCRT1FIFO_630(SiS_Pr, ModeNo, HwInfo, RefreshRateTableIndex); + } +#endif +#ifdef SIS315H + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetCRT1FIFO_310(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); } #endif - return AdapterMemorySize; -} + SiS_SetCRT1ModeRegs(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); -#ifndef LINUX_XF86 -void -SiS_ClearBuffer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo) -{ - PVOID VideoMemoryAddress = (PVOID)HwDeviceExtension->pjVideoMemoryAddress; - ULONG AdapterMemorySize = (ULONG)HwDeviceExtension->ulVideoMemorySize; - PUSHORT pBuffer; - int i; + SiS_LoadDAC(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); - if (SiS_Pr->SiS_ModeType>=ModeEGA) { - if(ModeNo > 0x13) { - AdapterMemorySize = GetDRAMSize(SiS_Pr, HwDeviceExtension); - SiS_SetMemory(VideoMemoryAddress,AdapterMemorySize,0); - } else { - pBuffer = VideoMemoryAddress; - for(i=0; i<0x4000; i++) - pBuffer[i] = 0x0000; - } - } else { - pBuffer = VideoMemoryAddress; - if (SiS_Pr->SiS_ModeType < ModeCGA) { - for(i=0; i<0x4000; i++) - pBuffer[i] = 0x0720; - } else { - SiS_SetMemory(VideoMemoryAddress,0x8000,0); - } +#ifndef LINUX_XF86 + if(SiS_Pr->SiS_flag_clearbuffer) { + SiS_ClearBuffer(SiS_Pr,HwInfo,ModeNo); } -} #endif -void -SiS_DisplayOn(SiS_Private *SiS_Pr) -{ - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x01,0xDF,0x00); -} - -void -SiS_DisplayOff(SiS_Private *SiS_Pr) -{ - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x01,0xDF,0x20); + if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA))) { + SiS_WaitRetrace1(SiS_Pr); + SiS_DisplayOn(SiS_Pr); + } } +/*********************************************/ +/* HELPER: ENABLE CRT1 */ +/*********************************************/ -/* ========================================== */ -/* SR CRTC GR */ -void -SiS_SetReg1(USHORT port, USHORT index, USHORT data) +static void +SiS_HandleCRT1(SiS_Private *SiS_Pr) { - OutPortByte(port,index); - OutPortByte(port+1,data); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,SiS_Pr->SiS_MyCR63,0xbf); +#if 0 + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x15) & 0x01)) { + if((SiS_GetReg(SiS_Pr->SiS_P3c4,0x15) & 0x0a) || + (SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x01)) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,SiS_Pr->SiS_MyCR63,0x40); + } + } +#endif } -/* ========================================== */ -/* AR(3C0) */ -void -SiS_SetReg2(SiS_Private *SiS_Pr, USHORT port, USHORT index, USHORT data) -{ - InPortByte(port+0x3da-0x3c0); - OutPortByte(SiS_Pr->SiS_P3c0,index); - OutPortByte(SiS_Pr->SiS_P3c0,data); - OutPortByte(SiS_Pr->SiS_P3c0,0x20); -} +/*********************************************/ +/* HELPER: SET VIDEO REGISTERS */ +/*********************************************/ -void -SiS_SetReg3(USHORT port, USHORT data) +static void +SiS_StrangeStuff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - OutPortByte(port,data); + if((IS_SIS651) || (IS_SISM650)) { + SiS_SetReg(SiS_Pr->SiS_VidCapt, 0x3f, 0x00); /* Fiddle with capture regs */ + SiS_SetReg(SiS_Pr->SiS_VidCapt, 0x00, 0x00); + SiS_SetReg(SiS_Pr->SiS_VidPlay, 0x00, 0x86); /* (BIOS does NOT unlock) */ + SiS_SetRegAND(SiS_Pr->SiS_VidPlay, 0x30, 0xfe); /* Fiddle with video regs */ + SiS_SetRegAND(SiS_Pr->SiS_VidPlay, 0x3f, 0xef); + } + /* !!! This does not support modes < 0x13 !!! */ } -void -SiS_SetReg4(USHORT port, ULONG data) -{ - OutPortLong(port,data); -} +/*********************************************/ +/* XFree86: SET SCREEN PITCH */ +/*********************************************/ -void -SiS_SetReg5(USHORT port, USHORT data) +#ifdef LINUX_XF86 +static void +SiS_SetPitchCRT1(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) { - OutPortWord(port,data); + SISPtr pSiS = SISPTR(pScrn); + UShort HDisplay = pSiS->scrnPitch >> 3; + + SiS_SetReg(SiS_Pr->SiS_P3d4,0x13,(HDisplay & 0xFF)); + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,(HDisplay>>8)); } -UCHAR SiS_GetReg1(USHORT port, USHORT index) +static void +SiS_SetPitchCRT2(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) { - UCHAR data; + SISPtr pSiS = SISPTR(pScrn); + UShort HDisplay = pSiS->scrnPitch2 >> 3; - OutPortByte(port,index); - data = InPortByte(port+1); + /* Unlock CRT2 */ + if(pSiS->VGAEngine == SIS_315_VGA) + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2F, 0x01); + else + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24, 0x01); - return(data); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(HDisplay & 0xFF)); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0xF0,(HDisplay >> 8)); } -UCHAR -SiS_GetReg2(USHORT port) +static void +SiS_SetPitch(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) { - UCHAR data; + SISPtr pSiS = SISPTR(pScrn); + BOOLEAN isslavemode = FALSE; - data= InPortByte(port); + if( (pSiS->VBFlags & VB_VIDEOBRIDGE) && + ( ((pSiS->VGAEngine == SIS_300_VGA) && + (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0xa0) == 0x20) || + ((pSiS->VGAEngine == SIS_315_VGA) && + (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x50) == 0x10) ) ) { + isslavemode = TRUE; + } - return(data); + /* We need to set pitch for CRT1 if bridge is in slave mode, too */ + if((pSiS->VBFlags & DISPTYPE_DISP1) || (isslavemode)) { + SiS_SetPitchCRT1(SiS_Pr, pScrn); + } + /* We must not set the pitch for CRT2 if bridge is in slave mode */ + if((pSiS->VBFlags & DISPTYPE_DISP2) && (!isslavemode)) { + SiS_SetPitchCRT2(SiS_Pr, pScrn); + } } +#endif -ULONG -SiS_GetReg3(USHORT port) +/*********************************************/ +/* SiSSetMode() */ +/*********************************************/ + +#ifdef LINUX_XF86 +/* We need pScrn for setting the pitch correctly */ +BOOLEAN +SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch) +#else +BOOLEAN +SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,USHORT ModeNo) +#endif { - ULONG data; + ULONG temp; + USHORT ModeIdIndex; + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + SISIOADDRESS BaseAddr = HwInfo->ulIOAddress; + unsigned char backupreg=0; +#ifndef LINUX_XF86 + USHORT KeepLockReg; - data = InPortLong(port); + SiS_Pr->UseCustomMode = FALSE; + SiS_Pr->CRT1UsesCustomMode = FALSE; +#endif - return(data); -} + if(SiS_Pr->UseCustomMode) { + ModeNo = 0xfe; + } -USHORT -SiS_GetReg4(USHORT port) -{ - ULONG data; + SiSInitPtr(SiS_Pr, HwInfo); + SiSRegInit(SiS_Pr, BaseAddr); + SiS_GetSysFlags(SiS_Pr, HwInfo); - data = InPortWord(port); +#ifdef LINUX_XF86 + if(pScrn) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); + else +#endif + SiS_Pr->SiS_VGAINFO = 0x11; - return(data); -} + SiSInitPCIetc(SiS_Pr, HwInfo); + SiSSetLVDSetc(SiS_Pr, HwInfo); + SiSDetermineROMUsage(SiS_Pr, HwInfo); -void -SiS_ClearDAC(SiS_Private *SiS_Pr, ULONG port) -{ - int i; + if(!SiS_Pr->UseCustomMode) { + ModeNo = ((ModeNo & 0x80) << 8) | (ModeNo & 0x7f); + } - OutPortByte(port, 0); - port++; - for (i=0; i < (256 * 3); i++) { - OutPortByte(port, 0); +#ifdef LINUX_XF86 + /* We never clear the buffer in X */ + ModeNo |= 0x8000; +#endif + + if(ModeNo & 0x8000) { + ModeNo &= 0x7fff; + SiS_Pr->SiS_flag_clearbuffer = 0; + } else { + SiS_Pr->SiS_flag_clearbuffer = 1; } -} +#ifndef LINUX_XF86 + KeepLockReg = SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); +#endif + SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); -#if 0 /* TW: Unused */ -void -SiS_SetInterlace(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT RefreshRateTableIndex) -{ - ULONG Temp; - USHORT data,Temp2; + SiS_UnLockCRT2(SiS_Pr, HwInfo); - if (ModeNo<=0x13) return; + if(!SiS_Pr->UseCustomMode) { + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; + } else { + ModeIdIndex = 0; + } - Temp = (ULONG)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x01); - Temp++; - Temp <<= 3; + SiS_GetVBType(SiS_Pr, HwInfo); - if(Temp == 1024) data = 0x0035; - else if(Temp == 1280) data = 0x0048; - else data = 0x0000; + /* Init/restore some VB registers */ + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + SiS_UnLockCRT2(SiS_Pr,HwInfo); + if(ROMAddr && SiS_Pr->SiS_UseROM) { + if(HwInfo->jChipType < SIS_330) { + temp = ROMAddr[VB310Data_1_2_Offset]; + temp |= 0x40; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); + } + if(HwInfo->jChipType > SIS_330) { + temp = ROMAddr[0x7e]; + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x7b) >= 100) temp |= 0x40; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); + } + } + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10); - Temp2 = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - Temp2 &= InterlaceMode; - if(Temp2 == 0) data=0x0000; + SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x00,0x0c); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x19,data); + backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + } else { + backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + } + } - Temp = (ULONG)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x1A); - Temp = (USHORT)(Temp & 0xFC); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x1A,(USHORT)Temp); + /* Get VB information (connectors, connected devices) */ + SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, (SiS_Pr->UseCustomMode) ? 0 : 1); + SiS_SetYPbPr(SiS_Pr, HwInfo); + SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_SetLowModeTest(SiS_Pr, ModeNo, HwInfo); - Temp = (ULONG)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x0f); - Temp2 = (USHORT)Temp & 0xBF; - if(ModeNo==0x37) Temp2 |= 0x40; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x1A,(USHORT)Temp2); -} +#ifndef LINUX_XF86 + /* 3. Check memory size (Kernel framebuffer driver only) */ + temp = SiS_CheckMemorySize(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + if(!temp) return(0); #endif -#ifdef SIS315H -void -SiS_SetCRT1FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT modeflag; + if(HwInfo->jChipType >= SIS_315H) { +#if 0 + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x08) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(ModeNo != 0x10) SiS_Pr->SiS_SetFlag |= SetDOSMode; + } else if((IS_SIS651) && (SiS_Pr->SiS_VBType & VB_NoLCD)) { + SiS_Pr->SiS_SetFlag |= SetDOSMode; + } + } +#endif - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x3D,0xFE); /* disable auto-threshold */ + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(IS_SIS650) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); + if(IS_SIS651) SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x20); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); + } else if(IS_SIS661741660760) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x3a,0xef); + } + } + } + + if(SiS_Pr->UseCustomMode) { + SiS_Pr->CRT1UsesCustomMode = TRUE; + SiS_Pr->CSRClock_CRT1 = SiS_Pr->CSRClock; + SiS_Pr->CModeFlag_CRT1 = SiS_Pr->CModeFlag; + } else { + SiS_Pr->CRT1UsesCustomMode = FALSE; + } + + /* Set mode on CRT1 */ + if( (SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) || + (!(SiS_Pr->SiS_VBInfo & SwitchCRT2)) ) { + SiS_SetCRT1Group(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + } + + /* Set mode on CRT2 */ + if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA)) { + if( (SiS_Pr->SiS_VBType & VB_SISVB) || + (SiS_Pr->SiS_IF_DEF_LVDS == 1) || + (SiS_Pr->SiS_IF_DEF_CH70xx != 0) || + (SiS_Pr->SiS_IF_DEF_TRUMPION != 0) ) { + SiS_SetCRT2Group(SiS_Pr, HwInfo, ModeNo); + } + } + + SiS_HandleCRT1(SiS_Pr); + + SiS_StrangeStuff(SiS_Pr, HwInfo); + + SiS_DisplayOn(SiS_Pr); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); + + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); + } + } + } + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + if(HwInfo->jChipType < SIS_661) { + if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); + } else { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); + } + } + + SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg); + + if((IS_SIS650) && (SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & 0xfc)) { + if((ModeNo == 0x03) || (ModeNo == 0x10)) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x80); + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x56,0x08); + } + } + + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); + } + } else if((HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730)) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg); + } + } + +#ifdef LINUX_XF86 + if(pScrn) { + /* SetPitch: Adapt to virtual size & position */ + if((ModeNo > 0x13) && (dosetpitch)) { + SiS_SetPitch(SiS_Pr, pScrn); + } - if(ModeNo > 0x13) { - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - if( (!(modeflag & DoubleScanMode)) || (!(modeflag & HalfDCLK))) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,0x34); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,0xAE); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); - } - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,0xAE); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); - } -} + /* Backup/Set ModeNo in BIOS scratch area */ + SiS_GetSetModeID(pScrn, ModeNo); + } #endif -#ifdef SIS300 -void -SiS_SetCRT1FIFO_300(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT RefreshRateTableIndex) -{ - USHORT ThresholdLow = 0; - USHORT index, VCLK, MCLK, colorth=0; - USHORT tempah, temp; +#ifndef LINUX_XF86 /* We never lock registers in XF86 */ + if(KeepLockReg == 0xA1) SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); + else SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x00); +#endif - if(ModeNo > 0x13) { + return TRUE; +} - if(SiS_Pr->UseCustomMode) { - VCLK = SiS_Pr->CSRClock; - } else { - index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - index &= 0x3F; - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ - } +/*********************************************/ +/* XFree86: SiSBIOSSetMode() */ +/* for non-Dual-Head mode */ +/*********************************************/ - switch (SiS_Pr->SiS_ModeType - ModeEGA) { /* Get half colordepth */ - case 0 : colorth = 1; break; - case 1 : colorth = 1; break; - case 2 : colorth = 2; break; - case 3 : colorth = 2; break; - case 4 : colorth = 3; break; - case 5 : colorth = 4; break; - } +#ifdef LINUX_XF86 +BOOLEAN +SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom) +{ + SISPtr pSiS = SISPTR(pScrn); + UShort ModeNo=0; - index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A); - index &= 0x07; - MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ + SiS_Pr->UseCustomMode = FALSE; - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35); - tempah &= 0xc3; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3c,tempah); + if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { - do { - ThresholdLow = SiS_CalcDelay(SiS_Pr, ROMAddr, VCLK, colorth, MCLK); - ThresholdLow++; - if(ThresholdLow < 0x13) break; - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x16,0xfc); - ThresholdLow = 0x13; - tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - tempah >>= 6; - if(!(tempah)) break; - tempah--; - tempah <<= 6; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3f,tempah); - } while(0); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting custom mode %dx%d\n", + SiS_Pr->CHDisplay, + (mode->Flags & V_INTERLACE ? SiS_Pr->CVDisplay * 2 : + (mode->Flags & V_DBLSCAN ? SiS_Pr->CVDisplay / 2 : + SiS_Pr->CVDisplay))); - } else ThresholdLow = 2; + return(SiSSetMode(SiS_Pr, HwInfo, pScrn, ModeNo, TRUE)); - /* Write CRT/CPU threshold low, CRT/Engine threshold high */ - temp = (ThresholdLow << 4) | 0x0f; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,temp); + } - temp = (ThresholdLow & 0x10) << 1; - if(ModeNo > 0x13) temp |= 0x40; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0f,0x9f,temp); + ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes); + if(!ModeNo) return FALSE; - /* What is this? */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x3B,0x09); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting standard mode 0x%x\n", ModeNo); - /* Write CRT/CPU threshold high */ - temp = ThresholdLow + 3; - if(temp > 0x0f) temp = 0x0f; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x09,temp); + return(SiSSetMode(SiS_Pr, HwInfo, pScrn, ModeNo, TRUE)); } -USHORT -SiS_CalcDelay(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT VCLK, USHORT colordepth, USHORT MCLK) +/*********************************************/ +/* XFree86: SiSBIOSSetModeCRT2() */ +/* for Dual-Head modes */ +/*********************************************/ +BOOLEAN +SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom) { - USHORT tempax, tempbx; + ULONG temp; + USHORT ModeIdIndex; + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + SISIOADDRESS BaseAddr = HwInfo->ulIOAddress; + UShort ModeNo = 0; + unsigned char backupreg=0; + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; +#endif - tempbx = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 0); - tempax = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 1); - if(tempax < 4) tempax = 4; - tempax -= 4; - if(tempbx < tempax) tempbx = tempax; - return(tempbx); -} + SiS_Pr->UseCustomMode = FALSE; -USHORT -SiS_DoCalcDelay(SiS_Private *SiS_Pr, USHORT MCLK, USHORT VCLK, USHORT colordepth, USHORT key) -{ - const UCHAR ThLowA[] = { 61, 3,52, 5,68, 7,100,11, - 43, 3,42, 5,54, 7, 78,11, - 34, 3,37, 5,47, 7, 67,11 }; + /* Remember: Custom modes for CRT2 are ONLY supported + * -) on 315/330 series, + * -) on the 30x/B/C, and + * -) if CRT2 is LCD or VGA + */ - const UCHAR ThLowB[] = { 81, 4,72, 6,88, 8,120,12, - 55, 4,54, 6,66, 8, 90,12, - 42, 4,45, 6,55, 8, 75,12 }; + if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { - const UCHAR ThTiming[] = { 1, 2, 2, 3, 0, 1, 1, 2 }; + ModeNo = 0xfe; - USHORT tempah, tempal, tempcl, tempbx, temp; - ULONG longtemp; + } else { - tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18); - tempah &= 0x62; - tempah >>= 1; - tempal = tempah; - tempah >>= 3; - tempal |= tempah; - tempal &= 0x07; - tempcl = ThTiming[tempal]; - tempbx = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - tempbx >>= 6; - tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - tempah >>= 4; - tempah &= 0x0c; - tempbx |= tempah; - tempbx <<= 1; - if(key == 0) { - tempal = ThLowA[tempbx + 1]; - tempal *= tempcl; - tempal += ThLowA[tempbx]; - } else { - tempal = ThLowB[tempbx + 1]; - tempal *= tempcl; - tempal += ThLowB[tempbx]; - } - longtemp = tempal * VCLK * colordepth; - temp = longtemp % (MCLK * 16); - longtemp /= (MCLK * 16); - if(temp) longtemp++; - return((USHORT)longtemp); -} + BOOLEAN havecustommodes = pSiS->HaveCustomModes; -#if 0 /* TW: Old fragment, unused */ -USHORT -SiS_CalcDelay(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT key) -{ - USHORT data,data2,temp0,temp1; - UCHAR ThLowA[]= {61,3,52,5,68,7,100,11, - 43,3,42,5,54,7, 78,11, - 34,3,37,5,47,7, 67,11}; - - UCHAR ThLowB[]= {81,4,72,6,88,8,120,12, - 55,4,54,6,66,8, 90,12, - 42,4,45,6,55,8, 75,12}; - - UCHAR ThTiming[]= {1,2,2,3,0,1,1,2}; - - data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - data=data>>6; - data2=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - data2=(data2>>4)&0x0C; - data=data|data2; - data=data<1; - if(key==0) { - temp0=(USHORT)ThLowA[data]; - temp1=(USHORT)ThLowA[data+1]; - } else { - temp0=(USHORT)ThLowB[data]; - temp1=(USHORT)ThLowB[data+1]; - } +#ifdef SISMERGED + if(pSiS->MergedFB) havecustommodes = pSiS->HaveCustomModes2; +#endif - data2=0; - data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18); - if(data&0x02) data2=data2|0x01; - if(data&0x20) data2=data2|0x02; - if(data&0x40) data2=data2|0x04; + ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, havecustommodes); + if(!ModeNo) return FALSE; - data=temp1*ThTiming[data2]+temp0; - return(data); -} + } + + SiSRegInit(SiS_Pr, BaseAddr); + SiSInitPtr(SiS_Pr, HwInfo); + SiS_GetSysFlags(SiS_Pr, HwInfo); + SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); + SiSInitPCIetc(SiS_Pr, HwInfo); + SiSSetLVDSetc(SiS_Pr, HwInfo); + SiSDetermineROMUsage(SiS_Pr, HwInfo); + + /* Save mode info so we can set it from within SetMode for CRT1 */ +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + pSiSEnt->CRT2ModeNo = ModeNo; + pSiSEnt->CRT2DMode = mode; + pSiSEnt->CRT2IsCustom = IsCustom; + pSiSEnt->CRT2CR30 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + pSiSEnt->CRT2CR31 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); + pSiSEnt->CRT2CR35 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + pSiSEnt->CRT2CR38 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); +#if 0 + /* We can't set CRT2 mode before CRT1 mode is set */ + if(pSiSEnt->CRT1ModeNo == -1) { + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting CRT2 mode delayed until after setting CRT1 mode\n"); + return TRUE; + } +#endif + pSiSEnt->CRT2ModeSet = TRUE; + } #endif -void -SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT RefreshRateTableIndex) -{ - USHORT i,index,data,VCLK,MCLK,colorth=0; - ULONG B,eax,bl,data2; - USHORT ThresholdLow=0; - UCHAR FQBQData[]= { - 0x01,0x21,0x41,0x61,0x81, - 0x31,0x51,0x71,0x91,0xb1, - 0x00,0x20,0x40,0x60,0x80, - 0x30,0x50,0x70,0x90,0xb0, - 0xFF - }; - UCHAR FQBQData730[]= { - 0x34,0x74,0xb4, - 0x23,0x63,0xa3, - 0x12,0x52,0x92, - 0x01,0x41,0x81, - 0x00,0x40,0x80, - 0xff - }; + /* We don't clear the buffer under X */ + SiS_Pr->SiS_flag_clearbuffer=0; - i=0; - if(ModeNo > 0x13) { - if(SiS_Pr->UseCustomMode) { - VCLK = SiS_Pr->CSRClock; - } else { - index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - index &= 0x3F; - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ - } + if(SiS_Pr->UseCustomMode) { - index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); - index &= 0x07; - MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ + USHORT temptemp = SiS_Pr->CVDisplay; - data2 = SiS_Pr->SiS_ModeType - ModeEGA; /* Get half colordepth */ - switch (data2) { - case 0 : colorth = 1; break; - case 1 : colorth = 1; break; - case 2 : colorth = 2; break; - case 3 : colorth = 2; break; - case 4 : colorth = 3; break; - case 5 : colorth = 4; break; - } + if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; + else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; - if(HwDeviceExtension->jChipType == SIS_730) { - - do { - B = SiS_CalcDelay2(SiS_Pr, ROMAddr, FQBQData730[i], HwDeviceExtension) * VCLK * colorth; - bl = B / (MCLK * 16); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting custom mode %dx%d on CRT2\n", + SiS_Pr->CHDisplay, temptemp); - if(B == bl * 16 * MCLK) { - bl = bl + 1; - } else { - bl = bl + 2; - } + } else { - if(bl > 0x13) { - if(FQBQData730[i+1] == 0xFF) { - ThresholdLow = 0x13; - break; - } - i++; - } else { - ThresholdLow = bl; - break; - } - } while(FQBQData730[i] != 0xFF); - - } else { - - do { - B = SiS_CalcDelay2(SiS_Pr, ROMAddr, FQBQData[i], HwDeviceExtension) * VCLK * colorth; - bl = B / (MCLK * 16); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting standard mode 0x%x on CRT2\n", ModeNo); - if(B == bl * 16 * MCLK) { - bl = bl + 1; - } else { - bl = bl + 2; - } + } - if(bl > 0x13) { - if(FQBQData[i+1] == 0xFF) { - ThresholdLow = 0x13; - break; - } - i++; - } else { - ThresholdLow = bl; - break; - } - } while(FQBQData[i] != 0xFF); - } - } - else { - if(HwDeviceExtension->jChipType == SIS_730) { - } else { - i = 9; - } - ThresholdLow = 0x02; - } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); + + SiS_UnLockCRT2(SiS_Pr, HwInfo); + + if(!SiS_Pr->UseCustomMode) { + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; + } else { + ModeIdIndex = 0; + } - /* Write foreground and background queue */ - if(HwDeviceExtension->jChipType == SIS_730) { - - data2 = FQBQData730[i]; - data2 = (data2 & 0xC0) >> 5; - data2 <<= 8; + SiS_GetVBType(SiS_Pr, HwInfo); -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x80000050); - eax = SiS_GetReg3(0xcfc); - eax &= 0xfffff9ff; - eax |= data2; - SiS_SetReg4(0xcfc,eax); -#else - /* We use pci functions X offers. We use pcitag 0, because - * we want to read/write to the host bridge (which is always - * 00:00.0 on 630, 730 and 540), not the VGA device. - */ - eax = pciReadLong(0x00000000, 0x50); - eax &= 0xfffff9ff; - eax |= data2; - pciWriteLong(0x00000000, 0x50, eax); -#endif + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + SiS_UnLockCRT2(SiS_Pr,HwInfo); + if(ROMAddr && SiS_Pr->SiS_UseROM) { + if(HwInfo->jChipType < SIS_330) { + temp = ROMAddr[VB310Data_1_2_Offset]; + temp |= 0x40; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); + } + if(HwInfo->jChipType > SIS_330) { + temp = ROMAddr[0x7e]; + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x7b) >= 100) temp |= 0x40; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); + } + } + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10); - /* Write GUI grant timer (PCI config 0xA3) */ - data2 = FQBQData730[i] << 8; - data2 = (data2 & 0x0f00) | ((data2 & 0x3000) >> 8); - data2 <<= 20; - -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x800000A0); - eax = SiS_GetReg3(0xcfc); - eax &= 0x00ffffff; - eax |= data2; - SiS_SetReg4(0xcfc,eax); -#else - eax = pciReadLong(0x00000000, 0xA0); - eax &= 0x00ffffff; - eax |= data2; - pciWriteLong(0x00000000, 0xA0, eax); -#endif + SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x00,0x0c); - } else { - - data2 = FQBQData[i]; - data2 = (data2 & 0xf0) >> 4; - data2 <<= 24; + backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + } else { + backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + } + } -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x80000050); - eax = SiS_GetReg3(0xcfc); - eax &= 0xf0ffffff; - eax |= data2; - SiS_SetReg4(0xcfc,eax); -#else - eax = pciReadLong(0x00000000, 0x50); - eax &= 0xf0ffffff; - eax |= data2; - pciWriteLong(0x00000000, 0x50, eax); -#endif + /* Get VB information (connectors, connected devices) */ + if(!SiS_Pr->UseCustomMode) { + SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, 1); + } else { + /* If this is a custom mode, we don't check the modeflag for CRT2Mode */ + SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, 0); + } + SiS_SetYPbPr(SiS_Pr, HwInfo); + SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_SetLowModeTest(SiS_Pr, ModeNo, HwInfo); - /* Write GUI grant timer (PCI config 0xA3) */ - data2 = FQBQData[i]; - data2 &= 0x0f; - data2 <<= 24; + /* Set mode on CRT2 */ + if( (SiS_Pr->SiS_VBType & VB_SISVB) || + (SiS_Pr->SiS_IF_DEF_LVDS == 1) || + (SiS_Pr->SiS_IF_DEF_CH70xx != 0) || + (SiS_Pr->SiS_IF_DEF_TRUMPION != 0) ) { + SiS_SetCRT2Group(SiS_Pr, HwInfo, ModeNo); + } -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x800000A0); - eax = SiS_GetReg3(0xcfc); - eax &= 0xf0ffffff; - eax |= data2; - SiS_SetReg4(0xcfc,eax); -#else - eax = pciReadLong(0x00000000, 0xA0); - eax &= 0xf0ffffff; - eax |= data2; - pciWriteLong(0x00000000, 0xA0, eax); -#endif - - } + SiS_StrangeStuff(SiS_Pr, HwInfo); - /* Write CRT/CPU threshold low, CRT/Engine threshold high */ - data = ((ThresholdLow & 0x0f) << 4) | 0x0f; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,data); + SiS_DisplayOn(SiS_Pr); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); - data = (ThresholdLow & 0x10) << 1; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xDF,data); + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); + } + } + } - /* What is this? */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x3B,0x09); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + if(HwInfo->jChipType < SIS_661) { + if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); + } else { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); + } + } - /* Write CRT/CPU threshold high (gap = 3) */ - data = ThresholdLow + 3; - if(data > 0x0f) data = 0x0f; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x09,0x80,data); -} + SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg); -USHORT -SiS_CalcDelay2(SiS_Private *SiS_Pr, UCHAR *ROMAddr,UCHAR key, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT data,index; - const UCHAR LatencyFactor[] = { - 97, 88, 86, 79, 77, 00, /*; 64 bit BQ=2 */ - 00, 87, 85, 78, 76, 54, /*; 64 bit BQ=1 */ - 97, 88, 86, 79, 77, 00, /*; 128 bit BQ=2 */ - 00, 79, 77, 70, 68, 48, /*; 128 bit BQ=1 */ - 80, 72, 69, 63, 61, 00, /*; 64 bit BQ=2 */ - 00, 70, 68, 61, 59, 37, /*; 64 bit BQ=1 */ - 86, 77, 75, 68, 66, 00, /*; 128 bit BQ=2 */ - 00, 68, 66, 59, 57, 37 /*; 128 bit BQ=1 */ - }; - const UCHAR LatencyFactor730[] = { - 69, 63, 61, - 86, 79, 77, - 103, 96, 94, - 120,113,111, - 137,130,128, /* --- Table ends with this entry, data below */ - 137,130,128, /* to avoid using illegal values */ - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - }; + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); + } + } else if((HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730)) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg); + } + } - if(HwDeviceExtension->jChipType == SIS_730) { - index = ((key & 0x0f) * 3) + ((key & 0xC0) >> 6); - data = LatencyFactor730[index]; - } else { - index = (key & 0xE0) >> 5; - if(key & 0x10) index +=6; - if(!(key & 0x01)) index += 24; - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - if(data & 0x0080) index += 12; - data = LatencyFactor[index]; - } - return(data); + /* SetPitch: Adapt to virtual size & position */ + SiS_SetPitchCRT2(SiS_Pr, pScrn); + + return TRUE; } -#endif -/* =============== Autodetection ================ */ -/* I N C O M P L E T E */ +/*********************************************/ +/* XFree86: SiSBIOSSetModeCRT1() */ +/* for Dual-Head modes */ +/*********************************************/ BOOLEAN -SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom) { - const USHORT PanelTypeTable300[16] = { - 0xc101, 0xc117, 0x0121, 0xc135, 0xc142, 0xc152, 0xc162, 0xc072, - 0xc181, 0xc192, 0xc1a1, 0xc1b6, 0xc1c2, 0xc0d2, 0xc1e2, 0xc1f2 - }; - const USHORT PanelTypeTable31030x[16] = { - 0xc102, 0xc112, 0x0122, 0xc132, 0xc142, 0xc152, 0xc169, 0xc179, - 0x0189, 0xc192, 0xc1a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - }; - const USHORT PanelTypeTable310LVDS[16] = { - 0xc111, 0xc122, 0xc133, 0xc144, 0xc155, 0xc166, 0xc177, 0xc188, - 0xc199, 0xc0aa, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - }; - USHORT tempax,tempbx,tempah,temp; + SISPtr pSiS = SISPTR(pScrn); + SISIOADDRESS BaseAddr = HwInfo->ulIOAddress; + USHORT ModeIdIndex, ModeNo=0; + UCHAR backupreg=0; +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; + UCHAR backupcr30, backupcr31, backupcr38, backupcr35, backupp40d=0; + BOOLEAN backupcustom; +#endif - if(HwDeviceExtension->jChipType < SIS_315H) { + SiS_Pr->UseCustomMode = FALSE; - tempax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18); - tempbx = tempax & 0x0F; - if(!(tempax & 0x10)){ - if(SiS_Pr->SiS_IF_DEF_LVDS == 1){ - tempbx = 0; - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x38); - if(temp & 0x40) tempbx |= 0x08; - if(temp & 0x20) tempbx |= 0x02; - if(temp & 0x01) tempbx |= 0x01; - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x39); - if(temp & 0x80) tempbx |= 0x04; - } else { - return 0; - } - } - tempbx = PanelTypeTable300[tempbx]; - tempbx |= LCDSync; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,temp); - temp = (tempbx & 0xFF00) >> 8; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,~(LCDSyncBit|LCDRGB18Bit),temp); + if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { - } else { + USHORT temptemp = SiS_Pr->CVDisplay; - tempax = tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1a); - tempax &= 0x1e; - tempax >>= 1; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(tempax == 0) { - /* TODO: Include HUGE detection routine - (Probably not worth bothering) - */ - return 0; - } - temp = tempax & 0xff; - tempax--; - tempbx = PanelTypeTable310LVDS[tempax]; - } else { - tempbx = PanelTypeTable31030x[tempax]; - temp = tempbx & 0xff; - } - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,temp); - tempbx = (tempbx & 0xff00) >> 8; - temp = tempbx & 0xc1; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,~(LCDSyncBit|LCDRGB18Bit),temp); - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - temp = tempbx & 0x04; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x39,0xfb,temp); - } + if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; + else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; - } - return 1; -} + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting custom mode %dx%d on CRT1\n", + SiS_Pr->CHDisplay, temptemp); + ModeNo = 0xfe; + } else { -#ifdef LINUXBIOS + ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes); + if(!ModeNo) return FALSE; -void -SiS_DetectMonitor(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr) -{ - UCHAR DAC_TEST_PARMS[] = {0x0F,0x0F,0x0F}; - UCHAR DAC_CLR_PARMS[] = {0x00,0x00,0x00}; - USHORT SR1F; - - SR1F = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1F); /* backup DAC pedestal */ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1F,0x04); - - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(!(SiS_BridgeIsOn(SiS_Pr, BaseAddr))) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,0x41); - } - } + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting standard mode 0x%x on CRT1\n", ModeNo); + } - SiSSetMode(SiS_Pr,HwDeviceExtension,0x2E); - if(HwDeviceExtension->jChipType >= SIS_650) { - /* TW: On 650 only - enable CRT1 */ - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x63,0xbf); - } - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff); - SiS_ClearDAC(SiS_Pr, SiS_Pr->SiS_P3c8); - SiS_LongWait(SiS_Pr); - SiS_LongWait(SiS_Pr); - SiS_LongWait(SiS_Pr); - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,0xDF,0x00); - if(SiS_TestMonitorType(SiS_Pr, DAC_TEST_PARMS[0],DAC_TEST_PARMS[1],DAC_TEST_PARMS[2])) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,0xDF,0x20); - } else if(SiS_TestMonitorType(SiS_Pr, DAC_TEST_PARMS[0],DAC_TEST_PARMS[1],DAC_TEST_PARMS[2])) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,0xDF,0x20); - } - SiS_TestMonitorType(SiS_Pr, DAC_CLR_PARMS[0],DAC_CLR_PARMS[1],DAC_CLR_PARMS[2]); + SiSInitPtr(SiS_Pr, HwInfo); + SiSRegInit(SiS_Pr, BaseAddr); + SiS_GetSysFlags(SiS_Pr, HwInfo); + SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); + SiSInitPCIetc(SiS_Pr, HwInfo); + SiSSetLVDSetc(SiS_Pr, HwInfo); + SiSDetermineROMUsage(SiS_Pr, HwInfo); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1F,SR1F); -} + /* We don't clear the buffer under X */ + SiS_Pr->SiS_flag_clearbuffer = 0; -USHORT -SiS_TestMonitorType(SiS_Private *SiS_Pr, UCHAR R_DAC,UCHAR G_DAC,UCHAR B_DAC) -{ - USHORT temp,tempbx; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); - tempbx = R_DAC * 0x4d + G_DAC * 0x97 + B_DAC * 0x1c; - if((tempbx & 0x00ff) > 0x80) tempbx += 0x100; - tempbx = (tempbx & 0xFF00) >> 8; - R_DAC = (UCHAR) tempbx; - G_DAC = (UCHAR) tempbx; - B_DAC = (UCHAR) tempbx; - - SiS_SetReg3(SiS_Pr->SiS_P3c8,0x00); - SiS_SetReg3(SiS_Pr->SiS_P3c9,R_DAC); - SiS_SetReg3(SiS_Pr->SiS_P3c9,G_DAC); - SiS_SetReg3(SiS_Pr->SiS_P3c9,B_DAC); - SiS_LongWait(SiS_Pr); - temp=SiS_GetReg2(SiS_Pr->SiS_P3c2); - if(temp & 0x10) return(1); - else return(0); -} + SiS_UnLockCRT2(SiS_Pr, HwInfo); -void -SiS_GetSenseStatus(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,UCHAR *ROMAddr) -{ - USHORT tempax=0,tempbx,tempcx,temp; - USHORT P2reg0=0,SenseModeNo=0,OutputSelect=*SiS_Pr->pSiS_OutputSelect; - USHORT ModeIdIndex,i; - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; - - if(SiS_Pr->SiS_IF_DEF_LVDS == 1){ - SiS_GetPanelID(SiS_Pr); - temp=LCDSense; - temp=temp|SiS_SenseCHTV(SiS_Pr); - tempbx=~(LCDSense|AVIDEOSense|SVIDEOSense); - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,tempbx,temp); - } else { /* for 301 */ - if(SiS_Pr->SiS_IF_DEF_HiVision==1) { /* for HiVision */ - tempax=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x38); - temp=tempax&0x01; - tempax=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A); - temp=temp|(tempax&0x02); - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,0xA0,temp); - } else { - if(SiS_BridgeIsOn(SiS_Pr, BaseAddr)==0) { /* TW: Inserted "==0" */ - P2reg0 = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x00); - if(!(SiS_BridgeIsEnable(SiS_Pr, BaseAddr,HwDeviceExtension))) { - SenseModeNo=0x2e; - temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&SenseModeNo,&ModeIdIndex); - SiS_Pr->SiS_SetFlag = 0x00; - SiS_Pr->SiS_ModeType = ModeVGA; - SiS_Pr->SiS_VBInfo = SetCRT2ToRAMDAC |LoadDACFlag |SetInSlaveMode; - SiS_SetCRT2Group301(SiS_Pr, BaseAddr,ROMAddr,SenseModeNo,HwDeviceExtension); - for(i=0;i<20;i++) { - SiS_LongWait(SiS_Pr); - } - } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,0x1c); - tempax=0; - tempbx=*SiS_Pr->pSiS_RGBSenseData; - if(SiS_Is301B(SiS_Pr, BaseAddr)){ - tempbx=*SiS_Pr->pSiS_RGBSenseData2; - } - tempcx=0x0E08; - if(SiS_Sense(SiS_Pr, tempbx,tempcx)){ - if(SiS_Sense(SiS_Pr, tempbx,tempcx)){ - tempax=tempax|Monitor2Sense; - } - } - tempbx=*SiS_Pr->pSiS_YCSenseData; - if(SiS_Is301B(SiS_Pr, BaseAddr)){ - tempbx=*SiS_Pr->pSiS_YCSenseData2; - } - tempcx=0x0604; - if(SiS_Sense(SiS_Pr, tempbx,tempcx)){ - if(SiS_Sense(SiS_Pr,tempbx,tempcx)){ - tempax=tempax|SVIDEOSense; - } - } + if(!SiS_Pr->UseCustomMode) { + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; + } else { + ModeIdIndex = 0; + } - if(ROMAddr && SiS_Pr->SiS_UseROM) { -#ifdef SIS300 - if((HwDeviceExtension->jChipType==SIS_630)|| - (HwDeviceExtension->jChipType==SIS_730)) { - OutputSelect = ROMAddr[0xfe]; - } -#endif -#ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { - OutputSelect = ROMAddr[0xf3]; - if(HwDeviceExtension->jChipType == SIS_330) { - OutputSelect = ROMAddr[0x11b]; - } - } -#endif - } - if(OutputSelect & BoardTVType){ - tempbx = *SiS_Pr->pSiS_VideoSenseData; - if(SiS_Is301B(SiS_Pr, BaseAddr)){ - tempbx = *SiS_Pr->pSiS_VideoSenseData2; - } - tempcx = 0x0804; - if(SiS_Sense(SiS_Pr, tempbx,tempcx)){ - if(SiS_Sense(SiS_Pr, tempbx,tempcx)){ - tempax |= AVIDEOSense; - } - } - } else { - if(!(tempax & SVIDEOSense)){ - tempbx = *SiS_Pr->pSiS_VideoSenseData; - if(SiS_Is301B(SiS_Pr, BaseAddr)){ - tempbx = *SiS_Pr->pSiS_VideoSenseData2; - } - tempcx = 0x0804; - if(SiS_Sense(SiS_Pr,tempbx,tempcx)){ - if(SiS_Sense(SiS_Pr, tempbx,tempcx)){ - tempax |= AVIDEOSense; - } - } - } - } + /* Determine VBType */ + SiS_GetVBType(SiS_Pr, HwInfo); + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + } else { + backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); } + } - if(SiS_SenseLCD(SiS_Pr, HwDeviceExtension)){ - tempax |= LCDSense; + /* Get VB information (connectors, connected devices) */ + /* (We don't care if the current mode is a CRT2 mode) */ + SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, 0); + SiS_SetYPbPr(SiS_Pr, HwInfo); + SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_SetLowModeTest(SiS_Pr, ModeNo, HwInfo); + + if(HwInfo->jChipType >= SIS_315H) { +#if 0 + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x08) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(ModeNo != 0x10) SiS_Pr->SiS_SetFlag |= SetDOSMode; + } else if((IS_SIS651) && (SiS_Pr->SiS_VBType & VB_NoLCD)) { + SiS_Pr->SiS_SetFlag |= SetDOSMode; + } } +#endif - tempbx=0; - tempcx=0; - SiS_Sense(SiS_Pr, tempbx,tempcx); - - if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV)) { - tempax &= 0x00ef; /* 30xlv have no VGA2*/ - } - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,~0xDF,tempax); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,P2reg0); - if(!(P2reg0 & 0x20)) { - SiS_Pr->SiS_VBInfo = DisableCRT2Display; - SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,SenseModeNo,HwDeviceExtension); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(IS_SIS650) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); + if(IS_SIS651) SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x20); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); + } else if(IS_SIS661741660760) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x3a,0xef); + } } - } - } -} + } -BOOLEAN -SiS_Sense(SiS_Private *SiS_Pr, USHORT tempbx,USHORT tempcx) -{ - USHORT temp,i,tempch; + /* Set mode on CRT1 */ + SiS_SetCRT1Group(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_SetCRT2Group(SiS_Pr, HwInfo, ModeNo); + } - temp = tempbx & 0xFF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x11,temp); - temp = (tempbx & 0xFF00) >> 8; - temp |= (tempcx & 0x00FF); - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,~0x1F,temp); - - for(i=0; i<10; i++) SiS_LongWait(SiS_Pr); - - tempch = (tempcx & 0x7F00) >> 8; - temp = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x03); - temp ^= 0x0E; - temp &= tempch; - if(temp>0) return 1; - else return 0; -} + /* SetPitch: Adapt to virtual size & position */ + SiS_SetPitchCRT1(SiS_Pr, pScrn); -USHORT -SiS_SenseLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp; +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + pSiSEnt->CRT1ModeNo = ModeNo; + pSiSEnt->CRT1DMode = mode; + } +#endif - temp=SiS_GetPanelID(SiS_Pr); - if(!temp) temp=SiS_GetLCDDDCInfo(SiS_Pr, HwDeviceExtension); - return(temp); -} + if(SiS_Pr->UseCustomMode) { + SiS_Pr->CRT1UsesCustomMode = TRUE; + SiS_Pr->CSRClock_CRT1 = SiS_Pr->CSRClock; + SiS_Pr->CModeFlag_CRT1 = SiS_Pr->CModeFlag; + } else { + SiS_Pr->CRT1UsesCustomMode = FALSE; + } -BOOLEAN -SiS_GetLCDDDCInfo(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp; - /*add lcd sense*/ - if(HwDeviceExtension->ulCRT2LCDType==LCD_UNKNOWN) - return 0; - else{ - temp=(USHORT)HwDeviceExtension->ulCRT2LCDType; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,temp); - return 1; - } -} + /* Reset CRT2 if changing mode on CRT1 */ +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + if(pSiSEnt->CRT2ModeNo != -1) { + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "(Re-)Setting mode for CRT2\n"); + backupcustom = SiS_Pr->UseCustomMode; + backupcr30 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + backupcr31 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); + backupcr35 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + backupcr38 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(SiS_Pr->SiS_VBType & VB_SISVB) { + /* Backup LUT-enable */ + if(pSiSEnt->CRT2ModeSet) { + backupp40d = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x0d) & 0x08; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x30,pSiSEnt->CRT2CR30); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x31,pSiSEnt->CRT2CR31); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,pSiSEnt->CRT2CR35); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,pSiSEnt->CRT2CR38); + } + SiSBIOSSetModeCRT2(SiS_Pr, HwInfo, pSiSEnt->pScrn_1, + pSiSEnt->CRT2DMode, pSiSEnt->CRT2IsCustom); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x30,backupcr30); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x31,backupcr31); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupcr35); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupcr38); + if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0d, ~0x08, backupp40d); + } + SiS_Pr->UseCustomMode = backupcustom; + } + } +#endif -USHORT -SiS_SenseCHTV(SiS_Private *SiS_Pr) -{ - USHORT temp,push0e,status; + /* Warning: From here, the custom mode entries in SiS_Pr are + * possibly overwritten + */ - status=0; - push0e = SiS_GetCH700x(SiS_Pr, 0x0e); - push0e = (push0e << 8) | 0x0e; - SiS_SetCH700x(SiS_Pr, 0x0b0e); - SiS_SetCH700x(SiS_Pr, 0x0110); - SiS_SetCH700x(SiS_Pr, 0x0010); - temp = SiS_GetCH700x(SiS_Pr, 0x10); - if(temp & 0x08) status |= SVIDEOSense; - if(temp & 0x02) status |= AVIDEOSense; - SiS_SetCH700x(SiS_Pr, push0e); - return(status); -} -#endif /* LINUXBIOS */ + SiS_HandleCRT1(SiS_Pr); -/* ================ for TC only ================= */ + SiS_StrangeStuff(SiS_Pr, HwInfo); -#ifdef TC + SiS_DisplayOn(SiS_Pr); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); -int -INT1AReturnCode(union REGS regs) -{ - if (regs.x.cflag) - { - /*printf("Error to find pci device!\n"); */ - return 1; - } - - switch(regs.h.ah) - { - case 0: return 0; - break; - case 0x81: printf("Function not support\n"); - break; - case 0x83: printf("bad vendor id\n"); - break; - case 0x86: printf("device not found\n"); - break; - case 0x87: printf("bad register number\n"); - break; - case 0x88: printf("set failed\n"); - break; - case 0x89: printf("buffer too small"); - break; - } - return 1; -} + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg); + } else if((HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730)) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg); + } + } -unsigned -FindPCIIOBase(unsigned index,unsigned deviceid) -{ - union REGS regs; + /* Backup/Set ModeNo in BIOS scratch area */ + SiS_GetSetModeID(pScrn,ModeNo); - regs.h.ah = 0xb1; /*PCI_FUNCTION_ID */ - regs.h.al = 0x02; /*FIND_PCI_DEVICE */ - regs.x.cx = deviceid; - regs.x.dx = 0x1039; - regs.x.si = index; /* find n-th device */ - - int86(0x1A, ®s, ®s); - - if (INT1AReturnCode(regs)!=0) - return 0; - - /* regs.h.bh *//* bus number */ - /* regs.h.bl *//* device number */ - regs.h.ah = 0xb1; /*PCI_FUNCTION_ID */ - regs.h.al = 0x09; /*READ_CONFIG_WORD */ - regs.x.cx = deviceid; - regs.x.dx = 0x1039; - regs.x.di = 0x18; /* register number */ - int86(0x1A, ®s, ®s); - - if (INT1AReturnCode(regs)!=0) - return 0; - return regs.x.cx; + return TRUE; } +#endif /* Linux_XF86 */ -void -main(int argc, char *argv[]) +#ifdef LINUX_XF86 +BOOLEAN +SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - SIS_HW_DEVICE_INFO HwDeviceExtension; - USHORT temp; - USHORT ModeNo; + const USHORT PanelTypeTable300[16] = { + 0xc101, 0xc117, 0x0121, 0xc135, 0xc142, 0xc152, 0xc162, 0xc072, + 0xc181, 0xc192, 0xc1a1, 0xc1b6, 0xc1c2, 0xc0d2, 0xc1e2, 0xc1f2 + }; + const USHORT PanelTypeTable31030x[16] = { + 0xc102, 0xc112, 0x0122, 0xc132, 0xc142, 0xc152, 0xc169, 0xc179, + 0x0189, 0xc192, 0xc1a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 + }; + const USHORT PanelTypeTable310LVDS[16] = { + 0xc111, 0xc122, 0xc133, 0xc144, 0xc155, 0xc166, 0xc177, 0xc188, + 0xc199, 0xc0aa, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 + }; + USHORT tempax,tempbx,temp; - /*HwDeviceExtension.pjVirtualRomBase =(PUCHAR) MK_FP(0xC000,0); */ - /*HwDeviceExtension.pjVideoMemoryAddress = (PUCHAR)MK_FP(0xA000,0);*/ + if(HwInfo->jChipType < SIS_315H) { -#ifdef SIS300 - HwDeviceExtension.ulIOAddress = (FindPCIIOBase(0,0x6300)&0xFF80) + 0x30; - HwDeviceExtension.jChipType = SIS_630; -#endif + tempax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x18); + tempbx = tempax & 0x0F; + if(!(tempax & 0x10)){ + if(SiS_Pr->SiS_IF_DEF_LVDS == 1){ + tempbx = 0; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x38); + if(temp & 0x40) tempbx |= 0x08; + if(temp & 0x20) tempbx |= 0x02; + if(temp & 0x01) tempbx |= 0x01; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x39); + if(temp & 0x80) tempbx |= 0x04; + } else { + return 0; + } + } + tempbx = PanelTypeTable300[tempbx]; + tempbx |= LCDSync; + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,temp); + temp = (tempbx & 0xFF00) >> 8; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,~(LCDSyncBit|LCDRGB18Bit),temp); -#ifdef SIS315H -// HwDeviceExtension.ulIOAddress = (FindPCIIOBase(0,0x5315)&0xFF80) + 0x30; -// HwDeviceExtension.jChipType = SIS_550; - HwDeviceExtension.ulIOAddress = (FindPCIIOBase(0,0x325)&0xFF80) + 0x30; - HwDeviceExtension.jChipType = SIS_315H; -#endif + } else { + + if(HwInfo->jChipType >= SIS_661) return 0; + + tempax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1a); + tempax &= 0x1e; + tempax >>= 1; + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(tempax == 0) { + /* TODO: Include HUGE detection routine + (Probably not worth bothering) + */ + return 0; + } + temp = tempax & 0xff; + tempax--; + tempbx = PanelTypeTable310LVDS[tempax]; + } else { + tempbx = PanelTypeTable31030x[tempax]; + temp = tempbx & 0xff; + } + SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,temp); + tempbx = (tempbx & 0xff00) >> 8; + temp = tempbx & 0xc1; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,~(LCDSyncBit|LCDRGB18Bit),temp); + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp = tempbx & 0x04; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x39,0xfb,temp); + } - HwDeviceExtension.ujVBChipID = VB_CHIP_301; - strcpy(HwDeviceExtension.szVBIOSVer,"0.84"); - HwDeviceExtension.bSkipDramSizing = FALSE; - HwDeviceExtension.ulVideoMemorySize = 0; - if(argc==2) { - ModeNo=atoi(argv[1]); - } - else { - ModeNo=0x2e; - /*ModeNo=0x37; */ /* 1024x768x 4bpp */ - /*ModeNo=0x38; *//* 1024x768x 8bpp */ - /*ModeNo=0x4A; *//* 1024x768x 16bpp */ - /*ModeNo=0x47;*/ /* 800x600x 16bpp */ } - /* SiSInit(SiS_Pr, &HwDeviceExtension);*/ - SiSSetMode(SiS_Pr, &HwDeviceExtension, ModeNo); + return 1; } -#endif /* TC END */ +#endif + /* ================ XFREE86 ================= */ @@ -5000,44 +4308,78 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pSc SISPtr pSiS = SISPTR(pScrn); int out_n, out_dn, out_div, out_sbit, out_scale; int depth = pSiS->CurrentLayout.bitsPerPixel; - -#ifdef SISDUALHEAD - if( ((!pSiS->DualHeadMode) && (VBFlags & DISPTYPE_DISP2)) || - ((pSiS->DualHeadMode) && (!pSiS->SecondHead)) ) return 0; -#else - if(VBFlags & DISPTYPE_DISP2) return 0; -#endif + unsigned int vclk[5]; + +#define Midx 0 +#define Nidx 1 +#define VLDidx 2 +#define Pidx 3 +#define PSNidx 4 + + pSiS->SiS_Pr->CModeFlag = 0; pSiS->SiS_Pr->CDClock = mode->Clock; - + pSiS->SiS_Pr->CHDisplay = mode->HDisplay; pSiS->SiS_Pr->CHSyncStart = mode->HSyncStart; pSiS->SiS_Pr->CHSyncEnd = mode->HSyncEnd; pSiS->SiS_Pr->CHTotal = mode->HTotal; - pSiS->SiS_Pr->CHBlankStart = pSiS->SiS_Pr->CHDisplay; - pSiS->SiS_Pr->CHBlankEnd = pSiS->SiS_Pr->CHTotal; - + pSiS->SiS_Pr->CVDisplay = mode->VDisplay; pSiS->SiS_Pr->CVSyncStart = mode->VSyncStart; pSiS->SiS_Pr->CVSyncEnd = mode->VSyncEnd; pSiS->SiS_Pr->CVTotal = mode->VTotal; + + pSiS->SiS_Pr->CFlags = mode->Flags; + + if(pSiS->SiS_Pr->CFlags & V_INTERLACE) { + pSiS->SiS_Pr->CVDisplay >>= 1; + pSiS->SiS_Pr->CVSyncStart >>= 1; + pSiS->SiS_Pr->CVSyncEnd >>= 1; + pSiS->SiS_Pr->CVTotal >>= 1; + } + if(pSiS->SiS_Pr->CFlags & V_DBLSCAN) { + /* pSiS->SiS_Pr->CDClock <<= 1; */ + pSiS->SiS_Pr->CVDisplay <<= 1; + pSiS->SiS_Pr->CVSyncStart <<= 1; + pSiS->SiS_Pr->CVSyncEnd <<= 1; + pSiS->SiS_Pr->CVTotal <<= 1; + } + + pSiS->SiS_Pr->CHBlankStart = pSiS->SiS_Pr->CHDisplay; + pSiS->SiS_Pr->CHBlankEnd = pSiS->SiS_Pr->CHTotal; pSiS->SiS_Pr->CVBlankStart = pSiS->SiS_Pr->CVSyncStart - 1; pSiS->SiS_Pr->CVBlankEnd = pSiS->SiS_Pr->CVTotal; - - pSiS->SiS_Pr->CFlags = mode->Flags; - SiS_compute_vclk(pSiS->SiS_Pr->CDClock, &out_n, &out_dn, &out_div, &out_sbit, &out_scale); - + if(SiS_compute_vclk(pSiS->SiS_Pr->CDClock, &out_n, &out_dn, &out_div, &out_sbit, &out_scale)) { + pSiS->SiS_Pr->CSR2B = (out_div == 2) ? 0x80 : 0x00; + pSiS->SiS_Pr->CSR2B |= ((out_n - 1) & 0x7f); + pSiS->SiS_Pr->CSR2C = (out_dn - 1) & 0x1f; + pSiS->SiS_Pr->CSR2C |= (((out_scale - 1) & 3) << 5); + pSiS->SiS_Pr->CSR2C |= ((out_sbit & 0x01) << 7); +#ifdef TWDEBUG + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sb %d sc %d\n", + pSiS->SiS_Pr->CDClock, out_n, out_dn, out_div, out_sbit, out_scale); +#endif + } else { + SiSCalcClock(pScrn, pSiS->SiS_Pr->CDClock, 2, vclk); + pSiS->SiS_Pr->CSR2B = (vclk[VLDidx] == 2) ? 0x80 : 0x00; + pSiS->SiS_Pr->CSR2B |= (vclk[Midx] - 1) & 0x7f; + pSiS->SiS_Pr->CSR2C = (vclk[Nidx] - 1) & 0x1f; + if(vclk[Pidx] <= 4) { + /* postscale 1,2,3,4 */ + pSiS->SiS_Pr->CSR2C |= ((vclk[Pidx] - 1) & 3) << 5; + } else { + /* postscale 6,8 */ + pSiS->SiS_Pr->CSR2C |= (((vclk[Pidx] / 2) - 1) & 3) << 5; + pSiS->SiS_Pr->CSR2C |= 0x80; + } #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sb %d sc %d\n", - pSiS->SiS_Pr->CDClock, out_n, out_dn, out_div, out_sbit, out_scale); -#endif - - pSiS->SiS_Pr->CSR2B = (out_div == 2) ? 0x80 : 0x00; - pSiS->SiS_Pr->CSR2B |= ((out_n - 1) & 0x7f); - pSiS->SiS_Pr->CSR2C = (out_dn - 1) & 0x1f; - pSiS->SiS_Pr->CSR2C |= (((out_scale - 1) & 3) << 5); - pSiS->SiS_Pr->CSR2C |= ((out_sbit & 0x01) << 7); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sc %d\n", + pSiS->SiS_Pr->CDClock, vclk[Midx], vclk[Nidx], vclk[VLDidx], vclk[Pidx]); +#endif + } + pSiS->SiS_Pr->CSRClock = (pSiS->SiS_Pr->CDClock / 1000) + 1; pSiS->SiS_Pr->CCRT1CRTC[0] = ((pSiS->SiS_Pr->CHTotal >> 3) - 5) & 0xff; @@ -5045,9 +4387,9 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pSc pSiS->SiS_Pr->CCRT1CRTC[2] = (pSiS->SiS_Pr->CHBlankStart >> 3) - 1; pSiS->SiS_Pr->CCRT1CRTC[3] = (((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1) & 0x1F) | 0x80; pSiS->SiS_Pr->CCRT1CRTC[4] = (pSiS->SiS_Pr->CHSyncStart >> 3) + 3; - pSiS->SiS_Pr->CCRT1CRTC[5] = ((((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1) & 0x20) << 2) | + pSiS->SiS_Pr->CCRT1CRTC[5] = ((((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1) & 0x20) << 2) | (((pSiS->SiS_Pr->CHSyncEnd >> 3) + 3) & 0x1F); - + pSiS->SiS_Pr->CCRT1CRTC[6] = (pSiS->SiS_Pr->CVTotal - 2) & 0xFF; pSiS->SiS_Pr->CCRT1CRTC[7] = (((pSiS->SiS_Pr->CVTotal - 2) & 0x100) >> 8) | (((pSiS->SiS_Pr->CVDisplay - 1) & 0x100) >> 7) @@ -5057,71 +4399,76 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pSc | (((pSiS->SiS_Pr->CVTotal - 2) & 0x200) >> 4) | (((pSiS->SiS_Pr->CVDisplay - 1) & 0x200) >> 3) | ((pSiS->SiS_Pr->CVSyncStart & 0x200) >> 2); - + pSiS->SiS_Pr->CCRT1CRTC[16] = ((((pSiS->SiS_Pr->CVBlankStart - 1) & 0x200) >> 4) >> 5); /* cr9 */ - -#if 0 + +#if 0 if (mode->VScan >= 32) regp->CRTC[9] |= 0x1F; else if (mode->VScan > 1) regp->CRTC[9] |= mode->VScan - 1; -#endif +#endif - pSiS->SiS_Pr->CCRT1CRTC[8] = (pSiS->SiS_Pr->CVSyncStart - 1) & 0xFF; /* cr10 */ - pSiS->SiS_Pr->CCRT1CRTC[9] = ((pSiS->SiS_Pr->CVSyncEnd - 1) & 0x0F) | 0x80; /* cr11 */ - pSiS->SiS_Pr->CCRT1CRTC[10] = (pSiS->SiS_Pr->CVDisplay - 1) & 0xFF; /* cr12 */ - pSiS->SiS_Pr->CCRT1CRTC[11] = (pSiS->SiS_Pr->CVBlankStart - 1) & 0xFF; /* cr15 */ - pSiS->SiS_Pr->CCRT1CRTC[12] = (pSiS->SiS_Pr->CVBlankEnd - 1) & 0xFF; /* cr16 */ - - pSiS->SiS_Pr->CCRT1CRTC[13] = + pSiS->SiS_Pr->CCRT1CRTC[8] = (pSiS->SiS_Pr->CVSyncStart ) & 0xFF; /* cr10 */ + pSiS->SiS_Pr->CCRT1CRTC[9] = ((pSiS->SiS_Pr->CVSyncEnd ) & 0x0F) | 0x80; /* cr11 */ + pSiS->SiS_Pr->CCRT1CRTC[10] = (pSiS->SiS_Pr->CVDisplay - 1) & 0xFF; /* cr12 */ + pSiS->SiS_Pr->CCRT1CRTC[11] = (pSiS->SiS_Pr->CVBlankStart - 1) & 0xFF; /* cr15 */ + pSiS->SiS_Pr->CCRT1CRTC[12] = (pSiS->SiS_Pr->CVBlankEnd - 1) & 0xFF; /* cr16 */ + + pSiS->SiS_Pr->CCRT1CRTC[13] = GETBITSTR((pSiS->SiS_Pr->CVTotal -2), 10:10, 0:0) | GETBITSTR((pSiS->SiS_Pr->CVDisplay -1), 10:10, 1:1) | GETBITSTR((pSiS->SiS_Pr->CVBlankStart-1), 10:10, 2:2) | GETBITSTR((pSiS->SiS_Pr->CVSyncStart ), 10:10, 3:3) | GETBITSTR((pSiS->SiS_Pr->CVBlankEnd -1), 8:8, 4:4) | - GETBITSTR((pSiS->SiS_Pr->CVSyncEnd -1), 4:4, 5:5) ; + GETBITSTR((pSiS->SiS_Pr->CVSyncEnd ), 4:4, 5:5) ; - pSiS->SiS_Pr->CCRT1CRTC[14] = + pSiS->SiS_Pr->CCRT1CRTC[14] = GETBITSTR((pSiS->SiS_Pr->CHTotal >> 3) - 5, 9:8, 1:0) | GETBITSTR((pSiS->SiS_Pr->CHDisplay >> 3) - 1, 9:8, 3:2) | GETBITSTR((pSiS->SiS_Pr->CHBlankStart >> 3) - 1, 9:8, 5:4) | GETBITSTR((pSiS->SiS_Pr->CHSyncStart >> 3) + 3, 9:8, 7:6) ; - + pSiS->SiS_Pr->CCRT1CRTC[15] = GETBITSTR((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1, 7:6, 1:0) | - GETBITSTR((pSiS->SiS_Pr->CHSyncEnd >> 3) + 3, 5:5, 2:2) ; - + GETBITSTR((pSiS->SiS_Pr->CHSyncEnd >> 3) + 3, 5:5, 2:2) ; + switch(depth) { - case 8: - pSiS->SiS_Pr->CModeFlag = 0x223b; + case 8: + pSiS->SiS_Pr->CModeFlag |= 0x223b; break; - case 16: - pSiS->SiS_Pr->CModeFlag = 0x227d; + case 16: + pSiS->SiS_Pr->CModeFlag |= 0x227d; break; - case 32: - pSiS->SiS_Pr->CModeFlag = 0x22ff; + case 32: + pSiS->SiS_Pr->CModeFlag |= 0x22ff; break; default: return 0; } if(pSiS->SiS_Pr->CFlags & V_DBLSCAN) - pSiS->SiS_Pr->CModeFlag |= DoubleScanMode; - if((pSiS->SiS_Pr->CVDisplay >= 1024) || - (pSiS->SiS_Pr->CVTotal >= 1024) || + pSiS->SiS_Pr->CModeFlag |= DoubleScanMode; + + if((pSiS->SiS_Pr->CVDisplay >= 1024) || + (pSiS->SiS_Pr->CVTotal >= 1024) || (pSiS->SiS_Pr->CHDisplay >= 1024)) - pSiS->SiS_Pr->CModeFlag |= LineCompareOff; + pSiS->SiS_Pr->CModeFlag |= LineCompareOff; + if(pSiS->SiS_Pr->CFlags & V_CLKDIV2) - pSiS->SiS_Pr->CModeFlag |= HalfDCLK; - + pSiS->SiS_Pr->CModeFlag |= HalfDCLK; + pSiS->SiS_Pr->CInfoFlag = 0x0007; - if(pSiS->SiS_Pr->CFlags & V_NHSYNC) - pSiS->SiS_Pr->CInfoFlag |= 0x4000; - if(pSiS->SiS_Pr->CFlags & V_NVSYNC) - pSiS->SiS_Pr->CInfoFlag |= 0x8000; - if(pSiS->SiS_Pr->CFlags & V_INTERLACE) - pSiS->SiS_Pr->CInfoFlag |= InterlaceMode; + + if(pSiS->SiS_Pr->CFlags & V_NHSYNC) + pSiS->SiS_Pr->CInfoFlag |= 0x4000; + + if(pSiS->SiS_Pr->CFlags & V_NVSYNC) + pSiS->SiS_Pr->CInfoFlag |= 0x8000; + + if(pSiS->SiS_Pr->CFlags & V_INTERLACE) + pSiS->SiS_Pr->CInfoFlag |= InterlaceMode; pSiS->SiS_Pr->UseCustomMode = TRUE; #ifdef TWDEBUG @@ -5152,13 +4499,13 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pSc pSiS->SiS_Pr->CSR2B, pSiS->SiS_Pr->CSR2C, pSiS->SiS_Pr->CSRClock); -#endif +#endif return 1; } -/* TW: Build a list of supported modes */ +/* Build a list of supported modes */ DisplayModePtr -SiSBuildBuiltInModeList(ScrnInfoPtr pScrn) +SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfordvi) { SISPtr pSiS = SISPTR(pScrn); unsigned short VRE, VBE, VRS, VBS, VDE, VT; @@ -5166,23 +4513,28 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr unsigned char sr_data, cr_data, cr_data2, cr_data3; unsigned char sr2b, sr2c; float num, denum, postscalar, divider; - int A, B, C, D, E, F, temp, i, j, index, vclkindex; - DisplayModePtr new = NULL, current = NULL, first = NULL, backup = NULL; + int A, B, C, D, E, F, temp, i, j, k, l, index, vclkindex; + DisplayModePtr new = NULL, current = NULL, first = NULL; + BOOLEAN done = FALSE; +#if 0 + DisplayModePtr backup = NULL; +#endif pSiS->backupmodelist = NULL; - + pSiS->AddedPlasmaModes = FALSE; + /* Initialize our pointers */ if(pSiS->VGAEngine == SIS_300_VGA) { #ifdef SIS300 - InitTo300Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); + InitTo300Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); #else - return NULL; + return NULL; #endif } else if(pSiS->VGAEngine == SIS_315_VGA) { #ifdef SIS315H - InitTo310Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); + InitTo310Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); #else - return NULL; + return NULL; #endif } else return NULL; @@ -5190,19 +4542,21 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr while(pSiS->SiS_Pr->SiS_RefIndex[i].Ext_InfoFlag != 0xFFFF) { index = pSiS->SiS_Pr->SiS_RefIndex[i].Ext_CRT1CRTC; -#if 0 /* Not any longer */ - if(pSiS->VGAEngine == SIS_300_VGA) index &= 0x3F; -#endif - - if(((pSiS->SiS_Pr->SiS_RefIndex[i].XRes < 512) && (!pSiS->DSTN)) || - ((pSiS->DSTN) && - (pSiS->SiS_Pr->SiS_RefIndex[i].XRes < 512) && - (pSiS->SiS_Pr->SiS_RefIndex[i].XRes != 320) && - (pSiS->SiS_Pr->SiS_RefIndex[i].YRes != 480))) { + + /* 0x5a (320x240) is a pure FTSN mode, not DSTN! */ + if((!pSiS->FSTN) && + (pSiS->SiS_Pr->SiS_RefIndex[i].ModeID == 0x5a)) { i++; continue; } - + if((pSiS->FSTN) && + (pSiS->SiS_Pr->SiS_RefIndex[i].XRes == 320) && + (pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 240) && + (pSiS->SiS_Pr->SiS_RefIndex[i].ModeID != 0x5a)) { + i++; + continue; + } + if(!(new = xalloc(sizeof(DisplayModeRec)))) return first; memset(new, 0, sizeof(DisplayModeRec)); if(!(new->name = xalloc(10))) { @@ -5216,13 +4570,13 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr } current = new; - + sprintf(current->name, "%dx%d", pSiS->SiS_Pr->SiS_RefIndex[i].XRes, pSiS->SiS_Pr->SiS_RefIndex[i].YRes); current->status = MODE_OK; - current->type = M_T_DEFAULT; + current->type = M_T_DEFAULT; vclkindex = pSiS->SiS_Pr->SiS_RefIndex[i].Ext_CRTVCLK; if(pSiS->VGAEngine == SIS_300_VGA) vclkindex &= 0x3F; @@ -5235,7 +4589,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr ( (((sr2c >> 5) & 0x03) == 0x02) ? 6.0 : 8.0) : (((sr2c >> 5) & 0x03) + 1.0); num = (sr2b & 0x7f) + 1.0; denum = (sr2c & 0x1f) + 1.0; - + #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "------------\n"); xf86DrvMsg(0, X_INFO, "sr2b: %x sr2c %x div %f ps %f num %f denum %f\n", @@ -5303,10 +4657,29 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr D = B - F - C; - current->HDisplay = (E * 8); - current->HSyncStart = (E * 8) + (F * 8); - current->HSyncEnd = (E * 8) + (F * 8) + (C * 8); - current->HTotal = (E * 8) + (F * 8) + (C * 8) + (D * 8); + if((pSiS->SiS_Pr->SiS_RefIndex[i].XRes == 320) && + ((pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 200) || + (pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 240))) { + + /* Terrible hack, but correct CRTC data for + * these modes only produces a black screen... + * (HRE is 0, leading into a too large C and + * a negative D. The CRT controller does not + * seem to like correcting HRE to 50 + */ + current->HDisplay = 320; + current->HSyncStart = 328; + current->HSyncEnd = 376; + current->HTotal = 400; + + } else { + + current->HDisplay = (E * 8); + current->HSyncStart = (E * 8) + (F * 8); + current->HSyncEnd = (E * 8) + (F * 8) + (C * 8); + current->HTotal = (E * 8) + (F * 8) + (C * 8) + (D * 8); + + } #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, @@ -5430,7 +4803,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr current->VSyncStart <<= 1; current->VSyncEnd <<= 1; current->VTotal <<= 1; - current->VTotal |= 1; + current->VTotal |= 1; } if(current->Flags & V_DBLSCAN) { current->Clock >>= 1; @@ -5440,6 +4813,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr current->VTotal >>= 1; } +#if 0 if((backup = xalloc(sizeof(DisplayModeRec)))) { if(!pSiS->backupmodelist) pSiS->backupmodelist = backup; else { @@ -5458,6 +4832,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr backup->Flags = current->Flags; backup->Clock = current->Clock; } +#endif #ifdef TWDEBUG xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -5465,61 +4840,324 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr current->name, (float)current->Clock / 1000, current->HDisplay, current->HSyncStart, current->HSyncEnd, current->HTotal, current->VDisplay, current->VSyncStart, current->VSyncEnd, current->VTotal); +#else + (void)VBS; (void)HBS; (void)A; #endif i++; } + /* Add non-standard LCD modes for panel's detailed timings */ + + if(!includelcdmodes) return first; + + if(pSiS->SiS_Pr->CP_Vendor) { + xf86DrvMsg(0, X_INFO, "Checking database for vendor %x, product %x\n", + pSiS->SiS_Pr->CP_Vendor, pSiS->SiS_Pr->CP_Product); + } + + i = 0; + while((!done) && (SiS_PlasmaTable[i].vendor) && (pSiS->SiS_Pr->CP_Vendor)) { + + if(SiS_PlasmaTable[i].vendor == pSiS->SiS_Pr->CP_Vendor) { + + for(j=0; jSiS_Pr->CP_Product) { + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Identified %s panel, adding specific modes\n", + SiS_PlasmaTable[i].plasmaname); + + for(k=0; kname = xalloc(10))) { + xfree(new); + return first; + } + if(!first) first = new; + if(current) { + current->next = new; + new->prev = current; + } + + current = new; + + pSiS->AddedPlasmaModes = TRUE; + + l = SiS_PlasmaTable[i].plasmamodes[k] & 0x3f; + + sprintf(current->name, "%dx%d", SiS_PlasmaMode[l].HDisplay, + SiS_PlasmaMode[l].VDisplay); + + current->status = MODE_OK; + + current->type = M_T_BUILTIN; + + current->Clock = SiS_PlasmaMode[l].clock; + current->SynthClock = current->Clock; + + current->HDisplay = SiS_PlasmaMode[l].HDisplay; + current->HSyncStart = current->HDisplay + SiS_PlasmaMode[l].HFrontPorch; + current->HSyncEnd = current->HSyncStart + SiS_PlasmaMode[l].HSyncWidth; + current->HTotal = SiS_PlasmaMode[l].HTotal; + + current->VDisplay = SiS_PlasmaMode[l].VDisplay; + current->VSyncStart = current->VDisplay + SiS_PlasmaMode[l].VFrontPorch; + current->VSyncEnd = current->VSyncStart + SiS_PlasmaMode[l].VSyncWidth; + current->VTotal = SiS_PlasmaMode[l].VTotal; + + current->CrtcHDisplay = current->HDisplay; + current->CrtcHBlankStart = current->HSyncStart; + current->CrtcHSyncStart = current->HSyncStart; + current->CrtcHSyncEnd = current->HSyncEnd; + current->CrtcHBlankEnd = current->HSyncEnd; + current->CrtcHTotal = current->HTotal; + + current->CrtcVDisplay = current->VDisplay; + current->CrtcVBlankStart = current->VSyncStart; + current->CrtcVSyncStart = current->VSyncStart; + current->CrtcVSyncEnd = current->VSyncEnd; + current->CrtcVBlankEnd = current->VSyncEnd; + current->CrtcVTotal = current->VTotal; + + if(SiS_PlasmaMode[l].SyncFlags & SIS_PL_HSYNCP) + current->Flags |= V_PHSYNC; + else + current->Flags |= V_NHSYNC; + + if(SiS_PlasmaMode[l].SyncFlags & SIS_PL_VSYNCP) + current->Flags |= V_PVSYNC; + else + current->Flags |= V_NVSYNC; + + if(current->HDisplay > pSiS->LCDwidth) + pSiS->LCDwidth = pSiS->SiS_Pr->CP_MaxX = current->HDisplay; + if(current->VDisplay > pSiS->LCDheight) + pSiS->LCDheight = pSiS->SiS_Pr->CP_MaxY = current->VDisplay; + + } + done = TRUE; + break; + } + } + } + + i++; + + } + + if(pSiS->SiS_Pr->CP_HaveCustomData) { + + for(i=0; i<7; i++) { + + if(pSiS->SiS_Pr->CP_DataValid[i]) { + + if(!(new = xalloc(sizeof(DisplayModeRec)))) return first; + + memset(new, 0, sizeof(DisplayModeRec)); + if(!(new->name = xalloc(10))) { + xfree(new); + return first; + } + if(!first) first = new; + if(current) { + current->next = new; + new->prev = current; + } + + current = new; + + sprintf(current->name, "%dx%d", pSiS->SiS_Pr->CP_HDisplay[i], + pSiS->SiS_Pr->CP_VDisplay[i]); + + current->status = MODE_OK; + + current->type = M_T_BUILTIN; + + current->Clock = pSiS->SiS_Pr->CP_Clock[i]; + current->SynthClock = current->Clock; + + current->HDisplay = pSiS->SiS_Pr->CP_HDisplay[i]; + current->HSyncStart = pSiS->SiS_Pr->CP_HSyncStart[i]; + current->HSyncEnd = pSiS->SiS_Pr->CP_HSyncEnd[i]; + current->HTotal = pSiS->SiS_Pr->CP_HTotal[i]; + + current->VDisplay = pSiS->SiS_Pr->CP_VDisplay[i]; + current->VSyncStart = pSiS->SiS_Pr->CP_VSyncStart[i]; + current->VSyncEnd = pSiS->SiS_Pr->CP_VSyncEnd[i]; + current->VTotal = pSiS->SiS_Pr->CP_VTotal[i]; + + current->CrtcHDisplay = current->HDisplay; + current->CrtcHBlankStart = pSiS->SiS_Pr->CP_HBlankStart[i]; + current->CrtcHSyncStart = current->HSyncStart; + current->CrtcHSyncEnd = current->HSyncEnd; + current->CrtcHBlankEnd = pSiS->SiS_Pr->CP_HBlankEnd[i]; + current->CrtcHTotal = current->HTotal; + + current->CrtcVDisplay = current->VDisplay; + current->CrtcVBlankStart = pSiS->SiS_Pr->CP_VBlankStart[i]; + current->CrtcVSyncStart = current->VSyncStart; + current->CrtcVSyncEnd = current->VSyncEnd; + current->CrtcVBlankEnd = pSiS->SiS_Pr->CP_VBlankEnd[i]; + current->CrtcVTotal = current->VTotal; + + if(pSiS->SiS_Pr->CP_SyncValid[i]) { + if(pSiS->SiS_Pr->CP_HSync_P[i]) + current->Flags |= V_PHSYNC; + else + current->Flags |= V_NHSYNC; + + if(pSiS->SiS_Pr->CP_VSync_P[i]) + current->Flags |= V_PVSYNC; + else + current->Flags |= V_NVSYNC; + } else { + /* No sync data? Use positive sync... */ + current->Flags |= V_PHSYNC; + current->Flags |= V_PVSYNC; + } + } + } + } + return first; } + +/* Build a list of supported modes */ +int +SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber) +{ + SISPtr pSiS = SISPTR(pScrn); + int i; + + /* Initialize our pointers */ + if(pSiS->VGAEngine == SIS_300_VGA) { +#ifdef SIS300 + InitTo300Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); +#else + return -1; +#endif + } else if(pSiS->VGAEngine == SIS_315_VGA) { +#ifdef SIS315H + InitTo310Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); +#else + return -1; #endif + } else return -1; + + if(modenumber <= 0x13) return modenumber; + + i = 0; + while(pSiS->SiS_Pr->SiS_EModeIDTable[i].Ext_ModeID != 0xff) { + if(pSiS->SiS_Pr->SiS_EModeIDTable[i].Ext_ModeID == modenumber) { + return (int)pSiS->SiS_Pr->SiS_EModeIDTable[i].Ext_VESAID; + } + i++; + } + return -1; +} +#endif /* Xfree86 */ #ifdef LINUX_KERNEL int -sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, +sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, unsigned char modeno, unsigned char rateindex) { USHORT ModeNo = modeno; USHORT ModeIdIndex = 0, ClockIndex = 0; USHORT RefreshRateTableIndex = 0; - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - ULONG temp = 0; int Clock; - - if(HwDeviceExtension->jChipType < SIS_315H) { + + if(HwInfo->jChipType < SIS_315H) { #ifdef SIS300 - InitTo300Pointer(SiS_Pr, HwDeviceExtension); + InitTo300Pointer(SiS_Pr, HwInfo); #else - return 65; + return 65 * 1000; #endif } else { #ifdef SIS315H - InitTo310Pointer(SiS_Pr, HwDeviceExtension); + InitTo310Pointer(SiS_Pr, HwInfo); #else - return 65; + return 65 * 1000; #endif } - - temp = SiS_SearchModeID(SiS_Pr, ROMAddr, &ModeNo, &ModeIdIndex); - if(!temp) { + + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) {; printk(KERN_ERR "Could not find mode %x\n", ModeNo); - return 65; + return 65 * 1000; } - + RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; RefreshRateTableIndex += (rateindex - 1); ClockIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - if(HwDeviceExtension->jChipType < SIS_315H) { + if(HwInfo->jChipType < SIS_315H) { ClockIndex &= 0x3F; } - Clock = SiS_Pr->SiS_VCLKData[ClockIndex].CLOCK * 1000 * 1000; + Clock = SiS_Pr->SiS_VCLKData[ClockIndex].CLOCK * 1000; return(Clock); } +BOOLEAN +sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex) +{ + USHORT ModeNo = modeno; + USHORT ModeIdIndex = 0, CRT1Index = 0; + USHORT RefreshRateTableIndex = 0; + unsigned char sr_data, cr_data, cr_data2; + + if(HwInfo->jChipType < SIS_315H) { +#ifdef SIS300 + InitTo300Pointer(SiS_Pr, HwInfo); +#else + return FALSE; +#endif + } else { +#ifdef SIS315H + InitTo310Pointer(SiS_Pr, HwInfo); +#else + return FALSE; +#endif + } + + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; + + RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; + RefreshRateTableIndex += (rateindex - 1); + CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; + + sr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14]; + cr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[0]; + *htotal = (((cr_data & 0xff) | ((unsigned short) (sr_data & 0x03) << 8)) + 5) * 8; + + sr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]; + cr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[6]; + cr_data2 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7]; + *vtotal = ((cr_data & 0xFF) | + ((unsigned short)(cr_data2 & 0x01) << 8) | + ((unsigned short)(cr_data2 & 0x20) << 4) | + ((unsigned short)(sr_data & 0x01) << 10)) + 2; + + if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & InterlaceMode) + *vtotal *= 2; + + return TRUE; +} + int -sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, +sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, unsigned char modeno, unsigned char rateindex, ULONG *left_margin, ULONG *right_margin, ULONG *upper_margin, ULONG *lower_margin, @@ -5529,29 +5167,27 @@ sisfb_mode_rate_to_ddata(SiS_Private *Si USHORT ModeNo = modeno; USHORT ModeIdIndex = 0, index = 0; USHORT RefreshRateTableIndex = 0; - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; unsigned short VRE, VBE, VRS, VBS, VDE, VT; unsigned short HRE, HBE, HRS, HBS, HDE, HT; unsigned char sr_data, cr_data, cr_data2, cr_data3; int A, B, C, D, E, F, temp, j; - if(HwDeviceExtension->jChipType < SIS_315H) { + if(HwInfo->jChipType < SIS_315H) { #ifdef SIS300 - InitTo300Pointer(SiS_Pr, HwDeviceExtension); + InitTo300Pointer(SiS_Pr, HwInfo); #else return 0; #endif } else { #ifdef SIS315H - InitTo310Pointer(SiS_Pr, HwDeviceExtension); + InitTo310Pointer(SiS_Pr, HwInfo); #else return 0; #endif } - temp = SiS_SearchModeID(SiS_Pr, ROMAddr, &ModeNo, &ModeIdIndex); - if(!temp) return 0; - + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return 0; + RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; RefreshRateTableIndex += (rateindex - 1); index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; @@ -5606,17 +5242,32 @@ sisfb_mode_rate_to_ddata(SiS_Private *Si C = (temp > 0) ? temp : (temp + 64); D = B - F - C; - - *left_margin = D * 8; - *right_margin = F * 8; - *hsync_len = C * 8; + + if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes == 320) && + ((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 200) || + (SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 240))) { + + /* Terrible hack, but the correct CRTC data for + * these modes only produces a black screen... + */ + *left_margin = (400 - 376); + *right_margin = (328 - 320); + *hsync_len = (376 - 328); + + } else { + + *left_margin = D * 8; + *right_margin = F * 8; + *hsync_len = C * 8; + + } sr_data = SiS_Pr->SiS_CRT1Table[index].CR[13]; cr_data = SiS_Pr->SiS_CRT1Table[index].CR[6]; - + cr_data2 = SiS_Pr->SiS_CRT1Table[index].CR[7]; - + /* Vertical total */ VT = (cr_data & 0xFF) | ((unsigned short) (cr_data2 & 0x01) << 8) | @@ -5683,7 +5334,7 @@ sisfb_mode_rate_to_ddata(SiS_Private *Si else *sync |= FB_SYNC_HOR_HIGH_ACT; - *vmode = FB_VMODE_NONINTERLACED; + *vmode = FB_VMODE_NONINTERLACED; if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x0080) *vmode = FB_VMODE_INTERLACED; else { @@ -5699,19 +5350,19 @@ sisfb_mode_rate_to_ddata(SiS_Private *Si j++; } } - -#if 0 /* That's bullshit, only the resolution needs to be shifted */ + if((*vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { +#if 0 /* Do this? */ *upper_margin <<= 1; *lower_margin <<= 1; *vsync_len <<= 1; +#endif } else if((*vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { *upper_margin >>= 1; *lower_margin >>= 1; *vsync_len >>= 1; - } -#endif - + } + return 1; } diff -puN drivers/video/sis/initdef.h~sisfb-update drivers/video/sis/initdef.h --- 25/drivers/video/sis/initdef.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/initdef.h 2004-01-22 03:06:55.000000000 -0800 @@ -1,13 +1,76 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/initdef.h,v 1.4 2000/12/02 01:16:17 dawes Exp $ */ - +/* $XFree86$ */ +/* + * Global definitions for init.c and init301.c + * + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the Linux kernel, the following license terms + * apply: + * + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Otherwise, the following license terms apply: + * + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) All advertising materials mentioning features or use of this software + * * must display the following acknowledgement: "This product includes + * * software developed by Thomas Winischhofer, Vienna, Austria." + * * 4) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * + */ #ifndef _INITDEF_ #define _INITDEF_ -#define SiS300 0x0300 -#define SiS540 0x5300 -#define SiS630 0x6300 -#define SiS730 0x6300 +#define IS_SIS330 (HwInfo->jChipType == SIS_330) +#define IS_SIS550 (HwInfo->jChipType == SIS_550) +#define IS_SIS650 (HwInfo->jChipType == SIS_650) /* All versions, incl 651, M65x */ +#define IS_SIS740 (HwInfo->jChipType == SIS_740) +#define IS_SIS651 (SiS_Pr->SiS_SysFlags & (SF_Is651 | SF_Is652)) +#define IS_SISM650 (SiS_Pr->SiS_SysFlags & (SF_IsM650 | SF_IsM652 | SF_IsM653)) +#define IS_SIS65x (IS_SIS651 || IS_SISM650) /* Only special versions of 65x */ +#define IS_SIS661 (HwInfo->jChipType == SIS_661) +#define IS_SIS741 (HwInfo->jChipType == SIS_741) +#define IS_SIS660 (HwInfo->jChipType == SIS_660) +#define IS_SIS760 (HwInfo->jChipType == SIS_760) +#define IS_SIS661741660760 (IS_SIS661 || IS_SIS741 || IS_SIS660 || IS_SIS760) +#define IS_SIS650740 ((HwInfo->jChipType >= SIS_650) && (HwInfo->jChipType < SIS_330)) +#define IS_SIS550650740 (IS_SIS550 || IS_SIS650740) +#define IS_SIS650740660 (IS_SIS650 || IS_SIS740 || IS_SIS661741660760) +#define IS_SIS550650740660 (IS_SIS550 || IS_SIS650740660) /* SiS_VBType */ #define VB_SIS301 0x0001 @@ -15,23 +78,41 @@ #define VB_SIS302B 0x0004 #define VB_SIS301LV 0x0008 #define VB_SIS302LV 0x0010 -#define VB_SIS30xLV VB_SIS301LV -#define VB_SIS30xNEW VB_SIS302LV +#define VB_SIS302ELV 0x0020 +#define VB_SIS301C 0x0040 #define VB_NoLCD 0x8000 -#define VB_SIS301BLV302BLV (VB_SIS301B|VB_SIS302B|VB_SIS301LV|VB_SIS302LV) -#define VB_SIS301B302B (VB_SIS301B|VB_SIS302B) -#define VB_SIS301LV302LV (VB_SIS301LV|VB_SIS302LV) - -#define IS_SIS650740 ((HwDeviceExtension->jChipType >= SIS_650) && (HwDeviceExtension->jChipType < SIS_330)) - -#define IS_SIS650 (HwDeviceExtension->jChipType == SIS_650) -#define IS_SIS740 (HwDeviceExtension->jChipType == SIS_740) -#define IS_SIS330 (HwDeviceExtension->jChipType == SIS_330) -#define IS_SIS550 (HwDeviceExtension->jChipType == SIS_550) - -#define CRT1Len 17 -#define LVDSCRT1Len 15 -#define CHTVRegDataLen 5 +#define VB_SIS301BLV302BLV (VB_SIS301B|VB_SIS301C|VB_SIS302B|VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV) +#define VB_SIS301B302B (VB_SIS301B|VB_SIS301C|VB_SIS302B) +#define VB_SIS301LV302LV (VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV) +#define VB_SISVB (VB_SIS301 | VB_SIS301BLV302BLV) + +/* VBInfo */ +#define SetSimuScanMode 0x0001 /* CR 30 */ +#define SwitchCRT2 0x0002 +#define SetCRT2ToAVIDEO 0x0004 +#define SetCRT2ToSVIDEO 0x0008 +#define SetCRT2ToSCART 0x0010 +#define SetCRT2ToLCD 0x0020 +#define SetCRT2ToRAMDAC 0x0040 +#define SetCRT2ToHiVision 0x0080 /* for SiS bridge */ +#define SetCRT2ToCHYPbPr SetCRT2ToHiVision /* for Chrontel */ +#define SetNTSCTV 0x0000 /* CR 31 */ +#define SetPALTV 0x0100 /* Deprecated here, now in TVMode */ +#define SetInSlaveMode 0x0200 +#define SetNotSimuMode 0x0400 +#define SetNotSimuTVMode SetNotSimuMode +#define SetDispDevSwitch 0x0800 +#define SetCRT2ToYPbPr525750 0x0800 +#define LoadDACFlag 0x1000 +#define DisableCRT2Display 0x2000 +#define DriverMode 0x4000 +#define HotKeySwitch 0x8000 +#define SetCRT2ToLCDA 0x8000 + +/* v-- Needs change in sis_vga.c if changed (GPIO) --v */ +#define SetCRT2ToTV (SetCRT2ToYPbPr525750|SetCRT2ToHiVision|SetCRT2ToSCART|SetCRT2ToSVIDEO|SetCRT2ToAVIDEO) +#define SetCRT2ToTVNoYPbPrHiVision (SetCRT2ToSCART | SetCRT2ToSVIDEO | SetCRT2ToAVIDEO) +#define SetCRT2ToTVNoHiVision (SetCRT2ToYPbPr525750 | SetCRT2ToSCART | SetCRT2ToSVIDEO | SetCRT2ToAVIDEO) /* SiS_ModeType */ #define ModeText 0x00 @@ -59,60 +140,66 @@ #define DoubleScanMode 0x8000 /* Infoflag */ -#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 #define SupportCHTV 0x0800 -#define SupportTV1024 0x0800 +#define Support64048060Hz 0x0800 /* Special for 640x480 LCD */ +#define SupportHiVision 0x0010 +#define SupportYPbPr 0x1000 /* TODO */ +#define SupportLCD 0x0020 +#define SupportRAMDAC2 0x0040 /* All (<= 100Mhz) */ +#define SupportRAMDAC2_135 0x0100 /* All except DH (<= 135Mhz) */ +#define SupportRAMDAC2_162 0x0200 /* B, C (<= 162Mhz) */ +#define SupportRAMDAC2_202 0x0400 /* C (<= 202Mhz) */ #define InterlaceMode 0x0080 -#define SupportHiVisionTV2 0x1000 #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 - -/* VBInfo */ -#define SetSimuScanMode 0x0001 /* CR 30 */ -#define SwitchToCRT2 0x0002 -#define SetCRT2ToAVIDEO 0x0004 -#define SetCRT2ToSVIDEO 0x0008 -#define SetCRT2ToSCART 0x0010 -#define SetCRT2ToLCD 0x0020 -#define SetCRT2ToRAMDAC 0x0040 -#define SetCRT2ToHiVisionTV 0x0080 -#define SetCRT2ToTV 0x009C /* alias */ -#define SetNTSCTV 0x0000 /* CR 31 */ -#define SetPALTV 0x0100 -#define SetInSlaveMode 0x0200 -#define SetNotSimuMode 0x0400 -#define SetNotSimuTVMode 0x0400 -#define SetDispDevSwitch 0x0800 -#define LoadDACFlag 0x1000 -#define SetCHTVOverScan 0x1000 /* TW: Re-defined (from 0x8000) */ -#define DisableCRT2Display 0x2000 -#define CRT2DisplayFlag 0x2000 -#define DriverMode 0x4000 -#define HotKeySwitch 0x8000 /* TW: ? */ -#define SetCRT2ToLCDA 0x8000 -#define PanelRGB18Bit 0x0100 -#define PanelRGB24Bit 0x0000 - -#define TVOverScan 0x10 /* Bit in CR35 (300 series only) */ -#define TVOverScanShift 4 -#define ClearBufferFlag 0x20 +/* SetFlag */ +#define ProgrammingCRT2 0x0001 +#define LowModeTests 0x0002 +/* #define TVSimuMode 0x0002 - deprecated */ +/* #define RPLLDIV2XO 0x0004 - deprecated */ +#define LCDVESATiming 0x0008 +#define EnableLVDSDDA 0x0010 +#define SetDispDevSwitchFlag 0x0020 +#define CheckWinDos 0x0040 +#define SetDOSMode 0x0080 + +/* TVMode flag */ +#define TVSetPAL 0x0001 +#define TVSetNTSCJ 0x0002 +#define TVSetPALM 0x0004 +#define TVSetPALN 0x0008 +#define TVSetCHOverScan 0x0010 +#define TVSetYPbPr525i 0x0020 +#define TVSetYPbPr525p 0x0040 +#define TVSetYPbPr750p 0x0080 +#define TVSetHiVision 0x0100 /* = 1080i, software-wise identical */ +#define TVSetTVSimuMode 0x0800 +#define TVRPLLDIV2XO 0x1000 +#define TVSetNTSC1024 0x2000 + +/* YPbPr flag (>=315, <661) */ +#define YPbPr525p 0x0001 /* 525p */ +#define YPbPr750p 0x0002 /* 750p */ +#define YPbPr525i 0x0004 /* 525p */ +#define YPbPrHiVision 0x0008 /* HiVision or 1080i (bridge type dependent) */ +#define YPbPrModeMask (YPbPr750p | YPbPr525p | YPbPr525i | YPbPrHiVision) + +/* SysFlags (to identify special versions) */ +#define SF_Is651 0x0001 +#define SF_IsM650 0x0002 +#define SF_Is652 0x0004 +#define SF_IsM652 0x0008 +#define SF_IsM653 0x0010 +#define SF_IsM661 0x0020 +#define SF_IsM741 0x0040 +#define SF_IsM760 0x0080 -/* CR32 (Newer 630, and 310/325 series) +/* CR32 (Newer 630, and 315 series) [0] VB connected with CVBS [1] VB connected with SVHS @@ -121,9 +208,32 @@ [4] VB connected with CRT2 (secondary VGA) [5] CRT1 monitor is connected [6] VB connected with Hi-Vision TV - [7] VB connected with DVI combo connector + [7] <= 330: VB connected with DVI combo connector + >= 661: VB connected to YPbPr +*/ + +/* CR35 (300 series only) */ +#define TVOverScan 0x10 +#define TVOverScanShift 4 + +/* CR35 (661 series only) + + [0] 1 = PAL, 0 = NTSC + [1] 1 = NTSC-J (if D0 = 0) + [2] 1 = PALM (if D0 = 1) + [3] 1 = PALN (if D0 = 1) + [4] 1 = Overscan (Chrontel only) + [7:5] (only if D2 in CR38 is set) + 000 525i + 001 525p + 010 750p + 011 1080i (or HiVision on 301, 301B) + + These bits are being translated to TVMode flag. +*/ +/* CR37 [0] Set 24/18 bit (0/1) RGB to LVDS/TMDS transmitter (set by BIOS) @@ -134,11 +244,14 @@ 011 LVDS + Tumpion Zurac 100 LVDS + Chrontel 7005 110 Chrontel 7005 - 310/325 series + 315/330 series 001 SiS30x (never seen) 010 LVDS 011 LVDS + Chrontel 7019 + 660 series [2:1] only: + reserved (now in CR38) All other combinations reserved + [3] 661 only: Pass 1:1 data [4] LVDS: 0: Panel Link expands / 1: Panel Link does not expand 30x: 0: Bridge scales / 1: Bridge does not scale = Panel scales (if possible) [5] LCD polarity select @@ -155,36 +268,60 @@ /* CR37: LCDInfo */ #define LCDRGB18Bit 0x0001 #define LCDNonExpanding 0x0010 +#define LCDSync 0x0020 +#define LCDPass11 0x0100 +#define LCDDualLink 0x0200 + #define DontExpandLCD LCDNonExpanding #define LCDNonExpandingShift 4 #define DontExpandLCDShift LCDNonExpandingShift -#define LCDSync 0x0020 -#define LCDPass11 0x0100 #define LCDSyncBit 0x00e0 #define LCDSyncShift 6 -/* CR38 (310/325 series) */ -#define EnableDualEdge 0x01 -#define SetToLCDA 0x02 /* LCD channel A (302B/LV and 650+LVDS only) */ -#define EnableSiSHiVision 0x04 /* HiVision (HDTV) on SiS bridge */ -#define EnableLVDSScart 0x04 /* Scart on Ch7019 (unofficial definition - TW) */ -#define EnableLVDSHiVision 0x08 /* YPbPr color format (480i HDTV); only on 650/Ch7019 systems */ -#define SiSHiVision1 0x10 /* See SetHiVision() */ -#define SiSHiVision2 0x20 +/* CR38 (315 series) */ +#define EnableDualEdge 0x01 +#define SetToLCDA 0x02 /* LCD channel A (301C/302B/30x(E)LV and 650+LVDS only) */ +#define EnableCHScart 0x04 /* Scart on Ch7019 (unofficial definition - TW) */ +#define EnableCHYPbPr 0x08 /* YPbPr on Ch7019 (480i HDTV); only on 650/Ch7019 systems */ +#define EnableSiSYPbPr 0x08 /* Enable YPbPr mode (30xLV/301C only) */ +#define EnableYPbPr525i 0x00 /* Enable 525i YPbPr mode (30xLV/301C only) (mask 0x30) */ +#define EnableYPbPr525p 0x10 /* Enable 525p YPbPr mode (30xLV/301C only) (mask 0x30) */ +#define EnableYPbPr750p 0x20 /* Enable 750p YPbPr mode (30xLV/301C only) (mask 0x30) */ +#define EnableYPbPr1080i 0x30 /* Enable 1080i YPbPr mode (30xLV/301C only) (mask 0x30) */ #define EnablePALM 0x40 /* 1 = Set PALM */ #define EnablePALN 0x80 /* 1 = Set PALN */ +#define EnableNTSCJ EnablePALM /* Not BIOS */ -#define SetSCARTOutput 0x01 -#define BoardTVType 0x02 +/* CR38 (661 and later) + D[7:5] 000 No VB + 001 301 series VB + 010 LVDS + 011 Chrontel 7019 + 100 Conexant + D2 Enable YPbPr output (see CR35) + D[1:0] LCDA (like before) +*/ #define EnablePALMN 0x40 /* Romflag: 1 = Allow PALM/PALN */ -/* CR39 (650) */ +/* CR39 (650 only) */ #define LCDPass1_1 0x01 /* LVDS only; set by driver to pass 1:1 data to LVDS output */ -#define Enable302LV_DualLink 0x04 /* 30xNEW (302LV) only; set by mode switching function */ +#define Enable302LV_DualLink 0x04 /* 302LV only; enable dual link */ + +/* CR39 (661 and later) + D[1:0] YPbPr Aspect Ratio + 00 4:3 letterbox + 01 4:3 + 10 16:9 + 11 4:3 +*/ +/* CR3B (651+301C) + D[1:0] YPbPr Aspect Ratio + ? +*/ -/* CR79 (310/325 series only) +/* CR79 (315/330 series only; not 661 and later) [3-0] Notify driver 0001 Mode Switch event (set by BIOS) 0010 Epansion On/Off event @@ -202,16 +339,6 @@ [7] TV UnderScan/OverScan (set by BIOS) */ -/* SetFlag */ -#define ProgrammingCRT2 0x01 -#define TVSimuMode 0x02 -#define RPLLDIV2XO 0x04 -#define LCDVESATiming 0x08 -#define EnableLVDSDDA 0x10 -#define SetDispDevSwitchFlag 0x20 -#define CheckWinDos 0x40 -#define SetDOSMode 0x80 - /* LCDResInfo */ #define Panel300_800x600 0x01 /* CR36 */ #define Panel300_1024x768 0x02 @@ -220,7 +347,10 @@ #define Panel300_640x480 0x05 #define Panel300_1024x600 0x06 #define Panel300_1152x768 0x07 -#define Panel300_320x480 0x08 /* fstn - TW: This is fake, can be any */ +#define Panel300_1280x768 0x0a +#define Panel300_320x480 0x0e /* fstn - TW: This is fake, can be any */ +#define Panel300_Custom 0x0f +#define Panel300_Barco1366 0x10 #define Panel310_800x600 0x01 #define Panel310_1024x768 0x02 @@ -231,9 +361,12 @@ #define Panel310_1280x960 0x07 #define Panel310_1152x768 0x08 /* LVDS only */ #define Panel310_1400x1050 0x09 -#define Panel310_1280x768 0x0a /* LVDS only */ +#define Panel310_1280x768 0x0a #define Panel310_1600x1200 0x0b -#define Panel310_320x480 0x0c /* fstn - TW: This is fake, can be any */ +#define Panel310_640x480_2 0x0c +#define Panel310_640x480_3 0x0d +#define Panel310_320x480 0x0e /* fstn - TW: This is fake, can be any */ +#define Panel310_Custom 0x0f #define Panel_800x600 0x01 /* Unified values */ #define Panel_1024x768 0x02 @@ -246,23 +379,50 @@ #define Panel_1400x1050 0x09 #define Panel_1280x768 0x0a /* LVDS only */ #define Panel_1600x1200 0x0b -#define Panel_320x480 0x0c /* fstn - TW: This is fake, can be any */ +#define Panel_640x480_2 0x0c +#define Panel_640x480_3 0x0d +#define Panel_320x480 0x0e /* fstn - TW: This is fake, can be any */ +#define Panel_Custom 0x0f +#define Panel_Barco1366 0x10 +#define Panel_848x480 0x11 +#define Panel_1280x800 0x12 /* 661etc: 0x0c */ +#define Panel_1680x1050 0x13 /* 661etc: 0x0d */ + +/* Index in ModeResInfo table */ +#define SIS_RI_320x200 0 +#define SIS_RI_320x240 1 +#define SIS_RI_320x400 2 +#define SIS_RI_400x300 3 +#define SIS_RI_512x384 4 +#define SIS_RI_640x400 5 +#define SIS_RI_640x480 6 +#define SIS_RI_800x600 7 +#define SIS_RI_1024x768 8 +#define SIS_RI_1280x1024 9 +#define SIS_RI_1600x1200 10 +#define SIS_RI_1920x1440 11 +#define SIS_RI_2048x1536 12 +#define SIS_RI_720x480 13 +#define SIS_RI_720x576 14 +#define SIS_RI_1280x960 15 +#define SIS_RI_800x480 16 +#define SIS_RI_1024x576 17 +#define SIS_RI_1280x720 18 +#define SIS_RI_856x480 19 +#define SIS_RI_1280x768 20 +#define SIS_RI_1400x1050 21 +#define SIS_RI_1152x864 22 /* Up to this SiS conforming */ +#define SIS_RI_848x480 23 +#define SIS_RI_1360x768 24 +#define SIS_RI_1024x600 25 +#define SIS_RI_1152x768 26 +#define SIS_RI_768x576 27 +#define SIS_RI_1360x1024 28 -#define ExtChipType 0x0e -#define ExtChip301 0x02 -#define ExtChipLVDS 0x04 -#define ExtChipTrumpion 0x06 -#define ExtChipCH7005 0x08 -#define ExtChipMitacTV 0x0a /* TW: Incorrect, 0x0a = Chrontel 7005 only */ - -#define IsM650 0x80 /* TW: CR5F */ - -#define LCDDataLen 8 -#define HiTVDataLen 12 -#define TVDataLen 16 -#define SetPALTV 0x0100 -#define HalfDCLK 0x1000 /* modeflag */ +/* CR5F */ +#define IsM650 0x80 +/* Timing data */ #define NTSCHT 1716 #define NTSC2HT 1920 #define NTSCVT 525 @@ -275,37 +435,45 @@ #define ExtHiTVHT 2100 #define ExtHiTVVT 1125 -#define VCLKStartFreq 25 -#define SoftDramType 0x80 +/* Indices in (VB)VCLKData tables */ -#define VCLK40 0x04 /* Index in VCLKData array */ -#define VCLK65 0x09 /* Index in VCLKData array */ -#define VCLK108_2 0x14 /* Index in VCLKData array */ -#define TVVCLKDIV2 0x21 /* Indices in (VB)VCLKData arrays */ -#define TVVCLK 0x22 -#define HiTVVCLKDIV2 0x23 -#define HiTVVCLK 0x24 -#define HiTVSimuVCLK 0x25 -#define HiTVTextVCLK 0x26 +#define VCLK28 0x00 /* Index in VCLKData table (300 and 315) */ +#define VCLK40 0x04 /* Index in VCLKData table (300 and 315) */ +#define VCLK65_300 0x09 /* Index in VCLKData table (300) */ +#define VCLK108_2_300 0x14 /* Index in VCLKData table (300) */ +#define VCLK81_300 0x3f /* Index in VCLKData table (300) */ +#define VCLK108_3_300 0x42 /* Index in VCLKData table (300) */ +#define VCLK100_300 0x43 /* Index in VCLKData table (300) */ +#define VCLK34_300 0x3d /* Index in VCLKData table (300) */ +#define VCLK65_315 0x0b /* Index in (VB)VCLKData table (315) */ +#define VCLK108_2_315 0x19 /* Index in (VB)VCLKData table (315) */ +#define VCLK81_315 0x5b /* Index in (VB)VCLKData table (315) */ +#define VCLK162_315 0x21 /* Index in (VB)VCLKData table (315) */ +#define VCLK108_3_315 0x45 /* Index in VBVCLKData table (315) */ +#define VCLK100_315 0x46 /* Index in VBVCLKData table (315) */ +#define VCLK34_315 0x55 /* Index in VBVCLKData table (315) */ +#define VCLK68_315 0x0d + +#define TVCLKBASE_300 0x21 /* Indices on TV clocks in VCLKData table (300) */ +#define TVCLKBASE_315 0x3a /* Indices on TV clocks in (VB)VCLKData table (315) */ +#define TVVCLKDIV2 0x00 /* Index relative to TVCLKBASE */ +#define TVVCLK 0x01 /* Index relative to TVCLKBASE */ +#define HiTVVCLKDIV2 0x02 /* Index relative to TVCLKBASE */ +#define HiTVVCLK 0x03 /* Index relative to TVCLKBASE */ +#define HiTVSimuVCLK 0x04 /* Index relative to TVCLKBASE */ +#define HiTVTextVCLK 0x05 /* Index relative to TVCLKBASE */ +#define YPbPr750pVCLK 0x0f /* NOT relative to TVCLKBASE ! */ -#define LoadDACFlag 0x1000 -#define AfterLockCRT2 0x4000 -#define SetCRT2ToAVIDEO 0x0004 -#define SetCRT2ToSCART 0x0010 -#define Ext2StructSize 5 +/* ------------------------------ */ #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 SIS_VIDEO_CAPTURE 0x00 - 0x30 +#define SIS_VIDEO_PLAYBACK 0x02 - 0x30 #define SIS_CRT2_PORT_04 0x04 - 0x30 #define SIS_CRT2_PORT_10 0x10 - 0x30 #define SIS_CRT2_PORT_12 0x12 - 0x30 @@ -318,8 +486,11 @@ #define ADR_CHTVVCLKPtr 0x216 #define ADR_CHTVRegDataPtr 0x218 +#define LCDDataLen 8 +#define HiTVDataLen 12 +#define TVDataLen 16 + #define LVDSDataLen 6 -#define EnableLVDSDDA 0x10 #define LVDSDesDataLen 3 #define ActiveNonExpanding 0x40 #define ActiveNonExpandingShift 6 @@ -330,8 +501,6 @@ #define SoftSettingAddr 0x52 #define ModeSettingAddr 0x53 -#define SelectCRT1Rate 0x4 - #define _PanelType00 0x00 #define _PanelType01 0x08 #define _PanelType02 0x10 @@ -350,7 +519,8 @@ #define _PanelType0F 0x78 #define PRIMARY_VGA 0 /* 1: SiS is primary vga 0:SiS is secondary vga */ -#define BIOSIDCodeAddr 0x235 /* TW: Offsets to ptrs in BIOS image */ + +#define BIOSIDCodeAddr 0x235 /* Offsets to ptrs in BIOS image */ #define OEMUtilIDCodeAddr 0x237 #define VBModeIDTableAddr 0x239 #define OEMTVPtrAddr 0x241 @@ -393,7 +563,7 @@ /* ============================================================= - for 310/325 series + for 315 series ============================================================= */ #define SoftDRAMType 0x80 diff -puN drivers/video/sis/init.h~sisfb-update drivers/video/sis/init.h --- 25/drivers/video/sis/init.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/init.h 2004-01-22 03:06:55.000000000 -0800 @@ -1,19 +1,66 @@ +/* $XFree86$ */ +/* + * Data and prototypes for init.c + * + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the Linux kernel, the following license terms + * apply: + * + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Otherwise, the following license terms apply: + * + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) All advertising materials mentioning features or use of this software + * * must display the following acknowledgement: "This product includes + * * software developed by Thomas Winischhofer, Vienna, Austria." + * * 4) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * + */ + #ifndef _INIT_ #define _INIT_ #include "osdef.h" + #include "initdef.h" #include "vgatypes.h" #include "vstruct.h" -#ifdef TC -#include -#include -#include -#include -#include -#endif - #ifdef LINUX_XF86 #include "xf86.h" #include "xf86Pci.h" @@ -24,6 +71,9 @@ #endif #ifdef LINUX_KERNEL +#ifdef SIS_CP +#undef SIS_CP +#endif #include #include #include @@ -36,18 +86,38 @@ #endif #endif -#ifdef WIN2000 -#include -#include -#include -#include "dderror.h" -#include "devioctl.h" -#include "miniport.h" -#include "ntddvdeo.h" -#include "video.h" -#include "sisv.h" -#include "tools.h" -#endif +/* Mode numbers */ +const USHORT ModeIndex_320x200[] = {0x59, 0x41, 0x00, 0x4f}; +const USHORT ModeIndex_320x240[] = {0x50, 0x56, 0x00, 0x53}; +const USHORT ModeIndex_320x240_FSTN[] = {0x5a, 0x5b, 0x00, 0x00}; /* FSTN */ +const USHORT ModeIndex_400x300[] = {0x51, 0x57, 0x00, 0x54}; +const USHORT ModeIndex_512x384[] = {0x52, 0x58, 0x00, 0x5c}; +const USHORT ModeIndex_640x400[] = {0x2f, 0x5d, 0x00, 0x5e}; +const USHORT ModeIndex_640x480[] = {0x2e, 0x44, 0x00, 0x62}; +const USHORT ModeIndex_720x480[] = {0x31, 0x33, 0x00, 0x35}; +const USHORT ModeIndex_720x576[] = {0x32, 0x34, 0x00, 0x36}; +const USHORT ModeIndex_768x576[] = {0x5f, 0x60, 0x00, 0x61}; +const USHORT ModeIndex_800x480[] = {0x70, 0x7a, 0x00, 0x76}; +const USHORT ModeIndex_800x600[] = {0x30, 0x47, 0x00, 0x63}; +const USHORT ModeIndex_848x480[] = {0x39, 0x3b, 0x00, 0x3e}; +const USHORT ModeIndex_856x480[] = {0x3f, 0x42, 0x00, 0x45}; +const USHORT ModeIndex_1024x768[] = {0x38, 0x4a, 0x00, 0x64}; +const USHORT ModeIndex_1024x576[] = {0x71, 0x74, 0x00, 0x77}; +const USHORT ModeIndex_1024x600[] = {0x20, 0x21, 0x00, 0x22}; /* 300 series only */ +const USHORT ModeIndex_1280x1024[] = {0x3a, 0x4d, 0x00, 0x65}; +const USHORT ModeIndex_1280x960[] = {0x7c, 0x7d, 0x00, 0x7e}; +const USHORT ModeIndex_1152x768[] = {0x23, 0x24, 0x00, 0x25}; /* 300 series only */ +const USHORT ModeIndex_1152x864[] = {0x29, 0x2a, 0x00, 0x2b}; +const USHORT ModeIndex_300_1280x768[] = {0x55, 0x5a, 0x00, 0x5b}; +const USHORT ModeIndex_310_1280x768[] = {0x23, 0x24, 0x00, 0x25}; +const USHORT ModeIndex_1280x720[] = {0x79, 0x75, 0x00, 0x78}; +const USHORT ModeIndex_1360x768[] = {0x48, 0x4b, 0x00, 0x4e}; +const USHORT ModeIndex_300_1360x1024[]= {0x67, 0x6f, 0x00, 0x72}; /* 300 series, BARCO only */ +const USHORT ModeIndex_1400x1050[] = {0x26, 0x27, 0x00, 0x28}; /* 315 series only */ +const USHORT ModeIndex_1600x1200[] = {0x3c, 0x3d, 0x00, 0x66}; +const USHORT ModeIndex_1920x1440[] = {0x68, 0x69, 0x00, 0x6b}; +const USHORT ModeIndex_300_2048x1536[]= {0x6c, 0x6d, 0x00, 0x00}; +const USHORT ModeIndex_310_2048x1536[]= {0x6c, 0x6d, 0x00, 0x6e}; const USHORT SiS_DRAMType[17][5]={ {0x0C,0x0A,0x02,0x40,0x39}, @@ -144,187 +214,2650 @@ const USHORT SiS_VGA_DAC[] = 0x0B,0x0C,0x0D,0x0F,0x10 }; -void SiS_SetReg1(USHORT, USHORT, USHORT); -void SiS_SetReg2(SiS_Private *, USHORT, USHORT, USHORT); -void SiS_SetReg3(USHORT, USHORT); -void SiS_SetReg4(USHORT, ULONG); -void SiS_SetReg5(USHORT, USHORT); -UCHAR SiS_GetReg1(USHORT, USHORT); -UCHAR SiS_GetReg2(USHORT); -ULONG SiS_GetReg3(USHORT); -USHORT SiS_GetReg4(USHORT); -void SiS_ClearDAC(SiS_Private *SiS_Pr, ULONG); -void SiS_SetMemoryClock(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetDRAMModeRegister(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -BOOLEAN SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo); -void SiS_IsLowResolution(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); - -#ifdef SIS300 -void SiS_SetDRAMSize_300(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -USHORT SiS_ChkBUSWidth_300(SiS_Private *SiS_Pr, ULONG FBAddress); +static const SiS_StResInfoStruct SiS_StResInfo[]= +{ + { 640,400}, + { 640,350}, + { 720,400}, + { 720,350}, + { 640,480} +}; + +static const SiS_ModeResInfoStruct SiS_ModeResInfo[] = +{ + { 320, 200, 8, 8}, /* 0x00 */ + { 320, 240, 8, 8}, /* 0x01 */ + { 320, 400, 8, 8}, /* 0x02 */ + { 400, 300, 8, 8}, /* 0x03 */ + { 512, 384, 8, 8}, /* 0x04 */ + { 640, 400, 8,16}, /* 0x05 */ + { 640, 480, 8,16}, /* 0x06 */ + { 800, 600, 8,16}, /* 0x07 */ + { 1024, 768, 8,16}, /* 0x08 */ + { 1280,1024, 8,16}, /* 0x09 */ + { 1600,1200, 8,16}, /* 0x0a */ + { 1920,1440, 8,16}, /* 0x0b */ + { 2048,1536, 8,16}, /* 0x0c */ + { 720, 480, 8,16}, /* 0x0d */ + { 720, 576, 8,16}, /* 0x0e */ + { 1280, 960, 8,16}, /* 0x0f */ + { 800, 480, 8,16}, /* 0x10 */ + { 1024, 576, 8,16}, /* 0x11 */ + { 1280, 720, 8,16}, /* 0x12 */ + { 856, 480, 8,16}, /* 0x13 */ + { 1280, 768, 8,16}, /* 0x14 */ + { 1400,1050, 8,16}, /* 0x15 */ + { 1152, 864, 8,16}, /* 0x16 */ + { 848, 480, 8,16}, /* 0x17 */ + { 1360, 768, 8,16}, /* 0x18 */ + { 1024, 600, 8,16}, /* 0x19 */ + { 1152, 768, 8,16}, /* 0x1a */ + { 768, 576, 8,16}, /* 0x1b */ + { 1360,1024, 8,16} /* 0x1c */ +}; + +static SiS_StandTableStruct SiS_StandTable[]= +{ +/* 0x00: MD_0_200 */ + { + 0x28,0x18,0x08,0x0800, + {0x09,0x03,0x00,0x02}, + 0x63, + {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x01: MD_1_200 */ + { + 0x28,0x18,0x08,0x0800, + {0x09,0x03,0x00,0x02}, + 0x63, + {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x02: MD_2_200 */ + { + 0x50,0x18,0x08,0x1000, + {0x01,0x03,0x00,0x02}, + 0x63, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x03: MD_3_200 - mode 0x03 - 0 */ + { + 0x50,0x18,0x08,0x1000, + {0x01,0x03,0x00,0x02}, + 0x63, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x04: MD_4 */ + { + 0x28,0x18,0x08,0x4000, + {0x09,0x03,0x00,0x02}, + 0x63, + {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, /* 0x2c is 2b for 300 */ + 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2, + 0xff}, + {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x01,0x00,0x03,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00, + 0xff} + }, +/* 0x05: MD_5 */ + { + 0x28,0x18,0x08,0x4000, + {0x09,0x03,0x00,0x02}, + 0x63, + {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, /* 0x2c is 2b for 300 */ + 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2, + 0xff}, + {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x01,0x00,0x03,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00, + 0xff} + }, +/* 0x06: MD_6 */ + { + 0x50,0x18,0x08,0x4000, + {0x01,0x01,0x00,0x06}, + 0x63, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, /* 55,81 is 54,80 for 300 */ + 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2, + 0xff}, + {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17, + 0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17, + 0x01,0x00,0x01,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00, + 0xff} + }, +/* 0x07: MD_7 */ + { + 0x50,0x18,0x0e,0x1000, + {0x00,0x03,0x00,0x03}, + 0xa6, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, + 0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3, + 0xff}, + {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x0e,0x00,0x0f,0x08}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00, + 0xff} + }, +/* 0x08: MDA_DAC */ + { + 0x00,0x00,0x00,0x0000, + {0x00,0x00,0x00,0x15}, + 0x15, + {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, + 0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f, + 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00, + 0x00}, + {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15, + 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, + 0x15,0x15,0x15,0x15}, + {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, + 0x3f} + }, +/* 0x09: CGA_DAC */ + { + 0x00,0x10,0x04,0x0114, + {0x11,0x09,0x15,0x00}, + 0x10, + {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a, + 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a, + 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10, + 0x04}, + {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04, + 0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e, + 0x3e,0x2b,0x3b,0x2f}, + {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f, + 0x3f} + }, +/* 0x0a: EGA_DAC */ + { + 0x00,0x10,0x04,0x0114, + {0x11,0x05,0x15,0x20}, + 0x30, + {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18, + 0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38, + 0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12, + 0x06}, + {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26, + 0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e, + 0x1e,0x0b,0x1b,0x0f}, + {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f, + 0x3f} + }, +/* 0x0b: VGA_DAC */ + { + 0x00,0x10,0x04,0x0114, + {0x11,0x09,0x15,0x2a}, + 0x3a, + {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05, + 0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20, + 0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10, + 0x1f}, + {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d, + 0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15, + 0x1c,0x0e,0x11,0x15}, + {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00, + 0x04} + }, +/* 0x0c */ + { + 0x08,0x0c,0x10,0x0a08, + {0x0c,0x0e,0x10,0x0b}, + 0x0c, + {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00, + 0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00, + 0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00, + 0x06}, + {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08, + 0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00} + }, +/* 0x0d: MD_D */ + { + 0x28,0x18,0x08,0x2000, + {0x09,0x0f,0x00,0x06}, + 0x63, + {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, /* 2c is 2b for 300 */ + 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x01,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, + 0xff} + }, +/* 0x0e: MD_E */ + { + 0x50,0x18,0x08,0x4000, + {0x01,0x0f,0x00,0x06}, + 0x63, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, /* 55,81 is 54,80 for 300 */ + 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x01,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, + 0xff} + }, +/* 0x0f: ExtVGATable - modes > 0x13 */ + { + 0x00,0x00,0x00,0x0000, + {0x01,0x0f,0x00,0x0e}, + 0x23, + {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, + 0x01,0x00,0x00,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, + 0xff} + }, +/* 0x10: ROM_SAVEPTR - totally different for 300 */ + { + 0x9f,0x3b,0x00,0x00c0, + {0x00,0x00,0x00,0x00}, + 0x00, + {0x00,0x00,0x00,0x00,0x00,0x00,0xbb,0x3f, + 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x1a,0x00,0xac,0x3e,0x00,0xc0, + 0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00} + }, +/* 0x11: MD_F */ + { + 0x50,0x18,0x0e,0x8000, + {0x01,0x0f,0x00,0x06}, + 0xa2, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, /* 55,81 is 54,80 on 300 */ + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3, /* 82,84 is 83,85 on 300 */ + 0xff}, + {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00, + 0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00, + 0x0b,0x00,0x05,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05, + 0xff} + }, +/* 0x12: MD_10 */ + { + 0x50,0x18,0x0e,0x8000, + {0x01,0x0f,0x00,0x06}, + 0xa3, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, /* 55,81 is 54,80 on 300 */ + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3, /* 82,84 is 83,85 on 300 */ + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x01,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, + 0xff} + }, +/* 0x13: MD_0_350 */ + { + 0x28,0x18,0x0e,0x0800, + {0x09,0x03,0x00,0x02}, + 0xa3, + {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f, /* b1 is a0 on 300 */ + 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, + 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x14: MD_1_350 */ + { + 0x28,0x18,0x0e,0x0800, + {0x09,0x03,0x00,0x02}, + 0xa3, + {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, + 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x15: MD_2_350 */ + { + 0x50,0x18,0x0e,0x1000, + {0x01,0x03,0x00,0x02}, + 0xa3, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, + 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x16: MD_3_350 - mode 0x03 - 1 */ + { + 0x50,0x18,0x0e,0x1000, + {0x01,0x03,0x00,0x02}, + 0xa3, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, + 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x17: MD_0_1_400 */ + { + 0x28,0x18,0x10,0x0800, + {0x08,0x03,0x00,0x02}, + 0x67, + {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f, /* b1 is a0 on 300 */ + 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x0c,0x00,0x0f,0x08}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x18: MD_2_3_400 - mode 0x03 - 2 */ + { + 0x50,0x18,0x10,0x1000, + {0x00,0x03,0x00,0x02}, + 0x67, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x0c,0x00,0x0f,0x08}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x19: MD_7_400 */ + { + 0x50,0x18,0x10,0x1000, + {0x00,0x03,0x00,0x02}, + 0x66, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x0e,0x00,0x0f,0x08}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00, + 0xff} + }, +/* 0x1a: MD_11 */ + { + 0x50,0x1d,0x10,0xa000, + {0x01,0x0f,0x00,0x06}, + 0xe3, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, /* 55,81 is 54,80 on 300 */ + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xc3, /* e9,8b is ea,8c on 300 */ + 0xff}, + {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, + 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, + 0x01,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01, + 0xff} + }, +/* 0x1b: ExtEGATable - Modes <= 0x02 */ + { + 0x50,0x1d,0x10,0xa000, + {0x01,0x0f,0x00,0x06}, + 0xe3, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, /* 55,81 is 54,80 on 300 */ + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xe3, /* e9,8b is ea,8c on 300 */ + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x01,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, + 0xff} + }, +/* 0x1c: MD_13 */ + { + 0x28,0x18,0x08,0x2000, + {0x01,0x0f,0x00,0x0e}, + 0x63, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, /* 55,81 is 54,80 on 300 */ + 0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, + 0x41,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, + 0xff} + } +}; + +/**************************************************************/ +/* SIS VIDEO BRIDGE ----------------------------------------- */ +/**************************************************************/ + +static const UCHAR SiS_SoftSetting = 0x30; /* RAM setting */ + +static const UCHAR SiS_OutputSelect = 0x40; + +static const UCHAR SiS_NTSCTiming[] = { + 0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c, + 0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a, + 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b, + 0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17, + 0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02, + 0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50, + 0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00 +}; + +static const UCHAR SiS_PALTiming[] = { + 0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70, + 0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d, + 0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b, + 0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17, + 0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02, + 0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63, + 0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00 +}; + +static const UCHAR SiS_HiTVExtTiming[] = { + 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, + 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, + 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, + 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, + 0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40, + 0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d, + 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 +}; + +static const UCHAR SiS_HiTVSt1Timing[] = { + 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, + 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, + 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, + 0x65,0x90,0x7b,0xa8,0x03,0xf0,0x87,0x03, + 0x11,0x15,0x11,0xcf,0x10,0x11,0xcf,0x10, + 0x35,0x35,0x3b,0x69,0x1d,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x86, + 0xaf,0x5d,0x0e,0x00,0xfc,0xff,0x2d,0x00 +}; + +static const UCHAR SiS_HiTVSt2Timing[] = { + 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, + 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, + 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, + 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, + 0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40, + 0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d, + 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 +}; + +#if 0 +static const UCHAR SiS_HiTVTextTiming[] = { + 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, + 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, + 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, + 0x65,0x90,0xe7,0xbc,0x03,0x0c,0x97,0x03, + 0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20, + 0xc8,0xc8,0x3b,0xd2,0x26,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96, + 0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00 +}; #endif -#ifdef SIS315H -UCHAR SiS_Get310DRAMType(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_DDR_MRS(SiS_Private *SiS_Pr); -void SiS_SDR_MRS(SiS_Private *SiS_Pr); -void SiS_DisableRefresh(SiS_Private *SiS_Pr); -void SiS_EnableRefresh(SiS_Private *SiS_Pr, UCHAR *ROMAddr); -void SiS_SetDRAMSize_310(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO); -void SiS_DisableChannelInterleaving(SiS_Private *SiS_Pr, int index,USHORT SiS_DDRDRAM_TYPE[][5]); -void SiS_SetDRAMSizingType(SiS_Private *SiS_Pr, int index,USHORT DRAMTYPE_TABLE[][5]); -void SiS_CheckBusWidth_310(SiS_Private *SiS_Pr, UCHAR *ROMAddress,ULONG FBAddress, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -int SiS_SetRank(SiS_Private *SiS_Pr, int index,UCHAR RankNo,USHORT DRAMTYPE_TABLE[][5]); -int SiS_SetDDRChannel(SiS_Private *SiS_Pr, int index,UCHAR ChannelNo, - USHORT DRAMTYPE_TABLE[][5]); -int SiS_CheckColumn(SiS_Private *SiS_Pr, int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress); -int SiS_CheckBanks(SiS_Private *SiS_Pr, int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress); -int SiS_CheckRank(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress); -int SiS_CheckDDRRank(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress); -int SiS_CheckRanks(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress); -int SiS_CheckDDRRanks(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress); -int SiS_SDRSizing(SiS_Private *SiS_Pr, ULONG FBAddress); -int SiS_DDRSizing(SiS_Private *SiS_Pr, ULONG FBAddress); -int Is315E(SiS_Private *SiS_Pr); -void SiS_VerifyMclk(SiS_Private *SiS_Pr, ULONG FBAddr); -#endif - -void SiS_HandleCRT1(SiS_Private *SiS_Pr); -void SiS_Handle301B_1400x1050(SiS_Private *SiS_Pr, USHORT ModeNo); -void SiS_SetEnableDstn(SiS_Private *SiS_Pr); -void SiS_Delay15us(SiS_Private *SiS_Pr); -BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo,USHORT *ModeIdIndex); -BOOLEAN SiS_CheckMemorySize(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT ModeIdIndex); -UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex); -void SiS_SetSeqRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex); -void SiS_SetMiscRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex); -void SiS_SetCRTCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT StandTableIndex); -void SiS_SetATTRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetGRCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex); -void SiS_ClearExt1Regs(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetSync(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT RefreshRateTableIndex); -void SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -BOOLEAN SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *ResInfo,USHORT *DisplayType); -void SiS_ResetCRT1VCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCRT1VCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO, - USHORT RefreshRateTableIndex); -void SiS_SetVCLKState(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO, USHORT ModeNo, - USHORT RefreshRateTableIndex, USHORT ModeIdIndex); -void SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -void SiS_WriteDAC(SiS_Private *SiS_Pr, USHORT, USHORT, USHORT, USHORT, USHORT, USHORT); -void SiS_DisplayOn(SiS_Private *SiS_Pr); -void SiS_DisplayOff(SiS_Private *SiS_Pr); -void SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO,USHORT ModeNo, - USHORT ModeIdIndex,USHORT RefreshRateTableIndex); -void SiS_GetVBType(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO); -USHORT SiS_ChkBUSWidth(SiS_Private *SiS_Pr, UCHAR *ROMAddr); -USHORT SiS_GetModeIDLength(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT); -USHORT SiS_GetRefindexLength(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT); -void SiS_SetInterlace(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT RefreshRateTableIndex); -void SiS_Set_LVDS_TRUMPION(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCRT1Offset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT,USHORT,USHORT,PSIS_HW_DEVICE_INFO); -#ifdef SIS315H -void SiS_SetCRT1FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT,USHORT,PSIS_HW_DEVICE_INFO); +static const UCHAR SiS_HiTVGroup3Data[] = { + 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f, + 0x05,0x21,0xb2,0xb2,0x55,0x77,0x2a,0xa6, + 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, + 0x8c,0x6e,0x60,0x2e,0x58,0x48,0x72,0x44, + 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, + 0x4f,0x7f,0x03,0xa8,0x7d,0x20,0x1a,0xa9, + 0x14,0x05,0x03,0x7e,0x64,0x31,0x14,0x75, + 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 +}; + +static const UCHAR SiS_HiTVGroup3Simu[] = { + 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95, + 0xdb,0x20,0xb8,0xb8,0x55,0x47,0x2a,0xa6, + 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, + 0x8c,0x6e,0x60,0x15,0x26,0xd3,0xe4,0x11, + 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, + 0x67,0x36,0x01,0x47,0x0e,0x10,0xbe,0xb4, + 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, + 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 +}; + +#if 0 +static const UCHAR SiS_HiTVGroup3Text[] = { + 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7, + 0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6, + 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, + 0x8c,0x6e,0x60,0x18,0x2c,0x0c,0x20,0x22, + 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, + 0x93,0x3c,0x01,0x50,0x2f,0x10,0xf4,0xca, + 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, + 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 +}; #endif -#ifdef SIS300 -void SiS_SetCRT1FIFO_300(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,PSIS_HW_DEVICE_INFO, - USHORT RefreshRateTableIndex); -void SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,PSIS_HW_DEVICE_INFO, - USHORT RefreshRateTableIndex); -USHORT SiS_CalcDelay(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT VCLK, - USHORT colordepth, USHORT MCLK); -USHORT SiS_DoCalcDelay(SiS_Private *SiS_Pr, USHORT MCLK, USHORT VCLK, USHORT colordepth, USHORT key); -USHORT SiS_CalcDelay2(SiS_Private *SiS_Pr, UCHAR *ROMAddr, UCHAR,PSIS_HW_DEVICE_INFO HwDeviceExtension); -#endif -void SiS_ClearBuffer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT ModeNo); -void SiS_SetCRT1Group(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT ModeIdIndex,USHORT BaseAddr); -void SiS_DetectMonitor(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr); -void SiS_GetSenseStatus(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,UCHAR *ROMAddr); -USHORT SiS_TestMonitorType(SiS_Private *SiS_Pr, UCHAR R_DAC,UCHAR G_DAC,UCHAR B_DAC); -USHORT SiS_SenseCHTV(SiS_Private *SiS_Pr); -BOOLEAN SiS_Sense(SiS_Private *SiS_Pr, USHORT tempbx,USHORT tempcx); -BOOLEAN SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO); -BOOLEAN SiS_GetLCDDDCInfo(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO); -USHORT SiS_SenseLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO); -void SiSRegInit(SiS_Private *SiS_Pr, USHORT BaseAddr); -void SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo); -void SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiSDetermineROMUsage(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR *ROMAddr); -#ifdef LINUX_XF86 -USHORT SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags); -void SiS_SetPitch(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr); -void SiS_SetPitchCRT1(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr); -void SiS_SetPitchCRT2(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr); -extern int SiS_compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div, - int *out_sbit, int *out_scale); -extern unsigned char SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, unsigned char value); -extern unsigned char SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id); -extern USHORT SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode); +static const UCHAR SiS_NTSCPhase[] = {0x21,0xed,0xba,0x08}; +static const UCHAR SiS_PALPhase[] = {0x2a,0x05,0xe3,0x00}; +static const UCHAR SiS_PALMPhase[] = {0x21,0xE4,0x2E,0x9B}; +static const UCHAR SiS_PALNPhase[] = {0x21,0xF4,0x3E,0xBA}; +static const UCHAR SiS_NTSCPhase2[] = {0x21,0xF0,0x7B,0xD6}; +static const UCHAR SiS_PALPhase2[] = {0x2a,0x09,0x86,0xe9}; +static const UCHAR SiS_PALMPhase2[] = {0x21,0xE6,0xEF,0xA4}; +static const UCHAR SiS_PALNPhase2[] = {0x21,0xF6,0x94,0x46}; +static const UCHAR SiS_SpecialPhase[] = {0x1e,0x8c,0x5c,0x7a}; +static const UCHAR SiS_SpecialPhaseM[]= {0x1e,0x83,0x0a,0xe0}; +static const UCHAR SiS_SpecialPhaseJ[]= {0x25,0xd4,0xfd,0x5e}; + +static const SiS_TVDataStruct SiS_StPALData[] = +{ + { 1, 1, 864, 525,1270, 400, 100, 0, 760,0xf4,0xff,0x1c,0x22}, + { 1, 1, 864, 525,1270, 350, 100, 0, 760,0xf4,0xff,0x1c,0x22}, + { 1, 1, 864, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, + { 1, 1, 864, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, + { 1, 1, 864, 525,1270, 480, 50, 0, 760,0xf4,0xff,0x1c,0x22}, + { 1, 1, 864, 525,1270, 600, 50, 0, 0,0xf4,0xff,0x1c,0x22} +}; + +static const SiS_TVDataStruct SiS_ExtPALData[] = +{ + { 27, 10, 848, 448,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, /* 640x400, 320x200 */ + { 108, 35, 848, 398,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, + { 12, 5, 954, 448,1270, 530, 50, 0, 50,0xf1,0x04,0x1f,0x18}, + { 9, 4, 960, 463,1644, 438, 50, 0, 50,0xf4,0x0b,0x1c,0x0a}, + { 9, 4, 848, 528,1270, 530, 0, 0, 50,0xf5,0xfb,0x1b,0x2a}, /* 640x480, 320x240 */ +/*{ 36, 25,1060, 648,1316, 530, 438, 0, 438,0xeb,0x05,0x25,0x16},*//* 800x600, 400x300 */ + { 36, 25,1060, 648,1270, 530, 438, 0, 438,0xeb,0x05,0x25,0x16}, /* 800x600, 400x300 - better */ + { 3, 2,1080, 619,1270, 540, 438, 0, 438,0xf3,0x00,0x1d,0x20}, /* 720x576 */ + { 1, 1,1170, 821,1270, 520, 686, 0, 686,0xF3,0x00,0x1D,0x20}, /* 1024x768 */ + { 1, 1,1170, 821,1270, 520, 686, 0, 686,0xF3,0x00,0x1D,0x20} /* 1024x768 (for NTSC equ) */ +}; + +static const SiS_TVDataStruct SiS_StNTSCData[] = +{ + { 1, 1, 858, 525,1270, 400, 50, 0, 760,0xf1,0x04,0x1f,0x18}, + { 1, 1, 858, 525,1270, 350, 50, 0, 640,0xf1,0x04,0x1f,0x18}, + { 1, 1, 858, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, + { 1, 1, 858, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, + { 1, 1, 858, 525,1270, 480, 0, 0, 760,0xf1,0x04,0x1f,0x18} +}; + +static const SiS_TVDataStruct SiS_ExtNTSCData[] = +{ + { 143, 65, 858, 443,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, /* 640x400, 320x200 */ + { 88, 35, 858, 393,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, + { 143, 70, 924, 443,1270, 440, 92, 0, 92,0xf1,0x04,0x1f,0x18}, + { 143, 70, 924, 393,1270, 440, 92, 0, 92,0xf4,0x0b,0x1c,0x0a}, + { 143, 76, 836, 523,1270, 440, 224, 0, 0,0xf1,0x05,0x1f,0x16}, /* 640x480, 320x240 */ + { 143, 120,1056, 643,1270, 440, 0, 128, 0,0xf4,0x10,0x1c,0x00}, /* 800x600, 400x300 */ +/*{ 2, 1, 858, 503,1270, 480, 0, 128, 0,0xee,0x0c,0x22,0x08},*/ /* 720x480 (old, from 650) */ + { 143, 76, 836, 523,1270, 440, 0, 128, 0,0xee,0x0c,0x22,0x08}, /* 720x480 - BETTER (from 300 series) */ +/*{ 65, 64,1056, 791,1270, 480, 638, 0, 0,0xEE,0x0C,0x22,0x08} */ /* 1024x768 (525i) */ + { 1, 1,1100, 811,1412, 440, 0, 128, 0,0xee,0x0c,0x22,0x08}, /* 1024x768 (525i) CORRECTED */ + { 65, 64,1056, 791,1270, 480, 455, 0, 0,0x00,0x00,0x00,0x00} /* 1024x768 (525p) */ +}; + +static const SiS_TVDataStruct SiS_StHiTVData[] = /* Slave + TVSimu */ +{ + { 1, 1, 0x37c,0x233,0x2b2,0x320, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x37c,0x233,0x2b2,0x320, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x37c,0x233,0x2b2,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 8, 5, 0x41a,0x2ab,0x670,0x3c0,0x150,128, 0, 0x00,0x00,0x00,0x00} +}; + +static const SiS_TVDataStruct SiS_St2HiTVData[] = /* Slave */ +{ + { 3, 1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 3, 1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 5, 2, 0x348,0x233,0x670,0x3c0,0x08d,128, 0, 0x00,0x00,0x00,0x00}, + { 8, 5, 0x41a,0x2ab,0x670,0x3c0,0x17c,128, 0, 0x00,0x00,0x00,0x00} +}; + +static const SiS_TVDataStruct SiS_ExtHiTVData[] = +{ + { 6, 1, 0x348,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 3, 1, 0x3c0,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 6, 1, 0x348,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 3, 1, 0x3c0,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 5, 1, 0x348,0x233,0x670,0x3c0,0x166,128, 0, 0x00,0x00,0x00,0x00}, /* 640x480 */ + { 16, 5, 0x41a,0x2ab,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00}, /* 800x600 */ + { 25, 12, 0x4ec,0x353,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, /* 1024x768 */ + { 5, 4, 0x627,0x464,0x670,0x3c0,0x128, 0, 0, 0x00,0x00,0x00,0x00}, /* 1280x1024 */ + { 4, 1, 0x41a,0x233,0x60c,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00}, /* 800x480 */ + { 5, 2, 0x578,0x293,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, /* 1024x576 */ + { 8, 5, 0x6d6,0x323,0x670,0x3c0,0x128, 0, 0, 0x00,0x00,0x00,0x00} /* 1280x720 */ +}; + +static const SiS_TVDataStruct SiS_St525pData[] = +{ + { 1, 1, 0x6b4,0x20d,0x4f6,0x190, 50, 0, 0x2f8, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x6b4,0x20d,0x4f6,0x15e, 50, 0, 0x280, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x6b4,0x20d,0x4f6,0x190, 50, 0, 0x2f8, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x6b4,0x20d,0x4f6,0x15e, 50, 0, 0x280, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x6b4,0x20d,0x4f6,0x1e0, 0, 0, 0x2f8, 0x00,0x00,0x00,0x00} +}; + +static const SiS_TVDataStruct SiS_St750pData[] = +{ + { 1, 1, 0x672,0x2ee,0x500,0x190, 50, 0, 0x2f8, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x672,0x2ee,0x500,0x15e, 50, 0, 0x280, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x672,0x2ee,0x500,0x190, 0, 0, 0x2d0, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x672,0x2ee,0x500,0x15e, 0, 0, 0x2d0, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x672,0x2ee,0x500,0x1e0, 0, 0, 0x2f8, 0x00,0x00,0x00,0x00} +}; + +static const SiS_TVDataStruct SiS_Ext750pData[] = +{ + { 3, 1, 0x3a7,0x1d6,0x500,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00}, + { 24, 7, 0x3a7,0x1a4,0x500,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00}, + { 3, 1, 0x3a7,0x1d6,0x500,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00}, + { 24, 7, 0x3a7,0x1a4,0x500,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00}, + { 99, 32, 0x320,0x1fe,0x500,0x2d0, 50, 0, 0, 0x00,0x00,0x00,0x00}, /* 640x480 */ + { 5, 4, 0x5d8,0x29e,0x500,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00}, /* 800x600 */ + { 2, 1, 0x35a,0x1f7,0x4f6,0x1e0, 0,128, 0, 0x00,0x00,0x00,0x00}, /* 720x480 */ + { 68, 64, 0x55f,0x346,0x500,0x2a8,0x27e, 0, 0, 0x00,0x00,0x00,0x00}, /* 1024x768 */ +}; + +static const SiS_LCDDataStruct SiS_LCD1280x960Data[] = +{ + { 9, 2, 800, 500,1800,1000}, + { 9, 2, 800, 500,1800,1000}, + { 4, 1, 900, 500,1800,1000}, + { 4, 1, 900, 500,1800,1000}, + { 9, 2, 800, 500,1800,1000}, + { 30, 11,1056, 625,1800,1000}, + { 5, 3,1350, 800,1800,1000}, + { 1, 1,1576,1050,1576,1050}, + { 1, 1,1800,1000,1800,1000} +}; + +/* 1280x768 panel data from Fujitsu 7911 (VL-17WDX8). + * Other 1280x768 panels (with clock != 81000, HTxVT != 1688x802) + * will be treated as custom panels. + */ + +static const SiS_LCDDataStruct SiS_StLCD1280x768Data[] = +{ + { 211, 100, 2100, 408, 1688, 802 }, /* These values are *wrong* */ + { 211, 64, 1536, 358, 1688, 802 }, /* (which is why they aren't used yet) */ + { 211, 100, 2100, 408, 1688, 802 }, + { 211, 64, 1536, 358, 1688, 802 }, + { 211, 48, 840, 488, 1688, 802 }, + { 211, 72, 1008, 609, 1688, 802 }, + { 211, 128, 1400, 776, 1688, 802 }, + { 211, 205, 1680, 1041, 1688, 802 }, + { 1, 1, 1688, 802, 1688, 802 } /* That's the only one that is correct */ +}; + +static const SiS_LCDDataStruct SiS_ExtLCD1280x768Data[] = +{ + { 211, 100, 2100, 408, 1688, 802 }, /* These values are *wrong* */ + { 211, 64, 1536, 358, 1688, 802 }, /* (which is why they aren't used yet) */ + { 211, 100, 2100, 408, 1688, 802 }, + { 211, 64, 1536, 358, 1688, 802 }, + { 211, 48, 840, 488, 1688, 802 }, + { 211, 72, 1008, 609, 1688, 802 }, + { 211, 128, 1400, 776, 1688, 802 }, + { 211, 205, 1680, 1041, 1688, 802 }, + { 1, 1, 1688, 802, 1688, 802 } /* That's the only one that is correct */ +}; + +static const SiS_LCDDataStruct SiS_NoScaleData1280x768[] = +{ + { 1, 1, 1688, 802, 1688, 802}, + { 1, 1, 1688, 802, 1688, 802}, + { 1, 1, 1688, 802, 1688, 802}, + { 1, 1, 1688, 802, 1688, 802}, + { 1, 1, 1688, 802, 1688, 802}, + { 1, 1, 1688, 802, 1688, 802}, + { 1, 1, 1688, 802, 1688, 802}, + { 1, 1, 1688, 802, 1688, 802}, + { 1, 1, 1688, 802, 1688, 802} +}; + +static const SiS_LCDDataStruct SiS_StLCD1400x1050Data[] = +{ + { 211, 100, 2100, 408, 1688, 1066 }, + { 211, 64, 1536, 358, 1688, 1066 }, + { 211, 100, 2100, 408, 1688, 1066 }, + { 211, 64, 1536, 358, 1688, 1066 }, + { 211, 48, 840, 488, 1688, 1066 }, + { 211, 72, 1008, 609, 1688, 1066 }, + { 211, 128, 1400, 776, 1688, 1066 }, + { 211, 205, 1680, 1041, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 } +}; + +static const SiS_LCDDataStruct SiS_ExtLCD1400x1050Data[] = +{ + { 211, 100, 2100, 408, 1688, 1066 }, + { 211, 64, 1536, 358, 1688, 1066 }, + { 211, 100, 2100, 408, 1688, 1066 }, + { 211, 64, 1536, 358, 1688, 1066 }, + { 211, 48, 840, 488, 1688, 1066 }, + { 211, 72, 1008, 609, 1688, 1066 }, + { 211, 128, 1400, 776, 1688, 1066 }, + { 211, 205, 1680, 1041, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 } +}; + +static const SiS_LCDDataStruct SiS_NoScaleData1400x1050[] = +{ + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 } +}; + +static const SiS_LCDDataStruct SiS_StLCD1600x1200Data[] = +{ + {27, 4, 800, 500, 2160, 1250 }, + {27, 4, 800, 500, 2160, 1250 }, + { 6, 1, 900, 500, 2160, 1250 }, + { 6, 1, 900, 500, 2160, 1250 }, + {27, 1, 800, 500, 2160, 1250 }, + { 4, 1,1080, 625, 2160, 1250 }, + { 5, 2,1350, 800, 2160, 1250 }, + {135,88,1600,1100, 2160, 1250 }, + {135,88,1600,1100, 2160, 1250 }, + { 1, 1,2160,1250, 2160, 1250 } +}; + +static const SiS_LCDDataStruct SiS_ExtLCD1600x1200Data[] = +{ + {27, 4, 800, 500, 2160, 1250 }, + {27, 4, 800, 500, 2160, 1250 }, + { 6, 1, 900, 500, 2160, 1250 }, + { 6, 1, 900, 500, 2160, 1250 }, + {27, 1, 800, 500, 2160, 1250 }, + { 4, 1,1080, 625, 2160, 1250 }, + { 5, 2,1350, 800, 2160, 1250 }, + {27,16,1500,1064, 2160, 1250 }, + {27,16,1500,1064, 2160, 1250 }, + { 1, 1,2160,1250, 2160, 1250 } +}; + +static const SiS_LCDDataStruct SiS_NoScaleData1600x1200[] = +{ + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, +}; + +static const SiS_LCDDataStruct SiS_NoScaleData[] = +{ + { 1, 1, 800, 449, 800, 449 }, + { 1, 1, 800, 449, 800, 449 }, + { 1, 1, 900, 449, 900, 449 }, + { 1, 1, 900, 449, 900, 449 }, + { 1, 1, 800, 525, 800, 525 }, + { 1, 1,1056, 628,1056, 628 }, + { 1, 1,1344, 806,1344, 806 }, + { 1, 1,1688,1066,1688,1066 }, + { 1, 1,1688, 802,1688, 802 }, /* 1280x768: 802 was 806 in both cases */ + { 1, 1,2160,1250,2160,1250 }, /* 1600x1200 */ + { 1, 1,1800,1000,1800,1000 } /* 1280x960 */ +}; + +/* *** LCDA *** */ + +static const SiS_LVDSDataStruct SiS_LCDA1024x768Data_1[]= +{ + { 960, 438,1344, 806}, + { 960, 388,1344, 806}, + { 1040, 438,1344, 806}, + { 1040, 388,1344, 806}, + { 960, 518,1344, 806}, /* 640x480 */ + { 1120, 638,1344, 806}, /* 800x600 */ + { 1344, 806,1344, 806}, /* 1024x768 */ +#if 0 + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 518,1344, 806}, /* 640x480 */ + {1050, 638,1344, 806}, /* 800x600 */ + {1344, 806,1344, 806}, /* 1024x768 */ #endif +}; -extern USHORT SiS_GetOffset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -extern void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -extern BOOLEAN SiS_SetCRT2Group301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern void SiS_PresetScratchregister(SiS_Private *SiS_Pr, USHORT SiS_P3d4, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr); -extern void SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr); -extern BOOLEAN SiS_BridgeIsOn(SiS_Private *SiS_Pr, USHORT BaseAddr); -extern BOOLEAN SiS_BridgeIsEnable(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO ); -extern void SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension, int chkcrt2mode); -extern BOOLEAN SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern void SiS_SetHiVision(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern USHORT SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern void SiS_WhatIsThis(SiS_Private *SiS_Pr, USHORT myvbinfo); -extern void SiS_LongWait(SiS_Private *SiS_Pr); -extern void SiS_SetRegOR(USHORT Port,USHORT Index,USHORT DataOR); -extern void SiS_SetRegAND(USHORT Port,USHORT Index,USHORT DataAND); -extern void SiS_SetRegANDOR(USHORT Port,USHORT Index,USHORT DataAND,USHORT DataOR); -extern USHORT SiS_GetResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -extern void SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempax); -extern USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax); -extern void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempax); -extern USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempax); -extern void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempax); -extern USHORT SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempax); -extern BOOLEAN SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - USHORT *ResInfo,USHORT *DisplayType); -extern USHORT SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern BOOLEAN SiS_Is301B(SiS_Private *SiS_Pr, USHORT BaseAddr); -extern BOOLEAN SiS_IsM650(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -extern BOOLEAN SiS_LowModeStuff(SiS_Private *SiS_Pr, USHORT ModeNo,PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern BOOLEAN SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -extern BOOLEAN SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -extern USHORT SiS_GetMCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension); +static const SiS_LVDSDataStruct SiS_LCDA1024x768Data_2[]= +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, +}; + +static const SiS_LVDSDataStruct SiS_LCDA1280x1024Data_1[]= +{ /* Acer, Compaq */ + {1048, 442,1688,1066}, + {1048, 392,1688,1066}, + {1128, 442,1688,1066}, + {1128, 392,1688,1066}, + {1048, 522,1688,1066}, + {1208, 642,1688,1066}, + {1432, 810,1688,1066}, + {1688,1066,1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LCDA1280x1024Data_2[]= +{ /* Corrected (illegal in Acer, correct in Compaq) */ + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LCDA1400x1050Data_1[]= +{ /* Clevo */ + { 928, 416, 1688,1066}, + { 928, 366, 1688,1066}, + {1008, 416, 1688,1066}, + {1008, 366, 1688,1066}, + {1200, 530, 1688,1066}, + {1088, 616, 1688,1066}, + {1312, 784, 1688,1066}, + {1568,1040, 1688,1066}, + {1688,1066, 1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LCDA1400x1050Data_2[]= +{ /* Clevo */ + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LCDA1600x1200Data_1[]= +{ /* Clevo (Temporary data) */ + {1200, 450, 2048,1250}, + {1200, 400, 2048,1250}, + {1280, 450, 2048,1250}, + {1280, 400, 2048,1250}, + {1200, 530, 2048,1250}, + {1360, 650, 2048,1250}, + {1584, 818, 2048,1250}, + {1688,1066, 2048,1250}, + {1688,1066, 2048,1250}, + {2048,1250, 2048,1250} /* this should be correct */ +#if 0 + {2160,1250, 2048,1250} /* ? */ +#endif +}; + +static const SiS_LVDSDataStruct SiS_LCDA1600x1200Data_2[]= +{ /* Clevo (Temporary data. Seems invalid.) */ + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250} +}; + +/* LVDS SKEW for LCDA */ + +static const SiS_LVDSDesStruct SiS_PanelType1076_1[]= +{ /* 1024x768 */ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, /* 805; was 0, 0 -> top line cut away (26/09/03) */ +}; + +static const SiS_LVDSDesStruct SiS_PanelType1076_2[]= +{ /* 1024x768; not expanded */ + { 1184, 622 }, + { 1184, 597 }, + { 1184, 622 }, + { 1184, 597 }, + { 1152, 650 }, /* 622 */ + { 1232, 722 }, + { 0, 0 }, /* 805; was 0, 0 -> top line cut away (26/09/03) */ +}; + +static const SiS_LVDSDesStruct SiS_PanelType1210_1[]= +{ /* 1280x1024 */ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 1065}, /* Acer */ + { 0 , 0} +}; + +static const SiS_LVDSDesStruct SiS_PanelType1210_2[]= +{ /* 1280x1024; not expanded */ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0} +}; + +static const SiS_LVDSDesStruct SiS_PanelType1296_1[]= +{ /* 1400x1050 */ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 1065} /* Was 0,0 */ +}; + +static const SiS_LVDSDesStruct SiS_PanelType1296_2[]= +{ /* 1400x1050; not expanded */ + { 1308, 741 }, + { 1308, 716 }, + { 1308, 741 }, + { 1308, 716 }, + { 1308, 781 }, + { 1388, 841 }, + { 1500, 925 }, + { 1628,1053 }, + { 0,1065 } +#if 0 + { 808 , 740}, + { 0 , 715}, + { 632 , 740}, + { 632 , 715}, + { 1307, 780}, + { 1387,1157}, + { 1499, 924}, + { 1627,1052}, + { 0 , 0} +#endif +}; + +static const SiS_LVDSDesStruct SiS_PanelType1600_1[]= +{ /* 1600x1200 */ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0} +}; +static const SiS_LVDSDesStruct SiS_PanelType1600_2[]= +{ /* 1600x1200; not expanded */ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0} +}; + +#ifdef SIS315H + +/* LCDA CRT1 custom data */ + +static const SiS_LCDACRT1DataStruct Compaq1280x1024_LCDACRT1_1[]= +{ + {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0x86,0x1f, + 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0x86,0x1f, + 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0x08,0x3e, + 0xe0,0x84,0xdf,0xdf,0x09,0x00,0x00,0x06, + 0x00}}, + {{0x92,0x63,0x63,0x96,0x6c,0x1a,0x80,0xf0, + 0x58,0x8c,0x57,0x57,0x81,0x20,0x00,0x06, + 0x01}}, + {{0xae,0x7f,0x7f,0x92,0x88,0x96,0x28,0xf5, + 0x00,0x84,0xff,0xff,0x29,0x10,0x00,0x02, + 0x01}}, + {{0xce,0x9f,0x9f,0x92,0xa8,0x16,0x28,0x5a, + 0x00,0x84,0xff,0xff,0x29,0x01,0x00,0x07, + 0x01}} +}; + +static const SiS_LCDACRT1DataStruct Compaq1280x1024_LCDACRT1_1_H[]= +{ + {{0x56,0x27,0x27,0x9a,0x30,0x1e,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x3c,0x4f,0x4f,0x82,0x58,0x06,0x86,0xd1, + 0xbc,0x80,0xbb,0xbb,0xe5,0x00,0x00,0x06, + 0x01}}, + {{0x56,0x27,0x27,0x9a,0x30,0x1e,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x3c,0x4f,0x4f,0x82,0x58,0x06,0x86,0xd1, + 0xbc,0x80,0xbb,0xbb,0xe5,0x00,0x00,0x06, + 0x01}}, + {{0x56,0x27,0x27,0x9a,0x30,0x1e,0x08,0x3e, + 0xe0,0x84,0xdf,0xdf,0x09,0x00,0x00,0x05, + 0x00}}, + {{0x60,0x31,0x31,0x84,0x3a,0x88,0x80,0xf0, + 0x58,0x8c,0x57,0x57,0x81,0x20,0x00,0x01, + 0x01}}, + {{0x6e,0x3f,0x3f,0x92,0x48,0x96,0x28,0xf5, + 0x00,0x84,0xff,0xff,0x29,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS_LCDACRT1DataStruct Clevo1024x768_LCDACRT1_1[]= +{ + {{0x73,0x4f,0x4f,0x97,0x55,0x86,0xc4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x55,0x86,0x97,0x1f, + 0x60,0x87,0x5d,0x5d,0x83,0x10,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x55,0x86,0xc4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x55,0x86,0x97,0x1f, + 0x60,0x87,0x5d,0x5d,0x83,0x10,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x55,0x86,0x04,0x3e, + 0xE2,0x89,0xDf,0xDf,0x05,0x00,0x00,0x05, + 0x00}}, + {{0x87,0x63,0x63,0x8B,0x69,0x1A,0x7c,0xf0, + 0x5A,0x8F,0x57,0x57,0x7D,0x20,0x00,0x26, + 0x01}}, + {{0xA3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xFf,0xFf,0x25,0x10,0x00,0x02, + 0x01}} +}; + +static const SiS_LCDACRT1DataStruct Clevo1024x768_LCDACRT1_1_H[]= +{ + {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0xc4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0x97,0x1f, + 0x60,0x87,0x5D,0x5D,0x83,0x01,0x00,0x44, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0xc4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0x97,0x1f, + 0x60,0x87,0x5D,0x5D,0x83,0x01,0x00,0x44, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x32,0x1b,0x04,0x3e, + 0xE2,0x89,0xDf,0xDf,0x05,0x00,0x00,0x45, + 0x00}}, + {{0x55,0x31,0x31,0x99,0x46,0x1d,0x7c,0xf0, + 0x5A,0x8F,0x57,0x57,0x7D,0x20,0x00,0x55, + 0x01}}, + {{0x63,0x3F,0x3F,0x87,0x4A,0x93,0x24,0xF5, + 0x02,0x88,0xFF,0xFF,0x25,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS_LCDACRT1DataStruct Clevo1024x768_LCDACRT1_2[]= +{ + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x63,0x63,0x87,0x78,0x89,0x24,0xf1, + 0xae,0x84,0x57,0x57,0x25,0x30,0x00,0x02, + 0x01}}, + {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, + 0x01}} +}; + +static const SiS_LCDACRT1DataStruct Clevo1024x768_LCDACRT1_2_H[]= +{ + {{0x7b,0x27,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x57,0x8e,0x8f,0x8f,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x3e,0x85,0x5d,0x5d,0x25,0x10,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x57,0x8e,0x8f,0x8f,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x3e,0x85,0x5d,0x5d,0x25,0x10,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x7f,0x86,0xdf,0xdf,0x25,0x10,0x00,0x01, + 0x00 }}, + {{0x71,0x31,0x31,0x95,0x46,0x97,0x24,0xf1, + 0xbb,0x82,0x57,0x57,0x25,0x10,0x00,0x01, + 0x01 }}, + {{0x63,0x3f,0x3f,0x87,0x46,0x97,0x24,0xf5, + 0x0f,0x86,0xff,0xff,0x25,0x30,0x00,0x01, + 0x01 }} +}; + +#endif /* 315 */ + +/**************************************************************/ +/* LVDS ----------------------------------------------------- */ +/**************************************************************/ + +static const SiS_LVDSDataStruct SiS_LVDS320x480Data_1[]= +{ + { 848, 433, 400, 525}, + { 848, 389, 400, 525}, + { 848, 433, 400, 525}, + { 848, 389, 400, 525}, + { 848, 518, 400, 525}, + {1056, 628, 400, 525}, + { 400, 525, 400, 525}, + { 800, 449,1000, 644}, + { 800, 525,1000, 635} +}; + +static const SiS_LVDSDataStruct SiS_LVDS640x480Data_1[]= +{ + { 800, 445, 800, 525}, /* 800, 449, 800, 449 */ + { 800, 395, 800, 525}, + { 800, 445, 800, 525}, + { 800, 395, 800, 525}, + { 800, 525, 800, 525}, + { 800, 525, 800, 525}, /* pseudo */ + { 800, 525, 800, 525} /* pseudo */ +}; + +/* FSTN 320x240 */ +static const SiS_LVDSDataStruct SiS_LVDS640x480Data_2[]= +{ + { 800, 445, 800, 525}, + { 800, 395, 800, 525}, + { 800, 445, 800, 525}, + { 800, 395, 800, 525}, + { 800, 525, 800, 525}, + { 800, 525, 800, 525}, /* pseudo */ + { 800, 525, 800, 525} /* pseudo */ +}; + + +static const SiS_LVDSDataStruct SiS_LVDS800x600Data_1[]= +{ + { 848, 433,1060, 629}, + { 848, 389,1060, 629}, + { 848, 433,1060, 629}, + { 848, 389,1060, 629}, + { 848, 518,1060, 629}, + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + { 800, 449,1000, 644}, + { 800, 525,1000, 635} +}; + +static const SiS_LVDSDataStruct SiS_LVDS800x600Data_2[]= +{ + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + { 800, 449,1000, 644}, + { 800, 525,1000, 635} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1024x768Data_1[]= +{ + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 518,1344, 806}, /* 640x480 */ + {1050, 638,1344, 806}, /* 800x600 */ + {1344, 806,1344, 806}, /* 1024x768 */ + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1024x768Data_2[]= +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + + +static const SiS_LVDSDataStruct SiS_LVDS1280x1024Data_1[]= +{ + {1048, 442,1688,1066}, + {1048, 392,1688,1066}, + {1048, 442,1688,1066}, + {1048, 392,1688,1066}, + {1048, 522,1688,1066}, + {1208, 642,1688,1066}, + {1432, 810,1688,1066}, + {1688,1066,1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1280x1024Data_2[]= +{ + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1400x1050Data_1[]= +{ + { 928, 416, 1688,1066}, + { 928, 366, 1688,1066}, + { 928, 416, 1688,1066}, + { 928, 366, 1688,1066}, + { 928, 496, 1688,1066}, + {1088, 616, 1688,1066}, + {1312, 784, 1688,1066}, + {1568,1040, 1688,1066}, + {1688,1066, 1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1400x1050Data_2[]= +{ + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, +}; + +static const SiS_LVDSDataStruct SiS_LVDS1600x1200Data_1[]= +{ + {1088, 520, 2048,1320}, + {1088, 470, 2048,1320}, + {1088, 520, 2048,1320}, + {1088, 470, 2048,1320}, + {1088, 600, 2048,1320}, + {1248, 720, 2048,1320}, + {1472, 888, 2048,1320}, + {1728,1144, 2048,1320}, + {1848,1170, 2048,1320}, + {2048,1320, 2048,1320} +#if 0 + {1088, 450, 2048,1250}, + {1088, 400, 2048,1250}, + {1088, 450, 2048,1250}, + {1088, 400, 2048,1250}, + {1088, 530, 2048,1250}, + {1248, 650, 2048,1250}, + {1472, 818, 2048,1250}, + {1728,1066, 2048,1250}, + {1848,1066, 2048,1250}, + {2048,1250, 2048,1250} +#endif +}; + +static const SiS_LVDSDataStruct SiS_LVDS1600x1200Data_2[]= +{ + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1280x960Data_1[]= +{ + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 518,1344, 806}, + {1050, 638,1344, 806}, + {1344, 806,1344, 806}, + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1280x960Data_2[]= +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1280x768Data_1[]= +{ + { 768, 438, 1408, 806}, + { 768, 388, 1408, 806}, + { 768, 438, 1408, 806}, + { 768, 388, 1408, 806}, + { 768, 518, 1408, 806}, + { 928, 638, 1408, 806}, + {1152, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1280x768Data_2[]= +{ + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1024x600Data_1[] = +{ + { 840, 604,1344, 800}, + { 840, 560,1344, 800}, + { 840, 604,1344, 800}, + { 840, 560,1344, 800}, + { 840, 689,1344, 800}, + {1050, 800,1344, 800}, + {1344, 800,1344, 800}, + { 800, 449,1280, 789}, + { 800, 525,1280, 785} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1024x600Data_2[] = +{ + {1344, 800,1344, 800}, + {1344, 800,1344, 800}, + {1344, 800,1344, 800}, + {1344, 800,1344, 800}, + {1344, 800,1344, 800}, + {1344, 800,1344, 800}, + {1344, 800,1344, 800}, + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1152x768Data_1[] = +{ + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 518,1344, 806}, + {1050, 638,1344, 806}, + {1344, 806,1344, 806}, + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1152x768Data_2[] = +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + +/* Pass 1:1 data */ +static const SiS_LVDSDataStruct SiS_LVDSXXXxXXXData_1[]= +{ + { 800, 449, 800, 449}, + { 800, 449, 800, 449}, + { 900, 449, 900, 449}, + { 900, 449, 900, 449}, + { 800, 525, 800, 525}, /* 640x480 */ + {1056, 628, 1056, 628}, /* 800x600 */ + {1344, 806, 1344, 806}, /* 1024x768 */ + {1344,1066, 1344,1066}, /* 1280x1024 */ /* INSERTED ! */ + {1688, 806, 1688, 806}, /* 1280x768 */ + /* No other panels ! */ +}; + +/* Custom data for Barco iQ R series */ +static const SiS_LVDSDataStruct SiS_LVDSBARCO1366Data_1[]= +{ + { 832, 438,1331, 806}, + { 832, 388,1331, 806}, + { 832, 438,1331, 806}, + { 832, 388,1331, 806}, + { 832, 518,1331, 806}, + {1050, 638,1344, 806}, + {1344, 806,1344, 806}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066} /* 1360x1024 */ +}; + +/* Custom data for Barco iQ R series */ +static const SiS_LVDSDataStruct SiS_LVDSBARCO1366Data_2[]= +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066} /* 1360x1024 */ +}; + +/* Custom data for Barco iQ G series */ +static const SiS_LVDSDataStruct SiS_LVDSBARCO1024Data_1[]= +{ + { 832, 438,1331, 806}, + { 832, 409,1331, 806}, + { 832, 438,1331, 806}, + { 832, 409,1331, 806}, + { 832, 518,1331, 806}, /* 640x480 */ + {1050, 638,1344, 806}, /* 800x600 */ + {1344, 806,1344, 806}, /* 1024x768 */ +}; + +/* Custom data for Barco iQ G series */ +static const SiS_LVDSDataStruct SiS_LVDSBARCO1024Data_2[]= +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, +}; + +/* Custom data for 848x480 parallel panel */ +static const SiS_LVDSDataStruct SiS_LVDS848x480Data_1[]= +{ + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + {1088, 525,1088, 525}, /* 640x480 TODO */ + {1088, 525,1088, 525}, /* 800x600 TODO */ + {1088, 525,1088, 525}, /* 1024x768 TODO */ + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + {1088, 525,1088, 525}, /* 848x480 */ + {1088, 525,1088, 525} /* 1360x768 TODO */ +}; + +/* Custom data for 848x480 parallel panel */ +static const SiS_LVDSDataStruct SiS_LVDS848x480Data_2[]= +{ + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + {1088, 525,1088, 525}, /* 640x480 */ + {1088, 525,1088, 525}, /* 800x600 */ + {1088, 525,1088, 525}, /* 1024x768 */ + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + {1088, 525,1088, 525}, /* 848x480 */ + {1088, 525,1088, 525} /* 1360x768 TODO */ +}; + +static const SiS_LVDSDataStruct SiS_CHTVUNTSCData[]= +{ + { 840, 600, 840, 600}, + { 840, 600, 840, 600}, + { 840, 600, 840, 600}, + { 840, 600, 840, 600}, + { 784, 600, 784, 600}, + {1064, 750,1064, 750}, + {1160, 945,1160, 945} +}; + +static const SiS_LVDSDataStruct SiS_CHTVONTSCData[]= +{ + { 840, 525, 840, 525}, + { 840, 525, 840, 525}, + { 840, 525, 840, 525}, + { 840, 525, 840, 525}, + { 784, 525, 784, 525}, + {1040, 700,1040, 700}, + {1160, 840,1160, 840} +}; + +/* LVDS Skew */ + +static const SiS_LVDSDesStruct SiS_PanelTypeNS_1[]= +{ + { 8, 0}, + { 8, 0}, + { 8, 0}, + { 8, 0}, + { 8, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 806}, + { 0, 0} +}; + +static const SiS_LVDSDesStruct SiS_PanelTypeNS_2[] = +{ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0} +}; + +/* Chrontel TV Skew */ + +static const SiS_LVDSDesStruct SiS_CHTVUNTSCDesData[]= +{ + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0} +}; + +static const SiS_LVDSDesStruct SiS_CHTVONTSCDesData[]= +{ + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0} +}; + +static const SiS_LVDSDesStruct SiS_CHTVUPALDesData[]= +{ + {256, 0}, + {256, 0}, + {256, 0}, + {256, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0} +}; + +static const SiS_LVDSDesStruct SiS_CHTVOPALDesData[]= +{ + {256, 0}, + {256, 0}, + {256, 0}, + {256, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0} +}; + +/* CRT1 CRTC data for slave modes */ + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1320x480_1[] = +{ + {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + 0x00 }}, + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00 }}, + {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00 }}, + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00 }}, + {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e, + 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, + 0x00 }}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01 }}, + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00 }} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_1[] = +{ + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_1_H[] = +{ + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00, + 0x00}}, + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x83,0x85,0x63,0xba,0x00,0x00,0x00, + 0x00}}, + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00, + 0x00}}, + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x83,0x85,0x63,0xba,0x00,0x00,0x00, + 0x00}}, + {{0x2d,0x28,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_2[] = +{ + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01}}, + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_2_H[] = +{ + {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + 0x00}}, + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00}}, + {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00}}, + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00}}, + {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e, + 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, + 0x00}}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01}}, + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_3[] = +{ + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05, + 0x00}}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01}}, + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_3_H[] = +{ + {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + 0x00}}, + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00}}, + {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00}}, + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00}}, + {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e, + 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, + 0x00}}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01}}, + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11024x600_1[] = +{ + {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, + 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, + 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, + 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, + 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0xaf,0xba, + 0x3b,0x82,0xdf,0xb0,0x00,0x00,0x01, + 0x00}}, + {{0x7e,0x63,0x82,0x68,0x15,0x1e,0xf1, + 0xae,0x85,0x57,0x1f,0x30,0x00,0x26, + 0x01}}, + {{0xa3,0x7f,0x87,0x86,0x97,0x1e,0xf1, + 0xae,0x85,0x57,0x1f,0x30,0x00,0x02, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11024x600_1_H[] = +{ + {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, + 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, + 0x00}}, + {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, + 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, + 0x01}}, + {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11024x600_2[] = +{ + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, + 0xae,0x84,0x57,0x25,0x30,0x00,0x02, + 0x01}}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11024x600_2_H[] = +{ + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, + 0xae,0x84,0x57,0x25,0x30,0x00,0x01, + 0x01}}, + {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11152x768_1[] = +{ + {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e, + 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, + 0x00}}, + {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, + 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, + 0x01}}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11152x768_1_H[] = +{ + {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, + 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, + 0x00}}, + {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, + 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, + 0x01}}, + {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11152x768_2[] = +{ + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, + 0xae,0x84,0x57,0x25,0x30,0x00,0x02, + 0x01}}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11152x768_2_H[] = +{ + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, + 0xae,0x84,0x57,0x25,0x30,0x00,0x01, + 0x01}}, + {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_1[] = +{ + {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f, + 0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01, + 0x00}}, + {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f, + 0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01, + 0x00}}, + {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f, + 0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01, + 0x00}}, + {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f, + 0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01, + 0x00}}, + {{0x5b,0x4f,0x9f,0x55,0x19,0x04,0x3e, + 0xec,0x8e,0xdf,0x05,0x20,0x00,0x01, + 0x00}}, + {{0x6f,0x63,0x93,0x69,0x8d,0x7c,0xf0, + 0x64,0x86,0x57,0x7d,0x20,0x00,0x05, + 0x01}}, + {{0x8b,0x7f,0x8f,0x85,0x09,0x24,0xf5, + 0x0c,0x8e,0xff,0x25,0x30,0x00,0x02, + 0x01}}, + {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5, + 0x0c,0x8e,0xff,0x25,0x30,0x00,0x06, + 0x01}}, + {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5, + 0x0c,0x8e,0xff,0x25,0x30,0x00,0x06, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_1_H[] = +{ + {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, + 0x93,0x86,0x8f,0x9f,0x30,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, + 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x8b,0x30,0x1e,0x9e,0x1f, + 0x92,0x86,0x8f,0x9f,0x30,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, + 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x8b,0x2c,0x1a,0xee,0x1f, + 0xe2,0x86,0xdf,0xef,0x10,0x00,0x05, + 0x00}}, + {{0x51,0x31,0x95,0x36,0x04,0x66,0xf0, + 0x5a,0x8e,0x57,0x67,0x20,0x00,0x01, + 0x01}}, + {{0x5f,0x3f,0x83,0x44,0x92,0x0e,0xf5, + 0x02,0x86,0xff,0x0f,0x10,0x00,0x01, + 0x01}}, + {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a, + 0x02,0x86,0xff,0x0f,0x09,0x00,0x05, + 0x01}}, + {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a, + 0x02,0x86,0xff,0x0f,0x09,0x00,0x05, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_2[] = +{ + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, + 0x54,0x86,0xdb,0xda,0x00,0x00,0x02, + 0x00}}, + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, + 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02, + 0x00}}, + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, + 0x54,0x86,0xdb,0xda,0x00,0x00,0x02, + 0x00}}, + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, + 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02, + 0x00}}, + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xb3, + 0x7c,0x8e,0x03,0x02,0x10,0x00,0x02, + 0x01}}, + {{0xab,0x63,0x8f,0x8a,0x8e,0x24,0xf1, + 0xb6,0x88,0x57,0x25,0x10,0x00,0x02, + 0x01}}, + {{0xab,0x7f,0x8f,0x98,0x9c,0x24,0xf5, + 0x0a,0x8c,0xff,0x25,0x30,0x00,0x02, + 0x01}}, + {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, + 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, + 0x01}}, + {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, + 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_2_H[] = +{ + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, + 0x54,0x86,0xdb,0xda,0x00,0x00,0x01, + 0x00}}, + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, + 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01, + 0x00}}, + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, + 0x54,0x86,0xdb,0xda,0x00,0x00,0x01, + 0x00}}, + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, + 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01, + 0x00}}, + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xb3, + 0x7c,0x8e,0x03,0x02,0x10,0x00,0x01, + 0x01}}, + {{0x79,0x31,0x9d,0x58,0x9c,0x24,0xf1, + 0xb6,0x88,0x57,0x25,0x10,0x00,0x01, + 0x01}}, + {{0x6b,0x3f,0x8f,0x58,0x9c,0x24,0xf5, + 0x0a,0x8c,0xff,0x25,0x30,0x00,0x01, + 0x01}}, + {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, + 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, + 0x01}}, + {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, + 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1XXXxXXX_1[] = +{ + {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x05, + 0x00}}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01}}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01}}, + {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a, + 0x00,0x84,0xff,0x29,0x09,0x00,0x07, + 0x01}}, + {{0xce,0x9f,0x92,0xa9,0x17,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x07, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1XXXxXXX_1_H[] = +{ + {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, + 0x00}}, + {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, + 0x00}}, + {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, + 0x00}}, + {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, + 0x00}}, + {{0x38,0x27,0x9c,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}}, + {{0x4d,0x31,0x91,0x3b,0x03,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x01, + 0x01}}, + {{0x63,0x3f,0x87,0x4a,0x92,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x01, + 0x01}} +}; + + +/**************************************************************/ +/* COMMON --------------------------------------------------- */ +/**************************************************************/ + +#define SIS_PL_HSYNCP 0x01 +#define SIS_PL_HSYNCN 0x02 +#define SIS_PL_VSYNCP 0x04 +#define SIS_PL_VSYNCN 0x08 +#define SIS_PL_DVI 0x80 + +typedef struct _SiS_PlasmaModes +{ + const char *name; + ULONG clock; + USHORT HDisplay, HTotal, HFrontPorch, HSyncWidth; + USHORT VDisplay, VTotal, VFrontPorch, VSyncWidth; + UCHAR SyncFlags; +} SiS_PlasmaModes; + +typedef struct _SiS_PlasmaTables +{ + USHORT vendor; + UCHAR productnum; + USHORT product[5]; + const char *DDCnames[5]; + const char *plasmaname; + UCHAR modenum; + UCHAR plasmamodes[20]; /* | 0x80 = DVI-capable, | 0x40 = analog */ +} SiS_PlasmaTables; + +static const SiS_PlasmaModes SiS_PlasmaMode[] = { + { "640x400", /* 00: IBM 400@70 */ + 25175, + 640, 800, 17, 64, + 400, 449, 13, 2, + SIS_PL_HSYNCN | SIS_PL_VSYNCN }, + { "640x480", /* 01: VESA 480@72 */ + 31500, + 640, 832, 24, 40, + 480, 520, 9, 3, + SIS_PL_HSYNCN | SIS_PL_VSYNCN }, + { "800x600", /* 02: VESA 600@72 */ + 50000, + 800, 1040, 56, 120, + 600, 666, 37, 6, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "864x480", /* 03: Cereb wide 1 */ + 42526, + 864, 1134, 22, 86, + 480, 500, 1, 3, + SIS_PL_HSYNCP | SIS_PL_VSYNCN }, + { "848x480", /* 04: VESA wide (NEC1) */ + 33750, + 848, 1088, 16, 112, + 480, 517, 6, 8, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1024x576", /* 05: VESA wide (NEC2) */ + 47250, + 1024, 1320, 16, 144, + 576, 596, 2, 4, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1280x720", /* 06: VESA wide (NEC3) */ + 76500, + 1280, 1696, 48, 176, + 720, 750, 4, 8, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1360x765", /* 07: VESA wide (NEC4) */ + 85500, + 1360, 1792, 64, 176, + 765, 795, 4, 8, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1024x600", /* 08: CEREB wide 2 */ + 51200, + 1024, 1352, 51, 164, + 600, 628, 1, 4, + SIS_PL_HSYNCN | SIS_PL_VSYNCP }, + { "1024x768", /* 09: VESA 768@75 */ + 78750, + 1024, 1312, 16, 96, + 768, 800, 1, 3, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1152x864", /* 10: VESA 1152x864@75 */ + 108000, + 1152, 1600, 64, 128, + 864, 900, 1, 3, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1280x1024", /* 11: VESA 1024@60 */ + 108000, + 1280, 1688, 48, 112, + 1024, 1066, 1, 3, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1280x768", /* 12: W_XGA */ + 81000, + 1280, 1688, 48, 112, + 768, 802, 3, 6, + SIS_PL_HSYNCP | SIS_PL_VSYNCN }, + { "1280x768", /* 13: I/O Data W_XGA@56Hz */ + 76064, + 1280, 1688, 48, 112, + 768, 802, 2, 3, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1376x768", /* 14: I/O Wide XGA */ + 87340, + 1376, 1808, 32, 128, + 768, 806, 3, 6, + SIS_PL_HSYNCN | SIS_PL_VSYNCP }, + { "1280x960", /* 15: VESA 960@60 */ + 108000, + 1280, 1800, 96, 112, + 960, 1000, 1, 3, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1400x1050", /* 16: VESA 1050@60Hz */ + 108000, + 1400, 1688, 48, 112, + 1050, 1066, 1, 3, + SIS_PL_HSYNCN | SIS_PL_VSYNCN }, + { "1360x768", /* 17: VESA wide (NEC4/2) */ + 85500, + 1360, 1792, 64, 112, + 765, 795, 3, 6, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "800x600", /* 18: VESA 600@56 */ + 36000, + 800, 1024, 24, 2, + 600, 625, 1, 2, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1072x600", /* 19: Panasonic 1072x600 (sync?) */ + 54100, + 1072, 1424, 48, 176, + 600, 628, 16, 1, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "848x480", /* 20: Panasonic 848x480 (sync?) */ + 33070, /* is 852x480, but we can't use 852 */ + 848, 1068, 20, 40, /* differs from DDC data, better centered */ + 480, 516, 3, 5, /* won't work assumingly, because data is % 8 */ + SIS_PL_HSYNCN | SIS_PL_VSYNCN }, +}; + +static const SiS_PlasmaTables SiS_PlasmaTable[] = { +#if 0 /* Product IDs missing */ + { 0x38a3, 4, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 42VP4/42VP4D/42VP4G/42VP4DG", + 11, /* All DVI, except 0, 7, 13 */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0, + 17|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, +#endif +#if 0 /* Product IDs missing */ + { 0x38a3, 3, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 42PD1/50PD1/50PD2", + 5, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0, 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 1, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 42PD3", + 10, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 3|0xc0, 4|0xc0, 5|0xc0, 6|0xc0, 7|0x40, 8|0xc0, 9|0xc0, + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 2, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 42VM3/61XM1", + 11, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 3|0xc0, 4|0xc0, 5|0xc0, 6|0xc0, 8|0xc0, 9|0xc0,11|0xc0, + 17|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 2, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 42MP1/42MP2", + 6, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0,11|0xc0, 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 1, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 50MP1", + 10, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0, + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, +#endif + { 0x38a3, 4, + { 0xa482, 0xa483, 0x0000, 0x0000, 0x0000 }, + { "PX-42VM", "", "", "", "" }, + "NEC PlasmaSync 42MP3/42MP4/50MP2/61MP1", + 11, /* All DVI except 0, 7, 13, 17 */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0, + 17|0x40, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, +#if 0 /* Product IDs missing */ + { 0x38a3, 1, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 3300W", + 3, + { 0|0x40, 1|0xc0,18|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 1, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 4200W", + 4, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 1, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 4210W", + 6, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0,11|0xc0, 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 1, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 5000W", + 7, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,11|0xc0, 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, +#endif + { 0x412f, 2, + { 0x000c, 0x000b, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "Pioneer 503CMX/PDA-5002", + 6, /* DVI unknown */ + { 1|0xc0, 2|0xc0, 9|0xc0,11|0xc0,12|0xc0,15|0xc0, 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x34a9, 1, + { 0xa00e, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "Panasonic TH-42", + 5, /* No DVI output */ + { 1|0x40, 2|0x40, 4|0x40, 9|0x40,15|0x40, 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x34a9, 1, + { 0xa005, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "TH-42PW*4", "", "", "", "" }, + "Panasonic TH-42PW5", + 1, /* No special modes otherwise; no DVI. */ + {20|0x40,19|0x40, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x0000 } +}; + +USHORT SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, BOOLEAN FSTN); +USHORT SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, BOOLEAN FSTN, + USHORT CustomT, int LCDwith, int LCDheight); +USHORT SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth); +USHORT SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth); + +void SiS_SetReg(SISIOADDRESS port, USHORT index, USHORT data); +void SiS_SetRegByte(SISIOADDRESS port, USHORT data); +void SiS_SetRegShort(SISIOADDRESS port, USHORT data); +void SiS_SetRegLong(SISIOADDRESS port, ULONG data); +UCHAR SiS_GetReg(SISIOADDRESS port, USHORT index); +UCHAR SiS_GetRegByte(SISIOADDRESS port); +USHORT SiS_GetRegShort(SISIOADDRESS port); +ULONG SiS_GetRegLong(SISIOADDRESS port); +void SiS_SetRegANDOR(SISIOADDRESS Port,USHORT Index,USHORT DataAND,USHORT DataOR); +void SiS_SetRegAND(SISIOADDRESS Port,USHORT Index,USHORT DataAND); +void SiS_SetRegOR(SISIOADDRESS Port,USHORT Index,USHORT DataOR); +void SiS_DisplayOn(SiS_Private *SiS_Pr); +void SiS_DisplayOff(SiS_Private *SiS_Pr); +void SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr); +void SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable); +void SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable); +void SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +USHORT SiS_GetMCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex); +UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); +USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); +USHORT SiS_GetOffset(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo); +void SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT ModeIdIndex); +#ifdef LINUX_XF86 +BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch); +BOOLEAN SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom); +BOOLEAN SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom); +BOOLEAN SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom); +int SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber); +BOOLEAN SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_INFO); +USHORT SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags); +DisplayModePtr SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfordvi); +#else +BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,USHORT ModeNo); +#endif #ifdef LINUX_KERNEL -int sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, +int sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, unsigned char modeno, unsigned char rateindex); -int sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, +int sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, unsigned char modeno, unsigned char rateindex, - ULONG *left_margin, ULONG *right_margin, + ULONG *left_margin, ULONG *right_margin, ULONG *upper_margin, ULONG *lower_margin, ULONG *hsync_len, ULONG *vsync_len, ULONG *sync, ULONG *vmode); +BOOLEAN sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex); +#endif + +extern void SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo, int chkcrt2mode); +extern void SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo); +extern void SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +extern void SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); +extern void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +extern void SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +extern void SiS_DisableBridge(SiS_Private *, PSIS_HW_INFO); +extern BOOLEAN SiS_SetCRT2Group(SiS_Private *, PSIS_HW_INFO, USHORT); +extern USHORT SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo); +extern void SiS_WaitRetrace1(SiS_Private *SiS_Pr); +extern USHORT SiS_GetResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); +extern USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax); +extern USHORT SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo); +extern BOOLEAN SiS_IsVAMode(SiS_Private *, PSIS_HW_INFO); +extern BOOLEAN SiS_IsDualEdge(SiS_Private *, PSIS_HW_INFO); + +#ifdef LINUX_XF86 +extern int SiS_compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div, + int *out_sbit, int *out_scale); +extern void SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD, unsigned int *vclk); + +extern unsigned char SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, unsigned char value); +extern unsigned char SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id); +extern USHORT SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, unsigned long VBFlags, + BOOLEAN hcm); #endif #endif diff -puN drivers/video/sis/oem300.h~sisfb-update drivers/video/sis/oem300.h --- 25/drivers/video/sis/oem300.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/oem300.h 2004-01-22 03:06:55.000000000 -0800 @@ -1,5 +1,56 @@ - -/* OEM Data for 300 series */ +/* $XFree86$ */ +/* + * OEM Data for 300 series + * + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the Linux kernel, the following license terms + * apply: + * + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Otherwise, the following license terms apply: + * + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) All advertising materials mentioning features or use of this software + * * must display the following acknowledgement: "This product includes + * * software developed by Thomas Winischhofer, Vienna, Austria." + * * 4) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * + */ const UCHAR SiS300_OEMTVDelay301[8][4] = { @@ -245,140 +296,124 @@ const UCHAR SiS300_OEMLCDDelay3[64][4] = {0x20,0x20,0x20,0x20} }; -const UCHAR SiS300_Phase1[8][6][4] = +const UCHAR SiS300_Phase1[8][5][4] = { { {0x21,0xed,0x00,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08}, - {0x21,0xed,0x8a,0x08}, - {0xff,0xff,0xff,0xff} + {0x21,0xed,0x8a,0x08} }, { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, - {0x2a,0x05,0xd3,0x00}, - {0xff,0xff,0xff,0xff} + {0x2a,0x05,0xd3,0x00} }, { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, - {0x2a,0x05,0xd3,0x00}, - {0xff,0xff,0xff,0xff} + {0x2a,0x05,0xd3,0x00} }, { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, - {0x2a,0x05,0xd3,0x00}, - {0xff,0xff,0xff,0xff} + {0x2a,0x05,0xd3,0x00} }, { {0x21,0xed,0x00,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08}, - {0x21,0xed,0x8a,0x08}, - {0xff,0xff,0xff,0xff} + {0x21,0xed,0x8a,0x08} }, { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, - {0x2a,0x05,0xd3,0x00}, - {0xff,0xff,0xff,0xff} + {0x2a,0x05,0xd3,0x00} }, { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, - {0x2a,0x05,0xd3,0x00}, - {0xff,0xff,0xff,0xff} + {0x2a,0x05,0xd3,0x00} }, { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, - {0x2a,0x05,0xd3,0x00}, - {0xff,0xff,0xff,0xff} + {0x2a,0x05,0xd3,0x00} } }; -const UCHAR SiS300_Phase2[8][6][4] = +const UCHAR SiS300_Phase2[8][5][4] = { { {0x21,0xed,0x00,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08}, - {0x21,0xed,0x8a,0x08}, - {0xff,0xff,0xff,0xff} + {0x21,0xed,0x8a,0x08} }, { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, - {0x2a,0x05,0xd3,0x00}, - {0xff,0xff,0xff,0xff} + {0x2a,0x05,0xd3,0x00} }, { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, - {0x2a,0x05,0xd3,0x00}, - {0xff,0xff,0xff,0xff} + {0x2a,0x05,0xd3,0x00} }, { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, - {0x2a,0x05,0xd3,0x00}, - {0xff,0xff,0xff,0xff} + {0x2a,0x05,0xd3,0x00} }, { {0x21,0xed,0x00,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08}, - {0x21,0xed,0x8a,0x08}, - {0xff,0xff,0xff,0xff} + {0x21,0xed,0x8a,0x08} }, { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, - {0x2a,0x05,0xd3,0x00}, - {0xff,0xff,0xff,0xff} + {0x2a,0x05,0xd3,0x00} }, { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, - {0x2a,0x05,0xd3,0x00}, - {0xff,0xff,0xff,0xff} + {0x2a,0x05,0xd3,0x00} }, { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, - {0x2a,0x05,0xd3,0x00}, - {0xff,0xff,0xff,0xff} + {0x2a,0x05,0xd3,0x00} } }; @@ -680,325 +715,147 @@ const UCHAR SiS300_Filter2[10][9][7] = } }; -const UCHAR SiS300_LCDHData[24][11][5] = { +/* Custom data for Barco iQ Pro R300 */ +const UCHAR barco_p1[2][9][7][3] = { { - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x65,0xef,0x83,0x5c,0x00}, - {0x65,0xef,0x83,0x5c,0x00}, - {0x8a,0x14,0x00,0x80,0x00}, - {0x8a,0x14,0x00,0x80,0x00} - }, - { - {0x4e,0x18,0x90,0x38,0x00}, - {0x4e,0x18,0x90,0x38,0x00}, - {0x8e,0x18,0x28,0x78,0x00}, - {0x8e,0x18,0x28,0x78,0x00}, - {0x8e,0x18,0x28,0x78,0x00}, - {0x4e,0x18,0x90,0x38,0x00}, - {0x4e,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9a,0x56,0x00}, - {0x67,0x11,0x9a,0x56,0x00}, - {0x8a,0x14,0x00,0x80,0x00}, - {0x8a,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x65,0xef,0x83,0x5c,0x00}, - {0x65,0xef,0x83,0x5c,0x00}, - {0x8a,0x14,0x00,0x80,0x00}, - {0x8a,0x14,0x00,0x80,0x00} - }, - { - {0x4e,0x18,0x90,0x38,0x00}, - {0x4e,0x18,0x90,0x38,0x00}, - {0x8e,0x18,0x28,0x78,0x00}, - {0x8e,0x18,0x28,0x78,0x00}, - {0x8e,0x18,0x28,0x78,0x00}, - {0x4e,0x18,0x90,0x38,0x00}, - {0x4e,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9a,0x56,0x00}, - {0x67,0x11,0x9a,0x56,0x00}, - {0x8a,0x14,0x00,0x80,0x00}, - {0x8a,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x65,0xef,0x83,0x5c,0x00}, - {0x65,0xef,0x83,0x5c,0x00}, - {0x8a,0x14,0x00,0x80,0x00}, - {0x8a,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} + { { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x19, 0x00 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x1e, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x16, 0x00 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x19, 0x00 }, + { 0, 0, 0 } + }, + { + { 0, 0, 0 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x1e, 0x00 }, + { 0, 0, 0 } + }, + { + { 0x16, 0xd1, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x11, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x26, 0x00 } + }, + { + { 0x16, 0xd1, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x30, 0x00 }, + { 0, 0, 0 } + }, + { + { 0x16, 0x00, 0x00 }, + { 0x17, 0xa0, 0x00 }, + { 0x1a, 0xa0, 0x00 }, + { 0x1b, 0x2a, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0, 0, 0 } + }, + { + { 0x16, 0x00, 0x00 }, + { 0x17, 0xaa, 0x00 }, + { 0x1a, 0xa0, 0x00 }, + { 0x1b, 0x2a, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0, 0, 0 } + } + }, + { + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x19, 0x00 } + }, + { + { 0, 0, 0 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x19, 0x00 }, + }, + { + { 0, 0, 0 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x1e, 0x00 } + }, + { + { 0x16, 0xd1, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe6, 0x00 }, + { 0x1b, 0x11, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x26, 0x00 } + }, + { + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe0, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x30, 0x00 }, + { 0, 0, 0 } + }, + { + { 0, 0, 0 } + }, + { + { 0, 0, 0 } + } } }; -#if 0 -const UCHAR SiS300_LCDVData[24][11][6] = { - { - { - }, -}; -#endif + + + + + diff -puN drivers/video/sis/oem310.h~sisfb-update drivers/video/sis/oem310.h --- 25/drivers/video/sis/oem310.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/oem310.h 2004-01-22 03:06:55.000000000 -0800 @@ -1,7 +1,58 @@ +/* $XFree86$ */ +/* + * OEM Data for 315/330 series + * + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the Linux kernel, the following license terms + * apply: + * + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Otherwise, the following license terms apply: + * + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) All advertising materials mentioning features or use of this software + * * must display the following acknowledgement: "This product includes + * * software developed by Thomas Winischhofer, Vienna, Austria." + * * 4) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * + */ -/* OEM Data for 310/325/330 series */ - -const UCHAR SiS310_LCDDelayCompensation_301[] = /* 301 */ +static const UCHAR SiS310_LCDDelayCompensation_301[] = /* 301 */ { 0x00,0x00,0x00, /* 800x600 */ 0x0b,0x0b,0x0b, /* 1024x768 */ @@ -21,7 +72,7 @@ const UCHAR SiS310_LCDDelayCompensation_ }; /* This is contained in 650+301B BIOSes, but it is wrong - so we don't use it */ -UCHAR SiS310_LCDDelayCompensation_650301B[] = /* 30xB,LV */ +static const UCHAR SiS310_LCDDelayCompensation_650301LV[] = /* 650 + 30xLV */ { 0x01,0x01,0x01, /* 800x600 */ 0x01,0x01,0x01, /* 1024x768 */ @@ -40,67 +91,9 @@ UCHAR SiS310_LCDDelayCompensation_650301 0x02,0x02,0x02 }; -/* This data is correct, so we use it instead of the table above */ -UCHAR SiS310_LCDDelayCompensation_3xx301B[] = /* 30xB,LV */ -{ - 0x01,0x01,0x01, /* 800x600 */ - 0x0C,0x0C,0x0C, /* 1024x768 */ - 0x0C,0x0C,0x0C, /* 1280x1024 */ - 0x08,0x08,0x08, /* 640x480 */ - 0x0C,0x0C,0x0C, /* 1024x600 (guessed) */ - 0x0C,0x0C,0x0C, /* 1152x864 (guessed) */ - 0x0C,0x0C,0x0C, /* 1280x960 (guessed) */ - 0x0C,0x0C,0x0C, /* 1152x768 (guessed) */ - 0x0C,0x0C,0x0C, /* 1400x1050 (guessed) */ - 0x0C,0x0C,0x0C, /* 1280x768 (guessed) */ - 0x0C,0x0C,0x0C, /* 1600x1200 (guessed) */ - 0x02,0x02,0x02, - 0x02,0x02,0x02, - 0x02,0x02,0x02, - 0x02,0x02,0x02 -}; - -const UCHAR SiS310_LCDDelayCompensation_LVDS650[] = /* LVDS */ +static const UCHAR SiS310_LCDDelayCompensation_651301LV[] = /* M650/651 301LV */ { - 0x00,0x00,0x00, /* 800x600 */ - 0x00,0x00,0x00, /* 1024x768 */ - 0x00,0x00,0x00, /* 1280x1024 */ - 0x00,0x00,0x00, /* 640x480 (unknown) */ - 0x00,0x00,0x00, /* 1024x600 (unknown) */ - 0x00,0x00,0x00, /* 1152x864 (unknown) */ - 0x00,0x00,0x00, /* 1280x960 (guessed) */ - 0x00,0x00,0x00, /* 1152x768 (unknown) */ - 0x00,0x00,0x00, /* 1400x1050 */ - 0x00,0x00,0x00, /* 1280x768 (guessed) */ - 0x00,0x00,0x00, /* 1600x1200 */ - 0x00,0x00,0x00, - 0x00,0x00,0x00, - 0x00,0x00,0x00, - 0x00,0x00,0x00 -}; - -const UCHAR SiS310_LCDDelayCompensation_LVDS740[] = /* LVDS */ -{ - 0x03,0x03,0x03, /* 800x600 */ - 0x03,0x03,0x03, /* 1024x768 */ - 0x03,0x03,0x03, /* 1280x1024 */ - 0x03,0x03,0x03, /* 640x480 (unknown) */ - 0x03,0x03,0x03, /* 1024x600 (unknown) */ - 0x03,0x03,0x03, /* 1152x864 (unknown) */ - 0x03,0x03,0x03, /* 1280x960 (guessed) */ - 0x03,0x03,0x03, /* 1152x768 (unknown) */ - 0x03,0x03,0x03, /* 1400x1050 */ - 0x03,0x03,0x03, /* 1280x768 (guessed) */ - 0x03,0x03,0x03, /* 1600x1200 */ - 0x00,0x00,0x00, - 0x00,0x00,0x00, - 0x00,0x00,0x00, - 0x00,0x00,0x00 -}; - -const UCHAR SiS310_LCDDelayCompensation_651301LV[] = /* M650/651 301LV */ -{ - 0x33,0x33,0x33, /* 800x600 (guessed) */ + 0x33,0x33,0x33, /* 800x600 (guessed) - new: PanelType, not PanelRes ! */ 0x33,0x33,0x33, /* 1024x768 */ 0x33,0x33,0x33, /* 1280x1024 */ 0x33,0x33,0x33, /* 640x480 (unknown) */ @@ -117,7 +110,7 @@ const UCHAR SiS310_LCDDelayCompensation_ 0x33,0x33,0x33 }; -const UCHAR SiS310_LCDDelayCompensation_651302LV[] = /* M650/651 302LV */ +static const UCHAR SiS310_LCDDelayCompensation_651302LV[] = /* M650/651 302LV */ { 0x33,0x33,0x33, /* 800x600 (guessed) */ 0x33,0x33,0x33, /* 1024x768 */ @@ -136,66 +129,111 @@ const UCHAR SiS310_LCDDelayCompensation_ 0x33,0x33,0x33 }; -const UCHAR SiS310_TVDelayCompensation_301[] = /* 301 */ +static const UCHAR SiS310_LCDDelayCompensation_3xx301B[] = /* 30xB,LV */ +{ + 0x01,0x01,0x01, /* 800x600 */ + 0x0C,0x0C,0x0C, /* 1024x768 */ + 0x0C,0x0C,0x0C, /* 1280x1024 */ + 0x08,0x08,0x08, /* 640x480 */ + 0x0C,0x0C,0x0C, /* 1024x600 (guessed) */ + 0x0C,0x0C,0x0C, /* 1152x864 (guessed) */ + 0x0C,0x0C,0x0C, /* 1280x960 (guessed) */ + 0x0C,0x0C,0x0C, /* 1152x768 (guessed) */ + 0x0C,0x0C,0x0C, /* 1400x1050 (guessed) */ + 0x0C,0x0C,0x0C, /* 1280x768 (guessed) */ + 0x0C,0x0C,0x0C, /* 1600x1200 (guessed) */ + 0x02,0x02,0x02, + 0x02,0x02,0x02, + 0x02,0x02,0x02, + 0x02,0x02,0x02 +}; + +static const UCHAR SiS310_TVDelayCompensation_301[] = /* 301 */ { 0x02,0x02, /* NTSC Enhanced, Standard */ 0x02,0x02, /* PAL */ 0x08,0x0b /* HiVision */ }; -const UCHAR SiS310_TVDelayCompensation_301B[] = /* 30xB, 30xLV */ +static const UCHAR SiS310_TVDelayCompensation_301B[] = /* 30xB, 30xLV */ { 0x03,0x03, 0x03,0x03, 0x03,0x03 }; -const UCHAR SiS310_TVDelayCompensation_740301B[] = /* 740 + 30xB (30xLV?) */ +static const UCHAR SiS310_TVDelayCompensation_740301B[] = /* 740 + 30xB (30xLV?) */ { 0x05,0x05, 0x05,0x05, 0x05,0x05 }; -const UCHAR SiS310_TVDelayCompensation_LVDS[] = /* LVDS */ +static const UCHAR SiS310_TVDelayCompensation_LVDS[] = /* LVDS */ { 0x0a,0x0a, 0x0a,0x0a, 0x0a,0x0a }; -const UCHAR SiS310_TVDelayCompensation_651301LV[] = /* M650, 651, 301LV */ +static const UCHAR SiS310_TVDelayCompensation_651301LV[] = /* M650, 651, 301LV */ { 0x33,0x33, 0x33,0x33, 0x33,0x33 }; -const UCHAR SiS310_TVDelayCompensation_651302LV[] = /* M650, 651, 302LV */ +static const UCHAR SiS310_TVDelayCompensation_651302LV[] = /* M650, 651, 302LV */ { 0x33,0x33, 0x33,0x33, 0x33,0x33 }; -const UCHAR SiS310_TVAntiFlick1[3][2] = +static const UCHAR SiS_TVDelay661_301[] = /* 661, 301 */ +{ + 0x44,0x44, + 0x44,0x44, + 0x00,0x00, + 0x44,0x44, + 0x44,0x44, + 0x44,0x44 +}; + +static const UCHAR SiS_TVDelay661_301B[] = /* 661, 301B et al */ +{ + 0x44,0x44, + 0x44,0x44, + 0x00,0x00, + 0x44,0x44, + 0x44,0x44, + 0x44,0x44 +}; + +static const UCHAR SiS310_TVAntiFlick1[6][2] = { {0x4,0x0}, {0x4,0x8}, + {0x0,0x0}, + {0x0,0x0}, + {0x0,0x0}, {0x0,0x0} }; -const UCHAR SiS310_TVEdge1[3][2] = +static const UCHAR SiS310_TVEdge1[6][2] = { {0x0,0x4}, {0x0,0x4}, + {0x0,0x0}, + {0x0,0x0}, + {0x0,0x0}, {0x0,0x0} }; -const UCHAR SiS310_TVYFilter1[3][8][4] = +static const UCHAR SiS310_TVYFilter1[5][8][4] = { { - {0x00,0xf4,0x10,0x38}, + {0x00,0xf4,0x10,0x38}, /* NTSC */ {0x00,0xf4,0x10,0x38}, {0xeb,0x04,0x25,0x18}, {0xf1,0x04,0x1f,0x18}, @@ -205,7 +243,7 @@ const UCHAR SiS310_TVYFilter1[3][8][4] = {0xeb,0x15,0x25,0xf6} }, { - {0x00,0xf4,0x10,0x38}, + {0x00,0xf4,0x10,0x38}, /* PAL */ {0x00,0xf4,0x10,0x38}, {0xf1,0xf7,0x1f,0x32}, {0xf3,0x00,0x1d,0x20}, @@ -215,7 +253,7 @@ const UCHAR SiS310_TVYFilter1[3][8][4] = {0xfc,0xfb,0x14,0x2a} }, { - {0x00,0x00,0x00,0x00}, + {0x00,0x00,0x00,0x00}, /* HiVision */ {0x00,0xf4,0x10,0x38}, {0x00,0xf4,0x10,0x38}, {0xeb,0x04,0x25,0x18}, @@ -223,13 +261,33 @@ const UCHAR SiS310_TVYFilter1[3][8][4] = {0x00,0xf4,0x10,0x38}, {0xeb,0x04,0x25,0x18}, {0xee,0x0c,0x22,0x08} + }, + { + {0x00,0xf4,0x10,0x38}, /* PAL-M */ + {0x00,0xf4,0x10,0x38}, + {0xeb,0x04,0x10,0x18}, + {0xf7,0x06,0x19,0x14}, + {0x00,0xf4,0x10,0x38}, + {0xeb,0x04,0x25,0x18}, + {0xeb,0x04,0x25,0x18}, + {0xeb,0x15,0x25,0xf6} + }, + { + {0x00,0xf4,0x10,0x38}, /* PAL-N */ + {0x00,0xf4,0x10,0x38}, + {0xeb,0x04,0x10,0x18}, + {0xf7,0x06,0x19,0x14}, + {0x00,0xf4,0x10,0x38}, + {0xeb,0x04,0x25,0x18}, + {0xeb,0x04,0x25,0x18}, + {0xeb,0x15,0x25,0xf6} } }; -const UCHAR SiS310_TVYFilter2[3][9][7] = +static const UCHAR SiS310_TVYFilter2[5][9][7] = { { - {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, + {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, /* NTSC */ {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, @@ -240,7 +298,7 @@ const UCHAR SiS310_TVYFilter2[3][9][7] = {0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28} }, { - {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, + {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, /* PAL */ {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, @@ -251,6 +309,7 @@ const UCHAR SiS310_TVYFilter2[3][9][7] = {0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28} }, { + {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22}, /* HiVision */ {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22}, {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22}, {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22}, @@ -259,53 +318,9 @@ const UCHAR SiS310_TVYFilter2[3][9][7] = {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22}, {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22}, {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22} - } -}; - -const UCHAR SiS310_PALMFilter[16][4] = -{ - {0x00,0xf4,0x10,0x38}, - {0x00,0xf4,0x10,0x38}, - {0xeb,0x04,0x10,0x18}, - {0xf7,0x06,0x19,0x14}, - {0x00,0xf4,0x10,0x38}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x15,0x25,0xf6}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18} -}; - -const UCHAR SiS310_PALNFilter[16][4] = -{ - {0x00,0xf4,0x10,0x38}, - {0x00,0xf4,0x10,0x38}, - {0xeb,0x04,0x10,0x18}, - {0xf7,0x06,0x19,0x14}, - {0x00,0xf4,0x10,0x38}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x15,0x25,0xf6}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18}, - {0xeb,0x04,0x25,0x18} -}; - - -const UCHAR SiS310_PALMFilter2[9][7] = -{ - {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, + }, + { + {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, /* PAL-M */ {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, @@ -314,11 +329,9 @@ const UCHAR SiS310_PALMFilter2[9][7] = {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0x01,0x01,0xFC,0xF8,0x08,0x26,0x38}, {0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28} -}; - -const UCHAR SiS310_PALNFilter2[9][7] = -{ - {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, + }, + { + {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, /* PAL-N */ {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, @@ -327,9 +340,10 @@ const UCHAR SiS310_PALNFilter2[9][7] = {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0x01,0x01,0xFC,0xF8,0x08,0x26,0x38}, {0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28} + } }; -const UCHAR SiS310_TVPhaseIncr1[3][2][4] = +static const UCHAR SiS310_TVPhaseIncr1[3][2][4] = { { {0x21,0xed,0xba,0x08}, @@ -345,15 +359,15 @@ const UCHAR SiS310_TVPhaseIncr1[3][2][4] } }; -const UCHAR SiS310_TVPhaseIncr2[3][2][4] = +static const UCHAR SiS310_TVPhaseIncr2[3][2][4] = { { - {0x21,0xf0,0x7b,0xd6}, /* 1.10.7w; 1.10.6s: {0x1e,0x8b,0xda,0xa7}, old: {0x21,0xF1,0x37,0x56} */ - {0x21,0xf0,0x7b,0xd6} /* 1.10.7w; 1.10.6s: {0x1e,0x8b,0xda,0xa7} old: {0x21,0xF1,0x37,0x56} */ + {0x21,0xf0,0x7b,0xd6}, + {0x21,0xf0,0x7b,0xd6} }, { - {0x2a,0x0a,0x41,0xe9}, /* 1.10.7w, 1.10.6s. old: {0x2a,0x09,0x86,0xe9}, */ - {0x2a,0x0a,0x41,0xe9} /* 1.10.7w, 1.10.6s. old: {0x2a,0x09,0x86,0xe9} */ + {0x2a,0x0a,0x41,0xe9}, + {0x2a,0x0a,0x41,0xe9} }, { {0x2a,0x05,0xd3,0x00}, @@ -361,5 +375,239 @@ const UCHAR SiS310_TVPhaseIncr2[3][2][4] } }; +static const UCHAR SiS661_TVPhase[] = { + 0x21,0xED,0xBA,0x08, + 0x2A,0x05,0xE3,0x00, + 0x21,0xE4,0x2E,0x9B, + 0x21,0xF4,0x3E,0xBA, + 0x1E,0x8B,0xA2,0xA7, + 0x1E,0x83,0x0A,0xE0, + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + 0x21,0xF0,0x7B,0xD6, + 0x2A,0x09,0x86,0xE9, + 0x21,0xE6,0xEF,0xA4, + 0x21,0xF6,0x94,0x46, + 0x1E,0x8B,0xA2,0xA7, + 0x1E,0x83,0x0A,0xE0, + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00 +}; + +/**************************************************************/ +/* CUSTOM TIMING DATA --------------------------------------- */ +/**************************************************************/ + +/* Inventec / Compaq Presario 3045US, 3017 */ + +static const SiS_LCDDataStruct SiS310_ExtCompaq1280x1024Data[] = +{ + { 211, 60,1024, 501,1688,1066}, + { 211, 60,1024, 508,1688,1066}, + { 211, 60,1024, 501,1688,1066}, + { 211, 60,1024, 508,1688,1066}, + { 32, 15,1696, 501,1696,1066}, + { 212, 75,1024, 621,1696,1066}, + { 4, 3,1696, 810,1696,1066}, + { 1, 1,1696,1066,1696,1066} +}; + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Compaq1280x1024_1[] = +{ + {{0x3F,0x1B,0xD0,0xF0,0xB0,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x35,0x1B,0xA0,0xC0,0x80,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x3F,0x1B,0xD0,0xF0,0xB0,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x3F,0x1B,0xD0,0xF0,0xB0,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x45,0x1C,0x20,0x3F,0xFF,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x49,0x1C,0x40,0x7F,0xFF,0xAD,0x23,0x0A,0x07,0xF3,0x8A,0x12}}, + {{0x4C,0x1C,0x18,0x2F,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x48,0x1C,0x15,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}} +}; + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Compaq1280x1024_2[] = +{ + {{0x2B,0x12,0xD9,0xE5,0xD5,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}}, + {{0x22,0x12,0xC0,0xCC,0xBC,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}}, + {{0x2B,0x12,0xD9,0xE5,0xD5,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}}, + {{0x22,0x12,0xC0,0xCC,0xBC,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}}, + {{0x33,0x13,0x01,0x0D,0xFD,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}}, + {{0x3F,0x1B,0x3D,0x49,0x39,0x54,0x23,0xC0,0x27,0x66,0x30,0x42}}, + {{0x33,0x1B,0x91,0x9D,0x8D,0x8C,0x23,0xF8,0x27,0x9E,0x68,0x42}}, + {{0x43,0x24,0x11,0x1D,0x0D,0xCC,0x23,0x38,0x37,0xDE,0xA8,0x42}}, + {{0x43,0x24,0x21,0x29,0x19,0xEA,0x23,0x0A,0x07,0x32,0xC6,0x42}} +}; + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Compaq1280x1024_3[] = +{ + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBE,0x23,0x0A,0x07,0x26,0x8A,0x42}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBE,0x23,0x0A,0x07,0x26,0x8A,0x42}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBE,0x23,0x0A,0x07,0x26,0x8A,0x42}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBE,0x23,0x0A,0x07,0x26,0x8A,0x42}} +}; + +/* LCDA CRT2 data is std */ + +static const SiS_LVDSDesStruct Compaq1280x1024Des_1[] = +{ + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 } +}; + +static const SiS_LVDSDesStruct Compaq1280x1024Des_2[] = +{ + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 } +}; + +/* Clevo L285/287 (dual-link 1024x768) */ + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Clevo1024x768_1[] = +{ + {{0x25,0x12,0xC9,0xDC,0xB6,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}}, + {{0x2C,0x12,0x9A,0xAE,0x88,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}}, + {{0x25,0x12,0xC9,0xDC,0xB6,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x38,0x13,0x16,0x0C,0xE6,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}}, + {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}}, + {{0x36,0x13,0x13,0x25,0xFF,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x25,0x12,0xC9,0xDC,0xB6,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}} +}; + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Clevo1024x768_2[] = +{ + {{0x25,0x12,0x51,0x6E,0x48,0xCC,0x12,0x89,0x47,0x1C,0x49,0x33}}, + {{0x2C,0x12,0x38,0x55,0x2F,0xCC,0x12,0x89,0x47,0x1C,0x49,0x33}}, + {{0x25,0x12,0x51,0x6E,0x48,0xCC,0x12,0x89,0x47,0x1C,0x49,0x33}}, + {{0x2C,0x12,0x38,0x55,0x2F,0xE0,0x12,0xB1,0x47,0x30,0x71,0x33}}, + {{0x2D,0x12,0x79,0x96,0x70,0xCC,0x12,0x89,0x47,0x1C,0x49,0x33}}, + {{0x29,0x12,0xB5,0xD2,0xAC,0xF4,0x12,0xD9,0x47,0x44,0x99,0x33}}, + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, +#if 0 + {{0x25,0x12,0x51,0x6E,0x48,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x2C,0x12,0x38,0x55,0x2F,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x25,0x12,0x51,0x6E,0x48,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x2C,0x12,0x38,0x55,0x2F,0xC1,0x35,0xB1,0x47,0xE9,0x71,0x33}}, + {{0x2D,0x12,0x79,0x96,0x70,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x29,0x12,0xB5,0xD2,0xAC,0xE9,0x35,0xD9,0x47,0x11,0x99,0x33}}, + {{0x36,0x13,0x13,0x25,0xFF,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}} +#endif +}; + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Clevo1024x768_3[] = +{ + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, /* Corrected */ + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x25,0x13,0xC9,0x25,0xFF,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}} +}; + +/* CRT2 data is std */ + +static const SiS_LVDSDesStruct Clevo1024x768Des_1[] = +{ + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 } +}; + +static const SiS_LVDSDesStruct Clevo1024x768Des_2[] = +{ + { 1184, 622 }, + { 1184, 597 }, + { 1184, 622 }, + { 1184, 597 }, + { 1152, 622 }, + { 1232, 722 }, + { 0, 0 } +}; + +/* Asus A2xxxH _2 */ + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Asus1024x768_3[] = +{ + {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x2c,0x13,0x9a,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x38,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x38,0x13,0x16,0x25,0xff,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x36,0x13,0x13,0x25,0xff,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}} +}; + +static const SiS_LVDSDesStruct Asus1024x768Des_1[] = +{ + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 } +}; + +static const SiS_LVDSDesStruct Asus1024x768Des_2[] = +{ + { 1184, 622 }, + { 1184, 597 }, + { 1184, 622 }, + { 1184, 597 }, + { 1152, 622 }, + { 1232, 722 }, + { 0, 0 } +}; + +/* CRT2 data is std */ + +/* Uniwill N243S9, ECS A928 */ + +static const SiS_LVDSDesStruct Uniwill1024x768Des_1[] = +{ + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 805 } +}; + +static const SiS_LVDSDesStruct Uniwill1024x768Des_2[] = +{ + { 1184, 622 }, + { 1184, 597 }, + { 1184, 622 }, + { 1184, 597 }, + { 1152, 650 }, + { 1232, 722 }, + { 0, 805 }, +}; diff -puN drivers/video/sis/osdef.h~sisfb-update drivers/video/sis/osdef.h --- 25/drivers/video/sis/osdef.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/osdef.h 2004-01-22 03:06:55.000000000 -0800 @@ -1,79 +1,95 @@ -/* #define WINCE_HEADER */ -/* #define WIN2000 */ -/* #define TC */ +/* $XFree86$ */ +/* + * OS depending defines + * + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the Linux kernel, the following license terms + * apply: + * + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Otherwise, the following license terms apply: + * + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) All advertising materials mentioning features or use of this software + * * must display the following acknowledgement: "This product includes + * * software developed by Thomas Winischhofer, Vienna, Austria." + * * 4) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * Silicon Integrated Systems, Inc. (used by permission) + * + */ + +/* The choices are: */ + #define LINUX_KERNEL /* Kernel framebuffer */ /* #define LINUX_XF86 */ /* XFree86 */ /**********************************************************************/ -#ifdef LINUX_KERNEL - #include - #include - #ifdef CONFIG_FB_SIS_300 - #define SIS300 - #endif - - #ifdef CONFIG_FB_SIS_315 - #define SIS315H - #endif - #if 1 - #define SISFBACCEL /* Include 2D acceleration */ - #endif - #if 1 - #define SISFB_PAN /* Include Y-Panning code */ - #endif -#else -/* #define SIS300*/ - #define SIS315H -#endif -#ifdef LINUX_XF86 - #define SIS300 - /* #define SIS315H */ /* TW: done above */ -#endif +#ifdef LINUX_KERNEL /* -------------------------- */ +#include +#include -/**********************************************************************/ -#ifdef TC -#endif -#ifdef WIN2000 -#endif -#ifdef WINCE_HEADER +#ifdef CONFIG_FB_SIS_300 +#define SIS300 #endif -#ifdef LINUX_XF86 -#endif -#ifdef LINUX_KERNEL -#endif -/**********************************************************************/ -#ifdef TC -#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize); -#endif -#ifdef WIN2000 -#define SiS_SetMemory(MemoryAddress,MemorySize,value) MemFill((PVOID) MemoryAddress,(ULONG) MemorySize,(UCHAR) value); + +#ifdef CONFIG_FB_SIS_315 +#define SIS315H #endif -#ifdef WINCE_HEADER -#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize); + +#if 1 +#define SISFBACCEL /* Include 2D acceleration */ #endif -#ifdef LINUX_XF86 -#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize) + #endif -#ifdef LINUX_KERNEL -#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize) + +#ifdef LINUX_XF86 /* ----------------------------- */ +#define SIS300 +#define SIS315H #endif -/**********************************************************************/ /**********************************************************************/ - -#ifdef TC -#define SiS_MemoryCopy(Destination,Soruce,Length) memmove(Destination, Soruce, Length); -#endif -#ifdef WIN2000 -#define SiS_MemoryCopy(Destination,Soruce,Length) /*VideoPortMoveMemory((PUCHAR)Destination , Soruce,length);*/ -#endif -#ifdef WINCE_HEADER -#define SiS_MemoryCopy(Destination,Soruce,Length) memmove(Destination, Soruce, Length); -#endif #ifdef LINUX_XF86 +#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize) #define SiS_MemoryCopy(Destination,Soruce,Length) memcpy(Destination,Soruce,Length) #endif + #ifdef LINUX_KERNEL +#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize) #define SiS_MemoryCopy(Destination,Soruce,Length) memcpy(Destination,Soruce,Length) #endif @@ -104,19 +120,6 @@ #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 */ /**********************************************************************/ @@ -142,29 +145,4 @@ #define InPortLong(p) inl((u16)(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 diff -puN drivers/video/sis/sis_accel.c~sisfb-update drivers/video/sis/sis_accel.c --- 25/drivers/video/sis/sis_accel.c~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/sis_accel.c 2004-01-22 03:06:55.000000000 -0800 @@ -1,14 +1,27 @@ /* - * SiS 300/630/730/540/315/550/650/740 frame buffer driver - * for Linux kernels 2.4.x and 2.5.x + * SiS 300/630/730/540/315/550/65x/74x/330/760 frame buffer driver + * for Linux kernels 2.4.x and 2.6.x * * 2D acceleration part * - * Based on the X driver's sis300_accel.c which is - * Copyright Xavier Ducoin - * Copyright 2002 by Thomas Winischhofer, Vienna, Austria + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the named License, + * or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Based on the XFree86 driver's sis300_accel.c which is + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * and sis310_accel.c which is - * Copyright 2002 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * * Author: Thomas Winischhofer * (see http://www.winischhofer.net/ @@ -114,8 +127,8 @@ static const unsigned char myrops[] = { }; #endif -/* 300 series */ - +/* 300 series ----------------------------------------------------- */ +#ifdef CONFIG_FB_SIS_300 static void SiS300Sync(void) { @@ -123,12 +136,6 @@ SiS300Sync(void) } static void -SiS310Sync(void) -{ - SiS310Idle -} - -static void SiS300SetupForScreenToScreenCopy(int xdir, int ydir, int rop, unsigned int planemask, int trans_color) { @@ -210,8 +217,16 @@ SiS300SubsequentSolidFillRect(int x, int SiS300SetupCMDFlag(X_INC | Y_INC | BITBLT) SiS300DoCMD } +#endif -/* 310/325 series ------------------------------------------------ */ +/* 315/330 series ------------------------------------------------- */ + +#ifdef CONFIG_FB_SIS_315 +static void +SiS310Sync(void) +{ + SiS310Idle +} static void SiS310SetupForScreenToScreenCopy(int xdir, int ydir, int rop, @@ -230,7 +245,7 @@ SiS310SetupForScreenToScreenCopy(int xdi /* SiSSetupCMDFlag(BITBLT | SRCVIDEO) */ } SiS310SetupCMDFlag(ivideo.SiS310_AccelDepth) - /* TW: The 310/325 series is smart enough to know the direction */ + /* The 315 series is smart enough to know the direction */ } static void @@ -306,6 +321,7 @@ SiS310SubsequentSolidFillRect(int x, int SiS310SetupCMDFlag(BITBLT) SiS310DoCMD } +#endif /* --------------------------------------------------------------------- */ @@ -322,22 +338,33 @@ int sisfb_initaccel(void) void sisfb_syncaccel(void) { if(sisvga_engine == SIS_300_VGA) { +#ifdef CONFIG_FB_SIS_300 SiS300Sync(); +#endif } else { +#ifdef CONFIG_FB_SIS_315 SiS310Sync(); +#endif } } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,34) /* --- KERNEL 2.5.34 and later --- */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) /* --------------- 2.5 --------------- */ int fbcon_sis_sync(struct fb_info *info) { - if(!sisfb_accel) return 0; CRITFLAGS + + if(!ivideo.accel) + return 0; + if(sisvga_engine == SIS_300_VGA) { +#ifdef CONFIG_FB_SIS_300 SiS300Sync(); +#endif } else { +#ifdef CONFIG_FB_SIS_315 SiS310Sync(); +#endif } CRITEND return 0; @@ -352,32 +379,36 @@ void fbcon_sis_fillrect(struct fb_info * if(!rect->width || !rect->height) return; - if(!sisfb_accel) { + if(!ivideo.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; - } + 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; + } if(sisvga_engine == SIS_300_VGA) { - CRITBEGIN - SiS300SetupForSolidFill(col, myrops[rect->rop], 0); - SiS300SubsequentSolidFillRect(rect->dx, rect->dy, rect->width, rect->height); - CRITEND - SiS300Sync(); +#ifdef CONFIG_FB_SIS_300 + CRITBEGIN + SiS300SetupForSolidFill(col, myrops[rect->rop], 0); + SiS300SubsequentSolidFillRect(rect->dx, rect->dy, rect->width, rect->height); + CRITEND + SiS300Sync(); +#endif } else { - CRITBEGIN - SiS310SetupForSolidFill(col, myrops[rect->rop], 0); - SiS310SubsequentSolidFillRect(rect->dx, rect->dy, rect->width, rect->height); - CRITEND - SiS310Sync(); +#ifdef CONFIG_FB_SIS_315 + CRITBEGIN + SiS310SetupForSolidFill(col, myrops[rect->rop], 0); + SiS310SubsequentSolidFillRect(rect->dx, rect->dy, rect->width, rect->height); + CRITEND + SiS310Sync(); +#endif } } @@ -388,7 +419,7 @@ void fbcon_sis_copyarea(struct fb_info * CRITFLAGS TWDEBUG("Inside sis_copyarea"); - if(!sisfb_accel) { + if(!ivideo.accel) { cfb_copyarea(info, area); return; } @@ -402,23 +433,27 @@ void fbcon_sis_copyarea(struct fb_info * else ydir = 1; if(sisvga_engine == SIS_300_VGA) { +#ifdef CONFIG_FB_SIS_300 CRITBEGIN SiS300SetupForScreenToScreenCopy(xdir, ydir, 3, 0, -1); SiS300SubsequentScreenToScreenCopy(area->sx, area->sy, area->dx, area->dy, area->width, area->height); CRITEND SiS300Sync(); +#endif } else { +#ifdef CONFIG_FB_SIS_315 CRITBEGIN SiS310SetupForScreenToScreenCopy(xdir, ydir, 3, 0, -1); SiS310SubsequentScreenToScreenCopy(area->sx, area->sy, area->dx, area->dy, area->width, area->height); CRITEND SiS310Sync(); +#endif } } #endif -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,33) /* ------ KERNEL <2.5.34 ------ */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* -------------- 2.4 --------------- */ void fbcon_sis_bmove(struct display *p, int srcy, int srcx, int dsty, int dstx, int height, int width) @@ -460,25 +495,28 @@ void fbcon_sis_bmove(struct display *p, else ydir = 1; if(sisvga_engine == SIS_300_VGA) { +#ifdef CONFIG_FB_SIS_300 CRITBEGIN SiS300SetupForScreenToScreenCopy(xdir, ydir, 3, 0, -1); SiS300SubsequentScreenToScreenCopy(srcx, srcy, dstx, dsty, width, height); CRITEND SiS300Sync(); +#endif } else { +#ifdef CONFIG_FB_SIS_315 CRITBEGIN SiS310SetupForScreenToScreenCopy(xdir, ydir, 3, 0, -1); SiS310SubsequentScreenToScreenCopy(srcx, srcy, dstx, dsty, width, height); CRITEND SiS310Sync(); -#if 0 +#if 0 printk(KERN_INFO "sis_bmove sx %d sy %d dx %d dy %d w %d h %d\n", srcx, srcy, dstx, dsty, width, height); -#endif +#endif +#endif } } - static void fbcon_sis_clear(struct vc_data *conp, struct display *p, int srcy, int srcx, int height, int width, int color) { @@ -490,17 +528,21 @@ static void fbcon_sis_clear(struct vc_da height *= fontheight(p); if(sisvga_engine == SIS_300_VGA) { +#ifdef CONFIG_FB_SIS_300 CRITBEGIN SiS300SetupForSolidFill(color, 3, 0); SiS300SubsequentSolidFillRect(srcx, srcy, width, height); CRITEND SiS300Sync(); +#endif } else { +#ifdef CONFIG_FB_SIS_315 CRITBEGIN SiS310SetupForSolidFill(color, 3, 0); SiS310SubsequentSolidFillRect(srcx, srcy, width, height); CRITEND SiS310Sync(); +#endif } } @@ -575,54 +617,58 @@ void fbcon_sis_revc(struct display *p, i srcy *= fontheight(p); if(sisvga_engine == SIS_300_VGA) { +#ifdef CONFIG_FB_SIS_300 CRITBEGIN SiS300SetupForSolidFill(0, 0x0a, 0); SiS300SubsequentSolidFillRect(srcx, srcy, fontwidth(p), fontheight(p)); CRITEND SiS300Sync(); +#endif } else { +#ifdef CONFIG_FB_SIS_315 CRITBEGIN SiS310SetupForSolidFill(0, 0x0a, 0); SiS310SubsequentSolidFillRect(srcx, srcy, fontwidth(p), fontheight(p)); CRITEND SiS310Sync(); +#endif } } #ifdef FBCON_HAS_CFB8 struct display_switch fbcon_sis8 = { - setup: fbcon_cfb8_setup, - bmove: fbcon_sis_bmove, - clear: fbcon_sis_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) + .setup = fbcon_cfb8_setup, + .bmove = fbcon_sis_bmove, + .clear = fbcon_sis_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_sis16 = { - setup: fbcon_cfb16_setup, - bmove: fbcon_sis_bmove, - clear: fbcon_sis_clear16, - putc: fbcon_cfb16_putc, - putcs: fbcon_cfb16_putcs, - revc: fbcon_sis_revc, - clear_margins: fbcon_cfb16_clear_margins, - fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16) + .setup = fbcon_cfb16_setup, + .bmove = fbcon_sis_bmove, + .clear = fbcon_sis_clear16, + .putc = fbcon_cfb16_putc, + .putcs = fbcon_cfb16_putcs, + .revc = fbcon_sis_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_sis32 = { - setup: fbcon_cfb32_setup, - bmove: fbcon_sis_bmove, - clear: fbcon_sis_clear32, - putc: fbcon_cfb32_putc, - putcs: fbcon_cfb32_putcs, - revc: fbcon_sis_revc, - clear_margins: fbcon_cfb32_clear_margins, - fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16) + .setup = fbcon_cfb32_setup, + .bmove = fbcon_sis_bmove, + .clear = fbcon_sis_clear32, + .putc = fbcon_cfb32_putc, + .putcs = fbcon_cfb32_putcs, + .revc = fbcon_sis_revc, + .clear_margins = fbcon_cfb32_clear_margins, + .fontwidthmask = FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16) }; #endif diff -puN drivers/video/sis/sis_accel.h~sisfb-update drivers/video/sis/sis_accel.h --- 25/drivers/video/sis/sis_accel.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/sis_accel.h 2004-01-22 03:06:55.000000000 -0800 @@ -4,11 +4,24 @@ * * 2D acceleration part * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the named License, + * or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * * Based on the X driver's sis300_accel.h which is - * Copyright Xavier Ducoin - * Copyright 2002 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * and sis310_accel.h which is - * Copyright 2002 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * * Author: Thomas Winischhofer : * (see http://www.winischhofer.net/ @@ -47,7 +60,7 @@ #define TRAPAZOID_FILL 0x00000005 /* Fill trapezoid */ #define TRANSPARENT_BITBLT 0x00000006 /* Transparent Blit */ -/* Additional engine commands for 310/325 */ +/* Additional engine commands for 315 */ #define ALPHA_BLEND 0x00000007 /* Alpha blend ? */ #define A3D_FUNCTION 0x00000008 /* 3D command ? */ #define CLEAR_Z_BUFFER 0x00000009 /* ? */ @@ -90,11 +103,11 @@ #define NO_RESET_COUNTER 0x00400000 #define NO_LAST_PIXEL 0x00200000 -/* Subfunctions for Color/Enhanced Color Expansion (310/325 only) */ +/* Subfunctions for Color/Enhanced Color Expansion (315 only) */ #define COLOR_TO_MONO 0x00100000 #define AA_TEXT 0x00200000 -/* Some general registers for 310/325 series */ +/* Some general registers for 315 series */ #define SRC_ADDR 0x8200 #define SRC_PITCH 0x8204 #define AGP_BASE 0x8206 /* color-depth dependent value */ @@ -326,7 +339,7 @@ int CmdQueLen; -/* ----------- SiS 310/325 series --------------- */ +/* -------------- SiS 315 series --------------- */ /* Q_STATUS: bit 31 = 1: All engines idle and all queues empty @@ -342,16 +355,27 @@ int CmdQueLen; 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...) + can accept) on the 315 series? */ /* TW: FIXME: CmdQueLen is... where....? */ +/* We assume a length of 4 bytes per command; since 512K of + * of RAM are allocated, the number of commands is easily + * calculated (assuming that there is no 3D support yet) + * We calculate it very cautiously (128K only) and let the + * rest to the (never?)-to-come (?) 3D engine. (The 3D engine + * can use a similar technique, using the remaining 384K, + * hence a queue overflow is avoided) + * UPDATE: This technique causes a terrible system latency + * on integrated chipsets. Disable the queue handling for + * now. + */ #define SiS310Idle \ { \ while( (MMIO_IN16(ivideo.mmio_vbase, Q_STATUS+2) & 0x8000) != 0x8000){}; \ while( (MMIO_IN16(ivideo.mmio_vbase, Q_STATUS+2) & 0x8000) != 0x8000){}; \ - CmdQueLen=MMIO_IN16(ivideo.mmio_vbase, Q_STATUS); \ + CmdQueLen = 0; \ + /*CmdQueLen = ((128 * 1024) / 4) - 64; */ \ } #define SiS310SetupSRCBase(base) \ diff -puN drivers/video/sis/sis_main.c~sisfb-update drivers/video/sis/sis_main.c --- 25/drivers/video/sis/sis_main.c~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/sis_main.c 2004-01-22 03:06:55.000000000 -0800 @@ -1,25 +1,34 @@ /* - * SiS 300/630/730/540/315/550/650/740 frame buffer device - * for Linux kernels 2.4.x and 2.5.x + * SiS 300/630/730/540/315/550/650/651/M650/661FX/M661FX/740/741/M741/330/760 + * frame buffer driver for Linux kernels 2.4.x and 2.5.x * - * Partly based on the VBE 2.0 compliant graphic boards framebuffer driver, + * Copyright (C) 2001-2004 Thomas Winischhofer, Vienna, Austria. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the named License, + * or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Author: Thomas Winischhofer + * + * Author of code base: + * SiS (www.sis.com.tw) + * Copyright (C) 1999 Silicon Integrated Systems, Inc. + * + * See http://www.winischhofer.net/ for more information and updates + * + * Originally based on the VBE 2.0 compliant graphic boards framebuffer driver, * which is (c) 1998 Gerd Knorr * - * Authors: SiS (www.sis.com.tw) - * (Various others) - * Thomas Winischhofer : - * - SiS Xabre (330) support - * - many fixes and enhancements for all chipset series, - * - extended bridge handling, TV output for Chrontel 7005 - * - 650/LVDS support (for LCD panels up to 1600x1200) - * - 650/740/Chrontel 7019 support - * - 30xB/30xLV LCD, TV and VGA2 support - * - memory queue handling enhancements, - * - 2D acceleration and y-panning, - * - portation to 2.5 API - * - etc. - * (see http://www.winischhofer.net/ - * for more information and updates) */ #include @@ -38,11 +47,15 @@ #include #include #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) +#include +#endif #include #include #include #include #include +#include #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) #include @@ -73,9 +86,13 @@ #include "sis_main.h" #include "sis.h" +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +#error "This version of sisfb requires at least 2.6.0" +#else #if 0 -#ifdef LINUXBIOS -#include "bios.h" +#define NEWFBDEV /* Define this as soon as new fvdev code has been merged */ +#endif #endif #endif @@ -121,7 +138,7 @@ u32 sisfb_get_reg3(u16 port) /* ------------ Interface for init & mode switching code ------------- */ BOOLEAN -sisfb_query_VGA_config_space(PSIS_HW_DEVICE_INFO psishw_ext, +sisfb_query_VGA_config_space(PSIS_HW_INFO psishw_ext, unsigned long offset, unsigned long set, unsigned long *value) { static struct pci_dev *pdev = NULL; @@ -134,9 +151,19 @@ sisfb_query_VGA_config_space(PSIS_HW_DEV if (!init) { init = TRUE; - pdev = pci_find_device(PCI_VENDOR_ID_SI, ivideo.chip_id, pdev); - if (pdev) - valid_pdev = TRUE; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74) + pci_for_each_dev(pdev) { +#else + while((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_ANY_ID, pdev))) { +#endif + DPRINTK("sisfb: Current: 0x%x, target: 0x%x\n", + pdev->device, ivideo.chip_id); + if ((pdev->vendor == PCI_VENDOR_ID_SI) + && (pdev->device == ivideo.chip_id)) { + valid_pdev = TRUE; + break; + } + } } if (!valid_pdev) { @@ -153,7 +180,7 @@ sisfb_query_VGA_config_space(PSIS_HW_DEV return TRUE; } -BOOLEAN sisfb_query_north_bridge_space(PSIS_HW_DEVICE_INFO psishw_ext, +BOOLEAN sisfb_query_north_bridge_space(PSIS_HW_INFO psishw_ext, unsigned long offset, unsigned long set, unsigned long *value) { static struct pci_dev *pdev = NULL; @@ -163,6 +190,7 @@ BOOLEAN sisfb_query_north_bridge_space(P if (!init) { init = TRUE; switch (ivideo.chip) { +#ifdef CONFIG_FB_SIS_300 case SIS_540: nbridge_id = PCI_DEVICE_ID_SI_540; break; @@ -172,23 +200,48 @@ BOOLEAN sisfb_query_north_bridge_space(P case SIS_730: nbridge_id = PCI_DEVICE_ID_SI_730; break; +#endif +#ifdef CONFIG_FB_SIS_315 case SIS_550: nbridge_id = PCI_DEVICE_ID_SI_550; break; case SIS_650: nbridge_id = PCI_DEVICE_ID_SI_650; break; - case SIS_740: + case SIS_740: nbridge_id = PCI_DEVICE_ID_SI_740; break; + case SIS_661: + nbridge_id = PCI_DEVICE_ID_SI_660; + break; + case SIS_741: + nbridge_id = PCI_DEVICE_ID_SI_741; + break; + case SIS_660: + nbridge_id = PCI_DEVICE_ID_SI_660; + break; + case SIS_760: + nbridge_id = PCI_DEVICE_ID_SI_760; + break; +#endif default: nbridge_id = 0; break; } - pdev = pci_find_device(PCI_VENDOR_ID_SI, nbridge_id, pdev); - if (pdev) - valid_pdev = TRUE; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74) + pci_for_each_dev(pdev) { +#else + while((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_ANY_ID, pdev))) { +#endif + DPRINTK("Current: 0x%x, target: 0x%x\n", + pdev->device, ivideo.chip_id); + if ((pdev->vendor == PCI_VENDOR_ID_SI) + && (pdev->device == nbridge_id)) { + valid_pdev = TRUE; + break; + } + } } if (!valid_pdev) { @@ -207,241 +260,373 @@ BOOLEAN sisfb_query_north_bridge_space(P /* ------------------ Internal helper routines ----------------- */ -static void sisfb_search_mode(const char *name) +static BOOLEAN sisfb_verify_rate(struct sisfb_monitor *monitor, int mode_idx, int rate_idx, int rate) { - int i = 0, j = 0; + int htotal, vtotal; + unsigned int dclock, hsync; - if(name == NULL) { - printk(KERN_ERR "sisfb: Internal error, using default mode.\n"); - sisfb_mode_idx = DEFAULT_MODE; - return; + if(!monitor->datavalid) return TRUE; + + if(mode_idx < 0) return FALSE; + + if(rate < (monitor->vmin - 1)) return FALSE; + if(rate > (monitor->vmax + 1)) return FALSE; + + if(sisfb_gettotalfrommode(&SiS_Pr, &sishw_ext, sisbios_mode[mode_idx].mode_no, + &htotal, &vtotal, rate_idx)) { + dclock = (htotal * vtotal * rate) / 1000; + if(dclock > (monitor->dclockmax + 1000)) return FALSE; + hsync = dclock / htotal; + if(hsync < (monitor->hmin - 1)) return FALSE; + if(hsync > (monitor->hmax + 1)) return FALSE; + } else { + return FALSE; } - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) - if (!strcmp(name, sisbios_mode[MODE_INDEX_NONE].name)) { - printk(KERN_ERR "sisfb: Mode 'none' not supported anymore. Using default.\n"); - sisfb_mode_idx = DEFAULT_MODE; - return; + return TRUE; +}; + +static BOOLEAN sisfb_interpret_edid(struct sisfb_monitor *monitor, u8 *buffer) +{ + int i, j, xres, yres, refresh, index; + u32 emodes; + + if(buffer[0] != 0x00 || buffer[1] != 0xff || + buffer[2] != 0xff || buffer[3] != 0xff || + buffer[4] != 0xff || buffer[5] != 0xff || + buffer[6] != 0xff || buffer[7] != 0x00) { + printk(KERN_DEBUG "sisfb: Bad EDID header\n"); + return FALSE; } -#endif - while(sisbios_mode[i].mode_no != 0) { - if (!strcmp(name, sisbios_mode[i].name)) { - sisfb_mode_idx = i; - j = 1; - break; - } - i++; + if(buffer[0x12] != 0x01) { + printk(KERN_INFO "sisfb: EDID version %d not supported\n", + buffer[0x12]); + return FALSE; + } + + monitor->feature = buffer[0x18]; + + if(!buffer[0x14] & 0x80) { + if(!(buffer[0x14] & 0x08)) { + printk(KERN_INFO "sisfb: WARNING: Monitor does not support separate syncs\n"); + } + } + + if(buffer[0x13] >= 0x01) { + /* EDID V1 rev 1 and 2: Search for monitor descriptor + * to extract ranges + */ + j = 0x36; + for(i=0; i<4; i++) { + if(buffer[j] == 0x00 && buffer[j + 1] == 0x00 && + buffer[j + 2] == 0x00 && buffer[j + 3] == 0xfd && + buffer[j + 4] == 0x00) { + monitor->hmin = buffer[j + 7]; + monitor->hmax = buffer[j + 8]; + monitor->vmin = buffer[j + 5]; + monitor->vmax = buffer[j + 6]; + monitor->dclockmax = buffer[j + 9] * 10 * 1000; + monitor->datavalid = TRUE; + break; + } + j += 18; + } + } + + if(!monitor->datavalid) { + /* Otherwise: Get a range from the list of supported + * Estabished Timings. This is not entirely accurate, + * because fixed frequency monitors are not supported + * that way. + */ + monitor->hmin = 65535; monitor->hmax = 0; + monitor->vmin = 65535; monitor->vmax = 0; + monitor->dclockmax = 0; + emodes = buffer[0x23] | (buffer[0x24] << 8) | (buffer[0x25] << 16); + for(i = 0; i < 13; i++) { + if(emodes & sisfb_ddcsmodes[i].mask) { + if(monitor->hmin > sisfb_ddcsmodes[i].h) monitor->hmin = sisfb_ddcsmodes[i].h; + if(monitor->hmax < sisfb_ddcsmodes[i].h) monitor->hmax = sisfb_ddcsmodes[i].h + 1; + if(monitor->vmin > sisfb_ddcsmodes[i].v) monitor->vmin = sisfb_ddcsmodes[i].v; + if(monitor->vmax < sisfb_ddcsmodes[i].v) monitor->vmax = sisfb_ddcsmodes[i].v; + if(monitor->dclockmax < sisfb_ddcsmodes[i].d) monitor->dclockmax = sisfb_ddcsmodes[i].d; + } + } + index = 0x26; + for(i = 0; i < 8; i++) { + xres = (buffer[index] + 31) * 8; + switch(buffer[index + 1] & 0xc0) { + case 0xc0: yres = (xres * 9) / 16; break; + case 0x80: yres = (xres * 4) / 5; break; + case 0x40: yres = (xres * 3) / 4; break; + default: yres = xres; break; + } + refresh = (buffer[index + 1] & 0x3f) + 60; + if((xres >= 640) && (yres >= 480)) { + for(j = 0; j < 8; j++) { + if((xres == sisfb_ddcfmodes[j].x) && + (yres == sisfb_ddcfmodes[j].y) && + (refresh == sisfb_ddcfmodes[j].v)) { + if(monitor->hmin > sisfb_ddcfmodes[j].h) monitor->hmin = sisfb_ddcfmodes[j].h; + if(monitor->hmax < sisfb_ddcfmodes[j].h) monitor->hmax = sisfb_ddcfmodes[j].h + 1; + if(monitor->vmin > sisfb_ddcsmodes[j].v) monitor->vmin = sisfb_ddcsmodes[j].v; + if(monitor->vmax < sisfb_ddcsmodes[j].v) monitor->vmax = sisfb_ddcsmodes[j].v; + if(monitor->dclockmax < sisfb_ddcsmodes[j].d) monitor->dclockmax = sisfb_ddcsmodes[i].d; + } + } + } + index += 2; + } + if((monitor->hmin <= monitor->hmax) && (monitor->vmin <= monitor->vmax)) { + monitor->datavalid = TRUE; + } + } + + return(monitor->datavalid); +} + +static void sisfb_handle_ddc(struct sisfb_monitor *monitor, int crtno) +{ + USHORT temp, i, realcrtno = crtno; + u8 buffer[256]; + + monitor->datavalid = FALSE; + + if(crtno) { + if(ivideo.vbflags & CRT2_LCD) realcrtno = 1; + else if(ivideo.vbflags & CRT2_VGA) realcrtno = 2; + else return; + } + + if((sisfb_crt1off) && (!crtno)) return; + + temp = SiS_HandleDDC(&SiS_Pr, ivideo.vbflags, sisvga_engine, realcrtno, 0, &buffer[0]); + if((!temp) || (temp == 0xffff)) { + printk(KERN_INFO "sisfb: CRT%d DDC probing failed\n", crtno + 1); + return; + } else { + printk(KERN_INFO "sisfb: CRT%d DDC supported\n", crtno + 1); + printk(KERN_INFO "sisfb: CRT%d DDC level: %s%s%s%s\n", + crtno + 1, + (temp & 0x1a) ? "" : "[none of the supported]", + (temp & 0x02) ? "2 " : "", + (temp & 0x08) ? "D&P" : "", + (temp & 0x10) ? "FPDI-2" : ""); + if(temp & 0x02) { + i = 3; /* Number of retrys */ + do { + temp = SiS_HandleDDC(&SiS_Pr, ivideo.vbflags, sisvga_engine, + realcrtno, 1, &buffer[0]); + } while((temp) && i--); + if(!temp) { + if(sisfb_interpret_edid(monitor, &buffer[0])) { + printk(KERN_INFO "sisfb: Monitor range H %d-%dKHz, V %d-%dHz, Max. dotclock %dMHz\n", + monitor->hmin, monitor->hmax, monitor->vmin, monitor->vmax, + monitor->dclockmax / 1000); + } else { + printk(KERN_INFO "sisfb: CRT%d DDC EDID corrupt\n", crtno + 1); + } + } else { + printk(KERN_INFO "sisfb: CRT%d DDC reading failed\n", crtno + 1); + } + } else { + printk(KERN_INFO "sisfb: VESA D&P and FPDI-2 not supported yet\n"); + } } - if(!j) printk(KERN_INFO "sisfb: Invalid mode '%s'\n", name); } -static void sisfb_search_vesamode(unsigned int vesamode) +static void sisfb_search_vesamode(unsigned int vesamode, BOOLEAN quiet) { int i = 0, j = 0; if(vesamode == 0) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) sisfb_mode_idx = MODE_INDEX_NONE; #else - printk(KERN_ERR "sisfb: Mode 'none' not supported anymore. Using default.\n"); + if(!quiet) + printk(KERN_ERR "sisfb: Mode 'none' not supported anymore. Using default.\n"); sisfb_mode_idx = DEFAULT_MODE; -#endif +#endif return; } vesamode &= 0x1dff; /* Clean VESA mode number from other flags */ + while(sisbios_mode[i++].mode_no != 0) { + if( (sisbios_mode[i-1].vesa_mode_no_1 == vesamode) || + (sisbios_mode[i-1].vesa_mode_no_2 == vesamode) ) { + if(sisfb_fstn) { + if(sisbios_mode[i-1].mode_no == 0x50 || + sisbios_mode[i-1].mode_no == 0x56 || + sisbios_mode[i-1].mode_no == 0x53) continue; + } else { + if(sisbios_mode[i-1].mode_no == 0x5a || + sisbios_mode[i-1].mode_no == 0x5b) continue; + } + sisfb_mode_idx = i - 1; + j = 1; + break; + } + } + if((!j) && !quiet) printk(KERN_ERR "sisfb: Invalid VESA mode 0x%x'\n", vesamode); +} + +static void sisfb_search_mode(char *name, BOOLEAN quiet) +{ + int i = 0; + unsigned int j = 0, xres = 0, yres = 0, depth = 0, rate = 0; + char strbuf[16], strbuf1[20]; + char *nameptr = name; + + if(name == NULL) { + if(!quiet) + printk(KERN_ERR "sisfb: Internal error, using default mode.\n"); + sisfb_mode_idx = DEFAULT_MODE; + return; + } + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) + if (!strnicmp(name, sisbios_mode[MODE_INDEX_NONE].name, strlen(name))) { + if(!quiet) + printk(KERN_ERR "sisfb: Mode 'none' not supported anymore. Using default.\n"); + sisfb_mode_idx = DEFAULT_MODE; + return; + } +#endif + if(strlen(name) <= 19) { + strcpy(strbuf1, name); + for(i=0; i '9') strbuf1[i] = ' '; + } + + /* This does some fuzzy mode naming detection */ + if(sscanf(strbuf1, "%u %u %u %u", &xres, &yres, &depth, &rate) == 4) { + if((rate <= 32) || (depth > 32)) { + j = rate; rate = depth; depth = j; + } + sprintf(strbuf, "%ux%ux%u", xres, yres, depth); + nameptr = strbuf; + ivideo.refresh_rate = sisfb_parm_rate = rate; + } else if(sscanf(strbuf1, "%u %u %u", &xres, &yres, &depth) == 3) { + sprintf(strbuf, "%ux%ux%u", xres, yres, depth); + nameptr = strbuf; + } else { + xres = 0; + if((sscanf(strbuf1, "%u %u", &xres, &yres) == 2) && (xres != 0)) { + sprintf(strbuf, "%ux%ux8", xres, yres); + nameptr = strbuf; + } else { + sisfb_search_vesamode(simple_strtoul(name, NULL, 0), quiet); + return; + } + } + } + + i = 0; j = 0; while(sisbios_mode[i].mode_no != 0) { - if( (sisbios_mode[i].vesa_mode_no_1 == vesamode) || - (sisbios_mode[i].vesa_mode_no_2 == vesamode) ) { - sisfb_mode_idx = i; - j = 1; - break; + if(!strnicmp(nameptr, sisbios_mode[i++].name, strlen(nameptr))) { + if(sisfb_fstn) { + if(sisbios_mode[i-1].mode_no == 0x50 || + sisbios_mode[i-1].mode_no == 0x56 || + sisbios_mode[i-1].mode_no == 0x53) continue; + } else { + if(sisbios_mode[i-1].mode_no == 0x5a || + sisbios_mode[i-1].mode_no == 0x5b) continue; + } + sisfb_mode_idx = i - 1; + j = 1; + break; } - i++; } - if(!j) printk(KERN_INFO "sisfb: Invalid VESA mode 0x%x'\n", vesamode); + if((!j) && !quiet) printk(KERN_ERR "sisfb: Invalid mode '%s'\n", nameptr); + } -static int sisfb_validate_mode(int myindex) +static int sisfb_validate_mode(int myindex, unsigned long vbflags) { - u16 xres, yres; + u16 xres, yres, myres; #ifdef CONFIG_FB_SIS_300 if(sisvga_engine == SIS_300_VGA) { - if(!(sisbios_mode[myindex].chipset & MD_SIS300)) { - return(-1); - } + if(!(sisbios_mode[myindex].chipset & MD_SIS300)) return(-1); } #endif #ifdef CONFIG_FB_SIS_315 if(sisvga_engine == SIS_315_VGA) { - if(!(sisbios_mode[myindex].chipset & MD_SIS315)) { - return(-1); - } + if(!(sisbios_mode[myindex].chipset & MD_SIS315)) return(-1); } #endif - switch (ivideo.disp_state & DISPTYPE_DISP2) { - case DISPTYPE_LCD: + myres = sisbios_mode[myindex].yres; + + switch (vbflags & VB_DISPTYPE_DISP2) { + case CRT2_LCD: switch (sishw_ext.ulCRT2LCDType) { - case LCD_640x480: - xres = 640; yres = 480; break; - case LCD_800x600: - xres = 800; yres = 600; break; - case LCD_1024x600: - xres = 1024; yres = 600; break; - case LCD_1024x768: - xres = 1024; yres = 768; break; - case LCD_1152x768: - xres = 1152; yres = 768; break; - case LCD_1280x960: - xres = 1280; yres = 960; break; - case LCD_1280x768: - xres = 1280; yres = 768; break; - case LCD_1280x1024: - xres = 1280; yres = 1024; break; - case LCD_1400x1050: - xres = 1400; yres = 1050; break; - case LCD_1600x1200: - xres = 1600; yres = 1200; break; - case LCD_320x480: /* TW: FSTN */ - xres = 320; yres = 480; break; - default: - xres = 0; yres = 0; break; + case LCD_640x480: xres = 640; yres = 480; break; + case LCD_800x600: xres = 800; yres = 600; break; + case LCD_1024x600: xres = 1024; yres = 600; break; + case LCD_1024x768: xres = 1024; yres = 768; break; + case LCD_1152x768: xres = 1152; yres = 768; break; + case LCD_1280x960: xres = 1280; yres = 960; break; + case LCD_1280x768: xres = 1280; yres = 768; break; + case LCD_1280x1024:xres = 1280; yres = 1024; break; + case LCD_1400x1050:xres = 1400; yres = 1050; break; + case LCD_1600x1200:xres = 1600; yres = 1200; break; + case LCD_320x480: xres = 320; yres = 480; break; /* FSTN (old) */ + case LCD_640x480_2: + case LCD_640x480_3:xres = 640; yres = 480; break; /* FSTN (new) */ + default: xres = 0; yres = 0; break; } - if(sisbios_mode[myindex].xres > xres) { - return(-1); - } - if(sisbios_mode[myindex].yres > yres) { - return(-1); + + if(SiS_Pr.SiS_CustomT == CUT_BARCO1366) { + xres = 1360; yres = 1024; } - if((sishw_ext.usExternalChip == 0x01) || /* LVDS */ - (sishw_ext.usExternalChip == 0x05) || /* LVDS+Chrontel */ - (sishw_ext.Is301BDH)) { /* 301B-DH */ - switch (sisbios_mode[myindex].xres) { - case 512: - if(sisbios_mode[myindex].yres != 512) return -1; - if(sishw_ext.ulCRT2LCDType == LCD_1024x600) return -1; - break; - case 640: - if((sisbios_mode[myindex].yres != 400) && - (sisbios_mode[myindex].yres != 480)) - return -1; - break; - case 800: - if(sisbios_mode[myindex].yres != 600) return -1; - break; - case 1024: - if((sisbios_mode[myindex].yres != 600) && - (sisbios_mode[myindex].yres != 768)) - return -1; - if((sisbios_mode[myindex].yres == 600) && - (sishw_ext.ulCRT2LCDType != LCD_1024x600)) - return -1; - break; - case 1152: - if((sisbios_mode[myindex].yres) != 768) return -1; - if(sishw_ext.ulCRT2LCDType != LCD_1152x768) return -1; - break; - case 1280: - if((sisbios_mode[myindex].yres != 768) && - (sisbios_mode[myindex].yres != 1024)) - return -1; - if((sisbios_mode[myindex].yres == 768) && - (sishw_ext.ulCRT2LCDType != LCD_1280x768)) - return -1; - break; - case 1400: - if(sisbios_mode[myindex].yres != 1050) return -1; - break; - case 1600: - if(sisbios_mode[myindex].yres != 1200) return -1; - break; - default: - return -1; - } + + if(SiS_Pr.SiS_CustomT == CUT_PANEL848) { + xres = 848; yres = 480; } else { - switch (sisbios_mode[myindex].xres) { - case 512: - if(sisbios_mode[myindex].yres != 512) return -1; - break; - case 640: - if((sisbios_mode[myindex].yres != 400) && - (sisbios_mode[myindex].yres != 480)) - return -1; - break; - case 800: - if(sisbios_mode[myindex].yres != 600) return -1; - break; - case 1024: - if(sisbios_mode[myindex].yres != 768) return -1; - break; - case 1280: - if((sisbios_mode[myindex].yres != 960) && - (sisbios_mode[myindex].yres != 1024)) - return -1; - if(sisbios_mode[myindex].yres == 960) { - if(sishw_ext.ulCRT2LCDType == LCD_1400x1050) - return -1; - } - break; - case 1400: - if(sisbios_mode[myindex].yres != 1050) return -1; - break; - case 1600: - if(sisbios_mode[myindex].yres != 1200) return -1; - break; - default: - return -1; + if(sisbios_mode[myindex].xres > xres) return(-1); + if(myres > yres) return(-1); + } + + if(vbflags & (VB_LVDS | VB_30xBDH)) { + if(sisbios_mode[myindex].xres == 320) { + if((myres == 240) || (myres == 480)) { + if(!sisfb_fstn) { + if(sisbios_mode[myindex].mode_no == 0x5a || + sisbios_mode[myindex].mode_no == 0x5b) + return(-1); + } else { + if(sisbios_mode[myindex].mode_no == 0x50 || + sisbios_mode[myindex].mode_no == 0x56 || + sisbios_mode[myindex].mode_no == 0x53) + return(-1); + } + } } } + + if(SiS_GetModeID_LCD(sisvga_engine, vbflags, sisbios_mode[myindex].xres, sisbios_mode[myindex].yres, + 0, sisfb_fstn, SiS_Pr.SiS_CustomT, xres, yres) < 0x14) { + return(-1); + } break; - case DISPTYPE_TV: - switch (sisbios_mode[myindex].xres) { - case 512: - case 640: - case 800: - break; - case 720: - if (ivideo.TV_type == TVMODE_NTSC) { - if (sisbios_mode[myindex].yres != 480) { - return(-1); - } - } else if (ivideo.TV_type == TVMODE_PAL) { - if (sisbios_mode[myindex].yres != 576) { - return(-1); - } - } - /* TW: LVDS/CHRONTEL does not support 720 */ - if (ivideo.hasVB == HASVB_LVDS_CHRONTEL || - ivideo.hasVB == HASVB_CHRONTEL) { - return(-1); - } - break; - case 1024: - if (ivideo.TV_type == TVMODE_NTSC) { - if(sisbios_mode[myindex].bpp == 32) { - return(-1); - } - } - /* TW: LVDS/CHRONTEL only supports < 800 (1024 on 650/Ch7019)*/ - if (ivideo.hasVB == HASVB_LVDS_CHRONTEL || - ivideo.hasVB == HASVB_CHRONTEL) { - if(ivideo.chip < SIS_315H) { - return(-1); - } - } - break; - default: - return(-1); + + case CRT2_TV: + if(SiS_GetModeID_TV(sisvga_engine, vbflags, sisbios_mode[myindex].xres, + sisbios_mode[myindex].yres, 0) < 0x14) { + return(-1); + } + break; + + case CRT2_VGA: + if(SiS_GetModeID_VGA2(sisvga_engine, vbflags, sisbios_mode[myindex].xres, + sisbios_mode[myindex].yres, 0) < 0x14) { + return(-1); } break; - case DISPTYPE_CRT2: - if(sisbios_mode[myindex].xres > 1280) return -1; - break; } + return(myindex); } @@ -453,15 +638,20 @@ static void sisfb_search_crt2type(const return; while(sis_crt2type[i].type_no != -1) { - if (!strcmp(name, sis_crt2type[i].name)) { + if (!strnicmp(name, sis_crt2type[i].name, strlen(sis_crt2type[i].name))) { sisfb_crt2type = sis_crt2type[i].type_no; sisfb_tvplug = sis_crt2type[i].tvplug_no; + sisfb_dstn = (sis_crt2type[i].flags & FL_550_DSTN) ? 1 : 0; + sisfb_fstn = (sis_crt2type[i].flags & FL_550_FSTN) ? 1 : 0; break; } i++; } if(sisfb_crt2type < 0) - printk(KERN_INFO "sisfb: Invalid CRT2 type: %s\n", name); + printk(KERN_ERR "sisfb: Invalid CRT2 type: %s\n", name); + if(ivideo.chip != SIS_550) { + sisfb_dstn = sisfb_fstn = 0; + } } static void sisfb_search_queuemode(const char *name) @@ -472,23 +662,23 @@ static void sisfb_search_queuemode(const return; while (sis_queuemode[i].type_no != -1) { - if (!strcmp(name, sis_queuemode[i].name)) { + if (!strnicmp(name, sis_queuemode[i].name, strlen(sis_queuemode[i].name))) { sisfb_queuemode = sis_queuemode[i].type_no; break; } i++; } if (sisfb_queuemode < 0) - printk(KERN_INFO "sisfb: Invalid queuemode type: %s\n", name); + printk(KERN_ERR "sisfb: Invalid queuemode type: %s\n", name); } -static u8 sisfb_search_refresh_rate(unsigned int rate) +static u8 sisfb_search_refresh_rate(unsigned int rate, int mode_idx) { u16 xres, yres; int i = 0; - xres = sisbios_mode[sisfb_mode_idx].xres; - yres = sisbios_mode[sisfb_mode_idx].yres; + xres = sisbios_mode[mode_idx].xres; + yres = sisbios_mode[mode_idx].yres; sisfb_rate_idx = 0; while ((sisfb_vrate[i].idx != 0) && (sisfb_vrate[i].xres <= xres)) { @@ -536,45 +726,101 @@ static void sisfb_search_tvstd(const cha return; while (sis_tvtype[i].type_no != -1) { - if (!strcmp(name, sis_tvtype[i].name)) { - sisfb_tvmode = sis_tvtype[i].type_no; + if (!strnicmp(name, sis_tvtype[i].name, strlen(sis_tvtype[i].name))) { + ivideo.vbflags |= sis_tvtype[i].type_no; break; } i++; } } +static void sisfb_search_specialtiming(const char *name) +{ + int i = 0; + BOOLEAN found = FALSE; + + if(name == NULL) + return; + + if(!strnicmp(name, "none", 4)) { + SiS_Pr.SiS_CustomT = CUT_FORCENONE; + printk(KERN_DEBUG "sisfb: Special timing disabled\n"); + } else { + while(mycustomttable[i].chipID != 0) { + if(!strnicmp(name,mycustomttable[i].optionName, strlen(mycustomttable[i].optionName))) { + SiS_Pr.SiS_CustomT = mycustomttable[i].SpecialID; + found = TRUE; + printk(KERN_INFO "sisfb: Special timing for %s %s forced (\"%s\")\n", + mycustomttable[i].vendorName, mycustomttable[i].cardName, + mycustomttable[i].optionName); + break; + } + i++; + } + if(!found) { + printk(KERN_WARNING "sisfb: Invalid SpecialTiming parameter, valid are:"); + printk(KERN_WARNING "\t\"none\" (to disable special timings)\n"); + i = 0; + while(mycustomttable[i].chipID != 0) { + printk(KERN_WARNING "\t\"%s\" (for %s %s)\n", + mycustomttable[i].optionName, + mycustomttable[i].vendorName, + mycustomttable[i].cardName); + i++; + } + } + } +} + static BOOLEAN sisfb_bridgeisslave(void) { - unsigned char usScratchP1_00; + unsigned char P1_00; - if(ivideo.hasVB == HASVB_NONE) return FALSE; + if(!(ivideo.vbflags & VB_VIDEOBRIDGE)) return FALSE; - inSISIDXREG(SISPART1,0x00,usScratchP1_00); - if( ((sisvga_engine == SIS_300_VGA) && (usScratchP1_00 & 0xa0) == 0x20) || - ((sisvga_engine == SIS_315_VGA) && (usScratchP1_00 & 0x50) == 0x10) ) { + inSISIDXREG(SISPART1,0x00,P1_00); + if( ((sisvga_engine == SIS_300_VGA) && (P1_00 & 0xa0) == 0x20) || + ((sisvga_engine == SIS_315_VGA) && (P1_00 & 0x50) == 0x10) ) { return TRUE; } else { return FALSE; } } -static BOOLEAN sisfbcheckvretracecrt1(void) +static BOOLEAN sisfballowretracecrt1(void) { unsigned char temp; inSISIDXREG(SISCR,0x17,temp); if(!(temp & 0x80)) return FALSE; - - if(sisvga_engine == SIS_315_VGA) { - inSISIDXREG(SISSR,0x1f,temp); - if(temp & 0xc0) return FALSE; - } + + inSISIDXREG(SISSR,0x1f,temp); + if(temp & 0xc0) return FALSE; + + return TRUE; +} + +static BOOLEAN sisfbcheckvretracecrt1(void) +{ + + if(!sisfballowretracecrt1()) return FALSE; if(inSISREG(SISINPSTAT) & 0x08) return TRUE; else return FALSE; } +static void sisfbwaitretracecrt1(void) +{ + int watchdog; + + if(!sisfballowretracecrt1()) return; + + watchdog = 65536; + while((!(inSISREG(SISINPSTAT) & 0x08)) && --watchdog); + watchdog = 65536; + while((inSISREG(SISINPSTAT) & 0x08) && --watchdog); +} + static BOOLEAN sisfbcheckvretracecrt2(void) { unsigned char temp, reg; @@ -595,9 +841,9 @@ static BOOLEAN sisfbcheckvretracecrt2(vo else return TRUE; } -static BOOLEAN sisfb_CheckVBRetrace(void) +static BOOLEAN sisfb_CheckVBRetrace(void) { - if(ivideo.disp_state & DISPTYPE_DISP2) { + if(ivideo.currentvbflags & VB_DISPTYPE_DISP2) { if(sisfb_bridgeisslave()) { return(sisfbcheckvretracecrt1()); } else { @@ -607,60 +853,195 @@ static BOOLEAN sisfb_CheckVBRetrace(void return(sisfbcheckvretracecrt1()); } +static int sisfb_myblank(int blank) +{ + u8 sr01, sr11, sr1f, cr63=0, p2_0, p1_13; + BOOLEAN backlight = TRUE; + + switch(blank) { + case 0: /* on */ + sr01 = 0x00; + sr11 = 0x00; + sr1f = 0x00; + cr63 = 0x00; + p2_0 = 0x20; + p1_13 = 0x00; + backlight = TRUE; + break; + case 1: /* blank */ + sr01 = 0x20; + sr11 = 0x00; + sr1f = 0x00; + cr63 = 0x00; + p2_0 = 0x20; + p1_13 = 0x00; + backlight = TRUE; + break; + case 2: /* no vsync */ + sr01 = 0x20; + sr11 = 0x08; + sr1f = 0x80; + cr63 = 0x40; + p2_0 = 0x40; + p1_13 = 0x80; + backlight = FALSE; + break; + case 3: /* no hsync */ + sr01 = 0x20; + sr11 = 0x08; + sr1f = 0x40; + cr63 = 0x40; + p2_0 = 0x80; + p1_13 = 0x40; + backlight = FALSE; + break; + case 4: /* off */ + sr01 = 0x20; + sr11 = 0x08; + sr1f = 0xc0; + cr63 = 0x40; + p2_0 = 0xc0; + p1_13 = 0xc0; + backlight = FALSE; + break; + default: + return 1; + } + + if(ivideo.currentvbflags & VB_DISPTYPE_CRT1) { + + setSISIDXREG(SISSR, 0x01, ~0x20, sr01); + + if( (!sisfb_thismonitor.datavalid) || + ((sisfb_thismonitor.datavalid) && + (sisfb_thismonitor.feature & 0xe0))) { + + if(sisvga_engine == SIS_315_VGA) { + setSISIDXREG(SISCR, SiS_Pr.SiS_MyCR63, 0xbf, cr63); + } + + setSISIDXREG(SISSR, 0x1f, 0x3f, sr1f); + } + + } + + if(ivideo.currentvbflags & CRT2_LCD) { + + if(ivideo.vbflags & (VB_301LV|VB_302LV|VB_302ELV)) { + if(backlight) { + SiS_SiS30xBLOn(&SiS_Pr, &sishw_ext); + } else { + SiS_SiS30xBLOff(&SiS_Pr, &sishw_ext); + } + } else if(sisvga_engine == SIS_315_VGA) { + if(ivideo.vbflags & VB_CHRONTEL) { + if(backlight) { + SiS_Chrontel701xBLOn(&SiS_Pr,&sishw_ext); + } else { + SiS_Chrontel701xBLOff(&SiS_Pr); + } + } + } + + if(((sisvga_engine == SIS_300_VGA) && + (ivideo.vbflags & (VB_301|VB_30xBDH|VB_LVDS))) || + ((sisvga_engine == SIS_315_VGA) && + ((ivideo.vbflags & (VB_LVDS | VB_CHRONTEL)) == VB_LVDS))) { + setSISIDXREG(SISSR, 0x11, ~0x0c, sr11); + } + + if(sisvga_engine == SIS_300_VGA) { + if((ivideo.vbflags & (VB_301B|VB_301C|VB_302B)) && + (!(ivideo.vbflags & VB_30xBDH))) { + setSISIDXREG(SISPART1, 0x13, 0x3f, p1_13); + } + } else if(sisvga_engine == SIS_315_VGA) { + if((ivideo.vbflags & (VB_301B|VB_301C|VB_302B)) && + (!(ivideo.vbflags & VB_30xBDH))) { + setSISIDXREG(SISPART2, 0x00, 0x1f, p2_0); + } + } + + } else if(ivideo.currentvbflags & CRT2_VGA) { + + if(ivideo.vbflags & (VB_301B|VB_301C|VB_302B)) { + setSISIDXREG(SISPART2, 0x00, 0x1f, p2_0); + } + + } + + return(0); +} + /* ----------- FBDev related routines for all series ----------- */ +static void sisfb_set_vparms(void) +{ + switch(ivideo.video_bpp) { + case 8: + ivideo.DstColor = 0x0000; + ivideo.SiS310_AccelDepth = 0x00000000; + ivideo.video_cmap_len = 256; + break; + case 16: + ivideo.DstColor = 0x8000; + ivideo.SiS310_AccelDepth = 0x00010000; + ivideo.video_cmap_len = 16; + break; + case 32: + ivideo.DstColor = 0xC000; + ivideo.SiS310_AccelDepth = 0x00020000; + ivideo.video_cmap_len = 16; + break; + default: + ivideo.video_cmap_len = 16; + printk(KERN_ERR "sisfb: Unsupported depth %d", ivideo.video_bpp); + ivideo.accel = 0; + break; + } +} + static int sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *info) { - unsigned int htotal = - var->left_margin + var->xres + var->right_margin + - var->hsync_len; - unsigned int vtotal = 0; - double drate = 0, hrate = 0; + unsigned int htotal = 0, vtotal = 0; + unsigned int drate = 0, hrate = 0; int found_mode = 0; int old_mode; - unsigned char reg; + u32 pixclock; - TWDEBUG("Inside do_set_var"); - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - inSISIDXREG(SISCR,0x34,reg); - if(reg & 0x80) { - printk(KERN_INFO "sisfb: Cannot change display mode, X server is active\n"); - return -EBUSY; - } -#endif + htotal = var->left_margin + var->xres + var->right_margin + var->hsync_len; + + vtotal = var->upper_margin + var->lower_margin + var->vsync_len; + + pixclock = var->pixclock; if((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) { - vtotal = var->upper_margin + var->yres + var->lower_margin + - var->vsync_len; + vtotal += var->yres; vtotal <<= 1; } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { - vtotal = var->upper_margin + var->yres + var->lower_margin + - var->vsync_len; + vtotal += var->yres; vtotal <<= 2; } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { - vtotal = var->upper_margin + (var->yres/2) + var->lower_margin + - var->vsync_len; - } else vtotal = var->upper_margin + var->yres + var->lower_margin + - var->vsync_len; + vtotal += var->yres; + vtotal <<= 1; + } else vtotal += var->yres; if(!(htotal) || !(vtotal)) { DPRINTK("sisfb: Invalid 'var' information\n"); return -EINVAL; } - if(var->pixclock && htotal && vtotal) { - drate = 1E12 / var->pixclock; - hrate = drate / htotal; - ivideo.refresh_rate = (unsigned int) (hrate / vtotal * 2 + 0.5); + if(pixclock && htotal && vtotal) { + drate = 1000000000 / pixclock; + hrate = (drate * 1000) / htotal; + ivideo.refresh_rate = (unsigned int) (hrate * 2 / vtotal); } else ivideo.refresh_rate = 60; - /* TW: Calculation wrong for 1024x600 - force it to 60Hz */ - if((var->xres == 1024) && (var->yres == 600)) ivideo.refresh_rate = 60; - +#if 0 printk(KERN_DEBUG "sisfb: Change mode to %dx%dx%d-%dHz\n", var->xres,var->yres,var->bits_per_pixel,ivideo.refresh_rate); +#endif old_mode = sisfb_mode_idx; sisfb_mode_idx = 0; @@ -678,7 +1059,7 @@ static int sisfb_do_set_var(struct fb_va } if(found_mode) - sisfb_mode_idx = sisfb_validate_mode(sisfb_mode_idx); + sisfb_mode_idx = sisfb_validate_mode(sisfb_mode_idx, ivideo.currentvbflags); else sisfb_mode_idx = -1; @@ -689,12 +1070,21 @@ static int sisfb_do_set_var(struct fb_va return -EINVAL; } - if(sisfb_search_refresh_rate(ivideo.refresh_rate) == 0) { + if(sisfb_search_refresh_rate(ivideo.refresh_rate, sisfb_mode_idx) == 0) { sisfb_rate_idx = sisbios_mode[sisfb_mode_idx].rate_idx; ivideo.refresh_rate = 60; } #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) + if(sisfb_thismonitor.datavalid) { + if(!sisfb_verify_rate(&sisfb_thismonitor, sisfb_mode_idx, + sisfb_rate_idx, ivideo.refresh_rate)) { + printk(KERN_INFO "sisfb: WARNING: Refresh rate exceeds monitor specs!\n"); + } + } +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) if(((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) && isactive) { #else if(isactive) { @@ -708,14 +1098,6 @@ static int sisfb_do_set_var(struct fb_va outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); - sisfb_post_setmode(); - - DPRINTK("sisfb: Set new mode: %dx%dx%d-%d \n", - sisbios_mode[sisfb_mode_idx].xres, - sisbios_mode[sisfb_mode_idx].yres, - sisbios_mode[sisfb_mode_idx].bpp, - ivideo.refresh_rate); - ivideo.video_bpp = sisbios_mode[sisfb_mode_idx].bpp; ivideo.video_vwidth = ivideo.video_width = sisbios_mode[sisfb_mode_idx].xres; ivideo.video_vheight = ivideo.video_height = sisbios_mode[sisfb_mode_idx].yres; @@ -725,53 +1107,38 @@ static int sisfb_do_set_var(struct fb_va if(sisfb_accel) { ivideo.accel = (var->accel_flags & FB_ACCELF_TEXT) ? -1 : 0; } - switch(ivideo.video_bpp) { - case 8: - ivideo.DstColor = 0x0000; - ivideo.SiS310_AccelDepth = 0x00000000; - ivideo.video_cmap_len = 256; - break; - case 16: - ivideo.DstColor = 0x8000; - ivideo.SiS310_AccelDepth = 0x00010000; - ivideo.video_cmap_len = 16; - break; - case 32: - ivideo.DstColor = 0xC000; - ivideo.SiS310_AccelDepth = 0x00020000; - ivideo.video_cmap_len = 16; - break; - default: - ivideo.video_cmap_len = 16; - printk(KERN_ERR "sisfb: Unsupported depth %d", ivideo.video_bpp); - ivideo.accel = 0; - break; - } + + sisfb_set_vparms(); + + ivideo.current_width = ivideo.video_width; + ivideo.current_height = ivideo.video_height; + ivideo.current_bpp = ivideo.video_bpp; + ivideo.current_htotal = htotal; + ivideo.current_vtotal = vtotal; + ivideo.current_pixclock = var->pixclock; + ivideo.current_refresh_rate = ivideo.refresh_rate; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) + sisfb_lastrates[sisfb_mode_no] = ivideo.refresh_rate; +#endif + + sisfb_post_setmode(); } - TWDEBUG("End of do_set_var"); return 0; } -#ifdef SISFB_PAN static int sisfb_pan_var(struct fb_var_screeninfo *var) { unsigned int base; - TWDEBUG("Inside pan_var"); - if (var->xoffset > (var->xres_virtual - var->xres)) { - printk(KERN_INFO "Pan: xo: %d xv %d xr %d\n", - var->xoffset, var->xres_virtual, var->xres); return -EINVAL; } if(var->yoffset > (var->yres_virtual - var->yres)) { - printk(KERN_INFO "Pan: yo: %d yv %d yr %d\n", - var->yoffset, var->yres_virtual, var->yres); return -EINVAL; } - base = var->yoffset * var->xres_virtual + var->xoffset; + base = var->yoffset * var->xres_virtual + var->xoffset; /* calculate base bpp dep. */ switch(var->bits_per_pixel) { @@ -794,7 +1161,7 @@ static int sisfb_pan_var(struct fb_var_s if(sisvga_engine == SIS_315_VGA) { setSISIDXREG(SISSR, 0x37, 0xFE, (base >> 24) & 0x01); } - if(ivideo.disp_state & DISPTYPE_DISP2) { + if(ivideo.currentvbflags & VB_DISPTYPE_DISP2) { orSISIDXREG(SISPART1, sisfb_CRT2_write_enable, 0x01); outSISIDXREG(SISPART1, 0x06, (base & 0xFF)); outSISIDXREG(SISPART1, 0x05, ((base >> 8) & 0xFF)); @@ -803,10 +1170,8 @@ static int sisfb_pan_var(struct fb_var_s setSISIDXREG(SISPART1, 0x02, 0x7F, ((base >> 24) & 0x01) << 7); } } - TWDEBUG("End of pan_var"); return 0; } -#endif static void sisfb_bpp_to_var(struct fb_var_screeninfo *var) { @@ -843,22 +1208,24 @@ static void sisfb_bpp_to_var(struct fb_v void sis_dispinfo(struct ap_data *rec) { - rec->minfo.bpp = ivideo.video_bpp; - rec->minfo.xres = ivideo.video_width; - rec->minfo.yres = ivideo.video_height; - rec->minfo.v_xres = ivideo.video_vwidth; - rec->minfo.v_yres = ivideo.video_vheight; - rec->minfo.org_x = ivideo.org_x; - rec->minfo.org_y = ivideo.org_y; - rec->minfo.vrate = ivideo.refresh_rate; - rec->iobase = ivideo.vga_base - 0x30; - rec->mem_size = ivideo.video_size; - rec->disp_state = ivideo.disp_state; - rec->version = (VER_MAJOR << 24) | (VER_MINOR << 16) | VER_LEVEL; - rec->hasVB = ivideo.hasVB; - rec->TV_type = ivideo.TV_type; - rec->TV_plug = ivideo.TV_plug; - rec->chip = ivideo.chip; + rec->minfo.bpp = ivideo.video_bpp; + rec->minfo.xres = ivideo.video_width; + rec->minfo.yres = ivideo.video_height; + rec->minfo.v_xres = ivideo.video_vwidth; + rec->minfo.v_yres = ivideo.video_vheight; + rec->minfo.org_x = ivideo.org_x; + rec->minfo.org_y = ivideo.org_y; + rec->minfo.vrate = ivideo.refresh_rate; + rec->iobase = ivideo.vga_base - 0x30; + rec->mem_size = ivideo.video_size; + rec->disp_state = ivideo.disp_state; + rec->version = (VER_MAJOR << 24) | (VER_MINOR << 16) | VER_LEVEL; + rec->hasVB = ivideo.hasVB; + rec->TV_type = ivideo.TV_type; + rec->TV_plug = ivideo.TV_plug; + rec->chip = ivideo.chip; + rec->vbflags = ivideo.vbflags; + rec->currentvbflags = ivideo.currentvbflags; } /* ------------ FBDev related routines for 2.4 series ----------- */ @@ -871,15 +1238,14 @@ static void sisfb_crtc_to_var(struct fb_ u16 HRE, HBE, HRS, HBS, HDE, HT; u8 sr_data, cr_data, cr_data2, cr_data3, mr_data; int A, B, C, D, E, F, temp; - double hrate, drate; + unsigned int hrate, drate, maxyres; - TWDEBUG("Inside crtc_to_var"); inSISIDXREG(SISSR, IND_SIS_COLOR_MODE, sr_data); - if (sr_data & SIS_INTERLACED_MODE) - var->vmode = FB_VMODE_INTERLACED; + if(sr_data & SIS_INTERLACED_MODE) + var->vmode = FB_VMODE_INTERLACED; else - var->vmode = FB_VMODE_NONINTERLACED; + var->vmode = FB_VMODE_NONINTERLACED; switch ((sr_data & 0x1C) >> 2) { case SIS_8BPP_COLOR_MODE: @@ -921,6 +1287,8 @@ static void sisfb_crtc_to_var(struct fb_ inSISIDXREG(SISCR, 0x09, cr_data3); + if(cr_data3 & 0x80) var->vmode = FB_VMODE_DOUBLE; + VBS = (cr_data & 0xff) | ((u16) (cr_data2 & 0x08) << 5) | ((u16) (cr_data3 & 0x20) << 4) | ((u16) (sr_data & 0x04) << 8); @@ -939,26 +1307,22 @@ static void sisfb_crtc_to_var(struct fb_ D = B - F - C; var->yres = E; -#ifndef SISFB_PAN - var->yres_virtual = E; -#endif - /* TW: We have to report the physical dimension to the console! */ - if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { - var->yres <<= 1; -#ifndef SISFB_PAN - var->yres_virtual <<= 1; -#endif - } else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { - var->yres >>= 1; -#ifndef SISFB_PAN - var->yres_virtual >>= 1; -#endif - } - var->upper_margin = D; var->lower_margin = F; var->vsync_len = C; + if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { + var->yres <<= 1; + var->upper_margin <<= 1; + var->lower_margin <<= 1; + var->vsync_len <<= 1; + } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { + var->yres >>= 1; + var->upper_margin >>= 1; + var->lower_margin >>= 1; + var->vsync_len >>= 1; + } + inSISIDXREG(SISSR, 0x0b, sr_data); inSISIDXREG(SISCR, 0x00, cr_data); @@ -999,44 +1363,62 @@ static void sisfb_crtc_to_var(struct fb_ D = B - F - C; var->xres = var->xres_virtual = E * 8; - var->left_margin = D * 8; - var->right_margin = F * 8; - var->hsync_len = C * 8; + if((var->xres == 320) && + (var->yres == 200 || var->yres == 240)) { + /* Terrible hack, but the correct CRTC data for + * these modes only produces a black screen... + */ + var->left_margin = (400 - 376); + var->right_margin = (328 - 320); + var->hsync_len = (376 - 328); + } else { + var->left_margin = D * 8; + var->right_margin = F * 8; + var->hsync_len = C * 8; + } var->activate = FB_ACTIVATE_NOW; var->sync = 0; mr_data = inSISREG(SISMISCR); - if (mr_data & 0x80) - var->sync &= ~FB_SYNC_VERT_HIGH_ACT; + if(mr_data & 0x80) + var->sync &= ~FB_SYNC_VERT_HIGH_ACT; else - var->sync |= FB_SYNC_VERT_HIGH_ACT; + var->sync |= FB_SYNC_VERT_HIGH_ACT; - if (mr_data & 0x40) - var->sync &= ~FB_SYNC_HOR_HIGH_ACT; + if(mr_data & 0x40) + var->sync &= ~FB_SYNC_HOR_HIGH_ACT; else - var->sync |= FB_SYNC_HOR_HIGH_ACT; + var->sync |= FB_SYNC_HOR_HIGH_ACT; VT += 2; VT <<= 1; HT = (HT + 5) * 8; - hrate = (double) ivideo.refresh_rate * (double) VT / 2; - drate = hrate * HT; - var->pixclock = (u32) (1E12 / drate); + if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { + VT <<= 1; + } + hrate = ivideo.refresh_rate * VT / 2; + drate = (hrate * HT) / 1000; + var->pixclock = (u32) (1000000000 / drate); -#ifdef SISFB_PAN if(sisfb_ypan) { - var->yres_virtual = ivideo.heapstart / (var->xres * (var->bits_per_pixel >> 3)); - if(var->yres_virtual <= var->yres) { - var->yres_virtual = var->yres; - } - } else -#endif + maxyres = ivideo.heapstart / (var->xres * (var->bits_per_pixel >> 3)); + if(maxyres > 32767) maxyres = 32767; + if(sisfb_max) { + var->yres_virtual = maxyres; + } else { + if(var->yres_virtual > maxyres) { + var->yres_virtual = maxyres; + } + } + if(var->yres_virtual <= var->yres) { + var->yres_virtual = var->yres; + } + } else var->yres_virtual = var->yres; - TWDEBUG("end of crtc_to_var"); } static int sis_getcolreg(unsigned regno, unsigned *red, unsigned *green, unsigned *blue, @@ -1069,7 +1451,7 @@ static int sisfb_setcolreg(unsigned regn outSISREG(SISDACD, (red >> 10)); outSISREG(SISDACD, (green >> 10)); outSISREG(SISDACD, (blue >> 10)); - if (ivideo.disp_state & DISPTYPE_DISP2) { + if (ivideo.currentvbflags & VB_DISPTYPE_DISP2) { outSISREG(SISDAC2A, regno); outSISREG(SISDAC2D, (red >> 8)); outSISREG(SISDAC2D, (green >> 8)); @@ -1118,7 +1500,7 @@ static void sisfb_set_disp(int con, stru display->ywrapstep = fix.ywrapstep; display->line_length = fix.line_length; display->next_line = fix.line_length; - display->can_soft_blank = 0; + display->can_soft_blank = 1; display->inverse = sisfb_inverse; display->var = *var; @@ -1162,17 +1544,12 @@ static void sisfb_set_disp(int con, stru display->dispsw = &sisfb_sw; restore_flags(flags); -#ifdef SISFB_PAN - if((ivideo.accel) && (sisfb_ypan)) { - /* display->scrollmode = SCROLL_YPAN; - not defined */ + if(sisfb_ypan) { + /* display->scrollmode = 0; */ } else { display->scrollmode = SCROLL_YREDRAW; sisfb_sw.bmove = fbcon_redraw_bmove; } -#else - display->scrollmode = SCROLL_YREDRAW; - sisfb_sw.bmove = fbcon_redraw_bmove; -#endif } static void sisfb_do_install_cmap(int con, struct fb_info *info) @@ -1191,17 +1568,16 @@ static void sisfb_do_install_cmap(int co static int sisfb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) { - TWDEBUG("inside get_var"); if(con == -1) memcpy(var, &default_var, sizeof(struct fb_var_screeninfo)); else *var = fb_display[con].var; - /* For FSTN, DSTN */ - if (var->xres == 320 && var->yres == 480) + if(sisfb_fstn) { + if (var->xres == 320 && var->yres == 480) var->yres = 240; - - TWDEBUG("end of get_var"); + } + return 0; } @@ -1211,8 +1587,6 @@ static int sisfb_set_var(struct fb_var_s int err; unsigned int cols, rows; - TWDEBUG("inside set_var"); - fb_display[con].var.activate = FB_ACTIVATE_NOW; if(sisfb_do_set_var(var, con == currcon, info)) { sisfb_crtc_to_var(var); @@ -1233,16 +1607,17 @@ static int sisfb_set_var(struct fb_var_s cols = sisbios_mode[sisfb_mode_idx].cols; rows = sisbios_mode[sisfb_mode_idx].rows; - vc_resize_con(rows, cols, fb_display[con].conp->vc_num); +#if 0 + /* Why was this called here? */ + vc_resize_con(rows, cols, fb_display[con].conp->vc_num); +#endif - TWDEBUG("end of set_var"); return 0; } static int sisfb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) { - TWDEBUG("inside get_cmap"); if (con == currcon) return fb_get_cmap(cmap, kspc, sis_getcolreg, info); @@ -1251,7 +1626,6 @@ static int sisfb_get_cmap(struct fb_cmap else fb_copy_cmap(fb_default_cmap(ivideo.video_cmap_len), cmap, kspc ? 0 : 2); - TWDEBUG("end of get_cmap"); return 0; } @@ -1260,7 +1634,6 @@ static int sisfb_set_cmap(struct fb_cmap { int err; - TWDEBUG("inside set_cmap"); if (!fb_display[con].cmap.len) { err = fb_alloc_cmap(&fb_display[con].cmap, ivideo.video_cmap_len, 0); if (err) @@ -1272,17 +1645,15 @@ static int sisfb_set_cmap(struct fb_cmap else fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1); - TWDEBUG("end of set_cmap"); + return 0; } -#ifdef SISFB_PAN static int sisfb_pan_display(struct fb_var_screeninfo *var, int con, struct fb_info* info) { int err; - - TWDEBUG("inside pan_display"); + if (var->vmode & FB_VMODE_YWRAP) { if (var->yoffset < 0 || var->yoffset >= fb_display[con].var.yres_virtual || var->xoffset) return -EINVAL; @@ -1303,10 +1674,8 @@ static int sisfb_pan_display(struct fb_v else fb_display[con].var.vmode &= ~FB_VMODE_YWRAP; - TWDEBUG("end of pan_display"); return 0; } -#endif static int sisfb_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma) @@ -1316,7 +1685,6 @@ static int sisfb_mmap(struct fb_info *in unsigned long off; u32 len, mmio_off; - TWDEBUG("inside mmap"); if(vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) return -EINVAL; off = vma->vm_pgoff << PAGE_SHIFT; @@ -1351,11 +1719,11 @@ static int sisfb_mmap(struct fb_info *in if (boot_cpu_data.x86 > 3) pgprot_val(vma->vm_page_prot) |= _PAGE_PCD; #endif + /* RedHat requires vma as the first paramater to the following call */ if (io_remap_page_range(vma->vm_start, off, vma->vm_end - vma->vm_start, vma->vm_page_prot)) return -EAGAIN; - TWDEBUG("end of mmap"); return 0; } @@ -1368,7 +1736,6 @@ static void sis_get_glyph(struct fb_info u8 *gbuf = gly->gmask; int size; - TWDEBUG("Inside get_glyph"); gly->fontheight = fontheight(p); gly->fontwidth = fontwidth(p); widthb = (fontwidth(p) + 7) / 8; @@ -1382,16 +1749,11 @@ static void sis_get_glyph(struct fb_info size = fontheight(p) * widthb; memcpy(gbuf, cdat, size); gly->ngmask = size; - TWDEBUG("End of get_glyph"); } static int sisfb_update_var(int con, struct fb_info *info) { -#ifdef SISFB_PAN return(sisfb_pan_var(&fb_display[con].var)); -#else - return 0; -#endif } static int sisfb_switch(int con, struct fb_info *info) @@ -1428,127 +1790,7 @@ static int sisfb_switch(int con, struct static void sisfb_blank(int blank, struct fb_info *info) { - u8 reg; - - inSISIDXREG(SISCR, 0x17, reg); - - if(blank > 0) - reg &= 0x7f; - else - reg |= 0x80; - - outSISIDXREG(SISCR, 0x17, reg); - outSISIDXREG(SISSR, 0x00, 0x01); /* Synchronous Reset */ - outSISIDXREG(SISSR, 0x00, 0x03); /* End Reset */ - printk(KERN_DEBUG "sisfb_blank() called (%d)\n", blank); -} - - -static int sisfb_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg, int con, - struct fb_info *info) -{ - TWDEBUG("inside ioctl"); - switch (cmd) { - case FBIO_ALLOC: - if (!capable(CAP_SYS_RAWIO)) - return -EPERM; - sis_malloc((struct sis_memreq *) arg); - break; - case FBIO_FREE: - if (!capable(CAP_SYS_RAWIO)) - return -EPERM; - sis_free(*(unsigned long *) arg); - break; - case FBIOGET_GLYPH: - sis_get_glyph(info,(SIS_GLYINFO *) arg); - break; - case FBIOGET_HWCINFO: - { - unsigned long *hwc_offset = (unsigned long *) arg; - - if (sisfb_caps & HW_CURSOR_CAP) - *hwc_offset = sisfb_hwcursor_vbase - - (unsigned long) ivideo.video_vbase; - else - *hwc_offset = 0; - - break; - } - case FBIOPUT_MODEINFO: - { - struct mode_info *x = (struct mode_info *)arg; - - ivideo.video_bpp = x->bpp; - ivideo.video_width = x->xres; - ivideo.video_height = x->yres; - ivideo.video_vwidth = x->v_xres; - ivideo.video_vheight = x->v_yres; - ivideo.org_x = x->org_x; - ivideo.org_y = x->org_y; - ivideo.refresh_rate = x->vrate; - ivideo.video_linelength = ivideo.video_vwidth * (ivideo.video_bpp >> 3); - switch(ivideo.video_bpp) { - case 8: - ivideo.DstColor = 0x0000; - ivideo.SiS310_AccelDepth = 0x00000000; - ivideo.video_cmap_len = 256; - break; - case 16: - ivideo.DstColor = 0x8000; - ivideo.SiS310_AccelDepth = 0x00010000; - ivideo.video_cmap_len = 16; - break; - case 32: - ivideo.DstColor = 0xC000; - ivideo.SiS310_AccelDepth = 0x00020000; - ivideo.video_cmap_len = 16; - break; - default: - ivideo.video_cmap_len = 16; - printk(KERN_ERR "sisfb: Unsupported depth %d", ivideo.video_bpp); - ivideo.accel = 0; - break; - } - - break; - } - case FBIOGET_DISPINFO: - sis_dispinfo((struct ap_data *)arg); - break; - case SISFB_GET_INFO: /* TW: New for communication with X driver */ - { - sisfb_info *x = (sisfb_info *)arg; - - x->sisfb_id = SISFB_ID; - x->sisfb_version = VER_MAJOR; - x->sisfb_revision = VER_MINOR; - x->sisfb_patchlevel = VER_LEVEL; - x->chip_id = ivideo.chip_id; - x->memory = ivideo.video_size / 1024; - x->heapstart = ivideo.heapstart / 1024; - x->fbvidmode = sisfb_mode_no; - x->sisfb_caps = sisfb_caps; - x->sisfb_tqlen = 512; /* yet unused */ - x->sisfb_pcibus = ivideo.pcibus; - x->sisfb_pcislot = ivideo.pcislot; - x->sisfb_pcifunc = ivideo.pcifunc; - x->sisfb_lcdpdc = sisfb_detectedpdc; - x->sisfb_lcda = sisfb_detectedlcda; - break; - } - case SISFB_GET_VBRSTATUS: - { - unsigned long *vbrstatus = (unsigned long *) arg; - if(sisfb_CheckVBRetrace()) *vbrstatus = 1; - else *vbrstatus = 0; - } - default: - return -EINVAL; - } - TWDEBUG("end of ioctl"); - return 0; - + sisfb_myblank(blank); } #endif @@ -1575,11 +1817,9 @@ static int sisfb_get_cmap_len(const stru rc = 256; break; case 16: - rc = 16; - break; case 32: rc = 16; - break; + break; } return rc; } @@ -1596,7 +1836,7 @@ static int sisfb_setcolreg(unsigned regn outSISREG(SISDACD, (red >> 10)); outSISREG(SISDACD, (green >> 10)); outSISREG(SISDACD, (blue >> 10)); - if (ivideo.disp_state & DISPTYPE_DISP2) { + if (ivideo.currentvbflags & VB_DISPTYPE_DISP2) { outSISREG(SISDAC2A, regno); outSISREG(SISDAC2D, (red >> 8)); outSISREG(SISDAC2D, (green >> 8)); @@ -1611,7 +1851,7 @@ static int sisfb_setcolreg(unsigned regn red >>= 8; green >>= 8; blue >>= 8; - ((u32 *) (info->pseudo_palette))[regno] = + ((u32 *) (info->pseudo_palette))[regno] = (red << 16) | (green << 8) | (blue); break; } @@ -1622,63 +1862,52 @@ static int sisfb_set_par(struct fb_info { int err; - TWDEBUG("inside set_par"); if((err = sisfb_do_set_var(&info->var, 1, info))) return err; sisfb_get_fix(&info->fix, info->currcon, info); - TWDEBUG("end of set_par"); return 0; } static int sisfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { - unsigned int htotal = - var->left_margin + var->xres + var->right_margin + - var->hsync_len; - unsigned int vtotal = 0; - double drate = 0, hrate = 0; + unsigned int htotal = 0, vtotal = 0, myrateindex = 0; + unsigned int drate = 0, hrate = 0, maxyres; int found_mode = 0; int refresh_rate, search_idx; + BOOLEAN recalc_clock = FALSE; + u32 pixclock; - TWDEBUG("Inside check_var"); + htotal = var->left_margin + var->xres + var->right_margin + var->hsync_len; + + vtotal = var->upper_margin + var->lower_margin + var->vsync_len; + + pixclock = var->pixclock; if((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) { - vtotal = var->upper_margin + var->yres + var->lower_margin + - var->vsync_len; + vtotal += var->yres; vtotal <<= 1; } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { - vtotal = var->upper_margin + var->yres + var->lower_margin + - var->vsync_len; + vtotal += var->yres; vtotal <<= 2; } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { - vtotal = var->upper_margin + (var->yres/2) + var->lower_margin + - var->vsync_len; - } else vtotal = var->upper_margin + var->yres + var->lower_margin + - var->vsync_len; + vtotal += var->yres; + vtotal <<= 1; + } else vtotal += var->yres; if(!(htotal) || !(vtotal)) { SISFAIL("sisfb: no valid timing data"); } - if((var->pixclock) && (htotal)) { - drate = 1E12 / var->pixclock; - hrate = drate / htotal; - refresh_rate = (unsigned int) (hrate / vtotal * 2 + 0.5); - } else refresh_rate = 60; - - /* TW: Calculation wrong for 1024x600 - force it to 60Hz */ - if((var->xres == 1024) && (var->yres == 600)) refresh_rate = 60; - search_idx = 0; while( (sisbios_mode[search_idx].mode_no != 0) && (sisbios_mode[search_idx].xres <= var->xres) ) { if( (sisbios_mode[search_idx].xres == var->xres) && (sisbios_mode[search_idx].yres == var->yres) && (sisbios_mode[search_idx].bpp == var->bits_per_pixel)) { - if(sisfb_validate_mode(search_idx) > 0) { + if(sisfb_validate_mode(search_idx, ivideo.currentvbflags) > 0) { found_mode = 1; break; } @@ -1687,38 +1916,95 @@ static int sisfb_check_var(struct fb_var } if(!found_mode) { - - printk(KERN_ERR "sisfb: %dx%dx%d is no valid mode\n", - var->xres, var->yres, var->bits_per_pixel); - + search_idx = 0; while(sisbios_mode[search_idx].mode_no != 0) { - if( (var->xres <= sisbios_mode[search_idx].xres) && - (var->yres <= sisbios_mode[search_idx].yres) && + (var->yres <= sisbios_mode[search_idx].yres) && (var->bits_per_pixel == sisbios_mode[search_idx].bpp) ) { - if(sisfb_validate_mode(search_idx) > 0) { + if(sisfb_validate_mode(search_idx, ivideo.currentvbflags) > 0) { found_mode = 1; break; } } search_idx++; - } + } if(found_mode) { + printk(KERN_DEBUG "sisfb: Adapted from %dx%dx%d to %dx%dx%d\n", + var->xres, var->yres, var->bits_per_pixel, + sisbios_mode[search_idx].xres, + sisbios_mode[search_idx].yres, + var->bits_per_pixel); var->xres = sisbios_mode[search_idx].xres; var->yres = sisbios_mode[search_idx].yres; - printk(KERN_DEBUG "sisfb: Adapted to mode %dx%dx%d\n", - var->xres, var->yres, var->bits_per_pixel); - + + } else { - printk(KERN_ERR "sisfb: Failed to find similar mode to %dx%dx%d\n", + printk(KERN_ERR "sisfb: Failed to find supported mode near %dx%dx%d\n", var->xres, var->yres, var->bits_per_pixel); return -EINVAL; } } - /* TW: TODO: Check the refresh rate */ - + if( ((ivideo.vbflags & VB_LVDS) || /* Slave modes on LVDS and 301B-DH */ + ((ivideo.vbflags & VB_30xBDH) && (ivideo.currentvbflags & CRT2_LCD))) && + (var->bits_per_pixel == 8) ) { + refresh_rate = 60; + recalc_clock = TRUE; + } else if( (ivideo.current_htotal == htotal) && /* x=x & y=y & c=c -> assume depth change */ + (ivideo.current_vtotal == vtotal) && + (ivideo.current_pixclock == pixclock) ) { + drate = 1000000000 / pixclock; + hrate = (drate * 1000) / htotal; + refresh_rate = (unsigned int) (hrate * 2 / vtotal); + } else if( ( (ivideo.current_htotal != htotal) || /* x!=x | y!=y & c=c -> invalid pixclock */ + (ivideo.current_vtotal != vtotal) ) && + (ivideo.current_pixclock == var->pixclock) ) { + if(sisfb_lastrates[sisbios_mode[search_idx].mode_no]) { + refresh_rate = sisfb_lastrates[sisbios_mode[search_idx].mode_no]; + } else if(sisfb_parm_rate != -1) { + refresh_rate = sisfb_parm_rate; + } else { + refresh_rate = 60; + } + recalc_clock = TRUE; + } else if((pixclock) && (htotal) && (vtotal)) { + drate = 1000000000 / pixclock; + hrate = (drate * 1000) / htotal; + refresh_rate = (unsigned int) (hrate * 2 / vtotal); + } else if(ivideo.current_refresh_rate) { + refresh_rate = ivideo.current_refresh_rate; + recalc_clock = TRUE; + } else { + refresh_rate = 60; + recalc_clock = TRUE; + } + + myrateindex = sisfb_search_refresh_rate(refresh_rate, search_idx); + + /* Eventually recalculate timing and clock */ + if(recalc_clock) { + if(!myrateindex) myrateindex = sisbios_mode[search_idx].rate_idx; + var->pixclock = (u32) (1000000000 / sisfb_mode_rate_to_dclock(&SiS_Pr, &sishw_ext, + sisbios_mode[search_idx].mode_no, myrateindex)); + sisfb_mode_rate_to_ddata(&SiS_Pr, &sishw_ext, + sisbios_mode[search_idx].mode_no, myrateindex, + &var->left_margin, &var->right_margin, + &var->upper_margin, &var->lower_margin, + &var->hsync_len, &var->vsync_len, + &var->sync, &var->vmode); + if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { + var->pixclock <<= 1; + } + } + + if(sisfb_thismonitor.datavalid) { + if(!sisfb_verify_rate(&sisfb_thismonitor, search_idx, + myrateindex, refresh_rate)) { + printk(KERN_INFO "sisfb: WARNING: Refresh rate exceeds monitor specs!\n"); + } + } + /* Adapt RGB settings */ sisfb_bpp_to_var(var); @@ -1732,24 +2018,32 @@ static int sisfb_check_var(struct fb_var if(var->xres != var->xres_virtual) var->xres_virtual = var->xres; - if(!sisfb_ypan) { - if(var->yres != var->yres_virtual) - var->yres_virtual = var->yres; + if(sisfb_ypan) { + maxyres = ivideo.heapstart / (var->xres * (var->bits_per_pixel >> 3)); + if(maxyres > 32767) maxyres = 32767; + if(sisfb_max) { + var->yres_virtual = maxyres; + } else { + if(var->yres_virtual > maxyres) { + var->yres_virtual = maxyres; + } + } + if(var->yres_virtual <= var->yres) { + var->yres_virtual = var->yres; + } } else { - /* TW: Now patch yres_virtual if we use panning */ - /* *** May I do this? *** */ - var->yres_virtual = ivideo.heapstart / (var->xres * (var->bits_per_pixel >> 3)); - if(var->yres_virtual <= var->yres) { - /* TW: Paranoia check */ - var->yres_virtual = var->yres; - } + if(var->yres != var->yres_virtual) { + var->yres_virtual = var->yres; + } + var->xoffset = 0; + var->yoffset = 0; } /* Truncate offsets to maximum if too high */ - if (var->xoffset > var->xres_virtual - var->xres) + if(var->xoffset > var->xres_virtual - var->xres) var->xoffset = var->xres_virtual - var->xres - 1; - if (var->yoffset > var->yres_virtual - var->yres) + if(var->yoffset > var->yres_virtual - var->yres) var->yoffset = var->yres_virtual - var->yres - 1; /* Set everything else to 0 */ @@ -1757,28 +2051,25 @@ static int sisfb_check_var(struct fb_var var->green.msb_right = var->blue.msb_right = var->transp.offset = var->transp.length = var->transp.msb_right = 0; - - TWDEBUG("end of check_var"); + return 0; } -#ifdef SISFB_PAN static int sisfb_pan_display(struct fb_var_screeninfo *var, struct fb_info* info) { int err; - - TWDEBUG("inside pan_display"); - + if (var->xoffset > (var->xres_virtual - var->xres)) return -EINVAL; if (var->yoffset > (var->yres_virtual - var->yres)) return -EINVAL; if (var->vmode & FB_VMODE_YWRAP) { - if (var->yoffset < 0 - || var->yoffset >= info->var.yres_virtual - || var->xoffset) return -EINVAL; + if (var->yoffset < 0 || + var->yoffset >= info->var.yres_virtual || + var->xoffset) + return -EINVAL; } else { if (var->xoffset + info->var.xres > info->var.xres_virtual || var->yoffset + info->var.yres > info->var.yres_virtual) @@ -1794,10 +2085,8 @@ static int sisfb_pan_display(struct fb_v else info->var.vmode &= ~FB_VMODE_YWRAP; - TWDEBUG("end of pan_display"); return 0; } -#endif static int sisfb_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma) @@ -1806,7 +2095,6 @@ static int sisfb_mmap(struct fb_info *in unsigned long off; u32 len, mmio_off; - TWDEBUG("inside mmap"); if(vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) return -EINVAL; off = vma->vm_pgoff << PAGE_SHIFT; @@ -1844,188 +2132,219 @@ static int sisfb_mmap(struct fb_info *in vma->vm_page_prot)) return -EAGAIN; - TWDEBUG("end of mmap"); return 0; } static int sisfb_blank(int blank, struct fb_info *info) { - u8 reg; + return(sisfb_myblank(blank)); +} - inSISIDXREG(SISCR, 0x17, reg); +#endif - if(blank > 0) - reg &= 0x7f; - else - reg |= 0x80; +/* ----------- FBDev related routines for all series ---------- */ - outSISIDXREG(SISCR, 0x17, reg); - outSISIDXREG(SISSR, 0x00, 0x01); /* Synchronous Reset */ - outSISIDXREG(SISSR, 0x00, 0x03); /* End Reset */ - return(0); -} +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) +static int sisfb_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg, + struct fb_info *info) +#else static int sisfb_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg, + unsigned int cmd, unsigned long arg, int con, struct fb_info *info) +#endif { - TWDEBUG("inside ioctl"); + struct sis_memreq sismemreq; + struct ap_data sisapdata; + unsigned long sismembase = 0; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) + SIS_GLYINFO sisglyinfo; +#endif + switch (cmd) { case FBIO_ALLOC: - if (!capable(CAP_SYS_RAWIO)) + if(!capable(CAP_SYS_RAWIO)) return -EPERM; - sis_malloc((struct sis_memreq *) arg); + if(copy_from_user(&sismemreq, (void *)arg, sizeof(sismemreq))) + return -EFAULT; + sis_malloc(&sismemreq); + if(copy_to_user((void *)arg, &sismemreq, sizeof(sismemreq))) { + sis_free(sismemreq.offset); + return -EFAULT; + } break; case FBIO_FREE: - if (!capable(CAP_SYS_RAWIO)) + if(!capable(CAP_SYS_RAWIO)) return -EPERM; - sis_free(*(unsigned long *) arg); + if(get_user(sismembase, (unsigned long *) arg)) + return -EFAULT; + sis_free(sismembase); break; - case FBIOGET_HWCINFO: +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) + case FBIOGET_GLYPH: + if(copy_from_user(&sisglyinfo, (void *)arg, sizeof(sisglyinfo))) + return -EFAULT; + sis_get_glyph(info, &sisglyinfo); + break; + case FBIOPUT_MODEINFO: { - unsigned long *hwc_offset = (unsigned long *) arg; + struct mode_info x; - if (sisfb_caps & HW_CURSOR_CAP) - *hwc_offset = sisfb_hwcursor_vbase - - (unsigned long) ivideo.video_vbase; - else - *hwc_offset = 0; + if(copy_from_user(&x, (void *)arg, sizeof(x))) + return -EFAULT; + ivideo.video_bpp = x.bpp; + ivideo.video_width = x.xres; + ivideo.video_height = x.yres; + ivideo.video_vwidth = x.v_xres; + ivideo.video_vheight = x.v_yres; + ivideo.org_x = x.org_x; + ivideo.org_y = x.org_y; + ivideo.refresh_rate = x.vrate; + ivideo.video_linelength = ivideo.video_vwidth * (ivideo.video_bpp >> 3); + sisfb_set_vparms(); break; } - case FBIOPUT_MODEINFO: +#endif + case FBIOGET_HWCINFO: { - struct mode_info *x = (struct mode_info *)arg; + unsigned long myhwcoffset = 0; - ivideo.video_bpp = x->bpp; - ivideo.video_width = x->xres; - ivideo.video_height = x->yres; - ivideo.video_vwidth = x->v_xres; - ivideo.video_vheight = x->v_yres; - ivideo.org_x = x->org_x; - ivideo.org_y = x->org_y; - ivideo.refresh_rate = x->vrate; - ivideo.video_linelength = ivideo.video_vwidth * (ivideo.video_bpp >> 3); - switch(ivideo.video_bpp) { - case 8: - ivideo.DstColor = 0x0000; - ivideo.SiS310_AccelDepth = 0x00000000; - ivideo.video_cmap_len = 256; - break; - case 16: - ivideo.DstColor = 0x8000; - ivideo.SiS310_AccelDepth = 0x00010000; - ivideo.video_cmap_len = 16; - break; - case 32: - ivideo.DstColor = 0xC000; - ivideo.SiS310_AccelDepth = 0x00020000; - ivideo.video_cmap_len = 16; - break; - default: - ivideo.video_cmap_len = 16; - printk(KERN_ERR "sisfb: Unsupported accel depth %d", ivideo.video_bpp); - ivideo.accel = 0; - break; - } + if(sisfb_caps & HW_CURSOR_CAP) + myhwcoffset = sisfb_hwcursor_vbase - + (unsigned long) ivideo.video_vbase; + + return put_user(myhwcoffset, (unsigned long *)arg); break; } case FBIOGET_DISPINFO: - sis_dispinfo((struct ap_data *)arg); + sis_dispinfo(&sisapdata); + if(copy_to_user((void *)arg, &sisapdata, sizeof(sisapdata))) + return -EFAULT; break; - case SISFB_GET_INFO: /* TW: New for communication with X driver */ + case SISFB_GET_INFO: /* For communication with X driver */ { - sisfb_info *x = (sisfb_info *)arg; + sisfb_info x; - x->sisfb_id = SISFB_ID; - x->sisfb_version = VER_MAJOR; - x->sisfb_revision = VER_MINOR; - x->sisfb_patchlevel = VER_LEVEL; - x->chip_id = ivideo.chip_id; - x->memory = ivideo.video_size / 1024; - x->heapstart = ivideo.heapstart / 1024; - x->fbvidmode = sisfb_mode_no; - x->sisfb_caps = sisfb_caps; - x->sisfb_tqlen = 512; /* yet unused */ - x->sisfb_pcibus = ivideo.pcibus; - x->sisfb_pcislot = ivideo.pcislot; - x->sisfb_pcifunc = ivideo.pcifunc; - x->sisfb_lcdpdc = sisfb_detectedpdc; - x->sisfb_lcda = sisfb_detectedlcda; + x.sisfb_id = SISFB_ID; + x.sisfb_version = VER_MAJOR; + x.sisfb_revision = VER_MINOR; + x.sisfb_patchlevel = VER_LEVEL; + x.chip_id = ivideo.chip_id; + x.memory = ivideo.video_size / 1024; + x.heapstart = ivideo.heapstart / 1024; + x.fbvidmode = sisfb_mode_no; + x.sisfb_caps = sisfb_caps; + x.sisfb_tqlen = 512; /* yet fixed */ + x.sisfb_pcibus = ivideo.pcibus; + x.sisfb_pcislot = ivideo.pcislot; + x.sisfb_pcifunc = ivideo.pcifunc; + x.sisfb_lcdpdc = sisfb_detectedpdc; + x.sisfb_lcda = sisfb_detectedlcda; + x.sisfb_vbflags = ivideo.vbflags; + x.sisfb_currentvbflags = ivideo.currentvbflags; + x.sisfb_scalelcd = SiS_Pr.UsePanelScaler; + x.sisfb_specialtiming = SiS_Pr.SiS_CustomT; + x.sisfb_haveemi = SiS_Pr.HaveEMI ? 1 : 0; + x.sisfb_haveemilcd = SiS_Pr.HaveEMILCD ? 1 : 0; + x.sisfb_emi30 = SiS_Pr.EMI_30; + x.sisfb_emi31 = SiS_Pr.EMI_31; + x.sisfb_emi32 = SiS_Pr.EMI_32; + x.sisfb_emi33 = SiS_Pr.EMI_33; + if(copy_to_user((void *)arg, &x, sizeof(x))) + return -EFAULT; break; } case SISFB_GET_VBRSTATUS: { - unsigned long *vbrstatus = (unsigned long *) arg; - if(sisfb_CheckVBRetrace()) *vbrstatus = 1; - else *vbrstatus = 0; + if(sisfb_CheckVBRetrace()) + return put_user(1UL, (unsigned long *) arg); + else + return put_user(0UL, (unsigned long *) arg); + break; + } + case SISFB_GET_AUTOMAXIMIZE: + { + if(sisfb_max) + return put_user(1UL, (unsigned long *) arg); + else + return put_user(0UL, (unsigned long *) arg); + break; + } + case SISFB_SET_AUTOMAXIMIZE: + { + unsigned long newmax; + + if(copy_from_user(&newmax, (unsigned long *)arg, sizeof(newmax))) + return -EFAULT; + + if(newmax) sisfb_max = 1; + else sisfb_max = 0; + break; } default: return -EINVAL; } - TWDEBUG("end of ioctl"); return 0; - } -#endif - -/* ----------- FBDev related routines for all series ---------- */ static int sisfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info) { - TWDEBUG("inside get_fix"); memset(fix, 0, sizeof(struct fb_fix_screeninfo)); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - strcpy(fix->id, sis_fb_info.modename); + strcpy(fix->id, sis_fb_info->modename); #else strcpy(fix->id, myid); #endif fix->smem_start = ivideo.video_base; - /* TW */ if((!sisfb_mem) || (sisfb_mem > (ivideo.video_size/1024))) { - if (ivideo.video_size > 0x1000000) { - fix->smem_len = 0xc00000; - } else if (ivideo.video_size > 0x800000) - fix->smem_len = 0x800000; - else - fix->smem_len = 0x400000; + if(sisvga_engine == SIS_300_VGA) { + if(ivideo.video_size > 0x1000000) { + fix->smem_len = 0xc00000; + } else if(ivideo.video_size > 0x800000) + fix->smem_len = 0x800000; + else + fix->smem_len = 0x400000; + } else { + fix->smem_len = ivideo.video_size - 0x100000; + } } else fix->smem_len = sisfb_mem * 1024; - fix->type = video_type; + fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; if(ivideo.video_bpp == 8) - fix->visual = FB_VISUAL_PSEUDOCOLOR; + fix->visual = FB_VISUAL_PSEUDOCOLOR; else - fix->visual = FB_VISUAL_TRUECOLOR; + fix->visual = FB_VISUAL_TRUECOLOR; fix->xpanstep = 0; -#ifdef SISFB_PAN + if(sisfb_ypan) fix->ypanstep = 1; -#endif + fix->ywrapstep = 0; fix->line_length = ivideo.video_linelength; fix->mmio_start = ivideo.mmio_base; fix->mmio_len = sisfb_mmio_size; if(sisvga_engine == SIS_300_VGA) fix->accel = FB_ACCEL_SIS_GLAMOUR; - else if(ivideo.chip == SIS_330) + else if((ivideo.chip == SIS_330) || (ivideo.chip == SIS_760)) fix->accel = FB_ACCEL_SIS_XABRE; - else + else fix->accel = FB_ACCEL_SIS_GLAMOUR_2; - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) fix->reserved[0] = ivideo.video_size & 0xFFFF; fix->reserved[1] = (ivideo.video_size >> 16) & 0xFFFF; fix->reserved[2] = sisfb_caps; -#endif +#endif - TWDEBUG("end of get_fix"); return 0; } @@ -2033,17 +2352,15 @@ static int sisfb_get_fix(struct fb_fix_s #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) static struct fb_ops sisfb_ops = { - owner: THIS_MODULE, - fb_get_fix: sisfb_get_fix, - fb_get_var: sisfb_get_var, - fb_set_var: sisfb_set_var, - fb_get_cmap: sisfb_get_cmap, - fb_set_cmap: sisfb_set_cmap, -#ifdef SISFB_PAN - fb_pan_display: sisfb_pan_display, -#endif - fb_ioctl: sisfb_ioctl, - fb_mmap: sisfb_mmap, + .owner = THIS_MODULE, + .fb_get_fix = sisfb_get_fix, + .fb_get_var = sisfb_get_var, + .fb_set_var = sisfb_set_var, + .fb_get_cmap = sisfb_get_cmap, + .fb_set_cmap = sisfb_set_cmap, + .fb_pan_display = sisfb_pan_display, + .fb_ioctl = sisfb_ioctl, + .fb_mmap = sisfb_mmap, }; #endif @@ -2056,9 +2373,7 @@ static struct fb_ops sisfb_ops = { .fb_check_var = sisfb_check_var, .fb_set_par = sisfb_set_par, .fb_setcolreg = sisfb_setcolreg, -#ifdef SISFB_PAN .fb_pan_display = sisfb_pan_display, -#endif .fb_blank = sisfb_blank, .fb_fillrect = fbcon_sis_fillrect, .fb_copyarea = fbcon_sis_copyarea, @@ -2097,368 +2412,98 @@ static int sisfb_get_dram_size_300(void) break; } - if (nbridge_id == 0) { /* 300 */ - - inSISIDXREG(SISSR, IND_SIS_DRAM_SIZE,reg); - ivideo.video_size = - ((unsigned int) ((reg & SIS_DRAM_SIZE_MASK) + 1) << 20); - - } else { /* 540, 630, 730 */ - - pdev = pci_find_device(PCI_VENDOR_ID_SI, nbridge_id, pdev); - if (pdev) { - pci_read_config_byte(pdev, IND_BRI_DRAM_STATUS, &pci_data); - pci_data = (pci_data & BRI_DRAM_SIZE_MASK) >> 4; - ivideo.video_size = (unsigned int)(1 << (pci_data+21)); - pdev_valid = 1; - - reg = SIS_DATA_BUS_64 << 6; - switch (pci_data) { - case BRI_DRAM_SIZE_2MB: - reg |= SIS_DRAM_SIZE_2MB; - break; - case BRI_DRAM_SIZE_4MB: - reg |= SIS_DRAM_SIZE_4MB; - break; - case BRI_DRAM_SIZE_8MB: - reg |= SIS_DRAM_SIZE_8MB; - break; - case BRI_DRAM_SIZE_16MB: - reg |= SIS_DRAM_SIZE_16MB; - break; - case BRI_DRAM_SIZE_32MB: - reg |= SIS_DRAM_SIZE_32MB; - break; - case BRI_DRAM_SIZE_64MB: - reg |= SIS_DRAM_SIZE_64MB; - break; - } - outSISIDXREG(SISSR, IND_SIS_DRAM_SIZE, reg); - } - - if (!pdev_valid) return -1; - } - return 0; -} - -static void sisfb_detect_VB_connect_300() -{ - u8 sr16, sr17, cr32, temp; - - ivideo.TV_plug = ivideo.TV_type = 0; - - switch(ivideo.hasVB) { - case HASVB_LVDS_CHRONTEL: - case HASVB_CHRONTEL: - SiS_SenseCh(); - break; - case HASVB_301: - case HASVB_302: - SiS_Sense30x(); - break; - } - - inSISIDXREG(SISSR, IND_SIS_SCRATCH_REG_17, sr17); - inSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR32, cr32); - - if ((sr17 & 0x0F) && (ivideo.chip != SIS_300)) { - - if ((sr17 & 0x01) && !sisfb_crt1off) - sisfb_crt1off = 0; - else { - if (sr17 & 0x0E) - sisfb_crt1off = 1; - else - sisfb_crt1off = 0; - } - - if (sisfb_crt2type != -1) - /* TW: override detected CRT2 type */ - ivideo.disp_state = sisfb_crt2type; - else if (sr17 & 0x04) - ivideo.disp_state = DISPTYPE_TV; - else if (sr17 & 0x02) - ivideo.disp_state = DISPTYPE_LCD; - else if (sr17 & 0x08 ) - ivideo.disp_state = DISPTYPE_CRT2; - else - ivideo.disp_state = 0; - - if(sisfb_tvplug != -1) - /* PR/TW: override detected TV type */ - ivideo.TV_plug = sisfb_tvplug; - else if (sr17 & 0x20) - ivideo.TV_plug = TVPLUG_SVIDEO; - else if (sr17 & 0x10) - ivideo.TV_plug = TVPLUG_COMPOSITE; - - inSISIDXREG(SISSR, IND_SIS_SCRATCH_REG_16, sr16); - if (sr16 & 0x20) - ivideo.TV_type = TVMODE_PAL; - else - ivideo.TV_type = TVMODE_NTSC; - - } else { - - if ((cr32 & SIS_CRT1) && !sisfb_crt1off) - sisfb_crt1off = 0; - else { - if (cr32 & 0x5F) - sisfb_crt1off = 1; - else - sisfb_crt1off = 0; - } - - if (sisfb_crt2type != -1) - /* TW: override detected CRT2 type */ - ivideo.disp_state = sisfb_crt2type; - else if (cr32 & SIS_VB_TV) - ivideo.disp_state = DISPTYPE_TV; - else if (cr32 & SIS_VB_LCD) - ivideo.disp_state = DISPTYPE_LCD; - else if (cr32 & SIS_VB_CRT2) - ivideo.disp_state = DISPTYPE_CRT2; - else - ivideo.disp_state = 0; - - /* TW: Detect TV plug & type */ - if(sisfb_tvplug != -1) - /* PR/TW: override with option */ - ivideo.TV_plug = sisfb_tvplug; - else if (cr32 & SIS_VB_HIVISION) { - ivideo.TV_type = TVMODE_HIVISION; - ivideo.TV_plug = TVPLUG_SVIDEO; - } - else if (cr32 & SIS_VB_SVIDEO) - ivideo.TV_plug = TVPLUG_SVIDEO; - else if (cr32 & SIS_VB_COMPOSITE) - ivideo.TV_plug = TVPLUG_COMPOSITE; - else if (cr32 & SIS_VB_SCART) - ivideo.TV_plug = TVPLUG_SCART; - - if (ivideo.TV_type == 0) { - inSISIDXREG(SISSR, IND_SIS_POWER_ON_TRAP, temp); - if (temp & 0x01) - ivideo.TV_type = TVMODE_PAL; - else - ivideo.TV_type = TVMODE_NTSC; - } - - } - - /* TW: Copy forceCRT1 option to CRT1off if option is given */ - if (sisfb_forcecrt1 != -1) { - if(sisfb_forcecrt1) sisfb_crt1off = 0; - else sisfb_crt1off = 1; - } -} - -static void sisfb_get_VB_type_300(void) -{ - u8 reg; - - if(ivideo.chip != SIS_300) { - if(!sisfb_has_VB_300()) { - inSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR37, reg); - switch ((reg & SIS_EXTERNAL_CHIP_MASK) >> 1) { - case SIS_EXTERNAL_CHIP_LVDS: - ivideo.hasVB = HASVB_LVDS; - break; - case SIS_EXTERNAL_CHIP_TRUMPION: - ivideo.hasVB = HASVB_TRUMPION; - break; - case SIS_EXTERNAL_CHIP_LVDS_CHRONTEL: - ivideo.hasVB = HASVB_LVDS_CHRONTEL; - break; - case SIS_EXTERNAL_CHIP_CHRONTEL: - ivideo.hasVB = HASVB_CHRONTEL; - break; - default: - break; - } - } - } else { - sisfb_has_VB_300(); - } -} - -static int sisfb_has_VB_300(void) -{ - u8 vb_chipid; - - inSISIDXREG(SISPART4, 0x00, vb_chipid); - switch (vb_chipid) { - case 0x01: - ivideo.hasVB = HASVB_301; - break; - case 0x02: - ivideo.hasVB = HASVB_302; - break; - default: - ivideo.hasVB = HASVB_NONE; - return FALSE; - } - return TRUE; - -} - -#endif /* CONFIG_FB_SIS_300 */ - - -#ifdef CONFIG_FB_SIS_315 /* for SiS 315/550/650/740/330 */ - -static int sisfb_get_dram_size_315(void) -{ - struct pci_dev *pdev = NULL; - int pdev_valid = 0; - u8 pci_data; - u8 reg = 0; + if (nbridge_id == 0) { /* 300 */ - if (ivideo.chip == SIS_550 || ivideo.chip == SIS_650 || ivideo.chip == SIS_740) { + inSISIDXREG(SISSR, IND_SIS_DRAM_SIZE,reg); + ivideo.video_size = + ((unsigned int) ((reg & SIS_DRAM_SIZE_MASK) + 1) << 20); -#ifdef LINUXBIOS + } else { /* 540, 630, 730 */ - while ((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_ANY_ID, pdev)) != NULL) { - if ((pdev->device == PCI_DEVICE_ID_SI_550) || - (pdev->device == PCI_DEVICE_ID_SI_650) || - (pdev->device == PCI_DEVICE_ID_SI_740)) { - pci_read_config_byte(pdev, IND_BRI_DRAM_STATUS, - &pci_data); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74) + pci_for_each_dev(pdev) { +#else + while((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_ANY_ID, pdev))) { +#endif + if ((pdev->vendor == PCI_VENDOR_ID_SI) + && (pdev->device == nbridge_id)) { + pci_read_config_byte(pdev, IND_BRI_DRAM_STATUS, &pci_data); pci_data = (pci_data & BRI_DRAM_SIZE_MASK) >> 4; - ivideo.video_size = (unsigned int)(1 << (pci_data + 21)); + ivideo.video_size = (unsigned int)(1 << (pci_data+21)); pdev_valid = 1; - /* TW: Initialize SR14 "by hand" */ - inSISIDXREG(SISSR, IND_SIS_DRAM_SIZE, reg); - reg &= 0xC0; + reg = SIS_DATA_BUS_64 << 6; switch (pci_data) { + case BRI_DRAM_SIZE_2MB: + reg |= SIS_DRAM_SIZE_2MB; + break; case BRI_DRAM_SIZE_4MB: - reg |= SIS550_DRAM_SIZE_4MB; + reg |= SIS_DRAM_SIZE_4MB; break; case BRI_DRAM_SIZE_8MB: - reg |= SIS550_DRAM_SIZE_8MB; + reg |= SIS_DRAM_SIZE_8MB; break; case BRI_DRAM_SIZE_16MB: - reg |= SIS550_DRAM_SIZE_16MB; + reg |= SIS_DRAM_SIZE_16MB; break; case BRI_DRAM_SIZE_32MB: - reg |= SIS550_DRAM_SIZE_32MB; + reg |= SIS_DRAM_SIZE_32MB; break; case BRI_DRAM_SIZE_64MB: - reg |= SIS550_DRAM_SIZE_64MB; + reg |= SIS_DRAM_SIZE_64MB; break; } - - /* TODO: set Dual channel and bus width bits here */ - outSISIDXREG(SISSR, IND_SIS_DRAM_SIZE, reg); break; } } if (!pdev_valid) return -1; + } + return 0; +} -#else +#endif /* CONFIG_FB_SIS_300 */ + + +#ifdef CONFIG_FB_SIS_315 /* for SiS 315/550/650/740/330/661/741/760 */ + +static int sisfb_get_dram_size_315(void) +{ + u8 reg = 0; + + if(ivideo.chip == SIS_550 || + ivideo.chip == SIS_650 || + ivideo.chip == SIS_740) { inSISIDXREG(SISSR, IND_SIS_DRAM_SIZE, reg); - switch (reg & SIS550_DRAM_SIZE_MASK) { - case SIS550_DRAM_SIZE_4MB: - ivideo.video_size = 0x400000; break; - case SIS550_DRAM_SIZE_8MB: - ivideo.video_size = 0x800000; break; - case SIS550_DRAM_SIZE_16MB: - ivideo.video_size = 0x1000000; break; - case SIS550_DRAM_SIZE_24MB: - ivideo.video_size = 0x1800000; break; - case SIS550_DRAM_SIZE_32MB: - ivideo.video_size = 0x2000000; break; - case SIS550_DRAM_SIZE_64MB: - ivideo.video_size = 0x4000000; break; - case SIS550_DRAM_SIZE_96MB: - ivideo.video_size = 0x6000000; break; - case SIS550_DRAM_SIZE_128MB: - ivideo.video_size = 0x8000000; break; - case SIS550_DRAM_SIZE_256MB: - ivideo.video_size = 0x10000000; break; - default: - /* TW: Some 550 BIOSes don't seem to initialize SR14 correctly (if at all), - * do it the hard way ourselves in this case. Unfortunately, we don't - * support 24, 48, 96 and other "odd" amounts here. - */ - printk(KERN_INFO - "sisfb: Warning: Could not determine memory size, " - "now reading from PCI config\n"); - pdev_valid = 0; - - while ((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_550, pdev)) != NULL) { - pci_read_config_byte(pdev, IND_BRI_DRAM_STATUS, - &pci_data); - pci_data = (pci_data & BRI_DRAM_SIZE_MASK) >> 4; - ivideo.video_size = (unsigned int)(1 << (pci_data+21)); - pdev_valid = 1; - /* TW: Initialize SR14=IND_SIS_DRAM_SIZE */ - inSISIDXREG(SISSR, IND_SIS_DRAM_SIZE, reg); - reg &= 0xC0; - switch (pci_data) { - case BRI_DRAM_SIZE_4MB: - reg |= SIS550_DRAM_SIZE_4MB; break; - case BRI_DRAM_SIZE_8MB: - reg |= SIS550_DRAM_SIZE_8MB; break; - case BRI_DRAM_SIZE_16MB: - reg |= SIS550_DRAM_SIZE_16MB; break; - case BRI_DRAM_SIZE_32MB: - reg |= SIS550_DRAM_SIZE_32MB; break; - case BRI_DRAM_SIZE_64MB: - reg |= SIS550_DRAM_SIZE_64MB; break; - default: - printk(KERN_INFO "sisfb: Unable to determine memory size, giving up.\n"); - return -1; - } - outSISIDXREG(SISSR, IND_SIS_DRAM_SIZE, reg); - } - if (!pdev_valid) { - printk(KERN_INFO "sisfb: Total confusion - No SiS PCI VGA device found?!\n"); - return -1; - } - return 0; - } -#endif + reg &= 0x3f; + reg++; + reg <<= 2; + ivideo.video_size = reg << 20; return 0; - } else { /* 315 */ + } else if(ivideo.chip == SIS_661 || + ivideo.chip == SIS_741 || + ivideo.chip == SIS_660 || + ivideo.chip == SIS_760) { + + inSISIDXREG(SISCR, 0x79, reg); + reg &= 0xf0; + reg >>= 4; + ivideo.video_size = (1 << reg) << 20; + return 0; + + } else { /* 315, 330 */ inSISIDXREG(SISSR, IND_SIS_DRAM_SIZE, reg); - switch ((reg & SIS315_DRAM_SIZE_MASK) >> 4) { - case SIS315_DRAM_SIZE_2MB: - ivideo.video_size = 0x200000; - break; - case SIS315_DRAM_SIZE_4MB: - ivideo.video_size = 0x400000; - break; - case SIS315_DRAM_SIZE_8MB: - ivideo.video_size = 0x800000; - break; - case SIS315_DRAM_SIZE_16MB: - ivideo.video_size = 0x1000000; - break; - case SIS315_DRAM_SIZE_32MB: - ivideo.video_size = 0x2000000; - break; - case SIS315_DRAM_SIZE_64MB: - ivideo.video_size = 0x4000000; - break; - case SIS315_DRAM_SIZE_128MB: - ivideo.video_size = 0x8000000; - break; - default: - return -1; - } - + ivideo.video_size = (1 << ((reg & 0xf0) >> 4)) << 20; + reg &= SIS315_DUAL_CHANNEL_MASK; reg >>= 2; - + if(ivideo.chip == SIS_330) { - + if(reg) ivideo.video_size <<= 1; } else { @@ -2470,7 +2515,7 @@ static int sisfb_get_dram_size_315(void) case SIS315_DUAL_CHANNEL_1_RANK: ivideo.video_size <<= 1; break; - case SIS315_ASYM_DDR: /* TW: DDR asymentric */ + case SIS315_ASYM_DDR: /* TW: DDR asymetric */ ivideo.video_size += (ivideo.video_size/2); break; } @@ -2483,312 +2528,581 @@ static int sisfb_get_dram_size_315(void) } -static void sisfb_detect_VB_connect_315(void) +#endif /* CONFIG_FB_SIS_315 */ + + +/* -------------- video bridge detection --------------- */ + +static void sisfb_detect_VB_connect() { - u8 cr32, temp=0; + u8 sr16, sr17, cr32, temp; + + if(sisvga_engine == SIS_300_VGA) { - ivideo.TV_plug = ivideo.TV_type = 0; + inSISIDXREG(SISSR, IND_SIS_SCRATCH_REG_17, sr17); + + if ((sr17 & 0x0F) && (ivideo.chip != SIS_300)) { + + /* Old BIOSes store the detected CRT2 type in SR17 + * instead of CR32. However, since our detection + * routines store their results to CR32, we now copy + * the remaining bits (for LCD and VGA) to CR32 for + * unified usage. + * SR17[0] CRT1 [1] LCD [2] TV [3] VGA2 + * [4] AVIDEO [5] SVIDEO + */ + +#if 0 + if (sr17 & 0x01) orSISIDXREG(SISCR, 0x32, SIS_CRT1); + else andSISIDXREG(SISCR, 0x32, ~SIS_CRT1); + + if (sr17 & 0x02) orSISIDXREG(SISCR, 0x32, SIS_VB_LCD); + else andSISIDXREG(SISCR, 0x32, ~SIS_VB_LCD); + + /* no HiVision and no DVI connector here */ + andSISIDXREG(SISCR, 0x32, ~0xc0); +#endif + + /* PAL/NTSC is stored on SR16 on such machines */ + if (!(ivideo.vbflags & (TV_PAL | TV_NTSC))) { + inSISIDXREG(SISSR, IND_SIS_SCRATCH_REG_16, sr16); + if (sr16 & 0x20) + ivideo.vbflags |= TV_PAL; + else + ivideo.vbflags |= TV_NTSC; + } + + } - switch(ivideo.hasVB) { - case HASVB_LVDS_CHRONTEL: - case HASVB_CHRONTEL: - SiS_SenseCh(); - break; - case HASVB_301: - case HASVB_302: - SiS_Sense30x(); - break; } inSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR32, cr32); - if ((cr32 & SIS_CRT1) && !sisfb_crt1off) + if (cr32 & SIS_CRT1) sisfb_crt1off = 0; else { - if (cr32 & 0x5F) + if (cr32 & 0x5F) sisfb_crt1off = 1; else sisfb_crt1off = 0; } - if (sisfb_crt2type != -1) - /* TW: Override with option */ - ivideo.disp_state = sisfb_crt2type; - else if (cr32 & SIS_VB_TV) - ivideo.disp_state = DISPTYPE_TV; - else if (cr32 & SIS_VB_LCD) - ivideo.disp_state = DISPTYPE_LCD; - else if (cr32 & SIS_VB_CRT2) - ivideo.disp_state = DISPTYPE_CRT2; - else - ivideo.disp_state = 0; + ivideo.vbflags &= ~(CRT2_TV | CRT2_LCD | CRT2_VGA); + if (cr32 & SIS_VB_TV) + ivideo.vbflags |= CRT2_TV; + if (cr32 & SIS_VB_LCD) + ivideo.vbflags |= CRT2_LCD; + if (cr32 & SIS_VB_CRT2) + ivideo.vbflags |= CRT2_VGA; + + /* TW: Detect/set TV plug & type */ if(sisfb_tvplug != -1) - /* PR/TW: Override with option */ - ivideo.TV_plug = sisfb_tvplug; - else if (cr32 & SIS_VB_HIVISION) { - ivideo.TV_type = TVMODE_HIVISION; - ivideo.TV_plug = TVPLUG_SVIDEO; - } - else if (cr32 & SIS_VB_SVIDEO) - ivideo.TV_plug = TVPLUG_SVIDEO; + ivideo.vbflags |= sisfb_tvplug; + + if (cr32 & SIS_VB_SVIDEO) + ivideo.vbflags |= TV_SVIDEO; else if (cr32 & SIS_VB_COMPOSITE) - ivideo.TV_plug = TVPLUG_COMPOSITE; + ivideo.vbflags |= TV_AVIDEO; else if (cr32 & SIS_VB_SCART) - ivideo.TV_plug = TVPLUG_SCART; + ivideo.vbflags |= TV_SCART; - if(ivideo.TV_type == 0) { - /* TW: PAL/NTSC changed for 650 */ - if((ivideo.chip <= SIS_315PRO) || (ivideo.chip >= SIS_330)) { - - inSISIDXREG(SISCR, 0x38, temp); - if(temp & 0x10) - ivideo.TV_type = TVMODE_PAL; - else - ivideo.TV_type = TVMODE_NTSC; + if (!(ivideo.vbflags & (TV_PAL | TV_NTSC))) { + if(sisvga_engine == SIS_300_VGA) { + inSISIDXREG(SISSR, IND_SIS_POWER_ON_TRAP, temp); + if (temp & 0x01) + ivideo.vbflags |= TV_PAL; + else + ivideo.vbflags |= TV_NTSC; + } else if((ivideo.chip <= SIS_315PRO) || (ivideo.chip >= SIS_330)) { - } else { + inSISIDXREG(SISSR, 0x38, temp); + if(temp & 0x01) + ivideo.vbflags |= TV_PAL; + else + ivideo.vbflags |= TV_NTSC; - inSISIDXREG(SISCR, 0x79, temp); - if(temp & 0x20) - ivideo.TV_type = TVMODE_PAL; - else - ivideo.TV_type = TVMODE_NTSC; - } + } else { + + inSISIDXREG(SISCR, 0x79, temp); + if(temp & 0x20) + ivideo.vbflags |= TV_PAL; + else + ivideo.vbflags |= TV_NTSC; + } } /* TW: Copy forceCRT1 option to CRT1off if option is given */ if (sisfb_forcecrt1 != -1) { - if (sisfb_forcecrt1) sisfb_crt1off = 0; - else sisfb_crt1off = 1; + if(sisfb_forcecrt1) sisfb_crt1off = 0; + else sisfb_crt1off = 1; } -} - -static void sisfb_get_VB_type_315(void) -{ - u8 reg; - if (!sisfb_has_VB_315()) { - inSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR37, reg); - switch ((reg & SIS_EXTERNAL_CHIP_MASK) >> 1) { - case SIS310_EXTERNAL_CHIP_LVDS: - ivideo.hasVB = HASVB_LVDS; - break; - case SIS310_EXTERNAL_CHIP_LVDS_CHRONTEL: - ivideo.hasVB = HASVB_LVDS_CHRONTEL; - break; - default: - break; - } - } } - -static int sisfb_has_VB_315(void) +static void sisfb_get_VB_type(void) { u8 vb_chipid; + u8 reg; + char stdstr[] = "sisfb: Detected"; + char bridgestr[] = "video bridge"; + char lvdsstr[] = "LVDS transmitter"; + char chrstr[] = "Chrontel TV encoder"; + + ivideo.hasVB = HASVB_NONE; + sishw_ext.ujVBChipID = VB_CHIP_UNKNOWN; + sishw_ext.Is301BDH = FALSE; + sishw_ext.usExternalChip = 0; inSISIDXREG(SISPART4, 0x00, vb_chipid); switch (vb_chipid) { case 0x01: ivideo.hasVB = HASVB_301; + inSISIDXREG(SISPART4, 0x01, reg); + if(reg < 0xb0) { + ivideo.vbflags |= VB_301; + sishw_ext.ujVBChipID = VB_CHIP_301; + printk(KERN_INFO "%s SiS301 %s\n", stdstr, bridgestr); + } else if(reg < 0xc0) { + ivideo.vbflags |= VB_301B; + sishw_ext.ujVBChipID = VB_CHIP_301B; + inSISIDXREG(SISPART4,0x23,reg); + if(!(reg & 0x02)) { + sishw_ext.Is301BDH = TRUE; + ivideo.vbflags |= VB_30xBDH; + printk(KERN_INFO "%s SiS301B-DH %s\n", stdstr, bridgestr); + } else { + printk(KERN_INFO "%s SiS301B %s\n", stdstr, bridgestr); + } + } else if(reg < 0xd0) { + ivideo.vbflags |= VB_301C; + sishw_ext.ujVBChipID = VB_CHIP_301C; + printk(KERN_INFO "%s SiS301C %s\n", stdstr, bridgestr); + } else if(reg < 0xe0) { + ivideo.vbflags |= VB_301LV; + sishw_ext.ujVBChipID = VB_CHIP_301LV; + printk(KERN_INFO "%s SiS301LV %s\n", stdstr, bridgestr); + } else if(reg <= 0xe1) { + inSISIDXREG(SISPART4,0x39,reg); + if(reg == 0xff) { + ivideo.vbflags |= VB_302LV; + sishw_ext.ujVBChipID = VB_CHIP_302LV; + printk(KERN_INFO "%s SiS302LV %s\n", stdstr, bridgestr); + } else { + ivideo.vbflags |= VB_302ELV; + sishw_ext.ujVBChipID = VB_CHIP_302ELV; + printk(KERN_INFO "%s SiS302ELV %s\n", stdstr, bridgestr); + } + } break; case 0x02: ivideo.hasVB = HASVB_302; + inSISIDXREG(SISPART4, 0x01, reg); + if(reg < 0xd0) { + ivideo.vbflags |= VB_302B; + sishw_ext.ujVBChipID = VB_CHIP_302B; + inSISIDXREG(SISPART4,0x23,reg); + if(!(reg & 0x02)) { + sishw_ext.Is301BDH = TRUE; + ivideo.vbflags |= VB_30xBDH; + printk(KERN_INFO "%s SiS302B-DH %s\n", stdstr, bridgestr); + } else { + printk(KERN_INFO "%s SiS302B %s\n", stdstr, bridgestr); + } + } else if(reg < 0xe0) { + ivideo.vbflags |= VB_301LV; + sishw_ext.ujVBChipID = VB_CHIP_301LV; + printk(KERN_INFO "%s SiS301LV %s\n", stdstr, bridgestr); + } else if(reg <= 0xe1) { + ivideo.vbflags |= VB_302LV; + sishw_ext.ujVBChipID = VB_CHIP_302LV; + printk(KERN_INFO "%s SiS302LV %s\n", stdstr, bridgestr); + } break; - default: - ivideo.hasVB = HASVB_NONE; - return FALSE; } - return TRUE; -} -#endif /* CONFIG_FB_SIS_315 */ + if((!(ivideo.vbflags & VB_VIDEOBRIDGE)) && (ivideo.chip != SIS_300)) { + inSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR37, reg); + reg &= SIS_EXTERNAL_CHIP_MASK; + reg >>= 1; + if(sisvga_engine == SIS_300_VGA) { + switch (reg) { + case SIS_EXTERNAL_CHIP_LVDS: + ivideo.hasVB = HASVB_LVDS; + ivideo.vbflags |= VB_LVDS; + sishw_ext.usExternalChip = 0x01; + printk(KERN_INFO "%s %s\n", stdstr, lvdsstr); + break; + case SIS_EXTERNAL_CHIP_TRUMPION: + ivideo.hasVB = HASVB_TRUMPION; + sishw_ext.usExternalChip = 0x02; + printk(KERN_INFO "%s Trumpion LCD scaler\n", stdstr); + break; + case SIS_EXTERNAL_CHIP_CHRONTEL: + ivideo.hasVB = HASVB_CHRONTEL; + ivideo.vbflags |= VB_CHRONTEL; + sishw_ext.usExternalChip = 0x04; + printk(KERN_INFO "%s %s\n", stdstr, chrstr); + break; + case SIS_EXTERNAL_CHIP_LVDS_CHRONTEL: + ivideo.hasVB = HASVB_LVDS_CHRONTEL; + ivideo.vbflags |= (VB_LVDS | VB_CHRONTEL); + sishw_ext.usExternalChip = 0x05; + printk(KERN_INFO "%s %s and %s\n", stdstr, lvdsstr, chrstr); + break; + } + } else if(ivideo.chip < SIS_661) { + switch (reg) { + case SIS310_EXTERNAL_CHIP_LVDS: + ivideo.hasVB = HASVB_LVDS; + ivideo.vbflags |= VB_LVDS; + sishw_ext.usExternalChip = 0x01; + printk(KERN_INFO "%s %s\n", stdstr, lvdsstr); + break; + case SIS310_EXTERNAL_CHIP_LVDS_CHRONTEL: + ivideo.hasVB = HASVB_LVDS_CHRONTEL; + ivideo.vbflags |= (VB_LVDS | VB_CHRONTEL); + sishw_ext.usExternalChip = 0x05; + printk(KERN_INFO "%s %s and %s\n", stdstr, lvdsstr, chrstr); + break; + } + } + + } + + if(ivideo.vbflags & VB_SISBRIDGE) { + SiS_Sense30x(); + } else if(ivideo.vbflags & VB_CHRONTEL) { + SiS_SenseCh(); + } + +} /* ------------------ Sensing routines ------------------ */ -/* TW: Determine and detect attached devices on SiS30x */ -int +static BOOLEAN +sisfb_test_DDC1(void) +{ + unsigned short old; + int count = 48; + + old = SiS_ReadDDC1Bit(&SiS_Pr); + do { + if(old != SiS_ReadDDC1Bit(&SiS_Pr)) break; + } while(count--); + return (count == -1) ? FALSE : TRUE; +} + +static void +sisfb_sense_crt1(void) +{ + unsigned char SR1F, CR63=0, CR17; + unsigned short temp = 0xffff; + int i; + BOOLEAN mustwait = FALSE; + + inSISIDXREG(SISSR,0x1F,SR1F); + orSISIDXREG(SISSR,0x1F,0x04); + andSISIDXREG(SISSR,0x1F,0x3F); + if(SR1F & 0xc0) mustwait = TRUE; + + if(sisvga_engine == SIS_315_VGA) { + inSISIDXREG(SISCR,SiS_Pr.SiS_MyCR63,CR63); + CR63 &= 0x40; + andSISIDXREG(SISCR,SiS_Pr.SiS_MyCR63,0xBF); + } + + inSISIDXREG(SISCR,0x17,CR17); + CR17 &= 0x80; + if(!CR17) { + orSISIDXREG(SISCR,0x17,0x80); + mustwait = TRUE; + outSISIDXREG(SISSR, 0x00, 0x01); + outSISIDXREG(SISSR, 0x00, 0x03); + } + + if(mustwait) { + for(i=0; i < 10; i++) sisfbwaitretracecrt1(); + } + + i = 3; + do { + temp = SiS_HandleDDC(&SiS_Pr, ivideo.vbflags, sisvga_engine, 0, 0, NULL); + } while(((temp == 0) || (temp == 0xffff)) && i--); + + if((temp == 0) || (temp == 0xffff)) { + if(sisfb_test_DDC1()) temp = 1; + } + + if((temp) && (temp != 0xffff)) { + orSISIDXREG(SISCR,0x32,0x20); + } + + if(sisvga_engine == SIS_315_VGA) { + setSISIDXREG(SISCR,SiS_Pr.SiS_MyCR63,0xBF,CR63); + } + + setSISIDXREG(SISCR,0x17,0x7F,CR17); + + outSISIDXREG(SISSR,0x1F,SR1F); +} + +/* Determine and detect attached devices on SiS30x */ +static int SISDoSense(int tempbl, int tempbh, int tempcl, int tempch) { - int temp,i; + int temp; outSISIDXREG(SISPART4,0x11,tempbl); temp = tempbh | tempcl; setSISIDXREG(SISPART4,0x10,0xe0,temp); - for(i=0; i<10; i++) SiS_LongWait(&SiS_Pr); + SiS_DDC2Delay(&SiS_Pr, 0x1000); tempch &= 0x7f; inSISIDXREG(SISPART4,0x03,temp); temp ^= 0x0e; temp &= tempch; - return(temp); + return((temp == tempch)); } -void +static void SiS_Sense30x(void) { - u8 backupP4_0d; - u8 testsvhs_tempbl, testsvhs_tempbh; - u8 testsvhs_tempcl, testsvhs_tempch; - u8 testcvbs_tempbl, testcvbs_tempbh; - u8 testcvbs_tempcl, testcvbs_tempch; - u8 testvga2_tempbl, testvga2_tempbh; - u8 testvga2_tempcl, testvga2_tempch; - int myflag, result; + u8 backupP4_0d,backupP2_00; + u8 svhs_bl, svhs_bh; + u8 svhs_cl, svhs_ch; + u8 cvbs_bl, cvbs_bh; + u8 cvbs_cl, cvbs_ch; + u8 vga2_bl, vga2_bh; + u8 vga2_cl, vga2_ch; + int myflag, result, haveresult, i, j; + char stdstr[] = "sisfb: Detected"; + char tvstr[] = "TV connected to"; inSISIDXREG(SISPART4,0x0d,backupP4_0d); - outSISIDXREG(SISPART4,0x0d,(backupP4_0d | 0x04)); + if(!(ivideo.vbflags & (VB_301C|VB_302ELV))) { + outSISIDXREG(SISPART4,0x0d,(backupP4_0d | 0x04)); + } + + inSISIDXREG(SISPART2,0x00,backupP2_00); + outSISIDXREG(SISPART2,0x00,(backupP2_00 | 0x1c)); if(sisvga_engine == SIS_300_VGA) { - testvga2_tempbh = 0x00; testvga2_tempbl = 0xd1; - testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xb9; - testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xb3; - if((sishw_ext.ujVBChipID != VB_CHIP_301) && - (sishw_ext.ujVBChipID != VB_CHIP_302) ) { - testvga2_tempbh = 0x01; testvga2_tempbl = 0x90; - testsvhs_tempbh = 0x01; testsvhs_tempbl = 0x6b; - testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x74; + if(ivideo.vbflags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV)) { + vga2_bh = 0x01; vga2_bl = 0x90; + svhs_bh = 0x01; svhs_bl = 0x6b; + cvbs_bh = 0x01; cvbs_bl = 0x74; + } else { + vga2_bh = 0x00; vga2_bl = 0xd1; + svhs_bh = 0x00; svhs_bl = 0xb9; + cvbs_bh = 0x00; cvbs_bl = 0xb3; } inSISIDXREG(SISPART4,0x01,myflag); if(myflag & 0x04) { - testvga2_tempbh = 0x00; testvga2_tempbl = 0xfd; - testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xdd; - testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xee; - } - testvga2_tempch = 0x0e; testvga2_tempcl = 0x08; - testsvhs_tempch = 0x06; testsvhs_tempcl = 0x04; - testcvbs_tempch = 0x08; testcvbs_tempcl = 0x04; + vga2_bh = 0x00; vga2_bl = 0xfd; + svhs_bh = 0x00; svhs_bl = 0xdd; + cvbs_bh = 0x00; cvbs_bl = 0xee; + } + vga2_ch = 0x0e; vga2_cl = 0x08; + svhs_ch = 0x04; svhs_cl = 0x04; + cvbs_ch = 0x08; cvbs_cl = 0x04; + if(ivideo.vbflags & (VB_301LV|VB_302LV)) { + vga2_bh = 0x00; vga2_bl = 0x00; + vga2_ch = 0x00; vga2_cl = 0x00; + } if(ivideo.chip == SIS_300) { inSISIDXREG(SISSR,0x3b,myflag); if(!(myflag & 0x01)) { - testvga2_tempbh = 0x00; testvga2_tempbl = 0x00; - testvga2_tempch = 0x00; testvga2_tempcl = 0x00; + vga2_bh = 0x00; vga2_bl = 0x00; + vga2_ch = 0x00; vga2_cl = 0x00; } } } else { - testvga2_tempbh = 0x00; testvga2_tempbl = 0xd1; - testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xb9; - testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xb3; - if((sishw_ext.ujVBChipID != VB_CHIP_301) && - (sishw_ext.ujVBChipID != VB_CHIP_302)) { - testvga2_tempbh = 0x01; testvga2_tempbl = 0x90; - testsvhs_tempbh = 0x01; testsvhs_tempbl = 0x6b; - testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x74; - if(sishw_ext.ujVBChipID == VB_CHIP_301LV || - sishw_ext.ujVBChipID == VB_CHIP_302LV) { - testvga2_tempbh = 0x00; testvga2_tempbl = 0x00; - testsvhs_tempbh = 0x02; testsvhs_tempbl = 0x00; - testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x00; - } - } - if(sishw_ext.ujVBChipID != VB_CHIP_301LV && - sishw_ext.ujVBChipID != VB_CHIP_302LV) { - inSISIDXREG(SISPART4,0x01,myflag); - if(myflag & 0x04) { - testvga2_tempbh = 0x00; testvga2_tempbl = 0xfd; - testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xdd; - testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xee; - } + if(ivideo.vbflags & (VB_301B|VB_302B)) { + vga2_bh = 0x01; vga2_bl = 0x90; + svhs_bh = 0x01; svhs_bl = 0x6b; + cvbs_bh = 0x01; cvbs_bl = 0x74; + } else if(ivideo.vbflags & (VB_301C|VB_302ELV)) { + vga2_bh = 0x01; vga2_bl = 0x90; + svhs_bh = 0x01; svhs_bl = 0x6b; + cvbs_bh = 0x01; cvbs_bl = 0x10; + } else if(ivideo.vbflags & (VB_301LV|VB_302LV)) { + vga2_bh = 0x00; vga2_bl = 0x00; + svhs_bh = 0x02; svhs_bl = 0x00; + cvbs_bh = 0x01; cvbs_bl = 0x00; + } else { + vga2_bh = 0x00; vga2_bl = 0xd1; + svhs_bh = 0x00; svhs_bl = 0xb9; + cvbs_bh = 0x00; cvbs_bl = 0xb3; + inSISIDXREG(SISPART4,0x01,myflag); + if(myflag & 0x04) { + vga2_bh = 0x00; vga2_bl = 0xfd; + svhs_bh = 0x00; svhs_bl = 0xdd; + cvbs_bh = 0x00; cvbs_bl = 0xee; + } } - if((sishw_ext.ujVBChipID == VB_CHIP_301LV) || - (sishw_ext.ujVBChipID == VB_CHIP_302LV) ) { - testvga2_tempbh = 0x00; testvga2_tempbl = 0x00; - testvga2_tempch = 0x00; testvga2_tempcl = 0x00; - testsvhs_tempch = 0x04; testsvhs_tempcl = 0x08; - testcvbs_tempch = 0x08; testcvbs_tempcl = 0x08; + + if(ivideo.vbflags & (VB_301LV|VB_302LV|VB_302ELV)) { + vga2_bh = 0x00; vga2_bl = 0x00; + vga2_ch = 0x00; vga2_cl = 0x00; + svhs_ch = 0x04; svhs_cl = 0x08; + cvbs_ch = 0x08; cvbs_cl = 0x08; } else { - testvga2_tempch = 0x0e; testvga2_tempcl = 0x08; - testsvhs_tempch = 0x06; testsvhs_tempcl = 0x04; - testcvbs_tempch = 0x08; testcvbs_tempcl = 0x04; + vga2_ch = 0x0e; vga2_cl = 0x08; + svhs_ch = 0x04; svhs_cl = 0x04; + cvbs_ch = 0x08; cvbs_cl = 0x04; } } - if(testvga2_tempch || testvga2_tempcl || testvga2_tempbh || testvga2_tempbl) { - result = SISDoSense(testvga2_tempbl, testvga2_tempbh, - testvga2_tempcl, testvga2_tempch); - if(result) { - printk(KERN_INFO "sisfb: Detected secondary VGA connection\n"); - orSISIDXREG(SISCR, 0x32, 0x10); - } + if(vga2_ch || vga2_cl || vga2_bh || vga2_bl) { + haveresult = 0; + for(j = 0; j < 10; j++) { + result = 0; + for(i = 0; i < 3; i++) { + if(SISDoSense(vga2_bl, vga2_bh, vga2_cl, vga2_ch)) + result++; + } + if((result == 0) || (result >= 2)) break; + } + if(result) { + printk(KERN_INFO "%s secondary VGA connection\n", stdstr); + orSISIDXREG(SISCR, 0x32, 0x10); + } else { + andSISIDXREG(SISCR, 0x32, ~0x10); + } + } + + if(ivideo.vbflags & (VB_301C|VB_302ELV)) { + orSISIDXREG(SISPART4,0x0d,0x04); + } + + haveresult = 0; + for(j = 0; j < 10; j++) { + result = 0; + for(i = 0; i < 3; i++) { + if(SISDoSense(svhs_bl, svhs_bh, svhs_cl, svhs_ch)) + result++; + } + if((result == 0) || (result >= 2)) break; } - - result = SISDoSense(testsvhs_tempbl, testsvhs_tempbh, - testsvhs_tempcl, testsvhs_tempch); if(result) { - printk(KERN_INFO "sisfb: Detected TV connected to SVHS output\n"); - /* TW: So we can be sure that there IS a SVHS output */ - ivideo.TV_plug = TVPLUG_SVIDEO; + printk(KERN_INFO "%s %s SVIDEO output\n", stdstr, tvstr); + ivideo.vbflags |= TV_SVIDEO; orSISIDXREG(SISCR, 0x32, 0x02); + andSISIDXREG(SISCR, 0x32, ~0x05); } if(!result) { - result = SISDoSense(testcvbs_tempbl, testcvbs_tempbh, - testcvbs_tempcl, testcvbs_tempch); + + haveresult = 0; + for(j = 0; j < 10; j++) { + result = 0; + for(i = 0; i < 3; i++) { + if(SISDoSense(cvbs_bl, cvbs_bh, cvbs_cl, cvbs_ch)) + result++; + } + if((result == 0) || (result >= 2)) break; + } if(result) { - printk(KERN_INFO "sisfb: Detected TV connected to CVBS output\n"); - /* TW: So we can be sure that there IS a CVBS output */ - ivideo.TV_plug = TVPLUG_COMPOSITE; + printk(KERN_INFO "%s %s COMPOSITE output\n", stdstr, tvstr); + ivideo.vbflags |= TV_AVIDEO; orSISIDXREG(SISCR, 0x32, 0x01); + andSISIDXREG(SISCR, 0x32, ~0x06); + } else { + andSISIDXREG(SISCR, 0x32, ~0x07); } } SISDoSense(0, 0, 0, 0); + outSISIDXREG(SISPART2,0x00,backupP2_00); outSISIDXREG(SISPART4,0x0d,backupP4_0d); } -/* TW: Determine and detect attached TV's on Chrontel */ -void +/* Determine and detect attached TV's on Chrontel */ +static void SiS_SenseCh(void) { - u8 temp1; -#ifdef CONFIG_FB_SIS_315 - u8 temp2; + u8 temp1, temp2; +#ifdef CONFIG_FB_SIS_300 + unsigned char test[3]; + int i; #endif + char stdstr[] = "sisfb: Chrontel: Detected TV connected to"; if(ivideo.chip < SIS_315H) { #ifdef CONFIG_FB_SIS_300 - SiS_Pr.SiS_IF_DEF_CH70xx = 1; /* TW: Chrontel 7005 */ + SiS_Pr.SiS_IF_DEF_CH70xx = 1; /* Chrontel 700x */ + SiS_SetChrontelGPIO(&SiS_Pr, 0x9c); /* Set general purpose IO for Chrontel communication */ + SiS_DDC2Delay(&SiS_Pr, 1000); temp1 = SiS_GetCH700x(&SiS_Pr, 0x25); - if ((temp1 >= 50) && (temp1 <= 100)) { - /* TW: Read power status */ + /* See Chrontel TB31 for explanation */ + temp2 = SiS_GetCH700x(&SiS_Pr, 0x0e); + if(((temp2 & 0x07) == 0x01) || (temp2 & 0x04)) { + SiS_SetCH700x(&SiS_Pr, 0x0b0e); + SiS_DDC2Delay(&SiS_Pr, 300); + } + temp2 = SiS_GetCH700x(&SiS_Pr, 0x25); + if(temp2 != temp1) temp1 = temp2; + + if((temp1 >= 0x22) && (temp1 <= 0x50)) { + /* Read power status */ temp1 = SiS_GetCH700x(&SiS_Pr, 0x0e); if((temp1 & 0x03) != 0x03) { - /* TW: Power all outputs */ - SiS_SetCH70xxANDOR(&SiS_Pr, 0x030E,0xF8); + /* Power all outputs */ + SiS_SetCH700x(&SiS_Pr, 0x0B0E); + SiS_DDC2Delay(&SiS_Pr, 300); } - /* TW: Sense connected TV devices */ - SiS_SetCH700x(&SiS_Pr, 0x0110); - SiS_SetCH700x(&SiS_Pr, 0x0010); - temp1 = SiS_GetCH700x(&SiS_Pr, 0x10); - if(!(temp1 & 0x08)) { - printk(KERN_INFO - "sisfb: Chrontel: Detected TV connected to SVHS output\n"); - /* TW: So we can be sure that there IS a SVHS output */ - ivideo.TV_plug = TVPLUG_SVIDEO; + /* Sense connected TV devices */ + for(i = 0; i < 3; i++) { + SiS_SetCH700x(&SiS_Pr, 0x0110); + SiS_DDC2Delay(&SiS_Pr, 0x96); + SiS_SetCH700x(&SiS_Pr, 0x0010); + SiS_DDC2Delay(&SiS_Pr, 0x96); + temp1 = SiS_GetCH700x(&SiS_Pr, 0x10); + if(!(temp1 & 0x08)) test[i] = 0x02; + else if(!(temp1 & 0x02)) test[i] = 0x01; + else test[i] = 0; + SiS_DDC2Delay(&SiS_Pr, 0x96); + } + + if(test[0] == test[1]) temp1 = test[0]; + else if(test[0] == test[2]) temp1 = test[0]; + else if(test[1] == test[2]) temp1 = test[1]; + else { + printk(KERN_INFO + "sisfb: TV detection unreliable - test results varied\n"); + temp1 = test[2]; + } + if(temp1 == 0x02) { + printk(KERN_INFO "%s SVIDEO output\n", stdstr); + ivideo.vbflags |= TV_SVIDEO; orSISIDXREG(SISCR, 0x32, 0x02); - } else if (!(temp1 & 0x02)) { - printk(KERN_INFO - "sisfb: Chrontel: Detected TV connected to CVBS output\n"); - /* TW: So we can be sure that there IS a CVBS output */ - ivideo.TV_plug = TVPLUG_COMPOSITE; + andSISIDXREG(SISCR, 0x32, ~0x05); + } else if (temp1 == 0x01) { + printk(KERN_INFO "%s CVBS output\n", stdstr); + ivideo.vbflags |= TV_AVIDEO; orSISIDXREG(SISCR, 0x32, 0x01); + andSISIDXREG(SISCR, 0x32, ~0x06); } else { SiS_SetCH70xxANDOR(&SiS_Pr, 0x010E,0xF8); + andSISIDXREG(SISCR, 0x32, ~0x07); } } else if(temp1 == 0) { SiS_SetCH70xxANDOR(&SiS_Pr, 0x010E,0xF8); + andSISIDXREG(SISCR, 0x32, ~0x07); } + /* Set general purpose IO for Chrontel communication */ + SiS_SetChrontelGPIO(&SiS_Pr, 0x00); #endif } else { #ifdef CONFIG_FB_SIS_315 - SiS_Pr.SiS_IF_DEF_CH70xx = 2; /* TW: Chrontel 7019 */ + SiS_Pr.SiS_IF_DEF_CH70xx = 2; /* Chrontel 7019 */ temp1 = SiS_GetCH701x(&SiS_Pr, 0x49); SiS_SetCH701x(&SiS_Pr, 0x2049); SiS_DDC2Delay(&SiS_Pr, 0x96); @@ -2808,22 +3122,24 @@ SiS_SenseCh(void) if( (temp1 & 0x01) && (temp1 & 0x02) ) temp1 = 0x04; switch(temp1) { case 0x01: - printk(KERN_INFO - "sisfb: Chrontel: Detected TV connected to CVBS output\n"); - ivideo.TV_plug = TVPLUG_COMPOSITE; + printk(KERN_INFO "%s CVBS output\n", stdstr); + ivideo.vbflags |= TV_AVIDEO; orSISIDXREG(SISCR, 0x32, 0x01); + andSISIDXREG(SISCR, 0x32, ~0x06); break; case 0x02: - printk(KERN_INFO - "sisfb: Chrontel: Detected TV connected to SVHS output\n"); - ivideo.TV_plug = TVPLUG_SVIDEO; + printk(KERN_INFO "%s SVIDEO output\n", stdstr); + ivideo.vbflags |= TV_SVIDEO; orSISIDXREG(SISCR, 0x32, 0x02); + andSISIDXREG(SISCR, 0x32, ~0x05); break; case 0x04: - /* TW: This should not happen */ - printk(KERN_INFO - "sisfb: Chrontel: Detected TV connected to SCART output\n"); + printk(KERN_INFO "%s SCART output\n", stdstr); + orSISIDXREG(SISCR, 0x32, 0x04); + andSISIDXREG(SISCR, 0x32, ~0x03); break; + default: + andSISIDXREG(SISCR, 0x32, ~0x07); } #endif @@ -2845,12 +3161,17 @@ static int sisfb_heap_init(void) unsigned long *write_port = 0; SIS_CMDTYPE cmd_type; #ifndef AGPOFF +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) struct agp_kern_info *agp_info; struct agp_memory *agp; +#else + agp_kern_info *agp_info; + agp_memory *agp; +#endif u32 agp_phys; #endif #endif -/* TW: The heap start is either set manually using the "mem" parameter, or +/* The heap start is either set manually using the "mem" parameter, or * defaults as follows: * -) If more than 16MB videoRAM available, let our heap start at 12MB. * -) If more than 8MB videoRAM available, let our heap start at 8MB. @@ -2860,20 +3181,26 @@ static int sisfb_heap_init(void) * in XF86Config-4. * The heap start can also be specified by parameter "mem" when starting the sisfb * driver. sisfb mem=1024 lets heap starts at 1MB, etc. + * + * On the 315 and Xabre series, the default is a 1MB heap since DRI is not + * supported there. */ if ((!sisfb_mem) || (sisfb_mem > (ivideo.video_size/1024))) { - if (ivideo.video_size > 0x1000000) { + if(sisvga_engine == SIS_300_VGA) { + if (ivideo.video_size > 0x1000000) { ivideo.heapstart = 0xc00000; - } else if (ivideo.video_size > 0x800000) { + } else if (ivideo.video_size > 0x800000) { ivideo.heapstart = 0x800000; - } else { + } else { ivideo.heapstart = 0x400000; + } + } else { + ivideo.heapstart = ivideo.video_size - 0x100000; } } else { ivideo.heapstart = sisfb_mem * 1024; } - sisfb_heap_start = - (unsigned long) (ivideo.video_vbase + ivideo.heapstart); + sisfb_heap_start = (unsigned long) (ivideo.video_vbase + ivideo.heapstart); printk(KERN_INFO "sisfb: Memory heap starting at %dK\n", (int)(ivideo.heapstart / 1024)); @@ -2882,8 +3209,8 @@ static int sisfb_heap_init(void) #ifdef CONFIG_FB_SIS_315 if (sisvga_engine == SIS_315_VGA) { - /* TW: Now initialize the 310 series' command queue mode. - * On 310/325, there are three queue modes available which + /* Now initialize the 315/330 series' command queue mode. + * On 315, there are three queue modes available which * are chosen by setting bits 7:5 in SR26: * 1. MMIO queue mode (bit 5, 0x20). The hardware will keep * track of the queue, the FIFO, command parsing and so @@ -2923,8 +3250,13 @@ static int sisfb_heap_init(void) #ifndef AGPOFF if (sisfb_queuemode == AGP_CMD_QUEUE) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) agp_info = vmalloc(sizeof(*agp_info)); memset((void*)agp_info, 0x00, sizeof(*agp_info)); +#else + agp_info = vmalloc(sizeof(agp_kern_info)); + memset((void*)agp_info, 0x00, sizeof(agp_kern_info)); +#endif agp_copy_info(agp_info); agp_backend_acquire(); @@ -2948,7 +3280,7 @@ static int sisfb_heap_init(void) agp_enabled = 0; #endif - /* TW: Now select the queue mode */ + /* Now select the queue mode */ if ((agp_enabled) && (sisfb_queuemode == AGP_CMD_QUEUE)) { cmd_type = AGP_CMD_QUEUE; @@ -3025,10 +3357,6 @@ static int sisfb_heap_init(void) break; default: /* MMIO */ - /* TW: This previously only wrote SIS_MMIO_CMD_ENABLE - * to IND_SIS_CMDQUEUE_SET. I doubt that this is - * enough. Reserve memory in any way. - */ sisfb_heap_end -= COMMAND_QUEUE_AREA_SIZE; sisfb_heap_size -= COMMAND_QUEUE_AREA_SIZE; @@ -3037,7 +3365,7 @@ static int sisfb_heap_init(void) *write_port = *read_port; - /* TW: Set Auto_Correction bit */ + /* Set Auto_Correction bit */ temp |= (SIS_MMIO_CMD_ENABLE | SIS_CMD_AUTO_CORR); outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_SET, temp); @@ -3054,7 +3382,7 @@ static int sisfb_heap_init(void) #ifdef CONFIG_FB_SIS_300 if (sisvga_engine == SIS_300_VGA) { - /* TW: Now initialize TurboQueue. TB is always located at the very + /* Now initialize TurboQueue. TB is always located at the very * top of the video RAM. */ if (sisfb_heap_size >= TURBO_QUEUE_AREA_SIZE) { unsigned int tqueue_pos; @@ -3082,8 +3410,8 @@ static int sisfb_heap_init(void) } } #endif - /* TW: Now reserve memory for the HWCursor. It is always located at the very - top of the videoRAM, right below the TB memory area (if used). */ + /* Now reserve memory for the HWCursor. It is always located at the very + top of the videoRAM, right below the TB memory area (if used). */ if (sisfb_heap_size >= sisfb_hwcursor_size) { sisfb_heap_end -= sisfb_hwcursor_size; sisfb_heap_size -= sisfb_hwcursor_size; @@ -3333,7 +3661,6 @@ void sis_malloc(struct sis_memreq *req) req->offset = poh->offset; req->size = poh->size; } - } void sis_free(unsigned long base) @@ -3352,45 +3679,91 @@ void sis_free(unsigned long base) static void sisfb_pre_setmode(void) { - u8 cr30 = 0, cr31 = 0; + u8 cr30 = 0, cr31 = 0, cr33 = 0, cr35 = 0; + + ivideo.currentvbflags &= (VB_VIDEOBRIDGE | VB_DISPTYPE_DISP2); inSISIDXREG(SISCR, 0x31, cr31); cr31 &= ~0x60; + cr31 |= 0x04; - switch (ivideo.disp_state & DISPTYPE_DISP2) { - case DISPTYPE_CRT2: - cr30 = (SIS_VB_OUTPUT_CRT2 | SIS_SIMULTANEOUS_VIEW_ENABLE); + cr33 = sisfb_rate_idx & 0x0F; + + SiS_SetEnableDstn(&SiS_Pr, FALSE); + SiS_SetEnableFstn(&SiS_Pr, FALSE); + + switch (ivideo.currentvbflags & VB_DISPTYPE_DISP2) { + case CRT2_TV: + ivideo.disp_state = DISPTYPE_TV; + if (ivideo.vbflags & TV_SVIDEO) { + cr30 = (SIS_VB_OUTPUT_SVIDEO | SIS_SIMULTANEOUS_VIEW_ENABLE); + ivideo.currentvbflags |= TV_SVIDEO; + ivideo.TV_plug = TVPLUG_SVIDEO; + } else if (ivideo.vbflags & TV_AVIDEO) { + cr30 = (SIS_VB_OUTPUT_COMPOSITE | SIS_SIMULTANEOUS_VIEW_ENABLE); + ivideo.currentvbflags |= TV_AVIDEO; + ivideo.TV_plug = TVPLUG_COMPOSITE; + } else if (ivideo.vbflags & TV_SCART) { + cr30 = (SIS_VB_OUTPUT_SCART | SIS_SIMULTANEOUS_VIEW_ENABLE); + ivideo.currentvbflags |= TV_SCART; + ivideo.TV_plug = TVPLUG_SCART; + } cr31 |= SIS_DRIVER_MODE; + + if(!(ivideo.vbflags & TV_HIVISION)) { + if (ivideo.vbflags & TV_PAL) { + cr31 |= 0x01; + cr35 |= 0x01; + ivideo.currentvbflags |= TV_PAL; + ivideo.TV_type = TVMODE_PAL; + } else { + cr31 &= ~0x01; + cr35 &= ~0x01; + ivideo.currentvbflags |= TV_NTSC; + ivideo.TV_type = TVMODE_NTSC; + } + } break; - case DISPTYPE_LCD: + case CRT2_LCD: + ivideo.disp_state = DISPTYPE_LCD; cr30 = (SIS_VB_OUTPUT_LCD | SIS_SIMULTANEOUS_VIEW_ENABLE); cr31 |= SIS_DRIVER_MODE; + SiS_SetEnableDstn(&SiS_Pr, sisfb_dstn); + SiS_SetEnableFstn(&SiS_Pr, sisfb_fstn); break; - case DISPTYPE_TV: - if (ivideo.TV_type == TVMODE_HIVISION) - cr30 = (SIS_VB_OUTPUT_HIVISION | SIS_SIMULTANEOUS_VIEW_ENABLE); - else if (ivideo.TV_plug == TVPLUG_SVIDEO) - cr30 = (SIS_VB_OUTPUT_SVIDEO | SIS_SIMULTANEOUS_VIEW_ENABLE); - else if (ivideo.TV_plug == TVPLUG_COMPOSITE) - cr30 = (SIS_VB_OUTPUT_COMPOSITE | SIS_SIMULTANEOUS_VIEW_ENABLE); - else if (ivideo.TV_plug == TVPLUG_SCART) - cr30 = (SIS_VB_OUTPUT_SCART | SIS_SIMULTANEOUS_VIEW_ENABLE); + case CRT2_VGA: + ivideo.disp_state = DISPTYPE_CRT2; + cr30 = (SIS_VB_OUTPUT_CRT2 | SIS_SIMULTANEOUS_VIEW_ENABLE); cr31 |= SIS_DRIVER_MODE; - - if (sisfb_tvmode == 1 || ivideo.TV_type == TVMODE_PAL) - cr31 |= 0x01; - else - cr31 &= ~0x01; + if(sisfb_nocrt2rate) { + cr33 |= (sisbios_mode[sisfb_mode_idx].rate_idx << 4); + } else { + cr33 |= ((sisfb_rate_idx & 0x0F) << 4); + } break; default: /* disable CRT2 */ cr30 = 0x00; cr31 |= (SIS_DRIVER_MODE | SIS_VB_OUTPUT_DISABLE); } + if(ivideo.chip >= SIS_661) { + cr31 &= ~0x01; + /* Leave overscan bit alone */ + setSISIDXREG(SISCR, 0x35, ~0x10, cr35); + } outSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR30, cr30); outSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR31, cr31); + outSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR33, cr33); - outSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR33, (sisfb_rate_idx & 0x0F)); +#ifdef CONFIG_FB_SIS_315 + if(sisvga_engine == SIS_315_VGA) { + /* Clear LCDA and PAL-N/M bits */ + andSISIDXREG(SISCR,0x38,~0x03); + if(ivideo.chip < SIS_661) { + andSISIDXREG(SISCR,0x38,~0xc0); + } + } +#endif if(ivideo.accel) sisfb_syncaccel(); @@ -3400,67 +3773,90 @@ static void sisfb_pre_setmode(void) static void sisfb_post_setmode(void) { u8 reg; + BOOLEAN crt1isoff = FALSE; +#ifdef CONFIG_FB_SIS_315 + u8 reg1; +#endif +#ifdef CONFIG_FB_SIS_300 BOOLEAN doit = TRUE; -#if 0 /* TW: Wrong: Is not in MMIO space, but in RAM */ - /* Backup mode number to MMIO space */ - if(ivideo.mmio_vbase) { - *(volatile u8 *)(((u8*)ivideo.mmio_vbase) + 0x449) = (unsigned char)sisfb_mode_no; - } -#endif - - if (ivideo.video_bpp == 8) { - /* TW: We can't switch off CRT1 on LVDS/Chrontel in 8bpp Modes */ - if ((ivideo.hasVB == HASVB_LVDS) || (ivideo.hasVB == HASVB_LVDS_CHRONTEL)) { - doit = FALSE; - } - /* TW: We can't switch off CRT1 on 301B-DH in 8bpp Modes if using LCD */ - if ( (sishw_ext.Is301BDH) && (ivideo.disp_state & DISPTYPE_LCD) ) { - doit = FALSE; - } - } - - /* TW: We can't switch off CRT1 if bridge is in slave mode */ - if(ivideo.hasVB != HASVB_NONE) { - inSISIDXREG(SISPART1, 0x00, reg); +#endif + /* We can't switch off CRT1 if bridge is in slave mode */ + if(ivideo.vbflags & VB_VIDEOBRIDGE) { +#ifdef CONFIG_FB_SIS_300 if(sisvga_engine == SIS_300_VGA) { + inSISIDXREG(SISPART1, 0x00, reg); if((reg & 0xa0) == 0x20) { doit = FALSE; } } - if(sisvga_engine == SIS_315_VGA) { - if((reg & 0x50) == 0x10) { - doit = FALSE; - } - } +#endif } else sisfb_crt1off = 0; - inSISIDXREG(SISCR, 0x17, reg); - if((sisfb_crt1off) && (doit)) - reg &= ~0x80; - else - reg |= 0x80; - outSISIDXREG(SISCR, 0x17, reg); + if(sisvga_engine == SIS_300_VGA) { + +#ifdef CONFIG_FB_SIS_300 + if((sisfb_crt1off) && (doit)) { + crt1isoff = TRUE; + reg = 0x00; + } else { + crt1isoff = FALSE; + reg = 0x80; + } + setSISIDXREG(SISCR, 0x17, 0x7f, reg); +#endif + + } else { + +#ifdef CONFIG_FB_SIS_315 + if(sisfb_crt1off) { + crt1isoff = TRUE; + reg = 0x40; + reg1 = 0xc0; + } else { + crt1isoff = FALSE; + reg = 0x00; + reg1 = 0x00; - andSISIDXREG(SISSR, IND_SIS_RAMDAC_CONTROL, ~0x04); + } + setSISIDXREG(SISCR, SiS_Pr.SiS_MyCR63, ~0x40, reg); + setSISIDXREG(SISSR, 0x1f, ~0xc0, reg1); +#endif + + } - if((ivideo.disp_state & DISPTYPE_TV) && (ivideo.hasVB == HASVB_301)) { + if(crt1isoff) { + ivideo.currentvbflags &= ~VB_DISPTYPE_CRT1; + ivideo.currentvbflags |= VB_SINGLE_MODE; + ivideo.disp_state |= DISPMODE_SINGLE; + } else { + ivideo.currentvbflags |= VB_DISPTYPE_CRT1; + ivideo.disp_state |= DISPTYPE_CRT1; + if(ivideo.currentvbflags & VB_DISPTYPE_CRT2) { + ivideo.currentvbflags |= VB_MIRROR_MODE; + ivideo.disp_state |= DISPMODE_MIRROR; + } else { + ivideo.currentvbflags |= VB_SINGLE_MODE; + ivideo.disp_state |= DISPMODE_SINGLE; + } + } - inSISIDXREG(SISPART4, 0x01, reg); + andSISIDXREG(SISSR, IND_SIS_RAMDAC_CONTROL, ~0x04); - if(reg < 0xB0) { /* Set filter for SiS301 */ + if((ivideo.currentvbflags & CRT2_TV) && (ivideo.vbflags & VB_301)) { /* Set filter for SiS301 */ switch (ivideo.video_width) { case 320: - filter_tb = (ivideo.TV_type == TVMODE_NTSC) ? 4 : 12; + filter_tb = (ivideo.vbflags & TV_NTSC) ? 4 : 12; break; case 640: - filter_tb = (ivideo.TV_type == TVMODE_NTSC) ? 5 : 13; + filter_tb = (ivideo.vbflags & TV_NTSC) ? 5 : 13; break; case 720: - filter_tb = (ivideo.TV_type == TVMODE_NTSC) ? 6 : 14; + filter_tb = (ivideo.vbflags & TV_NTSC) ? 6 : 14; break; + case 400: case 800: - filter_tb = (ivideo.TV_type == TVMODE_NTSC) ? 7 : 15; + filter_tb = (ivideo.vbflags & TV_NTSC) ? 7 : 15; break; default: filter = -1; @@ -3469,15 +3865,15 @@ static void sisfb_post_setmode(void) orSISIDXREG(SISPART1, sisfb_CRT2_write_enable, 0x01); - if(ivideo.TV_type == TVMODE_NTSC) { + if(ivideo.vbflags & TV_NTSC) { andSISIDXREG(SISPART2, 0x3a, 0x1f); - if (ivideo.TV_plug == TVPLUG_SVIDEO) { + if (ivideo.vbflags & TV_SVIDEO) { andSISIDXREG(SISPART2, 0x30, 0xdf); - } else if (ivideo.TV_plug == TVPLUG_COMPOSITE) { + } else if (ivideo.vbflags & TV_AVIDEO) { orSISIDXREG(SISPART2, 0x30, 0x20); @@ -3494,6 +3890,7 @@ static void sisfb_post_setmode(void) outSISIDXREG(SISPART2, 0x37, 0x22); outSISIDXREG(SISPART2, 0x38, 0x08); break; + case 400: case 800: outSISIDXREG(SISPART2, 0x35, 0xEB); outSISIDXREG(SISPART2, 0x36, 0x15); @@ -3503,15 +3900,15 @@ static void sisfb_post_setmode(void) } } - } else if(ivideo.TV_type == TVMODE_PAL) { + } else if(ivideo.vbflags & TV_PAL) { andSISIDXREG(SISPART2, 0x3A, 0x1F); - if (ivideo.TV_plug == TVPLUG_SVIDEO) { + if (ivideo.vbflags & TV_SVIDEO) { andSISIDXREG(SISPART2, 0x30, 0xDF); - } else if (ivideo.TV_plug == TVPLUG_COMPOSITE) { + } else if (ivideo.vbflags & TV_AVIDEO) { orSISIDXREG(SISPART2, 0x30, 0x20); @@ -3528,6 +3925,7 @@ static void sisfb_post_setmode(void) outSISIDXREG(SISPART2, 0x37, 0x1D); outSISIDXREG(SISPART2, 0x38, 0x20); break; + case 400: case 800: outSISIDXREG(SISPART2, 0x35, 0xFC); outSISIDXREG(SISPART2, 0x36, 0xFB); @@ -3538,8 +3936,8 @@ static void sisfb_post_setmode(void) } } - if ((filter >= 0) && (filter <=7)) { - DPRINTK("FilterTable[%d]-%d: %02x %02x %02x %02x\n", filter_tb, filter, + if ((filter >= 0) && (filter <= 7)) { + DPRINTK("FilterTable[%d]-%d: %02x %02x %02x %02x\n", filter_tb, filter, sis_TV_filter[filter_tb].filter[filter][0], sis_TV_filter[filter_tb].filter[filter][1], sis_TV_filter[filter_tb].filter[filter][2], @@ -3550,8 +3948,6 @@ static void sisfb_post_setmode(void) outSISIDXREG(SISPART2, 0x37, (sis_TV_filter[filter_tb].filter[filter][2])); outSISIDXREG(SISPART2, 0x38, (sis_TV_filter[filter_tb].filter[filter][3])); } - - } } @@ -3563,12 +3959,15 @@ int sisfb_setup(char *options) char *this_opt; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - sis_fb_info.fontname[0] = '\0'; -#endif + sisfb_fontname[0] = '\0'; +#endif ivideo.refresh_rate = 0; + SiS_Pr.SiS_CustomT = CUT_NONE; + SiS_Pr.UsePanelScaler = -1; + SiS_Pr.LVDSHL = -1; - printk(KERN_INFO "sisfb: Options %s\n", options); + printk(KERN_DEBUG "sisfb: Options %s\n", options); if (!options || !*options) return 0; @@ -3577,72 +3976,80 @@ int sisfb_setup(char *options) if (!*this_opt) continue; - if (!strncmp(this_opt, "mode:", 5)) { - sisfb_search_mode(this_opt + 5); - } else if (!strncmp(this_opt, "vesa:", 5)) { - sisfb_search_vesamode(simple_strtoul(this_opt + 5, NULL, 0)); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - } else if (!strcmp(this_opt, "inverse")) { + if (!strnicmp(this_opt, "mode:", 5)) { + sisfb_search_mode(this_opt + 5, FALSE); + } else if (!strnicmp(this_opt, "vesa:", 5)) { + sisfb_search_vesamode(simple_strtoul(this_opt + 5, NULL, 0), FALSE); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) + } else if (!strnicmp(this_opt, "inverse", 7)) { sisfb_inverse = 1; /* fb_invert_cmaps(); */ - } else if (!strncmp(this_opt, "font:", 5)) { - strcpy(sis_fb_info.fontname, this_opt + 5); -#endif - } else if (!strncmp(this_opt, "mode:", 5)) { - sisfb_search_mode(this_opt + 5); - } else if (!strncmp(this_opt, "vesa:", 5)) { - sisfb_search_vesamode(simple_strtoul(this_opt + 5, NULL, 0)); - } else if (!strncmp(this_opt, "vrate:", 6)) { + } else if (!strnicmp(this_opt, "font:", 5)) { + strncpy(sisfb_fontname, this_opt + 5, sizeof(sisfb_fontname) - 1); + sisfb_fontname[sizeof(sisfb_fontname) - 1] = '\0'; +#endif + } else if (!strnicmp(this_opt, "vrate:", 6)) { ivideo.refresh_rate = simple_strtoul(this_opt + 6, NULL, 0); - } else if (!strncmp(this_opt, "rate:", 5)) { + sisfb_parm_rate = ivideo.refresh_rate; + } else if (!strnicmp(this_opt, "rate:", 5)) { ivideo.refresh_rate = simple_strtoul(this_opt + 5, NULL, 0); - } else if (!strncmp(this_opt, "off", 3)) { + sisfb_parm_rate = ivideo.refresh_rate; + } else if (!strnicmp(this_opt, "off", 3)) { sisfb_off = 1; - } else if (!strncmp(this_opt, "crt1off", 7)) { + } else if (!strnicmp(this_opt, "crt1off", 7)) { sisfb_crt1off = 1; - } else if (!strncmp(this_opt, "filter:", 7)) { + } else if (!strnicmp(this_opt, "filter:", 7)) { filter = (int)simple_strtoul(this_opt + 7, NULL, 0); - } else if (!strncmp(this_opt, "forcecrt2type:", 14)) { + } else if (!strnicmp(this_opt, "forcecrt2type:", 14)) { sisfb_search_crt2type(this_opt + 14); - } else if (!strncmp(this_opt, "forcecrt1:", 10)) { + } else if (!strnicmp(this_opt, "forcecrt1:", 10)) { sisfb_forcecrt1 = (int)simple_strtoul(this_opt + 10, NULL, 0); - } else if (!strncmp(this_opt, "tvmode:",7)) { + } else if (!strnicmp(this_opt, "tvmode:",7)) { sisfb_search_tvstd(this_opt + 7); - } else if (!strncmp(this_opt, "tvstandard:",11)) { + } else if (!strnicmp(this_opt, "tvstandard:",11)) { sisfb_search_tvstd(this_opt + 7); - } else if (!strncmp(this_opt, "mem:",4)) { + } else if (!strnicmp(this_opt, "mem:",4)) { sisfb_mem = simple_strtoul(this_opt + 4, NULL, 0); - } else if (!strncmp(this_opt, "dstn", 4)) { - enable_dstn = 1; - /* TW: DSTN overrules forcecrt2type */ - sisfb_crt2type = DISPTYPE_LCD; - } else if (!strncmp(this_opt, "queuemode:", 10)) { + } else if (!strnicmp(this_opt, "queuemode:", 10)) { sisfb_search_queuemode(this_opt + 10); - } else if (!strncmp(this_opt, "pdc:", 4)) { + } else if (!strnicmp(this_opt, "pdc:", 4)) { sisfb_pdc = simple_strtoul(this_opt + 4, NULL, 0); - if(sisfb_pdc & ~0x3c) { - printk(KERN_INFO "sisfb: Illegal pdc parameter\n"); - sisfb_pdc = 0; - } - } else if (!strncmp(this_opt, "noaccel", 7)) { + } else if (!strnicmp(this_opt, "noaccel", 7)) { sisfb_accel = 0; - } else if (!strncmp(this_opt, "noypan", 6)) { + } else if (!strnicmp(this_opt, "noypan", 6)) { sisfb_ypan = 0; - } else if (!strncmp(this_opt, "userom:", 7)) { + } else if (!strnicmp(this_opt, "nomax", 5)) { + sisfb_max = 0; + } else if (!strnicmp(this_opt, "userom:", 7)) { sisfb_userom = (int)simple_strtoul(this_opt + 7, NULL, 0); - } else if (!strncmp(this_opt, "useoem:", 7)) { + } else if (!strnicmp(this_opt, "useoem:", 7)) { sisfb_useoem = (int)simple_strtoul(this_opt + 7, NULL, 0); + } else if (!strnicmp(this_opt, "nocrt2rate", 10)) { + sisfb_nocrt2rate = 1; + } else if (!strnicmp(this_opt, "scalelcd:", 9)) { + unsigned long temp = 2; + temp = simple_strtoul(this_opt + 9, NULL, 0); + if((temp == 0) || (temp == 1)) { + SiS_Pr.UsePanelScaler = temp ^ 1; + } + } else if (!strnicmp(this_opt, "specialtiming:", 14)) { + sisfb_search_specialtiming(this_opt + 14); + } else if (!strnicmp(this_opt, "lvdshl:", 7)) { + unsigned long temp = 4; + temp = simple_strtoul(this_opt + 7, NULL, 0); + if((temp >= 0) && (temp <= 3)) { + SiS_Pr.LVDSHL = temp; + } + } else if(this_opt[0] >= '0' && this_opt[0] <= '9') { + sisfb_search_mode(this_opt, TRUE); } else { printk(KERN_INFO "sisfb: Invalid option %s\n", this_opt); } /* TW: Acceleration only with MMIO mode */ if((sisfb_queuemode != -1) && (sisfb_queuemode != MMIO_CMD)) { - sisfb_ypan = 0; sisfb_accel = 0; } - /* TW: Panning only with acceleration */ - if(sisfb_accel == 0) sisfb_ypan = 0; } return 0; @@ -3653,74 +4060,43 @@ static char *sis_find_rom(void) { #if defined(__i386__) u32 segstart; - unsigned char *rom_base; - unsigned char *rom; - int stage; - int i; - char sis_rom_sig[] = "Silicon Integrated Systems"; - char *sis_sig_300[4] = { - "300", "540", "630", "730" - }; - char *sis_sig_310[7] = { - "315", "315", "315", "5315", "6325", "6325", "Xabre" - }; - ushort sis_nums_300[4] = { - SIS_300, SIS_540, SIS_630, SIS_730 - }; - unsigned short sis_nums_310[7] = { - SIS_315PRO, SIS_315H, SIS_315, SIS_550, SIS_650, SIS_740, SIS_330 - }; + unsigned char *rom_base, *rom; + int romptr; + unsigned short pciid; for(segstart=0x000c0000; segstart<0x000f0000; segstart+=0x00001000) { - stage = 1; - - rom_base = (char *)ioremap(segstart, 0x1000); + rom_base = (char *)ioremap(segstart, 0x10000); + if(!rom_base) continue; - if ((*rom_base == 0x55) && (((*(rom_base + 1)) & 0xff) == 0xaa)) - stage = 2; - - if (stage != 2) { + if((*rom_base != 0x55) || (*(rom_base + 1) != 0xaa)) { iounmap(rom_base); continue; } + romptr = (unsigned short)(*(rom_base + 0x18) | (*(rom_base + 0x19) << 8)); + if(romptr > (0x10000 - 8)) { + iounmap(rom_base); + continue; + } + + rom = rom_base + romptr; - rom = rom_base + (unsigned short)(*(rom_base + 0x12) | (*(rom_base + 0x13) << 8)); - if(strncmp(sis_rom_sig, rom, strlen(sis_rom_sig)) == 0) { - stage = 3; - } - if(stage != 3) { - iounmap(rom_base); - continue; - } + if((*rom != 'P') || (*(rom + 1) != 'C') || (*(rom + 2) != 'I') || (*(rom + 3) != 'R')) { + iounmap(rom_base); + continue; + } - rom = rom_base + (unsigned short)(*(rom_base + 0x14) | (*(rom_base + 0x15) << 8)); - for(i = 0;(i < 4) && (stage != 4); i++) { - if(strncmp(sis_sig_300[i], rom, strlen(sis_sig_300[i])) == 0) { - if(sis_nums_300[i] == ivideo.chip) { - stage = 4; - break; - } - } - } - if(stage != 4) { - for(i = 0;(i < 7) && (stage != 4); i++) { - if(strncmp(sis_sig_310[i], rom, strlen(sis_sig_310[i])) == 0) { - if(sis_nums_310[i] == ivideo.chip) { - stage = 4; - break; - } - } - } + pciid = (*(rom + 4)) | ((*(rom + 5)) << 8); + if(pciid != 0x1039) { + iounmap(rom_base); + continue; } - if(stage != 4) { - iounmap(rom_base); - continue; - } + pciid = (*(rom + 6)) | ((*(rom + 7)) << 8); + if(pciid == ivideo.chip_id) return rom_base; - return rom_base; + iounmap(rom_base); } #endif return NULL; @@ -3735,11 +4111,9 @@ int __init sisfb_init(void) int pdev_valid = 0; u32 reg32; u16 reg16; - u8 reg, reg1; - - /* outb(0x77, 0x80); */ /* What is this? */ + u8 reg; -#if 0 +#if 0 /* for DOC VB */ sisfb_set_reg4(0xcf8,0x800000e0); reg32 = sisfb_get_reg3(0xcfc); @@ -3751,24 +4125,39 @@ int __init sisfb_init(void) if (sisfb_off) return -ENXIO; - if (enable_dstn) - SiS_SetEnableDstn(&SiS_Pr); - sisfb_registered = 0; + sisfb_thismonitor.datavalid = FALSE; - memset(&sis_fb_info, 0, sizeof(sis_fb_info)); + memset(&sishw_ext, 0, sizeof(sishw_ext)); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) + memset(&sisfb_lastrates[0], 0, 128); +#endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) memset(&sis_disp, 0, sizeof(sis_disp)); -#endif +#endif - while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74) + pci_for_each_dev(pdev) { +#else + while((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_ANY_ID, pdev))) { +#endif for (b = sisdev_list; b->vendor; b++) { if ((b->vendor == pdev->vendor) && (b->device == pdev->device)) { pdev_valid = 1; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0) - strcpy(sis_fb_info.modename, b->name); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && defined(NEWFBDEV) + sis_fb_info = framebuffer_alloc(0, &pdev->dev); +#else + sis_fb_info = kmalloc(sizeof(*sis_fb_info), GFP_KERNEL); +#endif + if(!sis_fb_info) return -ENOMEM; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) || (!(defined(NEWFBDEV))) + memset(sis_fb_info, 0, sizeof(*sis_fb_info)); +#endif +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0) + strcpy(sis_fb_info->modename, b->name); #else strcpy(myid, b->name); #endif @@ -3804,18 +4193,17 @@ int __init sisfb_init(void) break; case PCI_DEVICE_ID_SI_630_VGA: { + ivideo.chip = SIS_630; sisfb_set_reg4(0xCF8, 0x80000000); reg32 = sisfb_get_reg3(0xCFC); if(reg32 == 0x07301039) { ivideo.chip = SIS_730; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0) - strcpy(sis_fb_info.modename, "SIS 730"); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0) + strcpy(sis_fb_info->modename, "SIS 730"); #else strcpy(myid, "SIS 730"); -#endif - } else - ivideo.chip = SIS_630; - +#endif + } sisvga_engine = SIS_300_VGA; sisfb_hwcursor_size = HW_CURSOR_AREA_SIZE_300 * 2; sisfb_CRT2_write_enable = IND_SIS_CRT2_WRITE_ENABLE_300; @@ -3860,11 +4248,11 @@ int __init sisfb_init(void) reg32 = sisfb_get_reg3(0xCFC); if(reg32 == 0x07401039) { ivideo.chip = SIS_740; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0) - strcpy(sis_fb_info.modename, "SIS 740"); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0) + strcpy(sis_fb_info->modename, "SIS 740"); #else - strcpy(myid, "SIS 740"); -#endif + strcpy(myid, "SIS 740"); +#endif } sisvga_engine = SIS_315_VGA; sisfb_hwcursor_size = HW_CURSOR_AREA_SIZE_315 * 2; @@ -3877,8 +4265,47 @@ int __init sisfb_init(void) sisfb_hwcursor_size = HW_CURSOR_AREA_SIZE_315 * 2; sisfb_CRT2_write_enable = IND_SIS_CRT2_WRITE_ENABLE_315; break; + case PCI_DEVICE_ID_SI_660_VGA: + { + sisfb_set_reg4(0xCF8, 0x80000000); + reg32 = sisfb_get_reg3(0xCFC); + if(reg32 == 0x07601039) { + ivideo.chip = SIS_760; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0) + strcpy(sis_fb_info->modename, "SIS 760"); +#else + strcpy(myid, "SIS 760"); +#endif + } else if(reg32 == 0x06601039) { + ivideo.chip = SIS_660; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0) + strcpy(sis_fb_info->modename, "SIS 660"); +#else + strcpy(myid, "SIS 660"); +#endif + } else if(reg32 == 0x07411039) { + ivideo.chip = SIS_741; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0) + strcpy(sis_fb_info->modename, "SIS 741"); +#else + strcpy(myid, "SIS 741"); +#endif + } else { + ivideo.chip = SIS_661; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0) + strcpy(sis_fb_info->modename, "SIS 661"); +#else + strcpy(myid, "SIS 661"); +#endif + } + sisvga_engine = SIS_315_VGA; + sisfb_hwcursor_size = HW_CURSOR_AREA_SIZE_315 * 2; + sisfb_CRT2_write_enable = IND_SIS_CRT2_WRITE_ENABLE_315; + break; + } #endif default: + kfree(sis_fb_info); return -ENODEV; } sishw_ext.jChipType = ivideo.chip; @@ -3890,73 +4317,65 @@ int __init sisfb_init(void) ivideo.video_base = pci_resource_start(pdev, 0); ivideo.mmio_base = pci_resource_start(pdev, 1); - sishw_ext.ulIOAddress = (unsigned short) ivideo.vga_base = - (unsigned short) SiS_Pr.RelIO = pci_resource_start(pdev, 2) + 0x30; + sishw_ext.ulIOAddress = SiS_Pr.RelIO = pci_resource_start(pdev, 2) + 0x30; + ivideo.vga_base = (unsigned short) sishw_ext.ulIOAddress; sisfb_mmio_size = pci_resource_len(pdev, 1); if(!sisvga_enabled) { - if (pci_enable_device(pdev)) return -EIO; + if(pci_enable_device(pdev)) { + kfree(sis_fb_info); + return -EIO; + } } SiS_Pr.SiS_Backup70xx = 0xff; SiS_Pr.SiS_CHOverScan = -1; SiS_Pr.SiS_ChSW = FALSE; SiS_Pr.SiS_UseLCDA = FALSE; - SiS_Pr.UsePanelScaler = -1; - SiSRegInit(&SiS_Pr, (USHORT)sishw_ext.ulIOAddress); + SiS_Pr.HaveEMI = FALSE; + SiS_Pr.HaveEMILCD = FALSE; + SiS_Pr.OverruleEMI = FALSE; + SiS_Pr.SiS_SensibleSR11 = FALSE; + SiS_Pr.SiS_MyCR63 = 0x63; + if(ivideo.chip >= SIS_661) { + SiS_Pr.SiS_SensibleSR11 = TRUE; + SiS_Pr.SiS_MyCR63 = 0x53; + } + SiSRegInit(&SiS_Pr, sishw_ext.ulIOAddress); #ifdef CONFIG_FB_SIS_300 - /* TW: Find PCI systems for Chrontel/ISA bridge manipulation */ + /* TW: Find PCI systems for Chrontel/GPIO communication setup */ if(ivideo.chip == SIS_630) { - int i=0; - do { - if(mychswtable[i].subsysVendor == ivideo.subsysvendor && - mychswtable[i].subsysCard == ivideo.subsysdevice) { - SiS_Pr.SiS_ChSW = TRUE; - } - i++; - } while(mychswtable[i].subsysVendor != 0); + int i=0; + do { + if(mychswtable[i].subsysVendor == ivideo.subsysvendor && + mychswtable[i].subsysCard == ivideo.subsysdevice) { + SiS_Pr.SiS_ChSW = TRUE; + printk(KERN_DEBUG "sisfb: Identified [%s %s] requiring Chrontel/GPIO setup\n", + mychswtable[i].vendorName, mychswtable[i].cardName); + break; + } + i++; + } while(mychswtable[i].subsysVendor != 0); } #endif outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#ifdef MODULE +#ifdef MODULE inSISIDXREG(SISCR,0x34,reg); - if(reg & 0x80) { + if((reg & 0x80) && (reg != 0xff)) { if((sisbios_mode[sisfb_mode_idx].mode_no) != 0xFF) { printk(KERN_INFO "sisfb: Cannot initialize display mode, X server is active\n"); + kfree(sis_fb_info); return -EBUSY; } } #endif #endif -#ifdef LINUXBIOS /* -------------------------------- */ - -#ifdef CONFIG_FB_SIS_300 - if (sisvga_engine == SIS_300_VGA) { - outSISIDXREG(SISSR, 0x28, 0x37); - - outSISIDXREG(SISSR, 0x29, 0x61); - - orSISIDXREG(SISSR, IND_SIS_SCRATCH_REG_1A, SIS_SCRATCH_REG_1A_MASK); - } -#endif -#ifdef CONFIG_FB_SIS_315 - if (ivideo.chip == SIS_550 || ivideo.chip == SIS_650 || ivideo.chip == SIS_740) { - outSISIDXREG(SISSR, 0x28, 0x5a); - - outSISIDXREG(SISSR, 0x29, 0x64); - - outSISIDXREG(SISCR, 0x3a, 0x00); - } -#endif - -#endif /* LinuxBIOS -------------------------------- */ - if (sisvga_engine == SIS_315_VGA) { switch (ivideo.chip) { case SIS_315H: @@ -3967,6 +4386,10 @@ int __init sisfb_init(void) case SIS_550: case SIS_650: case SIS_740: + case SIS_661: + case SIS_741: + case SIS_660: + case SIS_760: sishw_ext.bIntegratedMMEnabled = TRUE; break; default: @@ -3984,7 +4407,6 @@ int __init sisfb_init(void) } } - sishw_ext.pDevice = NULL; if(sisfb_userom) { sishw_ext.pjVirtualRomBase = sis_find_rom(); if(sishw_ext.pjVirtualRomBase) { @@ -4000,23 +4422,76 @@ int __init sisfb_init(void) sishw_ext.UseROM = FALSE; printk(KERN_INFO "sisfb: Video ROM usage disabled\n"); } - sishw_ext.pjCustomizedROMImage = NULL; sishw_ext.bSkipDramSizing = 0; sishw_ext.pQueryVGAConfigSpace = &sisfb_query_VGA_config_space; sishw_ext.pQueryNorthBridgeSpace = &sisfb_query_north_bridge_space; - strcpy(sishw_ext.szVBIOSVer, "0.84"); - /* TW: Mode numbers for 1280x960 are different for 300 and 310/325 series */ + /* Find systems for special custom timing */ + if(SiS_Pr.SiS_CustomT == CUT_NONE) { + int i=0, j; + unsigned char *biosver = NULL; + unsigned char *biosdate = NULL; + BOOLEAN footprint; + unsigned long chksum = 0; + + if(sishw_ext.UseROM) { + biosver = sishw_ext.pjVirtualRomBase + 0x06; + biosdate = sishw_ext.pjVirtualRomBase + 0x2c; + for(i=0; i<32768; i++) chksum += sishw_ext.pjVirtualRomBase[i]; + } + + i=0; + do { + if( (mycustomttable[i].chipID == ivideo.chip) && + ((!strlen(mycustomttable[i].biosversion)) || + (sishw_ext.UseROM && + (!strncmp(mycustomttable[i].biosversion, biosver, strlen(mycustomttable[i].biosversion))))) && + ((!strlen(mycustomttable[i].biosdate)) || + (sishw_ext.UseROM && + (!strncmp(mycustomttable[i].biosdate, biosdate, strlen(mycustomttable[i].biosdate))))) && + ((!mycustomttable[i].bioschksum) || + (sishw_ext.UseROM && + (mycustomttable[i].bioschksum == chksum))) && + (mycustomttable[i].pcisubsysvendor == ivideo.subsysvendor) && + (mycustomttable[i].pcisubsyscard == ivideo.subsysdevice) ) { + footprint = TRUE; + for(j=0; j<5; j++) { + if(mycustomttable[i].biosFootprintAddr[j]) { + if(sishw_ext.UseROM) { + if(sishw_ext.pjVirtualRomBase[mycustomttable[i].biosFootprintAddr[j]] != + mycustomttable[i].biosFootprintData[j]) + footprint = FALSE; + } else footprint = FALSE; + } + } + if(footprint) { + SiS_Pr.SiS_CustomT = mycustomttable[i].SpecialID; + printk(KERN_DEBUG "sisfb: Identified [%s %s], special timing applies\n", + mycustomttable[i].vendorName, + mycustomttable[i].cardName); + printk(KERN_DEBUG "sisfb: [specialtiming parameter name: %s]\n", + mycustomttable[i].optionName); + break; + } + } + i++; + } while(mycustomttable[i].chipID); + } + +#ifdef CONFIG_FB_SIS_300 + /* Mode numbers for 1280x768 are different for 300 and 315 series */ if(sisvga_engine == SIS_300_VGA) { - sisbios_mode[MODEINDEX_1280x960].mode_no = 0x6e; - sisbios_mode[MODEINDEX_1280x960+1].mode_no = 0x6f; - sisbios_mode[MODEINDEX_1280x960+2].mode_no = 0x7b; - sisbios_mode[MODEINDEX_1280x960+3].mode_no = 0x7b; + sisbios_mode[MODEINDEX_1280x768].mode_no = 0x55; + sisbios_mode[MODEINDEX_1280x768+1].mode_no = 0x5a; + sisbios_mode[MODEINDEX_1280x768+2].mode_no = 0x5b; + sisbios_mode[MODEINDEX_1280x768+3].mode_no = 0x5b; } +#endif sishw_ext.pSR = vmalloc(sizeof(SIS_DSReg) * SR_BUFFER_SIZE); if (sishw_ext.pSR == NULL) { printk(KERN_ERR "sisfb: Fatal error: Allocating SRReg space failed.\n"); + kfree(sis_fb_info); return -ENODEV; } sishw_ext.pSR[0].jIdx = sishw_ext.pSR[0].jVal = 0xFF; @@ -4025,6 +4500,7 @@ int __init sisfb_init(void) if (sishw_ext.pCR == NULL) { vfree(sishw_ext.pSR); printk(KERN_ERR "sisfb: Fatal error: Allocating CRReg space failed.\n"); + kfree(sis_fb_info); return -ENODEV; } sishw_ext.pCR[0].jIdx = sishw_ext.pCR[0].jVal = 0xFF; @@ -4033,32 +4509,16 @@ int __init sisfb_init(void) if(sisvga_engine == SIS_300_VGA) { if(!sisvga_enabled) { /* Mapping Max FB Size for 300 Init */ - sishw_ext.pjVideoMemoryAddress - = ioremap(ivideo.video_base, 0x4000000); - if((sisfb_mode_idx < 0) || ((sisbios_mode[sisfb_mode_idx].mode_no) != 0xFF)) { -#ifdef LINUXBIOS /* TW: SiSInit now for LinuxBIOS only */ - SiSInit(&SiS_Pr, &sishw_ext); -#endif - outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); - } - } -#ifdef LINUXBIOS - else { - sishw_ext.pjVideoMemoryAddress - = ioremap(ivideo.video_base, 0x4000000); + sishw_ext.pjVideoMemoryAddress = ioremap(ivideo.video_base, 0x4000000); if((sisfb_mode_idx < 0) || ((sisbios_mode[sisfb_mode_idx].mode_no) != 0xFF)) { - SiSInit(&SiS_Pr, &sishw_ext); outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); } } - if((sisfb_mode_idx < 0) || ((sisbios_mode[sisfb_mode_idx].mode_no) != 0xFF)) { - orSISIDXREG(SISSR, 0x07, 0x10); - } -#endif if(sisfb_get_dram_size_300()) { vfree(sishw_ext.pSR); vfree(sishw_ext.pCR); printk(KERN_ERR "sisfb: Fatal error: Unable to determine RAM size\n"); + kfree(sis_fb_info); return -ENODEV; } } @@ -4068,35 +4528,9 @@ int __init sisfb_init(void) if (sisvga_engine == SIS_315_VGA) { if (!sisvga_enabled) { /* Mapping Max FB Size for 315 Init */ - sishw_ext.pjVideoMemoryAddress - = ioremap(ivideo.video_base, 0x8000000); - if((sisfb_mode_idx < 0) || ((sisbios_mode[sisfb_mode_idx].mode_no) != 0xFF)) { -#ifdef LINUXBIOS - /* TW: SISInit is now for LINUXBIOS only */ - SiSInit(&SiS_Pr, &sishw_ext); -#endif - - outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); - - sishw_ext.bSkipDramSizing = TRUE; - sishw_ext.pSR[0].jIdx = 0x13; - sishw_ext.pSR[1].jIdx = 0x14; - sishw_ext.pSR[2].jIdx = 0xFF; - inSISIDXREG(SISSR, 0x13, sishw_ext.pSR[0].jVal); - inSISIDXREG(SISSR, 0x14, sishw_ext.pSR[1].jVal); - sishw_ext.pSR[2].jVal = 0xFF; - } - } -#ifdef LINUXBIOS - else { - sishw_ext.pjVideoMemoryAddress - = ioremap(ivideo.video_base, 0x8000000); - if((sisfb_mode_idx < 0) || ((sisbios_mode[sisfb_mode_idx].mode_no) != 0xFF)) { - - SiSInit(&SiS_Pr, &sishw_ext); - + sishw_ext.pjVideoMemoryAddress = ioremap(ivideo.video_base, 0x8000000); + if((sisfb_mode_idx < 0) || ((sisbios_mode[sisfb_mode_idx].mode_no) != 0xFF)) { outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); - sishw_ext.bSkipDramSizing = TRUE; sishw_ext.pSR[0].jIdx = 0x13; sishw_ext.pSR[1].jIdx = 0x14; @@ -4106,11 +4540,11 @@ int __init sisfb_init(void) sishw_ext.pSR[2].jVal = 0xFF; } } -#endif - if (sisfb_get_dram_size_315()) { + if(sisfb_get_dram_size_315()) { vfree(sishw_ext.pSR); vfree(sishw_ext.pCR); printk(KERN_INFO "sisfb: Fatal error: Unable to determine RAM size.\n"); + kfree(sis_fb_info); return -ENODEV; } } @@ -4128,39 +4562,59 @@ int __init sisfb_init(void) sishw_ext.ulVideoMemorySize = ivideo.video_size; + if(sisvga_engine == SIS_300_VGA) sisfb_pdc &= 0x3c; if(sisfb_pdc) { - sishw_ext.pdc = sisfb_pdc; + SiS_Pr.PDC = sisfb_pdc; } else { - sishw_ext.pdc = 0; + SiS_Pr.PDC = 0; } - if (!request_mem_region(ivideo.video_base, ivideo.video_size, "sisfb FB")) { + if(!request_mem_region(ivideo.video_base, ivideo.video_size, "sisfb FB")) { printk(KERN_ERR "sisfb: Fatal error: Unable to reserve frame buffer memory\n"); printk(KERN_ERR "sisfb: Is there another framebuffer driver active?\n"); vfree(sishw_ext.pSR); vfree(sishw_ext.pCR); + kfree(sis_fb_info); return -ENODEV; } - if (!request_mem_region(ivideo.mmio_base, sisfb_mmio_size, "sisfb MMIO")) { + if(!request_mem_region(ivideo.mmio_base, sisfb_mmio_size, "sisfb MMIO")) { printk(KERN_ERR "sisfb: Fatal error: Unable to reserve MMIO region\n"); release_mem_region(ivideo.video_base, ivideo.video_size); vfree(sishw_ext.pSR); vfree(sishw_ext.pCR); + kfree(sis_fb_info); return -ENODEV; } - ivideo.video_vbase = sishw_ext.pjVideoMemoryAddress = - ioremap(ivideo.video_base, ivideo.video_size); + ivideo.video_vbase = sishw_ext.pjVideoMemoryAddress = ioremap(ivideo.video_base, ivideo.video_size); + if(!ivideo.video_vbase) { + printk(KERN_ERR "sisfb: Fatal error: Unable to map frame buffer memory\n"); + release_mem_region(ivideo.video_base, ivideo.video_size); + release_mem_region(ivideo.mmio_base, sisfb_mmio_size); + vfree(sishw_ext.pSR); + vfree(sishw_ext.pCR); + kfree(sis_fb_info); + return -ENODEV; + } + ivideo.mmio_vbase = ioremap(ivideo.mmio_base, sisfb_mmio_size); + if(!ivideo.mmio_vbase) { + printk(KERN_ERR "sisfb: Fatal error: Unable to map MMIO region\n"); + iounmap(ivideo.video_vbase); + release_mem_region(ivideo.video_base, ivideo.video_size); + release_mem_region(ivideo.mmio_base, sisfb_mmio_size); + vfree(sishw_ext.pSR); + vfree(sishw_ext.pCR); + kfree(sis_fb_info); + return -ENODEV; + } printk(KERN_INFO "sisfb: Framebuffer at 0x%lx, mapped to 0x%p, size %dk\n", - ivideo.video_base, ivideo.video_vbase, - ivideo.video_size / 1024); + ivideo.video_base, ivideo.video_vbase, ivideo.video_size / 1024); printk(KERN_INFO "sisfb: MMIO at 0x%lx, mapped to 0x%p, size %ldk\n", - ivideo.mmio_base, ivideo.mmio_vbase, - sisfb_mmio_size / 1024); + ivideo.mmio_base, ivideo.mmio_vbase, sisfb_mmio_size / 1024); if(sisfb_heap_init()) { printk(KERN_WARNING "sisfb: Failed to initialize offscreen memory heap\n"); @@ -4168,206 +4622,173 @@ int __init sisfb_init(void) ivideo.mtrr = (unsigned int) 0; - if((sisfb_mode_idx < 0) || ((sisbios_mode[sisfb_mode_idx].mode_no) != 0xFF)) { - -#ifdef CONFIG_FB_SIS_300 - if (sisvga_engine == SIS_300_VGA) { - sisfb_get_VB_type_300(); - } -#endif + ivideo.vbflags = 0; -#ifdef CONFIG_FB_SIS_315 - if (sisvga_engine == SIS_315_VGA) { - sisfb_get_VB_type_315(); - } -#endif + if((sisfb_mode_idx < 0) || ((sisbios_mode[sisfb_mode_idx].mode_no) != 0xFF)) { sishw_ext.ujVBChipID = VB_CHIP_UNKNOWN; sishw_ext.Is301BDH = FALSE; sishw_ext.usExternalChip = 0; - switch (ivideo.hasVB) { + sisfb_sense_crt1(); - case HASVB_301: - inSISIDXREG(SISPART4, 0x01, reg); - if (reg >= 0xE0) { - sishw_ext.ujVBChipID = VB_CHIP_302LV; - printk(KERN_INFO "sisfb: SiS302LV bridge detected (revision 0x%02x)\n",reg); - } else if (reg >= 0xD0) { - sishw_ext.ujVBChipID = VB_CHIP_301LV; - printk(KERN_INFO "sisfb: SiS301LV bridge detected (revision 0x%02x)\n",reg); - } else if (reg >= 0xB0) { - sishw_ext.ujVBChipID = VB_CHIP_301B; - inSISIDXREG(SISPART4,0x23,reg1); - if(!(reg1 & 0x02)) sishw_ext.Is301BDH = TRUE; - printk(KERN_INFO "sisfb: SiS301B%s bridge detected (revision 0x%02x)\n", - (sishw_ext.Is301BDH ? "-DH" : ""), reg); - } else { - sishw_ext.ujVBChipID = VB_CHIP_301; - printk(KERN_INFO "sisfb: SiS301 bridge detected\n"); - } - break; - case HASVB_302: - inSISIDXREG(SISPART4, 0x01, reg); - if (reg >= 0xE0) { - sishw_ext.ujVBChipID = VB_CHIP_302LV; - printk(KERN_INFO "sisfb: SiS302LV bridge detected (revision 0x%02x)\n",reg); - } else if (reg >= 0xD0) { - sishw_ext.ujVBChipID = VB_CHIP_301LV; - printk(KERN_INFO "sisfb: SiS302LV bridge detected (revision 0x%02x)\n",reg); - } else if (reg >= 0xB0) { - inSISIDXREG(SISPART4,0x23,reg1); - if(!(reg1 & 0x02)) sishw_ext.Is301BDH = TRUE; - sishw_ext.ujVBChipID = VB_CHIP_302B; - printk(KERN_INFO "sisfb: SiS302B%s bridge detected (revision 0x%02x)\n", - (sishw_ext.Is301BDH ? "-DH" : ""), reg); - } else { - sishw_ext.ujVBChipID = VB_CHIP_302; - printk(KERN_INFO "sisfb: SiS302 bridge detected\n"); - } - break; - case HASVB_LVDS: - sishw_ext.usExternalChip = 0x1; - printk(KERN_INFO "sisfb: LVDS transmitter detected\n"); - break; - case HASVB_TRUMPION: - sishw_ext.usExternalChip = 0x2; - printk(KERN_INFO "sisfb: Trumpion Zurac LVDS scaler detected\n"); - break; - case HASVB_CHRONTEL: - sishw_ext.usExternalChip = 0x4; - printk(KERN_INFO "sisfb: Chrontel TV encoder detected\n"); - break; - case HASVB_LVDS_CHRONTEL: - sishw_ext.usExternalChip = 0x5; - printk(KERN_INFO "sisfb: LVDS transmitter and Chrontel TV encoder detected\n"); - break; - default: - printk(KERN_INFO "sisfb: No or unknown bridge type detected\n"); - break; - } + sisfb_get_VB_type(); - if (ivideo.hasVB != HASVB_NONE) { -#ifdef CONFIG_FB_SIS_300 - if (sisvga_engine == SIS_300_VGA) { - sisfb_detect_VB_connect_300(); - } -#endif -#ifdef CONFIG_FB_SIS_315 - if (sisvga_engine == SIS_315_VGA) { - sisfb_detect_VB_connect_315(); - } -#endif + if(ivideo.vbflags & VB_VIDEOBRIDGE) { + sisfb_detect_VB_connect(); } - if (ivideo.disp_state & DISPTYPE_DISP2) { - if (sisfb_crt1off) - ivideo.disp_state |= DISPMODE_SINGLE; - else - ivideo.disp_state |= (DISPMODE_MIRROR | DISPTYPE_CRT1); - } else { - ivideo.disp_state = DISPMODE_SINGLE | DISPTYPE_CRT1; + ivideo.currentvbflags = ivideo.vbflags & VB_VIDEOBRIDGE; + + if(ivideo.vbflags & VB_VIDEOBRIDGE) { + if(sisfb_crt2type != -1) { + if((sisfb_crt2type == CRT2_LCD) && (ivideo.vbflags & CRT2_LCD)) { + ivideo.currentvbflags |= CRT2_LCD; + } else if(sisfb_crt2type != CRT2_LCD) { + ivideo.currentvbflags |= sisfb_crt2type; + } + } else { + /* Chrontel 700x TV detection often unreliable, therefore use a + * different default order on such machines + */ + if((sisvga_engine == SIS_300_VGA) && (ivideo.vbflags & VB_CHRONTEL)) { + if(ivideo.vbflags & CRT2_LCD) ivideo.currentvbflags |= CRT2_LCD; + else if(ivideo.vbflags & CRT2_TV) ivideo.currentvbflags |= CRT2_TV; + else if(ivideo.vbflags & CRT2_VGA) ivideo.currentvbflags |= CRT2_VGA; + } else { + if(ivideo.vbflags & CRT2_TV) ivideo.currentvbflags |= CRT2_TV; + else if(ivideo.vbflags & CRT2_LCD) ivideo.currentvbflags |= CRT2_LCD; + else if(ivideo.vbflags & CRT2_VGA) ivideo.currentvbflags |= CRT2_VGA; + } + } } - if (ivideo.disp_state & DISPTYPE_LCD) { - if (!enable_dstn) { - inSISIDXREG(SISCR, IND_SIS_LCD_PANEL, reg); - reg &= 0x0f; - if (sisvga_engine == SIS_300_VGA) { - sishw_ext.ulCRT2LCDType = sis300paneltype[reg]; - } else { - sishw_ext.ulCRT2LCDType = sis310paneltype[reg]; - } - } else { - /* TW: FSTN/DSTN */ - sishw_ext.ulCRT2LCDType = LCD_320x480; - } + if(ivideo.vbflags & CRT2_LCD) { + inSISIDXREG(SISCR, IND_SIS_LCD_PANEL, reg); + reg &= 0x0f; + if(sisvga_engine == SIS_300_VGA) { + sishw_ext.ulCRT2LCDType = sis300paneltype[reg]; + } else { + sishw_ext.ulCRT2LCDType = sis310paneltype[reg]; + } } sisfb_detectedpdc = 0; -#ifndef LINUXBIOS + #ifdef CONFIG_FB_SIS_300 - /* TW: Save the current PanelDelayCompensation if the LCD is currently used */ + /* Save the current PanelDelayCompensation if the LCD is currently used */ if(sisvga_engine == SIS_300_VGA) { - if((sishw_ext.usExternalChip == 0x01) || /* LVDS */ - (sishw_ext.usExternalChip == 0x05) || /* LVDS+Chrontel */ - (sishw_ext.Is301BDH)) { /* 301B-DH */ + if(ivideo.vbflags & (VB_LVDS | VB_30xBDH)) { int tmp; inSISIDXREG(SISCR,0x30,tmp); if(tmp & 0x20) { /* Currently on LCD? If yes, read current pdc */ inSISIDXREG(SISPART1,0x13,sisfb_detectedpdc); sisfb_detectedpdc &= 0x3c; - if(sishw_ext.pdc == 0) { + if(SiS_Pr.PDC == 0) { /* Let option override detection */ - sishw_ext.pdc = sisfb_detectedpdc; + SiS_Pr.PDC = sisfb_detectedpdc; } printk(KERN_INFO "sisfb: Detected LCD PanelDelayCompensation %d\n", sisfb_detectedpdc); } - if((sishw_ext.pdc) && (sishw_ext.pdc != sisfb_detectedpdc)) { + if((SiS_Pr.PDC) && (SiS_Pr.PDC != sisfb_detectedpdc)) { printk(KERN_INFO "sisfb: Using LCD PanelDelayCompensation %d\n", - sishw_ext.pdc); + SiS_Pr.PDC); } - } + } } #endif -#endif + sisfb_detectedlcda = 0xff; -#ifndef LINUXBIOS + #ifdef CONFIG_FB_SIS_315 - /* TW: Try to find about LCDA */ + if(sisvga_engine == SIS_315_VGA) { - if((sishw_ext.ujVBChipID == VB_CHIP_302B) || - (sishw_ext.ujVBChipID == VB_CHIP_301LV) || - (sishw_ext.ujVBChipID == VB_CHIP_302LV)) { - int tmp; - inSISIDXREG(SISCR,0x34,tmp); - if(tmp <= 0x13) { - /* Currently on LCDA? (Some BIOSes leave CR38) */ - inSISIDXREG(SISCR,0x38,tmp); - if((tmp & 0x03) == 0x03) { - SiS_Pr.SiS_UseLCDA = TRUE; - } else { - /* Currently on LCDA? (Some newer BIOSes set D0 in CR35) */ - inSISIDXREG(SISCR,0x35,tmp); - if(tmp & 0x01) { - SiS_Pr.SiS_UseLCDA = TRUE; - } else { - /* Currently on LCD? If so, we can find out - by peeking the mode register - */ - inSISIDXREG(SISCR,0x30,tmp); - if(tmp & 0x20) { - inSISIDXREG(SISPART1,0x13,tmp); - if(tmp & 0x04) { - SiS_Pr.SiS_UseLCDA = TRUE; - } - } - } - } - } - if(SiS_Pr.SiS_UseLCDA) { - sisfb_detectedlcda = 0x03; - printk(KERN_INFO - "sisfb: Bridge uses LCDA for low resolution and text modes\n"); - } + /* Save PDC */ + if(ivideo.vbflags & (VB_301LV | VB_302LV | VB_302ELV)) { + int tmp; + inSISIDXREG(SISCR,0x30,tmp); + if(tmp & 0x20) { + /* Currently on LCD? If yes, read current pdc */ + inSISIDXREG(SISPART1,0x2D,sisfb_detectedpdc); + if(SiS_Pr.PDC == 0) { + /* Let option override detection */ + SiS_Pr.PDC = sisfb_detectedpdc; + } + printk(KERN_INFO + "sisfb: Detected LCD PanelDelayCompensation %d\n", + sisfb_detectedpdc); + } + if((SiS_Pr.PDC) && (SiS_Pr.PDC != sisfb_detectedpdc)) { + printk(KERN_INFO + "sisfb: Using LCD PanelDelayCompensation %d\n", + SiS_Pr.PDC); + } + /* Save EMI */ + if(ivideo.vbflags & (VB_302LV | VB_302ELV)) { + inSISIDXREG(SISPART4,0x30,SiS_Pr.EMI_30); + inSISIDXREG(SISPART4,0x31,SiS_Pr.EMI_31); + inSISIDXREG(SISPART4,0x32,SiS_Pr.EMI_32); + inSISIDXREG(SISPART4,0x33,SiS_Pr.EMI_33); + SiS_Pr.HaveEMI = TRUE; + if(tmp & 0x20) SiS_Pr.HaveEMILCD = TRUE; + } + } + + /* Try to find about LCDA */ + if(ivideo.vbflags & (VB_301C | VB_302B | VB_301LV | VB_302LV | VB_302ELV)) { + int tmp; + inSISIDXREG(SISCR,0x34,tmp); + if((tmp <= 0x13) || (tmp == 0xff)) { + /* Currently on LCDA? (Some BIOSes leave CR38) */ + inSISIDXREG(SISCR,0x38,tmp); + if((tmp & 0x03) == 0x03) SiS_Pr.SiS_UseLCDA = TRUE; + else { + /* Currently on LCDA? (Some newer BIOSes set D0 in CR35) */ + inSISIDXREG(SISCR,0x35,tmp); + if(tmp & 0x01) SiS_Pr.SiS_UseLCDA = TRUE; + else { + /* Currently on LCD? If so, we can find out + * by peeking the mode register + */ + inSISIDXREG(SISCR,0x30,tmp); + if(tmp & 0x20) { + inSISIDXREG(SISPART1,0x13,tmp); + if(tmp & 0x04) SiS_Pr.SiS_UseLCDA = TRUE; + } + } + } + } + if(SiS_Pr.SiS_UseLCDA) { + sisfb_detectedlcda = 0x03; + printk(KERN_DEBUG + "sisfb: Bridge uses LCDA for low resolution and text modes\n"); + } } } #endif -#endif + + if (!sisfb_crt1off) { + sisfb_handle_ddc(&sisfb_thismonitor, 0); + } else { + if ((ivideo.vbflags & (VB_301|VB_301B|VB_301C|VB_302B)) && + (ivideo.vbflags & (CRT2_VGA | CRT2_LCD))) { + sisfb_handle_ddc(&sisfb_thismonitor, 1); + } + } if (sisfb_mode_idx >= 0) - sisfb_mode_idx = sisfb_validate_mode(sisfb_mode_idx); + sisfb_mode_idx = sisfb_validate_mode(sisfb_mode_idx, ivideo.currentvbflags); if (sisfb_mode_idx < 0) { - switch (ivideo.disp_state & DISPTYPE_DISP2) { - case DISPTYPE_LCD: + switch (ivideo.currentvbflags & VB_DISPTYPE_DISP2) { + case CRT2_LCD: sisfb_mode_idx = DEFAULT_LCDMODE; break; - case DISPTYPE_TV: + case CRT2_TV: sisfb_mode_idx = DEFAULT_TVMODE; break; default: @@ -4379,39 +4800,27 @@ int __init sisfb_init(void) sisfb_mode_no = sisbios_mode[sisfb_mode_idx].mode_no; if (ivideo.refresh_rate != 0) - sisfb_search_refresh_rate(ivideo.refresh_rate); + sisfb_search_refresh_rate(ivideo.refresh_rate, sisfb_mode_idx); if (sisfb_rate_idx == 0) { sisfb_rate_idx = sisbios_mode[sisfb_mode_idx].rate_idx; ivideo.refresh_rate = 60; } + if (sisfb_thismonitor.datavalid) { + if(!sisfb_verify_rate(&sisfb_thismonitor, sisfb_mode_idx, + sisfb_rate_idx, ivideo.refresh_rate)) { + printk(KERN_INFO "sisfb: WARNING: Refresh rate exceeds monitor specs!\n"); + } + } + ivideo.video_bpp = sisbios_mode[sisfb_mode_idx].bpp; ivideo.video_vwidth = ivideo.video_width = sisbios_mode[sisfb_mode_idx].xres; ivideo.video_vheight = ivideo.video_height = sisbios_mode[sisfb_mode_idx].yres; ivideo.org_x = ivideo.org_y = 0; ivideo.video_linelength = ivideo.video_width * (ivideo.video_bpp >> 3); - switch(ivideo.video_bpp) { - case 8: - ivideo.DstColor = 0x0000; - ivideo.SiS310_AccelDepth = 0x00000000; - ivideo.video_cmap_len = 256; - break; - case 16: - ivideo.DstColor = 0x8000; - ivideo.SiS310_AccelDepth = 0x00010000; - ivideo.video_cmap_len = 16; - break; - case 32: - ivideo.DstColor = 0xC000; - ivideo.SiS310_AccelDepth = 0x00020000; - ivideo.video_cmap_len = 16; - break; - default: - ivideo.video_cmap_len = 16; - printk(KERN_INFO "sisfb: Unsupported depth %d", ivideo.video_bpp); - break; - } + + sisfb_set_vparms(); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) @@ -4424,30 +4833,56 @@ int __init sisfb_init(void) sisfb_pre_setmode(); if (SiSSetMode(&SiS_Pr, &sishw_ext, sisfb_mode_no) == 0) { - printk(KERN_ERR "sisfb: Setting mode[0x%x] failed, using default mode\n", + printk(KERN_ERR "sisfb: Fatal error: Setting mode[0x%x] failed\n", sisfb_mode_no); - return -1; + vfree(sishw_ext.pSR); + vfree(sishw_ext.pCR); + release_mem_region(ivideo.video_base, ivideo.video_size); + release_mem_region(ivideo.mmio_base, sisfb_mmio_size); + kfree(sis_fb_info); + return -EINVAL; } outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); sisfb_post_setmode(); + ivideo.accel = 0; + if(sisfb_accel) { + ivideo.accel = -1; + default_var.accel_flags |= FB_ACCELF_TEXT; + sisfb_initaccel(); + } + + /* Maximize regardless of sisfb_max at startup */ + default_var.yres_virtual = 32767; sisfb_crtc_to_var(&default_var); + sis_fb_info->node = -1; + sis_fb_info->flags = FBINFO_FLAG_DEFAULT; + sis_fb_info->blank = &sisfb_blank; + sis_fb_info->fbops = &sisfb_ops; + sis_fb_info->switch_con = &sisfb_switch; + sis_fb_info->updatevar = &sisfb_update_var; + sis_fb_info->changevar = NULL; + sis_fb_info->disp = &sis_disp; + strcpy(sis_fb_info->fontname, sisfb_fontname); + + sisfb_set_disp(-1, &default_var, sis_fb_info); + #else /* --------- For 2.5: Setup a somewhat sane default var ------------ */ printk(KERN_INFO "sisfb: Default mode is %dx%dx%d (%dHz)\n", ivideo.video_width, ivideo.video_height, ivideo.video_bpp, ivideo.refresh_rate); - + default_var.xres = default_var.xres_virtual = ivideo.video_width; default_var.yres = default_var.yres_virtual = ivideo.video_height; default_var.bits_per_pixel = ivideo.video_bpp; - + sisfb_bpp_to_var(&default_var); - default_var.pixclock = (u32) (1E12 / + default_var.pixclock = (u32) (1000000000 / sisfb_mode_rate_to_dclock(&SiS_Pr, &sishw_ext, sisfb_mode_no, sisfb_rate_idx)); @@ -4457,28 +4892,10 @@ int __init sisfb_init(void) &default_var.upper_margin, &default_var.lower_margin, &default_var.hsync_len, &default_var.vsync_len, &default_var.sync, &default_var.vmode)) { - - if((default_var.vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { - default_var.yres <<= 1; - default_var.yres_virtual <<= 1; - } else if((default_var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { - default_var.pixclock >>= 1; - default_var.yres >>= 1; - default_var.yres_virtual >>= 1; - } - + if((default_var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { + default_var.pixclock <<= 1; + } } -#ifdef SISFB_PAN - if(sisfb_ypan) { - default_var.yres_virtual = - ivideo.heapstart / (default_var.xres * (default_var.bits_per_pixel >> 3)); - if(default_var.yres_virtual <= default_var.yres) { - default_var.yres_virtual = default_var.yres; - } - } -#endif - -#endif ivideo.accel = 0; if(sisfb_accel) { @@ -4487,32 +4904,33 @@ int __init sisfb_init(void) sisfb_initaccel(); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* ---- 2.4 series init ---- */ - sis_fb_info.node = -1; - sis_fb_info.flags = FBINFO_FLAG_DEFAULT; - sis_fb_info.blank = &sisfb_blank; - sis_fb_info.fbops = &sisfb_ops; - sis_fb_info.switch_con = &sisfb_switch; - sis_fb_info.updatevar = &sisfb_update_var; - sis_fb_info.changevar = NULL; - sis_fb_info.disp = &sis_disp; - - sisfb_set_disp(-1, &default_var, &sis_fb_info); -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) /* ---- 2.5 series init ---- */ - sis_fb_info.flags = FBINFO_FLAG_DEFAULT; - sis_fb_info.var = default_var; - sis_fb_info.fix = sisfb_fix; - sis_fb_info.par = &ivideo; - sis_fb_info.screen_base = ivideo.video_vbase; - sis_fb_info.fbops = &sisfb_ops; - sisfb_get_fix(&sis_fb_info.fix, -1, &sis_fb_info); - sis_fb_info.pseudo_palette = pseudo_palette; + if(sisfb_ypan) { + /* Maximize regardless of sisfb_max at startup */ + default_var.yres_virtual = + ivideo.heapstart / (default_var.xres * (default_var.bits_per_pixel >> 3)); + if(default_var.yres_virtual > 32767) default_var.yres_virtual = 32767; + if(default_var.yres_virtual <= default_var.yres) { + default_var.yres_virtual = default_var.yres; + } + } + + sis_fb_info->flags = FBINFO_FLAG_DEFAULT; + sis_fb_info->var = default_var; + sis_fb_info->fix = sisfb_fix; + sis_fb_info->par = &ivideo; + sis_fb_info->screen_base = ivideo.video_vbase; + sis_fb_info->fbops = &sisfb_ops; +#ifdef NEWFBDEV + sis_fb_info->class_dev.dev = &pdev->dev; +#endif + sisfb_get_fix(&sis_fb_info->fix, -1, sis_fb_info); + sis_fb_info->pseudo_palette = pseudo_palette; - fb_alloc_cmap(&sis_fb_info.cmap, 256 , 0); + fb_alloc_cmap(&sis_fb_info->cmap, 256 , 0); #endif + printk(KERN_INFO "sisfb: Initial vbflags 0x%lx\n", ivideo.vbflags); + #ifdef CONFIG_MTRR ivideo.mtrr = mtrr_add((unsigned int) ivideo.video_base, (unsigned int) ivideo.video_size, @@ -4520,37 +4938,44 @@ int __init sisfb_init(void) if(ivideo.mtrr) { printk(KERN_INFO "sisfb: Added MTRRs\n"); } + #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) vc_resize_con(1, 1, 0); #endif - TWDEBUG("Before calling register_framebuffer"); - - if(register_framebuffer(&sis_fb_info) < 0) + if(register_framebuffer(sis_fb_info) < 0) { + vfree(sishw_ext.pSR); + vfree(sishw_ext.pCR); + release_mem_region(ivideo.video_base, ivideo.video_size); + release_mem_region(ivideo.mmio_base, sisfb_mmio_size); + printk(KERN_ERR "sisfb: Fatal error: Failed to register framebuffer\n"); + kfree(sis_fb_info); return -EINVAL; - + } + sisfb_registered = 1; - printk(KERN_INFO "sisfb: Installed SISFB_GET_INFO ioctl (%x)\n", SISFB_GET_INFO); + printk(KERN_DEBUG "sisfb: Installed SISFB_GET_INFO ioctl (%x)\n", SISFB_GET_INFO); + printk(KERN_DEBUG "sisfb: Installed SISFB_GET_VBRSTATUS ioctl (%x)\n", SISFB_GET_VBRSTATUS); printk(KERN_INFO "sisfb: 2D acceleration is %s, scrolling mode %s\n", sisfb_accel ? "enabled" : "disabled", - sisfb_ypan ? "ypan" : "redraw"); + sisfb_ypan ? (sisfb_max ? "ypan (auto-max)" : "ypan (no auto-max)") : "redraw"); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) printk(KERN_INFO "fb%d: %s frame buffer device, Version %d.%d.%02d\n", - GET_FB_IDX(sis_fb_info.node), sis_fb_info.modename, VER_MAJOR, VER_MINOR, + GET_FB_IDX(sis_fb_info->node), sis_fb_info->modename, VER_MAJOR, VER_MINOR, VER_LEVEL); -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) +#else printk(KERN_INFO "fb%d: %s frame buffer device, Version %d.%d.%02d\n", - sis_fb_info.node, myid, VER_MAJOR, VER_MINOR, VER_LEVEL); + sis_fb_info->node, myid, VER_MAJOR, VER_MINOR, VER_LEVEL); #endif - } /* TW: if mode = "none" */ + printk(KERN_INFO "sisfb: (C) 2001-2004 Thomas Winischhofer.\n"); + + } /* if mode = "none" */ return 0; } @@ -4562,38 +4987,47 @@ static int vesa = -1; static unsigned int rate = 0; static unsigned int crt1off = 1; static unsigned int mem = 0; -static unsigned int dstn = 0; static char *forcecrt2type = NULL; static int forcecrt1 = -1; static char *queuemode = NULL; static int pdc = 0; static int noaccel = -1; static int noypan = -1; +static int nomax = -1; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) static int inverse = 0; #endif static int userom = 1; static int useoem = -1; static char *tvstandard = NULL; +static int nocrt2rate = 0; +static int scalelcd = -1; +static char *specialtiming = NULL; +static int lvdshl = -1; -MODULE_DESCRIPTION("SiS 300/540/630/730/315/550/650/740/330 framebuffer driver"); +MODULE_DESCRIPTION("SiS 300/540/630/730/315/550/650/651/661/740/741/330/760 framebuffer driver"); MODULE_LICENSE("GPL"); -MODULE_AUTHOR("SiS; Thomas Winischhofer ; Various others"); +MODULE_AUTHOR("Thomas Winischhofer ; SiS; Various others"); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) MODULE_PARM(mode, "s"); MODULE_PARM_DESC(mode, "\nSelects the desired display mode in the format [X]x[Y]x[Depth], eg.\n" - "800x600x16 (default: none if sisfb is a module; this leaves the\n" - "console untouched and the driver will only do the video memory\n" - "management for eg. DRM/DRI; 800x600x8 if sisfb is in the kernel)"); + "1024x768x16. Other formats supported include XxY-Depth and\n" + "XxY-Depth@Rate. If the parameter is only one (decimal or hexadecimal)\n" + "number, it will be interpreted as a VESA mode number. (default: none if\n" + "sisfb is a module; this leaves the console untouched and the driver will\n" + "only do the video memory management for eg. DRM/DRI; 800x600x8 if sisfb\n" + "is in the kernel)"); #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) MODULE_PARM(mode, "s"); MODULE_PARM_DESC(mode, - "\nSelects the desired default display mode in the format [X]x[Y]x[Depth],\n" - "eg. 1024x768x16 (default: 800x600x8)"); -#endif + "\nSelects the desired default display mode in the format XxYxDepth,\n" + "eg. 1024x768x16. Other formats supported include XxY-Depth and\n" + "XxY-Depth@Rate. If the parameter is only one (decimal or hexadecimal)\n" + "number, it will be interpreted as a VESA mode number. (default: 800x600x8)"); +#endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) MODULE_PARM(vesa, "i"); @@ -4603,17 +5037,18 @@ MODULE_PARM_DESC(vesa, "and the driver will only do the video memory management for eg. DRM/DRI;\n" "0x0103 if sisfb is in the kernel)"); #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) MODULE_PARM(vesa, "i"); MODULE_PARM_DESC(vesa, "\nSelects the desired default display mode by VESA defined mode number, eg.\n" "0x117 (default: 0x0103)"); -#endif +#endif MODULE_PARM(rate, "i"); MODULE_PARM_DESC(rate, "\nSelects the desired vertical refresh rate for CRT1 (external VGA) in Hz.\n" - "(default: 60)"); + "If the mode is specified in the format XxY-Depth@Rate, this parameter\n" + "will be ignored (default: 60)"); MODULE_PARM(crt1off, "i"); MODULE_PARM_DESC(crt1off, @@ -4624,14 +5059,9 @@ MODULE_PARM_DESC(filter, "\nSelects TV flicker filter type (only for systems with a SiS301 video bridge).\n" "(Possible values 0-7, default: [no filter])"); -MODULE_PARM(dstn, "i"); -MODULE_PARM_DESC(dstn, - "\nSelects DSTN/FSTN display mode for SiS550. This sets CRT2 type to LCD and\n" - "overrides forcecrt2type setting. (1=ON, 0=OFF) (default: 0)"); - MODULE_PARM(queuemode, "s"); MODULE_PARM_DESC(queuemode, - "\nSelects the queue mode on 315/550/650/740/330. Possible choices are AGP, VRAM or\n" + "\nSelects the queue mode on 315/550/65x/74x/330/760. Possible choices are AGP, VRAM,\n" "MMIO. AGP is only available if the kernel has AGP support. The queue mode is\n" "important to programs using the 2D/3D accelerator of the SiS chip. The modes\n" "require a totally different way of programming the engines. If any mode than\n" @@ -4642,11 +5072,12 @@ MODULE_PARM_DESC(queuemode, MODULE_PARM(mem, "i"); MODULE_PARM_DESC(mem, "\nDetermines the beginning of the video memory heap in KB. This heap is used\n" - "for video RAM management for eg. DRM/DRI. The default depends on the amount\n" - "of video RAM available. If 8MB of video RAM or less is available, the heap\n" - "starts at 4096KB, if between 8 and 16MB are available at 8192KB, otherwise\n" - "at 12288KB. The value is to be specified without 'KB' and should match\n" - "the MaxXFBMem setting for XFree 4.x (x>=2)."); + "for video RAM management for eg. DRM/DRI. On 300 series, the default depends\n" + "on the amount of video RAM available. If 8MB of video RAM or less is available,\n" + "the heap starts at 4096KB, if between 8 and 16MB are available at 8192KB,\n" + "otherwise at 12288KB. On 315 and Xabre series, the heap is 1MB by default. The\n" + "value is to be specified without 'KB' and should match the MaxXFBMem setting for\n" + "XFree 4.x (x>=2)."); MODULE_PARM(forcecrt2type, "s"); MODULE_PARM_DESC(forcecrt2type, @@ -4664,65 +5095,97 @@ MODULE_PARM_DESC(forcecrt1, MODULE_PARM(pdc, "i"); MODULE_PARM_DESC(pdc, - "\n(300 series only) This is for manually selecting the LCD panel delay\n" - "compensation. The driver should detect this correctly in most cases; however,\n" - "sometimes this is not possible. If you see 'small waves' on the LCD, try\n" - "setting this to 4, 32 or 24. If the problem persists, try other values\n" - "between 4 and 60 in steps of 4. (default: [autodetected])"); + "\nThis is for manually selecting the LCD panel delay compensation. The driver\n" + "should detect this correctly in most cases; however, sometimes this is not\n" + "possible. If you see 'small waves' on the LCD, try setting this to 4, 32 or 24\n" + "on a 300 series chipset; 3 or 51 on a 315 series chipset. If the problem persists,\n" + "try other values (on 300 series: between 4 and 60 in steps of 4; on 315 series:\n" + "and value from 0 to 255). (default: [autodetected])"); MODULE_PARM(noaccel, "i"); MODULE_PARM_DESC(noaccel, - "\nIf set to anything other than 0, 2D acceleration and y-panning will be\n" - "disabled. (default: 0)"); + "\nIf set to anything other than 0, 2D acceleration will be disabled.\n" + "(default: 0)"); MODULE_PARM(noypan, "i"); MODULE_PARM_DESC(noypan, "\nIf set to anything other than 0, y-panning will be disabled and scrolling\n" - "will be performed by redrawing the screen. This required 2D acceleration, so\n" - "if the option noaccel is set, y-panning will be disabled. (default: 0)"); + "will be performed by redrawing the screen. (default: 0)"); + +MODULE_PARM(nomax, "i"); +MODULE_PARM_DESC(nomax, + "\nIf y-panning is enabled, sisfb will by default use the entire available video\n" + "memory for the virtual screen in order to optimize scrolling performance. If this\n" + "is set to anything other than 0, sisfb will not do this and thereby enable the user\n" + "to positively specify a virtual Y size of the screen using fbset. (default: 0)\n"); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) MODULE_PARM(inverse, "i"); MODULE_PARM_DESC(inverse, "\nSetting this to anything but 0 should invert the display colors, but this\n" - "does not seem to work. (default: 0)"); + "does not seem to work. (default: 0)"); #endif MODULE_PARM(userom, "i"); MODULE_PARM_DESC(userom, "\nSetting this to 0 keeps sisfb from using the video BIOS data which is needed\n" - "for some LCD and TV setup. (default: 1)"); + "for some LCD and TV setup. (default: 1)"); MODULE_PARM(useoem, "i"); MODULE_PARM_DESC(useoem, "\nSetting this to 0 keeps sisfb from using its internel OEM data for some LCD\n" - "panels and TV connector types. (default: auto)"); + "panels and TV connector types. (default: [auto])"); MODULE_PARM(tvstandard, "s"); MODULE_PARM_DESC(tvstandard, "\nThis allows overriding the BIOS default for the TV standard. Valid choices are\n" - "pal and ntsc. (default: auto)"); + "pal and ntsc. (default: [auto])"); + +MODULE_PARM(nocrt2rate, "i"); +MODULE_PARM_DESC(nocrt2rate, + "\nSetting this to 1 will force the driver to use the default refresh rate for\n" + "CRT2 if CRT2 type is VGA. (default: 0, use same rate as CRT1)"); + +MODULE_PARM(scalelcd, "i"); +MODULE_PARM_DESC(scalelcd, + "\nSetting this to 1 will force the driver to scale the LCD image to the panel's\n" + "native resolution. Setting it to 0 will disable scaling; if the panel can scale\n" + "by itself, it will probably do this, otherwise you will see a black bar around\n" + "the screen image. Default: [autodetect if panel can scale]"); + +MODULE_PARM(specialtiming, "s"); + +MODULE_PARM(lvdshl, "i"); + int init_module(void) { int err; - + + SiS_Pr.UsePanelScaler = -1; + SiS_Pr.SiS_CustomT = CUT_NONE; + SiS_Pr.LVDSHL = -1; + + ivideo.refresh_rate = sisfb_parm_rate = rate; + + if((scalelcd == 0) || (scalelcd == 1)) { + SiS_Pr.UsePanelScaler = scalelcd ^ 1; + } + if(mode) - sisfb_search_mode(mode); + sisfb_search_mode(mode, FALSE); else if(vesa != -1) - sisfb_search_vesamode(vesa); - else -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) + sisfb_search_vesamode(vesa, FALSE); + else +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* For 2.4, set mode=none if no mode is given */ sisfb_mode_idx = MODE_INDEX_NONE; #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) - /* For 2.5, we don't need this "mode=none" stuff anymore */ + /* For 2.5, we don't need this "mode=none" stuff anymore */ sisfb_mode_idx = DEFAULT_MODE; #endif - ivideo.refresh_rate = rate; - if(forcecrt2type) sisfb_search_crt2type(forcecrt2type); @@ -4746,11 +5209,12 @@ int init_module(void) if(noypan == 1) sisfb_ypan = 0; else if(noypan == 0) sisfb_ypan = 1; - /* TW: Panning only with acceleration */ - if(sisfb_accel == 0) sisfb_ypan = 0; + if(nomax == 1) sisfb_max = 0; + else if(nomax == 0) sisfb_max = 1; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) if(inverse) sisfb_inverse = 1; + sisfb_fontname[0] = '\0'; #endif if(mem) sisfb_mem = mem; @@ -4759,24 +5223,21 @@ int init_module(void) sisfb_useoem = useoem; - enable_dstn = dstn; - - /* TW: DSTN overrules forcecrt2type */ - if (enable_dstn) sisfb_crt2type = DISPTYPE_LCD; - if (queuemode) sisfb_search_queuemode(queuemode); - /* TW: If other queuemode than MMIO, disable 2D accel and ypan */ + /* If other queuemode than MMIO, disable 2D accel and ypan */ if((sisfb_queuemode != -1) && (sisfb_queuemode != MMIO_CMD)) { sisfb_accel = 0; - sisfb_ypan = 0; } - if(pdc) { - if(!(pdc & ~0x3c)) { - sisfb_pdc = pdc & 0x3c; - } - } + if(pdc) sisfb_pdc = pdc & 0x3c; + + sisfb_nocrt2rate = nocrt2rate; + + if(specialtiming) + sisfb_search_specialtiming(specialtiming); + + if((lvdshl >= 0) && (lvdshl <= 3)) SiS_Pr.LVDSHL = lvdshl; if((err = sisfb_init()) < 0) return err; @@ -4785,12 +5246,16 @@ int init_module(void) void cleanup_module(void) { - /* TW: Release mem regions */ + /* Unmap */ + iounmap(ivideo.video_vbase); + iounmap(ivideo.mmio_vbase); + + /* Release mem regions */ release_mem_region(ivideo.video_base, ivideo.video_size); release_mem_region(ivideo.mmio_base, sisfb_mmio_size); - + #ifdef CONFIG_MTRR - /* TW: Release MTRR region */ + /* Release MTRR region */ if(ivideo.mtrr) { mtrr_del(ivideo.mtrr, (unsigned int)ivideo.video_base, @@ -4800,13 +5265,24 @@ void cleanup_module(void) /* Unregister the framebuffer */ if(sisfb_registered) { - unregister_framebuffer(&sis_fb_info); + unregister_framebuffer(sis_fb_info); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && (defined(NEWFBDEV)) + framebuffer_release(sis_fb_info); +#else + kfree(sis_fb_info); +#endif } - + if(sishw_ext.pSR) vfree(sishw_ext.pSR); if(sishw_ext.pCR) vfree(sishw_ext.pCR); - /* TODO: Restore the initial mode */ + /* TODO: Restore the initial mode + * This sounds easy but is as good as impossible + * on many machines with SiS chip and video bridge + * since text modes are always set up differently + * from machine to machine. Depends on the type + * of integration between chipset and bridge. + */ printk(KERN_INFO "sisfb: Module unloaded\n"); } diff -puN drivers/video/sis/sis_main.h~sisfb-update drivers/video/sis/sis_main.h --- 25/drivers/video/sis/sis_main.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/sis_main.h 2004-01-22 03:06:55.000000000 -0800 @@ -1,24 +1,42 @@ +/* + * SiS 300/630/730/540/315/550/650/651/M650/661FX/M661FX/740/741/330/760 + * frame buffer driver for Linux kernels 2.4.x and 2.5.x + * + * Copyright (C) 2001-2004 Thomas Winischhofer, Vienna, Austria. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the named License, + * or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + */ + #ifndef _SISFB_MAIN #define _SISFB_MAIN -/* Comments and changes marked with "TW" by Thomas Winischhofer */ - #include "vstruct.h" /* ------------------- Constant Definitions ------------------------- */ -#undef LINUXBIOS /* turn this on when compiling for LINUXBIOS */ #define AGPOFF /* default is turn off AGP */ #define SISFAIL(x) do { printk(x "\n"); return -EINVAL; } while(0) #define VER_MAJOR 1 #define VER_MINOR 6 -#define VER_LEVEL 1 +#define VER_LEVEL 25 #include "sis.h" -/* TW: To be included in pci_ids.h */ +/* To be included in pci_ids.h */ #ifndef PCI_DEVICE_ID_SI_650_VGA #define PCI_DEVICE_ID_SI_650_VGA 0x6325 #endif @@ -31,13 +49,28 @@ #ifndef PCI_DEVICE_ID_SI_330 #define PCI_DEVICE_ID_SI_330 0x0330 #endif +#ifndef PCI_DEVICE_ID_SI_660_VGA +#define PCI_DEVICE_ID_SI_660_VGA 0x6330 +#endif +#ifndef PCI_DEVICE_ID_SI_660 +#define PCI_DEVICE_ID_SI_660 0x0661 +#endif +#ifndef PCI_DEVICE_ID_SI_741 +#define PCI_DEVICE_ID_SI_741 0x0741 +#endif +#ifndef PCI_DEVICE_ID_SI_660 +#define PCI_DEVICE_ID_SI_660 0x0660 +#endif +#ifndef PCI_DEVICE_ID_SI_760 +#define PCI_DEVICE_ID_SI_760 0x0760 +#endif /* To be included in fb.h */ #ifndef FB_ACCEL_SIS_GLAMOUR_2 -#define FB_ACCEL_SIS_GLAMOUR_2 40 /* SiS 315, 650, 740 */ +#define FB_ACCEL_SIS_GLAMOUR_2 40 /* SiS 315, 65x, 740, 661, 741 */ #endif #ifndef FB_ACCEL_SIS_XABRE -#define FB_ACCEL_SIS_XABRE 41 /* SiS 330 ("Xabre") */ +#define FB_ACCEL_SIS_XABRE 41 /* SiS 330 ("Xabre"), 760 */ #endif #define MAX_ROM_SCAN 0x10000 @@ -53,13 +86,12 @@ #define TURBO_QUEUE_AREA_SIZE 0x80000 /* 512K */ #endif -/* For 315 series */ +/* For 315/Xabre series */ #ifdef CONFIG_FB_SIS_315 #define COMMAND_QUEUE_AREA_SIZE 0x80000 /* 512K */ #define COMMAND_QUEUE_THRESHOLD 0x1F #endif -/* TW */ #define HW_CURSOR_AREA_SIZE_315 0x4000 /* 16K */ #define HW_CURSOR_AREA_SIZE_300 0x1000 /* 4K */ @@ -95,7 +127,9 @@ #define SISDAC2A SISPART5 #define SISDAC2D (SISPART5 + 1) #define SISMISCR (SiS_Pr.RelIO + 0x1c) -#define SISINPSTAT (SiS_Pr.RelIO + 0x2a) +#define SISMISCW SiS_Pr.SiS_P3c2 +#define SISINPSTAT (SiS_Pr.RelIO + 0x2a) +#define SISPEL SiS_Pr.SiS_P3c6 #define IND_SIS_PASSWORD 0x05 /* SRs */ #define IND_SIS_COLOR_MODE 0x06 @@ -149,14 +183,6 @@ #define SIS_DATA_BUS_64 0x01 #define SIS_DATA_BUS_128 0x02 -#define SIS315_DRAM_SIZE_MASK 0xF0 /* 315 SR14 */ -#define SIS315_DRAM_SIZE_2MB 0x01 -#define SIS315_DRAM_SIZE_4MB 0x02 -#define SIS315_DRAM_SIZE_8MB 0x03 -#define SIS315_DRAM_SIZE_16MB 0x04 -#define SIS315_DRAM_SIZE_32MB 0x05 -#define SIS315_DRAM_SIZE_64MB 0x06 -#define SIS315_DRAM_SIZE_128MB 0x07 #define SIS315_DATA_BUS_MASK 0x02 #define SIS315_DATA_BUS_64 0x00 #define SIS315_DATA_BUS_128 0x01 @@ -166,17 +192,6 @@ #define SIS315_ASYM_DDR 0x02 #define SIS315_DUAL_CHANNEL_1_RANK 0x3 -#define SIS550_DRAM_SIZE_MASK 0x3F /* 550/650/740 SR14 */ -#define SIS550_DRAM_SIZE_4MB 0x00 -#define SIS550_DRAM_SIZE_8MB 0x01 -#define SIS550_DRAM_SIZE_16MB 0x03 -#define SIS550_DRAM_SIZE_24MB 0x05 -#define SIS550_DRAM_SIZE_32MB 0x07 -#define SIS550_DRAM_SIZE_64MB 0x0F -#define SIS550_DRAM_SIZE_96MB 0x17 -#define SIS550_DRAM_SIZE_128MB 0x1F -#define SIS550_DRAM_SIZE_256MB 0x3F - #define SIS_SCRATCH_REG_1A_MASK 0x10 #define SIS_ENABLE_2D 0x40 /* SR1E */ @@ -217,7 +232,7 @@ #define SIS_VB_TV (SIS_VB_COMPOSITE | SIS_VB_SVIDEO | \ SIS_VB_SCART | SIS_VB_HIVISION) -#define SIS_EXTERNAL_CHIP_MASK 0x0E /* CR37 */ +#define SIS_EXTERNAL_CHIP_MASK 0x0E /* CR37 (< SiS 660) */ #define SIS_EXTERNAL_CHIP_SIS301 0x01 /* in CR37 << 1 ! */ #define SIS_EXTERNAL_CHIP_LVDS 0x02 /* in CR37 << 1 ! */ #define SIS_EXTERNAL_CHIP_TRUMPION 0x03 /* in CR37 << 1 ! */ @@ -236,12 +251,33 @@ #define BRI_DRAM_SIZE_32MB 0x04 #define BRI_DRAM_SIZE_64MB 0x05 -#define HW_DEVICE_EXTENSION SIS_HW_DEVICE_INFO -#define PHW_DEVICE_EXTENSION PSIS_HW_DEVICE_INFO +#define HW_DEVICE_EXTENSION SIS_HW_INFO +#define PHW_DEVICE_EXTENSION PSIS_HW_INFO #define SR_BUFFER_SIZE 5 #define CR_BUFFER_SIZE 5 +/* entries for disp_state - deprecated as of 1.6.02 */ +#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 + +/* Deprecated as of 1.6.02 - use vbflags instead */ +#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 + /* Useful macros */ #define inSISREG(base) inb(base) #define outSISREG(base,val) outb(val,base) @@ -281,50 +317,48 @@ /* ------------------- Global Variables ----------------------------- */ /* Fbcon variables */ -static struct fb_info sis_fb_info; - -static int video_type = FB_TYPE_PACKED_PIXELS; +static struct fb_info *sis_fb_info; 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 + .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 sisfb_fix = { .id = "SiS", .type = FB_TYPE_PACKED_PIXELS, - .xpanstep = 1, + .xpanstep = 0, .ypanstep = 1, }; -static char myid[20]; +static char myid[40]; static u32 pseudo_palette[17]; #endif @@ -347,62 +381,55 @@ static union { } sis_fbcon_cmap; static int sisfb_inverse = 0; +static int currcon = 0; #endif -/* display status */ +/* global flags */ static int sisfb_off = 0; static int sisfb_crt1off = 0; static int sisfb_forcecrt1 = -1; static int sisvga_enabled = 0; static int sisfb_userom = 1; static int sisfb_useoem = -1; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -static int currcon = 0; -#endif - -/* global flags */ -static int sisfb_registered; -static int sisfb_tvmode = 0; +static int sisfb_parm_rate = -1; +static int sisfb_registered = 0; static int sisfb_mem = 0; static int sisfb_pdc = 0; -static int enable_dstn = 0; static int sisfb_ypan = -1; +static int sisfb_max = -1; +static int sisfb_nocrt2rate = 0; +static int sisfb_dstn = 0; +static int sisfb_fstn = 0; VGA_ENGINE sisvga_engine = UNKNOWN_VGA; int sisfb_accel = -1; -/* TW: These are to adapted according to VGA_ENGINE type */ +/* These are to adapted according to VGA_ENGINE type */ static int sisfb_hwcursor_size = 0; static int sisfb_CRT2_write_enable = 0; -int sisfb_crt2type = -1; /* TW: CRT2 type (for overriding autodetection) */ -int sisfb_tvplug = -1; /* PR: Tv plug type (for overriding autodetection) */ +int sisfb_crt2type = -1; /* CRT2 type (for overriding autodetection) */ +int sisfb_tvplug = -1; /* Tv plug type (for overriding autodetection) */ -int sisfb_queuemode = -1; /* TW: Use MMIO queue mode by default (310/325 series only) */ +int sisfb_queuemode = -1; /* Use MMIO queue mode by default (315 series only) */ unsigned char sisfb_detectedpdc = 0; unsigned char sisfb_detectedlcda = 0xff; -/* data for sis components */ +/* data for sis hardware ("par") */ struct video_info ivideo; -/* TW: For ioctl SISFB_GET_INFO */ +/* For ioctl SISFB_GET_INFO */ sisfb_info sisfbinfo; -/* TW: Hardware extension; contains data on hardware */ -HW_DEVICE_EXTENSION sishw_ext = { - NULL, NULL, FALSE, NULL, NULL, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - NULL, NULL, NULL, NULL, - {0, 0, 0, 0}, - 0 -}; +/* Hardware info; contains data on hardware */ +SIS_HW_INFO sishw_ext; -/* TW: SiS private structure */ +/* SiS private structure */ SiS_Private SiS_Pr; -/* card parameters */ +/* Card parameters */ static unsigned long sisfb_mmio_size = 0; static u8 sisfb_caps = 0; @@ -412,7 +439,7 @@ typedef enum _SIS_CMDTYPE { VM_CMD_QUEUE, } SIS_CMDTYPE; -/* Supported SiS Chips list */ +/* List of supported chips */ static struct board { u16 vendor, device; const char *name; @@ -424,16 +451,17 @@ static struct board { {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_315, "SIS 315"}, {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_315PRO, "SIS 315PRO"}, {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_550_VGA, "SIS 550 VGA"}, - {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_650_VGA, "SIS 650/M650/651/740 VGA"}, + {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_650_VGA, "SIS 65x/M65x/740 VGA"}, {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_330, "SIS 330"}, + {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_660_VGA, "SIS 661FX/M661FX/741/760 VGA"}, {0, 0, NULL} }; #define MD_SIS300 1 #define MD_SIS315 2 -/* mode table */ -/* NOT const - will be patched for 1280x960 mode number chaos reasons */ +/* Mode table */ +/* NOT const - will be patched for 1280x768 mode number chaos reasons */ struct _sisbios_mode { char name[15]; u8 mode_no; @@ -447,14 +475,33 @@ struct _sisbios_mode { u16 rows; u8 chipset; } sisbios_mode[] = { -#define MODE_INDEX_NONE 0 /* TW: index for mode=none */ - {"none", 0xFF, 0x0000, 0x0000, 0, 0, 0, 0, 0, 0, MD_SIS300|MD_SIS315}, /* TW: for mode "none" */ - {"320x240x16", 0x56, 0x0000, 0x0000, 320, 240, 16, 1, 40, 15, MD_SIS315}, - {"320x480x8", 0x5A, 0x0000, 0x0000, 320, 480, 8, 1, 40, 30, MD_SIS315}, /* TW: FSTN */ - {"320x480x16", 0x5B, 0x0000, 0x0000, 320, 480, 16, 1, 40, 30, MD_SIS315}, /* TW: FSTN */ - {"640x480x8", 0x2E, 0x0101, 0x0101, 640, 480, 8, 1, 80, 30, MD_SIS300|MD_SIS315}, +#define MODE_INDEX_NONE 0 /* index for mode=none */ + {"none", 0xff, 0x0000, 0x0000, 0, 0, 0, 0, 0, 0, MD_SIS300|MD_SIS315}, + {"320x200x8", 0x59, 0x0138, 0x0000, 320, 200, 8, 1, 40, 12, MD_SIS300|MD_SIS315}, + {"320x200x16", 0x41, 0x010e, 0x0000, 320, 200, 16, 1, 40, 12, MD_SIS300|MD_SIS315}, + {"320x200x24", 0x4f, 0x0000, 0x0000, 320, 200, 32, 1, 40, 12, MD_SIS300|MD_SIS315}, /* TW: That's for people who mix up color- and fb depth */ + {"320x200x32", 0x4f, 0x0000, 0x0000, 320, 200, 32, 1, 40, 12, MD_SIS300|MD_SIS315}, + {"320x240x8", 0x50, 0x0132, 0x0000, 320, 240, 8, 1, 40, 15, MD_SIS300|MD_SIS315}, + {"320x240x16", 0x56, 0x0135, 0x0000, 320, 240, 16, 1, 40, 15, MD_SIS300|MD_SIS315}, + {"320x240x24", 0x53, 0x0000, 0x0000, 320, 240, 32, 1, 40, 15, MD_SIS300|MD_SIS315}, + {"320x240x32", 0x53, 0x0000, 0x0000, 320, 240, 32, 1, 40, 15, MD_SIS300|MD_SIS315}, + {"320x240x8", 0x5a, 0x0132, 0x0000, 320, 480, 8, 1, 40, 30, MD_SIS315}, /* TW: FSTN */ + {"320x240x16", 0x5b, 0x0135, 0x0000, 320, 480, 16, 1, 40, 30, MD_SIS315}, /* TW: FSTN */ + {"400x300x8", 0x51, 0x0133, 0x0000, 400, 300, 8, 1, 50, 18, MD_SIS300|MD_SIS315}, + {"400x300x16", 0x57, 0x0136, 0x0000, 400, 300, 16, 1, 50, 18, MD_SIS300|MD_SIS315}, + {"400x300x24", 0x54, 0x0000, 0x0000, 400, 300, 32, 1, 50, 18, MD_SIS300|MD_SIS315}, + {"400x300x32", 0x54, 0x0000, 0x0000, 400, 300, 32, 1, 50, 18, MD_SIS300|MD_SIS315}, + {"512x384x8", 0x52, 0x0000, 0x0000, 512, 384, 8, 1, 64, 24, MD_SIS300|MD_SIS315}, + {"512x384x16", 0x58, 0x0000, 0x0000, 512, 384, 16, 1, 64, 24, MD_SIS300|MD_SIS315}, + {"512x384x24", 0x5c, 0x0000, 0x0000, 512, 384, 32, 1, 64, 24, MD_SIS300|MD_SIS315}, + {"512x384x32", 0x5c, 0x0000, 0x0000, 512, 384, 32, 1, 64, 24, MD_SIS300|MD_SIS315}, + {"640x400x8", 0x2f, 0x0000, 0x0000, 640, 400, 8, 1, 80, 25, MD_SIS300|MD_SIS315}, + {"640x400x16", 0x5d, 0x0000, 0x0000, 640, 400, 16, 1, 80, 25, MD_SIS300|MD_SIS315}, + {"640x400x24", 0x5e, 0x0000, 0x0000, 640, 400, 32, 1, 80, 25, MD_SIS300|MD_SIS315}, + {"640x400x32", 0x5e, 0x0000, 0x0000, 640, 400, 32, 1, 80, 25, MD_SIS300|MD_SIS315}, + {"640x480x8", 0x2e, 0x0101, 0x0101, 640, 480, 8, 1, 80, 30, MD_SIS300|MD_SIS315}, {"640x480x16", 0x44, 0x0111, 0x0111, 640, 480, 16, 1, 80, 30, MD_SIS300|MD_SIS315}, - {"640x480x24", 0x62, 0x013a, 0x0112, 640, 480, 32, 1, 80, 30, MD_SIS300|MD_SIS315}, /* TW: That's for people who mix up color- and fb depth */ + {"640x480x24", 0x62, 0x013a, 0x0112, 640, 480, 32, 1, 80, 30, MD_SIS300|MD_SIS315}, {"640x480x32", 0x62, 0x013a, 0x0112, 640, 480, 32, 1, 80, 30, MD_SIS300|MD_SIS315}, {"720x480x8", 0x31, 0x0000, 0x0000, 720, 480, 8, 1, 90, 30, MD_SIS300|MD_SIS315}, {"720x480x16", 0x33, 0x0000, 0x0000, 720, 480, 16, 1, 90, 30, MD_SIS300|MD_SIS315}, @@ -464,63 +511,87 @@ struct _sisbios_mode { {"720x576x16", 0x34, 0x0000, 0x0000, 720, 576, 16, 1, 90, 36, MD_SIS300|MD_SIS315}, {"720x576x24", 0x36, 0x0000, 0x0000, 720, 576, 32, 1, 90, 36, MD_SIS300|MD_SIS315}, {"720x576x32", 0x36, 0x0000, 0x0000, 720, 576, 32, 1, 90, 36, MD_SIS300|MD_SIS315}, + {"768x576x8", 0x5f, 0x0000, 0x0000, 768, 576, 8, 1, 96, 36, MD_SIS300|MD_SIS315}, + {"768x576x16", 0x60, 0x0000, 0x0000, 768, 576, 16, 1, 96, 36, MD_SIS300|MD_SIS315}, + {"768x576x24", 0x61, 0x0000, 0x0000, 768, 576, 32, 1, 96, 36, MD_SIS300|MD_SIS315}, + {"768x576x32", 0x61, 0x0000, 0x0000, 768, 576, 32, 1, 96, 36, MD_SIS300|MD_SIS315}, {"800x480x8", 0x70, 0x0000, 0x0000, 800, 480, 8, 1, 100, 30, MD_SIS300|MD_SIS315}, {"800x480x16", 0x7a, 0x0000, 0x0000, 800, 480, 16, 1, 100, 30, MD_SIS300|MD_SIS315}, {"800x480x24", 0x76, 0x0000, 0x0000, 800, 480, 32, 1, 100, 30, MD_SIS300|MD_SIS315}, {"800x480x32", 0x76, 0x0000, 0x0000, 800, 480, 32, 1, 100, 30, MD_SIS300|MD_SIS315}, -#define DEFAULT_MODE 20 /* TW: index for 800x600x8 */ -#define DEFAULT_LCDMODE 20 /* TW: index for 800x600x8 */ -#define DEFAULT_TVMODE 20 /* TW: index for 800x600x8 */ +#define DEFAULT_MODE 43 /* index for 800x600x8 */ +#define DEFAULT_LCDMODE 43 /* index for 800x600x8 */ +#define DEFAULT_TVMODE 43 /* index for 800x600x8 */ {"800x600x8", 0x30, 0x0103, 0x0103, 800, 600, 8, 2, 100, 37, MD_SIS300|MD_SIS315}, {"800x600x16", 0x47, 0x0114, 0x0114, 800, 600, 16, 2, 100, 37, MD_SIS300|MD_SIS315}, {"800x600x24", 0x63, 0x013b, 0x0115, 800, 600, 32, 2, 100, 37, MD_SIS300|MD_SIS315}, {"800x600x32", 0x63, 0x013b, 0x0115, 800, 600, 32, 2, 100, 37, MD_SIS300|MD_SIS315}, + {"848x480x8", 0x39, 0x0000, 0x0000, 848, 480, 8, 2, 106, 30, MD_SIS300|MD_SIS315}, + {"848x480x16", 0x3b, 0x0000, 0x0000, 848, 480, 16, 2, 106, 30, MD_SIS300|MD_SIS315}, + {"848x480x24", 0x3e, 0x0000, 0x0000, 848, 480, 32, 2, 106, 30, MD_SIS300|MD_SIS315}, + {"848x480x32", 0x3e, 0x0000, 0x0000, 848, 480, 32, 2, 106, 30, MD_SIS300|MD_SIS315}, + {"856x480x8", 0x3f, 0x0000, 0x0000, 856, 480, 8, 2, 107, 30, MD_SIS300|MD_SIS315}, + {"856x480x16", 0x42, 0x0000, 0x0000, 856, 480, 16, 2, 107, 30, MD_SIS300|MD_SIS315}, + {"856x480x24", 0x45, 0x0000, 0x0000, 856, 480, 32, 2, 107, 30, MD_SIS300|MD_SIS315}, + {"856x480x32", 0x45, 0x0000, 0x0000, 856, 480, 32, 2, 107, 30, MD_SIS300|MD_SIS315}, {"1024x576x8", 0x71, 0x0000, 0x0000, 1024, 576, 8, 1, 128, 36, MD_SIS300|MD_SIS315}, {"1024x576x16", 0x74, 0x0000, 0x0000, 1024, 576, 16, 1, 128, 36, MD_SIS300|MD_SIS315}, {"1024x576x24", 0x77, 0x0000, 0x0000, 1024, 576, 32, 1, 128, 36, MD_SIS300|MD_SIS315}, {"1024x576x32", 0x77, 0x0000, 0x0000, 1024, 576, 32, 1, 128, 36, MD_SIS300|MD_SIS315}, - {"1024x600x8", 0x20, 0x0000, 0x0000, 1024, 600, 8, 1, 128, 37, MD_SIS300 }, /* TW: 300 series only */ + {"1024x600x8", 0x20, 0x0000, 0x0000, 1024, 600, 8, 1, 128, 37, MD_SIS300 }, {"1024x600x16", 0x21, 0x0000, 0x0000, 1024, 600, 16, 1, 128, 37, MD_SIS300 }, {"1024x600x24", 0x22, 0x0000, 0x0000, 1024, 600, 32, 1, 128, 37, MD_SIS300 }, {"1024x600x32", 0x22, 0x0000, 0x0000, 1024, 600, 32, 1, 128, 37, MD_SIS300 }, {"1024x768x8", 0x38, 0x0105, 0x0105, 1024, 768, 8, 2, 128, 48, MD_SIS300|MD_SIS315}, - {"1024x768x16", 0x4A, 0x0117, 0x0117, 1024, 768, 16, 2, 128, 48, MD_SIS300|MD_SIS315}, + {"1024x768x16", 0x4a, 0x0117, 0x0117, 1024, 768, 16, 2, 128, 48, MD_SIS300|MD_SIS315}, {"1024x768x24", 0x64, 0x013c, 0x0118, 1024, 768, 32, 2, 128, 48, MD_SIS300|MD_SIS315}, {"1024x768x32", 0x64, 0x013c, 0x0118, 1024, 768, 32, 2, 128, 48, MD_SIS300|MD_SIS315}, - {"1152x768x8", 0x23, 0x0000, 0x0000, 1152, 768, 8, 1, 144, 48, MD_SIS300 }, /* TW: 300 series only */ + {"1152x768x8", 0x23, 0x0000, 0x0000, 1152, 768, 8, 1, 144, 48, MD_SIS300 }, {"1152x768x16", 0x24, 0x0000, 0x0000, 1152, 768, 16, 1, 144, 48, MD_SIS300 }, {"1152x768x24", 0x25, 0x0000, 0x0000, 1152, 768, 32, 1, 144, 48, MD_SIS300 }, {"1152x768x32", 0x25, 0x0000, 0x0000, 1152, 768, 32, 1, 144, 48, MD_SIS300 }, + {"1152x864x8", 0x29, 0x0000, 0x0000, 1152, 864, 8, 1, 144, 54, MD_SIS300|MD_SIS315}, + {"1152x864x16", 0x2a, 0x0000, 0x0000, 1152, 864, 16, 1, 144, 54, MD_SIS300|MD_SIS315}, + {"1152x864x24", 0x2b, 0x0000, 0x0000, 1152, 864, 32, 1, 144, 54, MD_SIS300|MD_SIS315}, + {"1152x864x32", 0x2b, 0x0000, 0x0000, 1152, 864, 32, 1, 144, 54, MD_SIS300|MD_SIS315}, {"1280x720x8", 0x79, 0x0000, 0x0000, 1280, 720, 8, 1, 160, 45, MD_SIS300|MD_SIS315}, {"1280x720x16", 0x75, 0x0000, 0x0000, 1280, 720, 16, 1, 160, 45, MD_SIS300|MD_SIS315}, {"1280x720x24", 0x78, 0x0000, 0x0000, 1280, 720, 32, 1, 160, 45, MD_SIS300|MD_SIS315}, {"1280x720x32", 0x78, 0x0000, 0x0000, 1280, 720, 32, 1, 160, 45, MD_SIS300|MD_SIS315}, - {"1280x768x8", 0x23, 0x0000, 0x0000, 1280, 768, 8, 1, 160, 48, MD_SIS315}, /* TW: 310/325 series only */ - {"1280x768x16", 0x24, 0x0000, 0x0000, 1280, 768, 16, 1, 160, 48, MD_SIS315}, - {"1280x768x24", 0x25, 0x0000, 0x0000, 1280, 768, 32, 1, 160, 48, MD_SIS315}, - {"1280x768x32", 0x25, 0x0000, 0x0000, 1280, 768, 32, 1, 160, 48, MD_SIS315}, -#define MODEINDEX_1280x960 48 - {"1280x960x8", 0x7C, 0x0000, 0x0000, 1280, 960, 8, 1, 160, 60, MD_SIS300|MD_SIS315}, /* TW: Modenumbers being patched */ - {"1280x960x16", 0x7D, 0x0000, 0x0000, 1280, 960, 16, 1, 160, 60, MD_SIS300|MD_SIS315}, - {"1280x960x24", 0x7E, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60, MD_SIS300|MD_SIS315}, - {"1280x960x32", 0x7E, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60, MD_SIS300|MD_SIS315}, - {"1280x1024x8", 0x3A, 0x0107, 0x0107, 1280, 1024, 8, 2, 160, 64, MD_SIS300|MD_SIS315}, - {"1280x1024x16", 0x4D, 0x011a, 0x011a, 1280, 1024, 16, 2, 160, 64, MD_SIS300|MD_SIS315}, +#define MODEINDEX_1280x768 79 + {"1280x768x8", 0x23, 0x0000, 0x0000, 1280, 768, 8, 1, 160, 48, MD_SIS300|MD_SIS315}, + {"1280x768x16", 0x24, 0x0000, 0x0000, 1280, 768, 16, 1, 160, 48, MD_SIS300|MD_SIS315}, + {"1280x768x24", 0x25, 0x0000, 0x0000, 1280, 768, 32, 1, 160, 48, MD_SIS300|MD_SIS315}, + {"1280x768x32", 0x25, 0x0000, 0x0000, 1280, 768, 32, 1, 160, 48, MD_SIS300|MD_SIS315}, + {"1280x960x8", 0x7c, 0x0000, 0x0000, 1280, 960, 8, 1, 160, 60, MD_SIS300|MD_SIS315}, + {"1280x960x16", 0x7d, 0x0000, 0x0000, 1280, 960, 16, 1, 160, 60, MD_SIS300|MD_SIS315}, + {"1280x960x24", 0x7e, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60, MD_SIS300|MD_SIS315}, + {"1280x960x32", 0x7e, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60, MD_SIS300|MD_SIS315}, + {"1280x1024x8", 0x3a, 0x0107, 0x0107, 1280, 1024, 8, 2, 160, 64, MD_SIS300|MD_SIS315}, + {"1280x1024x16", 0x4d, 0x011a, 0x011a, 1280, 1024, 16, 2, 160, 64, MD_SIS300|MD_SIS315}, {"1280x1024x24", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 2, 160, 64, MD_SIS300|MD_SIS315}, {"1280x1024x32", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 2, 160, 64, MD_SIS300|MD_SIS315}, - {"1400x1050x8", 0x26, 0x0000, 0x0000, 1400, 1050, 8, 1, 175, 65, MD_SIS315}, /* TW: 310/325 series only */ + {"1360x768x8", 0x48, 0x0000, 0x0000, 1360, 768, 8, 1, 170, 48, MD_SIS300|MD_SIS315}, + {"1360x768x16", 0x4b, 0x0000, 0x0000, 1360, 768, 16, 1, 170, 48, MD_SIS300|MD_SIS315}, + {"1360x768x24", 0x4e, 0x0000, 0x0000, 1360, 768, 32, 1, 170, 48, MD_SIS300|MD_SIS315}, + {"1360x768x32", 0x4e, 0x0000, 0x0000, 1360, 768, 32, 1, 170, 48, MD_SIS300|MD_SIS315}, + {"1360x1024x8", 0x67, 0x0000, 0x0000, 1360, 1024, 8, 1, 170, 64, MD_SIS300 }, + {"1360x1024x16", 0x6f, 0x0000, 0x0000, 1360, 1024, 16, 1, 170, 64, MD_SIS300 }, + {"1360x1024x24", 0x72, 0x0000, 0x0000, 1360, 1024, 32, 1, 170, 64, MD_SIS300 }, + {"1360x1024x32", 0x72, 0x0000, 0x0000, 1360, 1024, 32, 1, 170, 64, MD_SIS300 }, + {"1400x1050x8", 0x26, 0x0000, 0x0000, 1400, 1050, 8, 1, 175, 65, MD_SIS315}, {"1400x1050x16", 0x27, 0x0000, 0x0000, 1400, 1050, 16, 1, 175, 65, MD_SIS315}, {"1400x1050x24", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65, MD_SIS315}, {"1400x1050x32", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65, MD_SIS315}, - {"1600x1200x8", 0x3C, 0x0130, 0x011c, 1600, 1200, 8, 1, 200, 75, MD_SIS300|MD_SIS315}, - {"1600x1200x16", 0x3D, 0x0131, 0x011e, 1600, 1200, 16, 1, 200, 75, MD_SIS300|MD_SIS315}, + {"1600x1200x8", 0x3c, 0x0130, 0x011c, 1600, 1200, 8, 1, 200, 75, MD_SIS300|MD_SIS315}, + {"1600x1200x16", 0x3d, 0x0131, 0x011e, 1600, 1200, 16, 1, 200, 75, MD_SIS300|MD_SIS315}, {"1600x1200x24", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75, MD_SIS300|MD_SIS315}, {"1600x1200x32", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75, MD_SIS300|MD_SIS315}, {"1920x1440x8", 0x68, 0x013f, 0x0000, 1920, 1440, 8, 1, 240, 75, MD_SIS300|MD_SIS315}, {"1920x1440x16", 0x69, 0x0140, 0x0000, 1920, 1440, 16, 1, 240, 75, MD_SIS300|MD_SIS315}, - {"1920x1440x24", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_SIS300|MD_SIS315}, - {"1920x1440x32", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_SIS300|MD_SIS315}, - {"2048x1536x8", 0x6c, 0x0000, 0x0000, 2048, 1536, 8, 1, 256, 96, MD_SIS315}, /* TW: 310/325 series only */ + {"1920x1440x24", 0x6b, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_SIS300|MD_SIS315}, + {"1920x1440x32", 0x6b, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_SIS300|MD_SIS315}, + {"2048x1536x8", 0x6c, 0x0000, 0x0000, 2048, 1536, 8, 1, 256, 96, MD_SIS315}, {"2048x1536x16", 0x6d, 0x0000, 0x0000, 2048, 1536, 16, 1, 256, 96, MD_SIS315}, {"2048x1536x24", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96, MD_SIS315}, {"2048x1536x32", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96, MD_SIS315}, @@ -536,39 +607,38 @@ int sisfb_mode_idx = -1; / u8 sisfb_mode_no = 0; u8 sisfb_rate_idx = 0; -/* TW: CR36 evaluation */ +/* CR36 evaluation */ const USHORT sis300paneltype[] = - { LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024, - LCD_1280x960, LCD_640x480, LCD_1024x600, LCD_1152x768, - LCD_320x480, LCD_1024x768, LCD_1024x768, LCD_1024x768, - LCD_1024x768, LCD_1024x768, LCD_1024x768, LCD_1024x768 }; + { 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_320x480, LCD_1024x768 }; const USHORT sis310paneltype[] = - { 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_320x480, LCD_1024x768, LCD_1024x768, LCD_1024x768 }; + { 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_640x480_2, LCD_640x480_3, LCD_320x480, LCD_1024x768 }; + +#define FL_550_DSTN 0x01 +#define FL_550_FSTN 0x02 static const struct _sis_crt2type { char name[10]; int type_no; int tvplug_no; + unsigned short flags; } sis_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} + {"NONE", 0, -1, 0}, + {"LCD", CRT2_LCD, -1, 0}, + {"TV", CRT2_TV, -1, 0}, + {"VGA", CRT2_VGA, -1, 0}, + {"SVIDEO", CRT2_TV, TV_SVIDEO, 0}, + {"COMPOSITE", CRT2_TV, TV_AVIDEO, 0}, + {"SCART", CRT2_TV, TV_SCART, 0}, + {"DSTN", CRT2_LCD, -1, FL_550_DSTN}, + {"FSTN", CRT2_LCD, -1, FL_550_FSTN}, + {"\0", -1, -1, 0} }; /* Queue mode selection for 310 series */ @@ -579,9 +649,6 @@ static const struct _sis_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} }; @@ -590,10 +657,8 @@ static const struct _sis_tvtype { char name[6]; int type_no; } sis_tvtype[] = { - {"PAL", 1}, - {"NTSC", 2}, - {"pal", 1}, - {"ntsc", 2}, + {"PAL", TV_PAL}, + {"NTSC", TV_NTSC}, {"\0", -1} }; @@ -602,33 +667,103 @@ static const struct _sis_vrate { u16 xres; u16 yres; u16 refresh; + BOOLEAN SiS730valid32bpp; } sisfb_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, 56}, {2, 800, 600, 60}, {3, 800, 600, 72}, {4, 800, 600, 75}, - {5, 800, 600, 85}, {6, 800, 600, 100}, {7, 800, 600, 120}, {8, 800, 600, 160}, - {1, 1024, 768, 43}, {2, 1024, 768, 60}, {3, 1024, 768, 70}, {4, 1024, 768, 75}, - {5, 1024, 768, 85}, {6, 1024, 768, 100}, {7, 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, 43}, {2, 1280, 1024, 60}, {3, 1280, 1024, 75}, {4, 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} + {1, 320, 200, 70, TRUE}, + {1, 320, 240, 60, TRUE}, + {1, 320, 480, 60, TRUE}, + {1, 400, 300, 60, TRUE}, + {1, 512, 384, 60, TRUE}, + {1, 640, 400, 72, TRUE}, + {1, 640, 480, 60, TRUE}, {2, 640, 480, 72, TRUE}, {3, 640, 480, 75, TRUE}, + {4, 640, 480, 85, TRUE}, {5, 640, 480, 100, TRUE}, {6, 640, 480, 120, TRUE}, + {7, 640, 480, 160, TRUE}, {8, 640, 480, 200, TRUE}, + {1, 720, 480, 60, TRUE}, + {1, 720, 576, 58, TRUE}, + {1, 768, 576, 58, TRUE}, + {1, 800, 480, 60, TRUE}, {2, 800, 480, 75, TRUE}, {3, 800, 480, 85, TRUE}, + {1, 800, 600, 56, TRUE}, {2, 800, 600, 60, TRUE}, {3, 800, 600, 72, TRUE}, + {4, 800, 600, 75, TRUE}, {5, 800, 600, 85, TRUE}, {6, 800, 600, 105, TRUE}, + {7, 800, 600, 120, TRUE}, {8, 800, 600, 160, TRUE}, + {1, 848, 480, 39, TRUE}, {2, 848, 480, 60, TRUE}, + {1, 856, 480, 39, TRUE}, {2, 856, 480, 60, TRUE}, + {1, 1024, 576, 60, TRUE}, {2, 1024, 576, 75, TRUE}, {3, 1024, 576, 85, TRUE}, + {1, 1024, 600, 60, TRUE}, + {1, 1024, 768, 43, TRUE}, {2, 1024, 768, 60, TRUE}, {3, 1024, 768, 70, FALSE}, + {4, 1024, 768, 75, FALSE}, {5, 1024, 768, 85, TRUE}, {6, 1024, 768, 100, TRUE}, + {7, 1024, 768, 120, TRUE}, + {1, 1152, 768, 60, TRUE}, + {1, 1152, 864, 75, TRUE}, {2, 1152, 864, 84, TRUE}, + {1, 1280, 720, 60, TRUE}, {2, 1280, 720, 75, TRUE}, {3, 1280, 720, 85, TRUE}, + {1, 1280, 768, 60, TRUE}, + {1, 1280, 960, 60, TRUE}, {2, 1280, 960, 85, TRUE}, + {1, 1280, 1024, 43, TRUE}, {2, 1280, 1024, 60, TRUE}, {3, 1280, 1024, 75, TRUE}, + {4, 1280, 1024, 85, TRUE}, + {1, 1360, 768, 60, TRUE}, + {1, 1360, 1024, 59, TRUE}, + {1, 1400, 1050, 60, TRUE}, {2, 1400, 1050, 75, TRUE}, + {1, 1600, 1200, 60, TRUE}, {2, 1600, 1200, 65, TRUE}, {3, 1600, 1200, 70, TRUE}, + {4, 1600, 1200, 75, TRUE}, {5, 1600, 1200, 85, TRUE}, {6, 1600, 1200, 100, TRUE}, + {7, 1600, 1200, 120, TRUE}, + {1, 1920, 1440, 60, TRUE}, {2, 1920, 1440, 65, TRUE}, {3, 1920, 1440, 70, TRUE}, + {4, 1920, 1440, 75, TRUE}, {5, 1920, 1440, 85, TRUE}, {6, 1920, 1440, 100, TRUE}, + {1, 2048, 1536, 60, TRUE}, {2, 2048, 1536, 65, TRUE}, {3, 2048, 1536, 70, TRUE}, + {4, 2048, 1536, 75, TRUE}, {5, 2048, 1536, 85, TRUE}, + {0, 0, 0, 0, FALSE} }; +static struct sisfb_monitor { + u16 hmin; + u16 hmax; + u16 vmin; + u16 vmax; + u32 dclockmax; + u8 feature; + BOOLEAN datavalid; +} sisfb_thismonitor; + +static const struct _sisfbddcsmodes { + u32 mask; + u16 h; + u16 v; + u32 d; +} sisfb_ddcsmodes[] = { + { 0x10000, 67, 75, 108000}, + { 0x08000, 48, 72, 50000}, + { 0x04000, 46, 75, 49500}, + { 0x01000, 35, 43, 44900}, + { 0x00800, 48, 60, 65000}, + { 0x00400, 56, 70, 75000}, + { 0x00200, 60, 75, 78800}, + { 0x00100, 80, 75, 135000}, + { 0x00020, 31, 60, 25200}, + { 0x00008, 38, 72, 31500}, + { 0x00004, 37, 75, 31500}, + { 0x00002, 35, 56, 36000}, + { 0x00001, 38, 60, 40000} +}; + +static const struct _sisfbddcfmodes { + u16 x; + u16 y; + u16 v; + u16 h; + u32 d; +} sisfb_ddcfmodes[] = { + { 1280, 1024, 85, 92, 157500}, + { 1600, 1200, 60, 75, 162000}, + { 1600, 1200, 65, 82, 175500}, + { 1600, 1200, 70, 88, 189000}, + { 1600, 1200, 75, 94, 202500}, + { 1600, 1200, 85, 107,229500}, + { 1920, 1440, 60, 90, 234000}, + { 1920, 1440, 75, 113,297000} +}; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) +static u8 sisfb_lastrates[128]; +#endif + static const struct _chswtable { int subsysVendor; int subsysCard; @@ -636,9 +771,152 @@ static const struct _chswtable { char *cardName; } mychswtable[] = { { 0x1631, 0x1002, "Mitachi", "0x1002" }, + { 0x1071, 0x7521, "Mitac" , "7521P" }, { 0, 0, "" , "" } }; +static const struct _customttable { + unsigned short chipID; + char *biosversion; + char *biosdate; + unsigned long bioschksum; + unsigned short biosFootprintAddr[5]; + unsigned char biosFootprintData[5]; + unsigned short pcisubsysvendor; + unsigned short pcisubsyscard; + char *vendorName; + char *cardName; + unsigned long SpecialID; + char *optionName; +} mycustomttable[] = { + { SIS_630, "2.00.07", "09/27/2002-13:38:25", + 0x3240A8, + { 0x220, 0x227, 0x228, 0x229, 0x0ee }, + { 0x01, 0xe3, 0x9a, 0x6a, 0xef }, + 0x1039, 0x6300, + "Barco", "iQ R200L/300/400", CUT_BARCO1366, "BARCO_1366" + }, + { SIS_630, "2.00.07", "09/27/2002-13:38:25", + 0x323FBD, + { 0x220, 0x227, 0x228, 0x229, 0x0ee }, + { 0x00, 0x5a, 0x64, 0x41, 0xef }, + 0x1039, 0x6300, + "Barco", "iQ G200L/300/400/500", CUT_BARCO1024, "BARCO_1024" + }, + { SIS_650, "", "", + 0, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x0e11, 0x083c, + "Inventec (Compaq)", "3017cl/3045US", CUT_COMPAQ12802, "COMPAQ_1280" + }, + { SIS_650, "", "", + 0, + { 0x00c, 0, 0, 0, 0 }, + { 'e' , 0, 0, 0, 0 }, + 0x1558, 0x0287, + "Clevo", "L285/L287 (Version 1)", CUT_CLEVO1024, "CLEVO_L28X_1" + }, + { SIS_650, "", "", + 0, + { 0x00c, 0, 0, 0, 0 }, + { 'y' , 0, 0, 0, 0 }, + 0x1558, 0x0287, + "Clevo", "L285/L287 (Version 2)", CUT_CLEVO10242, "CLEVO_L28X_2" + }, + { SIS_650, "", "", + 0, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1558, 0x0400, /* possibly 401 and 402 as well; not panelsize specific (?) */ + "Clevo", "D400S/D410S/D400H/D410H", CUT_CLEVO1400, "CLEVO_D4X0" + }, + { SIS_650, "", "", + 0, /* Shift LCD in LCD-via-CRT1 mode */ + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1558, 0x2263, + "Clevo", "D22ES/D27ES", CUT_UNIWILL1024, "CLEVO_D2X0ES" + }, + { SIS_650, "", "", + 0, /* Shift LCD in LCD-via-CRT1 mode */ + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1734, 0x101f, + "Uniwill", "N243S9", CUT_UNIWILL1024, "UNIWILL_N243S9" + }, + { SIS_650, "", "", + 0, /* Shift LCD in LCD-via-CRT1 mode */ + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1584, 0x5103, + "Uniwill", "N35BS1", CUT_UNIWILL10242, "UNIWILL_N35BS1" + }, + { SIS_650, "1.09.2c", "", /* Other versions, too? */ + 0, /* Shift LCD in LCD-via-CRT1 mode */ + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1019, 0x0f05, + "ECS", "A928", CUT_UNIWILL1024, "ECS_A928" + }, + { SIS_740, "1.11.27a", "", + 0, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1043, 0x1612, + "Asus", "L3000D/L3500D", CUT_ASUSL3000D, "ASUS_L3X00" + }, + { SIS_650, "1.10.9k", "", + 0, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1025, 0x0028, + "Acer", "Aspire 1700", CUT_ACER1280, "ACER_ASPIRE1700" + }, + { SIS_650, "1.10.7w", "", + 0, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x14c0, 0x0012, + "Compal", "??? (V1)", CUT_COMPAL1400_1, "COMPAL_1400_1" + }, + { SIS_650, "1.10.7x", "", + 0, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x14c0, 0x0012, + "Compal", "??? (V2)", CUT_COMPAL1400_2, "COMPAL_1400_2" + }, + { SIS_650, "1.10.8o", "", + 0, /* For EMI (unknown) */ + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1043, 0x1612, + "Asus", "A2H (V1)", CUT_ASUSA2H_1, "ASUS_A2H_1" + }, + { SIS_650, "1.10.8q", "", + 0, /* For EMI */ + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1043, 0x1612, + "Asus", "A2H (V2)", CUT_ASUSA2H_2, "ASUS_A2H_2" + }, + { 4321, "", "", /* never autodetected */ + 0, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0, 0, + "Generic", "LVDS/Parallel 848x480", CUT_PANEL848, "PANEL848x480" + }, + { 0, "", "", + 0, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + 0, 0, + "", "", CUT_NONE, "" + } +}; + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* Offscreen layout */ typedef struct _SIS_GLYINFO { @@ -648,6 +926,8 @@ typedef struct _SIS_GLYINFO { u8 gmask[72]; int ngmask; } SIS_GLYINFO; + +static char sisfb_fontname[40]; #endif typedef struct _SIS_OH { @@ -677,7 +957,6 @@ static unsigned long sisfb_heap_end; static unsigned long sisfb_heap_size; static SIS_HEAP sisfb_heap; -// Eden Chen static const struct _sis_TV_filter { u8 filter[9][4]; } sis_TV_filter[] = { @@ -697,7 +976,7 @@ static const struct _sis_TV_filter { {0xF8,0xF4,0x18,0x38}, {0xFC,0xFB,0x14,0x2A}, {0x00,0x00,0x10,0x20}, - {0x00,0x04,0x10,0x18}, + {0x00,0x04,0x10,0x18}, {0xFF,0xFF,0xFF,0xFF} }}, { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_2 */ {0xF5,0xEE,0x1B,0x44}, @@ -717,7 +996,7 @@ static const struct _sis_TV_filter { {0xF9,0x0A,0x17,0x0C}, {0x00,0x07,0x10,0x12}, {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_4 */ + { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_4 - 320 */ {0x00,0xE0,0x10,0x60}, {0x00,0xEE,0x10,0x44}, {0x00,0xF4,0x10,0x38}, @@ -726,7 +1005,7 @@ static const struct _sis_TV_filter { {0x00,0x00,0x10,0x20}, {0x00,0x04,0x10,0x18}, {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_5 */ + { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_5 - 640 */ {0xF5,0xEE,0x1B,0x44}, {0xF8,0xF4,0x18,0x38}, {0xEB,0x04,0x25,0x18}, @@ -735,7 +1014,7 @@ static const struct _sis_TV_filter { {0xFA,0x06,0x16,0x14}, {0x00,0x04,0x10,0x18}, {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_6 */ + { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_6 - 720 */ {0xEB,0x04,0x25,0x18}, {0xE7,0x0E,0x29,0x04}, {0xEE,0x0C,0x22,0x08}, @@ -744,7 +1023,7 @@ static const struct _sis_TV_filter { {0xFC,0x0A,0x14,0x0C}, {0x00,0x08,0x10,0x10}, {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_7 */ + { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_7 - 800 */ {0xEC,0x02,0x24,0x1C}, {0xF2,0x04,0x1E,0x18}, {0xEB,0x15,0x25,0xF6}, @@ -789,7 +1068,7 @@ static const struct _sis_TV_filter { {0xFB,0x04,0x15,0x18}, {0x00,0x06,0x10,0x14}, {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* PALFilter_4 */ + { {{0x00,0x00,0x00,0x40}, /* PALFilter_4 - 320 */ {0x00,0xE0,0x10,0x60}, {0x00,0xEE,0x10,0x44}, {0x00,0xF4,0x10,0x38}, @@ -798,7 +1077,7 @@ static const struct _sis_TV_filter { {0x00,0x00,0x10,0x20}, {0x00,0x04,0x10,0x18}, {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* PALFilter_5 */ + { {{0x00,0x00,0x00,0x40}, /* PALFilter_5 - 640 */ {0xF5,0xEE,0x1B,0x44}, {0xF8,0xF4,0x18,0x38}, {0xF1,0xF7,0x1F,0x32}, @@ -807,7 +1086,7 @@ static const struct _sis_TV_filter { {0xFB,0x01,0x15,0x1E}, {0x00,0x04,0x10,0x18}, {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* PALFilter_6 */ + { {{0x00,0x00,0x00,0x40}, /* PALFilter_6 - 720 */ {0xF5,0xEE,0x1B,0x2A}, {0xEE,0xFE,0x22,0x24}, {0xF3,0x00,0x1D,0x20}, @@ -816,7 +1095,7 @@ static const struct _sis_TV_filter { {0xFB,0x04,0x15,0x18}, {0x00,0x06,0x10,0x14}, {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* PALFilter_7 */ + { {{0x00,0x00,0x00,0x40}, /* PALFilter_7 - 800 */ {0xF5,0xEE,0x1B,0x44}, {0xF8,0xF4,0x18,0x38}, {0xFC,0xFB,0x14,0x2A}, @@ -829,9 +1108,8 @@ static const struct _sis_TV_filter { static int filter = -1; static unsigned char filter_tb; -//~Eden Chen -/* ---------------------- Routine prototypes ------------------------- */ +/* ---------------------- Prototypes ------------------------- */ /* Interface used by the world */ #ifndef MODULE @@ -894,10 +1172,6 @@ extern void fbcon_sis_fillrect(struc const struct fb_fillrect *rect); extern void fbcon_sis_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_sis_sync(struct fb_info *info); static int sisfb_ioctl(struct inode *inode, struct file *file, @@ -905,14 +1179,14 @@ static int sisfb_ioctl(struct inode unsigned long arg, struct fb_info *info); extern int sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, - PSIS_HW_DEVICE_INFO HwDeviceExtension, + PSIS_HW_INFO HwDeviceExtension, unsigned char modeno, unsigned char rateindex); -extern int sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, +extern int sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_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); + unsigned int *sync, unsigned int *vmode); #endif static int sisfb_get_fix(struct fb_fix_screeninfo *fix, int con, @@ -923,9 +1197,9 @@ extern int sisfb_initaccel(void); extern void sisfb_syncaccel(void); /* Internal general routines */ -static void sisfb_search_mode(const char *name); -static int sisfb_validate_mode(int modeindex); -static u8 sisfb_search_refresh_rate(unsigned int rate); +static void sisfb_search_mode(char *name, BOOLEAN quiet); +static int sisfb_validate_mode(int modeindex, unsigned long vbflags); +static u8 sisfb_search_refresh_rate(unsigned int rate, int index); static int sisfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *fb_info); @@ -939,6 +1213,11 @@ static BOOLEAN sisfb_CheckVBRetrace(voi static BOOLEAN sisfbcheckvretracecrt2(void); static BOOLEAN sisfbcheckvretracecrt1(void); static BOOLEAN sisfb_bridgeisslave(void); +static void sisfb_detect_VB_connect(void); +static void sisfb_get_VB_type(void); + +static void sisfb_handle_ddc(struct sisfb_monitor *monitor, int crtno); +static BOOLEAN sisfb_interpret_edid(struct sisfb_monitor *monitor, unsigned char *buffer); /* SiS-specific Export functions */ void sis_dispinfo(struct ap_data *rec); @@ -952,15 +1231,9 @@ u32 sisfb_get_reg3(u16 port) /* Chipset-dependent internal routines */ #ifdef CONFIG_FB_SIS_300 static int sisfb_get_dram_size_300(void); -static void sisfb_detect_VB_connect_300(void); -static void sisfb_get_VB_type_300(void); -static int sisfb_has_VB_300(void); #endif #ifdef CONFIG_FB_SIS_315 static int sisfb_get_dram_size_315(void); -static void sisfb_detect_VB_connect_315(void); -static void sisfb_get_VB_type_315(void); -static int sisfb_has_VB_315(void); #endif /* Internal heap routines */ @@ -973,30 +1246,46 @@ static SIS_OH *sisfb_poh_free(unsigned static void sisfb_free_node(SIS_OH *poh); /* Internal routines to access PCI configuration space */ -BOOLEAN sisfb_query_VGA_config_space(PSIS_HW_DEVICE_INFO psishw_ext, +BOOLEAN sisfb_query_VGA_config_space(PSIS_HW_INFO psishw_ext, unsigned long offset, unsigned long set, unsigned long *value); -BOOLEAN sisfb_query_north_bridge_space(PSIS_HW_DEVICE_INFO psishw_ext, +BOOLEAN sisfb_query_north_bridge_space(PSIS_HW_INFO psishw_ext, unsigned long offset, unsigned long set, unsigned long *value); +/* Sensing routines */ +static void SiS_Sense30x(void); +static int SISDoSense(int tempbl, int tempbh, int tempcl, int tempch); +static void SiS_SenseCh(void); /* Routines from init.c/init301.c */ -extern void SiSRegInit(SiS_Private *SiS_Pr, USHORT BaseAddr); -extern BOOLEAN SiSInit(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo); -extern void SiS_SetEnableDstn(SiS_Private *SiS_Pr); -extern void SiS_LongWait(SiS_Private *SiS_Pr); +extern USHORT SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, BOOLEAN FSTN); +extern USHORT SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, + BOOLEAN FSTN, USHORT CustomT, int LCDwith, int LCDheight); +extern USHORT SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth); +extern USHORT SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth); + +extern void SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr); +extern BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceInfo, USHORT ModeNo); +extern void SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable); +extern void SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable); + +extern BOOLEAN sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceExtension, + unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex); -/* TW: Chrontel TV functions */ +/* Chrontel TV functions */ extern USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx); extern void SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempbx); extern USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx); extern void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx); extern void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh); extern void SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime); +extern void SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo); +extern USHORT SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, + USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer); +extern USHORT SiS_ReadDDC1Bit(SiS_Private *SiS_Pr); +extern void SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceInfo); +extern void SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr); +extern void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceInfo); +extern void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceInfo); -/* TW: Sensing routines */ -void SiS_Sense30x(void); -int SISDoSense(int tempbl, int tempbh, int tempcl, int tempch); -void SiS_SenseCh(void); #endif diff -puN drivers/video/sis/vgatypes.h~sisfb-update drivers/video/sis/vgatypes.h --- 25/drivers/video/sis/vgatypes.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/vgatypes.h 2004-01-22 03:06:55.000000000 -0800 @@ -1,18 +1,69 @@ +/* $XFree86$ */ +/* + * General type definitions for universal mode switching modules + * + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the Linux kernel, the following license terms + * apply: + * + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Otherwise, the following license terms apply: + * + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) All advertising materials mentioning features or use of this software + * * must display the following acknowledgement: "This product includes + * * software developed by Thomas Winischhofer, Vienna, Austria." + * * 4) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * + */ + #ifndef _VGATYPES_ #define _VGATYPES_ #ifdef LINUX_XF86 +#include "xf86Version.h" #include "xf86Pci.h" #endif -#ifdef LINUX_KERNEL /* TW: We don't want the X driver to depend on kernel source */ +#ifdef LINUX_KERNEL /* We don't want the X driver to depend on kernel source */ #include #endif -#ifndef TC -#define far -#endif - #ifndef FALSE #define FALSE 0 #endif @@ -49,47 +100,34 @@ typedef unsigned short USHORT; typedef unsigned long ULONG; #endif -#ifndef PUCHAR -typedef UCHAR far *PUCHAR; -#endif - -#ifndef PUSHORT -typedef USHORT far *PUSHORT; -#endif - -#ifndef PULONG -typedef ULONG far *PULONG; -#endif - -#ifndef PVOID -typedef void far *PVOID; -#endif -#ifndef VOID -typedef void VOID; -#endif - #ifndef BOOLEAN typedef UCHAR BOOLEAN; #endif -#ifndef WINCE_HEADER #ifndef bool typedef UCHAR bool; #endif -#endif /*WINCE_HEADER*/ -#ifndef VBIOS_VER_MAX_LENGTH -#define VBIOS_VER_MAX_LENGTH 4 +#ifdef LINUX_KERNEL +typedef unsigned long SISIOADDRESS; +#endif + +#ifdef LINUX_XF86 +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,0,0,0) +typedef unsigned long IOADDRESS; +typedef unsigned long SISIOADDRESS; +#else +typedef IOADDRESS SISIOADDRESS; +#endif #endif -#ifndef LINUX_KERNEL /* For kernel, this is defined in sisfb.h */ -#ifndef WIN2000 +#ifndef LINUX_KERNEL /* For the linux kernel, this is defined in sisfb.h */ #ifndef SIS_CHIP_TYPE typedef enum _SIS_CHIP_TYPE { SIS_VGALegacy = 0, #ifdef LINUX_XF86 - SIS_530, /* TW */ - SIS_OLD, /* TW */ + SIS_530, + SIS_OLD, #endif SIS_300, SIS_630, @@ -101,30 +139,32 @@ typedef enum _SIS_CHIP_TYPE { SIS_550, SIS_650, SIS_740, - SIS_330, + SIS_330, + SIS_661, + SIS_741, + SIS_660, + SIS_760, MAX_SIS_CHIP } SIS_CHIP_TYPE; #endif #endif -#endif -#ifndef WIN2000 #ifndef SIS_VB_CHIP_TYPE typedef enum _SIS_VB_CHIP_TYPE { VB_CHIP_Legacy = 0, VB_CHIP_301, - VB_CHIP_301B, + 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 } SIS_VB_CHIP_TYPE; #endif -#endif -#ifndef WIN2000 #ifndef SIS_LCD_TYPE typedef enum _SIS_LCD_TYPE { LCD_INVALID = 0, @@ -136,18 +176,22 @@ typedef enum _SIS_LCD_TYPE { LCD_1600x1200, LCD_1920x1440, LCD_2048x1536, - LCD_320x480, /* TW: FSTN */ + LCD_320x480, /* FSTN, DSTN */ LCD_1400x1050, LCD_1152x864, LCD_1152x768, LCD_1280x768, LCD_1024x600, + LCD_640x480_2, /* FSTN, DSTN */ + LCD_640x480_3, /* FSTN, DSTN */ + LCD_848x480, + LCD_1280x800, + LCD_1680x1050, + LCD_CUSTOM, LCD_UNKNOWN } SIS_LCD_TYPE; #endif -#endif -#ifndef WIN2000 /* mark by Paul, Move definition to sisv.h*/ #ifndef PSIS_DSReg typedef struct _SIS_DSReg { @@ -156,36 +200,27 @@ typedef struct _SIS_DSReg } SIS_DSReg, *PSIS_DSReg; #endif -#ifndef SIS_HW_DEVICE_INFO - -typedef struct _SIS_HW_DEVICE_INFO SIS_HW_DEVICE_INFO, *PSIS_HW_DEVICE_INFO; +#ifndef SIS_HW_INFO -typedef BOOLEAN (*PSIS_QUERYSPACE) (PSIS_HW_DEVICE_INFO, ULONG, ULONG, ULONG *); +typedef struct _SIS_HW_INFO SIS_HW_INFO, *PSIS_HW_INFO; +typedef BOOLEAN (*PSIS_QUERYSPACE) (PSIS_HW_INFO, ULONG, ULONG, ULONG *); -struct _SIS_HW_DEVICE_INFO +struct _SIS_HW_INFO { - PVOID pDevice; /* The pointer to the physical device data structure - in each OS or NULL for unused. */ - UCHAR *pjVirtualRomBase; /* base virtual address of VBIOS ROM Space */ - /* or base virtual address of ROM image file. */ - /* if NULL, then read from pjROMImage; */ - /* Note:ROM image file is the file of VBIOS ROM */ +#ifdef LINUX_XF86 + PCITAG PciTag; /* PCI Tag */ +#endif - BOOLEAN UseROM; /* TW: Use the ROM image if provided */ - - UCHAR *pjCustomizedROMImage;/* base virtual address of ROM image file. */ - /* wincE:ROM image file is the file for OEM */ - /* customized table */ - /* Linux: not used */ - /* NT : not used */ - /* Note : pjCustomizedROMImage=NULL if no ROM image file */ + UCHAR *pjVirtualRomBase; /* ROM image */ + + BOOLEAN UseROM; /* Use the ROM image if provided */ UCHAR *pjVideoMemoryAddress;/* base virtual memory address */ /* of Linear VGA memory */ ULONG ulVideoMemorySize; /* size, in bytes, of the memory on the board */ - ULONG ulIOAddress; /* base I/O address of VGA ports (0x3B0) */ + SISIOADDRESS ulIOAddress; /* base I/O address of VGA ports (0x3B0) */ UCHAR jChipType; /* Used to Identify SiS Graphics Chip */ /* defined in the data structure type */ /* "SIS_CHIP_TYPE" */ @@ -194,20 +229,12 @@ struct _SIS_HW_DEVICE_INFO UCHAR ujVBChipID; /* the ID of video bridge */ /* defined in the data structure type */ /* "SIS_VB_CHIP_TYPE" */ +#ifdef LINUX_KERNEL + BOOLEAN Is301BDH; +#endif - USHORT usExternalChip; /* NO VB or other video bridge(not */ + USHORT usExternalChip; /* NO VB or other video bridge (other than */ /* SiS video bridge) */ - /* if ujVBChipID = VB_CHIP_UNKNOWN, */ - /* then bit0=1 : LVDS,bit1=1 : trumpion, */ - /* bit2=1 : CH7005 & no video bridge if */ - /* usExternalChip = 0. */ - /* Note: CR37[3:1]: */ - /* 001:SiS 301 */ - /* 010:LVDS */ - /* 011:Trumpion LVDS Scaling Chip */ - /* 100:LVDS(LCD-out)+Chrontel 7005 */ - /* 101:Single Chrontel 7005 */ - /* TW: This has changed on 310/325 series! */ ULONG ulCRT2LCDType; /* defined in the data structure type */ /* "SIS_LCD_TYPE" */ @@ -215,6 +242,8 @@ struct _SIS_HW_DEVICE_INFO BOOLEAN bIntegratedMMEnabled;/* supporting integration MM enable */ BOOLEAN bSkipDramSizing; /* True: Skip video memory sizing. */ + +#ifdef LINUX_KERNEL PSIS_DSReg pSR; /* restore SR registers in initial function. */ /* end data :(idx, val) = (FF, FF). */ /* Note : restore SR registers if */ @@ -224,38 +253,25 @@ struct _SIS_HW_DEVICE_INFO /* end data :(idx, val) = (FF, FF) */ /* Note : restore cR registers if */ /* bSkipDramSizing = TRUE */ +#endif PSIS_QUERYSPACE pQueryVGAConfigSpace; /* Get/Set VGA Configuration */ /* space */ PSIS_QUERYSPACE pQueryNorthBridgeSpace;/* Get/Set North Bridge */ /* space */ - - UCHAR szVBIOSVer[VBIOS_VER_MAX_LENGTH]; - - UCHAR pdc; /* TW: PanelDelayCompensation */ - -#ifdef LINUX_KERNEL - BOOLEAN Is301BDH; -#endif - -#ifdef LINUX_XF86 - PCITAG PciTag; /* PCI Tag for Linux XF86 */ -#endif }; #endif -#endif - -/* TW: Addtional IOCTL for communication sisfb <> X driver */ -/* If changing this, sisfb.h must also be changed (for sisfb) */ +/* Addtional IOCTL for communication sisfb <> X driver */ +/* If changing this, sisfb.h must also be changed (for sisfb) */ #ifdef LINUX_XF86 /* We don't want the X driver to depend on the kernel source */ -/* TW: ioctl for identifying and giving some info (esp. memory heap start) */ +/* ioctl for identifying and giving some info (esp. memory heap start) */ #define SISFB_GET_INFO 0x80046ef8 /* Wow, what a terrible hack... */ -/* TW: Structure argument for SISFB_GET_INFO ioctl */ +/* Structure argument for SISFB_GET_INFO ioctl */ typedef struct _SISFB_INFO sisfb_info, *psisfb_info; struct _SISFB_INFO { @@ -284,86 +300,19 @@ struct _SISFB_INFO { unsigned char sisfb_lcda; - char reserved[235]; /* for future use */ -}; -#endif + unsigned long sisfb_vbflags; + unsigned long sisfb_currentvbflags; -#ifndef WIN2000 -#ifndef WINCE_HEADER -#ifndef BUS_DATA_TYPE -typedef enum _BUS_DATA_TYPE { - ConfigurationSpaceUndefined = -1, - Cmos, - EisaConfiguration, - Pos, - CbusConfiguration, - PCIConfiguration, - VMEConfiguration, - NuBusConfiguration, - PCMCIAConfiguration, - MPIConfiguration, - MPSAConfiguration, - PNPISAConfiguration, - MaximumBusDataType -} BUS_DATA_TYPE, *PBUS_DATA_TYPE; -#endif -#endif /* WINCE_HEADER */ - -#ifndef PCI_TYPE0_ADDRESSES -#define PCI_TYPE0_ADDRESSES 6 -#endif - -#ifndef PCI_TYPE1_ADDRESSES -#define PCI_TYPE1_ADDRESSES 2 -#endif - -#ifndef WINCE_HEADER -#ifndef PCI_COMMON_CONFIG -typedef struct _PCI_COMMON_CONFIG { - USHORT VendorID; /* (ro) */ - USHORT DeviceID; /* (ro) */ - USHORT Command; /* Device control */ - USHORT Status; - UCHAR RevisionID; /* (ro) */ - UCHAR ProgIf; /* (ro) */ - UCHAR SubClass; /* (ro) */ - UCHAR BaseClass; /* (ro) */ - UCHAR CacheLineSize; /* (ro+) */ - UCHAR LatencyTimer; /* (ro+) */ - UCHAR HeaderType; /* (ro) */ - UCHAR BIST; /* Built in self test */ - - union { - struct _PCI_HEADER_TYPE_0 { - ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; - ULONG CIS; - USHORT SubVendorID; - USHORT SubSystemID; - ULONG ROMBaseAddress; - ULONG Reserved2[2]; - - UCHAR InterruptLine; /* */ - UCHAR InterruptPin; /* (ro) */ - UCHAR MinimumGrant; /* (ro) */ - UCHAR MaximumLatency; /* (ro) */ - } type0; - - - } u; - - UCHAR DeviceSpecific[192]; - -} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; -#endif -#endif /* WINCE_HEADER */ + int sisfb_scalelcd; + unsigned long sisfb_specialtiming; -#ifndef FIELD_OFFSET -#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field)) -#endif + unsigned char sisfb_haveemi; + unsigned char sisfb_emi30,sisfb_emi31,sisfb_emi32,sisfb_emi33; + unsigned char sisfb_haveemilcd; -#ifndef PCI_COMMON_HDR_LENGTH -#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET (PCI_COMMON_CONFIG, DeviceSpecific)) -#endif + char reserved[213]; /* for future use */ +}; #endif #endif + diff -puN drivers/video/sis/vstruct.h~sisfb-update drivers/video/sis/vstruct.h --- 25/drivers/video/sis/vstruct.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/drivers/video/sis/vstruct.h 2004-01-22 03:06:55.000000000 -0800 @@ -1,3 +1,57 @@ +/* $XFree86$ */ +/* + * General structure definitions for universal mode switching modules + * + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the Linux kernel, the following license terms + * apply: + * + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Otherwise, the following license terms apply: + * + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) All advertising materials mentioning features or use of this software + * * must display the following acknowledgement: "This product includes + * * software developed by Thomas Winischhofer, Vienna, Austria." + * * 4) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * + */ + #ifdef _INIT_ #define EXTERN #else @@ -58,7 +112,6 @@ typedef struct _SiS_LVDSCRT1DataStruct UCHAR CR[15]; } SiS_LVDSCRT1DataStruct; -/*add for LCDA*/ typedef struct _SiS_LCDACRT1DataStruct { UCHAR CR[17]; @@ -79,6 +132,7 @@ typedef struct _SiS_StStruct UCHAR VB_StTVFlickerIndex; UCHAR VB_StTVEdgeIndex; UCHAR VB_StTVYFilterIndex; + UCHAR St_PDC; } SiS_StStruct; typedef struct _SiS_VBModeStruct @@ -110,14 +164,13 @@ typedef struct _SiS_ExtStruct { UCHAR Ext_ModeID; USHORT Ext_ModeFlag; - USHORT Ext_ModeInfo; - USHORT Ext_Point; + UCHAR Ext_ModeOffset; USHORT Ext_VESAID; - UCHAR Ext_VESAMEMSize; UCHAR Ext_RESINFO; UCHAR VB_ExtTVFlickerIndex; UCHAR VB_ExtTVEdgeIndex; UCHAR VB_ExtTVYFilterIndex; + UCHAR VB_ExtTVYFilterIndexROM661; UCHAR REFindex; } SiS_ExtStruct; @@ -130,7 +183,7 @@ typedef struct _SiS_Ext2Struct UCHAR ModeID; USHORT XRes; USHORT YRes; - USHORT ROM_OFFSET; + UCHAR Ext_PDC; } SiS_Ext2Struct; typedef struct _SiS_Part2PortTblStruct @@ -149,12 +202,6 @@ typedef struct _SiS_MCLKDataStruct USHORT CLOCK; } SiS_MCLKDataStruct; -typedef struct _SiS_ECLKDataStruct -{ - UCHAR SR2E,SR2F,SR30; - USHORT CLOCK; -} SiS_ECLKDataStruct; - typedef struct _SiS_VCLKDataStruct { UCHAR SR2B,SR2C; @@ -183,41 +230,78 @@ typedef struct _SiS_ModeResInfoStruct typedef UCHAR DRAM4Type[4]; +/* Defines for SiS_CustomT */ +/* Never change these for sisfb compatibility */ +#define CUT_NONE 0 +#define CUT_FORCENONE 1 +#define CUT_BARCO1366 2 +#define CUT_BARCO1024 3 +#define CUT_COMPAQ1280 4 +#define CUT_COMPAQ12802 5 +#define CUT_PANEL848 6 +#define CUT_CLEVO1024 7 +#define CUT_CLEVO10242 8 +#define CUT_CLEVO1400 9 +#define CUT_CLEVO14002 10 +#define CUT_UNIWILL1024 11 +#define CUT_ASUSL3000D 12 +#define CUT_UNIWILL10242 13 +#define CUT_ACER1280 14 +#define CUT_COMPAL1400_1 15 +#define CUT_COMPAL1400_2 16 +#define CUT_ASUSA2H_1 17 +#define CUT_ASUSA2H_2 18 + typedef struct _SiS_Private { #ifdef LINUX_KERNEL - USHORT RelIO; + SISIOADDRESS RelIO; #endif - USHORT SiS_P3c4; - USHORT SiS_P3d4; - USHORT SiS_P3c0; - USHORT SiS_P3ce; - USHORT SiS_P3c2; - USHORT SiS_P3ca; - USHORT SiS_P3c6; - USHORT SiS_P3c7; - USHORT SiS_P3c8; - USHORT SiS_P3c9; - USHORT SiS_P3da; - USHORT SiS_Part1Port; - USHORT SiS_Part2Port; - USHORT SiS_Part3Port; - USHORT SiS_Part4Port; - USHORT SiS_Part5Port; + SISIOADDRESS SiS_P3c4; + SISIOADDRESS SiS_P3d4; + SISIOADDRESS SiS_P3c0; + SISIOADDRESS SiS_P3ce; + SISIOADDRESS SiS_P3c2; + SISIOADDRESS SiS_P3ca; + SISIOADDRESS SiS_P3c6; + SISIOADDRESS SiS_P3c7; + SISIOADDRESS SiS_P3c8; + SISIOADDRESS SiS_P3c9; + SISIOADDRESS SiS_P3cb; + SISIOADDRESS SiS_P3cd; + SISIOADDRESS SiS_P3da; + SISIOADDRESS SiS_Part1Port; + SISIOADDRESS SiS_Part2Port; + SISIOADDRESS SiS_Part3Port; + SISIOADDRESS SiS_Part4Port; + SISIOADDRESS SiS_Part5Port; + SISIOADDRESS SiS_VidCapt; + SISIOADDRESS SiS_VidPlay; USHORT SiS_IF_DEF_LVDS; + USHORT SiS_IF_DEF_CH70xx; + USHORT SiS_IF_DEF_CONEX; USHORT SiS_IF_DEF_TRUMPION; USHORT SiS_IF_DEF_DSTN; USHORT SiS_IF_DEF_FSTN; - USHORT SiS_IF_DEF_CH70xx; - USHORT SiS_IF_DEF_HiVision; + USHORT SiS_SysFlags; UCHAR SiS_VGAINFO; +#ifndef LINUX_KERNEL + USHORT SiS_CP1, SiS_CP2, SiS_CP3, SiS_CP4; +#endif BOOLEAN SiS_UseROM; int SiS_CHOverScan; BOOLEAN SiS_CHSOverScan; BOOLEAN SiS_ChSW; BOOLEAN SiS_UseLCDA; int SiS_UseOEM; + ULONG SiS_CustomT; USHORT SiS_Backup70xx; + BOOLEAN HaveEMI; + BOOLEAN HaveEMILCD; + BOOLEAN OverruleEMI; + UCHAR EMI_30,EMI_31,EMI_32,EMI_33; + UCHAR PDC; + UCHAR SiS_MyCR63; USHORT SiS_CRT1Mode; USHORT SiS_flag_clearbuffer; int SiS_RAMType; @@ -225,12 +309,14 @@ typedef struct _SiS_Private UCHAR SiS_DataBusWidth; USHORT SiS_ModeType; USHORT SiS_VBInfo; + USHORT SiS_TVMode; USHORT SiS_LCDResInfo; USHORT SiS_LCDTypeInfo; USHORT SiS_LCDInfo; + USHORT SiS_LCDInfo661; USHORT SiS_VBType; USHORT SiS_VBExtInfo; - USHORT SiS_HiVision; + USHORT SiS_YPbPr; USHORT SiS_SelectCRT2Rate; USHORT SiS_SetFlag; USHORT SiS_RVBHCFACT; @@ -254,11 +340,13 @@ typedef struct _SiS_Private USHORT SiS_DDC_Port; USHORT SiS_DDC_Index; USHORT SiS_DDC_Data; + USHORT SiS_DDC_NData; USHORT SiS_DDC_Clk; - USHORT SiS_DDC_DataShift; + USHORT SiS_DDC_NClk; USHORT SiS_DDC_DeviceAddr; USHORT SiS_DDC_ReadAddr; USHORT SiS_DDC_SecAddr; + BOOLEAN SiS_SensibleSR11; USHORT SiS_Panel800x600; USHORT SiS_Panel1024x768; USHORT SiS_Panel1280x1024; @@ -270,22 +358,24 @@ typedef struct _SiS_Private USHORT SiS_Panel1280x768; USHORT SiS_Panel1024x600; USHORT SiS_Panel640x480; + USHORT SiS_Panel640x480_2; + USHORT SiS_Panel640x480_3; USHORT SiS_Panel1152x864; + USHORT SiS_PanelCustom; + USHORT SiS_PanelBarco1366; USHORT SiS_PanelMax; USHORT SiS_PanelMinLVDS; USHORT SiS_PanelMin301; USHORT SiS_ChrontelInit; - /* Pointers: */ const SiS_StStruct *SiS_SModeIDTable; - const SiS_StandTableStruct *SiS_StandTable; + SiS_StandTableStruct *SiS_StandTable; const SiS_ExtStruct *SiS_EModeIDTable; const SiS_Ext2Struct *SiS_RefIndex; const SiS_VBModeStruct *SiS_VBModeIDTable; const SiS_CRT1TableStruct *SiS_CRT1Table; const SiS_MCLKDataStruct *SiS_MCLKData_0; const SiS_MCLKDataStruct *SiS_MCLKData_1; - const SiS_ECLKDataStruct *SiS_ECLKData; const SiS_VCLKDataStruct *SiS_VCLKData; const SiS_VBVCLKDataStruct *SiS_VBVCLKData; const SiS_StResInfoStruct *SiS_StResInfo; @@ -316,7 +406,7 @@ typedef struct _SiS_Private const USHORT *pSiS_RGBSenseData; const USHORT *pSiS_VideoSenseData; const USHORT *pSiS_YCSenseData; - const USHORT *pSiS_RGBSenseData2; /*301b*/ + const USHORT *pSiS_RGBSenseData2; const USHORT *pSiS_VideoSenseData2; const USHORT *pSiS_YCSenseData2; #endif @@ -329,6 +419,8 @@ typedef struct _SiS_Private const UCHAR *SiS_PALMPhase2; const UCHAR *SiS_PALNPhase2; const UCHAR *SiS_SpecialPhase; + const UCHAR *SiS_SpecialPhaseM; + const UCHAR *SiS_SpecialPhaseJ; const SiS_LCDDataStruct *SiS_StLCD1024x768Data; const SiS_LCDDataStruct *SiS_ExtLCD1024x768Data; const SiS_LCDDataStruct *SiS_St2LCD1024x768Data; @@ -340,26 +432,38 @@ typedef struct _SiS_Private const SiS_LCDDataStruct *SiS_LCD1280x960Data; const SiS_LCDDataStruct *SiS_NoScaleData1400x1050; const SiS_LCDDataStruct *SiS_NoScaleData1600x1200; + const SiS_LCDDataStruct *SiS_NoScaleData1280x768; const SiS_LCDDataStruct *SiS_StLCD1400x1050Data; const SiS_LCDDataStruct *SiS_StLCD1600x1200Data; + const SiS_LCDDataStruct *SiS_StLCD1280x768Data; const SiS_LCDDataStruct *SiS_ExtLCD1400x1050Data; const SiS_LCDDataStruct *SiS_ExtLCD1600x1200Data; + const SiS_LCDDataStruct *SiS_ExtLCD1280x768Data; + const SiS_LCDDataStruct *SiS_NoScaleData; const SiS_TVDataStruct *SiS_StPALData; const SiS_TVDataStruct *SiS_ExtPALData; const SiS_TVDataStruct *SiS_StNTSCData; const SiS_TVDataStruct *SiS_ExtNTSCData; -/* const SiS_TVDataStruct *SiS_St1HiTVData; */ + const SiS_TVDataStruct *SiS_St1HiTVData; const SiS_TVDataStruct *SiS_St2HiTVData; const SiS_TVDataStruct *SiS_ExtHiTVData; + const SiS_TVDataStruct *SiS_St525iData; + const SiS_TVDataStruct *SiS_St525pData; + const SiS_TVDataStruct *SiS_St750pData; + const SiS_TVDataStruct *SiS_Ext525iData; + const SiS_TVDataStruct *SiS_Ext525pData; + const SiS_TVDataStruct *SiS_Ext750pData; const UCHAR *SiS_NTSCTiming; const UCHAR *SiS_PALTiming; const UCHAR *SiS_HiTVExtTiming; const UCHAR *SiS_HiTVSt1Timing; const UCHAR *SiS_HiTVSt2Timing; - const UCHAR *SiS_HiTVTextTiming; const UCHAR *SiS_HiTVGroup3Data; const UCHAR *SiS_HiTVGroup3Simu; +#if 0 + const UCHAR *SiS_HiTVTextTiming; const UCHAR *SiS_HiTVGroup3Text; +#endif const SiS_PanelDelayTblStruct *SiS_PanelDelayTbl; const SiS_PanelDelayTblStruct *SiS_PanelDelayTblLVDS; const SiS_LVDSDataStruct *SiS_LVDS800x600Data_1; @@ -381,12 +485,23 @@ typedef struct _SiS_Private const SiS_LVDSDataStruct *SiS_LVDS1152x768Data_1; const SiS_LVDSDataStruct *SiS_LVDS1152x768Data_2; const SiS_LVDSDataStruct *SiS_LVDS640x480Data_1; + const SiS_LVDSDataStruct *SiS_LVDS640x480Data_2; const SiS_LVDSDataStruct *SiS_LVDS320x480Data_1; + const SiS_LVDSDataStruct *SiS_LCDA1024x768Data_1; + const SiS_LVDSDataStruct *SiS_LCDA1024x768Data_2; + const SiS_LVDSDataStruct *SiS_LCDA1280x1024Data_1; + const SiS_LVDSDataStruct *SiS_LCDA1280x1024Data_2; const SiS_LVDSDataStruct *SiS_LCDA1400x1050Data_1; const SiS_LVDSDataStruct *SiS_LCDA1400x1050Data_2; const SiS_LVDSDataStruct *SiS_LCDA1600x1200Data_1; const SiS_LVDSDataStruct *SiS_LCDA1600x1200Data_2; const SiS_LVDSDataStruct *SiS_LVDSXXXxXXXData_1; + const SiS_LVDSDataStruct *SiS_LVDSBARCO1366Data_1; + const SiS_LVDSDataStruct *SiS_LVDSBARCO1366Data_2; + const SiS_LVDSDataStruct *SiS_LVDSBARCO1024Data_1; + const SiS_LVDSDataStruct *SiS_LVDSBARCO1024Data_2; + const SiS_LVDSDataStruct *SiS_LVDS848x480Data_1; + const SiS_LVDSDataStruct *SiS_LVDS848x480Data_2; const SiS_LVDSDataStruct *SiS_CHTVUNTSCData; const SiS_LVDSDataStruct *SiS_CHTVONTSCData; const SiS_LVDSDataStruct *SiS_CHTVUPALData; @@ -478,6 +593,12 @@ typedef struct _SiS_Private const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11600x1200_2_H; const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1XXXxXXX_1; const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1XXXxXXX_1_H; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_1; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_1_H; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_2; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_2_H; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_3; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_3_H; const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1UNTSC; const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1ONTSC; const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1UPAL; @@ -486,28 +607,23 @@ typedef struct _SiS_Private const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1320x480_1; - const SiS_LCDACRT1DataStruct *SiS_LCDACRT1800x600_1; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11024x768_1; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11280x1024_1; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11400x1050_1; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11600x1200_1; - const SiS_LCDACRT1DataStruct *SiS_LCDACRT1800x600_1_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11024x768_1_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11280x1024_1_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11400x1050_1_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11600x1200_1_H; - const SiS_LCDACRT1DataStruct *SiS_LCDACRT1800x600_2; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11024x768_2; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11280x1024_2; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11400x1050_2; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11600x1200_2; - const SiS_LCDACRT1DataStruct *SiS_LCDACRT1800x600_2_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11024x768_2_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11280x1024_2_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11400x1050_2_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11600x1200_2_H; - /* TW: New for 650/301LV */ const SiS_Part2PortTblStruct *SiS_CRT2Part2_1024x768_1; const SiS_Part2PortTblStruct *SiS_CRT2Part2_1280x1024_1; const SiS_Part2PortTblStruct *SiS_CRT2Part2_1400x1050_1; @@ -539,6 +655,9 @@ typedef struct _SiS_Private const UCHAR *SiS_CHTVVCLKUPALN; const UCHAR *SiS_CHTVVCLKOPALN; const UCHAR *SiS_CHTVVCLKSOPAL; + + USHORT PanelXRes; + USHORT PanelYRes; BOOLEAN UseCustomMode; BOOLEAN CRT1UsesCustomMode; @@ -560,10 +679,12 @@ typedef struct _SiS_Private UCHAR CSR2B; UCHAR CSR2C; USHORT CSRClock; + USHORT CSRClock_CRT1; USHORT CModeFlag; + USHORT CModeFlag_CRT1; USHORT CInfoFlag; - BOOLEAN SiS_CHPALM; - BOOLEAN SiS_CHPALN; + + int LVDSHL; BOOLEAN Backup; UCHAR Backup_Mode; @@ -578,7 +699,22 @@ typedef struct _SiS_Private UCHAR Backup_1c; UCHAR Backup_1d; - int UsePanelScaler; + int UsePanelScaler; + + USHORT CP_Vendor, CP_Product; + BOOLEAN CP_HaveCustomData; + int CP_PreferredX, CP_PreferredY; + int CP_MaxX, CP_MaxY, CP_MaxClock; + BOOLEAN CP_Supports64048075; + int CP_HDisplay[7], CP_VDisplay[7]; /* For Custom LCD panel dimensions */ + int CP_HTotal[7], CP_VTotal[7]; + int CP_HSyncStart[7], CP_VSyncStart[7]; + int CP_HSyncEnd[7], CP_VSyncEnd[7]; + int CP_HBlankStart[7], CP_VBlankStart[7]; + int CP_HBlankEnd[7], CP_VBlankEnd[7]; + int CP_Clock[7]; + BOOLEAN CP_DataValid[7]; + BOOLEAN CP_HSync_P[7], CP_VSync_P[7], CP_SyncValid[7]; } SiS_Private; #endif diff -puN include/video/sisfb.h~sisfb-update include/video/sisfb.h --- 25/include/video/sisfb.h~sisfb-update 2004-01-22 03:06:55.000000000 -0800 +++ 25-akpm/include/video/sisfb.h 2004-01-22 03:06:55.000000000 -0800 @@ -1,37 +1,98 @@ +/* + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the named License, + * or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + */ + #ifndef _LINUX_SISFB #define _LINUX_SISFB -#include - #include #include -#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 +/**********************************************/ +/* PUBLIC */ +/**********************************************/ + +/* vbflags */ +#define CRT2_DEFAULT 0x00000001 +#define CRT2_LCD 0x00000002 /* TW: Never change the order of the CRT2_XXX entries */ +#define CRT2_TV 0x00000004 /* (see SISCycleCRT2Type()) */ +#define CRT2_VGA 0x00000008 +#define TV_NTSC 0x00000010 +#define TV_PAL 0x00000020 +#define TV_HIVISION 0x00000040 +#define TV_YPBPR 0x00000080 +#define TV_AVIDEO 0x00000100 +#define TV_SVIDEO 0x00000200 +#define TV_SCART 0x00000400 +#define VB_CONEXANT 0x00000800 +#define TV_PALM 0x00001000 +#define TV_PALN 0x00002000 +#define TV_NTSCJ 0x00001000 +#define VB_302ELV 0x00004000 +#define TV_CHSCART 0x00008000 +#define TV_CHYPBPR525I 0x00010000 +#define CRT1_VGA 0x00000000 +#define CRT1_LCDA 0x00020000 +#define VGA2_CONNECTED 0x00040000 +#define VB_DISPTYPE_CRT1 0x00080000 /* CRT1 connected and used */ +#define VB_301 0x00100000 /* Video bridge type */ +#define VB_301B 0x00200000 +#define VB_302B 0x00400000 +#define VB_30xBDH 0x00800000 /* 30xB DH version (w/o LCD support) */ +#define VB_LVDS 0x01000000 +#define VB_CHRONTEL 0x02000000 +#define VB_301LV 0x04000000 +#define VB_302LV 0x08000000 +#define VB_301C 0x10000000 +#define VB_SINGLE_MODE 0x20000000 /* CRT1 or CRT2; determined by DISPTYPE_CRTx */ +#define VB_MIRROR_MODE 0x40000000 /* CRT1 + CRT2 identical (mirror mode) */ +#define VB_DUALVIEW_MODE 0x80000000 /* CRT1 + CRT2 independent (dual head mode) */ + +/* Aliases: */ +#define CRT2_ENABLE (CRT2_LCD | CRT2_TV | CRT2_VGA) +#define TV_STANDARD (TV_NTSC | TV_PAL | TV_PALM | TV_PALN | TV_NTSCJ) +#define TV_INTERFACE (TV_AVIDEO|TV_SVIDEO|TV_SCART|TV_HIVISION|TV_YPBPR|TV_CHSCART|TV_CHYPBPR525I) + +/* Only if TV_YPBPR is set: */ +#define TV_YPBPR525I TV_NTSC +#define TV_YPBPR525P TV_PAL +#define TV_YPBPR750P TV_PALM +#define TV_YPBPR1080I TV_PALN +#define TV_YPBPRALL (TV_YPBPR525I | TV_YPBPR525P | TV_YPBPR750P | TV_YPBPR1080I) + +#define VB_SISBRIDGE (VB_301|VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV) +#define VB_SISTVBRIDGE (VB_301|VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV) +#define VB_VIDEOBRIDGE (VB_SISBRIDGE | VB_LVDS | VB_CHRONTEL | VB_CONEXANT) + +#define VB_DISPTYPE_DISP2 CRT2_ENABLE +#define VB_DISPTYPE_CRT2 CRT2_ENABLE +#define VB_DISPTYPE_DISP1 VB_DISPTYPE_CRT1 +#define VB_DISPMODE_SINGLE VB_SINGLE_MODE +#define VB_DISPMODE_MIRROR VB_MIRROR_MODE +#define VB_DISPMODE_DUAL VB_DUALVIEW_MODE +#define VB_DISPLAY_MODE (SINGLE_MODE | MIRROR_MODE | DUALVIEW_MODE) -/* TW: *Never* change the order of the following enum */ +/* *Never* change the order of the following enum */ typedef enum _SIS_CHIP_TYPE { - SIS_VGALegacy = 0, + SIS_VGALegacy = 0, /* chip_id in sisfb_info */ SIS_300, SIS_630, SIS_540, - SIS_730, + SIS_730, SIS_315H, SIS_315, SIS_315PRO, @@ -39,15 +100,73 @@ typedef enum _SIS_CHIP_TYPE { SIS_650, SIS_740, SIS_330, + SIS_661, + SIS_741, + SIS_660, + SIS_760, MAX_SIS_CHIP } SIS_CHIP_TYPE; -typedef enum _VGA_ENGINE { - UNKNOWN_VGA = 0, - SIS_300_VGA, - SIS_315_VGA, -} VGA_ENGINE; +/* Addtional IOCTLs for communication sisfb <> X driver */ +/* If changing this, vgatypes.h must also be changed (for X driver) */ + +/* ioctl for identifying and giving some info (esp. memory heap start) */ +#define SISFB_GET_INFO _IOR('n',0xF8,__u32) +/* ioctrl to get current vertical retrace status */ +#define SISFB_GET_VBRSTATUS _IOR('n',0xF9,__u32) +/* ioctl to enable/disable panning auto-maximize (like nomax parameter) */ +#define SISFB_GET_AUTOMAXIMIZE _IOR('n',0xFA,__u32) +#define SISFB_SET_AUTOMAXIMIZE _IOW('n',0xFA,__u32) + +/* TW: Structure argument for SISFB_GET_INFO ioctl */ +typedef struct _SISFB_INFO sisfb_info, *psisfb_info; + +struct _SISFB_INFO { + unsigned long sisfb_id; /* for identifying sisfb */ +#ifndef SISFB_ID +#define SISFB_ID 0x53495346 /* Identify myself with 'SISF' */ +#endif + int chip_id; /* PCI ID of detected chip */ + int memory; /* video memory in KB which sisfb manages */ + int heapstart; /* heap start (= sisfb "mem" argument) in KB */ + unsigned char fbvidmode; /* current sisfb mode */ + + unsigned char sisfb_version; + unsigned char sisfb_revision; + unsigned char sisfb_patchlevel; + + unsigned char sisfb_caps; /* Sisfb capabilities */ + + int sisfb_tqlen; /* turbo queue length (in KB) */ + + unsigned int sisfb_pcibus; /* The card's PCI ID */ + unsigned int sisfb_pcislot; + unsigned int sisfb_pcifunc; + + unsigned char sisfb_lcdpdc; /* PanelDelayCompensation */ + + unsigned char sisfb_lcda; /* Detected status of LCDA for low res/text modes */ + + unsigned long sisfb_vbflags; + unsigned long sisfb_currentvbflags; + + int sisfb_scalelcd; + unsigned long sisfb_specialtiming; + + unsigned char sisfb_haveemi; + unsigned char sisfb_emi30,sisfb_emi31,sisfb_emi32,sisfb_emi33; + unsigned char sisfb_haveemilcd; + + char reserved[213]; /* for future use */ +}; + +/* For fb memory manager */ +struct sis_memreq { + unsigned long offset; + unsigned long size; +}; +/* More or less deprecated stuff follows: */ typedef enum _TVTYPE { TVMODE_NTSC = 0, TVMODE_PAL, @@ -63,19 +182,14 @@ typedef enum _TVPLUGTYPE { TVPLUG_TOTAL } SIS_TV_PLUG; -struct sis_memreq { - unsigned long offset; - unsigned long size; -}; - struct mode_info { int bpp; int xres; int yres; - int v_xres; - int v_yres; - int org_x; - int org_y; + int v_xres; /* deprecated - use var instead */ + int v_yres; /* deprecated - use var instead */ + int org_x; /* deprecated - use var instead */ + int org_y; /* deprecated - use var instead */ unsigned int vrate; }; @@ -83,15 +197,30 @@ struct ap_data { struct mode_info minfo; unsigned long iobase; unsigned int mem_size; - unsigned long disp_state; + unsigned long disp_state; /* deprecated */ SIS_CHIP_TYPE chip; unsigned char hasVB; - SIS_TV_TYPE TV_type; - SIS_TV_PLUG TV_plug; + SIS_TV_TYPE TV_type; /* deprecated */ + SIS_TV_PLUG TV_plug; /* deprecated */ unsigned long version; - char reserved[256]; + unsigned long vbflags; /* replaces deprecated entries above */ + unsigned long currentvbflags; + char reserved[248]; }; +/**********************************************/ +/* PRIVATE */ +/**********************************************/ + +#ifdef __KERNEL__ +#include + +typedef enum _VGA_ENGINE { + UNKNOWN_VGA = 0, + SIS_300_VGA, + SIS_315_VGA, +} VGA_ENGINE; + struct video_info { int chip_id; unsigned int video_size; @@ -107,26 +236,26 @@ struct video_info { int video_cmap_len; int video_width; int video_height; - int video_vwidth; - int video_vheight; - int org_x; - int org_y; + int video_vwidth; /* DEPRECATED - use var instead */ + int video_vheight; /* DEPRECATED - use var instead */ + int org_x; /* DEPRECATED - use var instead */ + int org_y; /* DEPRECATED - use var instead */ int video_linelength; unsigned int refresh_rate; - unsigned long disp_state; - unsigned char hasVB; - unsigned char TV_type; - unsigned char TV_plug; + unsigned long disp_state; /* DEPRECATED */ + unsigned char hasVB; /* DEPRECATED */ + unsigned char TV_type; /* DEPRECATED */ + unsigned char TV_plug; /* DEPRECATED */ SIS_CHIP_TYPE chip; unsigned char revision_id; - unsigned short DstColor; /* TW: For 2d acceleration */ + unsigned short DstColor; /* For 2d acceleration */ unsigned long SiS310_AccelDepth; unsigned long CommandReg; - spinlock_t lockaccel; + spinlock_t lockaccel; /* Do not use outside of kernel! */ unsigned int pcibus; unsigned int pcislot; @@ -137,58 +266,20 @@ struct video_info { unsigned short subsysvendor; unsigned short subsysdevice; - char reserved[236]; -}; - - -/* TW: Addtional IOCTL for communication sisfb <> X driver */ -/* If changing this, vgatypes.h must also be changed (for X driver) */ - -/* TW: ioctl for identifying and giving some info (esp. memory heap start) */ - -/* - * 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 SISFB_GET_INFO _IOR('n',0xF8,__u32) -#define SISFB_GET_VBRSTATUS _IOR('n',0xF9,__u32) - -/* TW: Structure argument for SISFB_GET_INFO ioctl */ -typedef struct _SISFB_INFO sisfb_info, *psisfb_info; - -struct _SISFB_INFO { - unsigned long sisfb_id; /* for identifying sisfb */ -#ifndef SISFB_ID -#define SISFB_ID 0x53495346 /* Identify myself with 'SISF' */ -#endif - int chip_id; /* PCI ID of detected chip */ - int memory; /* video memory in KB which sisfb manages */ - int heapstart; /* heap start (= sisfb "mem" argument) in KB */ - unsigned char fbvidmode; /* current sisfb mode */ - - unsigned char sisfb_version; - unsigned char sisfb_revision; - unsigned char sisfb_patchlevel; + unsigned long vbflags; /* Replacing deprecated stuff from above */ + unsigned long currentvbflags; - unsigned char sisfb_caps; /* Sisfb capabilities */ + int current_bpp; + int current_width; + int current_height; + int current_htotal; + int current_vtotal; + __u32 current_pixclock; + int current_refresh_rate; - int sisfb_tqlen; /* turbo queue length (in KB) */ - - unsigned int sisfb_pcibus; /* The card's PCI ID */ - unsigned int sisfb_pcislot; - unsigned int sisfb_pcifunc; - - unsigned char sisfb_lcdpdc; /* PanelDelayCompensation */ - - unsigned char sisfb_lcda; /* Detected status of LCDA for low res/text modes */ - - char reserved[235]; /* for future use */ + char reserved[200]; }; -#ifdef __KERNEL__ extern struct video_info ivideo; extern void sis_malloc(struct sis_memreq *req); _