From 515b943c4413e15d368ed9b585dbf3cec7c4db5d Mon Sep 17 00:00:00 2001 From: Thomas Winischhofer Date: Thu, 17 Jun 2004 13:20:14 +0000 Subject: SiS driver update 2004/06/17 --- man/sis.man | 285 +- src/300vtbl.h | 1045 ++- src/310vtbl.h | 2848 ++++----- src/init.c | 6736 +++++++++++--------- src/init.h | 1865 +++--- src/init301.c | 17126 ++++++++++++++++++++++++-------------------------- src/init301.h | 603 +- src/initdef.h | 502 +- src/oem300.h | 115 +- src/oem310.h | 461 +- src/osdef.h | 150 +- src/sis.h | 506 +- src/sis300_accel.c | 228 +- src/sis300_accel.h | 55 +- src/sis310_accel.c | 301 +- src/sis310_accel.h | 189 +- src/sis6326_video.c | 141 +- src/sis_accel.c | 84 +- src/sis_accel.h | 82 +- src/sis_common.h | 17 +- src/sis_cursor.c | 831 ++- src/sis_cursor.h | 381 +- src/sis_dac.c | 1006 ++- src/sis_dac.h | 81 +- src/sis_dga.c | 64 +- src/sis_dri.c | 163 +- src/sis_dri.h | 14 + src/sis_driver.c | 955 ++- src/sis_driver.h | 510 +- src/sis_opt.c | 807 ++- src/sis_regs.h | 112 +- src/sis_setup.c | 344 +- src/sis_shadow.c | 338 +- src/sis_vb.c | 948 ++- src/sis_vga.c | 650 +- src/sis_video.c | 3010 ++++++--- src/vgatypes.h | 384 +- src/vstruct.h | 332 +- 38 files changed, 22928 insertions(+), 21341 deletions(-) diff --git a/man/sis.man b/man/sis.man index 0f87f75..d1c510e 100644 --- a/man/sis.man +++ b/man/sis.man @@ -1,6 +1,17 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.man,v 1.11 2003/08/30 16:13:52 twini Exp $ +.\" $XFree86$ +.\" $XdotOrg$ .\" shorthand for double quote that works everywhere. .ds q \N'34' +#ifdef __servername__ +#define __myservername__ __servername__ +#else +#define __myservername__ XFree86 +#endif +#ifdef __xconfigfile__ +#define __myxconfigfile__ __xconfigfile__ +#else +#define __myxconfigfile__ XF86Config +#endif .TH SIS __drivermansuffix__ __vendorversion__ .SH NAME sis \- SiS video driver @@ -14,9 +25,9 @@ sis \- SiS video driver .fi .SH DESCRIPTION .B sis -is an XFree86 driver for SiS video chips. The driver is accelerated, and -provides support for 8, 16 and 24 colordepths. XVideo, Render and other -extensions are supported as well. +is an __myservername__ driver for SiS (Silicon Integrated Systems) video chips. The +driver is accelerated, and provides support for colordepths of 8, 16 and 24 bpp. +XVideo, Render and other extensions are supported as well. .SH SUPPORTED HARDWARE The .B sis @@ -29,9 +40,10 @@ driver supports PCI and AGP video cards based on the following chipsets: .B SiS540 .B SiS630/730 .B SiS315/H/PRO -.B SiS550 -.B SiS650/651/M650/661FX/M661FX/740/741 +.B SiS550/551/552 +.B SiS650/651/M650/661FX/M661FX/M661MX/740/741/741GX .B SiS330 (Xabre) +.B SiS760 .PP In the following text, the following terms are used: .PP @@ -42,9 +54,10 @@ for SiS5597/5598, 530/620 and 6326/AGP/DVD for SiS300/305, 540 and 630/730 .PP .B 315/330 series -for SiS315/H/PRO, 550 and 650/651/M650/661FX/M661FX/740/741, 330 +for SiS315, 55x and (M)65x/(M)661xX/74x(GX), 330, 760 +.PP .SH CONFIGURATION DETAILS -Please refer to XF86Config(__filemansuffix__) for general configuration +Please refer to __myxconfigfile__(__filemansuffix__) for general configuration details. This section only covers configuration details specific to this driver. .PP @@ -70,37 +83,43 @@ The opposite of HWCursor. Default: SWCursor is off. .TP .BI "Option \*qRotate\*q \*qCW\*q" Rotate the display clockwise. This mode is unaccelerated, and uses -the Shadow Frame Buffer layer. +the Shadow Frame Buffer layer. Using this option disables +the Resize and Rotate extension (RandR). Default: no rotation. .TP .BI "Option \*qRotate\*q \*qCCW\*q" Rotate the display counterclockwise. This mode is unaccelerated, and -uses the Shadow Frame Buffer layer. +uses the Shadow Frame Buffer layer. Using this option disables +the Resize and Rotate extension (RandR). Default: no rotation. .TP .BI "Option \*qShadowFB\*q \*q" boolean \*q Enable or disable use of the shadow framebuffer layer. Default: Shadow framebuffer is off. +.TP +.BI "Option \*qCRT1Gamma\*q \*q" boolean \*q +Enable or disable gamma correction. +Default: Gamma correction is on. .PP .I "2. Old series specific information" .PP The driver will auto-detect the amount of video memory present for all -these chips, but in the 6326 case, it will limit the memory size to 4MB. -This is because the 6326's 2D engine can only address 4MB. The remaining -memory seems to be intended for 3D texture data, since only the 3D -engine can address RAM above 4MB. However, you can override this forced +these chips, but in the case of the 6326, it will limit the memory size +to 4MB. This is because the 6326's 2D engine can only address 4MB. The +remaining memory seems to be intended for 3D texture data, since only +the 3D engine can address RAM above 4MB. However, you can override this limitation using the .B \*qVideoRAM\*q -option in the device section if your board has more than -4MB and you need to use it. However, 2D acceleration, Xvideo and the -HWCursor will be disabled in this case. +option in the Device section if your board has more than 4MB and you +need to use it. However, 2D acceleration, Xvideo and the HWCursor will +be disabled in this case. .PP The driver will also auto-detect the maximum dotclock and DAC speed. If you have problems getting high resolutions because of dot clock limitations, try using the .B \*qDacSpeed\*q -option, also in the device section. However, this is not recommended -for the 6326. For this chipset, the driver has two built-in modes for +option, also in the Device section. However, this is not recommended +for the 6326. For this chip, the driver has two built-in modes for high resolutions which you should use instead. These are named .B \*qSIS1280x1024-75\*q and @@ -110,13 +129,13 @@ just place them in your Screen section. Example: .PP .BI "Modes \*qSIS1600x1200-60\*q \*qSIS1280x1024x75\*q \*q1024x768\*q ... .PP -1280x1024 is only available at 8, 15 and 16bpp. 1600x1200 is available -at 8bpp only. +Of these modes, 1280x1024 is only available at 8, 15 and 16bpp. 1600x1200 +is available at 8bpp only. .PP TV support for the 6326 .PP -TV output is supported on the 6326. The driver will auto detect a -TV connected, and in this case add the following modes to the list +TV output is supported for the 6326. The driver will auto detect a +TV connected and in this case add the following modes to the list of default modes: "PAL800x600", "PAL800x600U", "PAL720x540", "PAL640x480", "NTSC640x480", "NTSC640x480U" and "NTSC640x400". Use these modes like the hi-res modes described above. @@ -130,11 +149,10 @@ Enable or disable TurboQueue mode. Default: off for SIS530/620, on for the others .TP .BI "Option \*qFastVram\*q \*q" boolean \*q -Enable or disable FastVram mode. Enabling this sets the video RAM timing -to only one cycle per read operation instead of two cycles. Disabling -this will set 2 cycles for read and write operations. Leaving this -option out uses the default. -Default: off for read, on for write. +Enable or disable FastVram mode. Enabling this sets the video RAM timing +to one cycle per read operation instead of two cycles. Disabling this will +set two cycles for read and write operations. Leaving this option out uses +the default, which varies depending on the chipset. .TP .BI "Option \*qNoHostBus\*q \*q" boolean \*q (SiS5597/5598 only). Disable CPU-to-VGA host bus support. This @@ -143,39 +161,46 @@ speeds up CPU to video RAM transfers. Default: Host bus is enabled. .BI "Option \*qNoXVideo\*q \*q" boolean \*q Disable XV (XVideo) extension support. Default: XVideo is on. .TP +.BI "Option \*qNoYV12\*q \*q" boolean \*q +Disable YV12 Xv support. This might me required due to hardware bugs in some +chipsets. Disabling YV12 support forces Xv-aware applications to use YUV2 or +XShm for video output. +Default: YV12 support is on. +.TP .BI "Option \*qTVStandard\*q \*q" string \*q -(6326 only) Possible parameters are +(6326 only) Valid parameters are .B PAL or .B NTSC. The default is set by a jumper on the card. .TP .BI "Option \*qTVXPosOffset\*q \*q" integer \*q -(6326 only) This option allows horizontal relocation the TV output. -The range is from -16 to 16. +(6326 only) This option allows tuning the horizontal position of the image +for TV output. The range is from -16 to 16. Default: 0 .TP .BI "Option \*qTVYPosOffset\*q \*q" integer \*q -(6326 only) This option allows vertical relocation the TV output. -The range is from -16 to 16. +(6326 only) This option allows tuning the vertical position of the image +for TV output. The range is from -16 to 16. Default: 0 .TP .BI "Option \*qSIS6326TVEnableYFilter\*q \*q" boolean \*q -(6326 only) This option allows enabling/disabling the Y filter for +(6326 only) This option allows enabling/disabling the Y (chroma) filter for TV output. .TP .BI "Option \*qSIS6326TVAntiFlicker\*q \*q" string \*q -(6326 only) This option allow enabling/disabling the anti flicker -facility for TV output. Possible parameters are +(6326 only) This option allow enabling/disabling the anti flicker facility +for TV output. Possible parameters are .B OFF, LOW, MED, HIGH or .B ADAPTIVE. By experience, .B ADAPTIVE -yields the best results. +yields the best results, hence it is the default. .PP .I "2. 300 and 315/330 series specific information" .PP -The 300 and 315/330 series very often come with a video bridge for -controlling LCD and TV output. Hereinafter, the term +The 300 and 315/330 series feature two CRT controllers and very often come +with a video bridge for controlling LCD and TV output. Hereinafter, the +term .B CRT1 refers to the VGA output of the chip, and .B CRT2 @@ -190,7 +215,7 @@ The driver supports the following video bridges: .B SiS301B(-DH) .B SiS301C .B SiS301LV -.B SiS302LV +.B SiS302(E)LV .PP Instead of a video bridge, some machines have a .B LVDS @@ -204,13 +229,15 @@ About TV output .PP On the SiS301 and the Chrontel 7005, only resolutions up to 800x600 are supported. On all others, resolutions up to 1024x768 are supported. +However, due to a hardware bug, Xvideo might be distorted on SiS video +bridges if running NTSC or PAL-M at 1024x768. .PP About XVideo support .PP XVideo is supported on all chipsets of both families. However, there are some differences in hardware features which cause limitations. -The 300 series as well as the SiS550, M650, 651, 661FX, M661FX, -and 741 support two video overlays. The SiS315/H/PRO and 650/740 support +The 300 series as well as the SiS55x, M650, 651, 661FX, M661FX, and +741 support two video overlays. The SiS315/H/PRO, 650/740 and 330 support only one such overlay. On chips with two overlays, one overlay is used for CRT1, the other for CRT2. On the other chipsets, the option .B \*qXvOnCRT2\*q @@ -226,7 +253,7 @@ About dual-head support .PP Dual head mode has some limitations as regards color depth and resolution. Due to memory bandwidth limits, CRT1 might have a -reduced refresh rate if running on higher resolutions than +reduced maximum refresh rate if running on higher resolutions than 1280x1024. .PP Colordepth 8 is not supported when running in dual head mode. @@ -248,24 +275,19 @@ and if this option is either unset or set to option is set to .B true ). If either only CRT1 or CRT2 is detected, the driver decides -automatically. +automatically. In Merged Framebuffer mode, this option is ignored. Default: overlay is used on CRT1 .TP .BI "Option \*qForceCRT1\*q \*q" boolean \*q -The BIOS detects VGA monitors connected to CRT1 at boot time -and the X driver by default relies on the information passed -by the BIOS. However, some old monitors are not detected -correctly. If this is the case, or if you connected the VGA -monitor after you booted the machine, you may set this -option to -.B true -in order to make the X driver ignore the -information from the BIOS and initialize CRT1 anyway. +Force CRT1 to be on of off. If a monitor is connected, it will be +detected during server start. However, some old monitors are not +detected correctly. In such cases, you may set this option to +.B on +in order to make the driver initialize CRT1 anyway. If this option is set to -.B false -, the driver will switch -off CRT1 and thus save memory bandwidth. -Default: auto detect CRT1 +.B off +, the driver will switch off CRT1. +Default: auto-detect .TP .BI "Option \*qForceCRT2Type\*q \*q" string \*q Force display type to one of: @@ -277,6 +299,8 @@ Force display type to one of: , .B COMPOSITE , +.B SVIDEO+COMPOSITE +, .B SCART , .B LCD @@ -284,56 +308,54 @@ Force display type to one of: .B VGA ; .B NONE -will disable CRT2. The SVIDEO, COMPOSITE and SCART parameters -are for SiS video bridges only and can be used to force the +will disable CRT2. The SVIDEO, COMPOSITE, SVIDEO+COMPOSITE and SCART +parameters are for SiS video bridges only and can be used to force the driver to use a specific TV output connector (if present). Default: auto detect. .TP -.BI "Option \*qPanelDelayCompensation\*q \*q" integer \*q -This option is only for machines with a 300 series chipset -and either a SiS301B-DH video bridge or a LVDS transmitter, -and a 315 series chipset with a SiS30xLV bridge. -Different LCD panels require different delay compensation -values. In most cases, the driver can autodetect this value. -However, due to bad BIOS design this might fail in rare -cases. If your LCD shows small horizontal waves, set the -parameter of this option on the 300 series first to -.B 4 -, -.B 32 -or -.B 24 -and if the problem persists, try using other values between -4 and 60 in steps of 4. On the 315 series, any value can -be set. +.BI "Option \*qCRT2Gamma\*q \*q" boolean \*q +Enable or disable gamma correction for CRT2. Only supported +for SiS video bridges. Default: Gamma correction for CRT2 is on. .TP .BI "Option \*qTVStandard\*q \*q" string \*q Force the TV standard to either .B PAL or .B NTSC. -On some machines with 630, 730 or the 315 series, +On some machines with 630, 730 and the 315/330 series, .B PALM -and +, .B PALN +and +.B NTSCJ are supported as well. Default: BIOS setting. .TP .BI "Option \*qTVXPosOffset\*q \*q" integer \*q -This option allows horizontal relocation the TV output. -The range is from -32 to 32. Not supported on the Chrontel -7019. +This option allows tuning the horizontal position of the image for +TV output. The range is from -32 to 32. Not supported on the Chrontel +7019. Default: 0 .TP .BI "Option \*qTVYPosOffset\*q \*q" integer \*q -This option allows vertical relocation the TV output. -The range is from -32 to 32. Not supported on the Chrontel -7019. +This option allows tuning the vertical position of the image for TV +output. The range is from -32 to 32. Not supported on the Chrontel +7019. Default: 0 +.TP +.BI "Option \*qSISTVXScale\*q \*q" integer \*q +This option selects the horizontal zooming level for TV output. The range +is from -16 to 16. Only supported on SiS video bridges. Default: 0 +.TP +.BI "Option \*qSISTVYScale\*q \*q" integer \*q +This option selects the vertical zooming level for TV output in the +following modes: 640x480, 800x600. On the 315/330 series, also 720x480, +720x576 and 768x576. The range is from -4 to 3. Only supported on +SiS video bridges. Default: 0 .TP .BI "Option \*qCHTVOverscan\*q \*q" boolean \*q -On machines with a Chrontel TV encoder, this can be used to -force the TV mode to overscan or underscan. -.B True +On machines with a Chrontel TV encoder, this can be used to force the +TV mode to overscan or underscan. +.B on means overscan, -.B false +.B off means underscan. Default: BIOS setting. .TP @@ -343,57 +365,40 @@ enables a super-overscan mode. This is only supported if the TV standard is PAL. Super overscan will produce an image on the TV which is larger than the viewable area. .PP -The driver supports many more TV related options. Please -see http://www.winischhofer.net/linuxsisvga.shtml for +The driver supports many more options. Please see +http://www.winischhofer.net/linuxsisvga.shtml for more information. .PP .I "3. 300 series specific information" .PP -DRI is supported on the 300 series only. DRI requires -the kernel's SiS framebuffer driver ( +DRI is supported on the 300 series only. On Linux, DRI requires the +kernel's SiS framebuffer driver ( .B sisfb -) and some other modules -which come with either the kernel or XFree86. -.PP -Sisfb takes care of memory management for texture -data. In order to prevent the X driver and sisfb from -overwriting each others video memory, sisfb reserves -an amount of video memory for the X driver. This amount -can either be selected using sisfb's mem parameter, or -auto-selected depending on the amount of total video RAM -available. However, the X driver needs to know about the -amount of RAM sisfb reserved. For this purpose, the +) and some other modules which come with either the kernel or the X server. +.PP +Sisfb takes care of memory management for texture data. In order to +prevent the X Server and sisfb from overwriting each other's data, +sisfb reserves an amount of video memory for the X driver. This amount +can either be selected using sisfb's mem parameter, or auto-selected +depending on the amount of total video RAM available. +.PP +Sisfb can be used for memory management only, or as a complete framebuffer +driver. If you start sisfb with a valid mode (ie you gain a graphical console), +the X driver can communicate with sisfb and doesn't require any +manual configuration for finding out about the video memory it is allowed +to use. +However, if you are running a 2.4 series Linux kernel and use sisfb for +video memory management only, ie you started sisfb with mode=none and still +have a text mode console, there is no communication between sisfb and the +X driver. For this purpose, +the .TP .BI "Option \*qMaxXFBMem\*q \*q" integer \*q .PP -exists. -.PP -XFree 4.3.0 disabled SiS DRI support. Old information follows: -.PP -At the moment (2003), the SiS DRI driver is not -maintained, lacks support for memory swapping and -has a few bugs. If you intend to use DRI, I recommend -setting the total video memory in the BIOS to 64MB -in order to at least overcome the lack of memory -swap functions. -.PP -Sisfb can be used for memory management only, or as -a complete framebuffer driver. If you start sisfb -with a valid mode (ie you gain a graphical console), -the X driver can communicate with sisfb and doesn't -require setting the -.B \*qMaxXFBMem\*q -option at all. The X driver will receive enough information -from sisfb in this case. -.PP -However, if you use sisfb for memory management only, ie -you started sisfb with mode=none and still have a text -mode console, there is no communication between sisfb -and the X driver. In this case, you need to set -.B \*qMaxXFBMem\*q -to the same value as you gave sisfb with its mem -parameter. If you didn't specify any mem parameter, -sisfb will reserve +exists. This option must be set to the same value as given to sisfb through +its "mem" parameter, ie the amount of memory to use for X in kilobytes. +.PP +If you started sisfb without the mem argument, sisfb will reserve .TP 12288KB if more than 16MB of total video RAM is available, .TP @@ -401,14 +406,24 @@ sisfb will reserve .TP 4096KB in all other cases. .PP -Then you need to specify any of these amounts as the -parameter for the -.B \*qMaxXFBMem\*q -option. The value is to be given without 'KB'. +If you intend to use DRI, I recommend setting the total video memory in +the BIOS to 64MB in order to at least overcome the lack of memory swap +functions. +.TP +.BI "Option \*qDRI\*q \*q" boolean \*q +This option allows enabling or disabling DRI. By default, DRI is on. +.TP +.BI "Option \*qAGPSize\*q \*q" integer \*q +This option allows selecting the amount of AGP memory to be used for DRI. +The amount is to be specified in megabyte, the default is 8. .SH "KNOWN BUGS" none. .SH "SEE ALSO" +#ifdef __xservername__ +__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__) +#else XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) +#endif .PP .B "http://www.winischhofer.net/linuxsisvga.shtml" for more information and updates diff --git a/src/300vtbl.h b/src/300vtbl.h index c058895..e46862d 100644 --- a/src/300vtbl.h +++ b/src/300vtbl.h @@ -1,272 +1,241 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/300vtbl.h,v 1.14 2003/07/28 12:39:45 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Register settings for SiS 300 series * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * If distributed as part of the linux kernel, the contents of this file - * is entirely covered by the GPL. + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * Otherwise, the following 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 * - * 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) 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 EXPRESSED 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 * - * Based on code by Silicon Intergrated Systems - * */ -typedef struct _SiS300_StStruct -{ - UCHAR St_ModeID; - USHORT St_ModeFlag; - UCHAR St_StTableIndex; - UCHAR St_CRT2CRTC; - UCHAR St_ResInfo; - UCHAR VB_StTVFlickerIndex; - UCHAR VB_StTVEdgeIndex; - UCHAR VB_StTVYFilterIndex; -} 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_ExtStruct -{ - UCHAR Ext_ModeID; - USHORT Ext_ModeFlag; - USHORT Ext_ModeInfo; - USHORT Ext_VESAID; - UCHAR Ext_RESINFO; - UCHAR VB_ExtTVFlickerIndex; - UCHAR VB_ExtTVEdgeIndex; - UCHAR VB_ExtTVYFilterIndex; - UCHAR REFindex; -} SiS300_ExtStruct; - -static const SiS300_ExtStruct SiS300_EModeIDTable[] = -{ - {0x6a,0x2212,0x0407,0x0102,SIS_RI_800x600, 0x00,0x00,0x00,0x00}, /* 800x600x? */ - {0x2e,0x0a1b,0x0306,0x0101,SIS_RI_640x480, 0x00,0x00,0x00,0x08}, - {0x2f,0x021b,0x0305,0x0100,SIS_RI_640x400, 0x00,0x00,0x00,0x10}, /* 640x400x8 */ - {0x30,0x2a1b,0x0407,0x0103,SIS_RI_800x600, 0x00,0x00,0x00,0x00}, - {0x31,0x0a1b,0x0a0d,0x0000,SIS_RI_720x480, 0x00,0x00,0x00,0x11}, /* 720x480x8 */ - {0x32,0x2a1b,0x0a0e,0x0000,SIS_RI_720x576, 0x00,0x00,0x00,0x12}, /* 720x576x8 */ - {0x33,0x0a1d,0x0a0d,0x0000,SIS_RI_720x480, 0x00,0x00,0x00,0x11}, /* 720x480x16 */ - {0x34,0x2a1d,0x0a0e,0x0000,SIS_RI_720x576, 0x00,0x00,0x00,0x12}, /* 720x576x16 */ - {0x35,0x0a1f,0x0a0d,0x0000,SIS_RI_720x480, 0x00,0x00,0x00,0x11}, /* 720x480x32 */ - {0x36,0x2a1f,0x0a0e,0x0000,SIS_RI_720x576, 0x00,0x00,0x00,0x12}, /* 720x576x32 */ - {0x37,0x0212,0x0508,0x0104,SIS_RI_1024x768, 0x00,0x00,0x00,0x13}, /* 1024x768x? */ - {0x38,0x0a1b,0x0508,0x0105,SIS_RI_1024x768, 0x00,0x00,0x00,0x13}, /* 1024x768x8 */ - {0x3a,0x0e3b,0x0609,0x0107,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a}, /* 1280x1024x8 */ - {0x3c,0x063b,0x070a,0x0130,SIS_RI_1600x1200,0x00,0x00,0x00,0x1e}, - {0x3d,0x067d,0x070a,0x0131,SIS_RI_1600x1200,0x00,0x00,0x00,0x1e}, - {0x40,0x921c,0x0000,0x010d,SIS_RI_320x200, 0x00,0x00,0x00,0x23}, /* 320x200x15 */ - {0x41,0x921d,0x0000,0x010e,SIS_RI_320x200, 0x00,0x00,0x00,0x23}, /* 320x200x16 */ - {0x43,0x0a1c,0x0306,0x0110,SIS_RI_640x480, 0x00,0x00,0x00,0x08}, - {0x44,0x0a1d,0x0306,0x0111,SIS_RI_640x480, 0x00,0x00,0x00,0x08}, - {0x46,0x2a1c,0x0407,0x0113,SIS_RI_800x600, 0x00,0x00,0x00,0x00}, /* 800x600x15 */ - {0x47,0x2a1d,0x0407,0x0114,SIS_RI_800x600, 0x00,0x00,0x00,0x00}, /* 800x600x16 */ - {0x49,0x0a3c,0x0508,0x0116,SIS_RI_1024x768, 0x00,0x00,0x00,0x13}, - {0x4a,0x0a3d,0x0508,0x0117,SIS_RI_1024x768, 0x00,0x00,0x00,0x13}, - {0x4c,0x0e7c,0x0609,0x0119,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a}, - {0x4d,0x0e7d,0x0609,0x011a,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a}, - {0x50,0x921b,0x0001,0x0132,SIS_RI_320x240, 0x00,0x00,0x00,0x24}, /* 320x240x8 */ - {0x51,0xb21b,0x0103,0x0133,SIS_RI_400x300, 0x00,0x00,0x00,0x25}, /* 400x300x8 */ - {0x52,0x921b,0x0204,0x0134,SIS_RI_512x384, 0x00,0x00,0x00,0x26}, /* 512x384x8 */ - {0x56,0x921d,0x0001,0x0135,SIS_RI_320x240, 0x00,0x00,0x00,0x24}, /* 320x240x16 */ - {0x57,0xb21d,0x0103,0x0136,SIS_RI_400x300, 0x00,0x00,0x00,0x25}, /* 400x300x16 */ - {0x58,0x921d,0x0204,0x0137,SIS_RI_512x384, 0x00,0x00,0x00,0x26}, /* 512x384x16 */ - {0x59,0x921b,0x0000,0x0138,SIS_RI_320x200, 0x00,0x00,0x00,0x23}, /* 320x200x8 */ - {0x5c,0x921f,0x0204,0x0000,SIS_RI_512x384, 0x00,0x00,0x00,0x26}, /* 512x384x32 */ - {0x5d,0x021d,0x0305,0x0139,SIS_RI_640x400, 0x00,0x00,0x00,0x10}, /* 640x400x16 */ - {0x5e,0x021f,0x0305,0x0000,SIS_RI_640x400, 0x00,0x00,0x00,0x10}, /* 640x400x32 */ - {0x62,0x0a3f,0x0306,0x013a,SIS_RI_640x480, 0x00,0x00,0x00,0x08}, - {0x63,0x2a3f,0x0407,0x013b,SIS_RI_800x600, 0x00,0x00,0x00,0x00}, /* 800x600x32 */ - {0x64,0x0a7f,0x0508,0x013c,SIS_RI_1024x768, 0x00,0x00,0x00,0x13}, - {0x65,0x0eff,0x0609,0x013d,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a}, - {0x66,0x06ff,0x070a,0x013e,SIS_RI_1600x1200,0x00,0x00,0x00,0x1e}, - {0x68,0x067b,0x080b,0x013f,SIS_RI_1920x1440,0x00,0x00,0x00,0x27}, - {0x69,0x06fd,0x080b,0x0140,SIS_RI_1920x1440,0x00,0x00,0x00,0x27}, - {0x6b,0x07ff,0x080b,0x0000,SIS_RI_1920x1440,0x00,0x00,0x00,0x27}, - {0x6c,0x067b,0x090c,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x28}, /* 2048x1536x8 - not in BIOS! */ - {0x6d,0x06fd,0x090c,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x28}, /* 2048x1536x16 - not in BIOS! */ - {0x70,0x2a1b,0x0400,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x2d}, /* 800x480x8 */ - {0x71,0x0a1b,0x0501,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x30}, /* 1024x576x8 */ - {0x74,0x0a1d,0x0501,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x30}, /* 1024x576x16 */ - {0x75,0x0e3d,0x0602,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x33}, /* 1280x720x16 */ - {0x76,0x2a1f,0x0400,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x2d}, /* 800x480x32 */ - {0x77,0x0a3f,0x0501,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x30}, /* 1024x576x32 */ - {0x78,0x0eff,0x0602,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x33}, /* 1280x720x32 */ - {0x79,0x0e3b,0x0602,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x33}, /* 1280x720x8 */ - {0x7a,0x2a1d,0x0400,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x2d}, /* 800x480x16 */ - {0x7c,0x0a3b,0x060f,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x29}, /* 1280x960x8 */ - {0x7d,0x0a7d,0x060f,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x29}, /* 1280x960x16 */ - {0x7e,0x0aff,0x060f,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x29}, /* 1280x960x32 */ - {0x20,0x0a1b,0x0504,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x2b}, /* 1024x600 */ - {0x21,0x0a3d,0x0504,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x2b}, - {0x22,0x0a7f,0x0504,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x2b}, - {0x23,0x0a1b,0x0c05,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x2c}, /* 1152x768 */ - {0x24,0x0a3d,0x0c05,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x2c}, - {0x25,0x0a7f,0x0c05,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x2c}, - {0x29,0x0e1b,0x0c05,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x36}, /* 1152x864 */ - {0x2a,0x0e3d,0x0c05,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x36}, - {0x2b,0x0e7f,0x0c05,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x36}, - {0x39,0x2a1b,0x0d06,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x38}, /* 848x480 */ - {0x3b,0x2a3d,0x0d06,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x38}, - {0x3e,0x2a7f,0x0d06,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x38}, - {0x3f,0x2a1b,0x0d07,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x3a}, /* 856x480 */ - {0x42,0x2a3d,0x0d07,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x3a}, - {0x45,0x2a7f,0x0d07,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x3a}, - {0x48,0x223b,0x0e08,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x3c}, /* 1360x768 */ - {0x4b,0x227d,0x0e08,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x3c}, - {0x4e,0x22ff,0x0e08,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x3c}, - {0x4f,0x921f,0x0000,0x0000,SIS_RI_320x200, 0x00,0x00,0x00,0x23}, /* 320x200x32 */ - {0x53,0x921f,0x0001,0x0000,SIS_RI_320x240, 0x00,0x00,0x00,0x24}, /* 320x240x32 */ - {0x54,0xb21f,0x0103,0x0000,SIS_RI_400x300, 0x00,0x00,0x00,0x25}, /* 400x300x32 */ - {0x55,0x2e3b,0x0609,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x3d}, /* 1280x768 */ - {0x5a,0x2e7d,0x0609,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x3d}, - {0x5b,0x2eff,0x0609,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x3d}, - {0x5f,0x2a1b,0x0f0e,0x0000,SIS_RI_768x576, 0x00,0x00,0x00,0x3e}, /* 768x576x8 */ - {0x60,0x2a1d,0x0f0e,0x0000,SIS_RI_768x576, 0x00,0x00,0x00,0x3e}, /* 768x576x16 */ - {0x61,0x2a1f,0x0f0e,0x0000,SIS_RI_768x576, 0x00,0x00,0x00,0x3e}, /* 768x576x32 */ - {0x67,0x2e3b,0x0e08,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x3f}, /* 1360x1024x8 (BARCO) */ - {0x6f,0x2e7d,0x0e08,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x3f}, /* 1360x1024x16 (BARCO) */ - {0x72,0x2eff,0x0e08,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x3f}, /* 1360x1024x32 (BARCO) */ - {0xff,0x0000,0x0000,0xffff,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 ModeID; - USHORT XRes; - USHORT YRes; -} 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}, /* 00 */ - {0x0467,0x0e,0x44,0x05,0x6a, 800, 600}, /* 01 */ - {0x0067,0x0f,0x07,0x48,0x6a, 800, 600}, /* 02 - CRT1CRTC was 0x4f */ - {0x0067,0x10,0x06,0x8b,0x6a, 800, 600}, /* 03 */ - {0x0147,0x11,0x08,0x00,0x6a, 800, 600}, /* 04 */ - {0x0147,0x12,0x0c,0x00,0x6a, 800, 600}, /* 05 */ - {0x0047,0x11,0x4e,0x00,0x6a, 800, 600}, /* 06 - CRT1CRTC was 0x51 */ - {0x0047,0x11,0x13,0x00,0x6a, 800, 600}, /* 07 */ - {0xc85f,0x05,0x00,0x04,0x2e, 640, 480}, /* 08 */ - {0xc067,0x06,0x02,0x04,0x2e, 640, 480}, /* 09 */ - {0xc067,0x07,0x02,0x47,0x2e, 640, 480}, /* 0a */ - {0xc067,0x08,0x03,0x8a,0x2e, 640, 480}, /* 0b */ - {0xc047,0x09,0x05,0x00,0x2e, 640, 480}, /* 0c */ - {0xc047,0x0a,0x08,0x00,0x2e, 640, 480}, /* 0d */ - {0xc047,0x0b,0x0a,0x00,0x2e, 640, 480}, /* 0e */ - {0xc047,0x0c,0x10,0x00,0x2e, 640, 480}, /* 0f */ - {0x487f,0x04,0x00,0x00,0x2f, 640, 400}, /* 10 */ - {0xc00f,0x31,0x01,0x06,0x31, 720, 480}, /* 11 */ - {0x000f,0x32,0x03,0x06,0x32, 720, 576}, /* 12 */ - {0x0187,0x15,0x05,0x00,0x37,1024, 768}, /* 13 */ - {0xc877,0x16,0x09,0x06,0x37,1024, 768}, /* 14 */ - {0xc067,0x17,0x0b,0x49,0x37,1024, 768}, /* 15 - CRT1CRTC was 0x97 */ - {0x0267,0x18,0x0d,0x00,0x37,1024, 768}, /* 16 */ - {0x0047,0x19,0x11,0x8c,0x37,1024, 768}, /* 17 - CRT1CRTC was 0x59 */ - {0x0047,0x1a,0x52,0x00,0x37,1024, 768}, /* 18 */ - {0x0007,0x1b,0x16,0x00,0x37,1024, 768}, /* 19 - CRT1CRTC was 0x5b */ - {0x0387,0x1c,0x4d,0x00,0x3a,1280,1024}, /* 1a - CRT1CRTC was 0x5c */ - {0x0077,0x1d,0x14,0x07,0x3a,1280,1024}, /* 1b */ - {0x0047,0x1e,0x17,0x00,0x3a,1280,1024}, /* 1c */ - {0x0007,0x1f,0x98,0x00,0x3a,1280,1024}, /* 1d */ - {0x0007,0x20,0x59,0x00,0x3c,1600,1200}, /* 1e - CRT1CRTC was 0x60 */ - {0x0007,0x21,0x5a,0x00,0x3c,1600,1200}, /* 1f */ - {0x0007,0x22,0x1b,0x00,0x3c,1600,1200}, /* 20 */ - {0x0007,0x23,0x1d,0x00,0x3c,1600,1200}, /* 21 - CRT1CRTC was 0x63 */ - {0x0007,0x24,0x1e,0x00,0x3c,1600,1200}, /* 22 */ - {0x407f,0x00,0x00,0x00,0x40, 320, 200}, /* 23 */ - {0xc07f,0x01,0x00,0x04,0x50, 320, 240}, /* 24 */ - {0x0077,0x02,0x04,0x05,0x51, 400, 300}, /* 25 */ - {0xc877,0x03,0x09,0x06,0x52, 512, 384}, /* 26 */ /* was c077 */ - {0x8207,0x25,0x1f,0x00,0x68,1920,1440}, /* 27 */ - {0x0007,0x26,0x20,0x00,0x6c,2048,1536}, /* 28 */ - {0x0067,0x27,0x14,0x08,0x6e,1280, 960}, /* 29 - TW: 1280x960-60 */ - {0x0027,0x45,0x3c,0x08,0x6e,1280, 960}, /* 2a - TW: 1280x960-85 */ - {0xc077,0x33,0x09,0x06,0x20,1024, 600}, /* 2b */ - {0xc077,0x34,0x0b,0x06,0x23,1152, 768}, /* 2c */ /* VCLK 0x09 */ - {0x0057,0x35,0x27,0x08,0x70, 800, 480}, /* 2d */ - {0x0047,0x36,0x37,0x08,0x70, 800, 480}, /* 2e */ - {0x0047,0x37,0x08,0x08,0x70, 800, 480}, /* 2f */ - {0x0057,0x38,0x09,0x09,0x71,1024, 576}, /* 30 */ - {0x0047,0x39,0x38,0x09,0x71,1024, 576}, /* 31 */ - {0x0047,0x3a,0x11,0x09,0x71,1024, 576}, /* 32 */ - {0x0057,0x3b,0x39,0x0a,0x75,1280, 720}, /* 33 */ - {0x0047,0x3c,0x3a,0x0a,0x75,1280, 720}, /* 34 */ - {0x0007,0x3d,0x3b,0x0a,0x75,1280, 720}, /* 35 */ - {0x0047,0x3e,0x34,0x06,0x29,1152, 864}, /* 36 1152x864-75Hz */ - {0x0047,0x44,0x3a,0x06,0x29,1152, 864}, /* 37 1152x864-85Hz */ - {0x00c7,0x3f,0x28,0x00,0x39, 848, 480}, /* 38 848x480-38Hzi */ - {0xc067,0x40,0x3d,0x0b,0x39, 848, 480}, /* 39 848x480-60Hz */ - {0x00c7,0x41,0x28,0x00,0x3f, 856, 480}, /* 3a 856x480-38Hzi */ - {0xc047,0x42,0x28,0x00,0x3f, 856, 480}, /* 3b 856x480-60Hz */ - {0x0067,0x43,0x3e,0x0c,0x48,1360, 768}, /* 3c 1360x768-60Hz */ - {0x0077,0x46,0x3f,0x08,0x55,1280, 768}, /* 3d 1280x768-60Hz */ - {0x000f,0x47,0x03,0x06,0x5f, 768, 576}, /* 3e 768x576 */ - {0x0027,0x48,0x13,0x08,0x67,1360,1024}, /* 3f 1360x1024-59Hz (BARCO1366 only) */ - {0xffff, 0, 0, 0, 0, 0, 0} -}; - -typedef struct _SiS_VBModeIDTableStruct -{ - UCHAR ModeID; - UCHAR VB_TVDelayIndex; - UCHAR VB_TVFlickerIndex; - UCHAR VB_TVPhaseIndex; - UCHAR VB_TVYFilterIndex; - UCHAR VB_LCDDelayIndex; - UCHAR _VB_LCDHIndex; - UCHAR _VB_LCDVIndex; -}SiS_VBModeIDTableStruct; - -static const SiS_VBModeIDTableStruct SiS300_VBModeIDTable[] = +static const SiS_StStruct SiS300_SModeIDTable[] = +{ + {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} +}; + +static const SiS_ExtStruct SiS300_EModeIDTable[] = +{ + {0x6a,0x2212,0x0102,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00,-1}, /* 800x600x? */ + {0x2e,0x0a1b,0x0101,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08,-1}, + {0x2f,0x021b,0x0100,SIS_RI_640x400, 0x00,0x00,0x00,0x00,0x10,-1}, /* 640x400x8 */ + {0x30,0x2a1b,0x0103,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00,-1}, + {0x31,0x0a1b,0x0000,SIS_RI_720x480, 0x00,0x00,0x00,0x00,0x11,-1}, /* 720x480x8 */ + {0x32,0x2a1b,0x0000,SIS_RI_720x576, 0x00,0x00,0x00,0x00,0x12,-1}, /* 720x576x8 */ + {0x33,0x0a1d,0x0000,SIS_RI_720x480, 0x00,0x00,0x00,0x00,0x11,-1}, /* 720x480x16 */ + {0x34,0x2a1d,0x0000,SIS_RI_720x576, 0x00,0x00,0x00,0x00,0x12,-1}, /* 720x576x16 */ + {0x35,0x0a1f,0x0000,SIS_RI_720x480, 0x00,0x00,0x00,0x00,0x11,-1}, /* 720x480x32 */ + {0x36,0x2a1f,0x0000,SIS_RI_720x576, 0x00,0x00,0x00,0x00,0x12,-1}, /* 720x576x32 */ + {0x37,0x0212,0x0104,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13,-1}, /* 1024x768x? */ + {0x38,0x0a1b,0x0105,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13,-1}, /* 1024x768x8 */ + {0x3a,0x0e3b,0x0107,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a,-1}, /* 1280x1024x8 */ + {0x3c,0x063b,0x0130,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e,-1}, + {0x3d,0x067d,0x0131,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e,-1}, + {0x40,0x921c,0x010d,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23,-1}, /* 320x200x15 */ + {0x41,0x921d,0x010e,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23,-1}, /* 320x200x16 */ + {0x43,0x0a1c,0x0110,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08,-1}, + {0x44,0x0a1d,0x0111,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08,-1}, + {0x46,0x2a1c,0x0113,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00,-1}, /* 800x600x15 */ + {0x47,0x2a1d,0x0114,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00,-1}, /* 800x600x16 */ + {0x49,0x0a3c,0x0116,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13,-1}, + {0x4a,0x0a3d,0x0117,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13,-1}, + {0x4c,0x0e7c,0x0119,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a,-1}, + {0x4d,0x0e7d,0x011a,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a,-1}, + {0x50,0x921b,0x0132,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x24,-1}, /* 320x240x8 */ + {0x51,0xb21b,0x0133,SIS_RI_400x300, 0x00,0x00,0x00,0x00,0x25,-1}, /* 400x300x8 */ + {0x52,0x921b,0x0134,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x26,-1}, /* 512x384x8 */ + {0x56,0x921d,0x0135,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x24,-1}, /* 320x240x16 */ + {0x57,0xb21d,0x0136,SIS_RI_400x300, 0x00,0x00,0x00,0x00,0x25,-1}, /* 400x300x16 */ + {0x58,0x921d,0x0137,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x26,-1}, /* 512x384x16 */ + {0x59,0x921b,0x0138,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23,-1}, /* 320x200x8 */ + {0x5c,0x921f,0x0000,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x26,-1}, /* 512x384x32 */ + {0x5d,0x021d,0x0139,SIS_RI_640x400, 0x00,0x00,0x00,0x00,0x10,-1}, /* 640x400x16 */ + {0x5e,0x021f,0x0000,SIS_RI_640x400, 0x00,0x00,0x00,0x00,0x10,-1}, /* 640x400x32 */ + {0x62,0x0a3f,0x013a,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08,-1}, + {0x63,0x2a3f,0x013b,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00,-1}, /* 800x600x32 */ + {0x64,0x0a7f,0x013c,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13,-1}, + {0x65,0x0eff,0x013d,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a,-1}, + {0x66,0x06ff,0x013e,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e,-1}, + {0x68,0x067b,0x013f,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x27,-1}, + {0x69,0x06fd,0x0140,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x27,-1}, + {0x6b,0x07ff,0x0000,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x27,-1}, + {0x6c,0x067b,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x28,-1}, /* 2048x1536x8 - not in BIOS! */ + {0x6d,0x06fd,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x28,-1}, /* 2048x1536x16 - not in BIOS! */ + {0x70,0x2a1b,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x00,0x2d,-1}, /* 800x480x8 */ + {0x71,0x0a1b,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x30,-1}, /* 1024x576x8 */ + {0x74,0x0a1d,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x30,-1}, /* 1024x576x16 */ + {0x75,0x0e3d,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x33,-1}, /* 1280x720x16 */ + {0x76,0x2a1f,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x00,0x2d,-1}, /* 800x480x32 */ + {0x77,0x0a3f,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x30,-1}, /* 1024x576x32 */ + {0x78,0x0eff,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x33,-1}, /* 1280x720x32 */ + {0x79,0x0e3b,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x33,-1}, /* 1280x720x8 */ + {0x7a,0x2a1d,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x00,0x2d,-1}, /* 800x480x16 */ + {0x7c,0x0a3b,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x29,-1}, /* 1280x960x8 */ + {0x7d,0x0a7d,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x29,-1}, /* 1280x960x16 */ + {0x7e,0x0aff,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x29,-1}, /* 1280x960x32 */ + {0x20,0x0a1b,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x00,0x2b,-1}, /* 1024x600 */ + {0x21,0x0a3d,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x00,0x2b,-1}, + {0x22,0x0a7f,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x00,0x2b,-1}, + {0x23,0x0a1b,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x00,0x2c,-1}, /* 1152x768 */ + {0x24,0x0a3d,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x00,0x2c,-1}, + {0x25,0x0a7f,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x00,0x2c,-1}, + {0x29,0x0e1b,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x36,-1}, /* 1152x864 */ + {0x2a,0x0e3d,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x36,-1}, + {0x2b,0x0e7f,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x36,-1}, + {0x39,0x2a1b,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x38,-1}, /* 848x480 */ + {0x3b,0x2a3d,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x38,-1}, + {0x3e,0x2a7f,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x38,-1}, + {0x3f,0x2a1b,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x3a,-1}, /* 856x480 */ + {0x42,0x2a3d,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x3a,-1}, + {0x45,0x2a7f,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x3a,-1}, + {0x48,0x223b,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x3c,-1}, /* 1360x768 */ + {0x4b,0x227d,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x3c,-1}, + {0x4e,0x22ff,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x3c,-1}, + {0x4f,0x921f,0x0000,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23,-1}, /* 320x200x32 */ + {0x53,0x921f,0x0000,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x24,-1}, /* 320x240x32 */ + {0x54,0xb21f,0x0000,SIS_RI_400x300, 0x00,0x00,0x00,0x00,0x25,-1}, /* 400x300x32 */ + {0x55,0x2e3b,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x3d,-1}, /* 1280x768 */ + {0x5a,0x2e7d,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x3d,-1}, + {0x5b,0x2eff,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x3d,-1}, + {0x5f,0x2a1b,0x0000,SIS_RI_768x576, 0x00,0x00,0x00,0x00,0x3e,-1}, /* 768x576x8 */ + {0x60,0x2a1d,0x0000,SIS_RI_768x576, 0x00,0x00,0x00,0x00,0x3e,-1}, /* 768x576x16 */ + {0x61,0x2a1f,0x0000,SIS_RI_768x576, 0x00,0x00,0x00,0x00,0x3e,-1}, /* 768x576x32 */ + {0x67,0x2e3b,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x00,0x3f,-1}, /* 1360x1024x8 (BARCO) */ + {0x6f,0x2e7d,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x00,0x3f,-1}, /* 1360x1024x16 (BARCO) */ + {0x72,0x2eff,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x00,0x3f,-1}, /* 1360x1024x32 (BARCO) */ + {0xff,0x0000,0xffff,0, 0x00,0x00,0x00,0x00,0x00} +}; + +static const SiS_Ext2Struct SiS300_RefIndex[] = +{ + {0x085f,0x0d,0x03,0x05,0x05,0x6a, 800, 600, 0}, /* 00 */ + {0x0467,0x0e,0x44,0x05,0x05,0x6a, 800, 600, 0}, /* 01 */ + {0x0067,0x0f,0x07,0x48,0x00,0x6a, 800, 600, 0}, /* 02 - CRT1CRTC was 0x4f */ + {0x0067,0x10,0x06,0x8b,0x00,0x6a, 800, 600, 0}, /* 03 */ + {0x0147,0x11,0x08,0x00,0x00,0x6a, 800, 600, 0}, /* 04 */ + {0x0147,0x12,0x0c,0x00,0x00,0x6a, 800, 600, 0}, /* 05 */ + {0x0047,0x11,0x4e,0x00,0x00,0x6a, 800, 600, 0}, /* 06 - CRT1CRTC was 0x51 */ + {0x0047,0x11,0x13,0x00,0x00,0x6a, 800, 600, 0}, /* 07 */ + {0xc85f,0x05,0x00,0x04,0x04,0x2e, 640, 480, 0}, /* 08 */ + {0xc067,0x06,0x02,0x04,0x04,0x2e, 640, 480, 0}, /* 09 */ + {0xc067,0x07,0x02,0x47,0x04,0x2e, 640, 480, 0}, /* 0a */ + {0xc067,0x08,0x03,0x8a,0x04,0x2e, 640, 480, 0}, /* 0b */ + {0xc047,0x09,0x05,0x00,0x00,0x2e, 640, 480, 0}, /* 0c */ + {0xc047,0x0a,0x08,0x00,0x00,0x2e, 640, 480, 0}, /* 0d */ + {0xc047,0x0b,0x0a,0x00,0x00,0x2e, 640, 480, 0}, /* 0e */ + {0xc047,0x0c,0x10,0x00,0x00,0x2e, 640, 480, 0}, /* 0f */ + {0x487f,0x04,0x00,0x00,0x00,0x2f, 640, 400, 0}, /* 10 */ + {0xc04f,0x31,0x01,0x06,0x00,0x31, 720, 480, 0}, /* 11 */ + {0x004f,0x32,0x03,0x06,0x00,0x32, 720, 576, 0}, /* 12 */ + {0x0187,0x15,0x05,0x00,0x00,0x37,1024, 768, 0}, /* 13 */ + {0xc877,0x16,0x09,0x06,0x06,0x37,1024, 768, 0}, /* 14 */ + {0xc067,0x17,0x0b,0x49,0x06,0x37,1024, 768, 0}, /* 15 - CRT1CRTC was 0x97 */ + {0x0267,0x18,0x0d,0x00,0x06,0x37,1024, 768, 0}, /* 16 */ + {0x0047,0x19,0x11,0x8c,0x00,0x37,1024, 768, 0}, /* 17 - CRT1CRTC was 0x59 */ + {0x0047,0x1a,0x52,0x00,0x00,0x37,1024, 768, 0}, /* 18 */ + {0x0007,0x1b,0x16,0x00,0x00,0x37,1024, 768, 0}, /* 19 - CRT1CRTC was 0x5b */ + {0x0387,0x1c,0x4d,0x00,0x00,0x3a,1280,1024, 0}, /* 1a - CRT1CRTC was 0x5c */ + {0x0077,0x1d,0x14,0x07,0x00,0x3a,1280,1024, 0}, /* 1b */ + {0x0047,0x1e,0x17,0x00,0x00,0x3a,1280,1024, 0}, /* 1c */ + {0x0007,0x1f,0x98,0x00,0x00,0x3a,1280,1024, 0}, /* 1d */ + {0x0007,0x20,0x59,0x00,0x00,0x3c,1600,1200, 0}, /* 1e - CRT1CRTC was 0x60 */ + {0x0007,0x21,0x5a,0x00,0x00,0x3c,1600,1200, 0}, /* 1f */ + {0x0007,0x22,0x1b,0x00,0x00,0x3c,1600,1200, 0}, /* 20 */ + {0x0007,0x23,0x1d,0x00,0x00,0x3c,1600,1200, 0}, /* 21 - CRT1CRTC was 0x63 */ + {0x0007,0x24,0x1e,0x00,0x00,0x3c,1600,1200, 0}, /* 22 */ + {0x407f,0x00,0x00,0x00,0x00,0x40, 320, 200, 0}, /* 23 */ + {0xc07f,0x01,0x00,0x04,0x04,0x50, 320, 240, 0}, /* 24 */ + {0x0077,0x02,0x04,0x05,0x05,0x51, 400, 300, 0}, /* 25 */ + {0xc877,0x03,0x09,0x06,0x06,0x52, 512, 384, 0}, /* 26 */ /* was c077 */ + {0x8207,0x25,0x1f,0x00,0x00,0x68,1920,1440, 0}, /* 27 */ + {0x0007,0x26,0x20,0x00,0x00,0x6c,2048,1536, 0}, /* 28 */ + {0x0067,0x27,0x14,0x08,0x0a,0x6e,1280, 960, 0}, /* 29 - 1280x960-60 */ + {0x0027,0x45,0x3c,0x08,0x0a,0x6e,1280, 960, 0}, /* 2a - 1280x960-85 */ + {0xc077,0x33,0x09,0x06,0x00,0x20,1024, 600, 0}, /* 2b */ + {0xc077,0x34,0x0b,0x06,0x00,0x23,1152, 768, 0}, /* 2c */ /* VCLK 0x09 */ + {0x0057,0x35,0x27,0x08,0x00,0x70, 800, 480, 0}, /* 2d */ + {0x0047,0x36,0x37,0x08,0x00,0x70, 800, 480, 0}, /* 2e */ + {0x0047,0x37,0x08,0x08,0x00,0x70, 800, 480, 0}, /* 2f */ + {0x0057,0x38,0x09,0x09,0x00,0x71,1024, 576, 0}, /* 30 */ + {0x0047,0x39,0x38,0x09,0x00,0x71,1024, 576, 0}, /* 31 */ + {0x0047,0x3a,0x11,0x09,0x00,0x71,1024, 576, 0}, /* 32 */ + {0x0057,0x3b,0x39,0x0a,0x00,0x75,1280, 720, 0}, /* 33 */ + {0x0047,0x3c,0x3a,0x0a,0x00,0x75,1280, 720, 0}, /* 34 */ + {0x0007,0x3d,0x3b,0x0a,0x00,0x75,1280, 720, 0}, /* 35 */ + {0x0047,0x3e,0x34,0x06,0x00,0x29,1152, 864, 0}, /* 36 1152x864-75Hz */ + {0x0047,0x44,0x3a,0x06,0x00,0x29,1152, 864, 0}, /* 37 1152x864-85Hz */ + {0x00c7,0x3f,0x28,0x00,0x00,0x39, 848, 480, 0}, /* 38 848x480-38Hzi */ + {0xc067,0x40,0x3d,0x0b,0x0b,0x39, 848, 480, 0}, /* 39 848x480-60Hz */ + {0x00c7,0x41,0x28,0x00,0x00,0x3f, 856, 480, 0}, /* 3a 856x480-38Hzi */ + {0xc047,0x42,0x28,0x00,0x00,0x3f, 856, 480, 0}, /* 3b 856x480-60Hz */ + {0x0067,0x43,0x3e,0x0c,0x0b,0x48,1360, 768, 0}, /* 3c 1360x768-60Hz */ + {0x0077,0x46,0x3f,0x08,0x00,0x55,1280, 768, 0}, /* 3d 1280x768-60Hz */ + {0x004f,0x47,0x03,0x06,0x00,0x5f, 768, 576, 0}, /* 3e 768x576 */ + {0x0027,0x48,0x13,0x08,0x08,0x67,1360,1024, 0}, /* 3f 1360x1024-59Hz (BARCO1366 only) */ + {0xffff, 0, 0, 0, 0, 0, 0, 0, 0} +}; + +static const SiS_VBModeStruct SiS300_VBModeIDTable[] = { {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01}, @@ -291,6 +260,10 @@ static const SiS_VBModeIDTableStruct SiS300_VBModeIDTable[] = {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}, @@ -304,30 +277,32 @@ static const SiS_VBModeIDTableStruct SiS300_VBModeIDTable[] = {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}, + {0x6c,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, + {0x6d,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00} }; -typedef struct _SiS300_CRT1TableStruct -{ - UCHAR CR[17]; -} SiS300_CRT1TableStruct; - -static const SiS300_CRT1TableStruct SiS300_CRT1Table[] = +static const SiS_CRT1TableStruct SiS300_CRT1Table[] = { #if 1 {{0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, /* 0x00 - 320x200 */ @@ -592,13 +567,7 @@ static const SiS300_CRT1TableStruct SiS300_CRT1Table[] = 0x00}} /* 0x48 */ }; -typedef struct _SiS300_MCLKDataStruct -{ - UCHAR SR28,SR29,SR2A; - USHORT CLOCK; -} SiS300_MCLKDataStruct; - -static const SiS300_MCLKDataStruct SiS300_MCLKData_630[] = +static const SiS_MCLKDataStruct SiS300_MCLKData_630[] = { { 0x5a,0x64,0x80, 66}, { 0xb3,0x45,0x80, 83}, @@ -610,7 +579,7 @@ static const SiS300_MCLKDataStruct SiS300_MCLKData_630[] = { 0x37,0x61,0x80,100} }; -static const SiS300_MCLKDataStruct SiS300_MCLKData_300[] = +static const SiS_MCLKDataStruct SiS300_MCLKData_300[] = { { 0x68,0x43,0x80,125}, { 0x68,0x43,0x80,125}, @@ -622,33 +591,7 @@ static const SiS300_MCLKDataStruct SiS300_MCLKData_300[] = { 0x37,0x61,0x80,100} }; -#ifdef LINUXBIOS -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} -}; -#endif - -typedef struct _SiS300_VCLKDataStruct -{ - UCHAR SR2B,SR2C; - USHORT CLOCK; -} SiS300_VCLKDataStruct; - -static const SiS300_VCLKDataStruct SiS300_VCLKData[] = +static SiS_VCLKDataStruct SiS300_VCLKData[] = { { 0x1b,0xe1, 25}, /* 0x00 */ { 0x4e,0xe4, 28}, /* 0x01 */ @@ -722,75 +665,15 @@ static const SiS300_VCLKDataStruct SiS300_VCLKData[] = { 0xa1,0x42,108}, /* 0x42 */ /* 1280x960 LCD */ { 0x37,0x61,100}, /* 0x43 */ /* 1280x960 LCD */ { 0xe3,0x9a,106}, /* 0x44 */ /* 1360x1024 - special for Barco iQ R300 */ - { 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}, - { 0xff,0x00, 0} -}; -#endif - -static const UCHAR SiS300_ScreenOffset[] = -{ - 0x14,0x19,0x20,0x28,0x32,0x40,0x50, - 0x64,0x78,0x80,0x2d,0x35,0x48,0x35, - 0x55,0x30,0xff + { 0xe2,0x46,135}, /* 0x45 */ /* 1280x1024-75, better clock for VGA2 */ + { 0, 0, 0} /* 0x46 custom (will be filled out) */ }; #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}, @@ -824,17 +707,12 @@ 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 -typedef struct _SiS300_PanelDelayTblStruct -{ - UCHAR timer[2]; -} SiS300_PanelDelayTblStruct; - -static const SiS300_PanelDelayTblStruct SiS300_PanelDelayTbl[] = +static const SiS_PanelDelayTblStruct SiS300_PanelDelayTbl[] = { {{0x05,0xaa}}, {{0x05,0x14}}, @@ -854,7 +732,8 @@ static const SiS300_PanelDelayTblStruct SiS300_PanelDelayTbl[] = {{0x05,0x60}} }; -static const SiS300_PanelDelayTblStruct SiS300_PanelDelayTblLVDS[] = +#if 0 +static const SiS_PanelDelayTblStruct SiS300_PanelDelayTblLVDS[] = { {{0x05,0xaa}}, {{0x05,0x14}}, @@ -873,29 +752,24 @@ static const SiS300_PanelDelayTblStruct SiS300_PanelDelayTblLVDS[] = {{0x05,0x14}}, /* Some BIOSes: 05, 40 */ {{0x05,0x60}} }; +#endif -typedef struct _SiS300_LCDDataStruct -{ - USHORT RVBHCMAX; - USHORT RVBHCFACT; - USHORT VGAHT; - USHORT VGAVT; - USHORT LCDHT; - USHORT LCDVT; -} SiS300_LCDDataStruct; +/**************************************************************/ +/* SIS VIDEO BRIDGE ----------------------------------------- */ +/**************************************************************/ -static const SiS300_LCDDataStruct SiS300_StLCD1024x768Data[] = +static const SiS_LCDDataStruct SiS300_St2LCD1024x768Data[] = { - { 66, 31, 992, 510,1320, 816}, - { 66, 31, 992, 510,1320, 816}, - { 176, 75, 900, 510,1320, 816}, - { 176, 75, 900, 510,1320, 816}, - { 66, 31, 992, 510,1320, 816}, - { 27, 16,1024, 650,1350, 832}, + { 62, 25, 800, 546,1344, 806}, + { 32, 15, 930, 546,1344, 806}, + { 32, 15, 930, 546,1344, 806}, + { 104, 45, 945, 496,1344, 806}, + { 62, 25, 800, 546,1344, 806}, + { 31, 18,1008, 624,1344, 806}, { 1, 1,1344, 806,1344, 806} }; -static const SiS300_LCDDataStruct SiS300_ExtLCD1024x768Data[] = +static const SiS_LCDDataStruct SiS300_ExtLCD1024x768Data[] = { { 12, 5, 896, 512,1344, 806}, { 12, 5, 896, 510,1344, 806}, @@ -912,30 +786,19 @@ static const SiS300_LCDDataStruct SiS300_ExtLCD1024x768Data[] = { 1, 1,1344, 806,1344, 806} }; -static const SiS300_LCDDataStruct SiS300_St2LCD1024x768Data[] = -{ - { 62, 25, 800, 546,1344, 806}, - { 32, 15, 930, 546,1344, 806}, - { 32, 15, 930, 546,1344, 806}, - { 104, 45, 945, 496,1344, 806}, - { 62, 25, 800, 546,1344, 806}, - { 31, 18,1008, 624,1344, 806}, - { 1, 1,1344, 806,1344, 806} -}; - -static const SiS300_LCDDataStruct SiS300_StLCD1280x1024Data[] = +static const SiS_LCDDataStruct SiS300_St2LCD1280x1024Data[] = { - { 4, 1, 880, 510,1650,1088}, - { 4, 1, 880, 510,1650,1088}, + { 22, 5, 800, 510,1650,1088}, + { 22, 5, 800, 510,1650,1088}, { 176, 45, 900, 510,1650,1088}, { 176, 45, 900, 510,1650,1088}, - { 4, 1, 880, 510,1650,1088}, + { 22, 5, 800, 510,1650,1088}, { 13, 5,1024, 675,1560,1152}, { 16, 9,1266, 804,1688,1072}, { 1, 1,1688,1066,1688,1066} }; -static const SiS300_LCDDataStruct SiS300_ExtLCD1280x1024Data[] = +static const SiS_LCDDataStruct SiS300_ExtLCD1280x1024Data[] = { { 211, 60,1024, 501,1688,1066}, { 211, 60,1024, 508,1688,1066}, @@ -947,51 +810,53 @@ static const SiS300_LCDDataStruct SiS300_ExtLCD1280x1024Data[] = { 1, 1,1688,1066,1688,1066} }; -static const SiS300_LCDDataStruct SiS300_St2LCD1280x1024Data[] = -{ - { 22, 5, 800, 510,1650,1088}, - { 22, 5, 800, 510,1650,1088}, - { 176, 45, 900, 510,1650,1088}, - { 176, 45, 900, 510,1650,1088}, - { 22, 5, 800, 510,1650,1088}, - { 13, 5,1024, 675,1560,1152}, - { 16, 9,1266, 804,1688,1072}, - { 1, 1,1688,1066,1688,1066} +static const SiS_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 SiS_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}} }; -static const SiS300_LCDDataStruct SiS300_NoScaleData1024x768[] = +static const SiS_Part2PortTblStruct SiS300_CRT2Part2_1024x768_3[] = +{ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} +}; + +static const SiS_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_1[] = { - { 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} + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -static const SiS300_LCDDataStruct SiS300_NoScaleData1280x1024[] = /* TW: Fake */ +static const SiS_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_2[] = { - { 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} + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -typedef struct _SiS300_LVDSDataStruct +static const SiS_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_3[] = { - USHORT VGAHT; - USHORT VGAVT; - USHORT LCDHT; - USHORT LCDVT; -} SiS300_LVDSDataStruct; + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} +}; -static const SiS300_LVDSDataStruct SiS300_CHTVUPALData[] = +/**************************************************************/ +/* LVDS/Chrontel -------------------------------------------- */ +/**************************************************************/ + +static const SiS_LVDSDataStruct SiS300_CHTVUPALData[] = { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1001,7 +866,7 @@ static const SiS300_LVDSDataStruct SiS300_CHTVUPALData[] = { 936, 836, 936, 836} }; -static const SiS300_LVDSDataStruct SiS300_CHTVOPALData[] = +static const SiS_LVDSDataStruct SiS300_CHTVOPALData[] = { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1011,7 +876,7 @@ static const SiS300_LVDSDataStruct SiS300_CHTVOPALData[] = { 960, 750, 960, 750} }; -static const SiS300_LVDSDataStruct SiS300_CHTVSOPALData[] = +static const SiS_LVDSDataStruct SiS300_CHTVSOPALData[] = { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1021,13 +886,8 @@ static const SiS300_LVDSDataStruct SiS300_CHTVSOPALData[] = { 944, 625, 944, 625} }; -typedef struct _SiS300_LVDSDesStruct -{ - USHORT LCDHDES; - USHORT LCDVDES; -} SiS300_LVDSDesStruct; -static const SiS300_LVDSDesStruct SiS300_PanelType00_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType00_1[] = { { 1059, 626 }, /* 2.08 */ { 1059, 624 }, @@ -1051,7 +911,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType00_1[] = #endif }; -static const SiS300_LVDSDesStruct SiS300_PanelType01_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType01_1[] = { { 0, 0 }, /* 2.08 */ { 0, 0 }, @@ -1075,7 +935,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType01_1[] = #endif }; -static const SiS300_LVDSDesStruct SiS300_PanelType02_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType02_1[] = { { 1059, 626 }, /* 2.08 */ { 1059, 624 }, @@ -1099,7 +959,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType02_1[] = #endif }; -static const SiS300_LVDSDesStruct SiS300_PanelType03_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType03_1[] = { { 8, 436}, { 8, 440}, @@ -1112,7 +972,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType03_1[] = {1343, 794} }; -static const SiS300_LVDSDesStruct SiS300_PanelType04_1[] = /* 1280x1024 */ +static const SiS_LVDSDesStruct SiS300_PanelType04_1[] = /* 1280x1024 */ { {1343, 798}, {1343, 794}, @@ -1125,7 +985,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType04_1[] = /* 1280x1024 */ { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType05_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType05_1[] = { {1343, 798}, {1343, 794}, @@ -1138,7 +998,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType05_1[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType06_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType06_1[] = /* Clevo Trumpion 1024x768 */ { {1343, 798}, {1343, 794}, @@ -1151,7 +1011,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType06_1[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType07_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType07_1[] = { {1343, 798}, {1343, 794}, @@ -1164,7 +1024,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType07_1[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType08_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType08_1[] = { {1059, 626}, {1059, 624}, @@ -1177,7 +1037,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType08_1[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType09_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType09_1[] = { {1343, 798}, {1343, 794}, @@ -1190,7 +1050,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType09_1[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType0a_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType0a_1[] = { {1059, 626}, {1059, 624}, @@ -1203,7 +1063,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0a_1[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType0b_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType0b_1[] = { {1343, 0}, {1343, 0}, @@ -1216,7 +1076,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0b_1[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType0c_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType0c_1[] = { {1343, 798}, {1343, 794}, @@ -1229,7 +1089,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0c_1[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType0d_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType0d_1[] = { {1343, 798}, {1343, 794}, @@ -1242,7 +1102,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0d_1[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType0e_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType0e_1[] = { {1343, 798}, {1343, 794}, @@ -1255,7 +1115,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0e_1[] = { 0, 0} /* 1280x960 - not applicable */ }; -static const SiS300_LVDSDesStruct SiS300_PanelType0f_1[] = +static const SiS_LVDSDesStruct SiS300_PanelType0f_1[] = { {1343, 798}, {1343, 794}, @@ -1268,7 +1128,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0f_1[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType00_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType00_2[] = { {976, 527}, {976, 502}, @@ -1281,7 +1141,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType00_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType01_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType01_2[] = { {1152, 622}, {1152, 597}, @@ -1294,7 +1154,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType01_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType02_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType02_2[] = { {976, 527}, {976, 502}, @@ -1307,7 +1167,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType02_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType03_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType03_2[] = { {1152, 622}, {1152, 597}, @@ -1320,7 +1180,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType03_2[] = {1152, 597} }; -static const SiS300_LVDSDesStruct SiS300_PanelType04_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType04_2[] = { {1152, 622}, {1152, 597}, @@ -1333,7 +1193,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType04_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType05_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType05_2[] = { {1152, 622}, {1152, 597}, @@ -1346,7 +1206,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType05_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType06_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType06_2[] = { {1152, 622}, {1152, 597}, @@ -1359,7 +1219,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType06_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType07_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType07_2[] = { {1152, 622}, {1152, 597}, @@ -1372,7 +1232,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType07_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType08_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType08_2[] = { {976, 527}, {976, 502}, @@ -1385,7 +1245,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType08_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType09_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType09_2[] = { {1152, 622}, {1152, 597}, @@ -1398,7 +1258,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType09_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType0a_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType0a_2[] = { {976, 527}, {976, 502}, @@ -1411,7 +1271,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0a_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType0b_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType0b_2[] = { { 1152, 700}, { 1152, 675}, @@ -1424,7 +1284,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0b_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType0c_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType0c_2[] = { {1152, 622}, {1152, 597}, @@ -1437,7 +1297,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0c_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType0d_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType0d_2[] = { {1152, 622}, {1152, 597}, @@ -1450,7 +1310,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0d_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType0e_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType0e_2[] = { {1152, 622}, {1152, 597}, @@ -1463,7 +1323,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0e_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType0f_2[] = +static const SiS_LVDSDesStruct SiS300_PanelType0f_2[] = { {1152, 622}, {1152, 597}, @@ -1476,8 +1336,36 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0f_2[] = { 0, 0} }; +static const SiS_LVDSDesStruct SiS300_PanelTypeNS_1[]= +{ + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 805}, + { 0, 0}, + { 0, 0}, + { 0, 0} +}; + +static const SiS_LVDSDesStruct SiS300_PanelTypeNS_2[] = +{ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0} +}; + /* Custom data for Barco iQ R200/300/400 (BIOS 2.00.07) */ -static const SiS300_LVDSDesStruct SiS300_PanelType04_1a[] = /* 1280x1024 (1366x1024) */ +static const SiS_LVDSDesStruct SiS300_PanelType04_1a[] = /* 1280x1024 (1366x1024) */ { {1330, 798}, /* 320x200 */ {1330, 794}, @@ -1490,7 +1378,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType04_1a[] = /* 1280x1024 (1366x { 0, 0} /* 1360x1024 */ }; -static const SiS300_LVDSDesStruct SiS300_PanelType04_2a[] = +static const SiS_LVDSDesStruct SiS300_PanelType04_2a[] = { {1152, 622}, {1152, 597}, @@ -1504,7 +1392,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType04_2a[] = }; /* Custom data for Barco iQ G200/300/400 (BIOS 2.00.07) */ -static const SiS300_LVDSDesStruct SiS300_PanelType04_1b[] = /* 1024x768 */ +static const SiS_LVDSDesStruct SiS300_PanelType04_1b[] = /* 1024x768 */ { {1330, 798}, /* 320x200 */ {1330, 794}, @@ -1515,7 +1403,7 @@ static const SiS300_LVDSDesStruct SiS300_PanelType04_1b[] = /* 1024x768 */ { 0, 805} /* 1024x768 / 512x384 */ }; -static const SiS300_LVDSDesStruct SiS300_PanelType04_2b[] = +static const SiS_LVDSDesStruct SiS300_PanelType04_2b[] = { {1152, 622}, {1152, 597}, @@ -1526,90 +1414,9 @@ static const SiS300_LVDSDesStruct SiS300_PanelType04_2b[] = { 0, 805} }; +/* CRT1 CRTC for slave modes */ -typedef struct _SiS300_Part2PortTblStruct -{ - 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}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_2[] = -{ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1400x1050_2[] = -{ - {{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}} -}; - -typedef struct _SiS300_LVDSCRT1DataStruct -{ -UCHAR CR[15]; -} SiS300_LVDSCRT1DataStruct; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_1[] = +static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_1[] = { {{0x65,0x4f,0x89,0x56,0x83,0xaf,0x1f, 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, @@ -1631,7 +1438,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_1[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_1_H[] = +static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_1_H[] = { {{0x30,0x27,0x94,0x2c,0x92,0xaf,0x1f, 0x90,0x85,0x8f,0xab,0x30,0x00,0x04, @@ -1653,7 +1460,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_1_H[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1[] = +static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1[] = { {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, @@ -1678,7 +1485,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1[] = 0x01}} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1_H[] = +static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1_H[] = { {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, @@ -1727,7 +1534,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1_H[] = #endif }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1[] = +static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1[] = { {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f, 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, @@ -1752,7 +1559,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1_H[] = +static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1_H[] = { {{0x2f,0x27,0x93,0x2b,0x90,0xb4,0x1f, 0x92,0x89,0x8f,0xb5,0x30,0x00,0x04, @@ -1777,7 +1584,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1_H[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2[] = +static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2[] = { {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, 0xf4,0x88,0x8f,0x73,0x20,0x00,0x06, @@ -1799,7 +1606,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2_H[] = +static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2_H[] = { {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, 0xf4,0x88,0x8f,0x73,0x20,0x00,0x05, @@ -1821,7 +1628,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2_H[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2[] = +static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2[] = { {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, @@ -1846,7 +1653,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2_H[] = +static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2_H[] = { {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, @@ -1871,7 +1678,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2_H[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2[] = +static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2[] = { {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, @@ -1896,7 +1703,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2_H[] = +static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2_H[] = { {{0x4f,0x27,0x93,0x39,0x81,0x24,0xbb, 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, @@ -1921,7 +1728,64 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2_H[] = 0x01}} }; -static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1UNTSC[] = +static const SiS_LVDSCRT1DataStruct SiS300_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 SiS300_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 SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1UNTSC[] = { {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, 0xe8,0x84,0x8f,0x57,0x20,0x00,0x01, @@ -1943,7 +1807,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1UNTSC[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1ONTSC[] = +static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1ONTSC[] = { {{0x64,0x4f,0x88,0x5a,0x9f,0x0b,0x3e, 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01, @@ -1965,7 +1829,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1ONTSC[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1UPAL[] = +static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1UPAL[] = { {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05, @@ -1987,7 +1851,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1UPAL[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1OPAL[] = +static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1OPAL[] = { {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, @@ -2009,7 +1873,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1OPAL[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1SOPAL[] = +static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1SOPAL[] = { {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, @@ -2031,12 +1895,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1SOPAL[] = 0x01 }} }; -typedef struct _SiS300_CHTVRegDataStruct -{ - UCHAR Reg[16]; -} SiS300_CHTVRegDataStruct; - -static const SiS300_CHTVRegDataStruct SiS300_CHTVReg_UNTSC[] = +static const SiS_CHTVRegDataStruct SiS300_CHTVReg_UNTSC[] = { {{0x4a,0x94,0x00,0x48,0xfe,0,0,0,0,0,0,0,0,0,0,0}}, {{0x4a,0x94,0x00,0x48,0xfe,0,0,0,0,0,0,0,0,0,0,0}}, @@ -2046,7 +1905,7 @@ static const SiS300_CHTVRegDataStruct SiS300_CHTVReg_UNTSC[] = {{0x8d,0xc4,0x00,0x3b,0xfb,0,0,0,0,0,0,0,0,0,0,0}} /* Mode 24: 800x600 NTSC 7/10 */ }; -static const SiS300_CHTVRegDataStruct SiS300_CHTVReg_ONTSC[] = +static const SiS_CHTVRegDataStruct SiS300_CHTVReg_ONTSC[] = { {{0x49,0x94,0x00,0x34,0xfe,0,0,0,0,0,0,0,0,0,0,0}}, {{0x49,0x94,0x00,0x34,0xfe,0,0,0,0,0,0,0,0,0,0,0}}, @@ -2056,7 +1915,7 @@ static const SiS300_CHTVRegDataStruct SiS300_CHTVReg_ONTSC[] = {{0x8c,0xb4,0x00,0x32,0xf9,0,0,0,0,0,0,0,0,0,0,0}} /* Mode 23: 800x600 NTSC 3/4 */ }; -static const SiS300_CHTVRegDataStruct SiS300_CHTVReg_UPAL[] = +static const SiS_CHTVRegDataStruct SiS300_CHTVReg_UPAL[] = { {{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}}, @@ -2067,7 +1926,7 @@ static const SiS300_CHTVRegDataStruct SiS300_CHTVReg_UPAL[] = }; -static const SiS300_CHTVRegDataStruct SiS300_CHTVReg_OPAL[] = +static const SiS_CHTVRegDataStruct SiS300_CHTVReg_OPAL[] = { {{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}}, @@ -2078,7 +1937,7 @@ static const SiS300_CHTVRegDataStruct SiS300_CHTVReg_OPAL[] = }; -static const SiS300_CHTVRegDataStruct SiS300_CHTVReg_SOPAL[] = +static const SiS_CHTVRegDataStruct SiS300_CHTVReg_SOPAL[] = { {{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}}, diff --git a/src/310vtbl.h b/src/310vtbl.h index 42c597a..e33c190 100644 --- a/src/310vtbl.h +++ b/src/310vtbl.h @@ -1,273 +1,265 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/310vtbl.h,v 1.12 2003/08/07 12:52:22 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Register settings for SiS 315/330 series * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * If distributed as part of the linux kernel, the contents of this file - * is entirely covered by the GPL. + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * Otherwise, the following 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 * - * 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) 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 EXPRESSED 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 * - * Based on code by Silicon Intergrated Systems - * */ -typedef struct _SiS310_StStruct -{ - UCHAR St_ModeID; - USHORT St_ModeFlag; - UCHAR St_StTableIndex; - UCHAR St_CRT2CRTC; - UCHAR St_ResInfo; - UCHAR VB_StTVFlickerIndex; - UCHAR VB_StTVEdgeIndex; - UCHAR VB_StTVYFilterIndex; -} 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_ExtStruct -{ - UCHAR Ext_ModeID; - USHORT Ext_ModeFlag; - USHORT Ext_ModeInfo; - USHORT Ext_VESAID; - UCHAR Ext_RESINFO; - UCHAR VB_ExtTVFlickerIndex; - UCHAR VB_ExtTVEdgeIndex; - UCHAR VB_ExtTVYFilterIndex; - UCHAR REFindex; -} SiS310_ExtStruct; - -static const SiS310_ExtStruct SiS310_EModeIDTable[]= -{ - {0x6a,0x2212,0x0407,0x0102,SIS_RI_800x600, 0x00,0x00,0x07,0x00}, /* 800x600x? */ - {0x2e,0x0a1b,0x0306,0x0101,SIS_RI_640x480, 0x00,0x00,0x05,0x08}, /* 640x480x8 */ - {0x2f,0x0a1b,0x0305,0x0100,SIS_RI_640x400, 0x00,0x00,0x05,0x10}, /* 640x400x8 */ - {0x30,0x2a1b,0x0407,0x0103,SIS_RI_800x600, 0x00,0x00,0x07,0x00}, /* 800x600x8 */ - {0x31,0x0a1b,0x0a0d,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x11}, /* 720x480x8 */ - {0x32,0x0a1b,0x0a0e,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x12}, /* 720x576x8 */ - {0x33,0x0a1d,0x0a0d,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x11}, /* 720x480x16 */ - {0x34,0x2a1d,0x0a0e,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x12}, /* 720x576x16 */ - {0x35,0x0a1f,0x0a0d,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x11}, /* 720x480x32 */ - {0x36,0x2a1f,0x0a0e,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x12}, /* 720x576x32 */ - {0x37,0x0212,0x0508,0x0104,SIS_RI_1024x768, 0x00,0x00,0x08,0x13}, /* 1024x768x? */ - {0x38,0x0a1b,0x0508,0x0105,SIS_RI_1024x768, 0x00,0x00,0x08,0x13}, /* 1024x768x8 */ - {0x3a,0x0e3b,0x0609,0x0107,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a}, /* 1280x1024x8 */ - {0x3c,0x0e3b,0x070a,0x0130,SIS_RI_1600x1200,0x00,0x00,0x00,0x1e}, /* 1600x1200x8 */ - {0x3d,0x0e7d,0x070a,0x0131,SIS_RI_1600x1200,0x00,0x00,0x00,0x1e}, /* 1600x1200x16 */ - {0x40,0x9a1c,0x0000,0x010d,SIS_RI_320x200, 0x00,0x00,0x04,0x25}, /* 320x200x15 */ - {0x41,0x9a1d,0x0000,0x010e,SIS_RI_320x200, 0x00,0x00,0x04,0x25}, /* 320x200x16 */ - {0x43,0x0a1c,0x0306,0x0110,SIS_RI_640x480, 0x00,0x00,0x05,0x08}, - {0x44,0x0a1d,0x0306,0x0111,SIS_RI_640x480, 0x00,0x00,0x05,0x08}, /* 640x480x16 */ - {0x46,0x2a1c,0x0407,0x0113,SIS_RI_800x600, 0x00,0x00,0x07,0x00}, - {0x47,0x2a1d,0x0407,0x0114,SIS_RI_800x600, 0x00,0x00,0x07,0x00}, /* 800x600x16 */ - {0x49,0x0a3c,0x0508,0x0116,SIS_RI_1024x768, 0x00,0x00,0x00,0x13}, - {0x4a,0x0a3d,0x0508,0x0117,SIS_RI_1024x768, 0x00,0x00,0x08,0x13}, /* 1024x768x16 */ - {0x4c,0x0e7c,0x0609,0x0119,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a}, - {0x4d,0x0e7d,0x0609,0x011a,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a}, /* 1280x1024x16 */ - {0x50,0x9a1b,0x0001,0x0132,SIS_RI_320x240, 0x00,0x00,0x04,0x26}, /* 320x240x8 */ - {0x51,0xba1b,0x0103,0x0133,SIS_RI_400x300, 0x00,0x00,0x07,0x27}, /* 400x300x8 */ - {0x52,0xba1b,0x0204,0x0134,SIS_RI_512x384, 0x00,0x00,0x00,0x28}, /* 512x384x8 */ - {0x56,0x9a1d,0x0001,0x0135,SIS_RI_320x240, 0x00,0x00,0x04,0x26}, /* 320x240x16 */ - {0x57,0xba1d,0x0103,0x0136,SIS_RI_400x300, 0x00,0x00,0x07,0x27}, /* 400x300x16 */ - {0x58,0xba1d,0x0204,0x0137,SIS_RI_512x384, 0x00,0x00,0x00,0x28}, /* 512x384x16 */ - {0x59,0x9a1b,0x0000,0x0138,SIS_RI_320x200, 0x00,0x00,0x04,0x25}, /* 320x200x8 */ - {0x5a,0x021b,0x0014,0x0138,SIS_RI_320x240, 0x00,0x00,0x04,0x3f}, /* 320x240x8 fstn */ - {0x5b,0x0a1d,0x0014,0x0135,SIS_RI_320x240, 0x00,0x00,0x04,0x3f}, /* 320x240x16 fstn */ - {0x5c,0xba1f,0x0204,0x0000,SIS_RI_512x384, 0x00,0x00,0x00,0x28}, /* 512x384x32 */ - {0x5d,0x0a1d,0x0305,0x0139,SIS_RI_640x400, 0x00,0x00,0x05,0x10}, - {0x5e,0x0a1f,0x0305,0x0000,SIS_RI_640x400, 0x00,0x00,0x05,0x10}, /* 640x400x32 */ - {0x62,0x0a3f,0x0306,0x013a,SIS_RI_640x480, 0x00,0x00,0x05,0x08}, /* 640x480x32 */ - {0x63,0x2a3f,0x0407,0x013b,SIS_RI_800x600, 0x00,0x00,0x07,0x00}, /* 800x600x32 */ - {0x64,0x0a7f,0x0508,0x013c,SIS_RI_1024x768, 0x00,0x00,0x08,0x13}, /* 1024x768x32 */ - {0x65,0x0eff,0x0609,0x013d,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a}, /* 1280x1024x32 */ - {0x66,0x0eff,0x070a,0x013e,SIS_RI_1600x1200,0x00,0x00,0x00,0x1e}, /* 1600x1200x32 */ - {0x68,0x067b,0x080b,0x013f,SIS_RI_1920x1440,0x00,0x00,0x00,0x29}, /* 1920x1440x8 */ - {0x69,0x06fd,0x080b,0x0140,SIS_RI_1920x1440,0x00,0x00,0x00,0x29}, /* 1920x1440x16 */ - {0x6b,0x07ff,0x080b,0x0141,SIS_RI_1920x1440,0x00,0x00,0x00,0x29}, /* 1920x1440x32 */ - {0x6c,0x067b,0x090c,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x2f}, /* 2048x1536x8 */ - {0x6d,0x06fd,0x090c,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x2f}, /* 2048x1536x16 */ - {0x6e,0x07ff,0x090c,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x2f}, /* 2048x1536x32 */ - {0x70,0x2a1b,0x0410,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x34}, /* 800x480x8 */ - {0x71,0x0a1b,0x0511,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x37}, /* 1024x576x8 */ - {0x74,0x0a1d,0x0511,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x37}, /* 1024x576x16 */ - {0x75,0x0a3d,0x0612,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x3a}, /* 1280x720x16 */ - {0x76,0x2a1f,0x0410,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x34}, /* 800x480x32 */ - {0x77,0x0a1f,0x0511,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x37}, /* 1024x576x32 */ - {0x78,0x0a3f,0x0612,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x3a}, /* 1280x720x32 */ - {0x79,0x0a3b,0x0612,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x3a}, /* 1280x720x8 */ - {0x7a,0x2a1d,0x0410,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x34}, /* 800x480x16 */ - {0x7c,0x0e3b,0x060f,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x3d}, /* 1280x960x8 */ - {0x7d,0x0e7d,0x060f,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x3d}, /* 1280x960x16 */ - {0x7e,0x0eff,0x060f,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x3d}, /* 1280x960x32 */ - {0x23,0x0e3b,0x0614,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x40}, /* 1280x768x8 */ - {0x24,0x0e7d,0x0614,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x40}, /* 1280x768x16 */ - {0x25,0x0eff,0x0614,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x40}, /* 1280x768x32 */ - {0x26,0x0e3b,0x0c15,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x41}, /* 1400x1050x8 */ - {0x27,0x0e7d,0x0c15,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x41}, /* 1400x1050x16 */ - {0x28,0x0eff,0x0c15,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x41}, /* 1400x1050x32*/ - {0x29,0x0e1b,0x0d16,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x43}, /* 1152x864 */ - {0x2a,0x0e3d,0x0d16,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x43}, - {0x2b,0x0e7f,0x0d16,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x43}, - {0x39,0x2a1b,0x0b17,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x45}, /* 848x480 */ - {0x3b,0x2a3d,0x0b17,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x45}, - {0x3e,0x2a7f,0x0b17,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x45}, - {0x3f,0x2a1b,0x0b13,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x47}, /* 856x480 */ - {0x42,0x2a3d,0x0b13,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x47}, - {0x45,0x2a7f,0x0b13,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x47}, - {0x48,0x2a1b,0x0e18,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x49}, /* 1360x768 */ - {0x4b,0x2a3d,0x0e18,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x49}, - {0x4e,0x2a7f,0x0e18,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x49}, - {0x4f,0x9a1f,0x0000,0x0000,SIS_RI_320x200, 0x00,0x00,0x04,0x25}, /* 320x200x32 */ - {0x53,0x9a1f,0x0001,0x0000,SIS_RI_320x240, 0x00,0x00,0x04,0x26}, /* 320x240x32 */ - {0x54,0xba1f,0x0103,0x0000,SIS_RI_400x300, 0x00,0x00,0x07,0x27}, /* 400x300x32 */ - {0x5f,0x2a1b,0x0f0e,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x4a}, /* 768x576x8 */ - {0x60,0x2a1d,0x0f0e,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x4a}, /* 768x576x16 */ - {0x61,0x2a1f,0x0f0e,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x4a}, /* 768x576x32 */ - {0xff,0x0000,0x0000,0x0000,0x00, 0x00,0x00,0x00,0x00} -}; - -typedef struct _SiS310_Ext2Struct -{ - USHORT Ext_InfoFlag; - UCHAR Ext_CRT1CRTC; - UCHAR Ext_CRTVCLK; - UCHAR Ext_CRT2CRTC; - UCHAR ModeID; - USHORT XRes; - USHORT YRes; -} SiS310_Ext2Struct; - -static const SiS310_Ext2Struct SiS310_RefIndex[]= -{ - {0x085f,0x0d,0x03,0x05,0x6a, 800, 600}, /* 0x0 */ - {0x0467,0x0e,0x04,0x05,0x6a, 800, 600}, /* 0x1 */ - {0x0067,0x0f,0x08,0x48,0x6a, 800, 600}, /* 0x2 */ - {0x0067,0x10,0x07,0x8b,0x6a, 800, 600}, /* 0x3 */ - {0x0147,0x11,0x0a,0x00,0x6a, 800, 600}, /* 0x4 */ - {0x0147,0x12,0x0d,0x00,0x6a, 800, 600}, /* 0x5 - TW: Test sync change */ - {0x0047,0x13,0x13,0x00,0x6a, 800, 600}, /* 0x6 */ - {0x0047,0x14,0x1c,0x00,0x6a, 800, 600}, /* 0x7 */ - {0xc85f,0x05,0x00,0x04,0x2e, 640, 480}, /* 0x8 */ - {0xc067,0x06,0x02,0x04,0x2e, 640, 480}, /* 0x9 */ - {0xc067,0x07,0x02,0x47,0x2e, 640, 480}, /* 0xa */ - {0xc067,0x08,0x03,0x8a,0x2e, 640, 480}, /* 0xb */ - {0xc047,0x09,0x05,0x00,0x2e, 640, 480}, /* 0xc */ - {0xc047,0x0a,0x09,0x00,0x2e, 640, 480}, /* 0xd */ - {0xc047,0x0b,0x0e,0x00,0x2e, 640, 480}, /* 0xe */ - {0xc047,0x0c,0x15,0x00,0x2e, 640, 480}, /* 0xf */ - {0x407f,0x04,0x00,0x00,0x2f, 640, 400}, /* 0x10 */ - {0xc00f,0x3c,0x01,0x06,0x31, 720, 480}, /* 0x11 */ - {0x000f,0x3d,0x03,0x06,0x32, 720, 576}, /* 0x12 */ - {0x0187,0x15,0x06,0x00,0x37,1024, 768}, /* 0x13 */ - {0xc877,0x16,0x0b,0x06,0x37,1024, 768}, /* 0x14 */ - {0xc067,0x17,0x0f,0x49,0x37,1024, 768}, /* 0x15 */ - {0x0267,0x18,0x11,0x00,0x37,1024, 768}, /* 0x16 */ - {0x0047,0x19,0x16,0x8c,0x37,1024, 768}, /* 0x17 */ - {0x0047,0x1a,0x1b,0x00,0x37,1024, 768}, /* 0x18 */ - {0x0007,0x1b,0x1f,0x00,0x37,1024, 768}, /* 0x19 */ - {0x0387,0x1c,0x11,0x00,0x3a,1280,1024}, /* 0x1a */ - {0x0077,0x1d,0x19,0x07,0x3a,1280,1024}, /* 0x1b */ - {0x0047,0x1e,0x1e,0x00,0x3a,1280,1024}, /* 0x1c */ - {0x0007,0x1f,0x20,0x00,0x3a,1280,1024}, /* 0x1d */ - {0x0867,0x20,0x21,0x09,0x3c,1600,1200}, /* 0x1e */ - {0x0007,0x21,0x22,0x00,0x3c,1600,1200}, /* 0x1f */ - {0x0007,0x22,0x23,0x00,0x3c,1600,1200}, /* 0x20 */ - {0x0007,0x23,0x25,0x00,0x3c,1600,1200}, /* 0x21 */ - {0x0007,0x24,0x26,0x00,0x3c,1600,1200}, /* 0x22 */ - {0x0007,0x25,0x2c,0x00,0x3c,1600,1200}, /* 0x23 */ - {0x0007,0x26,0x34,0x00,0x3c,1600,1200}, /* 0x24 */ - {0x407f,0x00,0x00,0x00,0x40, 320, 200}, /* 0x25 */ - {0xc07f,0x01,0x00,0x04,0x50, 320, 240}, /* 0x26 */ - {0x007f,0x02,0x04,0x05,0x51, 400, 300}, /* 0x27 */ - {0xc077,0x03,0x0b,0x06,0x52, 512, 384}, /* 0x28 */ - {0x8007,0x27,0x27,0x00,0x68,1920,1440}, /* 0x29 */ - {0x4007,0x28,0x29,0x00,0x68,1920,1440}, /* 0x2a */ - {0x4007,0x29,0x2e,0x00,0x68,1920,1440}, /* 0x2b */ - {0x4007,0x2a,0x30,0x00,0x68,1920,1440}, /* 0x2c */ - {0x4007,0x2b,0x35,0x00,0x68,1920,1440}, /* 0x2d */ - {0x4005,0x2c,0x39,0x00,0x68,1920,1440}, /* 0x2e */ - {0x4007,0x2d,0x2b,0x00,0x6c,2048,1536}, /* 0x2f */ - {0x4007,0x2e,0x31,0x00,0x6c,2048,1536}, /* 0x30 */ - {0x4007,0x2f,0x33,0x00,0x6c,2048,1536}, /* 0x31 */ - {0x4007,0x30,0x37,0x00,0x6c,2048,1536}, /* 0x32 */ - {0x4005,0x31,0x38,0x00,0x6c,2048,1536}, /* 0x33 */ - {0x0057,0x32,0x40,0x08,0x70, 800, 480}, /* 0x34 */ - {0x0047,0x33,0x07,0x08,0x70, 800, 480}, /* 0x35 */ - {0x0047,0x34,0x0a,0x08,0x70, 800, 480}, /* 0x36 */ - {0x0057,0x35,0x0b,0x09,0x71,1024, 576}, /* 0x37 */ - {0x0047,0x36,0x11,0x09,0x71,1024, 576}, /* 0x38 */ - {0x0047,0x37,0x16,0x09,0x71,1024, 576}, /* 0x39 */ - {0x0057,0x38,0x19,0x0a,0x75,1280, 720}, /* 0x3a */ - {0x0047,0x39,0x1e,0x0a,0x75,1280, 720}, /* 0x3b */ - {0x0007,0x3a,0x20,0x0a,0x75,1280, 720}, /* 0x3c */ - {0x0067,0x3b,0x19,0x08,0x7c,1280, 960}, /* 0x3d */ - {0x0027,0x4c,0x59,0x08,0x7c,1280, 960}, /* 0x3e */ - {0xc07f,0x4e,0x00,0x06,0x5a, 320, 240}, /* 0x3f */ /* FSTN 320x240 */ - {0x0077,0x42,0x5b,0x08,0x23,1280, 768}, /* 0x40 */ /* TW: 0x5b was 0x12 */ - {0x0067,0x43,0x4d,0x08,0x26,1400,1050}, /* 0x41 */ - {0x0007,0x4b,0x5a,0x08,0x26,1400,1050}, /* 0x42 TW: not in any BIOS */ - {0x0047,0x44,0x19,0x00,0x29,1152, 864}, /* 0x43 TW: Non-BIOS, new */ - {0x0047,0x4a,0x1e,0x00,0x29,1152, 864}, /* 0x44 TW: Non-BIOS, new */ - {0x00c7,0x45,0x57,0x00,0x39, 848, 480}, /* 0x45 TW: 848x480-38Hzi - Non-BIOS, new */ - {0xc067,0x46,0x55,0x0b,0x39, 848, 480}, /* 0x46 TW: 848x480-60Hz - Non-BIOS, new */ - {0x00c7,0x47,0x57,0x00,0x3f, 856, 480}, /* 0x47 TW: 856x480-38Hzi - Non-BIOS, new */ - {0xc047,0x48,0x57,0x00,0x3f, 856, 480}, /* 0x48 TW: 856x480-60Hz - Non-BIOS, new */ - {0x0067,0x49,0x58,0x0c,0x48,1360, 768}, /* 0x49 TW: 1360x768-60Hz - Non-BIOS, new */ - {0x000f,0x4d,0x03,0x06,0x5f, 768, 576}, /* 0x4a TW: 768x576 */ - {0xffff,0x00,0x00,0x00,0x00, 0, 0} -}; - -typedef struct _SiS310_CRT1TableStruct -{ - UCHAR CR[17]; -} SiS310_CRT1TableStruct; - -static const SiS310_CRT1TableStruct SiS310_CRT1Table[]= +static const SiS_StStruct SiS310_SModeIDTable[]= +{ + {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} +}; + +static const SiS_ExtStruct SiS310_EModeIDTable[]= +{ + {0x6a,0x2212,0x0102,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00, 3}, /* 800x600x? */ + {0x2e,0x0a1b,0x0101,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08, 2}, /* 640x480x8 */ + {0x2f,0x0a1b,0x0100,SIS_RI_640x400, 0x00,0x00,0x05,0x05,0x10, 0}, /* 640x400x8 */ + {0x30,0x2a1b,0x0103,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00, 3}, /* 800x600x8 */ + {0x31,0x4a1b,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x06,0x11,-1}, /* 720x480x8 */ + {0x32,0x4a1b,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x06,0x12,-1}, /* 720x576x8 */ + {0x33,0x4a1d,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x06,0x11,-1}, /* 720x480x16 */ + {0x34,0x6a1d,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x06,0x12,-1}, /* 720x576x16 */ + {0x35,0x4a1f,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x06,0x11,-1}, /* 720x480x32 */ + {0x36,0x6a1f,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x06,0x12,-1}, /* 720x576x32 */ + {0x37,0x0212,0x0104,SIS_RI_1024x768, 0x00,0x00,0x08,0x07,0x13, 4}, /* 1024x768x? */ + {0x38,0x0a1b,0x0105,SIS_RI_1024x768, 0x00,0x00,0x08,0x07,0x13, 4}, /* 1024x768x8 */ + {0x3a,0x0e3b,0x0107,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a, 8}, /* 1280x1024x8 */ + {0x3c,0x0e3b,0x0130,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e,10}, /* 1600x1200x8 */ + {0x3d,0x0e7d,0x0131,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e,10}, /* 1600x1200x16 */ + {0x40,0x9a1c,0x010d,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25, 0}, /* 320x200x15 */ + {0x41,0x9a1d,0x010e,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25, 0}, /* 320x200x16 */ + {0x43,0x0a1c,0x0110,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08, 2}, + {0x44,0x0a1d,0x0111,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08, 2}, /* 640x480x16 */ + {0x46,0x2a1c,0x0113,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00, 3}, + {0x47,0x2a1d,0x0114,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00, 3}, /* 800x600x16 */ + {0x49,0x0a3c,0x0116,SIS_RI_1024x768, 0x00,0x00,0x00,0x07,0x13, 4}, + {0x4a,0x0a3d,0x0117,SIS_RI_1024x768, 0x00,0x00,0x08,0x07,0x13, 4}, /* 1024x768x16 */ + {0x4c,0x0e7c,0x0119,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a, 8}, + {0x4d,0x0e7d,0x011a,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a, 8}, /* 1280x1024x16 */ + {0x50,0x9a1b,0x0132,SIS_RI_320x240, 0x00,0x00,0x04,0x04,0x26, 2}, /* 320x240x8 */ + {0x51,0xba1b,0x0133,SIS_RI_400x300, 0x00,0x00,0x07,0x07,0x27, 3}, /* 400x300x8 */ + {0x52,0xba1b,0x0134,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28, 4}, /* 512x384x8 */ + {0x56,0x9a1d,0x0135,SIS_RI_320x240, 0x00,0x00,0x04,0x04,0x26, 2}, /* 320x240x16 */ + {0x57,0xba1d,0x0136,SIS_RI_400x300, 0x00,0x00,0x07,0x07,0x27, 3}, /* 400x300x16 */ + {0x58,0xba1d,0x0137,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28, 4}, /* 512x384x16 */ + {0x59,0x9a1b,0x0138,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25, 0}, /* 320x200x8 */ + {0x5a,0x021b,0x0138,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x3f, 2}, /* 320x240x8 fstn */ + {0x5b,0x0a1d,0x0135,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x3f, 2}, /* 320x240x16 fstn */ + {0x5c,0xba1f,0x0000,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28, 4}, /* 512x384x32 */ + {0x5d,0x0a1d,0x0139,SIS_RI_640x400, 0x00,0x00,0x05,0x07,0x10, 0}, + {0x5e,0x0a1f,0x0000,SIS_RI_640x400, 0x00,0x00,0x05,0x07,0x10, 0}, /* 640x400x32 */ + {0x62,0x0a3f,0x013a,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08, 2}, /* 640x480x32 */ + {0x63,0x2a3f,0x013b,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00, 3}, /* 800x600x32 */ + {0x64,0x0a7f,0x013c,SIS_RI_1024x768, 0x00,0x00,0x08,0x07,0x13, 4}, /* 1024x768x32 */ + {0x65,0x0eff,0x013d,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a, 8}, /* 1280x1024x32 */ + {0x66,0x0eff,0x013e,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e,10}, /* 1600x1200x32 */ + {0x68,0x067b,0x013f,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x29,-1}, /* 1920x1440x8 */ + {0x69,0x06fd,0x0140,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x29,-1}, /* 1920x1440x16 */ + {0x6b,0x07ff,0x0141,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x29,-1}, /* 1920x1440x32 */ + {0x6c,0x067b,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x2f,-1}, /* 2048x1536x8 */ + {0x6d,0x06fd,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x2f,-1}, /* 2048x1536x16 */ + {0x6e,0x07ff,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x2f,-1}, /* 2048x1536x32 */ + {0x70,0x6a1b,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x07,0x34,-1}, /* 800x480x8 */ + {0x71,0x4a1b,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x37,-1}, /* 1024x576x8 */ + {0x74,0x4a1d,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x37,-1}, /* 1024x576x16 */ + {0x75,0x0a3d,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x3a, 5}, /* 1280x720x16 */ + {0x76,0x6a1f,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x07,0x34,-1}, /* 800x480x32 */ + {0x77,0x4a1f,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x37,-1}, /* 1024x576x32 */ + {0x78,0x0a3f,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x3a, 5}, /* 1280x720x32 */ + {0x79,0x0a3b,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x3a, 5}, /* 1280x720x8 */ + {0x7a,0x6a1d,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x07,0x34,-1}, /* 800x480x16 */ + {0x7c,0x0e3b,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x3d,-1}, /* 1280x960x8 */ + {0x7d,0x0e7d,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x3d,-1}, /* 1280x960x16 */ + {0x7e,0x0eff,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x3d,-1}, /* 1280x960x32 */ + {0x23,0x0e3b,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x40, 6}, /* 1280x768x8 */ + {0x24,0x0e7d,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x40, 6}, /* 1280x768x16 */ + {0x25,0x0eff,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x40, 6}, /* 1280x768x32 */ + {0x26,0x0e3b,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x41, 9}, /* 1400x1050x8 */ + {0x27,0x0e7d,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x41, 9}, /* 1400x1050x16 */ + {0x28,0x0eff,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x41, 9}, /* 1400x1050x32*/ + {0x29,0x4e1b,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x43,-1}, /* 1152x864 */ + {0x2a,0x4e3d,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x43,-1}, + {0x2b,0x4e7f,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x43,-1}, + {0x39,0x6a1b,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x45,-1}, /* 848x480 */ + {0x3b,0x6a3d,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x45,-1}, + {0x3e,0x6a7f,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x45,-1}, + {0x3f,0x6a1b,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x47,-1}, /* 856x480 */ + {0x42,0x6a3d,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x47,-1}, + {0x45,0x6a7f,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x47,-1}, + {0x48,0x6a3b,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x49,-1}, /* 1360x768 */ + {0x4b,0x6a7d,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x49,-1}, + {0x4e,0x6aff,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x49,-1}, + {0x4f,0x9a1f,0x0000,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25, 0}, /* 320x200x32 */ + {0x53,0x9a1f,0x0000,SIS_RI_320x240, 0x00,0x00,0x04,0x04,0x26, 2}, /* 320x240x32 */ + {0x54,0xba1f,0x0000,SIS_RI_400x300, 0x00,0x00,0x07,0x07,0x27, 3}, /* 400x300x32 */ + {0x5f,0x6a1b,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4a,-1}, /* 768x576 */ + {0x60,0x6a1d,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4a,-1}, + {0x61,0x6a3f,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4a,-1}, + {0x14,0x0e3b,0x0000,SIS_RI_1280x800, 0x00,0x00,0x00,0x00,0x4b, 7}, /* 1280x800 */ + {0x15,0x0e7d,0x0000,SIS_RI_1280x800, 0x00,0x00,0x00,0x00,0x4b, 7}, + {0x16,0x0eff,0x0000,SIS_RI_1280x800, 0x00,0x00,0x00,0x00,0x4b, 7}, + {0x17,0x0e3b,0x0000,SIS_RI_1680x1050,0x00,0x00,0x00,0x00,0x4c, 9}, /* 1680x1050 */ + {0x18,0x0e7d,0x0000,SIS_RI_1680x1050,0x00,0x00,0x00,0x00,0x4c, 9}, + {0x19,0x0eff,0x0000,SIS_RI_1680x1050,0x00,0x00,0x00,0x00,0x4c, 9}, + {0x2c,0x267b,0x0000,SIS_RI_1920x1080,0x00,0x00,0x00,0x00,0x4d,-1}, /* 1920x1080(i) */ + {0x2d,0x26fd,0x0000,SIS_RI_1920x1080,0x00,0x00,0x00,0x00,0x4d,-1}, + {0x73,0x27ff,0x0000,SIS_RI_1920x1080,0x00,0x00,0x00,0x00,0x4d,-1}, + {0x1d,0x6a1b,0x0000,SIS_RI_960x540, 0x00,0x00,0x00,0x00,0x4e,-1}, /* 960x540 */ + {0x1e,0x6a3d,0x0000,SIS_RI_960x540, 0x00,0x00,0x00,0x00,0x4e,-1}, + {0x1f,0x6a7f,0x0000,SIS_RI_960x540, 0x00,0x00,0x00,0x00,0x4e,-1}, + {0xff,0x0000,0x0000,0, 0x00,0x00,0x00,0x00,0x00,-1} +}; + +static const SiS_Ext2Struct SiS310_RefIndex[]= +{ + {0x085f,0x0d,0x03,0x05,0x05,0x6a, 800, 600, 0x40}, /* 0x0 */ + {0x0067,0x0e,0x04,0x05,0x05,0x6a, 800, 600, 0x40}, /* 0x1 */ + {0x0067,0x0f,0x08,0x48,0x05,0x6a, 800, 600, 0x40}, /* 0x2 */ + {0x0067,0x10,0x07,0x8b,0x05,0x6a, 800, 600, 0x40}, /* 0x3 */ + {0x0047,0x11,0x0a,0x00,0x05,0x6a, 800, 600, 0x40}, /* 0x4 */ + {0x0047,0x12,0x0d,0x00,0x05,0x6a, 800, 600, 0x40}, /* 0x5 */ + {0x0047,0x13,0x13,0x00,0x05,0x6a, 800, 600, 0x20}, /* 0x6 */ + {0x0107,0x14,0x1c,0x00,0x05,0x6a, 800, 600, 0x20}, /* 0x7 */ + {0xc85f,0x05,0x00,0x04,0x04,0x2e, 640, 480, 0x40}, /* 0x8 */ + {0xc067,0x06,0x02,0x04,0x04,0x2e, 640, 480, 0x40}, /* 0x9 */ + {0xc067,0x07,0x02,0x47,0x04,0x2e, 640, 480, 0x40}, /* 0xa */ + {0xc067,0x08,0x03,0x8a,0x04,0x2e, 640, 480, 0x40}, /* 0xb */ + {0xc047,0x09,0x05,0x00,0x04,0x2e, 640, 480, 0x40}, /* 0xc */ + {0xc047,0x0a,0x09,0x00,0x04,0x2e, 640, 480, 0x40}, /* 0xd */ + {0xc047,0x0b,0x0e,0x00,0x04,0x2e, 640, 480, 0x40}, /* 0xe */ + {0xc047,0x0c,0x15,0x00,0x04,0x2e, 640, 480, 0x40}, /* 0xf */ + {0x487f,0x04,0x00,0x00,0x00,0x2f, 640, 400, 0x30}, /* 0x10 */ + {0xc06f,0x3c,0x01,0x06,0x13,0x31, 720, 480, 0x30}, /* 0x11 */ + {0x006f,0x3d,0x03,0x06,0x14,0x32, 720, 576, 0x30}, /* 0x12 */ + {0x0087,0x15,0x06,0x00,0x06,0x37,1024, 768, 0x30}, /* 0x13 */ + {0xc877,0x16,0x0b,0x06,0x06,0x37,1024, 768, 0x20}, /* 0x14 */ + {0xc067,0x17,0x0f,0x49,0x06,0x37,1024, 768, 0x20}, /* 0x15 */ + {0x0067,0x18,0x11,0x00,0x06,0x37,1024, 768, 0x20}, /* 0x16 */ + {0x0047,0x19,0x16,0x8c,0x06,0x37,1024, 768, 0x20}, /* 0x17 */ + {0x0107,0x1a,0x1b,0x00,0x06,0x37,1024, 768, 0x10}, /* 0x18 */ + {0x0107,0x1b,0x1f,0x00,0x06,0x37,1024, 768, 0x10}, /* 0x19 */ + {0x0087,0x1c,0x11,0x00,0x07,0x3a,1280,1024, 0x30}, /* 0x1a */ + {0x0137,0x1d,0x19,0x07,0x07,0x3a,1280,1024, 0x00}, /* 0x1b */ + {0x0107,0x1e,0x1e,0x00,0x07,0x3a,1280,1024, 0x00}, /* 0x1c */ + {0x0207,0x1f,0x20,0x00,0x07,0x3a,1280,1024, 0x00}, /* 0x1d */ + {0x0227,0x20,0x21,0x09,0x09,0x3c,1600,1200, 0x00}, /* 0x1e */ + {0x0407,0x21,0x22,0x00,0x09,0x3c,1600,1200, 0x00}, /* 0x1f */ + {0x0407,0x22,0x23,0x00,0x09,0x3c,1600,1200, 0x00}, /* 0x20 */ + {0x0407,0x23,0x25,0x00,0x09,0x3c,1600,1200, 0x00}, /* 0x21 */ + {0x0007,0x24,0x26,0x00,0x09,0x3c,1600,1200, 0x00}, /* 0x22 */ + {0x0007,0x25,0x2c,0x00,0x09,0x3c,1600,1200, 0x00}, /* 0x23 */ + {0x0007,0x26,0x34,0x00,0x09,0x3c,1600,1200, 0x00}, /* 0x24 */ + {0x407f,0x00,0x00,0x00,0x00,0x40, 320, 200, 0x30}, /* 0x25 */ + {0xc07f,0x01,0x00,0x04,0x04,0x50, 320, 240, 0x30}, /* 0x26 */ + {0x007f,0x02,0x04,0x05,0x05,0x51, 400, 300, 0x30}, /* 0x27 */ + {0xc077,0x03,0x0b,0x06,0x06,0x52, 512, 384, 0x30}, /* 0x28 */ + {0x8007,0x27,0x27,0x00,0x00,0x68,1920,1440, 0x00}, /* 0x29 */ + {0x4007,0x28,0x29,0x00,0x00,0x68,1920,1440, 0x00}, /* 0x2a */ + {0x4007,0x29,0x2e,0x00,0x00,0x68,1920,1440, 0x00}, /* 0x2b */ + {0x4007,0x2a,0x30,0x00,0x00,0x68,1920,1440, 0x00}, /* 0x2c */ + {0x4007,0x2b,0x35,0x00,0x00,0x68,1920,1440, 0x00}, /* 0x2d */ + {0x4005,0x2c,0x39,0x00,0x00,0x68,1920,1440, 0x00}, /* 0x2e */ + {0x4007,0x2d,0x2b,0x00,0x00,0x6c,2048,1536, 0x00}, /* 0x2f */ + {0x4007,0x2e,0x31,0x00,0x00,0x6c,2048,1536, 0x00}, /* 0x30 */ + {0x4007,0x2f,0x33,0x00,0x00,0x6c,2048,1536, 0x00}, /* 0x31 */ + {0x4007,0x30,0x37,0x00,0x00,0x6c,2048,1536, 0x00}, /* 0x32 */ + {0x4005,0x31,0x38,0x00,0x00,0x6c,2048,1536, 0x00}, /* 0x33 */ + {0x0077,0x32,0x40,0x08,0x18,0x70, 800, 480, 0x30}, /* 0x34 */ + {0x0047,0x33,0x07,0x08,0x18,0x70, 800, 480, 0x30}, /* 0x35 */ + {0x0047,0x34,0x0a,0x08,0x18,0x70, 800, 480, 0x30}, /* 0x36 */ + {0x0077,0x35,0x0b,0x09,0x19,0x71,1024, 576, 0x30}, /* 0x37 */ + {0x0047,0x36,0x11,0x09,0x19,0x71,1024, 576, 0x30}, /* 0x38 */ + {0x0047,0x37,0x16,0x09,0x19,0x71,1024, 576, 0x30}, /* 0x39 */ + {0x1137,0x38,0x19,0x0a,0x0c,0x75,1280, 720, 0x30}, /* 0x3a */ + {0x1107,0x39,0x1e,0x0a,0x0c,0x75,1280, 720, 0x30}, /* 0x3b */ + {0x1307,0x3a,0x20,0x0a,0x0c,0x75,1280, 720, 0x30}, /* 0x3c */ + {0x0127,0x3b,0x19,0x08,0x0a,0x7c,1280, 960, 0x30}, /* 0x3d */ + {0x0227,0x4c,0x59,0x08,0x0a,0x7c,1280, 960, 0x20}, /* 0x3e */ + {0xc07f,0x4e,0x00,0x06,0x04,0x5a, 320, 240, 0x30}, /* 0x3f */ /* FSTN 320x240 */ + {0x0077,0x42,0x5b,0x08,0x11,0x23,1280, 768, 0x30}, /* 0x40 */ /* 0x5b was 0x12 */ + {0x0127,0x43,0x4d,0x08,0x0b,0x26,1400,1050, 0x30}, /* 0x41 */ + {0x0207,0x4b,0x5a,0x08,0x0b,0x26,1400,1050, 0x30}, /* 0x42 1400x1050-75Hz */ + {0x0127,0x44,0x19,0x00,0x1a,0x29,1152, 864, 0x30}, /* 0x43 1152x864-75Hz */ + {0x0127,0x4a,0x1e,0x00,0x1a,0x29,1152, 864, 0x30}, /* 0x44 1152x864-85Hz */ + {0x0087,0x45,0x57,0x00,0x16,0x39, 848, 480, 0x30}, /* 0x45 848x480-38Hzi */ + {0xc067,0x46,0x55,0x0b,0x16,0x39, 848, 480, 0x30}, /* 0x46 848x480-60Hz */ + {0x0087,0x47,0x57,0x00,0x17,0x3f, 856, 480, 0x30}, /* 0x47 856x480-38Hzi */ + {0xc067,0x48,0x57,0x00,0x17,0x3f, 856, 480, 0x30}, /* 0x48 856x480-60Hz */ + {0x0067,0x49,0x58,0x0c,0x1b,0x48,1360, 768, 0x30}, /* 0x49 1360x768-60Hz */ + {0x006f,0x4d,0x03,0x06,0x15,0x5f, 768, 576, 0x30}, /* 0x4a 768x576-56Hz */ + {0x0067,0x4f,0x5c,0x08,0x0d,0x14,1280, 800, 0x30}, /* 0x4b 1280x800-60Hz */ + {0x0067,0x50,0x5d,0x0c,0x0e,0x17,1680,1050, 0x30}, /* 0x4c 1680x1050-60Hz */ + {0x0087,0x51,0x69,0x00,0x00,0x2c,1920,1080, 0x30}, /* 0x4d 1920x1080 60Hzi */ + {0x0067,0x52,0x6a,0x00,0x1c,0x1d, 960, 540, 0x30}, /* 0x4e 960x540 60Hz */ + {0xffff,0x00,0x00,0x00,0x00,0x00, 0, 0, 0} +}; + +static const SiS_CRT1TableStruct SiS310_CRT1Table[]= { {{0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x00, @@ -288,7 +280,7 @@ static const SiS310_CRT1TableStruct SiS310_CRT1Table[]= {{0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x05, 0x00}}, /* 0x5 */ -#endif +#endif {{0x5f,0x4f,0x4f,0x83,0x55,0x81,0x0b,0x3e, /* 0x05 - corrected 640x480-60 */ 0xe9,0x8b,0xdf,0xe8,0x0c,0x00,0x00,0x05, 0x00}}, @@ -307,16 +299,16 @@ static const SiS310_CRT1TableStruct SiS310_CRT1Table[]= 0xe0,0x83,0xdf,0xdf,0xfc,0x10,0x00,0x05, 0x00}}, /* 0x8 */ {{0x65,0x4f,0x4f,0x89,0x58,0x80,0xfb,0x1f, - 0xe0,0x83,0xdf,0xdf,0xfc,0x10,0x00,0x05, /* TW: Corrected VBE */ + 0xe0,0x83,0xdf,0xdf,0xfc,0x10,0x00,0x05, /* Corrected VBE */ 0x61}}, /* 0x9 */ {{0x65,0x4f,0x4f,0x89,0x58,0x80,0x01,0x3e, 0xe0,0x83,0xdf,0xdf,0x02,0x00,0x00,0x05, 0x61}}, /* 0xa */ {{0x67,0x4f,0x4f,0x8b,0x58,0x81,0x0d,0x3e, - 0xe0,0x83,0xdf,0xdf,0x0e,0x00,0x00,0x05, /* TW: Corrected VBE */ + 0xe0,0x83,0xdf,0xdf,0x0e,0x00,0x00,0x05, /* Corrected VBE */ 0x61}}, /* 0xb */ {{0x65,0x4f,0x4f,0x89,0x57,0x9f,0xfb,0x1f, - 0xe6,0x8a,0xdf,0xdf,0xfc,0x10,0x00,0x01, /* TW: Corrected VDE, VBE */ + 0xe6,0x8a,0xdf,0xdf,0xfc,0x10,0x00,0x01, /* Corrected VDE, VBE */ 0x00}}, /* 0xc */ {{0x7b,0x63,0x63,0x9f,0x6a,0x93,0x6f,0xf0, 0x58,0x8a,0x57,0x57,0x70,0x20,0x00,0x05, @@ -444,7 +436,7 @@ static const SiS310_CRT1TableStruct SiS310_CRT1Table[]= {{0x9f,0x7f,0x7f,0x83,0x85,0x91,0x1e,0xf1, 0xad,0x81,0x3f,0x3f,0x1f,0x30,0x00,0x02, 0x01}}, /* 0x36 */ - {{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}}, /* 0x37 */ {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x28,0xc4, @@ -476,7 +468,7 @@ static const SiS310_CRT1TableStruct SiS310_CRT1Table[]= {{0x81,0x6a,0x6a,0x85,0x70,0x00,0x0f,0x3e, 0xeb,0x8e,0xdf,0xdf,0x10,0x00,0x00,0x02, 0x00}}, /* 0x3f */ - {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x1e,0xf1, /* TW: The following from 650/LVDS BIOS */ + {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x1e,0xf1, 0xae,0x85,0x57,0x57,0x1f,0x30,0x00,0x02, 0x01}}, /* 0x40 */ {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, @@ -488,31 +480,31 @@ static const SiS310_CRT1TableStruct SiS310_CRT1Table[]= {{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, /* 1152x864-75 */ 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, /* 848x480-38i */ 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, /* 848x480-60 */ 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, /* 856x480-38i */ 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, /* 856x480-60 */ 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, /* 1360x768-60 */ 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, /* 1152x864-84 */ 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, /* 1400x1050-75 */ 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, /* 1280x960-85 */ 0xc0,0x83,0xbf,0xbf,0xf2,0x10,0x00,0x07, 0x01}}, /* 0x4c */ {{0x7b,0x5f,0x63,0x9f,0x6a,0x93,0x6f,0xf0, /* 768x576 */ @@ -520,17 +512,22 @@ static const SiS310_CRT1TableStruct SiS310_CRT1Table[]= 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; - USHORT CLOCK; -} SiS310_MCLKDataStruct; - -#ifdef LINUXBIOS -static const SiS310_MCLKDataStruct SiS310_MCLKData_0_315[] = + 0x00}}, /* 0x4e */ + {{0xcd,0x9f,0x9f,0x91,0xab,0x1c,0x3a,0xff, /* 1280x800-60 */ + 0x20,0x83,0x1f,0x1f,0x3b,0x10,0x00,0x07, + 0x21}}, /* 0x4f */ + {{0x15,0xd1,0xd1,0x99,0xe2,0x19,0x3d,0x10, /* 1680x1050-60 */ + 0x1a,0x8d,0x19,0x19,0x3e,0x2f,0x01,0x0c, + 0x20}}, /* 0x50 */ + {{0x0e,0xef,0xef,0x92,0xfe,0x03,0x30,0xf0, /* 1920x1080-60i */ + 0x1e,0x83,0x1b,0x1c,0x31,0x00,0x01,0x00, + 0x61}}, /* 0x51 */ + {{0x85,0x77,0x77,0x89,0x7d,0x01,0x31,0xf0, /* 960x540-60 */ + 0x1e,0x84,0x1b,0x1c,0x32,0x00,0x00,0x02, + 0x41}} /* 0x52 */ +}; + +static const SiS_MCLKDataStruct SiS310_MCLKData_0_315[] = { { 0x3b,0x22,0x01,143}, { 0x5c,0x23,0x01,166}, @@ -542,7 +539,7 @@ static const SiS310_MCLKDataStruct SiS310_MCLKData_0_315[] = { 0x5c,0x23,0x01,166} }; -static const SiS310_MCLKDataStruct SiS310_MCLKData_0_650[] = +static const SiS_MCLKDataStruct SiS310_MCLKData_0_650[] = { { 0x5a,0x64,0x82, 66}, { 0xb3,0x45,0x82, 83}, @@ -553,9 +550,8 @@ static const SiS310_MCLKDataStruct SiS310_MCLKData_0_650[] = { 0x37,0x22,0x82,133}, { 0x37,0x22,0x82,133} }; -#endif -static const SiS310_MCLKDataStruct SiS310_MCLKData_0_330[] = +static const SiS_MCLKDataStruct SiS310_MCLKData_0_330[] = { { 0x5c,0x23,0x01,166}, { 0x5c,0x23,0x01,166}, @@ -567,21 +563,55 @@ static const SiS310_MCLKDataStruct SiS310_MCLKData_0_330[] = { 0x79,0x06,0x01,250} }; -#ifdef LINUXBIOS -static const SiS310_MCLKDataStruct SiS310_MCLKData_0_660[] = /* TODO */ +static const SiS_MCLKDataStruct SiS310_MCLKData_0_660[] = +{ + { 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 SiS_MCLKDataStruct SiS310_MCLKData_0_760[] = +{ + { 0x37,0x22,0x82,133}, + { 0x5c,0x23,0x82,166}, + { 0x65,0x23,0x82,183}, + { 0x7c,0x08,0x82,200}, + { 0x29,0x21,0x82,150}, + { 0x5c,0x23,0x82,166}, + { 0x65,0x23,0x82,183}, + { 0x37,0x21,0x82,200} +}; + +static const SiS_MCLKDataStruct SiS310_MCLKData_0_761[] = +{ + { 0x37,0x22,0x82,133}, /* Preliminary */ + { 0x5c,0x23,0x82,166}, + { 0x65,0x23,0x82,183}, + { 0x7c,0x08,0x82,200}, + { 0x29,0x21,0x82,150}, + { 0x5c,0x23,0x82,166}, + { 0x65,0x23,0x82,183}, + { 0x37,0x21,0x82,200} +}; + +static const SiS_MCLKDataStruct SiS310_MCLKData_0_340[] = { - { 0x5c,0x23,0x01,166}, - { 0x5c,0x23,0x01,166}, - { 0x7c,0x08,0x01,200}, { 0x79,0x06,0x01,250}, { 0x7c,0x08,0x01,200}, - { 0x7c,0x08,0x01,200}, - { 0x7c,0x08,0x01,200}, - { 0x79,0x06,0x01,250} + { 0x7c,0x08,0x80,200}, + { 0x79,0x06,0x80,250}, + { 0x29,0x01,0x81,300}, + { 0x29,0x01,0x81,300}, + { 0x29,0x01,0x81,300}, + { 0x29,0x01,0x81,300} }; -#endif -static const SiS310_MCLKDataStruct SiS310_MCLKData_1[] = +static const SiS_MCLKDataStruct SiS310_MCLKData_1[] = /* ECLK */ { { 0x29,0x21,0x82,150}, { 0x5c,0x23,0x82,166}, @@ -593,29 +623,19 @@ static const SiS310_MCLKDataStruct SiS310_MCLKData_1[] = { 0x37,0x22,0x82,133} }; -#ifdef LINUXBIOS -typedef struct _SiS310_ECLKDataStruct -{ - UCHAR SR2E,SR2F,SR30; - USHORT CLOCK; -} SiS310_ECLKDataStruct; - -static const SiS310_ECLKDataStruct SiS310_ECLKData[]= +static const SiS_MCLKDataStruct SiS310_MCLKData_1_340[] = { - { 0x5c,0x23,0x01,166}, - { 0x5c,0x23,0x01,166}, - { 0x5c,0x23,0x01,166}, - { 0x5c,0x23,0x01,166} + { 0x7c,0x08,0x01,200}, + { 0x7c,0x08,0x01,200}, + { 0x7c,0x08,0x80,200}, + { 0x79,0x06,0x80,250}, + { 0x29,0x01,0x81,300}, + { 0x29,0x01,0x81,300}, + { 0x29,0x01,0x81,300}, + { 0x29,0x01,0x81,300} }; -#endif -typedef struct _SiS310_VCLKDataStruct -{ - UCHAR SR2B,SR2C; - USHORT CLOCK; -} SiS310_VCLKDataStruct; - -static const SiS310_VCLKDataStruct SiS310_VCLKData[]= +static SiS_VCLKDataStruct SiS310_VCLKData[]= { { 0x1b,0xe1, 25}, /* 0x00 */ { 0x4e,0xe4, 28}, /* 0x01 */ @@ -628,7 +648,7 @@ static const SiS310_VCLKDataStruct SiS310_VCLKData[]= { 0x53,0xe2, 50}, /* 0x08 */ { 0x74,0x67, 52}, /* 0x09 */ { 0x6d,0x66, 56}, /* 0x0a */ - { 0x5a,0x64, 65}, /* 0x0b */ /* TW: was 6c c3 - WRONG */ + { 0x5a,0x64, 65}, /* 0x0b */ /* was 6c c3 - WRONG */ { 0x46,0x44, 67}, /* 0x0c */ { 0xb1,0x46, 68}, /* 0x0d */ { 0xd3,0x4a, 72}, /* 0x0e */ @@ -642,7 +662,7 @@ static const SiS310_VCLKDataStruct SiS310_VCLKData[]= { 0x62,0x44, 94}, /* 0x16 */ { 0x2b,0x41,104}, /* 0x17 */ { 0x3a,0x23,105}, /* 0x18 */ - { 0x70,0x44,108}, /* 0x19 */ /* 1400x1050 LCD */ + { 0x70,0x44,108}, /* 0x19 */ { 0x3c,0x23,109}, /* 0x1a */ { 0x5e,0x43,113}, /* 0x1b */ { 0xbc,0x44,116}, /* 0x1c */ @@ -675,49 +695,58 @@ static const SiS310_VCLKDataStruct SiS310_VCLKData[]= { 0xea,0x08,340}, /* 0x37 */ { 0xe8,0x07,376}, /* 0x38 */ { 0xde,0x06,389}, /* 0x39 */ - { 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 */ + { 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 */ - { 0x9f,0x46, 44}, /* 0x43 */ /* Chrontel */ + { 0x60,0x36, 30}, /* 0x41 Chrontel */ + { 0x40,0x4a, 28}, /* 0x42 Chrontel */ + { 0x9f,0x46, 44}, /* 0x43 Chrontel */ { 0x97,0x2c, 26}, /* 0x44 */ - { 0x44,0xe4, 25}, /* 0x45 */ /* Chrontel */ - { 0x7e,0x32, 47}, /* 0x46 */ /* Chrontel */ - { 0x8a,0x24, 31}, /* 0x47 */ /* Chrontel */ - { 0x97,0x2c, 26}, /* 0x48 */ /* Chrontel */ + { 0x44,0xe4, 25}, /* 0x45 Chrontel */ + { 0x7e,0x32, 47}, /* 0x46 Chrontel */ + { 0x8a,0x24, 31}, /* 0x47 Chrontel */ + { 0x97,0x2c, 26}, /* 0x48 Chrontel */ { 0xce,0x3c, 39}, /* 0x49 */ - { 0x52,0x4a, 36}, /* 0x4a */ /* Chrontel */ + { 0x52,0x4a, 36}, /* 0x4a Chrontel */ { 0x34,0x61, 95}, /* 0x4b */ { 0x78,0x27,108}, /* 0x4c - was 102 */ - { 0x66,0x43,123}, /* 0x4d */ /* Modes 0x26-0x28 (1400x1050) */ + { 0x66,0x43,123}, /* 0x4d Modes 0x26-0x28 (1400x1050) */ { 0x41,0x4e, 21}, /* 0x4e */ - { 0xa1,0x4a, 29}, /* 0x4f */ /* Chrontel */ + { 0xa1,0x4a, 29}, /* 0x4f Chrontel */ { 0x19,0x42, 42}, /* 0x50 */ - { 0x54,0x46, 58}, /* 0x51 */ /* Chrontel */ + { 0x54,0x46, 58}, /* 0x51 Chrontel */ { 0x25,0x42, 61}, /* 0x52 */ - { 0x44,0x44, 66}, /* 0x53 */ /* Chrontel */ - { 0x3a,0x62, 70}, /* 0x54 */ /* Chrontel */ - { 0x62,0xc6, 34}, /* 0x55 - added for 848x480-60 (not in any BIOS) */ - { 0x6a,0xc6, 37}, /* 0x56 - added for 848x480-75 (not in any BIOS) - TEMP */ - { 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 */ - { 0x70,0x29, 81} /* 0x5b */ /* 1280x768 LCD */ -}; - -typedef struct _SiS310_VBVCLKDataStruct -{ - UCHAR Part4_A,Part4_B; - USHORT CLOCK; -} SiS310_VBVCLKDataStruct; - -static const SiS310_VBVCLKDataStruct SiS310_VBVCLKData[]= + { 0x44,0x44, 66}, /* 0x53 Chrontel */ + { 0x3a,0x62, 70}, /* 0x54 Chrontel */ + { 0x62,0xc6, 34}, /* 0x55 848x480-60 */ + { 0x6a,0xc6, 37}, /* 0x56 848x480-75 - TEMP */ + { 0xbf,0xc8, 35}, /* 0x57 856x480-38i,60 */ + { 0x30,0x23, 88}, /* 0x58 1360x768-62 (is 60Hz!) */ + { 0x52,0x07,149}, /* 0x59 1280x960-85 */ + { 0x56,0x07,156}, /* 0x5a 1400x1050-75 */ + { 0x70,0x29, 81}, /* 0x5b 1280x768 LCD */ + { 0x45,0x25, 83}, /* 0x5c 1280x800 */ + { 0x70,0x0a,147}, /* 0x5d 1680x1050 */ + { 0x70,0x24,162}, /* 0x5e 1600x1200 */ + { 0x5a,0x64, 65}, /* 0x5f 1280x720 - temp */ + { 0x63,0x46, 68}, /* 0x60 1280x768_2 */ + { 0x31,0x42, 79}, /* 0x61 1280x768_3 - temp */ + { 0, 0, 0}, /* 0x62 - custom (will be filled out at run-time) */ + { 0x5a,0x64, 65}, /* 0x63 1280x720 (LCD LVDS) */ + { 0x70,0x28, 90}, /* 0x64 1152x864@60 */ + { 0x41,0xc4, 32}, /* 0x65 848x480@60 */ + { 0x5c,0xc6, 32}, /* 0x66 856x480@60 */ + { 0x76,0xe7, 27}, /* 0x67 720x480@60 */ + { 0x5f,0xc6, 33}, /* 0x68 720/768x576@60 */ + { 0x52,0x27, 75}, /* 0x69 1920x1080i 60Hz interlaced */ + { 0x7c,0x6b, 38} /* 0x6a 960x540@60 */ +}; + +static SiS_VBVCLKDataStruct SiS310_VBVCLKData[]= { { 0x1b,0xe1, 25}, /* 0x00 */ { 0x4e,0xe4, 28}, /* 0x01 */ @@ -730,7 +759,7 @@ static const SiS310_VBVCLKDataStruct SiS310_VBVCLKData[]= { 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 */ + { 0x35,0x62, 65}, /* 0x0b */ /* Was 0x5a,0x64 - 650/LVDS+301: 35,62 */ { 0x46,0x44, 67}, /* 0x0c */ { 0xb1,0x46, 68}, /* 0x0d */ { 0xd3,0x4a, 72}, /* 0x0e */ @@ -749,10 +778,16 @@ static const SiS310_VBVCLKDataStruct SiS310_VBVCLKData[]= { 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 */ @@ -777,50 +812,58 @@ static const SiS310_VBVCLKDataStruct SiS310_VBVCLKData[]= { 0xea,0x08,340}, /* 0x37 */ { 0xe8,0x07,376}, /* 0x38 */ { 0xde,0x06,389}, /* 0x39 */ - { 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 */ + { 0x52,0x2a, 54}, /* 0x3a 301 TV - start */ + { 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 */ /* 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 */ + { 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 */ - { 0x52,0x4a, 36}, /* 0x4a */ /* UNUSED */ - { 0x34,0x61, 95}, /* 0x4b */ /* UNUSED */ - { 0x78,0x27,108}, /* 0x4c */ /* UNUSED */ - { 0x66,0x43,123}, /* 0x4d */ /* 1400x1050-60 */ - { 0x41,0x4e, 21}, /* 0x4e */ /* UNUSED */ - { 0xa1,0x4a, 29}, /* 0x4f */ /* UNUSED */ - { 0x19,0x42, 42}, /* 0x50 */ /* UNUSED */ - { 0x54,0x46, 58}, /* 0x51 */ /* UNUSED */ - { 0x25,0x42, 61}, /* 0x52 */ /* UNUSED */ - { 0x44,0x44, 66}, /* 0x53 */ /* UNUSED */ - { 0x3a,0x62, 70}, /* 0x54 */ /* UNUSED */ - { 0x62,0xc6, 34}, /* 0x55 */ /* 848x480-60 */ - { 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 */ - { 0x70,0x29, 81} /* 0x5b */ /* 1280x768 LCD */ -}; - -static const UCHAR SiS310_ScreenOffset[] = -{ - 0x14,0x19,0x20,0x28,0x32,0x40,0x50,0x64, - 0x78,0x80,0x2d,0x35,0x57,0x48,0x55,0x30, - 0xff -}; - -static const UCHAR SiS310_SR15[8][4]={ + { 0x97,0x2c, 26}, /* 0x48 UNUSED */ + { 0xce,0x3c, 39}, /* 0x49 UNUSED */ + { 0x52,0x4a, 36}, /* 0x4a UNUSED */ + { 0x34,0x61, 95}, /* 0x4b UNUSED */ + { 0x78,0x27,108}, /* 0x4c UNUSED */ + { 0x66,0x43,123}, /* 0x4d 1400x1050-60 */ + { 0x41,0x4e, 21}, /* 0x4e UNUSED */ + { 0xa1,0x4a, 29}, /* 0x4f UNUSED */ + { 0x19,0x42, 42}, /* 0x50 UNUSED */ + { 0x54,0x46, 58}, /* 0x51 UNUSED */ + { 0x25,0x42, 61}, /* 0x52 UNUSED */ + { 0x44,0x44, 66}, /* 0x53 UNUSED */ + { 0x3a,0x62, 70}, /* 0x54 UNUSED */ + { 0x62,0xc6, 34}, /* 0x55 848x480-60 */ + { 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 */ + { 0x56,0x07,156}, /* 0x5a 1400x1050-75 */ + { 0x70,0x29, 81}, /* 0x5b 1280x768 LCD */ + { 0x45,0x25, 83}, /* 0x5c 1280x800 LCD - (was 0x9c,0x62, 69 - wrong?) */ + { 0xbe,0x44,121}, /* 0x5d 1680x1050 LCD */ + { 0x70,0x24,162}, /* 0x5e 1600x1200 LCD */ + { 0x52,0x27, 75}, /* 0x5f 1280x720 LCD TMDS + HDTV (correct) */ + { 0x63,0x46, 68}, /* 0x60 1280x768_2 */ + { 0x31,0x42, 79}, /* 0x61 1280x768_3 - temp */ + { 0, 0, 0}, /* 0x62 - custom (will be filled out at run-time) */ + { 0x5a,0x64, 65}, /* 0x63 1280x720 (LCD LVDS) */ + { 0x70,0x28, 90}, /* 0x64 1152x864@60 */ + { 0x41,0xc4, 32}, /* 0x65 848x480@60 */ + { 0x5c,0xc6, 32}, /* 0x66 856x480@60 */ + { 0x76,0xe7, 27}, /* 0x67 720x480@60 */ + { 0x5f,0xc6, 33}, /* 0x68 720/768x576@60 */ + { 0x52,0x27, 75}, /* 0x69 1920x1080i 60Hz interlaced (UNUSED) */ + { 0x7c,0x6b, 38} /* 0x6a 960x540@60 */ +}; + +static const DRAM4Type SiS310_SR15[8] = { {0x00,0x04,0x60,0x60}, {0x0f,0x0f,0x0f,0x0f}, {0xba,0xba,0xba,0xba}, @@ -835,7 +878,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}, @@ -865,28 +908,62 @@ static const USHORT SiS310_VideoSenseData2 = 0x0174; static const USHORT SiS310_YCSenseData2 = 0x016b; #endif -typedef struct _SiS310_LCDDataStruct +static const SiS_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 SiS_PanelDelayTblStruct SiS310_PanelDelayTblLVDS[]= { - USHORT RVBHCMAX; - USHORT RVBHCFACT; - USHORT VGAHT; - USHORT VGAVT; - USHORT LCDHT; - USHORT LCDVT; -} SiS310_LCDDataStruct; + {{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}} +}; -static const SiS310_LCDDataStruct SiS310_StLCD1024x768Data[]= +/**************************************************************/ +/* SIS VIDEO BRIDGE ----------------------------------------- */ +/**************************************************************/ + +static const SiS_LCDDataStruct SiS310_St2LCD1024x768Data[] = { { 62, 25, 800, 546,1344, 806}, { 32, 15, 930, 546,1344, 806}, - { 32, 15, 930, 546,1344, 806}, + { 62, 25, 800, 546,1344, 806}, { 104, 45, 945, 496,1344, 806}, { 62, 25, 800, 546,1344, 806}, { 31, 18,1008, 624,1344, 806}, { 1, 1,1344, 806,1344, 806} }; -static const SiS310_LCDDataStruct SiS310_ExtLCD1024x768Data[] = +static const SiS_LCDDataStruct SiS310_ExtLCD1024x768Data[] = { { 42, 25,1536, 419,1344, 806}, { 48, 25,1536, 369,1344, 806}, @@ -894,28 +971,10 @@ static const SiS310_LCDDataStruct SiS310_ExtLCD1024x768Data[] = { 48, 25,1536, 369,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} - -}; - -static const SiS310_LCDDataStruct SiS310_St2LCD1024x768Data[] = -{ - { 62, 25, 800, 546,1344, 806}, - { 32, 15, 930, 546,1344, 806}, - { 62, 25, 800, 546,1344, 806}, - { 104, 45, 945, 496,1344, 806}, - { 62, 25, 800, 546,1344, 806}, - { 31, 18,1008, 624,1344, 806}, { 1, 1,1344, 806,1344, 806} }; -static const SiS310_LCDDataStruct SiS310_StLCD1280x1024Data[] = +static const SiS_LCDDataStruct SiS310_St2LCD1280x1024Data[] = { { 22, 5, 800, 510,1650,1088}, { 22, 5, 800, 510,1650,1088}, @@ -927,7 +986,7 @@ static const SiS310_LCDDataStruct SiS310_StLCD1280x1024Data[] = { 1, 1,1688,1066,1688,1066} }; -static const SiS310_LCDDataStruct SiS310_ExtLCD1280x1024Data[] = +static const SiS_LCDDataStruct SiS310_ExtLCD1280x1024Data[] = { { 211, 60,1024, 501,1688,1066}, { 211, 60,1024, 508,1688,1066}, @@ -936,102 +995,48 @@ static const SiS310_LCDDataStruct SiS310_ExtLCD1280x1024Data[] = { 211, 60,1024, 500,1688,1066}, { 211, 75,1024, 625,1688,1066}, { 211, 120,1280, 798,1688,1066}, - { 1, 1,1688,1066,1688,1066}, - { 1, 1,1800,1000,1688,1066} /* 1280x960 - does not work, use panel scaler instead */ -}; - -static const SiS310_LCDDataStruct SiS310_St2LCD1280x1024Data[] = -{ - { 22, 5, 800, 510,1650,1088}, - { 22, 5, 800, 510,1650,1088}, - { 176, 45, 900, 510,1650,1088}, - { 176, 45, 900, 510,1650,1088}, - { 22, 5, 800, 510,1650,1088}, - { 13, 5,1024, 675,1560,1152}, - { 16, 9,1266, 804,1688,1072}, { 1, 1,1688,1066,1688,1066} }; -static const SiS310_LCDDataStruct SiS310_NoScaleData1024x768[] = -{ - { 1, 1,1344, 806,1344, 806}, - { 1, 1,1344, 806,1344, 806}, - { 1, 1,1344, 806,1344, 806}, - { 1, 1,1344, 806,1344, 806}, /* 640x400 - does not work */ - { 1, 1,1344, 806,1344, 806}, /* 640x480 - does not work */ - { 1, 1,1344, 806,1344, 806}, - { 1, 1,1344, 806,1344, 806}, - { 1, 1,1344, 806,1344, 806} -}; - -static const SiS310_LCDDataStruct SiS310_NoScaleData1280x1024[] = +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_1024x768_1[] = { - { 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} + {{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}} }; +/* *** LCDA *** */ -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}} +#if 0 +static const SiS_LVDSDataStruct SiS_LCDA1600x1200Data_1[]= +{ /* Clevo, 651+301C */ + {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}, +#if 0 + {2048,1250, 2048,1250} /* this should be correct */ +#endif +#if 1 + {2160,1250, 2048,1250} /* ? */ +#endif }; +#endif -typedef struct _SiS310_LVDSDataStruct -{ - USHORT VGAHT; - USHORT VGAVT; - USHORT LCDHT; - USHORT LCDVT; -} SiS310_LVDSDataStruct; +/**************************************************************/ +/* LVDS, CHRONTEL ------------------------------------------- */ +/**************************************************************/ -static const SiS310_LVDSDataStruct SiS310_CHTVUPALData[]= +static const SiS_LVDSDataStruct SiS310_CHTVUPALData[]= { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1042,7 +1047,7 @@ static const SiS310_LVDSDataStruct SiS310_CHTVUPALData[]= {1400,1000,1400,1000} }; -static const SiS310_LVDSDataStruct SiS310_CHTVOPALData[]= +static const SiS_LVDSDataStruct SiS310_CHTVOPALData[]= { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1053,7 +1058,7 @@ static const SiS310_LVDSDataStruct SiS310_CHTVOPALData[]= {1400, 875,1400, 875} }; -static const SiS310_LVDSDataStruct SiS310_CHTVUPALMData[]= +static const SiS_LVDSDataStruct SiS310_CHTVUPALMData[]= { { 840, 600, 840, 600}, { 840, 600, 840, 600}, @@ -1064,7 +1069,7 @@ static const SiS310_LVDSDataStruct SiS310_CHTVUPALMData[]= {1160, 945,1160, 945} }; -static const SiS310_LVDSDataStruct SiS310_CHTVOPALMData[]= +static const SiS_LVDSDataStruct SiS310_CHTVOPALMData[]= { { 840, 525, 840, 525}, { 840, 525, 840, 525}, @@ -1075,7 +1080,7 @@ static const SiS310_LVDSDataStruct SiS310_CHTVOPALMData[]= {1160, 840,1160, 840} }; -static const SiS310_LVDSDataStruct SiS310_CHTVUPALNData[]= +static const SiS_LVDSDataStruct SiS310_CHTVUPALNData[]= { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1086,7 +1091,7 @@ static const SiS310_LVDSDataStruct SiS310_CHTVUPALNData[]= {1400,1000,1400,1000} }; -static const SiS310_LVDSDataStruct SiS310_CHTVOPALNData[]= +static const SiS_LVDSDataStruct SiS310_CHTVOPALNData[]= { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1097,7 +1102,7 @@ static const SiS310_LVDSDataStruct SiS310_CHTVOPALNData[]= {1400, 875,1400, 875} }; -static const SiS310_LVDSDataStruct SiS310_CHTVSOPALData[]= /* TW: (super overscan - no effect on 7019) */ +static const SiS_LVDSDataStruct SiS310_CHTVSOPALData[]= /* (super overscan - no effect on 7019) */ { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1108,13 +1113,8 @@ static const SiS310_LVDSDataStruct SiS310_CHTVSOPALData[]= /* TW: (super over {1400, 875,1400, 875} }; -typedef struct _SiS310_LVDSDesStruct -{ - USHORT LCDHDES; - USHORT LCDVDES; -} SiS310_LVDSDesStruct; -static const SiS310_LVDSDesStruct SiS310_PanelType00_1[]= /* 800x600 */ +static const SiS_LVDSDesStruct SiS310_PanelType00_1[]= /* 800x600 */ { { 0, 0}, { 0, 0}, @@ -1127,7 +1127,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType00_1[]= /* 800x600 */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType01_1[]= /* 1024x768 */ +static const SiS_LVDSDesStruct SiS310_PanelType01_1[]= /* 1024x768 */ { { 0, 0}, { 0, 0}, @@ -1140,7 +1140,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType01_1[]= /* 1024x768 */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType02_1[]= /* 1280x1024 */ +static const SiS_LVDSDesStruct SiS310_PanelType02_1[]= /* 1280x1024 */ { { 0, 0}, { 0, 0}, @@ -1155,7 +1155,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType02_1[]= /* 1280x1024 */ }; -static const SiS310_LVDSDesStruct SiS310_PanelType03_1[]= +static const SiS_LVDSDesStruct SiS310_PanelType03_1[]= { { 0, 0}, { 0, 0}, @@ -1168,7 +1168,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType03_1[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType04_1[]= +static const SiS_LVDSDesStruct SiS310_PanelType04_1[]= { {1343, 798}, {1343, 794}, @@ -1181,7 +1181,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType04_1[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType05_1[]= +static const SiS_LVDSDesStruct SiS310_PanelType05_1[]= { {1343, 798}, {1343, 794}, @@ -1194,7 +1194,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType05_1[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType06_1[]= +static const SiS_LVDSDesStruct SiS310_PanelType06_1[]= { {1343, 798}, {1343, 794}, @@ -1207,7 +1207,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType06_1[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType07_1[]= +static const SiS_LVDSDesStruct SiS310_PanelType07_1[]= { {1343, 798}, {1343, 794}, @@ -1220,7 +1220,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType07_1[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType08_1[]= /* 1400x1050 */ +static const SiS_LVDSDesStruct SiS310_PanelType08_1[]= /* 1400x1050 */ { { 0, 0}, { 0, 0}, @@ -1235,7 +1235,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType08_1[]= /* 1400x1050 */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType09_1[]= /* 1280x768 */ +static const SiS_LVDSDesStruct SiS310_PanelType09_1[]= /* 1280x768 */ { { 0, 0}, { 0, 0}, @@ -1250,7 +1250,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType09_1[]= /* 1280x768 */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0a_1[]= /* 1600x1200 */ +static const SiS_LVDSDesStruct SiS310_PanelType0a_1[]= /* 1600x1200 */ { { 0, 0}, { 0, 0}, @@ -1265,7 +1265,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0a_1[]= /* 1600x1200 */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0b_1[]= /* 640x480_2 */ +static const SiS_LVDSDesStruct SiS310_PanelType0b_1[]= /* 640x480_2 */ { { 0, 524}, { 0, 524}, @@ -1277,7 +1277,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0b_1[]= /* 640x480_2 */ { 0, 524} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0c_1[]= /* 640x480_3 */ +static const SiS_LVDSDesStruct SiS310_PanelType0c_1[]= /* 640x480_3 */ { { 0, 524}, { 0, 524}, @@ -1289,7 +1289,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0c_1[]= /* 640x480_3 */ { 0, 524} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0d_1[]= +static const SiS_LVDSDesStruct SiS310_PanelType0d_1[]= { {1343, 798}, {1343, 794}, @@ -1302,7 +1302,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0d_1[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0e_1[]= +static const SiS_LVDSDesStruct SiS310_PanelType0e_1[]= { {1343, 798}, {1343, 794}, @@ -1315,7 +1315,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0e_1[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0f_1[]= +static const SiS_LVDSDesStruct SiS310_PanelType0f_1[]= { {1343, 798}, {1343, 794}, @@ -1328,7 +1328,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0f_1[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType00_2[]= +static const SiS_LVDSDesStruct SiS310_PanelType00_2[]= { {980, 528}, {980, 503}, @@ -1341,7 +1341,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType00_2[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType01_2[]= +static const SiS_LVDSDesStruct SiS310_PanelType01_2[]= { {1152, 622}, {1152, 597}, @@ -1354,7 +1354,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType01_2[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType02_2[]= +static const SiS_LVDSDesStruct SiS310_PanelType02_2[]= { {1368, 754}, {1368, 729}, @@ -1369,7 +1369,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType02_2[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType03_2[]= +static const SiS_LVDSDesStruct SiS310_PanelType03_2[]= { { 0, 0}, { 0, 0}, @@ -1380,7 +1380,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType03_2[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType04_2[]= +static const SiS_LVDSDesStruct SiS310_PanelType04_2[]= { { 0, 0}, { 0, 0}, @@ -1393,7 +1393,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType04_2[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType05_2[]= +static const SiS_LVDSDesStruct SiS310_PanelType05_2[]= { {1152, 622}, {1152, 597}, @@ -1406,7 +1406,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType05_2[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType06_2[]= +static const SiS_LVDSDesStruct SiS310_PanelType06_2[]= { {1152, 622}, {1152, 597}, @@ -1419,7 +1419,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType06_2[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType07_2[]= +static const SiS_LVDSDesStruct SiS310_PanelType07_2[]= { {1152, 622}, {1152, 597}, @@ -1432,7 +1432,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType07_2[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType08_2[]= /* 1400x1050 */ +static const SiS_LVDSDesStruct SiS310_PanelType08_2[]= /* 1400x1050 */ { {1308, 741}, {1308, 716}, @@ -1445,20 +1445,9 @@ static const SiS310_LVDSDesStruct SiS310_PanelType08_2[]= /* 1400x1050 */ { 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 */ +static const SiS_LVDSDesStruct SiS310_PanelType09_2[]= /* 1280x768 */ { {1083, 622}, {1083, 597}, @@ -1471,8 +1460,19 @@ static const SiS310_LVDSDesStruct SiS310_PanelType09_2[]= /* 1280x768 */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0a_2[]= /* 1600x1200 */ +static const SiS_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}, @@ -1483,9 +1483,10 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0a_2[]= /* 1600x1200 */ {1888,1162}, {1948,1175}, { 0, 0} +#endif }; -static const SiS310_LVDSDesStruct SiS310_PanelType0b_2[]= /* 640x480_2 */ +static const SiS_LVDSDesStruct SiS310_PanelType0b_2[]= /* 640x480_2 */ { {1152, 622}, {1152, 597}, @@ -1498,7 +1499,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0b_2[]= /* 640x480_2 */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0c_2[]= /* 640x480_3 */ +static const SiS_LVDSDesStruct SiS310_PanelType0c_2[]= /* 640x480_3 */ { {1152, 622}, {1152, 597}, @@ -1511,7 +1512,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0c_2[]= /* 640x480_3 */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0d_2[]= +static const SiS_LVDSDesStruct SiS310_PanelType0d_2[]= { {1152, 622}, {1152, 597}, @@ -1524,7 +1525,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0d_2[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0e_2[]= +static const SiS_LVDSDesStruct SiS310_PanelType0e_2[]= { {1152, 622}, {1152, 597}, @@ -1537,7 +1538,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0e_2[]= { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0f_2[] = +static const SiS_LVDSDesStruct SiS310_PanelType0f_2[] = { {1152, 622}, {1152, 597}, @@ -1550,792 +1551,125 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0f_2[] = { 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: 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_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[] = -{ - {{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_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}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_2[] = +static const SiS_LVDSDesStruct SiS310_PanelTypeNS_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}} -}; - -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}} + { 8, 0}, + { 8, 0}, + { 8, 0}, + { 8, 0}, + { 8, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 806}, + { 0, 0} }; -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_2[] = +static const SiS_LVDSDesStruct SiS310_PanelTypeNS_2[] = { - {{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}} + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0} }; +/* CRT1 CRTC for SlaveModes and LCDA */ -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_3[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1[] = { -#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 + {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + 0x00 }}, + {{0x6b,0x4f,0x8f,0x55,0x85,0x78,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00 }}, + {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + 0x00 }}, + {{0x6b,0x4f,0x8f,0x55,0x85,0x78,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00 }}, + {{0x6b,0x4f,0x8f,0x55,0x85,0xfa,0x1f, + 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, + 0x00 }}, + {{0x7f,0x63,0x83,0x69,0x19,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01 }} }; -/* 1 2 4 5 6 1c 1d 1f 20 21 23 25 */ -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_3[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1_H[] = { - {{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}} -}; - -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}} + {{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_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_3[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_2[]= { - {{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}} -}; - -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[]= -{ - {{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[]= -{ - {{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[]= -{ - {{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[]= -{ - {{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[]= -{ - {{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[]= -{ - {{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[]= -{ - {{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[]= -{ - {{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[]= -{ - {{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[]= -{ - {{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[]= -{ - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, + 0xff,0x84,0x8f,0x73,0x00,0x00,0x06, 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x01, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, + 0xe6,0x8b,0x5d,0x73,0x00,0x00,0x06, 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, + 0xff,0x84,0x8f,0x73,0x00,0x00,0x06, 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x01, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, + 0xe6,0x8b,0x5d,0x73,0x00,0x00,0x06, 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x01, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0xba, + 0x27,0x8c,0xdf,0x73,0x00,0x00,0x06, 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, + {{0x7f,0x63,0x83,0x69,0x19,0x72,0xf0, + 0x58,0x8d,0x57,0x73,0x20,0x00,0x06, 0x01 }} }; -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_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}} -}; - -typedef struct _SiS310_LVDSCRT1DataStruct -{ - UCHAR CR[15]; -} SiS310_LVDSCRT1DataStruct; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_2_H[] = { - {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, + 0xff,0x84,0x8f,0x73,0x00,0x00,0x01, 0x00 }}, - {{0x6b,0x4f,0x8f,0x55,0x85,0x78,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, + 0xd6,0x8b,0x5d,0x73,0x00,0x00,0x01, 0x00 }}, - {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, + 0xff,0x84,0x8f,0x73,0x00,0x00,0x01, 0x00 }}, - {{0x6b,0x4f,0x8f,0x55,0x85,0x78,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, + 0xd6,0x8b,0x5d,0x73,0x00,0x00,0x01, 0x00 }}, - {{0x6b,0x4f,0x8f,0x55,0x85,0xfa,0x1f, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, + {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0xba, + 0x27,0x8c,0xdf,0x73,0x00,0x00,0x01, 0x00 }}, - {{0x7f,0x63,0x83,0x69,0x19,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + {{0x4d,0x31,0x91,0x3a,0x0a,0x72,0xf0, + 0x63,0x88,0x57,0x73,0x00,0x00,0x01, 0x01 }} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1[] = { {{0x73,0x4f,0x97,0x53,0x84,0xb4,0x1f, 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, @@ -2360,82 +1694,110 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1[] = 0x01}} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1_H[] = { - {{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, + {{0x4b,0x27,0x8f,0x2b,0x1c,0xb4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, + 0x00 }}, + {{0x4b,0x27,0x8f,0x2b,0x1c,0x82,0x1f, + 0x60,0x87,0x5D,0x83,0x01,0x00,0x05, 0x00}}, - {{0x7e,0x4f,0x82,0x58,0x04,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, + {{0x4b,0x27,0x8f,0x2b,0x1c,0xb4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, 0x00}}, - {{0x7e,0x4f,0x82,0x58,0x04,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, + {{0x4b,0x27,0x8f,0x2b,0x1c,0x82,0x1f, + 0x60,0x87,0x5D,0x83,0x01,0x00,0x05, 0x00}}, - {{0x7e,0x4f,0x82,0x58,0x04,0x08,0x3e, - 0xe0,0x84,0xdf,0x09,0x00,0x00,0x06, + {{0x4b,0x27,0x8f,0x2b,0x1c,0x04,0x3e, + 0xE2,0x89,0xDf,0x05,0x00,0x00,0x05, 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, + {{0x55,0x31,0x99,0x35,0x06,0x7c,0xf0, + 0x5A,0x81,0x57,0x7D,0x00,0x00,0x01, 0x01}}, - {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a, - 0x00,0x84,0xff,0x29,0x09,0x00,0x07, - 0x01}} + {{0x63,0x3F,0x87,0x43,0x94,0x24,0xf5, + 0x02,0x89,0xFf,0x25,0x10,0x00,0x01, + 0x01 }} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1_H[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_2[] = { - {{0x43,0x27,0x87,0x2d,0x1d,0xaa,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x57,0x8e,0x8f,0x25,0x30,0x00,0x06, 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0x78,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x3e,0x85,0x5d,0x25,0x10,0x00,0x06, 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0xfa,0x1f, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x57,0x8e,0x8f,0x25,0x30,0x00,0x06, 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0x78,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x3e,0x85,0x5d,0x25,0x10,0x00,0x06, + 0x01 }}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x7f,0x86,0xdf,0x25,0x10,0x00,0x06, 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0xfa,0x1f, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, + {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, + 0xbb,0x82,0x57,0x25,0x10,0x00,0x02, + 0x01 }}, + {{0xa3,0x7f,0x87,0x83,0x94,0x24,0xf5, + 0x02,0x89,0xff,0x25,0x10,0x00,0x02, + 0x01 }} +}; + +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_2_H[] = +{ + {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x57,0x8e,0x8f,0x25,0x30,0x00,0x01, 0x00 }}, - {{0x4d,0x31,0x91,0x37,0x07,0x72,0xf0, - 0x58,0x8d,0x57,0x73,0x20,0x00,0x01, + {{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_LVDSCRT11024x768_1_H[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1[] = { - {{0x4b,0x27,0x8f,0x2b,0x1c,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, - 0x00 }}, - {{0x4b,0x27,0x8f,0x2b,0x1c,0x82,0x1f, - 0x60,0x87,0x5D,0x83,0x01,0x00,0x05, + {{0x7e,0x4f,0x82,0x58,0x04,0xb8,0x1f, + 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, 0x00}}, - {{0x4b,0x27,0x8f,0x2b,0x1c,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, + {{0x7e,0x4f,0x82,0x58,0x04,0x86,0x1f, + 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, 0x00}}, - {{0x4b,0x27,0x8f,0x2b,0x1c,0x82,0x1f, - 0x60,0x87,0x5D,0x83,0x01,0x00,0x05, + {{0x7e,0x4f,0x82,0x58,0x04,0xb8,0x1f, + 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, 0x00}}, - {{0x4b,0x27,0x8f,0x2b,0x1c,0x04,0x3e, - 0xE2,0x89,0xDf,0x05,0x00,0x00,0x05, + {{0x7e,0x4f,0x82,0x58,0x04,0x86,0x1f, + 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, 0x00}}, - {{0x55,0x31,0x99,0x35,0x06,0x7c,0xf0, - 0x5A,0x81,0x57,0x7D,0x00,0x00,0x01, + {{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}}, - {{0x63,0x3F,0x87,0x43,0x94,0x24,0xf5, - 0x02,0x89,0xFf,0x25,0x10,0x00,0x01, - 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[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1_H[] = { {{0x56,0x27,0x9a,0x31,0x1c,0xb8,0x1f, 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, @@ -2460,54 +1822,7 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1_H[] = 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,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 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x3e,0x85,0x5d,0x25,0x10,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x57,0x8e,0x8f,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x3e,0x85,0x5d,0x25,0x10,0x00,0x06, - 0x01 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x7f,0x86,0xdf,0x25,0x10,0x00,0x06, - 0x00 }}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xbb,0x82,0x57,0x25,0x10,0x00,0x02, - 0x01 }}, - {{0xa3,0x7f,0x87,0x83,0x94,0x24,0xf5, - 0x02,0x89,0xff,0x25,0x10,0x00,0x02, - 0x01 }} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2[] = { {{0xce,0x72,0x91,0x81,0x8f,0x28,0x92, 0xc8,0x8c,0x5d,0x5c,0x01,0x00,0x02, @@ -2535,54 +1850,7 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2[] = 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[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2_H[] = { {{0xa6,0x4a,0x89,0x59,0x07,0x28,0x92, 0xc8,0x8c,0x5d,0x5c,0x01,0x00,0x06, @@ -2607,7 +1875,7 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2_H[] = 0x01}} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1[] = { {{0x6f,0x4f,0x93,0x54,0x82,0x9e,0x1f, 0x8f,0x81,0x8f,0x9f,0x30,0x00,0x05, @@ -2667,7 +1935,7 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1[] = #endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1_H[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1_H[] = { {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, 0x8f,0x81,0x8f,0x9f,0x30,0x00,0x05, @@ -2727,7 +1995,7 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1_H[] = #endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2[] = { {{0xce,0x72,0x91,0x84,0x92,0x28,0x92, 0xd7,0x8b,0x5d,0x5c,0x21,0x00,0x02, @@ -2787,7 +2055,7 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2[] = #endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2_H[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2_H[] = { {{0xa6,0x4a,0x89,0x5c,0x0a,0x28,0x92, 0xd7,0x8b,0x5d,0x5c,0x21,0x00,0x06, @@ -2847,8 +2115,39 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2_H[] = #endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1[] = +static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1[] = { + {{0x83,0x4F,0x87,0x5B,0x13,0x06,0x3E, + 0xB3,0x86,0x8F,0x07,0x20,0x00,0x06, + 0x00}}, + {{0x83,0x4F,0x87,0x5B,0x13,0xD4,0x1F, + 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, + 0x00}}, + {{0x83,0x4F,0x87,0x5B,0x13,0x06,0x3E, + 0xB3,0x86,0x8F,0x07,0x20,0x00,0x06, + 0x00}}, + {{0x83,0x4F,0x87,0x5B,0x13,0xD4,0x1F, + 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, + 0x00}}, + {{0x83,0x4F,0x87,0x5B,0x13,0x56,0xBA, + 0x03,0x86,0xDF,0x57,0x00,0x00,0x06, + 0x00}}, + {{0x97,0x63,0x9B,0x6F,0x07,0xCE,0xF0, + 0x7B,0x8E,0x57,0xCF,0x20,0x00,0x02, + 0x01}}, + {{0xB3,0x7F,0x97,0x8B,0x83,0x76,0xF5, + 0x23,0x86,0xFF,0x77,0x10,0x00,0x06, + 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}}, + {{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}}, @@ -2879,10 +2178,42 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1[] = {{0xfb,0xc7,0x9f,0xc9,0x81,0xe0,0x10, 0xb0,0x84,0xaf,0xe1,0x2f,0x00,0x07, 0x00}} +#endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1_H[] = -{ +static const SiS_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}}, @@ -2913,10 +2244,42 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1_H[] = {{0x97,0x63,0x9b,0x65,0x1d,0xe0,0x10, 0xb0,0x84,0xaf,0xe1,0x2f,0x00,0x06, 0x00}} +#endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_2[] = -{ +static const SiS_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}}, @@ -2947,10 +2310,42 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_2[] = {{0xfb,0xc7,0x9f,0xc9,0x84,0xe0,0x10, 0xc7,0x8b,0xaf,0xe1,0x0f,0x00,0x07, 0x00}} +#endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_2_H[] = -{ +static const SiS_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}}, @@ -2981,253 +2376,296 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_2_H[] = {{0x97,0x63,0x9b,0x68,0x00,0xe0,0x10, 0xc7,0x8b,0xaf,0xe1,0x0f,0x00,0x02, 0x00}} +#endif +}; + +static const SiS_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 SiS_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_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, - 0x36,0x88,0xff,0xb0,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1ONTSC[] = +/* CRT1 CRTC for Chrontel TV slave modes */ + +static const SiS_LVDSCRT1DataStruct SiS310_CHTVCRT1UNTSC[] = { - {{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[] = + {{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 SiS_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 SiS_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, - 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 }} -}; - -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, - 0x28,0x88,0xff,0x6a,0x10,0x00,0x02, - 0x01 }} -}; - -typedef struct _SiS310_CHTVRegDataStruct -{ - UCHAR Reg[16]; -} 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}} -}; - -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}} -}; - -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}} -}; - -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}} -}; - -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}} + {{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 SiS_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 }} +}; + + +static const SiS_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}} +}; /* 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 SiS_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}} +}; + +static const SiS_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}} +}; + +static const SiS_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 SiS_CHTVRegDataStruct SiS310_CHTVReg_UPALM[] = +{ + {{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[] = +static const SiS_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[] = +static const SiS_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[] = +static const SiS_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 --git a/src/init.c b/src/init.c index 3e23e3b..6899796 100644 --- a/src/init.c +++ b/src/init.c @@ -1,35 +1,58 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.c,v 1.20 2003/09/05 09:38:32 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* - * Mode switching code (CRT1 section) for - * SiS 300/540/630/730/315/550/650/M650/651/M652/740/330/660/M660/760 + * Mode initializing code (CRT1 section) for + * for SiS 300/305/540/630/730 and + * SiS 315/550/650/M650/651/661FX/M661FX/740/741(GX)/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 - * Formerly based on non-functional code-fragements by SiS, Inc. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * If distributed as part of the linux kernel, the contents of this file - * is entirely covered by the GPL. + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * Otherwise, the following 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 * - * 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) 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 EXPRESSED 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. @@ -51,141 +74,75 @@ #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, BOOLEAN includelcdmodes, BOOLEAN isfordvi); -int SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber); -#ifdef SISDUALHEAD -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, BOOLEAN IsCustom); -#endif /* dual head */ -#endif /* linux_xf86 */ - -#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 - -#ifndef LINUX_XF86 -static ULONG GetDRAMSize(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -#endif - #if defined(ALLOC_PRAGMA) #pragma alloc_text(PAGE,SiSSetMode) -#pragma alloc_text(PAGE,SiSInit) #endif +/*********************************************/ +/* POINTER INITIALIZATION */ +/*********************************************/ + +#if defined(SIS300) || defined(SIS315H) static void -InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { SiS_Pr->SiS_StResInfo = SiS_StResInfo; SiS_Pr->SiS_ModeResInfo = SiS_ModeResInfo; SiS_Pr->SiS_StandTable = SiS_StandTable; - if(HwDeviceExtension->jChipType < SIS_315H) { - 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; - } else { - 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_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_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_HiTVTextTiming = SiS_HiTVTextTiming; + 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 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_St1HiTVData; */ + 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_LCD1280x720Data = SiS_LCD1280x720Data; + SiS_Pr->SiS_StLCD1280x768_2Data = SiS_StLCD1280x768_2Data; + SiS_Pr->SiS_ExtLCD1280x768_2Data = SiS_ExtLCD1280x768_2Data; + SiS_Pr->SiS_LCD1280x768_3Data = SiS_LCD1280x768_3Data; + SiS_Pr->SiS_LCD1280x800Data = SiS_LCD1280x800Data; 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_ExtLCD1400x1050Data = SiS_ExtLCD1400x1050Data; + SiS_Pr->SiS_LCD1680x1050Data = SiS_LCD1680x1050Data; 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_ExtLCD1600x1200Data = SiS_ExtLCD1600x1200Data; SiS_Pr->SiS_NoScaleData = SiS_NoScaleData; SiS_Pr->SiS_LVDS320x480Data_1 = SiS_LVDS320x480Data_1; @@ -214,36 +171,12 @@ InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) 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_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->SiS_CHTVUNTSCData = SiS_CHTVUNTSCData; - SiS_Pr->SiS_CHTVONTSCData = SiS_CHTVONTSCData; - - 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_LVDSBARCO1024Data_1 = SiS_LVDSBARCO1024Data_1; + SiS_Pr->SiS_LVDSBARCO1024Data_2 = SiS_LVDSBARCO1024Data_2; + SiS_Pr->SiS_LVDSBARCO1366Data_1 = SiS_LVDSBARCO1366Data_1; + SiS_Pr->SiS_LVDSBARCO1366Data_2 = SiS_LVDSBARCO1366Data_2; SiS_Pr->SiS_LVDSCRT11280x768_1 = SiS_LVDSCRT11280x768_1; SiS_Pr->SiS_LVDSCRT11024x600_1 = SiS_LVDSCRT11024x600_1; @@ -258,38 +191,72 @@ InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) 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; + + SiS_Pr->SiS_CHTVUNTSCData = SiS_CHTVUNTSCData; + SiS_Pr->SiS_CHTVONTSCData = SiS_CHTVONTSCData; + + 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_PanelMinLVDS = Panel_800x600; /* lowest value LVDS/LCDA */ + SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* lowest value 301 */ } +#endif #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, HwDeviceExtension); - - SiS_Pr->SiS_SModeIDTable = (SiS_StStruct *)SiS300_SModeIDTable; - SiS_Pr->SiS_VBModeIDTable = (SiS_VBModeStruct *)SiS300_VBModeIDTable; - 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) { - SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS300_MCLKData_300; /* 300 */ + 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 = SiS300_SModeIDTable; + SiS_Pr->SiS_VBModeIDTable = SiS300_VBModeIDTable; + SiS_Pr->SiS_EModeIDTable = SiS300_EModeIDTable; + SiS_Pr->SiS_RefIndex = SiS300_RefIndex; + SiS_Pr->SiS_CRT1Table = SiS300_CRT1Table; + if(HwInfo->jChipType == SIS_300) { + SiS_Pr->SiS_MCLKData_0 = SiS300_MCLKData_300; /* 300 */ } else { - SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS300_MCLKData_630; /* 630, 730 */ + SiS_Pr->SiS_MCLKData_0 = SiS300_MCLKData_630; /* 630, 730 */ } -#ifdef LINUXBIOS - SiS_Pr->SiS_ECLKData = (SiS_ECLKDataStruct *)SiS300_ECLKData; -#endif - SiS_Pr->SiS_VCLKData = (SiS_VCLKDataStruct *)SiS300_VCLKData; + SiS_Pr->SiS_VCLKData = SiS300_VCLKData; SiS_Pr->SiS_VBVCLKData = (SiS_VBVCLKDataStruct *)SiS300_VCLKData; - SiS_Pr->SiS_ScreenOffset = SiS300_ScreenOffset; SiS_Pr->SiS_SR15 = SiS300_SR15; @@ -318,94 +285,102 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->pSiS_YCSenseData2 = &SiS300_YCSenseData2; #endif - SiS_Pr->SiS_StLCD1024x768Data = (SiS_LCDDataStruct *)SiS300_StLCD1024x768Data; - SiS_Pr->SiS_ExtLCD1024x768Data = (SiS_LCDDataStruct *)SiS300_ExtLCD1024x768Data; - SiS_Pr->SiS_St2LCD1024x768Data = (SiS_LCDDataStruct *)SiS300_St2LCD1024x768Data; - SiS_Pr->SiS_StLCD1280x1024Data = (SiS_LCDDataStruct *)SiS300_StLCD1280x1024Data; - SiS_Pr->SiS_ExtLCD1280x1024Data = (SiS_LCDDataStruct *)SiS300_ExtLCD1280x1024Data; - 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_PanelDelayTbl = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTbl; - SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTblLVDS; - - SiS_Pr->SiS_CHTVUPALData = (SiS_LVDSDataStruct *)SiS300_CHTVUPALData; - SiS_Pr->SiS_CHTVOPALData = (SiS_LVDSDataStruct *)SiS300_CHTVOPALData; - 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; - SiS_Pr->SiS_PanelType03_1 = (SiS_LVDSDesStruct *)SiS300_PanelType03_1; - SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1; - SiS_Pr->SiS_PanelType05_1 = (SiS_LVDSDesStruct *)SiS300_PanelType05_1; - SiS_Pr->SiS_PanelType06_1 = (SiS_LVDSDesStruct *)SiS300_PanelType06_1; - SiS_Pr->SiS_PanelType07_1 = (SiS_LVDSDesStruct *)SiS300_PanelType07_1; - SiS_Pr->SiS_PanelType08_1 = (SiS_LVDSDesStruct *)SiS300_PanelType08_1; - SiS_Pr->SiS_PanelType09_1 = (SiS_LVDSDesStruct *)SiS300_PanelType09_1; - SiS_Pr->SiS_PanelType0a_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0a_1; - SiS_Pr->SiS_PanelType0b_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0b_1; - SiS_Pr->SiS_PanelType0c_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0c_1; - SiS_Pr->SiS_PanelType0d_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0d_1; - SiS_Pr->SiS_PanelType0e_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0e_1; - SiS_Pr->SiS_PanelType0f_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0f_1; - SiS_Pr->SiS_PanelType00_2 = (SiS_LVDSDesStruct *)SiS300_PanelType00_2; - SiS_Pr->SiS_PanelType01_2 = (SiS_LVDSDesStruct *)SiS300_PanelType01_2; - SiS_Pr->SiS_PanelType02_2 = (SiS_LVDSDesStruct *)SiS300_PanelType02_2; - SiS_Pr->SiS_PanelType03_2 = (SiS_LVDSDesStruct *)SiS300_PanelType03_2; - SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2; - SiS_Pr->SiS_PanelType05_2 = (SiS_LVDSDesStruct *)SiS300_PanelType05_2; - SiS_Pr->SiS_PanelType06_2 = (SiS_LVDSDesStruct *)SiS300_PanelType06_2; - SiS_Pr->SiS_PanelType07_2 = (SiS_LVDSDesStruct *)SiS300_PanelType07_2; - SiS_Pr->SiS_PanelType08_2 = (SiS_LVDSDesStruct *)SiS300_PanelType08_2; - SiS_Pr->SiS_PanelType09_2 = (SiS_LVDSDesStruct *)SiS300_PanelType09_2; - SiS_Pr->SiS_PanelType0a_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0a_2; - SiS_Pr->SiS_PanelType0b_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0b_2; - SiS_Pr->SiS_PanelType0c_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0c_2; - 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_PanelDelayTbl = SiS300_PanelDelayTbl; + SiS_Pr->SiS_PanelDelayTblLVDS = SiS300_PanelDelayTbl; + + SiS_Pr->SiS_ExtLCD1024x768Data = SiS300_ExtLCD1024x768Data; + SiS_Pr->SiS_St2LCD1024x768Data = SiS300_St2LCD1024x768Data; + SiS_Pr->SiS_ExtLCD1280x1024Data = SiS300_ExtLCD1280x1024Data; + SiS_Pr->SiS_St2LCD1280x1024Data = SiS300_St2LCD1280x1024Data; + + SiS_Pr->SiS_CRT2Part2_1024x768_1 = SiS300_CRT2Part2_1024x768_1; + SiS_Pr->SiS_CRT2Part2_1280x1024_1 = SiS300_CRT2Part2_1280x1024_1; + SiS_Pr->SiS_CRT2Part2_1024x768_2 = SiS300_CRT2Part2_1024x768_2; + SiS_Pr->SiS_CRT2Part2_1280x1024_2 = SiS300_CRT2Part2_1280x1024_2; + SiS_Pr->SiS_CRT2Part2_1024x768_3 = SiS300_CRT2Part2_1024x768_3; + SiS_Pr->SiS_CRT2Part2_1280x1024_3 = SiS300_CRT2Part2_1280x1024_3; + + SiS_Pr->SiS_CHTVUPALData = SiS300_CHTVUPALData; + SiS_Pr->SiS_CHTVOPALData = SiS300_CHTVOPALData; + 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 = SiS300_CHTVUPALData; /* not supported on 300 series */ + SiS_Pr->SiS_CHTVOPALNData = SiS300_CHTVOPALData; /* not supported on 300 series */ + SiS_Pr->SiS_CHTVSOPALData = SiS300_CHTVSOPALData; + + SiS_Pr->SiS_PanelType00_1 = SiS300_PanelType00_1; + SiS_Pr->SiS_PanelType01_1 = SiS300_PanelType01_1; + SiS_Pr->SiS_PanelType02_1 = SiS300_PanelType02_1; + SiS_Pr->SiS_PanelType03_1 = SiS300_PanelType03_1; + SiS_Pr->SiS_PanelType04_1 = SiS300_PanelType04_1; + SiS_Pr->SiS_PanelType05_1 = SiS300_PanelType05_1; + SiS_Pr->SiS_PanelType06_1 = SiS300_PanelType06_1; + SiS_Pr->SiS_PanelType07_1 = SiS300_PanelType07_1; + SiS_Pr->SiS_PanelType08_1 = SiS300_PanelType08_1; + SiS_Pr->SiS_PanelType09_1 = SiS300_PanelType09_1; + SiS_Pr->SiS_PanelType0a_1 = SiS300_PanelType0a_1; + SiS_Pr->SiS_PanelType0b_1 = SiS300_PanelType0b_1; + SiS_Pr->SiS_PanelType0c_1 = SiS300_PanelType0c_1; + SiS_Pr->SiS_PanelType0d_1 = SiS300_PanelType0d_1; + SiS_Pr->SiS_PanelType0e_1 = SiS300_PanelType0e_1; + SiS_Pr->SiS_PanelType0f_1 = SiS300_PanelType0f_1; + SiS_Pr->SiS_PanelType00_2 = SiS300_PanelType00_2; + SiS_Pr->SiS_PanelType01_2 = SiS300_PanelType01_2; + SiS_Pr->SiS_PanelType02_2 = SiS300_PanelType02_2; + SiS_Pr->SiS_PanelType03_2 = SiS300_PanelType03_2; + SiS_Pr->SiS_PanelType04_2 = SiS300_PanelType04_2; + SiS_Pr->SiS_PanelType05_2 = SiS300_PanelType05_2; + SiS_Pr->SiS_PanelType06_2 = SiS300_PanelType06_2; + SiS_Pr->SiS_PanelType07_2 = SiS300_PanelType07_2; + SiS_Pr->SiS_PanelType08_2 = SiS300_PanelType08_2; + SiS_Pr->SiS_PanelType09_2 = SiS300_PanelType09_2; + SiS_Pr->SiS_PanelType0a_2 = SiS300_PanelType0a_2; + SiS_Pr->SiS_PanelType0b_2 = SiS300_PanelType0b_2; + SiS_Pr->SiS_PanelType0c_2 = SiS300_PanelType0c_2; + SiS_Pr->SiS_PanelType0d_2 = SiS300_PanelType0d_2; + SiS_Pr->SiS_PanelType0e_2 = SiS300_PanelType0e_2; + SiS_Pr->SiS_PanelType0f_2 = SiS300_PanelType0f_2; + SiS_Pr->SiS_PanelTypeNS_1 = SiS300_PanelTypeNS_1; + SiS_Pr->SiS_PanelTypeNS_2 = SiS300_PanelTypeNS_2; 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; + SiS_Pr->SiS_PanelType04_1 = SiS300_PanelType04_1a; + SiS_Pr->SiS_PanelType04_2 = 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_PanelType04_1 = SiS300_PanelType04_1b; + SiS_Pr->SiS_PanelType04_2 = 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_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_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_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_CHTVCRT1UNTSC = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1UNTSC; - SiS_Pr->SiS_CHTVCRT1ONTSC = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1ONTSC; - SiS_Pr->SiS_CHTVCRT1UPAL = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1UPAL; - SiS_Pr->SiS_CHTVCRT1OPAL = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1OPAL; - SiS_Pr->SiS_CHTVCRT1SOPAL = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1SOPAL; - SiS_Pr->SiS_CHTVReg_UNTSC = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_UNTSC; - SiS_Pr->SiS_CHTVReg_ONTSC = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_ONTSC; - SiS_Pr->SiS_CHTVReg_UPAL = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_UPAL; - SiS_Pr->SiS_CHTVReg_OPAL = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_OPAL; - SiS_Pr->SiS_CHTVReg_UPALM = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_UNTSC; /* not supported on 300 series */ - SiS_Pr->SiS_CHTVReg_OPALM = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_ONTSC; /* not supported on 300 series */ - SiS_Pr->SiS_CHTVReg_UPALN = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_UPAL; /* not supported on 300 series */ - SiS_Pr->SiS_CHTVReg_OPALN = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_OPAL; /* not supported on 300 series */ - SiS_Pr->SiS_CHTVReg_SOPAL = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_SOPAL; + SiS_Pr->SiS_LVDSCRT1800x600_1 = SiS300_LVDSCRT1800x600_1; + SiS_Pr->SiS_LVDSCRT1800x600_1_H = SiS300_LVDSCRT1800x600_1_H; + SiS_Pr->SiS_LVDSCRT1800x600_2 = SiS300_LVDSCRT1800x600_2; + SiS_Pr->SiS_LVDSCRT1800x600_2_H = SiS300_LVDSCRT1800x600_2_H; + SiS_Pr->SiS_LVDSCRT11024x768_1 = SiS300_LVDSCRT11024x768_1; + SiS_Pr->SiS_LVDSCRT11024x768_1_H = SiS300_LVDSCRT11024x768_1_H; + SiS_Pr->SiS_LVDSCRT11024x768_2 = SiS300_LVDSCRT11024x768_2; + SiS_Pr->SiS_LVDSCRT11024x768_2_H = SiS300_LVDSCRT11024x768_2_H; + SiS_Pr->SiS_LVDSCRT11280x1024_1 = SiS300_LVDSCRT11280x1024_1; + SiS_Pr->SiS_LVDSCRT11280x1024_1_H = SiS300_LVDSCRT11280x1024_1_H; + SiS_Pr->SiS_LVDSCRT11280x1024_2 = SiS300_LVDSCRT11280x1024_2; + SiS_Pr->SiS_LVDSCRT11280x1024_2_H = SiS300_LVDSCRT11280x1024_2_H; + SiS_Pr->SiS_LVDSCRT1XXXxXXX_1 = SiS300_LVDSCRT1XXXxXXX_1; + SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H = SiS300_LVDSCRT1XXXxXXX_1_H; + + SiS_Pr->SiS_CHTVCRT1UNTSC = SiS300_CHTVCRT1UNTSC; + SiS_Pr->SiS_CHTVCRT1ONTSC = SiS300_CHTVCRT1ONTSC; + SiS_Pr->SiS_CHTVCRT1UPAL = SiS300_CHTVCRT1UPAL; + SiS_Pr->SiS_CHTVCRT1OPAL = SiS300_CHTVCRT1OPAL; + SiS_Pr->SiS_CHTVCRT1SOPAL = SiS300_CHTVCRT1SOPAL; + SiS_Pr->SiS_CHTVReg_UNTSC = SiS300_CHTVReg_UNTSC; + SiS_Pr->SiS_CHTVReg_ONTSC = SiS300_CHTVReg_ONTSC; + SiS_Pr->SiS_CHTVReg_UPAL = SiS300_CHTVReg_UPAL; + SiS_Pr->SiS_CHTVReg_OPAL = SiS300_CHTVReg_OPAL; + SiS_Pr->SiS_CHTVReg_UPALM = SiS300_CHTVReg_UNTSC; /* not supported on 300 series */ + SiS_Pr->SiS_CHTVReg_OPALM = SiS300_CHTVReg_ONTSC; /* not supported on 300 series */ + SiS_Pr->SiS_CHTVReg_UPALN = SiS300_CHTVReg_UPAL; /* not supported on 300 series */ + SiS_Pr->SiS_CHTVReg_OPALN = SiS300_CHTVReg_OPAL; /* not supported on 300 series */ + SiS_Pr->SiS_CHTVReg_SOPAL = SiS300_CHTVReg_SOPAL; SiS_Pr->SiS_CHTVVCLKUNTSC = SiS300_CHTVVCLKUNTSC; SiS_Pr->SiS_CHTVVCLKONTSC = SiS300_CHTVVCLKONTSC; SiS_Pr->SiS_CHTVVCLKUPAL = SiS300_CHTVVCLKUPAL; @@ -415,74 +390,69 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->SiS_CHTVVCLKUPALN = SiS300_CHTVVCLKUPAL; /* not supported on 300 series */ SiS_Pr->SiS_CHTVVCLKOPALN = SiS300_CHTVVCLKOPAL; /* not supported on 300 series */ SiS_Pr->SiS_CHTVVCLKSOPAL = SiS300_CHTVVCLKSOPAL; - - 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; - SiS_Pr->SiS_CRT2Part2_1600x1200_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1600x1200_1; - SiS_Pr->SiS_CRT2Part2_1024x768_2 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1024x768_2; - SiS_Pr->SiS_CRT2Part2_1280x1024_2 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1280x1024_2; - SiS_Pr->SiS_CRT2Part2_1400x1050_2 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_2; - SiS_Pr->SiS_CRT2Part2_1600x1200_2 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1600x1200_2; - SiS_Pr->SiS_CRT2Part2_1024x768_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1024x768_3; - SiS_Pr->SiS_CRT2Part2_1280x1024_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1280x1024_3; - 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 315 series definitions */ - SiS_Pr->SiS_Panel320x480 = Panel_320x480; - SiS_Pr->SiS_Panel640x480 = Panel_640x480; - SiS_Pr->SiS_Panel800x600 = Panel_800x600; - SiS_Pr->SiS_Panel1024x768 = Panel_1024x768; - SiS_Pr->SiS_Panel1280x1024 = Panel_1280x1024; - SiS_Pr->SiS_Panel1280x960 = Panel_1280x960; - SiS_Pr->SiS_Panel1024x600 = Panel_1024x600; - SiS_Pr->SiS_Panel1152x768 = Panel_1152x768; - SiS_Pr->SiS_Panel1280x768 = Panel_1280x768; - SiS_Pr->SiS_Panel1600x1200 = 255; /* TW: Something illegal */ - SiS_Pr->SiS_Panel1400x1050 = 255; /* TW: Something illegal */ - SiS_Pr->SiS_Panel640x480_2 = 255; /* TW: Something illegal */ - SiS_Pr->SiS_Panel640x480_3 = 255; /* TW: Something illegal */ - SiS_Pr->SiS_Panel1152x864 = 255; /* 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_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, HwDeviceExtension); - - SiS_Pr->SiS_SModeIDTable = (SiS_StStruct *)SiS310_SModeIDTable; - SiS_Pr->SiS_EModeIDTable = (SiS_ExtStruct *)SiS310_EModeIDTable; + 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 = SiS310_SModeIDTable; + SiS_Pr->SiS_EModeIDTable = SiS310_EModeIDTable; SiS_Pr->SiS_RefIndex = (SiS_Ext2Struct *)SiS310_RefIndex; - SiS_Pr->SiS_CRT1Table = (SiS_CRT1TableStruct *)SiS310_CRT1Table; - /* TW: MCLK is different */ -#ifdef LINUXBIOS - if(HwDeviceExtension->jChipType >= SIS_660) { - SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_660; /* 660/760 */ - } else if(HwDeviceExtension->jChipType == SIS_330) { -#endif - SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_330; /* 330 */ -#ifdef LINUXBIOS - } else if(HwDeviceExtension->jChipType > SIS_315PRO) { - SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_650; /* 550, 650, 740 */ + SiS_Pr->SiS_CRT1Table = SiS310_CRT1Table; + if(HwInfo->jChipType >= SIS_340) { + SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_340; /* 340 */ + } else if(HwInfo->jChipType >= SIS_761) { + SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_761; /* 761 - preliminary */ + } else if(HwInfo->jChipType >= SIS_760) { + SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_760; /* 760 */ + } else if(HwInfo->jChipType >= SIS_661) { + SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_660; /* 661/741 */ + } else if(HwInfo->jChipType == SIS_330) { + SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_330; /* 330 */ + } else if(HwInfo->jChipType > SIS_315PRO) { + SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_650; /* 550, 650, 740 */ } else { - SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_315; /* 315 */ + SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_315; /* 315 */ } -#endif - SiS_Pr->SiS_MCLKData_1 = (SiS_MCLKDataStruct *)SiS310_MCLKData_1; -#ifdef LINUXBIOS - SiS_Pr->SiS_ECLKData = (SiS_ECLKDataStruct *)SiS310_ECLKData; -#endif - SiS_Pr->SiS_VCLKData = (SiS_VCLKDataStruct *)SiS310_VCLKData; - SiS_Pr->SiS_VBVCLKData = (SiS_VBVCLKDataStruct *)SiS310_VBVCLKData; - SiS_Pr->SiS_ScreenOffset = SiS310_ScreenOffset; + if(HwInfo->jChipType >= SIS_340) { + SiS_Pr->SiS_MCLKData_1 = SiS310_MCLKData_1_340; + } else { + SiS_Pr->SiS_MCLKData_1 = SiS310_MCLKData_1; + } + SiS_Pr->SiS_VCLKData = SiS310_VCLKData; + SiS_Pr->SiS_VBVCLKData = SiS310_VBVCLKData; SiS_Pr->SiS_SR15 = SiS310_SR15; @@ -511,128 +481,96 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->pSiS_YCSenseData2 = &SiS310_YCSenseData2; #endif - SiS_Pr->SiS_StLCD1024x768Data = (SiS_LCDDataStruct *)SiS310_StLCD1024x768Data; - SiS_Pr->SiS_ExtLCD1024x768Data = (SiS_LCDDataStruct *)SiS310_ExtLCD1024x768Data; - SiS_Pr->SiS_St2LCD1024x768Data = (SiS_LCDDataStruct *)SiS310_St2LCD1024x768Data; - SiS_Pr->SiS_StLCD1280x1024Data = (SiS_LCDDataStruct *)SiS310_StLCD1280x1024Data; - SiS_Pr->SiS_ExtLCD1280x1024Data = (SiS_LCDDataStruct *)SiS310_ExtLCD1280x1024Data; - 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_PanelDelayTbl = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTbl; - SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTblLVDS; - - SiS_Pr->SiS_CHTVUPALData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALData; - SiS_Pr->SiS_CHTVOPALData = (SiS_LVDSDataStruct *)SiS310_CHTVOPALData; - SiS_Pr->SiS_CHTVUPALMData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALMData; - SiS_Pr->SiS_CHTVOPALMData = (SiS_LVDSDataStruct *)SiS310_CHTVOPALMData; - 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; - SiS_Pr->SiS_PanelType03_1 = (SiS_LVDSDesStruct *)SiS310_PanelType03_1; - SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS310_PanelType04_1; - SiS_Pr->SiS_PanelType05_1 = (SiS_LVDSDesStruct *)SiS310_PanelType05_1; - SiS_Pr->SiS_PanelType06_1 = (SiS_LVDSDesStruct *)SiS310_PanelType06_1; - SiS_Pr->SiS_PanelType07_1 = (SiS_LVDSDesStruct *)SiS310_PanelType07_1; - SiS_Pr->SiS_PanelType08_1 = (SiS_LVDSDesStruct *)SiS310_PanelType08_1; - SiS_Pr->SiS_PanelType09_1 = (SiS_LVDSDesStruct *)SiS310_PanelType09_1; - SiS_Pr->SiS_PanelType0a_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0a_1; - SiS_Pr->SiS_PanelType0b_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0b_1; - SiS_Pr->SiS_PanelType0c_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0c_1; - SiS_Pr->SiS_PanelType0d_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0d_1; - SiS_Pr->SiS_PanelType0e_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0e_1; - SiS_Pr->SiS_PanelType0f_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0f_1; - SiS_Pr->SiS_PanelType00_2 = (SiS_LVDSDesStruct *)SiS310_PanelType00_2; - SiS_Pr->SiS_PanelType01_2 = (SiS_LVDSDesStruct *)SiS310_PanelType01_2; - SiS_Pr->SiS_PanelType02_2 = (SiS_LVDSDesStruct *)SiS310_PanelType02_2; - SiS_Pr->SiS_PanelType03_2 = (SiS_LVDSDesStruct *)SiS310_PanelType03_2; - SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS310_PanelType04_2; - SiS_Pr->SiS_PanelType05_2 = (SiS_LVDSDesStruct *)SiS310_PanelType05_2; - SiS_Pr->SiS_PanelType06_2 = (SiS_LVDSDesStruct *)SiS310_PanelType06_2; - SiS_Pr->SiS_PanelType07_2 = (SiS_LVDSDesStruct *)SiS310_PanelType07_2; - SiS_Pr->SiS_PanelType08_2 = (SiS_LVDSDesStruct *)SiS310_PanelType08_2; - SiS_Pr->SiS_PanelType09_2 = (SiS_LVDSDesStruct *)SiS310_PanelType09_2; - SiS_Pr->SiS_PanelType0a_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0a_2; - SiS_Pr->SiS_PanelType0b_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0b_2; - SiS_Pr->SiS_PanelType0c_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0c_2; - 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_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; - SiS_Pr->SiS_CRT2Part2_1600x1200_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1600x1200_1; - SiS_Pr->SiS_CRT2Part2_1024x768_2 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1024x768_2; - SiS_Pr->SiS_CRT2Part2_1280x1024_2 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1280x1024_2; - SiS_Pr->SiS_CRT2Part2_1400x1050_2 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_2; - SiS_Pr->SiS_CRT2Part2_1600x1200_2 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1600x1200_2; - SiS_Pr->SiS_CRT2Part2_1024x768_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1024x768_3; - SiS_Pr->SiS_CRT2Part2_1280x1024_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1280x1024_3; - 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_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_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_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_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_LVDSCRT11600x1200_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_2_H; - 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_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; - SiS_Pr->SiS_CHTVReg_OPAL = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPAL; - SiS_Pr->SiS_CHTVReg_UPALM = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPALM; - 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_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_PanelDelayTbl = SiS310_PanelDelayTbl; + SiS_Pr->SiS_PanelDelayTblLVDS = SiS310_PanelDelayTblLVDS; + + SiS_Pr->SiS_St2LCD1024x768Data = SiS310_St2LCD1024x768Data; + SiS_Pr->SiS_ExtLCD1024x768Data = SiS310_ExtLCD1024x768Data; + SiS_Pr->SiS_St2LCD1280x1024Data = SiS310_St2LCD1280x1024Data; + SiS_Pr->SiS_ExtLCD1280x1024Data = SiS310_ExtLCD1280x1024Data; + + SiS_Pr->SiS_CRT2Part2_1024x768_1 = SiS310_CRT2Part2_1024x768_1; + + SiS_Pr->SiS_PanelType00_1 = SiS310_PanelType00_1; + SiS_Pr->SiS_PanelType01_1 = SiS310_PanelType01_1; + SiS_Pr->SiS_PanelType02_1 = SiS310_PanelType02_1; + SiS_Pr->SiS_PanelType03_1 = SiS310_PanelType03_1; + SiS_Pr->SiS_PanelType04_1 = SiS310_PanelType04_1; + SiS_Pr->SiS_PanelType05_1 = SiS310_PanelType05_1; + SiS_Pr->SiS_PanelType06_1 = SiS310_PanelType06_1; + SiS_Pr->SiS_PanelType07_1 = SiS310_PanelType07_1; + SiS_Pr->SiS_PanelType08_1 = SiS310_PanelType08_1; + SiS_Pr->SiS_PanelType09_1 = SiS310_PanelType09_1; + SiS_Pr->SiS_PanelType0a_1 = SiS310_PanelType0a_1; + SiS_Pr->SiS_PanelType0b_1 = SiS310_PanelType0b_1; + SiS_Pr->SiS_PanelType0c_1 = SiS310_PanelType0c_1; + SiS_Pr->SiS_PanelType0d_1 = SiS310_PanelType0d_1; + SiS_Pr->SiS_PanelType0e_1 = SiS310_PanelType0e_1; + SiS_Pr->SiS_PanelType0f_1 = SiS310_PanelType0f_1; + SiS_Pr->SiS_PanelType00_2 = SiS310_PanelType00_2; + SiS_Pr->SiS_PanelType01_2 = SiS310_PanelType01_2; + SiS_Pr->SiS_PanelType02_2 = SiS310_PanelType02_2; + SiS_Pr->SiS_PanelType03_2 = SiS310_PanelType03_2; + SiS_Pr->SiS_PanelType04_2 = SiS310_PanelType04_2; + SiS_Pr->SiS_PanelType05_2 = SiS310_PanelType05_2; + SiS_Pr->SiS_PanelType06_2 = SiS310_PanelType06_2; + SiS_Pr->SiS_PanelType07_2 = SiS310_PanelType07_2; + SiS_Pr->SiS_PanelType08_2 = SiS310_PanelType08_2; + SiS_Pr->SiS_PanelType09_2 = SiS310_PanelType09_2; + SiS_Pr->SiS_PanelType0a_2 = SiS310_PanelType0a_2; + SiS_Pr->SiS_PanelType0b_2 = SiS310_PanelType0b_2; + SiS_Pr->SiS_PanelType0c_2 = SiS310_PanelType0c_2; + SiS_Pr->SiS_PanelType0d_2 = SiS310_PanelType0d_2; + SiS_Pr->SiS_PanelType0e_2 = SiS310_PanelType0e_2; + SiS_Pr->SiS_PanelType0f_2 = SiS310_PanelType0f_2; + SiS_Pr->SiS_PanelTypeNS_1 = SiS310_PanelTypeNS_1; + SiS_Pr->SiS_PanelTypeNS_2 = SiS310_PanelTypeNS_2; + + SiS_Pr->SiS_CHTVUPALData = SiS310_CHTVUPALData; + SiS_Pr->SiS_CHTVOPALData = SiS310_CHTVOPALData; + SiS_Pr->SiS_CHTVUPALMData = SiS310_CHTVUPALMData; + SiS_Pr->SiS_CHTVOPALMData = SiS310_CHTVOPALMData; + SiS_Pr->SiS_CHTVUPALNData = SiS310_CHTVUPALNData; + SiS_Pr->SiS_CHTVOPALNData = SiS310_CHTVOPALNData; + SiS_Pr->SiS_CHTVSOPALData = SiS310_CHTVSOPALData; + + SiS_Pr->SiS_LVDSCRT1800x600_1 = SiS310_LVDSCRT1800x600_1; + SiS_Pr->SiS_LVDSCRT11024x768_1 = SiS310_LVDSCRT11024x768_1; + SiS_Pr->SiS_LVDSCRT11280x1024_1 = SiS310_LVDSCRT11280x1024_1; + SiS_Pr->SiS_LVDSCRT11400x1050_1 = SiS310_LVDSCRT11400x1050_1; + SiS_Pr->SiS_LVDSCRT11600x1200_1 = SiS310_LVDSCRT11600x1200_1; + SiS_Pr->SiS_LVDSCRT1800x600_1_H = SiS310_LVDSCRT1800x600_1_H; + SiS_Pr->SiS_LVDSCRT11024x768_1_H = SiS310_LVDSCRT11024x768_1_H; + SiS_Pr->SiS_LVDSCRT11280x1024_1_H = SiS310_LVDSCRT11280x1024_1_H; + SiS_Pr->SiS_LVDSCRT11400x1050_1_H = SiS310_LVDSCRT11400x1050_1_H; + SiS_Pr->SiS_LVDSCRT11600x1200_1_H = SiS310_LVDSCRT11600x1200_1_H; + SiS_Pr->SiS_LVDSCRT1800x600_2 = SiS310_LVDSCRT1800x600_2; + SiS_Pr->SiS_LVDSCRT11024x768_2 = SiS310_LVDSCRT11024x768_2; + SiS_Pr->SiS_LVDSCRT11280x1024_2 = SiS310_LVDSCRT11280x1024_2; + SiS_Pr->SiS_LVDSCRT11400x1050_2 = SiS310_LVDSCRT11400x1050_2; + SiS_Pr->SiS_LVDSCRT11600x1200_2 = SiS310_LVDSCRT11600x1200_2; + SiS_Pr->SiS_LVDSCRT1800x600_2_H = SiS310_LVDSCRT1800x600_2_H; + SiS_Pr->SiS_LVDSCRT11024x768_2_H = SiS310_LVDSCRT11024x768_2_H; + SiS_Pr->SiS_LVDSCRT11280x1024_2_H = SiS310_LVDSCRT11280x1024_2_H; + SiS_Pr->SiS_LVDSCRT11400x1050_2_H = SiS310_LVDSCRT11400x1050_2_H; + SiS_Pr->SiS_LVDSCRT11600x1200_2_H = SiS310_LVDSCRT11600x1200_2_H; + SiS_Pr->SiS_LVDSCRT1XXXxXXX_1 = SiS310_LVDSCRT1XXXxXXX_1; + SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H = SiS310_LVDSCRT1XXXxXXX_1_H; + SiS_Pr->SiS_CHTVCRT1UNTSC = SiS310_CHTVCRT1UNTSC; + SiS_Pr->SiS_CHTVCRT1ONTSC = SiS310_CHTVCRT1ONTSC; + SiS_Pr->SiS_CHTVCRT1UPAL = SiS310_CHTVCRT1UPAL; + SiS_Pr->SiS_CHTVCRT1OPAL = SiS310_CHTVCRT1OPAL; + SiS_Pr->SiS_CHTVCRT1SOPAL = SiS310_CHTVCRT1OPAL; + + SiS_Pr->SiS_CHTVReg_UNTSC = SiS310_CHTVReg_UNTSC; + SiS_Pr->SiS_CHTVReg_ONTSC = SiS310_CHTVReg_ONTSC; + SiS_Pr->SiS_CHTVReg_UPAL = SiS310_CHTVReg_UPAL; + SiS_Pr->SiS_CHTVReg_OPAL = SiS310_CHTVReg_OPAL; + SiS_Pr->SiS_CHTVReg_UPALM = SiS310_CHTVReg_UPALM; + SiS_Pr->SiS_CHTVReg_OPALM = SiS310_CHTVReg_OPALM; + SiS_Pr->SiS_CHTVReg_UPALN = SiS310_CHTVReg_UPALN; + SiS_Pr->SiS_CHTVReg_OPALN = SiS310_CHTVReg_OPALN; + SiS_Pr->SiS_CHTVReg_SOPAL = SiS310_CHTVReg_OPAL; SiS_Pr->SiS_CHTVVCLKUNTSC = SiS310_CHTVVCLKUNTSC; SiS_Pr->SiS_CHTVVCLKONTSC = SiS310_CHTVVCLKONTSC; @@ -641,201 +579,15 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->SiS_CHTVVCLKUPALM = SiS310_CHTVVCLKUPALM; 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_Panel320x480 = Panel_320x480; - SiS_Pr->SiS_Panel640x480 = Panel_640x480; - SiS_Pr->SiS_Panel800x600 = Panel_800x600; - SiS_Pr->SiS_Panel1024x768 = Panel_1024x768; - SiS_Pr->SiS_Panel1280x1024 = Panel_1280x1024; - SiS_Pr->SiS_Panel1280x960 = Panel_1280x960; - SiS_Pr->SiS_Panel1600x1200 = Panel_1600x1200; - SiS_Pr->SiS_Panel1400x1050 = Panel_1400x1050; - SiS_Pr->SiS_Panel1152x768 = Panel_1152x768; - SiS_Pr->SiS_Panel1152x864 = Panel_1152x864; - SiS_Pr->SiS_Panel1280x768 = Panel_1280x768; - SiS_Pr->SiS_Panel1024x600 = Panel_1024x600; - SiS_Pr->SiS_Panel640x480_2 = Panel_640x480_2; - SiS_Pr->SiS_Panel640x480_3 = Panel_640x480_3; - 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_PanelCustom = Panel_Custom; - SiS_Pr->SiS_PanelBarco1366 = 255; -} -#endif - -#ifdef SIS315H -UCHAR -SiS_Get310DRAMType(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - UCHAR data, temp; - - if(*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) { - data = *SiS_Pr->pSiS_SoftSetting & 0x03; - } else { - if(IS_SIS550650740660) { - 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(data > 1) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f) & 0x30; - switch(temp) { - case 0x00: data = 1; break; - case 0x10: data = 3; break; - case 0x20: data = 3; break; - case 0x30: data = 2; break; - } - } else { - data = 0; - } - } - } - } - - return data; -} -#endif - -/* ----------------------------------------- */ - -void SiSRegInit(SiS_Private *SiS_Pr, USHORT 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; -} - -void -SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - switch(HwDeviceExtension->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_SetReg1(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_660: - case SIS_760: - SiS_SetReg1(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_SetReg1(SiS_Pr->SiS_P3c4,0x20,0xa1); - /* No 3D engine ! */ - /* - Enable 2D (0x40) - */ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x40); - } + SiS_Pr->SiS_CHTVVCLKOPALN = SiS310_CHTVVCLKOPALN; + SiS_Pr->SiS_CHTVVCLKSOPAL = SiS310_CHTVVCLKOPAL; } - -void -SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo) -{ - ULONG temp; - - 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; - - SiS_Pr->SiS_ChrontelInit = 0; - -#if 0 - if(HwDeviceExtension->jChipType >= SIS_315H) { - if((ModeNo == 0x5a) || (ModeNo == 0x5b)) { - SiS_Pr->SiS_IF_DEF_DSTN = 1; /* for 550 dstn */ - SiS_Pr->SiS_IF_DEF_FSTN = 1; /* for fstn */ - } - } -#endif - - switch(HwDeviceExtension->jChipType) { -#ifdef SIS300 - case SIS_540: - case SIS_630: - case SIS_730: - /* 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)) { - /* 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: - case SIS_660: - case SIS_760: - 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; - break; #endif - default: - break; - } -} -void -SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - switch(HwDeviceExtension->jChipType) { + switch(HwInfo->jChipType) { #ifdef SIS315H case SIS_315H: case SIS_315: @@ -844,9 +596,13 @@ SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) case SIS_650: case SIS_740: case SIS_330: + case SIS_661: + case SIS_741: case SIS_660: case SIS_760: - InitTo310Pointer(SiS_Pr, HwDeviceExtension); + case SIS_761: + case SIS_340: + InitTo310Pointer(SiS_Pr, HwInfo); break; #endif #ifdef SIS300 @@ -854,7 +610,7 @@ SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) case SIS_540: case SIS_630: case SIS_730: - InitTo300Pointer(SiS_Pr, HwDeviceExtension); + InitTo300Pointer(SiS_Pr, HwInfo); break; #endif default: @@ -862,1757 +618,2400 @@ SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) } } -void -SiSDetermineROMUsage(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR *ROMAddr) +/*********************************************/ +/* HELPER: Get ModeID */ +/*********************************************/ + +USHORT +SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, + int Depth, BOOLEAN FSTN, int LCDwidth, int LCDheight) { - 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) { -#if 0 - /* 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 - /* Sony's VAIO BIOS 1.09 follows the standard, so perhaps - * the others do as well - */ - SiS_Pr->SiS_UseROM = TRUE; -#endif - } else { - /* TW: 315/330 series stick to the standard */ - SiS_Pr->SiS_UseROM = TRUE; - } - } else SiS_Pr->SiS_UseROM = FALSE; + USHORT ModeIndex = 0; + + 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(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 960: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 540) ModeIndex = ModeIndex_960x540[Depth]; + } + break; + case 1024: + if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + else if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; + else if((!(VBFlags & CRT1_LCDA)) && (VGAEngine == SIS_300_VGA)) { + if(VDisplay == 600) ModeIndex = ModeIndex_1024x600[Depth]; + } + break; + case 1152: + if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; + if((!(VBFlags & CRT1_LCDA)) && (VGAEngine == SIS_300_VGA)) { + if(VDisplay == 768) ModeIndex = ModeIndex_1152x768[Depth]; + } + break; + case 1280: + if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; + else if(VDisplay == 800) { + if(VGAEngine == SIS_315_VGA) { + if((VBFlags & CRT1_LCDA) && (LCDwidth == 1280) && (LCDheight == 800)) { + ModeIndex = ModeIndex_1280x800[Depth]; + } else if(!(VBFlags & CRT1_LCDA)) { + ModeIndex = ModeIndex_1280x800[Depth]; + } + } + } else if(VDisplay == 720) { + if((VBFlags & CRT1_LCDA) && (LCDwidth == 1280) && (LCDheight == 720)) { + ModeIndex = ModeIndex_1280x720[Depth]; + } else if(!(VBFlags & CRT1_LCDA)) { + ModeIndex = ModeIndex_1280x720[Depth]; + } + } else if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 960) ModeIndex = ModeIndex_1280x960[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(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; + if(!(VBFlags & CRT1_LCDA)) { + if(VGAEngine == SIS_300_VGA) { + if(VDisplay == 1024) ModeIndex = ModeIndex_300_1360x1024[Depth]; + } + } + break; + case 1400: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1050) { + if((VBFlags & CRT1_LCDA) && + (((LCDwidth == 1400) && (LCDheight == 1050)) || + ((LCDwidth == 1600) && (LCDheight == 1200)))) { + ModeIndex = ModeIndex_1400x1050[Depth]; + } else if(!(VBFlags & CRT1_LCDA)) { + ModeIndex = ModeIndex_1400x1050[Depth]; + } + } + } + break; + case 1600: + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + break; + case 1680: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1680x1050[Depth]; + } + break; + case 1920: + if(!(VBFlags & CRT1_LCDA)) { + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1080) ModeIndex = ModeIndex_1920x1080[Depth]; + } + 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; + } + return(ModeIndex); } -/* - ========================================= - ======== 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) +USHORT +SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, + int Depth, BOOLEAN FSTN, USHORT CustomT, int LCDwidth, int LCDheight) { - SISPtr pSiS = SISPTR(pScrn); - 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\n", - SiS_Pr->CHDisplay, - (mode->Flags & V_INTERLACE ? SiS_Pr->CVDisplay * 2 : - (mode->Flags & V_DBLSCAN ? SiS_Pr->CVDisplay / 2 : - SiS_Pr->CVDisplay))); + USHORT ModeIndex = 0; + + if(VBFlags & (VB_LVDS | VB_30xBDH)) { + + 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(!((VGAEngine == SIS_300_VGA) && (VBFlags & VB_TRUMPION))) { + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + } + } + break; + case 512: + if(CustomT != CUT_PANEL848) { + if(!((VGAEngine == SIS_300_VGA) && (VBFlags & VB_TRUMPION))) { + if(LCDwidth != 1024 || LCDheight != 600) { + if(VDisplay == 384) { + 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]; + } + if((VDisplay == 800) && (LCDheight == 800)) { + 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; + } - return(SiSSetMode(SiS_Pr, HwDeviceExtension, pScrn, ModeNo, TRUE)); + } 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 720: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth]; + else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth]; + } + break; + case 768: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; + } + break; + case 800: + if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth]; + } + break; + case 848: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; + } + break; + case 856: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; + } + break; + case 960: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 540) ModeIndex = ModeIndex_960x540[Depth]; + } + break; + case 1024: + if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; + } + break; + case 1152: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; + } + break; + case 1280: + if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; + else if(VDisplay == 768) { + if((LCDheight == 768) || (LCDwidth == 1680) || + (VBFlags & VB_SISTMDS)) { + if(VGAEngine == SIS_300_VGA) { + ModeIndex = ModeIndex_300_1280x768[Depth]; + } else { + ModeIndex = ModeIndex_310_1280x768[Depth]; + } + } + } else if(VDisplay == 960) { + if((LCDheight == 960) || (VBFlags & VB_SISTMDS)) { + ModeIndex = ModeIndex_1280x960[Depth]; + } + } else if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 800) { + if((LCDheight == 800) || (LCDwidth == 1680) || + (VBFlags & VB_SISTMDS)) { + ModeIndex = ModeIndex_1280x800[Depth]; + } + } else if(VDisplay == 720) { + if((LCDheight == 720) || (LCDwidth == 1680) || (LCDwidth == 1400) || + (VBFlags & VB_SISTMDS)) { + ModeIndex = ModeIndex_1280x720[Depth]; + } + } + } + break; + case 1360: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; + } + break; + case 1400: + if(VGAEngine == SIS_315_VGA) { + if(VBFlags & (VB_301B | VB_301C | VB_302B | VB_302LV | VB_302ELV)) { + if((LCDwidth == 1400) || (LCDwidth == 1600) || (LCDwidth == 1680)) { + ModeIndex = ModeIndex_1400x1050[Depth]; + } + } + } + break; + case 1600: + if(VGAEngine == SIS_315_VGA) { + if(VBFlags & (VB_301C | VB_302B | VB_302LV | VB_302ELV)) { + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + } + } + break; + case 1680: + if(VGAEngine == SIS_315_VGA) { + if(VBFlags & (VB_301C | VB_302B | VB_302LV | VB_302ELV)) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1680x1050[Depth]; + } + } + break; + } } - ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->HaveCustomModes); - if(!ModeNo) return FALSE; + return ModeIndex; +} - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting standard mode 0x%x\n", ModeNo); +USHORT +SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth) +{ + USHORT ModeIndex = 0; + + if(VBFlags & VB_CHRONTEL) { + + 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) { - return(SiSSetMode(SiS_Pr, HwDeviceExtension, pScrn, ModeNo, TRUE)); + 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_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) && (VBFlags & TV_YPBPR750P)) || + ((!(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) && (VBFlags & TV_YPBPR750P)) || + ((!(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(VDisplay == 720) { + if((VBFlags & TV_HIVISION) || + ((VBFlags & TV_YPBPR) && (VBFlags & (TV_YPBPR1080I | TV_YPBPR750P)))) { + ModeIndex = ModeIndex_1280x720[Depth]; + } + } else if(VDisplay == 1024) { + if((VBFlags & TV_HIVISION) || + ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) { + ModeIndex = ModeIndex_1280x1024[Depth]; + } + } + break; + } + } + return ModeIndex; } -#ifdef SISDUALHEAD -/* TW: Set CRT1 mode (used for dual head and MergedFB) */ -BOOLEAN -SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, ScrnInfoPtr pScrn, - DisplayModePtr mode, BOOLEAN IsCustom) +USHORT +SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth) { - 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 ModeNo=0; - - SiS_Pr->UseCustomMode = FALSE; + USHORT ModeIndex = 0; + + if(!(VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; + + 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 960: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 540) ModeIndex = ModeIndex_960x540[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 == 800) ModeIndex = ModeIndex_1280x800[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; + case 1680: + if(VGAEngine == SIS_315_VGA) { + if(VBFlags & (VB_301B|VB_301C|VB_302B)) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1680x1050[Depth]; + } + } + break; + } - if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { + return ModeIndex; +} - USHORT temptemp = SiS_Pr->CVDisplay; - if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; - else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; +/*********************************************/ +/* HELPER: SetReg, GetReg */ +/*********************************************/ - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting custom mode %dx%d on CRT1\n", - SiS_Pr->CHDisplay, temptemp); - ModeNo = 0xfe; +void +SiS_SetReg(SISIOADDRESS port, USHORT index, USHORT data) +{ + OutPortByte(port,index); + OutPortByte(port + 1,data); +} - } else { +void +SiS_SetRegByte(SISIOADDRESS port, USHORT data) +{ + OutPortByte(port,data); +} - ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->HaveCustomModes); - if(!ModeNo) return FALSE; +void +SiS_SetRegShort(SISIOADDRESS port, USHORT data) +{ + OutPortWord(port,data); +} - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting standard mode 0x%x on CRT1\n", ModeNo); - } +void +SiS_SetRegLong(SISIOADDRESS port, ULONG data) +{ + OutPortLong(port,data); +} - SiSInitPtr(SiS_Pr, HwDeviceExtension); +UCHAR +SiS_GetReg(SISIOADDRESS port, USHORT index) +{ + OutPortByte(port,index); + return(InPortByte(port + 1)); +} - SiSRegInit(SiS_Pr, BaseAddr); +UCHAR +SiS_GetRegByte(SISIOADDRESS port) +{ + return(InPortByte(port)); +} - SiS_GetSysFlags(SiS_Pr, HwDeviceExtension); +USHORT +SiS_GetRegShort(SISIOADDRESS port) +{ + return(InPortWord(port)); +} - SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); +ULONG +SiS_GetRegLong(SISIOADDRESS port) +{ + return(InPortLong(port)); +} - SiSInitPCIetc(SiS_Pr, HwDeviceExtension); +void +SiS_SetRegANDOR(SISIOADDRESS Port,USHORT Index,USHORT DataAND,USHORT DataOR) +{ + USHORT temp; - SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, ModeNo); + temp = SiS_GetReg(Port,Index); + temp = (temp & (DataAND)) | DataOR; + SiS_SetReg(Port,Index,temp); +} - SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr); +void +SiS_SetRegAND(SISIOADDRESS Port,USHORT Index,USHORT DataAND) +{ + USHORT temp; - /* We don't clear the buffer under X */ - SiS_Pr->SiS_flag_clearbuffer = 0; + temp = SiS_GetReg(Port,Index); + temp &= DataAND; + SiS_SetReg(Port,Index,temp); +} - /* 1.Openkey */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); +void +SiS_SetRegOR(SISIOADDRESS Port,USHORT Index,USHORT DataOR) +{ + USHORT temp; - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); + temp = SiS_GetReg(Port,Index); + temp |= DataOR; + SiS_SetReg(Port,Index,temp); +} - /* 2.Get ModeID Table */ - if(!SiS_Pr->UseCustomMode) { - temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&ModeNo,&ModeIdIndex); - if(temp == 0) return(0); - } else { - ModeIdIndex = 0; - } +/*********************************************/ +/* HELPER: DisplayOn, DisplayOff */ +/*********************************************/ - /* TW: Determine VBType (301,301B,301LV,302B,302LV) */ - SiS_GetVBType(SiS_Pr, BaseAddr,HwDeviceExtension); +void +SiS_DisplayOn(SiS_Private *SiS_Pr) +{ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x01,0xDF); +} - 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); - } - } +void +SiS_DisplayOff(SiS_Private *SiS_Pr) +{ + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x20); +} - /* 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_GetReg1(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; - } - } +/*********************************************/ +/* HELPER: Init Port Addresses */ +/*********************************************/ - if(IS_SIS650) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - 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); - } - } - } +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; +} - /* Set mode on CRT1 */ - SiS_SetCRT1Group(SiS_Pr, ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,BaseAddr); +/*********************************************/ +/* HELPER: GetSysFlags */ +/*********************************************/ - /* SetPitch: Adapt to virtual size & position */ - SiS_SetPitchCRT1(SiS_Pr, pScrn, BaseAddr); +static void +SiS_GetSysFlags(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + unsigned char cr5f, temp1, temp2; - if(pSiS->DualHeadMode) { - pSiSEnt->CRT1ModeNo = ModeNo; - pSiSEnt->CRT1DMode = mode; - } + /* 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_330) { + SiS_Pr->SiS_MyCR63 = 0x53; + if(HwInfo->jChipType >= SIS_661) { + SiS_Pr->SiS_SensibleSR11 = TRUE; + } + } - 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; - } + /* You should use the macros, not these flags directly */ - /* We have to reset CRT2 if changing mode on CRT1 */ - if(pSiS->DualHeadMode) { - if(pSiSEnt->CRT2ModeNo != -1) { - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "(Re-)Setting mode for CRT2\n"); - backupcustom = SiS_Pr->UseCustomMode; - SiSBIOSSetModeCRT2(SiS_Pr, HwDeviceExtension, pSiSEnt->pScrn_1, - pSiSEnt->CRT2DMode, pSiSEnt->CRT2IsCustom); - SiS_Pr->UseCustomMode = backupcustom; + 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; + } } } + if(HwInfo->jChipType == SIS_760) { + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x78); + if(temp1 & 0x30) SiS_Pr->SiS_SysFlags |= SF_760LFB; + } +} - /* Warning: From here, the custom mode entries in SiS_Pr are - * possibly overwritten - */ +/*********************************************/ +/* HELPER: Init PCI & Engines */ +/*********************************************/ - SiS_HandleCRT1(SiS_Pr); +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: + case SIS_761: + case SIS_340: + 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); + } +} - SiS_StrangeStuff(SiS_Pr, HwDeviceExtension); +/*********************************************/ +/* HELPER: SetLVDSetc */ +/*********************************************/ - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF); +void +SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT temp; - 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); - } - } + 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; - /* Backup/Set ModeNo in BIOS scratch area */ - SiS_GetSetModeID(pScrn,ModeNo); + SiS_Pr->SiS_ChrontelInit = 0; - return TRUE; + /* Check for SiS30x first */ + temp = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); + if((temp == 1) || (temp == 2)) return; + + switch(HwInfo->jChipType) { +#ifdef SIS300 + case SIS_540: + case SIS_630: + case SIS_730: + 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: + case SIS_761: + case SIS_340: + 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; + } } -/* TW: Set CRT2 mode (used for dual head) */ -BOOLEAN -SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, ScrnInfoPtr pScrn, - DisplayModePtr mode, BOOLEAN IsCustom) +/*********************************************/ +/* HELPER: Enable DSTN/FSTN */ +/*********************************************/ + +void +SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable) { - 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->SiS_IF_DEF_DSTN = enable ? 1 : 0; +} - SiS_Pr->UseCustomMode = FALSE; +void +SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable) +{ + SiS_Pr->SiS_IF_DEF_FSTN = enable ? 1 : 0; +} - /* Remember: Custom modes for CRT2 are ONLY supported - * -) on 315/330 series, - * -) on the 301 and 30xB, and - * -) if CRT2 is LCD or VGA - */ +/*********************************************/ +/* HELPER: Determine ROM usage */ +/*********************************************/ - if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { +BOOLEAN +SiSDetermineROMLayout661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT romversoffs, romvmaj = 1, romvmin = 0; + + if(HwInfo->jChipType >= SIS_761) { + /* I very much assume 761 and 340 will use new layout */ + return TRUE; + } else if(HwInfo->jChipType >= SIS_661) { + if((ROMAddr[0x1a] == 'N') && + (ROMAddr[0x1b] == 'e') && + (ROMAddr[0x1c] == 'w') && + (ROMAddr[0x1d] == 'V')) { + return TRUE; + } + romversoffs = ROMAddr[0x16] | (ROMAddr[0x17] << 8); + if(romversoffs) { + if((ROMAddr[romversoffs+1] == '.') || (ROMAddr[romversoffs+4] == '.')) { + romvmaj = ROMAddr[romversoffs] - '0'; + romvmin = ((ROMAddr[romversoffs+2] -'0') * 10) + (ROMAddr[romversoffs+3] - '0'); + } + } + if((romvmaj != 0) || (romvmin >= 92)) { + return TRUE; + } + } else if(IS_SIS650740) { + if((ROMAddr[0x1a] == 'N') && + (ROMAddr[0x1b] == 'e') && + (ROMAddr[0x1c] == 'w') && + (ROMAddr[0x1d] == 'V')) { + return TRUE; + } + } + return FALSE; +} - ModeNo = 0xfe; +static void +SiSDetermineROMUsage(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT romptr = 0; - } else { + SiS_Pr->SiS_UseROM = FALSE; + SiS_Pr->SiS_ROMNew = FALSE; - BOOLEAN havecustommodes = pSiS->HaveCustomModes; + if((ROMAddr) && (HwInfo->UseROM)) { + 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 if(HwInfo->jChipType < SIS_315H) { + /* Sony's VAIO BIOS 1.09 follows the standard, so perhaps + * the others do as well + */ + SiS_Pr->SiS_UseROM = TRUE; + } else { + /* 315/330 series stick to the standard(s) */ + SiS_Pr->SiS_UseROM = TRUE; + if((SiS_Pr->SiS_ROMNew = SiSDetermineROMLayout661(SiS_Pr, HwInfo))) { + /* Find out about LCD data table entry size */ + if((romptr = SISGETROMW(0x0102))) { + if(ROMAddr[romptr + (32 * 16)] == 0xff) + SiS_Pr->SiS661LCD2TableSize = 32; + else if(ROMAddr[romptr + (34 * 16)] == 0xff) + SiS_Pr->SiS661LCD2TableSize = 34; + else if(ROMAddr[romptr + (36 * 16)] == 0xff) + SiS_Pr->SiS661LCD2TableSize = 36; /* 0.94 final */ + } + } + } + } +} -#ifdef SISMERGED - if(pSiS->MergedFB) havecustommodes = pSiS->HaveCustomModes2; -#endif +/*********************************************/ +/* HELPER: SET SEGMENT REGISTERS */ +/*********************************************/ - ModeNo = SiS_CalcModeIndex(pScrn, mode, havecustommodes); - if(!ModeNo) return FALSE; +static void +SiS_SetSegRegLower(SiS_Private *SiS_Pr, USHORT value) +{ + USHORT temp; + + 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); +} - } +static void +SiS_SetSegRegUpper(SiS_Private *SiS_Pr, USHORT value) +{ + USHORT temp; + + 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); +} - /* Save mode info so we can set it from within SetMode for CRT1 */ - if(pSiS->DualHeadMode) { - pSiSEnt->CRT2ModeNo = ModeNo; - pSiSEnt->CRT2DMode = mode; - pSiSEnt->CRT2IsCustom = IsCustom; +static void +SiS_SetSegmentReg(SiS_Private *SiS_Pr, USHORT value) +{ + SiS_SetSegRegLower(SiS_Pr, value); + SiS_SetSegRegUpper(SiS_Pr, value); +} - /* 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; - } - } +static void +SiS_ResetSegmentReg(SiS_Private *SiS_Pr) +{ + SiS_SetSegmentReg(SiS_Pr, 0); +} - SiSInitPtr(SiS_Pr, HwDeviceExtension); +static void +SiS_SetSegmentRegOver(SiS_Private *SiS_Pr, USHORT value) +{ + USHORT temp = value >> 8; - SiSRegInit(SiS_Pr, BaseAddr); + temp &= 0x07; + temp |= (temp << 4); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x1d,temp); + SiS_SetSegmentReg(SiS_Pr, value); +} - SiS_GetSysFlags(SiS_Pr, HwDeviceExtension); +static void +SiS_ResetSegmentRegOver(SiS_Private *SiS_Pr) +{ + SiS_SetSegmentRegOver(SiS_Pr, 0); +} - SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); +static void +SiS_ResetSegmentRegisters(SiS_Private *SiS_Pr,PSIS_HW_INFO HwInfo) +{ + if((IS_SIS65x) || (HwInfo->jChipType >= SIS_661)) { + SiS_ResetSegmentReg(SiS_Pr); + SiS_ResetSegmentRegOver(SiS_Pr); + } +} - SiSInitPCIetc(SiS_Pr, HwDeviceExtension); +/*********************************************/ +/* HELPER: GetVBType */ +/*********************************************/ - SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, ModeNo); +void +SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag=0, rev=0, nolcd=0; - SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr); + SiS_Pr->SiS_VBType = 0; - /* We don't clear the buffer under X */ - SiS_Pr->SiS_flag_clearbuffer=0; + if((SiS_Pr->SiS_IF_DEF_LVDS) || (SiS_Pr->SiS_IF_DEF_CONEX)) + return; - if(SiS_Pr->UseCustomMode) { + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); - USHORT temptemp = SiS_Pr->CVDisplay; + if(flag > 3) return; - if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; - else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; + rev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting custom mode %dx%d on CRT2\n", - SiS_Pr->CHDisplay, temptemp); + if(flag >= 2) { + SiS_Pr->SiS_VBType = VB_SIS302B; + } else if(flag == 1) { + 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; + } else { + SiS_Pr->SiS_VBType = VB_SIS301; + } + } + if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS301C | VB_SIS302B)) { + 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_SIS301C; /* VB_SIS302ELV; */ + } else if(rev >= 0xD0) { + SiS_Pr->SiS_VBType = VB_SIS301LV; + } + } +} - } else { +/*********************************************/ +/* HELPER: Check RAM size */ +/*********************************************/ - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting standard mode 0x%x on CRT2\n", ModeNo); +#ifndef LINUX_XF86 +static BOOLEAN +SiS_CheckMemorySize(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex) +{ + USHORT AdapterMemSize = HwInfo->ulVideoMemorySize / (1024*1024); + USHORT memorysize,modeflag; - } + 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; + } + } - /* 1.Openkey */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); + memorysize = modeflag & MemoryInfoFlag; + memorysize >>= MemorySizeShift; /* Get required memory size */ + memorysize++; - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); + if(AdapterMemSize < memorysize) return FALSE; + return TRUE; +} +#endif - /* 2.Get ModeID */ - if(!SiS_Pr->UseCustomMode) { - temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&ModeNo,&ModeIdIndex); - if(temp == 0) return(0); +/*********************************************/ +/* HELPER: Get DRAM type */ +/*********************************************/ + +#ifdef SIS315H +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 { - ModeIdIndex = 0; + if(HwInfo->jChipType >= SIS_340) { + /* TODO */ + data = 0; + } if(HwInfo->jChipType >= SIS_661) { + data = SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0x07; + if(SiS_Pr->SiS_ROMNew) { + data = ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0xc0) >> 6); + } + } 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_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0x30; + switch(temp) { + case 0x00: data = 1; break; + case 0x10: data = 3; break; + case 0x20: data = 3; break; + case 0x30: data = 2; break; + } + } else { + data = 0; + } + } + } } - /* Determine VBType (301,301B,301LV,302B,302LV) */ - SiS_GetVBType(SiS_Pr, BaseAddr,HwDeviceExtension); + return data; +} - 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); +USHORT +SiS_GetMCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT index; - SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x02,0x0c); + index = SiS_Get310DRAMType(SiS_Pr, HwInfo); + if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->SiS_ROMNew) { + return((USHORT)(SISGETROMW((0x90 + (index * 5) + 3)))); + } + 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 - backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - } else { - backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35); - } - } +/*********************************************/ +/* HELPER: ClearBuffer */ +/*********************************************/ - /* Get VB information (connectors, connected devices) */ - if(!SiS_Pr->UseCustomMode) { - SiS_GetVBInfo(SiS_Pr, BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,1); - } else { - /* If this is a custom mode, we don't check the modeflag for CRT2Mode */ - SiS_GetVBInfo(SiS_Pr, BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,0); - } - SiS_SetHiVision(SiS_Pr, BaseAddr,HwDeviceExtension); - SiS_GetLCDResInfo(SiS_Pr, ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); +#ifndef LINUX_XF86 +static void +SiS_ClearBuffer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) +{ + UCHAR *VideoMemoryAddress = HwInfo->pjVideoMemoryAddress; + ULONG AdapterMemorySize = (ULONG)HwInfo->ulVideoMemorySize; + USHORT *pBuffer; + int i; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(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; - } - } - } + if(SiS_Pr->SiS_ModeType >= ModeEGA) { + if(ModeNo > 0x13) { + SiS_SetMemory(VideoMemoryAddress, AdapterMemorySize, 0); + } else { + pBuffer = (USHORT *)VideoMemoryAddress; + for(i=0; i<0x4000; i++) pBuffer[i] = 0x0000; + } + } else { + if(SiS_Pr->SiS_ModeType < ModeCGA) { + pBuffer = (USHORT *)VideoMemoryAddress; + for(i=0; i<0x4000; i++) pBuffer[i] = 0x0720; + } else { + SiS_SetMemory(VideoMemoryAddress, 0x8000, 0); + } + } +} +#endif - /* Set mode on CRT2 */ - switch (HwDeviceExtension->ujVBChipID) { - case VB_CHIP_301: - case VB_CHIP_301B: - case VB_CHIP_301C: - case VB_CHIP_301LV: - case VB_CHIP_302: - case VB_CHIP_302B: - case VB_CHIP_302LV: - SiS_SetCRT2Group(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_SetCRT2Group(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension); - } - break; - } +/*********************************************/ +/* HELPER: SearchModeID */ +/*********************************************/ - SiS_StrangeStuff(SiS_Pr, HwDeviceExtension); +BOOLEAN +SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex) +{ + UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF); + if(*ModeNo <= 0x13) { - 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); - } - } - } + if((*ModeNo) <= 0x05) (*ModeNo) |= 0x01; - 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); - } + 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; + } - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x38,backupreg); + 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 */ - 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); + } else { - 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); + 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; } - } - - /* SetPitch: Adapt to virtual size & position */ - SiS_SetPitchCRT2(SiS_Pr, pScrn, BaseAddr); + } return TRUE; } -#endif /* Dualhead */ -#endif /* Linux_XF86 */ -#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) -#endif +/*********************************************/ +/* HELPER: GetModePtr */ +/*********************************************/ + +UCHAR +SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex) { - ULONG temp; - USHORT ModeIdIndex,KeepLockReg; - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; - unsigned char backupreg=0, tempr1, tempr2; + UCHAR index; -#ifndef LINUX_XF86 - SiS_Pr->UseCustomMode = FALSE; - SiS_Pr->CRT1UsesCustomMode = FALSE; -#endif - - if(SiS_Pr->UseCustomMode) { - ModeNo = 0xfe; + if(ModeNo <= 0x13) { + index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_StTableIndex; + } else { + if(SiS_Pr->SiS_ModeType <= ModeEGA) index = 0x1B; + else index = 0x0F; } + return index; +} - SiSInitPtr(SiS_Pr, HwDeviceExtension); +/*********************************************/ +/* HELPER: LowModeTests */ +/*********************************************/ - SiSRegInit(SiS_Pr, BaseAddr); +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(TRUE); + 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(FALSE); + else return(TRUE); + } else { + if(temp2 != 0x55) return(TRUE); + else { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); + return(FALSE); + } + } +} - SiS_GetSysFlags(SiS_Pr, HwDeviceExtension); +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 LINUX_XF86 - if(pScrn) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); - else -#endif - SiS_Pr->SiS_VGAINFO = 0x11; +/*********************************************/ +/* HELPER: ENABLE CRT1 */ +/*********************************************/ -#ifdef LINUX_XF86 -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "VGAInfo 0x%02x\n", SiS_Pr->SiS_VGAINFO); -#endif +static void +SiS_SetupCR5x(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + if(IS_SIS650) { + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + 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,0x61,0xf7); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); + if(!SiS_Pr->SiS_ROMNew) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x3a,0xef); + } + } +} + +static void +SiS_HandleCRT1(SiS_Private *SiS_Pr) +{ + /* Enable CRT1 gating */ + 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 +} - SiSInitPCIetc(SiS_Pr, HwDeviceExtension); +/*********************************************/ +/* HELPER: GetColorDepth */ +/*********************************************/ - SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, ModeNo); +USHORT +SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex) +{ + USHORT ColorDepth[6] = { 1, 2, 4, 4, 6, 8}; + SHORT index; + USHORT modeflag; - SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr); + /* 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; + } - if(!SiS_Pr->UseCustomMode) { - /* TW: Shift the clear-buffer-bit away */ - ModeNo = ((ModeNo & 0x80) << 8) | (ModeNo & 0x7f); - } + index = (modeflag & ModeInfoFlag) - ModeEGA; + if(index < 0) index = 0; + return(ColorDepth[index]); +} -#ifdef LINUX_XF86 - /* We never clear the buffer in X */ - ModeNo |= 0x8000; -#endif +/*********************************************/ +/* HELPER: GetOffset */ +/*********************************************/ - if(ModeNo & 0x8000) { - ModeNo &= 0x7fff; - SiS_Pr->SiS_flag_clearbuffer = 0; - } else { - SiS_Pr->SiS_flag_clearbuffer = 1; - } +USHORT +SiS_GetOffset(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo) +{ + USHORT xres, temp, colordepth, infoflag; - /* 1.Openkey */ - KeepLockReg = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x05); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); + if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; + xres = SiS_Pr->CHDisplay; + } else { + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; + xres = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes; + } - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); + colordepth = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex); - if(!SiS_Pr->UseCustomMode) { + temp = xres / 16; + if(infoflag & InterlaceMode) temp <<= 1; + temp *= colordepth; + if(xres % 16) { + colordepth >>= 1; + temp += colordepth; + } - /* 2.Get ModeID Table */ - temp = SiS_SearchModeID(SiS_Pr,ROMAddr,&ModeNo,&ModeIdIndex); - if(temp == 0) return(0); + return(temp); +} - } else { +/*********************************************/ +/* SEQ */ +/*********************************************/ - ModeIdIndex = 0; +static void +SiS_SetSeqRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, PSIS_HW_INFO HwInfo) +{ + UCHAR SRdata; + USHORT i; - } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x03); /* Set SR0 */ - /* Determine VBType (301,301B,301LV,302B,302LV) */ - SiS_GetVBType(SiS_Pr,BaseAddr,HwDeviceExtension); + SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[0]; - /* 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); - } + 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 */ + } } - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10); - - SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x02,0x0c); - - backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - } else { - backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35); - } - } - - /* Get VB information (connectors, connected devices) */ - if(SiS_Pr->UseCustomMode) { - SiS_GetVBInfo(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,0); - } else { - SiS_GetVBInfo(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,1); + } 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 */ + } + } + } } - SiS_SetHiVision(SiS_Pr,BaseAddr,HwDeviceExtension); - SiS_GetLCDResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); - -#ifndef LINUX_XF86 - /* 3. Check memory size (Kernel framebuffer driver only) */ - temp = SiS_CheckMemorySize(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex); - if(!temp) return(0); -#endif - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(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; + 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(IS_SIS650) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - 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); - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SRdata |= 0x01; /* 8 dot clock */ + } } } - 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; - } + SRdata |= 0x20; /* screen off */ - /* 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); - } - } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x01,SRdata); - /* 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_301C: - case VB_CHIP_301LV: - case VB_CHIP_302: - case VB_CHIP_302B: - case VB_CHIP_302LV: - SiS_SetCRT2Group(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_SetCRT2Group(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension); - break; - } + for(i = 2; i <= 4; i++) { + SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i-1]; + SiS_SetReg(SiS_Pr->SiS_P3c4,i,SRdata); } - - SiS_HandleCRT1(SiS_Pr); +} - SiS_StrangeStuff(SiS_Pr, HwDeviceExtension); - - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF); +/*********************************************/ +/* MISC */ +/*********************************************/ - 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_SetMiscRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, PSIS_HW_INFO HwInfo) +{ + UCHAR Miscdata; + + Miscdata = SiS_Pr->SiS_StandTable[StandTableIndex].MISC; + + if(HwInfo->jChipType < SIS_661) { + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + Miscdata |= 0x0C; + } } } - 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_SetRegByte(SiS_Pr->SiS_P3c2,Miscdata); +} - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x38,backupreg); +/*********************************************/ +/* CRTC */ +/*********************************************/ - 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); +static void +SiS_SetCRTCRegs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT StandTableIndex) +{ + UCHAR CRTCdata; + USHORT i; - 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); - } - } + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /* Unlock CRTC */ - 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); - } - } + 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_661) { + SiS_SetupCR5x(SiS_Pr, HwInfo); + for(i = 0x13; i <= 0x14; i++) { + CRTCdata = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i]; + SiS_SetReg(SiS_Pr->SiS_P3d4,i,CRTCdata); + } + } else 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); + } + } + } +} -#ifdef LINUX_XF86 - if(pScrn) { - /* SetPitch: Adapt to virtual size & position */ - if((ModeNo > 0x13) && (dosetpitch)) { - SiS_SetPitch(SiS_Pr, pScrn, BaseAddr); - } +/*********************************************/ +/* ATT */ +/*********************************************/ - /* Backup/Set ModeNo in BIOS scratch area */ - SiS_GetSetModeID(pScrn, ModeNo); - } -#endif +static void +SiS_SetATTRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, + PSIS_HW_INFO HwInfo) +{ + UCHAR ARdata; + USHORT i; -#ifndef LINUX_XF86 /* 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); + 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 */ - return TRUE; + SiS_GetRegByte(SiS_Pr->SiS_P3da); + SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x20); /* Enable Attribute */ + SiS_GetRegByte(SiS_Pr->SiS_P3da); } -void -SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable) -{ - SiS_Pr->SiS_IF_DEF_DSTN = enable ? 1 : 0; -} +/*********************************************/ +/* GRC */ +/*********************************************/ -void -SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable) +static void +SiS_SetGRCRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex) { - SiS_Pr->SiS_IF_DEF_FSTN = enable ? 1 : 0; + UCHAR GRdata; + USHORT i; + + for(i = 0; i <= 0x08; i++) { + GRdata = SiS_Pr->SiS_StandTable[StandTableIndex].GRC[i]; + SiS_SetReg(SiS_Pr->SiS_P3ce,i,GRdata); + } + + if(SiS_Pr->SiS_ModeType > ModeVGA) { + /* 256 color disable */ + SiS_SetRegAND(SiS_Pr->SiS_P3ce,0x05,0xBF); + } } -void -SiS_HandleCRT1(SiS_Private *SiS_Pr) +/*********************************************/ +/* CLEAR EXTENDED REGISTERS */ +/*********************************************/ + +static void +SiS_ClearExt1Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) { - /* 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 i; - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x63,0xbf); + for(i = 0x0A; i <= 0x0E; i++) { + SiS_SetReg(SiS_Pr->SiS_P3c4,i,0x00); + } -#if 0 - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15) & 0x01)) { - if((SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15) & 0x0a) || - (SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16) & 0x01)) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x63,0x40); + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x37,0xFE); + if(ModeNo <= 0x13) { + if(ModeNo == 0x06 || ModeNo >= 0x0e) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0e,0x20); + } } } -#endif } -void -SiS_GetSysFlags(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +/*********************************************/ +/* RESET VCLK */ +/*********************************************/ + +static void +SiS_ResetCRT1VCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - unsigned char cr5f, temp1, temp2; + 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; + } + } - /* You should use the macros, not these flags directly */ + 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_Pr->SiS_SysFlags = 0; - if(HwDeviceExtension->jChipType == SIS_650) { - cr5f = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f) & 0xf0; - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x5c,0x07); - temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x5c,0xf8); - temp2 = SiS_GetReg1(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_GetReg1(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; - } - } - } -} - -void -SiS_StrangeStuff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - if((IS_SIS651) || (IS_SISM650)) { - SiS_SetReg1(SiS_Pr->SiS_VidCapt, 0x3f, 0x00); /* Fiddle with capture regs */ - SiS_SetReg1(SiS_Pr->SiS_VidCapt, 0x00, 0x00); - SiS_SetReg1(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 !!! */ -} +/*********************************************/ +/* SYNC */ +/*********************************************/ -void -SiS_SetCRT1Group(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT ModeIdIndex,USHORT BaseAddr) +static void +SiS_SetCRT1Sync(SiS_Private *SiS_Pr, USHORT RefreshRateTableIndex) { - USHORT StandTableIndex,RefreshRateTableIndex; + USHORT sync; - 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(SiS_Pr->UseCustomMode) { + sync = SiS_Pr->CInfoFlag >> 8; + } else { + sync = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; } - /* 550, 651 */ - SiS_WhatTheHellIsThis(SiS_Pr,HwDeviceExtension,BaseAddr); + sync &= 0xC0; + sync |= 0x2f; + SiS_SetRegByte(SiS_Pr->SiS_P3c2,sync); +} + +/*********************************************/ +/* CRTC/2 */ +/*********************************************/ - 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); +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; - SiS_Pr->SiS_SelectCRT2Rate = 0; - SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /* unlock cr0-7 */ -#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->UseCustomMode) { - if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + modeflag = SiS_Pr->CModeFlag; + + for(i=0,j=0;i<=7;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]); } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - } + temp = SiS_Pr->CCRT1CRTC[16] & 0xE0; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp); - RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); + temp = (SiS_Pr->CCRT1CRTC[16] & 0x01) << 5; + if(modeflag & DoubleScanMode) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,temp); - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - SiS_Pr->SiS_SetFlag &= ~ProgrammingCRT2; - } + } else { - 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); - } + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } -#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 + index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; - SiS_SetCRT1ModeRegs(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,RefreshRateTableIndex); + for(i=0,j=0;i<=7;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]); + } - SiS_LoadDAC(SiS_Pr,HwDeviceExtension,ROMAddr,ModeNo,ModeIdIndex); + temp = SiS_Pr->SiS_CRT1Table[index].CR[16] & 0xE0; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp); -#ifndef LINUX_XF86 - if(SiS_Pr->SiS_flag_clearbuffer) { - SiS_ClearBuffer(SiS_Pr,HwDeviceExtension,ModeNo); - } -#endif + temp = ((SiS_Pr->SiS_CRT1Table[index].CR[16]) & 0x01) << 5; + if(modeflag & DoubleScanMode) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,temp); - if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2 | SetCRT2ToLCDA))) { - SiS_LongWait(SiS_Pr); - SiS_DisplayOn(SiS_Pr); } + + if(SiS_Pr->SiS_ModeType > ModeVGA) SiS_SetReg(SiS_Pr->SiS_P3d4,0x14,0x4F); } -#ifdef LINUX_XF86 -void -SiS_SetPitch(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr) -{ - SISPtr pSiS = SISPTR(pScrn); - BOOLEAN isslavemode = FALSE; +/*********************************************/ +/* OFFSET & PITCH */ +/*********************************************/ +/* (partly overruled by SetPitch() in XF86) */ +/*********************************************/ - if( (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) ) ) { - isslavemode = TRUE; - } +static void +SiS_SetCRT1Offset(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT temp, DisplayUnit, infoflag; - /* 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, BaseAddr); - } - /* 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, BaseAddr); + if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; + } else { + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; } -} - -void -SiS_SetPitchCRT1(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr) -{ - SISPtr pSiS = SISPTR(pScrn); - ULong HDisplay,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); -} + DisplayUnit = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); -void -SiS_SetPitchCRT2(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr) -{ - SISPtr pSiS = SISPTR(pScrn); - ULong HDisplay,temp; + temp = (DisplayUnit >> 8) & 0x0f; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,temp); - HDisplay = pSiS->scrnPitch2 / 8; + temp = DisplayUnit & 0xFF; + SiS_SetReg(SiS_Pr->SiS_P3d4,0x13,temp); - /* 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); + if(infoflag & InterlaceMode) DisplayUnit >>= 1; - 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); + DisplayUnit <<= 5; + temp = (DisplayUnit & 0xff00) >> 8; + if(DisplayUnit & 0xff) temp++; + temp++; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x10,temp); } -#endif - -void -SiS_GetVBType(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT flag=0, rev=0, nolcd=0; - SiS_Pr->SiS_VBType = 0; +/*********************************************/ +/* VCLK */ +/*********************************************/ - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) return; +static void +SiS_SetCRT1VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) +{ + USHORT index=0, clka, clkb; - flag = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00); + 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(flag > 3) return; + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF); + } else { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x00); + } - rev = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x01); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2B,clka); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,clkb); - 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_GetReg1(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); - 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; - } - } + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x01); + } else { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80); } } -BOOLEAN -SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT *ModeNo,USHORT *ModeIdIndex) -{ - UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; - - if(*ModeNo <= 0x13) { - - if((*ModeNo) <= 0x05) (*ModeNo) |= 0x01; +/*********************************************/ +/* FIFO */ +/*********************************************/ - 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 +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 }; - 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 */ + 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 }; - } else { + const UCHAR ThTiming[] = { 1, 2, 2, 3, 0, 1, 1, 2 }; - 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; - } + USHORT tempah, tempal, tempcl, tempbx, temp; + ULONG longtemp; - } - return TRUE; + 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); } -BOOLEAN -SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo) +static USHORT +SiS_CalcDelay(SiS_Private *SiS_Pr, USHORT VCLK, USHORT colordepth, USHORT MCLK) { - 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; - } + USHORT tempax, tempbx; - 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); + 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); } -#ifndef LINUX_XF86 -BOOLEAN -SiS_CheckMemorySize(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT ModeIdIndex) +static void +SiS_SetCRT1FIFO_300(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo, + USHORT RefreshRateTableIndex) { - USHORT memorysize,modeflag; - ULONG temp; + USHORT ThresholdLow = 0; + USHORT index, VCLK, MCLK, colorth=0; + USHORT tempah, 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; - } - } + if(ModeNo > 0x13) { - 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(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(temp < memorysize) return(FALSE); - else return(TRUE); -} -#endif + 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; + } -UCHAR -SiS_GetModePtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) -{ - UCHAR index; + index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A); + index &= 0x07; + MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ - 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; -} + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + tempah &= 0xc3; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3c,tempah); -static void -SiS_WhatIsThis1a(SiS_Private *SiS_Pr, USHORT somevalue) -{ - USHORT temp, tempbl, tempbh; - - tempbl = tempbh = somevalue; - temp = SiS_GetReg2(SiS_Pr->SiS_P3cb); - temp &= 0xf0; - tempbl >>= 4; - temp |= tempbl; - SiS_SetReg3(SiS_Pr->SiS_P3cb, temp); - temp = SiS_GetReg2(SiS_Pr->SiS_P3cd); - temp &= 0xf0; - tempbh &= 0x0f; - temp |= tempbh; - SiS_SetReg3(SiS_Pr->SiS_P3cd, temp); -} + 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); -static void -SiS_WhatIsThis1b(SiS_Private *SiS_Pr, USHORT somevalue) -{ - USHORT temp, tempbl, tempbh; - - tempbl = tempbh = somevalue; - temp = SiS_GetReg2(SiS_Pr->SiS_P3cb); - temp &= 0x0f; - tempbl &= 0xf0; - temp |= tempbl; - SiS_SetReg3(SiS_Pr->SiS_P3cb, temp); - temp = SiS_GetReg2(SiS_Pr->SiS_P3cd); - temp &= 0x0f; - tempbh <<= 4; - temp |= tempbh; - SiS_SetReg3(SiS_Pr->SiS_P3cd, temp); -} + } else ThresholdLow = 2; -static void -SiS_WhatIsThis2b(SiS_Private *SiS_Pr, USHORT somevalue) -{ - SiS_WhatIsThis1a(SiS_Pr, somevalue); - SiS_WhatIsThis1b(SiS_Pr, somevalue); -} + /* Write CRT/CPU threshold low, CRT/Engine threshold high */ + temp = (ThresholdLow << 4) | 0x0f; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,temp); -static void -SiS_WhatIsThis1(SiS_Private *SiS_Pr) -{ - SiS_WhatIsThis2b(SiS_Pr, 0); -} + temp = (ThresholdLow & 0x10) << 1; + if(ModeNo > 0x13) temp |= 0x40; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0f,0x9f,temp); -static void -SiS_WhatIsThis2a(SiS_Private *SiS_Pr, USHORT somevalue) -{ - USHORT temp = somevalue >> 8; + /* What is this? */ + SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09); - temp &= 0x07; - temp |= (temp << 4); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1d,temp); - SiS_WhatIsThis2b(SiS_Pr, somevalue); + /* Write CRT/CPU threshold high */ + temp = ThresholdLow + 3; + if(temp > 0x0f) temp = 0x0f; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x09,temp); } -static void -SiS_WhatIsThis2(SiS_Private *SiS_Pr) +static USHORT +SiS_CalcDelay2(SiS_Private *SiS_Pr, UCHAR key, PSIS_HW_INFO HwInfo) { - SiS_WhatIsThis2a(SiS_Pr, 0); -} + 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, + }; -void -SiS_WhatTheHellIsThis(SiS_Private *SiS_Pr,PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr) -{ - if(IS_SIS65x) { - SiS_WhatIsThis1(SiS_Pr); - SiS_WhatIsThis2(SiS_Pr); - } + 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); } -void -SiS_SetSeqRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex) +static void +SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, USHORT ModeNo, + PSIS_HW_INFO HwInfo, + USHORT RefreshRateTableIndex) { - 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 */ + 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 + }; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x01,SRdata); + 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(i = 2; i <= 4; i++) { - SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i-1]; - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,SRdata); - } -} + index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A); + index &= 0x07; + MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ -void -SiS_SetMiscRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex) -{ - UCHAR Miscdata; + 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; + } - Miscdata = SiS_Pr->SiS_StandTable[StandTableIndex].MISC; + if(HwInfo->jChipType == SIS_730) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - Miscdata |= 0x0C; - } - } + do { + B = SiS_CalcDelay2(SiS_Pr, FQBQData730[i], HwInfo) * VCLK * colorth; + bl = B / (MCLK * 16); - SiS_SetReg3(SiS_Pr->SiS_P3c2,Miscdata); -} + if(B == bl * 16 * MCLK) { + bl = bl + 1; + } else { + bl = bl + 2; + } -void -SiS_SetCRTCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT StandTableIndex) -{ - UCHAR CRTCdata; - USHORT i; + 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, 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(bl > 0x13) { + if(FQBQData[i+1] == 0xFF) { + ThresholdLow = 0x13; + break; + } + i++; + } else { + ThresholdLow = bl; + break; + } + } while(FQBQData[i] != 0xFF); + } } - 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); - } + else { + if(HwInfo->jChipType == SIS_730) { + } else { + i = 9; } + ThresholdLow = 0x02; } -} -void -SiS_SetATTRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - UCHAR ARdata; - USHORT i; + /* Write foreground and background queue */ + if(HwInfo->jChipType == SIS_730) { + + data2 = FQBQData730[i]; + data2 = (data2 & 0xC0) >> 5; + data2 <<= 8; - 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; - } - } +#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 - 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_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_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); -} + /* Write GUI grant timer (PCI config 0xA3) */ + data2 = FQBQData730[i] << 8; + data2 = (data2 & 0x0f00) | ((data2 & 0x3000) >> 8); + data2 <<= 20; -void -SiS_SetGRCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex) -{ - UCHAR GRdata; - USHORT i; +#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; i <= 0x08; i++) { - GRdata = SiS_Pr->SiS_StandTable[StandTableIndex].GRC[i]; - SiS_SetReg1(SiS_Pr->SiS_P3ce,i,GRdata); /* Set GR(3ce) */ - } + } else { - if(SiS_Pr->SiS_ModeType > ModeVGA) { - SiS_SetRegAND(SiS_Pr->SiS_P3ce,0x05,0xBF); /* 256 color disable */ - } -} + data2 = FQBQData[i]; + data2 = (data2 & 0xf0) >> 4; + data2 <<= 24; -void -SiS_ClearExt1Regs(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT i; +#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 - for(i = 0x0A; i <= 0x0E; i++) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0x00); /* Clear SR0A-SR0E */ - } + /* Write GUI grant timer (PCI config 0xA3) */ + data2 = FQBQData[i]; + data2 &= 0x0f; + data2 <<= 24; + +#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 - /* TW: 330, 650/LVDS/301LV, 740/LVDS */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x37,0xFE); } -} -void -SiS_SetSync(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT RefreshRateTableIndex) -{ - USHORT sync; - USHORT temp; + /* 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->UseCustomMode) { - sync = SiS_Pr->CInfoFlag >> 8; - } else { - sync = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; - } + data = (ThresholdLow & 0x10) << 1; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xDF,data); - sync &= 0xC0; - temp = 0x2F | sync; - SiS_SetReg3(SiS_Pr->SiS_P3c2,temp); /* Set Misc(3c2) */ + /* What is this? */ + SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09); + + /* 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 -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 ResIndex,DisplayType; - const SiS_LCDACRT1DataStruct *LCDACRT1Ptr = NULL; -#endif +static void +SiS_SetCRT1FIFO_310(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT modeflag; - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /*unlock cr0-7 */ + /* disable auto-threshold */ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x3D,0xFE); 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,&ResIndex,&DisplayType); - - 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; - } + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } - tempah = (LCDACRT1Ptr+ResIndex)->CR[0]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x00,tempah); - for(i=0x01,j=1;i<=0x07;i++,j++){ - tempah = (LCDACRT1Ptr+ResIndex)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x10,j=8;i<=0x12;i++,j++){ - tempah = (LCDACRT1Ptr+ResIndex)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x15,j=11;i<=0x16;i++,j++){ - tempah =(LCDACRT1Ptr+ResIndex)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x0A,j=13;i<=0x0C;i++,j++){ - tempah = (LCDACRT1Ptr+ResIndex)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,tempah); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); + if(ModeNo > 0x13) { + if(HwInfo->jChipType >= SIS_661) { + if(!(modeflag & HalfDCLK)) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); + } + } else { + if((!(modeflag & DoubleScanMode)) || (!(modeflag & HalfDCLK))) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); + } } - - tempah = (LCDACRT1Ptr+ResIndex)->CR[16]; - tempah &= 0x0E0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x0E,tempah); - - tempah = (LCDACRT1Ptr+ResIndex)->CR[16]; - tempah &= 0x01; - tempah <<= 5; - if(modeflag & DoubleScanMode) tempah |= 0x080; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah); - + } +} #endif - } else { +/*********************************************/ +/* MODE REGISTERS */ +/*********************************************/ - /* LVDS, 301, 301B, 301LV, 302LV, ... (non-LCDA) */ +static void +SiS_SetVCLKState(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT RefreshRateTableIndex, + USHORT ModeIdIndex) +{ + USHORT data=0, VCLK=0, index=0; + if(ModeNo > 0x13) { 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); - - tempah = SiS_Pr->CCRT1CRTC[16]; - tempah &= 0x01; - tempah <<= 5; - if(modeflag & DoubleScanMode) tempah |= 0x80; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,tempah); - - + VCLK = SiS_Pr->CSRClock; } else { - - index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */ -#if 0 /* Not any longer... */ - if(HwDeviceExtension->jChipType < SIS_315H) { - index &= 0x3F; - } -#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); - - 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); - + index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; } } - if(SiS_Pr->SiS_ModeType > ModeVGA) SiS_SetReg1(SiS_Pr->SiS_P3d4,0x14,0x4F); -} - -BOOLEAN -SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *ResIndex, - USHORT *DisplayType) - { - USHORT tempbx=0,modeflag=0; - USHORT CRT2CRTC=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; - } - - tempbx = SiS_Pr->SiS_LCDResInfo; - - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 32; - if(modeflag & HalfDCLK) tempbx += 16; - - *ResIndex = CRT2CRTC & 0x3F; - *DisplayType = tempbx; - - return 1; -} - -/* 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) -{ - 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); - - temp = DisplayUnit & 0xFF; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x13,temp); - - if(infoflag & InterlaceMode) DisplayUnit >>= 1; - - DisplayUnit <<= 5; - temp = (DisplayUnit & 0xff00) >> 8; - if (DisplayUnit & 0xff) temp++; - temp++; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x10,temp); -} - -/* 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(HwInfo->jChipType < SIS_315H) { - 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); -} + if(VCLK > 150) data |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data); -void -SiS_SetCRT1VCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT RefreshRateTableIndex) -{ - USHORT index=0; + data = 0x00; + if(VCLK >= 150) data |= 0x08; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data); - if(!SiS_Pr->UseCustomMode) { - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - } + } else { - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ){ + if(VCLK >= 166) data |= 0x0c; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF); + if(VCLK >= 166) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1f,0xe7); + } + } - 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); + /* DAC speed */ + if(HwInfo->jChipType >= SIS_661) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x01); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80); - } + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xE8,0x10); } else { - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x00); - } + data = 0x03; + if((VCLK >= 135) && (VCLK < 160)) data = 0x02; + else if((VCLK >= 160) && (VCLK < 260)) data = 0x01; + else if(VCLK >= 260) data = 0x00; - 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); - } + if(HwInfo->jChipType == SIS_540) { + if((VCLK == 203) || (VCLK < 234)) data = 0x02; + } - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x01); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80); + if(HwInfo->jChipType < SIS_315H) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xFC,data); + } else { + if(HwInfo->jChipType > SIS_315PRO) { + if(ModeNo > 0x13) data &= 0xfc; } - } -} - -#if 0 /* TW: Not used */ -void -SiS_IsLowResolution(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) -{ - USHORT ModeFlag; - - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0x7F); + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xF8,data); + } - 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); - } } } -#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 infoflag=0,modeflag; + USHORT data,infoflag=0,modeflag; USHORT resindex,xres; #ifdef SIS315H + USHORT data2,data3; ULONG longdata; -#endif + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; +#endif if(SiS_Pr->UseCustomMode) { modeflag = SiS_Pr->CModeFlag; infoflag = SiS_Pr->CInfoFlag; + xres = SiS_Pr->CHDisplay; } else { + resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex); if(ModeNo > 0x13) { modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; + xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; } else { modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; } } - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1F,0x3F); /* DAC pedestal */ - - if(ModeNo > 0x13) data = infoflag; - else data = 0; + /* Disable DPMS */ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1F,0x3F); - data2 = 0; + data = 0; if(ModeNo > 0x13) { - if(SiS_Pr->SiS_ModeType > 0x02) { - data2 |= 0x02; - data3 = (SiS_Pr->SiS_ModeType - ModeVGA) << 2; - data2 |= data3; - } - } -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "Debug: Mode infoflag = %x, Chiptype %d\n", - data, HwDeviceExtension->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); - if(ModeNo <= 0x13) { - xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; - } else { - xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; + if(SiS_Pr->SiS_ModeType > ModeEGA) { + data |= 0x02; + data |= ((SiS_Pr->SiS_ModeType - ModeVGA) << 2); } + if(infoflag & InterlaceMode) data |= 0x20; } + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x06,0xC0,data); - if(HwDeviceExtension->jChipType != SIS_300) { - data = 0x0000; + if(HwInfo->jChipType != SIS_300) { + data = 0; if(infoflag & InterlaceMode) { - if(xres <= 800) data = 0x0020; + if(xres <= 800) data = 0x0020; else if(xres <= 1024) data = 0x0035; - else data = 0x0048; + 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 & 0xFF)); + 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(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 */ + data = 0; + if(modeflag & LineCompareOff) data = 0x08; + if(HwInfo->jChipType == SIS_300) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xF7,data); } else { - if(modeflag & LineCompareOff) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,0x08); - } else { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xB7); - } - /* 651 BIOS does something for mode 0x12 here */ - } - - if(HwDeviceExtension->jChipType != SIS_300) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,data); if(SiS_Pr->SiS_ModeType == ModeEGA) { if(ModeNo > 0x13) { SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x40); @@ -2620,969 +3019,1027 @@ SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDe } } -#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); + if(HwInfo->jChipType >= SIS_661) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xfb); } - /* 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; - } +#ifdef SIS315H + if(HwInfo->jChipType == SIS_315PRO) { - data3 = SiS_GetColorDepth(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex); - data3 >>= 1; - - data2 *= data3; - - data3 = SiS_GetMCLK(SiS_Pr,ROMAddr, HwDeviceExtension); - longdata = data3 * 1024; - - 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); + 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); + + } else if( (HwInfo->jChipType == SIS_330) || + ((HwInfo->jChipType == SIS_760) && (SiS_Pr->SiS_SysFlags & SF_760LFB))) { + + data = SiS_Get310DRAMType(SiS_Pr, HwInfo); + if(HwInfo->jChipType == SIS_330) { + data = SiS_Pr->SiS_SR15[2][data]; + } else { + if(SiS_Pr->SiS_ROMNew) data = ROMAddr[0xf6]; + else if(SiS_Pr->SiS_UseROM) data = ROMAddr[0x100 + data]; + else data = 0xba; + } + 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,ModeNo,ModeIdIndex) >> 1; + if(data3) data2 *= data3; + + longdata = SiS_GetMCLK(SiS_Pr, HwInfo) * 1024; + + data2 = longdata / data2; + + if(HwInfo->jChipType == SIS_330) { + 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; + } + } else { /* 760+LFB */ + if (data2 >= 0x190) data = 0xba; + else if(data2 >= 0xff) data = 0x7a; + else if(data2 >= 0xd3) data = 0x3a; + else if(data2 >= 0xa9) data = 0x1a; + else if(data2 >= 0x93) data = 0x0a; + else data = 0x02; + } + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x17,data); + } else if(HwInfo->jChipType == SIS_340) { + /* TODO */ } #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); - } + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x2c); + } else { + SiS_SetReg(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) +/*********************************************/ +/* LOAD DAC */ +/*********************************************/ + +#if 0 +static void +SiS_ClearDAC(SiS_Private *SiS_Pr, ULONG port) { - USHORT data, data2=0; - USHORT VCLK, index=0; + int i; - if (ModeNo <= 0x13) VCLK = 0; - else { - if(SiS_Pr->UseCustomMode) { - VCLK = SiS_Pr->CSRClock; + OutPortByte(port, 0); + port++; + for (i=0; i < (256 * 3); i++) { + OutPortByte(port, 0); + } +} +#endif + +static void +SiS_WriteDAC(SiS_Private *SiS_Pr, SISIOADDRESS DACData, USHORT shiftflag, + USHORT dl, USHORT ah, USHORT al, USHORT dh) +{ + 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 { - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; - } + temp = bl; + bl = bh; + bh = temp; + } + } + if(shiftflag) { + dh <<= 2; + bh <<= 2; + bl <<= 2; + } + SiS_SetRegByte(DACData,(USHORT)dh); + SiS_SetRegByte(DACData,(USHORT)bh); + SiS_SetRegByte(DACData,(USHORT)bl); +} + +void +SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex) +{ + 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; + + 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; + } + } + + 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; + } + } + + 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 */ + } +} + +/*********************************************/ +/* SET CRT1 REGISTER GROUP */ +/*********************************************/ + +static void +SiS_SetCRT1Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex) +{ + USHORT StandTableIndex,RefreshRateTableIndex; + + 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); + } } - if(HwDeviceExtension->jChipType < SIS_315H) { /* 300 series */ + 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, ModeNo); + 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 + + if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + } + } - data2 = 0x00; - if(VCLK > 150) data2 |= 0x80; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data2); /* DAC speed */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + } - data2 = 0x00; - if(VCLK >= 150) data2 |= 0x08; /* VCLK > 150 */ - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data2); + RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - } else { /* 315 series */ + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + SiS_Pr->SiS_SetFlag &= ~ProgrammingCRT2; + } - 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(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); + } - if(VCLK >= 166) { /* TW: Was 200, is 166 in 650, 315 and 330 BIOSes */ - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1f,0xe7); - } +#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 - data2 = 0x03; - if((VCLK >= 135) && (VCLK < 160)) data2 = 0x02; - if((VCLK >= 160) && (VCLK < 260)) data2 = 0x01; - if(VCLK >= 260) data2 = 0x00; + SiS_SetCRT1ModeRegs(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); - if(HwDeviceExtension->jChipType == SIS_540) { - if((VCLK == 203) || (VCLK < 234)) data2 = 0x02; + SiS_LoadDAC(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + +#ifndef LINUX_XF86 + if(SiS_Pr->SiS_flag_clearbuffer) { + SiS_ClearBuffer(SiS_Pr,HwInfo,ModeNo); } - - 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 */ +#endif + + if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA))) { + SiS_WaitRetrace1(SiS_Pr); + SiS_DisplayOn(SiS_Pr); } } -void -SiS_LoadDAC(SiS_Private *SiS_Pr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +/*********************************************/ +/* HELPER: RESET VIDEO BRIDGE */ +/*********************************************/ + +static void +SiS_ResetVB(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - 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 + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT temp; + + if(SiS_Pr->SiS_UseROM) { + if(HwInfo->jChipType < SIS_330) { + temp = ROMAddr[VB310Data_1_2_Offset] | 0x40; + if(SiS_Pr->SiS_ROMNew) temp = ROMAddr[0x80] | 0x40; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); + } else if(HwInfo->jChipType >= SIS_661) { + temp = ROMAddr[0x7e]; + if(SiS_Pr->SiS_ROMNew) temp = ROMAddr[0x80]; + if(HwInfo->jChipType >= SIS_660) temp |= 0x40; + else if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x7b) >= 100) temp |= 0x40; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); + } + } +} - 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; - } +/*********************************************/ +/* HELPER: SET VIDEO REGISTERS */ +/*********************************************/ + +static void +SiS_StrangeStuff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + 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 !!! */ +} -#if 0 - if(!(ds:489 & 0x08)) { +/*********************************************/ +/* XFree86: SET SCREEN PITCH */ +/*********************************************/ + +#ifdef LINUX_XF86 +static void +SiS_SetPitchCRT1(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) +{ + 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)); +} + +static void +SiS_SetPitchCRT2(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + UShort HDisplay = pSiS->scrnPitch2 >> 3; + + /* 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); + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(HDisplay & 0xFF)); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0xF0,(HDisplay >> 8)); +} + +static void +SiS_SetPitch(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + BOOLEAN isslavemode = FALSE; + + 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; + } + + /* 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 - 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; - } +/*********************************************/ +/* 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 +{ + USHORT ModeIdIndex; + SISIOADDRESS BaseAddr = HwInfo->ulIOAddress; + unsigned char backupreg=0; +#ifndef LINUX_XF86 + USHORT KeepLockReg; + ULONG temp; + + SiS_Pr->UseCustomMode = FALSE; + SiS_Pr->CRT1UsesCustomMode = FALSE; +#endif + + if(SiS_Pr->UseCustomMode) { + ModeNo = 0xfe; + } - SiS_SetReg3(DACAddr,0x00); - - for(i=0; i>= 2; - } - } + SiSInitPtr(SiS_Pr, HwInfo); + SiSRegInit(SiS_Pr, BaseAddr); + SiS_GetSysFlags(SiS_Pr, HwInfo); - 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); - } - 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 */ - } -#if 0 - } /* ds:489 & 0x08 */ +#if defined(LINUX_XF86) && (defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__)) + if(pScrn) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); + else #endif + SiS_Pr->SiS_VGAINFO = 0x11; -#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 -} + SiSInitPCIetc(SiS_Pr, HwInfo); + SiSSetLVDSetc(SiS_Pr, HwInfo); + SiSDetermineROMUsage(SiS_Pr, HwInfo); -void -SiS_WriteDAC(SiS_Private *SiS_Pr, USHORT DACData, USHORT shiftflag, - USHORT dl, USHORT ah, USHORT al, USHORT dh) -{ - USHORT temp; - USHORT bh,bl; + SiS_Pr->SiS_flag_clearbuffer = 0; - 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; - } - } - if(shiftflag) { - dh <<= 2; - bh <<= 2; - bl <<= 2; - } - SiS_SetReg3(DACData,(USHORT)dh); - SiS_SetReg3(DACData,(USHORT)bh); - SiS_SetReg3(DACData,(USHORT)bl); -} + if(!SiS_Pr->UseCustomMode) { +#ifndef LINUX_XF86 + if(!(ModeNo & 0x80)) SiS_Pr->SiS_flag_clearbuffer = 1; +#endif + ModeNo &= 0x7f; + } #ifndef LINUX_XF86 -static ULONG -GetDRAMSize(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - ULONG AdapterMemorySize = 0; -#ifdef SIS315H - USHORT counter; + KeepLockReg = SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); #endif + SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); - switch(HwDeviceExtension->jChipType) { -#ifdef SIS315H - case SIS_315H: - case SIS_315: - case SIS_315PRO: - 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); - break; + SiS_UnLockCRT2(SiS_Pr, HwInfo); - case SIS_330: - counter = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - AdapterMemorySize = 1 << ((counter & 0xF0) >> 4); - counter &= 0x0c; - if(counter != 0) { - AdapterMemorySize <<= 1; - } - AdapterMemorySize *= (1024*1024); - break; + if(!SiS_Pr->UseCustomMode) { + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; + } else { + ModeIdIndex = 0; + } - case SIS_550: - case SIS_650: - case SIS_740: - case SIS_660: - case SIS_760: - counter = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14) & 0x3F; - counter++; - AdapterMemorySize = counter * 4; - AdapterMemorySize *= (1024*1024); - break; -#endif + SiS_GetVBType(SiS_Pr, HwInfo); -#ifdef SIS300 - case SIS_300: - case SIS_540: - case SIS_630: - case SIS_730: - AdapterMemorySize = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14) & 0x3F; - AdapterMemorySize++; - AdapterMemorySize *= (1024*1024); - break; -#endif - default: - break; - } + /* Init/restore some VB registers */ - return AdapterMemorySize; -} -#endif + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + SiS_ResetVB(SiS_Pr, HwInfo); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10); + SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x00,0x0c); + backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + } else { + backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + } + } -#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; + /* 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); - 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 + /* 3. Check memory size (Kernel framebuffer driver only) */ + temp = SiS_CheckMemorySize(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + if(!temp) return(0); #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(HwInfo->jChipType >= SIS_315H) { + SiS_SetupCR5x(SiS_Pr, HwInfo); + } + 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; + } -/* ========================================== */ -/* SR CRTC GR */ -void -SiS_SetReg1(USHORT port, USHORT index, USHORT data) -{ - OutPortByte(port,index); - OutPortByte(port+1,data); -} + /* Set mode on CRT1 */ + if( (SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) || + (!(SiS_Pr->SiS_VBInfo & SwitchCRT2)) ) { + SiS_SetCRT1Group(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + } -/* ========================================== */ -/* 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); -} + /* 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); + } + } -void -SiS_SetReg3(USHORT port, USHORT data) -{ - OutPortByte(port,data); -} + SiS_HandleCRT1(SiS_Pr); -void -SiS_SetReg4(USHORT port, ULONG data) -{ - OutPortLong(port,data); -} + SiS_StrangeStuff(SiS_Pr, HwInfo); -void -SiS_SetReg5(USHORT port, USHORT data) -{ - OutPortWord(port,data); -} + SiS_DisplayOn(SiS_Pr); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); -UCHAR SiS_GetReg1(USHORT port, USHORT index) -{ - UCHAR 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); + } + } + } - OutPortByte(port,index); - data = InPortByte(port+1); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + if(!SiS_Pr->SiS_ROMNew) { + if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); + } else { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); + } + } - return(data); -} + SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg); -UCHAR -SiS_GetReg2(USHORT port) -{ - UCHAR data; + 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); + } + } - data= InPortByte(port); + 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); + } + } - return(data); -} +#ifdef LINUX_XF86 + if(pScrn) { + /* SetPitch: Adapt to virtual size & position */ + if((ModeNo > 0x13) && (dosetpitch)) { + SiS_SetPitch(SiS_Pr, pScrn); + } -ULONG -SiS_GetReg3(USHORT port) -{ - ULONG data; + /* Backup/Set ModeNo in BIOS scratch area */ + SiS_GetSetModeID(pScrn, ModeNo); + } +#endif - data = InPortLong(port); +#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 - return(data); + return TRUE; } -USHORT -SiS_GetReg4(USHORT port) +/*********************************************/ +/* XFree86: SiSBIOSSetMode() */ +/* for non-Dual-Head mode */ +/*********************************************/ + +#ifdef LINUX_XF86 +BOOLEAN +SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom) { - ULONG data; + SISPtr pSiS = SISPTR(pScrn); + UShort ModeNo=0; + + SiS_Pr->UseCustomMode = FALSE; - data = InPortWord(port); + if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { - return(data); -} + 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))); -void -SiS_ClearDAC(SiS_Private *SiS_Pr, ULONG port) -{ - int i; + return(SiSSetMode(SiS_Pr, HwInfo, pScrn, ModeNo, TRUE)); - OutPortByte(port, 0); - port++; - for (i=0; i < (256 * 3); i++) { - OutPortByte(port, 0); } + ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes); + if(!ModeNo) return FALSE; + + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting standard mode 0x%x\n", ModeNo); + + return(SiSSetMode(SiS_Pr, HwInfo, pScrn, ModeNo, TRUE)); } -#if 0 /* TW: Unused */ -void -SiS_SetInterlace(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT RefreshRateTableIndex) +/*********************************************/ +/* XFree86: SiSBIOSSetModeCRT2() */ +/* for Dual-Head modes */ +/*********************************************/ +BOOLEAN +SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom) { - ULONG Temp; - USHORT data,Temp2; + USHORT ModeIdIndex; + SISIOADDRESS BaseAddr = HwInfo->ulIOAddress; + UShort ModeNo = 0; + unsigned char backupreg=0; + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; +#endif - if (ModeNo<=0x13) return; + SiS_Pr->UseCustomMode = FALSE; - Temp = (ULONG)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x01); - Temp++; - Temp <<= 3; + /* Remember: Custom modes for CRT2 are ONLY supported + * -) on 315/330 series, + * -) on the 30x/B/C, and + * -) if CRT2 is LCD or VGA + */ - if(Temp == 1024) data = 0x0035; - else if(Temp == 1280) data = 0x0048; - else data = 0x0000; + if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { - Temp2 = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - Temp2 &= InterlaceMode; - if(Temp2 == 0) data=0x0000; + ModeNo = 0xfe; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x19,data); + } else { - Temp = (ULONG)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x1A); - Temp = (USHORT)(Temp & 0xFC); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x1A,(USHORT)Temp); + BOOLEAN havecustommodes = pSiS->HaveCustomModes; - 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); -} +#ifdef SISMERGED + if(pSiS->MergedFB) havecustommodes = pSiS->HaveCustomModes2; #endif -#ifdef SIS315H -void -SiS_SetCRT1FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT modeflag; + ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, havecustommodes); + if(!ModeNo) return FALSE; - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x3D,0xFE); /* disable auto-threshold */ + } - 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); - } -} + SiSRegInit(SiS_Pr, BaseAddr); + SiSInitPtr(SiS_Pr, HwInfo); + SiS_GetSysFlags(SiS_Pr, HwInfo); +#if (defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__)) + SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); +#else + SiS_Pr->SiS_VGAINFO = 0x11; #endif + SiSInitPCIetc(SiS_Pr, HwInfo); + SiSSetLVDSetc(SiS_Pr, HwInfo); + SiSDetermineROMUsage(SiS_Pr, HwInfo); -#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; + /* 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 + + /* We don't clear the buffer under X */ + SiS_Pr->SiS_flag_clearbuffer=0; + + if(SiS_Pr->UseCustomMode) { + + USHORT temptemp = SiS_Pr->CVDisplay; + + if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; + else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; - if(ModeNo > 0x13) { + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting custom mode %dx%d on CRT2\n", + SiS_Pr->CHDisplay, temptemp); - 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 */ - } + } else { - 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; - } + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting standard mode 0x%x on CRT2\n", ModeNo); - index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A); - index &= 0x07; - MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ + } - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35); - tempah &= 0xc3; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3c,tempah); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); - 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); + SiS_UnLockCRT2(SiS_Pr, HwInfo); - } else ThresholdLow = 2; + if(!SiS_Pr->UseCustomMode) { + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; + } else { + ModeIdIndex = 0; + } - /* Write CRT/CPU threshold low, CRT/Engine threshold high */ - temp = (ThresholdLow << 4) | 0x0f; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,temp); + SiS_GetVBType(SiS_Pr, HwInfo); - temp = (ThresholdLow & 0x10) << 1; - if(ModeNo > 0x13) temp |= 0x40; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0f,0x9f,temp); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + SiS_ResetVB(SiS_Pr, HwInfo); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10); + SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x00,0x0c); + backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + } else { + backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + } + } - /* What is this? */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x3B,0x09); + /* 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 CRT/CPU threshold high */ - temp = ThresholdLow + 3; - if(temp > 0x0f) temp = 0x0f; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x09,temp); -} + /* 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); + } -USHORT -SiS_CalcDelay(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT VCLK, USHORT colordepth, USHORT MCLK) -{ - USHORT tempax, tempbx; + SiS_StrangeStuff(SiS_Pr, HwInfo); - 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_DisplayOn(SiS_Pr); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); -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 }; + 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); + } + } + } - 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(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + if(!SiS_Pr->SiS_ROMNew) { + if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); + } else { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); + } + } - const UCHAR ThTiming[] = { 1, 2, 2, 3, 0, 1, 1, 2 }; + SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg); - USHORT tempah, tempal, tempcl, tempbx, temp; - ULONG longtemp; + 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); + } + } - 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); + /* SetPitch: Adapt to virtual size & position */ + SiS_SetPitchCRT2(SiS_Pr, pScrn); + + return TRUE; } -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 - }; +/*********************************************/ +/* XFree86: SiSBIOSSetModeCRT1() */ +/* for Dual-Head modes */ +/*********************************************/ - 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 */ - } +BOOLEAN +SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom) +{ + 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 - index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); - index &= 0x07; - MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ + SiS_Pr->UseCustomMode = FALSE; - 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((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { - if(HwDeviceExtension->jChipType == SIS_730) { - - do { - B = SiS_CalcDelay2(SiS_Pr, ROMAddr, FQBQData730[i], HwDeviceExtension) * VCLK * colorth; - bl = B / (MCLK * 16); + USHORT temptemp = SiS_Pr->CVDisplay; - if(B == bl * 16 * MCLK) { - bl = bl + 1; - } else { - bl = bl + 2; - } + if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; + else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; - 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 custom mode %dx%d on CRT1\n", + SiS_Pr->CHDisplay, temptemp); + ModeNo = 0xfe; - if(B == bl * 16 * MCLK) { - bl = bl + 1; - } else { - bl = bl + 2; - } + } else { - 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; - } + ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes); + if(!ModeNo) return FALSE; - /* Write foreground and background queue */ - if(HwDeviceExtension->jChipType == SIS_730) { - - data2 = FQBQData730[i]; - data2 = (data2 & 0xC0) >> 5; - data2 <<= 8; + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting standard mode 0x%x on CRT1\n", ModeNo); + } -#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); + SiSInitPtr(SiS_Pr, HwInfo); + SiSRegInit(SiS_Pr, BaseAddr); + SiS_GetSysFlags(SiS_Pr, HwInfo); +#if (defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__)) + SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); +#else + SiS_Pr->SiS_VGAINFO = 0x11; #endif + SiSInitPCIetc(SiS_Pr, HwInfo); + SiSSetLVDSetc(SiS_Pr, HwInfo); + SiSDetermineROMUsage(SiS_Pr, HwInfo); - /* 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 + /* We don't clear the buffer under X */ + SiS_Pr->SiS_flag_clearbuffer = 0; - } else { - - data2 = FQBQData[i]; - data2 = (data2 & 0xf0) >> 4; - data2 <<= 24; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); -#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); + SiS_UnLockCRT2(SiS_Pr, HwInfo); + + if(!SiS_Pr->UseCustomMode) { + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; + } else { + ModeIdIndex = 0; + } + + /* 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); + } + } + + /* 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) { + SiS_SetupCR5x(SiS_Pr, HwInfo); + } + + /* Set mode on CRT1 */ + SiS_SetCRT1Group(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_SetCRT2Group(SiS_Pr, HwInfo, ModeNo); + } + + /* SetPitch: Adapt to virtual size & position */ + SiS_SetPitchCRT1(SiS_Pr, pScrn); + +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + pSiSEnt->CRT1ModeNo = ModeNo; + pSiSEnt->CRT1DMode = mode; + } #endif - /* Write GUI grant timer (PCI config 0xA3) */ - data2 = FQBQData[i]; - data2 &= 0x0f; - data2 <<= 24; + 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; + } -#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); + /* 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 - - } - /* Write CRT/CPU threshold low, CRT/Engine threshold high */ - data = ((ThresholdLow & 0x0f) << 4) | 0x0f; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,data); + /* Warning: From here, the custom mode entries in SiS_Pr are + * possibly overwritten + */ - data = (ThresholdLow & 0x10) << 1; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xDF,data); + SiS_HandleCRT1(SiS_Pr); - /* What is this? */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x3B,0x09); + SiS_StrangeStuff(SiS_Pr, HwInfo); - /* 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_DisplayOn(SiS_Pr); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); -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_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); + } + } - 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); + /* Backup/Set ModeNo in BIOS scratch area */ + SiS_GetSetModeID(pScrn,ModeNo); + + return TRUE; } -#endif +#endif /* Linux_XF86 */ + #ifdef LINUX_XF86 BOOLEAN -SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { const USHORT PanelTypeTable300[16] = { 0xc101, 0xc117, 0x0121, 0xc135, 0xc142, 0xc152, 0xc162, 0xc072, @@ -3596,70 +4053,249 @@ SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) 0xc111, 0xc122, 0xc133, 0xc144, 0xc155, 0xc166, 0xc177, 0xc188, 0xc199, 0xc0aa, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }; - USHORT tempax,tempbx,tempah,temp; - - if(HwDeviceExtension->jChipType < SIS_315H) { - - 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); + USHORT tempax,tempbx,temp; + + if(HwInfo->jChipType < SIS_315H) { + + 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); } else { - tempax = tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1a); - tempax &= 0x1e; - tempax >>= 1; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(tempax == 0) { + 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_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); - } + } + 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); + } } return 1; } #endif +#ifndef GETBITSTR +#define BITMASK(h,l) (((unsigned)(1U << ((h)-(l)+1))-1)<<(l)) +#define GENMASK(mask) BITMASK(1?mask,0?mask) +#define GETBITS(var,mask) (((var) & GENMASK(mask)) >> (0?mask)) +#define GETBITSTR(val,from,to) ((GETBITS(val,from)) << (0?to)) +#endif + +static void +SiS_CalcCRRegisters(SiS_Private *SiS_Pr, int depth) +{ + SiS_Pr->CCRT1CRTC[0] = ((SiS_Pr->CHTotal >> 3) - 5) & 0xff; /* CR0 */ + SiS_Pr->CCRT1CRTC[1] = (SiS_Pr->CHDisplay >> 3) - 1; /* CR1 */ + SiS_Pr->CCRT1CRTC[2] = (SiS_Pr->CHBlankStart >> 3) - 1; /* CR2 */ + SiS_Pr->CCRT1CRTC[3] = (((SiS_Pr->CHBlankEnd >> 3) - 1) & 0x1F) | 0x80; /* CR3 */ + SiS_Pr->CCRT1CRTC[4] = (SiS_Pr->CHSyncStart >> 3) + 3; /* CR4 */ + SiS_Pr->CCRT1CRTC[5] = ((((SiS_Pr->CHBlankEnd >> 3) - 1) & 0x20) << 2) | /* CR5 */ + (((SiS_Pr->CHSyncEnd >> 3) + 3) & 0x1F); + + SiS_Pr->CCRT1CRTC[6] = (SiS_Pr->CVTotal - 2) & 0xFF; /* CR6 */ + SiS_Pr->CCRT1CRTC[7] = (((SiS_Pr->CVTotal - 2) & 0x100) >> 8) /* CR7 */ + | (((SiS_Pr->CVDisplay - 1) & 0x100) >> 7) + | ((SiS_Pr->CVSyncStart & 0x100) >> 6) + | (((SiS_Pr->CVBlankStart - 1) & 0x100) >> 5) + | 0x10 + | (((SiS_Pr->CVTotal - 2) & 0x200) >> 4) + | (((SiS_Pr->CVDisplay - 1) & 0x200) >> 3) + | ((SiS_Pr->CVSyncStart & 0x200) >> 2); + + SiS_Pr->CCRT1CRTC[16] = ((((SiS_Pr->CVBlankStart - 1) & 0x200) >> 4) >> 5); /* CR9 */ + + if(depth != 8) { + if(SiS_Pr->CHDisplay >= 1600) SiS_Pr->CCRT1CRTC[16] |= 0x60; /* SRE */ + else if(SiS_Pr->CHDisplay >= 640) SiS_Pr->CCRT1CRTC[16] |= 0x40; + } + +#if 0 + if (mode->VScan >= 32) + regp->CRTC[9] |= 0x1F; + else if (mode->VScan > 1) + regp->CRTC[9] |= mode->VScan - 1; +#endif + + SiS_Pr->CCRT1CRTC[8] = (SiS_Pr->CVSyncStart ) & 0xFF; /* CR10 */ + SiS_Pr->CCRT1CRTC[9] = ((SiS_Pr->CVSyncEnd ) & 0x0F) | 0x80; /* CR11 */ + SiS_Pr->CCRT1CRTC[10] = (SiS_Pr->CVDisplay - 1) & 0xFF; /* CR12 */ + SiS_Pr->CCRT1CRTC[11] = (SiS_Pr->CVBlankStart - 1) & 0xFF; /* CR15 */ + SiS_Pr->CCRT1CRTC[12] = (SiS_Pr->CVBlankEnd - 1) & 0xFF; /* CR16 */ + + SiS_Pr->CCRT1CRTC[13] = /* SRA */ + GETBITSTR((SiS_Pr->CVTotal -2), 10:10, 0:0) | + GETBITSTR((SiS_Pr->CVDisplay -1), 10:10, 1:1) | + GETBITSTR((SiS_Pr->CVBlankStart-1), 10:10, 2:2) | + GETBITSTR((SiS_Pr->CVSyncStart ), 10:10, 3:3) | + GETBITSTR((SiS_Pr->CVBlankEnd -1), 8:8, 4:4) | + GETBITSTR((SiS_Pr->CVSyncEnd ), 4:4, 5:5) ; + + SiS_Pr->CCRT1CRTC[14] = /* SRB */ + GETBITSTR((SiS_Pr->CHTotal >> 3) - 5, 9:8, 1:0) | + GETBITSTR((SiS_Pr->CHDisplay >> 3) - 1, 9:8, 3:2) | + GETBITSTR((SiS_Pr->CHBlankStart >> 3) - 1, 9:8, 5:4) | + GETBITSTR((SiS_Pr->CHSyncStart >> 3) + 3, 9:8, 7:6) ; + + + SiS_Pr->CCRT1CRTC[15] = /* SRC */ + GETBITSTR((SiS_Pr->CHBlankEnd >> 3) - 1, 7:6, 1:0) | + GETBITSTR((SiS_Pr->CHSyncEnd >> 3) + 3, 5:5, 2:2) ; +} + +void +SiS_CalcLCDACRT1Timing(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex) +{ + USHORT modeflag, tempax, tempbx, VGAHDE = SiS_Pr->SiS_VGAHDE; + int i,j; + + /* 1:1 data: use data set by setcrt1crtc() */ + if(SiS_Pr->SiS_LCDInfo & LCDPass11) return; + + 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; + } + + if(modeflag & HalfDCLK) VGAHDE >>= 1; + + SiS_Pr->CHDisplay = VGAHDE; + SiS_Pr->CHBlankStart = VGAHDE; + + SiS_Pr->CVDisplay = SiS_Pr->SiS_VGAVDE; + SiS_Pr->CVBlankStart = SiS_Pr->SiS_VGAVDE; + + tempbx = SiS_Pr->PanelHT - SiS_Pr->PanelXRes; + tempax = SiS_Pr->SiS_VGAHDE; /* not /2 ! */ + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempax = SiS_Pr->PanelXRes; + } + tempbx += tempax; + if(modeflag & HalfDCLK) tempbx -= VGAHDE; + SiS_Pr->CHTotal = SiS_Pr->CHBlankEnd = tempbx; + + tempax = VGAHDE; + tempbx = SiS_Pr->CHTotal; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempbx = SiS_Pr->PanelXRes; + if(modeflag & HalfDCLK) tempbx >>= 1; + tempax += ((tempbx - tempax) >> 1); + } + + tempax += SiS_Pr->PanelHRS; + SiS_Pr->CHSyncStart = tempax; + tempax += SiS_Pr->PanelHRE; + SiS_Pr->CHSyncEnd = tempax; + + tempbx = SiS_Pr->PanelVT - SiS_Pr->PanelYRes; + tempax = SiS_Pr->SiS_VGAVDE; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempax = SiS_Pr->PanelYRes; + } + SiS_Pr->CVTotal = SiS_Pr->CVBlankEnd = tempbx + tempax; + + tempax = SiS_Pr->SiS_VGAVDE; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempax += (SiS_Pr->PanelYRes - tempax) >> 1; + } + tempax += SiS_Pr->PanelVRS; + SiS_Pr->CVSyncStart = tempax; + tempax += SiS_Pr->PanelVRE; + SiS_Pr->CVSyncEnd = tempax; + + SiS_CalcCRRegisters(SiS_Pr, 8); + SiS_Pr->CCRT1CRTC[16] &= ~0xE0; + + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); + + for(i=0,j=0;i<=7;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]); + } + + tempax = SiS_Pr->CCRT1CRTC[16] & 0xE0; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1F,tempax); + + tempax = (SiS_Pr->CCRT1CRTC[16] & 0x01) << 5; + if(modeflag & DoubleScanMode) tempax |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,tempax); + +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "%d %d %d %d %d %d %d %d (%d %d %d %d)\n", + SiS_Pr->CHDisplay, SiS_Pr->CHSyncStart, SiS_Pr->CHSyncEnd, SiS_Pr->CHTotal, + SiS_Pr->CVDisplay, SiS_Pr->CVSyncStart, SiS_Pr->CVSyncEnd, SiS_Pr->CVTotal, + SiS_Pr->CHBlankStart, SiS_Pr->CHBlankEnd, SiS_Pr->CVBlankStart, SiS_Pr->CVBlankEnd); + + xf86DrvMsg(0, X_INFO, " {{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", + SiS_Pr->CCRT1CRTC[0], SiS_Pr->CCRT1CRTC[1], + SiS_Pr->CCRT1CRTC[2], SiS_Pr->CCRT1CRTC[3], + SiS_Pr->CCRT1CRTC[4], SiS_Pr->CCRT1CRTC[5], + SiS_Pr->CCRT1CRTC[6], SiS_Pr->CCRT1CRTC[7]); + xf86DrvMsg(0, X_INFO, " 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", + SiS_Pr->CCRT1CRTC[8], SiS_Pr->CCRT1CRTC[9], + SiS_Pr->CCRT1CRTC[10], SiS_Pr->CCRT1CRTC[11], + SiS_Pr->CCRT1CRTC[12], SiS_Pr->CCRT1CRTC[13], + SiS_Pr->CCRT1CRTC[14], SiS_Pr->CCRT1CRTC[15]); + xf86DrvMsg(0, X_INFO, " 0x%02x}},\n", SiS_Pr->CCRT1CRTC[16]); +#endif +} + /* ================ XFREE86 ================= */ /* Helper functions */ #ifdef LINUX_XF86 + USHORT SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags) { @@ -3691,17 +4327,17 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags) 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; + 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->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; @@ -3740,118 +4376,56 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags) pSiS->SiS_Pr->CSRClock = (pSiS->SiS_Pr->CDClock / 1000) + 1; - pSiS->SiS_Pr->CCRT1CRTC[0] = ((pSiS->SiS_Pr->CHTotal >> 3) - 5) & 0xff; - pSiS->SiS_Pr->CCRT1CRTC[1] = (pSiS->SiS_Pr->CHDisplay >> 3) - 1; - 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->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) - | ((pSiS->SiS_Pr->CVSyncStart & 0x100) >> 6) - | (((pSiS->SiS_Pr->CVBlankStart - 1) & 0x100) >> 5) - | 0x10 - | (((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 (mode->VScan >= 32) - regp->CRTC[9] |= 0x1F; - else if (mode->VScan > 1) - regp->CRTC[9] |= mode->VScan - 1; -#endif - - 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 ), 4:4, 5:5) ; - - 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) ; + SiS_CalcCRRegisters(pSiS->SiS_Pr, depth); + switch(depth) { + case 8: pSiS->SiS_Pr->CModeFlag |= 0x223b; break; + case 16: pSiS->SiS_Pr->CModeFlag |= 0x227d; break; + case 32: pSiS->SiS_Pr->CModeFlag |= 0x22ff; break; + default: return 0; + } - 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) ; + if(pSiS->SiS_Pr->CFlags & V_DBLSCAN) + pSiS->SiS_Pr->CModeFlag |= DoubleScanMode; - switch(depth) { - case 8: - pSiS->SiS_Pr->CModeFlag |= 0x223b; - break; - case 16: - pSiS->SiS_Pr->CModeFlag |= 0x227d; - break; - 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) || + 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; + 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 - xf86DrvMsg(0, X_INFO, "Custom mode %dx%d:\n", + xf86DrvMsg(0, X_INFO, "Custom mode %dx%d:\n", pSiS->SiS_Pr->CHDisplay,pSiS->SiS_Pr->CVDisplay); xf86DrvMsg(0, X_INFO, "Modeflag %04x, Infoflag %04x\n", pSiS->SiS_Pr->CModeFlag, pSiS->SiS_Pr->CInfoFlag); xf86DrvMsg(0, X_INFO, " {{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", - pSiS->SiS_Pr->CCRT1CRTC[0], - pSiS->SiS_Pr->CCRT1CRTC[1], - pSiS->SiS_Pr->CCRT1CRTC[2], - pSiS->SiS_Pr->CCRT1CRTC[3], - pSiS->SiS_Pr->CCRT1CRTC[4], - pSiS->SiS_Pr->CCRT1CRTC[5], - pSiS->SiS_Pr->CCRT1CRTC[6], - pSiS->SiS_Pr->CCRT1CRTC[7]); + pSiS->SiS_Pr->CCRT1CRTC[0], pSiS->SiS_Pr->CCRT1CRTC[1], + pSiS->SiS_Pr->CCRT1CRTC[2], pSiS->SiS_Pr->CCRT1CRTC[3], + pSiS->SiS_Pr->CCRT1CRTC[4], pSiS->SiS_Pr->CCRT1CRTC[5], + pSiS->SiS_Pr->CCRT1CRTC[6], pSiS->SiS_Pr->CCRT1CRTC[7]); xf86DrvMsg(0, X_INFO, " 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", - pSiS->SiS_Pr->CCRT1CRTC[8], - pSiS->SiS_Pr->CCRT1CRTC[9], - pSiS->SiS_Pr->CCRT1CRTC[10], - pSiS->SiS_Pr->CCRT1CRTC[11], - pSiS->SiS_Pr->CCRT1CRTC[12], - pSiS->SiS_Pr->CCRT1CRTC[13], - pSiS->SiS_Pr->CCRT1CRTC[14], - pSiS->SiS_Pr->CCRT1CRTC[15]); + pSiS->SiS_Pr->CCRT1CRTC[8], pSiS->SiS_Pr->CCRT1CRTC[9], + pSiS->SiS_Pr->CCRT1CRTC[10], pSiS->SiS_Pr->CCRT1CRTC[11], + pSiS->SiS_Pr->CCRT1CRTC[12], pSiS->SiS_Pr->CCRT1CRTC[13], + pSiS->SiS_Pr->CCRT1CRTC[14], pSiS->SiS_Pr->CCRT1CRTC[15]); xf86DrvMsg(0, X_INFO, " 0x%02x}},\n", pSiS->SiS_Pr->CCRT1CRTC[16]); xf86DrvMsg(0, X_INFO, "Clock: 0x%02x, 0x%02x, %d\n", - pSiS->SiS_Pr->CSR2B, - pSiS->SiS_Pr->CSR2C, - pSiS->SiS_Pr->CSRClock); + pSiS->SiS_Pr->CSR2B, pSiS->SiS_Pr->CSR2C, pSiS->SiS_Pr->CSRClock); #endif return 1; } @@ -3879,15 +4453,15 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfo /* 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; @@ -3895,9 +4469,6 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfo 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 /* 0x5a (320x240) is a pure FTSN mode, not DSTN! */ if((!pSiS->FSTN) && @@ -3971,7 +4542,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfo /* Horizontal display enable end */ HDE = (cr_data & 0xff) | ((unsigned short) (sr_data & 0x0C) << 6); - E = HDE + 1; + E = HDE + 1; /* 0x80 0x64 */ cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[4]; /* inSISIDXREG(SISCR, 0x04, cr_data); */ @@ -3979,7 +4550,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfo /* Horizontal retrace (=sync) start */ HRS = (cr_data & 0xff) | ((unsigned short) (sr_data & 0xC0) << 2); - F = HRS - E - 3; + F = HRS - E - 3; /* 0x06 0x06 */ cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[2]; /* inSISIDXREG(SISCR, 0x02, cr_data); */ @@ -4009,7 +4580,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfo B = (temp > 0) ? temp : (temp + 256); temp = HRE - ((E + F + 3) & 63); - C = (temp > 0) ? temp : (temp + 64); + C = (temp > 0) ? temp : (temp + 64); /* 0x0b 0x0b */ D = B - F - C; @@ -4196,6 +4767,8 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfo 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++; @@ -4205,8 +4778,10 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfo if(!includelcdmodes) return first; - xf86DrvMsg(0, X_INFO, "Checking database for vendor %x, product %x\n", - pSiS->SiS_Pr->CP_Vendor, pSiS->SiS_Pr->CP_Product); + 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)) { @@ -4423,74 +4998,68 @@ SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber) #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 * 1000 * 1000; + return 65 * 1000; #endif } else { #ifdef SIS315H - InitTo310Pointer(SiS_Pr, HwDeviceExtension); + InitTo310Pointer(SiS_Pr, HwInfo); #else - return 65 * 1000 * 1000; + 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 * 1000 * 1000; + 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_DEVICE_INFO HwDeviceExtension, +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; - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - ULONG temp = 0; unsigned char sr_data, cr_data, cr_data2; - - if(HwDeviceExtension->jChipType < SIS_315H) { + + if(HwInfo->jChipType < SIS_315H) { #ifdef SIS300 - InitTo300Pointer(SiS_Pr, HwDeviceExtension); + InitTo300Pointer(SiS_Pr, HwInfo); #else return FALSE; #endif } else { #ifdef SIS315H - InitTo310Pointer(SiS_Pr, HwDeviceExtension); + InitTo310Pointer(SiS_Pr, HwInfo); #else return FALSE; #endif } - temp = SiS_SearchModeID(SiS_Pr, ROMAddr, &ModeNo, &ModeIdIndex); - if(!temp) return FALSE; + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; RefreshRateTableIndex += (rateindex - 1); @@ -4515,39 +5084,34 @@ sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtensio } 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, - ULONG *hsync_len, ULONG *vsync_len, - ULONG *sync, ULONG *vmode) + struct fb_var_screeninfo *var) { 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; @@ -4610,15 +5174,15 @@ sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtens /* 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); + var->left_margin = (400 - 376); + var->right_margin = (328 - 320); + var->hsync_len = (376 - 328); } else { - *left_margin = D * 8; - *right_margin = F * 8; - *hsync_len = C * 8; + var->left_margin = D * 8; + var->right_margin = F * 8; + var->hsync_len = C * 8; } @@ -4680,47 +5244,47 @@ sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtens D = B - F - C; - *upper_margin = D; - *lower_margin = F; - *vsync_len = C; + var->upper_margin = D; + var->lower_margin = F; + var->vsync_len = C; if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x8000) - *sync &= ~FB_SYNC_VERT_HIGH_ACT; + var->sync &= ~FB_SYNC_VERT_HIGH_ACT; else - *sync |= FB_SYNC_VERT_HIGH_ACT; + var->sync |= FB_SYNC_VERT_HIGH_ACT; if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x4000) - *sync &= ~FB_SYNC_HOR_HIGH_ACT; + var->sync &= ~FB_SYNC_HOR_HIGH_ACT; else - *sync |= FB_SYNC_HOR_HIGH_ACT; + var->sync |= FB_SYNC_HOR_HIGH_ACT; - *vmode = FB_VMODE_NONINTERLACED; + var->vmode = FB_VMODE_NONINTERLACED; if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x0080) - *vmode = FB_VMODE_INTERLACED; + var->vmode = FB_VMODE_INTERLACED; else { - j = 0; - while(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID != 0xff) { + j = 0; + while(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID != 0xff) { if(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID == SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].ModeID) { if(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeFlag & DoubleScanMode) { - *vmode = FB_VMODE_DOUBLE; + var->vmode = FB_VMODE_DOUBLE; } break; } j++; - } + } } - if((*vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { + if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { #if 0 /* Do this? */ - *upper_margin <<= 1; - *lower_margin <<= 1; - *vsync_len <<= 1; + var->upper_margin <<= 1; + var->lower_margin <<= 1; + var->vsync_len <<= 1; #endif - } else if((*vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { - *upper_margin >>= 1; - *lower_margin >>= 1; - *vsync_len >>= 1; + } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { + var->upper_margin >>= 1; + var->lower_margin >>= 1; + var->vsync_len >>= 1; } return 1; diff --git a/src/init.h b/src/init.h index 63d5db3..03a489b 100644 --- a/src/init.h +++ b/src/init.h @@ -1,36 +1,53 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.h,v 1.23 2003/09/09 10:29:00 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Data and prototypes for init.c * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * If distributed as part of the linux kernel, the contents of this file - * is entirely covered by the GPL. + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * Otherwise, the following 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 * - * 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) 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 EXPRESSED 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 * - * Based on code by Silicon Intergrated Systems - * */ #ifndef _INIT_ @@ -67,6 +84,43 @@ #endif #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_960x540[] = {0x1d, 0x1e, 0x00, 0x1f}; /* 315 series only */ +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_1280x800[] = {0x14, 0x15, 0x00, 0x16}; +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_1680x1050[] = {0x17, 0x18, 0x00, 0x19}; /* 315 series only */ +const USHORT ModeIndex_1600x1200[] = {0x3c, 0x3d, 0x00, 0x66}; +const USHORT ModeIndex_1920x1080[] = {0x2c, 0x2d, 0x00, 0x73}; /* 315 series only */ +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}, {0x0D,0x0A,0x01,0x40,0x48}, @@ -201,9 +255,14 @@ static const SiS_ModeResInfoStruct SiS_ModeResInfo[] = { 1024, 600, 8,16}, /* 0x19 */ { 1152, 768, 8,16}, /* 0x1a */ { 768, 576, 8,16}, /* 0x1b */ - { 1360,1024, 8,16} /* 0x1c */ + { 1360,1024, 8,16}, /* 0x1c */ + { 1680,1050, 8,16}, /* 0x1d */ + { 1280, 800, 8,16}, /* 0x1e */ + { 1920,1080, 8,16}, /* 0x1f */ + { 960, 540, 8,16} /* 0x20 */ }; +#if defined(SIS300) || defined(SIS315H) static SiS_StandTableStruct SiS_StandTable[]= { /* 0x00: MD_0_200 */ @@ -642,6 +701,15 @@ static SiS_StandTableStruct SiS_StandTable[]= 0xff} } }; +#endif + +/**************************************************************/ +/* 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, @@ -698,6 +766,7 @@ static const UCHAR SiS_HiTVSt2Timing[] = { 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, @@ -708,6 +777,7 @@ static const UCHAR SiS_HiTVTextTiming[] = { 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96, 0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00 }; +#endif static const UCHAR SiS_HiTVGroup3Data[] = { 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f, @@ -731,6 +801,7 @@ static const UCHAR SiS_HiTVGroup3Simu[] = { 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, @@ -741,9 +812,10 @@ static const UCHAR SiS_HiTVGroup3Text[] = { 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 }; +#endif -static const UCHAR SiS_NTSCPhase[] = {0x21,0xed,0xba,0x08}; /* Was {0x21,0xed,0x8a,0x08}; */ -static const UCHAR SiS_PALPhase[] = {0x2a,0x05,0xe3,0x00}; /* Was {0x2a,0x05,0xd3,0x00}; */ +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}; @@ -751,8 +823,10 @@ 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[]= +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}, @@ -772,10 +846,12 @@ static const SiS_TVDataStruct SiS_ExtPALData[] = /*{ 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 */ + { 1, 1,1170, 821,1270, 520, 686, 0, 686,0xF3,0x00,0x1D,0x20}, /* 1024x768 (for NTSC equ) */ + { 9, 4, 848, 528,1270, 530, 0, 0, 50,0xf5,0xfb,0x1b,0x2a} /* 720x480 test */ }; -static const SiS_TVDataStruct SiS_StNTSCData[]= +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}, @@ -784,7 +860,7 @@ static const SiS_TVDataStruct SiS_StNTSCData[]= { 1, 1, 858, 525,1270, 480, 0, 0, 760,0xf1,0x04,0x1f,0x18} }; -static const SiS_TVDataStruct SiS_ExtNTSCData[]= +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}, @@ -792,102 +868,191 @@ static const SiS_TVDataStruct SiS_ExtNTSCData[]= { 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 */ - { 143, 76, 836, 523,1270, 440, 0, 128, 0,0xee,0x0c,0x22,0x08}, /* 720x480 - BETTER (from 300 series) */ /*{ 2, 1, 858, 503,1270, 480, 0, 128, 0,0xee,0x0c,0x22,0x08},*/ /* 720x480 (old, from 650) */ - { 1, 1,1100, 811,1412, 440, 0, 128, 0,0xee,0x0c,0x22,0x08} /* 1024x768 CORRECTED */ -/*{ 65, 64,1056, 791,1270, 480, 638, 0, 0,0xEE,0x0C,0x22,0x08} */ /* 1024x768 */ -#if 0 /* 300 series was: */ - { 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} -#endif + { 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[]= +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, 0x3e8,0x233,0x311,0x2bc, 0, 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[]= +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}, - { 3, 1, 0x348,0x1e3,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,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00}, /* 800x480 */ + { 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 UCHAR SiS_OutputSelect = 0x40; +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 UCHAR SiS_SoftSetting = 0x30; /* RAM setting */ +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[] = +{ +#if 1 + { 143, 65, 0x35a,0x1bb,0x4f6,0x1b8,0x0ab, 0, 0x0ab, 0x00,0x00,0x00,0x00}, + { 88, 35, 0x35a,0x189,0x4f6,0x1b8,0x0ab, 0, 0x0ab, 0x00,0x00,0x00,0x00}, + { 18, 5, 0x339,0x1ae,0x500,0x2d0,0x05c, 0, 0x05c, 0x00,0x00,0x00,0x00}, + { 143, 70, 0x39c,0x189,0x4f6,0x1b8,0x05c, 0, 0x05c, 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 */ +#if 0 + { 2, 1, 0x35a,0x1f7,0x4f6,0x1e0, 0,128, 0, 0x00,0x00,0x00,0x00}, /* 720x480 */ +#endif + { 99, 32, 0x320,0x1fe,0x500,0x2d0, 50, 0, 0, 0x00,0x00,0x00,0x00}, /* 720x480 test WORKS */ + { 68, 64, 0x55f,0x346,0x500,0x2a8,0x27e, 0, 0, 0x00,0x00,0x00,0x00}, /* 1024x768 */ + { 5, 2, 0x3a7,0x226,0x500,0x2a8, 0,128, 0, 0x00,0x00,0x00,0x00}, /* 720x576 */ + { 25, 24, 0x5d8,0x2f3,0x460,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00} /* 1280x720 WORKS */ +#endif +#if 0 + { 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 */ + { 25, 24, 0x5d8,0x2f3,0x460,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00} /* 1280x720 */ +#endif +#if 0 + { 136, 35, 0x339,0x181,0x460,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00}, /* TEST (0.93) BAD */ + { 17, 6, 0x339,0x203,0x460,0x2a8, 50, 0, 50, 0x00,0x00,0x00,0x00}, + { 136, 35, 0x339,0x181,0x460,0x2a8, 50, 0, 50, 0x00,0x00,0x00,0x00}, + { 17, 6, 0x339,0x203,0x460,0x2a8, 50, 0, 50, 0x00,0x00,0x00,0x00}, + { 85, 46, 0x3f4,0x27b,0x460,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00}, /* 640x480 */ + { 17, 16, 0x55f,0x323,0x460,0x2a8,0x2b6, 0, 0, 0x00,0x00,0x00,0x00}, /* 800x600 */ + { 136, 35, 0x339,0x181,0x460,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00}, /* 720x480 */ + { 187, 74, 0x39d,0x203,0x460,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00}, /* 1024x768 */ + { 25, 24, 0x5d8,0x2f3,0x460,0x2a8, 50, 0, 50, 0x00,0x00,0x00,0x00} /* 1280x720 */ +#endif +}; + +static const SiS_LCDDataStruct SiS_LCD1280x720Data[] = +{ + { 14, 5, 864, 432, 1344, 806 }, /* 640x400 */ + { 16, 5, 864, 378, 1344, 806 }, + { 14, 5, 864, 432, 1344, 806 }, + { 16, 5, 864, 378, 1344, 806 }, + { 24, 11, 924, 523, 1344, 806 }, /* 640x480 */ + { 7, 5, 1152, 664, 1344, 806 }, /* 800x600 */ + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 1, 1, 1344, 806, 1344, 806 } /* 1280x720 */ +}; + +/* About 1280x768: For TMDS, Panel_1280x768 will only be set if + * the panel is a Fujitsu 7911 (VL-17WDX8) (with clock 81, 1688x802) + * Other TMDS panels of this resolution will be treated as custom. + * For LVDS, we know two types. Data follows: + */ + +static const SiS_LCDDataStruct SiS_StLCD1280x768_2Data[] = +{ + { 64, 21, 858, 434, 1408, 806 }, /* 640x400 */ + { 32, 9, 858, 372, 1408, 806 }, + { 64, 21, 858, 434, 1408, 806 }, + { 32, 9, 858, 372, 1408, 806 }, + { 143, 68, 1024, 527, 1408, 806 }, /* 640x480 */ + { 64, 51, 1364, 663, 1408, 806 }, /* 800x600 */ + { 88, 81, 1296, 806, 1408, 806 }, /* 1024x768 */ + { 0, 0, 0, 0, 0, 0 }, + { 1, 1, 1408, 806, 1408, 806 } /* 1280x768 */ +}; + +static const SiS_LCDDataStruct SiS_ExtLCD1280x768_2Data[] = +{ + { 64, 25, 1056, 422, 1408, 806 }, /*, 664 */ + { 128, 39, 884, 396, 1408, 806 }, /*, 640 */ + { 64, 25, 1056, 422, 1408, 806 }, /*, 664 */ + { 128, 39, 884, 396, 1408, 806 }, /*, 640 */ + { 32, 15, 1056, 513, 1408, 806 }, /*, 664 */ + { 176, 125, 1280, 640, 1408, 806 }, /*, 768 */ + { 88, 81, 1296, 806, 1408, 806 }, + { 0, 0, 0, 0, 0, 0 }, + { 1, 1, 1408, 806, 1408, 806 } +}; + +static const SiS_LCDDataStruct SiS_LCD1280x768_3Data[] = +{ + { 64, 25, 1056, 422, 1664, 798 }, /* 640x400 */ + { 128, 39, 884, 396, 1408, 806 }, /* ,640 */ + { 64, 25, 1056, 422, 1664, 798 }, /* 640x400 */ + { 128, 39, 884, 396, 1408, 806 }, /* ,640 */ + { 32, 15, 1056, 513, 1408, 806 }, /* ,664 */ /* 640x480 */ + { 176, 125, 1280, 640, 1408, 806 }, /* ,768 */ /* 800x600 */ + { 64, 61, 1342, 806, 1408, 806 }, /* 1024x768 */ + { 0, 0, 0, 0, 0, 0 }, + { 1, 1, 1408, 806, 1408, 806 } /* 1280x768 */ +}; + +static const SiS_LCDDataStruct SiS_LCD1280x800Data[] = +{ + { 128, 51, 1122, 412, 1408, 816 }, /* 640x400 */ + { 128, 49, 1232, 361, 1408, 816 }, + { 128, 51, 1122, 412, 1408, 816 }, + { 128, 49, 1232, 361, 1408, 816 }, + { 8, 3, 880, 491, 1408, 816 }, /* 640x480 */ + { 11, 6, 1024, 612, 1408, 816 }, /* 800x600 */ + { 22, 21, 1400, 784, 1408, 816 }, /* 1024x768 */ + { 0, 0, 0, 0, 0, 0 }, + { 1, 1, 1408, 816, 1408, 816 } /* 1280x800 */ +}; 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} -}; - -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 *might* be 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 *might* be correct */ -}; - -static const SiS_LCDDataStruct SiS_NoScaleData1280x768[] = -{ /* All values guessed */ - { 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} + { 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 SiS_LCDDataStruct SiS_StLCD1400x1050Data[] = @@ -905,28 +1070,37 @@ static const SiS_LCDDataStruct SiS_StLCD1400x1050Data[] = static const SiS_LCDDataStruct SiS_ExtLCD1400x1050Data[] = { - { 211, 100, 2100, 408, 1688, 1066 }, +/* { 211, 60, 1260, 410, 1688, 1066 }, 640x400 (6330) */ + { 211, 100, 2100, 408, 1688, 1066 }, /* 640x400 (6325) WORKS */ { 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 } +/* { 211, 80, 1400, 490, 1688, 1066 }, 640x480 (6330) */ + { 211, 48, 840, 488, 1688, 1066 }, /* 640x480 (6325) WORKS */ +/* { 211, 117, 1638, 613, 1688, 1066 }, 800x600 (6330) */ + { 211, 72, 1008, 609, 1688, 1066 }, /* 800x600 (6325) WORKS */ + { 211, 128, 1400, 776, 1688, 1066 }, /* 1024x768 */ + { 211, 205, 1680, 1041, 1688, 1066 }, /* 1280x1024 - not used (always unscaled) */ + { 1, 1, 1688, 1066, 1688, 1066 }, /* 1400x1050 */ + { 0, 0, 0, 0, 0, 0 }, /* kludge */ + { 211, 120, 1400, 730, 1688, 1066 } /* 1280x720 */ +}; + +static const SiS_LCDDataStruct SiS_LCD1680x1050Data[] = +{ + { 95, 24, 1260, 410, 1900, 1066 }, /* 0 640x400 */ + { 10, 3, 1710, 362, 1900, 1066 }, + { 95, 24, 1260, 410, 1900, 1066 }, + { 10, 3, 1710, 362, 1900, 1066 }, + { 95, 32, 1400, 490, 1900, 1066 }, /* 4 640x480 */ + { 95, 42, 1470, 610, 1900, 1066 }, /* 5 800x600 */ + { 95, 64, 1750, 784, 1900, 1066 }, /* 6 1024x768 */ + { 95, 94, 1900, 1055, 1900, 1066 }, /* 7 1280x1024 */ + { 41, 31, 1900, 806, 1900, 1066 }, /* 8 1280x768 */ + { 95, 69, 1800, 817, 1900, 1066 }, /* 9 1280x800 patch */ + { 13, 9, 1900, 739, 1900, 1066 }, /* 10 1280x720 */ + { 95, 94, 1880, 1066, 1900, 1066 }, /* 11 1400x1050 patch */ + { 1, 1, 1900, 1066, 1900, 1066 } /* 12 1680x1050 */ }; static const SiS_LCDDataStruct SiS_StLCD1600x1200Data[] = @@ -939,52 +1113,63 @@ static const SiS_LCDDataStruct SiS_StLCD1600x1200Data[] = { 4, 1,1080, 625, 2160, 1250 }, { 5, 2,1350, 800, 2160, 1250 }, {135,88,1600,1100, 2160, 1250 }, - {135,88,1600,1100, 2160, 1250 }, + {72, 49,1680,1092, 2160, 1250 }, { 1, 1,2160,1250, 2160, 1250 } }; static const SiS_LCDDataStruct SiS_ExtLCD1600x1200Data[] = { - {27, 4, 800, 500, 2160, 1250 }, + {72,11, 990, 422, 2160, 1250 }, /* 640x400 (6330) WORKS */ +/* {27, 4, 800, 500, 2160, 1250 }, 640x400 (6235) */ {27, 4, 800, 500, 2160, 1250 }, { 6, 1, 900, 500, 2160, 1250 }, { 6, 1, 900, 500, 2160, 1250 }, - {27, 1, 800, 500, 2160, 1250 }, + {45, 8, 960, 505, 2160, 1250 }, /* 640x480 (6330) WORKS */ +/* {27, 1, 800, 500, 2160, 1250 }, 640x480 (6325) */ { 4, 1,1080, 625, 2160, 1250 }, { 5, 2,1350, 800, 2160, 1250 }, - {27,16,1500,1064, 2160, 1250 }, - {27,16,1500,1064, 2160, 1250 }, + {27,16,1500,1064, 2160, 1250 }, /* 1280x1024 */ + {72,49,1680,1092, 2160, 1250 }, /* 1400x1050 (6330, was not supported on 6325) */ { 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 }, /* 0x00: 320x200, 640x400 */ { 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 */ -}; + { 1, 1, 800, 525, 800, 525 }, /* 0x04: 320x240, 640x480 */ + { 1, 1,1056, 628,1056, 628 }, /* 0x05: 400x300, 800x600 */ + { 1, 1,1344, 806,1344, 806 }, /* 0x06: 512x384, 1024x768 */ + { 1, 1,1688,1066,1688,1066 }, /* 0x07: 1280x1024 */ + { 1, 1,1688, 802,1688, 802 }, /* 0x08: 1280x768: Fujitsu, TMDS only */ + { 1, 1,2160,1250,2160,1250 }, /* 0x09: 1600x1200 */ + { 1, 1,1800,1000,1800,1000 }, /* 0x0a: 1280x960 */ + { 1, 1,1688,1066,1688,1066 }, /* 0x0b: 1400x1050 */ + { 1, 1,1650, 750,1650, 750 }, /* 0x0c: 1280x720 (TMDS, projector) */ + { 1, 1,1656, 841,1656, 841 }, /* 0x0d: 1280x800 (was: 1408, 816) */ + { 1, 1,1900,1066,1900,1066 }, /* 0x0e: 1680x1050 (LVDS) */ + { 1, 1,1408, 806,1408, 806 }, /* 0x0f: 1280x768_2 */ + { 1, 1,1664, 798,1664, 798 }, /* 0x10: 1280x768_3 */ + { 1, 1,1688, 802,1688, 802 }, /* 0x11: 1280x768: Std, TMDS only */ + { 1, 1,1344, 806,1344, 806 }, /* 0x12: 1280x720 (LVDS) */ + { 1, 1, 896, 497, 896, 497 }, /* 0x13: 720x480 */ + { 1, 1, 912, 597, 912, 597 }, /* 0x14: 720x576 */ + { 1, 1, 912, 597, 912, 597 }, /* 0x15: 768x576 */ + { 1, 1,1056, 497,1056, 497 }, /* 0x16: 848x480 */ + { 1, 1,1064, 497,1064, 497 }, /* 0x17: 856x480 */ + { 1, 1,1056, 497,1056, 497 }, /* 0x18: 800x480 */ + { 1, 1,1328, 739,1328, 739 }, /* 0x19: 1024x576 */ + { 1, 1,1680, 892,1680, 892 }, /* 0x1a: 1152x864 */ + { 1, 1,1808, 808,1808, 808 }, /* 0x1b: 1360x768 */ + { 1, 1,1104, 563,1104, 563 } /* 0x1c: 960x540 */ +}; + + +/**************************************************************/ +/* LVDS ----------------------------------------------------- */ +/**************************************************************/ static const SiS_LVDSDataStruct SiS_LVDS320x480Data_1[]= { @@ -999,6 +1184,30 @@ static const SiS_LVDSDataStruct SiS_LVDS320x480Data_1[]= { 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}, @@ -1007,9 +1216,7 @@ static const SiS_LVDSDataStruct SiS_LVDS800x600Data_1[]= { 848, 389,1060, 629}, { 848, 518,1060, 629}, {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - { 800, 449,1000, 644}, - { 800, 525,1000, 635} + {1056, 628,1056, 628} }; static const SiS_LVDSDataStruct SiS_LVDS800x600Data_2[]= @@ -1020,35 +1227,7 @@ static const SiS_LVDSDataStruct SiS_LVDS800x600Data_2[]= {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_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} + {1056, 628,1056, 628} }; static const SiS_LVDSDataStruct SiS_LVDS1024x768Data_1[]= @@ -1060,8 +1239,6 @@ static const SiS_LVDSDataStruct SiS_LVDS1024x768Data_1[]= { 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[]= @@ -1073,58 +1250,30 @@ static const SiS_LVDSDataStruct SiS_LVDS1024x768Data_2[]= {1344, 806,1344, 806}, {1344, 806,1344, 806}, {1344, 806,1344, 806}, - { 800, 449,1280, 801}, - { 800, 525,1280, 813} }; -/* Custom data for Barco iQ R300 */ -static const SiS_LVDSDataStruct SiS_LVDSBARCO1366Data_1[]= +static const SiS_LVDSDataStruct SiS_LVDS1280x1024Data_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 */ + {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} }; -/* Custom data for Barco iQ R300 */ -static const SiS_LVDSDataStruct SiS_LVDSBARCO1366Data_2[]= +static const SiS_LVDSDataStruct SiS_LVDS1280x1024Data_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 */ -}; - -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 */ -}; - -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}, + {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[]= @@ -1155,6 +1304,17 @@ static const SiS_LVDSDataStruct SiS_LVDS1400x1050Data_2[]= 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}, @@ -1165,20 +1325,47 @@ static const SiS_LVDSDataStruct SiS_LVDS1600x1200Data_1[]= {1728,1066, 2048,1250}, {1848,1066, 2048,1250}, {2048,1250, 2048,1250} +#endif }; static const SiS_LVDSDataStruct SiS_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} + {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[]= @@ -1209,15 +1396,13 @@ static const SiS_LVDSDataStruct SiS_LVDS1280x768Data_2[]= 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}, + { 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} + {1344, 800,1344, 800} }; static const SiS_LVDSDataStruct SiS_LVDS1024x600Data_2[] = @@ -1228,9 +1413,7 @@ static const SiS_LVDSDataStruct SiS_LVDS1024x600Data_2[] = {1344, 800,1344, 800}, {1344, 800,1344, 800}, {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - { 800, 449,1280, 801}, - { 800, 525,1280, 813} + {1344, 800,1344, 800} }; static const SiS_LVDSDataStruct SiS_LVDS1152x768Data_1[] = @@ -1241,9 +1424,7 @@ static const SiS_LVDSDataStruct SiS_LVDS1152x768Data_1[] = { 840, 409,1344, 806}, { 840, 518,1344, 806}, {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - { 800, 449,1280, 801}, - { 800, 525,1280, 813} + {1344, 806,1344, 806} }; static const SiS_LVDSDataStruct SiS_LVDS1152x768Data_2[] = @@ -1254,12 +1435,10 @@ static const SiS_LVDSDataStruct SiS_LVDS1152x768Data_2[] = {1344, 806,1344, 806}, {1344, 806,1344, 806}, {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - { 800, 449,1280, 801}, - { 800, 525,1280, 813} + {1344, 806,1344, 806} }; -/* TW: Pass 1:1 data */ +/* Pass 1:1 data */ static const SiS_LVDSDataStruct SiS_LVDSXXXxXXXData_1[]= { { 800, 449, 800, 449}, @@ -1269,49 +1448,53 @@ static const SiS_LVDSDataStruct SiS_LVDSXXXxXXXData_1[]= { 800, 525, 800, 525}, /* 640x480 */ {1056, 628, 1056, 628}, /* 800x600 */ {1344, 806, 1344, 806}, /* 1024x768 */ - {1344,1066, 1344,1066}, /* 1280x1024 */ /* INSERTED ! */ + {1688,1066, 1688,1066}, /* 1280x1024 */ /* INSERTED ! */ {1688, 806, 1688, 806}, /* 1280x768 */ /* No other panels ! */ }; -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[]= +/* Custom data for Barco iQ R series */ +static const SiS_LVDSDataStruct SiS_LVDSBARCO1366Data_1[]= { - { 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 */ + { 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 */ }; - -static const SiS_LVDSDataStruct SiS_LVDS1280x960Data_1[]= +/* Custom data for Barco iQ R series */ +static const SiS_LVDSDataStruct SiS_LVDSBARCO1366Data_2[]= { - { 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} + {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 */ }; -static const SiS_LVDSDataStruct SiS_LVDS1280x960Data_2[]= +/* 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}, @@ -1320,10 +1503,9 @@ static const SiS_LVDSDataStruct SiS_LVDS1280x960Data_2[]= {1344, 806,1344, 806}, {1344, 806,1344, 806}, {1344, 806,1344, 806}, - { 800, 449,1280, 801}, - { 800, 525,1280, 813} }; +/* Custom data for 848x480 parallel panel */ static const SiS_LVDSDataStruct SiS_LVDS848x480Data_1[]= { { 0, 0, 0, 0}, @@ -1341,6 +1523,7 @@ static const SiS_LVDSDataStruct SiS_LVDS848x480Data_1[]= {1088, 525,1088, 525} /* 1360x768 TODO */ }; +/* Custom data for 848x480 parallel panel */ static const SiS_LVDSDataStruct SiS_LVDS848x480Data_2[]= { { 0, 0, 0, 0}, @@ -1358,63 +1541,6 @@ static const SiS_LVDSDataStruct SiS_LVDS848x480Data_2[]= {1088, 525,1088, 525} /* 1360x768 TODO */ }; -/* LCDA */ - -static const SiS_LVDSDataStruct SiS_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 SiS_LVDSDataStruct SiS_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 SiS_LVDSDataStruct SiS_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 SiS_LVDSDataStruct SiS_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} -}; - static const SiS_LVDSDataStruct SiS_CHTVUNTSCData[]= { { 840, 600, 840, 600}, @@ -1437,139 +1563,7 @@ static const SiS_LVDSDataStruct SiS_CHTVONTSCData[]= {1160, 840,1160, 840} }; -static const SiS_LVDSDesStruct SiS_PanelType1076_1[]= -{ /* 1024x768 */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS_LVDSDesStruct SiS_PanelType1076_2[]= -{ /* 1024x768 */ - { 1184, 622 }, - { 1184, 597 }, - { 1184, 622 }, - { 1184, 597 }, - { 1152, 622 }, - { 1232, 722 }, - { 0, 0 }, - { 0, 794 }, - { 0, 0 } -}; - -static const SiS_LVDSDesStruct SiS_PanelType1210_1[]= -{ /* 1280x1024 */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS_LVDSDesStruct SiS_PanelType1210_2[]= -{ /* 1280x1024 */ - { 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 , 0} -}; - -static const SiS_LVDSDesStruct SiS_PanelType1296_2[]= -{ /* 1400x1050 - looks heavily invalid */ - { 808 , 740}, - { 0 , 715}, - { 632 , 740}, - { 632 , 715}, - { 1307, 780}, - { 1387,1157}, - { 1499, 924}, - { 1627,1052}, - { 0 , 0} -}; - -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 - BIOS 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 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[]= { @@ -1615,6 +1609,8 @@ static const SiS_LVDSDesStruct SiS_CHTVOPALDesData[]= { 0, 0} }; +/* CRT1 CRTC data for slave modes */ + static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1320x480_1[] = { {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f, @@ -1640,204 +1636,345 @@ static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1320x480_1[] = 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}} + {{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}} + {{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}} + {{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}} + {{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}} + {{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}} + {{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}} + {{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}} + {{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[] = @@ -1964,202 +2101,9 @@ static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_2_H[] = 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}} -}; - -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}} -}; +/**************************************************************/ +/* COMMON --------------------------------------------------- */ +/**************************************************************/ #define SIS_PL_HSYNCP 0x01 #define SIS_PL_HSYNCN 0x02 @@ -2176,7 +2120,6 @@ typedef struct _SiS_PlasmaModes UCHAR SyncFlags; } SiS_PlasmaModes; - typedef struct _SiS_PlasmaTables { USHORT vendor; @@ -2283,7 +2226,17 @@ static const SiS_PlasmaModes SiS_PlasmaMode[] = { 36000, 800, 1024, 24, 2, 600, 625, 1, 2, - SIS_PL_HSYNCP | SIS_PL_VSYNCP } + 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[] = { @@ -2397,159 +2350,105 @@ static const SiS_PlasmaTables SiS_PlasmaTable[] = { { 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 } }; -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); -BOOLEAN SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo); -void SiS_IsLowResolution(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -void SiS_GetSysFlags(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -#ifdef SIS315H -UCHAR SiS_Get310DRAMType(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -#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, int enable); -void SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable); -BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo,USHORT *ModeIdIndex); -#ifndef LINUX_XF86 -BOOLEAN SiS_CheckMemorySize(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT ModeIdIndex); -#endif -UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex); -void SiS_WhatTheHellIsThis(SiS_Private *SiS_Pr,PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr); -void SiS_StrangeStuff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -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); +USHORT SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, + int Depth, BOOLEAN FSTN, int LCDwith, int LCDheight); +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); +BOOLEAN SiSDetermineROMLayout661(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); +void SiS_CalcLCDACRT1Timing(SiS_Private *SiS_Pr,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 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); +#ifdef LINUX_KERNEL +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_INFO HwInfo, + unsigned char modeno, unsigned char rateindex, + struct fb_var_screeninfo *var); +BOOLEAN sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex); #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 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); + +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 -BOOLEAN SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO); -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); + 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, BOOLEAN hcm); -#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_SetCRT2Group(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - 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 void 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); - -#ifdef LINUX_KERNEL -int sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - unsigned char modeno, unsigned char rateindex); -int sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - unsigned char modeno, unsigned char rateindex, - 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_DEVICE_INFO HwDeviceExtension, - unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex); +extern USHORT SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, unsigned long VBFlags, + BOOLEAN hcm); #endif #endif diff --git a/src/init301.c b/src/init301.c index 3552a29..0ebf272 100644 --- a/src/init301.c +++ b/src/init301.c @@ -1,34 +1,58 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c,v 1.29 2003/09/09 10:29:00 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* - * Mode switching code (CRT2 section) - * for SiS 300/305/540/630/730/315/550/650/M650/651/740/330/660/M660/760/M760 - * (Universal module for Linux kernel framebuffer and 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(GX)/M741/330/660/M660/760/M760 + * (Universal module for Linux kernel framebuffer and XFree86/X.org 4.x) * - * Copyright 2002, 2003 by Thomas Winischhofer - * Formerly based on non-functional code-fragements for 300 series by SiS, Inc. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * If distributed as part of the linux kernel, the contents of this file - * is entirely covered by the GPL. + * * 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 terms apply: + * Otherwise, 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. + * * 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) 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 EXPRESSED 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. * - * 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. + * 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. @@ -36,23 +60,19 @@ * 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 -#endif -#if 0 -#define SET_EMI +#if 1 +#define SET_EMI /* 302LV/ELV: Set EMI values */ #endif -#include "init301.h" +#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) */ -#if 0 -#define TWNEWPANEL -#endif +#include "init301.h" #ifdef SIS300 #include "oem300.h" @@ -65,3490 +85,3134 @@ #define SiS_I2CDELAY 1000 #define SiS_I2CDELAYSHORT 150 -BOOLEAN -SiS_SetCRT2Group(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +static USHORT SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr); + +/*********************************************/ +/* 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: Write SR11 */ +/*********************************************/ - /* Used for shifting CR33 */ - SiS_Pr->SiS_SelectCRT2Rate = 4; +static void +SiS_SetRegSR11ANDOR(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DataAND, USHORT DataOR) +{ + if(HwInfo->jChipType >= SIS_661) { + DataAND &= 0x0f; + DataOR &= 0x0f; + } + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,DataAND,DataOR); +} - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); +/*********************************************/ +/* HELPER: Get Pointer to LCD structure */ +/*********************************************/ - RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr, ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); +#ifdef SIS315H +static UCHAR * +GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + UCHAR *myptr = NULL; + USHORT romindex = 0; - SiS_SaveCRT2Info(SiS_Pr,ModeNo); + /* Use the BIOS tables only for LVDS panels; DVI is unreliable + * due to the variaty of panels the BIOS doesn't know about. + */ - 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); + if((SiS_Pr->SiS_ROMNew) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + myptr = (UCHAR *)SiS_LCDStruct661; + romindex = SISGETROMW(0x100); + if(romindex) { + romindex += ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x7d) & 0x1f) * 26); + myptr = &ROMAddr[romindex]; } - SiS_SetCRT2ModeRegs(SiS_Pr,BaseAddr,ModeNo,ModeIdIndex,HwDeviceExtension); } + return myptr; +} - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - SiS_LockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); - SiS_DisplayOn(SiS_Pr); - return(TRUE); - } +static USHORT +GetLCDStructPtr661_2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT romptr = 0; - SiS_GetCRT2Data(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); + /* Use the BIOS tables only for LVDS panels; DVI is unreliable + * due to the variaty of panels the BIOS doesn't know about. + */ - /* 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, BaseAddr); - } else { - SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; + if((SiS_Pr->SiS_ROMNew) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + romptr = SISGETROMW(0x102); + romptr += ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) * SiS_Pr->SiS661LCD2TableSize); } -#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 + return(romptr); +} #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 checkmask=0,modeid,infoflag; - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { + modeid = 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); + if(SiS_Pr->SiS_VBType & VB_SISVB) { - /* 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); - } - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { + + checkmask |= SupportRAMDAC2; + if(HwInfo->jChipType >= SIS_315H) { + checkmask |= SupportRAMDAC2_135; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + checkmask |= SupportRAMDAC2_162; + if(SiS_Pr->SiS_VBType & VB_SIS301C) { + checkmask |= SupportRAMDAC2_202; } - SiS_SetCRT2ECLK(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); } - } + } - } else { + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - 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); + checkmask |= SupportLCD; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(modeid == 0x2e) checkmask |= Support64048060Hz; + } } } - SiS_SetCRT2ECLK(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - 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 - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_SetCHTVReg(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex); + checkmask |= SupportHiVision; + + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750|SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) { + + checkmask |= SupportTV; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + checkmask |= SupportTV1024; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { + checkmask |= SupportYPbPr750p; } - } + } } - } - -#ifdef SIS300 - if(HwDeviceExtension->jChipType < SIS_315H) { - 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,ModeIdIndex, - RefreshRateTableIndex); - } - } else { - SiS_OEM300Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,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,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo, - ModeIdIndex,RefreshRateTableIndex); - } - if(HwDeviceExtension->jChipType == SIS_730) { - SiS_DisplayOn(SiS_Pr); - } - } - } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(HwDeviceExtension->jChipType != SIS_730) { - SiS_DisplayOn(SiS_Pr); - } - } - } -#endif + } -#ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - SiS_FinalizeLCD(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, HwDeviceExtension); - if(SiS_Pr->SiS_UseOEM) { - SiS_OEM310Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - } - SiS_CRT2AutoThreshold(SiS_Pr,BaseAddr); - } - } -#endif + } else { /* LVDS */ - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - SiS_EnableBridge(SiS_Pr,HwDeviceExtension,BaseAddr); - } + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + checkmask |= SupportCHTV; + } + } - SiS_DisplayOn(SiS_Pr); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + checkmask |= SupportLCD; + } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - /* Disable LCD panel when using TV */ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x11,0x0C); - } else { - /* 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 == modeid; (*i)--) { + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].Ext_InfoFlag; + if(infoflag & checkmask) return TRUE; + 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 != modeid) { + return FALSE; + } + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].Ext_InfoFlag; + if(infoflag & checkmask) return TRUE; + } + return TRUE; } -BOOLEAN -SiS_LowModeStuff(SiS_Private *SiS_Pr, USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp,temp1,temp2; - - 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); - } - } -} +/*********************************************/ +/* Get rate index */ +/*********************************************/ -/* 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 +SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { - USHORT temp=0, tempax=0, tempbx=0, tempcx=0; - USHORT pushbx=0, CRT1Index=0; -#ifdef SIS315H - USHORT tempbl=0; -#endif - USHORT modeflag, resinfo=0; + 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; + + /* Do NOT check for UseCustomMode here, will skrew up FIFO */ + if(ModeNo == 0xfe) return 0; 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; - } + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { -#ifdef SIS315H - SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo, - RefreshRateTableIndex,HwDeviceExtension); + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(modeflag & HalfDCLK) return 0; + } + } - SiS_SetGroup1_LCDA(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); -#endif - } else { + if(ModeNo < 0x14) return 0xFFFF; - 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_GetBIOSLCDResInfo(SiS_Pr)]; + 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); - - 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 - } + RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; + ModeNo = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].ModeID; - SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo, - RefreshRateTableIndex,HwDeviceExtension); + 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++; + } + } + } - /* 1. Horizontal setup */ + 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); - if (HwDeviceExtension->jChipType < SIS_315H ) { + 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++; + } + } -#ifdef SIS300 /* ------------- 300 series --------------*/ + i--; - temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ + 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) & 0xFF00) >> 8) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */ + return(RefreshRateTableIndex + i); +} - temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */ +/*********************************************/ +/* STORE CRT2 INFO in CR34 */ +/*********************************************/ - 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; +static void +SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo) +{ + USHORT temp1,temp2; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + /* 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->UseCustomMode) { - tempbx = SiS_Pr->CHSyncStart + 12; - tempcx = SiS_Pr->CHSyncEnd + 12; - } +/*********************************************/ +/* HELPER: GET SOME DATA FROM BIOS ROM */ +/*********************************************/ - 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; - } - - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == SIS_RI_1024x768)){ - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)){ - tempbx = 1040; - tempcx = 1042; - } - } - } +#ifdef SIS300 +static BOOLEAN +SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = (UCHAR *)HwInfo->pjVirtualRomBase; + USHORT temp,temp1; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp); /* CRT2 Horizontal Retrace Start */ -#endif /* SIS300 */ + if(SiS_Pr->SiS_UseROM) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xff) >> 4); + temp1 = SISGETROMW(0x23b); + if(temp1 & temp) return TRUE; + } + } + return FALSE; +} - } else { +static BOOLEAN +SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = (UCHAR *)HwInfo->pjVirtualRomBase; + USHORT temp,temp1; -#ifdef SIS315H /* ------------------- 315/330 series --------------- */ + if(SiS_Pr->SiS_UseROM) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xff) >> 4); + temp1 = SISGETROMW(0x23d); + if(temp1 & temp) return TRUE; + } + } + return FALSE; +} +#endif - tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HT 0x08,0x09 */ - if(modeflag & HalfDCLK) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - 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; - } - } else { - tempcx >>= 1; - } - } - tempcx--; +/*********************************************/ +/* HELPER: DELAY FUNCTIONS */ +/*********************************************/ - temp = tempcx & 0xff; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ +void +SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime) +{ + USHORT i, j; - temp = ((tempcx & 0xff00) >> 8) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0F,temp); /* CRT2 Horizontal Total Overflow [7:4] */ + for(i=0; iSiS_P3c4,0x05); + } +} - 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; +#if defined(SIS300) || defined(SIS315H) +static void +SiS_GenericDelay(SiS_Private *SiS_Pr, USHORT delay) +{ + USHORT temp,flag; - temp = tempbx & 0xff; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */ + flag = SiS_GetRegByte(0x61) & 0x10; - pushbx = tempbx; - tempcx >>= 1; - tempbx += tempcx; - tempcx += tempbx; + while(delay) { + temp = SiS_GetRegByte(0x61) & 0x10; + if(temp == flag) continue; + flag = temp; + delay--; + } +} +#endif - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - - 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(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; - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if(resinfo == SIS_RI_1024x768) { - tempbx = 1040; - tempcx = 1042; - } - } - } -#if 0 - /* Makes no sense, but is in 650/30xLV 1.10.6s */ - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == SIS_RI_1024x768)){ - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - tempbx = 1040; - tempcx = 1042; - } - } - } +#ifdef SIS315H +static void +SiS_LongDelay(SiS_Private *SiS_Pr, USHORT delay) +{ + while(delay--) { + SiS_GenericDelay(SiS_Pr,0x19df); + } +} #endif - } - temp = tempbx & 0xff; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp); /* CRT2 Horizontal Retrace Start */ -#endif /* SIS315H */ +#if defined(SIS300) || defined(SIS315H) +static void +SiS_ShortDelay(SiS_Private *SiS_Pr, USHORT delay) +{ + while(delay--) { + SiS_GenericDelay(SiS_Pr,0x42); + } +} +#endif - } /* 315/330 series */ +static void +SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime) +{ +#if defined(SIS300) || defined(SIS315H) + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT PanelID, DelayIndex, Delay=0; +#endif - /* The following is done for all bridge/chip types/series */ + if(HwInfo->jChipType < SIS_315H) { - 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); /* Overflow */ +#ifdef SIS300 - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0D,temp); /* CRT2 Horizontal Retrace End */ + 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(!(DelayTime & 0x01)) { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; + } else { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; + } + if(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); - /* 2. Vertical setup */ +#endif /* SIS300 */ - tempcx = SiS_Pr->SiS_VGAVT - 1; - temp = tempcx & 0x00FF; + } else { - 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) { - /* 650/30xLV 1.10.6s */ - temp--; - } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0E,temp); /* CRT2 Vertical Total */ - - tempbx = SiS_Pr->SiS_VGAVDE - 1; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0F,temp); /* CRT2 Vertical Display Enable End */ - - temp = ((tempbx & 0xFF00) << 3) >> 8; - temp |= ((tempcx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x12,temp); /* Overflow (and HWCursor Test Mode) */ - - /* 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 { - /* 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((HwInfo->jChipType >= SIS_661) || + (HwInfo->jChipType <= SIS_315PRO) || + (HwInfo->jChipType == SIS_330)) { - if(SiS_Pr->UseCustomMode) { - tempbx = SiS_Pr->CVSyncStart; - tempcx = (tempcx & 0xFF00) | (SiS_Pr->CVSyncEnd & 0x00FF); - } + if(!(DelayTime & 0x01)) { + SiS_DDC2Delay(SiS_Pr, 0x1000); + } else { + SiS_DDC2Delay(SiS_Pr, 0x4000); + } - 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_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp); /* CRT2 Vertical Retrace Start */ + } else if((SiS_Pr->SiS_IF_DEF_LVDS == 1) /* || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400) */ ) { /* 315 series, LVDS; Special */ - temp = ((tempbx & 0xFF00) >> 8) << 4; - temp |= (tempcx & 0x000F); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x11,temp); /* CRT2 Vert. Retrace End; Overflow; "Enable CRTC Check" */ + 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((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { + 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_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 & SetCRT2ToHiVisionTV) { - 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 & (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); /* 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_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80)) 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_LCDResInfo == SiS_Pr->SiS_PanelCustom) temp = 0x2c; - 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) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { - 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; - } - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD|SetCRT2ToLCDA)) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(HwDeviceExtension->pdc) { - temp = HwDeviceExtension->pdc; - tempbl = 0; - } - } - } - } 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; - } - } - - 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; - } - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,tempbl,temp); /* Panel Link Delay Compensation */ + watchdog = 65535; + while((SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08) && --watchdog); + watchdog = 65535; + while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); +} - tempax = 0; - if (modeflag & DoubleScanMode) tempax |= 0x80; - if (modeflag & HalfDCLK) tempax |= 0x40; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax); +#if defined(SIS300) || defined(SIS315H) +static void +SiS_WaitRetrace2(SiS_Private *SiS_Pr, USHORT reg) +{ + USHORT watchdog; -#endif /* SIS315H */ + watchdog = 65535; + while((SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02) && --watchdog); + watchdog = 65535; + while((!(SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02)) && --watchdog); +} +#endif - } +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 + } +} - } /* Slavemode */ +static void +SiS_VBWait(SiS_Private *SiS_Pr) +{ + USHORT tempal,temp,i,j; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + 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; + else break; + } else { + if(!(tempal & 0x08)) continue; + else break; + } + } + temp ^= 0x01; + } +} - /* For 301BDH with LCD, we set up the Panel Link */ - if( (SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) { +static void +SiS_VBLongWait(SiS_Private *SiS_Pr) +{ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SiS_VBWait(SiS_Pr); + } else { + SiS_WaitRetrace1(SiS_Pr); + } +} - SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); +/*********************************************/ +/* HELPER: MISC */ +/*********************************************/ - } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { +#ifdef SIS300 +static BOOLEAN +SiS_Is301B(SiS_Private *SiS_Pr) +{ + if(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01) >= 0xb0) return TRUE; + return FALSE; +} +#endif - SiS_SetGroup1_301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); - } +static BOOLEAN +SiS_CRT2IsLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - } else { + 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; +} - 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); - } - - } +BOOLEAN +SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ +#ifdef SIS315H + USHORT flag; + 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; } - } /* LCDA */ + } +#endif + 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_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - USHORT push1,push2; - USHORT tempax,tempbx,tempcx,temp; - USHORT resinfo,modeflag; - unsigned char p1_7, p1_8; +#ifdef SIS315H + USHORT flag; - 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(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if((flag & EnableDualEdge) && (flag & SetToLCDA)) return TRUE; } +#endif + return FALSE; +} - /* 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 +static BOOLEAN +SiS_IsVAorLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + if(SiS_IsVAMode(SiS_Pr,HwInfo)) return TRUE; + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) return TRUE; + return FALSE; +} +#endif - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) modeflag |= Charx8Dot; +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; + } + } +#endif + return FALSE; +} - if(modeflag & Charx8Dot) tempcx = 0x08; - else tempcx = 0x09; +#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_SIS301C | VB_SIS301LV302LV)) { + if(SiS_GetReg(SiS_Pr->SiS_Part2Port,0x4d) & 0x10) return TRUE; + } + return FALSE; +} +#endif - if(tempax >= SiS_Pr->SiS_VGAHT) tempax = SiS_Pr->SiS_VGAHT; +#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 - if(modeflag & HalfDCLK) tempax >>= 1; +#ifdef SIS315H +static BOOLEAN +SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x79) & 0x10) return TRUE; + } + return FALSE; +} +#endif - tempax = (tempax / tempcx) - 5; - tempbx = tempax & 0x00FF; +#ifdef SIS315H +static BOOLEAN +SiS_IsNotM650orLater(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,0xff); /* set MAX HT */ + 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 - 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); +#ifdef SIS315H +static BOOLEAN +SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - temp = (tempbx & 0xFF00) >> 8; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - temp += 2; - } + if(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */ } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(SiS_Pr->SiS_HiVision == 3) { - if(resinfo == SIS_RI_800x600) 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_LCDInfo & DontExpandLCD) temp += 28; - } - } - } - } - } - } - - p1_7 = temp; - p1_8 = 0x00; + return FALSE; +} +#endif - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - if(ModeNo <= 0x01) { - p1_7 = 0x2a; - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) p1_8 = 0x61; - else p1_8 = 0x41; - } else if(SiS_Pr->SiS_ModeType == ModeText) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) p1_7 = 0x54; - else p1_7 = 0x55; - p1_8 = 0x00; - } else if(ModeNo <= 0x13) { - if(modeflag & HalfDCLK) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - p1_7 = 0x30; - p1_8 = 0x03; - } else { - p1_7 = 0x2f; - p1_8 = 0x02; - } - } else { - p1_7 = 0x5b; - p1_8 = 0x03; - } - } else if( ((HwDeviceExtension->jChipType >= SIS_315H) && - ((ModeNo == 0x50) || (ModeNo = 0x56) || (ModeNo = 0x53))) || - ((HwDeviceExtension->jChipType < SIS_315H) && - (resinfo == SIS_RI_320x200 || resinfo == SIS_RI_320x240)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - p1_7 = 0x30, - p1_8 = 0x03; - } else { - p1_7 = 0x2f; - p1_8 = 0x03; - } - } - } - } +#ifdef SIS315H +static BOOLEAN +SiS_IsChScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(SiS_Pr->SiS_HiVision & 0x03) { - p1_7 = 0xb2; - if(SiS_Pr->SiS_HiVision & 0x02) { - p1_7 = 0xab; - } - } + if(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 */ } + return FALSE; +} +#endif - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,p1_7); /* 0x07 Horizontal Retrace Start */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,p1_8); /* 0x08 Horizontal Retrace End */ - - - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x03); /* 0x18 SR08 (FIFO Threshold?) */ - - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x19,0xF0); - - 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; - 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_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp); /* 0x10 vertical Blank Start */ +#ifdef SIS315H +static BOOLEAN +SiS_IsTVOrYPbPrOrScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - 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; + 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; } + return FALSE; +} #endif - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0E,temp); - - if(tempbx & 0x0100) tempcx |= 0x0002; - - tempax = 0x000B; - if(modeflag & DoubleScanMode) tempax |= 0x8000; - - if(tempbx & 0x0200) tempcx |= 0x0040; - - temp = (tempax & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp); - - if(tempbx & 0x0400) tempcx |= 0x0600; - - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x11,0x00); /* 0x11 Vertical Blank End */ - - tempax = (SiS_Pr->SiS_VGAVT - tempbx) >> 2; - if((ModeNo > 0x13) || (HwDeviceExtension->jChipType < SIS_315H)) { - if(resinfo != SIS_RI_1280x1024) { - tempbx += (tempax << 1); - } - } else if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) { - tempbx += (tempax << 1); - } - } +#ifdef SIS315H +static BOOLEAN +SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (SiS_Pr->SiS_HiVision == 3)) { - tempbx -= 10; + 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 { - 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 >>= 2; - tempax++; - tempax += tempbx; - push1 = tempax; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - if(tempbx <= 513) { - if(tempax >= 513) tempbx = 513; - } + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToLCD) return TRUE; } - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0C,temp); /* 0x0C Vertical Retrace Start */ - - tempbx--; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp); - - if(tempbx & 0x0100) tempcx |= 0x0008; + return FALSE; +} +#endif - if(tempbx & 0x0200) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20); - } - tempbx++; +static BOOLEAN +SiS_BridgeIsOn(SiS_Private *SiS_Pr) +{ + USHORT flag; - 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 TRUE; + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); + if((flag == 1) || (flag == 2)) return TRUE; } + return FALSE; +} - tempbx = push1; - temp = tempbx & 0x000F; - 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; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp); /* 0x0A CR07 */ + 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 TRUE; + } else { + flag &= 0x50; + if((flag == 0x40) || (flag == 0x10)) return TRUE; + } + } + return FALSE; +} - temp = (tempcx & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,temp); /* 0x17 SR0A */ +static BOOLEAN +SiS_BridgeInSlavemode(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) { - /* 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; +#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; - - /* This is not supported on LVDS */ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return; - if(SiS_Pr->UseCustomMode) return; + 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; + } else 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; } - /* Set up Panel Link */ - - /* 1. Horizontal setup */ - - tempax = SiS_Pr->SiS_LCDHDES; - - 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; - } - } - - tempcx = SiS_Pr->SiS_HT; /* Horiz. Total */ + SiS_Pr->SiS_SetFlag = 0; - tempbx = SiS_Pr->SiS_HDE; /* Horiz. Display End */ + SiS_Pr->SiS_ModeType = modeflag & ModeInfoFlag; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || - SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) { - tempbx >>= 1; - } + tempbx = 0; + if(SiS_BridgeIsOn(SiS_Pr)) { + 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_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; +#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 if not driver mode */ + 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; } } - } - } - } - tempcx = (tempcx - tempbx) >> 2; /* HT-HDE / 4 */ - push1 = tempax; + if(SiS_Pr->SiS_VBType & (VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV)) { + tempbx &= ~(SetCRT2ToRAMDAC); + } - tempax += tempbx; + 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; + } + } + } - if(tempax >= SiS_Pr->SiS_HT) tempax -= SiS_Pr->SiS_HT; + 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; + } + } + } + } - push2 = tempax; +#endif /* SIS315H */ - 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(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(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; } - 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; } - } - } - } - - tempcx += tempax; /* lcdhrs */ - if(tempcx >= SiS_Pr->SiS_HT) tempcx -= SiS_Pr->SiS_HT; + } - tempax = tempcx >> 3; /* BPLHRS */ - temp = tempax & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,temp); /* Part1_14h; Panel Link Horizontal Retrace Start */ + if(!(tempbx & temp)) { + tempax = DisableCRT2Display; + tempbx = 0; + } - 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(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; - } - } - } - } + 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); } - } - } - } - } + } + 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; + } + } + } - 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_SetReg1(SiS_Pr->SiS_Part1Port,0x15,temp); /* Part1_15h; Panel Link Horizontal Retrace End/Skew */ + if(tempax & DisableCRT2Display) { + if(!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { + tempbx = SetSimuScanMode | DisableCRT2Display; + } + } - tempbx = push2; - tempcx = push1; /* lcdhdes */ + if(!(tempbx & DriverMode)) tempbx |= SetSimuScanMode; - temp = (tempcx & 0x0007); /* BPLHDESKEW */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1A,temp); /* Part1_1Ah; Panel Link Vertical Retrace Start (2:0) */ + /* 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) || + ((SiS_Pr->SiS_VBType & VB_NoLCD) && (tempbx & SetCRT2ToLCD)) ) { + modeflag &= (~CRT2Mode); + } + } - tempcx >>= 3; /* BPLHDES */ - temp = (tempcx & 0x00FF); -#if 0 /* Not 550 FSTN */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(ModeNo == 0x5b) temp--; */ - } -#endif - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,temp); /* Part1_16h; Panel Link Horizontal Display Enable Start */ + 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_BridgeInSlavemode(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; + } + } - if((HwDeviceExtension->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(HwDeviceExtension->jChipType >= SIS_315H) { - if(ModeNo == 0x5b) temp--; + + SiS_Pr->SiS_VBInfo = tempbx; + + if(HwInfo->jChipType == SIS_630) { + SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo); } + +#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 - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,temp); /* Part1_17h; Panel Link Horizontal Display Enable End */ +} - /* 2. Vertical setup */ +/*********************************************/ +/* DETERMINE YPbPr MODE */ +/*********************************************/ - if(HwDeviceExtension->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; - } +void +SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + + UCHAR temp; + + /* 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. + */ + + SiS_Pr->SiS_YPbPr = 0; + if(HwInfo->jChipType >= SIS_661) return; + + 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; + } } } - tempcx -= tempbx; + } - } else { +} - tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE; /* VGAVT-VGAVDE */ +/*********************************************/ +/* DETERMINE TVMode flag */ +/*********************************************/ - } +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 = SiS_Pr->SiS_LCDVDES; /* VGAVDES */ - push1 = tempbx; + SiS_Pr->SiS_TVMode = 0; - tempax = SiS_Pr->SiS_VGAVDE; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; + if(SiS_Pr->UseCustomMode) return; - 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; - } + if(ModeNo > 0x13) { + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; } - tempbx += tempax; - if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; + if(HwInfo->jChipType < SIS_661) { - push2 = tempbx; + if(SiS_Pr->SiS_VBInfo & SetPALTV) SiS_Pr->SiS_TVMode |= TVSetPAL; - 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(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - tempcx = 0x0002; -#ifdef TWNEWPANEL - tempcx = 0x0003; -#endif - } else { - tempcx = 0x0002; /* A901; sometimes 0x0003; */ - } - } else tempcx = 0x0003; + 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 && SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { + 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) || - (SiS_Pr->SiS_IF_DEF_FSTN) || - (SiS_Pr->SiS_IF_DEF_DSTN)) { - 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(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750 | SetCRT2ToHiVision)) { + if(resinfo == SIS_RI_800x480 || resinfo == SIS_RI_1024x576 || resinfo == SIS_RI_1280x720) { + SiS_Pr->SiS_TVMode |= TVAspect169; + } else { + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x39); + if(temp1 & 0x02) { + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetHiVision)) { + SiS_Pr->SiS_TVMode |= TVAspect169; + } else { + SiS_Pr->SiS_TVMode |= TVAspect43LB; + } + } else { + SiS_Pr->SiS_TVMode |= TVAspect43; + } + } + } + } } - 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; 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)) && - (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( (HwDeviceExtension->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(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; - 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. */ - 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; + 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; + } + } } - } 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(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { - temp |= 0x80; + + 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; } - } 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; 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 */ +/*********************************************/ +/* GET LCD INFO */ +/*********************************************/ - if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) { - tempebx = 0x003F; - } +static USHORT +SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr) +{ + USHORT temp = SiS_Pr->SiS_LCDResInfo; + /* Translate my LCDResInfo to BIOS value */ + if(temp == Panel_1280x768_2) temp = Panel_1280x768; + if(temp == Panel_1280x768_3) temp = Panel_1280x768; + return temp; +} - temp = (USHORT)(tempebx & 0x00FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1E,temp); /* Part1_1Eh; Panel Link Vertical Scaling Factor */ +static void +SiS_GetLCDInfoBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ +#ifdef SIS315H + UCHAR *ROMAddr; + USHORT temp; + +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "Paneldata driver: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n", + SiS_Pr->PanelHT, SiS_Pr->PanelVT, + SiS_Pr->PanelHRS, SiS_Pr->PanelHRE, + SiS_Pr->PanelVRS, SiS_Pr->PanelVRE, + SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK, + SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A, + SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B); +#endif -#endif /* SIS300 */ + if((ROMAddr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { + if((temp = SISGETROMW(6)) != SiS_Pr->PanelHT) { + SiS_Pr->SiS_NeedRomModeData = TRUE; + SiS_Pr->PanelHT = temp; + } + if((temp = SISGETROMW(8)) != SiS_Pr->PanelVT) { + SiS_Pr->SiS_NeedRomModeData = TRUE; + SiS_Pr->PanelVT = temp; + } + SiS_Pr->PanelHRS = SISGETROMW(10); + SiS_Pr->PanelHRE = SISGETROMW(12); + SiS_Pr->PanelVRS = SISGETROMW(14); + SiS_Pr->PanelVRE = SISGETROMW(16); + SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315; + SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].CLOCK = + SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].CLOCK = (USHORT)((UCHAR)ROMAddr[18]); + SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2B = + SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_A = ROMAddr[19]; + SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2C = + SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_B = ROMAddr[20]; + +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "Paneldata BIOS: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n", + SiS_Pr->PanelHT, SiS_Pr->PanelVT, + SiS_Pr->PanelHRS, SiS_Pr->PanelHRE, + SiS_Pr->PanelVRS, SiS_Pr->PanelVRE, + SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK, + SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A, + SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B); +#endif - } else { + } +#endif +} -#ifdef SIS315H /* 315 series */ +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 }; - if(HwDeviceExtension->jChipType == SIS_740) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x03); - } else { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1E,0x23); - } - - 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; Panel Link Vertical Scaling Factor */ - temp = (USHORT)((tempebx & 0x00FF00) >> 8); - SiS_SetReg1(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_SetReg1(SiS_Pr->SiS_Part1Port,0x35,temp); /* Part1_35h; Panel Link Vertical Scaling Factor */ + SiS_Pr->SiS_LCDResInfo = 0; + SiS_Pr->SiS_LCDTypeInfo = 0; + SiS_Pr->SiS_LCDInfo = 0; + SiS_Pr->PanelHRS = 999; /* HSync start */ + SiS_Pr->PanelHRE = 999; /* HSync end */ + SiS_Pr->PanelVRS = 999; /* VSync start */ + SiS_Pr->PanelVRE = 999; /* VSync end */ + SiS_Pr->SiS_NeedRomModeData = FALSE; -#endif /* SIS315H */ + if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return; + 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; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; } - tempbx = push2; /* BPLVDEE */ - tempcx = push1; - - push1 = temp; + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); + if(!temp) return; - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(!SiS_Pr->SiS_IF_DEF_FSTN && !SiS_Pr->SiS_IF_DEF_DSTN) { - if(HwDeviceExtension->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++; - } - } - } + if((HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { + SiS_Pr->SiS_LCDTypeInfo = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x7c) >> 2; + } else if((HwInfo->jChipType < SIS_315H) || (HwInfo->jChipType >= SIS_661)) { + SiS_Pr->SiS_LCDTypeInfo = temp >> 4; + } else { + SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1; } - - 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; - } + temp &= 0x0f; + if(HwInfo->jChipType < SIS_315H) { + /* Translate 300 series LCDRes to 315 series for unified usage */ + temp = SiS300SeriesLCDRes[temp]; } - temp = ((tempbx & 0x0700) >> 8) << 3; - temp |= ((tempcx & 0x0700) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1D,temp); /* Part1_1Dh; Vertical Display Overflow; Control Signal */ - - temp = tempbx & 0x00FF; - /* if(SiS_Pr->SiS_IF_DEF_FSTN) temp++; */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1C,temp); /* Part1_1Ch; Panel Link Vertical Display Enable End */ + if(HwInfo->jChipType == SIS_550) { + if(temp == Panel310_640x480_2) temp = Panel_640x480_2; + if(temp == Panel310_640x480_3) temp = Panel_640x480_3; + } - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1B,temp); /* Part1_1Bh; Panel Link Vertical Display Enable Start */ + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* SiS LVDS */ + if(temp == Panel310_1280x768) { + temp = Panel_1280x768_2; +#ifdef SIS315H + if((myptr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { + if((myptr[8] | (myptr[9] << 8)) == 798) temp = Panel_1280x768_3; + } +#endif + } + } - /* 3. Additional horizontal setup (scaling, etc) */ + SiS_Pr->SiS_LCDResInfo = temp; - tempecx = SiS_Pr->SiS_VGAHDE; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { - 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_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; } } - tempecx = tempeax; - if(HwDeviceExtension->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; + 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 { - tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1; + if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMinLVDS) + SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMinLVDS; } - tempecx <<= 16; - tempecx |= (tempeax & 0xFFFF); - temp = (USHORT)(tempecx & 0x00FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1F,temp); /* Part1_1Fh; 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 { - 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; - } - - temp = ((tempbx & 0xFF00) >> 8) << 3; - temp |= (USHORT)((tempecx & 0x0700) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x20,temp); /* Part1_20h; Overflow register */ - - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x21,temp); /* Part1_21h; Panel Link Vertical Accumulator Register */ + SiS_Pr->PanelVCLKIdx300 = VCLK65_300; + SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; - tempecx >>= 16; /* BPLHCFACT */ - if((HwDeviceExtension->jChipType < SIS_315H) || (SiS_Pr->SiS_IF_DEF_FSTN) || (SiS_Pr->SiS_IF_DEF_DSTN)) { - if(modeflag & HalfDCLK) tempecx >>= 1; + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_320x480: SiS_Pr->PanelXRes = 320; SiS_Pr->PanelYRes = 480; + SiS_Pr->PanelHT = 400; SiS_Pr->PanelVT = 525; + SiS_Pr->PanelVCLKIdx300 = VCLK28; + SiS_Pr->PanelVCLKIdx315 = VCLK28; + break; + case Panel_640x480_2: + case Panel_640x480_3: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; + SiS_Pr->PanelVRS = 24; SiS_Pr->PanelVRE = 3; + SiS_Pr->PanelVCLKIdx300 = VCLK28; + SiS_Pr->PanelVCLKIdx315 = VCLK28; + break; + case Panel_640x480: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; + SiS_Pr->PanelVRE = 3; + SiS_Pr->PanelVCLKIdx300 = VCLK28; + SiS_Pr->PanelVCLKIdx315 = VCLK28; + break; + case Panel_800x600: SiS_Pr->PanelXRes = 800; SiS_Pr->PanelYRes = 600; + SiS_Pr->PanelHT = 1056; SiS_Pr->PanelVT = 628; + SiS_Pr->PanelHRS = 40; SiS_Pr->PanelHRE = 128; + SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 4; + SiS_Pr->PanelVCLKIdx300 = VCLK40; + SiS_Pr->PanelVCLKIdx315 = VCLK40; + break; + case Panel_1024x600: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 600; + SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 800; + SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; + SiS_Pr->PanelVRS = 2 /* 88 */ ; SiS_Pr->PanelVRE = 6; + SiS_Pr->PanelVCLKIdx300 = VCLK65_300; + SiS_Pr->PanelVCLKIdx315 = VCLK65_315; + break; + case Panel_1024x768: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; + SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; + SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; + SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; + if(HwInfo->jChipType < SIS_315H) { + SiS_Pr->PanelHRS = 23; + SiS_Pr->PanelVRE = 5; + } + SiS_Pr->PanelVCLKIdx300 = VCLK65_300; + SiS_Pr->PanelVCLKIdx315 = VCLK65_315; + SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + break; + case Panel_1152x768: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 768; + SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; + SiS_Pr->PanelHRS = 24; + SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; + if(HwInfo->jChipType < SIS_315H) { + SiS_Pr->PanelHRS = 23; + SiS_Pr->PanelVRE = 5; + } + SiS_Pr->PanelVCLKIdx300 = VCLK65_300; + SiS_Pr->PanelVCLKIdx315 = VCLK65_315; + break; + case Panel_1152x864: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 864; + break; + case Panel_1280x720: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 720; + SiS_Pr->PanelHT = 1650; SiS_Pr->PanelVT = 750; + SiS_Pr->PanelHRS = 110; SiS_Pr->PanelHRE = 40; + SiS_Pr->PanelVRS = 5; SiS_Pr->PanelVRE = 5; + SiS_Pr->PanelVCLKIdx315 = VCLK_1280x720; + /* Data above for TMDS (projector); get from BIOS for LVDS */ + SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + break; + case Panel_1280x768: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; + SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 802; + SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRS = 112; + SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; + SiS_Pr->PanelVCLKIdx300 = VCLK81_300; + SiS_Pr->PanelVCLKIdx315 = VCLK81_315; + break; + case Panel_1280x768_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; + SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 806; + SiS_Pr->PanelHRS = 16; SiS_Pr->PanelHRE = 64; + SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; + SiS_Pr->PanelVCLKIdx315 = VCLK_1280x768_2; + SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + break; + case Panel_1280x768_3: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; + SiS_Pr->PanelHT = 1664; SiS_Pr->PanelVT = 798; + SiS_Pr->PanelHRS = 64; SiS_Pr->PanelHRE = 128; + SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 7; + SiS_Pr->PanelVCLKIdx315 = VCLK_1280x768_3; + SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + break; + case Panel_1280x800: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800; + SiS_Pr->PanelHT = 1656; SiS_Pr->PanelVT = 841; /* 1408, 816 */ + SiS_Pr->PanelHRS = 32; SiS_Pr->PanelHRE = 312; /* 16, 64 */ + SiS_Pr->PanelVRS = 16; SiS_Pr->PanelVRE = 8; /* 4, 3 */ + SiS_Pr->PanelVCLKIdx315 = VCLK83_315; + SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + break; + case Panel_1280x960: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 960; + SiS_Pr->PanelHT = 1800; SiS_Pr->PanelVT = 1000; + SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300; + SiS_Pr->PanelVCLKIdx315 = VCLK108_3_315; + if(resinfo == SIS_RI_1280x1024) { + SiS_Pr->PanelVCLKIdx300 = VCLK100_300; + SiS_Pr->PanelVCLKIdx315 = VCLK100_315; + } + break; + case Panel_1280x1024: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 1024; + SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; + SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; + SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; + SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300; + SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; + SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + break; + case Panel_1400x1050: SiS_Pr->PanelXRes = 1400; SiS_Pr->PanelYRes = 1050; + SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; + SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; /* HRE OK for LVDS, not for LCDA */ + SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; + SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; + SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + break; + case Panel_1600x1200: SiS_Pr->PanelXRes = 1600; SiS_Pr->PanelYRes = 1200; + SiS_Pr->PanelHT = 2160; SiS_Pr->PanelVT = 1250; + SiS_Pr->PanelHRS = 64; SiS_Pr->PanelHRE = 192; + SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; + SiS_Pr->PanelVCLKIdx315 = VCLK162_315; + SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + break; + case Panel_1680x1050: SiS_Pr->PanelXRes = 1680; SiS_Pr->PanelYRes = 1050; + SiS_Pr->PanelHT = 1900; SiS_Pr->PanelVT = 1066; + SiS_Pr->PanelHRS = 26; SiS_Pr->PanelHRE = 76; + SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; + SiS_Pr->PanelVCLKIdx315 = VCLK121_315; + SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + break; + case Panel_Custom: SiS_Pr->PanelXRes = SiS_Pr->CP_MaxX; + SiS_Pr->PanelYRes = SiS_Pr->CP_MaxY; + SiS_Pr->PanelHT = SiS_Pr->CHTotal; + SiS_Pr->PanelVT = SiS_Pr->CVTotal; + if(SiS_Pr->CP_PreferredIndex != -1) { + SiS_Pr->PanelXRes = SiS_Pr->CP_HDisplay[SiS_Pr->CP_PreferredIndex]; + SiS_Pr->PanelYRes = SiS_Pr->CP_VDisplay[SiS_Pr->CP_PreferredIndex]; + SiS_Pr->PanelHT = SiS_Pr->CP_HTotal[SiS_Pr->CP_PreferredIndex]; + SiS_Pr->PanelVT = SiS_Pr->CP_VTotal[SiS_Pr->CP_PreferredIndex]; + SiS_Pr->PanelHRS = SiS_Pr->CP_HSyncStart[SiS_Pr->CP_PreferredIndex]; + SiS_Pr->PanelHRE = SiS_Pr->CP_HSyncEnd[SiS_Pr->CP_PreferredIndex]; + SiS_Pr->PanelVRS = SiS_Pr->CP_VSyncStart[SiS_Pr->CP_PreferredIndex]; + SiS_Pr->PanelVRE = SiS_Pr->CP_VSyncEnd[SiS_Pr->CP_PreferredIndex]; + SiS_Pr->PanelHRS -= SiS_Pr->PanelXRes; + SiS_Pr->PanelHRE -= SiS_Pr->PanelHRS; + SiS_Pr->PanelVRS -= SiS_Pr->PanelYRes; + SiS_Pr->PanelVRE -= SiS_Pr->PanelVRS; + } + break; + case Panel_Barco1366: SiS_Pr->PanelXRes = 1360; SiS_Pr->PanelYRes = 1024; + SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; + break; + case Panel_848x480: SiS_Pr->PanelXRes = 848; SiS_Pr->PanelYRes = 480; + SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525; + break; + default: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; + SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; + break; } - temp = (USHORT)((tempecx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x22,temp); /* Part1_22h; Panel Link Horizontal Scaling Factor High */ - temp = (USHORT)(tempecx & 0x00FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x23,temp); /* Part1_22h; Panel Link Horizontal Scaling Factor Low */ + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + SiS_Pr->SiS_LCDInfo = temp & ~0x000e; - /* 630/301B and 630/LVDS do something for 640x480 panels here */ + if(!(SiS_Pr->UsePanelScaler)) SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; + else if(SiS_Pr->UsePanelScaler == 1) SiS_Pr->SiS_LCDInfo |= DontExpandLCD; #ifdef SIS315H - if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) { - 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); - 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_SetReg1(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_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); - - 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_SetReg1(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_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; - 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_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 */ - 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_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,0x19,0x38); - - if(SiS_Pr->SiS_IF_DEF_FSTN) { - 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_SetReg1(SiS_Pr->SiS_Part1Port,0x35,0x0c); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x36,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x37,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x38,0x80); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x39,0xA0); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3a,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3b,0xf0); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3c,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3d,0x10); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3e,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3f,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x40,0x10); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x41,0x25); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x42,0x80); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x43,0x14); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x44,0x03); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x45,0x0a); + if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(temp & 0x08) SiS_Pr->SiS_LCDInfo |= LCDPass11; + } + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_ROMNew) { + if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink; + } else if((myptr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { + if(myptr[2] & 0x01) SiS_Pr->SiS_LCDInfo |= LCDDualLink; + } + } + } else if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x01) SiS_Pr->SiS_LCDInfo |= LCDPass11; + } + if((SiS_Pr->SiS_ROMNew) && (!(SiS_Pr->PanelSelfDetected))) { + SiS_Pr->SiS_LCDInfo &= ~(LCDRGB18Bit); + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + if(temp & 0x01) SiS_Pr->SiS_LCDInfo |= LCDRGB18Bit; + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink; + } } } -#endif /* SIS315H */ - -} - -#ifdef SIS315H -void -SiS_CRT2AutoThreshold(SiS_Private *SiS_Pr, USHORT BaseAddr) -{ - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40); -} #endif - -#ifdef SIS315H -/* For LVDS / 302B/30xLV - LCDA (this must only be called on 315 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 modeflag,resinfo; - USHORT push1,push2,tempax,tempbx,tempcx,temp; - ULONG tempeax=0,tempebx,tempecx,tempvcfact; - - /* This is not supported with LCDA */ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return; - if(SiS_Pr->UseCustomMode) return; - - 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, 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 */ + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + /* Always center screen on LVDS (if scaling is disabled) */ + SiS_Pr->SiS_LCDInfo &= ~LCDPass11; + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + /* Always center screen on SiS LVDS (if scaling is disabled) */ + SiS_Pr->SiS_LCDInfo &= ~LCDPass11; } else { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2D,0x0f); /* 650/30xLv 1.10.6s */ + /* By default, pass 1:1 on SiS TMDS (if scaling is disabled) */ + SiS_Pr->SiS_LCDInfo |= LCDPass11; + if(SiS_Pr->CenterScreen == 1) SiS_Pr->SiS_LCDInfo &= ~LCDPass11; } } - 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; - } - - tempax = SiS_Pr->SiS_LCDHDES; - tempbx = SiS_Pr->SiS_HDE; - tempcx = SiS_Pr->SiS_HT; - - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - tempbx = SiS_Pr->PanelXRes; + 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(D0 = 0) */ + } } - 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; - /* 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_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(modeflag & NoSupportLCDScale) { + /* No scaling for this mode on any panel */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_Custom: + /* For non-standard LCD resolution, we let the panel scale */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + break; + case Panel_1280x720: + if(SiS_Pr->PanelHT == 1650) { + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + case Panel_1280x768: /* TMDS only */ + /* No idea about the timing and zoom factors */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + break; + case Panel_1280x960: + SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; + break; + case Panel_1280x1024: + if(SiS_Pr->SiS_VBType & VB_SISTMDS) { + if(ModeNo == 0x7c || ModeNo == 0x7d || ModeNo == 0x7e || + ModeNo == 0x79 || ModeNo == 0x75 || ModeNo == 0x78 || + ModeNo == 0x14 || ModeNo == 0x15 || ModeNo == 0x16) { + /* We do not scale to 1280x720/800/960 (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; + } + } + break; + case Panel_1400x1050: + if(SiS_Pr->SiS_VBType & VB_SISTMDS) { + if(ModeNo == 0x7c || ModeNo == 0x7d || ModeNo == 0x7e || + ModeNo == 0x79 || ModeNo == 0x75 || ModeNo == 0x78 || + ModeNo == 0x14 || ModeNo == 0x15 || ModeNo == 0x16 || + ModeNo == 0x23 || ModeNo == 0x24 || ModeNo == 0x25) { + /* Do not scale to 1280x720/768/800/960 (B/C bridges only) */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + } + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(ModeNo == 0x79 || ModeNo == 0x75 || ModeNo == 0x78) { + if(SiS_Pr->UsePanelScaler == -1) { + /* Do not scale to 1280x720 by default (LVDS bridges) */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + } + } + if(ModeNo == 0x3a || ModeNo == 0x4d || ModeNo == 0x65) { + /* Do not scale to 1280x1024 (all bridges) */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + break; + case Panel_1600x1200: + if(SiS_Pr->SiS_VBType & VB_SISTMDS) { + /* No idea about the timing and zoom factors (C bridge only) */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + break; + } } } - 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 */ - - 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; - } - } +#ifdef SIS300 + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(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); } } } - 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 */ +#endif - tempcx >>= 3; /* BPLHDES */ - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,temp); /* Part1_16h */ + /* Special cases */ + if(SiS_Pr->SiS_IF_DEF_TRUMPION) { + SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11); + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(tempbx & 0x07) tempbx += 8; + if(SiS_Pr->SiS_LCDResInfo == Panel_640x480) { + SiS_Pr->SiS_LCDInfo |= LCDPass11; } - tempbx >>= 3; /* BPLHDEE */ - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,temp); /* Part1_17h */ - - 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) { - tempax = SiS_Pr->PanelYRes; - } else { - tempax = SiS_Pr->SiS_VGAVDE; + + if(SiS_Pr->UseCustomMode) { + SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11); } - tempbx += tempax; - tempax = SiS_Pr->SiS_VT; /* VT */ - if(tempbx >= tempax) tempbx -= tempax; - - push2 = tempbx; - - tempcx >>= 2; - - /* 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; - } + /* (In)validate LCDPass11 flag */ + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + SiS_Pr->SiS_LCDInfo &= ~LCDPass11; } - tempbx += tempcx; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - tempbx++; /* BPLVRS */ + /* Special cases */ + 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) ) { + SiS_Pr->PanelHRS = 999; + SiS_Pr->PanelHRE = 999; } - if(tempbx >= tempax) tempbx -= tempax; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,temp); /* Part1_18h */ - 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 { - /* 650/30xLV 1.10.6s, Xabre */ - temp |= 0xC0; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp); /* Part1_19h */ + if( (SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || + (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) { + SiS_Pr->PanelVRS = 999; + SiS_Pr->PanelVRE = 999; } - 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) { - /* 650/30xLV 1.10.6s */ - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) temp |= 0x80; +#ifdef SIS315H + if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { + if(!(SiS_Pr->SiS_ROMNew)) { + 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 == Panel_1024x768)) { + /* (Sets this in SenseLCD; new paneltypes) */ + SiS_Pr->SiS_LCDInfo |= LCDDualLink; + } + if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || + (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || + (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) || + (SiS_Pr->SiS_LCDResInfo == Panel_1680x1050)) { + SiS_Pr->SiS_LCDInfo |= LCDDualLink; + } } - } else { - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) temp |= 0x80; } } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x87,temp); /* Part1_1Ah */ - - tempbx = push2; /* BPLVDEE */ - tempcx = push1; /* NPLVDES */ - push1 = (USHORT)(tempeax & 0xFFFF); - - 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 = SiS_Pr->SiS_VGAVDE; - tempcx = tempbx; - tempbx--; - } - - temp = (tempbx & 0xFF00) >> 8; - temp &= 0x07; - temp <<= 3; - temp = temp | (((tempcx & 0xFF00) >> 8) & 0x07); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1D,temp); /* Part1_1Dh */ - - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1C,temp); /* Part1_1Ch */ - - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1B,temp); /* Part1_1Bh */ - - 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); - - temp = (USHORT)((tempebx & 0x00FF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x36,temp); - - temp = (USHORT)((tempebx & 0x00030000) >> 16); - if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x35,temp); - - 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 */ - - tempeax = SiS_Pr->SiS_VGAVDE; - tempeax <<= 18; - tempeax = tempeax / tempvcfact; - tempbx = (USHORT)(tempeax & 0x0FFFF); - - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx--; - - if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempbx = 1; - - temp = ((tempbx & 0xFF00) >> 8) << 3; - temp = temp | (USHORT)(((tempecx & 0x0000FF00) >> 8) & 0x07); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x20,temp); /* Part1_20h */ +#endif - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x21,temp); /* Part1_21h */ + if(!((HwInfo->jChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) { - tempecx >>= 16; /* BPLHCFACT */ - if(modeflag & HalfDCLK) tempecx >>= 1; - temp = (USHORT)((tempecx & 0x0000FF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x22,temp); /* Part1_22h */ + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { + if(ModeNo == 0x12) { + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } + } else if(ModeNo > 0x13) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x600) { + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + if((resinfo == SIS_RI_800x600) || (resinfo == SIS_RI_400x300)) { + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } + } + } + } + } + } - temp=(USHORT)(tempecx & 0x000000FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x23,temp); + if(modeflag & HalfDCLK) { + if(SiS_Pr->SiS_IF_DEF_TRUMPION == 1) { + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else if(SiS_Pr->SiS_LCDResInfo == Panel_640x480) { + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else if(ModeNo > 0x13) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + if(resinfo == SIS_RI_512x384) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else if(SiS_Pr->SiS_LCDResInfo == Panel_800x600) { + if(resinfo == SIS_RI_400x300) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } + } + } -#if 0 - /* 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 - /* 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); + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) { + SiS_Pr->SiS_SetFlag |= LCDVESATiming; + } + } else { + SiS_Pr->SiS_SetFlag |= LCDVESATiming; } +#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 } -#endif /* SIS 315 */ - -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_VBInfo & SetInSlaveMode) return; - - offset = SiS_GetOffset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || - SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) offset >>= 1; - - 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); -} +/*********************************************/ +/* GET VCLK */ +/*********************************************/ USHORT -SiS_GetOffset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { - USHORT temp,colordepth; - USHORT modeinfo,index,infoflag; + USHORT CRT2Index,VCLKIndex=0,VCLKIndexGEN=0; + USHORT modeflag,resinfo,tempbx; + const UCHAR *CHTVVCLKPtr = NULL; - if(SiS_Pr->UseCustomMode) { - infoflag = SiS_Pr->CInfoFlag; - temp = SiS_Pr->CHDisplay / 16; + 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; + VCLKIndexGEN = (SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)) >> 2) & 0x03; } else { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - modeinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeInfo; - index = (modeinfo >> 8) & 0xFF; - temp = SiS_Pr->SiS_ScreenOffset[index]; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + CRT2Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + VCLKIndexGEN = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + if(HwInfo->jChipType < SIS_315H) VCLKIndexGEN &= 0x3f; } - - colordepth = SiS_GetColorDepth(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex); - if(infoflag & InterlaceMode) temp <<= 1; + if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 30x/B/LV */ - temp *= colordepth; + if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - if( ( ((ModeNo >= 0x26) && (ModeNo <= 0x28)) || - ModeNo == 0x3f || - ModeNo == 0x42 || - ModeNo == 0x45 ) || - (SiS_Pr->UseCustomMode && (SiS_Pr->CHDisplay % 16)) ) { - colordepth >>= 1; - temp += colordepth; - } - - return(temp); -} + CRT2Index >>= 6; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* LCD */ -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) { + VCLKIndex = SiS_Pr->PanelVCLKIdx300; + } else { + VCLKIndex = SiS_Pr->PanelVCLKIdx315; + if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { + VCLKIndex = VCLKIndexGEN; + switch(resinfo) { + /* Only those whose IndexGEN doesn't match VBVCLK array: */ + case SIS_RI_1280x720: VCLKIndex = VCLK_1280x720; + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x720) { + if(SiS_Pr->PanelHT == 1344) { + VCLKIndex = VCLK_1280x720_2; + } + } + break; + case SIS_RI_720x480: VCLKIndex = VCLK_720x480; break; + case SIS_RI_720x576: VCLKIndex = VCLK_720x576; break; + case SIS_RI_768x576: VCLKIndex = VCLK_768x576; break; + case SIS_RI_848x480: VCLKIndex = VCLK_848x480; break; + case SIS_RI_856x480: VCLKIndex = VCLK_856x480; break; + case SIS_RI_800x480: VCLKIndex = VCLK_800x480; break; + case SIS_RI_1024x576: VCLKIndex = VCLK_1024x576; break; + case SIS_RI_1152x864: VCLKIndex = VCLK_1152x864; break; + case SIS_RI_1360x768: VCLKIndex = VCLK_1360x768; break; + } + + 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; + } + } + } - /* 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; - } + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */ - index = (modeflag & ModeInfoFlag) - ModeEGA; - if(index < 0) index = 0; - return(ColorDepth[index]); -} + 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; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) VCLKIndex = TVVCLKDIV2; + else if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = TVVCLKDIV2; + else VCLKIndex = TVVCLK; + + if(HwInfo->jChipType < SIS_315H) VCLKIndex += TVCLKBASE_300; + else VCLKIndex += TVCLKBASE_315; + + } else { /* VGA2 */ + + VCLKIndex = VCLKIndexGEN; + if(HwInfo->jChipType < SIS_315H) { + if(ModeNo > 0x13) { + if( (HwInfo->jChipType == SIS_630) && + (HwInfo->jChipRevision >= 0x30)) { + if(VCLKIndex == 0x14) VCLKIndex = 0x34; + } + /* Better VGA2 clock for 1280x1024@75 */ + if(VCLKIndex == 0x17) VCLKIndex = 0x45; + } + } + } -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; + } else { /* If not programming CRT2 */ - flag = 0; - tempbl = 0xC0; + VCLKIndex = VCLKIndexGEN; + if(HwInfo->jChipType < SIS_315H) { + if(ModeNo > 0x13) { + if( (HwInfo->jChipType != SIS_630) && + (HwInfo->jChipType != SIS_300) ) { + if(VCLKIndex == 0x1b) VCLKIndex = 0x35; + } + } + } + } - if(SiS_Pr->UseCustomMode) { - infoflag = SiS_Pr->CInfoFlag; - } else { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - } + } else { /* LVDS */ - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */ + VCLKIndex = CRT2Index; - 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(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - tempah &= 0xC0; + if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + 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]; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || - (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { - tempah |= 0xc0; - } - } + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - 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); - } + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex = SiS_Pr->PanelVCLKIdx300; + } else { + VCLKIndex = SiS_Pr->PanelVCLKIdx315; + } - } else { + /* Special Timing: Barco iQ Pro R series */ + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) VCLKIndex = 0x44; - if(HwDeviceExtension->jChipType < SIS_315H) { + /* Special Timing: 848x480 parallel lvds */ + 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 = ?; */ + } + } -#ifdef SIS300 /* ---- 300 series --- */ + } else { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 630 - 301B(-DH) */ + VCLKIndex = VCLKIndexGEN; + if(HwInfo->jChipType < SIS_315H) { + if(ModeNo > 0x13) { + if( (HwInfo->jChipType == SIS_630) && + (HwInfo->jChipRevision >= 0x30) ) { + if(VCLKIndex == 0x14) VCLKIndex = 0x2e; + } + } + } + } - 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; + } else { /* if not programming CRT2 */ + VCLKIndex = VCLKIndexGEN; + if(HwInfo->jChipType < SIS_315H) { + if(ModeNo > 0x13) { + if( (HwInfo->jChipType != SIS_630) && + (HwInfo->jChipType != SIS_300) ) { + if(VCLKIndex == 0x1b) VCLKIndex = 0x35; + } #if 0 - if (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - /* BIOS does something here @@@ */ - } + if(HwInfo->jChipType == SIS_730) { + if(VCLKIndex == 0x0b) VCLKIndex = 0x40; /* 1024x768-70 */ + if(VCLKIndex == 0x0d) VCLKIndex = 0x41; /* 1024x768-75 */ + } #endif + } + } - tempah &= 0x3f; - tempah |= tempbl; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + } - } else { /* 630 - 301 */ + } + +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "VCLKIndex %d (0x%x)\n", VCLKIndex, VCLKIndex); +#endif - tempah = infoflag >> 8; - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + return(VCLKIndex); +} - } +/*********************************************/ +/* SET CRT2 MODE TYPE REGISTERS */ +/*********************************************/ -#endif /* SIS300 */ +static void +SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT i,j,modeflag; + USHORT tempcl,tempah=0; +#if defined(SIS300) || defined(SIS315H) + USHORT tempbl; +#endif +#ifdef SIS315H + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT tempah2, tempbl2; +#endif - } else { + 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; + } + + /* 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 */ -#ifdef SIS315H /* ------- 315 series ------ */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* 315 - 30xLV */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xAF,0x40); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2E,0xF7); - if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { - tempah = infoflag >> 8; - if(SiS_Pr->SiS_LCDInfo & LCDSync) { - tempah = SiS_Pr->SiS_LCDInfo; - } - } else { - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37); - } - tempah &= 0xC0; + } else { - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + for(i=0,j=4; i<3; i++,j++) SiS_SetReg(SiS_Pr->SiS_Part1Port,j,0); + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0x7F); + } - } else { /* 315 - 301, 301B */ + tempcl = SiS_Pr->SiS_ModeType; - 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 0 - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - /* BIOS does something here @@@ */ - } -#endif + if(HwInfo->jChipType < SIS_315H) { - 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); +#ifdef SIS300 /* ---- 300 series ---- */ - } - -#endif /* SIS315H */ - } - } -} + /* For 301BDH: (with LCD via LVDS) */ + if(SiS_Pr->SiS_VBType & VB_NoLCD) { + tempbl = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32); + tempbl &= 0xef; + tempbl |= 0x02; + if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) || (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + tempbl |= 0x10; + tempbl &= 0xfd; + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,tempbl); + } -/* 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) -{ - 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 - }; - - SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate; + if(ModeNo > 0x13) { + tempcl -= ModeVGA; + if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */ + tempah = ((0x10 >> tempcl) | 0x80); + } + } else tempah = 0x80; - 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); + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0; - if(CRT1ModeNo >= 0x13) { - index = SiS_Pr->SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK; - index &= 0x3F; - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ +#endif /* SIS300 */ + + } else { + +#ifdef SIS315H /* ------- 315/330 series ------ */ + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x08); + } + } + + 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; + + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50; + +#endif /* SIS315H */ - colorth = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT1ModeNo,modeidindex); /* Get colordepth */ - colorth >>= 1; - if(!colorth) colorth++; } - } else { - - 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(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; + + 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); + } + } } - } + if(SiS_Pr->SiS_VBType & VB_SISVB) { - 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 */ + 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; + } + } - data2 = (colorth * VCLK) / MCLK; + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - temp = ((temp & 0x00FF) >> 6) << 1; - if(temp == 0) temp = 1; - temp <<= 2; - temp &= 0xff; + if(HwInfo->jChipType < SIS_315H) { - data2 = temp - data2; - - if((28 * 16) % data2) { - data2 = (28 * 16) / data2; - data2++; - } else { - data2 = (28 * 16) / data2; - } + tempah = (tempah << 5) & 0xFF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); + tempah = (tempah >> 5) & 0xFF; - if(HwDeviceExtension->jChipType == SIS_300) { + } 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; - tempal = ThLowB[tempbx + 1]; - tempal *= tempcl; - tempal += ThLowB[tempbx]; - data = tempal; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF8,tempah); - } 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; - -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x800000A0); - eax = SiS_GetReg3(0xcfc); -#else - eax = pciReadLong(0x00000000, 0xA0); -#endif - temp = (USHORT)(eax >> 28); - temp &= 0x0F; - tempal |= temp; - - 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 { - - index = 0; - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - if(temp & 0x0080) index += 12; - -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x800000A0); - eax = SiS_GetReg3(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 - temp = (USHORT)(eax >> 24); - if(!(temp&0x01)) index += 24; - -#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; + } - temp = (temp & 0x0F) >> 1; - index += temp; - - data = LatencyFactor[index]; - data += 15; - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - if(!(temp & 0x80)) data += 5; - } - - data += data2; /* CRT1 Request Period */ - - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; + if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { + tempah |= 0x10; + } - if(!SiS_Pr->UseCustomMode) { + if((HwInfo->jChipType < SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301)) { + if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || + (SiS_Pr->SiS_LCDResInfo == Panel_1280x960)) { + tempah |= 0x80; + } + } else { + tempah |= 0x80; + } - CRT2ModeNo = ModeNo; - SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT2ModeNo,&modeidindex); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p))) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + tempah |= 0x20; + } + } + } - refreshratetableindex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT2ModeNo, - modeidindex,HwDeviceExtension); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah); - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,CRT2ModeNo,modeidindex, - refreshratetableindex,HwDeviceExtension); - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ + tempah = 0; - 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); - } - } - } + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempah |= 0x40; - } else { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) { + tempah |= 0x40; + } + } - CRT2ModeNo = 0xfe; - VCLK = SiS_Pr->CSRClock; /* Get VCLK */ + if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || + (SiS_Pr->SiS_LCDResInfo == Panel_1280x960) || + ((SiS_Pr->SiS_LCDResInfo == Panel_Custom) && + (SiS_Pr->CP_MaxX >= 1280) && (SiS_Pr->CP_MaxY >= 960))) { + tempah |= 0x80; + } - } + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0C,tempah); - colorth = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT2ModeNo,modeidindex); /* Get colordepth */ - colorth >>= 1; - if(!colorth) colorth++; + } else { /* LVDS */ - data = data * VCLK * colorth; - if(data % (MCLK << 4)) { - data = data / (MCLK << 4); - data++; - } else { - data = data / (MCLK << 4); - } - - if(data <= 6) data = 6; - if(data > 0x14) data = 0x14; + if(HwInfo->jChipType >= SIS_315H) { - 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); + /* 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( (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; - - } -} -#endif + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + tempah |= 0x02; + } -/* Set FIFO on 315/330 series */ -#ifdef SIS315H -void -SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ -#if 0 /* This code is obsolete */ - 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; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tempah ^= 0x01; + } - SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate; -#endif + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { + tempah = 1; + } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x01,0x3B); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah); -#if 0 - if(!SiS_Pr->CRT1UsesCustomMode) { - - CRT1ModeNo = SiS_Pr->SiS_CRT1Mode; /* get CRT1 ModeNo */ - SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT1ModeNo,&ModeIdIndex); + } else { - SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); - SiS_Pr->SiS_SelectCRT2Rate = 0; + tempah = 0; + if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { + tempah |= 0x02; + } + tempah <<= 5; - /* Get REFIndex for crt1 refreshrate */ - RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT1ModeNo, - ModeIdIndex,HwDeviceExtension); - index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - tempax = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; - tempbx = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT1ModeNo,ModeIdIndex); /* Get colordepth */ - tempbx >>= 1; - if(!tempbx) tempbx++; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); - } else { + } - CRT1ModeNo = 0xfe; - tempax = SiS_Pr->CSRClock_CRT1; /* Get VCLK */ - tempbx = (SiS_Pr->CModeFlag_CRT1 & 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; } - - } - - tempax *= tempbx; - tempbx = SiS_GetMCLK(SiS_Pr,ROMAddr, HwDeviceExtension); /* Get MCLK */ + } /* LCDA */ - tempax /= tempbx; + if(SiS_Pr->SiS_VBType & VB_SISVB) { - tempbx = tempax; + if(HwInfo->jChipType >= SIS_315H) { - tempax = 16; +#ifdef SIS315H - tempax -= tempbx; + unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); - tempbx = tempax; /* tempbx = 16-DRamBus - DCLK*BytePerPixel/MCLK */ + /* 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...? + */ - tempax = ((52 * 16) / tempbx); + /* 740 variants match for 30xB, 301B-DH, 30xLV */ - if ((52*16 % tempbx) != 0) { - tempax++; - } - tempcx = tempax; - tempcx += 40; + 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); + } - /* 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 */ + /* 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? + */ - for (temp3 = 0; temp3 < 16; temp3 += 2) { - if ((CombCode[temp3] == tempcl) && (CombCode[temp3+1] == tempch)) { - temp3 = CRT2ThLow[temp3 >> 1]; - } - } + if((IS_SIS740) || (HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { + tempah = 0x30; + tempbl = 0xc0; + if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || + ((SiS_Pr->SiS_ROMNew) && (!(ROMAddr[0x5b] & 0x04)))) { + 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); + } - tempcx += temp3; /* CRT1 Request Period */ + 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); + } + +#if 0 + if(SiS_Pr->SiS_VBType & VB_SIS301C) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x3a,0xc0); + } +#endif - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; +#endif /* SIS315H */ - if(!SiS_Pr->UseCustomMode) { + } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - CRT2ModeNo = ModeNo; /* get CRT2 ModeNo */ - SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT2ModeNo,&ModeIdIndex); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); - RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT2ModeNo, - ModeIdIndex,HwDeviceExtension); + 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); + } - 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 */ - } else { - tempax = SiS_Pr->SiS_VBVCLKData[index].CLOCK; } - } else { + } else { /* LVDS */ - CRT2ModeNo = 0xfe; /* Get VCLK */ - tempax = SiS_Pr->CSRClock; +#ifdef SIS315H + if(HwInfo->jChipType >= SIS_315H) { - } + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - tempbx = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT2ModeNo,ModeIdIndex); /* Get colordepth */ - tempbx >>= 1; - if(!tempbx) tempbx++; + 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); - tempax *= tempbx; + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); + } - tempax *= tempcx; + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); - tempbx = SiS_GetMCLK(SiS_Pr,ROMAddr, HwDeviceExtension); /* Get MCLK */ - tempbx <<= 4; + } else if(HwInfo->jChipType == SIS_550) { - tempcx = tempax; - tempax /= tempbx; - if(tempcx % tempbx) tempax++; /* CRT1 Request period * TCLK * BytePerPixel / (MCLK*16) */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); - if (tempax > 0x37) tempax = 0x37; + } - /* 650/LVDS, 650/301LV, 740, 330 overrule calculated value; 315 does not */ - if(HwDeviceExtension->jChipType >= SIS_650) { - tempax = 0x04; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,~0x3F,tempax); -#else + } +#endif - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,~0x3F,0x04); + } -#endif } +/*********************************************/ +/* GET RESOLUTION DATA */ +/*********************************************/ + USHORT -SiS_GetMCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex) { - USHORT index; - - 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); - } + if(ModeNo <= 0x13) return((USHORT)SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo); + else return((USHORT)SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO); } -#endif - -/* 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, - USHORT BaseAddr) +static void +SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { - USHORT modeflag; - USHORT PanelIndex,ResIndex; - const SiS_LVDSDesStruct *PanelDesPtr = NULL; + USHORT xres,yres,modeflag=0,resindex; - 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; + if(SiS_Pr->UseCustomMode) { + xres = SiS_Pr->CHDisplay; + if(SiS_Pr->CModeFlag & HalfDCLK) xres *= 2; + SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; + yres = SiS_Pr->CVDisplay; + if(SiS_Pr->CModeFlag & DoubleScanMode) yres *= 2; + SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; return; } - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - -#ifdef SIS315H - SiS_GetLVDSDesPtrA(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &PanelIndex,&ResIndex, HwDeviceExtension, BaseAddr); - - switch (PanelIndex) - { - case 0: PanelDesPtr = SiS_Pr->LVDS1024x768Des_1; break; /* --- expanding --- */ - case 1: PanelDesPtr = SiS_Pr->LVDS1280x1024Des_1; break; - case 2: PanelDesPtr = SiS_Pr->LVDS1400x1050Des_1; break; - case 3: PanelDesPtr = SiS_Pr->LVDS1600x1200Des_1; break; - case 4: PanelDesPtr = SiS_Pr->LVDS1024x768Des_2; break; /* --- non expanding --- */ - 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; - default: PanelDesPtr = SiS_Pr->LVDS1024x768Des_1; break; - } -#endif + 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 { - - SiS_GetLVDSDesPtr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &PanelIndex,&ResIndex,HwDeviceExtension); - - switch (PanelIndex) - { - case 0: PanelDesPtr = SiS_Pr->SiS_PanelType00_1; break; /* --- */ - case 1: PanelDesPtr = SiS_Pr->SiS_PanelType01_1; break; - case 2: PanelDesPtr = SiS_Pr->SiS_PanelType02_1; break; - case 3: PanelDesPtr = SiS_Pr->SiS_PanelType03_1; break; - case 4: PanelDesPtr = SiS_Pr->SiS_PanelType04_1; break; - case 5: PanelDesPtr = SiS_Pr->SiS_PanelType05_1; break; - case 6: PanelDesPtr = SiS_Pr->SiS_PanelType06_1; break; - case 7: PanelDesPtr = SiS_Pr->SiS_PanelType07_1; break; - case 8: PanelDesPtr = SiS_Pr->SiS_PanelType08_1; break; - case 9: PanelDesPtr = SiS_Pr->SiS_PanelType09_1; break; - case 10: PanelDesPtr = SiS_Pr->SiS_PanelType0a_1; break; - case 11: PanelDesPtr = SiS_Pr->SiS_PanelType0b_1; break; - case 12: PanelDesPtr = SiS_Pr->SiS_PanelType0c_1; break; - case 13: PanelDesPtr = SiS_Pr->SiS_PanelType0d_1; break; - case 14: PanelDesPtr = SiS_Pr->SiS_PanelType0e_1; break; - case 15: PanelDesPtr = SiS_Pr->SiS_PanelType0f_1; break; - case 16: PanelDesPtr = SiS_Pr->SiS_PanelType00_2; break; /* --- */ - case 17: PanelDesPtr = SiS_Pr->SiS_PanelType01_2; break; - case 18: PanelDesPtr = SiS_Pr->SiS_PanelType02_2; break; - case 19: PanelDesPtr = SiS_Pr->SiS_PanelType03_2; break; - case 20: PanelDesPtr = SiS_Pr->SiS_PanelType04_2; break; - case 21: PanelDesPtr = SiS_Pr->SiS_PanelType05_2; break; - case 22: PanelDesPtr = SiS_Pr->SiS_PanelType06_2; break; - case 23: PanelDesPtr = SiS_Pr->SiS_PanelType07_2; break; - case 24: PanelDesPtr = SiS_Pr->SiS_PanelType08_2; break; - case 25: PanelDesPtr = SiS_Pr->SiS_PanelType09_2; break; - case 26: PanelDesPtr = SiS_Pr->SiS_PanelType0a_2; break; - case 27: PanelDesPtr = SiS_Pr->SiS_PanelType0b_2; break; - case 28: PanelDesPtr = SiS_Pr->SiS_PanelType0c_2; break; - case 29: PanelDesPtr = SiS_Pr->SiS_PanelType0d_2; break; - case 30: PanelDesPtr = SiS_Pr->SiS_PanelType0e_2; break; - case 31: PanelDesPtr = SiS_Pr->SiS_PanelType0f_2; break; - case 32: PanelDesPtr = SiS_Pr->SiS_PanelTypeNS_1; break; /* pass 1:1 */ - case 33: PanelDesPtr = SiS_Pr->SiS_PanelTypeNS_2; break; - case 50: PanelDesPtr = SiS_Pr->SiS_CHTVUNTSCDesData; break; /* TV */ - case 51: PanelDesPtr = SiS_Pr->SiS_CHTVONTSCDesData; break; - 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; - } + xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; + yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; } - SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES; - SiS_Pr->SiS_LCDVDES = (PanelDesPtr+ResIndex)->LCDVDES; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD){ - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - if(!(modeflag & HalfDCLK)) { - SiS_Pr->SiS_LCDHDES = 632; - } + 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; } - } 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(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - if(HwDeviceExtension->jChipType < SIS_315H) { - if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 320; - } else { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) - SiS_Pr->SiS_LCDHDES = 480; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) - SiS_Pr->SiS_LCDHDES = 804; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) - SiS_Pr->SiS_LCDHDES = 704; - if(!(modeflag & HalfDCLK)) { - SiS_Pr->SiS_LCDHDES = 320; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) - SiS_Pr->SiS_LCDHDES = 632; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) - SiS_Pr->SiS_LCDHDES = 542; - } - } - } - } - } + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x3a) & 0x01) { + if(ModeNo == 0x12) yres = 400; } } - } -} - -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(modeflag & HalfDCLK) xres *= 2; + if(modeflag & DoubleScanMode) yres *= 2; - 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 & SetCRT2ToTV) { - tempbx = 50; - if((SiS_Pr->SiS_VBInfo & SetPALTV) && (!SiS_Pr->SiS_CHPALM)) tempbx += 2; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - /* 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++; - } - } - /* 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++; - } - } - } + if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { - *PanelIndex = tempbx; - *ResIndex = tempal & 0x1F; -} - -#ifdef SIS315H -void -SiS_GetLVDSDesPtrA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *PanelIndex,USHORT *ResIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ - USHORT tempbx=0,tempal; +#if 0 + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCDA | SetCRT2ToLCD | SetCRT2ToHiVision)) { + if(xres == 720) xres = 640; + } +#endif - 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_VBInfo & SetCRT2ToLCD) { + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_1024x768: + 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; + } + } + break; + case Panel_1280x1024: + 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; + } + break; + case Panel_1600x1200: + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + if(yres == 1024) yres = 1056; + } + break; + } + } - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 4; + } else { - if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(SiS_IsDualLink(SiS_Pr, HwDeviceExtension, BaseAddr)) { - tempbx = 80; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVision)) { + if(xres == 720) xres = 640; } + } 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; +} - if(ModeNo <= 0x13) - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - else - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; +/*********************************************/ +/* GET CRT2 TIMING DATA */ +/*********************************************/ - *PanelIndex = tempbx; - *ResIndex = tempal & 0x1F; -} -#endif +static BOOLEAN +SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, USHORT *ResIndex, + USHORT *DisplayType) + { + USHORT modeflag=0; -void -SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT BaseAddr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT i,j,modeflag; - USHORT tempcl,tempah=0; -#ifdef SIS300 - USHORT temp; -#endif -#ifdef SIS315H - USHORT tempbl; -#endif + 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; + (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; } else { - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; } - - /* 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_VBInfo & SetCRT2ToLCDA) { - /* 1. for LVDS/302B/302LV **LCDA** */ - - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xAF,0x40); /* FUNCTION CONTROL */ - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2E,0xF7); + (*ResIndex) &= 0x3F; + if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { + (*DisplayType) = 18; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + (*DisplayType) += 2; + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) (*DisplayType) = 99; + } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + (*DisplayType) = 18; /* PALM uses NTSC data */ + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++; + } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { + (*DisplayType) = 20; /* PALN uses PAL data */ + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++; + } + } } else { + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_640x480: (*DisplayType) = 50; break; + case Panel_640x480_2: (*DisplayType) = 52; break; + case Panel_640x480_3: (*DisplayType) = 54; break; + case Panel_800x600: (*DisplayType) = 0; break; + case Panel_1024x600: (*DisplayType) = 23; break; + case Panel_1024x768: (*DisplayType) = 4; break; + case Panel_1152x768: (*DisplayType) = 27; break; + case Panel_1280x768: (*DisplayType) = 40; break; + case Panel_1280x1024: (*DisplayType) = 8; break; + case Panel_1400x1050: (*DisplayType) = 14; break; + case Panel_1600x1200: (*DisplayType) = 36; break; + default: return FALSE; + } + + if(modeflag & HalfDCLK) (*DisplayType)++; + + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_640x480: + case Panel_640x480_2: + case Panel_640x480_3: + break; + default: + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) (*DisplayType) += 2; + } - for(i=0,j=4; i<3; i++,j++) SiS_SetReg1(SiS_Pr->SiS_Part1Port,j,0); - - tempcl = SiS_Pr->SiS_ModeType; - - if(HwDeviceExtension->jChipType < SIS_315H) { - -#ifdef SIS300 /* ---- 300 series ---- */ - - /* For 301BDH: (with LCD via LVDS) */ - 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); - } - - if(ModeNo > 0x13) { - tempcl -= ModeVGA; - if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */ - tempah = ((0x10 >> tempcl) | 0x80); - } - } else tempah = 0x80; - - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0; - -#endif /* SIS300 */ - - } else { - -#ifdef SIS315H /* ------- 315/330 series ------ */ - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & CRT2DisplayFlag) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x08); - } - } - - 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; - - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50; - -#endif /* SIS315H */ - - } - - if(SiS_Pr->SiS_VBInfo & CRT2DisplayFlag) tempah = 0; - - 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_LCDInfo & LCDPass11) { + (*DisplayType) = 12; + if(modeflag & HalfDCLK) (*DisplayType)++; + } + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { +#if 0 + if(SiS_Pr->SiS_IF_DEF_FSTN) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){ + (*DisplayType) = 22; + } + } +#endif - /* 2. for 301 (301B, 302B 301LV, 302LV non-LCDA) */ + return TRUE; +} - 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; - } - } +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,resinfo=0; - if(SiS_Pr->SiS_VBInfo & CRT2DisplayFlag) tempah = 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(HwDeviceExtension->jChipType < SIS_315H) { + if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_IF_DEF_LVDS == 0)) { - /* ---- 300 series ---- */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */ - tempah = (tempah << 5) & 0xFF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x01,tempah); - tempah = (tempah >> 5) & 0xFF; + tempbx = SiS_Pr->SiS_LCDResInfo; + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx += 32; + + if(SiS_Pr->SiS_LCDResInfo == Panel_1680x1050) { + if (resinfo == SIS_RI_1280x800) tempal = 9; + else if(resinfo == SIS_RI_1400x1050) tempal = 11; + } + + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { /* Pass 1:1 only (center-screen handled outside) */ + tempbx = 100; + if(ModeNo >= 0x13) { + tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS; + if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes == 1280) && + (SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 768)) { + /* Special for Fujitsu 7911 (VL-17WDX8), others custom */ + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x768) tempal = 0x08; + else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x768_2) tempal = 0x0f; + else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x768_3) tempal = 0x10; + } + } + } - } else { +#ifdef SIS315H + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + tempbx = 200; + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++; + } + } + } +#endif - /* ---- 315 series ---- */ + } else { /* TV */ - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF8,tempah); + 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; + } - } + } - if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { - tempah |= 0x10; - } + tempal &= 0x3F; - if((HwDeviceExtension->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(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_TVMode & (TVSetPAL | TVSetPALN)) { + if(resinfo == SIS_RI_720x480) tempal = 9; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { + if(resinfo == SIS_RI_1024x768) tempal = 8; + } + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { + if((resinfo == SIS_RI_720x576) || + (resinfo == SIS_RI_768x576)) { + tempal = 8; + } + if(resinfo == SIS_RI_1280x720) tempal = 9; + } + } } + } - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(!(SiS_Pr->SiS_HiVision & 0x03)) { - tempah |= 0x20; - } - } - } + *CRT2Index = tempbx; + *ResIndex = tempal; - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah); + } else { /* LVDS, 301B-DH (if running on LCD) */ - 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; - } + tempbx = 0; + if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { + 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; } - } - - /* For 302LV dual-channel */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_IsDualLink(SiS_Pr, HwDeviceExtension, BaseAddr)) - tempah |= 0x40; + 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; } + } + } else { + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_640x480: tempbx = 6; break; + case Panel_640x480_2: tempbx = 30; break; + case Panel_640x480_3: tempbx = 30; break; + case Panel_800x600: tempbx = 0; break; + case Panel_1024x600: tempbx = 15; break; + case Panel_1024x768: tempbx = 2; break; + case Panel_1152x768: tempbx = 17; break; + case Panel_1280x768: tempbx = 18; break; + case Panel_1280x1024: tempbx = 4; break; + case Panel_1400x1050: tempbx = 8; break; + case Panel_1600x1200: tempbx = 21; break; + case Panel_Barco1366: tempbx = 80; break; } - 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; + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_640x480: + case Panel_640x480_2: + case Panel_640x480_3: + break; + default: + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; } - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0C,tempah); + if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempbx = 7; - } else { + if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { + tempbx = 82; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { + tempbx = 84; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } - /* 3. for LVDS */ + } - if(HwDeviceExtension->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_SetFlag & SetDOSMode) { + if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) tempal = 7; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) tempal++; + } + } - /* 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; - } - } + (*CRT2Index) = tempbx; + (*ResIndex) = tempal & 0x1F; + } +} - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - tempah |= 0x02; - } +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; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - tempah ^= 0x01; - } + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - tempah = 1; - } + if(ModeNo <= 0x13) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah); + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + index = SiS_GetModePtr(SiS_Pr,ModeNo,ModeIdIndex); - } else { + tempax = SiS_Pr->SiS_StandTable[index].CRTC[0]; + tempbx = SiS_Pr->SiS_StandTable[index].CRTC[6]; + temp1 = SiS_Pr->SiS_StandTable[index].CRTC[7]; - /* (added ModeType check) */ - tempah = 0; - if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { - tempah |= 0x02; - } - tempah <<= 5; + } else { - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x01,tempah); + 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; } - /* Inserted the entire following section */ - - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + if(modeflag & Charx8Dot) tempax *= 8; + else tempax *= 9; - if(HwDeviceExtension->jChipType >= SIS_315H) { + if(modeflag & HalfDCLK) tempax <<= 1; -#ifdef SIS315H + tempbx++; - unsigned char bridgerev = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x01);; + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = tempbx; +} - /* 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...? - */ +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; - /* 740 variants match for 30xB, 301B-DH, 30xLV */ + SiS_GetCRT2ResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - 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(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; + } - /* 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); the b1 version in a - * 650 box (Jake). What is the criteria? - */ + if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - 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 if(SiS_Pr->SiS_VBType & VB_SIS301) { - /* Fixes "TV-blue-bug" on 315+301 */ - 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 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (bridgerev == 0xb0)) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xCF,0x30); /* For 30xB-DH rev b0 (or "DH on 651"?) */ - } else { - tempah = 0x30; /* For 30xB (and 301BDH rev b1) */ - tempbl = 0xcf; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempah = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) { - tempbl = 0xff; +#ifdef SIS315H + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + if(SiS_Pr->UseCustomMode) { + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->CHTotal; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal; + } else { + if(ModeNo < 0x13) { + ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS; + /* Special for our 3 types, others custom (works with default) */ + if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes == 1280) && + (SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 768)) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x768) ResIndex = 0x08; + else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x768_2) ResIndex = 0x0f; + else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x768_3) ResIndex = 0x10; + } + /* Special for 1280x720 TMDS <> LVDS */ + if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes == 1280) && + (SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 720)) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x720) { + if(SiS_Pr->PanelHT == 1344) ResIndex = 0x12; + } + } } + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAHT; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAVT; + SiS_Pr->SiS_HT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDHT; + SiS_Pr->SiS_VT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDVT; } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah); + } else { + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->PanelVT; } - - 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) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,0xc0); /* For 30xLV */ - } else if((SiS_Pr->SiS_VBType & VB_NoLCD) && (bridgerev == 0xb0)) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,0xc0); /* For 30xB-DH rev b0 (or "DH on 651"? */ - } else { - tempah = 0xc0; /* For 301, 301B (and 301BDH rev b1) */ - 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); - } - - 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); - } - -#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 { + /* This handles custom modes and custom panels */ + SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; + SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; + SiS_Pr->SiS_HT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VT = SiS_Pr->PanelVT; + SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT - (SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE); + SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT - (SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE); } - } else { /* LVDS */ - -#ifdef SIS315H - if(HwDeviceExtension->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, HwDeviceExtension, BaseAddr)) { - tempbl = 0xff; - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); - - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x00); - } - - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xcf,0x30); - - } else if(HwDeviceExtension->jChipType == SIS_550) { + SiS_CalcLCDACRT1Timing(SiS_Pr,ModeNo,ModeIdIndex); -#if 0 - tempah = 0x00; - tempbl = 0xfb; - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - tempah = 0x00; - tempbl = 0xfb; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); -#endif - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); - - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xcf,0x30); - } - - } #endif - } - -} - -void -SiS_GetCRT2Data(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - - SiS_GetCRT2DataLVDS(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } else { - - if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_VBType & VB_NoLCD) ) { - - /* Need LVDS Data for LCD on 301B-DH */ - SiS_GetCRT2DataLVDS(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - - } else { - - SiS_GetCRT2Data301(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } - - } - - } else { - - SiS_GetCRT2Data301(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } - - } else { - - SiS_GetCRT2DataLVDS(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } -} - -/* Checked with 650/LVDS 1.10.07 BIOS */ -void -SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - 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; - } - - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - -#ifdef SIS315H - SiS_GetCRT2PtrA(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex); - - 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 - } else { /* 301BDH needs LVDS Data */ - if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_VBType & VB_NoLCD) ) { - SiS_Pr->SiS_IF_DEF_LVDS = 1; + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + SiS_Pr->SiS_IF_DEF_LVDS = 1; } - SiS_GetCRT2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex,HwDeviceExtension); + SiS_GetCRT2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + &CRT2Index, &ResIndex, HwInfo); /* 301BDH needs LVDS Data */ - if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_VBType & VB_NoLCD) ) { - SiS_Pr->SiS_IF_DEF_LVDS = 0; + 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_IF_DEF_LVDS == 0) { - - if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; - SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; - } - - } else { + case 0: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break; + case 1: LVDSData = SiS_Pr->SiS_LVDS800x600Data_2; break; + case 2: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; + case 3: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_2; break; + case 4: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_1; 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_LVDS1024x600Data_2; break; + case 17: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_1; 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; + } - 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; - } - } -#if 0 - if(SiS_Pr->SiS_IF_DEF_FSTN) { - SiS_Pr->SiS_HDE = 320; - SiS_Pr->SiS_VDE = 480; - } -#endif - } - } - } - } - } + 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_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { + 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; + } + } + } + } + } + } } -void -SiS_GetCRT2Data301(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, +static void +SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) + PSIS_HW_INFO HwInfo) { - USHORT tempax,tempbx,modeflag; - USHORT resinfo; - USHORT CRT2Index,ResIndex; + UCHAR *ROMAddr = NULL; + USHORT tempax,tempbx,modeflag,romptr=0; + USHORT resinfo,CRT2Index,ResIndex; const SiS_LCDDataStruct *LCDPtr = NULL; const SiS_TVDataStruct *TVPtr = NULL; +#ifdef SIS315H + SHORT resinfo661; +#endif 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 { - 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; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; +#ifdef SIS315H + resinfo661 = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].ROMMODEIDX661; + if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && + (SiS_Pr->SiS_SetFlag & LCDVESATiming) && + (resinfo661 >= 0) && + (SiS_Pr->SiS_NeedRomModeData) ) { + if((ROMAddr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { + if((romptr = (SISGETROMW(21)))) { + romptr += (resinfo661 * 10); + ROMAddr = HwInfo->pjVirtualRomBase; + } + } } +#endif } SiS_Pr->SiS_NewFlickerMode = 0; @@ -3558,7 +3222,7 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT Mode SiS_Pr->SiS_RY3COE = 0; SiS_Pr->SiS_RY4COE = 0; - SiS_GetCRT2ResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); + SiS_GetCRT2ResInfo(SiS_Pr,ModeNo,ModeIdIndex,HwInfo); if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){ @@ -3575,104 +3239,115 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT Mode } else { - SiS_GetRAMDAC2DATA(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); + SiS_GetRAMDAC2DATA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + } } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_GetCRT2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex,HwDeviceExtension); - - 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; /* Just to avoid a crash */ - } + SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, + &CRT2Index,&ResIndex,HwInfo); + + 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; + } - 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_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - - if(SiS_Pr->SiS_HiVision != 3) { - if(resinfo == SIS_RI_1024x768) SiS_Pr->SiS_NewFlickerMode = 0x40; - if(resinfo == SIS_RI_1280x1024) SiS_Pr->SiS_NewFlickerMode = 0x40; - if(resinfo == SIS_RI_1280x720) 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; - } - } - } - } + if((resinfo == SIS_RI_1024x768) || + (resinfo == SIS_RI_1280x1024) || + (resinfo == SIS_RI_1280x720)) { + SiS_Pr->SiS_NewFlickerMode = 0x40; + } - } else { + if(SiS_Pr->SiS_VGAVDE == 350) SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; + + 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 + } + } - 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; + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - 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 & 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; + } - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - SiS_Pr->SiS_HT = NTSCHT; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if((ModeNo == 0x64) || (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; - } + } else { - } + 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; + } + + } } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; + 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; @@ -3681,59 +3356,86 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT Mode SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; } else { + + BOOLEAN gotit = FALSE; - SiS_GetCRT2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex,HwDeviceExtension); - - 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 */ + if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { + + SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; + SiS_Pr->SiS_HT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VT = SiS_Pr->PanelVT; + gotit = TRUE; + + } else if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) && (romptr) && (ROMAddr) ) { + +#ifdef SIS315H + SiS_Pr->SiS_RVBHCMAX = ROMAddr[romptr]; + SiS_Pr->SiS_RVBHCFACT = ROMAddr[romptr+1]; + SiS_Pr->SiS_VGAHT = ROMAddr[romptr+2] | ((ROMAddr[romptr+3] & 0x0f) << 8); + SiS_Pr->SiS_VGAVT = ROMAddr[romptr+4] | ((ROMAddr[romptr+3] & 0xf0) << 4); + SiS_Pr->SiS_HT = ROMAddr[romptr+5] | ((ROMAddr[romptr+6] & 0x0f) << 8); + SiS_Pr->SiS_VT = ROMAddr[romptr+7] | ((ROMAddr[romptr+6] & 0xf0) << 4); + if(SiS_Pr->SiS_VGAHT) gotit = TRUE; +#endif + + } + + if(!gotit) { + + SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, + &CRT2Index,&ResIndex,HwInfo); + + switch(CRT2Index) { + case Panel_1024x768 : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; + case Panel_1024x768 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1024x768Data; break; + case Panel_1280x720 : + case Panel_1280x720 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x720Data; break; + case Panel_1280x768_2 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x768_2Data; break; + case Panel_1280x768_2+ 32: LCDPtr = SiS_Pr->SiS_StLCD1280x768_2Data; break; + case Panel_1280x768_3 : + case Panel_1280x768_3+ 32: LCDPtr = SiS_Pr->SiS_LCD1280x768_3Data; break; + case Panel_1280x800 : + case Panel_1280x800 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x800Data; break; + case Panel_1280x960 : + case Panel_1280x960 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x960Data; break; + case Panel_1280x1024 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data; break; + case Panel_1280x1024 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; + case Panel_1400x1050 : LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data; break; + case Panel_1400x1050 + 32: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break; + case Panel_1600x1200 : LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break; + case Panel_1600x1200 + 32: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break; + case Panel_1680x1050 : + case Panel_1680x1050 + 32: LCDPtr = SiS_Pr->SiS_LCD1680x1050Data; break; + case 100 : LCDPtr = SiS_Pr->SiS_NoScaleData; break; #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; + case 200 : LCDPtr = SiS310_ExtCompaq1280x1024Data; break; + case 201 : LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; #endif - default: LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; /* Just to avoid a crash */ - } - - 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; + default : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; + } #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, - "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex); + xf86DrvMsg(0, X_INFO, "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex); #endif - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - tempax = 1024; + 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; + + } + + tempax = SiS_Pr->PanelXRes; + tempbx = SiS_Pr->PanelYRes; + + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - if(HwDeviceExtension->jChipType < SIS_315H) { + 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; @@ -3742,4125 +3444,3671 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT Mode 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; + } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x960) { 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_Panel1600x1200) { - tempax = 1600; - if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 875; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 1000; - else tempbx = 1200; - } else { - tempax = SiS_Pr->PanelXRes; - tempbx = SiS_Pr->PanelYRes; - } + } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { + 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 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) { + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 875; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 1000; + } + } + 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; } } } -USHORT -SiS_GetResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +static void +SiS_GetCRT2Data(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { - USHORT resindex; - if(ModeNo <= 0x13) - resindex=SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; - else - resindex=SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + if(SiS_Pr->SiS_VBType & VB_SISVB) { - return(resindex); -} + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + } else { + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + /* Need LVDS Data for LCD on 301B-DH */ + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + } else { + SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + } + } -void -SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT xres,yres,modeflag=0,resindex; + } else { + + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - 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,ROMAddr,ModeNo,ModeIdIndex); +/*********************************************/ +/* GET LVDS DES (SKEW) DATA */ +/*********************************************/ + +static void +SiS_GetLVDSDesPtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, USHORT *PanelIndex, + USHORT *ResIndex, PSIS_HW_INFO HwInfo) +{ + USHORT modeflag; if(ModeNo <= 0x13) { - xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; - yres = SiS_Pr->SiS_StResInfo[resindex].VTotal; + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; } else { - xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; - yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal; modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; } - if((!SiS_Pr->SiS_IF_DEF_DSTN) && (!SiS_Pr->SiS_IF_DEF_FSTN)) { + (*ResIndex) &= 0x1F; + (*PanelIndex) = 0; - 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; - } + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + (*PanelIndex) = 50; + if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) (*PanelIndex) += 2; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*PanelIndex) += 1; + /* Nothing special needed for SOverscan */ + /* PALM uses NTSC data, PALN uses PAL data */ } + } - if(ModeNo > 0x13) { - if(modeflag & HalfDCLK) xres *= 2; - if(modeflag & DoubleScanMode) yres *= 2; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + *PanelIndex = 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 + */ + (*PanelIndex) = SiS_Pr->SiS_LCDResInfo - 1; + } + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + (*PanelIndex) += 16; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + (*PanelIndex) = 32; + if(modeflag & HalfDCLK) (*PanelIndex)++; + } } - } - 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) { /* 301BDH */ - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVisionTV)) { - 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 & (SetCRT2ToLCD | SetCRT2ToHiVisionTV)) { - if(xres == 720) xres = 640; - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - 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(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; - } - if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) { - yres = 480; - } - } + if(SiS_Pr->SiS_SetFlag & SetDOSMode) { + if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) { + (*ResIndex) = 7; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) (*ResIndex)++; + } + } } - SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; - SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; } -void -SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_GetLVDSDesData(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { - USHORT tempbx=0,tempal=0; - USHORT Flag,resinfo=0; + USHORT modeflag; + USHORT PanelIndex,ResIndex; + const SiS_LVDSDesStruct *PanelDesPtr = NULL; - 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; + SiS_Pr->SiS_LCDHDES = 0; + SiS_Pr->SiS_LCDVDES = 0; + + if( (SiS_Pr->UseCustomMode) || + (SiS_Pr->SiS_LCDResInfo == Panel_Custom) || + (SiS_Pr->SiS_CustomT == CUT_PANEL848) || + ((SiS_Pr->SiS_VBType & VB_SISVB) && + (SiS_Pr->SiS_LCDInfo & DontExpandLCD) && + (SiS_Pr->SiS_LCDInfo & LCDPass11)) ) { + return; } - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + +#ifdef SIS315H + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + /* non-pass 1:1 only, see above */ + if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) { + SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2); + } + if(SiS_Pr->SiS_VGAVDE != SiS_Pr->PanelYRes) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE) / 2); + } + } + if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { + switch(SiS_Pr->SiS_CustomT) { + case CUT_UNIWILL1024: + case CUT_UNIWILL10242: + case CUT_CLEVO1400: + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } + break; + } + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { + if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } + } + } +#endif - 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; -#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; - } 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 += 5; - /* GetRevisionID(); */ - /* BIOS only adds 5 once */ - tempbx += 5; - } - } + SiS_GetLVDSDesPtr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + &PanelIndex, &ResIndex, HwInfo); + + switch(PanelIndex) { + case 0: PanelDesPtr = SiS_Pr->SiS_PanelType00_1; break; /* --- */ + case 1: PanelDesPtr = SiS_Pr->SiS_PanelType01_1; break; + case 2: PanelDesPtr = SiS_Pr->SiS_PanelType02_1; break; + case 3: PanelDesPtr = SiS_Pr->SiS_PanelType03_1; break; + case 4: PanelDesPtr = SiS_Pr->SiS_PanelType04_1; break; + case 5: PanelDesPtr = SiS_Pr->SiS_PanelType05_1; break; + case 6: PanelDesPtr = SiS_Pr->SiS_PanelType06_1; break; + case 7: PanelDesPtr = SiS_Pr->SiS_PanelType07_1; break; + case 8: PanelDesPtr = SiS_Pr->SiS_PanelType08_1; break; + case 9: PanelDesPtr = SiS_Pr->SiS_PanelType09_1; break; + case 10: PanelDesPtr = SiS_Pr->SiS_PanelType0a_1; break; + case 11: PanelDesPtr = SiS_Pr->SiS_PanelType0b_1; break; + case 12: PanelDesPtr = SiS_Pr->SiS_PanelType0c_1; break; + case 13: PanelDesPtr = SiS_Pr->SiS_PanelType0d_1; break; + case 14: PanelDesPtr = SiS_Pr->SiS_PanelType0e_1; break; + case 15: PanelDesPtr = SiS_Pr->SiS_PanelType0f_1; break; + case 16: PanelDesPtr = SiS_Pr->SiS_PanelType00_2; break; /* --- */ + case 17: PanelDesPtr = SiS_Pr->SiS_PanelType01_2; break; + case 18: PanelDesPtr = SiS_Pr->SiS_PanelType02_2; break; + case 19: PanelDesPtr = SiS_Pr->SiS_PanelType03_2; break; + case 20: PanelDesPtr = SiS_Pr->SiS_PanelType04_2; break; + case 21: PanelDesPtr = SiS_Pr->SiS_PanelType05_2; break; + case 22: PanelDesPtr = SiS_Pr->SiS_PanelType06_2; break; + case 23: PanelDesPtr = SiS_Pr->SiS_PanelType07_2; break; + case 24: PanelDesPtr = SiS_Pr->SiS_PanelType08_2; break; + case 25: PanelDesPtr = SiS_Pr->SiS_PanelType09_2; break; + case 26: PanelDesPtr = SiS_Pr->SiS_PanelType0a_2; break; + case 27: PanelDesPtr = SiS_Pr->SiS_PanelType0b_2; break; + case 28: PanelDesPtr = SiS_Pr->SiS_PanelType0c_2; break; + case 29: PanelDesPtr = SiS_Pr->SiS_PanelType0d_2; break; + case 30: PanelDesPtr = SiS_Pr->SiS_PanelType0e_2; break; + case 31: PanelDesPtr = SiS_Pr->SiS_PanelType0f_2; break; + case 32: PanelDesPtr = SiS_Pr->SiS_PanelTypeNS_1; break; /* pass 1:1 */ + case 33: PanelDesPtr = SiS_Pr->SiS_PanelTypeNS_2; break; + case 50: PanelDesPtr = SiS_Pr->SiS_CHTVUNTSCDesData; break; /* TV */ + case 51: PanelDesPtr = SiS_Pr->SiS_CHTVONTSCDesData; break; + case 52: PanelDesPtr = SiS_Pr->SiS_CHTVUPALDesData; break; + case 53: PanelDesPtr = SiS_Pr->SiS_CHTVOPALDesData; break; + default: return; + } + + SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES; + SiS_Pr->SiS_LCDVDES = (PanelDesPtr+ResIndex)->LCDVDES; + + if((ModeNo <= 0x13) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 632; + } else if(!(SiS_Pr->SiS_SetFlag & SetDOSMode)) { + if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) { + if(SiS_Pr->SiS_LCDResInfo >= Panel_1024x768) { + if(HwInfo->jChipType < SIS_315H) { + if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 320; + } else { + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) SiS_Pr->SiS_LCDHDES = 480; + if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 804; + if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 704; + if(!(modeflag & HalfDCLK)) { + SiS_Pr->SiS_LCDHDES = 320; + if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 632; + if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 542; + } + } + } + } + } + } + } +} +/*********************************************/ +/* 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_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ #ifdef SIS315H - if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { - tempbx = 50; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 51; - else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 52; - } + USHORT tempah,pushax=0,modenum; #endif + USHORT temp=0; - } 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; - } - - } - - tempal &= 0x3F; - - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) { - if(ModeNo > 0x13) { - if(tempal == 6) tempal = 7; - if((resinfo == SIS_RI_720x480) || - (resinfo == SIS_RI_720x576) || - (resinfo == SIS_RI_768x576)) { - tempal = 6; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ===== For 30xB/LV ===== */ + + if(HwInfo->jChipType < SIS_315H) { + +#ifdef SIS300 /* 300 series */ + + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); + } else { + 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); + if(!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + 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); + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); + } else { + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + } + } + +#endif /* SIS300 */ - *CRT2Index = tempbx; - *ResIndex = tempal; + } else { - } else { /* LVDS, 301B-DH (if running on LCD) */ +#ifdef SIS315H /* 315 series */ + + BOOLEAN custom1 = ((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) ? TRUE : FALSE; - 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_ModeType > ModeVGA) { - if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; + modenum = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34) & 0x7f; + + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + +#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); } - 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; - } - } - } - } + } +#endif + if( (modenum <= 0x13) || + (SiS_IsVAMode(SiS_Pr,HwInfo)) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); + if(custom1) SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } - 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(!custom1) { + SiS_DDC2Delay(SiS_Pr,0xff00); + SiS_DDC2Delay(SiS_Pr,0xe000); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); + pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06); + if(IS_SIS740) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); + } + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - tempbx = 7; - } + } + + if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { + if(HwInfo->jChipType < SIS_340) { + tempah = 0xef; + if(SiS_IsVAMode(SiS_Pr,HwInfo)) tempah = 0xf7; + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); + } + } + + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,~0x10); + } + + 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_Pr->SiS_CustomT == CUT_PANEL848) { - tempbx = 84; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; - } + if((SiS_IsVAMode(SiS_Pr,HwInfo)) || + ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) { - } + SiS_DisplayOff(SiS_Pr); + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + } + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF); + + } + + if((!(SiS_IsVAMode(SiS_Pr,HwInfo))) || + ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) { + + 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); + + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + } -#if 0 - if(SiS_Pr->SiS_IF_DEF_FSTN){ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){ - tempbx = 14; - tempal = 6; - } - } -#endif + 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_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++; - } + } + + if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); + } - } + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + + if(!custom1) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(ModeNo > 0x13) { - if((resinfo == SIS_RI_720x480) || - (resinfo == SIS_RI_720x576) || - (resinfo == SIS_RI_768x576)) - tempal = 6; - } - } + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + if(!(SiS_CRT2IsLCD(SiS_Pr,HwInfo))) { + if(!(SiS_IsDualEdge(SiS_Pr,HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); + } + } + } - *CRT2Index = tempbx; - *ResIndex = tempal & 0x1F; - } -} + SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); -#ifdef SIS315H -void -SiS_GetCRT2PtrA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index, - USHORT *ResIndex) -{ - USHORT tempbx,tempal; + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 20); + } + } + + } else { + + 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); + } + } - 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 if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) tempbx = 2; - else tempbx -= SiS_Pr->SiS_Panel1024x768; +#endif /* SIS315H */ - 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; + } else { /* ============ For 301 ================ */ - *CRT2Index = tempbx; - *ResIndex = tempal & 0x1F; -} + if(HwInfo->jChipType < SIS_315H) { +#ifdef SIS300 + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } #endif + } -void -SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index, - USHORT *ResIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT BaseAddr) -{ - USHORT tempbx,tempal; - - if(ModeNo <= 0x13) - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - else - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */ + SiS_DisplayOff(SiS_Pr); - tempbx = SiS_Pr->SiS_LCDResInfo; + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + } - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 16; - else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx += 32; + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */ -#ifdef SIS315H - 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, HwDeviceExtension, BaseAddr)) { - tempbx = 103; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 104; - else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx = 105; - } - } - } + 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 { +#ifdef SIS300 + 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); + } #endif + } - *CRT2Index = tempbx; - *ResIndex = tempal & 0x3F; -} + } -USHORT -SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - 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; + } else { /* ============ For LVDS =============*/ - /* Do NOT check for UseCustomMode here, will skrew up FIFO */ - if(ModeNo == 0xfe) return 0; + if(HwInfo->jChipType < SIS_315H) { - if(ModeNo <= 0x13) - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - else - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; +#ifdef SIS300 /* 300 series */ - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(modeflag & HalfDCLK) return(0); - } - } + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { + SiS_SetCH700x(SiS_Pr,0x090E); + } - if(ModeNo < 0x14) return(0xFFFF); + 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); + } + } + } + } - /* 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 - */ + SiS_DisplayOff(SiS_Pr); - index = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x33); - index >>= SiS_Pr->SiS_SelectCRT2Rate; - index &= 0x0F; - backupindex = index; + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - if(index > 0) index--; + 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_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; + 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(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; - } - } - } +#endif /* SIS300 */ - RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; - ModeNo = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].ModeID; + } else { - /* 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++; +#ifdef SIS315H /* 315 series */ + + if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { + if(HwInfo->jChipType < SIS_340) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,~0x18); + } } - } - } - 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); + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - 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(HwInfo->jChipType == SIS_740) { + temp = SiS_GetCH701x(SiS_Pr,0x61); + if(temp < 1) { + SiS_SetCH701x(SiS_Pr,0xac76); + SiS_SetCH701x(SiS_Pr,0x0066); + } - i--; + if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) ) { + SiS_SetCH701x(SiS_Pr,0x3e49); + } + } + + if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (SiS_IsVAMode(SiS_Pr,HwInfo)) ) { + SiS_Chrontel701xBLOff(SiS_Pr); + SiS_Chrontel701xOff(SiS_Pr,HwInfo); + } + + if(HwInfo->jChipType != SIS_740) { + if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) ) { + SiS_SetCH701x(SiS_Pr,0x0149); + } + } - 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))) { - /* 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; } - } - return(RefreshRateTableIndex + i); -} + if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } -/* 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; + if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (!(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo))) ) { + SiS_DisplayOff(SiS_Pr); + } - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = 0; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } + 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); + } - tempbx = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].ModeID; + if(HwInfo->jChipType == SIS_740) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); + } - tempax = 0; + 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_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 == SIS_RI_1600x1200) tempax |= SupportTV1024; - } - } - } - } else 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 == SIS_RI_640x480) && (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 == SIS_RI_640x480) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - return(0); - } else { - if((resinfo >= SIS_RI_1280x1024) && (resinfo != SIS_RI_1280x768)) { - return(0); - } - } - } - } - } - } - } - } else { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - if( (resinfo != SIS_RI_1024x600) && - ((resinfo == SIS_RI_512x384) || (resinfo >= SIS_RI_1024x768))) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { - if((resinfo != SIS_RI_1152x768) && (resinfo > SIS_RI_1024x768)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { - if((resinfo != SIS_RI_1280x960) && (resinfo > SIS_RI_1024x768)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(resinfo > SIS_RI_1280x1024) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(resinfo > SIS_RI_1024x768) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - if((resinfo == SIS_RI_512x384) || (resinfo > SIS_RI_800x600)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - if((resinfo == SIS_RI_512x384) || - (resinfo == SIS_RI_400x300) || - (resinfo > SIS_RI_640x480)) return(0); - } - } - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(SiS_Pr->SiS_HiVision == 3) { - tempax |= SupportHiVisionTV2; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode){ - if(resinfo == SIS_RI_512x384) return(0); - if(resinfo == SIS_RI_400x300) return(0); - if(resinfo == SIS_RI_800x600) { - if(SiS_Pr->SiS_SetFlag & TVSimuMode) return(0); - } - if(resinfo > SIS_RI_800x600) return(0); - } - } else { - tempax |= SupportHiVisionTV; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode){ - if(resinfo == SIS_RI_512x384) return(0); - if((resinfo == SIS_RI_400x300) || (resinfo == SIS_RI_800x600)) { - if(SiS_Pr->SiS_SetFlag & TVSimuMode) return(0); - } - if(resinfo > SIS_RI_800x600) 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 != SIS_RI_1024x768) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != SIS_RI_512x384)) ) { - 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 != SIS_RI_800x600)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else { - if( (resinfo != SIS_RI_400x300) || - (!(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 == SIS_RI_400x300) 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 != SIS_RI_800x600)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else { - if( (resinfo != SIS_RI_400x300) || - (!(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 == SIS_RI_400x300) return(0); - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else return(0); - } - } - } else { /* slavemode */ - if(resinfo != SIS_RI_1024x768) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != SIS_RI_512x384) ) ) { - 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 != SIS_RI_800x600)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else { - if( (resinfo != SIS_RI_400x300) || - (!(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 == SIS_RI_400x300) 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 != SIS_RI_800x600)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else { - if( (resinfo != SIS_RI_400x300) || - (!(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 == SIS_RI_400x300) return(0); - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0); - } - } - } else return(0); - } - } - } - - } else { /* for LVDS */ - - 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 != SIS_RI_1280x768) && (resinfo >= SIS_RI_1280x1024)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - if((resinfo != SIS_RI_1024x600) && (resinfo >= SIS_RI_1024x768)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { - if((resinfo != SIS_RI_1152x768) && (resinfo > SIS_RI_1024x768)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - if((resinfo != SIS_RI_1400x1050) && (resinfo > SIS_RI_1280x1024)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { - if(resinfo > SIS_RI_1600x1200) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(resinfo > SIS_RI_1280x1024) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(resinfo > SIS_RI_1024x768) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600){ - if(resinfo > SIS_RI_800x600) return(0); - if(resinfo == SIS_RI_512x384) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelBarco1366) { - if((resinfo != SIS_RI_1360x1024) && (resinfo > SIS_RI_1280x1024)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == Panel_848x480) { - if((resinfo != SIS_RI_1360x768) && - (resinfo != SIS_RI_848x480) && - (resinfo > SIS_RI_1024x768)) return(0); - } - } - } - - /* 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; - } - /* 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); -} - -void -SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo) -{ - USHORT temp1,temp2; - - /* 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); -} - -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; - - 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; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } - } - - SiS_Pr->SiS_SetFlag = 0; - - SiS_Pr->SiS_ModeType = modeflag & ModeInfoFlag; - - 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 315/330+30xLV */ - if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV)) { - if(SiS_Pr->SiS_HiVision & 0x03) { /* New from 650/30xLV 1.10.6s */ - temp &= (SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode); /* 0x83 */ - temp |= SetCRT2ToHiVisionTV; /* 0x80 */ - } - if(SiS_Pr->SiS_HiVision & 0x04) { /* New from 650/30xLV 1.10.6s */ - temp &= (SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode); /* 0x83 */ - temp |= SetCRT2ToSVIDEO; /* 0x08 */ - } - } -#endif -#if 0 - if(SiS_Pr->SiS_IF_DEF_FSTN) { /* fstn must set CR30=0x21 */ - temp = (SetCRT2ToLCD | SetSimuScanMode); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,temp); - } -#endif - tempbx |= temp; - tempax = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) << 8; - tempax &= (LoadDACFlag | DriverMode | SetDispDevSwitch | SetNotSimuMode | SetPALTV); - tempbx |= tempax; - tempbx &= ~(SetCHTVOverScan | SetInSlaveMode | DisableCRT2Display);; - -#ifdef SIS315H - - 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 + 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); } - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) { - tempbx |= SetCRT2ToLCDA; + } + } else { + if(HwInfo->jChipType == SIS_740) { + if(SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); } - } - - 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; - } + } else if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); } } -#endif /* SIS315H */ - - 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(!(tempbx & temp)) { - tempax = DisableCRT2Display; - tempbx = 0; - } - - 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_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); + } } - if(tempax & DisableCRT2Display) { - if(!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { - tempbx = SetSimuScanMode | DisableCRT2Display; - } - } + SiS_UnLockCRT2(SiS_Pr,HwInfo); - if(!(tempbx & DriverMode)){ - tempbx |= SetSimuScanMode; - } - - /* 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(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(!(tempbx & SetSimuScanMode)) { - if(tempbx & SwitchToCRT2) { - if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { - if( (HwDeviceExtension->jChipType >= SIS_315H) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { - if(resinfo != SIS_RI_1600x1200) - tempbx |= SetSimuScanMode; - } else { - tempbx |= SetSimuScanMode; - } - } - } else { - if(!(SiS_BridgeIsEnable(SiS_Pr,BaseAddr,HwDeviceExtension))) { - if(!(tempbx & DriverMode)) { - if(SiS_BridgeInSlave(SiS_Pr)) { - tempbx |= SetSimuScanMode; - } - } - } - } - } - 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 != SIS_RI_1600x1200) { /* 650/301 BIOS */ - tempbx |= SetInSlaveMode; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(tempbx & SetCRT2ToTV) { - if(!(tempbx & SetNotSimuMode)) - SiS_Pr->SiS_SetFlag |= TVSimuMode; - } - } - } /* 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->SiS_CHSOverScan) { - tempbx |= SetCHTVOverScan; + 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); + } } - } - } - - 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; - } } - } - - SiS_Pr->SiS_VBInfo = tempbx; - - if(HwDeviceExtension->jChipType == SIS_630) { - SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo); - } - -#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 - -} - -/* 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_ChSW)) return; - -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x80000874); /* get ACPI base */ - acpibase = SiS_GetReg3(0xcfc); -#else - acpibase = pciReadLong(0x00000800, 0x74); -#endif - acpibase &= 0xFFFF; - temp = SiS_GetReg4((USHORT)(acpibase + 0x3c)); /* ACPI register 0x3c: GP Event 1 I/O mode select */ - temp &= 0xFEFF; - SiS_SetReg5((USHORT)(acpibase + 0x3c), temp); - temp = SiS_GetReg4((USHORT)(acpibase + 0x3c)); - temp = SiS_GetReg4((USHORT)(acpibase + 0x3a)); /* ACPI register 0x3a: GP Pin Level (low/high) */ - temp &= 0xFEFF; - if(!(myvbinfo & SetCRT2ToTV)) { - temp |= 0x0100; - } - SiS_SetReg5((USHORT)(acpibase + 0x3a), temp); - temp = SiS_GetReg4((USHORT)(acpibase + 0x3a)); -} - -void -SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT tempax=0,tempbx=0; - USHORT temp1=0,modeflag=0,tempcx=0; - USHORT StandTableIndex,CRT1Index; -#ifdef SIS315H - USHORT ResIndex,DisplayType,temp=0; - const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr = NULL; -#endif - - SiS_Pr->SiS_RVBHCMAX = 1; - SiS_Pr->SiS_RVBHCFACT = 1; - - if(ModeNo <= 0x13) { - 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]; - - } else { - - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ) { - -#ifdef SIS315H - temp = SiS_GetLVDSCRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,&ResIndex,&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+ResIndex)->CR[0]; - tempax |= (LVDSCRT1Ptr+ResIndex)->CR[14] << 8; - tempax &= 0x03FF; - tempbx = (LVDSCRT1Ptr+ResIndex)->CR[6]; - tempcx = (LVDSCRT1Ptr+ResIndex)->CR[13] << 8; - tempcx &= 0x0100; - tempcx <<= 2; - tempbx |= tempcx; - temp1 = (LVDSCRT1Ptr+ResIndex)->CR[7]; -#endif - - } else { - - 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]; - - } - - } - - 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; +#endif /* SIS315H */ - /* From 650/30xLV 1.10.6s */ - if(modeflag & HalfDCLK) tempax <<= 1; + } /* 315 series */ - tempbx++; - - SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; - SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = tempbx; -} + } /* LVDS */ -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); } -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); -} +/*********************************************/ +/* 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_EnableCRT2(SiS_Private *SiS_Pr) -{ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); -} - -/* NEVER use any variables (VBInfo), this will be called outside the context of modeswitch! */ -/* I MUST call getVBType before calling this */ -void -SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr) +SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { + USHORT temp=0,tempah; #ifdef SIS315H - USHORT tempah,pushax=0,modenum; + USHORT temp1,pushax=0; + BOOLEAN delaylong = FALSE; #endif - USHORT temp=0; - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ===== For 30xB/LV ===== */ - - if(HwDeviceExtension->jChipType < SIS_315H) { - -#ifdef SIS300 /* 300 series */ - - if(HwDeviceExtension->jChipType == SIS_300) { /* For 300+301LV (A907) */ - - 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->SiS_VBType & VB_SIS301BLV302BLV) { /* ====== For 301B et al ====== */ - } else { + if(HwInfo->jChipType < SIS_315H) { - 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); - } - } - -#endif /* SIS300 */ +#ifdef SIS300 /* 300 series */ - } else { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); + } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); + } + if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV | VB_NoLCD)) { + if(!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } + } + } + + if((SiS_Pr->SiS_VBType & VB_NoLCD) && + (SiS_CRT2IsLCD(SiS_Pr, HwInfo))) { + + 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_BridgeInSlavemode(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_BridgeInSlavemode(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_VBType & VB_SIS301LV302LV) { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + 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); + } + } + } + + } -#ifdef SIS315H /* 315 series */ + +#endif /* SIS300 */ - if(IS_SIS550650740660) { /* 550, 650, 740, 660 */ + } else { - modenum = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34); +#ifdef SIS315H /* 315 series */ - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* LV */ +#ifdef SET_EMI + UCHAR r30=0, r31=0, r32=0, r33=0, cr36=0; + /* USHORT emidelay=0; */ +#endif + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0xef); #ifdef SET_EMI - if(SiS_Pr->SiS_VBType & VB_SIS302LV) { - if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - } - } + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); + } #endif - - if( (modenum <= 0x13) || - (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) || - (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); - if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || - (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - } - } - - if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && - (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { - 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); - } - - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - - if(!(IS_SIS740)) { - 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); - } - } - } - - } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { /* B-DH */ - /* This is actually bullshit. The B-DH bridge has cetainly no - * Part4 Index 26, since it has no ability to drive LCD panels - * at all. But as the BIOS does it, we do it, too... - */ - if(HwDeviceExtension->jChipType == SIS_650) { - if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,0xef); - } - if((!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) || - (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00); - } - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 3); - } - } - - 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_VBType & VB_SIS301B302B) || - (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || - (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { - 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_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) { - - 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_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); - } - } - - } else { - - if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || - (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || - (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { - 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); - } - - } - - if((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && - (SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && - (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { - - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,~0x10); /* 1.10.8r, 8m */ - - 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_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr)) { /* 1.10.8r, 8m */ - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); - } /* 1.10.8r, 8m */ - - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf); - } - - 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 if(SiS_Pr->SiS_VBType & VB_NoLCD) { - - if(HwDeviceExtension->jChipType == SIS_650) { - if((SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)))) { - if((!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) || - (!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)))) { - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 2); - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 4); - } - } - } - - } else if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || - (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || - (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { - - if(HwDeviceExtension->jChipType == SIS_650) { - if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) { - tempah = 0xef; - if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) { - 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,HwDeviceExtension, BaseAddr)) || - (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)))) { - if((!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) || - (!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)))) { - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 2); - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 4); - } - } - } - } - - } - - } else { /* 315, 330 - all bridge types */ - - 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))) ) { - - if( (!(SiS_Is301B(SiS_Pr,BaseAddr))) || - (!(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); - - } - - } /* 315/330 */ - -#endif /* SIS315H */ + } - } + if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { + if(HwInfo->jChipType < SIS_340) { + 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); + } + } - } else { /* ============ For 301 ================ */ + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + + 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(HwDeviceExtension->jChipType < SIS_315H) { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - } - } + if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) { + if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2); + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_GenericDelay(SiS_Pr, 0x4500); + } + } + } - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */ - SiS_DisplayOff(SiS_Pr); + if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40)) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + delaylong = TRUE; + } - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - } + } - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */ + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; + if(SiS_BridgeInSlavemode(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); - 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 */ - 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); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ + + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); + + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); } - } + + } else { + + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x20); + + } - } + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); + 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); - } else { /* ============ For LVDS =============*/ + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(HwDeviceExtension->jChipType < SIS_315H) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); -#ifdef SIS300 /* 300 series */ + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1f,0x10); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - SiS_SetCH700x(SiS_Pr,0x090E); - } + 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); + SiS_GenericDelay(SiS_Pr, 0x500); + } +#endif + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c); - 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)) { + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { +#ifdef SET_EMI + cr36 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); + + if(SiS_Pr->SiS_ROMNew) { + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo); + if(romptr) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */ + SiS_Pr->EMI_30 = 0; + SiS_Pr->EMI_31 = ROMAddr[romptr + 14]; + SiS_Pr->EMI_32 = ROMAddr[romptr + 15]; + SiS_Pr->EMI_33 = ROMAddr[romptr + 16]; + if(ROMAddr[romptr + 1] & 0x10) SiS_Pr->EMI_30 = 0x40; + /* emidelay = SISGETROMW((romptr + 0x22)); */ + SiS_Pr->HaveEMI = SiS_Pr->HaveEMILCD = SiS_Pr->OverruleEMI = TRUE; + } + } - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { - - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { + /* (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; + } - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); + /* 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_GetReg1(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) { - SiS_DisplayOff(SiS_Pr); - } + if((!SiS_Pr->HaveEMI) || (!SiS_Pr->HaveEMILCD)) { + switch((cr36 & 0x0f)) { + case 2: + r30 |= 0x40; + if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) r30 &= ~0x40; + if(!SiS_Pr->HaveEMI) { + r31 = 0x05; r32 = 0x60; r33 = 0x33; + if((cr36 & 0xf0) == 0x30) { + r31 = 0x0d; r32 = 0x70; r33 = 0x40; + } + } + break; + case 3: /* 1280x1024 */ + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) r30 |= 0x40; + if(!SiS_Pr->HaveEMI) { + r31 = 0x12; r32 = 0xd0; r33 = 0x6b; + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + r31 = 0x0d; r32 = 0x70; r33 = 0x6b; + } + } + break; + case 9: /* 1400x1050 */ + r30 |= 0x40; + if(!SiS_Pr->HaveEMI) { + r31 = 0x05; r32 = 0x60; r33 = 0x00; + if(SiS_Pr->SiS_CustomT == CUT_COMPAL1400_2) { + r31 = 0x0d; r32 = 0x70; r33 = 0x40; /* BIOS values */ + } + } + break; + case 11: /* 1600x1200 - unknown */ + r30 |= 0x40; + if(!SiS_Pr->HaveEMI) { + r31 = 0x05; r32 = 0x60; r33 = 0x00; + } + } + } - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - } - } - } - } + /* 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; + } + } +#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); /* Reset */ + SiS_GenericDelay(SiS_Pr, 0x500); + } + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,r31); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,r32); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x33,r33); +#endif /* SET_EMI */ + + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + +#ifdef SET_EMI + if( (SiS_LCDAEnabled(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); /* Enable */ + } + } +#endif + } + } - SiS_DisplayOff(SiS_Pr); + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + if(SiS_IsVAorLCD(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); + } + } - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); + SiS_DisplayOn(SiS_Pr); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xff); - 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_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + } - 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); - } +#endif /* SIS315H */ -#endif /* SIS300 */ + } - } else { + } else { /* ============ For 301 ================ */ -#ifdef SIS315H /* 315 series */ + if(HwInfo->jChipType < SIS_315H) { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } + } - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ + if(SiS_BridgeInSlavemode(SiS_Pr)) { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); - if(HwDeviceExtension->jChipType == SIS_740) { - temp = SiS_GetCH701x(SiS_Pr,0x61); - if(temp < 1) { - SiS_SetCH701x(SiS_Pr,0xac76); - SiS_SetCH701x(SiS_Pr,0x0066); - } + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ - 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(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_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_Chrontel701xBLOff(SiS_Pr); - SiS_Chrontel701xOff(SiS_Pr,HwDeviceExtension); - } else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_Chrontel701xBLOff(SiS_Pr); - SiS_Chrontel701xOff(SiS_Pr,HwDeviceExtension); - } + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ - if(HwDeviceExtension->jChipType != SIS_740) { - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetCH701x(SiS_Pr,0x0149); - } else if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetCH701x(SiS_Pr,0x0149); - } - } + 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); - } + 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(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - } + } - 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); - } + } else { /* =================== For LVDS ================== */ - 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(HwInfo->jChipType < SIS_315H) { - if(HwDeviceExtension->jChipType == SIS_740) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); - } +#ifdef SIS300 /* 300 series */ - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + 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); + } + } - 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); - } + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); + SiS_DisplayOn(SiS_Pr); + SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); + if(SiS_BridgeInSlavemode(SiS_Pr)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); + } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, BaseAddr,HwDeviceExtension)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); - if(HwDeviceExtension->jChipType == SIS_550) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xbf); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xef); - } - } - } else { - if(HwDeviceExtension->jChipType == SIS_740) { - if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); - } - } else { - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { + if(!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) { + SiS_WaitVBRetrace(SiS_Pr, HwInfo); + SiS_SetCH700x(SiS_Pr,0x0B0E); + } + } + + 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_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); - } - } +#endif /* SIS300 */ - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); + } else { - if(HwDeviceExtension->jChipType == SIS_550) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); - } else 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); - } +#ifdef SIS315H /* 315 series */ -#if 0 /* 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! */ - } - } + if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { + if(HwInfo->jChipType < SIS_340) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x18); + } } -#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); - } - } + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } } -#endif /* SIS315H */ - - } /* 310 series */ - - } /* LVDS */ - -} - -/* NEVER use any variables (VBInfo), this will be called outside the context of modeswitch! */ -/* I MUST call getVBType before calling this */ -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; -#endif - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); + SiS_UnLockCRT2(SiS_Pr,HwInfo); - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ====== For 301B et al ====== */ + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp &= 0x20; + SiS_Chrontel701xBLOff(SiS_Pr); + } - if(HwDeviceExtension->jChipType < SIS_315H) { + if(HwInfo->jChipType != SIS_550) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); + } -#ifdef SIS300 /* 300 series */ + 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); + } + } + } - if(HwDeviceExtension->jChipType == SIS_300) { + temp1 = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); + if(!(temp1 & 0x80)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + } - 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(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(temp) { + SiS_Chrontel701xBLOn(SiS_Pr, HwInfo); + } + } - } else { + 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); + } + } - 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); - } - } + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + } - } -#endif /* SIS300 */ + 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); + } + } - } else { + 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); + } + } + } -#ifdef SIS315H /* 315 series */ +#endif /* SIS315H */ - if(IS_SIS550650740660) { /* 550, 650, 740, 660 */ + } /* 310 series */ -#if 0 - if(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00) != 1) return; /* From 1.10.7w */ -#endif + } /* LVDS */ - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { +} - if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && - (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0xef); /* 1.10.7u */ -#ifdef SET_EMI - if(SiS_Pr->SiS_VBType & VB_SIS302LV) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); /* 1.10.7u */ - } -#endif - } +/*********************************************/ +/* SET PART 1 REGISTER GROUP */ +/*********************************************/ - if(!(IS_SIS740)) { - if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) { - tempah = 0x10; - if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || - (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x13) & 0x04) { - if((SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) == 0x0c) { - tempah = 0x08; - } else { - tempah = 0x18; - } - } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x4c,tempah); - } else { - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - tempah = 0x08; - } - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,tempah); - } - } - } +/* Set CRT2 OFFSET / PITCH */ +static void +SiS_SetCRT2Offset(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RRTI, PSIS_HW_INFO HwInfo) +{ + USHORT offset; + UCHAR temp; - if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && - (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { - 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); - } - } + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) return; - if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) { - if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { - if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && - (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { - SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 2); - } - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 2); - } - } + offset = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex,RRTI,HwInfo); - if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && - (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { - if(!(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x40)) { - SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10); - delaylong = TRUE; - } - } + if((SiS_Pr->SiS_LCDResInfo == Panel_640x480_2) || + (SiS_Pr->SiS_LCDResInfo == Panel_640x480_3)) { + offset >>= 1; + } - } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(offset & 0xFF)); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,(offset >> 8)); + temp = (UCHAR)(((offset >> 3) & 0xFF) + 1); + if(offset % 8) temp++; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,temp); +} - if(HwDeviceExtension->jChipType == SIS_650) { - if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x10); - } - if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 0); - } - } +/* Set CRT2 sync and PanelLink mode */ +static void +SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT RefreshRateTableIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT tempah=0,tempbl,infoflag; - } else if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + tempbl = 0xC0; - if(HwDeviceExtension->jChipType == SIS_650) { - if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) { - tempah = 0x10; - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x13) & 0x04) { - tempah = 0x18; - if((SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) == 0x0c) { - tempah = 0x08; - } - } - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,tempah); - } - } - - } + if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; + } else { + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; + } - 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)) { - if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || - (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { - if(!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x13) & 0x04)) temp |= 0x20; - } else temp |= 0x20; - } - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ - - 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_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); - } - } + 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 & SetCRT2ToLCD) { + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + tempah |= 0xf0; + } + if( (SiS_Pr->SiS_IF_DEF_FSTN) || + (SiS_Pr->SiS_IF_DEF_DSTN) || + (SiS_Pr->SiS_IF_DEF_TRUMPION) || + (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) { + tempah |= 0x30; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(HwInfo->jChipType >= SIS_315H) { + tempah >>= 3; + tempah &= 0x18; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xE7,tempah); + /* Don't care about 12/18/24 bit mode - TV is via VGA, not PL */ + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,0xe0); + } + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + } - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x20); - } + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); + if(HwInfo->jChipType < SIS_315H) { - if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || - (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || - (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2e); - if(!(temp & 0x80)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); - } - } +#ifdef SIS300 /* ---- 300 series --- */ - 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); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 630 - 301B(-DH) */ - if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || - (((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || - (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) && - (!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); - } + tempah = infoflag >> 8; + tempbl = 0; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + tempah = SiS_Pr->SiS_LCDInfo; + tempbl = (tempah >> 6) & 0x03; + } + } + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + tempah |= 0xc0; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); + } - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + } else { /* 630 - 301 */ - if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { -#ifdef SET_EMI - if(SiS_Pr->SiS_VBType & VB_SIS302LV) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); /* All this from 1.10.7u */ - } -#endif - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c); -#ifdef SET_EMI - if(SiS_Pr->SiS_VBType & VB_SIS302LV) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); - } -#endif - } + tempah = infoflag >> 8; + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + } -#ifdef SET_EMI - if(SiS_Pr->SiS_VBType & VB_SIS302LV) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x08); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x10); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x4d); - if((SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0x0f) != 0x02) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x0d); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x70); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x6b); - } - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); - } -#endif +#endif /* SIS300 */ - } else if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { + } else { -#ifdef SET_EMI - if(SiS_Pr->SiS_VBType & VB_SIS302LV) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x12); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0xd0); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x6b); - if((SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0x0f) == 0x02) { /* Acer */ - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x0d); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x70); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x40); - if(((SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xf0) != 0x30)) { /* Acer */ - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x05); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x60); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x33); /* 00 */ - } - } - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); - if((SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0x0f) != 0x03) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); - } - } -#endif - } +#ifdef SIS315H /* ------- 315 series ------ */ - if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && - (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - } + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* 315 - LVDS */ - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1f,0x10); + tempbl = 0; + if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) && + (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { + tempah = infoflag >> 8; + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + tempbl = ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6); + } + } else if((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) && + (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050)) { + tempah = infoflag >> 8; + tempbl = 0x03; + } else { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + tempbl = (tempah >> 6) & 0x03; + tempbl |= 0x08; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempbl |= 0x04; + } + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) tempah |= 0xc0; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); + } + } - if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + } else { /* 315 - TMDS */ - if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) { - SiS_DisplayOn(SiS_Pr); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1); - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); -#ifdef SET_EMI - if(SiS_Pr->SiS_VBType & VB_SIS302LV) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); - } -#endif - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfe,0x01); - } - } + tempah = tempbl = infoflag >> 8; + if(!SiS_Pr->UseCustomMode) { + tempbl = 0; + if((SiS_Pr->SiS_VBType & VB_SIS301C) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + if(ModeNo <= 0x13) { + tempah = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); + } + } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + tempah = SiS_Pr->SiS_LCDInfo; + tempbl = (tempah >> 6) & 0x03; + } + } + } + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + if(SiS_Pr->SiS_VBType & VB_NoLCD) { + /* Imitate BIOS bug */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah |= 0xc0; + } + if((SiS_Pr->SiS_VBType & VB_SIS301C) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + tempah >>= 3; + tempah &= 0x18; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xe7,tempah); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); + } + } + } - } else if(SiS_Pr->SiS_CustomT == CUT_CLEVO1400) { + } +#endif /* SIS315H */ + } + } +} - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) { - SiS_DisplayOn(SiS_Pr); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1); - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfe,0x01); - } - } +/* Set CRT2 FIFO on 300/630/730 */ +#ifdef SIS300 +static void +SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo, + PSIS_HW_INFO HwInfo) +{ + 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 + }; - } else { + SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate; - 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->CRT1UsesCustomMode) { + + 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); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax); - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff); + if(CRT1ModeNo >= 0x13) { + index = SiS_Pr->SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK; + index &= 0x3F; + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); - } + colorth = SiS_GetColorDepth(SiS_Pr,CRT1ModeNo,modeidindex); /* Get colordepth */ + colorth >>= 1; + if(!colorth) colorth++; + } - } + } else { - } if(SiS_Pr->SiS_VBType & VB_NoLCD) { + 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(HwDeviceExtension->jChipType == SIS_650) { - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); - } - } - } + } - } + 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 */ - } else { /* 315, 330 */ + data2 = (colorth * VCLK) / MCLK; - 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 = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + temp = ((temp & 0x00FF) >> 6) << 1; + if(temp == 0) temp = 1; + temp <<= 2; + temp &= 0xff; - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ + data2 = temp - data2; - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E); - if(!(temp & 0x80)) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); - } + if((28 * 16) % data2) { + data2 = (28 * 16) / data2; + data2++; + } else { + data2 = (28 * 16) / data2; + } - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); + if(HwInfo->jChipType == SIS_300) { - if(SiS_Is301B(SiS_Pr,BaseAddr)) { + 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; - temp=SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E); - if(!(temp & 0x80)) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + } else if(HwInfo->jChipType == SIS_730) { - 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); +#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; - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); +#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; - } else { + 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; - SiS_VBLongWait(SiS_Pr); - SiS_DisplayOn(SiS_Pr); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7F); - SiS_VBLongWait(SiS_Pr); + data = LatencyFactor730[tempbx]; + data += 15; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + if(!(temp & 0x80)) data += 5; - } + } else { - } /* 315, 330 */ + index = 0; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + if(temp & 0x0080) index += 12; -#endif /* SIS315H */ +#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 + temp = (USHORT)(eax >> 24); + if(!(temp&0x01)) index += 24; - } +#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; - } else { /* ============ For 301 ================ */ + temp = (temp & 0x0F) >> 1; + index += temp; - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xFB); - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 0); - } - } + data = LatencyFactor[index]; + data += 15; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + if(!(temp & 0x80)) data += 5; + } - 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); + data += data2; /* CRT1 Request Period */ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; - 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->UseCustomMode) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ + CRT2ModeNo = ModeNo; + SiS_SearchModeID(SiS_Pr, &CRT2ModeNo, &modeidindex); - 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); + refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT2ModeNo, modeidindex, HwInfo); - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 1); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xF7); - } + index = SiS_GetVCLK2Ptr(SiS_Pr,CRT2ModeNo,modeidindex, + refreshratetableindex,HwInfo); + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ + + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + if(SiS_Pr->SiS_UseROM) { + if(ROMAddr[0x220] & 0x01) { + VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8); + } + } } - } + } else { - } else { /* =================== For LVDS ================== */ + CRT2ModeNo = 0xfe; + VCLK = SiS_Pr->CSRClock; /* Get VCLK */ - if(HwDeviceExtension->jChipType < SIS_315H) { + } -#ifdef SIS300 /* 300 series */ + colorth = SiS_GetColorDepth(SiS_Pr,CRT2ModeNo,modeidindex); /* Get colordepth */ + colorth >>= 1; + if(!colorth) colorth++; - 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); - } - } + data = data * VCLK * colorth; + if(data % (MCLK << 4)) { + data = data / (MCLK << 4); + data++; + } else { + data = data / (MCLK << 4); + } + + if(data <= 6) data = 6; + if(data > 0x14) data = 0x14; - 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); + 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 == Panel_1280x1024) { + 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 { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); - } - - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) { - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - SiS_SetCH700x(SiS_Pr,0x0B0E); - } + temp = (temp & (~0x1F)) | 0x16; } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0xe0,temp); - 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); - } - } - } + 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); -#endif /* SIS300 */ + } else { /* If mode <= 0x13, we just restore everything */ - } else { + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; -#ifdef SIS315H /* 315 series */ + } +} +#endif -#if 0 /* BIOS code makes no sense */ - if(SiS_IsVAMode()) { - if(SiS_IsLCDOrLCDA()) { - } - } +/* Set CRT2 FIFO on 315/330 series */ +#ifdef SIS315H +static void +SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,0x3B); + if( (HwInfo->jChipType == SIS_760) && + (SiS_Pr->SiS_SysFlags & SF_760LFB) && + (SiS_Pr->SiS_ModeType == Mode32Bpp) && + (SiS_Pr->SiS_VGAHDE >= 1280) && + (SiS_Pr->SiS_VGAVDE >= 1024) ) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2f,0x03); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,0x3b); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4d,0xc0); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2f,0x01); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4d,0xc0); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,0x6e); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,~0x3f,0x04); + } + +} #endif - 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); - } - } +static USHORT +SiS_GetVGAHT2(SiS_Private *SiS_Pr) +{ + ULONG tempax,tempbx; - SiS_EnableCRT2(SiS_Pr); - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); + tempbx = (SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) * SiS_Pr->SiS_RVBHCMAX; + 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_Part1Port,0x2e,0xf7); +/* Set Part 1 / SiS bridge slave mode */ +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,xres=0; + unsigned char p1_7, p1_8; - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp &= 0x20; - SiS_Chrontel701xBLOff(SiS_Pr); - } + 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; + xres = SiS_Pr->CHDisplay; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + xres = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes; + } - if(HwDeviceExtension->jChipType != SIS_550) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); - } + /* The following is only done if bridge is in slave mode: */ - if(HwDeviceExtension->jChipType == SIS_740) { - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension,BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); - } - } - } + if((HwInfo->jChipType >= SIS_661) && (ModeNo > 0x13)) { + if(xres >= 1600) { + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x31,0x04); + } + } - temp1 = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E); - if(!(temp1 & 0x80)) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0xff); /* set MAX HT */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(temp) { - SiS_Chrontel701xBLOn(SiS_Pr, HwDeviceExtension); - } - } + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) modeflag |= Charx8Dot; - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); - if(HwDeviceExtension->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,HwDeviceExtension, BaseAddr)) { - if(HwDeviceExtension->jChipType != SIS_740) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); - } - } + if(modeflag & Charx8Dot) tempcx = 0x08; + else tempcx = 0x09; - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); - } + 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 == 2) { + temp = tempax; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x04,temp); - if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_Chrontel701xOn(SiS_Pr,HwDeviceExtension, BaseAddr); - } + 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 */ - 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); - } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x06,0x03); /* 0x06 Horizontal Blank end */ - } + 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 == 2) { - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_Chrontel701xBLOn(SiS_Pr, HwDeviceExtension); - SiS_ChrontelDoSomething4(SiS_Pr,HwDeviceExtension, BaseAddr); - } else if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_Chrontel701xBLOn(SiS_Pr, HwDeviceExtension); - 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 & 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 != Panel_1280x960) && + (SiS_Pr->SiS_LCDResInfo != Panel_1600x1200)) { + if(SiS_Pr->SiS_VGAHDE >= 800) { + temp -= 7; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_ModeType == ModeEGA) { + if(SiS_Pr->SiS_VGAVDE == 1024) { + temp += 15; + if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) + temp += 7; + } + } + } + if(SiS_Pr->SiS_LCDResInfo != Panel_1400x1050) { + if(SiS_Pr->SiS_VGAHDE >= 1280) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) temp += 28; + } + } + } + } + } + } + } -#endif /* SIS315H */ + p1_7 = temp; + p1_8 = 0x00; - } /* 310 series */ + 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; + } + } + } + } - } /* LVDS */ + 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; + } + } + } else { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { + if(modeflag & HalfDCLK) p1_7 = 0x30; + } + } + } -} + 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 */ -void -SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x03); /* 0x18 SR08 (FIFO Threshold?) */ - /* 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); - } - } -} + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x19,0xF0); -void -SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,0xFF); /* 0x09 Set Max VT */ - /* 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); + 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 == Panel_1024x768) { + 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 */ - 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 = 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; } -} - -BOOLEAN -SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp,temp1; - UCHAR *ROMAddr; +#endif + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0E,temp); - if((ROMAddr = (UCHAR *)HwDeviceExtension->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) { - if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - 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 = 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 { - return(0); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,temp); + if(tempbx & 0x0100) tempcx |= 0x0002; + if(tempbx & 0x0400) tempcx |= 0x0600; } -} -BOOLEAN -SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp,temp1; - UCHAR *ROMAddr; + if(tempbx & 0x0200) tempcx |= 0x0040; - if((ROMAddr = (UCHAR *)HwDeviceExtension->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) { - if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - 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); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x11,0x00); /* 0x11 Vertical Blank End */ + + tempax = (SiS_Pr->SiS_VGAVT - tempbx) >> 2; + + 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 != Panel_1400x1050) { + tempbx += (tempax << 1); + } + } + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + tempbx -= 10; } else { - return(0); + 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 */ -void -SiS_SetPanelDelayLoop(SiS_Private *SiS_Pr, UCHAR *ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT DelayTime, USHORT DelayLoop) -{ - int i; - for(i=0; iSiS_Part1Port,0x10,temp); -void -SiS_SetPanelDelay(SiS_Private *SiS_Pr, UCHAR *ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT DelayTime) -{ - USHORT PanelID, DelayIndex, Delay; -#ifdef SIS300 - USHORT temp; -#endif + if(tempbx & 0x0100) tempcx |= 0x0008; - if(HwDeviceExtension->jChipType < SIS_315H) { + if(tempbx & 0x0200) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20); + } + tempbx++; -#ifdef SIS300 + 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(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 300 series, LVDS */ + tempbx = push1; + temp = tempbx & 0x000F; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,temp); /* 0x0D vertical Retrace End */ - PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); + if(tempbx & 0x0010) tempcx |= 0x2000; - DelayIndex = PanelID >> 4; + temp = tempcx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* 0x0A CR07 */ - if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { - Delay = 3; - } else { - if(DelayTime >= 2) DelayTime -= 2; + temp = (tempcx & 0xFF00) >> 8; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* 0x17 SR0A */ - 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); + 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 */ - } else { /* 300 series, 301(B) */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* 0x0F CR14 */ - PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18); - if(!(temp & 0x10)) PanelID = 0x12; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,0x00); /* 0x12 CR17 */ - DelayIndex = PanelID >> 4; + 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 */ - if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { - Delay = 3; - } else { - if(DelayTime >= 2) DelayTime -= 2; + temp = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); +} - 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); +/* Setup panel link + * This is used for LVDS, LCDA and Chrontel TV output + * 300/LVDS+TV, 300/301B-DH, 315/LVDS+TV, 315/LCDA + */ +static void +SiS_SetGroup1_LVDS(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=0; + BOOLEAN islvds = FALSE, issis = FALSE, chkdclkfirst = FALSE; +#ifdef SIS300 + USHORT crt2crtc; +#endif +#ifdef SIS315H + USHORT pushcx; +#endif - } + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; +#ifdef SIS300 + crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; +#endif + } else if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + resinfo = 0; +#ifdef SIS300 + crt2crtc = 0; +#endif + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; +#ifdef SIS300 + crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; +#endif + } -#endif /* SIS300 */ + /* is lvds if really LVDS, or SiS 301B-DH with external LVDS transmitter */ + if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || + ((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBType & VB_NoLCD))) { + islvds = TRUE; + } - } else { + /* is really sis if sis bridge, but not 301B-DH */ + if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { + issis = TRUE; + } - if(HwDeviceExtension->jChipType == SIS_330) return; + if((HwInfo->jChipType >= SIS_315H) && (islvds) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA))) { + if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { + chkdclkfirst = TRUE; + } + } #ifdef SIS315H + if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + if(IS_SIS330) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); + } else if(IS_SIS740) { + if(islvds) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x03); + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); + } + } else { + if(islvds) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x00); + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2D,0x0f); + if(SiS_Pr->SiS_VBType & VB_SIS301C) { + if((SiS_Pr->SiS_LCDResInfo == Panel_1024x768) || + (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x20); + } + } + } + } + } +#endif - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 315 series, LVDS */ + /* Horizontal */ - 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; + tempax = SiS_Pr->SiS_LCDHDES; + if(islvds) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { + if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) && + (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { + tempax -= 8; + } + } + } + } - 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); - } + temp = (tempax & 0x0007); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* BPLHDESKEW[2:0] */ + temp = (tempax >> 3) & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* BPLHDESKEW[10:3] */ - } else { /* 315 series, 301(B) */ + tempbx = SiS_Pr->SiS_HDE; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if((SiS_Pr->SiS_LCDResInfo == Panel_640x480_2) || + (SiS_Pr->SiS_LCDResInfo == Panel_640x480_3)) { + tempbx >>= 1; + } + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + tempbx = SiS_Pr->PanelXRes; + } + } - 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); + tempax += tempbx; + if(tempax >= SiS_Pr->SiS_HT) tempax -= SiS_Pr->SiS_HT; - } + temp = tempax; + if(temp & 0x07) temp += 8; + temp >>= 3; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* BPLHDEE */ -#endif /* SIS315H */ + tempcx = (SiS_Pr->SiS_HT - tempbx) >> 2; - } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(SiS_Pr->PanelHRS != 999) tempcx = SiS_Pr->PanelHRS; + } + } -} + tempcx += tempax; + if(tempcx >= SiS_Pr->SiS_HT) tempcx -= SiS_Pr->SiS_HT; -void -SiS_LongDelay(SiS_Private *SiS_Pr, USHORT delay) -{ - while(delay--) { - SiS_GenericDelay(SiS_Pr,0x19df); + temp = (tempcx >> 3) & 0x00FF; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(SiS_Pr->SiS_IF_DEF_TRUMPION) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + switch(ModeNo) { + case 0x04: + case 0x05: + case 0x0d: temp = 0x56; break; + case 0x10: temp = 0x60; break; + case 0x13: temp = 0x5f; break; + case 0x40: + case 0x41: + case 0x4f: + case 0x43: + case 0x44: + case 0x62: + case 0x56: + case 0x53: + case 0x5d: + case 0x5e: temp = 0x54; break; + } + } + } } -} + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,temp); /* BPLHRS */ -void -SiS_ShortDelay(SiS_Private *SiS_Pr, USHORT delay) -{ - while(delay--) { - SiS_GenericDelay(SiS_Pr,0x42); + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + temp += 2; + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + temp += 8; + if(SiS_Pr->PanelHRE != 999) { + temp = tempcx + SiS_Pr->PanelHRE; + if(temp >= SiS_Pr->SiS_HT) temp -= SiS_Pr->SiS_HT; + temp >>= 3; + } + } + } else { + temp += 10; } -} -void -SiS_GenericDelay(SiS_Private *SiS_Pr, USHORT delay) -{ - USHORT temp,flag; + temp &= 0x1F; + temp |= ((tempcx & 0x07) << 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); /* BPLHRE */ - flag = SiS_GetReg3(0x61) & 0x10; + /* Vertical */ - while(delay) { - temp = SiS_GetReg3(0x61) & 0x10; - if(temp == flag) continue; - flag = temp; - delay--; + tempax = SiS_Pr->SiS_VGAVDE; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + tempax = SiS_Pr->PanelYRes; + } } -} - -BOOLEAN -SiS_Is301B(SiS_Private *SiS_Pr, USHORT BaseAddr) -{ - USHORT flag; - flag = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x01); - if(flag >= 0x0B0) return(1); - else return(0); -} + tempbx = SiS_Pr->SiS_LCDVDES + tempax; + if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; -BOOLEAN -SiS_CRT2IsLCD(SiS_Private *SiS_Pr, USHORT BaseAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT flag; + push2 = tempbx; - if(HwDeviceExtension->jChipType == SIS_730) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13); - if(flag & 0x20) return(1); + tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->PanelYRes; + } + } } - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(flag & 0x20) return(1); - else return(0); -} + if(islvds) tempcx >>= 1; + else tempcx >>= 2; -BOOLEAN -SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + if( (SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) && + (!(SiS_Pr->SiS_LCDInfo & LCDPass11)) && + (SiS_Pr->PanelVRS != 999) ) { + tempcx = SiS_Pr->PanelVRS; + tempbx += tempcx; + if(issis) tempbx++; + } else { + tempbx += tempcx; + if(HwInfo->jChipType < SIS_315H) tempbx++; + else if(issis) tempbx++; + } - 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); -} + if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; /* BPLVRS */ -BOOLEAN -SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + temp = tempbx & 0x00FF; + if(SiS_Pr->SiS_IF_DEF_TRUMPION) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + if(ModeNo == 0x10) temp = 0xa9; + } + } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); - if(HwDeviceExtension->jChipType >= SIS_315H) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if((flag & EnableDualEdge) && (flag & SetToLCDA)) return(1); - else return(0); - } else -#endif - return(0); -} + tempcx >>= 3; + tempcx++; -BOOLEAN -SiS_IsDualLink(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { - if((SiS_CRT2IsLCD(SiS_Pr, BaseAddr, HwDeviceExtension)) || - (SiS_IsVAMode(SiS_Pr, HwDeviceExtension, BaseAddr))) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) return(1); + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(SiS_Pr->PanelVRE != 999) tempcx = SiS_Pr->PanelVRE; } } -#endif - return(0); - } - -BOOLEAN -SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; - 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); - } + tempcx += tempbx; + temp = tempcx & 0x000F; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp); /* BPLVRE */ -#if 0 -BOOLEAN -SiS_Is315E(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + temp = ((tempbx >> 8) & 0x07) << 3; + 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; + tempbx = 0x87; + if((HwInfo->jChipType >= SIS_315H) || + (HwInfo->jChipRevision >= 0x30)) { + tempbx = 0x07; + if((SiS_Pr->SiS_IF_DEF_CH70xx == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x03) temp |= 0x80; + } + /* Chrontel 701x operates in 24bit mode (8-8-8, 2x12bit mutliplexed) via VGA2 */ + if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x10) temp |= 0x80; + } else { + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) temp |= 0x80; + } + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,tempbx,temp); - 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 + tempbx = push2; /* BPLVDEE */ -BOOLEAN -SiS_IsNotM650or651(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + tempcx = SiS_Pr->SiS_LCDVDES; /* BPLVDES */ - if(HwDeviceExtension->jChipType == SIS_650) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f); - flag &= 0xF0; - /* Check for revision != A0 only */ - if((flag == 0xe0) || (flag == 0xc0) || - (flag == 0xb0) || (flag == 0x90)) return 0; - else return 1; - } else -#endif - return 1; -} + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_640x480: + tempbx = SiS_Pr->SiS_VGAVDE - 1; + tempcx = SiS_Pr->SiS_VGAVDE; + break; + case Panel_800x600: + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(resinfo == SIS_RI_800x600) tempcx++; + } + break; + case Panel_1024x600: + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(resinfo == SIS_RI_1024x600) tempcx++; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(resinfo == SIS_RI_800x600) tempcx++; + } + } + break; + case Panel_1024x768: + if(HwInfo->jChipType < SIS_315H) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(resinfo == SIS_RI_1024x768) tempcx++; + } + } + break; + } + } -BOOLEAN -SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + temp = ((tempbx >> 8) & 0x07) << 3; + temp = temp | ((tempcx >> 8) & 0x07); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1D,temp); + /* if(SiS_Pr->SiS_IF_DEF_FSTN) tempbx++; */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1C,tempbx); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1B,tempcx); - 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); -} + /* Vertical scaling */ -BOOLEAN -SiS_IsChScart(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + if(HwInfo->jChipType < SIS_315H) { - 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); -} +#ifdef SIS300 /* 300 series */ + tempeax = SiS_Pr->SiS_VGAVDE << 6; + temp = (tempeax % (ULONG)SiS_Pr->SiS_VDE); + tempeax = tempeax / (ULONG)SiS_Pr->SiS_VDE; + if(temp) tempeax++; -BOOLEAN -SiS_IsTVOrYPbPrOrScart(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ - USHORT flag; + if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempeax = 0x3F; -#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); -} + temp = (USHORT)(tempeax & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1E,temp); /* BPLVCFACT */ + tempvcfact = temp; +#endif /* SIS300 */ -BOOLEAN -SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ - USHORT flag; + } else { -#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 +#ifdef SIS315H /* 315 series */ + tempeax = SiS_Pr->SiS_VGAVDE << 18; + tempebx = SiS_Pr->SiS_VDE; + temp = (tempeax % tempebx); + tempeax = tempeax / tempebx; + if(temp) tempeax++; + tempvcfact = tempeax; + + temp = (USHORT)(tempeax & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,temp); + temp = (USHORT)((tempeax & 0x00FF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,temp); + 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); + } #endif - { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToLCD) return(1); - } - return(0); -} + } -BOOLEAN -SiS_BridgeIsOn(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT flag; + /* Horizontal scaling */ - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - return(0); + tempeax = SiS_Pr->SiS_VGAHDE; /* 1f = ( (VGAHDE * 65536) / ( (VGAHDE * 65536) / HDE ) ) - 1*/ + if(chkdclkfirst) { + if(modeflag & HalfDCLK) tempeax >>= 1; + } + tempebx = tempeax << 16; + if(SiS_Pr->SiS_HDE == tempeax) { + tempecx = 0xFFFF; } else { - flag = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00); - if((flag == 1) || (flag == 2)) return(0); - else return(1); + tempecx = tempebx / SiS_Pr->SiS_HDE; + if(HwInfo->jChipType >= SIS_315H) { + if(tempebx % SiS_Pr->SiS_HDE) tempecx++; + } } -} -BOOLEAN -SiS_BridgeIsEnable(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT flag; + if(HwInfo->jChipType >= SIS_315H) { + tempeax = (tempebx / tempecx) - 1; + } else { + tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1; + } + tempecx = (tempecx << 16) | (tempeax & 0xFFFF); + temp = (USHORT)(tempecx & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1F,temp); - 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 { - /* 315 series (650/30xLV 1.10.6s) */ - flag &= 0x50; - if((flag == 0x40) || (flag == 0x10)) return 0; - else return 1; - } + if(HwInfo->jChipType >= SIS_315H) { + tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact; + tempbx = (USHORT)(tempeax & 0xFFFF); + } else { + tempeax = SiS_Pr->SiS_VGAVDE << 6; + tempbx = tempvcfact & 0x3f; + if(tempbx == 0) tempbx = 64; + tempeax /= tempbx; + tempbx = (USHORT)(tempeax & 0xFFFF); + } + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) 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 != Panel_640x480) tempbx = 1; } - return 1; -} -BOOLEAN -SiS_BridgeInSlave(SiS_Private *SiS_Pr) -{ - USHORT flag1; + temp = ((tempbx >> 8) & 0x07) << 3; + temp = temp | ((tempecx >> 8) & 0x07); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x20,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x21,tempbx); - flag1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31); - if(flag1 & (SetInSlaveMode >> 8)) return 1; - else return 0; -} + tempecx >>= 16; /* BPLHCFACT */ + if(!chkdclkfirst) { + if(modeflag & HalfDCLK) tempecx >>= 1; + } + temp = (USHORT)((tempecx & 0xFF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x22,temp); + temp = (USHORT)(tempecx & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp); -void -SiS_SetHiVision(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ #ifdef SIS315H - USHORT temp; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + if((islvds) || (SiS_Pr->SiS_VBInfo & VB_SIS301LV302LV)) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x20); + } + } else { + if(islvds) { + if(HwInfo->jChipType == SIS_740) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x03); + } else { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x23); + } + } + } + } #endif - /* Note: This variable is only used on 30xLV systems. - CR38 has a different meaning on LVDS/CH7019 systems. - */ +#ifdef SIS300 + if(SiS_Pr->SiS_IF_DEF_TRUMPION) { + int i; + UCHAR TrumpMode13[4] = { 0x01, 0x10, 0x2c, 0x00 }; + UCHAR TrumpMode10_1[4] = { 0x01, 0x10, 0x27, 0x00 }; + UCHAR TrumpMode10_2[4] = { 0x01, 0x16, 0x10, 0x00 }; + + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xbf); + for(i=0; i<5; i++) { + SiS_SetTrumpionBlock(SiS_Pr, &SiS300_TrumpionData[crt2crtc][0]); + } + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + if(ModeNo == 0x13) { + for(i=0; i<4; i++) { + SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode13[0]); + } + } else if(ModeNo == 0x10) { + for(i=0; i<4; i++) { + SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode10_1[0]); + SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode10_2[0]); + } + } + } + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); + } +#endif - 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); - } + 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,~0x07,0x03); + tempax = SiS_Pr->SiS_HDE; /* Blps = lcdhdee(lcdhdes+HDE) + 64 */ + if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || + SiS_Pr->SiS_LCDResInfo == Panel_640x480_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 == Panel_640x480_2 || + SiS_Pr->SiS_LCDResInfo == Panel_640x480_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 == Panel_640x480_2 || + SiS_Pr->SiS_LCDResInfo == Panel_640x480_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 == Panel_640x480_2 || + SiS_Pr->SiS_LCDResInfo == Panel_640x480_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 == Panel_640x480_2 || + SiS_Pr->SiS_LCDResInfo == Panel_640x480_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 */ } +#endif /* SIS315H */ } -void -SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension) +/* Set Part 1 */ +static void +SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) { - 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 }; +#if defined(SIS300) || defined(SIS315H) + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; +#endif + USHORT temp=0, tempax=0, tempbx=0, tempcx=0, bridgeadd=0; + USHORT pushbx=0, CRT1Index=0, modeflag, resinfo=0; +#ifdef SIS315H + USHORT tempbl=0; +#endif - SiS_Pr->SiS_LCDResInfo = 0; - SiS_Pr->SiS_LCDTypeInfo = 0; - SiS_Pr->SiS_LCDInfo = 0; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + return; + } - if(SiS_Pr->UseCustomMode) { + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else 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; - } + CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; } + SiS_SetCRT2Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + + if( ! ((HwInfo->jChipType >= SIS_315H) && + (SiS_Pr->SiS_IF_DEF_LVDS == 1) && + (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) { + + if(HwInfo->jChipType < SIS_315H ) { +#ifdef SIS300 + SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo, HwInfo); +#endif + } else { #ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x39,~0x04); - } - } + SiS_SetCRT2FIFO_310(SiS_Pr, HwInfo); #endif + } - if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return; + /* 1. Horizontal setup */ - if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2))) return; + if(HwInfo->jChipType < SIS_315H ) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); +#ifdef SIS300 /* ------------- 300 series --------------*/ -#if 0 - /* 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); - } -#endif + 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_315H) { - SiS_Pr->SiS_LCDTypeInfo = temp >> 4; - } else { - SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1; - } - temp &= 0x0f; - if(HwDeviceExtension->jChipType < SIS_315H) { - /* Translate 300 series LCDRes to 315 series for unified usage */ - temp = SiS300SeriesLCDRes[temp]; - } - SiS_Pr->SiS_LCDResInfo = temp; + temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */ -#if 0 - if(SiS_Pr->SiS_IF_DEF_FSTN){ - SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_Panel320x480; - } -#endif + 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 == 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; - } + pushbx = SiS_Pr->SiS_VGAHDE + 12; /* bx BTVGA2HRS 0x0B,0x0C */ + tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2; + tempbx = pushbx + tempcx; + tempcx <<= 1; + tempcx += tempbx; + + bridgeadd = 12; - 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; - } +#endif /* SIS300 */ - 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; + } 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--; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,tempcx); /* CRT2 Horizontal Total */ + temp = (tempcx >> 4) & 0xF0; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0F,temp); /* CRT2 Horizontal Total Overflow [7:4] */ + + 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; + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,tempbx); /* CRT2 Horizontal Display Enable End */ + + pushbx = tempbx; + tempcx >>= 1; + tempbx += tempcx; + tempcx += tempbx; + + bridgeadd = 16; + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(HwInfo->jChipType >= SIS_661) { + if((SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) || + (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { + if(resinfo == SIS_RI_1280x1024) { + tempcx = (tempcx & 0xff00) | 0x30; + } else if(resinfo == SIS_RI_1600x1200) { + tempcx = (tempcx & 0xff00) | 0xff; + } + } + } + } + +#endif /* SIS315H */ + + } /* 315/330 series */ + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CHSyncStart + bridgeadd; + tempcx = SiS_Pr->CHSyncEnd + bridgeadd; + tempax = SiS_Pr->SiS_VGAHT; + if(modeflag & HalfDCLK) tempax >>= 1; + tempax--; + if(tempcx > tempax) tempcx = tempax; + } + + 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 += bridgeadd; + tempcx += bridgeadd; + tempax = SiS_Pr->SiS_VGAHT; + if(modeflag & HalfDCLK) tempax >>= 1; + tempax--; + if(tempcx > tempax) tempcx = tempax; + } + + if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { + tempbx = 1040; + tempcx = 1044; /* HWCursor bug! */ + } + } - } + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,tempbx); /* CRT2 Horizontal Retrace Start */ + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,tempcx); /* CRT2 Horizontal Retrace End */ + + temp = ((tempbx >> 8) & 0x0F) | ((pushbx >> 4) & 0xF0); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0C,temp); /* Overflow */ + + /* 2. Vertical setup */ - 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_GetReg1(SiS_Pr->SiS_P3d4,0x37); -#if 0 - if(SiS_Pr->SiS_IF_DEF_FSTN){ - /* Fake LVDS bridge for FSTN */ - temp = 0x04; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,temp); - } -#endif - SiS_Pr->SiS_LCDInfo = temp; + tempcx = SiS_Pr->SiS_VGAVT - 1; + temp = tempcx & 0x00FF; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { - SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20; /* neg sync, RGB24 */ + 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 */ + + tempbx = SiS_Pr->SiS_VGAVDE - 1; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,tempbx); /* CRT2 Vertical Display Enable End */ + + temp = ((tempbx >> 5) & 0x38) | ((tempcx >> 8) & 0x07); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,temp); /* Overflow */ + + 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(!(SiS_Pr->UsePanelScaler)) SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; - else if(SiS_Pr->UsePanelScaler == 1) SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - 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) { - /* Bridge does not scale to 1280x960 */ - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { - /* TEMP - 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) { - /* Bridge does not scale to 1280x1024 */ - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { - /* TEMP - no idea about the timing and zoom factors */ - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CVSyncStart; + tempcx = SiS_Pr->CVSyncEnd; } - if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { + unsigned char cr8, cr7, cr13; + if(SiS_Pr->UseCustomMode) { + cr8 = SiS_Pr->CCRT1CRTC[8]; + cr7 = SiS_Pr->CCRT1CRTC[7]; + cr13 = SiS_Pr->CCRT1CRTC[13]; + tempcx = 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]; + tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9]; } - } + tempbx = cr8; + if(cr7 & 0x04) tempbx |= 0x0100; + if(cr7 & 0x80) tempbx |= 0x0200; + if(cr13 & 0x08) tempbx |= 0x0400; + } } - } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,tempbx); /* CRT2 Vertical Retrace Start */ + temp = ((tempbx >> 4) & 0x70) | (tempcx & 0x0F); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x11,temp); /* CRT2 Vert. Retrace End; Overflow */ - if(HwDeviceExtension->jChipType >= SIS_315H) { -#ifdef SIS315H - 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[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - if(!(ROMAddr[0x235] & 0x02)) { - SiS_Pr->SiS_LCDInfo &= 0xEF; - } + /* 3. Panel delay compensation */ + + if(HwInfo->jChipType < SIS_315H) { + +#ifdef SIS300 /* ---------- 300 series -------------- */ + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp = 0x20; + if(HwInfo->jChipType == SIS_300) { + temp = 0x10; + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) temp = 0x2c; + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) temp = 0x20; + } + if(SiS_Pr->SiS_VBType & VB_SIS301) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) temp = 0x20; + } + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x960) temp = 0x24; + if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) 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_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 == Panel_1280x1024) + temp = ROMAddr[0x223]; + else + temp = ROMAddr[0x224]; + temp &= 0x3c; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC & 0x3c; + } + + } else { + temp = 0x20; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { + if(SiS_Pr->SiS_LCDResInfo == Panel_640x480) temp = 0x04; + } + if(SiS_Pr->SiS_UseROM) { + if(ROMAddr[0x220] & 0x80) { + temp = ROMAddr[0x220] & 0x3c; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC & 0x3c; } } - } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10))) { - SiS_Pr->SiS_LCDInfo &= 0xEF; - } - } -#endif - } - /* Trumpion: Assume non-expanding */ - if(SiS_Pr->SiS_IF_DEF_TRUMPION != 0) { - SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); - } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */ + +#endif /* SIS300 */ - if(!((HwDeviceExtension->jChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) { + } else { - 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; +#ifdef SIS315H /* --------------- 315/330 series ---------------*/ + + if(HwInfo->jChipType < SIS_661) { + + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + + 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; } - } - } - } - if(ModeNo == 0x12) { - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } + + if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) { + temp = 0x08; + tempbl = 0; + if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { + if(ROMAddr[0x13c] & 0x80) tempbl = 0xf0; + } + } + + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,tempbl,temp); /* Panel Link Delay Compensation */ } - } - } - 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 == 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; + } /* < 661 */ + + tempax = 0; + if(modeflag & DoubleScanMode) tempax |= 0x80; + if(modeflag & HalfDCLK) tempax |= 0x40; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax); + +#endif /* SIS315H */ + } - } + } /* Slavemode */ - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) { - SiS_Pr->SiS_SetFlag |= LCDVESATiming; - } + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + /* For 301BDH with LCD, we set up the Panel Link */ + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SiS_SetGroup1_301(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + } } else { - SiS_Pr->SiS_SetFlag |= LCDVESATiming; - } - -#ifdef SIS315H - 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) - */ - if((SiS_Pr->SiS_CustomT == CUT_CLEVO1024) && - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)) { - /* (Sets this in SenseLCD; new paneltypes) */ - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x39,0x04); - } - 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_SetRegOR(SiS_Pr->SiS_P3d4,0x39,0x04); + if(HwInfo->jChipType < SIS_315H) { + 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); + } + } else { + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex, HwInfo,RefreshRateTableIndex); } } } -#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 - } -void -SiS_LongWait(SiS_Private *SiS_Pr) +/*********************************************/ +/* SET PART 2 REGISTER GROUP */ +/*********************************************/ + +#ifdef SIS315H +static UCHAR * +SiS_GetGroup2CLVXPtr(SiS_Private *SiS_Pr, int tabletype, PSIS_HW_INFO HwInfo) { - USHORT i; + const UCHAR *tableptr = NULL; + USHORT a, b, p = 0; - i = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1F); + a = SiS_Pr->SiS_VGAHDE; + b = SiS_Pr->SiS_HDE; + if(tabletype) { + a = SiS_Pr->SiS_VGAVDE; + b = SiS_Pr->SiS_VDE; + } - 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; - } - } + 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_VBLongWait(SiS_Private *SiS_Pr) +static void +SiS_SetGroup2_C_ELV(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { - SiS_VBWait(SiS_Pr); - } else { - SiS_LongWait(SiS_Pr); - } -} + UCHAR *tableptr; + int i, j; + UCHAR temp; -void -SiS_VBWait(SiS_Private *SiS_Pr) -{ - USHORT tempal,temp,i,j; + if(!(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV))) return; - 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; - } + 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_WaitVBRetrace(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +static BOOLEAN +SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,USHORT *CRT2Index, + USHORT *ResIndex,PSIS_HW_INFO HwInfo) { - 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(HwInfo->jChipType < SIS_315H) return FALSE; + + if(ModeNo <= 0x13) + (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + else + (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; -void -SiS_WaitRetrace1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT watchdog; -#ifdef SIS300 - USHORT i; -#endif + (*ResIndex) &= 0x3f; + (*CRT2Index) = 0; - 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 /* Not done in A901 BIOS */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return; + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + (*CRT2Index) = 200; } -#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; + } + + if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) (*CRT2Index) = 206; } -#endif } + return(((*CRT2Index) != 0)); } +#endif -void -SiS_WaitRetraceDDC(SiS_Private *SiS_Pr) +#ifdef SIS300 +static void +SiS_Group2LCDSpecial(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT crt2crtc) { - USHORT watchdog; + USHORT tempcx; + const UCHAR atable[] = { + 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02, + 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02 + }; - 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(!SiS_Pr->UseCustomMode) { + if( ( ( (HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730) ) && + (HwInfo->jChipRevision > 2) ) && + (SiS_Pr->SiS_LCDResInfo == Panel_1024x768) && + (!(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); + } + } + } + + 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]); + } + } + } } -void -SiS_WaitRetrace2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +/* For ECS A907. Highly preliminary. */ +static void +SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeIdIndex, USHORT RefreshRateTableIndex, + USHORT ModeNo) { - USHORT watchdog; -#ifdef SIS300 - USHORT i; -#endif + USHORT crt2crtc, resindex; + int i,j; + const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; - 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 + if(HwInfo->jChipType != SIS_300) return; + if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; + if(SiS_Pr->UseCustomMode) return; + + if(ModeNo <= 0x13) { + crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; } else { -#ifdef SIS300 - for(i=0; i<10; i++) { - watchdog = 65535; - while( (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x25) & 0x02) && --watchdog); - if(watchdog) break; - } - for(i=0; i<10; i++) { - watchdog = 65535; - while( (!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x25) & 0x02)) && --watchdog); - if(watchdog) break; - } -#endif + crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; } -} -/* =========== Set and Get register routines ========== */ + resindex = crt2crtc & 0x3F; + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; + else CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_2; -void -SiS_SetRegANDOR(USHORT Port,USHORT Index,USHORT DataAND,USHORT DataOR) -{ - USHORT temp; + /* 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 = (temp & (DataAND)) | DataOR; - 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_SetRegAND(USHORT Port,USHORT Index,USHORT DataAND) +static void +SiS_SetTVSpecial(SiS_Private *SiS_Pr, USHORT ModeNo) { - USHORT temp; - - temp = SiS_GetReg1(Port,Index); - temp &= DataAND; - SiS_SetReg1(Port,Index,temp); + if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) return; + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) return; + + 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); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1b); + } else { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x14); /* 15 */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1a); /* 1b */ + } + } + } + } else { + if((ModeNo == 0x38) || (ModeNo == 0x4a) || (ModeNo == 0x64) || + (ModeNo == 0x52) || (ModeNo == 0x58) || (ModeNo == 0x5c)) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b); /* 21 */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54); /* 5a */ + } else { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1a); /* 21 */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x53); /* 5a */ + } + } } -void SiS_SetRegOR(USHORT Port,USHORT Index,USHORT DataOR) +static void +SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo) { USHORT temp; - temp = SiS_GetReg1(Port,Index); - temp |= DataOR; - SiS_SetReg1(Port,Index,temp); -} - -/* ========================================================= */ + 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); + } + } -static void -SiS_SetTVSpecial(SiS_Private *SiS_Pr, USHORT ModeNo) -{ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((ModeNo == 0x64) || (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); /* 48 */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2d,0xe4); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2e,0x73); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,0xda); /* de */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0x13); - if((SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38)) & 0x40) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x14); - } else { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x15); - } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x1b); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,0x72); - } - } else { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x21); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x5a); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) { + if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x1a,0x03); + /* Not always for LV, see SetGrp2 */ + } + temp = 1; + if(ModeNo <= 0x13) temp = 3; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0b,temp); + } +#if 0 + /* 651+301C, for 1280x768 - do I really need that? */ + if((SiS_Pr->SiS_PanelXRes == 1280) && (SiS_Pr->SiS_PanelYRes == 768)) { + if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { + if(((SiS_Pr->SiS_HDE == 640) && (SiS_Pr->SiS_VDE == 480)) || + ((SiS_Pr->SiS_HDE == 320) && (SiS_Pr->SiS_VDE == 240))) { + SiS_SetReg(SiS_Part2Port,0x01,0x2b); + SiS_SetReg(SiS_Part2Port,0x02,0x13); + SiS_SetReg(SiS_Part2Port,0x04,0xe5); + SiS_SetReg(SiS_Part2Port,0x05,0x08); + SiS_SetReg(SiS_Part2Port,0x06,0xe2); + SiS_SetReg(SiS_Part2Port,0x1c,0x21); + SiS_SetReg(SiS_Part2Port,0x1d,0x45); + SiS_SetReg(SiS_Part2Port,0x1f,0x0b); + SiS_SetReg(SiS_Part2Port,0x20,0x00); + SiS_SetReg(SiS_Part2Port,0x21,0xa9); + SiS_SetReg(SiS_Part2Port,0x23,0x0b); + SiS_SetReg(SiS_Part2Port,0x25,0x04); + } } } +#endif } } -/* 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, tempch, tempcl, temp; + USHORT push2, modeflag, crt2crtc, bridgeoffset; + ULONG longtemp; 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; -#ifdef SIS300 - const UCHAR atable[] = { - 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02, - 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02 - }; -#endif + const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; -#ifdef SIS315H - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - /* 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 = 0x01; - if(ModeNo <= 0x13) temp = 0x03; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0b,temp); - } - } - SiS_SetTVSpecial(SiS_Pr, ModeNo); - return; - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; #endif if(ModeNo <= 0x13) { modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + crt2crtc = 0; } else { - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - resinfo = 0; - crt2crtc = 0; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - } + 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; + 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; - /* 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; - } + 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 & SetCRT2ToHiVision) { + + TimingPoint = SiS_Pr->SiS_HiTVExtTiming; 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; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + TimingPoint = SiS_Pr->SiS_HiTVSt1Timing; +#if 0 + if(!(modeflag & Charx8Dot)) TimingPoint = SiS_Pr->SiS_HiTVTextTiming; +#endif } - } else TimingPoint = SiS_Pr->SiS_HiTVExtTiming; - - if(SiS_Pr->SiS_HiVision & 0x03) temp &= 0xfe; + } - } else { + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_VBInfo & SetPALTV){ + 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]; - TimingPoint = SiS_Pr->SiS_PALTiming; - PhasePoint = SiS_Pr->SiS_PALPhase; + PhasePoint = SiS_Pr->SiS_NTSCPhase; - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALPhase2; - } + } else if(SiS_Pr->SiS_TVMode & TVSetPAL) { - } else { + if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && + ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { + PhasePoint = SiS_Pr->SiS_PALPhase2; + } - temp |= 0x10; - TimingPoint = SiS_Pr->SiS_NTSCTiming; - PhasePoint = SiS_Pr->SiS_NTSCPhase; + } else { - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_NTSCPhase2; - } + 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(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; + } } - 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_SIS301BLV302BLV) && - ( (!(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_SIS301BLV302BLV) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALNPhase2; - } - } - } + + 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; } } -#ifdef SIS315H - 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 == 0x64) || (ModeNo == 0x4a) || (ModeNo == 0x38)) { - PhasePoint = SiS_Pr->SiS_SpecialPhase; - } - } - } + 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)) - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F); - } else { + if(SiS_Pr->SiS_ModeType != ModeText) { 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); + 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 & 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 & SetCRT2ToHiVision) tempax = 950; + else if(SiS_Pr->SiS_TVMode & TVSetPAL) tempax = 520; + else tempax = 440; /* NTSC, YPbPr 525, 750 */ - 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)) ) ) ) { + 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); - - 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); + 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); + + if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) && (SiS_Pr->SiS_VGAHDE >= 1024)) { + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b); /* 19 */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54); /* 52 */ } 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; - - /* 650/30xLV 1.10.6s */ - if(SiS_IsDualLink(SiS_Pr, HwDeviceExtension, BaseAddr)) { - tempcx >>= 1; - } - + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; tempcx--; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - tempcx--; - } - temp = tempcx & 0x00FF; - SiS_SetReg1(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++; - } - tempcx >>= 1; - - push1 = tempcx; - + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) tempcx--; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1B,tempcx); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0xF0,((tempcx >> 8) & 0x0f)); + + tempcx = SiS_Pr->SiS_HT >> 1; + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; tempcx += 7; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (SiS_Pr->SiS_HiVision == 3)) { - tempcx -= 4; - } - temp = (tempcx & 0x00FF) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x22,0x0F,temp); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4; + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x22,0x0F,((tempcx << 4) & 0xf0)); - tempbx = TimingPoint[j] | ((TimingPoint[j+1]) << 8); + tempbx = TimingPoint[j] | (TimingPoint[j+1] << 8); tempbx += tempcx; - - push2 = tempbx; - - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,temp); - temp = ((tempbx & 0xFF00) >> 8) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0F,temp); - - tempbx = push2; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x24,tempbx); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0F,((tempbx >> 4) & 0xf0)); tempbx += 8; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (SiS_Pr->SiS_HiVision == 3)) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { tempbx -= 4; tempcx = tempbx; } - temp = (tempbx & 0x00FF) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x29,0x0F,temp); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x29,0x0F,((tempbx << 4) & 0xf0)); j += 2; - tempcx += ((TimingPoint[j] | ((TimingPoint[j+1]) << 8))); - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,temp); - temp = ((tempcx & 0xFF00) >> 8) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x28,0x0F,temp); + tempcx += (TimingPoint[j] | (TimingPoint[j+1] << 8)); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x27,tempcx); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x28,0x0F,((tempcx >> 4) & 0xf0)); tempcx += 8; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (SiS_Pr->SiS_HiVision == 3)) { - tempcx -= 4; - } - temp = (tempcx & 0x00FF) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2A,0x0F,temp); - - tempcx = push1; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4; + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2A,0x0F,((tempcx << 4) & 0xf0)); + tempcx = SiS_Pr->SiS_HT >> 1; + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; j += 2; tempcx -= (TimingPoint[j] | ((TimingPoint[j+1]) << 8)); - temp = (tempcx & 0x00FF) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2D,0x0F,temp); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2D,0x0F,((tempcx << 4) & 0xf0)); 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,tempcx); 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; - } 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) /* BIOS calls GetRatePtrCRT2 here - does not make sense */ - if(SiS_Pr->SiS_ModeType <= 3) tempbx++; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_VGAVDE == 360) tempbx = 746; + if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 746; + if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 853; + } else if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && + (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p))) ) { + tempbx >>= 1; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + if((ModeNo <= 0x13) && (crt2crtc == 1)) tempbx++; + } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(SiS_Pr->SiS_ModeType <= ModeVGA) { + if(crt2crtc == 4) 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) || (ModeNo == 0x5d) || (ModeNo == 0x5e)) temp++; - } - } - /* From 1.10.7w - doesn't make sense */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { /* SetFlag?? */ - if(ModeNo == 0x03) 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)) { /* New from 630/301B (II) BIOS */ - tempax |= 0x1000; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) tempax |= 0x2000; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + if((ModeNo == 0x2f) || (ModeNo == 0x5d) || (ModeNo == 0x5e)) tempbx++; + } + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + if(ModeNo == 0x03) tempbx++; /* From 1.10.7w - doesn't make sense */ } } - } 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); + tempbx -= 2; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2F,tempbx); - if(HwDeviceExtension->jChipType > SIS_315H) { - 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); - } - } + temp = (tempcx >> 8) & 0x0F; + temp |= ((tempbx >> 2) & 0xC0); + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) { + temp |= 0x10; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToAVIDEO) temp |= 0x20; + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,temp); + + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xdf,((tempbx & 0x0400) >> 5)); } - 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]); - } - for(i=0x39; i<=0x45; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS_HiVisionTable[SiS_Pr->SiS_HiVision][j]); - } +#if 0 + /* TEST qqqq */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + for(i=0x01, j=0; i<=0x2D; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); + } + for(i=0x39; i<=0x45; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); } } +#endif if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { tempbx = SiS_Pr->SiS_VDE; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) { + if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && + (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) ) { 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); - if(HwDeviceExtension->jChipType >= SIS_315H) { - 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); - } + temp = ((tempbx >> 3) & 0x60) | 0x18; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x46,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x47,tempbx); + + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xbf,((tempbx & 0x0400) >> 4)); } } - tempbx &= 0x00FF; + tempbx = 0; if(!(modeflag & HalfDCLK)) { if(SiS_Pr->SiS_VGAHDE >= SiS_Pr->SiS_HDE) { - tempbx |= 0x2000; - tempax &= 0x00FF; + tempax = 0; + tempbx |= 0x20; } } - tempcx = 0x0101; -/*if(SiS_Pr->SiS_VBInfo & (SetPALTV | SetCRT2ToTV)) { */ /* 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)) { - tempcx = 0x1920; - if(SiS_Pr->SiS_VGAHDE >= 1280) { - tempcx = 0x1420; - tempbx &= 0xDFFF; - } + tempch = tempcl = 0x01; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_VGAHDE >= 1024) { + if((!(modeflag & HalfDCLK)) || (HwInfo->jChipType < SIS_315H)) { + tempch = 0x19; + tempcl = 0x20; + if(SiS_Pr->SiS_VGAHDE >= 1280) { + tempch = 0x14; + tempbx &= ~0x20; } } } } - if(!(tempbx & 0x2000)) { - 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; - } - tempeax = longtemp / SiS_Pr->SiS_HDE; - if(longtemp % SiS_Pr->SiS_HDE) tempeax++; - tempax = (USHORT)tempeax; - tempcx = (tempcx & 0xFF00) | ((tempax & 0xFF00) >> (8 + 5)); - tempbx |= (tempax & 0x1F00); - tempax = ((tempax & 0x00FF) << 8) | (tempax & 0x00FF); + if(!(tempbx & 0x20)) { + if(modeflag & HalfDCLK) tempcl <<= 1; + longtemp = ((SiS_Pr->SiS_VGAHDE * tempch) / tempcl) << 13; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) longtemp <<= 3; + tempax = longtemp / SiS_Pr->SiS_HDE; + if(longtemp % SiS_Pr->SiS_HDE) tempax++; + tempbx |= ((tempax >> 8) & 0x1F); + tempcx = tempax >> 13; } - 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); 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) { + tempcx &= 0x07; + if(tempbx & 0x20) tempcx = 0; + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x46,0xF8,tempcx); + + if(SiS_Pr->SiS_TVMode & TVSetPAL) { 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); - temp = (tempcx & 0x0300) >> (8 - 2); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4B,tempbx); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4C,tempcx); + temp = (tempcx & 0x0300) >> 6; temp |= ((tempbx >> 8) & 0x03); - if(HwDeviceExtension->jChipType < SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4D,temp); - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4D,0xF0,temp); + 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 = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x43); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,(USHORT)(temp - 3)); - } + temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,(temp - 3)); - 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); - } - } + 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(HwDeviceExtension->jChipType >= SIS_315H) { - if((SiS_Pr->SiS_VBType & VB_SIS301B302B) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0B,0x00); - } + 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)); } + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xEF); } -#if 0 /* Old: Why HiVision? */ - if( (SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && - (!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) ) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0B,0x00); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0B,0x00); } } -#endif - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_Set300Part2Regs(SiS_Pr, HwDeviceExtension, ModeIdIndex, - RefreshRateTableIndex, BaseAddr, ModeNo); - return; - } - } else { - /* !!! The following is a duplicate, done for LCDA as well (see above) */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_SetTVSpecial(SiS_Pr, ModeNo); - return; - } - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) return; /* From here: Part2 LCD setup */ tempbx = SiS_Pr->SiS_HDE; - if(SiS_IsDualLink(SiS_Pr, HwDeviceExtension, BaseAddr)) tempbx >>= 1; - tempbx--; /* RHACTE=HDE-1 */ - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2C,temp); - temp = (tempbx & 0xFF00) >> 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,temp); + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + tempbx--; /* RHACTE = HDE - 1 */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2C,tempbx); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,((tempbx >> 4) & 0xf0)); temp = 0x01; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { if(SiS_Pr->SiS_ModeType == ModeEGA) { if(SiS_Pr->SiS_VGAHDE >= 1024) { temp = 0x02; - if(HwDeviceExtension->jChipType >= SIS_315H) { + if(HwInfo->jChipType >= SIS_315H) { if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { temp = 0x01; } @@ -7868,66 +7116,22 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo } } } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0B,temp); - - tempbx = SiS_Pr->SiS_VDE; /* RTVACTEO = VDE - 1 */ - /* push1 = tempbx; */ - tempbx--; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x03,temp); - temp = ((tempbx & 0xFF00) >> 8) & 0x07; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0C,0xF8,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0B,temp); - tempcx = SiS_Pr->SiS_VT; - /* push2 = tempcx; */ - tempcx--; - temp = tempcx & 0x00FF; /* RVTVT = VT - 1 */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x19,temp); + tempbx = SiS_Pr->SiS_VDE - 1; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x03,tempbx); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0C,0xF8,((tempbx >> 8) & 0x07)); - 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) { - temp |= 0x10; - } else { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { /* 32bpp mode? */ - temp |= 0x10; - } - } - } else { + tempcx = SiS_Pr->SiS_VT - 1; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x19,tempcx); + temp = (tempcx >> 3) & 0xE0; + if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { + /* Enable dithering; only do this for 32bpp mode */ + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { temp |= 0x10; } } - - /* 630/301 does not do all this */ - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - if((HwDeviceExtension->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { - 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))) { -#ifdef SIS315H - if(SiS_Pr->SiS_LCDInfo & LCDSync) { - temp |= (SiS_Pr->SiS_LCDInfo >> 6); - } -#endif - } else { - 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 */ - } - } else { - if(SiS_Pr->SiS_LCDInfo & LCDSync) { - temp |= (SiS_Pr->SiS_LCDInfo >> 6); - } - } - } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1A,temp); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1A,0x0f,temp); SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x09,0xF0); SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x0A,0xF0); @@ -7935,115 +7139,57 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x17,0xFB); SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x18,0xDF); - if((HwDeviceExtension->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 ------------ */ - - /* 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. - */ - - SiS_GetCRT2Part2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&resindex,HwDeviceExtension,BaseAddr); - +#ifdef SIS315H + if(SiS_GetCRT2Part2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + &CRT2Index, &resindex, HwInfo)) { switch(CRT2Index) { - case Panel_1024x768 : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; break; /* "Normal" */ - case Panel_1280x1024 : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1280x1024_1; break; - case Panel_1400x1050 : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1400x1050_1; break; - case Panel_1600x1200 : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1600x1200_1; break; - case Panel_1024x768 + 16: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_2; break; /* Non-Expanding */ - case Panel_1280x1024 + 16: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1280x1024_2; break; - case Panel_1400x1050 + 16: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1400x1050_2; break; - case Panel_1600x1200 + 16: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1600x1200_2; break; - case Panel_1024x768 + 32: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_3; break; /* VESA Timing */ - 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; - default: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_3; break; + case 200: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; break; + case 206: CRT2Part2Ptr = 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)) { - 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_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp); - SiS_SetReg1(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_SetGroup2_Tail(SiS_Pr, ModeNo); - /* !!! 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 */ - temp = 1; - if(ModeNo <= 0x13) temp = 3; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0b,temp); - } - } + + } else { #endif - - } 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 bridge scales all modes to 1024. - * !!! Malfunction at 640x480 and 640x400 when panel is auto-expanding - black screen !!! - */ - - /* cx = VT - 1 */ - - tempcx++; - - tempbx = SiS_Pr->PanelYRes; + + /* Checked for 1024x768, 1280x1024, 1400x1050, 1600x1200 */ + /* Clevo dual-link 1024x768 */ + /* Compaq 1280x1024 has HT 1696 sometimes (calculation OK, if given HT is correct) */ + /* Acer: OK, but uses different setting for VESA timing at 640/800/1024 and 640x400 */ if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - tempbx = SiS_Pr->SiS_VDE - 1; - tempcx--; - } - - tempax = 1; - if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - if(tempbx != SiS_Pr->SiS_VDE) { - tempax = tempbx; - if(tempax < SiS_Pr->SiS_VDE) { - tempax = 0; - tempcx = 0; + if((SiS_Pr->SiS_LCDInfo & LCDPass11) || (SiS_Pr->PanelYRes == SiS_Pr->SiS_VDE)) { + tempbx = SiS_Pr->SiS_VDE - 1; + tempcx = SiS_Pr->SiS_VT - 1; + } else { + tempbx = SiS_Pr->SiS_VDE + ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VDE) / 2); + tempcx = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VDE) / 2); + } + } else { + tempbx = SiS_Pr->PanelYRes; + tempcx = SiS_Pr->SiS_VT; + tempax = 1; + if(SiS_Pr->PanelYRes != SiS_Pr->SiS_VDE) { + tempax = SiS_Pr->PanelYRes; + /* if(SiS_Pr->SiS_VGAVDE == 525) tempax += 0x3c; */ /* 651+301C */ + if(SiS_Pr->PanelYRes < SiS_Pr->SiS_VDE) { + tempax = tempcx = 0; } else { tempax -= SiS_Pr->SiS_VDE; } @@ -8052,37 +7198,56 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo tempcx -= tempax; /* lcdvdes */ tempbx -= tempax; /* lcdvdee */ } -#if 0 /* meaningless: 1 / 2 = 0... */ - else { - tempax >>= 1; - tempcx -= tempax; /* lcdvdes */ - tempbx -= tempax; /* lcdvdee */ - } -#endif - /* Non-expanding: lcdvdees = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */ + /* Non-expanding: lcdvdes = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */ #ifdef TWDEBUG 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); - temp = tempbx & 0x00FF; /* RVEQ2EQ=lcdvdee */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,tempcx); /* lcdvdes */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,tempbx); /* lcdvdee */ + + temp = (tempbx >> 5) & 0x38; + temp |= ((tempcx >> 8) & 0x07); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp); - temp = ((tempbx & 0xFF00) >> 8) << 3; - temp |= ((tempcx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,temp); + tempax = SiS_Pr->SiS_VDE; + if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { + tempax = SiS_Pr->PanelYRes; + } + tempcx = (SiS_Pr->SiS_VT - tempax) >> 4; + if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { + if(SiS_Pr->PanelYRes != SiS_Pr->SiS_VDE) { + tempcx = (SiS_Pr->SiS_VT - tempax) / 10; + } + } - 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; + tempbx = ((SiS_Pr->SiS_VT + SiS_Pr->SiS_VDE) >> 1) - 1; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->PanelYRes != SiS_Pr->SiS_VDE) { + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { /* ? */ + tempax = SiS_Pr->SiS_VT - SiS_Pr->PanelYRes; + if(tempax % 4) { tempax >>= 2; tempax++; } + else { tempax >>= 2; } + tempbx -= (tempax - 1); + } else { + tempbx -= 10; + if(tempbx <= SiS_Pr->SiS_VDE) tempbx = SiS_Pr->SiS_VDE + 1; + } + } + } + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + tempbx++; + if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (crt2crtc == 6)) { + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + tempbx = 770; + tempcx = 3; + } + } + } - /* non-expanding: lcdvrs = tempbx = ((VT + VDE) / 2) - 10 */ + /* non-expanding: lcdvrs = ((VT + VDE) / 2) - 10 */ if(SiS_Pr->UseCustomMode) { tempbx = SiS_Pr->CVSyncStart; @@ -8092,12 +7257,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo xf86DrvMsg(0, X_INFO, "lcdvrs 0x%x\n", tempbx); #endif - temp = tempbx & 0x00FF; /* RTVACTEE = lcdvrs */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,tempbx); /* lcdvrs */ - temp = ((tempbx & 0xFF00) >> 8) << 4; + temp = (tempbx >> 4) & 0xF0; tempbx += (tempcx + 1); - temp |= (tempbx & 0x000F); + temp |= (tempbx & 0x0F); if(SiS_Pr->UseCustomMode) { temp &= 0xf0; @@ -8108,545 +7272,253 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo xf86DrvMsg(0, X_INFO, "lcdvre[3:0] 0x%x\n", (temp & 0x0f)); #endif - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,temp); - - /* Code from 630/301B (I+II) BIOS */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); - if(!SiS_Pr->UseCustomMode) { - 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); - } - } - } - } +#ifdef SIS300 + SiS_Group2LCDSpecial(SiS_Pr, HwInfo, ModeNo, crt2crtc); +#endif -#ifdef SIS300 - if(HwDeviceExtension->jChipType < SIS_315H) { - if(!SiS_Pr->UseCustomMode) { - 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); - } + bridgeoffset = 7; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) bridgeoffset += 2; + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) bridgeoffset++; + if(SiS_IsDualLink(SiS_Pr, HwInfo)) bridgeoffset++; - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(crt2crtc == 4) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x28); - } - } - } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x18); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]); - } + temp = 0; + if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { + if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) { + temp = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2); + if(SiS_IsDualLink(SiS_Pr, HwInfo)) temp >>= 1; } } -#endif - - 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; + temp += bridgeoffset; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1F,temp); /* lcdhdes */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x20,0x0F,((temp >> 4) & 0xf0)); + + tempcx = SiS_Pr->SiS_HT; + tempax = tempbx = SiS_Pr->SiS_HDE; + if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { + if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) { + tempax = SiS_Pr->PanelXRes; + tempbx = SiS_Pr->PanelXRes - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2); + } + } + if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + tempcx >>= 1; + tempbx >>= 1; + tempax >>= 1; } - push1 = tempbx; #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdhdee 0x%x\n", tempbx); #endif - temp = tempbx & 0x00FF; /* RHEQPLE = lcdhdee */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,temp); - temp = (tempbx & 0xFF00) >> 8; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0xF0,temp); + tempbx += bridgeoffset; - temp = 7; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - temp += 2; - } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1F,temp); /* RHBLKE = lcdhdes[7:0] */ - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x20,0x0F); /* lcdhdes [11:8] */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,tempbx); /* lcdhdee */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0xF0,((tempbx >> 8) & 0x0f)); + + tempcx = (tempcx - tempax) >> 2; tempbx += tempcx; push2 = tempbx; - if(SiS_Pr->UseCustomMode) { - tempbx = SiS_Pr->CHSyncStart + 7; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - tempbx += 2; + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + if(SiS_Pr->SiS_HDE == 1280) tempbx = (tempbx & 0xff00) | 0x47; + } } } + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CHSyncStart; + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + tempbx += bridgeoffset; + } + #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdhrs 0x%x\n", tempbx); #endif - 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 & 0x0F00) >> 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1C,tempbx); /* lcdhrs */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,((tempbx >> 4) & 0xf0)); tempbx = push2; + tempcx <<= 1; + if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { + if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) tempcx >>= 2; + } tempbx += tempcx; if(SiS_Pr->UseCustomMode) { - tempbx = SiS_Pr->CHSyncEnd + 7; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - tempbx += 2; - } + tempbx = SiS_Pr->CHSyncEnd; + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + tempbx += bridgeoffset; } #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); - - 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); - } - } - SiS_Set300Part2Regs(SiS_Pr, HwDeviceExtension, ModeIdIndex, - RefreshRateTableIndex, BaseAddr, ModeNo); - - } /* HwDeviceExtension */ -} + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,tempbx); /* lcdhre */ -USHORT -SiS_GetVGAHT2(SiS_Private *SiS_Pr) -{ - ULONG tempax,tempbx; + SiS_SetGroup2_Tail(SiS_Pr, ModeNo); - 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); +#ifdef SIS300 + SiS_Set300Part2Regs(SiS_Pr, HwInfo, ModeIdIndex, RefreshRateTableIndex, ModeNo); +#endif +#ifdef SIS315H + } /* CRT2-LCD from table */ +#endif } -/* 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) -{ - USHORT crt2crtc, resindex; - int i,j; - const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; - - if(HwDeviceExtension->jChipType != SIS_300) return; - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; - if(SiS_Pr->UseCustomMode) return; - - 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) is obviously a fragment! */ - if(ModeNo > 0x13) { - CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; - resindex = 4; - } - - 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]); - } - for(j = 0x1c; j <= 0x1d; i++, j++ ) { - SiS_SetReg1(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_SetReg1(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]); - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]); -} +/*********************************************/ +/* SET PART 3 REGISTER GROUP */ +/*********************************************/ -void -SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { - USHORT temp; - USHORT i; - const UCHAR *tempdi; - USHORT modeflag; + USHORT i; + const UCHAR *tempdi; if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; - 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; - } - } - #ifndef SIS_CP - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x00,0x00); -#endif - -#ifdef SIS_CP + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x00,0x00); +#else SIS_CP_INIT301_CP #endif - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xFA); - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xC8); + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xFA); + SiS_SetReg(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); - } + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xF5); + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xB7); } - 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); - } - } - } + 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); } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { + tempdi = NULL; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { tempdi = SiS_Pr->SiS_HiTVGroup3Data; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { tempdi = SiS_Pr->SiS_HiTVGroup3Simu; - if(!(modeflag & Charx8Dot)) { - tempdi = SiS_Pr->SiS_HiTVGroup3Text; - } } - if(SiS_Pr->SiS_HiVision & 0x03) { + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(!(SiS_Pr->SiS_TVMode & TVSetYPbPr525i)) { tempdi = SiS_HiTVGroup3_1; - if(SiS_Pr->SiS_HiVision & 0x02) tempdi = SiS_HiTVGroup3_2; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempdi = SiS_HiTVGroup3_2; } - for(i=0; i<=0x3E; i++){ - SiS_SetReg1(SiS_Pr->SiS_Part3Port,i,tempdi[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); + } } } #ifdef SIS_CP SIS_CP_INIT301_CP2 #endif - } -/* 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) -{ - 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; - } 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) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_SetReg1(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(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - /* From 650/301LV (any, incl. 1.10.6s, 1.10.7w) */ - /* This is a duplicate; done at the end, too */ - if(SiS_IsDualLink(SiS_Pr, HwDeviceExtension, BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); - } -#ifdef SET_EMI - if(SiS_Pr->SiS_VBType & VB_SIS302LV) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); - } -#endif - } - return; - } - } - - temp = SiS_Pr->SiS_RVBHCFACT; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x13,temp); - - tempbx = SiS_Pr->SiS_RVBHCMAX; - temp = tempbx & 0x00FF; - SiS_SetReg1(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); - - temp = (((tempcx & 0xFF00) >> 8) << 3) & 0x00ff; - temp2 |= temp; - - tempcx = SiS_Pr->SiS_VGAVT - 1; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempcx -= 5; - - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x17,temp); - - temp = temp2 | ((tempcx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x15,temp); - - tempbx = SiS_Pr->SiS_VGAHDE; - if(modeflag & HalfDCLK) tempbx >>= 1; - - 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; - } - } else { - temp = 0x80; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - temp = 0; - if(tempbx > 800) temp = 0x60; - } - } - if(SiS_Pr->SiS_HiVision & 0x03) { - temp = 0; - if(SiS_Pr->SiS_VGAHDE == 1024) temp = 0x20; - } - - if(SiS_IsDualLink(SiS_Pr, HwDeviceExtension, BaseAddr)) temp = 0; - - if(SiS_Pr->SiS_VBType & VB_SIS301) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) - temp |= 0x0A; - } - - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0E,0x10,temp); - - tempebx = SiS_Pr->SiS_VDE; - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(!(temp & 0xE0)) tempebx >>=1; - } - - tempcx = SiS_Pr->SiS_RVBHRS; - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x18,temp); - - tempeax = SiS_Pr->SiS_VGAVDE; - tempcx |= 0x4000; - if(tempeax <= tempebx) { - tempcx ^= 0x4000; - } else { - tempeax -= tempebx; - } +/*********************************************/ +/* SET PART 4 REGISTER GROUP */ +/*********************************************/ - templong = (tempeax * 256 * 1024) % tempebx; - tempeax = (tempeax * 256 * 1024) / tempebx; - tempebx = tempeax; - if(templong != 0) tempebx++; +#ifdef SIS315H +static void +SiS_ShiftXPos(SiS_Private *SiS_Pr, int shift) +{ + USHORT temp, temp1, temp2; - temp = (USHORT)(tempebx & 0x000000FF); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1B,temp); - temp = (USHORT)((tempebx & 0x0000FF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1A,temp); + temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x1f); + temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x20); + temp = (USHORT)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1f,temp); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x20,0x0f,((temp >> 4) & 0xf0)); + temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x2b) & 0x0f; + temp = (USHORT)((int)(temp) + shift); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2b,0xf0,(temp & 0x0f)); + temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43); + temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x42); + temp = (USHORT)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,temp); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x42,0x0f,((temp >> 4) & 0xf0)); +} - tempbx = (USHORT)(tempebx >> 16); - temp = tempbx & 0x00FF; - temp <<= 4; - temp |= ((tempcx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x19,temp); +static void +SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex) +{ + USHORT temp, temp1, resinfo = 0; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(!(SiS_Pr->SiS_VBType & VB_SIS301C)) return; + if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToHiVision | SetCRT2ToYPbPr525750))) return; - 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_IsDualLink(SiS_Pr, HwDeviceExtension, BaseAddr)) tempax >>= 1; - else if(tempax > 800) tempax -= 800; - } else { - if(tempax > 800) tempax -= 800; - } - } + if(ModeNo > 0x13) { + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } -/* 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 == SIS_RI_1024x768) 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); + 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); + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) temp = 0x0000; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) temp = 0x0002; + else if(SiS_Pr->SiS_TVMode & TVSetHiVision) temp = 0x0400; + else temp = 0x0402; + if(HwInfo->jChipType >= SIS_661) { + temp1 = 0; + if(SiS_Pr->SiS_TVMode & TVAspect43) temp1 = 4; + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0f,0xfb,temp1); + if(SiS_Pr->SiS_TVMode & TVAspect43LB) temp |= 0x01; + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0x7c,(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,0xf8,(temp & 0xff)); + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8)); - 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; - } - 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(SiS_IsDualLink(SiS_Pr, HwDeviceExtension, BaseAddr)) 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); - /* LCD-too-dark-error-source, see FinalizeLCD() */ - } - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_IsDualLink(SiS_Pr, HwDeviceExtension, BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); + if(HwInfo->jChipType >= SIS_661) { /* ? */ + if(SiS_Pr->SiS_TVMode & TVAspect43) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { + if(resinfo == SIS_RI_1024x768) { + SiS_ShiftXPos(SiS_Pr, 97); + } else { + SiS_ShiftXPos(SiS_Pr, 111); } + } else if(SiS_Pr->SiS_TVMode & TVSetHiVision) { + SiS_ShiftXPos(SiS_Pr, 136); } -#ifdef SET_EMI - if(SiS_Pr->SiS_VBType & VB_SIS302LV) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); - } -#endif - } - - } /* 301B */ - - SiS_SetCRT2VCLK(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); + } + } + } } +#endif - -void -SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { USHORT vclkindex; USHORT temp, reg1, reg2; @@ -8655,382 +7527,300 @@ SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeN reg1 = SiS_Pr->CSR2B; reg2 = SiS_Pr->CSR2C; } else { - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); + 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; } if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,reg1); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0B,reg2); - 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 == 0x64) || (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_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); +} + +static void +SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +{ + USHORT tempax,tempcx,tempbx,modeflag,temp,resinfo; + ULONG tempebx,tempeax,templong; + + 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(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); + } + } + } + + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV)) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f); } - } else { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,0x01); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0B,reg2); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,reg1); } - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x12,0x00); - temp = 0x08; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) temp |= 0x20; - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x12,temp); -} -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}; - 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; - const UCHAR *CHTVVCLKPtr = NULL; - const USHORT *LCDXlatVCLK1 = NULL; - const USHORT *LCDXlatVCLK2 = NULL; - const USHORT *LVDSXlatVCLK2 = NULL; - const USHORT *LVDSXlatVCLK3 = NULL; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); + } - 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(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); +#ifdef SET_EMI + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); +#endif + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + } + } + return; + } } - 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; - } + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x13,SiS_Pr->SiS_RVBHCFACT); - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { /* 30x/B/LV */ + tempbx = SiS_Pr->SiS_RVBHCMAX; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x14,tempbx); - if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { + temp = (tempbx >> 1) & 0x80; - 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 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_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) { - if(HwDeviceExtension->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(HwDeviceExtension->jChipType <= SIS_315PRO) { - 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 += TVCLKBASE_300; - } else { - VCLKIndex += TVCLKBASE_315; - } - } 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)) { - /* This is certainly wrong: It replaces clock - * 108 by 47... - */ - /* if(VCLKIndex == 0x14) VCLKIndex = 0x2e; */ - if(VCLKIndex == 0x14) VCLKIndex = 0x34; - } - } - } - } + tempcx = SiS_Pr->SiS_VGAHT - 1; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x16,tempcx); - } else { /* If not programming CRT2 */ + temp |= ((tempcx >> 5) & 0x78); - 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; - } - } - } - } + tempcx = SiS_Pr->SiS_VGAVT - 1; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempcx -= 5; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x17,tempcx); - } else { /* LVDS */ + temp |= ((tempcx >> 8) & 0x07); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x15,temp); + + tempbx = SiS_Pr->SiS_VGAHDE; + if(modeflag & HalfDCLK) tempbx >>= 1; + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + temp = 0; + if(tempbx > 800) temp = 0x60; + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + temp = 0; + if(tempbx == 1024) temp = 0xA0; + else if(tempbx > 1024) temp = 0xC0; + } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { + temp = 0; + if(tempbx >= 1280) temp = 0x40; + else if(tempbx >= 1024) temp = 0x20; + } else { + temp = 0x80; + if(tempbx >= 1024) temp = 0xA0; + } - VCLKIndex = CRT2Index; + if(SiS_Pr->SiS_VBType & VB_SIS301) { + if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) temp |= 0x0A; + } - if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { /* programming CRT2 */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0E,0x10,temp); + + tempeax = SiS_Pr->SiS_VGAVDE; + tempebx = SiS_Pr->SiS_VDE; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + if(!(temp & 0xE0)) tempebx >>=1; + } + + tempcx = SiS_Pr->SiS_RVBHRS; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x18,tempcx); + tempcx >>= 8; + tempcx |= 0x40; + + if(tempeax <= tempebx) { + tempcx ^= 0x40; + } else { + tempeax -= tempebx; + } - if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { + tempeax *= (256 * 1024); + templong = tempeax % tempebx; + tempeax /= tempebx; + if(templong) tempeax++; - VCLKIndex &= 0x1f; - tempbx = 0; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - tempbx += 2; - if(SiS_Pr->SiS_ModeType > ModeVGA) { - 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_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 VCLKIndex = LVDSXlatVCLK3[VCLKIndex]; - - if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { - /* Special Timing: Barco iQ Pro R300/400/... */ - VCLKIndex = 0x44; - } + temp = (USHORT)(tempeax & 0x000000FF); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1B,temp); + temp = (USHORT)((tempeax & 0x0000FF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1A,temp); + temp = (USHORT)((tempeax >> 12) & 0x70); /* sic! */ + temp |= (tempcx & 0x4F); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x19,temp); - if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { - if(HwDeviceExtension->jChipType < SIS_315H) { - VCLKIndex = VCLK34_300; - /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ - } else { - VCLKIndex = VCLK34_315; - /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ - } - } + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - } else { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1C,0x28); - 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; - } - } + /* Calc Linebuffer max address and set/clear decimode */ + tempbx = 0; + if(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr750p)) tempbx = 0x08; + tempax = SiS_Pr->SiS_VGAHDE; + if(modeflag & HalfDCLK) tempax >>= 1; + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempax >>= 1; + if(tempax > 800) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + tempax -= 800; + } else { /* 651+301C: Only if TVNoHiviNoYPbPr */ + tempbx = 0x08; + if(tempax == 1024) tempax *= 25; + else tempax *= 20; + temp = tempax % 32; + tempax /= 32; + if(temp) tempax++; + tempax++; + if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) || + (SiS_Pr->SiS_TVMode & TVSetYPbPr525i)) { + if(resinfo == SIS_RI_1024x768) { + /* Otherwise white line at right edge */ + tempax = (tempax & 0xff00) | 0x20; + } } + } + } + tempax--; + temp = ((tempax >> 4) & 0x30) | tempbx; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1D,tempax); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1E,temp); - } 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; - } -#if 0 - if(HwDeviceExtension->jChipType == SIS_730) { - if(VCLKIndex == 0x0b) VCLKIndex = 0x40; /* 1024x768-70 */ - if(VCLKIndex == 0x0d) VCLKIndex = 0x41; /* 1024x768-75 */ - } -#endif + temp = 0x0036; tempbx = 0xD0; + if((IS_SIS550650740660) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + temp = 0x0026; tempbx = 0xC0; /* See En/DisableBridge() */ + } + 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 &= ~0x01; } } + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,tempbx,temp); + + tempbx = SiS_Pr->SiS_HT >> 1; + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + tempbx -= 2; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x22,tempbx); + temp = (tempbx >> 5) & 0x38; + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp); + 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); + } } + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); +#ifdef SET_EMI + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); +#endif + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + } + } - } -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "VCLKIndex %d (0x%x)\n", VCLKIndex, VCLKIndex); -#endif - return(VCLKIndex); + } /* 301B */ + + SiS_SetCRT2VCLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); } -/* Set 301 Palette address port registers */ -/* 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 */ +/*********************************************/ + +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))){ - SiS_EnableCRT2(SiS_Pr); - SiS_LoadDAC(SiS_Pr,HwDeviceExtension,ROMAddr,ModeNo,ModeIdIndex); + if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))) { + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); + 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 tempah,i,modeflag,j; USHORT ResIndex,DisplayType; const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr=NULL; - 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 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || (SiS_Pr->SiS_CustomT == CUT_PANEL848)) return; - temp = SiS_GetLVDSCRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &ResIndex,&DisplayType); - - 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; } 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 1 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1_H; break; + case 2 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2; break; + case 3 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2_H; break; + case 4 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; + case 5 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1_H; break; + case 6 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2; break; + case 7 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2_H; break; + case 8 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1; break; + case 9 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1_H; break; + case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2; 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; @@ -9069,30 +7859,30 @@ SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdI default: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; } - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /*unlock cr0-7 */ + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); tempah = (LVDSCRT1Ptr + ResIndex)->CR[0]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x00,tempah); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,tempah); for(i=0x02,j=1;i<=0x05;i++,j++){ tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); } for(i=0x06,j=5;i<=0x07;i++,j++){ tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); } for(i=0x10,j=7;i<=0x11;i++,j++){ tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); } for(i=0x15,j=9;i<=0x16;i++,j++){ tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); } for(i=0x0A,j=11;i<=0x0C;i++,j++){ tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,tempah); + SiS_SetReg(SiS_Pr->SiS_P3c4,i,tempah); } tempah = (LVDSCRT1Ptr + ResIndex)->CR[14]; @@ -9104,143 +7894,38 @@ SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdI tempah <<= 5; if(modeflag & DoubleScanMode) tempah |= 0x080; SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah); - - /* 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 *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 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_ModeType > ModeVGA) { - 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++; - } 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++; - } - } - -#if 0 - 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 1; -} +/*********************************************/ +/* SET CRT2 ECLK */ +/*********************************************/ -void -SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { + 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)) { + if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) || (SiS_Pr->SiS_LCDInfo & LCDPass11)) { SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK & 0x3f) == 2) { RefreshRateTableIndex--; } - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); + 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); } 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(SiS_Pr->SiS_UseROM) { if(ROMAddr[0x220] & 0x01) { sr2b = ROMAddr[0x227]; sr2c = ROMAddr[0x228]; @@ -9255,79 +7940,63 @@ SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeId } } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x20); - SiS_SetReg1(SiS_Pr->SiS_P3c4,clkbase,sr2b); - SiS_SetReg1(SiS_Pr->SiS_P3c4,clkbase+1,sr2c); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x10); - SiS_SetReg1(SiS_Pr->SiS_P3c4,clkbase,sr2b); - SiS_SetReg1(SiS_Pr->SiS_P3c4,clkbase+1,sr2c); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x00); - SiS_SetReg1(SiS_Pr->SiS_P3c4,clkbase,sr2b); - SiS_SetReg1(SiS_Pr->SiS_P3c4,clkbase+1,sr2c); -} - -#if 0 /* 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,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 -/* 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; +#if defined(SIS300) || defined(SIS315H) + USHORT temp, tempbx; +#endif + USHORT tempcl; USHORT TVType, resindex; const SiS_CHTVRegDataStruct *CHTVRegData = NULL; if(ModeNo <= 0x13) - tempcl = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + tempcl = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; else - tempcl = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + 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_ModeType > ModeVGA) { if(SiS_Pr->SiS_CHSOverScan) TVType = 8; } - if(SiS_Pr->SiS_CHPALM) { + 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) { - case 0: CHTVRegData = SiS_Pr->SiS_CHTVReg_UNTSC; break; - case 1: CHTVRegData = SiS_Pr->SiS_CHTVReg_ONTSC; break; - case 2: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPAL; break; - case 3: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; - case 4: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALM; break; - case 5: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALM; break; - case 6: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALN; break; - case 7: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALN; break; - case 8: CHTVRegData = SiS_Pr->SiS_CHTVReg_SOPAL; break; - default: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; + case 0: CHTVRegData = SiS_Pr->SiS_CHTVReg_UNTSC; break; + case 1: CHTVRegData = SiS_Pr->SiS_CHTVReg_ONTSC; break; + case 2: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPAL; break; + case 3: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; + case 4: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALM; break; + case 5: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALM; break; + case 6: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALN; break; + case 7: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALN; break; + case 8: CHTVRegData = SiS_Pr->SiS_CHTVReg_SOPAL; break; + default: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; } resindex = tempcl & 0x3F; @@ -9340,7 +8009,7 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIn /* We don't support modes >800x600 */ if (resindex > 5) return; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { + 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 { @@ -9385,7 +8054,7 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIn */ #ifndef SIS_CP SiS_SetCH70xx(SiS_Pr,0x003D); -#endif +#endif /* Register 0x10 only contains 1 writable bit (S0) for sensing, all other bits a read-only. Macrovision? @@ -9401,12 +8070,12 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIn */ 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 */ + } 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); @@ -9439,9 +8108,9 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIn SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); } } - } else { /* ---- PAL ---- */ + } else { /* ---- PAL ---- */ /* We don't play around with FSCI in PAL mode */ - if (resindex == 0x04) { + if(resindex == 0x04) { SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */ } else { @@ -9462,69 +8131,85 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIn 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 */ } @@ -9535,16 +8220,14 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIn } -/* Chrontel 701x functions ================================= */ - void -SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { USHORT temp; /* Enable Chrontel 7019 LCD panel backlight */ if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(HwDeviceExtension->jChipType == SIS_740) { + if(HwInfo->jChipType == SIS_740) { SiS_SetCH701x(SiS_Pr,0x6566); } else { temp = SiS_GetCH701x(SiS_Pr,0x66); @@ -9561,16 +8244,56 @@ SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr) /* 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 /* ----------- 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) +{ + 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 == Panel_1024x768) { + if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1024_740; + else tableptr = table1024_740; + } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || + (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || + (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) { + if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1400_740; + else tableptr = table1400_740; + } else return; + } else { + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + tableptr = table1024_650; + } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || + (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || + (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) { + 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 }; @@ -9594,59 +8317,49 @@ SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,U USHORT tempbh; int i; - if(HwDeviceExtension->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; + if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tableptr = table1024_740; + else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) tableptr = table1280_740; + else if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) tableptr = table1400_740; + else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) 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; + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tableptr = table1024_650; + else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) tableptr = table1280_650; + else if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) tableptr = table1400_650; + else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) tableptr = table1600_650; + else return; } tempbh = SiS_GetCH701x(SiS_Pr,0x74); if((tempbh == 0xf6) || (tempbh == 0xc7)) { tempbh = SiS_GetCH701x(SiS_Pr,0x73); if(tempbh == 0xc8) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) return; + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) return; } else if(tempbh == 0xdb) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) return; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) return; + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) return; + if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) return; } else if(tempbh == 0xde) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) return; + if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) return; } } - if(HwDeviceExtension->jChipType == SIS_740) { - tempbh = 0x0d; - } else { - tempbh = 0x0c; - } + 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,HwDeviceExtension); + SiS_ChrontelPowerSequencing(SiS_Pr,HwInfo); tempbh = SiS_GetCH701x(SiS_Pr,0x1e); tempbh |= 0xc0; SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1e); - if(HwDeviceExtension->jChipType == SIS_740) { + if(HwInfo->jChipType == SIS_740) { tempbh = SiS_GetCH701x(SiS_Pr,0x1c); tempbh &= 0xfb; SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1c); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2d,0x03); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); tempbh = SiS_GetCH701x(SiS_Pr,0x64); tempbh |= 0x40; SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x64); @@ -9656,72 +8369,53 @@ SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,U } } -void -SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_ChrontelResetVSync(SiS_Private *SiS_Pr) { - UCHAR regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b }; - UCHAR table1024_740[] = { 0x01, 0x02, 0x01, 0x01, 0x01 }; - UCHAR table1400_740[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 }; - 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 */ + unsigned char temp, temp1; - if(HwDeviceExtension->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) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) { - 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]); - } + 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) { - if(HwDeviceExtension->jChipType == SIS_740) { + if(HwInfo->jChipType == SIS_740) { temp = SiS_GetCH701x(SiS_Pr,0x1c); - temp |= 0x04; + temp |= 0x04; /* Invert XCLK phase */ SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); } - if(SiS_IsYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) { + if(SiS_IsYPbPr(SiS_Pr, HwInfo)) { temp = SiS_GetCH701x(SiS_Pr,0x01); temp &= 0x3f; 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; /* Enable SCART + CVBS */ SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01); } - if(HwDeviceExtension->jChipType == SIS_740) { - SiS_ChrontelDoSomething5(SiS_Pr); - SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */ + 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 */ + SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */ temp = SiS_GetCH701x(SiS_Pr,0x49); - if(SiS_IsYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) { + if(SiS_IsYPbPr(SiS_Pr,HwInfo)) { temp = SiS_GetCH701x(SiS_Pr,0x73); temp |= 0x60; SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x73); @@ -9738,13 +8432,13 @@ SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,US } void -SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +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(HwDeviceExtension->jChipType == SIS_740) { + if(HwInfo->jChipType == SIS_740) { SiS_LongDelay(SiS_Pr,1); SiS_GenericDelay(SiS_Pr,0x16ff); SiS_SetCH701x(SiS_Pr,0xac76); @@ -9755,38 +8449,22 @@ SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) temp &= 0xfc; SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); SiS_SetCH701x(SiS_Pr,0x0066); - } - } -} - -void -SiS_ChrontelDoSomething5(SiS_Private *SiS_Pr) -{ - 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); + } + } } -void -SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) +static void +SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { USHORT temp; - if(HwDeviceExtension->jChipType == SIS_740) { - temp = SiS_GetCH701x(SiS_Pr,0x4a); + if(HwInfo->jChipType == SIS_740) { + + temp = SiS_GetCH701x(SiS_Pr,0x4a); /* Version ID */ temp &= 0x01; - if(!(temp)) { + if(!temp) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { + if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) { temp = SiS_GetCH701x(SiS_Pr,0x49); SiS_SetCH701x(SiS_Pr,0x3e49); } @@ -9795,13 +8473,14 @@ SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, SiS_LongDelay(SiS_Pr,1); SiS_SetCH701x(SiS_Pr,0x1848); - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_ChrontelDoSomething5(SiS_Pr); + 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); @@ -9813,9 +8492,10 @@ SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); temp = SiS_GetCH701x(SiS_Pr,0x61); if(!temp) { - SiS_SetCH701xForLCD(SiS_Pr,HwDeviceExtension,BaseAddr); + SiS_SetCH701xForLCD(SiS_Pr, HwInfo); } } + } else { /* 650 */ /* Reset Chrontel 7019 datapath */ SiS_SetCH701x(SiS_Pr,0x1048); @@ -9825,14 +8505,14 @@ SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, } void -SiS_ChrontelDoSomething4(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) +SiS_ChrontelInitTVVSync(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { USHORT temp; - if(HwDeviceExtension->jChipType == SIS_740) { + if(HwInfo->jChipType == SIS_740) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_ChrontelDoSomething5(SiS_Pr); + if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) { + SiS_ChrontelResetVSync(SiS_Pr); } } else { @@ -9853,21 +8533,20 @@ SiS_ChrontelDoSomething4(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtens } } -void -SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT BaseAddr) +static void +SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo) { USHORT temp,temp1; - if(HwDeviceExtension->jChipType == SIS_740) { + 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); - SiS_SetCH701x(SiS_Pr,0xaf76); + 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); @@ -9885,7 +8564,7 @@ SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_DEVICE_INFO temp |= 0x5f; SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); if(ModeNo > 0x13) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { + if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) { SiS_GenericDelay(SiS_Pr,0x3ff); } else { SiS_GenericDelay(SiS_Pr,0x2ff); @@ -9905,8 +8584,8 @@ SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_DEVICE_INFO } } -void -SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) +static void +SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { USHORT temp,tempcl,tempch; @@ -9916,43 +8595,43 @@ SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtens do { temp = SiS_GetCH701x(SiS_Pr,0x66); - temp &= 0x04; + temp &= 0x04; /* PLL stable? -> bail out */ if(temp == 0x04) break; - - if(HwDeviceExtension->jChipType == SIS_740) { + + if(HwInfo->jChipType == SIS_740) { + /* Power down LVDS output, PLL normal operation */ SiS_SetCH701x(SiS_Pr,0xac76); } - SiS_SetCH701xForLCD(SiS_Pr,HwDeviceExtension,BaseAddr); + SiS_SetCH701xForLCD(SiS_Pr,HwInfo); if(tempcl == 0) { if(tempch == 3) break; - SiS_ChrontelResetDB(SiS_Pr,HwDeviceExtension,BaseAddr); + SiS_ChrontelResetDB(SiS_Pr,HwInfo); tempcl = 3; tempch++; } tempcl--; temp = SiS_GetCH701x(SiS_Pr,0x76); - temp &= 0xfb; + temp &= 0xfb; /* Reset PLL */ SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); SiS_LongDelay(SiS_Pr,2); temp = SiS_GetCH701x(SiS_Pr,0x76); - temp |= 0x04; + temp |= 0x04; /* PLL normal operation */ SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); - if(HwDeviceExtension->jChipType == SIS_740) { - SiS_SetCH701x(SiS_Pr,0xe078); + 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); + SiS_SetCH701x(SiS_Pr,0x0077); /* MV? */ } void -SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT BaseAddr) +SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { USHORT temp; @@ -9960,126 +8639,421 @@ SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtens temp |= 0x80; /* Set datapath 1 to TV */ temp &= 0xbf; /* Set datapath 2 to LVDS */ SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); - - if(HwDeviceExtension->jChipType == SIS_740) { + + if(HwInfo->jChipType == SIS_740) { temp = SiS_GetCH701x(SiS_Pr,0x1c); - temp &= 0xfb; + temp &= 0xfb; /* Normal XCLK phase */ SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2d,0x03); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); temp = SiS_GetCH701x(SiS_Pr,0x64); - temp |= 0x40; + temp |= 0x40; /* ? Bit not defined */ SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x64); temp = SiS_GetCH701x(SiS_Pr,0x03); - temp &= 0x3f; + temp &= 0x3f; /* D1 input to both LVDS and TV */ 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); - } + 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,HwDeviceExtension,BaseAddr); + 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 */ - SiS_ChrontelDoSomething2(SiS_Pr,HwDeviceExtension,BaseAddr); + } - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34); - SiS_ChrontelDoSomething3(SiS_Pr,temp,HwDeviceExtension,BaseAddr); +} +#endif /* 315 series */ - SiS_SetCH701x(SiS_Pr,0xaf76); +/*********************************************/ +/* 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 and LCDA */ + SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; + 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); + } + +#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) { + + 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, ModeNo, ModeIdIndex); +#endif + SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + + SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); + + /* For 301BDH (Panel link initialization): */ + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) { + 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); + } + } + + } else { + + SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); + + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwInfo); + } + + SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwInfo); + + 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); + } + } + } + + } + +#ifdef SIS300 + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + if(SiS_Pr->SiS_UseOEM) { + if((SiS_Pr->SiS_UseROM) && (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 + +#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); + SiS_OEM310Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + } else { + SiS_OEM661Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40); + } + } +#endif + + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + SiS_EnableBridge(SiS_Pr, HwInfo); + } + + 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); + } + } + + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + SiS_LockCRT2(SiS_Pr,HwInfo); + } + + return TRUE; +} + + +/*********************************************/ +/* ENABLE/DISABLE LCD BACKLIGHT (SIS) */ +/*********************************************/ + +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); + } +} + +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); +} +/*********************************************/ +/* DDC RELATED FUNCTIONS */ +/*********************************************/ + +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; + } } -#endif /* 315 series ------------------------------------ */ +#ifdef SIS300 +static UCHAR * +SiS_SetTrumpBlockLoop(SiS_Private *SiS_Pr, UCHAR *dataptr) +{ + int i, j, num; + USHORT tempah,temp; + UCHAR *mydataptr; + + for(i=0; i<20; i++) { /* Do 20 attempts to write */ + mydataptr = dataptr; + num = *mydataptr++; + if(!num) return mydataptr; + if(i) { + SiS_SetStop(SiS_Pr); + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT*2); + } + 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 = *mydataptr++; + temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write register number */ + if(temp) continue; /* (ERROR: no ack) */ + for(j=0; jSiS_DDC_DeviceAddr = 0xF0; /* DAB (Device Address Byte) */ + 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); -/* End of Chrontel 701x functions ==================================== */ + SiS_SetSwitchDDC2(SiS_Pr); -/* Generic Read/write routines for Chrontel ========================== */ + while(*dataptr) { + dataptr = SiS_SetTrumpBlockLoop(SiS_Pr, dataptr); + if(!dataptr) return FALSE; + } +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "Trumpion block success\n"); +#endif + return TRUE; +} +#endif -/* 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 */ +static BOOLEAN +SiS_SetChReg(SiS_Private *SiS_Pr, USHORT tempbx, USHORT myor) +{ + 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; +} + +#ifdef SIS300 +/* Write Trumpion register */ void -SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +SiS_SetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx) { - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) - SiS_SetCH700x(SiS_Pr,tempbx); - else - SiS_SetCH701x(SiS_Pr,tempbx); + SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB (Device Address Byte) */ + 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); + SiS_SetChReg(SiS_Pr, tempbx, 0); } +#endif /* 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; /* 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; /* DAB (Device Address Byte) */ - } - - for(i=0;i<10;i++) { /* Do only 10 attempts to write */ - /* SiS_SetSwitchDDC2(SiS_Pr); */ - 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 |= 0x80; /* (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; - } - - /* For 630ST */ - if(!(SiS_Pr->SiS_ChrontelInit)) { + 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); + } + + 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; /* DAB (Device Address Byte) */ - - for(i=0;i<10;i++) { /* Do only 10 attempts to write */ - /* SiS_SetSwitchDDC2(SiS_Pr); */ - 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 |= 0x80; /* (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; - } + SiS_SetupDDCN(SiS_Pr); + + SiS_SetChReg(SiS_Pr, tempbx, 0x80); } } @@ -10088,105 +9062,96 @@ SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempbx) void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx) { - USHORT tempah,temp,i; - 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_SetupDDCN(SiS_Pr); SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ + SiS_SetChReg(SiS_Pr, tempbx, 0); +} + +void +SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +{ + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) + SiS_SetCH700x(SiS_Pr,tempbx); + else + SiS_SetCH701x(SiS_Pr,tempbx); +} - for(i=0;i<10;i++) { /* Do only 10 attempts to write */ - 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; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write RAB */ - 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 */ - return; +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; } -/* Read from Chrontel 70xx */ -/* Parameter is [Register no (S7-S0)] */ +#ifdef SIS300 +/* Read from Trumpion */ USHORT -SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +SiS_GetTrumpReg(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)); + SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB */ + 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); + SiS_Pr->SiS_DDC_ReadAddr = tempbx; + return(SiS_GetChReg(SiS_Pr,0)); } +#endif /* 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; /* 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; /* DAB */ + SiS_SetupDDCN(SiS_Pr); } SiS_Pr->SiS_DDC_ReadAddr = tempbx; - for(i=0;i<20;i++) { /* Do only 20 attempts to read */ - /* SiS_SetSwitchDDC2(SiS_Pr); */ - 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 | 0x80; /* Write RAB | 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); - } - - /* For 630ST */ - if(!SiS_Pr->SiS_ChrontelInit) { - SiS_Pr->SiS_DDC_Index = 0x0a; /* 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; /* DAB (Device Address Byte) */ - - for(i=0;i<20;i++) { /* Do only 20 attempts to read */ - /* SiS_SetSwitchDDC2(SiS_Pr); */ - 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 | 0x80; /* Write RAB | 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); + if( ((result = SiS_GetChReg(SiS_Pr,0x80)) == 0xFFFF) && + (!SiS_Pr->SiS_ChrontelInit) ) { + + 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(result); } /* Read from Chrontel 701x */ @@ -10194,32 +9159,26 @@ SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx) USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx) { - USHORT tempah,temp,i; - 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_SetupDDCN(SiS_Pr); SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ + SiS_Pr->SiS_DDC_ReadAddr = tempbx; - for(i=0;i<20;i++) { /* Do only 20 attempts to read */ - 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; /* Write RAB */ - 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 */ - SiS_SetStop(SiS_Pr); /* Stop condition */ - return(tempah); - } - return 0xFFFF; + return(SiS_GetChReg(SiS_Pr,0)); +} + +/* 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 */ @@ -10246,7 +9205,7 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, SiS_Pr->SiS_DDC_Index = 0x11; flag = 0xff; - cr32 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x32); + cr32 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x32); #if 0 if(VBFlags & VB_SISBRIDGE) { @@ -10291,7 +9250,7 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, } else { /* 315/330 series */ /* here we simplify: 0 = CRT1, 1 = CRT2 (VGA, LCD) */ - + if(VBFlags & VB_SISBRIDGE) { if(myadaptnum == 2) { myadaptnum = 1; @@ -10327,6 +9286,8 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, 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); @@ -10371,11 +9332,15 @@ SiS_SendACK(SiS_Private *SiS_Pr, USHORT yesno) { 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); } @@ -10390,6 +9355,9 @@ SiS_DoProbeDDC(SiS_Private *SiS_Pr) SiS_SetSwitchDDC2(SiS_Pr); if(SiS_PrepareDDC(SiS_Pr)) { SiS_SetStop(SiS_Pr); +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "Probe: Prepare failed\n"); +#endif return(0xFFFF); } mask = 0xf0; @@ -10403,6 +9371,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) { @@ -10412,6 +9383,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; } @@ -10494,18 +9468,88 @@ USHORT SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer) { + unsigned char sr1f,cr17=1; + USHORT result; + if(adaptnum > 2) return 0xFFFF; if(DDCdatatype > 4) return 0xFFFF; if((!(VBFlags & VB_VIDEOBRIDGE)) && (adaptnum > 0)) return 0xFFFF; - if(SiS_InitDDCRegs(SiS_Pr, VBFlags, VGAEngine, adaptnum, DDCdatatype, TRUE) == 0xFFFF) 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, 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 */ /* SiS30x(B) only */ USHORT @@ -10521,6 +9565,8 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) 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; + SiS_Pr->CP_PreferredX = SiS_Pr->CP_PreferredY = 0; + SiS_Pr->CP_PreferredIndex = -1; if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; if(pSiS->VBFlags & VB_30xBDH) return 0; @@ -10531,7 +9577,7 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) /* Probe supported DA's */ flag = SiS_ProbeDDC(SiS_Pr); -#ifdef TWDEBUG +#ifdef TWDEBUG xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, "CRT2 DDC capabilities 0x%x\n", flag); #endif @@ -10550,17 +9596,17 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) retry = 2; do { if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, - "CRT2: DDC read failed (attempt %d), %s\n", + 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], @@ -10574,8 +9620,14 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) 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; @@ -10609,12 +9661,14 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) SiS_Pr->CP_PreferredY = yres; switch(xres) { +#if 0 /* Treat as custom */ case 800: if(yres == 600) { paneltype = Panel_800x600; checkexpand = TRUE; } break; +#endif case 1024: if(yres == 768) { paneltype = Panel_1024x768; @@ -10622,7 +9676,7 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) } break; case 1280: - if(yres == 1024) { + if(yres == 1024) { paneltype = Panel_1280x1024; checkexpand = TRUE; } else if(yres == 960) { @@ -10632,9 +9686,13 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) paneltype = Panel310_1280x960; } } else if(yres == 768) { - paneltype = Panel_1280x768; - checkexpand = FALSE; - cr37 |= 0x10; + 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: @@ -10648,9 +9706,11 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) #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; + if(pSiS->VBFlags & VB_301C) { + if(yres == 1200) { + paneltype = Panel310_1600x1200; + checkexpand = TRUE; + } } } break; @@ -10664,6 +9724,7 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) /* 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 */ } } @@ -10690,6 +9751,7 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) }; paneltype = 0; + SiS_Pr->CP_Supports64048075 = TRUE; /* Find the maximum resolution */ @@ -10745,20 +9807,21 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) SiS_Pr->CP_DataValid[i] = TRUE; /* Sort out invalid timings, interlace and too high clocks */ - if((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] > 162000)) || - ((!(pSiS->VBFlags & VB_301C)) && (SiS_Pr->CP_Clock[i] > 108000)) ) || + 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; @@ -10773,9 +9836,18 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) 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]; + if((SiS_Pr->CP_PreferredX == xres) && (SiS_Pr->CP_PreferredY == yres)) { + SiS_Pr->CP_PreferredIndex = 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 */ @@ -10822,6 +9894,13 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) 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, @@ -10841,28 +9920,20 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) SiS_Pr->CP_MaxX = xres = buffer[0x76] | (buffer[0x77] << 8); SiS_Pr->CP_MaxY = yres = buffer[0x78] | (buffer[0x79] << 8); switch(xres) { +#if 0 case 800: if(yres == 600) { paneltype = Panel_800x600; checkexpand = TRUE; } break; +#endif case 1024: if(yres == 768) { 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: if(yres == 960) { if(pSiS->VGAEngine == SIS_315_VGA) { @@ -10873,11 +9944,8 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) } else if(yres == 1024) { paneltype = Panel_1280x1024; checkexpand = TRUE; - } else if(yres == 768) { - paneltype = Panel_1280x768; - checkexpand = FALSE; - cr37 |= 0x10; } + /* 1280x768 treated as custom here */ break; case 1400: if(pSiS->VGAEngine == SIS_315_VGA) { @@ -10890,9 +9958,11 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) #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; + if(pSiS->VBFlags & VB_301C) { + if(yres == 1200) { + paneltype = Panel310_1600x1200; + checkexpand = TRUE; + } } } break; @@ -10916,7 +9986,7 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) 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 */ @@ -10942,9 +10012,12 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) /* 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_DataValid[i] = TRUE; - if((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] > 162000)) || - ((!(pSiS->VBFlags & VB_301C)) && (SiS_Pr->CP_Clock[i] > 108000)) ) || + 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; @@ -10990,6 +10064,10 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i]; + if((SiS_Pr->CP_MaxX == xres) && (SiS_Pr->CP_MaxY == yres)) { + SiS_Pr->CP_PreferredIndex = 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; @@ -11035,7 +10113,7 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) 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 Display section\n", + " 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]); } @@ -11044,15 +10122,18 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) 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_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x08); -#ifdef TWDEBUG + SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,paneltype); + cr37 &= 0xf1; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,0x0c,cr37); + SiS_Pr->PanelSelfDetected = TRUE; +#ifdef TWDEBUG xf86DrvMsgVerb(pSiS->pScrn->scrnIndex, X_PROBED, 3, - "CRT2: [DDC LCD results: 0x%02x, 0x%02x]\n", paneltype, cr37); + "CRT2: [DDC LCD results: 0x%02x, 0x%02x]\n", paneltype, cr37); #endif + } else { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x32,~0x08); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,0x00); } return 0; } @@ -11066,8 +10147,7 @@ SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS) unsigned char buffer[256]; 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->VBFlags, pSiS->VGAEngine, 2, 0, FALSE) == 0xFFFF) return 0; SiS_Pr->SiS_DDC_SecAddr = 0x00; @@ -11084,16 +10164,16 @@ SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS) SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */ DDCdatatype = 1; } else { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, "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, DDCdatatype, buffer)) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, "CRT2: DDC read failed (attempt %d), %s\n", (3-retry), (retry == 1) ? "giving up" : "retrying"); retry--; @@ -11106,10 +10186,15 @@ SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS) */ 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; + return 0; } SiS_Pr->CP_Vendor = buffer[9] | (buffer[8] << 8); SiS_Pr->CP_Product = buffer[10] | (buffer[11] << 8); @@ -11117,6 +10202,11 @@ SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS) 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) && @@ -11133,42 +10223,11 @@ SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS) } if(foundcrt) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x10); + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x10); } return(0); } -/* Generic I2C functions (compliant to i2c library) */ - -#if 0 -USHORT -SiS_I2C_GetByte(SiS_Private *SiS_Pr) -{ - return(SiS_ReadDDC2Data(SiS_Pr,0)); -} - -Bool -SiS_I2C_PutByte(SiS_Private *SiS_Pr, USHORT data) -{ - if(SiS_WriteDDC2Data(SiS_Pr,data)) return FALSE; - return TRUE; -} - -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; -} - -void -SiS_I2C_Stop(SiS_Private *SiS_Pr) -{ - SiS_SetStop(SiS_Pr); -} -#endif - #endif void @@ -11181,18 +10240,23 @@ SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh) SiS_SetCH70xx(SiS_Pr,tempbl); } -/* 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); } /* Set I2C start condition */ @@ -11201,11 +10265,15 @@ USHORT SiS_SetStart(SiS_Private *SiS_Pr) { 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_Data,SiS_Pr->SiS_DDC_Data); /* SD->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 */ 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_Data,0x00); /* SD->low = start condition */ + 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; } @@ -11216,11 +10284,15 @@ USHORT SiS_SetStop(SiS_Private *SiS_Pr) { 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_Data,0x00); /* SD->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_Data,SiS_Pr->SiS_DDC_Data); /* SD->high = stop condition */ + 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; } @@ -11231,15 +10303,19 @@ SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) { USHORT i,flag,temp; - flag=0x80; - for(i=0;i<8;i++) { + 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); /* 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); /* 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); /* SC->high */ flag >>= 1; @@ -11257,10 +10333,12 @@ SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) 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); @@ -11269,8 +10347,10 @@ SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) 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; } @@ -11278,33 +10358,25 @@ 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); - } -} - /* Check I2C acknowledge */ /* Returns 0 if ack ok, non-0 if ack not ok */ USHORT @@ -11313,10 +10385,12 @@ SiS_CheckACK(SiS_Private *SiS_Pr) USHORT tempah; SiS_SetSCLKLow(SiS_Pr); /* (SC->low) */ - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* (SD->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) */ SiS_SetSCLKHigh(SiS_Pr); /* SC->high = clock impulse for ack */ - tempah = SiS_GetReg1(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);/* Read SD */ + 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); @@ -11330,64 +10404,67 @@ SiS_CheckACK(SiS_Private *SiS_Pr) #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 = SISGETROMW(0x128); if(SiS_Pr->SiS_VBType & VB_SIS301B302B) - romptr = ROMAddr[0x12a] | (ROMAddr[0x12b] << 8); + romptr = SISGETROMW(0x12a); } else { - romptr = ROMAddr[0x1a8] | (ROMAddr[0x1a9] << 8); + romptr = SISGETROMW(0x1a8); if(SiS_Pr->SiS_VBType & VB_SIS301B302B) - romptr = ROMAddr[0x1aa] | (ROMAddr[0x1ab] << 8); + romptr = SISGETROMW(0x1aa); } return(romptr); } 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 = SISGETROMW(0x120); if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) - romptr = ROMAddr[0x122] | (ROMAddr[0x123] << 8); + romptr = SISGETROMW(0x122); } else { - romptr = ROMAddr[0x1a0] | (ROMAddr[0x1a1] << 8); + romptr = SISGETROMW(0x1a0); if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) - romptr = ROMAddr[0x1a2] | (ROMAddr[0x1a3] << 8); + romptr = SISGETROMW(0x1a2); } return(romptr); } 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) { - romptr = ROMAddr[0x114] | (ROMAddr[0x115] << 8); + if(HwInfo->jChipType < SIS_330) { + romptr = SISGETROMW(0x114); if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) - romptr = ROMAddr[0x11a] | (ROMAddr[0x11b] << 8); + romptr = SISGETROMW(0x11a); } else { - romptr = ROMAddr[0x194] | (ROMAddr[0x195] << 8); + romptr = SISGETROMW(0x194); if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) - romptr = ROMAddr[0x19a] | (ROMAddr[0x19b] << 8); + romptr = SISGETROMW(0x19a); } return(romptr); } static USHORT -GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) +GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { USHORT index; if((IS_SIS650) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { - if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if((index = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xf0)) { + 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; @@ -11397,9 +10474,9 @@ GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, U } } - 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; + index = SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F; + if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) index -= 5; + else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 6; index--; index *= 3; if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; @@ -11412,90 +10489,184 @@ GetLCDPtrIndex(SiS_Private *SiS_Pr) { USHORT index; - index = SiS_Pr->SiS_LCDResInfo & 0x0F; - index--; - index *= 3; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; + index = ((SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F) - 1) * 3; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++; - 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_GEN(SiS_Private *SiS_Pr, int addme) +{ + 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 += addme; + temp++; + } + temp += 0x0100; + } + return(ULONG)(index | (temp << 16)); +} + +static ULONG +GetOEMTVPtr661_2_OLD(SiS_Private *SiS_Pr) +{ + return(GetOEMTVPtr661_2_GEN(SiS_Pr, 8)); +} + +#if 0 +static ULONG +GetOEMTVPtr661_2_NEW(SiS_Private *SiS_Pr) +{ + return(GetOEMTVPtr661_2_GEN(SiS_Pr, 6)); +} +#endif + +static int +GetOEMTVPtr661(SiS_Private *SiS_Pr) +{ + int index = 0; + + if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 2; + if(SiS_Pr->SiS_ROMNew) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525i) index = 4; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) index = 6; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) index = 8; + if(SiS_Pr->SiS_TVMode & TVSetHiVision) index = 10; + } else { + 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) { + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT delay=0,index,myindex,temp,romptr=0; BOOLEAN dochiptest = TRUE; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { /* VGA */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x20,0xbf); + } else { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x35,0x7f); + } + + /* 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); - if(!romptr) return; - delay = ROMAddr[romptr]; - } else { + if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { + romptr = GetRAMDACromptr(SiS_Pr, HwInfo); + } + if(romptr) delay = ROMAddr[romptr]; + else { delay = 0x04; if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { if(IS_SIS650) { 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) + } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { delay = 0x00; + } } - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */ + } 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 or did we get a user-defined? If yes, use it */ + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->PDC != -1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0xf0,((SiS_Pr->PDC >> 1) & 0x0f)); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,0x7f,((SiS_Pr->PDC & 0x01) << 7)); + return; + } + } else { + if(SiS_Pr->PDCA != -1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,((SiS_Pr->PDCA << 3) & 0xf0)); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x20,0xbf,((SiS_Pr->PDCA & 0x01) << 6)); + return; + } + } + + /* Custom Panel? */ - if(HwDeviceExtension->pdc) return; + if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + delay = 0x00; + if((SiS_Pr->PanelXRes <= 1280) && (SiS_Pr->PanelYRes <= 1024)) { + delay = 0x20; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,delay); + } else { + delay = 0x0c; + if(SiS_Pr->SiS_VBType & VB_SIS301C) delay = 0x03; + else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(IS_SIS740) delay = 0x01; + else delay = 0x03; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0xf0,delay); + } + return; + } /* This is a piece of typical SiS crap: They code the OEM LCD - * delay into the code, at none defined place in the BIOS. + * 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) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { gotitfrompci = TRUE; dochiptest = FALSE; delay = 0x03; @@ -11503,145 +10674,197 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT B break; case CUT_CLEVO1400: case CUT_CLEVO14002: - /* if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { */ - gotitfrompci = TRUE; - dochiptest = FALSE; - delay = 0x02; - /* } */ + gotitfrompci = TRUE; + dochiptest = FALSE; + delay = 0x02; break; case CUT_CLEVO1024: case CUT_CLEVO10242: - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { gotitfrompci = TRUE; dochiptest = FALSE; delay = 0x33; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2D,delay); + 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, HwDeviceExtension, BaseAddr); + index = GetLCDPtrIndexBIOS(SiS_Pr, HwInfo); 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 - } + if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + + if(SiS_IsNotM650orLater(SiS_Pr, HwInfo)) { + + if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { + /* Always use the second pointer on 650; some BIOSes */ + /* still carry old 301 data at the first location */ + /* romptr = SISGETROMW(0x120); */ + /* if(SiS_Pr->SiS_VBType & VB_SIS302LV) */ + romptr = SISGETROMW(0x122); + 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) + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) 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); - if(!romptr) return; - delay = ROMAddr[(romptr + index)]; - } 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_SIS550650740660) { - 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]; - } - } - } + + } else if(SiS_Pr->SiS_UseROM && + (!(SiS_Pr->SiS_ROMNew)) && + (SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) && + (SiS_Pr->SiS_LCDResInfo != Panel_1280x768) && + (SiS_Pr->SiS_LCDResInfo != Panel_1280x960)) { + + /* Data for 1280x1024 wrong in 301B BIOS */ + romptr = GetLCDromptr(SiS_Pr, HwInfo); + if(!romptr) return; + delay = ROMAddr[(romptr + index)]; + + } 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_SIS301LV302LV) { + if(IS_SIS740) delay = 0x01; + else if(HwInfo->jChipType <= SIS_315PRO) delay = SiS310_LCDDelayCompensation_3xx301LV[myindex]; + else delay = SiS310_LCDDelayCompensation_650301LV[myindex]; + } else if(SiS_Pr->SiS_VBType & VB_SIS301C) { + if(IS_SIS740) delay = 0x01; /* ? */ + else delay = 0x03; + } 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 { - 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]; - } - } + + if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) { + + if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { + /* Always use the second pointer on 650; some BIOSes */ + /* still carry old 301 data at the first location */ + /* romptr = SISGETROMW(0x114); */ + /* if(SiS_Pr->SiS_VBType & VB_SIS302LV) */ + romptr = SISGETROMW(0x11a); + 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((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { + + 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]; + /* LV: use 301 data? BIOS bug? */ + } else { + delay = SiS310_TVDelayCompensation_301B[index]; + if(SiS_Pr->SiS_VBType & VB_SIS301C) delay = 0x02; + } + } + + } + + if(SiS_LCDAEnabled(SiS_Pr, HwInfo)) { + 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); + } - - } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + } else { /* LVDS */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); } else { @@ -11652,49 +10875,47 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT B SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); } } - } else { - if(dochiptest && IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { - temp = (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xf0) >> 4; - if(temp == 8) { /* 1400x1050 BIOS (ECS) */ - delay &= 0x0f; - delay |= 0xb0; - } else if(temp == 6) { - delay &= 0x0f; - delay |= 0xc0; - } else if(temp > 7) { /* 1280x1024 BIOS (which one?) */ - delay = 0x35; - } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2D,delay); - } 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; - if(ROMAddr && SiS_Pr->SiS_UseROM) { - romptr = ROMAddr[0x112] | (ROMAddr[0x113] << 8); - if(HwDeviceExtension->jChipType >= SIS_330) { - romptr = ROMAddr[0x192] | (ROMAddr[0x193] << 8); + temp = GetTVPtrIndex(SiS_Pr); + temp >>= 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */ + temp1 = temp; + + if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { + if(HwInfo->jChipType >= SIS_661) { + temp1 = GetOEMTVPtr661(SiS_Pr); + temp1 >>= 1; + romptr = SISGETROMW(0x260); + if(HwInfo->jChipType >= SIS_760) { + romptr = SISGETROMW(0x360); + } + } else if(HwInfo->jChipType >= SIS_330) { + romptr = SISGETROMW(0x192); + } else { + romptr = SISGETROMW(0x112); } } if(romptr) { - temp <<= 1; - temp = ROMAddr[romptr + temp + index]; + temp1 <<= 1; + temp = ROMAddr[romptr + temp1 + index]; } else { temp = SiS310_TVAntiFlick1[temp][index]; } @@ -11704,29 +10925,37 @@ SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT } 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 = temp1 = GetTVPtrIndex(SiS_Pr) >> 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */ - if(ModeNo<=0x13) + if(ModeNo <= 0x13) index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex; else 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) { - romptr = ROMAddr[0x1a4] | (ROMAddr[0x1a5] << 8); + if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { + if(HwInfo->jChipType >= SIS_661) { + romptr = SISGETROMW(0x26c); + if(HwInfo->jChipType >= SIS_760) { + romptr = SISGETROMW(0x36c); + } + temp1 = GetOEMTVPtr661(SiS_Pr); + temp1 >>= 1; + } else if(HwInfo->jChipType >= SIS_330) { + romptr = SISGETROMW(0x1a4); + } else { + romptr = SISGETROMW(0x124); } } if(romptr) { - temp <<= 1; - temp = ROMAddr[romptr + temp + index]; + temp1 <<= 1; + temp = ROMAddr[romptr + temp1 + index]; } else { temp = SiS310_TVEdge1[temp][index]; } @@ -11735,90 +10964,62 @@ SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT } 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 */ - if (ModeNo<=0x13) { - index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex; + if(ModeNo <= 0x13) { + index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex; } else { - index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; + index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) temp = 1; /* Hivision TV uses PAL */ + temp = GetTVPtrIndex(SiS_Pr) >> 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_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]); - } + 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_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter1[temp][index][j]); - } - } - - 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]); - } - } - } - /* PALN : Is this data correct? */ - 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]); - } - } - } - } + 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) || SiS_Pr->SiS_ROMNew) { + lindex = GetOEMTVPtr661_2_OLD(SiS_Pr) & 0xffff; + lindex <<= 2; + 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; @@ -11830,20 +11031,20 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT B /* 0: NTSC Graphics, 1: NTSC Text, 2: PAL Graphics, * 3: PAL Text, 4: HiTV Graphics 5: HiTV Text */ - if((ROMAddr) && SiS_Pr->SiS_UseROM) { - romptr = ROMAddr[0x116] | (ROMAddr[0x117] << 8); - if(HwDeviceExtension->jChipType >= SIS_330) { - romptr = ROMAddr[0x196] | (ROMAddr[0x197] << 8); + if(SiS_Pr->SiS_UseROM) { + romptr = SISGETROMW(0x116); + if(HwInfo->jChipType >= SIS_330) { + romptr = SISGETROMW(0x196); } if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - romptr = ROMAddr[0x11c] | (ROMAddr[0x11d] << 8); - if(HwDeviceExtension->jChipType >= SIS_330) { - romptr = ROMAddr[0x19c] | (ROMAddr[0x19d] << 8); - } - if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_SetFlag & TVSimuMode))) { - romptr = ROMAddr[0x116] | (ROMAddr[0x117] << 8); - if(HwDeviceExtension->jChipType >= SIS_330) { - romptr = ROMAddr[0x196] | (ROMAddr[0x197] << 8); + romptr = SISGETROMW(0x11c); + if(HwInfo->jChipType >= SIS_330) { + romptr = SISGETROMW(0x19c); + } + if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode))) { + romptr = SISGETROMW(0x116); + if(HwInfo->jChipType >= SIS_330) { + romptr = SISGETROMW(0x196); } } } @@ -11851,58 +11052,264 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT B 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]); - } - } - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 650/301LV: (VB_SIS301LV | VB_SIS302LV)) */ - if((!(SiS_Pr->SiS_VBInfo & SetPALTV)) && (ModeNo > 0x13)) { - if(resinfo == SIS_RI_640x480) { - 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 == SIS_RI_800x600) { - 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 == SIS_RI_1024x768) { - 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); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]); + } + } + + 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); + SetDelayComp(SiS_Pr,HwInfo,ModeNo); if(SiS_Pr->UseCustomMode) return; - 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); - } + 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_SIS301) { + SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + } + } +} + +static void +SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, + USHORT ModeIdIndex, USHORT RTI) +{ + USHORT delay = 0, romptr = 0, index; + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + + if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToRAMDAC))) + return; + + /* 1. New ROM: VGA2 and LCD/LCDA-Pass1:1 */ + + if(SiS_Pr->SiS_ROMNew) { + if((SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) || + ((SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) && + (SiS_Pr->SiS_LCDInfo & LCDPass11))) { + index = 25; + if(SiS_Pr->UseCustomMode) { + index = SiS_Pr->CSRClock; + } else if(ModeNo > 0x13) { + index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RTI,HwInfo); + index = SiS_Pr->SiS_VCLKData[index].CLOCK; + } + if(index < 25) index = 25; + index = ((index / 25) - 1) << 1; + if((ROMAddr[0x5b] & 0x80) || (SiS_Pr->SiS_VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD))) { + index++; + } + romptr = SISGETROMW(0x104); /* 0x4ae */ + delay = ROMAddr[romptr + index]; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD)) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0xf0,((delay >> 1) & 0x0f)); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,0x7f,((delay & 0x01) << 7)); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,((delay << 3) & 0xf0)); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x20,0xbf,((delay & 0x01) << 6)); + } + return; + } + } + + /* 2. Old ROM: VGA2 and LCD/LCDA-Pass 1:1 */ + + if(SiS_Pr->UseCustomMode) delay = 0x04; + else if(ModeNo <= 0x13) delay = 0x04; + else delay = (SiS_Pr->SiS_RefIndex[RTI].Ext_PDC >> 4); + delay |= (delay << 8); + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + + /* 3. TV */ + + index = GetOEMTVPtr661(SiS_Pr); + if(SiS_Pr->SiS_ROMNew) { + romptr = SISGETROMW(0x106); /* 0x4ba */ + delay = ROMAddr[romptr + index]; + } else { + delay = 0x04; + } + + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + + /* 4. LCD, LCDA (for new ROM only LV and non-Pass 1:1) */ + + if( (SiS_Pr->SiS_LCDResInfo != Panel_Custom) && + ((romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo))) ) { + + /* For LV, the BIOS must know about the correct value */ + delay = ROMAddr[romptr + 0x0d]; /* LCD */ + delay |= (ROMAddr[romptr + 0x0c] << 8); /* LCDA */ + + } else { + + /* TMDS: Set our own, since BIOS has no idea - TODO: Find out about values */ + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if((SiS_Pr->PanelXRes <= 1024) && (SiS_Pr->PanelYRes <= 768)) { + delay = 0x0404; + } else if((SiS_Pr->PanelXRes <= 1280) && (SiS_Pr->PanelYRes <= 1024)) { + delay = 0x0404; + } else if((SiS_Pr->PanelXRes <= 1400) && (SiS_Pr->PanelYRes <= 1050)) { + delay = 0x1004; + } else + delay = 0x0000; + } + + /* Override by detected or user-set values */ + /* (but only if, for some reason, we can't read value from BIOS) */ + if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->PDC != -1)) { + delay = SiS_Pr->PDC & 0x1f; + } + if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) && (SiS_Pr->PDCA != -1)) { + delay = (SiS_Pr->PDCA & 0x1f) << 8; + } + + } + + } + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + delay >>= 8; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,((delay << 3) & 0xf0)); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x20,0xbf,((delay & 0x01) << 6)); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0xf0,((delay >> 1) & 0x0f)); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,0x7f,((delay & 0x01) << 7)); + } +} + +static void +SetCRT2SyncDither661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT RTI) +{ + USHORT infoflag; + UCHAR temp; + + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + + if(ModeNo <= 0x13) { + infoflag = SiS_GetRegByte(SiS_Pr->SiS_P3ca+2); + } else if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; + } else { + infoflag = SiS_Pr->SiS_RefIndex[RTI].Ext_InfoFlag; + } + infoflag &= 0xc0; + + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + temp &= 0x3f; + temp |= infoflag; + } else { + 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); + } else { + 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 *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT romptr, temp1, temp2; + + 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); + } + } + + if(SiS_Pr->SiS_ROMNew) { + + if((romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo))) { + if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { + temp1 = (ROMAddr[romptr] & 0x03) | 0x0c; + temp2 = 0xfc; + if(SiS_Pr->LVDSHL != -1) { + temp1 &= 0xfc; + temp2 = 0xf3; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,temp2,temp1); + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + temp1 = (ROMAddr[romptr + 1] & 0x80) >> 1; + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0d,0xbf,temp1); + } + } + + } +} + +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_SIS301) { + SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + } + } } } @@ -11914,8 +11321,8 @@ SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USH * 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; @@ -11928,7 +11335,7 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeN } } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return; + if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) return; if(SiS_Pr->UseCustomMode) return; switch(SiS_Pr->SiS_CustomT) { @@ -11940,15 +11347,15 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeN } 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_GetReg1(SiS_Pr->SiS_P3d4, 0x5f) & 0xf0)) { + 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 { @@ -11958,7 +11365,8 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeN } if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { /* Maybe all panels? */ + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + /* Maybe all panels? */ if(SiS_Pr->LVDSHL == -1) { SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01); } @@ -11968,17 +11376,18 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeN if(SiS_Pr->SiS_CustomT == CUT_CLEVO10242) { if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { /* Maybe all panels? */ + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 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_GetReg1(SiS_Pr->SiS_P3d4,0x36) >> 4; + tempch = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4; if(tempch == 3) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x02); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,0x25); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1c,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1d,0x1b); + 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; @@ -11987,133 +11396,123 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeN } if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { -#ifdef SET_EMI - if(SiS_Pr->SiS_VBType & VB_SIS302LV) { - 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_Pr->SiS_LCDResInfo == Panel_1024x768) { + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); +#ifdef SET_EMI + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); +#endif + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); } -#endif - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { /* Maybe all panels? */ + } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { if(SiS_Pr->LVDSHL == -1) { /* Maybe ACER only? */ SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01); } } - tempch = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); - tempch &= 0xf0; - tempch >>= 4; + tempch = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4; if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - if(tempch == 0x03) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x02); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,0x25); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1c,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1d,0x1b); - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1f,0x76); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1f,0x76); + } else if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + 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 == SIS_RI_1024x768)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x02); /* 1.10.7u */ + 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_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; - } - } - } - } + 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(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 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); } } @@ -12121,25 +11520,24 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeN #endif - /* ================= SiS 300 O.E.M. ================== */ #ifdef SIS300 void -SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, USHORT RefTabIndex) +SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex, USHORT RefTabIndex) { USHORT crt2crtc=0, modeflag, myindex=0; UCHAR temp; int i; if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + 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; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + crt2crtc = SiS_Pr->SiS_RefIndex[RefTabIndex].Ext_CRT2CRTC; } crt2crtc &= 0x3f; @@ -12151,7 +11549,7 @@ SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { if(modeflag & HalfDCLK) myindex = 1; - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { + 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, @@ -12161,46 +11559,19 @@ SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT } } } - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00); + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); if(temp & 0x80) { - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x18); + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x18); temp++; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); } } } -#if 0 /* Not used */ -static USHORT -GetRevisionID(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - ULONG temp1; -#ifndef LINUX_XF86 - ULONG base; -#endif - USHORT temp2 = 0; - - 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; -} -#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, @@ -12211,24 +11582,21 @@ GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR * 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }; - if(HwDeviceExtension->jChipType == SIS_300) { + if(HwInfo->jChipType == SIS_300) { - tempbx = (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0x0f) - 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_LCDResInfo == Panel_1024x768) { if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 3; } - if((ROMAddr) && SiS_Pr->SiS_UseROM) { + if(SiS_Pr->SiS_UseROM) { if(ROMAddr[0x235] & 0x80) { tempbx = SiS_Pr->SiS_LCDTypeInfo; if(Flag) { - romptr = ROMAddr[0x255] | (ROMAddr[0x256] << 8); - if(romptr) { - tempbx = ROMAddr[romptr + SiS_Pr->SiS_LCDTypeInfo]; - } else { - tempbx = customtable300[SiS_Pr->SiS_LCDTypeInfo]; - } - if(tempbx == 0xFF) return 0xFFFF; + romptr = SISGETROMW(0x255); + if(romptr) tempbx = ROMAddr[romptr + SiS_Pr->SiS_LCDTypeInfo]; + else tempbx = customtable300[SiS_Pr->SiS_LCDTypeInfo]; + if(tempbx == 0xFF) return 0xFFFF; } tempbx <<= 1; if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++; @@ -12238,21 +11606,18 @@ GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR * } 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(SiS_Pr->SiS_UseROM) { + romptr = SISGETROMW(0x255); + 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; @@ -12262,17 +11627,18 @@ GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR * } 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(SiS_Pr->SiS_LCDResInfo == Panel_Custom) return; - if((ROMAddr) && SiS_Pr->SiS_UseROM) { + if(SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x237] & 0x01)) return; if(!(ROMAddr[0x237] & 0x02)) return; - romptr = ROMAddr[0x24b] | (ROMAddr[0x24c] << 8); + romptr = SISGETROMW(0x24b); } /* The Panel Compensation Delay should be set according to tables @@ -12282,86 +11648,87 @@ SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT * 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 != -1) return; - temp = GetOEMLCDPtr(SiS_Pr,HwDeviceExtension, ROMAddr, 0); + temp = GetOEMLCDPtr(SiS_Pr,HwInfo, 0); 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 = SISGETROMW(romptr); + 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(SiS_Pr->SiS_UseROM && (ROMAddr[0x235] & 0x80)) { if(romptr) { romptr += (temp * 2); - romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); + romptr = SISGETROMW(romptr); 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(SiS_Pr->SiS_UseROM) { + romptr = ROMAddr[0x249] | (ROMAddr[0x24a] << 8); + if(romptr) { + romptr += (temp * 2); + romptr = SISGETROMW(romptr); + 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 /* Unfinished; Data table missing */ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT index,temp; - if((ROMAddr) && SiS_Pr->SiS_UseROM) { + if((SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x237] & 0x01)) return; if(!(ROMAddr[0x237] & 0x04)) return; /* No rom pointer in BIOS header! */ } - temp = GetOEMLCDPtr(SiS_Pr,HwDeviceExtension, ROMAddr, 1); + 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 } @@ -12373,27 +11740,28 @@ 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) { + if(SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x238] & 0x01)) return; if(!(ROMAddr[0x238] & 0x02)) return; - romptr = ROMAddr[0x241] | (ROMAddr[0x242] << 8); + romptr = SISGETROMW(0x241); } temp = GetOEMTVPtr(SiS_Pr); @@ -12402,31 +11770,31 @@ SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT if(romptr) { romptr += (temp * 2); - romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); + romptr = SISGETROMW(romptr); 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]; } } temp &= 0x3c; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* index 0A D[6:4] */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); } 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) { + if(SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x238] & 0x01)) return; if(!(ROMAddr[0x238] & 0x04)) return; - romptr = ROMAddr[0x243] | (ROMAddr[0x244] << 8); + romptr = SISGETROMW(0x243); } temp = GetOEMTVPtr(SiS_Pr); @@ -12435,28 +11803,31 @@ SetOEMAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, if(romptr) { romptr += (temp * 2); - romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); + romptr = SISGETROMW(romptr); romptr += index; temp = ROMAddr[romptr]; } else { temp = SiS300_OEMTVFlicker[temp][index]; } temp &= 0x70; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0A,0x8F,temp); /* index 0A D[6:4] */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0A,0x8F,temp); } 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(SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x238] & 0x01)) return; if(!(ROMAddr[0x238] & 0x08)) return; - romptr = ROMAddr[0x245] | (ROMAddr[0x246] << 8); + romptr = SISGETROMW(0x245); } temp = GetOEMTVPtr(SiS_Pr); @@ -12464,101 +11835,120 @@ SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHOR 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 = SISGETROMW(romptr); + 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(SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x238] & 0x01)) return; if(!(ROMAddr[0x238] & 0x10)) return; - romptr = ROMAddr[0x247] | (ROMAddr[0x248] << 8); + romptr = SISGETROMW(0x247); } 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 = SISGETROMW(romptr); 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,USHORT ModeIdIndex, - USHORT RefTableIndex) +SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex, USHORT RefTableIndex) { USHORT OEMModeIdIndex=0; if(!SiS_Pr->UseCustomMode) { - OEMModeIdIndex = SiS_SearchVBModeID(SiS_Pr,ROMAddr,&ModeNo); + OEMModeIdIndex = SiS_SearchVBModeID(SiS_Pr,&ModeNo); if(!(OEMModeIdIndex)) return; } if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - SetOEMLCDDelay(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,OEMModeIdIndex); - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - SetOEMLCDData(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,OEMModeIdIndex); - } + 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,OEMModeIdIndex); - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - SetOEMAntiFlicker(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,OEMModeIdIndex); - SetOEMPhaseIncr(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,OEMModeIdIndex); - SetOEMYFilter(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,OEMModeIdIndex); - } + 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 --git a/src/init301.h b/src/init301.h index a8442fe..b0c74dd 100644 --- a/src/init301.h +++ b/src/init301.h @@ -1,36 +1,53 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.h,v 1.23 2003/09/09 10:29:01 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Data and prototypes for init301.c * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * If distributed as part of the linux kernel, the contents of this file - * is entirely covered by the GPL. + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * Otherwise, the following 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 * - * 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) 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 EXPRESSED 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 * - * Based on code by Silicon Intergrated Systems - * */ #ifndef _INIT301_ @@ -65,36 +82,48 @@ #endif #endif -const UCHAR SiS_HiVisionTable[3][64] = { +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, 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 + 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 /*0x8d*/,0x08,0x92,0x8f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x53 /*0x50*/, + 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,0x4c /*0x4f*/,0x13, + 0xad,0x11,0xad,0x1d,0x40,0x8a,0x3d,0xb8, + 0x51,0x5e,0x60,0x57 /*0x49*/,0x7b /*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 +#if 1 + 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,0x21 /*0x2b*/,0x13, + 0x27,0x0b,0x27,0xfc,0x30,0x27,0x1c,0xb0, + 0x4b,0x4b,0x65 /*0x6f*/,0x2f,0x63,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x27, + 0x00,0x40,0x11,0x00,0xfc,0xff,0x32,0x00 +#endif +#if 0 + 0x2a,0x14,0xe8,0x09,0x09,0xed,0x0c,0x0c, /* TEST (0.93) - BAD */ + 0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a, + 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f, + 0xed,0x50,0x70,0x9e,0x16,0x57,0x6c,0x13, + 0x27,0x0b,0x27,0xfb,0x30,0x27,0x15,0xb0, + 0x3b,0xdb,0x61,0x24,0x78,0x92,0x0f,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0x14,0x6f, + 0x00,0x52,0xbb,0x00,0xd5,0xf7,0xa2,0x00 +#endif } }; @@ -120,256 +149,266 @@ const UCHAR SiS_HiTVGroup3_2[] = { 0x18, 0x1d, 0x23, 0x28, 0x4c, 0xaa, 0x01 }; -extern BOOLEAN SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *RomAddr, USHORT *); +/* 301C / 302ELV extended Part2 TV registers */ -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_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_IsDualLink(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, - PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -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, - USHORT BaseAddr); -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_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, - PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -#endif -void SiS_SetTPData(SiS_Private *SiS_Pr); -void SiS_SetChrontelGPIO(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); +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,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 -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,USHORT RefreshRateTableIndex); +/* 661 et al LCD data structure (0.94.0) */ +static const UCHAR SiS_LCDStruct661[] = { + /* 1024x768 */ +/* type|CR37| HDE | VDE | HT | VT | hss | hse */ + 0x02,0xC0,0x00,0x04,0x00,0x03,0x40,0x05,0x26,0x03,0x10,0x00,0x88, + 0x00,0x02,0x00,0x06,0x00,0x41,0x5A,0x64,0x00,0x00,0x00,0x00,0x04, + /* | vss | vse |clck| clock |CRT2DataP|CRT2DataP|idx */ + /* VESA non-VESA noscale */ + /* 1280x1024 */ + 0x03,0xC0,0x00,0x05,0x00,0x04,0x98,0x06,0x2A,0x04,0x30,0x00,0x70, + 0x00,0x01,0x00,0x03,0x00,0x6C,0xF8,0x2F,0x00,0x00,0x00,0x00,0x08, + /* 1400x1050 */ + 0x09,0x20,0x78,0x05,0x1A,0x04,0x98,0x06,0x2A,0x04,0x18,0x00,0x38, + 0x00,0x01,0x00,0x03,0x00,0x6C,0xF8,0x2F,0x00,0x00,0x00,0x00,0x09, + /* 1600x1200 */ + 0x0B,0xC0,0x40,0x06,0xB0,0x04,0x70,0x08,0xE2,0x04,0x40,0x00,0xC0, + 0x00,0x01,0x00,0x03,0x00,0xA2,0x70,0x24,0x00,0x00,0x00,0x00,0x0B, + /* 1280x768 */ + 0x0A,0xC0,0x00,0x05,0x00,0x03,0x80,0x05,0x26,0x03,0x10,0x00,0x40, + 0x00,0x03,0x00,0x06,0x00,0x44,0x63,0x46,0x00,0x00,0x00,0x00,0x06, + /* 1280x720 */ + 0x0E,0xE0,0x00,0x05,0xD0,0x02,0x80,0x05,0x26,0x03,0x10,0x00,0x02, + 0x00,0x01,0x00,0x06,0x00,0x45,0x9C,0x62,0x00,0x00,0x00,0x00,0x05, + /* 1280x800 */ + 0x0C,0xE0,0x00,0x05,0x20,0x03,0x80,0x05,0x30,0x03,0x10,0x00,0x40, + 0x00,0x04,0x00,0x03,0x00,0x45,0x9C,0x62,0x00,0x00,0x00,0x00,0x07, + /* 1680x1050 */ + 0x0D,0xE0,0x90,0x06,0x1A,0x04,0x6C,0x07,0x2A,0x04,0x1A,0x00,0x4C, + 0x00,0x03,0x00,0x06,0x00,0x79,0xBE,0x44,0x00,0x00,0x00,0x00,0x06, + /* 1280x768 (not in 0.93) */ + 0x0A,0xC0,0x00,0x05,0x00,0x03,0x80,0x06,0x1E,0x03,0x40,0x00,0x80, + 0x00,0x03,0x00,0x07,0x00,0x4F,0x00,0x00,0x00,0x00,0x00,0x00,0x06 +}; #endif + #ifdef SIS300 -void SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo, USHORT ModeIdIndex, USHORT RefTabindex); -void SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr, USHORT ModeNo, USHORT ModeIdIndex,USHORT RefTableIndex); +static UCHAR SiS300_TrumpionData[7][80] = { + { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02, + 0x20,0x03,0x0B,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x10,0x00,0x00,0x04,0x23, + 0x00,0x00,0x03,0x28,0x03,0x10,0x05,0x08,0x40,0x10,0x00,0x10,0x04,0x23,0x00,0x23, + 0x03,0x11,0x60,0xBC,0x01,0xFF,0x03,0xFF,0x19,0x01,0x00,0x05,0x09,0x04,0x04,0x05, + 0x04,0x0C,0x09,0x05,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5A,0x01,0xBE,0x01,0x00 }, + { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x27,0x00,0x80,0x02, + 0x20,0x03,0x07,0x00,0x5E,0x01,0x0D,0x02,0x60,0x0C,0x30,0x11,0x00,0x00,0x04,0x23, + 0x00,0x00,0x03,0x80,0x03,0x28,0x06,0x08,0x40,0x11,0x00,0x11,0x04,0x23,0x00,0x23, + 0x03,0x11,0x60,0x90,0x01,0xFF,0x0F,0xF4,0x19,0x01,0x00,0x05,0x01,0x00,0x04,0x05, + 0x04,0x0C,0x02,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEC,0x57,0x01,0xBE,0x01,0x00 }, + { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x8A,0x00,0xD8,0x02, + 0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23, + 0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23, + 0x03,0x11,0x60,0xD9,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05, + 0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x59,0x01,0xBE,0x01,0x00 }, + { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x72,0x00,0xD8,0x02, + 0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23, + 0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23, + 0x03,0x11,0x60,0xDA,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05, + 0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 }, + { 0x02,0x0A,0x02,0x00,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02, + 0x20,0x03,0x16,0x00,0xE0,0x01,0x0D,0x02,0x60,0x0C,0x30,0x98,0x00,0x00,0x04,0x23, + 0x00,0x01,0x03,0x45,0x03,0x48,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x23,0x00,0x23, + 0x03,0x11,0x60,0xF4,0x01,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x05,0x01,0x00,0x05,0x05, + 0x04,0x0C,0x08,0x05,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 }, + { 0x02,0x0A,0x02,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0xBF,0x00,0x20,0x03, + 0x20,0x04,0x0D,0x00,0x58,0x02,0x71,0x02,0x80,0x0C,0x30,0x9A,0x00,0xFA,0x03,0x1D, + 0x00,0x01,0x03,0x22,0x03,0x28,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x1D,0x00,0x1D, + 0x03,0x11,0x60,0x39,0x03,0x40,0x05,0xF4,0x18,0x07,0x02,0x06,0x04,0x01,0x06,0x0B, + 0x02,0x0A,0x20,0x19,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 }, + { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0xEF,0x00,0x00,0x04, + 0x40,0x05,0x13,0x00,0x00,0x03,0x26,0x03,0x88,0x0C,0x30,0x90,0x00,0x00,0x04,0x23, + 0x00,0x01,0x03,0x24,0x03,0x28,0x06,0x08,0x40,0x90,0x00,0x90,0x04,0x23,0x00,0x23, + 0x03,0x11,0x60,0x40,0x05,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x08,0x01,0x00,0x08,0x01, + 0x00,0x08,0x01,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 } +}; #endif -BOOLEAN SiS_LowModeStuff(SiS_Private *SiS_Pr, USHORT ModeNo,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void 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); */ +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); -BOOLEAN SiS_SetCRT2Group(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 +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_SetCRT2FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_CRT2AutoThreshold(SiS_Private *SiS_Pr, USHORT BaseAddr); +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 */ +#ifdef SIS300 +void SiS_SetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx); +USHORT SiS_GetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx); +static BOOLEAN SiS_SetTrumpionBlock(SiS_Private *SiS_Pr, UCHAR *dataptr); #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); +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); -void SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -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, PSIS_HW_DEVICE_INFO HwDeviceExtension); -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, PSIS_HW_DEVICE_INFO HwDeviceExtension); -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); +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 -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); +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 - -/* DDC functions */ -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); +#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); + +extern void SiS_CalcLCDACRT1Timing(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex); + #endif diff --git a/src/initdef.h b/src/initdef.h index 6fdc3d2..13fc262 100644 --- a/src/initdef.h +++ b/src/initdef.h @@ -1,45 +1,76 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/initdef.h,v 1.17 2003/08/26 20:40:23 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Global definitions for init.c and init301.c * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * If distributed as part of the linux kernel, the contents of this file - * is entirely covered by the GPL. + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * Otherwise, the following 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 * - * 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) 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 EXPRESSED 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 * - * Based on code by Silicon Intergrated Systems - * */ #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) + +#define SISGETROMW(x) (ROMAddr[(x)] | (ROMAddr[(x)+1] << 8)) /* SiS_VBType */ #define VB_SIS301 0x0001 @@ -47,34 +78,43 @@ #define VB_SIS302B 0x0004 #define VB_SIS301LV 0x0008 #define VB_SIS302LV 0x0010 -#define VB_SIS301C 0x0020 -#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_SIS301C|VB_SIS302B|VB_SIS301LV|VB_SIS302LV) +#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) +#define VB_SIS301LV302LV (VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV) +#define VB_SISVB (VB_SIS301 | VB_SIS301BLV302BLV) +#define VB_SISTMDS (VB_SIS301 | VB_SIS301B302B) +#define VB_SISLVDS VB_SIS301LV302LV -#define IS_SIS330 (HwDeviceExtension->jChipType == SIS_330) -#define IS_SIS550 (HwDeviceExtension->jChipType == SIS_550) -#define IS_SIS650 (HwDeviceExtension->jChipType == SIS_650) -#define IS_SIS740 (HwDeviceExtension->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_SIS661 (SiS_Pr->SiS_SysFlags & (SF_Is661 | SF_IsM651)) -#define IS_SIS741 (SiS_Pr->SiS_SysFlags & SF_IsM741) -#define IS_SIS65x (IS_SIS651 || IS_SISM650) -#define IS_SIS661741 (SiS_Pr->SiS_SysFlags & (SF_Is661 | SF_IsM661 | SF_Is741)) -#define IS_SIS660 (HwDeviceExtension->jChipType == SIS_660) -#define IS_SIS760 (HwDeviceExtension->jChipType == SIS_760) -#define IS_SIS650660 (IS_SIS650 || IS_SIS660) -#define IS_SIS650740 ((HwDeviceExtension->jChipType >= SIS_650) && (HwDeviceExtension->jChipType < SIS_330)) -#define IS_SIS650740660 (IS_SIS650 || IS_SIS660 || IS_SIS740 || IS_SIS760) -#define IS_SIS550650740660 (IS_SIS550 || IS_SIS650 || IS_SIS660 || IS_SIS740 || IS_SIS760) - -#define CRT1Len 17 -#define LVDSCRT1Len 15 -#define CHTVRegDataLen 5 +/* 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 @@ -99,82 +139,72 @@ #define CRT2Mode 0x0800 #define HalfDCLK 0x1000 #define NoSupportSimuTV 0x2000 +#define NoSupportLCDScale 0x4000 /* TMDS: No scaling possible (no matter what panel) */ #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 SupportYPbPr750p 0x1000 +#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 /* 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 - -/* SysFlags */ +#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 /* new 0x10 */ +#define TVSetYPbPr525p 0x0040 /* new 0x20 */ +#define TVSetYPbPr750p 0x0080 /* new 0x40 */ +#define TVSetHiVision 0x0100 /* new 0x80; = 1080i, software-wise identical */ +#define TVSetTVSimuMode 0x0200 /* new 0x200, prev. 0x800 */ +#define TVRPLLDIV2XO 0x0400 /* prev 0x1000 */ +#define TVSetNTSC1024 0x0800 /* new 0x100, prev. 0x2000 */ +#define TVAspect43 0x2000 +#define TVAspect169 0x4000 +#define TVAspect43LB 0x8000 + +/* YPbPr flag (>=315, <661; converted to TVMode) */ +#define YPbPr525p 0x0001 +#define YPbPr750p 0x0002 +#define YPbPr525i 0x0004 +#define YPbPrHiVision 0x0008 +#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_Is661 0x0020 -#define SF_IsM661 0x0040 -#define SF_Is741 0x0080 -#define SF_Is660 0x8000 - -#define PanelRGB18Bit 0x0100 -#define PanelRGB24Bit 0x0000 - -#define TVOverScan 0x10 /* Bit in CR35 (300 series only) */ -#define TVOverScanShift 4 -#define ClearBufferFlag 0x20 +#define SF_IsM661 0x0020 +#define SF_IsM741 0x0040 +#define SF_IsM760 0x0080 +#define SF_760LFB 0x8000 /* 760: We have LFB */ /* CR32 (Newer 630, and 315 series) @@ -185,9 +215,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) @@ -198,11 +251,14 @@ 011 LVDS + Tumpion Zurac 100 LVDS + Chrontel 7005 110 Chrontel 7005 - 315 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 @@ -219,37 +275,60 @@ /* CR37: LCDInfo */ #define LCDRGB18Bit 0x0001 #define LCDNonExpanding 0x0010 +#define LCDSync 0x0020 +#define LCDPass11 0x0100 /* 0: center screen, 1: Pass 1:1 data */ +#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 (315 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 EnableHiVision750 0x08 /* Enable 750P HiVision mode (30xLV only) */ -#define EnableHiVision525 0x10 /* Enable 525P HiVision mode (30xLV only) */ -#define SiSHiVision2 0x20 /* ? - | --- mask 0x38 combinations have different meaning! */ +#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 SetSCARTOutput 0x01 -#define BoardTVType 0x02 +#define EnableNTSCJ EnablePALM /* Not BIOS */ + +/* 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) */ -#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 */ +/* CR39 (650 only) */ +#define LCDPass1_1 0x01 /* 0: center screen, 1: pass 1:1 data output */ +#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 (315 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 @@ -276,7 +355,7 @@ #define Panel300_1024x600 0x06 #define Panel300_1152x768 0x07 #define Panel300_1280x768 0x0a -#define Panel300_320x480 0x0e /* fstn - TW: This is fake, can be any */ +#define Panel300_320x480 0x0e /* fstn - This is fake, can be any */ #define Panel300_Custom 0x0f #define Panel300_Barco1366 0x10 @@ -296,8 +375,24 @@ #define Panel310_320x480 0x0e /* fstn - TW: This is fake, can be any */ #define Panel310_Custom 0x0f +#define Panel661_800x600 0x01 +#define Panel661_1024x768 0x02 +#define Panel661_1280x1024 0x03 +#define Panel661_640x480 0x04 +#define Panel661_1024x600 0x05 +#define Panel661_1152x864 0x06 +#define Panel661_1280x960 0x07 +#define Panel661_1152x768 0x08 +#define Panel661_1400x1050 0x09 +#define Panel661_1280x768 0x0a +#define Panel661_1600x1200 0x0b +#define Panel661_1280x800 0x0c +#define Panel661_1680x1050 0x0d +#define Panel661_1280x720 0x0e +#define Panel661_Custom 0x0f + #define Panel_800x600 0x01 /* Unified values */ -#define Panel_1024x768 0x02 +#define Panel_1024x768 0x02 /* MUST match BIOS values from 0-e */ #define Panel_1280x1024 0x03 #define Panel_640x480 0x04 #define Panel_1024x600 0x05 @@ -305,61 +400,59 @@ #define Panel_1280x960 0x07 #define Panel_1152x768 0x08 /* LVDS only */ #define Panel_1400x1050 0x09 -#define Panel_1280x768 0x0a /* LVDS only */ +#define Panel_1280x768 0x0a /* 30xB/C and LVDS only (BIOS: all) */ #define Panel_1600x1200 0x0b -#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 0x0c /* 661etc */ +#define Panel_1680x1050 0x0d /* 661etc */ +#define Panel_1280x720 0x0e /* 661etc */ +#define Panel_Custom 0x0f /* MUST BE 0x0f (for DVI DDC detection */ +#define Panel_320x480 0x10 /* SiS 550 fstn - TW: This is fake, can be any */ +#define Panel_Barco1366 0x11 +#define Panel_848x480 0x12 +#define Panel_640x480_2 0x13 /* SiS 550 */ +#define Panel_640x480_3 0x14 /* SiS 550 */ +#define Panel_1280x768_2 0x15 /* 30xLV */ +#define Panel_1280x768_3 0x16 /* 30xLV */ /* 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_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_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 -#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_1152x864 22 /* Up to here 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 SIS_RI_1680x1050 29 +#define SIS_RI_1280x800 30 +#define SIS_RI_1920x1080 31 +#define SIS_RI_960x540 32 -#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 @@ -372,9 +465,6 @@ #define ExtHiTVHT 2100 #define ExtHiTVVT 1125 -#define VCLKStartFreq 25 -#define SoftDramType 0x80 - /* Indices in (VB)VCLKData tables */ #define VCLK28 0x00 /* Index in VCLKData table (300 and 315) */ @@ -385,13 +475,32 @@ #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 VCLK_CUSTOM_300 0x46 #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 VCLK162_315 0x5e /* 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 VCLK34_315 0x55 +#define VCLK68_315 0x0d +#define VCLK69_315 0x5c /* deprecated ! Index in VBVCLKData table (315) */ +#define VCLK83_315 0x5c /* Index in VBVCLKData table (315) */ +#define VCLK121_315 0x5d /* Index in VBVCLKData table (315) */ +#define VCLK_1280x720 0x5f +#define VCLK_1280x768_2 0x60 +#define VCLK_1280x768_3 0x61 +#define VCLK_CUSTOM_315 0x62 +#define VCLK_1280x720_2 0x63 +#define VCLK_720x480 0x67 +#define VCLK_720x576 0x68 +#define VCLK_768x576 0x68 +#define VCLK_848x480 0x65 +#define VCLK_856x480 0x66 +#define VCLK_800x480 0x65 +#define VCLK_1024x576 0x51 +#define VCLK_1152x864 0x64 +#define VCLK_1360x768 0x58 #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) */ @@ -401,25 +510,14 @@ #define HiTVVCLK 0x03 /* Index relative to TVCLKBASE */ #define HiTVSimuVCLK 0x04 /* Index relative to TVCLKBASE */ #define HiTVTextVCLK 0x05 /* Index relative to TVCLKBASE */ +#define YPbPr750pVCLK 0x25 /* Index relative to TVCLKBASE; was 0x0f NOT relative */ /* ------------------------------ */ -#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 @@ -436,8 +534,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 @@ -448,8 +549,6 @@ #define SoftSettingAddr 0x52 #define ModeSettingAddr 0x53 -#define SelectCRT1Rate 0x4 - #define _PanelType00 0x00 #define _PanelType01 0x08 #define _PanelType02 0x10 @@ -468,7 +567,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 @@ -511,7 +611,7 @@ /* ============================================================= - for 315 series + for 315 series (old data layout) ============================================================= */ #define SoftDRAMType 0x80 diff --git a/src/oem300.h b/src/oem300.h index 9bf1a5d..d644464 100644 --- a/src/oem300.h +++ b/src/oem300.h @@ -1,36 +1,53 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/oem300.h,v 1.8 2003/06/19 13:28:01 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * OEM Data for 300 series * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * If distributed as part of the linux kernel, the contents of this file - * is entirely covered by the GPL. + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * Otherwise, the following 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 * - * 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) 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 EXPRESSED 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 * - * Based on code by Silicon Intergrated Systems - * */ const UCHAR SiS300_OEMTVDelay301[8][4] = @@ -277,140 +294,124 @@ const UCHAR SiS300_OEMLCDDelay3[64][4] = { /* For LVDS */ {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} } }; diff --git a/src/oem310.h b/src/oem310.h index 15f41d3..e99496e 100644 --- a/src/oem310.h +++ b/src/oem310.h @@ -1,39 +1,56 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/oem310.h,v 1.12 2003/08/07 15:04:41 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * OEM Data for 315/330 series * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * If distributed as part of the linux kernel, the contents of this file - * is entirely covered by the GPL. + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * Otherwise, the following 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 * - * 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) 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 EXPRESSED 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 * - * Based on code by Silicon Intergrated Systems - * */ -const UCHAR SiS310_LCDDelayCompensation_301[] = /* 301 */ +static const UCHAR SiS310_LCDDelayCompensation_301[] = /* 301 */ { 0x00,0x00,0x00, /* 800x600 */ 0x0b,0x0b,0x0b, /* 1024x768 */ @@ -53,7 +70,7 @@ const UCHAR SiS310_LCDDelayCompensation_301[] = /* 301 */ }; /* 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 */ @@ -72,65 +89,7 @@ UCHAR SiS310_LCDDelayCompensation_650301B[] = /* 30xB,LV */ 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 */ -{ - 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 */ +static const UCHAR SiS310_LCDDelayCompensation_651301LV[] = /* M650/651 301LV */ { 0x33,0x33,0x33, /* 800x600 (guessed) - new: PanelType, not PanelRes ! */ 0x33,0x33,0x33, /* 1024x768 */ @@ -149,7 +108,7 @@ const UCHAR SiS310_LCDDelayCompensation_651301LV[] = /* M650/651 301LV */ 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 */ @@ -168,66 +127,130 @@ const UCHAR SiS310_LCDDelayCompensation_651302LV[] = /* M650/651 302LV */ 0x33,0x33,0x33 }; -const UCHAR SiS310_TVDelayCompensation_301[] = /* 301 */ +static const UCHAR SiS310_LCDDelayCompensation_3xx301B[] = /* 30xB */ +{ + 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_LCDDelayCompensation_3xx301LV[] = /* 315+30xLV */ +{ + 0x01,0x01,0x01, /* 800x600 */ + 0x04,0x04,0x04, /* 1024x768 (A531/BIOS 1.14.05f: 4 - works with 6 */ + 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 */ -{ - 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_TVDelayCompensation_LVDS[] = /* LVDS */ +{ + 0x0a,0x0a, + 0x0a,0x0a, + 0x0a,0x0a +}; + +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}, @@ -237,7 +260,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}, @@ -247,7 +270,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}, @@ -255,13 +278,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}, @@ -272,7 +315,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}, @@ -283,6 +326,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}, @@ -291,53 +335,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}, @@ -346,11 +346,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}, @@ -359,9 +357,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}, @@ -377,15 +376,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}, @@ -393,7 +392,31 @@ const UCHAR SiS310_TVPhaseIncr2[3][2][4] = } }; -/* OEM data for Compaq Presario 3045US */ +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}, @@ -406,111 +429,21 @@ static const SiS_LCDDataStruct SiS310_ExtCompaq1280x1024Data[] = { 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}} -}; +/* Asus A2xxxH _2 */ -static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Clevo1024x768_1[] = +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Asus1024x768_3[] = { - {{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}}, + {{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,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}}, + {{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,0x12,0xC9,0xDC,0xB6,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}} + {{0x25,0x13,0xc9,0x25,0xff,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}} -}; -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 }, - { 0, 794 }, - { 0, 0 } -}; diff --git a/src/osdef.h b/src/osdef.h index 3230658..098580d 100644 --- a/src/osdef.h +++ b/src/osdef.h @@ -1,93 +1,127 @@ - -/* OS depending defines */ +/* $XFree86$ */ +/* $XdotOrg$ */ +/* + * 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) 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 EXPRESSED 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 - -#ifdef CONFIG_FB_SIS_300 -#define SIS300 -#endif - -#ifdef CONFIG_FB_SIS_315 -#define SIS315H -#endif - -#if 1 -#define SISFBACCEL /* Include 2D acceleration */ -#endif - -#endif - -#ifdef LINUX_XF86 /* ----------------------------- */ -#define SIS300 -#define SIS315H -#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 - -#ifdef LINUX_XF86 -#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize) -#define SiS_MemoryCopy(Destination,Soruce,Length) memcpy(Destination,Soruce,Length) -#endif - -/**********************************************************************/ +#define LINUX_XF86 /* XFree86/X.org */ #ifdef OutPortByte #undef OutPortByte -#endif /* OutPortByte */ +#endif #ifdef OutPortWord #undef OutPortWord -#endif /* OutPortWord */ +#endif #ifdef OutPortLong #undef OutPortLong -#endif /* OutPortLong */ +#endif #ifdef InPortByte #undef InPortByte -#endif /* InPortByte */ +#endif #ifdef InPortWord #undef InPortWord -#endif /* InPortWord */ +#endif #ifdef InPortLong #undef InPortLong -#endif /* InPortLong */ +#endif /**********************************************************************/ /* LINUX KERNEL */ /**********************************************************************/ #ifdef LINUX_KERNEL -#define OutPortByte(p,v) outb((u8)(v),(u16)(p)) -#define OutPortWord(p,v) outw((u16)(v),(u16)(p)) -#define OutPortLong(p,v) outl((u32)(v),(u16)(p)) -#define InPortByte(p) inb((u16)(p)) -#define InPortWord(p) inw((u16)(p)) -#define InPortLong(p) inl((u16)(p)) +#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 + +#define OutPortByte(p,v) outb((u8)(v),(IOADDRESS)(p)) +#define OutPortWord(p,v) outw((u16)(v),(IOADDRESS)(p)) +#define OutPortLong(p,v) outl((u32)(v),(IOADDRESS)(p)) +#define InPortByte(p) inb((IOADDRESS)(p)) +#define InPortWord(p) inw((IOADDRESS)(p)) +#define InPortLong(p) inl((IOADDRESS)(p)) +#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset_io(MemoryAddress, value, MemorySize) #endif /**********************************************************************/ -/* LINUX XF86 */ +/* XFree86/X.org */ /**********************************************************************/ #ifdef LINUX_XF86 -#define OutPortByte(p,v) outb((CARD16)(p),(CARD8)(v)) -#define OutPortWord(p,v) outw((CARD16)(p),(CARD16)(v)) -#define OutPortLong(p,v) outl((CARD16)(p),(CARD32)(v)) -#define InPortByte(p) inb((CARD16)(p)) -#define InPortWord(p) inw((CARD16)(p)) -#define InPortLong(p) inl((CARD16)(p)) +#define SIS300 +#define SIS315H + +#define OutPortByte(p,v) outb((IOADDRESS)(p),(CARD8)(v)) +#define OutPortWord(p,v) outw((IOADDRESS)(p),(CARD16)(v)) +#define OutPortLong(p,v) outl((IOADDRESS)(p),(CARD32)(v)) +#define InPortByte(p) inb((IOADDRESS)(p)) +#define InPortWord(p) inw((IOADDRESS)(p)) +#define InPortLong(p) inl((IOADDRESS)(p)) +#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize) #endif diff --git a/src/sis.h b/src/sis.h index e8fa10c..a0e3d76 100644 --- a/src/sis.h +++ b/src/sis.h @@ -1,46 +1,52 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h,v 1.60 2003/09/09 10:29:01 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Main global data and definitions * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * 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. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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. * - * Authors: - * - * ? - * Thomas Winischhofer + * Authors: Thomas Winischhofer + * others (old code base) * */ + #ifndef _SIS_H #define _SIS_H_ /* Always unlock the registers (should be set!) */ #define UNLOCK_ALWAYS -#define SISDRIVERVERSIONYEAR 3 -#define SISDRIVERVERSIONMONTH 9 -#define SISDRIVERVERSIONDAY 9 +#define SISDRIVERVERSIONYEAR 4 +#define SISDRIVERVERSIONMONTH 6 +#define SISDRIVERVERSIONDAY 16 #define SISDRIVERREVISION 1 -#define SISDRIVERIVERSION (SISDRIVERVERSIONYEAR << 16) | (SISDRIVERVERSIONMONTH << 8) \ - | SISDRIVERVERSIONDAY | (SISDRIVERREVISION << 24) +#define SISDRIVERIVERSION (SISDRIVERVERSIONYEAR << 16) | \ + (SISDRIVERVERSIONMONTH << 8) | \ + SISDRIVERVERSIONDAY | \ + (SISDRIVERREVISION << 24) #if 0 #define TWDEBUG /* for debugging */ @@ -60,17 +66,22 @@ #include "xaa.h" #include "vgaHW.h" #include "vbe.h" + #include "osdef.h" #include "vgatypes.h" #include "vstruct.h" +#ifdef XORG_VERSION_CURRENT +#define SISMYSERVERNAME "X.org" +#else +#define SISMYSERVERNAME "XFree86" +#endif + #ifdef XF86DRI #undef SISNEWDRI -#if 0 /* Need to wait for the DRI merge */ -#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,99,??,0) +#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,99,14,0) #define SISNEWDRI #endif -#endif #include "xf86drm.h" #include "sarea.h" #define _XF86DRI_SERVER_ @@ -80,36 +91,32 @@ #include "sis_dri.h" #endif -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,0,0,0) -typedef unsigned long IOADDRESS; -#endif - #if 1 -#define SISDUALHEAD /* Include Dual Head code */ +#define SISDUALHEAD /* Include Dual Head code */ #endif #if 1 -#define SISMERGED /* Include Merged-FB mode */ +#define SISMERGED /* Include Merged-FB mode */ #endif #ifdef SISMERGED #if 1 -#define SISXINERAMA /* Include SiS Pseudo-Xinerama for MergedFB mode */ +#define SISXINERAMA /* Include SiS Pseudo-Xinerama for MergedFB mode */ #define SIS_XINERAMA_MAJOR_VERSION 1 #define SIS_XINERAMA_MINOR_VERSION 1 #endif #endif -#if 0 /* Include code for cycling CRT2 type via keyboard */ -#define CYCLECRT2 /* (not functional yet) */ +#if 1 /* Include code for gamma correction */ +#define SISGAMMA #endif -#if 1 -#define SISGAMMA /* Include code for gamma correction */ +#if 1 /* Include code for color hardware cursors */ +#define SIS_ARGB_CURSOR #endif -#if 1 /* Include code for color hardware cursors */ -#define SIS_ARGB_CURSOR +#if 1 /* Include YPbPr support on SiS bridges (315 series and 661/741/760) */ +#define ENABLE_YPBPR #endif #ifdef SISMERGED @@ -125,29 +132,40 @@ typedef unsigned long IOADDRESS; #define SISVRAMQ /* Use VRAM queue mode on 315 series */ #endif +/* Include support for YUV->RGB blit adaptors (VRAM queue mode only) */ +#undef INCL_YUV_BLIT_ADAPTOR +#ifdef SISVRAMQ +#if 1 +#define INCL_YUV_BLIT_ADAPTOR +#endif +#endif + #undef SIS315DRI /* define this if dri is adapted for 315/330 series */ /* For SiS315/550/650/740/330/660 - these should be moved elsewhere! */ #ifndef PCI_CHIP_SIS315H -#define PCI_CHIP_SIS315H 0x0310 +#define PCI_CHIP_SIS315H 0x0310 #endif #ifndef PCI_CHIP_SIS315 -#define PCI_CHIP_SIS315 0x0315 +#define PCI_CHIP_SIS315 0x0315 #endif #ifndef PCI_CHIP_SIS315PRO -#define PCI_CHIP_SIS315PRO 0x0325 +#define PCI_CHIP_SIS315PRO 0x0325 #endif #ifndef PCI_CHIP_SIS550 -#define PCI_CHIP_SIS550 0x5315 /* 550_VGA */ +#define PCI_CHIP_SIS550 0x5315 /* 550_VGA */ #endif #ifndef PCI_CHIP_SIS650 -#define PCI_CHIP_SIS650 0x6325 /* 650_VGA and 740_VGA */ +#define PCI_CHIP_SIS650 0x6325 /* 650_VGA and 740_VGA */ #endif #ifndef PCI_CHIP_SIS330 -#define PCI_CHIP_SIS330 0x0330 +#define PCI_CHIP_SIS330 0x0330 #endif #ifndef PCI_CHIP_SIS660 -#define PCI_CHIP_SIS660 0x6330 /* 660_VGA and 760_VGA (obviously DOA) */ +#define PCI_CHIP_SIS660 0x6330 /* 661_VGA, 741_VGA, 760_VGA */ +#endif +#ifndef PCI_CHIP_SIS340 +#define PCI_CHIP_SIS340 0x0340 #endif #define SIS_NAME "SIS" @@ -179,28 +197,28 @@ typedef unsigned long IOADDRESS; /* VBFlags - if anything is changed here, increase VBFlagsVersion! */ #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_LCD 0x00000002 /* Never change the order of the CRT2_XXX entries */ +#define CRT2_TV 0x00000004 #define CRT2_VGA 0x00000008 -#define CRT2_ENABLE (CRT2_LCD | CRT2_TV | CRT2_VGA) -#define DISPTYPE_DISP2 CRT2_ENABLE #define TV_NTSC 0x00000010 #define TV_PAL 0x00000020 #define TV_HIVISION 0x00000040 -#define TV_HIVISION_LV 0x00000080 -#define TV_TYPE (TV_NTSC | TV_PAL | TV_HIVISION | TV_HIVISION_LV) +#define TV_YPBPR 0x00000080 #define TV_AVIDEO 0x00000100 #define TV_SVIDEO 0x00000200 #define TV_SCART 0x00000400 -#define TV_INTERFACE (TV_AVIDEO | TV_SVIDEO | TV_SCART | TV_CHSCART | TV_CHHDTV) -#define VB_USELCDA 0x00000800 +#define VB_CONEXANT 0x00000800 /* 661 series only */ +#define VB_TRUMPION VB_CONEXANT /* 300 series only */ #define TV_PALM 0x00001000 #define TV_PALN 0x00002000 +#define TV_NTSCJ 0x00001000 +#define VB_302ELV 0x00004000 #define TV_CHSCART 0x00008000 -#define TV_CHHDTV 0x00010000 +#define TV_CHYPBPR525I 0x00010000 +#define CRT1_VGA 0x00000000 +#define CRT1_LCDA 0x00020000 #define VGA2_CONNECTED 0x00040000 #define DISPTYPE_CRT1 0x00080000 /* CRT1 connected and used */ -#define DISPTYPE_DISP1 DISPTYPE_CRT1 #define VB_301 0x00100000 /* Video bridge type */ #define VB_301B 0x00200000 #define VB_302B 0x00400000 @@ -209,22 +227,43 @@ typedef unsigned long IOADDRESS; #define VB_CHRONTEL 0x02000000 #define VB_301LV 0x04000000 #define VB_302LV 0x08000000 -#define VB_30xLV VB_301LV -#define VB_30xLVX VB_302LV #define VB_301C 0x10000000 -#define VB_VIDEOBRIDGE (VB_301|VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV| \ - VB_LVDS|VB_CHRONTEL) -#define VB_SISBRIDGE (VB_301|VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV) #define SINGLE_MODE 0x20000000 /* CRT1 or CRT2; determined by DISPTYPE_CRTx */ -#define VB_DISPMODE_SINGLE SINGLE_MODE /* alias */ #define MIRROR_MODE 0x40000000 /* CRT1 + CRT2 identical (mirror mode) */ -#define VB_DISPMODE_MIRROR MIRROR_MODE /* alias */ #define 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) + +/* 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 TV_YPBPR43LB TV_CHSCART +#define TV_YPBPR43 TV_CHYPBPR525I +#define TV_YPBPR169 (TV_CHSCART | TV_CHYPBPR525I) +#define TV_YPBPRAR (TV_CHSCART | TV_CHYPBPR525I) + +#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_SISLVDSBRIDGE (VB_301LV|VB_302LV|VB_302ELV) +#define VB_SISTMDSBRIDGE (VB_301|VB_301B|VB_301C|VB_302B) + +#define DISPTYPE_DISP2 CRT2_ENABLE +#define DISPTYPE_DISP1 DISPTYPE_CRT1 +#define VB_DISPMODE_SINGLE SINGLE_MODE /* alias */ +#define VB_DISPMODE_MIRROR MIRROR_MODE /* alias */ #define VB_DISPMODE_DUAL DUALVIEW_MODE /* alias */ -#define DISPLAY_MODE (SINGLE_MODE | MIRROR_MODE | DUALVIEW_MODE) /* TW */ +#define DISPLAY_MODE (SINGLE_MODE | MIRROR_MODE | DUALVIEW_MODE) -/* TW: pSiS->VBLCDFlags */ -#define VB_LCD_320x480 0x00000001 /* TW: DSTN/FSTN for 550 */ +/* pSiS->VBLCDFlags */ +#define VB_LCD_320x480 0x00000001 /* DSTN/FSTN for 550 */ #define VB_LCD_640x480 0x00000002 #define VB_LCD_800x600 0x00000004 #define VB_LCD_1024x768 0x00000008 @@ -240,28 +279,23 @@ typedef unsigned long IOADDRESS; #define VB_LCD_640x480_2 0x00002000 /* DSTN/FSTN */ #define VB_LCD_640x480_3 0x00004000 /* DSTN/FSTN */ #define VB_LCD_848x480 0x00008000 /* LVDS only, otherwise handled as custom */ +#define VB_LCD_1280x800 0x00010000 +#define VB_LCD_1680x1050 0x00020000 +#define VB_LCD_1280x720 0x00040000 #define VB_LCD_BARCO1366 0x20000000 #define VB_LCD_CUSTOM 0x40000000 #define VB_LCD_EXPANDING 0x80000000 +/* PresetMode argument */ +#define SIS_MODE_SIMU 0 +#define SIS_MODE_CRT1 1 +#define SIS_MODE_CRT2 2 + /* pSiS->MiscFlags */ #define MISC_CRT1OVERLAY 0x00000001 /* Current display mode supports overlay */ #define MISC_PANELLINKSCALER 0x00000002 /* Panel link is currently scaling */ - -/* More or less useful macros (although we often use pSiS->VGAEngine instead) */ -#define SIS_IS_300_CHIPSET (pSiS->Chipset == PCI_CHIP_SIS300) || \ - (pSiS->Chipset == PCI_CHIP_SIS630) || \ - (pSiS->Chipset == PCI_CHIP_SIS540) || \ - (pSiS->Chipset == PCI_CHIP_SIS730) - -#define SIS_IS_315_CHIPSET (pSiS->Chipset == PCI_CHIP_SIS315) || \ - (pSiS->Chipset == PCI_CHIP_SIS315H) || \ - (pSiS->Chipset == PCI_CHIP_SIS315PRO) || \ - (pSiS->Chipset == PCI_CHIP_SIS550) || \ - (pSiS->Chipset == PCI_CHIP_SIS650) || \ - (pSiS->Chipset == PCI_CHIP_SIS330) || \ - (pSiS->Chipset == PCI_CHIP_SIS660) || \ - (pSiS->Chipset == PCI_CHIP_SIS760) +#define MISC_CRT1OVERLAYGAMMA 0x00000004 /* Current display mode supports overlay gamma corr on CRT1 */ +#define MISC_TVNTSC1024 0x00000008 /* Current display mode is TV NTSC/PALM/YPBPR525I 1024x768 */ /* SiS6326Flags */ #define SIS6326_HASTV 0x00000001 @@ -271,7 +305,7 @@ typedef unsigned long IOADDRESS; #define SIS6326_TVDETECTED 0x00000010 #define SIS6326_TVON 0x80000000 -#define HW_DEVICE_EXTENSION SIS_HW_DEVICE_INFO +#define HW_DEVICE_EXTENSION SIS_HW_INFO #ifdef DEBUG #define PDEBUG(p) p @@ -291,19 +325,19 @@ typedef unsigned char UChar; #define SIS_530_VGA 1 #define SIS_OLD_VGA 2 #define SIS_300_VGA 3 -#define SIS_315_VGA 4 /* Includes Xabre; see ChipFlags */ +#define SIS_315_VGA 4 /* Includes 330/660/661/741/760 and M versions thereof */ /* oldChipset */ -#define OC_UNKNOWN 0 -#define OC_SIS86201 1 -#define OC_SIS86202 2 -#define OC_SIS6205A 3 -#define OC_SIS6205B 4 -#define OC_SIS82204 5 -#define OC_SIS6205C 6 -#define OC_SIS6225 7 -#define OC_SIS5597 8 -#define OC_SIS6326 9 +#define OC_UNKNOWN 0 +#define OC_SIS86201 1 +#define OC_SIS86202 2 +#define OC_SIS6205A 3 +#define OC_SIS6205B 4 +#define OC_SIS82204 5 +#define OC_SIS6205C 6 +#define OC_SIS6225 7 +#define OC_SIS5597 8 +#define OC_SIS6326 9 #define OC_SIS530A 11 #define OC_SIS530B 12 #define OC_SIS620 13 @@ -314,53 +348,113 @@ typedef unsigned char UChar; /* ChipFlags */ /* Use only lower 16 bit for chip id! (sisctrl) */ -#define SiSCF_LARGEOVERLAY 0x00000001 -#define SiSCF_Is651 0x00000002 -#define SiSCF_IsM650 0x00000004 -#define SiSCF_IsM652 0x00000008 -#define SiSCF_IsM653 0x00000010 -#define SiSCF_Is652 0x00000020 -#define SiSCF_Is661FX 0x00000040 -#define SiSCF_IsM661FX 0x00000080 -#define SiSCF_Is661 (SiSCF_Is661FX | SiSCF_IsM661FX) -#define SiSCF_Is741 0x00000100 -#define SiSCF_Is65x (SiSCF_Is651|SiSCF_IsM650|SiSCF_IsM652|SiSCF_IsM653| \ - SiSCF_Is652|SiSCF_Is661FX|SiSCF_IsM661FX|SiSCF_Is741) -#define SiSCF_IsM660 0x00000200 -#define SiSCF_IsM760 0x00000400 -#define SiSCF_Is66x (SiSCF_IsM660 | SiSCF_IsM760) -#define SiSCF_XabreCore 0x00010000 -#define SiSCF_Glamour3 0x40000000 -#define SiSCF_Integrated 0x80000000 - +#define SiSCF_LARGEOVERLAY 0x00000001 +#define SiSCF_Is651 0x00000002 +#define SiSCF_IsM650 0x00000004 +#define SiSCF_IsM652 0x00000008 +#define SiSCF_IsM653 0x00000010 +#define SiSCF_Is652 0x00000020 +#define SiSCF_Is65x (SiSCF_Is651|SiSCF_IsM650|SiSCF_IsM652|SiSCF_IsM653|SiSCF_Is652) +#define SiSCF_IsM661 0x00000100 /* M661FX */ +#define SiSCF_IsM741 0x00000200 +#define SiSCF_IsM760 0x00000400 +#define SiSCF_IsM661M 0x00000800 /* M661MX */ +#define SiSCF_IsM66x (SiSCF_IsM661 | SiSCF_IsM741 | SiSCF_IsM760 | SiSCF_IsM661M) +#define SiSCF_315Core 0x00010000 /* 3D: Real 315 */ +#define SiSCF_Real256ECore 0x00020000 /* 3D: Similar to 315 core, no T&L? (65x, 661, 740, 741) */ +#define SiSCF_XabreCore 0x00040000 /* 3D: Real Xabre */ +#define SiSCF_Ultra256Core 0x00080000 /* 3D: aka "Mirage 2"; similar to Xabre, no T&L?, no P:Shader? (760) */ +#define SiSCF_UseLCDA 0x01000000 +#define SiSCF_760LFB 0x08000000 /* 760: LFB active (if not set, UMA only) */ +#define SiSCF_760UMA 0x10000000 /* 760: UMA active (if not set, LFB only) */ +#define SiSCF_CRT2HWCKaputt 0x20000000 /* CRT2 Mono HWCursor engine buggy (SiS 330) */ +#define SiSCF_Glamour3 0x40000000 +#define SiSCF_Integrated 0x80000000 /* SiS Direct Xv-API */ -#define SiS_SD_IS300SERIES 0x00000001 -#define SiS_SD_IS315SERIES 0x00000002 -#define SiS_SD_IS330SERIES 0x00000004 -#define SiS_SD_SUPPORTPALMN 0x00000008 /* tv chip supports pal-m, pal-n */ -#define SiS_SD_SUPPORT2OVL 0x00000010 /* set = 2 overlays, 1 = support SWITCHCRT xv prop */ -#define SiS_SD_SUPPORTTVPOS 0x00000020 /* supports changing tv position */ -#define SiS_SD_ISDUALHEAD 0x00000040 /* Driver is in dual head mode */ -#define SiS_SD_ISMERGEDFB 0x00000080 /* Driver is in merged fb mode */ -#define SiS_SD_ISDHSECONDHEAD 0x00000100 /* Dual head: This is CRT1 (=second head) */ -#define SiS_SD_ISDHXINERAMA 0x00000200 /* Dual head: We are running Xinerama */ -#define SiS_SD_VBHASSCART 0x00000400 /* videobridge has SCART instead of VGA2 */ -#define SiS_SD_ISDEPTH8 0x00000800 /* Depth is 8, no independent gamma correction */ -#define SiS_SD_SUPPORTSOVER 0x00001000 /* Support for Chrontel Super Overscan */ -#define SiS_SD_ENABLED 0x00002000 /* sisctrl is enabled (by option) */ -#define SiS_SD_PSEUDOXINERAMA 0x00004000 /* pseudo xinerama is active */ - -#define SIS_DIRECTKEY 0x3145792 +#define SiS_SD_IS300SERIES 0x00000001 +#define SiS_SD_IS315SERIES 0x00000002 +#define SiS_SD_IS330SERIES 0x00000004 +#define SiS_SD_SUPPORTPALMN 0x00000008 /* tv chip supports pal-m, pal-n */ +#define SiS_SD_SUPPORT2OVL 0x00000010 /* set = 2 overlays, clear = support SWITCHCRT xv prop */ +#define SiS_SD_SUPPORTTVPOS 0x00000020 /* supports changing tv position */ +#define SiS_SD_ISDUALHEAD 0x00000040 /* Driver is in dual head mode */ +#define SiS_SD_ISMERGEDFB 0x00000080 /* Driver is in merged fb mode */ +#define SiS_SD_ISDHSECONDHEAD 0x00000100 /* Dual head: This is CRT1 (=second head) */ +#define SiS_SD_ISDHXINERAMA 0x00000200 /* Dual head: We are running Xinerama */ +#define SiS_SD_VBHASSCART 0x00000400 /* videobridge has SCART instead of VGA2 */ +#define SiS_SD_ISDEPTH8 0x00000800 /* Depth is 8, no independent gamma correction */ +#define SiS_SD_SUPPORTSOVER 0x00001000 /* Support for Chrontel Super Overscan */ +#define SiS_SD_ENABLED 0x00002000 /* sisctrl is enabled (by option) */ +#define SiS_SD_PSEUDOXINERAMA 0x00004000 /* pseudo xinerama is active */ +#define SiS_SD_SUPPORTLCDA 0x00008000 /* Support LCD Channel A */ +#define SiS_SD_SUPPORTNTSCJ 0x00010000 /* tv chip supports ntsc-j */ +#define SiS_SD_ADDLSUPFLAG 0x00020000 /* 1 = the following flags are valid */ +#define SiS_SD_SUPPORTVGA2 0x00040000 /* CRT2=VGA supported */ +#define SiS_SD_SUPPORTSCART 0x00080000 /* CRT2=SCART supported */ +#define SiS_SD_SUPPORTOVERSCAN 0x00100000 /* Overscan flag supported */ +#define SiS_SD_SUPPORTXVGAMMA1 0x00200000 /* Xv Gamma correction for CRT1 supported */ +#define SiS_SD_SUPPORTTV 0x00400000 /* CRT2=TV supported */ +#define SiS_SD_SUPPORTYPBPR 0x00800000 /* CRT2=YPbPr (525i, 525p, 750p, 1080i) is supported */ +#define SiS_SD_SUPPORTHIVISION 0x01000000 /* CRT2=HiVision is supported */ +#define SiS_SD_SUPPORTYPBPRAR 0x02000000 /* YPbPr aspect ratio is supported */ +#define SiS_SD_SUPPORTSCALE 0x04000000 /* Scaling of LCD panel supported */ +#define SiS_SD_SUPPORTCENTER 0x08000000 /* If scaling supported: Centering of screen [NOT] supported (TMDS only) */ +#define SiS_SD_SUPPORTREDETECT 0x10000000 /* Support re-detection of CRT2 devices */ +#define SiS_SD_IS340SERIES 0x20000000 + +#define SIS_DIRECTKEY 0x03145792 /* SiSCtrl: Check mode for CRT2 */ -#define SiS_CF2_LCD 0x01 -#define SiS_CF2_TV 0x02 -#define SiS_CF2_VGA2 0x04 -#define SiS_CF2_TVPAL 0x08 -#define SiS_CF2_TVNTSC 0x10 -#define SiS_CF2_TVPALM 0x20 -#define SiS_CF2_TVPALN 0x40 +#define SiS_CF2_LCD 0x01 +#define SiS_CF2_TV 0x02 +#define SiS_CF2_VGA2 0x04 +#define SiS_CF2_TVPAL 0x08 +#define SiS_CF2_TVNTSC 0x10 /* + NTSC-J */ +#define SiS_CF2_TVPALM 0x20 +#define SiS_CF2_TVPALN 0x40 +#define SiS_CF2_CRT1LCDA 0x80 +#define SiS_CF2_TYPEMASK (SiS_CF2_LCD | SiS_CF2_TV | SiS_CF2_VGA2 | SiS_CF2_CRT1LCDA) +#define SiS_CF2_TVSPECIAL (SiS_CF2_LCD | SiS_CF2_TV) +#define SiS_CF2_TVSPECMASK (SiS_CF2_TVPAL | SiS_CF2_TVNTSC | SiS_CF2_TVPALM | SiS_CF2_TVPALN) +#define SiS_CF2_TVHIVISION SiS_CF2_TVPAL +#define SiS_CF2_TVYPBPR525I SiS_CF2_TVNTSC +#define SiS_CF2_TVYPBPR525P (SiS_CF2_TVPAL | SiS_CF2_TVNTSC) +#define SiS_CF2_TVYPBPR750P SiS_CF2_TVPALM +#define SiS_CF2_TVYPBPR1080I (SiS_CF2_TVPALM | SiS_CF2_TVPAL) + +/* AGP stuff for DRI */ +#define AGP_PAGE_SIZE 4096 +#define AGP_PAGES 2048 /* Default: 2048 pages @ 4096 = 8MB */ +/* 300 */ +#define AGP_CMDBUF_PAGES 256 +#define AGP_CMDBUF_SIZE (AGP_PAGE_SIZE * AGP_CMDBUF_PAGES) +/* 315/330 */ +#define AGP_VTXBUF_PAGES 512 +#define AGP_VTXBUF_SIZE (AGP_PAGE_SIZE * AGP_VTXBUF_PAGES) + +/* Used for mapping a0000 and saving/restoring fonts (or not doing so) */ +/* List of architectures likely to be incomplete */ +#define SIS_PC_PLATFORM +#if defined(__powerpc__) || defined(__mips__) || defined(__arm32__) +#undef SIS_PC_PLATFORM +#endif + +#if 0 +/* Used for mapping i/o port area to virtual memory (or not doing so) */ +/* List of architectures likely to be incomplete */ +/* BROKEN, see comment in sis_driver.c */ +#undef SIS_NEED_MAP_IOP +#if defined(__arm32__) || defined(__mips__) +#define SIS_NEED_MAP_IOP +#endif +#endif + +/* Used for makeing use of the BIOS scratch area (save/restore mode number) */ +#undef SIS_USE_BIOS_SCRATCH +#if (defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__)) +#define SIS_USE_BIOS_SCRATCH +#endif /* For backup of register contents */ typedef struct { @@ -370,7 +464,7 @@ typedef struct { unsigned char sisCapt[0x60]; unsigned char sisVid[0x50]; unsigned char VBPart1[0x50]; - unsigned char VBPart2[0x50]; + unsigned char VBPart2[0x100]; unsigned char VBPart3[0x50]; unsigned char VBPart4[0x50]; unsigned short ch70xx[64]; @@ -408,14 +502,16 @@ typedef struct { unsigned char * BIOS; SiS_Private * SiS_Pr; unsigned long agpHandle; - CARD32 agpAddr; + unsigned long agpAddr; unsigned char *agpBase; unsigned int agpSize; - CARD32 agpCmdBufAddr; /* 300 series */ + unsigned int agpWantedSize; + unsigned int agpWantedPages; + unsigned long agpCmdBufAddr; /* 300 series */ unsigned char *agpCmdBufBase; unsigned int agpCmdBufSize; unsigned int agpCmdBufFree; - CARD32 agpVtxBufAddr; /* 315 series */ + unsigned long agpVtxBufAddr; /* 315 series */ unsigned char *agpVtxBufBase; unsigned int agpVtxBufSize; unsigned int agpVtxBufFree; @@ -428,20 +524,22 @@ typedef struct { DisplayModePtr CRT1DMode; /* Current display mode for CRT1 */ int CRT2ModeNo; /* Current display mode for CRT2 */ DisplayModePtr CRT2DMode; /* Current display mode for CRT2 */ + Bool CRT2ModeSet; /* CRT2 mode has been set */ Bool CRT2IsCustom; + unsigned char CRT2CR30, CRT2CR31, CRT2CR35, CRT2CR38; int refCount; int lastInstance; /* number of entities */ Bool DisableDual; /* Emergency flag */ Bool ErrorAfterFirst; /* Emergency flag: Error after first init -> Abort second */ Bool HWCursor; /* Backup master settings for use on slave */ Bool TurboQueue; + int ForceCRT1Type; int ForceCRT2Type; int OptTVStand; int OptTVOver; int OptTVSOver; int OptROMUsage; int OptUseOEM; - int PDC; Bool NoAccel; int forceCRT1; int DSTN, FSTN; @@ -479,24 +577,40 @@ typedef struct { int sistvyfilter; int tvxpos, tvypos; int tvxscale, tvyscale; - int ForceTVType; + int ForceTVType, SenseYPbPr; + unsigned long ForceYPbPrType, ForceYPbPrAR; int chtvtype; - int NonDefaultPAL; + int NonDefaultPAL, NonDefaultNTSC; unsigned short tvx, tvy; - unsigned char p2_01, p2_02, p2_1f, p2_20; + unsigned char p2_01, p2_02, p2_1f, p2_20, p2_43, p2_42, p2_2b; unsigned char p2_44, p2_45, p2_46; unsigned long sistvccbase; unsigned char p2_35, p2_36, p2_37, p2_38, p2_48, p2_49, p2_4a; unsigned char p2_0a, p2_2f, p2_30, p2_47; - unsigned char scalingp1[9], scalingp4[9]; + unsigned char scalingp1[9], scalingp4[9], scalingp2[64]; unsigned short cursorBufferNum; BOOLEAN restorebyset; - BOOLEAN CRT1gamma, CRT2gamma; + BOOLEAN CRT1gamma, CRT1gammaGiven, CRT2gamma, XvGamma, XvGammaGiven, XvDefAdaptorBlit; + int XvGammaRed, XvGammaGreen, XvGammaBlue; + int GammaBriR, GammaBriG, GammaBriB; /* strictly for Xinerama */ + int GammaPBriR, GammaPBriG, GammaPBriB; /* strictly for Xinerama */ int curxvcrtnum; - int UsePanelScaler; + int UsePanelScaler, CenterLCD; int AllowHotkey; BOOLEAN enablesisctrl; unsigned long cmdQ_SharedWritePort_2D; + unsigned char *RenderAccelArray; + unsigned char * FbBase1; + unsigned long OnScreenSize1; + unsigned char OldMode; + int HWCursorMBufNum, HWCursorCBufNum; + BOOLEAN ROM661New; +#ifdef SIS_NEED_MAP_IOP + CARD32 IOPAddress; /* I/O port physical address */ + unsigned char * IOPBase; /* I/O port linear address */ + unsigned short MapCountIOPBase; /* map/unmap queue counter */ + Bool forceUnmapIOPBase; /* ignore counter and unmap */ +#endif #ifdef SIS_CP SIS_CP_H_ENT #endif @@ -536,7 +650,7 @@ typedef struct { #ifdef __alpha__ unsigned char * IOBaseDense; /* MMIO for Alpha platform */ #endif - CARD16 RelIO; /* Relocated IO Ports baseaddress */ + SISIOADDRESS RelIO; /* Relocated IO Ports baseaddress */ unsigned char * BIOS; int MemClock; int BusWidth; @@ -562,6 +676,7 @@ typedef struct { Bool UsePCIRetry; Bool TurboQueue; int VESA; + int ForceCRT1Type; int ForceCRT2Type; int OptTVStand; int OptTVOver; @@ -572,13 +687,14 @@ typedef struct { int forceCRT1; Bool CRT1changed; unsigned char oldCR17, oldCR63, oldSR1F; - unsigned char oldCR32; + unsigned char oldCR32, oldCR36, oldCR37; + unsigned char myCR32, myCR36, myCR37, myCR63; unsigned char newCR32; unsigned long VBFlags; /* Video bridge configuration */ unsigned long VBFlags_backup; /* Backup for SlaveMode-modes */ unsigned long VBLCDFlags; /* Moved LCD panel size bits here */ int ChrontelType; /* CHRONTEL_700x or CHRONTEL_701x */ - int PDC; /* PanelDelayCompensation */ + unsigned int PDC, PDCA; /* PanelDelayCompensation */ short scrnOffset; /* Screen pitch (data) */ short scrnPitch; /* Screen pitch (display; regarding interlace) */ short DstColor; @@ -608,7 +724,6 @@ typedef struct { xf86CursorInfoPtr CursorInfoPtr; XAAInfoRecPtr AccelInfoPtr; CloseScreenProcPtr CloseScreen; - unsigned int (*ddc1Read)(ScrnInfoPtr); Bool (*ModeInit)(ScrnInfoPtr pScrn, DisplayModePtr mode); void (*SiSSave)(ScrnInfoPtr pScrn, SISRegPtr sisreg); void (*SiSSave2)(ScrnInfoPtr pScrn, SISRegPtr sisreg); @@ -618,8 +733,6 @@ typedef struct { void (*SiSRestore2)(ScrnInfoPtr pScrn, SISRegPtr sisreg); void (*SiSRestore3)(ScrnInfoPtr pScrn, SISRegPtr sisreg); void (*SiSRestoreLVDSChrontel)(ScrnInfoPtr pScrn, SISRegPtr sisreg); - void (*SetThreshold)(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High); void (*LoadCRT2Palette)(ScrnInfoPtr pScrn, int numColors, int *indicies, LOCO *colors, VisualPtr pVisual); @@ -639,14 +752,16 @@ typedef struct { unsigned int cmdQueueSize_div4; unsigned int cmdQueueSize_4_3; unsigned long agpHandle; - CARD32 agpAddr; + unsigned long agpAddr; unsigned char *agpBase; unsigned int agpSize; - CARD32 agpCmdBufAddr; /* 300 series */ + unsigned int agpWantedSize; + unsigned int agpWantedPages; + unsigned long agpCmdBufAddr; /* 300 series */ unsigned char *agpCmdBufBase; unsigned int agpCmdBufSize; unsigned int agpCmdBufFree; - CARD32 agpVtxBufAddr; /* 315 series */ + unsigned long agpVtxBufAddr; /* 315 series */ unsigned char *agpVtxBufBase; unsigned int agpVtxBufSize; unsigned int agpVtxBufFree; @@ -658,6 +773,7 @@ typedef struct { int irq; Bool IsAGPCard; unsigned long DRIheapstart, DRIheapend; + Bool NeedFlush; /* Need to flush cmd buf mem (760) */ void (*RenderCallback)(ScrnInfoPtr); Time RenderTime; @@ -670,8 +786,8 @@ typedef struct { int ColorExpandBufferNumber; int ColorExpandBufferCountMask; unsigned char *ColorExpandBufferAddr[32]; - int ColorExpandBufferScreenOffset[32]; - long ColorExpandBase; + CARD32 ColorExpandBufferScreenOffset[32]; + CARD32 ColorExpandBase; int ImageWriteBufferSize; unsigned char *ImageWriteBufferAddr; @@ -683,6 +799,8 @@ typedef struct { unsigned char *ShadowPtr; int ShadowPitch; + Bool loadDRI; + #ifdef XF86DRI Bool directRenderingEnabled; DRIInfoPtr pDRIInfo; @@ -694,8 +812,12 @@ typedef struct { #endif XF86VideoAdaptorPtr adaptor; + XF86VideoAdaptorPtr blitadaptor; + void * blitPriv; ScreenBlockHandlerProcPtr BlockHandler; void (*VideoTimerCallback)(ScrnInfoPtr, Time); + void (*ResetXv)(ScrnInfoPtr); + void (*ResetXvGamma)(ScrnInfoPtr); OptionInfoPtr Options; unsigned char LCDon; @@ -728,15 +850,13 @@ typedef struct { BOOL SiSXinerama; /* Do we use Xinerama mode? */ #endif SISFBLayout CurrentLayout; /* Current framebuffer layout */ - Bool (*i2cInit)(ScrnInfoPtr);/* I2C stuff (unused) */ - I2CBusPtr I2C; USHORT SiS_DDC2_Index; USHORT SiS_DDC2_Data; USHORT SiS_DDC2_Clk; BOOL Primary; /* Display adapter is primary */ xf86Int10InfoPtr pInt; /* Our int10 */ int oldChipset; /* Type of old chipset */ - CARD32 RealVideoRam; /* 6326 can only address 4MB, but TQ can be above */ + int RealVideoRam; /* 6326 can only address 4MB, but TQ can be above */ CARD32 CmdQueLenMask; /* Mask of queue length in MMIO register */ CARD32 CmdQueLenFix; /* Fix value to subtract from QueLen (530/620) */ CARD32 CmdQueMaxLen; /* (6326/5597/5598) Amount of cmds the queue can hold */ @@ -770,24 +890,30 @@ typedef struct { int sis6326fscadjust; BOOL sisfbfound; BOOL donttrustpdc; /* Don't trust the detected PDC */ - unsigned char sisfbpdc; + unsigned char sisfbpdc, sisfbpdca; unsigned char sisfblcda; int sisfbscalelcd; unsigned long sisfbspecialtiming; + BOOL sisfb_haveemi, sisfb_haveemilcd, sisfb_tvposvalid, sisfb_havelock; + unsigned char sisfb_emi30,sisfb_emi31,sisfb_emi32,sisfb_emi33; + int sisfb_tvxpos, sisfb_tvypos; + char sisfbdevname[16]; + int EMI; int NoYV12; /* Disable Xv YV12 support (old series) */ unsigned char postVBCR32; int newFastVram; /* Replaces FastVram */ - int ForceTVType; - int NonDefaultPAL; + int ForceTVType, SenseYPbPr; + int NonDefaultPAL, NonDefaultNTSC; + unsigned long ForceYPbPrType, ForceYPbPrAR; unsigned long lockcalls; /* Count unlock calls for debug */ unsigned short tvx, tvy; /* Backup TV position registers */ - unsigned char p2_01, p2_02, p2_1f, p2_20; /* Backup TV position registers */ + unsigned char p2_01, p2_02, p2_1f, p2_20, p2_43, p2_42, p2_2b; /* Backup TV position registers */ unsigned short tvx1, tvx2, tvx3, tvy1; /* Backup TV position registers */ unsigned char p2_44, p2_45, p2_46; unsigned long sistvccbase; unsigned char p2_35, p2_36, p2_37, p2_38, p2_48, p2_49, p2_4a; unsigned char p2_0a, p2_2f, p2_30, p2_47; - unsigned char scalingp1[9], scalingp4[9]; + unsigned char scalingp1[9], scalingp4[9], scalingp2[64]; BOOLEAN ForceCursorOff; BOOLEAN HaveCustomModes; BOOLEAN IsCustom; @@ -797,12 +923,17 @@ typedef struct { Atom xvAutopaintColorKey, xvSetDefaults, xvSwitchCRT; Atom xvDisableGfx, xvDisableGfxLR, xvTVXPosition, xvTVYPosition; Atom xvDisableColorkey, xvUseChromakey, xvChromaMin, xvChromaMax; - Atom xvInsideChromakey, xvYUVChromakey; + Atom xvInsideChromakey, xvYUVChromakey, xvVSync; + Atom xvGammaRed, xvGammaGreen, xvGammaBlue; Atom xv_QVF, xv_QVV, xv_USD, xv_SVF, xv_QDD, xv_TAF, xv_TSA, xv_TEE, xv_GSF; Atom xv_TTE, xv_TCO, xv_TCC, xv_TCF, xv_TLF, xv_CMD, xv_CMDR, xv_CT1, xv_SGA; Atom xv_GDV, xv_GHI, xv_OVR, xv_GBI, xv_TXS, xv_TYS, xv_CFI, xv_COC, xv_COF; Atom xv_YFI, xv_GSS, xv_BRR, xv_BRG, xv_BRB, xv_PBR, xv_PBG, xv_PBB, xv_SHC; - BOOLEAN xv_sisdirectunlocked; + Atom xv_BRR2, xv_BRG2, xv_BRB2, xv_PBR2, xv_PBG2, xv_PBB2, xv_PMD, xv_RDT; +#ifdef TWDEBUG + Atom xv_STR; +#endif + int xv_sisdirectunlocked; unsigned long xv_sd_result; int CRT1isoff; #ifdef SIS_CP @@ -819,17 +950,20 @@ typedef struct { BOOLEAN restorebyset; BOOLEAN nocrt2ddcdetection; BOOLEAN forcecrt2redetection; - BOOLEAN CRT1gamma, CRT2gamma; + BOOLEAN CRT1gamma, CRT1gammaGiven, CRT2gamma, XvGamma, XvGammaGiven; int XvDefCon, XvDefBri, XvDefHue, XvDefSat; - BOOLEAN XvDefDisableGfx, XvDefDisableGfxLR; + BOOLEAN XvDefDisableGfx, XvDefDisableGfxLR, XvDefAdaptorBlit; BOOLEAN XvUseMemcpy; BOOLEAN XvUseChromaKey, XvDisableColorKey; BOOLEAN XvInsideChromaKey, XvYUVChromaKey; int XvChromaMin, XvChromaMax; + int XvGammaRed, XvGammaGreen, XvGammaBlue; + int XvGammaRedDef, XvGammaGreenDef, XvGammaBlueDef; + CARD8 XvGammaRampRed[256], XvGammaRampGreen[256], XvGammaRampBlue[256]; BOOLEAN disablecolorkeycurrent; CARD32 colorKey; CARD32 MiscFlags; - int UsePanelScaler; + int UsePanelScaler, CenterLCD; FBLinearPtr AccelLinearScratch; void (*AccelRenderCallback)(ScrnInfoPtr); float zClearVal; @@ -847,8 +981,13 @@ typedef struct { int GammaPBriR, GammaPBriG, GammaPBriB; Bool HideHWCursor; /* Custom application */ Bool HWCursorIsVisible; + unsigned long HWCursorBackup[16]; + int HWCursorMBufNum, HWCursorCBufNum; + unsigned long mmioSize; + BOOLEAN ROM661New; + BOOLEAN NewCRLayout; #ifdef SISMERGED - Bool MergedFB; + Bool MergedFB, MergedFBAuto; SiSScrn2Rel CRT2Position; char * CRT2HSync; char * CRT2VRefresh; @@ -866,6 +1005,12 @@ typedef struct { int maxCRT1_X1, maxCRT1_X2, maxCRT1_Y1, maxCRT1_Y2; int maxCRT2_X1, maxCRT2_X2, maxCRT2_Y1, maxCRT2_Y2; int maxClone_X1, maxClone_X2, maxClone_Y1, maxClone_Y2; + int MergedFBXDPI, MergedFBYDPI; + IOADDRESS MyPIOOffset; +#ifdef SIS_NEED_MAP_IOP + CARD32 IOPAddress; /* I/O port physical address */ + unsigned char * IOPBase; /* I/O port linear address */ +#endif #ifdef SISXINERAMA Bool UseSiSXinerama; Bool CRT2IsScrn0; @@ -946,7 +1091,7 @@ typedef struct _customttable { unsigned short chipID; char *biosversion; char *biosdate; - unsigned long bioschksum; + CARD32 bioschksum; unsigned short biosFootprintAddr[5]; unsigned char biosFootprintData[5]; unsigned short pcisubsysvendor; @@ -1029,8 +1174,10 @@ extern void SiS_SetTVyposoffset(ScrnInfoPtr pScrn, int val); extern void SiS_SetTVxscale(ScrnInfoPtr pScrn, int val); extern void SiS_SetTVyscale(ScrnInfoPtr pScrn, int val); extern Bool SISSwitchCRT2Type(ScrnInfoPtr pScrn, unsigned long newvbflags); -extern Bool SISCheckModeIndexForCRT2Type(ScrnInfoPtr pScrn, unsigned short cond, unsigned short index, Bool quiet); +extern int SISCheckModeIndexForCRT2Type(ScrnInfoPtr pScrn, unsigned short cond, + unsigned short index, Bool quiet); extern Bool SISSwitchCRT1Status(ScrnInfoPtr pScrn, int onoff); +extern Bool SISRedetectCRT2Devices(ScrnInfoPtr pScrn); extern int SiS_GetCHTVlumabandwidthcvbs(ScrnInfoPtr pScrn); extern int SiS_GetCHTVlumabandwidthsvideo(ScrnInfoPtr pScrn); extern int SiS_GetCHTVlumaflickerfilter(ScrnInfoPtr pScrn); @@ -1053,3 +1200,6 @@ extern int SiS_GetTVyposoffset(ScrnInfoPtr pScrn); extern int SiS_GetTVxscale(ScrnInfoPtr pScrn); extern int SiS_GetTVyscale(ScrnInfoPtr pScrn); #endif + + + diff --git a/src/sis300_accel.c b/src/sis300_accel.c index 8e2e5f4..1251ba8 100644 --- a/src/sis300_accel.c +++ b/src/sis300_accel.c @@ -1,32 +1,34 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c,v 1.20 2003/09/02 18:28:35 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* - * 2D Acceleration for SiS300, SiS540, SiS630, SiS730, SiS530, SiS620 + * 2D Acceleration for SiS 530, 620, 300, 540, 630, 730. * - * Copyright Xavier Ducoin - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * 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. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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. * - * Authors: - * - * Xavier Ducoin - * Thomas Winischhofer + * Authors: Thomas Winischhofer + * Can-Ru Yeou, SiS Inc. * */ @@ -41,7 +43,7 @@ #include "xf86Pci.h" #include "compiler.h" #include "xaa.h" -#include "xaalocal.h" +#include "xaarop.h" #include "sis.h" #include "sis300_accel.h" @@ -51,9 +53,9 @@ #define HEADOFFSET (pSiS->dhmOffset) #endif -#undef STSCE /* TW: Use/Don't use ScreenToScreenColorExpand - does not work */ +#undef STSCE /* Use/Don't use ScreenToScreenColorExpand - does not work */ -#undef TRAP /* TW: Use/Don't use Trapezoid Fills - does not work - XAA provides +#undef TRAP /* Use/Don't use Trapezoid Fills - does not work - XAA provides * illegal trapezoid data (left and right edges cross each other * sometimes) which causes drawing errors. Further, I have not found * out how to draw polygones with a height greater than 127... @@ -175,12 +177,12 @@ SiS300AccelInit(ScreenPtr pScreen) (pScrn->bitsPerPixel != 32)) return FALSE; - /* TW: Although SiS states that the 300 series supports a - * virtual framebuffer of 4096x4096, the 2D accelerator - * does not seem to know that. If the destination bitmap - * pitch is > 8192 (which easily happens in 32bpp mode), - * the accelerator engine collapses. - * TODO: Find out about the 530 and 620 + /* Although SiS states that the 300 series supports a + * virtual framebuffer of 4096x4096, the 2D accelerator + * does not seem to know that. If the destination bitmap + * pitch is > 8192 (which easily happens in 32bpp mode), + * the accelerator engine collapses. + * TODO: Find out about the 530 and 620 */ if(pSiS->scrnOffset < 8192) { @@ -226,7 +228,7 @@ SiS300AccelInit(ScreenPtr pScreen) #ifdef STSCE /* Screen To Screen Color Expand */ - /* TW: The hardware does support this the way we need it */ + /* The hardware does support this the way we need it */ infoPtr->SetupForScreenToScreenColorExpandFill = SiSSetupForScreenToScreenColorExpand; infoPtr->SubsequentScreenToScreenColorExpandFill = @@ -246,9 +248,7 @@ SiS300AccelInit(ScreenPtr pScreen) infoPtr->CPUToScreenColorExpandFillFlags = NO_PLANEMASK | BIT_ORDER_IN_BYTE_MSBFIRST | NO_TRANSPARENCY | - SYNC_AFTER_COLOR_EXPAND | - HARDWARE_PATTERN_SCREEN_ORIGIN | - HARDWARE_PATTERN_PROGRAMMED_BITS ; + SYNC_AFTER_COLOR_EXPAND; #endif /* per-scanline color expansion (using indirect method) */ @@ -320,7 +320,7 @@ SiS300AccelInit(ScreenPtr pScreen) if(Avail.y2 < pScrn->currentMode->VDisplay) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Not enough video RAM for accelerator. At least " - "%dKB needed, %dKB available\n", + "%dKB needed, %ldKB available\n", ((((pScrn->displayWidth * pScrn->bitsPerPixel/8) /* TW: +8 for make it sure */ * pScrn->currentMode->VDisplay) + reservedFbSize) / 1024) + 8, pSiS->maxxfbmem/1024); @@ -358,59 +358,19 @@ SiSRestoreAccelState(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - /* TW: We don't need to do anything special here; forcing the - * other head to re-read the CmdQueLen is not necessary: - * After the Sync in RestoreAccelState(), the real queue - * length is always larger than (or at least equal to) - * the amount stored in CmdQueueLen of the other head, - * so the only thing that might happen is one unnecessary - * Sync on the other head. I think we can live with that. + /* We don't need to do anything special here; forcing the + * other head to re-read the CmdQueLen is not necessary: + * After the Sync in RestoreAccelState(), the real queue + * length is always larger than (or at least equal to) + * the amount stored in CmdQueueLen of the other head, + * so the only thing that might happen is one unnecessary + * Sync on the other head. I think we can live with that. */ pSiS->DoColorExpand = FALSE; SiSIdle } #endif -static const int sisALUConv[] = -{ - 0x00, /* dest = 0; 0, GXclear, 0 */ - 0x88, /* dest &= src; DSa, GXand, 0x1 */ - 0x44, /* dest = src & ~dest; SDna, GXandReverse, 0x2 */ - 0xCC, /* dest = src; S, GXcopy, 0x3 */ - 0x22, /* dest &= ~src; DSna, GXandInverted, 0x4 */ - 0xAA, /* dest = dest; D, GXnoop, 0x5 */ - 0x66, /* dest = ^src; DSx, GXxor, 0x6 */ - 0xEE, /* dest |= src; DSo, GXor, 0x7 */ - 0x11, /* dest = ~src & ~dest; DSon, GXnor, 0x8 */ - 0x99, /* dest ^= ~src ; DSxn, GXequiv, 0x9 */ - 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */ - 0xDD, /* dest = src|~dest ; SDno, GXorReverse, 0xB */ - 0x33, /* dest = ~src; Sn, GXcopyInverted, 0xC */ - 0xBB, /* dest |= ~src; DSno, GXorInverted, 0xD */ - 0x77, /* dest = ~src|~dest; DSan, GXnand, 0xE */ - 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ -}; -/* same ROP but with Pattern as Source */ -static const int sisPatALUConv[] = -{ - 0x00, /* dest = 0; 0, GXclear, 0 */ - 0xA0, /* dest &= src; DPa, GXand, 0x1 */ - 0x50, /* dest = src & ~dest; PDna, GXandReverse, 0x2 */ - 0xF0, /* dest = src; P, GXcopy, 0x3 */ - 0x0A, /* dest &= ~src; DPna, GXandInverted, 0x4 */ - 0xAA, /* dest = dest; D, GXnoop, 0x5 */ - 0x5A, /* dest = ^src; DPx, GXxor, 0x6 */ - 0xFA, /* dest |= src; DPo, GXor, 0x7 */ - 0x05, /* dest = ~src & ~dest; DPon, GXnor, 0x8 */ - 0xA5, /* dest ^= ~src ; DPxn, GXequiv, 0x9 */ - 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */ - 0xF5, /* dest = src|~dest ; PDno, GXorReverse, 0xB */ - 0x0F, /* dest = ~src; Pn, GXcopyInverted, 0xC */ - 0xAF, /* dest |= ~src; DPno, GXorInverted, 0xD */ - 0x5F, /* dest = ~src|~dest; DPan, GXnand, 0xE */ - 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ -}; - static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, unsigned int planemask, int trans_color) @@ -429,7 +389,7 @@ static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, SiSSetupSRCTrans(trans_color) SiSSetupCMDFlag(TRANSPARENT_BITBLT) } else { - SiSSetupROP(sisALUConv[rop]) + SiSSetupROP(XAACopyROP[rop]) } if(xdir > 0) { SiSSetupCMDFlag(X_INC) @@ -443,8 +403,8 @@ static void SiSSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int src_x, int src_y, int dst_x, int dst_y, int width, int height) { - SISPtr pSiS = SISPTR(pScrn); - long srcbase, dstbase; + SISPtr pSiS = SISPTR(pScrn); + CARD32 srcbase, dstbase; PDEBUG(ErrorF("Subsequent ScreenCopy(%d,%d, %d,%d, %d,%d)\n", src_x, src_y, dst_x, dst_y, width, height)); @@ -486,7 +446,7 @@ static void SiSSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); PDEBUG(ErrorF("Setup SolidFill(0x%x, 0x%x, 0x%x)\n", color, rop, planemask)); @@ -499,7 +459,7 @@ SiSSetupForSolidFill(ScrnInfoPtr pScrn, SiSSetupPATFG(color) SiSSetupDSTRect(pSiS->scrnOffset, -1) SiSSetupDSTColorDepth(pSiS->DstColor); - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupROP(XAAPatternROP[rop]) /* SiSSetupCMDFlag(PATFG) - is zero */ } @@ -507,8 +467,8 @@ static void SiSSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) { - SISPtr pSiS = SISPTR(pScrn); - long dstbase; + SISPtr pSiS = SISPTR(pScrn); + CARD32 dstbase; PDEBUG(ErrorF("Subsequent SolidFillRect(%d, %d, %d, %d)\n", x, y, w, h)); @@ -536,7 +496,7 @@ SiSSubsequentSolidFillRect(ScrnInfoPtr pScrn, SiSDoCMD } -/* TW: Trapezoid */ +/* Trapezoid */ /* This would work better if XAA would provide us with valid trapezoids. * In fact, with small trapezoids the left and the right edge often cross * each other or result in a line length of 0 which causes drawing errors @@ -550,8 +510,8 @@ SiSSubsequentSolidFillTrap(ScrnInfoPtr pScrn, int y, int h, int left, int dxL, int dyL, int eL, int right, int dxR, int dyR, int eR ) { - SISPtr pSiS = SISPTR(pScrn); - long dstbase; + SISPtr pSiS = SISPTR(pScrn); + CARD32 dstbase; #if 0 float kL, kR; #endif @@ -648,7 +608,7 @@ static void SiSSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); PDEBUG(ErrorF("Setup SolidLine(0x%x, 0x%x, 0x%x)\n", color, rop, planemask)); @@ -657,7 +617,7 @@ SiSSetupForSolidLine(ScrnInfoPtr pScrn, SiSSetupPATFG(color) SiSSetupDSTRect(pSiS->scrnOffset, -1) SiSSetupDSTColorDepth(pSiS->DstColor); - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupROP(XAAPatternROP[rop]) SiSSetupCMDFlag(PATFG | LINE) } @@ -665,8 +625,9 @@ static void SiSSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, int flags) { - SISPtr pSiS = SISPTR(pScrn); - long dstbase,miny,maxy; + SISPtr pSiS = SISPTR(pScrn); + CARD32 dstbase; + int miny,maxy; PDEBUG(ErrorF("Subsequent SolidLine(%d, %d, %d, %d, 0x%x)\n", x1, y1, x2, y2, flags)); @@ -701,8 +662,8 @@ static void SiSSubsequentSolidHorzVertLine(ScrnInfoPtr pScrn, int x, int y, int len, int dir) { - SISPtr pSiS = SISPTR(pScrn); - long dstbase; + SISPtr pSiS = SISPTR(pScrn); + CARD32 dstbase; PDEBUG(ErrorF("Subsequent SolidHorzVertLine(%d, %d, %d, %d)\n", x, y, len, dir)); @@ -746,7 +707,7 @@ SiSSetupForDashedLine(ScrnInfoPtr pScrn, SiSSetupStyleLow(*pattern) SiSSetupStyleHigh(*(pattern+4)) SiSSetupStylePeriod(length-1); - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupROP(XAAPatternROP[rop]) SiSSetupPATFG(fg) SiSSetupCMDFlag(LINE | LINE_STYLE) if(bg != -1) { @@ -762,7 +723,8 @@ SiSSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, int flags, int phase) { SISPtr pSiS = SISPTR(pScrn); - long dstbase,miny,maxy; + CARD32 dstbase; + int miny,maxy; PDEBUG(ErrorF("Subsequent DashedLine(%d,%d, %d,%d, 0x%x,0x%x)\n", x1, y1, x2, y2, flags, phase)); @@ -806,7 +768,7 @@ SiSSetupForMonoPatternFill(ScrnInfoPtr pScrn, SiSSetupDSTColorDepth(pSiS->DstColor); SiSSetupMONOPAT(patx,paty) SiSSetupPATFG(fg) - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupROP(XAAPatternROP[rop]) SiSSetupCMDFlag(PATMONO) if(bg != -1) { SiSSetupPATBG(bg) @@ -821,7 +783,7 @@ SiSSubsequentMonoPatternFill(ScrnInfoPtr pScrn, int x, int y, int w, int h) { SISPtr pSiS = SISPTR(pScrn); - long dstbase; + CARD32 dstbase; PDEBUG(ErrorF("Subsequent MonoPatFill(0x%x,0x%x, %d,%d, %d,%d)\n", patx, paty, x, y, w, h)); @@ -858,8 +820,8 @@ SiSSubsequentMonoPatternFillTrap(ScrnInfoPtr pScrn, int left, int dxL, int dyL, int eL, int right, int dxR, int dyR, int eR ) { - SISPtr pSiS = SISPTR(pScrn); - long dstbase; + SISPtr pSiS = SISPTR(pScrn); + CARD32 dstbase; PDEBUG(ErrorF("Subsequent Mono8x8PatternFillTrap(%d, %d, %d - %d %d/%d %d/%d)\n", y, h, left, right, dxL, dxR, eL, eR)); @@ -918,7 +880,7 @@ SiSSubsequentMonoPatternFillTrap(ScrnInfoPtr pScrn, #if 0 -/* TW: The following (already commented) functions have NOT been adapted for dual-head mode */ +/* The following (already commented) functions have NOT been adapted for dual-head mode */ /* ----- CPU To Screen Color Expand (single task) ------------------------- */ @@ -940,7 +902,7 @@ SiSSetupForCPUToScreenColorExpand(ScrnInfoPtr pScrn, SiSSetupDSTColorDepth(pSiS->DstColor); SiSSetupSRCXY(0,0) SiSSetupSRCFG(fg) - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupROP(XAAPatternROP[rop]) SiSSetupCMDFlag(X_INC | Y_INC | COLOREXP) if(bg == -1) { SiSSetupCMDFlag(TRANSPARENT) @@ -954,7 +916,7 @@ SiSSubsequentCPUToScreenColorExpand(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft) { SISPtr pSiS = SISPTR(pScrn); - long dstbase; + CARD32 dstbase; PDEBUG(ErrorF("Subsequent CPUToScreen ColorExpand(%d,%d, %d,%d, %d)\n", x, y, w, h, skipleft)); @@ -977,7 +939,7 @@ SiSSubsequentCPUToScreenColorExpand(ScrnInfoPtr pScrn, /* ------ Screen To Screen Color Expand ------------------------------- */ -/* TW: The hareware does not seem to support this the way we need it */ +/* The hareware does not seem to support this the way we need it */ #ifdef STSCE static void @@ -985,14 +947,14 @@ SiSSetupForScreenToScreenColorExpand(ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); PDEBUG(ErrorF("Setup ScreenToScreen ColorExp(0x%x,0x%x, 0x%x)\n", fg, bg, rop)); SiSSetupDSTColorDepth(pSiS->DstColor) SiSSetupDSTRect(pSiS->scrnOffset, -1) - SiSSetupROP(sisALUConv[rop]) + SiSSetupROP(XAACopyROP[rop]) SiSSetupSRCFG(fg) /* SiSSetupSRCXY(0,0) */ @@ -1007,7 +969,7 @@ SiSSetupForScreenToScreenColorExpand(ScrnInfoPtr pScrn, } #endif -/* TW. This method blits in a single task; this does not seem to work +/* This method blits in a single task; this does not seem to work * because the hardware does not use the source pitch as scanline * offset but only to calculate pattern address from source X and Y. * XAA provides the pattern bitmap with scrnOffset (displayWidth * bpp/8) @@ -1054,7 +1016,7 @@ SiSSubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, int srcx, int srcy, int skipleft) { SISPtr pSiS = SISPTR(pScrn); - long srcbase, dstbase; + CARD32 srcbase, dstbase; #if 0 int _x0, _y0, _x1, _y1; #endif @@ -1158,7 +1120,7 @@ SiSSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, while((MMIO_IN16(pSiS->IOBase, 0x8242) & 0x1F00) != 0) {} /* WDR: == 0x10 */ SiSSetupSRCXY(0,0); - SiSSetupROP(sisALUConv[rop]); + SiSSetupROP(XAACopyROP[rop]); SiSSetupSRCFG(fg); SiSSetupDSTRect(pSiS->scrnOffset, -1); SiSSetupDSTColorDepth(pSiS->DstColor); @@ -1182,8 +1144,8 @@ SiSSubsequentScanlineCPUToScreenColorExpandFill( int h, int skipleft) { SISPtr pSiS = SISPTR(pScrn); - int _x0, _y0, _x1, _y1; - long dstbase; + int _x0, _y0, _x1, _y1; + CARD32 dstbase; dstbase = 0; if((y >= 2048) || ((y + h) >= 2048)) { @@ -1196,13 +1158,13 @@ SiSSubsequentScanlineCPUToScreenColorExpandFill( } #endif - /* TW: Wait until there is no color expansion command in queue - * (This solves the OpenOffice.org window-move bug) - * Added Idle-check - bit 23 is set sometimes, although - * engine is actually idle! - * Update: Bit 23 is not reliable. After heavy 3D engine - * action, this bit never gets cleared again. So do - * SiSIdle instead. + /* Wait until there is no color expansion command in queue + * (This solves the OpenOffice.org window-move bug) + * Added Idle-check - bit 23 is set sometimes, although + * engine is actually idle! + * Update: Bit 23 is not reliable. After heavy 3D engine + * action, this bit never gets cleared again. So do + * SiSIdle instead. */ if((MMIO_IN16(pSiS->IOBase, 0x8242) & 0xe000) != 0xe000) { /* while ((MMIO_IN16(pSiS->IOBase, 0x8242) & 0x0080) != 0) {} */ @@ -1236,7 +1198,7 @@ SiSSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) #if 0 int newhead,bltbufstage,newtail; #endif - long cbo; + CARD32 cbo; cbo = pSiS->ColorExpandBufferScreenOffset[bufno]; #ifdef SISDUALHEAD @@ -1245,13 +1207,13 @@ SiSSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) } #endif - /* TW: Wait until there is no color expansion command in queue - * (This solves the GTK-big-font bug) - * Added Idle-check - bit 23 is set sometimes, although - * engine is actually idle! - * Update: Bit 23 is not reliable. After heavy 3D engine - * action, this bit never gets cleared again. So do - * SiSIdle instead. + /* Wait until there is no color expansion command in queue + * (This solves the GTK-big-font bug) + * Added Idle-check - bit 23 is set sometimes, although + * engine is actually idle! + * Update: Bit 23 is not reliable. After heavy 3D engine + * action, this bit never gets cleared again. So do + * SiSIdle instead. */ if((MMIO_IN16(pSiS->IOBase, 0x8242) & 0xe000) != 0xe000) { /* while ((MMIO_IN16(pSiS->IOBase, 0x8242) & 0x0080) != 0) {} */ diff --git a/src/sis300_accel.h b/src/sis300_accel.h index 3cc5a66..5b26fb9 100644 --- a/src/sis300_accel.h +++ b/src/sis300_accel.h @@ -1,33 +1,35 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h,v 1.13 2003/08/23 10:25:19 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* - * 2D Acceleration for SiS300, SiS540, SiS630, SiS730, SiS530, SiS620 + * 2D Acceleration for SiS 530, 620, 300, 540, 630, 730. * Definitions for the SIS engine communication * - * Copyright Xavier Ducoin - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * 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. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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. * - * Authors: - * - * Xavier Ducoin - * Thomas Winischhofer + * Authors: Thomas Winischhofer + * Can-Ru Yeou, SiS Inc. (code base) * */ @@ -116,7 +118,7 @@ while( (MMIO_IN16(pSiS->IOBase, BR(16)+2) & 0xE000) != 0xE000){}; \ CmdQueLen = (MMIO_IN16(pSiS->IOBase, 0x8240) & pSiS->CmdQueLenMask) - pSiS->CmdQueLenFix; \ } -/* TW: (do three times, because 2D engine seems quite unsure about whether or not it's idle) */ +/* (do three times, because 2D engine seems quite unsure about whether or not it's idle) */ #define SiSSetupSRCBase(base) \ if (CmdQueLen <= 0) SiSIdle;\ @@ -229,6 +231,7 @@ } else { \ unsigned long temp; \ temp = MMIO_IN32(pSiS->IOBase, BR(16)); \ + (void) temp; \ } \ /* Line */ @@ -262,7 +265,7 @@ MMIO_OUT32(pSiS->IOBase, BR(12), ls);\ CmdQueLen--; -/* TW: Trapezoid */ +/* Trapezoid */ #define SiSSetupYH(y,h) \ if (CmdQueLen <= 0) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, 0x8208, (y)<<16 | (h) );\ diff --git a/src/sis310_accel.c b/src/sis310_accel.c index e47da9e..bd4144c 100644 --- a/src/sis310_accel.c +++ b/src/sis310_accel.c @@ -1,33 +1,37 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis310_accel.c,v 1.20 2003/09/02 18:28:35 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* - * 2D Acceleration for SiS 315 and Xabre series - * (315/550/650/740/M650/651/652/M652/330/660/M660/760/M760) + * 2D Acceleration for SiS 315 and 330 series * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * 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. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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. * - * Based on sis300_accel.c - * 2003/08/18: Rewritten for using VRAM command queue (TW) * * Author: Thomas Winischhofer * + * 2003/08/18: Rewritten for using VRAM command queue + * */ #include "xf86.h" @@ -37,7 +41,7 @@ #include "xf86Pci.h" #include "compiler.h" #include "xaa.h" -#include "xaalocal.h" +#include "xaarop.h" #include "sis.h" #include "sis310_accel.h" @@ -57,7 +61,7 @@ * checking the trapezoid for such a case is very * time-intensive, it is faster to let it be done * by the generic polygon functions. - * Does not work on XABRE at all, hangs the engine. + * Does not work on 330 series at all, hangs the engine. * Even with correct trapezoids, this is slower than * doing it by the CPU. */ @@ -65,9 +69,9 @@ #undef CTSCE /* Use/Don't use CPUToScreenColorExpand. Disabled * because it is slower than doing it by the CPU. * Indirect mode does not work in VRAM queue mode. - * Does not work on Xabre (even in MMIO mode). + * Does not work on 330 series (even in MMIO mode). */ -#undef CTSCE_DIRECT /* Use direct method - This works (on both 315 and Xabre at +#undef CTSCE_DIRECT /* Use direct method - This works (on both 315 and 330 at * least in VRAM queue mode) but we don't use this either, * because it's slower than doing it by the CPU. (Using it * would require defining CTSCE) @@ -183,9 +187,9 @@ extern void SiSSubsequentCPUToScreenTexture(ScrnInfoPtr pScrn, int width, int height); extern CARD32 SiSAlphaTextureFormats[2]; -extern CARD32 SiSTextureFormats[2]; -CARD32 SiSAlphaTextureFormats[2] = { PICT_a8, 0 }; -CARD32 SiSTextureFormats[2] = { PICT_a8r8g8b8, 0 }; +extern CARD32 SiSTextureFormats[2]; +CARD32 SiSAlphaTextureFormats[2] = { PICT_a8 , 0 }; +CARD32 SiSTextureFormats[2] = { PICT_a8r8g8b8, 0 }; #endif #endif @@ -193,6 +197,8 @@ CARD32 SiSTextureFormats[2] = { PICT_a8r8g8b8, 0 }; static void SiSRestoreAccelState(ScrnInfoPtr pScrn); #endif +CARD32 dummybuf; + static void SiSInitializeAccelerator(ScrnInfoPtr pScrn) { @@ -218,13 +224,16 @@ SiS315AccelInit(ScreenPtr pScreen) int topFB; int reservedFbSize; int UsableFbSize; - unsigned char *AvailBufBase; BoxRec Avail; +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = NULL; +#endif #ifdef CTSCE + unsigned char *AvailBufBase; #ifndef CTSCE_DIRECT int i; #endif -#endif +#endif pSiS->AccelInfoPtr = infoPtr = XAACreateInfoRec(); if(!infoPtr) return FALSE; @@ -242,6 +251,10 @@ SiS315AccelInit(ScreenPtr pScreen) (pScrn->bitsPerPixel != 32)) return FALSE; +#ifdef SISDUALHEAD + pSiSEnt = pSiS->entityPrivate; +#endif + /* BitBlt */ infoPtr->SetupForScreenToScreenCopy = SiSSetupForScreenToScreenCopy; infoPtr->SubsequentScreenToScreenCopy = SiSSubsequentScreenToScreenCopy; @@ -252,7 +265,8 @@ SiS315AccelInit(ScreenPtr pScreen) infoPtr->SubsequentSolidFillRect = SiSSubsequentSolidFillRect; #ifdef TRAP if((pSiS->Chipset != PCI_CHIP_SIS660) && - (pSiS->Chipset != PCI_CHIP_SIS330)) { + (pSiS->Chipset != PCI_CHIP_SIS330) && + (pSiS->Chipset != PCI_CHIP_SIS340)) { infoPtr->SubsequentSolidFillTrap = SiSSubsequentSolidFillTrap; } #endif @@ -276,21 +290,22 @@ SiS315AccelInit(ScreenPtr pScreen) infoPtr->SubsequentMono8x8PatternFillRect = SiSSubsequentMonoPatternFill; #ifdef TRAP if((pSiS->Chipset != PCI_CHIP_SIS660) && - (pSiS->Chipset != PCI_CHIP_SIS330)) { + (pSiS->Chipset != PCI_CHIP_SIS330) && + (pSiS->Chipset != PCI_CHIP_SIS340)) { infoPtr->SubsequentMono8x8PatternFillTrap = SiSSubsequentMonoPatternFillTrap; } #endif infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | HARDWARE_PATTERN_SCREEN_ORIGIN | HARDWARE_PATTERN_PROGRAMMED_BITS | - BIT_ORDER_IN_BYTE_MSBFIRST ; + BIT_ORDER_IN_BYTE_MSBFIRST; #ifdef SISVRAMQ /* 8x8 color pattern fill (MMIO support not implemented) */ infoPtr->SetupForColor8x8PatternFill = SiSSetupForColor8x8PatternFill; infoPtr->SubsequentColor8x8PatternFillRect = SiSSubsequentColor8x8PatternFillRect; infoPtr->Color8x8PatternFillFlags = NO_PLANEMASK | - HARDWARE_PATTERN_SCREEN_ORIGIN | + HARDWARE_PATTERN_SCREEN_ORIGIN | NO_TRANSPARENCY; #endif @@ -341,13 +356,14 @@ SiS315AccelInit(ScreenPtr pScreen) * * SLOW! SLOWER! SLOWEST! * - * Does not work on XABRE, hangs the engine (both VRAM and MMIO). + * Does not work on 330 series, hangs the engine (both VRAM and MMIO). * Does not work in VRAM queue mode. */ #ifndef SISVRAMQ if((pSiS->Chipset != PCI_CHIP_SIS650) && (pSiS->Chipset != PCI_CHIP_SIS660) && - (pSiS->Chipset != PCI_CHIP_SIS330)) { + (pSiS->Chipset != PCI_CHIP_SIS330) && + (pSiS->Chipset != PCI_CHIP_SIS340)) { pSiS->ColorExpandBufferNumber = 16; pSiS->ColorExpandBufferCountMask = 0x0F; pSiS->PerColorExpandBufferSize = ((pScrn->virtualX + 31)/32) * 4; @@ -375,25 +391,35 @@ SiS315AccelInit(ScreenPtr pScreen) pSiS->PerColorExpandBufferSize = 0; #endif + pSiS->RenderAccelArray = NULL; + #ifdef INCL_RENDER #ifdef RENDER /* Render */ if(((pScrn->bitsPerPixel == 16) || (pScrn->bitsPerPixel == 32)) && pSiS->doRender) { int i, j; - if((pSiS->RenderAccelArray = xnfcalloc(65536, 1))) { - for(i = 0; i < 256; i++) { - for(j = 0; j < 256; j++) { - pSiS->RenderAccelArray[(i << 8) + j] = (i * j) / 255; - } +#ifdef SISDUALHEAD + if(pSiSEnt) pSiS->RenderAccelArray = pSiSEnt->RenderAccelArray; +#endif + if(!pSiS->RenderAccelArray) { + if((pSiS->RenderAccelArray = xnfcalloc(65536, 1))) { +#ifdef SISDUALHEAD + if(pSiSEnt) pSiSEnt->RenderAccelArray = pSiS->RenderAccelArray; +#endif + for(i = 0; i < 256; i++) { + for(j = 0; j < 256; j++) { + pSiS->RenderAccelArray[(i << 8) + j] = (i * j) / 255; + } + } } - + } + if(pSiS->RenderAccelArray) { pSiS->AccelLinearScratch = NULL; infoPtr->SetupForCPUToScreenAlphaTexture = SiSSetupForCPUToScreenAlphaTexture; infoPtr->SubsequentCPUToScreenAlphaTexture = SiSSubsequentCPUToScreenTexture; infoPtr->CPUToScreenAlphaTextureFormats = SiSAlphaTextureFormats; - infoPtr->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE | - XAA_RENDER_NO_SRC_ALPHA; + infoPtr->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE; infoPtr->SetupForCPUToScreenTexture = SiSSetupForCPUToScreenTexture; infoPtr->SubsequentCPUToScreenTexture = SiSSubsequentCPUToScreenTexture; @@ -424,8 +450,8 @@ SiS315AccelInit(ScreenPtr pScreen) * UsableFbSize ColorExpandBuffers | DRI-Heap HWCursor CommandQueue * topFB */ - AvailBufBase = pSiS->FbBase + UsableFbSize; #ifdef CTSCE + AvailBufBase = pSiS->FbBase + UsableFbSize; if(pSiS->ColorExpandBufferNumber) { #ifdef CTSCE_DIRECT infoPtr->ColorExpandBase = (unsigned char *)AvailBufBase; @@ -450,7 +476,7 @@ SiS315AccelInit(ScreenPtr pScreen) if(Avail.y2 < pScrn->currentMode->VDisplay) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Not enough video RAM for accelerator. At least " - "%dKB needed, %dKB available\n", + "%dKB needed, %ldKB available\n", ((((pScrn->displayWidth * pScrn->bitsPerPixel/8) /* +8 for make it sure */ * pScrn->currentMode->VDisplay) + reservedFbSize) / 1024) + 8, pSiS->maxxfbmem/1024); @@ -504,47 +530,6 @@ SiSRestoreAccelState(ScrnInfoPtr pScrn) } #endif -static const int sisALUConv[] = -{ - 0x00, /* dest = 0; 0, GXclear, 0 */ - 0x88, /* dest &= src; DSa, GXand, 0x1 */ - 0x44, /* dest = src & ~dest; SDna, GXandReverse, 0x2 */ - 0xCC, /* dest = src; S, GXcopy, 0x3 */ - 0x22, /* dest &= ~src; DSna, GXandInverted, 0x4 */ - 0xAA, /* dest = dest; D, GXnoop, 0x5 */ - 0x66, /* dest = ^src; DSx, GXxor, 0x6 */ - 0xEE, /* dest |= src; DSo, GXor, 0x7 */ - 0x11, /* dest = ~src & ~dest; DSon, GXnor, 0x8 */ - 0x99, /* dest ^= ~src ; DSxn, GXequiv, 0x9 */ - 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */ - 0xDD, /* dest = src|~dest ; SDno, GXorReverse, 0xB */ - 0x33, /* dest = ~src; Sn, GXcopyInverted, 0xC */ - 0xBB, /* dest |= ~src; DSno, GXorInverted, 0xD */ - 0x77, /* dest = ~src|~dest; DSan, GXnand, 0xE */ - 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ -}; - -/* same ROP but with Pattern as Source */ -static const int sisPatALUConv[] = -{ - 0x00, /* dest = 0; 0, GXclear, 0 */ - 0xA0, /* dest &= src; DPa, GXand, 0x1 */ - 0x50, /* dest = src & ~dest; PDna, GXandReverse, 0x2 */ - 0xF0, /* dest = src; P, GXcopy, 0x3 */ - 0x0A, /* dest &= ~src; DPna, GXandInverted, 0x4 */ - 0xAA, /* dest = dest; D, GXnoop, 0x5 */ - 0x5A, /* dest = ^src; DPx, GXxor, 0x6 */ - 0xFA, /* dest |= src; DPo, GXor, 0x7 */ - 0x05, /* dest = ~src & ~dest; DPon, GXnor, 0x8 */ - 0xA5, /* dest ^= ~src ; DPxn, GXequiv, 0x9 */ - 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */ - 0xF5, /* dest = src|~dest ; PDno, GXorReverse, 0xB */ - 0x0F, /* dest = ~src; Pn, GXcopyInverted, 0xC */ - 0xAF, /* dest |= ~src; DPno, GXorInverted, 0xD */ - 0x5F, /* dest = ~src|~dest; DPan, GXnand, 0xE */ - 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ -}; - static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, unsigned int planemask, int trans_color) @@ -569,7 +554,7 @@ static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, SiSSetupSRCTrans(trans_color) SiSSetupCMDFlag(TRANSPARENT_BITBLT) } else { - SiSSetupROP(sisALUConv[rop]) + SiSSetupROP(XAACopyROP[rop]) /* Set command - not needed, both 0 */ /* SiSSetupCMDFlag(BITBLT | SRCVIDEO) */ } @@ -589,9 +574,9 @@ static void SiSSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int src_x, int src_y, int dst_x, int dst_y, int width, int height) { - SISPtr pSiS = SISPTR(pScrn); - long srcbase, dstbase; - int mymin, mymax; + SISPtr pSiS = SISPTR(pScrn); + CARD32 srcbase, dstbase; + int mymin, mymax; PDEBUG(ErrorF("Subsequent ScreenCopy(%d,%d, %d,%d, %d,%d)\n", src_x, src_y, dst_x, dst_y, width, height)); @@ -604,7 +589,9 @@ static void SiSSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, * correctly if there are 512x512 slots, but no 256x256 * slots. This leads to catastrophic data fed to us. * Filter this out here and warn the user. + * Fixed in 4.3.99.10 (?) and Debian's 4.3.0.1 */ +#if (XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,10,0)) && (XF86_VERSION_CURRENT != XF86_VERSION_NUMERIC(4,3,0,1,0)) if((src_x < 0) || (dst_x < 0) || (src_y < 0) || @@ -622,6 +609,7 @@ static void SiSSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, "Please update libxaa.a to avoid this error.\n"); return; } +#endif /* Although the chip knows the direction to use * if the source and destination areas overlap, @@ -689,14 +677,14 @@ SiSSetupForSolidFill(ScrnInfoPtr pScrn, int color, SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); SiSCheckQueue(16 * 1); SiSSetupPATFGDSTRect(color, pSiS->scrnOffset, -1) - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupROP(XAAPatternROP[rop]) SiSSetupCMDFlag(PATFG) SiSSyncWP #else SiSSetupPATFG(color) SiSSetupDSTRect(pSiS->scrnOffset, -1) SiSSetupDSTColorDepth(pSiS->DstColor); - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupROP(XAAPatternROP[rop]) SiSSetupCMDFlag(PATFG | pSiS->SiS310_AccelDepth) #endif } @@ -705,8 +693,8 @@ static void SiSSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) { - SISPtr pSiS = SISPTR(pScrn); - long dstbase; + SISPtr pSiS = SISPTR(pScrn); + CARD32 dstbase; PDEBUG(ErrorF("Subsequent SolidFillRect(%d, %d, %d, %d)\n", x, y, w, h)); @@ -743,7 +731,7 @@ SiSSubsequentSolidFillRect(ScrnInfoPtr pScrn, /* This would work better if XAA would provide us with valid trapezoids. * In fact, with small trapezoids the left and the right edge often cross * each other which causes drawing errors (filling over whole scanline). - * DOES NOT WORK ON XABRE, HANGS THE ENGINE. + * DOES NOT WORK ON 330 SERIES, HANGS THE ENGINE. */ #ifdef TRAP static void @@ -751,8 +739,8 @@ SiSSubsequentSolidFillTrap(ScrnInfoPtr pScrn, int y, int h, int left, int dxL, int dyL, int eL, int right, int dxR, int dyR, int eR ) { - SISPtr pSiS = SISPTR(pScrn); - long dstbase; + SISPtr pSiS = SISPTR(pScrn); + CARD32 dstbase; dstbase = 0; if(y >= 2048) { @@ -824,7 +812,7 @@ static void SiSSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); PDEBUG(ErrorF("Setup SolidLine(0x%x, 0x%x, 0x%x)\n", color, rop, planemask)); @@ -834,7 +822,7 @@ SiSSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, SiSCheckQueue(16 * 3); SiSSetupLineCountPeriod(1, 1) SiSSetupPATFGDSTRect(color, pSiS->scrnOffset, -1) - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupROP(XAAPatternROP[rop]) SiSSetupCMDFlag(PATFG | LINE) SiSSyncWP #else @@ -842,7 +830,7 @@ SiSSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, SiSSetupPATFG(color) SiSSetupDSTRect(pSiS->scrnOffset, -1) SiSSetupDSTColorDepth(pSiS->DstColor) - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupROP(XAAPatternROP[rop]) SiSSetupCMDFlag(PATFG | LINE | pSiS->SiS310_AccelDepth) #endif } @@ -851,8 +839,9 @@ static void SiSSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, int flags) { - SISPtr pSiS = SISPTR(pScrn); - long dstbase,miny,maxy; + SISPtr pSiS = SISPTR(pScrn); + CARD32 dstbase; + int miny,maxy; PDEBUG(ErrorF("Subsequent SolidLine(%d, %d, %d, %d, 0x%x)\n", x1, y1, x2, y2, flags)); @@ -891,8 +880,8 @@ static void SiSSubsequentSolidHorzVertLine(ScrnInfoPtr pScrn, int x, int y, int len, int dir) { - SISPtr pSiS = SISPTR(pScrn); - long dstbase; + SISPtr pSiS = SISPTR(pScrn); + CARD32 dstbase; PDEBUG(ErrorF("Subsequent SolidHorzVertLine(%d, %d, %d, %d)\n", x, y, len, dir)); @@ -953,7 +942,7 @@ SiSSetupForDashedLine(ScrnInfoPtr pScrn, SiSSetupPATFG(fg) #endif - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupROP(XAAPatternROP[rop]) SiSSetupCMDFlag(LINE | LINE_STYLE) @@ -977,7 +966,7 @@ SiSSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, int flags, int phase) { SISPtr pSiS = SISPTR(pScrn); - long dstbase,miny,maxy; + CARD32 dstbase,miny,maxy; PDEBUG(ErrorF("Subsequent DashedLine(%d,%d, %d,%d, 0x%x,0x%x)\n", x1, y1, x2, y2, flags, phase)); @@ -1033,7 +1022,7 @@ SiSSetupForMonoPatternFill(ScrnInfoPtr pScrn, SiSSetupMONOPAT(patx,paty) - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupROP(XAAPatternROP[rop]) #ifdef SISVRAMQ SiSSetupCMDFlag(PATMONO) @@ -1059,7 +1048,7 @@ SiSSubsequentMonoPatternFill(ScrnInfoPtr pScrn, int x, int y, int w, int h) { SISPtr pSiS = SISPTR(pScrn); - long dstbase; + CARD32 dstbase; PDEBUG(ErrorF("Subsequent MonoPatFill(0x%x,0x%x, %d,%d, %d,%d)\n", patx, paty, x, y, w, h)); @@ -1092,7 +1081,7 @@ SiSSubsequentMonoPatternFill(ScrnInfoPtr pScrn, /* --- Trapezoid --- */ -/* Does not work at all on Xabre */ +/* Does not work at all on 330 series */ #ifdef TRAP static void @@ -1102,8 +1091,8 @@ SiSSubsequentMonoPatternFillTrap(ScrnInfoPtr pScrn, int left, int dxL, int dyL, int eL, int right, int dxR, int dyR, int eR) { - SISPtr pSiS = SISPTR(pScrn); - long dstbase; + SISPtr pSiS = SISPTR(pScrn); + CARD32 dstbase; PDEBUG(ErrorF("Subsequent Mono8x8PatternFillTrap(%d, %d, %d - %d %d/%d %d/%d)\n", y, h, left, right, dxL, dxR, eL, eR)); @@ -1192,7 +1181,7 @@ SiSSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, patadr += 16; /* = 64 due to (CARD32 *) */ } - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupROP(XAAPatternROP[rop]) SiSSetupCMDFlag(PATPATREG) @@ -1203,8 +1192,8 @@ static void SiSSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patternx, int patterny, int x, int y, int w, int h) { - SISPtr pSiS = SISPTR(pScrn); - long dstbase; + SISPtr pSiS = SISPTR(pScrn); + CARD32 dstbase; #ifdef ACCELDEBUG xf86DrvMsg(0, X_INFO, "Subsequent Color8x8FillRect(%d, %d, %d, %d)\n", @@ -1251,7 +1240,7 @@ SiSSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, #ifdef SISVRAMQ SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); - SiSSetupROP(sisALUConv[rop]); + SiSSetupROP(XAACopyROP[rop]); SiSSetupSRCFGDSTRect(fg, pSiS->scrnOffset, -1) if(bg == -1) { SiSSetupCMDFlag(TRANSPARENT | ENCOLOREXP | SRCVIDEO); @@ -1262,7 +1251,7 @@ SiSSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, SiSSyncWP #else SiSSetupSRCXY(0,0); - SiSSetupROP(sisALUConv[rop]); + SiSSetupROP(XAACopyROP[rop]); SiSSetupSRCFG(fg); SiSSetupDSTRect(pSiS->scrnOffset, -1); SiSSetupDSTColorDepth(pSiS->DstColor); @@ -1283,7 +1272,7 @@ SiSSubsequentCPUToScreenColorExpandFill( { SISPtr pSiS = SISPTR(pScrn); int _x0, _y0, _x1, _y1; - long srcbase, dstbase; + CARD32 srcbase, dstbase; srcbase = pSiS->ColorExpandBase; @@ -1363,7 +1352,7 @@ SiSSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, #endif SiSSetupSRCXY(0,0); - SiSSetupROP(sisALUConv[rop]); + SiSSetupROP(XAACopyROP[rop]); SiSSetupSRCFG(fg); SiSSetupDSTRect(pSiS->scrnOffset, -1); #ifndef SISVRAMQ @@ -1394,7 +1383,7 @@ SiSSubsequentScanlineCPUToScreenColorExpandFill( { SISPtr pSiS = SISPTR(pScrn); int _x0, _y0, _x1, _y1; - long dstbase; + CARD32 dstbase; dstbase = 0; if(y >= 2048) { @@ -1439,7 +1428,7 @@ static void SiSSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) { SISPtr pSiS = SISPTR(pScrn); - long cbo; + CARD32 cbo; cbo = pSiS->ColorExpandBufferScreenOffset[bufno]; #ifdef SISDUALHEAD @@ -1474,7 +1463,7 @@ SiSSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) * limit the drawing width (similar to width set by SetupRect). * XAA provides the pattern bitmap with scrnOffset (displayWidth * bpp/8) * offset, but this is not supported by the hardware. - * DOES NOT WORK ON XABRE, HANGS ENGINE. + * DOES NOT WORK ON 330 SERIES, HANGS ENGINE. */ #ifdef STSCE @@ -1491,7 +1480,7 @@ SiSSetupForScreenToScreenColorExpand(ScrnInfoPtr pScrn, SiSSetupDSTColorDepth(pSiS->DstColor) #endif SiSSetupDSTRect(pSiS->scrnOffset, -1) - SiSSetupROP(sisALUConv[rop]) + SiSSetupROP(XAACopyROP[rop]) SiSSetupSRCFG(fg) /* SiSSetupSRCXY(0,0) */ @@ -1550,7 +1539,7 @@ SiSSubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, int srcx, int srcy, int skipleft) { SISPtr pSiS = SISPTR(pScrn); - long srcbase, dstbase; + CARD32 srcbase, dstbase; #if 0 int _x0, _y0, _x1, _y1; #endif @@ -1716,8 +1705,8 @@ SiSSetupForCPUToScreenAlphaTexture(ScrnInfoPtr pScrn, unsigned char *renderaccelarray; #ifdef ACCELDEBUG - xf86DrvMsg(0, X_INFO, "AT: op %d RGB %x %x %x, w %d h %d A-pitch %d\n", - op, red, green, blue, width, height, alphaPitch); + xf86DrvMsg(0, X_INFO, "AT: op %d type %d ARGB %x %x %x %x, w %d h %d A-pitch %d\n", + op, alphaType, alpha, red, green, blue, width, height, alphaPitch); #endif if(op != PictOpOver) return FALSE; @@ -1728,14 +1717,16 @@ SiSSetupForCPUToScreenAlphaTexture(ScrnInfoPtr pScrn, sizeNeeded = pitch * height; if(pScrn->bitsPerPixel == 16) sizeNeeded <<= 1; - red &= 0xff00; - green &= 0xff00; - blue &= 0xff00; - renderaccelarray = pSiS->RenderAccelArray; + if(!((renderaccelarray = pSiS->RenderAccelArray))) + return FALSE; if(!SiSAllocateLinear(pScrn, sizeNeeded)) return FALSE; + red &= 0xff00; + green &= 0xff00; + blue &= 0xff00; + #ifdef SISVRAMQ SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); SiSSetupSRCPitchDSTRect((pitch << 2), pSiS->scrnOffset, -1); @@ -1759,17 +1750,38 @@ SiSSetupForCPUToScreenAlphaTexture(ScrnInfoPtr pScrn, SiSIdle } - while(height--) { - for(x = 0; x < width; x++) { - myalpha = alphaPtr[x]; - dstPtr[x] = (renderaccelarray[red + myalpha] << 16) | - (renderaccelarray[green + myalpha] << 8) | - renderaccelarray[blue + myalpha] | - myalpha << 24; - } - dstPtr += pitch; - alphaPtr += alphaPitch; - } + + if(alpha == 0xffff) { + + while(height--) { + for(x = 0; x < width; x++) { + myalpha = alphaPtr[x]; + dstPtr[x] = (renderaccelarray[red + myalpha] << 16) | + (renderaccelarray[green + myalpha] << 8) | + renderaccelarray[blue + myalpha] | + myalpha << 24; + } + dstPtr += pitch; + alphaPtr += alphaPitch; + } + + } else { + + alpha &= 0xff00; + + while(height--) { + for(x = 0; x < width; x++) { + myalpha = alphaPtr[x]; + dstPtr[x] = (renderaccelarray[alpha + myalpha] << 24) | + (renderaccelarray[red + myalpha] << 16) | + (renderaccelarray[green + myalpha] << 8) | + renderaccelarray[blue + myalpha]; + } + dstPtr += pitch; + alphaPtr += alphaPitch; + } + + } return TRUE; } @@ -1843,11 +1855,10 @@ SiSSubsequentCPUToScreenTexture(ScrnInfoPtr pScrn, int width, int height) { SISPtr pSiS = SISPTR(pScrn); - long srcbase, dstbase; + CARD32 srcbase, dstbase; srcbase = pSiS->AccelLinearScratch->offset << 1; - if(pScrn->bitsPerPixel == 32) - srcbase <<= 1; + if(pScrn->bitsPerPixel == 32) srcbase <<= 1; #ifdef ACCELDEBUG xf86DrvMsg(0, X_INFO, "FIRE: scrbase %x dx %d dy %d w %d h %d\n", diff --git a/src/sis310_accel.h b/src/sis310_accel.h index fdf1e35..62afd45 100644 --- a/src/sis310_accel.h +++ b/src/sis310_accel.h @@ -1,40 +1,44 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis310_accel.h,v 1.13 2003/09/02 18:28:35 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * 2D Acceleration for SiS 315 and Xabre series * Definitions for the SIS engine communication. * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * 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. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * 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. - * - * Based on sis300_accel.h - * 2003/08/18: Added VRAM queue support + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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 * + * 2003/08/18: Added VRAM queue support + * */ /* SiS315 and 330 engine commands */ #define BITBLT 0x00000000 /* Blit */ #define COLOREXP 0x00000001 /* Color expand */ #define ENCOLOREXP 0x00000002 /* Enhanced color expand (315 only?) */ -#define MULTIPLE_SCANLINE 0x00000003 /* ? */ +#define MULTIPLE_SCANLINE 0x00000003 /* 315 only, not 330 */ #define LINE 0x00000004 /* Draw line */ #define TRAPAZOID_FILL 0x00000005 /* Fill trapezoid */ #define TRANSPARENT_BITBLT 0x00000006 /* Transparent Blit */ @@ -44,6 +48,9 @@ #define GRADIENT_FILL 0x0000000A /* Gradient fill */ #define STRETCH_BITBLT 0x0000000B /* Stretched BitBlit */ +#define YUVRGB_BLIT_325 0x0000000C +#define YUVRGB_BLIT_330 0x00000003 + /* Command bits */ /* Source selection */ @@ -94,6 +101,21 @@ #define T_R_Y_INC 0x00400000 /* right edge direction Y */ #define T_R_X_INC 0x00200000 /* right edge direction X */ +/* YUV to RGB blit */ +#define YUV_FORMAT_YUY2 0x00000000 +#define YUV_FORMAT_YVYU 0x00002000 +#define YUV_FORMAT_UYVY 0x00004000 +#define YUV_FORMAT_VYUY 0x00006000 +#define YUV_FORMAT_NV12 0x00008000 /* Only supported one */ +#define YUV_FORMAT_NV21 0x0000A000 + +#define YUV_CMD_YUV 0x00800000 + +/* Scanline trigger (315 only, not 330) */ +#define SCANLINE_TR_CRT1 0x00000000 +#define SCANLINE_TR_CRT2 0x01000000 +#define SCANLINE_TRIGGER_ENABLE 0x80000000 + /* Some general registers */ #define SRC_ADDR 0x8200 #define SRC_PITCH 0x8204 @@ -163,6 +185,10 @@ #define SIS_PACKET_HEADER1 0x62100000L #define SIS_NIL_CMD 0x168F0000L +#define SIS_PACKET12_HEADER0 0x968A000CL +#define SIS_PACKET12_HEADER1 0x62100010L +#define SIS_PACKET12_LENGTH 80 + /* Macros to do useful things with the SiS315/330 BitBLT engine */ /* Q_STATUS: @@ -189,7 +215,7 @@ while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x0400) != 0x0400) {}; \ } -#define SiSResetCmd pSiS->CommandReg = 0; +#define SiSResetCmd pSiS->CommandReg = 0; #define SiSSetupCMDFlag(flags) pSiS->CommandReg |= (flags); @@ -198,11 +224,20 @@ #define SiSGetSwWP() (CARD32)(*(pSiS->cmdQ_SharedWritePort)) #define SiSGetHwRP() (CARD32)(MMIO_IN32(pSiS->IOBase, Q_READ_PTR)) -#define SiSSyncWP MMIO_OUT32(pSiS->IOBase, Q_WRITE_PTR, (CARD32)(*(pSiS->cmdQ_SharedWritePort))); - +#define SiSFlushCmdBuf \ + if(pSiS->NeedFlush) { \ + CARD32 ttt = ((SiSGetSwWP()) - 4) & pSiS->cmdQueueSizeMask; \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + dummybuf = ((volatile CARD32 *)(tt))[0]; \ + } + +#define SiSSyncWP \ + SiSFlushCmdBuf; \ + MMIO_OUT32(pSiS->IOBase, Q_WRITE_PTR, (CARD32)(*(pSiS->cmdQ_SharedWritePort))); + #define SiSSetHwWP(p) \ - *(pSiS->cmdQ_SharedWritePort) = (p); \ - MMIO_OUT32(pSiS->IOBase, Q_WRITE_PTR, (p)); \ + *(pSiS->cmdQ_SharedWritePort) = (p); \ + MMIO_OUT32(pSiS->IOBase, Q_WRITE_PTR, (p)); #define SiSSetSwWP(p) *(pSiS->cmdQ_SharedWritePort) = (p); @@ -276,9 +311,9 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + SRC_Y); \ - ((CARD32 *)(tt))[1] = (CARD32)((sx)<<16 | (sy)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((sx)<<16) | (sy)); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + DST_Y); \ - ((CARD32 *)(tt))[3] = (CARD32)((dx)<<16 | (dy)); \ + ((CARD32 *)(tt))[3] = (CARD32)(((dx)<<16) | (dy)); \ SiSUpdateQueue \ SiSSetSwWP(ttt); \ } @@ -288,9 +323,9 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + DST_Y); \ - ((CARD32 *)(tt))[1] = (CARD32)((x)<<16 | (y)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((x)<<16) | (y)); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + RECT_WIDTH); \ - ((CARD32 *)(tt))[3] = (CARD32)((h)<<16 | (w)); \ + ((CARD32 *)(tt))[3] = (CARD32)(((h)<<16) | (w)); \ SiSUpdateQueue \ SiSSetSwWP(ttt); \ } @@ -302,7 +337,7 @@ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + SRC_PITCH); \ ((CARD32 *)(tt))[1] = (CARD32)(pitch); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + DST_PITCH); \ - ((CARD32 *)(tt))[3] = (CARD32)((y)<<16 | (x)); \ + ((CARD32 *)(tt))[3] = (CARD32)(((y)<<16) | (x)); \ SiSUpdateQueue \ SiSSetSwWP(ttt); \ } @@ -330,7 +365,7 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + SRC_Y); \ - ((CARD32 *)(tt))[1] = (CARD32)((x)<<16 | (y)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((x)<<16) | (y)); \ SiSNILandUpdateSWQueue \ } @@ -348,7 +383,7 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + DST_Y); \ - ((CARD32 *)(tt))[1] = (CARD32)((x)<<16 | (y)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((x)<<16) | (y)); \ SiSNILandUpdateSWQueue \ } @@ -357,7 +392,7 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + DST_PITCH); \ - ((CARD32 *)(tt))[1] = (CARD32)((y)<<16 | (x)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((y)<<16) | (x)); \ SiSNILandUpdateSWQueue \ } @@ -366,7 +401,7 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + DST_PITCH); \ - ((CARD32 *)(tt))[1] = (CARD32)((y)<<16 | (x)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((y)<<16) | (x)); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_BURST_HEADER0 + reg); \ ((CARD32 *)(tt))[3] = (CARD32)(SIS_BURST_HEADER1 + num); \ SiSUpdateQueue \ @@ -383,7 +418,7 @@ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + PAT_FGCOLOR); \ ((CARD32 *)(tt))[1] = (CARD32)(color); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + DST_PITCH); \ - ((CARD32 *)(tt))[3] = (CARD32)((y)<<16 | (x)); \ + ((CARD32 *)(tt))[3] = (CARD32)(((y)<<16) | (x)); \ SiSUpdateQueue \ SiSSetSwWP(ttt); \ } @@ -395,7 +430,7 @@ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + SRC_FGCOLOR); \ ((CARD32 *)(tt))[1] = (CARD32)(color); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + DST_PITCH); \ - ((CARD32 *)(tt))[3] = (CARD32)((y)<<16 | (x)); \ + ((CARD32 *)(tt))[3] = (CARD32)(((y)<<16) | (x)); \ SiSUpdateQueue \ SiSSetSwWP(ttt); \ } @@ -405,7 +440,7 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + RECT_WIDTH); \ - ((CARD32 *)(tt))[1] = (CARD32)((h)<<16 | (w)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((h)<<16) | (w)); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + SRC_PITCH); \ ((CARD32 *)(tt))[3] = (CARD32)(pitch); \ SiSUpdateQueue \ @@ -417,7 +452,7 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + RECT_WIDTH); \ - ((CARD32 *)(tt))[1] = (CARD32)((h)<<16 | (w)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((h)<<16) | (w)); \ SiSNILandUpdateSWQueue \ } @@ -498,9 +533,9 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + LEFT_CLIP); \ - ((CARD32 *)(tt))[1] = (CARD32)(((left) & 0xFFFF) | (top)<<16); \ + ((CARD32 *)(tt))[1] = (CARD32)(((left) & 0xFFFF) | ((top)<<16)); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + RIGHT_CLIP); \ - ((CARD32 *)(tt))[3] = (CARD32)(((right) & 0xFFFF) | (bottom)<<16); \ + ((CARD32 *)(tt))[3] = (CARD32)(((right) & 0xFFFF)|((bottom)<<16)); \ SiSUpdateQueue \ SiSSetSwWP(ttt); \ } @@ -513,6 +548,7 @@ ((CARD32 *)(tt))[1] = (CARD32)(base); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + COMMAND_READY); \ ((CARD32 *)(tt))[3] = (CARD32)(pSiS->CommandReg); \ + if(pSiS->NeedFlush) dummybuf = ((volatile CARD32 *)(tt))[3]; \ SiSUpdateQueue \ SiSSetHwWP(ttt); \ } @@ -522,11 +558,12 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + RECT_WIDTH); \ - ((CARD32 *)(tt))[1] = (CARD32)((h)<<16 | (w)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((h)<<16) | (w)); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + COMMAND_READY); \ ((CARD32 *)(tt))[3] = (CARD32)(pSiS->CommandReg); \ - SiSUpdateQueue \ - SiSSetHwWP(ttt); \ + if(pSiS->NeedFlush) dummybuf = ((volatile CARD32 *)(tt))[3]; \ + SiSUpdateQueue \ + SiSSetHwWP(ttt); \ } #define SiSSetupROP(rop) \ @@ -540,6 +577,7 @@ ((CARD32 *)(tt))[1] = (CARD32)(pSiS->CommandReg); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_NIL_CMD); \ ((CARD32 *)(tt))[3] = (CARD32)(SIS_NIL_CMD); \ + if(pSiS->NeedFlush) dummybuf = ((volatile CARD32 *)(tt))[3]; \ SiSUpdateQueue \ SiSSetHwWP(ttt); \ } @@ -551,9 +589,9 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + LINE_X0); \ - ((CARD32 *)(tt))[1] = (CARD32)((y1)<<16 | (x1)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((y1)<<16) | (x1)); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + LINE_X1); \ - ((CARD32 *)(tt))[3] = (CARD32)((y2)<<16 | (x2)); \ + ((CARD32 *)(tt))[3] = (CARD32)(((y2)<<16) | (x2)); \ SiSUpdateQueue \ SiSSetSwWP(ttt); \ } @@ -563,7 +601,7 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + LINE_X0); \ - ((CARD32 *)(tt))[1] = (CARD32)((y)<<16 | (x)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((y)<<16) | (x)); \ SiSNILandUpdateSWQueue \ } @@ -572,7 +610,7 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + LINE_X1); \ - ((CARD32 *)(tt))[1] = (CARD32)((y)<<16 | (x)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((y)<<16) | (x)); \ SiSNILandUpdateSWQueue \ } @@ -581,7 +619,7 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + LINE_COUNT); \ - ((CARD32 *)(tt))[1] = (CARD32)((p) << 16 | (c)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((p) << 16) | (c)); \ SiSNILandUpdateSWQueue \ } @@ -604,9 +642,9 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + TRAP_YH); \ - ((CARD32 *)(tt))[1] = (CARD32)((y)<<16 | (h)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((y)<<16) | (h)); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + TRAP_LR); \ - ((CARD32 *)(tt))[3] = (CARD32)((right)<<16 | (left)); \ + ((CARD32 *)(tt))[3] = (CARD32)(((right)<<16) | (left)); \ SiSUpdateQueue \ SiSSetSwWP(ttt); \ } @@ -617,9 +655,9 @@ CARD32 ttt = SiSGetSwWP(); \ pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + TRAP_DL); \ - ((CARD32 *)(tt))[1] = (CARD32)((dyL)<<16 | (dxL)); \ + ((CARD32 *)(tt))[1] = (CARD32)(((dyL)<<16) | (dxL)); \ ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + TRAP_DR); \ - ((CARD32 *)(tt))[3] = (CARD32)((dyR)<<16 | (dxR)); \ + ((CARD32 *)(tt))[3] = (CARD32)(((dyR)<<16) | (dxR)); \ SiSUpdateQueue \ SiSSetSwWP(ttt); \ } @@ -668,6 +706,49 @@ SiSSetSwWP(ttt); \ } +typedef struct _SiS_Packet12_YUV { + CARD32 P12_Header0; + CARD32 P12_Header1; + CARD16 P12_UVPitch; /* 8200 UV if planar, Y if packed */ + CARD16 P12_Unused0; /* 8202 */ + CARD16 P12_YPitch; /* 8204 Y if planar */ + CARD16 P12_AGPBase; /* 8206 */ + CARD16 P12_Unused1; /* 8208 */ + CARD16 P12_Unused2; /* 820a */ + CARD16 P12_DstY; /* 820c */ + CARD16 P12_DstX; /* 820e */ + CARD32 P12_DstAddr; /* 8210 */ + CARD16 P12_DstPitch; /* 8214 */ + CARD16 P12_DstHeight; /* 8216 */ + CARD16 P12_RectWidth; /* 8218 */ + CARD16 P12_RectHeight; /* 821a */ + CARD32 P12_Unused3; /* 821c */ + CARD32 P12_Unused4; /* 8220 */ + CARD32 P12_UVSrcAddr; /* 8224 UV if planar, Y if packed */ + CARD32 P12_YSrcAddr; /* 8228 Y if planar */ + CARD32 P12_Unused5; /* 822c */ + CARD32 P12_Unused6; /* 8230 */ + CARD16 P12_ClipLeft; /* 8234 */ + CARD16 P12_ClipTop; /* 8236 */ + CARD16 P12_ClipRight; /* 8238 */ + CARD16 P12_ClipBottom; /* 823a */ + CARD32 P12_Command; /* 823c */ + CARD32 P12_Null1; + CARD32 P12_Null2; +} SiS_Packet12_YUV; + +#define SiSWritePacketPart(part1, part2, part3, part4) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(part1); \ + ((CARD32 *)(tt))[1] = (CARD32)(part2); \ + ((CARD32 *)(tt))[2] = (CARD32)(part3); \ + ((CARD32 *)(tt))[3] = (CARD32)(part4); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + #endif /* VRAM mode */ /* ---- MMIO mode ---- */ diff --git a/src/sis6326_video.c b/src/sis6326_video.c index 7c9fdf9..3f2a44d 100644 --- a/src/sis6326_video.c +++ b/src/sis6326_video.c @@ -1,31 +1,34 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis6326_video.c,v 1.9 2003/08/07 12:52:23 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Xv driver for SiS 5597/5598, 6236 and 530/620. * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria. * - * Based on sis_video.c which is - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * 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. - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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 + * */ #include "sis.h" @@ -43,7 +46,6 @@ #include "xf86xv.h" #include "Xv.h" #include "xaa.h" -#include "xaalocal.h" #include "dixstruct.h" #include "fourcc.h" @@ -390,7 +392,7 @@ typedef struct { (SISPortPrivPtr)((SISPTR(pScrn))->adaptor->pPortPrivates[0].ptr) static void -SIS6326SetPortDefaults (ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) +SIS6326SetPortDefaults(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) { SISPtr pSiS = SISPTR(pScrn); @@ -526,6 +528,13 @@ SIS6326SetupImageVideo(ScreenPtr pScreen) XF86VideoAdaptorPtr adapt; SISPortPrivPtr pPriv; +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,1,99,1,0) + XAAInfoRecPtr pXAA = pSiS->AccelInfoPtr; + + if (!pXAA || !pXAA->FillSolidRects) + return NULL; +#endif + if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + sizeof(SISPortPrivRec) + sizeof(DevUnion)))) @@ -576,7 +585,11 @@ SIS6326SetupImageVideo(ScreenPtr pScreen) SIS6326SetPortDefaults(pScrn, pPriv); /* gotta uninit this someplace */ - REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); +#if defined(REGION_NULL) + REGION_NULL(pScreen, &pPriv->clip); +#else + REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); +#endif pSiS->adaptor = adapt; @@ -588,11 +601,12 @@ SIS6326SetupImageVideo(ScreenPtr pScreen) xvDisableGfx = MAKE_ATOM("XV_DISABLE_GRAPHICS"); SIS6326ResetVideo(pScrn); + pSiS->ResetXv = SIS6326ResetVideo; return adapt; } -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,3,0) static Bool RegionsEqual(RegionPtr A, RegionPtr B) { @@ -1261,17 +1275,17 @@ SIS6326StopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown) if(shutdown) { if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - close_overlay(pSiS, pPriv); - pPriv->mustwait = 1; + close_overlay(pSiS, pPriv); + pPriv->mustwait = 1; } SIS6326FreeOverlayMemory(pScrn); pPriv->videoStatus = 0; pSiS->VideoTimerCallback = NULL; } else { if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - pPriv->videoStatus = OFF_TIMER | CLIENT_VIDEO_ON; - pPriv->offTime = currentTime.milliseconds + OFF_DELAY; - pSiS->VideoTimerCallback = SIS6326VideoTimerCallback; + pPriv->videoStatus = OFF_TIMER | CLIENT_VIDEO_ON; + pPriv->offTime = currentTime.milliseconds + OFF_DELAY; + pSiS->VideoTimerCallback = SIS6326VideoTimerCallback; } } } @@ -1310,7 +1324,7 @@ SIS6326PutImage( pPriv->height = height; pPriv->width = width; - /* TW: Pixel formats: + /* Pixel formats: 1. YU12: 3 planes: H V Y sample period 1 1 (8 bit per pixel) V sample period 2 2 (8 bit per pixel, subsampled) @@ -1383,29 +1397,25 @@ SIS6326PutImage( SIS6326DisplayVideo(pScrn, pPriv); /* update cliplist */ -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) if( pPriv->autopaintColorKey && (pPriv->grabbedByV4L || +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,3,0) !RegionsEqual(&pPriv->clip, clipBoxes)) ) { +#else + !REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) ) { +#endif /* We always paint colorkey for V4L */ if(!pPriv->grabbedByV4L) REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); /* draw these */ - XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,1,99,1,0) + (*pSiS->AccelInfoPtr->FillSolidRects)(pScrn, pPriv->colorKey, GXcopy, ~0, REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); - } #else - if( pPriv->autopaintColorKey && - (pPriv->grabbedByV4L || - !REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) ) { - /* We always paint colorkey for V4L */ - if(!pPriv->grabbedByV4L) - REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); - /* draw these */ xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - } #endif + } pPriv->currentBuf ^= 1; @@ -1487,33 +1497,32 @@ SIS6326VideoTimerCallback (ScrnInfoPtr pScrn, Time now) if(pSiS->adaptor) { pPriv = GET_PORT_PRIVATE(pScrn); - if(!pPriv->videoStatus) - pPriv = NULL; + if(!pPriv->videoStatus) pPriv = NULL; } if(pPriv) { - if(pPriv->videoStatus & TIMER_MASK) { - UpdateCurrentTime(); - if(pPriv->offTime < currentTime.milliseconds) { + if(pPriv->videoStatus & TIMER_MASK) { if(pPriv->videoStatus & OFF_TIMER) { - /* Turn off the overlay */ - sridx = inSISREG(SISSR); cridx = inSISREG(SISCR); - close_overlay(pSiS, pPriv); - outSISREG(SISSR, sridx); outSISREG(SISCR, cridx); - pPriv->mustwait = 1; - pPriv->videoStatus = FREE_TIMER; - pPriv->freeTime = currentTime.milliseconds + FREE_DELAY; - pSiS->VideoTimerCallback = SIS6326VideoTimerCallback; + if(pPriv->offTime < now) { + /* Turn off the overlay */ + sridx = inSISREG(SISSR); cridx = inSISREG(SISCR); + close_overlay(pSiS, pPriv); + outSISREG(SISSR, sridx); outSISREG(SISCR, cridx); + pPriv->mustwait = 1; + pPriv->videoStatus = FREE_TIMER; + pPriv->freeTime = now + FREE_DELAY; + pSiS->VideoTimerCallback = SIS6326VideoTimerCallback; + } + } else if(pPriv->videoStatus & FREE_TIMER) { + if(pPriv->freeTime < now) { + SIS6326FreeOverlayMemory(pScrn); + pPriv->mustwait = 1; + pPriv->videoStatus = 0; + } } else - if(pPriv->videoStatus & FREE_TIMER) { - SIS6326FreeOverlayMemory(pScrn); - pPriv->mustwait = 1; - pPriv->videoStatus = 0; - } - } else - pSiS->VideoTimerCallback = SIS6326VideoTimerCallback; - } - } + pSiS->VideoTimerCallback = SIS6326VideoTimerCallback; + } + } } /* Offscreen surface stuff for v4l */ @@ -1658,8 +1667,8 @@ SIS6326DisplaySurface ( SIS6326DisplayVideo(pScrn, pPriv); if(pPriv->autopaintColorKey) { -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) - XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,1,99,1,0) + (*XAAPTR(pScrn)->FillSolidRects)(pScrn, pPriv->colorKey, GXcopy, ~0, REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); #else diff --git a/src/sis_accel.c b/src/sis_accel.c index 529a087..d97d56b 100644 --- a/src/sis_accel.c +++ b/src/sis_accel.c @@ -1,34 +1,37 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c,v 1.29 2003/06/26 22:35:17 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * 2D acceleration for SiS5597/5598 and 6326 * - * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Parts Copyright 2002-2003 Thomas Winischhofer, Vienna, Austria. + * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England. + * Parts Copyright (C) 2001-2004 Thomas Winischhofer, Vienna, Austria. + * + * Licensed under the following terms: * * 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 + * the above copyright notice appears in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * 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. + * "as is" without expressed or implied warranty. * * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * 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. * - * Authors: Alan Hourihane, alanh@fairlite.demon.co.uk + * Authors: Alan Hourihane , * Mike Chapman , * Juanjo Santamarta , - * Mitani Hiroshi - * David Thomas - * Thomas Winischhofer + * Mitani Hiroshi , + * David Thomas , + * Thomas Winischhofer . */ #if 0 @@ -214,7 +217,7 @@ SiSAccelInit(ScreenPtr pScreen) if(AvailFBArea.y2 < pScrn->currentMode->VDisplay) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Not enough video RAM for accelerator. At least " - "%dKB needed, %dKB available\n", + "%dKB needed, %ldKB available\n", ((((pScrn->displayWidth * pScrn->bitsPerPixel/8) /* TW: +8 for make it sure */ * pScrn->currentMode->VDisplay) + reservedFbSize) / 1024) + 8, pSiS->maxxfbmem/1024); @@ -242,7 +245,7 @@ SiSSync(ScrnInfoPtr pScrn) { } /* Clipping */ -static void SiSSetClippingRectangle ( ScrnInfoPtr pScrn, +static void SiSSetClippingRectangle( ScrnInfoPtr pScrn, int left, int top, int right, int bottom) { SISPtr pSiS = SISPTR(pScrn); @@ -253,53 +256,12 @@ static void SiSSetClippingRectangle ( ScrnInfoPtr pScrn, pSiS->ClipEnabled = TRUE; } -static void SiSDisableClipping (ScrnInfoPtr pScrn) +static void SiSDisableClipping(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); pSiS->ClipEnabled = FALSE; } -static const int sisALUConv[] = -{ - 0x00, /* dest = 0; 0, GXclear, 0 */ - 0x88, /* dest &= src; DSa, GXand, 0x1 */ - 0x44, /* dest = src & ~dest; SDna, GXandReverse, 0x2 */ - 0xCC, /* dest = src; S, GXcopy, 0x3 */ - 0x22, /* dest &= ~src; DSna, GXandInverted, 0x4 */ - 0xAA, /* dest = dest; D, GXnoop, 0x5 */ - 0x66, /* dest = ^src; DSx, GXxor, 0x6 */ - 0xEE, /* dest |= src; DSo, GXor, 0x7 */ - 0x11, /* dest = ~src & ~dest; DSon, GXnor, 0x8 */ - 0x99, /* dest ^= ~src ; DSxn, GXequiv, 0x9 */ - 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */ - 0xDD, /* dest = src|~dest ; SDno, GXorReverse, 0xB */ - 0x33, /* dest = ~src; Sn, GXcopyInverted, 0xC */ - 0xBB, /* dest |= ~src; DSno, GXorInverted, 0xD */ - 0x77, /* dest = ~src|~dest; DSan, GXnand, 0xE */ - 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ -}; -/* same ROP but with Pattern as Source */ -static const int sisPatALUConv[] = -{ - 0x00, /* dest = 0; 0, GXclear, 0 */ - 0xA0, /* dest &= src; DPa, GXand, 0x1 */ - 0x50, /* dest = src & ~dest; PDna, GXandReverse, 0x2 */ - 0xF0, /* dest = src; P, GXcopy, 0x3 */ - 0x0A, /* dest &= ~src; DPna, GXandInverted, 0x4 */ - 0xAA, /* dest = dest; D, GXnoop, 0x5 */ - 0x5A, /* dest = ^src; DPx, GXxor, 0x6 */ - 0xFA, /* dest |= src; DPo, GXor, 0x7 */ - 0x05, /* dest = ~src & ~dest; DPon, GXnor, 0x8 */ - 0xA5, /* dest ^= ~src ; DPxn, GXequiv, 0x9 */ - 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */ - 0xF5, /* dest = src|~dest ; PDno, GXorReverse, 0xB */ - 0x0F, /* dest = ~src; Pn, GXcopyInverted, 0xC */ - 0xAF, /* dest |= ~src; DPno, GXorInverted, 0xD */ - 0x5F, /* dest = ~src|~dest; DPan, GXnand, 0xE */ - 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ -}; - - /* Screen to screen copy */ static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, @@ -416,7 +378,7 @@ SiSSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, patternRegPtr = (unsigned int *)sisSETPATREG(); pSiS->sisPatternReg[0] = pSiS->sisPatternReg[2] = patternx ; pSiS->sisPatternReg[1] = pSiS->sisPatternReg[3] = patterny ; - for ( i = 0 ; i < 16 /* sisPatternHeight */ ; ) { + for( i = 0 ; i < 16 /* sisPatternHeight */ ; ) { patternRegPtr[i++] = patternx ; patternRegPtr[i++] = patterny ; } @@ -577,11 +539,11 @@ SiSSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, sisSETROPBG(0xAA); /* dst = dst (=noop) */ pSiS->CommandReg |= sisSRCFG; } else { - sisSETBGROPCOL(sisPatALUConv[rop], bg); + sisSETBGROPCOL(XAAPatternROP[rop], bg); pSiS->CommandReg |= sisSRCFG | sisPATBG; } - sisSETFGROPCOL(sisALUConv[rop], fg); + sisSETFGROPCOL(XAACopyROP[rop], fg); sisSETDSTPITCH(pSiS->scrnOffset); } diff --git a/src/sis_accel.h b/src/sis_accel.h index 5fe9a33..2a3f2fa 100644 --- a/src/sis_accel.h +++ b/src/sis_accel.h @@ -1,35 +1,38 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.h,v 1.6 2003/06/26 22:35:17 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * 2D acceleration for 5597/5598 and 6326 * Definitions for the SIS engine communication * - * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Parts Copyright 2002,2003 Thomas Winischhofer, Vienna, Austria. + * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England. + * Parts Copyright (C) 2001-2004 Thomas Winischhofer, Vienna, Austria. + * + * Licensed under the following terms: * * 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 + * the above copyright notice appears in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * 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. + * "as is" without expressed or implied warranty. * * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * 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. * - * Authors: Alan Hourihane, alanh@fairlite.demon.co.uk + * Authors: Alan Hourihane , * Mike Chapman , * Juanjo Santamarta , - * Mitani Hiroshi - * David Thomas - * Thomas Winischhofer + * Mitani Hiroshi , + * David Thomas , + * Thomas Winischhofer . */ @@ -116,6 +119,7 @@ const int sisReg32MMIO[] = { unsigned long temp; \ MMIO_OUT16(pSiS->IOBase, BR(10) + 2, op); \ temp = MMIO_IN32(pSiS->IOBase, BR(10)); \ + (void)temp; \ } /* set foreground color and fg ROP */ @@ -129,29 +133,17 @@ const int sisReg32MMIO[] = { /* background color */ #define sisSETBGCOLOR(bgColor) \ MMIO_OUT32(pSiS->IOBase, BR(5), (bgColor)); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(5)) = (bgColor) -#endif /* foreground color */ #define sisSETFGCOLOR(fgColor) \ MMIO_OUT32(pSiS->IOBase, BR(4), (fgcolor)); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(4)) = (fgColor) -#endif /* ROP */ #define sisSETROPFG(op) \ MMIO_OUT8(pSiS->IOBase, BR(4) + 3, op); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(4)) = ((*(volatile unsigned int *)(pSiS->IOBase + BR(4)))&0xffffff) | (op<<24) -#endif #define sisSETROPBG(op) \ MMIO_OUT8(pSiS->IOBase, BR(5) + 3, op); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(5)) = ((*(volatile unsigned int *)(pSiS->IOBase + BR(5)))&0xffffff) | (op<<24) -#endif #define sisSETROP(op) \ sisSETROPFG(op); sisSETROPBG(op); @@ -159,23 +151,13 @@ const int sisReg32MMIO[] = { /* source and dest address */ #define sisSETSRCADDR(srcAddr) \ MMIO_OUT32(pSiS->IOBase, BR(0), (srcAddr & 0x3FFFFFL)); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(0)) = srcAddr & 0x3FFFFFL -#endif #define sisSETDSTADDR(dstAddr) \ MMIO_OUT32(pSiS->IOBase, BR(1), (dstAddr & 0x3FFFFFL)); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(1)) = dstAddr & 0x3FFFFFL -#endif /* pitch */ #define sisSETPITCH(srcPitch,dstPitch) \ MMIO_OUT32(pSiS->IOBase, BR(2), ((((dstPitch) & 0xFFFF) << 16) | ((srcPitch) & 0xFFFF))); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(2)) = ((dstPitch&0xFFFF)<<16)| \ - (srcPitch&0xFFFF) -#endif #define sisSETSRCPITCH(srcPitch) \ MMIO_OUT16(pSiS->IOBase, BR(2), ((srcPitch) & 0xFFFF)); @@ -189,54 +171,26 @@ const int sisReg32MMIO[] = { */ #define sisSETHEIGHTWIDTH(Height, Width) \ MMIO_OUT32(pSiS->IOBase, BR(3), ((((Height) & 0xFFFF) << 16) | ((Width) & 0xFFFF))); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(3)) = (((Height)&0xFFFF)<<16)| \ - ((Width)&0xFFFF) -#endif /* Clipping */ #define sisSETCLIPTOP(x, y) \ MMIO_OUT32(pSiS->IOBase, BR(8), ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(8)) = (((y)&0xFFFF)<<16)| \ - ((x)&0xFFFF) -#endif #define sisSETCLIPBOTTOM(x, y) \ MMIO_OUT32(pSiS->IOBase, BR(9), ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(9)) = (((y)&0xFFFF)<<16)| \ - ((x)&0xFFFF) -#endif /* Line drawing */ #define sisSETXStart(XStart) \ MMIO_OUT32(pSiS->IOBase, BR(0), ((XStart) & 0xFFFF)); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(0)) = XStart&0xFFFF -#endif #define sisSETYStart(YStart) \ MMIO_OUT32(pSiS->IOBase, BR(1), ((YStart) & 0xFFFF)); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(1)) = YStart&0xFFFF -#endif #define sisSETLineMajorCount(MajorAxisCount) \ MMIO_OUT32(pSiS->IOBase, BR(3), ((MajorAxisCount) & 0xFFFF)); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(3)) = MajorAxisCount&0xFFFF -#endif #define sisSETLineSteps(K1,K2) \ MMIO_OUT32(pSiS->IOBase, BR(6), ((((K1) & 0xFFFF) << 16) | ((K2) & 0xFFFF))); -#if 0 - *(volatile unsigned int *)(pSiS->IOBase + BR(6)) = (((K1)&0xFFFF)<<16)| \ - ((K2)&0xFFFF) -#endif #define sisSETLineErrorTerm(ErrorTerm) \ MMIO_OUT16(pSiS->IOBase, BR(7), (ErrorTerm)); -#if 0 - *(volatile unsigned short *)(pSiS->IOBase + BR(7)) = ErrorTerm -#endif diff --git a/src/sis_common.h b/src/sis_common.h index cbddf0c..690c9ce 100644 --- a/src/sis_common.h +++ b/src/sis_common.h @@ -1,4 +1,5 @@ -/* * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_common.h,v 1.1 2003/08/29 08:52:12 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Common header definitions for SiS 2D/3D/DRM suite * @@ -6,16 +7,16 @@ * * 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 + * the above copyright notice appears in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * 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. + * "as is" without expressed or implied warranty. * * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * 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 diff --git a/src/sis_cursor.c b/src/sis_cursor.c index d7b6b46..9620303 100644 --- a/src/sis_cursor.c +++ b/src/sis_cursor.c @@ -1,34 +1,36 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c,v 1.18 2003/09/04 15:32:42 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * SiS hardware cursor handling * - * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria. * - * 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 holders not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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 + * + * Idea based on code by Can-Ru Yeou, SiS Inc. * - * Authors: Alan Hourihane, alanh@fairlite.demon.co.uk - * Mike Chapman , - * Juanjo Santamarta , - * Mitani Hiroshi - * David Thomas . - * Thomas Winischhofer */ #include "xf86.h" @@ -66,8 +68,6 @@ SiSXConvertMono2ARGB(SISPtr pSiS) if(!dest || !src) return; - if(pSiS->UseHWARGBCursor) return; - for(i = 0; i < 64; i++) { for(j = 0; j < 8; j++) { chunk = *(src + 8); mask = *src++; @@ -105,23 +105,23 @@ SiS300HideCursor(ScrnInfoPtr pScrn) #ifdef SISDUALHEAD if(pSiS->DualHeadMode && (!pSiS->ForceCursorOff)) { - if(pSiS->SecondHead) { - /* TW: Head 2 is always CRT1 */ - sis300DisableHWCursor() - sis300SetCursorPositionY(2000, 0) - } else { - /* TW: Head 1 is always CRT2 */ - sis301DisableHWCursor() - sis301SetCursorPositionY(2000, 0) - } + if(pSiS->SecondHead) { + /* Head 2 is always CRT1 */ + sis300DisableHWCursor() + sis300SetCursorPositionY(2000, 0) + } else { + /* Head 1 is always CRT2 */ + sis301DisableHWCursor() + sis301SetCursorPositionY(2000, 0) + } } else { #endif - sis300DisableHWCursor() - sis300SetCursorPositionY(2000, 0) - if(pSiS->VBFlags & CRT2_ENABLE) { - sis301DisableHWCursor() - sis301SetCursorPositionY(2000, 0) - } + sis300DisableHWCursor() + sis300SetCursorPositionY(2000, 0) + if(pSiS->VBFlags & CRT2_ENABLE) { + sis301DisableHWCursor() + sis301SetCursorPositionY(2000, 0) + } #ifdef SISDUALHEAD } #endif @@ -136,33 +136,23 @@ SiS310HideCursor(ScrnInfoPtr pScrn) #ifdef SISDUALHEAD if(pSiS->DualHeadMode && (!pSiS->ForceCursorOff)) { - if(pSiS->SecondHead) { - /* TW: Head 2 is always CRT1 */ - sis310DisableHWCursor() - sis310SetCursorPositionY(2000, 0) - } else { - /* TW: Head 1 is always CRT2 */ - if(pSiS->ChipFlags & SiSCF_XabreCore) { - sis301DisableHWCursor330() - sis301SetCursorPositionY330(2000, 0) - } else { - sis301DisableHWCursor310() - sis301SetCursorPositionY310(2000, 0) - } - } + if(pSiS->SecondHead) { + /* Head 2 is always CRT1 */ + sis310DisableHWCursor() + sis310SetCursorPositionY(2000, 0) + } else { + /* Head 1 is always CRT2 */ + sis301DisableHWCursor310() + sis301SetCursorPositionY310(2000, 0) + } } else { #endif - sis310DisableHWCursor() - sis310SetCursorPositionY(2000, 0) - if(pSiS->VBFlags & CRT2_ENABLE) { - if(pSiS->ChipFlags & SiSCF_XabreCore) { - sis301DisableHWCursor330() - sis301SetCursorPositionY330(2000, 0) - } else { - sis301DisableHWCursor310() - sis301SetCursorPositionY310(2000, 0) - } - } + sis310DisableHWCursor() + sis310SetCursorPositionY(2000, 0) + if(pSiS->VBFlags & VB_VIDEOBRIDGE) { + sis301DisableHWCursor310() + sis301SetCursorPositionY310(2000, 0) + } #ifdef SISDUALHEAD } #endif @@ -195,50 +185,50 @@ SiS300ShowCursor(ScrnInfoPtr pScrn) #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { - if(pSiS->SecondHead) { - /* TW: Head 2 is always CRT1 */ - if(pSiS->UseHWARGBCursor) { -#ifdef SIS300_USE_ARGB16 - sis300EnableHWARGB16Cursor() + if(pSiS->SecondHead) { + /* Head 2 is always CRT1 */ + if(pSiS->UseHWARGBCursor) { +#ifdef SIS300_USE_ARGB16 + sis300EnableHWARGB16Cursor() #else - sis300EnableHWARGBCursor() -#endif - } else { - sis300EnableHWCursor() - } - } else { - /* TW: Head 1 is always CRT2 */ - if(pSiS->UseHWARGBCursor) { -#ifdef SIS300_USE_ARGB16 - sis301EnableHWARGB16Cursor() + sis300EnableHWARGBCursor() +#endif + } else { + sis300EnableHWCursor() + } + } else { + /* Head 1 is always CRT2 */ + if(pSiS->UseHWARGBCursor) { +#ifdef SIS300_USE_ARGB16 + sis301EnableHWARGB16Cursor() #else - sis301EnableHWARGBCursor() -#endif - } else { - sis301EnableHWCursor() - } - } + sis301EnableHWARGBCursor() +#endif + } else { + sis301EnableHWCursor() + } + } } else { #endif - if(pSiS->UseHWARGBCursor) { + if(pSiS->UseHWARGBCursor) { #ifdef SIS300_USE_ARGB16 - sis300EnableHWARGB16Cursor() + sis300EnableHWARGB16Cursor() #else - sis300EnableHWARGBCursor() -#endif - if(pSiS->VBFlags & CRT2_ENABLE) { -#ifdef SIS300_USE_ARGB16 - sis301EnableHWARGB16Cursor() + sis300EnableHWARGBCursor() +#endif + if(pSiS->VBFlags & CRT2_ENABLE) { +#ifdef SIS300_USE_ARGB16 + sis301EnableHWARGB16Cursor() #else - sis301EnableHWARGBCursor() -#endif - } - } else { - sis300EnableHWCursor() - if(pSiS->VBFlags & CRT2_ENABLE) { - sis301EnableHWCursor() - } - } + sis301EnableHWARGBCursor() +#endif + } + } else { + sis300EnableHWCursor() + if(pSiS->VBFlags & CRT2_ENABLE) { + sis301EnableHWCursor() + } + } #ifdef SISDUALHEAD } #endif @@ -259,49 +249,49 @@ SiS310ShowCursor(ScrnInfoPtr pScrn) #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { - if(pSiS->SecondHead) { - /* TW: Head 2 is always CRT1 */ - if(pSiS->UseHWARGBCursor) { - sis310EnableHWARGBCursor() - } else { - sis310EnableHWCursor() - } - } else { - /* TW: Head 1 is always CRT2 */ - if(pSiS->ChipFlags & SiSCF_XabreCore) { - sis301EnableHWCursor330() - } else { - if(pSiS->UseHWARGBCursor) { - sis301EnableHWARGBCursor310() - } else { - sis301EnableHWCursor310() - } - } - } + if(pSiS->SecondHead) { + /* Head 2 is always CRT1 */ + if(pSiS->UseHWARGBCursor) { + sis310EnableHWARGBCursor() + } else { + sis310EnableHWCursor() + } + } else { + /* Head 1 is always CRT2 */ + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + sis301EnableHWCursor330() + } else { + if(pSiS->UseHWARGBCursor) { + sis301EnableHWARGBCursor310() + } else { + sis301EnableHWCursor310() + } + } + } } else { #endif - if(pSiS->ChipFlags & SiSCF_XabreCore) { - if(pSiS->UseHWARGBCursor) { - sis310EnableHWARGBCursor() - } else { - sis310EnableHWCursor() - } - if(pSiS->VBFlags & CRT2_ENABLE) { - sis301EnableHWCursor330() - } - } else { - if(pSiS->UseHWARGBCursor) { - sis310EnableHWARGBCursor() - if(pSiS->VBFlags & CRT2_ENABLE) { - sis301EnableHWARGBCursor310() - } - } else { - sis310EnableHWCursor() - if(pSiS->VBFlags & CRT2_ENABLE) { - sis301EnableHWCursor310() - } - } - } + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + if(pSiS->UseHWARGBCursor) { + sis310EnableHWARGBCursor() + } else { + sis310EnableHWCursor() + } + if(pSiS->VBFlags & CRT2_ENABLE) { + sis301EnableHWCursor330() + } + } else { + if(pSiS->UseHWARGBCursor) { + sis310EnableHWARGBCursor() + if(pSiS->VBFlags & CRT2_ENABLE) { + sis301EnableHWARGBCursor310() + } + } else { + sis310EnableHWCursor() + if(pSiS->VBFlags & CRT2_ENABLE) { + sis301EnableHWCursor310() + } + } + } #ifdef SISDUALHEAD } #endif @@ -311,7 +301,7 @@ static void SiSSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) { SISPtr pSiS = SISPTR(pScrn); - DisplayModePtr mode = pSiS->CurrentLayout.mode; /* pScrn->currentMode; */ + DisplayModePtr mode = pSiS->CurrentLayout.mode; unsigned char x_preset = 0; unsigned char y_preset = 0; int temp; @@ -323,14 +313,14 @@ SiSSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - if (x < 0) { - x_preset = (-x); - x = 0; + if(x < 0) { + x_preset = (-x); + x = 0; } - if (y < 0) { - y_preset = (-y); - y = 0; + if(y < 0) { + y_preset = (-y); + y = 0; } if(mode->Flags & V_INTERLACE) y /= 2; @@ -376,24 +366,24 @@ SiSSetCursorPositionMerged(ScrnInfoPtr pScrn1, int x, int y) if((pSiS->VGAEngine == SIS_300_VGA) && (pSiS->UseHWARGBCursor)) maxpreset = 31; if(x1 < 0) { - x1_preset = (-x1); - if(x1_preset > maxpreset) x1_preset = maxpreset; - x1 = 0; + x1_preset = (-x1); + if(x1_preset > maxpreset) x1_preset = maxpreset; + x1 = 0; } if(y1 < 0) { - y1_preset = (-y1); - if(y1_preset > maxpreset) y1_preset = maxpreset; - y1 = 0; + y1_preset = (-y1); + if(y1_preset > maxpreset) y1_preset = maxpreset; + y1 = 0; } if(x2 < 0) { - x2_preset = (-x2); - if(x2_preset > maxpreset) x2_preset = maxpreset; - x2 = 0; + x2_preset = (-x2); + if(x2_preset > maxpreset) x2_preset = maxpreset; + x2 = 0; } if(y2 < 0) { - y2_preset = (-y2); - if(y2_preset > maxpreset) y2_preset = maxpreset; - y2 = 0; + y2_preset = (-y2); + if(y2_preset > maxpreset) y2_preset = maxpreset; + y2 = 0; } if(mode1->Flags & V_INTERLACE) { y1 /= 2; y1_preset /= 2; } @@ -402,6 +392,10 @@ SiSSetCursorPositionMerged(ScrnInfoPtr pScrn1, int x, int y) if(mode2->Flags & V_INTERLACE) { y2 /= 2; y2_preset /= 2; } else if(mode2->Flags & V_DBLSCAN) { y2 *= 2; y2_preset *= 2; } + /* Work around bug in Cursor engine */ + if(x1 > mode1->HDisplay) { y1 = 2000; y1_preset = 0; } + if(x2 > mode2->HDisplay) { y2 = 2000; y2_preset = 0; } + if(pSiS->VGAEngine == SIS_300_VGA) { sis300SetCursorPositionX(x1, x1_preset) sis300SetCursorPositionY(y1, y1_preset) @@ -410,13 +404,8 @@ SiSSetCursorPositionMerged(ScrnInfoPtr pScrn1, int x, int y) } else { sis310SetCursorPositionX(x1, x1_preset) sis310SetCursorPositionY(y1, y1_preset) - if(pSiS->ChipFlags & SiSCF_XabreCore) { - sis301SetCursorPositionX330(x2 + 17, x2_preset) - sis301SetCursorPositionY330(y2, y2_preset) - } else { - sis301SetCursorPositionX310(x2 + 17, x2_preset) - sis301SetCursorPositionY310(y2, y2_preset) - } + sis301SetCursorPositionX310(x2 + 17, x2_preset) + sis301SetCursorPositionY310(y2, y2_preset) } } #endif @@ -436,13 +425,13 @@ SiS300SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) } #endif - if (x < 0) { - x_preset = (-x); - x = 0; + if(x < 0) { + x_preset = (-x); + x = 0; } - if (y < 0) { - y_preset = (-y); - y = 0; + if(y < 0) { + y_preset = (-y); + y = 0; } if(mode->Flags & V_INTERLACE) y /= 2; @@ -450,23 +439,23 @@ SiS300SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { - if(pSiS->SecondHead) { - /* TW: Head 2 is always CRT1 */ - sis300SetCursorPositionX(x, x_preset) - sis300SetCursorPositionY(y, y_preset) - } else { - /* TW: Head 1 is always CRT2 */ - sis301SetCursorPositionX(x + 13, x_preset) - sis301SetCursorPositionY(y, y_preset) - } + if(pSiS->SecondHead) { + /* Head 2 is always CRT1 */ + sis300SetCursorPositionX(x, x_preset) + sis300SetCursorPositionY(y, y_preset) + } else { + /* Head 1 is always CRT2 */ + sis301SetCursorPositionX(x + 13, x_preset) + sis301SetCursorPositionY(y, y_preset) + } } else { #endif - sis300SetCursorPositionX(x, x_preset) - sis300SetCursorPositionY(y, y_preset) - if(pSiS->VBFlags & CRT2_ENABLE) { - sis301SetCursorPositionX(x + 13, x_preset) - sis301SetCursorPositionY(y, y_preset) - } + sis300SetCursorPositionX(x, x_preset) + sis300SetCursorPositionY(y, y_preset) + if(pSiS->VBFlags & CRT2_ENABLE) { + sis301SetCursorPositionX(x + 13, x_preset) + sis301SetCursorPositionY(y, y_preset) + } #ifdef SISDUALHEAD } #endif @@ -487,13 +476,13 @@ SiS310SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) } #endif - if (x < 0) { - x_preset = (-x); - x = 0; + if(x < 0) { + x_preset = (-x); + x = 0; } - if (y < 0) { - y_preset = (-y); - y = 0; + if(y < 0) { + y_preset = (-y); + y = 0; } if(mode->Flags & V_INTERLACE) y /= 2; @@ -501,32 +490,22 @@ SiS310SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { - if(pSiS->SecondHead) { - /* TW: Head 2 is always CRT1 */ - sis310SetCursorPositionX(x, x_preset) - sis310SetCursorPositionY(y, y_preset) - } else { - /* TW: Head 1 is always CRT2 */ - if(pSiS->ChipFlags & SiSCF_XabreCore) { - sis301SetCursorPositionX330(x + 17, x_preset) - sis301SetCursorPositionY330(y, y_preset) - } else { - sis301SetCursorPositionX310(x + 17, x_preset) - sis301SetCursorPositionY310(y, y_preset) - } - } + if(pSiS->SecondHead) { + /* Head 2 is always CRT1 */ + sis310SetCursorPositionX(x, x_preset) + sis310SetCursorPositionY(y, y_preset) + } else { + /* Head 1 is always CRT2 */ + sis301SetCursorPositionX310(x + 17, x_preset) + sis301SetCursorPositionY310(y, y_preset) + } } else { #endif sis310SetCursorPositionX(x, x_preset) sis310SetCursorPositionY(y, y_preset) if(pSiS->VBFlags & CRT2_ENABLE) { - if(pSiS->ChipFlags & SiSCF_XabreCore) { - sis301SetCursorPositionX330(x + 17, x_preset) - sis301SetCursorPositionY330(y, y_preset) - } else { - sis301SetCursorPositionX310(x + 17, x_preset) - sis301SetCursorPositionY310(y, y_preset) - } + sis301SetCursorPositionX310(x + 17, x_preset) + sis301SetCursorPositionY310(y, y_preset) } #ifdef SISDUALHEAD } @@ -574,23 +553,23 @@ SiS300SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { - if(pSiS->SecondHead) { - /* TW: Head 2 is always CRT1 */ - sis300SetCursorBGColor(bg) - sis300SetCursorFGColor(fg) - } else { - /* TW: Head 1 is always CRT2 */ - sis301SetCursorBGColor(bg) - sis301SetCursorFGColor(fg) - } + if(pSiS->SecondHead) { + /* Head 2 is always CRT1 */ + sis300SetCursorBGColor(bg) + sis300SetCursorFGColor(fg) + } else { + /* Head 1 is always CRT2 */ + sis301SetCursorBGColor(bg) + sis301SetCursorFGColor(fg) + } } else { #endif - sis300SetCursorBGColor(bg) - sis300SetCursorFGColor(fg) - if(pSiS->VBFlags & CRT2_ENABLE) { - sis301SetCursorBGColor(bg) - sis301SetCursorFGColor(fg) - } + sis300SetCursorBGColor(bg) + sis300SetCursorFGColor(fg) + if(pSiS->VBFlags & CRT2_ENABLE) { + sis301SetCursorBGColor(bg) + sis301SetCursorFGColor(fg) + } #ifdef SISDUALHEAD } #endif @@ -606,39 +585,39 @@ SiS310SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { if(pSiS->SecondHead) { - /* TW: Head 2 is always CRT1 */ - sis310SetCursorBGColor(bg) - sis310SetCursorFGColor(fg) + /* Head 2 is always CRT1 */ + sis310SetCursorBGColor(bg) + sis310SetCursorFGColor(fg) } else { - /* TW: Head 1 is always CRT2 */ - if(pSiS->ChipFlags & SiSCF_XabreCore) { - if((fg != pSiS->CurFGCol) || (bg != pSiS->CurBGCol)) { - pSiS->CurFGCol = fg; - pSiS->CurBGCol = bg; - SiSXConvertMono2ARGB(pSiS); - } - } else { - sis301SetCursorBGColor310(bg) - sis301SetCursorFGColor310(fg) - } - } - } else { -#endif - sis310SetCursorBGColor(bg) - sis310SetCursorFGColor(fg) - - if(pSiS->VBFlags & CRT2_ENABLE) { - if(pSiS->ChipFlags & SiSCF_XabreCore) { + /* Head 1 is always CRT2 */ + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { if((fg != pSiS->CurFGCol) || (bg != pSiS->CurBGCol)) { - pSiS->CurFGCol = fg; - pSiS->CurBGCol = bg; - SiSXConvertMono2ARGB(pSiS); + pSiS->CurFGCol = fg; + pSiS->CurBGCol = bg; + SiSXConvertMono2ARGB(pSiS); } } else { sis301SetCursorBGColor310(bg) sis301SetCursorFGColor310(fg) } - } + } + } else { +#endif + sis310SetCursorBGColor(bg) + sis310SetCursorFGColor(fg) + + if(pSiS->VBFlags & CRT2_ENABLE) { + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + if((fg != pSiS->CurFGCol) || (bg != pSiS->CurBGCol)) { + pSiS->CurFGCol = fg; + pSiS->CurBGCol = bg; + SiSXConvertMono2ARGB(pSiS); + } + } else { + sis301SetCursorBGColor310(bg) + sis301SetCursorFGColor310(fg) + } + } #ifdef SISDUALHEAD } #endif @@ -738,35 +717,33 @@ SiS300LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) } if(pSiS->UseHWARGBCursor) { - if(pSiS->VBFlags & DISPTYPE_CRT1) { - status1 = sis300GetCursorStatus; - sis300DisableHWCursor() - if(pSiS->VBFlags & CRT2_ENABLE) { - status2 = sis301GetCursorStatus; - sis301DisableHWCursor() - } - SISWaitRetraceCRT1(pScrn); - sis300SwitchToMONOCursor(); - if(pSiS->VBFlags & CRT2_ENABLE) { - SISWaitRetraceCRT2(pScrn); - sis301SwitchToMONOCursor(); - } - } + if(pSiS->VBFlags & DISPTYPE_CRT1) { + status1 = sis300GetCursorStatus; + sis300DisableHWCursor() + if(pSiS->VBFlags & CRT2_ENABLE) { + status2 = sis301GetCursorStatus; + sis301DisableHWCursor() + } + SISWaitRetraceCRT1(pScrn); + sis300SwitchToMONOCursor(); + if(pSiS->VBFlags & CRT2_ENABLE) { + SISWaitRetraceCRT2(pScrn); + sis301SwitchToMONOCursor(); + } + } } sis300SetCursorAddress(cursor_addr); - sis300SetCursorPatternSelect(0); if(status1) sis300SetCursorStatus(status1) if(pSiS->VBFlags & CRT2_ENABLE) { - if((pSiS->UseHWARGBCursor) && (!pSiS->VBFlags & DISPTYPE_CRT1)) { - status2 = sis301GetCursorStatus; - sis301DisableHWCursor() - SISWaitRetraceCRT2(pScrn); - sis301SwitchToMONOCursor(); - } - sis301SetCursorAddress(cursor_addr) - sis301SetCursorPatternSelect(0) - if(status2) sis301SetCursorStatus(status2) + if((pSiS->UseHWARGBCursor) && (!pSiS->VBFlags & DISPTYPE_CRT1)) { + status2 = sis301GetCursorStatus; + sis301DisableHWCursor() + SISWaitRetraceCRT2(pScrn); + sis301SwitchToMONOCursor(); + } + sis301SetCursorAddress(cursor_addr) + if(status2) sis301SetCursorStatus(status2) } pSiS->UseHWARGBCursor = FALSE; @@ -780,8 +757,19 @@ SiS310LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) CARD32 status1 = 0, status2 = 0; unsigned char *dest = pSiS->FbBase; BOOLEAN sizedouble = FALSE; + int bufnum; #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; + + if(pSiS->DualHeadMode) { + pSiSEnt->HWCursorMBufNum ^= 1; + bufnum = 1 << pSiSEnt->HWCursorMBufNum; + } else { +#endif + pSiS->HWCursorMBufNum ^= 1; + bufnum = 1 << pSiS->HWCursorMBufNum; +#ifdef SISDUALHEAD + } #endif #ifdef SISMERGED @@ -795,13 +783,17 @@ SiS310LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) sizedouble = TRUE; } - cursor_addr = pScrn->videoRam - pSiS->cursorOffset - (pSiS->CursorSize/1024); /* 1K boundary */ - #ifdef SISDUALHEAD - /* TW: Use the global (real) FbBase in DHM */ + /* Use the global (real) FbBase in DHM */ if(pSiS->DualHeadMode) dest = pSiSEnt->FbBase; #endif + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + cursor_addr = pScrn->videoRam - pSiS->cursorOffset - (pSiS->CursorSize/1024); + } else { + cursor_addr = pScrn->videoRam - pSiS->cursorOffset - ((pSiS->CursorSize/1024) * bufnum); + } + if(sizedouble) { int i; for(i = 0; i < 32; i++) { @@ -814,7 +806,7 @@ SiS310LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) memcpy((unsigned char *)dest + (cursor_addr * 1024), src, 1024); } - if(pSiS->ChipFlags & SiSCF_XabreCore) { + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { /* Convert Mono image to color image */ @@ -826,46 +818,44 @@ SiS310LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) SiSXConvertMono2ARGB(pSiS); if(pSiS->UseHWARGBCursor) { - if(pSiS->VBFlags & DISPTYPE_CRT1) { - status1 = sis310GetCursorStatus; - sis310DisableHWCursor(); - SISWaitRetraceCRT1(pScrn); - sis310SwitchToMONOCursor(); - } - } + if(pSiS->VBFlags & DISPTYPE_CRT1) { + status1 = sis310GetCursorStatus; + sis310DisableHWCursor(); + SISWaitRetraceCRT1(pScrn); + sis310SwitchToMONOCursor(); + } + } } else { if(pSiS->UseHWARGBCursor) { - if(pSiS->VBFlags & DISPTYPE_CRT1) { - status1 = sis310GetCursorStatus; - sis310DisableHWCursor() - if(pSiS->VBFlags & CRT2_ENABLE) { - status2 = sis301GetCursorStatus310; - sis301DisableHWCursor310() - } - SISWaitRetraceCRT1(pScrn); - sis310SwitchToMONOCursor(); - if(pSiS->VBFlags & CRT2_ENABLE) { - SISWaitRetraceCRT2(pScrn); - sis301SwitchToMONOCursor310(); - } - } - } else if(pSiS->Chipset == PCI_CHIP_SIS315H) { - if(pSiS->VBFlags & DISPTYPE_CRT1) { - SISWaitRetraceCRT1(pScrn); - } - } + if(pSiS->VBFlags & DISPTYPE_CRT1) { + status1 = sis310GetCursorStatus; + sis310DisableHWCursor() + if(pSiS->VBFlags & CRT2_ENABLE) { + status2 = sis301GetCursorStatus310; + sis301DisableHWCursor310() + } + SISWaitRetraceCRT1(pScrn); + sis310SwitchToMONOCursor(); + if(pSiS->VBFlags & CRT2_ENABLE) { + SISWaitRetraceCRT2(pScrn); + sis301SwitchToMONOCursor310(); + } + } + } else if(pSiS->Chipset == PCI_CHIP_SIS315H) { + if(pSiS->VBFlags & DISPTYPE_CRT1) { + SISWaitRetraceCRT1(pScrn); + } + } } sis310SetCursorAddress(cursor_addr); - sis310SetCursorPatternSelect(0); if(status1) sis310SetCursorStatus(status1) if(pSiS->VBFlags & CRT2_ENABLE) { - if(pSiS->ChipFlags & SiSCF_XabreCore) { - sis301SetCursorAddress330(cursor_addr2) - sis301SetCursorPatternSelect330(0) + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + sis301SetCursorAddress310(cursor_addr2) } else { if((pSiS->UseHWARGBCursor) && (!pSiS->VBFlags & DISPTYPE_CRT1)) { status2 = sis301GetCursorStatus310; @@ -874,7 +864,6 @@ SiS310LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) sis301SwitchToMONOCursor310(); } sis301SetCursorAddress310(cursor_addr) - sis301SetCursorPatternSelect310(0) if(status2) sis301SetCursorStatus310(status2) } } @@ -887,15 +876,15 @@ SiSUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; SISPtr pSiS = SISPTR(pScrn); - DisplayModePtr mode = pSiS->CurrentLayout.mode; /* pScrn->currentMode; */ - + DisplayModePtr mode = pSiS->CurrentLayout.mode; + if(pSiS->Chipset != PCI_CHIP_SIS6326) return TRUE; if(!(pSiS->SiS6326Flags & SIS6326_TVDETECTED)) return TRUE; if((strcmp(mode->name, "PAL800x600U") == 0) || (strcmp(mode->name, "NTSC640x480U") == 0)) - return FALSE; + return FALSE; else - return TRUE; + return TRUE; } static Bool @@ -903,7 +892,7 @@ SiS300UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; SISPtr pSiS = SISPTR(pScrn); - DisplayModePtr mode = pSiS->CurrentLayout.mode; /* pScrn->currentMode; */ + DisplayModePtr mode = pSiS->CurrentLayout.mode; #ifdef SISMERGED DisplayModePtr mode2 = NULL; @@ -918,9 +907,9 @@ SiS300UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) case PCI_CHIP_SIS630: case PCI_CHIP_SIS540: if(mode->Flags & V_INTERLACE) - return FALSE; + return FALSE; if((mode->Flags & V_DBLSCAN) && (pCurs->bits->height > 32)) - return FALSE; + return FALSE; #ifdef SISMERGED if(pSiS->MergedFB) { if(mode2->Flags & V_INTERLACE) @@ -930,17 +919,18 @@ SiS300UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) } #endif break; - case PCI_CHIP_SIS550: - case PCI_CHIP_SIS650: case PCI_CHIP_SIS315: case PCI_CHIP_SIS315H: case PCI_CHIP_SIS315PRO: + case PCI_CHIP_SIS550: + case PCI_CHIP_SIS650: case PCI_CHIP_SIS330: case PCI_CHIP_SIS660: + case PCI_CHIP_SIS340: if(mode->Flags & V_INTERLACE) - return FALSE; + return FALSE; if((mode->Flags & V_DBLSCAN) && (pCurs->bits->height > 32)) - return FALSE; + return FALSE; #ifdef SISMERGED if(pSiS->MergedFB) { if(mode2->Flags & V_INTERLACE) @@ -949,23 +939,12 @@ SiS300UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) return FALSE; } #endif - if(pSiS->Chipset == PCI_CHIP_SIS330) { - if((pSiS->VBFlags & CRT2_TV) && - (pSiS->VBFlags & (TV_NTSC|TV_PALM))) { -#ifdef SISMERGED - if(pSiS->MergedFB) { - if(mode2->HDisplay == 1024) return FALSE; - } else -#endif - if(mode->HDisplay == 1024) return FALSE; - } - } break; default: if(mode->Flags & V_INTERLACE) - return FALSE; + return FALSE; if((mode->Flags & V_DBLSCAN) && (pCurs->bits->height > 32)) - return FALSE; + return FALSE; break; } return TRUE; @@ -979,7 +958,7 @@ SiSUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; SISPtr pSiS = SISPTR(pScrn); - DisplayModePtr mode = pSiS->CurrentLayout.mode; /* pScrn->currentMode; */ + DisplayModePtr mode = pSiS->CurrentLayout.mode; #ifdef SISMERGED DisplayModePtr mode2 = NULL; @@ -994,11 +973,11 @@ SiSUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs) case PCI_CHIP_SIS630: case PCI_CHIP_SIS540: if(mode->Flags & V_INTERLACE) - return FALSE; - if(pCurs->bits->height > 32 || pCurs->bits->width > 32) - return FALSE; + return FALSE; + if((pCurs->bits->height > 32) || (pCurs->bits->width > 32)) + return FALSE; if((mode->Flags & V_DBLSCAN) && (pCurs->bits->height > 16)) - return FALSE; + return FALSE; #ifdef SISMERGED if(pSiS->MergedFB) { if(mode2->Flags & V_INTERLACE) @@ -1015,14 +994,15 @@ SiSUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs) case PCI_CHIP_SIS315PRO: case PCI_CHIP_SIS330: case PCI_CHIP_SIS660: + case PCI_CHIP_SIS340: if(mode->Flags & V_INTERLACE) - return FALSE; - if(pCurs->bits->height > 64 || pCurs->bits->width > 64) - return FALSE; + return FALSE; + if((pCurs->bits->height > 64) || (pCurs->bits->width > 64)) + return FALSE; if((mode->Flags & V_DBLSCAN) && (pCurs->bits->height > 32)) - return FALSE; + return FALSE; if((pSiS->CurrentLayout.bitsPerPixel == 8) && (pSiS->VBFlags & CRT2_ENABLE)) - return FALSE; + return FALSE; #ifdef SISMERGED if(pSiS->MergedFB) { if(mode2->Flags & V_INTERLACE) @@ -1031,20 +1011,8 @@ SiSUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs) return FALSE; } #endif - if(pSiS->Chipset == PCI_CHIP_SIS330) { - if((pSiS->VBFlags & VB_SISBRIDGE) && - (pSiS->VBFlags & CRT2_TV) && - (pSiS->VBFlags & (TV_NTSC|TV_PALM))) { -#ifdef SISMERGED - if(pSiS->MergedFB) { - if(mode2->HDisplay == 1024) return FALSE; - } else -#endif - if(mode->HDisplay == 1024) return FALSE; - } - } break; - default: + default: return FALSE; } return TRUE; @@ -1096,10 +1064,10 @@ static void SiS300LoadCursorImageARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) dest = (MYSISPTRTYPE *)((unsigned char *)pSiS->FbBase + (cursor_addr * 1024)); if(sizedouble) { - if(srcheight > 16) srcheight = 16; - maxheight = 16; + if(srcheight > 16) srcheight = 16; + maxheight = 16; } - + #ifdef SIS300_USE_ARGB16 /* Use 16 Bit RGB pointer */ for(i = 0; i < srcheight; i++) { p = src; @@ -1179,35 +1147,34 @@ static void SiS300LoadCursorImageARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) #endif if(!pSiS->UseHWARGBCursor) { - if(pSiS->VBFlags & DISPTYPE_CRT1) { - status1 = sis300GetCursorStatus; - sis300DisableHWCursor() - if(pSiS->VBFlags & CRT2_ENABLE) { - status2 = sis301GetCursorStatus; - sis301DisableHWCursor() - } - SISWaitRetraceCRT1(pScrn); - sis300SwitchToRGBCursor(); - if(pSiS->VBFlags & CRT2_ENABLE) { - SISWaitRetraceCRT2(pScrn); - sis301SwitchToRGBCursor(); - } - } + if(pSiS->VBFlags & DISPTYPE_CRT1) { + status1 = sis300GetCursorStatus; + sis300DisableHWCursor() + if(pSiS->VBFlags & CRT2_ENABLE) { + status2 = sis301GetCursorStatus; + sis301DisableHWCursor() + } + SISWaitRetraceCRT1(pScrn); + sis300SwitchToRGBCursor(); + if(pSiS->VBFlags & CRT2_ENABLE) { + SISWaitRetraceCRT2(pScrn); + sis301SwitchToRGBCursor(); + } + } } + sis300SetCursorAddress(cursor_addr); - sis300SetCursorPatternSelect(0); if(status1) sis300SetCursorStatus(status1) - if(pSiS->VBFlags & CRT2_ENABLE) { - if((!pSiS->UseHWARGBCursor) && (!pSiS->VBFlags & DISPTYPE_CRT1)) { - status2 = sis301GetCursorStatus; - sis301DisableHWCursor() - SISWaitRetraceCRT2(pScrn); - sis301SwitchToRGBCursor(); - } - sis301SetCursorAddress(cursor_addr) - sis301SetCursorPatternSelect(0) - if(status2) sis301SetCursorStatus(status2) + if(pSiS->VBFlags & CRT2_ENABLE) { + if((!pSiS->UseHWARGBCursor) && (!pSiS->VBFlags & DISPTYPE_CRT1)) { + status2 = sis301GetCursorStatus; + sis301DisableHWCursor() + SISWaitRetraceCRT2(pScrn); + sis301SwitchToRGBCursor(); + } + sis301SetCursorAddress(cursor_addr) + if(status2) sis301SetCursorStatus(status2) } pSiS->UseHWARGBCursor = TRUE; @@ -1222,6 +1189,7 @@ static void SiS310LoadCursorImageARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) int srcheight = pCurs->bits->height; CARD32 status1 = 0, status2 = 0; BOOLEAN sizedouble = FALSE; + int bufnum; #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; #endif @@ -1237,47 +1205,64 @@ static void SiS310LoadCursorImageARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) sizedouble = TRUE; } - cursor_addr = pScrn->videoRam - pSiS->cursorOffset - ((pSiS->CursorSize/1024) * 2); +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + pSiSEnt->HWCursorCBufNum ^= 1; + bufnum = 1 << pSiSEnt->HWCursorCBufNum; + } else { +#endif + pSiS->HWCursorCBufNum ^= 1; + bufnum = 1 << pSiS->HWCursorCBufNum; +#ifdef SISDUALHEAD + } +#endif + + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + cursor_addr = pScrn->videoRam - pSiS->cursorOffset - ((pSiS->CursorSize/1024) * 2); + } else { + cursor_addr = pScrn->videoRam - pSiS->cursorOffset - ((pSiS->CursorSize/1024) * (2 + bufnum)); + } if(srcwidth > 64) srcwidth = 64; if(srcheight > 64) srcheight = 64; #ifdef SISDUALHEAD if(pSiS->DualHeadMode) - /* TW: Use the global (real) FbBase in DHM */ - dest = (CARD32 *)((unsigned char *)pSiSEnt->FbBase + (cursor_addr * 1024)); + /* Use the global (real) FbBase in DHM */ + dest = (CARD32 *)((unsigned char *)pSiSEnt->FbBase + (cursor_addr * 1024)); else #endif - dest = (CARD32 *)((unsigned char *)pSiS->FbBase + (cursor_addr * 1024)); + dest = (CARD32 *)((unsigned char *)pSiS->FbBase + (cursor_addr * 1024)); if(sizedouble) { - if(srcheight > 32) srcheight = 32; - maxheight = 32; + if(srcheight > 32) srcheight = 32; + maxheight = 32; } for(i = 0; i < srcheight; i++) { - p = src; - pb = dest; - src += pCurs->bits->width; - for(j = 0; j < srcwidth; j++) *dest++ = *p++; - if(srcwidth < 64) { - for(; j < 64; j++) *dest++ = 0; - } - if(sizedouble) { - for(j = 0; j < 64; j++) { - *dest++ = *pb++; - } - } + p = src; + pb = dest; + src += pCurs->bits->width; + for(j = 0; j < srcwidth; j++) *dest++ = *p++; + if(srcwidth < 64) { + for(; j < 64; j++) *dest++ = 0; + } + if(sizedouble) { + for(j = 0; j < 64; j++) { + *dest++ = *pb++; + } + } } if(srcheight < maxheight) { - for(; i < maxheight; i++) - for(j = 0; j < 64; j++) *dest++ = 0; - if(sizedouble) { - for(j = 0; j < 64; j++) *dest++ = 0; - } + for(; i < maxheight; i++) { + for(j = 0; j < 64; j++) *dest++ = 0; + if(sizedouble) { + for(j = 0; j < 64; j++) *dest++ = 0; + } + } } - if(pSiS->ChipFlags & SiSCF_XabreCore) { + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { if(!pSiS->UseHWARGBCursor) { if(pSiS->VBFlags & DISPTYPE_CRT1) { @@ -1309,13 +1294,11 @@ static void SiS310LoadCursorImageARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) } sis310SetCursorAddress(cursor_addr); - sis310SetCursorPatternSelect(0); if(status1) sis310SetCursorStatus(status1) if(pSiS->VBFlags & CRT2_ENABLE) { - if(pSiS->ChipFlags & SiSCF_XabreCore) { - sis301SetCursorAddress330(cursor_addr) - sis301SetCursorPatternSelect330(0) + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + sis301SetCursorAddress310(cursor_addr) } else { if((!pSiS->UseHWARGBCursor) && (!pSiS->VBFlags & DISPTYPE_CRT1)) { status2 = sis301GetCursorStatus310; @@ -1324,7 +1307,6 @@ static void SiS310LoadCursorImageARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) sis301SwitchToRGBCursor310(); } sis301SetCursorAddress310(cursor_addr) - sis301SetCursorPatternSelect310(0) if(status2) sis301SetCursorStatus310(status2) } } @@ -1387,7 +1369,8 @@ SiSHWCursorInit(ScreenPtr pScreen) case PCI_CHIP_SIS315PRO: case PCI_CHIP_SIS330: case PCI_CHIP_SIS660: - infoPtr->MaxWidth = 64; + case PCI_CHIP_SIS340: + infoPtr->MaxWidth = 64; infoPtr->MaxHeight = 64; infoPtr->ShowCursor = SiS310ShowCursor; infoPtr->HideCursor = SiS310HideCursor; diff --git a/src/sis_cursor.h b/src/sis_cursor.h index 4d62cf3..3046b05 100644 --- a/src/sis_cursor.h +++ b/src/sis_cursor.h @@ -1,38 +1,40 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.h,v 1.9 2003/06/26 22:35:17 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * SiS hardware cursor handling * Definitions * - * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria. * - * 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 holders not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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 + * + * Idea based on code by Can-Ru Yeou, SiS Inc. * - * Authors: Alan Hourihane, alanh@fairlite.demon.co.uk - * Mike Chapman , - * Juanjo Santamarta , - * Mitani Hiroshi - * David Thomas . - * Thomas Winischhofer : */ -#define CS(x) (0x8500+(x<<2)) +#define CS(x) (0x8500 + (x << 2)) /* 300 series, CRT1 */ @@ -118,20 +120,11 @@ { \ unsigned long temp; \ temp = MMIO_IN32(pSiS->IOBase, CS(0)); \ - temp &= 0xFFFF0000; \ + temp &= 0xF0FF0000; \ temp |= address; \ MMIO_OUT32(pSiS->IOBase,CS(0),temp); \ } -#define sis300SetCursorPatternSelect(pat_id)\ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(0)); \ - temp &= 0xF0FFFFFF; \ - temp |= (pat_id) << 24; \ - MMIO_OUT32(pSiS->IOBase,CS(0),temp); \ - } - /* 300 series, CRT2 */ /* 80000000 = RGB(1) - MONO(0) @@ -216,20 +209,11 @@ { \ unsigned long temp; \ temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0xFFFF0000; \ + temp &= 0xF0FF0000; \ temp |= address; \ MMIO_OUT32(pSiS->IOBase,CS(8),temp); \ } -#define sis301SetCursorPatternSelect(pat_id)\ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0xF0FFFFFF; \ - temp |= (pat_id) << 24; \ - MMIO_OUT32(pSiS->IOBase,CS(8),temp); \ - } - /* 315/330 series CRT1 */ /* 80000000 = RGB(1) - MONO(0) @@ -242,86 +226,69 @@ MMIO_IN32(pSiS->IOBase, CS(0)) & 0x40000000; #define sis310SetCursorStatus(status) \ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(0)); \ - temp &= 0xbfffffff; \ - temp |= status; \ - MMIO_OUT32(pSiS->IOBase, CS(0), temp); \ - } + pSiS->HWCursorBackup[0] &= 0xbfffffff; \ + pSiS->HWCursorBackup[0] |= status; \ + MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \ + MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \ + MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]); #define sis310EnableHWCursor()\ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(0)); \ - temp &= 0x0fffffff; \ - temp |= 0x40000000; \ - MMIO_OUT32(pSiS->IOBase, CS(0), temp); \ - } + pSiS->HWCursorBackup[0] &= 0x0fffffff; \ + pSiS->HWCursorBackup[0] |= 0x40000000; \ + MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \ + MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \ + MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]); #define sis310EnableHWARGBCursor()\ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(0)); \ - temp &= 0x0FFFFFFF; \ - temp |= 0xE0000000; \ - MMIO_OUT32(pSiS->IOBase, CS(0), temp); \ - } + pSiS->HWCursorBackup[0] &= 0x0FFFFFFF; \ + pSiS->HWCursorBackup[0] |= 0xE0000000; \ + MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \ + MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \ + MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]); #define sis310SwitchToMONOCursor() \ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(0)); \ - temp &= 0x4fffffff; \ - MMIO_OUT32(pSiS->IOBase, CS(0), temp); \ - } - + pSiS->HWCursorBackup[0] &= 0x4fffffff; \ + MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \ + MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \ + MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]); + #define sis310SwitchToRGBCursor() \ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(0)); \ - temp &= 0xBFFFFFFF; \ - temp |= 0xA0000000; \ - MMIO_OUT32(pSiS->IOBase, CS(0), temp); \ - } - + pSiS->HWCursorBackup[0] &= 0xBFFFFFFF; \ + pSiS->HWCursorBackup[0] |= 0xA0000000; \ + MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \ + MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \ + MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]); + #define sis310DisableHWCursor()\ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(0)); \ - temp &= 0xBFFFFFFF; \ - MMIO_OUT32(pSiS->IOBase, CS(0), temp); \ - } + pSiS->HWCursorBackup[0] &= 0xBFFFFFFF; \ + MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \ + MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \ + MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]); #define sis310SetCursorBGColor(color) \ - MMIO_OUT32(pSiS->IOBase, CS(1), (color)); + MMIO_OUT32(pSiS->IOBase, CS(1), (color)); \ + pSiS->HWCursorBackup[1] = color; #define sis310SetCursorFGColor(color)\ - MMIO_OUT32(pSiS->IOBase, CS(2), (color)); + MMIO_OUT32(pSiS->IOBase, CS(2), (color)); \ + pSiS->HWCursorBackup[2] = color; -#define sis310SetCursorPositionX(x,preset)\ - MMIO_OUT32(pSiS->IOBase, CS(3), ((x) | ((preset) << 16))); +#define sis310SetCursorPositionX(x,preset) \ + pSiS->HWCursorBackup[3] = ((x) | ((preset) << 16)); \ + MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); -#define sis310SetCursorPositionY(y,preset)\ - MMIO_OUT32(pSiS->IOBase, CS(4), ((y) | ((preset) << 16))); +#define sis310SetCursorPositionY(y,preset) \ + pSiS->HWCursorBackup[4] = ((y) | ((preset) << 16)); \ + MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]); #define sis310SetCursorAddress(address)\ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(0)); \ - temp &= 0xFFF00000; \ - temp |= address; \ - MMIO_OUT32(pSiS->IOBase,CS(0),temp); \ - } - -#define sis310SetCursorPatternSelect(pat_id)\ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(0)); \ - temp &= 0xF0FFFFFF; \ - temp |= (pat_id) << 24; \ - MMIO_OUT32(pSiS->IOBase,CS(0),temp); \ - } + pSiS->HWCursorBackup[0] &= 0xF0F00000; \ + pSiS->HWCursorBackup[0] |= address; \ + MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \ + MMIO_OUT32(pSiS->IOBase, CS(1), pSiS->HWCursorBackup[1]); \ + MMIO_OUT32(pSiS->IOBase, CS(2), pSiS->HWCursorBackup[2]); \ + MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \ + MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]); /* 315 series CRT2 */ @@ -335,78 +302,62 @@ MMIO_IN32(pSiS->IOBase, CS(8)) & 0x40000000; #define sis301SetCursorStatus310(status) \ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0xbfffffff; \ - temp |= status; \ - MMIO_OUT32(pSiS->IOBase, CS(8), temp); \ - } + pSiS->HWCursorBackup[8] &= 0xbfffffff; \ + pSiS->HWCursorBackup[8] |= status; \ + MMIO_OUT32(pSiS->IOBase, CS(8), pSiS->HWCursorBackup[8]); \ + MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \ + MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]); #define sis301EnableHWCursor310()\ - { \ - unsigned long temp, temp1, temp2; \ - temp1 = MMIO_IN32(pSiS->IOBase, CS(11)); \ - temp2 = MMIO_IN32(pSiS->IOBase, CS(12)); \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0x0fffffff; \ - temp |= 0x40000000; \ - MMIO_OUT32(pSiS->IOBase, CS(8), temp); \ - MMIO_OUT32(pSiS->IOBase, CS(11), temp1); \ - MMIO_OUT32(pSiS->IOBase, CS(12), temp2); \ - } + pSiS->HWCursorBackup[8] &= 0x0fffffff; \ + pSiS->HWCursorBackup[8] |= 0x40000000; \ + MMIO_OUT32(pSiS->IOBase, CS(8), pSiS->HWCursorBackup[8]); \ + MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \ + MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]); #define sis301EnableHWARGBCursor310()\ - { \ - unsigned long temp, temp1, temp2; \ - temp1 = MMIO_IN32(pSiS->IOBase, CS(11)); \ - temp2 = MMIO_IN32(pSiS->IOBase, CS(12)); \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0x0FFFFFFF; \ - temp |= 0xE0000000; \ - MMIO_OUT32(pSiS->IOBase, CS(8), temp); \ - MMIO_OUT32(pSiS->IOBase, CS(11), temp1); \ - MMIO_OUT32(pSiS->IOBase, CS(12), temp2); \ - } + pSiS->HWCursorBackup[8] &= 0x0FFFFFFF; \ + pSiS->HWCursorBackup[8] |= 0xE0000000; \ + MMIO_OUT32(pSiS->IOBase, CS(8), pSiS->HWCursorBackup[8]); \ + MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \ + MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]); #define sis301SwitchToRGBCursor310() \ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0xBFFFFFFF; \ - temp |= 0xA0000000; \ - MMIO_OUT32(pSiS->IOBase, CS(8), temp); \ - } + pSiS->HWCursorBackup[8] &= 0xBFFFFFFF; \ + pSiS->HWCursorBackup[8] |= 0xA0000000; \ + MMIO_OUT32(pSiS->IOBase, CS(8), pSiS->HWCursorBackup[8]); \ + MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \ + MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]); #define sis301SwitchToMONOCursor310() \ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0x4fffffff; \ - MMIO_OUT32(pSiS->IOBase, CS(8), temp); \ - } + pSiS->HWCursorBackup[8] &= 0x4fffffff; \ + MMIO_OUT32(pSiS->IOBase, CS(8), pSiS->HWCursorBackup[8]); \ + MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \ + MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]); #define sis301DisableHWCursor310()\ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0xBFFFFFFF; \ - MMIO_OUT32(pSiS->IOBase, CS(8), temp); \ - } + pSiS->HWCursorBackup[8] &= 0xBFFFFFFF; \ + MMIO_OUT32(pSiS->IOBase, CS(8), pSiS->HWCursorBackup[8]); \ + MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \ + MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]); -#define sis301SetCursorBGColor310(color)\ - MMIO_OUT32(pSiS->IOBase, CS(9), (color)); -#define sis301SetCursorFGColor310(color)\ - MMIO_OUT32(pSiS->IOBase, CS(10), (color)); +#define sis301SetCursorBGColor310(color) \ + MMIO_OUT32(pSiS->IOBase, CS(9), (color)); \ + pSiS->HWCursorBackup[9] = color; -#define sis301SetCursorPositionX310(x,preset)\ - MMIO_OUT32(pSiS->IOBase, CS(11), ((x) | ((preset) << 16))); -#define sis301SetCursorPositionY310(y,preset)\ - MMIO_OUT32(pSiS->IOBase, CS(12), ((y) | ((preset) << 16))); +#define sis301SetCursorFGColor310(color) \ + MMIO_OUT32(pSiS->IOBase, CS(10), (color)); \ + pSiS->HWCursorBackup[10] = color; -#define sis301SetCursorAddress310(address)\ - { \ - unsigned long temp; \ +#define sis301SetCursorPositionX310(x,preset) \ + pSiS->HWCursorBackup[11] = ((x) | ((preset) << 16)); \ + MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); + +#define sis301SetCursorPositionY310(y,preset) \ + pSiS->HWCursorBackup[12] = ((y) | ((preset) << 16)); \ + MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]); + +#define sis301SetCursorAddress310(address) \ if(pSiS->sishw_ext.jChipType == SIS_315H) { \ if(address & 0x10000) { \ address &= ~0x10000; \ @@ -415,25 +366,18 @@ andSISIDXREG(SISSR, 0x37, 0x7f); \ } \ } \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0xFFF00000; \ - temp |= address; \ - MMIO_OUT32(pSiS->IOBase,CS(8),temp); \ - } - -#define sis301SetCursorPatternSelect310(pat_id)\ - { \ - unsigned long temp; \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0xF0FFFFFF; \ - temp |= (pat_id) << 24; \ - MMIO_OUT32(pSiS->IOBase,CS(8),temp); \ - } + pSiS->HWCursorBackup[8] &= 0xF0F00000; \ + pSiS->HWCursorBackup[8] |= address; \ + MMIO_OUT32(pSiS->IOBase, CS(8), pSiS->HWCursorBackup[8]); \ + MMIO_OUT32(pSiS->IOBase, CS(9), pSiS->HWCursorBackup[9]); \ + MMIO_OUT32(pSiS->IOBase, CS(10), pSiS->HWCursorBackup[10]); \ + MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \ + MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]); /* 330 series CRT2 */ -/* Mono cursor engine for CRt2 on 330 has bugs and cannot be - * used! +/* Mono cursor engine for CRT2 on SiS330 (Xabre) has bugs + * and cannot be used! Will hang engine. */ /* 80000000 = RGB(1) - MONO(0) @@ -442,65 +386,14 @@ * 10000000 = "ghost"(1) - Alpha Blend(0) ? */ -#define sis301EnableHWCursor330()\ - { \ - unsigned long temp, temp1, temp2; \ - andSISIDXREG(SISCR,0x5b,~0x10); \ - temp1 = MMIO_IN32(pSiS->IOBase, CS(11)); \ - temp2 = MMIO_IN32(pSiS->IOBase, CS(12)); \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0x0fffffff; \ - temp |= 0xE0000000; \ - MMIO_OUT32(pSiS->IOBase, CS(8), temp); \ - MMIO_OUT32(pSiS->IOBase, CS(11), temp1); \ - MMIO_OUT32(pSiS->IOBase, CS(12), temp2); \ - orSISIDXREG(SISCR,0x5b,0x10); \ - } - -#define sis301DisableHWCursor330()\ - { \ - unsigned long temp; \ - andSISIDXREG(SISCR,0x5b,~0x10); \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0xBFFFFFFF; \ - MMIO_OUT32(pSiS->IOBase, CS(8), temp); \ - orSISIDXREG(SISCR,0x5b,0x10); \ - } - -#define sis301SetCursorPositionX330(x,preset)\ - andSISIDXREG(SISCR,0x5b,~0x10); \ - MMIO_OUT32(pSiS->IOBase, CS(11), ((x) | ((preset) << 16))); \ - orSISIDXREG(SISCR,0x5b,0x10); - -#define sis301SetCursorPositionY330(y,preset)\ - andSISIDXREG(SISCR,0x5b,~0x10); \ - MMIO_OUT32(pSiS->IOBase, CS(12), ((y) | ((preset) << 16))); \ - orSISIDXREG(SISCR,0x5b,0x10); \ - -#define sis301SetCursorAddress330(address)\ - { \ - unsigned long temp, temp1, temp2; \ - temp1 = MMIO_IN32(pSiS->IOBase, CS(11)); \ - temp2 = MMIO_IN32(pSiS->IOBase, CS(12)); \ - andSISIDXREG(SISCR,0x5b,~0x10); \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0xFFF00000; \ - temp |= address; \ - MMIO_OUT32(pSiS->IOBase,CS(8),temp); \ - MMIO_OUT32(pSiS->IOBase, CS(11), temp1); \ - MMIO_OUT32(pSiS->IOBase, CS(12), temp2); \ - orSISIDXREG(SISCR,0x5b,0x10); \ - } +#define sis301EnableHWCursor330() \ + /* andSISIDXREG(SISCR,0x5b,~0x10); */ \ + pSiS->HWCursorBackup[8] &= 0x0fffffff; \ + pSiS->HWCursorBackup[8] |= 0xE0000000; \ + MMIO_OUT32(pSiS->IOBase, CS(8), pSiS->HWCursorBackup[8]); \ + MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \ + MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]); \ + /* orSISIDXREG(SISCR,0x5b,0x10); */ -#define sis301SetCursorPatternSelect330(pat_id)\ - { \ - unsigned long temp; \ - andSISIDXREG(SISCR,0x5b,~0x10); \ - temp = MMIO_IN32(pSiS->IOBase, CS(8)); \ - temp &= 0xF0FFFFFF; \ - temp |= (pat_id) << 24; \ - MMIO_OUT32(pSiS->IOBase,CS(8),temp); \ - orSISIDXREG(SISCR,0x5b,0x10); \ - } diff --git a/src/sis_dac.c b/src/sis_dac.c index 78693da..d5e0ca3 100644 --- a/src/sis_dac.c +++ b/src/sis_dac.c @@ -1,36 +1,66 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c,v 1.39 2003/08/26 20:40:23 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * DAC helper functions (Save/Restore, MemClk, etc) * - * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria. - * Parts Copyright 1998,1999 by Alan Hourihane, Wigan, England. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria. + * + * 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) 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 EXPRESSED 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 + * + * -------------------------------------------------------------------------- + * + * SiS_compute_vclk(), SiSCalcClock() and parts of SiSMclk(): + * + * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England + * Written by: + * Alan Hourihane , + * Mike Chapman , + * Juanjo Santamarta , + * Mitani Hiroshi , + * David Thomas , + * Thomas Winischhofer . + * + * Licensed under the following terms: * * 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 provider not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The provider makes no representations + * the above copyright notice appears in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * 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. + * "as is" without expressed or implied warranty. * - * THE PROVIDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE PROVIDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * 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. - * - * Author: Thomas Winischhofer - * - * MemClock functions by: - * Alan Hourihane - * Mike Chapman , - * Juanjo Santamarta , - * Mitani Hiroshi - * David Thomas . */ #include "xf86.h" @@ -61,13 +91,11 @@ static void SiS301BRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg); static void SiSLVDSChrontelRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg); static void SiS301LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, LOCO *colors, VisualPtr pVisual); -static void SiSThreshold(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High); static void SetBlock(CARD16 port, CARD8 from, CARD8 to, CARD8 *DataPtr); static const unsigned short ch700xidx[] = { 0x00,0x07,0x08,0x0a,0x0b,0x04,0x09,0x20,0x21,0x18,0x19,0x1a, - 0x1b,0x1c,0x1d,0x1e,0x1f, /* 0x0e, - TW: Don't save the power register */ + 0x1b,0x1c,0x1d,0x1e,0x1f, /* 0x0e, - Don't save the power register */ 0x01,0x03,0x06,0x0d,0x11,0x13,0x14,0x15,0x17,0x22,0x23,0x24 }; @@ -75,7 +103,7 @@ static const unsigned short ch701xidx[] = { 0x1c,0x5f,0x64,0x6f,0x70,0x71,0x72,0x73,0x74,0x76,0x78,0x7d, 0x67,0x68,0x69,0x6a,0x6b,0x1e,0x00,0x01,0x02,0x04,0x03,0x05, 0x06,0x07,0x08,0x15,0x1f,0x0c,0x0d,0x0e,0x0f,0x10,0x66 - }; + }; int SiS_compute_vclk( int Clock, @@ -188,15 +216,18 @@ SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD, unsigned int *vclk) SISPtr pSiS = SISPTR(pScrn); int M, N, P , PSN, VLD , PSNx ; int bestM=0, bestN=0, bestP=0, bestPSN=0, bestVLD=0; - double bestError, abest = 42.0, bestFout; + double abest = 42.0; double target; double Fvco, Fout; double error, aerror; +#ifdef DEBUG + double bestFout; +#endif /* * fd = fref*(Numerator/Denumerator)*(Divider/PostScaler) * - * M = Numerator [1:128] + * M = Numerator [1:128] * N = DeNumerator [1:32] * VLD = Divider (Vco Loop Divider) : divide by 1, 2 * P = Post Scaler : divide by 1, 2, 3, 4 @@ -257,13 +288,14 @@ SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD, unsigned int *vclk) aerror = (error < 0) ? -error : error; if(aerror < abest) { abest = aerror; - bestError = error; bestM = M; bestN = N; bestP = P; bestPSN = PSN; bestVLD = VLD; +#ifdef DEBUG bestFout = Fout; +#endif } } @@ -313,13 +345,14 @@ SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD, unsigned int *vclk) aerror = (error < 0) ? -error : error; if(aerror < abest) { abest = aerror; - bestError = error; bestM = M; bestN = N; bestP = P; bestPSN = PSN; bestVLD = VLD; +#ifdef DEBUG bestFout = Fout; +#endif } #ifdef TWDEBUG xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,3, @@ -380,17 +413,17 @@ SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg) /* Save extended SR registers */ for(i = 0x00; i <= max; i++) { - inSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); + inSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SR%02X - %02X \n", i,sisReg->sisRegs3C4[i]); #endif } #ifdef TWDEBUG for(i = 0x00; i <= 0x3f; i++) { - inSISIDXREG(SISCR, i, max); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + inSISIDXREG(SISCR, i, max); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CR%02X - %02X \n", i,max); } #endif @@ -400,13 +433,13 @@ SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg) sisReg->sisRegs3C2 = inSISREG(SISMISCR); /* Misc */ - /* TW: Save TV registers */ + /* Save TV registers */ if((pSiS->Chipset == PCI_CHIP_SIS6326) && (pSiS->SiS6326Flags & SIS6326_HASTV)) { outSISIDXREG(SISCR, 0x80, 0x86); for(i = 0x00; i <= 0x44; i++) { - sisReg->sis6326tv[i] = SiS6326GetTVReg(pScrn, i); + sisReg->sis6326tv[i] = SiS6326GetTVReg(pScrn, i); #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VR%02X - %02X \n", i,sisReg->sis6326tv[i]); #endif } @@ -449,9 +482,9 @@ SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) } /* Restore other extended SR registers */ - for (i = 0x06; i <= max; i++) { - if((i == 0x13) || (i == 0x2a) || (i == 0x2b)) continue; - outSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); + for(i = 0x06; i <= max; i++) { + if((i == 0x13) || (i == 0x2a) || (i == 0x2b)) continue; + outSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); } /* Now restore VCLK (with correct SR38 setting) */ @@ -467,13 +500,13 @@ SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) usleep(10000); outSISIDXREG(SISSR, 0x00, 0x03); /* End Reset */ - /* TW: Restore TV registers */ + /* Restore TV registers */ pSiS->SiS6326Flags &= ~SIS6326_TVON; if((pSiS->Chipset == PCI_CHIP_SIS6326) && (pSiS->SiS6326Flags & SIS6326_HASTV)) { for(i = 0x01; i <= 0x44; i++) { - SiS6326SetTVReg(pScrn, i, sisReg->sis6326tv[i]); + SiS6326SetTVReg(pScrn, i, sisReg->sis6326tv[i]); #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VR%02x restored to %02x\n", i, sisReg->sis6326tv[i]); #endif @@ -543,12 +576,12 @@ SiS300Save(ScrnInfoPtr pScrn, SISRegPtr sisReg) #ifndef TWDEBUG if(!pSiS->UseVESA) { #endif - if (pSiS->VBFlags & (VB_LVDS|VB_CHRONTEL)) - (*pSiS->SiSSaveLVDSChrontel)(pScrn, sisReg); - if (pSiS->VBFlags & VB_301) - (*pSiS->SiSSave2)(pScrn, sisReg); - if (pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV)) - (*pSiS->SiSSave3)(pScrn, sisReg); + if(pSiS->VBFlags & (VB_LVDS|VB_CHRONTEL)) + (*pSiS->SiSSaveLVDSChrontel)(pScrn, sisReg); + if(pSiS->VBFlags & VB_301) + (*pSiS->SiSSave2)(pScrn, sisReg); + if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)) + (*pSiS->SiSSave3)(pScrn, sisReg); #ifndef TWDEBUG } #endif @@ -557,7 +590,7 @@ SiS300Save(ScrnInfoPtr pScrn, SISRegPtr sisReg) #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,2,99,0,0) if(!(pSiS->UseVESA)) #endif - pSiS->BIOSModeSave = SiS_GetSetModeID(pScrn,0xFF); + pSiS->BIOSModeSave = SiS_GetSetModeID(pScrn,0xFF); #ifdef TWDEBUG xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -581,67 +614,67 @@ SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - /* TW: Wait for accelerator to finish on-going drawing operations. */ + /* Wait for accelerator to finish on-going drawing operations. */ inSISIDXREG(SISSR, 0x1E, temp); if(temp & (0x40|0x10|0x02)) { - while ( (MMIO_IN16(pSiS->IOBase, 0x8242) & 0xE000) != 0xE000){}; - while ( (MMIO_IN16(pSiS->IOBase, 0x8242) & 0xE000) != 0xE000){}; - while ( (MMIO_IN16(pSiS->IOBase, 0x8242) & 0xE000) != 0xE000){}; + while ( (MMIO_IN16(pSiS->IOBase, 0x8242) & 0xE000) != 0xE000){}; + while ( (MMIO_IN16(pSiS->IOBase, 0x8242) & 0xE000) != 0xE000){}; + while ( (MMIO_IN16(pSiS->IOBase, 0x8242) & 0xE000) != 0xE000){}; } - + if(!(pSiS->UseVESA)) { if(pSiS->VBFlags & VB_LVDS) { - SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); - SiS_DisableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); + SiS_DisableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext); } } /* Restore extended CR registers */ for(i = 0x19; i < 0x40; i++) { - outSISIDXREG(SISCR, i, sisReg->sisRegs3D4[i]); + outSISIDXREG(SISCR, i, sisReg->sisRegs3D4[i]); } if(pSiS->Chipset != PCI_CHIP_SIS300) { - unsigned char val; - inSISIDXREG(SISCR, 0x1A, val); - if(val == sisReg->sisRegs3D4[0x19]) - outSISIDXREG(SISCR, 0x1A, sisReg->sisRegs3D4[0x19]); - inSISIDXREG(SISCR,0x19,val); - if(val == sisReg->sisRegs3D4[0x1A]) - outSISIDXREG(SISCR, 0x19, sisReg->sisRegs3D4[0x1A]); + unsigned char val; + inSISIDXREG(SISCR, 0x1A, val); + if(val == sisReg->sisRegs3D4[0x19]) + outSISIDXREG(SISCR, 0x1A, sisReg->sisRegs3D4[0x19]); + inSISIDXREG(SISCR,0x19,val); + if(val == sisReg->sisRegs3D4[0x1A]) + outSISIDXREG(SISCR, 0x19, sisReg->sisRegs3D4[0x1A]); } /* Set (and leave) PCI_IO_ENABLE on if accelerators are on */ if(sisReg->sisRegs3C4[0x1e] & 0x50) { - sisReg->sisRegs3C4[0x20] |= 0x20; - outSISIDXREG(SISSR, 0x20, sisReg->sisRegs3C4[0x20]); + sisReg->sisRegs3C4[0x20] |= 0x20; + outSISIDXREG(SISSR, 0x20, sisReg->sisRegs3C4[0x20]); } - /* TW: If TQ is switched on, don't switch it off ever again! - * Therefore, always restore registers with TQ enabled. + /* If TQ is switched on, don't switch it off ever again! + * Therefore, always restore registers with TQ enabled. */ if((!pSiS->NoAccel) && (pSiS->TurboQueue)) { - temp = (pScrn->videoRam/64) - 8; - sisReg->sisRegs3C4[0x26] = temp & 0xFF; - sisReg->sisRegs3C4[0x27] = ((temp >> 8) & 3) | 0xF0; + temp = (pScrn->videoRam/64) - 8; + sisReg->sisRegs3C4[0x26] = temp & 0xFF; + sisReg->sisRegs3C4[0x27] = ((temp >> 8) & 3) | 0xF0; } /* Restore extended SR registers */ - for (i = 0x06; i <= 0x3D; i++) { - temp = sisReg->sisRegs3C4[i]; - if(!(pSiS->UseVESA)) { - if(pSiS->VBFlags & VB_LVDS) { - if(i == 0x11) { - inSISIDXREG(SISSR,0x11,temp); - temp &= 0x0c; - temp |= (sisReg->sisRegs3C4[i] & 0xf3); - } - } - } - outSISIDXREG(SISSR, i, temp); + for(i = 0x06; i <= 0x3D; i++) { + temp = sisReg->sisRegs3C4[i]; + if(!(pSiS->UseVESA)) { + if(pSiS->VBFlags & VB_LVDS) { + if(i == 0x11) { + inSISIDXREG(SISSR,0x11,temp); + temp &= 0x0c; + temp |= (sisReg->sisRegs3C4[i] & 0xf3); + } + } + } + outSISIDXREG(SISSR, i, temp); } - - /* TW: Restore VCLK and ECLK */ + + /* Restore VCLK and ECLK */ if(pSiS->VBFlags & (VB_LVDS | VB_301B | VB_301C)) { outSISIDXREG(SISSR,0x31,0x20); outSISIDXREG(SISSR,0x2b,sisReg->sisRegs3C4[0x2b]); @@ -667,10 +700,10 @@ SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) outSISIDXREG(SISSR,0x2e,sisReg->sisRegs3C4[0x2e]); outSISIDXREG(SISSR,0x2f,sisReg->sisRegs3C4[0x2f]); } - + /* Restore Misc register */ - outSISREG(SISMISCW, sisReg->sisRegs3C2); - + outSISREG(SISMISCW, sisReg->sisRegs3C2); + /* Restore FQBQ and GUI timer settings */ if(pSiS->Chipset == PCI_CHIP_SIS630) { temp1 = pciReadLong(0x00000000, 0x50); @@ -680,9 +713,9 @@ SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) } else { /* 730 */ temp1 &= 0xfffff9ff; temp1 |= (sisReg->sisRegsPCI50 & ~0xfffff9ff); - } + } pciWriteLong(0x00000000, 0x50, temp1); - + temp1 = pciReadLong(0x00000000, 0xA0); if(pciReadLong(0x00000000, 0x00) == 0x06301039) { temp1 &= 0xf0ffffff; @@ -690,20 +723,20 @@ SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) } else { /* 730 */ temp1 &= 0x00ffffff; temp1 |= (sisReg->sisRegsPCIA0 & ~0x00ffffff); - } + } pciWriteLong(0x00000000, 0xA0, temp1); } /* Restore panel link/video bridge registers */ if(!(pSiS->UseVESA)) { - if(pSiS->VBFlags & (VB_LVDS|VB_CHRONTEL)) - (*pSiS->SiSRestoreLVDSChrontel)(pScrn, sisReg); - if(pSiS->VBFlags & VB_301) - (*pSiS->SiSRestore2)(pScrn, sisReg); - if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV)) - (*pSiS->SiSRestore3)(pScrn, sisReg); + if(pSiS->VBFlags & (VB_LVDS|VB_CHRONTEL)) + (*pSiS->SiSRestoreLVDSChrontel)(pScrn, sisReg); + if(pSiS->VBFlags & VB_301) + (*pSiS->SiSRestore2)(pScrn, sisReg); + if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)) + (*pSiS->SiSRestore3)(pScrn, sisReg); } - + /* MemClock needs this to take effect */ outSISIDXREG(SISSR, 0x00, 0x01); /* Synchronous Reset */ outSISIDXREG(SISSR, 0x00, 0x03); /* End Reset */ @@ -712,7 +745,7 @@ SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,2,99,0,0) if(!(pSiS->UseVESA)) #endif - SiS_GetSetModeID(pScrn,pSiS->BIOSModeSave); + SiS_GetSetModeID(pScrn,pSiS->BIOSModeSave); } /* Save SiS315 series register contents */ @@ -730,10 +763,10 @@ SiS315Save(ScrnInfoPtr pScrn, SISRegPtr sisReg) #endif /* Save SR registers */ - for (i = 0x00; i <= 0x3F; i++) { - inSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); + for(i = 0x00; i <= 0x3F; i++) { + inSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SR%02X - %02X \n", i,sisReg->sisRegs3C4[i]); #endif } @@ -742,45 +775,45 @@ SiS315Save(ScrnInfoPtr pScrn, SISRegPtr sisReg) sisReg->sisMMIO85C0 = MMIO_IN32(pSiS->IOBase, 0x85C0); /* Save CR registers */ - for (i = 0x00; i <= 0x7a; i++) { - inSISIDXREG(SISCR, i, sisReg->sisRegs3D4[i]); + for(i = 0x00; i <= 0x7c; i++) { + inSISIDXREG(SISCR, i, sisReg->sisRegs3D4[i]); #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CR%02X Contents - %02X \n", i,sisReg->sisRegs3D4[i]); #endif } /* Save video capture registers */ - for (i = 0x00; i <= 0x4f; i++) { - inSISIDXREG(SISCAP, i, sisReg->sisCapt[i]); + for(i = 0x00; i <= 0x4f; i++) { + inSISIDXREG(SISCAP, i, sisReg->sisCapt[i]); #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Capt%02X Contents - %02X \n", i,sisReg->sisCapt[i]); #endif } /* Save video playback registers */ - for (i = 0x00; i <= 0x3f; i++) { - inSISIDXREG(SISVID, i, sisReg->sisVid[i]); + for(i = 0x00; i <= 0x3f; i++) { + inSISIDXREG(SISVID, i, sisReg->sisVid[i]); #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Vid%02X Contents - %02X \n", i,sisReg->sisVid[i]); #endif } /* Save Misc register */ - sisReg->sisRegs3C2 = inSISREG(SISMISCR); + sisReg->sisRegs3C2 = inSISREG(SISMISCR); /* Save panel link/video bridge registers */ #ifndef TWDEBUG - if (!pSiS->UseVESA) { + if(!pSiS->UseVESA) { #endif - if (pSiS->VBFlags & (VB_LVDS|VB_CHRONTEL)) - (*pSiS->SiSSaveLVDSChrontel)(pScrn, sisReg); - if (pSiS->VBFlags & VB_301) - (*pSiS->SiSSave2)(pScrn, sisReg); - if (pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV)) - (*pSiS->SiSSave3)(pScrn, sisReg); + if(pSiS->VBFlags & (VB_LVDS|VB_CHRONTEL)) + (*pSiS->SiSSaveLVDSChrontel)(pScrn, sisReg); + if(pSiS->VBFlags & VB_301) + (*pSiS->SiSSave2)(pScrn, sisReg); + if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)) + (*pSiS->SiSSave3)(pScrn, sisReg); #ifndef TWDEBUG } #endif @@ -789,12 +822,12 @@ SiS315Save(ScrnInfoPtr pScrn, SISRegPtr sisReg) #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,2,99,0,0) if(!(pSiS->UseVESA)) #endif - pSiS->BIOSModeSave = SiS_GetSetModeID(pScrn,0xFF); - -#ifdef TWDEBUG + pSiS->BIOSModeSave = SiS_GetSetModeID(pScrn,0xFF); + +#ifdef TWDEBUG xf86DrvMsg(pScrn->scrnIndex, X_INFO, "BIOS mode ds:449 = 0x%x\n", pSiS->BIOSModeSave); -#endif +#endif } /* Restore SiS315/330 series register contents */ @@ -813,10 +846,10 @@ SiS315Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) /* Wait for accelerator to finish on-going drawing operations. */ inSISIDXREG(SISSR, 0x1E, temp); - if (temp & (0x40|0x10|0x02)) { /* 0x40 = 2D, 0x10 = 3D enabled*/ - while ( (MMIO_IN32(pSiS->IOBase, 0x85CC) & 0x80000000) != 0x80000000){}; - while ( (MMIO_IN32(pSiS->IOBase, 0x85CC) & 0x80000000) != 0x80000000){}; - while ( (MMIO_IN32(pSiS->IOBase, 0x85CC) & 0x80000000) != 0x80000000){}; + if(temp & (0x40|0x10|0x02)) { /* 0x40 = 2D, 0x10 = 3D enabled*/ + while ( (MMIO_IN32(pSiS->IOBase, 0x85CC) & 0x80000000) != 0x80000000){}; + while ( (MMIO_IN32(pSiS->IOBase, 0x85CC) & 0x80000000) != 0x80000000){}; + while ( (MMIO_IN32(pSiS->IOBase, 0x85CC) & 0x80000000) != 0x80000000){}; } /* We reset the command queue before restoring. @@ -829,51 +862,56 @@ SiS315Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) outSISIDXREG(SISSR, 0x26, 0x01); /* Restore extended CR registers */ - for (i = 0x19; i < 0x5C; i++) { - outSISIDXREG(SISCR, i, sisReg->sisRegs3D4[i]); + for(i = 0x19; i < 0x5C; i++) { + outSISIDXREG(SISCR, i, sisReg->sisRegs3D4[i]); + } + if(pSiS->sishw_ext.jChipType < SIS_661) { + outSISIDXREG(SISCR, 0x79, sisReg->sisRegs3D4[0x79]); } - outSISIDXREG(SISCR, 0x79, sisReg->sisRegs3D4[0x79]); - outSISIDXREG(SISCR, 0x63, sisReg->sisRegs3D4[0x63]); + outSISIDXREG(SISCR, pSiS->myCR63, sisReg->sisRegs3D4[pSiS->myCR63]); /* Leave PCI_IO_ENABLE on if accelerators are on (Is this required?) */ - if (sisReg->sisRegs3C4[0x1e] & 0x50) { /*0x40=2D, 0x10=3D*/ - sisReg->sisRegs3C4[0x20] |= 0x20; - outSISIDXREG(SISSR, 0x20, sisReg->sisRegs3C4[0x20]); + if(sisReg->sisRegs3C4[0x1e] & 0x50) { /*0x40=2D, 0x10=3D*/ + sisReg->sisRegs3C4[0x20] |= 0x20; + outSISIDXREG(SISSR, 0x20, sisReg->sisRegs3C4[0x20]); } /* Restore extended SR registers */ - for (i = 0x06; i <= 0x3F; i++) { - outSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); + if(pSiS->sishw_ext.jChipType >= SIS_661) { + sisReg->sisRegs3C4[0x11] &= 0x0f; + } + for(i = 0x06; i <= 0x3F; i++) { + outSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); } /* Restore VCLK and ECLK */ andSISIDXREG(SISSR,0x31,0xcf); if(pSiS->VBFlags & VB_LVDS) { - orSISIDXREG(SISSR,0x31,0x20); - outSISIDXREG(SISSR,0x2b,sisReg->sisRegs3C4[0x2b]); - outSISIDXREG(SISSR,0x2c,sisReg->sisRegs3C4[0x2c]); - outSISIDXREG(SISSR,0x2d,0x80); - andSISIDXREG(SISSR,0x31,0xcf); - orSISIDXREG(SISSR,0x31,0x10); - outSISIDXREG(SISSR,0x2b,sisReg->sisRegs3C4[0x2b]); - outSISIDXREG(SISSR,0x2c,sisReg->sisRegs3C4[0x2c]); - outSISIDXREG(SISSR,0x2d,0x80); - andSISIDXREG(SISSR,0x31,0xcf); - outSISIDXREG(SISSR,0x2b,sisReg->sisRegs3C4[0x2b]); - outSISIDXREG(SISSR,0x2c,sisReg->sisRegs3C4[0x2c]); - outSISIDXREG(SISSR,0x2d,0x01); - outSISIDXREG(SISSR,0x31,0x20); - outSISIDXREG(SISSR,0x2e,sisReg->sisRegs3C4[0x2e]); - outSISIDXREG(SISSR,0x2f,sisReg->sisRegs3C4[0x2f]); - outSISIDXREG(SISSR,0x31,0x10); - outSISIDXREG(SISSR,0x2e,sisReg->sisRegs3C4[0x2e]); - outSISIDXREG(SISSR,0x2f,sisReg->sisRegs3C4[0x2f]); - outSISIDXREG(SISSR,0x31,0x00); - outSISIDXREG(SISSR,0x2e,sisReg->sisRegs3C4[0x2e]); - outSISIDXREG(SISSR,0x2f,sisReg->sisRegs3C4[0x2f]); + orSISIDXREG(SISSR,0x31,0x20); + outSISIDXREG(SISSR,0x2b,sisReg->sisRegs3C4[0x2b]); + outSISIDXREG(SISSR,0x2c,sisReg->sisRegs3C4[0x2c]); + outSISIDXREG(SISSR,0x2d,0x80); + andSISIDXREG(SISSR,0x31,0xcf); + orSISIDXREG(SISSR,0x31,0x10); + outSISIDXREG(SISSR,0x2b,sisReg->sisRegs3C4[0x2b]); + outSISIDXREG(SISSR,0x2c,sisReg->sisRegs3C4[0x2c]); + outSISIDXREG(SISSR,0x2d,0x80); + andSISIDXREG(SISSR,0x31,0xcf); + outSISIDXREG(SISSR,0x2b,sisReg->sisRegs3C4[0x2b]); + outSISIDXREG(SISSR,0x2c,sisReg->sisRegs3C4[0x2c]); + outSISIDXREG(SISSR,0x2d,0x01); + outSISIDXREG(SISSR,0x31,0x20); + outSISIDXREG(SISSR,0x2e,sisReg->sisRegs3C4[0x2e]); + outSISIDXREG(SISSR,0x2f,sisReg->sisRegs3C4[0x2f]); + outSISIDXREG(SISSR,0x31,0x10); + outSISIDXREG(SISSR,0x2e,sisReg->sisRegs3C4[0x2e]); + outSISIDXREG(SISSR,0x2f,sisReg->sisRegs3C4[0x2f]); + outSISIDXREG(SISSR,0x31,0x00); + outSISIDXREG(SISSR,0x2e,sisReg->sisRegs3C4[0x2e]); + outSISIDXREG(SISSR,0x2f,sisReg->sisRegs3C4[0x2f]); } else { - outSISIDXREG(SISSR,0x2b,sisReg->sisRegs3C4[0x2b]); - outSISIDXREG(SISSR,0x2c,sisReg->sisRegs3C4[0x2c]); - outSISIDXREG(SISSR,0x2d,0x01); + outSISIDXREG(SISSR,0x2b,sisReg->sisRegs3C4[0x2b]); + outSISIDXREG(SISSR,0x2c,sisReg->sisRegs3C4[0x2c]); + outSISIDXREG(SISSR,0x2d,0x01); } #ifndef SISVRAMQ @@ -888,12 +926,12 @@ SiS315Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) /* Restore panel link/video bridge registers */ if(!(pSiS->UseVESA)) { - if(pSiS->VBFlags & (VB_LVDS|VB_CHRONTEL)) - (*pSiS->SiSRestoreLVDSChrontel)(pScrn, sisReg); - if(pSiS->VBFlags & VB_301) - (*pSiS->SiSRestore2)(pScrn, sisReg); - if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV)) - (*pSiS->SiSRestore3)(pScrn, sisReg); + if(pSiS->VBFlags & (VB_LVDS|VB_CHRONTEL)) + (*pSiS->SiSRestoreLVDSChrontel)(pScrn, sisReg); + if(pSiS->VBFlags & VB_301) + (*pSiS->SiSRestore2)(pScrn, sisReg); + if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)) + (*pSiS->SiSRestore3)(pScrn, sisReg); } /* MemClock needs this to take effect */ @@ -907,56 +945,56 @@ SiS315Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) SiS_GetSetModeID(pScrn,pSiS->BIOSModeSave); } -/* Save SiS301 bridge register contents */ static void -SiS301Save(ScrnInfoPtr pScrn, SISRegPtr sisReg) +SiSVBSave(ScrnInfoPtr pScrn, SISRegPtr sisReg, int p1, int p2, int p3, int p4) { SISPtr pSiS = SISPTR(pScrn); int i; - int Part1max=0, Part2max=0, Part3max=0, Part4max=0; - /* Highest register number to save/restore */ - switch (pSiS->VGAEngine) { - case SIS_300_VGA: - Part1max = 0x1d; - Part2max = 0x45; - Part3max = 0x3e; - Part4max = 0x1b; - break; - case SIS_315_VGA: - Part1max = 0x2e; /* 0x23, but we also need 2d-2e */ - Part2max = 0x45; - Part3max = 0x3e; - Part4max = 0x1b; - break; - } - - for (i=0; i<=Part1max; i++) { - inSISIDXREG(SISPART1, i, sisReg->VBPart1[i]); + for(i=0; i<=p1; i++) { + inSISIDXREG(SISPART1, i, sisReg->VBPart1[i]); #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "301Save: Part1Port 0x%02x = 0x%02x\n", i, sisReg->VBPart1[i]); + xf86DrvMsg(0, X_INFO, "301xSave: Part1Port 0x%02x = 0x%02x\n", i, sisReg->VBPart1[i]); #endif } - for (i=0; i<=Part2max; i++) { - inSISIDXREG(SISPART2, i, sisReg->VBPart2[i]); + for(i=0; i<=p2; i++) { + inSISIDXREG(SISPART2, i, sisReg->VBPart2[i]); #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "301Save: Part2Port 0x%02x = 0x%02x\n", i, sisReg->VBPart2[i]); + xf86DrvMsg(0, X_INFO, "301xSave: Part2Port 0x%02x = 0x%02x\n", i, sisReg->VBPart2[i]); #endif } - for (i=0; i<=Part3max; i++) { - inSISIDXREG(SISPART3, i, sisReg->VBPart3[i]); + for(i=0; i<=p3; i++) { + inSISIDXREG(SISPART3, i, sisReg->VBPart3[i]); #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "301Save: Part3Port 0x%02x = 0x%02x\n", i, sisReg->VBPart3[i]); + xf86DrvMsg(0, X_INFO, "301xSave: Part3Port 0x%02x = 0x%02x\n", i, sisReg->VBPart3[i]); #endif } - for (i=0; i<=Part4max; i++) { - inSISIDXREG(SISPART4, i, sisReg->VBPart4[i]); + for(i=0; i<=p4; i++) { + inSISIDXREG(SISPART4, i, sisReg->VBPart4[i]); #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "301Save: Part4Port 0x%02x = 0x%02x\n", i, sisReg->VBPart4[i]); + xf86DrvMsg(0, X_INFO, "301xSave: Part4Port 0x%02x = 0x%02x\n", i, sisReg->VBPart4[i]); #endif } +} + +/* Save SiS301 bridge register contents */ +static void +SiS301Save(ScrnInfoPtr pScrn, SISRegPtr sisReg) +{ + SISPtr pSiS = SISPTR(pScrn); + int Part1max, Part2max, Part3max, Part4max; - sisReg->VBPart2[0] &= ~0x20; /* Disable VB Processor */ + /* Highest register number to save/restore */ + if(pSiS->VGAEngine == SIS_300_VGA) Part1max = 0x1d; + else Part1max = 0x2e; /* 0x23, but we also need 2d-2e */ + + Part2max = 0x45; + Part3max = 0x3e; + Part4max = 0x1b; + + SiSVBSave(pScrn, sisReg, Part1max, Part2max, Part3max, Part4max); + + sisReg->VBPart2[0x00] &= ~0x20; /* Disable VB Processor */ sisReg->sisRegs3C4[0x32] &= ~0x20; /* Disable Lock Mode */ } @@ -965,27 +1003,19 @@ static void SiS301Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) { SISPtr pSiS = SISPTR(pScrn); - int Part1max=0, Part2max=0, Part3max=0, Part4max=0; + int Part1max, Part2max, Part3max, Part4max; /* Highest register number to save/restore */ - switch (pSiS->VGAEngine) { - case SIS_300_VGA: - Part1max = 0x1d; - Part2max = 0x45; - Part3max = 0x3e; - Part4max = 0x1b; - break; - case SIS_315_VGA: - Part1max = 0x23; - Part2max = 0x45; - Part3max = 0x3e; - Part4max = 0x1b; - break; - } + if(pSiS->VGAEngine == SIS_300_VGA) Part1max = 0x1d; + else Part1max = 0x23; + + Part2max = 0x45; + Part3max = 0x3e; + Part4max = 0x1b; - SiS_DisableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + SiS_DisableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext); - SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); /* Pre-restore Part1 */ outSISIDXREG(SISPART1, 0x04, 0x00); @@ -998,22 +1028,17 @@ SiS301Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) outSISIDXREG(SISPART4, 0x0D, sisReg->VBPart4[0x0D]); outSISIDXREG(SISPART4, 0x0C, sisReg->VBPart4[0x0C]); - if (!(sisReg->sisRegs3D4[0x30] & 0x03) && - (sisReg->sisRegs3D4[0x31] & 0x20)) { /* disable CRT2 */ - SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); - return; + if((!(sisReg->sisRegs3D4[0x30] & 0x03)) && + (sisReg->sisRegs3D4[0x31] & 0x20)) { /* disable CRT2 */ + SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); + return; } /* Restore Part1 */ SetBlock(SISPART1, 0x02, Part1max, &(sisReg->VBPart1[0x02])); - switch (pSiS->VGAEngine) { - case SIS_300_VGA: - /* Nothing special here. */ - break; - case SIS_315_VGA: - /* Restore extra registers on 315 series */ - SetBlock(SISPART1, 0x2C, 0x2E, &(sisReg->VBPart1[0x2C])); - break; + if(pSiS->VGAEngine == SIS_315_VGA) { + /* Restore extra registers on 315 series */ + SetBlock(SISPART1, 0x2C, 0x2E, &(sisReg->VBPart1[0x2C])); } /* Restore Part2 */ @@ -1033,99 +1058,58 @@ SiS301Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) outSISIDXREG(SISPART4, 0x12, 0x00); outSISIDXREG(SISPART4, 0x12, sisReg->VBPart4[0x12]); - SiS_EnableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + SiS_EnableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext); SiS_DisplayOn(pSiS->SiS_Pr); - SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); } -/* Save SiS301B/302B/30xLV bridge register contents */ +/* Save SiS30xB/30xLV bridge register contents */ static void SiS301BSave(ScrnInfoPtr pScrn, SISRegPtr sisReg) { SISPtr pSiS = SISPTR(pScrn); - int i; - int Part1max=0, Part2max=0, Part3max=0, Part4max=0; - - switch (pSiS->VGAEngine) { - case SIS_300_VGA: - Part1max = 0x37; /* 0x1d, but we also need 2c-2e, 35-37 */ - Part2max = 0x4d; - Part3max = 0x3e; - if(pSiS->VBFlags & (VB_301LV|VB_302LV)) - Part4max = 0x34; - else - Part4max = 0x23; - break; - case SIS_315_VGA: - Part1max = 0x37; /* 0x23, but we also need 2c-2e, 35-37 */ - Part2max = 0x4d; - Part3max = 0x3e; - if(pSiS->VBFlags & (VB_301LV|VB_302LV)) - Part4max = 0x34; - else - Part4max = 0x23; - break; - } - - for (i=0; i<=Part1max; i++) { - inSISIDXREG(SISPART1, i, sisReg->VBPart1[i]); -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "301BSave: Part1Port 0x%02x = 0x%02x\n", i, sisReg->VBPart1[i]); -#endif - } - for (i=0; i<=Part2max; i++) { - inSISIDXREG(SISPART2, i, sisReg->VBPart2[i]); -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "301BSave: Part2Port 0x%02x = 0x%02x\n", i, sisReg->VBPart2[i]); -#endif - } - for (i=0; i<=Part3max; i++) { - inSISIDXREG(SISPART3, i, sisReg->VBPart3[i]); -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "301BSave: Part3Port 0x%02x = 0x%02x\n", i, sisReg->VBPart3[i]); -#endif + int Part1max, Part2max, Part3max, Part4max; + + Part1max = 0x4c; + Part2max = 0x4d; + Part3max = 0x3e; + Part4max = 0x23; + if(pSiS->VBFlags & (VB_301C|VB_302ELV)) { + Part2max = 0xff; + Part4max = 0x3c; } - for (i=0; i<=Part4max; i++) { - inSISIDXREG(SISPART4, i, sisReg->VBPart4[i]); -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "301BSave: Part4Port 0x%02x = 0x%02x\n", i, sisReg->VBPart4[i]); -#endif + if(pSiS->VBFlags & (VB_301LV|VB_302LV)) { + Part4max = 0x34; } - sisReg->VBPart2[0] &= ~0x20; /* Disable VB Processor */ + + SiSVBSave(pScrn, sisReg, Part1max, Part2max, Part3max, Part4max); + + sisReg->VBPart2[0x00] &= ~0x20; /* Disable VB Processor */ sisReg->sisRegs3C4[0x32] &= ~0x20; /* Disable Lock Mode */ } -/* Restore SiS301B/302B/301LV/302LV bridge register contents */ +/* Restore SiS30xB/30xLV bridge register contents */ static void SiS301BRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) { SISPtr pSiS = SISPTR(pScrn); - int Part1max=0, Part2max=0, Part3max=0, Part4max=0; - - switch (pSiS->VGAEngine) { - case SIS_300_VGA: - Part1max = 0x23; - Part2max = 0x4d; - Part3max = 0x3e; - if(pSiS->VBFlags & (VB_301LV|VB_302LV)) - Part4max = 0x24; - else - Part4max = 0x22; - break; - case SIS_315_VGA: - Part1max = 0x23; - Part2max = 0x4d; - Part3max = 0x3e; - if(pSiS->VBFlags & (VB_301LV|VB_302LV)) - Part4max = 0x24; - else - Part4max = 0x22; - break; - } - - SiS_DisableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); - - SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + int Part1max, Part2max, Part3max, Part4max; + + Part1max = 0x23; + Part2max = 0x4d; + Part3max = 0x3e; + Part4max = 0x22; + if(pSiS->VBFlags & (VB_301C|VB_302ELV)) { + Part2max = 0xff; + Part4max = 0x3c; + } + if(pSiS->VBFlags & (VB_301LV|VB_302LV)) { + Part4max = 0x34; + } + + SiS_DisableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext); + + SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); /* Pre-restore Part1 */ outSISIDXREG(SISPART1, 0x04, 0x00); @@ -1134,17 +1118,18 @@ SiS301BRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) outSISIDXREG(SISPART1, 0x00, sisReg->VBPart1[0x00]); outSISIDXREG(SISPART1, 0x01, sisReg->VBPart1[0x01]); /* Mode reg 0x01 became 0x2e on 315 series (0x01 still contains FIFO) */ - if(pSiS->VGAEngine == SIS_315_VGA) - outSISIDXREG(SISPART1, 0x2e, sisReg->VBPart1[0x2e]); + if(pSiS->VGAEngine == SIS_315_VGA) { + outSISIDXREG(SISPART1, 0x2e, sisReg->VBPart1[0x2e]); + } /* Pre-restore Part4 */ outSISIDXREG(SISPART4, 0x0D, sisReg->VBPart4[0x0D]); outSISIDXREG(SISPART4, 0x0C, sisReg->VBPart4[0x0C]); - if (!(sisReg->sisRegs3D4[0x30] & 0x03) && - (sisReg->sisRegs3D4[0x31] & 0x20)) { /* disable CRT2 */ - SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); - return; + if((!(sisReg->sisRegs3D4[0x30] & 0x03)) && + (sisReg->sisRegs3D4[0x31] & 0x20)) { /* disable CRT2 */ + SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); + return; } /* Restore Part1 */ @@ -1170,9 +1155,9 @@ SiS301BRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) outSISIDXREG(SISPART4, 0x12, 0x00); outSISIDXREG(SISPART4, 0x12, sisReg->VBPart4[0x12]); - SiS_EnableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + SiS_EnableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext); SiS_DisplayOn(pSiS->SiS_Pr); - SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); } /* Save LVDS bridge (+ Chrontel) register contents */ @@ -1183,31 +1168,31 @@ SiSLVDSChrontelSave(ScrnInfoPtr pScrn, SISRegPtr sisReg) int i; /* Save Part1 */ - for (i=0; i<0x46; i++) { - inSISIDXREG(SISPART1, i, sisReg->VBPart1[i]); + for(i=0; i<0x46; i++) { + inSISIDXREG(SISPART1, i, sisReg->VBPart1[i]); #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "LVDSSave: Part1Port 0x%02x = 0x%02x\n", i, sisReg->VBPart1[i]); #endif } /* Save Chrontel registers */ - if (pSiS->VBFlags & VB_CHRONTEL) { - if (pSiS->ChrontelType == CHRONTEL_700x) { - for (i=0; i<0x1D; i++) { - sisReg->ch70xx[i] = SiS_GetCH700x(pSiS->SiS_Pr, ch700xidx[i]); + if(pSiS->VBFlags & VB_CHRONTEL) { + if(pSiS->ChrontelType == CHRONTEL_700x) { + for(i=0; i<0x1D; i++) { + sisReg->ch70xx[i] = SiS_GetCH700x(pSiS->SiS_Pr, ch700xidx[i]); #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "LVDSSave: Chrontel 0x%02x = 0x%02x\n", ch700xidx[i], sisReg->ch70xx[i]); #endif } } else { - for (i=0; i<35; i++) { - sisReg->ch70xx[i] = SiS_GetCH701x(pSiS->SiS_Pr, ch701xidx[i]); + for(i=0; i<35; i++) { + sisReg->ch70xx[i] = SiS_GetCH701x(pSiS->SiS_Pr, ch701xidx[i]); #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "LVDSSave: Chrontel 0x%02x = 0x%02x\n", ch701xidx[i], sisReg->ch70xx[i]); #endif @@ -1226,24 +1211,24 @@ SiSLVDSChrontelRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) int i; USHORT wtemp; - SiS_DisableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + SiS_DisableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext); if(pSiS->sishw_ext.jChipType == SIS_730) { - outSISIDXREG(SISPART1, 0x00, 0x80); + outSISIDXREG(SISPART1, 0x00, 0x80); } - SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); if(pSiS->VBFlags & VB_CHRONTEL) { /* Restore Chrontel registers */ if(pSiS->ChrontelType == CHRONTEL_700x) { for(i=0; i<0x11; i++) { - wtemp = ((sisReg->ch70xx[i]) << 8) | (ch700xidx[i] & 0x00FF); - SiS_SetCH700x(pSiS->SiS_Pr, wtemp); + wtemp = ((sisReg->ch70xx[i]) << 8) | (ch700xidx[i] & 0x00FF); + SiS_SetCH700x(pSiS->SiS_Pr, wtemp); } } else { for(i=0; i<34; i++) { - wtemp = ((sisReg->ch70xx[i]) << 8) | (ch701xidx[i] & 0x00FF); - SiS_SetCH701x(pSiS->SiS_Pr, wtemp); + wtemp = ((sisReg->ch70xx[i]) << 8) | (ch701xidx[i] & 0x00FF); + SiS_SetCH701x(pSiS->SiS_Pr, wtemp); } } } @@ -1253,39 +1238,39 @@ SiSLVDSChrontelRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) outSISIDXREG(SISPART1, 0x05, 0x00); outSISIDXREG(SISPART1, 0x06, 0x00); outSISIDXREG(SISPART1, 0x00, sisReg->VBPart1[0]); - if(pSiS->VGAEngine == SIS_300_VGA) { + if(pSiS->VGAEngine == SIS_300_VGA) { outSISIDXREG(SISPART1, 0x01, (sisReg->VBPart1[1] | 0x80)); } else { outSISIDXREG(SISPART1, 0x01, sisReg->VBPart1[1]); } - if (!(sisReg->sisRegs3D4[0x30] & 0x03) && - (sisReg->sisRegs3D4[0x31] & 0x20)) { /* disable CRT2 */ - SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); - return; + if((!(sisReg->sisRegs3D4[0x30] & 0x03)) && + (sisReg->sisRegs3D4[0x31] & 0x20)) { /* disable CRT2 */ + SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); + return; } /* Restore Part1 */ - if(pSiS->VGAEngine == SIS_300_VGA) { + if(pSiS->VGAEngine == SIS_300_VGA) { outSISIDXREG(SISPART1, 0x02, (sisReg->VBPart1[2] | 0x40)); } else { outSISIDXREG(SISPART1, 0x02, sisReg->VBPart1[2]); } SetBlock(SISPART1, 0x03, 0x23, &(sisReg->VBPart1[0x03])); if(pSiS->VGAEngine == SIS_315_VGA) { - SetBlock(SISPART1, 0x2C, 0x2E, &(sisReg->VBPart1[0x2C])); - SetBlock(SISPART1, 0x35, 0x37, &(sisReg->VBPart1[0x35])); /* Panel Link Scaler */ + SetBlock(SISPART1, 0x2C, 0x2E, &(sisReg->VBPart1[0x2C])); + SetBlock(SISPART1, 0x35, 0x37, &(sisReg->VBPart1[0x35])); /* Panel Link Scaler */ } /* For 550 DSTN registers */ - if (pSiS->DSTN || pSiS->FSTN) { - SetBlock(SISPART1, 0x25, 0x2E, &(sisReg->VBPart1[0x25])); - SetBlock(SISPART1, 0x30, 0x45, &(sisReg->VBPart1[0x30])); + if(pSiS->DSTN || pSiS->FSTN) { + SetBlock(SISPART1, 0x25, 0x2E, &(sisReg->VBPart1[0x25])); + SetBlock(SISPART1, 0x30, 0x45, &(sisReg->VBPart1[0x30])); } - SiS_EnableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + SiS_EnableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext); SiS_DisplayOn(pSiS->SiS_Pr); - SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); } /* Restore output selection registers */ @@ -1293,123 +1278,30 @@ void SiSRestoreBridge(ScrnInfoPtr pScrn, SISRegPtr sisReg) { SISPtr pSiS = SISPTR(pScrn); - unsigned char temp = 0; + int i; #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - outSISIDXREG(SISCR, 0x30, sisReg->sisRegs3D4[0x30]); - outSISIDXREG(SISCR, 0x31, sisReg->sisRegs3D4[0x31]); - outSISIDXREG(SISCR, 0x33, sisReg->sisRegs3D4[0x33]); - outSISIDXREG(SISCR, 0x34, sisReg->sisRegs3D4[0x34]); - outSISIDXREG(SISCR, 0x36, sisReg->sisRegs3D4[0x36]); - outSISIDXREG(SISCR, 0x37, sisReg->sisRegs3D4[0x37]); - if(pSiS->Chipset != PCI_CHIP_SIS300) { - switch(pSiS->VGAEngine) { - case SIS_300_VGA: temp = 0x35; break; - case SIS_315_VGA: temp = 0x38; break; - } - if(temp) { - outSISIDXREG(SISCR, temp, sisReg->sisRegs3D4[temp]); - } + for(i = 0x30; i <= 0x3b; i++) { + if(i == 0x34) continue; + outSISIDXREG(SISCR, i, sisReg->sisRegs3D4[i]); } + if(pSiS->VGAEngine == SIS_315_VGA) { - outSISIDXREG(SISCR, 0x39, sisReg->sisRegs3D4[0x39]); - outSISIDXREG(SISCR, 0x63, sisReg->sisRegs3D4[0x63]); - outSISIDXREG(SISCR, 0x79, sisReg->sisRegs3D4[0x79]); + outSISIDXREG(SISCR, pSiS->myCR63, sisReg->sisRegs3D4[pSiS->myCR63]); + if(pSiS->sishw_ext.jChipType < SIS_661) { + outSISIDXREG(SISCR, 0x79, sisReg->sisRegs3D4[0x79]); + } } } -unsigned int -SiSddc1Read(ScrnInfoPtr pScrn) -{ - SISPtr pSiS = SISPTR(pScrn); - unsigned char temp; - -#ifdef UNLOCK_ALWAYS - sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); -#endif - - /* Wait until vertical retrace is in progress. */ - while(inSISREG(SISINPSTAT) & 0x08); - while(!(inSISREG(SISINPSTAT) & 0x08)); - - /* Get the result */ - inSISIDXREG(SISSR, 0x11, temp); - - return((temp & 0x02)>>1); -} - -#if 0 /* TW: The following function should take a threshold value - * from predefined tables. This is only needed on some - * 530 boards, which have an ESS sound device on-board. - * However, I don't know how to calculate the index to - * be submitted to this function. - */ -unsigned short -SiS_CalcSpecial530Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, int index) -{ - SISPtr pSiS = SISPTR(pScrn); - static const unsigned char t640x480[3][24] = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,A9, /* b4 - 9d - depth 8 */ - 0, 0,11,14,14, 0, 0, 0, 0, 0, 0,9D }, - { 0, 0, 0, 0, 0,12,15, 0, 0, 0,92,91, /* 9c - 85 - depth 16 */ - 0,31,31,31,31, 0, 0, 0, 0, 0, 0,85 }, - { 0, 0, 0, 0, 0,17,22,25, 0, 0, 0,79, /* 84 - ? - depth 32 */ - 0,31,31, 0, 0, 0, 0, 0, 0, 0, 0,6d } - } - static const unsigned char t800x600[3][24] = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,61, - 0,18,25,30,27,31,31,31, 0, 0, 0, 0 }, - {55, 0, 0, 0, 0, 9,10,15,18,19, 0, 0, - ... to be continued - - depthindex = (pSiS->CurrentLayout.bitsPerPixel + 1) >> 3; - if(depthindex == 3) return(0); - if(depthindex == 4) depthindex--; - depthindex--; - - switch(mode->HDisplay) { - case 640: - if(mode->VDisplay == 480) { - return(t640x480[depthindex][index]; - } else return(0); - case 800: - if(mode->VDisplay == 600) { - return(t800x600[depthindex][index]; - } else return(0); - case 1024: - if(mode->VDisplay == 768) { - return(t1024x768[depthindex][index]; - } else return(0); - case 1280: - if(mode->VDisplay == 1024) { - return(t1280x1024[depthindex][index]; - } else return(0); - case 1600: - if(mode->VDisplay == 1200) { - return(t1600x1200[depthindex][index]; - } else return(0); - default: return(0); - } -} -#endif - -/* TW: Stub */ -static void -SiSThreshold(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High) -{ - return; -} - - /* Auxiliary function to find real memory clock (in Khz) */ /* Not for 530/620 if UMA (on these, the mclk is stored in SR10) */ int SiSMclk(SISPtr pSiS) -{ +{ int mclk; unsigned char Num, Denum, Base; @@ -1425,6 +1317,7 @@ SiSMclk(SISPtr pSiS) case PCI_CHIP_SIS315PRO: case PCI_CHIP_SIS330: case PCI_CHIP_SIS660: + case PCI_CHIP_SIS340: /* Numerator */ inSISIDXREG(SISSR, 0x28, Num); mclk = 14318 * ((Num & 0x7f) + 1); @@ -1438,9 +1331,9 @@ SiSMclk(SISPtr pSiS) /* Post-Scaler */ if((Denum & 0x80) == 0) { - mclk = mclk / (((Denum & 0x60) >> 5) + 1); + mclk = mclk / (((Denum & 0x60) >> 5) + 1); } else { - mclk = mclk / ((((Denum & 0x60) >> 5) + 1) * 2); + mclk = mclk / ((((Denum & 0x60) >> 5) + 1) * 2); } break; @@ -1464,11 +1357,11 @@ SiSMclk(SISPtr pSiS) /* Post-scaler. Values' meaning depends on SR13 bit 7 */ inSISIDXREG(SISSR, 0x13, Base); if((Base & 0x80) == 0) { - mclk = mclk / (((Denum & 0x60) >> 5) + 1); + mclk = mclk / (((Denum & 0x60) >> 5) + 1); } else { - /* Values 00 and 01 are reserved */ - if ((Denum & 0x60) == 0x40) mclk /= 6; - if ((Denum & 0x60) == 0x60) mclk /= 8; + /* Values 00 and 01 are reserved */ + if ((Denum & 0x60) == 0x40) mclk /= 6; + if ((Denum & 0x60) == 0x60) mclk /= 8; } break; } @@ -1487,37 +1380,57 @@ SiSMclk(SISPtr pSiS) * For VGA2, we share the bandwith equally. */ static int -SiSEstimateCRT2Clock(ScrnInfoPtr pScrn) +SiSEstimateCRT2Clock(ScrnInfoPtr pScrn, BOOLEAN IsForMergedFBCRT2) { SISPtr pSiS = SISPTR(pScrn); if(pSiS->VBFlags & CRT2_LCD) { - if(pSiS->VBLCDFlags & (VB_LCD_320x480 | VB_LCD_800x600 | VB_LCD_640x480)) - return 40000; - else if(pSiS->VBLCDFlags & (VB_LCD_1024x768 | VB_LCD_1024x600 | VB_LCD_1152x768)) - return 65000; - else if(pSiS->VBLCDFlags & VB_LCD_1280x768) - return 81000; - else if(pSiS->VBLCDFlags & (VB_LCD_1280x1024 | VB_LCD_1280x960 | VB_LCD_1400x1050)) - return 108000; - else if(pSiS->VBLCDFlags & VB_LCD_1600x1200) - return 162000; - else if((pSiS->VBLCDFlags & VB_LCD_CUSTOM) && (pSiS->SiS_Pr->CP_HaveCustomData)) - return pSiS->SiS_Pr->CP_MaxClock; - else - return 108000; + if(pSiS->VBLCDFlags & (VB_LCD_320x480 | VB_LCD_800x600 | VB_LCD_640x480)) { + return 40000; + } else if(pSiS->VBLCDFlags & (VB_LCD_1024x768 | VB_LCD_1024x600 | VB_LCD_1152x768)) { + return 65000; + } else if(pSiS->VBLCDFlags & VB_LCD_1280x720) { + return 75000; + } else if(pSiS->VBLCDFlags & VB_LCD_1280x768) { + return 81000; + } else if(pSiS->VBLCDFlags & VB_LCD_1280x800) { + return 83000; /* Use this any way; BIOS timing seems wrong */ +#if 0 + /* Must fake clock; built-in mode shows 83 for VGA, but uses only 70 for LCD */ + if(IsForMergedFBCRT2) return 83000; + else return 70000; +#endif + } else if(pSiS->VBLCDFlags & VB_LCD_1400x1050) { + /* Must fake clock; built-in mode shows 122 for VGA, but uses only 108 for LCD */ + if(IsForMergedFBCRT2) return 123000; + else return 108000; + } else if(pSiS->VBLCDFlags & (VB_LCD_1280x1024 | VB_LCD_1280x960)) { + return 108000; + } else if(pSiS->VBLCDFlags & VB_LCD_1680x1050) { + /* Must fake clock; built-in mode shows 147 for VGA, but uses only 122 for LCD */ + if(IsForMergedFBCRT2) return 148000; + else return 122000; + } else if(pSiS->VBLCDFlags & VB_LCD_1600x1200) { + return 162000; + } else if((pSiS->VBLCDFlags & VB_LCD_CUSTOM) && (pSiS->SiS_Pr->CP_HaveCustomData)) { + return pSiS->SiS_Pr->CP_MaxClock; + } else + return 108000; } else if(pSiS->VBFlags & CRT2_TV) { - if(pSiS->VBFlags & VB_CHRONTEL) { - switch(pSiS->VGAEngine) { - case SIS_300_VGA: - return 50000; - case SIS_315_VGA: - default: - return 70000; - } - } else if(pSiS->VBFlags & VB_SISBRIDGE) { - return 70000; - } + if(pSiS->VBFlags & VB_CHRONTEL) { + switch(pSiS->VGAEngine) { + case SIS_300_VGA: + return 50000; + case SIS_315_VGA: + default: + return 70000; + } + } else if(pSiS->VBFlags & VB_SISBRIDGE) { + if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTYPBPR) + return 75000; + else + return 70000; + } } return 0; @@ -1537,13 +1450,19 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn, BOOLEAN IsForCRT2) int bytesperpixel = (bpp + 7) / 8; float magic=0.0, total, crt2used, maxcrt2; int crt2clock, max=0; +#ifdef __SUNPRO_C +#define const +#endif const float magic300[4] = { 1.2, 1.368421, 2.263158, 1.2}; const float magic630[4] = { 1.441177, 1.441177, 2.588235, 1.441177 }; const float magic315[4] = { 1.2, 1.368421, 1.368421, 1.2 }; const float magic550[4] = { 1.441177, 1.441177, 2.588235, 1.441177 }; +#ifdef __SUNPRO_C +#undef const +#endif BOOLEAN DHM, GetForCRT1; - switch (pSiS->Chipset) { + switch(pSiS->Chipset) { case PCI_CHIP_SIS5597: total = ((mclk * (bus / 8)) * 0.7) / bytesperpixel; @@ -1579,6 +1498,7 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn, BOOLEAN IsForCRT2) case PCI_CHIP_SIS650: case PCI_CHIP_SIS330: case PCI_CHIP_SIS660: + case PCI_CHIP_SIS340: switch(pSiS->Chipset) { case PCI_CHIP_SIS300: magic = magic300[bus/64]; @@ -1604,9 +1524,18 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn, BOOLEAN IsForCRT2) magic = magic550[bus/64]; max = 680000; break; - case PCI_CHIP_SIS660: /* Guessed */ - magic = magic550[bus/64]; - max = 680000; + case PCI_CHIP_SIS660: + if((pSiS->sishw_ext.jChipType >= SIS_660) && + (!(pSiS->ChipFlags & SiSCF_760UMA))) { + magic = magic315[bus/64]; + } else { + magic = magic550[bus/64]; + } + max = 800000; + case PCI_CHIP_SIS340: + magic = magic315[bus/64]; + max = 800000; + break; } PDEBUG(ErrorF("mclk: %d, bus: %d, magic: %g, bpp: %d\n", @@ -1621,11 +1550,13 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn, BOOLEAN IsForCRT2) maxcrt2 = 135000; if(pSiS->VBFlags & (VB_301B|VB_302B)) maxcrt2 = 162000; - else if(pSiS->VBFlags & VB_301C) maxcrt2 = 162000; /* ? */ - if(pSiS->VBFlags & VB_30xBDH) maxcrt2 = 100000; + else if(pSiS->VBFlags & VB_301C) maxcrt2 = 203000; + /* if(pSiS->VBFlags & VB_30xBDH) maxcrt2 = 100000; + Ignore 301B-DH here; seems the current version is like + 301B anyway */ crt2used = 0.0; - crt2clock = SiSEstimateCRT2Clock(pScrn); + crt2clock = SiSEstimateCRT2Clock(pScrn, IsForCRT2); if(crt2clock) { crt2used = crt2clock + 2000; } @@ -1649,17 +1580,17 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn, BOOLEAN IsForCRT2) if(!GetForCRT1) { - /* TW: First head = CRT2 */ + /* First head = CRT2 */ if(crt2clock) { - /* TW: We use the mem bandwidth as max clock; this - * might exceed the 70% limit a bit, but that - * does not matter; we take care of that limit - * when we calc CRT1. Overall, we might use up - * to 85% of the memory bandwidth, which seems - * enough to use accel and video. - * The "* macic" is just to compensate the - * calculation below. + /* We use the mem bandwidth as max clock; this + * might exceed the 70% limit a bit, but that + * does not matter; we take care of that limit + * when we calc CRT1. Overall, we might use up + * to 85% of the memory bandwidth, which seems + * enough to use accel and video. + * The "* macic" is just to compensate the + * calculation below. */ total = crt2used * magic; @@ -1685,9 +1616,8 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn, BOOLEAN IsForCRT2) crt2used/1000); } else { - #ifdef SISDUALHEAD - /* TW: Second head = CRT1 */ + /* Second head = CRT1 */ /* Now We know about the first head's depth, * so we can calculate more accurately. @@ -1730,9 +1660,8 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn, BOOLEAN IsForCRT2) xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Bandwidth available for CRT1 is %g MHz\n", total/1000); -#ifdef SISDUALHEAD + } -#endif } total /= magic; @@ -1758,7 +1687,9 @@ SISLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, { SISPtr pSiS = SISPTR(pScrn); int i, j, index; + unsigned char backup = 0; Bool dogamma1 = pSiS->CRT1gamma; + Bool resetxvgamma = FALSE; #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; @@ -1768,10 +1699,21 @@ SISLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, PDEBUG(ErrorF("SiSLoadPalette(%d)\n", numColors)); #ifdef SISDUALHEAD - if( ((pSiS->DualHeadMode) && (pSiS->SecondHead)) || - (!pSiS->DualHeadMode) ) { + if((!pSiS->DualHeadMode) || (pSiS->SecondHead)) { #endif + if(pSiS->VGAEngine == SIS_315_VGA) { + inSISIDXREG(SISSR, 0x1f, backup); + andSISIDXREG(SISSR, 0x1f, 0xe7); + if( (pSiS->XvGamma) && + (pSiS->MiscFlags & MISC_CRT1OVERLAYGAMMA) && + ((pSiS->CurrentLayout.depth == 16) || + (pSiS->CurrentLayout.depth == 24)) ) { + orSISIDXREG(SISSR, 0x1f, 0x10); + resetxvgamma = TRUE; + } + } + switch(pSiS->CurrentLayout.depth) { #ifdef SISGAMMA case 15: @@ -1841,28 +1783,33 @@ SISLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, } } + if(pSiS->VGAEngine == SIS_315_VGA) { + outSISIDXREG(SISSR, 0x1f, backup); + inSISIDXREG(SISSR, 0x07, backup); + if((backup & 0x04) && (resetxvgamma) && (pSiS->ResetXvGamma)) { + (pSiS->ResetXvGamma)(pScrn); + } + } + #ifdef SISDUALHEAD } - if( ((pSiS->DualHeadMode) && (!pSiS->SecondHead)) || - (!pSiS->DualHeadMode) ) { + if((!pSiS->DualHeadMode) || (!pSiS->SecondHead)) { #endif - switch(pSiS->VGAEngine) { - case SIS_300_VGA: - case SIS_315_VGA: - if(pSiS->VBFlags & CRT2_ENABLE) { - /* TW: Only the SiS bridges support a CRT2 palette */ - if(pSiS->VBFlags & VB_SISBRIDGE) { - (*pSiS->LoadCRT2Palette)(pScrn, numColors, indices, - colors, pVisual); - } - } - break; - } + switch(pSiS->VGAEngine) { + case SIS_300_VGA: + case SIS_315_VGA: + if(pSiS->VBFlags & CRT2_ENABLE) { + /* Only the SiS bridges support a CRT2 palette */ + if(pSiS->VBFlags & VB_SISBRIDGE) { + (*pSiS->LoadCRT2Palette)(pScrn, numColors, indices, colors, pVisual); + } + } + } #ifdef SISDUALHEAD - } + } #endif } @@ -1968,6 +1915,7 @@ SISDACPreInit(ScrnInfoPtr pScrn) case PCI_CHIP_SIS315PRO: case PCI_CHIP_SIS330: case PCI_CHIP_SIS660: + case PCI_CHIP_SIS340: pSiS->MaxClock = SiSMemBandWidth(pScrn, FALSE); pSiS->SiSSave = SiS315Save; pSiS->SiSSave2 = SiS301Save; @@ -1978,8 +1926,6 @@ SISDACPreInit(ScrnInfoPtr pScrn) pSiS->SiSRestore3 = SiS301BRestore; pSiS->SiSRestoreLVDSChrontel = SiSLVDSChrontelRestore; pSiS->LoadCRT2Palette = SiS301LoadPalette; - pSiS->SetThreshold = SiSThreshold; - pSiS->i2cInit = NULL; break; case PCI_CHIP_SIS300: case PCI_CHIP_SIS630: @@ -1994,8 +1940,6 @@ SISDACPreInit(ScrnInfoPtr pScrn) pSiS->SiSRestore3 = SiS301BRestore; pSiS->SiSRestoreLVDSChrontel = SiSLVDSChrontelRestore; pSiS->LoadCRT2Palette = SiS301LoadPalette; - pSiS->SetThreshold = SiSThreshold; - pSiS->i2cInit = NULL; break; case PCI_CHIP_SIS5597: case PCI_CHIP_SIS6326: @@ -2004,8 +1948,6 @@ SISDACPreInit(ScrnInfoPtr pScrn) pSiS->MaxClock = SiSMemBandWidth(pScrn, FALSE); pSiS->SiSRestore = SiSRestore; pSiS->SiSSave = SiSSave; - pSiS->SetThreshold = SiSThreshold; - pSiS->i2cInit = NULL; break; } } @@ -2034,12 +1976,12 @@ SiS6326SetTVReg(ScrnInfoPtr pScrn, CARD8 index, CARD8 data) unsigned char SiS6326GetTVReg(ScrnInfoPtr pScrn, CARD8 index) { - SISPtr pSiS = SISPTR(pScrn); - unsigned char data; + SISPtr pSiS = SISPTR(pScrn); + unsigned char data; - outSISIDXREG(SISCR, 0xE0, index); - inSISIDXREG(SISCR, 0xE1, data); - return(data); + outSISIDXREG(SISCR, 0xE0, index); + inSISIDXREG(SISCR, 0xE1, data); + return(data); } void @@ -2053,10 +1995,10 @@ SiS6326SetXXReg(ScrnInfoPtr pScrn, CARD8 index, CARD8 data) unsigned char SiS6326GetXXReg(ScrnInfoPtr pScrn, CARD8 index) { - SISPtr pSiS = SISPTR(pScrn); - unsigned char data; + SISPtr pSiS = SISPTR(pScrn); + unsigned char data; - outSISIDXREG(SISCR, 0xE2, index); - inSISIDXREG(SISCR, 0xE3, data); - return(data); + outSISIDXREG(SISCR, 0xE2, index); + inSISIDXREG(SISCR, 0xE3, data); + return(data); } diff --git a/src/sis_dac.h b/src/sis_dac.h index 8f4c202..e408ec6 100644 --- a/src/sis_dac.h +++ b/src/sis_dac.h @@ -1,46 +1,42 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.h,v 1.11 2003/06/10 16:44:19 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * DAC helper functions (Save/Restore, MemClk, etc) * Definitions and prototypes * - * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria. * - * 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 provider not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The provider makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * THE PROVIDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE PROVIDER 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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. * - * Authors: Alan Hourihane - * Mike Chapman , - * Juanjo Santamarta , - * Mitani Hiroshi - * David Thomas . - * Thomas Winischhofer */ -int SiS_compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div, - int *out_sbit, int *out_scale); +int SiS_compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div, + int *out_sbit, int *out_scale); void SISDACPreInit(ScrnInfoPtr pScrn); -unsigned int SiSddc1Read(ScrnInfoPtr pScrn); void SISLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, - LOCO *colors, VisualPtr pVisual); + LOCO *colors, VisualPtr pVisual); void SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD, unsigned int *vclk); - void SiSIODump(ScrnInfoPtr pScrn); int SiSMemBandWidth(ScrnInfoPtr pScrn, BOOLEAN IsForCRT2); int SiSMclk(SISPtr pSiS); @@ -53,11 +49,11 @@ extern unsigned char SiS6326GetXXReg(ScrnInfoPtr pScrn, CARD8 index); extern int SiSCalcVRate(DisplayModePtr mode); -/* TW: Functions from init.c & init301.c */ -extern void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT BaseAddr); -extern void SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT BaseAddr); -extern void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT BaseAddr); -extern void SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT BaseAddr); +/* Functions from init.c and init301.c */ +extern void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO); +extern void SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO); +extern void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO); +extern void SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO); 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); @@ -65,7 +61,10 @@ extern void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx); extern USHORT SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx); extern void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx); extern void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh); +extern void SiS_SetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx); +extern USHORT SiS_GetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx); extern void SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime); +extern USHORT SiS_ReadDDC1Bit(SiS_Private *SiS_Pr); extern USHORT SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer); extern void SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo); @@ -73,15 +72,3 @@ extern void SiS_DisplayOn(SiS_Private *SiS_Pr); extern unsigned char SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id); extern void SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable); extern void SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable); -#if 0 -extern void SiS_SetSwitchDDC2(SiS_Private *SiS_Pr); -extern USHORT SiS_I2C_GetByte(SiS_Private *SiS_Pr); -extern Bool SiS_I2C_PutByte(SiS_Private *SiS_Pr, USHORT data); -extern Bool SiS_I2C_Address(SiS_Private *SiS_Pr, USHORT addr); -extern void SiS_I2C_Stop(SiS_Private *SiS_Pr); -#endif - - - - - diff --git a/src/sis_dga.c b/src/sis_dga.c index b417411..272bcba 100644 --- a/src/sis_dga.c +++ b/src/sis_dga.c @@ -1,14 +1,17 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dga.c,v 1.9 2003/06/26 22:35:18 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * SiS DGA handling * - * Copyright 2000 by Alan Hourihane, Sychdyn, North Wales, UK. - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2000 by Alan Hourihane, Sychdyn, North Wales, UK. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * * Portions from radeon_dga.c which is * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and * VA Linux Systems Inc., Fremont, California. * + * Licensed under the following terms: + * * 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 @@ -37,7 +40,6 @@ #include "xf86Pci.h" #include "xf86PciInfo.h" #include "xaa.h" -#include "xaalocal.h" #include "sis.h" #include "sis_regs.h" #include "dgaproc.h" @@ -101,7 +103,7 @@ SISSetupDGAMode( pMode = firstMode = pScrn->modes; - while (pMode) { + while(pMode) { otherPitch = secondPitch ? secondPitch : pMode->HDisplay; @@ -140,9 +142,9 @@ SECOND_PASS: currentMode->flags |= DGA_BLIT_RECT_TRANS; } } - if (pMode->Flags & V_DBLSCAN) + if(pMode->Flags & V_DBLSCAN) currentMode->flags |= DGA_DOUBLESCAN; - if (pMode->Flags & V_INTERLACE) + if(pMode->Flags & V_INTERLACE) currentMode->flags |= DGA_INTERLACED; currentMode->byteOrder = pScrn->imageByteOrder; currentMode->depth = depth; @@ -190,8 +192,8 @@ SECOND_PASS: } pMode = pMode->next; - if (pMode == firstMode) - break; + if(pMode == firstMode) + break; } return modes; @@ -207,17 +209,23 @@ SISDGAInit(ScreenPtr pScreen) int num = 0; /* 8 */ -#ifdef SISDUALHEAD - /* We don't ever use 8bpp modes in dual head mode, - * so don't offer them to DGA either + /* We don't support 8bpp modes in dual head or MergedFB mode, + * so don't offer them to DGA either. */ +#ifdef SISDUALHEAD if(!pSiS->DualHeadMode) { #endif - modes = SISSetupDGAMode(pScrn, modes, &num, 8, 8, - (pScrn->bitsPerPixel == 8), - ((pScrn->bitsPerPixel != 8) - ? 0 : pScrn->displayWidth), - 0, 0, 0, PseudoColor); +#ifdef SISMERGED + if(!(pSiS->MergedFB)) { +#endif + modes = SISSetupDGAMode(pScrn, modes, &num, 8, 8, + (pScrn->bitsPerPixel == 8), + ((pScrn->bitsPerPixel != 8) + ? 0 : pScrn->displayWidth), + 0, 0, 0, PseudoColor); +#ifdef SISMERGED + } +#endif #ifdef SISDUALHEAD } #endif @@ -230,21 +238,21 @@ SISDGAInit(ScreenPtr pScreen) 0xf800, 0x07e0, 0x001f, TrueColor); if((pSiS->VGAEngine == SIS_530_VGA) || (pSiS->VGAEngine == SIS_OLD_VGA)) { - /* 24 */ - modes = SISSetupDGAMode(pScrn, modes, &num, 24, 24, - (pScrn->bitsPerPixel == 24), - ((pScrn->bitsPerPixel != 24) - ? 0 : pScrn->displayWidth), + /* 24 */ + modes = SISSetupDGAMode(pScrn, modes, &num, 24, 24, + (pScrn->bitsPerPixel == 24), + ((pScrn->bitsPerPixel != 24) + ? 0 : pScrn->displayWidth), 0xff0000, 0x00ff00, 0x0000ff, TrueColor); } if(pSiS->VGAEngine != SIS_OLD_VGA) { - /* 32 */ - modes = SISSetupDGAMode(pScrn, modes, &num, 32, 24, - (pScrn->bitsPerPixel == 32), - ((pScrn->bitsPerPixel != 32) - ? 0 : pScrn->displayWidth), - 0xff0000, 0x00ff00, 0x0000ff, TrueColor); + /* 32 */ + modes = SISSetupDGAMode(pScrn, modes, &num, 32, 24, + (pScrn->bitsPerPixel == 32), + ((pScrn->bitsPerPixel != 32) + ? 0 : pScrn->displayWidth), + 0xff0000, 0x00ff00, 0x0000ff, TrueColor); } pSiS->numDGAModes = num; diff --git a/src/sis_dri.c b/src/sis_dri.c index 4b8bc97..91553c8 100644 --- a/src/sis_dri.c +++ b/src/sis_dri.c @@ -1,4 +1,5 @@ /* $XFree86$ */ +/* $XdotOrg$ */ /* * DRI wrapper for 300 and 315 series * @@ -50,8 +51,7 @@ #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,2,99,0,0) #include "xf86drmCompat.h" #endif - -#ifdef SISNEWDRI +#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0) #include "sis_common.h" #endif @@ -70,7 +70,6 @@ while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000){}; \ } - extern void GlxSetVisualConfigs( int nconfigs, __GLXvisualConfig *configs, @@ -138,46 +137,44 @@ SISInitVisualConfigs(ScreenPtr pScreen) xfree(pSISConfigs); return FALSE; } - for(i=0; ibitsPerPixel == 16) { - pConfigs[i].redSize = 5; - pConfigs[i].greenSize = 6; - pConfigs[i].blueSize = 5; - pConfigs[i].alphaSize = 0; - pConfigs[i].redMask = 0x0000F800; - pConfigs[i].greenMask = 0x000007E0; - pConfigs[i].blueMask = 0x0000001F; - pConfigs[i].alphaMask = 0x00000000; + if(pScrn->bitsPerPixel == 16) { + pConfigs[i].redSize = 5; + pConfigs[i].greenSize = 6; + pConfigs[i].blueSize = 5; + pConfigs[i].redMask = 0x0000F800; + pConfigs[i].greenMask = 0x000007E0; + pConfigs[i].blueMask = 0x0000001F; + pConfigs[i].alphaMask = 0x00000000; } else { - pConfigs[i].redSize = 8; - pConfigs[i].greenSize = 8; - pConfigs[i].blueSize = 8; - pConfigs[i].alphaSize = 8; - pConfigs[i].redMask = 0x00FF0000; - pConfigs[i].greenMask = 0x0000FF00; - pConfigs[i].blueMask = 0x000000FF; - pConfigs[i].alphaMask = 0xFF000000; + pConfigs[i].redSize = 8; + pConfigs[i].greenSize = 8; + pConfigs[i].blueSize = 8; + pConfigs[i].redMask = 0x00FF0000; + pConfigs[i].greenMask = 0x0000FF00; + pConfigs[i].blueMask = 0x000000FF; + pConfigs[i].alphaMask = 0xFF000000; } if(accum) { - pConfigs[i].accumRedSize = 16; + pConfigs[i].accumRedSize = 16; pConfigs[i].accumGreenSize = 16; - pConfigs[i].accumBlueSize = 16; - if (pConfigs[i].alphaMask == 0) - pConfigs[i].accumAlphaSize = 0; + pConfigs[i].accumBlueSize = 16; + if(pConfigs[i].alphaMask == 0) + pConfigs[i].accumAlphaSize = 0; else - pConfigs[i].accumAlphaSize = 16; + pConfigs[i].accumAlphaSize = 16; } else { - pConfigs[i].accumRedSize = 0; + pConfigs[i].accumRedSize = 0; pConfigs[i].accumGreenSize = 0; - pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumBlueSize = 0; pConfigs[i].accumAlphaSize = 0; } if(db) pConfigs[i].doubleBuffer = TRUE; @@ -204,14 +201,14 @@ SISInitVisualConfigs(ScreenPtr pScreen) } pConfigs[i].auxBuffers = 0; pConfigs[i].level = 0; - if (pConfigs[i].accumRedSize != 0) - pConfigs[i].visualRating = GLX_SLOW_CONFIG; - else - pConfigs[i].visualRating = GLX_NONE_EXT; + if(pConfigs[i].accumRedSize != 0) + pConfigs[i].visualRating = GLX_SLOW_CONFIG; + else + pConfigs[i].visualRating = GLX_NONE_EXT; pConfigs[i].transparentPixel = GLX_NONE; - pConfigs[i].transparentRed = 0; + pConfigs[i].transparentRed = 0; pConfigs[i].transparentGreen = 0; - pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentBlue = 0; pConfigs[i].transparentAlpha = 0; pConfigs[i].transparentIndex = 0; i++; @@ -240,7 +237,7 @@ Bool SISDRIScreenInit(ScreenPtr pScreen) SISPtr pSIS = SISPTR(pScrn); DRIInfoPtr pDRIInfo; SISDRIPtr pSISDRI; -#ifdef SISNEWDRI +#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0) drmVersionPtr version; #endif @@ -249,31 +246,31 @@ Bool SISDRIScreenInit(ScreenPtr pScreen) pSIS->cmdQ_SharedWritePortBackup = NULL; #endif - /* Check that the GLX, DRI, and DRM modules have been loaded by testing - * for canonical symbols in each module. - */ - if(!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE; - if(!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE; - if(!xf86LoaderCheckSymbol("drmAvailable")) return FALSE; - if(!xf86LoaderCheckSymbol("DRIQueryVersion")) { - xf86DrvMsg(pScreen->myNum, X_ERROR, + /* Check that the GLX, DRI, and DRM modules have been loaded by testing + * for canonical symbols in each module. + */ + if(!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE; + if(!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE; + if(!xf86LoaderCheckSymbol("drmAvailable")) return FALSE; + if(!xf86LoaderCheckSymbol("DRIQueryVersion")) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] SISDRIScreenInit failed (libdri.a too old)\n"); - return FALSE; - } + return FALSE; + } - /* Check the DRI version */ - { - int major, minor, patch; - DRIQueryVersion(&major, &minor, &patch); - if(major != 4 || minor < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, + /* Check the DRI version */ + { + int major, minor, patch; + DRIQueryVersion(&major, &minor, &patch); + if(major != 4 || minor < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] SISDRIScreenInit failed because of a version mismatch.\n" "\t[dri] libDRI version is %d.%d.%d but version 4.0.x is needed.\n" "\t[dri] Disabling DRI.\n", major, minor, patch); - return FALSE; - } - } + return FALSE; + } + } pDRIInfo = DRICreateInfoRec(); if (!pDRIInfo) return FALSE; @@ -281,19 +278,20 @@ Bool SISDRIScreenInit(ScreenPtr pScreen) pDRIInfo->drmDriverName = SISKernelDriverName; pDRIInfo->clientDriverName = SISClientDriverName; -#ifdef SISNEWDRI2 +#if 0 /* Wait for DRI update */ if(xf86LoaderCheckSymbol("DRICreatePCIBusID")) { - pDRIInfo->busIdString = DRICreatePCIBusID(pSiS->PciInfo); + pDRIInfo->busIdString = DRICreatePCIBusID(pSIS->PciInfo); } else { -#endif +#endif pDRIInfo->busIdString = xalloc(64); sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d", ((pciConfigPtr)pSIS->PciInfo->thisCard)->busnum, ((pciConfigPtr)pSIS->PciInfo->thisCard)->devnum, ((pciConfigPtr)pSIS->PciInfo->thisCard)->funcnum); -#ifdef SISNEWDRI2 +#if 0 } -#endif +#endif + /* Hack to keep old DRI working -- checked for major==1 and * minor==1. */ @@ -376,36 +374,36 @@ Bool SISDRIScreenInit(ScreenPtr pScreen) return FALSE; } -#ifdef SISNEWDRI +#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0) /* Check DRM kernel version */ version = drmGetVersion(pSIS->drmSubFD); if(version) { - if(version->version_major != 1 || - version->version_minor < 0) { - /* incompatible drm version */ - xf86DrvMsg(pScreen->myNum, X_ERROR, + if((version->version_major != 1) || + (version->version_minor < 0)) { + /* incompatible drm version */ + xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] SISDRIScreenInit failed because of a version mismatch.\n" - "\t[dri] sis.o kernel module version is %d.%d.%d but version 1.0.x is needed.\n" + "\t[dri] sis.o kernel module version is %d.%d.%d but version >=1.0.x is needed.\n" "\t[dri] Disabling the DRI.\n", version->version_major, version->version_minor, version->version_patchlevel); - drmFreeVersion(version); - SISDRICloseScreen(pScreen); - return FALSE; - } - if(version->version_minor >= 1) { - /* Includes support for framebuffer memory allocation without sisfb */ - drm_sis_fb_t fb; - fb.offset = pSIS->DRIheapstart; - fb.size = pSIS->DRIheapend - pSIS->DRIheapstart; - drmCommandWrite(pSIS->drmSubFD, DRM_SIS_FB_INIT, &fb, sizeof(fb)); - xf86DrvMsg(pScreen->myNum, X_INFO, + drmFreeVersion(version); + SISDRICloseScreen(pScreen); + return FALSE; + } + if(version->version_minor >= 1) { + /* Includes support for framebuffer memory allocation without sisfb */ + drm_sis_fb_t fb; + fb.offset = pSIS->DRIheapstart; + fb.size = pSIS->DRIheapend - pSIS->DRIheapstart; + drmCommandWrite(pSIS->drmSubFD, DRM_SIS_FB_INIT, &fb, sizeof(fb)); + xf86DrvMsg(pScreen->myNum, X_INFO, "[dri] DRI video RAM memory heap: 0x%lx to 0x%lx (%dKB)\n", pSIS->DRIheapstart, pSIS->DRIheapend, (int)((pSIS->DRIheapend - pSIS->DRIheapstart) >> 10)); - } - drmFreeVersion(version); + } + drmFreeVersion(version); } #endif @@ -508,11 +506,8 @@ Bool SISDRIScreenInit(ScreenPtr pScreen) /* pSIS->agpBase = */ pSISDRI->agp.size = pSIS->agpSize; - if(drmAddMap(pSIS->drmSubFD, (drm_handle_t)0, - pSISDRI->agp.size, DRM_AGP, 0, - &pSISDRI->agp.handle) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] Failed to map public agp area\n"); + if(drmAddMap(pSIS->drmSubFD, (drm_handle_t)0, pSISDRI->agp.size, DRM_AGP, 0, &pSISDRI->agp.handle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] Failed to map public AGP area, AGP disabled\n"); pSISDRI->agp.size = 0; break; } diff --git a/src/sis_dri.h b/src/sis_dri.h index 0799c6c..9603d42 100644 --- a/src/sis_dri.h +++ b/src/sis_dri.h @@ -1,4 +1,5 @@ /* $XFree86$ */ +/* $XdotOrg$ */ /* * SiS DRI wrapper * @@ -36,6 +37,19 @@ #include "xf86drm.h" +#if 0 +#ifndef DRI_VERSION_CURRENT +#define drm_handle_t drmHandle +#define drm_context_t drmContext +#endif +#ifdef DRI_VERSION_CURRENT +#if DRI_VERSION_CURRENT < DRI_VERSION_NUMERIC(?,?,?,?) +#define drm_handle_t drmHandle +#define drm_context_t drmContext +#endif +#endif +#endif + #define SIS_MAX_DRAWABLES 256 #define SISIOMAPSIZE (64*1024) diff --git a/src/sis_driver.c b/src/sis_driver.c index 5abdda6..baba1d2 100644 --- a/src/sis_driver.c +++ b/src/sis_driver.c @@ -1,4 +1,5 @@ /* $XFree86$ */ +/* $XdotOrg$ */ /* * SiS driver main code * @@ -34,7 +35,7 @@ * * This notice covers the entire driver code unless otherwise indicated. * - * Formerly based on code which is + * Formerly based on code which was * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England. * Written by: * Alan Hourihane , @@ -154,6 +155,7 @@ static SymTabRec SISChipsets[] = { { PCI_CHIP_SIS650, "SIS650/M650/651/740" }, { PCI_CHIP_SIS330, "SIS330(Xabre)" }, { PCI_CHIP_SIS660, "SIS660/661FX/M661FX/M661MX/741/741GX/M741/760/M760" }, + { PCI_CHIP_SIS340, "SIS340" }, { -1, NULL } }; @@ -171,6 +173,7 @@ static PciChipsets SISPciChipsets[] = { { PCI_CHIP_SIS650, PCI_CHIP_SIS650, RES_SHARED_VGA }, { PCI_CHIP_SIS330, PCI_CHIP_SIS330, RES_SHARED_VGA }, { PCI_CHIP_SIS660, PCI_CHIP_SIS660, RES_SHARED_VGA }, + { PCI_CHIP_SIS340, PCI_CHIP_SIS340, RES_SHARED_VGA }, { -1, -1, RES_UNDEFINED } }; @@ -178,10 +181,6 @@ static const char *xaaSymbols[] = { "XAACopyROP", "XAACreateInfoRec", "XAADestroyInfoRec", -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) - "XAAFillSolidRects", -#endif - "XAAFillMono8x8PatternRects", "XAAHelpPatternROP", "XAAInit", NULL @@ -269,6 +268,11 @@ static const char *drmSymbols[] = { "drmCtlInstHandler", "drmGetInterruptFromBusID", "drmSiSAgpInit", +#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0) + "drmGetVersion", + "drmFreeVersion", + "drmCommandWrite", +#endif NULL }; @@ -282,10 +286,10 @@ static const char *driSymbols[] = { "DRIQueryVersion", "DRIScreenInit", "DRIUnlock", +#if 0 /* Wait for DRI update */ + "DRICreatePCIBusID", +#endif "GlxSetVisualConfigs", -#ifdef SISNEWDRI2 - "DRICreatePCIBusID" -#endif NULL }; #endif @@ -300,7 +304,11 @@ static XF86ModuleVersionInfo sisVersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, +#ifdef XORG_VERSION_CURRENT XORG_VERSION_CURRENT, +#else + XF86_VERSION_CURRENT, +#endif SIS_MAJOR_VERSION, SIS_MINOR_VERSION, SIS_PATCHLEVEL, ABI_CLASS_VIDEODRV, /* This is a video driver */ ABI_VIDEODRV_VERSION, @@ -592,10 +600,10 @@ SISDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int fla } if(docrt1) { - setSISIDXREG(SISSR, 0x01, ~0x20, sr1); /* Set/Clear "Display On" bit */ switch(pSiS->VGAEngine) { case SIS_OLD_VGA: case SIS_530_VGA: + setSISIDXREG(SISSR, 0x01, ~0x20, sr1); /* Set/Clear "Display On" bit */ inSISIDXREG(SISSR, 0x11, oldpmreg); setSISIDXREG(SISCR, 0x17, 0x7f, cr17); setSISIDXREG(SISSR, 0x11, 0x3f, pmreg); @@ -607,15 +615,15 @@ SISDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int fla } /* fall through */ default: + if(!SiSBridgeIsInSlaveMode(pScrn)) { + setSISIDXREG(SISSR, 0x01, ~0x20, sr1); /* Set/Clear "Display On" bit */ + } if((!(pSiS->VBFlags & CRT1_LCDA)) || (pSiS->VBFlags & VB_301C)) { inSISIDXREG(SISSR, 0x1f, oldpmreg); - if(!pSiS->CRT1off) { + if((!pSiS->CRT1off) && (!SiSBridgeIsInSlaveMode(pScrn))) { setSISIDXREG(SISSR, 0x1f, 0x3f, pmreg); } } - /* TODO: Check if Chrontel TV is active and in slave mode, - * don't go into power-saving mode this in this case! - */ } oldpmreg &= 0xc0; } @@ -741,6 +749,23 @@ SISErrorLog(ScrnInfoPtr pScrn, const char *format, ...) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, str); } +static void +SiS_SiSFB_Lock(ScrnInfoPtr pScrn, Bool lock) +{ + SISPtr pSiS = SISPTR(pScrn); + int fd; + CARD32 parm; + + if(!pSiS->sisfbfound) return; + if(!pSiS->sisfb_havelock) return; + + if((fd = open(pSiS->sisfbdevname, 'r')) != -1) { + parm = lock ? 1 : 0; + ioctl(fd, SISFB_SET_LOCK, &parm); + close(fd); + } +} + /* Mandatory */ static Bool SISProbe(DriverPtr drv, int flags) @@ -842,7 +867,8 @@ SISProbe(DriverPtr drv, int flags) pEnt->chipset == PCI_CHIP_SIS650 || pEnt->chipset == PCI_CHIP_SIS550 || pEnt->chipset == PCI_CHIP_SIS315 || pEnt->chipset == PCI_CHIP_SIS315H || pEnt->chipset == PCI_CHIP_SIS315PRO || pEnt->chipset == PCI_CHIP_SIS330 || - pEnt->chipset == PCI_CHIP_SIS300 || pEnt->chipset == PCI_CHIP_SIS660) { + pEnt->chipset == PCI_CHIP_SIS300 || pEnt->chipset == PCI_CHIP_SIS660 || + pEnt->chipset == PCI_CHIP_SIS340) { SISEntPtr pSiSEnt = NULL; DevUnion *pPriv; @@ -2247,6 +2273,51 @@ SiSMakeOwnModeList(ScrnInfoPtr pScrn, BOOLEAN acceptcustommodes, BOOLEAN include return FALSE; } +void SISDetermineLCDACap(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + + if( ((pSiS->sishw_ext.jChipType == SIS_650) || + (pSiS->sishw_ext.jChipType >= SIS_661)) && + (pSiS->VBFlags & (VB_301C | VB_302B | VB_301LV | VB_302LV)) && + (pSiS->VESA != 1) ) { + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTLCDA; + } else { + pSiS->SiS_SD_Flags &= ~SiS_SD_SUPPORTLCDA; + } +} + +void SISSaveDetectedDevices(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + /* Backup detected CRT2 devices */ + pSiS->detectedCRT2Devices = pSiS->VBFlags & (CRT2_LCD|CRT2_TV|CRT2_VGA|TV_AVIDEO|TV_SVIDEO| + TV_SCART|TV_HIVISION|TV_YPBPR); +} + +static BOOLEAN +SISCheckBIOS(SISPtr pSiS, unsigned short mypciid) +{ + unsigned short romptr, pciid; + + if(!pSiS->BIOS) return FALSE; + + if((pSiS->BIOS[0] != 0x55) || (pSiS->BIOS[1] != 0xaa)) return FALSE; + + romptr = pSiS->BIOS[0x18] | (pSiS->BIOS[0x19] << 8); + if(romptr > (BIOS_SIZE - 8)) return FALSE; + if((pSiS->BIOS[romptr] != 'P') || (pSiS->BIOS[romptr+1] != 'C') || + (pSiS->BIOS[romptr+2] != 'I') || (pSiS->BIOS[romptr+3] != 'R')) return FALSE; + + pciid = pSiS->BIOS[romptr+4] | (pSiS->BIOS[romptr+5] << 8); + if(pciid != 0x1039) return FALSE; + + pciid = pSiS->BIOS[romptr+6] | (pSiS->BIOS[romptr+7] << 8); + if(pciid != mypciid) return FALSE; + + return TRUE; +} + /* Mandatory */ static Bool SISPreInit(ScrnInfoPtr pScrn, int flags) @@ -2326,7 +2397,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) return FALSE; } - /* The vgahw module should be loaded here when needed */ + /* Load the vgahw module */ if(!xf86LoadSubModule(pScrn, "vgahw")) { SISErrorLog(pScrn, "Could not load vgahw module\n"); return FALSE; @@ -2347,13 +2418,13 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Copyright (C) 2001-2004 Thomas Winischhofer and others\n"); xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Compiled for X.Org %d.%d.%d.%d\n", + "Compiled for " SISMYSERVERNAME " version %d.%d.%d.%d\n", XF86_VERSION_MAJOR, XF86_VERSION_MINOR, XF86_VERSION_PATCH, XF86_VERSION_SNAP); #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,2,99,0,0) if(xf86GetVersion() != XF86_VERSION_CURRENT) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "This version of the driver is not compiled for this version of X.Org!\n"); + "This version of the driver is not compiled for this version of " SISMYSERVERNAME "\n"); } #endif xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -2413,22 +2484,57 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "This adapter is %s display adapter\n", (pSiS->Primary ? "primary" : "secondary")); - + + /* "Patch" the PIOOffset inside vgaHW in order to force + * the vgaHW module to use our relocated i/o ports. + */ + VGAHWPTR(pScrn)->PIOOffset = pSiS->MyPIOOffset = pSiS->IODBase + pSiS->PciInfo->ioBase[2] - 0x380; + +#ifdef SIS_NEED_MAP_IOP + /********************************************/ + /* THIS IS BROKEN AND WON'T WORK */ + /* Reasons: */ + /* 1) MIPS and ARM have no i/o ports but */ + /* use memory mapped i/o only. The inX/outX */ + /* macros in compiler.h are smart enough to */ + /* add "IOPortBase" to the port number, but */ + /* "IOPortBase" is never initialized. */ + /* 2) IOPortBase is declared in compiler.h */ + /* itself. So until somebody fixes all */ + /* modules (eg vgahw) to set IOPortBase, */ + /* vga support for MIPS and ARM is unusable.*/ + /********************************************/ + pSiS->IOPAddress = pSiS->IODBase + pSiS->PciInfo->ioBase[2]; + if(!SISMapIOPMem(pScrn)) { + SISErrorLog(pScrn, "Could not map I/O port area at 0x%x\n", pSiS->IOPAddress); + SISFreeRec(pScrn); + return FALSE; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "I/O port area mapped to %p, size 128\n", pSiS->IOPBase); +#if defined(__mips__) || defined(__arm32__) + /* inX/outX macros on these use IOPortBase as offset */ + /* This is entirely skrewed. */ + IOPortBase = (unsigned int)pSiS->IOPBase; +#else + /* Others might not... */ + VGAHWPTR(pScrn)->PIOOffset = pSiS->MyPIOOffset = (IOADDRESS)pSiS->IOPBase - 0x380; +#endif + } +#endif + + /* Map 64k VGA window for saving/restoring CGA fonts */ +#ifdef SIS_PC_PLATFORM if(pSiS->Primary) { - VGAHWPTR(pScrn)->MapSize = 0x10000; /* Standard 64k VGA window */ + VGAHWPTR(pScrn)->MapSize = 0x10000; if(!vgaHWMapMem(pScrn)) { - SISErrorLog(pScrn, "Could not map VGA memory\n"); SISFreeRec(pScrn); return FALSE; } } +#endif + vgaHWGetIOBase(VGAHWPTR(pScrn)); - /* We "patch" the PIOOffset inside vgaHW in order to force - * the vgaHW module to use our relocated i/o ports. - */ - VGAHWPTR(pScrn)->PIOOffset = pSiS->IODBase + (pSiS->PciInfo->ioBase[2] & 0xFFFC) - 0x380; - pSiS->pInt = NULL; if(!pSiS->Primary) { #if !defined(__alpha__) @@ -2482,7 +2588,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) * Set the Chipset and ChipRev, allowing config file entries to * override. DANGEROUS! */ - if(pSiS->pEnt->device->chipset && *pSiS->pEnt->device->chipset) { + if(pSiS->pEnt->device->chipset && *pSiS->pEnt->device->chipset) { pScrn->chipset = pSiS->pEnt->device->chipset; pSiS->Chipset = xf86StringToToken(SISChipsets, pScrn->chipset); from = X_CONFIG; @@ -2561,6 +2667,8 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->ChipFlags = 0; pSiS->SiS_SD_Flags = 0; pSiS->HWCursorMBufNum = pSiS->HWCursorCBufNum = 0; + pSiS->NeedFlush = FALSE; + pSiS->NewCRLayout = FALSE; switch(pSiS->Chipset) { case PCI_CHIP_SIS300: @@ -2636,7 +2744,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->VGAEngine = SIS_315_VGA; pSiS->ChipFlags |= SiSCF_XabreCore; pSiS->SiS_SD_Flags |= SiS_SD_IS330SERIES; - pSiS->myCR63 = 0x63; + pSiS->myCR63 = 0x53; /* sic! */ pSiS->mmioSize = 256; break; case PCI_CHIP_SIS660: /* 660, 661, 741, 760 */ @@ -2647,11 +2755,13 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->sishw_ext.jChipType = SIS_660; pSiS->ChipFlags |= SiSCF_Ultra256Core; pSiS->mmioSize = 256; + pSiS->NeedFlush = TRUE; break; case 0x07601039: pSiS->sishw_ext.jChipType = SIS_760; pSiS->ChipFlags |= SiSCF_Ultra256Core; pSiS->mmioSize = 256; + pSiS->NeedFlush = TRUE; break; case 0x07411039: pSiS->sishw_ext.jChipType = SIS_741; @@ -2673,9 +2783,19 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->VGAEngine = SIS_315_VGA; pSiS->ChipFlags |= SiSCF_Integrated; pSiS->SiS_SD_Flags |= SiS_SD_IS330SERIES; - pSiS->myCR63 = 0x53; /* Yes, 0x53 */ + pSiS->myCR63 = 0x53; /* sic! */ + pSiS->NewCRLayout = TRUE; } break; + case PCI_CHIP_SIS340: + pSiS->sishw_ext.jChipType = SIS_340; + pSiS->VGAEngine = SIS_315_VGA; + pSiS->ChipFlags |= SiSCF_XabreCore; + pSiS->SiS_SD_Flags |= SiS_SD_IS340SERIES; + pSiS->myCR63 = 0x53; /* sic! */ + pSiS->mmioSize = 256; + pSiS->NewCRLayout = TRUE; + break; case PCI_CHIP_SIS530: pSiS->sishw_ext.jChipType = SIS_530; pSiS->VGAEngine = SIS_530_VGA; @@ -2693,9 +2813,9 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) * We use this for checking where sisfb starts its memory * heap in order to automatically detect the correct MaxXFBMem * setting (which normally is given by the option of the same name). - * Under kernel 2.4.y, that only works if sisfb is completely + * Under a 2.4 kernel, that only works if sisfb is completely * running, ie with a video mode because the fbdev will not be - * installed otherwise. Under 2.5 and later, sisfb will install + * installed otherwise. Under 2.6 and later, sisfb will install * the framebuffer device in any way and running it with mode=none * is no longer supported (or necessary). */ @@ -2709,132 +2829,181 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->sisfb_haveemi = FALSE; pSiS->OldMode = 0; pSiS->sisfbfound = FALSE; + pSiS->sisfb_tvposvalid = FALSE; + pSiS->sisfbdevname[0] = 0; + pSiS->sisfb_havelock = FALSE; if(pSiS->VGAEngine == SIS_300_VGA || pSiS->VGAEngine == SIS_315_VGA) { - int fd, i; - sisfb_info mysisfbinfo; - char name[10]; - CARD32 sisfbversion; + int fd, i; + CARD32 sisfbinfosize = 0; + sisfb_info *mysisfbinfo; + CARD32 sisfbversion; + char name[16]; - { - i=0; - do { + i=0; + do { + + if(i <= 7) { sprintf(name, "/dev/fb%1d", i); - if((fd = open(name, 'r')) != -1) { - - if(!ioctl(fd, SISFB_GET_INFO, &mysisfbinfo)) { - - if(mysisfbinfo.sisfb_id == SISFB_ID) { - - sisfbversion = (mysisfbinfo.sisfb_version << 16) | - (mysisfbinfo.sisfb_revision << 8) | - (mysisfbinfo.sisfb_patchlevel); - - if(sisfbversion >= 0x010508) { - /* Added PCI bus/slot/func into in sisfb Version 1.5.08. - Check this to make sure we run on the same card as sisfb - */ - if((mysisfbinfo.sisfb_pcibus == pSiS->PciInfo->bus) && - (mysisfbinfo.sisfb_pcislot == pSiS->PciInfo->device) && - (mysisfbinfo.sisfb_pcifunc == pSiS->PciInfo->func) ) { - pSiS->sisfbfound = TRUE; - } - } else pSiS->sisfbfound = TRUE; + } else { + sprintf(name, "/dev/fb/%1d", i-8); + } + + if((fd = open(name, 'r')) != -1) { + + Bool gotit = FALSE; + + if(!ioctl(fd, SISFB_GET_INFO_SIZE, &sisfbinfosize)) { + if((mysisfbinfo = xalloc(sisfbinfosize))) { + if(!ioctl(fd, (SISFB_GET_INFO | (sisfbinfosize << 16)), mysisfbinfo)) { + gotit = TRUE; + } else { + xfree(mysisfbinfo); + mysisfbinfo = NULL; + } + } + } else { + if((mysisfbinfo = xalloc(sizeof(*mysisfbinfo)+16))) { + if(!ioctl(fd, SISFB_GET_INFO_OLD, mysisfbinfo)) { + gotit = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Possibly old version of sisfb detected. Please update.\n"); + } else { + xfree(mysisfbinfo); + mysisfbinfo = NULL; + } + } + } + + if(gotit) { + + if(mysisfbinfo->sisfb_id == SISFB_ID) { + + sisfbversion = (mysisfbinfo->sisfb_version << 16) | + (mysisfbinfo->sisfb_revision << 8) | + (mysisfbinfo->sisfb_patchlevel); + + if(sisfbversion >= 0x010508) { + /* Added PCI bus/slot/func into in sisfb Version 1.5.08. + * Check this to make sure we run on the same card as sisfb + */ + if((mysisfbinfo->sisfb_pcibus == pSiS->PciInfo->bus) && + (mysisfbinfo->sisfb_pcislot == pSiS->PciInfo->device) && + (mysisfbinfo->sisfb_pcifunc == pSiS->PciInfo->func) ) { + pSiS->sisfbfound = TRUE; + } + } else pSiS->sisfbfound = TRUE; - if(pSiS->sisfbfound) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + if(pSiS->sisfbfound) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "%s: SiS kernel fb driver (sisfb) %d.%d.%d detected (PCI: %02d:%02d.%d)\n", &name[5], - mysisfbinfo.sisfb_version, - mysisfbinfo.sisfb_revision, - mysisfbinfo.sisfb_patchlevel, + mysisfbinfo->sisfb_version, + mysisfbinfo->sisfb_revision, + mysisfbinfo->sisfb_patchlevel, pSiS->PciInfo->bus, pSiS->PciInfo->device, pSiS->PciInfo->func); - /* Added version/rev/pl in sisfb 1.4.0 */ - if(mysisfbinfo.sisfb_version == 0) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Old version of sisfb found. Please update\n"); - } - pSiS->sisfbMem = mysisfbinfo.heapstart; - /* Basically, we can't trust the pdc register if sisfb is loaded */ - pSiS->donttrustpdc = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "sisfb: memory heap starts at %dKB\n", (int)pSiS->sisfbMem); + /* Added version/rev/pl in sisfb 1.4.0 */ + if(mysisfbinfo->sisfb_version == 0) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Old version of sisfb found. Please update.\n"); + } + pSiS->sisfbMem = mysisfbinfo->heapstart; + /* Basically, we can't trust the pdc register if sisfb is loaded */ + pSiS->donttrustpdc = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "sisfb: memory heap starts at %dKB\n", (int)pSiS->sisfbMem); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "sisfb: using video mode 0x%02x\n", mysisfbinfo->fbvidmode); + pSiS->OldMode = mysisfbinfo->fbvidmode; + if(sisfbversion >= 0x010506) { xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "sisfb: using video mode 0x%02x\n", mysisfbinfo.fbvidmode); - pSiS->OldMode = mysisfbinfo.fbvidmode; - if(sisfbversion >= 0x010506) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "sisfb: %sreserved hardware cursor, using %s command queue\n", - (mysisfbinfo.sisfb_caps & 0x80) ? "" : "not ", - (mysisfbinfo.sisfb_caps & 0x40) ? "SiS300 Turbo" : - (mysisfbinfo.sisfb_caps & 0x20) ? "SiS315/330 AGP" : - (mysisfbinfo.sisfb_caps & 0x10) ? "SiS315/330 VRAM" : - (mysisfbinfo.sisfb_caps & 0x08) ? "SiS315/330 MMIO" : + "sisfb: %sreserved HW cursor, using %s cmd queue\n", + (mysisfbinfo->sisfb_caps & 0x80) ? "" : "not ", + (mysisfbinfo->sisfb_caps & 0x40) ? "SiS300 Turbo" : + (mysisfbinfo->sisfb_caps & 0x20) ? "SiS315/330/340 AGP" : + (mysisfbinfo->sisfb_caps & 0x10) ? "SiS315/330/340 VRAM" : + (mysisfbinfo->sisfb_caps & 0x08) ? "SiS315/330/340 MMIO" : "no"); - } - if(sisfbversion >= 0x01050A) { - /* We can trust the pdc value if sisfb is of recent version */ - if(pSiS->VGAEngine == SIS_300_VGA) pSiS->donttrustpdc = FALSE; - if(sisfbversion >= 0x01050B) { - if(pSiS->VGAEngine == SIS_300_VGA) { - /* As of 1.5.11, sisfb saved the register for us (300 series) */ - pSiS->sisfbpdc = mysisfbinfo.sisfb_lcdpdc; - if(!pSiS->sisfbpdc) pSiS->sisfbpdc = 0xff; - } - } - if(sisfbversion >= 0x01050E) { - if(pSiS->VGAEngine == SIS_315_VGA) { - pSiS->sisfblcda = mysisfbinfo.sisfb_lcda; - } - if(sisfbversion >= 0x01060D) { - pSiS->sisfbscalelcd = mysisfbinfo.sisfb_scalelcd; - pSiS->sisfbspecialtiming = mysisfbinfo.sisfb_specialtiming; - } - if(sisfbversion >= 0x010610) { - if(pSiS->VGAEngine == SIS_315_VGA) { - pSiS->donttrustpdc = FALSE; - pSiS->sisfbpdc = mysisfbinfo.sisfb_lcdpdc; - if(sisfbversion >= 0x010618) { - pSiS->sisfb_haveemi = mysisfbinfo.sisfb_haveemi ? TRUE : FALSE; - pSiS->sisfb_haveemilcd = TRUE; /* will match most cases */ - pSiS->sisfb_emi30 = mysisfbinfo.sisfb_emi30; - pSiS->sisfb_emi31 = mysisfbinfo.sisfb_emi31; - pSiS->sisfb_emi32 = mysisfbinfo.sisfb_emi32; - pSiS->sisfb_emi33 = mysisfbinfo.sisfb_emi33; - } - if(sisfbversion >= 0x010619) { - pSiS->sisfb_haveemilcd = mysisfbinfo.sisfb_haveemilcd ? TRUE : FALSE; - } - if(sisfbversion >= 0x01061f) { - pSiS->sisfbpdca = mysisfbinfo.sisfb_lcdpdca; - } else { - if(pSiS->sisfbpdc) { - pSiS->sisfbpdca = (pSiS->sisfbpdc & 0xf0) >> 3; - pSiS->sisfbpdc = (pSiS->sisfbpdc & 0x0f) << 1; - } else { - pSiS->sisfbpdca = pSiS->sisfbpdc = 0xff; - } - } - } + } + if(sisfbversion >= 0x01050A) { + /* We can trust the pdc value if sisfb is of recent version */ + if(pSiS->VGAEngine == SIS_300_VGA) pSiS->donttrustpdc = FALSE; + } + if(sisfbversion >= 0x01050B) { + if(pSiS->VGAEngine == SIS_300_VGA) { + /* As of 1.5.11, sisfb saved the register for us (300 series) */ + pSiS->sisfbpdc = mysisfbinfo->sisfb_lcdpdc; + if(!pSiS->sisfbpdc) pSiS->sisfbpdc = 0xff; + } + } + if(sisfbversion >= 0x01050E) { + if(pSiS->VGAEngine == SIS_315_VGA) { + pSiS->sisfblcda = mysisfbinfo->sisfb_lcda; + } + } + if(sisfbversion >= 0x01060D) { + pSiS->sisfbscalelcd = mysisfbinfo->sisfb_scalelcd; + pSiS->sisfbspecialtiming = mysisfbinfo->sisfb_specialtiming; + } + if(sisfbversion >= 0x010610) { + if(pSiS->VGAEngine == SIS_315_VGA) { + pSiS->donttrustpdc = FALSE; + pSiS->sisfbpdc = mysisfbinfo->sisfb_lcdpdc; + if(sisfbversion >= 0x010618) { + pSiS->sisfb_haveemi = mysisfbinfo->sisfb_haveemi ? TRUE : FALSE; + pSiS->sisfb_haveemilcd = TRUE; /* will match most cases */ + pSiS->sisfb_emi30 = mysisfbinfo->sisfb_emi30; + pSiS->sisfb_emi31 = mysisfbinfo->sisfb_emi31; + pSiS->sisfb_emi32 = mysisfbinfo->sisfb_emi32; + pSiS->sisfb_emi33 = mysisfbinfo->sisfb_emi33; + } + if(sisfbversion >= 0x010619) { + pSiS->sisfb_haveemilcd = mysisfbinfo->sisfb_haveemilcd ? TRUE : FALSE; + } + if(sisfbversion >= 0x01061f) { + pSiS->sisfbpdca = mysisfbinfo->sisfb_lcdpdca; + } else { + if(pSiS->sisfbpdc) { + pSiS->sisfbpdca = (pSiS->sisfbpdc & 0xf0) >> 3; + pSiS->sisfbpdc = (pSiS->sisfbpdc & 0x0f) << 1; + } else { + pSiS->sisfbpdca = pSiS->sisfbpdc = 0xff; } - } - } + } + } } - } + if(sisfbversion >= 0x010700) { + pSiS->sisfb_havelock = TRUE; + if(sisfbversion >= 0x010701) { + pSiS->sisfb_tvxpos = mysisfbinfo->sisfb_tvxpos; + pSiS->sisfb_tvypos = mysisfbinfo->sisfb_tvypos; + pSiS->sisfb_tvposvalid = TRUE; + } + } + } } - close (fd); - } - i++; - } while((i <= 7) && (!pSiS->sisfbfound)); - if(!pSiS->sisfbfound) xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "sisfb not found\n"); + xfree(mysisfbinfo); + mysisfbinfo = NULL; + } + close (fd); + } + i++; + } while((i <= 15) && (!pSiS->sisfbfound)); + + if(pSiS->sisfbfound) { + strncpy(pSiS->sisfbdevname, name, 15); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "sisfb not found\n"); } } - + /* * The first thing we should figure out is the depth, bpp, etc. + * Set SupportConvert... flags since we use the fb layer which + * supports this conversion. (24to32 seems not implemented though) * Additionally, determine the size of the HWCursor memory area. */ switch(pSiS->VGAEngine) { @@ -2848,12 +3017,15 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) break; case SIS_530_VGA: pSiS->CursorSize = 2048; - pix24flags = Support32bppFb | - Support24bppFb; + pix24flags = Support32bppFb | + Support24bppFb | + SupportConvert32to24; break; default: pSiS->CursorSize = 2048; - pix24flags = Support24bppFb; + pix24flags = Support24bppFb | + SupportConvert32to24 | + PreferConvert32to24; break; } @@ -2942,7 +3114,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) } /* Get our relocated IO registers */ - pSiS->RelIO = (SISIOADDRESS)((pSiS->PciInfo->ioBase[2] & 0xFFFC) + pSiS->IODBase); + pSiS->RelIO = (SISIOADDRESS)(pSiS->PciInfo->ioBase[2] + pSiS->IODBase); pSiS->sishw_ext.ulIOAddress = (SISIOADDRESS)(pSiS->RelIO + 0x30); xf86DrvMsg(pScrn->scrnIndex, from, "Relocated IO registers at 0x%lX\n", (unsigned long)pSiS->RelIO); @@ -3168,7 +3340,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) /* Unlock registers */ sisSaveUnlockExtRegisterLock(pSiS, &srlockReg, &crlockReg); - /* Read BIOS for 300 and 315/330 series customization */ + /* Read BIOS for 300 and 315/330/340 series customization */ pSiS->sishw_ext.pjVirtualRomBase = NULL; pSiS->BIOS = NULL; pSiS->sishw_ext.UseROM = FALSE; @@ -3190,33 +3362,37 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) "Could not allocate memory for video BIOS image\n"); } else { unsigned long segstart; - unsigned short romptr, pciid; - BOOLEAN found; - - found = FALSE; - for(segstart=BIOS_BASE; segstart<0x000f0000; segstart+=0x00001000) { + unsigned short mypciid = pSiS->Chipset; + BOOLEAN found = FALSE, readpci = FALSE; + + switch(pSiS->sishw_ext.jChipType) { + case SIS_300: readpci = TRUE; break; + case SIS_315: mypciid = PCI_CHIP_SIS315; readpci = TRUE; break; + case SIS_315PRO: mypciid = PCI_CHIP_SIS315PRO; readpci = TRUE; break; + case SIS_315H: readpci = TRUE; break; + case SIS_330: readpci = TRUE; break; + case SIS_340: readpci = TRUE; break; + } + + if(readpci) { + xf86ReadPciBIOS(0, pSiS->PciTag, 0, pSiS->BIOS, BIOS_SIZE); + if(SISCheckBIOS(pSiS, mypciid)) found = TRUE; + } + + if(!found) { + for(segstart=BIOS_BASE; segstart<0x000f0000; segstart+=0x00001000) { #if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) - if(xf86ReadBIOS(segstart, 0, pSiS->BIOS, BIOS_SIZE) != BIOS_SIZE) continue; + if(xf86ReadBIOS(segstart, 0, pSiS->BIOS, BIOS_SIZE) != BIOS_SIZE) continue; #else - if(xf86ReadDomainMemory(pSiS->PciTag, segstart, BIOS_SIZE, pSiS->BIOS) != BIOS_SIZE) continue; + if(xf86ReadDomainMemory(pSiS->PciTag, segstart, BIOS_SIZE, pSiS->BIOS) != BIOS_SIZE) continue; #endif - if((pSiS->BIOS[0] != 0x55) || (pSiS->BIOS[1] != 0xaa)) continue; - - romptr = pSiS->BIOS[0x18] | (pSiS->BIOS[0x19] << 8); - if(romptr > (BIOS_SIZE - 8)) continue; - if((pSiS->BIOS[romptr] != 'P') || (pSiS->BIOS[romptr+1] != 'C') || - (pSiS->BIOS[romptr+2] != 'I') || (pSiS->BIOS[romptr+3] != 'R')) continue; - - pciid = pSiS->BIOS[romptr+4] | (pSiS->BIOS[romptr+5] << 8); - if(pciid != 0x1039) continue; + if(!SISCheckBIOS(pSiS, mypciid)) continue; - pciid = pSiS->BIOS[romptr+6] | (pSiS->BIOS[romptr+7] << 8); - if(pciid != pSiS->Chipset) continue; - - found = TRUE; - break; + found = TRUE; + break; + } } if(!found) { @@ -3225,12 +3401,13 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) xfree(pSiS->BIOS); pSiS->BIOS = NULL; } else { + unsigned short romptr; pSiS->sishw_ext.pjVirtualRomBase = pSiS->BIOS; pSiS->ROM661New = SiSDetermineROMLayout661(pSiS->SiS_Pr,&pSiS->sishw_ext); romptr = pSiS->BIOS[0x16] | (pSiS->BIOS[0x17] << 8); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Video BIOS version \"%7s\" found at 0x%lx (%s data layout)\n", - &pSiS->BIOS[romptr], segstart, pSiS->ROM661New ? "new" : "old"); + "Video BIOS version \"%7s\" found (%s data layout)\n", + &pSiS->BIOS[romptr], pSiS->ROM661New ? "new" : "old"); #ifdef SISDUALHEAD if(pSiSEnt) { pSiSEnt->BIOS = pSiS->BIOS; @@ -3311,6 +3488,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiSEnt->AllowHotkey = pSiS->AllowHotkey; pSiSEnt->enablesisctrl = pSiS->enablesisctrl; pSiSEnt->SenseYPbPr = pSiS->SenseYPbPr; + pSiSEnt->XvDefAdaptorBlit = pSiS->XvDefAdaptorBlit; #ifdef SIS_CP SIS_CP_DRIVER_COPYOPTIONSENT #endif @@ -3391,7 +3569,8 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) } pSiS->XvOnCRT2 = pSiSEnt->XvOnCRT2; pSiS->enablesisctrl = pSiSEnt->enablesisctrl; - /* Copy gamma brightness to Ent for Xinerama */ + pSiS->XvDefAdaptorBlit = pSiSEnt->XvDefAdaptorBlit; + /* Copy gamma brightness to Ent (sic!) for Xinerama */ pSiSEnt->GammaBriR = pSiS->GammaBriR; pSiSEnt->GammaBriG = pSiS->GammaBriG; pSiSEnt->GammaBriB = pSiS->GammaBriB; @@ -3513,7 +3692,6 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->FbMapSize = pSiS->availMem = pScrn->videoRam * 1024; pSiS->sishw_ext.ulVideoMemorySize = pScrn->videoRam * 1024; - pSiS->sishw_ext.bSkipDramSizing = TRUE; /* Calculate real availMem according to Accel/TurboQueue and * HWCursur setting. Also, initialize some variables used @@ -3692,8 +3870,10 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->ChipFlags |= SiSCF_LARGEOVERLAY; break; case PCI_CHIP_SIS330: - pSiS->ChipFlags |= SiSCF_LARGEOVERLAY; pSiS->ChipFlags |= SiSCF_CRT2HWCKaputt; + /* Fall through */ + case PCI_CHIP_SIS340: + pSiS->ChipFlags |= SiSCF_LARGEOVERLAY; break; case PCI_CHIP_SIS660: { @@ -3849,7 +4029,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) int i = 0, j; unsigned short bversptr = 0; BOOLEAN footprint; - unsigned long chksum = 0; + CARD32 chksum = 0; if(pSiS->sishw_ext.UseROM) { bversptr = pSiS->BIOS[0x16] | (pSiS->BIOS[0x17] << 8); @@ -3907,7 +4087,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) SISCRT1PreInit(pScrn); /* Detect LCD (connected via CRT2, regardless of LCDA) and LCD resolution */ - SISLCDPreInit(pScrn); + SISLCDPreInit(pScrn, FALSE); /* LCDA only supported under these conditions: */ if(pSiS->ForceCRT1Type == CRT1_LCDA) { @@ -3944,28 +4124,32 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) } #endif - if(pSiS->VBFlags & CRT2_LCD) { - if((pSiS->VGAEngine != SIS_300_VGA) || (!(pSiS->VBFlags & VB_TRUMPION))) { - pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTSCALE; - if(pSiS->VBFlags & (VB_301|VB_301B|VB_302B|VB_301C)) { - pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTCENTER; - } + if((pSiS->VGAEngine != SIS_300_VGA) || (!(pSiS->VBFlags & VB_TRUMPION))) { + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTSCALE; + if(pSiS->VBFlags & (VB_301|VB_301B|VB_302B|VB_301C)) { + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTCENTER; } } + +#ifdef SISDUALHEAD + if(!pSiS->DualHeadMode) { + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTREDETECT; + } +#endif -#ifdef TWDEBUG /* @@@ TEST @@@ */ +#ifdef TWDEBUG /* FOR TESTING */ pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTYPBPRAR; xf86DrvMsg(0, X_INFO, "TEST: Support Aspect Ratio\n"); #endif /* Detect CRT2-TV and PAL/NTSC mode */ - SISTVPreInit(pScrn); + SISTVPreInit(pScrn, FALSE); /* Detect CRT2-VGA */ - SISCRT2PreInit(pScrn); + SISCRT2PreInit(pScrn, FALSE); /* Backup detected CRT2 devices */ - pSiS->detectedCRT2Devices = pSiS->VBFlags & (CRT2_LCD|CRT2_TV|CRT2_VGA|TV_AVIDEO|TV_SVIDEO|TV_SCART|TV_HIVISION|TV_YPBPR); + SISSaveDetectedDevices(pScrn); if(!(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTYPBPR)) { if((pSiS->ForceTVType != -1) && (pSiS->ForceTVType & TV_YPBPR)) { @@ -3999,14 +4183,10 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) } } - if( ((pSiS->sishw_ext.jChipType == SIS_650) || - (pSiS->sishw_ext.jChipType >= SIS_661)) && - (pSiS->VBFlags & (VB_301C | VB_302B | VB_301LV | VB_302LV)) && - (pSiS->VBFlags & CRT2_LCD) && - (pSiS->VESA != 1) ) { - pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTLCDA; - } else { - /* Paranoia */ + SISDetermineLCDACap(pScrn); + if((!(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTLCDA)) || + (!(pSiS->VBFlags & CRT2_LCD))) { + /* No LCDA if not supported or no LCD panel found */ pSiS->ForceCRT1Type = CRT1_VGA; } @@ -4028,7 +4208,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->ForceCRT2Type = CRT2_LCD; else if(pSiS->VBFlags & CRT2_TV) pSiS->ForceCRT2Type = CRT2_TV; - else if(pSiS->VBFlags & CRT2_VGA) + else if((pSiS->VBFlags & CRT2_VGA) && (pSiS->ForceCRT1Type == CRT1_VGA)) pSiS->ForceCRT2Type = CRT2_VGA; } @@ -4086,7 +4266,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) (float)((float)pSiS->XvGammaBlue / 1000)); if(!pSiS->CRT1gamma) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Separate Xv gamma corr. only effective if CRT1 gamma corr. is enabled\n"); + "Xv gamma correction only effective if CRT1 gamma corr. is enabled\n"); } } } @@ -4689,7 +4869,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) } /* Now for something completely different: DDC. - * For 300 and 315/330 series, we provide our + * For 300 and 315/330/340 series, we provide our * own functions (in order to probe CRT2 as well) * If these fail, use the VBE. * All other chipsets will use VBE. No need to re-invent @@ -4925,7 +5105,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) clockRanges->doubleScanAllowed = TRUE; /* - * Since we have lots of built-in modes for 300/315/330 series + * Since we have lots of built-in modes for 300/315/330/340 series * with vb support, we replace the given default mode list with our * own. In case the video bridge is to be used, we only allow other * modes if @@ -4996,7 +5176,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) #endif } else { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Building list of built-in modes failed, using X.Org defaults\n"); + "Building list of built-in modes failed, using server defaults\n"); } } else { pSiS->HaveCustomModes = TRUE; @@ -5499,9 +5679,74 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) return TRUE; } +/* + * Map I/O port area for non-PC platforms + */ +#ifdef SIS_NEED_MAP_IOP +static Bool +SISMapIOPMem(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; + + if(pSiS->DualHeadMode) { + pSiSEnt->MapCountIOPBase++; + if(!(pSiSEnt->IOPBase)) { + /* Only map if not mapped previously */ + pSiSEnt->IOPBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, + pSiS->PciTag, pSiS->IOPAddress, 128); + } + pSiS->IOPBase = pSiSEnt->IOPBase; + } else +#endif + pSiS->IOPBase = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, + pSiS->PciTag, pSiS->IOPAddress, 128); + + if(pSiS->IOPBase == NULL) { + SISErrorLog(pScrn, "Could not map I/O port area\n"); + return FALSE; + } + + return TRUE; +} + +static Bool +SISUnmapIOPMem(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate;; +#endif + +/* In dual head mode, we must not unmap if the other head still + * assumes memory as mapped + */ +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + if(pSiSEnt->MapCountIOPBase) { + pSiSEnt->MapCountIOPBase--; + if((pSiSEnt->MapCountIOPBase == 0) || (pSiSEnt->forceUnmapIOPBase)) { + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pSiSEnt->IOPBase, 2048); + pSiSEnt->IOPBase = NULL; + pSiSEnt->MapCountIOPBase = 0; + pSiSEnt->forceUnmapIOPBase = FALSE; + } + pSiS->IOPBase = NULL; + } + } else { +#endif + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pSiS->IOPBase, 2048); + pSiS->IOPBase = NULL; +#ifdef SISDUALHEAD + } +#endif + return TRUE; +} +#endif /* - * Map the framebuffer and MMIO memory. + * Map the framebuffer and MMIO memory */ static Bool @@ -5700,21 +5945,24 @@ SISSave(ScrnInfoPtr pScrn) vgaReg = &VGAHWPTR(pScrn)->SavedReg; sisReg = &pSiS->SavedReg; - if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - if((pSiS->VBFlags & VB_VIDEOBRIDGE) && (SiSBridgeIsInSlaveMode(pScrn))) { - vgaHWSave(pScrn, vgaReg, VGA_SR_CMAP | VGA_SR_MODE); - SiSRegInit(pSiS->SiS_Pr, pSiS->RelIO+0x30); - SiSSetLVDSetc(pSiS->SiS_Pr, &pSiS->sishw_ext, 0); - SiS_GetVBType(pSiS->SiS_Pr, &pSiS->sishw_ext); - SiS_DisableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext); - vgaHWSave(pScrn, vgaReg, VGA_SR_FONTS); - SiS_EnableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext); - } else { - vgaHWSave(pScrn, vgaReg, VGA_SR_ALL); - } + if( ((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) && + ((pSiS->VBFlags & VB_VIDEOBRIDGE) && (SiSBridgeIsInSlaveMode(pScrn))) ) { + vgaHWSave(pScrn, vgaReg, VGA_SR_CMAP | VGA_SR_MODE); +#ifdef SIS_PC_PLATFORM + SiSRegInit(pSiS->SiS_Pr, pSiS->RelIO+0x30); + SiSSetLVDSetc(pSiS->SiS_Pr, &pSiS->sishw_ext, 0); + SiS_GetVBType(pSiS->SiS_Pr, &pSiS->sishw_ext); + SiS_DisableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext); + vgaHWSave(pScrn, vgaReg, VGA_SR_FONTS); + SiS_EnableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext); +#endif } else { +#ifdef SIS_PC_PLATFORM vgaHWSave(pScrn, vgaReg, VGA_SR_ALL); - } +#else + vgaHWSave(pScrn, vgaReg, VGA_SR_CMAP | VGA_SR_MODE); +#endif + } sisSaveUnlockExtRegisterLock(pSiS,&sisReg->sisRegs3C4[0x05],&sisReg->sisRegs3D4[0x80]); @@ -5736,6 +5984,7 @@ SISSave(ScrnInfoPtr pScrn) } } +#ifdef SIS_PC_PLATFORM static void SiS_WriteAttr(SISPtr pSiS, int index, int value) { @@ -5753,12 +6002,14 @@ SiS_ReadAttr(SISPtr pSiS, int index) outb(pSiS->IODBase + VGA_ATTR_INDEX, index); return(inb(pSiS->IODBase + VGA_ATTR_DATA_R)); } +#endif #define SIS_FONTS_SIZE (8 * 8192) static void SiS_SaveFonts(ScrnInfoPtr pScrn) { +#ifdef SIS_PC_PLATFORM SISPtr pSiS = SISPTR(pScrn); unsigned char miscOut, attr10, gr4, gr5, gr6, seq2, seq4, scrn; #if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) @@ -5826,11 +6077,13 @@ SiS_SaveFonts(ScrnInfoPtr pScrn) outSISIDXREG(SISGR, 0x05, gr5); outSISIDXREG(SISGR, 0x06, gr6); outSISREG(SISMISCW, miscOut); +#endif } static void SiS_RestoreFonts(ScrnInfoPtr pScrn) { +#ifdef SIS_PC_PLATFORM SISPtr pSiS = SISPTR(pScrn); unsigned char miscOut, attr10, gr1, gr3, gr4, gr5, gr6, gr8, seq2, seq4, scrn; #if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) @@ -5897,6 +6150,7 @@ SiS_RestoreFonts(ScrnInfoPtr pScrn) outSISIDXREG(SISGR, 0x08, gr8); outSISIDXREG(SISSR, 0x02, seq2); outSISIDXREG(SISSR, 0x04, seq4); +#endif } #undef SIS_FONTS_SIZE @@ -6141,7 +6395,7 @@ SISModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) } /* Reset our PIOOffset as vgaHWInit might have reset it */ - VGAHWPTR(pScrn)->PIOOffset = pSiS->IODBase + (pSiS->PciInfo->ioBase[2] & 0xFFFC) - 0x380; + VGAHWPTR(pScrn)->PIOOffset = pSiS->MyPIOOffset; /* Prepare the register contents */ if(!(*pSiS->ModeInit)(pScrn, mode)) { @@ -6285,6 +6539,70 @@ SISSpecialRestore(ScrnInfoPtr pScrn) } } +/* Fix SR11 for 661 and later */ +static void +SiSFixupSR11(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + CARD8 tmpreg; + +#ifdef UNLOCK_ALWAYS + sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); +#endif + + if(pSiS->sishw_ext.jChipType >= SIS_661) { + inSISIDXREG(SISSR,0x11,tmpreg); +#ifdef TWDEBUG + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "SiSFixupSR11(): SR11 reads %02x\n", tmpreg); +#endif + if(tmpreg & 0x20) { + inSISIDXREG(SISSR,0x3e,tmpreg); +#ifdef TWDEBUG + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "SiSFixupSR11(): SR3e reads %02x\n", tmpreg); +#endif + tmpreg = (tmpreg + 1) & 0xff; + outSISIDXREG(SISSR,0x3e,tmpreg); +#ifdef TWDEBUG + inSISIDXREG(SISSR,0x3e,tmpreg); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "SiSFixupSR11(): SR3e reads %02x after writing\n", tmpreg); +#endif + } + + inSISIDXREG(SISSR,0x11,tmpreg); + if(tmpreg & 0xf0) { + andSISIDXREG(SISSR,0x11,0x0f); + } +#ifdef TWDEBUG + inSISIDXREG(SISSR,0x11,tmpreg); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "SiSFixupSR11(): SR11 reads %02x after AND 0x0f\n", tmpreg); +#endif + } +} + +/* Subroutine for restoring sisfb's TV parameters (used by SiSRestore()) */ + +static void +SiSRestore_SiSFB_TVParms(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + int fd; + CARD32 parm; + + if(!pSiS->sisfbfound) return; + if(!pSiS->sisfb_tvposvalid) return; + if(!(pSiS->sisfbdevname[0])) return; + + if((fd = open(pSiS->sisfbdevname, 'r')) != -1) { + parm = (CARD32)((pSiS->sisfb_tvxpos << 16) | (pSiS->sisfb_tvypos & 0xffff)); + ioctl(fd, SISFB_SET_TVPOSOFFSET, &parm); + close(fd); + } +} + /* * Restore the initial mode. To be used internally only! */ @@ -6416,6 +6734,9 @@ SISRestore(ScrnInfoPtr pScrn) pSiS->SiS_Pr->UsePanelScaler = backupscaler; pSiS->SiS_Pr->CenterScreen = backupcenter; pSiS->SiS_Pr->SiS_CustomT = backupspecialtiming; + SiS_SiSFB_Lock(pScrn, FALSE); + SiSRestore_SiSFB_TVParms(pScrn); + SiS_SiSFB_Lock(pScrn, TRUE); } @@ -6426,7 +6747,7 @@ SISRestore(ScrnInfoPtr pScrn) outSISIDXREG(SISSR, 0x1f, pSiS->oldSR1F); #ifdef SISVRAMQ - /* Restore queue mode registers on 315/330 series */ + /* Restore queue mode registers on 315/330/340 series */ /* (This became necessary due to the switch to VRAM queue) */ if(pSiS->VGAEngine == SIS_315_VGA) { unsigned char tempCR55=0; @@ -6467,7 +6788,7 @@ SISRestore(ScrnInfoPtr pScrn) } if(doitlater) { - outSISIDXREG(SISCR, 0x17, pSiS->oldCR17); + outSISIDXREG(SISCR, 0x17, pSiS->oldCR17); } if(pSiS->Primary) { @@ -6477,6 +6798,7 @@ SISRestore(ScrnInfoPtr pScrn) * so this is the only safe way: Disable the bridge ONLY if * in Slave Mode, and don't bother if not. */ +#ifdef SIS_PC_PLATFORM SiSRegInit(pSiS->SiS_Pr, pSiS->RelIO+0x30); SiSSetLVDSetc(pSiS->SiS_Pr, &pSiS->sishw_ext, 0); SiS_GetVBType(pSiS->SiS_Pr, &pSiS->sishw_ext); @@ -6485,22 +6807,32 @@ SISRestore(ScrnInfoPtr pScrn) vgaHWProtect(pScrn, TRUE); /* We now restore ALL to overcome the vga=extended problem */ + vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL); - + vgaHWProtect(pScrn, FALSE); SiS_EnableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext); andSISIDXREG(SISSR, 0x01, ~0x20); /* Display on */ +#else + vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE | VGA_SR_CMAP); +#endif } else { vgaHWProtect(pScrn, TRUE); /* We now restore ALL to overcome the vga=extended problem */ +#ifdef SIS_PC_PLATFORM vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL); +#else + vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE | VGA_SR_CMAP); +#endif vgaHWProtect(pScrn, FALSE); } } - + + SiSFixupSR11(pScrn); + #ifdef TWDEBUG { SISRegPtr pReg = &pSiS->ModeReg; @@ -6524,7 +6856,11 @@ SISRestore(ScrnInfoPtr pScrn) vgaHWProtect(pScrn, TRUE); if(pSiS->Primary) { - vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL); +#ifdef SIS_PC_PLATFORM + vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL); +#else + vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE | VGA_SR_CMAP); +#endif } /* Restore TV. This is rather complicated, but if we don't do it, @@ -6573,7 +6909,7 @@ SISVESARestore(ScrnInfoPtr pScrn) if(pSiS->UseVESA) { SISVESASaveRestore(pScrn, MODE_RESTORE); #ifdef SISVRAMQ - /* Restore queue mode registers on 315/330 series */ + /* Restore queue mode registers on 315/330/340 series */ /* (This became necessary due to the switch to VRAM queue) */ if(pSiS->VGAEngine == SIS_315_VGA) { SISRegPtr sisReg = &pSiS->SavedReg; @@ -6659,6 +6995,9 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) hwp = VGAHWPTR(pScrn); pSiS = SISPTR(pScrn); + + /* Patch the PIOOffset inside vgaHW to use our relocated IO ports */ + VGAHWPTR(pScrn)->PIOOffset = pSiS->MyPIOOffset; #ifdef SISDUALHEAD if((!pSiS->DualHeadMode) || (!pSiS->SecondHead)) { @@ -6685,7 +7024,8 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } #endif - /* Map the VGA memory and get the VGA IO base */ + /* Map the 64k VGA memory */ +#ifdef SIS_PC_PLATFORM if(pSiS->Primary) { hwp->MapSize = 0x10000; /* Standard 64k VGA window */ if(!vgaHWMapMem(pScrn)) { @@ -6693,18 +7033,18 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; } } +#endif + + /* Get the VGA IO base (relocated) */ vgaHWGetIOBase(hwp); - - /* Patch the PIOOffset inside vgaHW to use - * our relocated IO ports. - */ - VGAHWPTR(pScrn)->PIOOffset = pSiS->IODBase + (pSiS->PciInfo->ioBase[2] & 0xFFFC) - 0x380; /* Map the SIS memory and MMIO areas */ if(!SISMapMem(pScrn)) { SISErrorLog(pScrn, "SiSMapMem() failed\n"); return FALSE; } + + SiS_SiSFB_Lock(pScrn, TRUE); #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); @@ -6721,7 +7061,6 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if(pSiS->VGAEngine != SIS_315_VGA) #endif SiSEnableTurboQueue(pScrn); - } /* Save the current state */ @@ -7024,7 +7363,7 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Using SiS300/315 series HW Xv on CRT%d\n", + "Using SiS300/315/330/340 series HW Xv on CRT%d\n", (pSiS->SecondHead ? 1 : 2)); if(!pSiS->hasTwoOverlays) { if( (pSiS->XvOnCRT2 && pSiS->SecondHead) || @@ -7039,15 +7378,20 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) #endif if(pSiS->hasTwoOverlays) xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Using SiS300/315/330 series HW Xv\n" ); + "Using SiS300/315/330/340 series HW Xv\n" ); else xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Using SiS300/315/330 series HW Xv by default on CRT%d\n", + "Using SiS300/315/330/340 series HW Xv by default on CRT%d\n", (pSiS->XvOnCRT2 ? 2 : 1)); SISInitVideo(pScreen); #ifdef SISDUALHEAD } #endif + if(pSiS->blitadaptor) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Default Xv adaptor is %s\n", + pSiS->XvDefAdaptorBlit ? "Video Blitter" : "Video Overlay"); + } } else if( pSiS->Chipset == PCI_CHIP_SIS6326 || pSiS->Chipset == PCI_CHIP_SIS530 || pSiS->Chipset == PCI_CHIP_SIS5597 ) { @@ -7209,8 +7553,21 @@ SISSwitchCRT2Type(ScrnInfoPtr pScrn, unsigned long newvbflags) DisplayModePtr mode = pScrn->currentMode; /* Do NOT use this to switch from CRT2_LCD to CRT1_LCDA */ + /* Switching CRT2 to LCD or VGA will switch CRT1 to VGA if + * previously LCD-via-CRT1 + */ + /* For usability reasons, the user should not simply "lose" one + * of his output devices in MergedFB mode. Therefore, a switch + * which might lead to this situation will not be performed in + * MergedFB mode. (For example: If CRT1 is LCD-via-CRT1, don't + * let the user switch CRT2 to LCD or VGA mode, because he + * would lose one output device since LCD-via-CRT1 is only + * supported together with TV, not any other CRT2 type.) + * In Non-MergedFB mode, losing one output device is not + * considered that harmful. + */ - /* Only on 300 and 315/330 series */ + /* Only on 300 and 315/330/340 series */ if(pSiS->VGAEngine != SIS_300_VGA && pSiS->VGAEngine != SIS_315_VGA) return FALSE; @@ -7242,9 +7599,14 @@ SISSwitchCRT2Type(ScrnInfoPtr pScrn, unsigned long newvbflags) if(pSiS->MergedFB) { if(!(newvbflags & CRT2_ENABLE)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "CRT2 can't be switched off in MergedFB mode\n"); + "CRT2 can't be switched off in MergedFB mode\n"); return FALSE; } + if((newvbflags & (CRT2_LCD|CRT2_VGA)) && (newvbflags & CRT1_LCDA)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "CRT2 type can only be TV while in LCD-via-CRT1 mode\n"); + return FALSE; + } hcm = pSiS->HaveCustomModes2; if(mode->Private) { mode = ((SiSMergedDisplayModePtr)mode->Private)->CRT2; @@ -7258,9 +7620,9 @@ SISSwitchCRT2Type(ScrnInfoPtr pScrn, unsigned long newvbflags) "CRT2 can't be switched off while CRT1 is off\n"); return FALSE; } - - /* CRT2_LCD overrules LCDA */ - if(newvbflags & CRT2_LCD) { + + /* CRT2_LCD and CRT2_VGA overrule LCDA (in non-MergedFB mode) */ + if(newvbflags & (CRT2_LCD|CRT2_VGA)) { newvbflags &= ~CRT1_LCDA; } @@ -7435,6 +7797,47 @@ SISCheckModeIndexForCRT2Type(ScrnInfoPtr pScrn, unsigned short cond, unsigned sh return result; } +Bool +SISRedetectCRT2Devices(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + + if((pSiS->VGAEngine != SIS_300_VGA) && (pSiS->VGAEngine != SIS_315_VGA)) { + return FALSE; + } + +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) return FALSE; +#endif + + /* Sync the accelerators */ + if(!pSiS->NoAccel) { + if(pSiS->AccelInfoPtr) { + (*pSiS->AccelInfoPtr->Sync)(pScrn); + } + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Redetection of CRT2 devices initiated...\n"); + + if(SISRedetectCRT2Type(pScrn)) { + /* If this returns TRUE, we need to reset the display mode */ + /* Sync the accelerators */ + if(!pSiS->NoAccel) { + if(pSiS->AccelInfoPtr) { + (*pSiS->AccelInfoPtr->Sync)(pScrn); + } + } + if(!(pScrn->SwitchMode(pScrn->scrnIndex, pScrn->currentMode, 0))) return FALSE; + SISAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Redetection of CRT2 devices finished\n"); + + return TRUE; +} + Bool SISSwitchCRT1Status(ScrnInfoPtr pScrn, int onoff) { @@ -7444,11 +7847,21 @@ SISSwitchCRT1Status(ScrnInfoPtr pScrn, int onoff) int crt1off; /* onoff: 0=OFF, 1=ON(VGA), 2=ON(LCDA) */ - /* Switching to LCDA will disable CRT2 if previously LCD */ + /* Switching to LCDA will disable CRT2 if previously LCD or VGA */ + /* For usability reasons, the user should not simply "lose" one + * of his output devices in MergedFB mode. Therefore, a switch + * which might lead to this situation will not be performed in + * MergedFB mode. (For example: If CRT2 is either LCD or VGA, + * don't let the user switch to LCD-via-CRT1 mode, because he + * would lose one output device since LCD-via-CRT1 is only + * supported together with TV, not any other CRT2 type.) + * In Non-MergedFB mode, losing one output device is not + * considered that harmful. + */ /* Do NOT use this to switch from CRT1_LCDA to CRT2_LCD */ - /* Only on 300 and 315/330 series */ + /* Only on 300 and 315/330/340 series */ if(pSiS->VGAEngine != SIS_300_VGA && pSiS->VGAEngine != SIS_315_VGA) return FALSE; @@ -7463,7 +7876,7 @@ SISSwitchCRT1Status(ScrnInfoPtr pScrn, int onoff) if(!(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTLCDA)) { if(onoff == 2) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "LCD-via-CRT1 not supported on this hardware\n"); + "LCD-via-CRT1 not supported by hardware or no panel detected\n"); return FALSE; } } @@ -7472,12 +7885,12 @@ SISSwitchCRT1Status(ScrnInfoPtr pScrn, int onoff) if(pSiS->MergedFB) { if(!onoff) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "CRT1 can't be switched off in MergedFB mode\n"); + "CRT1 can't be switched off in MergedFB mode\n"); return FALSE; } else if(onoff == 2) { - if(vbflags & CRT2_LCD) { + if(vbflags & (CRT2_LCD|CRT2_VGA)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "CRT2 type can't be LCD while CRT1 is LCD-via-CRT1\n"); + "CRT1 type can only be VGA while CRT2 is LCD or VGA\n"); return FALSE; } } @@ -7494,7 +7907,7 @@ SISSwitchCRT1Status(ScrnInfoPtr pScrn, int onoff) crt1off = 0; if(onoff == 2) { vbflags |= CRT1_LCDA; - vbflags &= ~CRT2_LCD; + vbflags &= ~(CRT2_LCD|CRT2_VGA); } /* Remember: Dualhead not supported */ if(vbflags & CRT2_ENABLE) vbflags |= MIRROR_MODE; @@ -7901,6 +8314,8 @@ SISEnterVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; SISPtr pSiS = SISPTR(pScrn); + + SiS_SiSFB_Lock(pScrn, TRUE); sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); @@ -8005,6 +8420,8 @@ SISLeaveVT(int scrnIndex, int flags) } vgaHWLock(hwp); + + SiS_SiSFB_Lock(pScrn, FALSE); } @@ -8073,6 +8490,8 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen) vgaHWLock(hwp); } + + SiS_SiSFB_Lock(pScrn, FALSE); /* We should restore the mode number in case vtsema = false as well, * but since we haven't register access then we can't do it. I think @@ -8082,7 +8501,9 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen) */ SISUnmapMem(pScrn); +#ifdef SIS_PC_PLATFORM vgaHWUnmapMem(pScrn); +#endif #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { @@ -8126,6 +8547,11 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen) pSiS->adaptor = NULL; pSiS->ResetXv = pSiS->ResetXvGamma = NULL; } + + if(pSiS->blitadaptor) { + xfree(pSiS->blitadaptor); + pSiS->blitadaptor = NULL; + } pScrn->vtSema = FALSE; @@ -8144,6 +8570,21 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen) static void SISFreeScreen(int scrnIndex, int flags) { +#ifdef SIS_NEED_MAP_IOP + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SISPtr pSiS = SISPTR(pScrn); + + if(pSiS) { +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; + if(pSiSEnt) { + pSiSEnt->forceUnmapIOPBase = TRUE; + } +#endif + SISUnmapIOPMem(pScrn); + } +#endif + if(xf86LoaderCheckSymbol("vgaHWFreeHWRec")) { vgaHWFreeHWRec(xf86Screens[scrnIndex]); } @@ -8430,7 +8871,7 @@ SISModifyModeInfo(DisplayModePtr mode) mode->CrtcVBlankEnd--; } -/* Enable the Turboqueue/Commandqueue (For 300 and 315/330 series only) */ +/* Enable the Turboqueue/Commandqueue (For 300 and 315/330/340 series only) */ void SiSEnableTurboQueue(ScrnInfoPtr pScrn) { @@ -8454,7 +8895,7 @@ SiSEnableTurboQueue(ScrnInfoPtr pScrn) case SIS_315_VGA: if(!pSiS->NoAccel) { - /* On 315/330 series, there are three queue modes available + /* On 315/330/340 series, 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 @@ -8488,7 +8929,7 @@ SiSEnableTurboQueue(ScrnInfoPtr pScrn) /* Set Command Queue Threshold to max value 11111b (?) */ outSISIDXREG(SISSR, 0x27, 0x1F); - /* No idea what this does */ + /* Disable queue flipping */ if(pSiS->sishw_ext.jChipType <= SIS_330) { inSISIDXREG(SISCR, 0x55, tempCR55) ; andSISIDXREG(SISCR, 0x55, 0x33) ; @@ -8695,7 +9136,7 @@ void SiSPreSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int viewmode) CR32 = pSiS->newCR32; inSISIDXREG(SISCR, 0x33, CR33); - if(pSiS->Chipset == PCI_CHIP_SIS660) { + if(pSiS->NewCRLayout) { inSISIDXREG(SISCR, 0x35, CR35); inSISIDXREG(SISCR, 0x38, CR38); @@ -8732,7 +9173,7 @@ void SiSPreSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int viewmode) CR31 |= 0x04; /* Set VB_NotSimuMode (not for 30xB/1400x1050?) */ CR35 = 0x00; - if(pSiS->Chipset != PCI_CHIP_SIS660) { + if(!pSiS->NewCRLayout) { if(!pSiS->AllowHotkey) { CR31 |= 0x80; /* Disable hotkey-switch */ } @@ -8764,7 +9205,7 @@ void SiSPreSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int viewmode) CR38 &= ~0x04; CR31 &= ~0x01; } else if(vbflag & TV_HIVISION) { /* SiS bridge */ - if(pSiS->Chipset == PCI_CHIP_SIS660) { + if(pSiS->NewCRLayout) { CR38 |= 0x04; CR35 |= 0x60; } else { @@ -8778,7 +9219,7 @@ void SiSPreSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int viewmode) CR31 |= 0x01; CR35 |= 0x01; } else if(vbflag & TV_YPBPR) { /* SiS bridge */ - if(pSiS->Chipset == PCI_CHIP_SIS660) { + if(pSiS->NewCRLayout) { CR38 |= 0x04; if(vbflag & TV_YPBPR525P) CR35 |= 0x20; else if(vbflag & TV_YPBPR750P) CR35 |= 0x40; @@ -8961,7 +9402,7 @@ void SiSPreSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int viewmode) } } - if(pSiS->Chipset == PCI_CHIP_SIS660) { + if(pSiS->NewCRLayout) { CR31 &= 0xfe; /* Clear PAL flag (now in CR35) */ CR38 &= 0x07; /* Use only LCDA and HiVision/YPbPr bits */ @@ -10512,6 +10953,13 @@ void SiS_SetTVyscale(ScrnInfoPtr pScrn, int val) case 0x31: /* 720x480 */ case 0x33: case 0x35: + if(pSiS->VGAEngine == SIS_315_VGA) { + if(!usentsc) { + srindex = 21; + break; + } + } + /* fall through */ case 0x32: /* 720x576 */ case 0x34: case 0x36: @@ -10630,7 +11078,7 @@ void SiS_SetTVyscale(ScrnInfoPtr pScrn, int val) if(pSiS->VBFlags & (VB_301C|VB_302ELV)) { #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "301C scaler: Table index %d\n"); + xf86DrvMsg(0, X_INFO, "301C scaler: Table index %d\n", srindex301c); #endif for(j=0; j<64; j++) { outSISIDXREG(SISPART2,(0xc0 + j), SiS301CScaling[srindex301c + j]); @@ -10733,14 +11181,7 @@ SiSPostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - if(pSiS->sishw_ext.jChipType >= SIS_661) { - inSISIDXREG(SISSR,0x11,tmpreg); - if(tmpreg & 0x20) { - inSISIDXREG(SISSR,0x3e,tmpreg); - tmpreg = (tmpreg + 1) & 0xff; - outSISIDXREG(SISSR,0x3e,tmpreg); - } - } + SiSFixupSR11(pScrn); if((!pSiS->UseVESA) && (pSiS->VBFlags & CRT2_ENABLE)) { @@ -10850,6 +11291,7 @@ SiSPostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) case SIS_741: case SIS_660: case SIS_760: + case SIS_340: if(myclock < 180) { pSiS->MiscFlags |= MISC_CRT1OVERLAY; if(myclock < 166) { @@ -11379,7 +11821,7 @@ SiS_CheckCalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, unsigned long VBF int j; #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "Inside CheckCalcModeIndex (VBFlags %x, mode %dx%d)\n", + xf86DrvMsg(0, X_INFO, "Inside CheckCalcModeIndex (VBFlags %lx, mode %dx%d)\n", VBFlags,mode->HDisplay, mode->VDisplay); #endif @@ -11655,7 +12097,7 @@ unsigned char SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, unsigned char value) { unsigned char ret = 0; -#if (defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__)) +#ifdef SIS_USE_BIOS_SCRATCH unsigned char *base; base = xf86MapVidMem(pScrn->scrnIndex, VIDMEM_MMIO, 0, 0x2000); @@ -11667,8 +12109,9 @@ SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, unsigned char value) ret = *(base + offset); /* value != 0xff means: set register */ - if(value != 0xff) + if(value != 0xff) { *(base + offset) = value; + } xf86UnMapVidMem(pScrn->scrnIndex, base, 0x2000); #endif @@ -11705,7 +12148,7 @@ sisSaveUnlockExtRegisterLock(SISPtr pSiS, unsigned char *reg1, unsigned char *re inSISIDXREG(SISSR, i, val1); inSISIDXREG(0x3c4, i, val2); xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, - "SR%02d: RelIO=0x%02x 0x3c4=0x%02x (%d)\n", + "SR%02d: RelIO=0x%02x 0x3c4=0x%02x (%ld)\n", i, val1, val2, mylockcalls); } #endif diff --git a/src/sis_driver.h b/src/sis_driver.h index 03d22f3..9a07d4c 100644 --- a/src/sis_driver.h +++ b/src/sis_driver.h @@ -1,64 +1,36 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.h,v 1.18 2003/09/08 14:20:39 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Global data and definitions * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * 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. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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 * */ -/* Mode numbers for 300/315/330 series */ -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}; - /* VESA */ /* The following is included because there are BIOSes out there that * report incomplete mode lists. These are 630 BIOS versions <2.01.2x @@ -104,6 +76,7 @@ static const struct _sis_vrate { {7, 800, 600, 120, FALSE}, {8, 800, 600, 160, FALSE}, {1, 848, 480, 39, TRUE}, {2, 848, 480, 60, TRUE}, {1, 856, 480, 39, TRUE}, {2, 856, 480, 60, TRUE}, + {1, 960, 540, 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}, @@ -113,14 +86,17 @@ static const struct _sis_vrate { {1, 1152, 864, 75, TRUE}, {2, 1152, 864, 84, FALSE}, {1, 1280, 720, 60, TRUE}, {2, 1280, 720, 75, FALSE}, {3, 1280, 720, 85, TRUE}, {1, 1280, 768, 60, TRUE}, + {1, 1280, 800, 60, TRUE}, {1, 1280, 960, 60, TRUE}, {2, 1280, 960, 85, TRUE}, {1, 1280, 1024, 43, FALSE}, {2, 1280, 1024, 60, TRUE}, {3, 1280, 1024, 75, FALSE}, {4, 1280, 1024, 85, TRUE}, {1, 1360, 768, 60, 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}, + {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, 1680, 1050, 60, TRUE}, + {1, 1920, 1080, 30, 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}, @@ -140,56 +116,131 @@ static const pdctable mypdctable[] = { { 0, 0, 0, "" , "" } }; +/* These machines require setting/clearing a GPIO bit for enabling/ + * disabling communication with the Chrontel TV encoder + */ static const chswtable mychswtable[] = { { 0x1631, 0x1002, "Mitachi", "0x1002" }, { 0x1071, 0x7521, "Mitac" , "7521P" }, { 0, 0, "" , "" } }; +/* These machines require special timing/handling + */ const customttable 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, "BARCO1366" + "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, "BARCO1024" + "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, - "Compaq (Inventec)", "Presario 3017cl/3045US", CUT_COMPAQ12802, "COMPAQ1280" + "Inventec (Compaq)", "3017cl/3045US", CUT_COMPAQ12802, "COMPAQ_1280" }, { SIS_650, "", "", - 0, + 0, /* Special 1024x768 / dual link */ { 0x00c, 0, 0, 0, 0 }, { 'e' , 0, 0, 0, 0 }, 0x1558, 0x0287, - "Clevo", "L285/L287 (Version 1)", CUT_CLEVO1024, "CLEVO1024" + "Clevo", "L285/L287 (Version 1)", CUT_CLEVO1024, "CLEVO_L28X_1" }, { SIS_650, "", "", - 0, + 0, /* Special 1024x768 / single link */ { 0x00c, 0, 0, 0, 0 }, { 'y' , 0, 0, 0, 0 }, 0x1558, 0x0287, - "Clevo", "L285/L287 (Version 2)", CUT_CLEVO10242, "CLEVO10242" + "Clevo", "L285/L287 (Version 2)", CUT_CLEVO10242, "CLEVO_L28X_2" + }, + { SIS_650, "", "", + 0, /* Special 1400x1050 */ + { 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 }, - 0x1558, 0x0400, /* possibly 401 and 402 as well; not panelsize specific (?) */ - "Clevo", "D400S/D410S/D400H/D410H", CUT_CLEVO1400, "CLEVO400" + 0x1043, 0x1612, + "Asus", "L3000D/L3500D", CUT_ASUSL3000D, "ASUS_L3X00" + }, + { SIS_650, "1.10.9k", "", + 0, /* For EMI */ + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1025, 0x0028, + "Acer", "Aspire 1700", CUT_ACER1280, "ACER_ASPIRE1700" }, - { 4321, "", "", /* This is hopefully NEVER autodetected */ + { SIS_650, "1.10.7w", "", + 0, /* For EMI */ + { 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", "", /* New BIOS on its way (from BG.) */ + 0, /* For EMI */ + { 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 }, @@ -600,6 +651,8 @@ static DisplayModeRec SiS6326SIS1600x1200_60Mode = { 0.0 /* VRefresh */ }; +/* TV filters for SiS video bridges + */ static const struct _SiSTVFilter301 { unsigned char filter[7][4]; } SiSTVFilter301[] = { @@ -722,6 +775,8 @@ static const struct _SiSTVFilter301B { {0x01,0xff,0xfb,0xfb,0x0c,0x25,0x32} }} }; +/* TV scaling data for SiS video bridges + */ typedef struct _SiSTVVScale { unsigned short ScaleVDE; int sindex; @@ -848,13 +903,6 @@ static const MySiSTVVScale SiSTVVScale[] = { 0x0429, 0x036E, 0x00F2, 0x0291, 0x0275, 0x0279, 0x0001, 0x0082, 0x008F, 0x0429, 0x0291, 0x024E } }, -#if 0 - { 0x01B8, 0, 768, /* NTSC 1024 - v-scaling not supported */ - { 0x044B, 0x041A, 0x002D, 0x0329, 0x030A, 0x030D, - 0x0000, 0x0001, 0x0001, 0x044B, 0x032A, 0x02D2 } - }, -#endif - { 0x0230, 3, 480, /* PAL 640 */ { 0x0371, 0x02AE, 0x00EA, 0x01FF, 0x01E8, 0x01EB, 0x0000, 0x0007, 0x0010, 0x0371, 0x0200, 0x0032, @@ -980,12 +1028,6 @@ static const MySiSTVVScale SiSTVVScale[] = { 0x0437, 0x0372, 0x00FE, 0x0296, 0x0277, 0x027B, 0x0000, 0x0003, 0x0004, 0x0437, 0x0296, 0x01BA } }, -#if 0 - { 0x0208, 0, 768, /* PAL 1024 - v-scaling not supported */ - { 0x0491, 0x0422, 0x0046, 0x0333, 0x030D, 0x0311, - 0x0000, 0x0001, 0x0001, 0x0491, 0x0334, 0x02AE } - } -#endif }; unsigned const char SiSScalingP1Regs[] = { @@ -995,11 +1037,319 @@ unsigned const char SiSScalingP4Regs[] = { 0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b }; +static const unsigned char SiS301CScaling[] = { + + /* NTSC/PAL-M/525ip 640x480 */ + + 0x03,0x1C,0x03,0x7E,0x01,0x1C,0x05,0x7E,0x00,0x1C,0x06,0x7E,0x7F,0x1B,0x09,0x7D, + 0x7E,0x1A,0x0B,0x7D,0x7D,0x19,0x0D,0x7D,0x7D,0x18,0x0F,0x7C,0x7C,0x16,0x12,0x7C, + 0x7C,0x14,0x14,0x7C,0x7C,0x12,0x16,0x7C,0x7C,0x0F,0x18,0x7D,0x7C,0x0D,0x19,0x7E, + 0x7D,0x0B,0x1A,0x7E,0x7D,0x09,0x1B,0x7F,0x7E,0x06,0x1C,0x00,0x7E,0x05,0x1C,0x01, + + 0x03,0x1B,0x03,0x7F,0x02,0x1B,0x05,0x7E,0x00,0x1B,0x07,0x7E,0x7F,0x1B,0x09,0x7D, + 0x7E,0x1A,0x0B,0x7D,0x7D,0x19,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7C,0x16,0x12,0x7C, + 0x7C,0x14,0x14,0x7C,0x7C,0x12,0x16,0x7C,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x19,0x7E, + 0x7D,0x0B,0x1A,0x7E,0x7D,0x09,0x1B,0x7F,0x7E,0x07,0x1B,0x00,0x7E,0x05,0x1B,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, + + 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, + + 0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x19,0x0A,0x7C, + 0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x10,0x7C,0x7D,0x15,0x11,0x7D, + 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x15,0x7D,0x7D,0x10,0x16,0x7D,0x7D,0x0E,0x17,0x7E, + 0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04, + + 0x05,0x18,0x05,0x7E,0x04,0x19,0x07,0x7C,0x02,0x18,0x08,0x7E,0x01,0x18,0x0A,0x7D, + 0x00,0x17,0x0C,0x7D,0x7F,0x17,0x0E,0x7C,0x7E,0x15,0x0F,0x7E,0x7E,0x14,0x11,0x7D, + 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x17,0x7E, + 0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x18,0x03,0x7D,0x07,0x19,0x03, + + 0x05,0x18,0x05,0x7E,0x04,0x18,0x07,0x7D,0x03,0x18,0x09,0x7C,0x02,0x17,0x0A,0x7D, + 0x01,0x17,0x0C,0x7C,0x00,0x16,0x0E,0x7C,0x7F,0x15,0x0F,0x7D,0x7E,0x14,0x11,0x7D, + 0x7E,0x12,0x12,0x7E,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x16,0x7F, + 0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x17,0x02,0x7D,0x09,0x18,0x02,0x7D,0x07,0x18,0x04, + + /* NTSC/PAL-M/525ip 720x480 */ + + 0x03,0x1C,0x03,0x7E,0x01,0x1C,0x05,0x7E,0x00,0x1C,0x06,0x7E,0x7F,0x1B,0x09,0x7D, + 0x7E,0x1A,0x0B,0x7D,0x7D,0x19,0x0D,0x7D,0x7D,0x18,0x0F,0x7C,0x7C,0x16,0x12,0x7C, + 0x7C,0x14,0x14,0x7C,0x7C,0x12,0x16,0x7C,0x7C,0x0F,0x18,0x7D,0x7C,0x0D,0x19,0x7E, + 0x7D,0x0B,0x1A,0x7E,0x7D,0x09,0x1B,0x7F,0x7E,0x06,0x1C,0x00,0x7E,0x05,0x1C,0x01, + + 0x03,0x1B,0x03,0x7F,0x02,0x1B,0x05,0x7E,0x00,0x1B,0x07,0x7E,0x7F,0x1B,0x09,0x7D, + 0x7E,0x1A,0x0B,0x7D,0x7D,0x19,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7C,0x16,0x12,0x7C, + 0x7C,0x14,0x14,0x7C,0x7C,0x12,0x16,0x7C,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x19,0x7E, + 0x7D,0x0B,0x1A,0x7E,0x7D,0x09,0x1B,0x7F,0x7E,0x07,0x1B,0x00,0x7E,0x05,0x1B,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, + + 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, + + 0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x19,0x0A,0x7C, + 0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x10,0x7C,0x7D,0x15,0x11,0x7D, + 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x15,0x7D,0x7D,0x10,0x16,0x7D,0x7D,0x0E,0x17,0x7E, + 0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04, + + 0x05,0x18,0x05,0x7E,0x04,0x19,0x07,0x7C,0x02,0x18,0x08,0x7E,0x01,0x18,0x0A,0x7D, + 0x00,0x17,0x0C,0x7D,0x7F,0x17,0x0E,0x7C,0x7E,0x15,0x0F,0x7E,0x7E,0x14,0x11,0x7D, + 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x17,0x7E, + 0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x18,0x03,0x7D,0x07,0x19,0x03, + + 0x05,0x18,0x05,0x7E,0x04,0x18,0x07,0x7D,0x03,0x18,0x09,0x7C,0x02,0x17,0x0A,0x7D, + 0x01,0x17,0x0C,0x7C,0x00,0x16,0x0E,0x7C,0x7F,0x15,0x0F,0x7D,0x7E,0x14,0x11,0x7D, + 0x7E,0x12,0x12,0x7E,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x16,0x7F, + 0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x17,0x02,0x7D,0x09,0x18,0x02,0x7D,0x07,0x18,0x04, + + /* NTSC/PAL-M/525i 800x600 */ + + 0x07,0x15,0x07,0x7D,0x05,0x15,0x08,0x7E,0x04,0x15,0x09,0x7E,0x03,0x15,0x0B,0x7D, + 0x02,0x14,0x0C,0x7E,0x01,0x14,0x0D,0x7E,0x00,0x13,0x0F,0x7E,0x00,0x12,0x10,0x7E, + 0x7F,0x11,0x11,0x7F,0x7E,0x10,0x12,0x00,0x7E,0x0F,0x13,0x00,0x7E,0x0D,0x14,0x01, + 0x7D,0x0C,0x14,0x03,0x7D,0x0B,0x15,0x03,0x7D,0x09,0x15,0x05,0x7D,0x08,0x15,0x06, + + 0x07,0x15,0x07,0x7D,0x06,0x15,0x08,0x7D,0x05,0x15,0x09,0x7D,0x04,0x14,0x0B,0x7D, + 0x03,0x14,0x0C,0x7D,0x02,0x13,0x0D,0x7E,0x01,0x13,0x0E,0x7E,0x00,0x12,0x10,0x7E, + 0x7F,0x11,0x11,0x7F,0x7F,0x10,0x12,0x7F,0x7E,0x0E,0x13,0x01,0x7E,0x0D,0x13,0x02, + 0x7E,0x0C,0x14,0x02,0x7D,0x0B,0x14,0x04,0x7D,0x09,0x15,0x05,0x7D,0x08,0x15,0x06, + + 0x07,0x14,0x07,0x7E,0x06,0x14,0x08,0x7E,0x05,0x14,0x0A,0x7D,0x04,0x14,0x0B,0x7D, + 0x03,0x13,0x0C,0x7E,0x02,0x13,0x0D,0x7E,0x01,0x12,0x0E,0x7F,0x00,0x11,0x0F,0x00, + 0x00,0x10,0x10,0x00,0x7F,0x0F,0x11,0x01,0x7F,0x0E,0x12,0x01,0x7E,0x0D,0x13,0x02, + 0x7E,0x0C,0x13,0x03,0x7E,0x0B,0x14,0x03,0x7D,0x0A,0x14,0x05,0x7D,0x08,0x14,0x07, + + 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, + + 0x08,0x13,0x08,0x7D,0x07,0x13,0x09,0x7D,0x05,0x13,0x0A,0x7E,0x04,0x13,0x0B,0x7E, + 0x04,0x12,0x0C,0x7E,0x03,0x12,0x0D,0x7E,0x02,0x11,0x0E,0x7F,0x01,0x10,0x0F,0x00, + 0x00,0x10,0x10,0x00,0x00,0x0F,0x10,0x01,0x7F,0x0E,0x11,0x02,0x7F,0x0D,0x12,0x02, + 0x7E,0x0C,0x12,0x04,0x7E,0x0B,0x13,0x04,0x7E,0x0A,0x13,0x05,0x7E,0x09,0x13,0x06, + + 0x08,0x13,0x08,0x7D,0x07,0x13,0x09,0x7D,0x06,0x12,0x0A,0x7E,0x05,0x12,0x0B,0x7E, + 0x04,0x12,0x0C,0x7E,0x03,0x11,0x0D,0x7F,0x02,0x11,0x0E,0x7F,0x01,0x10,0x0E,0x01, + 0x01,0x0F,0x0F,0x01,0x00,0x0E,0x10,0x02,0x00,0x0E,0x11,0x01,0x7F,0x0D,0x11,0x03, + 0x7F,0x0C,0x12,0x03,0x7E,0x0B,0x12,0x05,0x7E,0x0A,0x12,0x06,0x7E,0x09,0x13,0x06, + + 0x08,0x12,0x08,0x7E,0x07,0x12,0x09,0x7E,0x06,0x12,0x0A,0x7E,0x05,0x12,0x0B,0x7E, + 0x04,0x11,0x0C,0x7F,0x03,0x11,0x0D,0x7F,0x02,0x10,0x0D,0x01,0x02,0x10,0x0E,0x00, + 0x01,0x0F,0x0F,0x01,0x00,0x0E,0x10,0x02,0x00,0x0D,0x10,0x03,0x7F,0x0D,0x11,0x03, + 0x7F,0x0C,0x11,0x04,0x7F,0x0B,0x12,0x04,0x7E,0x0A,0x12,0x06,0x7E,0x09,0x12,0x07, + + /* PAL/PAL-N 640x480 */ + + 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, + + 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, + + 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, + + 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, + + 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, + + 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, + + 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, + + /* PAL/PAL-N 720x576, 768x576 */ + + 0x03,0x1C,0x03,0x7E,0x01,0x1C,0x05,0x7E,0x00,0x1C,0x07,0x7D,0x7F,0x1B,0x09,0x7D, + 0x7E,0x1A,0x0B,0x7D,0x7D,0x19,0x0D,0x7D,0x7D,0x18,0x0F,0x7C,0x7C,0x16,0x12,0x7C, + 0x7C,0x14,0x14,0x7C,0x7C,0x12,0x16,0x7C,0x7C,0x0F,0x18,0x7D,0x7C,0x0D,0x19,0x7E, + 0x7D,0x0B,0x1A,0x7E,0x7D,0x09,0x1B,0x7F,0x7E,0x07,0x1C,0x7F,0x7E,0x05,0x1C,0x01, + + 0x03,0x1B,0x03,0x7F,0x02,0x1B,0x05,0x7E,0x01,0x1B,0x07,0x7D,0x7F,0x1B,0x09,0x7D, + 0x7E,0x1A,0x0B,0x7D,0x7E,0x19,0x0D,0x7C,0x7D,0x17,0x10,0x7C,0x7C,0x16,0x12,0x7C, + 0x7C,0x14,0x14,0x7C,0x7C,0x12,0x16,0x7C,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x19,0x7E, + 0x7D,0x0B,0x1A,0x7E,0x7D,0x09,0x1B,0x7F,0x7D,0x07,0x1B,0x01,0x7E,0x05,0x1B,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, + + 0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D,0x01,0x1A,0x08,0x7D,0x00,0x1A,0x09,0x7D, + 0x7F,0x19,0x0B,0x7D,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,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02, + + 0x04,0x19,0x04,0x7F,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x19,0x0A,0x7C, + 0x7F,0x18,0x0C,0x7D,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x10,0x7C,0x7D,0x15,0x11,0x7D, + 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x15,0x7D,0x7C,0x10,0x16,0x7E,0x7C,0x0E,0x17,0x7F, + 0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04, + + 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, + + 0x05,0x18,0x05,0x7E,0x04,0x18,0x07,0x7D,0x03,0x18,0x08,0x7D,0x01,0x18,0x0A,0x7D, + 0x00,0x17,0x0C,0x7D,0x7F,0x16,0x0E,0x7D,0x7F,0x15,0x0F,0x7D,0x7E,0x14,0x11,0x7D, + 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x16,0x7F, + 0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x18,0x03,0x7D,0x07,0x18,0x04, + + /* PAL/PAL-N 800x600 */ + + 0x04,0x1A,0x04,0x7E,0x02,0x1A,0x05,0x7F,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,0x1A,0x03, + + 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, + + 0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x19,0x0A,0x7C, + 0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x10,0x7C,0x7D,0x15,0x11,0x7D, + 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x15,0x7D,0x7C,0x10,0x16,0x7E,0x7C,0x0E,0x17,0x7F, + 0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04, + + 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, + + 0x05,0x18,0x05,0x7E,0x04,0x18,0x07,0x7D,0x03,0x18,0x08,0x7D,0x01,0x18,0x0A,0x7D, + 0x00,0x17,0x0C,0x7D,0x7F,0x16,0x0E,0x7D,0x7F,0x15,0x0F,0x7D,0x7E,0x14,0x11,0x7D, + 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x16,0x7F, + 0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x18,0x03,0x7D,0x07,0x18,0x04, + + 0x06,0x18,0x06,0x7C,0x04,0x18,0x07,0x7D,0x03,0x18,0x09,0x7C,0x02,0x17,0x0A,0x7D, + 0x01,0x17,0x0C,0x7C,0x00,0x16,0x0E,0x7C,0x7F,0x15,0x0F,0x7D,0x7E,0x14,0x11,0x7D, + 0x7E,0x12,0x12,0x7E,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x16,0x7F, + 0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x17,0x02,0x7D,0x09,0x18,0x02,0x7D,0x07,0x18,0x04, + + 0x06,0x17,0x06,0x7D,0x05,0x17,0x07,0x7D,0x03,0x17,0x09,0x7D,0x02,0x17,0x0A,0x7D, + 0x01,0x16,0x0C,0x7D,0x00,0x15,0x0E,0x7D,0x7F,0x14,0x0F,0x7E,0x7F,0x13,0x11,0x7D, + 0x7E,0x12,0x12,0x7E,0x7E,0x11,0x13,0x7E,0x7D,0x0F,0x14,0x00,0x7D,0x0E,0x15,0x00, + 0x7D,0x0C,0x16,0x01,0x7D,0x0A,0x17,0x02,0x7D,0x09,0x17,0x03,0x7D,0x07,0x17,0x05 +}; + + +/* Mandatory functions */ +static void SISIdentify(int flags); +static Bool SISProbe(DriverPtr drv, int flags); +static Bool SISPreInit(ScrnInfoPtr pScrn, int flags); +static Bool SISScreenInit(int Index, ScreenPtr pScreen, int argc, char **argv); +static Bool SISEnterVT(int scrnIndex, int flags); +static void SISLeaveVT(int scrnIndex, int flags); +static Bool SISCloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool SISSaveScreen(ScreenPtr pScreen, int mode); +static Bool SISSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); +static void SISAdjustFrame(int scrnIndex, int x, int y, int flags); +#ifdef SISDUALHEAD +static Bool SISSaveScreenDH(ScreenPtr pScreen, int mode); +#endif + +/* Optional functions */ +static void SISFreeScreen(int scrnIndex, int flags); +static ModeStatus SISValidMode(int scrnIndex, DisplayModePtr mode, + Bool verbose, int flags); + +/* Internally used functions */ +static Bool SISMapMem(ScrnInfoPtr pScrn); +static Bool SISUnmapMem(ScrnInfoPtr pScrn); +#ifdef SIS_NEED_MAP_IOP +static Bool SISMapIOPMem(ScrnInfoPtr pScrn); +static Bool SISUnmapIOPMem(ScrnInfoPtr pScrn); +#endif +static void SISSave(ScrnInfoPtr pScrn); +static void SISRestore(ScrnInfoPtr pScrn); +static void SISVESARestore(ScrnInfoPtr pScrn); +static Bool SISModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void SISModifyModeInfo(DisplayModePtr mode); +static void SiSPreSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int viewmode); +static void SiSPostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg); +static void SiS6326PostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg); +static Bool SiSSetVESAMode(ScrnInfoPtr pScrn, DisplayModePtr pMode); +static void SiSBuildVesaModeList(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock *vbe); +static UShort SiSCalcVESAModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void SISVESASaveRestore(ScrnInfoPtr pScrn, vbeSaveRestoreFunction function); +static void SISBridgeRestore(ScrnInfoPtr pScrn); +static void SiSEnableTurboQueue(ScrnInfoPtr pScrn); +unsigned char SISSearchCRT1Rate(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void SISWaitVBRetrace(ScrnInfoPtr pScrn); +void SISWaitRetraceCRT1(ScrnInfoPtr pScrn); +void SISWaitRetraceCRT2(ScrnInfoPtr pScrn); +static Bool InRegion(int x, int y, region r); +#ifdef SISMERGED +static void SISMergePointerMoved(int scrnIndex, int x, int y); +#endif +BOOLEAN SiSBridgeIsInSlaveMode(ScrnInfoPtr pScrn); +USHORT SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, + unsigned long VBFlags, BOOLEAN hcm); +USHORT SiS_CheckCalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, + unsigned long VBFlags, BOOLEAN hcm); +unsigned char SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, unsigned char value); +#ifdef DEBUG +static void SiSDumpModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode); +#endif +void SISDetermineLCDACap(ScrnInfoPtr pScrn); +void SISSaveDetectedDevices(ScrnInfoPtr pScrn); -USHORT SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN hcm); -USHORT SiS_CheckCalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, unsigned long VBFlags, BOOLEAN hcm); -unsigned char SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, unsigned char value); +extern USHORT SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, + int Depth, BOOL FSTN, int LCDwith, int LCDheight); +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 int SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber); +extern BOOLEAN SiSDetermineROMLayout661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +extern BOOLEAN SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceExtension, + ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom); +extern BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceExtension, + ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch); +extern void SiSRegInit(SiS_Private *SiS_Pr, USHORT BaseAddr); +extern void SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceExtension,USHORT ModeNo); +extern void SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO); +extern DisplayModePtr SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, + BOOLEAN isfordvi); +extern BOOLEAN SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceExtension, + ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom); +extern BOOLEAN SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceExtension, + ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom); -void SISMergePointerMoved(int scrnIndex, int x, int y); +/* For power management for 315 series */ +extern void SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceExtension); +extern void SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr); +extern void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceExtension); +extern void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceExtension); diff --git a/src/sis_opt.c b/src/sis_opt.c index b0e0677..b344cae 100644 --- a/src/sis_opt.c +++ b/src/sis_opt.c @@ -1,31 +1,34 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c,v 1.31 2003/09/04 15:32:44 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * SiS driver option evaluation * - * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * Based on code by ? (included in XFree86 4.1) + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * 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 supplier not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The supplier makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE SUPPLIER 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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. * * Authors: Thomas Winischhofer - * ? + * ? */ #include "xf86.h" @@ -40,15 +43,18 @@ extern const customttable mycustomttable[]; typedef enum { OPTION_SW_CURSOR, OPTION_HW_CURSOR, -/* OPTION_PCI_RETRY, */ OPTION_NOACCEL, OPTION_TURBOQUEUE, OPTION_FAST_VRAM, OPTION_NOHOSTBUS, -/* OPTION_SET_MEMCLOCK, */ OPTION_RENDER, + OPTION_FORCE_CRT1TYPE, OPTION_FORCE_CRT2TYPE, + OPTION_YPBPRAR, OPTION_SHADOW_FB, + OPTION_DRI, + OPTION_AGP_SIZE, + OPTION_AGP_SIZE2, OPTION_ROTATE, OPTION_NOXVIDEO, OPTION_VESA, @@ -56,6 +62,10 @@ typedef enum { OPTION_FORCECRT1, OPTION_XVONCRT2, OPTION_PDC, + OPTION_PDCA, + OPTION_PDCS, + OPTION_PDCAS, + OPTION_EMI, OPTION_TVSTANDARD, OPTION_USEROMDATA, OPTION_NOINTERNALMODES, @@ -94,8 +104,10 @@ typedef enum { OPTION_RESTOREBYSET, OPTION_NODDCFORCRT2, OPTION_FORCECRT2REDETECTION, + OPTION_SENSEYPBPR, OPTION_CRT1GAMMA, OPTION_CRT2GAMMA, + OPTION_XVGAMMA, OPTION_XVDEFCONTRAST, OPTION_XVDEFBRIGHTNESS, OPTION_XVDEFHUE, @@ -109,11 +121,14 @@ typedef enum { OPTION_XVDISABLECOLORKEY, OPTION_XVINSIDECHROMAKEY, OPTION_XVYUVCHROMAKEY, + OPTION_XVDEFAULTADAPTOR, OPTION_SCALELCD, + OPTION_CENTERLCD, OPTION_SPECIALTIMING, OPTION_LVDSHL, OPTION_ENABLEHOTKEY, OPTION_MERGEDFB, + OPTION_MERGEDFBAUTO, OPTION_CRT2HSYNC, OPTION_CRT2VREFRESH, OPTION_CRT2POS, @@ -125,13 +140,10 @@ typedef enum { OPTION_NOSISXINERAMA, OPTION_NOSISXINERAMA2, OPTION_CRT2ISSCRN0, + OPTION_MERGEDDPI, OPTION_ENABLESISCTRL, - OPTION_STOREDBRIR, - OPTION_STOREDBRIG, - OPTION_STOREDBRIB, - OPTION_STOREDPBRIR, - OPTION_STOREDPBRIG, - OPTION_STOREDPBRIB, + OPTION_STOREDBRI, + OPTION_STOREDPBRI, #ifdef SIS_CP SIS_CP_OPT_OPTIONS #endif @@ -141,22 +153,31 @@ typedef enum { static const OptionInfoRec SISOptions[] = { { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, -/* { OPTION_PCI_RETRY, "PciRetry", OPTV_BOOLEAN, {0}, FALSE }, */ { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_TURBOQUEUE, "TurboQueue", OPTV_BOOLEAN, {0}, FALSE }, -/* { OPTION_SET_MEMCLOCK, "SetMClk", OPTV_FREQ, {0}, -1 }, */ { OPTION_FAST_VRAM, "FastVram", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_NOHOSTBUS, "NoHostBus", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_RENDER, "RenderAcceleration", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_FORCE_CRT2TYPE, "ForceCRT2Type", OPTV_ANYSTR, {0}, FALSE }, + { OPTION_FORCE_CRT1TYPE, "ForceCRT1Type", OPTV_STRING, {0}, FALSE }, + { OPTION_FORCE_CRT2TYPE, "ForceCRT2Type", OPTV_STRING, {0}, FALSE }, + { OPTION_YPBPRAR, "YPbPrAspectRatio", OPTV_STRING, {0}, FALSE }, { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, + { OPTION_DRI, "DRI", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_AGP_SIZE2, "GARTSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_ROTATE, "Rotate", OPTV_STRING, {0}, FALSE }, { OPTION_NOXVIDEO, "NoXvideo", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_VESA, "Vesa", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_MAXXFBMEM, "MaxXFBMem", OPTV_INTEGER, {0}, -1 }, { OPTION_FORCECRT1, "ForceCRT1", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_XVONCRT2, "XvOnCRT2", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_PDC, "PanelDelayCompensation", OPTV_INTEGER, {0}, -1 }, + { OPTION_PDCA, "PanelDelayCompensation1",OPTV_INTEGER, {0}, -1 }, + { OPTION_PDCS, "PDC", OPTV_INTEGER, {0}, -1 }, + { OPTION_PDCAS, "PDC1", OPTV_INTEGER, {0}, -1 }, + { OPTION_EMI, "EMI", OPTV_INTEGER, {0}, -1 }, + { OPTION_LVDSHL, "LVDSHL", OPTV_INTEGER, {0}, -1 }, + { OPTION_SPECIALTIMING, "SpecialTiming", OPTV_STRING, {0}, -1 }, { OPTION_TVSTANDARD, "TVStandard", OPTV_STRING, {0}, -1 }, { OPTION_USEROMDATA, "UseROMData", OPTV_BOOLEAN, {0}, -1 }, { OPTION_NOINTERNALMODES, "NoInternalModes", OPTV_BOOLEAN, {0}, FALSE }, @@ -191,12 +212,16 @@ static const OptionInfoRec SISOptions[] = { { OPTION_SIS6326FSCADJUST, "SIS6326FSCAdjust", OPTV_INTEGER, {0}, -1 }, { OPTION_USERGBCURSOR, "UseColorHWCursor", OPTV_BOOLEAN, {0}, -1 }, { OPTION_USERGBCURSORBLEND, "ColorHWCursorBlending", OPTV_BOOLEAN, {0}, -1 }, - { OPTION_USERGBCURSORBLENDTH, "ColorHWCursorBlendThreshold", OPTV_INTEGER, {0}, -1 }, + { OPTION_USERGBCURSORBLENDTH, "ColorHWCursorBlendThreshold", OPTV_INTEGER,{0},-1 }, { OPTION_RESTOREBYSET, "RestoreBySetMode", OPTV_BOOLEAN, {0}, -1 }, { OPTION_NODDCFORCRT2, "NoCRT2Detection", OPTV_BOOLEAN, {0}, -1 }, { OPTION_FORCECRT2REDETECTION, "ForceCRT2ReDetection", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_SENSEYPBPR, "SenseYPbPr", OPTV_BOOLEAN, {0}, -1 }, { OPTION_CRT1GAMMA, "CRT1Gamma", OPTV_BOOLEAN, {0}, -1 }, { OPTION_CRT2GAMMA, "CRT2Gamma", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_STOREDBRI, "StoredGammaBrightness", OPTV_STRING, {0}, -1 }, + { OPTION_STOREDPBRI, "StoredGammaPreBrightness",OPTV_STRING, {0}, -1 }, + { OPTION_XVGAMMA, "XvGamma", OPTV_STRING, {0}, -1 }, { OPTION_XVDEFCONTRAST, "XvDefaultContrast", OPTV_INTEGER, {0}, -1 }, { OPTION_XVDEFBRIGHTNESS, "XvDefaultBrightness", OPTV_INTEGER, {0}, -1 }, { OPTION_XVDEFHUE, "XvDefaultHue", OPTV_INTEGER, {0}, -1 }, @@ -210,31 +235,27 @@ static const OptionInfoRec SISOptions[] = { { OPTION_XVYUVCHROMAKEY, "XvYUVChromaKey", OPTV_BOOLEAN, {0}, -1 }, { OPTION_XVDISABLECOLORKEY, "XvDisableColorKey", OPTV_BOOLEAN, {0}, -1 }, { OPTION_XVMEMCPY, "XvUseMemcpy", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_XVDEFAULTADAPTOR, "XvDefaultAdaptor", OPTV_STRING, {0}, -1 }, { OPTION_SCALELCD, "ScaleLCD", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_CENTERLCD, "CenterLCD", OPTV_BOOLEAN, {0}, -1 }, { OPTION_ENABLEHOTKEY, "EnableHotkey", OPTV_BOOLEAN, {0}, -1 }, - { OPTION_SPECIALTIMING, "SpecialTiming", OPTV_STRING, {0}, -1 }, - { OPTION_LVDSHL, "LVDSHL", OPTV_INTEGER, {0}, -1 }, { OPTION_ENABLESISCTRL, "EnableSiSCtrl", OPTV_BOOLEAN, {0}, -1 }, - { OPTION_STOREDBRIR, "StoredGammaBrightnessRed", OPTV_INTEGER, {0}, -1 }, - { OPTION_STOREDBRIG, "StoredGammaBrightnessGreen", OPTV_INTEGER, {0}, -1 }, - { OPTION_STOREDBRIB, "StoredGammaBrightnessBlue", OPTV_INTEGER, {0}, -1 }, - { OPTION_STOREDPBRIR, "StoredGammaPreBrightnessRed", OPTV_INTEGER, {0}, -1 }, - { OPTION_STOREDPBRIG, "StoredGammaPreBrightnessGreen", OPTV_INTEGER, {0}, -1 }, - { OPTION_STOREDPBRIB, "StoredGammaPreBrightnessBlue", OPTV_INTEGER, {0}, -1 }, #ifdef SISMERGED { OPTION_MERGEDFB, "MergedFB", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_CRT2HSYNC, "CRT2HSync", OPTV_ANYSTR, {0}, FALSE }, - { OPTION_CRT2VREFRESH, "CRT2VRefresh", OPTV_ANYSTR, {0}, FALSE }, - { OPTION_CRT2POS, "CRT2Position", OPTV_ANYSTR, {0}, FALSE }, - { OPTION_METAMODES, "MetaModes", OPTV_ANYSTR, {0}, FALSE }, - { OPTION_MERGEDFB2, "TwinView", OPTV_BOOLEAN, {0}, FALSE }, /* alias */ - { OPTION_CRT2HSYNC2, "SecondMonitorHorizSync", OPTV_ANYSTR, {0}, FALSE }, /* alias */ - { OPTION_CRT2VREFRESH2, "SecondMonitorVertRefresh", OPTV_ANYSTR, {0}, FALSE }, /* alias */ - { OPTION_CRT2POS2, "TwinViewOrientation", OPTV_ANYSTR, {0}, FALSE }, /* alias */ + { OPTION_MERGEDFB2, "TwinView", OPTV_BOOLEAN, {0}, FALSE }, /* alias */ + { OPTION_MERGEDFBAUTO, "MergedFBAuto", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_CRT2HSYNC, "CRT2HSync", OPTV_STRING, {0}, FALSE }, + { OPTION_CRT2HSYNC2, "SecondMonitorHorizSync", OPTV_STRING, {0}, FALSE }, /* alias */ + { OPTION_CRT2VREFRESH, "CRT2VRefresh", OPTV_STRING, {0}, FALSE }, + { OPTION_CRT2VREFRESH2, "SecondMonitorVertRefresh", OPTV_STRING, {0}, FALSE }, /* alias */ + { OPTION_CRT2POS, "CRT2Position", OPTV_STRING, {0}, FALSE }, + { OPTION_CRT2POS2, "TwinViewOrientation", OPTV_STRING, {0}, FALSE }, /* alias */ + { OPTION_METAMODES, "MetaModes", OPTV_STRING, {0}, FALSE }, + { OPTION_MERGEDDPI, "MergedDPI", OPTV_STRING, {0}, FALSE }, #ifdef SISXINERAMA { OPTION_NOSISXINERAMA, "NoMergedXinerama", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_CRT2ISSCRN0, "MergedXineramaCRT2IsScreen0", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_NOSISXINERAMA2, "NoTwinviewXineramaInfo", OPTV_BOOLEAN, {0}, FALSE }, /* alias */ + { OPTION_NOSISXINERAMA2, "NoTwinviewXineramaInfo", OPTV_BOOLEAN, {0}, FALSE }, /* alias */ + { OPTION_CRT2ISSCRN0, "MergedXineramaCRT2IsScreen0",OPTV_BOOLEAN,{0},FALSE }, #endif #endif #ifdef SIS_CP @@ -248,7 +269,6 @@ SiSOptions(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); MessageType from; -/* double temp; */ char *strptr; static const char *mybadparm = "\"%s\" is is not a valid parameter for option \"%s\"\n"; static const char *disabledstr = "disabled"; @@ -259,8 +279,7 @@ SiSOptions(ScrnInfoPtr pScrn) xf86CollectOptions(pScrn, NULL); /* Process the options */ - if(!(pSiS->Options = xalloc(sizeof(SISOptions)))) - return; + if(!(pSiS->Options = xalloc(sizeof(SISOptions)))) return; memcpy(pSiS->Options, SISOptions, sizeof(SISOptions)); @@ -270,7 +289,6 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->newFastVram = -1; pSiS->NoHostBus = FALSE; -/* pSiS->UsePCIRetry = TRUE; */ pSiS->TurboQueue = TRUE; #ifdef SISVRAMQ /* TODO: Option (315 series VRAM command queue) */ @@ -281,6 +299,8 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->HWCursor = TRUE; pSiS->Rotate = FALSE; pSiS->ShadowFB = FALSE; + pSiS->loadDRI = FALSE; + pSiS->agpWantedPages = AGP_PAGES; pSiS->VESA = -1; pSiS->NoXvideo = FALSE; pSiS->maxxfbmem = 0; @@ -290,6 +310,8 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->XvOnCRT2 = FALSE; pSiS->NoYV12 = -1; pSiS->PDC = -1; + pSiS->PDCA = -1; + pSiS->EMI = -1; pSiS->OptTVStand = -1; pSiS->OptROMUsage = -1; pSiS->noInternalModes = FALSE; @@ -319,19 +341,25 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->tvypos = 0; pSiS->tvxscale = 0; pSiS->tvyscale = 0; - pSiS->NonDefaultPAL = -1; + pSiS->NonDefaultPAL = pSiS->NonDefaultNTSC = -1; pSiS->chtvtype = -1; pSiS->restorebyset = TRUE; pSiS->nocrt2ddcdetection = FALSE; - pSiS->forcecrt2redetection = FALSE; + pSiS->forcecrt2redetection = TRUE; /* default changed since 13/09/2003 */ + pSiS->SenseYPbPr = TRUE; + pSiS->ForceCRT1Type = CRT1_VGA; pSiS->ForceCRT2Type = CRT2_DEFAULT; + pSiS->ForceYPbPrAR = TV_YPBPR169; pSiS->ForceTVType = -1; pSiS->CRT1gamma = TRUE; + pSiS->CRT1gammaGiven = FALSE; pSiS->CRT2gamma = TRUE; + pSiS->XvGamma = FALSE; + pSiS->XvGammaGiven = FALSE; pSiS->enablesisctrl = FALSE; if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { pSiS->XvDefBri = 10; - pSiS->XvDefCon = 5; + pSiS->XvDefCon = 2; } else { pSiS->XvDefBri = 0; pSiS->XvDefCon = 4; @@ -340,7 +368,9 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->XvDefSat = 0; pSiS->XvDefDisableGfx = FALSE; pSiS->XvDefDisableGfxLR = FALSE; + pSiS->XvDefAdaptorBlit = FALSE; pSiS->UsePanelScaler = -1; + pSiS->CenterLCD = -1; pSiS->XvUseMemcpy = TRUE; pSiS->XvUseChromaKey = FALSE; pSiS->XvDisableColorKey = FALSE; @@ -348,16 +378,19 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->XvYUVChromaKey = FALSE; pSiS->XvChromaMin = 0x000101fe; pSiS->XvChromaMax = 0x000101ff; + pSiS->XvGammaRed = pSiS->XvGammaGreen = pSiS->XvGammaBlue = + pSiS->XvGammaRedDef = pSiS->XvGammaGreenDef = pSiS->XvGammaBlueDef = 1000; pSiS->GammaBriR = pSiS->GammaBriG = pSiS->GammaBriB = 1000; pSiS->GammaPBriR = pSiS->GammaPBriG = pSiS->GammaPBriB = 1000; pSiS->HideHWCursor = FALSE; pSiS->HWCursorIsVisible = FALSE; #ifdef SISMERGED - pSiS->MergedFB = FALSE; + pSiS->MergedFB = pSiS->MergedFBAuto = FALSE; pSiS->CRT2Position = sisRightOf; pSiS->CRT2HSync = NULL; pSiS->CRT2VRefresh = NULL; pSiS->MetaModes = NULL; + pSiS->MergedFBXDPI = pSiS->MergedFBYDPI = 0; #ifdef SISXINERAMA pSiS->UseSiSXinerama = TRUE; pSiS->CRT2IsScrn0 = FALSE; @@ -384,6 +417,14 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->HWCursor = FALSE; } + /* DRI only supported on 300 series, + * so don't load DRI by default on + * others. + */ + if(pSiS->VGAEngine == SIS_300_VGA) { + pSiS->loadDRI = TRUE; + } + #if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) pSiS->OptUseColorCursor = 0; #else @@ -395,6 +436,7 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->OptUseColorCursor = 1; } #endif + if(pSiS->VGAEngine == SIS_300_VGA) { pSiS->AllowHotkey = 0; } else if(pSiS->VGAEngine == SIS_315_VGA) { @@ -403,28 +445,8 @@ SiSOptions(ScrnInfoPtr pScrn) /* Collect the options */ -#if 0 - /* PCI retry - What the heck is/was this for? */ - from = X_DEFAULT; - if(xf86GetOptValBool(pSiS->Options, OPTION_PCI_RETRY, &pSiS->UsePCIRetry)) { - from = X_CONFIG; - } - xf86DrvMsg(pScrn->scrnIndex, from, "PCI retry %s\n", - pSiS->UsePCIRetry ? enabledstr : disabledstr); -#endif - - /* Mem clock */ -#if 0 /* This is not used */ - if(xf86GetOptValFreq(pSiS->Options, OPTION_SET_MEMCLOCK, OPTUNITS_MHZ, - &temp)) { - pSiS->MemClock = (int)(temp * 1000.0); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Memory clock set to %.3f MHz\n", pSiS->MemClock/1000.0); - } -#endif - - /* FastVRAM (5597/5598, 6326 and 530/620 only) - */ + /* FastVRAM (5597/5598, 6326 and 530/620 only) + */ if((pSiS->VGAEngine == SIS_OLD_VGA) || (pSiS->VGAEngine == SIS_530_VGA)) { from = X_DEFAULT; if(xf86GetOptValBool(pSiS->Options, OPTION_FAST_VRAM, &pSiS->newFastVram)) { @@ -437,8 +459,8 @@ SiSOptions(ScrnInfoPtr pScrn) (pSiS->newFastVram ? "enabled (for read and write)" : disabledstr)); } - /* NoHostBus (5597/5598 only) - */ + /* NoHostBus (5597/5598 only) + */ if((pSiS->Chipset == PCI_CHIP_SIS5597)) { from = X_DEFAULT; if(xf86GetOptValBool(pSiS->Options, OPTION_NOHOSTBUS, &pSiS->NoHostBus)) { @@ -448,19 +470,19 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->NoHostBus ? disabledstr : enabledstr); } - /* MaxXFBMem - * This options limits the amount of video memory X uses for screen - * and off-screen buffers. This option should be used if using DRI - * is intended. The kernel framebuffer driver required for DRM will - * start its memory heap at 12MB if it detects more than 16MB, at 8MB if - * between 8 and 16MB are available, otherwise at 4MB. So, if the amount - * of memory X uses, a clash between the framebuffer's memory heap - * and X is avoided. The amount is to be specified in KB. - */ + /* MaxXFBMem + * This options limits the amount of video memory X uses for screen + * and off-screen buffers. This option should be used if using DRI + * is intended. The kernel framebuffer driver required for DRM will + * start its memory heap at 12MB if it detects more than 16MB, at 8MB if + * between 8 and 16MB are available, otherwise at 4MB. So, if the amount + * of memory X uses, a clash between the framebuffer's memory heap + * and X is avoided. The amount is to be specified in KB. + */ if(xf86GetOptValULong(pSiS->Options, OPTION_MAXXFBMEM, &pSiS->maxxfbmem)) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "MaxXFBMem: Framebuffer memory shall be limited to %d KB\n", + "MaxXFBMem: Framebuffer memory shall be limited to %ld KB\n", pSiS->maxxfbmem); pSiS->maxxfbmem *= 1024; } @@ -470,7 +492,7 @@ SiSOptions(ScrnInfoPtr pScrn) */ if(xf86ReturnOptValBool(pSiS->Options, OPTION_NOACCEL, FALSE)) { pSiS->NoAccel = TRUE; -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) pSiS->NoXvideo = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "2D Acceleration and Xv disabled\n"); #else @@ -584,9 +606,26 @@ SiSOptions(ScrnInfoPtr pScrn) if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { Bool val; if(xf86GetOptValBool(pSiS->Options, OPTION_MERGEDFB, &val)) { - if(val) pSiS->MergedFB = TRUE; + if(val) { + pSiS->MergedFB = TRUE; + pSiS->MergedFBAuto = FALSE; + } } else if(xf86GetOptValBool(pSiS->Options, OPTION_MERGEDFB2, &val)) { - if(val) pSiS->MergedFB = TRUE; + if(val) { + pSiS->MergedFB = TRUE; + pSiS->MergedFBAuto = FALSE; + } + } + + if(xf86GetOptValBool(pSiS->Options, OPTION_MERGEDFBAUTO, &val)) { + if(!pSiS->MergedFB) { + if(val) { + pSiS->MergedFB = pSiS->MergedFBAuto = TRUE; + } + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Option \"MergedFB\" overrules option \"MergedFBAuto\"\n"); + } } if(pSiS->MergedFB) { @@ -631,29 +670,32 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->MetaModes = xalloc(strlen(strptr) + 1); if(pSiS->MetaModes) memcpy(pSiS->MetaModes, strptr, strlen(strptr) + 1); } - if(pSiS->MetaModes) { - strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2HSYNC); - if(!strptr) { - strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2HSYNC2); - } - if(strptr) { - pSiS->CRT2HSync = xalloc(strlen(strptr) + 1); - if(pSiS->CRT2HSync) memcpy(pSiS->CRT2HSync, strptr, strlen(strptr) + 1); - } - strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2VREFRESH); - if(!strptr) { - strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2VREFRESH2); - } - if(strptr) { - pSiS->CRT2VRefresh = xalloc(strlen(strptr) + 1); - if(pSiS->CRT2VRefresh) memcpy(pSiS->CRT2VRefresh, strptr, strlen(strptr) + 1); + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2HSYNC); + if(!strptr) { + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2HSYNC2); + } + if(strptr) { + pSiS->CRT2HSync = xalloc(strlen(strptr) + 1); + if(pSiS->CRT2HSync) memcpy(pSiS->CRT2HSync, strptr, strlen(strptr) + 1); + } + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2VREFRESH); + if(!strptr) { + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2VREFRESH2); + } + if(strptr) { + pSiS->CRT2VRefresh = xalloc(strlen(strptr) + 1); + if(pSiS->CRT2VRefresh) memcpy(pSiS->CRT2VRefresh, strptr, strlen(strptr) + 1); + } + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_MERGEDDPI); + if(strptr) { + int val1 = 0, val2 = 0; + sscanf(strptr, "%d %d", &val1, &val2); + if(val1 && val2) { + pSiS->MergedFBXDPI = val1; + pSiS->MergedFBYDPI = val2; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "MergedDPI"); } - } else { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Option \"MergedFB\" (alias \"TwinView\") requires Option \"MetaModes\".\n"); - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "MergedFB (alias TwinView) mode disabled.\n"); - pSiS->MergedFB = FALSE; } #ifdef SISXINERAMA if(pSiS->MergedFB) { @@ -673,9 +715,9 @@ SiSOptions(ScrnInfoPtr pScrn) } #endif - /* Some options can only be specified in the Master Head's Device - * section. Here we give the user a hint in the log. - */ + /* Some options can only be specified in the Master Head's Device + * section. Here we give the user a hint in the log. + */ #ifdef SISDUALHEAD if((pSiS->DualHeadMode) && (pSiS->SecondHead)) { static const char *mystring = "Option \"%s\" is only accepted in Master Head's device section\n"; @@ -710,14 +752,34 @@ SiSOptions(ScrnInfoPtr pScrn) if(xf86GetOptValBool(pSiS->Options, OPTION_FORCECRT2REDETECTION, &val)) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "ForceCRT2ReDetection"); } + if(xf86GetOptValBool(pSiS->Options, OPTION_SENSEYPBPR, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "SenseYPbPr"); + } + if(xf86GetOptValString(pSiS->Options, OPTION_FORCE_CRT1TYPE)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "ForceCRT1Type"); + } if(xf86GetOptValString(pSiS->Options, OPTION_FORCE_CRT2TYPE)) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "ForceCRT2Type"); } + if(xf86GetOptValString(pSiS->Options, OPTION_YPBPRAR)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "YPbPrAspectRatio"); + } if(xf86GetOptValBool(pSiS->Options, OPTION_SCALELCD, &val)) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "ScaleLCD"); } - if(xf86GetOptValInteger(pSiS->Options, OPTION_PDC, &vali)) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "PanelDelayCompensation"); + if(xf86GetOptValBool(pSiS->Options, OPTION_CENTERLCD, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "CenterLCD"); + } + if((xf86GetOptValInteger(pSiS->Options, OPTION_PDC, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_PDCS, &vali))) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "PanelDelayCompensation (PDC)"); + } + if((xf86GetOptValInteger(pSiS->Options, OPTION_PDCA, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_PDCAS, &vali))) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "PanelDelayCompensation1 (PDC1)"); + } + if(xf86GetOptValInteger(pSiS->Options, OPTION_EMI, &vali)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "EMI"); } if(xf86GetOptValString(pSiS->Options, OPTION_SPECIALTIMING)) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "SpecialTiming"); @@ -759,15 +821,15 @@ SiSOptions(ScrnInfoPtr pScrn) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "TV related options are only accepted in Master Head's device section"); } - if(xf86GetOptValBool(pSiS->Options, OPTION_CRT1GAMMA, &val)) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "CRT1Gamma"); - } if(xf86GetOptValBool(pSiS->Options, OPTION_CRT2GAMMA, &val)) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "CRT2Gamma"); } if(xf86GetOptValBool(pSiS->Options, OPTION_XVONCRT2, &val)) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "XvOnCRT2"); } + if(xf86GetOptValString(pSiS->Options, OPTION_XVDEFAULTADAPTOR)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "XvDefaultAdaptor"); + } #ifdef SIS_CP SIS_CP_OPT_DH_WARN #endif @@ -870,19 +932,6 @@ SiSOptions(ScrnInfoPtr pScrn) val ? enabledstr : disabledstr); } - /* ForceCRT1 (300/315/330 series only) - * This option can be used to force CRT1 to be switched on/off. Its - * intention is mainly for old monitors that can't be detected - * automatically. This is only useful on machines with a video bridge. - * In normal cases, this option won't be necessary. - */ - if(xf86GetOptValBool(pSiS->Options, OPTION_FORCECRT1, &val)) { - pSiS->forceCRT1 = val ? 1 : 0; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "CRT1 shall be forced to %s\n", - val ? "ON" : "OFF"); - } - /* NoCRT2DDCDetection (315/330 series only) * If set to true, this disables CRT2 detection using DDC. This is * to avoid problems with not entirely DDC compiant LCD panels or @@ -910,6 +959,56 @@ SiSOptions(ScrnInfoPtr pScrn) } else pSiS->forcecrt2redetection = FALSE; } + /* SenseYPbPr (315/330 series only) + * If set to true, the driver will sense for YPbPr TV. This is + * inconvenient for folks connecting SVideo and CVBS at the same + * time, because this condition will be detected as YPbPr (since + * the TV output pins are shared). "False" will not sense for + * YPbPr and detect SVideo or CVBS only. + */ + if(xf86GetOptValBool(pSiS->Options, OPTION_SENSEYPBPR, &val)) { + if(val) pSiS->SenseYPbPr = TRUE; + else pSiS->SenseYPbPr = FALSE; + } + + + /* ForceCRT1Type (315/330 series only) + * Used for forcing the driver to initialize CRT1 as + * VGA (analog) or LCDA (for simultanious LCD and TV + * display) - on M650/651 and 661 or later with 301C/30xLV only! + */ + if(pSiS->VGAEngine == SIS_315_VGA) { + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_FORCE_CRT1TYPE); + if(strptr != NULL) { + if(!xf86NameCmp(strptr,"VGA")) { + pSiS->ForceCRT1Type = CRT1_VGA; + } else if( (!xf86NameCmp(strptr,"LCD")) || + (!xf86NameCmp(strptr,"LCDA")) || + (!xf86NameCmp(strptr,"DVI-D")) || + (!xf86NameCmp(strptr,"LCD-A")) ) { + pSiS->ForceCRT1Type = CRT1_LCDA; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "ForceCRT1Type"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Valid parameters are \"VGA\" or \"LCD\" (alias \"DVI-D\")\n"); + } + } + } + + /* ForceCRT1 (300/315/330 series only) + * This option can be used to force CRT1 to be switched on/off. Its + * intention is mainly for old monitors that can't be detected + * automatically. This is only useful on machines with a video bridge. + * In normal cases, this option won't be necessary. + */ + if(xf86GetOptValBool(pSiS->Options, OPTION_FORCECRT1, &val)) { + pSiS->forceCRT1 = val ? 1 : 0; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "CRT1 shall be forced %s\n", + val ? "ON" : "OFF"); + if(!pSiS->forceCRT1) pSiS->ForceCRT1Type = CRT1_VGA; + } + /* ForceCRT2Type (300/315/330 series only) * Used for forcing the driver to initialize a given * CRT2 device type. @@ -919,35 +1018,87 @@ SiSOptions(ScrnInfoPtr pScrn) if(strptr != NULL) { if(!xf86NameCmp(strptr,"TV")) pSiS->ForceCRT2Type = CRT2_TV; - else if(!xf86NameCmp(strptr,"SVIDEO")) { + else if( (!xf86NameCmp(strptr,"SVIDEO")) || + (!xf86NameCmp(strptr,"SVHS")) ) { pSiS->ForceCRT2Type = CRT2_TV; pSiS->ForceTVType = TV_SVIDEO; - } else if(!xf86NameCmp(strptr,"COMPOSITE")) { + } else if( (!xf86NameCmp(strptr,"COMPOSITE")) || + (!xf86NameCmp(strptr,"CVBS")) ) { pSiS->ForceCRT2Type = CRT2_TV; pSiS->ForceTVType = TV_AVIDEO; + } else if( (!xf86NameCmp(strptr,"COMPOSITE SVIDEO")) || /* Ugly, but shorter than a parsing function */ + (!xf86NameCmp(strptr,"COMPOSITE+SVIDEO")) || + (!xf86NameCmp(strptr,"SVIDEO+COMPOSITE")) || + (!xf86NameCmp(strptr,"SVIDEO COMPOSITE")) ) { + pSiS->ForceCRT2Type = CRT2_TV; + pSiS->ForceTVType = (TV_SVIDEO | TV_AVIDEO); } else if(!xf86NameCmp(strptr,"SCART")) { pSiS->ForceCRT2Type = CRT2_TV; pSiS->ForceTVType = TV_SCART; - } else if((!xf86NameCmp(strptr,"LCD")) || (!xf86NameCmp(strptr,"DVI-D"))) - pSiS->ForceCRT2Type = CRT2_LCD; - else if((!xf86NameCmp(strptr,"VGA")) || (!xf86NameCmp(strptr,"DVI-A"))) - pSiS->ForceCRT2Type = CRT2_VGA; - else if(!xf86NameCmp(strptr,"NONE")) + } else if((!xf86NameCmp(strptr,"LCD")) || (!xf86NameCmp(strptr,"DVI-D"))) { + if(pSiS->ForceCRT1Type == CRT1_VGA) { + pSiS->ForceCRT2Type = CRT2_LCD; + } else { + pSiS->ForceCRT2Type = 0; + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Can't set both CRT1 and CRT2 type to LCD; CRT2 disabled\n"); + } + } else if((!xf86NameCmp(strptr,"VGA")) || (!xf86NameCmp(strptr,"DVI-A"))) { + if(pSiS->ForceCRT1Type == CRT1_VGA) { + pSiS->ForceCRT2Type = CRT2_VGA; + } else { + pSiS->ForceCRT2Type = 0; + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "CRT2 can only be TV or off while CRT1 is LCD; CRT2 disabled\n"); + } + } else if(!xf86NameCmp(strptr,"NONE")) pSiS->ForceCRT2Type = 0; - else if(pSiS->Chipset == PCI_CHIP_SIS550) { - if(!xf86NameCmp(strptr,"DSTN")) { + else if((!xf86NameCmp(strptr,"DSTN")) && (pSiS->Chipset == PCI_CHIP_SIS550)) { + if(pSiS->ForceCRT1Type == CRT1_VGA) { pSiS->ForceCRT2Type = CRT2_LCD; pSiS->DSTN = TRUE; - } else if(!xf86NameCmp(strptr,"FSTN")) { + } + } else if((!xf86NameCmp(strptr,"FSTN")) && (pSiS->Chipset == PCI_CHIP_SIS550)) { + if(pSiS->ForceCRT1Type == CRT1_VGA) { pSiS->ForceCRT2Type = CRT2_LCD; pSiS->FSTN = TRUE; } +#ifdef ENABLE_YPBPR + } else if(!xf86NameCmp(strptr,"HIVISION")) { + pSiS->ForceCRT2Type = CRT2_TV; + pSiS->ForceTVType = TV_HIVISION; + } else if((!xf86NameCmp(strptr,"YPBPR1080I")) && (pSiS->VGAEngine == SIS_315_VGA)) { + pSiS->ForceCRT2Type = CRT2_TV; + pSiS->ForceTVType = TV_YPBPR; + pSiS->ForceYPbPrType = TV_YPBPR1080I; + } else if(((!xf86NameCmp(strptr,"YPBPR525I")) || (!xf86NameCmp(strptr,"YPBPR480I"))) && + (pSiS->VGAEngine == SIS_315_VGA)) { + pSiS->ForceCRT2Type = CRT2_TV; + pSiS->ForceTVType = TV_YPBPR; + pSiS->ForceYPbPrType = TV_YPBPR525I; + } else if(((!xf86NameCmp(strptr,"YPBPR525P")) || (!xf86NameCmp(strptr,"YPBPR480P"))) && + (pSiS->VGAEngine == SIS_315_VGA)) { + pSiS->ForceCRT2Type = CRT2_TV; + pSiS->ForceTVType = TV_YPBPR; + pSiS->ForceYPbPrType = TV_YPBPR525P; + } else if(((!xf86NameCmp(strptr,"YPBPR750P")) || (!xf86NameCmp(strptr,"YPBPR720P"))) && + (pSiS->VGAEngine == SIS_315_VGA)) { + pSiS->ForceCRT2Type = CRT2_TV; + pSiS->ForceTVType = TV_YPBPR; + pSiS->ForceYPbPrType = TV_YPBPR750P; +#endif } else { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "ForceCRT2Type"); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Valid parameters are \"LCD\" (=\"DVI-D\"), \"TV\", \"SVIDEO\", \"COMPOSITE\",\n" - "\t\"SCART\", \"VGA\" (=\"DVI-A\") or \"NONE\", on the SiS550 also \"DSTN\"\n" - "\tand \"FSTN\"\n"); + "\t\"SVIDEO+COMPOSITE\", \"SCART\", \"VGA\" (=\"DVI-A\") or \"NONE\"; on the SiS550\n" + "\talso \"DSTN\" and \"FSTN\"" +#ifdef ENABLE_YPBPR + "; on SiS 301/301B bridges also \"HIVISION\", and on\n" + "\tSiS315/330 series with 301C/30xLV bridge also \"YPBPR480I\", \"YPBPR480P\",\n" + "\t\"YPBPR720P\" and \"YPBPR1080I\"" +#endif + "\n"); } if(pSiS->ForceCRT2Type != CRT2_DEFAULT) @@ -955,6 +1106,23 @@ SiSOptions(ScrnInfoPtr pScrn) "CRT2 type shall be %s\n", strptr); } + if(pSiS->ForceTVType == TV_YPBPR) { + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_YPBPRAR); + if(strptr != NULL) { + if(!xf86NameCmp(strptr,"4:3LB")) + pSiS->ForceYPbPrAR = TV_YPBPR43LB; + else if(!xf86NameCmp(strptr,"4:3")) + pSiS->ForceYPbPrAR = TV_YPBPR43; + else if(!xf86NameCmp(strptr,"16:9")) + pSiS->ForceYPbPrAR = TV_YPBPR169; + else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "YPbPrAspectRatio"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Valid parameters are \"4:3LB\", \"4:3\" and \"16:9\"\n"); + } + } + } + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_SPECIALTIMING); if(strptr != NULL) { int i = 0; @@ -1015,8 +1183,24 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->UsePanelScaler ? disabledstr : enabledstr); } + /* CenterLCD (300/315/330 + SiS video bridge only) + * If LCD shall not be scaled, this selects whether 1:1 data + * will be sent to the output, or the image shall be centered + * on the LCD. For LVDS panels, screen will always be centered, + * since these have no built-in scaler. For TMDS, this is + * selectable. Non-centered means that the driver will pass + * 1:1 data to the output and that the panel will have to + * scale by itself (if supported by the panel). + */ + if(xf86GetOptValBool(pSiS->Options, OPTION_CENTERLCD, &val)) { + pSiS->CenterLCD = val ? 1 : 0; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Non-scaled LCD output will %sbe centered\n", + pSiS->CenterLCD ? "not " : ""); + } + /* PanelDelayCompensation (300/315/330 series only) - * This might be required if the LCD panel shows "small waves". + * This might be required if the LCD panel shows "small waves" + * or wrong colors. * The parameter is an integer, (on 300 series usually either * 4, 32 or 24; on 315 series + LV bridge usually 3 or 51) * Why this option? Simply because SiS did poor BIOS design. @@ -1024,20 +1208,49 @@ SiSOptions(ScrnInfoPtr pScrn) * particular machine. For most panels, the driver is able * to detect the correct value. However, some panels require * a different setting. For 300 series, the value given must - * be within the mask 0x3c. + * be within the mask 0x3c. For 661 and later, if must be + * within the range of 0 to 31. */ - if(xf86GetOptValInteger(pSiS->Options, OPTION_PDC, &pSiS->PDC)) { + { + int val = -1; + xf86GetOptValInteger(pSiS->Options, OPTION_PDC, &val); + xf86GetOptValInteger(pSiS->Options, OPTION_PDCS, &val); + if(val != -1) { + pSiS->PDC = val; if((pSiS->VGAEngine == SIS_300_VGA) && (pSiS->PDC & ~0x3c)) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Illegal PanelDelayCompensation parameter\n"); pSiS->PDC = -1; } else { + if(pSiS->VGAEngine == SIS_315_VGA) pSiS->PDC &= 0x1f; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Panel delay compensation shall be %d\n", + "Panel delay compensation shall be %d (for LCD=CRT2)\n", pSiS->PDC); } } + /* PanelDelayCompensation1 (315 series only) + * Same as above, but for LCD-via-CRT1 ("LCDA") + */ + if(pSiS->VGAEngine == SIS_315_VGA) { + val = -1; + xf86GetOptValInteger(pSiS->Options, OPTION_PDCA, &val); + xf86GetOptValInteger(pSiS->Options, OPTION_PDCAS, &val); + if(val != -1) { + pSiS->PDCA = val; + if(pSiS->PDCA > 0x1f) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Illegal PanelDelayCompensation1 (PDC1) parameter (0 <= PDC1 <= 31\n"); + pSiS->PDCA = -1; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Panel delay compensation shall be %d (for LCD=CRT1)\n", + pSiS->PDCA); + } + } + } + } + /* LVDSHL (300/315/330 series + 30xLV bridge only) * This might be required if the LCD panel is too dark. * The parameter is an integer from 0 to 3. @@ -1054,6 +1267,28 @@ SiSOptions(ScrnInfoPtr pScrn) } } + /* EMI (315/330 series + 302LV/302ELV bridge only) + * This might be required if the LCD panel loses sync on + * mode switches. So far, this problem should not show up + * due to the auto-detection (from reading the values set + * by the BIOS; however, the BIOS values are wrong sometimes + * such as in the case of some Compal machines with a + * 1400x1050, or some Inventec(Compaq) machines with a + * 1280x1024 panel. + * The parameter is an integer from 0 to 0x60ffffff. + */ + if(xf86GetOptValInteger(pSiS->Options, OPTION_EMI, &pSiS->EMI)) { + if((pSiS->EMI < 0) || (pSiS->EMI > 0x60ffffff)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Illegal EMI parameter, valid is 0 through 0x60ffffff\n"); + pSiS->EMI = -1; + } else { + pSiS->EMI &= 0x60ffffff; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "EMI will be 0x%04x\n", pSiS->EMI); + } + } + } @@ -1076,46 +1311,51 @@ SiSOptions(ScrnInfoPtr pScrn) (!xf86NameCmp(strptr,"PAL-N"))) { pSiS->OptTVStand = 1; pSiS->NonDefaultPAL = 0; + } else if((!xf86NameCmp(strptr,"NTSCJ")) || + (!xf86NameCmp(strptr,"NTSC-J"))) { + pSiS->OptTVStand = 0; + pSiS->NonDefaultNTSC = 1; } else if(!xf86NameCmp(strptr,"NTSC")) pSiS->OptTVStand = 0; else { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "TVStandard"); xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Valid parameters are \"PAL\", \"PALM\", \"PALN\" or \"NTSC\"\n"); + "Valid parameters are \"PAL\", \"PALM\", \"PALN\", \"NTSC\", \"NTSCJ\"\n"); } if(pSiS->OptTVStand != -1) { static const char *tvstdstr = "TV standard shall be %s\n"; if(pSiS->Chipset == PCI_CHIP_SIS6326) { pSiS->NonDefaultPAL = -1; + pSiS->NonDefaultNTSC = -1; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, tvstdstr, pSiS->OptTVStand ? "PAL" : "NTSC"); } else { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, tvstdstr, (pSiS->OptTVStand ? ( (pSiS->NonDefaultPAL == -1) ? "PAL" : - ((pSiS->NonDefaultPAL) ? "PALM" : "PALN") ) - : "NTSC")); + ((pSiS->NonDefaultPAL) ? "PALM" : "PALN") ) : + (pSiS->NonDefaultNTSC == -1) ? "NTSC" : "NTSCJ")); } } } } - /* CHTVType (315/330 series only) + /* CHTVType (315/330 series + Chrontel only) * Used for telling the driver if the TV output shall - * be i480 HDTV or SCART. + * be 525i YPbPr or SCART. */ if(pSiS->VGAEngine == SIS_315_VGA) { strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CHTVTYPE); if(strptr != NULL) { if(!xf86NameCmp(strptr,"SCART")) pSiS->chtvtype = 1; - else if(!xf86NameCmp(strptr,"HDTV")) + else if(!xf86NameCmp(strptr,"YPBPR525I")) pSiS->chtvtype = 0; else { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "CHTVType"); xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Valid parameters are \"SCART\" or \"HDTV\"\n"); + "Valid parameters are \"SCART\" or \"YPBPR525I\"\n"); } if(pSiS->chtvtype != -1) xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, @@ -1123,15 +1363,15 @@ SiSOptions(ScrnInfoPtr pScrn) } } - /* CHTVOverscan (300/315/330 series only) - * CHTVSuperOverscan (300/315/330 series only) - * These options are for overriding the BIOS option for - * TV Overscan. Some BIOS don't even have such an option. - * SuperOverscan is only supported with PAL. - * Both options are only effective on machines with a - * CHRONTEL TV encoder. SuperOverscan is only available - * on the 700x. - */ + /* CHTVOverscan (300/315/330 series only) + * CHTVSuperOverscan (300/315/330 series only) + * These options are for overriding the BIOS option for + * TV Overscan. Some BIOS don't even have such an option. + * SuperOverscan is only supported with PAL. + * Both options are only effective on machines with a + * CHRONTEL TV encoder. SuperOverscan is only available + * on the 700x. + */ if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { Bool val; if(xf86GetOptValBool(pSiS->Options, OPTION_CHTVOVERSCAN, &val)) { @@ -1147,8 +1387,8 @@ SiSOptions(ScrnInfoPtr pScrn) } } - /* Various parameters for TV output via SiS bridge, Chrontel or SiS6326 - */ + /* Various parameters for TV output via SiS bridge, Chrontel or SiS6326 + */ if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { int tmp = 0; xf86GetOptValInteger(pSiS->Options, OPTION_CHTVLUMABANDWIDTHCVBS, @@ -1276,27 +1516,29 @@ SiSOptions(ScrnInfoPtr pScrn) } } - /* CRT1Gamma - disable gamma correction for CRT1 - */ - { - Bool val; - from = X_DEFAULT; - if(xf86GetOptValBool(pSiS->Options, OPTION_CRT1GAMMA, &val)) { - from = X_CONFIG; - pSiS->CRT1gamma = val; - } - xf86DrvMsg(pScrn->scrnIndex, from, "CRT1 gamma correction is %s\n", - pSiS->CRT1gamma ? enabledstr : disabledstr); - } - - /* CRT2Gamma - disable gamma correction for CRT2 - */ + /* CRT2Gamma - enable/disable gamma correction for CRT2 + */ if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { Bool val; if(xf86GetOptValBool(pSiS->Options, OPTION_CRT2GAMMA, &val)) { pSiS->CRT2gamma = val; } } + + /* Default adaptor: Overlay (default) or Blitter */ + if(pSiS->VGAEngine == SIS_315_VGA) { + if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_XVDEFAULTADAPTOR))) { + if(!xf86NameCmp(strptr, "OVERLAY")) { + pSiS->XvDefAdaptorBlit = FALSE; + } else if(!xf86NameCmp(strptr, "BLITTER")) { + pSiS->XvDefAdaptorBlit = TRUE; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "XvDefaultAdaptor"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Valid parameters are \"OVERLAY\" or \"BLITTER\"\n"); + } + } + } #ifdef SIS_CP SIS_CP_OPT_DOOPT @@ -1304,13 +1546,22 @@ SiSOptions(ScrnInfoPtr pScrn) } /* DualHead */ - /* VESA - DEPRECATED - * This option is for forcing the driver to use - * the VESA BIOS extension for mode switching. - */ + /* CRT1Gamma - enable/disable gamma correction for CRT1 + */ { - Bool val; + Bool val; + if(xf86GetOptValBool(pSiS->Options, OPTION_CRT1GAMMA, &val)) { + pSiS->CRT1gamma = val; + pSiS->CRT1gammaGiven = TRUE; + } + } + /* VESA - DEPRECATED + * This option is for forcing the driver to use + * the VESA BIOS extension for mode switching. + */ + { + Bool val; if(xf86GetOptValBool(pSiS->Options, OPTION_VESA, &val)) { pSiS->VESA = val ? 1 : 0; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, @@ -1318,6 +1569,7 @@ SiSOptions(ScrnInfoPtr pScrn) val ? enabledstr : disabledstr); xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "*** Option \"VESA\" is deprecated. *** \n"); + if(pSiS->VESA) pSiS->ForceCRT1Type = CRT1_VGA; } } @@ -1331,10 +1583,10 @@ SiSOptions(ScrnInfoPtr pScrn) * generated out of the known and supported modes. Use * this option to disable this. NOT RECOMMENDED. */ - from = X_DEFAULT; - if(xf86GetOptValBool(pSiS->Options, OPTION_NOINTERNALMODES, &pSiS->noInternalModes)) + from = X_DEFAULT; + if(xf86GetOptValBool(pSiS->Options, OPTION_NOINTERNALMODES, &pSiS->noInternalModes)) from = X_CONFIG; - xf86DrvMsg(pScrn->scrnIndex, from, "Usage of built-in modes is %s\n", + xf86DrvMsg(pScrn->scrnIndex, from, "Usage of built-in modes is %s\n", pSiS->noInternalModes ? disabledstr : enabledstr); } @@ -1352,7 +1604,7 @@ SiSOptions(ScrnInfoPtr pScrn) } if(pSiS->ShadowFB) { pSiS->NoAccel = TRUE; -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) pSiS->NoXvideo = TRUE; xf86DrvMsg(pScrn->scrnIndex, from, "Using \"Shadow Frame Buffer\" - 2D acceleration and Xv disabled\n"); @@ -1384,7 +1636,7 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->ShadowFB = TRUE; pSiS->NoAccel = TRUE; pSiS->HWCursor = FALSE; -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) pSiS->NoXvideo = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Rotating screen %sclockwise; (2D acceleration and Xv disabled)\n", @@ -1405,10 +1657,38 @@ SiSOptions(ScrnInfoPtr pScrn) } } - /* NoXVideo - * Set this to TRUE to disable Xv hardware video acceleration - */ -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) +#ifdef XF86DRI + /* DRI */ + from = X_DEFAULT; + if(xf86GetOptValBool(pSiS->Options, OPTION_DRI, &pSiS->loadDRI)) { + from = X_CONFIG; + } + xf86DrvMsg(pScrn->scrnIndex, from, "DRI %s\n", + pSiS->loadDRI ? enabledstr : disabledstr); + + /* AGPSize */ + { + int vali; + Bool gotit = FALSE; + if(xf86GetOptValInteger(pSiS->Options, OPTION_AGP_SIZE, &vali)) { + gotit = TRUE; + } else if(xf86GetOptValInteger(pSiS->Options, OPTION_AGP_SIZE2, &vali)) { + gotit = TRUE; + } + if(gotit) { + if((vali >= 8) && (vali <= 512)) { + pSiS->agpWantedPages = (vali * 1024 * 1024) / AGP_PAGE_SIZE; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, "AGPSize (alias GARTSize)", 8, 512); + } + } + } +#endif + + /* NoXVideo + * Set this to TRUE to disable Xv hardware video acceleration + */ +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) if((!pSiS->NoAccel) && (!pSiS->NoXvideo)) { #else if(!pSiS->NoXvideo) { @@ -1532,40 +1812,103 @@ SiSOptions(ScrnInfoPtr pScrn) xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Xv will %suse memcpy()\n", val ? "" : "not "); } + + if(pSiS->VGAEngine == SIS_315_VGA) { + /* XvGamma - enable/disable gamma correction for Xv + * Supported for CRT1 only + */ + if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_XVGAMMA))) { + if( (!xf86NameCmp(strptr,"off")) || + (!xf86NameCmp(strptr,"false")) || + (!xf86NameCmp(strptr,"no")) || + (!xf86NameCmp(strptr,"0")) ) { + pSiS->XvGamma = FALSE; + pSiS->XvGammaGiven = TRUE; + } else if( (!xf86NameCmp(strptr,"on")) || + (!xf86NameCmp(strptr,"true")) || + (!xf86NameCmp(strptr,"yes")) || + (!xf86NameCmp(strptr,"1")) ) { + pSiS->XvGamma = pSiS->XvGammaGiven = TRUE; + } else { + float val1 = 0.0, val2 = 0.0, val3 = 0.0; + Bool valid = FALSE; + int result = sscanf(strptr, "%f %f %f", &val1, &val2, &val3); + if(result == 1) { + if((val1 >= 0.1) && (val1 <= 10.0)) { + pSiS->XvGammaGreen = pSiS->XvGammaBlue = pSiS->XvGammaRed = + pSiS->XvGammaGreenDef = pSiS->XvGammaBlueDef = pSiS->XvGammaRedDef = (int)(val1 * 1000); + valid = TRUE; + } + } else if(result == 3) { + if((val1 >= 0.1) && (val1 <= 10.0) && + (val2 >= 0.1) && (val2 <= 10.0) && + (val3 >= 0.1) && (val3 <= 10.0)) { + pSiS->XvGammaRed = pSiS->XvGammaRedDef = (int)(val1 * 1000); + pSiS->XvGammaGreen = pSiS->XvGammaGreenDef = (int)(val2 * 1000); + pSiS->XvGammaBlue = pSiS->XvGammaBlueDef = (int)(val3 * 1000); + valid = TRUE; + } + } + if(valid) { + pSiS->XvGamma = pSiS->XvGammaGiven = TRUE; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "XvGamma expects either a boolean, or 1 or 3 real numbers (0.1 - 10.0)\n"); + } + } + } + } } } if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - int tmp; - if(xf86GetOptValInteger(pSiS->Options, OPTION_STOREDBRIR, &tmp)) { - if((tmp >= 100) && (tmp <= 10000)) pSiS->GammaBriR = tmp; - else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, - "StoredGammaBrightnessRed", 100, 10000); - } - if(xf86GetOptValInteger(pSiS->Options, OPTION_STOREDBRIG, &tmp)) { - if((tmp >= 100) && (tmp <= 10000)) pSiS->GammaBriG = tmp; - else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, - "StoredGammaBrightnessGreen", 100, 10000); - } - if(xf86GetOptValInteger(pSiS->Options, OPTION_STOREDBRIB, &tmp)) { - if((tmp >= 100) && (tmp <= 10000)) pSiS->GammaBriB = tmp; - else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, - "StoredGammaBrightnessBlue", 100, 10000); - } - if(xf86GetOptValInteger(pSiS->Options, OPTION_STOREDPBRIR, &tmp)) { - if((tmp >= 100) && (tmp <= 10000)) pSiS->GammaPBriR = tmp; - else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, - "StoredGammaPreBrightnessRed", 100, 10000); - } - if(xf86GetOptValInteger(pSiS->Options, OPTION_STOREDPBRIG, &tmp)) { - if((tmp >= 100) && (tmp <= 10000)) pSiS->GammaPBriG = tmp; - else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, - "StoredGammaPreBrightnessGreen", 100, 10000); + if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_STOREDBRI))) { + float val1 = 0.0, val2 = 0.0, val3 = 0.0; + Bool valid = FALSE; + int result = sscanf(strptr, "%f %f %f", &val1, &val2, &val3); + if(result == 1) { + if((val1 >= 0.1) && (val1 <= 10.0)) { + valid = TRUE; + pSiS->GammaBriR = pSiS->GammaBriG = pSiS->GammaBriB = (int)(val1 * 1000); + } + } else if(result == 3) { + if((val1 >= 0.1) && (val1 <= 10.0) && + (val2 >= 0.1) && (val2 <= 10.0) && + (val3 >= 0.1) && (val3 <= 10.0)) { + valid = TRUE; + pSiS->GammaBriR = (int)(val1 * 1000); + pSiS->GammaBriG = (int)(val2 * 1000); + pSiS->GammaBriB = (int)(val3 * 1000); + } + } + if(!valid) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "StoredGammaBrightness expects 1 or 3 real numbers (0.1 - 10.0)\n"); + } } - if(xf86GetOptValInteger(pSiS->Options, OPTION_STOREDPBRIB, &tmp)) { - if((tmp >= 100) && (tmp <= 10000)) pSiS->GammaPBriB = tmp; - else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, - "StoredGammaPreBrightnessBlue", 100, 10000); + if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_STOREDPBRI))) { + float val1 = 0.0, val2 = 0.0, val3 = 0.0; + Bool valid = FALSE; + int result = sscanf(strptr, "%f %f %f", &val1, &val2, &val3); + if(result == 1) { + if((val1 >= 0.1) && (val1 <= 10.0)) { + valid = TRUE; + pSiS->GammaPBriR = pSiS->GammaPBriG = pSiS->GammaPBriB = (int)(val1 * 1000); + } + } else if(result == 3) { + if((val1 >= 0.1) && (val1 <= 10.0) && + (val2 >= 0.1) && (val2 <= 10.0) && + (val3 >= 0.1) && (val3 <= 10.0)) { + valid = TRUE; + pSiS->GammaPBriR = (int)(val1 * 1000); + pSiS->GammaPBriG = (int)(val2 * 1000); + pSiS->GammaPBriB = (int)(val3 * 1000); + } + } + if(!valid) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "\"StoredGammaPreBrightness\" expects 1 or 3 real numbers (0.1 - 10.0)\n"); + } } } diff --git a/src/sis_regs.h b/src/sis_regs.h index a1ee303..4e6230d 100644 --- a/src/sis_regs.h +++ b/src/sis_regs.h @@ -1,30 +1,39 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h,v 1.22 2003/09/04 15:32:44 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* - * 2D Acceleration for SiS300, SiS540, SiS630, SiS730, SiS530, SiS620 + * Register definitions for old and 300 series * - * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * 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. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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. + * + * Old series register definitions + * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England. + * + * Authors: Thomas Winischhofer + * Alan Hourihane * */ - /* For general use --------------------------------------------------------------- */ @@ -64,16 +73,16 @@ outSISIDXREG(base,idx,__Temp); \ } while (0) -#define BITMASK(h,l) (((unsigned)(1U << ((h)-(l)+1))-1)<<(l)) -#define GENMASK(mask) BITMASK(1?mask,0?mask) +#define BITMASK(h,l) (((unsigned)(1U << ((h)-(l)+1))-1)<<(l)) +#define GENMASK(mask) BITMASK(1?mask,0?mask) #define GETBITS(var,mask) (((var) & GENMASK(mask)) >> (0?mask)) #define SETBITS(val,mask) ((val) << (0?mask)) #define SETBIT(n) (1<<(n)) -#define GETBITSTR(val,from,to) ((GETBITS(val,from)) << (0?to)) -#define SETVARBITS(var,val,from,to) (((var)&(~(GENMASK(to)))) | \ - GETBITSTR(val,from,to)) +#define GETBITSTR(val,from,to) ((GETBITS(val,from)) << (0?to)) +#define SETVARBITS(var,val,from,to) (((var)&(~(GENMASK(to)))) | \ + GETBITSTR(val,from,to)) #define GETVAR8(var) ((var)&0xFF) #define SETVAR8(var,val) (var) = GETVAR8(val) @@ -283,13 +292,13 @@ #define Index_VI_SubPict_Scale_Control 0x3D /* (0x40 = enable/disable subpicture) */ -/* TW: Subpicture line buffer control */ +/* Subpicture line buffer control */ #define Index_VI_SubPict_Threshold 0x3E -/* TW: What is this? */ +/* What is this? */ #define Index_VI_FIFO_Max 0x3F -/* TW: Subpicture palette; 16 colors, total 32 bytes address space */ +/* Subpicture palette; 16 colors, total 32 bytes address space */ #define Index_VI_SubPict_Pal_Base_Low 0x40 #define Index_VI_SubPict_Pal_Base_High 0x41 @@ -299,7 +308,7 @@ #define Index_MPEG_Read_Ctrl2 0x62 /* MPEG auto flip */ #define Index_MPEG_Read_Ctrl3 0x63 /* MPEG auto flip */ -/* TW: MPEG AutoFlip scale */ +/* MPEG AutoFlip scale */ #define Index_MPEG_Ver_Up_Scale_Low 0x64 #define Index_MPEG_Ver_Up_Scale_High 0x65 @@ -309,9 +318,9 @@ #define Index_MPEG_UV_Buf_Preset_Middle 0x69 #define Index_MPEG_Y_UV_Buf_Preset_High 0x6A -/* TW: The following registers only exist on the 315 series */ +/* The following registers only exist on the 315 series */ -/* TW: Bit 16:24 of Y_U_V buf start address (?) */ +/* Bit 16:24 of Y_U_V buf start address */ #define Index_VI_Y_Buf_Start_Over 0x6B #define Index_VI_U_Buf_Start_Over 0x6C #define Index_VI_V_Buf_Start_Over 0x6D @@ -328,11 +337,18 @@ #define Index_VI_Control_Misc3 0x74 +/* 340: */ +/* DDA registers 0x75 - 0xb4 */ +/* threshold high 0xb5, 0xb6 */ +#define Index_VI_Line_Buffer_Size_High 0xb7 + + /* Bits in Scale control (0x1c) */ #define VI_Scale_Ctrl_Horiz_DDA 0x20 #define VI_Scale_Ctrl_Vert_DDA 0x40 -/* TW: Bits (and helpers) for Index_VI_Control_Misc0 */ +/* Bits (and helpers) for Index_VI_Control_Misc0 */ +#define VI_Misc0_Enable_Capture_AutoFlip 0x01 /* 340 only? */ #define VI_Misc0_Enable_Overlay 0x02 #define VI_Misc0_420_Plane_Enable 0x04 /* Select Plane or Packed mode */ #define VI_Misc0_422_Enable 0x20 /* Select 422 or 411 mode */ @@ -344,7 +360,7 @@ #define VI_Misc0_Fmt_NV12 0x4c /* (330 series only?) */ #define VI_Misc0_ChromaKeyRGBYUV 0x40 /* 300 series only: 0 = RGB, 1 = YUV */ -/* TW: Bits for Index_VI_Control_Misc1 */ +/* Bits for Index_VI_Control_Misc1 */ #define VI_Misc1_DisableGraphicsAtOverlay 0x01 /* Disables graphics display in overlay area */ #define VI_Misc1_BOB_Enable 0x02 /* Enable BOB de-interlacer */ #define VI_Misc1_Line_Merge 0x04 @@ -354,7 +370,7 @@ /* #define VI_Misc1_? 0x40 */ /* #define VI_Misc1_? 0x80 */ -/* TW: Bits for Index_VI_Control_Misc2 */ +/* Bits for Index_VI_Control_Misc2 */ #define VI_Misc2_Select_Video2 0x01 #define VI_Misc2_Video2_On_Top 0x02 #define VI_Misc2_DisableGraphics 0x04 /* Disable graphics display entirely (<= 650 only, not >= M650, 651) */ @@ -364,12 +380,12 @@ #define VI_Misc2_Auto_Flip_Enable 0x40 #define VI_Misc2_Video_Reg_Write_Enable 0x80 /* 315 series only? */ -/* TW: Bits for Index_VI_Control_Misc3 */ +/* Bits for Index_VI_Control_Misc3 */ #define VI_Misc3_Submit_Video_1 0x01 /* AKA "address ready" */ #define VI_Misc3_Submit_Video_2 0x02 /* AKA "address ready" */ #define VI_Misc3_Submit_SubPict 0x04 /* AKA "address ready" */ -/* TW: Values for Index_VI_Key_Overlay_OP (0x2F) */ +/* Values for Index_VI_Key_Overlay_OP (0x2F) */ #define VI_ROP_Never 0x00 #define VI_ROP_DestKey 0x03 #define VI_ROP_ChromaKey 0x05 @@ -461,10 +477,10 @@ #define Index_VI6326_Control_Misc5 0xBE /* (Datasheet: 530/620 ONLY - not correct) */ #define Index_VI6326_Control_Misc6 0xB2 /* 5597 and 6326 only! */ -/* TW: What is this? not a register, obviously */ +/* What is this? not a register, obviously */ #define Index_VI6326_FIFO_Max 0x3F -/* TW: Bits (and helpers) for Index_VI6326_Control_Misc0 */ +/* Bits (and helpers) for Index_VI6326_Control_Misc0 */ #define VI6326_Misc0_EnableCapture 0x01 /* 1 = on, 0 = off (6326 only) */ #define VI6326_Misc0_EnableOverlay 0x02 /* 1 = on, 0 = off */ #define VI6326_Misc0_VideoOnly 0x10 /* 1 = video only, 0 = gfx + video */ @@ -472,7 +488,7 @@ #define VI6326_Misc0_VideoFormat 0x40 /* 1 = YUV, 0 = RGB */ #define VI6326_Misc0_FieldPolarity 0x80 /* 1 = *Odd / Even, 0 = Odd / *Even (6326 only) */ -/* TW: Bits for Index_VI6326_Control_Misc1 (ALL 6326 ONLY) */ +/* Bits for Index_VI6326_Control_Misc1 (ALL 6326 ONLY) */ #define VI6326_Misc1_EnableYUVCapture 0x01 /* 0 = RGB, 1 = YUV */ #define VI6326_Misc1_EnableCaptureDithering 0x02 /* 0 = disable, 1 = enable */ #define VI6326_Misc1_CaptureFormat555 0x04 /* 1 = 555, 0 = 565 */ @@ -485,7 +501,7 @@ #define VI6326_Misc1_EnableVBSyncIRQ 0x40 /* 1 = Enable IRQ on vertical blank */ #define VI6326_Misc1_ClearVBSyncIRQ 0x80 /* Clear pending irq */ -/* TW: Bits for Index_VI6326_Control_Misc3 */ +/* Bits for Index_VI6326_Control_Misc3 */ #define VI6326_Misc3_UVCaptureFormat 0x01 /* 1 = 2's complement, 0 = CCIR 601 (6326 only) */ #define VI6326_Misc3_UVOverlayFormat 0x02 /* 1 = 2's complement, 0 = CCIR 601 */ #define VI6326_Misc3_ChromaKeyFormat 0x04 /* 1 = YUV, 0 = RGB */ @@ -495,7 +511,7 @@ #define VI6326_Misc3_BT819A 0x40 /* 1 = enable, 0 = disable (6326 only) */ #define VI6326_Misc3_SystemMemFB 0x80 /* 1 = enable, 0 = disable (6326 only) */ -/* TW: Bits for Index_VI6326_Control_Misc4 */ +/* Bits for Index_VI6326_Control_Misc4 */ #define VI6326_Misc4_CPUVideoFormatMask 0x03 #define VI6326_Misc4_CPUVideoFormatRGB555 0x00 #define VI6326_Misc4_CPUVideoFormatYUV422 0x01 @@ -503,12 +519,12 @@ #define VI6326_Misc4_EnableYUV420 0x04 /* 1 = enable, 0 = disable */ /** #define WHATISTHIS 0x40 */ -/* TW: Bits for Index_VI6326_Control_Misc5 (all 530/620 only) */ +/* Bits for Index_VI6326_Control_Misc5 (all 530/620 only) */ #define VI6326_Misc5_LineBufferMerge 0x10 /* 0 = disable, 1=enable */ #define VI6326_Misc5_VPlaneBit20 0x04 #define VI6326_Misc5_UPlaneBit20 0x02 -/* TW: Bits for Index_VI6326_Control_Misc6 (5597 and 6326 only) */ +/* Bits for Index_VI6326_Control_Misc6 (5597 and 6326 only) */ #define VI6326_Misc6_Decimation 0x80 /* 0=disable 1=enable video decimation */ /* Video format selection */ @@ -519,14 +535,14 @@ #define VI_6326_VideoRGB555 0x00 #define VI_6326_VideoRGB565 0x40 -/* TW: Values for Index_VI6326_Key_Overlay_OP */ +/* Values for Index_VI6326_Key_Overlay_OP */ #define VI6326_ROP_Never 0x00 #define VI6326_ROP_DestKey 0x03 #define VI6326_ROP_Always 0x0F /* --- end of 6326 video registers ---------------------------------- */ -/* TW register base (6326 only) */ +/* register base (6326 only) */ #define Index_TV6326_TVOutIndex 0xE0 #define Index_TV6326_TVOutData 0xE1 @@ -561,7 +577,7 @@ #define _VIN_FIELD_BOTH 4 -/* i2c registers (TW; not on 300/315 series) */ +/* i2c registers (not on 300/315 series) */ #define X_INDEXREG 0x14 #define X_PORTREG 0x15 #define X_DATA 0x0f @@ -572,7 +588,7 @@ /* mmio registers for video */ #define REG_PRIM_CRT_COUNTER 0x8514 -/* TW: MPEG MMIO registers (630 and later) ----------------------------------------- */ +/* MPEG MMIO registers (630 and later) ----------------------------------------- */ /* Not public (yet?) */ diff --git a/src/sis_setup.c b/src/sis_setup.c index 150ad12..019729f 100644 --- a/src/sis_setup.c +++ b/src/sis_setup.c @@ -1,28 +1,35 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c,v 1.18 2003/08/27 23:32:50 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Basic hardware and memory detection * - * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria. * - * 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. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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 + * Author: Thomas Winischhofer + * + * Ideas and methods for old series based on code by Can-Ru Yeou, SiS Inc. * */ @@ -58,12 +65,13 @@ static const char *dramTypeStr[] = { "SDR SDRAM", "SGRAM", "ESDRAM", - "DDR SDRAM", /* for 550/650 */ - "DDR SDRAM", /* for 550/650 */ - "VCM" /* for 630 */ + "DDR SDRAM", /* for 550/650/etc */ + "DDR SDRAM", /* for 550/650/etc */ + "VCM", /* for 630 */ + "DDR2 SDRAM", "" }; -/* TW: MCLK tables for SiS6326 */ +/* MCLK tables for SiS6326 */ static const int SiS6326MCLKIndex[4][8] = { { 10, 12, 14, 16, 17, 18, 19, 7 }, /* SGRAM */ { 4, 6, 8, 10, 11, 12, 13, 3 }, /* Fast Page */ @@ -110,7 +118,7 @@ sisOldSetup(ScrnInfoPtr pScrn) int ramtype[4] = { 5, 0, 1, 3 }; int config; int temp, i; - unsigned char sr23, sr33, sr34, sr37; + unsigned char sr23, sr33, sr37; #if 0 unsigned char newsr13, newsr28, newsr29; #endif @@ -160,7 +168,7 @@ sisOldSetup(ScrnInfoPtr pScrn) i = SiS6326MCLKIndex[i][temp]; pSiS->MemClock = SiS6326MCLK[i].mclk; #if 0 - /* TW: Correct invalid MCLK settings by old BIOSes */ + /* Correct invalid MCLK settings by old BIOSes */ newsr13 = SiS6326MCLK[i].sr13; newsr28 = SiS6326MCLK[i].sr28; newsr29 = SiS6326MCLK[i].sr29; @@ -193,7 +201,6 @@ sisOldSetup(ScrnInfoPtr pScrn) if(pSiS->oldChipset >= OC_SIS82204) { inSISIDXREG(SISSR, 0x23, sr23); inSISIDXREG(SISSR, 0x33, sr33); - inSISIDXREG(SISSR, 0x34, sr34); if(pSiS->oldChipset >= OC_SIS530A) sr33 &= ~0x08; if(sr33 & 0x09) { /* 5597: Sync DRAM timing | One cycle EDO ram; */ pSiS->Flags |= (sr33 & SYNCDRAM); /* 6326: Enable SGRam timing | One cycle EDO ram */ @@ -267,7 +274,7 @@ sis300Setup(ScrnInfoPtr pScrn) unsigned int config, pciconfig, sr3a, ramtype; unsigned char temp; int cpubuswidth; - int from = X_PROBED; + MessageType from = X_PROBED; pSiS->MemClock = SiSMclk(pSiS); @@ -345,7 +352,7 @@ sis300Setup(ScrnInfoPtr pScrn) pSiS->BusWidth); } -/* For 315, 315H, 315PRO, 330 */ +/* For 315, 315H, 315PRO, 330, 340 */ static void sis315Setup(ScrnInfoPtr pScrn) { @@ -355,14 +362,14 @@ sis315Setup(ScrnInfoPtr pScrn) int busDDRA[4] = {64+32, 64+32 , (64+32)*2, (64+32)*2}; unsigned int config, config1, config2, sr3a; char *dramTypeStr315[] = { - "Single Channel 1 rank SDR SDRAM", - "Single Channel 1 rank SDR SGRAM", - "Single Channel 1 rank DDR SDRAM", - "Single Channel 1 rank DDR SGRAM", - "Single Channel 2 rank SDR SDRAM", - "Single Channel 2 rank SDR SGRAM", - "Single Channel 2 rank DDR SDRAM", - "Single Channel 2 rank DDR SGRAM", + "Single channel 1 rank SDR SDRAM", + "Single channel 1 rank SDR SGRAM", + "Single channel 1 rank DDR SDRAM", + "Single channel 1 rank DDR SGRAM", + "Single channel 2 rank SDR SDRAM", + "Single channel 2 rank SDR SGRAM", + "Single channel 2 rank DDR SDRAM", + "Single channel 2 rank DDR SGRAM", "Asymmetric SDR SDRAM", "Asymmetric SDR SGRAM", "Asymmetric DDR SDRAM", @@ -388,6 +395,23 @@ sis315Setup(ScrnInfoPtr pScrn) "", "Dual channel DDR SDRAM", ""}; + char *dramTypeStr340[] = { + "Single channel 1 Rank DDR SDRAM", + "Single channel 1 Rank DDR2 SDRAM", + "Single channel 1 Rank DDR2x SDRAM", + "", + "Single channel 2 Rank DDR SDRAM", + "Single channel 2 Rank DDR2 SDRAM", + "Single channel 2 Rank DDR2x SDRAM", + "", + "Dual channel 1 rank DDR SDRAM", + "Dual channel 1 rank DDR2 SDRAM", + "Dual channel 1 rank DDR2x SDRAM", + "", + "Quad channel 1 rank DDR SDRAM", + "Quad channel 1 rank DDR2 SDRAM", + "Quad channel 1 rank DDR2x SDRAM", + ""}; inSISIDXREG(SISSR, 0x14, config); config1 = (config & 0x0C) >> 2; @@ -396,40 +420,75 @@ sis315Setup(ScrnInfoPtr pScrn) pScrn->videoRam = (1 << ((config & 0xF0) >> 4)) * 1024; - if(pSiS->Chipset == PCI_CHIP_SIS330) { + if(pSiS->Chipset == PCI_CHIP_SIS340) { + + pSiS->IsAGPCard = TRUE; + + if(config1 == 0x02) pScrn->videoRam <<= 1; /* dual rank */ + else if(config1 == 0x03) pScrn->videoRam <<= 2; /* quad rank */ + + inSISIDXREG(SISSR, 0x39, config2); + config2 &= 0x02; + if(!config2) { + inSISIDXREG(SISSR, 0x3a, config2); + config2 = (config2 & 0x02) >> 1; + } + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "DRAM type: %s\n", dramTypeStr340[(config1 * 4) + (config2 & 0x03)]); + + } else if(pSiS->Chipset == PCI_CHIP_SIS330) { pSiS->IsAGPCard = TRUE; if(config1) pScrn->videoRam <<= 1; + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "DRAM type: %s\n", dramTypeStr330[(config1 * 4) + (config2 & 0x02)]); } else { pSiS->IsAGPCard = ((sr3a & 0x30) == 0x30) ? FALSE : TRUE; /* If SINGLE_CHANNEL_2_RANK or DUAL_CHANNEL_1_RANK -> mem * 2 */ - if((config1 == 0x01) || (config1 == 0x03)) + if((config1 == 0x01) || (config1 == 0x03)) { pScrn->videoRam <<= 1; + } /* If DDR asymetric -> mem * 1,5 */ - if(config1 == 0x02) - pScrn->videoRam += pScrn->videoRam/2; + if(config1 == 0x02) pScrn->videoRam += pScrn->videoRam/2; + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "DRAM type: %s\n", dramTypeStr315[(config1 * 4) + config2]); } pSiS->MemClock = SiSMclk(pSiS); - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "DRAM type: %s\n", - (pSiS->Chipset == PCI_CHIP_SIS330) ? - dramTypeStr330[(config1 * 4) + (config2 & 0x02)] : - dramTypeStr315[(config1 * 4) + config2]); - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Memory clock: %3.3f MHz\n", pSiS->MemClock/1000.0); - /* TW: DDR -> mclk * 2 - needed for bandwidth calculation */ - if(pSiS->Chipset == PCI_CHIP_SIS330) { + /* DDR -> mclk * 2 - needed for bandwidth calculation */ + if(pSiS->Chipset == PCI_CHIP_SIS340) { + + pSiS->MemClock *= 2; /* at least DDR */ + + inSISIDXREG(SISCR,0x97,config); + if(!(config & 0x10)) { + inSISIDXREG(SISSR,0x39,config); + config = (config & 0x02) >> 1; + } else config &= 0x01; + + if(config) { + pSiS->MemClock *= 2; /* DDR2 ? */ + pSiS->BusWidth = 32; + } else { + pSiS->BusWidth = 64; + } + + } else if(pSiS->Chipset == PCI_CHIP_SIS330) { + if(config2 & 0x02) { pSiS->MemClock *= 2; if(config1 == 0x02) { @@ -444,7 +503,9 @@ sis315Setup(ScrnInfoPtr pScrn) pSiS->BusWidth = busSDR[(config & 0x02)]; } } + } else { + if(config2 & 0x02) pSiS->MemClock *= 2; if(config1 == 0x02) pSiS->BusWidth = busDDRA[(config & 0x03)]; @@ -452,6 +513,7 @@ sis315Setup(ScrnInfoPtr pScrn) pSiS->BusWidth = busDDR[(config & 0x03)]; else pSiS->BusWidth = busSDR[(config & 0x03)]; + } xf86DrvMsg(pScrn->scrnIndex, X_PROBED, @@ -459,7 +521,7 @@ sis315Setup(ScrnInfoPtr pScrn) pSiS->BusWidth); } -/* For 550, 65x, 74x, 660 */ +/* For 550, 65x, 740, 661, 741, 660, 760 */ static void sis550Setup(ScrnInfoPtr pScrn) { @@ -469,32 +531,106 @@ sis550Setup(ScrnInfoPtr pScrn) BOOLEAN alldone = FALSE; pSiS->IsAGPCard = TRUE; + pSiS->ChipFlags &= ~SiSCF_760UMA; pSiS->MemClock = SiSMclk(pSiS); if(pSiS->Chipset == PCI_CHIP_SIS660) { - /* TODO - this is entirely guessed */ + if(pSiS->sishw_ext.jChipType >= SIS_660) { - pciconfig = pciReadByte(0x00000000, 0x64); - if(pciconfig & 0x80) { - pScrn->videoRam = (1 << (((pciconfig & 0x70) >> 4) + 22)) / 1024; - pSiS->BusWidth = 64; - for(i=0; i<=3; i++) { - if(pciconfig & (1 << i)) { - temp = pciReadByte(0x00000000, 0x60 + i); - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "DIMM%d is %s SDRAM\n", - i, (temp & 0x40) ? "DDR" : "SDR"); - } else { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "DIMM%d is not installed\n", i); + /* UMA - shared fb */ + pciconfig = pciReadByte(0x00000000, 0x4c); + if(pciconfig & 0xe0) { + pScrn->videoRam = (1 << (((pciconfig & 0xe0) >> 5) - 2)) * 32768; + pSiS->ChipFlags |= SiSCF_760UMA; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "%dK shared video RAM (UMA)\n", + pScrn->videoRam); + } else pScrn->videoRam = 0; + + /* LFB - local framebuffer: PCI reg hold total RAM (but configurable in BIOS) */ + pciconfig = pciReadByte(0x00000800, 0xcd); + pciconfig = (pciconfig >> 1) & 0x03; + i = 0; + if(pciconfig == 0x01) i = 32768; + else if(pciconfig == 0x03) i = 65536; + if(i) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "%dK total local framebuffer RAM (LFB)\n", i); + } + + /* LFB: CR78 holds amount of LFB memory configured in the BIOS setup */ + inSISIDXREG(SISCR, 0x78, config); + config &= 0x30; + if(config) { + i = 0; + if(config == 0x10) i = 32768; + else if(config == 0x30) i = 65536; + if(i) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "%dK configured local framebuffer RAM (LFB)\n", i); + pScrn->videoRam += i; + pSiS->ChipFlags |= SiSCF_760LFB; } } - pciconfig = pciReadByte(0x00000000, 0x7c); - if(pciconfig & 0x02) ramtype = 8; - else ramtype = 4; - alldone = TRUE; + + if((pScrn->videoRam < 32768) || (pScrn->videoRam > 131072)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal video RAM size (%dK) detected, using BIOS provided setting\n", + pScrn->videoRam); + pSiS->ChipFlags &= ~(SiSCF_760LFB | SiSCF_760UMA); + } else { + pSiS->BusWidth = 64; + ramtype = 8; + alldone = TRUE; + } + + } else { + + int dimmnum; + + if(pSiS->sishw_ext.jChipType == SIS_741) { + dimmnum = 4; + } else { /* 661 */ + dimmnum = 3; + } + + pciconfig = pciReadByte(0x00000000, 0x64); + if(pciconfig & 0x80) { + pScrn->videoRam = (1 << (((pciconfig & 0x70) >> 4) - 1)) * 32768; + if((pScrn->videoRam < 32768) || (pScrn->videoRam > (128 * 1024))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal video RAM size (%dK) detected, using BIOS provided setting\n", + pScrn->videoRam); + } else { + pSiS->BusWidth = 64; + for(i=0; i<=(dimmnum - 1); i++) { + if(pciconfig & (1 << i)) { + temp = pciReadByte(0x00000000, 0x60 + i); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "DIMM%d is %s SDRAM\n", + i, (temp & 0x40) ? "DDR" : "SDR"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "DIMM%d is not installed\n", i); + } + } + pciconfig = pciReadByte(0x00000000, 0x7c); + ramtype = (pciconfig & 0x02) ? 8 : 4; +#if 0 + if(pSiS->sishw_ext.jChipType == SIS_741) { + /* Is this really correct? - Doesn't seem so*/ + ramtype = 12 - ramtype; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiS741 PCI RamType %d\n", ramtype); + /* For now, we don't trust it */ + inSISIDXREG(SISCR, 0x79, config); + ramtype = (config & 0x01) ? 8 : 4; + } +#endif + alldone = TRUE; + } + } + } } else if(pSiS->Chipset == PCI_CHIP_SIS650) { @@ -536,17 +672,42 @@ sis550Setup(ScrnInfoPtr pScrn) } + /* Fall back to BIOS detection results in case of problems: */ + if(!alldone) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Shared Memory Area is disabled - awaiting doom\n"); - inSISIDXREG(SISSR, 0x14, config); - pScrn->videoRam = (((config & 0x3F) + 1) * 4) * 1024; - if(pSiS->Chipset == PCI_CHIP_SIS650) { - ramtype = (((config & 0x80) >> 7) << 2) + 4; - pSiS->BusWidth = 64; /* (config & 0x40) ? 128 : 64; */ + + if(pSiS->Chipset == PCI_CHIP_SIS660) { + inSISIDXREG(SISCR, 0x79, config); + pSiS->BusWidth = (config & 0x04) ? 128 : 64; + ramtype = (config & 0x01) ? 8 : 4; + if(pSiS->sishw_ext.jChipType >= SIS_660) { + pScrn->videoRam = 0; + if(config & 0xf0) { + pScrn->videoRam = (1 << ((config & 0xf0) >> 4)) * 1024; + pSiS->ChipFlags |= SiSCF_760UMA; + } + inSISIDXREG(SISCR, 0x78, config); + config &= 0x30; + if(config) { + if(config == 0x10) pScrn->videoRam += 32768; + else pScrn->videoRam += 65536; + pSiS->ChipFlags |= SiSCF_760LFB; + } + } else { + pScrn->videoRam = (1 << ((config & 0xf0) >> 4)) * 1024; + } } else { - ramtype = 4; - pSiS->BusWidth = 64; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Shared Memory Area is disabled - awaiting doom\n"); + inSISIDXREG(SISSR, 0x14, config); + pScrn->videoRam = (((config & 0x3F) + 1) * 4) * 1024; + if(pSiS->Chipset == PCI_CHIP_SIS650) { + ramtype = (((config & 0x80) >> 7) << 2) + 4; + pSiS->BusWidth = 64; /* (config & 0x40) ? 128 : 64; */ + } else { + ramtype = 4; + pSiS->BusWidth = 64; + } } } @@ -562,7 +723,7 @@ sis550Setup(ScrnInfoPtr pScrn) "DRAM bus width: %d bit\n", pSiS->BusWidth); - /* TW: DDR -> Mclk * 2 - needed for bandwidth calculation */ + /* DDR -> Mclk * 2 - needed for bandwidth calculation */ if(ramtype == 8) pSiS->MemClock *= 2; } @@ -574,26 +735,27 @@ SiSSetup(ScrnInfoPtr pScrn) pSiS->Flags = 0; pSiS->VBFlags = 0; - switch (SISPTR(pScrn)->Chipset) { - case PCI_CHIP_SIS300: - case PCI_CHIP_SIS630: /* +730 */ - case PCI_CHIP_SIS540: + switch (SISPTR(pScrn)->Chipset) { + case PCI_CHIP_SIS300: + case PCI_CHIP_SIS630: /* +730 */ + case PCI_CHIP_SIS540: sis300Setup(pScrn); break; - case PCI_CHIP_SIS315: - case PCI_CHIP_SIS315H: - case PCI_CHIP_SIS315PRO: - case PCI_CHIP_SIS330: + case PCI_CHIP_SIS315: + case PCI_CHIP_SIS315H: + case PCI_CHIP_SIS315PRO: + case PCI_CHIP_SIS330: + case PCI_CHIP_SIS340: sis315Setup(pScrn); break; - case PCI_CHIP_SIS550: - case PCI_CHIP_SIS650: /* + 740 */ - case PCI_CHIP_SIS660: /* + 760 */ + case PCI_CHIP_SIS550: + case PCI_CHIP_SIS650: /* + 740,M650,651 */ + case PCI_CHIP_SIS660: /* + (M)661,(M)741,(M)760 */ sis550Setup(pScrn); break; - case PCI_CHIP_SIS5597: - case PCI_CHIP_SIS6326: - case PCI_CHIP_SIS530: + case PCI_CHIP_SIS5597: + case PCI_CHIP_SIS6326: + case PCI_CHIP_SIS530: default: sisOldSetup(pScrn); break; diff --git a/src/sis_shadow.c b/src/sis_shadow.c index 0e206b7..ee0f545 100644 --- a/src/sis_shadow.c +++ b/src/sis_shadow.c @@ -1,28 +1,31 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_shadow.c,v 1.7 2003/05/21 15:15:04 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* - * Copyright (c) 1999, The XFree86 Project Inc. - * based on code written by Mark Vojkovich + * Copyright (C) 1999-2004 by The XFree86 Project, Inc. + * based on code written by Mark Vojkovich + * + * Licensed under the following terms: * * 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 + * the above copyright notice appears in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * 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. + * "as is" without expressed or implied warranty. * * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * 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. * - * TW: This module doesn't use CurrentLayout, because it is never - * active when DGA is active and vice versa. + * TW: This module doesn't use CurrentLayout, because it is never + * active when DGA is active and vice versa. */ #include "xf86.h" @@ -36,97 +39,89 @@ #include "sis_shadow.h" +void +SISPointerMoved(int index, int x, int y) +{ + ScrnInfoPtr pScrn = xf86Screens[index]; + SISPtr pSiS = SISPTR(pScrn); + + if(pSiS->Rotate == 1) { + (*pSiS->PointerMoved)(index, pScrn->pScreen->height - y - 1, x); + } else { + (*pSiS->PointerMoved)(index, y, pScrn->pScreen->width - x - 1); + } +} + void SISRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { SISPtr pSiS = SISPTR(pScrn); - int width, height, Bpp, FBPitch; - unsigned char *src, *dst; + int width, height, Bpp, FBPitch; + CARD8 *src, *dst; Bpp = pScrn->bitsPerPixel >> 3; FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); while(num--) { - width = (pbox->x2 - pbox->x1) * Bpp; - height = pbox->y2 - pbox->y1; - src = pSiS->ShadowPtr + (pbox->y1 * pSiS->ShadowPitch) + - (pbox->x1 * Bpp); - dst = pSiS->FbBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); - - while(height--) { - memcpy(dst, src, width); - dst += FBPitch; - src += pSiS->ShadowPitch; - } + width = (pbox->x2 - pbox->x1) * Bpp; + height = pbox->y2 - pbox->y1; + src = pSiS->ShadowPtr + (pbox->y1 * pSiS->ShadowPitch) + (pbox->x1 * Bpp); + dst = pSiS->FbBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); + + while(height--) { + memcpy(dst, src, width); + dst += FBPitch; + src += pSiS->ShadowPitch; + } - pbox++; + pbox++; } } -void -SISPointerMoved(int index, int x, int y) -{ - ScrnInfoPtr pScrn = xf86Screens[index]; - SISPtr pSiS = SISPTR(pScrn); - int newX, newY; - - if(pSiS->Rotate == 1) { - newX = pScrn->pScreen->height - y - 1; - newY = x; - } else { - newX = y; - newY = pScrn->pScreen->width - x - 1; - } - - (*pSiS->PointerMoved)(index, newX, newY); -} - void SISRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { SISPtr pSiS = SISPTR(pScrn); - int count, width, height, y1, y2, dstPitch, srcPitch; - CARD8 *dstPtr, *srcPtr, *src; + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD8 *dstPtr, *srcPtr, *src; CARD32 *dst; dstPitch = pScrn->displayWidth; srcPitch = -pSiS->Rotate * pSiS->ShadowPitch; while(num--) { - width = pbox->x2 - pbox->x1; - y1 = pbox->y1 & ~3; - y2 = (pbox->y2 + 3) & ~3; - height = (y2 - y1) >> 2; /* in dwords */ - - if(pSiS->Rotate == 1) { - dstPtr = pSiS->FbBase + - (pbox->x1 * dstPitch) + pScrn->virtualX - y2; - srcPtr = pSiS->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; - } else { - dstPtr = pSiS->FbBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; - srcPtr = pSiS->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; - } - - while(width--) { - src = srcPtr; - dst = (CARD32*)dstPtr; - count = height; - while(count--) { - *(dst++) = src[0] | (src[srcPitch] << 8) | - (src[srcPitch * 2] << 16) | - (src[srcPitch * 3] << 24); - src += srcPitch * 4; - } - srcPtr += pSiS->Rotate; - dstPtr += dstPitch; - } - - pbox++; + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* in dwords */ + + if(pSiS->Rotate == 1) { + dstPtr = pSiS->FbBase + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = pSiS->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; + } else { + dstPtr = pSiS->FbBase + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = pSiS->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = (CARD32 *)dstPtr; + count = height; + while(count--) { + *(dst++) = src[0] | + (src[srcPitch] << 8) | + (src[srcPitch * 2] << 16) | + (src[srcPitch * 3] << 24); + src += (srcPitch * 4); + } + srcPtr += pSiS->Rotate; + dstPtr += dstPitch; + } + + pbox++; } } - void SISRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { @@ -139,89 +134,86 @@ SISRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) srcPitch = -pSiS->Rotate * pSiS->ShadowPitch >> 1; while(num--) { - width = pbox->x2 - pbox->x1; - y1 = pbox->y1 & ~1; - y2 = (pbox->y2 + 1) & ~1; - height = (y2 - y1) >> 1; /* in dwords */ - - if(pSiS->Rotate == 1) { - dstPtr = (CARD16*)pSiS->FbBase + - (pbox->x1 * dstPitch) + pScrn->virtualX - y2; - srcPtr = (CARD16*)pSiS->ShadowPtr + - ((1 - y2) * srcPitch) + pbox->x1; - } else { - dstPtr = (CARD16*)pSiS->FbBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; - srcPtr = (CARD16*)pSiS->ShadowPtr + - (y1 * srcPitch) + pbox->x2 - 1; - } - - while(width--) { - src = srcPtr; - dst = (CARD32*)dstPtr; - count = height; - while(count--) { - *(dst++) = src[0] | (src[srcPitch] << 16); - src += srcPitch * 2; - } - srcPtr += pSiS->Rotate; - dstPtr += dstPitch; - } - - pbox++; + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~1; + y2 = (pbox->y2 + 1) & ~1; + height = (y2 - y1) >> 1; /* in dwords */ + + if(pSiS->Rotate == 1) { + dstPtr = (CARD16 *)pSiS->FbBase + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = (CARD16 *)pSiS->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; + } else { + dstPtr = (CARD16 *)pSiS->FbBase + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = (CARD16 *)pSiS->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = (CARD32 *)dstPtr; + count = height; + while(count--) { + *(dst++) = src[0] | (src[srcPitch] << 16); + src += (srcPitch * 2); + } + srcPtr += pSiS->Rotate; + dstPtr += dstPitch; + } + + pbox++; } } - /* this one could be faster */ void SISRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { SISPtr pSiS = SISPTR(pScrn); - int count, width, height, y1, y2, dstPitch, srcPitch; - CARD8 *dstPtr, *srcPtr, *src; + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD8 *dstPtr, *srcPtr, *src; CARD32 *dst; dstPitch = BitmapBytePad(pScrn->displayWidth * 24); srcPitch = -pSiS->Rotate * pSiS->ShadowPitch; while(num--) { - width = pbox->x2 - pbox->x1; - y1 = pbox->y1 & ~3; - y2 = (pbox->y2 + 3) & ~3; - height = (y2 - y1) >> 2; /* blocks of 3 dwords */ - - if(pSiS->Rotate == 1) { - dstPtr = pSiS->FbBase + - (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); - srcPtr = pSiS->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); - } else { - dstPtr = pSiS->FbBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); - srcPtr = pSiS->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3; - } - - while(width--) { - src = srcPtr; - dst = (CARD32*)dstPtr; - count = height; - while(count--) { - dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | - (src[srcPitch] << 24); - dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) | - (src[srcPitch * 2] << 16) | - (src[(srcPitch * 2) + 1] << 24); - dst[2] = src[(srcPitch * 2) + 2] | (src[srcPitch * 3] << 8) | - (src[(srcPitch * 3) + 1] << 16) | - (src[(srcPitch * 3) + 2] << 24); - dst += 3; - src += srcPitch * 4; - } - srcPtr += pSiS->Rotate * 3; - dstPtr += dstPitch; - } - - pbox++; + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* blocks of 3 dwords */ + + if(pSiS->Rotate == 1) { + dstPtr = pSiS->FbBase + (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); + srcPtr = pSiS->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); + } else { + dstPtr = pSiS->FbBase + ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); + srcPtr = pSiS->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3; + } + + while(width--) { + src = srcPtr; + dst = (CARD32 *)dstPtr; + count = height; + while(count--) { + dst[0] = src[0] | + (src[1] << 8) | + (src[2] << 16) | + (src[srcPitch] << 24); + dst[1] = src[srcPitch + 1] | + (src[srcPitch + 2] << 8) | + (src[srcPitch * 2] << 16) | + (src[(srcPitch * 2) + 1] << 24); + dst[2] = src[(srcPitch * 2) + 2] | + (src[srcPitch * 3] << 8) | + (src[(srcPitch * 3) + 1] << 16) | + (src[(srcPitch * 3) + 2] << 24); + dst += 3; + src += (srcPitch << 2); + } + srcPtr += pSiS->Rotate * 3; + dstPtr += dstPitch; + } + + pbox++; } } @@ -229,40 +221,36 @@ void SISRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { SISPtr pSiS = SISPTR(pScrn); - int count, width, height, dstPitch, srcPitch; + int count, width, height, dstPitch, srcPitch; CARD32 *dstPtr, *srcPtr, *src, *dst; dstPitch = pScrn->displayWidth; srcPitch = -pSiS->Rotate * pSiS->ShadowPitch >> 2; while(num--) { - width = pbox->x2 - pbox->x1; - height = pbox->y2 - pbox->y1; - - if(pSiS->Rotate == 1) { - dstPtr = (CARD32*)pSiS->FbBase + - (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; - srcPtr = (CARD32*)pSiS->ShadowPtr + - ((1 - pbox->y2) * srcPitch) + pbox->x1; - } else { - dstPtr = (CARD32*)pSiS->FbBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; - srcPtr = (CARD32*)pSiS->ShadowPtr + - (pbox->y1 * srcPitch) + pbox->x2 - 1; - } - - while(width--) { - src = srcPtr; - dst = dstPtr; - count = height; - while(count--) { - *(dst++) = *src; - src += srcPitch; - } - srcPtr += pSiS->Rotate; - dstPtr += dstPitch; - } - - pbox++; + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + if(pSiS->Rotate == 1) { + dstPtr = (CARD32 *)pSiS->FbBase + (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; + srcPtr = (CARD32 *)pSiS->ShadowPtr + ((1 - pbox->y2) * srcPitch) + pbox->x1; + } else { + dstPtr = (CARD32 *)pSiS->FbBase + ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; + srcPtr = (CARD32 *)pSiS->ShadowPtr + (pbox->y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = dstPtr; + count = height; + while(count--) { + *(dst++) = *src; + src += srcPitch; + } + srcPtr += pSiS->Rotate; + dstPtr += dstPitch; + } + + pbox++; } } diff --git a/src/sis_vb.c b/src/sis_vb.c index 319df6a..4134f71 100644 --- a/src/sis_vb.c +++ b/src/sis_vb.c @@ -1,26 +1,31 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.c,v 1.19 2003/09/05 09:38:37 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Video bridge detection and configuration for 300, 315 and 330 series * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * 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. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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 * @@ -36,85 +41,107 @@ #include "sis_vb.h" #include "sis_dac.h" -extern void SISWaitRetraceCRT1(ScrnInfoPtr pScrn); +extern BOOLEAN SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceExtension); +extern USHORT SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS); +extern USHORT SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS); + +extern void SISDetermineLCDACap(ScrnInfoPtr pScrn); +extern void SISSaveDetectedDevices(ScrnInfoPtr pScrn); + +extern void SISWaitRetraceCRT1(ScrnInfoPtr pScrn); +extern unsigned char SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, unsigned char value); static const SiS_LCD_StStruct SiS300_LCD_Type[]= { - { VB_LCD_1024x768, 1024, 768, LCD_1024x768 }, /* 0 - invalid */ - { VB_LCD_800x600, 800, 600, LCD_800x600 }, /* 1 */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768 }, /* 2 */ - { VB_LCD_1280x1024,1280, 1024, LCD_1280x1024}, /* 3 */ - { VB_LCD_1280x960, 1280, 960, LCD_1280x960 }, /* 4 */ - { VB_LCD_640x480, 640, 480, LCD_640x480 }, /* 5 */ - { VB_LCD_1024x600, 1024, 600, LCD_1024x600 }, /* 6 */ - { VB_LCD_1152x768, 1152, 768, LCD_1152x768 }, /* 7 */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768 }, /* 8 */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768 }, /* 9 */ - { VB_LCD_1280x768, 1280, 768, LCD_1280x768 }, /* a */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768 }, /* b */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768 }, /* c */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768 }, /* d */ - { VB_LCD_320x480, 320, 480, LCD_320x480 }, /* e */ - { VB_LCD_CUSTOM, 0, 0, LCD_CUSTOM } /* f */ + { VB_LCD_1024x768, 1024, 768 }, /* 0 - invalid */ + { VB_LCD_800x600, 800, 600 }, /* 1 */ + { VB_LCD_1024x768, 1024, 768 }, /* 2 */ + { VB_LCD_1280x1024,1280, 1024 }, /* 3 */ + { VB_LCD_1280x960, 1280, 960 }, /* 4 */ + { VB_LCD_640x480, 640, 480 }, /* 5 */ + { VB_LCD_1024x600, 1024, 600 }, /* 6 */ + { VB_LCD_1152x768, 1152, 768 }, /* 7 */ + { VB_LCD_1024x768, 1024, 768 }, /* 8 */ + { VB_LCD_1024x768, 1024, 768 }, /* 9 */ + { VB_LCD_1280x768, 1280, 768 }, /* a */ + { VB_LCD_1024x768, 1024, 768 }, /* b */ + { VB_LCD_1024x768, 1024, 768 }, /* c */ + { VB_LCD_1024x768, 1024, 768 }, /* d */ + { VB_LCD_320x480, 320, 480 }, /* e */ + { VB_LCD_CUSTOM, 0, 0 } /* f */ }; static const SiS_LCD_StStruct SiS315_LCD_Type[]= { - { VB_LCD_1024x768, 1024, 768, LCD_1024x768 }, /* 0 - invalid */ - { VB_LCD_800x600, 800, 600, LCD_800x600 }, /* 1 */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768 }, /* 2 */ - { VB_LCD_1280x1024,1280, 1024, LCD_1280x1024 }, /* 3 */ - { VB_LCD_640x480, 640, 480, LCD_640x480 }, /* 4 */ - { VB_LCD_1024x600, 1024, 600, LCD_1024x600 }, /* 5 */ - { VB_LCD_1152x864, 1152, 864, LCD_1152x864 }, /* 6 */ - { VB_LCD_1280x960, 1280, 960, LCD_1280x960 }, /* 7 */ - { VB_LCD_1152x768, 1152, 768, LCD_1152x768 }, /* 8 */ - { VB_LCD_1400x1050,1400, 1050, LCD_1400x1050 }, /* 9 */ - { VB_LCD_1280x768, 1280, 768, LCD_1280x768 }, /* a */ - { VB_LCD_1600x1200,1600, 1200, LCD_1600x1200 }, /* b */ - { VB_LCD_640x480_2, 640, 480, LCD_640x480_2 }, /* c DSTN/FSTN */ - { VB_LCD_640x480_3, 640, 480, LCD_640x480_3 }, /* d DSTN/FSTN */ - { VB_LCD_320x480, 320, 480, LCD_320x480 }, /* e */ - { VB_LCD_CUSTOM, 0, 0, LCD_CUSTOM, } /* f */ + { VB_LCD_1024x768, 1024, 768 }, /* 0 - invalid */ + { VB_LCD_800x600, 800, 600 }, /* 1 */ + { VB_LCD_1024x768, 1024, 768 }, /* 2 */ + { VB_LCD_1280x1024,1280, 1024 }, /* 3 */ + { VB_LCD_640x480, 640, 480 }, /* 4 */ + { VB_LCD_1024x600, 1024, 600 }, /* 5 */ + { VB_LCD_1152x864, 1152, 864 }, /* 6 */ + { VB_LCD_1280x960, 1280, 960 }, /* 7 */ + { VB_LCD_1152x768, 1152, 768 }, /* 8 */ + { VB_LCD_1400x1050,1400, 1050 }, /* 9 */ + { VB_LCD_1280x768, 1280, 768 }, /* a */ + { VB_LCD_1600x1200,1600, 1200 }, /* b */ + { VB_LCD_640x480_2, 640, 480 }, /* c DSTN/FSTN */ + { VB_LCD_640x480_3, 640, 480 }, /* d DSTN/FSTN */ + { VB_LCD_320x480, 320, 480 }, /* e */ + { VB_LCD_CUSTOM, 0, 0 } /* f */ +}; + +static const SiS_LCD_StStruct SiS661_LCD_Type[]= +{ + { VB_LCD_1024x768, 1024, 768 }, /* 0 - invalid */ + { VB_LCD_800x600, 800, 600 }, /* 1 */ + { VB_LCD_1024x768, 1024, 768 }, /* 2 */ + { VB_LCD_1280x1024,1280, 1024 }, /* 3 */ + { VB_LCD_640x480, 640, 480 }, /* 4 */ + { VB_LCD_1024x600, 1024, 600 }, /* 5 */ + { VB_LCD_1152x864, 1152, 864 }, /* 6 */ + { VB_LCD_1280x960, 1280, 960 }, /* 7 */ + { VB_LCD_1152x768, 1152, 768 }, /* 8 */ + { VB_LCD_1400x1050,1400, 1050 }, /* 9 */ + { VB_LCD_1280x768, 1280, 768 }, /* a */ + { VB_LCD_1600x1200,1600, 1200 }, /* b */ + { VB_LCD_1280x800, 1280, 800 }, /* c */ + { VB_LCD_1680x1050,1680, 1050 }, /* d */ + { VB_LCD_1280x720, 1280, 720 }, /* e */ + { VB_LCD_CUSTOM, 0, 0 } /* f */ }; static Bool -SISTestMonitorType(ScrnInfoPtr pScrn, int r, int g, int b) +TestDDC1(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - unsigned short testval = (r * 77) + (g * 151) + (b * 28); - - if((testval & 0xff) > 0x80) testval += 0x100; - testval >>= 8; - - outSISREG(SISCOLIDX,0x00); - outSISREG(SISCOLDATA,testval); - outSISREG(SISCOLDATA,testval); - outSISREG(SISCOLDATA,testval); + unsigned short old; + int count = 48; - while(!(inSISREG(SISINPSTAT) & 0x01)) {} - while(inSISREG(SISINPSTAT) & 0x01) {} - - return((inSISREG(SISMISCW) & 0x10) ? TRUE : FALSE); + old = SiS_ReadDDC1Bit(pSiS->SiS_Pr); + do { + if(old != SiS_ReadDDC1Bit(pSiS->SiS_Pr)) break; + } while(count--); + return (count == -1) ? FALSE : TRUE; } static int -SISDetectCRT1(ScrnInfoPtr pScrn) +SiS_SISDetectCRT1(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - unsigned char SR1F,CR63=0,CR17,pel; - int i, ret=0; + unsigned short temp = 0xffff; + unsigned char SR1F, CR63=0, CR17; + int i, ret = 0; Bool mustwait = FALSE; inSISIDXREG(SISSR,0x1F,SR1F); - orSISIDXREG(SISSR,0x1F,0x04); - andSISIDXREG(SISSR,0x1F,0x3F); + setSISIDXREG(SISSR,0x1F,0x3f,0x04); if(SR1F & 0xc0) mustwait = TRUE; if(pSiS->VGAEngine == SIS_315_VGA) { - inSISIDXREG(SISCR,0x63,CR63); + inSISIDXREG(SISCR,pSiS->myCR63,CR63); CR63 &= 0x40; - andSISIDXREG(SISCR,0x63,0xBF); + andSISIDXREG(SISCR,pSiS->myCR63,0xbf); } inSISIDXREG(SISCR,0x17,CR17); @@ -129,35 +156,51 @@ SISDetectCRT1(ScrnInfoPtr pScrn) if(mustwait) { for(i=0; i < 10; i++) SISWaitRetraceCRT1(pScrn); } - - pel = inSISREG(SISPEL); - outSISREG(SISPEL,0xff); - - outSISREG(SISCOLIDX,0x00); - for(i = 0; i < (256 * 3); i++) { - outSISREG(SISCOLDATA,0x00); + + if(pSiS->sishw_ext.jChipType >= SIS_330) { + if(pSiS->sishw_ext.jChipType >= SIS_340) { + outSISIDXREG(SISCR, 0x57, 0x4a); + } else { + outSISIDXREG(SISCR, 0x57, 0x5f); + } + orSISIDXREG(SISCR, 0x53, 0x02); + while((inSISREG(SISINPSTAT)) & 0x01) break; + while(!((inSISREG(SISINPSTAT)) & 0x01)) break; + if((inSISREG(SISMISCW)) & 0x10) temp = 1; + andSISIDXREG(SISCR, 0x53, 0xfd); + andSISIDXREG(SISCR, 0x57, 0x00); +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "330: Found CRT1: %s\n", (temp == 1) ? "yes" : "no"); +#endif } - SISWaitRetraceCRT1(pScrn); - SISWaitRetraceCRT1(pScrn); - - if(SISTestMonitorType(pScrn, 0x0f, 0x0f, 0x0f)) ret |= 1; - if(SISTestMonitorType(pScrn, 0x0f, 0x0f, 0x0f)) ret |= 1; + if(temp == 0xffff) { + i = 3; + do { + temp = SiS_HandleDDC(pSiS->SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 0, 0, NULL); + } while(((temp == 0) || (temp == 0xffff)) && i--); - SISTestMonitorType(pScrn, 0x00, 0x00, 0x00); - - outSISREG(SISPEL,pel); + if((temp == 0) || (temp == 0xffff)) { + if(TestDDC1(pScrn)) temp = 1; + } + } + + if((temp) && (temp != 0xffff)) { + orSISIDXREG(SISCR,0x32,0x20); + ret = 1; + } else if(pSiS->sishw_ext.jChipType >= SIS_330) { + andSISIDXREG(SISCR,0x32,~0x20); + ret = 0; + } if(pSiS->VGAEngine == SIS_315_VGA) { - setSISIDXREG(SISCR,0x63,0xBF,CR63); + setSISIDXREG(SISCR,pSiS->myCR63,0xBF,CR63); } setSISIDXREG(SISCR,0x17,0x7F,CR17); outSISIDXREG(SISSR,0x1F,SR1F); - if(ret) orSISIDXREG(SISCR,0x32,0x20); - return ret; } @@ -170,84 +213,100 @@ void SISCRT1PreInit(ScrnInfoPtr pScrn) unsigned char OtherDevices = 0; if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) { - pSiS->CRT1off = 0; - return; + pSiS->CRT1off = 0; + return; } #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { - pSiS->CRT1off = 0; - return; + pSiS->CRT1off = 0; + return; } #endif #ifdef SISMERGED - if(pSiS->MergedFB) { - pSiS->CRT1off = 0; - return; + if((pSiS->MergedFB) && (!(pSiS->MergedFBAuto))) { + pSiS->CRT1off = 0; + return; } #endif inSISIDXREG(SISCR, 0x32, CR32); - if(CR32 & 0x20) CRT1Detected = 1; - else CRT1Detected = SISDetectCRT1(pScrn); + if(pSiS->sishw_ext.jChipType >= SIS_330) { + /* Works reliably on 330 and later */ + CRT1Detected = SiS_SISDetectCRT1(pScrn); + } else { + if(CR32 & 0x20) CRT1Detected = 1; + else CRT1Detected = SiS_SISDetectCRT1(pScrn); + } if(CR32 & 0x5F) OtherDevices = 1; if(pSiS->CRT1off == -1) { if(!CRT1Detected) { - /* BIOS detected no CRT1. */ + /* No CRT1 detected. */ /* If other devices exist, switch it off */ if(OtherDevices) pSiS->CRT1off = 1; else pSiS->CRT1off = 0; } else { - /* BIOS detected CRT1, leave/switch it on */ + /* CRT1 detected, leave/switch it on */ pSiS->CRT1off = 0; } } xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "%sCRT1 connection detected\n", + "%sCRT1 (VGA) connection detected\n", CRT1Detected ? "" : "No "); } /* Detect CRT2-LCD and LCD size */ -void SISLCDPreInit(ScrnInfoPtr pScrn) +void SISLCDPreInit(ScrnInfoPtr pScrn, Bool quiet) { SISPtr pSiS = SISPTR(pScrn); - unsigned char CR32, CR36, CR37; + unsigned char CR32, CR36, CR37, CR7D=0, tmp; + + pSiS->VBFlags &= ~(CRT2_LCD); + pSiS->VBLCDFlags = 0; + pSiS->LCDwidth = 0; + pSiS->LCDheight = 0; - if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) { - return; - } + if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) return; inSISIDXREG(SISCR, 0x32, CR32); if(CR32 & 0x08) pSiS->VBFlags |= CRT2_LCD; - /* TW: If no panel has been detected by the BIOS during booting, - * we try to detect it ourselves at this point. This is useful - * on machines with DVI connectors where the panel was - * connected after booting. This is only supported on the - * 315/330 series and the 301/30xB bridge (because the 30xLV/LVX - * don't seem to have a DDC port and operates only LVDS panels - * which mostly don't support DDC). We only do this if there was no - * secondary VGA detected by the BIOS, because LCD and VGA2 - * share the same DDC channel and might be misdetected as the - * wrong type (especially if the LCD panel only supports + /* If no panel has been detected by the BIOS during booting, + * we try to detect it ourselves at this point. We do that + * if forcecrt2redetection was given, too. + * This is useful on machines with DVI connectors where the + * panel was connected after booting. This is only supported + * on the 315/330 series and the 301/30xB/C bridge (because the + * 30xLV don't seem to have a DDC port and operate only LVDS + * panels which mostly don't support DDC). We only do this if + * there was no secondary VGA detected by the BIOS, because LCD + * and VGA2 share the same DDC channel and might be misdetected + * as the wrong type (especially if the LCD panel only supports * EDID Version 1). + * + * By default, CRT2 redetection is forced since 12/09/2003, as + * I encountered numerous panels which deliver more or less + * bogus DDC data confusing the BIOS. Since our DDC detection + * is waaaay better, we prefer it instead of the primitive + * and buggy BIOS method. */ #ifdef SISDUALHEAD if((!pSiS->DualHeadMode) || (!pSiS->SecondHead)) { #endif if((pSiS->VGAEngine == SIS_315_VGA) && (pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)) && - (!(pSiS->VBFlags & VB_30xBDH))) { + (!(pSiS->VBFlags & VB_30xBDH)) && + (!pSiS->VESA)) { if(pSiS->forcecrt2redetection) { pSiS->VBFlags &= ~CRT2_LCD; @@ -255,10 +314,12 @@ void SISLCDPreInit(ScrnInfoPtr pScrn) if(!(pSiS->nocrt2ddcdetection)) { if((!(pSiS->VBFlags & CRT2_LCD)) && (!(CR32 & 0x10))) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "%s LCD/Plasma panel, sensing via DDC\n", - pSiS->forcecrt2redetection ? - "Forced re-detection of" : "BIOS detected no"); + if(!quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "%s LCD/plasma panel, sensing via DDC\n", + pSiS->forcecrt2redetection ? + "Forced re-detection of" : "BIOS detected no"); + } if(SiS_SenseLCDDDC(pSiS->SiS_Pr, pSiS)) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC error during LCD panel detection\n"); @@ -269,7 +330,7 @@ void SISLCDPreInit(ScrnInfoPtr pScrn) pSiS->postVBCR32 |= 0x08; } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "No LCD/Plasma panel detected\n"); + "No LCD/plasma panel detected\n"); } } } @@ -283,6 +344,7 @@ void SISLCDPreInit(ScrnInfoPtr pScrn) if(pSiS->VBFlags & CRT2_LCD) { inSISIDXREG(SISCR, 0x36, CR36); inSISIDXREG(SISCR, 0x37, CR37); + inSISIDXREG(SISCR, 0x7D, CR7D); if(pSiS->SiS_Pr->SiS_CustomT == CUT_BARCO1366) { pSiS->VBLCDFlags |= VB_LCD_BARCO1366; pSiS->LCDwidth = 1360; @@ -299,12 +361,11 @@ void SISLCDPreInit(ScrnInfoPtr pScrn) pSiS->LCDwidth = pSiS->SiS_Pr->CP_MaxX = 848; pSiS->LCDheight = pSiS->SiS_Pr->CP_MaxY = 480; pSiS->VBLCDFlags |= VB_LCD_EXPANDING; - pSiS->sishw_ext.ulCRT2LCDType = LCD_848x480; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Assuming LCD/plasma panel (848x480, expanding, RGB24)\n"); } else { if((pSiS->VGAEngine == SIS_315_VGA) && (!CR36)) { - /* TW: Old 650/301LV BIOS version "forgot" to set CR36, CR37 */ + /* Old 650/301LV BIOS version "forgot" to set CR36, CR37 */ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "BIOS-provided LCD information invalid, probing myself...\n"); if(pSiS->VBFlags & VB_LVDS) pSiS->SiS_Pr->SiS_IF_DEF_LVDS = 1; @@ -317,10 +378,9 @@ void SISLCDPreInit(ScrnInfoPtr pScrn) pSiS->VBLCDFlags |= VB_LCD_CUSTOM; pSiS->LCDheight = pSiS->SiS_Pr->CP_MaxY; pSiS->LCDwidth = pSiS->SiS_Pr->CP_MaxX; - pSiS->sishw_ext.ulCRT2LCDType = LCD_CUSTOM; if(CR37 & 0x10) pSiS->VBLCDFlags |= VB_LCD_EXPANDING; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected non-standard LCD/Plasma panel (max. X %d Y %d, preferred %dx%d, RGB%d)\n", + "Detected LCD/Plasma panel (max. X %d Y %d, preferred %dx%d, RGB%d)\n", pSiS->SiS_Pr->CP_MaxX, pSiS->SiS_Pr->CP_MaxY, pSiS->SiS_Pr->CP_PreferredX, pSiS->SiS_Pr->CP_PreferredY, (CR37 & 0x01) ? 18 : 24); @@ -329,37 +389,51 @@ void SISLCDPreInit(ScrnInfoPtr pScrn) pSiS->VBLCDFlags |= SiS300_LCD_Type[(CR36 & 0x0f)].VBLCD_lcdflag; pSiS->LCDheight = SiS300_LCD_Type[(CR36 & 0x0f)].LCDheight; pSiS->LCDwidth = SiS300_LCD_Type[(CR36 & 0x0f)].LCDwidth; - pSiS->sishw_ext.ulCRT2LCDType = SiS300_LCD_Type[(CR36 & 0x0f)].LCDtype; if(CR37 & 0x10) pSiS->VBLCDFlags |= VB_LCD_EXPANDING; - } else { + } else if((pSiS->sishw_ext.jChipType >= SIS_661) || (pSiS->ROM661New)) { + pSiS->VBLCDFlags |= SiS661_LCD_Type[(CR36 & 0x0f)].VBLCD_lcdflag; + pSiS->LCDheight = SiS661_LCD_Type[(CR36 & 0x0f)].LCDheight; + pSiS->LCDwidth = SiS661_LCD_Type[(CR36 & 0x0f)].LCDwidth; + if(CR37 & 0x10) pSiS->VBLCDFlags |= VB_LCD_EXPANDING; + if(pSiS->sishw_ext.jChipType < SIS_661) { + if(!(pSiS->SiS_Pr->PanelSelfDetected)) { + inSISIDXREG(SISCR,0x35,tmp); + CR37 &= 0xfc; + CR37 |= (tmp & 0x01); + } + } + } else { pSiS->VBLCDFlags |= SiS315_LCD_Type[(CR36 & 0x0f)].VBLCD_lcdflag; pSiS->LCDheight = SiS315_LCD_Type[(CR36 & 0x0f)].LCDheight; pSiS->LCDwidth = SiS315_LCD_Type[(CR36 & 0x0f)].LCDwidth; - pSiS->sishw_ext.ulCRT2LCDType = SiS315_LCD_Type[(CR36 & 0x0f)].LCDtype; if(CR37 & 0x10) pSiS->VBLCDFlags |= VB_LCD_EXPANDING; } xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected LCD/Plasma panel (%dx%d, type %d, %sexpanding, RGB%d)\n", + "Detected LCD/plasma panel (%dx%d, %d, %sexp., RGB%d [%02x%02x%02x])\n", pSiS->LCDwidth, pSiS->LCDheight, - (pSiS->VGAEngine == SIS_315_VGA) ? ((CR36 & 0x0f) - 1) : ((CR36 & 0xf0) >> 4), + ((pSiS->VGAEngine == SIS_315_VGA) && + (!pSiS->NewCRLayout)) ? + ((CR36 & 0x0f) - 1) : ((CR36 & 0xf0) >> 4), (CR37 & 0x10) ? "" : "non-", - (CR37 & 0x01) ? 18 : 24); + (CR37 & 0x01) ? 18 : 24, + CR36, CR37, CR7D); } } } + } /* Detect CRT2-TV connector type and PAL/NTSC flag */ -void SISTVPreInit(ScrnInfoPtr pScrn) +void SISTVPreInit(ScrnInfoPtr pScrn, Bool quiet) { SISPtr pSiS = SISPTR(pScrn); - unsigned char SR16, SR38, CR32, CR38=0, CR79; + unsigned char SR16, SR38, CR32, CR35=0, CR38=0, CR79, CR39; int temp = 0; - - if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) - return; + + if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) return; inSISIDXREG(SISCR, 0x32, CR32); + inSISIDXREG(SISCR, 0x35, CR35); inSISIDXREG(SISSR, 0x16, SR16); inSISIDXREG(SISSR, 0x38, SR38); switch(pSiS->VGAEngine) { @@ -380,27 +454,64 @@ void SISTVPreInit(ScrnInfoPtr pScrn) CR32, SR16, SR38); #endif - if(CR32 & 0x47) - pSiS->VBFlags |= CRT2_TV; + if(CR32 & 0x47) pSiS->VBFlags |= CRT2_TV; - if(CR32 & 0x04) - pSiS->VBFlags |= TV_SCART; + if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTYPBPR) { + if(CR32 & 0x80) pSiS->VBFlags |= CRT2_TV; + } else { + CR32 &= 0x7f; + } + + if(CR32 & 0x01) + pSiS->VBFlags |= TV_AVIDEO; else if(CR32 & 0x02) pSiS->VBFlags |= TV_SVIDEO; - else if(CR32 & 0x01) - pSiS->VBFlags |= TV_AVIDEO; - else if(CR32 & 0x40) - pSiS->VBFlags |= (TV_SVIDEO | TV_HIVISION); - else if((CR38 & 0x04) && (pSiS->VBFlags & (VB_301LV | VB_302LV))) - pSiS->VBFlags |= TV_HIVISION_LV; - else if((CR38 & 0x04) && (pSiS->VBFlags & VB_CHRONTEL)) + else if(CR32 & 0x04) + pSiS->VBFlags |= TV_SCART; + else if((CR32 & 0x40) && (pSiS->SiS_SD_Flags & SiS_SD_SUPPORTHIVISION)) + pSiS->VBFlags |= (TV_HIVISION | TV_PAL); + else if((CR32 & 0x80) && (pSiS->SiS_SD_Flags & SiS_SD_SUPPORTYPBPR)) { + pSiS->VBFlags |= TV_YPBPR; + if(pSiS->NewCRLayout) { + if(CR38 & 0x04) { + switch(CR35 & 0xE0) { + case 0x20: pSiS->VBFlags |= TV_YPBPR525P; break; + case 0x40: pSiS->VBFlags |= TV_YPBPR750P; break; + case 0x60: pSiS->VBFlags |= TV_YPBPR1080I; break; + default: pSiS->VBFlags |= TV_YPBPR525I; + } + } else pSiS->VBFlags |= TV_YPBPR525I; + inSISIDXREG(SISCR,0x39,CR39); + CR39 &= 0x03; + if(CR39 == 0x00) pSiS->VBFlags |= TV_YPBPR43LB; + else if(CR39 == 0x01) pSiS->VBFlags |= TV_YPBPR43; + else if(CR39 == 0x02) pSiS->VBFlags |= TV_YPBPR169; + else pSiS->VBFlags |= TV_YPBPR43; + } else if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTYPBPR) { + if(CR38 & 0x08) { + switch(CR38 & 0x30) { + case 0x10: pSiS->VBFlags |= TV_YPBPR525P; break; + case 0x20: pSiS->VBFlags |= TV_YPBPR750P; break; + case 0x30: pSiS->VBFlags |= TV_YPBPR1080I; break; + default: pSiS->VBFlags |= TV_YPBPR525I; + } + } else pSiS->VBFlags |= TV_YPBPR525I; + if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTYPBPRAR) { + inSISIDXREG(SISCR,0x3B,CR39); + CR39 &= 0x03; + if(CR39 == 0x00) pSiS->VBFlags |= TV_YPBPR43LB; + else if(CR39 == 0x01) pSiS->VBFlags |= TV_YPBPR169; + else if(CR39 == 0x03) pSiS->VBFlags |= TV_YPBPR43; + } + } + } else if((CR38 & 0x04) && (pSiS->VBFlags & VB_CHRONTEL)) pSiS->VBFlags |= (TV_CHSCART | TV_PAL); else if((CR38 & 0x08) && (pSiS->VBFlags & VB_CHRONTEL)) - pSiS->VBFlags |= (TV_CHHDTV | TV_NTSC); - - if(pSiS->VBFlags & (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION | TV_HIVISION_LV)) { + pSiS->VBFlags |= (TV_CHYPBPR525I | TV_NTSC); + + if(pSiS->VBFlags & (TV_SCART | TV_SVIDEO | TV_AVIDEO)) { if(pSiS->VGAEngine == SIS_300_VGA) { - /* TW: Should be SR38, but this does not work. */ + /* Should be SR38, but this does not work. */ if(SR16 & 0x20) pSiS->VBFlags |= TV_PAL; else @@ -417,7 +528,7 @@ void SISTVPreInit(ScrnInfoPtr pScrn) else if(CR38 & 0x80) pSiS->VBFlags |= TV_PALN; } else pSiS->VBFlags |= TV_NTSC; - } else if((pSiS->Chipset == PCI_CHIP_SIS650) || (pSiS->Chipset == PCI_CHIP_SIS660)) { + } else if(pSiS->Chipset == PCI_CHIP_SIS650) { inSISIDXREG(SISCR, 0x79, CR79); if(CR79 & 0x20) { pSiS->VBFlags |= TV_PAL; @@ -425,6 +536,15 @@ void SISTVPreInit(ScrnInfoPtr pScrn) else if(CR38 & 0x80) pSiS->VBFlags |= TV_PALN; } else pSiS->VBFlags |= TV_NTSC; + } else if(pSiS->NewCRLayout) { + if(SR38 & 0x01) { + pSiS->VBFlags |= TV_PAL; + if(CR35 & 0x04) pSiS->VBFlags |= TV_PALM; + else if(CR35 & 0x08) pSiS->VBFlags |= TV_PALN; + } else { + pSiS->VBFlags |= TV_NTSC; + if(CR35 & 0x02) pSiS->VBFlags |= TV_NTSCJ; + } } else { /* 315, 330 */ if(SR38 & 0x01) { pSiS->VBFlags |= TV_PAL; @@ -434,30 +554,41 @@ void SISTVPreInit(ScrnInfoPtr pScrn) pSiS->VBFlags |= TV_NTSC; } } - - if(pSiS->VBFlags & (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION | TV_HIVISION_LV | TV_CHSCART | TV_CHHDTV)) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "%sTV standard %s\n", - (pSiS->VBFlags & (TV_CHSCART | TV_CHHDTV)) ? "Using " : "Detected default ", - (pSiS->VBFlags & TV_NTSC) ? - ((pSiS->VBFlags & TV_CHHDTV) ? "480i HDTV" : "NTSC") : - ((pSiS->VBFlags & TV_PALM) ? "PALM" : - ((pSiS->VBFlags & TV_PALN) ? "PALN" : "PAL"))); + + if((pSiS->VBFlags & (TV_SCART|TV_SVIDEO|TV_AVIDEO)) && !quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected default TV standard %s\n", + (pSiS->VBFlags & TV_NTSC) ? + ((pSiS->VBFlags & TV_NTSCJ) ? "NTSCJ" : "NTSC") : + ((pSiS->VBFlags & TV_PALM) ? "PALM" : + ((pSiS->VBFlags & TV_PALN) ? "PALN" : "PAL"))); + } + + if((pSiS->VBFlags & TV_HIVISION) && !quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "BIOS reports HiVision TV\n"); + } + + if((pSiS->VBFlags & VB_CHRONTEL) && (pSiS->VBFlags & (TV_CHSCART|TV_CHYPBPR525I)) && !quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Chrontel: %s forced\n", + (pSiS->VBFlags & TV_CHSCART) ? "SCART (PAL)" : "YPbPr (480i)"); + } + + if((pSiS->VBFlags & TV_YPBPR) && !quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected YPbPr TV (by default %s)\n", + (pSiS->VBFlags & TV_YPBPR525I) ? "480i" : + ((pSiS->VBFlags & TV_YPBPR525P) ? "480p" : + ((pSiS->VBFlags & TV_YPBPR750P) ? "720p" : "1080i"))); } } /* Detect CRT2-VGA */ -void SISCRT2PreInit(ScrnInfoPtr pScrn) +void SISCRT2PreInit(ScrnInfoPtr pScrn, Bool quiet) { SISPtr pSiS = SISPTR(pScrn); unsigned char CR32; - if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) - return; - - /* CRT2-VGA not supported on LVDS and 30xLV */ - if(pSiS->VBFlags & (VB_LVDS|VB_301LV|VB_302LV)) - return; + /* CRT2-VGA only supported on these bridges */ + if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) + return; inSISIDXREG(SISCR, 0x32, CR32); @@ -479,33 +610,474 @@ void SISCRT2PreInit(ScrnInfoPtr pScrn) * which is prone to be misdetected as a secondary VGA) */ if(!(pSiS->nocrt2ddcdetection)) { - if(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)) { - if(!(pSiS->VBFlags & (CRT2_VGA | CRT2_LCD))) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "%s secondary VGA, sensing via DDC\n", - pSiS->forcecrt2redetection ? - "Forced redetection of" : "BIOS detected no"); - if(SiS_SenseVGA2DDC(pSiS->SiS_Pr, pSiS)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + if(!(pSiS->VBFlags & (CRT2_VGA | CRT2_LCD))) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "%s secondary VGA, sensing via DDC\n", + pSiS->forcecrt2redetection ? + "Forced re-detection of" : "BIOS detected no"); + if(SiS_SenseVGA2DDC(pSiS->SiS_Pr, pSiS)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "DDC error during secondary VGA detection\n"); - } else { - inSISIDXREG(SISCR, 0x32, CR32); - if(CR32 & 0x10) { - pSiS->VBFlags |= CRT2_VGA; - pSiS->postVBCR32 |= 0x10; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + } else { + inSISIDXREG(SISCR, 0x32, CR32); + if(CR32 & 0x10) { + pSiS->VBFlags |= CRT2_VGA; + pSiS->postVBCR32 |= 0x10; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected secondary VGA connection\n"); - } else { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + } else { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "No secondary VGA connection detected\n"); - } } - } + } + } + } +#ifdef SISDUALHEAD + } +#endif +} + +static int +SISDoSense(ScrnInfoPtr pScrn, unsigned short type, unsigned short test) +{ + SISPtr pSiS = SISPTR(pScrn); + int temp, mytest, result, i, j; + +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "Sense: %x %x\n", type, test); +#endif + + for(j = 0; j < 10; j++) { + result = 0; + for(i = 0; i < 3; i++) { + mytest = test; + outSISIDXREG(SISPART4,0x11,(type & 0x00ff)); + temp = (type >> 8) | (mytest & 0x00ff); + setSISIDXREG(SISPART4,0x10,0xe0,temp); + SiS_DDC2Delay(pSiS->SiS_Pr, 0x1500); + mytest >>= 8; + mytest &= 0x7f; + inSISIDXREG(SISPART4,0x03,temp); + temp ^= 0x0e; + temp &= mytest; + if(temp == mytest) result++; +#if 1 + outSISIDXREG(SISPART4,0x11,0x00); + andSISIDXREG(SISPART4,0x10,0xe0); + SiS_DDC2Delay(pSiS->SiS_Pr, 0x1000); +#endif + } + if((result == 0) || (result >= 2)) break; + } + return(result); +} + +#define GETROMWORD(w) (pSiS->BIOS[w] | (pSiS->BIOS[w+1] << 8)) + +/* Sense connected devices on 30x */ +void +SISSense30x(ScrnInfoPtr pScrn, Bool quiet) +{ + SISPtr pSiS = SISPTR(pScrn); + unsigned char backupP4_0d,backupP2_00,backupP2_4d,backupSR_1e,biosflag=0; + unsigned short svhs=0, svhs_c=0; + unsigned short cvbs=0, cvbs_c=0; + unsigned short vga2=0, vga2_c=0; + int myflag, result; /* , i; */ + + if(!(pSiS->VBFlags & VB_SISBRIDGE)) return; + + if(pSiS->VBFlags & VB_301) { + svhs = 0x00b9; cvbs = 0x00b3; vga2 = 0x00d1; + inSISIDXREG(SISPART4,0x01,myflag); + if(myflag & 0x04) { + svhs = 0x00dd; cvbs = 0x00ee; vga2 = 0x00fd; + } + } else if(pSiS->VBFlags & (VB_301B | VB_302B)) { + svhs = 0x016b; cvbs = 0x0174; vga2 = 0x0190; + } else if(pSiS->VBFlags & (VB_301LV | VB_302LV)) { + svhs = 0x0200; cvbs = 0x0100; + } else if(pSiS->VBFlags & (VB_301C | VB_302ELV)) { + svhs = 0x016b; cvbs = 0x0110; vga2 = 0x0190; + } else return; + + vga2_c = 0x0e08; svhs_c = 0x0404; cvbs_c = 0x0804; + if(pSiS->VBFlags & (VB_301LV|VB_302LV|VB_302ELV)) { + svhs_c = 0x0408; cvbs_c = 0x0808; + } + biosflag = 2; + + if(pSiS->Chipset == PCI_CHIP_SIS300) { + inSISIDXREG(SISSR,0x3b,myflag); + if(!(myflag & 0x01)) vga2 = vga2_c = 0; + } + + if(pSiS->sishw_ext.UseROM) { + if(pSiS->VGAEngine == SIS_300_VGA) { + if(pSiS->VBFlags & VB_301) { + inSISIDXREG(SISPART4,0x01,myflag); + if(!(myflag & 0x04)) { + vga2 = GETROMWORD(0xf8); svhs = GETROMWORD(0xfa); cvbs = GETROMWORD(0xfc); + } + } + biosflag = pSiS->BIOS[0xfe]; + } else if((pSiS->Chipset == PCI_CHIP_SIS660) || + (pSiS->Chipset == PCI_CHIP_SIS340)) { + if(pSiS->ROM661New) { + biosflag = 2; + vga2 = GETROMWORD(0x63); svhs = cvbs = GETROMWORD(0x65); + if(pSiS->BIOS[0x5d] & 0x04) biosflag |= 0x01; + } + } else if(!pSiS->ROM661New) { +#if 0 /* eg. 1.15.23 has wrong values here */ + myflag = 0; + if(pSiS->VBFlags & VB_301) { + if(pSiS->Chipset == PCI_CHIP_SIS330) { + myflag = 0xe5; i = 0x11b; + } else { + myflag = 0xbd; i = 0xf3 + } + } else if(pSiS->VBFlags & (VB_301B|VB_302B|VB_301LV|VB_302LV)) { + if(pSiS->Chipset == PCI_CHIP_SIS330) { + myflag = 0xeb; i = 0x11b; + } else { + myflag = 0xc3; i = 0xf3 + } + } + if(myflag) { + biosflag = pSiS->BIOS[i]; vga2 = GETROMWORD(myflag); + svhs = GETROMWORD(myflag+2); cvbs = GETROMWORD(myflag+4); + } +#endif + } + } + + if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) { + vga2 = vga2_c = 0; + } + + inSISIDXREG(SISSR,0x1e,backupSR_1e); + orSISIDXREG(SISSR,0x1e,0x20); + + inSISIDXREG(SISPART4,0x0d,backupP4_0d); + if(pSiS->VBFlags & VB_301C) { + setSISIDXREG(SISPART4,0x0d,~0x07,0x01); + } else { + orSISIDXREG(SISPART4,0x0d,0x04); + } + SiS_DDC2Delay(pSiS->SiS_Pr, 0x2000); + + inSISIDXREG(SISPART2,0x00,backupP2_00); + outSISIDXREG(SISPART2,0x00,((backupP2_00 | 0x1c) & 0xfc)); + + inSISIDXREG(SISPART2,0x4d,backupP2_4d); + if(pSiS->VBFlags & (VB_301C|VB_301LV|VB_302LV|VB_302ELV)) { + outSISIDXREG(SISPART2,0x4d,(backupP2_4d & ~0x10)); + } + + if(!(pSiS->VBFlags & VB_301C)) { + SISDoSense(pScrn, 0, 0); + } + + andSISIDXREG(SISCR, 0x32, ~0x14); + pSiS->postVBCR32 &= ~0x14; + + if(vga2_c || vga2) { + if(SISDoSense(pScrn, vga2, vga2_c)) { + if(biosflag & 0x01) { + if(!quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiS30x: Detected TV connected to SCART output\n"); + } + pSiS->VBFlags |= TV_SCART; + orSISIDXREG(SISCR, 0x32, 0x04); + pSiS->postVBCR32 |= 0x04; + } else { + if(!quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiS30x: Detected secondary VGA connection\n"); + } + pSiS->VBFlags |= VGA2_CONNECTED; + orSISIDXREG(SISCR, 0x32, 0x10); + pSiS->postVBCR32 |= 0x10; + } + } + if(biosflag & 0x01) pSiS->SiS_SD_Flags |= SiS_SD_VBHASSCART; + } + + andSISIDXREG(SISCR, 0x32, 0x3f); + pSiS->postVBCR32 &= 0x3f; + + if(pSiS->VBFlags & VB_301C) { + orSISIDXREG(SISPART4,0x0d,0x04); + } + + if((pSiS->VGAEngine == SIS_315_VGA) && (pSiS->VBFlags & (VB_301C|VB_301LV|VB_302LV|VB_302ELV))) { + if(pSiS->SenseYPbPr) { + outSISIDXREG(SISPART2,0x4d,(backupP2_4d | 0x10)); + SiS_DDC2Delay(pSiS->SiS_Pr, 0x2000); + if((result = SISDoSense(pScrn, svhs, 0x0604))) { + if((result = SISDoSense(pScrn, cvbs, 0x0804))) { + if(!quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiS30x: Detected TV connected to YPbPr component output\n"); + } + orSISIDXREG(SISCR,0x32,0x80); + pSiS->VBFlags |= TV_YPBPR; + pSiS->postVBCR32 |= 0x80; + } + } + outSISIDXREG(SISPART2,0x4d,backupP2_4d); + } + } + + andSISIDXREG(SISCR, 0x32, ~0x03); + pSiS->postVBCR32 &= ~0x03; + + if(!(pSiS->VBFlags & TV_YPBPR)) { + + if((result = SISDoSense(pScrn, svhs, svhs_c))) { + if(!quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiS30x: Detected TV connected to SVIDEO output\n"); + } + pSiS->VBFlags |= TV_SVIDEO; + orSISIDXREG(SISCR, 0x32, 0x02); + pSiS->postVBCR32 |= 0x02; + } + + if((biosflag & 0x02) || (!result)) { + if(SISDoSense(pScrn, cvbs, cvbs_c)) { + if(!quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiS30x: Detected TV connected to COMPOSITE output\n"); + } + pSiS->VBFlags |= TV_AVIDEO; + orSISIDXREG(SISCR, 0x32, 0x01); + pSiS->postVBCR32 |= 0x01; } } } + + SISDoSense(pScrn, 0, 0); + + outSISIDXREG(SISPART2,0x00,backupP2_00); + outSISIDXREG(SISPART4,0x0d,backupP4_0d); + outSISIDXREG(SISSR,0x1e,backupSR_1e); + + if(pSiS->VBFlags & VB_301C) { + inSISIDXREG(SISPART2,0x00,biosflag); + if(biosflag & 0x20) { + for(myflag = 2; myflag > 0; myflag--) { + biosflag ^= 0x20; + outSISIDXREG(SISPART2,0x00,biosflag); + } + } + } + + outSISIDXREG(SISPART2,0x00,backupP2_00); } +void +SISSenseChrontel(ScrnInfoPtr pScrn, Bool quiet) +{ + SISPtr pSiS = SISPTR(pScrn); + int temp1=0, temp2, i; + unsigned char test[3]; + + if(pSiS->SiS_Pr->SiS_IF_DEF_CH70xx == 1) { + + /* Chrontel 700x */ + + /* Read power status */ + temp1 = SiS_GetCH700x(pSiS->SiS_Pr, 0x0e); /* Power status */ + if((temp1 & 0x03) != 0x03) { + /* Power all outputs */ + SiS_SetCH700x(pSiS->SiS_Pr, 0x0B0E); + SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); + } + /* Sense connected TV devices */ + for(i = 0; i < 3; i++) { + SiS_SetCH700x(pSiS->SiS_Pr, 0x0110); + SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); + SiS_SetCH700x(pSiS->SiS_Pr, 0x0010); + SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); + temp1 = SiS_GetCH700x(pSiS->SiS_Pr, 0x10); + if(!(temp1 & 0x08)) test[i] = 0x02; + else if(!(temp1 & 0x02)) test[i] = 0x01; + else test[i] = 0; + SiS_DDC2Delay(pSiS->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 { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Chrontel: TV detection unreliable - test results varied\n"); + temp1 = test[2]; + } + + } else if(pSiS->SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + + /* Chrontel 701x */ + + /* Backup Power register */ + temp1 = SiS_GetCH701x(pSiS->SiS_Pr, 0x49); + + /* Enable TV path */ + SiS_SetCH701x(pSiS->SiS_Pr, 0x2049); + + SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); + + /* Sense connected TV devices */ + temp2 = SiS_GetCH701x(pSiS->SiS_Pr, 0x20); + temp2 |= 0x01; + SiS_SetCH701x(pSiS->SiS_Pr, (temp2 << 8) | 0x20); + + SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); + + temp2 ^= 0x01; + SiS_SetCH701x(pSiS->SiS_Pr, (temp2 << 8) | 0x20); + + SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); + + temp2 = SiS_GetCH701x(pSiS->SiS_Pr, 0x20); + + /* Restore Power register */ + SiS_SetCH701x(pSiS->SiS_Pr, (temp1 << 8) | 0x49); + + temp1 = 0; + if(temp2 & 0x02) temp1 |= 0x01; + if(temp2 & 0x10) temp1 |= 0x01; + if(temp2 & 0x04) temp1 |= 0x02; + + if( (temp1 & 0x01) && (temp1 & 0x02) ) temp1 = 0x04; + + } + + switch(temp1) { + case 0x01: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Chrontel: Detected TV connected to COMPOSITE output\n"); + pSiS->VBFlags |= TV_AVIDEO; + orSISIDXREG(SISCR, 0x32, 0x01); + andSISIDXREG(SISCR, 0x32, ~0x06); + pSiS->postVBCR32 |= 0x01; + pSiS->postVBCR32 &= ~0x06; + break; + case 0x02: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Chrontel: Detected TV connected to SVIDEO output\n"); + pSiS->VBFlags |= TV_SVIDEO; + orSISIDXREG(SISCR, 0x32, 0x02); + andSISIDXREG(SISCR, 0x32, ~0x05); + pSiS->postVBCR32 |= 0x02; + pSiS->postVBCR32 &= ~0x05; + break; + case 0x04: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Chrontel: Detected TV connected to SCART or YPBPR output\n"); + if(pSiS->chtvtype == -1) { + if(!quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Chrontel: Use CHTVType option to select either SCART or YPBPR525I\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Chrontel: Using SCART by default\n"); + } + pSiS->chtvtype = 1; + } + if(pSiS->chtvtype) + pSiS->VBFlags |= TV_CHSCART; + else + pSiS->VBFlags |= TV_CHYPBPR525I; + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Chrontel: No TV detected.\n"); + andSISIDXREG(SISCR, 0x32, ~0x07); + pSiS->postVBCR32 &= ~0x07; + } +} + +/* Redetect CRT2 devices. Calling this requires a reset + * of the current display mode if TRUE is returned. + */ +Bool SISRedetectCRT2Type(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + unsigned long VBFlagsBackup = pSiS->VBFlags; + Bool backup1 = pSiS->forcecrt2redetection; + Bool backup2 = pSiS->nocrt2ddcdetection; + +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) return FALSE; +#endif + + pSiS->VBFlags &= (VB_VIDEOBRIDGE | DISPLAY_MODE); + + /* At first, re-do the sensing for TV and VGA2 */ + if(pSiS->VBFlags & VB_SISBRIDGE) { + SISSense30x(pScrn, FALSE); + } else if(pSiS->VBFlags & VB_CHRONTEL) { + SiS_SetChrontelGPIO(pSiS->SiS_Pr, 0x9c); + SISSenseChrontel(pScrn, TRUE); + SiS_SetChrontelGPIO(pSiS->SiS_Pr, 0x00); + } + + SISTVPreInit(pScrn, TRUE); + + pSiS->forcecrt2redetection = TRUE; + pSiS->nocrt2ddcdetection = FALSE; + + /* We only re-detect LCD for the TMDS-SiS-bridges. LVDS + * is practically never being hot-plugged (and even if, + * there is no way of detecting this). + */ + if((pSiS->VGAEngine == SIS_315_VGA) && + (pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)) && + (!(pSiS->VBFlags & VB_30xBDH)) && + (!pSiS->VESA)) { + SISLCDPreInit(pScrn, TRUE); + } else { + pSiS->VBFlags |= (pSiS->detectedCRT2Devices & CRT2_LCD); + } + + /* Secondary VGA is only supported on these bridges: */ + if(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)) { + SISCRT2PreInit(pScrn, TRUE); + } + + pSiS->forcecrt2redetection = backup1; + pSiS->nocrt2ddcdetection = backup2; + + SISDetermineLCDACap(pScrn); + SISSaveDetectedDevices(pScrn); + + pSiS->VBFlags = VBFlagsBackup; + + /* If LCD disappeared, don't use it and don't advertise LCDA support. Duh! */ + if(!(pSiS->detectedCRT2Devices & CRT2_LCD)) { + pSiS->SiS_SD_Flags &= ~(SiS_SD_SUPPORTLCDA); + if(pSiS->VBFlags & CRT2_LCD) { + /* If CRT2 was LCD, disable CRT2 and adapt display mode flags */ + pSiS->VBFlags &= ~(CRT2_LCD | DISPLAY_MODE); + /* Switch on CRT1 as an emergency measure */ + pSiS->VBFlags |= (SINGLE_MODE | DISPTYPE_CRT1); + pSiS->CRT1off = 0; + } + /* If CRT1 was LCD, switch to CRT1-VGA. No need to adapt display mode flags. */ + pSiS->VBFlags &= ~(CRT1_LCDA); + pSiS->VBFlags_backup = pSiS->VBFlags; + } + + /* Save new detection result registers to write them back in EnterVT() */ + inSISIDXREG(SISCR,0x32,pSiS->myCR32); + inSISIDXREG(SISCR,0x36,pSiS->myCR36); + inSISIDXREG(SISCR,0x37,pSiS->myCR37); + + return TRUE; +} diff --git a/src/sis_vga.c b/src/sis_vga.c index 0e0ce37..c7b551c 100644 --- a/src/sis_vga.c +++ b/src/sis_vga.c @@ -1,32 +1,38 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c,v 1.28 2003/09/04 15:32:45 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Mode setup and basic video bridge detection * - * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria. * - * Init() function for old series (except for TV and FIFO calculation) based - * on code which was Copyright 1998,1999 by Alan Hourihane, Wigan, England. + * The SISInit() function for old series (except TV and FIFO calculation) + * was previously based on code which was Copyright (C) 1998,1999 by Alan + * Hourihane, Wigan, England. However, the code has been rewritten entirely + * and is - it its current representation - not covered by this old copyright. * - * 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. + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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. * - * Authors: Thomas Winischhofer - * ... + * Author: Thomas Winischhofer * */ @@ -41,18 +47,14 @@ #include "sis_regs.h" #include "sis_dac.h" -#if 0 -#define TV6326TEST -#endif - static Bool SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode); static Bool SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode); -/* To be used internally only */ -int SISDoSense(ScrnInfoPtr pScrn, int tempbl, int tempbh, int tempcl, int tempch); -void SISSense30x(ScrnInfoPtr pScrn); -int SIS6326DoSense(ScrnInfoPtr pScrn, int tempbh, int tempbl, int tempch, int tempcl); -void SISSense6326(ScrnInfoPtr pScrn); -static void SiS6326TVDelay(ScrnInfoPtr pScrn, int delay); +static int SIS6326DoSense(ScrnInfoPtr pScrn, int tempbh, int tempbl, int tempch, int tempcl); +static void SISSense6326(ScrnInfoPtr pScrn); +static void SiS6326TVDelay(ScrnInfoPtr pScrn, int delay); + +extern void SISSense30x(ScrnInfoPtr pScrn, Bool quiet); +extern void SISSenseChrontel(ScrnInfoPtr pScrn, Bool quiet); const CARD8 SiS6326TVRegs1[14] = { 0x00,0x01,0x02,0x03,0x04,0x11,0x12,0x13,0x21,0x26,0x27,0x3a,0x3c,0x43 @@ -67,17 +69,6 @@ const CARD8 SiS6326TVRegs1_NTSC[6][14] = { {0x83,0x5d,0x21,0xbe,0x75,0x03,0x00,0x09,0x08,0x42,0x10,0x4d,0x61,0x79} /* 640x480u */ }; -#ifdef TV6326TEST -const CARD8 SiS6326TVRegs1_NTSC_2[6][3] = { - { 0x00,0x00,0x00}, - { 0x00,0x00,0x00}, - { 0x24,0x92,0x49}, - { 0x24,0x92,0x49}, /* 8a50 */ - { 0x24,0x92,0x49}, /* 640x400, 640x480 */ /* 8afc */ - { 0x21,0xbe,0x75} /* 640x480u */ /* n/a */ -}; -#endif - const CARD8 SiS6326TVRegs2_NTSC[6][54] = { {0x11, 0x17, 0x03, 0x09, 0x94, 0x02, 0x05, 0x06, 0x09, 0x50, 0x0C, 0x0C, 0x06, 0x0D, 0x04, 0x0A, 0x94, 0x06, 0x0D, 0x04, 0x0A, 0x94, @@ -120,17 +111,6 @@ const CARD8 SiS6326TVRegs1_PAL[6][14] = { {0x81,0x63,0xa4,0x03,0xd9,0x01,0x00,0x09,0x10,0x9f,0x10,0xaa,0x71,0x59} /* 720x540 */ }; -#ifdef TV6326TEST -const CARD8 SiS6326TVRegs1_PAL_2[6][3] = { - { 0x00,0x00,0x00}, - { 0x00,0x00,0x00}, - { 0xa4,0x07,0xd9}, /* 640x480 */ /* 887e */ - { 0xa4,0x08,0x19}, /* 800x600 */ /* 8828 */ - { 0xa1,0x7e,0xa3}, /* 800x600u */ /* n/a */ - { 0xa4,0x07,0xd9} /* 720x540 */ /* n/a */ -}; -#endif - const CARD8 SiS6326TVRegs2_PAL[6][54] = { {0x15, 0x4E, 0x35, 0x6E, 0x94, 0x02, 0x04, 0x38, 0x3A, 0x50, 0x3D, 0x70, 0x06, 0x3E, 0x35, 0x6D, 0x94, 0x05, 0x3F, 0x36, 0x6E, 0x94, @@ -164,7 +144,6 @@ const CARD8 SiS6326TVRegs2_PAL[6][54] = { 0x6A, 0x5A, 0x73, 0xA0, 0xC1, 0x95, 0x73, 0xB6, 0x03, 0xA0} }; - const CARD8 SiS6326CR[9][15] = { {0x79,0x63,0x64,0x1d,0x6a,0x93,0x00,0x6f,0xf0,0x58,0x8a,0x57,0x57,0x70,0x20}, /* PAL 800x600 */ {0x79,0x4f,0x50,0x95,0x60,0x93,0x00,0x6f,0xba,0x14,0x86,0xdf,0xe0,0x30,0x00}, /* PAL 640x480 */ @@ -240,7 +219,7 @@ SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode) pReg->sisRegs3C4[0x06] &= 0x01; } - /* set interlace */ + /* set interlace */ if(!(mode->Flags & V_INTERLACE)) { offset = pSiS->CurrentLayout.displayWidth >> 3; } else { @@ -458,11 +437,13 @@ SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode) /* Programmable Clock */ pReg->sisRegs3C2 = inb(SISMISCR) | 0x0C; +#if 0 if(pSiS->oldChipset <= OC_SIS86202) { /* TODO: Handle SR07 for clock selection */ /* 86C201 does not even have a programmable clock... */ /* pReg->sisRegs3C4[0x07] &= 0x??; */ } +#endif /* Set VCLK */ if((sis6326tvmode) || (sis6326himode)) { @@ -533,7 +514,7 @@ SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode) pReg->sisRegs3C4[0x2A] = (vclk[Midx] - 1) & 0x7f; pReg->sisRegs3C4[0x2A] |= ((vclk[VLDidx] == 2) ? 1 : 0) << 7; - /* bits [4:0] contain denumerator */ + /* D[4:0]: denumerator */ pReg->sisRegs3C4[0x2B] = (vclk[Nidx] - 1) & 0x1f; if(vclk[Pidx] <= 4){ @@ -585,7 +566,7 @@ SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode) pSiS->ValidWidth = TRUE; pReg->sisRegs3C4[0x27] &= 0xCF; if(pSiS->CurrentLayout.bitsPerPixel == 24) { - /* Invalid logical width */ + /* "Invalid logical width" */ pReg->sisRegs3C4[0x27] |= 0x30; pSiS->ValidWidth = FALSE; } else { @@ -807,11 +788,6 @@ SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode) for(i=0; i<14; i++) { pReg->sis6326tv[SiS6326TVRegs1[i]] = SiS6326TVRegs1_PAL[index][i]; } -#ifdef TV6326TEST - for(i=0, j=2; i<3; i++, j++) { - pReg->sis6326tv[j] = SiS6326TVRegs1_PAL_2[index][i]; - } -#endif fsc = (SiS6326TVRegs1_PAL[index][2] << 16) | (SiS6326TVRegs1_PAL[index][3] << 8) | (SiS6326TVRegs1_PAL[index][4]); @@ -822,11 +798,6 @@ SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode) for(i=0; i<14; i++) { pReg->sis6326tv[SiS6326TVRegs1[i]] = SiS6326TVRegs1_NTSC[index][i]; } -#ifdef TV6326TEST - for(i=0, j=2; i<3; i++, j++) { - pReg->sis6326tv[j] = SiS6326TVRegs1_NTSC_2[index][i]; - } -#endif fsc = (SiS6326TVRegs1_NTSC[index][2] << 16) | (SiS6326TVRegs1_NTSC[index][3] << 8) | (SiS6326TVRegs1_NTSC[index][4]); @@ -884,11 +855,8 @@ SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode) SISRegPtr pReg = &pSiS->ModeReg; unsigned short temp; DisplayModePtr realmode = mode; -#ifdef SISMERGED - DisplayModePtr realmode2 = NULL; -#endif - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, "SIS300Init()\n"); + PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, "SIS300Init()\n")); xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, "virtualX = %d depth = %d Logical width = %d\n", @@ -898,7 +866,6 @@ SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode) #ifdef SISMERGED if(pSiS->MergedFB) { realmode = ((SiSMergedDisplayModePtr)mode->Private)->CRT1; - realmode2 = ((SiSMergedDisplayModePtr)mode->Private)->CRT2; } #endif @@ -910,15 +877,10 @@ SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode) ((pSiS->CurrentLayout.bitsPerPixel + 7) / 8); pSiS->scrnPitch = pSiS->scrnPitch2 = pSiS->scrnOffset; - - if(realmode->Flags & V_INTERLACE) pSiS->scrnPitch <<= 1; - -#ifdef SISMERGED - if(pSiS->MergedFB) { - if(realmode2->Flags & V_INTERLACE) pSiS->scrnPitch2 <<= 1; - } else -#endif - pSiS->scrnPitch2 = pSiS->scrnPitch; + if(!(pSiS->VBFlags & CRT1_LCDA)) { + if(realmode->Flags & V_INTERLACE) pSiS->scrnPitch <<= 1; + } + /* CRT2 mode can never be interlaced */ #ifdef UNLOCK_ALWAYS outSISIDXREG(SISSR, 0x05, 0x86); @@ -977,258 +939,6 @@ SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode) return(TRUE); } -int -SISDoSense(ScrnInfoPtr pScrn, int tempbl, int tempbh, int tempcl, int tempch) -{ - SISPtr pSiS = SISPTR(pScrn); - int temp; - - outSISIDXREG(SISPART4,0x11,tempbl); - temp = tempbh | tempcl; - setSISIDXREG(SISPART4,0x10,0xe0,temp); - SiS_DDC2Delay(pSiS->SiS_Pr, 0x1000); - tempch &= 0x7f; - inSISIDXREG(SISPART4,0x03,temp); - temp ^= 0x0e; - temp &= tempch; - return((temp == tempch)); -} - -/* Sense connected devices on 30x */ -void SISSense30x(ScrnInfoPtr pScrn) -{ - SISPtr pSiS = SISPTR(pScrn); - unsigned char backupP4_0d,backupP2_00,biosflag; - unsigned char svhs_bl, svhs_bh; - unsigned char svhs_cl, svhs_ch; - unsigned char cvbs_bl, cvbs_bh; - unsigned char cvbs_cl, cvbs_ch; - unsigned char vga2_bl, vga2_bh; - unsigned char vga2_cl, vga2_ch; - int myflag, result=0, i, j, haveresult; - unsigned short temp; - - inSISIDXREG(SISPART4,0x0d,backupP4_0d); - outSISIDXREG(SISPART4,0x0d,(backupP4_0d | 0x04)); - - inSISIDXREG(SISPART2,0x00,backupP2_00); - outSISIDXREG(SISPART2,0x00,(backupP2_00 | 0x1c)); - - SISDoSense(pScrn, 0, 0, 0, 0); - - if((pSiS->VGAEngine == SIS_315_VGA) || - (pSiS->Chipset == PCI_CHIP_SIS300)) { - if(pSiS->sishw_ext.UseROM) { - if(pSiS->VGAEngine == SIS_300_VGA) temp = 0xfe; - else { - temp = 0xf3; - if((pSiS->Chipset == PCI_CHIP_SIS330) || (pSiS->Chipset == PCI_CHIP_SIS660)) { - temp = 0x11b; - } - } - if(pSiS->BIOS[temp] & 0x08) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "SiS30x: Video bridge has DVI-I TMDS/VGA combo connector\n"); - orSISIDXREG(SISCR, 0x32, 0x80); - } else { - andSISIDXREG(SISCR, 0x32, 0x7f); - } - } - } - - if(pSiS->VGAEngine == SIS_300_VGA) { - - if(pSiS->sishw_ext.UseROM) { - vga2_bh = pSiS->BIOS[0xf9]; vga2_bl = pSiS->BIOS[0xf8]; - svhs_bh = pSiS->BIOS[0xfb]; svhs_bl = pSiS->BIOS[0xfa]; - cvbs_bh = pSiS->BIOS[0xfd]; cvbs_bl = pSiS->BIOS[0xfc]; - biosflag = pSiS->BIOS[0xfe]; - } else { - vga2_bh = 0x00; vga2_bl = 0xd1; - svhs_bh = 0x00; svhs_bl = 0xb9; - cvbs_bh = 0x00; cvbs_bl = 0xb3; - biosflag = 0; - } - if(pSiS->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; - } - 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; - } - vga2_ch = 0x0e; vga2_cl = 0x08; - svhs_ch = 0x04; svhs_cl = 0x04; - cvbs_ch = 0x08; cvbs_cl = 0x04; - - if(pSiS->Chipset == PCI_CHIP_SIS300) { - inSISIDXREG(SISSR,0x3b,myflag); - if(!(myflag & 0x01)) { - vga2_bh = 0x00; vga2_bl = 0x00; - vga2_ch = 0x00; vga2_cl = 0x00; - } - } - - } else { - - if(pSiS->sishw_ext.UseROM) { - if((pSiS->Chipset == PCI_CHIP_SIS330) || (pSiS->Chipset == PCI_CHIP_SIS660)) { - vga2_bh = pSiS->BIOS[0xe6]; vga2_bl = pSiS->BIOS[0xe5]; - svhs_bh = pSiS->BIOS[0xe8]; svhs_bl = pSiS->BIOS[0xe7]; - cvbs_bh = pSiS->BIOS[0xea]; cvbs_bl = pSiS->BIOS[0xe9]; - biosflag = pSiS->BIOS[0x11b]; - } else { - vga2_bh = pSiS->BIOS[0xbe]; vga2_bl = pSiS->BIOS[0xbd]; - svhs_bh = pSiS->BIOS[0xc0]; svhs_bl = pSiS->BIOS[0xbf]; - cvbs_bh = pSiS->BIOS[0xc2]; cvbs_bl = pSiS->BIOS[0xc1]; - biosflag = pSiS->BIOS[0xf3]; - } - } else { - vga2_bh = 0x00; vga2_bl = 0xd1; - svhs_bh = 0x00; svhs_bl = 0xb9; - cvbs_bh = 0x00; cvbs_bl = 0xb3; - biosflag = 0; - } - - if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV)) { - if(pSiS->sishw_ext.UseROM) { - if((pSiS->Chipset == PCI_CHIP_SIS330) || (pSiS->Chipset == PCI_CHIP_SIS660)) { - vga2_bh = pSiS->BIOS[0xec]; vga2_bl = pSiS->BIOS[0xeb]; - svhs_bh = pSiS->BIOS[0xee]; svhs_bl = pSiS->BIOS[0xed]; - cvbs_bh = pSiS->BIOS[0xf0]; cvbs_bl = pSiS->BIOS[0xef]; - } else { - vga2_bh = pSiS->BIOS[0xc4]; vga2_bl = pSiS->BIOS[0xc3]; - svhs_bh = pSiS->BIOS[0xc6]; svhs_bl = pSiS->BIOS[0xc5]; - cvbs_bh = pSiS->BIOS[0xc8]; cvbs_bl = pSiS->BIOS[0xc7]; - } - } else { - if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B)) { - vga2_bh = 0x01; vga2_bl = 0x90; - svhs_bh = 0x01; svhs_bl = 0x6b; - cvbs_bh = 0x01; cvbs_bl = 0x74; - } else { - vga2_bh = 0x00; vga2_bl = 0x00; - svhs_bh = 0x02; svhs_bl = 0x00; - cvbs_bh = 0x01; cvbs_bl = 0x00; - } - } - } - - if(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)) { - 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(pSiS->VBFlags & (VB_301LV|VB_302LV)) { - /* TW: No VGA2 or SCART on LV bridges */ - 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 { - vga2_ch = 0x0e; vga2_cl = 0x08; - svhs_ch = 0x04; svhs_cl = 0x04; - cvbs_ch = 0x08; cvbs_cl = 0x04; - } - - } - - andSISIDXREG(SISCR, 0x32, ~0x14); - pSiS->postVBCR32 &= ~0x14; - if(vga2_ch || vga2_cl || vga2_bh || vga2_bl) { -#ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "SiS30x: Scanning for VGA2/SCART (%x %x %x %x)\n", - vga2_bh, vga2_bl, vga2_ch, vga2_cl); -#endif - - haveresult = 0; - for(j = 0; j < 10; j++) { - result = 0; - for(i = 0; i < 3; i++) { - if(SISDoSense(pScrn, vga2_bl, vga2_bh, vga2_cl, vga2_ch)) - result++; - } - if((result == 0) || (result >= 2)) break; - } - if(result) { - if(biosflag & 0x01) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "SiS30x: Detected TV connected to SCART output\n"); - pSiS->VBFlags |= TV_SCART; - orSISIDXREG(SISCR, 0x32, 0x04); - pSiS->postVBCR32 |= 0x04; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "SiS30x: Detected secondary VGA connection\n"); - pSiS->VBFlags |= VGA2_CONNECTED; - orSISIDXREG(SISCR, 0x32, 0x10); - pSiS->postVBCR32 |= 0x10; - } - } - if(biosflag & 0x01) pSiS->SiS_SD_Flags |= SiS_SD_VBHASSCART; - } - -#ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "SiS30x: Scanning for TV (%x %x %x %x; %x %x %x %x)\n", - svhs_bh, svhs_bl, svhs_ch, svhs_cl, - cvbs_bh, cvbs_bl, cvbs_ch, cvbs_cl); -#endif - - andSISIDXREG(SISCR, 0x32, ~0x03); - pSiS->postVBCR32 &= ~0x03; - - haveresult = 0; - for(j = 0; j < 10; j++) { - result = 0; - for(i = 0; i < 3; i++) { - if(SISDoSense(pScrn, svhs_bl, svhs_bh, svhs_cl, svhs_ch)) - result++; - } - if((result == 0) || (result >= 2)) break; - } - if(result) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "SiS30x: Detected TV connected to SVIDEO output\n"); - pSiS->VBFlags |= TV_SVIDEO; - orSISIDXREG(SISCR, 0x32, 0x02); - pSiS->postVBCR32 |= 0x02; - } - - if((biosflag & 0x02) || (!(result))) { - - haveresult = 0; - for(j = 0; j < 10; j++) { - result = 0; - for(i = 0; i < 3; i++) { - if(SISDoSense(pScrn, cvbs_bl, cvbs_bh, cvbs_cl, cvbs_ch)) - result++; - } - if((result == 0) || (result >= 2)) break; - } - if(result) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "SiS30x: Detected TV connected to COMPOSITE output\n"); - pSiS->VBFlags |= TV_AVIDEO; - orSISIDXREG(SISCR, 0x32, 0x01); - pSiS->postVBCR32 |= 0x01; - } - } - - SISDoSense(pScrn, 0, 0, 0, 0); - - outSISIDXREG(SISPART2,0x00,backupP2_00); - outSISIDXREG(SISPART4,0x0d,backupP4_0d); -} - static void SiS6326TVDelay(ScrnInfoPtr pScrn, int delay) { @@ -1239,9 +949,10 @@ SiS6326TVDelay(ScrnInfoPtr pScrn, int delay) for(i=0; iModeInit = SIS300Init; break; default: @@ -1354,45 +1067,36 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) inSISIDXREG(SISPART4, 0x00, temp); temp &= 0x0F; - if (temp == 1) { + if(temp == 1) { inSISIDXREG(SISPART4, 0x01, temp1); temp1 &= 0xff; if(temp1 >= 0xE0) { - pSiS->VBFlags |= VB_302LV; - pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LV; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS302LV video bridge (ID 1; Revision 0x%x)\n", - temp1); + inSISIDXREG(SISPART4, 0x39, temp2); + if(temp2 == 0xff) { + pSiS->VBFlags |= VB_302LV; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, detectvb, "SiS302LV", 1, temp1); + } else { + pSiS->VBFlags |= VB_301C; /* VB_302ELV; */ + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, detectvb, "SiS301C", 1, temp1); + } } else if(temp1 >= 0xD0) { pSiS->VBFlags |= VB_301LV; - pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LV; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS301LV video bridge (ID 1; Revision 0x%x)\n", - temp1); - } else if(temp1 >= 0xC0) { /* guessed */ + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, detectvb, "SiS301LV", 1, temp1); + } else if(temp1 >= 0xC0) { pSiS->VBFlags |= VB_301C; - pSiS->sishw_ext.ujVBChipID = VB_CHIP_301C; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS301C video bridge (ID 1; Revision 0x%x)\n", - temp1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, detectvb, "SiS301C", 1, temp1); } else if(temp1 >= 0xB0) { pSiS->VBFlags |= VB_301B; - pSiS->sishw_ext.ujVBChipID = VB_CHIP_301B; inSISIDXREG(SISPART4, 0x23, temp2); if(!(temp2 & 0x02)) pSiS->VBFlags |= VB_30xBDH; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS301B%s video bridge (Revision 0x%x)\n", - (temp2 & 0x02) ? "" : " (DH)", - temp1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, detectvb, + (temp2 & 0x02) ? "SiS301B" : "SiS301B-DH", 1, temp1); } else { pSiS->VBFlags |= VB_301; - pSiS->sishw_ext.ujVBChipID = VB_CHIP_301; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS301 video bridge (Revision 0x%x)\n", - temp1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, detectvb, "SiS301", 1, temp1); } - SISSense30x(pScrn); + SISSense30x(pScrn, TRUE); } else if (temp == 2) { @@ -1400,67 +1104,49 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) temp1 &= 0xff; if(temp1 >= 0xE0) { pSiS->VBFlags |= VB_302LV; - pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LV; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS302LV video bridge (ID 2; Revision 0x%x)\n", - temp1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, detectvb, "SiS302LV", 2, temp1); } else if(temp1 >= 0xD0) { pSiS->VBFlags |= VB_301LV; - pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LV; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS301LV video bridge (ID 2; Revision 0x%x)\n", - temp1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, detectvb, "SiS301LV", 2, temp1); } else { pSiS->VBFlags |= VB_302B; - pSiS->sishw_ext.ujVBChipID = VB_CHIP_302B; - inSISIDXREG(SISPART4, 0x23, temp2); - if(!(temp & 0x02)) pSiS->VBFlags |= VB_30xBDH; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS302B%s video bridge (Revision 0x%x)\n", - (temp2 & 0x02) ? "" : " (DH)", - temp1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, detectvb, "SiS302B", 2, temp1); } - SISSense30x(pScrn); + SISSense30x(pScrn, FALSE); } else if (temp == 3) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS303 video bridge - not supported\n"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, detectvb, "unsupported SiS303", temp, 0); } else { - pSiS->sishw_ext.ujVBChipID = VB_CHIP_UNKNOWN; - inSISIDXREG(SISCR, 0x37, temp); - temp = (temp >> 1) & 0x07; -#if 0 /* TW: This does not seem to be used on any machine */ - if ( (temp == 0) || (temp == 1)) { - pSiS->VBFlags |= VB_301; /* TW: 301 ? */ - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS301 video bridge (Irregular bridge type %d)\n", temp); + if(pSiS->NewCRLayout) { + inSISIDXREG(SISCR, 0x38, temp); + temp = (temp >> 5) & 0x07; + } else { + inSISIDXREG(SISCR, 0x37, temp); + temp = (temp >> 1) & 0x07; } -#endif if(pSiS->VGAEngine == SIS_300_VGA) { lowerlimitlvds = 2; upperlimitlvds = 4; lowerlimitch = 4; upperlimitch = 5; chronteltype = 1; chrontelidreg = 0x25; + upperlimitvb = upperlimitlvds; } else { lowerlimitlvds = 2; upperlimitlvds = 3; lowerlimitch = 3; upperlimitch = 3; chronteltype = 2; chrontelidreg = 0x4b; + upperlimitvb = upperlimitlvds; + if(pSiS->NewCRLayout) { + upperlimitvb = 4; + } } if((temp >= lowerlimitlvds) && (temp <= upperlimitlvds)) { pSiS->VBFlags |= VB_LVDS; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected LVDS transmitter (Bridge type %d)\n", temp); - if(pSiS->Chipset == PCI_CHIP_SIS650) { - inSISIDXREG(SISCR, 0x38, temp1); - if(temp1 & 0x02) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "[LVDS: LCD channel A]\n"); - } - } + "Detected LVDS transmitter (External chip ID %d)\n", temp); } if((temp >= lowerlimitch) && (temp <= upperlimitch)) { /* Set global for init301.c */ @@ -1504,123 +1190,12 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) default: temp2 = 8; pSiS->ChrontelType = CHRONTEL_701x; break; } xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected Chrontel %s TV encoder (ID 0x%02x; bridge type %d)\n", + "Detected Chrontel %s TV encoder (ID 0x%02x; chip ID %d)\n", ChrontelTypeStr[temp2], temp1, temp); /* Sense connected TV's */ - - if(chronteltype == 1) { - - /* Chrontel 700x */ - - /* Read power status */ - temp1 = SiS_GetCH700x(pSiS->SiS_Pr, 0x0e); /* Power status */ - if((temp1 & 0x03) != 0x03) { - /* TW: Power all outputs */ - SiS_SetCH700x(pSiS->SiS_Pr, 0x0B0E); - SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); - } - /* Sense connected TV devices */ - for(i = 0; i < 3; i++) { - SiS_SetCH700x(pSiS->SiS_Pr, 0x0110); - SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); - SiS_SetCH700x(pSiS->SiS_Pr, 0x0010); - SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); - temp1 = SiS_GetCH700x(pSiS->SiS_Pr, 0x10); - if(!(temp1 & 0x08)) test[i] = 0x02; - else if(!(temp1 & 0x02)) test[i] = 0x01; - else test[i] = 0; - SiS_DDC2Delay(pSiS->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 { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "TV detection unreliable - test results varied\n"); - temp1 = test[2]; - } - - } else { - - /* Chrontel 701x */ - - /* Backup Power register */ - temp1 = SiS_GetCH701x(pSiS->SiS_Pr, 0x49); - - /* Enable TV path */ - SiS_SetCH701x(pSiS->SiS_Pr, 0x2049); - - SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); - - /* Sense connected TV devices */ - temp2 = SiS_GetCH701x(pSiS->SiS_Pr, 0x20); - temp2 |= 0x01; - SiS_SetCH701x(pSiS->SiS_Pr, (temp2 << 8) | 0x20); - - SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); - - temp2 ^= 0x01; - SiS_SetCH701x(pSiS->SiS_Pr, (temp2 << 8) | 0x20); - - SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); - - temp2 = SiS_GetCH701x(pSiS->SiS_Pr, 0x20); - - /* Restore Power register */ - SiS_SetCH701x(pSiS->SiS_Pr, (temp1 << 8) | 0x49); - - temp1 = 0; - if(temp2 & 0x02) temp1 |= 0x01; - if(temp2 & 0x10) temp1 |= 0x01; - if(temp2 & 0x04) temp1 |= 0x02; - - if( (temp1 & 0x01) && (temp1 & 0x02) ) temp1 = 0x04; - - } - - switch(temp1) { - case 0x01: - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Chrontel: Detected TV connected to COMPOSITE output\n"); - pSiS->VBFlags |= TV_AVIDEO; - orSISIDXREG(SISCR, 0x32, 0x01); - andSISIDXREG(SISCR, 0x32, ~0x06); - pSiS->postVBCR32 |= 0x01; - pSiS->postVBCR32 &= ~0x06; - break; - case 0x02: - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Chrontel: Detected TV connected to SVIDEO output\n"); - pSiS->VBFlags |= TV_SVIDEO; - orSISIDXREG(SISCR, 0x32, 0x02); - andSISIDXREG(SISCR, 0x32, ~0x05); - pSiS->postVBCR32 |= 0x02; - pSiS->postVBCR32 &= ~0x05; - break; - case 0x04: - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Chrontel: Detected TV connected to SCART output or 480i HDTV\n"); - if(pSiS->chtvtype == -1) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Chrontel: Use CHTVType option to select either SCART or HDTV\n"); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Chrontel: Using SCART by default\n"); - pSiS->chtvtype = 1; - } - if(pSiS->chtvtype) - pSiS->VBFlags |= TV_CHSCART; - else - pSiS->VBFlags |= TV_CHHDTV; - break; - default: - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Chrontel: No TV detected.\n"); - andSISIDXREG(SISCR, 0x32, ~0x07); - pSiS->postVBCR32 &= ~0x07; - } - + SISSenseChrontel(pScrn, FALSE); + } else if(temp1==0) { /* This indicates a communication problem, but it only occures if there * is no TV attached. So we don't use TV in this case. @@ -1640,11 +1215,17 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) SiS_SetChrontelGPIO(pSiS->SiS_Pr, 0x00); } } - if ((pSiS->VGAEngine == SIS_300_VGA) && (temp == 3)) { + if((pSiS->NewCRLayout) && (temp == 4)) { + pSiS->VBFlags |= VB_CONEXANT; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Detected Conexant video bridge - UNSUPPORTED\n"); + } + if((pSiS->VGAEngine == SIS_300_VGA) && (temp == 3)) { + pSiS->VBFlags |= VB_TRUMPION; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected Trumpion Zurac (I/II/III) LVDS scaler - UNSUPPORTED\n"); + "Detected Trumpion Zurac (I/II/III) LVDS scaler\n"); } - if (temp > upperlimitlvds) { + if(temp > upperlimitvb) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Detected unknown bridge type (%d)\n", temp); } @@ -1700,11 +1281,12 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) * relevant registers ourselves. */ if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->VBFlags & (VB_302B | VB_301LV | VB_302LV)) { - if(pSiS->sisfblcda != 0xff) { + + if(pSiS->VBFlags & (VB_301C | VB_302B | VB_301LV | VB_302LV | VB_302ELV)) { + if(pSiS->sisfblcda != 0xff) { if((pSiS->sisfblcda & 0x03) == 0x03) { pSiS->SiS_Pr->SiS_UseLCDA = TRUE; - pSiS->VBFlags |= VB_USELCDA; + pSiS->ChipFlags |= SiSCF_UseLCDA; } } else { inSISIDXREG(SISCR,0x34,temp); @@ -1712,32 +1294,22 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) inSISIDXREG(SISCR,0x38,temp); if((temp & 0x03) == 0x03) { pSiS->SiS_Pr->SiS_UseLCDA = TRUE; - pSiS->VBFlags |= VB_USELCDA; + pSiS->ChipFlags |= SiSCF_UseLCDA; pSiS->SiS_Pr->Backup = TRUE; } else { - inSISIDXREG(SISCR,0x35,temp); - if(temp & 0x01) { + orSISIDXREG(SISPART1,0x2f,0x01); /* Unlock CRT2 */ + inSISIDXREG(SISPART1,0x13,temp); + if(temp & 0x04) { pSiS->SiS_Pr->SiS_UseLCDA = TRUE; - pSiS->VBFlags |= VB_USELCDA; + pSiS->ChipFlags |= SiSCF_UseLCDA; pSiS->SiS_Pr->Backup = TRUE; - } else { - inSISIDXREG(SISCR,0x30,temp); - if(temp & 0x20) { - orSISIDXREG(SISPART1,0x2f,0x01); /* Unlock CRT2 */ - inSISIDXREG(SISPART1,0x13,temp); - if(temp & 0x04) { - pSiS->SiS_Pr->SiS_UseLCDA = TRUE; - pSiS->VBFlags |= VB_USELCDA; - pSiS->SiS_Pr->Backup = TRUE; - } - } } } } } - if(pSiS->VBFlags & VB_USELCDA) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Bridge uses LCDA for low resolution and text modes\n"); + if(pSiS->ChipFlags & SiSCF_UseLCDA) { + xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED, 3, + "BIOS uses LCDA for low resolution and text modes\n"); if(pSiS->SiS_Pr->Backup == TRUE) { inSISIDXREG(SISCR,0x34,pSiS->SiS_Pr->Backup_Mode); inSISIDXREG(SISPART1,0x14,pSiS->SiS_Pr->Backup_14); diff --git a/src/sis_video.c b/src/sis_video.c index df172d2..35741fc 100644 --- a/src/sis_video.c +++ b/src/sis_video.c @@ -1,43 +1,44 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_video.c,v 1.27 2003/09/04 15:32:45 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * Xv driver for SiS 300, 315 and 330 series. * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria. - * All Rights Reserved. + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria. * - * Basic structure based on the mga Xv driver by Mark Vojkovich - * and i810 Xv driver by Jonathan Bian . + * 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) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Formerly based on a mostly non-working fragment for the 630 by - * Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED 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. * - * 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. + * Author: Thomas Winischhofer * - * 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. - * - * Authors: - * Thomas Winischhofer : - * (Original code fragment for 630 by - * Sung-Ching Lin ) + * Formerly based on a mostly non-working code fragment for the 630 by + * Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan which is + * Copyright (C) 2000 Silicon Integrated Systems Corp, Inc. * + * Basic structure based on the mga Xv driver by Mark Vojkovich + * and i810 Xv driver by Jonathan Bian . * * All comments in this file are by Thomas Winischhofer. * - * This supports the following chipsets: + * The overlay adaptor supports the following chipsets: * SiS300: No registers >0x65, two overlays (one used for CRT1, one for CRT2) * SiS630/730: No registers >0x6b, two overlays (one used for CRT1, one for CRT2) * SiS550: Full register range, two overlays (one used for CRT1, one for CRT2) @@ -45,11 +46,12 @@ * SiS650/740: Full register range, one overlay (used for both CRT1 and CRT2 alt.) * SiSM650/651: Full register range, two overlays (one used for CRT1, one for CRT2) * SiS330: Full register range, one overlay (used for both CRT1 and CRT2 alt.) - * SiS660: ? Full register range, two overlays (one used for CRT1, one for CRT2) ? + * SiS661/741/760: Full register range, two overlays (one used for CRT1, one for CRT2) + * SiS340: - not finished yet; dda stuff missing - 1 overlay. Extended registers for DDA * * Help for reading the code: - * 315/550/650/740/M650/651/330/660 = SIS_315_VGA - * 300/630/730 = SIS_300_VGA + * 315/550/650/740/M650/651/330/661/741/760 = SIS_315_VGA + * 300/630/730 = SIS_300_VGA * For chipsets with 2 overlays, hasTwoOverlays will be true * * Notes on display modes: @@ -58,14 +60,14 @@ * DISPMODE is either SINGLE1 or SINGLE2, hence you need to check dualHeadMode flag * DISPMODE is _never_ MIRROR. * a) Chipsets with 2 overlays: - * 315/330 series: Only half sized overlays available (width 960) + * 315/330 series: Only half sized overlays available (width 960), 660: 1536 * Overlay 1 is used on CRT1, overlay 2 for CRT2. * b) Chipsets with 1 overlay: * Full size overlays available. * Overlay is used for either CRT1 or CRT2 * -) merged fb mode: * a) Chipsets with 2 overlays: - * 315/330 series: Only half sized overlays available (width 960) + * 315/330 series: Only half sized overlays available (width 960), 660: 1536 * DISPMODE is always MIRROR. Overlay 1 is used for CRT1, overlay 2 for CRT2. * b) Chipsets with 1 overlay: * Full size overlays available. @@ -73,14 +75,23 @@ * CRT1 or CRT2 (automatically, where it is located) * -) mirror mode (without dualhead or mergedfb) * a) Chipsets with 2 overlays: - * 315/330 series: Only half sized overlays available (width 960) + * 315/330 series: Only half sized overlays available (width 960), 660: 1536 * DISPMODE is MIRROR. Overlay 1 is used for CRT1, overlay 2 for CRT2. * b) Chipsets with 1 overlay: * Full size overlays available. * DISPMODE is either SINGLE1 or SINGLE2. Overlay is used depending on * XvOnCRT2 flag. + * + * About the video blitter: + * The video blitter adaptor supports 16 ports. By default, adaptor 0 will + * be the overlay adaptor, adaptor 1 the video blitter. The option XvDefaultAdaptor + * allows reversing this. + * Since SiS does not provide information on the 3D engine, I could not + * implement scaling. Instead, the driver paints a black border around the unscaled + * video if the destination area is bigger than the video. + * */ - + #include "xf86.h" #include "xf86_OSproc.h" #include "xf86Resources.h" @@ -95,12 +106,15 @@ #include "xf86xv.h" #include "Xv.h" #include "xaa.h" -#include "xaalocal.h" #include "dixstruct.h" #include "fourcc.h" #include "sis_regs.h" +#ifdef INCL_YUV_BLIT_ADAPTOR +#include "sis310_accel.h" +#endif + static XF86VideoAdaptorPtr SISSetupImageVideo(ScreenPtr); static void SISStopVideo(ScrnInfoPtr, pointer, Bool); static int SISSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); @@ -116,8 +130,22 @@ static void SISVideoTimerCallback(ScrnInfoPtr pScrn, Time now); static void SISInitOffscreenImages(ScreenPtr pScrn); extern BOOLEAN SiSBridgeIsInSlaveMode(ScrnInfoPtr pScrn); -#define OFF_DELAY 200 /* milliseconds */ -#define FREE_DELAY 60000 +#ifdef INCL_YUV_BLIT_ADAPTOR +static XF86VideoAdaptorPtr SISSetupBlitVideo(ScreenPtr); +static void SISStopVideoBlit(ScrnInfoPtr, unsigned long, Bool); +static int SISSetPortAttributeBlit(ScrnInfoPtr, Atom, INT32, unsigned long); +static int SISGetPortAttributeBlit(ScrnInfoPtr, Atom ,INT32 *, unsigned long); +static void SISQueryBestSizeBlit(ScrnInfoPtr, Bool, short, short, short, + short, unsigned int *,unsigned int *, unsigned long); +static int SISPutImageBlit( ScrnInfoPtr, + short, short, short, short, short, short, short, short, + int, unsigned char*, short, short, Bool, RegionPtr, unsigned long); +static int SISQueryImageAttributesBlit(ScrnInfoPtr, + int, unsigned short *, unsigned short *, int *, int *); +#endif + +#define OFF_DELAY 200 /* milliseconds */ +#define FREE_DELAY 30000 #define OFF_TIMER 0x01 #define FREE_TIMER 0x02 @@ -125,7 +153,7 @@ extern BOOLEAN SiSBridgeIsInSlaveMode(ScrnInfoPtr pScrn); #define TIMER_MASK (OFF_TIMER | FREE_TIMER) -#define WATCHDOG_DELAY 500000 /* Watchdog counter for Vertical Restrace waiting */ +#define WATCHDOG_DELAY 200000 /* Watchdog counter for Vertical Restrace waiting */ #define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) @@ -135,6 +163,7 @@ extern BOOLEAN SiSBridgeIsInSlaveMode(ScrnInfoPtr pScrn); #define IMAGE_MAX_HEIGHT_300 576 #define IMAGE_MAX_WIDTH_315 1920 #define IMAGE_MAX_HEIGHT_315 1080 +#define IMAGE_MAX_WIDTH_340 1920 /* ? */ #define OVERLAY_MIN_WIDTH 32 /* Minimum overlay sizes */ #define OVERLAY_MIN_HEIGHT 24 @@ -145,11 +174,13 @@ extern BOOLEAN SiSBridgeIsInSlaveMode(ScrnInfoPtr pScrn); #define LINEBUFLIMIT1 384 /* Limits at which line buffers must be merged */ #define LINEBUFLIMIT2 720 +#define LINEBUFLIMIT3 576 +#define LINEBUFLIMIT4 1280 /* 340 */ #ifdef SISDUALHEAD #define HEADOFFSET (pSiS->dhmOffset) #endif - + /* Note on "MIRROR": * When using VESA on machines with an enabled video bridge, this means * a real mirror. CRT1 and CRT2 have the exact same resolution and @@ -160,146 +191,6 @@ extern BOOLEAN SiSBridgeIsInSlaveMode(ScrnInfoPtr pScrn); * refresh rate. */ -/**************************************************************************** - * Raw register access : These routines directly interact with the sis's - * control aperature. Must not be called until after - * the board's pci memory has been mapped. - ****************************************************************************/ - -#if 0 -static CARD32 _sisread(SISPtr pSiS, CARD32 reg) -{ - return *(pSiS->IOBase + reg); -} - -static void _siswrite(SISPtr pSiS, CARD32 reg, CARD32 data) -{ - *(pSiS->IOBase + reg) = data; -} -#endif - -static CARD8 getsrreg(SISPtr pSiS, CARD8 reg) -{ - CARD8 ret; - inSISIDXREG(SISSR, reg, ret); - return(ret); -} - -static CARD8 getvideoreg(SISPtr pSiS, CARD8 reg) -{ - CARD8 ret; - inSISIDXREG(SISVID, reg, ret); - return(ret); -} - -static __inline void setvideoreg(SISPtr pSiS, CARD8 reg, CARD8 data) -{ - outSISIDXREG(SISVID, reg, data); -} - -static __inline void setvideoregmask(SISPtr pSiS, CARD8 reg, CARD8 data, CARD8 mask) -{ - CARD8 old; - inSISIDXREG(SISVID, reg, old); - data = (data & mask) | (old & (~mask)); - outSISIDXREG(SISVID, reg, data); -} - -static void setsrregmask(SISPtr pSiS, CARD8 reg, CARD8 data, CARD8 mask) -{ - CARD8 old; - - inSISIDXREG(SISSR, reg, old); - data = (data & mask) | (old & (~mask)); - outSISIDXREG(SISSR, reg, data); -} - -/* VBlank */ -static CARD8 vblank_active_CRT1(SISPtr pSiS) -{ - return (inSISREG(SISINPSTAT) & 0x08); -} - -static CARD8 vblank_active_CRT2(SISPtr pSiS) -{ - CARD8 ret; - if(pSiS->VGAEngine == SIS_315_VGA) { - inSISIDXREG(SISPART1, Index_310_CRT2_FC_VR, ret); - } else { - inSISIDXREG(SISPART1, Index_CRT2_FC_VR, ret); - } - return((ret & 0x02) ^ 0x02); -} - -/* Scanline - unused */ -#if 0 -static CARD32 get_scanline_CRT1(SISPtr pSiS) -{ - CARD32 line; - - _siswrite (pSiS, REG_PRIM_CRT_COUNTER, 0x00000001); - line = _sisread (pSiS, REG_PRIM_CRT_COUNTER); - - return ((line >> 16) & 0x07FF); -} - -static CARD32 get_scanline_CRT2(SISPtr pSiS) -{ - CARD32 line; - - line = (CARD32)(getsisreg(pSiS, SISPART1, Index_CRT2_FC_VCount1) & 0x70) * 16 - + getsisreg(pSiS, SISPART1, Index_CRT2_FC_VCount); - - return line; -} -#endif - -void SISInitVideo(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; - XF86VideoAdaptorPtr newAdaptor = NULL; - int num_adaptors; - - newAdaptor = SISSetupImageVideo(pScreen); - if(newAdaptor) - SISInitOffscreenImages(pScreen); - - num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); - - if(newAdaptor) { - if(!num_adaptors) { - num_adaptors = 1; - adaptors = &newAdaptor; - } else { - /* need to free this someplace */ - newAdaptors = xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); - if(newAdaptors) { - memcpy(newAdaptors, adaptors, num_adaptors * - sizeof(XF86VideoAdaptorPtr)); - newAdaptors[num_adaptors] = newAdaptor; - adaptors = newAdaptors; - num_adaptors++; - } - } - } - - if(num_adaptors) - xf86XVScreenInit(pScreen, adaptors, num_adaptors); - - if(newAdaptors) - xfree(newAdaptors); -} - -/* client libraries expect an encoding */ -static XF86VideoEncodingRec DummyEncoding = -{ - 0, - "XV_IMAGE", - 0, 0, /* Will be filled in */ - {1, 1} -}; - #define NUM_FORMATS 3 static XF86VideoFormatRec SISFormats[NUM_FORMATS] = @@ -319,6 +210,9 @@ static char sisxvsetdefaults[] = "XV_SET_DEFAULTS"; static char sisxvswitchcrt[] = "XV_SWITCHCRT"; static char sisxvtvxposition[] = "XV_TVXPOSITION"; static char sisxvtvyposition[] = "XV_TVYPOSITION"; +static char sisxvgammared[] = "XV_GAMMA_RED"; +static char sisxvgammagreen[] = "XV_GAMMA_GREEN"; +static char sisxvgammablue[] = "XV_GAMMA_BLUE"; static char sisxvdisablegfx[] = "XV_DISABLE_GRAPHICS"; static char sisxvdisablegfxlr[] = "XV_DISABLE_GRAPHICS_LR"; static char sisxvdisablecolorkey[] = "XV_DISABLE_COLORKEY"; @@ -339,6 +233,7 @@ static char sisxvsdquerydetecteddevices[] = "XV_SD_QUERYDETECTEDDEVICES"; static char sisxvsdcrt1status[] = "XV_SD_CRT1STATUS"; static char sisxvsdcheckmodeindexforcrt2[] = "XV_SD_CHECKMODEINDEXFORCRT2"; static char sisxvsdresultcheckmodeindexforcrt2[] = "XV_SD_RESULTCHECKMODEINDEXFORCRT2"; +static char sisxvsdredetectcrt2[] = "XV_SD_REDETECTCRT2DEVICES"; static char sisxvsdsisantiflicker[] = "XV_SD_SISANTIFLICKER"; static char sisxvsdsissaturation[] = "XV_SD_SISSATURATION"; static char sisxvsdsisedgeenhance[] = "XV_SD_SISEDGEENHANCE"; @@ -362,11 +257,44 @@ static char sisxvsdstorebrib[] = "XV_SD_STOREDGAMMABRIB"; static char sisxvsdstorepbrir[] = "XV_SD_STOREDGAMMAPBRIR"; static char sisxvsdstorepbrig[] = "XV_SD_STOREDGAMMAPBRIG"; static char sisxvsdstorepbrib[] = "XV_SD_STOREDGAMMAPBRIB"; +static char sisxvsdstorebrir2[] = "XV_SD_STOREDGAMMABRIR2"; +static char sisxvsdstorebrig2[] = "XV_SD_STOREDGAMMABRIG2"; +static char sisxvsdstorebrib2[] = "XV_SD_STOREDGAMMABRIB2"; +static char sisxvsdstorepbrir2[] = "XV_SD_STOREDGAMMAPBRIR2"; +static char sisxvsdstorepbrig2[] = "XV_SD_STOREDGAMMAPBRIG2"; +static char sisxvsdstorepbrib2[] = "XV_SD_STOREDGAMMAPBRIB2"; static char sisxvsdhidehwcursor[] = "XV_SD_HIDEHWCURSOR"; +static char sisxvsdpanelmode[] = "XV_SD_PANELMODE"; +#ifdef INCL_YUV_BLIT_ADAPTOR +static char sisxvvsync[] = "XV_SYNC_TO_VBLANK"; +#endif +#ifdef TWDEBUG +static char sisxvsetreg[] = "XV_SD_SETREG"; +#endif + +/***********************************************/ +/* OVERLAY ADAPTOR */ +/***********************************************/ + +#define GET_PORT_PRIVATE(pScrn) \ + (SISPortPrivPtr)((SISPTR(pScrn))->adaptor->pPortPrivates[0].ptr) + +/* client libraries expect an encoding */ +static XF86VideoEncodingRec DummyEncoding = +{ + 0, + "XV_IMAGE", + 0, 0, /* Will be filled in */ + {1, 1} +}; #ifndef SIS_CP -#define NUM_ATTRIBUTES_300 50 -#define NUM_ATTRIBUTES_315 53 +#define NUM_ATTRIBUTES_300 58 +#ifdef TWDEBUG +#define NUM_ATTRIBUTES_315 65 +#else +#define NUM_ATTRIBUTES_315 64 +#endif #endif static XF86AttributeRec SISAttributes_300[NUM_ATTRIBUTES_300] = @@ -398,6 +326,7 @@ static XF86AttributeRec SISAttributes_300[NUM_ATTRIBUTES_300] = {XvSettable | XvGettable, 0, 1, sisxvsdcrt1status}, {XvSettable , 0, 0xffffffff, sisxvsdcheckmodeindexforcrt2}, { XvGettable, 0, 0xffffffff, sisxvsdresultcheckmodeindexforcrt2}, + {XvSettable , 0, 0, sisxvsdredetectcrt2}, {XvSettable | XvGettable, 0, 4, sisxvsdsisantiflicker}, {XvSettable | XvGettable, 0, 15, sisxvsdsissaturation}, {XvSettable | XvGettable, 0, 15, sisxvsdsisedgeenhance}, @@ -421,6 +350,13 @@ static XF86AttributeRec SISAttributes_300[NUM_ATTRIBUTES_300] = {XvSettable | XvGettable, 100, 10000, sisxvsdstorepbrir}, {XvSettable | XvGettable, 100, 10000, sisxvsdstorepbrig}, {XvSettable | XvGettable, 100, 10000, sisxvsdstorepbrib}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorebrir2}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorebrig2}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorebrib2}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorepbrir2}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorepbrig2}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorepbrib2}, + {XvSettable | XvGettable, 0, 15, sisxvsdpanelmode}, #ifdef SIS_CP SIS_CP_VIDEO_ATTRIBUTES #endif @@ -437,12 +373,14 @@ static XF86AttributeRec SISAttributes_315[NUM_ATTRIBUTES_315] = {XvSettable , 0, 0, sisxvsetdefaults}, {XvSettable | XvGettable, -32, 32, sisxvtvxposition}, {XvSettable | XvGettable, -32, 32, sisxvtvyposition}, + {XvSettable | XvGettable, 100, 10000, sisxvgammared}, + {XvSettable | XvGettable, 100, 10000, sisxvgammagreen}, + {XvSettable | XvGettable, 100, 10000, sisxvgammablue}, {XvSettable | XvGettable, 0, 1, sisxvdisablegfx}, {XvSettable | XvGettable, 0, 1, sisxvdisablegfxlr}, {XvSettable | XvGettable, 0, 1, sisxvdisablecolorkey}, {XvSettable | XvGettable, 0, 1, sisxvusechromakey}, {XvSettable | XvGettable, 0, 1, sisxvinsidechromakey}, -/* {XvSettable | XvGettable, 0, 1, sisxvyuvchromakey}, - NO, Chromakey format = Source format */ {XvSettable | XvGettable, 0, (1 << 24) - 1, sisxvchromamin}, {XvSettable | XvGettable, 0, (1 << 24) - 1, sisxvchromamax}, { XvGettable, 0, 0xffffffff, sisxvqueryvbflags}, @@ -457,6 +395,7 @@ static XF86AttributeRec SISAttributes_315[NUM_ATTRIBUTES_315] = {XvSettable | XvGettable, 0, 1, sisxvsdcrt1status}, {XvSettable , 0, 0xffffffff, sisxvsdcheckmodeindexforcrt2}, { XvGettable, 0, 0xffffffff, sisxvsdresultcheckmodeindexforcrt2}, + {XvSettable , 0, 0, sisxvsdredetectcrt2}, {XvSettable | XvGettable, 0, 4, sisxvsdsisantiflicker}, {XvSettable | XvGettable, 0, 15, sisxvsdsissaturation}, {XvSettable | XvGettable, 0, 15, sisxvsdsisedgeenhance}, @@ -470,7 +409,7 @@ static XF86AttributeRec SISAttributes_315[NUM_ATTRIBUTES_315] = {XvSettable | XvGettable, 0, 15, sisxvsdchlumaflickerfilter}, {XvSettable | XvGettable, 0, 1, sisxvsdchcvbscolor}, {XvSettable | XvGettable, 0, 3, sisxvsdchoverscan}, - {XvSettable | XvGettable, 0, 3, sisxvsdenablegamma}, + {XvSettable | XvGettable, 0, 7, sisxvsdenablegamma}, {XvSettable | XvGettable, -16, 16, sisxvsdtvxscale}, {XvSettable | XvGettable, -4, 3, sisxvsdtvyscale}, { XvGettable, 0, 0xffffffff, sisxvsdgetscreensize}, @@ -480,7 +419,17 @@ static XF86AttributeRec SISAttributes_315[NUM_ATTRIBUTES_315] = {XvSettable | XvGettable, 100, 10000, sisxvsdstorepbrir}, {XvSettable | XvGettable, 100, 10000, sisxvsdstorepbrig}, {XvSettable | XvGettable, 100, 10000, sisxvsdstorepbrib}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorebrir2}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorebrig2}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorebrib2}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorepbrir2}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorepbrig2}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorepbrib2}, {XvSettable | XvGettable, 0, 1, sisxvsdhidehwcursor}, + {XvSettable | XvGettable, 0, 15, sisxvsdpanelmode}, +#ifdef TWDEBUG + {XvSettable , 0, 0xffffffff, sisxvsetreg}, +#endif #ifdef SIS_CP SIS_CP_VIDEO_ATTRIBUTES #endif @@ -488,17 +437,18 @@ static XF86AttributeRec SISAttributes_315[NUM_ATTRIBUTES_315] = }; #define NUM_IMAGES_300 6 -#define NUM_IMAGES_315 7 /* NV12 only - but does not work */ +#define NUM_IMAGES_315 7 /* basically NV12 only - but does not work */ #define NUM_IMAGES_330 9 /* NV12 and NV21 */ + #define PIXEL_FMT_YV12 FOURCC_YV12 /* 0x32315659 */ #define PIXEL_FMT_UYVY FOURCC_UYVY /* 0x59565955 */ #define PIXEL_FMT_YUY2 FOURCC_YUY2 /* 0x32595559 */ #define PIXEL_FMT_I420 FOURCC_I420 /* 0x30323449 */ #define PIXEL_FMT_RGB5 0x35315652 #define PIXEL_FMT_RGB6 0x36315652 -#define PIXEL_FMT_YVYU 0x55595659 /* 315/330 only */ -#define PIXEL_FMT_NV12 0x3231564e /* 330 only */ -#define PIXEL_FMT_NV21 0x3132564e /* 330 only */ +#define PIXEL_FMT_YVYU 0x55595659 /* 315/330+ only */ +#define PIXEL_FMT_NV12 0x3231564e /* 330+ only */ +#define PIXEL_FMT_NV21 0x3132564e /* 330+ only */ /* TODO: */ #define PIXEL_FMT_RAW8 0x38574152 @@ -519,7 +469,6 @@ static XF86ImageRec SISImages[NUM_IMAGES_330] = 16, XvPacked, 1, -/* 15, 0x001F, 0x03E0, 0x7C00, - incorrect! */ 15, 0x7C00, 0x03E0, 0x001F, 0, 0, 0, 0, 0, 0, @@ -537,7 +486,6 @@ static XF86ImageRec SISImages[NUM_IMAGES_330] = 16, XvPacked, 1, -/* 16, 0x001F, 0x07E0, 0xF800, - incorrect! */ 16, 0xF800, 0x07E0, 0x001F, 0, 0, 0, 0, 0, 0, @@ -599,6 +547,76 @@ static XF86ImageRec SISImages[NUM_IMAGES_330] = }, }; +typedef struct { + FBLinearPtr linear; + CARD32 bufAddr[2]; + + unsigned char currentBuf; + + short drw_x, drw_y, drw_w, drw_h; + short src_x, src_y, src_w, src_h; + int id; + short srcPitch, height; + + char brightness; + unsigned char contrast; + char hue; + short saturation; + + RegionRec clip; + CARD32 colorKey; + Bool autopaintColorKey; + + Bool disablegfx; + Bool disablegfxlr; + + Bool usechromakey; + Bool insidechromakey, yuvchromakey; + CARD32 chromamin, chromamax; + + CARD32 videoStatus; + BOOLEAN overlayStatus; + Time offTime; + Time freeTime; + + CARD32 displayMode; + Bool bridgeIsSlave; + + Bool hasTwoOverlays; /* Chipset has two overlays */ + Bool dualHeadMode; /* We're running in DHM */ + + Bool NoOverlay; + Bool PrevOverlay; + + Bool AllowSwitchCRT; + int crtnum; /* 0=CRT1, 1=CRT2 */ + + Bool needToScale; /* Need to scale video */ + + int shiftValue; /* 315/330 series need word addr/pitch, 300 series double word */ + + short linebufMergeLimit; + CARD8 linebufmask; + + short oldx1, oldx2, oldy1, oldy2; +#ifdef SISMERGED + short oldx1_2, oldx2_2, oldy1_2, oldy2_2; +#endif + int mustwait; + + Bool grabbedByV4L; /* V4L stuff */ + int pitch; + int offset; + + int modeflags; /* Flags field of current display mode */ + + int tvxpos, tvypos; + Bool updatetvxpos, updatetvypos; + + Bool is340; + +} SISPortPrivRec, *SISPortPrivPtr; + typedef struct { int pixelFormat; @@ -622,7 +640,7 @@ typedef struct { CARD16 SCREENheight; - CARD8 lineBufSize; + CARD16 lineBufSize; DisplayModePtr currentmode; @@ -640,7 +658,7 @@ typedef struct { CARD32 PSV2; CARD32 PSU2; CARD16 SCREENheight2; - CARD8 lineBufSize2; + CARD16 lineBufSize2; DisplayModePtr currentmode2; @@ -648,105 +666,357 @@ typedef struct { #endif CARD8 bobEnable; + + CARD8 planar; + CARD8 planar_shiftpitch; CARD8 contrastCtrl; CARD8 contrastFactor; + + CARD16 oldLine, oldtop; - CARD8 (*VBlankActiveFunc)(SISPtr); + CARD8 (*VBlankActiveFunc)(SISPtr, SISPortPrivPtr); #if 0 CARD32 (*GetScanLineFunc)(SISPtr pSiS); #endif -#if 0 - /* The following are not used yet */ - CARD16 SubPictHUSF; /* Subpicture scaling */ - CARD16 SubpictVUSF; - CARD8 SubpictIntBit; - CARD8 SubPictwHPre; - CARD16 SubPictsrcW; /* Subpicture source width */ - CARD16 SubPictsrcH; /* Subpicture source height */ - BoxRec SubPictdstBox; /* SubPicture destination box */ - CARD32 SubPictAddr; /* SubPicture address */ - CARD32 SubPictPitch; /* SubPicture pitch */ - CARD32 SubPictOrigPitch; /* SubPicture real pitch (needed for scaling twice) */ - CARD32 SubPictPreset; /* Subpicture Preset */ - - CARD32 MPEG_Y; /* MPEG Y Buffer Addr */ - CARD32 MPEG_UV; /* MPEG UV Buffer Addr */ -#endif - } SISOverlayRec, *SISOverlayPtr; -typedef struct { - FBLinearPtr linear; - CARD32 bufAddr[2]; - - unsigned char currentBuf; +/***********************************************/ +/* BLITTER ADAPTOR */ +/***********************************************/ - short drw_x, drw_y, drw_w, drw_h; - short src_x, src_y, src_w, src_h; - int id; - short srcPitch, height; - - char brightness; - unsigned char contrast; - char hue; - char saturation; +#ifdef INCL_YUV_BLIT_ADAPTOR - RegionRec clip; - CARD32 colorKey; - Bool autopaintColorKey; +#define NUM_BLIT_PORTS 16 - Bool disablegfx; - Bool disablegfxlr; +static XF86VideoEncodingRec DummyEncodingBlit = +{ + 0, + "XV_IMAGE", + 2046, 2046, + {1, 1} +}; - Bool usechromakey; - Bool insidechromakey, yuvchromakey; - CARD32 chromamin, chromamax; +#define NUM_ATTRIBUTES_BLIT 2 - CARD32 videoStatus; - BOOLEAN overlayStatus; - Time offTime; - Time freeTime; +static XF86AttributeRec SISAttributes_Blit[NUM_ATTRIBUTES_BLIT] = +{ + {XvSettable | XvGettable, 0, 1, sisxvvsync}, + {XvSettable , 0, 0, sisxvsetdefaults} +}; - CARD32 displayMode; - Bool bridgeIsSlave; +#define NUM_IMAGES_BLIT 7 - Bool hasTwoOverlays; /* Chipset has two overlays */ - Bool dualHeadMode; /* We're running in DHM */ - - Bool NoOverlay; - Bool PrevOverlay; - - Bool AllowSwitchCRT; - int crtnum; /* 0=CRT1, 1=CRT2 */ +static XF86ImageRec SISImagesBlit[NUM_IMAGES_BLIT] = +{ - Bool needToScale; /* Need to scale video */ + XVIMAGE_YUY2, + XVIMAGE_YV12, + XVIMAGE_UYVY, + XVIMAGE_I420, + { /* YVYU */ + PIXEL_FMT_YVYU, \ + XvYUV, \ + LSBFirst, \ + {'Y','V','Y','U', + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, + 16, + XvPacked, + 1, + 0, 0, 0, 0, + 8, 8, 8, + 1, 2, 2, + 1, 1, 1, + {'Y','V','Y','U', + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + XvTopToBottom + }, + { /* NV12 */ + PIXEL_FMT_NV12, + XvYUV, + LSBFirst, + {'N','V','1','2', + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, + 12, + XvPlanar, + 2, + 0, 0, 0, 0, + 8, 8, 8, + 1, 2, 2, + 1, 2, 2, + {'Y','U','V',0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + XvTopToBottom + }, + { /* NV21 */ + PIXEL_FMT_NV21, + XvYUV, + LSBFirst, + {'N','V','2','1', + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, + 12, + XvPlanar, + 2, + 0, 0, 0, 0, + 8, 8, 8, + 1, 2, 2, + 1, 2, 2, + {'Y','V','U',0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + XvTopToBottom + } +}; - int shiftValue; /* 315/330 series need word addr/pitch, 300 series double word */ +typedef struct { + FBLinearPtr linear[NUM_BLIT_PORTS]; + CARD32 bufAddr[NUM_BLIT_PORTS][2]; - short linebufMergeLimit; - CARD8 linebufmask; + unsigned char currentBuf[NUM_BLIT_PORTS]; + + RegionRec blitClip[NUM_BLIT_PORTS]; + + CARD32 videoStatus[NUM_BLIT_PORTS]; + Time freeTime[NUM_BLIT_PORTS]; + + Bool vsync; + CARD32 AccelCmd; + CARD32 VBlankTriggerCRT1, VBlankTriggerCRT2; +} SISBPortPrivRec, *SISBPortPrivPtr; - short oldx1, oldx2, oldy1, oldy2; -#ifdef SISMERGED - short oldx1_2, oldx2_2, oldy1_2, oldy2_2; +#endif /* INCL_BLIT */ + +/**************************************************************************** + * Raw register access : These routines directly interact with the sis's + * control aperature. Must not be called until after + * the board's pci memory has been mapped. + ****************************************************************************/ + +#if 0 +static CARD32 _sisread(SISPtr pSiS, CARD32 reg) +{ + return *(pSiS->IOBase + reg); +} + +static void _siswrite(SISPtr pSiS, CARD32 reg, CARD32 data) +{ + *(pSiS->IOBase + reg) = data; +} #endif - int mustwait; - Bool grabbedByV4L; /* V4L stuff */ - int pitch; - int offset; +static CARD8 getsrreg(SISPtr pSiS, CARD8 reg) +{ + CARD8 ret; + inSISIDXREG(SISSR, reg, ret); + return(ret); +} - int modeflags; /* Flags field of current display mode */ +static CARD8 getvideoreg(SISPtr pSiS, CARD8 reg) +{ + CARD8 ret; + inSISIDXREG(SISVID, reg, ret); + return(ret); +} - int tvxpos, tvypos; - Bool updatetvxpos, updatetvypos; +static __inline void setvideoreg(SISPtr pSiS, CARD8 reg, CARD8 data) +{ + outSISIDXREG(SISVID, reg, data); +} -} SISPortPrivRec, *SISPortPrivPtr; +static __inline void setvideoregmask(SISPtr pSiS, CARD8 reg, CARD8 data, CARD8 mask) +{ + CARD8 old; + inSISIDXREG(SISVID, reg, old); + data = (data & mask) | (old & (~mask)); + outSISIDXREG(SISVID, reg, data); +} -#define GET_PORT_PRIVATE(pScrn) \ - (SISPortPrivPtr)((SISPTR(pScrn))->adaptor->pPortPrivates[0].ptr) +static void setsrregmask(SISPtr pSiS, CARD8 reg, CARD8 data, CARD8 mask) +{ + CARD8 old; + + inSISIDXREG(SISSR, reg, old); + data = (data & mask) | (old & (~mask)); + outSISIDXREG(SISSR, reg, data); +} + +/* VBlank */ +static CARD8 vblank_active_CRT1(SISPtr pSiS, SISPortPrivPtr pPriv) +{ + return(inSISREG(SISINPSTAT) & 0x08); /* Verified */ +} + +static CARD8 vblank_active_CRT2(SISPtr pSiS, SISPortPrivPtr pPriv) +{ + CARD8 ret; + + if(pPriv->bridgeIsSlave) return(vblank_active_CRT1(pSiS, pPriv)); + + if(pSiS->VGAEngine == SIS_315_VGA) { + inSISIDXREG(SISPART1, 0x30, ret); + } else { + inSISIDXREG(SISPART1, 0x25, ret); + } + return(ret & 0x02); /* Verified */ +} + +/* Scanline - unused */ +#if 0 +static CARD16 get_scanline_CRT1(SISPtr pSiS) +{ + CARD32 line; + + _siswrite(pSiS, REG_PRIM_CRT_COUNTER, 0x00000001); + line = _sisread(pSiS, REG_PRIM_CRT_COUNTER); + + return((CARD16)((line >> 16) & 0x07FF)); +} +#endif + +#if 1 +static CARD16 get_scanline_CRT2(SISPtr pSiS, SISPortPrivPtr pPriv) +{ + CARD8 reg1, reg2; + + if(pSiS->VGAEngine == SIS_315_VGA) { + inSISIDXREG(SISPART1, 0x32, reg1); + inSISIDXREG(SISPART1, 0x33, reg2); + } else { + inSISIDXREG(SISPART1, 0x27, reg1); + inSISIDXREG(SISPART1, 0x28, reg2); + } + + return((CARD16)(reg1 | ((reg2 & 0x70) << 4))); +} +#endif + +static void +SiSComputeXvGamma(SISPtr pSiS) +{ + int num = 255, i; + double red = 1.0 / (double)((double)pSiS->XvGammaRed / 1000); + double green = 1.0 / (double)((double)pSiS->XvGammaGreen / 1000); + double blue = 1.0 / (double)((double)pSiS->XvGammaBlue / 1000); + + for(i = 0; i <= num; i++) { + pSiS->XvGammaRampRed[i] = + (red == 1.0) ? i : (CARD8)(pow((double)i / (double)num, red) * (double)num + 0.5); + + pSiS->XvGammaRampGreen[i] = + (green == 1.0) ? i : (CARD8)(pow((double)i / (double)num, green) * (double)num + 0.5); + + pSiS->XvGammaRampBlue[i] = + (blue == 1.0) ? i : (CARD8)(pow((double)i / (double)num, blue) * (double)num + 0.5); + } +} + +static void +SiSSetXvGamma(SISPtr pSiS) +{ + int i; + unsigned char backup = getsrreg(pSiS, 0x1f); + setsrregmask(pSiS, 0x1f, 0x08, 0x18); + for(i = 0; i <= 255; i++) { + MMIO_OUT32(pSiS->IOBase, 0x8570, + (i << 24) | + (pSiS->XvGammaRampBlue[i] << 16) | + (pSiS->XvGammaRampGreen[i] << 8) | + pSiS->XvGammaRampRed[i]); + } + setsrregmask(pSiS, 0x1f, backup, 0xff); +} + +static void +SiSUpdateXvGamma(SISPtr pSiS, SISPortPrivPtr pPriv) +{ + unsigned char sr7 = getsrreg(pSiS, 0x07); + + if(!pSiS->XvGamma) return; + if(!(pSiS->MiscFlags & MISC_CRT1OVERLAYGAMMA)) return; + +#ifdef SISDUALHEAD + if((pPriv->dualHeadMode) && (!pSiS->SecondHead)) return; +#endif + + if(!(sr7 & 0x04)) return; + + SiSComputeXvGamma(pSiS); + SiSSetXvGamma(pSiS); +} + +static void +SISResetXvGamma(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + SISPortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); + + SiSUpdateXvGamma(pSiS, pPriv); +} + +void SISInitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; +#ifdef INCL_YUV_BLIT_ADAPTOR + SISPtr pSiS = SISPTR(pScrn); +#endif + XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL, newBlitAdaptor = NULL; + int num_adaptors; + + newAdaptor = SISSetupImageVideo(pScreen); + if(newAdaptor) { + SISInitOffscreenImages(pScreen); + } + +#ifdef INCL_YUV_BLIT_ADAPTOR + if( ( (pSiS->ChipFlags & SiSCF_Is65x) || + (pSiS->sishw_ext.jChipType >= SIS_330) ) && + (pScrn->bitsPerPixel != 8) ) { + newBlitAdaptor = SISSetupBlitVideo(pScreen); + } +#endif + + num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + + if(newAdaptor || newBlitAdaptor) { + int size = num_adaptors; + + if(newAdaptor) size++; + if(newBlitAdaptor) size++; + + newAdaptors = xalloc(size * sizeof(XF86VideoAdaptorPtr*)); + if(newAdaptors) { + if(num_adaptors) { + memcpy(newAdaptors, adaptors, num_adaptors * sizeof(XF86VideoAdaptorPtr)); + } + if(pSiS->XvDefAdaptorBlit) { + if(newBlitAdaptor) { + newAdaptors[num_adaptors] = newBlitAdaptor; + num_adaptors++; + } + } + if(newAdaptor) { + newAdaptors[num_adaptors] = newAdaptor; + num_adaptors++; + } + if(!pSiS->XvDefAdaptorBlit) { + if(newBlitAdaptor) { + newAdaptors[num_adaptors] = newBlitAdaptor; + num_adaptors++; + } + } + adaptors = newAdaptors; + } + } + + if(num_adaptors) { + xf86XVScreenInit(pScreen, adaptors, num_adaptors); + } + + if(newAdaptors) { + xfree(newAdaptors); + } +} static void SISSetPortDefaults(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) @@ -757,7 +1027,6 @@ SISSetPortDefaults(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) #endif pPriv->colorKey = pSiS->colorKey = 0x000101fe; - pPriv->videoStatus = 0; pPriv->brightness = pSiS->XvDefBri; pPriv->contrast = pSiS->XvDefCon; pPriv->hue = pSiS->XvDefHue; @@ -789,12 +1058,19 @@ SISSetPortDefaults(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) #ifdef SIS_CP SIS_CP_VIDEO_DEF #endif - if(pPriv->dualHeadMode) + if(pPriv->dualHeadMode) { +#ifdef SISDUALHEAD pPriv->crtnum = pSiSEnt->curxvcrtnum = pSiSEnt->XvOnCRT2 ? 1 : 0; - else +#endif + } else pPriv->crtnum = pSiS->XvOnCRT2 ? 1 : 0; + + pSiS->XvGammaRed = pSiS->XvGammaRedDef; + pSiS->XvGammaGreen = pSiS->XvGammaGreenDef; + pSiS->XvGammaBlue = pSiS->XvGammaBlueDef; + SiSUpdateXvGamma(pSiS, pPriv); } static void @@ -813,7 +1089,7 @@ SISResetVideo(ScrnInfoPtr pScrn) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Xv: Video password could not unlock registers\n"); } - + /* Initialize first overlay (CRT1) ------------------------------- */ /* This bit has obviously a different meaning on 315 series (linebuffer-related) */ @@ -848,17 +1124,29 @@ SISResetVideo(ScrnInfoPtr pScrn) setvideoreg(pSiS, Index_VI_Disp_Y_UV_Buf_Preset_High, 0x00); setvideoreg(pSiS, Index_VI_Play_Threshold_Low, 0x00); setvideoreg(pSiS, Index_VI_Play_Threshold_High, 0x00); + if(pSiS->Chipset == PCI_CHIP_SIS340) { + setvideoregmask(pSiS, 0xb5, 0x00, 0x01); /* Threshold high? */ + setvideoregmask(pSiS, 0xb6, 0x00, 0x01); + } - if((pSiS->Chipset == PCI_CHIP_SIS330) || (pSiS->Chipset == PCI_CHIP_SIS660)) { - /* What does this do? */ + if(pSiS->Chipset == PCI_CHIP_SIS330) { /* 340? */ setvideoregmask(pSiS, Index_VI_Key_Overlay_OP, 0x00, 0x10); + } else if(pSiS->Chipset == PCI_CHIP_SIS660) { + setvideoregmask(pSiS, Index_VI_Key_Overlay_OP, 0x00, 0xE0); + } + if(pSiS->sishw_ext.jChipType == SIS_661) { + setvideoregmask(pSiS, Index_VI_V_Buf_Start_Over, 0x2c, 0x3c); } - if(pSiS->ChipFlags & SiSCF_Is65x) { + if((pSiS->ChipFlags & SiSCF_Is65x) || (pSiS->Chipset == PCI_CHIP_SIS660)) { setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0x04); } + + /* Reset top window position for scanline check */ + setvideoreg(pSiS, Index_VI_Win_Ver_Disp_Start_Low, 0x00); + setvideoreg(pSiS, Index_VI_Win_Ver_Over, 0x00); - /* Initialize second overlay (CRT2) ---- only for 300, 630/730, 550, M650/651/652/653, 660 */ + /* Initialize second overlay (CRT2) - only for 300, 630/730, 550, M650/651, 661/741/660/760 */ if(pPriv->hasTwoOverlays) { if(pSiS->VGAEngine == SIS_300_VGA) { @@ -878,8 +1166,6 @@ SISResetVideo(ScrnInfoPtr pScrn) /* Select RGB chroma key format */ if(pSiS->VGAEngine == SIS_300_VGA) { setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x40); - } else { - /* setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x01, 0x01); */ } /* Reset scale control and contrast */ @@ -895,10 +1181,18 @@ SISResetVideo(ScrnInfoPtr pScrn) setvideoreg(pSiS, Index_VI_Play_Threshold_Low, 0x00); setvideoreg(pSiS, Index_VI_Play_Threshold_High, 0x00); - if((pSiS->Chipset == PCI_CHIP_SIS330) || (pSiS->Chipset == PCI_CHIP_SIS660)) { - /* What does this do? */ + if(pSiS->Chipset == PCI_CHIP_SIS330) { setvideoregmask(pSiS, Index_VI_Key_Overlay_OP, 0x00, 0x10); + } else if(pSiS->Chipset == PCI_CHIP_SIS660) { + setvideoregmask(pSiS, Index_VI_Key_Overlay_OP, 0x00, 0xE0); + } + if(pSiS->sishw_ext.jChipType == SIS_661) { + setvideoregmask(pSiS, Index_VI_V_Buf_Start_Over, 0x24, 0x3c); } + + setvideoreg(pSiS, Index_VI_Win_Ver_Disp_Start_Low, 0x00); + setvideoreg(pSiS, Index_VI_Win_Ver_Over, 0x00); + } /* set default properties for overlay 1 (CRT1) -------------------------- */ @@ -912,13 +1206,18 @@ SISResetVideo(ScrnInfoPtr pScrn) /* set default properties for overlay 2(CRT2) -------------------------- */ if(pPriv->hasTwoOverlays) { - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, 0x01); - setvideoregmask(pSiS, Index_VI_Contrast_Enh_Ctrl, 0x04, 0x07); - setvideoreg(pSiS, Index_VI_Brightness, 0x20); - if(pSiS->VGAEngine == SIS_315_VGA) { - setvideoreg(pSiS, Index_VI_Hue, 0x00); - setvideoreg(pSiS, Index_VI_Saturation, 0x00); - } + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, 0x01); + setvideoregmask(pSiS, Index_VI_Contrast_Enh_Ctrl, 0x04, 0x07); + setvideoreg(pSiS, Index_VI_Brightness, 0x20); + if(pSiS->VGAEngine == SIS_315_VGA) { + setvideoreg(pSiS, Index_VI_Hue, 0x00); + setvideoreg(pSiS, Index_VI_Saturation, 0x00); + } + } + + /* Reset Xv gamma correction */ + if(pSiS->VGAEngine == SIS_315_VGA) { + SiSUpdateXvGamma(pSiS, pPriv); } } @@ -940,27 +1239,27 @@ set_dispmode(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) if( (pSiS->VBFlags & VB_DISPMODE_MIRROR) || ((pPriv->bridgeIsSlave) && (pSiS->VBFlags & DISPTYPE_DISP2)) ) { - if(pPriv->hasTwoOverlays) - pPriv->displayMode = DISPMODE_MIRROR; /* CRT1+CRT2 (2 overlays) */ - else if(pPriv->crtnum) - pPriv->displayMode = DISPMODE_SINGLE2; /* CRT2 only */ - else - pPriv->displayMode = DISPMODE_SINGLE1; /* CRT1 only */ + if(pPriv->hasTwoOverlays) + pPriv->displayMode = DISPMODE_MIRROR; /* CRT1+CRT2 (2 overlays) */ + else if(pPriv->crtnum) + pPriv->displayMode = DISPMODE_SINGLE2; /* CRT2 only */ + else + pPriv->displayMode = DISPMODE_SINGLE1; /* CRT1 only */ } else { #ifdef SISDUALHEAD - if(pSiS->DualHeadMode) { - pPriv->dualHeadMode = TRUE; - if(pSiS->SecondHead) - pPriv->displayMode = DISPMODE_SINGLE1; /* CRT1 only */ - else - pPriv->displayMode = DISPMODE_SINGLE2; /* CRT2 only */ - } else + if(pSiS->DualHeadMode) { + pPriv->dualHeadMode = TRUE; + if(pSiS->SecondHead) + pPriv->displayMode = DISPMODE_SINGLE1; /* CRT1 only */ + else + pPriv->displayMode = DISPMODE_SINGLE2; /* CRT2 only */ + } else #endif - if(pSiS->VBFlags & DISPTYPE_DISP1) { - pPriv->displayMode = DISPMODE_SINGLE1; /* CRT1 only */ - } else { - pPriv->displayMode = DISPMODE_SINGLE2; /* CRT2 only */ - } + if(pSiS->VBFlags & DISPTYPE_DISP1) { + pPriv->displayMode = DISPMODE_SINGLE1; /* CRT1 only */ + } else { + pPriv->displayMode = DISPMODE_SINGLE2; /* CRT2 only */ + } } } @@ -977,22 +1276,22 @@ set_disptype_regs(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) /* * SR06[7:6] - * Bit 7: Enable overlay 2 on CRT2 - * Bit 6: Enable overlay 1 on CRT2 + * Bit 7: Enable overlay 1 on CRT2 + * Bit 6: Enable overlay 0 on CRT2 * SR32[7:6] - * Bit 7: DCLK/TCLK overlay 2 + * Bit 7: DCLK/TCLK overlay 1 * 0=DCLK (overlay on CRT1) * 1=TCLK (overlay on CRT2) - * Bit 6: DCLK/TCLK overlay 1 + * Bit 6: DCLK/TCLK overlay 0 * 0=DCLK (overlay on CRT1) * 1=TCLK (overlay on CRT2) * * On chipsets with two overlays, we can freely select and also - * have a mirror mode. However, we use overlay 1 for CRT1 and - * overlay 2 for CRT2. + * have a mirror mode. However, we use overlay 0 for CRT1 and + * overlay 1 for CRT2. * ATTENTION: CRT2 can only take up to 1 (one) overlay. Setting * SR06/32 to 0xc0 DOES NOT WORK. THAT'S CONFIRMED. - * Therefore, we use overlay 1 on CRT2 if in SINGLE2 mode. + * Therefore, we use overlay 0 on CRT2 if in SINGLE2 mode. * * For chipsets with only one overlay, user must choose whether * to display the overlay on CRT1 or CRT2 by setting XvOnCRT2 @@ -1008,7 +1307,7 @@ set_disptype_regs(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) case DISPMODE_SINGLE1: /* CRT1-only mode: */ if(pPriv->hasTwoOverlays) { if(pPriv->dualHeadMode) { - setsrregmask(pSiS, 0x06, 0x00, 0x40); /* overlay 1 -> CRT1 */ + setsrregmask(pSiS, 0x06, 0x00, 0x40); /* overlay 0 -> CRT1 */ setsrregmask(pSiS, 0x32, 0x00, 0x40); } else { setsrregmask(pSiS, 0x06, 0x00, 0xc0); /* both overlays -> CRT1 */ @@ -1029,10 +1328,10 @@ set_disptype_regs(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) case DISPMODE_SINGLE2: /* CRT2-only mode: */ if(pPriv->hasTwoOverlays) { if(pPriv->dualHeadMode) { - setsrregmask(pSiS, 0x06, 0x80, 0x80); /* overlay 2 -> CRT2 */ + setsrregmask(pSiS, 0x06, 0x80, 0x80); /* overlay 1 -> CRT2 */ setsrregmask(pSiS, 0x32, 0x80, 0x80); } else { - setsrregmask(pSiS, 0x06, 0x40, 0xc0); /* overlay 1 -> CRT2 */ + setsrregmask(pSiS, 0x06, 0x40, 0xc0); /* overlay 0 -> CRT2 */ setsrregmask(pSiS, 0x32, 0xc0, 0xc0); /* (although both clocks for CRT2!) */ } } else { @@ -1049,7 +1348,7 @@ set_disptype_regs(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) case DISPMODE_MIRROR: /* CRT1+CRT2-mode: (only on chips with 2 overlays) */ default: - setsrregmask(pSiS, 0x06, 0x80, 0xc0); /* overlay 1 -> CRT1, overlay 2 -> CRT2 */ + setsrregmask(pSiS, 0x06, 0x80, 0xc0); /* overlay 0 -> CRT1, overlay 1 -> CRT2 */ setsrregmask(pSiS, 0x32, 0x80, 0xc0); break; } @@ -1083,22 +1382,37 @@ set_maxencoding(SISPtr pSiS, SISPortPrivPtr pPriv) } else { DummyEncoding.width = IMAGE_MAX_WIDTH_315; DummyEncoding.height = IMAGE_MAX_HEIGHT_315; + if(pSiS->Chipset == PCI_CHIP_SIS340) { + DummyEncoding.width = IMAGE_MAX_WIDTH_340; + } if(pPriv->hasTwoOverlays) { /* Only half width available if both overlays * are going to be used */ #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { - DummyEncoding.width >>= 1; + if(pSiS->Chipset == PCI_CHIP_SIS660) { + DummyEncoding.width = 1536; + } else { + DummyEncoding.width >>= 1; + } } else #endif #ifdef SISMERGED if(pSiS->MergedFB) { - DummyEncoding.width >>= 1; + if(pSiS->Chipset == PCI_CHIP_SIS660) { + DummyEncoding.width = 1536; + } else { + DummyEncoding.width >>= 1; + } } else #endif if(pPriv->displayMode == DISPMODE_MIRROR) { - DummyEncoding.width >>= 1; + if(pSiS->Chipset == PCI_CHIP_SIS660) { + DummyEncoding.width = 1536; + } else { + DummyEncoding.width >>= 1; + } } } } @@ -1112,6 +1426,13 @@ SISSetupImageVideo(ScreenPtr pScreen) XF86VideoAdaptorPtr adapt; SISPortPrivPtr pPriv; +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,1,99,1,0) + XAAInfoRecPtr pXAA = pSiS->AccelInfoPtr; + + if (!pXAA || !pXAA->FillSolidRects) + return NULL; +#endif + if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + sizeof(SISPortPrivRec) + sizeof(DevUnion)))) @@ -1184,9 +1505,14 @@ SISSetupImageVideo(ScreenPtr pScreen) pPriv->grabbedByV4L= FALSE; pPriv->NoOverlay = FALSE; pPriv->PrevOverlay = FALSE; + pPriv->is340 = (pSiS->Chipset == PCI_CHIP_SIS340) ? TRUE : FALSE; /* gotta uninit this someplace */ - REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); +#if defined(REGION_NULL) + REGION_NULL(pScreen, &pPriv->clip); +#else + REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); +#endif pSiS->adaptor = adapt; @@ -1202,6 +1528,9 @@ SISSetupImageVideo(ScreenPtr pScreen) pSiS->xvDisableGfxLR = MAKE_ATOM(sisxvdisablegfxlr); pSiS->xvTVXPosition = MAKE_ATOM(sisxvtvxposition); pSiS->xvTVYPosition = MAKE_ATOM(sisxvtvyposition); + pSiS->xvGammaRed = MAKE_ATOM(sisxvgammared); + pSiS->xvGammaGreen = MAKE_ATOM(sisxvgammagreen); + pSiS->xvGammaBlue = MAKE_ATOM(sisxvgammablue); pSiS->xvDisableColorkey = MAKE_ATOM(sisxvdisablecolorkey); pSiS->xvUseChromakey = MAKE_ATOM(sisxvusechromakey); pSiS->xvInsideChromakey = MAKE_ATOM(sisxvinsidechromakey); @@ -1220,6 +1549,7 @@ SISSetupImageVideo(ScreenPtr pScreen) pSiS->xv_CT1 = MAKE_ATOM(sisxvsdcrt1status); pSiS->xv_CMD = MAKE_ATOM(sisxvsdcheckmodeindexforcrt2); pSiS->xv_CMDR = MAKE_ATOM(sisxvsdresultcheckmodeindexforcrt2); + pSiS->xv_RDT = MAKE_ATOM(sisxvsdredetectcrt2); pSiS->xv_TAF = MAKE_ATOM(sisxvsdsisantiflicker); pSiS->xv_TSA = MAKE_ATOM(sisxvsdsissaturation); pSiS->xv_TEE = MAKE_ATOM(sisxvsdsisedgeenhance); @@ -1243,12 +1573,22 @@ SISSetupImageVideo(ScreenPtr pScreen) pSiS->xv_PBR = MAKE_ATOM(sisxvsdstorepbrir); pSiS->xv_PBG = MAKE_ATOM(sisxvsdstorepbrig); pSiS->xv_PBB = MAKE_ATOM(sisxvsdstorepbrib); + pSiS->xv_BRR2 = MAKE_ATOM(sisxvsdstorebrir2); + pSiS->xv_BRG2 = MAKE_ATOM(sisxvsdstorebrig2); + pSiS->xv_BRB2 = MAKE_ATOM(sisxvsdstorebrib2); + pSiS->xv_PBR2 = MAKE_ATOM(sisxvsdstorepbrir2); + pSiS->xv_PBG2 = MAKE_ATOM(sisxvsdstorepbrig2); + pSiS->xv_PBB2 = MAKE_ATOM(sisxvsdstorepbrib2); pSiS->xv_SHC = MAKE_ATOM(sisxvsdhidehwcursor); + pSiS->xv_PMD = MAKE_ATOM(sisxvsdpanelmode); +#ifdef TWDEBUG + pSiS->xv_STR = MAKE_ATOM(sisxvsetreg); +#endif #ifdef SIS_CP SIS_CP_VIDEO_ATOMS #endif - pSiS->xv_sisdirectunlocked = FALSE; + pSiS->xv_sisdirectunlocked = 0; pSiS->xv_sd_result = 0; /* 300 series require double words for addresses and pitches, @@ -1271,13 +1611,14 @@ SISSetupImageVideo(ScreenPtr pScreen) * All chipsets have a certain number of linebuffers, each of a certain * size. The number of buffers is per overlay. * Chip number size max video size - * 300 2 ? ? - * 630/730 2 ? ? + * 300 2 ? 720x576 + * 630/730 2 ? 720x576 * 315 2 960? 1920x1080 * 650/740 2 960 ("120x128") 1920x1080 * M650/651.. 4 480 1920x1080 - * 330 2 960? 1920x1080? - * 660 ? ? ? + * 330 2 960 1920x1080 + * 661/741/760 4 768 1920x1080 + * 340 2 1280? ? * The unit of size is unknown; I just know that a size of 480 limits * the video source width to 384. Beyond that, line buffers must be * merged (otherwise the video output is garbled). @@ -1287,10 +1628,13 @@ SISSetupImageVideo(ScreenPtr pScreen) * either only CRT1 or only CRT2 is used. * If both overlays are going to be used (such as in modes were both * CRT1 and CRT2 are active), we are limited to the half of the - * maximum width. + * maximum width, or 1536 on 661/741/760. */ pPriv->linebufMergeLimit = LINEBUFLIMIT1; + if(pSiS->Chipset == PCI_CHIP_SIS660) { + pPriv->linebufMergeLimit = LINEBUFLIMIT3; + } set_maxencoding(pSiS, pPriv); @@ -1303,6 +1647,9 @@ SISSetupImageVideo(ScreenPtr pScreen) * generally larger, so our merging-limit is higher, too. */ pPriv->linebufMergeLimit = LINEBUFLIMIT2; + if(pSiS->Chipset == PCI_CHIP_SIS340) { + pPriv->linebufMergeLimit = LINEBUFLIMIT4; + } } } @@ -1313,11 +1660,15 @@ SISSetupImageVideo(ScreenPtr pScreen) set_disptype_regs(pScrn, pPriv); SISResetVideo(pScrn); + pSiS->ResetXv = SISResetVideo; + if(pSiS->VGAEngine == SIS_315_VGA) { + pSiS->ResetXvGamma = SISResetXvGamma; + } return adapt; } -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,3,0) static Bool RegionsEqual(RegionPtr A, RegionPtr B) { @@ -1432,16 +1783,22 @@ SISSetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, } else if(attribute == pSiS->xvChromaMax) { pPriv->chromamax = value; } else if(attribute == pSiS->xv_USD) { - if((pSiS->enablesisctrl) && (value == SIS_DIRECTKEY)) - pSiS->xv_sisdirectunlocked = TRUE; - else - pSiS->xv_sisdirectunlocked = FALSE; + if(pSiS->enablesisctrl) { + if(value == SIS_DIRECTKEY) { + pSiS->xv_sisdirectunlocked++; + } else if(pSiS->xv_sisdirectunlocked) { + pSiS->xv_sisdirectunlocked--; + } + } else { + pSiS->xv_sisdirectunlocked = 0; + } } else if(attribute == pSiS->xv_SVF) { #ifdef SISDUALHEAD if(!pPriv->dualHeadMode) #endif if(pSiS->xv_sisdirectunlocked) { SISSwitchCRT2Type(pScrn, (unsigned long)value); + set_dispmode(pScrn, pPriv); set_allowswitchcrt(pSiS, pPriv); set_maxencoding(pSiS, pPriv); } @@ -1451,13 +1808,21 @@ SISSetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, #endif if(pSiS->xv_sisdirectunlocked) { SISSwitchCRT1Status(pScrn, (unsigned long)value); + set_dispmode(pScrn, pPriv); set_allowswitchcrt(pSiS, pPriv); set_maxencoding(pSiS, pPriv); } - } else if(attribute == pSiS->xv_TAF) { - if(pSiS->xv_sisdirectunlocked) { - SiS_SetSISTVantiflicker(pScrn, (int)value); - } + } else if(attribute == pSiS->xv_RDT) { +#ifdef SISDUALHEAD + if(!pPriv->dualHeadMode) +#endif + if(pSiS->xv_sisdirectunlocked) { + SISRedetectCRT2Devices(pScrn); + } + } else if(attribute == pSiS->xv_TAF) { + if(pSiS->xv_sisdirectunlocked) { + SiS_SetSISTVantiflicker(pScrn, (int)value); + } } else if(attribute == pSiS->xv_TSA) { if(pSiS->xv_sisdirectunlocked) { SiS_SetSISTVsaturation(pScrn, (int)value); @@ -1516,26 +1881,30 @@ SISSetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, } } else if(attribute == pSiS->xv_CMD) { if(pSiS->xv_sisdirectunlocked) { + int result = 0; pSiS->xv_sd_result = (value & 0xffffff00); - if(SISCheckModeIndexForCRT2Type(pScrn, (unsigned short)(value & 0xff), - (unsigned short)((value >> 8) & 0xff), - FALSE)) { - pSiS->xv_sd_result |= 0x01; - } + result = SISCheckModeIndexForCRT2Type(pScrn, (unsigned short)(value & 0xff), + (unsigned short)((value >> 8) & 0xff), + FALSE); + pSiS->xv_sd_result |= (result & 0xff); } } else if(attribute == pSiS->xv_SGA) { if(pSiS->xv_sisdirectunlocked) { + Bool backup = pSiS->XvGamma; + pSiS->CRT1gamma = (value & 0x01) ? TRUE : FALSE; + pSiS->CRT2gamma = (value & 0x02) ? TRUE : FALSE; + pSiS->XvGamma = (value & 0x04) ? TRUE : FALSE; #ifdef SISDUALHEAD if(pPriv->dualHeadMode) { - pSiSEnt->CRT1gamma = (value & 0x01) ? TRUE : FALSE; - pSiSEnt->CRT2gamma = (value & 0x02) ? TRUE : FALSE; - } else { -#endif - pSiS->CRT1gamma = (value & 0x01) ? TRUE : FALSE; - pSiS->CRT2gamma = (value & 0x02) ? TRUE : FALSE; -#ifdef SISDUALHEAD + pSiSEnt->CRT1gamma = pSiS->CRT1gamma; + pSiSEnt->CRT2gamma = pSiS->CRT2gamma; } #endif + if(pSiS->VGAEngine == SIS_315_VGA) { + if(backup != pSiS->XvGamma) { + SiSUpdateXvGamma(pSiS, pPriv); + } + } } } else if(attribute == pSiS->xv_TXS) { if((value < -16) || (value > 16)) @@ -1585,6 +1954,54 @@ SISSetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, if(pSiS->xv_sisdirectunlocked) { pSiS->GammaPBriB = value; } + } else if(attribute == pSiS->xv_BRR2) { + if((value < 100) || (value > 10000)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) pSiSEnt->GammaBriR = value; +#endif + } + } else if(attribute == pSiS->xv_BRG2) { + if((value < 100) || (value > 10000)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) pSiSEnt->GammaBriG = value; +#endif + } + } else if(attribute == pSiS->xv_BRB2) { + if((value < 100) || (value > 10000)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) pSiSEnt->GammaBriB = value; +#endif + } + } else if(attribute == pSiS->xv_PBR2) { + if((value < 100) || (value > 10000)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) pSiSEnt->GammaPBriR = value; +#endif + } + } else if(attribute == pSiS->xv_PBG2) { + if((value < 100) || (value > 10000)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) pSiSEnt->GammaPBriG = value; +#endif + } + } else if(attribute == pSiS->xv_PBB2) { + if((value < 100) || (value > 10000)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) pSiSEnt->GammaPBriB = value; +#endif + } } else if(attribute == pSiS->xv_SHC) { if(pSiS->xv_sisdirectunlocked) { Bool VisibleBackup = pSiS->HWCursorIsVisible; @@ -1600,6 +2017,35 @@ SISSetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, pSiS->HWCursorIsVisible = VisibleBackup; } } + } else if(attribute == pSiS->xv_PMD) { + if(pSiS->xv_sisdirectunlocked) { + if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTSCALE) { + if(value & 0x01) pSiS->SiS_Pr->UsePanelScaler = -1; + else if(value & 0x02) pSiS->SiS_Pr->UsePanelScaler = 1; + else pSiS->SiS_Pr->UsePanelScaler = 0; + if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTCENTER) { + if(value & 0x04) pSiS->SiS_Pr->CenterScreen = -1; + else if(value & 0x08) pSiS->SiS_Pr->CenterScreen = 1; + else pSiS->SiS_Pr->CenterScreen = 0; + } + } + } +#ifdef TWDEBUG + } else if(attribute == pSiS->xv_STR) { + unsigned short port; + switch((value & 0xff000000) >> 24) { + case 0x00: port = SISSR; break; + case 0x01: port = SISPART1; break; + case 0x02: port = SISPART2; break; + case 0x03: port = SISPART3; break; + case 0x04: port = SISPART4; break; + case 0x05: port = SISCR; break; + case 0x06: port = SISVID; break; + default: return BadValue; + } + outSISIDXREG(port,((value & 0x00ff0000) >> 16), ((value & 0x0000ff00) >> 8)); + return Success; +#endif #ifdef SIS_CP SIS_CP_VIDEO_SETATTRIBUTE #endif @@ -1615,20 +2061,35 @@ SISSetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, } } else if(attribute == pSiS->xvHue) { if((value < -8) || (value > 7)) - return BadValue; + return BadValue; pPriv->hue = value; } else if(attribute == pSiS->xvSaturation) { if((value < -7) || (value > 7)) - return BadValue; + return BadValue; pPriv->saturation = value; + } else if(attribute == pSiS->xvGammaRed) { + if((value < 100) || (value > 10000)) + return BadValue; + pSiS->XvGammaRed = value; + SiSUpdateXvGamma(pSiS, pPriv); + } else if(attribute == pSiS->xvGammaGreen) { + if((value < 100) || (value > 10000)) + return BadValue; + pSiS->XvGammaGreen = value; + SiSUpdateXvGamma(pSiS, pPriv); + } else if(attribute == pSiS->xvGammaBlue) { + if((value < 100) || (value > 10000)) + return BadValue; + pSiS->XvGammaBlue = value; + SiSUpdateXvGamma(pSiS, pPriv); } else return BadMatch; } else return BadMatch; return Success; } -static int +static int SISGetPortAttribute( - ScrnInfoPtr pScrn, + ScrnInfoPtr pScrn, Atom attribute, INT32 *value, pointer data @@ -1637,7 +2098,7 @@ SISGetPortAttribute( SISPtr pSiS = SISPTR(pScrn); #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate;; -#endif +#endif if(attribute == pSiS->xvBrightness) { *value = pPriv->brightness; @@ -1684,7 +2145,7 @@ SISGetPortAttribute( } else if(attribute == pSiS->xv_GSF) { *value = pSiS->SiS_SD_Flags; } else if(attribute == pSiS->xv_USD) { - *value = pSiS->xv_sisdirectunlocked ? 1 : 0; + *value = pSiS->xv_sisdirectunlocked; } else if(attribute == pSiS->xv_TAF) { *value = SiS_GetSISTVantiflicker(pScrn); } else if(attribute == pSiS->xv_TSA) { @@ -1712,6 +2173,7 @@ SISGetPortAttribute( } else if(attribute == pSiS->xv_CMDR) { *value = pSiS->xv_sd_result; } else if(attribute == pSiS->xv_OVR) { + /* Changing of CRT2 settings not supported in DHM! */ *value = 0; if(pSiS->OptTVSOver == 1) *value = 3; else if(pSiS->UseCHOverScan == 1) *value = 2; @@ -1728,6 +2190,7 @@ SISGetPortAttribute( if(pSiS->CRT2gamma) *value |= 0x02; #ifdef SISDUALHEAD } + if(pSiS->XvGamma) *value |= 0x04; #endif } else if(attribute == pSiS->xv_TXS) { *value = SiS_GetTVxscale(pScrn); @@ -1747,8 +2210,58 @@ SISGetPortAttribute( *value = pSiS->GammaPBriG; } else if(attribute == pSiS->xv_PBB) { *value = pSiS->GammaPBriB; + } else if(attribute == pSiS->xv_BRR2) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) *value = pSiSEnt->GammaBriR; + else +#endif + *value = pSiS->GammaBriR; + } else if(attribute == pSiS->xv_BRG2) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) *value = pSiSEnt->GammaBriG; + else +#endif + *value = pSiS->GammaBriG; + } else if(attribute == pSiS->xv_BRB2) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) *value = pSiSEnt->GammaBriB; + else +#endif + *value = pSiS->GammaBriB; + } else if(attribute == pSiS->xv_PBR2) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) *value = pSiSEnt->GammaPBriR; + else +#endif + *value = pSiS->GammaPBriR; + } else if(attribute == pSiS->xv_PBG2) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) *value = pSiSEnt->GammaPBriG; + else +#endif + *value = pSiS->GammaPBriG; + } else if(attribute == pSiS->xv_PBB2) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) *value = pSiSEnt->GammaPBriB; + else +#endif + *value = pSiS->GammaPBriB; } else if(attribute == pSiS->xv_SHC) { *value = pSiS->HideHWCursor ? 1 : 0; + } else if(attribute == pSiS->xv_PMD) { + *value = 0; + if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTSCALE) { + switch(pSiS->SiS_Pr->UsePanelScaler) { + case -1: *value |= 0x01; break; + case 1: *value |= 0x02; break; + } + if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTCENTER) { + switch(pSiS->SiS_Pr->CenterScreen) { + case -1: *value |= 0x04; break; + case 1: *value |= 0x08; break; + } + } + } #ifdef SIS_CP SIS_CP_VIDEO_GETATTRIBUTE #endif @@ -1764,6 +2277,12 @@ SISGetPortAttribute( *value = pPriv->hue; } else if(attribute == pSiS->xvSaturation) { *value = pPriv->saturation; + } else if(attribute == pSiS->xvGammaRed) { + *value = pSiS->XvGammaRed; + } else if(attribute == pSiS->xvGammaGreen) { + *value = pSiS->XvGammaGreen; + } else if(attribute == pSiS->xvGammaBlue) { + *value = pSiS->XvGammaBlue; } else return BadMatch; } else return BadMatch; return Success; @@ -1795,12 +2314,10 @@ SiSHandleSiSDirectCommand(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv, sisdirectcomm break; case SDC_CMD_CHECKMODEFORCRT2: j = sdcbuf->sdc_parm[0]; - sdcbuf->sdc_parm[0] = 0; - if(SISCheckModeIndexForCRT2Type(pScrn, (unsigned short)(j & 0xff), - (unsigned short)((j >> 8) & 0xff), - FALSE)) { - sdcbuf->sdc_parm[0] = 1; - } + sdcbuf->sdc_parm[0] = SISCheckModeIndexForCRT2Type(pScrn, + (unsigned short)(j & 0xff), + (unsigned short)((j >> 8) & 0xff), + FALSE) & 0xff; break; default: sdcbuf->sdc_header = SDC_RESULT_UNDEFCMD; @@ -1840,16 +2357,17 @@ calc_scale_factor(SISOverlayPtr pOverlay, ScrnInfoPtr pScrn, int origdstH = dstH; int modeflags = pOverlay->currentmode->Flags; - /* TW: Stretch image due to panel link scaling */ - if(pSiS->VBFlags & CRT2_LCD) { + /* Stretch image due to panel link scaling */ + if(pSiS->VBFlags & (CRT2_LCD | CRT1_LCDA)) { if(pPriv->bridgeIsSlave) { if(pSiS->VBFlags & (VB_LVDS | VB_30xBDH)) { if(pSiS->MiscFlags & MISC_PANELLINKSCALER) { dstH = (dstH * LCDheight) / pOverlay->SCREENheight; } } - } else if(iscrt2) { - if(pSiS->VBFlags & (VB_LVDS | VB_30xBDH)) { + } else if((iscrt2 && (pSiS->VBFlags & CRT2_LCD)) || + (!iscrt2 && (pSiS->VBFlags & CRT1_LCDA))) { + if(pSiS->VBFlags & (VB_LVDS | VB_30xBDH | CRT1_LCDA)) { if(pSiS->MiscFlags & MISC_PANELLINKSCALER) { dstH = (dstH * LCDheight) / pOverlay->SCREENheight; if(pPriv->displayMode == DISPMODE_MIRROR) flag = 1; @@ -1863,99 +2381,94 @@ calc_scale_factor(SISOverlayPtr pOverlay, ScrnInfoPtr pScrn, * Interlace mode vice versa. */ if(modeflags & V_DBLSCAN) { - dstH = origdstH << 1; - flag = 0; - if((pSiS->sishw_ext.jChipType >= SIS_315H) && - (pSiS->sishw_ext.jChipType <= SIS_550)) { - dstW <<= 1; - } + dstH = origdstH << 1; + flag = 0; + if((pSiS->sishw_ext.jChipType >= SIS_315H) && + (pSiS->sishw_ext.jChipType <= SIS_550)) { + dstW <<= 1; + } } if(modeflags & V_INTERLACE) { - dstH = origdstH >> 1; - flag = 0; + dstH = origdstH >> 1; + flag = 0; } -#if 0 - /* TEST @@@ */ - if(pOverlay->bobEnable & 0x08) dstH <<= 1; -#endif - if(dstW < OVERLAY_MIN_WIDTH) dstW = OVERLAY_MIN_WIDTH; if(dstW == srcW) { - pOverlay->HUSF = 0x00; - pOverlay->IntBit = 0x05; - pOverlay->wHPre = 0; + pOverlay->HUSF = 0x00; + pOverlay->IntBit = 0x05; + pOverlay->wHPre = 0; } else if(dstW > srcW) { - dstW += 2; - pOverlay->HUSF = (srcW << 16) / dstW; - pOverlay->IntBit = 0x04; - pOverlay->wHPre = 0; + dstW += 2; + pOverlay->HUSF = (srcW << 16) / dstW; + pOverlay->IntBit = 0x04; + pOverlay->wHPre = 0; } else { - int tmpW = dstW; - - /* It seems, the hardware can't scale below factor .125 (=1/8) if the - pitch isn't a multiple of 256. - TODO: Test this on the 315 series! - */ - if((srcPitch % 256) || (srcPitch < 256)) { - if(((dstW * 1000) / srcW) < 125) dstW = tmpW = ((srcW * 125) / 1000) + 1; - } + int tmpW = dstW; - I = 0; - pOverlay->IntBit = 0x01; - while (srcW >= tmpW) { - tmpW <<= 1; - I++; - } - pOverlay->wHPre = (CARD8)(I - 1); - dstW <<= (I - 1); - if((srcW % dstW)) - pOverlay->HUSF = ((srcW - dstW) << 16) / dstW; - else - pOverlay->HUSF = 0x00; + /* It seems, the hardware can't scale below factor .125 (=1/8) if the + pitch isn't a multiple of 256. + TODO: Test this on the 315 series! + */ + if((srcPitch % 256) || (srcPitch < 256)) { + if(((dstW * 1000) / srcW) < 125) dstW = tmpW = ((srcW * 125) / 1000) + 1; + } + + I = 0; + pOverlay->IntBit = 0x01; + while(srcW >= tmpW) { + tmpW <<= 1; + I++; + } + pOverlay->wHPre = (CARD8)(I - 1); + dstW <<= (I - 1); + if((srcW % dstW)) + pOverlay->HUSF = ((srcW - dstW) << 16) / dstW; + else + pOverlay->HUSF = 0x00; } if(dstH < OVERLAY_MIN_HEIGHT) dstH = OVERLAY_MIN_HEIGHT; if(dstH == srcH) { - pOverlay->VUSF = 0x00; - pOverlay->IntBit |= 0x0A; + pOverlay->VUSF = 0x00; + pOverlay->IntBit |= 0x0A; } else if(dstH > srcH) { - dstH += 0x02; - pOverlay->VUSF = (srcH << 16) / dstH; - pOverlay->IntBit |= 0x08; + dstH += 0x02; + pOverlay->VUSF = (srcH << 16) / dstH; + pOverlay->IntBit |= 0x08; } else { - CARD32 realI; - I = realI = srcH / dstH; - pOverlay->IntBit |= 0x02; + I = srcH / dstH; + pOverlay->IntBit |= 0x02; - if(I < 2) { - pOverlay->VUSF = ((srcH - dstH) << 16) / dstH; - /* TW: Needed for LCD-scaling modes */ - if((flag) && (mult = (srcH / origdstH)) >= 2) - pOverlay->pitch /= mult; - } else { + if(I < 2) { + pOverlay->VUSF = ((srcH - dstH) << 16) / dstH; + /* Needed for LCD-scaling modes */ + if((flag) && (mult = (srcH / origdstH)) >= 2) { + pOverlay->pitch /= mult; + } + } else { #if 0 - if(((pOverlay->bobEnable & 0x08) == 0x00) && - (((srcPitch * I)>>2) > 0xFFF)){ - pOverlay->bobEnable |= 0x08; - srcPitch >>= 1; - } + if(((pOverlay->bobEnable & 0x08) == 0x00) && + (((srcPitch * I) >> 2) > 0xFFF)){ + pOverlay->bobEnable |= 0x08; + srcPitch >>= 1; + } #endif - if(((srcPitch * I)>>2) > 0xFFF) { - I = (0xFFF*2/srcPitch); - pOverlay->VUSF = 0xFFFF; - } else { - dstH = I * dstH; - if(srcH % dstH) - pOverlay->VUSF = ((srcH - dstH) << 16) / dstH; - else - pOverlay->VUSF = 0x00; - } - /* set video frame buffer offset */ - pOverlay->pitch = (CARD16)(srcPitch*I); + if(((srcPitch * I) >> 2) > 0xFFF) { + I = (0xFFF * 2 / srcPitch); + pOverlay->VUSF = 0xFFFF; + } else { + dstH = I * dstH; + if(srcH % dstH) + pOverlay->VUSF = ((srcH - dstH) << 16) / dstH; + else + pOverlay->VUSF = 0x00; } - } + /* set video frame buffer offset */ + pOverlay->pitch = (CARD16)(srcPitch * I); + } + } } #ifdef SISMERGED @@ -1990,196 +2503,193 @@ calc_scale_factor_2(SISOverlayPtr pOverlay, ScrnInfoPtr pScrn, * Interlace mode vice versa. */ if(modeflags & V_DBLSCAN) { - dstH = origdstH << 1; - flag = 0; - if((pSiS->sishw_ext.jChipType >= SIS_315H) && - (pSiS->sishw_ext.jChipType <= SIS_550)) { - dstW <<= 1; - } + dstH = origdstH << 1; + flag = 0; + if((pSiS->sishw_ext.jChipType >= SIS_315H) && + (pSiS->sishw_ext.jChipType <= SIS_550)) { + dstW <<= 1; + } } if(modeflags & V_INTERLACE) { - dstH = origdstH >> 1; - flag = 0; + dstH = origdstH >> 1; + flag = 0; } -#if 0 - /* TEST @@@ */ - if(pOverlay->bobEnable & 0x08) dstH <<= 1; -#endif - if(dstW < OVERLAY_MIN_WIDTH) dstW = OVERLAY_MIN_WIDTH; if(dstW == srcW) { - pOverlay->HUSF2 = 0x00; - pOverlay->IntBit2 = 0x05; - pOverlay->wHPre2 = 0; + pOverlay->HUSF2 = 0x00; + pOverlay->IntBit2 = 0x05; + pOverlay->wHPre2 = 0; } else if(dstW > srcW) { - dstW += 2; - pOverlay->HUSF2 = (srcW << 16) / dstW; - pOverlay->IntBit2 = 0x04; - pOverlay->wHPre2 = 0; + dstW += 2; + pOverlay->HUSF2 = (srcW << 16) / dstW; + pOverlay->IntBit2 = 0x04; + pOverlay->wHPre2 = 0; } else { - int tmpW = dstW; - - /* It seems, the hardware can't scale below factor .125 (=1/8) if the - pitch isn't a multiple of 256. - TODO: Test this on the 315 series! - */ - if((srcPitch % 256) || (srcPitch < 256)) { - if(((dstW * 1000) / srcW) < 125) dstW = tmpW = ((srcW * 125) / 1000) + 1; - } + int tmpW = dstW; - I = 0; - pOverlay->IntBit2 = 0x01; - while (srcW >= tmpW) { - tmpW <<= 1; - I++; - } - pOverlay->wHPre2 = (CARD8)(I - 1); - dstW <<= (I - 1); - if((srcW % dstW)) - pOverlay->HUSF2 = ((srcW - dstW) << 16) / dstW; - else - pOverlay->HUSF2 = 0x00; + /* It seems, the hardware can't scale below factor .125 (=1/8) if the + pitch isn't a multiple of 256. + TODO: Test this on the 315 series! + */ + if((srcPitch % 256) || (srcPitch < 256)) { + if(((dstW * 1000) / srcW) < 125) dstW = tmpW = ((srcW * 125) / 1000) + 1; + } + + I = 0; + pOverlay->IntBit2 = 0x01; + while(srcW >= tmpW) { + tmpW <<= 1; + I++; + } + pOverlay->wHPre2 = (CARD8)(I - 1); + dstW <<= (I - 1); + if((srcW % dstW)) + pOverlay->HUSF2 = ((srcW - dstW) << 16) / dstW; + else + pOverlay->HUSF2 = 0x00; } if(dstH < OVERLAY_MIN_HEIGHT) dstH = OVERLAY_MIN_HEIGHT; if(dstH == srcH) { - pOverlay->VUSF2 = 0x00; - pOverlay->IntBit2 |= 0x0A; + pOverlay->VUSF2 = 0x00; + pOverlay->IntBit2 |= 0x0A; } else if(dstH > srcH) { - dstH += 0x02; - pOverlay->VUSF2 = (srcH << 16) / dstH; - pOverlay->IntBit2 |= 0x08; + dstH += 0x02; + pOverlay->VUSF2 = (srcH << 16) / dstH; + pOverlay->IntBit2 |= 0x08; } else { - CARD32 realI; - I = realI = srcH / dstH; - pOverlay->IntBit2 |= 0x02; + I = srcH / dstH; + pOverlay->IntBit2 |= 0x02; - if(I < 2) { - pOverlay->VUSF2 = ((srcH - dstH) << 16) / dstH; - /* Needed for LCD-scaling modes */ - if(flag && ((mult = (srcH / origdstH)) >= 2)) - pOverlay->pitch2 /= mult; - } else { + if(I < 2) { + pOverlay->VUSF2 = ((srcH - dstH) << 16) / dstH; + /* Needed for LCD-scaling modes */ + if(flag && ((mult = (srcH / origdstH)) >= 2)) { + pOverlay->pitch2 /= mult; + } + } else { #if 0 - if(((pOverlay->bobEnable & 0x08) == 0x00) && - (((srcPitch * I)>>2) > 0xFFF)){ - pOverlay->bobEnable |= 0x08; - srcPitch >>= 1; - } + if(((pOverlay->bobEnable & 0x08) == 0x00) && + (((srcPitch * I)>>2) > 0xFFF)){ + pOverlay->bobEnable |= 0x08; + srcPitch >>= 1; + } #endif - if(((srcPitch * I)>>2) > 0xFFF) { - I = (0xFFF*2/srcPitch); - pOverlay->VUSF2 = 0xFFFF; - } else { - dstH = I * dstH; - if(srcH % dstH) - pOverlay->VUSF2 = ((srcH - dstH) << 16) / dstH; - else - pOverlay->VUSF2 = 0x00; - } - /* set video frame buffer offset */ - pOverlay->pitch2 = (CARD16)(srcPitch*I); + if(((srcPitch * I) >> 2) > 0xFFF) { + I = (0xFFF * 2 / srcPitch); + pOverlay->VUSF2 = 0xFFFF; + } else { + dstH = I * dstH; + if(srcH % dstH) + pOverlay->VUSF2 = ((srcH - dstH) << 16) / dstH; + else + pOverlay->VUSF2 = 0x00; } - } + /* set video frame buffer offset */ + pOverlay->pitch2 = (CARD16)(srcPitch * I); + } + } } #endif -static CARD8 -calc_line_buf_size(CARD32 srcW, CARD8 wHPre, CARD32 pixelFormat) +static CARD16 +calc_line_buf_size(CARD32 srcW, CARD8 wHPre, CARD8 planar, SISPortPrivPtr pPriv) { - CARD8 preHIDF; CARD32 I; - CARD32 line = srcW; - if( (pixelFormat == PIXEL_FMT_YV12) || - (pixelFormat == PIXEL_FMT_I420) || - (pixelFormat == PIXEL_FMT_NV12) || - (pixelFormat == PIXEL_FMT_NV21) ) - { - preHIDF = wHPre & 0x07; - switch (preHIDF) - { - case 3 : - if((line & 0xffffff00) == line) - I = (line >> 8); - else - I = (line >> 8) + 1; - return((CARD8)(I * 32 - 1)); - case 4 : - if((line & 0xfffffe00) == line) - I = (line >> 9); - else - I = (line >> 9) + 1; - return((CARD8)(I * 64 - 1)); - case 5 : - if((line & 0xfffffc00) == line) - I = (line >> 10); - else - I = (line >> 10) + 1; - return((CARD8)(I * 128 - 1)); - case 6 : - return((CARD8)(255)); - default : - if((line & 0xffffff80) == line) - I = (line >> 7); - else - I = (line >> 7) + 1; - return((CARD8)(I * 16 - 1)); + if(planar) { + + switch(wHPre & 0x07) { + case 3: + I = (srcW >> 8); + if(srcW & 0xff) I++; + I <<= 5; + break; + case 4: + I = (srcW >> 9); + if(srcW & 0x1ff) I++; + I <<= 6; + break; + case 5: + I = (srcW >> 10); + if(srcW & 0x3ff) I++; + I <<= 7; + break; + case 6: + if(pPriv->is340) { + I = (srcW >> 11); + if(srcW & 0x7ff) I++; + I <<= 8; + break; + } else { + return((CARD16)(255)); + } + default: + I = (srcW >> 7); + if(srcW & 0x7f) I++; + I <<= 4; + break; } - } else { /* YUV2, UYVY */ - if((line & 0xffffff8) == line) - I = (line >> 3); - else - I = (line >> 3) + 1; - return((CARD8)(I - 1)); + + } else { /* packed */ + + I = (srcW >> 3); + if(srcW & 0x07) I++; + } + + if(I <= 3) I = 4; + + return((CARD16)(I - 1)); } static __inline void -set_line_buf_size_1(SISOverlayPtr pOverlay) +calc_line_buf_size_1(SISOverlayPtr pOverlay, SISPortPrivPtr pPriv) { - pOverlay->lineBufSize = calc_line_buf_size(pOverlay->srcW,pOverlay->wHPre, pOverlay->pixelFormat); + pOverlay->lineBufSize = + calc_line_buf_size(pOverlay->srcW, pOverlay->wHPre, pOverlay->planar, pPriv); } #ifdef SISMERGED static __inline void -set_line_buf_size_2(SISOverlayPtr pOverlay) +calc_line_buf_size_2(SISOverlayPtr pOverlay, SISPortPrivPtr pPriv) { - pOverlay->lineBufSize2 = calc_line_buf_size(pOverlay->srcW2,pOverlay->wHPre2, pOverlay->pixelFormat); + pOverlay->lineBufSize2 = + calc_line_buf_size(pOverlay->srcW2, pOverlay->wHPre2, pOverlay->planar, pPriv); } static void merge_line_buf_mfb(SISPtr pSiS, SISPortPrivPtr pPriv, Bool enable1, Bool enable2, short width1, short width2, short limit) { - unsigned char misc1, misc2, mask = pPriv->linebufmask; + unsigned char misc1, misc2, mask = pPriv->linebufmask; - if(pPriv->hasTwoOverlays) { /* This means we are in MIRROR mode */ + if(pPriv->hasTwoOverlays) { /* This means we are in MIRROR mode */ - misc2 = 0x00; - if(enable1) misc1 = 0x04; - else misc1 = 0x00; - setvideoregmask(pSiS, Index_VI_Control_Misc2, misc2, mask); - setvideoregmask(pSiS, Index_VI_Control_Misc1, misc1, 0x04); + misc2 = 0x00; + if(enable1) misc1 = 0x04; + else misc1 = 0x00; + setvideoregmask(pSiS, Index_VI_Control_Misc2, misc2, mask); + setvideoregmask(pSiS, Index_VI_Control_Misc1, misc1, 0x04); - misc2 = 0x01; - if(enable2) misc1 = 0x04; - else misc1 = 0x00; - setvideoregmask(pSiS, Index_VI_Control_Misc2, misc2, mask); - setvideoregmask(pSiS, Index_VI_Control_Misc1, misc1, 0x04); + misc2 = 0x01; + if(enable2) misc1 = 0x04; + else misc1 = 0x00; + setvideoregmask(pSiS, Index_VI_Control_Misc2, misc2, mask); + setvideoregmask(pSiS, Index_VI_Control_Misc1, misc1, 0x04); - } else { /* This means we are either in SINGLE1 or SINGLE2 mode */ + } else { /* This means we are either in SINGLE1 or SINGLE2 mode */ - misc2 = 0x00; - if(enable1 || enable2) misc1 = 0x04; - else misc1 = 0x00; + misc2 = 0x00; + if(enable1 || enable2) misc1 = 0x04; + else misc1 = 0x00; - setvideoregmask(pSiS, Index_VI_Control_Misc2, misc2, mask); - setvideoregmask(pSiS, Index_VI_Control_Misc1, misc1, 0x04); + setvideoregmask(pSiS, Index_VI_Control_Misc2, misc2, mask); + setvideoregmask(pSiS, Index_VI_Control_Misc1, misc1, 0x04); - } + } } #endif @@ -2207,6 +2717,7 @@ merge_line_buf_mfb(SISPtr pSiS, SISPortPrivPtr pPriv, Bool enable1, Bool enable2 * Individual merge is supported on all chipsets. * Dual merge is only supported on the 300 series and M650/651 and later. * All merge is only supported on the M650/651 and later. + * Single-Overlay-chipsets only support Individual merge. * */ @@ -2413,12 +2924,12 @@ set_brightness(SISPtr pSiS, CARD8 brightness) static __inline void set_contrast(SISPtr pSiS, CARD8 contrast) { - setvideoregmask(pSiS, Index_VI_Contrast_Enh_Ctrl, contrast ^ 0x07, 0x07); + setvideoregmask(pSiS, Index_VI_Contrast_Enh_Ctrl, contrast, 0x07); } /* 315 series and later only */ static __inline void -set_saturation(SISPtr pSiS, char saturation) +set_saturation(SISPtr pSiS, short saturation) { CARD8 temp = 0; @@ -2436,15 +2947,17 @@ set_saturation(SISPtr pSiS, char saturation) static __inline void set_hue(SISPtr pSiS, CARD8 hue) { - setvideoreg(pSiS, Index_VI_Hue, (hue & 0x08) ? (hue ^ 0x07) : hue); + setvideoregmask(pSiS, Index_VI_Hue, (hue & 0x08) ? (hue ^ 0x07) : hue, 0x0F); } static __inline void set_disablegfx(SISPtr pSiS, Bool mybool, SISOverlayPtr pOverlay) { - /* This is not supported on M65x or 65x (x>0) */ + /* This is not supported on M65x, 65x (x>0) or later */ /* For CRT1 ONLY!!! */ - if(!(pSiS->ChipFlags & SiSCF_Is65x)) { + if((!(pSiS->ChipFlags & SiSCF_Is65x)) && + (pSiS->Chipset != PCI_CHIP_SIS660) && + (pSiS->Chipset != PCI_CHIP_SIS340)) { setvideoregmask(pSiS, Index_VI_Control_Misc2, mybool ? 0x04 : 0x00, 0x04); if(mybool) pOverlay->keyOP = VI_ROP_Always; } @@ -2464,16 +2977,11 @@ set_disablegfxlr(SISPtr pSiS, Bool mybool, SISOverlayPtr pOverlay) static void set_overlay(SISPtr pSiS, SISOverlayPtr pOverlay, SISPortPrivPtr pPriv, int index, int iscrt2) { - ScrnInfoPtr pScrn = pSiS->pScrn; - - CARD16 pitch=0; CARD8 h_over=0, v_over=0; - CARD16 top, bottom, left, right; + CARD16 top, bottom, left, right, pitch=0; CARD16 screenX, screenY; - int modeflags; - CARD8 data; - CARD32 watchdog; CARD32 PSY; + int modeflags, watchdog=0; #ifdef SISMERGED if(pSiS->MergedFB && iscrt2) { @@ -2522,34 +3030,62 @@ set_overlay(SISPtr pSiS, SISOverlayPtr pOverlay, SISPortPrivPtr pPriv, int index /* set line buffer size */ #ifdef SISMERGED - if(pSiS->MergedFB && iscrt2) - setvideoreg(pSiS, Index_VI_Line_Buffer_Size, pOverlay->lineBufSize2); - else + if(pSiS->MergedFB && iscrt2) { + setvideoreg(pSiS, Index_VI_Line_Buffer_Size, (CARD8)pOverlay->lineBufSize2); + if(pPriv->is340) { + setvideoreg(pSiS, Index_VI_Line_Buffer_Size_High, (CARD8)(pOverlay->lineBufSize2 >> 8)); + } + } else { #endif - setvideoreg(pSiS, Index_VI_Line_Buffer_Size, pOverlay->lineBufSize); + setvideoreg(pSiS, Index_VI_Line_Buffer_Size, (CARD8)pOverlay->lineBufSize); + if(pPriv->is340) { + setvideoreg(pSiS, Index_VI_Line_Buffer_Size_High, (CARD8)(pOverlay->lineBufSize >> 8)); + } +#ifdef SISMERGED + } +#endif /* set color key mode */ setvideoregmask(pSiS, Index_VI_Key_Overlay_OP, pOverlay->keyOP, 0x0f); - + /* We don't have to wait for vertical retrace in all cases */ if(pPriv->mustwait) { - watchdog = WATCHDOG_DELAY; - while (pOverlay->VBlankActiveFunc(pSiS) && --watchdog); - watchdog = WATCHDOG_DELAY; - while ((!pOverlay->VBlankActiveFunc(pSiS)) && --watchdog); - if(!watchdog) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Xv: Waiting for vertical retrace timed-out\n"); + if(pSiS->VGAEngine == SIS_315_VGA) { + + if(index) { + CARD16 mytop = getvideoreg(pSiS, Index_VI_Win_Ver_Disp_Start_Low); + mytop |= ((getvideoreg(pSiS, Index_VI_Win_Ver_Over) & 0x0f) << 8); + pOverlay->oldtop = mytop; + watchdog = 0xffff; + if(mytop < screenY - 2) { + do { + watchdog = get_scanline_CRT2(pSiS, pPriv); + } while((watchdog <= mytop) || (watchdog >= screenY)); + } + pOverlay->oldLine = watchdog; + } + + } else { + + watchdog = WATCHDOG_DELAY; + while(pOverlay->VBlankActiveFunc(pSiS, pPriv) && --watchdog); + watchdog = WATCHDOG_DELAY; + while((!pOverlay->VBlankActiveFunc(pSiS, pPriv)) && --watchdog); + + } } - + /* Unlock address registers */ - data = getvideoreg(pSiS, Index_VI_Control_Misc1); - setvideoreg(pSiS, Index_VI_Control_Misc1, data | 0x20); - /* Is this required? */ - setvideoreg(pSiS, Index_VI_Control_Misc1, data | 0x20); + setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x20, 0x20); + + /* set destination window position */ + setvideoreg(pSiS, Index_VI_Win_Hor_Disp_Start_Low, (CARD8)left); + setvideoreg(pSiS, Index_VI_Win_Hor_Disp_End_Low, (CARD8)right); + setvideoreg(pSiS, Index_VI_Win_Hor_Over, (CARD8)h_over); - /* Is this required? (seems so) */ - if(pSiS->Chipset == SIS_315_VGA) - setvideoregmask(pSiS, Index_VI_Control_Misc3, 0x00, (1 << index)); + setvideoreg(pSiS, Index_VI_Win_Ver_Disp_Start_Low, (CARD8)top); + setvideoreg(pSiS, Index_VI_Win_Ver_Disp_End_Low, (CARD8)bottom); + setvideoreg(pSiS, Index_VI_Win_Ver_Over, (CARD8)v_over); /* Set Y buf pitch */ setvideoreg(pSiS, Index_VI_Disp_Y_Buf_Pitch_Low, (CARD8)(pitch)); @@ -2569,95 +3105,85 @@ set_overlay(SISPtr pSiS, SISOverlayPtr pOverlay, SISPortPrivPtr pPriv, int index /* set 315 series overflow bits for Y plane */ if(pSiS->VGAEngine == SIS_315_VGA) { - setvideoreg(pSiS, Index_VI_Disp_Y_Buf_Pitch_High, (CARD8)(pitch >> 12)); - setvideoreg(pSiS, Index_VI_Y_Buf_Start_Over, ((CARD8)(PSY >> 24) & 0x03)); + setvideoreg(pSiS, Index_VI_Disp_Y_Buf_Pitch_High, (CARD8)(pitch >> 12)); + setvideoreg(pSiS, Index_VI_Y_Buf_Start_Over, ((CARD8)(PSY >> 24) & 0x03)); } /* Set U/V data if using planar formats */ - if( (pOverlay->pixelFormat == PIXEL_FMT_YV12) || - (pOverlay->pixelFormat == PIXEL_FMT_I420) || - (pOverlay->pixelFormat == PIXEL_FMT_NV12) || - (pOverlay->pixelFormat == PIXEL_FMT_NV21) ) { + if(pOverlay->planar) { - CARD32 PSU=0, PSV=0, uvpitch = pitch; + CARD32 PSU = pOverlay->PSU; + CARD32 PSV = pOverlay->PSV; - PSU = pOverlay->PSU; - PSV = pOverlay->PSV; #ifdef SISMERGED if(pSiS->MergedFB && iscrt2) { PSU = pOverlay->PSU2; PSV = pOverlay->PSV2; } #endif - if((pOverlay->pixelFormat == PIXEL_FMT_YV12) || - (pOverlay->pixelFormat == PIXEL_FMT_I420)) { - uvpitch >>= 1; - } + + if(pOverlay->planar_shiftpitch) pitch >>= 1; /* Set U/V pitch */ - setvideoreg (pSiS, Index_VI_Disp_UV_Buf_Pitch_Low, (CARD8)uvpitch); - setvideoregmask (pSiS, Index_VI_Disp_Y_UV_Buf_Pitch_Middle, (CARD8)(uvpitch >> 4), 0xf0); + setvideoreg(pSiS, Index_VI_Disp_UV_Buf_Pitch_Low, (CARD8)pitch); + setvideoregmask(pSiS, Index_VI_Disp_Y_UV_Buf_Pitch_Middle, (CARD8)(pitch >> 4), 0xf0); /* set U/V start address */ - setvideoreg (pSiS, Index_VI_U_Buf_Start_Low, (CARD8)PSU); - setvideoreg (pSiS, Index_VI_U_Buf_Start_Middle,(CARD8)(PSU >> 8)); - setvideoreg (pSiS, Index_VI_U_Buf_Start_High, (CARD8)(PSU >> 16)); + setvideoreg(pSiS, Index_VI_U_Buf_Start_Low, (CARD8)PSU); + setvideoreg(pSiS, Index_VI_U_Buf_Start_Middle,(CARD8)(PSU >> 8)); + setvideoreg(pSiS, Index_VI_U_Buf_Start_High, (CARD8)(PSU >> 16)); - setvideoreg (pSiS, Index_VI_V_Buf_Start_Low, (CARD8)PSV); - setvideoreg (pSiS, Index_VI_V_Buf_Start_Middle,(CARD8)(PSV >> 8)); - setvideoreg (pSiS, Index_VI_V_Buf_Start_High, (CARD8)(PSV >> 16)); + setvideoreg(pSiS, Index_VI_V_Buf_Start_Low, (CARD8)PSV); + setvideoreg(pSiS, Index_VI_V_Buf_Start_Middle,(CARD8)(PSV >> 8)); + setvideoreg(pSiS, Index_VI_V_Buf_Start_High, (CARD8)(PSV >> 16)); /* 315 series overflow bits */ if(pSiS->VGAEngine == SIS_315_VGA) { - setvideoreg (pSiS, Index_VI_Disp_UV_Buf_Pitch_High, (CARD8)(uvpitch >> 12)); - setvideoreg (pSiS, Index_VI_U_Buf_Start_Over, ((CARD8)(PSU >> 24) & 0x03)); - setvideoreg (pSiS, Index_VI_V_Buf_Start_Over, ((CARD8)(PSV >> 24) & 0x03)); + setvideoreg(pSiS, Index_VI_Disp_UV_Buf_Pitch_High, (CARD8)(pitch >> 12)); + setvideoreg(pSiS, Index_VI_U_Buf_Start_Over, ((CARD8)(PSU >> 24) & 0x03)); + if(pSiS->sishw_ext.jChipType == SIS_661) { + setvideoregmask(pSiS, Index_VI_V_Buf_Start_Over, ((CARD8)(PSV >> 24) & 0x03), 0xc3); + } else { + setvideoreg(pSiS, Index_VI_V_Buf_Start_Over, ((CARD8)(PSV >> 24) & 0x03)); + } } } + + setvideoregmask(pSiS, Index_VI_Control_Misc1, pOverlay->bobEnable, 0x1a); + + /* Lock the address registers */ + setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x20); /* set scale factor */ #ifdef SISMERGED if(pSiS->MergedFB && iscrt2) { - setvideoreg (pSiS, Index_VI_Hor_Post_Up_Scale_Low, (CARD8)(pOverlay->HUSF2)); - setvideoreg (pSiS, Index_VI_Hor_Post_Up_Scale_High,(CARD8)((pOverlay->HUSF2) >> 8)); - setvideoreg (pSiS, Index_VI_Ver_Up_Scale_Low, (CARD8)(pOverlay->VUSF2)); - setvideoreg (pSiS, Index_VI_Ver_Up_Scale_High, (CARD8)((pOverlay->VUSF2) >> 8)); + setvideoreg(pSiS, Index_VI_Hor_Post_Up_Scale_Low, (CARD8)(pOverlay->HUSF2)); + setvideoreg(pSiS, Index_VI_Hor_Post_Up_Scale_High,(CARD8)((pOverlay->HUSF2) >> 8)); + setvideoreg(pSiS, Index_VI_Ver_Up_Scale_Low, (CARD8)(pOverlay->VUSF2)); + setvideoreg(pSiS, Index_VI_Ver_Up_Scale_High, (CARD8)((pOverlay->VUSF2) >> 8)); - setvideoregmask (pSiS, Index_VI_Scale_Control, (pOverlay->IntBit2 << 3) - |(pOverlay->wHPre2), 0x7f); + setvideoregmask(pSiS, Index_VI_Scale_Control, (pOverlay->IntBit2 << 3) | + (pOverlay->wHPre2), 0x7f); } else { #endif - setvideoreg (pSiS, Index_VI_Hor_Post_Up_Scale_Low, (CARD8)(pOverlay->HUSF)); - setvideoreg (pSiS, Index_VI_Hor_Post_Up_Scale_High,(CARD8)((pOverlay->HUSF) >> 8)); - setvideoreg (pSiS, Index_VI_Ver_Up_Scale_Low, (CARD8)(pOverlay->VUSF)); - setvideoreg (pSiS, Index_VI_Ver_Up_Scale_High, (CARD8)((pOverlay->VUSF)>>8)); + setvideoreg(pSiS, Index_VI_Hor_Post_Up_Scale_Low, (CARD8)(pOverlay->HUSF)); + setvideoreg(pSiS, Index_VI_Hor_Post_Up_Scale_High,(CARD8)((pOverlay->HUSF) >> 8)); + setvideoreg(pSiS, Index_VI_Ver_Up_Scale_Low, (CARD8)(pOverlay->VUSF)); + setvideoreg(pSiS, Index_VI_Ver_Up_Scale_High, (CARD8)((pOverlay->VUSF) >> 8)); - setvideoregmask (pSiS, Index_VI_Scale_Control, (pOverlay->IntBit << 3) - |(pOverlay->wHPre), 0x7f); + setvideoregmask(pSiS, Index_VI_Scale_Control, (pOverlay->IntBit << 3) | + (pOverlay->wHPre), 0x7f); #ifdef SISMERGED } #endif - - /* set destination window position */ - setvideoreg(pSiS, Index_VI_Win_Hor_Disp_Start_Low, (CARD8)left); - setvideoreg(pSiS, Index_VI_Win_Hor_Disp_End_Low, (CARD8)right); - setvideoreg(pSiS, Index_VI_Win_Hor_Over, (CARD8)h_over); - - setvideoreg(pSiS, Index_VI_Win_Ver_Disp_Start_Low, (CARD8)top); - setvideoreg(pSiS, Index_VI_Win_Ver_Disp_End_Low, (CARD8)bottom); - setvideoreg(pSiS, Index_VI_Win_Ver_Over, (CARD8)v_over); - - setvideoregmask(pSiS, Index_VI_Control_Misc1, pOverlay->bobEnable, 0x1a); - - /* Lock the address registers */ - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x20); + } /* Overlay MUST NOT be switched off while beam is over it */ static void close_overlay(SISPtr pSiS, SISPortPrivPtr pPriv) { - CARD32 watchdog; + int watchdog; if(!(pPriv->overlayStatus)) return; pPriv->overlayStatus = FALSE; @@ -2691,15 +3217,16 @@ close_overlay(SISPtr pSiS, SISPortPrivPtr pPriv) } setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x01); + watchdog = WATCHDOG_DELAY; - while(vblank_active_CRT2(pSiS) && --watchdog); + while((!vblank_active_CRT2(pSiS, pPriv)) && --watchdog); watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT2(pSiS)) && --watchdog); + while(vblank_active_CRT2(pSiS, pPriv) && --watchdog); setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); watchdog = WATCHDOG_DELAY; - while(vblank_active_CRT2(pSiS) && --watchdog); + while((!vblank_active_CRT2(pSiS, pPriv)) && --watchdog); watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT2(pSiS)) && --watchdog); + while(vblank_active_CRT2(pSiS, pPriv) && --watchdog); #ifdef SIS_CP SIS_CP_RESET_CP @@ -2720,17 +3247,19 @@ close_overlay(SISPtr pSiS, SISPortPrivPtr pPriv) } } #endif + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0x05); setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x01); + watchdog = WATCHDOG_DELAY; - while(vblank_active_CRT1(pSiS) && --watchdog); + while((!vblank_active_CRT1(pSiS, pPriv)) && --watchdog); watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT1(pSiS)) && --watchdog); + while(vblank_active_CRT1(pSiS, pPriv) && --watchdog); setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); watchdog = WATCHDOG_DELAY; - while(vblank_active_CRT1(pSiS) && --watchdog); + while((!vblank_active_CRT1(pSiS, pPriv)) && --watchdog); watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT1(pSiS)) && --watchdog); + while(vblank_active_CRT1(pSiS, pPriv) && --watchdog); } } @@ -2751,10 +3280,9 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) int index = 0, iscrt2 = 0; #ifdef SISMERGED unsigned char temp; - CARD32 watchdog; unsigned short screen2width=0; int srcOffsetX2=0, srcOffsetY2=0; - int sx2=0, sy2=0; + int sx2=0, sy2=0, watchdog; #endif pPriv->NoOverlay = FALSE; @@ -2786,15 +3314,21 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) set_dispmode(pScrn, pPriv); /* Check if overlay is supported with current mode */ - if(pPriv->displayMode & (DISPMODE_SINGLE1 | DISPMODE_MIRROR)) { - if(!(pSiS->MiscFlags & MISC_CRT1OVERLAY)) { - if(pPriv->overlayStatus) { - close_overlay(pSiS, pPriv); - } - pPriv->NoOverlay = TRUE; - return; +#ifdef SISMERGED + if(!pSiS->MergedFB) { +#endif + if(pPriv->displayMode & (DISPMODE_SINGLE1 | DISPMODE_MIRROR)) { + if(!(pSiS->MiscFlags & MISC_CRT1OVERLAY)) { + if(pPriv->overlayStatus) { + close_overlay(pSiS, pPriv); + } + pPriv->NoOverlay = TRUE; + return; + } } +#ifdef SISMERGED } +#endif memset(&overlay, 0, sizeof(overlay)); @@ -2839,12 +3373,16 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) overlay.dstBox.x2 = pPriv->drw_x + pPriv->drw_w - pScrn->frameX0; overlay.dstBox.y1 = pPriv->drw_y - pScrn->frameY0; overlay.dstBox.y2 = pPriv->drw_y + pPriv->drw_h - pScrn->frameY0; + /* xf86DrvMsg(0, X_INFO, "DV(1): %d %d %d %d\n", + overlay.dstBox.x1,overlay.dstBox.x2,overlay.dstBox.y1,overlay.dstBox.y2); */ #ifdef SISMERGED } #endif - if((overlay.dstBox.x1 > overlay.dstBox.x2) || - (overlay.dstBox.y1 > overlay.dstBox.y2)) { + /* Note: x2/y2 is actually real coordinate + 1 */ + + if((overlay.dstBox.x1 >= overlay.dstBox.x2) || + (overlay.dstBox.y1 >= overlay.dstBox.y2)) { #ifdef SISMERGED if(pSiS->MergedFB) overlay.DoFirst = FALSE; else @@ -2852,7 +3390,7 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) return; } - if((overlay.dstBox.x2 < 0) || (overlay.dstBox.y2 < 0)) { + if((overlay.dstBox.x2 <= 0) || (overlay.dstBox.y2 <= 0)) { #ifdef SISMERGED if(pSiS->MergedFB) overlay.DoFirst = FALSE; else @@ -2868,6 +3406,17 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) return; } +#ifdef SISMERGED + if(pSiS->MergedFB) { + /* Check if dotclock is within limits for CRT1 */ + if(pPriv->displayMode & (DISPMODE_SINGLE1 | DISPMODE_MIRROR)) { + if(!(pSiS->MiscFlags & MISC_CRT1OVERLAY)) { + overlay.DoFirst = FALSE; + } + } + } +#endif + if(overlay.dstBox.x1 < 0) { srcOffsetX = pPriv->src_w * (-overlay.dstBox.x1) / pPriv->drw_w; overlay.dstBox.x1 = 0; @@ -2876,14 +3425,20 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) srcOffsetY = pPriv->src_h * (-overlay.dstBox.y1) / pPriv->drw_h; overlay.dstBox.y1 = 0; } + + if((overlay.dstBox.x1 >= overlay.dstBox.x2 - 2) || + (overlay.dstBox.x1 >= screenwidth - 2) || + (overlay.dstBox.y1 >= overlay.dstBox.y2)) { +#ifdef SISMERGED + if(pSiS->MergedFB) overlay.DoFirst = FALSE; + else +#endif + return; + } #ifdef SISMERGED if(pSiS->MergedFB) { - if((overlay.dstBox2.x1 > overlay.dstBox2.x2) || - (overlay.dstBox2.y1 > overlay.dstBox2.y2)) - overlay.DoSecond = FALSE; - - if((overlay.dstBox2.x2 < 0) || (overlay.dstBox2.y2 < 0)) + if((overlay.dstBox2.x2 <= 0) || (overlay.dstBox2.y2 <= 0)) overlay.DoSecond = FALSE; if((overlay.dstBox2.x1 >= screen2width) || (overlay.dstBox2.y1 >= overlay.SCREENheight2)) @@ -2893,10 +3448,16 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) srcOffsetX2 = pPriv->src_w * (-overlay.dstBox2.x1) / pPriv->drw_w; overlay.dstBox2.x1 = 0; } + if(overlay.dstBox2.y1 < 0) { srcOffsetY2 = pPriv->src_h * (-overlay.dstBox2.y1) / pPriv->drw_h; overlay.dstBox2.y1 = 0; } + + if((overlay.dstBox2.x1 >= overlay.dstBox2.x2 - 2) || + (overlay.dstBox2.x1 >= screen2width - 2) || + (overlay.dstBox2.y1 >= overlay.dstBox2.y2)) + overlay.DoSecond = FALSE; /* If neither overlay is to be displayed, disable them if they are currently enabled */ if((!overlay.DoFirst) && (!overlay.DoSecond)) { @@ -2906,19 +3467,19 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) if(temp & 0x02) { watchdog = WATCHDOG_DELAY; if(pPriv->hasTwoOverlays) { - while(vblank_active_CRT1(pSiS) && --watchdog); + while((!vblank_active_CRT1(pSiS, pPriv)) && --watchdog); watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT1(pSiS)) && --watchdog); + while(vblank_active_CRT1(pSiS, pPriv) && --watchdog); } else { temp = getsrreg(pSiS, 0x06); if(!(temp & 0x40)) { - while(vblank_active_CRT1(pSiS) && --watchdog); + while((!vblank_active_CRT1(pSiS, pPriv)) && --watchdog); watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT1(pSiS)) && --watchdog); + while(vblank_active_CRT1(pSiS, pPriv) && --watchdog); } else { - while(vblank_active_CRT2(pSiS) && --watchdog); + while((!vblank_active_CRT2(pSiS, pPriv)) && --watchdog); watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT2(pSiS)) && --watchdog); + while(vblank_active_CRT2(pSiS, pPriv) && --watchdog); } } setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); @@ -2929,9 +3490,9 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) temp = getvideoreg(pSiS,Index_VI_Control_Misc0); if(temp & 0x02) { watchdog = WATCHDOG_DELAY; - while(vblank_active_CRT2(pSiS) && --watchdog); + while((!vblank_active_CRT2(pSiS, pPriv)) && --watchdog); watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT2(pSiS)) && --watchdog); + while(vblank_active_CRT2(pSiS, pPriv) && --watchdog); setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); } } @@ -2941,13 +3502,11 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) } #endif - /* xf86DrvMsg(0, X_INFO, "DV(2): %d %d %d %d | %d %d %d %d\n", - overlay.dstBox.x1,overlay.dstBox.x2,overlay.dstBox.y1,overlay.dstBox.y2, - overlay.dstBox2.x1,overlay.dstBox2.x2,overlay.dstBox2.y1,overlay.dstBox2.y2); */ - switch(pPriv->id) { case PIXEL_FMT_YV12: + overlay.planar = 1; + overlay.planar_shiftpitch = 1; #ifdef SISMERGED if((!pSiS->MergedFB) || (overlay.DoFirst)) { #endif @@ -2980,6 +3539,8 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) break; case PIXEL_FMT_I420: + overlay.planar = 1; + overlay.planar_shiftpitch = 1; #ifdef SISMERGED if((!pSiS->MergedFB) || (overlay.DoFirst)) { #endif @@ -3013,6 +3574,8 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) case PIXEL_FMT_NV12: case PIXEL_FMT_NV21: + overlay.planar = 1; + overlay.planar_shiftpitch = 0; #ifdef SISMERGED if((!pSiS->MergedFB) || (overlay.DoFirst)) { #endif @@ -3047,6 +3610,7 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) case PIXEL_FMT_RGB6: case PIXEL_FMT_RGB5: default: + overlay.planar = 0; #ifdef SISMERGED if((!pSiS->MergedFB) || (overlay.DoFirst)) { #endif @@ -3108,9 +3672,9 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) temp = getvideoreg(pSiS,Index_VI_Control_Misc0); if(temp & 0x02) { watchdog = WATCHDOG_DELAY; - while(vblank_active_CRT1(pSiS) && --watchdog); + while((!vblank_active_CRT1(pSiS, pPriv)) && --watchdog); watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT1(pSiS)) && --watchdog); + while(vblank_active_CRT1(pSiS, pPriv) && --watchdog); setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); } } else if(!overlay.DoSecond) { @@ -3119,16 +3683,23 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) temp = getvideoreg(pSiS,Index_VI_Control_Misc0); if(temp & 0x02) { watchdog = WATCHDOG_DELAY; - while(vblank_active_CRT2(pSiS) && --watchdog); + while((!vblank_active_CRT2(pSiS, pPriv)) && --watchdog); watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT2(pSiS)) && --watchdog); + while(vblank_active_CRT2(pSiS, pPriv) && --watchdog); setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); } } } #endif + /* xf86DrvMsg(0, X_INFO, "DV(2): %d %d %d %d (%d %d) | %d %d %d %d (%d %d)\n", + overlay.dstBox.x1,overlay.dstBox.x2,overlay.dstBox.y1,overlay.dstBox.y2,srcOffsetX,srcOffsetY, + overlay.dstBox2.x1,overlay.dstBox2.x2,overlay.dstBox2.y1,overlay.dstBox2.y2,srcOffsetX2,srcOffsetY2); */ + /* Loop head */ + /* Note: index can only be 1 for CRT2, ie overlay 1 + * is only used for CRT2. + */ if(pPriv->displayMode & DISPMODE_SINGLE2) { if(pPriv->hasTwoOverlays) { /* We have 2 overlays: */ if(pPriv->dualHeadMode) { @@ -3193,27 +3764,61 @@ SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) #ifdef SISMERGED if((!pSiS->MergedFB) || (overlay.DoFirst)) #endif - set_line_buf_size_1(&overlay); + calc_line_buf_size_1(&overlay, pPriv); #ifdef SISMERGED if((pSiS->MergedFB) && (overlay.DoSecond)) - set_line_buf_size_2(&overlay); + calc_line_buf_size_2(&overlay, pPriv); +#endif + + if(pPriv->dualHeadMode) { +#ifdef SISDUALHEAD + if(!pSiS->SecondHead) { + if(pPriv->updatetvxpos) { + SiS_SetTVxposoffset(pScrn, pPriv->tvxpos); + pPriv->updatetvxpos = FALSE; + } + if(pPriv->updatetvypos) { + SiS_SetTVyposoffset(pScrn, pPriv->tvypos); + pPriv->updatetvypos = FALSE; + } + } #endif + } else { + if(pPriv->updatetvxpos) { + SiS_SetTVxposoffset(pScrn, pPriv->tvxpos); + pPriv->updatetvxpos = FALSE; + } + if(pPriv->updatetvypos) { + SiS_SetTVyposoffset(pScrn, pPriv->tvypos); + pPriv->updatetvypos = FALSE; + } + } + +#if 0 /* Clearing this does not seem to be required */ + /* and might even be dangerous. */ + if(pSiS->VGAEngine == SIS_315_VGA) { + watchdog = WATCHDOG_DELAY; + while(overlay.VBlankActiveFunc(pSiS, pPriv) && --watchdog); + setvideoregmask(pSiS, Index_VI_Control_Misc3, 0x00, 0x03); + } +#endif + setvideoregmask(pSiS, Index_VI_Control_Misc3, 0x03, 0x03); /* Do the following in a loop for CRT1 and CRT2 ----------------- */ MIRROR: - /* calculate (not set!) scale factor */ + /* calculate scale factor */ #ifdef SISMERGED if(pSiS->MergedFB && iscrt2) calc_scale_factor_2(&overlay, pScrn, pPriv, index, iscrt2); else #endif calc_scale_factor(&overlay, pScrn, pPriv, index, iscrt2); - - /* Select video1 (used for CRT1/or CRT2) or video2 (used for CRT2) */ + + /* Select overlay 0 (used for CRT1/or CRT2) or overlay 1 (used for CRT2 only) */ setvideoregmask(pSiS, Index_VI_Control_Misc2, index, 0x01); - - /* set format */ + + /* set format (before color and chroma keys) */ set_format(pSiS, &overlay); /* set color key */ @@ -3236,35 +3841,10 @@ MIRROR: set_saturation(pSiS, pPriv->saturation); } - if(pPriv->dualHeadMode) { -#ifdef SISDUALHEAD - if(!pSiS->SecondHead) { - if(pPriv->updatetvxpos) { - SiS_SetTVxposoffset(pScrn, pPriv->tvxpos); - pPriv->updatetvxpos = FALSE; - } - if(pPriv->updatetvypos) { - SiS_SetTVyposoffset(pScrn, pPriv->tvypos); - pPriv->updatetvypos = FALSE; - } - } -#endif - } else { - if(pPriv->updatetvxpos) { - SiS_SetTVxposoffset(pScrn, pPriv->tvxpos); - pPriv->updatetvxpos = FALSE; - } - if(pPriv->updatetvypos) { - SiS_SetTVyposoffset(pScrn, pPriv->tvypos); - pPriv->updatetvypos = FALSE; - } - } - /* enable/disable graphics display around overlay * (Since disabled overlays don't get treated in this * loop, we omit respective checks here) */ - if(!iscrt2) set_disablegfx(pSiS, pPriv->disablegfx, &overlay); else if(!pPriv->hasTwoOverlays) { set_disablegfx(pSiS, FALSE, &overlay); @@ -3275,14 +3855,9 @@ MIRROR: SIS_CP_VIDEO_SET_CP #endif - /* set overlay parameters */ + /* set remaining overlay parameters */ set_overlay(pSiS, &overlay, pPriv, index, iscrt2); - - if(pSiS->VGAEngine == SIS_315_VGA) { - /* Trigger register copy for 315 series */ - setvideoregmask(pSiS, Index_VI_Control_Misc3, (1 << index), (1 << index)); - } - + /* enable overlay */ setvideoregmask (pSiS, Index_VI_Control_Misc0, 0x02, 0x02); @@ -3297,10 +3872,78 @@ MIRROR: overlay.VBlankActiveFunc = vblank_active_CRT2; goto MIRROR; #ifdef SISMERGED - } + } #endif } + /* Now for the trigger: This is a bad hack to work-around + * an obvious hardware bug: Overlay 1 (which is ONLY used + * for CRT2 in this driver) does not always update its + * window position and some other stuff. Earlier, this was + * solved be disabling the overlay, but this took forever + * and was ugly on the screen. + * Now: We write 0x03 to 0x74 from the beginning. This is + * meant as a "lock" - the driver is supposed to write 0 + * to this register, bit 0 for overlay 0, bit 1 for over- + * lay 1, then change buffer addresses, pitches, window + * position, scaler registers, format, etc., then write + * 1 to 0x74. The hardware then reads the registers into + * its internal engine and clears these bits. + * All this works for overlay 0, but not 1. Overlay 1 + * has assumingly the following restrictions: + * - New data written to the registers are only read + * correctly by the engine, if the registers are written + * when the current scanline is beyond the current + * overlay position and below the maximum visible + * scanline (vertical screen resolution) + * - If a vertical retrace occures during writing the + * registers, the registers written BEFORE this re- + * trace happened, are not being read into the + * engine if the trigger is set after the retrace. + * Therefore: We write the overlay registers above in + * set_overlay only if the scanline matches, and save + * the then current scanline. If this scanline is higher + * than the now current scanline, we assume a retrace, + * wait for the scanline to match the criteria above again, + * and rewrite all relevant registers. + * I have no idea if this is meant that way, but after + * fiddling three entire days with this crap, I found this + * to be the only solution. + */ + if(pSiS->VGAEngine == SIS_315_VGA) { + if((pPriv->mustwait) && index) { + watchdog = get_scanline_CRT2(pSiS, pPriv); + if(watchdog <= overlay.oldLine) { + int i, mytop = overlay.oldtop; + int screenHeight = overlay.SCREENheight; +#ifdef SISMERGED + if(pSiS->MergedFB) { + screenHeight = overlay.SCREENheight2; + } +#endif + if(mytop < screenHeight - 2) { + do { + watchdog = get_scanline_CRT2(pSiS, pPriv); + } while((watchdog <= mytop) || (watchdog >= screenHeight)); + } + for(i=0x02; i<=0x12; i++) { + setvideoreg(pSiS, i, getvideoreg(pSiS, i)); + } + for(i=0x18; i<=0x1c; i++) { + setvideoreg(pSiS, i, getvideoreg(pSiS, i)); + } + for(i=0x2c; i<=0x2e; i++) { + setvideoreg(pSiS, i, getvideoreg(pSiS, i)); + } + for(i=0x6b; i<=0x6f; i++) { + setvideoreg(pSiS, i, getvideoreg(pSiS, i)); + } + } + } + /* Trigger register copy for 315/330 series */ + setvideoregmask(pSiS, Index_VI_Control_Misc3, 0x03, 0x03); + } + pPriv->mustwait = 0; pPriv->overlayStatus = TRUE; } @@ -3315,13 +3958,11 @@ SISAllocateOverlayMemory( FBLinearPtr new_linear; if(linear) { - if(linear->size >= size) - return linear; + if(linear->size >= size) return linear; - if(xf86ResizeOffscreenLinear(linear, size)) - return linear; + if(xf86ResizeOffscreenLinear(linear, size)) return linear; - xf86FreeOffscreenLinear(linear); + xf86FreeOffscreenLinear(linear); } pScreen = screenInfo.screens[pScrn->scrnIndex]; @@ -3330,25 +3971,25 @@ SISAllocateOverlayMemory( NULL, NULL, NULL); if(!new_linear) { - int max_size; + int max_size; - xf86QueryLargestOffscreenLinear(pScreen, &max_size, 8, + xf86QueryLargestOffscreenLinear(pScreen, &max_size, 8, PRIORITY_EXTREME); - if(max_size < size) return NULL; + if(max_size < size) return NULL; - xf86PurgeUnlockedOffscreenAreas(pScreen); - new_linear = xf86AllocateOffscreenLinear(pScreen, size, 8, + xf86PurgeUnlockedOffscreenAreas(pScreen); + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 8, NULL, NULL, NULL); } if(!new_linear) - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Xv: Failed to allocate %dK of video memory\n", size/1024); -#ifdef TWDEBUG +#ifdef TWDEBUG else - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Xv: Allocated %dK of video memory\n", size/1024); -#endif +#endif return new_linear; } @@ -3359,8 +4000,8 @@ SISFreeOverlayMemory(ScrnInfoPtr pScrn) SISPortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); if(pPriv->linear) { - xf86FreeOffscreenLinear(pPriv->linear); - pPriv->linear = NULL; + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; } } @@ -3370,24 +4011,23 @@ SISStopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown) SISPortPrivPtr pPriv = (SISPortPrivPtr)data; SISPtr pSiS = SISPTR(pScrn); - if(pPriv->grabbedByV4L) - return; + if(pPriv->grabbedByV4L) return; REGION_EMPTY(pScrn->pScreen, &pPriv->clip); if(shutdown) { if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - close_overlay(pSiS, pPriv); - pPriv->mustwait = 1; + close_overlay(pSiS, pPriv); + pPriv->mustwait = 1; } SISFreeOverlayMemory(pScrn); pPriv->videoStatus = 0; - pSiS->VideoTimerCallback = NULL; } else { if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - pPriv->videoStatus = OFF_TIMER | CLIENT_VIDEO_ON; - pPriv->offTime = currentTime.milliseconds + OFF_DELAY; - pSiS->VideoTimerCallback = SISVideoTimerCallback; + UpdateCurrentTime(); + pPriv->offTime = currentTime.milliseconds + OFF_DELAY; + pPriv->videoStatus = OFF_TIMER | CLIENT_VIDEO_ON; + pSiS->VideoTimerCallback = SISVideoTimerCallback; } } } @@ -3406,6 +4046,7 @@ SISPutImage( ){ SISPtr pSiS = SISPTR(pScrn); SISPortPrivPtr pPriv = (SISPortPrivPtr)data; + XAAInfoRecPtr pXAA = pSiS->AccelInfoPtr; int totalSize=0; int depth = pSiS->CurrentLayout.bitsPerPixel >> 3; @@ -3417,8 +4058,7 @@ SISPutImage( } #endif - if(pPriv->grabbedByV4L) - return Success; + if(pPriv->grabbedByV4L) return Success; pPriv->drw_x = drw_x; pPriv->drw_y = drw_y; @@ -3455,6 +4095,14 @@ SISPutImage( Y0 U0 Y1 V0 Y2 U2 Y3 V2 ... 5. YVYU: Like YUY2, but order is Y0 V0 Y1 U0 Y2 V2 Y3 U2 ... + 6. NV12, NV21: 2 planes H V + Y sample period 1 1 (8 bit per pixel) + V sample period 2 1 (8 bit per pixel, subsampled) + U sample period 2 1 (8 bit per pixel, subsampled) + Y plane is fully samples (width*height), U and V planes are + interleaved in memory (one byte U, one byte V for NV12, NV21 + other way round) and sampled in 2x1 blocks. Otherwise such + as all other planar formats. */ switch(id){ @@ -3510,30 +4158,28 @@ SISPutImage( /* update cliplist */ if(pPriv->autopaintColorKey && (pPriv->grabbedByV4L || -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,3,0) (!RegionsEqual(&pPriv->clip, clipBoxes)) || #else (!REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) || #endif (pPriv->PrevOverlay != pPriv->NoOverlay))) { /* We always paint the colorkey for V4L */ - if(!pPriv->grabbedByV4L) -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) + if(!pPriv->grabbedByV4L) { REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); -#else - REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); -#endif + } /* draw these */ pPriv->PrevOverlay = pPriv->NoOverlay; - if((pPriv->NoOverlay) && (!pSiS->NoAccel)) { - XAAFillMono8x8PatternRects(pScrn, myreds[depth-1], 0x000000, GXcopy, ~0, + if((pPriv->NoOverlay) && pXAA && pXAA->FillMono8x8PatternRects) { + (*pXAA->FillMono8x8PatternRects)(pScrn, myreds[depth-1], + 0x000000, GXcopy, ~0, REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes), 0x00422418, 0x18244200, 0, 0); } else { if(!pSiS->disablecolorkeycurrent) { -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) - XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,1,99,1,0) + (*pXAA->FillSolidRects)(pScrn, pPriv->colorKey, GXcopy, ~0, REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); #else @@ -3624,48 +4270,9 @@ SISQueryImageAttributes( return size; } -static void -SISVideoTimerCallback(ScrnInfoPtr pScrn, Time now) -{ - SISPtr pSiS = SISPTR(pScrn); - SISPortPrivPtr pPriv = NULL; - unsigned char sridx, cridx; - - pSiS->VideoTimerCallback = NULL; - - if(!pScrn->vtSema) return; - - if(pSiS->adaptor) { - pPriv = GET_PORT_PRIVATE(pScrn); - if(!pPriv->videoStatus) - pPriv = NULL; - } - - if(pPriv) { - if(pPriv->videoStatus & TIMER_MASK) { - UpdateCurrentTime(); - if(pPriv->offTime < currentTime.milliseconds) { - if(pPriv->videoStatus & OFF_TIMER) { - /* Turn off the overlay */ - sridx = inSISREG(SISSR); cridx = inSISREG(SISCR); - close_overlay(pSiS, pPriv); - outSISREG(SISSR, sridx); outSISREG(SISCR, cridx); - pPriv->mustwait = 1; - pPriv->videoStatus = FREE_TIMER; - pPriv->freeTime = currentTime.milliseconds + FREE_DELAY; - pSiS->VideoTimerCallback = SISVideoTimerCallback; - } else if(pPriv->videoStatus & FREE_TIMER) { - SISFreeOverlayMemory(pScrn); - pPriv->mustwait = 1; - pPriv->videoStatus = 0; - } - } else - pSiS->VideoTimerCallback = SISVideoTimerCallback; - } - } -} - -/* Offscreen surface stuff */ +/*****************************************************************/ +/* OFFSCREEN SURFACES */ +/*****************************************************************/ static int SISAllocSurface ( @@ -3725,9 +4332,9 @@ SISStopSurface (XF86SurfacePtr surface) SISPtr pSiS = SISPTR(surface->pScrn); if(pPriv->grabbedByV4L && pPriv->videoStatus) { - close_overlay(pSiS, pPriv); - pPriv->mustwait = 1; - pPriv->videoStatus = 0; + close_overlay(pSiS, pPriv); + pPriv->mustwait = 1; + pPriv->videoStatus = 0; } return Success; } @@ -3738,9 +4345,9 @@ SISFreeSurface (XF86SurfacePtr surface) SISPortPrivPtr pPriv = (SISPortPrivPtr)(surface->devPrivate.ptr); if(pPriv->grabbedByV4L) { - SISStopSurface(surface); - SISFreeOverlayMemory(surface->pScrn); - pPriv->grabbedByV4L = FALSE; + SISStopSurface(surface); + SISFreeOverlayMemory(surface->pScrn); + pPriv->grabbedByV4L = FALSE; } return Success; } @@ -3788,8 +4395,7 @@ SISDisplaySurface ( xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Xv: DisplaySurface called\n"); #endif - if(!pPriv->grabbedByV4L) - return Success; + if(!pPriv->grabbedByV4L) return Success; pPriv->drw_x = drw_x; pPriv->drw_y = drw_y; @@ -3808,8 +4414,10 @@ SISDisplaySurface ( SISDisplayVideo(pScrn, pPriv); if(pPriv->autopaintColorKey) { - if((pPriv->NoOverlay) && (!(pSiS->NoAccel))) { - XAAFillMono8x8PatternRects(pScrn, + XAAInfoRecPtr pXAA = pSiS->AccelInfoPtr; + + if((pPriv->NoOverlay) && pXAA && pXAA->FillMono8x8PatternRects) { + (*pXAA->FillMono8x8PatternRects)(pScrn, myreds[(pSiS->CurrentLayout.bitsPerPixel >> 3) - 1], 0x000000, GXcopy, ~0, REGION_NUM_RECTS(clipBoxes), @@ -3817,8 +4425,8 @@ SISDisplaySurface ( 0x00422418, 0x18244200, 0, 0); } else { -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) - XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,1,99,1,0) + (*pXAA->FillSolidRects)(pScrn, pPriv->colorKey, GXcopy, ~0, REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); #else @@ -3934,209 +4542,635 @@ SISInitOffscreenImages(ScreenPtr pScreen) xf86XVRegisterOffscreenImages(pScreen, SISOffscreenImages, num); } -#ifdef NOT_YET_IMPLEMENTED /* ----------- TW: FOR FUTURE USE -------------------- */ +/*****************************************************************/ +/* BLIT ADAPTORS */ +/*****************************************************************/ +#ifdef INCL_YUV_BLIT_ADAPTOR -/* Set alpha - does not work */ static void -set_alpha(SISPtr pSiS, CARD8 alpha) +SISSetPortDefaultsBlit(ScrnInfoPtr pScrn, SISBPortPrivPtr pPriv) { - setvideoregmask(pSiS, Index_VI_Key_Overlay_OP, ((alpha & 0x0f) << 4), 0xf0); + /* Default: Don't sync. */ + pPriv->vsync = 0; } -/* Set SubPicture Start Address (yet unused) */ static void -set_subpict_start_offset(SISPtr pSiS, SISOverlayPtr pOverlay, int index) +SISResetVideoBlit(ScrnInfoPtr pScrn) { - CARD32 temp; - CARD8 data; - - temp = pOverlay->SubPictAddr >> 4; /* 630 <-> 315 shiftValue? */ - - setvideoreg(pSiS,Index_VI_SubPict_Buf_Start_Low, temp & 0xFF); - setvideoreg(pSiS,Index_VI_SubPict_Buf_Start_Middle, (temp>>8) & 0xFF); - setvideoreg(pSiS,Index_VI_SubPict_Buf_Start_High, (temp>>16) & 0x3F); - if(pSiS->VGAEngine == SIS_315_VGA) { - setvideoreg(pSiS,Index_VI_SubPict_Start_Over, (temp>>22) & 0x01); - /* Submit SubPict offset ? */ - /* data=getvideoreg(pSiS,Index_VI_Control_Misc3); */ - setvideoreg(pSiS,Index_VI_Control_Misc3, (1 << index) | 0x04); - } } -/* Set SubPicture Pitch (yet unused) */ -static void -set_subpict_pitch(SISPtr pSiS, SISOverlayPtr pOverlay, int index) +static XF86VideoAdaptorPtr +SISSetupBlitVideo(ScreenPtr pScreen) { - CARD32 temp; - CARD8 data; - - temp = pOverlay->SubPictPitch >> 4; /* 630 <-> 315 shiftValue? */ - - setvideoreg(pSiS,Index_VI_SubPict_Buf_Pitch, temp & 0xFF); - if(pSiS->VGAEngine == SIS_315_VGA) { - setvideoreg(pSiS,Index_VI_SubPict_Buf_Pitch_High, (temp>>8) & 0xFF); - /* Submit SubPict pitch ? */ - /* data=getvideoreg(pSiS,Index_VI_Control_Misc3); */ - setvideoreg(pSiS,Index_VI_Control_Misc3, (1 << index) | 0x04); - } -} + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SISPtr pSiS = SISPTR(pScrn); + XF86VideoAdaptorPtr adapt; + SISBPortPrivPtr pPriv; + int i; -/* Calculate and set SubPicture scaling (untested, unused yet) */ -static void -set_subpict_scale_factor(SISOverlayPtr pOverlay, ScrnInfoPtr pScrn, - SISPortPrivPtr pPriv, int index, int iscrt2) -{ - SISPtr pSiS = SISPTR(pScrn); - CARD32 I=0,mult=0; - int flag=0; + if(!pSiS->AccelInfoPtr) return NULL; - int dstW = pOverlay->SubPictdstBox.x2 - pOverlay->SubPictdstBox.x1; - int dstH = pOverlay->SubPictdstBox.y2 - pOverlay->SubPictdstBox.y1; - int srcW = pOverlay->SubPictsrcW; - int srcH = pOverlay->SubPictsrcH; - CARD16 LCDheight = pSiS->LCDheight; - int srcPitch = pOverlay->SubPictOrigPitch; - int origdstH = dstH; + if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + + (sizeof(DevUnion) * NUM_BLIT_PORTS) + + sizeof(SISBPortPrivRec)))) { + return NULL; + } - /* Stretch image due to idiotic LCD "auto"-scaling */ - /* INCOMPLETE and INCORRECT - See set_scale_factor() */ - if( (pPriv->bridgeIsSlave) && (pSiS->VBFlags & CRT2_LCD) ) { - dstH = (dstH * LCDheight) / pOverlay->SCREENheight; - } else if((index) && (pSiS->VBFlags & CRT2_LCD)) { - dstH = (dstH * LCDheight) / pOverlay->SCREENheight; - if(pPriv->displayMode == DISPMODE_MIRROR) flag = 1; - } + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = 0; + adapt->name = "SIS 315/330 series Video Blitter"; + adapt->nEncodings = 1; + adapt->pEncodings = &DummyEncodingBlit; + adapt->nFormats = 4; + adapt->pFormats = SISFormats; + adapt->nImages = NUM_IMAGES_BLIT; + adapt->pImages = SISImagesBlit; + adapt->pAttributes = SISAttributes_Blit; + adapt->nAttributes = NUM_ATTRIBUTES_BLIT; + adapt->nPorts = NUM_BLIT_PORTS; + adapt->pPortPrivates = (DevUnion*)(&adapt[1]); + + pSiS->blitPriv = (void *)(&adapt->pPortPrivates[NUM_BLIT_PORTS]); + pPriv = (SISBPortPrivPtr)(pSiS->blitPriv); + + for(i = 0; i < NUM_BLIT_PORTS; i++) { + adapt->pPortPrivates[i].uval = (unsigned long)(i); +#if defined(REGION_NULL) + REGION_NULL(pScreen, &pPriv->blitClip[i]); +#else + REGION_INIT(pScreen, &pPriv->blitClip[i], NullBox, 0); +#endif + pPriv->videoStatus[i] = 0; + pPriv->currentBuf[i] = 0; + pPriv->linear[i] = NULL; + } + + if(pSiS->sishw_ext.jChipType >= SIS_330) { + pPriv->AccelCmd = YUVRGB_BLIT_330; + pPriv->VBlankTriggerCRT1 = 0; + pPriv->VBlankTriggerCRT2 = 0; + } else { + pPriv->AccelCmd = YUVRGB_BLIT_325; + pPriv->VBlankTriggerCRT1 = SCANLINE_TRIGGER_ENABLE | SCANLINE_TR_CRT1; + pPriv->VBlankTriggerCRT2 = SCANLINE_TRIGGER_ENABLE | SCANLINE_TR_CRT2; + } + + adapt->PutVideo = NULL; + adapt->PutStill = NULL; + adapt->GetVideo = NULL; + adapt->GetStill = NULL; + adapt->StopVideo = (StopVideoFuncPtr)SISStopVideoBlit; + adapt->SetPortAttribute = (SetPortAttributeFuncPtr)SISSetPortAttributeBlit; + adapt->GetPortAttribute = (GetPortAttributeFuncPtr)SISGetPortAttributeBlit; + adapt->QueryBestSize = (QueryBestSizeFuncPtr)SISQueryBestSizeBlit; + adapt->PutImage = (PutImageFuncPtr)SISPutImageBlit; + adapt->QueryImageAttributes = SISQueryImageAttributesBlit; + + pSiS->blitadaptor = adapt; - if(dstW == srcW) { - pOverlay->SubPictHUSF = 0x00; - pOverlay->SubPictIntBit = 0x01; - } else if(dstW > srcW) { - pOverlay->SubPictHUSF = (srcW << 16) / dstW; - pOverlay->SubPictIntBit = 0x00; - } else { - int tmpW = dstW; + pSiS->xvVSync = MAKE_ATOM(sisxvvsync); + pSiS->xvSetDefaults = MAKE_ATOM(sisxvsetdefaults); + + SISResetVideoBlit(pScrn); + + /* Reset the properties to their defaults */ + SISSetPortDefaultsBlit(pScrn, pPriv); - I = 0x00; - while (srcW >= tmpW) { - tmpW <<= 1; - I++; - } - pOverlay->SubPictwHPre = (CARD8)(I - 1); - dstW <<= (I - 1); - if((srcW % dstW)) - pOverlay->SubPictHUSF = ((srcW - dstW) << 16) / dstW; - else - pOverlay->SubPictHUSF = 0x00; + return adapt; +} - pOverlay->SubPictIntBit = 0x01; - } +static void +SISFreeBlitMemory(ScrnInfoPtr pScrn, int index) +{ + SISPtr pSiS = SISPTR(pScrn); + SISBPortPrivPtr pPriv = (SISBPortPrivPtr)(pSiS->blitPriv); - if(dstH == srcH) { - pOverlay->SubPictVUSF = 0x00; - pOverlay->SubPictIntBit |= 0x02; - } else if(dstH > srcH) { - dstH += 0x02; - pOverlay->SubPictVUSF = (srcH << 16) / dstH; - /* pOverlay->SubPictIntBit |= 0x00; */ - } else { - CARD32 realI; + if(pPriv->linear[index]) { + xf86FreeOffscreenLinear(pPriv->linear[index]); + pPriv->linear[index] = NULL; + } +} - I = realI = srcH / dstH; - pOverlay->SubPictIntBit |= 0x02; +static int +SISGetPortAttributeBlit(ScrnInfoPtr pScrn, Atom attribute, + INT32 *value, unsigned long index) +{ + SISPtr pSiS = SISPTR(pScrn); + SISBPortPrivPtr pPriv = (SISBPortPrivPtr)(pSiS->blitPriv); - if(I < 2) { - pOverlay->SubPictVUSF = ((srcH - dstH) << 16) / dstH; - /* TW: Needed for LCD-scaling modes */ - if((flag) && (mult = (srcH / origdstH)) >= 2) - pOverlay->SubPictPitch /= mult; - } else { - if(((srcPitch * I)>>2) > 0xFFF) { - I = (0xFFF*2/srcPitch); - pOverlay->SubPictVUSF = 0xFFFF; - } else { - dstH = I * dstH; - if(srcH % dstH) - pOverlay->SubPictVUSF = ((srcH - dstH) << 16) / dstH; - else - pOverlay->SubPictVUSF = 0x00; - } - /* set video frame buffer offset */ - pOverlay->SubPictPitch = (CARD16)(srcPitch*I); - } - } - /* set SubPicture scale factor */ - setvideoreg (pSiS, Index_VI_SubPict_Hor_Scale_Low, (CARD8)(pOverlay->SubPictHUSF)); - setvideoreg (pSiS, Index_VI_SubPict_Hor_Scale_High, (CARD8)((pOverlay->SubPictHUSF)>>8)); - setvideoreg (pSiS, Index_VI_SubPict_Vert_Scale_Low, (CARD8)(pOverlay->SubPictVUSF)); - setvideoreg (pSiS, Index_VI_SubPict_Vert_Scale_High,(CARD8)((pOverlay->SubPictVUSF)>>8)); - - setvideoregmask (pSiS, Index_VI_SubPict_Scale_Control, - (pOverlay->SubPictIntBit << 3) | - (pOverlay->SubPictwHPre), 0x7f); + if(attribute == pSiS->xvVSync) { + *value = pPriv->vsync; + } else return BadMatch; + return Success; } -/* Set SubPicture Preset (yet unused) */ -static void -set_subpict_preset(SISPtr pSiS, SISOverlayPtr pOverlay) +static int +SISSetPortAttributeBlit(ScrnInfoPtr pScrn, Atom attribute, + INT32 value, unsigned long index) { - CARD32 temp; - CARD8 data; - - temp = pOverlay->SubPictPreset >> 4; /* TW: 630 <-> 315 ? */ - - setvideoreg(pSiS,Index_VI_SubPict_Buf_Preset_Low, temp & 0xFF); - setvideoreg(pSiS,Index_VI_SubPict_Buf_Preset_Middle, (temp>>8) & 0xFF); - data = getvideoreg(pSiS,Index_VI_SubPict_Buf_Start_High); - if(temp > 0xFFFF) - data |= 0x40; - else - data &= ~0x40; - setvideoreg(pSiS,Index_VI_SubPict_Buf_Start_High, data); + SISPtr pSiS = SISPTR(pScrn); + SISBPortPrivPtr pPriv = (SISBPortPrivPtr)(pSiS->blitPriv); + + if(attribute == pSiS->xvVSync) { + if((value < 0) || (value > 1)) return BadValue; + pPriv->vsync = value; + } else if(attribute == pSiS->xvSetDefaults) { + SISSetPortDefaultsBlit(pScrn, pPriv); + } else return BadMatch; + return Success; } static void -enable_subpict_overlay(SISPtr pSiS, Bool enable) +SISStopVideoBlit(ScrnInfoPtr pScrn, unsigned long index, Bool shutdown) { - setvideoregmask(pSiS, Index_VI_SubPict_Scale_Control, - enable ? 0x40 : 0x00, - 0x40); + SISPtr pSiS = SISPTR(pScrn); + SISBPortPrivPtr pPriv = (SISBPortPrivPtr)(pSiS->blitPriv); + + /* This shouldn't be called for blitter adaptors due to + * adapt->flags but we provide it anyway. + */ + + if(index > NUM_BLIT_PORTS) return; + + REGION_EMPTY(pScrn->pScreen, &pPriv->blitClip[index]); + + if(shutdown) { + XAAInfoRecPtr pXAA = pSiS->AccelInfoPtr; + pPriv->videoStatus[index] = 0; + if(pXAA && pXAA->Sync) (pXAA->Sync)(pScrn); + SISFreeBlitMemory(pScrn, (int)index); + } } -/* Set overlay for subpicture */ static void -set_subpict_overlay(SISPtr pSiS, SISOverlayPtr pOverlay, SISPortPrivPtr pPriv, int index) +SISWriteBlitPacket(SISPtr pSiS, CARD32 *packet) { - ScrnInfoPtr pScrn = pSiS->pScrn; + CARD32 dummybuf; + + SiSWritePacketPart(packet[0], packet[1], packet[2], packet[3]); + SiSWritePacketPart(packet[4], packet[5], packet[6], packet[7]); + SiSWritePacketPart(packet[8], packet[9], packet[10], packet[11]); + SiSWritePacketPart(packet[12], packet[13], packet[14], packet[15]); + SiSWritePacketPart(packet[16], packet[17], packet[18], packet[19]); + SiSSyncWP; +} - set_subpict_pitch(pSiS, &overlay, index); - set_subpict_start_offset(pSiS, &overlay, index); - set_subpict_scale_factor(&overlay, pScrn, pPriv, index); - /* set_subpict_preset(pSiS, &overlay); */ - /* enable_subpict_overlay(pSiS, 1); */ +static int +SISPutImageBlit( + ScrnInfoPtr pScrn, + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, + int id, unsigned char* buf, + short width, short height, + Bool sync, + RegionPtr clipBoxes, unsigned long index +){ + SISPtr pSiS = SISPTR(pScrn); + SISBPortPrivPtr pPriv = (SISBPortPrivPtr)(pSiS->blitPriv); +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,1,99,1,0) + XAAInfoRecPtr pXAA = pSiS->AccelInfoPtr; +#endif + BoxPtr pbox = REGION_RECTS(clipBoxes); + int nbox = REGION_NUM_RECTS(clipBoxes); + int depth = pSiS->CurrentLayout.bitsPerPixel >> 3; + CARD32 dstbase = 0, offsety, offsetuv, temp; + int totalSize, bytesize=0, h, w, wb, srcPitch; + int xoffset = 0, yoffset = 0, left, right, top, bottom; + unsigned char *ybases, *ubases = NULL, *vbases = NULL, *myubases, *myvbases; + unsigned char *ybased, *uvbased, packed; + CARD16 *myuvbased; + SiS_Packet12_YUV MyPacket; + Bool first; + + if(index > NUM_BLIT_PORTS) return BadMatch; + + if(!height || !width) return Success; + + switch(id) { + case PIXEL_FMT_YV12: + case PIXEL_FMT_I420: + case PIXEL_FMT_NV12: + case PIXEL_FMT_NV21: + srcPitch = (width + 7) & ~7; /* Should come this way anyway */ + bytesize = srcPitch * height; + totalSize = (bytesize * 3) >> 1; + break; + case PIXEL_FMT_YUY2: + case PIXEL_FMT_UYVY: + case PIXEL_FMT_YVYU: + srcPitch = ((width << 1) + 3) & ~3; + /* Size = width * 2 * height */ + totalSize = srcPitch * height; + bytesize = 0; + break; + default: + return BadMatch; + } + + /* allocate memory (we do doublebuffering) */ + if(!(pPriv->linear[index] = SISAllocateOverlayMemory(pScrn, pPriv->linear[index], totalSize<<1))) + return BadAlloc; + + /* fixup pointers */ + pPriv->bufAddr[index][0] = (pPriv->linear[index]->offset * depth); + pPriv->bufAddr[index][1] = pPriv->bufAddr[index][0] + totalSize; + + if(drw_w > width) { + xoffset = (drw_w - width) >> 1; + } + if(drw_h > (height & ~1)) { + yoffset = (drw_h - height) >> 1; + } + + if(xoffset || yoffset) { +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,3,0) + if(!RegionsEqual(&pPriv->blitClip[index], clipBoxes)) { +#else + if(!REGION_EQUAL(pScrn->pScreen, &pPriv->blitClip[index], clipBoxes)) { +#endif +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,1,99,1,0) + (*pXAA->FillSolidRects)(pScrn, 0x00000000, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); +#else + xf86XVFillKeyHelper(pScrn->pScreen, 0x00000000, clipBoxes); +#endif + REGION_COPY(pScrn->pScreen, &pPriv->blitClip[index], clipBoxes); + } + } + + memset(&MyPacket, 0, sizeof(MyPacket)); + + ybased = pSiS->FbBase + pPriv->bufAddr[index][pPriv->currentBuf[index]]; + uvbased = pSiS->FbBase + pPriv->bufAddr[index][pPriv->currentBuf[index]] + bytesize; + + ybases = buf; + packed = 0; + + switch(id) { + case PIXEL_FMT_YV12: + vbases = buf + bytesize; + ubases = buf + bytesize*5/4; + break; + case PIXEL_FMT_I420: + ubases = buf + bytesize; + vbases = buf + bytesize*5/4; + break; + case PIXEL_FMT_NV12: + MyPacket.P12_Command = YUV_FORMAT_NV12; + break; + case PIXEL_FMT_NV21: + MyPacket.P12_Command = YUV_FORMAT_NV21; + break; + case PIXEL_FMT_YUY2: + MyPacket.P12_Command = YUV_FORMAT_YUY2; + packed = 1; + break; + case PIXEL_FMT_UYVY: + MyPacket.P12_Command = YUV_FORMAT_UYVY; + packed = 1; + break; + case PIXEL_FMT_YVYU: + MyPacket.P12_Command = YUV_FORMAT_YVYU; + packed = 1; + break; + default: + return BadMatch; + } + + switch(id) { + case PIXEL_FMT_YV12: + case PIXEL_FMT_I420: + MyPacket.P12_Command = YUV_FORMAT_NV12; + /* Copy y plane */ + memcpy(ybased, ybases, bytesize); + /* Copy u/v planes */ + wb = srcPitch >> 1; + h = height >> 1; + while(h--) { + myuvbased = (CARD16*)uvbased; + myubases = ubases; + myvbases = vbases; + w = wb; + while(w--) { +#if X_BYTE_ORDER == X_BIG_ENDIAN + temp = (*myubases++) << 8; + temp |= (*myvbases++); +#else + temp = (*myvbases++) << 8; + temp |= (*myubases++); +#endif + *myuvbased++ = temp; + } + uvbased += srcPitch; + ubases += wb; + vbases += wb; + } + break; + default: + memcpy(ybased, ybases, totalSize); + } + +#ifdef SISDUALHEAD + dstbase += HEADOFFSET; +#endif + + MyPacket.P12_Header0 = SIS_PACKET12_HEADER0; + MyPacket.P12_Header1 = SIS_PACKET12_HEADER1; + MyPacket.P12_Null1 = SIS_NIL_CMD; + MyPacket.P12_Null2 = SIS_NIL_CMD; + MyPacket.P12_YPitch = MyPacket.P12_UVPitch = srcPitch; + MyPacket.P12_DstAddr = dstbase; + MyPacket.P12_DstPitch = pSiS->scrnOffset; + MyPacket.P12_DstHeight = 0xffff; + + MyPacket.P12_Command |= pPriv->AccelCmd | + SRCVIDEO | + PATFG | + pSiS->SiS310_AccelDepth | + YUV_CMD_YUV | + DSTVIDEO; + + if(pPriv->vsync) { +#ifdef SISMERGED + if(!pSiS->MergedFB) { +#endif +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + if(pSiS->SecondHead) { + MyPacket.P12_Command |= pPriv->VBlankTriggerCRT1; + } else { + MyPacket.P12_Command |= pPriv->VBlankTriggerCRT2; + } + } else { +#endif + Bool IsSlaveMode = SiSBridgeIsInSlaveMode(pScrn); + if((pSiS->VBFlags & DISPTYPE_DISP2) && !IsSlaveMode) + MyPacket.P12_Command |= pPriv->VBlankTriggerCRT2; + else if((pSiS->VBFlags & DISPTYPE_DISP1) || IsSlaveMode) + MyPacket.P12_Command |= pPriv->VBlankTriggerCRT1; +#ifdef SISDUALHEAD + } +#endif +#ifdef SISMERGED + } +#endif + } + + first = TRUE; + while(nbox--) { + left = pbox->x1; + if(left >= drw_x + xoffset + width) goto mycont; + + right = pbox->x2; + if(right <= drw_x + xoffset) goto mycont; + + top = pbox->y1; + if(top >= drw_y + yoffset + height) goto mycont; + + bottom = pbox->y2; + if(bottom <= drw_y + yoffset) goto mycont; + + if(left < (drw_x + xoffset)) left = drw_x + xoffset; + if(right > (drw_x + xoffset + width)) right = drw_x + xoffset + width; + if(top < (drw_y + yoffset)) top = drw_y + yoffset; + if(bottom > (drw_y + yoffset + height)) bottom = drw_y + yoffset + height; + + MyPacket.P12_DstX = left; + MyPacket.P12_DstY = top; + MyPacket.P12_RectWidth = right - left; + MyPacket.P12_RectHeight = bottom - top; + +#ifdef SISMERGED + if((first) && (pSiS->MergedFB)) { + int scrwidth = ((SiSMergedDisplayModePtr)pSiS->CurrentLayout.mode->Private)->CRT2->HDisplay; + int scrheight = ((SiSMergedDisplayModePtr)pSiS->CurrentLayout.mode->Private)->CRT2->VDisplay; + if( (right < pSiS->CRT2pScrn->frameX0) || + (left >= pSiS->CRT2pScrn->frameX0 + scrwidth) || + (bottom < pSiS->CRT2pScrn->frameY0) || + (top >= pSiS->CRT2pScrn->frameY0 + scrheight) ) { + MyPacket.P12_Command |= pPriv->VBlankTriggerCRT1; + } else { + MyPacket.P12_Command |= pPriv->VBlankTriggerCRT2; + } + } +#endif + + offsety = offsetuv = 0; + if(packed) { + if(pbox->y1 > drw_y + yoffset) { + offsetuv = (pbox->y1 - drw_y - yoffset) * srcPitch; + } + if(pbox->x1 > drw_x + xoffset) { + offsetuv += ((pbox->x1 - drw_x - xoffset) << 1); + if(offsetuv & 3) { +#if 0 /* Paint over covering object - no */ + if(MyPacket.P12_DstX > 0) { + offsetuv &= ~3; + MyPacket.P12_DstX--; + MyPacket.P12_RectWidth++; + } else { +#endif + offsetuv = (offsetuv + 3) & ~3; + MyPacket.P12_DstX++; + MyPacket.P12_RectWidth--; +#if 0 + } +#endif + } + } + } else { + if(pbox->y1 > drw_y + yoffset) { + offsety = (pbox->y1 - drw_y - yoffset) * srcPitch; + offsetuv = ((pbox->y1 - drw_y - yoffset) >> 1) * srcPitch; + } + if(pbox->x1 > drw_x + xoffset) { + offsety += (pbox->x1 - drw_x - xoffset); + offsetuv += (pbox->x1 - drw_x - xoffset); + if(offsetuv & 1) { + offsety++; + offsetuv++; + MyPacket.P12_DstX++; + MyPacket.P12_RectWidth--; + } + } + } + + if(!MyPacket.P12_RectWidth) continue; + + MyPacket.P12_YSrcAddr = pPriv->bufAddr[index][pPriv->currentBuf[index]] + offsety; + MyPacket.P12_UVSrcAddr = pPriv->bufAddr[index][pPriv->currentBuf[index]] + bytesize + offsetuv; + SISWriteBlitPacket(pSiS, (CARD32*)&MyPacket); + MyPacket.P12_Command &= ~(pPriv->VBlankTriggerCRT1 | pPriv->VBlankTriggerCRT2); + first = FALSE; +mycont: + pbox++; + } + +#if 0 + { + int debug = 0; + while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000) { debug++; }; + while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000) { debug++; }; + xf86DrvMsg(0, X_INFO, "vsync %d, debug %d\n", pPriv->vsync, debug); + } +#endif + + pPriv->currentBuf[index] ^= 1; + + UpdateCurrentTime(); + pPriv->freeTime[index] = currentTime.milliseconds + FREE_DELAY; + pPriv->videoStatus[index] = FREE_TIMER; + + pSiS->VideoTimerCallback = SISVideoTimerCallback; + + return Success; } +static int +SISQueryImageAttributesBlit( + ScrnInfoPtr pScrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets +){ + int pitchY, pitchUV; + int size, sizeY, sizeUV; + + if(*w > DummyEncodingBlit.width) *w = DummyEncodingBlit.width; + if(*h > DummyEncodingBlit.height) *h = DummyEncodingBlit.height; -/* Set MPEG Field Preset (yet unused) */ -static void -set_mpegfield_preset(SISPtr pSiS, SISOverlayPtr pOverlay) -{ - setvideoreg(pSiS,Index_MPEG_Y_Buf_Preset_Low, pOverlay->MPEG_Y & 0xFF); - setvideoreg(pSiS,Index_MPEG_Y_Buf_Preset_Middle, (pOverlay->MPEG_Y>>8) & 0xFF); + switch(id) { + case PIXEL_FMT_YV12: + case PIXEL_FMT_I420: + *w = (*w + 7) & ~7; + *h = (*h + 1) & ~1; + pitchY = *w; + pitchUV = *w >> 1; + if(pitches) { + pitches[0] = pitchY; + pitches[1] = pitches[2] = pitchUV; + } + sizeY = pitchY * (*h); + sizeUV = pitchUV * ((*h) >> 1); + if(offsets) { + offsets[0] = 0; + offsets[1] = sizeY; + offsets[2] = sizeY + sizeUV; + } + size = sizeY + (sizeUV << 1); + break; + case PIXEL_FMT_NV12: + case PIXEL_FMT_NV21: + *w = (*w + 7) & ~7; + pitchY = *w; + pitchUV = *w; + if(pitches) { + pitches[0] = pitchY; + pitches[1] = pitchUV; + } + sizeY = pitchY * (*h); + sizeUV = pitchUV * ((*h) >> 1); + if(offsets) { + offsets[0] = 0; + offsets[1] = sizeY; + } + size = sizeY + (sizeUV << 1); + break; + case PIXEL_FMT_YUY2: + case PIXEL_FMT_UYVY: + case PIXEL_FMT_YVYU: + default: + *w = (*w + 1) & ~1; + pitchY = *w << 1; + if(pitches) pitches[0] = pitchY; + if(offsets) offsets[0] = 0; + size = pitchY * (*h); + break; + } - setvideoreg(pSiS,Index_MPEG_UV_Buf_Preset_Low, pOverlay->MPEG_UV & 0xFF); - setvideoreg(pSiS,Index_MPEG_UV_Buf_Preset_Middle, (pOverlay->MPEG_UV>>8) & 0xFF); + return size; +} - setvideoreg(pSiS,Index_MPEG_Y_UV_Buf_Preset_High, - ((pOverlay->MPEG_Y>>16) & 0x0F) | ((pOverlay->MPEG_UV>>12) & 0xF0)); +static void +SISQueryBestSizeBlit( + ScrnInfoPtr pScrn, + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, + unsigned long index +){ + /* We cannot scale */ + *p_w = vid_w; + *p_h = vid_h; } +#endif /* INCL_YUV */ + +/*****************************************/ +/* TIMER CALLBACK */ +/*****************************************/ static void -set_mpegfield_scale(SISPtr pSiS, SISOverlayPtr pOverlay) +SISVideoTimerCallback(ScrnInfoPtr pScrn, Time now) { - /* Empty for now */ -} + SISPtr pSiS = SISPTR(pScrn); + SISPortPrivPtr pPriv = NULL; + SISBPortPrivPtr pPrivBlit = NULL; + unsigned char sridx, cridx; + Bool setcallback = FALSE; -#endif /* ------------------------------------------------------------------- */ + if(!pScrn->vtSema) return; + if(pSiS->adaptor) { + pPriv = GET_PORT_PRIVATE(pScrn); + if(!pPriv->videoStatus) pPriv = NULL; + } + if(pPriv) { + if(pPriv->videoStatus & TIMER_MASK) { + if(pPriv->videoStatus & OFF_TIMER) { + setcallback = TRUE; + if(pPriv->offTime < now) { + /* Turn off the overlay */ + sridx = inSISREG(SISSR); cridx = inSISREG(SISCR); + close_overlay(pSiS, pPriv); + outSISREG(SISSR, sridx); outSISREG(SISCR, cridx); + pPriv->mustwait = 1; + pPriv->videoStatus = FREE_TIMER; + pPriv->freeTime = now + FREE_DELAY; + } + } else if(pPriv->videoStatus & FREE_TIMER) { + if(pPriv->freeTime < now) { + SISFreeOverlayMemory(pScrn); + pPriv->mustwait = 1; + pPriv->videoStatus = 0; + } else { + setcallback = TRUE; + } + } + } + } + +#ifdef INCL_YUV_BLIT_ADAPTOR + if(pSiS->blitadaptor) { + int i; + pPrivBlit = (SISBPortPrivPtr)(pSiS->blitPriv); + for(i = 0; i < NUM_BLIT_PORTS; i++) { + if(pPrivBlit->videoStatus[i] & FREE_TIMER) { + if(pPrivBlit->freeTime[i] < now) { + SISFreeBlitMemory(pScrn, i); + pPrivBlit->videoStatus[i] = 0; + } else { + setcallback = TRUE; + } + } + } + } +#endif + + pSiS->VideoTimerCallback = (setcallback) ? SISVideoTimerCallback : NULL; +} diff --git a/src/vgatypes.h b/src/vgatypes.h index a5ec310..8205040 100644 --- a/src/vgatypes.h +++ b/src/vgatypes.h @@ -1,40 +1,60 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/vgatypes.h,v 1.9 2003/08/26 20:40:24 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * General type definitions for universal mode switching modules * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * If distributed as part of the linux kernel, the contents of this file - * is entirely covered by the GPL. + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * Otherwise, the following 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 * - * 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) 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 EXPRESSED 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. * - * Authors: Thomas Winischhofer - * Silicon Integrated Systems + * Author: Thomas Winischhofer * */ + #ifndef _VGATYPES_ #define _VGATYPES_ #ifdef LINUX_XF86 +#include "xf86Version.h" #include "xf86Pci.h" #endif @@ -42,10 +62,6 @@ #include #endif -#ifndef TC -#define far -#endif - #ifndef FALSE #define FALSE 0 #endif @@ -82,25 +98,6 @@ 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 @@ -109,53 +106,45 @@ typedef UCHAR BOOLEAN; typedef UCHAR bool; #endif -#ifndef VBIOS_VER_MAX_LENGTH -#define VBIOS_VER_MAX_LENGTH 4 +#ifdef LINUX_KERNEL +typedef unsigned long SISIOADDRESS; #endif -#ifndef LINUX_KERNEL /* For 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 */ +#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 + +enum _SIS_CHIP_TYPE { + SIS_VGALegacy = 0, + SIS_530, + SIS_OLD, SIS_300, SIS_630, SIS_730, SIS_540, SIS_315H, /* SiS 310 */ SIS_315, - SIS_315PRO, /* SiS 325 */ + SIS_315PRO, SIS_550, SIS_650, SIS_740, SIS_330, + SIS_661, + SIS_741, SIS_660, SIS_760, + SIS_761, + SIS_340, MAX_SIS_CHIP -} SIS_CHIP_TYPE; -#endif -#endif - -#ifndef SIS_VB_CHIP_TYPE -typedef enum _SIS_VB_CHIP_TYPE { - VB_CHIP_Legacy = 0, - VB_CHIP_301, - VB_CHIP_301B, - VB_CHIP_301LV, - VB_CHIP_302, - VB_CHIP_302B, - VB_CHIP_302LV, - VB_CHIP_301C, - VB_CHIP_UNKNOWN, /* other video bridge or no video bridge */ - MAX_VB_CHIP -} SIS_VB_CHIP_TYPE; -#endif +}; -#ifndef SIS_LCD_TYPE -typedef enum _SIS_LCD_TYPE { +#ifdef LINUX_KERNEL +enum _SIS_LCD_TYPE { LCD_INVALID = 0, LCD_800x600, LCD_1024x768, @@ -165,234 +154,123 @@ typedef enum _SIS_LCD_TYPE { LCD_1600x1200, LCD_1920x1440, LCD_2048x1536, - LCD_320x480, /* FSTN, DSTN */ + LCD_320x480, /* FSTN */ LCD_1400x1050, LCD_1152x864, LCD_1152x768, LCD_1280x768, LCD_1024x600, - LCD_640x480_2, /* FSTN, DSTN */ - LCD_640x480_3, /* FSTN, DSTN */ + LCD_640x480_2, /* DSTN */ + LCD_640x480_3, /* DSTN */ LCD_848x480, + LCD_1280x800, + LCD_1680x1050, + LCD_1280x720, LCD_CUSTOM, LCD_UNKNOWN -} SIS_LCD_TYPE; -#endif - -#ifndef PSIS_DSReg -typedef struct _SIS_DSReg -{ - UCHAR jIdx; - UCHAR jVal; -} SIS_DSReg, *PSIS_DSReg; +}; +typedef unsigned int SIS_LCD_TYPE; #endif -#ifndef SIS_HW_DEVICE_INFO +#ifndef SIS_HW_INFO -typedef struct _SIS_HW_DEVICE_INFO SIS_HW_DEVICE_INFO, *PSIS_HW_DEVICE_INFO; +typedef struct _SIS_HW_INFO SIS_HW_INFO, *PSIS_HW_INFO; -typedef BOOLEAN (*PSIS_QUERYSPACE) (PSIS_HW_DEVICE_INFO, ULONG, ULONG, ULONG *); +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 */ - - 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 */ +#ifdef LINUX_XF86 + PCITAG PciTag; /* PCI Tag */ +#endif + + 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; relocated) */ + UCHAR jChipType; /* Used to Identify SiS Graphics Chip */ - /* defined in the data structure type */ - /* "SIS_CHIP_TYPE" */ + /* defined in the enum "SIS_CHIP_TYPE" (above or sisfb.h) */ UCHAR jChipRevision; /* Used to Identify SiS Graphics Chip Revision */ - UCHAR ujVBChipID; /* the ID of video bridge */ - /* defined in the data structure type */ - /* "SIS_VB_CHIP_TYPE" */ - - 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 315 series! */ - ULONG ulCRT2LCDType; /* defined in the data structure type */ - /* "SIS_LCD_TYPE" */ - BOOLEAN bIntegratedMMEnabled;/* supporting integration MM enable */ - - BOOLEAN bSkipDramSizing; /* True: Skip video memory sizing. */ - PSIS_DSReg pSR; /* restore SR registers in initial function. */ - /* end data :(idx, val) = (FF, FF). */ - /* Note : restore SR registers if */ - /* bSkipDramSizing = TRUE */ - - PSIS_DSReg pCR; /* restore CR registers in initial function. */ - /* end data :(idx, val) = (FF, FF) */ - /* Note : restore cR registers if */ - /* bSkipDramSizing = TRUE */ - - 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 */ +#ifdef LINUX_KERNEL + ULONG ulCRT2LCDType; /* defined in the data structure type */ + /* "SIS_LCD_TYPE" */ #endif }; #endif - -/* TW: Addtional IOCTL for communication sisfb <> X driver */ -/* If changing this, sisfb.h must also be changed (for sisfb) */ +/* Addtional IOCTLs 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) */ -#define SISFB_GET_INFO 0x80046ef8 /* Wow, what a terrible hack... */ +/* ioctl for identifying and giving some info (esp. memory heap start) */ +#define SISFB_GET_INFO_SIZE 0x8004f300 +#define SISFB_GET_INFO 0x8000f301 /* Must be patched with result from ..._SIZE at D[29:16] */ +/* deprecated ioctl number (for older versions of sisfb) */ +#define SISFB_GET_INFO_OLD 0x80046ef8 + +/* ioctls for tv parameters (position) */ +#define SISFB_SET_TVPOSOFFSET 0x4004f304 -/* TW: Structure argument for SISFB_GET_INFO ioctl */ +/* lock sisfb from register access */ +#define SISFB_SET_LOCK 0x4004f306 + +/* 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 */ + CARD32 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; + CARD32 chip_id; /* PCI ID of detected chip */ + CARD32 memory; /* video memory in KB which sisfb manages */ + CARD32 heapstart; /* heap start (= sisfb "mem" argument) in KB */ + CARD8 fbvidmode; /* current sisfb mode */ - unsigned char sisfb_caps; /* sisfb's capabilities */ + CARD8 sisfb_version; + CARD8 sisfb_revision; + CARD8 sisfb_patchlevel; - int sisfb_tqlen; /* turbo queue length (in KB) */ + CARD8 sisfb_caps; /* sisfb's capabilities */ - unsigned int sisfb_pcibus; /* The card's PCI ID */ - unsigned int sisfb_pcislot; - unsigned int sisfb_pcifunc; - - unsigned char sisfb_lcdpdc; - - unsigned char sisfb_lcda; + CARD32 sisfb_tqlen; /* turbo queue length (in KB) */ - unsigned long sisfb_vbflags; - unsigned long sisfb_currentvbflags; + CARD32 sisfb_pcibus; /* The card's PCI ID */ + CARD32 sisfb_pcislot; + CARD32 sisfb_pcifunc; - int sisfb_scalelcd; - unsigned long sisfb_specialtiming; - - char reserved[219]; /* for future use */ -}; -#endif + CARD8 sisfb_lcdpdc; -#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 + CARD8 sisfb_lcda; -#ifndef PCI_TYPE0_ADDRESSES -#define PCI_TYPE0_ADDRESSES 6 -#endif + CARD32 sisfb_vbflags; + CARD32 sisfb_currentvbflags; -#ifndef PCI_TYPE1_ADDRESSES -#define PCI_TYPE1_ADDRESSES 2 -#endif + CARD32 sisfb_scalelcd; + CARD32 sisfb_specialtiming; -#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 + CARD8 sisfb_haveemi; + CARD8 sisfb_emi30,sisfb_emi31,sisfb_emi32,sisfb_emi33; + CARD8 sisfb_haveemilcd; -#ifndef FIELD_OFFSET -#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field)) -#endif + CARD8 sisfb_lcdpdca; + + CARD16 sisfb_tvxpos, sisfb_tvypos; /* Warning: Values + 32 ! */ -#ifndef PCI_COMMON_HDR_LENGTH -#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET (PCI_COMMON_CONFIG, DeviceSpecific)) + CARD8 reserved[208]; /* for future use */ +}; #endif #endif diff --git a/src/vstruct.h b/src/vstruct.h index 5f71368..5a97e18 100644 --- a/src/vstruct.h +++ b/src/vstruct.h @@ -1,34 +1,52 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/vstruct.h,v 1.14 2003/09/04 15:32:45 twini Exp $ */ +/* $XFree86$ */ +/* $XdotOrg$ */ /* * General structure definitions for universal mode switching modules * - * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria * - * If distributed as part of the linux kernel, the contents of this file - * is entirely covered by the GPL. + * If distributed as part of the Linux kernel, the following license terms + * apply: * - * Otherwise, the following 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 * - * 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) 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 EXPRESSED 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. * - * Authors: Thomas Winischhofer - * Silicon Integrated Systems + * Author: Thomas Winischhofer * */ @@ -112,6 +130,7 @@ typedef struct _SiS_StStruct UCHAR VB_StTVFlickerIndex; UCHAR VB_StTVEdgeIndex; UCHAR VB_StTVYFilterIndex; + UCHAR St_PDC; } SiS_StStruct; typedef struct _SiS_VBModeStruct @@ -143,13 +162,14 @@ typedef struct _SiS_ExtStruct { UCHAR Ext_ModeID; USHORT Ext_ModeFlag; - USHORT Ext_ModeInfo; USHORT Ext_VESAID; UCHAR Ext_RESINFO; UCHAR VB_ExtTVFlickerIndex; UCHAR VB_ExtTVEdgeIndex; UCHAR VB_ExtTVYFilterIndex; + UCHAR VB_ExtTVYFilterIndexROM661; UCHAR REFindex; + CHAR ROMMODEIDX661; } SiS_ExtStruct; typedef struct _SiS_Ext2Struct @@ -158,9 +178,11 @@ typedef struct _SiS_Ext2Struct UCHAR Ext_CRT1CRTC; UCHAR Ext_CRTVCLK; UCHAR Ext_CRT2CRTC; + UCHAR Ext_CRT2CRTC_NS; UCHAR ModeID; USHORT XRes; USHORT YRes; + UCHAR Ext_PDC; } SiS_Ext2Struct; typedef struct _SiS_Part2PortTblStruct @@ -179,12 +201,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; @@ -211,65 +227,85 @@ typedef struct _SiS_ModeResInfoStruct UCHAR YChar; } SiS_ModeResInfoStruct; + + typedef UCHAR DRAM4Type[4]; -/* Defines for SiS_Customt */ -#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 +/* 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_P3cb; - USHORT SiS_P3cd; - USHORT SiS_P3da; - USHORT SiS_Part1Port; - USHORT SiS_Part2Port; - USHORT SiS_Part3Port; - USHORT SiS_Part4Port; - USHORT SiS_Part5Port; - USHORT SiS_VidCapt; - USHORT SiS_VidPlay; + 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_ROMNew; + BOOLEAN SiS_NeedRomModeData; + BOOLEAN PanelSelfDetected; + int SiS_CHOverScan; BOOLEAN SiS_CHSOverScan; BOOLEAN SiS_ChSW; BOOLEAN SiS_UseLCDA; - int SiS_UseOEM; - ULONG SiS_CustomT; - USHORT SiS_Backup70xx; + int SiS_UseOEM; + ULONG SiS_CustomT; + USHORT SiS_Backup70xx; + BOOLEAN HaveEMI; + BOOLEAN HaveEMILCD; + BOOLEAN OverruleEMI; + UCHAR EMI_30,EMI_31,EMI_32,EMI_33; + SHORT PDC, PDCA; + UCHAR SiS_MyCR63; USHORT SiS_CRT1Mode; USHORT SiS_flag_clearbuffer; int SiS_RAMType; @@ -277,12 +313,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; @@ -306,32 +344,19 @@ 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; - USHORT SiS_Panel800x600; - USHORT SiS_Panel1024x768; - USHORT SiS_Panel1280x1024; - USHORT SiS_Panel1600x1200; - USHORT SiS_Panel1280x960; - USHORT SiS_Panel1400x1050; - USHORT SiS_Panel320x480; - USHORT SiS_Panel1152x768; - 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_ChrontelInit; + BOOLEAN SiS_SensibleSR11; + USHORT SiS661LCD2TableSize; + USHORT SiS_PanelMinLVDS; USHORT SiS_PanelMin301; - USHORT SiS_ChrontelInit; - + const SiS_StStruct *SiS_SModeIDTable; SiS_StandTableStruct *SiS_StandTable; const SiS_ExtStruct *SiS_EModeIDTable; @@ -340,12 +365,10 @@ typedef struct _SiS_Private 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; + SiS_VCLKDataStruct *SiS_VCLKData; + SiS_VBVCLKDataStruct *SiS_VBVCLKData; const SiS_StResInfoStruct *SiS_StResInfo; const SiS_ModeResInfoStruct *SiS_ModeResInfo; - const UCHAR *SiS_ScreenOffset; const UCHAR *pSiS_OutputSelect; const UCHAR *pSiS_SoftSetting; @@ -375,6 +398,12 @@ typedef struct _SiS_Private const USHORT *pSiS_VideoSenseData2; const USHORT *pSiS_YCSenseData2; #endif + + const SiS_PanelDelayTblStruct *SiS_PanelDelayTbl; + const SiS_PanelDelayTblStruct *SiS_PanelDelayTblLVDS; + + /* SiS bridge */ + const UCHAR *SiS_NTSCPhase; const UCHAR *SiS_PALPhase; const UCHAR *SiS_NTSCPhase2; @@ -384,42 +413,58 @@ typedef struct _SiS_Private const UCHAR *SiS_PALMPhase2; const UCHAR *SiS_PALNPhase2; const UCHAR *SiS_SpecialPhase; - const SiS_LCDDataStruct *SiS_StLCD1024x768Data; + const UCHAR *SiS_SpecialPhaseM; + const UCHAR *SiS_SpecialPhaseJ; const SiS_LCDDataStruct *SiS_ExtLCD1024x768Data; const SiS_LCDDataStruct *SiS_St2LCD1024x768Data; - const SiS_LCDDataStruct *SiS_StLCD1280x1024Data; + const SiS_LCDDataStruct *SiS_LCD1280x720Data; + const SiS_LCDDataStruct *SiS_StLCD1280x768_2Data; + const SiS_LCDDataStruct *SiS_ExtLCD1280x768_2Data; + const SiS_LCDDataStruct *SiS_LCD1280x768_3Data; + const SiS_LCDDataStruct *SiS_LCD1280x800Data; + const SiS_LCDDataStruct *SiS_LCD1280x960Data; const SiS_LCDDataStruct *SiS_ExtLCD1280x1024Data; const SiS_LCDDataStruct *SiS_St2LCD1280x1024Data; - const SiS_LCDDataStruct *SiS_NoScaleData1024x768; - const SiS_LCDDataStruct *SiS_NoScaleData1280x1024; - 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_StLCD1600x1200Data; const SiS_LCDDataStruct *SiS_ExtLCD1600x1200Data; - const SiS_LCDDataStruct *SiS_ExtLCD1280x768Data; + const SiS_LCDDataStruct *SiS_LCD1680x1050Data; 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_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; - const SiS_PanelDelayTblStruct *SiS_PanelDelayTbl; - const SiS_PanelDelayTblStruct *SiS_PanelDelayTblLVDS; +#endif + + const SiS_Part2PortTblStruct *SiS_CRT2Part2_1024x768_1; + const SiS_Part2PortTblStruct *SiS_CRT2Part2_1280x1024_1; + const SiS_Part2PortTblStruct *SiS_CRT2Part2_1024x768_2; + const SiS_Part2PortTblStruct *SiS_CRT2Part2_1280x1024_2; + const SiS_Part2PortTblStruct *SiS_CRT2Part2_1024x768_3; + const SiS_Part2PortTblStruct *SiS_CRT2Part2_1280x1024_3; + + /* LVDS, Chrontel */ + const SiS_LVDSDataStruct *SiS_LVDS800x600Data_1; const SiS_LVDSDataStruct *SiS_LVDS800x600Data_2; const SiS_LVDSDataStruct *SiS_LVDS1024x768Data_1; @@ -441,10 +486,6 @@ typedef struct _SiS_Private const SiS_LVDSDataStruct *SiS_LVDS640x480Data_1; const SiS_LVDSDataStruct *SiS_LVDS640x480Data_2; const SiS_LVDSDataStruct *SiS_LVDS320x480Data_1; - 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; @@ -461,6 +502,7 @@ typedef struct _SiS_Private const SiS_LVDSDataStruct *SiS_CHTVUPALNData; const SiS_LVDSDataStruct *SiS_CHTVOPALNData; const SiS_LVDSDataStruct *SiS_CHTVSOPALData; + const SiS_LVDSDesStruct *SiS_PanelType00_1; const SiS_LVDSDesStruct *SiS_PanelType01_1; const SiS_LVDSDesStruct *SiS_PanelType02_1; @@ -495,20 +537,11 @@ typedef struct _SiS_Private const SiS_LVDSDesStruct *SiS_PanelType0e_2; const SiS_LVDSDesStruct *SiS_PanelType0f_2; const SiS_LVDSDesStruct *SiS_PanelTypeNS_2; - - const SiS_LVDSDesStruct *LVDS1024x768Des_1; - const SiS_LVDSDesStruct *LVDS1280x1024Des_1; - const SiS_LVDSDesStruct *LVDS1400x1050Des_1; - const SiS_LVDSDesStruct *LVDS1600x1200Des_1; - const SiS_LVDSDesStruct *LVDS1024x768Des_2; - const SiS_LVDSDesStruct *LVDS1280x1024Des_2; - const SiS_LVDSDesStruct *LVDS1400x1050Des_2; - const SiS_LVDSDesStruct *LVDS1600x1200Des_2; - const SiS_LVDSDesStruct *SiS_CHTVUNTSCDesData; const SiS_LVDSDesStruct *SiS_CHTVONTSCDesData; const SiS_LVDSDesStruct *SiS_CHTVUPALDesData; const SiS_LVDSDesStruct *SiS_CHTVOPALDesData; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1800x600_1; const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11024x768_1; const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11280x1024_1; @@ -549,48 +582,13 @@ typedef struct _SiS_Private const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_2_H; const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_3; const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_3_H; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1320x480_1; const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1UNTSC; const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1ONTSC; const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1UPAL; const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1OPAL; const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1SOPAL; - 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; - - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1024x768_1; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1280x1024_1; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1400x1050_1; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1600x1200_1; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1024x768_2; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1280x1024_2; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1400x1050_2; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1600x1200_2; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1024x768_3; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1280x1024_3; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1400x1050_3; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1600x1200_3; - const SiS_CHTVRegDataStruct *SiS_CHTVReg_UNTSC; const SiS_CHTVRegDataStruct *SiS_CHTVReg_ONTSC; const SiS_CHTVRegDataStruct *SiS_CHTVReg_UPAL; @@ -600,6 +598,7 @@ typedef struct _SiS_Private const SiS_CHTVRegDataStruct *SiS_CHTVReg_UPALN; const SiS_CHTVRegDataStruct *SiS_CHTVReg_OPALN; const SiS_CHTVRegDataStruct *SiS_CHTVReg_SOPAL; + const UCHAR *SiS_CHTVVCLKUNTSC; const UCHAR *SiS_CHTVVCLKONTSC; const UCHAR *SiS_CHTVVCLKUPAL; @@ -610,9 +609,13 @@ typedef struct _SiS_Private const UCHAR *SiS_CHTVVCLKOPALN; const UCHAR *SiS_CHTVVCLKSOPAL; - USHORT PanelXRes; - USHORT PanelYRes; - + USHORT PanelXRes, PanelHT; + USHORT PanelYRes, PanelVT; + USHORT PanelHRS, PanelHRE; + USHORT PanelVRS, PanelVRE; + USHORT PanelVCLKIdx300; + USHORT PanelVCLKIdx315; + BOOLEAN UseCustomMode; BOOLEAN CRT1UsesCustomMode; USHORT CHDisplay; @@ -638,9 +641,6 @@ typedef struct _SiS_Private USHORT CModeFlag_CRT1; USHORT CInfoFlag; - BOOLEAN SiS_CHPALM; - BOOLEAN SiS_CHPALN; - int LVDSHL; BOOLEAN Backup; @@ -657,11 +657,13 @@ typedef struct _SiS_Private UCHAR Backup_1d; int UsePanelScaler; + int CenterScreen; USHORT CP_Vendor, CP_Product; BOOLEAN CP_HaveCustomData; - int CP_PreferredX, CP_PreferredY; + int CP_PreferredX, CP_PreferredY, CP_PreferredIndex; 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]; -- cgit v1.2.3