diff options
-rw-r--r-- | README.sgml | 254 | ||||
-rw-r--r-- | man/sis.man | 317 | ||||
-rw-r--r-- | src/300vtbl.h | 2599 | ||||
-rw-r--r-- | src/310vtbl.h | 5012 | ||||
-rw-r--r-- | src/init.c | 8146 | ||||
-rw-r--r-- | src/init.h | 2840 | ||||
-rw-r--r-- | src/init301.c | 17421 | ||||
-rw-r--r-- | src/init301.h | 495 | ||||
-rw-r--r-- | src/initdef.h | 419 | ||||
-rw-r--r-- | src/oem300.h | 549 | ||||
-rw-r--r-- | src/oem310.h | 485 | ||||
-rw-r--r-- | src/osdef.h | 113 | ||||
-rw-r--r-- | src/sis.h | 767 | ||||
-rw-r--r-- | src/sis300_accel.c | 572 | ||||
-rw-r--r-- | src/sis300_accel.h | 927 | ||||
-rw-r--r-- | src/sis310_accel.c | 1487 | ||||
-rw-r--r-- | src/sis310_accel.h | 652 | ||||
-rw-r--r-- | src/sis6326_video.c | 196 | ||||
-rw-r--r-- | src/sis_accel.c | 19 | ||||
-rw-r--r-- | src/sis_accel.h | 16 | ||||
-rw-r--r-- | src/sis_cursor.c | 876 | ||||
-rw-r--r-- | src/sis_cursor.h | 149 | ||||
-rw-r--r-- | src/sis_dac.c | 1825 | ||||
-rw-r--r-- | src/sis_dac.h | 72 | ||||
-rw-r--r-- | src/sis_dga.c | 60 | ||||
-rw-r--r-- | src/sis_dri.c | 475 | ||||
-rw-r--r-- | src/sis_dri.h | 40 | ||||
-rw-r--r-- | src/sis_driver.c | 9724 | ||||
-rw-r--r-- | src/sis_driver.h | 635 | ||||
-rw-r--r-- | src/sis_opt.c | 1970 | ||||
-rw-r--r-- | src/sis_regs.h | 97 | ||||
-rw-r--r-- | src/sis_setup.c | 359 | ||||
-rw-r--r-- | src/sis_shadow.c | 24 | ||||
-rw-r--r-- | src/sis_vb.c | 618 | ||||
-rw-r--r-- | src/sis_vga.c | 1845 | ||||
-rw-r--r-- | src/sis_video.c | 4409 | ||||
-rw-r--r-- | src/vgatypes.h | 263 | ||||
-rw-r--r-- | src/vstruct.h | 202 |
38 files changed, 39451 insertions, 27478 deletions
diff --git a/README.sgml b/README.sgml index 58d11ce..ec5b209 100644 --- a/README.sgml +++ b/README.sgml @@ -1,16 +1,16 @@ <!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN" [ <!ENTITY % defs SYSTEM "defs.ent"> %defs; ]> - + <article> <!-- Title information --> <title>Information for SiS Users -<author>Juanjo Santamarta (<email>santamarta@ctv.es</email>) -<date>5 March 2000 +<author>Thomas Winischhofer (<email>thomas@winischhofer.net</email>) +<date>5 October 2003 <ident> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/SiS.sgml,v 3.7 2000/03/06 22:59:24 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/SiS.sgml,v 3.8 2003/10/19 19:29:14 dawes Exp $ </ident> <!-- Table of contents --> @@ -18,30 +18,34 @@ $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/SiS.sgml,v 3.7 2000/03/06 22:5 <sect> Introduction <p> -This driver was primarily written for the SiS6326 and SiS530 by Alan Hourihane. -It also works on 5597/5598 chips, and probably on older SiS862X5 family. +This driver is written by Thomas Winischhofer and is a (nearly) complete re-write +of a driver written for the SiS6326 and SiS530 by Alan Hourihane and others. -The driver supports : +It currently supports the following chipsets: <itemize> - <item>Linear Addressing - <item>8/15/16/24 bits per pixel - <item>Fully programmable clocks are supported - <item>H/W acceleration and cursor support - <item>XAA support (XFree86 Acceleration Architecture) + <item>old series: 5597/5598, 6236/AGP/DVD, 530/620 + <item>300 series: 300/305, 540, 630/730 + <item>315 series: 315, 550, 650, 651, M650, 740 + <item>330 series: 330 ("Xabre"), 661FX, M661FX, 741, 760 </itemize> -<!-- this is incorrect -<sect> Supported chips <p> - -<quote> -SiS 530, SiS 86c2x5, SiS 5597/5598, SiS 6326 -</quote> - -This driver needs linear framebuffer support in the card. Because this -SiS 86C201 and 86C202 based cards don't work with this driver. +The driver supports: +<itemize> + <item>8/16/24 bits color depth; old series also 15; + <item>XAA (XFree86 Acceleration Architecture) + <item>XVideo (Xv) + <item>Render (XRAND) + <item>Hardware cursor; 315/330 series: Color HW cursor; + <item>6326: TV output + <item>300/315/330 series: TV output via Chrontel TV encoders or SiS video bridges + <item>300/315/330 series: LCD output via LVDS transmitters or SiS video bridges + <item>300/315/330 series: Dual head mode; Xinerama; Merged framebuffer mode; +</itemize> -Color expansion is not supported by the engine in 16M-color graphic mode. ---> +This document gives an overview over the driver's features and configuration options. +Please see http://www.winischhofer.net/linuxsisvga.shtml for detailed documentation +and updates. Support for the 661, 741 and 760 is entirely untested as of this writing, +and possibly incomplete for LCD output. <sect> XF86Config Options <p> @@ -49,83 +53,155 @@ The following options are of particular interest for the SiS driver. Each of them must be specified in the Device section of the XF86Config file for this card. -<descrip> -<tag>Option "SetMclk"</tag> - This option lets you to modify the memory clocking of your card. - (only for 5597 and 6326) Modifying the memory timings can destroy the - device, but usually the only ill effects of overclocking is to - have some noise an drawing errors, but BE CAREFUL. Usually a little - increment can improve the drawing speed, and allows also higher dotclocks. - The server reports default memclock on starting messages, so take it - as a base. Units are in KHZ. -<tag>Option "DacSpeed"</tag> - This option lets you to modify the maximum allowed dotclock). -<tag>Option "sw_cursor", "hw_cursor"</tag> - The default is for using the hardware cursor. -<!-- Which of these chips is even supported? --> -<tag>Option "Turboqueue"</tag> - 5597/8 and 6326 have the option to extend the engine command queue on - VRAM. With extended queue length, the driver only checks queue status - on some color-expansion commands. This gives some performance improvement, - but is possible to lose some commands, corrupting screen output. As the - size of extended command queue is 16-32K, the probability is very low, but - exists. The performance gain observed is around 8-10%. Currently, using - this option will occasionally freeze the acceleration engine, causing - weird image display. -<tag>Option "FastVram"</tag> - Enables 1 cycle memory access. Try it. Increased memory bandwidth reduces - the possibility of glitches and noise on high resolution modes. - -<tag>Option "PciRetry"</tag> +<sect1>For all chipsets<p> +<descrip> +<tag>Option "SWCursor", "HWCursor"</tag> + These options select whether the software (SW) or hardware (HW) cursor should + be used. The default is using the hardware cursor. <tag>Option "NoAccel"</tag> - Disables various hardware accelerations. + Disables 2D acceleration. Default: 2D acceleration is enabled. +<tag>Option "Turboqueue"</tag> + SiS chipsets have the option to extend the engine command queue on + VRAM. This concept is called "TurboQueue" and gives some performance improvement. + Due to hardware bugs, the TurboQueue is disabled on the 530/620, otherwise + enabled by default. +<tag>Option "Rotate"</tag> + This option enables clockwise ("CW") or counter-clockwise ("CCW") rotation of + the display. Enabling either CW or CCW rotation disables the RandR extension. + Default: no rotation. +<tag>Option "ShadowFB"</tag> + This option enables the shadow framebuffer layer. By default, it is disabled. +<tag>Option "NoXVideo"</tag> + Disables the XVideo support. Default: XVideo support is enabled. +<tag>Option "CRT1Gamma"</tag> + Enables or disables gamma correction. Default: gamma correction is enabled. +</descrip> -<tag>VideoRAM size</tag> The SiS chips can only directly address 4096K - bytes of video RAM. Some video cards using these chips are - shipped with additional video RAM. The videoRAM must be - explicitly limited to 4096 for those cards. Attempting to use - the additional RAM leads to a variety of scrambled screen - artifacts. +<sect1>old series specific options <p> +<descrip> +<tag>Option "FastVram"</tag> + Enables 1 cycle memory access for read and write operations. The default + depends on the chipset used. +<tag>Option "NoHostBus"</tag> + For 5597/5598 only. This option, if set, disables the CPU to VGA host bus. + Disabling the host bus will result in a severe performance regression. +<tag>VideoRAM size</tag> The SiS 6326 can only directly address 4096K + bytes of video RAM. However, there are some cards out there featuring + 8192K (8MB) of video RAM. This RAM is not addressable by the engines. + Therefore, by default, the driver will only use 4096K. This behavior + can be overridden by specifying the amount of video RAM using the + VideoRAM keyword. If more than 4096K is specified, the driver will + disable 2D acceleration, Xv and the HW cursor. On all other chipsets, + this keyword is ignored. +<tag>Option "NoYV12"</tag> + Due to hardware bugs, XVideo may display a corrupt image when using + YV12 encoded material. This option, if set, disables support for YV12 + and hence forces the Xv-aware application to use either YUV2 or XShm + for video output. +<tag>Option "TVStandard"</tag> + (6326 only) Selects the TV output standard. May be PAL or NTSC. By default, + this is selected by a jumper on the card. </descrip> +<sect1>300/315/330 series specific options<p> -<sect> Modelines <p> +<descrip> +<tag>Option "ForceCRT1"</tag> + Enables or disables CRT1 (= the external VGA monitor). By default, + the driver will use CRT1 if a monitor is detected during server + start. Some older monitors can't be detected, so they may require + setting this option to true. To disable CRT1 output, set this option + to false. +<tag>Option "ForceCRT1Type"</tag> + SiS 650, M650 and 651 with either 301LV or 302LV video bridge only. + May be VGA or LCD. Specifying LCD will force the driver to use the + VGA controller's CRT1 channel for driving the LCD, while CRT2 is + free for TV usage. Default is VGA. +<tag>Option "ForceCRT2Type"</tag> + Selects the CRT2 output device type. Valid parameters are LCD, TV, + SVIDEO, COMPOSITE, SCART, VGA, NONE. NONE disables CRT2. SVIDEO and + COMPOSITE are only for systems with a SiS video bridge and select the + desired plug type. For Chrontel systems, TV should be used instead. + VGA means secondary VGA and is only available on some SiS video bridges + (301, 301B, 301C). +<tag>Option "CRT2Gamma"</tag> + Enables or disables gamma correction for CRT2. This is only supported + for SiS video bridges. Default: gamma correction for CRT2 is enabled. +<tag>Option "DRI"</tag> + Although this option is accepted for all chipsets, it currently only + makes sense on the 300 series; DRI is only supported on these chipsets. + This option enables/disables DRI. +<tag>Option "TVStandard"</tag> + Selects the TV output standard. May be PAL or NTSC, on some machines + (depending on the hardware) also PALM and PALN. Default: BIOS setting. +<tag>Option "TVXPosOffset", "TVYPosOffset"</tag> + These options allow relocating the image on your TV. Both options take + an integer within the range of -16 to 16. Default: 0. Not supported for + Chrontel 7019. +<tag>Option "CHTVOverscan"</tag> + For Chrontel TV encoders only. Selects whether TV output should be + overscan or underscan. +<tag>Option "CHTVSuperOverscan"</tag> + For Chrontel 7005 TV encoders in PAL mode only. Selects whether TV output + should be super-overscan (slightly larger than the viewable area) or + not. +<tag> Option "SISTVXScale", "SISTVYScale"</tag> + For SiS video bridges only. These options allow zooming the image on + your TV. SISTVXScale takes an integer within the range of -16 to 16. + SISTVYScale accepts -4 to 3. Default: 0. Not all modes can be scaled. +</descrip> -When constructing a modeline for use with the Sis -driver you'll need to consider several points: -<itemize> - <item>H/W Acceleration. The H/W cursor, and fill operations - currently allocate memory of the video ram for there own use. - If this is not available these functions will automatically be - disabled. Also, Turboqueue allocate 32k of Vram. - <item>Dot Clock. SiS documents the following video modes to work with - 6326. The max dot clock allowable for your 6326 based board depends - also on the memory installed on it. Option FastVram can be needed - for high dot clocks to work. Of course, the memory installed must - allow 1 cycle R/W. - <p> - SiS recommended video modes for 6326: - <descrip> - <tag>640x480 :</tag>4, 8, 15, 16, 24 bpp at 85Hz Non-interlaced - <tag>800x600 :</tag>4, 8, 15, 16, 24 bpp at 85Hz Non-interlaced - <tag>1024x768 :</tag>4, 8, 15, 16, 24 bpp at 85Hz Non-interlaced - <tag>1280x1024 :</tag>4, 8, 15, 16, 24 bpp at 75Hz Non-interlaced - <tag>1600x1200 :</tag>4, 8 bpp at 65Hz Non-interlaced - </descrip> -</itemize> +<sect1> 300 series specific options<p> -<sect> Troubleshooting <p> +<descrip> +<tag>Option "MaxXFBMem"</tag> + DRI requires the linux kernel's SiS framebuffer driver "sisfb" and some + other modules which come with either the linux kernel or XFree86. (On *BSD, + the DRI driver does not require any framebuffer driver.) + 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 Option "MaxXFBMem" exists. + + XFree 4.3.0 disabled SiS DRI support due to a lack of maintainance of the SiS DRI + driver. XFree86 4.4 contains a newly written SiS DRI driver by Eric Anholt. + + 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. + + 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 MaxXFBMem option at all. + The X driver will receive enough information from sisfb in this case. + + 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 MaxXFBMem to the same value as you + gave sisfb with its mem parameter. If you didn't specify any mem parameter, sisfb + will reserve 12288KB if more than 16MB of total video RAM is available, 8192KB if + between 12 and 16MB of video RAM is available, 4096KB in all other cases. + + Then you need to specify any of these amounts as the parameter for the MaxXFBMem + option. The value is to be given without 'KB'. +</descrip> -<!-- don't have XF86Setup for 4.0 -The generic VGA driver don't work with 6326, so XF86Setup can't be used -for this card. Please use xf86config instead. ---> +<sect1> 315/330 series specific options<p> -Some video modes with high dot-clocks don't work at all, resulting on black -screen. Lowering dotclock in that case could solve the problem. +<descrip> +<tag>Option "RenderAcceleration"</tag> + Enables or disables RENDER acceleration. By default, RENDER acceleration + is enabled. +<tag>Option "XvOnCRT2"</tag> + 315, 650, 740, 330 only. This option selects whether the XVideo (Xv) + overlay should be displayed on CRT1 or CRT2. Setting this options + means CRT2. The other CRT will only display the (blue) color key. +</descrip> -Document based on 3.3 version written by Xavier Ducoin. +Document based on 4.1 version written by Joanjo Santamarta and 3.3 version +written by Xavier Ducoin. </article> diff --git a/man/sis.man b/man/sis.man index 7663044..ec4aee8 100644 --- a/man/sis.man +++ b/man/sis.man @@ -1,4 +1,4 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.man,v 1.10 2003/01/29 15:42:16 eich Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.man,v 1.14 2003/11/12 16:50:36 twini Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' .TH SIS __drivermansuffix__ __vendorversion__ @@ -14,9 +14,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 XFree86 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 +29,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/650M/740 +.B SiS550/551/552 +.B SiS650/651/M650/661FX/M661FX/M661MX/740/741 .B SiS330 (Xabre) +.B SiS760 .PP In the following text, the following terms are used: .PP @@ -41,13 +42,19 @@ for SiS5597/5598, 530/620 and 6326/AGP/DVD .B 300 series for SiS300/305, 540 and 630/730 .PP -.B 310/325/330 series -for SiS315/H/PRO, 550 and 650/651/650M/740, 330 +.B 315/330 series +for SiS315/H/PRO, 55x and (M)65x/(M)661xX/74x, 330, 760 +.PP +Note: Support for 661FX, M661FX, M661MX, 741 and 760 is untested. .SH CONFIGURATION DETAILS Please refer to XF86Config(__filemansuffix__) for general configuration details. This section only covers configuration details specific to this -driver. Please note that support for the SiS330 is new and there may be -some problems. +driver. +.PP +Detailed information on all supported options can be obtained at +http://www.winischhofer.net/linuxsisvga.shtml +.PP +This manpage only covers a subset of the supported options. .PP .I "1. For all supported chipsets" .PP @@ -56,8 +63,7 @@ The following driver are supported on all chipsets: .TP .BI "Option \*qNoAccel\*q \*q" boolean \*q -Disable or enable 2D acceleration. Please note: On chipsets with XVideo -support, this also disables XVideo. Default: acceleration is enabled. +Disable or enable 2D acceleration. Default: acceleration is enabled. .TP .BI "Option \*qHWCursor\*q \*q" boolean \*q Enable or disable the HW cursor. Default: HWCursor is on. @@ -67,37 +73,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 @@ -107,13 +119,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. @@ -127,11 +139,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 @@ -140,39 +151,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 310/325/330 series specific information" +.I "2. 300 and 315/330 series specific information" .PP -The 300 and 310/325/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 @@ -184,9 +202,9 @@ which makes it possible to run the driver in dual head mode. The driver supports the following video bridges: .PP .B SiS301 -.B SiS301B -.B SiS301LV -.B SiS302B +.B SiS301B(-DH) +.B SiS301C +.B SiS301LV(X) .B SiS302LV .PP Instead of a video bridge, some machines have a @@ -201,30 +219,38 @@ 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, 650M, 651 and 330 support two video -overlays. The SiS315/H/PRO and 650/740 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 +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 can be used to select the desired output channel. .PP +About Merged Framebuffer support +.PP +This mode is strongly recommended over Xinerama. Please see +http://www.winischhofer.net/linuxsisvga.shtml for detailed +information. +.PP 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. .PP The following driver .B Options -are supported on the 300 and 310/325 series: +are supported on the 300 and 315/330 series: .TP .BI "Option \*qNoXVideo\*q \*q" boolean \*q Disable XV (XVideo) extension support. @@ -239,24 +265,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: @@ -268,70 +289,63 @@ Force display type to one of: , .B COMPOSITE , -.B SCART, +.B SVIDEO+COMPOSITE +, +.B SCART , .B LCD , .B VGA ; .B NONE -will disable CRT2. The SVIDEO, COMPOSITE and SCART parameters -can be used to force the driver to use a specific TV output -connector (if present). +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 video bridge or a LVDS transmitter. -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 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. -.TP -.BI "Option \*qUseROMData\*q \*q" boolean \*q -The driver reads some data from the BIOS ROM, especially -LCD dependent information. If the folks at SiS some day -decide to change the location of this data inside the -BIOS image, the display might not be initialized correctly. -In order to prevent this, set this option's parameter to -.B false. -Default: ROM data is used +.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 650/740, +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 yet. +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 yet. +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 @@ -341,51 +355,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 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 XFree86. +.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 -At the moment (2002), 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 @@ -393,20 +396,22 @@ 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" -For some reason, PAL TV output on the SiS301LV bridge is -only black and white. NTSC is OK, though. -.PP -LCD panels with a resolution of 1280x1024 do not work -correctly. +none. .SH "SEE ALSO" XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) .PP -.B "http://www.winischhofer.net" +.B "http://www.winischhofer.net/linuxsisvga.shtml" for more information and updates .SH AUTHORS Authors include: Alan Hourihane, Mike Chapman, Juanjo Santamarta, Mitani diff --git a/src/300vtbl.h b/src/300vtbl.h index a6989da..6227235 100644 --- a/src/300vtbl.h +++ b/src/300vtbl.h @@ -1,8 +1,37 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/300vtbl.h,v 1.6 2003/02/10 01:14:16 tsi Exp $ */ - - -/* Register settings for SiS 300 series */ - +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/300vtbl.h,v 1.20 2003/11/19 00:49:02 twini Exp $ */ +/* + * Register settings for SiS 300 series + * + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the linux kernel, the contents of this file + * is entirely covered by the GPL. + * + * Otherwise, the following 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. + * + * 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 <thomas@winischhofer.net> + * + * Based on code by Silicon Intergrated Systems + * + */ typedef struct _SiS300_StStruct { @@ -14,577 +43,220 @@ typedef struct _SiS300_StStruct UCHAR VB_StTVFlickerIndex; UCHAR VB_StTVEdgeIndex; UCHAR VB_StTVYFilterIndex; + UCHAR St_PDC; } SiS300_StStruct; static const SiS300_StStruct SiS300_SModeIDTable[] = { - {0x01,0x9208,0x01,0x00,0x00,0x00,0x00,0x00}, - {0x01,0x1210,0x14,0x01,0x01,0x00,0x00,0x00}, - {0x01,0x1010,0x17,0x02,0x02,0x00,0x00,0x00}, - {0x03,0x8208,0x03,0x00,0x00,0x00,0x00,0x00}, - {0x03,0x0210,0x16,0x01,0x01,0x00,0x00,0x00}, - {0x03,0x0010,0x18,0x02,0x02,0x00,0x00,0x00}, - {0x05,0x9209,0x05,0x00,0x00,0x00,0x00,0x00}, - {0x06,0x8209,0x06,0x00,0x00,0x00,0x00,0x00}, - {0x07,0x0000,0x07,0x03,0x03,0x00,0x00,0x00}, - {0x07,0x0000,0x19,0x02,0x02,0x00,0x00,0x00}, - {0x0d,0x920a,0x0d,0x00,0x00,0x00,0x00,0x00}, - {0x0e,0x820a,0x0e,0x00,0x00,0x00,0x00,0x00}, - {0x0f,0x0202,0x11,0x01,0x01,0x00,0x00,0x00}, - {0x10,0x0212,0x12,0x01,0x01,0x00,0x00,0x00}, - {0x11,0x0212,0x1a,0x04,0x04,0x00,0x00,0x00}, - {0x12,0x0212,0x1b,0x04,0x04,0x00,0x00,0x00}, - {0x13,0x021b,0x1c,0x00,0x00,0x00,0x00,0x00}, - {0x12,0x0010,0x18,0x02,0x02,0x00,0x00,0x00}, - {0x12,0x0210,0x18,0x01,0x01,0x00,0x00,0x00}, - {0xff, 0, 0, 0, 0, 0, 0, 0} -}; - -typedef struct _SiS300_StandTableStruct -{ - UCHAR CRT_COLS; - UCHAR ROWS; - UCHAR CHAR_HEIGHT; - USHORT CRT_LEN; - UCHAR SR[4]; - UCHAR MISC; - UCHAR CRTC[0x19]; - UCHAR ATTR[0x14]; - UCHAR GRC[9]; -} SiS300_StandTableStruct; - -static const SiS300_StandTableStruct SiS300_StandTable[] = -{ - {0x28,0x18,0x08,0x0800, /* 0x00 */ - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x28,0x18,0x08,0x0800, /* 0x01 */ - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x50,0x18,0x08,0x1000, /* 0x02 */ - {0x01,0x03,0x00,0x02}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x50,0x18,0x08,0x1000, /* 0x03 */ - {0x01,0x03,0x00,0x02}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x28,0x18,0x08,0x4000, /* 0x04 */ - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0x80,0xbf,0x1f, - 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2, - 0xff}, - {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x03,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00, - 0xff} }, - {0x28,0x18,0x08,0x4000, /* 0x05 */ - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0x80,0xbf,0x1f, - 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2, - 0xff}, - {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x03,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00, - 0xff} }, - {0x50,0x18,0x08,0x4000, /* 0x06 */ - {0x01,0x01,0x00,0x06}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f, - 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2, - 0xff}, - {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17, - 0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17, - 0x01,0x00,0x01,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00, - 0xff} }, - {0x50,0x18,0x0e,0x1000, /* 0x07 */ - {0x00,0x03,0x00,0x03}, - 0xa6, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3, - 0xff}, - {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08, - 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18, - 0x0e,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00, - 0xff} }, -/* MDA_DAC*/ - {0x00,0x00,0x00,0x0000, /* 0x08 */ - {0x00,0x00,0x00,0x15}, - 0x15, - {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, - 0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00, - 0x00}, - {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15, - 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, - 0x15,0x15,0x15,0x15}, - {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f} }, -/* CGA_DAC*/ - {0x00,0x10,0x04,0x0114, /* 0x09 */ - {0x11,0x09,0x15,0x00}, - 0x10, - {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a, - 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a, - 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10, - 0x04}, - {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04, - 0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e, - 0x3e,0x2b,0x3b,0x2f}, - {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f, - 0x3f} }, -/* EGA_DAC*/ - {0x00,0x10,0x04,0x0114, /* 0x0a */ - {0x11,0x05,0x15,0x20}, - 0x30, - {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18, - 0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38, - 0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12, - 0x06}, - {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26, - 0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e, - 0x1e,0x0b,0x1b,0x0f}, - {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f, - 0x3f} }, -/* VGA_DAC*/ - {0x00,0x10,0x04,0x0114, /* 0x0b */ - {0x11,0x09,0x15,0x2a}, - 0x3a, - {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05, - 0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20, - 0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10, - 0x1f}, - {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d, - 0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15, - 0x1c,0x0e,0x11,0x15}, - {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00, - 0x04} }, - {0x08,0x0c,0x10,0x0a08, /* 0x0c */ - {0x0c,0x0e,0x10,0x0b}, - 0x0c, - {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00, - 0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00, - 0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00, - 0x06}, - {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08, - 0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00, - 0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00} }, - {0x28,0x18,0x08,0x2000, /* 0x0d */ - {0x09,0x0f,0x00,0x06}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0x80,0xbf,0x1f, - 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} }, - {0x50,0x18,0x08,0x4000, /* 0x0e */ - {0x01,0x0f,0x00,0x06}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f, - 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} }, - {0x00,0x00,0x00,0x0000, /* 0x0f */ /* TW: Standtable for VGA modes */ - {0x01,0x0f,0x00,0x0e}, - 0x23, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, - 0x01,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, - 0xff} }, - {0x4a,0x36,0x00,0x00c0, /* 0x10 */ - {0x00,0x00,0x00,0x00}, - 0x00, - {0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x3a, - 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x1a,0x00,0x57,0x39,0x00,0xc0, - 0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00} }, - {0x50,0x18,0x0e,0x8000, /* 0x11 */ - {0x01,0x0f,0x00,0x06}, - 0xa2, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x0f,0x63,0xba,0xe3, - 0xff}, - {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00, - 0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00, - 0x0b,0x00,0x05,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05, - 0xff} }, - {0x50,0x18,0x0e,0x8000, /* 0x12 */ - {0x01,0x0f,0x00,0x06}, - 0xa3, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x0f,0x63,0xba,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} }, - {0x28,0x18,0x0e,0x0800, /* 0x13 */ - {0x09,0x03,0x00,0x02}, - 0xa3, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x28,0x18,0x0e,0x0800, /* 0x14 */ - {0x09,0x03,0x00,0x02}, - 0xa3, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x50,0x18,0x0e,0x1000, /* 0x15 */ - {0x01,0x03,0x00,0x02}, - 0xa3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x50,0x18,0x0e,0x1000, /* 0x16 */ - {0x01,0x03,0x00,0x02}, - 0xa3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x28,0x18,0x10,0x0800, /* 0x17 */ - {0x08,0x03,0x00,0x02}, - 0x67, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x0c,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x50,0x18,0x10,0x1000, /* 0x18 */ - {0x00,0x03,0x00,0x02}, - 0x67, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x0c,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} }, - {0x50,0x18,0x10,0x1000, /* 0x19 */ - {0x00,0x03,0x00,0x02}, - 0x66, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08, - 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18, - 0x0e,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00, - 0xff} }, - {0x50,0x1d,0x10,0xa000, /* 0x1a */ - {0x01,0x0f,0x00,0x06}, - 0xe3, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0xea,0x8c,0xdf,0x28,0x00,0xe7,0x04,0xc3, - 0xff}, - {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01, - 0xff} }, - {0x50,0x1d,0x10,0xa000, /* 0x1b */ - {0x01,0x0f,0x00,0x06}, - 0xe3, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0xea,0x8c,0xdf,0x28,0x00,0xe7,0x04,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} }, - {0x28,0x18,0x08,0x2000, /* 0x1c */ - {0x01,0x0f,0x00,0x0e}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f, - 0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, - 0x41,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, - 0xff} } + {0x01,0x9208,0x01,0x00,0x00,0x00,0x00,0x00, 0}, + {0x01,0x1210,0x14,0x01,0x01,0x00,0x00,0x00, 0}, + {0x01,0x1010,0x17,0x02,0x02,0x00,0x00,0x00, 0}, + {0x03,0x8208,0x03,0x00,0x00,0x00,0x00,0x00, 0}, + {0x03,0x0210,0x16,0x01,0x01,0x00,0x00,0x00, 0}, + {0x03,0x0010,0x18,0x02,0x02,0x00,0x00,0x00, 0}, + {0x05,0x9209,0x05,0x00,0x00,0x00,0x00,0x00, 0}, + {0x06,0x8209,0x06,0x00,0x00,0x00,0x00,0x00, 0}, + {0x07,0x0000,0x07,0x03,0x03,0x00,0x00,0x00, 0}, + {0x07,0x0000,0x19,0x02,0x02,0x00,0x00,0x00, 0}, + {0x0d,0x920a,0x0d,0x00,0x00,0x00,0x00,0x00, 0}, + {0x0e,0x820a,0x0e,0x00,0x00,0x00,0x00,0x00, 0}, + {0x0f,0x0202,0x11,0x01,0x01,0x00,0x00,0x00, 0}, + {0x10,0x0212,0x12,0x01,0x01,0x00,0x00,0x00, 0}, + {0x11,0x0212,0x1a,0x04,0x04,0x00,0x00,0x00, 0}, + {0x12,0x0212,0x1b,0x04,0x04,0x00,0x00,0x00, 0}, + {0x13,0x021b,0x1c,0x00,0x00,0x00,0x00,0x00, 0}, + {0x12,0x0010,0x18,0x02,0x02,0x00,0x00,0x00, 0}, + {0x12,0x0210,0x18,0x01,0x01,0x00,0x00,0x00, 0}, + {0xff, 0, 0, 0, 0, 0, 0, 0, 0} }; typedef struct _SiS300_ExtStruct { - UCHAR Ext_ModeID; + UCHAR Ext_ModeID; USHORT Ext_ModeFlag; - USHORT Ext_ModeInfo; - USHORT Ext_Point; + UCHAR Ext_ModeOffset; USHORT Ext_VESAID; - UCHAR Ext_VESAMEMSize; - UCHAR Ext_RESINFO; - UCHAR VB_ExtTVFlickerIndex; - UCHAR VB_ExtTVEdgeIndex; - UCHAR VB_ExtTVYFilterIndex; - UCHAR REFindex; + UCHAR Ext_RESINFO; + UCHAR VB_ExtTVFlickerIndex; + UCHAR VB_ExtTVEdgeIndex; + UCHAR VB_ExtTVYFilterIndex; + UCHAR VB_ExtTVYFilterIndexROM661; + UCHAR REFindex; } SiS300_ExtStruct; static const SiS300_ExtStruct SiS300_EModeIDTable[] = { - {0x6a,0x2212,0x47,0x3563,0x0102,0x08,0x07,0x00,0x00,0x00,0x00}, /* 800x600x? */ - {0x2e,0x0a1b,0x36,0x3539,0x0101,0x08,0x06,0x00,0x00,0x00,0x08}, - {0x2f,0x021b,0x35,0x3532,0x0100,0x08,0x05,0x00,0x00,0x00,0x10}, /* 640x400x8 */ - {0x30,0x2a1b,0x47,0x3563,0x0103,0x08,0x07,0x00,0x00,0x00,0x00}, - {0x31,0x0a1b,0xad,0x3630,0x0000,0x08,0x0c,0x00,0x00,0x00,0x11}, /* 720x480x8 */ - {0x32,0x2a1b,0xae,0x3637,0x0000,0x08,0x0d,0x00,0x00,0x00,0x12}, /* 720x576x8 */ - {0x33,0x0a1d,0xad,0x3630,0x0000,0x08,0x0c,0x00,0x00,0x00,0x11}, /* 720x480x16 */ - {0x34,0x2a1d,0xae,0x3637,0x0000,0x08,0x0d,0x00,0x00,0x00,0x12}, /* 720x576x16 */ - {0x35,0x0a1f,0xad,0x3630,0x0000,0x08,0x0c,0x00,0x00,0x00,0x11}, /* 720x480x32 */ - {0x36,0x2a1f,0xae,0x3637,0x0000,0x08,0x0d,0x00,0x00,0x00,0x12}, /* 720x576x32 */ - {0x37,0x0212,0x58,0x358d,0x0104,0x08,0x08,0x00,0x00,0x00,0x13}, /* 1024x768x? */ - {0x38,0x0a1b,0x58,0x358d,0x0105,0x08,0x08,0x00,0x00,0x00,0x13}, /* 1024x768x8 */ - {0x3a,0x0e3b,0x69,0x35be,0x0107,0x08,0x09,0x00,0x00,0x00,0x1a}, /* 1280x1024x8 */ - {0x3c,0x063b,0x7a,0x35d4,0x0130,0x08,0x0a,0x00,0x00,0x00,0x1e}, - {0x3d,0x067d,0x7a,0x35d4,0x0131,0x08,0x0a,0x00,0x00,0x00,0x1e}, - {0x40,0x921c,0x00,0x3516,0x010d,0x08,0x00,0x00,0x00,0x00,0x23}, - {0x41,0x921d,0x00,0x3516,0x010e,0x08,0x00,0x00,0x00,0x00,0x23}, - {0x43,0x0a1c,0x36,0x3539,0x0110,0x08,0x06,0x00,0x00,0x00,0x08}, - {0x44,0x0a1d,0x36,0x3539,0x0111,0x08,0x06,0x00,0x00,0x00,0x08}, - {0x46,0x2a1c,0x47,0x3563,0x0113,0x08,0x07,0x00,0x00,0x00,0x00}, /* 800x600 */ - {0x47,0x2a1d,0x47,0x3563,0x0114,0x08,0x07,0x00,0x00,0x00,0x00}, /* 800x600 */ - {0x49,0x0a3c,0x58,0x358d,0x0116,0x08,0x08,0x00,0x00,0x00,0x13}, - {0x4a,0x0a3d,0x58,0x358d,0x0117,0x08,0x08,0x00,0x00,0x00,0x13}, - {0x4c,0x0e7c,0x69,0x35be,0x0119,0x08,0x09,0x00,0x00,0x00,0x1a}, - {0x4d,0x0e7d,0x69,0x35be,0x011a,0x08,0x09,0x00,0x00,0x00,0x1a}, - {0x50,0x921b,0x01,0x351d,0x0132,0x08,0x01,0x00,0x00,0x00,0x24}, - {0x51,0xb21b,0x13,0x3524,0x0133,0x08,0x03,0x00,0x00,0x00,0x25}, /* 400x300 */ - {0x52,0x921b,0x24,0x352b,0x0134,0x08,0x04,0x00,0x00,0x00,0x26}, - {0x56,0x921d,0x01,0x351d,0x0135,0x08,0x01,0x00,0x00,0x00,0x24}, - {0x57,0xb21d,0x13,0x3524,0x0136,0x08,0x03,0x00,0x00,0x00,0x25}, /* 400x300 */ - {0x58,0x921d,0x24,0x352b,0x0137,0x08,0x04,0x00,0x00,0x00,0x26}, - {0x59,0x921b,0x00,0x3516,0x0138,0x08,0x00,0x00,0x00,0x00,0x23}, - {0x5c,0x921f,0x24,0x352b,0x0000,0x08,0x04,0x00,0x00,0x00,0x26}, /* TW: inserted 512x384x32 */ - {0x5d,0x021d,0x35,0x3532,0x0139,0x08,0x05,0x00,0x00,0x00,0x10}, /* 640x400x16 */ - {0x5e,0x021f,0x35,0x3532,0x0000,0x08,0x05,0x00,0x00,0x00,0x10}, /* TW: inserted 640x400x32 */ - {0x62,0x0a3f,0x36,0x3539,0x013a,0x08,0x06,0x00,0x00,0x00,0x08}, - {0x63,0x2a3f,0x47,0x3563,0x013b,0x08,0x07,0x00,0x00,0x00,0x00}, /* 800x600 */ - {0x64,0x0a7f,0x58,0x358d,0x013c,0x08,0x08,0x00,0x00,0x00,0x13}, - {0x65,0x0eff,0x69,0x35be,0x013d,0x08,0x09,0x00,0x00,0x00,0x1a}, - {0x66,0x06ff,0x7a,0x35d4,0x013e,0x08,0x0a,0x00,0x00,0x00,0x1e}, - {0x68,0x067b,0x8b,0x35ef,0x013f,0x08,0x0b,0x00,0x00,0x00,0x27}, - {0x69,0x06fd,0x8b,0x35ef,0x0140,0x08,0x0b,0x00,0x00,0x00,0x27}, - {0x6b,0x07ff,0x8b,0x35ef,0x0000,0x10,0x0b,0x00,0x00,0x00,0x27}, - {0x6c,0x067b,0x9c,0x35f6,0x0000,0x08,0x11,0x00,0x00,0x00,0x28}, /* TW: 2048x1536x8 - not in BIOS! */ - {0x6d,0x06fd,0x9c,0x35f6,0x0000,0x10,0x11,0x00,0x00,0x00,0x28}, /* TW: 2048x1536x16 - not in BIOS! */ - {0x6e,0x0a3b,0x6f,0x35b2,0x0000,0x08,0x0e,0x00,0x00,0x00,0x29}, /* 1280x960x8 */ - {0x6f,0x0a7d,0x6f,0x35b2,0x0000,0x08,0x0e,0x00,0x00,0x00,0x29}, /* 1280x960x16 */ - /* TW: 16:9 modes copied from 310/325 series - not in ANY BIOS */ - {0x70,0x2a1b,0x40,0x3b52,0x0000,0x08,0x12,0x00,0x00,0x07,0x2d}, /* 800x480x8 */ - {0x71,0x0a1b,0x51,0x3b63,0x0000,0x08,0x13,0x00,0x00,0x00,0x30}, /* 1024x576x8 */ - {0x74,0x0a1d,0x51,0x3b63,0x0000,0x08,0x13,0x00,0x00,0x00,0x30}, /* 1024x576x16 */ - {0x75,0x0e3d,0x62,0x3b74,0x0000,0x08,0x14,0x00,0x00,0x00,0x33}, /* 1280x720x16 */ - {0x76,0x2a1f,0x40,0x3b52,0x0000,0x08,0x12,0x00,0x00,0x07,0x2d}, /* 800x480x32 */ - {0x77,0x0a3f,0x51,0x3b63,0x0000,0x08,0x13,0x00,0x00,0x00,0x30}, /* 1024x576x32 */ - {0x78,0x0eff,0x62,0x3b74,0x0000,0x08,0x14,0x00,0x00,0x00,0x33}, /* 1280x720x32 */ - {0x79,0x0e3b,0x62,0x3b74,0x0000,0x08,0x14,0x00,0x00,0x00,0x33}, /* 1280x720x8 */ - {0x7a,0x2a1d,0x40,0x3b52,0x0000,0x08,0x12,0x00,0x00,0x07,0x2d}, /* 800x480x16 */ - /* TW: End of new 16:9 modes */ - {0x7b,0x0aff,0x6f,0x35b2,0x0000,0x08,0x0e,0x00,0x00,0x00,0x29}, /* 1280x960x32 */ - {0x20,0x0a1b,0x54,0x0000,0x0000,0x08,0x0f,0x00,0x00,0x00,0x2b}, /* 1024x600 */ - {0x21,0x0a3d,0x54,0x0000,0x0000,0x08,0x0f,0x00,0x00,0x00,0x2b}, - {0x22,0x0a7f,0x54,0x0000,0x0000,0x08,0x0f,0x00,0x00,0x00,0x2b}, - {0x23,0x0a1b,0xc5,0x0000,0x0000,0x08,0x10,0x00,0x00,0x00,0x2c}, /* 1152x768 */ - {0x24,0x0a3d,0xc5,0x431d,0x0000,0x08,0x10,0x00,0x00,0x00,0x2c}, - {0x25,0x0a7f,0xc5,0x431d,0x0000,0x08,0x10,0x00,0x00,0x00,0x2c}, - {0x29,0x0e1b,0xc5,0x0000,0x0000,0x08,0x15,0x00,0x00,0x00,0x36}, /* TW: NEW 1152x864 - not in BIOS */ - {0x2a,0x0e3d,0xc5,0x0000,0x0000,0x08,0x15,0x00,0x00,0x00,0x36}, - {0x2b,0x0e7f,0xc5,0x0000,0x0000,0x08,0x15,0x00,0x00,0x00,0x36}, - {0x39,0x2a1b,0xd6,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x38}, /* TW: NEW 848x480 - not in BIOS */ - {0x3b,0x2a3d,0xd6,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x38}, - {0x3e,0x2a7f,0xd6,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x38}, - {0x3f,0x2a1b,0xd7,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x3a}, /* TW: NEW 856x480 - not in BIOS */ - {0x42,0x2a3d,0xd7,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x3a}, - {0x45,0x2a7f,0xd7,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x3a}, - {0x48,0x223b,0xe8,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x3c}, /* TW: NEW 1360x768 - not in BIOS */ - {0x4b,0x227d,0xe8,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x3c}, - {0x4e,0x22ff,0xe8,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x3c}, - {0xff,0x0000,0x00,0x0000,0xffff,0x00,0x00,0x00,0x00,0x00,0x00} + {0x6a,0x2212,0x04,0x0102,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00}, /* 800x600x? */ + {0x2e,0x0a1b,0x03,0x0101,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08}, + {0x2f,0x021b,0x03,0x0100,SIS_RI_640x400, 0x00,0x00,0x00,0x00,0x10}, /* 640x400x8 */ + {0x30,0x2a1b,0x04,0x0103,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00}, + {0x31,0x0a1b,0x0a,0x0000,SIS_RI_720x480, 0x00,0x00,0x00,0x00,0x11}, /* 720x480x8 */ + {0x32,0x2a1b,0x0a,0x0000,SIS_RI_720x576, 0x00,0x00,0x00,0x00,0x12}, /* 720x576x8 */ + {0x33,0x0a1d,0x0a,0x0000,SIS_RI_720x480, 0x00,0x00,0x00,0x00,0x11}, /* 720x480x16 */ + {0x34,0x2a1d,0x0a,0x0000,SIS_RI_720x576, 0x00,0x00,0x00,0x00,0x12}, /* 720x576x16 */ + {0x35,0x0a1f,0x0a,0x0000,SIS_RI_720x480, 0x00,0x00,0x00,0x00,0x11}, /* 720x480x32 */ + {0x36,0x2a1f,0x0a,0x0000,SIS_RI_720x576, 0x00,0x00,0x00,0x00,0x12}, /* 720x576x32 */ + {0x37,0x0212,0x05,0x0104,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13}, /* 1024x768x? */ + {0x38,0x0a1b,0x05,0x0105,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13}, /* 1024x768x8 */ + {0x3a,0x0e3b,0x06,0x0107,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, /* 1280x1024x8 */ + {0x3c,0x063b,0x07,0x0130,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e}, + {0x3d,0x067d,0x07,0x0131,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e}, + {0x40,0x921c,0x00,0x010d,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23}, /* 320x200x15 */ + {0x41,0x921d,0x00,0x010e,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23}, /* 320x200x16 */ + {0x43,0x0a1c,0x03,0x0110,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08}, + {0x44,0x0a1d,0x03,0x0111,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08}, + {0x46,0x2a1c,0x04,0x0113,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00}, /* 800x600x15 */ + {0x47,0x2a1d,0x04,0x0114,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00}, /* 800x600x16 */ + {0x49,0x0a3c,0x05,0x0116,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13}, + {0x4a,0x0a3d,0x05,0x0117,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13}, + {0x4c,0x0e7c,0x06,0x0119,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, + {0x4d,0x0e7d,0x06,0x011a,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, + {0x50,0x921b,0x00,0x0132,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x24}, /* 320x240x8 */ + {0x51,0xb21b,0x01,0x0133,SIS_RI_400x300, 0x00,0x00,0x00,0x00,0x25}, /* 400x300x8 */ + {0x52,0x921b,0x02,0x0134,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x26}, /* 512x384x8 */ + {0x56,0x921d,0x00,0x0135,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x24}, /* 320x240x16 */ + {0x57,0xb21d,0x01,0x0136,SIS_RI_400x300, 0x00,0x00,0x00,0x00,0x25}, /* 400x300x16 */ + {0x58,0x921d,0x02,0x0137,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x26}, /* 512x384x16 */ + {0x59,0x921b,0x00,0x0138,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23}, /* 320x200x8 */ + {0x5c,0x921f,0x02,0x0000,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x26}, /* 512x384x32 */ + {0x5d,0x021d,0x03,0x0139,SIS_RI_640x400, 0x00,0x00,0x00,0x00,0x10}, /* 640x400x16 */ + {0x5e,0x021f,0x03,0x0000,SIS_RI_640x400, 0x00,0x00,0x00,0x00,0x10}, /* 640x400x32 */ + {0x62,0x0a3f,0x03,0x013a,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08}, + {0x63,0x2a3f,0x04,0x013b,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00}, /* 800x600x32 */ + {0x64,0x0a7f,0x05,0x013c,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13}, + {0x65,0x0eff,0x06,0x013d,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, + {0x66,0x06ff,0x07,0x013e,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e}, + {0x68,0x067b,0x08,0x013f,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x27}, + {0x69,0x06fd,0x08,0x0140,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x27}, + {0x6b,0x07ff,0x08,0x0000,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x27}, + {0x6c,0x067b,0x09,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x28}, /* 2048x1536x8 - not in BIOS! */ + {0x6d,0x06fd,0x09,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x28}, /* 2048x1536x16 - not in BIOS! */ + {0x70,0x2a1b,0x04,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x00,0x2d}, /* 800x480x8 */ + {0x71,0x0a1b,0x05,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x30}, /* 1024x576x8 */ + {0x74,0x0a1d,0x05,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x30}, /* 1024x576x16 */ + {0x75,0x0e3d,0x06,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x33}, /* 1280x720x16 */ + {0x76,0x2a1f,0x04,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x00,0x2d}, /* 800x480x32 */ + {0x77,0x0a3f,0x05,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x30}, /* 1024x576x32 */ + {0x78,0x0eff,0x06,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x33}, /* 1280x720x32 */ + {0x79,0x0e3b,0x06,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x33}, /* 1280x720x8 */ + {0x7a,0x2a1d,0x04,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x00,0x2d}, /* 800x480x16 */ + {0x7c,0x0a3b,0x06,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x29}, /* 1280x960x8 */ + {0x7d,0x0a7d,0x06,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x29}, /* 1280x960x16 */ + {0x7e,0x0aff,0x06,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x29}, /* 1280x960x32 */ + {0x20,0x0a1b,0x05,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x00,0x2b}, /* 1024x600 */ + {0x21,0x0a3d,0x05,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x00,0x2b}, + {0x22,0x0a7f,0x05,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x00,0x2b}, + {0x23,0x0a1b,0x0c,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x00,0x2c}, /* 1152x768 */ + {0x24,0x0a3d,0x0c,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x00,0x2c}, + {0x25,0x0a7f,0x0c,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x00,0x2c}, + {0x29,0x0e1b,0x0c,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x36}, /* 1152x864 */ + {0x2a,0x0e3d,0x0c,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x36}, + {0x2b,0x0e7f,0x0c,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x36}, + {0x39,0x2a1b,0x0d,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x38}, /* 848x480 */ + {0x3b,0x2a3d,0x0d,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x38}, + {0x3e,0x2a7f,0x0d,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x38}, + {0x3f,0x2a1b,0x0d,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x3a}, /* 856x480 */ + {0x42,0x2a3d,0x0d,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x3a}, + {0x45,0x2a7f,0x0d,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x3a}, + {0x48,0x223b,0x0e,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x3c}, /* 1360x768 */ + {0x4b,0x227d,0x0e,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x3c}, + {0x4e,0x22ff,0x0e,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x3c}, + {0x4f,0x921f,0x00,0x0000,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23}, /* 320x200x32 */ + {0x53,0x921f,0x00,0x0000,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x24}, /* 320x240x32 */ + {0x54,0xb21f,0x01,0x0000,SIS_RI_400x300, 0x00,0x00,0x00,0x00,0x25}, /* 400x300x32 */ + {0x55,0x2e3b,0x06,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x3d}, /* 1280x768 */ + {0x5a,0x2e7d,0x06,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x3d}, + {0x5b,0x2eff,0x06,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x3d}, + {0x5f,0x2a1b,0x0f,0x0000,SIS_RI_768x576, 0x00,0x00,0x00,0x00,0x3e}, /* 768x576x8 */ + {0x60,0x2a1d,0x0f,0x0000,SIS_RI_768x576, 0x00,0x00,0x00,0x00,0x3e}, /* 768x576x16 */ + {0x61,0x2a1f,0x0f,0x0000,SIS_RI_768x576, 0x00,0x00,0x00,0x00,0x3e}, /* 768x576x32 */ + {0x67,0x2e3b,0x0e,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x00,0x3f}, /* 1360x1024x8 (BARCO) */ + {0x6f,0x2e7d,0x0e,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x00,0x3f}, /* 1360x1024x16 (BARCO) */ + {0x72,0x2eff,0x0e,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x00,0x3f}, /* 1360x1024x32 (BARCO) */ + {0xff,0x0000,0x00,0xffff,0, 0x00,0x00,0x00,0x00,0x00} }; typedef struct _SiS300_Ext2Struct { USHORT Ext_InfoFlag; - UCHAR Ext_CRT1CRTC; /* TW: Index in SiS300_CRT1Table */ - UCHAR Ext_CRTVCLK; /* TW: Index in VCLK array */ - UCHAR Ext_CRT2CRTC; /* TW: Index in LCD Paneltype arrays (&3f) */ + UCHAR Ext_CRT1CRTC; /* Index in SiS300_CRT1Table */ + UCHAR Ext_CRTVCLK; /* Index in VCLK array */ + UCHAR Ext_CRT2CRTC; /* Index in LCD Paneltype arrays (&3f) */ UCHAR ModeID; USHORT XRes; USHORT YRes; - USHORT ROM_OFFSET; + UCHAR Ext_PDC; } SiS300_Ext2Struct; static const SiS300_Ext2Struct SiS300_RefIndex[] = -{ /* TW: Don't ever insert anything here, table is indexed */ - {0x085f,0x0d,0x03,0x05,0x6a, 800, 600,0x3563}, /* 00 */ - {0x0467,0x0e,0x44,0x05,0x6a, 800, 600,0x3568}, /* 01 */ - {0x0067,0x0f,0x07,0x48,0x6a, 800, 600,0x356d}, /* 02 - CRT1CRTC was 0x4f */ - {0x0067,0x10,0x06,0x8b,0x6a, 800, 600,0x3572}, /* 03 */ - {0x0147,0x11,0x08,0x00,0x6a, 800, 600,0x3577}, /* 04 */ - {0x0147,0x12,0x0c,0x00,0x6a, 800, 600,0x357c}, /* 05 */ - {0x0047,0x11,0x4e,0x00,0x6a, 800, 600,0x3581}, /* 06 - CRT1CRTC was 0x51 */ - {0x0047,0x11,0x13,0x00,0x6a, 800, 600,0x3586}, /* 07 */ - {0xc85f,0x05,0x00,0x04,0x2e, 640, 480,0x3539}, /* 08 */ - {0xc067,0x06,0x02,0x04,0x2e, 640, 480,0x353e}, /* 09 */ - {0xc067,0x07,0x02,0x47,0x2e, 640, 480,0x3543}, /* 0a */ - {0xc067,0x08,0x03,0x8a,0x2e, 640, 480,0x3548}, /* 0b */ - {0xc047,0x09,0x05,0x00,0x2e, 640, 480,0x354d}, /* 0c */ - {0xc047,0x0a,0x08,0x00,0x2e, 640, 480,0x3552}, /* 0d */ - {0xc047,0x0b,0x0a,0x00,0x2e, 640, 480,0x3557}, /* 0e */ - {0xc047,0x0c,0x10,0x00,0x2e, 640, 480,0x355c}, /* 0f */ - {0x487f,0x04,0x00,0x00,0x2f, 640, 400,0x3532}, /* 10 */ - {0xc00f,0x31,0x01,0x06,0x31, 720, 480,0x3630}, /* 11 */ - {0x000f,0x32,0x03,0x06,0x32, 720, 576,0x3637}, /* 12 */ - {0x0187,0x15,0x05,0x00,0x37,1024, 768,0x358d}, /* 13 */ - {0xc877,0x16,0x09,0x06,0x37,1024, 768,0x3592}, /* 14 */ - {0xc067,0x17,0x0b,0x49,0x37,1024, 768,0x3597}, /* 15 - CRT1CRTC was 0x97 */ - {0x0267,0x18,0x0d,0x00,0x37,1024, 768,0x359c}, /* 16 */ - {0x0047,0x19,0x11,0x8c,0x37,1024, 768,0x35a1}, /* 17 - CRT1CRTC was 0x59 */ - {0x0047,0x1a,0x52,0x00,0x37,1024, 768,0x35a6}, /* 18 */ - {0x0047,0x1b,0x16,0x00,0x37,1024, 768,0x35ab}, /* 19 - CRT1CRTC was 0x5b */ - {0x0387,0x1c,0x4d,0x00,0x3a,1280,1024,0x35be}, /* 1a - CRT1CRTC was 0x5c */ - {0x0077,0x1d,0x14,0x07,0x3a,1280,1024,0x35c3}, /* 1b */ - {0x0047,0x1e,0x17,0x00,0x3a,1280,1024,0x35c8}, /* 1c */ - {0x0007,0x1f,0x98,0x00,0x3a,1280,1024,0x35cd}, /* 1d */ - {0x0007,0x20,0x59,0x00,0x3c,1600,1200,0x35d4}, /* 1e - CRT1CRTC was 0x60 */ - {0x0007,0x21,0x5a,0x00,0x3c,1600,1200,0x35d9}, /* 1f */ - {0x0007,0x22,0x1b,0x00,0x3c,1600,1200,0x35de}, /* 20 */ - {0x0007,0x23,0x1d,0x00,0x3c,1600,1200,0x35e3}, /* 21 - CRT1CRTC was 0x63 */ - {0x0007,0x24,0x1e,0x00,0x3c,1600,1200,0x35e8}, /* 22 */ - {0x407f,0x00,0x00,0x00,0x40, 320, 200,0x3516}, /* 23 */ - {0xc07f,0x01,0x00,0x04,0x50, 320, 240,0x351d}, /* 24 */ - {0x0077,0x02,0x04,0x05,0x51, 400, 300,0x3524}, /* 25 */ - {0xc877,0x03,0x09,0x06,0x52, 512, 384,0x352b}, /* 26 */ /* was c077 */ - {0x8207,0x25,0x1f,0x00,0x68,1920,1440,0x35ef}, /* 27 */ - {0x0007,0x26,0x20,0x00,0x6c,2048,1536,0x35f6}, /* 28 */ - {0x0027,0x27,0x14,0x08,0x6e,1280, 960,0x35b7}, /* 29 - TW: 1280x960-60 */ - {0x0047,0x45,0x3c,0x08,0x6e,1280, 960,0x35b7}, /* 2a - TW: 1280x960-85 */ - {0xc077,0x33,0x09,0x06,0x20,1024, 600,0x0000}, /* 2b */ - {0xc077,0x34,0x0b,0x06,0x23,1152, 768,0x0000}, /* 2c */ /* VCLK 0x09 */ - {0x0057,0x35,0x27,0x08,0x70, 800, 480,0x3b52}, /* 2d - TW: 16:9 modes */ - {0x0047,0x36,0x37,0x08,0x70, 800, 480,0x3b57}, /* 2e */ - {0x0047,0x37,0x08,0x08,0x70, 800, 480,0x3b5c}, /* 2f */ - {0x0057,0x38,0x09,0x09,0x71,1024, 576,0x3b63}, /* 30 */ - {0x0047,0x39,0x38,0x09,0x71,1024, 576,0x3b68}, /* 31 */ - {0x0047,0x3a,0x11,0x09,0x71,1024, 576,0x3b6d}, /* 32 */ - {0x0057,0x3b,0x39,0x0a,0x75,1280, 720,0x3b74}, /* 33 */ - {0x0047,0x3c,0x3a,0x0a,0x75,1280, 720,0x3b79}, /* 34 */ - {0x0047,0x3d,0x3b,0x0a,0x75,1280, 720,0x3b7e}, /* 35 - TW: END of 16:9 modes */ - {0x0047,0x3e,0x34,0x06,0x29,1152, 864,0x0000}, /* 36 TW: 1152x864-75Hz - Non-BIOS, new */ - {0x0047,0x44,0x3a,0x06,0x29,1152, 864,0x0000}, /* 37 TW: 1152x864-85Hz - Non-BIOS, new */ - {0x00c7,0x3f,0x28,0x00,0x39, 848, 480,0x0000}, /* 38 TW: 848x480-38Hzi - Non-BIOS, new */ - {0xc047,0x40,0x3d,0x00,0x39, 848, 480,0x0000}, /* 39 TW: 848x480-60Hz - Non-BIOS, new */ - {0x00c7,0x41,0x28,0x00,0x3f, 856, 480,0x0000}, /* 3a TW: 856x480-38Hzi - Non-BIOS, new */ - {0xc047,0x42,0x28,0x00,0x3f, 856, 480,0x0000}, /* 3b TW: 856x480-60Hz - Non-BIOS, new */ - {0x0047,0x43,0x3e,0x00,0x48,1360, 768,0x0000}, /* 3c TW: 1360x768-60Hz - Non-BIOS, new */ - {0xffff,0,0,0,0,0,0,0} -}; - -/*add for 300 oem util*/ +{ + {0x085f,0x0d,0x03,0x05,0x6a, 800, 600, 0}, /* 00 */ + {0x0467,0x0e,0x44,0x05,0x6a, 800, 600, 0}, /* 01 */ + {0x0067,0x0f,0x07,0x48,0x6a, 800, 600, 0}, /* 02 - CRT1CRTC was 0x4f */ + {0x0067,0x10,0x06,0x8b,0x6a, 800, 600, 0}, /* 03 */ + {0x0147,0x11,0x08,0x00,0x6a, 800, 600, 0}, /* 04 */ + {0x0147,0x12,0x0c,0x00,0x6a, 800, 600, 0}, /* 05 */ + {0x0047,0x11,0x4e,0x00,0x6a, 800, 600, 0}, /* 06 - CRT1CRTC was 0x51 */ + {0x0047,0x11,0x13,0x00,0x6a, 800, 600, 0}, /* 07 */ + {0xc85f,0x05,0x00,0x04,0x2e, 640, 480, 0}, /* 08 */ + {0xc067,0x06,0x02,0x04,0x2e, 640, 480, 0}, /* 09 */ + {0xc067,0x07,0x02,0x47,0x2e, 640, 480, 0}, /* 0a */ + {0xc067,0x08,0x03,0x8a,0x2e, 640, 480, 0}, /* 0b */ + {0xc047,0x09,0x05,0x00,0x2e, 640, 480, 0}, /* 0c */ + {0xc047,0x0a,0x08,0x00,0x2e, 640, 480, 0}, /* 0d */ + {0xc047,0x0b,0x0a,0x00,0x2e, 640, 480, 0}, /* 0e */ + {0xc047,0x0c,0x10,0x00,0x2e, 640, 480, 0}, /* 0f */ + {0x487f,0x04,0x00,0x00,0x2f, 640, 400, 0}, /* 10 */ + {0xc04f,0x31,0x01,0x06,0x31, 720, 480, 0}, /* 11 */ + {0x004f,0x32,0x03,0x06,0x32, 720, 576, 0}, /* 12 */ + {0x0187,0x15,0x05,0x00,0x37,1024, 768, 0}, /* 13 */ + {0xc877,0x16,0x09,0x06,0x37,1024, 768, 0}, /* 14 */ + {0xc067,0x17,0x0b,0x49,0x37,1024, 768, 0}, /* 15 - CRT1CRTC was 0x97 */ + {0x0267,0x18,0x0d,0x00,0x37,1024, 768, 0}, /* 16 */ + {0x0047,0x19,0x11,0x8c,0x37,1024, 768, 0}, /* 17 - CRT1CRTC was 0x59 */ + {0x0047,0x1a,0x52,0x00,0x37,1024, 768, 0}, /* 18 */ + {0x0007,0x1b,0x16,0x00,0x37,1024, 768, 0}, /* 19 - CRT1CRTC was 0x5b */ + {0x0387,0x1c,0x4d,0x00,0x3a,1280,1024, 0}, /* 1a - CRT1CRTC was 0x5c */ + {0x0077,0x1d,0x14,0x07,0x3a,1280,1024, 0}, /* 1b */ + {0x0047,0x1e,0x17,0x00,0x3a,1280,1024, 0}, /* 1c */ + {0x0007,0x1f,0x98,0x00,0x3a,1280,1024, 0}, /* 1d */ + {0x0007,0x20,0x59,0x00,0x3c,1600,1200, 0}, /* 1e - CRT1CRTC was 0x60 */ + {0x0007,0x21,0x5a,0x00,0x3c,1600,1200, 0}, /* 1f */ + {0x0007,0x22,0x1b,0x00,0x3c,1600,1200, 0}, /* 20 */ + {0x0007,0x23,0x1d,0x00,0x3c,1600,1200, 0}, /* 21 - CRT1CRTC was 0x63 */ + {0x0007,0x24,0x1e,0x00,0x3c,1600,1200, 0}, /* 22 */ + {0x407f,0x00,0x00,0x00,0x40, 320, 200, 0}, /* 23 */ + {0xc07f,0x01,0x00,0x04,0x50, 320, 240, 0}, /* 24 */ + {0x0077,0x02,0x04,0x05,0x51, 400, 300, 0}, /* 25 */ + {0xc877,0x03,0x09,0x06,0x52, 512, 384, 0}, /* 26 */ /* was c077 */ + {0x8207,0x25,0x1f,0x00,0x68,1920,1440, 0}, /* 27 */ + {0x0007,0x26,0x20,0x00,0x6c,2048,1536, 0}, /* 28 */ + {0x0067,0x27,0x14,0x08,0x6e,1280, 960, 0}, /* 29 - TW: 1280x960-60 */ + {0x0027,0x45,0x3c,0x08,0x6e,1280, 960, 0}, /* 2a - TW: 1280x960-85 */ + {0xc077,0x33,0x09,0x06,0x20,1024, 600, 0}, /* 2b */ + {0xc077,0x34,0x0b,0x06,0x23,1152, 768, 0}, /* 2c */ /* VCLK 0x09 */ + {0x0057,0x35,0x27,0x08,0x70, 800, 480, 0}, /* 2d */ + {0x0047,0x36,0x37,0x08,0x70, 800, 480, 0}, /* 2e */ + {0x0047,0x37,0x08,0x08,0x70, 800, 480, 0}, /* 2f */ + {0x0057,0x38,0x09,0x09,0x71,1024, 576, 0}, /* 30 */ + {0x0047,0x39,0x38,0x09,0x71,1024, 576, 0}, /* 31 */ + {0x0047,0x3a,0x11,0x09,0x71,1024, 576, 0}, /* 32 */ + {0x0057,0x3b,0x39,0x0a,0x75,1280, 720, 0}, /* 33 */ + {0x0047,0x3c,0x3a,0x0a,0x75,1280, 720, 0}, /* 34 */ + {0x0007,0x3d,0x3b,0x0a,0x75,1280, 720, 0}, /* 35 */ + {0x0047,0x3e,0x34,0x06,0x29,1152, 864, 0}, /* 36 1152x864-75Hz */ + {0x0047,0x44,0x3a,0x06,0x29,1152, 864, 0}, /* 37 1152x864-85Hz */ + {0x00c7,0x3f,0x28,0x00,0x39, 848, 480, 0}, /* 38 848x480-38Hzi */ + {0xc067,0x40,0x3d,0x0b,0x39, 848, 480, 0}, /* 39 848x480-60Hz */ + {0x00c7,0x41,0x28,0x00,0x3f, 856, 480, 0}, /* 3a 856x480-38Hzi */ + {0xc047,0x42,0x28,0x00,0x3f, 856, 480, 0}, /* 3b 856x480-60Hz */ + {0x0067,0x43,0x3e,0x0c,0x48,1360, 768, 0}, /* 3c 1360x768-60Hz */ + {0x0077,0x46,0x3f,0x08,0x55,1280, 768, 0}, /* 3d 1280x768-60Hz */ + {0x004f,0x47,0x03,0x06,0x5f, 768, 576, 0}, /* 3e 768x576 */ + {0x0027,0x48,0x13,0x08,0x67,1360,1024, 0}, /* 3f 1360x1024-59Hz (BARCO1366 only) */ + {0xffff, 0, 0, 0, 0, 0, 0, 0} +}; + typedef struct _SiS_VBModeIDTableStruct { UCHAR ModeID; @@ -622,6 +294,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}, @@ -635,24 +311,30 @@ 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}, - {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00} /* TW: added! */ + {0x6c,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, + {0x6d,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d}, + {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00} }; -/*end*/ typedef struct _SiS300_CRT1TableStruct { @@ -661,15 +343,32 @@ typedef struct _SiS300_CRT1TableStruct static const SiS300_CRT1TableStruct SiS300_CRT1Table[] = { - {{0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, /* 0x00 */ - 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x00, +#if 1 + {{0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, /* 0x00 - 320x200 */ + 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x00, /* HRE [4],[15] is invalid - but correcting it does not work */ 0x00}}, - {{0x2d,0x27,0x28,0x90,0x2c,0x80,0x0b,0x3e, - 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x00, +#endif +#if 0 + {{0x2d,0x27,0x27,0x91,0x2c,0x92,0xbf,0x1f, /* 0x00 - corrected 320x200-72 - does not work */ + 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x04, + 0x00}}, +#endif + {{0x2d,0x27,0x28,0x90,0x2c,0x80,0x0b,0x3e, /* 0x01 */ + 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x00, /* HRE [4],[15] is invalid - but correcting it does not work */ 0x00}}, - {{0x3d,0x31,0x31,0x81,0x37,0x1f,0x72,0xf0, +#if 0 + {{0x2d,0x27,0x27,0x91,0x2c,0x92,0x0b,0x3e, /* 0x01 - corrected 320x240-60 - does not work */ + 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x04, + 0x00}}, +#endif + {{0x3d,0x31,0x31,0x81,0x37,0x1f,0x72,0xf0, /* 0x02 */ 0x58,0x8c,0x57,0x57,0x73,0x20,0x00,0x05, 0x01}}, +#if 0 + {{0x3d,0x31,0x31,0x81,0x37,0x1f,0x72,0xf0, /* 0x02 - corrected 400x300-60 */ + 0x58,0x8c,0x57,0x57,0x73,0x20,0x00,0x05, + 0x01}}, +#endif {{0x4f,0x3f,0x3f,0x93,0x45,0x0d,0x24,0xf5, 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x01, 0x01}}, @@ -842,15 +541,10 @@ static const SiS300_CRT1TableStruct SiS300_CRT1Table[] = {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x1e,0xf1, /* 0x33 - 1024x600 */ 0xae,0x85,0x57,0x57,0x1f,0x30,0x00,0x02, 0x01}}, -#if 0 - {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, /* 0x34 - 1152x768 */ - 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, - 0x01}}, -#endif - {{0xa3,0x8f,0x8f,0x97,0x96,0x97,0x24,0xf5, /* 0x34 - 1152x768 - TW: corrected */ + {{0xa3,0x8f,0x8f,0x97,0x96,0x97,0x24,0xf5, /* 0x34 - 1152x768 - corrected */ 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, 0x01}}, - {{0x7f,0x63,0x63,0x83,0x6c,0x1c,0x72,0xba, /* 0x35 - NEW 16:9 modes, not in BIOS ------ */ + {{0x7f,0x63,0x63,0x83,0x6c,0x1c,0x72,0xba, /* 0x35 */ 0x27,0x8b,0xdf,0xdf,0x73,0x00,0x00,0x06, 0x01}}, /* 0x35 */ {{0x7f,0x63,0x63,0x83,0x69,0x13,0x6f,0xba, @@ -865,7 +559,7 @@ static const SiS300_CRT1TableStruct SiS300_CRT1Table[] = {{0x9f,0x7f,0x7f,0x83,0x85,0x91,0x1e,0xf1, 0xad,0x81,0x3f,0x3f,0x1f,0x30,0x00,0x02, 0x01}}, /* 0x39 */ - {{0xa7,0x7f,0x7f,0x88,0x89,0x95,0x26,0xf1, /* TW: 95 was 15 - illegal HBE! */ + {{0xa7,0x7f,0x7f,0x88,0x89,0x95,0x26,0xf1, /* 95 was 15 - illegal HBE! */ 0xb1,0x85,0x3f,0x3f,0x27,0x30,0x00,0x02, 0x01}}, /* 0x3a */ {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x28,0xc4, @@ -876,36 +570,40 @@ static const SiS300_CRT1TableStruct SiS300_CRT1Table[] = 0x01}}, /* 0x3c */ {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0x2e,0xd4, 0x7d,0x81,0xcf,0xcf,0x2f,0x21,0x00,0x07, - 0x01}}, /* 0x3d */ /* TW: End of 16:9 modes --------------- */ - {{0xc3,0x8f,0x8f,0x87,0x9b,0x0b,0x82,0xef, /* TW: New, 1152x864-75 (not in any BIOS) */ + 0x01}}, /* 0x3d */ + {{0xc3,0x8f,0x8f,0x87,0x9b,0x0b,0x82,0xef, /* 1152x864-75 */ 0x60,0x83,0x5f,0x5f,0x83,0x10,0x00,0x07, 0x01}}, /* 0x3e */ - {{0x86,0x69,0x69,0x8A,0x74,0x06,0x8C,0x15, /* TW: New, 848x480-38i, not in BIOS */ + {{0x86,0x69,0x69,0x8A,0x74,0x06,0x8C,0x15, /* 848x480-38i */ 0x4F,0x83,0xEF,0xEF,0x8D,0x30,0x00,0x02, 0x00}}, /* 0x3f */ -#if 0 - {{0x81,0x69,0x69,0x85,0x70,0x00,0x0F,0x3E, /* TW: New, 848x480-60, not in BIOS - incorrect for Philips panel */ - 0xEB,0x8E,0xDF,0xDF,0x10,0x00,0x00,0x02, - 0x00}}, /* 0x40 */ -#endif - {{0x83,0x69,0x69,0x87,0x6f,0x1d,0x03,0x3E, /* TW: New, 848x480-60, not in BIOS */ + {{0x83,0x69,0x69,0x87,0x6f,0x1d,0x03,0x3E, /* 848x480-60 */ 0xE5,0x8d,0xDF,0xe4,0x04,0x00,0x00,0x06, 0x00}}, /* 0x40 */ - {{0x86,0x6A,0x6A,0x8A,0x74,0x06,0x8C,0x15, /* TW: New, 856x480-38i, not in BIOS */ + {{0x86,0x6A,0x6A,0x8A,0x74,0x06,0x8C,0x15, /* 856x480-38i */ 0x4F,0x83,0xEF,0xEF,0x8D,0x30,0x00,0x02, 0x00}}, /* 0x41 */ - {{0x81,0x6A,0x6A,0x85,0x70,0x00,0x0F,0x3E, /* TW: New, 856x480-60, not in BIOS */ + {{0x81,0x6A,0x6A,0x85,0x70,0x00,0x0F,0x3E, /* 856x480-60 */ 0xEB,0x8E,0xDF,0xDF,0x10,0x00,0x00,0x02, 0x00}}, /* 0x42 */ - {{0xdd,0xa9,0xa9,0x81,0xb4,0x97,0x26,0xfd, /* TW: New, 1360x768-60, not in BIOS */ + {{0xdd,0xa9,0xa9,0x81,0xb4,0x97,0x26,0xfd, /* 1360x768-60 */ 0x01,0x8d,0xff,0x00,0x27,0x10,0x00,0x03, 0x01}}, /* 0x43 */ - {{0xd9,0x8f,0x8f,0x9d,0xba,0x0a,0x8a,0xff, /* TW: New, 1152x864-84 (not in any BIOS) */ + {{0xd9,0x8f,0x8f,0x9d,0xba,0x0a,0x8a,0xff, /* 1152x864-84 */ 0x60,0x8b,0x5f,0x5f,0x8b,0x10,0x00,0x03, - 0x01}}, /* 0x44 */ - {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0xf1,0xff, /* TW: New, 1280x960-85 (not in any BIOS) */ + 0x01}}, /* 0x44 */ + {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0xf1,0xff, /* 1280x960-85 */ 0xc0,0x83,0xbf,0xbf,0xf2,0x10,0x00,0x07, - 0x01}} /* 0x45 */ + 0x01}}, /* 0x45 */ + {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x20,0xf5, /* 1280x768-60 */ + 0x03,0x88,0xff,0xff,0x21,0x10,0x00,0x07, + 0x01}}, /* 0x46 */ + {{0x7b,0x5f,0x63,0x9f,0x6a,0x93,0x6f,0xf0, /* 768x576 */ + 0x58,0x8a,0x3f,0x57,0x70,0x20,0x00,0x05, + 0x01}}, /* 0x47 */ + {{0xce,0xa9,0xa9,0x92,0xb1,0x07,0x28,0x52, /* 1360x1024 (Barco iQ Pro R300) */ + 0x02,0x8e,0xff,0x00,0x29,0x0d,0x00,0x03, + 0x00}} /* 0x48 */ }; typedef struct _SiS300_MCLKDataStruct @@ -914,8 +612,8 @@ typedef struct _SiS300_MCLKDataStruct USHORT CLOCK; } SiS300_MCLKDataStruct; -static const SiS300_MCLKDataStruct SiS300_MCLKData_630[] = /* 630 */ -{ /* TW: at 0x54 in BIOS */ +static const SiS300_MCLKDataStruct SiS300_MCLKData_630[] = +{ { 0x5a,0x64,0x80, 66}, { 0xb3,0x45,0x80, 83}, { 0x37,0x61,0x80,100}, @@ -926,8 +624,8 @@ static const SiS300_MCLKDataStruct SiS300_MCLKData_630[] = /* 630 */ { 0x37,0x61,0x80,100} }; -static const SiS300_MCLKDataStruct SiS300_MCLKData_300[] = /* 300 */ -{ /* TW: at 0x54 in BIOS */ +static const SiS300_MCLKDataStruct SiS300_MCLKData_300[] = +{ { 0x68,0x43,0x80,125}, { 0x68,0x43,0x80,125}, { 0x68,0x43,0x80,125}, @@ -938,24 +636,6 @@ static const SiS300_MCLKDataStruct SiS300_MCLKData_300[] = /* 300 */ { 0x37,0x61,0x80,100} }; -typedef struct _SiS300_ECLKDataStruct -{ - UCHAR SR2E,SR2F,SR30; - USHORT CLOCK; -} SiS300_ECLKDataStruct; - -static const SiS300_ECLKDataStruct SiS300_ECLKData[] = -{ - { 0x54,0x43,0x80,100}, - { 0x53,0x43,0x80,100}, - { 0x55,0x43,0x80,100}, - { 0x52,0x43,0x80,100}, - { 0x3f,0x42,0x80,100}, - { 0x54,0x43,0x80,100}, - { 0x54,0x43,0x80,100}, - { 0x54,0x43,0x80,100} -}; - typedef struct _SiS300_VCLKDataStruct { UCHAR SR2B,SR2C; @@ -965,196 +645,93 @@ typedef struct _SiS300_VCLKDataStruct static const SiS300_VCLKDataStruct SiS300_VCLKData[] = { { 0x1b,0xe1, 25}, /* 0x00 */ - { 0x4e,0xe4, 28}, + { 0x4e,0xe4, 28}, /* 0x01 */ { 0x57,0xe4, 32}, /* 0x02 */ - { 0xc3,0xc8, 36}, + { 0xc3,0xc8, 36}, /* 0x03 */ { 0x42,0xc3, 40}, /* 0x04 */ - { 0x5d,0xc4, 45}, + { 0x5d,0xc4, 45}, /* 0x05 */ { 0x52,0x65, 50}, /* 0x06 */ - { 0x53,0x65, 50}, + { 0x53,0x65, 50}, /* 0x07 */ { 0x6d,0x66, 56}, /* 0x08 */ - { 0x5a,0x64, 65}, + { 0x5a,0x64, 65}, /* 0x09 */ { 0x46,0x44, 68}, /* 0x0a */ - { 0x3e,0x43, 75}, - { 0x6d,0x46, 76}, /* 0x0c: 800x600 | LVDS_2(CH), MITAC(CH); - 730, A901(301B): 0xb1,0x46, 76 */ - { 0x41,0x43, 79}, + { 0x3e,0x43, 75}, /* 0x0b */ + { 0x6d,0x46, 76}, /* 0x0c */ /* 800x600 | LVDS_2(CH), MITAC(CH); - 730, A901(301B): 0xb1,0x46, 76 */ + { 0x41,0x43, 79}, /* 0x0d */ { 0x31,0x42, 79}, /* 0x0e */ - { 0x46,0x25, 85}, + { 0x46,0x25, 85}, /* 0x0f */ { 0x78,0x29, 87}, /* 0x10 */ - { 0x62,0x44, 95}, + { 0x62,0x44, 95}, /* 0x11 */ { 0x2b,0x22,105}, /* 0x12 */ - { 0x49,0x24,106}, + { 0x49,0x24,106}, /* 0x13 */ { 0xc3,0x28,108}, /* 0x14 */ - { 0x3c,0x23,109}, + { 0x3c,0x23,109}, /* 0x15 */ { 0xf7,0x2c,132}, /* 0x16 */ - { 0xd4,0x28,136}, + { 0xd4,0x28,136}, /* 0x17 */ { 0x41,0x05,158}, /* 0x18 */ - { 0x43,0x05,162}, + { 0x43,0x05,162}, /* 0x19 */ { 0xe1,0x0f,175}, /* 0x1a */ { 0xfc,0x12,189}, /* 0x1b */ { 0xde,0x26,194}, /* 0x1c */ - { 0x54,0x05,203}, + { 0x54,0x05,203}, /* 0x1d */ { 0x3f,0x03,230}, /* 0x1e */ - { 0x30,0x02,234}, + { 0x30,0x02,234}, /* 0x1f */ { 0x24,0x01,266}, /* 0x20 */ - { 0x52,0x2a, 54}, /* 301 TV */ - { 0x52,0x6a, 27}, /* 301 TV */ - { 0x62,0x24, 70}, /* 301 TV */ - { 0x62,0x64, 70}, /* 301 TV */ - { 0xa8,0x4c, 30}, /* 301 TV */ - { 0x20,0x26, 33}, /* 301 TV */ - { 0x31,0xc2, 39}, - { 0xbf,0xc8, 35}, /* 0x28 - 856x480 */ - { 0x60,0x36, 30}, /* 0x29 CH/UNTSC TEXT | LVDS_2(CH) - 730, A901(301B), Mitac(CH): 0xe0, 0xb6, 30 */ - { 0x40,0x4a, 28}, - { 0x9f,0x46, 44}, - { 0x97,0x2c, 26}, - { 0x44,0xe4, 25}, - { 0x7e,0x32, 47}, - { 0x8a,0x24, 31}, /* 0x2f CH/PAL TEXT | LVDS_2(CH), Mitac(CH) - 730, A901(301B): 0x57, 0xe4, 31 */ - { 0x97,0x2c, 26}, - { 0xce,0x3c, 39}, - { 0x52,0x4a, 36}, /* 0x32 CH/PAL 800x600 5/6 */ - { 0x34,0x61, 95}, - { 0x78,0x27,108}, - { 0xce,0x25,189}, /* 0x35 */ - { 0x45,0x6b, 21}, /* 0x36 */ /* TW: Added from Mitac */ - { 0x52,0xe2, 49}, /* 0x37 - added for 16:9 modes (not in any BIOS) */ - { 0x2b,0x61, 78}, /* 0x38 - added for 16:9 modes (not in any BIOS) */ - { 0x70,0x44,108}, /* 0x39 - added for 16:9 modes (not in any BIOS) */ - { 0x54,0x42,135}, /* 0x3a - added for 16:9 modes (not in any BIOS) */ - { 0x41,0x22,157}, /* 0x3b - added for 16:9 modes (not in any BIOS) */ - { 0x52,0x07,149}, /* 0x3c - added for 1280x960-85 (not in any BIOS)*/ - { 0x62,0xc6, 34}, /* 0x3d - added for 848x480-60 (not in any BIOS) */ - { 0x30,0x23, 88}, /* 0x3e - added for 1360x768-60 (not in any BIOS)*/ - { 0x3f,0x64, 46}, /* 0x3f - added for 640x480-100 (not in any BIOS)*/ - { 0x72,0x2a, 76}, /* 0x40 - test for SiS730 */ - { 0x15,0x21, 79}, /* 0x41 - test for SiS730 */ - { 0xff,0x00, 0} -}; - -#if 0 /* TW: This table is in all BIOSes, but not used */ -static const SiS300_VCLKDataStruct SiS300_VBVCLKData[] = -{ - { 0x1b,0xe1, 25}, - { 0x4e,0xe4, 28}, - { 0x57,0xe4, 31}, - { 0xc3,0xc8, 36}, - { 0x42,0x47, 40}, - { 0x5d,0xc4, 44}, - { 0x52,0x47, 49}, - { 0x53,0x47, 50}, - { 0x6d,0x66, 56}, - { 0x5a,0x64, 65}, - { 0x46,0x44, 67}, - { 0x29,0x61, 75}, - { 0x6d,0x46, 75}, - { 0x41,0x43, 78}, - { 0x31,0x42, 79}, - { 0x46,0x25, 84}, - { 0x78,0x29, 86}, /* 0x10 */ - { 0x62,0x44, 94}, - { 0x2b,0x22,104}, - { 0x49,0x24,105}, - { 0x43,0x42,108}, - { 0x3c,0x23,109}, - { 0xe0,0x46,132}, - { 0x70,0x25,135}, - { 0x41,0x22,157}, - { 0x43,0x22,162}, - { 0x30,0x21,175}, - { 0xc1,0x24,189}, - { 0xde,0x26,194}, - { 0x70,0x07,202}, - { 0x3f,0x03,229}, - { 0x30,0x02,234}, /* 0x1f */ - { 0x24,0x01,265}, /* 0x20 */ - { 0x52,0x2a, 54}, - { 0x52,0x6a, 27}, - { 0x62,0x24, 70}, - { 0x62,0x64, 70}, - { 0xa8,0x4c, 30}, - { 0x20,0x26, 33}, - { 0x31,0xc2, 39}, - { 0x2e,0x48, 25}, /* 0x28 */ - { 0x24,0x46, 25}, /* 0x29 */ - { 0x26,0x64, 28}, - { 0x37,0x64, 40}, - { 0xa1,0x42,108}, - { 0x37,0x61,100}, - { 0x78,0x27,108}, + { 0x52,0x2a, 54}, /* 0x21 */ /* 301 TV */ + { 0x52,0x6a, 27}, /* 0x22 */ /* 301 TV */ + { 0x62,0x24, 70}, /* 0x23 */ /* 301 TV */ + { 0x62,0x64, 70}, /* 0x24 */ /* 301 TV */ + { 0xa8,0x4c, 30}, /* 0x25 */ /* 301 TV */ + { 0x20,0x26, 33}, /* 0x26 */ /* 301 TV */ + { 0x31,0xc2, 39}, /* 0x27 */ + { 0xbf,0xc8, 35}, /* 0x28 */ /* 856x480 */ + { 0x60,0x36, 30}, /* 0x29 */ /* CH/UNTSC TEXT | LVDS_2(CH) - 730, A901(301B), Mitac(CH): 0xe0, 0xb6, 30 */ + { 0x40,0x4a, 28}, /* 0x2a */ /* CH-TV */ + { 0x9f,0x46, 44}, /* 0x2b */ /* CH-TV */ + { 0x97,0x2c, 26}, /* 0x2c */ /* CH-TV */ + { 0x44,0xe4, 25}, /* 0x2d */ /* CH-TV */ + { 0x7e,0x32, 47}, /* 0x2e */ /* CH-TV */ + { 0x8a,0x24, 31}, /* 0x2f */ /* CH/PAL TEXT | LVDS_2(CH), Mitac(CH) - 730, A901(301B): 0x57, 0xe4, 31 */ + { 0x97,0x2c, 26}, /* 0x30 */ /* CH-TV */ + { 0xce,0x3c, 39}, /* 0x31 */ /* CH-TV */ + { 0x52,0x4a, 36}, /* 0x32 */ /* CH/PAL 800x600 5/6 */ + { 0x34,0x61, 95}, /* 0x33 */ + { 0x78,0x27,108}, /* 0x34 */ /* Replacement for index 0x14 for 630 (?) */ + { 0xce,0x25,189}, /* 0x35 */ /* Replacement for index 0x1b for 730 (and 540?) */ + { 0x45,0x6b, 21}, /* 0x36 */ /* Chrontel SuperOverscan */ + { 0x52,0xe2, 49}, /* 0x37 */ /* 16:9 modes */ + { 0x2b,0x61, 78}, /* 0x38 */ /* 16:9 modes */ + { 0x70,0x44,108}, /* 0x39 */ /* 16:9 modes */ + { 0x54,0x42,135}, /* 0x3a */ /* 16:9 modes */ + { 0x41,0x22,157}, /* 0x3b */ /* 16:9 modes */ + { 0x52,0x07,149}, /* 0x3c */ /* 1280x960-85 */ + { 0x62,0xc6, 34}, /* 0x3d */ /* 848x480-60 */ + { 0x30,0x23, 88}, /* 0x3e */ /* 1360x768-60 */ +#if 0 + { 0x3f,0x64, 46}, /* 0x3f */ /* 640x480-100 */ +#endif + { 0x70,0x29, 81}, /* 0x3f */ /* 1280x768-60 */ + { 0x72,0x2a, 76}, /* 0x40 */ /* test for SiS730 */ + { 0x15,0x21, 79}, /* 0x41 */ /* test for SiS730 */ + { 0xa1,0x42,108}, /* 0x42 */ /* 1280x960 LCD */ + { 0x37,0x61,100}, /* 0x43 */ /* 1280x960 LCD */ + { 0xe3,0x9a,106}, /* 0x44 */ /* 1360x1024 - special for Barco iQ R300 */ + { 0xe2,0x46,135}, /* 0x45 */ /* 1280x1024-75, better clock for VGA2 */ { 0xff,0x00, 0} }; -#endif static const UCHAR SiS300_ScreenOffset[] = { 0x14,0x19,0x20,0x28,0x32,0x40,0x50, - 0x64,0x78,0x80,0x2d,0x35,0x48,0x35, /* 0x35 for 848 and 856 */ - 0x55,0xff /* 0x55 for 1360 */ -}; - -typedef struct _SiS300_StResInfoStruct -{ - USHORT HTotal; - USHORT VTotal; -} SiS300_StResInfoStruct; - -static const SiS300_StResInfoStruct SiS300_StResInfo[] = -{ - { 640,400}, - { 640,350}, - { 720,400}, - { 720,350}, - { 640,480} -}; - -typedef struct _SiS300_ModeResInfoStruct -{ - USHORT HTotal; - USHORT VTotal; - UCHAR XChar; - UCHAR YChar; -} SiS300_ModeResInfoStruct; - -static const SiS300_ModeResInfoStruct SiS300_ModeResInfo[] = -{ - { 320, 200, 8, 8}, /* 0x00 */ - { 320, 240, 8, 8}, /* 0x01 */ - { 320, 400, 8, 8}, /* 0x02 */ - { 400, 300, 8, 8}, /* 0x03 */ - { 512, 384, 8, 8}, /* 0x04 */ - { 640, 400, 8,16}, /* 0x05 */ - { 640, 480, 8,16}, /* 0x06 */ - { 800, 600, 8,16}, /* 0x07 */ - { 1024, 768, 8,16}, /* 0x08 */ - { 1280,1024, 8,16}, /* 0x09 */ - { 1600,1200, 8,16}, /* 0x0a */ - { 1920,1440, 8,16}, /* 0x0b */ - { 720, 480, 8,16}, /* 0x0c */ - { 720, 576, 8,16}, /* 0x0d */ - { 1280, 960, 8,16}, /* 0x0e */ - { 1024, 600, 8,16}, /* 0x0f */ - { 1152, 768, 8,16}, /* 0x10 */ - { 2048,1536, 8,16}, /* 0x11 - TW: Not in BIOS! */ - { 800, 480, 8,16}, /* 0x12 - TW: New, not in any BIOS */ - { 1024, 576, 8,16}, /* 0x13 - TW: New, not in any BIOS */ - { 1280, 720, 8,16}, /* 0x14 - TW: New, not in any BIOS */ - { 1152, 864, 8,16}, /* 0x15 - TW: New, not in any BIOS */ - { 848, 480, 8,16}, /* 0x16 - TW: New, not in any BIOS */ - { 856, 480, 8,16}, /* 0x17 - TW: New, not in any BIOS */ - { 1360, 768, 8,16} /* 0x18 - TW: New, not in any BIOS */ -}; - -static const UCHAR SiS300_OutputSelect = 0x40; - -static const UCHAR SiS300_SoftSetting = 0x30; + 0x64,0x78,0x80,0x2d,0x35,0x48,0x35, + 0x55,0x30,0xff +}; #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}, @@ -1184,24 +761,15 @@ static UCHAR SiS300_CRT2Data_4_10 = 0x80; static const USHORT SiS300_RGBSenseData = 0xd1; static const USHORT SiS300_VideoSenseData = 0xb3; static const USHORT SiS300_YCSenseData = 0xb9; -static const USHORT SiS300_RGBSenseData2 = 0x0190; /*301b*/ +static const USHORT SiS300_RGBSenseData2 = 0x0190; static const USHORT SiS300_VideoSenseData2 = 0x0174; static const USHORT SiS300_YCSenseData2 = 0x016b; -static const UCHAR SiS300_CR40[5][4]; +static const DRAM4Type SiS300_CR40[5]; static UCHAR SiS300_CR49[2]; #endif -static const UCHAR SiS300_NTSCPhase[] = {0x21,0xed,0xba,0x08}; /* TW: Was {0x21,0xed,0x8a,0x08}; */ -static const UCHAR SiS300_PALPhase[] = {0x2a,0x05,0xe3,0x00}; /* TW: Was {0x2a,0x05,0xd3,0x00}; */ -static const UCHAR SiS300_PALMPhase[] = {0x21,0xE4,0x2E,0x9B}; /* palmn */ -static const UCHAR SiS300_PALNPhase[] = {0x21,0xF4,0x3E,0xBA}; -static const UCHAR SiS300_NTSCPhase2[] = {0x21,0xF0,0x7B,0xD6}; /* 301b */ -static const UCHAR SiS300_PALPhase2[] = {0x2a,0x09,0x86,0xe9}; /* 301b */ -static const UCHAR SiS300_PALMPhase2[] = {0x21,0xE6,0xEF,0xA4}; /* TW: palm 301b*/ -static const UCHAR SiS300_PALNPhase2[] = {0x21,0xF6,0x94,0x46}; /* TW: paln 301b*/ - typedef struct _SiS300_PanelDelayTblStruct { UCHAR timer[2]; @@ -1209,7 +777,7 @@ typedef struct _SiS300_PanelDelayTblStruct static const SiS300_PanelDelayTblStruct SiS300_PanelDelayTbl[] = { - {{0x05,0xaa}}, /* TW: From 2.04.5a */ + {{0x05,0xaa}}, {{0x05,0x14}}, {{0x05,0x36}}, {{0x05,0x14}}, @@ -1227,6 +795,7 @@ static const SiS300_PanelDelayTblStruct SiS300_PanelDelayTbl[] = {{0x05,0x60}} }; +#if 0 static const SiS300_PanelDelayTblStruct SiS300_PanelDelayTblLVDS[] = { {{0x05,0xaa}}, @@ -1246,6 +815,11 @@ static const SiS300_PanelDelayTblStruct SiS300_PanelDelayTblLVDS[] = {{0x05,0x14}}, /* Some BIOSes: 05, 40 */ {{0x05,0x60}} }; +#endif + +/**************************************************************/ +/* SIS VIDEO BRIDGE ----------------------------------------- */ +/**************************************************************/ typedef struct _SiS300_LCDDataStruct { @@ -1356,293 +930,86 @@ static const SiS300_LCDDataStruct SiS300_NoScaleData1280x1024[] = /* TW: Fake { 1, 1,1688,1066,1688,1066} }; -static const SiS300_LCDDataStruct SiS300_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 SiS300_LCDDataStruct SiS300_ExtLCD1400x1050Data[] = /* TW: New */ -{ - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS300_LCDDataStruct SiS300_ExtLCD1600x1200Data[] = /* TW: New */ -{ - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS300_LCDDataStruct SiS300_StLCD1400x1050Data[] = /* TW: New */ -{ - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS300_LCDDataStruct SiS300_StLCD1600x1200Data[] = /* TW: New */ -{ - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS300_LCDDataStruct SiS300_NoScaleData1400x1050[] = /* TW: New */ -{ - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS300_LCDDataStruct SiS300_NoScaleData1600x1200[] = /* TW: New */ -{ - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0} -}; - - -typedef struct _SiS300_TVDataStruct -{ - USHORT RVBHCMAX; - USHORT RVBHCFACT; - USHORT VGAHT; - USHORT VGAVT; - USHORT TVHDE; - USHORT TVVDE; - USHORT RVBHRS; - UCHAR FlickerMode; - USHORT HALFRVBHRS; - UCHAR RY1COE; - UCHAR RY2COE; - UCHAR RY3COE; - UCHAR RY4COE; -} SiS300_TVDataStruct; - -static const SiS300_TVDataStruct SiS300_StPALData[] = -{ - { 1, 1, 864, 525,1270, 400, 100, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 350, 100, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, - { 1, 1, 864, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, - { 1, 1, 864, 525,1270, 480, 50, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 600, 50, 0, 0,0xf4,0xff,0x1c,0x22} -}; - -static const SiS300_TVDataStruct SiS300_ExtPALData[] = +typedef struct _SiS300_Part2PortTblStruct { - { 27, 10, 848, 448,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, - { 108, 35, 848, 398,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, - { 12, 5, 954, 448,1270, 530, 50, 0, 50,0xf1,0x04,0x1f,0x18}, - { 9, 4, 960, 463,1644, 438, 50, 0, 50,0xf4,0x0b,0x1c,0x0a}, - { 9, 4, 848, 528,1270, 530, 0, 0, 50,0xf5,0xfb,0x1b,0x2a}, - { 36, 25,1060, 648,1316, 530, 438, 0, 438,0xeb,0x05,0x25,0x16}, - { 3, 2,1080, 619,1270, 540, 438, 0, 438,0xf3,0x00,0x1d,0x20}, - { 1, 1,1170, 821,1270, 520, 686, 0, 686,0xF3,0x00,0x1D,0x20} - -}; + UCHAR CR[12]; +} SiS300_Part2PortTblStruct; -static const SiS300_TVDataStruct SiS300_StNTSCData[] = -{ - { 1, 1, 858, 525,1270, 400, 50, 0, 760,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 350, 50, 0, 640,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, - { 1, 1, 858, 525,1270, 480, 0, 0, 760,0xf1,0x04,0x1f,0x18} +static const SiS300_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_TVDataStruct SiS300_ExtNTSCData[] = -{ - { 143, 65, 858, 443,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, - { 88, 35, 858, 393,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, - { 143, 70, 924, 443,1270, 440, 92, 0, 92,0xf1,0x04,0x1f,0x18}, - { 143, 70, 924, 393,1270, 440, 92, 0, 92,0xf4,0x0b,0x1c,0x0a}, - { 143, 76, 836, 523,1270, 440, 224, 0, 0,0xf1,0x05,0x1f,0x16}, - { 143, 120,1056, 643,1270, 440, 0, 128, 0,0xf4,0x10,0x1c,0x00}, - { 143, 76, 836, 523,1270, 440, 0, 128, 0,0xee,0x0c,0x22,0x08}, - { 65, 64,1056, 791,1270, 480, 638, 0, 0,0xf1,0x04,0x1f,0x18} +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_1[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -static const SiS_TVDataStruct SiS300_St1HiTVData[] = -{ - {0x00,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 SiS_TVDataStruct SiS300_St2HiTVData[] = -{ - {0x00,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 SiS_TVDataStruct SiS300_ExtHiTVData[] = -{ - {0x00,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 UCHAR SiS300_NTSCTiming[] = +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_2[] = { - 0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c, - 0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a, - 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b, - 0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17, /* (in 2.06.50) */ -/* 0x0c,0x50,0x00,0x99,0x00,0xec,0x4a,0x17, (in 2.04.5a) */ - 0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02, /* (in 2.06.50) */ -/* 0x88,0x00,0x4b,0x00,0x00,0xe2,0x00,0x02, (in 2.04.5a) */ - 0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50, - 0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00 + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -static const UCHAR SiS300_PALTiming[] = +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1400x1050_2[] = { - 0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70, - 0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b, - 0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17, /* (in 2.06.50) */ -/* 0x70,0x50,0x00,0x97,0x00,0xd7,0x5d,0x17, (in 2.04.5a) */ - 0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02, /* (in 2.06.50) */ -/* 0x88,0x00,0x45,0x00,0x00,0xe8,0x00,0x02, (in 2.04.5a) */ - 0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63, - 0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00 + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -#ifdef oldHV -static const UCHAR SiS300_HiTVExtTiming[] = /* TW: New */ -{ - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, - 0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40, - 0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d, - 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1600x1200_2[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -static const UCHAR SiS300_HiTVSt1Timing[] = /* TW: New */ -{ - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x65,0x90,0x7b,0xa8,0x03,0xf0,0x87,0x03, - 0x11,0x15,0x11,0xcf,0x10,0x11,0xcf,0x10, - 0x35,0x35,0x3b,0x69,0x1d,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x86, - 0xaf,0x5d,0x0e,0x00,0xfc,0xff,0x2d,0x00 +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1024x768_3[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -static const UCHAR SiS300_HiTVSt2Timing[] = /* TW: New */ -{ - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, - 0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40, - 0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d, - 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_3[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -static const UCHAR SiS300_HiTVTextTiming[] = /* TW: New */ -{ - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x65,0x90,0xe7,0xbc,0x03,0x0c,0x97,0x03, - 0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20, - 0xc8,0xc8,0x3b,0xd2,0x26,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96, - 0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00 +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1400x1050_3[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -static const UCHAR SiS300_HiTVGroup3Data[] = /* TW: New */ -{ - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f, - 0x05,0x21,0xb2,0xb2,0x55,0x77,0x2a,0xa6, - 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, - 0x8c,0x6e,0x60,0x2e,0x58,0x48,0x72,0x44, - 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, - 0x4f,0x7f,0x03,0xa8,0x7d,0x20,0x1a,0xa9, - 0x14,0x05,0x03,0x7e,0x64,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 +static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1600x1200_3[] = +{ /* TW: Temporary data, invalid */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -static const UCHAR SiS300_HiTVGroup3Simu[] = /* TW: New */ -{ - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95, - 0xdb,0x20,0xb8,0xb8,0x55,0x47,0x2a,0xa6, - 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, - 0x8c,0x6e,0x60,0x15,0x26,0xd3,0xe4,0x11, - 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, - 0x67,0x36,0x01,0x47,0x0e,0x10,0xbe,0xb4, - 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 -}; - -static const UCHAR SiS300_HiTVGroup3Text[] = /* TW: New */ -{ - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7, - 0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6, - 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, - 0x8c,0x6e,0x60,0x18,0x2c,0x0c,0x20,0x22, - 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, - 0x93,0x3c,0x01,0x50,0x2f,0x10,0xf4,0xca, - 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 -}; -#endif +/**************************************************************/ +/* LVDS/Chrontel -------------------------------------------- */ +/**************************************************************/ typedef struct _SiS300_LVDSDataStruct { @@ -1652,342 +1019,14 @@ typedef struct _SiS300_LVDSDataStruct USHORT LCDVT; } SiS300_LVDSDataStruct; -static const SiS300_LVDSDataStruct SiS300_LVDS320x480Data_1[] = -{ - {848, 433,400, 525}, - {848, 389,400, 525}, - {848, 433,400, 525}, - {848, 389,400, 525}, - {848, 518,400, 525}, - {1056,628,400, 525}, - {400, 525,400, 525}, - {800, 449,1000, 644}, - {800, 525,1000, 635} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS800x600Data_1[] = -{ - {848, 433,1060, 629}, - {848, 389,1060, 629}, - {848, 433,1060, 629}, - {848, 389,1060, 629}, - {848, 518,1060, 629}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {800, 449,1000, 644}, - {800, 525,1000, 635} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS800x600Data_2[] = -{ - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {800, 449,1000, 644}, - {800, 525,1000, 635} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1024x768Data_1[] = -{ - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1024x768Data_2[] = -{ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1280x1024Data_1[] = -{ - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_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}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1400x1050Data_1[] = /* TW: New */ -{ - {928, 416, 1688, 1066}, - {928, 366, 1688, 1066}, - {928, 416, 1688, 1066}, - {928, 366, 1688, 1066}, - {928, 496, 1688, 1066}, - {1088, 616, 1688, 1066}, - {1312, 784, 1688, 1066}, - {1568, 1040, 1688, 1066}, - {1688, 1066, 1688, 1066} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1400x1050Data_2[] = /* TW: New */ -{ - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1280x768Data_1[]= /* TW: New - TODO */ -{ /* TW: Temp data, invalid (is identical to 1024x768) */ - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1280x768Data_2[]= /* TW: New - TODO */ -{ /* TW: Temp data, invalid (is identical to 1024x768) */ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -/* TW: New: */ -static const SiS300_LVDSDataStruct SiS300_LVDS1024x600Data_1[] = -{ - {840, 604,1344, 800}, - {840, 560,1344, 800}, - {840, 604,1344, 800}, - {840, 560,1344, 800}, - {840, 689,1344, 800}, - {1050, 800,1344, 800}, - {1344, 800,1344, 800}, - {800, 449,1280, 789}, - {800, 525,1280, 785} -}; - -/* TW: New: */ -static const SiS300_LVDSDataStruct SiS300_LVDS1024x600Data_2[] = -{ - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -/* TW: New: */ -static const SiS300_LVDSDataStruct SiS300_LVDS1152x768Data_1[] = -{ - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -/* TW: New: */ -static const SiS300_LVDSDataStruct SiS300_LVDS1152x768Data_2[] = -{ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -/* TW: New in 650/LVDS BIOS - 1:1 */ -static const SiS300_LVDSDataStruct SiS300_LVDSXXXxXXXData_1[] = /* TW: New */ -{ - { 800, 449, 800, 449}, - { 800, 449, 800, 449}, - { 900, 449, 900, 449}, - { 900, 449, 900, 449}, - { 800, 525, 800, 525}, - {1056, 628,1056, 628}, - {1344, 806,1344, 806}, - {1688, 806,1688, 806} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS640x480Data_1[] = -{ - {800, 449, 800, 449}, - {800, 449, 800, 449}, - {800, 449, 800, 449}, - {800, 449, 800, 449}, - {800, 525, 800, 525}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1280x960Data_1[] = /* TW: New */ -{ - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LVDS1280x960Data_2[] = /* TW: New */ -{ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LCDA1400x1050Data_1[] = /* TW: New */ -{ /* TW: Might be temporary (invalid) data */ - {928, 416, 1688, 1066}, - {928, 366, 1688, 1066}, - {1008, 416, 1688, 1066}, - {1008, 366, 1688, 1066}, - {1200, 530, 1688, 1066}, - {1088, 616, 1688, 1066}, - {1312, 784, 1688, 1066}, - {1568, 1040, 1688, 1066}, - {1688, 1066, 1688, 1066} -}; - -static const SiS300_LVDSDataStruct SiS300_LCDA1400x1050Data_2[] = /* TW: New */ -{ /* TW: Temporary data. Not valid */ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LCDA1600x1200Data_1[] = /* TW: New */ -{ /* TW: Temporary data. Not valid */ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS300_LVDSDataStruct SiS300_LCDA1600x1200Data_2[] = /* TW: New */ -{ /* TW: Temporary data. Not valid */ - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0} -}; - - -/* TW: New: */ -static const SiS300_LVDSDataStruct SiS300_CHTVUNTSCData[] = -{ - {840, 600, 840, 600}, - {840, 600, 840, 600}, - {840, 600, 840, 600}, - {840, 600, 840, 600}, - {784, 600, 784, 600}, - {1064, 750,1064, 750} -}; - -static const SiS300_LVDSDataStruct SiS300_CHTVONTSCData[] = -{ - {840, 525, 840, 525}, - {840, 525, 840, 525}, - {840, 525, 840, 525}, - {840, 525, 840, 525}, - {784, 525, 784, 525}, - {1040, 700,1040, 700} -}; - static const SiS300_LVDSDataStruct SiS300_CHTVUPALData[] = { {1008, 625,1008, 625}, {1008, 625,1008, 625}, {1008, 625,1008, 625}, {1008, 625,1008, 625}, - {840, 750, 840, 750}, - {936, 836, 936, 836} + { 840, 750, 840, 750}, + { 936, 836, 936, 836} }; static const SiS300_LVDSDataStruct SiS300_CHTVOPALData[] = @@ -1996,8 +1035,8 @@ static const SiS300_LVDSDataStruct SiS300_CHTVOPALData[] = {1008, 625,1008, 625}, {1008, 625,1008, 625}, {1008, 625,1008, 625}, - {840, 625, 840, 625}, - {960, 750, 960, 750} + { 840, 625, 840, 625}, + { 960, 750, 960, 750} }; static const SiS300_LVDSDataStruct SiS300_CHTVSOPALData[] = @@ -2006,12 +1045,10 @@ static const SiS300_LVDSDataStruct SiS300_CHTVSOPALData[] = {1008, 625,1008, 625}, {1008, 625,1008, 625}, {1008, 625,1008, 625}, - {840, 500, 840, 500}, - {944, 625, 944, 625} + { 840, 500, 840, 500}, + { 944, 625, 944, 625} }; -/* TW: new end */ - typedef struct _SiS300_LVDSDesStruct { USHORT LCDHDES; @@ -2020,57 +1057,90 @@ typedef struct _SiS300_LVDSDesStruct static const SiS300_LVDSDesStruct SiS300_PanelType00_1[] = { + { 1059, 626 }, /* 2.08 */ + { 1059, 624 }, + { 1059, 626 }, + { 1059, 624 }, + { 1059, 624 }, + { 0, 627 }, + { 0, 627 }, + { 0, 0 }, + { 0, 0 } +#if 0 {0, 626}, {0, 624}, {0, 626}, {0, 624}, {0, 624}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} + {0, 627}, + {0, 627}, + {0, 0}, + {0, 0} +#endif }; static const SiS300_LVDSDesStruct SiS300_PanelType01_1[] = { + { 0, 0 }, /* 2.08 */ + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 } +#if 0 {1343, 798}, {1343, 794}, {1343, 798}, {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} +#endif }; static const SiS300_LVDSDesStruct SiS300_PanelType02_1[] = { + { 1059, 626 }, /* 2.08 */ + { 1059, 624 }, + { 1059, 626 }, + { 1059, 624 }, + { 1059, 624 }, + { 0, 627 }, + { 0, 627 }, + { 0, 0 }, + { 0, 0 } +#if 0 {0, 626}, {0, 624}, {0, 626}, {0, 624}, {0, 624}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} + {0, 627}, + {0, 627}, + {0, 0}, + {0, 0} +#endif }; static const SiS300_LVDSDesStruct SiS300_PanelType03_1[] = { - { 8, 436}, - { 8, 440}, - { 8, 436}, - { 8, 440}, - { 8, 512}, + { 8, 436}, + { 8, 440}, + { 8, 436}, + { 8, 440}, + { 8, 512}, {1343, 798}, {1343, 794}, {1343, 798}, {1343, 794} }; -static const SiS300_LVDSDesStruct SiS300_PanelType04_1[] = +static const SiS300_LVDSDesStruct SiS300_PanelType04_1[] = /* 1280x1024 */ { {1343, 798}, {1343, 794}, @@ -2078,9 +1148,9 @@ static const SiS300_LVDSDesStruct SiS300_PanelType04_1[] = {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType05_1[] = @@ -2091,9 +1161,9 @@ static const SiS300_LVDSDesStruct SiS300_PanelType05_1[] = {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType06_1[] = @@ -2104,9 +1174,9 @@ static const SiS300_LVDSDesStruct SiS300_PanelType06_1[] = {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType07_1[] = @@ -2117,9 +1187,9 @@ static const SiS300_LVDSDesStruct SiS300_PanelType07_1[] = {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType08_1[] = @@ -2129,10 +1199,10 @@ static const SiS300_LVDSDesStruct SiS300_PanelType08_1[] = {1059, 626}, {1059, 624}, {1059, 624}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} + { 0, 627}, + { 0, 627}, + { 0, 0}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType09_1[] = @@ -2143,9 +1213,9 @@ static const SiS300_LVDSDesStruct SiS300_PanelType09_1[] = {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType0a_1[] = @@ -2155,23 +1225,23 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0a_1[] = {1059, 626}, {1059, 624}, {1059, 624}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} + { 0, 627}, + { 0, 627}, + { 0, 0}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType0b_1[] = { - {1343, 0}, - {1343, 0}, - {1343, 0}, - {1343, 0}, - {1343, 0}, /* 640x480 - BIOS 1343, 0 */ - {1343, 0}, - { 0, 799}, - { 0, 0}, - { 0, 0} + {1343, 0}, + {1343, 0}, + {1343, 0}, + {1343, 0}, + {1343, 0}, + {1343, 0}, + { 0, 799}, + { 0, 0}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType0c_1[] = @@ -2182,9 +1252,9 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0c_1[] = {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType0d_1[] = @@ -2195,9 +1265,9 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0d_1[] = {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType0e_1[] = @@ -2206,11 +1276,11 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0e_1[] = {1343, 794}, {1343, 798}, {1343, 794}, - {1343, 0}, /* 640x480 */ - {1343, 0}, /* 800x600 */ - { 0, 805}, /* 1024x768 */ - { 0, 794}, /* 1280x1024 */ - { 0, 0} /* 1280x960 - not applicable */ + {1343, 0}, /* 640x480 */ + {1343, 0}, /* 800x600 */ + { 0, 805}, /* 1024x768 */ + { 0, 794}, /* 1280x1024 */ + { 0, 0} /* 1280x960 - not applicable */ }; static const SiS300_LVDSDesStruct SiS300_PanelType0f_1[] = @@ -2221,9 +1291,9 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0f_1[] = {1343, 794}, {1343, 0}, {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType00_2[] = @@ -2233,10 +1303,10 @@ static const SiS300_LVDSDesStruct SiS300_PanelType00_2[] = {976, 527}, {976, 502}, {976, 567}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} + { 0, 627}, + { 0, 627}, + { 0, 0}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType01_2[] = @@ -2247,9 +1317,9 @@ static const SiS300_LVDSDesStruct SiS300_PanelType01_2[] = {1152, 597}, {1152, 662}, {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 805}, + { 0, 794}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType02_2[] = @@ -2259,10 +1329,10 @@ static const SiS300_LVDSDesStruct SiS300_PanelType02_2[] = {976, 527}, {976, 502}, {976, 567}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} + { 0, 627}, + { 0, 627}, + { 0, 0}, + { 0, 0} }; static const SiS300_LVDSDesStruct SiS300_PanelType03_2[] = @@ -2434,204 +1504,57 @@ static const SiS300_LVDSDesStruct SiS300_PanelType0f_2[] = { 0, 0} }; -static const SiS300_LVDSDesStruct SiS300_PanelType1076_1[] = /* TW: New */ -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS300_LVDSDesStruct SiS300_PanelType1076_2[] = /* TW: New */ -{ - { 1152, 622 }, - { 1152, 597 }, - { 1152, 622 }, - { 1152, 597 }, - { 1152, 622 }, - { 1232, 722 }, - { 0, 0 }, - { 0, 794 }, - { 0, 0 } -}; - -static const SiS300_LVDSDesStruct SiS300_PanelType1210_1[] = /* TW: New */ -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS300_LVDSDesStruct SiS300_PanelType1210_2[] = /* TW: New */ -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS300_LVDSDesStruct SiS300_PanelType1296_1[] = /* TW: New */ -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS300_LVDSDesStruct SiS300_PanelType1296_2[] = /* TW: New */ -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - - -/* TW: New */ -static const SiS300_LVDSDesStruct SiS300_CHTVUNTSCDesData[] = -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS300_LVDSDesStruct SiS300_CHTVONTSCDesData[] = -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS300_LVDSDesStruct SiS300_CHTVUPALDesData[] = -{ - {256, 0}, - {256, 0}, - {256, 0}, - {256, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS300_LVDSDesStruct SiS300_CHTVOPALDesData[] = +/* Custom data for Barco iQ R200/300/400 (BIOS 2.00.07) */ +static const SiS300_LVDSDesStruct SiS300_PanelType04_1a[] = /* 1280x1024 (1366x1024) */ { - {256, 0}, - {256, 0}, - {256, 0}, - {256, 0}, - { 0, 0}, - { 0, 0} + {1330, 798}, /* 320x200 */ + {1330, 794}, + {1330, 798}, + {1330, 794}, + {1330, 0}, /* 640x480 / 320x240 */ + {1343, 0}, /* 800x600 / 400x300 */ + { 0, 805}, /* 1024x768 / 512x384 */ + {1688,1066}, /* 1280x1024 */ + { 0, 0} /* 1360x1024 */ }; -/* TW: New end */ -/* TW: New for SiS300+301LV */ -typedef struct _SiS300_Part2PortTblStruct +static const SiS300_LVDSDesStruct SiS300_PanelType04_2a[] = { - UCHAR CR[12]; -} SiS300_Part2PortTblStruct; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1024x768_1[] = -{ /* VESA Timing */ - {{0x21,0x12,0xbf,0xe4,0xc0,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, - {{0x21,0x12,0xbf,0xe4,0xc0,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}}, - {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}}, - {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_1[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1400x1050_1[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1600x1200_1[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1024x768_2[] = -{ /* Non-VESA */ - {{0x28,0x12,0xa3,0xd0,0xaa,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x28,0x12,0xa3,0xd0,0xaa,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x28,0x13,0xe7,0x0b,0xe8,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x38,0x18,0x16,0x00,0x00,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x36,0x13,0x13,0x25,0xff,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}} + {1152, 622}, + {1152, 597}, + {1152, 622}, + {1152, 597}, + {1152, 662}, + {1232, 722}, + { 0, 805}, + {1688,1066}, + { 0, 0} }; -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_2[] = +/* Custom data for Barco iQ G200/300/400 (BIOS 2.00.07) */ +static const SiS300_LVDSDesStruct SiS300_PanelType04_1b[] = /* 1024x768 */ { - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} + {1330, 798}, /* 320x200 */ + {1330, 794}, + {1330, 798}, + {1330, 794}, + {1330, 0}, /* 640x480 / 320x240 */ + {1343, 0}, /* 800x600 / 400x300 */ + { 0, 805} /* 1024x768 / 512x384 */ }; -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1400x1050_2[] = +static const SiS300_LVDSDesStruct SiS300_PanelType04_2b[] = { - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1600x1200_2[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1024x768_3[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_3[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1400x1050_3[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} + {1152, 622}, + {1152, 597}, + {1152, 622}, + {1152, 597}, + {1152, 662}, + {1232, 722}, + { 0, 805} }; -static const SiS300_Part2PortTblStruct SiS300_CRT2Part2_1600x1200_3[] = -{ /* TW: Temporary data, invalid */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; +/* CRT1 CRTC for slave modes */ typedef struct _SiS300_LVDSCRT1DataStruct { @@ -2660,6 +1583,28 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_1[] = 0x01 }} }; +static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_1_H[] = +{ + {{0x30,0x27,0x94,0x2c,0x92,0xaf,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x04, + 0x00 }}, + {{0x30,0x27,0x94,0x2c,0x92,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x04, + 0x00 }}, + {{0x30,0x27,0x94,0x2c,0x92,0xaf,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x04, + 0x00 }}, + {{0x30,0x27,0x94,0x2c,0x92,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x04, + 0x00 }}, + {{0x30,0x27,0x94,0x2c,0x92,0x04,0x3e, + 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x04, + 0x00 }}, + {{0x3d,0x31,0x81,0x37,0x1f,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x05, + 0x01 }} +}; + static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1[] = { {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, @@ -2685,55 +1630,31 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1[] = 0x01}} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1[] = -{ - {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x54,0x9f,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, - 0x00 }}, - {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, - 0x01 }}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01 }} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_1_H[] = +static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1_H[] = { - {{0x30,0x27,0x94,0x2c,0x92,0xaf,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x04, - 0x00 }}, - {{0x30,0x27,0x94,0x2c,0x92,0x83,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x04, - 0x00 }}, - {{0x30,0x27,0x94,0x2c,0x92,0xaf,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x04, - 0x00 }}, - {{0x30,0x27,0x94,0x2c,0x92,0x83,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x04, - 0x00 }}, - {{0x30,0x27,0x94,0x2c,0x92,0x04,0x3e, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x04, + {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, 0x00 }}, - {{0x3d,0x31,0x81,0x37,0x1f,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x05, + {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, + 0x60,0x87,0x5D,0x83,0x10,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, + 0x60,0x87,0x5D,0x83,0x10,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, + 0xE2,0x89,0xdf,0x05,0x00,0x00,0x44, + 0x00}}, + {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, + 0x5A,0x8F,0x57,0x7D,0x20,0x00,0x55, + 0x01}}, + {{0x4f,0x3F,0x93,0x45,0x0D,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x01, 0x01 }} -}; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1_H[] = -{ +#if 0 {{0x37,0x27,0x9B,0x2b,0x94,0xc4,0x1f, 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, 0x00 }}, @@ -2755,6 +1676,32 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1_H[] = {{0x4f,0x3F,0x93,0x45,0x0D,0x24,0xf5, 0x02,0x88,0xFf,0x25,0x10,0x00,0x01, 0x01 }} +#endif +}; + +static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1[] = +{ + {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x54,0x9f,0x04,0x3e, + 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, + 0x00 }}, + {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, + 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, + 0x01 }}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01 }} }; static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1_H[] = @@ -2804,32 +1751,29 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2[] = +static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2_H[] = { - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, + 0xf4,0x88,0x8f,0x73,0x20,0x00,0x05, 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, + 0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05, 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, + 0xf4,0x88,0x8f,0x73,0x20,0x00,0x05, 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + {{0x3d,0x27,0x81,0x3a,0x1a,0x72,0x3e, + 0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05, 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, + {{0x3d,0x27,0x81,0x32,0x1a,0x72,0xba, + 0x1c,0x80,0xdf,0x73,0x00,0x00,0x05, 0x00 }}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01 }}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + {{0x3d,0x31,0x81,0x37,0x1f,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x05, 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2[] = +static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2[] = { {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, @@ -2854,28 +1798,6 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2[] = 0x01 }} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2_H[] = -{ - {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, - 0xf4,0x88,0x8f,0x73,0x20,0x00,0x05, - 0x00 }}, - {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, - 0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05, - 0x00 }}, - {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, - 0xf4,0x88,0x8f,0x73,0x20,0x00,0x05, - 0x00 }}, - {{0x3d,0x27,0x81,0x3a,0x1a,0x72,0x3e, - 0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05, - 0x00 }}, - {{0x3d,0x27,0x81,0x32,0x1a,0x72,0xba, - 0x1c,0x80,0xdf,0x73,0x00,0x00,0x05, - 0x00 }}, - {{0x3d,0x31,0x81,0x37,0x1f,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x05, - 0x01 }} -}; - static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2_H[] = { {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, @@ -2901,6 +1823,31 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2_H[] = 0x01 }} }; +static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2[] = +{ + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + 0x00 }}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + 0x00 }}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + 0x00 }}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + 0x00 }}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, + 0x00 }}, + {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, + 0xae,0x84,0x57,0x25,0x30,0x00,0x02, + 0x01 }}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01 }} +}; + static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2_H[] = { {{0x4f,0x27,0x93,0x39,0x81,0x24,0xbb, @@ -2926,207 +1873,6 @@ static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2_H[] = 0x01}} }; -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x600_1[] = -{ - {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, - 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, - 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, - 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, - 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0xaf,0xba, - 0x3b,0x82,0xdf,0xb0,0x00,0x00,0x01, - 0x00}}, - {{0x7e,0x63,0x82,0x68,0x15,0x1e,0xf1, - 0xae,0x85,0x57,0x1f,0x30,0x00,0x26, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x1e,0xf1, - 0xae,0x85,0x57,0x1f,0x30,0x00,0x02, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x600_1_H[] = -{ - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, - 0x00}}, - {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x600_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11024x600_2_H[] = -{ - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x01, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11152x768_1[] = -{ - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, - 0x00}}, - {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11152x768_1_H[] = -{ - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, - 0x00}}, - {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11152x768_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS300_LVDSCRT1DataStruct SiS300_LVDSCRT11152x768_2_H[] = -{ - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x01, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -/* TW: New */ static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1UNTSC[] = { {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, @@ -3236,9 +1982,7 @@ static const SiS300_LVDSCRT1DataStruct SiS300_CHTVCRT1SOPAL[] = 0x90,0x8c,0x57,0xed,0x20,0x00,0x05, 0x01 }} }; -/* TW: New end */ -/* TW: New */ typedef struct _SiS300_CHTVRegDataStruct { UCHAR Reg[16]; @@ -3288,16 +2032,14 @@ static const SiS300_CHTVRegDataStruct SiS300_CHTVReg_OPAL[] = static const SiS300_CHTVRegDataStruct SiS300_CHTVReg_SOPAL[] = { - {{0x41,0x12,0x01,0x50,0x34,0,0,0,0,0,0,0,0,0,0,0}}, /* Mode 9: 640x400 PAL 5/4 */ + {{0x41,0x12,0x01,0x50,0x34,0,0,0,0,0,0,0,0,0,0,0}}, /* Mode 9: 640x400 PAL 1/1 */ {{0x41,0x12,0x00,0x50,0x00,0,0,0,0,0,0,0,0,0,0,0}}, {{0x41,0x12,0x01,0x50,0x34,0,0,0,0,0,0,0,0,0,0,0}}, {{0x41,0x12,0x00,0x50,0x00,0,0,0,0,0,0,0,0,0,0,0}}, {{0x60,0x30,0x00,0x10,0x00,0,0,0,0,0,0,0,0,0,0,0}}, /* TW: Mode 13: 640x480 PAL 5/4 */ {{0x81,0x50,0x00,0x1b,0x00,0,0,0,0,0,0,0,0,0,0,0}} /* TW: Mode 19: 800x600 PAL 1/1 */ }; -/* TW: New end */ -/* TW: New */ static const UCHAR SiS300_CHTVVCLKUNTSC[] = {0x29,0x29,0x29,0x29,0x2a,0x2e}; static const UCHAR SiS300_CHTVVCLKONTSC[] = {0x2c,0x2c,0x2c,0x2c,0x2d,0x2b}; @@ -3309,6 +2051,5 @@ static const UCHAR SiS300_CHTVVCLKUPAL[] = {0x2f,0x2f,0x2f,0x2f,0x2f,0x31}; static const UCHAR SiS300_CHTVVCLKOPAL[] = {0x2f,0x2f,0x2f,0x2f,0x30,0x32}; static const UCHAR SiS300_CHTVVCLKSOPAL[] = {0x2f,0x2f,0x2f,0x2f,0x36,0x29}; -/* TW: New end */ diff --git a/src/310vtbl.h b/src/310vtbl.h index 5bb9d77..1dcff00 100644 --- a/src/310vtbl.h +++ b/src/310vtbl.h @@ -1,8 +1,37 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/310vtbl.h,v 1.5 2003/02/10 01:14:16 tsi Exp $ */ - - -/* Register settings for SiS 310/325 series */ - +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/310vtbl.h,v 1.20 2003/11/19 00:49:02 twini Exp $ */ +/* + * Register settings for SiS 315/330 series + * + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the linux kernel, the contents of this file + * is entirely covered by the GPL. + * + * Otherwise, the following 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. + * + * 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 <thomas@winischhofer.net> + * + * Based on code by Silicon Intergrated Systems + * + */ typedef struct _SiS310_StStruct { @@ -14,688 +43,226 @@ typedef struct _SiS310_StStruct UCHAR VB_StTVFlickerIndex; UCHAR VB_StTVEdgeIndex; UCHAR VB_StTVYFilterIndex; + UCHAR St_PDC; } SiS310_StStruct; static const SiS310_StStruct SiS310_SModeIDTable[]= { - {0x01,0x9208,0x01,0x00,0x00,0x00,0x01,0x00}, - {0x01,0x1210,0x14,0x01,0x01,0x00,0x01,0x00}, - {0x01,0x1010,0x17,0x02,0x02,0x00,0x01,0x01}, - {0x03,0x8208,0x03,0x00,0x00,0x00,0x01,0x02}, - {0x03,0x0210,0x16,0x01,0x01,0x00,0x01,0x02}, - {0x03,0x0010,0x18,0x02,0x02,0x00,0x01,0x03}, - {0x05,0x9209,0x05,0x00,0x00,0x00,0x00,0x04}, - {0x06,0x8209,0x06,0x00,0x00,0x00,0x00,0x05}, - {0x07,0x0000,0x07,0x03,0x03,0x00,0x01,0x03}, - {0x07,0x0000,0x19,0x02,0x02,0x00,0x01,0x03}, - {0x0d,0x920a,0x0d,0x00,0x00,0x00,0x00,0x04}, - {0x0e,0x820a,0x0e,0x00,0x00,0x00,0x00,0x05}, - {0x0f,0x0202,0x11,0x01,0x01,0x00,0x00,0x05}, - {0x10,0x0212,0x12,0x01,0x01,0x00,0x00,0x05}, - {0x11,0x0212,0x1a,0x04,0x04,0x00,0x00,0x05}, - {0x12,0x0212,0x1b,0x04,0x04,0x00,0x00,0x05}, - {0x13,0x021b,0x1c,0x00,0x00,0x00,0x00,0x04}, - {0x12,0x0010,0x18,0x02,0x02,0x00,0x00,0x05}, - {0x12,0x0210,0x18,0x01,0x01,0x00,0x00,0x05}, - {0xff,0x0000,0x00,0x00,0x00,0x00,0x00,0x00} -}; - -typedef struct _SiS310_StandTableStruct -{ - UCHAR CRT_COLS; - UCHAR ROWS; - UCHAR CHAR_HEIGHT; - USHORT CRT_LEN; - UCHAR SR[4]; - UCHAR MISC; - UCHAR CRTC[0x19]; - UCHAR ATTR[0x14]; - UCHAR GRC[9]; -} SiS310_StandTableStruct; - -static const SiS310_StandTableStruct SiS310_StandTable[]= -{ -/* MD_0_200 */ - { - 0x28,0x18,0x08,0x0800, - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* MD_1_200 */ - { - 0x28,0x18,0x08,0x0800, - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* MD_2_200 */ - { - 0x50,0x18,0x08,0x1000, - {0x01,0x03,0x00,0x02}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* MD_3_200 */ - { - 0x50,0x18,0x08,0x1000, - {0x01,0x03,0x00,0x02}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* MD_4 */ - { - 0x28,0x18,0x08,0x4000, - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, - 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2, - 0xff}, - {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x03,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00, - 0xff} - }, -/* MD_5 */ - { - 0x28,0x18,0x08,0x4000, - {0x09,0x03,0x00,0x02}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, - 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2, - 0xff}, - {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x03,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00, - 0xff} - }, -/* MD_6 */ - { - 0x50,0x18,0x08,0x4000, - {0x01,0x01,0x00,0x06}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2, - 0xff}, - {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17, - 0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17, - 0x01,0x00,0x01,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00, - 0xff} - }, -/* MD_7 */ - { - 0x50,0x18,0x0e,0x1000, - {0x00,0x03,0x00,0x03}, - 0xa6, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3, - 0xff}, - {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08, - 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18, - 0x0e,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00, - 0xff} - }, -/* MDA_DAC */ - { - 0x00,0x00,0x00,0x0000, - {0x00,0x00,0x00,0x15}, - 0x15, - {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, - 0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00, - 0x00}, - {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15, - 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, - 0x15,0x15,0x15,0x15}, - {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f} - }, -/* CGA_DAC */ - { - 0x00,0x10,0x04,0x0114, - {0x11,0x09,0x15,0x00}, - 0x10, - {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a, - 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a, - 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10, - 0x04}, - {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04, - 0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e, - 0x3e,0x2b,0x3b,0x2f}, - {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f, - 0x3f} - }, -/* EGA_DAC */ - { - 0x00,0x10,0x04,0x0114, - {0x11,0x05,0x15,0x20}, - 0x30, - {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18, - 0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38, - 0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12, - 0x06}, - {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26, - 0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e, - 0x1e,0x0b,0x1b,0x0f}, - {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f, - 0x3f} - }, -/* VGA_DAC */ - { - 0x00,0x10,0x04,0x0114, - {0x11,0x09,0x15,0x2a}, - 0x3a, - {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05, - 0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20, - 0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10, - 0x1f}, - {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d, - 0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15, - 0x1c,0x0e,0x11,0x15}, - {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00, - 0x04} - }, - { - 0x08,0x0c,0x10,0x0a08, - {0x0c,0x0e,0x10,0x0b}, - 0x0c, - {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00, - 0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00, - 0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00, - 0x06}, - {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08, - 0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00, - 0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00} - }, -/* MD_D */ - { - 0x28,0x18,0x08,0x2000, - {0x09,0x0f,0x00,0x06}, - 0x63, - {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, - 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} - }, -/* MD_E */ - { - 0x50,0x18,0x08,0x4000, - {0x01,0x0f,0x00,0x06}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} - }, -/* ExtVGATable */ - { - 0x00,0x00,0x00,0x0000, - {0x01,0x0f,0x00,0x0e}, - 0x23, - {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, - 0x01,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, - 0xff} - }, -/* ROM_SAVEPTR */ - { - 0x9f,0x3b,0x00,0x00c0, - {0x00,0x00,0x00,0x00}, - 0x00, - {0x00,0x00,0x00,0x00,0x00,0x00,0xbb,0x3f, - 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x1a,0x00,0xac,0x3e,0x00,0xc0, - 0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00} - }, -/* MD_F */ - { - 0x50,0x18,0x0e,0x8000, - {0x01,0x0f,0x00,0x06}, - 0xa2, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3, - 0xff}, - {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00, - 0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00, - 0x0b,0x00,0x05,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05, - 0xff} - }, -/* MD_10 */ - { - 0x50,0x18,0x0e,0x8000, - {0x01,0x0f,0x00,0x06}, - 0xa3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} - }, -/* MD_0_350 */ - { - 0x28,0x18,0x0e,0x0800, - {0x09,0x03,0x00,0x02}, - 0xa3, - {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* MD_1_350 */ - { - 0x28,0x18,0x0e,0x0800, - {0x09,0x03,0x00,0x02}, - 0xa3, - {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* MD_2_350 */ - { - 0x50,0x18,0x0e,0x1000, - {0x01,0x03,0x00,0x02}, - 0xa3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* MD_3_350 */ - { - 0x50,0x18,0x0e,0x1000, - {0x01,0x03,0x00,0x02}, - 0xa3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, - 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x08,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* MD_0_1_400 */ - { - 0x28,0x18,0x10,0x0800, - {0x08,0x03,0x00,0x02}, - 0x67, - {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f, - 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x0c,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* MD_2_3_400 */ - { - 0x50,0x18,0x10,0x1000, - {0x00,0x03,0x00,0x02}, - 0x67, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x0c,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, - 0xff} - }, -/* MD_7_400 */ - { - 0x50,0x18,0x10,0x1000, - {0x00,0x03,0x00,0x02}, - 0x66, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08, - 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18, - 0x0e,0x00,0x0f,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00, - 0xff} - }, -/* MD_11 */ - { - 0x50,0x1d,0x10,0xa000, - {0x01,0x0f,0x00,0x06}, - 0xe3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xc3, - 0xff}, - {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01, - 0xff} - }, -/* ExtEGATable */ - { - 0x50,0x1d,0x10,0xa000, - {0x01,0x0f,0x00,0x06}, - 0xe3, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, - 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, - 0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xe3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, - 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x01,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, - 0xff} - }, -/* MD_13 */ - { - 0x28,0x18,0x08,0x2000, - {0x01,0x0f,0x00,0x0e}, - 0x63, - {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, - 0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00, - 0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3, - 0xff}, - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, - 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, - 0x41,0x00,0x0f,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, - 0xff} - } + {0x01,0x9208,0x01,0x00,0x00,0x00,0x01,0x00, 0x40}, + {0x01,0x1210,0x14,0x01,0x01,0x00,0x01,0x00, 0x40}, + {0x01,0x1010,0x17,0x02,0x02,0x00,0x01,0x01, 0x40}, + {0x03,0x8208,0x03,0x00,0x00,0x00,0x01,0x02, 0x40}, + {0x03,0x0210,0x16,0x01,0x01,0x00,0x01,0x02, 0x40}, + {0x03,0x0010,0x18,0x02,0x02,0x00,0x01,0x03, 0x40}, + {0x05,0x9209,0x05,0x00,0x00,0x00,0x00,0x04, 0x40}, + {0x06,0x8209,0x06,0x00,0x00,0x00,0x00,0x05, 0x40}, + {0x07,0x0000,0x07,0x03,0x03,0x00,0x01,0x03, 0x40}, + {0x07,0x0000,0x19,0x02,0x02,0x00,0x01,0x03, 0x40}, + {0x0d,0x920a,0x0d,0x00,0x00,0x00,0x00,0x04, 0x40}, + {0x0e,0x820a,0x0e,0x00,0x00,0x00,0x00,0x05, 0x40}, + {0x0f,0x0202,0x11,0x01,0x01,0x00,0x00,0x05, 0x40}, + {0x10,0x0212,0x12,0x01,0x01,0x00,0x00,0x05, 0x40}, + {0x11,0x0212,0x1a,0x04,0x04,0x00,0x00,0x05, 0x40}, + {0x12,0x0212,0x1b,0x04,0x04,0x00,0x00,0x05, 0x40}, + {0x13,0x021b,0x1c,0x00,0x00,0x00,0x00,0x04, 0x40}, + {0x12,0x0010,0x18,0x02,0x02,0x00,0x00,0x05, 0x40}, + {0x12,0x0210,0x18,0x01,0x01,0x00,0x00,0x05, 0x40}, + {0xff,0x0000,0x00,0x00,0x00,0x00,0x00,0x00, 0x40} }; typedef struct _SiS310_ExtStruct { - UCHAR Ext_ModeID; + UCHAR Ext_ModeID; USHORT Ext_ModeFlag; - USHORT Ext_ModeInfo; - USHORT Ext_Point; /* TW: Address of table entry in (older) BIOS image */ + UCHAR Ext_ModeOffset; USHORT Ext_VESAID; - UCHAR Ext_VESAMEMSize; - UCHAR Ext_RESINFO; - UCHAR VB_ExtTVFlickerIndex; - UCHAR VB_ExtTVEdgeIndex; - UCHAR VB_ExtTVYFilterIndex; - UCHAR REFindex; + UCHAR Ext_RESINFO; + UCHAR VB_ExtTVFlickerIndex; + UCHAR VB_ExtTVEdgeIndex; + UCHAR VB_ExtTVYFilterIndex; + UCHAR VB_ExtTVYFilterIndexROM661; + UCHAR REFindex; } SiS310_ExtStruct; -/* TW: Checked with 650/LVDS and 650/301LVx 1.10.6s */ static const SiS310_ExtStruct SiS310_EModeIDTable[]= { - {0x6a,0x2212,0x0407,0x3a81,0x0102,0x08,0x07,0x00,0x00,0x07,0x00}, /* 800x600x? */ - {0x2e,0x0a1b,0x0306,0x3a57,0x0101,0x08,0x06,0x00,0x00,0x05,0x08}, /* 640x480x8 */ -/* {0x2e,0x021b,0x0306,0x3a57,0x0101,0x08,0x06,0x00,0x00,0x05,0x08}, */ /* 640x480x8 - 650/LVDS BIOS (no CRt2Mode) */ - {0x2f,0x0a1b,0x0305,0x3a50,0x0100,0x08,0x05,0x00,0x00,0x05,0x10}, /* 640x400x8 */ -/* {0x2f,0x021b,0x0305,0x3a50,0x0100,0x08,0x05,0x00,0x00,0x05,0x10}, */ /* 640x400x8 - 650/LVDS BIOS (no CRt2Mode) */ - {0x30,0x2a1b,0x0407,0x3a81,0x0103,0x08,0x07,0x00,0x00,0x07,0x00}, /* 800x600x8 */ -/* {0x30,0x221b,0x0407,0x3a81,0x0103,0x08,0x07,0x00,0x00,0x07,0x00}, */ /* 800x600x8 - 650/LVDS BIOS (no CRt2Mode) */ -/* {0x31,0x0a1b,0x030d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x11}, */ /* 720x480x8 */ - {0x31,0x0a1b,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x11}, /* 720x480x8 BIOS (301/LVDS) */ - {0x32,0x0a1b,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x12}, /* 720x576x8 */ - {0x33,0x0a1d,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x11}, /* 720x480x16 */ - {0x34,0x2a1d,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x12}, /* 720x576x16 */ - {0x35,0x0a1f,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x11}, /* 720x480x32 */ - {0x36,0x2a1f,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x12}, /* 720x576x32 */ - {0x37,0x0212,0x0508,0x3aab,0x0104,0x08,0x08,0x00,0x00,0x08,0x13}, /* 1024x768x? */ - {0x38,0x0a1b,0x0508,0x3aab,0x0105,0x08,0x08,0x00,0x00,0x08,0x13}, /* 1024x768x8 */ -/* {0x38,0x021b,0x0508,0x3aab,0x0105,0x08,0x08,0x00,0x00,0x00,0x13}, */ /* 1024x768x8 - 650/LVDS BIOS (no CRt2Mode) */ - {0x3a,0x0e3b,0x0609,0x3adc,0x0107,0x08,0x09,0x00,0x00,0x00,0x1a}, /* 1280x1024x8 */ -/* {0x3a,0x063b,0x0609,0x3adc,0x0107,0x08,0x09,0x00,0x00,0x00,0x1a}, */ /* 1280x1024x8 - 650/LVDS BIOS*/ - {0x3c,0x0e3b,0x070a,0x3af2,0x0130,0x08,0x0a,0x00,0x00,0x00,0x1e}, /* 1600x1200x8 */ -/* {0x3c,0x063b,0x070a,0x3af2,0x0130,0x08,0x0a,0x00,0x00,0x00,0x1e}, */ /* 1600x1200x8 - 650/LVDS BIOS */ - {0x3d,0x067d,0x070a,0x3af2,0x0131,0x08,0x0a,0x00,0x00,0x00,0x1e}, /* 1600x1200x16 - 650/301LVx - no CRT2Mode? */ - {0x40,0x9a1c,0x0000,0x3a34,0x010d,0x08,0x00,0x00,0x00,0x04,0x25}, - {0x41,0x9a1d,0x0000,0x3a34,0x010e,0x08,0x00,0x00,0x00,0x04,0x25}, - {0x43,0x0a1c,0x0306,0x3a57,0x0110,0x08,0x06,0x00,0x00,0x05,0x08}, - {0x44,0x0a1d,0x0306,0x3a57,0x0111,0x08,0x06,0x00,0x00,0x05,0x08}, /* 640x480x16 */ - {0x46,0x2a1c,0x0407,0x3a81,0x0113,0x08,0x07,0x00,0x00,0x07,0x00}, - {0x47,0x2a1d,0x0407,0x3a81,0x0114,0x08,0x07,0x00,0x00,0x07,0x00}, /* 800x600x16 */ - {0x49,0x0a3c,0x0508,0x3aab,0x0116,0x08,0x08,0x00,0x00,0x00,0x13}, - {0x4a,0x0a3d,0x0508,0x3aab,0x0117,0x08,0x08,0x00,0x00,0x08,0x13}, /* 1024x768x16 */ - {0x4c,0x0e7c,0x0609,0x3adc,0x0119,0x08,0x09,0x00,0x00,0x00,0x1a}, - {0x4d,0x0e7d,0x0609,0x3adc,0x011a,0x08,0x09,0x00,0x00,0x00,0x1a}, /* 1280x1024x16 */ - {0x50,0x9a1b,0x0001,0x3a3b,0x0132,0x08,0x01,0x00,0x00,0x04,0x26}, -/* {0x50,0x921b,0x0001,0x3a3b,0x0132,0x08,0x01,0x00,0x00,0x04,0x26}, */ /* 650/LVDS BIOS */ - {0x51,0xba1b,0x0103,0x3a42,0x0133,0x08,0x03,0x00,0x00,0x07,0x27}, -/* {0x52,0x9a1b,0x0204,0x3a49,0x0134,0x08,0x04,0x00,0x00,0x00,0x28}, */ - {0x52,0xba1b,0x0204,0x3a49,0x0134,0x08,0x04,0x00,0x00,0x00,0x28}, /* 650/301 BIOS */ -/* {0x52,0xb21b,0x0204,0x3a49,0x0134,0x08,0x04,0x00,0x00,0x00,0x28}, */ /* 650/LVDS BIOS (no CRT2Mode) */ - {0x56,0x9a1d,0x0001,0x3a3b,0x0135,0x08,0x01,0x00,0x00,0x04,0x26}, - {0x57,0xba1d,0x0103,0x3a42,0x0136,0x08,0x03,0x00,0x00,0x07,0x27}, -/* {0x58,0x9a1d,0x0204,0x3a49,0x0137,0x08,0x04,0x00,0x00,0x00,0x28}, */ - {0x58,0xba1d,0x0204,0x3a49,0x0137,0x08,0x04,0x00,0x00,0x00,0x28}, /* BIOS (301+LVDS) */ - {0x59,0x9a1b,0x0000,0x3a34,0x0138,0x08,0x00,0x00,0x00,0x04,0x25}, -/* {0x59,0x921b,0x0000,0x3a34,0x0138,0x08,0x00,0x00,0x00,0x04,0x25}, */ /* 650/LVDS BIOS (no CRT2Mode) */ - {0x5A,0x021b,0x0014,0x3b83,0x0138,0x08,0x01,0x00,0x00,0x04,0x3f}, /* 320x480x8 fstn add new mode*/ - {0x5B,0x0a1d,0x0014,0x3b83,0x0135,0x08,0x01,0x00,0x00,0x04,0x3f}, /* 320x480x16 fstn add new mode*/ - {0x5c,0xba1f,0x0204,0x3a49,0x0000,0x08,0x04,0x00,0x00,0x00,0x28}, /* TW: inserted 512x384x32 */ - {0x5d,0x0a1d,0x0305,0x3a50,0x0139,0x08,0x05,0x00,0x00,0x07,0x10}, - {0x5e,0x0a1f,0x0305,0x3a50,0x0000,0x08,0x05,0x00,0x00,0x07,0x10}, /* TW: Inserted 640x400x32 */ - {0x62,0x0a3f,0x0306,0x3a57,0x013a,0x08,0x06,0x00,0x00,0x05,0x08}, /* 640x480x32 */ - {0x63,0x2a3f,0x0407,0x3a81,0x013b,0x08,0x07,0x00,0x00,0x07,0x00}, /* 800x600x32 */ - {0x64,0x0a7f,0x0508,0x3aab,0x013c,0x08,0x08,0x00,0x00,0x08,0x13}, /* 1024x768x32 */ - {0x65,0x0eff,0x0609,0x3adc,0x013d,0x08,0x09,0x00,0x00,0x00,0x1a}, /* 1280x1024x32 */ - {0x66,0x06ff,0x070a,0x3af2,0x013e,0x08,0x0a,0x00,0x00,0x00,0x1e}, /* 1600x1200x32 */ - {0x68,0x067b,0x080b,0x3b17,0x013f,0x08,0x0b,0x00,0x00,0x00,0x29}, /* 1920x1440x8 */ - {0x69,0x06fd,0x080b,0x3b17,0x0140,0x08,0x0b,0x00,0x00,0x00,0x29}, /* 1920x1440x16 */ - {0x6b,0x07ff,0x080b,0x3b17,0x0141,0x10,0x0b,0x00,0x00,0x00,0x29}, /* 1920x1440x32 */ - {0x6c,0x067b,0x090c,0x3b37,0x0000,0x08,0x0c,0x00,0x00,0x00,0x2f}, /* 2048x1536x8 */ - {0x6d,0x06fd,0x090c,0x3b37,0x0000,0x10,0x0c,0x00,0x00,0x00,0x2f}, /* 2048x1536x16 */ - {0x6e,0x07ff,0x090c,0x3b37,0x0000,0x10,0x0c,0x00,0x00,0x00,0x2f}, /* 2048x1536x32 */ - {0x70,0x2a1b,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34}, /* 800x480x8 */ - {0x71,0x0a1b,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37}, /* 1024x576x8 */ - {0x74,0x0a1d,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37}, /* 1024x576x16 */ - {0x75,0x0a3d,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a}, /* 1280x720x16 */ - {0x76,0x2a1f,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34}, /* 800x480x32 */ - {0x77,0x0a1f,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37}, /* 1024x576x32 */ - {0x78,0x0a3f,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a}, /* 1280x720x32 */ - {0x79,0x0a3b,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a}, /* 1280x720x8 */ - {0x7a,0x2a1d,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34}, /* 800x480x16 */ - {0x7c,0x0e3b,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x3d}, /* 1280x960x8 - TW */ - {0x7d,0x0e7d,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x3d}, /* 1280x960x16 - TW */ - {0x7e,0x0eff,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x3d}, /* 1280x960x32 - TW */ - /* TW: 650/LVDS BIOS new modes */ -/* {0x23,0x063b,0x0614,0x36f7,0x0000,0x08,0x14,0x00,0x00,0x00,0x40}, */ /* 1280x768x8 - 650/LVDS BIOS */ - {0x23,0x0e3b,0x0614,0x36f7,0x0000,0x08,0x14,0x00,0x00,0x00,0x40}, /* 1280x768x8 */ - {0x24,0x0e7d,0x0614,0x36f7,0x0000,0x08,0x14,0x00,0x00,0x00,0x40}, /* 1280x768x16 */ - {0x25,0x0eff,0x0614,0x36f7,0x0000,0x08,0x14,0x00,0x00,0x00,0x40}, /* 1280x768x32 */ - {0x26,0x0e3b,0x0c15,0x36fe,0x0000,0x08,0x15,0x00,0x00,0x00,0x41}, /* 1400x1050x8 */ -/* {0x26,0x063b,0x0c15,0x36fe,0x0000,0x08,0x15,0x00,0x00,0x00,0x41}, */ /* 1400x1050x8 - 650/LVDS BIOS */ - {0x27,0x0e7d,0x0c15,0x36fe,0x0000,0x08,0x15,0x00,0x00,0x00,0x41}, /* 1400x1050x16 */ - {0x28,0x0eff,0x0c15,0x36fe,0x0000,0x08,0x15,0x00,0x00,0x00,0x41}, /* 1400x1050x32*/ - {0x29,0x0e1b,0x0d16,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x43}, /* TW: NEW 1152x864 - not in BIOS */ - {0x2a,0x0e3d,0x0d16,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x43}, - {0x2b,0x0e7f,0x0d16,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x43}, - {0x39,0x2a1b,0x0b17,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x45}, /* TW: NEW 848x480 - not in BIOS */ - {0x3b,0x2a3d,0x0b17,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x45}, - {0x3e,0x2a7f,0x0b17,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x45}, - {0x3f,0x2a1b,0x0b13,0x0000,0x0000,0x08,0x13,0x00,0x00,0x00,0x47}, /* TW: NEW 856x480 - not in BIOS */ - {0x42,0x2a3d,0x0b13,0x0000,0x0000,0x08,0x13,0x00,0x00,0x00,0x47}, - {0x45,0x2a7f,0x0b13,0x0000,0x0000,0x08,0x13,0x00,0x00,0x00,0x47}, - {0x48,0x2a1b,0x0e18,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x49}, /* TW: NEW 1360x768 - not in BIOS */ - {0x4b,0x2a3d,0x0e18,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x49}, - {0x4e,0x2a7f,0x0e18,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x49}, - {0xff,0x0000,0x0000,0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00} + {0x6a,0x2212,0x04,0x0102,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00}, /* 800x600x? */ + {0x2e,0x0a1b,0x03,0x0101,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08}, /* 640x480x8 */ + {0x2f,0x0a1b,0x03,0x0100,SIS_RI_640x400, 0x00,0x00,0x05,0x05,0x10}, /* 640x400x8 */ + {0x30,0x2a1b,0x04,0x0103,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00}, /* 800x600x8 */ + {0x31,0x0a1b,0x0a,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x06,0x11}, /* 720x480x8 */ + {0x32,0x0a1b,0x0a,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x06,0x12}, /* 720x576x8 */ + {0x33,0x0a1d,0x0a,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x06,0x11}, /* 720x480x16 */ + {0x34,0x2a1d,0x0a,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x06,0x12}, /* 720x576x16 */ + {0x35,0x0a1f,0x0a,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x06,0x11}, /* 720x480x32 */ + {0x36,0x2a1f,0x0a,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x06,0x12}, /* 720x576x32 */ + {0x37,0x0212,0x05,0x0104,SIS_RI_1024x768, 0x00,0x00,0x08,0x07,0x13}, /* 1024x768x? */ + {0x38,0x0a1b,0x05,0x0105,SIS_RI_1024x768, 0x00,0x00,0x08,0x07,0x13}, /* 1024x768x8 */ + {0x3a,0x0e3b,0x06,0x0107,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, /* 1280x1024x8 */ + {0x3c,0x0e3b,0x07,0x0130,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e}, /* 1600x1200x8 */ + {0x3d,0x0e7d,0x07,0x0131,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e}, /* 1600x1200x16 */ + {0x40,0x9a1c,0x00,0x010d,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25}, /* 320x200x15 */ + {0x41,0x9a1d,0x00,0x010e,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25}, /* 320x200x16 */ + {0x43,0x0a1c,0x03,0x0110,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08}, + {0x44,0x0a1d,0x03,0x0111,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08}, /* 640x480x16 */ + {0x46,0x2a1c,0x04,0x0113,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00}, + {0x47,0x2a1d,0x04,0x0114,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00}, /* 800x600x16 */ + {0x49,0x0a3c,0x05,0x0116,SIS_RI_1024x768, 0x00,0x00,0x00,0x07,0x13}, + {0x4a,0x0a3d,0x05,0x0117,SIS_RI_1024x768, 0x00,0x00,0x08,0x07,0x13}, /* 1024x768x16 */ + {0x4c,0x0e7c,0x06,0x0119,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, + {0x4d,0x0e7d,0x06,0x011a,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, /* 1280x1024x16 */ + {0x50,0x9a1b,0x00,0x0132,SIS_RI_320x240, 0x00,0x00,0x04,0x04,0x26}, /* 320x240x8 */ + {0x51,0xba1b,0x01,0x0133,SIS_RI_400x300, 0x00,0x00,0x07,0x07,0x27}, /* 400x300x8 */ + {0x52,0xba1b,0x02,0x0134,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28}, /* 512x384x8 */ + {0x56,0x9a1d,0x00,0x0135,SIS_RI_320x240, 0x00,0x00,0x04,0x04,0x26}, /* 320x240x16 */ + {0x57,0xba1d,0x01,0x0136,SIS_RI_400x300, 0x00,0x00,0x07,0x07,0x27}, /* 400x300x16 */ + {0x58,0xba1d,0x02,0x0137,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28}, /* 512x384x16 */ + {0x59,0x9a1b,0x00,0x0138,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25}, /* 320x200x8 */ + {0x5a,0x021b,0x00,0x0138,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x3f}, /* 320x240x8 fstn */ + {0x5b,0x0a1d,0x00,0x0135,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x3f}, /* 320x240x16 fstn */ + {0x5c,0xba1f,0x02,0x0000,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28}, /* 512x384x32 */ + {0x5d,0x0a1d,0x03,0x0139,SIS_RI_640x400, 0x00,0x00,0x05,0x07,0x10}, + {0x5e,0x0a1f,0x03,0x0000,SIS_RI_640x400, 0x00,0x00,0x05,0x07,0x10}, /* 640x400x32 */ + {0x62,0x0a3f,0x03,0x013a,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08}, /* 640x480x32 */ + {0x63,0x2a3f,0x04,0x013b,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00}, /* 800x600x32 */ + {0x64,0x0a7f,0x05,0x013c,SIS_RI_1024x768, 0x00,0x00,0x08,0x07,0x13}, /* 1024x768x32 */ + {0x65,0x0eff,0x06,0x013d,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a}, /* 1280x1024x32 */ + {0x66,0x0eff,0x07,0x013e,SIS_RI_1600x1200,0x00,0x00,0x00,0x00,0x1e}, /* 1600x1200x32 */ + {0x68,0x067b,0x08,0x013f,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x29}, /* 1920x1440x8 */ + {0x69,0x06fd,0x08,0x0140,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x29}, /* 1920x1440x16 */ + {0x6b,0x07ff,0x08,0x0141,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x29}, /* 1920x1440x32 */ + {0x6c,0x067b,0x09,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x2f}, /* 2048x1536x8 */ + {0x6d,0x06fd,0x09,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x2f}, /* 2048x1536x16 */ + {0x6e,0x07ff,0x09,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x2f}, /* 2048x1536x32 */ + {0x70,0x2a1b,0x04,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x07,0x34}, /* 800x480x8 */ + {0x71,0x0a1b,0x05,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x37}, /* 1024x576x8 */ + {0x74,0x0a1d,0x05,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x37}, /* 1024x576x16 */ + {0x75,0x0a3d,0x06,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x3a}, /* 1280x720x16 */ + {0x76,0x2a1f,0x04,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x07,0x34}, /* 800x480x32 */ + {0x77,0x0a1f,0x05,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x37}, /* 1024x576x32 */ + {0x78,0x0a3f,0x06,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x3a}, /* 1280x720x32 */ + {0x79,0x0a3b,0x06,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x00,0x3a}, /* 1280x720x8 */ + {0x7a,0x2a1d,0x04,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x07,0x34}, /* 800x480x16 */ + {0x7c,0x0e3b,0x06,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x3d}, /* 1280x960x8 */ + {0x7d,0x0e7d,0x06,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x3d}, /* 1280x960x16 */ + {0x7e,0x0eff,0x06,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x00,0x3d}, /* 1280x960x32 */ + {0x23,0x0e3b,0x06,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x40}, /* 1280x768x8 */ + {0x24,0x0e7d,0x06,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x40}, /* 1280x768x16 */ + {0x25,0x0eff,0x06,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x40}, /* 1280x768x32 */ + {0x26,0x0e3b,0x0c,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x41}, /* 1400x1050x8 */ + {0x27,0x0e7d,0x0c,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x41}, /* 1400x1050x16 */ + {0x28,0x0eff,0x0c,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x41}, /* 1400x1050x32*/ + {0x29,0x0e1b,0x0d,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x43}, /* 1152x864 */ + {0x2a,0x0e3d,0x0d,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x43}, + {0x2b,0x0e7f,0x0d,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x43}, + {0x39,0x2a1b,0x0b,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x45}, /* 848x480 */ + {0x3b,0x2a3d,0x0b,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x45}, + {0x3e,0x2a7f,0x0b,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x45}, + {0x3f,0x2a1b,0x0b,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x47}, /* 856x480 */ + {0x42,0x2a3d,0x0b,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x47}, + {0x45,0x2a7f,0x0b,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x47}, + {0x48,0x2a1b,0x0e,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x49}, /* 1360x768 */ + {0x4b,0x2a3d,0x0e,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x49}, + {0x4e,0x2a7f,0x0e,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x49}, + {0x4f,0x9a1f,0x00,0x0000,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25}, /* 320x200x32 */ + {0x53,0x9a1f,0x00,0x0000,SIS_RI_320x240, 0x00,0x00,0x04,0x04,0x26}, /* 320x240x32 */ + {0x54,0xba1f,0x01,0x0000,SIS_RI_400x300, 0x00,0x00,0x07,0x07,0x27}, /* 400x300x32 */ + {0x5f,0x2a1b,0x0f,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4a}, /* 768x576x8 */ + {0x60,0x2a1d,0x0f,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4a}, /* 768x576x16 */ + {0x61,0x2a1f,0x0f,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4a}, /* 768x576x32 */ + {0xff,0x0000,0x00,0x0000,0, 0x00,0x00,0x00,0x00,0x00} }; typedef struct _SiS310_Ext2Struct { USHORT Ext_InfoFlag; - UCHAR Ext_CRT1CRTC; - UCHAR Ext_CRTVCLK; - UCHAR Ext_CRT2CRTC; + UCHAR Ext_CRT1CRTC; + UCHAR Ext_CRTVCLK; + UCHAR Ext_CRT2CRTC; UCHAR ModeID; USHORT XRes; USHORT YRes; - USHORT ROM_OFFSET; + UCHAR Ext_PDC; } SiS310_Ext2Struct; static const SiS310_Ext2Struct SiS310_RefIndex[]= { -/* {0x005f,0x0d,0x03,0x05,0x6a, 800, 600,0x3a81}, 0x0 - TW: Patch for Chrontel 7019 */ - {0x085f,0x0d,0x03,0x05,0x6a, 800, 600,0x3a81}, /* 0x0 */ - {0x0467,0x0e,0x04,0x05,0x6a, 800, 600,0x3a86}, /* 0x1 */ - {0x0067,0x0f,0x08,0x48,0x6a, 800, 600,0x3a8b}, /* 0x2 */ - {0x0067,0x10,0x07,0x8b,0x6a, 800, 600,0x3a90}, /* 0x3 */ - {0x0147,0x11,0x0a,0x00,0x6a, 800, 600,0x3a95}, /* 0x4 */ - {0x0147,0x12,0x0d,0x00,0x6a, 800, 600,0x3a9a}, /* 0x5 - 4147 TW: Test sync change */ - {0x0047,0x13,0x13,0x00,0x6a, 800, 600,0x3a9f}, /* 0x6 - 4047 */ - {0x0047,0x14,0x1c,0x00,0x6a, 800, 600,0x3aa4}, /* 0x7 - 4047 */ -/* {0xc05f,0x05,0x00,0x04,0x2e, 640, 480,0x3a57}, 0x8 - TW: Patch for Chrontel 7019 */ - {0xc85f,0x05,0x00,0x04,0x2e, 640, 480,0x3a57}, /* 0x8 */ - {0xc067,0x06,0x02,0x04,0x2e, 640, 480,0x3a5c}, /* 0x9 */ - {0xc067,0x07,0x02,0x47,0x2e, 640, 480,0x3a61}, /* 0xa */ - {0xc067,0x08,0x03,0x8a,0x2e, 640, 480,0x3a66}, /* 0xb */ - {0xc047,0x09,0x05,0x00,0x2e, 640, 480,0x3a6b}, /* 0xc - 4047 */ - {0xc047,0x0a,0x09,0x00,0x2e, 640, 480,0x3a70}, /* 0xd - 4047 */ - {0xc047,0x0b,0x0e,0x00,0x2e, 640, 480,0x3a75}, /* 0xe - 4047 */ - {0xc047,0x0c,0x15,0x00,0x2e, 640, 480,0x3a7a}, /* 0xf */ - {0x407f,0x04,0x00,0x00,0x2f, 640, 400,0x3a50}, /* 0x10 */ - {0xc00f,0x3c,0x01,0x06,0x31, 720, 480,0x3b85}, /* 0x11 */ - {0x000f,0x3d,0x03,0x06,0x32, 720, 576,0x3b8c}, /* 0x12 */ - {0x0187,0x15,0x06,0x00,0x37,1024, 768,0x3aab}, /* 0x13 */ - {0xc877,0x16,0x0b,0x06,0x37,1024, 768,0x3ab0}, /* 0x14 301b TV1024x768*/ - {0xc067,0x17,0x0f,0x49,0x37,1024, 768,0x3ab5}, /* 0x15 */ - {0x0267,0x18,0x11,0x00,0x37,1024, 768,0x3aba}, /* 0x16 */ - {0x0047,0x19,0x16,0x8c,0x37,1024, 768,0x3abf}, /* 0x17 */ - {0x0047,0x1a,0x1b,0x00,0x37,1024, 768,0x3ac4}, /* 0x18 - 4047 */ - {0x0047,0x1b,0x1f,0x00,0x37,1024, 768,0x3ac9}, /* 0x19 - 4047 */ - {0x0387,0x1c,0x11,0x00,0x3a,1280,1024,0x3adc}, /* 0x1a */ - {0x0077,0x1d,0x19,0x07,0x3a,1280,1024,0x3ae1}, /* 0x1b */ - {0x0047,0x1e,0x1e,0x00,0x3a,1280,1024,0x3ae6}, /* 0x1c */ - {0x0007,0x1f,0x20,0x00,0x3a,1280,1024,0x3aeb}, /* 0x1d */ - {0x0007,0x20,0x21,0x00,0x3c,1600,1200,0x3af2}, /* 0x1e */ - {0x0007,0x21,0x22,0x00,0x3c,1600,1200,0x3af7}, /* 0x1f */ - {0x0007,0x22,0x23,0x00,0x3c,1600,1200,0x3afc}, /* 0x20 */ - {0x0007,0x23,0x25,0x00,0x3c,1600,1200,0x3b01}, /* 0x21 */ - {0x0007,0x24,0x26,0x00,0x3c,1600,1200,0x3b06}, /* 0x22 */ - {0x0007,0x25,0x2c,0x00,0x3c,1600,1200,0x3b0b}, /* 0x23 */ - {0x0007,0x26,0x34,0x00,0x3c,1600,1200,0x3b10}, /* 0x24 */ - {0x407f,0x00,0x00,0x00,0x40, 320, 200,0x3a34}, /* 0x25 */ - {0xc07f,0x01,0x00,0x04,0x50, 320, 240,0x3a3b}, /* 0x26 */ - {0x007f,0x02,0x04,0x05,0x51, 400, 300,0x3a42}, /* 0x27 */ - {0xc077,0x03,0x0b,0x06,0x52, 512, 384,0x3a49}, /* 0x28 */ - {0x8007,0x27,0x27,0x00,0x68,1920,1440,0x3b17}, /* 0x29 */ - {0x4007,0x28,0x29,0x00,0x68,1920,1440,0x3b1c}, /* 0x2a */ - {0x4007,0x29,0x2e,0x00,0x68,1920,1440,0x3b21}, /* 0x2b */ - {0x4007,0x2a,0x30,0x00,0x68,1920,1440,0x3b26}, /* 0x2c */ - {0x4007,0x2b,0x35,0x00,0x68,1920,1440,0x3b2b}, /* 0x2d */ - {0x4005,0x2c,0x39,0x00,0x68,1920,1440,0x3b30}, /* 0x2e */ - {0x4007,0x2d,0x2b,0x00,0x6c,2048,1536,0x3b37}, /* 0x2f */ - {0x4007,0x2e,0x31,0x00,0x6c,2048,1536,0x3b3c}, /* 0x30 */ - {0x4007,0x2f,0x33,0x00,0x6c,2048,1536,0x3b41}, /* 0x31 */ - {0x4007,0x30,0x37,0x00,0x6c,2048,1536,0x3b46}, /* 0x32 */ - {0x4005,0x31,0x38,0x00,0x6c,2048,1536,0x3b4b}, /* 0x33 */ - {0x0057,0x32,0x40,0x08,0x70, 800, 480,0x3b52}, /* 0x34 */ - {0x0047,0x33,0x07,0x08,0x70, 800, 480,0x3b57}, /* 0x35 */ - {0x0047,0x34,0x0a,0x08,0x70, 800, 480,0x3b5c}, /* 0x36 */ - {0x0057,0x35,0x0b,0x09,0x71,1024, 576,0x3b63}, /* 0x37 */ - {0x0047,0x36,0x11,0x09,0x71,1024, 576,0x3b68}, /* 0x38 */ - {0x0047,0x37,0x16,0x09,0x71,1024, 576,0x3b6d}, /* 0x39 */ - {0x0057,0x38,0x19,0x0a,0x75,1280, 720,0x3b74}, /* 0x3a */ - {0x0047,0x39,0x1e,0x0a,0x75,1280, 720,0x3b79}, /* 0x3b */ - {0x0047,0x3a,0x20,0x0a,0x75,1280, 720,0x3b7e}, /* 0x3c */ - {0x0027,0x3b,0x19,0x08,0x7c,1280, 960,0x3ad0}, /* 0x3d */ - {0x0047,0x4c,0x59,0x08,0x7c,1280, 960,0x3ad0}, /* 0x3e */ - {0xc07f,0x01,0x00,0x06,0x5a, 320, 480,0x3b83}, /* 0x3f */ /* FSTN mode */ - {0x0077,0x42,0x12,0x07,0x23,1280, 768,0x0000}, /* 0x40 */ /* TW: 650/LVDS/301LVx new mode */ - {0x0067,0x43,0x4d,0x08,0x26,1400,1050,0x0000}, /* 0x41 */ /* TW: 650/LVDS/301LVx new mode */ - {0x0067,0x4b,0x5a,0x08,0x26,1400,1050,0x0000}, /* 0x42 */ /* TW: new, not in any BIOS */ - {0x0047,0x44,0x19,0x06,0x29,1152, 864,0x0000}, /* 0x43 TW: Non-BIOS, new */ - {0x0047,0x4a,0x1e,0x06,0x29,1152, 864,0x0000}, /* 0x44 TW: Non-BIOS, new */ - {0x00c7,0x45,0x57,0x00,0x39, 848, 480,0x0000}, /* 0x45 TW: 848x480-38Hzi - Non-BIOS, new */ - {0xc047,0x46,0x55,0x00,0x39, 848, 480,0x0000}, /* 0x46 TW: 848x480-60Hz - Non-BIOS, new */ - {0x00c7,0x47,0x57,0x00,0x3f, 856, 480,0x0000}, /* 0x47 TW: 856x480-38Hzi - Non-BIOS, new */ - {0xc047,0x48,0x57,0x00,0x3f, 856, 480,0x0000}, /* 0x48 TW: 856x480-60Hz - Non-BIOS, new */ - {0x0047,0x49,0x58,0x00,0x48,1360, 768,0x0000}, /* 0x49 TW: 1360x768-60Hz - Non-BIOS, new */ - {0xffff,0x00,0x00,0x00,0x00, 0, 0,0x0000} + {0x085f,0x0d,0x03,0x05,0x6a, 800, 600, 0x40}, /* 0x0 */ + {0x0067,0x0e,0x04,0x05,0x6a, 800, 600, 0x40}, /* 0x1 */ + {0x0067,0x0f,0x08,0x48,0x6a, 800, 600, 0x40}, /* 0x2 */ + {0x0067,0x10,0x07,0x8b,0x6a, 800, 600, 0x40}, /* 0x3 */ + {0x0047,0x11,0x0a,0x00,0x6a, 800, 600, 0x40}, /* 0x4 */ + {0x0047,0x12,0x0d,0x00,0x6a, 800, 600, 0x40}, /* 0x5 */ + {0x0047,0x13,0x13,0x00,0x6a, 800, 600, 0x20}, /* 0x6 */ + {0x0107,0x14,0x1c,0x00,0x6a, 800, 600, 0x20}, /* 0x7 */ + {0xc85f,0x05,0x00,0x04,0x2e, 640, 480, 0x40}, /* 0x8 */ + {0xc067,0x06,0x02,0x04,0x2e, 640, 480, 0x40}, /* 0x9 */ + {0xc067,0x07,0x02,0x47,0x2e, 640, 480, 0x40}, /* 0xa */ + {0xc067,0x08,0x03,0x8a,0x2e, 640, 480, 0x40}, /* 0xb */ + {0xc047,0x09,0x05,0x00,0x2e, 640, 480, 0x40}, /* 0xc */ + {0xc047,0x0a,0x09,0x00,0x2e, 640, 480, 0x40}, /* 0xd */ + {0xc047,0x0b,0x0e,0x00,0x2e, 640, 480, 0x40}, /* 0xe */ + {0xc047,0x0c,0x15,0x00,0x2e, 640, 480, 0x40}, /* 0xf */ + {0x487f,0x04,0x00,0x00,0x2f, 640, 400, 0x30}, /* 0x10 */ + {0xc04f,0x3c,0x01,0x06,0x31, 720, 480, 0x30}, /* 0x11 */ + {0x004f,0x3d,0x03,0x06,0x32, 720, 576, 0x30}, /* 0x12 */ + {0x0087,0x15,0x06,0x00,0x37,1024, 768, 0x30}, /* 0x13 */ + {0xc877,0x16,0x0b,0x06,0x37,1024, 768, 0x20}, /* 0x14 */ + {0xc067,0x17,0x0f,0x49,0x37,1024, 768, 0x20}, /* 0x15 */ + {0x0067,0x18,0x11,0x00,0x37,1024, 768, 0x20}, /* 0x16 */ + {0x0047,0x19,0x16,0x8c,0x37,1024, 768, 0x20}, /* 0x17 */ + {0x0107,0x1a,0x1b,0x00,0x37,1024, 768, 0x10}, /* 0x18 */ + {0x0107,0x1b,0x1f,0x00,0x37,1024, 768, 0x10}, /* 0x19 */ + {0x0087,0x1c,0x11,0x00,0x3a,1280,1024, 0x30}, /* 0x1a */ + {0x0137,0x1d,0x19,0x07,0x3a,1280,1024, 0x00}, /* 0x1b */ + {0x0107,0x1e,0x1e,0x00,0x3a,1280,1024, 0x00}, /* 0x1c */ + {0x0207,0x1f,0x20,0x00,0x3a,1280,1024, 0x00}, /* 0x1d */ + {0x0227,0x20,0x21,0x09,0x3c,1600,1200, 0x00}, /* 0x1e */ + {0x0407,0x21,0x22,0x00,0x3c,1600,1200, 0x00}, /* 0x1f */ + {0x0407,0x22,0x23,0x00,0x3c,1600,1200, 0x00}, /* 0x20 */ + {0x0407,0x23,0x25,0x00,0x3c,1600,1200, 0x00}, /* 0x21 */ + {0x0007,0x24,0x26,0x00,0x3c,1600,1200, 0x00}, /* 0x22 */ + {0x0007,0x25,0x2c,0x00,0x3c,1600,1200, 0x00}, /* 0x23 */ + {0x0007,0x26,0x34,0x00,0x3c,1600,1200, 0x00}, /* 0x24 */ + {0x407f,0x00,0x00,0x00,0x40, 320, 200, 0x30}, /* 0x25 */ + {0xc07f,0x01,0x00,0x04,0x50, 320, 240, 0x30}, /* 0x26 */ + {0x007f,0x02,0x04,0x05,0x51, 400, 300, 0x30}, /* 0x27 */ + {0xc077,0x03,0x0b,0x06,0x52, 512, 384, 0x30}, /* 0x28 */ + {0x8007,0x27,0x27,0x00,0x68,1920,1440, 0x00}, /* 0x29 */ + {0x4007,0x28,0x29,0x00,0x68,1920,1440, 0x00}, /* 0x2a */ + {0x4007,0x29,0x2e,0x00,0x68,1920,1440, 0x00}, /* 0x2b */ + {0x4007,0x2a,0x30,0x00,0x68,1920,1440, 0x00}, /* 0x2c */ + {0x4007,0x2b,0x35,0x00,0x68,1920,1440, 0x00}, /* 0x2d */ + {0x4005,0x2c,0x39,0x00,0x68,1920,1440, 0x00}, /* 0x2e */ + {0x4007,0x2d,0x2b,0x00,0x6c,2048,1536, 0x00}, /* 0x2f */ + {0x4007,0x2e,0x31,0x00,0x6c,2048,1536, 0x00}, /* 0x30 */ + {0x4007,0x2f,0x33,0x00,0x6c,2048,1536, 0x00}, /* 0x31 */ + {0x4007,0x30,0x37,0x00,0x6c,2048,1536, 0x00}, /* 0x32 */ + {0x4005,0x31,0x38,0x00,0x6c,2048,1536, 0x00}, /* 0x33 */ + {0x0057,0x32,0x40,0x08,0x70, 800, 480, 0x30}, /* 0x34 */ + {0x0047,0x33,0x07,0x08,0x70, 800, 480, 0x30}, /* 0x35 */ + {0x0047,0x34,0x0a,0x08,0x70, 800, 480, 0x30}, /* 0x36 */ + {0x0057,0x35,0x0b,0x09,0x71,1024, 576, 0x30}, /* 0x37 */ + {0x0047,0x36,0x11,0x09,0x71,1024, 576, 0x30}, /* 0x38 */ + {0x0047,0x37,0x16,0x09,0x71,1024, 576, 0x30}, /* 0x39 */ + {0x0117,0x38,0x19,0x0a,0x75,1280, 720, 0x30}, /* 0x3a */ + {0x0107,0x39,0x1e,0x0a,0x75,1280, 720, 0x30}, /* 0x3b */ + {0x0207,0x3a,0x20,0x0a,0x75,1280, 720, 0x30}, /* 0x3c */ + {0x0127,0x3b,0x19,0x08,0x7c,1280, 960, 0x30}, /* 0x3d */ + {0x0227,0x4c,0x59,0x08,0x7c,1280, 960, 0x20}, /* 0x3e */ + {0xc07f,0x4e,0x00,0x06,0x5a, 320, 240, 0x30}, /* 0x3f */ /* FSTN 320x240 */ + {0x0077,0x42,0x5b,0x08,0x23,1280, 768, 0x30}, /* 0x40 */ /* TW: 0x5b was 0x12 */ + {0x0127,0x43,0x4d,0x08,0x26,1400,1050, 0x30}, /* 0x41 */ + {0x0207,0x4b,0x5a,0x08,0x26,1400,1050, 0x30}, /* 0x42 Non-BIOS, new */ + {0x0107,0x44,0x19,0x00,0x29,1152, 864, 0x30}, /* 0x43 Non-BIOS, new */ + {0x0107,0x4a,0x1e,0x00,0x29,1152, 864, 0x30}, /* 0x44 Non-BIOS, new */ + {0x0087,0x45,0x57,0x00,0x39, 848, 480, 0x30}, /* 0x45 848x480-38Hzi - Non-BIOS, new */ + {0xc067,0x46,0x55,0x0b,0x39, 848, 480, 0x30}, /* 0x46 848x480-60Hz - Non-BIOS, new */ + {0x0087,0x47,0x57,0x00,0x3f, 856, 480, 0x30}, /* 0x47 856x480-38Hzi - Non-BIOS, new */ + {0xc047,0x48,0x57,0x00,0x3f, 856, 480, 0x30}, /* 0x48 856x480-60Hz - Non-BIOS, new */ + {0x0067,0x49,0x58,0x0c,0x48,1360, 768, 0x30}, /* 0x49 1360x768-60Hz - Non-BIOS, new */ + {0x004f,0x4d,0x03,0x06,0x5f, 768, 576, 0x30}, /* 0x4a 768x576 */ + {0xffff,0x00,0x00,0x00,0x00, 0, 0, 0} }; typedef struct _SiS310_CRT1TableStruct @@ -720,7 +287,7 @@ static const SiS310_CRT1TableStruct SiS310_CRT1Table[]= {{0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x05, 0x00}}, /* 0x4 */ -#if 0 +#if 0 {{0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x05, 0x00}}, /* 0x5 */ @@ -924,41 +491,41 @@ 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, /* New, 1152x864-75, not in BIOS */ 0x60,0x83,0x5f,0x5f,0x83,0x10,0x00,0x07, 0x01}}, /* 0x44 */ - {{0x86,0x69,0x69,0x8A,0x74,0x06,0x8C,0x15, /* TW: New, 848x480-38i, not in BIOS */ + {{0x86,0x69,0x69,0x8A,0x74,0x06,0x8C,0x15, /* New, 848x480-38i, not in BIOS */ 0x4F,0x83,0xEF,0xEF,0x8D,0x30,0x00,0x02, 0x00}}, /* 0x45 */ -#if 0 - {{0x81,0x69,0x69,0x85,0x70,0x00,0x0F,0x3E, /* TW: New, 848x480-60, not in BIOS - incorrect for Philips panel */ - 0xEB,0x8E,0xDF,0xDF,0x10,0x00,0x00,0x02, - 0x00}}, /* 0x46 */ -#endif - {{0x83,0x69,0x69,0x87,0x6f,0x1d,0x03,0x3E, /* TW: New, 848x480-60, not in BIOS */ + {{0x83,0x69,0x69,0x87,0x6f,0x1d,0x03,0x3E, /* New, 848x480-60, not in BIOS */ 0xE5,0x8d,0xDF,0xe4,0x04,0x00,0x00,0x06, 0x00}}, /* 0x46 */ - {{0x86,0x6A,0x6A,0x8A,0x74,0x06,0x8C,0x15, /* TW: New, 856x480-38i, not in BIOS */ + {{0x86,0x6A,0x6A,0x8A,0x74,0x06,0x8C,0x15, /* New, 856x480-38i, not in BIOS */ 0x4F,0x83,0xEF,0xEF,0x8D,0x30,0x00,0x02, 0x00}}, /* 0x47 */ - {{0x81,0x6A,0x6A,0x85,0x70,0x00,0x0F,0x3E, /* TW: New, 856x480-60, not in BIOS */ + {{0x81,0x6A,0x6A,0x85,0x70,0x00,0x0F,0x3E, /* New, 856x480-60, not in BIOS */ 0xEB,0x8E,0xDF,0xDF,0x10,0x00,0x00,0x02, 0x00}}, /* 0x48 */ - {{0xdd,0xa9,0xa9,0x81,0xb4,0x97,0x26,0xfd, /* TW: New, 1360x768-60, not in BIOS */ + {{0xdd,0xa9,0xa9,0x81,0xb4,0x97,0x26,0xfd, /* New, 1360x768-60, not in BIOS */ 0x01,0x8d,0xff,0x00,0x27,0x10,0x00,0x03, 0x01}}, /* 0x49 */ - {{0xd9,0x8f,0x8f,0x9d,0xba,0x0a,0x8a,0xff, /* TW: New, 1152x864-84, not in any BIOS */ + {{0xd9,0x8f,0x8f,0x9d,0xba,0x0a,0x8a,0xff, /* New, 1152x864-84, not in any BIOS */ 0x60,0x8b,0x5f,0x5f,0x8b,0x10,0x00,0x03, 0x01}}, /* 0x4a */ - {{0xea,0xae,0xae,0x8e,0xba,0x82,0x40,0x10, /* TW: New, 1400x1050-75, not in any BIOS */ + {{0xea,0xae,0xae,0x8e,0xba,0x82,0x40,0x10, /* New, 1400x1050-75, not in any BIOS */ 0x1b,0x87,0x19,0x1a,0x41,0x0f,0x00,0x03, - 0x00}}, /* 0x4b */ - {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0xf1,0xff, /* TW: New, 1280x960-85, not in any BIOS */ + 0x00}}, /* 0x4b */ + {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0xf1,0xff, /* New, 1280x960-85, not in any BIOS */ 0xc0,0x83,0xbf,0xbf,0xf2,0x10,0x00,0x07, - 0x01}} /* 0x4c */ + 0x01}}, /* 0x4c */ + {{0x7b,0x5f,0x63,0x9f,0x6a,0x93,0x6f,0xf0, /* 768x576 */ + 0x58,0x8a,0x3f,0x57,0x70,0x20,0x00,0x05, + 0x01}}, /* 0x4d */ + {{0x2d,0x27,0x28,0x90,0x2c,0x80,0x0b,0x3e, /* FSTN 320x480, TEMP - possibly invalid */ + 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x00, + 0x00}} /* 0x4e */ }; - typedef struct _SiS310_MCLKDataStruct { UCHAR SR28,SR29,SR2A; @@ -967,7 +534,7 @@ typedef struct _SiS310_MCLKDataStruct static const SiS310_MCLKDataStruct SiS310_MCLKData_0_315[] = { - { 0x3b,0x22,0x01,143}, /* TW: Was { 0x5c,0x23,0x01,166}, */ + { 0x3b,0x22,0x01,143}, { 0x5c,0x23,0x01,166}, { 0x5c,0x23,0x01,166}, { 0x5c,0x23,0x01,166}, @@ -977,7 +544,7 @@ static const SiS310_MCLKDataStruct SiS310_MCLKData_0_315[] = { 0x5c,0x23,0x01,166} }; -static const SiS310_MCLKDataStruct SiS310_MCLKData_0_650[] = /* @ 0x54 */ +static const SiS310_MCLKDataStruct SiS310_MCLKData_0_650[] = { { 0x5a,0x64,0x82, 66}, { 0xb3,0x45,0x82, 83}, @@ -989,7 +556,7 @@ static const SiS310_MCLKDataStruct SiS310_MCLKData_0_650[] = /* @ 0x54 */ { 0x37,0x22,0x82,133} }; -static const SiS310_MCLKDataStruct SiS310_MCLKData_0_330[] = /* @ 0x54 */ +static const SiS310_MCLKDataStruct SiS310_MCLKData_0_330[] = { { 0x5c,0x23,0x01,166}, { 0x5c,0x23,0x01,166}, @@ -1001,7 +568,19 @@ static const SiS310_MCLKDataStruct SiS310_MCLKData_0_330[] = /* @ 0x54 */ { 0x79,0x06,0x01,250} }; -static const SiS310_MCLKDataStruct SiS310_MCLKData_1[] = /* @ 0x155 */ +static const SiS310_MCLKDataStruct SiS310_MCLKData_0_660[] = /* TODO */ +{ + { 0x5c,0x23,0x82,166}, + { 0x5c,0x23,0x82,166}, + { 0x37,0x21,0x82,200}, + { 0x37,0x22,0x82,133}, + { 0x29,0x21,0x82,150}, + { 0x5c,0x23,0x82,166}, + { 0x65,0x23,0x82,183}, + { 0x37,0x21,0x82,200} +}; + +static const SiS310_MCLKDataStruct SiS310_MCLKData_1[] = { { 0x29,0x21,0x82,150}, { 0x5c,0x23,0x82,166}, @@ -1013,20 +592,6 @@ static const SiS310_MCLKDataStruct SiS310_MCLKData_1[] = /* @ 0x155 */ { 0x37,0x22,0x82,133} }; -typedef struct _SiS310_ECLKDataStruct -{ - UCHAR SR2E,SR2F,SR30; - USHORT CLOCK; -} SiS310_ECLKDataStruct; - -static const SiS310_ECLKDataStruct SiS310_ECLKData[]= -{ - { 0x5c,0x23,0x01,166}, - { 0x5c,0x23,0x01,166}, - { 0x5c,0x23,0x01,166}, - { 0x5c,0x23,0x01,166} -}; - typedef struct _SiS310_VCLKDataStruct { UCHAR SR2B,SR2C; @@ -1035,22 +600,22 @@ typedef struct _SiS310_VCLKDataStruct static const SiS310_VCLKDataStruct SiS310_VCLKData[]= { - { 0x1b,0xe1, 25}, /* 0x0 */ /* 650/LVDS BIOS: @ 0x5647 */ - { 0x4e,0xe4, 28}, /* 0x1 */ - { 0x57,0xe4, 31}, /* 0x2 */ - { 0xc3,0xc8, 36}, /* 0x3 */ - { 0x42,0xe2, 40}, /* 0x4 */ - { 0xfe,0xcd, 43}, /* 0x5 */ - { 0x5d,0xc4, 44}, /* 0x6 */ - { 0x52,0xe2, 49}, /* 0x7 */ - { 0x53,0xe2, 50}, /* 0x8 */ - { 0x74,0x67, 52}, /* 0x9 */ - { 0x6d,0x66, 56}, /* 0xa */ - { 0x5a,0x64, 65}, /* 0xb */ /* TW: was 6c c3 - WRONG */ - { 0x46,0x44, 67}, /* 0xc */ - { 0xb1,0x46, 68}, /* 0xd */ - { 0xd3,0x4a, 72}, /* 0xe */ - { 0x29,0x61, 75}, /* 0xf */ + { 0x1b,0xe1, 25}, /* 0x00 */ + { 0x4e,0xe4, 28}, /* 0x01 */ + { 0x57,0xe4, 31}, /* 0x02 */ + { 0xc3,0xc8, 36}, /* 0x03 */ + { 0x42,0xe2, 40}, /* 0x04 */ + { 0xfe,0xcd, 43}, /* 0x05 */ + { 0x5d,0xc4, 44}, /* 0x06 */ + { 0x52,0xe2, 49}, /* 0x07 */ + { 0x53,0xe2, 50}, /* 0x08 */ + { 0x74,0x67, 52}, /* 0x09 */ + { 0x6d,0x66, 56}, /* 0x0a */ + { 0x5a,0x64, 65}, /* 0x0b */ /* TW: was 6c c3 - WRONG */ + { 0x46,0x44, 67}, /* 0x0c */ + { 0xb1,0x46, 68}, /* 0x0d */ + { 0xd3,0x4a, 72}, /* 0x0e */ + { 0x29,0x61, 75}, /* 0x0f */ { 0x6e,0x46, 76}, /* 0x10 */ { 0x2b,0x61, 78}, /* 0x11 */ { 0x31,0x42, 79}, /* 0x12 */ @@ -1060,7 +625,7 @@ static const SiS310_VCLKDataStruct SiS310_VCLKData[]= { 0x62,0x44, 94}, /* 0x16 */ { 0x2b,0x41,104}, /* 0x17 */ { 0x3a,0x23,105}, /* 0x18 */ - { 0x70,0x44,108}, /* 0x19 */ + { 0x70,0x44,108}, /* 0x19 */ { 0x3c,0x23,109}, /* 0x1a */ { 0x5e,0x43,113}, /* 0x1b */ { 0xbc,0x44,116}, /* 0x1c */ @@ -1093,14 +658,13 @@ static const SiS310_VCLKDataStruct SiS310_VCLKData[]= { 0xea,0x08,340}, /* 0x37 */ { 0xe8,0x07,376}, /* 0x38 */ { 0xde,0x06,389}, /* 0x39 */ - { 0x52,0x2a, 54}, /* 0x3a */ - { 0x52,0x6a, 27}, /* 0x3b */ - { 0x62,0x24, 70}, /* 0x3c */ - { 0x62,0x64, 70}, /* 0x3d */ - { 0xa8,0x4c, 30}, /* 0x3e */ - { 0x20,0x26, 33}, /* 0x3f */ + { 0x52,0x2a, 54}, /* 0x3a */ /* 301 TV */ + { 0x52,0x6a, 27}, /* 0x3b */ /* 301 TV */ + { 0x62,0x24, 70}, /* 0x3c */ /* 301 TV */ + { 0x62,0x64, 70}, /* 0x3d */ /* 301 TV */ + { 0xa8,0x4c, 30}, /* 0x3e */ /* 301 TV */ + { 0x20,0x26, 33}, /* 0x3f */ /* 301 TV */ { 0x31,0xc2, 39}, /* 0x40 */ - /* TW: 650/LVDS BIOS @ 0x574b new: */ { 0x60,0x36, 30}, /* 0x41 */ /* Chrontel */ { 0x40,0x4a, 28}, /* 0x42 */ /* Chrontel */ { 0x9f,0x46, 44}, /* 0x43 */ /* Chrontel */ @@ -1112,7 +676,7 @@ static const SiS310_VCLKDataStruct SiS310_VCLKData[]= { 0xce,0x3c, 39}, /* 0x49 */ { 0x52,0x4a, 36}, /* 0x4a */ /* Chrontel */ { 0x34,0x61, 95}, /* 0x4b */ - { 0x78,0x27,108}, /* 0x4c - was 102 */ /* TW: Last entry in 650/301 BIOS */ + { 0x78,0x27,108}, /* 0x4c - was 102 */ { 0x66,0x43,123}, /* 0x4d */ /* Modes 0x26-0x28 (1400x1050) */ { 0x41,0x4e, 21}, /* 0x4e */ { 0xa1,0x4a, 29}, /* 0x4f */ /* Chrontel */ @@ -1124,9 +688,10 @@ static const SiS310_VCLKDataStruct SiS310_VCLKData[]= { 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) - TEMP */ + { 0x30,0x23, 88}, /* 0x58 - added for 1360x768-62 (is 60Hz!) (not in any BIOS) */ { 0x52,0x07,149}, /* 0x59 - added for 1280x960-85 (Not in any BIOS) */ - { 0x56,0x07,156} /* 0x5a - added for 1400x1050-75 */ + { 0x56,0x07,156}, /* 0x5a - added for 1400x1050-75 */ + { 0x70,0x29, 81} /* 0x5b - added for 1280x768 LCD */ }; typedef struct _SiS310_VBVCLKDataStruct @@ -1137,22 +702,22 @@ typedef struct _SiS310_VBVCLKDataStruct static const SiS310_VBVCLKDataStruct SiS310_VBVCLKData[]= { - { 0x1b,0xe1, 25}, /* 0x0 */ /* 650/LVDS BIOS: @ 0x579c */ - { 0x4e,0xe4, 28}, /* 0x1 */ - { 0x57,0xe4, 31}, /* 0x2 */ - { 0xc3,0xc8, 36}, /* 0x3 */ - { 0x42,0x47, 40}, /* 0x4 */ - { 0xfe,0xcd, 43}, /* 0x5 */ - { 0x5d,0xc4, 44}, /* 0x6 */ - { 0x52,0x47, 49}, /* 0x7 */ - { 0x53,0x47, 50}, /* 0x8 */ - { 0x74,0x67, 52}, /* 0x9 */ - { 0x6d,0x66, 56}, /* 0xa */ - { 0x35,0x62, 65}, /* 0xb */ /* Was 0x5a,0x64 - 650/LVDS+301 bios: 35,62 */ - { 0x46,0x44, 67}, /* 0xc */ - { 0xb1,0x46, 68}, /* 0xd */ - { 0xd3,0x4a, 72}, /* 0xe */ - { 0x29,0x61, 75}, /* 0xf */ + { 0x1b,0xe1, 25}, /* 0x00 */ + { 0x4e,0xe4, 28}, /* 0x01 */ + { 0x57,0xe4, 31}, /* 0x02 */ + { 0xc3,0xc8, 36}, /* 0x03 */ + { 0x42,0x47, 40}, /* 0x04 */ + { 0xfe,0xcd, 43}, /* 0x05 */ + { 0x5d,0xc4, 44}, /* 0x06 */ + { 0x52,0x47, 49}, /* 0x07 */ + { 0x53,0x47, 50}, /* 0x08 */ + { 0x74,0x67, 52}, /* 0x09 */ + { 0x6d,0x66, 56}, /* 0x0a */ + { 0x35,0x62, 65}, /* 0x0b */ /* Was 0x5a,0x64 - 650/LVDS+301 bios: 35,62 */ + { 0x46,0x44, 67}, /* 0x0c */ + { 0xb1,0x46, 68}, /* 0x0d */ + { 0xd3,0x4a, 72}, /* 0x0e */ + { 0x29,0x61, 75}, /* 0x0f */ { 0x6d,0x46, 75}, /* 0x10 */ { 0x41,0x43, 78}, /* 0x11 */ { 0x31,0x42, 79}, /* 0x12 */ @@ -1162,15 +727,21 @@ static const SiS310_VBVCLKDataStruct SiS310_VBVCLKData[]= { 0x62,0x44, 94}, /* 0x16 */ { 0x2b,0x22,104}, /* 0x17 */ { 0x49,0x24,105}, /* 0x18 */ - { 0xf8,0x2f,108}, /* 0x19 */ + { 0xf8,0x2f,108}, /* 0x19 */ /* 1400x1050 LCD */ { 0x3c,0x23,109}, /* 0x1a */ { 0x5e,0x43,113}, /* 0x1b */ { 0xbc,0x44,116}, /* 0x1c */ { 0xe0,0x46,132}, /* 0x1d */ +#if 0 { 0xd4,0x28,135}, /* 0x1e */ { 0xea,0x2a,139}, /* 0x1f */ { 0x41,0x22,157}, /* 0x20 */ { 0x70,0x24,162}, /* 0x21 */ +#endif + { 0xe2,0x46,135}, /* 0x1e */ /* 1280x1024-75, better clock for VGA2 */ + { 0xe5,0x46,139}, /* 0x1f */ /* 1024x768-120, better clock for VGA2 */ + { 0x15,0x01,157}, /* 0x20 */ /* 1280x1024-85, better clock for VGA2 */ + { 0x70,0x09,162}, /* 0x21 */ /* 1600x1200-60, better clock for VGA2 */ { 0x30,0x21,175}, /* 0x22 */ { 0x4e,0x22,189}, /* 0x23 */ { 0xde,0x26,194}, /* 0x24 */ @@ -1195,88 +766,50 @@ static const SiS310_VBVCLKDataStruct SiS310_VBVCLKData[]= { 0xea,0x08,340}, /* 0x37 */ { 0xe8,0x07,376}, /* 0x38 */ { 0xde,0x06,389}, /* 0x39 */ - { 0x52,0x2a, 54}, /* 0x3a */ - { 0x52,0x6a, 27}, /* 0x3b */ - { 0x62,0x24, 70}, /* 0x3c */ - { 0x62,0x64, 70}, /* 0x3d */ - { 0xa8,0x4c, 30}, /* 0x3e */ - { 0x20,0x26, 33}, /* 0x3f */ + { 0x52,0x2a, 54}, /* 0x3a */ /* 301 TV */ + { 0x52,0x6a, 27}, /* 0x3b */ /* 301 TV */ + { 0x62,0x24, 70}, /* 0x3c */ /* 301 TV */ + { 0x62,0x64, 70}, /* 0x3d */ /* 301 TV */ + { 0xa8,0x4c, 30}, /* 0x3e */ /* 301 TV */ + { 0x20,0x26, 33}, /* 0x3f */ /* 301 TV */ { 0x31,0xc2, 39}, /* 0x40 */ - /* TW: 650/LVDS+301 BIOS (@ 0x58a0 in LVDS) new: */ - { 0x2e,0x48, 25}, /* 0x41 */ - { 0x24,0x46, 25}, /* 0x42 */ - { 0x26,0x64, 28}, /* 0x43 */ - { 0x37,0x64, 40}, /* 0x44 */ - { 0xa1,0x42,108}, /* 0x45 */ - { 0x37,0x61,100}, /* 0x46 */ - { 0x78,0x27,108} /* 0x47 */ - /* --- 0x58bc --- */ -}; - -static const UCHAR SiS310_ScreenOffset[] = + { 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 */ + { 0x56,0x07,156}, /* 0x5a */ /* 1400x1050-75 */ + { 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, + 0x78,0x80,0x2d,0x35,0x57,0x48,0x55,0x30, 0xff -}; /* TW: Added 1400x1050, 1152x864, 848/856x480, 1360x768 */ - -typedef struct _SiS310_StResInfoStruct -{ - USHORT HTotal; - USHORT VTotal; -} SiS310_StResInfoStruct; - -static const SiS310_StResInfoStruct SiS310_StResInfo[]= -{ - { 640,400}, - { 640,350}, - { 720,400}, - { 720,350}, - { 640,480} }; -typedef struct _SiS310_ModeResInfoStruct -{ - USHORT HTotal; - USHORT VTotal; - UCHAR XChar; - UCHAR YChar; -} SiS310_ModeResInfoStruct; - -static const SiS310_ModeResInfoStruct SiS310_ModeResInfo[] = -{ - { 320, 200, 8, 8}, /* 0x00 */ - { 320, 240, 8, 8}, /* 0x01 */ - { 320, 400, 8, 8}, /* 0x02 */ - { 400, 300, 8, 8}, /* 0x03 */ - { 512, 384, 8, 8}, /* 0x04 */ - { 640, 400, 8,16}, /* 0x05 */ - { 640, 480, 8,16}, /* 0x06 */ - { 800, 600, 8,16}, /* 0x07 */ - { 1024, 768, 8,16}, /* 0x08 */ - { 1280,1024, 8,16}, /* 0x09 */ - { 1600,1200, 8,16}, /* 0x0a */ - { 1920,1440, 8,16}, /* 0x0b */ - { 2048,1536, 8,16}, /* 0x0c */ - { 720, 480, 8,16}, /* 0x0d */ - { 720, 576, 8,16}, /* 0x0e */ - { 1280, 960, 8,16}, /* 0x0f */ - { 800, 480, 8,16}, /* 0x10 */ - { 1024, 576, 8,16}, /* 0x11 */ - { 1280, 720, 8,16}, /* 0x12 */ - { 856, 480, 8,16}, /* 0x13 - TW: New, not in any BIOS */ - { 1280, 768, 8,16}, /* 0x14 20; TW: New */ - { 1400,1050, 8,16}, /* 0x15 21; TW: New */ - { 1152, 864, 8,16}, /* 0x16 - TW: New, not in any BIOS */ - { 848, 480, 8,16}, /* 0x17 - TW: New, not in any BIOS */ - { 1360, 768, 8,16} /* 0x18 - TW: New, not in any BIOS */ -}; - -static const UCHAR SiS310_OutputSelect = 0x40; - -static const UCHAR SiS310_SoftSetting = 0x30; /* TW: RAM setting */ - -static const UCHAR SiS310_SR15[8][4]={ +static const DRAM4Type SiS310_SR15[8] = { {0x00,0x04,0x60,0x60}, {0x0f,0x0f,0x0f,0x0f}, {0xba,0xba,0xba,0xba}, @@ -1291,7 +824,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}, @@ -1316,20 +849,59 @@ static UCHAR SiS310_CRT2Data_4_10 = 0x80; static const USHORT SiS310_RGBSenseData = 0xd1; static const USHORT SiS310_VideoSenseData = 0xb9; static const USHORT SiS310_YCSenseData = 0xb3; -static const USHORT SiS310_RGBSenseData2 = 0x0190; /*301b*/ +static const USHORT SiS310_RGBSenseData2 = 0x0190; static const USHORT SiS310_VideoSenseData2 = 0x0174; static const USHORT SiS310_YCSenseData2 = 0x016b; #endif -static const UCHAR SiS310_NTSCPhase[] = {0x21,0xed,0xba,0x08}; /* TW: Was {0x21,0xed,0x8a,0x08}; */ -static const UCHAR SiS310_PALPhase[] = {0x2a,0x05,0xe3,0x00}; /* TW: Was {0x2a,0x05,0xd3,0x00}; */ -static const UCHAR SiS310_PALMPhase[] = {0x21,0xE4,0x2E,0x9B}; /* TW: palm*/ -static const UCHAR SiS310_PALNPhase[] = {0x21,0xF4,0x3E,0xBA}; /* TW: paln*/ -static const UCHAR SiS310_NTSCPhase2[] = {0x21,0xF0,0x7B,0xD6}; -static const UCHAR SiS310_PALPhase2[] = {0x2a,0x09,0x86,0xe9}; -static const UCHAR SiS310_PALMPhase2[] = {0x21,0xE6,0xEF,0xA4}; /* TW: palm 301b*/ -static const UCHAR SiS310_PALNPhase2[] = {0x21,0xF6,0x94,0x46}; /* TW: paln 301b*/ -static const UCHAR SiS310_SpecialPhase[] = {0x1e,0x8c,0x5c,0x7a}; +typedef struct _SiS310_PanelDelayTblStruct +{ + UCHAR timer[2]; +} SiS310_PanelDelayTblStruct; + +static const SiS310_PanelDelayTblStruct SiS310_PanelDelayTbl[]= +{ + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}}, + {{0x10,0x40}} +}; + +static const SiS310_PanelDelayTblStruct SiS310_PanelDelayTblLVDS[]= +{ + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}}, + {{0x28,0xc8}} +}; + +/**************************************************************/ +/* SIS VIDEO BRIDGE ----------------------------------------- */ +/**************************************************************/ typedef struct _SiS310_LCDDataStruct { @@ -1352,12 +924,12 @@ static const SiS310_LCDDataStruct SiS310_StLCD1024x768Data[]= { 1, 1,1344, 806,1344, 806} }; -static const SiS310_LCDDataStruct SiS310_ExtLCD1024x768Data[] = /* TW: Checked */ +static const SiS310_LCDDataStruct SiS310_ExtLCD1024x768Data[] = { - { 12, 5, 896, 512,1344, 806}, - { 12, 5, 896, 510,1344, 806}, - { 32, 15,1008, 505,1344, 806}, - { 32, 15,1008, 514,1344, 806}, + { 42, 25,1536, 419,1344, 806}, + { 48, 25,1536, 369,1344, 806}, + { 42, 25,1536, 419,1344, 806}, + { 48, 25,1536, 369,1344, 806}, { 12, 5, 896, 500,1344, 806}, { 42, 25,1024, 625,1344, 806}, { 1, 1,1344, 806,1344, 806}, @@ -1367,14 +939,14 @@ static const SiS310_LCDDataStruct SiS310_ExtLCD1024x768Data[] = /* TW: Checke { 12, 5, 896, 500,1344, 806}, { 42, 25,1024, 625,1344, 806}, { 1, 1,1344, 806,1344, 806} + }; -static const SiS310_LCDDataStruct SiS310_St2LCD1024x768Data[] = /* TW: Checked */ +static const SiS310_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}, /* TW: Different in 650/301LV BIOS */ + { 62, 25, 800, 546,1344, 806}, { 104, 45, 945, 496,1344, 806}, { 62, 25, 800, 546,1344, 806}, { 31, 18,1008, 624,1344, 806}, @@ -1393,7 +965,7 @@ static const SiS310_LCDDataStruct SiS310_StLCD1280x1024Data[] = { 1, 1,1688,1066,1688,1066} }; -static const SiS310_LCDDataStruct SiS310_ExtLCD1280x1024Data[] = /* TW: Checked */ +static const SiS310_LCDDataStruct SiS310_ExtLCD1280x1024Data[] = { { 211, 60,1024, 501,1688,1066}, { 211, 60,1024, 508,1688,1066}, @@ -1402,7 +974,8 @@ static const SiS310_LCDDataStruct SiS310_ExtLCD1280x1024Data[] = /* TW: Checke { 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,1688,1066,1688,1066}, + { 1, 1,1800,1000,1688,1066} /* 1280x960 - does not work, use panel scaler instead */ }; static const SiS310_LCDDataStruct SiS310_St2LCD1280x1024Data[] = @@ -1417,19 +990,19 @@ static const SiS310_LCDDataStruct SiS310_St2LCD1280x1024Data[] = { 1, 1,1688,1066,1688,1066} }; -static const SiS310_LCDDataStruct SiS310_NoScaleData1024x768[] = /* TW: Checked */ +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}, - { 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[] = /* TW: New; Checked */ +static const SiS310_LCDDataStruct SiS310_NoScaleData1280x1024[] = { { 1, 1,1688,1066,1688,1066}, { 1, 1,1688,1066,1688,1066}, @@ -1438,653 +1011,663 @@ static const SiS310_LCDDataStruct SiS310_NoScaleData1280x1024[] = /* TW: New; { 1, 1,1688,1066,1688,1066}, { 1, 1,1688,1066,1688,1066}, { 1, 1,1688,1066,1688,1066}, + { 1, 1,1688,1066,1688,1066}, { 1, 1,1688,1066,1688,1066} }; -static const SiS310_LCDDataStruct SiS310_LCD1280x960Data[] = +typedef struct _SiS310_Part2PortTblStruct { - { 9, 2, 800, 500,1800,1000}, - { 9, 2, 800, 500,1800,1000}, - { 4, 1, 900, 500,1800,1000}, - { 4, 1, 900, 500,1800,1000}, - { 9, 2, 800, 500,1800,1000}, - { 30, 11,1056, 625,1800,1000}, - { 5, 3,1350, 800,1800,1000}, - { 1, 1,1576,1050,1576,1050}, - { 1, 1,1800,1000,1800,1000} -}; - -static const SiS310_LCDDataStruct SiS310_StLCD1400x1050Data[] = /* TW: New */ -{ /* TW: New from 1.11.6s */ - { 211, 100, 2100, 408, 1688, 1066 }, - { 211, 64, 1536, 358, 1688, 1066 }, - { 211, 100, 2100, 408, 1688, 1066 }, - { 211, 64, 1536, 358, 1688, 1066 }, - { 211, 48, 840, 488, 1688, 1066 }, - { 211, 72, 1008, 609, 1688, 1066 }, - { 211, 128, 1400, 776, 1688, 1066 }, - { 211, 205, 1680, 1041, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 } -}; - -static const SiS310_LCDDataStruct SiS310_ExtLCD1400x1050Data[] = /* TW: New */ -{ /* TW: New from 1.11.6s */ - { 211, 100, 2100, 408, 1688, 1066 }, - { 211, 64, 1536, 358, 1688, 1066 }, - { 211, 100, 2100, 408, 1688, 1066 }, - { 211, 64, 1536, 358, 1688, 1066 }, - { 211, 48, 840, 488, 1688, 1066 }, - { 211, 72, 1008, 609, 1688, 1066 }, - { 211, 128, 1400, 776, 1688, 1066 }, - { 211, 205, 1680, 1041, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 } -}; - -static const SiS310_LCDDataStruct SiS310_NoScaleData1400x1050[] = /* TW: New */ -{ /* TW: To be checked (BIOS uses 1280x1024 data, one line too short) */ - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 } -}; - -static const SiS310_LCDDataStruct SiS310_StLCD1600x1200Data[] = /* TW: New */ -{ /* TODO */ - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS310_LCDDataStruct SiS310_ExtLCD1600x1200Data[] = /* TW: New */ -{ /* TODO */ - { 0, 0, 0, 0, 0, 0} -}; - -static const SiS310_LCDDataStruct SiS310_NoScaleData1600x1200[] = /* TW: New */ -{ /* TODO */ - { 0, 0, 0, 0, 0, 0} -}; + UCHAR CR[12]; +} SiS310_Part2PortTblStruct; -typedef struct _SiS310_TVDataStruct -{ - USHORT RVBHCMAX; - USHORT RVBHCFACT; - USHORT VGAHT; - USHORT VGAVT; - USHORT TVHDE; - USHORT TVVDE; - USHORT RVBHRS; - UCHAR FlickerMode; - USHORT HALFRVBHRS; - UCHAR RY1COE; - UCHAR RY2COE; - UCHAR RY3COE; - UCHAR RY4COE; -} SiS310_TVDataStruct; - -static const SiS310_TVDataStruct SiS310_StPALData[]= +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_1[] = { - { 1, 1, 864, 525,1270, 400, 100, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 350, 100, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, - { 1, 1, 864, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, - { 1, 1, 864, 525,1270, 480, 50, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 600, 50, 0, 0,0xf4,0xff,0x1c,0x22} + {{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_TVDataStruct SiS310_ExtPALData[] = /* TW: Verfied (1.10.7w) */ +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_2[] = { - { 27, 10, 848, 448,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, - { 108, 35, 848, 398,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, - { 12, 5, 954, 448,1270, 530, 50, 0, 50,0xf1,0x04,0x1f,0x18}, - { 9, 4, 960, 463,1644, 438, 50, 0, 50,0xf4,0x0b,0x1c,0x0a}, - { 9, 4, 848, 528,1270, 530, 0, 0, 50,0xf5,0xfb,0x1b,0x2a}, /* 640x480 */ - { 36, 25,1060, 648,1316, 530, 438, 0, 438,0xeb,0x05,0x25,0x16}, /* 800x600 */ - { 3, 2,1080, 619,1270, 540, 438, 0, 438,0xf3,0x00,0x1d,0x20}, /* 720x480/576 */ - { 1, 1,1170, 821,1270, 520, 686, 0, 686,0xF3,0x00,0x1D,0x20} /* 1024x768 */ + {{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_TVDataStruct SiS310_StNTSCData[]= +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_3[] = { - { 1, 1, 858, 525,1270, 400, 50, 0, 760,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 350, 50, 0, 640,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, - { 1, 1, 858, 525,1270, 480, 0, 0, 760,0xf1,0x04,0x1f,0x18} +#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 }; -static const SiS310_TVDataStruct SiS310_ExtNTSCData[]= -{ - { 143, 65, 858, 443,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, - { 88, 35, 858, 393,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, - { 143, 70, 924, 443,1270, 440, 92, 0, 92,0xf1,0x04,0x1f,0x18}, - { 143, 70, 924, 393,1270, 440, 92, 0, 92,0xf4,0x0b,0x1c,0x0a}, - { 143, 76, 836, 523,1270, 440, 224, 0, 0,0xf1,0x05,0x1f,0x16}, /* 640x480 */ - { 143, 120,1056, 643,1270, 440, 0, 128, 0,0xf4,0x10,0x1c,0x00}, /* 800x600 */ - { 2, 1, 858, 503,1270, 480, 0, 128, 0,0xee,0x0c,0x22,0x08}, /* 720x480/576 */ - { 65, 64,1056, 791,1270, 480, 638, 0, 0,0xEE,0x0C,0x22,0x08} /* 1024x768 */ +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_1[] = +{ /* Acer; BIOS data invalid, last row taken from _3 */ + {{0x25,0x12,0x51,0x6E,0x48,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x2C,0x12,0x38,0x55,0x2F,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x25,0x12,0x51,0x6E,0x48,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x2C,0x12,0x38,0x55,0x2F,0xC1,0x35,0xB1,0x47,0xE9,0x71,0x33}}, + {{0x2D,0x12,0x79,0x96,0x70,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x29,0x12,0xB5,0xD2,0xAC,0xE9,0x35,0xD9,0x47,0x11,0x99,0x33}}, + {{0x36,0x13,0x02,0x25,0xFF,0x03,0x45,0x09,0x07,0xF9,0x00,0x24}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}} }; -/* TW: These tables will need data ! */ -static const SiS310_TVDataStruct SiS310_St1HiTVData[]= -{ - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_2[] = +{ /* Acer */ + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; -static const SiS310_TVDataStruct SiS310_St2HiTVData[]= -{ - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} +/* 1 2 4 5 6 1c 1d 1f 20 21 23 25 */ +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_3[] = +{ /* Acer */ + {{0x31,0x1B,0xC4,0xDA,0xB0,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x34,0x1B,0x9F,0xC0,0x80,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x3E,0x1B,0xCF,0xF0,0xB0,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x48,0x1C,0x15,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x48,0x1C,0x15,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x48,0x1C,0x15,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}} }; -static const SiS310_TVDataStruct SiS310_ExtHiTVData[]= +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_1[] = { - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} -}; - -static const UCHAR SiS310_NTSCTiming[] = { /* TW: New (checked 1.09, 1.10.6s) */ - 0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c, - 0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a, - 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b, - 0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17, - 0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02, - 0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50, - 0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00 -}; - -static const UCHAR SiS310_PALTiming[] = { /* TW: New (checked 1.09, 1.10.6s) */ - 0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70, - 0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b, - 0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17, - 0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02, - 0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63, - 0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00 -}; - -#ifdef oldHV -static const UCHAR SiS310_HiTVExtTiming[] = { /* TW: New */ - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, - 0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40, - 0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d, - 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 -}; - -static const UCHAR SiS310_HiTVSt1Timing[] = { /* TW: New */ - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x65,0x90,0x7b,0xa8,0x03,0xf0,0x87,0x03, - 0x11,0x15,0x11,0xcf,0x10,0x11,0xcf,0x10, - 0x35,0x35,0x3b,0x69,0x1d,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x86, - 0xaf,0x5d,0x0e,0x00,0xfc,0xff,0x2d,0x00 -}; - -static const UCHAR SiS310_HiTVSt2Timing[] = { /* TW: New */ - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, - 0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40, - 0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d, - 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 -}; - -static const UCHAR SiS310_HiTVTextTiming[] = { /* TW: New */ - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, - 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, - 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, - 0x65,0x90,0xe7,0xbc,0x03,0x0c,0x97,0x03, - 0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20, - 0xc8,0xc8,0x3b,0xd2,0x26,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96, - 0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00 -}; - -static const UCHAR SiS310_HiTVGroup3Data[] = { /* TW: New */ - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f, - 0x05,0x21,0xb2,0xb2,0x55,0x77,0x2a,0xa6, - 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, - 0x8c,0x6e,0x60,0x2e,0x58,0x48,0x72,0x44, - 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, - 0x4f,0x7f,0x03,0xa8,0x7d,0x20,0x1a,0xa9, - 0x14,0x05,0x03,0x7e,0x64,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 + {{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 UCHAR SiS310_HiTVGroup3Simu[] = { /* TW: New */ - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95, - 0xdb,0x20,0xb8,0xb8,0x55,0x47,0x2a,0xa6, - 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, - 0x8c,0x6e,0x60,0x15,0x26,0xd3,0xe4,0x11, - 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, - 0x67,0x36,0x01,0x47,0x0e,0x10,0xbe,0xb4, - 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_2[] = +{ + {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, + {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, + {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, + {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, + {{0x33,0x13,0x01,0x0d,0xfd,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, + {{0x3f,0x1b,0x3d,0x49,0x39,0x54,0x23,0xc0,0x27,0x66,0x30,0x42}}, + {{0x33,0x1b,0x91,0x9d,0x8d,0x8c,0x23,0xf8,0x27,0x9e,0x68,0x42}}, + {{0x43,0x24,0x11,0x1d,0x0d,0xcc,0x23,0x38,0x37,0xde,0xa8,0x42}}, + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} }; -static const UCHAR SiS310_HiTVGroup3Text[] = { /* TW: New */ - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7, - 0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6, - 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, - 0x8c,0x6e,0x60,0x18,0x2c,0x0c,0x20,0x22, - 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, - 0x93,0x3c,0x01,0x50,0x2f,0x10,0xf4,0xca, - 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 +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}} }; -#endif -typedef struct _SiS310_PanelDelayTblStruct +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_1[] = { - UCHAR timer[2]; -} SiS310_PanelDelayTblStruct; + {{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_PanelDelayTblStruct SiS310_PanelDelayTbl[]= /* TW: New */ +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_2[] = { - {{0x10,0x40}}, /* TW: from 650/301LVx 1.10.6s BIOS */ - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}}, - {{0x10,0x40}} -#if 0 - {{0x28,0xc8}}, /* TW: from 650/301LV BIOS */ - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}}, - {{0x28,0xc8}} -#endif + {{0x32,0x1B,0x2C,0x52,0x20,0x80,0x20,0x52,0x30,0xA3,0x3A,0x02}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x32,0x1B,0x2C,0x52,0x20,0x80,0x20,0x52,0x30,0xA3,0x3A,0x02}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x3A,0x1B,0x54,0x7A,0x48,0x80,0x24,0x52,0x30,0xA3,0x3A,0x02}}, + {{0x36,0x1B,0x90,0xB6,0x84,0xA8,0x24,0x7A,0x30,0xCB,0x62,0x02}}, + {{0x3A,0x1C,0xE4,0x0A,0xD8,0xE0,0x24,0xB2,0x30,0x03,0x9A,0x02}}, + {{0x4A,0x24,0x64,0x8A,0x58,0x20,0x34,0xF2,0x30,0x43,0xDA,0x52}}, + {{0x47,0x24,0x71,0x97,0x65,0x3E,0x34,0x10,0x40,0x61,0xF8,0x02}}, + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}} }; -static const SiS310_PanelDelayTblStruct SiS310_PanelDelayTblLVDS[]= +static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_3[] = { - {{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}} + {{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_LVDSDataStruct -{ - USHORT VGAHT; - USHORT VGAVT; - USHORT LCDHT; - USHORT LCDVT; -} SiS310_LVDSDataStruct; +/* CRT1 CRTC for LCDA */ -static const SiS310_LVDSDataStruct SiS310_LVDS320x480Data_1[]= +typedef struct _SiS310_LCDACRT1DataStruct { - {848, 433,400, 525}, - {848, 389,400, 525}, - {848, 433,400, 525}, - {848, 389,400, 525}, - {848, 518,400, 525}, - {1056,628,400, 525}, - {400, 525,400, 525}, - {800, 449,1000, 644}, - {800, 525,1000, 635} -}; + UCHAR CR[17]; +}SiS310_LCDACRT1DataStruct; -static const SiS310_LVDSDataStruct SiS310_LVDS800x600Data_1[]= /* TW: New */ +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_1[]= { - {848, 433,1060, 629}, - {848, 389,1060, 629}, - {848, 433,1060, 629}, - {848, 389,1060, 629}, - {848, 518,1060, 629}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {800, 449,1000, 644}, - {800, 525,1000, 635} + {{0x73,0x4f,0x4f,0x97,0x59,0x84,0xb4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x59,0x84,0x82,0x1f, + 0x60,0x87,0x5d,0x5d,0x83,0x10,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x59,0x84,0xb4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x59,0x84,0x82,0x1f, + 0x60,0x87,0x5d,0x5d,0x83,0x10,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x59,0x84,0x04,0x3e, + 0xE2,0x89,0xdf,0xdf,0x05,0x00,0x00,0x05, + 0x00}}, + {{0x87,0x63,0x63,0x8B,0x6D,0x18,0x7c,0xf0, + 0x5A,0x81,0x57,0x57,0x7D,0x00,0x00,0x06, + 0x01}}, + {{0xA3,0x7f,0x7f,0x87,0x89,0x94,0x24,0xf5, + 0x02,0x89,0xff,0xff,0x25,0x10,0x00,0x02, + 0x01}} }; -static const SiS310_LVDSDataStruct SiS310_LVDS800x600Data_2[]= /* TW: New */ +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_1_H[]= { - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {800, 449,1000, 644}, - {800, 525,1000, 635} + {{0x4b,0x27,0x27,0x8f,0x31,0x1c,0xb4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x31,0x1c,0x82,0x1f, + 0x60,0x87,0x5D,0x5D,0x83,0x10,0x00,0x05, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x31,0x1c,0xb4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x31,0x1c,0x82,0x1f, + 0x60,0x87,0x5D,0x5D,0x83,0x10,0x00,0x05, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x31,0x1c,0x04,0x3e, + 0xE2,0x89,0xDf,0xDf,0x05,0x00,0x00,0x05, + 0x00}}, + {{0x55,0x31,0x31,0x99,0x3b,0x06,0x7c,0xf0, + 0x5A,0x81,0x57,0x57,0x7D,0x00,0x00,0x01, + 0x01}}, + {{0x63,0x3F,0x3F,0x87,0x49,0x94,0x24,0xF5, + 0x02,0x89,0xFF,0xFF,0x25,0x10,0x00,0x01, + 0x01}} }; -static const SiS310_LVDSDataStruct SiS310_LVDS1024x768Data_1[]= /* TW: New */ +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_2[]= { - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 518,1344, 806}, /* 640x480 */ - {1050, 638,1344, 806}, /* 800x600 */ - {1344, 806,1344, 806}, /* 1024x768 */ - {800, 449,1280, 801}, - {800, 525,1280, 813} + {{0xa3,0x4f,0x4f,0x0f,0x6e,0x1f,0x24,0xbb, + 0x4a,0x81,0x8f,0xdb,0xda,0x20,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x0f,0x6e,0x1f,0x24,0xbb, + 0x31,0x88,0x5d,0xc2,0xc1,0x20,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x0f,0x6e,0x1f,0x24,0xbb, + 0x4a,0x81,0x8f,0xdb,0xda,0x20,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x0f,0x6e,0x1f,0x24,0xbb, + 0x31,0x88,0x5d,0xc2,0xc1,0x20,0x00,0x06, + 0x01}}, + {{0xa3,0x4f,0x4f,0x0f,0x6e,0x1f,0x24,0xb3, + 0x72,0x89,0xdf,0x03,0x02,0x30,0x00,0x06, + 0x01}}, + {{0xa3,0x63,0x63,0x98,0x78,0x19,0x24,0xf1, + 0xbb,0x82,0x57,0x57,0x25,0x10,0x00,0x02, + 0x01}}, + {{0xa3,0x7f,0x7f,0x87,0x89,0x94,0x24,0xf5, + 0x02,0x89,0xff,0xff,0x25,0x10,0x00,0x02, + 0x01}} }; -static const SiS310_LVDSDataStruct SiS310_LVDS1024x768Data_2[]= /* TW: New */ +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_2_H[]= { - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1280x1024Data_1[]= /* TW: New - TODO */ -{ /* TW: Temp data, invalid (is identical to 1024x768) */ - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS310_LVDSDataStruct SiS310_LVDS1280x1024Data_2[]= /* TW: New - TODO */ -{ /* TW: Temp data, invalid (is identical to 1024x768) */ - {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} + {{0x7b,0x27,0x27,0x0f,0x46,0x97,0x24,0xbb, + 0x4a,0x81,0x8f,0xdb,0xda,0x20,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x0f,0x46,0x97,0x24,0xbb, + 0x31,0x88,0x5d,0xc2,0xc1,0x20,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x0f,0x46,0x97,0x24,0xbb, + 0x4a,0x81,0x8f,0xdb,0xda,0x20,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x0f,0x46,0x97,0x24,0xbb, + 0x31,0x88,0x5d,0xc2,0xc1,0x20,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x0f,0x46,0x97,0x24,0xb3, + 0x72,0x89,0xdf,0x03,0x02,0x30,0x00,0x01, + 0x01 }}, + {{0x71,0x31,0x31,0x98,0x46,0x17,0x24,0xf1, + 0xbb,0x82,0x57,0x57,0x25,0x10,0x00,0x02, + 0x01 }}, + {{0x63,0x3f,0x3f,0x87,0x4c,0x97,0x24,0xf5, + 0x0f,0x86,0xff,0xff,0x25,0x30,0x00,0x01, + 0x01 }} }; -static const SiS310_LVDSDataStruct SiS310_LVDS1400x1050Data_1[]= /* TW: New */ -{ - {928, 416, 1688, 1066}, - {928, 366, 1688, 1066}, - {928, 416, 1688, 1066}, - {928, 366, 1688, 1066}, - {928, 496, 1688, 1066}, - {1088, 616, 1688, 1066}, - {1312, 784, 1688, 1066}, - {1568, 1040, 1688, 1066}, - {1688, 1066, 1688, 1066} +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_1[]= +{ /* Acer */ + {{0x7e,0x4f,0x4f,0x82,0x58,0x04,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x04,0x86,0x1f, + 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x04,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x04,0x86,0x1f, + 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x04,0x08,0x3e, + 0xe0,0x84,0xdf,0xdf,0x09,0x00,0x00,0x06, + 0x00}}, + {{0x92,0x63,0x63,0x96,0x6c,0x18,0x80,0xf0, + 0x58,0x8c,0x57,0x57,0x81,0x20,0x00,0x06, + 0x01}}, + {{0xae,0x7f,0x7f,0x92,0x88,0x94,0x28,0xf5, + 0x00,0x84,0xff,0xff,0x29,0x10,0x00,0x02, + 0x01}}, + {{0xce,0x9f,0x9f,0x92,0xa8,0x14,0x28,0x5a, + 0x00,0x84,0xff,0xff,0x29,0x01,0x00,0x07, + 0x01}} }; -static const SiS310_LVDSDataStruct SiS310_LVDS1400x1050Data_2[]= /* TW: New */ -{ - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, - {1688,1066, 1688,1066}, +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_1_H[]= +{ /* Acer */ + {{0x56,0x27,0x27,0x9a,0x31,0x1c,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x56,0x27,0x27,0x9a,0x31,0x1c,0x86,0x1f, + 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x05, + 0x00}}, + {{0x56,0x27,0x27,0x9a,0x31,0x1c,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x56,0x27,0x27,0x9a,0x31,0x1c,0x86,0x1f, + 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x05, + 0x01}}, + {{0x56,0x27,0x27,0x9a,0x31,0x1c,0x08,0x3e, + 0xe0,0x84,0xdf,0xdf,0x09,0x00,0x00,0x05, + 0x00}}, + {{0x60,0x31,0x31,0x84,0x3a,0x86,0x80,0xf0, + 0x58,0x8c,0x57,0x57,0x81,0x20,0x00,0x01, + 0x01}}, + {{0x6e,0x3f,0x3f,0x92,0x48,0x94,0x28,0xf5, + 0x00,0x84,0xff,0xff,0x29,0x10,0x00,0x01, + 0x01}} }; -static const SiS310_LVDSDataStruct SiS310_LVDS1280x768Data_1[]= /* TW: New - TODO */ -{ /* TW: Temp data, invalid (is identical to 1024x768) */ - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 438,1344, 806}, - {840, 409,1344, 806}, - {840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_2[]= +{ /* Illegal data in BIOS (Acer, Compaq) */ + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x63,0x63,0x87,0x78,0x89,0x24,0xf1, + 0xae,0x84,0x57,0x57,0x25,0x30,0x00,0x02, + 0x01}}, + {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, + 0x01}} }; -static const SiS310_LVDSDataStruct SiS310_LVDS1280x768Data_2[]= /* TW: New - TODO */ -{ /* TW: Temp data, invalid (is identical to 1024x768) */ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_2_H[]= +{ /* Illegal data in BIOS (Acer, Compaq) */ + {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, + 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, + 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, + 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, + 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, + 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x4f,0x31,0x31,0x93,0x3e,0x86,0x24,0xf1, + 0xae,0x84,0x57,0x57,0x25,0x30,0x00,0x01, + 0x01 }}, + {{0x4f,0x3f,0x3f,0x93,0x45,0x0d,0x24,0xf5, + 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x01, + 0x01 }} }; -/* TW: New: - from 300 series */ -static const SiS310_LVDSDataStruct SiS310_LVDS1024x600Data_1[]= +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_1[]= { - {840, 604,1344, 800}, - {840, 560,1344, 800}, - {840, 604,1344, 800}, - {840, 560,1344, 800}, - {840, 689,1344, 800}, - {1050, 800,1344, 800}, - {1344, 800,1344, 800}, - {800, 449,1280, 801}, - {800, 525,1280, 813} + {{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}} }; -/* TW: New: - from 300 series */ -static const SiS310_LVDSDataStruct SiS310_LVDS1024x600Data_2[]= +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_1_H[]= { - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {1344, 800,1344, 800}, - {800, 449,1280, 801}, - {800, 525,1280, 813} + {{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}} }; -/* TW: New: - from 300 series */ -static const SiS310_LVDSDataStruct SiS310_LVDS1152x768Data_1[]= +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_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} + {{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}} }; -/* TW: New: - from 300 series */ -static const SiS310_LVDSDataStruct SiS310_LVDS1152x768Data_2[]= +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_2_H[]= { - {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} + {{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}} }; -/* TW: New in 650/LVDS BIOS - pass 1:1 data */ -static const SiS310_LVDSDataStruct SiS310_LVDSXXXxXXXData_1[]= /* TW: New */ +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_1[]= { - { 800, 449, 800, 449}, - { 800, 449, 800, 449}, - { 900, 449, 900, 449}, - { 900, 449, 900, 449}, - { 800, 525, 800, 525}, - {1056, 628,1056, 628}, - {1344, 806,1344, 806}, - {1688, 806,1688, 806} + {{0x83,0x4F,0x4F,0x87,0x51,0x09,0xC0,0x1F, + 0x90,0x84,0x8F,0x8F,0xC1,0x30,0x00,0x06, + 0x00}}, + {{0x83,0x4F,0x4F,0x87,0x51,0x09,0x8E,0x1F, + 0x5E,0x82,0x5D,0x5D,0x8F,0x10,0x00,0x06, + 0x00}}, + {{0x83,0x4F,0x4F,0x87,0x51,0x09,0xC0,0x1F, + 0x90,0x84,0x8F,0x8F,0xC1,0x30,0x00,0x06, + 0x00}}, + {{0x83,0x4F,0x4F,0x87,0x51,0x09,0x8E,0x1F, + 0x5E,0x82,0x5D,0x5D,0x8F,0x10,0x00,0x06, + 0x00}}, + {{0x83,0x4F,0x4F,0x87,0x51,0x09,0x10,0x3E, + 0xE0,0x84,0xDF,0xDF,0x11,0x00,0x00,0x06, + 0x00}}, + {{0x97,0x63,0x63,0x9B,0x65,0x1D,0x88,0xF0, + 0x58,0x8C,0x57,0x57,0x89,0x20,0x00,0x06, + 0x01}}, + {{0xB3,0x7F,0x7F,0x97,0x81,0x99,0x30,0xF5, + 0x00,0x84,0xFF,0xFF,0x31,0x10,0x00,0x02, + 0x01}}, + {{0xD3,0x9F,0x9F,0x97,0xA1,0x19,0x30,0x5A, + 0x00,0x84,0xFF,0xFF,0x31,0x09,0x00,0x07, + 0x01}}, + {{0xE2,0xAE,0xAE,0x86,0xB0,0x88,0x4A,0x10, + 0x1A,0x8E,0x19,0x19,0x4B,0x2F,0x00,0x03, + 0x00}}, + {{0xFB,0xC7,0xC7,0x9F,0xC9,0x81,0xE0,0x10, + 0xB0,0x84,0xAF,0xAF,0xE1,0x2F,0x00,0x07, + 0x00}} }; -static const SiS310_LVDSDataStruct SiS310_LVDS640x480Data_1[]= /* TW: New */ +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_1_H[]= { - {800, 449, 800, 449}, - {800, 449, 800, 449}, - {800, 449, 800, 449}, - {800, 449, 800, 449}, - {800, 525, 800, 525}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628}, - {1056, 628,1056, 628} + {{0x69,0x27,0x27,0x8D,0x30,0x88,0xC0,0x1F, + 0x90,0x84,0x8F,0x8F,0xC1,0x30,0x00,0x01, + 0x00}}, + {{0x69,0x27,0x27,0x8D,0x30,0x88,0x8E,0x1F, + 0x5E,0x82,0x5D,0x5D,0x87,0x10,0x00,0x01, + 0x00}}, + {{0x69,0x27,0x27,0x8D,0x30,0x88,0xC0,0x1F, + 0x90,0x84,0x8F,0x8F,0xC1,0x30,0x00,0x01, + 0x00}}, + {{0x69,0x27,0x27,0x8D,0x30,0x88,0x8E,0x1F, + 0x5E,0x82,0x5D,0x5D,0x87,0x10,0x00,0x01, + 0x00}}, + {{0x69,0x27,0x27,0x8D,0x30,0x88,0x10,0x3E, + 0xE0,0x84,0xDF,0xDF,0x11,0x00,0x00,0x01, + 0x00}}, + {{0x73,0x31,0x31,0x97,0x3A,0x92,0x88,0xF0, + 0x58,0x8C,0x57,0x57,0x89,0x20,0x00,0x01, + 0x01}}, + {{0x81,0x3F,0x3F,0x85,0x48,0x00,0x30,0xF5, + 0x00,0x84,0xFF,0xFF,0x31,0x10,0x00,0x06, + 0x01}}, + {{0x91,0x4F,0x4F,0x95,0x58,0x10,0x30,0x5A, + 0x00,0x84,0xFF,0xFF,0x31,0x09,0x00,0x06, + 0x01}}, + {{0xD4,0x9F,0x9F,0x98,0xA8,0x00,0x30,0x5A, + 0x00,0x84,0xFF,0xFF,0x31,0x09,0x00,0x03, + 0x01}}, + {{0xA5,0x63,0x63,0x89,0x6C,0x84,0xE0,0x10, + 0xB0,0x84,0xAF,0xAF,0xE1,0x2F,0x00,0x02, + 0x00}} }; -static const SiS310_LVDSDataStruct SiS310_LVDS1280x960Data_1[]= /* TW: New */ +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_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} + {{0x09,0x4F,0x4F,0x8D,0xA3,0x1B,0xE0,0x9E, + 0x37,0x8B,0x8F,0x8F,0xE1,0x21,0x01,0x04, + 0x00}}, + {{0x09,0x4F,0x4F,0x8D,0xA3,0x1B,0xE0,0x9E, + 0x1E,0x82,0x5D,0x5D,0xE1,0x01,0x01,0x04, + 0x00}}, + {{0x09,0x4F,0x4F,0x8D,0xA3,0x1B,0xE0,0x9E, + 0x37,0x8B,0x8F,0x8F,0xE1,0x21,0x01,0x04, + 0x00}}, + {{0x09,0x4F,0x4F,0x8D,0xA3,0x1B,0xE0,0x9E, + 0x1E,0x82,0x5D,0x5D,0xE1,0x01,0x01,0x04, + 0x00}}, + {{0x09,0x4F,0x4F,0x8D,0xA3,0x1B,0xE0,0x9E, + 0x5F,0x83,0xDF,0xDF,0xE1,0x01,0x01,0x04, + 0x00}}, + {{0x09,0x63,0x63,0x8D,0xAD,0x05,0xE0,0xD4, + 0x9B,0x8F,0x57,0x57,0xE1,0x21,0x01,0x00, + 0x01}}, + {{0x09,0x7F,0x7F,0x8D,0xBB,0x13,0xE0,0xD4, + 0xEF,0x83,0xFF,0xFF,0xE1,0x21,0x01,0x00, + 0x01}}, + {{0x09,0x9F,0x9F,0x8D,0xCB,0x03,0xE0,0x5A, + 0x6F,0x83,0xFF,0xFF,0xE1,0x29,0x01,0x04, + 0x01}}, + {{0xD4,0x9F,0x9F,0x98,0xA8,0x00,0x30,0x5A, + 0x00,0x84,0xFF,0xFF,0x31,0x09,0x00,0x03, + 0x01}}, + {{0x09,0xC7,0xC7,0x8D,0xDF,0x17,0xE0,0x10, + 0xC7,0x8B,0xAF,0xAF,0xE1,0x0F,0x01,0x04, + 0x00}} }; -static const SiS310_LVDSDataStruct SiS310_LVDS1280x960Data_2[]= /* TW: New */ +static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_2_H[]= { - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS310_LVDSDataStruct SiS310_LCDA1400x1050Data_1[]= /* TW: New */ -{ /* TW: Might be temporary (invalid) data */ - {928, 416, 1688, 1066}, - {928, 366, 1688, 1066}, - {1008, 416, 1688, 1066}, - {1008, 366, 1688, 1066}, - {1200, 530, 1688, 1066}, - {1088, 616, 1688, 1066}, - {1312, 784, 1688, 1066}, - {1568, 1040, 1688, 1066}, - {1688, 1066, 1688, 1066} -}; - -static const SiS310_LVDSDataStruct SiS310_LCDA1400x1050Data_2[]= /* TW: New */ -{ /* TW: Temporary data. Not valid */ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} -}; - -static const SiS310_LVDSDataStruct SiS310_LCDA1600x1200Data_1[]= /* TW: New */ -{ /* TW: Temporary data. Not valid */ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {800, 449,1280, 801}, - {800, 525,1280, 813} + {{0xE1,0x27,0x27,0x85,0x7B,0x93,0xE0,0x9E, + 0x37,0x8B,0x8F,0x8F,0xE1,0x21,0x00,0x03, + 0x00}}, + {{0xE1,0x27,0x27,0x85,0x7B,0x93,0xE0,0x9E, + 0x1E,0x82,0x5D,0x5D,0xE1,0x01,0x00,0x03, + 0x00}}, + {{0xE1,0x27,0x27,0x85,0x7B,0x93,0xE0,0x9E, + 0x37,0x8B,0x8F,0x8F,0xE1,0x21,0x00,0x03, + 0x00}}, + {{0xE1,0x27,0x27,0x85,0x7B,0x93,0xE0,0x9E, + 0x1E,0x82,0x5D,0x5D,0xE1,0x01,0x00,0x03, + 0x00}}, + {{0xE1,0x27,0x27,0x85,0x7B,0x93,0xE0,0x9E, + 0x5F,0x83,0xDF,0xDF,0xE1,0x01,0x00,0x03, + 0x00}}, + {{0xD7,0x31,0x31,0x9B,0x7B,0x13,0xE0,0xD4, + 0x9B,0x8F,0x57,0x57,0xE1,0x21,0x00,0x03, + 0x01}}, + {{0xC9,0x3F,0x3F,0x8D,0x7B,0x13,0xE0,0xD4, + 0xEF,0x83,0xFF,0xFF,0xE1,0x21,0x00,0x03, + 0x01}}, + {{0xB9,0x4F,0x4F,0x9D,0x7B,0x93,0xE0,0x5A, + 0x6F,0x83,0xFF,0xFF,0xE1,0x29,0x00,0x02, + 0x01}}, + {{0xD4,0x9F,0x9F,0x98,0xA8,0x00,0x30,0x5A, + 0x00,0x84,0xFF,0xFF,0x31,0x09,0x00,0x03, + 0x01}}, + {{0xA5,0x63,0x63,0x89,0x7B,0x93,0xE0,0x10, + 0xC7,0x8B,0xAF,0xAF,0xE1,0x0F,0x00,0x02, + 0x00}} }; -static const SiS310_LVDSDataStruct SiS310_LCDA1600x1200Data_2[]= /* TW: New */ -{ /* TW: Temporary data. Not valid */ - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0} -}; -static const SiS310_LVDSDataStruct SiS310_CHTVUNTSCData[]= /* TW: New */ -{ - { 840, 600, 840, 600}, - { 840, 600, 840, 600}, - { 840, 600, 840, 600}, - { 840, 600, 840, 600}, - { 784, 600, 784, 600}, - {1064, 750,1064, 750}, - {1160, 945,1160, 945} /* TW: For Ch7019 1024 */ -}; +/**************************************************************/ +/* LVDS, CHRONTEL ------------------------------------------- */ +/**************************************************************/ -static const SiS310_LVDSDataStruct SiS310_CHTVONTSCData[]= /* TW: New */ +typedef struct _SiS310_LVDSDataStruct { - { 840, 525, 840, 525}, - { 840, 525, 840, 525}, - { 840, 525, 840, 525}, - { 840, 525, 840, 525}, - { 784, 525, 784, 525}, - {1040, 700,1040, 700}, - {1160, 840,1160, 840} /* TW: For Ch7019 1024 */ -}; + USHORT VGAHT; + USHORT VGAVT; + USHORT LCDHT; + USHORT LCDVT; +} SiS310_LVDSDataStruct; -static const SiS310_LVDSDataStruct SiS310_CHTVUPALData[]= /* TW: New */ +static const SiS310_LVDSDataStruct SiS310_CHTVUPALData[]= { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -2092,10 +1675,10 @@ static const SiS310_LVDSDataStruct SiS310_CHTVUPALData[]= /* TW: New */ {1008, 625,1008, 625}, { 840, 625, 840, 625}, { 960, 750, 960, 750}, - {1400,1000,1400,1000} /* TW: For Ch7019 1024 */ + {1400,1000,1400,1000} }; -static const SiS310_LVDSDataStruct SiS310_CHTVOPALData[]= /* TW: New */ +static const SiS310_LVDSDataStruct SiS310_CHTVOPALData[]= { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -2103,10 +1686,10 @@ static const SiS310_LVDSDataStruct SiS310_CHTVOPALData[]= /* TW: New */ {1008, 625,1008, 625}, { 840, 625, 840, 625}, { 944, 625, 944, 625}, - {1400, 875,1400, 875} /* TW: For Ch7019 1024 */ + {1400, 875,1400, 875} }; -static const SiS310_LVDSDataStruct SiS310_CHTVUPALMData[]= /* TW: New */ +static const SiS310_LVDSDataStruct SiS310_CHTVUPALMData[]= { { 840, 600, 840, 600}, { 840, 600, 840, 600}, @@ -2114,10 +1697,10 @@ static const SiS310_LVDSDataStruct SiS310_CHTVUPALMData[]= /* TW: New */ { 840, 600, 840, 600}, { 784, 600, 784, 600}, {1064, 750,1064, 750}, - {1160, 945,1160, 945} /* TW: For Ch7019 1024 */ + {1160, 945,1160, 945} }; -static const SiS310_LVDSDataStruct SiS310_CHTVOPALMData[]= /* TW: New */ +static const SiS310_LVDSDataStruct SiS310_CHTVOPALMData[]= { { 840, 525, 840, 525}, { 840, 525, 840, 525}, @@ -2125,10 +1708,10 @@ static const SiS310_LVDSDataStruct SiS310_CHTVOPALMData[]= /* TW: New */ { 840, 525, 840, 525}, { 784, 525, 784, 525}, {1040, 700,1040, 700}, - {1160, 840,1160, 840} /* TW: For Ch7019 1024 */ + {1160, 840,1160, 840} }; -static const SiS310_LVDSDataStruct SiS310_CHTVUPALNData[]= /* TW: New */ +static const SiS310_LVDSDataStruct SiS310_CHTVUPALNData[]= { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -2136,10 +1719,10 @@ static const SiS310_LVDSDataStruct SiS310_CHTVUPALNData[]= /* TW: New */ {1008, 625,1008, 625}, { 840, 625, 840, 625}, { 960, 750, 960, 750}, - {1400,1000,1400,1000} /* TW: For Ch7019 1024 */ + {1400,1000,1400,1000} }; -static const SiS310_LVDSDataStruct SiS310_CHTVOPALNData[]= /* TW: New */ +static const SiS310_LVDSDataStruct SiS310_CHTVOPALNData[]= { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -2147,10 +1730,10 @@ static const SiS310_LVDSDataStruct SiS310_CHTVOPALNData[]= /* TW: New */ {1008, 625,1008, 625}, { 840, 625, 840, 625}, { 944, 625, 944, 625}, - {1400, 875,1400, 875} /* TW: For Ch7019 1024 */ + {1400, 875,1400, 875} }; -static const SiS310_LVDSDataStruct SiS310_CHTVSOPALData[]= /* TW: New (super overscan - no effect on 7019) */ +static const SiS310_LVDSDataStruct SiS310_CHTVSOPALData[]= /* TW: (super overscan - no effect on 7019) */ { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -2167,9 +1750,7 @@ typedef struct _SiS310_LVDSDesStruct USHORT LCDVDES; } SiS310_LVDSDesStruct; -/* TW: PanelType arrays taken from 650/LVDS BIOS 1.10.0 */ - -static const SiS310_LVDSDesStruct SiS310_PanelType00_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType00_1[]= /* 800x600 */ { { 0, 0}, { 0, 0}, @@ -2182,7 +1763,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType00_1[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType01_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType01_1[]= /* 1024x768 */ { { 0, 0}, { 0, 0}, @@ -2195,7 +1776,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType01_1[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType02_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType02_1[]= /* 1280x1024 */ { { 0, 0}, { 0, 0}, @@ -2210,7 +1791,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType02_1[]= /* TW: New */ }; -static const SiS310_LVDSDesStruct SiS310_PanelType03_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType03_1[]= { { 0, 0}, { 0, 0}, @@ -2223,7 +1804,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType03_1[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType04_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType04_1[]= { {1343, 798}, {1343, 794}, @@ -2236,7 +1817,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType04_1[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType05_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType05_1[]= { {1343, 798}, {1343, 794}, @@ -2249,7 +1830,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType05_1[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType06_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType06_1[]= { {1343, 798}, {1343, 794}, @@ -2262,7 +1843,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType06_1[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType07_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType07_1[]= { {1343, 798}, {1343, 794}, @@ -2275,7 +1856,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType07_1[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType08_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType08_1[]= /* 1400x1050 */ { { 0, 0}, { 0, 0}, @@ -2290,58 +1871,61 @@ static const SiS310_LVDSDesStruct SiS310_PanelType08_1[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType09_1[]= /* TW: New - to check (1280x768) */ +static const SiS310_LVDSDesStruct SiS310_PanelType09_1[]= /* 1280x768 */ { - { 0, 448}, - { 0, 448}, - { 0, 448}, - { 0, 448}, - { 0, 524}, - { 0, 627}, - { 0, 805}, - { 0, 805}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0a_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType0a_1[]= /* 1600x1200 */ { - {1059, 626}, - {1059, 624}, - {1059, 626}, - {1059, 624}, - {1059, 624}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 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 SiS310_LVDSDesStruct SiS310_PanelType0b_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType0b_1[]= /* 640x480_2 */ { - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 8, 524}, + { 0, 524} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0c_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType0c_1[]= /* 640x480_3 */ { - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 0, 524}, + { 8, 524}, + { 0, 524} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0d_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType0d_1[]= { {1343, 798}, {1343, 794}, @@ -2354,7 +1938,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0d_1[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0e_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType0e_1[]= { {1343, 798}, {1343, 794}, @@ -2367,7 +1951,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0e_1[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0f_1[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType0f_1[]= { {1343, 798}, {1343, 794}, @@ -2380,7 +1964,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0f_1[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType00_2[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType00_2[]= { {980, 528}, {980, 503}, @@ -2393,7 +1977,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType00_2[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType01_2[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType01_2[]= { {1152, 622}, {1152, 597}, @@ -2406,7 +1990,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType01_2[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType02_2[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType02_2[]= { {1368, 754}, {1368, 729}, @@ -2421,7 +2005,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType02_2[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType03_2[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType03_2[]= { { 0, 0}, { 0, 0}, @@ -2432,7 +2016,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType03_2[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType04_2[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType04_2[]= { { 0, 0}, { 0, 0}, @@ -2445,7 +2029,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType04_2[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType05_2[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType05_2[]= { {1152, 622}, {1152, 597}, @@ -2458,7 +2042,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType05_2[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType06_2[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType06_2[]= { {1152, 622}, {1152, 597}, @@ -2471,7 +2055,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType06_2[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType07_2[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType07_2[]= { {1152, 622}, {1152, 597}, @@ -2484,45 +2068,61 @@ static const SiS310_LVDSDesStruct SiS310_PanelType07_2[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType08_2[]= /* TW: New */ -{ - {976, 527}, - {976, 502}, - {976, 527}, - {976, 502}, - {976, 567}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType09_2[]= /* TW: New - to check (1280x768) */ -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType0a_2[]= /* TW: New */ -{ - {976, 527}, - {976, 502}, - {976, 527}, - {976, 502}, - {976, 567}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} +static const SiS310_LVDSDesStruct SiS310_PanelType08_2[]= /* 1400x1050 */ +{ + {1308, 741}, + {1308, 716}, + {1308, 741}, + {1308, 716}, + {1308, 781}, + {1388, 841}, + {1500, 925}, + {1628,1053}, + { 0,1065}, + { 0, 0}, + { 0, 0} +}; + +static const SiS310_LVDSDesStruct SiS310_PanelType09_2[]= /* 1280x768 */ +{ + {1083, 622}, + {1083, 597}, + {1083, 622}, + {1083, 597}, + {1083, 662}, + {1163, 722}, + {1286, 805}, + { 0, 794}, + { 0, 0} +}; + +static const SiS310_LVDSDesStruct SiS310_PanelType0a_2[]= /* 1600x1200 */ +{ + {1568, 920}, + {1568, 895}, + {1568, 920}, + {1568, 895}, + {1568, 960}, + {1648,1020}, + {1760,1104}, + {1888,1232}, + {1948,1245}, + { 0, 0} +#if 0 + {1568, 850}, + {1568, 825}, + {1568, 850}, + {1568, 825}, + {1568, 890}, + {1648, 950}, + {1760,1034}, + {1888,1162}, + {1948,1175}, + { 0, 0} +#endif }; -static const SiS310_LVDSDesStruct SiS310_PanelType0b_2[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType0b_2[]= /* 640x480_2 */ { {1152, 622}, {1152, 597}, @@ -2535,7 +2135,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0b_2[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0c_2[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType0c_2[]= /* 640x480_3 */ { {1152, 622}, {1152, 597}, @@ -2548,7 +2148,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0c_2[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0d_2[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType0d_2[]= { {1152, 622}, {1152, 597}, @@ -2561,7 +2161,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0d_2[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0e_2[]= /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType0e_2[]= { {1152, 622}, {1152, 597}, @@ -2574,7 +2174,7 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0e_2[]= /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType0f_2[] = /* TW: New */ +static const SiS310_LVDSDesStruct SiS310_PanelType0f_2[] = { {1152, 622}, {1152, 597}, @@ -2587,962 +2187,102 @@ static const SiS310_LVDSDesStruct SiS310_PanelType0f_2[] = /* TW: New */ { 0, 0} }; -static const SiS310_LVDSDesStruct SiS310_PanelType1076_1[]= /* TW: New */ -{ /* 1024x768 - Checked (1.10.6s) */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1076_2[]= /* TW: New */ -{ /* 1024x768 - Checked (1.10.6s) */ - { 1184, 622 }, - { 1184, 597 }, - { 1184, 622 }, - { 1184, 597 }, - { 1152, 622 }, - { 1232, 722 }, - { 0, 0 }, - { 0, 794 }, - { 0, 0 } -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1210_1[]= /* TW: New */ -{ /* 1280x1024 - Checked (1.10.6s) */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1210_2[]= /* TW: New */ -{ /* 1280x1024 - Checked (1.10.6s) */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1296_1[]= /* TW: New */ -{ /* 1400x1050 - Checked (1.10.6s) */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1296_2[]= /* TW: New */ -{ /* 1400x1050 - Checked (1.10.6s) - looks heavily invalid */ - { 808 , 740}, - { 0 , 715}, - { 632 , 740}, - { 632 , 715}, - { 1307, 780}, - { 1387,1157}, - { 1499, 924}, - { 1627,1052}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1600_1[]= /* TW: New */ -{ /* 1600x1200 - Checked (1.10.6s) */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_PanelType1600_2[]= /* TW: New */ -{ /* 1600x1200 - Checked (1.10.6s) - looks heavily invalid */ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -static const SiS310_LVDSDesStruct SiS310_CHTVUNTSCDesData[]= -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS310_LVDSDesStruct SiS310_CHTVONTSCDesData[]= -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS310_LVDSDesStruct SiS310_CHTVUPALDesData[]= -{ - {256, 0}, - {256, 0}, - {256, 0}, - {256, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS310_LVDSDesStruct SiS310_CHTVOPALDesData[]= -{ - {256, 0}, - {256, 0}, - {256, 0}, - {256, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -typedef struct _SiS310_Part2PortTblStruct -{ - UCHAR CR[12]; -} SiS310_Part2PortTblStruct; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_1[] = -{ - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x38,0x13,0x16,0x0c,0xe6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_1[] = -{ /* TW: Temporary data, invalid */ - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_1[] = -{ /* TW: Temporary data, invalid */ - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_1[] = -{ /* TW: Temporary data, invalid */ - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_2[] = -{ - {{0x25,0x12,0x51,0x6e,0x48,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}}, - {{0x2c,0x12,0x38,0x55,0x2f,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}}, - {{0x25,0x12,0x51,0x6e,0x48,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}}, - {{0x2c,0x12,0x38,0x55,0x2f,0xc1,0x35,0xb1,0x47,0xe9,0x71,0x33}}, - {{0x2d,0x12,0x79,0x96,0x70,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}}, - {{0x29,0x12,0xb5,0xd2,0xac,0xe9,0x35,0xd9,0x47,0x11,0x99,0x33}}, - {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_2[] = -{ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_2[] = -{ - {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x33,0x13,0x01,0x0d,0xfd,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x3f,0x1b,0x3d,0x49,0x39,0x54,0x23,0xc0,0x27,0x66,0x30,0x42}}, - {{0x33,0x1b,0x91,0x9d,0x8d,0x8c,0x23,0xf8,0x27,0x9e,0x68,0x42}}, - {{0x43,0x24,0x11,0x1d,0x0d,0xcc,0x23,0x38,0x37,0xde,0xa8,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_2[] = -{ /* TW: Temporary data, invalid */ - {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x33,0x13,0x01,0x0d,0xfd,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}}, - {{0x3f,0x1b,0x3d,0x49,0x39,0x54,0x23,0xc0,0x27,0x66,0x30,0x42}}, - {{0x33,0x1b,0x91,0x9d,0x8d,0x8c,0x23,0xf8,0x27,0x9e,0x68,0x42}}, - {{0x43,0x24,0x11,0x1d,0x0d,0xcc,0x23,0x38,0x37,0xde,0xa8,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}} -}; - - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_3[] = -{ /* TW: Data from 650/301LVx 1.10.6s */ - {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x2c,0x13,0x9a,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x25,0x13,0xc9,0x24,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x38,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x25,0x13,0xc9,0x25,0xff,0xf9,0x45,0x09,0x07,0xf9,0x09,0x24}} -#if 0 /* TW: Data from 650/301LV */ - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x38,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -#endif -}; - -/* 1 2 4 5 6 1c 1d 1f 20 21 23 25 */ -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_3[] = -{ /* TW: Temporary data, invalid */ - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_3[] = -{ /* TW: Temporary data, invalid */ - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}} -}; - -static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_3[] = -{ /* TW: Temporary data, invalid */ - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}, - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}} -}; - -typedef struct _SiS310_LCDACRT1DataStruct -{ - UCHAR CR[17]; -}SiS310_LCDACRT1DataStruct; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT1800x600_1[] = -{ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_1[]= -{ /* TW: Checked (1.10.6s) */ - {{0x73,0x4f,0x4f,0x97,0x55,0x86,0xc4,0x1f, - 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, - 0x00}}, - {{0x73,0x4f,0x4f,0x97,0x55,0x86,0x97,0x1f, - 0x60,0x87,0x5d,0x5d,0x83,0x10,0x00,0x05, - 0x00}}, - {{0x73,0x4f,0x4f,0x97,0x55,0x86,0xc4,0x1f, - 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, - 0x00}}, - {{0x73,0x4f,0x4f,0x97,0x55,0x86,0x97,0x1f, - 0x60,0x87,0x5d,0x5d,0x83,0x10,0x00,0x05, - 0x00}}, - {{0x73,0x4f,0x4f,0x97,0x55,0x86,0x04,0x3e, - 0xE2,0x89,0xDf,0xDf,0x05,0x00,0x00,0x05, - 0x00}}, - {{0x87,0x63,0x63,0x8B,0x69,0x1A,0x7c,0xf0, - 0x5A,0x8F,0x57,0x57,0x7D,0x20,0x00,0x26, - 0x01}}, - {{0xA3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xFf,0xFf,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_1[]= -{ /* Checked (1.10.6s) */ - {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0xb8,0x1f, - 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0x86,0x1f, - 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0xb8,0x1f, - 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0x86,0x1f, - 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0x08,0x3e, - 0xe0,0x84,0xdf,0xdf,0x09,0x00,0x00,0x06, - 0x00}}, - {{0x92,0x63,0x63,0x96,0x6c,0x1a,0x80,0xf0, - 0x58,0x8c,0x57,0x57,0x81,0x20,0x00,0x06, - 0x01}}, - {{0xae,0x7f,0x7f,0x92,0x88,0x96,0x28,0xf5, - 0x00,0x84,0xff,0xff,0x29,0x10,0x00,0x02, - 0x01}}, - {{0xce,0x9f,0x9f,0x92,0xa8,0x16,0x28,0x5a, - 0x00,0x84,0xff,0xff,0x29,0x01,0x00,0x07, - 0x01}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_1[]= -{ /* Checked (1.10.6s) */ - {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x9e,0x1f, - 0x93,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x6c,0x1f, - 0x60,0x84,0x5d,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x9e,0x1f, - 0x93,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x6c,0x1f, - 0x60,0x84,0x5d,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0xee,0x1f, - 0xe2,0x86,0xdf,0xdf,0xef,0x10,0x00,0x05, - 0x00}}, - {{0x83,0x63,0x63,0x87,0x68,0x16,0x66,0xf0, - 0x5a,0x8e,0x57,0x57,0x67,0x20,0x00,0x06, - 0x01}}, - {{0x9f,0x7f,0x7f,0x83,0x84,0x92,0x0e,0xf5, - 0x02,0x86,0xff,0xff,0x0f,0x10,0x00,0x02, - 0x01}}, - {{0xbf,0x9f,0x9f,0x83,0xa4,0x12,0x0e,0x5a, - 0x02,0x86,0xff,0xff,0x0f,0x09,0x00,0x07, - 0x01}}, - {{0xce,0xae,0xae,0x92,0xb3,0x01,0x28,0x10, - 0x1a,0x80,0x19,0x19,0x29,0x0f,0x00,0x03, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_1[]= -{ /* MISSING */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT1800x600_1_H[]= -{ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_1_H[]= -{ /* TW: Checked (1.10.6s) */ - {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0xc4,0x1f, - 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0x97,0x1f, - 0x60,0x87,0x5D,0x5D,0x83,0x01,0x00,0x44, - 0x00}}, - {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0xc4,0x1f, - 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0x97,0x1f, - 0x60,0x87,0x5D,0x5D,0x83,0x01,0x00,0x44, - 0x00}}, - {{0x4b,0x27,0x27,0x8f,0x32,0x1b,0x04,0x3e, - 0xE2,0x89,0xDf,0xDf,0x05,0x00,0x00,0x45, - 0x00}}, - {{0x55,0x31,0x31,0x99,0x46,0x1d,0x7c,0xf0, - 0x5A,0x8F,0x57,0x57,0x7D,0x20,0x00,0x55, - 0x01}}, - {{0x63,0x3F,0x3F,0x87,0x4a,0x93,0x24,0xf5, - 0x02,0x88,0xFf,0xFf,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_1_H[]= -{ /* Checked (1.10.6s) */ - {{0x56,0x27,0x27,0x9a,0x30,0x1e,0xb8,0x1f, - 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x3c,0x4f,0x4f,0x82,0x58,0x06,0x86,0xd1, /* <-- Invalid data - one byte missing in BIOS */ - 0xbc,0x80,0xbb,0xbb,0xe5,0x00,0x00,0x06, - 0x01}}, - {{0x56,0x27,0x27,0x9a,0x30,0x1e,0xb8,0x1f, - 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x3c,0x4f,0x4f,0x82,0x58,0x06,0x86,0xd1, - 0xbc,0x80,0xbb,0xbb,0xe5,0x00,0x00,0x06, - 0x01}}, - {{0x56,0x27,0x27,0x9a,0x30,0x1e,0x08,0x3e, - 0xe0,0x84,0xdf,0xdf,0x09,0x00,0x00,0x05, - 0x00}}, - {{0x60,0x31,0x31,0x84,0x3a,0x88,0x80,0xf0, - 0x58,0x8c,0x57,0x57,0x81,0x20,0x00,0x01, - 0x01}}, - {{0x6e,0x3f,0x3f,0x92,0x48,0x96,0x28,0xf5, - 0x00,0x84,0xff,0xff,0x29,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_1_H[]= -{ /* Checked (1.10.6s) */ - {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, - 0x93,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x27,0x8b,0x30,0x1e,0x9e,0x1f, - 0x92,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0xee,0x1f, - 0xe2,0x86,0xdf,0xdf,0xef,0x10,0x00,0x05, - 0x00}}, - {{0x51,0x31,0x31,0x95,0x36,0x04,0x66,0xf0, - 0x5a,0x8e,0x57,0x57,0x67,0x20,0x00,0x01, - 0x01}}, - {{0x5f,0x3f,0x3f,0x83,0x44,0x92,0x0e,0xf5, - 0x02,0x86,0xff,0xff,0x0f,0x10,0x00,0x01, - 0x01}}, - {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x0e,0x5a, - 0x02,0x86,0xff,0xff,0x0f,0x09,0x00,0x05, - 0x01}}, - {{0x76,0x56,0x56,0x9a,0x5b,0x89,0x28,0x10, - 0x1c,0x80,0x19,0x19,0x29,0x0b,0x00,0x05, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_1_H[]= -{ /* MISSING */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; +/* CRT1 CRTC for SlaveModes and LCDA */ -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT1800x600_2[]= +typedef struct _SiS310_LVDSCRT1DataStruct { - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11024x768_2[]= -{ /* Checked (1.10.6s) */ - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_2[]= -{ /* Checked (1.10.6s) */ - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_2[]= -{ /* Checked (1.10.6s) */ - {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x03, - 0x00}}, - {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xc2,0x86,0x5d,0x5d,0x29,0x01,0x00,0x03, - 0x01}}, - {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x03, - 0x00}}, - {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xc2,0x86,0x5d,0x5d,0x29,0x01,0x00,0x03, - 0x00}}, - {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9e, - 0x03,0x87,0xdf,0xdf,0x29,0x01,0x00,0x03, - 0x00}}, - {{0xce,0x63,0x63,0x92,0x96,0x04,0x28,0xd4, - 0x3f,0x83,0x57,0x57,0x29,0x01,0x00,0x07, - 0x01}}, - {{0xce,0x7f,0x7f,0x92,0xa4,0x12,0x28,0xd4, - 0x93,0x87,0xff,0xff,0x29,0x21,0x00,0x07, - 0x01}}, - {{0xce,0x9f,0x9f,0x92,0xb4,0x02,0x28,0x5a, - 0x13,0x87,0xff,0xff,0x29,0x29,0x00,0x03, - 0x01}}, - {{0xce,0xae,0xae,0x92,0xbc,0x0a,0x28,0x10, - 0x20,0x84,0x19,0x19,0x29,0x0f,0x00,0x03, - 0x00}} -}; - -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11600x1200_2[]= -{ /* MISSING */ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00}} -}; + UCHAR CR[15]; +} SiS310_LVDSCRT1DataStruct; -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT1800x600_2_H[]= +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_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_2_H[]= -{ /* Checked (1.10.6s) */ - {{0x4f,0x27,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, + {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x8d,0x5d,0x25,0x30,0x00,0x01, /* <-- invalid data */ + {{0x6b,0x4f,0x8f,0x55,0x85,0x78,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, + {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x01, + {{0x6b,0x4f,0x8f,0x55,0x85,0x78,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x01, + {{0x6b,0x4f,0x8f,0x55,0x85,0xfa,0x1f, + 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, 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, + {{0x7f,0x63,0x83,0x69,0x19,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, 0x01 }} }; -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11280x1024_2_H[]= -{ /* Checked (1.10.6s) */ - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1_H[] = +{ + {{0x43,0x27,0x87,0x2d,0x1d,0xaa,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x01, + {{0x43,0x27,0x87,0x2d,0x1d,0x78,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01, + {{0x43,0x27,0x87,0x2d,0x1d,0xfa,0x1f, + 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x01, + {{0x43,0x27,0x87,0x2d,0x1d,0x78,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, 0x00 }}, - {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x01, + {{0x43,0x27,0x87,0x2d,0x1d,0xfa,0x1f, + 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, 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, + {{0x4d,0x31,0x91,0x37,0x07,0x72,0xf0, + 0x58,0x8d,0x57,0x73,0x20,0x00,0x01, 0x01 }} }; -static const SiS310_LCDACRT1DataStruct SiS310_LCDACRT11400x1050_2_H[]= -{ /* Checked (1.10.6s) */ - {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x06, - 0x00}}, - {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xc2,0x86,0x5d,0x5d,0x29,0x01,0x00,0x06, - 0x00}}, - {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x06, - 0x00}}, - {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xc2,0x86,0x5d,0x5d,0x29,0x01,0x00,0x06, - 0x00}}, - {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9e, - 0x03,0x87,0xdf,0xdf,0x29,0x01,0x00,0x06, - 0x00}}, - {{0x9c,0x31,0x31,0x80,0x64,0x92,0x28,0xd4, - 0x3f,0x83,0x57,0x57,0x29,0x01,0x00,0x06, - 0x01}}, - {{0x8e,0x3f,0x3f,0x92,0x64,0x12,0x28,0xd4, - 0x93,0x87,0xff,0xff,0x29,0x21,0x00,0x06, - 0x01}}, - {{0x7e,0x4f,0x4f,0x82,0x64,0x12,0x28,0x5a, - 0x13,0x87,0xff,0xff,0x29,0x29,0x00,0x06, - 0x01}}, - {{0x76,0x56,0x56,0x9a,0x64,0x92,0x28,0x10, - 0x20,0x84,0x19,0x19,0x29,0x0f,0x00,0x05, - 0x00}} -}; - -static const SiS310_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_LVDSCRT1320x480_1[] = +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_2[]= { - {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, + 0xff,0x84,0x8f,0x73,0x00,0x00,0x06, 0x00 }}, - {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, + 0xe6,0x8b,0x5d,0x73,0x00,0x00,0x06, 0x00 }}, - {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, + 0xff,0x84,0x8f,0x73,0x00,0x00,0x06, 0x00 }}, - {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, + 0xe6,0x8b,0x5d,0x73,0x00,0x00,0x06, 0x00 }}, - {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, + {{0x7f,0x4f,0x83,0x62,0x12,0x72,0xba, + 0x27,0x8c,0xdf,0x73,0x00,0x00,0x06, 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 }} + {{0x7f,0x63,0x83,0x69,0x19,0x72,0xf0, + 0x58,0x8d,0x57,0x73,0x20,0x00,0x06, + 0x01 }} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1[] = /* TW: New */ +static const SiS310_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[] = /* TW: New */ +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1[] = { {{0x73,0x4f,0x97,0x53,0x84,0xb4,0x1f, 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, @@ -3567,57 +2307,7 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1[] = /* TW: 0x01}} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1[] = /* TW: New */ -{ - {{0x7e,0x4f,0x82,0x56,0x04,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, - 0x00 }}, - {{0x7e,0x4f,0x82,0x56,0x04,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, - 0x00 }}, - {{0x7e,0x4f,0x82,0x56,0x04,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, - 0x00 }}, - {{0x7e,0x4f,0x82,0x56,0x04,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, - 0x00 }}, - {{0x7e,0x4f,0x82,0x56,0x04,0x08,0x3e, - 0xe0,0x84,0xdf,0x09,0x00,0x00,0x06, - 0x00 }}, - {{0x92,0x63,0x96,0x6a,0x18,0x80,0xf0, - 0x58,0x8c,0x57,0x81,0x20,0x00,0x06, - 0x01 }}, - {{0xae,0x7f,0x92,0x86,0x94,0x28,0xf5, - 0x00,0x84,0xff,0x29,0x10,0x00,0x02, - 0x01 }}, - {{0xce,0x9f,0x92,0xa6,0x14,0x28,0x5a, - 0x00,0x84,0xff,0x29,0x09,0x00,0x07, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1_H[] = /* TW: New */ -{ - {{0x43,0x27,0x87,0x2d,0x1d,0xaa,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, - 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0x78,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, - 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0xfa,0x1f, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, - 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0x78,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, - 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0xfa,0x1f, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, - 0x00 }}, - {{0x4d,0x31,0x91,0x37,0x07,0x72,0xf0, - 0x58,0x8d,0x57,0x73,0x20,0x00,0x01, - 0x01 }} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1_H[] = /* TW: New */ +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1_H[] = { {{0x4b,0x27,0x8f,0x2b,0x1c,0xb4,0x1f, 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, @@ -3642,55 +2332,8 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1_H[] = /* TW 0x01 }} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1_H[] = /* TW: New */ -{ - {{0x56,0x27,0x9a,0x2e,0x1c,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, - 0x00 }}, - {{0x56,0x27,0x9a,0x2e,0x1c,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x05, - 0x00 }}, - {{0x56,0x27,0x9a,0x2e,0x1c,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, - 0x00 }}, - {{0x56,0x27,0x9a,0x2e,0x1c,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x05, - 0x01 }}, - {{0x56,0x27,0x9a,0x2e,0x1c,0x08,0x3e, - 0xe0,0x84,0xdf,0x09,0x00,0x00,0x05, - 0x00 }}, - {{0x60,0x31,0x84,0x38,0x86,0x80,0xf0, - 0x58,0x8c,0x57,0x81,0x20,0x00,0x01, - 0x01 }}, - {{0x6e,0x3f,0x92,0x46,0x94,0x28,0xf5, - 0x00,0x84,0xff,0x29,0x10,0x00,0x01, - 0x01 }} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_2[]= /* TW: New */ +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_2[] = { - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xff,0x84,0x8f,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xe6,0x8b,0x5d,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xff,0x84,0x8f,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xe6,0x8b,0x5d,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0xba, - 0x27,0x8c,0xdf,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x63,0x83,0x69,0x19,0x72,0xf0, - 0x58,0x8d,0x57,0x73,0x20,0x00,0x06, - 0x01 }} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_2[] = /* TW: New */ -{ {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, 0x57,0x8e,0x8f,0x25,0x30,0x00,0x06, 0x00 }}, @@ -3714,58 +2357,8 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_2[] = /* TW: N 0x01 }} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2[] = /* TW: New */ -{ - {{0xce,0x4f,0x92,0x81,0x0f,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x03, - 0x00 }}, - {{0xce,0x4f,0x92,0x81,0x0f,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x03, - 0x00 }}, - {{0xce,0x4f,0x92,0x81,0x0f,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x03, - 0x00 }}, - {{0xce,0x4f,0x92,0x81,0x0f,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x03, - 0x00 }}, - {{0xce,0x4f,0x92,0x81,0x0f,0x28,0x9e, - 0x03,0x87,0xdf,0x29,0x01,0x00,0x03, - 0x00 }}, - {{0xce,0x63,0x92,0x8b,0x19,0x28,0xd4, - 0x3f,0x83,0x57,0x29,0x01,0x00,0x03, - 0x01 }}, - {{0xce,0x7f,0x92,0x99,0x07,0x28,0xd4, - 0x93,0x87,0xff,0x29,0x21,0x00,0x07, - 0x01 }}, - {{0xce,0x9f,0x92,0xa6,0x14,0x28,0x5a, - 0x00,0x84,0xff,0x29,0x09,0x00,0x07, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_2_H[] = /* TW: New */ +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_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[] = /* TW: New */ -{ {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, 0x57,0x8e,0x8f,0x25,0x30,0x00,0x01, 0x00 }}, @@ -3789,86 +2382,142 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_2_H[] = /* TW: 0x01 }} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2_H[] = /* TW: New */ -{ - {{0xa6,0x27,0x8a,0x59,0x87,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x06, - 0x00 }}, - {{0xa6,0x27,0x8a,0x59,0x87,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x06, - 0x00 }}, - {{0xa6,0x27,0x8a,0x59,0x87,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x06, - 0x00 }}, - {{0xa6,0x27,0x8a,0x59,0x87,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x06, - 0x00 }}, - {{0xa6,0x27,0x8a,0x59,0x87,0x28,0x9e, - 0x03,0x87,0xdf,0x29,0x01,0x00,0x06, - 0x00 }}, - {{0x9c,0x31,0x80,0x59,0x87,0x28,0xd4, - 0x3f,0x83,0x57,0x29,0x01,0x00,0x06, - 0x01 }}, - {{0x8e,0x3f,0x92,0x79,0x07,0x28,0xd4, - 0x93,0x87,0xff,0x29,0x21,0x00,0x06, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1XXXxXXX_1[] = /* TW: New */ +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1[] = { - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, + {{0x7e,0x4f,0x82,0x58,0x04,0xb8,0x1f, + 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, + {{0x7e,0x4f,0x82,0x58,0x04,0x86,0x1f, + 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, + {{0x7e,0x4f,0x82,0x58,0x04,0xb8,0x1f, + 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, + {{0x7e,0x4f,0x82,0x58,0x04,0x86,0x1f, + 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, - 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x05, + {{0x7e,0x4f,0x82,0x58,0x04,0x08,0x3e, + 0xe0,0x84,0xdf,0x09,0x00,0x00,0x06, 0x00}}, - {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + {{0x92,0x63,0x96,0x6c,0x18,0x80,0xf0, + 0x58,0x8c,0x57,0x81,0x20,0x00,0x06, 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + {{0xae,0x7f,0x92,0x88,0x94,0x28,0xf5, + 0x00,0x84,0xff,0x29,0x10,0x00,0x02, 0x01}}, - {{0xce,0x9f,0x92,0xa9,0x17,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x07, + {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a, + 0x00,0x84,0xff,0x29,0x09,0x00,0x07, 0x01}} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT1XXXxXXX_1_H[] = /* TW: New */ +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_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, + {{0x56,0x27,0x9a,0x31,0x1c,0xb8,0x1f, + 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, + {{0x56,0x27,0x9a,0x31,0x1c,0x86,0x1f, + 0x5e,0x82,0x5d,0x87,0x10,0x00,0x05, 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, + {{0x56,0x27,0x9a,0x31,0x1c,0xb8,0x1f, + 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0x0b,0x3e, - 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + {{0x56,0x27,0x9a,0x31,0x1c,0x86,0x1f, + 0x5e,0x82,0x5d,0x87,0x10,0x00,0x05, + 0x01}}, + {{0x56,0x27,0x9a,0x31,0x1c,0x08,0x3e, + 0xe0,0x84,0xdf,0x09,0x00,0x00,0x05, 0x00}}, - {{0x4d,0x31,0x91,0x3b,0x03,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x01, + {{0x60,0x31,0x84,0x3a,0x86,0x80,0xf0, + 0x58,0x8c,0x57,0x81,0x20,0x00,0x01, + 0x01}}, + {{0x6e,0x3f,0x92,0x48,0x94,0x28,0xf5, + 0x00,0x84,0xff,0x29,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2[] = +{ + {{0xce,0x72,0x91,0x81,0x8f,0x28,0x92, + 0xc8,0x8c,0x5d,0x5c,0x01,0x00,0x02, + 0x01}}, + {{0xce,0x72,0x91,0x81,0x8f,0x28,0x92, + 0xaf,0x83,0x44,0x43,0x21,0x00,0x02, + 0x01}}, + {{0xce,0x72,0x91,0x81,0x8f,0x28,0x92, + 0xc8,0x8c,0x5d,0x5c,0x01,0x00,0x02, + 0x01}}, + {{0xce,0x72,0x91,0x81,0x8f,0x28,0x92, + 0xaf,0x83,0x44,0x43,0x21,0x00,0x02, 0x01}}, - {{0x63,0x3f,0x87,0x4a,0x92,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, + {{0xce,0x72,0x91,0x81,0x8f,0x28,0x92, + 0xf0,0x84,0x85,0x84,0x11,0x00,0x02, + 0x01}}, + {{0xce,0x63,0x92,0x8b,0x19,0x28,0xd4, + 0x3f,0x83,0x57,0x29,0x01,0x00,0x03, + 0x01}}, + {{0xce,0x7f,0x92,0x99,0x07,0x28,0xd4, + 0x93,0x87,0xff,0x29,0x21,0x00,0x07, + 0x01}}, + {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a, + 0x00,0x84,0xff,0x29,0x09,0x00,0x07, + 0x01}} +}; + +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2_H[] = +{ + {{0xa6,0x4a,0x89,0x59,0x07,0x28,0x92, + 0xc8,0x8c,0x5d,0x5c,0x01,0x00,0x06, + 0x01}}, + {{0xa6,0x4a,0x89,0x59,0x07,0x28,0x92, + 0xaf,0x83,0x44,0x43,0x21,0x00,0x06, + 0x01}}, + {{0xa6,0x4a,0x89,0x59,0x07,0x28,0x92, + 0xc8,0x8c,0x5d,0x5c,0x01,0x00,0x06, + 0x01}}, + {{0xa6,0x4a,0x89,0x59,0x07,0x28,0x92, + 0xfa,0x83,0x44,0x43,0x31,0x00,0x06, + 0x01}}, + {{0xa6,0x4a,0x89,0x59,0x07,0x28,0x92, + 0xf0,0x84,0x85,0x84,0x11,0x00,0x06, + 0x01}}, + {{0x9c,0x31,0x80,0x59,0x87,0x28,0xd4, + 0x3f,0x83,0x57,0x29,0x01,0x00,0x06, + 0x01}}, + {{0x8e,0x3f,0x92,0x59,0x07,0x28,0xd4, + 0x93,0x87,0xff,0x29,0x21,0x00,0x06, 0x01}} }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1[] = /* TW: New */ +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1[] = { + {{0x6f,0x4f,0x93,0x54,0x82,0x9e,0x1f, + 0x8f,0x81,0x8f,0x9f,0x30,0x00,0x05, + 0x00}}, + {{0x6f,0x4f,0x93,0x54,0x82,0x6c,0x1f, + 0x5e,0x81,0x5d,0x6d,0x10,0x00,0x05, + 0x00}}, + {{0x6f,0x4f,0x93,0x54,0x82,0x9e,0x1f, + 0x90,0x83,0x8f,0x9f,0x30,0x00,0x05, + 0x00}}, + {{0x6f,0x4f,0x93,0x54,0x82,0x6c,0x1f, + 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, + 0x00}}, + {{0x6f,0x4f,0x93,0x54,0x82,0xee,0x1f, + 0xdf,0x82,0xdf,0xef,0x10,0x00,0x05, + 0x00}}, + {{0x83,0x63,0x87,0x68,0x16,0x66,0xf0, + 0x57,0x8e,0x57,0x67,0x20,0x00,0x06, + 0x01}}, + {{0x9f,0x7f,0x83,0x84,0x92,0x0e,0xf1, + 0xff,0x86,0xff,0x0f,0x10,0x00,0x02, + 0x01,}}, + {{0xbf,0x9f,0x83,0xa4,0x12,0x0e,0xde, + 0xff,0x86,0xff,0x0f,0x01,0x00,0x07, + 0x01}}, + {{0xce,0xae,0x92,0xb3,0x01,0x28,0x10, + 0x19,0x80,0x19,0x29,0x0f,0x00,0x03, + 0x00}} +#if 0 {{0x6f,0x4f,0x93,0x54,0x82,0x9e,0x1f, 0x93,0x86,0x8f,0x9f,0x30,0x00,0x05, 0x00}}, @@ -3896,11 +2545,40 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1[] = /* TW: {{0xce,0xae,0x92,0xb3,0x01,0x28,0x10, 0x1a,0x80,0x19,0x29,0x0f,0x00,0x03, 0x00}} +#endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1_H[] = /* TW: New */ +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1_H[] = { {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, + 0x8f,0x81,0x8f,0x9f,0x30,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, + 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x8b,0x30,0x1e,0x9e,0x1f, + 0x90,0x83,0x8f,0x9f,0x30,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, + 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x8b,0x2c,0x1a,0xee,0x1f, + 0xdf,0x86,0xdf,0xef,0x10,0x00,0x05, + 0x00}}, + {{0x51,0x31,0x95,0x36,0x04,0x66,0xf0, + 0x57,0x8e,0x57,0x67,0x20,0x00,0x01, + 0x01}}, + {{0x5f,0x3f,0x83,0x44,0x92,0x0e,0xf1, + 0xff,0x86,0xff,0x0f,0x10,0x00,0x01, + 0x01}}, + {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a, + 0x02,0x86,0xff,0x0f,0x09,0x00,0x05, + 0x01}}, + {{0x76,0x56,0x9a,0x5b,0x89,0x28,0x10, + 0x1c,0x80,0x19,0x29,0x0b,0x00,0x05, + 0x00}} +#if 0 + {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, 0x93,0x86,0x8f,0x9f,0x30,0x00,0x05, 0x00}}, {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, @@ -3927,10 +2605,39 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1_H[] = /* TW {{0x76,0x56,0x9a,0x5b,0x89,0x28,0x10, 0x1c,0x80,0x19,0x29,0x0b,0x00,0x05, 0x00}} +#endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2[] = /* TW: New */ +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2[] = { + {{0xce,0x72,0x91,0x84,0x92,0x28,0x92, + 0xd7,0x8b,0x5d,0x5c,0x21,0x00,0x02, + 0x01}}, + {{0xce,0x72,0x91,0x84,0x92,0x28,0x92, + 0xbe,0x82,0x44,0x43,0x01,0x00,0x02, + 0x01}}, + {{0xce,0x72,0x91,0x84,0x92,0x28,0x92, + 0xd7,0x8b,0x5d,0x5c,0x21,0x00,0x02, + 0x01}}, + {{0xce,0x72,0x91,0x84,0x92,0x28,0x92, + 0xbe,0x82,0x44,0x43,0x01,0x00,0x02, + 0x01}}, + {{0xce,0x72,0x91,0x84,0x92,0x28,0x92, + 0xff,0x83,0x85,0x84,0x11,0x00,0x02, + 0x01}}, + {{0xce,0x63,0x92,0x8e,0x1c,0x28,0xd4, + 0x3f,0x83,0x57,0x29,0x01,0x00,0x03, + 0x01}}, + {{0xce,0x7f,0x92,0x9c,0x0a,0x28,0xd4, + 0x93,0x87,0xff,0x29,0x21,0x00,0x07, + 0x01}}, + {{0xce,0x9f,0x92,0xac,0x1a,0x28,0x5a, + 0x13,0x87,0xff,0x29,0x29,0x00,0x07, + 0x01}}, + {{0xce,0xae,0x92,0xbc,0x0a,0x28,0x10, + 0x20,0x84,0x19,0x29,0x0f,0x00,0x03, + 0x00}} +#if 0 {{0xce,0x4f,0x92,0x8c,0x1a,0x28,0x9a, 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x03, 0x00}}, @@ -3958,10 +2665,39 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2[] = /* TW: {{0xce,0xae,0x92,0xbc,0x0a,0x28,0x10, 0x20,0x84,0x19,0x29,0x0f,0x00,0x03, 0x00}} +#endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2_H[] = /* TW: New */ +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2_H[] = { + {{0xa6,0x4a,0x89,0x5c,0x0a,0x28,0x92, + 0xd7,0x8b,0x5d,0x5c,0x21,0x00,0x06, + 0x01}}, + {{0xa6,0x4a,0x89,0x5c,0x0a,0x28,0x92, + 0xbe,0x82,0x44,0x43,0x01,0x00,0x06, + 0x01}}, + {{0xa6,0x4a,0x89,0x5c,0x0a,0x28,0x92, + 0xd7,0x8b,0x5d,0x5c,0x21,0x00,0x06, + 0x01}}, + {{0xa6,0x4a,0x89,0x5c,0x0a,0x28,0x92, + 0xbe,0x82,0x44,0x43,0x01,0x00,0x06, + 0x01}}, + {{0xa6,0x4a,0x89,0x5c,0x0a,0x28,0x92, + 0xff,0x83,0x85,0x84,0x11,0x00,0x06, + 0x01}}, + {{0x9c,0x31,0x80,0x5c,0x8a,0x28,0xd4, + 0x3f,0x83,0x57,0x29,0x01,0x00,0x06, + 0x01}}, + {{0x8e,0x3f,0x92,0x5c,0x0a,0x28,0xd4, + 0x93,0x87,0xff,0x29,0x21,0x00,0x06, + 0x01}}, + {{0x7e,0x4f,0x82,0x5c,0x0a,0x28,0x5a, + 0x13,0x87,0xff,0x29,0x29,0x00,0x06, + 0x01}}, + {{0x76,0x56,0x9a,0x64,0x92,0x28,0x10, + 0x20,0x84,0x19,0x29,0x0f,0x00,0x05, + 0x00}} +#if 0 {{0xa6,0x27,0x8a,0x64,0x92,0x28,0x9a, 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x06, 0x00}}, @@ -3989,565 +2725,375 @@ static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2_H[] = /* T {{0x76,0x56,0x9a,0x64,0x92,0x28,0x10, 0x20,0x84,0x19,0x29,0x0f,0x00,0x05, 0x00}} +#endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x768_1[] = /* TW: New */ -{ /* TW: Temp data, invalid */ - {{0x7e,0x4f,0x82,0x56,0x04,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, - 0x00 }}, - {{0x7e,0x4f,0x82,0x56,0x04,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, - 0x00 }}, - {{0x7e,0x4f,0x82,0x56,0x04,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, - 0x00 }}, - {{0x7e,0x4f,0x82,0x56,0x04,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, - 0x00 }}, - {{0x7e,0x4f,0x82,0x56,0x04,0x08,0x3e, - 0xe0,0x84,0xdf,0x09,0x00,0x00,0x06, - 0x00 }}, - {{0x92,0x63,0x96,0x6a,0x18,0x80,0xf0, - 0x58,0x8c,0x57,0x81,0x20,0x00,0x06, - 0x01 }}, - {{0xae,0x7f,0x92,0x86,0x94,0x28,0xf5, - 0x00,0x84,0xff,0x29,0x10,0x00,0x02, - 0x01 }}, - {{0xce,0x9f,0x92,0xa6,0x14,0x28,0x5a, - 0x00,0x84,0xff,0x29,0x09,0x00,0x07, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x768_1_H[] = /* TW: New */ -{ /* TW: Temp data, invalid */ - {{0x56,0x27,0x9a,0x2e,0x1c,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, - 0x00 }}, - {{0x56,0x27,0x9a,0x2e,0x1c,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x05, - 0x00 }}, - {{0x56,0x27,0x9a,0x2e,0x1c,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, - 0x00 }}, - {{0x56,0x27,0x9a,0x2e,0x1c,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x05, - 0x01 }}, - {{0x56,0x27,0x9a,0x2e,0x1c,0x08,0x3e, - 0xe0,0x84,0xdf,0x09,0x00,0x00,0x05, - 0x00 }}, - {{0x60,0x31,0x84,0x38,0x86,0x80,0xf0, - 0x58,0x8c,0x57,0x81,0x20,0x00,0x01, - 0x01 }}, - {{0x6e,0x3f,0x92,0x46,0x94,0x28,0xf5, - 0x00,0x84,0xff,0x29,0x10,0x00,0x01, - 0x01 }} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x768_2[] = /* TW: New */ -{ /* TW: Temp data, invalid */ - {{0xce,0x4f,0x92,0x81,0x0f,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x03, - 0x00 }}, - {{0xce,0x4f,0x92,0x81,0x0f,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x03, - 0x00 }}, - {{0xce,0x4f,0x92,0x81,0x0f,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x03, - 0x00 }}, - {{0xce,0x4f,0x92,0x81,0x0f,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x03, - 0x00 }}, - {{0xce,0x4f,0x92,0x81,0x0f,0x28,0x9e, - 0x03,0x87,0xdf,0x29,0x01,0x00,0x03, - 0x00 }}, - {{0xce,0x63,0x92,0x8b,0x19,0x28,0xd4, - 0x3f,0x83,0x57,0x29,0x01,0x00,0x03, - 0x01 }}, - {{0xce,0x7f,0x92,0x99,0x07,0x28,0xd4, - 0x93,0x87,0xff,0x29,0x21,0x00,0x07, - 0x01 }}, - {{0xce,0x9f,0x92,0xa6,0x14,0x28,0x5a, - 0x00,0x84,0xff,0x29,0x09,0x00,0x07, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11280x768_2_H[] = /* TW: New */ -{ /* TW: Temp data, invalid */ - {{0xa6,0x27,0x8a,0x59,0x87,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x06, - 0x00 }}, - {{0xa6,0x27,0x8a,0x59,0x87,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x06, - 0x00 }}, - {{0xa6,0x27,0x8a,0x59,0x87,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x06, - 0x00 }}, - {{0xa6,0x27,0x8a,0x59,0x87,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x06, - 0x00 }}, - {{0xa6,0x27,0x8a,0x59,0x87,0x28,0x9e, - 0x03,0x87,0xdf,0x29,0x01,0x00,0x06, - 0x00 }}, - {{0x9c,0x31,0x80,0x59,0x87,0x28,0xd4, - 0x3f,0x83,0x57,0x29,0x01,0x00,0x06, - 0x01 }}, - {{0x8e,0x3f,0x92,0x79,0x07,0x28,0xd4, - 0x93,0x87,0xff,0x29,0x21,0x00,0x06, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x600_1[] = -{ - {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, - 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, - 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, - 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, - 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0xaf,0xba, - 0x3b,0x82,0xdf,0xb0,0x00,0x00,0x01, - 0x00}}, - {{0x7e,0x63,0x82,0x68,0x15,0x1e,0xf1, - 0xae,0x85,0x57,0x1f,0x30,0x00,0x26, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x1e,0xf1, - 0xae,0x85,0x57,0x1f,0x30,0x00,0x02, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x600_1_H[] = -{ - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, - 0x00}}, - {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x600_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11024x600_2_H[] = -{ - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x01, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11152x768_1[] = -{ - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, - 0x00}}, - {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11152x768_1_H[] = -{ - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, - 0x00}}, - {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11152x768_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11152x768_2_H[] = +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1[] = { - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x01, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1[] = -{ /* TW: Temporary data - invalid */ - {{0x6f,0x4f,0x93,0x54,0x82,0x9e,0x1f, - 0x93,0x86,0x8f,0x9f,0x30,0x00,0x05, + {{0x83,0x4F,0x87,0x5B,0x13,0x06,0x3E, + 0xB3,0x86,0x8F,0x07,0x20,0x00,0x06, 0x00}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, + {{0x83,0x4F,0x87,0x5B,0x13,0xD4,0x1F, + 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, 0x00}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x9e,0x1f, - 0x93,0x86,0x8f,0x9f,0x30,0x00,0x05, + {{0x83,0x4F,0x87,0x5B,0x13,0x06,0x3E, + 0xB3,0x86,0x8F,0x07,0x20,0x00,0x06, 0x00}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, + {{0x83,0x4F,0x87,0x5B,0x13,0xD4,0x1F, + 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, 0x00}}, - {{0x6f,0x4f,0x93,0x54,0x82,0xee,0x1f, - 0xe2,0x86,0xdf,0xef,0x10,0x00,0x05, + {{0x83,0x4F,0x87,0x5B,0x13,0x56,0xBA, + 0x03,0x86,0xDF,0x57,0x00,0x00,0x06, 0x00}}, - {{0x83,0x63,0x87,0x68,0x16,0x66,0xf0, - 0x5a,0x8e,0x57,0x67,0x20,0x00,0x06, + {{0x97,0x63,0x9B,0x6F,0x07,0xCE,0xF0, + 0x7B,0x8E,0x57,0xCF,0x20,0x00,0x02, 0x01}}, - {{0x9f,0x7f,0x83,0x84,0x92,0x0e,0xf5, - 0x02,0x86,0xff,0x0f,0x10,0x00,0x02, + {{0xB3,0x7F,0x97,0x8B,0x83,0x76,0xF5, + 0x23,0x86,0xFF,0x77,0x10,0x00,0x06, 0x01}}, - {{0xbf,0x9f,0x83,0xa4,0x12,0x0e,0x5a, - 0x02,0x86,0xff,0x0f,0x09,0x00,0x07, + {{0xD3,0x9F,0x97,0xAB,0x03,0x76,0x5A, + 0x23,0x86,0xFF,0x77,0x09,0x00,0x03, 0x01}}, - {{0xce,0xae,0x92,0xb3,0x01,0x28,0x10, - 0x1a,0x80,0x19,0x29,0x0f,0x00,0x03, + {{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}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1_H[] = -{ /* TW: Temporary data - invalid */ - {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, - 0x93,0x86,0x8f,0x9f,0x30,0x00,0x05, +#if 0 + {{0x83,0x4f,0x87,0x51,0x09,0xc0,0x1f, + 0x90,0x84,0x8f,0xc1,0x30,0x00,0x06, 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, + {{0x83,0x4f,0x87,0x51,0x09,0x8e,0x1f, + 0x5e,0x82,0x5d,0x8f,0x10,0x00,0x06, 0x00}}, - {{0x47,0x27,0x8b,0x30,0x1e,0x9e,0x1f, - 0x92,0x86,0x8f,0x9f,0x30,0x00,0x05, + {{0x83,0x4f,0x87,0x51,0x09,0xc0,0x1f, + 0x90,0x84,0x8f,0xc1,0x30,0x00,0x06, 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, + {{0x83,0x4f,0x87,0x51,0x09,0x8e,0x1f, + 0x5e,0x82,0x5d,0x8f,0x10,0x00,0x06, 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0xee,0x1f, - 0xe2,0x86,0xdf,0xef,0x10,0x00,0x05, + {{0x83,0x4f,0x87,0x51,0x09,0x10,0x3e, + 0xe0,0x84,0xdf,0x11,0x00,0x00,0x06, 0x00}}, - {{0x51,0x31,0x95,0x36,0x04,0x66,0xf0, - 0x5a,0x8e,0x57,0x67,0x20,0x00,0x01, + {{0x97,0x63,0x9b,0x65,0x1d,0x88,0xf0, + 0x58,0x8c,0x57,0x89,0x20,0x00,0x06, 0x01}}, - {{0x5f,0x3f,0x83,0x44,0x92,0x0e,0xf5, - 0x02,0x86,0xff,0x0f,0x10,0x00,0x01, + {{0xb3,0x7f,0x97,0x81,0x99,0x30,0xf5, + 0x00,0x84,0xff,0x31,0x10,0x00,0x02, 0x01}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a, - 0x02,0x86,0xff,0x0f,0x09,0x00,0x05, + {{0xd3,0x9f,0x97,0xa1,0x19,0x30,0x5a, + 0x00,0x84,0xff,0x31,0x09,0x00,0x07, 0x01}}, - {{0x76,0x56,0x9a,0x5b,0x89,0x28,0x10, - 0x1c,0x80,0x19,0x29,0x0b,0x00,0x05, + {{0xe2,0xae,0x86,0xb0,0x88,0x4a,0x10, + 0x1a,0x8e,0x19,0x4b,0x2f,0x00,0x03, + 0x00}}, + {{0xfb,0xc7,0x9f,0xc9,0x81,0xe0,0x10, + 0xb0,0x84,0xaf,0xe1,0x2f,0x00,0x07, 0x00}} +#endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_2[] = -{ /* TW: Temporary data - invalid */ - {{0xce,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x03, +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1_H[] = +{ + {{0x5B,0x27,0x9F,0x33,0x0B,0x06,0x2E, + 0xB3,0x86,0x8F,0x07,0x20,0x00,0x01, 0x00}}, - {{0xce,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x03, - 0x01}}, - {{0xce,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x03, + {{0x5B,0x27,0x9F,0x29,0x01,0x8E,0x1F, + 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, 0x00}}, - {{0xce,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x03, + {{0x5B,0x27,0x9F,0x33,0x0B,0x06,0x2E, + 0xB3,0x86,0x8F,0x07,0x20,0x00,0x01, 0x00}}, - {{0xce,0x4f,0x92,0x8c,0x1a,0x28,0x9e, - 0x03,0x87,0xdf,0x29,0x01,0x00,0x03, + {{0x83,0x4F,0x87,0x5B,0x13,0xD4,0x1F, + 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, 0x00}}, - {{0xce,0x63,0x92,0x96,0x04,0x28,0xd4, - 0x3f,0x83,0x57,0x29,0x01,0x00,0x07, + {{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}}, - {{0xce,0x7f,0x92,0xa4,0x12,0x28,0xd4, - 0x93,0x87,0xff,0x29,0x21,0x00,0x07, + {{0x73,0x3F,0x97,0x4B,0x83,0x76,0xF5, + 0x23,0x86,0xFF,0x77,0x10,0x00,0x05, 0x01}}, - {{0xce,0x9f,0x92,0xb4,0x02,0x28,0x5a, - 0x13,0x87,0xff,0x29,0x29,0x00,0x03, + {{0xD3,0x9F,0x97,0xAB,0x03,0x76,0x5A, + 0x23,0x86,0xFF,0x77,0x09,0x00,0x03, 0x01}}, - {{0xce,0xae,0x92,0xbc,0x0a,0x28,0x10, - 0x20,0x84,0x19,0x29,0x0f,0x00,0x03, + {{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}} -}; - -static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_2_H[] = /* TW: New */ -{ /* TW: Temporary data - invalid */ - {{0xa6,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x06, +#if 0 + {{0x5b,0x27,0x9f,0x29,0x01,0xc0,0x1f, + 0x90,0x84,0x8f,0xc1,0x30,0x00,0x01, 0x00}}, - {{0xa6,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x06, + {{0x5b,0x27,0x9f,0x29,0x01,0x8e,0x1f, + 0x5e,0x82,0x5d,0x8f,0x10,0x00,0x01, 0x00}}, - {{0xa6,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x06, + {{0x5b,0x27,0x9f,0x29,0x01,0xc0,0x1f, + 0x90,0x84,0x8f,0xc1,0x30,0x00,0x01, 0x00}}, - {{0xa6,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x06, + {{0x5b,0x27,0x9f,0x29,0x01,0x8e,0x1f, + 0x5e,0x82,0x5d,0x8f,0x10,0x00,0x01, 0x00}}, - {{0xa6,0x27,0x8a,0x64,0x92,0x28,0x9e, - 0x03,0x87,0xdf,0x29,0x01,0x00,0x06, + {{0x5b,0x27,0x9f,0x29,0x01,0x10,0x3e, + 0xe0,0x84,0xdf,0x11,0x00,0x00,0x01, 0x00}}, - {{0x9c,0x31,0x80,0x64,0x92,0x28,0xd4, - 0x3f,0x83,0x57,0x29,0x01,0x00,0x06, + {{0x65,0x31,0x89,0x33,0x8b,0x88,0xf0, + 0x58,0x8c,0x57,0x89,0x20,0x00,0x01, 0x01}}, - {{0x8e,0x3f,0x92,0x64,0x12,0x28,0xd4, - 0x93,0x87,0xff,0x29,0x21,0x00,0x06, + {{0x73,0x3f,0x97,0x41,0x99,0x30,0xf5, + 0x00,0x84,0xff,0x31,0x10,0x00,0x01, 0x01}}, - {{0x7e,0x4f,0x82,0x64,0x12,0x28,0x5a, - 0x13,0x87,0xff,0x29,0x29,0x00,0x06, + {{0x83,0x4f,0x87,0x51,0x09,0x30,0x5a, + 0x00,0x84,0xff,0x31,0x09,0x00,0x06, 0x01}}, - {{0x76,0x56,0x9a,0x64,0x92,0x28,0x10, - 0x20,0x84,0x19,0x29,0x0f,0x00,0x05, + {{0x8a,0x56,0x8e,0x58,0x10,0x4a,0x10, + 0x1a,0x8e,0x19,0x4b,0x2f,0x00,0x06, + 0x00}}, + {{0x97,0x63,0x9b,0x65,0x1d,0xe0,0x10, + 0xb0,0x84,0xaf,0xe1,0x2f,0x00,0x06, 0x00}} +#endif }; - -static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1UNTSC[] = /* TW: New */ -{ - {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, - 0xe8,0x84,0x8f,0x57,0x20,0x00,0x01, - 0x00 }}, - {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, - 0xd0,0x82,0x5d,0x57,0x00,0x00,0x01, - 0x00 }}, - {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, - 0xe8,0x84,0x8f,0x57,0x20,0x00,0x01, - 0x00 }}, - {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, - 0xd0,0x82,0x5d,0x57,0x00,0x00,0x01, - 0x00 }}, - {{0x5d,0x4f,0x81,0x56,0x99,0x56,0xba, - 0x0a,0x84,0xdf,0x57,0x00,0x00,0x01, - 0x00 }}, - {{0x80,0x63,0x84,0x6d,0x0f,0xec,0xf0, - 0x7a,0x8f,0x57,0xed,0x20,0x00,0x06, - 0x01 }}, - {{0x8c,0x7f,0x90,0x86,0x09,0xaf,0xf5, /* TW: 1024x768 */ - 0x36,0x88,0xff,0xb0,0x10,0x00,0x02, - 0x01}} +static const SiS310_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_2[] = +{ + {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x97, + 0x43,0x86,0xDB,0xDA,0x11,0x00,0x07, + 0x01}}, + {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x97, + 0x2A,0x8D,0xC2,0xC1,0x11,0x00,0x07, + 0x01}}, + {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x97, + 0x43,0x86,0xDB,0xDA,0x11,0x00,0x07, + 0x01}}, + {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x97, + 0x2A,0x8D,0xC2,0xC1,0x11,0x00,0x07, + 0x01}}, + {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x9F, + 0x6B,0x8E,0x03,0x02,0x01,0x00,0x07, + 0x01}}, + {{0xFB,0x63,0x9F,0xA1,0x99,0x26,0xD5, + 0xA7,0x8A,0xBF,0xBE,0x01,0x00,0x07, + 0x01}}, + {{0xFB,0x7F,0x9F,0xAF,0x87,0x26,0xDD, + 0xFB,0x8E,0x13,0x12,0x31,0x00,0x03, + 0x01}}, + {{0xFB,0x9F,0x9F,0xBF,0x97,0x26,0x5B, + 0x7B,0x8E,0xFF,0x27,0x39,0x00,0x03, + 0x01}}, + {{0xFB,0xAE,0x9F,0xC6,0x9E,0x26,0x11, + 0x88,0x8B,0x19,0x27,0x1F,0x00,0x03, + 0x00}}, + {{0xFB,0xC7,0x9F,0xD3,0x8B,0x26,0x11, + 0xD3,0x86,0xAF,0x27,0x3F,0x00,0x07, + 0x00}} +#if 0 + {{0xfb,0x88,0x87,0x90,0x08,0xe0,0x96, + 0x20,0x84,0xb9,0xb8,0x01,0x00,0x07, + 0x01}}, + {{0xfb,0x88,0x87,0x90,0x08,0xe0,0x96, + 0x07,0x8b,0xa0,0x9f,0x01,0x00,0x07, + 0x01}}, + {{0xfb,0x88,0x87,0x90,0x08,0xe0,0x96, + 0x20,0x84,0xb9,0xb8,0x01,0x00,0x07, + 0x01}}, + {{0xfb,0x88,0x87,0x90,0x08,0xe0,0x96, + 0x07,0x8b,0xa0,0x9f,0x01,0x00,0x07, + 0x01}}, + {{0xfb,0x88,0x87,0x90,0x08,0xe0,0x96, + 0x48,0x8c,0xe1,0xe0,0x11,0x00,0x07, + 0x01}}, + {{0xfb,0x63,0x9f,0x9a,0x92,0xe0,0xd4, + 0x9b,0x8f,0x9d,0x9c,0x21,0x00,0x07, + 0x01}}, + {{0xfb,0x7f,0x9f,0xa8,0x80,0xe0,0xd4, + 0xef,0x83,0xff,0xe1,0x21,0x00,0x03, + 0x01}}, + {{0xfb,0x9f,0x9f,0xb8,0x90,0xe0,0x5a, + 0x6f,0x83,0xff,0xe1,0x29,0x00,0x03, + 0x01}}, + {{0xfb,0xae,0x9f,0xbf,0x97,0xe0,0x10, + 0x7c,0x80,0x19,0xe1,0x0f,0x00,0x03, + 0x00}}, + {{0xfb,0xc7,0x9f,0xc9,0x84,0xe0,0x10, + 0xc7,0x8b,0xaf,0xe1,0x0f,0x00,0x07, + 0x00}} +#endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1ONTSC[] = /* TW: New */ -{ - {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, - 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, - 0xb0,0x8d,0x5d,0x0c,0x00,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, - 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, - 0xb0,0x8d,0x5d,0x0c,0x00,0x00,0x01, - 0x00 }}, - {{0x5d,0x4f,0x81,0x58,0x9d,0x0b,0x3e, - 0xe8,0x84,0xdf,0x0c,0x00,0x00,0x01, - 0x00 }}, - {{0x7d,0x63,0x81,0x68,0x0e,0xba,0xf0, - 0x78,0x8a,0x57,0xbb,0x20,0x00,0x06, - 0x01 }}, - {{0x8c,0x7f,0x90,0x82,0x06,0x46,0xf5, /* TW: 1024x768 */ - 0x15,0x88,0xff,0x47,0x70,0x00,0x02, - 0x01 }} +static const SiS310_LVDSCRT1DataStruct SiS310_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}}, + {{0xd3,0x60,0x9f,0x68,0x00,0xe0,0x96, + 0x07,0x8b,0xa0,0x9f,0x01,0x00,0x02, + 0x01}}, + {{0xd3,0x60,0x9f,0x68,0x00,0xe0,0x96, + 0x20,0x84,0xb9,0xb8,0x01,0x00,0x02, + 0x01}}, + {{0xd3,0x60,0x9f,0x68,0x00,0xe0,0x96, + 0x07,0x8b,0xa0,0x9f,0x01,0x00,0x02, + 0x01}}, + {{0xd3,0x60,0x9f,0x68,0x00,0xe0,0x96, + 0x48,0x8c,0xe1,0xe0,0x11,0x00,0x02, + 0x01}}, + {{0xc9,0x31,0x8d,0x68,0x00,0xe0,0xd4, + 0x9b,0x8f,0x9d,0x9c,0x21,0x00,0x03, + 0x01}}, + {{0xbb,0x3f,0x9f,0x68,0x80,0xe0,0xd4, + 0xef,0x83,0xff,0xe1,0x21,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}} +#endif }; -static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1UPAL[] = /* TW: New */ +/* CRT1 CRTC for Chrontel TV slave modes */ + +static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1UNTSC[] = { - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, - 0x00 }}, - {{0x64,0x4f,0x88,0x5a,0x9f,0x6f,0xba, - 0x15,0x83,0xdf,0x70,0x00,0x00,0x01, - 0x00 }}, - {{0x73,0x63,0x97,0x69,0x8b,0xec,0xf0, - 0x90,0x8c,0x57,0xed,0x20,0x00,0x05, - 0x01 }}, - {{0xaa,0x7f,0x8e,0x8e,0x96,0xe6,0xf5, /* TW: 1024x768 */ - 0x50,0x88,0xff,0xe7,0x10,0x00,0x02, - 0x01}} + {{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_CHTVCRT1OPAL[] = /* TW: New */ +static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1ONTSC[] = { - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, - 0x00 }}, - {{0x64,0x4f,0x88,0x58,0x9d,0x6f,0xba, - 0x15,0x83,0xdf,0x70,0x00,0x00,0x01, - 0x00 }}, - {{0x71,0x63,0x95,0x69,0x8c,0x6f,0xf0, - 0x5a,0x8b,0x57,0x70,0x20,0x00,0x05, - 0x01 }}, - {{0xaa,0x7f,0x8e,0x8f,0x96,0x69,0xf5, /* TW: 1024x768 */ - 0x28,0x88,0xff,0x6a,0x10,0x00,0x02, - 0x01 }} + {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, + 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, + 0xb0,0x8d,0x5d,0x0c,0x00,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, + 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01, + 0x00 }}, + {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, + 0xb0,0x8d,0x5d,0x0c,0x00,0x00,0x01, + 0x00 }}, + {{0x5d,0x4f,0x81,0x58,0x9d,0x0b,0x3e, + 0xe8,0x84,0xdf,0x0c,0x00,0x00,0x01, + 0x00 }}, + {{0x7d,0x63,0x81,0x68,0x0e,0xba,0xf0, + 0x78,0x8a,0x57,0xbb,0x20,0x00,0x06, + 0x01 }}, + {{0x8c,0x7f,0x90,0x82,0x06,0x46,0xf5, + 0x15,0x88,0xff,0x47,0x70,0x00,0x02, + 0x01 }} +}; + +static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1UPAL[] = +{ + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05, + 0x00 }}, + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, + 0x00 }}, + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05, + 0x00 }}, + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, + 0x00 }}, + {{0x64,0x4f,0x88,0x5a,0x9f,0x6f,0xba, + 0x15,0x83,0xdf,0x70,0x00,0x00,0x01, + 0x00 }}, + {{0x73,0x63,0x97,0x69,0x8b,0xec,0xf0, + 0x90,0x8c,0x57,0xed,0x20,0x00,0x05, + 0x01 }}, + {{0xaa,0x7f,0x8e,0x8e,0x96,0xe6,0xf5, + 0x50,0x88,0xff,0xe7,0x10,0x00,0x02, + 0x01}} }; -static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1SOPAL[] = /* TW: New */ +static const SiS310_LVDSCRT1DataStruct SiS310_CHTVCRT1OPAL[] = { - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, - 0x00 }}, - {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, - 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, - 0x00 }}, - {{0x64,0x4f,0x88,0x58,0x9d,0x6f,0xba, - 0x15,0x83,0xdf,0x70,0x00,0x00,0x01, - 0x00 }}, - {{0x71,0x63,0x95,0x69,0x8c,0x6f,0xf0, - 0x5a,0x8b,0x57,0x70,0x20,0x00,0x05, - 0x01 }}, - {{0xaa,0x7f,0x8e,0x8f,0x96,0x69,0xf5, /* TW: 1024x768 */ - 0x28,0x88,0xff,0x6a,0x10,0x00,0x02, - 0x01 }} + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, + 0x00 }}, + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, + 0x00 }}, + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, + 0x00 }}, + {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, + 0xde,0x81,0x5d,0x70,0x00,0x00,0x05, + 0x00 }}, + {{0x64,0x4f,0x88,0x58,0x9d,0x6f,0xba, + 0x15,0x83,0xdf,0x70,0x00,0x00,0x01, + 0x00 }}, + {{0x71,0x63,0x95,0x69,0x8c,0x6f,0xf0, + 0x5a,0x8b,0x57,0x70,0x20,0x00,0x05, + 0x01 }}, + {{0xaa,0x7f,0x8e,0x8f,0x96,0x69,0xf5, + 0x28,0x88,0xff,0x6a,0x10,0x00,0x02, + 0x01 }} }; -/* TW: New data for Chrontel 7019 (From 650/LVDS BIOS 1.10.0) */ typedef struct _SiS310_CHTVRegDataStruct { UCHAR Reg[16]; @@ -4555,119 +3101,131 @@ typedef struct _SiS310_CHTVRegDataStruct static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_UNTSC[] = { - {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x6a,0x77,0xbb,0x6e,0x84,0x2e,0x02,0x5a,0x04,0x00,0x80,0x20,0x7e,0x80,0x98,0x00}}, - {{0xcf,0x77,0xb7,0xc8,0x84,0x3b,0x02,0x5a,0x04,0x00,0x80,0x19,0x88,0x30,0x7f,0x00}}, - {{0xee,0x77,0xbb,0x66,0x87,0x32,0x01,0x5a,0x04,0x00,0x80,0x1b,0xd3,0xf2,0x36,0x00}} -}; + {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x6a,0x77,0xbb,0x6e,0x84,0x2e,0x02,0x5a,0x04,0x00,0x80,0x20,0x7e,0x80,0x98,0x00}}, + {{0xcf,0x77,0xb7,0xc8,0x84,0x3b,0x02,0x5a,0x04,0x00,0x80,0x19,0x88,0x30,0x7f,0x00}}, + {{0xee,0x77,0xbb,0x66,0x87,0x32,0x01,0x5a,0x04,0x00,0x80,0x1b,0xd3,0xf2,0x36,0x00}} +}; /* WRONG: 0x02: should be 0xfx, because if CIVEnable is clear, this should be set; + 0x07: Blacklevel: NTSC/PAL-M: Should be 131 (0x83), and not 0x50/0x5a + PAL/PAL-N: 110 (0x6e) + NTSC-J: 102 (0x66) + 0x0c-0x0f: CIV is not default as in datasheet + MISSING: 0x21: Should set D1 to ZERO (for NTSC, PAL-M) or ONE (PAL, NTSC-J) + Most of this is wrong in all NTSC and PAL register arrays. But I won't correct + it as long as it works. For NTSC-J, the blacklevel is corrected in init301.c; + for PAL-M and PAL-N all above is corrected. + */ static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_ONTSC[] = { - {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x69,0x77,0xbb,0x6e,0x84,0x1e,0x00,0x5a,0x04,0x00,0x80,0x25,0x1a,0x43,0x04,0x00}}, - {{0xce,0x77,0xb7,0xb6,0x83,0x2c,0x02,0x5a,0x04,0x00,0x80,0x1c,0x00,0x82,0x97,0x00}}, - {{0xed,0x77,0xbb,0x66,0x8c,0x21,0x02,0x5a,0x04,0x00,0x80,0x1f,0x9f,0xc1,0x0c,0x00}} + {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x69,0x77,0xbb,0x6e,0x84,0x1e,0x00,0x5a,0x04,0x00,0x80,0x25,0x1a,0x43,0x04,0x00}}, + {{0xce,0x77,0xb7,0xb6,0x83,0x2c,0x02,0x5a,0x04,0x00,0x80,0x1c,0x00,0x82,0x97,0x00}}, + {{0xed,0x77,0xbb,0x66,0x8c,0x21,0x02,0x5a,0x04,0x00,0x80,0x1f,0x9f,0xc1,0x0c,0x00}} }; static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_UPAL[] = { - {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x80,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x12,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x26,0x2a,0x55,0x5d,0x00}}, - {{0xc3,0x7f,0xb7,0x7a,0x84,0x40,0x02,0x5a,0x05,0x00,0x80,0x1f,0x84,0x3d,0x28,0x00}}, - {{0xe5,0x7f,0xb7,0x1d,0xa7,0x3e,0x04,0x5a,0x05,0x00,0x80,0x20,0x3e,0xe4,0x22,0x00}} + {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x41,0x7f,0xb7,0x80,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x41,0x7f,0xb7,0x12,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x26,0x2a,0x55,0x5d,0x00}}, + {{0xc3,0x7f,0xb7,0x7a,0x84,0x40,0x02,0x5a,0x05,0x00,0x80,0x1f,0x84,0x3d,0x28,0x00}}, + {{0xe5,0x7f,0xb7,0x1d,0xa7,0x3e,0x04,0x5a,0x05,0x00,0x80,0x20,0x3e,0xe4,0x22,0x00}} }; static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_OPAL[] = { - {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x26,0x2a,0x55,0x5d,0x00}}, - {{0xc1,0x7f,0xb7,0x4d,0x8c,0x1e,0x31,0x5a,0x05,0x00,0x80,0x26,0x78,0x19,0x34,0x00}}, - {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x5a,0x05,0x00,0x80,0x25,0x8c,0xb2,0x2a,0x00}} -}; - -static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_SOPAL[] = -{ - {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x26,0x2a,0x55,0x5d,0x00}}, - {{0xc1,0x7f,0xb7,0x4d,0x8c,0x1e,0x31,0x5a,0x05,0x00,0x80,0x26,0x78,0x19,0x34,0x00}}, - {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x5a,0x05,0x00,0x80,0x25,0x8c,0xb2,0x2a,0x00}} + {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x26,0x2a,0x55,0x5d,0x00}}, + {{0xc1,0x7f,0xb7,0x4d,0x8c,0x1e,0x31,0x5a,0x05,0x00,0x80,0x26,0x78,0x19,0x34,0x00}}, + {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x5a,0x05,0x00,0x80,0x25,0x8c,0xb2,0x2a,0x00}} }; static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_UPALM[] = { - {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x72,0x77,0xbb,0x6e,0x84,0x2e,0x02,0x5a,0x04,0x00,0x80,0x20,0x76,0xdb,0x6e,0x00}}, - {{0xd7,0x77,0xb7,0xc8,0x84,0x3b,0x02,0x5a,0x04,0x00,0x80,0x19,0x84,0x0a,0xc7,0x00}}, - {{0xf6,0x77,0xbb,0x66,0x87,0x32,0x01,0x5a,0x04,0x00,0x80,0x1b,0xdc,0xb0,0x8d,0x00}} + {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x72,0x77,0xfb,0x6e,0x84,0x2e,0x02,0x83,0x04,0x00,0x80,0x20,0x76,0xdb,0x6e,0x00}}, + {{0xd7,0x77,0xf7,0xc8,0x84,0x3b,0x02,0x83,0x04,0x00,0x80,0x19,0x84,0x0a,0xc7,0x00}}, + {{0xf6,0x77,0xfb,0x66,0x87,0x32,0x01,0x83,0x04,0x00,0x80,0x1b,0xdc,0xb0,0x8d,0x00}} +#if 0 /* Correct blacklevel and CFRB */ + {{0x72,0x77,0xbb,0x6e,0x84,0x2e,0x02,0x5a,0x04,0x00,0x80,0x20,0x76,0xdb,0x6e,0x00}}, + {{0xd7,0x77,0xb7,0xc8,0x84,0x3b,0x02,0x5a,0x04,0x00,0x80,0x19,0x84,0x0a,0xc7,0x00}}, + {{0xf6,0x77,0xbb,0x66,0x87,0x32,0x01,0x5a,0x04,0x00,0x80,0x1b,0xdc,0xb0,0x8d,0x00}} +#endif }; static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_OPALM[] = { - {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x71,0x77,0xbb,0x6e,0x84,0x1e,0x00,0x5a,0x04,0x00,0x80,0x25,0x1a,0x1f,0x59,0x00}}, - {{0xd6,0x77,0xb7,0xb6,0x83,0x2c,0x02,0x5a,0x04,0x00,0x80,0x1b,0xf8,0x1f,0x82,0x00}}, - {{0xf5,0x77,0xbb,0x66,0x8c,0x21,0x02,0x5a,0x04,0x00,0x80,0x1f,0x58,0x46,0x9f,0x00}} + {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, + {{0x71,0x77,0xfb,0x6e,0x84,0x1e,0x00,0x83,0x04,0x00,0x80,0x25,0x1a,0x1f,0x59,0x00}}, + {{0xd6,0x77,0xf7,0xb6,0x83,0x2c,0x02,0x83,0x04,0x00,0x80,0x1b,0xf8,0x1f,0x82,0x00}}, + {{0xf5,0x77,0xfb,0x66,0x8c,0x21,0x02,0x83,0x04,0x00,0x80,0x1f,0x58,0x46,0x9f,0x00}} +#if 0 /* Correct blacklevel and CFRB */ + {{0x71,0x77,0xbb,0x6e,0x84,0x1e,0x00,0x5a,0x04,0x00,0x80,0x25,0x1a,0x1f,0x59,0x00}}, + {{0xd6,0x77,0xb7,0xb6,0x83,0x2c,0x02,0x5a,0x04,0x00,0x80,0x1b,0xf8,0x1f,0x82,0x00}}, + {{0xf5,0x77,0xbb,0x66,0x8c,0x21,0x02,0x5a,0x04,0x00,0x80,0x1f,0x58,0x46,0x9f,0x00}} +#endif }; static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_UPALN[] = { - {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x80,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x12,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x1f,0x0d,0x54,0x5e,0x00}}, - {{0xc3,0x7f,0xb7,0x7a,0x84,0x40,0x02,0x5a,0x05,0x00,0x80,0x19,0x78,0xef,0x35,0x00}}, - {{0xe5,0x7f,0xb7,0x1d,0xa7,0x3e,0x04,0x5a,0x05,0x00,0x80,0x1a,0x33,0x3f,0x2f,0x00}} + {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x41,0x7f,0xb7,0x80,0x85,0x50,0x00,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x41,0x7f,0xb7,0x12,0x85,0x50,0x00,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0xc3,0x7f,0xb7,0x7a,0x84,0x40,0x02,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0xe5,0x7f,0xb7,0x1d,0xa7,0x3e,0x04,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}} +#if 0 /* Correct blacklevel, CIV and CFRB */ + {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x1f,0x0d,0x54,0x5e,0x00}}, + {{0xc3,0x7f,0xb7,0x7a,0x84,0x40,0x02,0x5a,0x05,0x00,0x80,0x19,0x78,0xef,0x35,0x00}}, + {{0xe5,0x7f,0xb7,0x1d,0xa7,0x3e,0x04,0x5a,0x05,0x00,0x80,0x1a,0x33,0x3f,0x2f,0x00}} +#endif }; static const SiS310_CHTVRegDataStruct SiS310_CHTVReg_OPALN[] = { - {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, - {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x1f,0x0d,0x54,0x5e,0x00}}, - {{0xc1,0x7f,0xb7,0x4d,0x8c,0x1e,0x31,0x5a,0x05,0x00,0x80,0x1f,0x15,0xc0,0x1e,0x00}}, - {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x5a,0x05,0x00,0x80,0x1d,0xf1,0x6c,0xcb,0x00}} + {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0xc1,0x7f,0xb7,0x4d,0x8c,0x1e,0x31,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, + {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}} +#if 0 /* Correct blacklevel, CIV and CFRB */ + {{0x61,0x7f,0xb7,0x99,0x84,0x35,0x04,0x5a,0x05,0x00,0x80,0x1f,0x0d,0x54,0x5e,0x00}}, + {{0xc1,0x7f,0xb7,0x4d,0x8c,0x1e,0x31,0x5a,0x05,0x00,0x80,0x1f,0x15,0xc0,0x1e,0x00}}, + {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x5a,0x05,0x00,0x80,0x1d,0xf1,0x6c,0xcb,0x00}} +#endif }; static const UCHAR SiS310_CHTVVCLKUNTSC[] = {0x41,0x41,0x41,0x41,0x42,0x46,0x53}; - static const UCHAR SiS310_CHTVVCLKONTSC[] = {0x48,0x48,0x48,0x48,0x45,0x43,0x51}; static const UCHAR SiS310_CHTVVCLKUPAL[] = {0x47,0x47,0x47,0x47,0x48,0x4a,0x54}; - static const UCHAR SiS310_CHTVVCLKOPAL[] = {0x47,0x47,0x47,0x47,0x48,0x4f,0x52}; -static const UCHAR SiS310_CHTVVCLKSOPAL[] = {0x47,0x47,0x47,0x47,0x48,0x4f,0x52}; - static const UCHAR SiS310_CHTVVCLKUPALM[] = {0x41,0x41,0x41,0x41,0x42,0x46,0x53}; - static const UCHAR SiS310_CHTVVCLKOPALM[] = {0x48,0x48,0x48,0x48,0x45,0x43,0x51}; static const UCHAR SiS310_CHTVVCLKUPALN[] = {0x47,0x47,0x47,0x47,0x48,0x4a,0x54}; - static const UCHAR SiS310_CHTVVCLKOPALN[] = {0x47,0x47,0x47,0x47,0x48,0x4f,0x52}; -/* TW: New end */ + @@ -1,23 +1,18 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.c,v 1.6 2003/02/04 02:44:28 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.c,v 1.37 2003/11/20 19:53:20 twini Exp $ */ /* - * Mode switching code (CRT1 section) for SiS 300/540/630/730/315/550/650/740/330 + * Mode initializing code (CRT1 section) for + * for SiS 300/305/540/630/730 and + * SiS 315/550/650/M650/651/661FX/M661FX/740/741/330/660/M660/760/M760 * (Universal module for Linux kernel framebuffer and XFree86 4.x) * * Assembler-To-C translation - * Copyright 2002 by Thomas Winischhofer <thomas@winischhofer.net> - * Minor parts Copyright SiS, Inc. + * Copyright 2002, 2003 by Thomas Winischhofer <thomas@winischhofer.net> + * Formerly based on non-functional code-fragements by SiS, Inc. * - * Based on BIOS - * 1.10.07, 1.10a for SiS650/LVDS+CH7019 - * 1.11.05 for 650/LVDS (w/o Chrontel) - * 1.07.1b, 1.11.6s, 1.11.6w, 1.11.7w, 1.11.8r for SiS650/301(B/LV) - * 2.04.50 (I) and 2.04.5c (II) for SiS630/301(B) - * 2.06.50 for 630/301B (dual VGA) - * 2.02.3b, 2.03.02, 2.04.5c, 2.07a and 2.08.b3 for 630/LVDS/LVDS+CH7005 - * 2.04.5c, 2.04.6c for 730+LVDS+CH7005 - * 1.09b for 315/301(B) - * 1.16.51 for 300+301LVX (ECS A907) - * 1.01.03 for 330 (Xabre 400) + * If distributed as part of the linux kernel, the contents of this file + * is entirely covered by the GPL. + * + * Otherwise, the following 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 @@ -57,128 +52,199 @@ #include "310vtbl.h" #endif -#ifdef LINUX_XF86 -BOOLEAN SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom); -DisplayModePtr SiSBuildBuiltInModeList(ScrnInfoPtr pScrn); -#ifdef SISDUALHEAD /* TW: For dual head */ -BOOLEAN SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom); -BOOLEAN SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - ScrnInfoPtr pScrn, DisplayModePtr mode); -#endif /* dual head */ -#endif /* linux_xf86 */ - -#ifdef LINUXBIOS -BOOLEAN SiSInit(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -#endif - -#ifdef LINUX_XF86 -BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch); -#else -BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo); -#endif - #if defined(ALLOC_PRAGMA) #pragma alloc_text(PAGE,SiSSetMode) #pragma alloc_text(PAGE,SiSInit) #endif -static ULONG GetDRAMSize(SiS_Private *SiS_Pr, - PSIS_HW_DEVICE_INFO HwDeviceExtension); - -static void DelaySeconds(int seconds); -void SiS_DebugCode(SiS_Private *SiS_Pr, UCHAR code); - -#ifdef LINUX_XF86 -/* TW: Mode table for X driver */ -const UShort ModeIndex_320x480[] = {0x5a, 0x5b, 0x00, 0x00}; /* DSTN/FSTN */ -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_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_300_1280x960[] = {0x6e, 0x6f, 0x00, 0x7b}; -const UShort ModeIndex_310_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_1280x768[] = {0x23, 0x24, 0x00, 0x25}; /* 310/325 series only */ -const UShort ModeIndex_1280x720[] = {0x79, 0x75, 0x00, 0x78}; -const UShort ModeIndex_1360x768[] = {0x48, 0x4b, 0x00, 0x4e}; -const UShort ModeIndex_1400x1050[] = {0x26, 0x27, 0x00, 0x28}; /* 310/325 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}; -#endif +/*********************************************/ +/* POINTER INITIALIZATION */ +/*********************************************/ static void -DelaySeconds(int seconds) -{ - int i; -#ifdef WIN2000 - int j; -#endif - - for (i=0;i<seconds;i++) { -#ifdef TC - delay(1000); -#endif - -#ifdef WIN2000 - for (j=0;j<20000;j++) - VideoPortStallExecution(50); -#endif - -#ifdef WINCE_HEADER -#endif - -#ifdef LINUX_KERNEL -#endif - } -} - -void -SiS_DebugCode(SiS_Private *SiS_Pr, UCHAR code) +InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - OutPortByte(0x80, code); - DelaySeconds(0x3); + SiS_Pr->SiS_StResInfo = SiS_StResInfo; + SiS_Pr->SiS_ModeResInfo = SiS_ModeResInfo; + SiS_Pr->SiS_StandTable = SiS_StandTable; + + SiS_Pr->SiS_NTSCPhase = SiS_NTSCPhase; + SiS_Pr->SiS_PALPhase = SiS_PALPhase; + SiS_Pr->SiS_NTSCPhase2 = SiS_NTSCPhase2; + SiS_Pr->SiS_PALPhase2 = SiS_PALPhase2; + SiS_Pr->SiS_PALMPhase = SiS_PALMPhase; + SiS_Pr->SiS_PALNPhase = SiS_PALNPhase; + SiS_Pr->SiS_PALMPhase2 = SiS_PALMPhase2; + SiS_Pr->SiS_PALNPhase2 = SiS_PALNPhase2; + SiS_Pr->SiS_SpecialPhase = SiS_SpecialPhase; + SiS_Pr->SiS_SpecialPhaseM= SiS_SpecialPhaseM; + SiS_Pr->SiS_SpecialPhaseJ= SiS_SpecialPhaseJ; + + SiS_Pr->SiS_NTSCTiming = SiS_NTSCTiming; + SiS_Pr->SiS_PALTiming = SiS_PALTiming; + SiS_Pr->SiS_HiTVSt1Timing = SiS_HiTVSt1Timing; + SiS_Pr->SiS_HiTVSt2Timing = SiS_HiTVSt2Timing; + SiS_Pr->SiS_HiTVTextTiming = SiS_HiTVTextTiming; + SiS_Pr->SiS_HiTVExtTiming = SiS_HiTVExtTiming; + SiS_Pr->SiS_HiTVGroup3Data = SiS_HiTVGroup3Data; + SiS_Pr->SiS_HiTVGroup3Simu = SiS_HiTVGroup3Simu; + SiS_Pr->SiS_HiTVGroup3Text = SiS_HiTVGroup3Text; + + 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_St2HiTVData = SiS_St2HiTVData; + SiS_Pr->SiS_ExtHiTVData = SiS_ExtHiTVData; + + SiS_Pr->pSiS_OutputSelect = &SiS_OutputSelect; + SiS_Pr->pSiS_SoftSetting = &SiS_SoftSetting; + + SiS_Pr->SiS_LCD1280x960Data = SiS_LCD1280x960Data; + SiS_Pr->SiS_ExtLCD1400x1050Data = SiS_ExtLCD1400x1050Data; + SiS_Pr->SiS_ExtLCD1600x1200Data = SiS_ExtLCD1600x1200Data; + SiS_Pr->SiS_StLCD1400x1050Data = SiS_StLCD1400x1050Data; + SiS_Pr->SiS_StLCD1600x1200Data = SiS_StLCD1600x1200Data; + SiS_Pr->SiS_NoScaleData1400x1050 = SiS_NoScaleData1400x1050; + SiS_Pr->SiS_NoScaleData1600x1200 = SiS_NoScaleData1600x1200; + SiS_Pr->SiS_ExtLCD1280x768Data = SiS_ExtLCD1280x768Data; + SiS_Pr->SiS_StLCD1280x768Data = SiS_StLCD1280x768Data; + SiS_Pr->SiS_NoScaleData1280x768 = SiS_NoScaleData1280x768; + SiS_Pr->SiS_NoScaleData = SiS_NoScaleData; + + SiS_Pr->SiS_LVDS320x480Data_1 = SiS_LVDS320x480Data_1; + SiS_Pr->SiS_LVDS800x600Data_1 = SiS_LVDS800x600Data_1; + SiS_Pr->SiS_LVDS800x600Data_2 = SiS_LVDS800x600Data_2; + SiS_Pr->SiS_LVDS1024x768Data_1 = SiS_LVDS1024x768Data_1; + SiS_Pr->SiS_LVDS1024x768Data_2 = SiS_LVDS1024x768Data_2; + SiS_Pr->SiS_LVDS1280x1024Data_1 = SiS_LVDS1280x1024Data_1; + SiS_Pr->SiS_LVDS1280x1024Data_2 = SiS_LVDS1280x1024Data_2; + SiS_Pr->SiS_LVDS1400x1050Data_1 = SiS_LVDS1400x1050Data_1; + SiS_Pr->SiS_LVDS1400x1050Data_2 = SiS_LVDS1400x1050Data_2; + SiS_Pr->SiS_LVDS1600x1200Data_1 = SiS_LVDS1600x1200Data_1; + SiS_Pr->SiS_LVDS1600x1200Data_2 = SiS_LVDS1600x1200Data_2; + SiS_Pr->SiS_LVDS1280x768Data_1 = SiS_LVDS1280x768Data_1; + SiS_Pr->SiS_LVDS1280x768Data_2 = SiS_LVDS1280x768Data_2; + SiS_Pr->SiS_LVDS1024x600Data_1 = SiS_LVDS1024x600Data_1; + SiS_Pr->SiS_LVDS1024x600Data_2 = SiS_LVDS1024x600Data_2; + SiS_Pr->SiS_LVDS1152x768Data_1 = SiS_LVDS1152x768Data_1; + SiS_Pr->SiS_LVDS1152x768Data_2 = SiS_LVDS1152x768Data_2; + SiS_Pr->SiS_LVDSXXXxXXXData_1 = SiS_LVDSXXXxXXXData_1; + SiS_Pr->SiS_LVDS1280x960Data_1 = SiS_LVDS1280x960Data_1; + SiS_Pr->SiS_LVDS1280x960Data_2 = SiS_LVDS1280x960Data_2; + SiS_Pr->SiS_LVDS640x480Data_1 = SiS_LVDS640x480Data_1; + SiS_Pr->SiS_LVDS1280x960Data_1 = SiS_LVDS1280x1024Data_1; + SiS_Pr->SiS_LVDS1280x960Data_2 = SiS_LVDS1280x1024Data_2; + SiS_Pr->SiS_LVDS640x480Data_1 = SiS_LVDS640x480Data_1; + SiS_Pr->SiS_LVDS640x480Data_2 = SiS_LVDS640x480Data_2; + + SiS_Pr->SiS_LVDSBARCO1366Data_1 = SiS_LVDSBARCO1366Data_1; + SiS_Pr->SiS_LVDSBARCO1366Data_2 = SiS_LVDSBARCO1366Data_2; + SiS_Pr->SiS_LVDSBARCO1024Data_1 = SiS_LVDSBARCO1024Data_1; + SiS_Pr->SiS_LVDSBARCO1024Data_2 = SiS_LVDSBARCO1024Data_2; + SiS_Pr->SiS_LVDS848x480Data_1 = SiS_LVDS848x480Data_1; + SiS_Pr->SiS_LVDS848x480Data_2 = SiS_LVDS848x480Data_2; + + SiS_Pr->SiS_CHTVUNTSCData = SiS_CHTVUNTSCData; + SiS_Pr->SiS_CHTVONTSCData = SiS_CHTVONTSCData; + + SiS_Pr->SiS_LCDA1024x768Data_1 = SiS_LCDA1024x768Data_1; + SiS_Pr->SiS_LCDA1024x768Data_2 = SiS_LCDA1024x768Data_2; + SiS_Pr->SiS_LCDA1280x1024Data_1 = SiS_LCDA1280x1024Data_1; + SiS_Pr->SiS_LCDA1280x1024Data_2 = SiS_LCDA1280x1024Data_2; + SiS_Pr->SiS_LCDA1400x1050Data_1 = SiS_LCDA1400x1050Data_1; + SiS_Pr->SiS_LCDA1400x1050Data_2 = SiS_LCDA1400x1050Data_2; + SiS_Pr->SiS_LCDA1600x1200Data_1 = SiS_LCDA1600x1200Data_1; + SiS_Pr->SiS_LCDA1600x1200Data_2 = SiS_LCDA1600x1200Data_2; + + SiS_Pr->LVDS1024x768Des_1 = SiS_PanelType1076_1; + SiS_Pr->LVDS1280x1024Des_1 = SiS_PanelType1210_1; + SiS_Pr->LVDS1400x1050Des_1 = SiS_PanelType1296_1; + SiS_Pr->LVDS1600x1200Des_1 = SiS_PanelType1600_1; + SiS_Pr->LVDS1024x768Des_2 = SiS_PanelType1076_2; + SiS_Pr->LVDS1280x1024Des_2 = SiS_PanelType1210_2; + SiS_Pr->LVDS1400x1050Des_2 = SiS_PanelType1296_2; + SiS_Pr->LVDS1600x1200Des_2 = SiS_PanelType1600_2; + + SiS_Pr->SiS_PanelTypeNS_1 = SiS_PanelTypeNS_1; + SiS_Pr->SiS_PanelTypeNS_2 = SiS_PanelTypeNS_2; + + SiS_Pr->SiS_CHTVUNTSCDesData = SiS_CHTVUNTSCDesData; + SiS_Pr->SiS_CHTVONTSCDesData = SiS_CHTVONTSCDesData; + SiS_Pr->SiS_CHTVUPALDesData = SiS_CHTVUPALDesData; + SiS_Pr->SiS_CHTVOPALDesData = SiS_CHTVOPALDesData; + + SiS_Pr->SiS_LVDSCRT11280x768_1 = SiS_LVDSCRT11280x768_1; + SiS_Pr->SiS_LVDSCRT11024x600_1 = SiS_LVDSCRT11024x600_1; + SiS_Pr->SiS_LVDSCRT11152x768_1 = SiS_LVDSCRT11152x768_1; + SiS_Pr->SiS_LVDSCRT11280x768_1_H = SiS_LVDSCRT11280x768_1_H; + SiS_Pr->SiS_LVDSCRT11024x600_1_H = SiS_LVDSCRT11024x600_1_H; + SiS_Pr->SiS_LVDSCRT11152x768_1_H = SiS_LVDSCRT11152x768_1_H; + SiS_Pr->SiS_LVDSCRT11280x768_2 = SiS_LVDSCRT11280x768_2; + SiS_Pr->SiS_LVDSCRT11024x600_2 = SiS_LVDSCRT11024x600_2; + SiS_Pr->SiS_LVDSCRT11152x768_2 = SiS_LVDSCRT11152x768_2; + SiS_Pr->SiS_LVDSCRT11280x768_2_H = SiS_LVDSCRT11280x768_2_H; + SiS_Pr->SiS_LVDSCRT11024x600_2_H = SiS_LVDSCRT11024x600_2_H; + SiS_Pr->SiS_LVDSCRT11152x768_2_H = SiS_LVDSCRT11152x768_2_H; + SiS_Pr->SiS_LVDSCRT1320x480_1 = SiS_LVDSCRT1320x480_1; + SiS_Pr->SiS_LVDSCRT1XXXxXXX_1 = SiS_LVDSCRT1XXXxXXX_1; + SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H = SiS_LVDSCRT1XXXxXXX_1_H; + SiS_Pr->SiS_LVDSCRT1640x480_1 = SiS_LVDSCRT1640x480_1; + SiS_Pr->SiS_LVDSCRT1640x480_1_H = SiS_LVDSCRT1640x480_1_H; + SiS_Pr->SiS_LVDSCRT1640x480_2 = SiS_LVDSCRT1640x480_2; + SiS_Pr->SiS_LVDSCRT1640x480_2_H = SiS_LVDSCRT1640x480_2_H; + SiS_Pr->SiS_LVDSCRT1640x480_3 = SiS_LVDSCRT1640x480_3; + SiS_Pr->SiS_LVDSCRT1640x480_3_H = SiS_LVDSCRT1640x480_3_H; } #ifdef SIS300 static void -InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { + InitCommonPointer(SiS_Pr, HwInfo); + + SiS_StandTable[0x04].CRTC[4] = 0x2b; + SiS_StandTable[0x05].CRTC[4] = 0x2b; + SiS_StandTable[0x06].CRTC[4] = 0x54; + SiS_StandTable[0x06].CRTC[5] = 0x80; + SiS_StandTable[0x0d].CRTC[4] = 0x2b; + SiS_StandTable[0x0e].CRTC[4] = 0x54; + SiS_StandTable[0x0e].CRTC[5] = 0x80; + SiS_StandTable[0x11].CRTC[4] = 0x54; + SiS_StandTable[0x11].CRTC[5] = 0x80; + SiS_StandTable[0x11].CRTC[16] = 0x83; + SiS_StandTable[0x11].CRTC[17] = 0x85; + SiS_StandTable[0x12].CRTC[4] = 0x54; + SiS_StandTable[0x12].CRTC[5] = 0x80; + SiS_StandTable[0x12].CRTC[16] = 0x83; + SiS_StandTable[0x12].CRTC[17] = 0x85; + SiS_StandTable[0x13].CRTC[5] = 0xa0; + SiS_StandTable[0x17].CRTC[5] = 0xa0; + SiS_StandTable[0x1a].CRTC[4] = 0x54; + SiS_StandTable[0x1a].CRTC[5] = 0x80; + SiS_StandTable[0x1a].CRTC[16] = 0xea; + SiS_StandTable[0x1a].CRTC[17] = 0x8c; + SiS_StandTable[0x1b].CRTC[4] = 0x54; + SiS_StandTable[0x1b].CRTC[5] = 0x80; + SiS_StandTable[0x1b].CRTC[16] = 0xea; + SiS_StandTable[0x1b].CRTC[17] = 0x8c; + SiS_StandTable[0x1c].CRTC[4] = 0x54; + SiS_StandTable[0x1c].CRTC[5] = 0x80; + SiS_Pr->SiS_SModeIDTable = (SiS_StStruct *)SiS300_SModeIDTable; SiS_Pr->SiS_VBModeIDTable = (SiS_VBModeStruct *)SiS300_VBModeIDTable; - SiS_Pr->SiS_StandTable = (SiS_StandTableStruct *)SiS300_StandTable; SiS_Pr->SiS_EModeIDTable = (SiS_ExtStruct *)SiS300_EModeIDTable; SiS_Pr->SiS_RefIndex = (SiS_Ext2Struct *)SiS300_RefIndex; SiS_Pr->SiS_CRT1Table = (SiS_CRT1TableStruct *)SiS300_CRT1Table; - if(HwDeviceExtension->jChipType == SIS_300) { + if(HwInfo->jChipType == SIS_300) { SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS300_MCLKData_300; /* 300 */ } else { - SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS300_MCLKData_630; /* 630 */ + SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS300_MCLKData_630; /* 630, 730 */ } - SiS_Pr->SiS_ECLKData = (SiS_ECLKDataStruct *)SiS300_ECLKData; SiS_Pr->SiS_VCLKData = (SiS_VCLKDataStruct *)SiS300_VCLKData; SiS_Pr->SiS_VBVCLKData = (SiS_VBVCLKDataStruct *)SiS300_VCLKData; SiS_Pr->SiS_ScreenOffset = SiS300_ScreenOffset; - SiS_Pr->SiS_StResInfo = (SiS_StResInfoStruct *)SiS300_StResInfo; - SiS_Pr->SiS_ModeResInfo = (SiS_ModeResInfoStruct *)SiS300_ModeResInfo; - - SiS_Pr->pSiS_OutputSelect = &SiS300_OutputSelect; - SiS_Pr->pSiS_SoftSetting = &SiS300_SoftSetting; SiS_Pr->SiS_SR15 = SiS300_SR15; @@ -207,15 +273,6 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->pSiS_YCSenseData2 = &SiS300_YCSenseData2; #endif - SiS_Pr->SiS_NTSCPhase = SiS300_NTSCPhase; - SiS_Pr->SiS_PALPhase = SiS300_PALPhase; - SiS_Pr->SiS_NTSCPhase2 = SiS300_NTSCPhase2; - SiS_Pr->SiS_PALPhase2 = SiS300_PALPhase2; - SiS_Pr->SiS_PALMPhase = SiS300_PALMPhase; - SiS_Pr->SiS_PALNPhase = SiS300_PALNPhase; - SiS_Pr->SiS_PALMPhase2 = SiS300_PALMPhase2; - SiS_Pr->SiS_PALNPhase2 = SiS300_PALNPhase2; - SiS_Pr->SiS_StLCD1024x768Data = (SiS_LCDDataStruct *)SiS300_StLCD1024x768Data; SiS_Pr->SiS_ExtLCD1024x768Data = (SiS_LCDDataStruct *)SiS300_ExtLCD1024x768Data; SiS_Pr->SiS_St2LCD1024x768Data = (SiS_LCDDataStruct *)SiS300_St2LCD1024x768Data; @@ -224,70 +281,21 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->SiS_St2LCD1280x1024Data = (SiS_LCDDataStruct *)SiS300_St2LCD1280x1024Data; SiS_Pr->SiS_NoScaleData1024x768 = (SiS_LCDDataStruct *)SiS300_NoScaleData1024x768; SiS_Pr->SiS_NoScaleData1280x1024 = (SiS_LCDDataStruct *)SiS300_NoScaleData1280x1024; - SiS_Pr->SiS_LCD1280x960Data = (SiS_LCDDataStruct *)SiS300_LCD1280x960Data; - SiS_Pr->SiS_ExtLCD1400x1050Data = (SiS_LCDDataStruct *)SiS300_ExtLCD1400x1050Data; - SiS_Pr->SiS_ExtLCD1600x1200Data = (SiS_LCDDataStruct *)SiS300_ExtLCD1600x1200Data; - SiS_Pr->SiS_StLCD1400x1050Data = (SiS_LCDDataStruct *)SiS300_StLCD1400x1050Data; - SiS_Pr->SiS_StLCD1600x1200Data = (SiS_LCDDataStruct *)SiS300_StLCD1600x1200Data; - SiS_Pr->SiS_NoScaleData1400x1050 = (SiS_LCDDataStruct *)SiS300_NoScaleData1400x1050; - SiS_Pr->SiS_NoScaleData1600x1200 = (SiS_LCDDataStruct *)SiS300_NoScaleData1600x1200; - - SiS_Pr->SiS_StPALData = (SiS_TVDataStruct *)SiS300_StPALData; - SiS_Pr->SiS_ExtPALData = (SiS_TVDataStruct *)SiS300_ExtPALData; - SiS_Pr->SiS_StNTSCData = (SiS_TVDataStruct *)SiS300_StNTSCData; - SiS_Pr->SiS_ExtNTSCData = (SiS_TVDataStruct *)SiS300_ExtNTSCData; -#ifdef oldHV - SiS_Pr->SiS_St1HiTVData = (SiS_TVDataStruct *)SiS300_St1HiTVData; - SiS_Pr->SiS_St2HiTVData = (SiS_TVDataStruct *)SiS300_St2HiTVData; - SiS_Pr->SiS_ExtHiTVData = (SiS_TVDataStruct *)SiS300_ExtHiTVData; -#endif - - SiS_Pr->SiS_NTSCTiming = SiS300_NTSCTiming; - SiS_Pr->SiS_PALTiming = SiS300_PALTiming; -#ifdef oldHV - SiS_Pr->SiS_HiTVSt1Timing = SiS300_HiTVSt1Timing; - SiS_Pr->SiS_HiTVSt2Timing = SiS300_HiTVSt2Timing; - SiS_Pr->SiS_HiTVTextTiming = SiS300_HiTVTextTiming; - SiS_Pr->SiS_HiTVGroup3Data = SiS300_HiTVGroup3Data; - SiS_Pr->SiS_HiTVGroup3Simu = SiS300_HiTVGroup3Simu; - SiS_Pr->SiS_HiTVGroup3Text = SiS300_HiTVGroup3Text; -#endif SiS_Pr->SiS_PanelDelayTbl = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTbl; + SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTbl; +#if 0 SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTblLVDS; +#endif - SiS_Pr->SiS_LVDS800x600Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS800x600Data_1; - SiS_Pr->SiS_LVDS800x600Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS800x600Data_2; - SiS_Pr->SiS_LVDS1024x768Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1024x768Data_1; - SiS_Pr->SiS_LVDS1024x768Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1024x768Data_2; - SiS_Pr->SiS_LVDS1280x1024Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x1024Data_1; - SiS_Pr->SiS_LVDS1280x1024Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x1024Data_2; - SiS_Pr->SiS_LVDS1280x960Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x1024Data_1; - SiS_Pr->SiS_LVDS1280x960Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x1024Data_2; - SiS_Pr->SiS_LVDS1400x1050Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1400x1050Data_1; - SiS_Pr->SiS_LVDS1400x1050Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1400x1050Data_2; - SiS_Pr->SiS_LVDS1280x768Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x768Data_1; - SiS_Pr->SiS_LVDS1280x768Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x768Data_2; - SiS_Pr->SiS_LVDS1024x600Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1024x600Data_1; - SiS_Pr->SiS_LVDS1024x600Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1024x600Data_2; - SiS_Pr->SiS_LVDS1152x768Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1152x768Data_1; - SiS_Pr->SiS_LVDS1152x768Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1152x768Data_2; - SiS_Pr->SiS_LVDSXXXxXXXData_1 = (SiS_LVDSDataStruct *)SiS300_LVDSXXXxXXXData_1; - SiS_Pr->SiS_LVDS320x480Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS320x480Data_1; - SiS_Pr->SiS_LVDS640x480Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS640x480Data_1; - SiS_Pr->SiS_LCDA1400x1050Data_1 = (SiS_LVDSDataStruct *)SiS300_LCDA1400x1050Data_1; - SiS_Pr->SiS_LCDA1400x1050Data_2 = (SiS_LVDSDataStruct *)SiS300_LCDA1400x1050Data_2; - SiS_Pr->SiS_LCDA1600x1200Data_1 = (SiS_LVDSDataStruct *)SiS300_LCDA1600x1200Data_1; - SiS_Pr->SiS_LCDA1600x1200Data_2 = (SiS_LVDSDataStruct *)SiS300_LCDA1600x1200Data_2; - SiS_Pr->SiS_CHTVUNTSCData = (SiS_LVDSDataStruct *)SiS300_CHTVUNTSCData; - SiS_Pr->SiS_CHTVONTSCData = (SiS_LVDSDataStruct *)SiS300_CHTVONTSCData; SiS_Pr->SiS_CHTVUPALData = (SiS_LVDSDataStruct *)SiS300_CHTVUPALData; SiS_Pr->SiS_CHTVOPALData = (SiS_LVDSDataStruct *)SiS300_CHTVOPALData; - SiS_Pr->SiS_CHTVUPALMData = (SiS_LVDSDataStruct *)SiS300_CHTVUNTSCData; /* not supported on 300 series */ - SiS_Pr->SiS_CHTVOPALMData = (SiS_LVDSDataStruct *)SiS300_CHTVONTSCData; /* not supported on 300 series */ + SiS_Pr->SiS_CHTVUPALMData = SiS_CHTVUNTSCData; /* not supported on 300 series */ + SiS_Pr->SiS_CHTVOPALMData = SiS_CHTVONTSCData; /* not supported on 300 series */ SiS_Pr->SiS_CHTVUPALNData = (SiS_LVDSDataStruct *)SiS300_CHTVUPALData; /* not supported on 300 series */ SiS_Pr->SiS_CHTVOPALNData = (SiS_LVDSDataStruct *)SiS300_CHTVOPALData; /* not supported on 300 series */ SiS_Pr->SiS_CHTVSOPALData = (SiS_LVDSDataStruct *)SiS300_CHTVSOPALData; + SiS_Pr->SiS_PanelType00_1 = (SiS_LVDSDesStruct *)SiS300_PanelType00_1; SiS_Pr->SiS_PanelType01_1 = (SiS_LVDSDesStruct *)SiS300_PanelType01_1; SiS_Pr->SiS_PanelType02_1 = (SiS_LVDSDesStruct *)SiS300_PanelType02_1; @@ -320,30 +328,28 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) 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_CHTVUNTSCDesData = (SiS_LVDSDesStruct *)SiS300_CHTVUNTSCDesData; - SiS_Pr->SiS_CHTVONTSCDesData = (SiS_LVDSDesStruct *)SiS300_CHTVONTSCDesData; - SiS_Pr->SiS_CHTVUPALDesData = (SiS_LVDSDesStruct *)SiS300_CHTVUPALDesData; - SiS_Pr->SiS_CHTVOPALDesData = (SiS_LVDSDesStruct *)SiS300_CHTVOPALDesData; + + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1a; + SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2a; + } + if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { + SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1b; + SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2b; + } + SiS_Pr->SiS_LVDSCRT1800x600_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_1; SiS_Pr->SiS_LVDSCRT11024x768_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_1; SiS_Pr->SiS_LVDSCRT11280x1024_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_1; - SiS_Pr->SiS_LVDSCRT11024x600_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x600_1; - SiS_Pr->SiS_LVDSCRT11152x768_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11152x768_1; SiS_Pr->SiS_LVDSCRT1800x600_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_1_H; SiS_Pr->SiS_LVDSCRT11024x768_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_1_H; SiS_Pr->SiS_LVDSCRT11280x1024_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_1_H; - SiS_Pr->SiS_LVDSCRT11024x600_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x600_1_H; - SiS_Pr->SiS_LVDSCRT11152x768_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11152x768_1_H; SiS_Pr->SiS_LVDSCRT1800x600_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_2; SiS_Pr->SiS_LVDSCRT11024x768_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_2; SiS_Pr->SiS_LVDSCRT11280x1024_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_2; - SiS_Pr->SiS_LVDSCRT11024x600_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x600_2; - SiS_Pr->SiS_LVDSCRT11152x768_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11152x768_2; SiS_Pr->SiS_LVDSCRT1800x600_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_2_H; SiS_Pr->SiS_LVDSCRT11024x768_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_2_H; SiS_Pr->SiS_LVDSCRT11280x1024_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_2_H; - SiS_Pr->SiS_LVDSCRT11024x600_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x600_2_H; - SiS_Pr->SiS_LVDSCRT11152x768_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11152x768_2_H; SiS_Pr->SiS_CHTVCRT1UNTSC = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1UNTSC; SiS_Pr->SiS_CHTVCRT1ONTSC = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1ONTSC; SiS_Pr->SiS_CHTVCRT1UPAL = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1UPAL; @@ -368,7 +374,6 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->SiS_CHTVVCLKOPALN = SiS300_CHTVVCLKOPAL; /* not supported on 300 series */ SiS_Pr->SiS_CHTVVCLKSOPAL = SiS300_CHTVVCLKSOPAL; - /* TW: New from 300/301LV BIOS */ SiS_Pr->SiS_CRT2Part2_1024x768_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1024x768_1; SiS_Pr->SiS_CRT2Part2_1280x1024_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1280x1024_1; SiS_Pr->SiS_CRT2Part2_1400x1050_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_1; @@ -382,7 +387,7 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->SiS_CRT2Part2_1400x1050_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_3; SiS_Pr->SiS_CRT2Part2_1600x1200_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1600x1200_3; - /* TW: LCDResInfo will on 300 series be translated to 310/325 series definitions */ + /* LCDResInfo will on 300 series be translated to 315 series definitions */ SiS_Pr->SiS_Panel320x480 = Panel_320x480; SiS_Pr->SiS_Panel640x480 = Panel_640x480; SiS_Pr->SiS_Panel800x600 = Panel_800x600; @@ -391,43 +396,71 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->SiS_Panel1280x960 = Panel_1280x960; SiS_Pr->SiS_Panel1024x600 = Panel_1024x600; SiS_Pr->SiS_Panel1152x768 = Panel_1152x768; - SiS_Pr->SiS_Panel1600x1200 = 16; /* TW: Something illegal */ - SiS_Pr->SiS_Panel1400x1050 = 16; /* TW: Something illegal */ - SiS_Pr->SiS_Panel1152x864 = 16; /* TW: Something illegal */ - SiS_Pr->SiS_Panel1280x768 = 16; /* TW: Something illegal */ - SiS_Pr->SiS_PanelMax = Panel_320x480; /* TW: highest value */ - SiS_Pr->SiS_PanelMinLVDS = Panel_800x600; /* TW: Lowest value LVDS */ - SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* TW: lowest value 301 */ + SiS_Pr->SiS_Panel1280x768 = Panel_1280x768; + SiS_Pr->SiS_Panel1600x1200 = 255; /* Something illegal */ + SiS_Pr->SiS_Panel1400x1050 = 255; + SiS_Pr->SiS_Panel640x480_2 = 255; + SiS_Pr->SiS_Panel640x480_3 = 255; + SiS_Pr->SiS_Panel1152x864 = 255; + SiS_Pr->SiS_PanelMax = Panel_320x480; /* highest value */ + SiS_Pr->SiS_PanelMinLVDS = Panel_800x600; /* Lowest value LVDS */ + SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* lowest value 301 */ + SiS_Pr->SiS_PanelCustom = Panel_Custom; + SiS_Pr->SiS_PanelBarco1366 = Panel_Barco1366; } #endif #ifdef SIS315H static void -InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { + InitCommonPointer(SiS_Pr, HwInfo); + + SiS_StandTable[0x04].CRTC[4] = 0x2c; + SiS_StandTable[0x05].CRTC[4] = 0x2c; + SiS_StandTable[0x06].CRTC[4] = 0x55; + SiS_StandTable[0x06].CRTC[5] = 0x81; + SiS_StandTable[0x0d].CRTC[4] = 0x2c; + SiS_StandTable[0x0e].CRTC[4] = 0x55; + SiS_StandTable[0x0e].CRTC[5] = 0x81; + SiS_StandTable[0x11].CRTC[4] = 0x55; + SiS_StandTable[0x11].CRTC[5] = 0x81; + SiS_StandTable[0x11].CRTC[16] = 0x82; + SiS_StandTable[0x11].CRTC[17] = 0x84; + SiS_StandTable[0x12].CRTC[4] = 0x55; + SiS_StandTable[0x12].CRTC[5] = 0x81; + SiS_StandTable[0x12].CRTC[16] = 0x82; + SiS_StandTable[0x12].CRTC[17] = 0x84; + SiS_StandTable[0x13].CRTC[5] = 0xb1; + SiS_StandTable[0x17].CRTC[5] = 0xb1; + SiS_StandTable[0x1a].CRTC[4] = 0x55; + SiS_StandTable[0x1a].CRTC[5] = 0x81; + SiS_StandTable[0x1a].CRTC[16] = 0xe9; + SiS_StandTable[0x1a].CRTC[17] = 0x8b; + SiS_StandTable[0x1b].CRTC[4] = 0x55; + SiS_StandTable[0x1b].CRTC[5] = 0x81; + SiS_StandTable[0x1b].CRTC[16] = 0xe9; + SiS_StandTable[0x1b].CRTC[17] = 0x8b; + SiS_StandTable[0x1c].CRTC[4] = 0x55; + SiS_StandTable[0x1c].CRTC[5] = 0x81; + SiS_Pr->SiS_SModeIDTable = (SiS_StStruct *)SiS310_SModeIDTable; - SiS_Pr->SiS_StandTable = (SiS_StandTableStruct *)SiS310_StandTable; SiS_Pr->SiS_EModeIDTable = (SiS_ExtStruct *)SiS310_EModeIDTable; SiS_Pr->SiS_RefIndex = (SiS_Ext2Struct *)SiS310_RefIndex; SiS_Pr->SiS_CRT1Table = (SiS_CRT1TableStruct *)SiS310_CRT1Table; - /* TW: MCLK is different */ - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_661) { + SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_660; /* 661/741/760 */ + } else if(HwInfo->jChipType == SIS_330) { SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_330; /* 330 */ - } else if(HwDeviceExtension->jChipType > SIS_315PRO) { - SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_650; /* 550, 650 */ + } else if(HwInfo->jChipType > SIS_315PRO) { + SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_650; /* 550, 650, 740 */ } else { SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_315; /* 315 */ } SiS_Pr->SiS_MCLKData_1 = (SiS_MCLKDataStruct *)SiS310_MCLKData_1; - SiS_Pr->SiS_ECLKData = (SiS_ECLKDataStruct *)SiS310_ECLKData; SiS_Pr->SiS_VCLKData = (SiS_VCLKDataStruct *)SiS310_VCLKData; SiS_Pr->SiS_VBVCLKData = (SiS_VBVCLKDataStruct *)SiS310_VBVCLKData; SiS_Pr->SiS_ScreenOffset = SiS310_ScreenOffset; - SiS_Pr->SiS_StResInfo = (SiS_StResInfoStruct *)SiS310_StResInfo; - SiS_Pr->SiS_ModeResInfo = (SiS_ModeResInfoStruct *)SiS310_ModeResInfo; - - SiS_Pr->pSiS_OutputSelect = &SiS310_OutputSelect; - SiS_Pr->pSiS_SoftSetting = &SiS310_SoftSetting; SiS_Pr->SiS_SR15 = SiS310_SR15; @@ -456,16 +489,6 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->pSiS_YCSenseData2 = &SiS310_YCSenseData2; #endif - SiS_Pr->SiS_NTSCPhase = SiS310_NTSCPhase; - SiS_Pr->SiS_PALPhase = SiS310_PALPhase; - SiS_Pr->SiS_NTSCPhase2 = SiS310_NTSCPhase2; - SiS_Pr->SiS_PALPhase2 = SiS310_PALPhase2; - SiS_Pr->SiS_PALMPhase = SiS310_PALMPhase; - SiS_Pr->SiS_PALNPhase = SiS310_PALNPhase; - SiS_Pr->SiS_PALMPhase2 = SiS310_PALMPhase2; - SiS_Pr->SiS_PALNPhase2 = SiS310_PALNPhase2; - SiS_Pr->SiS_SpecialPhase = SiS310_SpecialPhase; - SiS_Pr->SiS_StLCD1024x768Data = (SiS_LCDDataStruct *)SiS310_StLCD1024x768Data; SiS_Pr->SiS_ExtLCD1024x768Data = (SiS_LCDDataStruct *)SiS310_ExtLCD1024x768Data; SiS_Pr->SiS_St2LCD1024x768Data = (SiS_LCDDataStruct *)SiS310_St2LCD1024x768Data; @@ -474,64 +497,10 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->SiS_St2LCD1280x1024Data = (SiS_LCDDataStruct *)SiS310_St2LCD1280x1024Data; SiS_Pr->SiS_NoScaleData1024x768 = (SiS_LCDDataStruct *)SiS310_NoScaleData1024x768; SiS_Pr->SiS_NoScaleData1280x1024 = (SiS_LCDDataStruct *)SiS310_NoScaleData1280x1024; - SiS_Pr->SiS_LCD1280x960Data = (SiS_LCDDataStruct *)SiS310_LCD1280x960Data; - SiS_Pr->SiS_ExtLCD1400x1050Data = (SiS_LCDDataStruct *)SiS310_ExtLCD1400x1050Data; - SiS_Pr->SiS_ExtLCD1600x1200Data = (SiS_LCDDataStruct *)SiS310_ExtLCD1600x1200Data; - SiS_Pr->SiS_StLCD1400x1050Data = (SiS_LCDDataStruct *)SiS310_StLCD1400x1050Data; - SiS_Pr->SiS_StLCD1600x1200Data = (SiS_LCDDataStruct *)SiS310_StLCD1600x1200Data; - SiS_Pr->SiS_NoScaleData1400x1050 = (SiS_LCDDataStruct *)SiS310_NoScaleData1400x1050; - SiS_Pr->SiS_NoScaleData1600x1200 = (SiS_LCDDataStruct *)SiS310_NoScaleData1600x1200; - - SiS_Pr->SiS_StPALData = (SiS_TVDataStruct *)SiS310_StPALData; - SiS_Pr->SiS_ExtPALData = (SiS_TVDataStruct *)SiS310_ExtPALData; - SiS_Pr->SiS_StNTSCData = (SiS_TVDataStruct *)SiS310_StNTSCData; - SiS_Pr->SiS_ExtNTSCData = (SiS_TVDataStruct *)SiS310_ExtNTSCData; -#ifdef oldHV - SiS_Pr->SiS_St1HiTVData = (SiS_TVDataStruct *)SiS310_St1HiTVData; - SiS_Pr->SiS_St2HiTVData = (SiS_TVDataStruct *)SiS310_St2HiTVData; - SiS_Pr->SiS_ExtHiTVData = (SiS_TVDataStruct *)SiS310_ExtHiTVData; -#endif - SiS_Pr->SiS_NTSCTiming = SiS310_NTSCTiming; - SiS_Pr->SiS_PALTiming = SiS310_PALTiming; -#ifdef oldHV - SiS_Pr->SiS_HiTVSt1Timing = SiS310_HiTVSt1Timing; - SiS_Pr->SiS_HiTVSt2Timing = SiS310_HiTVSt2Timing; - SiS_Pr->SiS_HiTVTextTiming = SiS310_HiTVTextTiming; - SiS_Pr->SiS_HiTVExtTiming = SiS310_HiTVExtTiming; - SiS_Pr->SiS_HiTVGroup3Data = SiS310_HiTVGroup3Data; - SiS_Pr->SiS_HiTVGroup3Simu = SiS310_HiTVGroup3Simu; - SiS_Pr->SiS_HiTVGroup3Text = SiS310_HiTVGroup3Text; -#endif - - SiS_Pr->SiS_PanelDelayTbl = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTbl; + SiS_Pr->SiS_PanelDelayTbl = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTbl; SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTblLVDS; - SiS_Pr->SiS_LVDS800x600Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS800x600Data_1; - SiS_Pr->SiS_LVDS800x600Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS800x600Data_2; - SiS_Pr->SiS_LVDS1024x768Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1024x768Data_1; - SiS_Pr->SiS_LVDS1024x768Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1024x768Data_2; - SiS_Pr->SiS_LVDS1280x1024Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x1024Data_1; - SiS_Pr->SiS_LVDS1280x1024Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x1024Data_2; - SiS_Pr->SiS_LVDS1280x960Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x960Data_1; - SiS_Pr->SiS_LVDS1280x960Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x960Data_2; - SiS_Pr->SiS_LVDS1400x1050Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1400x1050Data_1; - SiS_Pr->SiS_LVDS1400x1050Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1400x1050Data_2; - SiS_Pr->SiS_LVDS1280x768Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x768Data_1; - SiS_Pr->SiS_LVDS1280x768Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x768Data_2; - SiS_Pr->SiS_LVDS1024x600Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1024x600Data_1; - SiS_Pr->SiS_LVDS1024x600Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1024x600Data_2; - SiS_Pr->SiS_LVDS1152x768Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1152x768Data_1; - SiS_Pr->SiS_LVDS1152x768Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1152x768Data_2; - SiS_Pr->SiS_LVDSXXXxXXXData_1 = (SiS_LVDSDataStruct *)SiS310_LVDSXXXxXXXData_1; - SiS_Pr->SiS_LVDS320x480Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS320x480Data_1; - SiS_Pr->SiS_LVDS640x480Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS640x480Data_1; - SiS_Pr->SiS_LCDA1400x1050Data_1 = (SiS_LVDSDataStruct *)SiS310_LCDA1400x1050Data_1; - SiS_Pr->SiS_LCDA1400x1050Data_2 = (SiS_LVDSDataStruct *)SiS310_LCDA1400x1050Data_2; - SiS_Pr->SiS_LCDA1600x1200Data_1 = (SiS_LVDSDataStruct *)SiS310_LCDA1600x1200Data_1; - SiS_Pr->SiS_LCDA1600x1200Data_2 = (SiS_LVDSDataStruct *)SiS310_LCDA1600x1200Data_2; - SiS_Pr->SiS_CHTVUNTSCData = (SiS_LVDSDataStruct *)SiS310_CHTVUNTSCData; - SiS_Pr->SiS_CHTVONTSCData = (SiS_LVDSDataStruct *)SiS310_CHTVONTSCData; SiS_Pr->SiS_CHTVUPALData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALData; SiS_Pr->SiS_CHTVOPALData = (SiS_LVDSDataStruct *)SiS310_CHTVOPALData; SiS_Pr->SiS_CHTVUPALMData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALMData; @@ -539,6 +508,7 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) 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; @@ -572,16 +542,6 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->SiS_PanelType0e_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0e_2; SiS_Pr->SiS_PanelType0f_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0f_2; - SiS_Pr->LVDS1024x768Des_1 = (SiS_LVDSDesStruct *)SiS310_PanelType1076_1; - SiS_Pr->LVDS1280x1024Des_1 = (SiS_LVDSDesStruct *)SiS310_PanelType1210_1; - SiS_Pr->LVDS1400x1050Des_1 = (SiS_LVDSDesStruct *)SiS310_PanelType1296_1 ; - SiS_Pr->LVDS1600x1200Des_1 = (SiS_LVDSDesStruct *)SiS310_PanelType1600_1 ; - SiS_Pr->LVDS1024x768Des_2 = (SiS_LVDSDesStruct *)SiS310_PanelType1076_2; - SiS_Pr->LVDS1280x1024Des_2 = (SiS_LVDSDesStruct *)SiS310_PanelType1210_2; - SiS_Pr->LVDS1400x1050Des_2 = (SiS_LVDSDesStruct *)SiS310_PanelType1296_2; - SiS_Pr->LVDS1600x1200Des_2 = (SiS_LVDSDesStruct *)SiS310_PanelType1600_2 ; - - /* TW: New from 650/301LV BIOS */ SiS_Pr->SiS_CRT2Part2_1024x768_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1024x768_1; SiS_Pr->SiS_CRT2Part2_1280x1024_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1280x1024_1; SiS_Pr->SiS_CRT2Part2_1400x1050_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_1; @@ -595,50 +555,32 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->SiS_CRT2Part2_1400x1050_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_3; SiS_Pr->SiS_CRT2Part2_1600x1200_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1600x1200_3; - SiS_Pr->SiS_CHTVUNTSCDesData = (SiS_LVDSDesStruct *)SiS310_CHTVUNTSCDesData; - SiS_Pr->SiS_CHTVONTSCDesData = (SiS_LVDSDesStruct *)SiS310_CHTVONTSCDesData; - SiS_Pr->SiS_CHTVUPALDesData = (SiS_LVDSDesStruct *)SiS310_CHTVUPALDesData; - SiS_Pr->SiS_CHTVOPALDesData = (SiS_LVDSDesStruct *)SiS310_CHTVOPALDesData; - SiS_Pr->SiS_LVDSCRT1800x600_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_1; SiS_Pr->SiS_LVDSCRT11024x768_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_1; SiS_Pr->SiS_LVDSCRT11280x1024_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_1; SiS_Pr->SiS_LVDSCRT11400x1050_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_1; - SiS_Pr->SiS_LVDSCRT11280x768_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x768_1; - SiS_Pr->SiS_LVDSCRT11024x600_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x600_1; - SiS_Pr->SiS_LVDSCRT11152x768_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11152x768_1; SiS_Pr->SiS_LVDSCRT11600x1200_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_1; SiS_Pr->SiS_LVDSCRT1800x600_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_1_H; SiS_Pr->SiS_LVDSCRT11024x768_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_1_H; SiS_Pr->SiS_LVDSCRT11280x1024_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_1_H; SiS_Pr->SiS_LVDSCRT11400x1050_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_1_H; - SiS_Pr->SiS_LVDSCRT11280x768_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x768_1_H; - SiS_Pr->SiS_LVDSCRT11024x600_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x600_1_H; - SiS_Pr->SiS_LVDSCRT11152x768_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11152x768_1_H; SiS_Pr->SiS_LVDSCRT11600x1200_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_1_H; SiS_Pr->SiS_LVDSCRT1800x600_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_2; SiS_Pr->SiS_LVDSCRT11024x768_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_2; SiS_Pr->SiS_LVDSCRT11280x1024_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_2; SiS_Pr->SiS_LVDSCRT11400x1050_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_2; - SiS_Pr->SiS_LVDSCRT11280x768_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x768_2; - SiS_Pr->SiS_LVDSCRT11024x600_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x600_2; - SiS_Pr->SiS_LVDSCRT11152x768_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11152x768_2; SiS_Pr->SiS_LVDSCRT11600x1200_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_2; SiS_Pr->SiS_LVDSCRT1800x600_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_2_H; SiS_Pr->SiS_LVDSCRT11024x768_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_2_H; SiS_Pr->SiS_LVDSCRT11280x1024_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_2_H; SiS_Pr->SiS_LVDSCRT11400x1050_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_2_H; - SiS_Pr->SiS_LVDSCRT11280x768_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x768_2_H; - SiS_Pr->SiS_LVDSCRT11024x600_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x600_2_H; - SiS_Pr->SiS_LVDSCRT11152x768_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11152x768_2_H; SiS_Pr->SiS_LVDSCRT11600x1200_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_2_H; - SiS_Pr->SiS_LVDSCRT1XXXxXXX_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1XXXxXXX_1; - SiS_Pr->SiS_LVDSCRT1320x480_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1320x480_1; - SiS_Pr->SiS_CHTVCRT1UNTSC = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UNTSC; - SiS_Pr->SiS_CHTVCRT1ONTSC = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1ONTSC; - SiS_Pr->SiS_CHTVCRT1UPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UPAL; - SiS_Pr->SiS_CHTVCRT1OPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1OPAL; - SiS_Pr->SiS_CHTVCRT1SOPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1SOPAL; + SiS_Pr->SiS_CHTVCRT1UNTSC = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UNTSC; + SiS_Pr->SiS_CHTVCRT1ONTSC = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1ONTSC; + SiS_Pr->SiS_CHTVCRT1UPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UPAL; + SiS_Pr->SiS_CHTVCRT1OPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1OPAL; + SiS_Pr->SiS_CHTVCRT1SOPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1OPAL; + SiS_Pr->SiS_CHTVReg_UNTSC = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UNTSC; SiS_Pr->SiS_CHTVReg_ONTSC = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_ONTSC; SiS_Pr->SiS_CHTVReg_UPAL = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPAL; @@ -647,27 +589,25 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->SiS_CHTVReg_OPALM = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPALM; SiS_Pr->SiS_CHTVReg_UPALN = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPALN; SiS_Pr->SiS_CHTVReg_OPALN = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPALN; - SiS_Pr->SiS_CHTVReg_SOPAL = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_SOPAL; - SiS_Pr->SiS_LCDACRT1800x600_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_1; + SiS_Pr->SiS_CHTVReg_SOPAL = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPAL; + SiS_Pr->SiS_LCDACRT11024x768_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_1; SiS_Pr->SiS_LCDACRT11280x1024_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_1; SiS_Pr->SiS_LCDACRT11400x1050_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_1; SiS_Pr->SiS_LCDACRT11600x1200_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_1; - SiS_Pr->SiS_LCDACRT1800x600_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_1_H; SiS_Pr->SiS_LCDACRT11024x768_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_1_H; SiS_Pr->SiS_LCDACRT11280x1024_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_1_H; SiS_Pr->SiS_LCDACRT11400x1050_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_1_H; SiS_Pr->SiS_LCDACRT11600x1200_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_1_H; - SiS_Pr->SiS_LCDACRT1800x600_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_2; SiS_Pr->SiS_LCDACRT11024x768_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_2; SiS_Pr->SiS_LCDACRT11280x1024_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_2; SiS_Pr->SiS_LCDACRT11400x1050_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_2; SiS_Pr->SiS_LCDACRT11600x1200_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_2; - SiS_Pr->SiS_LCDACRT1800x600_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_2_H; SiS_Pr->SiS_LCDACRT11024x768_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_2_H; SiS_Pr->SiS_LCDACRT11280x1024_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_2_H; SiS_Pr->SiS_LCDACRT11400x1050_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_2_H; SiS_Pr->SiS_LCDACRT11600x1200_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_2_H; + SiS_Pr->SiS_CHTVVCLKUNTSC = SiS310_CHTVVCLKUNTSC; SiS_Pr->SiS_CHTVVCLKONTSC = SiS310_CHTVVCLKONTSC; SiS_Pr->SiS_CHTVVCLKUPAL = SiS310_CHTVVCLKUPAL; @@ -676,7 +616,7 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->SiS_CHTVVCLKOPALM = SiS310_CHTVVCLKOPALM; SiS_Pr->SiS_CHTVVCLKUPALN = SiS310_CHTVVCLKUPALN; SiS_Pr->SiS_CHTVVCLKOPALN = SiS310_CHTVVCLKOPALN; - SiS_Pr->SiS_CHTVVCLKSOPAL = SiS310_CHTVVCLKSOPAL; + SiS_Pr->SiS_CHTVVCLKSOPAL = SiS310_CHTVVCLKOPAL; SiS_Pr->SiS_Panel320x480 = Panel_320x480; SiS_Pr->SiS_Panel640x480 = Panel_640x480; @@ -690,1267 +630,608 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) SiS_Pr->SiS_Panel1152x864 = Panel_1152x864; SiS_Pr->SiS_Panel1280x768 = Panel_1280x768; SiS_Pr->SiS_Panel1024x600 = Panel_1024x600; - SiS_Pr->SiS_PanelMax = Panel_320x480; /* TW: highest value */ - SiS_Pr->SiS_PanelMinLVDS = Panel_800x600; /* TW: lowest value LVDS/LCDA */ - SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* TW: lowest value 301 */ + SiS_Pr->SiS_Panel640x480_2 = Panel_640x480_2; + SiS_Pr->SiS_Panel640x480_3 = Panel_640x480_3; + SiS_Pr->SiS_PanelMax = Panel_320x480; /* highest value */ + SiS_Pr->SiS_PanelMinLVDS = Panel_800x600; /* lowest value LVDS/LCDA */ + SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* lowest value 301 */ + SiS_Pr->SiS_PanelCustom = Panel_Custom; + SiS_Pr->SiS_PanelBarco1366 = 255; } #endif -#ifdef LINUXBIOS -/* -------------- SiSInit -----------------*/ -/* TW: I degraded this for LINUXBIOS only, because we - * don't need this otherwise. Under normal - * circumstances, the video BIOS has initialized - * the adapter for us. BTW, this code is incomplete - * and very possibly not functioning on newer chipsets. - */ -BOOLEAN -SiSInit(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - ULONG FBAddr = (ULONG)HwDeviceExtension->pjVideoMemoryAddress; - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; - UCHAR i, temp=0; - UCHAR SR11; -#ifdef LINUX_KERNEL - UCHAR temp1; - ULONG base; -#endif - UCHAR SR13=0, SR14=0, SR16=0 - UCHAR SR17=0, SR19=0, SR1A=0; -#ifdef SIS300 - UCHAR SR18=0, SR12=0; -#endif -#ifdef SIS315H - UCHAR CR37=0, CR38=0, CR79=0, - UCHAR CR7A=0, CR7B=0, CR7C=0; - UCHAR SR1B=0, SR15=0; - PSIS_DSReg pSR; - ULONG Temp; -#endif - UCHAR VBIOSVersion[5]; - - if(FBAddr==0) return (FALSE); - if(BaseAddr==0) return (FALSE); - - SiS_SetReg3((USHORT)(BaseAddr+0x12), 0x67); /* Misc */ - -#ifdef SIS315H - if(HwDeviceExtension->jChipType > SIS_315PRO) { - if(!HwDeviceExtension->bIntegratedMMEnabled) - return (FALSE); - } -#endif - - SiS_MemoryCopy(VBIOSVersion,HwDeviceExtension->szVBIOSVer,4); - VBIOSVersion[4]= 0x00; - - SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr); - - /* TW: Init pointers */ + switch(HwInfo->jChipType) { #ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) - InitTo310Pointer(SiS_Pr, HwDeviceExtension); + case SIS_315H: + case SIS_315: + case SIS_315PRO: + case SIS_550: + case SIS_650: + case SIS_740: + case SIS_330: + case SIS_661: + case SIS_741: + case SIS_660: + case SIS_760: + InitTo310Pointer(SiS_Pr, HwInfo); + break; #endif - #ifdef SIS300 - if((HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) || - (HwDeviceExtension->jChipType == SIS_300)) - InitTo300Pointer(SiS_Pr, HwDeviceExtension); + case SIS_300: + case SIS_540: + case SIS_630: + case SIS_730: + InitTo300Pointer(SiS_Pr, HwInfo); + break; #endif - - /* TW: Set SiS Register definitions */ - SiSRegInit(SiS_Pr, BaseAddr); - - /* TW: Determine LVDS/CH70xx/TRUMPION */ - SiS_Set_LVDS_TRUMPION(SiS_Pr, HwDeviceExtension); - - /* TW: Unlock registers */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); - -#ifdef LINUX_KERNEL - -#ifdef SIS300 /* Set SR14 */ - if((HwDeviceExtension->jChipType==SIS_540) || - (HwDeviceExtension->jChipType==SIS_630) || - (HwDeviceExtension->jChipType==SIS_730)) { - base=0x80000060; - OutPortLong(base,0xcf8); - temp1 = InPortLong(0xcfc); - temp1 >>= (16+8+4); - temp1 &= 0x07; - temp1++; - temp1 = 1 << temp1; - SR14 = temp1 - 1; - base = 0x80000064; - OutPortLong(base,0xcf8); - temp1 = InPortLong(0xcfc); - temp1 &= 0x00000020; - if(temp1) SR14 |= 0x80; - else SR14 |= 0x40; - } -#endif - -#ifdef SIS315H /* Set SR14 */ - if(HwDeviceExtension->jChipType == SIS_550) { - base = 0x80000060; - OutPortLong(base,0xcf8); - temp1 = InPortLong(0xcfc); - temp1 >>= (16+8+4); - temp1 &= 0x07; - temp1++; - temp1 = 1 << temp1; - SR14 = temp1 - 1; - base = 0x80000064; - OutPortLong(base,0xcf8); - temp1 = InPortLong(0xcfc); - temp1 &= 0x00000020; - if(temp1) SR14 |= 0x80; - else SR14 |= 0x40; - } - - if((HwDeviceExtension->jChipType == SIS_740) || /* Set SR14 */ - (HwDeviceExtension->jChipType == SIS_650)) { - base = 0x80000064; - OutPortLong(base,0xcf8); - temp1=InPortLong(0xcfc); - temp1 >>= 4; - temp1 &= 0x07; - if(temp1 > 2) { - temp = temp1; - switch(temp) { - case 3: temp1 = 0x07; break; - case 4: temp1 = 0x0F; break; - case 5: temp1 = 0x1F; break; - case 6: temp1 = 0x05; break; - case 7: temp1 = 0x17; break; - case 8: break; - case 9: break; - } - } - SR14 = temp1; - base = 0x8000007C; - OutPortLong(base,0xcf8); - temp1 = InPortLong(0xcfc); - temp1 &= 0x00000020; - if(temp1) SR14 |= 0x80; - } -#endif - -#endif /* Linux kernel */ - -#ifdef SIS300 - if((HwDeviceExtension->jChipType == SIS_540)|| - (HwDeviceExtension->jChipType == SIS_630)|| - (HwDeviceExtension->jChipType == SIS_730)) { - SR12 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x12); - SR13 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13); - SR14 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - SR16 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - SR17 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17); - SR18 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18); - SR19 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x19); - SR1A = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); - } else if(HwDeviceExtension->jChipType == SIS_300){ - SR13 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13); - SR14 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); + default: + break; } -#endif -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_650)) { - SR19 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x19); - SR19 = (SR19)||0x01; /* TW: ??? || ??? */ - if(SR19==0x00) { - SR13 = 0x22; - SR14 = 0x00; - SR15 = 0x01; - SR16 = 0x00; - SR17 = 0x00; - SR1A = 0x00; - SR1B = 0x00; - CR37 = 0x00; - CR38 = 0x00; - CR79 = 0x00; - CR7A = 0x00; - CR7B = 0x00; - CR7C = 0x00; - } else { - SR13 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13); - SR14 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - SR15 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15); - SR16 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - SR17 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17); - SR1A = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); - SR1B = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1B); - CR37 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37); /* TW: Was 0x02 - why? */ - CR38 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - CR79 = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x79); - CR7A = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x7A); - CR7B = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x7B); - CR7C = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x7C); - } - } -#endif - - /* Reset extended registers */ - - for(i=0x06; i< 0x20; i++) SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0); - for(i=0x21; i<=0x27; i++) SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0); - for(i=0x31; i<=0x3D; i++) SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0); - -#ifdef SIS300 - if((HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) || - (HwDeviceExtension->jChipType == SIS_300)) { - for(i=0x38; i<=0x3F; i++) SiS_SetReg1(SiS_Pr->SiS_P3d4,i,0); - } -#endif - -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) { - for(i=0x12; i<=0x1B; i++) SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0); - for(i=0x79; i<=0x7C; i++) SiS_SetReg1(SiS_Pr->SiS_P3d4,i,0); - } -#endif - - /* Restore Extended Registers */ - -#ifdef SIS300 - if((HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730)) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x12,SR12); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,SR13); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,SR14); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,SR16); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,SR17); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x18,SR18); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x19,SR19); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1A,SR1A); - } -#endif - -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_650)) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,SR13); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,SR14); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x15,SR15); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,SR16); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,SR17); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x19,SR19); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1A,SR1A); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1B,SR1B); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,CR37); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x38,CR38); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x79,CR79); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x7A,CR7A); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x7B,CR7B); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x7C,CR7C); - } -#endif - -#ifdef SIS300 - if((HwDeviceExtension->jChipType==SIS_540) || - (HwDeviceExtension->jChipType==SIS_630) || - (HwDeviceExtension->jChipType==SIS_730)) { - temp = (UCHAR)SR1A & 0x03; - } else if(HwDeviceExtension->jChipType == SIS_300) { - /* TW: Nothing */ - } -#endif -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_330) ) { - if((*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) == 0) { - temp = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A) & 0x03; - } - } - if((HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_650)) { - if((*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) == 0) { - temp = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x07; - } - } -#endif - - SiS_Pr->SiS_RAMType = temp; - SiS_SetMemoryClock(SiS_Pr, ROMAddr, HwDeviceExtension); - - /* Set default register contents */ - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x07,*SiS_Pr->pSiS_SR07); /* DAC speed */ - - if((HwDeviceExtension->jChipType != SIS_540) && - (HwDeviceExtension->jChipType != SIS_630) && - (HwDeviceExtension->jChipType != SIS_730)){ - for(i=0x15;i<0x1C;i++) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,SiS_Pr->SiS_SR15[i-0x15][SiS_Pr->SiS_RAMType]); - } - } - -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_330)) { - for(i=0x40;i<=0x44;i++) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,SiS_Pr->SiS_CR40[i-0x40][SiS_Pr->SiS_RAMType]); - } - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x48,0x23); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x49,SiS_Pr->SiS_CR49[0]); - /* SiS_SetReg1(SiS_Pr->SiS_P3c4,0x25,SiS_Pr->SiS_SR25[0]); */ - } -#endif - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1F,*SiS_Pr->pSiS_SR1F); /* DAC pedestal */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x20,0xA0); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x23,*SiS_Pr->pSiS_SR23); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x24,*SiS_Pr->pSiS_SR24); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x25,SiS_Pr->SiS_SR25[0]); - -#ifdef SIS300 - if(HwDeviceExtension->jChipType == SIS_300) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x21,0x84); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x22,0x00); - } -#endif - - SR11 = 0x0F; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x11,SR11); /* Power Management & DDC port */ - - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x02,*SiS_Pr->pSiS_CRT2Data_1_2); - -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2E,0x08); /* use VB */ -#endif - - temp = *SiS_Pr->pSiS_SR32; - if(SiS_BridgeIsOn(SiS_Pr, BaseAddr)) { - temp &= 0xEF; - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); - -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_330)) { - HwDeviceExtension->pQueryVGAConfigSpace(HwDeviceExtension,0x50,0,&Temp); - Temp >>= 20; - Temp &= 0xF; - if (Temp != 1) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x25,SiS_Pr->SiS_SR25[1]); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x49,SiS_Pr->SiS_CR49[1]); - } - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x27,0x1F); - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,*SiS_Pr->pSiS_SR31); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,*SiS_Pr->pSiS_SR32); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x33,*SiS_Pr->pSiS_SR33); - } -#endif - - if (SiS_BridgeIsOn(SiS_Pr, BaseAddr) == 0) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,0x1C); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0D,*SiS_Pr->pSiS_CRT2Data_4_D); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0E,*SiS_Pr->pSiS_CRT2Data_4_E); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x10,*SiS_Pr->pSiS_CRT2Data_4_10); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0F,0x3F); - } - SiS_LockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); - } - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x83,0x00); - -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_330)) { - if(HwDeviceExtension->bSkipDramSizing==TRUE) { - SiS_SetDRAMModeRegister(SiS_Pr, ROMAddr,HwDeviceExtension); - pSR = HwDeviceExtension->pSR; - if(pSR != NULL) { - while(pSR->jIdx != 0xFF) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,pSR->jIdx,pSR->jVal); - pSR++; - } - } - } else SiS_SetDRAMSize_310(SiS_Pr, HwDeviceExtension); - } -#endif - -#ifdef SIS315H - if(HwDeviceExtension->jChipType == SIS_550) { - /* SetDRAMConfig begin */ -/* SiS_SetReg1(SiS_Pr->SiS_P3c4,0x12,SR12); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,SR13); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,SR14); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,SR16); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,SR17); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x18,SR18); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x19,SR19); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1A,SR1A); */ - /* SetDRAMConfig end */ - } -#endif - -#ifdef SIS300 - if(HwDeviceExtension->jChipType == SIS_300) { - if (HwDeviceExtension->bSkipDramSizing == TRUE) { -/* SiS_SetDRAMModeRegister(ROMAddr,HwDeviceExtension); - temp = (HwDeviceExtension->pSR)->jVal; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,temp); - temp = (HwDeviceExtension->pSR)->jVal; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,temp); */ - } else { -#ifdef TC - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,SR13); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,SR14); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x15,0xFF,0x04); -#else - SiS_SetDRAMSize_300(SiS_Pr, HwDeviceExtension); - SiS_SetDRAMSize_300(SiS_Pr, HwDeviceExtension); -#endif - } - } - if((HwDeviceExtension->jChipType==SIS_540)|| - (HwDeviceExtension->jChipType==SIS_630)|| - (HwDeviceExtension->jChipType==SIS_730)) { -#if 0 - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x12,SR12); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,SR13); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,SR14); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,SR16); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,SR17); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x18,SR18); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x19,SR19); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1A,SR1A); -#endif - } -/* SetDRAMSize end */ -#endif /* SIS300 */ - - /* Set default Ext2Regs */ -#if 0 - AGP=1; - temp=(UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A); - temp &= 0x30; - if(temp == 0x30) AGP=0; - if(AGP == 0) *SiS_Pr->pSiS_SR21 &= 0xEF; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x21,*SiS_Pr->pSiS_SR21); - if(AGP == 1) *SiS_Pr->pSiS_SR22 &= 0x20; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x22,*SiS_Pr->pSiS_SR22); -#endif - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x21,*SiS_Pr->pSiS_SR21); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x22,*SiS_Pr->pSiS_SR22); - -#if 0 - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff); - SiS_ClearDAC(SiS_Pr, SiS_Pr->SiS_P3c8); -#endif - -#ifdef LINUXBIOS /* TW: This is not needed for our purposes */ - SiS_DetectMonitor(SiS_Pr, HwDeviceExtension,BaseAddr); /* Sense CRT1 */ - SiS_GetSenseStatus(SiS_Pr, HwDeviceExtension,ROMAddr); /* Sense CRT2 */ -#endif - - return(TRUE); } -void -SiS_Set_LVDS_TRUMPION(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp = 0; - -#ifdef SiS300 - if((HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730)) { - /* TW: Read POWER_ON_TRAP and copy to CR37 */ - temp = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); - temp = (temp & 0xE0) >> 4; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,0xF1,temp); - } -#endif -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) { -#if 0 /* TW: This is not required */ - /* TW: Read POWER_ON_TRAP and copy to CR37 */ - temp = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); - temp = (temp & 0xE0) >> 4; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,0xF1,temp); -#endif - } -#endif - - SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, 0); -} - -/* =============== SiS 300 dram sizing begin =============== */ -#ifdef SIS300 -void -SiS_SetDRAMSize_300(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - ULONG FBAddr = (ULONG)HwDeviceExtension->pjVideoMemoryAddress; - USHORT SR13, SR14=0, buswidth, Done; - SHORT i, j, k; - USHORT data, TotalCapacity, PhysicalAdrOtherPage=0; - ULONG Addr; - UCHAR temp; - int PseudoRankCapacity, PseudoTotalCapacity, PseudoAdrPinCount; - int RankCapacity, AdrPinCount, BankNumHigh, BankNumMid, MB2Bank; - int PageCapacity, PhysicalAdrHigh, PhysicalAdrHalfPage; - - SiSSetMode(SiS_Pr, HwDeviceExtension, 0x2e); - - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x20); /* Turn OFF Display */ - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,0x00); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0xBF); - - buswidth = SiS_ChkBUSWidth_300(SiS_Pr, FBAddr); - - MB2Bank = 16; - Done = 0; - for(i=6; i>=0; i--) { - if(Done == 1) break; - PseudoRankCapacity = 1 << i; - for(j=4; j>=1; j--) { - if(Done == 1) break; - PseudoTotalCapacity = PseudoRankCapacity * j; - PseudoAdrPinCount = 15 - j; - if(PseudoTotalCapacity <= 64) { - for(k=0; k<=16; k++) { - if(Done == 1) break; - RankCapacity = buswidth * SiS_DRAMType[k][3]; - AdrPinCount = SiS_DRAMType[k][2] + SiS_DRAMType[k][0]; - if(RankCapacity == PseudoRankCapacity) - if(AdrPinCount <= PseudoAdrPinCount) { - if(j == 3) { /* Rank No */ - BankNumHigh = RankCapacity * MB2Bank * 3 - 1; - BankNumMid = RankCapacity * MB2Bank * 1 - 1; - } else { - BankNumHigh = RankCapacity * MB2Bank * j - 1; - BankNumMid = RankCapacity * MB2Bank * j / 2 - 1; - } - PageCapacity = (1 << SiS_DRAMType[k][1]) * buswidth * 4; - PhysicalAdrHigh = BankNumHigh; - PhysicalAdrHalfPage = (PageCapacity / 2 + PhysicalAdrHigh) % PageCapacity; - PhysicalAdrOtherPage = PageCapacity * SiS_DRAMType[k][2] + PhysicalAdrHigh; - /* Write data */ - /*Test*/ - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x15,0xFB); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x15,0x04); - /*/Test*/ - TotalCapacity = SiS_DRAMType[k][3] * buswidth; - SR13 = SiS_DRAMType[k][4]; - if(buswidth == 4) SR14 = (TotalCapacity - 1) | 0x80; - if(buswidth == 2) SR14 = (TotalCapacity - 1) | 0x40; - if(buswidth == 1) SR14 = (TotalCapacity - 1) | 0x00; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,SR13); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,SR14); - - Addr = FBAddr + (BankNumHigh) * 64 * 1024 + PhysicalAdrHigh; - *((USHORT *)(Addr)) = (USHORT)PhysicalAdrHigh; - Addr = FBAddr + (BankNumMid) * 64 * 1024 + PhysicalAdrHigh; - *((USHORT *)(Addr)) = (USHORT)BankNumMid; - Addr = FBAddr + (BankNumHigh) * 64 * 1024 + PhysicalAdrHalfPage; - *((USHORT *)(Addr)) = (USHORT)PhysicalAdrHalfPage; - Addr = FBAddr + (BankNumHigh) * 64 * 1024 + PhysicalAdrOtherPage; - *((USHORT *)(Addr)) = PhysicalAdrOtherPage; - - /* Read data */ - Addr = FBAddr + (BankNumHigh) * 64 * 1024 + PhysicalAdrHigh; - data = *((USHORT *)(Addr)); - if(data == PhysicalAdrHigh) Done = 1; - } /* if struct */ - } /* for loop (k) */ - } /* if struct */ - } /* for loop (j) */ - } /* for loop (i) */ -} +/*********************************************/ +/* HELPER: Get ModeID */ +/*********************************************/ USHORT -SiS_ChkBUSWidth_300(SiS_Private *SiS_Pr, ULONG FBAddress) +SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, BOOLEAN FSTN) { - PULONG pVideoMemory; + USHORT ModeIndex = 0; - pVideoMemory = (PULONG)FBAddress; - - pVideoMemory[0] = 0x01234567L; - pVideoMemory[1] = 0x456789ABL; - pVideoMemory[2] = 0x89ABCDEFL; - pVideoMemory[3] = 0xCDEF0123L; - if (pVideoMemory[3]==0xCDEF0123L) { /* Channel A 128bit */ - return(4); - } - if (pVideoMemory[1]==0x456789ABL) { /* Channel B 64bit */ - return(2); + switch(HDisplay) + { + case 320: + if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; + else if(VDisplay == 240) { + if(FSTN) ModeIndex = ModeIndex_320x240_FSTN[Depth]; + else ModeIndex = ModeIndex_320x240[Depth]; + } + break; + case 400: + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + break; + case 512: + if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; + break; + case 640: + if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; + else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; + break; + case 720: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth]; + else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth]; + } + break; + case 768: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; + } + break; + case 800: + if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; + else if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth]; + } + break; + case 848: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; + } + break; + case 856: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; + } + break; + case 1024: + if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + else if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; + else if(VGAEngine == SIS_300_VGA) { + if(VDisplay == 600) ModeIndex = ModeIndex_1024x600[Depth]; + } + } + break; + case 1152: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; + else if(VGAEngine == SIS_300_VGA) { + if(VDisplay == 768) ModeIndex = ModeIndex_1152x768[Depth]; + } + } + break; + case 1280: + if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; + else if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 960) ModeIndex = ModeIndex_1280x960[Depth]; + else if(VDisplay == 720) ModeIndex = ModeIndex_1280x720[Depth]; + else if(VDisplay == 768) { + if(VGAEngine == SIS_300_VGA) { + ModeIndex = ModeIndex_300_1280x768[Depth]; + } else { + ModeIndex = ModeIndex_310_1280x768[Depth]; + } + } + } + break; + case 1360: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; + else if(VGAEngine == SIS_300_VGA) { + if(VDisplay == 1024) ModeIndex = ModeIndex_300_1360x1024[Depth]; + } + } + break; + case 1400: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; + } + break; + case 1600: + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + break; + case 1920: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 1440) ModeIndex = ModeIndex_1920x1440[Depth]; + } + break; + case 2048: + if(!(VBFlags & CRT1_LCDA)) { + if(VDisplay == 1536) { + if(VGAEngine == SIS_300_VGA) { + ModeIndex = ModeIndex_300_2048x1536[Depth]; + } else { + ModeIndex = ModeIndex_310_2048x1536[Depth]; + } + } + } + break; } - return(1); -} -#endif -/* =============== SiS 300 dram sizing end =============== */ - -/* ============ SiS 310/325 dram sizing begin ============== */ -#ifdef SIS315H - -/* TW: Moved Get310DRAMType further down */ -void -SiS_Delay15us(SiS_Private *SiS_Pr, ULONG ulMicrsoSec) -{ -} - -void -SiS_SDR_MRS(SiS_Private *SiS_Pr, ) -{ - USHORT data; - - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - data &= 0x3F; /* SR16 D7=0, D6=0 */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,data); /* enable mode register set(MRS) low */ - SiS_Delay15us(SiS_Pr, 0x100); - data |= 0x80; /* SR16 D7=1, D6=0 */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,data); /* enable mode register set(MRS) high */ - SiS_Delay15us(SiS_Pr, 0x100); + return(ModeIndex); } -void -SiS_DDR_MRS(SiS_Private *SiS_Pr) +USHORT +SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, + int Depth, BOOLEAN FSTN, USHORT CustomT, int LCDwidth, int LCDheight) { - USHORT data; - - /* SR16 <- 1F,DF,2F,AF */ + 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(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + } + break; + case 512: + if(CustomT != CUT_PANEL848) { + if(VDisplay == 384) { + if(LCDwidth != 1024 || LCDheight != 600) { + ModeIndex = ModeIndex_512x384[Depth]; + } + } + } + break; + case 640: + if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; + else if(VDisplay == 400) { + if(CustomT != CUT_PANEL848) ModeIndex = ModeIndex_640x400[Depth]; + } + break; + case 800: + if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; + break; + case 848: + if(CustomT == CUT_PANEL848) { + if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; + } + break; + case 1024: + if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + else if(VGAEngine == SIS_300_VGA) { + if((VDisplay == 600) && (LCDheight == 600)) { + ModeIndex = ModeIndex_1024x600[Depth]; + } + } + break; + case 1152: + if(VGAEngine == SIS_300_VGA) { + if((VDisplay == 768) && (LCDheight == 768)) { + ModeIndex = ModeIndex_1152x768[Depth]; + } + } + break; + case 1280: + if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; + else if(VGAEngine == SIS_315_VGA) { + if((VDisplay == 768) && (LCDheight == 768)) { + ModeIndex = ModeIndex_310_1280x768[Depth]; + } + } + break; + case 1360: + if(VGAEngine == SIS_300_VGA) { + if(CustomT == CUT_BARCO1366) { + if(VDisplay == 1024) ModeIndex = ModeIndex_300_1360x1024[Depth]; + } + } + if(CustomT == CUT_PANEL848) { + if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; + } + break; + case 1400: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; + } + break; + case 1600: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + } + break; + } - /* enable DLL of DDR SD/SGRAM , SR16 D4=1 */ - data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - data &= 0x0F; - data |= 0x10; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,data); + } else if(VBFlags & VB_SISBRIDGE) { - if (!(SiS_Pr->SiS_SR15[1][SiS_Pr->SiS_RAMType] & 0x10)) - data &= 0x0F; + switch(HDisplay) + { + case 320: + if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; + else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth]; + break; + case 400: + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + break; + case 512: + if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; + break; + case 640: + if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; + else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; + break; + case 800: + if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; + break; + case 1024: + if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + break; + case 1280: + if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; + else if(VDisplay == 768) { + if((LCDheight != 1050) && (LCDheight != 960)) { + if(VGAEngine == SIS_300_VGA) { + ModeIndex = ModeIndex_300_1280x768[Depth]; + } else { + ModeIndex = ModeIndex_310_1280x768[Depth]; + } + } + } else if(VDisplay == 960) { + if((LCDheight != 1050) && (LCDheight != 768)) { + ModeIndex = ModeIndex_1280x960[Depth]; + } + } + break; + case 1400: + if(VGAEngine == SIS_315_VGA) { + if(VBFlags & (VB_301B | VB_301C | VB_302B | VB_302LV | VB_302ELV)) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; + } + } + break; + case 1600: + if(VBFlags & (VB_301C | VB_302B | VB_302LV | VB_302ELV)) { + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + } + break; + } + } - /* SR16 D7=1,D6=1 */ - data |= 0xC0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,data); - - /* SR16 D7=1,D6=0,D5=1,D4=0 */ - data &= 0x0F; - data |= 0x20; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,data); - if (!(SiS_Pr->SiS_SR15[1][SiS_Pr->SiS_RAMType] & 0x10)) - data &= 0x0F; - - /* SR16 D7=1 */ - data |= 0x80; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,data); + return ModeIndex; } -void -SiS_SetDRAMModeRegister(SiS_Private *SiS_Pr, UCHAR *ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +USHORT +SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth) { - if (SiS_Get310DRAMType(ROMAddr,HwDeviceExtension) < 2) - SiS_SDR_MRS(SiS_Pr); - else - /* SR16 <- 0F,CF,0F,8F */ - SiS_DDR_MRS(SiS_Pr); -} + USHORT ModeIndex = 0; -void -SiS_DisableRefresh(SiS_Private *SiS_Pr) -{ - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x17,0xF8); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x19,0x03); -} + if(VBFlags & VB_CHRONTEL) { -void -SiS_EnableRefresh(SiS_Private *SiS_Pr, UCHAR *ROMAddr) -{ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,SiS_Pr->SiS_SR15[2][SiS_Pr->SiS_RAMType]); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x19,SiS_Pr->SiS_SR15[4][SiS_Pr->SiS_RAMType]); -} + 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; + } -void -SiS_DisableChannelInterleaving(SiS_Private *SiS_Pr, int index, - USHORT SiS_DDRDRAM_TYPE[][5]) -{ - USHORT data; + } else if(VBFlags & VB_SISTVBRIDGE) { - data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15); - data &= 0x1F; - switch (SiS_DDRDRAM_TYPE[index][3]) - { - case 64: data |= 0; break; - case 32: data |= 0x20; break; - case 16: data |= 0x40; break; - case 4: data |= 0x60; break; + 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_PAL) && (!(VBFlags & TV_PALM))) { + 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 | TV_HIVISION_LV))) { + if(VDisplay == 480) { + if((VBFlags & TV_NTSC) || (VBFlags & TV_PALM)) + ModeIndex = ModeIndex_720x480[Depth]; + } else if(VDisplay == 576) { + if((VBFlags & TV_PAL) && (!(VBFlags & TV_PALM))) + ModeIndex = ModeIndex_720x576[Depth]; + } + } + break; + case 768: + if(!(VBFlags & (TV_HIVISION | TV_HIVISION_LV))) { + if((VBFlags & TV_PAL) && (!(VBFlags & TV_PALM))) { + 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 | TV_HIVISION_LV)) { + 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 | TV_HIVISION_LV)) { + ModeIndex = ModeIndex_1024x576[Depth]; + } + } + break; + case 1280: + if(VBFlags & (TV_HIVISION | TV_HIVISION_LV)) { + if(VDisplay == 720) ModeIndex = ModeIndex_1280x720[Depth]; + else if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; + } + break; + } } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x15,data); + return ModeIndex; } -void -SiS_SetDRAMSizingType(SiS_Private *SiS_Pr, int index, USHORT DRAMTYPE_TABLE[][5]) -{ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,DRAMTYPE_TABLE[index][4]); - /* should delay 50 ns */ -} - -void -SiS_CheckBusWidth_310(SiS_Private *SiS_Pr, UCHAR *ROMAddress,ULONG FBAddress, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +USHORT +SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth) { - USHORT data, temp; - PULONG volatile pVideoMemory; + USHORT ModeIndex = 0; - pVideoMemory = (PULONG)FBAddress; + if(!(VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; - if(HwDeviceExtension->jChipType == SIS_330) temp = 1; - else temp = 2; - - if(SiS_Get310DRAMType(ROMAddress,HwDeviceExtension) < temp) { - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,0x00); - if(HwDeviceExtension->jChipType != SIS_330) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0x12); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0x02); - } - /* should delay */ - SiS_SDR_MRS(SiS_Pr); - - SiS_Pr->SiS_ChannelAB = 0; - SiS_Pr->SiS_DataBusWidth = 128; - pVideoMemory[0] = 0x01234567L; - pVideoMemory[1] = 0x456789ABL; - pVideoMemory[2] = 0x89ABCDEFL; - pVideoMemory[3] = 0xCDEF0123L; - pVideoMemory[4] = 0x55555555L; - pVideoMemory[5] = 0x55555555L; - pVideoMemory[6] = 0xFFFFFFFFL; - pVideoMemory[7] = 0xFFFFFFFFL; - if((pVideoMemory[3] != 0xCDEF0123L) || (pVideoMemory[2] != 0x89ABCDEFL)) { - /* Channel A 64Bit */ - SiS_Pr->SiS_DataBusWidth = 64; - SiS_Pr->SiS_ChannelAB = 0; - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x14, 0xFD); - } - if((pVideoMemory[1] != 0x456789ABL) || (pVideoMemory[0] != 0x01234567L)) { - /* Channel B 64Bit */ - SiS_Pr->SiS_DataBusWidth = 64; - SiS_Pr->SiS_ChannelAB = 1; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x14,0xfd,0x01); - } - return; - - } else { - - /* DDR Dual channel */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x13,0x00); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0x02); /* Channel A, 64bit */ - /* should delay */ - SiS_DDR_MRS(SiS_Pr); - - SiS_Pr->SiS_ChannelAB = 0; - SiS_Pr->SiS_DataBusWidth = 64; - pVideoMemory[0] = 0x01234567L; - pVideoMemory[1] = 0x456789ABL; - pVideoMemory[2] = 0x89ABCDEFL; - pVideoMemory[3] = 0xCDEF0123L; - pVideoMemory[4] = 0x55555555L; - pVideoMemory[5] = 0x55555555L; - pVideoMemory[6] = 0xAAAAAAAAL; - pVideoMemory[7] = 0xAAAAAAAAL; - - if (pVideoMemory[1] == 0x456789ABL) { - if (pVideoMemory[0] == 0x01234567L) { - /* Channel A 64bit */ - return; - } - } else { - if (pVideoMemory[0] == 0x01234567L) { - /* Channel A 32bit */ - SiS_Pr->SiS_DataBusWidth = 32; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0x00); - return; - } - } - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0x03); /* Channel B, 64bit */ - SiS_DDR_MRS(SiS_Pr); - - SiS_Pr->SiS_ChannelAB = 1; - SiS_Pr->SiS_DataBusWidth = 64; - pVideoMemory[0] = 0x01234567L; - pVideoMemory[1] = 0x456789ABL; - pVideoMemory[2] = 0x89ABCDEFL; - pVideoMemory[3] = 0xCDEF0123L; - pVideoMemory[4] = 0x55555555L; - pVideoMemory[5] = 0x55555555L; - pVideoMemory[6] = 0xAAAAAAAAL; - pVideoMemory[7] = 0xAAAAAAAAL; - if(pVideoMemory[1] == 0x456789ABL) { - /* Channel B 64 */ - if(pVideoMemory[0] == 0x01234567L) { - /* Channel B 64bit */ - return; - } else { - /* error */ - } - } else { - if(pVideoMemory[0] == 0x01234567L) { - /* Channel B 32 */ - SiS_Pr->SiS_DataBusWidth = 32; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,0x01); - } else { - /* error */ - } - } + switch(HDisplay) + { + case 320: + if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; + else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth]; + break; + case 400: + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + break; + case 512: + if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; + break; + case 640: + if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; + else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; + break; + case 720: + if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth]; + else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth]; + break; + case 768: + if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; + break; + case 800: + if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; + else if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth]; + break; + case 848: + if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; + break; + case 856: + if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; + break; + case 1024: + if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + else if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; + break; + case 1152: + if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; + else if(VGAEngine == SIS_300_VGA) { + if(VDisplay == 768) ModeIndex = ModeIndex_1152x768[Depth]; + } + break; + case 1280: + if(VDisplay == 768) { + if(VGAEngine == SIS_300_VGA) { + ModeIndex = ModeIndex_300_1280x768[Depth]; + } else { + ModeIndex = ModeIndex_310_1280x768[Depth]; + } + } else if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; + else if(VDisplay == 720) ModeIndex = ModeIndex_1280x720[Depth]; + else if(VDisplay == 960) ModeIndex = ModeIndex_1280x960[Depth]; + break; + case 1360: + if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; + break; + case 1400: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; + } + break; + case 1600: + if(VGAEngine == SIS_315_VGA) { + if(VBFlags & (VB_301B|VB_301C|VB_302B)) { + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + } + } + break; } -} -int -SiS_SetRank(SiS_Private *SiS_Pr, int index,UCHAR RankNo,USHORT DRAMTYPE_TABLE[][5]) -{ - USHORT data; - int RankSize; + return ModeIndex; +} - if ((RankNo==2)&&(DRAMTYPE_TABLE[index][0]==2)) - return 0; - RankSize = DRAMTYPE_TABLE[index][3]/2 * SiS_Pr->SiS_DataBusWidth / 32; +/*********************************************/ +/* HELPER: SetReg, GetReg */ +/*********************************************/ - if (RankNo * RankSize <= 128) { - data = 0; - while((RankSize >>= 1) > 0) { - data += 0x10; - } - data |= (RankNo - 1) << 2; - data |= (SiS_Pr->SiS_DataBusWidth / 64) & 2; - data |= SiS_Pr->SiS_ChannelAB; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,data); - /* should delay */ - SiS_SDR_MRS(SiS_Pr); - return 1; - } else - return 0; -} - -int -SiS_SetDDRChannel(SiS_Private *SiS_Pr, int index,UCHAR ChannelNo, - USHORT DRAMTYPE_TABLE[][5]) +void +SiS_SetReg(SISIOADDRESS port, USHORT index, USHORT data) { - USHORT data; - int RankSize; - - RankSize = DRAMTYPE_TABLE[index][3]/2 * SiS_Pr->SiS_DataBusWidth / 32; - /* RankSize = DRAMTYPE_TABLE[index][3]; */ - if (ChannelNo * RankSize <= 128) { - data = 0; - while((RankSize >>= 1) > 0) { - data += 0x10; - } - if(ChannelNo == 2) data |= 0x0C; - data |= (SiS_Pr->SiS_DataBusWidth / 32) & 2; - data |= SiS_Pr->SiS_ChannelAB; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,data); - /* should delay */ - SiS_DDR_MRS(SiS_Pr); - return 1; - } else - return 0; + OutPortByte(port,index); + OutPortByte(port + 1,data); } -int -SiS_CheckColumn(SiS_Private *SiS_Pr, int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress) +void +SiS_SetRegByte(SISIOADDRESS port, USHORT data) { - int i; - ULONG Increment,Position; - - /*Increment = 1<<(DRAMTYPE_TABLE[index][2] + SiS_Pr->SiS_DataBusWidth / 64 + 1); */ - Increment = 1 << (10 + SiS_Pr->SiS_DataBusWidth / 64); - - for (i=0,Position=0;i<2;i++) { - *((PULONG)(FBAddress + Position)) = Position; - Position += Increment; - } - - for (i=0,Position=0;i<2;i++) { -/* if (FBAddress[Position]!=Position) */ - if((*(PULONG)(FBAddress + Position)) != Position) - return 0; - Position += Increment; - } - return 1; + OutPortByte(port,data); } -int -SiS_CheckBanks(SiS_Private *SiS_Pr, int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress) +void +SiS_SetRegShort(SISIOADDRESS port, USHORT data) { - int i; - ULONG Increment,Position; - Increment = 1 << (DRAMTYPE_TABLE[index][2] + SiS_Pr->SiS_DataBusWidth / 64 + 2); - - for (i=0,Position=0;i<4;i++) { -/* FBAddress[Position]=Position; */ - *((PULONG)(FBAddress + Position)) = Position; - Position += Increment; - } - - for (i=0,Position=0;i<4;i++) { -/* if (FBAddress[Position]!=Position) */ - if((*(PULONG)(FBAddress + Position)) != Position) - return 0; - Position += Increment; - } - return 1; + OutPortWord(port,data); } -int -SiS_CheckRank(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress) +void +SiS_SetRegLong(SISIOADDRESS port, ULONG data) { - int i; - ULONG Increment,Position; - Increment = 1<<(DRAMTYPE_TABLE[index][2] + DRAMTYPE_TABLE[index][1] + - DRAMTYPE_TABLE[index][0] + SiS_Pr->SiS_DataBusWidth / 64 + RankNo); - - for (i=0,Position=0;i<2;i++) { -/* FBAddress[Position]=Position; */ - *((PULONG)(FBAddress+Position))=Position; - /* *((PULONG)(FBAddress))=Position; */ - Position += Increment; - } - - for (i=0,Position=0;i<2;i++) { -/* if (FBAddress[Position]!=Position) */ - if ( (*(PULONG) (FBAddress + Position)) !=Position) - /*if ( (*(PULONG) (FBAddress )) !=Position) */ - return 0; - Position += Increment; - } - return 1; + OutPortLong(port,data); } -int -SiS_CheckDDRRank(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress) +UCHAR +SiS_GetReg(SISIOADDRESS port, USHORT index) { - ULONG Increment,Position; - USHORT data; - - Increment = 1<<(DRAMTYPE_TABLE[index][2] + DRAMTYPE_TABLE[index][1] + - DRAMTYPE_TABLE[index][0] + SiS_Pr->SiS_DataBusWidth / 64 + RankNo); - - Increment += Increment/2; - - Position =0; - *((PULONG)(FBAddress+Position + 0)) = 0x01234567; - *((PULONG)(FBAddress+Position + 1)) = 0x456789AB; - *((PULONG)(FBAddress+Position + 2)) = 0x55555555; - *((PULONG)(FBAddress+Position + 3)) = 0x55555555; - *((PULONG)(FBAddress+Position + 4)) = 0xAAAAAAAA; - *((PULONG)(FBAddress+Position + 5)) = 0xAAAAAAAA; - - if ( (*(PULONG) (FBAddress + 1)) == 0x456789AB) - return 1; - - if ( (*(PULONG) (FBAddress + 0)) == 0x01234567) - return 0; - - data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - data &= 0xF3; - data |= 0x08; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x14,data); - data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15); - data += 0x20; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x15,data); - - return 1; + OutPortByte(port,index); + return(InPortByte(port + 1)); } -int -SiS_CheckRanks(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress) +UCHAR +SiS_GetRegByte(SISIOADDRESS port) { - int r; - - for (r=RankNo;r>=1;r--) { - if (!SiS_CheckRank(SiS_Pr, r, index, DRAMTYPE_TABLE, FBAddress)) - return 0; - } - if (!SiS_CheckBanks(SiS_Pr, index, DRAMTYPE_TABLE, FBAddress)) - return 0; - - if (!SiS_CheckColumn(SiS_Pr, index, DRAMTYPE_TABLE, FBAddress)) - return 0; - - return 1; + return(InPortByte(port)); } -int -SiS_CheckDDRRanks(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5], - ULONG FBAddress) +USHORT +SiS_GetRegShort(SISIOADDRESS port) { - int r; - - for (r=RankNo;r>=1;r--) { - if (!SiS_CheckDDRRank(SiS_Pr, r,index,DRAMTYPE_TABLE,FBAddress)) - return 0; - } - if (!SiS_CheckBanks(SiS_Pr, index,DRAMTYPE_TABLE,FBAddress)) - return 0; - - if (!SiS_CheckColumn(SiS_Pr, index,DRAMTYPE_TABLE,FBAddress)) - return 0; - - return 1; + return(InPortWord(port)); } -int -SiS_SDRSizing(SiS_Private *SiS_Pr, ULONG FBAddress) +ULONG +SiS_GetRegLong(SISIOADDRESS port) { - int i; - UCHAR j; - - for (i=0;i<13;i++) { - SiS_SetDRAMSizingType(SiS_Pr, i, SiS_SDRDRAM_TYPE); - for (j=2;j>0;j--) { - if (!SiS_SetRank(SiS_Pr, i,(UCHAR) j, SiS_SDRDRAM_TYPE)) - continue; - else { - if (SiS_CheckRanks(SiS_Pr, j,i,SiS_SDRDRAM_TYPE, FBAddress)) - return 1; - } - } - } - return 0; + return(InPortLong(port)); } -int -SiS_DDRSizing(SiS_Private *SiS_Pr, ULONG FBAddress) +void +SiS_SetRegANDOR(SISIOADDRESS Port,USHORT Index,USHORT DataAND,USHORT DataOR) { + USHORT temp; - int i; - UCHAR j; - - for (i=0; i<4; i++){ - SiS_SetDRAMSizingType(SiS_Pr, i, SiS_DDRDRAM_TYPE); - SiS_DisableChannelInterleaving(SiS_Pr, i, SiS_DDRDRAM_TYPE); - for (j=2; j>0; j--) { - SiS_SetDDRChannel(SiS_Pr, i, j, SiS_DDRDRAM_TYPE); - if (!SiS_SetRank(SiS_Pr, i, (UCHAR) j, SiS_DDRDRAM_TYPE)) - continue; - else { - if (SiS_CheckDDRRanks(SiS_Pr, j, i, SiS_DDRDRAM_TYPE, FBAddress)) - return 1; - } - } - } - return 0; + temp = SiS_GetReg(Port,Index); + temp = (temp & (DataAND)) | DataOR; + SiS_SetReg(Port,Index,temp); } -/* - check if read cache pointer is correct -*/ void -SiS_VerifyMclk(SiS_Private *SiS_Pr, ULONG FBAddr) -{ - PUCHAR pVideoMemory = (PUCHAR) FBAddr; - UCHAR i, j; - USHORT Temp,SR21; - - pVideoMemory[0] = 0xaa; /* alan */ - pVideoMemory[16] = 0x55; /* note: PCI read cache is off */ - - if((pVideoMemory[0] != 0xaa) || (pVideoMemory[16] != 0x55)) { - for (i=0,j=16; i<2; i++,j+=16) { - SR21 = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x21); - Temp = SR21 & 0xFB; /* disable PCI post write buffer empty gating */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x21,Temp); - - Temp = SiS_GetReg1(SiS_Pr->SiS_P3c4, 0x3C); - Temp |= 0x01; /* MCLK reset */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x3C,Temp); - Temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3C); - Temp &= 0xFE; /* MCLK normal operation */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x3C,Temp); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x21,SR21); - - pVideoMemory[16+j] = j; - if(pVideoMemory[16+j] == j) { - pVideoMemory[j] = j; - break; - } - } - } -} - -/* TW: Is this a 315E? */ -int -Is315E(SiS_Private *SiS_Pr) +SiS_SetRegAND(SISIOADDRESS Port,USHORT Index,USHORT DataAND) { - USHORT data; + USHORT temp; - data = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5F); - if(data & 0x10) return 1; - else return 0; + temp = SiS_GetReg(Port,Index); + temp &= DataAND; + SiS_SetReg(Port,Index,temp); } -/* TW: For 315 only */ void -SiS_SetDRAMSize_310(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_SetRegOR(SISIOADDRESS Port,USHORT Index,USHORT DataOR) { - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - ULONG FBAddr = (ULONG)HwDeviceExtension->pjVideoMemoryAddress; - USHORT data; - -#ifdef SIS301 /* TW: SIS301 ??? */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,0x40); */ -#endif -#ifdef SIS302 /* TW: SIS302 ??? */ - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,0x4D); /* alan,should change value */ - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x31,0xc0); /* alan,should change value */ - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x34,0x3F); /* alan,should change value */ -#endif - - SiSSetMode(SiS_Pr, HwDeviceExtension, 0x2e); - - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x21); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x21,0xDF); /* disable read cache */ - - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x20); /* Turn OFF Display */ - - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x16,0x0F); /* assume lowest speed DRAM */ - - SiS_SetDRAMModeRegister(SiS_Pr, ROMAddr, HwDeviceExtension); - SiS_DisableRefresh(SiS_Pr); - SiS_CheckBusWidth_310(SiS_Pr, ROMAddr, FBAddr, HwDeviceExtension); - - SiS_VerifyMclk(SiS_Pr, FBAddr); - - if(HwDeviceExtension->jChipType == SIS_330) temp = 1; - else temp = 2; - - if(SiS_Get310DRAMType(SiS_Pr, ROMAddr, HwDeviceExtension) < temp) - SiS_SDRSizing(SiS_Pr, FBAddr); - else - SiS_DDRSizing(SiS_Pr, FBAddr); - - if(HwDeviceExtension->jChipType != SIS_330) { - if(Is315E(SiS_Pr)) { - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - if((data & 0x0C) == 0x0C) { /* dual channel */ - if((data & 0xF0) > 0x40) - data = (data & 0x0F) | 0x40; - } else { /* single channel */ - if((data & 0xF0) > 0x50) - data = (data & 0x0F) | 0x50; - } - } - } - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x16,SiS_Pr->SiS_SR15[1][SiS_Pr->SiS_RAMType]); /* restore SR16 */ + USHORT temp; - SiS_EnableRefresh(SiS_Pr, ROMAddr); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x21,0x20); /* enable read cache */ + temp = SiS_GetReg(Port,Index); + temp |= DataOR; + SiS_SetReg(Port,Index,temp); } -#endif + +/*********************************************/ +/* HELPER: DisplayOn, DisplayOff */ +/*********************************************/ void -SiS_SetMemoryClock(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_DisplayOn(SiS_Private *SiS_Pr) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x28,SiS_Pr->SiS_MCLKData_0[SiS_Pr->SiS_RAMType].SR28); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x29,SiS_Pr->SiS_MCLKData_0[SiS_Pr->SiS_RAMType].SR29); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2A,SiS_Pr->SiS_MCLKData_0[SiS_Pr->SiS_RAMType].SR2A); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2E,SiS_Pr->SiS_ECLKData[SiS_Pr->SiS_RAMType].SR2E); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2F,SiS_Pr->SiS_ECLKData[SiS_Pr->SiS_RAMType].SR2F); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x30,SiS_Pr->SiS_ECLKData[SiS_Pr->SiS_RAMType].SR30); - -#ifdef SIS315H - if (Is315E(SiS_Pr)) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x28,0x3B); /* 143 */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x29,0x22); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2E,0x3B); /* 143 */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2F,0x22); - } -#endif + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x01,0xDF,0x00); } -#endif /* ifdef LINUXBIOS */ - -#ifdef SIS315H -UCHAR -SiS_Get310DRAMType(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) +void +SiS_DisplayOff(SiS_Private *SiS_Pr) { - UCHAR data, temp; - - if(*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) { - data = *SiS_Pr->pSiS_SoftSetting & 0x03; - } else { - if((HwDeviceExtension->jChipType > SIS_315PRO) && - (HwDeviceExtension->jChipType < SIS_330)) { - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x07; - } else { /* TW: 315, 330 */ - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3a) & 0x03; - if(HwDeviceExtension->jChipType == SIS_330) { - if(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; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x01,0xDF,0x20); } -#endif -/* SiSInit END */ -/* ----------------------------------------- */ +/*********************************************/ +/* HELPER: Init Port Addresses */ +/*********************************************/ -void SiSRegInit(SiS_Private *SiS_Pr, USHORT BaseAddr) +void +SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr) { SiS_Pr->SiS_P3c4 = BaseAddr + 0x14; SiS_Pr->SiS_P3d4 = BaseAddr + 0x24; @@ -1962,47 +1243,125 @@ void SiSRegInit(SiS_Private *SiS_Pr, USHORT BaseAddr) SiS_Pr->SiS_P3c7 = BaseAddr + 0x17; SiS_Pr->SiS_P3c8 = BaseAddr + 0x18; SiS_Pr->SiS_P3c9 = BaseAddr + 0x19; - SiS_Pr->SiS_P3da = BaseAddr + 0x2A; - SiS_Pr->SiS_Part1Port = BaseAddr + SIS_CRT2_PORT_04; /* Digital video interface registers (LCD) */ - SiS_Pr->SiS_Part2Port = BaseAddr + SIS_CRT2_PORT_10; /* 301 TV Encoder registers */ - SiS_Pr->SiS_Part3Port = BaseAddr + SIS_CRT2_PORT_12; /* 301 Macrovision registers */ - SiS_Pr->SiS_Part4Port = BaseAddr + SIS_CRT2_PORT_14; /* 301 VGA2 (and LCD) registers */ - SiS_Pr->SiS_Part5Port = BaseAddr + SIS_CRT2_PORT_14+2; /* 301 palette address port registers */ - SiS_Pr->SiS_DDC_Port = BaseAddr + 0x14; /* DDC Port ( = P3C4, SR11/0A) */ + 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) +/*********************************************/ +/* HELPER: GetSysFlags */ +/*********************************************/ + +static void +SiS_GetSysFlags(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { -/* #ifdef LINUX_XF86 */ - if ((HwDeviceExtension->jChipType == SIS_540)|| - (HwDeviceExtension->jChipType == SIS_630)|| - (HwDeviceExtension->jChipType == SIS_730)|| - (HwDeviceExtension->jChipType == SIS_300)) { - /* TW: Set - PCI LINEAR ADDRESSING ENABLE (0x80) - - PCI IO ENABLE (0x20) - - MMIO ENABLE (0x1) - */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x20,0xa1); - /* TW: Enable 2D (0x42) & 3D accelerator (0x18) */ - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1E,0xFF,0x5A); + unsigned char cr5f, temp1, temp2; + + /* You should use the macros, not these flags directly */ + + SiS_Pr->SiS_SysFlags = 0; + if(HwInfo->jChipType == SIS_650) { + cr5f = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0; + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x5c,0x07); + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x5c,0xf8); + temp2 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; + if((!temp1) || (temp2)) { + switch(cr5f) { + case 0x80: + case 0x90: + case 0xc0: + SiS_Pr->SiS_SysFlags |= SF_IsM650; break; + case 0xa0: + case 0xb0: + case 0xe0: + SiS_Pr->SiS_SysFlags |= SF_Is651; break; + } + } else { + switch(cr5f) { + case 0x90: + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; + switch(temp1) { + case 0x00: SiS_Pr->SiS_SysFlags |= SF_IsM652; break; + case 0x40: SiS_Pr->SiS_SysFlags |= SF_IsM653; break; + default: SiS_Pr->SiS_SysFlags |= SF_IsM650; break; + } + break; + case 0xb0: + SiS_Pr->SiS_SysFlags |= SF_Is652; break; + default: + SiS_Pr->SiS_SysFlags |= SF_IsM650; break; + } + } } - if((HwDeviceExtension->jChipType == SIS_315H)|| - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO)|| - (HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) { - /* TW: This seems to be done the same way on these chipsets */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x20,0xa1); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1E,0xFF,0x5A); +} + +/*********************************************/ +/* HELPER: Init PCI & Engines */ +/*********************************************/ + +static void +SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + switch(HwInfo->jChipType) { + case SIS_300: + case SIS_540: + case SIS_630: + case SIS_730: + /* Set - PCI LINEAR ADDRESSING ENABLE (0x80) + * - RELOCATED VGA IO (0x20) + * - MMIO ENABLE (0x1) + */ + SiS_SetReg(SiS_Pr->SiS_P3c4,0x20,0xa1); + /* - Enable 2D (0x40) + * - Enable 3D (0x02) + * - Enable 3D Vertex command fetch (0x10) ? + * - Enable 3D command parser (0x08) ? + */ + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x5A); + break; + case SIS_315H: + case SIS_315: + case SIS_315PRO: + case SIS_650: + case SIS_740: + case SIS_330: + case SIS_661: + case SIS_741: + case SIS_660: + case SIS_760: + SiS_SetReg(SiS_Pr->SiS_P3c4,0x20,0xa1); + /* - Enable 2D (0x40) + * - Enable 3D (0x02) + * - Enable 3D vertex command fetch (0x10) + * - Enable 3D command parser (0x08) + * - Enable 3D G/L transformation engine (0x80) + */ + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0xDA); + break; + case SIS_550: + SiS_SetReg(SiS_Pr->SiS_P3c4,0x20,0xa1); + /* No 3D engine ! */ + /* - Enable 2D (0x40) + */ + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x40); } -/* #endif */ } +/*********************************************/ +/* HELPER: SetLVDSetc */ +/*********************************************/ + void -SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo) +SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { ULONG temp; @@ -2012,912 +1371,448 @@ SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT SiS_Pr->SiS_IF_DEF_HiVision = 0; SiS_Pr->SiS_IF_DEF_DSTN = 0; SiS_Pr->SiS_IF_DEF_FSTN = 0; + SiS_Pr->SiS_IF_DEF_CONEX = 0; SiS_Pr->SiS_ChrontelInit = 0; - if((ModeNo == 0x5a) || (ModeNo == 0x5b)) { - SiS_Pr->SiS_IF_DEF_DSTN = 1; /* for 550 dstn */ - SiS_Pr->SiS_IF_DEF_FSTN = 1; /* for fstn */ - } - + switch(HwInfo->jChipType) { #ifdef SIS300 - if((HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730)) - { - /* TW: Check for SiS30x first */ - temp = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00); + case SIS_540: + case SIS_630: + case SIS_730: + /* Check for SiS30x first */ + temp = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); if((temp == 1) || (temp == 2)) return; - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37); + 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)) { - /* TW: Save power status (and error check) - UNUSED */ + /* 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 - if((HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) - { - /* TW: CR37 is different on 310/325 series */ - if(SiS_Pr->SiS_IF_DEF_FSTN) /* fstn: set CR37=0x04 */ - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,0x04); /* (fake LVDS bridge) */ - - temp=SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37); + 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; - } - - /* HiVision (HDTV) is done differently now. */ - /* SiS_Pr->SiS_IF_DEF_HiVision = 1; */ - } + if(temp == 3) SiS_Pr->SiS_IF_DEF_CH70xx = 2; + break; + case SIS_661: + case SIS_741: + case SIS_660: + case SIS_760: + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + temp = (temp & 0xe0) >> 5; + if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1; + if(temp == 3) SiS_Pr->SiS_IF_DEF_CH70xx = 2; + if(temp == 4) SiS_Pr->SiS_IF_DEF_CONEX = 1; /* Not yet supported */ + break; #endif + default: + break; + } } +/*********************************************/ +/* HELPER: Enable DSTN/FSTN */ +/*********************************************/ + void -SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable) { -#ifdef SIS315H - if((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO) || - (HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_330)) - InitTo310Pointer(SiS_Pr, HwDeviceExtension); -#endif - -#ifdef SIS300 - if ((HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) || - (HwDeviceExtension->jChipType == SIS_300)) - InitTo300Pointer(SiS_Pr, HwDeviceExtension); -#endif + SiS_Pr->SiS_IF_DEF_DSTN = enable ? 1 : 0; } void -SiSDetermineROMUsage(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR *ROMAddr) +SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable) +{ + SiS_Pr->SiS_IF_DEF_FSTN = enable ? 1 : 0; +} + +/*********************************************/ +/* HELPER: Determine ROM usage */ +/*********************************************/ + +static void +SiSDetermineROMUsage(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - 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. + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + + if((ROMAddr) && (HwInfo->UseROM)) { + if((ROMAddr[0x00] != 0x55) || (ROMAddr[0x01] != 0xAA)) { + SiS_Pr->SiS_UseROM = FALSE; + } else if(HwInfo->jChipType == SIS_300) { + /* 300: We check if the code starts below 0x220 by + * checking the jmp instruction at the beginning + * of the BIOS image. */ if((ROMAddr[3] == 0xe9) && ((ROMAddr[5] << 8) | ROMAddr[4]) > 0x21a) - SiS_Pr->SiS_UseROM = TRUE; - else SiS_Pr->SiS_UseROM = FALSE; - } else if(HwDeviceExtension->jChipType < SIS_315H) { - /* TW: Rest of 300 series: We don't use the ROM image if - * the BIOS version < 2.0.0 as such old BIOSes don't - * have the needed data at the expected locations. + SiS_Pr->SiS_UseROM = TRUE; + else + SiS_Pr->SiS_UseROM = FALSE; + } else if(HwInfo->jChipType < SIS_315H) { +#if 0 + /* Rest of 300 series: We don't use the ROM image if + * the BIOS version < 2.0.0 as such old BIOSes don't + * have the needed data at the expected locations. */ - if(ROMAddr[0x06] < '2') SiS_Pr->SiS_UseROM = FALSE; - else SiS_Pr->SiS_UseROM = TRUE; - } else { - /* TW: 310/325/330 series stick to the standard */ - SiS_Pr->SiS_UseROM = TRUE; - } + if(ROMAddr[0x06] < '2') SiS_Pr->SiS_UseROM = FALSE; + else SiS_Pr->SiS_UseROM = TRUE; +#else + /* Sony's VAIO BIOS 1.09 follows the standard, so perhaps + * the others do as well + */ + SiS_Pr->SiS_UseROM = TRUE; +#endif + } else { + /* 315/330 series stick to the standard */ + SiS_Pr->SiS_UseROM = TRUE; + } } else SiS_Pr->SiS_UseROM = FALSE; } -/* - ========================================= - ======== 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) -{ - 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, SiS_Pr->CVDisplay); - - return(SiSSetMode(SiS_Pr, HwDeviceExtension, pScrn, ModeNo, TRUE)); - - } - - ModeNo = SiS_CalcModeIndex(pScrn, mode); - if(!ModeNo) return FALSE; +/*********************************************/ +/* HELPER: SET SEGMENT REGISTERS */ +/*********************************************/ - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting mode 0x%x\n", ModeNo); - - return(SiSSetMode(SiS_Pr, HwDeviceExtension, pScrn, ModeNo, TRUE)); +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); } -#ifdef SISDUALHEAD -/* TW: Set CRT1 mode (used for dual head) */ -BOOLEAN -SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, ScrnInfoPtr pScrn, - DisplayModePtr mode, BOOLEAN IsCustom) +static void +SiS_SetSegRegUpper(SiS_Private *SiS_Pr, USHORT value) { - 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; - - if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { - - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting custom mode %dx%d in CRT1\n", - SiS_Pr->CHDisplay, SiS_Pr->CVDisplay); - ModeNo = 0xfe; - - } else { - - ModeNo = SiS_CalcModeIndex(pScrn, mode); - if(!ModeNo) return FALSE; - - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting mode 0x%x on CRT1\n", ModeNo); - } - - SiSInitPtr(SiS_Pr, HwDeviceExtension); - - SiSRegInit(SiS_Pr, BaseAddr); - - SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); - - SiSInitPCIetc(SiS_Pr, HwDeviceExtension); - - SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, ModeNo); - - SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr); - - /* TW: We don't clear the buffer under X */ - SiS_Pr->SiS_flag_clearbuffer = 0; - - /* 1.Openkey */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); - - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); - - if(!SiS_Pr->UseCustomMode) { - /* 2.Get ModeID Table */ - temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&ModeNo,&ModeIdIndex); - if(temp == 0) return(0); - } else { - ModeIdIndex = 0; - } - - /* TW: Determine VBType (301,301B,301LV,302B,302LV) */ - SiS_GetVBType(SiS_Pr, BaseAddr,HwDeviceExtension); - - 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); - } - } - - SiS_SetHiVision(SiS_Pr, BaseAddr,HwDeviceExtension); - - /* 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_GetLCDResInfo(SiS_Pr, ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); - - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08) { - /* TW: I am not sure the flag's name is correct */ - if(ModeNo != 0x10) SiS_Pr->SiS_SetFlag |= CRT2IsVGA; - } - - /* TW: New from 650/LV 1.10.6x */ - if(IS_SIS650740) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); - } - } - } - - /* TW: Set mode on CRT1 */ - SiS_SetCRT1Group(SiS_Pr, ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,BaseAddr); - - pSiSEnt->CRT1ModeNo = ModeNo; - pSiSEnt->CRT1DMode = mode; - - /* TW: SetPitch: Adapt to virtual size & position */ - SiS_SetPitchCRT1(SiS_Pr, pScrn, BaseAddr); - - /* We have to reset CRT2 if changing mode on CRT1 */ - if(pSiSEnt->CRT2ModeNo != -1) { - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "(Re-)Setting mode 0x%x on CRT2\n", - pSiSEnt->CRT2ModeNo); - backupcustom = SiS_Pr->UseCustomMode; - if(SiS_Pr->UseCustomMode) { - SiS_Pr->CRT1UsesCustomMode = TRUE; - } else { - SiS_Pr->CRT1UsesCustomMode = FALSE; - } - SiSBIOSSetModeCRT2(SiS_Pr, HwDeviceExtension, pSiSEnt->pScrn_1, - pSiSEnt->CRT2DMode); - SiS_Pr->UseCustomMode = backupcustom; - SiS_Pr->CRT1UsesCustomMode = FALSE; - } - - if(IS_SIS650740) { /* TW: *** For 650 only! *** */ - SiS_HandleCRT1(SiS_Pr); - } - - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF); - - /* TW: New from 650/LV 1.10.6x and 1.10.7w, 630/301B 2.06.50 */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x38,backupreg); - } else if((HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730)) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x35,backupreg); - } - } - - /* Backup/Set ModeNo in BIOS scratch area */ - SiS_GetSetModeID(pScrn,ModeNo); - - return TRUE; + 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); } -/* TW: Set CRT2 mode (used for dual head) */ -BOOLEAN -SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, ScrnInfoPtr pScrn, - DisplayModePtr mode) +static void +SiS_SetSegmentReg(SiS_Private *SiS_Pr, USHORT value) { - ULONG temp; - USHORT ModeIdIndex; - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; - UShort ModeNo = 0; - SISPtr pSiS = SISPTR(pScrn); - SISEntPtr pSiSEnt = pSiS->entityPrivate; - unsigned char tempr1, tempr2, backupreg=0; - - SiS_Pr->UseCustomMode = FALSE; - - ModeNo = SiS_CalcModeIndex(pScrn, mode); - if(!ModeNo) return FALSE; - - SiSInitPtr(SiS_Pr, HwDeviceExtension); - - SiSRegInit(SiS_Pr, BaseAddr); - - SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); - - SiSInitPCIetc(SiS_Pr, HwDeviceExtension); - - SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, ModeNo); - - SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr); - - /* TW: We don't clear the buffer under X */ - SiS_Pr->SiS_flag_clearbuffer=0; - - /* TW: Save ModeNo so we can set it from within SetMode for CRT1 */ - pSiSEnt->CRT2ModeNo = ModeNo; - pSiSEnt->CRT2DMode = mode; - - /* TW: We can't set CRT2 mode before CRT1 mode is set */ - if(pSiSEnt->CRT1ModeNo == -1) { - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting CRT2 mode delayed until after setting CRT1 mode\n"); - return TRUE; - } - - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting mode 0x%x on CRT2\n", ModeNo); - - /* 1.Openkey */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); - - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); - - /* 2.Get ModeID */ - temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&ModeNo,&ModeIdIndex); - if(temp == 0) return(0); - - /* TW: Determine VBType (301,301B,301LV,302B,302LV) */ - SiS_GetVBType(SiS_Pr, BaseAddr,HwDeviceExtension); - - 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); - - 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); - } - } - - /* TW: Get VB information (connectors, connected devices) */ - SiS_SetHiVision(SiS_Pr, BaseAddr,HwDeviceExtension); - SiS_GetVBInfo(SiS_Pr, BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,1); - SiS_GetLCDResInfo(SiS_Pr, ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); - - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08) { - /* TW: I am not sure the flag's name is correct */ - if(ModeNo != 0x10) SiS_Pr->SiS_SetFlag |= CRT2IsVGA; - } - } - - /* Set mode on CRT2 */ - switch (HwDeviceExtension->ujVBChipID) { - case VB_CHIP_301: - case VB_CHIP_301B: - case VB_CHIP_301LV: - case VB_CHIP_301LVX: - case VB_CHIP_302: - case VB_CHIP_302B: - case VB_CHIP_302LV: - case VB_CHIP_302LVX: - SiS_SetCRT2Group301(SiS_Pr, BaseAddr,ROMAddr,ModeNo,HwDeviceExtension); - break; - case VB_CHIP_303: - break; - case VB_CHIP_UNKNOWN: - if (SiS_Pr->SiS_IF_DEF_LVDS == 1 || - SiS_Pr->SiS_IF_DEF_CH70xx != 0 || - SiS_Pr->SiS_IF_DEF_TRUMPION != 0) { - SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension); - } - break; - } - - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF); - - 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); - } - } - } - - /* TW: New from 650/LV 1.10.6x and 1.10.7w, 630 2.06.50 */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); - } else { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); - } - - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x38,backupreg); - - 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); - - 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); - } - } - - /* TW: SetPitch: Adapt to virtual size & position */ - SiS_SetPitchCRT2(SiS_Pr, pScrn, BaseAddr); - - return TRUE; + SiS_SetSegRegLower(SiS_Pr, value); + SiS_SetSegRegUpper(SiS_Pr, value); } -#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 +static void +SiS_ResetSegmentReg(SiS_Private *SiS_Pr) { - ULONG temp; - USHORT ModeIdIndex,KeepLockReg; - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; - unsigned char backupreg=0, tempr1, tempr2; - -#ifndef LINUX_XF86 - SiS_Pr->UseCustomMode = FALSE; - SiS_Pr->CRT1UsesCustomMode = FALSE; -#endif - - if(SiS_Pr->UseCustomMode) { - ModeNo = 0xfe; - } - - SiSInitPtr(SiS_Pr, HwDeviceExtension); - - SiSRegInit(SiS_Pr, BaseAddr); - -#ifdef LINUX_XF86 - if(pScrn) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); - else -#endif - SiS_Pr->SiS_VGAINFO = 0x11; - - SiSInitPCIetc(SiS_Pr, HwDeviceExtension); - - SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, ModeNo); + SiS_SetSegmentReg(SiS_Pr, 0); +} - SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr); +static void +SiS_SetSegmentRegOver(SiS_Private *SiS_Pr, USHORT value) +{ + USHORT temp = value >> 8; - if(!SiS_Pr->UseCustomMode) { - /* TW: Shift the clear-buffer-bit away */ - ModeNo = ((ModeNo & 0x80) << 8) | (ModeNo & 0x7f); - } + temp &= 0x07; + temp |= (temp << 4); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x1d,temp); + SiS_SetSegmentReg(SiS_Pr, value); +} -#ifdef LINUX_XF86 - /* TW: We never clear the buffer in X */ - ModeNo |= 0x8000; -#endif +static void +SiS_ResetSegmentRegOver(SiS_Private *SiS_Pr) +{ + SiS_SetSegmentRegOver(SiS_Pr, 0); +} - if(ModeNo & 0x8000) { - ModeNo &= 0x7fff; - SiS_Pr->SiS_flag_clearbuffer = 0; - } else { - SiS_Pr->SiS_flag_clearbuffer = 1; +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); } +} - /* 1.Openkey */ - KeepLockReg = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x05); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); - - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); +/*********************************************/ +/* HELPER: GetVBType */ +/*********************************************/ - if(!SiS_Pr->UseCustomMode) { - - /* 2.Get ModeID Table */ - temp = SiS_SearchModeID(SiS_Pr,ROMAddr,&ModeNo,&ModeIdIndex); - if(temp == 0) return(0); - - } else { - - ModeIdIndex = 0; - - } - - /* TW: Determine VBType (301,301B,301LV,302B,302LV) */ - SiS_GetVBType(SiS_Pr,BaseAddr,HwDeviceExtension); - - /* TW: Init/restore some VB registers */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr); - if(HwDeviceExtension->jChipType < SIS_330) { - if(ROMAddr && SiS_Pr->SiS_UseROM) { - temp = ROMAddr[VB310Data_1_2_Offset]; - temp |= 0x40; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x02,temp); - } - } - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10); +void +SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag=0, rev=0, nolcd=0; - SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x02,0x0c); + SiS_Pr->SiS_VBType = 0; - backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - } else { - backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35); - } - } - - /* TW: Get VB information (connectors, connected devices) */ - SiS_SetHiVision(SiS_Pr,BaseAddr,HwDeviceExtension); - SiS_GetVBInfo(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,1); - SiS_GetLCDResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) return; - /* 3. Check memory size */ - temp = SiS_CheckMemorySize(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex); - if(!temp) return(0); + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08) { - /* TW: I am not sure the flag's name is correct */ - if(ModeNo != 0x10) SiS_Pr->SiS_SetFlag |= CRT2IsVGA; - } + if(flag > 3) return; - /* TW: New from 650/LV 1.10.6x */ - if(IS_SIS650740) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); - } - } - } + rev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); - /* TW: Set mode on CRT1 */ - if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) { - SiS_SetCRT1Group(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,BaseAddr); - } else { - if(!(SiS_Pr->SiS_VBInfo & SwitchToCRT2)) { - SiS_SetCRT1Group(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,BaseAddr); + if(flag >= 2) { + SiS_Pr->SiS_VBType = VB_SIS302B; + } else if(flag == 1) { + SiS_Pr->SiS_VBType = VB_SIS301; + if(rev >= 0xC0) { + SiS_Pr->SiS_VBType = VB_SIS301C; + } else if(rev >= 0xB0) { + SiS_Pr->SiS_VBType = VB_SIS301B; + /* Check if 30xB DH version (no LCD support, use Panel Link instead) */ + nolcd = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x23); + if(!(nolcd & 0x02)) SiS_Pr->SiS_VBType |= VB_NoLCD; } - } - - /* TW: Set mode on CRT2 */ - if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2 | SetCRT2ToLCDA)) { - switch (HwDeviceExtension->ujVBChipID) { - case VB_CHIP_301: - case VB_CHIP_301B: - case VB_CHIP_301LV: - case VB_CHIP_301LVX: - case VB_CHIP_302: - case VB_CHIP_302B: - case VB_CHIP_302LV: - case VB_CHIP_302LVX: - SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension); - break; - case VB_CHIP_303: - break; - case VB_CHIP_UNKNOWN: - if(SiS_Pr->SiS_IF_DEF_LVDS == 1 || - SiS_Pr->SiS_IF_DEF_CH70xx != 0 || - SiS_Pr->SiS_IF_DEF_TRUMPION != 0) - SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension); - break; + } + if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS301C | VB_SIS302B)) { + if(rev >= 0xD0) { + SiS_Pr->SiS_VBType &= ~(VB_SIS301B | VB_SIS301C | VB_SIS302B | VB_NoLCD); + if(rev >= 0xE0) { + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x39); + if(flag == 0xff) + SiS_Pr->SiS_VBType |= VB_SIS302LV; + else + SiS_Pr->SiS_VBType |= VB_SIS302ELV; + } else { + SiS_Pr->SiS_VBType |= VB_SIS301LV; + } } - } - - if(IS_SIS650740) { /* TW: For 650 only! */ - SiS_HandleCRT1(SiS_Pr); - } + } +} - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF); +/*********************************************/ +/* HELPER: GetDRAMSize */ +/*********************************************/ - if(HwDeviceExtension->jChipType >= SIS_315H) { -#if 0 - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - SiS_Handle301B_1400x1050(SiS_Pr, ModeNo); - } - } +#ifndef LINUX_XF86 +static ULONG +GetDRAMSize(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + ULONG AdapterMemorySize = 0; +#ifdef SIS315H + USHORT counter; #endif - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(!(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); - } - } - } - - /* TW: New from 650/LV 1.10.6x and 1.10.7w */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); - } else { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); - } - - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x38,backupreg); - 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); - - if((IS_SIS650740) && (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); - } - } + switch(HwInfo->jChipType) { +#ifdef SIS315H + case SIS_315H: + case SIS_315: + case SIS_315PRO: + counter = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + AdapterMemorySize = 1 << ((counter & 0xF0) >> 4); + counter >>= 2; + counter &= 0x03; + if(counter == 0x02) { + AdapterMemorySize += (AdapterMemorySize / 2); /* DDR asymetric */ + } else if(counter != 0) { + AdapterMemorySize <<= 1; /* SINGLE_CHANNEL_2_RANK or DUAL_CHANNEL_1_RANK */ + } + AdapterMemorySize *= (1024*1024); + break; - if(tempr1 & SetCRT2ToLCD) { -/* if(ModeNo <= 0x13) { - not in 1.10.8r */ - 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); - } - } + case SIS_330: + counter = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + AdapterMemorySize = 1 << ((counter & 0xF0) >> 4); + counter &= 0x0c; + if(counter != 0) { + AdapterMemorySize <<= 1; + } + AdapterMemorySize *= (1024*1024); + break; -#ifdef LINUX_XF86 - if(pScrn) { - /* TW: SetPitch: Adapt to virtual size & position */ - if((ModeNo > 0x13) && (dosetpitch)) { - SiS_SetPitch(SiS_Pr, pScrn, BaseAddr); - } + case SIS_550: + case SIS_650: + case SIS_740: + counter = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x3F; + counter++; + AdapterMemorySize = counter * 4; + AdapterMemorySize *= (1024*1024); + break; - /* Backup/Set ModeNo in BIOS scratch area */ - SiS_GetSetModeID(pScrn, ModeNo); - } + case SIS_661: + case SIS_741: + case SIS_660: + case SIS_760: + counter = (SiS_GetReg(SiS_Pr->SiS_P3c4,0x79) & 0xf0) >> 4; + AdapterMemorySize = 1 << counter; + AdapterMemorySize *= (1024*1024); + break; #endif -#ifndef LINUX_XF86 /* TW: We never lock registers in XF86 */ - if(KeepLockReg == 0xA1) SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); - else SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x00); +#ifdef SIS300 + case SIS_300: + case SIS_540: + case SIS_630: + case SIS_730: + AdapterMemorySize = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x3F; + AdapterMemorySize++; + AdapterMemorySize *= (1024*1024); + break; #endif + default: + break; + } - return TRUE; + return AdapterMemorySize; } +#endif -void -SiS_SetEnableDstn(SiS_Private *SiS_Pr) /* TW: Called from sis_main.c */ -{ - /* For 550 dstn */ - SiS_Pr->SiS_IF_DEF_DSTN = 1; -} +/*********************************************/ +/* HELPER: Check RAM size */ +/*********************************************/ -void -SiS_HandleCRT1(SiS_Private *SiS_Pr) +#ifndef LINUX_XF86 +static BOOLEAN +SiS_CheckMemorySize(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex) { - /* TW: Do this on 650 only! */ - - /* TW: No, we don't do this at all. There is a new - * CRT1-is-connected-at-boot-time logic in the 650, which - * confuses our own. So just clear the bit and skip the rest. - */ - - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x63,0xbf); - -#if 0 - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15) & 0x01)) - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x63,0x40); - } -#endif -} + USHORT memorysize,modeflag; + ULONG temp; -#if 0 -void -SiS_Handle301B_1400x1050(SiS_Private *SiS_Pr, USHORT ModeNo) -{ - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD) { + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + } else { if(ModeNo <= 0x13) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & (SetNotSimuMode >> 8)) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xFC); - } + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; } } -} -#endif - -void -SiS_SetCRT1Group(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT ModeIdIndex,USHORT BaseAddr) -{ - USHORT StandTableIndex,RefreshRateTableIndex; - - SiS_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); - } - } - 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); + memorysize = modeflag & MemoryInfoFlag; + memorysize >>= MemorySizeShift; /* Get required memory size */ + memorysize++; - SiS_Pr->SiS_SelectCRT2Rate = 0; - SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); + temp = GetDRAMSize(SiS_Pr, HwInfo); /* Get adapter memory size (in MB) */ + temp /= (1024*1024); -#ifdef LINUX_XF86 - xf86DrvMsgVerb(0, X_PROBED, 3, "(init: VBType=0x%04x, VBInfo=0x%04x)\n", - SiS_Pr->SiS_VBType, SiS_Pr->SiS_VBInfo); + if(temp < memorysize) return(FALSE); + else return(TRUE); +} #endif - if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - } - } - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - } +/*********************************************/ +/* HELPER: Get DRAM type */ +/*********************************************/ - RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); - - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - SiS_Pr->SiS_SetFlag &= ~ProgrammingCRT2; - } - - if(RefreshRateTableIndex != 0xFFFF) { - SiS_SetSync(SiS_Pr,ROMAddr,RefreshRateTableIndex); - SiS_SetCRT1CRTC(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwDeviceExtension); - SiS_SetCRT1Offset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwDeviceExtension); - SiS_SetCRT1VCLK(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,RefreshRateTableIndex); - } - -#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 - - SiS_SetCRT1ModeRegs(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,RefreshRateTableIndex); - - SiS_LoadDAC(SiS_Pr,HwDeviceExtension,ROMAddr,ModeNo,ModeIdIndex); - -#ifndef LINUX_XF86 - if(SiS_Pr->SiS_flag_clearbuffer) { - SiS_ClearBuffer(SiS_Pr,HwDeviceExtension,ModeNo); - } -#endif - - if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2 | SetCRT2ToLCDA))) { - SiS_LongWait(SiS_Pr); - SiS_DisplayOn(SiS_Pr); - } -} - -#ifdef LINUX_XF86 -void -SiS_SetPitch(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr) +static UCHAR +SiS_Get310DRAMType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - SISPtr pSiS = SISPTR(pScrn); + UCHAR data, temp; - /* TW: We need to set pitch for CRT1 if bridge is in SlaveMode, too */ - if( (pSiS->VBFlags & DISPTYPE_DISP1) || - ( (pSiS->VBFlags & VB_VIDEOBRIDGE) && - ( ((pSiS->VGAEngine == SIS_300_VGA) && (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0xa0) == 0x20) || - ((pSiS->VGAEngine == SIS_315_VGA) && (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x50) == 0x10) ) ) ) { - SiS_SetPitchCRT1(SiS_Pr, pScrn, BaseAddr); - } - if (pSiS->VBFlags & DISPTYPE_DISP2) { - SiS_SetPitchCRT2(SiS_Pr, pScrn, BaseAddr); + if(*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) { + data = *SiS_Pr->pSiS_SoftSetting & 0x03; + } else { + if(HwInfo->jChipType >= SIS_661) { + data = SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0x07; + } else if(IS_SIS550650740) { + data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x07; + } else { /* 315, 330 */ + data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3a) & 0x03; + if(HwInfo->jChipType == SIS_330) { + if(data > 1) { + temp = SiS_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; + } + } + } } -} -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); + return data; } -void -SiS_SetPitchCRT2(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr) +USHORT +SiS_GetMCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - SISPtr pSiS = SISPTR(pScrn); - ULong HDisplay,temp; - - HDisplay = pSiS->scrnPitch / 8; - - /* 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_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); + USHORT index; + + index = SiS_Get310DRAMType(SiS_Pr, HwInfo); + if(HwInfo->jChipType >= SIS_661) { + return(SiS_Pr->SiS_MCLKData_0[index].CLOCK); + } else if(index >= 4) { + index -= 4; + return(SiS_Pr->SiS_MCLKData_1[index].CLOCK); + } else { + return(SiS_Pr->SiS_MCLKData_0[index].CLOCK); + } } #endif -/* TW: Checked against 650/301 and 630/301B BIOS */ -/* TW: Re-written for 650/301LVx 1.10.6s BIOS */ -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; +/*********************************************/ +/* HELPER: ClearBuffer */ +/*********************************************/ - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) return; +#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; - flag = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00); - - /* TW: Illegal values not welcome... */ - if(flag > 10) return; - - rev = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x01); - - if (flag >= 2) { - SiS_Pr->SiS_VBType = VB_SIS302B; - } else if (flag == 1) { - SiS_Pr->SiS_VBType = VB_SIS301; - if(rev >= 0xB0) { - SiS_Pr->SiS_VBType = VB_SIS301B; - if((HwDeviceExtension->jChipType >= SIS_315H) || - (HwDeviceExtension->jChipType == SIS_300)) { - /* 650/301LV and 300/301LV use this, 630/301B does not */ - nolcd = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x23); - if(!(nolcd & 0x02)) - SiS_Pr->SiS_VBType |= VB_NoLCD; - } - } - } - if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) { - if(rev >= 0xD0) { - SiS_Pr->SiS_VBType &= ~(VB_SIS301B | VB_SIS302B); - SiS_Pr->SiS_VBType |= VB_SIS30xLV; - SiS_Pr->SiS_VBType &= ~(VB_NoLCD); - if(rev >= 0xE0) { - SiS_Pr->SiS_VBType &= ~(VB_SIS30xLV); - SiS_Pr->SiS_VBType |= VB_SIS30xNEW; - } - } + if(SiS_Pr->SiS_ModeType >= ModeEGA) { + if(ModeNo > 0x13) { + AdapterMemorySize = GetDRAMSize(SiS_Pr, HwInfo); + SiS_SetMemory(VideoMemoryAddress,AdapterMemorySize,0); + } else { + pBuffer = (USHORT *)VideoMemoryAddress; + for(i=0; i<0x4000; i++) + pBuffer[i] = 0x0000; + } + } else { + pBuffer = (USHORT *)VideoMemoryAddress; + if(SiS_Pr->SiS_ModeType < ModeCGA) { + for(i=0; i<0x4000; i++) + pBuffer[i] = 0x0720; + } else { + SiS_SetMemory(VideoMemoryAddress,0x8000,0); + } } } +#endif + +/*********************************************/ +/* HELPER: SearchModeID */ +/*********************************************/ -/* TW: Checked against 650/301LVx 1.10.6s */ BOOLEAN -SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT *ModeNo,USHORT *ModeIdIndex) +SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex) { UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; if(*ModeNo <= 0x13) { - if((*ModeNo) <= 5) (*ModeNo) |= 1; + if((*ModeNo) <= 0x05) (*ModeNo) |= 0x01; - for(*ModeIdIndex=0;;(*ModeIdIndex)++) { + 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; } @@ -2926,7 +1821,7 @@ SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT *ModeNo,USHORT *Mode if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */ /* else 350 lines */ } - if(*ModeNo <= 3) { + if(*ModeNo <= 0x03) { if(!(VGAINFO & 0x80)) (*ModeIdIndex)++; if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */ /* else 350 lines */ @@ -2935,7 +1830,7 @@ SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT *ModeNo,USHORT *Mode } else { - for(*ModeIdIndex=0;;(*ModeIdIndex)++) { + 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; } @@ -2944,134 +1839,212 @@ SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT *ModeNo,USHORT *Mode return TRUE; } -/* For SiS 300 oem util: Search VBModeID */ -BOOLEAN -SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo) -{ - USHORT ModeIdIndex; - UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; +/*********************************************/ +/* HELPER: GetModePtr */ +/*********************************************/ - if(*ModeNo <= 5) *ModeNo |= 1; +UCHAR +SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex) +{ + UCHAR index; - for(ModeIdIndex=0; ; ModeIdIndex++) { - if(SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == *ModeNo) break; - if(SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == 0xFF) return FALSE; + if(ModeNo <= 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; +} - 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); +/*********************************************/ +/* HELPER: LowModeTests */ +/*********************************************/ + +static BOOLEAN +SiS_DoLowModeTest(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo) +{ + USHORT temp,temp1,temp2; + + if((ModeNo != 0x03) && (ModeNo != 0x10) && (ModeNo != 0x12)) + return(1); + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x11); + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x11,0x80); + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x00); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,0x55); + temp2 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x00); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,temp1); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x11,temp); + if((HwInfo->jChipType >= SIS_315H) || + (HwInfo->jChipType == SIS_300)) { + if(temp2 == 0x55) return(0); + else return(1); + } else { + if(temp2 != 0x55) return(1); + else { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); + return(0); + } + } } -/* TW: Checked against 630/301B, 315 1.09 and 650/301LVx 1.10.6s BIOS */ -BOOLEAN -SiS_CheckMemorySize(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT ModeIdIndex) +static void +SiS_SetLowModeTest(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo) { - USHORT memorysize,modeflag; - ULONG temp; + if(SiS_DoLowModeTest(SiS_Pr, ModeNo, HwInfo)) { + SiS_Pr->SiS_SetFlag |= LowModeTests; + } +} - if(SiS_Pr->UseCustomMode) { +/*********************************************/ +/* HELPER: GetColorDepth */ +/*********************************************/ + +USHORT +SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex) +{ + USHORT ColorDepth[6] = { 1, 2, 4, 4, 6, 8}; + SHORT index; + USHORT modeflag; + + /* 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(ModeNo <= 0x13) + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + else + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; } - memorysize = modeflag & MemoryInfoFlag; - memorysize >>= MemorySizeShift; /* Get required memory size */ - memorysize++; - - temp = GetDRAMSize(SiS_Pr, HwDeviceExtension); /* Get adapter memory size */ - temp /= (1024*1024); /* (in MB) */ - - if(temp < memorysize) return(FALSE); - else return(TRUE); + index = (modeflag & ModeInfoFlag) - ModeEGA; + if(index < 0) index = 0; + return(ColorDepth[index]); } -UCHAR -SiS_GetModePtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +/*********************************************/ +/* HELPER: GetOffset */ +/*********************************************/ + +USHORT +SiS_GetOffset(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo) { - UCHAR index; + USHORT temp,colordepth,infoflag; - 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; + if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; + temp = SiS_Pr->CHDisplay / 16; + } else { + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; + temp = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeOffset; + temp = SiS_Pr->SiS_ScreenOffset[temp]; + } + + colordepth = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex); + + if(infoflag & InterlaceMode) temp <<= 1; + + temp *= colordepth; + + if( ( ((ModeNo >= 0x26) && (ModeNo <= 0x28)) || + ModeNo == 0x3f || + ModeNo == 0x42 || + ModeNo == 0x45 ) || + (SiS_Pr->UseCustomMode && (SiS_Pr->CHDisplay % 16)) ) { + colordepth >>= 1; + temp += colordepth; + } + + return(temp); } -/* TW: Checked against 300, 330, 650/LVDS (1.10.07, 1.10a) and 650/301LV BIOS */ -void -SiS_SetSeqRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex) +/*********************************************/ +/* SEQ */ +/*********************************************/ + +static void +SiS_SetSeqRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, PSIS_HW_INFO HwInfo) { UCHAR SRdata; USHORT i; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x00,0x03); /* Set SR0 */ + SiS_SetReg(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 & SetCRT2ToLCDA) { + SRdata |= 0x01; + } + if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SRdata |= 0x01; /* 8 dot clock */ + } + } + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_VBType & VB_NoLCD) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SRdata |= 0x01; /* 8 dot clock */ + } + } + } } + 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_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 |= 0x01; /* 8 dot clock */ } - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SRdata |= 0x01; /* 8 dot clock */ - } - } + } } SRdata |= 0x20; /* screen off */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x01,SRdata); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x01,SRdata); for(i = 2; i <= 4; i++) { - SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i-1]; - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,SRdata); + SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i-1]; + SiS_SetReg(SiS_Pr->SiS_P3c4,i,SRdata); } } -/* Checked against 300, 650/301LVx 1.10.6s and 650/LVDS 1.10.07 BIOS */ -void -SiS_SetMiscRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex) +/*********************************************/ +/* MISC */ +/*********************************************/ + +static void +SiS_SetMiscRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, PSIS_HW_INFO HwInfo) { UCHAR Miscdata; Miscdata = SiS_Pr->SiS_StandTable[StandTableIndex].MISC; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - Miscdata |= 0x0C; + if(HwInfo->jChipType < SIS_661) { + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + Miscdata |= 0x0C; + } } } - SiS_SetReg3(SiS_Pr->SiS_P3c2,Miscdata); + SiS_SetRegByte(SiS_Pr->SiS_P3c2,Miscdata); } -/* Checked against 300, 330, 650/LVDS (1.10.07) and 650/301LVx (1.10.6s) BIOS (630 code still there!) */ -void -SiS_SetCRTCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, +/*********************************************/ +/* CRTC */ +/*********************************************/ + +static void +SiS_SetCRTCRegs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT StandTableIndex) { UCHAR CRTCdata; @@ -3081,316 +2054,365 @@ SiS_SetCRTCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDevice 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) */ + SiS_SetReg(SiS_Pr->SiS_P3d4,i,CRTCdata); /* Set CRTC(3d4) */ } - if( ( (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) ) && - (HwDeviceExtension->jChipRevision >= 0x30) ) { /* for 630S0 */ - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x18,0xFE); - } - } + if( ( (HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730) ) && + (HwInfo->jChipRevision >= 0x30) ) { /* for 630S0 */ + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x18,0xFE); + } + } } } -/* TW: Checked against 300, 650/LVDS (1.10.07), 650/301LVx (1.10.6s) and 630/301B BIOS */ -void -SiS_SetATTRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +/*********************************************/ +/* ATT */ +/*********************************************/ + +static void +SiS_SetATTRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, + PSIS_HW_INFO HwInfo) { UCHAR ARdata; USHORT i; for(i = 0; i <= 0x13; i++) { - ARdata = SiS_Pr->SiS_StandTable[StandTableIndex].ATTR[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) { - 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((i <= 0x0f) || (i == 0x11)) { + if(ds:489 & 0x08) { + continue; + } } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - /* TW: From 650/LVDS 1.10.07, 1.10a; 650/301LVx 1.10.6s; not in 330 BIOS */ - ARdata = 0; - } else { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - ARdata=0; - } - } +#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_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_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_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_GetRegByte(SiS_Pr->SiS_P3da); /* reset 3da */ + SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x14); /* set index */ + SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x00); /* set data */ - SiS_GetReg2(SiS_Pr->SiS_P3da); - SiS_SetReg3(SiS_Pr->SiS_P3c0,0x20); /* Enable Attribute */ - SiS_GetReg2(SiS_Pr->SiS_P3da); + SiS_GetRegByte(SiS_Pr->SiS_P3da); + SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x20); /* Enable Attribute */ + SiS_GetRegByte(SiS_Pr->SiS_P3da); } -/* TW: Checked against 300, 330, 650/LVDS (1.10.07, 1.10a) and 650/301LV BIOS */ -void -SiS_SetGRCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex) +/*********************************************/ +/* GRC */ +/*********************************************/ + +static void +SiS_SetGRCRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex) { UCHAR GRdata; USHORT i; for(i = 0; i <= 0x08; i++) { - GRdata = SiS_Pr->SiS_StandTable[StandTableIndex].GRC[i]; - SiS_SetReg1(SiS_Pr->SiS_P3ce,i,GRdata); /* Set GR(3ce) */ + GRdata = SiS_Pr->SiS_StandTable[StandTableIndex].GRC[i]; + SiS_SetReg(SiS_Pr->SiS_P3ce,i,GRdata); } if(SiS_Pr->SiS_ModeType > ModeVGA) { - SiS_SetRegAND(SiS_Pr->SiS_P3ce,0x05,0xBF); /* 256 color disable */ + /* 256 color disable */ + SiS_SetRegAND(SiS_Pr->SiS_P3ce,0x05,0xBF); } } -/* TW: Checked against 650/LVDS (1.10.07, 1.10a), 650/301LVx (1.10.6s) and 630/301B BIOS */ -void -SiS_ClearExt1Regs(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +/*********************************************/ +/* CLEAR EXTENDED REGISTERS */ +/*********************************************/ + +static void +SiS_ClearExt1Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { USHORT i; for(i = 0x0A; i <= 0x0E; i++) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0x00); /* Clear SR0A-SR0E */ + SiS_SetReg(SiS_Pr->SiS_P3c4,i,0x00); } - /* TW: New from 330, 650/LVDS/301LV BIOSes: */ - if(HwDeviceExtension->jChipType >= SIS_315H) { + if(HwInfo->jChipType >= SIS_315H) { SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x37,0xFE); } } -/* TW: Checked against 300, 330, 650/LVDS (1.10.07) and 650/301LV BIOS */ -void -SiS_SetSync(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT RefreshRateTableIndex) +/*********************************************/ +/* RESET VCLK */ +/*********************************************/ + +static void +SiS_ResetCRT1VCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + if(HwInfo->jChipType >= SIS_315H) { + if(HwInfo->jChipType < SIS_661) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 0) return; + } + } else { + if((SiS_Pr->SiS_IF_DEF_LVDS == 0) && + (!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) { + return; + } + } + + 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); +} + +/*********************************************/ +/* SYNC */ +/*********************************************/ + +static void +SiS_SetCRT1Sync(SiS_Private *SiS_Pr, USHORT RefreshRateTableIndex) { USHORT sync; - USHORT temp; if(SiS_Pr->UseCustomMode) { sync = SiS_Pr->CInfoFlag >> 8; } else { sync = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; - } + } sync &= 0xC0; - temp = 0x2F | sync; - SiS_SetReg3(SiS_Pr->SiS_P3c2,temp); /* Set Misc(3c2) */ + sync |= 0x2f; + SiS_SetRegByte(SiS_Pr->SiS_P3c2,sync); } -/* TW: Checked against 300, 330, 650/LVDS (1.10.07) and 650/301LVx (1.10.6s) BIOS */ -void -SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, +/*********************************************/ +/* CRTC/2 */ +/*********************************************/ + +#ifdef SIS315H +static void +SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, USHORT *ResIndex, + USHORT *DisplayType) + { + USHORT modeflag = 0; + + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + *ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + *ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + } + + *ResIndex &= 0x3F; + + *DisplayType = SiS_Pr->SiS_LCDResInfo; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) *DisplayType += 32; + if(modeflag & HalfDCLK) *DisplayType += 16; + + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + *DisplayType = 100; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) *DisplayType += 2; + if(modeflag & HalfDCLK) *DisplayType += 1; + } + } else if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + *DisplayType = 104; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) *DisplayType += 2; + if(modeflag & HalfDCLK) *DisplayType += 1; + } + } + +} +#endif + +static void +SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) + PSIS_HW_INFO HwInfo) { UCHAR index; - USHORT tempah,i,modeflag,j; + USHORT temp,i,j,modeflag; #ifdef SIS315H - USHORT temp; - USHORT ResInfo,DisplayType; + USHORT ResIndex,DisplayType; const SiS_LCDACRT1DataStruct *LCDACRT1Ptr = NULL; #endif - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /*unlock cr0-7 */ + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /* unlock cr0-7 */ if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - } - - if((SiS_Pr->SiS_IF_DEF_LVDS == 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { -#ifdef SIS315H - - /* LCDA */ - - temp = SiS_GetLCDACRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,&ResInfo,&DisplayType); - - 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->CModeFlag; - tempah = (LCDACRT1Ptr+ResInfo)->CR[0]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x00,tempah); - for(i=0x01,j=1;i<=0x07;i++,j++){ - tempah = (LCDACRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + for(i=0,j=0;i<=07;i++,j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); } - for(i=0x10,j=8;i<=0x12;i++,j++){ - tempah = (LCDACRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + for(j=0x10;i<=10;i++,j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); } - for(i=0x15,j=11;i<=0x16;i++,j++){ - tempah =(LCDACRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + for(j=0x15;i<=12;i++,j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); } - for(i=0x0A,j=13;i<=0x0C;i++,j++){ - tempah = (LCDACRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,tempah); + for(j=0x0A;i<=15;i++,j++) { + SiS_SetReg(SiS_Pr->SiS_P3c4,j,SiS_Pr->CCRT1CRTC[i]); } - tempah = (LCDACRT1Ptr+ResInfo)->CR[16]; - tempah &= 0x0E0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x0E,tempah); + temp = SiS_Pr->CCRT1CRTC[16] & 0xE0; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp); - tempah = (LCDACRT1Ptr+ResInfo)->CR[16]; - tempah &= 0x01; - tempah <<= 5; - if(modeflag & DoubleScanMode) tempah |= 0x080; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah); - -#endif + temp = (SiS_Pr->CCRT1CRTC[16] & 0x01) << 5; + if(modeflag & DoubleScanMode) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,temp); } else { - /* LVDS, 301, 301B, 301LV, 302LV, ... (non-LCDA) */ + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } - if(SiS_Pr->UseCustomMode) { - - for(i=0,j=0;i<=07;i++,j++) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); + if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + +#ifdef SIS315H + + SiS_GetLCDACRT1Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, &ResIndex, &DisplayType); + + switch(DisplayType) { + case Panel_1024x768 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1; break; + case Panel_1280x1024 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_1; break; + case Panel_1400x1050 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_1; break; + case Panel_1600x1200 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_1; break; + case Panel_1024x768 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1_H; break; + case Panel_1280x1024 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_1_H; break; + case Panel_1400x1050 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_1_H; break; + case Panel_1600x1200 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_1_H; break; + case Panel_1024x768 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_2; break; + case Panel_1280x1024 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2; break; + case Panel_1400x1050 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_2; break; + case Panel_1600x1200 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_2; break; + case Panel_1024x768 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_2_H; break; + case Panel_1280x1024 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2_H; break; + case Panel_1400x1050 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_2_H; break; + case Panel_1600x1200 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_2_H; break; + case 100: LCDACRT1Ptr = Compaq1280x1024_LCDACRT1_1; break; + case 101: LCDACRT1Ptr = Compaq1280x1024_LCDACRT1_1_H; break; + case 102: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2; break; + case 103: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2_H; break; + case 104: LCDACRT1Ptr = Clevo1024x768_LCDACRT1_1; break; + case 105: LCDACRT1Ptr = Clevo1024x768_LCDACRT1_1_H; break; + case 106: LCDACRT1Ptr = Clevo1024x768_LCDACRT1_2; break; + case 107: LCDACRT1Ptr = Clevo1024x768_LCDACRT1_2_H; break; + default: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1; break; } - for(j=0x10;i<=10;i++,j++) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); + + for(i=0, j=0; i<=0x07; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,i,(LCDACRT1Ptr+ResIndex)->CR[j]); } - for(j=0x15;i<=12;i++,j++) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); + for(i=0x10, j=8; i<=0x12; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,i,(LCDACRT1Ptr+ResIndex)->CR[j]); } - for(j=0x0A;i<=15;i++,j++) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,j,SiS_Pr->CCRT1CRTC[i]); + for(i=0x15, j=11; i<=0x16; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,i,(LCDACRT1Ptr+ResIndex)->CR[j]); + } + for(i=0x0A, j=13; i<=0x0C; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_P3c4,i,(LCDACRT1Ptr+ResIndex)->CR[j]); } - tempah = SiS_Pr->CCRT1CRTC[16] & 0xE0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x0E,tempah); + temp = (LCDACRT1Ptr+ResIndex)->CR[16] & 0xE0; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp); + + temp = ((LCDACRT1Ptr+ResIndex)->CR[16] & 0x01) << 5; + if(modeflag & DoubleScanMode) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,temp); - tempah = SiS_Pr->CCRT1CRTC[16]; - tempah &= 0x01; - tempah <<= 5; - if(modeflag & DoubleScanMode) tempah |= 0x80; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,tempah); - - - } else { - - index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */ -#if 0 /* Not any longer... */ - if(HwDeviceExtension->jChipType < SIS_315H) { - index &= 0x3F; - } #endif + } else { + + index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; + 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); + SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]); } for(j=0x10;i<=10;i++,j++) { - tempah=SiS_Pr->SiS_CRT1Table[index].CR[i]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,j,tempah); + SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]); } for(j=0x15;i<=12;i++,j++) { - tempah=SiS_Pr->SiS_CRT1Table[index].CR[i]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,j,tempah); + SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]); } for(j=0x0A;i<=15;i++,j++) { - tempah=SiS_Pr->SiS_CRT1Table[index].CR[i]; - SiS_SetReg1(SiS_Pr->SiS_P3c4,j,tempah); + SiS_SetReg(SiS_Pr->SiS_P3c4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]); } - tempah = SiS_Pr->SiS_CRT1Table[index].CR[16]; - tempah &= 0xE0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x0E,tempah); + temp = SiS_Pr->SiS_CRT1Table[index].CR[16] & 0xE0; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp); - 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); + temp = ((SiS_Pr->SiS_CRT1Table[index].CR[16]) & 0x01) << 5; + if(modeflag & DoubleScanMode) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,temp); } } - if(SiS_Pr->SiS_ModeType > ModeVGA) SiS_SetReg1(SiS_Pr->SiS_P3d4,0x14,0x4F); + if(SiS_Pr->SiS_ModeType > ModeVGA) SiS_SetReg(SiS_Pr->SiS_P3d4,0x14,0x4F); } -BOOLEAN -SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *ResInfo, - USHORT *DisplayType) - { - USHORT tempbx=0,modeflag=0; - USHORT CRT2CRTC=0; - - 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 & LCDNonExpanding) tempbx += 32; - if(modeflag & HalfDCLK) tempbx += 16; - - *ResInfo = CRT2CRTC & 0x3F; - *DisplayType = tempbx; - - return 1; -} +/*********************************************/ +/* OFFSET & PITCH */ +/*********************************************/ +/* (partly overruled by SetPitch() in XF86) */ +/*********************************************/ -/* TW: Set offset and pitch - partly overruled by SetPitch() in XF86 */ -/* TW: Checked against 330, 650/LVDS (1.10.07), 650/301LV and 315 BIOS */ -void -SiS_SetCRT1Offset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, +static void +SiS_SetCRT1Offset(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) + PSIS_HW_INFO HwInfo) { USHORT temp, DisplayUnit, infoflag; @@ -3399,15 +2421,15 @@ SiS_SetCRT1Offset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeI } else { infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; } - - DisplayUnit = SiS_GetOffset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); + + DisplayUnit = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); temp = (DisplayUnit >> 8) & 0x0f; SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,temp); temp = DisplayUnit & 0xFF; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x13,temp); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x13,temp); if(infoflag & InterlaceMode) DisplayUnit >>= 1; @@ -3415,802 +2437,116 @@ SiS_SetCRT1Offset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeI 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/301B, and 650/LVDS - */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if (SiS_Pr->SiS_IF_DEF_LVDS == 0) return; - } else { - if( (SiS_Pr->SiS_IF_DEF_LVDS == 0) && - (!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) { - return; - } - } - - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xCF,0x20); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x20); - } - index = 1; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[index].SR2B); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[index].SR2C); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80); - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xcf,0x10); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x10); - } - index = 0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[index].SR2B); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[index].SR2C); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80); -} - -/* TW: Checked against 300, 330, 650/LVDS, 650/301LVx, 315, 630/301B, 630/LVDS BIOS */ -void -SiS_SetCRT1VCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT RefreshRateTableIndex) -{ - USHORT index=0; - - if(!SiS_Pr->UseCustomMode) { - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - } - - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) - && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ){ - - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF); - - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VBVCLKData[index].Part4_A); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VBVCLKData[index].Part4_B); - - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x01); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80); - } - - } else { - - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,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(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x01); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80); - } - } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x10,temp); } -#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); +/*********************************************/ +/* VCLK */ +/*********************************************/ - 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 - -/* TW: Checked against 300, 630/LVDS, 650/LVDS, 315 and 330 BIOS */ -void -SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex) +static void +SiS_SetCRT1VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) { - USHORT data,data2,data3; - USHORT infoflag=0,modeflag; - USHORT resindex,xres; + USHORT index=0, clka, clkb; if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - infoflag = SiS_Pr->CInfoFlag; + clka = SiS_Pr->CSR2B; + clkb = SiS_Pr->CSR2C; } else { - if(ModeNo > 0x13) { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; + 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 { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + clka = SiS_Pr->SiS_VCLKData[index].SR2B; + clkb = SiS_Pr->SiS_VCLKData[index].SR2C; } } - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1F,0x3F); /* DAC pedestal */ - - if(ModeNo > 0x13) data = infoflag; - else data = 0; - - data2 = 0; - if(ModeNo > 0x13) { - if(SiS_Pr->SiS_ModeType > 0x02) { - data2 |= 0x02; - data3 = (SiS_Pr->SiS_ModeType - ModeVGA) << 2; - data2 |= data3; - } - } -#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; + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF); } 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(HwDeviceExtension->jChipType != SIS_300) { - data = 0x0000; - if(infoflag & InterlaceMode) { - if(xres == 1024) data = 0x0035; - else data = 0x0048; - } - data2 = data & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x19,data2); - data2 = (data & 0xFF00) >> 8; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x1a,0xFC,data2); - } - - 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 */ - } else { - if(modeflag & LineCompareOff) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,0x08); - } else { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xB7); - } - } - - if(HwDeviceExtension->jChipType != SIS_300) { - if(SiS_Pr->SiS_ModeType == ModeEGA) { - if(ModeNo > 0x13) { - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x40); - } - } - } - -#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); - } - - /* 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; - } - - data3 = SiS_GetColorDepth(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex); - data3 >>= 1; - - data2 *= data3; - - data3 = SiS_GetMCLK(SiS_Pr,ROMAddr, HwDeviceExtension); - data3 *= 1024; - - data2 = data3 / data2; - - if(SiS_Pr->SiS_ModeType != Mode16Bpp) { - if(data2 >= 0x19c) data = 0xba; - else if(data2 >= 0x140) data = 0x7a; - else if(data2 >= 0x101) data = 0x3a; - else if(data2 >= 0xf5) data = 0x32; - else if(data2 >= 0xe2) data = 0x2a; - else if(data2 >= 0xc4) data = 0x22; - else if(data2 >= 0xac) data = 0x1a; - else if(data2 >= 0x9e) data = 0x12; - else if(data2 >= 0x8e) data = 0x0a; - else data = 0x02; - } else { - if(data2 >= 0x127) data = 0xba; - else data = 0x7a; - } - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,data); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x00); } -#endif - - data = 0x60; - if(SiS_Pr->SiS_ModeType != ModeText) { - 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_SetReg(SiS_Pr->SiS_P3c4,0x2B,clka); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,clkb); -#ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x40) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x52,0x2c); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x52,0x6c); - } - } -#endif -} - -/* TW: Checked against 300, 315, 330, 650/LVDS, 650/301LVx, 630/301B and 630/LVDS BIOS */ -void -SiS_SetVCLKState(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT RefreshRateTableIndex, - USHORT ModeIdIndex) -{ - USHORT data, data2=0; - USHORT VCLK, index=0; - - if (ModeNo <= 0x13) VCLK = 0; - else { - if(SiS_Pr->UseCustomMode) { - VCLK = SiS_Pr->CSRClock; - } else { - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; - } - } - - if(HwDeviceExtension->jChipType < SIS_315H) { /* 300 series */ - - data2 = 0x00; - if(VCLK > 150) data2 |= 0x80; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data2); /* DAC speed */ - - data2 = 0x00; - if(VCLK >= 150) data2 |= 0x08; /* VCLK > 150 */ - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data2); - - } else { /* 310/325 series */ - - data = 0; - if(VCLK >= 166) data |= 0x0c; /* TW: Was 200; is 166 in 650, 315 and 330 BIOSes */ - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); - - if(VCLK >= 166) { /* TW: Was 200, is 166 in 650, 315 and 330 BIOSes */ - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1f,0xe7); - } -#if 0 /* Not done in 315 and 650/301LV/LVDS BIOSes: */ - data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1F); /* DAC pedestal */ - data &= 0xE7; - if(VCLK<200) data |= 0x10; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1F,data); /* DAC pedestal */ -#endif - } - - data2 = 0x03; - if((VCLK >= 135) && (VCLK < 160)) data2 = 0x02; - if((VCLK >= 160) && (VCLK < 260)) data2 = 0x01; - if(VCLK >= 260) data2 = 0x00; - - if(HwDeviceExtension->jChipType == SIS_540) { - if((VCLK == 203) || (VCLK < 234)) data2 = 0x02; - } - - if(HwDeviceExtension->jChipType < SIS_315H) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xFC,data2); /* DAC speed */ + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x01); } 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 */ - } -} - -/* TW: Checked against 650/301LVx 1.10.6s, 315, 630/301B BIOS */ -void -SiS_LoadDAC(SiS_Private *SiS_Pr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) -{ - USHORT data,data2; - USHORT time,i,j,k; - USHORT m,n,o; - USHORT si,di,bx,dl; - USHORT al,ah,dh; - USHORT DACAddr, DACData, shiftflag; - const USHORT *table = NULL; -#if 0 - USHORT tempah,tempch,tempcl,tempdh,tempal,tempbx; -#endif - - if(ModeNo <= 0x13) { - data = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - if(SiS_Pr->UseCustomMode) { - data = SiS_Pr->CModeFlag; - } else { - data = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - } - -#if 0 - if(!(ds:489 & 0x08)) { -#endif - - data &= DACInfoFlag; - time = 64; - if(data == 0x00) table = SiS_MDA_DAC; - if(data == 0x08) table = SiS_CGA_DAC; - if(data == 0x10) table = SiS_EGA_DAC; - if(data == 0x18) { - time = 256; - table = SiS_VGA_DAC; - } - if(time == 256) j = 16; - else j = time; - - if( ( (HwDeviceExtension->jChipType == SIS_630) && /* 630/301B LCD */ - (SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) && - (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) || - (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) || /* LCDA */ - (!(SiS_Pr->SiS_SetFlag & ProgrammingCRT2)) ) { /* Programming CRT1 */ - DACAddr = SiS_Pr->SiS_P3c8; - DACData = SiS_Pr->SiS_P3c9; - shiftflag = 0; - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF); - } else { - shiftflag = 1; - DACAddr = SiS_Pr->SiS_Part5Port; - DACData = SiS_Pr->SiS_Part5Port + 1; - } - - SiS_SetReg3(DACAddr,0x00); - - for(i=0; i<j; i++) { - data = table[i]; - for(k=0; k<3; k++) { - data2 = 0; - if(data & 0x01) data2 = 0x2A; - if(data & 0x02) data2 += 0x15; - if(shiftflag) data2 <<= 2; - SiS_SetReg3(DACData,data2); - data >>= 2; - } - } - - 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 */ -#endif - -#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 -} - -void -SiS_WriteDAC(SiS_Private *SiS_Pr, USHORT DACData, USHORT shiftflag, - USHORT dl, USHORT ah, USHORT al, USHORT dh) -{ - USHORT temp; - USHORT bh,bl; - - bh = ah; - bl = al; - if(dl != 0) { - temp = bh; - bh = dh; - dh = temp; - if(dl == 1) { - temp = bl; - bl = dh; - dh = temp; - } else { - temp = bl; - bl = bh; - bh = temp; - } - } - if(shiftflag) { - dh <<= 2; - bh <<= 2; - bl <<= 2; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80); } - SiS_SetReg3(DACData,(USHORT)dh); - SiS_SetReg3(DACData,(USHORT)bh); - SiS_SetReg3(DACData,(USHORT)bl); } -static ULONG -GetDRAMSize(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - ULONG AdapterMemorySize = 0; -#ifdef SIS315H - USHORT counter; -#endif - -#ifdef SIS315H - if ((HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == 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); - - } else if(HwDeviceExtension->jChipType == 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); - - } else if((HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_650)) { - - counter = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14) & 0x3F; - counter++; - AdapterMemorySize = counter * 4; - AdapterMemorySize *= (1024*1024); - } -#endif +/*********************************************/ +/* FIFO */ +/*********************************************/ #ifdef SIS300 - if ((HwDeviceExtension->jChipType==SIS_300) || - (HwDeviceExtension->jChipType==SIS_540) || - (HwDeviceExtension->jChipType==SIS_630) || - (HwDeviceExtension->jChipType==SIS_730)) { - - AdapterMemorySize = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14) & 0x3F; - AdapterMemorySize++; - AdapterMemorySize *= (1024*1024); +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 }; - } -#endif + 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 }; - return AdapterMemorySize; -} + const UCHAR ThTiming[] = { 1, 2, 2, 3, 0, 1, 1, 2 }; -#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; + USHORT tempah, tempal, tempcl, tempbx, temp; + ULONG longtemp; - 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; - } + 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 { - pBuffer = VideoMemoryAddress; - if (SiS_Pr->SiS_ModeType < ModeCGA) { - for(i=0; i<0x4000; i++) - pBuffer[i] = 0x0720; - } else { - SiS_SetMemory(VideoMemoryAddress,0x8000,0); - } + 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); } -#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); -} - - -/* ========================================== */ -/* SR CRTC GR */ -void -SiS_SetReg1(USHORT port, USHORT index, USHORT data) -{ - OutPortByte(port,index); - OutPortByte(port+1,data); -} - -/* ========================================== */ -/* 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); -} - -void -SiS_SetReg3(USHORT port, USHORT data) -{ - OutPortByte(port,data); -} - -void -SiS_SetReg4(USHORT port, ULONG data) -{ - OutPortLong(port,data); -} - -void -SiS_SetReg5(USHORT port, USHORT data) -{ - OutPortWord(port,data); -} - -UCHAR SiS_GetReg1(USHORT port, USHORT index) -{ - UCHAR data; - - OutPortByte(port,index); - data = InPortByte(port+1); - - return(data); -} - -UCHAR -SiS_GetReg2(USHORT port) -{ - UCHAR data; - - data= InPortByte(port); - - return(data); -} - -ULONG -SiS_GetReg3(USHORT port) -{ - ULONG data; - - data = InPortLong(port); - - return(data); -} - -USHORT -SiS_GetReg4(USHORT port) -{ - ULONG data; - - data = InPortWord(port); - - return(data); -} - -void -SiS_ClearDAC(SiS_Private *SiS_Pr, ULONG port) -{ - int i; - - OutPortByte(port, 0); - port++; - for (i=0; i < (256 * 3); i++) { - OutPortByte(port, 0); - } - -} - -#if 0 /* TW: Unused */ -void -SiS_SetInterlace(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT RefreshRateTableIndex) -{ - ULONG Temp; - USHORT data,Temp2; - - if (ModeNo<=0x13) return; - - Temp = (ULONG)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x01); - Temp++; - Temp <<= 3; - - if(Temp == 1024) data = 0x0035; - else if(Temp == 1280) data = 0x0048; - else data = 0x0000; - - Temp2 = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - Temp2 &= InterlaceMode; - if(Temp2 == 0) data=0x0000; - - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x19,data); - - Temp = (ULONG)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x1A); - Temp = (USHORT)(Temp & 0xFC); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x1A,(USHORT)Temp); - - 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); -} -#endif -/* TW: Checked against 330, 650/LVDS (1.10.07), 650/301LVx (1.10.6s) and 315 BIOS */ -#ifdef SIS315H -void -SiS_SetCRT1FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +static USHORT +SiS_CalcDelay(SiS_Private *SiS_Pr, USHORT VCLK, USHORT colordepth, USHORT MCLK) { - USHORT modeflag; - - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x3D,0xFE); /* disable auto-threshold */ + USHORT tempax, tempbx; - 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); - } + 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); } -#endif -#ifdef SIS300 -void -SiS_SetCRT1FIFO_300(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,PSIS_HW_DEVICE_INFO HwDeviceExtension, +static void +SiS_SetCRT1FIFO_300(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) { USHORT ThresholdLow = 0; @@ -4236,21 +2572,21 @@ SiS_SetCRT1FIFO_300(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,PSIS_HW_DE case 5 : colorth = 4; break; } - index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A); + index = SiS_GetReg(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 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); tempah &= 0xc3; SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3c,tempah); do { - ThresholdLow = SiS_CalcDelay(SiS_Pr, ROMAddr, VCLK, colorth, MCLK); + 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_GetReg1(SiS_Pr->SiS_P3c4,0x16); + tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16); tempah >>= 6; if(!(tempah)) break; tempah--; @@ -4262,130 +2598,77 @@ SiS_SetCRT1FIFO_300(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,PSIS_HW_DE /* Write CRT/CPU threshold low, CRT/Engine threshold high */ temp = (ThresholdLow << 4) | 0x0f; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,temp); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,temp); temp = (ThresholdLow & 0x10) << 1; if(ModeNo > 0x13) temp |= 0x40; SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0f,0x9f,temp); /* What is this? */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x3B,0x09); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09); /* Write CRT/CPU threshold high */ temp = ThresholdLow + 3; if(temp > 0x0f) temp = 0x0f; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x09,temp); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x09,temp); } -USHORT -SiS_CalcDelay(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT VCLK, USHORT colordepth, USHORT MCLK) +static USHORT +SiS_CalcDelay2(SiS_Private *SiS_Pr, UCHAR key, PSIS_HW_INFO HwInfo) { - USHORT tempax, tempbx; - - 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); -} - -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 }; - - const UCHAR ThLowB[] = { 81, 4,72, 6,88, 8,120,12, - 55, 4,54, 6,66, 8, 90,12, - 42, 4,45, 6,55, 8, 75,12 }; - - const UCHAR ThTiming[] = { 1, 2, 2, 3, 0, 1, 1, 2 }; - - USHORT tempah, tempal, tempcl, tempbx, temp; - ULONG longtemp; - - 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); -} + 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 0 /* TW: Old fragment, unused */ -USHORT -SiS_CalcDelay(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT key) -{ - USHORT data,data2,temp0,temp1; - UCHAR ThLowA[]= {61,3,52,5,68,7,100,11, - 43,3,42,5,54,7, 78,11, - 34,3,37,5,47,7, 67,11}; - - UCHAR ThLowB[]= {81,4,72,6,88,8,120,12, - 55,4,54,6,66,8, 90,12, - 42,4,45,6,55,8, 75,12}; - - UCHAR ThTiming[]= {1,2,2,3,0,1,1,2}; - - data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - data=data>>6; - data2=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - data2=(data2>>4)&0x0C; - data=data|data2; - data=data<1; - if(key==0) { - temp0=(USHORT)ThLowA[data]; - temp1=(USHORT)ThLowA[data+1]; + if(HwInfo->jChipType == SIS_730) { + index = ((key & 0x0f) * 3) + ((key & 0xC0) >> 6); + data = LatencyFactor730[index]; } else { - temp0=(USHORT)ThLowB[data]; - temp1=(USHORT)ThLowB[data+1]; + 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]; } - - data2=0; - data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18); - if(data&0x02) data2=data2|0x01; - if(data&0x20) data2=data2|0x02; - if(data&0x40) data2=data2|0x04; - - data=temp1*ThTiming[data2]+temp0; return(data); } -#endif -void -SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension, +static void +SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, USHORT ModeNo, + PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) { USHORT i,index,data,VCLK,MCLK,colorth=0; ULONG B,eax,bl,data2; USHORT ThresholdLow=0; - UCHAR FQBQData[]= { + UCHAR FQBQData[]= { 0x01,0x21,0x41,0x61,0x81, 0x31,0x51,0x71,0x91,0xb1, 0x00,0x20,0x40,0x60,0x80, @@ -4402,7 +2685,7 @@ SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, }; i=0; - if(ModeNo >= 0x13) { + if(ModeNo > 0x13) { if(SiS_Pr->UseCustomMode) { VCLK = SiS_Pr->CSRClock; } else { @@ -4411,7 +2694,7 @@ SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ } - index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); + index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A); index &= 0x07; MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ @@ -4425,10 +2708,10 @@ SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, case 5 : colorth = 4; break; } - if(HwDeviceExtension->jChipType == SIS_730) { - + if(HwInfo->jChipType == SIS_730) { + do { - B = SiS_CalcDelay2(SiS_Pr, ROMAddr, FQBQData730[i], HwDeviceExtension) * VCLK * colorth; + B = SiS_CalcDelay2(SiS_Pr, FQBQData730[i], HwInfo) * VCLK * colorth; bl = B / (MCLK * 16); if(B == bl * 16 * MCLK) { @@ -4452,7 +2735,7 @@ SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, } else { do { - B = SiS_CalcDelay2(SiS_Pr, ROMAddr, FQBQData[i], HwDeviceExtension) * VCLK * colorth; + B = SiS_CalcDelay2(SiS_Pr, FQBQData[i], HwInfo) * VCLK * colorth; bl = B / (MCLK * 16); if(B == bl * 16 * MCLK) { @@ -4475,7 +2758,7 @@ SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, } } else { - if(HwDeviceExtension->jChipType == SIS_730) { + if(HwInfo->jChipType == SIS_730) { } else { i = 9; } @@ -4483,18 +2766,18 @@ SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, } /* Write foreground and background queue */ - if(HwDeviceExtension->jChipType == SIS_730) { + if(HwInfo->jChipType == SIS_730) { data2 = FQBQData730[i]; data2 = (data2 & 0xC0) >> 5; data2 <<= 8; #ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x80000050); - eax = SiS_GetReg3(0xcfc); + SiS_SetRegLong(0xcf8,0x80000050); + eax = SiS_GetRegLong(0xcfc); eax &= 0xfffff9ff; eax |= data2; - SiS_SetReg4(0xcfc,eax); + 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 @@ -4510,32 +2793,32 @@ SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, data2 = FQBQData730[i] << 8; data2 = (data2 & 0x0f00) | ((data2 & 0x3000) >> 8); data2 <<= 20; - + #ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x800000A0); - eax = SiS_GetReg3(0xcfc); + SiS_SetRegLong(0xcf8,0x800000A0); + eax = SiS_GetRegLong(0xcfc); eax &= 0x00ffffff; eax |= data2; - SiS_SetReg4(0xcfc,eax); + SiS_SetRegLong(0xcfc,eax); #else eax = pciReadLong(0x00000000, 0xA0); eax &= 0x00ffffff; eax |= data2; pciWriteLong(0x00000000, 0xA0, eax); -#endif +#endif } else { - + data2 = FQBQData[i]; data2 = (data2 & 0xf0) >> 4; data2 <<= 24; #ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x80000050); - eax = SiS_GetReg3(0xcfc); + SiS_SetRegLong(0xcf8,0x80000050); + eax = SiS_GetRegLong(0xcfc); eax &= 0xf0ffffff; eax |= data2; - SiS_SetReg4(0xcfc,eax); + SiS_SetRegLong(0xcfc,eax); #else eax = pciReadLong(0x00000000, 0x50); eax &= 0xf0ffffff; @@ -4549,951 +2832,1520 @@ SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, data2 <<= 24; #ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x800000A0); - eax = SiS_GetReg3(0xcfc); + SiS_SetRegLong(0xcf8,0x800000A0); + eax = SiS_GetRegLong(0xcfc); eax &= 0xf0ffffff; eax |= data2; - SiS_SetReg4(0xcfc,eax); + SiS_SetRegLong(0xcfc,eax); #else eax = pciReadLong(0x00000000, 0xA0); eax &= 0xf0ffffff; eax |= data2; pciWriteLong(0x00000000, 0xA0, eax); #endif - + } /* Write CRT/CPU threshold low, CRT/Engine threshold high */ data = ((ThresholdLow & 0x0f) << 4) | 0x0f; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,data); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,data); data = (ThresholdLow & 0x10) << 1; SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xDF,data); /* What is this? */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x3B,0x09); + 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 -USHORT -SiS_CalcDelay2(SiS_Private *SiS_Pr, UCHAR *ROMAddr,UCHAR key, PSIS_HW_DEVICE_INFO HwDeviceExtension) +#ifdef SIS315H +static void +SiS_SetCRT1FIFO_310(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { - USHORT 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, - }; + USHORT modeflag; - 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]; + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x3D,0xFE); /* disable auto-threshold */ + + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } + + if(HwInfo->jChipType >= SIS_661) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); + if(ModeNo > 0x13) { + if(!(modeflag & HalfDCLK)) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); + if(ModeNo != 0x38) { + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); + } + } + } + } else { + if(ModeNo > 0x13) { + if( (!(modeflag & DoubleScanMode)) || (!(modeflag & HalfDCLK))) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); + } else { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); + } + } else { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); + } } - return(data); } #endif -/* =============== Autodetection ================ */ -/* I N C O M P L E T E */ +/*********************************************/ +/* MODE REGISTERS */ +/*********************************************/ -BOOLEAN -SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_SetVCLKState(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT RefreshRateTableIndex, + USHORT ModeIdIndex) { - const USHORT PanelTypeTable300[16] = { - 0xc101, 0xc117, 0x0121, 0xc135, 0xc142, 0xc152, 0xc162, 0xc072, - 0xc181, 0xc192, 0xc1a1, 0xc1b6, 0xc1c2, 0xc0d2, 0xc1e2, 0xc1f2 - }; - const USHORT PanelTypeTable31030x[16] = { - 0xc102, 0xc112, 0x0122, 0xc132, 0xc142, 0xc152, 0xc169, 0xc179, - 0x0189, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - }; - const USHORT PanelTypeTable310LVDS[16] = { - 0xc111, 0xc122, 0xc133, 0xc144, 0xc155, 0xc166, 0xc177, 0xc188, - 0xc199, 0xc0aa, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - }; - USHORT tempax,tempbx,tempah,temp; - - 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 data, data2=0; + USHORT VCLK, index=0; - } else { + if(ModeNo <= 0x13) VCLK = 0; + else { + if(SiS_Pr->UseCustomMode) { + VCLK = SiS_Pr->CSRClock; + } else { + index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; + } + } - tempax = tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1a); - tempax &= 0x1e; - tempax >>= 1; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(tempax == 0) { - /* TODO: Include HUGE detection routine - (Probably not worth bothering) - */ - return 0; - } - temp = tempax & 0xff; - tempax--; - tempbx = PanelTypeTable310LVDS[tempax]; - } else { - tempbx = PanelTypeTable31030x[tempax]; - temp = tempbx & 0xff; - } - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,temp); - tempbx = (tempbx & 0xff00) >> 8; - temp = tempbx & 0xc1; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,~(LCDSyncBit|LCDRGB18Bit),temp); - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - temp = tempbx & 0x04; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x39,0xfb,temp); - } + if(HwInfo->jChipType < SIS_315H) { /* 300 series */ + + data2 = 0x00; + if(VCLK > 150) data2 |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data2); + + data2 = 0x00; + if(VCLK >= 150) data2 |= 0x08; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data2); + + } else { /* 315 series */ + data = 0; + if(VCLK >= 166) data |= 0x0c; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); + + if(VCLK >= 166) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1f,0xe7); + } } - return 1; -} + data2 = 0x03; + if((VCLK >= 135) && (VCLK < 160)) data2 = 0x02; + else if((VCLK >= 160) && (VCLK < 260)) data2 = 0x01; + else if(VCLK >= 260) data2 = 0x00; -#ifdef LINUXBIOS + if(HwInfo->jChipType == SIS_540) { + if((VCLK == 203) || (VCLK < 234)) data2 = 0x02; + } -void -SiS_DetectMonitor(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr) -{ - UCHAR DAC_TEST_PARMS[] = {0x0F,0x0F,0x0F}; - UCHAR DAC_CLR_PARMS[] = {0x00,0x00,0x00}; - USHORT SR1F; + if(HwInfo->jChipType < SIS_315H) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xFC,data2); /* DAC speed */ + } else { + if(HwInfo->jChipType > SIS_315PRO) { + /* This "if" is done in 330 and 650/LVDS/301LV BIOSes; Not in 315 BIOS */ + if(ModeNo > 0x13) data2 &= 0xfc; + } + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xF8,data2); /* DAC speed */ + } +} - SR1F = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1F); /* backup DAC pedestal */ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1F,0x04); +static void +SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex) +{ + USHORT data,data2; + USHORT infoflag=0,modeflag; + USHORT resindex,xres; +#ifdef SIS315H + USHORT data3; + ULONG longdata; +#if 0 + resinfo = 0; +#endif +#endif - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(!(SiS_BridgeIsOn(SiS_Pr, BaseAddr))) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,0x41); - } + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + infoflag = SiS_Pr->CInfoFlag; + } else { + if(ModeNo > 0x13) { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; +#ifdef SIS315H +#if 0 + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; +#endif +#endif + } else { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } } - SiSSetMode(SiS_Pr,HwDeviceExtension,0x2E); - if(HwDeviceExtension->jChipType >= SIS_650) { - /* TW: On 650 only - enable CRT1 */ - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x63,0xbf); + /* Disable DPMS */ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1F,0x3F); + + if(ModeNo > 0x13) data = infoflag; + else data = 0; + + data2 = 0; + if(ModeNo > 0x13) { + if(SiS_Pr->SiS_ModeType > 0x02) { + data2 |= 0x02; + data2 |= ((SiS_Pr->SiS_ModeType - ModeVGA) << 2); + } } - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff); - SiS_ClearDAC(SiS_Pr, SiS_Pr->SiS_P3c8); - SiS_LongWait(SiS_Pr); - SiS_LongWait(SiS_Pr); - SiS_LongWait(SiS_Pr); - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,0xDF,0x00); - if(SiS_TestMonitorType(SiS_Pr, DAC_TEST_PARMS[0],DAC_TEST_PARMS[1],DAC_TEST_PARMS[2])) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,0xDF,0x20); - } else if(SiS_TestMonitorType(SiS_Pr, DAC_TEST_PARMS[0],DAC_TEST_PARMS[1],DAC_TEST_PARMS[2])) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,0xDF,0x20); + +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "Debug: Mode infoflag = %x, Chiptype %d\n", + data, HwInfo->jChipType); +#endif + + if(data & InterlaceMode) data2 |= 0x20; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x06,0xC0,data2); + + if(SiS_Pr->UseCustomMode) { + xres = SiS_Pr->CHDisplay; + } else { + resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex); + if(ModeNo <= 0x13) { + xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; + } else { + xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; + } } - SiS_TestMonitorType(SiS_Pr, DAC_CLR_PARMS[0],DAC_CLR_PARMS[1],DAC_CLR_PARMS[2]); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1F,SR1F); -} + if(HwInfo->jChipType != SIS_300) { + data = 0x0000; + if(infoflag & InterlaceMode) { + if(xres <= 800) data = 0x0020; + else if(xres <= 1024) data = 0x0035; + else data = 0x0048; + } + SiS_SetReg(SiS_Pr->SiS_P3d4,0x19,(data & 0x00FF)); + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x1a,0xFC,(data >> 8)); + } -USHORT -SiS_TestMonitorType(SiS_Private *SiS_Pr, UCHAR R_DAC,UCHAR G_DAC,UCHAR B_DAC) -{ - USHORT temp,tempbx; - - tempbx = R_DAC * 0x4d + G_DAC * 0x97 + B_DAC * 0x1c; - if((tempbx & 0x00ff) > 0x80) tempbx += 0x100; - tempbx = (tempbx & 0xFF00) >> 8; - R_DAC = (UCHAR) tempbx; - G_DAC = (UCHAR) tempbx; - B_DAC = (UCHAR) tempbx; - - SiS_SetReg3(SiS_Pr->SiS_P3c8,0x00); - SiS_SetReg3(SiS_Pr->SiS_P3c9,R_DAC); - SiS_SetReg3(SiS_Pr->SiS_P3c9,G_DAC); - SiS_SetReg3(SiS_Pr->SiS_P3c9,B_DAC); - SiS_LongWait(SiS_Pr); - temp=SiS_GetReg2(SiS_Pr->SiS_P3c2); - if(temp & 0x10) return(1); - else return(0); -} + if(modeflag & HalfDCLK) { + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x08); + } -void -SiS_GetSenseStatus(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,UCHAR *ROMAddr) -{ - USHORT tempax=0,tempbx,tempcx,temp; - USHORT P2reg0=0,SenseModeNo=0,OutputSelect=*SiS_Pr->pSiS_OutputSelect; - USHORT ModeIdIndex,i; - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; - - if(SiS_Pr->SiS_IF_DEF_LVDS == 1){ - SiS_GetPanelID(SiS_Pr); - temp=LCDSense; - temp=temp|SiS_SenseCHTV(SiS_Pr); - tempbx=~(LCDSense|AVIDEOSense|SVIDEOSense); - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,tempbx,temp); - } else { /* for 301 */ - if(SiS_Pr->SiS_IF_DEF_HiVision==1) { /* for HiVision */ - tempax=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x38); - temp=tempax&0x01; - tempax=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A); - temp=temp|(tempax&0x02); - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,0xA0,temp); - } else { - if(SiS_BridgeIsOn(SiS_Pr, BaseAddr)==0) { /* TW: Inserted "==0" */ - P2reg0 = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x00); - if(!(SiS_BridgeIsEnable(SiS_Pr, BaseAddr,HwDeviceExtension))) { - SenseModeNo=0x2e; - temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&SenseModeNo,&ModeIdIndex); - SiS_Pr->SiS_SetFlag = 0x00; - SiS_Pr->SiS_ModeType = ModeVGA; - SiS_Pr->SiS_VBInfo = SetCRT2ToRAMDAC |LoadDACFlag |SetInSlaveMode; - SiS_SetCRT2Group301(SiS_Pr, BaseAddr,ROMAddr,SenseModeNo,HwDeviceExtension); - for(i=0;i<20;i++) { - SiS_LongWait(SiS_Pr); - } - } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,0x1c); - tempax=0; - tempbx=*SiS_Pr->pSiS_RGBSenseData; - if(SiS_Is301B(SiS_Pr, BaseAddr)){ - tempbx=*SiS_Pr->pSiS_RGBSenseData2; - } - tempcx=0x0E08; - if(SiS_Sense(SiS_Pr, tempbx,tempcx)){ - if(SiS_Sense(SiS_Pr, tempbx,tempcx)){ - tempax=tempax|Monitor2Sense; - } - } - tempbx=*SiS_Pr->pSiS_YCSenseData; - if(SiS_Is301B(SiS_Pr, BaseAddr)){ - tempbx=*SiS_Pr->pSiS_YCSenseData2; - } - tempcx=0x0604; - if(SiS_Sense(SiS_Pr, tempbx,tempcx)){ - if(SiS_Sense(SiS_Pr,tempbx,tempcx)){ - tempax=tempax|SVIDEOSense; - } + if(HwInfo->jChipType == SIS_300) { + if(modeflag & LineCompareOff) { + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x08); + } else { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xF7); + } + } else { + if(modeflag & LineCompareOff) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,0x08); + } else { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xB7); + } + if(SiS_Pr->SiS_ModeType == ModeEGA) { + if(ModeNo > 0x13) { + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x40); } + } + } - if(ROMAddr && SiS_Pr->SiS_UseROM) { -#ifdef SIS300 - if((HwDeviceExtension->jChipType==SIS_630)|| - (HwDeviceExtension->jChipType==SIS_730)) { - OutputSelect = ROMAddr[0xfe]; - } +#ifdef SIS315H + /* 315 BIOS sets SR17 at this point */ + if(HwInfo->jChipType == SIS_315PRO) { + data = SiS_Get310DRAMType(SiS_Pr, HwInfo); + data = SiS_Pr->SiS_SR15[2][data]; + if(SiS_Pr->SiS_ModeType == ModeText) { + data &= 0xc7; + } else { + data2 = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + data2 >>= 1; + if(infoflag & InterlaceMode) data2 >>= 1; + data3 = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex) >> 1; + if(!data3) data3++; + data2 /= data3; + if(data2 >= 0x50) { + data &= 0x0f; + data |= 0x50; + } + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x17,data); + } + + /* 330 BIOS sets SR17 at this point */ + if(HwInfo->jChipType == SIS_330) { + data = SiS_Get310DRAMType(SiS_Pr, HwInfo); + data = SiS_Pr->SiS_SR15[2][data]; + if(SiS_Pr->SiS_ModeType <= ModeEGA) { + data &= 0xc7; + } else { + if(SiS_Pr->UseCustomMode) { + data2 = SiS_Pr->CSRClock; + } else { + data2 = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + data2 = SiS_Pr->SiS_VCLKData[data2].CLOCK; + } + + data3 = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex) >> 1; + if(!data3) data3++; + + data2 *= data3; + + longdata = SiS_GetMCLK(SiS_Pr, HwInfo) * 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_SetReg(SiS_Pr->SiS_P3c4,0x17,data); + } #endif + + data = 0x60; + if(SiS_Pr->SiS_ModeType != ModeText) { + data ^= 0x60; + if(SiS_Pr->SiS_ModeType != ModeEGA) { + data ^= 0xA0; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x21,0x1F,data); + + SiS_SetVCLKState(SiS_Pr, HwInfo, ModeNo, RefreshRateTableIndex, ModeIdIndex); + #ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { - OutputSelect = ROMAddr[0xf3]; - if(HwDeviceExtension->jChipType == SIS_330) { - OutputSelect = ROMAddr[0x11b]; - } + 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); + } +#if 0 /* What is SR0E[D5:6]? */ + if(HwInfo->jChipType >= SIS_661) { + data = 0; + if((ModeNo == 6) || ((ModeNo >= 0x0e) && (ModeNo <= 0x13))) { + data |= 0x20; + } + if(SiS_Pr->SiS_ModeType != ModeVGA) { + if(SiS_Pr->UseCustomMode) { + if((xres >= 640) && (SiS_Pr->CVDisplay >= 480)) { + data |= 0x40; + } + if((xres > 1280) && (SiS_Pr->CVDisplay > 1024)) { + data |= 0x60; + } + } + } else if(ModeNo > 0x13) { /* These are in the CRT1 table, and set by CRT1CRTC */ + if(resinfo >= SIS_RI_640x480) { + if(resinfo <= SIS_RI_2048x1536) { + data |= 0x40; + if(resinfo > SIS_RI_1280x1024) { + data |= 0x60; + if(resinfo != SIS_RI_1600x1200) { + data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x0e); + data += 0x60; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0e); + data = 0; + } + } + } + if(resinfo == SIS_RI_1152x864) { + data = 0x40; + } + if(resinfo == SIS_RI_1400x1050) { /* TW */ + data = 0x60; + } } + } + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0e,data); + } #endif - } - if(OutputSelect & BoardTVType){ - tempbx = *SiS_Pr->pSiS_VideoSenseData; - if(SiS_Is301B(SiS_Pr, BaseAddr)){ - tempbx = *SiS_Pr->pSiS_VideoSenseData2; - } - tempcx = 0x0804; - if(SiS_Sense(SiS_Pr, tempbx,tempcx)){ - if(SiS_Sense(SiS_Pr, tempbx,tempcx)){ - tempax |= AVIDEOSense; - } - } - } else { - if(!(tempax & SVIDEOSense)){ - tempbx = *SiS_Pr->pSiS_VideoSenseData; - if(SiS_Is301B(SiS_Pr, BaseAddr)){ - tempbx = *SiS_Pr->pSiS_VideoSenseData2; - } - tempcx = 0x0804; - if(SiS_Sense(SiS_Pr,tempbx,tempcx)){ - if(SiS_Sense(SiS_Pr, tempbx,tempcx)){ - tempax |= AVIDEOSense; - } - } - } - } - } + } +#endif +} - if(SiS_SenseLCD(SiS_Pr, HwDeviceExtension)){ - tempax |= LCDSense; - } +/*********************************************/ +/* LOAD DAC */ +/*********************************************/ - tempbx=0; - tempcx=0; - SiS_Sense(SiS_Pr, tempbx,tempcx); +#if 0 +static void +SiS_ClearDAC(SiS_Private *SiS_Pr, ULONG port) +{ + int i; - if(SiS_Pr->SiS_VBType & (VB_SIS30xLV|VB_SIS30xNEW)) { - tempax &= 0x00ef; /* 301lv to disable CRT2*/ - } - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,~0xDF,tempax); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,P2reg0); - if(!(P2reg0 & 0x20)) { - SiS_Pr->SiS_VBInfo = DisableCRT2Display; - SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,SenseModeNo,HwDeviceExtension); - } - } + 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 { + 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); } -BOOLEAN -SiS_Sense(SiS_Private *SiS_Pr, USHORT tempbx,USHORT tempcx) +void +SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex) { - USHORT temp,i,tempch; - - temp = tempbx & 0xFF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x11,temp); - temp = (tempbx & 0xFF00) >> 8; - temp |= (tempcx & 0x00FF); - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,~0x1F,temp); - - for(i=0; i<10; i++) SiS_LongWait(SiS_Pr); - - tempch = (tempcx & 0x7F00) >> 8; - temp = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x03); - temp ^= 0x0E; - temp &= tempch; - if(temp>0) return 1; - else return 0; + 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<j; i++) { + data = table[i]; + for(k=0; k<3; k++) { + data2 = 0; + if(data & 0x01) data2 = 0x2A; + if(data & 0x02) data2 += 0x15; + if(shiftflag) data2 <<= 2; + SiS_SetRegByte(DACData, data2); + data >>= 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 */ + } } -USHORT -SiS_SenseLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +/*********************************************/ +/* SET CRT1 REGISTER GROUP */ +/*********************************************/ + +static void +SiS_SetCRT1Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex) { - USHORT temp; + USHORT StandTableIndex,RefreshRateTableIndex; - temp=SiS_GetPanelID(SiS_Pr); - if(!temp) temp=SiS_GetLCDDDCInfo(SiS_Pr, HwDeviceExtension); - return(temp); + SiS_Pr->SiS_CRT1Mode = ModeNo; + StandTableIndex = SiS_GetModePtr(SiS_Pr, ModeNo, ModeIdIndex); + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2)) { + SiS_DisableBridge(SiS_Pr, HwInfo); + } + } + + SiS_ResetSegmentRegisters(SiS_Pr, HwInfo); + + SiS_SetSeqRegs(SiS_Pr, StandTableIndex, HwInfo); + SiS_SetMiscRegs(SiS_Pr, StandTableIndex, HwInfo); + SiS_SetCRTCRegs(SiS_Pr, HwInfo, StandTableIndex); + SiS_SetATTRegs(SiS_Pr, StandTableIndex, HwInfo); + SiS_SetGRCRegs(SiS_Pr, StandTableIndex); + SiS_ClearExt1Regs(SiS_Pr,HwInfo); + SiS_ResetCRT1VCLK(SiS_Pr, HwInfo); + + SiS_Pr->SiS_SelectCRT2Rate = 0; + SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); + +#ifdef LINUX_XF86 + xf86DrvMsgVerb(0, X_PROBED, 4, "(init: VBType=0x%04x, VBInfo=0x%04x)\n", + SiS_Pr->SiS_VBType, SiS_Pr->SiS_VBInfo); +#endif + + if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + } + } + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + } + + RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + SiS_Pr->SiS_SetFlag &= ~ProgrammingCRT2; + } + + if(RefreshRateTableIndex != 0xFFFF) { + SiS_SetCRT1Sync(SiS_Pr, RefreshRateTableIndex); + SiS_SetCRT1CRTC(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetCRT1Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetCRT1VCLK(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + } + +#ifdef SIS300 + if(HwInfo->jChipType == SIS_300) { + SiS_SetCRT1FIFO_300(SiS_Pr, ModeNo,HwInfo,RefreshRateTableIndex); + } else if((HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730) || + (HwInfo->jChipType == SIS_540)) { + SiS_SetCRT1FIFO_630(SiS_Pr, ModeNo, HwInfo, RefreshRateTableIndex); + } +#endif +#ifdef SIS315H + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetCRT1FIFO_310(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + } +#endif + + SiS_SetCRT1ModeRegs(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); + + SiS_LoadDAC(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + +#ifndef LINUX_XF86 + if(SiS_Pr->SiS_flag_clearbuffer) { + SiS_ClearBuffer(SiS_Pr,HwInfo,ModeNo); + } +#endif + + if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA))) { + SiS_WaitRetrace1(SiS_Pr); + SiS_DisplayOn(SiS_Pr); + } } -BOOLEAN -SiS_GetLCDDDCInfo(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +/*********************************************/ +/* HELPER: ENABLE CRT1 */ +/*********************************************/ + +static void +SiS_HandleCRT1(SiS_Private *SiS_Pr) { - USHORT temp; - /*add lcd sense*/ - if(HwDeviceExtension->ulCRT2LCDType==LCD_UNKNOWN) - return 0; - else{ - temp=(USHORT)HwDeviceExtension->ulCRT2LCDType; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,temp); - return 1; + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x63,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,0x63,0x40); + } } +#endif } -USHORT -SiS_SenseCHTV(SiS_Private *SiS_Pr) +/*********************************************/ +/* HELPER: SET VIDEO REGISTERS */ +/*********************************************/ + +static void +SiS_StrangeStuff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - USHORT temp,push0e,status; - - status=0; - push0e = SiS_GetCH700x(SiS_Pr, 0x0e); - push0e = (push0e << 8) | 0x0e; - SiS_SetCH700x(SiS_Pr, 0x0b0e); - SiS_SetCH700x(SiS_Pr, 0x0110); - SiS_SetCH700x(SiS_Pr, 0x0010); - temp = SiS_GetCH700x(SiS_Pr, 0x10); - if(temp & 0x08) status |= SVIDEOSense; - if(temp & 0x02) status |= AVIDEOSense; - SiS_SetCH700x(SiS_Pr, push0e); - return(status); + 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 !!! */ } -#endif /* LINUXBIOS */ -/* ================ for TC only ================= */ +/*********************************************/ +/* XFree86: SET SCREEN PITCH */ +/*********************************************/ -#ifdef TC +#ifdef LINUX_XF86 +static void +SiS_SetPitchCRT1(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + UShort HDisplay = pSiS->scrnPitch >> 3; -int -INT1AReturnCode(union REGS regs) + 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) { - if (regs.x.cflag) - { - /*printf("Error to find pci device!\n"); */ - return 1; - } + SISPtr pSiS = SISPTR(pScrn); + UShort HDisplay = pSiS->scrnPitch2 >> 3; - switch(regs.h.ah) - { - case 0: return 0; - break; - case 0x81: printf("Function not support\n"); - break; - case 0x83: printf("bad vendor id\n"); - break; - case 0x86: printf("device not found\n"); - break; - case 0x87: printf("bad register number\n"); - break; - case 0x88: printf("set failed\n"); - break; - case 0x89: printf("buffer too small"); - break; - } - return 1; + /* 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)); } -unsigned -FindPCIIOBase(unsigned index,unsigned deviceid) +static void +SiS_SetPitch(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) { - union REGS regs; - - regs.h.ah = 0xb1; /*PCI_FUNCTION_ID */ - regs.h.al = 0x02; /*FIND_PCI_DEVICE */ - regs.x.cx = deviceid; - regs.x.dx = 0x1039; - regs.x.si = index; /* find n-th device */ - - int86(0x1A, ®s, ®s); - - if (INT1AReturnCode(regs)!=0) - return 0; - - /* regs.h.bh *//* bus number */ - /* regs.h.bl *//* device number */ - regs.h.ah = 0xb1; /*PCI_FUNCTION_ID */ - regs.h.al = 0x09; /*READ_CONFIG_WORD */ - regs.x.cx = deviceid; - regs.x.dx = 0x1039; - regs.x.di = 0x18; /* register number */ - int86(0x1A, ®s, ®s); - - if (INT1AReturnCode(regs)!=0) - return 0; - return regs.x.cx; + 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 +/*********************************************/ +/* SiSSetMode() */ +/*********************************************/ -void -main(int argc, char *argv[]) +#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 { - SIS_HW_DEVICE_INFO HwDeviceExtension; - USHORT temp; - USHORT ModeNo; + ULONG temp; + USHORT ModeIdIndex; + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + SISIOADDRESS BaseAddr = HwInfo->ulIOAddress; + unsigned char backupreg=0, tempr1, tempr2; +#ifndef LINUX_XF86 + USHORT KeepLockReg; + + SiS_Pr->UseCustomMode = FALSE; + SiS_Pr->CRT1UsesCustomMode = FALSE; +#endif + + if(SiS_Pr->UseCustomMode) { + ModeNo = 0xfe; + } + + SiSInitPtr(SiS_Pr, HwInfo); + + SiSRegInit(SiS_Pr, BaseAddr); + + SiS_GetSysFlags(SiS_Pr, HwInfo); + +#ifdef LINUX_XF86 + if(pScrn) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); + else +#endif + SiS_Pr->SiS_VGAINFO = 0x11; + + SiSInitPCIetc(SiS_Pr, HwInfo); - /*HwDeviceExtension.pjVirtualRomBase =(PUCHAR) MK_FP(0xC000,0); */ - /*HwDeviceExtension.pjVideoMemoryAddress = (PUCHAR)MK_FP(0xA000,0);*/ + SiSSetLVDSetc(SiS_Pr, HwInfo); -#ifdef SIS300 - HwDeviceExtension.ulIOAddress = (FindPCIIOBase(0,0x6300)&0xFF80) + 0x30; - HwDeviceExtension.jChipType = SIS_630; + SiSDetermineROMUsage(SiS_Pr, HwInfo); + + if(!SiS_Pr->UseCustomMode) { + ModeNo = ((ModeNo & 0x80) << 8) | (ModeNo & 0x7f); + } + +#ifdef LINUX_XF86 + /* We never clear the buffer in X */ + ModeNo |= 0x8000; #endif -#ifdef SIS315H -// HwDeviceExtension.ulIOAddress = (FindPCIIOBase(0,0x5315)&0xFF80) + 0x30; -// HwDeviceExtension.jChipType = SIS_550; - HwDeviceExtension.ulIOAddress = (FindPCIIOBase(0,0x325)&0xFF80) + 0x30; - HwDeviceExtension.jChipType = SIS_315H; + if(ModeNo & 0x8000) { + ModeNo &= 0x7fff; + SiS_Pr->SiS_flag_clearbuffer = 0; + } else { + SiS_Pr->SiS_flag_clearbuffer = 1; + } + +#ifndef LINUX_XF86 + KeepLockReg = SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); #endif + SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); - HwDeviceExtension.ujVBChipID = VB_CHIP_301; - strcpy(HwDeviceExtension.szVBIOSVer,"0.84"); - HwDeviceExtension.bSkipDramSizing = FALSE; - HwDeviceExtension.ulVideoMemorySize = 0; - if(argc==2) { - ModeNo=atoi(argv[1]); - } - else { - ModeNo=0x2e; - /*ModeNo=0x37; */ /* 1024x768x 4bpp */ - /*ModeNo=0x38; *//* 1024x768x 8bpp */ - /*ModeNo=0x4A; *//* 1024x768x 16bpp */ - /*ModeNo=0x47;*/ /* 800x600x 16bpp */ - } - /* SiSInit(SiS_Pr, &HwDeviceExtension);*/ - SiSSetMode(SiS_Pr, &HwDeviceExtension, ModeNo); -} -#endif /* TC END */ + SiS_UnLockCRT2(SiS_Pr, HwInfo); + + if(!SiS_Pr->UseCustomMode) { + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; + } else { + ModeIdIndex = 0; + } -/* ================ LINUX XFREE86 ====================== */ + SiS_GetVBType(SiS_Pr, HwInfo); -/* Helper functions */ + /* Init/restore some VB registers */ + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + SiS_UnLockCRT2(SiS_Pr,HwInfo); + if(HwInfo->jChipType < SIS_330) { + if(ROMAddr && SiS_Pr->SiS_UseROM) { + temp = ROMAddr[VB310Data_1_2_Offset]; + temp |= 0x40; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); + } + } + 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); + } + } + + /* Get VB information (connectors, connected devices) */ + SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, (SiS_Pr->UseCustomMode) ? 0 : 1); + SiS_SetHiVision(SiS_Pr, HwInfo); + SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_SetLowModeTest(SiS_Pr, ModeNo, HwInfo); + +#ifndef LINUX_XF86 + /* 3. Check memory size (Kernel framebuffer driver only) */ + temp = SiS_CheckMemorySize(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + if(!temp) return(0); +#endif + + if(HwInfo->jChipType >= SIS_315H) { +#if 0 + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x08) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(ModeNo != 0x10) SiS_Pr->SiS_SetFlag |= SetDOSMode; + } else if((IS_SIS651) && (SiS_Pr->SiS_VBType & VB_NoLCD)) { + SiS_Pr->SiS_SetFlag |= SetDOSMode; + } + } +#endif + + 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->UseCustomMode) { + SiS_Pr->CRT1UsesCustomMode = TRUE; + SiS_Pr->CSRClock_CRT1 = SiS_Pr->CSRClock; + SiS_Pr->CModeFlag_CRT1 = SiS_Pr->CModeFlag; + } else { + SiS_Pr->CRT1UsesCustomMode = FALSE; + } + + /* Set mode on CRT1 */ + if( (SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) || + (!(SiS_Pr->SiS_VBInfo & SwitchCRT2)) ) { + SiS_SetCRT1Group(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + } + + /* Set mode on CRT2 */ + if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA)) { + if( (SiS_Pr->SiS_VBType & VB_SISVB) || + (SiS_Pr->SiS_IF_DEF_LVDS == 1) || + (SiS_Pr->SiS_IF_DEF_CH70xx != 0) || + (SiS_Pr->SiS_IF_DEF_TRUMPION != 0) ) { + SiS_SetCRT2Group(SiS_Pr, HwInfo, ModeNo); + } + } + + SiS_HandleCRT1(SiS_Pr); + + SiS_StrangeStuff(SiS_Pr, HwInfo); + + SiS_DisplayOn(SiS_Pr); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); + + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); + } + } + } + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + if(HwInfo->jChipType < SIS_661) { + if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); + } else { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); + } + } + + SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg); + + tempr1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + tempr2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00); + if(tempr1 & SetCRT2ToAVIDEO) tempr2 &= 0xF7; + else tempr2 |= 0x08; + if(tempr1 & SetCRT2ToSVIDEO) tempr2 &= 0xFB; + else tempr2 |= 0x04; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x00,tempr2); + + if((IS_SIS650) && (SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & 0xfc)) { + if((ModeNo == 0x03) || (ModeNo == 0x10)) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x80); + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x56,0x08); + } + } + + if(tempr1 & SetCRT2ToLCD) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); + } + } else if((HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730)) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg); + } + } #ifdef LINUX_XF86 -USHORT -SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode) -{ - SISPtr pSiS = SISPTR(pScrn); - UShort i = (pSiS->CurrentLayout.bitsPerPixel+7)/8 - 1; - UShort ModeIndex = 0; + if(pScrn) { + /* SetPitch: Adapt to virtual size & position */ + if((ModeNo > 0x13) && (dosetpitch)) { + SiS_SetPitch(SiS_Pr, pScrn); + } + + /* Backup/Set ModeNo in BIOS scratch area */ + SiS_GetSetModeID(pScrn, ModeNo); + } +#endif + +#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 TRUE; +} - if((pSiS->HaveCustomModes) && (!(mode->type & M_T_DEFAULT))) - return 0xfe; +/*********************************************/ +/* 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) +{ + SISPtr pSiS = SISPTR(pScrn); + UShort ModeNo=0; - switch(mode->HDisplay) - { - case 320: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_320x480[i]; - } - break; - case 512: - if(mode->VDisplay == 384) { - ModeIndex = ModeIndex_512x384[i]; - } - break; - case 640: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_640x480[i]; - } else if(mode->VDisplay == 400) { - ModeIndex = ModeIndex_640x400[i]; - } - break; - case 720: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_720x480[i]; - } else if(mode->VDisplay == 576) { - ModeIndex = ModeIndex_720x576[i]; - } - break; - case 800: - if(mode->VDisplay == 600) { - ModeIndex = ModeIndex_800x600[i]; - } else if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_800x480[i]; - } - break; - case 848: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_848x480[i]; - } - break; - case 856: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_856x480[i]; - } - break; - case 1024: - if(mode->VDisplay == 768) { - ModeIndex = ModeIndex_1024x768[i]; - } else if(mode->VDisplay == 576) { - ModeIndex = ModeIndex_1024x576[i]; - } else if(pSiS->VGAEngine == SIS_300_VGA) { - if(mode->VDisplay == 600) { - ModeIndex = ModeIndex_1024x600[i]; - } - } - break; - case 1152: - if(mode->VDisplay == 864) { - ModeIndex = ModeIndex_1152x864[i]; - } else if(pSiS->VGAEngine == SIS_300_VGA) { - if(mode->VDisplay == 768) { - ModeIndex = ModeIndex_1152x768[i]; - } - } - break; - case 1280: - if(mode->VDisplay == 960) { - if(pSiS->VGAEngine == SIS_300_VGA) { - ModeIndex = ModeIndex_300_1280x960[i]; - } else { - ModeIndex = ModeIndex_310_1280x960[i]; - } - } else if (mode->VDisplay == 1024) { - ModeIndex = ModeIndex_1280x1024[i]; - } else if (mode->VDisplay == 720) { - ModeIndex = ModeIndex_1280x720[i]; - } else if(pSiS->VGAEngine == SIS_315_VGA) { - if (mode->VDisplay == 768) { - ModeIndex = ModeIndex_1280x768[i]; - } - } - break; - case 1360: - if(mode->VDisplay == 768) { - ModeIndex = ModeIndex_1360x768[i]; - } - break; - case 1400: - if(pSiS->VGAEngine == SIS_315_VGA) { - if(mode->VDisplay == 1050) { - ModeIndex = ModeIndex_1400x1050[i]; - } - } - break; - case 1600: - if(mode->VDisplay == 1200) { - ModeIndex = ModeIndex_1600x1200[i]; - } - break; - case 1920: - if(mode->VDisplay == 1440) { - ModeIndex = ModeIndex_1920x1440[i]; - } - break; - case 2048: - if(mode->VDisplay == 1536) { - if(pSiS->VGAEngine == SIS_300_VGA) { - ModeIndex = ModeIndex_300_2048x1536[i]; - } else { - ModeIndex = ModeIndex_310_2048x1536[i]; - } - } - break; + 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))); + + return(SiSSetMode(SiS_Pr, HwInfo, pScrn, ModeNo, TRUE)); + } - return(ModeIndex); + 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)); } -USHORT -SiS_CheckCalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags) +/*********************************************/ +/* XFree86: SiSBIOSSetModeCRT2() */ +/* for Dual-Head modes */ +/*********************************************/ +BOOLEAN +SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom) { - SISPtr pSiS = SISPTR(pScrn); - UShort i = (pSiS->CurrentLayout.bitsPerPixel+7)/8 - 1; - UShort ModeIndex = 0; + ULONG temp; + USHORT ModeIdIndex; + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + SISIOADDRESS BaseAddr = HwInfo->ulIOAddress; + UShort ModeNo = 0; + unsigned char tempr1, tempr2, backupreg=0; + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; +#endif - if(VBFlags & CRT2_LCD) { + SiS_Pr->UseCustomMode = FALSE; - if( (mode->HDisplay <= pSiS->LCDwidth) && - (mode->VDisplay <= pSiS->LCDheight) ) { + /* 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(VBFlags & VB_LVDS) { /* LCD on LVDS */ + if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { - switch(mode->HDisplay) - { - case 512: - if(mode->VDisplay == 384) { - if(pSiS->LCDwidth != 1024 || pSiS->LCDheight != 600) { /* not supported on 1024x600 panels */ - ModeIndex = ModeIndex_512x384[i]; - } - } - break; - case 640: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_640x480[i]; - } else if(mode->VDisplay == 400) { - ModeIndex = ModeIndex_640x400[i]; - } - break; - case 800: - if(mode->VDisplay == 600) { - ModeIndex = ModeIndex_800x600[i]; - } - break; - case 1024: - if(mode->VDisplay == 768) { - ModeIndex = ModeIndex_1024x768[i]; - } else if(pSiS->VGAEngine == SIS_300_VGA) { - if(mode->VDisplay == 600) { - if(pSiS->LCDheight == 600) { /* This mode only supported on 1024x600 panels */ - ModeIndex = ModeIndex_1024x600[i]; - } - } - } - break; - case 1152: - if(pSiS->VGAEngine == SIS_300_VGA) { - if(mode->VDisplay == 768) { - ModeIndex = ModeIndex_1152x768[i]; - } - } - break; - case 1280: - if(mode->VDisplay == 1024) { - ModeIndex = ModeIndex_1280x1024[i]; - } else if(pSiS->VGAEngine == SIS_315_VGA) { - if(mode->VDisplay == 768) { - ModeIndex = ModeIndex_1280x768[i]; - } - } - break; - case 1400: - if(mode->VDisplay == 1050) { - if(pSiS->VGAEngine == SIS_315_VGA) { - ModeIndex = ModeIndex_1400x1050[i]; - } - } - break; - } + ModeNo = 0xfe; - } else { /* LCD on 301(B) */ + } else { - switch(mode->HDisplay) - { - case 512: - if(mode->VDisplay == 384) { - ModeIndex = ModeIndex_512x384[i]; - } - break; - case 640: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_640x480[i]; - } else if(mode->VDisplay == 400) { - ModeIndex = ModeIndex_640x400[i]; - } - break; - case 800: - if(mode->VDisplay == 600) { - ModeIndex = ModeIndex_800x600[i]; - } - break; - case 1024: - if(mode->VDisplay == 768) { - ModeIndex = ModeIndex_1024x768[i]; - } - break; - case 1280: - if(mode->VDisplay == 960) { - if(pSiS->VGAEngine == SIS_300_VGA) { - ModeIndex = ModeIndex_300_1280x960[i]; - } else { - ModeIndex = ModeIndex_310_1280x960[i]; - } - } else if (mode->VDisplay == 1024) { - ModeIndex = ModeIndex_1280x1024[i]; - } - break; - case 1400: - if(mode->VDisplay == 1050) { - if(pSiS->VGAEngine == SIS_315_VGA) { - ModeIndex = ModeIndex_1400x1050[i]; - } - } - break; - case 1600: - if(mode->VDisplay == 1200) { - ModeIndex = ModeIndex_1600x1200[i]; - } - break; - } + BOOLEAN havecustommodes = pSiS->HaveCustomModes; - } +#ifdef SISMERGED + if(pSiS->MergedFB) havecustommodes = pSiS->HaveCustomModes2; +#endif + ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, havecustommodes); + if(!ModeNo) return FALSE; + + } + + SiSRegInit(SiS_Pr, BaseAddr); + + SiSInitPtr(SiS_Pr, HwInfo); + + SiS_GetSysFlags(SiS_Pr, HwInfo); + + SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); + + SiSInitPCIetc(SiS_Pr, HwInfo); + + SiSSetLVDSetc(SiS_Pr, HwInfo); + + SiSDetermineROMUsage(SiS_Pr, HwInfo); + + /* Save mode info so we can set it from within SetMode for CRT1 */ +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + pSiSEnt->CRT2ModeNo = ModeNo; + pSiSEnt->CRT2DMode = mode; + pSiSEnt->CRT2IsCustom = IsCustom; + pSiSEnt->CRT2CR30 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + pSiSEnt->CRT2CR31 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); + pSiSEnt->CRT2CR35 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + pSiSEnt->CRT2CR38 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); +#if 0 + /* We can't set CRT2 mode before CRT1 mode is set */ + if(pSiSEnt->CRT1ModeNo == -1) { + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting CRT2 mode delayed until after setting CRT1 mode\n"); + return TRUE; } +#endif + pSiSEnt->CRT2ModeSet = TRUE; + } +#endif - } else if(VBFlags & CRT2_TV) { + /* We don't clear the buffer under X */ + SiS_Pr->SiS_flag_clearbuffer=0; - if(VBFlags & VB_CHRONTEL) { /* TV on Chrontel */ + if(SiS_Pr->UseCustomMode) { - switch(mode->HDisplay) - { - case 512: - if(pSiS->VGAEngine == SIS_315_VGA) { - if(mode->VDisplay == 384) { - ModeIndex = ModeIndex_512x384[i]; - } - } - break; - case 640: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_640x480[i]; - } else if(mode->VDisplay == 400) { - ModeIndex = ModeIndex_640x400[i]; - } - break; - case 800: - if(mode->VDisplay == 600) { - ModeIndex = ModeIndex_800x600[i]; - } - break; - case 1024: - if(mode->VDisplay == 768) { - if(pSiS->VGAEngine == SIS_315_VGA) { - ModeIndex = ModeIndex_1024x768[i]; - } - } - break; - } + USHORT temptemp = SiS_Pr->CVDisplay; - } else { /* TV on 301(B/LV) */ + if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; + else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; - switch(mode->HDisplay) - { - case 512: - if(mode->VDisplay == 384) { - ModeIndex = ModeIndex_512x384[i]; - } - break; - case 640: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_640x480[i]; - } - break; - case 720: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_720x480[i]; - } else if(mode->VDisplay == 576) { - ModeIndex = ModeIndex_720x576[i]; - } - break; - case 800: - if(mode->VDisplay == 600) { - ModeIndex = ModeIndex_800x600[i]; - } - break; - case 1024: /* Not supported with depth 32 */ - if((mode->VDisplay == 768) && (i != 3) ) { - if(VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) { - ModeIndex = ModeIndex_1024x768[i]; - } - } - break; - } + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting custom mode %dx%d on CRT2\n", + SiS_Pr->CHDisplay, temptemp); + + } else { + + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting standard mode 0x%x on CRT2\n", ModeNo); + + } + + SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); + + SiS_UnLockCRT2(SiS_Pr, HwInfo); + + if(!SiS_Pr->UseCustomMode) { + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; + } else { + ModeIdIndex = 0; + } + + SiS_GetVBType(SiS_Pr, HwInfo); + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + SiS_UnLockCRT2(SiS_Pr,HwInfo); + if(HwInfo->jChipType < SIS_330) { + if(ROMAddr && SiS_Pr->SiS_UseROM) { + temp = ROMAddr[VB310Data_1_2_Offset]; + temp |= 0x40; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); + } + } + 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); } + } - } else if(VBFlags & CRT2_VGA) { /* CRT2 is VGA2 */ + /* 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_SetHiVision(SiS_Pr, HwInfo); + SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_SetLowModeTest(SiS_Pr, ModeNo, HwInfo); - switch(mode->HDisplay) - { - case 640: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_640x480[i]; - } else if(mode->VDisplay == 400) { - ModeIndex = ModeIndex_640x400[i]; - } - break; - case 800: - if(mode->VDisplay == 600) { - ModeIndex = ModeIndex_800x600[i]; - } else if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_800x480[i]; - } - break; - case 848: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_848x480[i]; - } - break; - case 856: - if(mode->VDisplay == 480) { - ModeIndex = ModeIndex_856x480[i]; - } - break; - case 1024: - if(mode->VDisplay == 768) { - ModeIndex = ModeIndex_1024x768[i]; - } else if(mode->VDisplay == 576) { - ModeIndex = ModeIndex_1024x576[i]; - } - break; - case 1152: - if(mode->VDisplay == 864) { - ModeIndex = ModeIndex_1152x864[i]; - } else if(pSiS->VGAEngine == SIS_300_VGA) { - if(mode->VDisplay == 768) { - ModeIndex = ModeIndex_1152x768[i]; - } - } - break; - case 1280: - if (mode->VDisplay == 1024) { - ModeIndex = ModeIndex_1280x1024[i]; - } else if (mode->VDisplay == 720) { - ModeIndex = ModeIndex_1280x720[i]; - } else if(pSiS->VGAEngine == SIS_315_VGA) { - if (mode->VDisplay == 768) { - ModeIndex = ModeIndex_1280x768[i]; - } - } - break; - } + /* 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); + } - } else { /* CRT1 only, no CRT2 */ + SiS_StrangeStuff(SiS_Pr, HwInfo); - ModeIndex = SiS_CalcModeIndex(pScrn, mode); + SiS_DisplayOn(SiS_Pr); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); + } + } } - return(ModeIndex); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(HwInfo->jChipType >= SIS_315H) { + if(HwInfo->jChipType < SIS_661) { + if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); + } else { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); + } + } + + SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg); + + tempr1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + tempr2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00); + if(tempr1 & SetCRT2ToAVIDEO) tempr2 &= 0xF7; + else tempr2 |= 0x08; + if(tempr1 & SetCRT2ToSVIDEO) tempr2 &= 0xFB; + else tempr2 |= 0x04; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x00,tempr2); + + if(tempr1 & 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); + } + } + + /* SetPitch: Adapt to virtual size & position */ + SiS_SetPitchCRT2(SiS_Pr, pScrn); + + return TRUE; } +/*********************************************/ +/* XFree86: SiSBIOSSetModeCRT1() */ +/* for Dual-Head modes */ +/*********************************************/ + +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 + + SiS_Pr->UseCustomMode = FALSE; + + if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { + + USHORT temptemp = SiS_Pr->CVDisplay; + + if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; + else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; + + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting custom mode %dx%d on CRT1\n", + SiS_Pr->CHDisplay, temptemp); + ModeNo = 0xfe; + + } else { + + ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes); + if(!ModeNo) return FALSE; + + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Setting standard mode 0x%x on CRT1\n", ModeNo); + } + + SiSInitPtr(SiS_Pr, HwInfo); + + SiSRegInit(SiS_Pr, BaseAddr); + + SiS_GetSysFlags(SiS_Pr, HwInfo); + + SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); + + SiSInitPCIetc(SiS_Pr, HwInfo); + + SiSSetLVDSetc(SiS_Pr, HwInfo); + + SiSDetermineROMUsage(SiS_Pr, HwInfo); + + /* We don't clear the buffer under X */ + SiS_Pr->SiS_flag_clearbuffer = 0; + + SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); + + SiS_UnLockCRT2(SiS_Pr, HwInfo); + + if(!SiS_Pr->UseCustomMode) { + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; + } else { + ModeIdIndex = 0; + } + + /* 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_SetHiVision(SiS_Pr, HwInfo); + SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_SetLowModeTest(SiS_Pr, ModeNo, HwInfo); + + if(HwInfo->jChipType >= SIS_315H) { +#if 0 + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x08) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(ModeNo != 0x10) SiS_Pr->SiS_SetFlag |= SetDOSMode; + } else if((IS_SIS651) && (SiS_Pr->SiS_VBType & VB_NoLCD)) { + SiS_Pr->SiS_SetFlag |= SetDOSMode; + } + } +#endif + + 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); + } + } + } + + /* 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 + + 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; + } + + /* 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 + + /* Warning: From here, the custom mode entries in SiS_Pr are + * possibly overwritten + */ + + SiS_HandleCRT1(SiS_Pr); + + SiS_StrangeStuff(SiS_Pr, HwInfo); + + SiS_DisplayOn(SiS_Pr); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); + + 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); + } + } + + /* Backup/Set ModeNo in BIOS scratch area */ + SiS_GetSetModeID(pScrn,ModeNo); + + return TRUE; +} +#endif /* Linux_XF86 */ + + +#ifdef LINUX_XF86 +BOOLEAN +SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + const USHORT PanelTypeTable300[16] = { + 0xc101, 0xc117, 0x0121, 0xc135, 0xc142, 0xc152, 0xc162, 0xc072, + 0xc181, 0xc192, 0xc1a1, 0xc1b6, 0xc1c2, 0xc0d2, 0xc1e2, 0xc1f2 + }; + const USHORT PanelTypeTable31030x[16] = { + 0xc102, 0xc112, 0x0122, 0xc132, 0xc142, 0xc152, 0xc169, 0xc179, + 0x0189, 0xc192, 0xc1a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 + }; + const USHORT PanelTypeTable310LVDS[16] = { + 0xc111, 0xc122, 0xc133, 0xc144, 0xc155, 0xc166, 0xc177, 0xc188, + 0xc199, 0xc0aa, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 + }; + USHORT tempax,tempbx,temp; + + 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 { + + if(HwInfo->jChipType >= SIS_661) return 0; + + tempax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1a); + tempax &= 0x1e; + tempax >>= 1; + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(tempax == 0) { + /* TODO: Include HUGE detection routine + (Probably not worth bothering) + */ + return 0; + } + temp = tempax & 0xff; + tempax--; + tempbx = PanelTypeTable310LVDS[tempax]; + } else { + tempbx = PanelTypeTable31030x[tempax]; + temp = tempbx & 0xff; + } + SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,temp); + tempbx = (tempbx & 0xff00) >> 8; + temp = tempbx & 0xc1; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,~(LCDSyncBit|LCDRGB18Bit),temp); + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp = tempbx & 0x04; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x39,0xfb,temp); + } + + } + return 1; +} +#endif + + +/* ================ XFREE86 ================= */ + +/* Helper functions */ + +#ifdef LINUX_XF86 USHORT SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags) { SISPtr pSiS = SISPTR(pScrn); int out_n, out_dn, out_div, out_sbit, out_scale; int depth = pSiS->CurrentLayout.bitsPerPixel; - -#ifdef SISDUALHEAD - if( ((!pSiS->DualHeadMode) && (VBFlags & DISPTYPE_DISP2)) || - ((pSiS->DualHeadMode) && (!pSiS->SecondHead)) ) return 0; -#else - if(VBFlags & DISPTYPE_DISP2) return 0; -#endif + unsigned int vclk[5]; + +#define Midx 0 +#define Nidx 1 +#define VLDidx 2 +#define Pidx 3 +#define PSNidx 4 + + pSiS->SiS_Pr->CModeFlag = 0; pSiS->SiS_Pr->CDClock = mode->Clock; - + pSiS->SiS_Pr->CHDisplay = mode->HDisplay; pSiS->SiS_Pr->CHSyncStart = mode->HSyncStart; pSiS->SiS_Pr->CHSyncEnd = mode->HSyncEnd; pSiS->SiS_Pr->CHTotal = mode->HTotal; - pSiS->SiS_Pr->CHBlankStart = pSiS->SiS_Pr->CHDisplay; - pSiS->SiS_Pr->CHBlankEnd = pSiS->SiS_Pr->CHTotal; - + pSiS->SiS_Pr->CVDisplay = mode->VDisplay; pSiS->SiS_Pr->CVSyncStart = mode->VSyncStart; pSiS->SiS_Pr->CVSyncEnd = mode->VSyncEnd; pSiS->SiS_Pr->CVTotal = mode->VTotal; + + pSiS->SiS_Pr->CFlags = mode->Flags; + + if(pSiS->SiS_Pr->CFlags & V_INTERLACE) { + pSiS->SiS_Pr->CVDisplay >>= 1; + pSiS->SiS_Pr->CVSyncStart >>= 1; + pSiS->SiS_Pr->CVSyncEnd >>= 1; + pSiS->SiS_Pr->CVTotal >>= 1; + } + if(pSiS->SiS_Pr->CFlags & V_DBLSCAN) { + /* pSiS->SiS_Pr->CDClock <<= 1; */ + pSiS->SiS_Pr->CVDisplay <<= 1; + pSiS->SiS_Pr->CVSyncStart <<= 1; + pSiS->SiS_Pr->CVSyncEnd <<= 1; + pSiS->SiS_Pr->CVTotal <<= 1; + } + + pSiS->SiS_Pr->CHBlankStart = pSiS->SiS_Pr->CHDisplay; + pSiS->SiS_Pr->CHBlankEnd = pSiS->SiS_Pr->CHTotal; pSiS->SiS_Pr->CVBlankStart = pSiS->SiS_Pr->CVSyncStart - 1; pSiS->SiS_Pr->CVBlankEnd = pSiS->SiS_Pr->CVTotal; - - pSiS->SiS_Pr->CFlags = mode->Flags; - SiS_compute_vclk(pSiS->SiS_Pr->CDClock, &out_n, &out_dn, &out_div, &out_sbit, &out_scale); - + if(SiS_compute_vclk(pSiS->SiS_Pr->CDClock, &out_n, &out_dn, &out_div, &out_sbit, &out_scale)) { + pSiS->SiS_Pr->CSR2B = (out_div == 2) ? 0x80 : 0x00; + pSiS->SiS_Pr->CSR2B |= ((out_n - 1) & 0x7f); + pSiS->SiS_Pr->CSR2C = (out_dn - 1) & 0x1f; + pSiS->SiS_Pr->CSR2C |= (((out_scale - 1) & 3) << 5); + pSiS->SiS_Pr->CSR2C |= ((out_sbit & 0x01) << 7); #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sb %d sc %d\n", - pSiS->SiS_Pr->CDClock, out_n, out_dn, out_div, out_sbit, out_scale); -#endif - - pSiS->SiS_Pr->CSR2B = (out_div == 2) ? 0x80 : 0x00; - pSiS->SiS_Pr->CSR2B |= ((out_n - 1) & 0x7f); - pSiS->SiS_Pr->CSR2C = (out_dn - 1) & 0x1f; - pSiS->SiS_Pr->CSR2C |= (((out_scale - 1) & 3) << 5); - pSiS->SiS_Pr->CSR2C |= ((out_sbit & 0x01) << 7); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sb %d sc %d\n", + pSiS->SiS_Pr->CDClock, out_n, out_dn, out_div, out_sbit, out_scale); +#endif + } else { + SiSCalcClock(pScrn, pSiS->SiS_Pr->CDClock, 2, vclk); + pSiS->SiS_Pr->CSR2B = (vclk[VLDidx] == 2) ? 0x80 : 0x00; + pSiS->SiS_Pr->CSR2B |= (vclk[Midx] - 1) & 0x7f; + pSiS->SiS_Pr->CSR2C = (vclk[Nidx] - 1) & 0x1f; + if(vclk[Pidx] <= 4) { + /* postscale 1,2,3,4 */ + pSiS->SiS_Pr->CSR2C |= ((vclk[Pidx] - 1) & 3) << 5; + } else { + /* postscale 6,8 */ + pSiS->SiS_Pr->CSR2C |= (((vclk[Pidx] / 2) - 1) & 3) << 5; + pSiS->SiS_Pr->CSR2C |= 0x80; + } +#ifdef TWDEBUG + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sc %d\n", + pSiS->SiS_Pr->CDClock, vclk[Midx], vclk[Nidx], vclk[VLDidx], vclk[Pidx]); +#endif + } + pSiS->SiS_Pr->CSRClock = (pSiS->SiS_Pr->CDClock / 1000) + 1; pSiS->SiS_Pr->CCRT1CRTC[0] = ((pSiS->SiS_Pr->CHTotal >> 3) - 5) & 0xff; @@ -5501,9 +4353,9 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags) pSiS->SiS_Pr->CCRT1CRTC[2] = (pSiS->SiS_Pr->CHBlankStart >> 3) - 1; pSiS->SiS_Pr->CCRT1CRTC[3] = (((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1) & 0x1F) | 0x80; pSiS->SiS_Pr->CCRT1CRTC[4] = (pSiS->SiS_Pr->CHSyncStart >> 3) + 3; - pSiS->SiS_Pr->CCRT1CRTC[5] = ((((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1) & 0x20) << 2) | + pSiS->SiS_Pr->CCRT1CRTC[5] = ((((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1) & 0x20) << 2) | (((pSiS->SiS_Pr->CHSyncEnd >> 3) + 3) & 0x1F); - + pSiS->SiS_Pr->CCRT1CRTC[6] = (pSiS->SiS_Pr->CVTotal - 2) & 0xFF; pSiS->SiS_Pr->CCRT1CRTC[7] = (((pSiS->SiS_Pr->CVTotal - 2) & 0x100) >> 8) | (((pSiS->SiS_Pr->CVDisplay - 1) & 0x100) >> 7) @@ -5513,71 +4365,76 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags) | (((pSiS->SiS_Pr->CVTotal - 2) & 0x200) >> 4) | (((pSiS->SiS_Pr->CVDisplay - 1) & 0x200) >> 3) | ((pSiS->SiS_Pr->CVSyncStart & 0x200) >> 2); - + pSiS->SiS_Pr->CCRT1CRTC[16] = ((((pSiS->SiS_Pr->CVBlankStart - 1) & 0x200) >> 4) >> 5); /* cr9 */ - -#if 0 + +#if 0 if (mode->VScan >= 32) regp->CRTC[9] |= 0x1F; else if (mode->VScan > 1) regp->CRTC[9] |= mode->VScan - 1; -#endif +#endif - pSiS->SiS_Pr->CCRT1CRTC[8] = (pSiS->SiS_Pr->CVSyncStart - 1) & 0xFF; /* cr10 */ - pSiS->SiS_Pr->CCRT1CRTC[9] = ((pSiS->SiS_Pr->CVSyncEnd - 1) & 0x0F) | 0x80; /* cr11 */ - pSiS->SiS_Pr->CCRT1CRTC[10] = (pSiS->SiS_Pr->CVDisplay - 1) & 0xFF; /* cr12 */ - pSiS->SiS_Pr->CCRT1CRTC[11] = (pSiS->SiS_Pr->CVBlankStart - 1) & 0xFF; /* cr15 */ - pSiS->SiS_Pr->CCRT1CRTC[12] = (pSiS->SiS_Pr->CVBlankEnd - 1) & 0xFF; /* cr16 */ - - pSiS->SiS_Pr->CCRT1CRTC[13] = + pSiS->SiS_Pr->CCRT1CRTC[8] = (pSiS->SiS_Pr->CVSyncStart ) & 0xFF; /* cr10 */ + pSiS->SiS_Pr->CCRT1CRTC[9] = ((pSiS->SiS_Pr->CVSyncEnd ) & 0x0F) | 0x80; /* cr11 */ + pSiS->SiS_Pr->CCRT1CRTC[10] = (pSiS->SiS_Pr->CVDisplay - 1) & 0xFF; /* cr12 */ + pSiS->SiS_Pr->CCRT1CRTC[11] = (pSiS->SiS_Pr->CVBlankStart - 1) & 0xFF; /* cr15 */ + pSiS->SiS_Pr->CCRT1CRTC[12] = (pSiS->SiS_Pr->CVBlankEnd - 1) & 0xFF; /* cr16 */ + + pSiS->SiS_Pr->CCRT1CRTC[13] = GETBITSTR((pSiS->SiS_Pr->CVTotal -2), 10:10, 0:0) | GETBITSTR((pSiS->SiS_Pr->CVDisplay -1), 10:10, 1:1) | GETBITSTR((pSiS->SiS_Pr->CVBlankStart-1), 10:10, 2:2) | GETBITSTR((pSiS->SiS_Pr->CVSyncStart ), 10:10, 3:3) | GETBITSTR((pSiS->SiS_Pr->CVBlankEnd -1), 8:8, 4:4) | - GETBITSTR((pSiS->SiS_Pr->CVSyncEnd -1), 4:4, 5:5) ; + GETBITSTR((pSiS->SiS_Pr->CVSyncEnd ), 4:4, 5:5) ; - pSiS->SiS_Pr->CCRT1CRTC[14] = + pSiS->SiS_Pr->CCRT1CRTC[14] = GETBITSTR((pSiS->SiS_Pr->CHTotal >> 3) - 5, 9:8, 1:0) | GETBITSTR((pSiS->SiS_Pr->CHDisplay >> 3) - 1, 9:8, 3:2) | GETBITSTR((pSiS->SiS_Pr->CHBlankStart >> 3) - 1, 9:8, 5:4) | GETBITSTR((pSiS->SiS_Pr->CHSyncStart >> 3) + 3, 9:8, 7:6) ; - + pSiS->SiS_Pr->CCRT1CRTC[15] = GETBITSTR((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1, 7:6, 1:0) | - GETBITSTR((pSiS->SiS_Pr->CHSyncEnd >> 3) + 3, 5:5, 2:2) ; - + GETBITSTR((pSiS->SiS_Pr->CHSyncEnd >> 3) + 3, 5:5, 2:2) ; + switch(depth) { - case 8: - pSiS->SiS_Pr->CModeFlag = 0x223b; + case 8: + pSiS->SiS_Pr->CModeFlag |= 0x223b; break; - case 16: - pSiS->SiS_Pr->CModeFlag = 0x227d; + case 16: + pSiS->SiS_Pr->CModeFlag |= 0x227d; break; - case 32: - pSiS->SiS_Pr->CModeFlag = 0x22ff; + case 32: + pSiS->SiS_Pr->CModeFlag |= 0x22ff; break; default: return 0; } if(pSiS->SiS_Pr->CFlags & V_DBLSCAN) - pSiS->SiS_Pr->CModeFlag |= DoubleScanMode; - if((pSiS->SiS_Pr->CVDisplay >= 1024) || - (pSiS->SiS_Pr->CVTotal >= 1024) || + pSiS->SiS_Pr->CModeFlag |= DoubleScanMode; + + if((pSiS->SiS_Pr->CVDisplay >= 1024) || + (pSiS->SiS_Pr->CVTotal >= 1024) || (pSiS->SiS_Pr->CHDisplay >= 1024)) - pSiS->SiS_Pr->CModeFlag |= LineCompareOff; + pSiS->SiS_Pr->CModeFlag |= LineCompareOff; + if(pSiS->SiS_Pr->CFlags & V_CLKDIV2) - pSiS->SiS_Pr->CModeFlag |= HalfDCLK; - + pSiS->SiS_Pr->CModeFlag |= HalfDCLK; + pSiS->SiS_Pr->CInfoFlag = 0x0007; - if(pSiS->SiS_Pr->CFlags & V_NHSYNC) - pSiS->SiS_Pr->CInfoFlag |= 0x4000; - if(pSiS->SiS_Pr->CFlags & V_NVSYNC) - pSiS->SiS_Pr->CInfoFlag |= 0x8000; - if(pSiS->SiS_Pr->CFlags & V_INTERLACE) - pSiS->SiS_Pr->CInfoFlag |= InterlaceMode; + + if(pSiS->SiS_Pr->CFlags & V_NHSYNC) + pSiS->SiS_Pr->CInfoFlag |= 0x4000; + + if(pSiS->SiS_Pr->CFlags & V_NVSYNC) + pSiS->SiS_Pr->CInfoFlag |= 0x8000; + + if(pSiS->SiS_Pr->CFlags & V_INTERLACE) + pSiS->SiS_Pr->CInfoFlag |= InterlaceMode; pSiS->SiS_Pr->UseCustomMode = TRUE; #ifdef TWDEBUG @@ -5608,13 +4465,13 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags) pSiS->SiS_Pr->CSR2B, pSiS->SiS_Pr->CSR2C, pSiS->SiS_Pr->CSRClock); -#endif +#endif return 1; } -/* TW: Build a list of supported modes */ +/* Build a list of supported modes */ DisplayModePtr -SiSBuildBuiltInModeList(ScrnInfoPtr pScrn) +SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfordvi) { SISPtr pSiS = SISPTR(pScrn); unsigned short VRE, VBE, VRS, VBS, VDE, VT; @@ -5622,23 +4479,28 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn) unsigned char sr_data, cr_data, cr_data2, cr_data3; unsigned char sr2b, sr2c; float num, denum, postscalar, divider; - int A, B, C, D, E, F, temp, i, j, index, vclkindex; - DisplayModePtr new = NULL, current = NULL, first = NULL, backup = NULL; + int A, B, C, D, E, F, temp, i, j, k, l, index, vclkindex; + DisplayModePtr new = NULL, current = NULL, first = NULL; + BOOLEAN done = FALSE; +#if 0 + DisplayModePtr backup = NULL; +#endif pSiS->backupmodelist = NULL; - + pSiS->AddedPlasmaModes = FALSE; + /* Initialize our pointers */ if(pSiS->VGAEngine == SIS_300_VGA) { #ifdef SIS300 - InitTo300Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); + InitTo300Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); #else - return NULL; + return NULL; #endif } else if(pSiS->VGAEngine == SIS_315_VGA) { #ifdef SIS315H - InitTo310Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); + InitTo310Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); #else - return NULL; + return NULL; #endif } else return NULL; @@ -5646,19 +4508,21 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn) while(pSiS->SiS_Pr->SiS_RefIndex[i].Ext_InfoFlag != 0xFFFF) { index = pSiS->SiS_Pr->SiS_RefIndex[i].Ext_CRT1CRTC; -#if 0 /* Not any longer */ - if(pSiS->VGAEngine == SIS_300_VGA) index &= 0x3F; -#endif - if(((pSiS->SiS_Pr->SiS_RefIndex[i].XRes < 512) && (!pSiS->DSTN)) || - ((pSiS->DSTN) && - (pSiS->SiS_Pr->SiS_RefIndex[i].XRes < 512) && - (pSiS->SiS_Pr->SiS_RefIndex[i].XRes != 320) && - (pSiS->SiS_Pr->SiS_RefIndex[i].YRes != 480))) { + /* 0x5a (320x240) is a pure FTSN mode, not DSTN! */ + if((!pSiS->FSTN) && + (pSiS->SiS_Pr->SiS_RefIndex[i].ModeID == 0x5a)) { i++; continue; } - + if((pSiS->FSTN) && + (pSiS->SiS_Pr->SiS_RefIndex[i].XRes == 320) && + (pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 240) && + (pSiS->SiS_Pr->SiS_RefIndex[i].ModeID != 0x5a)) { + i++; + continue; + } + if(!(new = xalloc(sizeof(DisplayModeRec)))) return first; memset(new, 0, sizeof(DisplayModeRec)); if(!(new->name = xalloc(10))) { @@ -5672,13 +4536,13 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn) } current = new; - + sprintf(current->name, "%dx%d", pSiS->SiS_Pr->SiS_RefIndex[i].XRes, pSiS->SiS_Pr->SiS_RefIndex[i].YRes); current->status = MODE_OK; - current->type = M_T_DEFAULT; + current->type = M_T_DEFAULT; vclkindex = pSiS->SiS_Pr->SiS_RefIndex[i].Ext_CRTVCLK; if(pSiS->VGAEngine == SIS_300_VGA) vclkindex &= 0x3F; @@ -5691,7 +4555,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn) ( (((sr2c >> 5) & 0x03) == 0x02) ? 6.0 : 8.0) : (((sr2c >> 5) & 0x03) + 1.0); num = (sr2b & 0x7f) + 1.0; denum = (sr2c & 0x1f) + 1.0; - + #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "------------\n"); xf86DrvMsg(0, X_INFO, "sr2b: %x sr2c %x div %f ps %f num %f denum %f\n", @@ -5759,10 +4623,29 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn) D = B - F - C; - current->HDisplay = (E * 8); - current->HSyncStart = (E * 8) + (F * 8); - current->HSyncEnd = (E * 8) + (F * 8) + (C * 8); - current->HTotal = (E * 8) + (F * 8) + (C * 8) + (D * 8); + if((pSiS->SiS_Pr->SiS_RefIndex[i].XRes == 320) && + ((pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 200) || + (pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 240))) { + + /* Terrible hack, but correct CRTC data for + * these modes only produces a black screen... + * (HRE is 0, leading into a too large C and + * a negative D. The CRT controller does not + * seem to like correcting HRE to 50 + */ + current->HDisplay = 320; + current->HSyncStart = 328; + current->HSyncEnd = 376; + current->HTotal = 400; + + } else { + + current->HDisplay = (E * 8); + current->HSyncStart = (E * 8) + (F * 8); + current->HSyncEnd = (E * 8) + (F * 8) + (C * 8); + current->HTotal = (E * 8) + (F * 8) + (C * 8) + (D * 8); + + } #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, @@ -5886,7 +4769,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn) current->VSyncStart <<= 1; current->VSyncEnd <<= 1; current->VTotal <<= 1; - current->VTotal |= 1; + current->VTotal |= 1; } if(current->Flags & V_DBLSCAN) { current->Clock >>= 1; @@ -5896,6 +4779,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn) current->VTotal >>= 1; } +#if 0 if((backup = xalloc(sizeof(DisplayModeRec)))) { if(!pSiS->backupmodelist) pSiS->backupmodelist = backup; else { @@ -5914,6 +4798,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn) backup->Flags = current->Flags; backup->Clock = current->Clock; } +#endif #ifdef TWDEBUG xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -5921,48 +4806,531 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn) current->name, (float)current->Clock / 1000, current->HDisplay, current->HSyncStart, current->HSyncEnd, current->HTotal, current->VDisplay, current->VSyncStart, current->VSyncEnd, current->VTotal); +#else + (void)VBS; (void)HBS; (void)A; #endif i++; } + /* Add non-standard LCD modes for panel's detailed timings */ + + if(!includelcdmodes) return first; + + if(pSiS->SiS_Pr->CP_Vendor) { + xf86DrvMsg(0, X_INFO, "Checking database for vendor %x, product %x\n", + pSiS->SiS_Pr->CP_Vendor, pSiS->SiS_Pr->CP_Product); + } + + i = 0; + while((!done) && (SiS_PlasmaTable[i].vendor) && (pSiS->SiS_Pr->CP_Vendor)) { + + if(SiS_PlasmaTable[i].vendor == pSiS->SiS_Pr->CP_Vendor) { + + for(j=0; j<SiS_PlasmaTable[i].productnum; j++) { + + if(SiS_PlasmaTable[i].product[j] == pSiS->SiS_Pr->CP_Product) { + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Identified %s panel, adding specific modes\n", + SiS_PlasmaTable[i].plasmaname); + + for(k=0; k<SiS_PlasmaTable[i].modenum; k++) { + + if(isfordvi) { + if(!(SiS_PlasmaTable[i].plasmamodes[k] & 0x80)) continue; + } else { + if(!(SiS_PlasmaTable[i].plasmamodes[k] & 0x40)) continue; + } + + if(!(new = xalloc(sizeof(DisplayModeRec)))) return first; + + memset(new, 0, sizeof(DisplayModeRec)); + if(!(new->name = xalloc(10))) { + xfree(new); + return first; + } + if(!first) first = new; + if(current) { + current->next = new; + new->prev = current; + } + + current = new; + + pSiS->AddedPlasmaModes = TRUE; + + l = SiS_PlasmaTable[i].plasmamodes[k] & 0x3f; + + sprintf(current->name, "%dx%d", SiS_PlasmaMode[l].HDisplay, + SiS_PlasmaMode[l].VDisplay); + + current->status = MODE_OK; + + current->type = M_T_BUILTIN; + + current->Clock = SiS_PlasmaMode[l].clock; + current->SynthClock = current->Clock; + + current->HDisplay = SiS_PlasmaMode[l].HDisplay; + current->HSyncStart = current->HDisplay + SiS_PlasmaMode[l].HFrontPorch; + current->HSyncEnd = current->HSyncStart + SiS_PlasmaMode[l].HSyncWidth; + current->HTotal = SiS_PlasmaMode[l].HTotal; + + current->VDisplay = SiS_PlasmaMode[l].VDisplay; + current->VSyncStart = current->VDisplay + SiS_PlasmaMode[l].VFrontPorch; + current->VSyncEnd = current->VSyncStart + SiS_PlasmaMode[l].VSyncWidth; + current->VTotal = SiS_PlasmaMode[l].VTotal; + + current->CrtcHDisplay = current->HDisplay; + current->CrtcHBlankStart = current->HSyncStart; + current->CrtcHSyncStart = current->HSyncStart; + current->CrtcHSyncEnd = current->HSyncEnd; + current->CrtcHBlankEnd = current->HSyncEnd; + current->CrtcHTotal = current->HTotal; + + current->CrtcVDisplay = current->VDisplay; + current->CrtcVBlankStart = current->VSyncStart; + current->CrtcVSyncStart = current->VSyncStart; + current->CrtcVSyncEnd = current->VSyncEnd; + current->CrtcVBlankEnd = current->VSyncEnd; + current->CrtcVTotal = current->VTotal; + + if(SiS_PlasmaMode[l].SyncFlags & SIS_PL_HSYNCP) + current->Flags |= V_PHSYNC; + else + current->Flags |= V_NHSYNC; + + if(SiS_PlasmaMode[l].SyncFlags & SIS_PL_VSYNCP) + current->Flags |= V_PVSYNC; + else + current->Flags |= V_NVSYNC; + + if(current->HDisplay > pSiS->LCDwidth) + pSiS->LCDwidth = pSiS->SiS_Pr->CP_MaxX = current->HDisplay; + if(current->VDisplay > pSiS->LCDheight) + pSiS->LCDheight = pSiS->SiS_Pr->CP_MaxY = current->VDisplay; + + } + done = TRUE; + break; + } + } + } + + i++; + + } + + if(pSiS->SiS_Pr->CP_HaveCustomData) { + + for(i=0; i<7; i++) { + + if(pSiS->SiS_Pr->CP_DataValid[i]) { + + if(!(new = xalloc(sizeof(DisplayModeRec)))) return first; + + memset(new, 0, sizeof(DisplayModeRec)); + if(!(new->name = xalloc(10))) { + xfree(new); + return first; + } + if(!first) first = new; + if(current) { + current->next = new; + new->prev = current; + } + + current = new; + + sprintf(current->name, "%dx%d", pSiS->SiS_Pr->CP_HDisplay[i], + pSiS->SiS_Pr->CP_VDisplay[i]); + + current->status = MODE_OK; + + current->type = M_T_BUILTIN; + + current->Clock = pSiS->SiS_Pr->CP_Clock[i]; + current->SynthClock = current->Clock; + + current->HDisplay = pSiS->SiS_Pr->CP_HDisplay[i]; + current->HSyncStart = pSiS->SiS_Pr->CP_HSyncStart[i]; + current->HSyncEnd = pSiS->SiS_Pr->CP_HSyncEnd[i]; + current->HTotal = pSiS->SiS_Pr->CP_HTotal[i]; + + current->VDisplay = pSiS->SiS_Pr->CP_VDisplay[i]; + current->VSyncStart = pSiS->SiS_Pr->CP_VSyncStart[i]; + current->VSyncEnd = pSiS->SiS_Pr->CP_VSyncEnd[i]; + current->VTotal = pSiS->SiS_Pr->CP_VTotal[i]; + + current->CrtcHDisplay = current->HDisplay; + current->CrtcHBlankStart = pSiS->SiS_Pr->CP_HBlankStart[i]; + current->CrtcHSyncStart = current->HSyncStart; + current->CrtcHSyncEnd = current->HSyncEnd; + current->CrtcHBlankEnd = pSiS->SiS_Pr->CP_HBlankEnd[i]; + current->CrtcHTotal = current->HTotal; + + current->CrtcVDisplay = current->VDisplay; + current->CrtcVBlankStart = pSiS->SiS_Pr->CP_VBlankStart[i]; + current->CrtcVSyncStart = current->VSyncStart; + current->CrtcVSyncEnd = current->VSyncEnd; + current->CrtcVBlankEnd = pSiS->SiS_Pr->CP_VBlankEnd[i]; + current->CrtcVTotal = current->VTotal; + + if(pSiS->SiS_Pr->CP_SyncValid[i]) { + if(pSiS->SiS_Pr->CP_HSync_P[i]) + current->Flags |= V_PHSYNC; + else + current->Flags |= V_NHSYNC; + + if(pSiS->SiS_Pr->CP_VSync_P[i]) + current->Flags |= V_PVSYNC; + else + current->Flags |= V_NVSYNC; + } else { + /* No sync data? Use positive sync... */ + current->Flags |= V_PHSYNC; + current->Flags |= V_PVSYNC; + } + } + } + } + return first; } -#define MODEID_OFF 0x449 +/* Build a list of supported modes */ +int +SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber) +{ + SISPtr pSiS = SISPTR(pScrn); + int i; -unsigned char -SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id) + /* Initialize our pointers */ + if(pSiS->VGAEngine == SIS_300_VGA) { +#ifdef SIS300 + InitTo300Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); +#else + return -1; +#endif + } else if(pSiS->VGAEngine == SIS_315_VGA) { +#ifdef SIS315H + InitTo310Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); +#else + return -1; +#endif + } else return -1; + + if(modenumber <= 0x13) return modenumber; + + i = 0; + while(pSiS->SiS_Pr->SiS_EModeIDTable[i].Ext_ModeID != 0xff) { + if(pSiS->SiS_Pr->SiS_EModeIDTable[i].Ext_ModeID == modenumber) { + return (int)pSiS->SiS_Pr->SiS_EModeIDTable[i].Ext_VESAID; + } + i++; + } + return -1; +} +#endif /* Xfree86 */ + +#ifdef LINUX_KERNEL +int +sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + unsigned char modeno, unsigned char rateindex) { - return(SiS_GetSetBIOSScratch(pScrn, MODEID_OFF, id)); + USHORT ModeNo = modeno; + USHORT ModeIdIndex = 0, ClockIndex = 0; + USHORT RefreshRateTableIndex = 0; + int Clock; + + if(HwInfo->jChipType < SIS_315H) { +#ifdef SIS300 + InitTo300Pointer(SiS_Pr, HwInfo); +#else + return 65 * 1000; +#endif + } else { +#ifdef SIS315H + InitTo310Pointer(SiS_Pr, HwInfo); +#else + return 65 * 1000; +#endif + } + + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) {; + printk(KERN_ERR "Could not find mode %x\n", ModeNo); + return 65 * 1000; + } + + RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; + RefreshRateTableIndex += (rateindex - 1); + ClockIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + if(HwInfo->jChipType < SIS_315H) { + ClockIndex &= 0x3F; + } + Clock = SiS_Pr->SiS_VCLKData[ClockIndex].CLOCK * 1000; + + return(Clock); } -unsigned char -SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, unsigned char value) +BOOLEAN +sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex) { - unsigned char ret; - unsigned char *base; - - base = xf86MapVidMem(pScrn->scrnIndex, VIDMEM_MMIO, 0, 0x2000); - if(!base) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "(init.c: Could not map BIOS scratch area)\n"); - return 0; + USHORT ModeNo = modeno; + USHORT ModeIdIndex = 0, CRT1Index = 0; + USHORT RefreshRateTableIndex = 0; + unsigned char sr_data, cr_data, cr_data2; + + if(HwInfo->jChipType < SIS_315H) { +#ifdef SIS300 + InitTo300Pointer(SiS_Pr, HwInfo); +#else + return FALSE; +#endif + } else { +#ifdef SIS315H + InitTo310Pointer(SiS_Pr, HwInfo); +#else + return FALSE; +#endif } - ret = *(base + offset); + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; + + RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; + RefreshRateTableIndex += (rateindex - 1); + CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; - /* value != 0xff means: set register */ - if (value != 0xff) - *(base + offset) = value; + sr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14]; + cr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[0]; + *htotal = (((cr_data & 0xff) | ((unsigned short) (sr_data & 0x03) << 8)) + 5) * 8; - xf86UnMapVidMem(pScrn->scrnIndex, base, 0x2000); + sr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]; + cr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[6]; + cr_data2 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7]; + *vtotal = ((cr_data & 0xFF) | + ((unsigned short)(cr_data2 & 0x01) << 8) | + ((unsigned short)(cr_data2 & 0x20) << 4) | + ((unsigned short)(sr_data & 0x01) << 10)) + 2; - return ret; + if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & InterlaceMode) + *vtotal *= 2; + + return TRUE; } +int +sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_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) +{ + USHORT ModeNo = modeno; + USHORT ModeIdIndex = 0, index = 0; + USHORT RefreshRateTableIndex = 0; + 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(HwInfo->jChipType < SIS_315H) { +#ifdef SIS300 + InitTo300Pointer(SiS_Pr, HwInfo); +#else + return 0; +#endif + } else { +#ifdef SIS315H + InitTo310Pointer(SiS_Pr, HwInfo); +#else + return 0; #endif + } + + 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; + + sr_data = SiS_Pr->SiS_CRT1Table[index].CR[14]; + cr_data = SiS_Pr->SiS_CRT1Table[index].CR[0]; + + /* Horizontal total */ + HT = (cr_data & 0xff) | + ((unsigned short) (sr_data & 0x03) << 8); + A = HT + 5; + + cr_data = SiS_Pr->SiS_CRT1Table[index].CR[1]; + + /* Horizontal display enable end */ + HDE = (cr_data & 0xff) | + ((unsigned short) (sr_data & 0x0C) << 6); + E = HDE + 1; + + cr_data = SiS_Pr->SiS_CRT1Table[index].CR[4]; + + /* Horizontal retrace (=sync) start */ + HRS = (cr_data & 0xff) | + ((unsigned short) (sr_data & 0xC0) << 2); + F = HRS - E - 3; + + cr_data = SiS_Pr->SiS_CRT1Table[index].CR[2]; + + /* Horizontal blank start */ + HBS = (cr_data & 0xff) | + ((unsigned short) (sr_data & 0x30) << 4); + + sr_data = SiS_Pr->SiS_CRT1Table[index].CR[15]; + + cr_data = SiS_Pr->SiS_CRT1Table[index].CR[3]; + + cr_data2 = SiS_Pr->SiS_CRT1Table[index].CR[5]; + + /* Horizontal blank end */ + HBE = (cr_data & 0x1f) | + ((unsigned short) (cr_data2 & 0x80) >> 2) | + ((unsigned short) (sr_data & 0x03) << 6); + /* Horizontal retrace (=sync) end */ + HRE = (cr_data2 & 0x1f) | ((sr_data & 0x04) << 3); + + temp = HBE - ((E - 1) & 255); + B = (temp > 0) ? temp : (temp + 256); + + temp = HRE - ((E + F + 3) & 63); + C = (temp > 0) ? temp : (temp + 64); + + D = B - F - C; + + if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes == 320) && + ((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 200) || + (SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 240))) { + + /* Terrible hack, but the correct CRTC data for + * these modes only produces a black screen... + */ + *left_margin = (400 - 376); + *right_margin = (328 - 320); + *hsync_len = (376 - 328); + + } else { + + *left_margin = D * 8; + *right_margin = F * 8; + *hsync_len = C * 8; + + } + + sr_data = SiS_Pr->SiS_CRT1Table[index].CR[13]; + + cr_data = SiS_Pr->SiS_CRT1Table[index].CR[6]; + + cr_data2 = SiS_Pr->SiS_CRT1Table[index].CR[7]; + + /* Vertical total */ + VT = (cr_data & 0xFF) | + ((unsigned short) (cr_data2 & 0x01) << 8) | + ((unsigned short)(cr_data2 & 0x20) << 4) | + ((unsigned short) (sr_data & 0x01) << 10); + A = VT + 2; + + cr_data = SiS_Pr->SiS_CRT1Table[index].CR[10]; + + /* Vertical display enable end */ + VDE = (cr_data & 0xff) | + ((unsigned short) (cr_data2 & 0x02) << 7) | + ((unsigned short) (cr_data2 & 0x40) << 3) | + ((unsigned short) (sr_data & 0x02) << 9); + E = VDE + 1; + + cr_data = SiS_Pr->SiS_CRT1Table[index].CR[8]; + + /* Vertical retrace (=sync) start */ + VRS = (cr_data & 0xff) | + ((unsigned short) (cr_data2 & 0x04) << 6) | + ((unsigned short) (cr_data2 & 0x80) << 2) | + ((unsigned short) (sr_data & 0x08) << 7); + F = VRS + 1 - E; + + cr_data = SiS_Pr->SiS_CRT1Table[index].CR[11]; + + cr_data3 = (SiS_Pr->SiS_CRT1Table[index].CR[16] & 0x01) << 5; + + /* Vertical blank start */ + VBS = (cr_data & 0xff) | + ((unsigned short) (cr_data2 & 0x08) << 5) | + ((unsigned short) (cr_data3 & 0x20) << 4) | + ((unsigned short) (sr_data & 0x04) << 8); + + cr_data = SiS_Pr->SiS_CRT1Table[index].CR[12]; + + /* Vertical blank end */ + VBE = (cr_data & 0xff) | + ((unsigned short) (sr_data & 0x10) << 4); + temp = VBE - ((E - 1) & 511); + B = (temp > 0) ? temp : (temp + 512); + + cr_data = SiS_Pr->SiS_CRT1Table[index].CR[9]; + + /* Vertical retrace (=sync) end */ + VRE = (cr_data & 0x0f) | ((sr_data & 0x20) >> 1); + temp = VRE - ((E + F - 1) & 31); + C = (temp > 0) ? temp : (temp + 32); + + D = B - F - C; + + *upper_margin = D; + *lower_margin = F; + *vsync_len = C; + + if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x8000) + *sync &= ~FB_SYNC_VERT_HIGH_ACT; + else + *sync |= FB_SYNC_VERT_HIGH_ACT; + + if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x4000) + *sync &= ~FB_SYNC_HOR_HIGH_ACT; + else + *sync |= FB_SYNC_HOR_HIGH_ACT; + + *vmode = FB_VMODE_NONINTERLACED; + if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x0080) + *vmode = FB_VMODE_INTERLACED; + else { + 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; + } + break; + } + j++; + } + } + + if((*vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { +#if 0 /* Do this? */ + *upper_margin <<= 1; + *lower_margin <<= 1; + *vsync_len <<= 1; +#endif + } else if((*vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { + *upper_margin >>= 1; + *lower_margin >>= 1; + *vsync_len >>= 1; + } + + return 1; +} + +#endif @@ -1,21 +1,47 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.h,v 1.5 2003/02/10 01:14:16 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.h,v 1.35 2003/11/20 19:53:21 twini Exp $ */ +/* + * Data and prototypes for init.c + * + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the linux kernel, the contents of this file + * is entirely covered by the GPL. + * + * Otherwise, the following 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. + * + * 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 <thomas@winischhofer.net> + * + * Based on code by Silicon Intergrated Systems + * + */ #ifndef _INIT_ #define _INIT_ #include "osdef.h" + #include "initdef.h" #include "vgatypes.h" #include "vstruct.h" -#ifdef TC -#include <stdio.h> -#include <string.h> -#include <conio.h> -#include <dos.h> -#include <stdlib.h> -#endif - #ifdef LINUX_XF86 #include "xf86.h" #include "xf86Pci.h" @@ -26,24 +52,54 @@ #endif #ifdef LINUX_KERNEL +#ifdef SIS_CP +#undef SIS_CP +#endif +#include <linux/config.h> +#include <linux/version.h> #include <linux/types.h> #include <asm/io.h> +#include <linux/fb.h> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #include <linux/sisfb.h> +#else +#include <video/sisfb.h> #endif - -#ifdef WIN2000 -#include <stdio.h> -#include <string.h> -#include <miniport.h> -#include "dderror.h" -#include "devioctl.h" -#include "miniport.h" -#include "ntddvdeo.h" -#include "video.h" -#include "sisv.h" -#include "tools.h" #endif +/* Mode numbers */ +const USHORT ModeIndex_320x200[] = {0x59, 0x41, 0x00, 0x4f}; +const USHORT ModeIndex_320x240[] = {0x50, 0x56, 0x00, 0x53}; +const USHORT ModeIndex_320x240_FSTN[] = {0x5a, 0x5b, 0x00, 0x00}; /* FSTN */ +const USHORT ModeIndex_400x300[] = {0x51, 0x57, 0x00, 0x54}; +const USHORT ModeIndex_512x384[] = {0x52, 0x58, 0x00, 0x5c}; +const USHORT ModeIndex_640x400[] = {0x2f, 0x5d, 0x00, 0x5e}; +const USHORT ModeIndex_640x480[] = {0x2e, 0x44, 0x00, 0x62}; +const USHORT ModeIndex_720x480[] = {0x31, 0x33, 0x00, 0x35}; +const USHORT ModeIndex_720x576[] = {0x32, 0x34, 0x00, 0x36}; +const USHORT ModeIndex_768x576[] = {0x5f, 0x60, 0x00, 0x61}; +const USHORT ModeIndex_800x480[] = {0x70, 0x7a, 0x00, 0x76}; +const USHORT ModeIndex_800x600[] = {0x30, 0x47, 0x00, 0x63}; +const USHORT ModeIndex_848x480[] = {0x39, 0x3b, 0x00, 0x3e}; +const USHORT ModeIndex_856x480[] = {0x3f, 0x42, 0x00, 0x45}; +const USHORT ModeIndex_1024x768[] = {0x38, 0x4a, 0x00, 0x64}; +const USHORT ModeIndex_1024x576[] = {0x71, 0x74, 0x00, 0x77}; +const USHORT ModeIndex_1024x600[] = {0x20, 0x21, 0x00, 0x22}; /* 300 series only */ +const USHORT ModeIndex_1280x1024[] = {0x3a, 0x4d, 0x00, 0x65}; +const USHORT ModeIndex_1280x960[] = {0x7c, 0x7d, 0x00, 0x7e}; +const USHORT ModeIndex_1152x768[] = {0x23, 0x24, 0x00, 0x25}; /* 300 series only */ +const USHORT ModeIndex_1152x864[] = {0x29, 0x2a, 0x00, 0x2b}; +const USHORT ModeIndex_300_1280x768[] = {0x55, 0x5a, 0x00, 0x5b}; +const USHORT ModeIndex_310_1280x768[] = {0x23, 0x24, 0x00, 0x25}; +const USHORT ModeIndex_1280x720[] = {0x79, 0x75, 0x00, 0x78}; +const USHORT ModeIndex_1360x768[] = {0x48, 0x4b, 0x00, 0x4e}; +const USHORT ModeIndex_300_1360x1024[]= {0x67, 0x6f, 0x00, 0x72}; /* 300 series, BARCO only */ +const USHORT ModeIndex_1400x1050[] = {0x26, 0x27, 0x00, 0x28}; /* 315 series only */ +const USHORT ModeIndex_1600x1200[] = {0x3c, 0x3d, 0x00, 0x66}; +const USHORT ModeIndex_1920x1440[] = {0x68, 0x69, 0x00, 0x6b}; +const USHORT ModeIndex_300_2048x1536[]= {0x6c, 0x6d, 0x00, 0x00}; +const USHORT ModeIndex_310_2048x1536[]= {0x6c, 0x6d, 0x00, 0x6e}; + const USHORT SiS_DRAMType[17][5]={ {0x0C,0x0A,0x02,0x40,0x39}, {0x0D,0x0A,0x01,0x40,0x48}, @@ -139,178 +195,2600 @@ const USHORT SiS_VGA_DAC[] = 0x0B,0x0C,0x0D,0x0F,0x10 }; -void SiS_SetReg1(USHORT, USHORT, USHORT); -void SiS_SetReg2(SiS_Private *, USHORT, USHORT, USHORT); -void SiS_SetReg3(USHORT, USHORT); -void SiS_SetReg4(USHORT, ULONG); -void SiS_SetReg5(USHORT, USHORT); -UCHAR SiS_GetReg1(USHORT, USHORT); -UCHAR SiS_GetReg2(USHORT); -ULONG SiS_GetReg3(USHORT); -USHORT SiS_GetReg4(USHORT); -void SiS_ClearDAC(SiS_Private *SiS_Pr, ULONG); -void SiS_SetMemoryClock(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetDRAMModeRegister(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -BOOLEAN SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo); -void SiS_IsLowResolution(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); - -#ifdef SIS300 -void SiS_SetDRAMSize_300(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -USHORT SiS_ChkBUSWidth_300(SiS_Private *SiS_Pr, ULONG FBAddress); +static const SiS_StResInfoStruct SiS_StResInfo[]= +{ + { 640,400}, + { 640,350}, + { 720,400}, + { 720,350}, + { 640,480} +}; + +static const SiS_ModeResInfoStruct SiS_ModeResInfo[] = +{ + { 320, 200, 8, 8}, /* 0x00 */ + { 320, 240, 8, 8}, /* 0x01 */ + { 320, 400, 8, 8}, /* 0x02 */ + { 400, 300, 8, 8}, /* 0x03 */ + { 512, 384, 8, 8}, /* 0x04 */ + { 640, 400, 8,16}, /* 0x05 */ + { 640, 480, 8,16}, /* 0x06 */ + { 800, 600, 8,16}, /* 0x07 */ + { 1024, 768, 8,16}, /* 0x08 */ + { 1280,1024, 8,16}, /* 0x09 */ + { 1600,1200, 8,16}, /* 0x0a */ + { 1920,1440, 8,16}, /* 0x0b */ + { 2048,1536, 8,16}, /* 0x0c */ + { 720, 480, 8,16}, /* 0x0d */ + { 720, 576, 8,16}, /* 0x0e */ + { 1280, 960, 8,16}, /* 0x0f */ + { 800, 480, 8,16}, /* 0x10 */ + { 1024, 576, 8,16}, /* 0x11 */ + { 1280, 720, 8,16}, /* 0x12 */ + { 856, 480, 8,16}, /* 0x13 */ + { 1280, 768, 8,16}, /* 0x14 */ + { 1400,1050, 8,16}, /* 0x15 */ + { 1152, 864, 8,16}, /* 0x16 */ + { 848, 480, 8,16}, /* 0x17 */ + { 1360, 768, 8,16}, /* 0x18 */ + { 1024, 600, 8,16}, /* 0x19 */ + { 1152, 768, 8,16}, /* 0x1a */ + { 768, 576, 8,16}, /* 0x1b */ + { 1360,1024, 8,16} /* 0x1c */ +}; + +static SiS_StandTableStruct SiS_StandTable[]= +{ +/* 0x00: MD_0_200 */ + { + 0x28,0x18,0x08,0x0800, + {0x09,0x03,0x00,0x02}, + 0x63, + {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x01: MD_1_200 */ + { + 0x28,0x18,0x08,0x0800, + {0x09,0x03,0x00,0x02}, + 0x63, + {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x02: MD_2_200 */ + { + 0x50,0x18,0x08,0x1000, + {0x01,0x03,0x00,0x02}, + 0x63, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x03: MD_3_200 - mode 0x03 - 0 */ + { + 0x50,0x18,0x08,0x1000, + {0x01,0x03,0x00,0x02}, + 0x63, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x04: MD_4 */ + { + 0x28,0x18,0x08,0x4000, + {0x09,0x03,0x00,0x02}, + 0x63, + {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, /* 0x2c is 2b for 300 */ + 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2, + 0xff}, + {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x01,0x00,0x03,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00, + 0xff} + }, +/* 0x05: MD_5 */ + { + 0x28,0x18,0x08,0x4000, + {0x09,0x03,0x00,0x02}, + 0x63, + {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, /* 0x2c is 2b for 300 */ + 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2, + 0xff}, + {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x01,0x00,0x03,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00, + 0xff} + }, +/* 0x06: MD_6 */ + { + 0x50,0x18,0x08,0x4000, + {0x01,0x01,0x00,0x06}, + 0x63, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, /* 55,81 is 54,80 for 300 */ + 0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2, + 0xff}, + {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17, + 0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17, + 0x01,0x00,0x01,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00, + 0xff} + }, +/* 0x07: MD_7 */ + { + 0x50,0x18,0x0e,0x1000, + {0x00,0x03,0x00,0x03}, + 0xa6, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, + 0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3, + 0xff}, + {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x0e,0x00,0x0f,0x08}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00, + 0xff} + }, +/* 0x08: MDA_DAC */ + { + 0x00,0x00,0x00,0x0000, + {0x00,0x00,0x00,0x15}, + 0x15, + {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, + 0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f, + 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00, + 0x00}, + {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15, + 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, + 0x15,0x15,0x15,0x15}, + {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, + 0x3f} + }, +/* 0x09: CGA_DAC */ + { + 0x00,0x10,0x04,0x0114, + {0x11,0x09,0x15,0x00}, + 0x10, + {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a, + 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a, + 0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10, + 0x04}, + {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04, + 0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e, + 0x3e,0x2b,0x3b,0x2f}, + {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f, + 0x3f} + }, +/* 0x0a: EGA_DAC */ + { + 0x00,0x10,0x04,0x0114, + {0x11,0x05,0x15,0x20}, + 0x30, + {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18, + 0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38, + 0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12, + 0x06}, + {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26, + 0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e, + 0x1e,0x0b,0x1b,0x0f}, + {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f, + 0x3f} + }, +/* 0x0b: VGA_DAC */ + { + 0x00,0x10,0x04,0x0114, + {0x11,0x09,0x15,0x2a}, + 0x3a, + {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05, + 0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20, + 0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10, + 0x1f}, + {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d, + 0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15, + 0x1c,0x0e,0x11,0x15}, + {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00, + 0x04} + }, +/* 0x0c */ + { + 0x08,0x0c,0x10,0x0a08, + {0x0c,0x0e,0x10,0x0b}, + 0x0c, + {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00, + 0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00, + 0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00, + 0x06}, + {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08, + 0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00} + }, +/* 0x0d: MD_D */ + { + 0x28,0x18,0x08,0x2000, + {0x09,0x0f,0x00,0x06}, + 0x63, + {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, /* 2c is 2b for 300 */ + 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x01,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, + 0xff} + }, +/* 0x0e: MD_E */ + { + 0x50,0x18,0x08,0x4000, + {0x01,0x0f,0x00,0x06}, + 0x63, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, /* 55,81 is 54,80 for 300 */ + 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, + 0x01,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, + 0xff} + }, +/* 0x0f: ExtVGATable - modes > 0x13 */ + { + 0x00,0x00,0x00,0x0000, + {0x01,0x0f,0x00,0x0e}, + 0x23, + {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, + 0x01,0x00,0x00,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, + 0xff} + }, +/* 0x10: ROM_SAVEPTR - totally different for 300 */ + { + 0x9f,0x3b,0x00,0x00c0, + {0x00,0x00,0x00,0x00}, + 0x00, + {0x00,0x00,0x00,0x00,0x00,0x00,0xbb,0x3f, + 0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x1a,0x00,0xac,0x3e,0x00,0xc0, + 0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00} + }, +/* 0x11: MD_F */ + { + 0x50,0x18,0x0e,0x8000, + {0x01,0x0f,0x00,0x06}, + 0xa2, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, /* 55,81 is 54,80 on 300 */ + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3, /* 82,84 is 83,85 on 300 */ + 0xff}, + {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00, + 0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00, + 0x0b,0x00,0x05,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05, + 0xff} + }, +/* 0x12: MD_10 */ + { + 0x50,0x18,0x0e,0x8000, + {0x01,0x0f,0x00,0x06}, + 0xa3, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, /* 55,81 is 54,80 on 300 */ + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3, /* 82,84 is 83,85 on 300 */ + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x01,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, + 0xff} + }, +/* 0x13: MD_0_350 */ + { + 0x28,0x18,0x0e,0x0800, + {0x09,0x03,0x00,0x02}, + 0xa3, + {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f, /* b1 is a0 on 300 */ + 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, + 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x14: MD_1_350 */ + { + 0x28,0x18,0x0e,0x0800, + {0x09,0x03,0x00,0x02}, + 0xa3, + {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, + 0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x15: MD_2_350 */ + { + 0x50,0x18,0x0e,0x1000, + {0x01,0x03,0x00,0x02}, + 0xa3, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, + 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x16: MD_3_350 - mode 0x03 - 1 */ + { + 0x50,0x18,0x0e,0x1000, + {0x01,0x03,0x00,0x02}, + 0xa3, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00, + 0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x08,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x17: MD_0_1_400 */ + { + 0x28,0x18,0x10,0x0800, + {0x08,0x03,0x00,0x02}, + 0x67, + {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f, /* b1 is a0 on 300 */ + 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x0c,0x00,0x0f,0x08}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x18: MD_2_3_400 - mode 0x03 - 2 */ + { + 0x50,0x18,0x10,0x1000, + {0x00,0x03,0x00,0x02}, + 0x67, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x0c,0x00,0x0f,0x08}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, +/* 0x19: MD_7_400 */ + { + 0x50,0x18,0x10,0x1000, + {0x00,0x03,0x00,0x02}, + 0x66, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x0e,0x00,0x0f,0x08}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00, + 0xff} + }, +/* 0x1a: MD_11 */ + { + 0x50,0x1d,0x10,0xa000, + {0x01,0x0f,0x00,0x06}, + 0xe3, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, /* 55,81 is 54,80 on 300 */ + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xc3, /* e9,8b is ea,8c on 300 */ + 0xff}, + {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, + 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, + 0x01,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01, + 0xff} + }, +/* 0x1b: ExtEGATable - Modes <= 0x02 */ + { + 0x50,0x1d,0x10,0xa000, + {0x01,0x0f,0x00,0x06}, + 0xe3, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, /* 55,81 is 54,80 on 300 */ + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xe3, /* e9,8b is ea,8c on 300 */ + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x01,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, + 0xff} + }, +/* 0x1c: MD_13 */ + { + 0x28,0x18,0x08,0x2000, + {0x01,0x0f,0x00,0x0e}, + 0x63, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, /* 55,81 is 54,80 on 300 */ + 0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, + 0x41,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, + 0xff} + } +}; + +/**************************************************************/ +/* SIS VIDEO BRIDGE ----------------------------------------- */ +/**************************************************************/ + +static const UCHAR SiS_SoftSetting = 0x30; /* RAM setting */ + +static const UCHAR SiS_OutputSelect = 0x40; + +static const UCHAR SiS_NTSCTiming[] = { + 0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c, + 0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a, + 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b, + 0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17, + 0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02, + 0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50, + 0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00 +}; + +static const UCHAR SiS_PALTiming[] = { + 0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70, + 0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d, + 0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b, + 0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17, + 0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02, + 0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63, + 0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00 +}; + +static const UCHAR SiS_HiTVExtTiming[] = { + 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, + 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, + 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, + 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, + 0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40, + 0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d, + 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 +}; + +static const UCHAR SiS_HiTVSt1Timing[] = { + 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, + 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, + 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, + 0x65,0x90,0x7b,0xa8,0x03,0xf0,0x87,0x03, + 0x11,0x15,0x11,0xcf,0x10,0x11,0xcf,0x10, + 0x35,0x35,0x3b,0x69,0x1d,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x86, + 0xaf,0x5d,0x0e,0x00,0xfc,0xff,0x2d,0x00 +}; + +static const UCHAR SiS_HiTVSt2Timing[] = { + 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, + 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, + 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, + 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, + 0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40, + 0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d, + 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 +}; + +static const UCHAR SiS_HiTVTextTiming[] = { + 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, + 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, + 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, + 0x65,0x90,0xe7,0xbc,0x03,0x0c,0x97,0x03, + 0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20, + 0xc8,0xc8,0x3b,0xd2,0x26,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96, + 0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00 +}; + +static const UCHAR SiS_HiTVGroup3Data[] = { + 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f, + 0x05,0x21,0xb2,0xb2,0x55,0x77,0x2a,0xa6, + 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, + 0x8c,0x6e,0x60,0x2e,0x58,0x48,0x72,0x44, + 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, + 0x4f,0x7f,0x03,0xa8,0x7d,0x20,0x1a,0xa9, + 0x14,0x05,0x03,0x7e,0x64,0x31,0x14,0x75, + 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 +}; + +static const UCHAR SiS_HiTVGroup3Simu[] = { + 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95, + 0xdb,0x20,0xb8,0xb8,0x55,0x47,0x2a,0xa6, + 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, + 0x8c,0x6e,0x60,0x15,0x26,0xd3,0xe4,0x11, + 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, + 0x67,0x36,0x01,0x47,0x0e,0x10,0xbe,0xb4, + 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, + 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 +}; + +static const UCHAR SiS_HiTVGroup3Text[] = { + 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7, + 0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6, + 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, + 0x8c,0x6e,0x60,0x18,0x2c,0x0c,0x20,0x22, + 0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80, + 0x93,0x3c,0x01,0x50,0x2f,0x10,0xf4,0xca, + 0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75, + 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 +}; + +static const UCHAR SiS_NTSCPhase[] = {0x21,0xed,0xba,0x08}; +static const UCHAR SiS_PALPhase[] = {0x2a,0x05,0xe3,0x00}; +static const UCHAR SiS_PALMPhase[] = {0x21,0xE4,0x2E,0x9B}; +static const UCHAR SiS_PALNPhase[] = {0x21,0xF4,0x3E,0xBA}; +static const UCHAR SiS_NTSCPhase2[] = {0x21,0xF0,0x7B,0xD6}; +static const UCHAR SiS_PALPhase2[] = {0x2a,0x09,0x86,0xe9}; +static const UCHAR SiS_PALMPhase2[] = {0x21,0xE6,0xEF,0xA4}; +static const UCHAR SiS_PALNPhase2[] = {0x21,0xF6,0x94,0x46}; +static const UCHAR SiS_SpecialPhase[] = {0x1e,0x8c,0x5c,0x7a}; +static const UCHAR SiS_SpecialPhaseM[]= {0x1e,0x83,0x0a,0xe0}; +static const UCHAR SiS_SpecialPhaseJ[]= {0x25,0xd4,0xfd,0x5e}; + +static const SiS_TVDataStruct SiS_StPALData[]= +{ + { 1, 1, 864, 525,1270, 400, 100, 0, 760,0xf4,0xff,0x1c,0x22}, + { 1, 1, 864, 525,1270, 350, 100, 0, 760,0xf4,0xff,0x1c,0x22}, + { 1, 1, 864, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, + { 1, 1, 864, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, + { 1, 1, 864, 525,1270, 480, 50, 0, 760,0xf4,0xff,0x1c,0x22}, + { 1, 1, 864, 525,1270, 600, 50, 0, 0,0xf4,0xff,0x1c,0x22} +}; + +static const SiS_TVDataStruct SiS_ExtPALData[] = +{ + { 27, 10, 848, 448,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, /* 640x400, 320x200 */ + { 108, 35, 848, 398,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, + { 12, 5, 954, 448,1270, 530, 50, 0, 50,0xf1,0x04,0x1f,0x18}, + { 9, 4, 960, 463,1644, 438, 50, 0, 50,0xf4,0x0b,0x1c,0x0a}, + { 9, 4, 848, 528,1270, 530, 0, 0, 50,0xf5,0xfb,0x1b,0x2a}, /* 640x480, 320x240 */ +/*{ 36, 25,1060, 648,1316, 530, 438, 0, 438,0xeb,0x05,0x25,0x16},*//* 800x600, 400x300 */ + { 36, 25,1060, 648,1270, 530, 438, 0, 438,0xeb,0x05,0x25,0x16}, /* 800x600, 400x300 - better */ + { 3, 2,1080, 619,1270, 540, 438, 0, 438,0xf3,0x00,0x1d,0x20}, /* 720x576 */ + { 1, 1,1170, 821,1270, 520, 686, 0, 686,0xF3,0x00,0x1D,0x20} /* 1024x768 */ +}; + +static const SiS_TVDataStruct SiS_StNTSCData[]= +{ + { 1, 1, 858, 525,1270, 400, 50, 0, 760,0xf1,0x04,0x1f,0x18}, + { 1, 1, 858, 525,1270, 350, 50, 0, 640,0xf1,0x04,0x1f,0x18}, + { 1, 1, 858, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, + { 1, 1, 858, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, + { 1, 1, 858, 525,1270, 480, 0, 0, 760,0xf1,0x04,0x1f,0x18} +}; + +static const SiS_TVDataStruct SiS_ExtNTSCData[]= +{ + { 143, 65, 858, 443,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, /* 640x400, 320x200 */ + { 88, 35, 858, 393,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, + { 143, 70, 924, 443,1270, 440, 92, 0, 92,0xf1,0x04,0x1f,0x18}, + { 143, 70, 924, 393,1270, 440, 92, 0, 92,0xf4,0x0b,0x1c,0x0a}, + { 143, 76, 836, 523,1270, 440, 224, 0, 0,0xf1,0x05,0x1f,0x16}, /* 640x480, 320x240 */ + { 143, 120,1056, 643,1270, 440, 0, 128, 0,0xf4,0x10,0x1c,0x00}, /* 800x600, 400x300 */ + { 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 */ +}; + +static const SiS_TVDataStruct SiS_St2HiTVData[]= +{ + { 3, 1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 3, 1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, + { 1, 1, 0x3e8,0x233,0x311,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, + { 5, 2, 0x348,0x233,0x670,0x3c0,0x08d,128, 0, 0x00,0x00,0x00,0x00}, + { 8, 5, 0x41a,0x2ab,0x670,0x3c0,0x17c,128, 0, 0x00,0x00,0x00,0x00} +}; + +static const 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}, + { 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 */ + { 5, 2, 0x578,0x293,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, /* 1024x576 */ + { 8, 5, 0x6d6,0x323,0x670,0x3c0,0x128, 0, 0, 0x00,0x00,0x00,0x00} /* 1280x720 */ +}; + +static const SiS_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} +}; + +static const SiS_LCDDataStruct SiS_StLCD1400x1050Data[] = +{ + { 211, 100, 2100, 408, 1688, 1066 }, + { 211, 64, 1536, 358, 1688, 1066 }, + { 211, 100, 2100, 408, 1688, 1066 }, + { 211, 64, 1536, 358, 1688, 1066 }, + { 211, 48, 840, 488, 1688, 1066 }, + { 211, 72, 1008, 609, 1688, 1066 }, + { 211, 128, 1400, 776, 1688, 1066 }, + { 211, 205, 1680, 1041, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 } +}; + +static const SiS_LCDDataStruct SiS_ExtLCD1400x1050Data[] = +{ + { 211, 100, 2100, 408, 1688, 1066 }, + { 211, 64, 1536, 358, 1688, 1066 }, + { 211, 100, 2100, 408, 1688, 1066 }, + { 211, 64, 1536, 358, 1688, 1066 }, + { 211, 48, 840, 488, 1688, 1066 }, + { 211, 72, 1008, 609, 1688, 1066 }, + { 211, 128, 1400, 776, 1688, 1066 }, + { 211, 205, 1680, 1041, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 } +}; + +static const SiS_LCDDataStruct SiS_NoScaleData1400x1050[] = +{ + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 }, + { 1, 1, 1688, 1066, 1688, 1066 } +}; + +static const SiS_LCDDataStruct SiS_StLCD1600x1200Data[] = +{ + {27, 4, 800, 500, 2160, 1250 }, + {27, 4, 800, 500, 2160, 1250 }, + { 6, 1, 900, 500, 2160, 1250 }, + { 6, 1, 900, 500, 2160, 1250 }, + {27, 1, 800, 500, 2160, 1250 }, + { 4, 1,1080, 625, 2160, 1250 }, + { 5, 2,1350, 800, 2160, 1250 }, + {135,88,1600,1100, 2160, 1250 }, + {135,88,1600,1100, 2160, 1250 }, + { 1, 1,2160,1250, 2160, 1250 } +}; + +static const SiS_LCDDataStruct SiS_ExtLCD1600x1200Data[] = +{ + {27, 4, 800, 500, 2160, 1250 }, + {27, 4, 800, 500, 2160, 1250 }, + { 6, 1, 900, 500, 2160, 1250 }, + { 6, 1, 900, 500, 2160, 1250 }, + {27, 1, 800, 500, 2160, 1250 }, + { 4, 1,1080, 625, 2160, 1250 }, + { 5, 2,1350, 800, 2160, 1250 }, + {27,16,1500,1064, 2160, 1250 }, + {27,16,1500,1064, 2160, 1250 }, + { 1, 1,2160,1250, 2160, 1250 } +}; + +static const SiS_LCDDataStruct SiS_NoScaleData1600x1200[] = +{ + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, + {1, 1, 2160, 1250, 2048, 1250}, +}; + +static const SiS_LCDDataStruct SiS_NoScaleData[] = +{ + { 1, 1, 800, 449, 800, 449 }, + { 1, 1, 800, 449, 800, 449 }, + { 1, 1, 900, 449, 900, 449 }, + { 1, 1, 900, 449, 900, 449 }, + { 1, 1, 800, 525, 800, 525 }, + { 1, 1,1056, 628,1056, 628 }, + { 1, 1,1344, 806,1344, 806 }, + { 1, 1,1688,1066,1688,1066 }, + { 1, 1,1688, 802,1688, 802 }, /* 1280x768: 802 was 806 in both cases */ + { 1, 1,2160,1250,2160,1250 }, /* 1600x1200 */ + { 1, 1,1800,1000,1800,1000 } /* 1280x960 */ +}; + +/* *** LCDA *** */ + +static const SiS_LVDSDataStruct SiS_LCDA1024x768Data_1[]= +{ + { 960, 438,1344, 806}, + { 960, 388,1344, 806}, + { 1040, 438,1344, 806}, + { 1040, 388,1344, 806}, + { 960, 518,1344, 806}, /* 640x480 */ + { 1120, 638,1344, 806}, /* 800x600 */ + { 1344, 806,1344, 806}, /* 1024x768 */ +#if 0 + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 518,1344, 806}, /* 640x480 */ + {1050, 638,1344, 806}, /* 800x600 */ + {1344, 806,1344, 806}, /* 1024x768 */ #endif +}; -#ifdef SIS315H -UCHAR SiS_Get310DRAMType(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_DDR_MRS(SiS_Private *SiS_Pr); -void SiS_SDR_MRS(SiS_Private *SiS_Pr); -void SiS_DisableRefresh(SiS_Private *SiS_Pr); -void SiS_EnableRefresh(SiS_Private *SiS_Pr, UCHAR *ROMAddr); -void SiS_SetDRAMSize_310(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO); -void SiS_DisableChannelInterleaving(SiS_Private *SiS_Pr, int index,USHORT SiS_DDRDRAM_TYPE[][5]); -void SiS_SetDRAMSizingType(SiS_Private *SiS_Pr, int index,USHORT DRAMTYPE_TABLE[][5]); -void SiS_CheckBusWidth_310(SiS_Private *SiS_Pr, UCHAR *ROMAddress,ULONG FBAddress, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -int SiS_SetRank(SiS_Private *SiS_Pr, int index,UCHAR RankNo,USHORT DRAMTYPE_TABLE[][5]); -int SiS_SetDDRChannel(SiS_Private *SiS_Pr, int index,UCHAR ChannelNo, - USHORT DRAMTYPE_TABLE[][5]); -int SiS_CheckColumn(SiS_Private *SiS_Pr, int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress); -int SiS_CheckBanks(SiS_Private *SiS_Pr, int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress); -int SiS_CheckRank(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress); -int SiS_CheckDDRRank(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress); -int SiS_CheckRanks(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress); -int SiS_CheckDDRRanks(SiS_Private *SiS_Pr, int RankNo,int index,USHORT DRAMTYPE_TABLE[][5],ULONG FBAddress); -int SiS_SDRSizing(SiS_Private *SiS_Pr, ULONG FBAddress); -int SiS_DDRSizing(SiS_Private *SiS_Pr, ULONG FBAddress); -int Is315E(SiS_Private *SiS_Pr); -void SiS_VerifyMclk(SiS_Private *SiS_Pr, ULONG FBAddr); +static const SiS_LVDSDataStruct SiS_LCDA1024x768Data_2[]= +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, +}; + +static const SiS_LVDSDataStruct SiS_LCDA1280x1024Data_1[]= +{ /* Acer, Compaq */ + {1048, 442,1688,1066}, + {1048, 392,1688,1066}, + {1128, 442,1688,1066}, + {1128, 392,1688,1066}, + {1048, 522,1688,1066}, + {1208, 642,1688,1066}, + {1432, 810,1688,1066}, + {1688,1066,1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LCDA1280x1024Data_2[]= +{ /* Corrected (illegal in Acer, correct in Compaq) */ + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LCDA1400x1050Data_1[]= +{ /* Clevo */ + { 928, 416, 1688,1066}, + { 928, 366, 1688,1066}, + {1008, 416, 1688,1066}, + {1008, 366, 1688,1066}, + {1200, 530, 1688,1066}, + {1088, 616, 1688,1066}, + {1312, 784, 1688,1066}, + {1568,1040, 1688,1066}, + {1688,1066, 1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LCDA1400x1050Data_2[]= +{ /* Clevo */ + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LCDA1600x1200Data_1[]= +{ /* Clevo (Temporary data) */ + {1200, 450, 2048,1250}, + {1200, 400, 2048,1250}, + {1280, 450, 2048,1250}, + {1280, 400, 2048,1250}, + {1200, 530, 2048,1250}, + {1360, 650, 2048,1250}, + {1584, 818, 2048,1250}, + {1688,1066, 2048,1250}, + {1688,1066, 2048,1250}, + {2048,1250, 2048,1250} /* this should be correct */ +#if 0 + {2160,1250, 2048,1250} /* ? */ #endif +}; + +static const SiS_LVDSDataStruct SiS_LCDA1600x1200Data_2[]= +{ /* Clevo (Temporary data. Seems invalid.) */ + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250}, + {2160,1250, 2160,1250} +}; + +/* LVDS SKEW for LCDA */ + +static const SiS_LVDSDesStruct SiS_PanelType1076_1[]= +{ /* 1024x768 */ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, /* 805; was 0, 0 -> top line cut away (26/09/03) */ +}; + +static const SiS_LVDSDesStruct SiS_PanelType1076_2[]= +{ /* 1024x768; not expanded */ + { 1184, 622 }, + { 1184, 597 }, + { 1184, 622 }, + { 1184, 597 }, + { 1152, 650 }, /* 622 */ + { 1232, 722 }, + { 0, 0 }, /* 805; was 0, 0 -> top line cut away (26/09/03) */ +}; + +static const SiS_LVDSDesStruct SiS_PanelType1210_1[]= +{ /* 1280x1024 */ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 1065}, /* Acer */ + { 0 , 0} +}; + +static const SiS_LVDSDesStruct SiS_PanelType1210_2[]= +{ /* 1280x1024; not expanded */ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0} +}; + +static const SiS_LVDSDesStruct SiS_PanelType1296_1[]= +{ /* 1400x1050 */ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 1065} /* Was 0,0 */ +}; + +static const SiS_LVDSDesStruct SiS_PanelType1296_2[]= +{ /* 1400x1050; not expanded */ + { 1308, 741 }, + { 1308, 716 }, + { 1308, 741 }, + { 1308, 716 }, + { 1308, 781 }, + { 1388, 841 }, + { 1500, 925 }, + { 1628,1053 }, + { 0,1065 } +#if 0 + { 808 , 740}, + { 0 , 715}, + { 632 , 740}, + { 632 , 715}, + { 1307, 780}, + { 1387,1157}, + { 1499, 924}, + { 1627,1052}, + { 0 , 0} +#endif +}; + +static const SiS_LVDSDesStruct SiS_PanelType1600_1[]= +{ /* 1600x1200 */ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0} +}; + +static const SiS_LVDSDesStruct SiS_PanelType1600_2[]= +{ /* 1600x1200; not expanded */ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0} +}; -void SiS_HandleCRT1(SiS_Private *SiS_Pr); -void SiS_Handle301B_1400x1050(SiS_Private *SiS_Pr, USHORT ModeNo); -void SiS_SetEnableDstn(SiS_Private *SiS_Pr); -void SiS_Delay15us(SiS_Private *SiS_Pr); -BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo,USHORT *ModeIdIndex); -BOOLEAN SiS_CheckMemorySize(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT ModeIdIndex); -UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex); -void SiS_SetSeqRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex); -void SiS_SetMiscRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex); -void SiS_SetCRTCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT StandTableIndex); -void SiS_SetATTRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetGRCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex); -void SiS_ClearExt1Regs(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetSync(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT RefreshRateTableIndex); -void SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -BOOLEAN SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *ResInfo,USHORT *DisplayType); -void SiS_ResetCRT1VCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCRT1VCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO, - USHORT RefreshRateTableIndex); -void SiS_SetVCLKState(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO, USHORT ModeNo, - USHORT RefreshRateTableIndex, USHORT ModeIdIndex); -void SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -void SiS_WriteDAC(SiS_Private *SiS_Pr, USHORT, USHORT, USHORT, USHORT, USHORT, USHORT); -void SiS_DisplayOn(SiS_Private *SiS_Pr); -void SiS_DisplayOff(SiS_Private *SiS_Pr); -void SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO,USHORT ModeNo, - USHORT ModeIdIndex,USHORT RefreshRateTableIndex); -void SiS_GetVBType(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO); -USHORT SiS_ChkBUSWidth(SiS_Private *SiS_Pr, UCHAR *ROMAddr); -USHORT SiS_GetModeIDLength(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT); -USHORT SiS_GetRefindexLength(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT); -void SiS_SetInterlace(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT RefreshRateTableIndex); -void SiS_Set_LVDS_TRUMPION(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCRT1Offset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT,USHORT,USHORT,PSIS_HW_DEVICE_INFO); #ifdef SIS315H -void SiS_SetCRT1FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT,USHORT,PSIS_HW_DEVICE_INFO); + +/* LCDA CRT1 custom data */ + +static const SiS_LCDACRT1DataStruct Compaq1280x1024_LCDACRT1_1[]= +{ + {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0x86,0x1f, + 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0x86,0x1f, + 0x5e,0x82,0x5d,0x5d,0x87,0x10,0x00,0x06, + 0x00}}, + {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0x08,0x3e, + 0xe0,0x84,0xdf,0xdf,0x09,0x00,0x00,0x06, + 0x00}}, + {{0x92,0x63,0x63,0x96,0x6c,0x1a,0x80,0xf0, + 0x58,0x8c,0x57,0x57,0x81,0x20,0x00,0x06, + 0x01}}, + {{0xae,0x7f,0x7f,0x92,0x88,0x96,0x28,0xf5, + 0x00,0x84,0xff,0xff,0x29,0x10,0x00,0x02, + 0x01}}, + {{0xce,0x9f,0x9f,0x92,0xa8,0x16,0x28,0x5a, + 0x00,0x84,0xff,0xff,0x29,0x01,0x00,0x07, + 0x01}} +}; + +static const SiS_LCDACRT1DataStruct Compaq1280x1024_LCDACRT1_1_H[]= +{ + {{0x56,0x27,0x27,0x9a,0x30,0x1e,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x3c,0x4f,0x4f,0x82,0x58,0x06,0x86,0xd1, + 0xbc,0x80,0xbb,0xbb,0xe5,0x00,0x00,0x06, + 0x01}}, + {{0x56,0x27,0x27,0x9a,0x30,0x1e,0xb8,0x1f, + 0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x3c,0x4f,0x4f,0x82,0x58,0x06,0x86,0xd1, + 0xbc,0x80,0xbb,0xbb,0xe5,0x00,0x00,0x06, + 0x01}}, + {{0x56,0x27,0x27,0x9a,0x30,0x1e,0x08,0x3e, + 0xe0,0x84,0xdf,0xdf,0x09,0x00,0x00,0x05, + 0x00}}, + {{0x60,0x31,0x31,0x84,0x3a,0x88,0x80,0xf0, + 0x58,0x8c,0x57,0x57,0x81,0x20,0x00,0x01, + 0x01}}, + {{0x6e,0x3f,0x3f,0x92,0x48,0x96,0x28,0xf5, + 0x00,0x84,0xff,0xff,0x29,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS_LCDACRT1DataStruct Clevo1024x768_LCDACRT1_1[]= +{ + {{0x73,0x4f,0x4f,0x97,0x55,0x86,0xc4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x55,0x86,0x97,0x1f, + 0x60,0x87,0x5d,0x5d,0x83,0x10,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x55,0x86,0xc4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x55,0x86,0x97,0x1f, + 0x60,0x87,0x5d,0x5d,0x83,0x10,0x00,0x05, + 0x00}}, + {{0x73,0x4f,0x4f,0x97,0x55,0x86,0x04,0x3e, + 0xE2,0x89,0xDf,0xDf,0x05,0x00,0x00,0x05, + 0x00}}, + {{0x87,0x63,0x63,0x8B,0x69,0x1A,0x7c,0xf0, + 0x5A,0x8F,0x57,0x57,0x7D,0x20,0x00,0x26, + 0x01}}, + {{0xA3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xFf,0xFf,0x25,0x10,0x00,0x02, + 0x01}} +}; + +static const SiS_LCDACRT1DataStruct Clevo1024x768_LCDACRT1_1_H[]= +{ + {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0xc4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0x97,0x1f, + 0x60,0x87,0x5D,0x5D,0x83,0x01,0x00,0x44, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0xc4,0x1f, + 0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0x97,0x1f, + 0x60,0x87,0x5D,0x5D,0x83,0x01,0x00,0x44, + 0x00}}, + {{0x4b,0x27,0x27,0x8f,0x32,0x1b,0x04,0x3e, + 0xE2,0x89,0xDf,0xDf,0x05,0x00,0x00,0x45, + 0x00}}, + {{0x55,0x31,0x31,0x99,0x46,0x1d,0x7c,0xf0, + 0x5A,0x8F,0x57,0x57,0x7D,0x20,0x00,0x55, + 0x01}}, + {{0x63,0x3F,0x3F,0x87,0x4A,0x93,0x24,0xF5, + 0x02,0x88,0xFF,0xFF,0x25,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS_LCDACRT1DataStruct Clevo1024x768_LCDACRT1_2[]= +{ + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x72,0x88,0xdf,0xdf,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x63,0x63,0x87,0x78,0x89,0x24,0xf1, + 0xae,0x84,0x57,0x57,0x25,0x30,0x00,0x02, + 0x01}}, + {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, + 0x01}} +}; + +static const SiS_LCDACRT1DataStruct Clevo1024x768_LCDACRT1_2_H[]= +{ + {{0x7b,0x27,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x57,0x8e,0x8f,0x8f,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x3e,0x85,0x5d,0x5d,0x25,0x10,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x57,0x8e,0x8f,0x8f,0x25,0x30,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x3e,0x85,0x5d,0x5d,0x25,0x10,0x00,0x01, + 0x00 }}, + {{0x7b,0x27,0x27,0x9f,0x46,0x97,0x24,0xbb, + 0x7f,0x86,0xdf,0xdf,0x25,0x10,0x00,0x01, + 0x00 }}, + {{0x71,0x31,0x31,0x95,0x46,0x97,0x24,0xf1, + 0xbb,0x82,0x57,0x57,0x25,0x10,0x00,0x01, + 0x01 }}, + {{0x63,0x3f,0x3f,0x87,0x46,0x97,0x24,0xf5, + 0x0f,0x86,0xff,0xff,0x25,0x30,0x00,0x01, + 0x01 }} +}; + +#endif /* 315 */ + +/**************************************************************/ +/* LVDS ----------------------------------------------------- */ +/**************************************************************/ + +static const SiS_LVDSDataStruct SiS_LVDS320x480Data_1[]= +{ + { 848, 433, 400, 525}, + { 848, 389, 400, 525}, + { 848, 433, 400, 525}, + { 848, 389, 400, 525}, + { 848, 518, 400, 525}, + {1056, 628, 400, 525}, + { 400, 525, 400, 525}, + { 800, 449,1000, 644}, + { 800, 525,1000, 635} +}; + +static const SiS_LVDSDataStruct SiS_LVDS640x480Data_1[]= +{ + { 800, 445, 800, 525}, /* 800, 449, 800, 449 */ + { 800, 395, 800, 525}, + { 800, 445, 800, 525}, + { 800, 395, 800, 525}, + { 800, 525, 800, 525}, + { 800, 525, 800, 525}, /* pseudo */ + { 800, 525, 800, 525} /* pseudo */ +}; + +/* FSTN 320x240 */ +static const SiS_LVDSDataStruct SiS_LVDS640x480Data_2[]= +{ + { 800, 445, 800, 525}, + { 800, 395, 800, 525}, + { 800, 445, 800, 525}, + { 800, 395, 800, 525}, + { 800, 525, 800, 525}, + { 800, 525, 800, 525}, /* pseudo */ + { 800, 525, 800, 525} /* pseudo */ +}; + + +static const SiS_LVDSDataStruct SiS_LVDS800x600Data_1[]= +{ + { 848, 433,1060, 629}, + { 848, 389,1060, 629}, + { 848, 433,1060, 629}, + { 848, 389,1060, 629}, + { 848, 518,1060, 629}, + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + { 800, 449,1000, 644}, + { 800, 525,1000, 635} +}; + +static const SiS_LVDSDataStruct SiS_LVDS800x600Data_2[]= +{ + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + {1056, 628,1056, 628}, + { 800, 449,1000, 644}, + { 800, 525,1000, 635} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1024x768Data_1[]= +{ + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 518,1344, 806}, /* 640x480 */ + {1050, 638,1344, 806}, /* 800x600 */ + {1344, 806,1344, 806}, /* 1024x768 */ + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1024x768Data_2[]= +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + + +static const SiS_LVDSDataStruct SiS_LVDS1280x1024Data_1[]= +{ + {1048, 442,1688,1066}, + {1048, 392,1688,1066}, + {1048, 442,1688,1066}, + {1048, 392,1688,1066}, + {1048, 522,1688,1066}, + {1208, 642,1688,1066}, + {1432, 810,1688,1066}, + {1688,1066,1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1280x1024Data_2[]= +{ + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1400x1050Data_1[]= +{ + { 928, 416, 1688,1066}, + { 928, 366, 1688,1066}, + { 928, 416, 1688,1066}, + { 928, 366, 1688,1066}, + { 928, 496, 1688,1066}, + {1088, 616, 1688,1066}, + {1312, 784, 1688,1066}, + {1568,1040, 1688,1066}, + {1688,1066, 1688,1066} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1400x1050Data_2[]= +{ + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, + {1688,1066, 1688,1066}, +}; + +static const SiS_LVDSDataStruct SiS_LVDS1600x1200Data_1[]= +{ + {1088, 520, 2048,1320}, + {1088, 470, 2048,1320}, + {1088, 520, 2048,1320}, + {1088, 470, 2048,1320}, + {1088, 600, 2048,1320}, + {1248, 720, 2048,1320}, + {1472, 888, 2048,1320}, + {1728,1144, 2048,1320}, + {1848,1170, 2048,1320}, + {2048,1320, 2048,1320} +#if 0 + {1088, 450, 2048,1250}, + {1088, 400, 2048,1250}, + {1088, 450, 2048,1250}, + {1088, 400, 2048,1250}, + {1088, 530, 2048,1250}, + {1248, 650, 2048,1250}, + {1472, 818, 2048,1250}, + {1728,1066, 2048,1250}, + {1848,1066, 2048,1250}, + {2048,1250, 2048,1250} #endif -#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); +}; + +static const SiS_LVDSDataStruct SiS_LVDS1600x1200Data_2[]= +{ + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320}, + {2048,1320, 2048,1320} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1280x960Data_1[]= +{ + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 518,1344, 806}, + {1050, 638,1344, 806}, + {1344, 806,1344, 806}, + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1280x960Data_2[]= +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1280x768Data_1[]= +{ + { 768, 438, 1408, 806}, + { 768, 388, 1408, 806}, + { 768, 438, 1408, 806}, + { 768, 388, 1408, 806}, + { 768, 518, 1408, 806}, + { 928, 638, 1408, 806}, + {1152, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1280x768Data_2[]= +{ + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806}, + {1408, 806, 1408, 806} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1024x600Data_1[] = +{ + { 840, 604,1344, 800}, + { 840, 560,1344, 800}, + { 840, 604,1344, 800}, + { 840, 560,1344, 800}, + { 840, 689,1344, 800}, + {1050, 800,1344, 800}, + {1344, 800,1344, 800}, + { 800, 449,1280, 789}, + { 800, 525,1280, 785} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1024x600Data_2[] = +{ + {1344, 800,1344, 800}, + {1344, 800,1344, 800}, + {1344, 800,1344, 800}, + {1344, 800,1344, 800}, + {1344, 800,1344, 800}, + {1344, 800,1344, 800}, + {1344, 800,1344, 800}, + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1152x768Data_1[] = +{ + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 438,1344, 806}, + { 840, 409,1344, 806}, + { 840, 518,1344, 806}, + {1050, 638,1344, 806}, + {1344, 806,1344, 806}, + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + +static const SiS_LVDSDataStruct SiS_LVDS1152x768Data_2[] = +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + { 800, 449,1280, 801}, + { 800, 525,1280, 813} +}; + +/* Pass 1:1 data */ +static const SiS_LVDSDataStruct SiS_LVDSXXXxXXXData_1[]= +{ + { 800, 449, 800, 449}, + { 800, 449, 800, 449}, + { 900, 449, 900, 449}, + { 900, 449, 900, 449}, + { 800, 525, 800, 525}, /* 640x480 */ + {1056, 628, 1056, 628}, /* 800x600 */ + {1344, 806, 1344, 806}, /* 1024x768 */ + {1344,1066, 1344,1066}, /* 1280x1024 */ /* INSERTED ! */ + {1688, 806, 1688, 806}, /* 1280x768 */ + /* No other panels ! */ +}; + +/* Custom data for Barco iQ R series */ +static const SiS_LVDSDataStruct SiS_LVDSBARCO1366Data_1[]= +{ + { 832, 438,1331, 806}, + { 832, 388,1331, 806}, + { 832, 438,1331, 806}, + { 832, 388,1331, 806}, + { 832, 518,1331, 806}, + {1050, 638,1344, 806}, + {1344, 806,1344, 806}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066} /* 1360x1024 */ +}; + +/* Custom data for Barco iQ R series */ +static const SiS_LVDSDataStruct SiS_LVDSBARCO1366Data_2[]= +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066} /* 1360x1024 */ +}; + +/* Custom data for Barco iQ G series */ +static const SiS_LVDSDataStruct SiS_LVDSBARCO1024Data_1[]= +{ + { 832, 438,1331, 806}, + { 832, 409,1331, 806}, + { 832, 438,1331, 806}, + { 832, 409,1331, 806}, + { 832, 518,1331, 806}, /* 640x480 */ + {1050, 638,1344, 806}, /* 800x600 */ + {1344, 806,1344, 806}, /* 1024x768 */ +}; + +/* Custom data for Barco iQ G series */ +static const SiS_LVDSDataStruct SiS_LVDSBARCO1024Data_2[]= +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, +}; + +/* Custom data for 848x480 parallel panel */ +static const SiS_LVDSDataStruct SiS_LVDS848x480Data_1[]= +{ + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + {1088, 525,1088, 525}, /* 640x480 TODO */ + {1088, 525,1088, 525}, /* 800x600 TODO */ + {1088, 525,1088, 525}, /* 1024x768 TODO */ + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + {1088, 525,1088, 525}, /* 848x480 */ + {1088, 525,1088, 525} /* 1360x768 TODO */ +}; + +/* Custom data for 848x480 parallel panel */ +static const SiS_LVDSDataStruct SiS_LVDS848x480Data_2[]= +{ + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + {1088, 525,1088, 525}, /* 640x480 */ + {1088, 525,1088, 525}, /* 800x600 */ + {1088, 525,1088, 525}, /* 1024x768 */ + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + {1088, 525,1088, 525}, /* 848x480 */ + {1088, 525,1088, 525} /* 1360x768 TODO */ +}; + +static const SiS_LVDSDataStruct SiS_CHTVUNTSCData[]= +{ + { 840, 600, 840, 600}, + { 840, 600, 840, 600}, + { 840, 600, 840, 600}, + { 840, 600, 840, 600}, + { 784, 600, 784, 600}, + {1064, 750,1064, 750}, + {1160, 945,1160, 945} +}; + +static const SiS_LVDSDataStruct SiS_CHTVONTSCData[]= +{ + { 840, 525, 840, 525}, + { 840, 525, 840, 525}, + { 840, 525, 840, 525}, + { 840, 525, 840, 525}, + { 784, 525, 784, 525}, + {1040, 700,1040, 700}, + {1160, 840,1160, 840} +}; + +/* LVDS Skew */ + +static const SiS_LVDSDesStruct SiS_PanelTypeNS_1[]= +{ + { 8, 0}, + { 8, 0}, + { 8, 0}, + { 8, 0}, + { 8, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 806}, + { 0, 0} +}; + +static const SiS_LVDSDesStruct SiS_PanelTypeNS_2[] = +{ + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0}, + { 0 , 0} +}; + +/* Chrontel TV Skew */ + +static const SiS_LVDSDesStruct SiS_CHTVUNTSCDesData[]= +{ + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0} +}; + +static const SiS_LVDSDesStruct SiS_CHTVONTSCDesData[]= +{ + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0} +}; + +static const SiS_LVDSDesStruct SiS_CHTVUPALDesData[]= +{ + {256, 0}, + {256, 0}, + {256, 0}, + {256, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0} +}; + +static const SiS_LVDSDesStruct SiS_CHTVOPALDesData[]= +{ + {256, 0}, + {256, 0}, + {256, 0}, + {256, 0}, + { 0, 0}, + { 0, 0}, + { 0, 0} +}; + +/* CRT1 CRTC data for slave modes */ + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1320x480_1[] = +{ + {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + 0x00 }}, + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00 }}, + {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00 }}, + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00 }}, + {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e, + 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, + 0x00 }}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01 }}, + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00 }} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_1[] = +{ + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_1_H[] = +{ + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00, + 0x00}}, + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x83,0x85,0x63,0xba,0x00,0x00,0x00, + 0x00}}, + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00, + 0x00}}, + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x83,0x85,0x63,0xba,0x00,0x00,0x00, + 0x00}}, + {{0x2d,0x28,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_2[] = +{ + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, + 0x00}}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01}}, + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_2_H[] = +{ + {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + 0x00}}, + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00}}, + {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00}}, + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00}}, + {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e, + 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, + 0x00}}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01}}, + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_3[] = +{ + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05, + 0x00}}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01}}, + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_3_H[] = +{ + {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f, + 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, + 0x00}}, + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00}}, + {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00}}, + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, + 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, + 0x00}}, + {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e, + 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, + 0x00}}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01}}, + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11024x600_1[] = +{ + {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, + 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, + 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, + 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, + 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0xaf,0xba, + 0x3b,0x82,0xdf,0xb0,0x00,0x00,0x01, + 0x00}}, + {{0x7e,0x63,0x82,0x68,0x15,0x1e,0xf1, + 0xae,0x85,0x57,0x1f,0x30,0x00,0x26, + 0x01}}, + {{0xa3,0x7f,0x87,0x86,0x97,0x1e,0xf1, + 0xae,0x85,0x57,0x1f,0x30,0x00,0x02, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11024x600_1_H[] = +{ + {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, + 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, + 0x00}}, + {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, + 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, + 0x01}}, + {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11024x600_2[] = +{ + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, + 0xae,0x84,0x57,0x25,0x30,0x00,0x02, + 0x01}}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11024x600_2_H[] = +{ + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, + 0xae,0x84,0x57,0x25,0x30,0x00,0x01, + 0x01}}, + {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11152x768_1[] = +{ + {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, + 0x00}}, + {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e, + 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, + 0x00}}, + {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, + 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, + 0x01}}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11152x768_1_H[] = +{ + {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, + 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, + 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, + 0x00}}, + {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, + 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, + 0x00}}, + {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, + 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, + 0x01}}, + {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11152x768_2[] = +{ + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, + 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, + 0x00}}, + {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, + 0xae,0x84,0x57,0x25,0x30,0x00,0x02, + 0x01}}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11152x768_2_H[] = +{ + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, + 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, + 0x00}}, + {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, + 0xae,0x84,0x57,0x25,0x30,0x00,0x01, + 0x01}}, + {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x01, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_1[] = +{ + {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f, + 0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01, + 0x00}}, + {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f, + 0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01, + 0x00}}, + {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f, + 0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01, + 0x00}}, + {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f, + 0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01, + 0x00}}, + {{0x5b,0x4f,0x9f,0x55,0x19,0x04,0x3e, + 0xec,0x8e,0xdf,0x05,0x20,0x00,0x01, + 0x00}}, + {{0x6f,0x63,0x93,0x69,0x8d,0x7c,0xf0, + 0x64,0x86,0x57,0x7d,0x20,0x00,0x05, + 0x01}}, + {{0x8b,0x7f,0x8f,0x85,0x09,0x24,0xf5, + 0x0c,0x8e,0xff,0x25,0x30,0x00,0x02, + 0x01}}, + {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5, + 0x0c,0x8e,0xff,0x25,0x30,0x00,0x06, + 0x01}}, + {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5, + 0x0c,0x8e,0xff,0x25,0x30,0x00,0x06, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_1_H[] = +{ + {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, + 0x93,0x86,0x8f,0x9f,0x30,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, + 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x8b,0x30,0x1e,0x9e,0x1f, + 0x92,0x86,0x8f,0x9f,0x30,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, + 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, + 0x00}}, + {{0x47,0x27,0x8b,0x2c,0x1a,0xee,0x1f, + 0xe2,0x86,0xdf,0xef,0x10,0x00,0x05, + 0x00}}, + {{0x51,0x31,0x95,0x36,0x04,0x66,0xf0, + 0x5a,0x8e,0x57,0x67,0x20,0x00,0x01, + 0x01}}, + {{0x5f,0x3f,0x83,0x44,0x92,0x0e,0xf5, + 0x02,0x86,0xff,0x0f,0x10,0x00,0x01, + 0x01}}, + {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a, + 0x02,0x86,0xff,0x0f,0x09,0x00,0x05, + 0x01}}, + {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a, + 0x02,0x86,0xff,0x0f,0x09,0x00,0x05, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_2[] = +{ + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, + 0x54,0x86,0xdb,0xda,0x00,0x00,0x02, + 0x00}}, + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, + 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02, + 0x00}}, + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, + 0x54,0x86,0xdb,0xda,0x00,0x00,0x02, + 0x00}}, + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, + 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02, + 0x00}}, + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xb3, + 0x7c,0x8e,0x03,0x02,0x10,0x00,0x02, + 0x01}}, + {{0xab,0x63,0x8f,0x8a,0x8e,0x24,0xf1, + 0xb6,0x88,0x57,0x25,0x10,0x00,0x02, + 0x01}}, + {{0xab,0x7f,0x8f,0x98,0x9c,0x24,0xf5, + 0x0a,0x8c,0xff,0x25,0x30,0x00,0x02, + 0x01}}, + {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, + 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, + 0x01}}, + {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, + 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_2_H[] = +{ + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, + 0x54,0x86,0xdb,0xda,0x00,0x00,0x01, + 0x00}}, + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, + 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01, + 0x00}}, + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, + 0x54,0x86,0xdb,0xda,0x00,0x00,0x01, + 0x00}}, + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, + 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01, + 0x00}}, + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xb3, + 0x7c,0x8e,0x03,0x02,0x10,0x00,0x01, + 0x01}}, + {{0x79,0x31,0x9d,0x58,0x9c,0x24,0xf1, + 0xb6,0x88,0x57,0x25,0x10,0x00,0x01, + 0x01}}, + {{0x6b,0x3f,0x8f,0x58,0x9c,0x24,0xf5, + 0x0a,0x8c,0xff,0x25,0x30,0x00,0x01, + 0x01}}, + {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, + 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, + 0x01}}, + {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, + 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1XXXxXXX_1[] = +{ + {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, + 0x00}}, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x05, + 0x00}}, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, + 0x01}}, + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x02, + 0x01}}, + {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a, + 0x00,0x84,0xff,0x29,0x09,0x00,0x07, + 0x01}}, + {{0xce,0x9f,0x92,0xa9,0x17,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x07, + 0x01}} +}; + +static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1XXXxXXX_1_H[] = +{ + {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, + 0x00}}, + {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, + 0x00}}, + {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, + 0x00}}, + {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, + 0x00}}, + {{0x38,0x27,0x9c,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}}, + {{0x4d,0x31,0x91,0x3b,0x03,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x01, + 0x01}}, + {{0x63,0x3f,0x87,0x4a,0x92,0x24,0xf5, + 0x02,0x88,0xff,0x25,0x10,0x00,0x01, + 0x01}} +}; + + +/**************************************************************/ +/* COMMON --------------------------------------------------- */ +/**************************************************************/ + +#define SIS_PL_HSYNCP 0x01 +#define SIS_PL_HSYNCN 0x02 +#define SIS_PL_VSYNCP 0x04 +#define SIS_PL_VSYNCN 0x08 +#define SIS_PL_DVI 0x80 + +typedef struct _SiS_PlasmaModes +{ + const char *name; + ULONG clock; + USHORT HDisplay, HTotal, HFrontPorch, HSyncWidth; + USHORT VDisplay, VTotal, VFrontPorch, VSyncWidth; + UCHAR SyncFlags; +} SiS_PlasmaModes; + +typedef struct _SiS_PlasmaTables +{ + USHORT vendor; + UCHAR productnum; + USHORT product[5]; + const char *DDCnames[5]; + const char *plasmaname; + UCHAR modenum; + UCHAR plasmamodes[20]; /* | 0x80 = DVI-capable, | 0x40 = analog */ +} SiS_PlasmaTables; + +static const SiS_PlasmaModes SiS_PlasmaMode[] = { + { "640x400", /* 00: IBM 400@70 */ + 25175, + 640, 800, 17, 64, + 400, 449, 13, 2, + SIS_PL_HSYNCN | SIS_PL_VSYNCN }, + { "640x480", /* 01: VESA 480@72 */ + 31500, + 640, 832, 24, 40, + 480, 520, 9, 3, + SIS_PL_HSYNCN | SIS_PL_VSYNCN }, + { "800x600", /* 02: VESA 600@72 */ + 50000, + 800, 1040, 56, 120, + 600, 666, 37, 6, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "864x480", /* 03: Cereb wide 1 */ + 42526, + 864, 1134, 22, 86, + 480, 500, 1, 3, + SIS_PL_HSYNCP | SIS_PL_VSYNCN }, + { "848x480", /* 04: VESA wide (NEC1) */ + 33750, + 848, 1088, 16, 112, + 480, 517, 6, 8, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1024x576", /* 05: VESA wide (NEC2) */ + 47250, + 1024, 1320, 16, 144, + 576, 596, 2, 4, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1280x720", /* 06: VESA wide (NEC3) */ + 76500, + 1280, 1696, 48, 176, + 720, 750, 4, 8, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1360x765", /* 07: VESA wide (NEC4) */ + 85500, + 1360, 1792, 64, 176, + 765, 795, 4, 8, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1024x600", /* 08: CEREB wide 2 */ + 51200, + 1024, 1352, 51, 164, + 600, 628, 1, 4, + SIS_PL_HSYNCN | SIS_PL_VSYNCP }, + { "1024x768", /* 09: VESA 768@75 */ + 78750, + 1024, 1312, 16, 96, + 768, 800, 1, 3, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1152x864", /* 10: VESA 1152x864@75 */ + 108000, + 1152, 1600, 64, 128, + 864, 900, 1, 3, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1280x1024", /* 11: VESA 1024@60 */ + 108000, + 1280, 1688, 48, 112, + 1024, 1066, 1, 3, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1280x768", /* 12: W_XGA */ + 81000, + 1280, 1688, 48, 112, + 768, 802, 3, 6, + SIS_PL_HSYNCP | SIS_PL_VSYNCN }, + { "1280x768", /* 13: I/O Data W_XGA@56Hz */ + 76064, + 1280, 1688, 48, 112, + 768, 802, 2, 3, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1376x768", /* 14: I/O Wide XGA */ + 87340, + 1376, 1808, 32, 128, + 768, 806, 3, 6, + SIS_PL_HSYNCN | SIS_PL_VSYNCP }, + { "1280x960", /* 15: VESA 960@60 */ + 108000, + 1280, 1800, 96, 112, + 960, 1000, 1, 3, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1400x1050", /* 16: VESA 1050@60Hz */ + 108000, + 1400, 1688, 48, 112, + 1050, 1066, 1, 3, + SIS_PL_HSYNCN | SIS_PL_VSYNCN }, + { "1360x768", /* 17: VESA wide (NEC4/2) */ + 85500, + 1360, 1792, 64, 112, + 765, 795, 3, 6, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "800x600", /* 18: VESA 600@56 */ + 36000, + 800, 1024, 24, 2, + 600, 625, 1, 2, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "1072x600", /* 19: Panasonic 1072x600 (sync?) */ + 54100, + 1072, 1424, 48, 176, + 600, 628, 16, 1, + SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + { "848x480", /* 20: Panasonic 848x480 (sync?) */ + 33070, /* is 852x480, but we can't use 852 */ + 848, 1068, 20, 40, /* differs from DDC data, better centered */ + 480, 516, 3, 5, /* won't work assumingly, because data is % 8 */ + SIS_PL_HSYNCN | SIS_PL_VSYNCN }, +}; + +static const SiS_PlasmaTables SiS_PlasmaTable[] = { +#if 0 /* Product IDs missing */ + { 0x38a3, 4, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 42VP4/42VP4D/42VP4G/42VP4DG", + 11, /* All DVI, except 0, 7, 13 */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0, + 17|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, +#endif +#if 0 /* Product IDs missing */ + { 0x38a3, 3, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 42PD1/50PD1/50PD2", + 5, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0, 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 1, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 42PD3", + 10, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 3|0xc0, 4|0xc0, 5|0xc0, 6|0xc0, 7|0x40, 8|0xc0, 9|0xc0, + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 2, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 42VM3/61XM1", + 11, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 3|0xc0, 4|0xc0, 5|0xc0, 6|0xc0, 8|0xc0, 9|0xc0,11|0xc0, + 17|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 2, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 42MP1/42MP2", + 6, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0,11|0xc0, 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 1, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 50MP1", + 10, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0, + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, +#endif + { 0x38a3, 4, + { 0xa482, 0xa483, 0x0000, 0x0000, 0x0000 }, + { "PX-42VM", "", "", "", "" }, + "NEC PlasmaSync 42MP3/42MP4/50MP2/61MP1", + 11, /* All DVI except 0, 7, 13, 17 */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0, + 17|0x40, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, +#if 0 /* Product IDs missing */ + { 0x38a3, 1, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 3300W", + 3, + { 0|0x40, 1|0xc0,18|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 1, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 4200W", + 4, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 1, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 4210W", + 6, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0,11|0xc0, 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x38a3, 1, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "NEC PlasmaSync 5000W", + 7, /* DVI entirely unknown */ + { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,11|0xc0, 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, #endif -void SiS_ClearBuffer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT ModeNo); -void SiS_SetCRT1Group(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeNo,USHORT ModeIdIndex,USHORT BaseAddr); -void SiS_DetectMonitor(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr); -void SiS_GetSenseStatus(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,UCHAR *ROMAddr); -USHORT SiS_TestMonitorType(SiS_Private *SiS_Pr, UCHAR R_DAC,UCHAR G_DAC,UCHAR B_DAC); -USHORT SiS_SenseCHTV(SiS_Private *SiS_Pr); -BOOLEAN SiS_Sense(SiS_Private *SiS_Pr, USHORT tempbx,USHORT tempcx); -BOOLEAN SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO); -BOOLEAN SiS_GetLCDDDCInfo(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO); -USHORT SiS_SenseLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO); -void SiSRegInit(SiS_Private *SiS_Pr, USHORT BaseAddr); -void SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo); -void SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiSDetermineROMUsage(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR *ROMAddr); + { 0x412f, 2, + { 0x000c, 0x000b, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "Pioneer 503CMX/PDA-5002", + 6, /* DVI unknown */ + { 1|0xc0, 2|0xc0, 9|0xc0,11|0xc0,12|0xc0,15|0xc0, 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x34a9, 1, + { 0xa00e, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "", "", "", "", "" }, + "Panasonic TH-42", + 5, /* No DVI output */ + { 1|0x40, 2|0x40, 4|0x40, 9|0x40,15|0x40, 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x34a9, 1, + { 0xa005, 0x0000, 0x0000, 0x0000, 0x0000 }, + { "TH-42PW*4", "", "", "", "" }, + "Panasonic TH-42PW5", + 1, /* No special modes otherwise; no DVI. */ + {20|0x40,19|0x40, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } + }, + { 0x0000 } +}; + +USHORT SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, BOOLEAN FSTN); +USHORT SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, BOOLEAN FSTN, + USHORT CustomT, int LCDwith, int LCDheight); +USHORT SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth); +USHORT SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth); +void SiS_SetReg(SISIOADDRESS port, USHORT index, USHORT data); +void SiS_SetRegByte(SISIOADDRESS port, USHORT data); +void SiS_SetRegShort(SISIOADDRESS port, USHORT data); +void SiS_SetRegLong(SISIOADDRESS port, ULONG data); +UCHAR SiS_GetReg(SISIOADDRESS port, USHORT index); +UCHAR SiS_GetRegByte(SISIOADDRESS port); +USHORT SiS_GetRegShort(SISIOADDRESS port); +ULONG SiS_GetRegLong(SISIOADDRESS port); +void SiS_SetRegANDOR(SISIOADDRESS Port,USHORT Index,USHORT DataAND,USHORT DataOR); +void SiS_SetRegAND(SISIOADDRESS Port,USHORT Index,USHORT DataAND); +void SiS_SetRegOR(SISIOADDRESS Port,USHORT Index,USHORT DataOR); +void SiS_DisplayOn(SiS_Private *SiS_Pr); +void SiS_DisplayOff(SiS_Private *SiS_Pr); +void SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr); +void SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable); +void SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable); +void SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +USHORT SiS_GetMCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex); +UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); +USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); +USHORT SiS_GetOffset(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo); +void SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT ModeIdIndex); #ifdef LINUX_XF86 -USHORT SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode); -USHORT SiS_CheckCalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags); -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); -unsigned char SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id); -unsigned char SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, unsigned char value); -extern int SiS_compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div, - int *out_sbit, int *out_scale); +BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch); +BOOLEAN SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom); +BOOLEAN SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom); +BOOLEAN SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom); +int SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber); +BOOLEAN SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_INFO); +USHORT SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags); +DisplayModePtr SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfordvi); +#else +BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,USHORT ModeNo); +#endif +#ifdef LINUX_KERNEL +int sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, PSIS_HW_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, + ULONG *left_margin, ULONG *right_margin, + ULONG *upper_margin, ULONG *lower_margin, + ULONG *hsync_len, ULONG *vsync_len, + ULONG *sync, ULONG *vmode); +BOOLEAN sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex); #endif -extern USHORT SiS_GetOffset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -extern void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -extern BOOLEAN SiS_SetCRT2Group301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern void SiS_PresetScratchregister(SiS_Private *SiS_Pr, USHORT SiS_P3d4, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr); -extern void SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr); -extern BOOLEAN SiS_BridgeIsOn(SiS_Private *SiS_Pr, USHORT BaseAddr); -extern BOOLEAN SiS_BridgeIsEnable(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO ); -extern void SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension, int chkcrt2mode); -extern BOOLEAN SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern void SiS_SetHiVision(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern USHORT SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern void SiS_WhatIsThis(SiS_Private *SiS_Pr, USHORT myvbinfo); -extern void SiS_LongWait(SiS_Private *SiS_Pr); -extern void SiS_SetRegOR(USHORT Port,USHORT Index,USHORT DataOR); -extern void SiS_SetRegAND(USHORT Port,USHORT Index,USHORT DataAND); -extern void SiS_SetRegANDOR(USHORT Port,USHORT Index,USHORT DataAND,USHORT DataOR); -extern USHORT SiS_GetResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -extern void SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempax); +extern 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_SetHiVision(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 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); +extern USHORT SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo); +extern BOOLEAN SiS_IsVAMode(SiS_Private *, PSIS_HW_INFO); +extern BOOLEAN SiS_IsDualEdge(SiS_Private *, PSIS_HW_INFO); + +#ifdef LINUX_XF86 +extern int SiS_compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div, + int *out_sbit, int *out_scale); +extern void SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD, unsigned int *vclk); + +extern unsigned char SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, unsigned char value); +extern unsigned char SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id); +extern USHORT SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, unsigned long VBFlags, + BOOLEAN hcm); +#endif #endif diff --git a/src/init301.c b/src/init301.c index 0c2b635..3b88a8d 100644 --- a/src/init301.c +++ b/src/init301.c @@ -1,22 +1,17 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c,v 1.10 2003/02/04 02:44:28 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c,v 1.52 2003/11/20 19:53:22 twini Exp $ */ /* - * Mode switching code (CRT2 section) for SiS 300/540/630/730/315/550/650/740/330 - * (Universal module for Linux kernel framebuffer, XFree86 4.x) + * Mode initializing code (CRT2 section) + * for SiS 300/305/540/630/730 and + * SiS 315/550/650/M650/651/661FX/M661xX/740/741/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 <thomas@winischhofer.net> - * Minor parts Copyright SiS, Inc. + * Formerly based on non-functional code-fragements for 300 series by SiS, Inc. * - * Based on BIOS - * 1.10.07, 1.10a for SiS650/LVDS+CH7019 - * 1.11.05 for 650/LVDS (w/o Chrontel) - * 1.07.1b, 1.10.6s, 1.11.6w, 1.11.7w, 1.11.8r for SiS650/301(B/LV), 650/301LVx - * 2.04.50 (I) and 2.04.5c (II) for SiS630/301(B) - * 2.02.3b, 2.03.02, 2.04.2c, 2.04.5c, 2.07a and 2.08.b3 for 630/LVDS/LVDS+CH7005 - * 2.04.5c, 2.04.6c for 730+LVDS+CH7005 - * 1.09b for 315/301(B) - * 1.16.51 for 300+301LVX (ECS A907) - * 1.01.03 for 330 (Xabre 400) + * If distributed as part of the linux kernel, the contents of this file + * is entirely covered by the GPL. + * + * Otherwise, the following 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 @@ -42,9 +37,17 @@ * 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 0 +#define SET_EMI +#endif + +#if 1 +#define SET_EMI_CPQ +#endif #include "init301.h" @@ -52,10 +55,6 @@ #define TWNEWPANEL #endif -#if 1 /* TW: Emulate 650/301LVx BIOS 1.10.6s (should be set) */ -#define SIS650301NEW -#endif - #ifdef SIS300 #include "oem300.h" #endif @@ -65,3114 +64,2823 @@ #endif #define SiS_I2CDELAY 1000 -#define SiS_I2CDELAYSHORT 333 - -BOOLEAN -SiS_SetCRT2Group301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT ModeIdIndex; - USHORT RefreshRateTableIndex; - - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; +#define SiS_I2CDELAYSHORT 150 - if(!SiS_Pr->UseCustomMode) { - SiS_SearchModeID(SiS_Pr,ROMAddr,&ModeNo,&ModeIdIndex); - } else { - ModeIdIndex = 0; - } +/*********************************************/ +/* HELPER: Lock/Unlock CRT2 */ +/*********************************************/ - /* TW: Used for shifting CR33 */ - SiS_Pr->SiS_SelectCRT2Rate = 4; +void +SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + if(HwInfo->jChipType >= SIS_315H) + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2f,0x01); + else + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01); +} - SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr); +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); +} - RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr, ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); +/*********************************************/ +/* HELPER: Enable CRT2 */ +/*********************************************/ - SiS_SaveCRT2Info(SiS_Pr,ModeNo); +void +SiS_EnableCRT2(SiS_Private *SiS_Pr) +{ + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); +} - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - SiS_DisableBridge(SiS_Pr,HwDeviceExtension,BaseAddr); - if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (HwDeviceExtension->jChipType == SIS_730)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,0x80); - } - SiS_SetCRT2ModeRegs(SiS_Pr,BaseAddr,ModeNo,ModeIdIndex,HwDeviceExtension); - } +/*********************************************/ +/* HELPER: Get Pointer to LCD structure */ +/*********************************************/ - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - SiS_LockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); - SiS_DisplayOn(SiS_Pr); - return(TRUE); - } +/* For 661 series only */ +#ifdef SIS315H +#if 0 /* Need to wait until hardware using this really exists */ +static UCHAR * +GetLCDPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, int tabletype, + USHORT ModeNo, USHORT ModeIdIndex, USHORT RRTI) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + UCHAR *tableptr = NULL; + UCHAR tablelengths[] = { 8, 7, 6, 6, 8, 6, 0, 0, 0 }; + USHORT modeflag, CRT2Index, tablelength, lcdid, myid, tableptri; - if(SiS_Pr->UseCustomMode) return(FALSE); - - SiS_GetCRT2Data(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - - /* LVDS, 650/301LV(LCDA) and 630/301B BIOS set up Panel Link */ - /* 300+LV does not */ - if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || - ((HwDeviceExtension->jChipType != SIS_300) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV))) { - SiS_GetLVDSDesData(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } else { - SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; - } + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + CRT2Index = SiS_Pr->SiS_RefIndex[RRTI].Ext_CRT2CRTC; + /* This is total bullshit: */ + if(SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO == SIS_RI_720x576) CRT2Index = 10; + } -#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 + if(tabletype <= 1) { +#if 0 /* Not yet implemented */ + if(ModeNo <= 0x13) { + CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex]. + 5; + } else { + CRT2Index = SiS_Pr->SiS_RefIndex[RRTI]. + 5; + } + if(tabletype & 1) CRT2Index >>= 4; #endif + } - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - SiS_SetGroup1(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); - } - - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - - 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); - - /* TW: 630/301B BIOS does all this: */ - if((HwDeviceExtension->jChipType < SIS_315H) && - (HwDeviceExtension->jChipType != SIS_300)) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - if(!((SiS_Pr->SiS_SetFlag & CRT2IsVGA) && ((ModeNo == 0x03) || (ModeNo = 0x10)))) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SiS_ModCRT1CRTC(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - } - } - } - SiS_SetCRT2ECLK(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - } - } + CRT2Index &= 0x0f; - } + tablelength = tablelengths[tabletype]; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + if((tabletype == 5) || (tabletype == 7)) tablelength = 8; + if((tabletype == 3) || (tabletype == 8)) tablelength = 8; + } - } else { + if(!tablelength) return NULL; - 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); - } - } - if(SiS_Pr->SiS_IF_DEF_FSTN == 0) { - SiS_SetCRT2ECLK(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - } - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - /* TW: Inserted from 650/LVDS BIOS */ - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - SiS_SetCH701xForLCD(SiS_Pr,HwDeviceExtension,BaseAddr); - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - /* TW: Set Chrontel registers only if CRT2 is TV */ - SiS_SetCHTVReg(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex); - } - } - } + tableptri = ROMAddr[0x222] | (ROMAddr[0x223] << 8); + tableptri += (tabletype << 1); + if(!tableptri) return NULL; + tableptr = &ROMAddr[tableptri]; - } + do { + lcdid = tableptr[0]; + if(lcdid == 0xff) break; + myid = SiS_Pr->SiS_LCDResInfo; + if((lcdid & 0x80) && (lcdid != 0x80)) { + lcdid &= 0x7f; + myid = SiS_Pr->SiS_LCDTypeInfo; + } + if(SiS_Pr->SiS_LCDInfo & LCDPass11) myid &= ~0x1f; + + if(myid == lcdid) { + lcdid = tableptr[1] | (tableptr[2] << 8); + myid = SiS_Pr->SiS_LCDInfo661; + if(modeflag & HalfDCLK) myid |= 0x200; + if(ModeNo <= 0x13) myid |= 0x400; + lcdid &= myid; + myid = tableptr[3] | (tableptr[4] << 8); + if(lcdid == myid) break; + } + tableptr += 7; + } while (1); -#ifdef SIS300 - if ( (HwDeviceExtension->jChipType == SIS_540) || - (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) || - (HwDeviceExtension->jChipType == SIS_300) ) - { - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - if(SiS_Pr->SiS_UseOEM) { - if((SiS_Pr->SiS_UseROM) && ROMAddr && (SiS_Pr->SiS_UseOEM == -1)) { - if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - SiS_OEM300Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo); - } - } else { - SiS_OEM300Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo); - } - } - } - } -#endif + if(lcdid == myid) { + lcdid = tableptr[5] | (tableptr[6] << 8); + lcdid += (tablelength * CRT2Index); + return((UCHAR *)&ROMAddr[lcdid]); + } -#ifdef SIS315H - if ( (HwDeviceExtension->jChipType == SIS_315H) || - (HwDeviceExtension->jChipType == SIS_315) || - (HwDeviceExtension->jChipType == SIS_315PRO)|| - (HwDeviceExtension->jChipType == SIS_550) || - (HwDeviceExtension->jChipType == SIS_740) || - (HwDeviceExtension->jChipType == SIS_650) || - (HwDeviceExtension->jChipType == SIS_330) ) - { - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { -#ifdef SIS650301NEW - SiS_FinalizeLCD(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, HwDeviceExtension); -#else - SiS_OEMLCD(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); -#endif - if(SiS_Pr->SiS_UseOEM) { - SiS_OEM310Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - } - SiS_CRT2AutoThreshold(SiS_Pr,BaseAddr); - } - } + return NULL; +} #endif - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(HwDeviceExtension->jChipType != SIS_730) { - SiS_DisplayOn(SiS_Pr); - } - } - } +static UCHAR * +GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT lcdres = SiS_Pr->SiS_LCDResInfo; + USHORT lcdtype = SiS_Pr->SiS_LCDTypeInfo; + USHORT romindex=0; + UCHAR *myptr = NULL; + UCHAR lcdid; - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(HwDeviceExtension->jChipType == SIS_730) { - SiS_DisplayOn(SiS_Pr); - } - } - SiS_EnableBridge(SiS_Pr,HwDeviceExtension,BaseAddr); + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + romindex = ROMAddr[0x256] | (ROMAddr[0x257] << 8); } - - SiS_DisplayOn(SiS_Pr); - - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - /* TW: Disable LCD panel when using TV */ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x11,0x0C); - } else { - /* TW: Disable TV when using LCD */ - SiS_SetCH70xxANDOR(SiS_Pr,0x010E,0xF8); - } + if(romindex) { + myptr = &ROMAddr[romindex]; + } else { + myptr = (UCHAR *)SiS_LCDStruct661; } - if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) { - SiS_LockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); + while(myptr[0] != 0xff) { + lcdid = myptr[0]; + if((lcdid & 0x80) && (lcdid != 0x80)) { + lcdres = lcdtype; + lcdid &= 0x7f; + } + if(lcdid == lcdres) break; + myptr += 26; } + if(myptr[0] == 0xff) return NULL; - return 1; + return myptr; } +#endif -/* TW: Checked with 330, 650/LVDS (1.10.07) and 630+301B/LVDS BIOS */ -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); - } - } -} +/*********************************************/ +/* Adjust Rate for CRT2 */ +/*********************************************/ -/* TW: Set Part1 registers */ -/* TW: Checked with 650/LVDS (1.10.07), 650/301LV (II) and 630/301B (II) BIOS */ -/* TW: Pass 2: Checked with 650/301LVx 1.10.6s, 630/301B 2.04.5a */ -void -SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT RefreshRateTableIndex) +static BOOLEAN +SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, USHORT *i, + PSIS_HW_INFO HwInfo) { - USHORT temp=0, tempax=0, tempbx=0, tempcx=0; - USHORT pushbx=0, CRT1Index=0; -#ifdef SIS315H - USHORT pushcx=0, tempbl=0; -#endif - USHORT modeflag, resinfo=0; + USHORT tempax,tempbx,resinfo; + USHORT modeflag,infoflag; - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = 0; } 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; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; } - /* TW: LCDA exists with LVDS as well */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + tempbx = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].ModeID; - SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo, - RefreshRateTableIndex,HwDeviceExtension); + tempax = 0; - SiS_SetGroup1_LCDA(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); + if(SiS_Pr->SiS_VBType & VB_SISVB) { - } else { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { - if( (HwDeviceExtension->jChipType >= SIS_315H) && - (SiS_Pr->SiS_IF_DEF_LVDS == 1) && - (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + tempax |= SupportRAMDAC2; + if(HwInfo->jChipType >= SIS_315H) { + tempax |= SupportRAMDAC2_135; + /* if((HwInfo->jChipType >= SIS_661) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { */ + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + tempax |= SupportRAMDAC2_162; + if(SiS_Pr->SiS_VBType & VB_SIS301C) { + tempax |= SupportRAMDAC2_202; + } + } + } - SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo, - RefreshRateTableIndex,HwDeviceExtension); + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - } else { + tempax |= SupportLCD; - SiS_SetCRT2Offset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if (HwDeviceExtension->jChipType < SIS_315H ) { -#ifdef SIS300 - SiS_SetCRT2FIFO_300(SiS_Pr,ROMAddr,ModeNo,HwDeviceExtension); -#endif - } else { -#ifdef SIS315H - SiS_SetCRT2FIFO_310(SiS_Pr,ROMAddr,ModeNo,HwDeviceExtension); -#endif + if(SiS_Pr->SiS_HiVision == 3) { + tempax |= SupportHiVisionTV2; + } else { + tempax |= SupportHiVisionTV; } - SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo, - RefreshRateTableIndex,HwDeviceExtension); + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART)) { - /* 1. Horizontal setup */ + tempax |= SupportTV; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + tempax |= SupportTV1024; + } - if (HwDeviceExtension->jChipType < SIS_315H ) { + } -#ifdef SIS300 /* ------------- 300 series --------------*/ + } else { /* for LVDS */ - temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,temp); /* TW: CRT2 Horizontal Total */ + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tempax |= SupportCHTV; + } + } - temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* TW: CRT2 Horizontal Total Overflow [7:4] */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + tempax |= SupportLCD; + } - temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp); /* TW: CRT2 Horizontal Display Enable End */ + } - 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; + /* 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; + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){ - /* CRT1Index &= 0x3F; - Not any longer */ - tempbx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4]; - tempbx |= ((SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14] & 0xC0) << 2); - tempbx = (tempbx - 1) << 3; - tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5]; - tempcx &= 0x1F; - temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15]; - temp = (temp & 0x04) << (6-2); - tempcx = ((tempcx | temp) - 1) << 3; - } - - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == 0x08)){ - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)){ - tempbx = 1040; - tempcx = 1042; - } - } - } + /* Look through the whole mode-section of the table from the beginning + * for a matching CRT2 mode if no mode was found yet. + */ + for((*i) = 0; ; (*i)++) { + if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].ModeID != tempbx) { + return(0); + } + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].Ext_InfoFlag; + if(infoflag & tempax) return(1); + } + return(1); +} - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp); /* TW: CRT2 Horizontal Retrace Start */ -#endif /* SIS300 */ +/*********************************************/ +/* Get rate pointer */ +/*********************************************/ - } else { +USHORT +SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) +{ + 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; -#ifdef SIS315H /* ----------------- 310/325 series ------------- */ + /* Do NOT check for UseCustomMode here, will skrew up FIFO */ + if(ModeNo == 0xfe) return 0; - tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HT 0x08,0x09 */ - pushcx = tempcx; - if(modeflag & HalfDCLK) { - if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_IF_DEF_CH70xx == 0)) { - tempax = SiS_Pr->SiS_VGAHDE >> 1; - tempcx = SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE + tempax; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) { - tempcx = SiS_Pr->SiS_HT - tempax; - } - } else { - tempcx >>= 1; - } - } - tempcx--; + if(ModeNo <= 0x13) + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + else + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - temp = tempcx & 0xff; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,temp); /* TW: CRT2 Horizontal Total */ + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(modeflag & HalfDCLK) return(0); + } + } - temp = ((tempcx & 0xff00) >> 8) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0F,temp); /* TW: CRT2 Horizontal Total Overflow [7:4] */ + if(ModeNo < 0x14) return(0xFFFF); - tempcx = pushcx; /* BTVGA2HDEE 0x0A,0x0C */ - tempbx = SiS_Pr->SiS_VGAHDE; - tempcx -= tempbx; - tempcx >>= 2; - if(modeflag & HalfDCLK) { - tempbx >>= 1; - tempcx >>= 1; - } - tempbx += 16; + /* 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 + */ - temp = tempbx & 0xff; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp); /* TW: CRT2 Horizontal Display Enable End */ + index = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x33) >> SiS_Pr->SiS_SelectCRT2Rate) & 0x0F; + backupindex = index; - pushbx = tempbx; - tempcx >>= 1; - tempbx += tempcx; - tempcx += tempbx; + if(index > 0) index--; - if(SiS_Pr->SiS_IF_DEF_LVDS==0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { - tempbx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4]; - tempbx |= ((SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14] & 0xC0) << 2); - tempbx = (tempbx - 3) << 3; /*(VGAHRS-3)*8 */ - tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5]; - tempcx &= 0x1F; - temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15]; - temp = (temp & 0x04) << (5-2); /* VGAHRE D[5] */ - tempcx = ((tempcx | temp) - 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) && (resinfo == 0x08)){ - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)){ - tempbx = 1040; - tempcx = 1042; - } - } - /* TW: Makes no sense, but is in 650/301LVx 1.10.6s */ - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == 0x08)){ - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - tempbx = 1040; - tempcx = 1042; - } - } - } - } + if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_VBType & VB_NoLCD) index = 0; + else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index = backupindex = 0; + } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) { + temp = LCDRefreshIndex[SiS_Pr->SiS_LCDResInfo]; + if(index > temp) index = temp; + } + } + } else { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0; + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) index = 0; + } + } + } - temp = tempbx & 0xff; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp); /* TW: CRT2 Horizontal Retrace Start */ -#endif /* SIS315H */ + RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; + ModeNo = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].ModeID; - } /* 310 series */ + 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++; + } + } + } - /* TW: The following is done for all bridge/chip types/series */ + 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); - tempax = tempbx & 0xFF00; - tempbx = pushbx; - tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); - tempax |= (tempbx & 0xFF00); - temp = (tempax & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0C,temp); /* TW: Overflow */ + 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++; + } + } - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0D,temp); /* TW: CRT2 Horizontal Retrace End */ + i--; - /* 2. Vertical setup */ + 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; + } + } - tempcx = SiS_Pr->SiS_VGAVT - 1; - temp = tempcx & 0x00FF; - /* TW: Matches 650/301LV, 650/LVDS, 630/LVDS(CLEVO), 630/LVDS(no-Ch7005) */ - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO|SetCRT2ToAVIDEO)) { - temp--; - } - } - } else { - temp--; - } - } else if(HwDeviceExtension->jChipType >= SIS_315H) { - /* TW: Inserted from 650/301LVx 1.10.6s */ - temp--; - } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0E,temp); /* TW: CRT2 Vertical Total */ - tempbx = SiS_Pr->SiS_VGAVDE - 1; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0F,temp); /* TW: CRT2 Vertical Display Enable End */ + return(RefreshRateTableIndex + i); +} - temp = ((tempbx & 0xFF00) << 3) >> 8; - temp |= ((tempcx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x12,temp); /* TW: Overflow (and HWCursor Test Mode) */ +/*********************************************/ +/* STORE CRT2 INFO in CR34 */ +/*********************************************/ - /* TW: For 650/LVDS (1.10.07), 650/301LVx (1.10.6s) */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - tempbx++; - tempax = tempbx; - tempcx++; - tempcx -= tempax; - tempcx >>= 2; - tempbx += tempcx; - if(tempcx < 4) tempcx = 4; - tempcx >>= 2; - tempcx += tempbx; - tempcx++; - } else { - /* TW: For 300/630/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 */ - } +static void +SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo) +{ + USHORT temp1,temp2; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){ - tempbx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[8]; - temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7]; - if(temp & 0x04) tempbx |= 0x0100; - if(temp & 0x80) tempbx |= 0x0200; - temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]; - if(temp & 0x08) tempbx |= 0x0400; - temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9]; - tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); - } - } - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp); /* TW: CRT2 Vertical Retrace Start */ + /* 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); +} - temp = ((tempbx & 0xFF00) >> 8) << 4; - temp |= (tempcx & 0x000F); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x11,temp); /* TW: CRT2 Vert. Retrace End; Overflow; "Enable CRTC Check" */ +/*********************************************/ +/* HELPER: GET SOME DATA FROM BIOS ROM */ +/*********************************************/ - /* 3. Panel compensation delay */ +static BOOLEAN +SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT temp,temp1; + UCHAR *ROMAddr; - if(HwDeviceExtension->jChipType < SIS_315H) { + if((ROMAddr = (UCHAR *)HwInfo->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xff) >> 4); + temp1 = (ROMAddr[0x23c] << 8) | ROMAddr[0x23b]; + if(temp1 & temp) return(1); + } + } + return(0); +} -#ifdef SIS300 /* ---------- 300 series -------------- */ +static BOOLEAN +SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT temp,temp1; + UCHAR *ROMAddr; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - temp = 0x20; + if((ROMAddr = (UCHAR *)HwInfo->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xff) >> 4); + temp1 = (ROMAddr[0x23e] << 8) | ROMAddr[0x23d]; + if(temp1 & temp) return(1); + } + } + return(0); +} - if(HwDeviceExtension->jChipType == SIS_300) { - temp = 0x10; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) temp = 0x2c; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) temp = 0x24; - } - if(SiS_Pr->SiS_VBType & VB_SIS301) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20; - } -#if 0 /* TW: Not in 630/301B BIOS */ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) temp = 0x24; -#endif - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x08; -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c; - else temp = 0x20; - } -#endif - if((ROMAddr) && (SiS_Pr->SiS_UseROM) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - if(ROMAddr[0x220] & 0x80) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV-SetCRT2ToHiVisionTV)) - temp = ROMAddr[0x221]; - else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) - temp = ROMAddr[0x222]; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) - temp = ROMAddr[0x223]; - else - temp = ROMAddr[0x224]; - temp &= 0x3c; - } - } - if(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; - } - } - } +/*********************************************/ +/* HELPER: DELAY FUNCTIONS */ +/*********************************************/ - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x03C,temp); /* TW: Panel Link Delay Compensation; (Software Command Reset; Power Saving) */ +void +SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime) +{ + USHORT i; -#endif /* SIS300 */ + for(i=0; i<delaytime; i++) { + SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); + } +} - } else { +static void +SiS_GenericDelay(SiS_Private *SiS_Pr, USHORT delay) +{ + USHORT temp,flag; -#ifdef SIS315H /* ----------- 310/325 series ---------------*/ + flag = SiS_GetRegByte(0x61) & 0x10; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - temp = 0x10; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) temp = 0x2c; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) temp = 0x24; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x08; - tempbl = 0xF0; - } else { - temp = 0x00; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x0a; - tempbl = 0xF0; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempbl = 0x0F; - } - } -#if 0 /* TW: Not done in 650/301LVx 1.10.6s */ - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - temp >>= 2; - } + while(delay) { + temp = SiS_GetRegByte(0x61) & 0x10; + if(temp == flag) continue; + flag = temp; + delay--; + } +} + +#ifdef SIS315H +static void +SiS_LongDelay(SiS_Private *SiS_Pr, USHORT delay) +{ + while(delay--) { + SiS_GenericDelay(SiS_Pr,0x19df); + } +} #endif - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,tempbl,temp); /* TW: Panel Link Delay Compensation */ - tempax = 0; - if (modeflag & DoubleScanMode) tempax |= 0x80; - if (modeflag & HalfDCLK) tempax |= 0x40; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax); +static void +SiS_ShortDelay(SiS_Private *SiS_Pr, USHORT delay) +{ + while(delay--) { + SiS_GenericDelay(SiS_Pr,0x42); + } +} -#endif /* SIS315H */ +static void +SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT PanelID, DelayIndex, Delay=0; - } + if(HwInfo->jChipType < SIS_315H) { - } /* Slavemode */ +#ifdef SIS300 + + PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x18) & 0x10)) PanelID = 0x12; + } + DelayIndex = PanelID >> 4; + if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { + Delay = 3; + } else { + if(DelayTime >= 2) DelayTime -= 2; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + 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); - /* TW: 630/301B BIOS sets up Panel Link, too! (300/301LV and 650/LV do not) */ - if( (HwDeviceExtension->jChipType < SIS_315H) && - (HwDeviceExtension->jChipType != SIS_300) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) { +#endif /* SIS300 */ - SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); + } else { - } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { +#ifdef SIS315H - SiS_SetGroup1_301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); - } + if(HwInfo->jChipType >= SIS_330) return; - } 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 */ - if(HwDeviceExtension->jChipType < SIS_315H) { - SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); - } else { - /* TW: For 650/LVDS */ - 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); - } + 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 { - SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - HwDeviceExtension,RefreshRateTableIndex); + DelayIndex = PanelID >> 4; } - } + if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { + Delay = 3; + } else { + if(DelayTime >= 2) DelayTime -= 2; + if(!(DelayTime & 0x01)) { + Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[0]; + } else { + Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[1]; + } + if((ROMAddr) && (SiS_Pr->SiS_UseROM)) { + if(ROMAddr[0x13c] & 0x40) { + if(!(DelayTime & 0x01)) { + Delay = (USHORT)ROMAddr[0x17e]; + } else { + Delay = (USHORT)ROMAddr[0x17f]; + } + } + } + } + SiS_ShortDelay(SiS_Pr,Delay); + } - } - } /* LCDA */ -} + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 315 series, 301(B) */ -/* TW: Checked against 650/301LV and 630/301B (II) BIOS */ -/* TW: Pass 2: Checked with 650/301LVx (1.10.6s) and 630/301B (2.04.5a) */ -void -SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex) -{ - USHORT push1,push2; - USHORT tempax,tempbx,tempcx,temp; - USHORT resinfo,modeflag; + PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); + DelayIndex = PanelID >> 4; + if(!(DelayTime & 0x01)) { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; + } else { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; + } + SiS_DDC2Delay(SiS_Pr, Delay * 4); - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } + } - /* TW: The following is only done if bridge is in slave mode: */ +#endif /* SIS315H */ - tempax = 0xFFFF; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempax = SiS_GetVGAHT2(SiS_Pr); + } +} - /* TW: 630/301B, 300/301LV do not check this flag, assume it is set */ - /* 650/LV and 650/301LVx BIOS do not check this either; so we set it... */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - modeflag |= Charx8Dot; - } +#ifdef SIS315H +static void +SiS_PanelDelayLoop(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT DelayTime, USHORT DelayLoop) +{ + int i; + for(i=0; i<DelayLoop; i++) { + SiS_PanelDelay(SiS_Pr, HwInfo, DelayTime); + } +} +#endif - if(modeflag & Charx8Dot) tempcx = 0x08; - else tempcx = 0x09; +/*********************************************/ +/* HELPER: WAIT-FOR-RETRACE FUNCTIONS */ +/*********************************************/ - if(tempax >= SiS_Pr->SiS_VGAHT) tempax = SiS_Pr->SiS_VGAHT; +void +SiS_WaitRetrace1(SiS_Private *SiS_Pr) +{ + USHORT watchdog; - if(modeflag & HalfDCLK) tempax >>= 1; + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return; - tempax = (tempax / tempcx) - 5; - tempbx = tempax & 0xFF; + if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80)) return; - temp = 0xFF; /* set MAX HT */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,temp); + watchdog = 65535; + while((SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08) && --watchdog); + watchdog = 65535; + while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); +} - tempax = SiS_Pr->SiS_VGAHDE; /* 0x04 Horizontal Display End */ - if(modeflag & HalfDCLK) tempax >>= 1; - tempax = (tempax / tempcx) - 1; - tempbx |= ((tempax & 0x00FF) << 8); - temp = tempax & 0xFF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x04,temp); +static void +SiS_WaitRetrace2(SiS_Private *SiS_Pr, USHORT reg) +{ + USHORT watchdog; - temp = (tempbx & 0xFF00) >> 8; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - temp += 2; - } -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(resinfo == 7) temp -= 2; - } + watchdog = 65535; + while((SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02) && --watchdog); + watchdog = 65535; + while((!(SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02)) && --watchdog); +} + +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 } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x05,temp); /* 0x05 Horizontal Display Start */ +} - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x06,0x03); /* 0x06 Horizontal Blank end */ +static void +SiS_VBWait(SiS_Private *SiS_Pr) +{ + USHORT tempal,temp,i,j; -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - temp = (tempbx & 0x00FF) - 1; - if(!(modeflag & HalfDCLK)) { - temp -= 6; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - temp -= 2; - if(ModeNo > 0x13) temp -= 10; - } - } - } else { -#endif - 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; - /* TW: Inserted from 650/301 BIOS, 630/301B/301 don't do this */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VGAHDE == 800) temp += 2; - } - } - } - } else { - if(!(modeflag & HalfDCLK)) { - temp -= 4; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) { - if(SiS_Pr->SiS_VGAHDE >= 800){ - temp -= 7; - if(HwDeviceExtension->jChipType < SIS_315H) { - /* 650/301LV(x) does not do this, 630/301B, 300/301LV do */ - if(SiS_Pr->SiS_ModeType == ModeEGA){ - if(SiS_Pr->SiS_VGAVDE == 1024){ - temp += 15; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) temp += 7; - } - } - } - if(SiS_Pr->SiS_VGAHDE >= 1280){ - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) { - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) temp += 28; - } - } - } - } + temp = 0; + for(i=0; i<3; i++) { + for(j=0; j<100; j++) { + tempal = SiS_GetRegByte(SiS_Pr->SiS_P3da); + if(temp & 0x01) { + if((tempal & 0x08)) continue; + if(!(tempal & 0x08)) break; + } else { + if(!(tempal & 0x08)) continue; + if((tempal & 0x08)) break; } } -#ifdef oldHV + temp ^= 0x01; } -#endif - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,temp); /* 0x07 Horizontal Retrace Start */ - - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x00); /* 0x08 Horizontal Retrace End */ +} +static void +SiS_VBLongWait(SiS_Private *SiS_Pr) +{ if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - if(ModeNo <= 1) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x2a); - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x61); - } else { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x41); - } - } else if(SiS_Pr->SiS_ModeType == ModeText) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x54); - } else { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x55); - } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x00); - } else if(ModeNo <= 0x13) { - if(modeflag & HalfDCLK) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x30); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x03); - } else { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x2f); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x02); - } - } else { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x5b); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x03); - } - } else if( ((HwDeviceExtension->jChipType >= SIS_315H) && (ModeNo == 0x50)) || - ((HwDeviceExtension->jChipType < SIS_315H) && (resinfo == 0 || resinfo == 1)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x30); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x03); - } else { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x2f); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x03); - } - } - - } + SiS_VBWait(SiS_Pr); + } else { + SiS_WaitRetrace1(SiS_Pr); } +} - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x03); /* 0x18 SR08 */ +/*********************************************/ +/* HELPER: MISC */ +/*********************************************/ - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x19,0xF0); +static BOOLEAN +SiS_Is301B(SiS_Private *SiS_Pr) +{ + USHORT flag; - tempbx = SiS_Pr->SiS_VGAVT; - push1 = tempbx; + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); + if(flag >= 0xb0) return TRUE; + else return FALSE; +} - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x09,0xFF); /* 0x09 Set Max VT */ +static BOOLEAN +SiS_CRT2IsLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - tempcx = 0x121; - tempbx = SiS_Pr->SiS_VGAVDE; /* 0x0E Vertical Display End */ - if(tempbx == 357) tempbx = 350; - if(tempbx == 360) tempbx = 350; - if(tempbx == 375) tempbx = 350; - if(tempbx == 405) tempbx = 400; - if(tempbx == 420) tempbx = 400; - if(tempbx == 525) tempbx = 480; - push2 = tempbx; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if(tempbx == 350) tempbx += 5; - if(tempbx == 480) tempbx += 5; - } - } + if(HwInfo->jChipType == SIS_730) { + flag = SiS_GetReg(SiS_Pr->SiS_P3c4,0x13); + if(flag & 0x20) return TRUE; } - tempbx--; - temp = tempbx & 0x00FF; - tempbx--; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp); /* 0x10 vertical Blank Start */ + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & 0x20) return TRUE; + return FALSE; +} - tempbx = push2; - tempbx--; - temp = tempbx & 0x00FF; -#if 0 - /* TW: Missing code from 630/301B 2.04.5a and 650/301LVx 1.10.6s (calles int 2f) */ - if(xxx()) { - if(temp == 0xdf) temp = 0xda; - } -#endif - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0E,temp); +BOOLEAN +SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ +#ifdef SIS315H + USHORT flag; - if(tempbx & 0x0100) { - tempcx |= 0x0002; - if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x000a; + if(HwInfo->jChipType >= SIS_315H) { + if((HwInfo->jChipType != SIS_650) || (SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & EnableDualEdge) return TRUE; + } } +#endif + return FALSE; +} - tempax = 0x000B; - if(modeflag & DoubleScanMode) tempax |= 0x8000; +BOOLEAN +SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ +#ifdef SIS315H + USHORT flag; - if(tempbx & 0x0200) { - tempcx |= 0x0040; - if(SiS_Pr->SiS_VBType & VB_SIS301) tempax |= 0x2000; + if(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if((flag & EnableDualEdge) && (flag & SetToLCDA)) return TRUE; } +#endif + return FALSE; +} - if(SiS_Pr->SiS_VBType & VB_SIS301) { - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - if(SiS_Pr->SiS_VGAVDE == 480) { - tempax = (tempax & 0x00ff) | 0x2000; - if(modeflag & DoubleScanMode) tempax |= 0x8000; - } - } +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; +} - temp = (tempax & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp); +#ifdef SIS315H +static BOOLEAN +SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - if(tempbx & 0x0400) tempcx |= 0x0600; + if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x79); + if(flag & 0x10) return TRUE; + } + return FALSE; +} +#endif - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x11,0x00); /* 0x11 Vertical Blank End */ +#ifdef SIS315H +static BOOLEAN +SiS_IsNotM650orLater(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - tempax = push1; - tempax -= tempbx; - tempax >>= 2; - push1 = tempax; + 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 return TRUE; + } else if(HwInfo->jChipType >= SIS_661) return FALSE; + return TRUE; +} +#endif - if(HwDeviceExtension->jChipType >= SIS_315H) { - /* TW: Inserted from 650/301LVx 1.10.6s */ - if(ModeNo > 0x13) { - if(resinfo != 0x09) { - tempax <<= 1; - tempbx += tempax; - } - } else { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) { - tempax <<= 1; - tempbx += tempax; - } - } - } else if((resinfo != 0x09) || (SiS_Pr->SiS_VBType & VB_SIS301)) { - tempax <<= 1; - tempbx += tempax; +#ifdef SIS315H +static BOOLEAN +SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; + + if(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & EnableLVDSHiVision) return TRUE; /* = YPrPb = 0x08 */ } -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - tempbx -= 10; - } else { + return FALSE; +} #endif - 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; - } - } - } - } -#ifdef oldHV + +#ifdef SIS315H +static BOOLEAN +SiS_IsChScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; + + if(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & EnableLVDSScart) return TRUE; /* = Scart = 0x04 */ } + return FALSE; +} #endif - tempax = push1; - tempax >>= 2; - tempax++; - tempax += tempbx; - push1 = tempax; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - if(tempbx <= 513) { - if(tempax >= 513) tempbx = 513; - } - } - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0C,temp); /* 0x0C Vertical Retrace Start */ - if(!(SiS_Pr->SiS_VBType & VB_SIS301)) { - tempbx--; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp); +#ifdef SIS315H +static BOOLEAN +SiS_IsTVOrYPbPrOrScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - if(tempbx & 0x0100) tempcx |= 0x0008; + if(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToTV) return TRUE; + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & EnableLVDSHiVision) return TRUE; /* = YPrPb = 0x08 */ + if(flag & EnableLVDSScart) return TRUE; /* = Scart = 0x04 - TW */ + } else { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToTV) return TRUE; + } + return FALSE; +} +#endif - if(tempbx & 0x0200) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20); - } +#ifdef SIS315H +static BOOLEAN +SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - tempbx++; - } - if(tempbx & 0x0100) tempcx |= 0x0004; - if(tempbx & 0x0200) tempcx |= 0x0080; - if(tempbx & 0x0400) { - if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x0800; - else tempcx |= 0x0C00; + if(HwInfo->jChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToLCD) return TRUE; + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & SetToLCDA) return TRUE; + } else { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToLCD) return TRUE; } + return FALSE; +} +#endif - tempbx = push1; - temp = tempbx & 0x00FF; - temp &= 0x0F; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0D,temp); /* 0x0D vertical Retrace End */ - - if(tempbx & 0x0010) tempcx |= 0x2000; +static BOOLEAN +SiS_BridgeIsOn(SiS_Private *SiS_Pr) +{ + USHORT flag; - temp = tempcx & 0x00FF; - if(SiS_Pr->SiS_VBType & VB_SIS301) { - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - if(SiS_Pr->SiS_VGAVDE == 480) temp = 0xa3; - } + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + return FALSE; + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); + if((flag == 1) || (flag == 2)) return FALSE; + else return TRUE; } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp); /* 0x0A CR07 */ + return TRUE; +} - temp = (tempcx & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,temp); /* 0x17 SR0A */ +static BOOLEAN +SiS_BridgeIsEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT flag; - tempax = modeflag; - temp = (tempax & 0xFF00) >> 8; - temp = (temp >> 1) & 0x09; - /* TW: Inserted from 630/301B and 650/301(LV/LVX) BIOS; not in 630/301 BIOS */ - if(!(SiS_Pr->SiS_VBType & VB_SIS301)) { - temp |= 0x01; + if(!(SiS_BridgeIsOn(SiS_Pr))) { + flag = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + if(HwInfo->jChipType < SIS_315H) { + flag &= 0xa0; + if((flag == 0x80) || (flag == 0x20)) return FALSE; + } else { + flag &= 0x50; + if((flag == 0x40) || (flag == 0x10)) return FALSE; + } } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,temp); /* 0x16 SR01 */ + return TRUE; +} + +static BOOLEAN +SiS_BridgeInSlave(SiS_Private *SiS_Pr) +{ + USHORT flag1; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* 0x0F CR14 */ + flag1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); + if(flag1 & (SetInSlaveMode >> 8)) return TRUE; + return FALSE; +} - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x12,0x00); /* 0x12 CR17 */ +/*********************************************/ +/* GET VIDEO BRIDGE CONFIG INFO */ +/*********************************************/ - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - /* TW: Inserted from 650/301LVx 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 */ +/* Setup general purpose IO for Chrontel communication */ +void +SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo) +{ + unsigned long acpibase; + unsigned short temp; - return; + 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)); } -/* TW: Checked against 650/LVDS 1.10.07, 630/301B (I,II) and 630/LVDS BIOS */ void -SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT RefreshRateTableIndex) +SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, + USHORT ModeIdIndex,PSIS_HW_INFO HwInfo, + int checkcrt2mode) { - USHORT modeflag, resinfo; - USHORT push1, push2, tempax, tempbx, tempcx, temp; -#ifdef SIS315H - USHORT pushcx; -#endif - ULONG tempeax=0, tempebx, tempecx, tempvcfact=0; + USHORT tempax,tempbx,temp; + USHORT modeflag, resinfo=0; - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } } - /* TW: Set up Panel Link */ - - /* 1. Horizontal setup */ + SiS_Pr->SiS_SetFlag = 0; - tempax = SiS_Pr->SiS_LCDHDES; + SiS_Pr->SiS_ModeType = modeflag & ModeInfoFlag; - if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { - tempax -= 8; - } + tempbx = 0; + if(SiS_BridgeIsOn(SiS_Pr) == 0) { + temp = SiS_GetReg(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 | SwitchCRT2 | SetSimuScanMode); /* 0x83 */ + temp |= SetCRT2ToHiVisionTV; /* 0x80 */ + } + if(SiS_Pr->SiS_HiVision & 0x04) { /* New from 650/30xLV 1.10.6s */ + temp &= (SetCRT2ToHiVisionTV | SwitchCRT2 | SetSimuScanMode); /* 0x83 */ + temp |= SetCRT2ToSVIDEO; /* 0x08 */ + } + } +#endif + tempbx |= temp; + tempax = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) << 8; + tempax &= (LoadDACFlag | DriverMode | SetDispDevSwitch | SetNotSimuMode | SetPALTV); + tempbx |= tempax; + tempbx &= ~(SetCHTVOverScan | SetInSlaveMode | DisableCRT2Display);; - tempcx = SiS_Pr->SiS_HT; /* Horiz. Total */ +#ifdef SIS315H + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302B | VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { + if(ModeNo == 0x03) { + /* Mode 0x03 is never in driver mode */ + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x31,0xbf); + } + if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8))) { + /* Reset LCDA setting */ + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); + } + if(IS_SIS650) { + if(SiS_Pr->SiS_UseLCDA) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xF0) { + if((ModeNo <= 0x13) || (!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8)))) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA)); + } + } + } + } + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) { + tempbx |= SetCRT2ToLCDA; + } + } - tempbx = SiS_Pr->SiS_HDE; /* Horiz. Display End */ + 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 & EnableLVDSHiVision) { + tempbx |= SetCRT2ToHiVisionTV; + } + } + } + } - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) { - if(!SiS_Pr->SiS_IF_DEF_DSTN) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempbx = 800; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx = 1024; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempbx = 1024; /* TW: not done in BIOS */ - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) tempbx = 1152; /* TW: not done in BIOS */ - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempbx = 1280; /* TW */ - else if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) tempbx = 1400; /* TW */ - } - } - tempcx = (tempcx - tempbx) >> 2; /* HT-HDE / 4 */ +#endif /* SIS315H */ - push1 = tempax; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp = SetCRT2ToSVIDEO | + SetCRT2ToAVIDEO | + SetCRT2ToSCART | + SetCRT2ToLCDA | + SetCRT2ToLCD | + SetCRT2ToRAMDAC | + SetCRT2ToHiVisionTV; + } else { + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + temp = SetCRT2ToAVIDEO | + SetCRT2ToSVIDEO | + SetCRT2ToSCART | + SetCRT2ToLCDA | + SetCRT2ToLCD | + SetCRT2ToHiVisionTV; + } else { + temp = SetCRT2ToLCDA | + SetCRT2ToLCD; + } + } else { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + temp = SetCRT2ToTV | SetCRT2ToLCD; + } else { + temp = SetCRT2ToLCD; + } + } + } - tempax += tempbx; + if(!(tempbx & temp)) { + tempax = DisableCRT2Display; + tempbx = 0; + } - if(tempax >= SiS_Pr->SiS_HT) tempax -= SiS_Pr->SiS_HT; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(tempbx & SetCRT2ToLCDA) { + tempbx &= (0xFF00|SwitchCRT2|SetSimuScanMode); + } + if(tempbx & SetCRT2ToRAMDAC) { + tempbx &= (0xFF00|SetCRT2ToRAMDAC|SwitchCRT2|SetSimuScanMode); + } + if(tempbx & SetCRT2ToLCD) { + tempbx &= (0xFF00|SetCRT2ToLCD|SwitchCRT2|SetSimuScanMode); + } + if(tempbx & SetCRT2ToSCART) { + tempbx &= (0xFF00|SetCRT2ToSCART|SwitchCRT2|SetSimuScanMode); + } + if(tempbx & SetCRT2ToHiVisionTV) { + tempbx &= (0xFF00|SetCRT2ToHiVisionTV|SwitchCRT2|SetSimuScanMode); + } + } 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; + } + } + } - push2 = tempax; + if(tempax & DisableCRT2Display) { + if(!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { + tempbx = SetSimuScanMode | DisableCRT2Display; + } + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(!SiS_Pr->SiS_IF_DEF_DSTN){ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x0028; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0030; - 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; other 301B BIOS 0x0018; */ - } - } else { - tempcx = 0x0018; - } - } - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempcx = 0x0018; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0040; - else if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) tempcx = 0x0030; - } - } + if(!(tempbx & DriverMode)){ + tempbx |= SetSimuScanMode; + } - tempcx += tempax; /* lcdhrs */ - if(tempcx >= SiS_Pr->SiS_HT) tempcx -= SiS_Pr->SiS_HT; + /* LVDS/CHRONTEL (LCD/TV) and 301BDH (LCD) can only be slave in 8bpp modes */ + if(SiS_Pr->SiS_ModeType <= ModeVGA) { + if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || + ((tempbx & SetCRT2ToLCD) && (SiS_Pr->SiS_VBType & VB_NoLCD)) ) { + modeflag &= (~CRT2Mode); + } + } - tempax = tempcx >> 3; /* BPLHRS */ - temp = tempax & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,temp); /* Part1_14h; TW: Panel Link Horizontal Retrace Start */ + if(!(tempbx & SetSimuScanMode)) { + if(tempbx & SwitchCRT2) { + if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { + if( (HwInfo->jChipType >= SIS_315H) && + (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { + if(resinfo != SIS_RI_1600x1200) { + tempbx |= SetSimuScanMode; + } + } else { + tempbx |= SetSimuScanMode; + } + } + } else { + if(!(SiS_BridgeIsEnabled(SiS_Pr,HwInfo))) { + if(!(tempbx & DriverMode)) { + if(SiS_BridgeInSlave(SiS_Pr)) { + tempbx |= SetSimuScanMode; + } + } + } + } + } - temp = (tempax & 0x00FF) + 10; + 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; + } + } - /* TW: Inserted this entire "if"-section from 650/LVDS BIOS */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(!SiS_Pr->SiS_IF_DEF_DSTN){ - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - temp += 6; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) { - temp++; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1024x768) { - temp += 7; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) { - temp -= 10; - } - } - } - } - } - } } - temp &= 0x1F; - temp |= ((tempcx & 0x0007) << 5); - if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0x20; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x15,temp); /* Part1_15h; TW: Panel Link Horizontal Retrace End/Skew */ - - tempbx = push2; - tempcx = push1; /* lcdhdes */ - - temp = (tempcx & 0x0007); /* BPLHDESKEW */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1A,temp); /* Part1_1Ah; TW: Panel Link Vertical Retrace Start (2:0) */ - - tempcx >>= 3; /* BPLHDES */ - temp = (tempcx & 0x00FF); - if(ModeNo == 0x5b) temp--; /* fix fstn mode=5b */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,temp); /* Part1_16h; TW: Panel Link Horizontal Display Enable Start */ + SiS_Pr->SiS_VBInfo = tempbx; - if(HwDeviceExtension->jChipType < SIS_315H) { /* TW: Not done in LVDS BIOS 1.10.07 */ - if(tempbx & 0x07) tempbx += 8; /* TW: Done in 630/301B and 630/LVDS BIOSes */ + if(HwInfo->jChipType == SIS_630) { + SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo); } - tempbx >>= 3; /* BPLHDEE */ - temp = tempbx & 0x00FF; - if(ModeNo == 0x5b) temp--; /* fix fstn mode=5b */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,temp); /* Part1_17h; TW: Panel Link Horizontal Display Enable End */ - /* 2. Vertical setup */ +#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 +} - if(HwDeviceExtension->jChipType < SIS_315H) { - - /* TW: This entire section from 630/301B and 630/LVDS/LVDS+CH BIOS */ - tempcx = SiS_Pr->SiS_VGAVT; - tempbx = SiS_Pr->SiS_VGAVDE; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { - tempbx = 600; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) { - tempbx = 768; - if( (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1024x768) && - (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1152x768) ) { - tempbx = 600; - } - } - } - } - tempcx -= tempbx; +/*********************************************/ +/* DETERMINE HiVision MODE */ +/*********************************************/ - } else { +void +SiS_SetHiVision(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ +#ifdef SIS315H + USHORT temp; +#endif - tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE; /* VGAVT-VGAVDE */ + /* Note: This variable is only used on 30xLV systems. + CR38 has a different meaning on LVDS/CH7019 systems. + */ + SiS_Pr->SiS_HiVision = 0; +#ifdef SIS315H + if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + temp &= 0x38; + SiS_Pr->SiS_HiVision = (temp >> 3); + } + } } +#endif /* SIS315H */ +} - tempbx = SiS_Pr->SiS_LCDVDES; /* VGAVDES */ - push1 = tempbx; +/*********************************************/ +/* DETERMINE TVMode flag */ +/*********************************************/ - tempax = SiS_Pr->SiS_VGAVDE; +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; - if((SiS_Pr->SiS_IF_DEF_TRUMPION == 0) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11)) - && (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480)) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(!SiS_Pr->SiS_IF_DEF_DSTN){ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempax = 600; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempax = 768; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempax = 600; /* TW */ - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) tempax = 768; /* TW */ - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempax = 1024; /* TW */ - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempax = 1050; /* TW */ - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempax = 1200; /* TW */ - else tempax = 600; - } - } - } + SiS_Pr->SiS_TVMode = 0; - tempbx += tempax; - if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; + if(SiS_Pr->UseCustomMode) return; - push2 = tempbx; + if(ModeNo > 0x13) { + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } - tempcx >>= 1; + if(HwInfo->jChipType < SIS_661) { - if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480)){ - if(!SiS_Pr->SiS_IF_DEF_DSTN){ - if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) ) { /* TW: @@@ TEST - not in BIOS! */ - tempcx = 0x0001; - } else if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) ) { - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - tempcx = 0x0002; -#ifdef TWNEWPANEL - tempcx = 0x0003; -#endif - } else { - tempcx = 0x0002; /* TW: A901; other 301B BIOS sets 0x0003; */ - } - } else tempcx = 0x0003; + if(SiS_Pr->SiS_VBInfo & SetPALTV) SiS_Pr->SiS_TVMode |= TVSetPAL; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp = 0; + if((HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730)) { + temp = 0x35; + romindex = 0xfe; + } else if(HwInfo->jChipType >= SIS_315H) { + temp = 0x38; + romindex = 0xf3; + if(HwInfo->jChipType >= SIS_330) romindex = 0x11b; + } + if(temp) { + if(romindex && ROMAddr && SiS_Pr->SiS_UseROM) { + OutputSelect = ROMAddr[romindex]; + if(!(OutputSelect & EnablePALMN)) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,temp,0x3F); + } + } + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,temp); + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + if(temp1 & EnablePALM) { /* 0x40 */ + SiS_Pr->SiS_TVMode |= TVSetPALM; + SiS_Pr->SiS_TVMode &= ~TVSetPAL; + } else if(temp1 & EnablePALN) { /* 0x80 */ + SiS_Pr->SiS_TVMode |= TVSetPALN; + } + } else { + if(temp1 & EnableNTSCJ) { /* 0x40 */ + SiS_Pr->SiS_TVMode |= TVSetNTSCJ; + } + } + } + } else if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_CHOverScan) { + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + if((temp & TVOverScan) || (SiS_Pr->SiS_CHOverScan == 1)) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x79); + if((temp & 0x80) || (SiS_Pr->SiS_CHOverScan == 1)) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } + if(SiS_Pr->SiS_CHSOverScan) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } } - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 0x0003; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0001; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0001; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0001; - else tempcx = 0x0057; + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + if(temp & EnablePALM) SiS_Pr->SiS_TVMode |= TVSetPALM; + else if(temp & EnablePALN) SiS_Pr->SiS_TVMode |= TVSetPALN; + } else { + if(temp & EnableNTSCJ) { + SiS_Pr->SiS_TVMode |= TVSetNTSCJ; + } + } + } } - } - tempbx += tempcx; /* BPLVRS */ + } else { /* 661 and later */ - if(HwDeviceExtension->jChipType < SIS_315H) { - tempbx++; + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + if(temp1 & 0x01) { + SiS_Pr->SiS_TVMode |= TVSetPAL; + if(temp1 & 0x08) { + SiS_Pr->SiS_TVMode |= TVSetPALN; + } else if(temp1 & 0x04) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_Pr->SiS_TVMode &= ~TVSetPAL; + } + SiS_Pr->SiS_TVMode |= TVSetPALM; + } + } else { + if(temp1 & 0x02) { + SiS_Pr->SiS_TVMode |= TVSetNTSCJ; + } + } + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(SiS_Pr->SiS_CHOverScan) { + if((temp1 & 0x10) || (SiS_Pr->SiS_CHOverScan == 1)) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } + } } - if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; - - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,temp); /* Part1_18h; TW: Panel Link Vertical Retrace Start */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) SiS_Pr->SiS_TVMode |= TVSetPAL; - tempcx >>= 3; - - 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_Panel1400x1050) tempcx = 0x0002; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) 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_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_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { + SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; + } } - } - tempcx = tempcx + tempbx + 1; /* BPLVRE */ - temp = tempcx & 0x000F; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xf0,temp); /* Part1_19h; TW: Panel Link Vertical Retrace End (3:0); Misc. */ + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + if(resinfo == SIS_RI_1024x768) { + SiS_Pr->SiS_TVMode |= TVSetNTSC1024; + } + } - temp = ((tempbx & 0x0700) >> 8) << 3; /* BPLDESKEW =0 */ - if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40; - if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40; - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { /* TW: Inserted from 650/LVDS 1.10.07 */ - temp |= 0x80; - } - } else { - if( (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) ) { - if(HwDeviceExtension->jChipRevision >= 0x30) { - temp |= 0x80; - } - } - } + SiS_Pr->SiS_TVMode |= TVRPLLDIV2XO; + if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; + } + } } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x87,temp); /* Part1_1Ah; TW: Panel Link Control Signal (7:3); Vertical Retrace Start (2:0) */ - if (HwDeviceExtension->jChipType < SIS_315H) { + SiS_Pr->SiS_VBInfo &= ~SetPALTV; -#ifdef SIS300 /* 300 series */ +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "(init301.c: TVMode %x)\n", SiS_Pr->SiS_TVMode); +#endif - tempeax = SiS_Pr->SiS_VGAVDE << 6; - temp = (USHORT)(tempeax % (ULONG)SiS_Pr->SiS_VDE); - tempeax = tempeax / (ULONG)SiS_Pr->SiS_VDE; - if(temp != 0) tempeax++; - tempebx = tempeax; /* BPLVCFACT */ +} - if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) { - tempebx = 0x003F; - } +/*********************************************/ +/* GET LCD INFO */ +/*********************************************/ - temp = (USHORT)(tempebx & 0x00FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1E,temp); /* Part1_1Eh; TW: Panel Link Vertical Scaling Factor */ +void +SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) +{ +#ifdef SIS300 + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; +#endif +#ifdef SIS315H + UCHAR *myptr = NULL; +#endif + USHORT temp,modeflag,resinfo=0; + const unsigned char SiS300SeriesLCDRes[] = + { 0, 1, 2, 3, 7, 4, 5, 8, + 0, 0, 10, 0, 0, 0, 0, 15 }; -#endif /* SIS300 */ + SiS_Pr->SiS_LCDResInfo = 0; + SiS_Pr->SiS_LCDTypeInfo = 0; + SiS_Pr->SiS_LCDInfo = 0; + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; } else { - -#ifdef SIS315H /* 310/325 series */ - - 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; TW: Panel Link Vertical Scaling Factor */ - temp = (USHORT)((tempebx & 0x00FF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x36,temp); /* Part1_36h; TW: Panel Link Vertical Scaling Factor */ - temp = (USHORT)((tempebx & 0x00030000) >> 16); - if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x35,temp); /* Part1_35h; TW: Panel Link Vertical Scaling Factor */ - -#endif /* SIS315H */ - + 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; + } } - tempbx = push2; /* p bx temppush1 BPLVDEE */ - tempcx = push1; + if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return; - push1 = temp; /* TW: For 630/301B and 630/LVDS */ + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(!SiS_Pr->SiS_IF_DEF_DSTN){ - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - if(resinfo == 15) tempcx++; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) { - if(resinfo == 7) tempcx++; - } - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - if(resinfo == 7) tempcx++; - if(resinfo == 8) tempcx++; /* TW: Doesnt make sense anyway... */ - } else if(resinfo == 8) tempcx++; - } else { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - if(resinfo == 7) tempcx++; - } - } - } + if((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) { - 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]; } + SiS_Pr->SiS_LCDResInfo = temp; - temp = ((tempbx & 0x0700) >> 8) << 3; - temp |= ((tempcx & 0x0700) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1D,temp); /* Part1_1Dh; TW: Vertical Display Overflow; Control Signal */ - - temp = tempbx & 0x00FF; - if(SiS_Pr->SiS_IF_DEF_FSTN) temp++; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1C,temp); /* Part1_1Ch; TW: Panel Link Vertical Display Enable End */ - - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1B,temp); /* Part1_1Bh; TW: Panel Link Vertical Display Enable Start */ - - /* 3. Additional horizontal setup (scaling, etc) */ + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMin301) + SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMin301; + } else { + if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMinLVDS) + SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMinLVDS; + } - tempecx = SiS_Pr->SiS_VGAHDE; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(modeflag & HalfDCLK) - tempecx >>= 1; + if((!SiS_Pr->CP_HaveCustomData) || (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_PanelCustom)) { + if(SiS_Pr->SiS_LCDResInfo > SiS_Pr->SiS_PanelMax) + SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_Panel1024x768; } - 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(modeflag & HalfDCLK) - tempeax >>= 1; - tempeax <<= 16; - tempeax = (tempeax / tempecx) - 1; + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_800x600: SiS_Pr->PanelXRes = 800; SiS_Pr->PanelYRes = 600; break; + case Panel_1024x768: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; break; + case Panel_1280x1024: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 1024; break; + case Panel_640x480_3: + case Panel_640x480_2: + case Panel_640x480: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; break; + case Panel_1024x600: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 600; break; + case Panel_1152x864: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 864; break; + case Panel_1280x960: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 960; break; + case Panel_1152x768: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 768; break; + case Panel_1400x1050: SiS_Pr->PanelXRes = 1400; SiS_Pr->PanelYRes = 1050; break; + case Panel_1280x768: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; break; + case Panel_1600x1200: SiS_Pr->PanelXRes = 1600; SiS_Pr->PanelYRes = 1200; break; + case Panel_320x480: SiS_Pr->PanelXRes = 320; SiS_Pr->PanelYRes = 480; break; + case Panel_Custom: SiS_Pr->PanelXRes = SiS_Pr->CP_MaxX; + SiS_Pr->PanelYRes = SiS_Pr->CP_MaxY; + break; + case Panel_Barco1366: SiS_Pr->PanelXRes = 1360; SiS_Pr->PanelYRes = 1024; break; + case Panel_848x480: SiS_Pr->PanelXRes = 848; SiS_Pr->PanelYRes = 480; break; + default: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; break; + } + + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + if(HwInfo->jChipType < SIS_661) { + temp &= ~0xe; } else { - tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1; +#ifdef SIS315H + if(!(temp & 0x10)) { + if(temp & 0x08) temp |= LCDPass11; + } + temp &= ~0xe; + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + myptr = GetLCDStructPtr661(SiS_Pr, HwInfo); + if(myptr) { + if(myptr[2] & 0x01) temp |= LCDDualLink; + } + } +#endif } - tempecx <<= 16; - tempecx |= (tempeax & 0xFFFF); - temp = (USHORT)(tempecx & 0x00FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1F,temp); /* Part1_1Fh; TW: Panel Link DDA Operational Number in each horiz. line */ + SiS_Pr->SiS_LCDInfo = temp; - tempbx = SiS_Pr->SiS_VDE; - if (HwDeviceExtension->jChipType >= SIS_315H) { - tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact; - tempbx = (USHORT)(tempeax & 0x0FFFF); - } else { - tempax = SiS_Pr->SiS_VGAVDE << 6; - tempbx = push1; - tempbx &= 0x3f; - if(tempbx == 0) tempbx = 64; - tempax = tempax / tempbx; - tempbx = tempax; + 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(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx--; - if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempbx = 1; - - temp = ((tempbx & 0xFF00) >> 8) << 3; - temp |= (USHORT)((tempecx & 0x0700) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x20,temp); /* Part1_20h; TW: Overflow register */ - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x21,temp); /* Part1_21h; TW: Panel Link Vertical Accumulator Register */ + if(!(SiS_Pr->UsePanelScaler)) SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; + else if(SiS_Pr->UsePanelScaler == 1) SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - tempecx >>= 16; /* BPLHCFACT */ - if(HwDeviceExtension->jChipType < SIS_315H) { - if(modeflag & HalfDCLK) tempecx >>= 1; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) { + /* For non-standard LCD resolution, we let the panel scale */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + if(ModeNo == 0x7c || ModeNo == 0x7d || ModeNo == 0x7e) { + /* We do not scale to 1280x960 (B/C bridges only) */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + /* No non-scaling data available for LV bridges */ + SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { + /* No idea about the timing and zoom factors */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + if(ModeNo == 0x3a || ModeNo == 0x4d || ModeNo == 0x65) { + /* We do not scale to 1280x1024 (all bridges) */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + /* No idea about the timing and zoom factors (C bridge only) */ + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; + } + } + } + } } - temp = (USHORT)((tempecx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x22,temp); /* Part1_22h; TW: Panel Link Horizontal Scaling Factor High */ - - temp = (USHORT)(tempecx & 0x00FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x23,temp); /* Part1_22h; TW: Panel Link Horizontal Scaling Factor Low */ - - /* 630/301B and 630/LVDS do something for 640x480 panels here */ + if(HwInfo->jChipType >= SIS_315H) { #ifdef SIS315H - /* TW: DSTN/FSTN initialisation - hardcoded for 320x480 panel */ - if(SiS_Pr->SiS_IF_DEF_DSTN) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1E,0x01); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x25,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x26,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x27,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x28,0x87); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x29,0x5A); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2A,0x4B); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x007,0x03); - tempbx = SiS_Pr->SiS_HDE + 64; /*Blps = lcdhdee(lcdhdes+HDE) + 64*/ - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x38,temp); - temp=((tempbx & 0xFF00) >> 8) << 3; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,~0x078,temp); - tempbx += 32; /*Blpe=lBlps+32*/ - temp = tempbx & 0x00FF; - if(SiS_Pr->SiS_IF_DEF_FSTN) temp=0; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x39,temp); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3A,0x00); /*Bflml=0*/ - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x007,0x00); - tempbx = SiS_Pr->SiS_VDE / 2; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3B,temp); - temp = ((tempbx & 0xFF00) >> 8) << 3; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x038,temp); - tempeax = SiS_Pr->SiS_HDE << 2; /* BDxFIFOSTOP = (HDE*4)/128 */ - tempebx = 128; - temp = (USHORT)(tempeax % tempebx); - tempeax = tempeax / tempebx; - if(temp != 0) tempeax++; - temp = (USHORT)(tempeax & 0x003F); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x45,~0x0FF,temp); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3F,0x00); /* BDxWadrst0 */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3E,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3D,0x10); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x040,0x00); - tempax = SiS_Pr->SiS_HDE >> 4; /* BDxWadroff = HDE*4/8/8 */ - pushcx = tempax; - temp = tempax & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x43,temp); - temp = ((tempax & 0xFF00) >> 8) << 3; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x0F8,temp); - tempax = SiS_Pr->SiS_VDE; /*BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */ - tempeax = (tempax * pushcx); - tempebx = 0x00100000 + tempeax; - temp = (USHORT)tempebx & 0x000000FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x42,temp); - temp = (USHORT)((tempebx & 0x0000FF00)>>8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x41,temp); - temp = (USHORT)((tempebx & 0x00FF0000)>>16); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x40,temp); - temp = (USHORT)(((tempebx & 0x01000000)>>24) << 7); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x080,temp); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2F,0x03); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,0x50); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x04,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2F,0x01); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x13,0x00); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); /* Unlock */ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1e,0x62); - if(SiS_Pr->SiS_IF_DEF_FSTN){ - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2b,0x1b); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2c,0xe3); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1e,0x62); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2e,0x04); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2f,0x42); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,0x01); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2b,0x02); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2c,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2d,0x00); - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0f,0x30); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1e,0x7d); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2e,0xe0); + if(HwInfo->jChipType < SIS_661) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x01) { + SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); + SiS_Pr->SiS_LCDInfo |= LCDPass11; + } + } +#endif + } else { +#ifdef SIS300 + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + if(!(ROMAddr[0x235] & 0x02)) { + SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); + } + } + } + } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10))) { + SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); + } + } +#endif } -#endif /* SIS315H */ - return; + /* Trumpion: Assume non-expanding */ + if(SiS_Pr->SiS_IF_DEF_TRUMPION != 0) { + SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); + } -} + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + SiS_Pr->SiS_LCDInfo &= (~LCDPass11); + } #ifdef SIS315H -void -SiS_CRT2AutoThreshold(SiS_Private *SiS_Pr, USHORT BaseAddr) -{ - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40); -} + if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + /* Enable 302LV/302ELV dual link mode. + * For 661, this is done above. + */ + if((SiS_Pr->SiS_CustomT == CUT_CLEVO1024) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)) { + /* (Sets this in SenseLCD; new paneltypes) */ + SiS_Pr->SiS_LCDInfo |= LCDDualLink; + } + if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) { + SiS_Pr->SiS_LCDInfo |= LCDDualLink; + } + } + } #endif + if(!((HwInfo->jChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) { -/* TW: For LVDS / 302b/lv - LCDA (this must only be called on 310/325 series!) */ -/* TW: Double-checked against 650/LVDS and 650/301 BIOS */ -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; + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { + if(ModeNo > 0x13) { + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + if((resinfo == SIS_RI_800x600) || (resinfo == SIS_RI_400x300)) { + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } + } + } + } + if(ModeNo == 0x12) { + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } + } + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* TW: From 650/LVDS BIOS */ - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04); /* TW: From 650/LVDS BIOS */ - } + if(modeflag & HalfDCLK) { + if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + if(!(((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (HwInfo->jChipType < SIS_315H)) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480))) { + if(ModeNo > 0x13) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(resinfo == SIS_RI_512x384) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { + if(resinfo == SIS_RI_400x300) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } + } + } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* TW: From 650/LVDS 1.10.07 */ - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x00); /* TW: From 650/LVDS 1.10.07 */ - } else { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2D,0x0f); /* TW: From 650/301Lvx 1.10.6s */ } - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) { + SiS_Pr->SiS_SetFlag |= LCDVESATiming; + } } 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 & LCDNonExpanding) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx = 1024; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempbx = 1400; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 1600; - else tempbx = 1280; - + SiS_Pr->SiS_SetFlag |= LCDVESATiming; } - 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; + SiS_Pr->SiS_LCDInfo661 = 0; + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) SiS_Pr->SiS_LCDInfo661 |= 0x0001; + if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) SiS_Pr->SiS_LCDInfo661 |= 0x0002; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) SiS_Pr->SiS_LCDInfo661 |= 0x0008; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) SiS_Pr->SiS_LCDInfo661 |= 0x0010; + SiS_Pr->SiS_LCDInfo661 |= (SiS_Pr->SiS_LCDInfo & 0xe0); + if(SiS_Pr->SiS_LCDInfo & LCDDualLink) SiS_Pr->SiS_LCDInfo661 |= 0x0100; - /* TW: Inserted from 650/301LVx 1.10.6s */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - 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_Panel1400x1050) tempcx = 0x30; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempcx = 0x18; - else tempcx = 0x30; - } - } - - 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; - 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 */ - - tempcx >>= 3; /* BPLHDES */ - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,temp); /* Part1_16h */ - - if(tempbx & 0x07) tempbx += 8; - 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; /* push bx temppush1 */ - if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0){ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempax = 768; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempax = 1024; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempax = 1050; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempax = 1200; - else tempax = 960; -#if 0 /* TW: Removed (650/LVDS BIOS) */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - tempax = SiS_Pr->SiS_VGAVDE; - } - } +#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 - } else tempax = SiS_Pr->SiS_VGAVDE; /* Trumpion */ - - tempbx += tempax; - tempax = SiS_Pr->SiS_VT; /* VT */ - if(tempbx >= tempax) tempbx -= tempax; - - push2 = tempbx; /* push bx temppush2 */ - tempcx >>= 2; /* TO CHECK - was 1 */ +#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 +} - /* TW: Inserted from 650/301LVx 1.10.6s */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - 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 tempcx = 0x0057; - } - } +/*********************************************/ +/* GET VCLK */ +/*********************************************/ - tempbx += tempcx; - tempbx++; /* BPLVRS */ - if(tempbx >= tempax) tempbx -= tempax; - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,temp); /* Part1_18h */ +USHORT +SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +{ + USHORT tempbx; + const USHORT LCDXlat0VCLK[4] = {VCLK40, VCLK40, VCLK40, VCLK40}; + const USHORT LVDSXlat1VCLK[4] = {VCLK40, VCLK40, VCLK40, VCLK40}; + const USHORT LVDSXlat4VCLK[4] = {VCLK28, VCLK28, VCLK28, VCLK28}; +#ifdef SIS300 + const USHORT LCDXlat1VCLK300[4] = {VCLK65_300, VCLK65_300, VCLK65_300, VCLK65_300}; + const USHORT LCDXlat2VCLK300[4] = {VCLK108_2_300,VCLK108_2_300,VCLK108_2_300,VCLK108_2_300}; + const USHORT LVDSXlat2VCLK300[4]= {VCLK65_300, VCLK65_300, VCLK65_300, VCLK65_300}; + const USHORT LVDSXlat3VCLK300[4]= {VCLK65_300, VCLK65_300, VCLK65_300, VCLK65_300}; +#endif +#ifdef SIS315H + const USHORT LCDXlat1VCLK310[4] = {VCLK65_315, VCLK65_315, VCLK65_315, VCLK65_315}; + const USHORT LCDXlat2VCLK310[4] = {VCLK108_2_315,VCLK108_2_315,VCLK108_2_315,VCLK108_2_315}; + const USHORT LVDSXlat2VCLK310[4]= {VCLK65_315, VCLK65_315, VCLK65_315, VCLK65_315}; + const USHORT LVDSXlat3VCLK310[4]= {VCLK108_2_315,VCLK108_2_315,VCLK108_2_315,VCLK108_2_315}; +#endif + USHORT CRT2Index,VCLKIndex=0; + USHORT modeflag,resinfo; + const UCHAR *CHTVVCLKPtr = NULL; + const USHORT *LCDXlatVCLK1 = NULL; + const USHORT *LCDXlatVCLK2 = NULL; + const USHORT *LVDSXlatVCLK2 = NULL; + const USHORT *LVDSXlatVCLK3 = NULL; - tempcx >>= 3; - tempcx += tempbx; - tempcx++; /* BPLVRE */ - temp = tempcx & 0x00FF; - temp &= 0x0F; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - /* TW: Inserted from 650/LVDS BIOS */ - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xf0,temp); + if(HwInfo->jChipType >= SIS_315H) { +#ifdef SIS315H + LCDXlatVCLK1 = LCDXlat1VCLK310; + LCDXlatVCLK2 = LCDXlat2VCLK310; + LVDSXlatVCLK2 = LVDSXlat2VCLK310; + LVDSXlatVCLK3 = LVDSXlat3VCLK310; +#endif } else { - /* TW: Inserted from 650/301LVx 1.10.6s */ - temp |= 0xC0; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp); /* Part1_19h */ +#ifdef SIS300 + LCDXlatVCLK1 = LCDXlat1VCLK300; + LCDXlatVCLK2 = LCDXlat2VCLK300; + LVDSXlatVCLK2 = LVDSXlat2VCLK300; + LVDSXlatVCLK3 = LVDSXlat3VCLK300; +#endif } - 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) { - /* TW: Inserted from 650/LVDS 1.10.07 */ - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) temp |= 0x80; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x87,temp); /* Part1_1Ah */ + 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 { - /* TW: Inserted from 650/301LVx 1.10.6s */ - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) temp |= 0x80; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x87,temp); /* Part1_1Ah */ + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + CRT2Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; } - tempbx = push2; /* p bx temppush2 BPLVDEE */ - tempcx = push1; /* pop cx temppush1 NPLVDES */ - push1 = (USHORT)(tempeax & 0xFFFF); + if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 30x/B/LV */ - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - if(resinfo == 7) tempcx++; - } - } - /* TW: Inserted from 650/301LVx+LVDS BIOSes */ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - tempbx = SiS_Pr->SiS_VGAVDE; - tempcx = tempbx; - tempbx--; - } + if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - temp = (tempbx & 0xFF00) >> 8; - temp &= 0x07; - temp <<= 3; - temp = temp | (((tempcx & 0xFF00) >> 8) & 0x07); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1D,temp); /* Part1_1Dh */ + CRT2Index >>= 6; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* LCD */ + + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { + VCLKIndex = LCDXlat0VCLK[CRT2Index]; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + VCLKIndex = LCDXlatVCLK1[CRT2Index]; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { + VCLKIndex = LCDXlatVCLK1[CRT2Index]; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { + VCLKIndex = LCDXlatVCLK1[CRT2Index]; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { + VCLKIndex = VCLK81_300; /* guessed */ + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { + VCLKIndex = VCLK108_3_300; + if(resinfo == SIS_RI_1280x1024) VCLKIndex = VCLK100_300; + } else { + VCLKIndex = LCDXlatVCLK2[CRT2Index]; + } + } else { + if( (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) || + (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + VCLKIndex = VCLK108_2_315; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { + VCLKIndex = VCLK81_315; /* guessed */ + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + VCLKIndex = VCLK108_2_315; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + VCLKIndex = VCLK162_315; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { + VCLKIndex = VCLK108_3_315; + if(resinfo == SIS_RI_1280x1024) VCLKIndex = VCLK100_315; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + VCLKIndex = LCDXlatVCLK1[CRT2Index]; + } else { + VCLKIndex = LCDXlatVCLK2[CRT2Index]; + } + } else { + VCLKIndex = (UCHAR)SiS_GetRegByte((USHORT)(SiS_Pr->SiS_P3ca+0x02)); /* Port 3cch */ + VCLKIndex = ((VCLKIndex >> 2) & 0x03); + if(ModeNo > 0x13) { + VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + } + if(ModeNo <= 0x13) { + if(HwInfo->jChipType <= SIS_315PRO) { + if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42; + } else { + if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x00; + } + } + if(HwInfo->jChipType <= SIS_315PRO) { + if(VCLKIndex == 0) VCLKIndex = 0x41; + if(VCLKIndex == 1) VCLKIndex = 0x43; + if(VCLKIndex == 4) VCLKIndex = 0x44; + } + } + } - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1C,temp); /* Part1_1Ch */ + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */ - temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1B,temp); /* Part1_1Bh */ + if( (SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && + (!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) ) { + 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 & TVRPLLDIV2XO) VCLKIndex = TVVCLKDIV2; + else VCLKIndex = TVVCLK; + } + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex += TVCLKBASE_300; + } else { + VCLKIndex += TVCLKBASE_315; + } - 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); + } else { /* VGA2 */ - temp = (USHORT)((tempebx & 0x00FF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x36,temp); + VCLKIndex = (UCHAR)SiS_GetRegByte((USHORT)(SiS_Pr->SiS_P3ca+0x02)); + VCLKIndex = ((VCLKIndex >> 2) & 0x03); + if(ModeNo > 0x13) { + VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex &= 0x3f; + if( (HwInfo->jChipType == SIS_630) && + (HwInfo->jChipRevision >= 0x30)) { + if(VCLKIndex == 0x14) VCLKIndex = 0x34; + } + /* Better VGA2 clock for 1280x1024@75 */ + if(VCLKIndex == 0x17) VCLKIndex = 0x45; + } + } + } - temp = (USHORT)((tempebx & 0x00030000) >> 16); - if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x35,temp); + } else { /* If not programming CRT2 */ - tempecx = SiS_Pr->SiS_VGAHDE; - 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; - 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 */ + VCLKIndex = (UCHAR)SiS_GetRegByte((USHORT)(SiS_Pr->SiS_P3ca+0x02)); + VCLKIndex = ((VCLKIndex >> 2) & 0x03); + if(ModeNo > 0x13) { + VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex &= 0x3f; + if( (HwInfo->jChipType != SIS_630) && + (HwInfo->jChipType != SIS_300) ) { + if(VCLKIndex == 0x1b) VCLKIndex = 0x35; + } + } + } + } - tempeax = SiS_Pr->SiS_VGAVDE; - tempeax <<= 18; - tempeax = tempeax / tempvcfact; - tempbx = (USHORT)(tempeax & 0x0FFFF); + } else { /* LVDS */ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx--; + VCLKIndex = CRT2Index; - if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempbx = 1; + if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { /* programming CRT2 */ - temp = ((tempbx & 0xFF00) >> 8) << 3; - temp = temp | (USHORT)(((tempecx & 0x0000FF00) >> 8) & 0x07); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x20,temp); /* Part1_20h */ + if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x21,temp); /* Part1_21h */ + VCLKIndex &= 0x1f; + tempbx = 0; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + tempbx += 2; + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) tempbx = 8; + } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + tempbx = 4; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { + tempbx = 6; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + } + } + switch(tempbx) { + case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break; + case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break; + case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break; + case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; + case 4: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALM; break; + case 5: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALM; break; + case 6: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALN; break; + case 7: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALN; break; + case 8: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKSOPAL; break; + default: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; + } + VCLKIndex = CHTVVCLKPtr[VCLKIndex]; + + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + + VCLKIndex >>= 6; + if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480)) + VCLKIndex = LVDSXlat1VCLK[VCLKIndex]; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) + VCLKIndex = LVDSXlat4VCLK[VCLKIndex]; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) + VCLKIndex = LVDSXlatVCLK2[VCLKIndex]; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) + VCLKIndex = LVDSXlatVCLK2[VCLKIndex]; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) + VCLKIndex = LVDSXlatVCLK2[VCLKIndex]; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) + VCLKIndex = VCLK68_315; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) + VCLKIndex = VCLK162_315; + else + VCLKIndex = LVDSXlatVCLK3[VCLKIndex]; + + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + /* Special Timing: Barco iQ Pro R series */ + VCLKIndex = 0x44; + } - 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_CustomT == CUT_PANEL848) { + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex = VCLK34_300; + /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ + } else { + VCLKIndex = VCLK34_315; + /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ + } + } + + } else { + + VCLKIndex = (UCHAR)SiS_GetRegByte((USHORT)(SiS_Pr->SiS_P3ca+0x02)); + VCLKIndex = ((VCLKIndex >> 2) & 0x03); + if(ModeNo > 0x13) { + VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex &= 0x3F; + } + if( (HwInfo->jChipType == SIS_630) && + (HwInfo->jChipRevision >= 0x30) ) { + if(VCLKIndex == 0x14) VCLKIndex = 0x2e; + } + } + } - temp=(USHORT)(tempecx & 0x000000FF); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x23,temp); + } else { /* if not programming CRT2 */ + VCLKIndex = (UCHAR)SiS_GetRegByte((USHORT)(SiS_Pr->SiS_P3ca+0x02)); + VCLKIndex = ((VCLKIndex >> 2) & 0x03); + if(ModeNo > 0x13) { + VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + if(HwInfo->jChipType < SIS_315H) { + VCLKIndex &= 0x3F; + if( (HwInfo->jChipType != SIS_630) && + (HwInfo->jChipType != SIS_300) ) { + if(VCLKIndex == 0x1b) VCLKIndex = 0x35; + } #if 0 - /* TW: Missing code (calles int 2f) (650/301LVx 1.10.6s; 1.10.7w doesn't do this) */ - if(xxx()) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0e,0xda); - } + if(HwInfo->jChipType == SIS_730) { + if(VCLKIndex == 0x0b) VCLKIndex = 0x40; /* 1024x768-70 */ + if(VCLKIndex == 0x0d) VCLKIndex = 0x41; /* 1024x768-75 */ + } #endif + } + } + + } - /* TW: Only for 650/LVDS and 30xLV/30xLVX */ - if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBInfo & (VB_SIS30xLV|VB_SIS30xNEW))){ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1e,0x20); } + +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "VCLKIndex %d (0x%x)\n", VCLKIndex, VCLKIndex); +#endif - return; + return(VCLKIndex); } -/* TW: Double-checked against 650/LVDS (1.10.07) and 650/301 BIOS */ -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); - 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); -} +/*********************************************/ +/* SET CRT2 MODE TYPE REGISTERS */ +/*********************************************/ -/* TW: Checked with 650/LVDS and 650/301 BIOS */ -USHORT -SiS_GetOffset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { - USHORT temp,colordepth; - USHORT modeinfo,index,infoflag; + USHORT i,j,modeflag; + USHORT tempcl,tempah=0; +#ifdef SIS300 + USHORT temp; +#endif +#ifdef SIS315H + USHORT tempbl, tempah2, tempbl2; +#endif - if(SiS_Pr->UseCustomMode) { - infoflag = SiS_Pr->CInfoFlag; - temp = SiS_Pr->CHDisplay / 16; + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; } else { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - modeinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeInfo; - - if(HwDeviceExtension->jChipType < SIS_315H ) { - index = (modeinfo >> 4) & 0xFF; + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; } else { - index = (modeinfo >> 8) & 0xFF; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; } - - temp = SiS_Pr->SiS_ScreenOffset[index]; } - colordepth = SiS_GetColorDepth(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex); - - if(infoflag & InterlaceMode) temp <<= 1; - - temp *= colordepth; - - /* TW: For 1400x1050 and 856x480 */ - if( ( ((ModeNo >= 0x26) && (ModeNo <= 0x28)) || - ModeNo == 0x3f || - ModeNo == 0x42 || - ModeNo == 0x45 ) || - (SiS_Pr->UseCustomMode && (SiS_Pr->CHDisplay % 16)) ) { - colordepth >>= 1; - temp += colordepth; - } + /* 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 */ - return(temp); -} + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { -/* TW: Checked with 650/LVDS BIOS */ -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; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xAF,0x40); /* FUNCTION CONTROL */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2E,0xF7); - 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; - } - index = (modeflag & ModeInfoFlag) - ModeEGA; - if(index < 0) index = 0; - return(ColorDepth[index]); -} + for(i=0,j=4; i<3; i++,j++) SiS_SetReg(SiS_Pr->SiS_Part1Port,j,0); -/* TW: Checked against 630/301/301B/LVDS, 650/301LVx/LVDS */ -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; - - flag = 0; - tempbl = 0xC0; - - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */ + tempcl = SiS_Pr->SiS_ModeType; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - tempah = SiS_Pr->SiS_LCDInfo; - if(HwDeviceExtension->jChipType >= SIS_315H) { - tempbl = tempah & 0xc0; - } - 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; + if(HwInfo->jChipType < SIS_315H) { - if (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - /* TW: BIOS does something here @@@ */ - } +#ifdef SIS300 /* ---- 300 series ---- */ - tempah &= 0x3f; - tempah |= tempbl; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + /* For 301BDH: (with LCD via LVDS) */ + if(SiS_Pr->SiS_VBType & VB_NoLCD) { + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32); + temp &= 0xef; + temp |= 0x02; + if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) || (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + temp |= 0x10; + temp &= 0xfd; + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); + } - } else { + if(ModeNo > 0x13) { + tempcl -= ModeVGA; + if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */ + tempah = ((0x10 >> tempcl) | 0x80); + } + } else tempah = 0x80; - if(HwDeviceExtension->jChipType < SIS_315H) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0; -#ifdef SIS300 /* ---- 300 series --- */ +#endif /* SIS300 */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 630 - 301B */ + } else { - 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; +#ifdef SIS315H /* ------- 315/330 series ------ */ - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBInfo & CRT2DisplayFlag) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x08); + } + } - if (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - /* TW: BIOS does something here @@@ */ - } + 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; - tempah &= 0x3f; - tempah |= tempbl; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50; - } else { /* 630 - 301 */ +#endif /* SIS315H */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - tempah = SiS_Pr->SiS_LCDInfo; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpandingShift) { /* ! */ - flag = 1; - } - } - if(flag != 1) tempah = infoflag >> 8; - tempah &= 0xC0; - tempah |= 0x30; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x3F,tempah); + } - } + if(SiS_Pr->SiS_VBInfo & CRT2DisplayFlag) tempah = 0; -#endif /* SIS300 */ + 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); + } + } + } - } else { + if(SiS_Pr->SiS_VBType & VB_SISVB) { -#ifdef SIS315H /* ----- 310/325 series ---- */ + tempah = 0x01; + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + tempah |= 0x02; + } + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + tempah ^= 0x05; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + tempah ^= 0x01; + } + } - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* 310/325 - 301LV/LVX */ + if(SiS_Pr->SiS_VBInfo & CRT2DisplayFlag) tempah = 0; - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37); - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if(HwInfo->jChipType < SIS_315H) { - } else { /* 310/325 - 301, 301B */ + tempah = (tempah << 5) & 0xFF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); + tempah = (tempah >> 5) & 0xFF; - tempah = infoflag >> 8; - tempah &= 0xC0; - tempah |= 0x20; + } else { - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF8,tempah); - if (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - /* TW: BIOS does something here @@@ */ - } + } - tempah &= 0x3f; - tempah |= tempbl; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { + tempah |= 0x10; + } - } -#endif /* SIS315H */ - } - } -} + if((HwInfo->jChipType < SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301)) { + if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960)) { + tempah |= 0x80; + } + } else { + tempah |= 0x80; + } -/* TW: Set CRT2 FIFO on 300/630/730 */ -/* TW: Checked against 630/301B BIOS; BIOS does not set PCI registers */ -#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(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(!(SiS_Pr->SiS_HiVision & 0x03)) { + tempah |= 0x20; + } + } + } - 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); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah); - if(CRT1ModeNo >= 0x13) { - index = SiS_Pr->SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK; - index &= 0x3F; - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ - data2 = SiS_Pr->SiS_ModeType - 2; - } - - } else { - - CRT1ModeNo = 0xfe; - VCLK = SiS_Pr->CSRClock; /* Get VCLK */ - data2 = (SiS_Pr->CModeFlag & ModeInfoFlag) - 2; - - } - - if(CRT1ModeNo >= 0x13) { - if(HwDeviceExtension->jChipType == SIS_300) { - index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A); - } else { - index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A); - } - index &= 0x07; - MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: CRT1Mode 0x%x VCLK %d MCLK %d modetype-2 = %d\n", - CRT1ModeNo, VCLK, MCLK, data2); -#endif - - switch(data2) { /* Get color depth */ - case 0 : colorth = 1; break; - case 1 : colorth = 1; break; - case 2 : colorth = 2; break; - case 3 : colorth = 2; break; - case 4 : colorth = 3; break; - case 5 : colorth = 4; break; - default: colorth = 2; break; - } - data2 = (colorth * VCLK) / MCLK; + tempah = 0; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) { + tempah |= 0x40; + } + } - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - temp = ((temp & 0x00FF) >> 6) << 1; - if(temp == 0) temp = 1; - temp <<= 2; - temp &= 0xff; + /* For 302LV dual-channel */ + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempah |= 0x40; + } + } - data2 = temp - data2; - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: data2 (step1) = %d\n", - data2); -#endif + if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) || + ((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) && + (SiS_Pr->CP_MaxX >= 1280) && (SiS_Pr->CP_MaxY >= 960))) { + tempah |= 0x80; + } - if((28 * 16) % data2) { - data2 = (28 * 16) / data2; - data2++; - } else { - data2 = (28 * 16) / data2; - } - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: data2 (step2) = %d\n", - data2); -#endif + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0C,tempah); - if(HwDeviceExtension->jChipType == SIS_300) { + } else { /* LVDS */ - tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18); - tempah &= 0x62; - tempah >>= 1; - tempal = tempah; - tempah >>= 3; - tempal |= tempah; - tempal &= 0x07; - tempcl = ThTiming[tempal]; - tempbx = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - tempbx >>= 6; - tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - tempah >>= 4; - tempah &= 0x0c; - tempbx |= tempah; - tempbx <<= 1; - tempal = ThLowB[tempbx + 1]; - tempal *= tempcl; - tempal += ThLowB[tempbx]; - data = tempal; + if(HwInfo->jChipType >= SIS_315H) { - } 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; + /* 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; + } + } -#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; + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + tempah |= 0x02; + } -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: Latencyfactorindex = 0x%x\n", tempal); -#endif - - tempbx = tempal; /* BIOS BUG (2.04.5d, 2.04.6a use ah here, which is unset!) */ - tempbx = 0; /* -- do it like the BIOS anyway... */ - tempax = tempbx; - tempbx &= 0xc0; - tempbx >>= 6; - tempax &= 0x0f; - tempax *= 3; - tempbx += tempax; - - data = LatencyFactor730[tempbx]; - data += 15; - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - if(!(temp & 0x80)) data += 5; - - } else { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tempah ^= 0x01; + } - index = 0; - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - if(temp & 0x0080) index += 12; + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { + tempah = 1; + } -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x800000A0); - eax = SiS_GetReg3(0xcfc); -#else - /* TW: We use pci functions X offers. We use tag 0, because - * we want to read/write to the host bridge (which is always - * 00:00.0 on 630, 730 and 540), not the VGA device. - */ - eax = pciReadLong(0x00000000, 0xA0); -#endif - temp = (USHORT)(eax >> 24); - if(!(temp&0x01)) index += 24; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah); -#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; + } else { - temp = (temp & 0x0F) >> 1; - index += temp; - - data = LatencyFactor[index]; - data += 15; - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14); - if(!(temp & 0x80)) data += 5; - } - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: latencyfactor (CRT1) = %d\n", data); -#endif + tempah = 0; + if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { + tempah |= 0x02; + } + tempah <<= 5; - data += data2; /* CRT1 Request Period */ - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: CRT1 request period = %d\n", data); -#endif + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; - CRT2ModeNo = ModeNo; - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; - SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT2ModeNo,&modeidindex); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); - refreshratetableindex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT2ModeNo, - modeidindex,HwDeviceExtension); + } - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,CRT2ModeNo,modeidindex, - refreshratetableindex,HwDeviceExtension); - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ - - data2 = SiS_Pr->SiS_ModeType - 2; - switch(data2) { /* Get color depth */ - case 0 : colorth = 1; break; - case 1 : colorth = 1; break; - case 2 : colorth = 2; break; - case 3 : colorth = 2; break; - case 4 : colorth = 3; break; - case 5 : colorth = 4; break; - default: colorth = 2; break; - } - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: CRT2Mode 0x%x VCLK %d MCLK %d modetype-2 = %d, colorth %d\n", - CRT2ModeNo, VCLK, MCLK, data2, colorth); -#endif + } - data = data * VCLK * colorth; - if(data % (MCLK << 4)) { - data = data / (MCLK << 4); - data++; - } else { - data = data / (MCLK << 4); - } - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "FIFO2: data (unclipped) = 0x%x\n", data); -#endif - - if(data <= 6) data = 6; - if(data > 0x14) data = 0x14; + } /* LCDA */ - 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); + if(SiS_Pr->SiS_VBType & VB_SISVB) { - 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(HwInfo->jChipType >= SIS_315H) { -/* TW: Set FIFO on 310 series */ #ifdef SIS315H -void -SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - - UCHAR CombCode[] = { 1, 1, 1, 4, 3, 1, 3, 4, - 4, 1, 4, 4, 5, 1, 5, 4}; - UCHAR CRT2ThLow[] = { 39, 63, 55, 79, 78,102, 90,114, - 55, 87, 84,116,103,135,119,151}; - USHORT temp3,tempax,tempbx,tempcx; - USHORT tempcl, tempch; - USHORT index; - USHORT CRT1ModeNo,CRT2ModeNo; - USHORT ModeIdIndex; - USHORT RefreshRateTableIndex; - USHORT SelectRate_backup; - - SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate; - - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x01,0x3B); - - if(!SiS_Pr->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; - - /* Get REFIndex for crt1 refreshrate */ - RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT1ModeNo, - ModeIdIndex,HwDeviceExtension); - - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,CRT1ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - tempax = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ - - tempbx = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT1ModeNo,ModeIdIndex); /* Get colordepth */ - tempbx >>= 1; - if(!tempbx) tempbx++; - - } else { - - tempax = SiS_Pr->CSRClock; /* Get VCLK */ - tempbx = (SiS_Pr->CModeFlag & ModeInfoFlag) - 2; - switch(tempbx) { /* Get color depth */ - case 0 : tempbx = 1; break; - case 1 : tempbx = 1; break; - case 2 : tempbx = 2; break; - case 3 : tempbx = 2; break; - case 4 : tempbx = 3; break; - case 5 : tempbx = 4; break; - default: tempbx = 2; break; - } - - } - - tempax *= tempbx; - tempbx = SiS_GetMCLK(SiS_Pr,ROMAddr, HwDeviceExtension); /* Get MCLK */ - - tempax /= tempbx; + unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01);; + + /* The following is nearly unpreditable and varies from machine + * to machine. Especially the 301DH seems to be a real trouble + * maker. Some BIOSes simply set the registers (like in the + * NoLCD-if-statements here), some set them according to the + * LCDA stuff. It is very likely that some machines are not + * treated correctly in the following, very case-orientated + * code. What do I do then...? + */ + + /* 740 variants match for 30xB, 301B-DH, 30xLV */ + + if(!(IS_SIS740)) { + tempah = 0x04; /* For all bridges */ + tempbl = 0xfb; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + tempah = 0x00; + if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { + tempbl = 0xff; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); + } - tempbx = tempax; + /* 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 0 /* TW: BIOS code is skrewed */ - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14) & 0x02) { - tempax = 16; - } else { - tempax = 8; - } -#endif - tempax = 16; + if((IS_SIS740) || (HwInfo->jChipType >= SIS_661)) { + tempah = 0x30; + tempbl = 0xc0; + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { + tempah = 0x00; + tempbl = 0x00; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xcf,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,tempbl); + } else if(SiS_Pr->SiS_VBType & VB_SIS301) { + /* Fixes "TV-blue-bug" on 315+301 */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xcf); /* For 301 */ + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); + } else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xLV */ + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0); + } else if((SiS_Pr->SiS_VBType & VB_NoLCD) && (bridgerev == 0xb0)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xB-DH rev b0 (or "DH on 651"?) */ + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0); + } else { + tempah = 0x30; tempah2 = 0xc0; /* For 30xB (and 301BDH rev b1) */ + tempbl = 0xcf; tempbl2 = 0x3f; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + tempah = tempah2 = 0x00; + if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { + tempbl = tempbl2 = 0xff; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl2,tempah2); + } - tempax -= tempbx; + 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); + } - tempbx = tempax; /* tempbx = 16-DRamBus - DCLK*BytePerPixel/MCLK */ + /* 661: Sets p4 27 and 34 here, done in SetGroup4 here */ - tempax = ((52 * 16) / tempbx); +#endif /* SIS315H */ - if ((52*16 % tempbx) != 0) { - tempax++; - } - tempcx = tempax; - tempcx += 40; + } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - /* 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 */ + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); - for (temp3 = 0; temp3 < 16; temp3 += 2) { - if ((CombCode[temp3] == tempcl) && (CombCode[temp3+1] == tempch)) { - temp3 = CRT2ThLow[temp3 >> 1]; - } - } + 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); + } - tempcx += temp3; /* CRT1 Request Period */ + } - CRT2ModeNo = ModeNo; /* get CRT2 ModeNo */ - SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT2ModeNo,&ModeIdIndex); /* Get ModeID Table */ + } else { /* LVDS */ - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; +#ifdef SIS315H + if(HwInfo->jChipType >= SIS_315H) { - RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT2ModeNo, - ModeIdIndex,HwDeviceExtension); + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,CRT2ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - tempax = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ + 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); - tempbx = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT2ModeNo,ModeIdIndex); /* Get colordepth */ - tempbx >>= 1; - if(!tempbx) tempbx++; + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); + } - tempax *= tempbx; + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); - tempax *= tempcx; + } else if(HwInfo->jChipType == SIS_550) { - tempbx = SiS_GetMCLK(SiS_Pr,ROMAddr, HwDeviceExtension); /* Get MCLK */ - tempbx <<= 4; + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); - tempcx = tempax; - tempax /= tempbx; - if(tempcx % tempbx) tempax++; /* CRT1 Request period * TCLK * BytePerPixel / (MCLK*16) */ + } - if (tempax > 0x37) tempax = 0x37; + } +#endif - /* TW: 650/LVDS (1.10.07, 1.10.00), 650/301LV overrule calculated value; 315 does not */ - if(HwDeviceExtension->jChipType == SIS_650) { - tempax = 0x04; } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,~0x3F,tempax); } +/*********************************************/ +/* 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; + USHORT resindex; - 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) + resindex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + else + resindex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + + return(resindex); } -#endif -/* TW: Checked against 650/LVDS 1.10.07 BIOS */ -void -SiS_GetLVDSDesData(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_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->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ) { + 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; + } - SiS_GetLVDSDesPtrA(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &PanelIndex,&ResIndex); - 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; - default: PanelDesPtr = SiS_Pr->LVDS1024x768Des_1; break; - } + resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex); + if(ModeNo <= 0x13) { + xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; + yres = SiS_Pr->SiS_StResInfo[resindex].VTotal; } else { + xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; + yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } - SiS_GetLVDSDesPtr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &PanelIndex,&ResIndex,HwDeviceExtension); + if((!SiS_Pr->SiS_IF_DEF_DSTN) && (!SiS_Pr->SiS_IF_DEF_FSTN)) { - switch (PanelIndex) - { - case 0: PanelDesPtr = SiS_Pr->SiS_PanelType00_1; break; /* --- expanding --- | */ - 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; /* --- non-expanding --- */ - 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_CHTVUNTSCDesData; break; - case 33: PanelDesPtr = SiS_Pr->SiS_CHTVONTSCDesData; break; - case 34: PanelDesPtr = SiS_Pr->SiS_CHTVUPALDesData; break; - case 35: PanelDesPtr = SiS_Pr->SiS_CHTVOPALDesData; break; - default: - if(HwDeviceExtension->jChipType < SIS_315H) - PanelDesPtr = SiS_Pr->SiS_PanelType0e_1; - else - PanelDesPtr = SiS_Pr->SiS_PanelType01_1; - break; + if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) { + if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) { + if(yres == 350) yres = 400; + } + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x3a) & 0x01) { + if(ModeNo == 0x12) yres = 400; + } } + + if(ModeNo > 0x13) { + if(modeflag & HalfDCLK) xres *= 2; + if(modeflag & DoubleScanMode) yres *= 2; + } + } - SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES; - SiS_Pr->SiS_LCDVDES = (PanelDesPtr+ResIndex)->LCDVDES; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding){ - 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_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + if(xres == 720) xres = 640; + } else { + if(SiS_Pr->SiS_VBType & VB_NoLCD) { /* 301BDH */ + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVisionTV)) { + if(xres == 720) xres = 640; + } + if(SiS_Pr->SiS_SetFlag & SetDOSMode) { + yres = 400; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480; + } else { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480; + } + } + } else { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVisionTV)) { + if(xres == 720) xres = 640; + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + if(yres == 1024) yres = 1056; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + /* BIOS bug - does this regardless of scaling */ + if(yres == 400) yres = 405; + } + if(yres == 350) yres = 360; + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + if(yres == 360) yres = 375; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + if(yres == 350) yres = 357; + if(yres == 400) yres = 420; + if(yres == 480) yres = 525; + } + } + } + } + } + } + } else { + if(xres == 720) xres = 640; + if(SiS_Pr->SiS_SetFlag & SetDOSMode) { + yres = 400; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480; + } else { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480; + } + if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) { + yres = 480; + } } - } - } else { - if(!(SiS_Pr->SiS_SetFlag & CRT2IsVGA)) { - if((HwDeviceExtension->jChipType < SIS_315H) || (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024)) { /* TW: New from 650/LVDS 1.10.07 */ - 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 { - /* TW: New from 650/LVDS 1.10.07 */ - 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; - } - } - } - } - } - } - } } - return; + SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; + SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; } -/* TW: Checked against 630/LVDS (2.04.5c) and 650/LVDS (1.10.07) BIOS */ -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; +/*********************************************/ +/* GET CRT2 TIMING DATA */ +/*********************************************/ - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; +static BOOLEAN +SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, USHORT *ResIndex, + USHORT *DisplayType) + { + USHORT tempbx,modeflag=0; + USHORT Flag,CRT2CRTC; + + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return FALSE; + } + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return FALSE; + } else + return FALSE; + + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + CRT2CRTC = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + 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)) { - tempbx = 32; - if((SiS_Pr->SiS_VBInfo & SetPALTV) && (!SiS_Pr->SiS_CHPALM)) tempbx += 2; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - /* TW: Nothing special needed for SOverscan */ - /* PALM uses NTSC data, PALN uses PAL data */ - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - tempbx = SiS_Pr->SiS_LCDTypeInfo; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 16; - /* TW: Inserted from 650/LVDS (1.10.07) BIOS */ - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - if(modeflag & HalfDCLK) tempbx += 16; - } - } - /* TW: Inserted from 630/LVDS and 650/LVDS (1.10.07) BIOS */ - if(SiS_Pr->SiS_SetFlag & CRT2IsVGA) { - 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_VBInfo & SetCRT2ToLCD)) { + Flag = 0; + tempbx = 18; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx++; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + tempbx += 2; + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; + } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + tempbx = 18; /* PALM uses NTSC data */ + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx++; + } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { + tempbx = 20; /* PALN uses PAL data */ + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx++; + } + } + } } + if(Flag) { + tempbx = SiS_Pr->SiS_LCDResInfo; + tempbx -= SiS_Pr->SiS_PanelMinLVDS; + if(SiS_Pr->SiS_LCDResInfo <= SiS_Pr->SiS_Panel1280x1024) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 6; + if(modeflag & HalfDCLK) tempbx += 3; + } else { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + tempbx = 14; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { + tempbx = 23; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { + tempbx = 27; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + tempbx = 36; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { + tempbx = 40; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) { + tempbx = 54; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2) { + tempbx = 52; + if(modeflag & HalfDCLK) tempbx++; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { + tempbx = 50; + if(modeflag & HalfDCLK) tempbx++; + } - *PanelIndex = tempbx; - *ResIndex = tempal & 0x1F; -} - -void -SiS_GetLVDSDesPtrA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *PanelIndex, - USHORT *ResIndex) -{ - USHORT tempbx=0,tempal; - - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - tempbx = 3; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { - tempbx = 4; - } else tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_PanelMinLVDS; - - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 4; + } + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + tempbx = 12; + if(modeflag & HalfDCLK) tempbx++; + } + } - if(ModeNo<=0x13) - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - else - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; +#if 0 + if(SiS_Pr->SiS_IF_DEF_FSTN) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){ + tempbx = 22; + } + } +#endif - *PanelIndex = tempbx; - *ResIndex = tempal & 0x1F; + *ResIndex = CRT2CRTC & 0x3F; + *DisplayType = tempbx; + return TRUE; } -/* TW: Checked against 650/LVDS (1.10.07), 650/301LV, 650/301LVx (!), 630/301 and 630/301B (II) BIOS */ -void -SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT BaseAddr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex, + PSIS_HW_INFO HwInfo) { - USHORT i,j,modeflag; - USHORT tempcl,tempah=0; -#ifdef SIS300 - USHORT temp; -#endif -#ifdef SIS315H - USHORT tempbl; -#endif + USHORT tempbx=0,tempal=0; + USHORT Flag,resinfo=0; - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + if(ModeNo <= 0x13) { + tempal = 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; - } + tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; } - - /* TW: BIOS does not do this (neither 301 nor LVDS) */ - /* (But it's harmless; see SetCRT2Offset) */ - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,0x00); /* fix write part1 index 0 BTDRAM bit Bug */ - - /* TW: Removed 301B302B301LV302LV check here to match 650/LVDS BIOS */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - - /* TW: 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); - - } else { - for(i=0,j=4; i<3; i++,j++) SiS_SetReg1(SiS_Pr->SiS_Part1Port,j,0); + if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_IF_DEF_LVDS == 0)) { - tempcl = SiS_Pr->SiS_ModeType; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */ - if(HwDeviceExtension->jChipType < SIS_315H) { - -#ifdef SIS300 /* ---- 300 series ---- */ - - /* TW: Inserted entire if-section from 630/301B BIOS */ - if((HwDeviceExtension->jChipType != SIS_300) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32); - temp &= 0xef; - temp |= 0x02; - /* If 0x10 not set when using VGA2, monitor will stay black */ - 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)) { /* TW: 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 /* ---- 310 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)) { /* TW: 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 { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); /* FUNCTION CONTROL */ - } - - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - - /* TW: 2. for 301 (301B, 302B 301LV, 302LV non-LCDA) */ - - tempah = 0x01; - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - tempah |= 0x02; - } - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { - tempah ^= 0x05; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - tempah ^= 0x01; - } - } - - if(SiS_Pr->SiS_VBInfo & CRT2DisplayFlag) tempah = 0; - - if(HwDeviceExtension->jChipType < SIS_315H) { - - /* --- 300 series --- */ - - tempah = (tempah << 5) & 0xFF; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x01,tempah); - tempah = (tempah >> 5) & 0xFF; - - } else { - - /* --- 310 series --- */ - - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF8,tempah); - - } - - if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { - tempah |= 0x10; - } - - /* TW: Inserted from 630/301 BIOS */ - if((HwDeviceExtension->jChipType < SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301)) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - tempah |= 0x80; - } + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { + tempbx = 15; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + tempbx = 20; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 21; + else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 22; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + tempbx = 23; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 24; + else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 25; +#if 0 + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { + tempbx = 26; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 27; + else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 28; +#endif + } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx = 13; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempbx = 14; + else { + tempbx = 29; + if(ModeNo >= 0x13) { + /* see below */ + if(resinfo == SIS_RI_1280x960) tempal = 10; + } + } + } else { + tempbx = 29; + if(ModeNo >= 0x13) { + /* 1280x768 and 1280x960 have same CRT2CRTC, + * so we change it here if 1280x960 is chosen + */ + if(resinfo == SIS_RI_1280x960) tempal = 10; + } + } } else { - tempah |= 0x80; - } - - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)){ - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - tempah |= 0x20; - } - } - - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah); - - tempah = 0; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_Pr->SiS_SetFlag |= RPLLDIV2XO; - tempah |= 0x40; - } else { - if(!(SiS_Pr->SiS_SetFlag & TVSimuMode)) { -#ifdef oldHV - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) { -#endif - SiS_Pr->SiS_SetFlag |= RPLLDIV2XO; - tempah |= 0x40; -#ifdef oldHV - } -#endif - } - } - } else { - SiS_Pr->SiS_SetFlag |= RPLLDIV2XO; - tempah |= 0x40; - } - } - /* TW: Inserted from 630/301LVx BIOS 1.10.6s */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) - tempah |= 0x40; - } + tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_Panel1024x768; + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + tempbx += 10; + } } - if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960)) { - tempah |= 0x80; +#ifdef SIS315H + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + tempbx = 50; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 51; + else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 52; + } } +#endif - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0C,tempah); + } else { /* TV */ - } else { + if((SiS_Pr->SiS_VBType & VB_SIS301B302B) && + (SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) { + if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_TVMode &= (~TVSetTVSimuMode); + tempbx = 2; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) tempbx = 12; + } + } else { + if(SiS_Pr->SiS_TVMode & TVSetPAL) tempbx = 3; + else tempbx = 4; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; + } - /* TW: 3. for LVDS */ + } - /* TW: Inserted if-statement - Part1Port 0x2e not assigned on 300 series */ - if(HwDeviceExtension->jChipType >= SIS_315H) { + tempal &= 0x3F; - /* TW: Inserted this entire section (BIOS 650/LVDS); added ModeType check - * (LVDS can only be slave in 8bpp modes) - */ - tempah = 0x80; - if( (modeflag & CRT2Mode) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { - if (SiS_Pr->SiS_VBInfo & DriverMode) { - tempah |= 0x02; - } + if(SiS_Pr->SiS_VBInfo & (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_VBInfo & SetInSlaveMode)) { - tempah |= 0x02; - } - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - tempah ^= 0x01; - } + *CRT2Index = tempbx; + *ResIndex = tempal; + + } else { /* LVDS, 301B-DH (if running on LCD) */ + + Flag = 1; + tempbx = 0; + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + Flag = 0; + tempbx = 10; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + tempbx += 2; + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; + } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + tempbx = 90; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { + tempbx = 92; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + } + } + } + } - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - tempah = 1; - } + if(Flag) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah); + if(SiS_Pr->SiS_LCDResInfo <= SiS_Pr->SiS_Panel1280x1024) { + tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_PanelMinLVDS; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 3; - } else { + if(SiS_Pr->SiS_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++; + } - /* TW: (added ModeType check) */ - tempah = 0; - if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { - tempah |= 0x02; - } - tempah <<= 5; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + tempbx = 7; + } - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; + if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { + tempbx = 84; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + } - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x01,tempah); + } + if(SiS_Pr->SiS_SetFlag & SetDOSMode) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) tempal = 7; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) tempal++; } + } - } - + *CRT2Index = tempbx; + *ResIndex = tempal & 0x1F; } - - /* TW: Inserted the entire following section */ - - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - - if(HwDeviceExtension->jChipType >= SIS_315H) { - -#ifdef SIS315H - 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); - - /* TW: This in order to fix "TV-blue-bug" on 315+301 */ - if(SiS_Pr->SiS_VBType & VB_SIS301) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xCF); /* For 301 */ - } else { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xCF,0x30); /* For 301LV */ - } else { - tempah = 0x30; /* For 301B */ - tempbl = 0xcf; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempah = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) { - tempbl = 0xff; - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah); - } - } - - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* For 301LV */ - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,0xc0); - } else { /* For 301, 301B */ - tempah = 0xc0; - tempbl = 0x3f; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempah = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) { - tempbl = 0xff; - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl,tempah); - } - - 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) || - ( (HwDeviceExtension->jChipType != SIS_300) && - (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) ) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x23,0x7F); - } else { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x23,0x80); - } - - } - - } else { /* LVDS */ +} #ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { +static void +SiS_GetCRT2PtrA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,USHORT *CRT2Index, + USHORT *ResIndex) +{ + USHORT tempbx,tempal; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + tempbx = SiS_Pr->SiS_LCDResInfo; - 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_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 4; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempbx = 3; + else tempbx -= SiS_Pr->SiS_Panel1024x768; - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x00); + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 5; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xcf,0x30); + if(ModeNo <= 0x13) + tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + else + tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - } + /* No customs required yet (Clevo, Compaq, etc) */ - } + *CRT2Index = tempbx; + *ResIndex = tempal & 0x1F; +} #endif - } +static void +SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo) +{ + USHORT tempax=0,tempbx=0; + USHORT temp1=0,modeflag=0,tempcx=0; + USHORT index; -} + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; -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(ModeNo <= 0x13) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + index = SiS_GetModePtr(SiS_Pr,ModeNo,ModeIdIndex); - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + tempax = SiS_Pr->SiS_StandTable[index].CRTC[0]; + tempbx = SiS_Pr->SiS_StandTable[index].CRTC[6]; + temp1 = SiS_Pr->SiS_StandTable[index].CRTC[7]; - SiS_GetCRT2DataLVDS(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } else { + } else { - if((HwDeviceExtension->jChipType < SIS_315H) && - (HwDeviceExtension->jChipType != SIS_300) && - (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; - SiS_GetCRT2Data301(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); + 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]; - /* TW: Need LVDS Data for LCD on 630/301B! */ - SiS_GetCRT2DataLVDS(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); + } - } else { + if(temp1 & 0x01) tempbx |= 0x0100; + if(temp1 & 0x20) tempbx |= 0x0200; + + tempax += 5; - SiS_GetCRT2Data301(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } + /* 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; - } else { + if(modeflag & HalfDCLK) tempax <<= 1; - SiS_GetCRT2Data301(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } + tempbx++; - } else { - - SiS_GetCRT2DataLVDS(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - } + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = tempbx; } -/* Checked with 650/LVDS 1.10.07 BIOS */ -void -SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, +static void +SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) + PSIS_HW_INFO HwInfo) { USHORT CRT2Index, ResIndex; const SiS_LVDSDataStruct *LVDSData = NULL; - SiS_GetCRT2ResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension); - - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + SiS_GetCRT2ResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; SiS_Pr->SiS_NewFlickerMode = 0; SiS_Pr->SiS_RVBHRS = 50; SiS_Pr->SiS_RY1COE = 0; SiS_Pr->SiS_RY2COE = 0; SiS_Pr->SiS_RY3COE = 0; SiS_Pr->SiS_RY4COE = 0; + } + + if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - SiS_GetCRT2PtrA(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, +#ifdef SIS315H + SiS_GetCRT2PtrA(SiS_Pr,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 0: LVDSData = SiS_Pr->SiS_LCDA1024x768Data_1; break; + case 1: LVDSData = SiS_Pr->SiS_LCDA1280x1024Data_1; break; case 3: LVDSData = SiS_Pr->SiS_LCDA1400x1050Data_1; break; case 4: LVDSData = SiS_Pr->SiS_LCDA1600x1200Data_1; break; - case 5: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_2; break; - case 6: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_2; break; - case 7: LVDSData = SiS_Pr->SiS_LVDS1280x960Data_2; break; + case 5: LVDSData = SiS_Pr->SiS_LCDA1024x768Data_2; break; + case 6: LVDSData = SiS_Pr->SiS_LCDA1280x1024Data_2; break; case 8: LVDSData = SiS_Pr->SiS_LCDA1400x1050Data_2; break; case 9: LVDSData = SiS_Pr->SiS_LCDA1600x1200Data_2; break; - default: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; + default: LVDSData = SiS_Pr->SiS_LCDA1024x768Data_1; break; } +#endif } else { - /* TW: SiS630/301B needs LVDS Data! */ - if( (HwDeviceExtension->jChipType < SIS_315H) && - (HwDeviceExtension->jChipType != SIS_300) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) { - SiS_Pr->SiS_IF_DEF_LVDS = 1; + /* 301BDH needs LVDS Data */ + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + SiS_Pr->SiS_IF_DEF_LVDS = 1; } - SiS_GetCRT2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex,HwDeviceExtension); + SiS_GetCRT2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + &CRT2Index, &ResIndex, HwInfo); - /* TW: SiS630/301B needs LVDS Data! */ - if( (HwDeviceExtension->jChipType < SIS_315H) && - (HwDeviceExtension->jChipType != SIS_300) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) { - SiS_Pr->SiS_IF_DEF_LVDS = 0; + /* 301BDH needs LVDS Data */ + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + SiS_Pr->SiS_IF_DEF_LVDS = 0; } switch (CRT2Index) { @@ -3183,105 +2891,76 @@ SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT Mod 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; /* TW: New */ - case 8: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_1; break; /* TW: New */ - case 9: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_2; break; /* TW: New */ + 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; /* TW: New */ - case 16: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_1; break; /* TW: New */ - case 17: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_2; break; /* TW: New */ - case 18: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_2; break; /* TW: New */ - case 19: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_1; break; /* TW: New */ - case 20: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_2; break; /* TW: New */ + 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; /* TW: Super Overscan */ + 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) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - - if(!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)){ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768){ - SiS_Pr->SiS_HDE = 1024; - SiS_Pr->SiS_VDE = 768; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024){ - SiS_Pr->SiS_HDE = 1280; - SiS_Pr->SiS_VDE = 1024; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050){ - SiS_Pr->SiS_HDE = 1400; - SiS_Pr->SiS_VDE = 1050; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200){ - SiS_Pr->SiS_HDE = 1600; - SiS_Pr->SiS_VDE = 1200; - } else { - SiS_Pr->SiS_HDE = 1280; - SiS_Pr->SiS_VDE = 960; - } - } + SiS_Pr->SiS_HT = (LVDSData+ResIndex)->LCDHT; + SiS_Pr->SiS_VT = (LVDSData+ResIndex)->LCDVT; - } else { + if(SiS_Pr->SiS_VBType & VB_SISVB) { - 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 & LCDNonExpanding)) || (SiS_Pr->SiS_SetFlag & CRT2IsVGA)) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - SiS_Pr->SiS_HDE = 800; - SiS_Pr->SiS_VDE = 600; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - SiS_Pr->SiS_HDE = 1024; - SiS_Pr->SiS_VDE = 768; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - SiS_Pr->SiS_HDE = 1280; - SiS_Pr->SiS_VDE = 1024; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - SiS_Pr->SiS_HDE = 1024; - SiS_Pr->SiS_VDE = 600; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - SiS_Pr->SiS_HDE = 1400; - SiS_Pr->SiS_VDE = 1050; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { - SiS_Pr->SiS_HDE = 1152; - SiS_Pr->SiS_VDE = 768; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x864) { - SiS_Pr->SiS_HDE = 1152; - SiS_Pr->SiS_VDE = 864; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { - SiS_Pr->SiS_HDE = 1280; - SiS_Pr->SiS_VDE = 768; - } else { - SiS_Pr->SiS_HDE = 1600; - SiS_Pr->SiS_VDE = 1200; - } - if(SiS_Pr->SiS_IF_DEF_FSTN) { - SiS_Pr->SiS_HDE = 320; - SiS_Pr->SiS_VDE = 480; + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; + SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; + } + + } else { + + if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { + if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (SiS_Pr->SiS_SetFlag & SetDOSMode)) { + SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; + SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; + + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + if(ResIndex < 0x08) { + SiS_Pr->SiS_HDE = 1280; + SiS_Pr->SiS_VDE = 1024; + } + } + } } - } - } + } } - } - } + } } -/* TW: Checked against 630/301B BIOS; does not check VDE values for LCD */ -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; @@ -3289,13 +2968,19 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT Mode const SiS_LCDDataStruct *LCDPtr = NULL; const SiS_TVDataStruct *TVPtr = NULL; - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + 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; + } } + SiS_Pr->SiS_NewFlickerMode = 0; SiS_Pr->SiS_RVBHRS = 50; SiS_Pr->SiS_RY1COE = 0; @@ -3303,34 +2988,40 @@ 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); - - /* TW: For VGA2 ("RAMDAC2") */ + SiS_GetCRT2ResInfo(SiS_Pr,ModeNo,ModeIdIndex,HwInfo); if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){ - SiS_GetRAMDAC2DATA(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - return; - } - /* TW: For TV */ + if(SiS_Pr->UseCustomMode) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; + SiS_Pr->SiS_VGAHT = SiS_Pr->CHTotal; + SiS_Pr->SiS_VGAVT = SiS_Pr->CVTotal; + SiS_Pr->SiS_HT = SiS_Pr->CHTotal; + SiS_Pr->SiS_VT = SiS_Pr->CVTotal; + SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE; + SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; - SiS_GetCRT2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex,HwDeviceExtension); + } else { - switch (CRT2Index) { -#ifdef oldHV - case 2: TVPtr = SiS_Pr->SiS_ExtHiTVData; break; - case 7: TVPtr = SiS_Pr->SiS_St1HiTVData; break; - case 12: TVPtr = SiS_Pr->SiS_St2HiTVData; break; -#endif - case 3: TVPtr = SiS_Pr->SiS_ExtPALData; break; - case 4: TVPtr = SiS_Pr->SiS_ExtNTSCData; break; - case 8: TVPtr = SiS_Pr->SiS_StPALData; break; - case 9: TVPtr = SiS_Pr->SiS_StNTSCData; break; - default: TVPtr = SiS_Pr->SiS_StPALData; break; /* TW: Just to avoid a crash */ + SiS_GetRAMDAC2DATA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + } + + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + + SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, + &CRT2Index,&ResIndex,HwInfo); + + 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; } SiS_Pr->SiS_RVBHCMAX = (TVPtr+ResIndex)->RVBHCMAX; @@ -3342,1416 +3033,536 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT Mode 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_RVBHRS = (TVPtr+ResIndex)->HALFRVBHRS; } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { /* TW: NOT oldHV! */ - - if(resinfo == 0x08) SiS_Pr->SiS_NewFlickerMode = 0x40; - if(resinfo == 0x09) SiS_Pr->SiS_NewFlickerMode = 0x40; - if(resinfo == 0x12) SiS_Pr->SiS_NewFlickerMode = 0x40; - - 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(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_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(!(modeflag & Charx8Dot)){ + SiS_Pr->SiS_HT = StHiTextTVHT; + SiS_Pr->SiS_VT = StHiTextTVVT; + } + } } - } + } } 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_VBInfo & SetPALTV)) { - SiS_Pr->SiS_HT = NTSCHT; -/* if(SiS_Pr->SiS_VBType & (VB_SIS30xLV|VB_SIS30xNEW)) { */ /* TW: ALL newer 650 BIOSes do this, no idea about 301B */ - if((ModeNo == 0x4a) || (ModeNo == 0x38)) SiS_Pr->SiS_HT = NTSC2HT; -/* } */ - SiS_Pr->SiS_VT = NTSCVT; - } else { - SiS_Pr->SiS_HT = PALHT; - SiS_Pr->SiS_VT = PALVT; - } - - } - - return; - } - - /* TW: For LCD */ - /* TW: Checked against 650/301LV; CRT2Index different (but does not matter) */ + 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(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(modeflag & HalfDCLK) { + SiS_Pr->SiS_RY1COE = 0x00; + SiS_Pr->SiS_RY2COE = 0xf4; + SiS_Pr->SiS_RY3COE = 0x10; + SiS_Pr->SiS_RY4COE = 0x38; + } - 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 */ - case 22: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break; /* Non-VESA Timing */ - case 23: LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break; /* VESA Timing */ - case 24: LCDPtr = SiS_Pr->SiS_NoScaleData1600x1200; break; /* Non-expanding */ - case 25: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break; /* Non-VESA Timing */ - default: LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; /* Just to avoid a crash */ - } + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + 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; + } - 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 = 1024; - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - 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_VGAVDE == 357) tempbx = 527; - else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620; - else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775; - else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775; - else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; - else tempbx = 768; } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024){ - tempax = 1280; - if (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768; - else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800; - else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864; - else tempbx = 1024; - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960){ - tempax = 1280; - if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 700; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 800; - else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960; - else tempbx = 960; - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050){ - tempax = 1400; - tempbx = 1050; - } - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) { - tempax = SiS_Pr->SiS_VGAHDE; - tempbx = SiS_Pr->SiS_VGAVDE; - } - SiS_Pr->SiS_HDE = tempax; - SiS_Pr->SiS_VDE = tempbx; - return; - } -} -USHORT -SiS_GetResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) -{ - USHORT resindex; - - if(ModeNo<=0x13) - resindex=SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; - else - resindex=SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - return(resindex); -} + if(SiS_Pr->UseCustomMode) { -/* TW: Checked against 650/301LV, 650/LVDS, 630/LVDS, 630/301 and 630/301B BIOS */ -void -SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT xres,yres,modeflag=0,resindex; + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; + SiS_Pr->SiS_VGAHT = SiS_Pr->CHTotal; + SiS_Pr->SiS_VGAVT = SiS_Pr->CVTotal; + SiS_Pr->SiS_HT = SiS_Pr->CHTotal; + SiS_Pr->SiS_VT = SiS_Pr->CVTotal; + SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE; + SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; - resindex = SiS_GetResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex); + } else { - if(ModeNo <= 0x13) { - xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; - yres = SiS_Pr->SiS_StResInfo[resindex].VTotal; - } else { - xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; - yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal; - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } + SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, + &CRT2Index,&ResIndex,HwInfo); + + switch(CRT2Index) { + case 0: LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; /* VESA Timing */ + case 1: LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data; break; /* VESA Timing */ + case 5: LCDPtr = SiS_Pr->SiS_StLCD1024x768Data; break; /* Obviously unused */ + case 6: LCDPtr = SiS_Pr->SiS_StLCD1280x1024Data; break; /* Obviously unused */ + case 10: LCDPtr = SiS_Pr->SiS_St2LCD1024x768Data; break; /* Non-VESA Timing */ + case 11: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; /* Non-VESA Timing */ + case 13: LCDPtr = SiS_Pr->SiS_NoScaleData1024x768; break; /* Non-expanding */ + case 14: LCDPtr = SiS_Pr->SiS_NoScaleData1280x1024; break; /* Non-expanding */ + case 15: LCDPtr = SiS_Pr->SiS_LCD1280x960Data; break; /* 1280x960 */ + case 20: LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data; break; /* VESA Timing */ + case 21: LCDPtr = SiS_Pr->SiS_NoScaleData1400x1050; break; /* Non-expanding (let panel scale) */ + case 22: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break; /* Non-VESA Timing (let panel scale) */ + case 23: LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break; /* VESA Timing */ + case 24: LCDPtr = SiS_Pr->SiS_NoScaleData1600x1200; break; /* Non-expanding */ + case 25: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break; /* Non-VESA Timing */ + case 26: LCDPtr = SiS_Pr->SiS_ExtLCD1280x768Data; break; /* VESA Timing */ + case 27: LCDPtr = SiS_Pr->SiS_NoScaleData1280x768; break; /* Non-expanding */ + case 28: LCDPtr = SiS_Pr->SiS_StLCD1280x768Data; break; /* Non-VESA Timing */ + case 29: LCDPtr = SiS_Pr->SiS_NoScaleData; break; /* Generic no-scale data */ +#ifdef SIS315H + case 50: LCDPtr = (SiS_LCDDataStruct *)SiS310_ExtCompaq1280x1024Data; break; + case 51: LCDPtr = SiS_Pr->SiS_NoScaleData1280x1024; break; + case 52: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; +#endif + default: LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; + } - /* TW: Inserted entire if-section from 650/LVDS BIOS 1.10.07: */ - if((HwDeviceExtension->jChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) { - if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & CRT2IsVGA)) { - if(yres == 350) yres = 400; - } - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x3a) & 0x01) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34) == 0x12) - yres = 400; - } - } + SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX; + SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT; + SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT; + SiS_Pr->SiS_VGAVT = (LCDPtr+ResIndex)->VGAVT; + SiS_Pr->SiS_HT = (LCDPtr+ResIndex)->LCDHT; + SiS_Pr->SiS_VT = (LCDPtr+ResIndex)->LCDVT; - if(ModeNo > 0x13) { - if(SiS_Pr->SiS_IF_DEF_FSTN == 1){ - xres *= 2; - yres *= 2; - } else { - if(modeflag & HalfDCLK) xres *= 2; - if(modeflag & DoubleScanMode) yres *= 2; - } - } +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, + "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex); +#endif - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - /* TW: Inserted from 650/301LV BIOS */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - if(xres == 720) xres = 640; - } else { - if((HwDeviceExtension->jChipType != SIS_300) || - (SiS_Pr->SiS_VBInfo & (SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | - SetCRT2ToSCART | SetCRT2ToLCD | SetCRT2ToHiVisionTV))) { - if(xres == 720) xres = 640; - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(yres == 400) yres = 405; - if(yres == 350) yres = 360; - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - if(yres == 360) yres = 375; - } - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768){ - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if(!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) { - if(yres == 350) yres = 357; - if(yres == 400) yres = 420; - if(yres == 480) yres = 525; - } - } - } - /* TW: Inserted for 630/301B */ - if( ( (HwDeviceExtension->jChipType < SIS_315H) && - (HwDeviceExtension->jChipType != SIS_300) ) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { - if(xres == 720) xres = 640; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + tempax = 1024; + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + if(HwInfo->jChipType < SIS_315H) { + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; + else tempbx = 768; + } else { + tempbx = 768; + } + } else { + if (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527; + else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620; + else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775; + else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775; + else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; + else tempbx = 768; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + tempax = 1280; + if (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768; + else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800; + else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864; + else tempbx = 1024; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { + tempax = 1280; + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 700; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 800; + else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960; + else tempbx = 960; + } else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) && + (HwInfo->jChipType >= SIS_661)) { + tempax = 1400; + tempbx = 1050; + if(SiS_Pr->SiS_VGAVDE == 1024) { + tempax = 1280; + tempbx = 1024; } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + tempax = 1600; + tempbx = 1200; + if((HwInfo->jChipType < SIS_661) || (!(SiS_Pr->SiS_SetFlag & LCDVESATiming))) { + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 875; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 1000; + } + } else { + tempax = SiS_Pr->PanelXRes; + tempbx = SiS_Pr->PanelYRes; } - } else { - if(xres == 720) xres = 640; - /* TW: Inserted from 650/LVDS and 630/LVDS BIOS */ - if(SiS_Pr->SiS_SetFlag & CRT2IsVGA) { - 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_LCDInfo & DontExpandLCD) { + tempax = SiS_Pr->SiS_VGAHDE; + tempbx = SiS_Pr->SiS_VGAVDE; + } + SiS_Pr->SiS_HDE = tempax; + SiS_Pr->SiS_VDE = tempbx; + } } - SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; - SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; } -/* TW: Checked against 650/301 and 650/LVDS (1.10.07) BIOS; modified for new panel resolutions */ -/* TW: Done differently in 630/301B BIOS; but same effect; checked against 630/301 */ -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_GetCRT2Data(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { - USHORT tempbx=0,tempal=0; - USHORT Flag,resinfo=0; - - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */ - - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { - tempbx = 15; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - tempbx = 20; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx = 21; - 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 & LCDNonExpanding) tempbx = 24; - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 25; - } else if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) { - tempbx = 13; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempbx++; - } else { - tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_Panel1024x768; - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - tempbx += 5; - /* GetRevisionID(); */ - /* TW: BIOS only adds 5 once */ - tempbx += 5; - } - } - } else { /* TV */ -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV){ - if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_SetFlag &= (~TVSimuMode); /* TW: Was "(!TVSimuMode)" - WRONG */ - tempbx = 2; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(!(SiS_Pr->SiS_SetFlag & TVSimuMode)) tempbx = 12; /* TW: Was 10! - WRONG */ - } - } else { -#endif - if(SiS_Pr->SiS_VBInfo & SetPALTV) tempbx = 3; - else tempbx = 4; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) tempbx += 5; -#ifdef oldHV - } -#endif - } - - if(ModeNo <= 0x13) { - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } - - tempal &= 0x3F; - - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - (SiS_Pr->SiS_VBInfo & (SetCRT2ToTV-SetCRT2ToHiVisionTV))) { - if(tempal == 0x06) tempal = 0x07; - } - - /* TW: Inserted from 300/301LV BIOS */ - if((HwDeviceExtension->jChipType == SIS_300) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - if(ModeNo > 0x13) { - if((resinfo == 0x0c) || (resinfo == 0x0d)) /* 720 (index diff. on 310/325!) */ - tempal = 6; - } - } + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(HwDeviceExtension->jChipType != SIS_300) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if((ModeNo == 0x31) || (ModeNo == 0x32)) tempal = 6; - } - } + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - *CRT2Index = tempbx; - *ResIndex = tempal; - - } else { /* LVDS */ - - Flag = 1; - tempbx = 0; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - Flag = 0; - tempbx = 10; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - tempbx += 2; - if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; - if(SiS_Pr->SiS_CHPALM) { - tempbx = 90; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - } else if(SiS_Pr->SiS_CHPALN) { - tempbx = 92; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - } - - } - } - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - if(Flag == 1) { - tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_PanelMinLVDS; - if(SiS_Pr->SiS_LCDResInfo <= SiS_Pr->SiS_Panel1280x1024) { - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 3; - } else { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - tempbx = 8; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx++; - } - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - tempbx = 7; - } + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) tempbx = 6; + } else { - /* TW: Inserted from 630/LVDS 2.04.5c BIOS */ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - tempbx = 15; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 2; - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { - tempbx = 16; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 2; - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) { - tempbx = 18; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx++; - } - } - } + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - 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; - } + /* Need LVDS Data for LCD on 301B-DH */ + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - if(SiS_Pr->SiS_IF_DEF_FSTN){ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){ - tempbx = 14; - tempal = 6; - } - } + } else { - /* TW: Inserted from 650/LVDS BIOS */ - if(SiS_Pr->SiS_SetFlag & CRT2IsVGA) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) tempal = 7; - if(HwDeviceExtension->jChipType < SIS_315H) { - /* TW: Inserted from 630/LVDS (2.04.5c) and 630/301B (II) BIOS */ - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) tempal++; - } + SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - } + } - /* TW: Inserted from 630/301B BIOS */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(ModeNo > 0x13) { - if(HwDeviceExtension->jChipType < SIS_315H) { - if((resinfo == 0x0c) || (resinfo == 0x0d)) /* 720 */ - tempal = 6; - } else { - if((resinfo == 0x0d) || (resinfo == 0x0e)) /* 720 */ - tempal = 6; - } - } - } + } - *CRT2Index = tempbx; - *ResIndex = tempal & 0x1F; - } -} + } else { -void -SiS_GetCRT2PtrA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index, - USHORT *ResIndex) -{ - USHORT tempbx,tempal; + SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - 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; - } - - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 5; - if(ModeNo <= 0x13) - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - else - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - *CRT2Index = tempbx; - *ResIndex = tempal & 0x1F; + } } -/* TW: New from 650/301LVx BIOS */ -void -SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index, - USHORT *ResIndex) -{ - USHORT tempbx,tempal; - - if(ModeNo <= 0x13) - tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - else - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - - tempbx = SiS_Pr->SiS_LCDResInfo; - - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 16; - else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx += 32; - - *CRT2Index = tempbx; - *ResIndex = tempal & 0x3F; -} +/*********************************************/ +/* GET LVDS DES DATA */ +/*********************************************/ -/* TW: Checked against all (incl 650/LVDS (1.10.07), 630/301B, 630/301) BIOSes */ -USHORT -SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_GetLVDSDesPtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, USHORT *PanelIndex, + USHORT *ResIndex, PSIS_HW_INFO HwInfo) { - SHORT LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01 }; - USHORT RefreshRateTableIndex,i,backup_i; - USHORT modeflag,index,temp,backupindex; - - if(SiS_Pr->UseCustomMode) return 0; - - if(ModeNo <= 0x13) - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - else - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(modeflag & HalfDCLK) return(0); - } - } - - if(ModeNo < 0x14) return(0xFFFF); - - /* TW: CR33 holds refresh rate index for CRT1 [3:0] and CRT2 [7:4]. - * On LVDS machines, CRT2 index is always 0 and will be - * set to 0 by the following code; this causes the function - * to take the first non-interlaced mode in SiS_Ext2Struct - */ - - index = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x33); - index >>= SiS_Pr->SiS_SelectCRT2Rate; - index &= 0x0F; - backupindex = index; - - if(index > 0) index--; - - if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0; - } else { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if((HwDeviceExtension->jChipType < SIS_315H) && - (HwDeviceExtension->jChipType != SIS_300)) - index = 0; - else if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) - index = backupindex = 0; - } - } - } - - if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - index = 0; - } - } - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - /* TW: This is not done in 630/301B BIOS */ - temp = LCDRefreshIndex[SiS_Pr->SiS_LCDResInfo]; - if(index > temp) index = temp; - } else { - index = 0; - } - } - } - - RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; - ModeNo = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].ModeID; + USHORT tempbx,tempal,modeflag; - /* TW: Inserted from 650/LVDS 1.10.07, 650/301LVx 1.10.6s */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(!(SiS_Pr->SiS_VBInfo & DriverMode)) { - if( (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x105) || - (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x107) ) { - if(backupindex <= 1) - RefreshRateTableIndex++; - } - } + if(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; } - 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_VBInfo & SetCRT2ToRAMDAC)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - temp = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + i - 1].Ext_InfoFlag; - if(temp & InterlaceMode) { - i++; - } - } + tempbx = 0; + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tempbx = 50; + if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) tempbx += 2; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; + /* Nothing special needed for SOverscan */ + /* PALM uses NTSC data, PALN uses PAL data */ + } } - i--; - - if((SiS_Pr->SiS_SetFlag & ProgrammingCRT2) && (!(SiS_Pr->SiS_VBInfo & DisableCRT2Display))) { - backup_i = i; - if (!(SiS_AdjustCRT2Rate(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,&i,HwDeviceExtension))) { - /* TW: This is for avoiding random data to be used; i is - * in an undefined state if no matching CRT2 mode is - * found. - */ - i = backup_i; - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + tempbx = SiS_Pr->SiS_LCDTypeInfo; + if(HwInfo->jChipType >= SIS_661) { + /* As long as we don's use the BIOS tables, we + * need to convert the TypeInfo as for 315 series + */ + tempbx = SiS_Pr->SiS_LCDResInfo - 1; + } + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 16; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + tempbx = 32; + if(modeflag & HalfDCLK) tempbx++; + } } - return(RefreshRateTableIndex + i); -} - -/* 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 (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; - tempbx = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].ModeID; - - tempax = 0; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - /* TW: For 301, 301B, 302B, 301LV, 302LV */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { - tempax |= SupportRAMDAC2; - if(HwDeviceExtension->jChipType >= SIS_315H) { - tempax |= SupportTV; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == 0x0a) tempax |= SupportTV1024; - } - } - } - } - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - tempax |= SupportLCD; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) { - if((resinfo == 6) && (SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) { - tempax |= SupportAllCRT2; - (*i) = 0; /* TW: Restore RefreshTableIndex (BIOS 650/301LVx 1.10.6s) */ - return(1); - } else { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) { - if((resinfo == 6) && (SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) { - return(0); - } else { - if((resinfo >= 9) && (resinfo != 0x14)) { - tempax = 0; - return(0); - } - } - } - } - } - } - } - } else { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - if((resinfo != 0x0f) && ((resinfo == 4) || (resinfo >= 8))) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { - if((resinfo != 0x10) && (resinfo > 8)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { - if((resinfo != 0x0e) && (resinfo > 8)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(resinfo > 9) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(resinfo > 8) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - if((resinfo == 4) || (resinfo > 7)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { - if((resinfo == 4) || (resinfo == 3) || (resinfo > 6)) return(0); - } - } - } -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */ - tempax |= SupportHiVisionTV; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode){ - if(resinfo == 4) return(0); - if(resinfo == 3) { - if(SiS_Pr->SiS_SetFlag & TVSimuMode) return(0); - } - if(resinfo > 7) return(0); - } - } else { -#endif - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) { - tempax |= SupportTV; - tempax |= SupportTV1024; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if((SiS_Pr->SiS_VBInfo & SetNotSimuMode) && (SiS_Pr->SiS_VBInfo & SetPALTV)) { - if(resinfo != 8) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 4)) ) { - tempax &= ~(SupportTV1024); - if(HwDeviceExtension->jChipType >= SIS_315H) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else { - if( (resinfo != 3) || - (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == 3) return(0); - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0); - } - } - } else return(0); - } - } - } - } else { - tempax &= ~(SupportTV1024); - if(HwDeviceExtension->jChipType >= SIS_315H) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else { - if( (resinfo != 3) || - (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == 3) return(0); - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0); - } - } - } else return(0); - } - } - } else { /* slavemode */ - if(resinfo != 8) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 4) ) ) { - tempax &= ~(SupportTV1024); - if(HwDeviceExtension->jChipType >= SIS_315H) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else { - if( (resinfo != 3) || - (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == 3) return(0); - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0); - } - } - } else return(0); - } - } - } - } - } else { /* 301 */ - tempax &= ~(SupportTV1024); - if(HwDeviceExtension->jChipType >= SIS_315H) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) || - ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0); - } - } - } else { - if( (resinfo != 3) || - (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == 3) return(0); - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0); - } - } - } else return(0); - } - } + if(SiS_Pr->SiS_SetFlag & SetDOSMode) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + tempal = 0x07; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) tempal++; } -#ifdef oldHV - } -#endif - } else { /* TW: 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 != 0x14) && (resinfo > 0x09)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - if((resinfo != 0x0f) && (resinfo > 0x08)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { - if((resinfo != 0x10) && (resinfo > 0x08)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - if((resinfo != 0x15) && (resinfo > 0x09)) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(resinfo > 0x09) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(resinfo > 0x08) return(0); - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600){ - if(resinfo > 0x07) return(0); - if(resinfo == 0x04) return(0); - } - } - } - /* TW: Look backwards in table for matching CRT2 mode */ - for(; SiS_Pr->SiS_RefIndex[RefreshRateTableIndex+(*i)].ModeID == tempbx; (*i)--) { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].Ext_InfoFlag; - if(infoflag & tempax) { - return(1); - } - if ((*i) == 0) break; - } - /* TW: Look through the whole mode-section of the table from the beginning - * for a matching CRT2 mode if no mode was found yet. - */ - for((*i) = 0; ; (*i)++) { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].Ext_InfoFlag; - if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].ModeID != tempbx) { - return(0); - } - if(infoflag & tempax) { - return(1); - } + } } - return(1); -} -/* Checked against 650/LVDS (1.10.07) and 650/301LV BIOS */ -void -SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo) -{ - USHORT temp1,temp2; - - /* TW: We store CRT1 ModeNo in CR34 */ - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x34,ModeNo); - temp1 = (SiS_Pr->SiS_VBInfo & SetInSlaveMode) >> 8; - temp2 = ~(SetInSlaveMode >> 8); - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x31,temp2,temp1); + *PanelIndex = tempbx; + *ResIndex = tempal & 0x1F; } -/* TW: Checked against 650+301, 650/LVDS (1.10.07) and 650/301LVx (1.10.6s) BIOS */ -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(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - if (ModeNo <= 0x13) - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } - } - - SiS_Pr->SiS_SetFlag = 0; - - SiS_Pr->SiS_ModeType = modeflag & ModeInfoFlag; - - tempbx = 0; - if(SiS_BridgeIsOn(SiS_Pr,BaseAddr,HwDeviceExtension) == 0) { /* TW: "== 0" inserted from 630/301B BIOS */ - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - /* SiS_HiVision is only used on 310/325+30xB/LV/LVX */ - if(SiS_Pr->SiS_HiVision & 0x03) { /* TW: New from 650/301LVx 1.10.6s */ - temp &= (SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode); /* 0x83 */ - temp |= SetCRT2ToHiVisionTV; /* 0x80 */ - } - if(SiS_Pr->SiS_HiVision & 0x04) { /* TW: New from 650/301LVx 1.10.6s */ - temp &= (SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode); /* 0x83 */ - temp |= SetCRT2ToSVIDEO; /* 0x08 */ - } - if(SiS_Pr->SiS_IF_DEF_FSTN) { /* fstn must set CR30=0x21 */ - temp = (SetCRT2ToLCD | SetSimuScanMode); - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,temp); - } - tempbx |= temp; - tempax = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) << 8; - tempax &= (LoadDACFlag | DriverMode | SetDispDevSwitch | SetNotSimuMode | SetPALTV); - tempbx |= tempax; - tempbx &= ~(SetCHTVOverScan | SetInSlaveMode | DisableCRT2Display);; - #ifdef SIS315H +static void +SiS_GetLVDSDesPtrA(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, USHORT *PanelIndex, USHORT *ResIndex, + PSIS_HW_INFO HwInfo) +{ + USHORT tempbx=0,tempal; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & (VB_SIS302B | VB_SIS30xLV | VB_SIS30xNEW)) { -#if 0 /* Not in 1.10.8r */ - if(ModeNo == 3) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x31,0xbf); - } -#endif -#if 0 /* Not in 1.10.8r */ - if(!(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8))) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); - } -#endif - 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 */ - } - } - } - } - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) { - tempbx |= SetCRT2ToLCDA; - } - } - /* TW: Inserted from 650/LVDS 1.10.07 BIOS: */ - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if(temp & SetToLCDA) - tempbx |= SetCRT2ToLCDA; - if(temp & EnableLVDSHiVision) - tempbx |= SetCRT2ToHiVisionTV; - } - } - -#endif /* SIS315H */ - - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - temp = SetCRT2ToLCDA | SetCRT2ToSCART | SetCRT2ToLCD | - SetCRT2ToRAMDAC | SetCRT2ToSVIDEO | SetCRT2ToAVIDEO; /* = 0x807C; */ - if(SiS_Pr->SiS_IF_DEF_HiVision == 1) - temp |= 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))) { - tempbx &= (0xFF00|SetCRT2ToLCD|SwitchToCRT2|SetSimuScanMode); - } - if(tempbx & SetCRT2ToSCART) { - tempbx &= (0xFF00|SetCRT2ToSCART|SwitchToCRT2|SetSimuScanMode); - tempbx |= SetPALTV; - } -#if 0 /* TW: Not done in 650/301LVx 1.10.6s BIOS */ - } else if(tempbx & SetCRT2ToHiVisionTV){ - tempbx &= (0xFF00|SetCRT2ToHiVisionTV|SwitchToCRT2|SetSimuScanMode); - tempbx |= SetPALTV; - } -#endif - } 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(tempax & DisableCRT2Display) { - if(!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { - tempbx = SetSimuScanMode | DisableCRT2Display; - } - } - - if(!(tempbx & DriverMode)){ - tempbx |= SetSimuScanMode; - } + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempbx = 2; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 3; + else tempbx = SiS_Pr->SiS_LCDResInfo - 2; - /* TW: LVDS (LCD/TV) and 630+301B (LCD) can only be slave in 8bpp modes */ - if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_ModeType <= ModeVGA) ) { - modeflag &= (~CRT2Mode); - } - if( (HwDeviceExtension->jChipType < SIS_315H) && - (HwDeviceExtension->jChipType != SIS_300) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - if(SiS_Pr->SiS_ModeType <= ModeVGA) { - if(tempbx & SetCRT2ToLCD) { - modeflag &= (~CRT2Mode); - } - } - } - /* TW end */ - - if(!(tempbx & SetSimuScanMode)){ - if(tempbx & SwitchToCRT2) { - if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { - if( (HwDeviceExtension->jChipType >= SIS_315H) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { - if(resinfo != 0x0a) - tempbx |= SetSimuScanMode; - } else { - tempbx |= SetSimuScanMode; - } - } - } else { - if(!(SiS_BridgeIsEnable(SiS_Pr,BaseAddr,HwDeviceExtension))) { - if(!(tempbx & DriverMode)) { - if(SiS_BridgeInSlave(SiS_Pr)) { - tempbx |= SetSimuScanMode; - } - } - } - } - } + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 4; - if(!(tempbx & DisableCRT2Display)) { - if(tempbx & DriverMode) { - if(tempbx & SetSimuScanMode) { - if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { - if( (HwDeviceExtension->jChipType >= SIS_315H) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { - if(resinfo != 0x0a) { /* TW: Inserted from 650/301 BIOS */ - tempbx |= SetInSlaveMode; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(tempbx & SetCRT2ToTV) { - if(!(tempbx & SetNotSimuMode)) - SiS_Pr->SiS_SetFlag |= TVSimuMode; - } - } - } /* TW: Inserted from 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_CustomT == CUT_CLEVO1024) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + tempbx = 80; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; } + } } - - if(SiS_Pr->SiS_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_WhatIsThis(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 - -#if 0 /* TW: Incomplete! (But does not seem to be required) */ - if(HwDeviceExtension->jChipType < SIS_315H) { - /* TW: From A901/630+301B BIOS */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) + if((SiS_Pr->SiS_CustomT == CUT_UNIWILL1024) || + (SiS_Pr->SiS_CustomT == CUT_UNIWILL10242)) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + tempbx = 82; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; } - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) - if( [si] == 3) ModeIdIndex = 0x3f2b; - } + } + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + tempbx = 84; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; } - SiS_SetRegAND(SiS_Pr->SiS_P3d4, 0x31, 0xF7); - if(ModeNo == 0x13) bp+4 = 0x03; - } else { - /* From 650/301LVx BIOS: */ - SiS_SetRegAND(SiS_Pr->SiS_P3d4, 0x31, 0xF7); - if(ModeNo == 0x13) bp+4 = 0x03; - else bp+4 = ModeNo; } -#endif - /* TW: 630/301B and 650/301 (not 301LV!) BIOSes do more here, but this seems for DOS mode */ + if(ModeNo <= 0x13) + tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + else + tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + *PanelIndex = tempbx; + *ResIndex = tempal & 0x1F; } +#endif -void -SiS_WhatIsThis(SiS_Private *SiS_Pr, USHORT myvbinfo) +static void +SiS_GetLVDSDesData(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { - unsigned long eax, temp; - unsigned short temp1; - - if(!(SiS_Pr->SiS_ChSW)) return; - -#ifndef LINUX_XF86 - SiS_SetReg4(0xcf8,0x80000874); - eax = SiS_GetReg3(0xcfc); -#else - eax = pciReadLong(0x00000800, 0x74); -#endif - eax &= 0xFFFF; - temp = eax; - eax += 0x3c; - temp1 = SiS_GetReg4((USHORT)eax); - temp1 &= 0xFEFF; - SiS_SetReg5((USHORT)eax, temp1); - temp1 = SiS_GetReg4((USHORT)eax); - eax = temp; - eax += 0x3a; - temp1 = SiS_GetReg4((USHORT)eax); - temp1 &= 0xFEFF; - if(!(myvbinfo & SetCRT2ToTV)) { - temp1 |= 0x0100; - } - SiS_SetReg5((USHORT)eax, temp1); - temp1 = SiS_GetReg4((USHORT)eax); -} + USHORT modeflag; + USHORT PanelIndex,ResIndex; + const SiS_LVDSDesStruct *PanelDesPtr = NULL; -void -SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT tempax,tempbx,temp; - USHORT temp1,modeflag=0,tempcx; - USHORT StandTableIndex,CRT1Index; - USHORT ResInfo,DisplayType; - const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr = NULL; + if((SiS_Pr->UseCustomMode) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) || + (SiS_Pr->SiS_CustomT == CUT_PANEL848)) { + SiS_Pr->SiS_LCDHDES = 0; + SiS_Pr->SiS_LCDVDES = 0; + return; + } - SiS_Pr->SiS_RVBHCMAX = 1; - SiS_Pr->SiS_RVBHCFACT = 1; + if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - if(ModeNo <= 0x13){ +#ifdef SIS315H + SiS_GetLVDSDesPtrA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + &PanelIndex, &ResIndex, HwInfo); - 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]; + 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; + case 82: PanelDesPtr = (SiS_LVDSDesStruct *)Uniwill1024x768Des_1; break; + case 83: PanelDesPtr = (SiS_LVDSDesStruct *)Uniwill1024x768Des_2; break; + case 84: PanelDesPtr = (SiS_LVDSDesStruct *)Compaq1280x1024Des_1; break; + case 85: PanelDesPtr = (SiS_LVDSDesStruct *)Compaq1280x1024Des_2; break; + default: PanelDesPtr = SiS_Pr->LVDS1024x768Des_1; break; + } +#endif } else { - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ) { - - temp = SiS_GetLVDSCRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,&ResInfo,&DisplayType); - - if(temp == 0) return; - - switch(DisplayType) { - case 0 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1; break; - case 1 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; - case 2 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1; break; - case 3 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1_H; break; - case 4 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1_H; break; - case 5 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1_H; break; - case 6 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2; break; - case 7 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2; break; - case 8 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2; break; - case 9 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2_H; break; - case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2_H; break; - case 11: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2_H; break; - case 12: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1; break; - case 13: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H; break; - case 14: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1; break; - case 15: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1_H; break; - case 16: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2; break; - case 17: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2_H; break; - case 18: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UNTSC; break; - case 19: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1ONTSC; break; - case 20: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UPAL; break; - case 21: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break; - case 22: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x480_1; break; - case 23: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1; break; - case 24: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1_H; break; - case 25: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2; break; - case 26: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2_H; break; - case 27: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1; break; - case 28: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1_H; break; - case 29: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2; break; - case 30: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2_H; break; - case 36: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1; break; - case 37: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1_H; break; - case 38: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2; break; - case 39: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2_H; break; - case 99: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break; - default: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; - } - tempax = (LVDSCRT1Ptr+ResInfo)->CR[0]; - tempax |= (LVDSCRT1Ptr+ResInfo)->CR[14] << 8; - tempax &= 0x03FF; - tempbx = (LVDSCRT1Ptr+ResInfo)->CR[6]; - tempcx = (LVDSCRT1Ptr+ResInfo)->CR[13] << 8; - tempcx &= 0x0100; - tempcx <<= 2; - tempbx |= tempcx; - temp1 = (LVDSCRT1Ptr+ResInfo)->CR[7]; - - } 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]; - - } + 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: + if(HwInfo->jChipType < SIS_315H) + PanelDesPtr = SiS_Pr->SiS_PanelType0e_1; + else + PanelDesPtr = SiS_Pr->SiS_PanelType01_1; + break; + } } + SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES; + SiS_Pr->SiS_LCDVDES = (PanelDesPtr+ResIndex)->LCDVDES; - 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(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; + } + } + } else { + if(!(SiS_Pr->SiS_SetFlag & SetDOSMode)) { + if( (HwInfo->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(HwInfo->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(modeflag & Charx8Dot) tempax *= 8; - else tempax *= 9; - - /* TW: From 650/301LVx 1.10.6s */ - if(modeflag & HalfDCLK) tempax <<= 1; - - SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; - tempbx++; - SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = tempbx; } -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); -} +/*********************************************/ +/* SET CRT2 AUTO-THRESHOLD */ +/*********************************************/ -void -SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr) +#ifdef SIS315H +static void +SiS_CRT2AutoThreshold(SiS_Private *SiS_Pr) { - if(HwDeviceExtension->jChipType >= SIS_315H) - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2F,0xFE); - else - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x24,0xFE); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40); } +#endif -void -SiS_EnableCRT2(SiS_Private *SiS_Pr) -{ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); -} +/*********************************************/ +/* DISABLE VIDEO BRIDGE */ +/*********************************************/ -/* Checked against all BIOSes */ +/* 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_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr) +SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { #ifdef SIS315H - USHORT tempah,pushax=0; + USHORT tempah,pushax=0,modenum; #endif USHORT temp=0; - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - if (SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ===== TW: For 30xB/LV ===== */ + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ===== For 30xB/LV ===== */ - if(HwDeviceExtension->jChipType < SIS_315H) { + if(HwInfo->jChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ - if(HwDeviceExtension->jChipType == SIS_300) { /* New for 300+301LV */ + if(HwInfo->jChipType == SIS_300) { /* For 300+301LV (A907) */ - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { - 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); + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } } + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0x3f); + SiS_ShortDelay(SiS_Pr,1); SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); SiS_DisplayOff(SiS_Pr); SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - if( (!(SiS_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_SIS301LV302LV) { + if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) ) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); + } } } else { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); } - if(SiS_Is301B(SiS_Pr,BaseAddr)) { + if(SiS_Is301B(SiS_Pr)) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0x3f); SiS_ShortDelay(SiS_Pr,1); } @@ -4759,12 +3570,12 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USH 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_UnLockCRT2(SiS_Pr,HwInfo); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); - if( (!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) || - (!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) ) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); + if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) ) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xFB,0x04); } } @@ -4773,141 +3584,222 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USH } else { -#ifdef SIS315H /* 310/325 series */ +#ifdef SIS315H /* 315 series */ - if(IS_SIS650740) { /* 650, 740 */ + if(IS_SIS550650740660) { /* 550, 650, 740, 660 */ -#if 0 - if(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00) != 1) return; /* From 1.10.7w */ -#endif + modenum = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34); - if(SiS_Pr->SiS_VBType & (VB_SIS30xLV|VB_SIS30xNEW)) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* LV */ - if(!(SiS_IsM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) { - tempah = 0xef; - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - tempah = 0xf7; - } - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { +#ifdef SET_EMI_CPQ + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x30,0x00); +#endif + } else if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { +#ifdef SET_EMI + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x30,0x00); +#endif + } + } + + if( (modenum <= 0x13) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (SiS_IsVAMode(SiS_Pr,HwInfo)) ) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); + if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } } - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); + if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { + SiS_DDC2Delay(SiS_Pr,0xff00); + SiS_DDC2Delay(SiS_Pr,0xe000); - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00); - } else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00); - } + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00); + pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06); - 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); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); - } + if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { + tempah = 0xef; + if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + tempah = 0xf7; + } + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); + } + } + + } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { /* B-DH */ + + if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,0xef); + } + + } - if(SiS_Pr->SiS_VBType & (VB_SIS301B|VB_SIS302B)) { + 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)) { + if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { tempah = 0x7f; - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { tempah = 0xbf; } } SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); - } + } - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { + if((SiS_IsVAMode(SiS_Pr,HwInfo)) || + ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) { - if(SiS_Pr->SiS_VBType & (VB_SIS301B|VB_SIS302B)) { + 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_PanelDelay(SiS_Pr, HwInfo, 2); SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF); + if((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13)) { + SiS_DisplayOff(SiS_Pr); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); + } } } else { - if(SiS_Pr->SiS_VBType & (VB_SIS301B|VB_SIS302B)) { - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { + if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + if(!(SiS_IsDualEdge(SiS_Pr,HwInfo))) { SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf); SiS_DisplayOff(SiS_Pr); } SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - 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); + SiS_PanelDelay(SiS_Pr, HwInfo, 2); } + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); + } - if(SiS_Pr->SiS_VBType & (VB_SIS30xLV|VB_SIS30xNEW)) { + 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)) { + if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { tempah = 0x7f; - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { tempah = 0xbf; } } SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); + if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) { /* 1.10.8r, 8m */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); + } /* 1.10.8r, 8m */ - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { 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); + 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); } } } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); - } + } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { + /* NIL */ - } else { /* 315, 330 */ + } else if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { - if(SiS_Is301B(SiS_Pr,BaseAddr)) { + if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { + tempah = 0xef; + if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + if(modenum > 0x13) { + tempah = 0xf7; + } + } + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); + } + if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + if((SiS_IsVAMode(SiS_Pr,HwInfo)) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo)))) { + if((!(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo))) || + (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo)))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); + SiS_PanelDelay(SiS_Pr, HwInfo, 4); + } + } + } + + } + + } else { /* 315, 330 - all bridge types */ + + if(SiS_Is301B(SiS_Pr)) { tempah = 0x3f; - if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) { + if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { tempah = 0x7f; - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { tempah = 0xbf; } } SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { + if(SiS_IsVAMode(SiS_Pr,HwInfo)) { 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))) || + (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { - if( (!(SiS_Is301B(SiS_Pr,BaseAddr))) || - (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) ) { + if( (!(SiS_Is301B(SiS_Pr))) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ) { SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); SiS_DisplayOff(SiS_Pr); @@ -4918,10 +3810,10 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USH SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00); + 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_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); } @@ -4931,69 +3823,69 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USH } - } else { /* ============ TW: For 301 ================ */ + } else { /* ============ For 301 ================ */ - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF0,0x0B); - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 1); - } + if(HwInfo->jChipType < SIS_315H) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } } SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */ SiS_DisplayOff(SiS_Pr); - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); } SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00); + 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_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); } else { SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */ + if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) ) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xFB,0x04); + } } } - } else { /* ============ TW: For LVDS =============*/ + } else { /* ============ For LVDS =============*/ - if(HwDeviceExtension->jChipType < SIS_315H) { + if(HwInfo->jChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - SiS_SetCH700x(SiS_Pr,0x090E); + SiS_SetCH700x(SiS_Pr,0x090E); } - if(HwDeviceExtension->jChipType == SIS_730) { - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); + if(HwInfo->jChipType == SIS_730) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { + SiS_WaitVBRetrace(SiS_Pr,HwInfo); } - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); } } else { - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { - - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { - - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) { - - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - - if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) { - SiS_DisplayOff(SiS_Pr); - } - - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - } + 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_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); + } } } } @@ -5003,112 +3895,126 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USH SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr); + SiS_UnLockCRT2(SiS_Pr,HwInfo); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); - if( (!(SiS_CRT2IsLCD(SiS_Pr,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_CRT2IsLCD(SiS_Pr, HwInfo))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) ) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xFB,0x04); } #endif /* SIS300 */ } else { -#ifdef SIS315H /* 310/325 series */ +#ifdef SIS315H /* 315 series */ if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_Chrontel701xBLOff(SiS_Pr); - SiS_Chrontel701xOff(SiS_Pr); - } else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_Chrontel701xBLOff(SiS_Pr); - SiS_Chrontel701xOff(SiS_Pr); - } - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetCH701x(SiS_Pr,0x0149); - } else if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetCH701x(SiS_Pr,0x0149); - } + if(HwInfo->jChipType == SIS_740) { + temp = SiS_GetCH701x(SiS_Pr,0x61); + if(temp < 1) { + SiS_SetCH701x(SiS_Pr,0xac76); + SiS_SetCH701x(SiS_Pr,0x0066); + } + + if( (!(SiS_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_IF_DEF_CH70xx == 0) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, HwInfo, 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); + if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (!(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo))) ) { + SiS_DisplayOff(SiS_Pr); } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - } else if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - } else if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || + (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || + (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + } + + if(HwInfo->jChipType == SIS_740) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); } SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); - 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); + 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_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, BaseAddr,HwDeviceExtension)) { - 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_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); + if(HwInfo->jChipType == SIS_550) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xbf); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xef); + } + } + } else { + if(HwInfo->jChipType == SIS_740) { + if(SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); + } + } else if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); + } } if(SiS_Pr->SiS_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); - } + if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + /* SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xff); */ + } else { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); + } } - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); + SiS_UnLockCRT2(SiS_Pr,HwInfo); - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); - } else if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); - } else if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); + if(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 0 /* TW: BIOS code makes no sense */ - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { - /* Nothing there! */ - } - } - } -#endif - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, BaseAddr,HwDeviceExtension)) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xFB,0x04); - } - } - } + 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_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xFB,0x04); + } + } + } #endif /* SIS315H */ @@ -5118,103 +4024,101 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USH } -/* TW: Checked against all BIOSes */ +/*********************************************/ +/* 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_EnableBridge(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 temp1,pushax=0; BOOLEAN delaylong = FALSE; #endif - UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* TW: ====== For 301B et al ====== */ + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ====== For 301B et al ====== */ - if(HwDeviceExtension->jChipType < SIS_315H) { + if(HwInfo->jChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ - if(HwDeviceExtension->jChipType == SIS_300) { + if(HwInfo->jChipType == SIS_300) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) { - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 0); + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); + if(!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } } } - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ if(SiS_BridgeInSlave(SiS_Pr)) { - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); + 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 */ - 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); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0); + SiS_DisplayOn(SiS_Pr); + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 1); } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfe,0x01); - } - } + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); + } + } } } else { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { + if((SiS_Pr->SiS_VBType & VB_NoLCD) && + (SiS_CRT2IsLCD(SiS_Pr, HwInfo))) { + /* 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); + if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 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_UnLockCRT2(SiS_Pr,HwInfo); SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); if(SiS_BridgeInSlave(SiS_Pr)) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); } else { SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); } - if(!(SiS_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_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,HwDeviceExtension); + SiS_WaitVBRetrace(SiS_Pr,HwInfo); 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); - } + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ + if(SiS_BridgeInSlave(SiS_Pr)) { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0); + SiS_DisplayOn(SiS_Pr); } } @@ -5222,199 +4126,313 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USH } else { -#ifdef SIS315H /* 310/325 series */ +#ifdef SIS315H /* 315 series */ - if(IS_SIS650740) { /* 650, 740 */ + if(IS_SIS550650740660) { /* 550, 650, 740, 660 */ -#if 0 - if(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00) != 1) return; /* From 1.10.7w */ -#endif + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(SiS_Pr->SiS_VBType & (VB_SIS30xLV|VB_SIS30xNEW)) { + 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 | VB_SIS302ELV)) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x30,0x00); /* 1.10.7u */ + } +#endif + } - if(!(SiS_IsM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) { + if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { tempah = 0x10; - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - tempah = 0x08; - } - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,tempah); + if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) { + if((SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) == 0x0c) { + tempah = 0x08; + } else { + tempah = 0x18; + } + } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4c,tempah); + } else { + if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + tempah = 0x08; + } + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,tempah); + } } - SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00); - - SiS_DisplayOff(SiS_Pr); + if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); + SiS_DisplayOff(SiS_Pr); + pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06); + if(IS_SIS740) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); + } + } - pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06); + if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || + (SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ) { + if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { + if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2); + } else { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } + } + } - if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) { - if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - } + if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40)) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + delaylong = TRUE; + } } - if(!(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x40)) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - delaylong = TRUE; + } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { + + if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x10); } + } else if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + + if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { + tempah = 0x10; + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) { + tempah = 0x18; + if((SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) == 0x0c) { + tempah = 0x08; + } + } + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,tempah); + } + } - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF; + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; if(SiS_BridgeInSlave(SiS_Pr)) { - tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) { + if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04)) temp |= 0x20; + } else temp |= 0x20; + } } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ - if(SiS_Pr->SiS_VBType & (VB_SIS301B|VB_SIS302B)) { + + 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); + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2e); if(!(temp & 0x80)) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); } } else { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2); + SiS_PanelDelay(SiS_Pr, HwInfo, 2); } - } - - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x20); + } else { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x20); } SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); - if(SiS_Pr->SiS_VBType & (VB_SIS301B|VB_SIS302B)) { - temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2e); + if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) { + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2e); if(!(temp & 0x80)) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); } } tempah = 0xc0; - if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) { + if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { tempah = 0x80; - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { + if(!(SiS_IsVAMode(SiS_Pr, HwInfo))) { tempah = 0x40; } } SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah); - if(SiS_Pr->SiS_VBType & (VB_SIS301B|VB_SIS302B)) { + if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || + (((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) && + (!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))))) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); } - if(SiS_Pr->SiS_VBType & (VB_SIS30xLV|VB_SIS30xNEW)) { - - 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_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - if(delaylong) { - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3); - } - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfe,0x01); - } - } + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax); - SiS_DisplayOn(SiS_Pr); - SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff); + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { +#ifdef SET_EMI_CPQ + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x30,0x00); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,0x08); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,0x10); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x33,0x4d); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + if((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0x0f) != 0x02) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,0x0d); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,0x70); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x33,0x6b); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + } + } +#endif + } else if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { +#ifdef SET_EMI + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetReg(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 | VB_SIS302ELV)) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,0x12); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,0xd0); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x33,0x6b); + if((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0x0f) == 0x02) { /* Acer */ + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,0x0d); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,0x70); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x33,0x40); + if(((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0) != 0x30)) { /* Acer */ + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,0x05); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,0x60); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x33,0x33); /* 00 */ + } + } + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + if((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0x0f) != 0x03) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); + } + } +#endif + } - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); - } + if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { + SiS_PanelDelay(SiS_Pr, HwInfo, 2); + } - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x05); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x60); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1f,0x10); - } + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || + (SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ) { + SiS_DisplayOn(SiS_Pr); + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + SiS_WaitVBRetrace(SiS_Pr, HwInfo); + SiS_PanelDelay(SiS_Pr, HwInfo, 3); +#ifdef SET_EMI_CPQ + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); + } +#endif + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); + } + } - } else { /* 315, 330 */ + } else if(SiS_Pr->SiS_CustomT == CUT_CLEVO1400) { - 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); + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + if( (SiS_IsVAMode(SiS_Pr, HwInfo)) || + (SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ) { + SiS_DisplayOn(SiS_Pr); + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + SiS_WaitVBRetrace(SiS_Pr,HwInfo); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); + } + } - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ + } else { - temp=SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E); - if (!(temp & 0x80)) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); - } + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || + ((SiS_CRT2IsLCD(SiS_Pr, HwInfo))) ) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + if(delaylong) { + SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + } + SiS_WaitVBRetrace(SiS_Pr,HwInfo); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); + } + } - if(SiS_Is301B(SiS_Pr,BaseAddr)) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); + SiS_DisplayOn(SiS_Pr); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xff); - temp=SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E); - if (!(temp & 0x80)) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + } - 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); + } - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + } - } else { - - SiS_VBLongWait(SiS_Pr); - SiS_DisplayOn(SiS_Pr); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7F); - SiS_VBLongWait(SiS_Pr); + } else { /* 315, 330 */ - } + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; + if(SiS_BridgeInSlave(SiS_Pr)) { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); + + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ + + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); + if(!(temp & 0x80)) + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + } + + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); + + if(SiS_Is301B(SiS_Pr)) { + + temp=SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); + if(!(temp & 0x80)) + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + + tempah = 0xc0; + if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + tempah = 0x80; + if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + tempah = 0x40; + } + } + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah); + + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + + } else { + + SiS_VBLongWait(SiS_Pr); + SiS_DisplayOn(SiS_Pr); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7F); + SiS_VBLongWait(SiS_Pr); + + } } /* 315, 330 */ @@ -5422,117 +4440,112 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USH } - } else { /* ============ TW: For 301 ================ */ + } else { /* ============ For 301 ================ */ - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF0,0x0B); - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 0); - } + if(HwInfo->jChipType < SIS_315H) { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xFB); + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } } - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ + temp = SiS_GetReg(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; + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ - 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(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 */ + } } SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ SiS_VBLongWait(SiS_Pr); SiS_DisplayOn(SiS_Pr); - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); } SiS_VBLongWait(SiS_Pr); - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 1); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF0,0x03); - } + if(HwInfo->jChipType < SIS_315H) { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xF7); + } } } - } else { /* =================== TW: For LVDS ================== */ + } else { /* =================== For LVDS ================== */ - if(HwDeviceExtension->jChipType < SIS_315H) { + if(HwInfo->jChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ - 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); - } - } + 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_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xFB); + if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) { + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } + } - SiS_EnableCRT2(SiS_Pr); - SiS_DisplayOn(SiS_Pr); - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); - if(SiS_BridgeInSlave(SiS_Pr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); - } + SiS_EnableCRT2(SiS_Pr); + SiS_DisplayOn(SiS_Pr); + SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); + if(SiS_BridgeInSlave(SiS_Pr)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); + } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) { - SiS_SetCH700x(SiS_Pr,0x0B0E); - } - } + 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,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(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_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xF7); + } } - } + } #endif /* SIS300 */ } else { -#ifdef SIS315H /* 310/325 series */ - -#if 0 /* BIOS code makes no sense */ - if(SiS_IsVAMode()) { - if(SiS_IsLCDOrLCDA()) { - } - } -#endif +#ifdef SIS315H /* 315 series */ if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xFB); - SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 0); - } + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xFB); + SiS_PanelDelay(SiS_Pr, HwInfo, 0); + } } SiS_EnableCRT2(SiS_Pr); - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr); + SiS_UnLockCRT2(SiS_Pr,HwInfo); SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); @@ -5542,63 +4555,72 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USH SiS_Chrontel701xBLOff(SiS_Pr); } - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); - - temp1 = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E); - if (!(temp1 & 0x80)) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); - - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(temp) { - SiS_Chrontel701xBLOn(SiS_Pr); - } + if(HwInfo->jChipType != SIS_550) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) { + 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); - } - } else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); + } + } } - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + temp1 = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); + if(!(temp1 & 0x80)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); } if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(temp) { + SiS_Chrontel701xBLOn(SiS_Pr, HwInfo); + } + } - if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_Chrontel701xOn(SiS_Pr,HwDeviceExtension, BaseAddr); - } + 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_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); - } + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + } + 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); + } } if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_Chrontel701xBLOn(SiS_Pr); - SiS_ChrontelDoSomething4(SiS_Pr,HwDeviceExtension, BaseAddr); - } else if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension, BaseAddr)) { -/* if(!SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { */ /* TW: makes no sense */ - SiS_Chrontel701xBLOn(SiS_Pr); - SiS_ChrontelDoSomething4(SiS_Pr,HwDeviceExtension, BaseAddr); -/* } */ - } - } + 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,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_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + SiS_PanelDelay(SiS_Pr, HwInfo, 1); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xF7); + } + } } #endif /* SIS315H */ @@ -5609,1112 +4631,2538 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USH } -void -SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +/*********************************************/ +/* SET PART 1 REGISTER GROUP */ +/*********************************************/ + +/********** Set CRT2 OFFSET / PITCH **********/ +static void +SiS_SetCRT2Offset(SiS_Private *SiS_Pr,USHORT ModeNo, + USHORT ModeIdIndex ,USHORT RefreshRateTableIndex, + PSIS_HW_INFO HwInfo) { - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; + USHORT offset; + UCHAR temp; - /* TW: Switch on LCD backlight on SiS30xLV */ - if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) || - (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) { - if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension); - } - if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x01)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); - } - } -} + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) return; -void -SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress; + offset = SiS_GetOffset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + HwInfo); - /* TW: Switch off LCD backlight on SiS30xLV */ - if( (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) || - (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00); - } + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) offset >>= 1; - if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) { - if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) { - if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFD,0x00); - } - } - } + temp = (UCHAR)(offset & 0xFF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,temp); + temp = (UCHAR)(offset >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,temp); + temp = (UCHAR)(((offset >> 3) & 0xFF) + 1); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,temp); } -BOOLEAN -SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +/************* Set CRT2 Sync *************/ +static void +SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT RefreshRateTableIndex, + PSIS_HW_INFO HwInfo) { - USHORT temp,temp1; - UCHAR *ROMAddr; + USHORT tempah=0,tempbl,infoflag; - if((ROMAddr = (UCHAR *)HwDeviceExtension->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xff; - temp >>= 4; - temp = 1 << temp; - temp1 = (ROMAddr[0x23c] << 8) | ROMAddr[0x23b]; - if(temp1 & temp) return(1); - else return(0); + tempbl = 0xC0; + + if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; } else { - return(0); + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; } -} -BOOLEAN -SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp,temp1; - UCHAR *ROMAddr; + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */ - if((ROMAddr = (UCHAR *)HwDeviceExtension->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xff; - temp >>= 4; - temp = 1 << temp; - temp1 = (ROMAddr[0x23e] << 8) | ROMAddr[0x23d]; - if(temp1 & temp) return(1); - else return(0); - } else { - return(0); - } -} + 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; -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 + tempah &= 0xC0; - if(HwDeviceExtension->jChipType < SIS_315H) { + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; -#ifdef SIS300 + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + tempah |= 0xc0; + } + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 300 series, LVDS */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(HwInfo->jChipType >= SIS_315H) { + tempah >>= 3; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xE7,tempah); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,0xe0); + } + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + } - PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { - DelayIndex = PanelID >> 4; + if(HwInfo->jChipType < SIS_315H) { - if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { - Delay = 3; - } else { - if(DelayTime >= 2) DelayTime -= 2; +#ifdef SIS300 /* ---- 300 series --- */ - 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]; - } - } + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 630 - 301B(-DH) */ + + tempah = infoflag >> 8; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + tempah = SiS_Pr->SiS_LCDInfo; } - } - SiS_ShortDelay(SiS_Pr,Delay); + } + tempah &= 0xC0; - } else { /* 300 series, 301(B) */ + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); - temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18); - if(!(temp & 0x10)) PanelID = 0x12; + tempah &= 0x3f; + tempah |= tempbl; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - DelayIndex = PanelID >> 4; + } else { /* 630 - 301 */ - if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { - Delay = 3; - } else { - if(DelayTime >= 2) DelayTime -= 2; + 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(!(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); + } - } +#endif /* SIS300 */ -#endif /* SIS300 */ + } else { - } else { +#ifdef SIS315H /* ------- 315 series ------ */ - if(HwDeviceExtension->jChipType == SIS_330) return; + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* 315 - 30xLV */ -#ifdef SIS315H + if(((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024)) || + ((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050))) { + tempah = infoflag >> 8; + } else { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + } + tempah &= 0xC0; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 310/325 series, LVDS */ + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - 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; + } else { /* 315 - 301, 301B */ - 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); - } + 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; - } else { /* 310/325 series, 301(B) */ + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); - DelayIndex = PanelID >> 4; - if(!(DelayTime & 0x01)) { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; - } else { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; - } - SiS_DDC2Delay(SiS_Pr, Delay * 4); + if(SiS_Pr->SiS_VBType & VB_NoLCD) { /* TEST, imitate BIOS bug */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tempah |= 0xc0; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + } +#endif /* SIS315H */ } - -#endif /* SIS315H */ - } - } -void -SiS_LongDelay(SiS_Private *SiS_Pr, USHORT delay) +/******** Set CRT2 FIFO on 300/630/730 *******/ +#ifdef SIS300 +static void +SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo, + PSIS_HW_INFO HwInfo) { - while(delay--) { - SiS_GenericDelay(SiS_Pr,0x19df); - } -} + 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 + }; -void -SiS_ShortDelay(SiS_Private *SiS_Pr, USHORT delay) -{ - while(delay--) { - SiS_GenericDelay(SiS_Pr,0x42); - } -} + SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate; -void -SiS_GenericDelay(SiS_Private *SiS_Pr, USHORT delay) -{ - USHORT temp,flag; + if(!SiS_Pr->CRT1UsesCustomMode) { - flag = SiS_GetReg3(0x61) & 0x10; + 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); - while(delay) { - temp = SiS_GetReg3(0x61) & 0x10; - if(temp == flag) continue; - flag = temp; - delay--; - } -} + if(CRT1ModeNo >= 0x13) { + index = SiS_Pr->SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK; + index &= 0x3F; + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ -BOOLEAN -SiS_Is301B(SiS_Private *SiS_Pr, USHORT BaseAddr) -{ - USHORT flag; + colorth = SiS_GetColorDepth(SiS_Pr,CRT1ModeNo,modeidindex); /* Get colordepth */ + colorth >>= 1; + if(!colorth) colorth++; + } - flag = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x01); - if(flag >= 0x0B0) return(1); - else return(0); -} + } else { -BOOLEAN -SiS_CRT2IsLCD(SiS_Private *SiS_Pr, USHORT BaseAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT flag; + 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_730) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13); - if(flag & 0x20) return(1); } - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(flag & 0x20) return(1); - else return(0); -} -BOOLEAN -SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + 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 */ - 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); -} + data2 = (colorth * VCLK) / MCLK; -BOOLEAN -SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + temp = ((temp & 0x00FF) >> 6) << 1; + if(temp == 0) temp = 1; + temp <<= 2; + temp &= 0xff; - if(HwDeviceExtension->jChipType >= SIS_315H) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if((flag & EnableDualEdge) && (flag & SetToLCDA)) return(1); -#if 0 /* Not done in 650/301LVx 1.10.6s, but in 650/301LV */ - else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(flag) return(1); - else return(0); - } + data2 = temp - data2; + + if((28 * 16) % data2) { + data2 = (28 * 16) / data2; + data2++; + } else { + data2 = (28 * 16) / data2; + } + + if(HwInfo->jChipType == SIS_300) { + + 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; + + } else if(HwInfo->jChipType == SIS_730) { + +#ifndef LINUX_XF86 + SiS_SetRegLong(0xcf8,0x80000050); + eax = SiS_GetRegLong(0xcfc); +#else + eax = pciReadLong(0x00000000, 0x50); #endif - else - return(0); - } else + tempal = (USHORT)(eax >> 8); + tempal &= 0x06; + tempal <<= 5; + +#ifndef LINUX_XF86 + SiS_SetRegLong(0xcf8,0x800000A0); + eax = SiS_GetRegLong(0xcfc); +#else + eax = pciReadLong(0x00000000, 0xA0); #endif - return(0); - } + temp = (USHORT)(eax >> 28); + temp &= 0x0F; + tempal |= temp; -BOOLEAN -SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + 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; - 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); - } + data = LatencyFactor730[tempbx]; + data += 15; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + if(!(temp & 0x80)) data += 5; -#if 0 -BOOLEAN -SiS_Is315E(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + } else { - if(HwDeviceExtension->jChipType >= SIS_315H) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f); - if(flag & 0x10) return(1); - else return(0); - } else + index = 0; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + if(temp & 0x0080) index += 12; + +#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 - return(0); -} + 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; -BOOLEAN -SiS_IsM650or651(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + temp = (temp & 0x0F) >> 1; + index += temp; - if(HwDeviceExtension->jChipType >= SIS_315H) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f); - flag &= 0xF0; - if((flag == 0xb0) || (flag == 0x90)) return 0; - else return 1; - } else -#endif - return 1; -} + data = LatencyFactor[index]; + data += 15; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); + if(!(temp & 0x80)) data += 5; + } -BOOLEAN -SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + data += data2; /* CRT1 Request Period */ - 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); -} + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; -BOOLEAN -SiS_IsChScart(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ -#ifdef SIS315H - USHORT flag; + if(!SiS_Pr->UseCustomMode) { - 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); -} + CRT2ModeNo = ModeNo; + SiS_SearchModeID(SiS_Pr, &CRT2ModeNo, &modeidindex); -BOOLEAN -SiS_IsTVOrYPbPrOrScart(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) -{ - USHORT flag; + refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT2ModeNo, modeidindex, HwInfo); + + 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((ROMAddr) && SiS_Pr->SiS_UseROM) { + if(ROMAddr[0x220] & 0x01) { + VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8); + } + } + } + + } else { + + CRT2ModeNo = 0xfe; + VCLK = SiS_Pr->CSRClock; /* Get VCLK */ + + } + + colorth = SiS_GetColorDepth(SiS_Pr,CRT2ModeNo,modeidindex); /* Get colordepth */ + colorth >>= 1; + if(!colorth) colorth++; + + 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; + + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x01); + if(HwInfo->jChipType == SIS_300) { + if(data <= 0x0f) temp = (temp & (~0x1F)) | 0x13; + else temp = (temp & (~0x1F)) | 0x16; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + temp = (temp & (~0x1F)) | 0x13; + } + } else { + if( ( (HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730) ) && + (HwInfo->jChipRevision >= 0x30) ) /* 630s or 730(s?) */ + { + temp = (temp & (~0x1F)) | 0x1b; + } else { + temp = (temp & (~0x1F)) | 0x16; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0xe0,temp); + + if( (HwInfo->jChipType == SIS_630) && + (HwInfo->jChipRevision >= 0x30) ) /* 630s, NOT 730 */ + { + if(data > 0x13) data = 0x13; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,0xe0,data); + + } else { /* If mode <= 0x13, we just restore everything */ + + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; -#ifdef 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); } +#endif -BOOLEAN -SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr) +/**** Set CRT2 FIFO on 315/330 series ****/ +#ifdef SIS315H +static void +SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr) { - USHORT flag; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,0x3B); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,~0x3F,0x04); +} +#endif +/*************** Set LCD-A ***************/ #ifdef SIS315H - if(HwDeviceExtension->jChipType >= SIS_315H) { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToLCD) return(1); - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if(flag & SetToLCDA) return(1); - else return(0); - } else -#endif - { - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToLCD) return(1); +static void +SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) +{ + USHORT modeflag,resinfo; + USHORT push2,tempax,tempbx,tempcx,temp; + ULONG tempeax=0,tempebx,tempecx,tempvcfact; + + /* 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 if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); /* 740/301LV, 301BDH */ + } + } else { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 650/LVDS */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04); /* 650/LVDS */ + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x00); /* 650/LVDS 1.10.07 */ + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2D,0x0f); /* 650/30xLv 1.10.6s */ + } } - return(0); -} + 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; + } -BOOLEAN -SiS_IsDisableCRT2(SiS_Private *SiS_Pr, USHORT BaseAddr) -{ - USHORT flag; + tempax = SiS_Pr->SiS_LCDHDES; - flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30); - if(flag & 0x20) return(0); - else return(1); -} + temp = (tempax & 0x0007); /* BPLHDESKEW[2:0] */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* Part1_1Ah */ + temp = (tempax >> 3) & 0x00FF; /* BPLHDESKEW[10:3] */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* Part1_16h */ -BOOLEAN -SiS_BridgeIsOn(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT flag; + tempbx = SiS_Pr->SiS_HDE; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempbx = SiS_Pr->PanelXRes; + } + + tempax += tempbx; /* HDE + HSKEW = lcdhdee */ + if(tempax >= SiS_Pr->SiS_HT) tempax -= SiS_Pr->SiS_HT; + + temp = tempax; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(temp & 0x07) temp += 8; + } + temp >>= 3; /* BPLHDEE */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* Part1_17h */ + tempcx = (SiS_Pr->SiS_HT - tempbx) >> 2; /* (HT-HDE) / 4 */ + + /* 650/30xLV 1.10.6s, 740/LVDS */ + if( ((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) || + ((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) ) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x28; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempcx = 0x18; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x30; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x40; + else tempcx = 0x30; + } + } + + tempcx += tempax; /* lcdhrs */ + if(tempcx >= SiS_Pr->SiS_HT) tempcx -= SiS_Pr->SiS_HT; + + temp = (tempcx >> 3) & 0x00FF; /* BPLHRS */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,temp); /* Part1_14h */ + + temp += 10; if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - return(0); + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + temp += 6; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) { + temp++; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1024x768) { + temp += 7; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) { + temp -= 10; + } + } + } + } + } + } + temp &= 0x1F; + temp |= ((tempcx & 0x07) << 5); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,temp); /* Part1_15h */ + + if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { + tempax = SiS_Pr->PanelYRes; } else { - flag = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00); - if((flag == 1) || (flag == 2)) return(0); - else return(1); + tempax = SiS_Pr->SiS_VGAVDE; } -} -BOOLEAN -SiS_BridgeIsEnable(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT flag; + tempbx = SiS_Pr->SiS_LCDVDES + tempax; + if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; + push2 = tempbx; - if(!(SiS_BridgeIsOn(SiS_Pr,BaseAddr,HwDeviceExtension))) { - flag = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00); - if(HwDeviceExtension->jChipType < SIS_315H) { - /* 300 series (630/301B 2.04.5a) */ - flag &= 0xa0; - if((flag == 0x80) || (flag == 0x20)) return 0; - else return 1; - } else { - /* 310/325 series (650/301LVx 1.10.6s) */ - flag &= 0x50; - if((flag == 0x40) || (flag == 0x10)) return 0; - else return 1; - } + tempcx = (SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 2; + + if( ((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) || + ((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) ) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 1; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempcx = 3; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 3; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 1; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 1; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 1; + else tempcx = 0x0057; + } } - return 1; -} -BOOLEAN -SiS_BridgeInSlave(SiS_Private *SiS_Pr) -{ - USHORT flag1; + tempbx += tempcx; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + tempbx++; /* BPLVRS */ + } + if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); /* Part1_18h */ - flag1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31); - if(flag1 & (SetInSlaveMode >> 8)) return 1; - else return 0; -} + tempcx >>= 3; + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 3; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempcx = 5; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 5; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 5; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 2; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 2; + } + } + } + tempcx += tempbx; + tempcx++; /* BPLVRE */ + temp = tempcx & 0x000F; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp |= 0xC0; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp); /* Part1_19h */ + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp); + } -/* TW: New from 650/301LV(x) 1.10.6s BIOS */ -void -SiS_SetHiVision(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ -#ifdef SIS315H - USHORT temp; -#endif + temp = ((tempbx >> 8) & 0x07) << 3; + if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40; + if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + /* Don't check Part1Port,0x00 -> is not being set if LCDA! */ + /* We check SR06 instead here: */ + if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x10) temp |= 0x80; + } + } else { + if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) temp |= 0x80; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x07,temp); /* Part1_1Ah */ - /* Note: This variable is only used on 30x/B/LV systems. - CR38 has a different meaning on LVDS/CH7019 systems. - */ + tempbx = push2; /* BPLVDEE */ - SiS_Pr->SiS_HiVision = 0; - if(HwDeviceExtension->jChipType >= SIS_315H) { -#ifdef SIS315H - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - /* TW: New from 650/301LVx BIOS 1.10.6s */ - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - if(temp & 0x04) { - temp &= 0x30; - switch(temp) { - case 0x00: SiS_Pr->SiS_HiVision = 4; break; - case 0x10: SiS_Pr->SiS_HiVision = 1; break; - case 0x20: SiS_Pr->SiS_HiVision = 2; break; - default: SiS_Pr->SiS_HiVision = 3; break; - } - } + tempcx = SiS_Pr->SiS_LCDVDES; /* NPLVDES */ + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { + if(resinfo == SIS_RI_800x600) tempcx++; } -#endif /* SIS315H */ + } + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { + tempbx = tempcx = SiS_Pr->SiS_VGAVDE; + tempbx--; + } + + temp = ((tempbx >> 8) & 0x07) << 3; + temp = temp | ((tempcx >> 8) & 0x07); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1D,temp); /* Part1_1Dh */ + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1C,temp); /* Part1_1Ch */ + temp = tempcx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1B,temp); /* Part1_1Bh */ + + tempeax = SiS_Pr->SiS_VGAVDE << 18; + tempebx = SiS_Pr->SiS_VDE; + temp = (USHORT)(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); + } + + tempeax = SiS_Pr->SiS_VGAHDE << 16; + tempebx = SiS_Pr->SiS_HDE; + temp = tempeax % tempebx; + tempeax /= tempebx; + if(temp) tempeax++; + if(tempebx == SiS_Pr->SiS_VGAHDE) tempeax = 0xFFFF; + tempecx = tempeax; + tempeax = ((SiS_Pr->SiS_VGAHDE << 16) / tempecx) - 1; + tempecx = (tempecx << 16) | (tempeax & 0xFFFF); + temp = (USHORT)(tempecx & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1F,temp); /* Part1_1Fh */ + + tempeax = (SiS_Pr->SiS_VGAVDE << 18) / 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 >> 8) & 0x07) << 3; + temp = temp | ((tempecx >> 8) & 0x07); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x20,temp); /* Part1_20h */ + + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x21,temp); /* Part1_21h */ + + tempecx >>= 16; /* BPLHCFACT */ + if(modeflag & HalfDCLK) tempecx >>= 1; + temp = (USHORT)((tempecx & 0x0000FF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x22,temp); /* Part1_22h */ + + temp = (USHORT)(tempecx & 0x000000FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp); + + if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBInfo & VB_SIS301LV302LV)) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x20); } } +#endif /* SIS 315 */ -/* TW: Checked against 630/LVDS 2.08, 650/LVDS and 650/301LV BIOS */ -BOOLEAN -SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension) +static USHORT +SiS_GetVGAHT2(SiS_Private *SiS_Pr) { - USHORT temp,modeflag,resinfo=0; - const unsigned char SiS300SeriesLCDRes[] = - { 0, 1, 2, 3, 7, 4, 5, 8, - 0, 0, 0, 0, 0, 0, 0, 0 }; + ULONG tempax,tempbx; - SiS_Pr->SiS_LCDResInfo = 0; - SiS_Pr->SiS_LCDTypeInfo = 0; - SiS_Pr->SiS_LCDInfo = 0; + 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); +} - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; +/******* Set Part 1 / SiS bridge *********/ +static void +SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo,USHORT RefreshRateTableIndex) +{ + USHORT push1,push2; + USHORT tempax,tempbx,tempcx,temp; + USHORT resinfo,modeflag; + unsigned char p1_7, p1_8; + + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; } else { - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + 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(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return 0; + /* The following is only done if bridge is in slave mode: */ - if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2))) return 0; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0xff); /* set MAX HT */ - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36); + tempax = 0xFFFF; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempax = SiS_GetVGAHT2(SiS_Pr); - /* FSTN: Fake CR36 (TypeInfo 2, ResInfo SiS_Panel320x480) */ - if(SiS_Pr->SiS_IF_DEF_FSTN) { - temp = 0x20 | SiS_Pr->SiS_Panel320x480; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,temp); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) modeflag |= Charx8Dot; + + if(modeflag & Charx8Dot) tempcx = 0x08; + else tempcx = 0x09; + + if(tempax >= SiS_Pr->SiS_VGAHT) tempax = SiS_Pr->SiS_VGAHT; + + if(modeflag & HalfDCLK) tempax >>= 1; + + tempax = (tempax / tempcx) - 5; + tempbx = tempax & 0x00FF; + + 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_SetReg(SiS_Pr->SiS_Part1Port,0x04,temp); + + temp = (tempbx & 0xFF00) >> 8; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { + temp += 2; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { + if(SiS_Pr->SiS_HiVision == 3) { + if(resinfo == SIS_RI_800x600) temp -= 2; + } } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x05,temp); /* 0x05 Horizontal Display Start */ - if(HwDeviceExtension->jChipType < SIS_315H) { - SiS_Pr->SiS_LCDTypeInfo = temp >> 4; + SiS_SetReg(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_TVMode & TVSetTVSimuMode) { + temp -= 2; + if(ModeNo > 0x13) temp -= 10; + } + } } else { - SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1; + 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(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VGAHDE == 800) temp += 2; + } + } + } + } else { + if(!(modeflag & HalfDCLK)) { + temp -= 4; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) { + if(SiS_Pr->SiS_VGAHDE >= 800) { + temp -= 7; + if(HwInfo->jChipType < SIS_315H) { + /* 650/301LV(x) does not do this, 630/301B, 300/301LV do */ + if(SiS_Pr->SiS_ModeType == ModeEGA) { + if(SiS_Pr->SiS_VGAVDE == 1024) { + temp += 15; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) + temp += 7; + } + } + } + if(SiS_Pr->SiS_VGAHDE >= 1280) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) temp += 28; + } + } + } + } + } } - temp &= 0x0f; - if(HwDeviceExtension->jChipType < SIS_315H) { - /* TW: Translate 300 series LCDRes to 310/325 series for unified usage */ - temp = SiS300SeriesLCDRes[temp]; + + p1_7 = temp; + p1_8 = 0x00; + + 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; + } + } + } } - SiS_Pr->SiS_LCDResInfo = temp; - if(SiS_Pr->SiS_IF_DEF_FSTN){ - SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_Panel320x480; + 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(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; + 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 */ + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x03); /* 0x18 SR08 (FIFO Threshold?) */ + + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x19,0xF0); + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,0xFF); /* 0x09 Set Max VT */ + + tempcx = 0x121; + tempbx = SiS_Pr->SiS_VGAVDE; /* 0x0E Vertical Display End */ + if (tempbx == 357) tempbx = 350; + else if(tempbx == 360) tempbx = 350; + else if(tempbx == 375) tempbx = 350; + else if(tempbx == 405) tempbx = 400; + else if(tempbx == 420) tempbx = 400; + else if(tempbx == 525) tempbx = 480; + push2 = tempbx; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + if (tempbx == 350) tempbx += 5; + else if(tempbx == 480) tempbx += 5; + } + } } + tempbx -= 2; + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp); /* 0x10 vertical Blank Start */ - if(SiS_Pr->SiS_LCDResInfo > SiS_Pr->SiS_PanelMax) - SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_Panel1024x768; + tempbx = push2; + tempbx--; + temp = tempbx & 0x00FF; +#if 0 + /* Missing code from 630/301B 2.04.5a and 650/302LV 1.10.6s (calles int 2f) */ + if(xxx()) { + if(temp == 0xdf) temp = 0xda; + } +#endif + SiS_SetReg(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_SetReg(SiS_Pr->SiS_Part1Port,0x0B,temp); - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37); - if(SiS_Pr->SiS_IF_DEF_FSTN){ - /* TW: Fake LVDS bridge for FSTN */ - temp = 0x04; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,temp); + if(tempbx & 0x0400) tempcx |= 0x0600; + + 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 != SiS_Pr->SiS_Panel1400x1050) { + tempbx += (tempax << 1); + } } - SiS_Pr->SiS_LCDInfo = temp; - /* TW: Inserted entire 315-block from 650/LVDS/301+LVx BIOSes */ - if(HwDeviceExtension->jChipType >= SIS_315H) { -#ifdef SIS315H - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - if(ModeNo == 0x3a || ModeNo == 0x4d || ModeNo == 0x65) { - SiS_Pr->SiS_LCDInfo |= LCDNonExpanding; - } - } - } + if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && + (SiS_Pr->SiS_HiVision == 3)) { + tempbx -= 10; + } else { + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + if(!(SiS_Pr->SiS_HiVision & 0x03)) { + tempbx += 40; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VGAHDE == 800) tempbx += 10; + } + } + } } - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x01) { - SiS_Pr->SiS_LCDInfo &= 0xFFEF; - SiS_Pr->SiS_LCDInfo |= LCDPass11; + } + 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 */ + + tempbx--; + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp); + + if(tempbx & 0x0100) tempcx |= 0x0008; + + if(tempbx & 0x0200) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20); + } + tempbx++; + + if(tempbx & 0x0100) tempcx |= 0x0004; + if(tempbx & 0x0200) tempcx |= 0x0080; + if(tempbx & 0x0400) { + if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x0800; + else tempcx |= 0x0C00; + } + + tempbx = push1; + temp = tempbx & 0x000F; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,temp); /* 0x0D vertical Retrace End */ + + if(tempbx & 0x0010) tempcx |= 0x2000; + + temp = tempcx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* 0x0A CR07 */ + + temp = (tempcx & 0xFF00) >> 8; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* 0x17 SR0A */ + + 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_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* 0x16 SR01 */ + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* 0x0F CR14 */ + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,0x00); /* 0x12 CR17 */ + + 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 */ +} + +/*********** Set Part 1 / LVDS ***********/ +static void +SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) +{ + USHORT modeflag, resinfo; + USHORT push1, push2, tempax, tempbx, tempcx, temp; +#ifdef SIS315H + USHORT pushcx; #endif + ULONG tempeax=0, tempebx, tempecx, tempvcfact=0; + + /* This is not supported on LVDS */ + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return; + if(SiS_Pr->UseCustomMode) return; + + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; } else { -#ifdef SIS300 - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if((ROMAddr) && SiS_Pr->SiS_UseROM) { - if(!(ROMAddr[0x235] & 0x02)) { - SiS_Pr->SiS_LCDInfo &= 0xEF; + 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 */ + + tempbx = SiS_Pr->SiS_HDE; /* Horiz. Display End */ + + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) { + tempbx >>= 1; + } + + if(!(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; + } } } - } else { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if((SiS_Pr->SiS_SetFlag & CRT2IsVGA) && ((ModeNo == 0x03) || (ModeNo == 0x10))) { - SiS_Pr->SiS_LCDInfo &= 0xEF; - } - } } + } + tempcx = (tempcx - tempbx) >> 2; /* HT-HDE / 4 */ + + push1 = tempax; + + tempax += tempbx; + + if(tempax >= SiS_Pr->SiS_HT) tempax -= SiS_Pr->SiS_HT; + + push2 = tempax; + + if((!SiS_Pr->SiS_IF_DEF_FSTN) && + (!SiS_Pr->SiS_IF_DEF_DSTN) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1366) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1024) && + (SiS_Pr->SiS_CustomT != CUT_PANEL848)) { + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x0028; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempcx = 0x0018; + else if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) ) { + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + tempcx = 0x0017; /* A901; sometimes 0x0018; */ + } else { + tempcx = 0x0017; +#ifdef TWNEWPANEL + tempcx = 0x0018; #endif + } + } else { + tempcx = 0x0018; + } + } + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 0x0028; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0030; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0030; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0040; + } + } + } } -#ifdef LINUX_KERNEL - 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); + tempcx += tempax; /* lcdhrs */ + if(tempcx >= SiS_Pr->SiS_HT) tempcx -= SiS_Pr->SiS_HT; + + tempax = tempcx >> 3; /* BPLHRS */ + temp = tempax & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,temp); /* Part1_14h; Panel Link Horizontal Retrace Start */ + + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + temp = (tempax & 0x00FF) + 2; + } else { + temp = (tempax & 0x00FF) + 10; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if((!SiS_Pr->SiS_IF_DEF_DSTN) && + (!SiS_Pr->SiS_IF_DEF_FSTN) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1366) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1024) && + (SiS_Pr->SiS_CustomT != CUT_PANEL848)) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + temp += 6; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) { + temp++; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1024x768) { + temp += 7; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) { + temp -= 0x14; + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x768) { + temp -= 10; + } + } + } + } + } + } + } + } + } + + temp &= 0x1F; + temp |= ((tempcx & 0x0007) << 5); +#if 0 + if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0x20; /* WRONG? BIOS loads cl, not ah */ #endif -#ifdef LINUX_XF86 - xf86DrvMsgVerb(0, X_PROBED, 3, - "(init301: LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)\n", - SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,temp); /* Part1_15h; Panel Link Horizontal Retrace End/Skew */ + + tempbx = push2; + tempcx = push1; /* lcdhdes */ + + temp = (tempcx & 0x0007); /* BPLHDESKEW */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* Part1_1Ah; Panel Link Vertical Retrace Start (2:0) */ + + tempcx >>= 3; /* BPLHDES */ + temp = (tempcx & 0x00FF); +#if 0 /* Not 550 FSTN */ + if(HwInfo->jChipType >= SIS_315H) { + if(ModeNo == 0x5b) temp--; */ + } #endif + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* Part1_16h; Panel Link Horizontal Display Enable Start */ - /* TW: With Trumpion, always Expanding */ - if(SiS_Pr->SiS_IF_DEF_TRUMPION != 0){ - SiS_Pr->SiS_LCDInfo &= (~LCDNonExpanding); + if((HwInfo->jChipType < SIS_315H) || + (SiS_Pr->SiS_IF_DEF_FSTN) || + (SiS_Pr->SiS_IF_DEF_DSTN)) { + if(tempbx & 0x07) tempbx += 8; + } + tempbx >>= 3; /* BPLHDEE */ + temp = tempbx & 0x00FF; +#if 0 /* Not 550 FSTN */ + if(HwInfo->jChipType >= SIS_315H) { + if(ModeNo == 0x5b) temp--; } +#endif + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* Part1_17h; Panel Link Horizontal Display Enable End */ - if(!((HwDeviceExtension->jChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & CRT2IsVGA))) { + /* 2. Vertical setup */ - 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 & LCDNonExpanding)) { - if((resinfo == 7) || (resinfo == 3)) { - SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } - } + if(HwInfo->jChipType < SIS_315H) { + tempcx = SiS_Pr->SiS_VGAVT; + tempbx = SiS_Pr->SiS_VGAVDE; + if((SiS_Pr->SiS_CustomT != CUT_BARCO1366) && (SiS_Pr->SiS_CustomT != CUT_BARCO1024)) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + tempbx = SiS_Pr->PanelYRes; } - } - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; } } + tempcx -= tempbx; - if(modeflag & HalfDCLK) { - if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { - if(!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) { - if(!(((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (HwDeviceExtension->jChipType < SIS_315H)) && - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480))) { - if(ModeNo > 0x13) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(resinfo == 4) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; /* 512x384 */ - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { - if(resinfo == 3) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; /* 400x300 */ - } - } - } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } + } else { - } + tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE; /* VGAVT-VGAVDE */ - /* TW: wdr: if (VBInfo & LCD) && (VBInfo & (SetSimuScanMode | SwitchToCRT2)) { */ - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) { - SiS_Pr->SiS_SetFlag |= LCDVESATiming; - } - } else { - SiS_Pr->SiS_SetFlag |= LCDVESATiming; } -#ifdef SIS315H - /* TW: Inserted from 650/301LVx BIOS 1.10.6s */ - if(HwDeviceExtension->jChipType > SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS30xNEW) { - temp = 0x00; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) temp = 0x04; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x04; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) temp = 0x04; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x39,temp); - } else if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x39,0x00); - } + tempbx = SiS_Pr->SiS_LCDVDES; /* VGAVDES */ + push1 = tempbx; + + tempax = SiS_Pr->SiS_VGAVDE; + + 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; + } } + + tempbx += tempax; + if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; + + push2 = tempbx; + + tempcx >>= 1; + + if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && + (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1366) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1024) && + (SiS_Pr->SiS_CustomT != CUT_PANEL848)) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) { + tempcx = 0x0017; + } else if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x0003; + else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768)) tempcx = 0x0003; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0001; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0001; + else tempcx = 0x0057; + } else { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x0001; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempcx = 0x0001; + else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768)) { + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + tempcx = 0x0002; /* A901; sometimes 0x0003; */ + } else { + tempcx = 0x0002; +#ifdef TWNEWPANEL + tempcx = 0x0003; #endif + } + } else tempcx = 0x0003; + } + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 0x0003; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0001; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0001; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0001; + else tempcx = 0x0057; + } + } + } - return 1; -} + tempbx += tempcx; /* BPLVRS */ -void -SiS_PresetScratchregister(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - return; - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,0x21); */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x31,0x41); */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x32,0x28); */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x33,0x22); */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x35,0x43); */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,0x01); */ - /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,0x00); */ -} + if((HwInfo->jChipType < SIS_315H) || + (SiS_Pr->SiS_IF_DEF_FSTN) || + (SiS_Pr->SiS_IF_DEF_DSTN)) { + tempbx++; + } -void -SiS_LongWait(SiS_Private *SiS_Pr) -{ - USHORT i; + if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; - i = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1F); + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); /* Part1_18h; Panel Link Vertical Retrace Start */ - 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; - } + tempcx >>= 3; + + if((!(SiS_Pr->SiS_LCDInfo & LCDPass11)) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1366) && + (SiS_Pr->SiS_CustomT != CUT_BARCO1024) && + (SiS_Pr->SiS_CustomT != CUT_PANEL848)) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if( (HwInfo->jChipType < SIS_315H) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) ) tempcx = 0x0001; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2) tempcx = 0x0002; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempcx = 0x0002; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 0x0003; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempcx = 0x0005; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) tempcx = 0x0005; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 0x0011; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0005; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0002; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0011; + else if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + tempcx = 0x0004; /* A901; Other BIOS sets 0x0005; */ + } else { + tempcx = 0x0004; +#ifdef TWNEWPANEL + tempcx = 0x0005; +#endif + } + } else { + tempcx = 0x0005; + } + } + } } -} -void -SiS_VBLongWait(SiS_Private *SiS_Pr) -{ - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { - SiS_VBWait(SiS_Pr); + 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; + } + } else if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40; + if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40; + if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { + temp |= 0x80; + } + } else { + if( (HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730) ) { + if(HwInfo->jChipRevision >= 0x30) { + temp |= 0x80; + } + } + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x87,temp); /* Part1_1Ah; Panel Link Control Signal (7:3); Vertical Retrace Start (2:0) */ + + if (HwInfo->jChipType < SIS_315H) { + +#ifdef SIS300 /* 300 series */ + + tempeax = SiS_Pr->SiS_VGAVDE << 6; + temp = (USHORT)(tempeax % (ULONG)SiS_Pr->SiS_VDE); + tempeax = tempeax / (ULONG)SiS_Pr->SiS_VDE; + if(temp != 0) tempeax++; + tempebx = tempeax; /* BPLVCFACT */ + + if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) { + tempebx = 0x003F; + } + + temp = (USHORT)(tempebx & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1E,temp); /* Part1_1Eh; Panel Link Vertical Scaling Factor */ + +#endif /* SIS300 */ + } else { - SiS_LongWait(SiS_Pr); + +#ifdef SIS315H /* 315 series */ + + if(HwInfo->jChipType == SIS_740) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x03); + } else { + SiS_SetReg(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_SetReg(SiS_Pr->SiS_Part1Port,0x37,temp); /* Part1_37h; Panel Link Vertical Scaling Factor */ + temp = (USHORT)((tempebx & 0x00FF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,temp); /* Part1_36h; Panel Link Vertical Scaling Factor */ + temp = (USHORT)((tempebx & 0x00030000) >> 16); + temp &= 0x03; + if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,temp); /* Part1_35h; Panel Link Vertical Scaling Factor */ + +#endif /* SIS315H */ + } - return; -} -void -SiS_VBWait(SiS_Private *SiS_Pr) -{ - USHORT tempal,temp,i,j; + tempbx = push2; /* BPLVDEE */ + tempcx = push1; - 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; + push1 = temp; + + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(!SiS_Pr->SiS_IF_DEF_FSTN && !SiS_Pr->SiS_IF_DEF_DSTN) { + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { + if(resinfo == SIS_RI_1024x600) tempcx++; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(resinfo == SIS_RI_800x600) tempcx++; + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { + if(resinfo == SIS_RI_800x600) tempcx++; + if(resinfo == SIS_RI_1024x768) tempcx++; /* Doesnt make sense anyway... */ + } else if(resinfo == SIS_RI_1024x768) tempcx++; + } else { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) { + if(resinfo == SIS_RI_800x600) tempcx++; + } + } + } } -} -void -SiS_WaitVBRetrace(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - if(HwDeviceExtension->jChipType < SIS_315H) { -#ifdef SIS300 - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return; + if(SiS_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; } - if(!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x80)) { - SiS_WaitRetrace1(SiS_Pr,HwDeviceExtension); - } else { - SiS_WaitRetrace2(SiS_Pr,HwDeviceExtension); + } + + temp = ((tempbx & 0x0700) >> 8) << 3; + temp |= ((tempcx & 0x0700) >> 8); + SiS_SetReg(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_SetReg(SiS_Pr->SiS_Part1Port,0x1C,temp); /* Part1_1Ch; Panel Link Vertical Display Enable End */ + + temp = tempcx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1B,temp); /* Part1_1Bh; Panel Link Vertical Display Enable Start */ + + /* 3. Additional horizontal setup (scaling, etc) */ + + tempecx = SiS_Pr->SiS_VGAHDE; + if(HwInfo->jChipType >= SIS_315H) { + if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { + if(modeflag & HalfDCLK) tempecx >>= 1; } -#endif + } + tempebx = SiS_Pr->SiS_HDE; + if(tempecx == tempebx) tempeax = 0xFFFF; + else { + tempeax = tempecx; + tempeax <<= 16; + temp = (USHORT)(tempeax % tempebx); + tempeax = tempeax / tempebx; + if(HwInfo->jChipType >= SIS_315H) { + if(temp) tempeax++; + } + } + tempecx = tempeax; + + if(HwInfo->jChipType >= SIS_315H) { + tempeax = SiS_Pr->SiS_VGAHDE; + if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { + if(modeflag & HalfDCLK) tempeax >>= 1; + } + tempeax <<= 16; + tempeax = (tempeax / tempecx) - 1; + } else { + tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1; + } + tempecx <<= 16; + tempecx |= (tempeax & 0xFFFF); + temp = (USHORT)(tempecx & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1F,temp); /* Part1_1Fh; Panel Link DDA Operational Number in each horiz. line */ + + tempbx = SiS_Pr->SiS_VDE; + if(HwInfo->jChipType >= SIS_315H) { + tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact; + tempbx = (USHORT)(tempeax & 0x0FFFF); } else { + tempeax = SiS_Pr->SiS_VGAVDE << 6; + tempbx = push1 & 0x3f; + if(tempbx == 0) tempbx = 64; + tempeax /= tempbx; + tempbx = (USHORT)(tempeax & 0x0FFFF); + } + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx--; + if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) { + if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) tempbx = 1; + else if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) tempbx = 1; + } + + temp = ((tempbx & 0xFF00) >> 8) << 3; + temp |= (USHORT)((tempecx & 0x0700) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x20,temp); /* Part1_20h; Overflow register */ + + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x21,temp); /* Part1_21h; Panel Link Vertical Accumulator Register */ + + tempecx >>= 16; /* BPLHCFACT */ + if((HwInfo->jChipType < SIS_315H) || (SiS_Pr->SiS_IF_DEF_FSTN) || (SiS_Pr->SiS_IF_DEF_DSTN)) { + if(modeflag & HalfDCLK) tempecx >>= 1; + } + temp = (USHORT)((tempecx & 0xFF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x22,temp); /* Part1_22h; Panel Link Horizontal Scaling Factor High */ + + temp = (USHORT)(tempecx & 0x00FF); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp); /* Part1_22h; Panel Link Horizontal Scaling Factor Low */ + + /* 630/301B and 630/LVDS do something for 640x480 panels here */ + #ifdef SIS315H - if(!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) { - SiS_WaitRetrace1(SiS_Pr,HwDeviceExtension); - } else { - SiS_WaitRetrace2(SiS_Pr,HwDeviceExtension); + if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x25,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x26,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x27,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x28,0x87); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x29,0x5A); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2A,0x4B); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x007,0x03); + tempax = SiS_Pr->SiS_HDE; /* Blps = lcdhdee(lcdhdes+HDE) + 64 */ + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempax >>= 1; + tempax += 64; + temp = tempax & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,temp); + temp = ((tempax & 0xFF00) >> 8) << 3; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,~0x078,temp); + tempax += 32; /* Blpe=lBlps+32 */ + temp = tempax & 0x00FF; + if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3A,0x00); /* Bflml=0 */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x007,0x00); + + tempax = SiS_Pr->SiS_VDE; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempax >>= 1; + tempax >>= 1; + temp = tempax & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3B,temp); + temp = ((tempax & 0xFF00) >> 8) << 3; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x038,temp); + + tempeax = SiS_Pr->SiS_HDE; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempeax >>= 1; + tempeax <<= 2; /* BDxFIFOSTOP = (HDE*4)/128 */ + tempebx = 128; + temp = (USHORT)(tempeax % tempebx); + tempeax = tempeax / tempebx; + if(temp) tempeax++; + temp = (USHORT)(tempeax & 0x003F); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x45,~0x0FF,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3F,0x00); /* BDxWadrst0 */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3E,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3D,0x10); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x040,0x00); + + tempax = SiS_Pr->SiS_HDE; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempax >>= 1; + tempax >>= 4; /* BDxWadroff = HDE*4/8/8 */ + pushcx = tempax; + temp = tempax & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,temp); + temp = ((tempax & 0xFF00) >> 8) << 3; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x0F8,temp); + + tempax = SiS_Pr->SiS_VDE; /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */ + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 || + SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempax >>= 1; + tempeax = (tempax * pushcx); + tempebx = 0x00100000 + tempeax; + temp = (USHORT)tempebx & 0x000000FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x42,temp); + temp = (USHORT)((tempebx & 0x0000FF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x41,temp); + temp = (USHORT)((tempebx & 0x00FF0000) >> 16); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,temp); + temp = (USHORT)(((tempebx & 0x01000000) >> 24) << 7); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x080,temp); + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x03); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0x50); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x04,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x01); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0x38); + + if(SiS_Pr->SiS_IF_DEF_FSTN) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2b,0x02); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2c,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,0x0c); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,0x80); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,0xA0); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3a,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3b,0xf0); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3c,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3d,0x10); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3e,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3f,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,0x10); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x41,0x25); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x42,0x80); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,0x14); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x44,0x03); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x45,0x0a); } -#endif } +#endif /* SIS315H */ + } -void -SiS_WaitRetrace1(SiS_Private *SiS_Pr, 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 watchdog; -#ifdef SIS300 - USHORT i; + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT temp=0, tempax=0, tempbx=0, tempcx=0; + USHORT pushbx=0, CRT1Index=0; +#ifdef SIS315H + USHORT tempbl=0; #endif + USHORT modeflag, resinfo=0; + + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + } else { + CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } + } + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - 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); + SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); + SiS_SetGroup1_LCDA(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); #endif + } else { + + if( (HwInfo->jChipType >= SIS_315H) && + (SiS_Pr->SiS_IF_DEF_LVDS == 1) && + (SiS_Pr->SiS_VBInfo & SetInSlaveMode) ) { + + SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); + + } else { + + SiS_SetCRT2Offset(SiS_Pr, ModeNo, ModeIdIndex, + RefreshRateTableIndex, HwInfo); + + if (HwInfo->jChipType < SIS_315H ) { #ifdef SIS300 -#if 0 /* TW: Not done in A901 BIOS */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return; - } + SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo, HwInfo); #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; - } + } else { +#ifdef SIS315H + SiS_SetCRT2FIFO_310(SiS_Pr); #endif - } + } + + SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); + + /* 1. Horizontal setup */ + + if(HwInfo->jChipType < SIS_315H ) { + +#ifdef SIS300 /* ------------- 300 series --------------*/ + + temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ + + temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */ + + temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */ + + pushbx = SiS_Pr->SiS_VGAHDE + 12; /* bx BTVGA@HRS 0x0B,0x0C */ + tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2; + tempbx = pushbx + tempcx; + tempcx <<= 1; + tempcx += tempbx; + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CHSyncStart + 12; + tempcx = SiS_Pr->CHSyncEnd + 12; + } + + 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_TVMode & TVSetPAL)){ + tempbx = 1040; + tempcx = 1042; + } + } + } + + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,temp); /* CRT2 Horizontal Retrace Start */ +#endif /* SIS300 */ + + } 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--; + + temp = tempcx & 0xff; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ + + temp = ((tempcx & 0xff00) >> 8) << 4; + 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; + + temp = tempbx & 0xff; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */ + + pushbx = tempbx; + tempcx >>= 1; + tempbx += tempcx; + tempcx += tempbx; + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + if(HwInfo->jChipType >= SIS_661) { + if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024)) { + if(resinfo == SIS_RI_1280x1024) { + tempcx = 0x30; + } else if(resinfo == SIS_RI_1600x1200) { + tempcx = 0xff; + } + } + } + + 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_TVMode & TVSetPAL)) { + if(resinfo == SIS_RI_1024x768) { + tempbx = 1040; + tempcx = 1042; + } + } + } + + } + + temp = tempbx & 0xff; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,temp); /* CRT2 Horizontal Retrace Start */ +#endif /* SIS315H */ + + } /* 315/330 series */ + + /* The following is done for all bridge/chip types/series */ + + tempax = tempbx & 0xFF00; + tempbx = pushbx; + tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); + tempax |= (tempbx & 0xFF00); + temp = (tempax & 0xFF00) >> 8; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0C,temp); /* Overflow */ + + temp = tempcx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,temp); /* CRT2 Horizontal Retrace End */ + + /* 2. Vertical setup */ + + tempcx = SiS_Pr->SiS_VGAVT - 1; + temp = tempcx & 0x00FF; + + 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; + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,temp); /* CRT2 Vertical Display Enable End */ + + temp = ((tempbx & 0xFF00) << 3) >> 8; + temp |= ((tempcx & 0xFF00) >> 8); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,temp); /* Overflow (and HWCursor Test Mode) */ + + 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->SiS_VBType & VB_SISVB) { + + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CVSyncStart; + tempcx = (tempcx & 0xFF00) | (SiS_Pr->CVSyncEnd & 0x00FF); + } + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { + unsigned char cr8, cr7, cr13, cr9; + if(SiS_Pr->UseCustomMode) { + cr8 = SiS_Pr->CCRT1CRTC[8]; + cr7 = SiS_Pr->CCRT1CRTC[7]; + cr13 = SiS_Pr->CCRT1CRTC[13]; + cr9 = SiS_Pr->CCRT1CRTC[9]; + } else { + cr8 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[8]; + cr7 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7]; + cr13 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]; + cr9 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9]; + } + tempbx = cr8; + if(cr7 & 0x04) tempbx |= 0x0100; + if(cr7 & 0x80) tempbx |= 0x0200; + if(cr13 & 0x08) tempbx |= 0x0400; + tempcx = (tempcx & 0xFF00) | (cr9 & 0x00FF); + } + } + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp); /* CRT2 Vertical Retrace Start */ + + temp = ((tempbx & 0xFF00) >> 8) << 4; + temp |= (tempcx & 0x000F); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x11,temp); /* CRT2 Vert. Retrace End; Overflow; "Enable CRTC Check" */ + + /* 3. Panel compensation delay */ + + 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 == 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(HwInfo->pdc) { + temp = HwInfo->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(HwInfo->pdc) { + temp = HwInfo->pdc & 0x3c; + } + } + } + + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x03C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */ + +#endif /* SIS300 */ + + } else { + +#ifdef SIS315H /* --------------- 315/330 series ---------------*/ + + if(HwInfo->jChipType < SIS_661) { + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + 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(HwInfo->jChipType < SIS_330) { + if(ROMAddr[0x13c] & 0x80) tempbl = 0xf0; + } else { + if(ROMAddr[0x1bc] & 0x80) tempbl = 0xf0; + } + } + } else { /* LV (550/301LV checks ROM byte, other LV BIOSes do not) */ + tempbl = 0xF0; + } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD|SetCRT2ToLCDA)) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(HwInfo->pdc) { + temp = HwInfo->pdc; + tempbl = 0; + } + } + } + + } else { /* LVDS */ + + 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(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 */ + + } /* < 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_VBType & VB_SISVB) { + + /* For 301BDH with LCD, we set up the Panel Link */ + if( (SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) { + + 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 { + + 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); + } + + } + + } + } /* LCDA */ } -void -SiS_WaitRetraceDDC(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) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + const UCHAR *tableptr = NULL; + USHORT a, b, p = 0; + + a = SiS_Pr->SiS_VGAHDE; + b = SiS_Pr->SiS_HDE; + if(tabletype) { + a = SiS_Pr->SiS_VGAVDE; + b = SiS_Pr->SiS_VDE; + } + + if((ROMAddr = (UCHAR *)HwInfo->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) { + + if(a < b) { + p = ROMAddr[0x278] | (ROMAddr[0x279] << 8); + } else if(a == b) { + p = ROMAddr[0x27a] | (ROMAddr[0x27b] << 8); + } else { + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + p = ROMAddr[0x27e] | (ROMAddr[0x27f] << 8); + } else { + p = ROMAddr[0x27c] | (ROMAddr[0x27d] << 8); + } + do { + if((ROMAddr[p] | ROMAddr[p+1] << 8) == a) break; + p += 0x42; + } while((ROMAddr[p] | ROMAddr[p+1] << 8) != 0xffff); + if((ROMAddr[p] | ROMAddr[p+1] << 8) == 0xffff) p -= 0x42; + } + p += 2; + return(&ROMAddr[p]); + + } else { + + 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; + } + 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]); + } +} + +static void +SiS_SetGroup2_C_ELV(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { - USHORT watchdog; + UCHAR *tableptr; + int i, j; + UCHAR temp; - 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->SiS_VBType & (VB_SIS301C | VB_SIS302ELV))) return; + + tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 0, HwInfo); + for(i = 0x80, j = 0; i <= 0xbf; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]); + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 1, HwInfo); + for(i = 0xc0, j = 0; i <= 0xff; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]); + } + } + temp = 0x10; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp |= 0x04; + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4e,0xeb,temp); } -void -SiS_WaitRetrace2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +static void +SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, + USHORT RefreshRateTableIndex,USHORT *CRT2Index, + USHORT *ResIndex,PSIS_HW_INFO HwInfo) { - USHORT watchdog; -#ifdef SIS300 - USHORT i; -#endif + USHORT tempbx,tempal; - if(HwDeviceExtension->jChipType >= SIS_315H) { -#ifdef SIS315H - watchdog = 65535; - while( (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x30) & 0x02) && --watchdog); - watchdog = 65535; - while( (!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x30) & 0x02)) && --watchdog); -#endif - } else { -#ifdef SIS300 - for(i=0; i<10; i++) { - watchdog = 65535; - while( (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x25) & 0x02) && --watchdog); - if(watchdog) break; + if(ModeNo <= 0x13) + tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + else + tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + + tempbx = SiS_Pr->SiS_LCDResInfo; + + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 16; + else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx += 32; + + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + tempbx = 100; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 101; + else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx = 102; } - for(i=0; i<10; i++) { - watchdog = 65535; - while( (!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x25) & 0x02)) && --watchdog); - if(watchdog) break; + } else if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + tempbx = 103; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx = 104; + else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx = 105; + } } -#endif } -} -/* =========== Set and Get register routines ========== */ + *CRT2Index = tempbx; + *ResIndex = tempal & 0x3F; +} +#endif -void -SiS_SetRegANDOR(USHORT Port,USHORT Index,USHORT DataAND,USHORT DataOR) +#ifdef SIS300 +/* For ECS A907. Highly preliminary. */ +static void +SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeIdIndex, USHORT RefreshRateTableIndex, + USHORT ModeNo) { - USHORT temp; + USHORT crt2crtc, resindex; + int i,j; + const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; - temp = SiS_GetReg1(Port,Index); - temp = (temp & (DataAND)) | DataOR; - SiS_SetReg1(Port,Index,temp); -} + if(HwInfo->jChipType != SIS_300) return; + if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; + if(SiS_Pr->UseCustomMode) return; -void -SiS_SetRegAND(USHORT Port,USHORT Index,USHORT DataAND) -{ - USHORT temp; + if(ModeNo <= 0x13) { + crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + } - temp = SiS_GetReg1(Port,Index); - temp &= DataAND; - SiS_SetReg1(Port,Index,temp); -} + 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_SetRegOR(USHORT Port,USHORT Index,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 |= 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 -/* ========================================================= */ +static void +SiS_SetTVSpecial(SiS_Private *SiS_Pr, USHORT ModeNo) +{ + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { + 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]); + } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x14); + } else { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x15); + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1b); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,0x72); + } + } else { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x21); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x5a); + } + } +} -/* TW: Set 301 TV Encoder (and some LCD relevant) registers */ -void -SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo, - USHORT ModeIdIndex,USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +/* Set 301 TV Encoder (and some LCD relevant) registers */ +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; +#if 0 + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; +#endif + USHORT i, j, tempax, tempbx, tempcx, temp; USHORT push1, push2; const UCHAR *PhasePoint; const UCHAR *TimingPoint; +#ifdef SIS315H const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; - USHORT modeflag, resinfo, crt2crtc, resindex, CRT2Index; - ULONG longtemp, tempeax, tempebx, temp2, tempecx; + USHORT resindex, CRT2Index; +#endif + USHORT modeflag, crt2crtc; + ULONG longtemp, tempeax; +#ifdef SIS300 const UCHAR atable[] = { - 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02, - 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02 + 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02, + 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02 }; +#endif - /* TW: Inserted from 650/301LV BIOS */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - /* TW: Inserted from 650/301LVx 1.10.6s: (Is at end of SetGroup2!) */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xfc,0x03); - temp = 1; - if(ModeNo <= 0x13) temp = 3; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0b,temp); - } - } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((ModeNo == 0x4a) || (ModeNo == 0x38)) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1c,0xa7); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1d,0x07); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1e,0xf2); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1f,0x6e); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x20,0x17); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x21,0x8b); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x22,0x73); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,0x53); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,0x13); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x25,0x40); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x26,0x34); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,0xf4); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x28,0x63); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x29,0xbb); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2a,0xcc); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2b,0x7a); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2c,0x58); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2d,0xe4); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2e,0x73); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,0xda); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0x13); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,0x72); - } - } - } - } - return; - } +#ifdef SIS315H + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; +#endif - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */ - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; - crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */ - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + crt2crtc = 0; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + } } - tempcx = SiS_Pr->SiS_VBInfo; - tempax = (tempcx & 0x00FF) << 8; - tempbx = (tempcx & 0x00FF) | ((tempcx & 0x00FF) << 8); - tempbx &= 0x0410; - temp = (tempax & 0x0800) >> 8; - temp >>= 1; - temp |= (((tempbx & 0xFF00) >> 8) << 1); - temp |= ((tempbx & 0x00FF) >> 3); - temp ^= 0x0C; - - /* TW: From 1.10.7w (no vb check there) */ - if(SiS_Pr->SiS_VBType & (VB_SIS30xLV | VB_SIS30xNEW)) { - 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; + + /* Disables SVIDEO and CVBS signal */ + if((SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) && + (SiS_Pr->SiS_CustomT != CUT_CLEVO1400)) { + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + temp |= 0x0c; + } } PhasePoint = SiS_Pr->SiS_PALPhase; TimingPoint = SiS_Pr->SiS_PALTiming; -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { /* PALPhase */ - temp ^= 0x01; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - TimingPoint = SiS_Pr->SiS_HiTVSt2Timing; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - if(modeflag & Charx8Dot) TimingPoint = SiS_Pr->SiS_HiTVSt1Timing; - else TimingPoint = SiS_Pr->SiS_HiTVTextTiming; - } - } else TimingPoint = SiS_Pr->SiS_HiTVExtTiming; + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { + + temp ^= 0x01; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + TimingPoint = SiS_Pr->SiS_HiTVSt2Timing; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + if(modeflag & Charx8Dot) TimingPoint = SiS_Pr->SiS_HiTVSt1Timing; + else TimingPoint = SiS_Pr->SiS_HiTVTextTiming; + } + } else TimingPoint = SiS_Pr->SiS_HiTVExtTiming; + + if(SiS_Pr->SiS_HiVision & 0x03) temp &= 0xfe; + } else { -#endif - if(SiS_Pr->SiS_VBInfo & SetPALTV){ - TimingPoint = SiS_Pr->SiS_PALTiming; - PhasePoint = SiS_Pr->SiS_PALPhase; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { - if( (SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALPhase2; - } + TimingPoint = SiS_Pr->SiS_PALTiming; + PhasePoint = SiS_Pr->SiS_PALPhase; - } else { + if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && + ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { + PhasePoint = SiS_Pr->SiS_PALPhase2; + } + + } else { temp |= 0x10; - TimingPoint = SiS_Pr->SiS_NTSCTiming; - PhasePoint = SiS_Pr->SiS_NTSCPhase; + 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_SIS301B | VB_SIS302B)) && + if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_NTSCPhase2; + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { + PhasePoint = SiS_Pr->SiS_NTSCPhase2; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { + PhasePoint = SiS_Pr->SiS_PALPhase2; + } } - } -#ifdef oldHV + } + } -#endif - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x00,temp); - temp = 0; - if((HwDeviceExtension->jChipType == SIS_630)|| - (HwDeviceExtension->jChipType == SIS_730)) { - temp = 0x35; - } - if(HwDeviceExtension->jChipType >= SIS_315H) { - temp = 0x38; - } - if(temp) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) { - temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,temp); - if(temp1 & EnablePALM) { /* 0x40 */ - PhasePoint = SiS_Pr->SiS_PALMPhase; - if( (SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) && - ( (!(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_SIS301B | VB_SIS302B)) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALNPhase2; - } - } - } - } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + PhasePoint = SiS_Pr->SiS_PALMPhase; + if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && + ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { + PhasePoint = SiS_Pr->SiS_PALMPhase2; + } + } + 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 - /* TW: Inserted from 650/301LV BIOS */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 650/301LV : 301LV | 302LV */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((ModeNo == 0x4a) || (ModeNo == 0x38)) { - PhasePoint = SiS_Pr->SiS_SpecialPhase; - } - } - } + if(SiS_Pr->SiS_TVMode & 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]); + for(i=0x31, j=0; i<=0x34; i++, 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]); + 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_SetReg1(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); + for(i=0x39; i<=0x45; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); } if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(!(SiS_Pr->SiS_ModeType & 0x07)) + if(SiS_Pr->SiS_ModeType != ModeText) { SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F); - } else { - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F); - } + } } SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x0A,SiS_Pr->SiS_NewFlickerMode); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x35,SiS_Pr->SiS_RY1COE); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x36,SiS_Pr->SiS_RY2COE); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x37,SiS_Pr->SiS_RY3COE); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x38,SiS_Pr->SiS_RY4COE); + 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); -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) tempax = 950; - else { -#endif - if(SiS_Pr->SiS_VBInfo & SetPALTV) tempax = 520; - else tempax = 440; -#ifdef oldHV + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { + if(SiS_Pr->SiS_HiVision == 3) tempax = 950; + else tempax = 440; + } else { + if(SiS_Pr->SiS_TVMode & TVSetPAL) tempax = 520; + else tempax = 440; } -#endif 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) && @@ -6722,29 +7170,27 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo tempax -= SiS_Pr->SiS_VDE; tempax >>= 2; - tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); + tempax &= 0x00ff; - temp = (tempax & 0xFF00) >> 8; - temp += (USHORT)TimingPoint[0]; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,temp); + temp = tempax + (USHORT)TimingPoint[0]; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); - temp = (tempax & 0xFF00) >> 8; - temp += (USHORT)TimingPoint[1]; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,temp); + temp = tempax + (USHORT)TimingPoint[1]; + SiS_SetReg(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); + (SiS_Pr->SiS_HiVision != 3) && + (SiS_Pr->SiS_VGAHDE >= 1024) ) { + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x19); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x52); } else { - if(HwDeviceExtension->jChipType >= SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x17); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x1d); + if(HwInfo->jChipType >= SIS_315H) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x17); + SiS_SetReg(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,0x0b); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x11); } } } @@ -6752,35 +7198,25 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo } tempcx = SiS_Pr->SiS_HT; - - /* TW: Inserted from 650/301LVx 1.10.6s */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) { - tempcx >>= 1; - } - } - + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; tempcx--; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - tempcx--; - } + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) tempcx--; temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1B,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1B,temp); temp = (tempcx & 0xFF00) >> 8; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0xF0,temp); tempcx++; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - tempcx++; - } + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) tempcx++; tempcx >>= 1; push1 = tempcx; tempcx += 7; -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) tempcx -= 4; -#endif + 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); @@ -6790,33 +7226,33 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo push2 = tempbx; temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x24,temp); temp = ((tempbx & 0xFF00) >> 8) << 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0F,temp); tempbx = push2; tempbx += 8; -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - tempbx -= 4; - tempcx = tempbx; + if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && + (SiS_Pr->SiS_HiVision == 3)) { + tempbx -= 4; + tempcx = tempbx; } -#endif temp = (tempbx & 0x00FF) << 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x29,0x0F,temp); j += 2; tempcx += ((TimingPoint[j] | ((TimingPoint[j+1]) << 8))); temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x27,temp); temp = ((tempcx & 0xFF00) >> 8) << 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x28,0x0F,temp); tempcx += 8; -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) tempcx -= 4; -#endif + 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); @@ -6829,353 +7265,287 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo tempcx -= 11; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { - tempax = SiS_GetVGAHT2(SiS_Pr) - 1; - tempcx = tempax; + tempcx = SiS_GetVGAHT2(SiS_Pr) - 1; } temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2E,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2E,temp); tempbx = SiS_Pr->SiS_VDE; if(SiS_Pr->SiS_VGAVDE == 360) tempbx = 746; if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 746; if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 853; - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempbx >>= 1; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempbx >>= 1; } else { - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) { - tempbx >>= 1; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - if(ModeNo <= 0x13) { - if(crt2crtc == 1) { - tempbx++; - } - } - } else { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(crt2crtc == 4) /* TW: BIOS calls GetRatePtrCRT2 here - does not make sense */ - if(SiS_Pr->SiS_ModeType <= 3) tempbx++; - } + if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) { + tempbx >>= 1; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + if(ModeNo <= 0x13) { + if(crt2crtc == 1) { + tempbx++; + } } - } + } else { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(crt2crtc == 4) /* BIOS calls GetRatePtrCRT2 here - does not make sense */ + if(SiS_Pr->SiS_ModeType <= 3) tempbx++; + } + } + } } tempbx -= 2; temp = tempbx & 0x00FF; -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(ModeNo == 0x2f) temp++; - } - } -#endif - /* TW: From 1.10.7w - doesn't make sense */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) && + (SiS_Pr->SiS_HiVision == 3)) { if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { /* SetFlag?? */ - if(ModeNo == 0x03) temp++; + if((ModeNo == 0x2f) || (ModeNo == 0x5d) || (ModeNo == 0x5e)) temp++; + } + } + + if(HwInfo->jChipType < SIS_661) { + /* From 1.10.7w - doesn't make sense */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { /* SetFlag?? */ + if(ModeNo == 0x03) temp++; + } } - } + } } } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2F,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2F,temp); - tempax = (tempcx & 0xFF00) | (tempax & 0x00FF); - tempbx = ((tempbx & 0xFF00) << 6) | (tempbx & 0x00FF); - tempax |= (tempbx & 0xFF00); -#ifdef oldHV - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) { -#endif - if(HwDeviceExtension->jChipType < SIS_315H) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART)) { /* TW: New from 630/301B (II) BIOS */ - tempax |= 0x1000; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) tempax |= 0x2000; - } - } else { - tempax |= 0x1000; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) tempax |= 0x2000; - } -#ifdef oldHV + temp = (tempcx >> 8) & 0x0F; + temp |= (((tempbx >> 8) << 6) & 0xC0); + if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToHiVisionTV | SetCRT2ToSCART))) { + temp |= 0x10; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) temp |= 0x20; } -#endif - temp = (tempax & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,temp); - /* TW: Inserted from 650/301LVx 1.10.6s */ - if(HwDeviceExtension->jChipType > SIS_315H) { + if((HwInfo->jChipType > SIS_315H) && (HwInfo->jChipType < SIS_661)) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) ) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x10,0x60); + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) { + if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) ) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x10,0x60); + } } } } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* tv gatingno */ - tempbx = SiS_Pr->SiS_VDE; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) { - tempbx >>= 1; - } - tempbx -= 3; - tempbx &= 0x03ff; - temp = ((tempbx & 0xFF00) >> 8) << 5; - temp |= 0x18; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x46,temp); - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x47,temp); - if(HwDeviceExtension->jChipType >= SIS_315H) { /* TW: Inserted from 650/301LVx 1.10.6s */ - tempax = 0; - if(SiS_Pr->SiS_HiVision & 0x07) { - if(SiS_Pr->SiS_HiVision & 0x04) tempax = 0x1000; - else if(SiS_Pr->SiS_HiVision & 0x01) tempax = 0x3000; - else tempax = 0x5000; - } - temp = (tempax & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4d,temp); - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { + if(SiS_Pr->SiS_HiVision != 3) { + for(i=0, j=0; i<=0x2d; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS_HiVisionTable[SiS_Pr->SiS_HiVision][j]); + } + for(i=0x39; i<=0x45; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS_HiVisionTable[SiS_Pr->SiS_HiVision][j]); + } + } + } + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + tempbx = SiS_Pr->SiS_VDE; + if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) { + tempbx >>= 1; + } + tempbx -= 3; + if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) { /* Why not 301B/LV? */ + temp = 0; + if(tempcx & 0x0400) temp |= 0x20; + if(tempbx & 0x0400) temp |= 0x40; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x10,temp); + } + } + tempbx &= 0x03ff; + temp = ((tempbx & 0xFF00) >> 8) << 5; + temp |= 0x18; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x46,temp); + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x47,temp); + + temp = 0; + if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_HiVision & 0x03) { + temp = 0x30; + if(SiS_Pr->SiS_HiVision & 0x01) temp = 0x50; + } + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4d,temp); + } - tempbx &= 0x00FF; + tempbx = 0; if(!(modeflag & HalfDCLK)) { - tempcx = SiS_Pr->SiS_VGAHDE; - if(tempcx >= SiS_Pr->SiS_HDE) { - tempbx |= 0x2000; - tempax &= 0x00FF; - } + if(SiS_Pr->SiS_VGAHDE >= SiS_Pr->SiS_HDE) { + tempax = 0; + tempbx |= 0x2000; + } } tempcx = 0x0101; -/*if(SiS_Pr->SiS_VBInfo & (SetPALTV | SetCRT2ToTV)) { */ /*301b- TW: BIOS BUG? */ if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) { - if(!(SiS_Pr->SiS_HiVision & 0x03)) { - if(SiS_Pr->SiS_VGAHDE >= 1024) { - if((!(modeflag & HalfDCLK)) || - (HwDeviceExtension->jChipType < SIS_315H)) { /* TW: This check not in 630/301B */ - tempcx = 0x1920; - if(SiS_Pr->SiS_VGAHDE >= 1280) { - tempcx = 0x1420; - tempbx &= 0xDFFF; - } + if(!(SiS_Pr->SiS_HiVision & 0x03)) { + if(SiS_Pr->SiS_VGAHDE >= 1024) { + if((!(modeflag & HalfDCLK)) || (HwInfo->jChipType < SIS_315H)) { + tempcx = 0x1920; + if(SiS_Pr->SiS_VGAHDE >= 1280) { + tempcx = 0x1420; + tempbx &= ~0x2000; + } + } } - } - } + } } - if(!(tempbx & 0x2000)){ - if(modeflag & HalfDCLK) { - tempcx = (tempcx & 0xFF00) | (((tempcx & 0x00FF) << 1) & 0xff); - } - push1 = tempbx; - tempeax = SiS_Pr->SiS_VGAHDE; - tempebx = (tempcx & 0xFF00) >> 8; - longtemp = tempeax * tempebx; - tempecx = tempcx & 0x00FF; - longtemp /= tempecx; - longtemp <<= 0x0d; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(!(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; - } - tempecx = SiS_Pr->SiS_HDE; - temp2 = longtemp % tempecx; - tempeax = longtemp / tempecx; - if(temp2 != 0) tempeax++; - tempax = (USHORT)tempeax; - tempbx = push1; - tempcx = (tempcx & 0xff00) | (((tempax & 0xFF00) >> 8) >> 5); - tempbx |= (tempax & 0x1F00); - tempax = ((tempax & 0x00FF) << 8) | (tempax & 0x00FF); + } + tempeax = longtemp / SiS_Pr->SiS_HDE; + if(longtemp % SiS_Pr->SiS_HDE) tempeax++; + tempax = (USHORT)tempeax; + tempbx |= (tempax & 0x1F00); + tempcx = (tempax & 0xFF00) >> (8 + 5); } - temp = (tempax & 0xFF00) >> 8; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x44,temp); - temp = (tempbx & 0xFF00) >> 8; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x44,tempax); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,(tempbx >> 8)); if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - temp = tempcx & 0x00FF; - if(tempbx & 0x2000) temp = 0; - temp |= 0x18; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x46,0xE0,temp); - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - tempbx = 0x0382; /* TW: BIOS; Was 0x0364; */ - tempcx = 0x007e; /* TW: BIOS; Was 0x009c; */ - } else { - tempbx = 0x0369; /* TW: BIOS; Was 0x0346; */ - tempcx = 0x0061; /* TW: BIOS; Was 0x0078; */ - } - temp = (tempbx & 0x00FF) ; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4B,temp); - temp = (tempcx & 0x00FF) ; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4C,temp); - tempbx &= 0x03FF; - temp = (tempcx & 0xFF00) >> 8; - temp = (temp & 0x0003) << 2; - temp |= (tempbx >> 8); - if(HwDeviceExtension->jChipType < SIS_315H) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4D,temp); - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4D,0xF0,temp); - } - temp = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x43); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,(USHORT)(temp - 3)); - } + temp = tempcx & 0x0007; + if(tempbx & 0x2000) temp = 0; + if((HwInfo->jChipType < SIS_661) || (!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD))) { + temp |= 0x18; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x46,0xE0,temp); - 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); - } - } - } - } + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + tempbx = 0x0382; + tempcx = 0x007e; + } else { + tempbx = 0x0369; + tempcx = 0x0061; + } + temp = (tempbx & 0x00FF) ; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4B,temp); + temp = (tempcx & 0x00FF) ; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4C,temp); + temp = (tempcx & 0x0300) >> (8 - 2); + temp |= ((tempbx >> 8) & 0x03); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4D,0xF0,temp); + temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,(USHORT)(temp - 3)); + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + 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); + } -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - SiS_SetReg1(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; + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + if(!(SiS_Pr->SiS_TVMode & TVSetNTSC1024)) { + temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x01); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp - 1); } - } else { - /* TW: !!! The following is a duplicate, done for LCDA as well (see above) */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 650/301LV: (VB_SIS301LV | VB_SIS302LV)) */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((ModeNo == 0x4a) || (ModeNo == 0x38)) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1c,0xa7); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1d,0x07); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1e,0xf2); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1f,0x6e); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x20,0x17); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x21,0x8b); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x22,0x73); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,0x53); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,0x13); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x25,0x40); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x26,0x34); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,0xf4); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x28,0x63); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x29,0xbb); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2a,0xcc); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2b,0x7a); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2c,0x58); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2d,0xe4); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2e,0x73); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,0xda); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0x13); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,0x72); - } - } - } - } - return; + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xEF); + } + + if(HwInfo->jChipType >= SIS_315H) { + if((SiS_Pr->SiS_VBType & VB_SIS301B302B) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0B,0x00); + } } } - /* TW: From here: Part2 LCD setup */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) return; + + /* From here: Part2 LCD setup */ tempbx = SiS_Pr->SiS_HDE; - /* TW: Inserted from 650/301LVx 1.10.6s */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempbx >>= 1; - } - tempbx--; /* RHACTE=HDE-1 */ + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + tempbx--; /* RHACTE = HDE - 1 */ temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2C,temp); - temp = (tempbx & 0xFF00) >> 8; - temp <<= 4; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2C,temp); + temp = (tempbx & 0xFF00) >> 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,temp); temp = 0x01; if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(SiS_Pr->SiS_ModeType == ModeEGA) { - if(SiS_Pr->SiS_VGAHDE >= 1024) { - temp = 0x02; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - temp = 0x01; + if(SiS_Pr->SiS_ModeType == ModeEGA) { + if(SiS_Pr->SiS_VGAHDE >= 1024) { + temp = 0x02; + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + temp = 0x01; + } } - } - } - } + } + } } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0B,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0B,temp); - tempbx = SiS_Pr->SiS_VDE; /* RTVACTEO=(VDE-1)&0xFF */ - push1 = tempbx; - - tempbx--; + tempbx = SiS_Pr->SiS_VDE - 1; temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x03,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x03,temp); temp = ((tempbx & 0xFF00) >> 8) & 0x07; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0C,0xF8,temp); - tempcx = SiS_Pr->SiS_VT; - push2 = tempcx; + tempcx = SiS_Pr->SiS_VT - 1; + temp = tempcx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x19,temp); - tempcx--; - temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x19,temp); + temp = ((tempcx & 0xFF00) >> 8) << 5; - temp = (tempcx & 0xFF00) >> 8; - temp <<= 5; - if((HwDeviceExtension->jChipType == SIS_300) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) temp |= 0x10; - } else if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp |= 0x10; - else { - if(SiS_Pr->SiS_LCDInfo & LCDSync) /* TW: 630/301 BIOS checks this */ - temp |= 0x10; - } - } else { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - /* TW: Inserted from 630/301LVx 1.10.6s */ - if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { - temp |= 0x10; - } - } - } else { - temp |= 0x10; - } + /* Enable dithering; only do this for 32bpp mode */ + if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { + temp |= 0x10; + } } - /* 630/301 does not do all this */ + /* Must do special for Compaq1280; Acer1280 OK, Clevo1400 OK, ECS1400 OK */ + /* Compaq1280 panel loses sync if using CR37 sync info. */ if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - if((HwDeviceExtension->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { - /* TW: Inserted from 650/301LVx 1.10.6s */ - temp |= (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37) >> 6); - temp |= 0x08; /* From 1.10.7w */ - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) temp |= 0x04; /* From 1.10.7w */ - } else { - tempbx = (tempbx & 0xFF00) | (SiS_Pr->SiS_LCDInfo & 0x0FF); - if(tempbx & LCDSync) { - tempbx &= (0xFF00 | LCDSyncBit); - tempbx = (tempbx & 0xFF00) | ((tempbx & 0x00FF) >> LCDSyncShift); - temp |= (tempbx & 0x00FF); - } - } + if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024)) { + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + temp |= ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6); + } + } else if((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050)) { + temp |= 0x03; + } else { + temp |= (SiS_GetReg(SiS_Pr->SiS_P3d4,0x37) >> 6); + temp |= 0x08; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) temp |= 0x04; + } + } else { + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + temp |= ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6); + } + } } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1A,temp); + + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1A,temp); SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x09,0xF0); SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x0A,0xF0); @@ -7183,437 +7553,607 @@ 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); - /* 1280x960, 1280x1024 and 1600x1200 data invalid/missing in tables, use old calculation */ - if((HwDeviceExtension->jChipType >= SIS_315H) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) && - (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) && - (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960)) { - /* ------------- 310 series ------------ */ +#if 0 /* Use the 315/330 series code for now */ + if((HwInfo->jChipType >= SIS_661) && + (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && + (ROMAddr && SiS_Pr->SiS_UseROM)) { + + /* This is done for the LVDS bridges only, since + * the TMDS panels already work correctly with + * the old code. Besides, we only do that if + * we can get the data from the ROM, I am tired + * of carrying a lot of tables around. + */ + +#ifdef SIS315H /* ------------ 661/741/760 series --------- */ + UCHAR *myptr = NULL, myptr1 = NULL; + + myptr = (UCHAR *)GetLCDPtr661(SiS_Pr, HwInfo, 6, ModeNo, ModeIdIndex, RefreshRateTableIndex); + myptr1 = (UCHAR *)GetLCDStructPtr661(SiS_Pr, HwInfo); + + tempbx = (myptr[3] | (myptr[4] << 8)) & 0x0fff; + tempcx = SiS_Pr->PanelYRes; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + tempcx = SiS_Pr->SiS_VDE; + } + + tempcx += tempbx; + if(tempcx >= SiS_Pr->SiS_VT) tempcx -= SiS_Pr->SiS_VT; + + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,tempbx); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,tempcx); + + tempcx &= 0x07ff; + tempbx &= 0x07ff; + temp = (tempcx >> 8) << 3; + temp |= (tempbx >> 8); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp); + + tempbx = (myptr[4] | (myptr[5] << 8)) >> 4; + tempcx = myptr1[6]; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempcx = myptr[7]; + + tempcx += tempbx; + if(tempcx >= SiS_Pr->SiS_VT) tempcx -= SiS_Pr->SiS_VT; + + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,tempbx); + temp = tempcx & 0x000f; + temp |= ((tempbx & 0x0f00) >> 4); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); + + tempax = SiS_Pr->SiS_HT; + tempbx = (myptr[0] | (myptr[1] << 8)) & 0x0fff; + tempcx = SiS_Pr->PanelXRes; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempcx = SiS_Pr->SiS_HDE; + + if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + tempax >>= 1; + tempbx >>= 1; + tempcx >>= 1; + } + if(SiS_Pr->SiS_VBType & VB_SIS302LV) tempbx++; + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) tempbx++; + + tempcx += tempbx; + if(tempcx >= tempax) tempcx -= tempax; + + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1f,tempbx); + temp = ((tempbx & 0xff00) >> 8) << 4; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x20,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,tempcx); + temp = tempcx >> 8; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x25,temp); + + tempax = SiS_Pr->SiS_HT; + tempbx = (myptr[1] | (myptr[2] << 8)) >> 4; + tempcx = myptr1[5]; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + tempcx = myptr[6]; + } + if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + tempax >>= 1; + tempbx >>= 1; + tempcx >>= 1; + } + if(SiS_Pr->SiS_VBType & VB_SIS302LV) tempbx++; - /* TW: Inserted this entire section from 650/301LV(x) BIOS */ + tempcx += tempbx; + if(tempcx >= tempax) tempcx -= tempax; - SiS_GetCRT2Part2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&resindex); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1c,tempbx); + temp = (tempbx & 0x0f00) >> 4; + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1d,0x0f,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,tempcx); + + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + if(SiS_Pr->SiS_VGAVDE == 525) { + temp = 0xc3; + if(SiS_Pr->SiS_ModeType <= ModeVGA) { + temp++; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp += 2; + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,0xb3); + } else if(SiS_Pr->SiS_VGAVDE == 420) { + temp = 0x4d; + if(SiS_Pr->SiS_ModeType <= ModeVGA) { + temp++; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp++; + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); + } + } + +#endif + + } else +#endif + if((HwInfo->jChipType >= SIS_315H) && + (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && + ((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) ) { + +#ifdef SIS315H /* ------------- 315/330 series ------------ */ + + SiS_GetCRT2Part2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + &CRT2Index, &resindex, HwInfo); switch(CRT2Index) { case Panel_1024x768 : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; break; /* "Normal" */ 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_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_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; } 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 == 0x20d) { + 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); - } - if(SiS_Pr->SiS_VGAVDE == 0x1a4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,0xb3); + } else if(SiS_Pr->SiS_VGAVDE == 420) { temp = 0x4d; if(SiS_Pr->SiS_ModeType <= ModeVGA) { temp++; if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp++; } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); } } - /* TW: Inserted from 650/301LVx 1.10.6s: */ - /* !!! This is a duplicate, done for LCDA as well - see above */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xfc,0x03); /* Not done in 1.10.7w */ + /* See Sync above, 0x1a */ temp = 1; if(ModeNo <= 0x13) temp = 3; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0b,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0b,temp); } } +#endif - } else { /* ------------- 300 series (and other LCD resolutions) ----------- */ + } else { /* ------ 300 series and other bridges, other LCD resolutions ------ */ - tempcx++; - tempbx = 768; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1024x768) { - tempbx = 1024; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) { - tempbx = 1200; - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) { - if(tempbx != SiS_Pr->SiS_VDE) { - tempbx = 960; - } - } - } - } - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) { - tempbx = SiS_Pr->SiS_VDE - 1; - tempcx--; + /* 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 !!! + */ + + tempcx = SiS_Pr->SiS_VT; + tempbx = SiS_Pr->PanelYRes; + + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempbx = SiS_Pr->SiS_VDE - 1; + tempcx--; } + tempax = 1; - if(!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) { - if(tempbx != SiS_Pr->SiS_VDE){ - tempax = tempbx; - if(tempax < SiS_Pr->SiS_VDE) { - tempax = 0; - tempcx = 0; - } else { - tempax -= SiS_Pr->SiS_VDE; - } - tempax >>= 1; - } - tempcx -= tempax; /* lcdvdes */ - tempbx -= tempax; /* lcdvdee */ - } else { - tempax >>= 1; - tempcx -= tempax; /* lcdvdes */ - tempbx -= tempax; /* lcdvdee */ + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + if(tempbx != SiS_Pr->SiS_VDE) { + tempax = tempbx; + if(tempax < SiS_Pr->SiS_VDE) { + tempax = 0; + tempcx = 0; + } else { + tempax -= SiS_Pr->SiS_VDE; + } + tempax >>= 1; + } + tempcx -= tempax; /* lcdvdes */ + tempbx -= tempax; /* lcdvdee */ } + /* Non-expanding: lcdvdees = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */ + +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "lcdvdes 0x%x lcdvdee 0x%x\n", tempcx, tempbx); +#endif + temp = tempcx & 0x00FF; /* RVEQ1EQ=lcdvdes */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,temp); temp = tempbx & 0x00FF; /* RVEQ2EQ=lcdvdee */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,temp); - temp = ((tempbx & 0xFF00) >> 8 ) << 3; + temp = ((tempbx & 0xFF00) >> 8) << 3; temp |= ((tempcx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp); - tempbx = push2; - tempax = push1; - tempcx = tempbx; - tempcx -= tempax; - tempcx >>= 4; + tempbx = SiS_Pr->SiS_VT; /* push2; */ + tempax = SiS_Pr->SiS_VDE; /* push1; */ + tempcx = (tempbx - tempax) >> 4; tempbx += tempax; tempbx >>= 1; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx -= 10; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx -= 10; + + /* non-expanding: lcdvrs = tempbx = ((VT + VDE) / 2) - 10 */ - temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,temp); + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CVSyncStart; + } + +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "lcdvrs 0x%x\n", tempbx); +#endif + + temp = tempbx & 0x00FF; /* RTVACTEE = lcdvrs */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,temp); temp = ((tempbx & 0xFF00) >> 8) << 4; tempbx += (tempcx + 1); temp |= (tempbx & 0x000F); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,temp); - - /* TW: Code from 630/301B (I+II) BIOS */ - - if( ( ( (HwDeviceExtension->jChipType == SIS_630) || - (HwDeviceExtension->jChipType == SIS_730) ) && - (HwDeviceExtension->jChipRevision > 2) ) && - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) && - (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) && - (!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) ) { - if(ModeNo == 0x13) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,0xB9); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,0xCC); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xA6); - } else { - if((crt2crtc & 0x3F) == 4) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x2B); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x13); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,0xE5); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,0x08); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xE2); - } - } + + if(SiS_Pr->UseCustomMode) { + temp &= 0xf0; + temp |= (SiS_Pr->CVSyncEnd & 0x0f); } - /* TW: Inserted missing code from 630/301B BIOS: (II: 3258) */ +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "lcdvre[3:0] 0x%x\n", (temp & 0x0f)); +#endif - if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) { - crt2crtc &= 0x1f; - tempcx = 0; - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { - if (SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - tempcx += 7; - } - } - tempcx += crt2crtc; - if (crt2crtc >= 4) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xff); - } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(crt2crtc == 4) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x28); + /* Code from 630/301B (I+II) BIOS */ + +#ifdef SIS300 + if(!SiS_Pr->UseCustomMode) { + if( ( ( (HwInfo->jChipType == SIS_630) || + (HwInfo->jChipType == SIS_730) ) && + (HwInfo->jChipRevision > 2) ) && + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) && + (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) && + (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) { + if(ModeNo == 0x13) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xB9); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0xCC); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xA6); + } else { + if((crt2crtc & 0x3F) == 4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x2B); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x13); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xE5); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0x08); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xE2); } - } - } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x18); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]); + } + } + + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) { + crt2crtc &= 0x1f; + tempcx = 0; + if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + tempcx += 7; + } + } + tempcx += crt2crtc; + if(crt2crtc >= 4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xff); + } + + if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(crt2crtc == 4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x28); + } + } + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x18); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]); + } + } } +#endif - tempcx = (SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE) >> 2; /* (HT-HDE)>>2 */ + tempcx = (SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE) >> 2; /* (HT - HDE) >> 2 */ tempbx = SiS_Pr->SiS_HDE + 7; /* lcdhdee */ if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - tempbx += 2; + tempbx += 2; } push1 = tempbx; - temp = tempbx & 0x00FF; /* RHEQPLE=lcdhdee */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,temp); + +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "lcdhdee 0x%x\n", tempbx); +#endif + + temp = tempbx & 0x00FF; /* RHEQPLE = lcdhdee */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,temp); temp = (tempbx & 0xFF00) >> 8; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0xF0,temp); temp = 7; if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - temp += 2; + temp += 2; } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1F,temp); /* RHBLKE=lcdhdes */ - - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x20,0x0F); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1F,temp); /* RHBLKE = lcdhdes[7:0] */ + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x20,0x0F); /* lcdhdes [11:8] */ tempbx += tempcx; push2 = tempbx; - temp = tempbx & 0xFF; /* RHBURSTS=lcdhrs */ - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) { - if(SiS_Pr->SiS_HDE == 1280) temp = 0x47; - } + + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CHSyncStart + 7; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + tempbx += 2; + } } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1C,temp); - temp = ((tempbx & 0xFF00) >> 8) << 4; + +#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_SetReg(SiS_Pr->SiS_Part2Port,0x1C,temp); + temp = (tempbx & 0x0F00) >> 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,temp); tempbx = push2; tempcx <<= 1; tempbx += tempcx; - 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; /* 650: 4e */ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp); - } + if(SiS_Pr->UseCustomMode) { + tempbx = SiS_Pr->CHSyncEnd + 7; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + tempbx += 2; + } } - SiS_Set300Part2Regs(SiS_Pr, HwDeviceExtension, ModeIdIndex, - RefreshRateTableIndex, BaseAddr, ModeNo); - } /* HwDeviceExtension */ -} +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "lcdhre 0x%x\n", tempbx); +#endif -USHORT -SiS_GetVGAHT2(SiS_Private *SiS_Pr) -{ - ULONG tempax,tempbx; + temp = tempbx & 0x00FF; /* RHSYEXP2S = lcdhre */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,temp); - 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); + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { + if(SiS_Pr->SiS_VGAVDE == 525) { + if(SiS_Pr->SiS_ModeType <= ModeVGA) + temp=0xC6; + else + temp=0xC3; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,0xB3); + } else if(SiS_Pr->SiS_VGAVDE == 420) { + if(SiS_Pr->SiS_ModeType <= ModeVGA) + temp=0x4F; + else + temp=0x4D; + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); + } + } + +#ifdef SIS300 + SiS_Set300Part2Regs(SiS_Pr, HwInfo, ModeIdIndex, + RefreshRateTableIndex, ModeNo); +#endif + + } /* HwInfo */ } -/* TW: New from 300/301LV BIOS 1.16.51. Seems highly preliminary. */ -void -SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeIdIndex, USHORT RefreshRateTableIndex, - USHORT BaseAddr, USHORT ModeNo) +/*********************************************/ +/* SET PART 3 REGISTER GROUP */ +/*********************************************/ + +static void +SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { - USHORT crt2crtc, resindex; - int i,j; - const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; + USHORT modeflag, i; + const UCHAR *tempdi; - if(HwDeviceExtension->jChipType != SIS_300) return; - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; if(ModeNo<=0x13) { - crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; } else { - crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } } - resindex = crt2crtc & 0x3F; - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; - else CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_2; +#ifndef SIS_CP + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x00,0x00); +#endif - /* TW: The BIOS code (1.16.51) is obviously a fragment! */ - if(ModeNo > 0x13) { - CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; - resindex = 4; - } +#ifdef SIS_CP + SIS_CP_INIT301_CP +#endif - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]); - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]); - for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xFA); + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xC8); + } else { + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xF5); + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xB7); } - for(j = 0x1c; j <= 0x1d; i++, j++ ) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xFA); + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xC8); + SiS_SetReg(SiS_Pr->SiS_Part3Port,0x3D,0xA8); } - for(j = 0x1f; j <= 0x21; i++, j++ ) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { + tempdi = SiS_Pr->SiS_HiTVGroup3Data; + 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) { + tempdi = SiS_HiTVGroup3_1; + if(SiS_Pr->SiS_HiVision & 0x02) tempdi = SiS_HiTVGroup3_2; + } + for(i=0; i<=0x3E; i++){ + SiS_SetReg(SiS_Pr->SiS_Part3Port,i,tempdi[i]); + } } - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]); - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]); -} -/* TW: Set 301 Macrovision(tm) registers */ -/* TW: Double-Checked against 650/301LV, 650/301LVx and 630/301B BIOS */ -void -SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT temp; -#ifdef oldHV - USHORT i; - const UCHAR *tempdi; +#ifdef SIS_CP + SIS_CP_INIT301_CP2 #endif - USHORT modeflag; - /* TW: Inserted from 650/301LVx 1.10.6s, 1.10.7w */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; +} - if(ModeNo<=0x13) - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - else - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; +/*********************************************/ +/* SET PART 4 REGISTER GROUP */ +/*********************************************/ - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x00,0x00); +static void +SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +{ + USHORT vclkindex; + USHORT temp, reg1, reg2; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xFA); - SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xC8); + if(SiS_Pr->UseCustomMode) { + reg1 = SiS_Pr->CSR2B; + reg2 = SiS_Pr->CSR2C; } 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); - } - } - - 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); - } - } - } + 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; } -#ifdef oldHV - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - tempdi = SiS_Pr->SiS_HiTVGroup3Data; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - tempdi = SiS_Pr->SiS_HiTVGroup3Simu; - if(!(modeflag & Charx8Dot)) { - tempdi = SiS_Pr->SiS_HiTVGroup3Text; - } - } - for(i=0; i<=0x3E; i++){ - SiS_SetReg1(SiS_Pr->SiS_Part3Port,i,tempdi[i]); - } + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,0x57); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,0x46); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1f,0xf6); + } else { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,reg1); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,reg2); + } + } else { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,0x01); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,reg2); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,reg1); } -#endif - - return; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x12,0x00); + temp = 0x08; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) temp |= 0x20; + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x12,temp); } -/* TW: Set 301 VGA2 registers */ -/* TW: Double-Checked against 650/301LV(x) and 630/301B BIOS */ -void -SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex,USHORT RefreshRateTableIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension) +/* Set 301 VGA2 registers */ +static void +SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { USHORT tempax,tempcx,tempbx,modeflag,temp,temp2,resinfo; ULONG tempebx,tempeax,templong; - - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; } else { + if(SiS_Pr->UseCustomMode) { + modeflag = SiS_Pr->CModeFlag; + resinfo = 0; + } else { modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } } - /* TW: From 650/301LVx 1.10.6s BIOS */ - if(SiS_Pr->SiS_VBType & (VB_SIS30xLV | VB_SIS30xNEW)) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x24,0x0e); - } + 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_SIS30xNEW) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f); - } + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV)) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f); + } } - /* TW: From 650/301LV BIOS (any, incl. 1.10.6s, 1.10.7w) */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - /* TW: This is a duplicate; done at the end, too */ - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); + 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(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { +#ifdef SET_EMI_CPQ + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x30,0x00); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + } +#endif + } else if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { +#ifdef SET_EMI + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x30,0x00); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); +#endif + } } - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); return; + } } temp = SiS_Pr->SiS_RVBHCFACT; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x13,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x13,temp); tempbx = SiS_Pr->SiS_RVBHCMAX; temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x14,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x14,temp); temp2 = (((tempbx & 0xFF00) >> 8) << 7) & 0x00ff; tempcx = SiS_Pr->SiS_VGAHT - 1; temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x16,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x16,temp); temp = (((tempcx & 0xFF00) >> 8) << 3) & 0x00ff; temp2 |= temp; @@ -7622,50 +8162,46 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempcx -= 5; temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x17,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x17,temp); temp = temp2 | ((tempcx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x15,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x15,temp); - tempcx = SiS_Pr->SiS_VBInfo; tempbx = SiS_Pr->SiS_VGAHDE; if(modeflag & HalfDCLK) tempbx >>= 1; + if(HwInfo->jChipType >= SIS_661) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + } - /* TW: New for 650/301LV and 630/301B */ temp = 0xA0; -#ifdef oldHV if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { - temp = 0; - if(tempbx > 800) { - temp = 0xA0; - if(tempbx != 1024) { - temp = 0xC0; - if(tempbx != 1280) temp = 0; - } - } - } else -#endif - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(tempbx <= 800) { - temp = 0x80; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD){ - temp = 0; - if(tempbx > 800) temp = 0x60; - } - } + 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; - } + 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; + temp = 0; + if(SiS_Pr->SiS_VGAHDE == 1024) temp = 0x20; } - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) temp = 0; + + if(HwInfo->jChipType < SIS_661) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) temp = 0; } if(SiS_Pr->SiS_VBType & VB_SIS301) { @@ -7677,22 +8213,20 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo tempebx = SiS_Pr->SiS_VDE; -#ifdef oldHV if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { if(!(temp & 0xE0)) tempebx >>=1; } -#endif tempcx = SiS_Pr->SiS_RVBHRS; temp = tempcx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x18,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x18,temp); tempeax = SiS_Pr->SiS_VGAVDE; tempcx |= 0x4000; - if(tempeax <= tempebx){ - tempcx ^= 0x4000; + if(tempeax <= tempebx) { + tempcx ^= 0x4000; } else { - tempeax -= tempebx; + tempeax -= tempebx; } templong = (tempeax * 256 * 1024) % tempebx; @@ -7701,437 +8235,167 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo if(templong != 0) tempebx++; temp = (USHORT)(tempebx & 0x000000FF); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1B,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1B,temp); temp = (USHORT)((tempebx & 0x0000FF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1A,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1A,temp); tempbx = (USHORT)(tempebx >> 16); temp = tempbx & 0x00FF; temp <<= 4; temp |= ((tempcx & 0xFF00) >> 8); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x19,temp); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x19,temp); if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1C,0x28); - tempbx = 0; - tempax = SiS_Pr->SiS_VGAHDE; - if(modeflag & HalfDCLK) tempax >>= 1; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) || (SiS_Pr->SiS_HiVision & 0x03)) { - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempax >>= 1; - else if(tempax > 800) tempax -= 800; - } else { - if(tempax > 800) tempax -= 800; - } - } + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1C,0x28); -/* if((SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetPALTV)) && (!(SiS_Pr->SiS_HiVision & 0x03))) { */ - if((SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) && (!(SiS_Pr->SiS_HiVision & 0x03))) { - if(tempax > 800) { - tempbx = 8; - if(tempax == 1024) - tempax *= 25; - else - tempax *= 20; - - temp = tempax % 32; - tempax /= 32; - tempax--; - if (temp!=0) tempax++; - } - } - tempax--; - temp = (tempax & 0xFF00) >> 8; - temp &= 0x03; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* From 1.10.7w */ - if(ModeNo > 0x13) { /* From 1.10.7w */ - if(resinfo == 8) tempax = 0x1f; /* From 1.10.7w */ - } /* From 1.10.7w */ - } /* From 1.10.7w */ - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1D,tempax & 0x00FF); - temp <<= 4; - temp |= tempbx; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1E,temp); - - if(HwDeviceExtension->jChipType > SIS_315H) { - temp = 0x0026; /* From 1.10.7w; 1.10.6s: 0x0036 */ - } else { - temp = 0x0036; - } - if((SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) && - (!(SiS_Pr->SiS_HiVision & 0x03))) { - temp |= 0x01; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(!(SiS_Pr->SiS_SetFlag & TVSimuMode)) - temp &= 0xFE; - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0,temp); - - tempbx = SiS_Pr->SiS_HT; - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempbx >>= 1; - } - tempbx >>= 1; - tempbx -= 2; - temp = ((tempbx & 0x0700) >> 8) << 3; - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp); - temp = tempbx & 0x00FF; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x22,temp); - if( (SiS_Pr->SiS_VBType & (VB_SIS30xLV | VB_SIS30xNEW)) && - (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x24,0x0e); - } - - /* TW: 650 BIOS does this for all bridge types - assumingly wrong */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - /* TW: This is a duplicate; done for LCDA as well (see above) */ - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); - } - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); - } else if(HwDeviceExtension->jChipType == SIS_300) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); - } - - } /* 301B */ - - SiS_SetCRT2VCLK(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); -} - -/* TW: Double-Checked against 650/301LV(x) and 630/301B BIOS */ -void -SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT vclkindex; - USHORT tempah; - - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - HwDeviceExtension); - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,tempah); - tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0B,tempah); - /* TW: New from 650/301LV, LVx BIOS (300/301LV does not do this) */ - if(HwDeviceExtension->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 650/301LV: (VB_SIS301LV | VB_SIS302LV)) */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { - if((ModeNo == 0x4a) || (ModeNo == 0x38)) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0a,0x57); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0b,0x46); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1f,0xf6); - } - } - } - } - } - } else { /* 650/301LVx does not do this anymore, jumps to SetRegs above - BUG? */ - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,0x01); - tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0B,tempah); - tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A; - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,tempah); - } - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x12,0x00); - tempah = 0x08; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { - tempah |= 0x20; - } - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x12,tempah); -} - -/* TW: Double-checked against 650/LVDS (1.10.07), 630/301B/LVDS/LVDS+CH, 650/301LVx (1.10.6s) BIOS */ -USHORT -SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT tempbx; -#ifdef SIS300 - const USHORT LCDXlat1VCLK300[4] = {VCLK65, VCLK65, VCLK65, VCLK65}; - const USHORT LCDXlat2VCLK300[4] = {VCLK108_2,VCLK108_2,VCLK108_2,VCLK108_2}; - const USHORT LVDSXlat2VCLK300[4]= {VCLK65, VCLK65, VCLK65, VCLK65}; - const USHORT LVDSXlat3VCLK300[4]= {VCLK65, VCLK65, VCLK65, VCLK65}; -#endif -#ifdef SIS315H - const USHORT LCDXlat1VCLK310[4] = {VCLK65+2, VCLK65+2, VCLK65+2, VCLK65+2}; - const USHORT LCDXlat2VCLK310[4] = {VCLK108_2+5,VCLK108_2+5,VCLK108_2+5,VCLK108_2+5}; - const USHORT LVDSXlat2VCLK310[4]= {VCLK65+2, VCLK65+2, VCLK65+2, VCLK65+2}; - const USHORT LVDSXlat3VCLK310[4]= {VCLK108_2+5,VCLK108_2+5,VCLK108_2+5,VCLK108_2+5}; - /* {VCLK65+2, VCLK65+2, VCLK65+2, VCLK65+2}; - 650/LVDS 1.10.07 */ -#endif - const USHORT LCDXlat0VCLK[4] = {VCLK40, VCLK40, VCLK40, VCLK40}; - const USHORT LVDSXlat1VCLK[4] = {VCLK40, VCLK40, VCLK40, VCLK40}; - USHORT CRT2Index,VCLKIndex=0; - USHORT modeflag,resinfo; - const UCHAR *CHTVVCLKPtr=NULL; - const USHORT *LCDXlatVCLK1 = NULL; - const USHORT *LCDXlatVCLK2 = NULL; - const USHORT *LVDSXlatVCLK2 = NULL; - const USHORT *LVDSXlatVCLK3 = NULL; - - if(HwDeviceExtension->jChipType >= SIS_315H) { -#ifdef SIS315H - LCDXlatVCLK1 = LCDXlat1VCLK310; - LCDXlatVCLK2 = LCDXlat2VCLK310; - LVDSXlatVCLK2 = LVDSXlat2VCLK310; - LVDSXlatVCLK3 = LVDSXlat3VCLK310; -#endif - } else { -#ifdef SIS300 - LCDXlatVCLK1 = LCDXlat1VCLK300; - LCDXlatVCLK2 = LCDXlat2VCLK300; - LVDSXlatVCLK2 = LVDSXlat2VCLK300; - LVDSXlatVCLK3 = LVDSXlat3VCLK300; -#endif - } - - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; - CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - CRT2Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - } - - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { /* 301 */ - - if (SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - - CRT2Index >>= 6; - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)){ /* LCD */ - if(HwDeviceExtension->jChipType < SIS_315H) { - /* TW: Inserted from 630/301B BIOS */ - 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 - VCLKIndex = LCDXlatVCLK2[CRT2Index]; - } else { - /* TW: 330, 650/301LV BIOS does not check expanding, 315 does */ - if( (HwDeviceExtension->jChipType > SIS_315PRO) || - (!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) ) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { - VCLKIndex = 0x19; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - VCLKIndex = 0x19; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { - VCLKIndex = 0x21; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - VCLKIndex = LCDXlatVCLK1[CRT2Index]; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) { - VCLKIndex = 0x45; /* TW: TODO: This is certainly wrong */ - if(resinfo == 0x09) VCLKIndex++; - } else { - VCLKIndex = LCDXlatVCLK2[CRT2Index]; - } - } else { - VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02)); /* Port 3cch */ - VCLKIndex = ((VCLKIndex >> 2) & 0x03); - if(ModeNo > 0x13) { - VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - } - if(ModeNo <= 0x13) { /* TW: Inserted from 315 BIOS */ - if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42; - } - if(VCLKIndex == 0) VCLKIndex = 0x41; - if(VCLKIndex == 1) VCLKIndex = 0x43; - if(VCLKIndex == 4) VCLKIndex = 0x44; - } - } - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */ - if((SiS_Pr->SiS_IF_DEF_HiVision == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) { - if(SiS_Pr->SiS_SetFlag & RPLLDIV2XO) VCLKIndex = HiTVVCLKDIV2; - else VCLKIndex = HiTVVCLK; - if(SiS_Pr->SiS_SetFlag & TVSimuMode) { - if(modeflag & Charx8Dot) VCLKIndex = HiTVSimuVCLK; - else VCLKIndex = HiTVTextVCLK; - } - } else { - if(SiS_Pr->SiS_SetFlag & RPLLDIV2XO) VCLKIndex = TVVCLKDIV2; - else VCLKIndex = TVVCLK; - } - if(HwDeviceExtension->jChipType >= SIS_315H) { - VCLKIndex += 25; - } - } else { /* RAMDAC2 */ - VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02)); - VCLKIndex = ((VCLKIndex >> 2) & 0x03); - if(ModeNo > 0x13) { - VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - if(HwDeviceExtension->jChipType < SIS_315H) { - VCLKIndex &= 0x3f; - if( (HwDeviceExtension->jChipType == SIS_630) && - (HwDeviceExtension->jChipRevision >= 0x30)) { - if(VCLKIndex == 0x14) VCLKIndex = 0x2e; - } - } - } + tempbx = 0; + tempax = SiS_Pr->SiS_VGAHDE; + if(modeflag & HalfDCLK) tempax >>= 1; + if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) || (SiS_Pr->SiS_HiVision & 0x03)) { + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempax >>= 1; + else if(tempax > 800) tempax -= 800; + } else { + if(tempax > 800) tempax -= 800; } + } - } 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((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++; } - } - - } else { /* LVDS */ - - VCLKIndex = CRT2Index; - - if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { /* programming CRT2 */ - - if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { - - VCLKIndex &= 0x1f; - tempbx = 0; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - tempbx += 2; - if(SiS_Pr->SiS_CHSOverScan) tempbx = 8; - if(SiS_Pr->SiS_CHPALM) { - tempbx = 4; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - } else if(SiS_Pr->SiS_CHPALN) { - tempbx = 6; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1; - } - } - switch(tempbx) { - case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break; - case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break; - case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break; - case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; - case 4: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALM; break; - case 5: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALM; break; - case 6: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALN; break; - case 7: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALN; break; - case 8: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKSOPAL; break; - default: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; - } - VCLKIndex = CHTVVCLKPtr[VCLKIndex]; - - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - - VCLKIndex >>= 6; - if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) || - (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480)) - VCLKIndex = LVDSXlat1VCLK[VCLKIndex]; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) - VCLKIndex = LVDSXlatVCLK2[VCLKIndex]; - else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) - VCLKIndex = LVDSXlatVCLK2[VCLKIndex]; - else VCLKIndex = LVDSXlatVCLK3[VCLKIndex]; - - } else { + } + 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_SetReg(SiS_Pr->SiS_Part4Port,0x1D,tempax & 0x00FF); + temp <<= 4; + temp |= tempbx; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1E,temp); + + if(SiS_Pr->SiS_VBType & VB_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_TVMode & TVSetTVSimuMode)) + temp &= 0xFE; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0,temp); - VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02)); - VCLKIndex = ((VCLKIndex >> 2) & 0x03); - if(ModeNo > 0x13) { - VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - if(HwDeviceExtension->jChipType < SIS_315H) { - VCLKIndex &= 0x3F; - } - if( (HwDeviceExtension->jChipType == SIS_630) && - (HwDeviceExtension->jChipRevision >= 0x30) ) { - if(VCLKIndex == 0x14) VCLKIndex = 0x2e; - } - } + tempbx = SiS_Pr->SiS_HT; + if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + tempbx >>= 1; + tempbx -= 2; + temp = ((tempbx & 0x0700) >> 8) << 3; + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp); + temp = tempbx & 0x00FF; + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x22,temp); + + 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); } - - } 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 - } + } + if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { +#ifdef SET_EMI_CPQ + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x30,0x00); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); } - +#endif + } else if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { +#ifdef SET_EMI + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x30,0x00); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); +#endif } + } - } -#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); } -/* TW: Set 301 Palette address port registers */ -/* TW: Checked against 650/301LV BIOS */ -void -SiS_SetGroup5(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr, - UCHAR *ROMAddr, USHORT ModeNo, USHORT ModeIdIndex) +/*********************************************/ +/* SET PART 5 REGISTER GROUP */ +/*********************************************/ + +/* Set 301 Palette address port registers */ +static void +SiS_SetGroup5(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; - if(SiS_Pr->SiS_ModeType == ModeVGA){ - if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))){ - SiS_EnableCRT2(SiS_Pr); - SiS_LoadDAC(SiS_Pr,HwDeviceExtension,ROMAddr,ModeNo,ModeIdIndex); - } + if(SiS_Pr->SiS_ModeType == ModeVGA) { + if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))){ + SiS_EnableCRT2(SiS_Pr); + SiS_LoadDAC(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + } } - return; } -/* TW: Checked against 650/LVDS and 630/301B BIOS */ -void -SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) +/*********************************************/ +/* MODIFY CRT1 GROUP FOR SLAVE MODE */ +/*********************************************/ + +static void +SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) { - USHORT temp,tempah,i,modeflag,j; - USHORT ResInfo,DisplayType; + USHORT tempah,i,modeflag,j; + USHORT ResIndex,DisplayType; const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr=NULL; if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; } - temp = SiS_GetLVDSCRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &ResInfo,&DisplayType); + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || + (SiS_Pr->SiS_CustomT == CUT_PANEL848)) + return; - if(temp == 0) return; + if(!(SiS_GetLVDSCRT1Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, + &ResIndex, &DisplayType))) return; - /* TW: Inserted from 630/LVDS BIOS */ - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_SetFlag & CRT2IsVGA) return; + if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_SetFlag & SetDOSMode) return; } switch(DisplayType) { @@ -8170,313 +8434,125 @@ SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdI 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 40: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_1; break; + case 41: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_1_H; break; + case 42: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2; break; + case 43: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2_H; break; + case 50: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1; break; + case 51: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1_H; break; + case 52: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2; break; + case 53: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2_H; break; + case 54: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3; break; + case 55: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3_H; break; case 99: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1SOPAL; break; default: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; } SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /*unlock cr0-7 */ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[0]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x00,tempah); + tempah = (LVDSCRT1Ptr + ResIndex)->CR[0]; + SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,tempah); for(i=0x02,j=1;i<=0x05;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; + SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); } for(i=0x06,j=5;i<=0x07;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; + SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); } for(i=0x10,j=7;i<=0x11;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; + SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); } for(i=0x15,j=9;i<=0x16;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); + tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; + SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); } for(i=0x0A,j=11;i<=0x0C;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,tempah); + tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; + SiS_SetReg(SiS_Pr->SiS_P3c4,i,tempah); } - tempah = (LVDSCRT1Ptr+ResInfo)->CR[14]; + tempah = (LVDSCRT1Ptr + ResIndex)->CR[14]; tempah &= 0xE0; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah); /* TW: Modfied (650/LVDS); Was SetReg(tempah) */ + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah); - tempah = (LVDSCRT1Ptr+ResInfo)->CR[14]; + tempah = (LVDSCRT1Ptr + ResIndex)->CR[14]; tempah &= 0x01; tempah <<= 5; - if(modeflag & DoubleScanMode){ - tempah |= 0x080; - } + if(modeflag & DoubleScanMode) tempah |= 0x080; SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah); - /* TW: Inserted from 650/LVDS BIOS */ + /* 650/LVDS BIOS - doesn't make sense */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { if(modeflag & HalfDCLK) SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); } - - return; } -#if 0 /* TW: Unused */ -/*301b*/ -void -SiS_CHACRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex) -{ - USHORT temp,tempah,i,modeflag,j; - USHORT ResInfo,DisplayType; - SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr=NULL; - - if(ModeNo<=0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */ - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */ - } - - temp=SiS_GetLVDSCRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &ResInfo,&DisplayType); - if(temp==0){ - return; - } +/*********************************************/ +/* SET CRT2 ECLK */ +/*********************************************/ - 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; /* FSTN */ - case 99: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break; - } - - tempah=(UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x11); /*unlock cr0-7 */ - tempah=tempah&0x7F; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x11,tempah); - tempah = (LVDSCRT1Ptr+ResInfo)->CR[0]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x0,tempah); - for(i=0x02,j=1;i<=0x05;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x06,j=5;i<=0x07;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x10,j=7;i<=0x11;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x15,j=9;i<=0x16;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah); - } - - for(i=0x0A,j=11;i<=0x0C;i++,j++){ - tempah = (LVDSCRT1Ptr+ResInfo)->CR[j]; - SiS_SetReg1(SiS_Pr->SiS_P3c4,i,tempah); - } - - tempah = (LVDSCRT1Ptr+ResInfo)->CR[14]; - tempah=tempah&0x0E0; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x0E,tempah); - - tempah = (LVDSCRT1Ptr+ResInfo)->CR[14]; - tempah=tempah&0x01; - tempah=tempah<<5; - if(modeflag&DoubleScanMode){ - tempah=tempah|0x080; - } - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah); - return; -} -#endif - -/* TW: Checked against 650/LVDS BIOS: modified for new panel resolutions */ -BOOLEAN -SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *ResInfo, - USHORT *DisplayType) - { - USHORT tempbx,modeflag=0; - USHORT Flag,CRT2CRTC; - - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - /* TW: Inserted from 650/LVDS BIOS */ - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return 0; - } - } +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(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - CRT2CRTC = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) || (SiS_Pr->SiS_IF_DEF_TRUMPION == 1)) { + SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); + if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK & 0x3f) == 2) { + RefreshRateTableIndex--; + } + vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, + RefreshRateTableIndex, HwInfo); + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - CRT2CRTC = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, + RefreshRateTableIndex, HwInfo); } - Flag = 1; - tempbx = 0; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - Flag = 0; - tempbx = 18; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx++; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - tempbx += 2; - if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; - if(SiS_Pr->SiS_CHPALM) { - tempbx = 18; /* PALM uses NTSC data */ - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx++; - } else if(SiS_Pr->SiS_CHPALN) { - tempbx = 20; /* PALN uses PAL data */ - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx++; - } - } - } - } - if(Flag) { - tempbx = SiS_Pr->SiS_LCDResInfo; - tempbx -= SiS_Pr->SiS_PanelMinLVDS; - if(SiS_Pr->SiS_LCDResInfo <= SiS_Pr->SiS_Panel1280x1024) { - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 6; - if(modeflag & HalfDCLK) tempbx += 3; - } else { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - tempbx = 14; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 2; - if(modeflag & HalfDCLK) tempbx++; - } else if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - tempbx = 12; - if(modeflag & HalfDCLK) tempbx++; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) { - tempbx = 23; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 2; - if(modeflag & HalfDCLK) tempbx++; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) { - tempbx = 27; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 2; - if(modeflag & HalfDCLK) tempbx++; - } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { - tempbx = 36; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 2; - if(modeflag & HalfDCLK) tempbx++; - } - } - } - if(SiS_Pr->SiS_IF_DEF_FSTN){ - if(SiS_Pr->SiS_LCDResInfo==SiS_Pr->SiS_Panel320x480){ - tempbx=22; - } - } - *ResInfo = CRT2CRTC & 0x3F; - *DisplayType = tempbx; - return 1; -} + sr2b = SiS_Pr->SiS_VCLKData[vclkindex].SR2B; + sr2c = SiS_Pr->SiS_VCLKData[vclkindex].SR2C; -/* TW: Checked against 650/LVDS (1.10a, 1.10.07), 630/301B (I/II) and 630/LVDS BIOS */ -void -SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension) -{ - USHORT tempah,tempal,pushax; - USHORT vclkindex=0; - - if(HwDeviceExtension->jChipType < SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) return; + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + if(ROMAddr[0x220] & 0x01) { + sr2b = ROMAddr[0x227]; + sr2c = ROMAddr[0x228]; + } } } - if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) || (SiS_Pr->SiS_IF_DEF_TRUMPION == 1)) { - SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); - tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - tempal &= 0x3F; - if(tempal == 2) RefreshRateTableIndex--; - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - } else { - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwDeviceExtension); - } - - tempal = 0x02B; + clkbase = 0x02B; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - tempal += 3; - } - } - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86); - pushax = tempal; - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x20); - tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2B; - SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah); - tempal++; - tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2C; - SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x10); - tempal = pushax; - tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2B; - SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah); - tempal++; - tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2C; - SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah); - SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x00); - tempal = pushax; - tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2B; - SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah); - tempal++; - tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2C; - SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah); - return; -} - -#if 0 /* TW: Not used */ -void -SiS_SetDefCRT2ExtRegs(SiS_Private *SiS_Pr, USHORT BaseAddr) -{ - USHORT temp; - - if(SiS_Pr->SiS_IF_DEF_LVDS==0) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x02,0x40); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x10,0x80); - temp=(UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16); - temp &= 0xC3; - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x35,temp); - } else { - SiS_SetReg1(SiS_Pr->SiS_P3d4,0x32,0x02); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x02,0x00); + clkbase += 3; + } } + + SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x20); + SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase,sr2b); + SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase+1,sr2c); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x10); + SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase,sr2b); + SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase+1,sr2c); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x00); + SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase,sr2b); + SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase+1,sr2c); } -#endif -/* TW: Start of Chrontel 70xx functions ---------------------- */ +/*********************************************/ +/* SET UP CHRONTEL CHIPS */ +/*********************************************/ -/* Set-up the Chrontel Registers */ -void -SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, +static void +SiS_SetCHTVReg(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex) { USHORT temp, tempbx, tempcl; @@ -8489,16 +8565,18 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIn tempcl = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; TVType = 0; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) TVType += 1; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { TVType += 2; - if(SiS_Pr->SiS_CHSOverScan) TVType = 8; - if(SiS_Pr->SiS_CHPALM) { + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) TVType = 8; + } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { TVType = 4; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) TVType += 1; - } else if(SiS_Pr->SiS_CHPALN) { + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; + } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { TVType = 6; - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) TVType += 1; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; } } switch(TVType) { @@ -8517,43 +8595,45 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIn if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - /* Chrontel 7005 */ +#ifdef SIS300 + + /* Chrontel 7005 - I assume that it does not come with a 315 series chip */ - /* TW: We don't support modes >800x600 */ + /* We don't support modes >800x600 */ if (resindex > 5) return; - if(SiS_Pr->SiS_VBInfo & SetPALTV) { - SiS_SetCH700x(SiS_Pr,0x4304); /* TW: 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/ - SiS_SetCH700x(SiS_Pr,0x6909); /* TW: Black level for PAL (105)*/ + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + SiS_SetCH700x(SiS_Pr,0x4304); /* 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/ + SiS_SetCH700x(SiS_Pr,0x6909); /* Black level for PAL (105)*/ } else { - SiS_SetCH700x(SiS_Pr,0x0304); /* TW: upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/ - SiS_SetCH700x(SiS_Pr,0x7109); /* TW: Black level for NTSC (113)*/ + SiS_SetCH700x(SiS_Pr,0x0304); /* upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/ + SiS_SetCH700x(SiS_Pr,0x7109); /* Black level for NTSC (113)*/ } temp = CHTVRegData[resindex].Reg[0]; - tempbx=((temp&0x00FF)<<8)|0x00; /* TW: Mode register */ + tempbx=((temp&0x00FF)<<8)|0x00; /* Mode register */ SiS_SetCH700x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[1]; - tempbx=((temp&0x00FF)<<8)|0x07; /* TW: Start active video register */ + tempbx=((temp&0x00FF)<<8)|0x07; /* Start active video register */ SiS_SetCH700x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[2]; - tempbx=((temp&0x00FF)<<8)|0x08; /* TW: Position overflow register */ + tempbx=((temp&0x00FF)<<8)|0x08; /* Position overflow register */ SiS_SetCH700x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[3]; - tempbx=((temp&0x00FF)<<8)|0x0A; /* TW: Horiz Position register */ + tempbx=((temp&0x00FF)<<8)|0x0A; /* Horiz Position register */ SiS_SetCH700x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[4]; - tempbx=((temp&0x00FF)<<8)|0x0B; /* TW: Vertical Position register */ + tempbx=((temp&0x00FF)<<8)|0x0B; /* Vertical Position register */ SiS_SetCH700x(SiS_Pr,tempbx); - /* TW: Set minimum flicker filter for Luma channel (SR1-0=00), + /* Set minimum flicker filter for Luma channel (SR1-0=00), minimum text enhancement (S3-2=10), maximum flicker filter for Chroma channel (S5-4=10) =00101000=0x28 (When reading, S1-0->S3-2, and S3-2->S1-0!) */ SiS_SetCH700x(SiS_Pr,0x2801); - /* TW: Set video bandwidth + /* Set video bandwidth High bandwith Luma composite video filter(S0=1) low bandwith Luma S-video filter (S2-1=00) disable peak filter in S-video channel (S3=0) @@ -8562,66 +8642,68 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIn */ SiS_SetCH700x(SiS_Pr,0xb103); /* old: 3103 */ - /* TW: Register 0x3D does not exist in non-macrovision register map + /* Register 0x3D does not exist in non-macrovision register map (Maybe this is a macrovision register?) */ - /* SiS_SetCH70xx(SiS_Pr,0x003D); */ +#ifndef SIS_CP + SiS_SetCH70xx(SiS_Pr,0x003D); +#endif - /* TW: Register 0x10 only contains 1 writable bit (S0) for sensing, + /* Register 0x10 only contains 1 writable bit (S0) for sensing, all other bits a read-only. Macrovision? */ SiS_SetCH70xxANDOR(SiS_Pr,0x0010,0x1F); - /* TW: Register 0x11 only contains 3 writable bits (S0-S2) for + /* Register 0x11 only contains 3 writable bits (S0-S2) for contrast enhancement (set to 010 -> gain 1 Yout = 17/16*(Yin-30) ) */ SiS_SetCH70xxANDOR(SiS_Pr,0x0211,0xF8); - /* TW: Clear DSEN + /* Clear DSEN */ SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xEF); - if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { /* ---- NTSC ---- */ - if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) { + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { /* ---- NTSC ---- */ + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) { if(resindex == 0x04) { /* 640x480 overscan: Mode 16 */ SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on, no need to set FSCI */ - } else { - if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0C19,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001A,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001B,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001D,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001E,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001F,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x0120,0xEF); /* Loop filter on for mode 23 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ - } + } else if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0C19,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x001A,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x001B,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x001D,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x001E,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x001F,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x0120,0xEF); /* Loop filter on for mode 23 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ } } else { if(resindex == 0x04) { /* ----- 640x480 underscan; Mode 17 */ SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); - } else { - if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0919,0xF0); /* FSCI for mode 24 is 428,554,851 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x081A,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x0b1B,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x031C,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x0a1D,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x061E,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x031F,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off for mode 24 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ - } + } else if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */ +#if 0 + SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0919,0xF0); /* FSCI for mode 24 is 428,554,851 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x081A,0xF0); /* 198b3a63 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0b1B,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x041C,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x011D,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x061E,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x051F,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off for mode 24 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ +#endif /* All alternatives wrong (datasheet wrong?), don't use FSCI */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ + SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); } } - } else { /* ---- PAL ---- */ - /* TW: We don't play around with FSCI in PAL mode */ - if (resindex == 0x04) { + } else { /* ---- PAL ---- */ + /* We don't play around with FSCI in PAL mode */ + if(resindex == 0x04) { SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */ } else { @@ -8629,283 +8711,484 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIn SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */ } } + +#endif /* 300 */ } else { - /* Chrontel 7019 */ + /* Chrontel 7019 - assumed that it does not come with a 300 series chip */ + +#ifdef SIS315H - /* TW: We don't support modes >1024x768 */ + /* We don't support modes >1024x768 */ if (resindex > 6) return; temp = CHTVRegData[resindex].Reg[0]; - tempbx=((temp & 0x00FF) <<8 ) | 0x00; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { + temp |= 0x10; + } + tempbx=((temp & 0x00FF) << 8) | 0x00; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[1]; - tempbx=((temp & 0x00FF) <<8 ) | 0x01; + tempbx=((temp & 0x00FF) << 8) | 0x01; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[2]; - tempbx=((temp & 0x00FF) <<8 ) | 0x02; + tempbx=((temp & 0x00FF) << 8) | 0x02; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[3]; - tempbx=((temp & 0x00FF) <<8 ) | 0x04; + tempbx=((temp & 0x00FF) << 8) | 0x04; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[4]; - tempbx=((temp & 0x00FF) <<8 ) | 0x03; + tempbx=((temp & 0x00FF) << 8) | 0x03; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[5]; - tempbx=((temp & 0x00FF) <<8 ) | 0x05; + tempbx=((temp & 0x00FF) << 8) | 0x05; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[6]; - tempbx=((temp & 0x00FF) <<8 ) | 0x06; + tempbx=((temp & 0x00FF) << 8) | 0x06; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[7]; - tempbx=((temp & 0x00FF) <<8 ) | 0x07; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { + temp = 0x66; + } + tempbx=((temp & 0x00FF) << 8) | 0x07; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[8]; - tempbx=((temp & 0x00FF) <<8 ) | 0x08; + tempbx=((temp & 0x00FF) << 8) | 0x08; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[9]; - tempbx=((temp & 0x00FF) <<8 ) | 0x15; + tempbx=((temp & 0x00FF) << 8) | 0x15; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[10]; - tempbx=((temp & 0x00FF) <<8 ) | 0x1f; + tempbx=((temp & 0x00FF) << 8) | 0x1f; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[11]; - tempbx=((temp & 0x00FF) <<8 ) | 0x0c; + tempbx=((temp & 0x00FF) << 8) | 0x0c; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[12]; - tempbx=((temp & 0x00FF) <<8 ) | 0x0d; + tempbx=((temp & 0x00FF) << 8) | 0x0d; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[13]; - tempbx=((temp & 0x00FF) <<8 ) | 0x0e; + tempbx=((temp & 0x00FF) << 8) | 0x0e; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[14]; - tempbx=((temp & 0x00FF) <<8 ) | 0x0f; + tempbx=((temp & 0x00FF) << 8) | 0x0f; SiS_SetCH701x(SiS_Pr,tempbx); temp = CHTVRegData[resindex].Reg[15]; - tempbx=((temp & 0x00FF) <<8 ) | 0x10; + tempbx=((temp & 0x00FF) << 8) | 0x10; SiS_SetCH701x(SiS_Pr,tempbx); + temp = SiS_GetCH701x(SiS_Pr,0x21) & ~0x02; + /* D1 should be set for PAL, PAL-N and NTSC-J, + but I won't do that for PAL unless somebody + tells me to do so. Since the BIOS uses + non-default CIV values and blacklevels, + this might be compensated anyway. + */ + if(SiS_Pr->SiS_TVMode & (TVSetPALN | TVSetNTSCJ)) temp |= 0x02; + SiS_SetCH701x(SiS_Pr,((temp << 8) | 0x21)); + +#endif /* 315 */ + } + +#ifdef SIS_CP + SIS_CP_INIT301_CP3 +#endif + } -/* TW: Chrontel 701x functions ================================= */ +void +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(HwInfo->jChipType == SIS_740) { + SiS_SetCH701x(SiS_Pr,0x6566); + } else { + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp |= 0x20; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); + } + } +} void -SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr) -{ - UCHAR regtable[] = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71, - 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d }; - UCHAR table1024[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, - 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 }; - UCHAR table1400[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xef, - 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 }; +SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr) +{ + USHORT temp; + + /* 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); + } +} + +#ifdef SIS315H /* ----------- 315 series only ---------- */ + +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 == SiS_Pr->SiS_Panel1024x768) { + if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1024_740; + else tableptr = table1024_740; + } else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) { + if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1400_740; + else tableptr = table1400_740; + } else return; + } else { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + tableptr = table1024_650; + } else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) || + (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) { + tableptr = table1400_650; + } else return; + } + + for(i=0; i<5; i++) { + SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]); + } +} + +static void +SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR regtable[] = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71, + 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66 }; + UCHAR table1024_740[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, + 0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44 }; + UCHAR table1280_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 }; + UCHAR table1400_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 }; + UCHAR table1600_740[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44 }; + UCHAR table1024_650[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, + 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 }; + UCHAR table1280_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02 }; + UCHAR table1400_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xef, + 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 }; + UCHAR table1600_650[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a }; UCHAR *tableptr = NULL; USHORT tempbh; int i; - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - tableptr = table1400; + if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + tableptr = table1024_740; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + tableptr = table1280_740; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + tableptr = table1400_740; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + tableptr = table1600_740; + } else return; } else { - tableptr = table1024; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + tableptr = table1024_650; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + tableptr = table1280_650; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { + tableptr = table1400_650; + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) { + tableptr = table1600_650; + } else return; } + tempbh = SiS_GetCH701x(SiS_Pr,0x74); if((tempbh == 0xf6) || (tempbh == 0xc7)) { tempbh = SiS_GetCH701x(SiS_Pr,0x73); if(tempbh == 0xc8) { - if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) return; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) return; } else if(tempbh == 0xdb) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) return; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) return; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) return; + } else if(tempbh == 0xde) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) return; } } - for(i=0; i<0x0c; i++) { + + if(HwInfo->jChipType == SIS_740) { + tempbh = 0x0d; + } else { + tempbh = 0x0c; + } + for(i = 0; i < tempbh; i++) { SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]); } - SiS_ChrontelPowerSequencing(SiS_Pr); + SiS_ChrontelPowerSequencing(SiS_Pr,HwInfo); tempbh = SiS_GetCH701x(SiS_Pr,0x1e); tempbh |= 0xc0; - SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1e); -} - -void -SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr) -{ - UCHAR regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b }; - UCHAR table1024[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; - UCHAR table1400[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; - UCHAR *tableptr = NULL; - int i; + SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1e); - /* Set up Power up/down timing */ - - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - tableptr = table1400; - } else { - tableptr = table1024; - } - - for(i=0; i<5; i++) { - SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]); + if(HwInfo->jChipType == SIS_740) { + tempbh = SiS_GetCH701x(SiS_Pr,0x1c); + tempbh &= 0xfb; + SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1c); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); + tempbh = SiS_GetCH701x(SiS_Pr,0x64); + tempbh |= 0x40; + SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x64); + tempbh = SiS_GetCH701x(SiS_Pr,0x03); + tempbh &= 0x3f; + SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x03); } } -void -SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr) +static void +SiS_ChrontelResetVSync(SiS_Private *SiS_Pr) { - USHORT temp; + unsigned char temp, temp1; - /* TW: Enable Chrontel 7019 LCD panel backlight */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp |= 0x20; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); - } + 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(SiS_IsYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) { + if(HwInfo->jChipType == SIS_740) { + temp = SiS_GetCH701x(SiS_Pr,0x1c); + temp |= 0x04; /* Invert XCLK phase */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); + } + if(SiS_IsYPbPr(SiS_Pr, HwInfo)) { temp = SiS_GetCH701x(SiS_Pr,0x01); temp &= 0x3f; - temp |= 0x80; /* TW: Enable YPrPb (HDTV) */ + temp |= 0x80; /* Enable YPrPb (HDTV) */ SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01); } - if(SiS_IsChScart(SiS_Pr,HwDeviceExtension, BaseAddr)) { + if(SiS_IsChScart(SiS_Pr, HwInfo)) { temp = SiS_GetCH701x(SiS_Pr,0x01); temp &= 0x3f; - temp |= 0xc0; /* TW: Enable SCART + CVBS */ + temp |= 0xc0; /* Enable SCART + CVBS */ SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01); } - SiS_SetCH701x(SiS_Pr,0x2049); /* TW: Enable TV path */ - temp = SiS_GetCH701x(SiS_Pr,0x49); - if(SiS_IsYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) { - temp = SiS_GetCH701x(SiS_Pr,0x73); - temp |= 0x60; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x73); + if(HwInfo->jChipType == SIS_740) { + SiS_ChrontelResetVSync(SiS_Pr); + SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */ + } else { + SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */ + temp = SiS_GetCH701x(SiS_Pr,0x49); + if(SiS_IsYPbPr(SiS_Pr,HwInfo)) { + temp = SiS_GetCH701x(SiS_Pr,0x73); + temp |= 0x60; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x73); + } + temp = SiS_GetCH701x(SiS_Pr,0x47); + temp &= 0x7f; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); + SiS_LongDelay(SiS_Pr,2); + temp = SiS_GetCH701x(SiS_Pr,0x47); + temp |= 0x80; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); } - temp = SiS_GetCH701x(SiS_Pr,0x47); - temp &= 0x7f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); - SiS_LongDelay(SiS_Pr,2); - temp = SiS_GetCH701x(SiS_Pr,0x47); - temp |= 0x80; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); - } -} - -void -SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr) -{ - USHORT temp; - - /* TW: 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); } } void -SiS_Chrontel701xOff(SiS_Private *SiS_Pr) +SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { USHORT temp; + /* Complete power down of LVDS */ if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(HwInfo->jChipType == SIS_740) { + SiS_LongDelay(SiS_Pr,1); + SiS_GenericDelay(SiS_Pr,0x16ff); + SiS_SetCH701x(SiS_Pr,0xac76); + SiS_SetCH701x(SiS_Pr,0x0066); + } else { SiS_LongDelay(SiS_Pr,2); - /* TW: Complete power down of LVDS */ temp = SiS_GetCH701x(SiS_Pr,0x76); temp &= 0xfc; SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); SiS_SetCH701x(SiS_Pr,0x0066); + } } } -void -SiS_ChrontelResetDB(SiS_Private *SiS_Pr) +static void +SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) { - /* TW: Reset Chrontel 7019 datapath */ - SiS_SetCH701x(SiS_Pr,0x1048); - SiS_LongDelay(SiS_Pr,1); - SiS_SetCH701x(SiS_Pr,0x1848); + USHORT temp; + + if(HwInfo->jChipType == SIS_740) { + + temp = SiS_GetCH701x(SiS_Pr,0x4a); /* Version ID */ + temp &= 0x01; + if(!temp) { + + if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) { + temp = SiS_GetCH701x(SiS_Pr,0x49); + SiS_SetCH701x(SiS_Pr,0x3e49); + } + /* Reset Chrontel 7019 datapath */ + SiS_SetCH701x(SiS_Pr,0x1048); + SiS_LongDelay(SiS_Pr,1); + SiS_SetCH701x(SiS_Pr,0x1848); + + if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) { + SiS_ChrontelResetVSync(SiS_Pr); + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x49); + } + + } else { + + /* Clear/set/clear GPIO */ + temp = SiS_GetCH701x(SiS_Pr,0x5c); + temp &= 0xef; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); + temp = SiS_GetCH701x(SiS_Pr,0x5c); + temp |= 0x10; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); + temp = SiS_GetCH701x(SiS_Pr,0x5c); + temp &= 0xef; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); + temp = SiS_GetCH701x(SiS_Pr,0x61); + if(!temp) { + SiS_SetCH701xForLCD(SiS_Pr, HwInfo); + } + } + + } else { /* 650 */ + /* Reset Chrontel 7019 datapath */ + SiS_SetCH701x(SiS_Pr,0x1048); + SiS_LongDelay(SiS_Pr,1); + SiS_SetCH701x(SiS_Pr,0x1848); + } } 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; - SiS_SetCH701x(SiS_Pr,0xaf76); /* Power up LVDS block */ - temp = SiS_GetCH701x(SiS_Pr,0x49); - temp &= 1; - if(temp != 1) { /* TV block powered? (0 = yes, 1 = no) */ - temp = SiS_GetCH701x(SiS_Pr,0x47); - temp &= 0x70; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* enable VSYNC */ - SiS_LongDelay(SiS_Pr,3); - temp = SiS_GetCH701x(SiS_Pr,0x47); - temp |= 0x80; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* disable VSYNC */ + if(HwInfo->jChipType == SIS_740) { + + if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) { + SiS_ChrontelResetVSync(SiS_Pr); + } + + } else { + + SiS_SetCH701x(SiS_Pr,0xaf76); /* Power up LVDS block */ + temp = SiS_GetCH701x(SiS_Pr,0x49); + temp &= 1; + if(temp != 1) { /* TV block powered? (0 = yes, 1 = no) */ + temp = SiS_GetCH701x(SiS_Pr,0x47); + temp &= 0x70; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* enable VSYNC */ + SiS_LongDelay(SiS_Pr,3); + temp = SiS_GetCH701x(SiS_Pr,0x47); + temp |= 0x80; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* disable VSYNC */ + } + } } -void -SiS_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; - temp1 = 0; - temp = SiS_GetCH701x(SiS_Pr,0x61); - if(temp < 2) { - temp++; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); - temp1 = 1; - } - SiS_SetCH701x(SiS_Pr,0xac76); - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp |= 0x5f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); - if(ModeNo > 0x13) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { - SiS_GenericDelay(SiS_Pr,0x3ff); - } else { - SiS_GenericDelay(SiS_Pr,0x2ff); - } - } else { - if(!temp1) - SiS_GenericDelay(SiS_Pr,0x2ff); + if(HwInfo->jChipType == SIS_740) { + + temp = SiS_GetCH701x(SiS_Pr,0x61); + if(temp < 1) { + temp++; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); + } + SiS_SetCH701x(SiS_Pr,0x4566); /* Panel power on */ + SiS_SetCH701x(SiS_Pr,0xaf76); /* All power on */ + SiS_LongDelay(SiS_Pr,1); + SiS_GenericDelay(SiS_Pr,0x16ff); + + } else { /* 650 */ + + temp1 = 0; + temp = SiS_GetCH701x(SiS_Pr,0x61); + if(temp < 2) { + temp++; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); + temp1 = 1; + } + SiS_SetCH701x(SiS_Pr,0xac76); + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp |= 0x5f; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); + if(ModeNo > 0x13) { + if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) { + SiS_GenericDelay(SiS_Pr,0x3ff); + } else { + SiS_GenericDelay(SiS_Pr,0x2ff); + } + } else { + if(!temp1) + SiS_GenericDelay(SiS_Pr,0x2ff); + } + temp = SiS_GetCH701x(SiS_Pr,0x76); + temp |= 0x03; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp &= 0x7f; + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); + SiS_LongDelay(SiS_Pr,1); + } - temp = SiS_GetCH701x(SiS_Pr,0x76); - temp |= 0x03; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp &= 0x7f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); - SiS_LongDelay(SiS_Pr,1); } -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; @@ -8915,35 +9198,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; - SiS_SetCH701xForLCD(SiS_Pr,HwDeviceExtension,BaseAddr); + if(HwInfo->jChipType == SIS_740) { + /* Power down LVDS output, PLL normal operation */ + SiS_SetCH701x(SiS_Pr,0xac76); + } + + SiS_SetCH701xForLCD(SiS_Pr,HwInfo); if(tempcl == 0) { if(tempch == 3) break; - SiS_ChrontelResetDB(SiS_Pr); + 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); - SiS_SetCH701x(SiS_Pr,0x6078); + 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; @@ -8952,245 +9243,474 @@ SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtens temp &= 0xbf; /* Set datapath 2 to LVDS */ SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); - SiS_ChrontelResetDB(SiS_Pr); + if(HwInfo->jChipType == SIS_740) { + + temp = SiS_GetCH701x(SiS_Pr,0x1c); + temp &= 0xfb; /* Normal XCLK phase */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); + + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); + + temp = SiS_GetCH701x(SiS_Pr,0x64); + temp |= 0x40; /* ? Bit not defined */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x64); + + temp = SiS_GetCH701x(SiS_Pr,0x03); + temp &= 0x3f; /* D1 input to both LVDS and TV */ + SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); + + if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) { + SiS_SetCH701x(SiS_Pr,0x4063); /* LVDS off */ + SiS_LongDelay(SiS_Pr, 1); + SiS_SetCH701x(SiS_Pr,0x0063); /* LVDS on */ + SiS_ChrontelResetDB(SiS_Pr, HwInfo); + SiS_ChrontelDoSomething2(SiS_Pr, HwInfo); + SiS_ChrontelDoSomething3(SiS_Pr, 0, HwInfo); + } else { + temp = SiS_GetCH701x(SiS_Pr,0x66); + if(temp != 0x45) { + SiS_ChrontelResetDB(SiS_Pr, HwInfo); + SiS_ChrontelDoSomething2(SiS_Pr, HwInfo); + SiS_ChrontelDoSomething3(SiS_Pr, 0, HwInfo); + } + } + + } else { /* 650 */ + + SiS_ChrontelResetDB(SiS_Pr,HwInfo); + SiS_ChrontelDoSomething2(SiS_Pr,HwInfo); + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34); + SiS_ChrontelDoSomething3(SiS_Pr,temp,HwInfo); + SiS_SetCH701x(SiS_Pr,0xaf76); /* All power on, LVDS normal operation */ + + } + +} +#endif /* 315 series */ + +/*********************************************/ +/* MAIN: SET CRT2 REGISTER GROUP */ +/*********************************************/ + +BOOLEAN +SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) +{ +#ifdef SIS300 + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; +#endif + USHORT ModeIdIndex, RefreshRateTableIndex; +#if 0 + USHORT temp; +#endif + + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + + if(!SiS_Pr->UseCustomMode) { + SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex); + } else { + ModeIdIndex = 0; + } + + /* Used for shifting CR33 */ + SiS_Pr->SiS_SelectCRT2Rate = 4; + + SiS_UnLockCRT2(SiS_Pr, HwInfo); + + RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + + SiS_SaveCRT2Info(SiS_Pr,ModeNo); + + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + SiS_DisableBridge(SiS_Pr,HwInfo); + if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (HwInfo->jChipType == SIS_730)) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,0x80); + } + SiS_SetCRT2ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + } + + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { +#if 0 + /* RDirectLCDN */ + if( (SiS_IsVAMode(SiS_Pr, HwInfo)) || + (SiS_IsDualEdge(SiS_Pr, HwInfo)) ) { + temp = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x23); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x23,0x80); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x23,0x7f); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x23,temp); + } +#endif + SiS_LockCRT2(SiS_Pr, HwInfo); + SiS_DisplayOn(SiS_Pr); + return TRUE; + } + + SiS_GetCRT2Data(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + + /* Set up Panel Link for LVDS, 301BDH and 30xLV(for LCDA) */ + if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || + ((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) || + ((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) { + SiS_GetLVDSDesData(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + } else { + SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; + } + +#ifdef LINUX_XF86 +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "(init301: LCDHDES 0x%03x LCDVDES 0x%03x)\n", SiS_Pr->SiS_LCDHDES, SiS_Pr->SiS_LCDVDES); + xf86DrvMsg(0, X_INFO, "(init301: HDE 0x%03x VDE 0x%03x)\n", SiS_Pr->SiS_HDE, SiS_Pr->SiS_VDE); + xf86DrvMsg(0, X_INFO, "(init301: VGAHDE 0x%03x VGAVDE 0x%03x)\n", SiS_Pr->SiS_VGAHDE, SiS_Pr->SiS_VGAVDE); + xf86DrvMsg(0, X_INFO, "(init301: HT 0x%03x VT 0x%03x)\n", SiS_Pr->SiS_HT, SiS_Pr->SiS_VT); + xf86DrvMsg(0, X_INFO, "(init301: VGAHT 0x%03x VGAVT 0x%03x)\n", SiS_Pr->SiS_VGAHT, SiS_Pr->SiS_VGAVT); +#endif +#endif + + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + SiS_SetGroup1(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + } + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + + 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); + SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + + /* For 301BDH (Panel link initialization): */ + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(!((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10)))) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + } + } + } + SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + } + } + + } else { + + if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) { + if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { + SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex, + RefreshRateTableIndex,HwInfo); + } + } + + 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) && ROMAddr && (SiS_Pr->SiS_UseOEM == -1)) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + SiS_OEM300Setting(SiS_Pr,HwInfo,ModeNo,ModeIdIndex, + RefreshRateTableIndex); + } + } else { + SiS_OEM300Setting(SiS_Pr,HwInfo,ModeNo,ModeIdIndex, + RefreshRateTableIndex); + } + } + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + SetOEMLCDData2(SiS_Pr, HwInfo, ModeNo, ModeIdIndex,RefreshRateTableIndex); + } + if(HwInfo->jChipType == SIS_730) { + SiS_DisplayOn(SiS_Pr); + } + } + } + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(HwInfo->jChipType != SIS_730) { + SiS_DisplayOn(SiS_Pr); + } + } + } +#endif + +#ifdef SIS315H + if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + if(HwInfo->jChipType < SIS_661) { + SiS_FinalizeLCD(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + if(SiS_Pr->SiS_UseOEM) { + SiS_OEM310Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + } + } else { + SiS_OEM661Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } + SiS_CRT2AutoThreshold(SiS_Pr); + } + } +#endif + + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + SiS_EnableBridge(SiS_Pr, HwInfo); + } + + SiS_DisplayOn(SiS_Pr); - SiS_ChrontelDoSomething2(SiS_Pr,HwDeviceExtension,BaseAddr); + 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); + } + } - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34); - SiS_ChrontelDoSomething3(SiS_Pr,temp,HwDeviceExtension,BaseAddr); + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + SiS_LockCRT2(SiS_Pr,HwInfo); + } - SiS_SetCH701x(SiS_Pr,0xaf76); + return TRUE; } -/* TW: End of Chrontel 701x functions ==================================== */ -/* TW: Generic Read/write routines for Chrontel ========================== */ +/*********************************************/ +/* ENABLE/DISABLE LCD BACKLIGHT (SIS) */ +/*********************************************/ -/* TW: The Chrontel is connected to the 630/730 via +void +SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + /* Switch on LCD backlight on SiS30xLV */ + 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); +} + +/*********************************************/ +/* DDC RELATED FUNCTIONS */ +/*********************************************/ + +/* The Chrontel 700x is connected to the 630/730 via * the 630/730's DDC/I2C port. * - * On 630(S)T chipset, the index changed from 0x11 to 0x0a, - * possibly for working around the DDC problems + * On 630(S)T chipset, the index changed from 0x11 to + * 0x0a, possibly for working around the DDC problems */ -void -SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +static BOOLEAN +SiS_SetChReg(SiS_Private *SiS_Pr, USHORT tempbx, USHORT myor) { - if (SiS_Pr->SiS_IF_DEF_CH70xx == 1) - SiS_SetCH700x(SiS_Pr,tempbx); - else - SiS_SetCH701x(SiS_Pr,tempbx); -} + USHORT tempah,temp,i; -/* TW: Write to Chrontel 700x */ + 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; +} + +/* 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_DataShift = 0x00; + SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ if(!(SiS_Pr->SiS_ChrontelInit)) { - SiS_Pr->SiS_DDC_Index = 0x11; /* TW: Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ - SiS_Pr->SiS_DDC_DataShift = 0x00; - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB (Device Address Byte) */ - } - - for(i=0;i<10;i++) { /* TW: Do only 10 attempts to write */ - /* SiS_SetSwitchDDC2(SiS_Pr); */ - if(SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = tempbx & 0x00FF; /* TW: Write RAB */ - tempah |= 0x80; /* TW: (set bit 7, see datasheet) */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = (tempbx & 0xFF00) >> 8; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write data */ - if(temp) continue; /* TW: (ERROR: no ack) */ - if(SiS_SetStop(SiS_Pr)) continue; /* TW: Set stop condition */ - SiS_Pr->SiS_ChrontelInit = 1; - return; - } - - /* TW: For 630ST */ - if(!(SiS_Pr->SiS_ChrontelInit)) { - SiS_Pr->SiS_DDC_Index = 0x0a; /* TW: Bit 7 = SC; Bit 6 = SD */ + SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ + SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ + SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ + } + + if( (!(SiS_SetChReg(SiS_Pr, tempbx, 0x80))) && + (!(SiS_Pr->SiS_ChrontelInit)) ) { + SiS_Pr->SiS_DDC_Index = 0x0a; /* Bit 7 = SC; Bit 6 = SD */ SiS_Pr->SiS_DDC_Data = 0x80; /* Bitmask in IndexReg for Data */ SiS_Pr->SiS_DDC_Clk = 0x40; /* Bitmask in IndexReg for Clk */ - SiS_Pr->SiS_DDC_DataShift = 0x00; - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB (Device Address Byte) */ - - for(i=0;i<10;i++) { /* TW: Do only 10 attempts to write */ - /* SiS_SetSwitchDDC2(SiS_Pr); */ - if (SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = tempbx & 0x00FF; /* TW: Write RAB */ - tempah |= 0x80; /* TW: (set bit 7, see datasheet) */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = (tempbx & 0xFF00) >> 8; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write data */ - if(temp) continue; /* TW: (ERROR: no ack) */ - if(SiS_SetStop(SiS_Pr)) continue; /* TW: Set stop condition */ - SiS_Pr->SiS_ChrontelInit = 1; - return; - } + + SiS_SetChReg(SiS_Pr, tempbx, 0x80); } } -/* TW: Write to Chrontel 701x */ +/* Write to Chrontel 701x */ /* Parameter is [Data (S15-S8) | Register no (S7-S0)] */ void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx) { - USHORT tempah,temp,i; - - SiS_Pr->SiS_DDC_Index = 0x11; /* TW: Bit 0 = SC; Bit 1 = SD */ + SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ SiS_Pr->SiS_DDC_DataShift = 0x00; - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB (Device Address Byte) */ + SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ - for(i=0;i<10;i++) { /* TW: Do only 10 attempts to write */ - if (SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = tempbx & 0x00FF; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write RAB */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = (tempbx & 0xFF00) >> 8; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write data */ - if(temp) continue; /* TW: (ERROR: no ack) */ - if(SiS_SetStop(SiS_Pr)) continue; /* TW: Set stop condition */ - return; - } + SiS_SetChReg(SiS_Pr, tempbx, 0); } -/* TW: Read from Chrontel 70xx */ -/* Parameter is [Register no (S7-S0)] */ -USHORT -SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +void +SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) { - if (SiS_Pr->SiS_IF_DEF_CH70xx == 1) - return(SiS_GetCH700x(SiS_Pr,tempbx)); + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) + SiS_SetCH700x(SiS_Pr,tempbx); else - return(SiS_GetCH701x(SiS_Pr,tempbx)); + SiS_SetCH701x(SiS_Pr,tempbx); } -/* TW: Read from Chrontel 700x */ +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 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_DataShift = 0x00; + SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ if(!(SiS_Pr->SiS_ChrontelInit)) { - SiS_Pr->SiS_DDC_Index = 0x11; /* TW: Bit 0 = SC; Bit 1 = SD */ + SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ - SiS_Pr->SiS_DDC_DataShift = 0x00; - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB */ } SiS_Pr->SiS_DDC_ReadAddr = tempbx; - for(i=0;i<20;i++) { /* TW: Do only 20 attempts to read */ - /* SiS_SetSwitchDDC2(SiS_Pr); */ - if(SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = SiS_Pr->SiS_DDC_ReadAddr | 0x80; /* TW: Write RAB | 0x80 */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* TW: (ERROR: no ack) */ - if (SiS_SetStart(SiS_Pr)) continue; /* TW: Re-start */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01; /* DAB | 0x01 = Read */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: DAB (S0=1=read) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* TW: Read byte */ - if (SiS_SetStop(SiS_Pr)) continue; /* TW: Stop condition */ - SiS_Pr->SiS_ChrontelInit = 1; - return(tempah); - } - - /* TW: For 630ST */ - if(!SiS_Pr->SiS_ChrontelInit) { - SiS_Pr->SiS_DDC_Index = 0x0a; /* TW: Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x80; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x40; /* Bitmask in IndexReg for Clk */ - SiS_Pr->SiS_DDC_DataShift = 0x00; - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB (Device Address Byte) */ - - for(i=0;i<20;i++) { /* TW: Do only 20 attempts to read */ - /* SiS_SetSwitchDDC2(SiS_Pr); */ - if(SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = SiS_Pr->SiS_DDC_ReadAddr | 0x80; /* TW: Write RAB | 0x80 */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* TW: (ERROR: no ack) */ - if (SiS_SetStart(SiS_Pr)) continue; /* TW: Re-start */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01; /* DAB | 0x01 = Read */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: DAB (S0=1=read) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* TW: Read byte */ - if (SiS_SetStop(SiS_Pr)) continue; /* TW: Stop condition */ - SiS_Pr->SiS_ChrontelInit = 1; - return(tempah); - } - } - return(0xFFFF); -} - -/* TW: Read from Chrontel 701x */ + 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; + + result = SiS_GetChReg(SiS_Pr,0x80); + } + return(result); +} + +/* Read from Chrontel 701x */ /* Parameter is [Register no (S7-S0)] */ USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx) { - USHORT tempah,temp,i; - - SiS_Pr->SiS_DDC_Index = 0x11; /* TW: Bit 0 = SC; Bit 1 = SD */ + SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ SiS_Pr->SiS_DDC_DataShift = 0x00; - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB */ + SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ + SiS_Pr->SiS_DDC_ReadAddr = tempbx; - for(i=0;i<20;i++) { /* TW: Do only 20 attempts to read */ - if(SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = SiS_Pr->SiS_DDC_ReadAddr; /* TW: Write RAB */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* TW: (ERROR: no ack) */ - if (SiS_SetStart(SiS_Pr)) continue; /* TW: Re-start */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01; /* DAB | 0x01 = Read */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: DAB (S0=1=read) */ - if(temp) continue; /* TW: (ERROR: no ack) */ - tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* TW: Read byte */ - SiS_SetStop(SiS_Pr); /* TW: Stop condition */ - return(tempah); - } - return 0xFFFF; + return(SiS_GetChReg(SiS_Pr,0)); } -#ifdef LINUX_XF86 -/* TW: Our own DDC functions */ +/* Read from Chrontel 70xx */ +/* Parameter is [Register no (S7-S0)] */ +USHORT +SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +{ + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) + return(SiS_GetCH700x(SiS_Pr, tempbx)); + else + return(SiS_GetCH701x(SiS_Pr, tempbx)); +} + +/* Our own DDC functions */ USHORT -SiS_InitDDCRegs(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, USHORT DDCdatatype) +SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, + USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32) { - unsigned char ddcdtype[] = { 0xa0, 0xa0, 0xa0, 0xa2, 0xa6}; + unsigned char ddcdtype[] = { 0xa0, 0xa0, 0xa0, 0xa2, 0xa6 }; unsigned char flag, cr32; USHORT temp = 0, myadaptnum = adaptnum; + if(adaptnum != 0) { + if(!(VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0xFFFF; + if((VBFlags & VB_30xBDH) && (adaptnum == 1)) return 0xFFFF; + } + + /* adapternum for SiS bridges: 0 = CRT1, 1 = LCD, 2 = VGA2 */ + SiS_Pr->SiS_ChrontelInit = 0; /* force re-detection! */ SiS_Pr->SiS_DDC_SecAddr = 0; @@ -9199,63 +9719,53 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, USHORT DDCdat SiS_Pr->SiS_DDC_Index = 0x11; flag = 0xff; - cr32 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x32); - - if(pSiS->VGAEngine == SIS_300_VGA) { /* 300 series */ + cr32 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x32); - if(pSiS->VBFlags & VB_SISBRIDGE) { - if(myadaptnum == 0) { - if(!(cr32 & 0x20)) { - myadaptnum = 2; - if(!(cr32 & 0x10)) { - myadaptnum = 1; - if(!(cr32 & 0x08)) { - myadaptnum = 0; - } +#if 0 + if(VBFlags & VB_SISBRIDGE) { + if(myadaptnum == 0) { + if(!(cr32 & 0x20)) { + myadaptnum = 2; + if(!(cr32 & 0x10)) { + myadaptnum = 1; + if(!(cr32 & 0x08)) { + myadaptnum = 0; } - } + } } - } + } + } +#endif + if(VGAEngine == SIS_300_VGA) { /* 300 series */ + if(myadaptnum != 0) { flag = 0; - if(pSiS->VBFlags & VB_SISBRIDGE) { + if(VBFlags & VB_SISBRIDGE) { SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port; SiS_Pr->SiS_DDC_Index = 0x0f; } } - if(cr32 & 0x80) { - if(myadaptnum >= 1) { - if(!(cr32 & 0x08)) { - myadaptnum = 1; - if(!(cr32 & 0x10)) return 0xFFFF; - } + if(!(VBFlags & VB_301)) { + if((cr32 & 0x80) && (checkcr32)) { + if(myadaptnum >= 1) { + if(!(cr32 & 0x08)) { + myadaptnum = 1; + if(!(cr32 & 0x10)) return 0xFFFF; + } + } } } temp = 4 - (myadaptnum * 2); if(flag) temp = 0; - SiS_Pr->SiS_DDC_Data = 0x02 << temp; - SiS_Pr->SiS_DDC_Clk = 0x01 << temp; + } else { /* 315/330 series */ - } else { /* 310/325 series */ + /* here we simplify: 0 = CRT1, 1 = CRT2 (VGA, LCD) */ - if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) myadaptnum = 0; - - if(pSiS->VBFlags & VB_SISBRIDGE) { - if(myadaptnum == 0) { - if(!(cr32 & 0x20)) { - myadaptnum = 2; - if(!(cr32 & 0x10)) { - myadaptnum = 1; - if(!(cr32 & 0x08)) { - myadaptnum = 0; - } - } - } - } + if(VBFlags & VB_SISBRIDGE) { if(myadaptnum == 2) { myadaptnum = 1; } @@ -9263,13 +9773,13 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, USHORT DDCdat if(myadaptnum == 1) { flag = 0; - if(pSiS->VBFlags & VB_SISBRIDGE) { + if(VBFlags & VB_SISBRIDGE) { SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port; SiS_Pr->SiS_DDC_Index = 0x0f; } } - if(cr32 & 0x80) { + if((cr32 & 0x80) && (checkcr32)) { if(myadaptnum >= 1) { if(!(cr32 & 0x08)) { myadaptnum = 1; @@ -9281,32 +9791,43 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, USHORT DDCdat temp = myadaptnum; if(myadaptnum == 1) { temp = 0; - if(pSiS->VBFlags & VB_LVDS) flag = 0xff; + if(VBFlags & VB_LVDS) flag = 0xff; } if(flag) temp = 0; - - SiS_Pr->SiS_DDC_Data = 0x02 << temp; - SiS_Pr->SiS_DDC_Clk = 0x01 << temp; - } + + SiS_Pr->SiS_DDC_Data = 0x02 << temp; + SiS_Pr->SiS_DDC_Clk = 0x01 << temp; + +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "DDC Port %x Index %x Shift %d\n", + SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index, temp); +#endif + return 0; } USHORT SiS_WriteDABDDC(SiS_Private *SiS_Pr) { - SiS_SetStart(SiS_Pr); - if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr)) return 0xFFFF; - if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_SecAddr)) return 0xFFFF; + if(SiS_SetStart(SiS_Pr)) return 0xFFFF; + if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr)) { + return 0xFFFF; + } + if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_SecAddr)) { + return 0xFFFF; + } return(0); } USHORT SiS_PrepareReadDDC(SiS_Private *SiS_Pr) { - SiS_SetStart(SiS_Pr); - if(SiS_WriteDDC2Data(SiS_Pr, (SiS_Pr->SiS_DDC_DeviceAddr | 0x01))) return 0xFFFF; + if(SiS_SetStart(SiS_Pr)) return 0xFFFF; + if(SiS_WriteDDC2Data(SiS_Pr, (SiS_Pr->SiS_DDC_DeviceAddr | 0x01))) { + return 0xFFFF; + } return(0); } @@ -9336,11 +9857,15 @@ USHORT SiS_DoProbeDDC(SiS_Private *SiS_Pr) { unsigned char mask, value; - USHORT temp, ret; + USHORT temp, ret=0; + BOOLEAN failed = FALSE; 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; @@ -9351,16 +9876,27 @@ SiS_DoProbeDDC(SiS_Private *SiS_Pr) if(temp == 0) { mask = 0xff; value = 0xff; + } else { + failed = TRUE; + ret = 0xFFFF; +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "Probe: Read 1 failed\n"); +#endif } } - temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); - SiS_SendACK(SiS_Pr, 1); - temp &= mask; - if(temp == value) ret = 0; - else { - ret = 0xFFFF; - if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { - if(value == 0x30) ret = 0; + if(failed == FALSE) { + temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); + SiS_SendACK(SiS_Pr, 1); + temp &= mask; + 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; + } } } SiS_SetStop(SiS_Pr); @@ -9384,12 +9920,12 @@ SiS_ProbeDDC(SiS_Private *SiS_Pr) } USHORT -SiS_ReadDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT DDCdatatype, unsigned char *buffer) +SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer) { USHORT flag, length, i; unsigned char chksum,gotcha; - if(DDCdatatype > 3) return 0xFFFF; /* incomplete! */ + if(DDCdatatype > 4) return 0xFFFF; flag = 0; SiS_SetSwitchDDC2(SiS_Pr); @@ -9416,28 +9952,7 @@ SiS_ReadDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT DDCdatatype, unsigned char return(flag); } -USHORT -SiS_ReadLCDDDC(SiS_Private *SiS_Pr, USHORT length, unsigned char *buffer) -{ - USHORT i=0, flag=0; - - length--; - - SiS_SetSwitchDDC2(SiS_Pr); - if(!(SiS_PrepareDDC(SiS_Pr))) { - for(i=0; i<length; i++) { - buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); - SiS_SendACK(SiS_Pr, 0); - } - buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); - SiS_SendACK(SiS_Pr, 1); - } else flag = 0xFFFF; - - SiS_SetStop(SiS_Pr); - return(0); -} - -/* TW: Our private DDC function +/* Our private DDC functions It complies somewhat with the corresponding VESA function in arguments and return values. @@ -9447,9 +9962,9 @@ SiS_ReadLCDDDC(SiS_Private *SiS_Pr, USHORT length, unsigned char *buffer) regards chipset and video bridge type. Arguments: - adaptnum: 0=CRT1, 1=CRT2 - CRT2 DDC is not supported in some cases. - DDCdatatype: 0=Probe, 1=EDID, 2=VDIF(not supported), 3=?, 4=?(not supported) + adaptnum: 0=CRT1, 1=LCD, 2=VGA2 + CRT2 DDC is only supported on SiS301, 301B, 302B. + DDCdatatype: 0=Probe, 1=EDID, 2=EDID+VDIF, 3=EDID V2 (P&D), 4=EDID V2 (FPDI-2) buffer: ptr to 256 data bytes which will be filled with read data. Returns 0xFFFF if error, otherwise @@ -9458,297 +9973,825 @@ SiS_ReadLCDDDC(SiS_Private *SiS_Pr, USHORT length, unsigned char *buffer) */ USHORT -SiS_HandleDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, - USHORT DDCdatatype, unsigned char *buffer) +SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, + USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer) { - if(DDCdatatype == 2) return 0xFFFF; + unsigned char sr1f,cr17=1; + USHORT result; + if(adaptnum > 2) return 0xFFFF; - if(pSiS->VGAEngine == SIS_300_VGA) { - if((adaptnum != 0) && (DDCdatatype != 0)) return 0xFFFF; + if(DDCdatatype > 4) return 0xFFFF; + if((!(VBFlags & VB_VIDEOBRIDGE)) && (adaptnum > 0)) return 0xFFFF; + if(SiS_InitDDCRegs(SiS_Pr, VBFlags, VGAEngine, adaptnum, DDCdatatype, FALSE) == 0xFFFF) return 0xFFFF; + + sr1f = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f); + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1f,0x3f,0x04); + if(VGAEngine == SIS_300_VGA) { + cr17 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80; + if(!cr17) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x17,0x80); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x01); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x03); + } + } + if((sr1f) || (!cr17)) { + SiS_WaitRetrace1(SiS_Pr); + SiS_WaitRetrace1(SiS_Pr); + SiS_WaitRetrace1(SiS_Pr); + SiS_WaitRetrace1(SiS_Pr); } - if((!(pSiS->VBFlags & VB_VIDEOBRIDGE)) && (adaptnum > 0)) return 0xFFFF; - if(SiS_InitDDCRegs(SiS_Pr, pSiS, adaptnum, DDCdatatype) == 0xFFFF) return 0xFFFF; + if(DDCdatatype == 0) { - return(SiS_ProbeDDC(SiS_Pr)); + result = SiS_ProbeDDC(SiS_Pr); } else { - if(DDCdatatype > 4) return 0xFFFF; - return(SiS_ReadDDC(SiS_Pr, pSiS, DDCdatatype, buffer)); + result = SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer); } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x1f,sr1f); + if(VGAEngine == SIS_300_VGA) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x17,0x7f,cr17); + } + return result; +} + +#ifdef LINUX_XF86 + +static BOOLEAN +checkedid1(unsigned char *buffer) +{ + /* Check header */ + if((buffer[0] != 0x00) || + (buffer[1] != 0xff) || + (buffer[2] != 0xff) || + (buffer[3] != 0xff) || + (buffer[4] != 0xff) || + (buffer[5] != 0xff) || + (buffer[6] != 0xff) || + (buffer[7] != 0x00)) + return FALSE; + + /* Check EDID version and revision */ + if((buffer[0x12] != 1) || (buffer[0x13] > 4)) return FALSE; + + /* Check week of manufacture for sanity */ + if(buffer[0x10] > 53) return FALSE; + + /* Check year of manufacture for sanity */ + if(buffer[0x11] > 40) return FALSE; + + return TRUE; } -#if 0 /* for future use */ +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 -SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS, unsigned char *buffer) -{ - USHORT flag, temp; - unsigned char buffer[8]; - unsigned char cr36=0, cr37=0; - unsigned chat tempal, tempah, tempbl, tempbh; - USHORT tempax, tempbx tempcx, push1, push2, push3; - unsigned char addresstable[] = { 0x00, 0x22, 0x30, 0x40 }; +SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) +{ + USHORT DDCdatatype, paneltype, flag, xres=0, yres=0; + USHORT index, myindex, lumsize, numcodes; + unsigned char cr37=0, seekcode; + BOOLEAN checkexpand = FALSE; + int retry, i; + unsigned char buffer[256]; + + for(i=0; i<7; i++) SiS_Pr->CP_DataValid[i] = FALSE; + SiS_Pr->CP_HaveCustomData = FALSE; + SiS_Pr->CP_MaxX = SiS_Pr->CP_MaxY = SiS_Pr->CP_MaxClock = 0; + + if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; + if(pSiS->VBFlags & VB_30xBDH) return 0; + + if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 1, 0, FALSE) == 0xFFFF) return 0; - if(SiS_InitDDCRegs(SiS_Pr, pSiS, 1, 0) == 0xFFFF) return 0xFFFF; - flag = SiS_ProbeDDC(SiS_Pr); + SiS_Pr->SiS_DDC_SecAddr = 0x00; - if(flag & 0x02) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; - SiS_Pr->SiS_DDC_SecAddr = 0x3a; + /* Probe supported DA's */ + flag = SiS_ProbeDDC(SiS_Pr); +#ifdef TWDEBUG + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, + "CRT2 DDC capabilities 0x%x\n", flag); +#endif + if(flag & 0x10) { + SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; /* EDID V2 (FP) */ + DDCdatatype = 4; } else if(flag & 0x08) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; - SiS_Pr->SiS_DDC_SecAddr = 0x76; - } else if(flag & 0x10) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; - SiS_Pr->SiS_DDC_SecAddr = 0x76; - } else return 0xFFFF; + SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; /* EDID V2 (P&D-D Monitor) */ + DDCdatatype = 3; + } else if(flag & 0x02) { + SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */ + DDCdatatype = 1; + } else return 0; /* no DDC support (or no device attached) */ - SiS_ReadLCDDDC(SiS_Pr, 4, buffer); - tempbl = buffer[0]; - tempbh = buffer[1]; - if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { - tempah = 0x02; - tempbl &= 0xf0; - if(tempbl != 0x40) { - tempah = 0x03; - if(tempbl == 0x50) { - if(!tempbh) { - tempbh = buffer[3] & 0xf0; - if(tempbh == 0x30) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; - SiS_Pr->SiS_DDC_SecAddr = 0x23; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempbl = buffer[0]; - tempbh = buffer[1]; - if(tempbl) cr37 |= 0x10; - tempah = 0x0a; - } - if(tempbh == 0x40) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; - SiS_Pr->SiS_DDC_SecAddr = 0x23; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempbl = buffer[0]; - tempbh = buffer[1]; - if(tempbl) cr37 |= 0x10; - tempah = 0x03; + /* Read the entire EDID */ + retry = 2; + do { + if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: DDC read failed (attempt %d), %s\n", + (3-retry), (retry == 1) ? "giving up" : "retrying"); + retry--; + if(retry == 0) return 0xFFFF; + } else break; + } while(1); + +#ifdef TWDEBUG + for(i=0; i<256; i+=16) { + 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], + buffer[i+8], buffer[i+9], buffer[i+10], buffer[i+11], + buffer[i+12], buffer[i+13], buffer[i+14], buffer[i+15]); + } +#endif + + /* Analyze EDID and retrieve LCD panel information */ + paneltype = 0; + 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, + "CRT2: Attached display expects analog input (0x%02x)\n", + buffer[0x14]); + return 0; + } + + if((buffer[0x18] & 0x18) != 0x08) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: Attached display is not of RGB but of %s type (0x%02x)\n", + ((buffer[0x18] & 0x18) == 0x00) ? "monochrome/greyscale" : + ( ((buffer[0x18] & 0x18) == 0x10) ? "non-RGB multicolor" : + "undefined"), + buffer[0x18]); + return 0; + } + + /* Now analyze the first Detailed Timing Block and see + * if the preferred timing mode is stored there. If so, + * check if this is a standard panel for which we already + * know the timing. + */ + + paneltype = Panel_Custom; + checkexpand = FALSE; + + if(buffer[0x18] & 0x02) { + + xres = buffer[0x38] | ((buffer[0x3a] & 0xf0) << 4); + yres = buffer[0x3b] | ((buffer[0x3d] & 0xf0) << 4); + + SiS_Pr->CP_PreferredX = xres; + SiS_Pr->CP_PreferredY = yres; + + switch(xres) { + case 800: + if(yres == 600) { + paneltype = Panel_800x600; + checkexpand = TRUE; + } + break; + case 1024: + if(yres == 768) { + paneltype = Panel_1024x768; + checkexpand = TRUE; + } + break; + case 1280: + if(yres == 1024) { + paneltype = Panel_1280x1024; + checkexpand = TRUE; + } else if(yres == 960) { + if(pSiS->VGAEngine == SIS_300_VGA) { + paneltype = Panel300_1280x960; + } else { + paneltype = Panel310_1280x960; + } + } else if(yres == 768) { + paneltype = Panel_1280x768; + checkexpand = FALSE; + cr37 |= 0x10; + } + break; + case 1400: + if(pSiS->VGAEngine == SIS_315_VGA) { + if(yres == 1050) { + paneltype = Panel310_1400x1050; + checkexpand = TRUE; + } + } + break; +#if 0 /* Treat this as custom, as we have no valid timing data yet */ + case 1600: + if(pSiS->VGAEngine == SIS_315_VGA) { + if(yres == 1200) { + paneltype = Panel310_1600x1200; + checkexpand = TRUE; + } + } + break; +#endif + } + + if(paneltype != Panel_Custom) { + if((buffer[0x47] & 0x18) == 0x18) { + cr37 |= ((((buffer[0x47] & 0x06) ^ 0x06) << 5) | 0x20); + } else { + /* What now? There is no digital separate output timing... */ + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, + "CRT2: Unable to retrieve Sync polarity information\n"); + } + } + + } + + /* If we still don't know what panel this is, we take it + * as a custom panel and derive the timing data from the + * detailed timing blocks + */ + if(paneltype == Panel_Custom) { + + BOOLEAN havesync = FALSE; + int i, temp, base = 0x36; + unsigned long estpack; + unsigned short estx[] = { + 720, 720, 640, 640, 640, 640, 800, 800, + 800, 800, 832,1024,1024,1024,1024,1280, + 1152 + }; + unsigned short esty[] = { + 400, 400, 480, 480, 480, 480, 600, 600, + 600, 600, 624, 768, 768, 768, 768,1024, + 870 + }; + + paneltype = 0; + + /* Find the maximum resolution */ + + /* 1. From Established timings */ + estpack = (buffer[0x23] << 9) | (buffer[0x24] << 1) | ((buffer[0x25] >> 7) & 0x01); + for(i=16; i>=0; i--) { + if(estpack & (1 << i)) { + if(estx[16 - i] > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = estx[16 - i]; + if(esty[16 - i] > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = esty[16 - i]; + } + } + + /* 2. From Standard Timings */ + for(i=0x26; i < 0x36; i+=2) { + if((buffer[i] != 0x01) && (buffer[i+1] != 0x01)) { + temp = (buffer[i] + 31) * 8; + if(temp > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = temp; + switch((buffer[i+1] & 0xc0) >> 6) { + case 0x03: temp = temp * 9 / 16; break; + case 0x02: temp = temp * 4 / 5; break; + case 0x01: temp = temp * 3 / 4; break; } - tempbh = 0x00; + if(temp > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = temp; } } - if(tempbh == 0x00) goto cr36ready; - tempah = 0x07; - if(tempbh == 0xc0) goto cr36ready; + + /* Now extract the Detailed Timings and convert them into modes */ + + for(i = 0; i < 4; i++, base += 18) { + + /* Is this a detailed timing block or a monitor descriptor? */ + if(buffer[base] || buffer[base+1] || buffer[base+2]) { + + xres = buffer[base+2] | ((buffer[base+4] & 0xf0) << 4); + yres = buffer[base+5] | ((buffer[base+7] & 0xf0) << 4); + + SiS_Pr->CP_HDisplay[i] = xres; + SiS_Pr->CP_HSyncStart[i] = xres + (buffer[base+8] | ((buffer[base+11] & 0xc0) << 2)); + SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[base+9] | ((buffer[base+11] & 0x30) << 4)); + SiS_Pr->CP_HTotal[i] = xres + (buffer[base+3] | ((buffer[base+4] & 0x0f) << 8)); + SiS_Pr->CP_HBlankStart[i] = xres + 1; + SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i]; + + SiS_Pr->CP_VDisplay[i] = yres; + SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[base+10] & 0xf0) >> 4) | ((buffer[base+11] & 0x0c) << 2)); + SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[base+10] & 0x0f) | ((buffer[base+11] & 0x03) << 4)); + SiS_Pr->CP_VTotal[i] = yres + (buffer[base+6] | ((buffer[base+7] & 0x0f) << 8)); + SiS_Pr->CP_VBlankStart[i] = yres + 1; + SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i]; + + SiS_Pr->CP_Clock[i] = (buffer[base] | (buffer[base+1] << 8)) * 10; + + SiS_Pr->CP_DataValid[i] = TRUE; + + /* Sort out invalid timings, interlace and too high clocks */ + if((SiS_Pr->CP_HDisplay[i] > 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] > 108500))) || + (buffer[base+17] & 0x80)) { + + SiS_Pr->CP_DataValid[i] = FALSE; + + } else { + + paneltype = Panel_Custom; + + SiS_Pr->CP_HaveCustomData = TRUE; + + if(xres > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = xres; + if(yres > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = yres; + if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i]; + + SiS_Pr->CP_Vendor = buffer[9] | (buffer[8] << 8); + SiS_Pr->CP_Product = buffer[10] | (buffer[11] << 8); + + /* We must assume the panel can scale, since we have + * no scaling data + */ + checkexpand = FALSE; + cr37 |= 0x10; + + /* Extract the sync polarisation information. This only works + * if the Flags indicate a digital separate output. + */ + if((buffer[base+17] & 0x18) == 0x18) { + SiS_Pr->CP_HSync_P[i] = (buffer[base+17] & 0x02) ? TRUE : FALSE; + SiS_Pr->CP_VSync_P[i] = (buffer[base+17] & 0x04) ? TRUE : FALSE; + SiS_Pr->CP_SyncValid[i] = TRUE; + if(!havesync) { + cr37 |= ((((buffer[base+17] & 0x06) ^ 0x06) << 5) | 0x20); + havesync = TRUE; + } + } else { + SiS_Pr->CP_SyncValid[i] = FALSE; + } + } + } + } + if(!havesync) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, + "CRT2: Unable to retrieve Sync polarity information\n"); + } } - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; - SiS_Pr->SiS_DDC_SecAddr = 0x18; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempbl = buffer[0]; - tempbh = buffer[1]; - if(tempbl & 0x02) goto cr36ready; - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; - SiS_Pr->SiS_DDC_SecAddr = 0x23; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempbl = buffer[0]; - tempbh = buffer[1]; - tempah = 0x03; - if(!tempbh & 0x01)) tempah = 0x02; - if(!tempbl) cr37 |= 0x10; - - } else { - - tempah = 0x02; - tempbx = tempbl | (tempbh << 8); - if(tempbx != 1024) tempah = 0x03; - - } -cr36ready: - cr36 = tempah; - - if((SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { - - SiS_Pr->SiS_DDC_SecAddr = 0x47; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempah = buffer[0]; - tempah &= 0x06; - tempah ^= 0x06; - tempah <<= 5; - tempah |= 0x20; - cr37 &= 0x1f; - cr37 |= tempah; - if((cr36 & 0x07) == 0x07) cr37 &= 0x0e; - - } else { - - push1 = tempah; - SiS_Pr->SiS_DDC_SecAddr = 0x45; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempah = 0x01; - if((buffer[0] != 0x20) && (buffer[0] != 0x34)) { - tempah = 0x00; - } - cr37 &= 0xfe; - cr37 |= tempah; - - SiS_Pr->SiS_DDC_SecAddr = 0x7e; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempax = (USHORT)(buffer[0] | (buffer[1] << 8)); - push2 = tempax; - tempax &= 0x0003; - tempax *= 0x1b; - push3 = tempax; - tempax = (USHORT)buffer[0]; - tempax &= 0x001c; - tempax >>= 2; - tempax *= 8; - tempbx = push3; - tempbx += tempax; - if(buffer[0] & 0x20) { - SiS_Pr->SiS_DDC_SecAddr = 0x80; - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempax = buffer[0] | (buffer[1] << 8); - tempax &= 0x1f; - if(buffer[0] & 0x70) tempax <<= 1; - tempax++; - tempbx += tempax; - } - tempcx = push2; - tempax = push1 << 8; - tempbx = (tempbx & 0xff00) | (((tempbx & 0x00ff) + 0x80) & 0x00ff); - if(tempcx & 0xf800) { - tempal = addresstable[((tempax & 0xff00) >> 8)]; - tempcx &= 0xf8ff; - tempcx >>= 11; - for(i=0; i<tempcx; i++) { - SiS_Pr->SiS_DDC_SecAddr = (tempbx & 0x00ff); - SiS_ReadLCDDDC(SiS_Pr, 2, buffer); - tempbx += 0x04; - if(buffer[0] == tempal) break; - } - tempah = buffer[1]; - tempah &= 0x0c; - tempah ^= 0x0c; - tempah <<= 4; - tempah |= 0x20; - cr37 &= 0x1f; - cr37 |= tempah; - if((cr36 & 0x07) == 0x07) cr37 &= 0x0e; - } - } - xf86DrvMsg(0, X_INFO, "DDC: cr36 = 0x%02x, cr37 = 0x%02x\n", cr36, cr37); + if(paneltype && checkexpand) { + /* If any of the Established low-res modes is supported, the + * panel can scale automatically. For 800x600 panels, we only + * check the even lower ones. + */ + if(paneltype == Panel_800x600) { + if(buffer[0x23] & 0xfc) cr37 |= 0x10; + } else { + if(buffer[0x23]) cr37 |= 0x10; + } + } + + break; + + 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, + "CRT2: Display supports TMDS input on primary interface\n"); + } else if((buffer[0x41] & 0xf0) == 0x30) { + index = 0x46 + 3; + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: Display supports TMDS input on secondary interface\n"); + } else { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: Display does not support TMDS video interface (0x%02x)\n", + buffer[0x41]); + return 0; + } + paneltype = Panel_Custom; + SiS_Pr->CP_MaxX = xres = buffer[0x76] | (buffer[0x77] << 8); + SiS_Pr->CP_MaxY = yres = buffer[0x78] | (buffer[0x79] << 8); + switch(xres) { + case 800: + if(yres == 600) { + paneltype = Panel_800x600; + checkexpand = TRUE; + } + break; + 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) { + paneltype = Panel310_1280x960; + } else { + paneltype = Panel300_1280x960; + } + } else if(yres == 1024) { + paneltype = Panel_1280x1024; + checkexpand = TRUE; + } else if(yres == 768) { + paneltype = Panel_1280x768; + checkexpand = FALSE; + cr37 |= 0x10; + } + break; + case 1400: + if(pSiS->VGAEngine == SIS_315_VGA) { + if(yres == 1050) { + paneltype = Panel310_1400x1050; + checkexpand = TRUE; + } + } + break; +#if 0 /* Treat this one as custom since we have no timing data yet */ + case 1600: + if(pSiS->VGAEngine == SIS_315_VGA) { + if(yres == 1200) { + paneltype = Panel310_1600x1200; + checkexpand = TRUE; + } + } + break; #endif + } -/* TW: Generic I2C functions (compliant to i2c library) */ + /* Determine if RGB18 or RGB24 */ + if(index) { + if((buffer[index] == 0x20) || (buffer[index] == 0x34)) { + cr37 |= 0x01; + } + } -#if 0 + if(checkexpand) { + /* TODO - for now, we let the panel scale */ + cr37 |= 0x10; + } + + /* Now seek 4-Byte Timing codes and extract sync pol info */ + index = 0x80; + if(buffer[0x7e] & 0x20) { /* skip Luminance Table (if provided) */ + lumsize = buffer[0x80] & 0x1f; + if(buffer[0x80] & 0x80) lumsize *= 3; + lumsize++; /* luminance header byte */ + index += lumsize; + } + index += (((buffer[0x7e] & 0x1c) >> 2) * 8); /* skip Frequency Ranges */ + index += ((buffer[0x7e] & 0x03) * 27); /* skip Detailed Range Limits */ + numcodes = (buffer[0x7f] & 0xf8) >> 3; + if(numcodes) { + myindex = index; + seekcode = (xres - 256) / 16; + for(i=0; i<numcodes; i++) { + if(buffer[myindex] == seekcode) break; + myindex += 4; + } + if(buffer[myindex] == seekcode) { + cr37 |= ((((buffer[myindex + 1] & 0x0c) ^ 0x0c) << 4) | 0x20); + } else { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, + "CRT2: Unable to retrieve Sync polarity information\n"); + } + } else { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, + "CRT2: Unable to retrieve Sync polarity information\n"); + } + + /* Now seek the detailed timing descriptions for custom panels */ + if(paneltype == Panel_Custom) { + index += (numcodes * 4); + numcodes = buffer[0x7f] & 0x07; + for(i=0; i<numcodes; i++, index += 18) { + xres = buffer[index+2] | ((buffer[index+4] & 0xf0) << 4); + yres = buffer[index+5] | ((buffer[index+7] & 0xf0) << 4); + + SiS_Pr->CP_HDisplay[i] = xres; + SiS_Pr->CP_HSyncStart[i] = xres + (buffer[index+8] | ((buffer[index+11] & 0xc0) << 2)); + SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[index+9] | ((buffer[index+11] & 0x30) << 4)); + SiS_Pr->CP_HTotal[i] = xres + (buffer[index+3] | ((buffer[index+4] & 0x0f) << 8)); + SiS_Pr->CP_HBlankStart[i] = xres + 1; + SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i]; + + SiS_Pr->CP_VDisplay[i] = yres; + SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[index+10] & 0xf0) >> 4) | ((buffer[index+11] & 0x0c) << 2)); + SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[index+10] & 0x0f) | ((buffer[index+11] & 0x03) << 4)); + SiS_Pr->CP_VTotal[i] = yres + (buffer[index+6] | ((buffer[index+7] & 0x0f) << 8)); + SiS_Pr->CP_VBlankStart[i] = yres + 1; + SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i]; + + SiS_Pr->CP_Clock[i] = (buffer[index] | (buffer[index+1] << 8)) * 10; + + SiS_Pr->CP_DataValid[i] = TRUE; + + if((SiS_Pr->CP_HDisplay[i] > 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] > 108500))) || + (buffer[index + 17] & 0x80)) { + + SiS_Pr->CP_DataValid[i] = FALSE; + + } else { + + SiS_Pr->CP_HaveCustomData = TRUE; + + if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i]; + + SiS_Pr->CP_HSync_P[i] = (buffer[index + 17] & 0x02) ? TRUE : FALSE; + SiS_Pr->CP_VSync_P[i] = (buffer[index + 17] & 0x04) ? TRUE : FALSE; + SiS_Pr->CP_SyncValid[i] = TRUE; + + SiS_Pr->CP_Vendor = buffer[2] | (buffer[1] << 8); + SiS_Pr->CP_Product = buffer[3] | (buffer[4] << 8); + + /* We must assume the panel can scale, since we have + * no scaling data + */ + cr37 |= 0x10; + + } + } + + } + + break; + + } + + /* 1280x960 panels are always RGB24, unable to scale and use + * high active sync polarity + */ + if(pSiS->VGAEngine == SIS_315_VGA) { + if(paneltype == Panel310_1280x960) cr37 &= 0x0e; + } else { + if(paneltype == Panel300_1280x960) cr37 &= 0x0e; + } + + for(i = 0; i < 7; i++) { + if(SiS_Pr->CP_DataValid[i]) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "Non-standard LCD timing data no. %d:\n", i); + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + " HDisplay %d HSync %d HSyncEnd %d HTotal %d\n", + SiS_Pr->CP_HDisplay[i], SiS_Pr->CP_HSyncStart[i], + SiS_Pr->CP_HSyncEnd[i], SiS_Pr->CP_HTotal[i]); + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + " VDisplay %d VSync %d VSyncEnd %d VTotal %d\n", + SiS_Pr->CP_VDisplay[i], SiS_Pr->CP_VSyncStart[i], + SiS_Pr->CP_VSyncEnd[i], SiS_Pr->CP_VTotal[i]); + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + " Pixel clock: %3.3fMhz\n", (float)SiS_Pr->CP_Clock[i] / 1000); + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, + " To use this, add \"%dx%d\" to the list of Modes in the Screen section\n", + SiS_Pr->CP_HDisplay[i], + SiS_Pr->CP_VDisplay[i]); + } + } + + if(paneltype) { + if(!SiS_Pr->CP_PreferredX) SiS_Pr->CP_PreferredX = SiS_Pr->CP_MaxX; + if(!SiS_Pr->CP_PreferredY) SiS_Pr->CP_PreferredY = SiS_Pr->CP_MaxY; + cr37 &= 0xf1; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x36,0xf0,paneltype); + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,0xf1,cr37); + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x08); +#ifdef TWDEBUG + xf86DrvMsgVerb(pSiS->pScrn->scrnIndex, X_PROBED, 3, + "CRT2: [DDC LCD results: 0x%02x, 0x%02x]\n", paneltype, cr37); +#endif + } + return 0; +} + USHORT -SiS_I2C_GetByte(SiS_Private *SiS_Pr) +SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS) { - return(SiS_ReadDDC2Data(SiS_Pr,0)); -} + USHORT DDCdatatype,flag; + BOOLEAN foundcrt = FALSE; + int retry; + unsigned char buffer[256]; -Bool -SiS_I2C_PutByte(SiS_Private *SiS_Pr, USHORT data) -{ - if(SiS_WriteDDC2Data(SiS_Pr,data)) return FALSE; - return TRUE; -} + if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; -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; -} + if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 2, 0, FALSE) == 0xFFFF) return 0; + + SiS_Pr->SiS_DDC_SecAddr = 0x00; + + /* Probe supported DA's */ + flag = SiS_ProbeDDC(SiS_Pr); + if(flag & 0x10) { + SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; /* EDID V2 (FP) */ + DDCdatatype = 4; + } else if(flag & 0x08) { + SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; /* EDID V2 (P&D-D Monitor) */ + DDCdatatype = 3; + } else if(flag & 0x02) { + SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */ + DDCdatatype = 1; + } else { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "Do DDC answer\n"); + return 0; /* no DDC support (or no device attached) */ + } -void -SiS_I2C_Stop(SiS_Private *SiS_Pr) -{ - SiS_SetStop(SiS_Pr); + /* Read the entire EDID */ + retry = 2; + do { + if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: DDC read failed (attempt %d), %s\n", + (3-retry), (retry == 1) ? "giving up" : "retrying"); + retry--; + if(retry == 0) return 0xFFFF; + } else break; + } while(1); + + /* Analyze EDID. We don't have many chances to + * distinguish a flat panel from a CRT... + */ + switch(DDCdatatype) { + case 1: + if(!(checkedid1(buffer))) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: EDID corrupt\n"); + return 0; + } + if(buffer[0x14] & 0x80) { /* Display uses digital input */ + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: Attached display expects digital input\n"); + return 0; + } + SiS_Pr->CP_Vendor = buffer[9] | (buffer[8] << 8); + SiS_Pr->CP_Product = buffer[10] | (buffer[11] << 8); + foundcrt = TRUE; + break; + case 3: + case 4: + if(!(checkedid2(buffer))) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: EDID corrupt\n"); + return 0; + } + if( ((buffer[0x41] & 0x0f) != 0x01) && /* Display does not support analog input */ + ((buffer[0x41] & 0x0f) != 0x02) && + ((buffer[0x41] & 0xf0) != 0x10) && + ((buffer[0x41] & 0xf0) != 0x20) ) { + xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, + "CRT2: Attached display does not support analog input (0x%02x)\n", + buffer[0x41]); + return 0; + } + SiS_Pr->CP_Vendor = buffer[2] | (buffer[1] << 8); + SiS_Pr->CP_Product = buffer[3] | (buffer[4] << 8); + foundcrt = TRUE; + break; + } + + if(foundcrt) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x10); + } + return(0); } -#endif #endif void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh) { - USHORT tempal,tempah,tempbl; + USHORT tempbl; - tempal = tempax & 0x00FF; - tempah =(tempax >> 8) & 0x00FF; - tempbl = SiS_GetCH70xx(SiS_Pr,tempal); - tempbl = (((tempbl & tempbh) | tempah) << 8 | tempal); + tempbl = SiS_GetCH70xx(SiS_Pr,(tempax & 0x00FF)); + tempbl = (((tempbl & tempbh) << 8) | tempax); SiS_SetCH70xx(SiS_Pr,tempbl); } -/* TW: Generic I2C functions for Chrontel --------- */ +/* Generic I2C functions for Chrontel & DDC --------- */ void SiS_SetSwitchDDC2(SiS_Private *SiS_Pr) { SiS_SetSCLKHigh(SiS_Pr); - /* SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAY); */ - SiS_WaitRetraceDDC(SiS_Pr); + SiS_WaitRetrace1(SiS_Pr); SiS_SetSCLKLow(SiS_Pr); - /* SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAY); */ - SiS_WaitRetraceDDC(SiS_Pr); + SiS_WaitRetrace1(SiS_Pr); +} + +USHORT +SiS_ReadDDC1Bit(SiS_Private *SiS_Pr) +{ + SiS_WaitRetrace1(SiS_Pr); + return((SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x02) >> 1); } -/* TW: Set I2C start condition */ -/* TW: This is done by a SD high-to-low transition while SC is high */ +/* Set I2C start condition */ +/* This is done by a SD high-to-low transition while SC is high */ USHORT SiS_SetStart(SiS_Private *SiS_Pr) { - if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* TW: (SC->low) */ + 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); /* TW: SD->high */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* TW: SC->high */ + ~SiS_Pr->SiS_DDC_Data,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); /* TW: SD->low = start condition */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* TW: (SC->low) */ + ~SiS_Pr->SiS_DDC_Data,0x00); /* SD->low = start condition */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->low) */ return 0; } -/* TW: Set I2C stop condition */ -/* TW: This is done by a SD low-to-high transition while SC is high */ +/* Set I2C stop condition */ +/* This is done by a SD low-to-high transition while SC is high */ USHORT SiS_SetStop(SiS_Private *SiS_Pr) { - if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* TW: (SC->low) */ + 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); /* TW: SD->low */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* TW: SC->high */ + ~SiS_Pr->SiS_DDC_Data,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); /* TW: SD->high = stop condition */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* TW: (SC->high) */ + ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* SD->high = stop condition */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->high) */ return 0; } -/* TW: Write 8 bits of data */ +/* Write 8 bits of data */ USHORT SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) { USHORT i,flag,temp; - flag=0x80; - for(i=0;i<8;i++) { - SiS_SetSCLKLow(SiS_Pr); /* TW: SC->low */ + flag = 0x80; + for(i=0; i<8; i++) { + SiS_SetSCLKLow(SiS_Pr); /* SC->low */ if(tempax & flag) { SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* TW: Write bit (1) to SD */ + ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* Write bit (1) to SD */ } else { SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, - ~SiS_Pr->SiS_DDC_Data,0x00); /* TW: Write bit (0) to SD */ + ~SiS_Pr->SiS_DDC_Data,0x00); /* Write bit (0) to SD */ } - SiS_SetSCLKHigh(SiS_Pr); /* TW: SC->high */ + SiS_SetSCLKHigh(SiS_Pr); /* SC->high */ flag >>= 1; } - temp = SiS_CheckACK(SiS_Pr); /* TW: Check acknowledge */ + temp = SiS_CheckACK(SiS_Pr); /* Check acknowledge */ return(temp); } @@ -9764,7 +10807,7 @@ SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, ~SiS_Pr->SiS_DDC_Data,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); @@ -9773,14 +10816,8 @@ SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) USHORT SiS_SetSCLKLow(SiS_Private *SiS_Pr) { - USHORT temp, watchdog=50000; - SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index, ~SiS_Pr->SiS_DDC_Clk,0x00); /* SetSCLKLow() */ - do { - temp = SiS_GetReg1(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); - } while((temp & SiS_Pr->SiS_DDC_Clk) && --watchdog); - if (!watchdog) return 0xFFFF; SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); return 0; } @@ -9788,53 +10825,129 @@ SiS_SetSCLKLow(SiS_Private *SiS_Pr) USHORT SiS_SetSCLKHigh(SiS_Private *SiS_Pr) { - USHORT temp,watchdog=50000; + 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() */ 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) return 0xFFFF; + if (!watchdog) { +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "SetClkHigh failed\n"); +#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; i<delaytime; i++) { - SiS_GetReg1(SiS_Pr->SiS_P3c4,0x05); - } -} - -/* TW: Check I2C acknowledge */ +/* Check I2C acknowledge */ /* Returns 0 if ack ok, non-0 if ack not ok */ USHORT SiS_CheckACK(SiS_Private *SiS_Pr) { USHORT tempah; - SiS_SetSCLKLow(SiS_Pr); /* TW: (SC->low) */ + SiS_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); /* TW: (SD->high) */ - SiS_SetSCLKHigh(SiS_Pr); /* TW: SC->high = clock impulse for ack */ - tempah = SiS_GetReg1(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);/* TW: Read SD */ - SiS_SetSCLKLow(SiS_Pr); /* TW: SC->low = end of clock impulse */ - if(tempah & SiS_Pr->SiS_DDC_Data) return(1); /* TW: Ack OK if bit = 0 */ + ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* (SD->high) */ + SiS_SetSCLKHigh(SiS_Pr); /* SC->high = clock impulse for ack */ + tempah = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);/* Read SD */ + SiS_SetSCLKLow(SiS_Pr); /* SC->low = end of clock impulse */ + if(tempah & SiS_Pr->SiS_DDC_Data) return(1); /* Ack OK if bit = 0 */ else return(0); } -/* TW: End of I2C functions ----------------------- */ +/* End of I2C functions ----------------------- */ -/* =============== SiS 310/325 O.E.M. ================= */ +/* =============== SiS 315/330 O.E.M. ================= */ #ifdef SIS315H static USHORT +GetRAMDACromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT romptr; + + if(HwInfo->jChipType < SIS_330) { + romptr = ROMAddr[0x128] | (ROMAddr[0x129] << 8); + if(SiS_Pr->SiS_VBType & VB_SIS301B302B) + romptr = ROMAddr[0x12a] | (ROMAddr[0x12b] << 8); + } else { + romptr = ROMAddr[0x1a8] | (ROMAddr[0x1a9] << 8); + if(SiS_Pr->SiS_VBType & VB_SIS301B302B) + romptr = ROMAddr[0x1aa] | (ROMAddr[0x1ab] << 8); + } + return(romptr); +} + +static USHORT +GetLCDromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT romptr; + + if(HwInfo->jChipType < SIS_330) { + romptr = ROMAddr[0x120] | (ROMAddr[0x121] << 8); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) + romptr = ROMAddr[0x122] | (ROMAddr[0x123] << 8); + } else { + romptr = ROMAddr[0x1a0] | (ROMAddr[0x1a1] << 8); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) + romptr = ROMAddr[0x1a2] | (ROMAddr[0x1a3] << 8); + } + return(romptr); +} + +static USHORT +GetTVromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT romptr; + + if(HwInfo->jChipType < SIS_330) { + romptr = ROMAddr[0x114] | (ROMAddr[0x115] << 8); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) + romptr = ROMAddr[0x11a] | (ROMAddr[0x11b] << 8); + } else { + romptr = ROMAddr[0x194] | (ROMAddr[0x195] << 8); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) + romptr = ROMAddr[0x19a] | (ROMAddr[0x19b] << 8); + } + return(romptr); +} + +static USHORT +GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + USHORT index; + + if((IS_SIS650) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { + if((index = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0)) { + index >>= 4; + index *= 3; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; + else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++; + return index; + } + } + } + + index = SiS_Pr->SiS_LCDResInfo & 0x0F; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) index -= 5; + else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) index -= 6; + index--; + index *= 3; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; + else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++; + return index; +} + +static USHORT GetLCDPtrIndex(SiS_Private *SiS_Pr) { USHORT index; @@ -9842,181 +10955,384 @@ GetLCDPtrIndex(SiS_Private *SiS_Pr) index = SiS_Pr->SiS_LCDResInfo & 0x0F; index--; index *= 3; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) index += 2; + 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_TVMode & TVSetPAL) index++; if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) index++; /* Hivision TV use PAL */ 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; } -/* TW: Checked against 650/LVDS (1.10.07) and 650/301LVx (1.10.6s) BIOS (including data) */ +static ULONG +GetOEMTVPtr661_2(SiS_Private *SiS_Pr) +{ + USHORT index = 0, temp = 0; + + if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1; + if(SiS_Pr->SiS_TVMode & TVSetPALM) index = 2; + if(SiS_Pr->SiS_TVMode & TVSetPALN) index = 3; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) index = 6; + if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { + index = 4; + if(SiS_Pr->SiS_TVMode & TVSetPALM) index++; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) index = 7; + } + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) { + index += 8; + temp++; + } + temp += 0x0100; + } + return(ULONG)(index | (temp << 16)); +} + +static int +GetOEMTVPtr661(SiS_Private *SiS_Pr) +{ + int index = 0; + + if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 2; +#if 0 + if(SiS_Pr->SiS_TVMode & 0x100?) index = 4; + if(SiS_Pr->SiS_TVMode & 0x20?) index = 6; + if(SiS_Pr->SiS_TVMode & 0x40?) index = 8; + if(SiS_Pr->SiS_TVMode & 0x80?) index = 10; +#endif + + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) index++; + + return index; +} + static void -SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr, USHORT ModeNo) +SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) { - USHORT delay,index,temp,romptr=0; + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT delay=0,index,myindex,temp,romptr=0; + BOOLEAN dochiptest = TRUE; + + /* Find delay (from ROM, internal tables, PCI subsystem) */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { /* ------------ VGA */ + if((ROMAddr) && SiS_Pr->SiS_UseROM) { - if(HwDeviceExtension->jChipType != SIS_330) { - romptr = ROMAddr[0x128] | (ROMAddr[0x129] << 8); /* 301, LVDS */ - if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) - romptr = ROMAddr[0x12a] | (ROMAddr[0x12b] << 8); - } else { - romptr = ROMAddr[0x1a8] | (ROMAddr[0x1a9] << 8); /* 301, LVDS */ - if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) - romptr = ROMAddr[0x1aa] | (ROMAddr[0x1ab] << 8); + romptr = GetRAMDACromptr(SiS_Pr, HwInfo); + if(!romptr) return; + 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(HwInfo->jChipType < SIS_330) { + delay = 0x0c; + } else { + delay = 0x0c; + } + } + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + delay = 0x00; } } - if(romptr) delay = ROMAddr[romptr]; - else { - delay = SiS310_CRT2DelayCompensation1; - if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) - delay = SiS310_CRT2DelayCompensation2; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) - delay = SiS310_CRT2DelayCompensation3; - } - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - index = GetLCDPtrIndex(SiS_Pr); - delay = SiS310_LCDDelayCompensation1[index]; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) - delay = SiS310_LCDDelayCompensation2[index]; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) - delay = SiS310_LCDDelayCompensation3[index]; - if((IS_SIS650740) && (SiS_Pr->SiS_IF_DEF_LVDS == 0)) { - if(SiS_IsM650or651(SiS_Pr,HwDeviceExtension, BaseAddr)) { - delay = SiS310_LCDDelayCompensation4[index]; /* 652c */ - if(SiS_Pr->SiS_VBType & VB_SIS30xNEW) - delay = SiS310_LCDDelayCompensation5[index]; /* 6541 */ - } else { - delay = SiS310_LCDDelayCompensation6[index]; /* 6550 */ - if(SiS_Pr->SiS_VBType & VB_SIS30xNEW) - delay = SiS310_LCDDelayCompensation7[index]; /* 655f */ - } + + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD|SetCRT2ToLCDA)) { /* ---------- LCD/LCDA */ + + BOOLEAN gotitfrompci = FALSE; + + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return; + + /* Could we detect a PDC for LCD? If yes, use it */ + + if(HwInfo->pdc) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,((HwInfo->pdc & 0x0f) << 4)); + } + return; } - } else { - index = GetTVPtrIndex(SiS_Pr); - if((ROMAddr) && SiS_Pr->SiS_UseROM) { - if(HwDeviceExtension->jChipType != SIS_330) { - romptr = ROMAddr[0x114] | (ROMAddr[0x115] << 8); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) - romptr = ROMAddr[0x11a] | (ROMAddr[0x11b] << 8); - } else { - romptr = ROMAddr[0x194] | (ROMAddr[0x195] << 8); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) - romptr = ROMAddr[0x19a] | (ROMAddr[0x19b] << 8); - } + + /* This is a piece of typical SiS crap: They code the OEM LCD + * delay into the code, at no defined place in the BIOS. + * We now have to start doing a PCI subsystem check here. + */ + + switch(SiS_Pr->SiS_CustomT) { + case CUT_COMPAQ1280: + case CUT_COMPAQ12802: + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + gotitfrompci = TRUE; + dochiptest = FALSE; + delay = 0x03; + } + break; + case CUT_CLEVO1400: + case CUT_CLEVO14002: + /* if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { */ + gotitfrompci = TRUE; + dochiptest = FALSE; + delay = 0x02; + /* } */ + break; + case CUT_CLEVO1024: + case CUT_CLEVO10242: + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + gotitfrompci = TRUE; + dochiptest = FALSE; + delay = 0x33; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2D,delay); + delay &= 0x0f; + } + break; } - if(romptr) delay = ROMAddr[romptr + index]; - else { - delay = SiS310_TVDelayCompensation1[index]; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) - delay = SiS310_TVDelayCompensation2[index]; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) - delay = SiS310_TVDelayCompensation3[index]; - } - if((IS_SIS650740) && (SiS_Pr->SiS_IF_DEF_LVDS == 0)) { - romptr = 0; - if(SiS_IsM650or651(SiS_Pr,HwDeviceExtension, BaseAddr)) { - if((ROMAddr) && SiS_Pr->SiS_UseROM) { - romptr = ROMAddr[0x114] | (ROMAddr[0x115] << 8); - if(SiS_Pr->SiS_VBType & VB_SIS30xNEW) - romptr = ROMAddr[0x11a] | (ROMAddr[0x11b] << 8); - } - if(romptr) delay = ROMAddr[romptr + index]; - else { - delay = SiS310_TVDelayCompensation4[index]; /* 656e @ 0x114 */ - if(SiS_Pr->SiS_VBType & VB_SIS30xNEW) - delay = SiS310_TVDelayCompensation5[index]; /* 6574 @ 0x11a */ - } - } else { - delay = SiS310_TVDelayCompensation6[index]; /* 657a */ - if(SiS_Pr->SiS_VBType & VB_SIS30xNEW) - delay = SiS310_TVDelayCompensation7[index]; /* 6580 */ - } + + /* Could we find it through the PCI ID? If no, use ROM or table */ + + if(!gotitfrompci) { + + index = GetLCDPtrIndexBIOS(SiS_Pr, HwInfo); + myindex = GetLCDPtrIndex(SiS_Pr); + + if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + + if(SiS_IsNotM650orLater(SiS_Pr, HwInfo)) { + + if((ROMAddr) && SiS_Pr->SiS_UseROM) { +#if 0 /* Always use the second pointer on 650; some BIOSes */ + /* still carry old 301 data at the first location */ + romptr = ROMAddr[0x120] | (ROMAddr[0x121] << 8); + if(SiS_Pr->SiS_VBType & VB_SIS302LV) +#endif + romptr = ROMAddr[0x122] | (ROMAddr[0x123] << 8); + if(!romptr) return; + delay = ROMAddr[(romptr + index)]; + } else { + delay = SiS310_LCDDelayCompensation_650301B[myindex]; +#if 0 + if(SiS_Pr->SiS_VBType & VB_SIS302LV) + delay = SiS310_LCDDelayCompensation_650301B[myindex]; +#endif + } + + } else { + + delay = SiS310_LCDDelayCompensation_651301LV[myindex]; + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) + delay = SiS310_LCDDelayCompensation_651302LV[myindex]; + + } + + } else if((ROMAddr) && SiS_Pr->SiS_UseROM && + (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024)) { + + romptr = GetLCDromptr(SiS_Pr, HwInfo); + if(!romptr) return; + delay = ROMAddr[(romptr + index)]; + + } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + + if(IS_SIS650) { + delay = SiS310_LCDDelayCompensation_LVDS650[myindex]; + } else { + delay = SiS310_LCDDelayCompensation_LVDS740[myindex]; + } + + } 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 + } + + } + + } /* got it from PCI */ + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,((delay << 4) & 0xf0)); + dochiptest = FALSE; } - } + + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* ------------ TV */ + + index = GetTVPtrIndex(SiS_Pr); + + if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + + if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) { + + 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 + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); - } else { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - delay <<= 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,delay); } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); + + switch(SiS_Pr->SiS_CustomT) { + case CUT_COMPAQ1280: + case CUT_COMPAQ12802: + case CUT_CLEVO1400: + case CUT_CLEVO14002: + delay = 0x02; + dochiptest = FALSE; + break; + case CUT_CLEVO1024: + case CUT_CLEVO10242: + delay = 0x03; + dochiptest = FALSE; + break; + default: + delay = SiS310_TVDelayCompensation_651301LV[index]; + if(SiS_Pr->SiS_VBType & VB_SIS302LV) { + delay = SiS310_TVDelayCompensation_651302LV[index]; + } + } } + + } else if((ROMAddr) && SiS_Pr->SiS_UseROM) { + + romptr = GetTVromptr(SiS_Pr, HwInfo); + if(!romptr) return; + delay = ROMAddr[romptr + index]; + + } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + + delay = SiS310_TVDelayCompensation_LVDS[index]; + + } else { + + 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]; + } + } + } - } else { - if((IS_SIS650740) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - temp = (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xf0) >> 4; - if(temp == 8) { + + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) { /* LCDA */ + delay &= 0x0f; + dochiptest = FALSE; + } + + } else return; + + /* Write delay */ + + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && dochiptest) { + + temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0) >> 4; + if(temp == 8) { /* 1400x1050 BIOS (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); /* index 2D D[3:0] */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2D,delay); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); + } + + } else { /* LVDS */ + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); + } else { + if(IS_SIS650 && (SiS_Pr->SiS_IF_DEF_CH70xx != 0)) { + delay <<= 4; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,delay); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); + } + } + } + } -/* TW: Checked against 650/301LVx 1.10.6s BIOS (including data) */ 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; - - temp = GetTVPtrIndex(SiS_Pr); - temp >>= 1; /* 0: NTSC, 1: PAL, 2: HiTV */ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT index,temp,temp1,romptr=0; if(ModeNo<=0x13) index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex; else index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex; + temp = GetTVPtrIndex(SiS_Pr); + temp >>= 1; /* 0: NTSC, 1: PAL, 2: HiTV */ + temp1 = temp; + if(ROMAddr && SiS_Pr->SiS_UseROM) { - romptr = ROMAddr[0x112] | (ROMAddr[0x113] << 8); - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_661) { + romptr = ROMAddr[0x260] | (ROMAddr[0x261] << 8); + temp1 = GetOEMTVPtr661(SiS_Pr); + temp1 >>= 1; + } else if(HwInfo->jChipType >= SIS_330) { romptr = ROMAddr[0x192] | (ROMAddr[0x193] << 8); + } else { + romptr = ROMAddr[0x112] | (ROMAddr[0x113] << 8); } } if(romptr) { - temp <<= 1; - temp = ROMAddr[romptr + temp + index]; + temp1 <<= 1; + temp = ROMAddr[romptr + temp1 + index]; } else { temp = SiS310_TVAntiFlick1[temp][index]; } @@ -10025,15 +11341,16 @@ SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0A,0x8f,temp); /* index 0A D[6:4] */ } -/* TW: Checked against 650/301LVx 1.10.6s BIOS (including data) */ 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 */ + temp1 = temp; if(ModeNo<=0x13) index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex; @@ -10041,15 +11358,20 @@ SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; if(ROMAddr && SiS_Pr->SiS_UseROM) { - romptr = ROMAddr[0x124] | (ROMAddr[0x125] << 8); - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_661) { + romptr = ROMAddr[0x26c] | (ROMAddr[0x26d] << 8); + temp1 = GetOEMTVPtr661(SiS_Pr); + temp1 >>= 1; + } else if(HwInfo->jChipType >= SIS_330) { romptr = ROMAddr[0x1a4] | (ROMAddr[0x1a5] << 8); + } else { + romptr = ROMAddr[0x124] | (ROMAddr[0x125] << 8); } } if(romptr) { - temp <<= 1; - temp = ROMAddr[romptr + temp + index]; + temp1 <<= 1; + temp = ROMAddr[romptr + temp1 + index]; } else { temp = SiS310_TVEdge1[temp][index]; } @@ -10057,97 +11379,125 @@ SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x3A,0x1F,temp); /* index 0A D[7:5] */ } -/* TW: Checked against 650/301LVx 1.10.6s BIOS (incl data) */ static void -SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { - USHORT index, temp, i, j; - UCHAR OutputSelect = *SiS_Pr->pSiS_OutputSelect; - - temp = GetTVPtrIndex(SiS_Pr); - temp >>= 1; /* 0: NTSC, 1: PAL, 2: HiTV */ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT index, myindex, oldindex,temp, i, j, flag1 = 0, flag2 = 0, romptr = 0; + ULONG lindex; - if (ModeNo<=0x13) { + if(ModeNo<=0x13) { index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex; } else { index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; } - if(SiS_Pr->SiS_VBInfo&SetCRT2ToHiVisionTV) temp = 1; /* Hivision TV uses PAL */ + oldindex = index; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); - } - for(i=0x48; i<=0x4A; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); - } - } else { - for(i=0x35, j=0; i<=0x38; i++, j++){ - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter1[temp][index][j]); - } - } + if((HwInfo->jChipType >= SIS_661) && ROMAddr && SiS_Pr->SiS_UseROM) { + if(ModeNo > 0x13) { + index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndexROM661; + } + lindex = GetOEMTVPtr661_2(SiS_Pr); + if(lindex & 0x00ff0000) flag1 = 1; + if(lindex & 0xff000000) flag2 = 1; + lindex &= 0xffff; - if(ROMAddr && SiS_Pr->SiS_UseROM) { - OutputSelect = ROMAddr[0xf3]; - if(HwDeviceExtension->jChipType == SIS_330) { - OutputSelect = ROMAddr[0x11b]; + /* NTSC-J: Use PAL filters */ + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) lindex = 1; + + romptr = ROMAddr[0x268] | (ROMAddr[0x269] << 8); + if(flag1) myindex = index * 7; + else myindex = index << 2; + + if(romptr) { + romptr += (lindex << 1); + romptr = (ROMAddr[romptr] | (ROMAddr[romptr+1] << 8)) + myindex; + if(romptr) { + if((!flag1) && (flag2)) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x35,0x00); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x36,0x00); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x37,0x00); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x38,ROMAddr[romptr++]); + } else { + for(i=0x35; i<=0x38; i++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr++]); + } + } + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + for(j=0, i=0x48; i<=0x4a; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr++]); + } + } + return; } + } } - if(OutputSelect & EnablePALMN) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) { - temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); - temp &= (EnablePALM | EnablePALN); - if(temp == EnablePALM) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALMFilter2[index][j]); - } - for(i=0x48; i<=0x4A; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALMFilter2[index][j]); - } - } else { - for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALMFilter[index][j]); - } - } - } - if(temp == EnablePALN) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALNFilter2[index][j]); - } - for(i=0x48, j=0; i<=0x4A; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALNFilter2[index][j]); - } - } else { - for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALNFilter[index][j]); - } - } - } - } + + index = oldindex; + + temp = GetTVPtrIndex(SiS_Pr); + temp >>= 1; /* 0: NTSC, 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 & SetCRT2ToHiVisionTV) temp = 1; /* Hivision TV uses PAL */ + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + for(i=0x35, j=0; i<=0x38; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); + } + for(i=0x48; i<=0x4A; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); + } + } else { + for(i=0x35, j=0; i<=0x38; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter1[temp][index][j]); + } } } -/* TW: Checked against 650/301LVx 1.10.6s BIOS (including data) */ 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 (ModeNo<=0x13) { - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + if(HwInfo->jChipType >= SIS_661) { + lindex = GetOEMTVPtr661_2(SiS_Pr) & 0xffff; + lindex <<= 2; + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + romptr = ROMAddr[0x264] | (ROMAddr[0x265] << 8); + } + if(romptr) { + romptr += lindex; + for(j=0, i=0x31; i<=0x34; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); + } + } else { + for(j=0, i=0x31; i<=0x34; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS661_TVPhase[lindex + j]); + } + } + return; + } + + /* PAL-M, PAL-N not in BIOS, and already set in SetGroup2 */ + if(SiS_Pr->SiS_TVMode & (TVSetPALM | TVSetPALN)) return; + + if(ModeNo<=0x13) { + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; } else { - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; } temp = GetTVPtrIndex(SiS_Pr); @@ -10156,17 +11506,17 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT B */ if((ROMAddr) && SiS_Pr->SiS_UseROM) { romptr = ROMAddr[0x116] | (ROMAddr[0x117] << 8); - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_330) { romptr = ROMAddr[0x196] | (ROMAddr[0x197] << 8); } if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { romptr = ROMAddr[0x11c] | (ROMAddr[0x11d] << 8); - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_330) { romptr = ROMAddr[0x19c] | (ROMAddr[0x19d] << 8); } - if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_SetFlag & TVSimuMode))) { + if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode))) { romptr = ROMAddr[0x116] | (ROMAddr[0x117] << 8); - if(HwDeviceExtension->jChipType == SIS_330) { + if(HwInfo->jChipType >= SIS_330) { romptr = ROMAddr[0x196] | (ROMAddr[0x197] << 8); } } @@ -10175,267 +11525,463 @@ 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) { /* TW: 650/301LV: (VB_SIS301LV | VB_SIS302LV)) */ - if((!(SiS_Pr->SiS_VBInfo & SetPALTV)) && (ModeNo > 0x13)) { - if(resinfo == 6) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x31,0x21); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x32,0xf0); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x33,0xf5); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x34,0x7f); - } else if (resinfo == 7) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x31,0x21); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x32,0xf0); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x33,0xf5); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x34,0x7f); - } else if (resinfo == 8) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x31,0x1e); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x32,0x8b); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x33,0xfb); - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x34,0x7b); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]); + } + } + + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if((!(SiS_Pr->SiS_TVMode & TVSetPAL)) && (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) -{ - SetDelayComp(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo); - /* TW: The TV functions are not for LVDS */ - if( (SiS_Pr->SiS_IF_DEF_LVDS == 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { - SetAntiFlicker(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - SetPhaseIncr(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - SetYFilter(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); +SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) +{ + SetDelayComp(SiS_Pr,HwInfo,ModeNo); + + if(SiS_Pr->UseCustomMode) return; + + if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { + SetAntiFlicker(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetPhaseIncr(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetYFilter(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - SetEdgeEnhance(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); + SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); } } } -/* TW: New from 650/301LVx 1.10.6s, 1.10.7w - clashes with OEMLCD() */ +static void +SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, + USHORT ModeIdIndex, USHORT RTI) +{ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + USHORT delay = 0, romptr = 0, index; + UCHAR *myptr = NULL; + UCHAR temp; + + if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToRAMDAC))) + return; + + delay = SiS_Pr->SiS_RefIndex[RTI].Ext_PDC; + + delay &= 0xf0; + delay >>= 4; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) delay <<= 12; /* BIOS: 8, wrong */ + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + index = GetOEMTVPtr661(SiS_Pr); + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + romptr = ROMAddr[0x25c] | (ROMAddr[0x25d] << 8); + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + romptr = ROMAddr[0x25e] | (ROMAddr[0x25f] << 8); + } + } + if(romptr) myptr = &ROMAddr[romptr]; + if(!myptr) { + myptr = (UCHAR *)SiS_TVDelay661_301; + if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + myptr = (UCHAR *)SiS_TVDelay661_301B; + } + } + delay = myptr[index]; + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) delay >>= 4; /* Should test dual edge */ + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(HwInfo->pdc) { + delay = HwInfo->pdc & 0x0f; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + delay |= (delay << 12); + } + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) { + delay = 0x4444; /* TEST THIS */ + } else if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + myptr = GetLCDStructPtr661(SiS_Pr, HwInfo); + if(myptr) delay = myptr[4]; + else delay = 0x44; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + delay |= (delay << 8); + } + } + } + + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2d); + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToRAMDAC)) { + temp &= 0xf0; + temp |= (delay & 0x000f); + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + temp &= 0x0f; + temp |= ((delay & 0xf000) >> 8); + } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,temp); +} + +static void +SetCRT2SyncDither661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT RTI) +{ + USHORT infoflag; + UCHAR temp; + + infoflag = SiS_Pr->SiS_RefIndex[RTI].Ext_InfoFlag; + if(ModeNo <= 0x13) { + infoflag = SiS_GetRegByte(SiS_Pr->SiS_P3ca+2); + } + infoflag &= 0xc0; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + if(temp & 0x20) infoflag = temp; + if(temp & 0x01) infoflag |= 0x01; + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + temp = 0x0c; + if(infoflag & 0x01) temp ^= 0x14; /* BIOS: 18, wrong */ + temp |= (infoflag >> 6); + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xe0,temp); + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + temp = 0; + if(infoflag & 0x01) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1a,0x7f,temp); + temp = 0x30; + if(infoflag & 0x01) temp = 0x20; + infoflag &= 0xc0; + temp |= infoflag; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0f,temp); + } +} + +static void +SetPanelParms661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +{ + UCHAR *myptr; + + if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->LVDSHL != -1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,SiS_Pr->LVDSHL); + } + } + + myptr = GetLCDStructPtr661(SiS_Pr, HwInfo); + if(myptr) { + if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->LVDSHL == -1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xE0,myptr[1] & 0x1f); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xE3,myptr[1] & 0x1c); + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0d,0x3f,myptr[2] & 0xc0); + } +} + +void +SiS_OEM661Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex, USHORT RRTI) +{ + if(SiS_Pr->SiS_VBType & VB_SISVB) { + + SetDelayComp661(SiS_Pr,HwInfo,ModeNo,ModeIdIndex,RRTI); + + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + SetCRT2SyncDither661(SiS_Pr,HwInfo,ModeNo,RRTI); + SetPanelParms661(SiS_Pr,HwInfo); + } + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SetPhaseIncr(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetYFilter(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetAntiFlicker(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { + SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + } + } + } +} + +/* FinalizeLCD + * This finalizes some CRT2 registers for the very panel used. + * If we have a backup if these registers, we use it; otherwise + * we set the register according to most BIOSes. However, this + * function looks quite different in every BIOS, so you better + * pray that we have a backup... + */ void -SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension) +SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + PSIS_HW_INFO HwInfo) { USHORT tempcl,tempch,tempbl,tempbh,tempbx,tempax,temp; USHORT resinfo,modeflag; - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; + if(!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) return; + + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(SiS_Pr->LVDSHL != -1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,SiS_Pr->LVDSHL); + } + } + + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return; + if(SiS_Pr->UseCustomMode) return; + + switch(SiS_Pr->SiS_CustomT) { + case CUT_COMPAQ1280: + case CUT_COMPAQ12802: + case CUT_CLEVO1400: + case CUT_CLEVO14002: + return; + } if(ModeNo <= 0x13) { - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; } else { - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } + + if(IS_SIS650) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3d4, 0x5f) & 0xf0)) { + if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x02); + } else { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x03); + } + } + } + + if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + /* Maybe all panels? */ + if(SiS_Pr->LVDSHL == -1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01); + } + return; + } + } + + if(SiS_Pr->SiS_CustomT == CUT_CLEVO10242) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(SiS_Pr->LVDSHL == -1) { + /* Maybe all panels? */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01); + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + tempch = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4; + if(tempch == 3) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x25); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x1b); + } + } + return; + } + } } if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); +#ifdef SET_EMI + if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x30,0x00); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + } +#endif + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) { + if(SiS_Pr->LVDSHL == -1) { + /* Maybe ACER only? */ + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01); + } } - tempch = SiS_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(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1f,0x76); - } - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { /* From 1.10.8w */ - if(!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,0x90); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x01); - if((ModeNo > 0x13) && (resinfo == 8)) { - tempbx = 806; /* 0x326 */ - 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); - } - } else { - if(ModeNo <= 0x13) { - if(ModeNo <= 1) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x70); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x19,0xff); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,0x48); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1d,0x12); - } - if(!(modeflag & HalfDCLK)) { - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,0x20); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x15,0x1a); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,0x28); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,0x00); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x4c); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x19,0xdc); - if(ModeNo == 0x12) { - switch(tempch) { - case 0: - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x95); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x19,0xdc); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1a,0x10); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,0x95); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1c,0x48); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1d,0x12); - break; - case 2: - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x95); - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,0x48); - break; - case 3: - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,0x95); - break; - } - } - } - } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1f,0x76); + } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { + if(tempch == 0x03) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x25); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x1b); + } + if((SiS_Pr->Backup == TRUE) && (SiS_Pr->Backup_Mode == ModeNo)) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,SiS_Pr->Backup_14); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,SiS_Pr->Backup_15); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,SiS_Pr->Backup_16); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,SiS_Pr->Backup_17); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,SiS_Pr->Backup_18); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,SiS_Pr->Backup_19); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1a,SiS_Pr->Backup_1a); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,SiS_Pr->Backup_1b); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,SiS_Pr->Backup_1c); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,SiS_Pr->Backup_1d); + } else if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { /* 1.10.8w */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,0x90); + if(ModeNo <= 0x13) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x11); + if((resinfo == 0) || (resinfo == 2)) return; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x18); + if((resinfo == 1) || (resinfo == 3)) return; + } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); + if((ModeNo > 0x13) && (resinfo == SIS_RI_1024x768)) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); /* 1.10.7u */ +#if 0 + tempbx = 806; /* 0x326 */ /* other older BIOSes */ + tempbx--; + temp = tempbx & 0xff; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); + temp = (tempbx >> 8) & 0x03; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1d,0xf8,temp); +#endif + } + } else if(ModeNo <= 0x13) { + if(ModeNo <= 1) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x70); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0xff); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x48); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x12); + } + if(!(modeflag & HalfDCLK)) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,0x20); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,0x1a); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,0x28); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,0x00); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x4c); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0xdc); + if(ModeNo == 0x12) { + switch(tempch) { + case 0: + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x95); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0xdc); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1a,0x10); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x95); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,0x48); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x12); + break; + case 2: + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x95); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x48); + break; + case 3: + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x95); + break; + } + } + } } } } else { - tempcl = tempbh = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x01); + tempcl = tempbh = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x01); tempcl &= 0x0f; tempbh &= 0x70; tempbh >>= 4; - tempbl = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x04); + tempbl = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x04); tempbx = (tempbh << 8) | tempbl; if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if((resinfo == 8) || (!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding))) { + 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); } } } -/* TW: New and checked from 650/301LV BIOS */ -/* This might clash with newer "FinalizeLCD()" function */ -void -SiS_OEMLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) -{ - USHORT tempbx,tempah,tempbl,tempbh,tempcl; - - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr); - tempbh = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x1a); - tempbh &= 0x38; - tempbh >>= 3; - tempbl = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x18); - tempbx = (tempbh << 8) | tempbl; - if(SiS_Pr->SiS_LCDTypeInfo == 1) tempbx -= 0x12; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,tempbx & 0x00ff); - tempah = (tempbx & 0xff00) >> 8; - tempah &= 0x07; - tempah <<= 3; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1a,0xc7,tempah); - tempah = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x19); - tempah &= 0x0f; - if(SiS_Pr->SiS_LCDTypeInfo == 1) tempah -= 2; - tempah &= 0x0f; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,tempah); - tempah = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x14); - if(SiS_Pr->SiS_LCDTypeInfo == 1) tempah++; - tempah -= 8; - SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,tempah); - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - tempcl = tempbh = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x01); - tempbh &= 0x70; - tempbh >>= 4; - tempbl = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x04); - tempbx = (tempbh << 8) | tempbl; - if(SiS_Pr->SiS_LCDTypeInfo == 1) { - tempbx -= 0x1e; - tempcl &= 0x0f; - tempcl -= 4; - tempcl &= 0x0f; - } - tempbl = tempbx & 0x00ff; - tempbh = (tempbx >> 8) & 0x00ff; - SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,tempbl); - tempbh <<= 4; - tempbh |= tempcl; - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,tempbh); - } -} #endif - /* ================= SiS 300 O.E.M. ================== */ #ifdef SIS300 -#if 0 /* Not used */ -static USHORT -GetRevisionID(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension) +void +SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex, USHORT RefTabIndex) { - ULONG temp1; -#ifndef LINUX_XF86 - ULONG base; -#endif - USHORT temp2 = 0; + USHORT crt2crtc=0, modeflag, myindex=0; + UCHAR temp; + int i; - if((HwDeviceExtension->jChipType==SIS_540)|| - (HwDeviceExtension->jChipType==SIS_630)|| - (HwDeviceExtension->jChipType==SIS_730)) { -#ifndef LINUX_XF86 - base = 0x80000008; - OutPortLong(base,0xcf8); - temp1 = InPortLong(0xcfc); -#else - temp1=pciReadLong(0x00000000, 0x08); -#endif - temp1 &= 0x000000FF; - temp2 = (USHORT)(temp1); - return temp2; - } - return 0; + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + crt2crtc = SiS_Pr->SiS_RefIndex[RefTabIndex].Ext_CRT2CRTC; + } + + crt2crtc &= 0x3f; + + if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xdf); + } + + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + if(modeflag & HalfDCLK) myindex = 1; + + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + for(i=0; i<7; i++) { + if(barco_p1[myindex][crt2crtc][i][0]) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port, + barco_p1[myindex][crt2crtc][i][0], + barco_p1[myindex][crt2crtc][i][2], + barco_p1[myindex][crt2crtc][i][1]); + } + } + } + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + if(temp & 0x80) { + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x18); + temp++; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); + } + } } -#endif -/* TW: Checked against 630/301B BIOS (incl data) */ 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, @@ -10446,24 +11992,24 @@ 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_Pr->SiS_LCDResInfo - 2; + tempbx = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0x0f) - 2; if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx += 4; if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) { - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 3; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 3; } if((ROMAddr) && SiS_Pr->SiS_UseROM) { if(ROMAddr[0x235] & 0x80) { tempbx = SiS_Pr->SiS_LCDTypeInfo; if(Flag) { - romptr = ROMAddr[0x255] | (ROMAddr[0x256] << 8); - if(romptr) { + romptr = ROMAddr[0x255] | (ROMAddr[0x256] << 8); + if(romptr) { tempbx = ROMAddr[romptr + SiS_Pr->SiS_LCDTypeInfo]; - } else { + } else { tempbx = customtable300[SiS_Pr->SiS_LCDTypeInfo]; - } - if(tempbx == 0xFF) return 0xFFFF; + } + if(tempbx == 0xFF) return 0xFFFF; } tempbx <<= 1; if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++; @@ -10473,103 +12019,109 @@ 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 & LCDNonExpanding) tempbx++; - return tempbx; + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + romptr = ROMAddr[0x255] | (ROMAddr[0x256] << 8); + if(romptr) { + tempbx = ROMAddr[romptr + SiS_Pr->SiS_LCDTypeInfo]; + } else { + tempbx = 0xff; + } + } else { + tempbx = customtable630[SiS_Pr->SiS_LCDTypeInfo]; + } + if(tempbx == 0xFF) return 0xFFFF; + tempbx <<= 2; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempbx += 2; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; + return tempbx; } tempbx = SiS_Pr->SiS_LCDTypeInfo << 2; if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempbx += 2; - if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx++; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; } return tempbx; } -/* TW: Checked against 630/301B and 630/LVDS BIOS (incl data) */ static void -SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT index,temp,romptr=0; + if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return; + if((ROMAddr) && SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x237] & 0x01)) return; if(!(ROMAddr[0x237] & 0x02)) return; romptr = ROMAddr[0x24b] | (ROMAddr[0x24c] << 8); } - /* TW: The Panel Compensation Delay should be set according to tables - * here. Unfortunately, various BIOS versions don't case about - * a uniform way using eg. ROM byte 0x220, but use different - * hard coded delays (0x04, 0x20, 0x18) in SetGroup1(). - * Thus we don't set this if the user select a custom pdc or if - * we otherwise detected a valid pdc. + /* The Panel Compensation Delay should be set according to tables + * here. Unfortunately, various BIOS versions don't case about + * a uniform way using eg. ROM byte 0x220, but use different + * hard coded delays (0x04, 0x20, 0x18) in SetGroup1(). + * Thus we don't set this if the user select a custom pdc or if + * we otherwise detected a valid pdc. */ - if(HwDeviceExtension->pdc) return; + if(HwInfo->pdc) return; - temp = GetOEMLCDPtr(SiS_Pr,HwDeviceExtension, ROMAddr, 0); + temp = GetOEMLCDPtr(SiS_Pr,HwInfo, 0); - index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex; - - if(HwDeviceExtension->jChipType != SIS_300) { + if(SiS_Pr->UseCustomMode) + index = 0; + else + index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex; + + if(HwInfo->jChipType != SIS_300) { + if(romptr) { + romptr += (temp * 2); + romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); + romptr += index; + temp = ROMAddr[romptr]; + } else { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp = SiS300_OEMLCDDelay2[temp][index]; + } else { + temp = SiS300_OEMLCDDelay3[temp][index]; + } + } + } else { + if((ROMAddr) && SiS_Pr->SiS_UseROM && (ROMAddr[0x235] & 0x80)) { if(romptr) { romptr += (temp * 2); romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); romptr += index; temp = ROMAddr[romptr]; } else { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - temp = SiS300_OEMLCDDelay2[temp][index]; + temp = SiS300_OEMLCDDelay5[temp][index]; + } + } else { + if((ROMAddr) && SiS_Pr->SiS_UseROM) { + romptr = ROMAddr[0x249] | (ROMAddr[0x24a] << 8); + if(romptr) { + romptr += (temp * 2); + romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); + romptr += index; + temp = ROMAddr[romptr]; } else { - temp = SiS300_OEMLCDDelay3[temp][index]; - } + temp = SiS300_OEMLCDDelay4[temp][index]; + } + } else { + temp = SiS300_OEMLCDDelay4[temp][index]; } - } else { - if((ROMAddr) && SiS_Pr->SiS_UseROM && (ROMAddr[0x235] & 0x80)) { - if(romptr) { - romptr += (temp * 2); - romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); - romptr += index; - temp = ROMAddr[romptr]; - } else { - temp = SiS300_OEMLCDDelay5[temp][index]; - } - } else { - if((ROMAddr) && SiS_Pr->SiS_UseROM) { - romptr = ROMAddr[0x249] | (ROMAddr[0x24a] << 8); - if(romptr) { - romptr += (temp * 2); - romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); - romptr += index; - temp = ROMAddr[romptr]; - } else { - temp = SiS300_OEMLCDDelay4[temp][index]; - } - } else { - temp = SiS300_OEMLCDDelay4[temp][index]; - } - } + } } temp &= 0x3c; SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* index 0A D[6:4] */ } static void -SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex) +SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex) { -#if 0 /* TW: Unfinished; VData table missing */ +#if 0 /* Unfinished; Data table missing */ + UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; USHORT index,temp; if((ROMAddr) && SiS_Pr->SiS_UseROM) { @@ -10578,26 +12130,25 @@ SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT /* 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 } -/* TW: Checked against 630/301B 2.04.50 and 630/LVDS BIOS */ static USHORT GetOEMTVPtr(SiS_Private *SiS_Pr) { @@ -10605,22 +12156,22 @@ GetOEMTVPtr(SiS_Private *SiS_Pr) index = 0; if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) index += 4; - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) index += 2; else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) index += 3; - else if(SiS_Pr->SiS_VBInfo & SetPALTV) index += 1; + else if(SiS_Pr->SiS_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; } -/* TW: Checked against 630/301B 2.04.50 and 630/LVDS BIOS (incl data) */ 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) { @@ -10639,7 +12190,7 @@ SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT 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]; @@ -10649,12 +12200,11 @@ SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* index 0A D[6:4] */ } -/* TW: Checked against 630/301B 2.04.50 BIOS (incl data) */ 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) { @@ -10679,15 +12229,17 @@ SetOEMAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0A,0x8F,temp); /* index 0A D[6:4] */ } -/* TW: Checked against 630/301B 2.04.50 BIOS (incl data) */ 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_TVMode & (TVSetNTSC1024 | TVSetNTSCJ | TVSetPALM | TVSetPALN)) return; + if((ROMAddr) && SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x238] & 0x01)) return; if(!(ROMAddr[0x238] & 0x08)) return; @@ -10699,31 +12251,31 @@ 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 = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); + romptr += (index * 4); + for(i=0x31, j=0; i<=0x34; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); + } + } else { + for(i=0x31, j=0; i<=0x34; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Phase1[temp][index][j]); + } + } } } -/* TW: Checked against 630/301B 2.04.50 BIOS (incl data) */ 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; @@ -10735,64 +12287,85 @@ SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT temp = GetOEMTVPtr(SiS_Pr); + if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 8; + else if(SiS_Pr->SiS_TVMode & TVSetPALN) temp = 9; + /* NTSCJ uses NTSC filters */ + index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVYFilterIndex; - if(HwDeviceExtension->jChipType > SIS_300) { - if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) { - temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35); - if(temp1 & (EnablePALM | EnablePALN)) { - temp = 8; - if(!(temp1 & EnablePALM)) temp = 9; - } - } - } if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); } for(i=0x48; i<=0x4A; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); } } else { - if(romptr) { + if((romptr) && (!(SiS_Pr->SiS_TVMode & (TVSetPALM|TVSetPALN)))) { romptr += (temp * 2); romptr = ROMAddr[romptr] | (ROMAddr[romptr + 1] << 8); romptr += (index * 4); for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); } } else { for(i=0x35, j=0; i<=0x38; i++, j++) { - SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Filter1[temp][index][j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter1[temp][index][j]); } } } } +static USHORT +SiS_SearchVBModeID(SiS_Private *SiS_Pr, USHORT *ModeNo) +{ + USHORT ModeIdIndex; + UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; + + if(*ModeNo <= 5) *ModeNo |= 1; + + for(ModeIdIndex=0; ; ModeIdIndex++) { + if(SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == *ModeNo) break; + if(SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == 0xFF) return 0; + } + + if(*ModeNo != 0x07) { + if(*ModeNo > 0x03) return ModeIdIndex; + if(VGAINFO & 0x80) return ModeIdIndex; + ModeIdIndex++; + } + + if(VGAINFO & 0x10) ModeIdIndex++; /* 400 lines */ + /* else 350 lines */ + return ModeIdIndex; +} + void -SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo) +SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo, USHORT ModeIdIndex, USHORT RefTableIndex) { - USHORT ModeIdIndex; + USHORT OEMModeIdIndex=0; - ModeIdIndex = SiS_SearchVBModeID(SiS_Pr,ROMAddr,&ModeNo); - if(!(ModeIdIndex)) return; + if(!SiS_Pr->UseCustomMode) { + OEMModeIdIndex = SiS_SearchVBModeID(SiS_Pr,&ModeNo); + if(!(OEMModeIdIndex)) return; + } if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - SetOEMLCDDelay(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - SetOEMLCDData(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - } + SetOEMLCDDelay(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + SetOEMLCDData(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + } } + if(SiS_Pr->UseCustomMode) return; if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SetOEMTVDelay(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { - SetOEMAntiFlicker(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - SetOEMPhaseIncr(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - SetOEMYFilter(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex); - } + SetOEMTVDelay(SiS_Pr, HwInfo, ModeNo,OEMModeIdIndex); + if(SiS_Pr->SiS_VBType & VB_SISVB) { + SetOEMAntiFlicker(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + SetOEMPhaseIncr(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + SetOEMYFilter(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + } } } #endif - diff --git a/src/init301.h b/src/init301.h index 2cbb39d..757cc36 100644 --- a/src/init301.h +++ b/src/init301.h @@ -1,20 +1,47 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.h,v 1.9 2003/02/04 02:44:28 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.h,v 1.33 2003/11/20 19:53:23 twini Exp $ */ +/* + * Data and prototypes for init301.c + * + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the linux kernel, the contents of this file + * is entirely covered by the GPL. + * + * Otherwise, the following 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. + * + * 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 <thomas@winischhofer.net> + * + * Based on code by Silicon Intergrated Systems + * + */ + #ifndef _INIT301_ #define _INIT301_ #include "osdef.h" + #include "initdef.h" #include "vgatypes.h" #include "vstruct.h" -#ifdef TC -#include <stdio.h> -#include <string.h> -#include <conio.h> -#include <dos.h> -#include <stdlib.h> -#endif - #ifdef LINUX_XF86 #include "xf86.h" #include "xf86Pci.h" @@ -24,141 +51,190 @@ #endif #ifdef LINUX_KERNEL +#ifdef SIS_CP +#undef SIS_CP +#endif +#include <linux/config.h> +#include <linux/version.h> #include <asm/io.h> #include <linux/types.h> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #include <linux/sisfb.h> +#else +#include <video/sisfb.h> #endif - -#ifdef WIN2000 -#include <stdio.h> -#include <string.h> -#include <miniport.h> -#include "dderror.h" -#include "devioctl.h" -#include "miniport.h" -#include "ntddvdeo.h" -#include "video.h" -#include "sisv.h" #endif -#if 0 -extern const USHORT SiS_MDA_DAC[]; -extern const USHORT SiS_CGA_DAC[]; -extern const USHORT SiS_EGA_DAC[]; -extern const USHORT SiS_VGA_DAC[]; -#endif +const UCHAR SiS_HiVisionTable[3][64] = { + { + 0x17, 0x1d, 0x03, 0x09, 0x05, 0x06, 0x0c, 0x0c, + 0x94, 0x49, 0x01, 0x0a, 0x06, 0x0d, 0x04, 0x0a, + 0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x1b, + 0x0c, 0x50, 0x00, 0x97, 0x00, 0xd4, 0x4a, 0x17, + 0x7d, 0x05, 0x4b, 0x00, 0x00, 0xe2, 0x00, 0x02, + 0x03, 0x0a, 0x65, 0x9d, 0x08, 0x92, 0x8f, 0x40, + 0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x14, 0x53, + 0x00, 0x40, 0x44, 0x00, 0xdb, 0x02, 0x3b, 0x00 + }, + { + 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 + }, + { + 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 + } +}; -extern BOOLEAN SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *RomAddr, USHORT *); +const UCHAR SiS_HiTVGroup3_1[] = { + 0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x13, + 0xb1, 0x41, 0x62, 0x62, 0xff, 0xf4, 0x45, 0xa6, + 0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20, + 0xac, 0xda, 0x60, 0xfe, 0x6a, 0x9a, 0x06, 0x10, + 0xd1, 0x04, 0x18, 0x0a, 0xff, 0x80, 0x00, 0x80, + 0x3b, 0x77, 0x00, 0xef, 0xe0, 0x10, 0xb0, 0xe0, + 0x10, 0x4f, 0x0f, 0x0f, 0x05, 0x0f, 0x08, 0x6e, + 0x1a, 0x1f, 0x25, 0x2a, 0x4c, 0xaa, 0x01 +}; -BOOLEAN SiS_Is301B(SiS_Private *SiS_Pr, USHORT BaseAddr); -BOOLEAN SiS_IsM650or651(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_IsDisableCRT2(SiS_Private *SiS_Pr, USHORT BaseAddr); -BOOLEAN SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_CRT2IsLCD(SiS_Private *SiS_Pr, USHORT BaseAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetDefCRT2ExtRegs(SiS_Private *SiS_Pr, USHORT BaseAddr); -USHORT SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -BOOLEAN SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT MODEIdIndex, - USHORT RefreshRateTableIndex,USHORT *i,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo); -void SiS_GetCRT2Data(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_GetCRT2PtrA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex); -void SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index, USHORT *ResIndex); -void SiS_GetCRT2Data301(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -USHORT SiS_GetResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -void SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT BaseAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO ); -void SiS_SetHiVision(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_GetLVDSDesData(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCRT2Offset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -USHORT SiS_GetOffset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex); -USHORT SiS_GetMCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -USHORT SiS_CalcDelayVB(SiS_Private *SiS_Pr); -USHORT SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetRegANDOR(USHORT Port,USHORT Index,USHORT DataAND,USHORT DataOR); -void SiS_SetRegOR(USHORT Port,USHORT Index,USHORT DataOR); -void SiS_SetRegAND(USHORT Port,USHORT Index,USHORT DataAND); -USHORT SiS_GetVGAHT2(SiS_Private *SiS_Pr); -void SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT ModeIdIndex, USHORT RefreshRateTableIndex, - USHORT BaseAddr, USHORT ModeNo); -void SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetGroup5(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex); -void SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_EnableCRT2(SiS_Private *SiS_Pr); -void SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension, int checkcrt2mode); -BOOLEAN SiS_BridgeIsOn(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO); -BOOLEAN SiS_BridgeIsEnable(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO); -BOOLEAN SiS_BridgeInSlave(SiS_Private *SiS_Pr); -void SiS_PresetScratchregister(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetTVSystem(SiS_Private *SiS_Pr); -void SiS_LongWait(SiS_Private *SiS_Pr); -USHORT SiS_GetQueueConfig(SiS_Private *SiS_Pr); -void SiS_VBLongWait(SiS_Private *SiS_Pr); -USHORT SiS_GetVCLKLen(SiS_Private *SiS_Pr, UCHAR *ROMAddr); -void SiS_WaitVBRetrace(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_WaitRetrace1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_WaitRetrace2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_WaitRetraceDDC(SiS_Private *SiS_Pr); -void SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_GetLVDSDesPtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *PanelIndex,USHORT *ResIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_GetLVDSDesPtrA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *PanelIndex,USHORT *ResIndex); -void SiS_SetTPData(SiS_Private *SiS_Pr); -void SiS_WhatIsThis(SiS_Private *SiS_Pr, USHORT myvbinfo); -void SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex); -void SiS_GetCHTVRegPtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex); -void SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempax); -USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax); -void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempax); -USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempax); -void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempax); -USHORT SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempax); -#ifdef LINUX_XF86 -USHORT SiS_I2C_GetByte(SiS_Private *SiS_Pr); -Bool SiS_I2C_PutByte(SiS_Private *SiS_Pr, USHORT data); -Bool SiS_I2C_Address(SiS_Private *SiS_Pr, USHORT addr); -void SiS_I2C_Stop(SiS_Private *SiS_Pr); +const UCHAR SiS_HiTVGroup3_2[] = { + 0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x7a, + 0x54, 0x41, 0xe7, 0xe7, 0xff, 0xf4, 0x45, 0xa6, + 0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20, + 0xac, 0x6a, 0x60, 0x2b, 0x52, 0xcd, 0x61, 0x10, + 0x51, 0x04, 0x18, 0x0a, 0x1f, 0x80, 0x00, 0x80, + 0xff, 0xa4, 0x04, 0x2b, 0x94, 0x21, 0x72, 0x94, + 0x26, 0x05, 0x01, 0x0f, 0xed, 0x0f, 0x0a, 0x64, + 0x18, 0x1d, 0x23, 0x28, 0x4c, 0xaa, 0x01 +}; + +/* 301C / 302ELV (?) extended Part2 TV registers */ + +static const UCHAR SiS_Part2CLVX_1[] = { + 0x00,0x00, + 0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, + 0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, + 0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C, + 0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E +}; + +static const UCHAR SiS_Part2CLVX_2[] = { + 0x00,0x00, + 0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, + 0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, + 0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C, + 0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E +}; + +static const UCHAR SiS_Part2CLVX_3[] = { /* NTSC */ + 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 +}; + +#ifdef SIS315H +/* 661 et al LCD data structure */ +static const UCHAR SiS_LCDStruct661[] = { + /* 1600x1200 */ + 0x0B,0xEA,0x81,0x10,0x00,0xC0,0x03,0x21,0x5A,0x23,0x5A,0x23,0x02, + 0x14,0x0A,0x02,0x00,0x30,0x10,0x5A,0x10,0x10,0x0A,0xC0,0x30,0x10, + /* 1400x1050 */ + 0x09,0xEA,0x81,0x80,0xA3,0x70,0x03,0x19,0xD2,0x2A,0xF8,0x2F,0x02, + 0x14,0x0A,0x02,0x00,0x30,0x10,0x5A,0x10,0x10,0x0A,0xC0,0x30,0x10, + /* 1280x1024 */ + 0x03,0xEA,0x81,0x40,0xA1,0x70,0x03,0x19,0xD2,0x2A,0xF8,0x2F,0x02, + 0x14,0x0A,0x02,0x00,0x30,0x10,0x5A,0x10,0x10,0x0A,0xC0,0x30,0x10, + /* 1024x768 */ + 0x02,0xEA,0x80,0x00,0x11,0x88,0x06,0x0B,0xF5,0x6C,0x35,0x62,0x02, + 0x14,0x0A,0x02,0x00,0x30,0x10,0x5A,0x10,0x10,0x0A,0xC0,0x28,0x10, + 0xFF, +}; #endif -void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh); + +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_SetHiVision(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); +void SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); +USHORT SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, + USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo); +USHORT SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex); +void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +BOOLEAN SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo); +void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); + +void SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempax); +USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax); +void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempax); +USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempax); +void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempax); +USHORT SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempax); +void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh); +#ifdef SIS315H +void SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_ChrontelInitTVVSync(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr); +#endif /* 315 */ + +USHORT SiS_ReadDDC1Bit(SiS_Private *SiS_Pr); void SiS_SetSwitchDDC2(SiS_Private *SiS_Pr); USHORT SiS_SetStart(SiS_Private *SiS_Pr); USHORT SiS_SetStop(SiS_Private *SiS_Pr); @@ -168,118 +244,61 @@ USHORT SiS_SetSCLKHigh(SiS_Private *SiS_Pr); USHORT SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax); USHORT SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax); USHORT SiS_CheckACK(SiS_Private *SiS_Pr); -USHORT SiS_ReadLCDDDC(SiS_Private *SiS_Pr, USHORT length, unsigned char *buffer); + +USHORT SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, + USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32); +USHORT SiS_WriteDABDDC(SiS_Private *SiS_Pr); +USHORT SiS_PrepareReadDDC(SiS_Private *SiS_Pr); +USHORT SiS_PrepareDDC(SiS_Private *SiS_Pr); +void SiS_SendACK(SiS_Private *SiS_Pr, USHORT yesno); +USHORT SiS_DoProbeDDC(SiS_Private *SiS_Pr); +USHORT SiS_ProbeDDC(SiS_Private *SiS_Pr); +USHORT SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer); +USHORT SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, + USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer); +#ifdef LINUX_XF86 +USHORT SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS); +USHORT SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS); +#endif + #ifdef SIS315H -void SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_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); +void SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex); +void SiS_OEM661Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, + USHORT ModeNo,USHORT ModeIdIndex, USHORT RRTI); +void SiS_FinalizeLCD(SiS_Private *, USHORT, USHORT, PSIS_HW_INFO); #endif #ifdef SIS300 -void SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr, - UCHAR *ROMAddr,USHORT ModeNo); +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 -BOOLEAN SiS_LowModeStuff(SiS_Private *SiS_Pr, USHORT ModeNo,PSIS_HW_DEVICE_INFO HwDeviceExtension); -BOOLEAN SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -/* void SiS_CHACRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex); */ +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); -BOOLEAN SiS_SetCRT2Group301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex); -void SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex); -void SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex); -void SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex); -#ifdef SIS300 -void SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -#endif -#ifdef SIS315H -void SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, - PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_CRT2AutoThreshold(SiS_Private *SiS_Pr, USHORT BaseAddr); -#endif -BOOLEAN SiS_GetLCDDDCInfo(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT BaseAddr); -void SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT BaseAddr); -void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT BaseAddr); -void SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO,USHORT BaseAddr); -void SiS_SetPanelDelay(SiS_Private *SiS_Pr, UCHAR* ROMAddr,PSIS_HW_DEVICE_INFO,USHORT DelayTime); -void SiS_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); +extern void SiS_DisplayOff(SiS_Private *SiS_Pr); +extern void SiS_DisplayOn(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); +extern BOOLEAN SiS_SearchModeID(SiS_Private *, USHORT *, USHORT *); +extern UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex); -/* TW: New functions (with mostly temporary names) */ -void SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr); -void SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - USHORT BaseAddr); -void SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr); -void SiS_Chrontel701xOff(SiS_Private *SiS_Pr); -void SiS_ChrontelResetDB(SiS_Private *SiS_Pr); -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); -#if 0 -BOOLEAN SiS_IsSomethingCR5F(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -#endif -BOOLEAN SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_IsChScart(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_IsTVOrYPbPrOrScart(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -BOOLEAN SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -void SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr); -void SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr); -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); -/* TW end */ +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_SetReg1(USHORT, USHORT, USHORT); -extern void SiS_SetReg3(USHORT, USHORT); -extern UCHAR SiS_GetReg1(USHORT, USHORT); -extern UCHAR SiS_GetReg2(USHORT); -extern BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo,USHORT *ModeIdIndex); -extern BOOLEAN SiS_GetRatePtr(SiS_Private *SiS_Pr, ULONG, USHORT); -extern void SiS_SetReg4(USHORT, ULONG); -extern ULONG SiS_GetReg3(USHORT); -extern void SiS_SetReg5(USHORT, USHORT); -extern USHORT SiS_GetReg4(USHORT); -extern void SiS_DisplayOff(SiS_Private *SiS_Pr); -extern void SiS_DisplayOn(SiS_Private *SiS_Pr); -extern UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex); -extern BOOLEAN SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *ResInfo,USHORT *DisplayType); -extern BOOLEAN SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *ResInfo,USHORT *DisplayType); -extern void SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO, UCHAR *ROMAddr,USHORT ModeNo, - USHORT ModeIdIndex); -#ifdef SIS315H -extern UCHAR SiS_Get310DRAMType(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension); -#endif +extern void SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO,USHORT ModeNo, + USHORT ModeIdIndex); -#ifdef LINUX_XF86 -/* DDC functions */ -USHORT SiS_InitDDCRegs(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, USHORT DDCdatatype); -USHORT SiS_WriteDABDDC(SiS_Private *SiS_Pr); -USHORT SiS_PrepareReadDDC(SiS_Private *SiS_Pr); -USHORT SiS_PrepareDDC(SiS_Private *SiS_Pr); -void SiS_SendACK(SiS_Private *SiS_Pr, USHORT yesno); -USHORT SiS_DoProbeDDC(SiS_Private *SiS_Pr); -USHORT SiS_ProbeDDC(SiS_Private *SiS_Pr); -USHORT SiS_ReadDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT DDCdatatype, unsigned char *buffer); -USHORT SiS_HandleDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, - USHORT DDCdatatype, unsigned char *buffer); -#endif #endif diff --git a/src/initdef.h b/src/initdef.h index a2d796b..5dc509f 100644 --- a/src/initdef.h +++ b/src/initdef.h @@ -1,30 +1,95 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/initdef.h,v 1.9 2003/02/04 02:44:28 dawes Exp $ */ - +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/initdef.h,v 1.24 2003/11/19 00:49:03 twini Exp $ */ +/* + * Global definitions for init.c and init301.c + * + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the linux kernel, the contents of this file + * is entirely covered by the GPL. + * + * Otherwise, the following 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. + * + * 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 <thomas@winischhofer.net> + * + * Based on code by Silicon Integrated 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) /* SiS_VBType */ #define VB_SIS301 0x0001 #define VB_SIS301B 0x0002 #define VB_SIS302B 0x0004 -#define VB_SIS30xLV 0x0008 -#define VB_SIS30xNEW 0x0010 +#define VB_SIS301LV 0x0008 +#define VB_SIS302LV 0x0010 +#define VB_SIS302ELV 0x0020 +#define VB_SIS301C 0x0040 #define VB_NoLCD 0x8000 -#define VB_SIS301BLV302BLV (VB_SIS301B|VB_SIS302B|VB_SIS30xLV|VB_SIS30xNEW) -#define VB_SIS301B302B (VB_SIS301B|VB_SIS302B) -#define VB_SIS301LV302LV (VB_SIS30xLV|VB_SIS30xNEW) - -#define IS_SIS650740 ((HwDeviceExtension->jChipType >= SIS_650) && (HwDeviceExtension->jChipType < SIS_330)) +#define VB_SIS301BLV302BLV (VB_SIS301B|VB_SIS301C|VB_SIS302B|VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV) +#define VB_SIS301B302B (VB_SIS301B|VB_SIS301C|VB_SIS302B) +#define VB_SIS301LV302LV (VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV) +#define VB_SISVB (VB_SIS301 | VB_SIS301BLV302BLV) -#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 SetCRT2ToHiVisionTV 0x0080 +#define SetCRT2ToTV 0x009C /* alias */ +#define SetNTSCTV 0x0000 /* CR 31 */ +#define SetPALTV 0x0100 /* Deprecated here, now in TVMode */ +#define SetInSlaveMode 0x0200 +#define SetNotSimuMode 0x0400 +#define SetNotSimuTVMode 0x0400 +#define SetDispDevSwitch 0x0800 +#define LoadDACFlag 0x1000 +#define SetCHTVOverScan 0x1000 /* Deprecated here, now in TVMode */ +#define DisableCRT2Display 0x2000 +#define CRT2DisplayFlag 0x2000 +#define DriverMode 0x4000 +#define HotKeySwitch 0x8000 +#define SetCRT2ToLCDA 0x8000 /* SiS_ModeType */ #define ModeText 0x00 @@ -52,59 +117,54 @@ #define DoubleScanMode 0x8000 /* Infoflag */ -#define SupportAllCRT2 0x0078 #define SupportTV 0x0008 +#define SupportTV1024 0x0800 +#define SupportCHTV 0x0800 #define SupportHiVisionTV 0x0010 +#define SupportHiVisionTV2 0x1000 #define SupportLCD 0x0020 -#define SupportRAMDAC2 0x0040 -#define NoSupportTV 0x0070 -#define NoSupportHiVisionTV 0x0060 -#define NoSupportLCD 0x0058 -#define SupportCHTV 0x0800 -#define SupportTV1024 0x0800 +#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 SyncPP 0x0000 #define SyncPN 0x4000 #define SyncNP 0x8000 #define SyncNN 0xc000 -#define ECLKindex0 0x0000 -#define ECLKindex1 0x0100 -#define ECLKindex2 0x0200 -#define ECLKindex3 0x0300 -#define ECLKindex4 0x0400 -/* VBInfo */ -#define SetSimuScanMode 0x0001 /* CR 30 */ -#define SwitchToCRT2 0x0002 -#define SetCRT2ToAVIDEO 0x0004 -#define SetCRT2ToSVIDEO 0x0008 -#define SetCRT2ToSCART 0x0010 -#define SetCRT2ToLCD 0x0020 -#define SetCRT2ToRAMDAC 0x0040 -#define SetCRT2ToHiVisionTV 0x0080 -#define SetCRT2ToTV 0x009C /* alias */ -#define SetNTSCTV 0x0000 /* CR 31 */ -#define SetPALTV 0x0100 -#define SetInSlaveMode 0x0200 -#define SetNotSimuMode 0x0400 -#define SetNotSimuTVMode 0x0400 -#define SetDispDevSwitch 0x0800 -#define LoadDACFlag 0x1000 -#define SetCHTVOverScan 0x1000 /* TW: Re-defined (from 0x8000) */ -#define DisableCRT2Display 0x2000 -#define CRT2DisplayFlag 0x2000 -#define DriverMode 0x4000 -#define HotKeySwitch 0x8000 /* TW: ? */ -#define SetCRT2ToLCDA 0x8000 - -#define PanelRGB18Bit 0x0100 -#define PanelRGB24Bit 0x0000 - -#define TVOverScan 0x10 /* Bit in CR35 (300 series only) */ -#define TVOverScanShift 4 -#define ClearBufferFlag 0x20 - -/* CR32 (Newer 630, and 310/325 series) +/* SetFlag */ +#define ProgrammingCRT2 0x0001 +#define LowModeTests 0x0002 +/* #define TVSimuMode 0x0002 - deprecated */ +/* #define RPLLDIV2XO 0x0004 - deprecated */ +#define LCDVESATiming 0x0008 +#define EnableLVDSDDA 0x0010 +#define SetDispDevSwitchFlag 0x0020 +#define CheckWinDos 0x0040 +#define SetDOSMode 0x0080 + +/* TVMode flag */ +#define TVSetPAL 0x0001 +#define TVSetNTSCJ 0x0002 +#define TVSetPALM 0x0004 +#define TVSetPALN 0x0008 +#define TVSetCHOverScan 0x0010 +#define TVSetTVSimuMode 0x0800 +#define TVRPLLDIV2XO 0x1000 +#define TVSetNTSC1024 0x2000 + +/* SysFlags (to identify special versions) */ +#define SF_Is651 0x0001 +#define SF_IsM650 0x0002 +#define SF_Is652 0x0004 +#define SF_IsM652 0x0008 +#define SF_IsM653 0x0010 +#define SF_IsM661 0x0020 +#define SF_IsM741 0x0040 +#define SF_IsM760 0x0080 + +/* CR32 (Newer 630, and 315 series) [0] VB connected with CVBS [1] VB connected with SVHS @@ -113,9 +173,31 @@ [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] 000 525i (not supported yet) + 001 525p + 010 750p + 011 1080i + + These bits are being translated to TVMode flag. + +*/ + +/* CR37 [0] Set 24/18 bit (0/1) RGB to LVDS/TMDS transmitter (set by BIOS) @@ -126,13 +208,16 @@ 011 LVDS + Tumpion Zurac 100 LVDS + Chrontel 7005 110 Chrontel 7005 - 310/325 series + 315/330 series 001 SiS30x (never seen) 010 LVDS 011 LVDS + Chrontel 7019 + 660 series [2:1] only: + reserved (now in CR38) All other combinations reserved - [4] LVDS: Expanding(0)/Non-expanding(1) LCD display - 30x: SiS30x(0)/LCD monitor(1) scaling display + [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 0: VESA DMT Standard 1: EDID 2.x defined @@ -144,28 +229,48 @@ 1: Low active */ -/* CR38 (310/325 series) */ +/* CR37: LCDInfo */ +#define LCDRGB18Bit 0x0001 +#define LCDNonExpanding 0x0010 +#define LCDSync 0x0020 +#define LCDPass11 0x0100 +#define LCDDualLink 0x0200 + +#define DontExpandLCD LCDNonExpanding +#define LCDNonExpandingShift 4 +#define DontExpandLCDShift LCDNonExpandingShift +#define LCDSyncBit 0x00e0 +#define LCDSyncShift 6 + +/* CR38 (315 series) */ #define EnableDualEdge 0x01 -#define SetToLCDA 0x02 /* LCD channel A (302B/LV and 650+LVDS only) */ +#define SetToLCDA 0x02 /* LCD channel A (302B/30xLV and 650+LVDS only) */ #define EnableSiSHiVision 0x04 /* HiVision (HDTV) on SiS bridge */ #define EnableLVDSScart 0x04 /* Scart on Ch7019 (unofficial definition - TW) */ #define EnableLVDSHiVision 0x08 /* YPbPr color format (480i HDTV); only on 650/Ch7019 systems */ -#define SiSHiVision1 0x10 /* See SetHiVision() */ -#define SiSHiVision2 0x20 +#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 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 +*/ #define EnablePALMN 0x40 /* Romflag: 1 = Allow PALM/PALN */ -/* CR39 (650) */ +/* CR39 (650 only) */ #define LCDPass1_1 0x01 /* LVDS only; set by driver to pass 1:1 data to LVDS output */ -#define SomeThingTV_LVNEW 0x04 /* 30xNEW only; set by mode switching function */ +#define Enable302LV_DualLink 0x04 /* 302LV only; enable dual link */ -/* CR79 (310/325 series only) +/* CR79 (315/330 series only; not 661 and later) [3-0] Notify driver 0001 Mode Switch event (set by BIOS) 0010 Epansion On/Off event @@ -174,23 +279,15 @@ 0101 Set Contrast event 0110 Set Mute event 0111 Set Volume Up/Down event - [4] Enable Backlight Control by BIOS/driver (set by driver) + [4] Enable Backlight Control by BIOS/driver + (set by driver; set means that the BIOS should + not touch the backlight registers because eg. + the driver already switched off the backlight) [5] PAL/NTSC (set by BIOS) [6] Expansion On/Off (set by BIOS; copied to CR32[4]) [7] TV UnderScan/OverScan (set by BIOS) */ -/* SetFlag */ -#define ProgrammingCRT2 0x01 -#define TVSimuMode 0x02 -#define RPLLDIV2XO 0x04 -#define LCDVESATiming 0x08 -#define EnableLVDSDDA 0x10 -#define SetDispDevSwitchFlag 0x20 -#define CheckWinDos 0x40 -#define SetJDOSMode 0x80 -#define CRT2IsVGA 0x80 /* TW: Not sure about this name... */ - /* LCDResInfo */ #define Panel300_800x600 0x01 /* CR36 */ #define Panel300_1024x768 0x02 @@ -199,7 +296,10 @@ #define Panel300_640x480 0x05 #define Panel300_1024x600 0x06 #define Panel300_1152x768 0x07 -#define Panel300_320x480 0x08 /* fstn - TW: This is fake, can be any */ +#define Panel300_1280x768 0x0a +#define Panel300_320x480 0x0e /* fstn - TW: This is fake, can be any */ +#define Panel300_Custom 0x0f +#define Panel300_Barco1366 0x10 #define Panel310_800x600 0x01 #define Panel310_1024x768 0x02 @@ -210,9 +310,12 @@ #define Panel310_1280x960 0x07 #define Panel310_1152x768 0x08 /* LVDS only */ #define Panel310_1400x1050 0x09 -#define Panel310_1280x768 0x0a /* LVDS only */ +#define Panel310_1280x768 0x0a #define Panel310_1600x1200 0x0b -#define Panel310_320x480 0x0c /* fstn - TW: This is fake, can be any */ +#define Panel310_640x480_2 0x0c +#define Panel310_640x480_3 0x0d +#define Panel310_320x480 0x0e /* fstn - TW: This is fake, can be any */ +#define Panel310_Custom 0x0f #define Panel_800x600 0x01 /* Unified values */ #define Panel_1024x768 0x02 @@ -225,31 +328,48 @@ #define Panel_1400x1050 0x09 #define Panel_1280x768 0x0a /* LVDS only */ #define Panel_1600x1200 0x0b -#define Panel_320x480 0x0c /* fstn - TW: This is fake, can be any */ - -#define 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 */ - -/* LCDInfo */ -#define LCDRGB18Bit 0x01 -#define LCDNonExpanding 0x10 -#define LCDNonExpandingShift 4 -#define LCDSync 0x20 -#define LCDPass11 0x100 -#define LCDSyncBit 0xe0 -#define LCDSyncShift 6 - -#define LCDDataLen 8 -#define HiTVDataLen 12 -#define TVDataLen 16 -#define SetPALTV 0x0100 -#define HalfDCLK 0x1000 /* modeflag */ +#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 + +/* Index in ModeResInfo table */ +#define SIS_RI_320x200 0 +#define SIS_RI_320x240 1 +#define SIS_RI_320x400 2 +#define SIS_RI_400x300 3 +#define SIS_RI_512x384 4 +#define SIS_RI_640x400 5 +#define SIS_RI_640x480 6 +#define SIS_RI_800x600 7 +#define SIS_RI_1024x768 8 +#define SIS_RI_1280x1024 9 +#define SIS_RI_1600x1200 10 +#define SIS_RI_1920x1440 11 +#define SIS_RI_2048x1536 12 +#define SIS_RI_720x480 13 +#define SIS_RI_720x576 14 +#define SIS_RI_1280x960 15 +#define SIS_RI_800x480 16 +#define SIS_RI_1024x576 17 +#define SIS_RI_1280x720 18 +#define SIS_RI_856x480 19 +#define SIS_RI_1280x768 20 +#define SIS_RI_1400x1050 21 +#define SIS_RI_1152x864 22 /* Up to this SiS conforming */ +#define SIS_RI_848x480 23 +#define SIS_RI_1360x768 24 +#define SIS_RI_1024x600 25 +#define SIS_RI_1152x768 26 +#define SIS_RI_768x576 27 +#define SIS_RI_1360x1024 28 + +/* CR5F */ +#define IsM650 0x80 + +/* Timing data */ #define NTSCHT 1716 #define NTSC2HT 1920 #define NTSCVT 525 @@ -262,37 +382,44 @@ #define ExtHiTVHT 2100 #define ExtHiTVVT 1125 -#define VCLKStartFreq 25 -#define SoftDramType 0x80 - -#define VCLK40 0x04 /* Index in VCLKData array */ -#define VCLK65 0x09 /* Index in VCLKData array */ -#define VCLK108_2 0x14 /* Index in VCLKData array */ -#define TVVCLKDIV2 0x21 /* Indices in (VB)VCLKData arrays */ -#define TVVCLK 0x22 -#define HiTVVCLKDIV2 0x23 -#define HiTVVCLK 0x24 -#define HiTVSimuVCLK 0x25 -#define HiTVTextVCLK 0x26 - -#define LoadDACFlag 0x1000 -#define AfterLockCRT2 0x4000 -#define SetCRT2ToAVIDEO 0x0004 -#define SetCRT2ToSCART 0x0010 -#define Ext2StructSize 5 +/* Indices in (VB)VCLKData tables */ + +#define VCLK28 0x00 /* Index in VCLKData table (300 and 315) */ +#define VCLK40 0x04 /* Index in VCLKData table (300 and 315) */ +#define VCLK65_300 0x09 /* Index in VCLKData table (300) */ +#define VCLK108_2_300 0x14 /* Index in VCLKData table (300) */ +#define VCLK81_300 0x3f /* Index in VCLKData table (300) */ +#define VCLK108_3_300 0x42 /* Index in VCLKData table (300) */ +#define VCLK100_300 0x43 /* Index in VCLKData table (300) */ +#define VCLK34_300 0x3d /* Index in VCLKData table (300) */ +#define VCLK65_315 0x0b /* Index in (VB)VCLKData table (315) */ +#define VCLK108_2_315 0x19 /* Index in (VB)VCLKData table (315) */ +#define VCLK81_315 0x5b /* Index in (VB)VCLKData table (315) */ +#define VCLK162_315 0x21 /* Index in (VB)VCLKData table (315) */ +#define VCLK108_3_315 0x45 /* Index in VBVCLKData table (315) */ +#define VCLK100_315 0x46 /* Index in VBVCLKData table (315) */ +#define VCLK34_315 0x55 /* Index in VBVCLKData table (315) */ +#define VCLK68_315 0x0d + +#define TVCLKBASE_300 0x21 /* Indices on TV clocks in VCLKData table (300) */ +#define TVCLKBASE_315 0x3a /* Indices on TV clocks in (VB)VCLKData table (315) */ +#define TVVCLKDIV2 0x00 /* Index relative to TVCLKBASE */ +#define TVVCLK 0x01 /* Index relative to TVCLKBASE */ +#define HiTVVCLKDIV2 0x02 /* Index relative to TVCLKBASE */ +#define HiTVVCLK 0x03 /* Index relative to TVCLKBASE */ +#define HiTVSimuVCLK 0x04 /* Index relative to TVCLKBASE */ +#define HiTVTextVCLK 0x05 /* Index relative to TVCLKBASE */ + +/* ------------------------------ */ #define SetSCARTOutput 0x01 -#define AVIDEOSense 0x01 -#define SVIDEOSense 0x02 -#define SCARTSense 0x04 -#define LCDSense 0x08 -#define Monitor1Sense 0x20 -#define Monitor2Sense 0x10 -#define HiTVSense 0x40 -#define BoardTVType 0x02 + #define HotPlugFunction 0x08 + #define StStructSize 0x06 +#define SIS_VIDEO_CAPTURE 0x00 - 0x30 +#define SIS_VIDEO_PLAYBACK 0x02 - 0x30 #define SIS_CRT2_PORT_04 0x04 - 0x30 #define SIS_CRT2_PORT_10 0x10 - 0x30 #define SIS_CRT2_PORT_12 0x12 - 0x30 @@ -305,8 +432,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 @@ -317,8 +447,6 @@ #define SoftSettingAddr 0x52 #define ModeSettingAddr 0x53 -#define SelectCRT1Rate 0x4 - #define _PanelType00 0x00 #define _PanelType01 0x08 #define _PanelType02 0x10 @@ -337,7 +465,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 @@ -380,7 +509,7 @@ /* ============================================================= - for 310/325 series + for 315 series ============================================================= */ #define SoftDRAMType 0x80 diff --git a/src/oem300.h b/src/oem300.h index 8f7e524..b594b4b 100644 --- a/src/oem300.h +++ b/src/oem300.h @@ -1,6 +1,37 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/oem300.h,v 1.3 2003/02/10 01:14:16 tsi Exp $ */ - -/* OEM Data for 300 series */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/oem300.h,v 1.11 2003/10/30 18:53:42 twini Exp $ */ +/* + * OEM Data for 300 series + * + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the linux kernel, the contents of this file + * is entirely covered by the GPL. + * + * Otherwise, the following 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. + * + * 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 <thomas@winischhofer.net> + * + * Based on code by Silicon Intergrated Systems + * + */ const UCHAR SiS300_OEMTVDelay301[8][4] = { @@ -246,140 +277,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} } }; @@ -681,325 +696,147 @@ const UCHAR SiS300_Filter2[10][9][7] = } }; -const UCHAR SiS300_LCDHData[24][11][5] = { - { - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x65,0xef,0x83,0x5c,0x00}, - {0x65,0xef,0x83,0x5c,0x00}, - {0x8a,0x14,0x00,0x80,0x00}, - {0x8a,0x14,0x00,0x80,0x00} - }, - { - {0x4e,0x18,0x90,0x38,0x00}, - {0x4e,0x18,0x90,0x38,0x00}, - {0x8e,0x18,0x28,0x78,0x00}, - {0x8e,0x18,0x28,0x78,0x00}, - {0x8e,0x18,0x28,0x78,0x00}, - {0x4e,0x18,0x90,0x38,0x00}, - {0x4e,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9a,0x56,0x00}, - {0x67,0x11,0x9a,0x56,0x00}, - {0x8a,0x14,0x00,0x80,0x00}, - {0x8a,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x65,0xef,0x83,0x5c,0x00}, - {0x65,0xef,0x83,0x5c,0x00}, - {0x8a,0x14,0x00,0x80,0x00}, - {0x8a,0x14,0x00,0x80,0x00} - }, - { - {0x4e,0x18,0x90,0x38,0x00}, - {0x4e,0x18,0x90,0x38,0x00}, - {0x8e,0x18,0x28,0x78,0x00}, - {0x8e,0x18,0x28,0x78,0x00}, - {0x8e,0x18,0x28,0x78,0x00}, - {0x4e,0x18,0x90,0x38,0x00}, - {0x4e,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9a,0x56,0x00}, - {0x67,0x11,0x9a,0x56,0x00}, - {0x8a,0x14,0x00,0x80,0x00}, - {0x8a,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x67,0x91,0x84,0x5e,0x00}, - {0x65,0xef,0x83,0x5c,0x00}, - {0x65,0xef,0x83,0x5c,0x00}, - {0x8a,0x14,0x00,0x80,0x00}, - {0x8a,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x67,0x91,0x84,0x5E,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x65,0xEF,0x83,0x5C,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} - }, - { - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x8E,0x18,0x28,0x78,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x4E,0x18,0x90,0x38,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x67,0x11,0x9A,0x56,0x00}, - {0x8A,0x14,0x00,0x80,0x00}, - {0x8A,0x14,0x00,0x80,0x00} +/* Custom data for Barco iQ Pro R300 */ +const UCHAR barco_p1[2][9][7][3] = { + { + { { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x19, 0x00 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x1e, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x16, 0x00 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x19, 0x00 }, + { 0, 0, 0 } + }, + { + { 0, 0, 0 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x1e, 0x00 }, + { 0, 0, 0 } + }, + { + { 0x16, 0xd1, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x11, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x26, 0x00 } + }, + { + { 0x16, 0xd1, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x30, 0x00 }, + { 0, 0, 0 } + }, + { + { 0x16, 0x00, 0x00 }, + { 0x17, 0xa0, 0x00 }, + { 0x1a, 0xa0, 0x00 }, + { 0x1b, 0x2a, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0, 0, 0 } + }, + { + { 0x16, 0x00, 0x00 }, + { 0x17, 0xaa, 0x00 }, + { 0x1a, 0xa0, 0x00 }, + { 0x1b, 0x2a, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0, 0, 0 } + } + }, + { + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x19, 0x00 } + }, + { + { 0, 0, 0 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x19, 0x00 }, + }, + { + { 0, 0, 0 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x1e, 0x00 } + }, + { + { 0x16, 0xd1, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe6, 0x00 }, + { 0x1b, 0x11, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x26, 0x00 } + }, + { + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe0, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x30, 0x00 }, + { 0, 0, 0 } + }, + { + { 0, 0, 0 } + }, + { + { 0, 0, 0 } + } } }; -#if 0 -const UCHAR SiS300_LCDVData[24][11][6] = { - { - { - }, -}; -#endif + + + + + diff --git a/src/oem310.h b/src/oem310.h index c4415aa..cc5e527 100644 --- a/src/oem310.h +++ b/src/oem310.h @@ -1,14 +1,39 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/oem310.h,v 1.4 2003/02/10 01:14:16 tsi Exp $ */ - -/* OEM Data for 310/325 series */ - -const UCHAR SiS310_CRT2DelayCompensation1 = 0x04; /* 301 */ - -const UCHAR SiS310_CRT2DelayCompensation2 = 0x00; /* 301B */ - -const UCHAR SiS310_CRT2DelayCompensation3 = 0x00; /* LVDS */ - -const UCHAR SiS310_LCDDelayCompensation1[] = /* 301 */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/oem310.h,v 1.18 2003/10/30 18:53:42 twini Exp $ */ +/* + * OEM Data for 315/330 series + * + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the linux kernel, the contents of this file + * is entirely covered by the GPL. + * + * Otherwise, the following 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. + * + * 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 <thomas@winischhofer.net> + * + * Based on code by Silicon Intergrated Systems + * + */ + +static const UCHAR SiS310_LCDDelayCompensation_301[] = /* 301 */ { 0x00,0x00,0x00, /* 800x600 */ 0x0b,0x0b,0x0b, /* 1024x768 */ @@ -27,7 +52,8 @@ const UCHAR SiS310_LCDDelayCompensation1[] = /* 301 */ 0x00,0x00,0x00 }; -UCHAR SiS310_LCDDelayCompensation2[] = /* 30xB,LV,LVX */ +/* This is contained in 650+301B BIOSes, but it is wrong - so we don't use it */ +static const UCHAR SiS310_LCDDelayCompensation_650301B[] = /* 30xB,LV */ { 0x01,0x01,0x01, /* 800x600 */ 0x01,0x01,0x01, /* 1024x768 */ @@ -46,7 +72,27 @@ UCHAR SiS310_LCDDelayCompensation2[] = /* 30xB,LV,LVX */ 0x02,0x02,0x02 }; -const UCHAR SiS310_LCDDelayCompensation3[] = /* LVDS */ +/* This data is correct, so we use it instead of the table above */ +static const UCHAR SiS310_LCDDelayCompensation_3xx301B[] = /* 30xB,LV */ +{ + 0x01,0x01,0x01, /* 800x600 */ + 0x0C,0x0C,0x0C, /* 1024x768 */ + 0x0C,0x0C,0x0C, /* 1280x1024 */ + 0x08,0x08,0x08, /* 640x480 */ + 0x0C,0x0C,0x0C, /* 1024x600 (guessed) */ + 0x0C,0x0C,0x0C, /* 1152x864 (guessed) */ + 0x0C,0x0C,0x0C, /* 1280x960 (guessed) */ + 0x0C,0x0C,0x0C, /* 1152x768 (guessed) */ + 0x0C,0x0C,0x0C, /* 1400x1050 (guessed) */ + 0x0C,0x0C,0x0C, /* 1280x768 (guessed) */ + 0x0C,0x0C,0x0C, /* 1600x1200 (guessed) */ + 0x02,0x02,0x02, + 0x02,0x02,0x02, + 0x02,0x02,0x02, + 0x02,0x02,0x02 +}; + +static const UCHAR SiS310_LCDDelayCompensation_LVDS650[] = /* LVDS */ { 0x00,0x00,0x00, /* 800x600 */ 0x00,0x00,0x00, /* 1024x768 */ @@ -65,47 +111,28 @@ const UCHAR SiS310_LCDDelayCompensation3[] = /* LVDS */ 0x00,0x00,0x00 }; -const UCHAR SiS310_LCDDelayCompensation4[] = /* 650 */ -{ - 0x01,0x01,0x01, /* 800x600 (guessed)*/ - 0x01,0x01,0x01, /* 1024x768 */ - 0x01,0x01,0x01, /* 1280x1024 */ - 0x01,0x01,0x01, /* 640x480 (unknown) */ - 0x01,0x01,0x01, /* 1024x600 (unknown) */ - 0x01,0x01,0x01, /* 1152x864 (unknown) */ - 0x01,0x01,0x01, /* 1280x960 (guessed) */ - 0x01,0x01,0x01, /* 1152x768 (unknown) */ - 0x01,0x01,0x01, /* 1400x1050 */ - 0x01,0x01,0x01, /* 1280x768 (guessed) */ - 0x01,0x01,0x01, /* 1600x1200 */ - 0x01,0x01,0x01, - 0x01,0x01,0x01, - 0x01,0x01,0x01, - 0x01,0x01,0x01 -}; - -const UCHAR SiS310_LCDDelayCompensation5[] = /* 650 LVX */ +static const UCHAR SiS310_LCDDelayCompensation_LVDS740[] = /* LVDS */ { - 0x01,0x01,0x01, /* 800x600 (guessed) */ - 0x01,0x01,0x01, /* 1024x768 */ - 0x01,0x01,0x01, /* 1280x1024 */ - 0x01,0x01,0x01, /* 640x480 (unknown) */ - 0x01,0x01,0x01, /* 1024x600 (unknown) */ - 0x01,0x01,0x01, /* 1152x864 (unknown) */ - 0x01,0x01,0x01, /* 1280x960 (guessed) */ - 0x01,0x01,0x01, /* 1152x768 (unknown) */ - 0x01,0x01,0x01, /* 1400x1050 */ - 0x01,0x01,0x01, /* 1280x768 (guessed) */ - 0x01,0x01,0x01, /* 1600x1200 */ - 0x01,0x01,0x01, - 0x01,0x01,0x01, - 0x01,0x01,0x01, - 0x01,0x01,0x01 + 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_LCDDelayCompensation6[] = /* M650/651 */ +static const UCHAR SiS310_LCDDelayCompensation_651301LV[] = /* M650/651 301LV */ { - 0x33,0x33,0x33, /* 800x600 (guessed) */ + 0x33,0x33,0x33, /* 800x600 (guessed) - new: PanelType, not PanelRes ! */ 0x33,0x33,0x33, /* 1024x768 */ 0x33,0x33,0x33, /* 1280x1024 */ 0x33,0x33,0x33, /* 640x480 (unknown) */ @@ -122,7 +149,7 @@ const UCHAR SiS310_LCDDelayCompensation6[] = /* M650/651 */ 0x33,0x33,0x33 }; -const UCHAR SiS310_LCDDelayCompensation7[] = /* M650/651 301LVX */ +static const UCHAR SiS310_LCDDelayCompensation_651302LV[] = /* M650/651 302LV */ { 0x33,0x33,0x33, /* 800x600 (guessed) */ 0x33,0x33,0x33, /* 1024x768 */ @@ -141,73 +168,86 @@ const UCHAR SiS310_LCDDelayCompensation7[] = /* M650/651 301LVX */ 0x33,0x33,0x33 }; -const UCHAR SiS310_TVDelayCompensation1[] = /* 301 */ +static const UCHAR SiS310_TVDelayCompensation_301[] = /* 301 */ { 0x02,0x02, /* NTSC Enhanced, Standard */ 0x02,0x02, /* PAL */ 0x08,0x0b /* HiVision */ }; -const UCHAR SiS310_TVDelayCompensation2[] = /* 301B;LV */ +static const UCHAR SiS310_TVDelayCompensation_301B[] = /* 30xB, 30xLV */ { 0x03,0x03, 0x03,0x03, 0x03,0x03 }; -const UCHAR SiS310_TVDelayCompensation3[] = /* LVDS */ -{ - 0x0a,0x0a, - 0x0a,0x0a, - 0x0a,0x0a -}; - -const UCHAR SiS310_TVDelayCompensation4[] = /* 650 */ +static const UCHAR SiS310_TVDelayCompensation_740301B[] = /* 740 + 30xB (30xLV?) */ { - 0x03,0x03, - 0x03,0x03, - 0x03,0x03 + 0x05,0x05, + 0x05,0x05, + 0x05,0x05 }; -const UCHAR SiS310_TVDelayCompensation5[] = /* 650 LVX */ +static const UCHAR SiS310_TVDelayCompensation_LVDS[] = /* LVDS */ { - 0x03,0x03, - 0x03,0x03, - 0x03,0x03 + 0x0a,0x0a, + 0x0a,0x0a, + 0x0a,0x0a }; -const UCHAR SiS310_TVDelayCompensation6[] = /* M650, 651 */ +static const UCHAR SiS310_TVDelayCompensation_651301LV[] = /* M650, 651, 301LV */ { 0x33,0x33, 0x33,0x33, 0x33,0x33 }; -const UCHAR SiS310_TVDelayCompensation7[] = /* M650, 651, LVX */ +static const UCHAR SiS310_TVDelayCompensation_651302LV[] = /* M650, 651, 302LV */ { 0x33,0x33, 0x33,0x33, 0x33,0x33 }; -const UCHAR SiS310_TVAntiFlick1[3][2] = +static const UCHAR SiS_TVDelay661_301[] = /* 661, 301 */ +{ + 0x44,0x44, + 0x44,0x44, + 0x00,0x00, + 0x44,0x44, + 0x44,0x44, + 0x44,0x44 +}; + +static const UCHAR SiS_TVDelay661_301B[] = /* 661, 301B et al */ +{ + 0x44,0x44, + 0x44,0x44, + 0x00,0x00, + 0x44,0x44, + 0x44,0x44, + 0x44,0x44 +}; + +static const UCHAR SiS310_TVAntiFlick1[3][2] = { {0x4,0x0}, {0x4,0x8}, {0x0,0x0} }; -const UCHAR SiS310_TVEdge1[3][2] = +static const UCHAR SiS310_TVEdge1[3][2] = { {0x0,0x4}, {0x0,0x4}, {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}, @@ -217,7 +257,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}, @@ -227,7 +267,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}, @@ -235,13 +275,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}, @@ -252,7 +312,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}, @@ -263,6 +323,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}, @@ -271,53 +332,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}, @@ -326,11 +343,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}, @@ -339,9 +354,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}, @@ -357,15 +373,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}, @@ -373,5 +389,200 @@ const UCHAR SiS310_TVPhaseIncr2[3][2][4] = } }; +static const UCHAR SiS661_TVPhase[] = { + 0x21,0xED,0xBA,0x08, + 0x2A,0x05,0xE3,0x00, + 0x21,0xE4,0x2E,0x9B, + 0x21,0xF4,0x3E,0xBA, + 0x1E,0x8B,0xA2,0xA7, + 0x1E,0x83,0x0A,0xE0, + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + 0x21,0xF0,0x7B,0xD6, + 0x2A,0x09,0x86,0xE9, + 0x21,0xE6,0xEF,0xA4, + 0x21,0xF6,0x94,0x46, + 0x1E,0x8B,0xA2,0xA7, + 0x1E,0x83,0x0A,0xE0, + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00 +}; + +/**************************************************************/ +/* CUSTOM TIMING DATA --------------------------------------- */ +/**************************************************************/ + +/* Inventec / Compaq Presario 3045US, 3017 */ + +static const SiS_LCDDataStruct SiS310_ExtCompaq1280x1024Data[] = +{ + { 211, 60,1024, 501,1688,1066}, + { 211, 60,1024, 508,1688,1066}, + { 211, 60,1024, 501,1688,1066}, + { 211, 60,1024, 508,1688,1066}, + { 32, 15,1696, 501,1696,1066}, + { 212, 75,1024, 621,1696,1066}, + { 4, 3,1696, 810,1696,1066}, + { 1, 1,1696,1066,1696,1066} +}; + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Compaq1280x1024_1[] = +{ + {{0x3F,0x1B,0xD0,0xF0,0xB0,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x35,0x1B,0xA0,0xC0,0x80,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x3F,0x1B,0xD0,0xF0,0xB0,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x3F,0x1B,0xD0,0xF0,0xB0,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x45,0x1C,0x20,0x3F,0xFF,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}}, + {{0x49,0x1C,0x40,0x7F,0xFF,0xAD,0x23,0x0A,0x07,0xF3,0x8A,0x12}}, + {{0x4C,0x1C,0x18,0x2F,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x48,0x1C,0x15,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}} +}; + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Compaq1280x1024_2[] = +{ + {{0x2B,0x12,0xD9,0xE5,0xD5,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}}, + {{0x22,0x12,0xC0,0xCC,0xBC,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}}, + {{0x2B,0x12,0xD9,0xE5,0xD5,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}}, + {{0x22,0x12,0xC0,0xCC,0xBC,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}}, + {{0x33,0x13,0x01,0x0D,0xFD,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}}, + {{0x3F,0x1B,0x3D,0x49,0x39,0x54,0x23,0xC0,0x27,0x66,0x30,0x42}}, + {{0x33,0x1B,0x91,0x9D,0x8D,0x8C,0x23,0xF8,0x27,0x9E,0x68,0x42}}, + {{0x43,0x24,0x11,0x1D,0x0D,0xCC,0x23,0x38,0x37,0xDE,0xA8,0x42}}, + {{0x43,0x24,0x21,0x29,0x19,0xEA,0x23,0x0A,0x07,0x32,0xC6,0x42}} +}; + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Compaq1280x1024_3[] = +{ + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBE,0x23,0x0A,0x07,0x26,0x8A,0x42}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBE,0x23,0x0A,0x07,0x26,0x8A,0x42}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBE,0x23,0x0A,0x07,0x26,0x8A,0x42}}, + {{0x47,0x1C,0x14,0x29,0xFF,0xBE,0x23,0x0A,0x07,0x26,0x8A,0x42}} +}; + +/* LCDA CRT2 data is std */ + +static const SiS_LVDSDesStruct Compaq1280x1024Des_1[] = +{ + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 } +}; + +static const SiS_LVDSDesStruct Compaq1280x1024Des_2[] = +{ + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 } +}; + +/* Clevo L285/287 (dual-link 1024x768) */ + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Clevo1024x768_1[] = +{ + {{0x25,0x12,0xC9,0xDC,0xB6,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}}, + {{0x2C,0x12,0x9A,0xAE,0x88,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}}, + {{0x25,0x12,0xC9,0xDC,0xB6,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x38,0x13,0x16,0x0C,0xE6,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}}, + {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}}, + {{0x36,0x13,0x13,0x25,0xFF,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x25,0x12,0xC9,0xDC,0xB6,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}} +}; + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Clevo1024x768_2[] = +{ + {{0x25,0x12,0x51,0x6E,0x48,0xCC,0x12,0x89,0x47,0x1C,0x49,0x33}}, + {{0x2C,0x12,0x38,0x55,0x2F,0xCC,0x12,0x89,0x47,0x1C,0x49,0x33}}, + {{0x25,0x12,0x51,0x6E,0x48,0xCC,0x12,0x89,0x47,0x1C,0x49,0x33}}, + {{0x2C,0x12,0x38,0x55,0x2F,0xE0,0x12,0xB1,0x47,0x30,0x71,0x33}}, + {{0x2D,0x12,0x79,0x96,0x70,0xCC,0x12,0x89,0x47,0x1C,0x49,0x33}}, + {{0x29,0x12,0xB5,0xD2,0xAC,0xF4,0x12,0xD9,0x47,0x44,0x99,0x33}}, + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, +#if 0 + {{0x25,0x12,0x51,0x6E,0x48,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x2C,0x12,0x38,0x55,0x2F,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x25,0x12,0x51,0x6E,0x48,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x2C,0x12,0x38,0x55,0x2F,0xC1,0x35,0xB1,0x47,0xE9,0x71,0x33}}, + {{0x2D,0x12,0x79,0x96,0x70,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}}, + {{0x29,0x12,0xB5,0xD2,0xAC,0xE9,0x35,0xD9,0x47,0x11,0x99,0x33}}, + {{0x36,0x13,0x13,0x25,0xFF,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}} +#endif +}; + +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Clevo1024x768_3[] = +{ + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, /* Corrected */ + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, + {{0x36,0x13,0x13,0x25,0xFF,0x32,0x22,0x0A,0x07,0x82,0x0A,0x12}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x25,0x13,0xC9,0x25,0xFF,0x59,0x45,0x09,0x07,0xF9,0x09,0x24}} +}; + +/* CRT2 data is std */ + +static const SiS_LVDSDesStruct Clevo1024x768Des_1[] = +{ + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 } +}; + +static const SiS_LVDSDesStruct Clevo1024x768Des_2[] = +{ + { 1184, 622 }, + { 1184, 597 }, + { 1184, 622 }, + { 1184, 597 }, + { 1152, 622 }, + { 1232, 722 }, + { 0, 0 } +}; + +/* Uniwill N243S9, ECS A928 */ + +static const SiS_LVDSDesStruct Uniwill1024x768Des_1[] = +{ + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 805 } +}; + +static const SiS_LVDSDesStruct Uniwill1024x768Des_2[] = +{ + { 1184, 622 }, + { 1184, 597 }, + { 1184, 622 }, + { 1184, 597 }, + { 1152, 650 }, + { 1232, 722 }, + { 0, 805 }, +}; diff --git a/src/osdef.h b/src/osdef.h index 039d968..7e6f472 100644 --- a/src/osdef.h +++ b/src/osdef.h @@ -1,18 +1,15 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/osdef.h,v 1.2 2003/02/10 01:14:16 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/osdef.h,v 1.5 2003/10/30 18:53:42 twini Exp $ */ /* OS depending defines */ /* The choices are: */ -/* #define WINCE_HEADER */ /* Incomplete! */ -/* #define WIN2000 */ /* Incomplete! */ -/* #define TC */ /* Incomplete! */ /* #define LINUX_KERNEL */ /* Kernel framebuffer */ #define LINUX_XF86 /* XFree86 */ /**********************************************************************/ #ifdef LINUX_KERNEL /* ----------------------------*/ - #include <linux/config.h> + #ifdef CONFIG_FB_SIS_300 #define SIS300 #endif @@ -21,62 +18,25 @@ #define SIS315H #endif -#else /* if not LINUX_KERNEL --------------------- */ -/* #define SIS300*/ -#define SIS315H - -#endif /* if LINUX_KERNEL ------------------------ */ +#if 1 +#define SISFBACCEL /* Include 2D acceleration */ +#endif -#ifdef LINUX_XF86 /* Linux Xfree86 ---------------- */ +#endif +#ifdef LINUX_XF86 /* ----------------------------- */ #define SIS300 -/* #define SIS315H */ /* TW: done above */ +#define SIS315H #endif /**********************************************************************/ -#ifdef TC -#endif -#ifdef WIN2000 -#endif -#ifdef WINCE_HEADER -#endif -#ifdef LINUX_XF86 -#endif -#ifdef LINUX_KERNEL -#endif -/**********************************************************************/ -#ifdef TC -#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize); -#endif -#ifdef WIN2000 -#define SiS_SetMemory(MemoryAddress,MemorySize,value) MemFill((PVOID) MemoryAddress,(ULONG) MemorySize,(UCHAR) value); -#endif -#ifdef WINCE_HEADER -#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize); -#endif -#ifdef LINUX_XF86 -#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize) -#endif #ifdef LINUX_KERNEL #define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize) +#define SiS_MemoryCopy(Destination,Soruce,Length) memcpy(Destination,Soruce,Length) #endif -/**********************************************************************/ - -/**********************************************************************/ -#ifdef TC -#define SiS_MemoryCopy(Destination,Soruce,Length) memmove(Destination, Soruce, Length); -#endif -#ifdef WIN2000 -#define SiS_MemoryCopy(Destination,Soruce,Length) /*VideoPortMoveMemory((PUCHAR)Destination , Soruce,length);*/ -#endif -#ifdef WINCE_HEADER -#define SiS_MemoryCopy(Destination,Soruce,Length) memmove(Destination, Soruce, Length); -#endif #ifdef LINUX_XF86 -#define SiS_MemoryCopy(Destination,Soruce,Length) memcpy(Destination,Soruce,Length) -#endif -#ifdef LINUX_KERNEL +#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize) #define SiS_MemoryCopy(Destination,Soruce,Length) memcpy(Destination,Soruce,Length) #endif @@ -107,31 +67,9 @@ #endif /* InPortLong */ /**********************************************************************/ -/* TC */ -/**********************************************************************/ - -#ifdef TC -#define OutPortByte(p,v) outp((unsigned short)(p),(unsigned char)(v)) -#define OutPortWord(p,v) outp((unsigned short)(p),(unsigned short)(v)) -#define OutPortLong(p,v) outp((unsigned short)(p),(unsigned long)(v)) -#define InPortByte(p) inp((unsigned short)(p)) -#define InPortWord(p) inp((unsigned short)(p)) -#define InPortLong(p) ((inp((unsigned short)(p+2))<<16) | inp((unsigned short)(p))) -#endif - -/**********************************************************************/ -/* LINUX XF86 */ +/* LINUX KERNEL */ /**********************************************************************/ -#ifdef LINUX_XF86 -#define OutPortByte(p,v) outb((CARD16)(p),(CARD8)(v)) -#define OutPortWord(p,v) outw((CARD16)(p),(CARD16)(v)) -#define OutPortLong(p,v) outl((CARD16)(p),(CARD32)(v)) -#define InPortByte(p) inb((CARD16)(p)) -#define InPortWord(p) inw((CARD16)(p)) -#define InPortLong(p) inl((CARD16)(p)) -#endif - #ifdef LINUX_KERNEL #define OutPortByte(p,v) outb((u8)(v),(u16)(p)) #define OutPortWord(p,v) outw((u16)(v),(u16)(p)) @@ -142,28 +80,15 @@ #endif /**********************************************************************/ -/* WIN 2000 */ +/* LINUX XF86 */ /**********************************************************************/ -#ifdef WIN2000 -#define OutPortByte(p,v) VideoPortWritePortUchar ((PUCHAR) (p), (UCHAR) (v)) -#define OutPortWord(p,v) VideoPortWritePortUshort((PUSHORT) (p), (USHORT) (v)) -#define OutPortLong(p,v) VideoPortWritePortUlong ((PULONG) (p), (ULONG) (v)) -#define InPortByte(p) VideoPortReadPortUchar ((PUCHAR) (p)) -#define InPortWord(p) VideoPortReadPortUshort ((PUSHORT) (p)) -#define InPortLong(p) VideoPortReadPortUlong ((PULONG) (p)) +#ifdef LINUX_XF86 +#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)) #endif - -/**********************************************************************/ -/* WIN CE */ -/**********************************************************************/ - -#ifdef WINCE_HEADER -#define OutPortByte(p,v) WRITE_PORT_UCHAR ((PUCHAR) (p), (UCHAR) (v)) -#define OutPortWord(p,v) WRITE_PORT_USHORT((PUSHORT) (p), (USHORT) (v)) -#define OutPortLong(p,v) WRITE_PORT_ULONG ((PULONG) (p), (ULONG) (v)) -#define InPortByte(p) READ_PORT_UCHAR ((PUCHAR) (p)) -#define InPortWord(p) READ_PORT_USHORT ((PUSHORT) (p)) -#define InPortLong(p) READ_PORT_ULONG ((PULONG) (p)) -#endif @@ -1,7 +1,8 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h,v 1.29 2003/01/29 15:42:16 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h,v 1.88 2003/11/20 19:53:23 twini Exp $ */ /* - * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Parts Copyright 2001, 2002 by Thomas Winischhofer, Vienna, Austria + * Main global data and definitions + * + * Copyright 2002, 2003 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 @@ -21,41 +22,36 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Authors: Alan Hourihane, alanh@fairlite.demon.co.uk - * Mike Chapman <mike@paranoia.com>, - * Juanjo Santamarta <santamarta@ctv.es>, - * Mitani Hiroshi <hmitani@drl.mei.co.jp> - * David Thomas <davtom@dream.org.uk>. + * Authors: + * + * ? + * Thomas Winischhofer <thomas@winischhofer.net> * - * Thomas Winischhofer <thomas@winischhofer.net>: - * - 310/325 series (315/550/650/651/740/M650) support - * - (possibly incomplete) Xabre (SiS330) support - * - new mode switching code for 300, 310/325 and 330 series - * - many fixes for 300/540/630/730 chipsets, - * - many fixes for 5597/5598, 6326 and 530/620 chipsets, - * - VESA mode switching (deprecated), - * - extended CRT2/video bridge handling support, - * - dual head support on 300, 310/325 and 330 series - * - 650/LVDS (up to 1400x1050), 650/Chrontel 701x support - * - 30xB/30xLV/30xLVX video bridge support (300, 310/325, 330 series) - * - Xv support for 5597/5598, 6326, 530/620 and 310/325 series - * - video overlay enhancements for 300 series - * - TV and hi-res support for the 6326 - * - Color hardware cursor support for 300/310/325/330 series - * - etc. */ - - #ifndef _SIS_H #define _SIS_H_ /* Always unlock the registers (should be set!) */ #define UNLOCK_ALWAYS +#define SISDRIVERVERSIONYEAR 3 +#define SISDRIVERVERSIONMONTH 11 +#define SISDRIVERVERSIONDAY 19 +#define SISDRIVERREVISION 1 + +#define SISDRIVERIVERSION (SISDRIVERVERSIONYEAR << 16) | (SISDRIVERVERSIONMONTH << 8) \ + | SISDRIVERVERSIONDAY | (SISDRIVERREVISION << 24) + #if 0 #define TWDEBUG /* for debugging */ #endif +#if 0 +#include "siscp.H" +#else +#undef SIS_CP +#endif + #include "xf86Pci.h" #include "xf86Cursor.h" #include "xf86_ansic.h" @@ -64,11 +60,20 @@ #include "xaa.h" #include "vgaHW.h" #include "vbe.h" + #include "osdef.h" #include "vgatypes.h" #include "vstruct.h" #ifdef XF86DRI +#undef SISNEWDRI +#undef SISNEWDRI2 +#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,99,14,0) +#define SISNEWDRI +#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,4,99,99,0) /* Adapt this when the time has come */ +#define SISNEWDRI2 +#endif +#endif #include "xf86drm.h" #include "sarea.h" #define _XF86DRI_SERVER_ @@ -78,35 +83,46 @@ #include "sis_dri.h" #endif -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,0,0,0) -typedef unsigned long IOADDRESS; +#if 1 +#define SISDUALHEAD /* Include Dual Head code */ #endif #if 1 -#define SISDUALHEAD /* TW: Include Dual Head code */ +#define SISMERGED /* Include Merged-FB mode */ #endif +#ifdef SISMERGED #if 1 -#define USE6326VIDEO /* TW: Include 6326/530/620 Xv code */ +#define SISXINERAMA /* Include SiS Pseudo-Xinerama for MergedFB mode */ +#define SIS_XINERAMA_MAJOR_VERSION 1 +#define SIS_XINERAMA_MINOR_VERSION 1 +#endif #endif -#if 1 /* TW: Include code for 330 - highly preliminary */ -#define INCL_SIS330 +#if 1 +#define SISGAMMA /* Include code for gamma correction */ #endif -#if 1 /* TW: Include code for cycling CRT2 type via keyboard */ -#define CYCLECRT2 /* (not functional yet) */ +#if 1 /* Include code for color hardware cursors */ +#define SIS_ARGB_CURSOR #endif -#if 1 -#define SISGAMMA /* TW: Include code for gamma correction */ +#ifdef SISMERGED +#ifdef SISXINERAMA +#define NEED_REPLIES /* ? */ +#define EXTENSION_PROC_ARGS void * +#include "extnsionst.h" /* required */ +#include "panoramiXproto.h" /* required */ +#endif #endif -#if 1 /* TW: Include code for color hardware cursors */ -#define SIS_ARGB_CURSOR +#if 1 +#define SISVRAMQ /* Use VRAM queue mode on 315 series */ #endif -/* TW: new for SiS315/550/650/740/330 - these should be moved elsewhere! */ +#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 #endif @@ -117,22 +133,25 @@ typedef unsigned long IOADDRESS; #define PCI_CHIP_SIS315PRO 0x0325 #endif #ifndef PCI_CHIP_SIS550 -#define PCI_CHIP_SIS550 0x5315 /* This is 550_VGA */ +#define PCI_CHIP_SIS550 0x5315 /* 550_VGA */ #endif #ifndef PCI_CHIP_SIS650 -#define PCI_CHIP_SIS650 0x6325 /* This is 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 #endif +#ifndef PCI_CHIP_SIS660 +#define PCI_CHIP_SIS660 0x6330 /* 661_VGA, 741_VGA, 760_VGA */ +#endif #define SIS_NAME "SIS" #define SIS_DRIVER_NAME "sis" #define SIS_MAJOR_VERSION 0 -#define SIS_MINOR_VERSION 6 +#define SIS_MINOR_VERSION 7 #define SIS_PATCHLEVEL 0 #define SIS_CURRENT_VERSION ((SIS_MAJOR_VERSION << 16) | \ - (SIS_MINOR_VERSION << 8) | SIS_PATCHLEVEL ) + (SIS_MINOR_VERSION << 8) | SIS_PATCHLEVEL ) /* pSiS->Flags (old series only) */ #define SYNCDRAM 0x00000001 @@ -148,11 +167,12 @@ typedef unsigned long IOADDRESS; #define BIOS_BASE 0xC0000 #define BIOS_SIZE 0x10000 -/* TW: New mode switching code */ #define SR_BUFFER_SIZE 5 #define CR_BUFFER_SIZE 5 -/* TW: VBFlags */ +#define SIS_VBFlagsVersion 1 + +/* 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()) */ @@ -162,40 +182,46 @@ typedef unsigned long IOADDRESS; #define TV_NTSC 0x00000010 #define TV_PAL 0x00000020 #define TV_HIVISION 0x00000040 -#define TV_TYPE (TV_NTSC | TV_PAL | TV_HIVISION) +#define TV_HIVISION_LV 0x00000080 +#define TV_TYPE (TV_NTSC | TV_PAL | TV_HIVISION | TV_HIVISION_LV) #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_CONEXANT 0x00000800 #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 CRT1_VGA 0x00000000 +#define CRT1_LCDA 0x00020000 #define VGA2_CONNECTED 0x00040000 -#define DISPTYPE_CRT1 0x00080000 /* TW: CRT1 connected and used */ +#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 -#define VB_303 0x00800000 +#define VB_30xBDH 0x00800000 /* 30xB DH version (w/o LCD support) */ #define VB_LVDS 0x01000000 #define VB_CHRONTEL 0x02000000 -#define VB_30xLV 0x04000000 -#define VB_30xLVX 0x08000000 -#define VB_TRUMPION 0x10000000 -#define VB_VIDEOBRIDGE (VB_301|VB_301B|VB_302B|VB_303|VB_30xLV|VB_30xLVX| \ - VB_LVDS|VB_CHRONTEL|VB_TRUMPION) /* TW */ -#define VB_SISBRIDGE (VB_301|VB_301B|VB_302B|VB_303|VB_30xLV|VB_30xLVX) -#define SINGLE_MODE 0x20000000 /* TW: CRT1 or CRT2; determined by DISPTYPE_CRTx */ -#define VB_DISPMODE_SINGLE SINGLE_MODE /* TW: alias */ -#define MIRROR_MODE 0x40000000 /* TW: CRT1 + CRT2 identical (mirror mode) */ -#define VB_DISPMODE_MIRROR MIRROR_MODE /* TW: alias */ -#define DUALVIEW_MODE 0x80000000 /* TW: CRT1 + CRT2 independent (dual head mode) */ -#define VB_DISPMODE_DUAL DUALVIEW_MODE /* TW: alias */ -#define DISPLAY_MODE (SINGLE_MODE | MIRROR_MODE | DUALVIEW_MODE) /* TW */ - -/* TW: pSiS->VBLCDFlags */ -#define VB_LCD_320x480 0x00000001 /* TW: DSTN/FSTN for 550 */ +#define VB_301LV 0x04000000 +#define VB_302LV 0x08000000 +#define VB_301C 0x10000000 +#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 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) */ +#define VB_DISPMODE_DUAL DUALVIEW_MODE /* alias */ +#define DISPLAY_MODE (SINGLE_MODE | MIRROR_MODE | DUALVIEW_MODE) + +/* 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 @@ -208,20 +234,22 @@ typedef unsigned long IOADDRESS; #define VB_LCD_1152x768 0x00000400 #define VB_LCD_1280x768 0x00000800 #define VB_LCD_1024x600 0x00001000 +#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_BARCO1366 0x20000000 +#define VB_LCD_CUSTOM 0x40000000 +#define VB_LCD_EXPANDING 0x80000000 -/* TW: 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) +/* PresetMode argument */ +#define SIS_MODE_SIMU 0 +#define SIS_MODE_CRT1 1 +#define SIS_MODE_CRT2 2 -/* This preliminaryly also contains SIS330 */ -#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->MiscFlags */ +#define MISC_CRT1OVERLAY 0x00000001 /* Current display mode supports overlay */ +#define MISC_PANELLINKSCALER 0x00000002 /* Panel link is currently scaling */ +#define MISC_CRT1OVERLAYGAMMA 0x00000004 /* Current display mode supports overlay gamma corr on CRT1 */ /* SiS6326Flags */ #define SIS6326_HASTV 0x00000001 @@ -231,7 +259,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 @@ -239,49 +267,125 @@ typedef unsigned long IOADDRESS; #define PDEBUG(p) #endif +#define BITMASK(h,l) (((unsigned)(1U << ((h)-(l)+1))-1)<<(l)) +#define GENMASK(mask) BITMASK(1?mask,0?mask) + typedef unsigned long ULong; typedef unsigned short UShort; typedef unsigned char UChar; -/* TW: VGA engine types */ +/* VGA engine types */ #define UNKNOWN_VGA 0 #define SIS_530_VGA 1 #define SIS_OLD_VGA 2 #define SIS_300_VGA 3 -#define SIS_315_VGA 4 - -/* TW: oldChipset */ -#define OC_UNKNOWN 0 -#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 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_SIS530A 11 #define OC_SIS530B 12 +#define OC_SIS620 13 -/* TW: Chrontel type */ +/* Chrontel type */ #define CHRONTEL_700x 0 #define CHRONTEL_701x 1 -/* Flags650 */ -#define SiS650_LARGEOVERLAY 0x00000001 +/* 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_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: Similar to Xabre, no T&L?, no P:Shader? (660, 760) */ +#define SiSCF_UseLCDA 0x01000000 +#define SiSCF_760UMA 0x10000000 /* 760: UMA active */ +#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_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 */ -/* TW: For backup of register contents */ +#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 /* + NTSC-J */ +#define SiS_CF2_TVPALM 0x20 +#define SiS_CF2_TVPALN 0x40 +#define SiS_CF2_CRT1LCDA 0x80 + +/* 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) + +/* For backup of register contents */ typedef struct { - unsigned char sisRegs3C4[0x50]; - unsigned char sisRegs3D4[0x90]; - unsigned char sisRegs3C2; - unsigned char VBPart1[0x50]; - unsigned char VBPart2[0x50]; - unsigned char VBPart3[0x50]; - unsigned char VBPart4[0x50]; - unsigned short ch70xx[64]; - unsigned long sisMMIO85C0; /* TW: Queue location for 310/325 series */ - unsigned char sis6326tv[0x46]; - unsigned long sisRegsPCI50, sisRegsPCIA0; + unsigned char sisRegs3C4[0x50]; + unsigned char sisRegs3D4[0x90]; + unsigned char sisRegs3C2; + unsigned char sisCapt[0x60]; + unsigned char sisVid[0x50]; + unsigned char VBPart1[0x50]; + unsigned char VBPart2[0x50]; + unsigned char VBPart3[0x50]; + unsigned char VBPart4[0x50]; + unsigned short ch70xx[64]; + unsigned long sisMMIO85C0; + unsigned char sis6326tv[0x46]; + unsigned long sisRegsPCI50, sisRegsPCIA0; } SISRegRec, *SISRegPtr; typedef struct _sisModeInfoPtr { @@ -292,46 +396,69 @@ typedef struct _sisModeInfoPtr { struct _sisModeInfoPtr *next; } sisModeInfoRec, *sisModeInfoPtr; -/* TW: SISFBLayout is mainly there because of DGA. It holds the - current layout parameters needed for acceleration and other - stuff. When switching mode using DGA, these are set up - accordingly and not necessarily match pScrn's. Therefore, - driver modules should read these values instead of pScrn's. +/* SISFBLayout is mainly there because of DGA. It holds the + * current layout parameters needed for acceleration and other + * stuff. When switching mode using DGA, these are set up + * accordingly and not necessarily match pScrn's. Therefore, + * driver modules should read these values instead of pScrn's. */ typedef struct { - int bitsPerPixel; /* TW: Copy from pScrn->bitsPerPixel */ - int depth; /* TW: Copy from pScrn->depth */ - int displayWidth; /* TW: Copy from pScrn->displayWidth */ - DisplayModePtr mode; /* TW: Copy from pScrn->currentMode */ + int bitsPerPixel; /* = pScrn->bitsPerPixel */ + int depth; /* = pScrn->depth */ + int displayWidth; /* = pScrn->displayWidth */ + DisplayModePtr mode; /* = pScrn->currentMode */ } SISFBLayout; -/* TW: Dual head private entity structure */ +/* Dual head private entity structure */ #ifdef SISDUALHEAD typedef struct { ScrnInfoPtr pScrn_1; ScrnInfoPtr pScrn_2; unsigned char * BIOS; - SiS_Private * SiS_Pr; /* TW: For new mode switching code */ + SiS_Private * SiS_Pr; + unsigned long agpHandle; + unsigned long agpAddr; + unsigned char *agpBase; + unsigned int agpSize; + unsigned int agpWantedSize; + unsigned int agpWantedPages; + unsigned long agpCmdBufAddr; /* 300 series */ + unsigned char *agpCmdBufBase; + unsigned int agpCmdBufSize; + unsigned int agpCmdBufFree; + unsigned long agpVtxBufAddr; /* 315 series */ + unsigned char *agpVtxBufBase; + unsigned int agpVtxBufSize; + unsigned int agpVtxBufFree; +#ifdef XF86DRI + sisRegion agp; + int drmSubFD; +#endif + Bool AGPInitOK; int CRT1ModeNo; /* Current display mode for CRT1 */ 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; - Bool NoXvideo; int forceCRT1; - int DSTN; + int DSTN, FSTN; Bool XvOnCRT2; int maxUsedClock; /* Max used pixelclock on master head */ unsigned long masterFbAddress; /* Framebuffer addresses and sizes */ @@ -349,7 +476,7 @@ typedef struct { unsigned short MapCountIOBaseDense; Bool forceUnmapIOBaseDense; /* ignore counter and unmap */ #endif - int chtvlumabandwidthcvbs; /* TW: TV settings for Chrontel TV encoder */ + int chtvlumabandwidthcvbs; /* TV settings for Chrontel TV encoder */ int chtvlumabandwidthsvideo; int chtvlumaflickerfilter; int chtvchromabandwidth; @@ -357,24 +484,57 @@ typedef struct { int chtvcvbscolor; int chtvtextenhance; int chtvcontrast; - int sistvedgeenhance; /* TW: TV settings for SiS bridge */ + int sistvedgeenhance; /* TV settings for SiS bridge */ int sistvantiflicker; int sistvsaturation; - int tvxpos; - int tvypos; + int sistvcolcalibc; + int sistvcolcalibf; + int sistvcfilter; + int sistvyfilter; + int tvxpos, tvypos; + int tvxscale, tvyscale; int ForceTVType; int chtvtype; - int NonDefaultPAL; + int NonDefaultPAL, NonDefaultNTSC; unsigned short tvx, tvy; - unsigned char p2_01, p2_02, p2_2d; + unsigned char p2_01, p2_02, p2_1f, p2_20; + 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 short cursorBufferNum; BOOLEAN restorebyset; + BOOLEAN CRT1gamma, CRT1gammaGiven, CRT2gamma, XvGamma, XvGammaGiven; + int XvGammaRed, XvGammaGreen, XvGammaBlue; + int GammaBriR, GammaBriG, GammaBriB; /* strictly for Xinerama */ + int GammaPBriR, GammaPBriG, GammaPBriB; /* strictly for Xinerama */ + int curxvcrtnum; + int UsePanelScaler; + int AllowHotkey; + BOOLEAN enablesisctrl; + unsigned long cmdQ_SharedWritePort_2D; + unsigned char *RenderAccelArray; + unsigned char * FbBase1; + unsigned long OnScreenSize1; +#ifdef SIS_CP + SIS_CP_H_ENT +#endif } SISEntRec, *SISEntPtr; #endif #define SISPTR(p) ((SISPtr)((p)->driverPrivate)) #define XAAPTR(p) ((XAAInfoRecPtr)(SISPTR(p)->AccelInfoPtr)) +/* Relative merge position */ +typedef enum { + sisLeftOf, + sisRightOf, + sisAbove, + sisBelow, + sisClone +} SiSScrn2Rel; + typedef struct { ScrnInfoPtr pScrn; /* -------------- DON'T INSERT ANYTHING HERE --------------- */ pciVideoPtr PciInfo; /* -------- OTHERWISE sis_dri.so MUST BE RECOMPILED -------- */ @@ -382,11 +542,11 @@ typedef struct { EntityInfoPtr pEnt; int Chipset; int ChipRev; - int VGAEngine; /* TW: see above */ - int hasTwoOverlays; /* TW: Chipset supports two video overlays? */ - HW_DEVICE_EXTENSION sishw_ext; /* TW: For new mode switching code */ - SiS_Private * SiS_Pr; /* TW: For new mode switching code */ - int DSTN; /* TW: For 550 FSTN/DSTN; set by option, no detection */ + int VGAEngine; /* see above */ + int hasTwoOverlays; /* Chipset supports two video overlays? */ + HW_DEVICE_EXTENSION sishw_ext; /* For new mode switching code */ + SiS_Private * SiS_Pr; /* For new mode switching code */ + int DSTN; /* For 550 FSTN/DSTN; set by option, no detection */ unsigned long FbAddress; /* VRAM physical address (in DHM: for each Fb!) */ unsigned long realFbAddress; /* For DHM/PCI mem mapping: store global FBAddress */ unsigned char * FbBase; /* VRAM virtual linear address */ @@ -396,7 +556,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; @@ -414,37 +574,38 @@ typedef struct { int numDGAModes; Bool DGAactive; int DGAViewportStatus; - int OldMode; /* TW: Back old modeNo (if available) */ + unsigned char OldMode; /* Back old modeNo (if available) */ Bool NoAccel; Bool NoXvideo; - Bool XvOnCRT2; /* TW: see sis_opt.c */ + Bool XvOnCRT2; /* see sis_opt.c */ Bool HWCursor; Bool UsePCIRetry; Bool TurboQueue; int VESA; + int ForceCRT1Type; int ForceCRT2Type; int OptTVStand; int OptTVOver; int OptROMUsage; int UseCHOverScan; Bool ValidWidth; - Bool FastVram; /* TW: now unused */ + Bool FastVram; /* now unused */ int forceCRT1; Bool CRT1changed; - unsigned char oldCR17; + unsigned char oldCR17, oldCR63, oldSR1F; unsigned char oldCR32; unsigned char newCR32; - int VBFlags; /* TW: Video bridge configuration */ - int VBFlags_backup; /* TW: Backup for SlaveMode-modes */ - int VBLCDFlags; /* TW: Moved LCD panel size bits here */ - int ChrontelType; /* TW: CHRONTEL_700x or CHRONTEL_701x */ - int PDC; /* TW: PanelDelayCompensation */ - short scrnOffset; /* TW: Screen pitch (data) */ - short scrnPitch; /* TW: Screen pitch (display; regarding interlace) */ + 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 */ + short scrnOffset; /* Screen pitch (data) */ + short scrnPitch; /* Screen pitch (display; regarding interlace) */ short DstColor; int xcurrent; /* for temp use in accel */ int ycurrent; /* for temp use in accel */ - long SiS310_AccelDepth; /* used in accel for 310/325 series */ + long SiS310_AccelDepth; /* used in accel for 315 series */ int Xdirection; /* for temp use in accel */ int Ydirection; /* for temp use in accel */ int sisPatternReg[4]; @@ -453,20 +614,21 @@ typedef struct { int MaxCMDQueueLen; int CurCMDQueueLen; int MinCMDQueueLen; - CARD16 CursorSize; /* TW: Size of HWCursor area (bytes) */ - CARD32 cursorOffset; /* TW: see sis_driver.c and sis_cursor.c */ + CARD16 CursorSize; /* Size of HWCursor area (bytes) */ + CARD32 cursorOffset; /* see sis_driver.c and sis_cursor.c */ int DstX; int DstY; unsigned char * XAAScanlineColorExpandBuffers[2]; CARD32 AccelFlags; Bool ClipEnabled; Bool DoColorExpand; + Bool ColorExpandBusy; + Bool alphaBlitBusy; SISRegRec SavedReg; SISRegRec ModeReg; 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); @@ -476,23 +638,51 @@ 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); - int cmdQueueLen; /* TW: Current cmdQueueLength (for 2D and 3D) */ - int *cmdQueueLenPtr; + int cmdQueueLen; /* Current cmdQueueLength (for 2D and 3D) */ + unsigned long cmdQueueLenMax; + unsigned long cmdQueueLenMin; + unsigned long *cmdQueueBase; + int *cmdQueueLenPtr; /* Ptr to variable holding the current queue length */ + int *cmdQueueLenPtrBackup; /* Backup for DRI init/restore */ + unsigned int cmdQueueOffset; + unsigned int cmdQueueSize; + unsigned long cmdQueueSizeMask; + unsigned long cmdQ_SharedWritePort_2D; + unsigned long *cmdQ_SharedWritePort; + unsigned long *cmdQ_SharedWritePortBackup; + unsigned int cmdQueueSize_div2; + 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; + unsigned int agpWantedSize; + unsigned int agpWantedPages; + unsigned long agpCmdBufAddr; /* 300 series */ unsigned char *agpCmdBufBase; unsigned int agpCmdBufSize; unsigned int agpCmdBufFree; + unsigned long agpVtxBufAddr; /* 315 series */ + unsigned char *agpVtxBufBase; + unsigned int agpVtxBufSize; + unsigned int agpVtxBufFree; +#ifdef XF86DRI + sisRegion agp; +#endif + Bool AGPInitOK; Bool irqEnabled; int irq; + Bool IsAGPCard; + unsigned long DRIheapstart, DRIheapend; + + void (*RenderCallback)(ScrnInfoPtr); + Time RenderTime; + unsigned char *RenderAccelArray; + Bool doRender; int ColorExpandRingHead; int ColorExpandRingTail; @@ -501,6 +691,7 @@ typedef struct { int ColorExpandBufferCountMask; unsigned char *ColorExpandBufferAddr[32]; int ColorExpandBufferScreenOffset[32]; + long ColorExpandBase; int ImageWriteBufferSize; unsigned char *ImageWriteBufferAddr; @@ -512,6 +703,8 @@ typedef struct { unsigned char *ShadowPtr; int ShadowPitch; + Bool loadDRI; + #ifdef XF86DRI Bool directRenderingEnabled; DRIInfoPtr pDRIInfo; @@ -525,6 +718,8 @@ typedef struct { XF86VideoAdaptorPtr adaptor; ScreenBlockHandlerProcPtr BlockHandler; void (*VideoTimerCallback)(ScrnInfoPtr, Time); + void (*ResetXv)(ScrnInfoPtr); + void (*ResetXvGamma)(ScrnInfoPtr); OptionInfoPtr Options; unsigned char LCDon; @@ -533,10 +728,10 @@ typedef struct { #endif Bool Blank; unsigned char BIOSModeSave; - int CRT1off; /* TW: 1=CRT1 off, 0=CRT1 on */ - CARD16 LCDheight; /* TW: Vertical resolution of LCD panel */ - CARD16 LCDwidth; /* TW: Horizontal resolution of LCD panel */ - vbeInfoPtr pVbe; /* TW: For VESA mode switching */ + int CRT1off; /* 1=CRT1 off, 0=CRT1 on */ + CARD16 LCDheight; /* Vertical resolution of LCD panel */ + CARD16 LCDwidth; /* Horizontal resolution of LCD panel */ + vbeInfoPtr pVbe; /* For VESA mode switching */ CARD16 vesamajor; CARD16 vesaminor; VbeInfoBlock *vbeInfo; @@ -551,31 +746,28 @@ typedef struct { CARD8 *state, *pstate; void *base, *VGAbase; #ifdef SISDUALHEAD - BOOL DualHeadMode; /* TW: TRUE if we use dual head mode */ - BOOL SecondHead; /* TW: TRUE is this is the second head */ - SISEntPtr entityPrivate; /* TW: Ptr to private entity (see above) */ - BOOL SiSXinerama; /* TW: Do we use Xinerama mode? */ -#endif - SISFBLayout CurrentLayout; /* TW: Current framebuffer layout */ - Bool (*i2cInit)(ScrnInfoPtr);/* I2C stuff */ - I2CBusPtr I2C; + BOOL DualHeadMode; /* TRUE if we use dual head mode */ + BOOL SecondHead; /* TRUE is this is the second head */ + SISEntPtr entityPrivate; /* Ptr to private entity (see above) */ + BOOL SiSXinerama; /* Do we use Xinerama mode? */ +#endif + SISFBLayout CurrentLayout; /* Current framebuffer layout */ USHORT SiS_DDC2_Index; USHORT SiS_DDC2_Data; USHORT SiS_DDC2_Clk; - BOOL Primary; /* TW: Display adapter is primary */ - xf86Int10InfoPtr pInt; /* TW: Our int10 */ - int oldChipset; /* TW: Type of old chipset */ - CARD32 RealVideoRam; /* TW: 6326 can only address 4MB, but TQ can be above */ - CARD32 CmdQueLenMask; /* TW: Mask of queue length in MMIO register */ - CARD32 CmdQueLenFix; /* TW: Fix value to subtract from QueLen (530/620) */ - CARD32 CmdQueMaxLen; /* TW: (6326/5597/5598) Amount of cmds the queue can hold */ - CARD32 TurboQueueLen; /* TW: For future use */ - CARD32 detectedCRT2Devices; /* TW: detected CRT2 devices before mask-out */ - Bool NoHostBus; /* TW: Enable/disable 5597/5598 host bus */ - Bool noInternalModes; /* TW: Use our own default modes? */ - char * sbiosn; /* TW: For debug */ - int OptUseOEM; /* TW: Use internal OEM data? */ - int chtvlumabandwidthcvbs; /* TW: TV settings for Chrontel TV encoder */ + BOOL Primary; /* Display adapter is primary */ + xf86Int10InfoPtr pInt; /* Our int10 */ + int oldChipset; /* Type of old chipset */ + 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 */ + CARD32 TurboQueueLen; /* For future use */ + CARD32 detectedCRT2Devices; /* detected CRT2 devices before mask-out */ + Bool NoHostBus; /* Enable/disable 5597/5598 host bus */ + Bool noInternalModes; /* Use our own default modes? */ + int OptUseOEM; /* Use internal OEM data? */ + int chtvlumabandwidthcvbs; /* TV settings for Chrontel TV encoder */ int chtvlumabandwidthsvideo; int chtvlumaflickerfilter; int chtvchromabandwidth; @@ -583,41 +775,136 @@ typedef struct { int chtvcvbscolor; int chtvtextenhance; int chtvcontrast; - int sistvedgeenhance; /* TW: TV settings for SiS bridges */ + int sistvedgeenhance; /* TV settings for SiS bridges */ int sistvantiflicker; int sistvsaturation; - int OptTVSOver; /* TW: Chrontel 7005: Superoverscan */ - int tvxpos; - int tvypos; - int SiS6326Flags; /* TW: SiS6326 TV settings */ - int sis6326antiflicker; + int sistvcolcalibc; + int sistvcolcalibf; + int sistvcfilter; + int sistvyfilter; + int OptTVSOver; /* Chrontel 7005: Superoverscan */ + int tvxpos, tvypos; + int tvxscale, tvyscale; + int SiS6326Flags; /* SiS6326 TV settings */ int sis6326enableyfilter; int sis6326yfilterstrong; - BOOL donttrustpdc; /* TW: Don't trust the detected PDC */ + int sis6326tvplug; + int sis6326fscadjust; + BOOL sisfbfound; + BOOL donttrustpdc; /* Don't trust the detected PDC */ unsigned char sisfbpdc; - int NoYV12; /* TW: Disable Xv YV12 support (old series) */ + unsigned char sisfblcda; + int sisfbscalelcd; + unsigned long sisfbspecialtiming; + int NoYV12; /* Disable Xv YV12 support (old series) */ unsigned char postVBCR32; - int newFastVram; /* TW: Replaces FastVram */ + int newFastVram; /* Replaces FastVram */ int ForceTVType; - int NonDefaultPAL; - unsigned long lockcalls; /* TW: Count unlock calls for debug */ - unsigned short tvx, tvy; /* TW: Backup TV position registers */ - unsigned char p2_01, p2_02, p2_2d; /* TW: Backup TV position registers */ - unsigned short tvx1, tvx2, tvx3, tvy1; /* TW: Backup TV position registers */ - BOOLEAN ForceCursorOff; - BOOLEAN HaveCustomModes; + int NonDefaultPAL, NonDefaultNTSC; + 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 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]; + BOOLEAN ForceCursorOff; + BOOLEAN HaveCustomModes; BOOLEAN IsCustom; DisplayModePtr backupmodelist; int chtvtype; Atom xvBrightness, xvContrast, xvColorKey, xvHue, xvSaturation; - Atom xvAutopaintColorKey, xvSetDefaults; - unsigned long Flags650; + Atom xvAutopaintColorKey, xvSetDefaults, xvSwitchCRT; + Atom xvDisableGfx, xvDisableGfxLR, xvTVXPosition, xvTVYPosition; + Atom xvDisableColorkey, xvUseChromakey, xvChromaMin, xvChromaMax; + Atom xvInsideChromakey, xvYUVChromakey; + 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; + Atom xv_BRR2, xv_BRG2, xv_BRB2, xv_PBR2, xv_PBG2, xv_PBB2; +#ifdef TWDEBUG + Atom xv_STR; +#endif + int xv_sisdirectunlocked; + unsigned long xv_sd_result; + int CRT1isoff; +#ifdef SIS_CP + SIS_CP_H +#endif + unsigned long ChipFlags; + unsigned long SiS_SD_Flags; BOOLEAN UseHWARGBCursor; int OptUseColorCursor; int OptUseColorCursorBlend; CARD32 OptColorCursorBlendThreshold; unsigned short cursorBufferNum; + int vb; BOOLEAN restorebyset; + BOOLEAN nocrt2ddcdetection; + BOOLEAN forcecrt2redetection; + BOOLEAN CRT1gamma, CRT1gammaGiven, CRT2gamma, XvGamma, XvGammaGiven; + int XvDefCon, XvDefBri, XvDefHue, XvDefSat; + BOOLEAN XvDefDisableGfx, XvDefDisableGfxLR; + 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; + FBLinearPtr AccelLinearScratch; + void (*AccelRenderCallback)(ScrnInfoPtr); + float zClearVal; + unsigned long bClrColor, dwColor; + int AllowHotkey; + BOOLEAN enablesisctrl; + short Video_MaxWidth, Video_MaxHeight; + int FSTN; + BOOLEAN AddedPlasmaModes; + short scrnPitch2; + CARD32 CurFGCol, CurBGCol; + unsigned char * CurMonoSrc; + CARD32 * CurARGBDest; + int GammaBriR, GammaBriG, GammaBriB; + int GammaPBriR, GammaPBriG, GammaPBriB; + Bool HideHWCursor; /* Custom application */ + Bool HWCursorIsVisible; +#ifdef SISMERGED + Bool MergedFB, MergedFBAuto; + SiSScrn2Rel CRT2Position; + char * CRT2HSync; + char * CRT2VRefresh; + char * MetaModes; + ScrnInfoPtr CRT2pScrn; + DisplayModePtr CRT1Modes; + DisplayModePtr CRT1CurrentMode; + int CRT1frameX0; + int CRT1frameY0; + int CRT1frameX1; + int CRT1frameY1; + Bool CheckForCRT2; + Bool IsCustomCRT2; + BOOLEAN HaveCustomModes2; + 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; +#ifdef SISXINERAMA + Bool UseSiSXinerama; + Bool CRT2IsScrn0; + ExtensionEntry *XineramaExtEntry; + int SiSXineramaVX, SiSXineramaVY; + Bool AtLeastOneNonClone; +#endif +#endif } SISRec, *SISPtr; typedef struct _ModeInfoData { @@ -626,6 +913,32 @@ typedef struct _ModeInfoData { VbeCRTCInfoBlock *block; } ModeInfoData; +#define SDMPTR(x) ((SiSMergedDisplayModePtr)(x->currentMode->Private)) +#define CDMPTR ((SiSMergedDisplayModePtr)(pSiS->CurrentLayout.mode->Private)) + +#define BOUND(test,low,hi) { \ + if(test < low) test = low; \ + if(test > hi) test = hi; } + +#define REBOUND(low,hi,test) { \ + if(test < low) { \ + hi += test-low; \ + low = test; } \ + if(test > hi) { \ + low += test-hi; \ + hi = test; } } + +typedef struct _MergedDisplayModeRec { + DisplayModePtr CRT1; + DisplayModePtr CRT2; + SiSScrn2Rel CRT2Position; +} SiSMergedDisplayModeRec, *SiSMergedDisplayModePtr; + + +typedef struct _region { + int x0,x1,y0,y1; +} region; + typedef struct _myhddctiming { int whichone; unsigned char mask; @@ -660,6 +973,56 @@ typedef struct _chswtable { char *cardName; } chswtable; +typedef struct _customttable { + unsigned short chipID; + char *biosversion; + char *biosdate; + unsigned long bioschksum; + unsigned short biosFootprintAddr[5]; + unsigned char biosFootprintData[5]; + unsigned short pcisubsysvendor; + unsigned short pcisubsyscard; + char *vendorName; + char *cardName; + unsigned long SpecialID; + char *optionName; +} customttable; + +#ifdef SISMERGED +#ifdef SISXINERAMA +typedef struct _SiSXineramaData { + int x; + int y; + int width; + int height; +} SiSXineramaData; +#endif +#endif + +#if 0 +/* SiS Direct access for config utility */ + +#define SDC_ID 0x53495321 + +#define SDC_VERSION 1 + +#define SDC_NUM_PARM 20 +typedef struct _sisdirectcommand { + unsigned long sdc_id; + unsigned long sdc_chksum; + unsigned long sdc_header; + unsigned long sdc_command; + unsigned long sdc_parm[SDC_NUM_PARM]; +} sisdirectcommand; + +#define SDC_RESULT_OK 0x66670000 +#define SDC_RESULT_UNDEFCMD 0x66670001 + +#define SDC_CMD_GETVERSION 0x98980001 +#define SDC_CMD_CHECKMODEFORCRT2 0x98980002 +/* more to come */ +#endif + extern void sisSaveUnlockExtRegisterLock(SISPtr pSiS, unsigned char *reg1, unsigned char *reg2); extern void sisRestoreExtRegisterLock(SISPtr pSiS, unsigned char reg1, unsigned char reg2); extern void SiSOptions(ScrnInfoPtr pScrn); @@ -668,7 +1031,7 @@ extern void SiSSetup(ScrnInfoPtr pScrn); extern void SISVGAPreInit(ScrnInfoPtr pScrn); extern Bool SiSAccelInit(ScreenPtr pScreen); extern Bool SiS300AccelInit(ScreenPtr pScreen); -extern Bool SiS310AccelInit(ScreenPtr pScreen); +extern Bool SiS315AccelInit(ScreenPtr pScreen); extern Bool SiS530AccelInit(ScreenPtr pScreen); extern Bool SiSHWCursorInit(ScreenPtr pScreen); extern Bool SISDGAInit(ScreenPtr pScreen); @@ -686,11 +1049,20 @@ extern void SiS_SetCHTVcontrast(ScrnInfoPtr pScrn, int val); extern void SiS_SetSISTVedgeenhance(ScrnInfoPtr pScrn, int val); extern void SiS_SetSISTVantiflicker(ScrnInfoPtr pScrn, int val); extern void SiS_SetSISTVsaturation(ScrnInfoPtr pScrn, int val); +extern void SiS_SetSISTVcfilter(ScrnInfoPtr pScrn, int val); +extern void SiS_SetSISTVyfilter(ScrnInfoPtr pScrn, int val); +extern void SiS_SetSISTVcolcalib(ScrnInfoPtr pScrn, int val, Bool coarse); extern void SiS_SetSIS6326TVantiflicker(ScrnInfoPtr pScrn, int val); extern void SiS_SetSIS6326TVenableyfilter(ScrnInfoPtr pScrn, int val); extern void SiS_SetSIS6326TVyfilterstrong(ScrnInfoPtr pScrn, int val); extern void SiS_SetTVxposoffset(ScrnInfoPtr pScrn, int val); 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 Bool SISSwitchCRT1Status(ScrnInfoPtr pScrn, int onoff); extern int SiS_GetCHTVlumabandwidthcvbs(ScrnInfoPtr pScrn); extern int SiS_GetCHTVlumabandwidthsvideo(ScrnInfoPtr pScrn); extern int SiS_GetCHTVlumaflickerfilter(ScrnInfoPtr pScrn); @@ -702,9 +1074,14 @@ extern int SiS_GetCHTVcontrast(ScrnInfoPtr pScrn); extern int SiS_GetSISTVedgeenhance(ScrnInfoPtr pScrn); extern int SiS_GetSISTVantiflicker(ScrnInfoPtr pScrn); extern int SiS_GetSISTVsaturation(ScrnInfoPtr pScrn); +extern int SiS_GetSISTVcfilter(ScrnInfoPtr pScrn); +extern int SiS_GetSISTVyfilter(ScrnInfoPtr pScrn); +extern int SiS_GetSISTVcolcalib(ScrnInfoPtr pScrn, Bool coarse); extern int SiS_GetSIS6326TVantiflicker(ScrnInfoPtr pScrn); extern int SiS_GetSIS6326TVenableyfilter(ScrnInfoPtr pScrn); extern int SiS_GetSIS6326TVyfilterstrong(ScrnInfoPtr pScrn); extern int SiS_GetTVxposoffset(ScrnInfoPtr pScrn); 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 8db9d49..ee374d2 100644 --- a/src/sis300_accel.c +++ b/src/sis300_accel.c @@ -1,23 +1,23 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c,v 1.14 2003/01/29 15:42:16 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c,v 1.23 2003/10/30 18:53:42 twini Exp $ */ /* * 2D Acceleration for SiS300, SiS540, SiS630, SiS730, SiS530, SiS620 * * Copyright Xavier Ducoin <x.ducoin@lectra.com> - * Copyright 2002 by Thomas Winischhofer, Vienna, Austria + * Copyright 2002, 2003 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 + * 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 holders make no representations + * 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 HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * 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 HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * 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 @@ -29,6 +29,7 @@ * Thomas Winischhofer <thomas@winischhofer.net> * */ + #if 0 #define DEBUG #endif @@ -40,6 +41,7 @@ #include "xf86Pci.h" #include "compiler.h" #include "xaa.h" +#include "xaalocal.h" #include "sis.h" #include "sis300_accel.h" @@ -173,100 +175,116 @@ SiS300AccelInit(ScreenPtr pScreen) (pScrn->bitsPerPixel != 32)) return FALSE; - /* screen to screen copy - TW: We now support transparent copies */ - infoPtr->SetupForScreenToScreenCopy = SiSSetupForScreenToScreenCopy; - infoPtr->SubsequentScreenToScreenCopy = SiSSubsequentScreenToScreenCopy; - infoPtr->ScreenToScreenCopyFlags = NO_PLANEMASK | - TRANSPARENCY_GXCOPY_ONLY; + /* 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 + */ + + if(pSiS->scrnOffset < 8192) { + + /* screen to screen copy */ + infoPtr->SetupForScreenToScreenCopy = SiSSetupForScreenToScreenCopy; + infoPtr->SubsequentScreenToScreenCopy = SiSSubsequentScreenToScreenCopy; + infoPtr->ScreenToScreenCopyFlags = NO_PLANEMASK | + TRANSPARENCY_GXCOPY_ONLY; - /* solid fills */ - infoPtr->SetupForSolidFill = SiSSetupForSolidFill; - infoPtr->SubsequentSolidFillRect = SiSSubsequentSolidFillRect; + /* solid fills */ + infoPtr->SetupForSolidFill = SiSSetupForSolidFill; + infoPtr->SubsequentSolidFillRect = SiSSubsequentSolidFillRect; #ifdef TRAP - infoPtr->SubsequentSolidFillTrap = SiSSubsequentSolidFillTrap; + infoPtr->SubsequentSolidFillTrap = SiSSubsequentSolidFillTrap; #endif - infoPtr->SolidFillFlags = NO_PLANEMASK; - - /* solid line */ - infoPtr->SetupForSolidLine = SiSSetupForSolidLine; - infoPtr->SubsequentSolidTwoPointLine = SiSSubsequentSolidTwoPointLine; - infoPtr->SubsequentSolidHorVertLine = SiSSubsequentSolidHorzVertLine; - infoPtr->SolidLineFlags = NO_PLANEMASK; - - /* dashed line */ - infoPtr->SetupForDashedLine = SiSSetupForDashedLine; - infoPtr->SubsequentDashedTwoPointLine = SiSSubsequentDashedTwoPointLine; - infoPtr->DashPatternMaxLength = 64; - infoPtr->DashedLineFlags = NO_PLANEMASK | - LINE_PATTERN_MSBFIRST_LSBJUSTIFIED; - - /* 8x8 mono pattern fill */ - infoPtr->SetupForMono8x8PatternFill = SiSSetupForMonoPatternFill; - infoPtr->SubsequentMono8x8PatternFillRect = SiSSubsequentMonoPatternFill; + infoPtr->SolidFillFlags = NO_PLANEMASK; + + /* solid line */ + infoPtr->SetupForSolidLine = SiSSetupForSolidLine; + infoPtr->SubsequentSolidTwoPointLine = SiSSubsequentSolidTwoPointLine; + infoPtr->SubsequentSolidHorVertLine = SiSSubsequentSolidHorzVertLine; + infoPtr->SolidLineFlags = NO_PLANEMASK; + + /* dashed line */ + infoPtr->SetupForDashedLine = SiSSetupForDashedLine; + infoPtr->SubsequentDashedTwoPointLine = SiSSubsequentDashedTwoPointLine; + infoPtr->DashPatternMaxLength = 64; + infoPtr->DashedLineFlags = NO_PLANEMASK | + LINE_PATTERN_MSBFIRST_LSBJUSTIFIED; + + /* 8x8 mono pattern fill */ + infoPtr->SetupForMono8x8PatternFill = SiSSetupForMonoPatternFill; + infoPtr->SubsequentMono8x8PatternFillRect = SiSSubsequentMonoPatternFill; #ifdef TRAP - infoPtr->SubsequentMono8x8PatternFillTrap = SiSSubsequentMonoPatternFillTrap; + infoPtr->SubsequentMono8x8PatternFillTrap = SiSSubsequentMonoPatternFillTrap; #endif - infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | - HARDWARE_PATTERN_SCREEN_ORIGIN | - HARDWARE_PATTERN_PROGRAMMED_BITS | - NO_TRANSPARENCY | - BIT_ORDER_IN_BYTE_MSBFIRST ; + infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | + HARDWARE_PATTERN_SCREEN_ORIGIN | + HARDWARE_PATTERN_PROGRAMMED_BITS | + /* NO_TRANSPARENCY | */ + BIT_ORDER_IN_BYTE_MSBFIRST ; #ifdef STSCE - /* Screen To Screen Color Expand */ - /* TW: The hardware does support this the way we need it */ - infoPtr->SetupForScreenToScreenColorExpandFill = + /* Screen To Screen Color Expand */ + /* TW: The hardware does support this the way we need it */ + infoPtr->SetupForScreenToScreenColorExpandFill = SiSSetupForScreenToScreenColorExpand; - infoPtr->SubsequentScreenToScreenColorExpandFill = + infoPtr->SubsequentScreenToScreenColorExpandFill = SiSSubsequentScreenToScreenColorExpand; - infoPtr->ScreenToScreenColorExpandFillFlags = NO_PLANEMASK | + infoPtr->ScreenToScreenColorExpandFillFlags = NO_PLANEMASK | BIT_ORDER_IN_BYTE_MSBFIRST ; #endif #if 0 - /* CPU To Screen Color Expand --- implement another instead of this one! */ - infoPtr->SetupForCPUToScreenColorExpandFill = - SiSSetupForCPUToScreenColorExpand; - infoPtr->SubsequentCPUToScreenColorExpandFill = - SiSSubsequentCPUToScreenColorExpand; - infoPtr->ColorExpandRange = PATREGSIZE; - infoPtr->ColorExpandBase = pSiS->IOBase+PBR(0); - infoPtr->CPUToScreenColorExpandFillFlags = NO_PLANEMASK | - BIT_ORDER_IN_BYTE_MSBFIRST | - NO_TRANSPARENCY | - SYNC_AFTER_COLOR_EXPAND | - HARDWARE_PATTERN_SCREEN_ORIGIN | - HARDWARE_PATTERN_PROGRAMMED_BITS ; + /* CPU To Screen Color Expand --- implement another instead of this one! */ + infoPtr->SetupForCPUToScreenColorExpandFill = + SiSSetupForCPUToScreenColorExpand; + infoPtr->SubsequentCPUToScreenColorExpandFill = + SiSSubsequentCPUToScreenColorExpand; + infoPtr->ColorExpandRange = PATREGSIZE; + infoPtr->ColorExpandBase = pSiS->IOBase+PBR(0); + infoPtr->CPUToScreenColorExpandFillFlags = NO_PLANEMASK | + BIT_ORDER_IN_BYTE_MSBFIRST | + NO_TRANSPARENCY | + SYNC_AFTER_COLOR_EXPAND | + HARDWARE_PATTERN_SCREEN_ORIGIN | + HARDWARE_PATTERN_PROGRAMMED_BITS ; #endif - /* per-scanline color expansion (using indirect method) */ - if(pSiS->VGAEngine == SIS_530_VGA) { - pSiS->ColorExpandBufferNumber = 4; - pSiS->ColorExpandBufferCountMask = 0x03; - } else { - pSiS->ColorExpandBufferNumber = 16; - pSiS->ColorExpandBufferCountMask = 0x0F; - } - pSiS->PerColorExpandBufferSize = ((pScrn->virtualX + 31)/32) * 4; - infoPtr->NumScanlineColorExpandBuffers = pSiS->ColorExpandBufferNumber; - infoPtr->ScanlineColorExpandBuffers = (unsigned char **)&pSiS->ColorExpandBufferAddr[0]; + /* per-scanline color expansion (using indirect method) */ + if(pSiS->VGAEngine == SIS_530_VGA) { + pSiS->ColorExpandBufferNumber = 4; + pSiS->ColorExpandBufferCountMask = 0x03; + } else { + pSiS->ColorExpandBufferNumber = 16; + pSiS->ColorExpandBufferCountMask = 0x0F; + } + pSiS->PerColorExpandBufferSize = ((pScrn->virtualX + 31)/32) * 4; + infoPtr->NumScanlineColorExpandBuffers = pSiS->ColorExpandBufferNumber; + infoPtr->ScanlineColorExpandBuffers = (unsigned char **)&pSiS->ColorExpandBufferAddr[0]; - infoPtr->SetupForScanlineCPUToScreenColorExpandFill = + infoPtr->SetupForScanlineCPUToScreenColorExpandFill = SiSSetupForScanlineCPUToScreenColorExpandFill; - infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = + infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = SiSSubsequentScanlineCPUToScreenColorExpandFill; - infoPtr->SubsequentColorExpandScanline = + infoPtr->SubsequentColorExpandScanline = SiSSubsequentColorExpandScanline; - infoPtr->ScanlineCPUToScreenColorExpandFillFlags = - NO_PLANEMASK | - CPU_TRANSFER_PAD_DWORD | - SCANLINE_PAD_DWORD | - BIT_ORDER_IN_BYTE_MSBFIRST | - LEFT_EDGE_CLIPPING; + infoPtr->ScanlineCPUToScreenColorExpandFillFlags = NO_PLANEMASK | + CPU_TRANSFER_PAD_DWORD | + SCANLINE_PAD_DWORD | + BIT_ORDER_IN_BYTE_MSBFIRST | + LEFT_EDGE_CLIPPING; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Virtual screen width too large for accelerator engine\n"); + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "2D acceleration and Xv disabled\n"); + pSiS->NoXvideo = TRUE; + } #ifdef SISDUALHEAD - if (pSiS->DualHeadMode) { - infoPtr->RestoreAccelState = SiSRestoreAccelState; + if(pSiS->DualHeadMode) { + infoPtr->RestoreAccelState = SiSRestoreAccelState; } #endif @@ -286,10 +304,10 @@ SiS300AccelInit(ScreenPtr pScreen) */ AvailBufBase = pSiS->FbBase + UsableFbSize; - for (i = 0; i < pSiS->ColorExpandBufferNumber; i++) { - pSiS->ColorExpandBufferAddr[i] = AvailBufBase + - i * pSiS->PerColorExpandBufferSize; - pSiS->ColorExpandBufferScreenOffset[i] = UsableFbSize + + for(i = 0; i < pSiS->ColorExpandBufferNumber; i++) { + pSiS->ColorExpandBufferAddr[i] = AvailBufBase + + i * pSiS->PerColorExpandBufferSize; + pSiS->ColorExpandBufferScreenOffset[i] = UsableFbSize + i * pSiS->PerColorExpandBufferSize; } Avail.x1 = 0; @@ -302,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); @@ -407,17 +425,17 @@ static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, SiSSetupDSTRect(pSiS->scrnOffset, -1) if(trans_color != -1) { - SiSSetupROP(0x0A) - SiSSetupSRCTrans(trans_color) - SiSSetupCMDFlag(TRANSPARENT_BITBLT) + SiSSetupROP(0x0A) + SiSSetupSRCTrans(trans_color) + SiSSetupCMDFlag(TRANSPARENT_BITBLT) } else { - SiSSetupROP(sisALUConv[rop]) + SiSSetupROP(sisALUConv[rop]) } if(xdir > 0) { - SiSSetupCMDFlag(X_INC) + SiSSetupCMDFlag(X_INC) } if(ydir > 0) { - SiSSetupCMDFlag(Y_INC) + SiSSetupCMDFlag(Y_INC) } } @@ -433,29 +451,29 @@ static void SiSSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, srcbase = dstbase = 0; if(src_y >= 2048) { - srcbase = pSiS->scrnOffset * src_y; - src_y = 0; + srcbase = pSiS->scrnOffset * src_y; + src_y = 0; } - if( (dst_y >= pScrn->virtualY) || (dst_y >= 2048) ) { - dstbase = pSiS->scrnOffset * dst_y; - dst_y = 0; + if((dst_y >= pScrn->virtualY) || (dst_y >= 2048)) { + dstbase = pSiS->scrnOffset * dst_y; + dst_y = 0; } #ifdef SISDUALHEAD if(pSiS->VGAEngine != SIS_530_VGA) { - srcbase += HEADOFFSET; - dstbase += HEADOFFSET; + srcbase += HEADOFFSET; + dstbase += HEADOFFSET; } #endif SiSSetupSRCBase(srcbase); SiSSetupDSTBase(dstbase); if(!(pSiS->CommandReg & X_INC)) { - src_x += width-1; - dst_x += width-1; + src_x += width-1; + dst_x += width-1; } if(!(pSiS->CommandReg & Y_INC)) { - src_y += height-1; - dst_y += height-1; + src_y += height-1; + dst_y += height-1; } SiSSetupRect(width, height) SiSSetupSRCXY(src_x, src_y) @@ -473,6 +491,11 @@ SiSSetupForSolidFill(ScrnInfoPtr pScrn, PDEBUG(ErrorF("Setup SolidFill(0x%x, 0x%x, 0x%x)\n", color, rop, planemask)); + if(pSiS->disablecolorkeycurrent) { + if((CARD32)color == pSiS->colorKey) { + rop = 5; /* NOOP */ + } + } SiSSetupPATFG(color) SiSSetupDSTRect(pSiS->scrnOffset, -1) SiSSetupDSTColorDepth(pSiS->DstColor); @@ -491,13 +514,13 @@ SiSSubsequentSolidFillRect(ScrnInfoPtr pScrn, x, y, w, h)); dstbase = 0; - if (y >= 2048) { - dstbase = pSiS->scrnOffset * y; - y = 0; + if(y >= 2048) { + dstbase = pSiS->scrnOffset * y; + y = 0; } #ifdef SISDUALHEAD if(pSiS->VGAEngine != SIS_530_VGA) { - dstbase += HEADOFFSET; + dstbase += HEADOFFSET; } #endif SiSSetupDSTBase(dstbase) @@ -534,13 +557,13 @@ SiSSubsequentSolidFillTrap(ScrnInfoPtr pScrn, int y, int h, #endif dstbase = 0; - if (y >= 2048) { - dstbase=pSiS->scrnOffset*y; - y = 0; + if(y >= 2048) { + dstbase=pSiS->scrnOffset*y; + y = 0; } #ifdef SISDUALHEAD if(pSiS->VGAEngine != SIS_530_VGA) { - dstbase += HEADOFFSET; + dstbase += HEADOFFSET; } #endif SiSSetupDSTBase(dstbase) @@ -579,23 +602,23 @@ SiSSubsequentSolidFillTrap(ScrnInfoPtr pScrn, int y, int h, #endif /* Determine egde angles */ - if (dxL < 0) { dxL = -dxL; } + if(dxL < 0) { dxL = -dxL; } else { SiSSetupCMDFlag(T_L_X_INC) } - if (dxR < 0) { dxR = -dxR; } + if(dxR < 0) { dxR = -dxR; } else { SiSSetupCMDFlag(T_R_X_INC) } /* (Y direction always positive - do this anyway) */ - if (dyL < 0) { dyL = -dyL; } + if(dyL < 0) { dyL = -dyL; } else { SiSSetupCMDFlag(T_L_Y_INC) } - if (dyR < 0) { dyR = -dyR; } + if(dyR < 0) { dyR = -dyR; } else { SiSSetupCMDFlag(T_R_Y_INC) } /* Determine major axis */ - if (dxL >= dyL) { /* X is major axis */ - SiSSetupCMDFlag(T_XISMAJORL) + if(dxL >= dyL) { /* X is major axis */ + SiSSetupCMDFlag(T_XISMAJORL) } - if (dxR >= dyR) { /* X is major axis */ - SiSSetupCMDFlag(T_XISMAJORR) + if(dxR >= dyR) { /* X is major axis */ + SiSSetupCMDFlag(T_XISMAJORR) } /* Set up deltas */ @@ -652,9 +675,9 @@ SiSSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, miny = (y1 > y2) ? y2 : y1; maxy = (y1 > y2) ? y1 : y2; if(maxy >= 2048) { - dstbase = pSiS->scrnOffset * miny; - y1 -= miny; - y2 -= miny; + dstbase = pSiS->scrnOffset * miny; + y1 -= miny; + y2 -= miny; } #ifdef SISDUALHEAD if(pSiS->VGAEngine != SIS_530_VGA) { @@ -665,10 +688,10 @@ SiSSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, SiSSetupX0Y0(x1,y1) SiSSetupX1Y1(x2,y2) - if (flags & OMIT_LAST) { - SiSSetupCMDFlag(NO_LAST_PIXEL) + if(flags & OMIT_LAST) { + SiSSetupCMDFlag(NO_LAST_PIXEL) } else { - pSiS->CommandReg &= ~(NO_LAST_PIXEL); + pSiS->CommandReg &= ~(NO_LAST_PIXEL); } SiSDoCMD @@ -686,22 +709,22 @@ SiSSubsequentSolidHorzVertLine(ScrnInfoPtr pScrn, len--; /* starting point is included! */ dstbase = 0; - if((y >= 2048) || ((y + len) >= 2048)) { - dstbase = pSiS->scrnOffset * y; - y = 0; + if((y >= 2048) || ((dir != DEGREES_0) && ((y + len) >= 2048))) { + dstbase = pSiS->scrnOffset * y; + y = 0; } #ifdef SISDUALHEAD if(pSiS->VGAEngine != SIS_530_VGA) { - dstbase += HEADOFFSET; + dstbase += HEADOFFSET; } #endif SiSSetupDSTBase(dstbase) SiSSetupX0Y0(x,y) - if (dir == DEGREES_0) { - SiSSetupX1Y1(x + len, y); + if(dir == DEGREES_0) { + SiSSetupX1Y1(x + len, y); } else { - SiSSetupX1Y1(x, y + len); + SiSSetupX1Y1(x, y + len); } SiSDoCMD @@ -722,14 +745,14 @@ SiSSetupForDashedLine(ScrnInfoPtr pScrn, SiSSetupDSTColorDepth(pSiS->DstColor); SiSSetupStyleLow(*pattern) SiSSetupStyleHigh(*(pattern+4)) - SiSSetupStylePeriod(length-1); /* TW: This was missing!!! */ + SiSSetupStylePeriod(length-1); SiSSetupROP(sisPatALUConv[rop]) SiSSetupPATFG(fg) - SiSSetupCMDFlag(LINE | LINE_STYLE) /* TW: This was missing!!! */ + SiSSetupCMDFlag(LINE | LINE_STYLE) if(bg != -1) { - SiSSetupPATBG(bg) + SiSSetupPATBG(bg) } else { - SiSSetupCMDFlag(TRANSPARENT); /* TW: This was missing!!! */ + SiSSetupCMDFlag(TRANSPARENT); } } @@ -748,9 +771,9 @@ SiSSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, miny = (y1 > y2) ? y2 : y1; maxy = (y1 > y2) ? y1 : y2; if(maxy >= 2048) { - dstbase = pSiS->scrnOffset * miny; - y1 -= miny; - y2 -= miny; + dstbase = pSiS->scrnOffset * miny; + y1 -= miny; + y2 -= miny; } #ifdef SISDUALHEAD if(pSiS->VGAEngine != SIS_530_VGA) { @@ -762,9 +785,9 @@ SiSSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, SiSSetupX0Y0(x1,y1) SiSSetupX1Y1(x2,y2) if(flags & OMIT_LAST) { - SiSSetupCMDFlag(NO_LAST_PIXEL) + SiSSetupCMDFlag(NO_LAST_PIXEL) } else { - pSiS->CommandReg &= ~(NO_LAST_PIXEL); + pSiS->CommandReg &= ~(NO_LAST_PIXEL); } SiSDoCMD @@ -785,7 +808,11 @@ SiSSetupForMonoPatternFill(ScrnInfoPtr pScrn, SiSSetupPATFG(fg) SiSSetupROP(sisPatALUConv[rop]) SiSSetupCMDFlag(PATMONO) - SiSSetupPATBG(bg) + if(bg != -1) { + SiSSetupPATBG(bg) + } else { + SiSSetupCMDFlag(TRANSPARENT) + } } static void @@ -800,9 +827,9 @@ SiSSubsequentMonoPatternFill(ScrnInfoPtr pScrn, patx, paty, x, y, w, h)); dstbase = 0; - if (y >= 2048) { - dstbase = pSiS->scrnOffset * y; - y = 0; + if(y >= 2048) { + dstbase = pSiS->scrnOffset * y; + y = 0; } #ifdef SISDUALHEAD if(pSiS->VGAEngine != SIS_530_VGA) { @@ -838,9 +865,9 @@ SiSSubsequentMonoPatternFillTrap(ScrnInfoPtr pScrn, y, h, left, right, dxL, dxR, eL, eR)); dstbase = 0; - if (y >= 2048) { - dstbase=pSiS->scrnOffset*y; - y = 0; + if(y >= 2048) { + dstbase = pSiS->scrnOffset * y; + y = 0; } #ifdef SISDUALHEAD if(pSiS->VGAEngine != SIS_530_VGA) { @@ -855,22 +882,22 @@ SiSSubsequentMonoPatternFillTrap(ScrnInfoPtr pScrn, T_R_X_INC | T_R_Y_INC | BITBLT); - if (dxL < 0) { dxL = -dxL; } + if(dxL < 0) { dxL = -dxL; } else { SiSSetupCMDFlag(T_L_X_INC) } - if (dxR < 0) { dxR = -dxR; } + if(dxR < 0) { dxR = -dxR; } else { SiSSetupCMDFlag(T_R_X_INC) } - if (dyL < 0) { dyL = -dyL; } + if(dyL < 0) { dyL = -dyL; } else { SiSSetupCMDFlag(T_L_Y_INC) } - if (dyR < 0) { dyR = -dyR; } + if(dyR < 0) { dyR = -dyR; } else { SiSSetupCMDFlag(T_R_Y_INC) } /* Determine major axis */ - if (dxL >= dyL) { /* X is major axis */ - SiSSetupCMDFlag(T_XISMAJORL) + if(dxL >= dyL) { /* X is major axis */ + SiSSetupCMDFlag(T_XISMAJORL) } - if (dxR >= dyR) { /* X is major axis */ - SiSSetupCMDFlag(T_XISMAJORR) + if(dxR >= dyR) { /* X is major axis */ + SiSSetupCMDFlag(T_XISMAJORR) } SiSSetupYH(y,h) @@ -893,49 +920,6 @@ SiSSubsequentMonoPatternFillTrap(ScrnInfoPtr pScrn, /* TW: The following (already commented) functions have NOT been adapted for dual-head mode */ - -/* ------- Color Pattern Fill --- is not useful for XAA -------------- */ - -static void -SiSSetupForColorPatternFill(ScrnInfoPtr pScrn, - int patx, int paty, int rop, - unsigned int planemask, - int trans_color) -{ - SISPtr pSiS = SISPTR(pScrn); - - PDEBUG(ErrorF("Setup ColorPatFill(0x%x,0x%x, 0x%x,0x%x, 0x%x)\n", - patx, paty, rop, planemask, trans_color)); - -/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ - SiSSetupDSTRect(pSiS->scrnOffset, -1) - SiSSetupDSTColorDepth(pSiS->DstColor); - SiSSetupROP(sisPatALUConv[rop]) - SiSSetupCMDFlag(PATPATREG | X_INC | Y_INC) -} - -static void -SiSSubsequentColorPatternFill(ScrnInfoPtr pScrn, - int patx, int paty, - int x, int y, int w, int h) -{ - SISPtr pSiS = SISPTR(pScrn); - long dstbase; - - PDEBUG(ErrorF("Subsequent ColorPatFill(0x%x,0x%x, %d,%d, %d,%d)\n", - patx, paty, x, y, w, h)); - - dstbase = 0; - if (y >= 2048) { - dstbase = pSiS->scrnOffset * y; - y = 0; - } - SiSSetupDSTBase(dstbase) - SiSSetupDSTXY(x,y) - SiSSetupRect(w,h) - SiSDoCMD -} - /* ----- CPU To Screen Color Expand (single task) ------------------------- */ /* This does not work. Assumingly for the same @@ -958,11 +942,10 @@ SiSSetupForCPUToScreenColorExpand(ScrnInfoPtr pScrn, SiSSetupSRCFG(fg) SiSSetupROP(sisPatALUConv[rop]) SiSSetupCMDFlag(X_INC | Y_INC | COLOREXP) - if (bg == -1) { - SiSSetupCMDFlag(TRANSPARENT) - } - else { - SiSSetupSRCBG(bg) + if(bg == -1) { + SiSSetupCMDFlag(TRANSPARENT) + } else { + SiSSetupSRCBG(bg) } } @@ -977,9 +960,9 @@ SiSSubsequentCPUToScreenColorExpand(ScrnInfoPtr pScrn, x, y, w, h, skipleft)); dstbase = 0; - if (y >= 2048) { - dstbase = pSiS->scrnOffset * y; - y = 0; + if(y >= 2048) { + dstbase = pSiS->scrnOffset * y; + y = 0; } SiSSetupDSTBase(dstbase) @@ -1014,11 +997,11 @@ SiSSetupForScreenToScreenColorExpand(ScrnInfoPtr pScrn, /* SiSSetupSRCXY(0,0) */ if(bg == -1) { - SiSSetupCMDFlag(TRANSPARENT | ENCOLOREXP | X_INC | + SiSSetupCMDFlag(TRANSPARENT | ENCOLOREXP | X_INC | Y_INC | SRCVIDEO); } else { - SiSSetupSRCBG(bg); - SiSSetupCMDFlag(ENCOLOREXP | X_INC | Y_INC | + SiSSetupSRCBG(bg); + SiSSetupCMDFlag(ENCOLOREXP | X_INC | Y_INC | SRCVIDEO); }; } @@ -1092,23 +1075,23 @@ SiSSubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, srcbase = dstbase = 0; #ifdef pitchdw - if (newsrcy >= 2048) { - srcbase = (pScrn->displayWidth / 8) * newsrcy; - newsrcy = 0; + if(newsrcy >= 2048) { + srcbase = (pScrn->displayWidth / 8) * newsrcy; + newsrcy = 0; } #endif #ifdef nopitch srcbase = (pSiS->scrnOffset * srcy) + (srcx * ((pScrn->bitsPerPixel+7)/8)); #endif #ifdef npitch - if (srcy >= 2048) { - srcbase = pSiS->scrnOffset * srcy; - srcy = 0; + if(srcy >= 2048) { + srcbase = pSiS->scrnOffset * srcy; + srcy = 0; } #endif - if (y >= 2048) { - dstbase = pSiS->scrnOffset * y; - y = 0; + if(y >= 2048) { + dstbase = pSiS->scrnOffset * y; + y = 0; } #ifdef SISDUALHEAD if(pSiS->VGAEngine != SIS_530_VGA) { @@ -1159,97 +1142,6 @@ SiSSubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, } #endif -/* TW: TEST: Do it scanline-wise because the other way does not seem to - * be supported by the hardware. (The source pitch seems to be - * displayWidth * (bbp/8) as opposed by the XAA HOWTO, where - * it is stated that the pitch would be displayWidth pixels; - * besides, the hardware seems to ignore the source pitch - * for address increments.) - * Apart from this (which can be solved by doing the color - * expand scanline-wise), I don't know how to implement the - * offset argument. The current method (which uses hardware - * clipping) does not work. - * - * THIS DOES NOT WORK IN THE CURRENT STATE. - */ -#if 0 -static void -SiSSubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int srcx, int srcy, int offset) -{ - SISPtr pSiS = SISPTR(pScrn); - long srcbase, dstbase; - int _x0, _y0, _x1, _y1; - - int newsrcx, newsrcy; - - newsrcy = ((pSiS->scrnOffset * srcy) + (srcx * ((pScrn->bitsPerPixel+7)/8))) / - (((((w+7)/8)+3) >> 2) * 4); - /* (pScrn->displayWidth/8); */ - newsrcx = ((pSiS->scrnOffset * srcy) + (srcx * ((pScrn->bitsPerPixel+7)/8))) % - (((((w+7)/8)+3) >> 2) * 4); - /* (pScrn->displayWidth/8); */ - - xf86DrvMsg(0, X_INFO, "Sub STS CE(%d,%d, %d,%d, %d,%d, %d)\n", - x, y, w, h, srcx, srcy, skipleft); - - srcbase = dstbase = 0; - if (newsrcy >= 2048) { - srcbase = (((((w+7)/8)+3) >> 2) * 4) * newsrcy; - /* (pScrn->displayWidth/8) * newsrcy; */ - /* pSiS->scrnOffset * srcy; */ - newsrcy = 0; - } - if (y >= 2048) { - dstbase = pSiS->scrnOffset * y; - y = 0; - } -#ifdef SISDUALHEAD - srcbase += HEADOFFSET; - dstbase += HEADOFFSET; -#endif - SiSSetupDSTBase(dstbase) - - SiSSetupRect(w, 1) - - SiSSetupSRCXY(newsrcx, newsrcy) - - /* SiSSetupSRCPitch(pScrn->displayWidth/8) */ /* old: (((w+31)&0xFFE0)/8) */ - SiSSetupSRCPitch(((((w+7)/8)+3) >> 2) * 4) -#if 1 - if (offset > 0) { - SiSSetupCMDFlag(CLIPENABLE) - } else - pSiS->CommandReg &= ~CLIPENABLE; -#endif - - while (h) { - - SiSSetupSRCBase(srcbase) -#if 1 - if (offset > 0) { - _x0 = x+skipleft; - _y0 = y; - _x1 = x+w; - _y1 = y+h; - SiSSetupClipLT(_x0, _y0); - SiSSetupClipRB(_x1, _y1); - } -#endif - SiSSetupDSTXY(x,y) - - SiSDoCMD - - srcbase += ((((w+7)/8)+3) >> 2) * 4 * 8* ((pScrn->bitsPerPixel+7)/8); - /* pSiS->scrnOffset; */ - y++; - h--; - } -} -#endif - - /* ----- CPU To Screen Color Expand (scanline-wise) ----------------- */ /* We do it using the indirect method */ @@ -1265,26 +1157,21 @@ SiSSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, */ while((MMIO_IN16(pSiS->IOBase, 0x8242) & 0x1F00) != 0) {} /* WDR: == 0x10 */ -#if 0 /* TW: This is obviously not needed */ - pSiS->ColorExpandRingHead = 0; - pSiS->ColorExpandRingTail = pSiS->ColorExpandBufferNumber - 1; -#endif - SiSSetupSRCXY(0,0); SiSSetupROP(sisALUConv[rop]); SiSSetupSRCFG(fg); SiSSetupDSTRect(pSiS->scrnOffset, -1); SiSSetupDSTColorDepth(pSiS->DstColor); if(bg == -1) { - SiSSetupCMDFlag(TRANSPARENT | - ENCOLOREXP | - X_INC | Y_INC | - SRCCPUBLITBUF); + SiSSetupCMDFlag(TRANSPARENT | + ENCOLOREXP | + X_INC | Y_INC | + SRCCPUBLITBUF); } else { - SiSSetupSRCBG(bg); - SiSSetupCMDFlag(ENCOLOREXP | - X_INC | Y_INC | - SRCCPUBLITBUF); + SiSSetupSRCBG(bg); + SiSSetupCMDFlag(ENCOLOREXP | + X_INC | Y_INC | + SRCCPUBLITBUF); } } @@ -1299,13 +1186,13 @@ SiSSubsequentScanlineCPUToScreenColorExpandFill( long dstbase; dstbase = 0; - if (y >= 2048) { - dstbase = pSiS->scrnOffset * y; - y = 0; + if((y >= 2048) || ((y + h) >= 2048)) { + dstbase = pSiS->scrnOffset * y; + y = 0; } #ifdef SISDUALHEAD if(pSiS->VGAEngine != SIS_530_VGA) { - dstbase += HEADOFFSET; + dstbase += HEADOFFSET; } #endif @@ -1324,16 +1211,16 @@ SiSSubsequentScanlineCPUToScreenColorExpandFill( SiSSetupDSTBase(dstbase) - if (skipleft > 0) { - _x0 = x + skipleft; - _y0 = y; - _x1 = x + w; - _y1 = y + h; - SiSSetupClipLT(_x0, _y0); - SiSSetupClipRB(_x1, _y1); - SiSSetupCMDFlag(CLIPENABLE); + if(skipleft > 0) { + _x0 = x + skipleft; + _y0 = y; + _x1 = x + w; + _y1 = y + h; + SiSSetupClipLT(_x0, _y0); + SiSSetupClipRB(_x1, _y1); + SiSSetupCMDFlag(CLIPENABLE); } else { - pSiS->CommandReg &= (~CLIPENABLE); + pSiS->CommandReg &= (~CLIPENABLE); } SiSSetupRect(w, 1); @@ -1367,8 +1254,8 @@ SiSSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) * SiSIdle instead. */ if((MMIO_IN16(pSiS->IOBase, 0x8242) & 0xe000) != 0xe000) { - /* while ((MMIO_IN16(pSiS->IOBase, 0x8242) & 0x0080) != 0) {} */ - SiSIdle + /* while ((MMIO_IN16(pSiS->IOBase, 0x8242) & 0x0080) != 0) {} */ + SiSIdle } SiSSetupSRCBase(cbo); @@ -1382,16 +1269,7 @@ SiSSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) if(pSiS->VGAEngine == SIS_530_VGA) { while(MMIO_IN8(pSiS->IOBase, 0x8242) & 0x80) {} } - -#if 0 /* TW: What is this good for? The Head/Tail data is never ever used elsewhere! */ - pSiS->ColorExpandRingHead = newhead = - (bufno + 1) & pSiS->ColorExpandBufferCountMask; - while (newhead == pSiS->ColorExpandRingTail) { - bltbufstage = (int)((MMIO_IN16(pSiS->IOBase,0x8242) & 0x1F00) >> 8); - newtail = newhead - (bltbufstage + 1); - pSiS->ColorExpandRingTail = (newtail >= 0) ? - newtail : (pSiS->ColorExpandBufferNumber + newtail); - } -#endif } + + diff --git a/src/sis300_accel.h b/src/sis300_accel.h index 33948d0..e787005 100644 --- a/src/sis300_accel.h +++ b/src/sis300_accel.h @@ -1,40 +1,36 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h,v 1.8 2003/01/29 15:42:16 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h,v 1.16 2003/11/03 17:02:52 twini Exp $ */ /* - * 2D acceleration for SiS530/620 and 300 series + * 2D Acceleration for SiS300, SiS540, SiS630, SiS730, SiS530, SiS620 + * Definitions for the SIS engine communication * - * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Parts Copyright 2002 Thomas Winischhofer, Vienna, Austria + * Copyright Xavier Ducoin <x.ducoin@lectra.com> + * Copyright 2002, 2003 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 Alan Hourihane not be used in + * 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. Alan Hourihane makes no representations + * 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. * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * 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 - * Mike Chapman <mike@paranoia.com>, - * Juanjo Santamarta <santamarta@ctv.es>, - * Mitani Hiroshi <hmitani@drl.mei.co.jp> - * David Thomas <davtom@dream.org.uk>. - * Xavier Ducoin <x.ducoin@lectra.com> - * Thomas Winischhofer <thomas@winischhofer.net> + * Authors: + * + * Xavier Ducoin <x.ducoin@lectra.com> + * Thomas Winischhofer <thomas@winischhofer.net> + * */ - -/* Definitions for the SIS engine communication. */ - #define PATREGSIZE 384 /* Pattern register size. 384 bytes @ 0x8300 */ #define BR(x) (0x8200 | (x) << 2) #define PBR(x) (0x8300 | (x) << 2) @@ -107,9 +103,11 @@ */ -/* TW: BR(16)+2 = 0x8242 */ +/* BR(16)+2 = 0x8242 */ -#define CmdQueLen pSiS->cmdQueueLen +/* As sis_dri.c relocated the cmd-q len to the sarea, don't use it directly here */ +/* #define CmdQueLen pSiS->cmdQueueLen */ +#define CmdQueLen (*(pSiS->cmdQueueLenPtr)) #define SiSIdle \ { \ @@ -231,6 +229,7 @@ } else { \ unsigned long temp; \ temp = MMIO_IN32(pSiS->IOBase, BR(16)); \ + (void) temp; \ } \ /* Line */ @@ -295,3 +294,891 @@ MMIO_OUT32(pSiS->IOBase, 0x8250, eR);\ CmdQueLen--; + +/* Set Pattern register */ +#define SiSSetPattern(num, value) \ + if (CmdQueLen <= 0) SiSIdle; \ + MMIO_OUT32(pSiS->IOBase, (PATTERN_REG + (num * 4)), value); \ + CmdQueLen--; + + +/* 3D stuff (used for RENDER) */ + +/* + * Register Addresses of 300/630/730/(540?) + */ +#define REG_3D_TSFSa 0x8800 +#define REG_3D_TSZa 0x8804 +#define REG_3D_TSXa 0x8808 +#define REG_3D_TSYa 0x880C +#define REG_3D_TSARGBa 0x8810 +#define REG_3D_TSWGa 0x8814 +#define REG_3D_TSUAa 0x8818 +#define REG_3D_TSVAa 0x881C +#define REG_3D_TSUBa 0x8820 +#define REG_3D_TSVBa 0x8824 +#define REG_3D_TSUCa 0x8828 +#define REG_3D_TSVCa 0x882C + +#define REG_3D_TSFSb 0x8830 +#define REG_3D_TSZb 0x8834 +#define REG_3D_TSXb 0x8838 +#define REG_3D_TSYb 0x883C +#define REG_3D_TSARGBb 0x8840 +#define REG_3D_TSWGb 0x8844 +#define REG_3D_TSUAb 0x8848 +#define REG_3D_TSVAb 0x884C +#define REG_3D_TSUBb 0x8850 +#define REG_3D_TSVBb 0x8854 +#define REG_3D_TSUCb 0x8858 +#define REG_3D_TSVCb 0x885C + +#define REG_3D_TSFSc 0x8860 +#define REG_3D_TSZc 0x8864 +#define REG_3D_TSXc 0x8868 +#define REG_3D_TSYc 0x886C +#define REG_3D_TSARGBc 0x8870 +#define REG_3D_TSWGc 0x8874 +#define REG_3D_TSUAc 0x8878 +#define REG_3D_TSVAc 0x887C +#define REG_3D_TSUBc 0x8880 +#define REG_3D_TSVBc 0x8884 +#define REG_3D_TSUCc 0x8888 +#define REG_3D_TSVCc 0x888C + +/* + * REG_3D_AGPCmdSetting (89e4h-89f7) + */ +#define REG_3D_AGPCmBase 0x89E4 +#define REG_3D_AGPRmDwNum 0x89E8 +#define REG_3D_AGPTtDwNum 0x89EC +#define REG_3D_AGPCmFire 0x89F0 + +#define REG_3D_ParsingSet 0x89F4 +#define REG_3D_PrimitiveSet 0x89F8 +#define REG_3D_ShadeMode 0x89F8 +#define REG_3D_EngineFire 0x89FC +#define REG_3D_EngineStatus 0x89FC +#define REG_3D_TEnable 0x8A00 +#define REG_3D_TEnable2 0x8A04 + +#define REG_3D_ZSet 0x8A08 +#define REG_3D_ZBias 0x8A0C +#define REG_3D_ZStWriteMask 0x8A10 + +#define REG_3D_ZAddress 0x8A14 +#define REG_3D_AlphaSet 0x8A18 +#define REG_3D_AlphaAddress 0x8A1C +#define REG_3D_DstSet 0x8A20 +#define REG_3D_DstAlphaWriteMask 0x8A24 + +#define REG_3D_DstAddress 0x8A28 + +#define REG_3D_LinePattern 0x8A2C + +#define REG_3D_FogSet 0x8A30 + +#define REG_3D_FogFarDistance 0x8A34 +#define REG_3D_FogInverseDistance 0x8A38 +#define REG_3D_FogFactorDensity 0x8A3C + +#define REG_3D_StencilSet 0x8A44 +#define REG_3D_StencilSet2 0x8A48 +#define REG_3D_StencilAddress 0x8A4C + +#define REG_3D_DstBlendMode 0x8A50 +#define REG_3D_SrcBlendMode 0x8A50 +#define REG_3D_ClipTopBottom 0x8A54 +#define REG_3D_ClipLeftRight 0x8A58 + +#define REG_3D_Brightness 0x8A5C + +#define REG_3D_BumpMapSet 0x8A68 +#define REG_3D_BumpMapAddress 0x8A6C +#define REG_3D_BumpMapPitch 0x8A70 +#define REG_3D_BumpMapMatrix0 0x8A74 +#define REG_3D_BumpMapMatrix1 0x8A78 + +/* + * Texture Registers + */ +#define REG_3D_TextureSet 0x8A7C +#define REG_3D_TextureWidthHeight 0x8A7C +#define REG_3D_TextureMip 0x8A80 + +#define REG_3D_TextureTransparencyColorHigh 0x8A84 +#define REG_3D_TextureTransparencyColorLow 0x8A88 +#define REG_3D_TextureBorderColor 0x8A8C +#define REG_3D_TextureAddress0 0x8A90 +#define REG_3D_TextureAddress1 0x8A94 +#define REG_3D_TextureAddress2 0x8A98 +#define REG_3D_TextureAddress3 0x8A9C +#define REG_3D_TextureAddress4 0x8AA0 +#define REG_3D_TextureAddress5 0x8AA4 +#define REG_3D_TextureAddress6 0x8AA8 +#define REG_3D_TextureAddress7 0x8AAC +#define REG_3D_TextureAddress8 0x8AB0 +#define REG_3D_TextureAddress9 0x8AB4 +#define REG_3D_TextureAddress10 0x8AB8 +#define REG_3D_TextureAddress11 0x8ABC +#define REG_3D_TexturePitch0 0x8AC0 +#define REG_3D_TexturePitch1 0x8AC0 +#define REG_3D_TexturePitch2 0x8AC4 +#define REG_3D_TexturePitch3 0x8AC4 +#define REG_3D_TexturePitch4 0x8AC8 +#define REG_3D_TexturePitch5 0x8AC8 +#define REG_3D_TexturePitch6 0x8ACC +#define REG_3D_TexturePitch7 0x8ACC +#define REG_3D_TexturePitch8 0x8AD0 +#define REG_3D_TexturePitch9 0x8AD0 +#define REG_3D_TexturePitch10 0x8AD4 + +#define REG_3D_Texture1Set 0x8ADC +#define REG_3D_Texture1WidthHeight 0x8ADC +#define REG_3D_Texture1Mip 0x8AE0 + +#define REG_3D_Texture1TransparencyColorHigh 0x8AE4 +#define REG_3D_Texture1TransparencyColorLow 0x8AE8 +#define REG_3D_Texture1BorderColor 0x8AEC +#define REG_3D_Texture1Address0 0x8AF0 +#define REG_3D_Texture1Address1 0x8AF4 +#define REG_3D_Texture1Address2 0x8AF8 +#define REG_3D_Texture1Address3 0x8AFC +#define REG_3D_Texture1Address4 0x8B00 +#define REG_3D_Texture1Address5 0x8B04 +#define REG_3D_Texture1Address6 0x8B08 +#define REG_3D_Texture1Address7 0x8B0C +#define REG_3D_Texture1Address8 0x8B10 +#define REG_3D_Texture1Address9 0x8B14 +#define REG_3D_Texture1Address10 0x8B18 +#define REG_3D_Texture1Address11 0x8B1C +#define REG_3D_Texture1Pitch0 0x8B20 +#define REG_3D_Texture1Pitch1 0x8B20 +#define REG_3D_Texture1Pitch2 0x8B24 +#define REG_3D_Texture1Pitch3 0x8B24 +#define REG_3D_Texture1Pitch4 0x8B28 +#define REG_3D_Texture1Pitch5 0x8B28 +#define REG_3D_Texture1Pitch6 0x8B2C +#define REG_3D_Texture1Pitch7 0x8B2C +#define REG_3D_Texture1Pitch8 0x8B30 +#define REG_3D_Texture1Pitch9 0x8B30 +#define REG_3D_Texture1Pitch10 0x8B34 + +#define REG_3D_TextureBlendFactor 0x8B3C +#define REG_3D_TextureColorBlendSet0 0x8B40 +#define REG_3D_TextureColorBlendSet1 0x8B44 +#define REG_3D_TextureAlphaBlendSet0 0x8B48 +#define REG_3D_TextureAlphaBlendSet1 0x8B4C + +#define REG_3D_EndPrimitiveList 0x8B50 + +#define REG_3D_Stipple0 0x8B60 + +#define REG_3D_TexturePalette 0x8C00 + +/* + * REG_3D_ParsingSet - Parsing Mask (89F4h-89F7h) + */ +#define MASK_VertexDWSize 0xF0000000 +#define MASK_VertexDataFormat 0x0FFF0000 +#define MASK_PsVertex_HAS_RHW 0x08000000 +#define MASK_PsVertex_HAS_NORMALXYZ 0x04000000 +#define MASK_PsVertex_HAS_DIFFUSE 0x02000000 +#define MASK_PsVertex_HAS_SPECULAR 0x01000000 +#define MASK_PsUVSet 0x00FF0000 +#define MASK_PsVertex_HAS_1SetUV 0x00800000 +#define MASK_PsVertex_HAS_2SetUV 0x00C00000 +#define MASK_PsVertex_HAS_3SetUV 0x00E00000 +#define MASK_PsVertex_HAS_UVSet1 0x00800000 +#define MASK_PsVertex_HAS_UVSet2 0x00400000 +#define MASK_PsVertex_HAS_UVSet3 0x00200000 +#define MASK_PsCullDirection_CCW 0x00008000 +#define MASK_PsShadingMode 0x00007000 +#define MASK_PsTextureFrom 0x000003F0 +#define MASK_PsTexture0FromA 0x00000000 +#define MASK_PsTexture1FromA 0x00000000 +#define MASK_PsTexture1FromB 0x00000040 +#define MASK_PsBumpTextureFromA 0x00000000 +#define MASK_PsBumpTextureFromB 0x00000010 +#define MASK_PsBumpTextureFromC 0x00000020 +#define MASK_PsDataType 0x0000000F +#define MASK_PsPointList 0x00000000 +#define MASK_PsLineList 0x00000004 +#define MASK_PsLineStrip 0x00000005 +#define MASK_PsTriangleList 0x00000008 +#define MASK_PsTriangleStrip 0x00000009 +#define MASK_PsTriangleFan 0x0000000A +/* + * REG_3D_PrimitiveSet - Fire Primitive Mask (89F8h-89FBh) + */ +#define MASK_DrawPrimitiveCommand 0x00000007 +#define MASK_SetFirePosition 0x00001F00 +#define MASK_BumpTextureFrom 0x00030000 +#define MASK_Texture1From 0x000C0000 +#define MASK_Texture0From 0x00300000 +#define MASK_ShadingMode 0x07000000 +#define MASK_CullDirection 0x08000000 +/* + * Command Queue Length Mask (89FCh-89FF) + */ +#define MASK_CmdQueueLen 0x0FFF0000 + +/* + * REG_3D_TEnable - Capability Enable Mask (8A00h-8A03h) + */ +#define MASK_DitherEnable 0x00000001 +#define MASK_BlendEnable 0x00000002 +#define MASK_FogTestEnable 0x00000004 +#define MASK_FogEnable 0x00000008 +#define MASK_SpecularEnable 0x00000010 +#define MASK_FogPerspectiveEnable 0x00000020 +#define MASK_TextureCacheClear 0x00000040 +#define MASK_TextureCacheEnable 0x00000080 +#define MASK_BumpMapEnable 0x00000100 +#define MASK_TexturePerspectiveEnable 0x00000200 +#define MASK_TextureEnable 0x00000400 +#define MASK_CullEnable 0x00000800 +#define MASK_TextureNumUsed 0x0000F000 +#define MASK_AlphaBufferEnable 0x00010000 +#define MASK_AlphaTestEnable 0x00020000 +#define MASK_AlphaWriteEnable 0x00040000 +#define MASK_ZTestEnable 0x00080000 +#define MASK_ZWriteEnable 0x00100000 +#define MASK_StencilBufferEnable 0x00200000 +#define MASK_StencilTestEnable 0x00400000 +#define MASK_StencilWriteEnable 0x00800000 +#define MASK_Texture0TransparencyEnable 0x01000000 +#define MASK_Texture1TransparencyEnable 0x02000000 +#define MASK_TextureAWrapUCorrection 0x04000000 +#define MASK_TextureAWrapVCorrection 0x08000000 +#define MASK_TextureBWrapUCorrection 0x10000000 +#define MASK_TextureBWrapVCorrection 0x20000000 +#define MASK_TextureCWrapUCorrection 0x40000000 +#define MASK_TextureCWrapVCorrection 0x80000000 + +/* + * REG_3D_TEnable2 - Capability Enable Mask2 (8A04h-8A07h) + */ +#define MASK_Texture0BlockTextureEnable 0x00000001 +#define MASK_Texture1BlockTextureEnable 0x00000002 +#define MASK_Texture0AnisotropicEnable 0x00000010 +#define MASK_Texture1AnisotropicEnable 0x00000020 +#define MASK_TextureMipmapBiasEnable 0x00000040 +#define MASK_LinePatternEnable 0x00000100 +#define MASK_StippleAlphaEnable 0x00000200 +#define MASK_StippleEnable 0x00000400 +#define MASK_AntiAliasEnable 0x00000800 +#define MASK_ZMaskWriteEnable 0x00001000 +#define MASK_StencilMaskWriteEnable 0x00002000 +#define MASK_AlphaMaskWriteEnable 0x00004000 +#define MASK_ColorMaskWriteEnable 0x00008000 +#define MASK_ZCacheClear 0x00010000 +#define MASK_ZCacheEnable 0x00020000 +#define MASK_StencilCacheClear 0x00040000 +#define MASK_StencilCacheEnable 0x00080000 +#define MASK_AlphaCacheClear 0x00100000 +#define MASK_AlphaCacheEnable 0x00200000 +#define MASK_ColorCacheClear 0x00400000 +#define MASK_ColorCacheEnable 0x00800000 + +/* + * REG_3D_ZSet -- Define Z Buffer Setting Mask (8A08h-8A0Bh) + */ +#define MASK_ZBufferPitch 0x00000FFF +#define MASK_ZTestMode 0x00070000 +#define MASK_ZBufferInSystem 0x00080000 +#define MASK_ZBufferFormat 0x01F00000 + +/* + * REG_3D_ZBias -- Define Z Buffer Setting Mask (8A0Ch-8A0Fh) + */ +#define MASK_ZBias 0xFFFFFFFF + +/* + * REG_3D_ZStWriteMask -- Define Z and Stencil Buffer Mask (8A10h-8A13h) + */ +#define MASK_ZWriteMask 0x00FFFFFF + +/* + * REG_3D_ZAddress -- Define Z Buffer Base Address(8A14h-8A17h) + */ +#define MASK_ZAddress 0xFFFFFFFF + +/* + * REG_3D_AlphaSet -- Define Alpha Buffer Setting Mask (8A18h-8A1Bh) + */ +#define MASK_AlphaBufferPitch 0x000003FF +#define MASK_AlphaRefValue 0x00FF0000 +#define MASK_AlphaTestMode 0x07000000 +#define MASK_AlphaBufferInSystem 0x08000000 +#define MASK_AlphaBufferFormat 0x30000000 + +/* + * REG_3D_AlphaAddress -- Define Alpha Buffer Base Address(8A1Ch-8A1Fh) + */ +#define MASK_AlphaAddress 0xFFFFFFFF + +/* + * REG_3D_DstSet -- Define Destination Buffer Setting Mask (8A20h-8A23h) + */ +#define MASK_DstBufferPitch 0x00000FFF +#define MASK_DstBufferFormat 0x000F0000 +#define MASK_DstBufferBitDepth 0x00300000 +#define MASK_DstBufferRgbOrder 0x00400000 +#define MASK_DstBufferInSystem 0x00800000 +#define MASK_Dst7BitFormat 0x007F0000 +#define MASK_ROP2 0x0F000000 + +/* + * REG_3D_DstAlphaWriteMask -- Define Destination/Alpha Buffer Write Mask (8A24h-8A27h) + */ +#define MASK_ColorWriteMask 0x00FFFFFF +#define MASK_AlphaWriteMask 0xFF000000 + +/* + * REG_3D_DstAddress -- Define Destination Buffer Base Address(8A1Ch-8A1Fh) + */ +#define MASK_DstAddress 0xFFFFFFFF + +/* + * REG_3D_LinePattern -- Define Line Pattern (8A2Ch-8A2Fh) + */ +#define MASK_LinePatternRepeatFactor 0x00007FFF +#define MASK_LinePatternLastPixelFlag 0x00008000 +#define MASK_LinePattern 0xFFFF0000 + +/* + * REG_3D_FogSet -- Define Fog Mask (8A30h-8A33h) + */ +#define MASK_FogColor 0x00FFFFFF +#define MASK_FogMode 0x07000000 +#define MASK_FogZLookup 0x08000000 + +/* + * REG_3D_FogStartEnd -- Define Fog Start End Setting (8A34h-8A37h) + */ +#define MASK_FogFarDistance 0x0007FFFF + +/* + * REG_3D_FogStartEnd -- Define Fog End Setting (8A38h-8A3Bh) + */ +#define MASK_FogInvFarDistance 0x0007FFFF + +#define MASK_FogDensity 0x0003FFFF +#define MASK_FogFactor 0xFF000000 + +#define MASK_StencilMaskValue 0x000000FF +#define MASK_StencilReferenceValue 0x0000FF00 +#define MASK_StencilTestMode 0x07000000 +#define MASK_StencilBufferInSystem 0x08000000 +#define MASK_StencilFormat 0x30000000 + +#define MASK_StencilMode_ALWAYS 0x07000000 +#define MASK_StencilBufferPitch 0x00000FFF +#define MASK_StencilZPassOp 0x00007000 +#define MASK_StencilZFailOp 0x00070000 +#define MASK_StencilFailOp 0x00700000 +#define MASK_StencilWriteMask 0xFF000000 + +#define MASK_StencilZPassOp_REPLACE 0x00002000 +#define MASK_StencilZFailOp_REPLACE 0x00020000 +#define MASK_StencilFailOp_REPLACE 0x00200000 +#define MASK_StencilAddress 0xFFFFFFFF + +#define MASK_SrcBlendMode 0x0000000F +#define MASK_DstBlendMode 0x000000F0 +#define MASK_DSTBLEND_ZERO 0x00000000 +#define MASK_DSTBLEND_ONE 0x00000010 +#define MASK_DSTBLEND_SRC_COLOR 0x00000020 +#define MASK_DSTBLEND_INV_SRC_COLOR 0x00000030 +#define MASK_DSTBLEND_SRC_ALPHA 0x00000040 +#define MASK_DSTBLEND_INV_SRC_ALPHA 0x00000050 +#define MASK_DSTBLEND_DST_ALPHA 0x00000060 +#define MASK_DSTBLEND_INV_DST_ALPHA 0x00000070 +#define MASK_DSTBLEND_DST_COLOR 0x00000080 +#define MASK_DSTBLEND_INV_DST_COLOR 0x00000090 +#define MASK_DSTBLEND_SRC_ALPHA_SAT 0x000000A0 + +#define MASK_SRCBLEND_ZERO 0x00000000 +#define MASK_SRCBLEND_ONE 0x00000001 +#define MASK_SRCBLEND_SRC_COLOR 0x00000002 +#define MASK_SRCBLEND_INV_SRC_COLOR 0x00000003 +#define MASK_SRCBLEND_SRC_ALPHA 0x00000004 +#define MASK_SRCBLEND_INV_SRC_ALPHA 0x00000005 +#define MASK_SRCBLEND_DST_ALPHA 0x00000006 +#define MASK_SRCBLEND_INV_DST_ALPHA 0x00000007 +#define MASK_SRCBLEND_DST_COLOR 0x00000008 +#define MASK_SRCBLEND_INV_DST_COLOR 0x00000009 +#define MASK_SRCBLEND_SRC_ALPHA_SAT 0x0000000A +#define MASK_SRCBLEND_BOTH_SRC_ALPHA 0x0000000B +#define MASK_SRCBLEND_BOTH_INV_SRC_ALPHA 0x0000000C + +#define MASK_BottomClip 0x00001FFF +#define MASK_TopClip 0x03FFE000 + +#define MASK_RightClip 0x00001FFF +#define MASK_LeftClip 0x03FFE000 + +#define MASK_BMMemoryInSystem 0x00000080 +#define MASK_BMHeight 0x00000F00 +#define MASK_BMWidth 0x0000F000 +#define MASK_BMFilter 0x00010000 +#define MASK_BMMappingMode 0x007E0000 +#define MASK_BMFormat 0x07800000 +#define MASK_BMTxBumpmap 0x08000000 + +#define MASK_BMAddress 0xFFFFFFFC + +#define MASK_BMOffset 0xFF800000 +#define MASK_BMScale 0x007FE000 +#define MASK_BMPitch 0x00001FFF + +#define MASK_BMMatrix00 0x000007FF +#define MASK_BMMatrix01 0x07FF0000 +#define MASK_BMMatrix10 0x000007FF +#define MASK_BMMatrix11 0x07FF0000 + +#define MASK_TextureHeight 0x0000000F +#define MASK_TextureWidth 0x000000F0 +#define MASK_TextureLevel 0x00000F00 +#define MASK_TextureSignYUVFormat 0x00001000 +#define MASK_TextureMappingMode 0x00FF0000 +#define MASK_TextureWrapU 0x00010000 +#define MASK_TextureWrapV 0x00020000 +#define MASK_TextureMirrorU 0x00040000 +#define MASK_TextureMirrorV 0x00080000 +#define MASK_TextureClampU 0x00100000 +#define MASK_TextureClampV 0x00200000 +#define MASK_TextureBorderU 0x00400000 +#define MASK_TextureBorderV 0x00800000 +#define MASK_TextureFormat 0xFF000000 +#define MASK_TextureBitDepth 0x70000000 +#define MASK_TextureRgbOrder 0x80000000 + +#define MASK_TextureAnisotropyRatio 0x0000000F +#define MASK_TextureMipmapLodBias 0x00003FF0 +#define MASK_TextureFilterMin 0x0001C000 +#define MASK_TextureFilterMag 0x00020000 +#define MASK_TextureFilter 0x0003C000 +#define MASK_TextureLevelInSystem 0x3FFC0000 +#define MASK_TextureLevel0InSystem 0x00040000 +#define MASK_TextureBlockLength 0xF0000000 + +#define MASK_TextureTransparencyColorHighB 0x000000FF +#define MASK_TextureTransparencyColorHighG 0x0000FF00 +#define MASK_TextureTransparencyColorHighR 0x00FF0000 +#define MASK_TextureAlphaTransparencyMode 0x08000000 + +#define MASK_TextureTransparencyColorLowB 0x000000FF +#define MASK_TextureTransparencyColorLowG 0x0000FF00 +#define MASK_TextureTransparencyColorLowR 0x00FF0000 +#define MASK_TextureBlockHeight 0x07000000 +#define MASK_TextureBlockWidth 0x70000000 + +#define MASK_TextureBorderColorB 0x000000FF +#define MASK_TextureBorderColorG 0x0000FF00 +#define MASK_TextureBorderColorR 0x00FF0000 +#define MASK_TextureBorderColorA 0xFF000000 + +#define MASK_TexturePitchOdd 0x000003FF +#define MASK_TexturePitchEven 0x03FF0000 +#define SHIFT_TexturePitchEven 16 + +#define MASK_TextureRealInSystem 0x00000001 +#define MASK_TextureDowngrade 0x00000002 + +#define OP_3D_POINT_DRAW 0x00000000 +#define OP_3D_LINE_DRAW 0x00000001 +#define OP_3D_TRIANGLE_DRAW 0x00000002 + +#define OP_3D_DIRECTION_RIGHT 0x00000000 +#define OP_3D_DIRECTION_LEFT 0x00000100 +#define OP_3D_DIRECTION_HORIZONTAL 0x00000000 +#define OP_3D_DIRECTION_VERTICAL 0x00000100 + +#define OP_3D_FIRE_TFIRE 0x00000000 +#define OP_3D_FIRE_TSARGBa 0x00000100 +#define OP_3D_FIRE_TSWa 0x00000200 +#define OP_3D_FIRE_TSVAa 0x00000300 +#define OP_3D_FIRE_TSVBa 0x00000400 +#define OP_3D_FIRE_TSVCa 0x00000500 + +#define OP_3D_FIRE_TSARGBb 0x00000900 +#define OP_3D_FIRE_TSWb 0x00000a00 +#define OP_3D_FIRE_TSVAb 0x00000b00 +#define OP_3D_FIRE_TSVBb 0x00000c00 +#define OP_3D_FIRE_TSVCb 0x00000d00 + +#define OP_3D_FIRE_TSARGBc 0x00001100 +#define OP_3D_FIRE_TSWc 0x00001200 +#define OP_3D_FIRE_TSVAc 0x00001300 +#define OP_3D_FIRE_TSVBc 0x00001400 +#define OP_3D_FIRE_TSVCc 0x00001500 + +#define OP_3D_Texture0FromA 0x00000000 +#define OP_3D_Texture0FromB 0x00100000 +#define OP_3D_Texture0FromC 0x00200000 +#define OP_3D_Texture1FromA 0x00000000 +#define OP_3D_Texture1FromB 0x00040000 +#define OP_3D_Texture1FromC 0x00080000 +#define OP_3D_TextureBumpFromA 0x00000000 +#define OP_3D_TextureBumpFromB 0x00010000 +#define OP_3D_TextureBumpFromC 0x00020000 + +#define SHADE_FLAT_VertexA 0x01000000 +#define SHADE_FLAT_VertexB 0x02000000 +#define SHADE_FLAT_VertexC 0x03000000 +#define SHADE_GOURAUD 0x04000000 + +#define Z_BUFFER_FORMAT_Z16 0x00000000 +#define Z_BUFFER_FORMAT_Z16_INT 0x00100000 +#define Z_BUFFER_FORMAT_S1Z15 0x00400000 +#define Z_BUFFER_FORMAT_S1Z15_INT 0x00500000 +#define Z_BUFFER_FORMAT_Z32 0x00800000 +#define Z_BUFFER_FORMAT_S1Z31 0x00C00000 +#define Z_BUFFER_FORMAT_S2Z30 0x00D00000 +#define Z_BUFFER_FORMAT_S4Z28 0x00E00000 +#define Z_BUFFER_FORMAT_S8Z24 0x00F00000 +#define Z_BUFFER_FORMAT_FZ30 0x01800000 +#define Z_BUFFER_FORMAT_FS1Z30 0x01C00000 +#define Z_BUFFER_FORMAT_FS2Z30 0x01D00000 +#define MASK_Z_BUFFER_FORMAT 0x01F00000 + +#define ALPHA_BUFFER_FORMAT_1 0x00000000 +#define ALPHA_BUFFER_FORMAT_2 0x10000000 +#define ALPHA_BUFFER_FORMAT_4 0x20000000 +#define ALPHA_BUFFER_FORMAT_8 0x30000000 + +#define DST_FORMAT_RGB_555 0x00100000 +#define DST_FORMAT_RGB_565 0x00110000 +#define DST_FORMAT_ARGB_1555 0x00120000 +#define DST_FORMAT_ARGB_4444 0x00130000 +#define DST_FORMAT_ARGB_1888 0x00300000 +#define DST_FORMAT_ARGB_2888 0x00310000 +#define DST_FORMAT_ARGB_4888 0x00320000 +#define DST_FORMAT_ARGB_8888 0x00330000 +#define DST_FORMAT_ARGB_0888 0x00340000 + +#define DST_FORMAT_BGR_555 0x00500000 +#define DST_FORMAT_BGR_565 0x00510000 +#define DST_FORMAT_ABGR_1555 0x00520000 +#define DST_FORMAT_ABGR_4444 0x00530000 +#define DST_FORMAT_ABGR_1888 0x00700000 +#define DST_FORMAT_ABGR_2888 0x00710000 +#define DST_FORMAT_ABGR_4888 0x00720000 +#define DST_FORMAT_ABGR_8888 0x00730000 +#define DST_FORMAT_ABGR_0888 0x00740000 + +#define MASK_TEXTURE_FORMAT 0xFF000000 + +#define TEXEL_INDEX1 0x00000000 +#define TEXEL_INDEX2 0x01000000 +#define TEXEL_INDEX4 0x02000000 +#define TEXEL_INDEX8 0x03000000 + +#define TEXEL_INDEX1WithAlpha 0x04000000 +#define TEXEL_INDEX2WithAlpha 0x05000000 +#define TEXEL_INDEX4WithAlpha 0x06000000 +#define TEXEL_INDEX8WithAlpha 0x07000000 + +#define TEXEL_I1 0x10000000 +#define TEXEL_I2 0x11000000 +#define TEXEL_I4 0x12000000 +#define TEXEL_I8 0x13000000 + +#define TEXEL_DXT1 0x19000000 +#define TEXEL_DXT2 0x1A000000 +#define TEXEL_DXT3 0x1B000000 + +#define TEXEL_YUV422 0x20000000 +#define TEXEL_YVU422 0x21000000 +#define TEXEL_UVY422 0x22000000 +#define TEXEL_VUY422 0x23000000 +#define TEXEL_YUV411 0x24000000 + +#define TEXEL_L1 0x30000000 +#define TEXEL_L2 0x31000000 +#define TEXEL_L4 0x32000000 +#define TEXEL_L8 0x33000000 + +#define TEXEL_AL11 0x34000000 +#define TEXEL_AL44 0x35000000 +#define TEXEL_AL26 0x37000000 +#define TEXEL_AL88 0x38000000 + +#define TEXEL_A1 0x40000000 +#define TEXEL_A2 0x41000000 +#define TEXEL_A4 0x42000000 +#define TEXEL_A8 0x43000000 + +#define TEXEL_RGB_332_8 0x50000000 +#define TEXEL_RGB_233_8 0x51000000 +#define TEXEL_RGB_232_8 0x52000000 +#define TEXEL_ARGB_1232_8 0x53000000 +#define TEXEL_ARGB_2222_8 0x54000000 + +#define TEXEL_RGB_555_16 0x60000000 +#define TEXEL_RGB_565_16 0x61000000 +#define TEXEL_ARGB_1555_16 0x62000000 +#define TEXEL_ARGB_4444_16 0x63000000 + +#define TEXEL_ARGB_1888_32 0x70000000 +#define TEXEL_ARGB_2888_32 0x71000000 +#define TEXEL_ARGB_4888_32 0x72000000 +#define TEXEL_ARGB_8888_32 0x73000000 +#define TEXEL_ARGB_0888_32 0x74000000 + +#define TEXEL_BGR_332_8 0xD0000000 +#define TEXEL_BGR_233_8 0xD1000000 +#define TEXEL_BGR_232_8 0xD2000000 +#define TEXEL_ABGR_1232_8 0xD3000000 +#define TEXEL_ABGR_2222_8 0xD4000000 + +#define TEXEL_BGR_555_16 0xE0000000 +#define TEXEL_BGR_565_16 0xE1000000 +#define TEXEL_ABGR_1555_16 0xE2000000 +#define TEXEL_ABGR_4444_16 0xE3000000 + +#define TEXEL_ABGR_1888_32 0xF0000000 +#define TEXEL_ABGR_2888_32 0xF1000000 +#define TEXEL_ABGR_4888_32 0xF2000000 +#define TEXEL_ABGR_8888_32 0xF3000000 +#define TEXEL_ABGR_0888_32 0xF4000000 + +#define TEXEL_VU88 0x00000000 +#define TEXEL_LVU655 0x00800000 +#define TEXEL_LVU888 0x01000000 +#define TEXEL_UV88 0x02000000 +#define TEXEL_LUV655 0x02800000 +#define TEXEL_LUV888 0x03000000 + +#define FOGMODE_CHEAP 0x04000000 +#define FOGMODE_LINEAR 0x05000000 +#define FOGMODE_EXP 0x06000000 +#define FOGMODE_EXP2 0x07000000 + +#define Z_16 0x00000000 +#define S_1_Z_15 0x00400000 +#define Z_32 0x00800000 +#define S_1_Z_31 0x00c00000 +#define S_2_Z_30 0x00d00000 +#define S_4_Z_28 0x00e00000 +#define S_8_Z_24 0x00f00000 + +#define S_1 0x00000000 +#define S_2 0x10000000 +#define S_4 0x20000000 +#define S_8 0x30000000 + +#define TEXTURE_FILTER_NEAREST 0x00000000 +#define TEXTURE_FILTER_LINEAR 0x00004000 +#define TEXTURE_FILTER_NEAREST_MIP_NEAREST 0x00008000 +#define TEXTURE_FILTER_NEAREST_MIP_LINEAR 0x00010000 +#define TEXTURE_FILTER_LINEAR_MIP_NEAREST 0x0000c000 +#define TEXTURE_FILTER_LINEAR_MIP_LINEAR 0x00014000 + +#define A_REPLACE_RGB_STAGE0 0xa1485000 +#define A_REPLACE_A_STAGE0 0xc3230000 +#define L_REPLACE__RGB_STAGE0 0xc1485000 +#define L_REPLACE__A_STAGE0 0x63230000 +#define LA_REPLACE__RGB_STAGE0 0xc1485000 +#define LA_REPLACE__A_STAGE0 0xc3230000 +#define I_REPLACE__RGB_STAGE0 0xc1485000 +#define I_REPLACE__A_STAGE0 0xc3230000 +#define RGB_REPLACE__RGB_STAGE0 0xc1485000 +#define RGB_REPLACE__A_STAGE0 0x63230000 +#define RGBA_REPLACE__RGB_STAGE0 0xc1485000 +#define RGBA_REPLACE__A_STAGE0 0xc3230000 + +#define A_MODULATE_RGB_STAGE0 0xa1485000 +#define A_MODULATE_A_STAGE0 0x63c30000 +#define L_MODULATE__RGB_STAGE0 0xa1705000 +#define L_MODULATE__A_STAGE0 0x63230000 +#define LA_MODULATE__RGB_STAGE0 0xa1705000 +#define LA_MODULATE__A_STAGE0 0x63c30000 +#define I_MODULATE__RGB_STAGE0 0xa1705000 +#define I_MODULATE__A_STAGE0 0x63c30000 +#define RGB_MODULATE__RGB_STAGE0 0xa1705000 +#define RGB_MODULATE__A_STAGE0 0x63230000 +#define RGBA_MODULATE__RGB_STAGE0 0xa1705000 +#define RGBA_MODULATE__A_STAGE0 0x63c30000 + +#define RGB_DECAL__RGB_STAGE0 0xc1485000 +#define RGB_DECAL__A_STAGE0 0x63230000 +#define RGBA_DECAL__RGB_STAGE0 0xc534c001 +#define RGBA_DECAL__A_STAGE0 0x63230000 + +#define A_BLEND_RGB_STAGE0 0xa1485000 +#define A_BLEND_A_STAGE0 0x63c30000 +#define L_BLEND__RGB_STAGE0 0x4530c001 +#define L_BLEND__A_STAGE0 0x63230000 +#define LA_BLEND__RGB_STAGE0 0x4530c001 +#define LA_BLEND__A_STAGE0 0x63c30000 +#define I_BLEND__RGB_STAGE0 0x4530c001 +#define I_BLEND__A_STAGE0 0x46c60001 +#define RGB_BLEND__RGB_STAGE0 0x4530c001 +#define RGB_BLEND__A_STAGE0 0x63230000 +#define RGBA_BLEND__RGB_STAGE0 0x4530c001 +#define RGBA_BLEND__A_STAGE0 0x63c30000 + +#define RGB_STAGE1 0xa1485000 +#define A_STAGE1 0xa3230000 + +#define A_REPLACE_RGB_STAGE1 0xa1485000 +#define A_REPLACE_A_STAGE1 0xe3230000 +#define L_REPLACE__RGB_STAGE1 0xe1485000 +#define L_REPLACE__A_STAGE1 0xa3230000 +#define LA_REPLACE__RGB_STAGE1 0xe1485000 +#define LA_REPLACE__A_STAGE1 0xe3230000 +#define I_REPLACE__RGB_STAGE1 0xe1485000 +#define I_REPLACE__A_STAGE1 0xe3230000 +#define RGB_REPLACE__RGB_STAGE1 0xe1485000 +#define RGB_REPLACE__A_STAGE1 0xa3230000 +#define RGBA_REPLACE__RGB_STAGE1 0xe1485000 +#define RGBA_REPLACE__A_STAGE1 0xe3230000 + +#define A_MODULATE_RGB_STAGE1 0xa1485000 +#define A_MODULATE_A_STAGE1 0xa3e30000 +#define L_MODULATE__RGB_STAGE1 0xa1785000 +#define L_MODULATE__A_STAGE1 0xa3230000 +#define LA_MODULATE__RGB_STAGE1 0xa1785000 +#define LA_MODULATE__A_STAGE1 0xa3e30000 +#define I_MODULATE__RGB_STAGE1 0xa1785000 +#define I_MODULATE__A_STAGE1 0xa3e30000 +#define RGB_MODULATE__RGB_STAGE1 0xa1785000 +#define RGB_MODULATE__A_STAGE1 0xa3230000 +#define RGBA_MODULATE__RGB_STAGE1 0xa1785000 +#define RGBA_MODULATE__A_STAGE1 0xa3e30000 + +#define RGB_DECAL__RGB_STAGE1 0xe1485000 +#define RGB_DECAL__A_STAGE1 0xa3230000 +#define RGBA_DECAL__RGB_STAGE1 0xe5394001 +#define RGBA_DECAL__A_STAGE1 0xa3230000 + +#define A_BLEND_RGB_STAGE1 0xa1485000 +#define A_BLEND_A_STAGE1 0xa3e30000 +#define L_BLEND__RGB_STAGE1 0x45394001 +#define L_BLEND__A_STAGE1 0xa3230000 +#define LA_BLEND__RGB_STAGE1 0x45394001 +#define LA_BLEND__A_STAGE1 0xa3e30000 +#define I_BLEND__RGB_STAGE1 0x45394001 +#define I_BLEND__A_STAGE1 0x4aea0001 +#define RGB_BLEND__RGB_STAGE1 0x45394001 +#define RGB_BLEND__A_STAGE1 0xa3230000 +#define RGBA_BLEND__RGB_STAGE1 0x45394001 +#define RGBA_BLEND__A_STAGE1 0xa3e30000 + + +#define INIT_6327_CapsEnable 0x00000080 +#define INIT_6327_CapsEnable2 0x00000000 + +#define INIT_6327_ZSet 0x00030000 +#define INIT_6327_ZMask 0xffffffff +#define INIT_6327_AlphaSet 0x07000000 +#define INIT_6327_DstSet 0x0C000000 +#define INIT_6327_DstMask 0xffffffff +#define INIT_6327_FogSet 0x04000000 +#define INIT_6327_BlendMode 0x00000001 +#define INIT_6327_TextureSet 0x00030000 +#define INIT_6327_TextureMip 0x00000000 +#define INIT_6327_TextureColorBlend0 0xC1485000 +#define INIT_6327_TextureAlphaBlend0 0x333A0000 +#define INIT_6327_Texture1Set 0x00030000 +#define INIT_6327_Texture1Set2 0x00000000 +#define INIT_6327_TextureColorBlend1 0x294B4000 +#define INIT_6327_TextureAlphaBlend1 0x333A0000 +#define INIT_6327_ParsingSet 0x00000060 + +#define SiS_Z_COMP_NEVER 0x00000000 +#define SiS_Z_COMP_S_LT_B 0x00010000 +#define SiS_Z_COMP_S_EQ_B 0x00020000 +#define SiS_Z_COMP_S_LE_B 0x00030000 +#define SiS_Z_COMP_S_GT_B 0x00040000 +#define SiS_Z_COMP_S_NE_B 0x00050000 +#define SiS_Z_COMP_S_GE_B 0x00060000 +#define SiS_Z_COMP_ALWAYS 0x00070000 + +#define SiS_ALPHA_NEVER 0x00000000 +#define SiS_ALPHA_LESS 0x01000000 +#define SiS_ALPHA_EQUAL 0x02000000 +#define SiS_ALPHA_LEQUAL 0x03000000 +#define SiS_ALPHA_GREATER 0x04000000 +#define SiS_ALPHA_NOTEQUAL 0x05000000 +#define SiS_ALPHA_GEQUAL 0x06000000 +#define SiS_ALPHA_ALWAYS 0x07000000 + +#define SiS_STENCIL_NEVER 0x00000000 +#define SiS_STENCIL_LESS 0x01000000 +#define SiS_STENCIL_EQUAL 0x02000000 +#define SiS_STENCIL_LEQUAL 0x03000000 +#define SiS_STENCIL_GREATER 0x04000000 +#define SiS_STENCIL_NOTEQUAL 0x05000000 +#define SiS_STENCIL_GEQUAL 0x06000000 +#define SiS_STENCIL_ALWAYS 0x07000000 + +#define SiS_SFAIL_KEEP 0x00000000 +#define SiS_SFAIL_ZERO 0x00100000 +#define SiS_SFAIL_REPLACE 0x00200000 +#define SiS_SFAIL_INVERT 0x00500000 +#define SiS_SFAIL_INCR 0x00600000 +#define SiS_SFAIL_DECR 0x00700000 + +#define SiS_SPASS_ZFAIL_KEEP 0x00000000 +#define SiS_SPASS_ZFAIL_ZERO 0x00010000 +#define SiS_SPASS_ZFAIL_REPLACE 0x00020000 +#define SiS_SPASS_ZFAIL_INVERT 0x00050000 +#define SiS_SPASS_ZFAIL_INCR 0x00060000 +#define SiS_SPASS_ZFAIL_DECR 0x00070000 + +#define SiS_SPASS_ZPASS_KEEP 0x00000000 +#define SiS_SPASS_ZPASS_ZERO 0x00001000 +#define SiS_SPASS_ZPASS_REPLACE 0x00002000 +#define SiS_SPASS_ZPASS_INVERT 0x00005000 +#define SiS_SPASS_ZPASS_INCR 0x00006000 +#define SiS_SPASS_ZPASS_DECR 0x00007000 + +#define SiS_D_ZERO 0x00000000 +#define SiS_D_ONE 0x00000010 +#define SiS_D_SRC_COLOR 0x00000020 +#define SiS_D_ONE_MINUS_SRC_COLOR 0x00000030 +#define SiS_D_SRC_ALPHA 0x00000040 +#define SiS_D_ONE_MINUS_SRC_ALPHA 0x00000050 +#define SiS_D_DST_ALPHA 0x00000060 +#define SiS_D_ONE_MINUS_DST_ALPHA 0x00000070 + +#define SiS_S_ZERO 0x00000000 +#define SiS_S_ONE 0x00000001 +#define SiS_S_SRC_ALPHA 0x00000004 +#define SiS_S_ONE_MINUS_SRC_ALPHA 0x00000005 +#define SiS_S_DST_ALPHA 0x00000006 +#define SiS_S_ONE_MINUS_DST_ALPHA 0x00000007 +#define SiS_S_DST_COLOR 0x00000008 +#define SiS_S_ONE_MINUS_DST_COLOR 0x00000009 +#define SiS_S_SRC_ALPHA_SATURATE 0x0000000a + +/* Logic Op */ +#define LOP_CLEAR 0x00000000 +#define LOP_NOR 0x01000000 +#define LOP_AND_INVERTED 0x02000000 +#define LOP_COPY_INVERTED 0x03000000 +#define LOP_AND_REVERSE 0x04000000 +#define LOP_INVERT 0x05000000 +#define LOP_XOR 0x06000000 +#define LOP_NAND 0x07000000 +#define LOP_AND 0x08000000 +#define LOP_EQUIV 0x09000000 +#define LOP_NOOP 0x0a000000 +#define LOP_OR_INVERTED 0x0b000000 +#define LOP_COPY 0x0c000000 +#define LOP_OR_REVERSE 0x0d000000 +#define LOP_OR 0x0e000000 +#define LOP_SET 0x0f000000 + +#define SiSWait3DCmdQueue(wLen)\ +do{ \ + while ( CmdQueLen < (int)(wLen)) { \ + CmdQueLen = (MMIO_IN16(pSiS->IOBase, 0x8240) & pSiS->CmdQueLenMask) - pSiS->CmdQueLenFix; \ + } \ + CmdQueLen -= (int)(wLen); \ +} while(0) + diff --git a/src/sis310_accel.c b/src/sis310_accel.c index aeee273..5db2d82 100644 --- a/src/sis310_accel.c +++ b/src/sis310_accel.c @@ -1,30 +1,32 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis310_accel.c,v 1.2 2003/01/29 15:42:16 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis310_accel.c,v 1.32 2003/11/06 19:10:01 twini Exp $ */ /* - * 2D Acceleration for SiS 310/325 series (315, 550, 650, 740, M650, 651) + * 2D Acceleration for SiS 315 and 330 series + * (315/550/650/740/M650/651/652/M652/330/660/661/M661/741/M741/760/M760) * - * Copyright 2002 by Thomas Winischhofer, Vienna, Austria + * Copyright 2002, 2003 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 Thomas Winischhofer not be used in + * 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. Thomas Winischhofer makes no representations + * 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. * - * THOMAS WINISCHHOFER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THOMAS WINISCHHOFER BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * 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.c + * 2003/08/18: Rewritten for using VRAM command queue (TW) * - * Author: Thomas Winischhofer <thomas@winischhofer.net> + * Author: Thomas Winischhofer <thomas@winischhofer.net> * */ @@ -35,21 +37,54 @@ #include "xf86Pci.h" #include "compiler.h" #include "xaa.h" +#include "xaalocal.h" #include "sis.h" #include "sis310_accel.h" +#if 0 +#define ACCELDEBUG +#endif + #ifdef SISDUALHEAD -/* TW: This is the offset to the memory for each head */ #define HEADOFFSET (pSiS->dhmOffset) #endif -#undef TRAP /* TW: 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. +#undef TRAP /* Use/Don't use Trapezoid Fills + * DOES NOT WORK. XAA sometimes provides illegal + * trapezoid data (left and right edges cross each + * other) which causes drawing errors. Since + * 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 330 series at all, hangs the engine. + * Even with correct trapezoids, this is slower than + * doing it by the CPU. */ -#define CTSCE /* Use/Don't use CPUToScreenColorExpand. */ +#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 330 series (even in MMIO mode). + */ +#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) + */ + +#undef STSCE /* Use/Don't use ScreenToScreenColorExpand - does not work, + * see comments below. + */ + +#define INCL_RENDER /* Use/Don't use RENDER extension acceleration */ + +#ifdef INCL_RENDER +#ifdef RENDER +#include "mipict.h" +#include "dixstruct.h" +#endif +#endif /* Accelerator functions */ static void SiSInitializeAccelerator(ScrnInfoPtr pScrn); @@ -94,7 +129,31 @@ static void SiSSubsequentMonoPatternFillTrap(ScrnInfoPtr pScrn, int left, int dxL, int dyL, int eL, int right, int dxR, int dyR, int eR); #endif +#ifdef SISVRAMQ +static void SiSSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, + int patternx, int patterny, + int rop, unsigned int planemask, int trans_col); +static void SiSSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, + int patternx, int patterny, int x, int y, + int w, int h); +#endif +#ifdef STSCE +static void SiSSetupForScreenToScreenColorExpand(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, unsigned int planemask); +static void SiSSubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int srcx, int srcy, int skipleft); +#endif #ifdef CTSCE +#ifdef CTSCE_DIRECT +static void SiSSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask); +static void SiSSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft); +#else static void SiSSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask); @@ -103,6 +162,32 @@ static void SiSSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int skipleft); static void SiSSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); #endif +#endif +#ifdef INCL_RENDER +#ifdef RENDER +extern Bool SiSSetupForCPUToScreenAlphaTexture(ScrnInfoPtr pScrn, + int op, CARD16 red, CARD16 green, + CARD16 blue, CARD16 alpha, + int alphaType, CARD8 *alphaPtr, + int alphaPitch, int width, + int height, int flags); + +extern Bool SiSSetupForCPUToScreenTexture( ScrnInfoPtr pScrn, + int op, int texType, CARD8 *texPtr, + int texPitch, int width, + int height, int flags); + +extern void SiSSubsequentCPUToScreenTexture(ScrnInfoPtr pScrn, + int dstx, int dsty, + int srcx, int srcy, + int width, int height); + +extern CARD32 SiSAlphaTextureFormats[2]; +extern CARD32 SiSTextureFormats[2]; +CARD32 SiSAlphaTextureFormats[2] = { PICT_a8, 0 }; +CARD32 SiSTextureFormats[2] = { PICT_a8r8g8b8, 0 }; +#endif +#endif #ifdef SISDUALHEAD static void SiSRestoreAccelState(ScrnInfoPtr pScrn); @@ -114,10 +199,18 @@ SiSInitializeAccelerator(ScrnInfoPtr pScrn) SISPtr pSiS = SISPTR(pScrn); pSiS->DoColorExpand = FALSE; + pSiS->alphaBlitBusy = FALSE; +#ifndef SISVRAMQ + if(pSiS->ChipFlags & SiSCF_Integrated) { + CmdQueLen = 0; + } else { + CmdQueLen = ((128 * 1024) / 4) - 64; + } +#endif } Bool -SiS310AccelInit(ScreenPtr pScreen) +SiS315AccelInit(ScreenPtr pScreen) { XAAInfoRecPtr infoPtr; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; @@ -125,13 +218,19 @@ SiS310AccelInit(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 pSiS->AccelInfoPtr = infoPtr = XAACreateInfoRec(); - if (!infoPtr) - return FALSE; + if(!infoPtr) return FALSE; SiSInitializeAccelerator(pScrn); @@ -142,21 +241,27 @@ SiS310AccelInit(ScreenPtr pScreen) /* sync */ infoPtr->Sync = SiSSync; - if ((pScrn->bitsPerPixel != 8) && (pScrn->bitsPerPixel != 16) && + if((pScrn->bitsPerPixel != 8) && (pScrn->bitsPerPixel != 16) && (pScrn->bitsPerPixel != 32)) return FALSE; +#ifdef SISDUALHEAD + pSiSEnt = pSiS->entityPrivate; +#endif + /* BitBlt */ infoPtr->SetupForScreenToScreenCopy = SiSSetupForScreenToScreenCopy; infoPtr->SubsequentScreenToScreenCopy = SiSSubsequentScreenToScreenCopy; infoPtr->ScreenToScreenCopyFlags = NO_PLANEMASK | TRANSPARENCY_GXCOPY_ONLY; - /*| NO_TRANSPARENCY; */ /* solid fills */ infoPtr->SetupForSolidFill = SiSSetupForSolidFill; infoPtr->SubsequentSolidFillRect = SiSSubsequentSolidFillRect; #ifdef TRAP - infoPtr->SubsequentSolidFillTrap = SiSSubsequentSolidFillTrap; + if((pSiS->Chipset != PCI_CHIP_SIS660) && + (pSiS->Chipset != PCI_CHIP_SIS330)) { + infoPtr->SubsequentSolidFillTrap = SiSSubsequentSolidFillTrap; + } #endif infoPtr->SolidFillFlags = NO_PLANEMASK; @@ -177,17 +282,31 @@ SiS310AccelInit(ScreenPtr pScreen) infoPtr->SetupForMono8x8PatternFill = SiSSetupForMonoPatternFill; infoPtr->SubsequentMono8x8PatternFillRect = SiSSubsequentMonoPatternFill; #ifdef TRAP - infoPtr->SubsequentMono8x8PatternFillTrap = SiSSubsequentMonoPatternFillTrap; + if((pSiS->Chipset != PCI_CHIP_SIS660) && + (pSiS->Chipset != PCI_CHIP_SIS330)) { + infoPtr->SubsequentMono8x8PatternFillTrap = SiSSubsequentMonoPatternFillTrap; + } #endif infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | HARDWARE_PATTERN_SCREEN_ORIGIN | HARDWARE_PATTERN_PROGRAMMED_BITS | - NO_TRANSPARENCY | - 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 | + NO_TRANSPARENCY; +#endif -#if 0 +#ifdef STSCE /* Screen To Screen Color Expand */ - /* TW: The hardware does not seem to support this the way we need it */ + /* The hardware does not support this the way we need it, because + * the mono-bitmap is not provided with a pitch of (width), but + * with a pitch of scrnOffset (= width * bpp / 8). + */ infoPtr->SetupForScreenToScreenColorExpandFill = SiSSetupForScreenToScreenColorExpand; infoPtr->SubsequentScreenToScreenColorExpandFill = @@ -196,69 +315,168 @@ SiS310AccelInit(ScreenPtr pScreen) BIT_ORDER_IN_BYTE_MSBFIRST ; #endif - /* per-scanline color expansion - indirect method */ - pSiS->ColorExpandBufferNumber = 16; - pSiS->ColorExpandBufferCountMask = 0x0F; - pSiS->PerColorExpandBufferSize = ((pScrn->virtualX + 31)/32) * 4; #ifdef CTSCE - infoPtr->NumScanlineColorExpandBuffers = pSiS->ColorExpandBufferNumber; - infoPtr->ScanlineColorExpandBuffers = (unsigned char **)&pSiS->ColorExpandBufferAddr[0]; - infoPtr->SetupForScanlineCPUToScreenColorExpandFill = SiSSetupForScanlineCPUToScreenColorExpandFill; - infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = SiSSubsequentScanlineCPUToScreenColorExpandFill; - infoPtr->SubsequentColorExpandScanline = SiSSubsequentColorExpandScanline; - infoPtr->ScanlineCPUToScreenColorExpandFillFlags = - NO_PLANEMASK | - CPU_TRANSFER_PAD_DWORD | - SCANLINE_PAD_DWORD | - BIT_ORDER_IN_BYTE_MSBFIRST | - LEFT_EDGE_CLIPPING; +#ifdef CTSCE_DIRECT + /* CPU color expansion - direct method + * + * We somewhat fake this function here in the following way: + * XAA copies its mono-bitmap data not into an aperture, but + * into our video RAM buffer. We then do a ScreenToScreen + * color expand. + * Unfortunately, XAA sends the data to the aperture AFTER + * the call to Subsequent(), therefore we do not execute the + * command in Subsequent, but in the following call to Sync(). + * (Hence, the SYNC_AFTER_COLOR_EXPAND flag MUST BE SET) + * + * This is slower than doing it by the CPU. + */ + + pSiS->ColorExpandBufferNumber = 48; + pSiS->PerColorExpandBufferSize = ((pScrn->virtualX + 31)/32) * 4; + infoPtr->SetupForCPUToScreenColorExpandFill = SiSSetupForCPUToScreenColorExpandFill; + infoPtr->SubsequentCPUToScreenColorExpandFill = SiSSubsequentCPUToScreenColorExpandFill; + infoPtr->ColorExpandRange = pSiS->ColorExpandBufferNumber * pSiS->PerColorExpandBufferSize; + infoPtr->CPUToScreenColorExpandFillFlags = + NO_PLANEMASK | + CPU_TRANSFER_PAD_DWORD | + SCANLINE_PAD_DWORD | + BIT_ORDER_IN_BYTE_MSBFIRST | + LEFT_EDGE_CLIPPING | + SYNC_AFTER_COLOR_EXPAND; +#else + /* CPU color expansion - per-scanline / indirect method + * + * SLOW! SLOWER! SLOWEST! + * + * 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->ColorExpandBufferNumber = 16; + pSiS->ColorExpandBufferCountMask = 0x0F; + pSiS->PerColorExpandBufferSize = ((pScrn->virtualX + 31)/32) * 4; + infoPtr->NumScanlineColorExpandBuffers = pSiS->ColorExpandBufferNumber; + infoPtr->ScanlineColorExpandBuffers = (unsigned char **)&pSiS->ColorExpandBufferAddr[0]; + infoPtr->SetupForScanlineCPUToScreenColorExpandFill = SiSSetupForScanlineCPUToScreenColorExpandFill; + infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = SiSSubsequentScanlineCPUToScreenColorExpandFill; + infoPtr->SubsequentColorExpandScanline = SiSSubsequentColorExpandScanline; + infoPtr->ScanlineCPUToScreenColorExpandFillFlags = + NO_PLANEMASK | + CPU_TRANSFER_PAD_DWORD | + SCANLINE_PAD_DWORD | + BIT_ORDER_IN_BYTE_MSBFIRST | + LEFT_EDGE_CLIPPING; + } else { +#endif + pSiS->ColorExpandBufferNumber = 0; + pSiS->PerColorExpandBufferSize = 0; +#ifndef SISVRAMQ + } +#endif +#endif +#else + pSiS->ColorExpandBufferNumber = 0; + 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; +#ifdef SISDUALHEAD + if(pSiSEnt) pSiS->RenderAccelArray = pSiSEnt->RenderAccelArray; +#endif + if(!pSiS->RenderAccelArray) { + if((pSiS->RenderAccelArray = xnfcalloc(65536, 1))) { #ifdef SISDUALHEAD - if (pSiS->DualHeadMode) { - infoPtr->RestoreAccelState = SiSRestoreAccelState; + 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->SetupForCPUToScreenTexture = SiSSetupForCPUToScreenTexture; + infoPtr->SubsequentCPUToScreenTexture = SiSSubsequentCPUToScreenTexture; + infoPtr->CPUToScreenTextureFormats = SiSTextureFormats; + infoPtr->CPUToScreenTextureFlags = XAA_RENDER_NO_TILE; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "RENDER acceleration enabled\n"); + } + } +#endif +#endif + +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + infoPtr->RestoreAccelState = SiSRestoreAccelState; } #endif - /* init Frame Buffer Manager */ + /* Init Frame Buffer Manager */ topFB = pSiS->maxxfbmem; reservedFbSize = (pSiS->ColorExpandBufferNumber * pSiS->PerColorExpandBufferSize); - /* TW: New for MaxXFBmem Option */ + UsableFbSize = topFB - reservedFbSize; /* Layout: * |--------------++++++++++++++++++++^************==========~~~~~~~~~~~~| * UsableFbSize ColorExpandBuffers | DRI-Heap HWCursor CommandQueue * topFB */ +#ifdef CTSCE AvailBufBase = pSiS->FbBase + UsableFbSize; - for (i = 0; i < pSiS->ColorExpandBufferNumber; i++) { - pSiS->ColorExpandBufferAddr[i] = AvailBufBase + + if(pSiS->ColorExpandBufferNumber) { +#ifdef CTSCE_DIRECT + infoPtr->ColorExpandBase = (unsigned char *)AvailBufBase; + pSiS->ColorExpandBase = UsableFbSize; +#else + for(i = 0; i < pSiS->ColorExpandBufferNumber; i++) { + pSiS->ColorExpandBufferAddr[i] = AvailBufBase + i * pSiS->PerColorExpandBufferSize; - pSiS->ColorExpandBufferScreenOffset[i] = UsableFbSize + + pSiS->ColorExpandBufferScreenOffset[i] = UsableFbSize + i * pSiS->PerColorExpandBufferSize; + } +#endif } +#endif + Avail.x1 = 0; Avail.y1 = 0; Avail.x2 = pScrn->displayWidth; - Avail.y2 = UsableFbSize - / (pScrn->displayWidth * pScrn->bitsPerPixel/8) - 1; - if (Avail.y2 < 0) - Avail.y2 = 32767; - if (Avail.y2 < pScrn->currentMode->VDisplay) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Not enough video RAM for accelerator. At least " - "%dKB needed, %dKB available\n", - ((((pScrn->displayWidth * pScrn->bitsPerPixel/8) /* TW: +8 for make it sure */ - * pScrn->currentMode->VDisplay) + reservedFbSize) / 1024) + 8, - pSiS->maxxfbmem/1024); - pSiS->NoAccel = TRUE; - pSiS->NoXvideo = TRUE; - XAADestroyInfoRec(pSiS->AccelInfoPtr); - pSiS->AccelInfoPtr = NULL; - return FALSE; + Avail.y2 = (UsableFbSize / (pScrn->displayWidth * pScrn->bitsPerPixel/8)) - 1; + + if(Avail.y2 < 0) Avail.y2 = 32767; + if(Avail.y2 < pScrn->currentMode->VDisplay) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Not enough video RAM for accelerator. At least " + "%dKB needed, %ldKB available\n", + ((((pScrn->displayWidth * pScrn->bitsPerPixel/8) /* +8 for make it sure */ + * pScrn->currentMode->VDisplay) + reservedFbSize) / 1024) + 8, + pSiS->maxxfbmem/1024); + pSiS->NoAccel = TRUE; + pSiS->NoXvideo = TRUE; + XAADestroyInfoRec(pSiS->AccelInfoPtr); + pSiS->AccelInfoPtr = NULL; + return FALSE; } xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -277,7 +495,18 @@ SiSSync(ScrnInfoPtr pScrn) PDEBUG(ErrorF("SiSSync()\n")); +#ifdef CTSCE +#ifdef CTSCE_DIRECT + if(pSiS->DoColorExpand) { + SiSDoCMD + pSiS->ColorExpandBusy = TRUE; + } +#endif +#endif + pSiS->DoColorExpand = FALSE; + pSiS->alphaBlitBusy = FALSE; + SiSIdle } @@ -287,8 +516,8 @@ SiSRestoreAccelState(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - /* TW: We don't need to do anything special here */ - pSiS->DoColorExpand = FALSE; + pSiS->ColorExpandBusy = FALSE; + pSiS->alphaBlitBusy = FALSE; SiSIdle } #endif @@ -312,6 +541,7 @@ static const int sisALUConv[] = 0x77, /* dest = ~src|~dest; DSan, GXnand, 0xE */ 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ }; + /* same ROP but with Pattern as Source */ static const int sisPatALUConv[] = { @@ -342,26 +572,35 @@ static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, PDEBUG(ErrorF("Setup ScreenCopy(%d, %d, 0x%x, 0x%x, 0x%x)\n", xdir, ydir, rop, planemask, trans_color)); - /* "AGP base" - color depth depending value (see sis_vga.c) */ +#ifdef SISVRAMQ + SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); + SiSCheckQueue(16 * 2); + SiSSetupSRCPitchDSTRect(pSiS->scrnOffset, pSiS->scrnOffset, -1) +#else SiSSetupDSTColorDepth(pSiS->DstColor); - /* SRC pitch */ SiSSetupSRCPitch(pSiS->scrnOffset) - /* DST pitch and height (-1 for disabling merge-clipping) */ SiSSetupDSTRect(pSiS->scrnOffset, -1) - /* Init CommandReg and set ROP */ - if (trans_color != -1) { - SiSSetupROP(0x0A) - SiSSetupSRCTrans(trans_color) - SiSSetupCMDFlag(TRANSPARENT_BITBLT) +#endif + + if(trans_color != -1) { + SiSSetupROP(0x0A) + SiSSetupSRCTrans(trans_color) + SiSSetupCMDFlag(TRANSPARENT_BITBLT) } else { - SiSSetupROP(sisALUConv[rop]) - /* Set command - not needed, both 0 */ - /* SiSSetupCMDFlag(BITBLT | SRCVIDEO) */ + SiSSetupROP(sisALUConv[rop]) + /* Set command - not needed, both 0 */ + /* SiSSetupCMDFlag(BITBLT | SRCVIDEO) */ } - /* Set some color depth depending value (see sis_vga.c) */ + +#ifndef SISVRAMQ SiSSetupCMDFlag(pSiS->SiS310_AccelDepth) +#endif - /* TW: The 310/325 series is smart enough to know the direction */ +#ifdef SISVRAMQ + SiSSyncWP +#endif + + /* The chip is smart enough to know the direction */ } static void SiSSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, @@ -370,29 +609,86 @@ static void SiSSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, { SISPtr pSiS = SISPTR(pScrn); long 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)); srcbase = dstbase = 0; - if (src_y >= 2048) { - srcbase = pSiS->scrnOffset * src_y; - src_y = 0; + mymin = min(src_y, dst_y); + mymax = max(src_y, dst_y); + + /* Libxaa.a has a bug: The tilecache cannot operate + * 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) || + (dst_y < 0) || + (width <= 0) || + (height <= 0)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "BitBlit fatal error: Illegal coordinates:\n"); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Source x %d y %d, dest x %d y %d, width %d height %d\n", + src_x, src_y, dst_x, dst_y, width, height); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "This is very probably caused by a known bug in libxaa.a.\n"); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Please update libxaa.a to avoid this error.\n"); + return; } - if ((dst_y >= pScrn->virtualY) || (dst_y >= 2048)) { - dstbase = pSiS->scrnOffset*dst_y; - dst_y = 0; +#endif + + /* Although the chip knows the direction to use + * if the source and destination areas overlap, + * that logic fails if we fiddle with the bitmap + * addresses. Therefore, we check if the source + * and destination blitting areas overlap and + * adapt the bitmap addresses synchronously + * if the coordinates exceed the valid range. + * The the areas do not overlap, we do our + * normal check. + */ + if((mymax - mymin) < height) { + if((src_y >= 2048) || (dst_y >= 2048)) { + srcbase = pSiS->scrnOffset * mymin; + dstbase = pSiS->scrnOffset * mymin; + src_y -= mymin; + dst_y -= mymin; + } + } else { + if(src_y >= 2048) { + srcbase = pSiS->scrnOffset * src_y; + src_y = 0; + } + if((dst_y >= pScrn->virtualY) || (dst_y >= 2048)) { + dstbase = pSiS->scrnOffset * dst_y; + dst_y = 0; + } } #ifdef SISDUALHEAD srcbase += HEADOFFSET; dstbase += HEADOFFSET; #endif + +#ifdef SISVRAMQ + SiSCheckQueue(16 * 3); + SiSSetupSRCDSTBase(srcbase, dstbase) + SiSSetupSRCDSTXY(src_x, src_y, dst_x, dst_y) + SiSSetRectDoCMD(width,height) +#else SiSSetupSRCBase(srcbase); SiSSetupDSTBase(dstbase); SiSSetupRect(width, height) SiSSetupSRCXY(src_x, src_y) SiSSetupDSTXY(dst_x, dst_y) SiSDoCMD +#endif } static void @@ -404,11 +700,26 @@ SiSSetupForSolidFill(ScrnInfoPtr pScrn, int color, PDEBUG(ErrorF("Setup SolidFill(0x%x, 0x%x, 0x%x)\n", color, rop, planemask)); - SiSSetupPATFG(color) + if(pSiS->disablecolorkeycurrent) { + if((CARD32)color == pSiS->colorKey) { + rop = 5; /* NOOP */ + } + } + +#ifdef SISVRAMQ + SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); + SiSCheckQueue(16 * 1); + SiSSetupPATFGDSTRect(color, pSiS->scrnOffset, -1) + SiSSetupROP(sisPatALUConv[rop]) + SiSSetupCMDFlag(PATFG) + SiSSyncWP +#else + SiSSetupPATFG(color) SiSSetupDSTRect(pSiS->scrnOffset, -1) SiSSetupDSTColorDepth(pSiS->DstColor); SiSSetupROP(sisPatALUConv[rop]) SiSSetupCMDFlag(PATFG | pSiS->SiS310_AccelDepth) +#endif } static void @@ -420,29 +731,40 @@ SiSSubsequentSolidFillRect(ScrnInfoPtr pScrn, PDEBUG(ErrorF("Subsequent SolidFillRect(%d, %d, %d, %d)\n", x, y, w, h)); + dstbase = 0; - if (y >= 2048) { - dstbase=pSiS->scrnOffset*y; - y = 0; + if(y >= 2048) { + dstbase = pSiS->scrnOffset * y; + y = 0; } #ifdef SISDUALHEAD dstbase += HEADOFFSET; #endif - SiSSetupDSTBase(dstbase) - SiSSetupDSTXY(x,y) - SiSSetupRect(w,h) + pSiS->CommandReg &= ~(T_XISMAJORL | T_XISMAJORR | T_L_X_INC | T_L_Y_INC | T_R_X_INC | T_R_Y_INC | TRAPAZOID_FILL); - SiSSetupCMDFlag(BITBLT) + + /* SiSSetupCMDFlag(BITBLT) - BITBLT = 0 */ + +#ifdef SISVRAMQ + SiSCheckQueue(16 * 2) + SiSSetupDSTXYRect(x,y,w,h) + SiSSetupDSTBaseDoCMD(dstbase) +#else + SiSSetupDSTBase(dstbase) + SiSSetupDSTXY(x,y) + SiSSetupRect(w,h) SiSDoCMD +#endif } -/* 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 which causes drawing errors (filling over whole scanline). + * DOES NOT WORK ON 330 SERIES, HANGS THE ENGINE. */ #ifdef TRAP static void @@ -452,19 +774,21 @@ SiSSubsequentSolidFillTrap(ScrnInfoPtr pScrn, int y, int h, { SISPtr pSiS = SISPTR(pScrn); long dstbase; -#if 0 - float kL, kR; -#endif dstbase = 0; - if (y >= 2048) { - dstbase=pSiS->scrnOffset*y; - y = 0; + if(y >= 2048) { + dstbase = pSiS->scrnOffset * y; + y = 0; } #ifdef SISDUALHEAD dstbase += HEADOFFSET; #endif + +#ifdef SISVRAMQ /* Not optimized yet */ + SiSCheckQueue(16 * 10) +#else SiSSetupDSTBase(dstbase) +#endif #if 1 SiSSetupPATFG(0xff0000) /* FOR TESTING */ @@ -479,60 +803,41 @@ SiSSubsequentSolidFillTrap(ScrnInfoPtr pScrn, int y, int h, xf86DrvMsg(0, X_INFO, "Trap (%d %d %d %d) dxL %d dyL %d eL %d dxR %d dyR %d eR %d\n", left, right, y, h, dxL, dyL, eL, dxR, dyR, eR); - /* Unfortunately, we must check if the right and the left edge - * cross each other... INCOMPLETE (equation wrong) - */ -#if 0 - if (dxL == 0) kL = 0; - else kL = (float)dyL / (float)dxL; - if (dxR == 0) kR = 0; - else kR = (float)dyR / (float)dxR; - xf86DrvMsg(0, X_INFO, "kL %f kR %f!\n", kL, kR); - if ( (kR != kL) && - (!(kR == 0 && kL == 0)) && - (!(kR < 0 && kL > 0)) ) { - xf86DrvMsg(0, X_INFO, "Inside if (%f - %d)\n", ( kL * ( ( ((float)right - (float)left) / (kL - kR) ) - left) + y), h+y); - if ( ( ( kL * ( ( ((float)right - (float)left) / (kL - kR) ) - (float)left) + (float)y) < (h + y) ) ) { - xf86DrvMsg(0, X_INFO, "Cross detected!\n"); - } - } -#endif - /* Determine egde angles */ - if (dxL < 0) { dxL = -dxL; } - else { SiSSetupCMDFlag(T_L_X_INC) } - if (dxR < 0) { dxR = -dxR; } - else { SiSSetupCMDFlag(T_R_X_INC) } + if(dxL < 0) { dxL = -dxL; } + else { SiSSetupCMDFlag(T_L_X_INC) } + if(dxR < 0) { dxR = -dxR; } + else { SiSSetupCMDFlag(T_R_X_INC) } /* (Y direction always positive - do this anyway) */ - if (dyL < 0) { dyL = -dyL; } - else { SiSSetupCMDFlag(T_L_Y_INC) } - if (dyR < 0) { dyR = -dyR; } - else { SiSSetupCMDFlag(T_R_Y_INC) } + if(dyL < 0) { dyL = -dyL; } + else { SiSSetupCMDFlag(T_L_Y_INC) } + if(dyR < 0) { dyR = -dyR; } + else { SiSSetupCMDFlag(T_R_Y_INC) } /* Determine major axis */ - if (dxL >= dyL) { /* X is major axis */ - SiSSetupCMDFlag(T_XISMAJORL) - } - if (dxR >= dyR) { /* X is major axis */ - SiSSetupCMDFlag(T_XISMAJORR) - } + if(dxL >= dyL) { SiSSetupCMDFlag(T_XISMAJORL) } + if(dxR >= dyR) { SiSSetupCMDFlag(T_XISMAJORR) } + SiSSetupCMDFlag(TRAPAZOID_FILL); + +#ifdef SISVRAMQ + SiSSetupYHLR(y, h, left, right) + SiSSetupdLdR(dxL, dyL, dxR, dyR) + SiSSetupELER(eL, eR) + SiSSetupDSTBaseDoCMD(dstbase) +#else /* Set up deltas */ SiSSetupdL(dxL, dyL) SiSSetupdR(dxR, dyR) - /* Set up y, h, left, right */ - SiSSetupYH(y,h) - SiSSetupLR(left,right) - + SiSSetupYH(y, h) + SiSSetupLR(left, right) /* Set up initial error term */ SiSSetupEL(eL) SiSSetupER(eR) - - SiSSetupCMDFlag(TRAPAZOID_FILL); - SiSDoCMD +#endif } #endif @@ -545,12 +850,22 @@ SiSSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, PDEBUG(ErrorF("Setup SolidLine(0x%x, 0x%x, 0x%x)\n", color, rop, planemask)); +#ifdef SISVRAMQ + SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); + SiSCheckQueue(16 * 3); + SiSSetupLineCountPeriod(1, 1) + SiSSetupPATFGDSTRect(color, pSiS->scrnOffset, -1) + SiSSetupROP(sisPatALUConv[rop]) + SiSSetupCMDFlag(PATFG | LINE) + SiSSyncWP +#else SiSSetupLineCount(1) SiSSetupPATFG(color) SiSSetupDSTRect(pSiS->scrnOffset, -1) - SiSSetupDSTColorDepth(pSiS->DstColor); + SiSSetupDSTColorDepth(pSiS->DstColor) SiSSetupROP(sisPatALUConv[rop]) SiSSetupCMDFlag(PATFG | LINE | pSiS->SiS310_AccelDepth) +#endif } static void @@ -566,24 +881,31 @@ SiSSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, dstbase = 0; miny = (y1 > y2) ? y2 : y1; maxy = (y1 > y2) ? y1 : y2; - if (maxy >= 2048) { - dstbase = pSiS->scrnOffset*miny; - y1 -= miny; - y2 -= miny; + if(maxy >= 2048) { + dstbase = pSiS->scrnOffset*miny; + y1 -= miny; + y2 -= miny; } #ifdef SISDUALHEAD dstbase += HEADOFFSET; #endif - SiSSetupDSTBase(dstbase) - SiSSetupX0Y0(x1,y1) - SiSSetupX1Y1(x2,y2) - if (flags & OMIT_LAST) { - SiSSetupCMDFlag(NO_LAST_PIXEL) + if(flags & OMIT_LAST) { + SiSSetupCMDFlag(NO_LAST_PIXEL) } else { - pSiS->CommandReg &= ~(NO_LAST_PIXEL); + pSiS->CommandReg &= ~(NO_LAST_PIXEL); } + +#ifdef SISVRAMQ + SiSCheckQueue(16 * 2); + SiSSetupX0Y0X1Y1(x1,y1,x2,y2) + SiSSetupDSTBaseDoCMD(dstbase) +#else + SiSSetupDSTBase(dstbase) + SiSSetupX0Y0(x1,y1) + SiSSetupX1Y1(x2,y2) SiSDoCMD +#endif } static void @@ -598,22 +920,32 @@ SiSSubsequentSolidHorzVertLine(ScrnInfoPtr pScrn, len--; /* starting point is included! */ dstbase = 0; - if ((y >= 2048) || ((y + len) >= 2048)) { - dstbase = pSiS->scrnOffset * y; - y = 0; + if((y >= 2048) || ((y + len) >= 2048)) { + dstbase = pSiS->scrnOffset * y; + y = 0; } #ifdef SISDUALHEAD dstbase += HEADOFFSET; #endif - SiSSetupDSTBase(dstbase) +#ifdef SISVRAMQ + SiSCheckQueue(16 * 2); + if(dir == DEGREES_0) { + SiSSetupX0Y0X1Y1(x, y, (x + len), y) + } else { + SiSSetupX0Y0X1Y1(x, y, x, (y + len)) + } + SiSSetupDSTBaseDoCMD(dstbase) +#else + SiSSetupDSTBase(dstbase) SiSSetupX0Y0(x,y) - if (dir == DEGREES_0) { - SiSSetupX1Y1(x + len, y); + if(dir == DEGREES_0) { + SiSSetupX1Y1(x + len, y); } else { - SiSSetupX1Y1(x, y + len); + SiSSetupX1Y1(x, y + len); } SiSDoCMD +#endif } static void @@ -626,21 +958,38 @@ SiSSetupForDashedLine(ScrnInfoPtr pScrn, PDEBUG(ErrorF("Setup DashedLine(0x%x, 0x%x, 0x%x, 0x%x, %d, 0x%x:%x)\n", fg, bg, rop, planemask, length, *(pattern+4), *pattern)); +#ifdef SISVRAMQ + SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); + SiSCheckQueue(16 * 3); + SiSSetupLineCountPeriod(1, length-1) + SiSSetupStyle(*pattern,*(pattern+4)) + SiSSetupPATFGDSTRect(fg, pSiS->scrnOffset, -1) +#else SiSSetupLineCount(1) SiSSetupDSTRect(pSiS->scrnOffset, -1) SiSSetupDSTColorDepth(pSiS->DstColor); SiSSetupStyleLow(*pattern) SiSSetupStyleHigh(*(pattern+4)) - SiSSetupStylePeriod(length-1); /* TW: This was missing!!! */ - SiSSetupROP(sisPatALUConv[rop]) + SiSSetupStylePeriod(length-1); SiSSetupPATFG(fg) - SiSSetupCMDFlag(LINE | LINE_STYLE) /* TW: This was missing!!! */ - if (bg != -1) { - SiSSetupPATBG(bg) +#endif + + SiSSetupROP(sisPatALUConv[rop]) + + SiSSetupCMDFlag(LINE | LINE_STYLE) + + if(bg != -1) { + SiSSetupPATBG(bg) } else { - SiSSetupCMDFlag(TRANSPARENT) /* TW: This was missing!!! */ + SiSSetupCMDFlag(TRANSPARENT) } +#ifndef SISVRAMQ SiSSetupCMDFlag(pSiS->SiS310_AccelDepth) +#endif + +#ifdef SISVRAMQ + SiSSyncWP +#endif } static void @@ -655,26 +1004,33 @@ SiSSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, x1, y1, x2, y2, flags, phase)); dstbase = 0; - miny=(y1 > y2) ? y2 : y1; - maxy=(y1 > y2) ? y1 : y2; - if (maxy >= 2048) { - dstbase = pSiS->scrnOffset * miny; - y1 -= miny; - y2 -= miny; + miny = (y1 > y2) ? y2 : y1; + maxy = (y1 > y2) ? y1 : y2; + if(maxy >= 2048) { + dstbase = pSiS->scrnOffset * miny; + y1 -= miny; + y2 -= miny; } #ifdef SISDUALHEAD dstbase += HEADOFFSET; #endif - SiSSetupDSTBase(dstbase) - SiSSetupX0Y0(x1,y1) - SiSSetupX1Y1(x2,y2) - if (flags & OMIT_LAST) { - SiSSetupCMDFlag(NO_LAST_PIXEL) + if(flags & OMIT_LAST) { + SiSSetupCMDFlag(NO_LAST_PIXEL) } else { - pSiS->CommandReg &= ~(NO_LAST_PIXEL); + pSiS->CommandReg &= ~(NO_LAST_PIXEL); } + +#ifdef SISVRAMQ + SiSCheckQueue(16 * 2); + SiSSetupX0Y0X1Y1(x1,y1,x2,y2) + SiSSetupDSTBaseDoCMD(dstbase) +#else + SiSSetupDSTBase(dstbase) + SiSSetupX0Y0(x1,y1) + SiSSetupX1Y1(x2,y2) SiSDoCMD +#endif } static void @@ -686,13 +1042,36 @@ SiSSetupForMonoPatternFill(ScrnInfoPtr pScrn, PDEBUG(ErrorF("Setup MonoPatFill(0x%x,0x%x, 0x%x,0x%x, 0x%x, 0x%x)\n", patx, paty, fg, bg, rop, planemask)); + +#ifdef SISVRAMQ + SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); + SiSCheckQueue(16 * 3); + SiSSetupPATFGDSTRect(fg, pSiS->scrnOffset, -1) +#else SiSSetupDSTRect(pSiS->scrnOffset, -1) SiSSetupDSTColorDepth(pSiS->DstColor); +#endif + SiSSetupMONOPAT(patx,paty) - SiSSetupPATFG(fg) + SiSSetupROP(sisPatALUConv[rop]) + +#ifdef SISVRAMQ + SiSSetupCMDFlag(PATMONO) +#else + SiSSetupPATFG(fg) SiSSetupCMDFlag(PATMONO | pSiS->SiS310_AccelDepth) - SiSSetupPATBG(bg) +#endif + + if(bg != -1) { + SiSSetupPATBG(bg) + } else { + SiSSetupCMDFlag(TRANSPARENT) + } + +#ifdef SISVRAMQ + SiSSyncWP +#endif } static void @@ -706,25 +1085,36 @@ SiSSubsequentMonoPatternFill(ScrnInfoPtr pScrn, PDEBUG(ErrorF("Subsequent MonoPatFill(0x%x,0x%x, %d,%d, %d,%d)\n", patx, paty, x, y, w, h)); dstbase = 0; - if (y >= 2048) { - dstbase = pSiS->scrnOffset * y; - y = 0; + if(y >= 2048) { + dstbase = pSiS->scrnOffset * y; + y = 0; } #ifdef SISDUALHEAD dstbase += HEADOFFSET; #endif - SiSSetupDSTBase(dstbase) - SiSSetupDSTXY(x,y) - SiSSetupRect(w,h) + /* Clear commandReg because Setup can be used for Rect and Trap */ pSiS->CommandReg &= ~(T_XISMAJORL | T_XISMAJORR | T_L_X_INC | T_L_Y_INC | T_R_X_INC | T_R_Y_INC | TRAPAZOID_FILL); + +#ifdef SISVRAMQ + SiSCheckQueue(16 * 2); + SiSSetupDSTXYRect(x,y,w,h) + SiSSetupDSTBaseDoCMD(dstbase) +#else + SiSSetupDSTBase(dstbase) + SiSSetupDSTXY(x,y) + SiSSetupRect(w,h) SiSDoCMD +#endif } -/* TW: Trapezoid */ +/* --- Trapezoid --- */ + +/* Does not work at all on 330 series */ + #ifdef TRAP static void SiSSubsequentMonoPatternFillTrap(ScrnInfoPtr pScrn, @@ -740,14 +1130,19 @@ SiSSubsequentMonoPatternFillTrap(ScrnInfoPtr pScrn, y, h, left, right, dxL, dxR, eL, eR)); dstbase = 0; - if (y >= 2048) { - dstbase=pSiS->scrnOffset*y; - y = 0; + if(y >= 2048) { + dstbase=pSiS->scrnOffset*y; + y = 0; } #ifdef SISDUALHEAD dstbase += HEADOFFSET; #endif + +#ifdef SISVRAMQ + SiSCheckQueue(16 * 4); +#else SiSSetupDSTBase(dstbase) +#endif /* Clear CommandReg because SetUp can be used for Rect and Trap */ pSiS->CommandReg &= ~(T_XISMAJORL | T_XISMAJORR | @@ -755,72 +1150,262 @@ SiSSubsequentMonoPatternFillTrap(ScrnInfoPtr pScrn, T_R_X_INC | T_R_Y_INC | BITBLT); - if (dxL < 0) { dxL = -dxL; } - else { SiSSetupCMDFlag(T_L_X_INC) } - if (dxR < 0) { dxR = -dxR; } - else { SiSSetupCMDFlag(T_R_X_INC) } + if(dxL < 0) { dxL = -dxL; } + else { SiSSetupCMDFlag(T_L_X_INC) } + if(dxR < 0) { dxR = -dxR; } + else { SiSSetupCMDFlag(T_R_X_INC) } - if (dyL < 0) { dyL = -dyL; } - else { SiSSetupCMDFlag(T_L_Y_INC) } - if (dyR < 0) { dyR = -dyR; } - else { SiSSetupCMDFlag(T_R_Y_INC) } + if(dyL < 0) { dyL = -dyL; } + else { SiSSetupCMDFlag(T_L_Y_INC) } + if(dyR < 0) { dyR = -dyR; } + else { SiSSetupCMDFlag(T_R_Y_INC) } /* Determine major axis */ - if (dxL >= dyL) { /* X is major axis */ - SiSSetupCMDFlag(T_XISMAJORL) - } - if (dxR >= dyR) { /* X is major axis */ - SiSSetupCMDFlag(T_XISMAJORR) - } + if(dxL >= dyL) { SiSSetupCMDFlag(T_XISMAJORL) } + if(dxR >= dyR) { SiSSetupCMDFlag(T_XISMAJORR) } - SiSSetupYH(y,h) - SiSSetupLR(left,right) + SiSSetupCMDFlag(TRAPAZOID_FILL); +#ifdef SISVRAMQ + SiSSetupYHLR(y, h, left, right) + SiSSetupdLdR(dxL, dyL, dxR, dyR) + SiSSetupELER(eL, eR) + SiSSetupDSTBaseDoCMD(dstbase) +#else + SiSSetupYH(y, h) + SiSSetupLR(left, right) SiSSetupdL(dxL, dyL) SiSSetupdR(dxR, dyR) - SiSSetupEL(eL) SiSSetupER(eR) + SiSDoCMD +#endif +} +#endif - SiSSetupCMDFlag(TRAPAZOID_FILL); +/* Color 8x8 pattern */ - SiSDoCMD +#ifdef SISVRAMQ +static void +SiSSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, + int rop, unsigned int planemask, int trans_col) +{ + SISPtr pSiS = SISPTR(pScrn); + int j = pScrn->bitsPerPixel >> 3; + CARD32 *patadr = (CARD32 *)(pSiS->FbBase + (patterny * pSiS->scrnOffset) + + (patternx * j)); + +#ifdef ACCELDEBUG + xf86DrvMsg(0, X_INFO, "Setup Color8x8PatFill(0x%x, 0x%x, 0x%x, 0x%x)\n", + patternx, patterny, rop, planemask); +#endif + + SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); + SiSCheckQueue(16 * 3); + + SiSSetupDSTRectBurstHeader(pSiS->scrnOffset, -1, PATTERN_REG, (pScrn->bitsPerPixel << 1)) + + while(j--) { + SiSSetupPatternRegBurst(patadr[0], patadr[1], patadr[2], patadr[3]); + SiSSetupPatternRegBurst(patadr[4], patadr[5], patadr[6], patadr[7]); + SiSSetupPatternRegBurst(patadr[8], patadr[9], patadr[10], patadr[11]); + SiSSetupPatternRegBurst(patadr[12], patadr[13], patadr[14], patadr[15]); + patadr += 16; /* = 64 due to (CARD32 *) */ + } + + SiSSetupROP(sisPatALUConv[rop]) + + SiSSetupCMDFlag(PATPATREG) + + SiSSyncWP +} + +static void +SiSSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patternx, + int patterny, int x, int y, int w, int h) +{ + SISPtr pSiS = SISPTR(pScrn); + long dstbase; + +#ifdef ACCELDEBUG + xf86DrvMsg(0, X_INFO, "Subsequent Color8x8FillRect(%d, %d, %d, %d)\n", + x, y, w, h); +#endif + + dstbase = 0; + if(y >= 2048) { + dstbase = pSiS->scrnOffset * y; + y = 0; + } +#ifdef SISDUALHEAD + dstbase += HEADOFFSET; +#endif + /* SiSSetupCMDFlag(BITBLT) - BITBLT = 0 */ + + SiSCheckQueue(16 * 2) + SiSSetupDSTXYRect(x,y,w,h) + SiSSetupDSTBaseDoCMD(dstbase) } #endif -/* ---- CPUToScreen Color Expand */ +/* ---- CPUToScreen Color Expand --- */ #ifdef CTSCE -/* We use the indirect method */ + +#ifdef CTSCE_DIRECT + +/* Direct method */ + +/* This is somewhat a fake. We let XAA copy its data not to an + * aperture, but to video RAM, and then do a ScreenToScreen + * color expansion. + * Since the data is sent AFTER the call to Subsequent, we + * don't execute the command here, but set a flag and do + * that in the (subsequent) call to Sync() + */ + +static void +SiSSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, int rop, unsigned int planemask) +{ + SISPtr pSiS=SISPTR(pScrn); + +#ifdef SISVRAMQ + SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); + SiSSetupROP(sisALUConv[rop]); + SiSSetupSRCFGDSTRect(fg, pSiS->scrnOffset, -1) + if(bg == -1) { + SiSSetupCMDFlag(TRANSPARENT | ENCOLOREXP | SRCVIDEO); + } else { + SiSSetupSRCBG(bg); + SiSSetupCMDFlag(ENCOLOREXP | SRCVIDEO); + } + SiSSyncWP +#else + SiSSetupSRCXY(0,0); + SiSSetupROP(sisALUConv[rop]); + SiSSetupSRCFG(fg); + SiSSetupDSTRect(pSiS->scrnOffset, -1); + SiSSetupDSTColorDepth(pSiS->DstColor); + if(bg == -1) { + SiSSetupCMDFlag(TRANSPARENT | ENCOLOREXP | SRCVIDEO + | pSiS->SiS310_AccelDepth); + } else { + SiSSetupSRCBG(bg); + SiSSetupCMDFlag(ENCOLOREXP | SRCVIDEO | pSiS->SiS310_AccelDepth); + } +#endif +} + +static void +SiSSubsequentCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, int x, int y, int w, + int h, int skipleft) +{ + SISPtr pSiS = SISPTR(pScrn); + int _x0, _y0, _x1, _y1; + long srcbase, dstbase; + + srcbase = pSiS->ColorExpandBase; + + dstbase = 0; + if(y >= 2048) { + dstbase = pSiS->scrnOffset*y; + y = 0; + } + +#ifdef SISDUALHEAD + srcbase += HEADOFFSET; + dstbase += HEADOFFSET; +#endif + +#ifdef SISVRAMQ + SiSSetupSRCDSTBase(srcbase,dstbase); +#else + SiSSetupSRCBase(srcbase); + SiSSetupDSTBase(dstbase) +#endif + + if(skipleft > 0) { + _x0 = x + skipleft; + _y0 = y; + _x1 = x + w; + _y1 = y + h; +#ifdef SISVRAMQ + SiSSetupClip(_x0, _y0, _x1, _y1); +#else + SiSSetupClipLT(_x0, _y0); + SiSSetupClipRB(_x1, _y1); +#endif + SiSSetupCMDFlag(CLIPENABLE); + } else { + pSiS->CommandReg &= (~CLIPENABLE); + } + +#ifdef SISVRAMQ + SiSSetupRectSRCPitch(w, h, ((((w + 7) >> 3) + 3) >> 2) << 2); + SiSSetupSRCDSTXY(0, 0, x, y); +#else + SiSSetupRect(w, h); + SiSSetupSRCPitch(((((w+7)/8)+3) >> 2) * 4); + SiSSetupDSTXY(x, y); +#endif + + if(pSiS->ColorExpandBusy) { + pSiS->ColorExpandBusy = FALSE; + SiSIdle + } + + pSiS->DoColorExpand = TRUE; +} + +#else + +/* Indirect method */ + +/* This is SLOW, slower than the CPU on most chipsets */ +/* Does not work in VRAM queue mode. */ + static void SiSSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask) { SISPtr pSiS=SISPTR(pScrn); - /* TW: FIXME: How do I check the "CPU driven blit stage" on the - * 310/325 series? - * That's the 300 series method but definitely wrong for - * 310/325 series (bit 28 is already used for idle!) - */ - /* while ((MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x1F00) != 0) {} */ +#ifdef SISVRAMQ + SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); +#endif - /* TW: Do Idle instead... */ - SiSIdle + /* !!! DOES NOT WORK IN VRAM QUEUE MODE !!! */ + /* (hence this is not optimized for VRAM mode) */ +#ifndef SISVRAMQ + SiSIdle +#endif SiSSetupSRCXY(0,0); + SiSSetupROP(sisALUConv[rop]); SiSSetupSRCFG(fg); SiSSetupDSTRect(pSiS->scrnOffset, -1); +#ifndef SISVRAMQ SiSSetupDSTColorDepth(pSiS->DstColor); - if (bg == -1) { - SiSSetupCMDFlag(TRANSPARENT | ENCOLOREXP | SRCCPUBLITBUF - | pSiS->SiS310_AccelDepth); +#endif + if(bg == -1) { +#ifdef SISVRAMQ + SiSSetupCMDFlag(TRANSPARENT | ENCOLOREXP | SRCVIDEO); +#else + SiSSetupCMDFlag(TRANSPARENT | ENCOLOREXP | SRCCPUBLITBUF + | pSiS->SiS310_AccelDepth); +#endif } else { - SiSSetupSRCBG(bg); - SiSSetupCMDFlag(ENCOLOREXP | SRCCPUBLITBUF - | pSiS->SiS310_AccelDepth); + SiSSetupSRCBG(bg); +#ifdef SISVRAMQ + SiSSetupCMDFlag(ENCOLOREXP | SRCCPUBLITBUF); +#else + SiSSetupCMDFlag(ENCOLOREXP | SRCCPUBLITBUF | pSiS->SiS310_AccelDepth); +#endif }; + } static void @@ -833,41 +1418,48 @@ SiSSubsequentScanlineCPUToScreenColorExpandFill( long dstbase; dstbase = 0; - if (y >= 2048) { - dstbase = pSiS->scrnOffset*y; - y = 0; + if(y >= 2048) { + dstbase = pSiS->scrnOffset*y; + y = 0; } #ifdef SISDUALHEAD dstbase += HEADOFFSET; #endif +#ifndef SISVRAMQ if((MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000) { - SiSIdle; + SiSIdle; } +#endif SiSSetupDSTBase(dstbase) - if (skipleft > 0) { - _x0 = x+skipleft; - _y0 = y; - _x1 = x+w; - _y1 = y+h; - SiSSetupClipLT(_x0, _y0); - SiSSetupClipRB(_x1, _y1); - SiSSetupCMDFlag(CLIPENABLE); + if(skipleft > 0) { + _x0 = x+skipleft; + _y0 = y; + _x1 = x+w; + _y1 = y+h; +#ifdef SISVRAMQ + SiSSetupClip(_x0, _y0, _x1, _y1); +#else + SiSSetupClipLT(_x0, _y0); + SiSSetupClipRB(_x1, _y1); +#endif + SiSSetupCMDFlag(CLIPENABLE); } else { - pSiS->CommandReg &= (~CLIPENABLE); + pSiS->CommandReg &= (~CLIPENABLE); } SiSSetupRect(w, 1); SiSSetupSRCPitch(((((w+7)/8)+3) >> 2) * 4); pSiS->ycurrent = y; pSiS->xcurrent = x; + } static void SiSSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) { - SISPtr pSiS=SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); long cbo; cbo = pSiS->ColorExpandBufferScreenOffset[bufno]; @@ -875,9 +1467,11 @@ SiSSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) cbo += HEADOFFSET; #endif +#ifndef SISVRAMQ if((MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000) { - SiSIdle; + SiSIdle; } +#endif SiSSetupSRCBase(cbo); @@ -886,9 +1480,428 @@ SiSSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) SiSDoCMD pSiS->ycurrent++; +#ifndef SISVRAMQ + SiSIdle +#endif +} +#endif +#endif + +/* --- Screen To Screen Color Expand --- */ + +/* This method blits in a single task; this does not work because + * the hardware does not use the source pitch as scanline offset + * but to calculate pattern address from source X and Y and to + * 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 330 SERIES, HANGS ENGINE. + */ + +#ifdef STSCE +static void +SiSSetupForScreenToScreenColorExpand(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, unsigned int planemask) +{ + SISPtr pSiS = SISPTR(pScrn); + +#ifdef SISVRAMQ + SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); +#else + SiSSetupDSTColorDepth(pSiS->DstColor) +#endif + SiSSetupDSTRect(pSiS->scrnOffset, -1) + SiSSetupROP(sisALUConv[rop]) + SiSSetupSRCFG(fg) + /* SiSSetupSRCXY(0,0) */ + if(bg == -1) { + SiSSetupCMDFlag(TRANSPARENT | ENCOLOREXP | SRCVIDEO); + } else { + SiSSetupSRCBG(bg); + SiSSetupCMDFlag(ENCOLOREXP | SRCVIDEO); + }; + +#ifdef SISVRAMQ + SiSSyncWP +#endif +} + +/* For testing, these are the methods: (use only one at a time!) */ + +#undef npitch /* Normal: Use srcx/y as srcx/y, use scrnOffset as source pitch + * Does not work on 315 series, because the hardware does not + * regard the src x and y. Apart from this problem: + * This would work if the hareware used the source pitch for + * incrementing the source address after each scanline - but + * it doesn't do this! The first line of the area is correctly + * color expanded, but since the source pitch is ignored and + * the source address not incremented correctly, the following + * lines are color expanded with any bit pattern that is left + * in the unused space of the source bitmap (which is organized + * with the depth of the screen framebuffer hence with a pitch + * of scrnOffset). + */ + +#undef pitchdw /* Use source pitch "displayWidth / 8" instead + * of scrnOffset (=displayWidth * bpp / 8) + * This can't work, because the pitch of the source + * bitmap is scrnoffset! + */ + +#define nopitch /* Calculate srcbase with srcx and srcy, set the + * pitch to scrnOffset (which IS the correct pitch + * for the source bitmap) and set srcx and srcy both + * to 0. + * This would work if the hareware used the source pitch for + * incrementing the source address after each scanline - but + * it doesn't do this! Again: The first line of the area is + * correctly color expanded, but since the source pitch is + * ignored for scanline address incremention, the following + * lines are not correctly color expanded. + * This is the only way it works (apart from the problem + * described above). The hardware does not regard the src + * x and y values in any way. + */ + +static void +SiSSubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int srcx, int srcy, int skipleft) +{ + SISPtr pSiS = SISPTR(pScrn); + long srcbase, dstbase; +#if 0 + int _x0, _y0, _x1, _y1; +#endif +#ifdef pitchdw + int newsrcx, newsrcy; + + /* srcx and srcy are provided based on a scrnOffset pitch ( = displayWidth * bpp / 8 ) + * We recalulate srcx and srcy based on pitch = displayWidth / 8 + */ + newsrcy = ((pSiS->scrnOffset * srcy) + (srcx * ((pScrn->bitsPerPixel+7)/8))) / + (pScrn->displayWidth/8); + newsrcx = ((pSiS->scrnOffset * srcy) + (srcx * ((pScrn->bitsPerPixel+7)/8))) % + (pScrn->displayWidth/8); +#endif + xf86DrvMsg(0, X_INFO, "Sub ScreenToScreen ColorExp(%d,%d, %d,%d, %d,%d, %d)\n", + x, y, w, h, srcx, srcy, skipleft); + + srcbase = dstbase = 0; + +#ifdef pitchdw + if(newsrcy >= 2048) { + srcbase = (pScrn->displayWidth / 8) * newsrcy; + newsrcy = 0; + } +#endif +#ifdef nopitch + srcbase = (pSiS->scrnOffset * srcy) + (srcx * ((pScrn->bitsPerPixel+7)/8)); +#endif +#ifdef npitch + if(srcy >= 2048) { + srcbase = pSiS->scrnOffset * srcy; + srcy = 0; + } +#endif + if(y >= 2048) { + dstbase = pSiS->scrnOffset * y; + y = 0; + } + +#ifdef SISDUALHEAD + srcbase += HEADOFFSET; + dstbase += HEADOFFSET; +#endif + + SiSSetupSRCBase(srcbase) + SiSSetupDSTBase(dstbase) + + /* 315 series seem to treat the src pitch as + * a "drawing limit", but still (as 300 series) + * does not use it for incrementing the + * address pointer for the next scanline. ARGH! + */ + +#ifdef pitchdw + SiSSetupSRCPitch(pScrn->displayWidth/8) +#endif +#ifdef nopitch + SiSSetupSRCPitch(pScrn->displayWidth/8) + /* SiSSetupSRCPitch(1024/8) */ /* For test */ +#endif +#ifdef npitch + SiSSetupSRCPitch(pScrn->displayWidth/8) + /* SiSSetupSRCPitch(pSiS->scrnOffset) */ +#endif + + SiSSetupRect(w,h) + +#if 0 /* How do I implement the offset? Not this way, that's for sure.. */ + if (skipleft > 0) { + _x0 = x+skipleft; + _y0 = y; + _x1 = x+w; + _y1 = y+h; + SiSSetupClipLT(_x0, _y0); + SiSSetupClipRB(_x1, _y1); + SiSSetupCMDFlag(CLIPENABLE); + } +#endif +#ifdef pitchdw + SiSSetupSRCXY(newsrcx, newsrcy) +#endif +#ifdef nopitch + SiSSetupSRCXY(0,0) +#endif +#ifdef npitch + SiSSetupSRCXY(srcx, srcy) +#endif + + SiSSetupDSTXY(x,y) + + SiSDoCMD +#ifdef SISVRAMQ + /* We MUST sync here, there must not be 2 or more color expansion commands in the queue */ SiSIdle +#endif +} +#endif + +/* ---- RENDER ---- */ + +#ifdef INCL_RENDER +#ifdef RENDER +static void +SiSRenderCallback(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + + if((currentTime.milliseconds > pSiS->RenderTime) && pSiS->AccelLinearScratch) { + xf86FreeOffscreenLinear(pSiS->AccelLinearScratch); + pSiS->AccelLinearScratch = NULL; + } + + if(!pSiS->AccelLinearScratch) { + pSiS->RenderCallback = NULL; + } +} + +#define RENDER_DELAY 15000 + +static Bool +SiSAllocateLinear(ScrnInfoPtr pScrn, int sizeNeeded) +{ + SISPtr pSiS = SISPTR(pScrn); + + pSiS->RenderTime = currentTime.milliseconds + RENDER_DELAY; + pSiS->RenderCallback = SiSRenderCallback; + + if(pSiS->AccelLinearScratch) { + if(pSiS->AccelLinearScratch->size >= sizeNeeded) { + return TRUE; + } else { + if(pSiS->alphaBlitBusy) { + pSiS->alphaBlitBusy = FALSE; + SiSIdle + } + if(xf86ResizeOffscreenLinear(pSiS->AccelLinearScratch, sizeNeeded)) { + return TRUE; + } + xf86FreeOffscreenLinear(pSiS->AccelLinearScratch); + pSiS->AccelLinearScratch = NULL; + } + } + + pSiS->AccelLinearScratch = xf86AllocateOffscreenLinear( + pScrn->pScreen, sizeNeeded, 32, + NULL, NULL, NULL); + + return(pSiS->AccelLinearScratch != NULL); +} + +Bool +SiSSetupForCPUToScreenAlphaTexture(ScrnInfoPtr pScrn, + int op, CARD16 red, CARD16 green, + CARD16 blue, CARD16 alpha, + int alphaType, CARD8 *alphaPtr, + int alphaPitch, int width, + int height, int flags) +{ + SISPtr pSiS = SISPTR(pScrn); + int x, pitch, sizeNeeded, offset; + CARD8 myalpha; + CARD32 *dstPtr; + 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); +#endif + + if(op != PictOpOver) return FALSE; + + if((width > 2048) || (height > 2048)) return FALSE; + + pitch = (width + 31) & ~31; + sizeNeeded = pitch * height; + if(pScrn->bitsPerPixel == 16) sizeNeeded <<= 1; + + red &= 0xff00; + green &= 0xff00; + blue &= 0xff00; + + if(!((renderaccelarray = pSiS->RenderAccelArray))) + return FALSE; + + if(!SiSAllocateLinear(pScrn, sizeNeeded)) + return FALSE; + +#ifdef SISVRAMQ + SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); + SiSSetupSRCPitchDSTRect((pitch << 2), pSiS->scrnOffset, -1); + SiSSetupCMDFlag(ALPHA_BLEND | SRCVIDEO | A_PERPIXELALPHA) + SiSSyncWP +#else + SiSSetupDSTColorDepth(pSiS->DstColor); + SiSSetupSRCPitch((pitch << 2)); + SiSSetupDSTRect(pSiS->scrnOffset, -1) + SiSSetupROP(0) + SiSSetupCMDFlag(ALPHA_BLEND | SRCVIDEO | A_PERPIXELALPHA | pSiS->SiS310_AccelDepth) +#endif + + offset = pSiS->AccelLinearScratch->offset << 1; + if(pScrn->bitsPerPixel == 32) offset <<= 1; + + dstPtr = (CARD32*)(pSiS->FbBase + offset); + + if(pSiS->alphaBlitBusy) { + pSiS->alphaBlitBusy = FALSE; + 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; + } + + return TRUE; } + +Bool +SiSSetupForCPUToScreenTexture(ScrnInfoPtr pScrn, + int op, int texType, CARD8 *texPtr, + int texPitch, int width, + int height, int flags) +{ + SISPtr pSiS = SISPTR(pScrn); + int pitch, sizeNeeded, offset; + CARD8 *dst; + +#ifdef ACCELDEBUG + xf86DrvMsg(0, X_INFO, "T: type %d op %d w %d h %d T-pitch %d\n", + texType, op, width, height, texPitch); +#endif + + if(op != PictOpOver) return FALSE; + + if((width > 2048) || (height > 2048)) return FALSE; + + pitch = (width + 31) & ~31; + sizeNeeded = pitch * height; + if(pScrn->bitsPerPixel == 16) sizeNeeded <<= 1; + + width <<= 2; + pitch <<= 2; + + if(!SiSAllocateLinear(pScrn, sizeNeeded)) + return FALSE; + +#ifdef SISVRAMQ + SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth); + SiSSetupSRCPitchDSTRect(pitch, pSiS->scrnOffset, -1); + SiSSetupAlpha(0x00) + SiSSetupCMDFlag(ALPHA_BLEND | SRCVIDEO | A_PERPIXELALPHA) + SiSSyncWP +#else + SiSSetupDSTColorDepth(pSiS->DstColor); + SiSSetupSRCPitch(pitch); + SiSSetupDSTRect(pSiS->scrnOffset, -1) + SiSSetupAlpha(0x00) + SiSSetupCMDFlag(ALPHA_BLEND | SRCVIDEO | A_PERPIXELALPHA | pSiS->SiS310_AccelDepth) #endif + offset = pSiS->AccelLinearScratch->offset << 1; + if(pScrn->bitsPerPixel == 32) offset <<= 1; + + dst = (CARD8*)(pSiS->FbBase + offset); + + if(pSiS->alphaBlitBusy) { + pSiS->alphaBlitBusy = FALSE; + SiSIdle + } + + while(height--) { + memcpy(dst, texPtr, width); + texPtr += texPitch; + dst += pitch; + } + + return TRUE; +} + +void +SiSSubsequentCPUToScreenTexture(ScrnInfoPtr pScrn, + int dst_x, int dst_y, + int src_x, int src_y, + int width, int height) +{ + SISPtr pSiS = SISPTR(pScrn); + long srcbase, dstbase; + + srcbase = pSiS->AccelLinearScratch->offset << 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", + srcbase, dst_x, dst_y, width, height); +#endif + + dstbase = 0; + if((dst_y >= pScrn->virtualY) || (dst_y >= 2048)) { + dstbase = pSiS->scrnOffset * dst_y; + dst_y = 0; + } +#ifdef SISDUALHEAD + srcbase += HEADOFFSET; + dstbase += HEADOFFSET; +#endif + +#ifdef SISVRAMQ + SiSCheckQueue(16 * 3) + SiSSetupSRCDSTBase(srcbase,dstbase); + SiSSetupSRCDSTXY(src_x, src_y, dst_x, dst_y) + SiSSetRectDoCMD(width,height) +#else + SiSSetupSRCBase(srcbase); + SiSSetupDSTBase(dstbase); + SiSSetupRect(width, height) + SiSSetupSRCXY(src_x, src_y) + SiSSetupDSTXY(dst_x, dst_y) + SiSDoCMD +#endif + pSiS->alphaBlitBusy = TRUE; +} +#endif +#endif diff --git a/src/sis310_accel.h b/src/sis310_accel.h index 9a6b20a..da85d67 100644 --- a/src/sis310_accel.h +++ b/src/sis310_accel.h @@ -1,47 +1,48 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis310_accel.h,v 1.2 2003/01/29 15:42:16 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis310_accel.h,v 1.14 2003/10/30 18:53:42 twini Exp $ */ /* - * Copyright 2002 by Thomas Winischhofer, Vienna, Austria + * 2D Acceleration for SiS 315 and Xabre series + * Definitions for the SIS engine communication. + * + * Copyright 2002, 2003 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 Thomas Winischhofer not be used in + * 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. Thomas Winischhofer makes no representations + * 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. * - * THOMAS WINISCHHOFER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THOMAS WINISCHHOFER BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * 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 * - * Author: Thomas Winischhofer <thomas@winischhofer.net> + * Author: Thomas Winischhofer <thomas@winischhofer.net> * */ -/* Definitions for the SIS engine communication. */ - - -/* SiS310 engine commands */ +/* SiS315 and 330 engine commands */ #define BITBLT 0x00000000 /* Blit */ #define COLOREXP 0x00000001 /* Color expand */ -#define ENCOLOREXP 0x00000002 /* Enhanced color expand */ +#define ENCOLOREXP 0x00000002 /* Enhanced color expand (315 only?) */ #define MULTIPLE_SCANLINE 0x00000003 /* ? */ #define LINE 0x00000004 /* Draw line */ #define TRAPAZOID_FILL 0x00000005 /* Fill trapezoid */ #define TRANSPARENT_BITBLT 0x00000006 /* Transparent Blit */ -#define ALPHA_BLEND 0x00000007 /* Alpha blend ? */ +#define ALPHA_BLEND 0x00000007 /* Alpha blended BitBlt */ #define A3D_FUNCTION 0x00000008 /* 3D command ? */ #define CLEAR_Z_BUFFER 0x00000009 /* ? */ #define GRADIENT_FILL 0x0000000A /* Gradient fill */ -#define STRETCH_BITBLT 0x0000000B /* Stretched Blit */ +#define STRETCH_BITBLT 0x0000000B /* Stretched BitBlit */ /* Command bits */ @@ -62,13 +63,19 @@ #define CLIPENABLE 0x00040000 #define CLIPWITHOUTMERGE 0x04040000 -/* Transparency */ +/* Subfunctions for BitBlt: Transparency */ #define OPAQUE 0x00000000 #define TRANSPARENT 0x00100000 -/* ? */ +/* Subfunctions for Alpha Blended BitBlt */ +#define A_CONSTANTALPHA 0x00000000 +#define A_PERPIXELALPHA 0x00080000 +#define A_NODESTALPHA 0x00100000 +#define A_3DFULLSCENE 0x00180000 + +/* Destination */ #define DSTAGP 0x02000000 -#define DSTVIDEO 0x02000000 +#define DSTVIDEO 0x00000000 /* Subfunctions for Color/Enhanced Color Expansion */ #define COLOR_TO_MONO 0x00100000 @@ -79,7 +86,7 @@ #define NO_RESET_COUNTER 0x00400000 #define NO_LAST_PIXEL 0x00200000 -/* Trapezoid */ +/* Trapezoid (315 only?) */ #define T_XISMAJORL 0x00800000 /* X axis is driving axis (left) */ #define T_XISMAJORR 0x08000000 /* X axis is driving axis (right) */ #define T_L_Y_INC 0x00000020 /* left edge direction Y */ @@ -132,6 +139,8 @@ #define TRANS_SRC_KEY_HIGH SRC_FGCOLOR #define TRANS_SRC_KEY_LOW SRC_BGCOLOR +#define ALPHA_ALPHA PAT_FGCOLOR + /* Trapezoid registers */ #define TRAP_YH SRC_Y /* 0x8208 */ #define TRAP_LR DST_Y /* 0x820C */ @@ -141,12 +150,20 @@ #define TRAP_ER 0x8250 /* Queue */ -#define Q_BASE_ADDR 0x85C0 /* Base address of software queue (?) */ -#define Q_WRITE_PTR 0x85C4 /* Current write pointer (?) */ -#define Q_READ_PTR 0x85C8 /* Current read pointer (?) */ +#define Q_BASE_ADDR 0x85C0 /* Base address of software queue */ +#define Q_WRITE_PTR 0x85C4 /* Current write pointer */ +#define Q_READ_PTR 0x85C8 /* Current read pointer */ #define Q_STATUS 0x85CC /* queue status */ -/* Macros to do useful things with the SIS 310 BitBLT engine */ +/* VRAM queue operation command header definitions */ +#define SIS_SPKC_HEADER 0x16800000L +#define SIS_BURST_HEADER0 0x568A0000L +#define SIS_BURST_HEADER1 0x62100000L +#define SIS_PACKET_HEARER0 0x968A0000L +#define SIS_PACKET_HEADER1 0x62100000L +#define SIS_NIL_CMD 0x168F0000L + +/* Macros to do useful things with the SiS315/330 BitBLT engine */ /* Q_STATUS: bit 31 = 1: All engines idle and all queues empty @@ -160,31 +177,533 @@ bits 23:16: 2D counter 3 bits 15:8: 2D counter 2 bits 7:0: 2D counter 1 - - Where is the command queue length (current amount of commands the queue - can accept) on the 310 series? (The current implementation is taken - from 300 series and certainly wrong...) */ -int CmdQueLen; +/* As sis_dri.c and dual head mode relocate the cmd-q len to the sarea/entity, + * don't use it directly here */ +#define CmdQueLen (*(pSiS->cmdQueueLenPtr)) + +#define SiSQEmpty \ + { \ + while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x0400) != 0x0400) {}; \ + while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x0400) != 0x0400) {}; \ + } + +#define SiSResetCmd pSiS->CommandReg = 0; + +#define SiSSetupCMDFlag(flags) pSiS->CommandReg |= (flags); + +/* --- VRAM mode --- */ + +#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 SiSSetHwWP(p) \ + *(pSiS->cmdQ_SharedWritePort) = (p); \ + MMIO_OUT32(pSiS->IOBase, Q_WRITE_PTR, (p)); \ + +#define SiSSetSwWP(p) *(pSiS->cmdQ_SharedWritePort) = (p); + +#define SiSCheckQueue(amount) + +#if 0 + { \ + CARD32 mcurrent, i=0, ttt = SiSGetSwWP(); \ + if((ttt + amount) >= pSiS->cmdQueueSize) { \ + do { \ + mcurrent = MMIO_IN32(pSiS->IOBase, Q_READ_PTR); \ + i++; \ + } while((mcurrent > ttt) || (mcurrent < ((ttt + amount) & pSiS->cmdQueueSizeMask))); \ + } else { \ + do { \ + mcurrent = MMIO_IN32(pSiS->IOBase, Q_READ_PTR); \ + i++; \ + } while((mcurrent > ttt) && (mcurrent < (ttt + amount))); \ + } \ + } +#endif + +#define SiSUpdateQueue \ + ttt += 16; \ + ttt &= pSiS->cmdQueueSizeMask; \ + if(!ttt) { \ + while(MMIO_IN32(pSiS->IOBase, Q_READ_PTR) < pSiS->cmdQueueSize_div4) {} \ + } else if(ttt == pSiS->cmdQueueSize_div4) { \ + CARD32 temppp; \ + do { \ + temppp = MMIO_IN32(pSiS->IOBase, Q_READ_PTR); \ + } while(temppp >= ttt && temppp <= pSiS->cmdQueueSize_div2); \ + } else if(ttt == pSiS->cmdQueueSize_div2) { \ + CARD32 temppp; \ + do { \ + temppp = MMIO_IN32(pSiS->IOBase, Q_READ_PTR); \ + } while(temppp >= ttt && temppp <= pSiS->cmdQueueSize_4_3); \ + } else if(ttt == pSiS->cmdQueueSize_4_3) { \ + while(MMIO_IN32(pSiS->IOBase, Q_READ_PTR) > ttt) {} \ + } + +/* Write-updates MUST be 128bit aligned. */ +#define SiSNILandUpdateSWQueue \ + ((CARD32 *)(tt))[2] = (CARD32)(SIS_NIL_CMD); \ + ((CARD32 *)(tt))[3] = (CARD32)(SIS_NIL_CMD); \ + SiSUpdateQueue; \ + SiSSetSwWP(ttt); + +#ifdef SISVRAMQ -/* TW: FIXME: CmdQueLen is... where....? */ #define SiSIdle \ { \ - while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000){}; \ - while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000){}; \ - CmdQueLen=MMIO_IN16(pSiS->IOBase, Q_STATUS); \ + while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000) {}; \ + while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000) {}; \ } - /* TW: (do twice like on 300 series?) */ + +#define SiSSetupSRCDSTBase(srcbase,dstbase) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + SRC_ADDR); \ + ((CARD32 *)(tt))[1] = (CARD32)(srcbase); \ + ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + DST_ADDR); \ + ((CARD32 *)(tt))[3] = (CARD32)(dstbase); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupSRCDSTXY(sx,sy,dx,dy) \ + { \ + 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))[2] = (CARD32)(SIS_SPKC_HEADER + DST_Y); \ + ((CARD32 *)(tt))[3] = (CARD32)((dx)<<16 | (dy)); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupDSTXYRect(x,y,w,h) \ + { \ + 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))[2] = (CARD32)(SIS_SPKC_HEADER + RECT_WIDTH); \ + ((CARD32 *)(tt))[3] = (CARD32)((h)<<16 | (w)); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupSRCPitchDSTRect(pitch,x,y) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((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)); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } #define SiSSetupSRCBase(base) \ - if (CmdQueLen <= 0) SiSIdle;\ - MMIO_OUT32(pSiS->IOBase, SRC_ADDR, base);\ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + SRC_ADDR); \ + ((CARD32 *)(tt))[1] = (CARD32)(base); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupSRCPitch(pitch) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + SRC_PITCH); \ + ((CARD32 *)(tt))[1] = (CARD32)(pitch); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupSRCXY(x,y) \ + { \ + 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)); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupDSTBase(base) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + DST_ADDR); \ + ((CARD32 *)(tt))[1] = (CARD32)(base); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupDSTXY(x,y) \ + { \ + 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)); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupDSTRect(x,y) \ + { \ + 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)); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupDSTRectBurstHeader(x,y,reg,num) \ + { \ + 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))[2] = (CARD32)(SIS_BURST_HEADER0 + reg); \ + ((CARD32 *)(tt))[3] = (CARD32)(SIS_BURST_HEADER1 + num); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupDSTColorDepth(bpp) \ + pSiS->CommandReg = (((CARD32)(bpp)) & (GENMASK(17:16))); + +#define SiSSetupPATFGDSTRect(color,x,y) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((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)); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupSRCFGDSTRect(color,x,y) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((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)); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupRectSRCPitch(w,h,pitch) \ + { \ + 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))[2] = (CARD32)(SIS_SPKC_HEADER + SRC_PITCH); \ + ((CARD32 *)(tt))[3] = (CARD32)(pitch); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupRect(w,h) \ + { \ + 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)); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupPATFG(color) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + PAT_FGCOLOR); \ + ((CARD32 *)(tt))[1] = (CARD32)(color); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupPATBG(color) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + PAT_BGCOLOR); \ + ((CARD32 *)(tt))[1] = (CARD32)(color); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupSRCFG(color) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + SRC_FGCOLOR); \ + ((CARD32 *)(tt))[1] = (CARD32)(color); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupSRCBG(color) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + SRC_BGCOLOR); \ + ((CARD32 *)(tt))[1] = (CARD32)(color); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupSRCTrans(color) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + TRANS_SRC_KEY_HIGH); \ + ((CARD32 *)(tt))[1] = (CARD32)(color); \ + ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + TRANS_SRC_KEY_LOW); \ + ((CARD32 *)(tt))[3] = (CARD32)(color); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupDSTTrans(color) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + TRANS_DST_KEY_HIGH); \ + ((CARD32 *)(tt))[1] = (CARD32)(color); \ + ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + TRANS_DST_KEY_LOW); \ + ((CARD32 *)(tt))[3] = (CARD32)(color); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupMONOPAT(p0,p1) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + MONO_MASK); \ + ((CARD32 *)(tt))[1] = (CARD32)(p0); \ + ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + MONO_MASK + 4); \ + ((CARD32 *)(tt))[3] = (CARD32)(p1); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupClip(left,top,right,bottom) \ + { \ + 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))[2] = (CARD32)(SIS_SPKC_HEADER + RIGHT_CLIP); \ + ((CARD32 *)(tt))[3] = (CARD32)(((right) & 0xFFFF) | (bottom)<<16); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupDSTBaseDoCMD(base) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + DST_ADDR); \ + ((CARD32 *)(tt))[1] = (CARD32)(base); \ + ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + COMMAND_READY); \ + ((CARD32 *)(tt))[3] = (CARD32)(pSiS->CommandReg); \ + SiSUpdateQueue \ + SiSSetHwWP(ttt); \ + } + +#define SiSSetRectDoCMD(w,h) \ + { \ + 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))[2] = (CARD32)(SIS_SPKC_HEADER + COMMAND_READY); \ + ((CARD32 *)(tt))[3] = (CARD32)(pSiS->CommandReg); \ + SiSUpdateQueue \ + SiSSetHwWP(ttt); \ + } + +#define SiSSetupROP(rop) \ + pSiS->CommandReg |= (rop) << 8; + +#define SiSDoCMD \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + COMMAND_READY); \ + ((CARD32 *)(tt))[1] = (CARD32)(pSiS->CommandReg); \ + ((CARD32 *)(tt))[2] = (CARD32)(SIS_NIL_CMD); \ + ((CARD32 *)(tt))[3] = (CARD32)(SIS_NIL_CMD); \ + SiSUpdateQueue \ + SiSSetHwWP(ttt); \ + } + +/* Line */ + +#define SiSSetupX0Y0X1Y1(x1,y1,x2,y2) \ + { \ + 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))[2] = (CARD32)(SIS_SPKC_HEADER + LINE_X1); \ + ((CARD32 *)(tt))[3] = (CARD32)((y2)<<16 | (x2)); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupX0Y0(x,y) \ + { \ + 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)); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupX1Y1(x,y) \ + { \ + 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)); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupLineCountPeriod(c, p) \ + { \ + 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)); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupStyle(ls,hs) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + LINE_STYLE_0); \ + ((CARD32 *)(tt))[1] = (CARD32)(ls); \ + ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + LINE_STYLE_1); \ + ((CARD32 *)(tt))[3] = (CARD32)(hs); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +/* Trapezoid */ + +#define SiSSetupYHLR(y,h,left,right) \ + { \ + 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))[2] = (CARD32)(SIS_SPKC_HEADER + TRAP_LR); \ + ((CARD32 *)(tt))[3] = (CARD32)((right)<<16 | (left)); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + + +#define SiSSetupdLdR(dxL,dyL,fxR,dyR) \ + { \ + 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))[2] = (CARD32)(SIS_SPKC_HEADER + TRAP_DR); \ + ((CARD32 *)(tt))[3] = (CARD32)((dyR)<<16 | (dxR)); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#define SiSSetupELER(eL,eR) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + TRAP_EL); \ + ((CARD32 *)(tt))[1] = (CARD32)(eL); \ + ((CARD32 *)(tt))[2] = (CARD32)(SIS_SPKC_HEADER + TRAP_ER); \ + ((CARD32 *)(tt))[3] = (CARD32)(eR); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +/* (Constant) Alpha blended BitBlt (alpha = 8 bit) */ + +#define SiSSetupAlpha(alpha) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + ALPHA_ALPHA); \ + ((CARD32 *)(tt))[1] = (CARD32)(alpha); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetPattern(num, value) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(SIS_SPKC_HEADER + (PATTERN_REG + (num * 4))); \ + ((CARD32 *)(tt))[1] = (CARD32)(value); \ + SiSNILandUpdateSWQueue \ + } + +#define SiSSetupPatternRegBurst(pat1, pat2, pat3, pat4) \ + { \ + CARD32 ttt = SiSGetSwWP(); \ + pointer tt = (char *)pSiS->cmdQueueBase + ttt; \ + ((CARD32 *)(tt))[0] = (CARD32)(pat1); \ + ((CARD32 *)(tt))[1] = (CARD32)(pat2); \ + ((CARD32 *)(tt))[2] = (CARD32)(pat3); \ + ((CARD32 *)(tt))[3] = (CARD32)(pat4); \ + SiSUpdateQueue \ + SiSSetSwWP(ttt); \ + } + +#endif /* VRAM mode */ + +/* ---- MMIO mode ---- */ + +#ifndef SISVRAMQ + +/* We assume a length of 4 bytes per command; since 512K of + * of RAM are allocated, the number of commands is easily + * calculated (and written to the address pointed to by + * CmdQueueLenPtr, since sis_dri.c relocates this) + * UPDATE: using the command queue without syncing totally + * (ie assuming a QueueLength of 0) decreases system latency + * dramatically on the integrated chipsets (sound gets interrupted, + * etc.). We now sync every time... this is a little slower, + * but it keeps the rest of the box somewhat alive. + * This was the reason for switching to VRAM queue mode. + */ +#define SiSIdle \ + { \ + if(pSiS->ChipFlags & SiSCF_Integrated) { \ + CmdQueLen = 0; \ + } else { \ + CmdQueLen = ((512 * 1024) / 4) - 64; \ + } \ + while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000) {}; \ + while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000) {}; \ + } + +#define SiSSetupSRCBase(base) \ + if (CmdQueLen <= 0) SiSIdle; \ + MMIO_OUT32(pSiS->IOBase, SRC_ADDR, base); \ CmdQueLen--; #define SiSSetupSRCPitch(pitch) \ - if (CmdQueLen <= 0) SiSIdle;\ - MMIO_OUT16(pSiS->IOBase, SRC_PITCH, pitch);\ + if (CmdQueLen <= 0) SiSIdle; \ + MMIO_OUT16(pSiS->IOBase, SRC_PITCH, pitch); \ CmdQueLen--; #define SiSSetupSRCXY(x,y) \ @@ -213,69 +732,68 @@ int CmdQueLen; CmdQueLen--; #define SiSSetupRect(w,h) \ - if (CmdQueLen <= 0) SiSIdle;\ + if(CmdQueLen <= 0) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, RECT_WIDTH, (h)<<16 | (w) );\ CmdQueLen--; #define SiSSetupPATFG(color) \ - if (CmdQueLen <= 0) SiSIdle;\ + if(CmdQueLen <= 0) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, PAT_FGCOLOR, color);\ CmdQueLen--; #define SiSSetupPATBG(color) \ - if (CmdQueLen <= 0) SiSIdle;\ + if(CmdQueLen <= 0) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, PAT_BGCOLOR, color);\ CmdQueLen--; #define SiSSetupSRCFG(color) \ - if (CmdQueLen <= 0) SiSIdle;\ + if(CmdQueLen <= 0) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, SRC_FGCOLOR, color);\ CmdQueLen--; #define SiSSetupSRCBG(color) \ - if (CmdQueLen <= 0) SiSIdle;\ - MMIO_OUT32(pSiS->IOBase, SRC_BGCOLOR, color);\ + if(CmdQueLen <= 0) SiSIdle; \ + MMIO_OUT32(pSiS->IOBase, SRC_BGCOLOR, color); \ CmdQueLen--; #define SiSSetupSRCTrans(color) \ - if (CmdQueLen <= 1) SiSIdle;\ + if(CmdQueLen <= 1) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, TRANS_SRC_KEY_HIGH, color);\ MMIO_OUT32(pSiS->IOBase, TRANS_SRC_KEY_LOW, color);\ CmdQueLen -= 2; #define SiSSetupDSTTrans(color) \ - if (CmdQueLen <= 1) SiSIdle;\ + if(CmdQueLen <= 1) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, TRANS_DST_KEY_HIGH, color); \ MMIO_OUT32(pSiS->IOBase, TRANS_DST_KEY_LOW, color); \ CmdQueLen -= 2; #define SiSSetupMONOPAT(p0,p1) \ - if (CmdQueLen <= 1) SiSIdle;\ + if(CmdQueLen <= 1) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, MONO_MASK, p0);\ MMIO_OUT32(pSiS->IOBase, MONO_MASK+4, p1);\ CmdQueLen=CmdQueLen-2; #define SiSSetupClipLT(left,top) \ - if (CmdQueLen <= 0) SiSIdle;\ - MMIO_OUT32(pSiS->IOBase, LEFT_CLIP, ((left) & 0xFFFF) | (top)<<16 );\ + if(CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, LEFT_CLIP, ((left) & 0xFFFF) | (top)<<16); \ CmdQueLen--; #define SiSSetupClipRB(right,bottom) \ - if (CmdQueLen <= 0) SiSIdle;\ - MMIO_OUT32(pSiS->IOBase, RIGHT_CLIP, ((right) & 0xFFFF) | (bottom)<<16 );\ + if(CmdQueLen <= 0) SiSIdle; \ + MMIO_OUT32(pSiS->IOBase, RIGHT_CLIP, ((right) & 0xFFFF) | (bottom)<<16); \ CmdQueLen--; #define SiSSetupROP(rop) \ pSiS->CommandReg = (rop) << 8; -#define SiSSetupCMDFlag(flags) \ - pSiS->CommandReg |= (flags); - #define SiSDoCMD \ if (CmdQueLen <= 1) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, COMMAND_READY, pSiS->CommandReg); \ MMIO_OUT32(pSiS->IOBase, FIRE_TRIGGER, 0); \ - CmdQueLen=CmdQueLen-2; + CmdQueLen -= 2; + +/* Line */ #define SiSSetupX0Y0(x,y) \ if (CmdQueLen <= 0) SiSIdle;\ @@ -308,34 +826,50 @@ int CmdQueLen; CmdQueLen--; /* Trapezoid */ + #define SiSSetupYH(y,h) \ if (CmdQueLen <= 0) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, TRAP_YH, (y)<<16 | (h) );\ - CmdQueLen --; + CmdQueLen--; #define SiSSetupLR(left,right) \ if (CmdQueLen <= 0) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, TRAP_LR, (right)<<16 | (left) );\ - CmdQueLen --; + CmdQueLen--; #define SiSSetupdL(dxL,dyL) \ if (CmdQueLen <= 0) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, TRAP_DL, (dyL)<<16 | (dxL) );\ - CmdQueLen --; + CmdQueLen--; #define SiSSetupdR(dxR,dyR) \ if (CmdQueLen <= 0) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, TRAP_DR, (dyR)<<16 | (dxR) );\ - CmdQueLen --; + CmdQueLen--; #define SiSSetupEL(eL) \ if (CmdQueLen <= 0) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, TRAP_EL, eL);\ - CmdQueLen --; + CmdQueLen--; #define SiSSetupER(eR) \ if (CmdQueLen <= 0) SiSIdle;\ MMIO_OUT32(pSiS->IOBase, TRAP_ER, eR);\ - CmdQueLen --; + CmdQueLen--; + +/* (Constant) alpha blended BitBlt (alpha = 8 bit) */ + +#define SiSSetupAlpha(alpha) \ + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, ALPHA_ALPHA, alpha);\ + CmdQueLen--; + +/* Set Pattern register */ + +#define SiSSetPattern(num, value) \ + if (CmdQueLen <= 0) SiSIdle; \ + MMIO_OUT32(pSiS->IOBase, (PATTERN_REG + (num * 4)), value); \ + CmdQueLen--; +#endif /* MMIO mode */ diff --git a/src/sis6326_video.c b/src/sis6326_video.c index f474755..15ee1eb 100644 --- a/src/sis6326_video.c +++ b/src/sis6326_video.c @@ -1,40 +1,34 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis6326_video.c,v 1.2 2003/01/29 15:42:16 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis6326_video.c,v 1.14 2003/11/11 18:04:30 twini Exp $ */ /* * Xv driver for SiS 5597/5598, 6236 and 530/620. * - * Copyright 2002 by Thomas Winischhofer, Vienna, Austria. + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria. * * Based on sis_video.c which is - * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. - * Parts Copyright 2002 by Thomas Winischhofer, Vienna, Austria. - * All Rights Reserved. + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: + * 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 above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. + * 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. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Author: - * Thomas Winischhofer <thomas@winischhofer.net> + * Author: Thomas Winischhofer <thomas@winischhofer.net> */ #include "sis.h" -#ifdef USE6326VIDEO #include "xf86.h" #include "xf86_OSproc.h" @@ -84,6 +78,7 @@ static void SIS6326InitOffscreenImages(ScreenPtr pScrn); static Atom xvBrightness, xvContrast, xvColorKey; static Atom xvAutopaintColorKey, xvSetDefaults; +static Atom xvDisableGfx; #define IMAGE_MIN_WIDTH 32 /* Minimum and maximum image sizes */ #define IMAGE_MIN_HEIGHT 24 @@ -121,7 +116,7 @@ static CARD8 getvideoreg(SISPtr pSiS, CARD8 reg) return(ret); } -static void setvideoreg(SISPtr pSiS, CARD8 reg, CARD8 data) +static __inline void setvideoreg(SISPtr pSiS, CARD8 reg, CARD8 data) { outSISIDXREG(SISCR, reg, data); } @@ -220,7 +215,7 @@ static XF86VideoFormatRec SIS6326Formats[NUM_FORMATS] = {24, TrueColor} }; -#define NUM_ATTRIBUTES 5 +#define NUM_ATTRIBUTES 6 static XF86AttributeRec SIS6326Attributes[NUM_ATTRIBUTES] = { @@ -228,7 +223,8 @@ static XF86AttributeRec SIS6326Attributes[NUM_ATTRIBUTES] = {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"}, {XvSettable | XvGettable, 0, 7, "XV_CONTRAST"}, {XvSettable | XvGettable, 0, 1, "XV_AUTOPAINT_COLORKEY"}, - {XvSettable , 0, 0, "XV_SET_DEFAULTS"} + {XvSettable , 0, 0, "XV_SET_DEFAULTS"}, + {XvSettable | XvGettable, 0, 1, "XV_DISABLE_GRAPHICS"} }; #define NUM_IMAGES 6 @@ -375,6 +371,8 @@ typedef struct { CARD32 colorKey; Bool autopaintColorKey; + Bool disablegfx; + CARD32 videoStatus; Time offTime; Time freeTime; @@ -392,13 +390,16 @@ 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); + pPriv->colorKey = 0x000101fe; pPriv->videoStatus = 0; - pPriv->brightness = 0; - pPriv->contrast = 4; + pPriv->brightness = pSiS->XvDefBri; /* 0; - see sis_opt.c */ + pPriv->contrast = pSiS->XvDefCon; /* 4; */ pPriv->autopaintColorKey = TRUE; + pPriv->disablegfx = pSiS->XvDefDisableGfx; } static void @@ -485,7 +486,7 @@ SIS6326ResetVideo(ScrnInfoPtr pScrn) /* Reset contrast control */ setvideoregmask(pSiS, Index_VI6326_Contrast_Enh_Ctrl, 0x04, 0x1F); - /* Set treshold */ + /* Set threshold */ if(pSiS->oldChipset < OC_SIS6326) { CARD8 temp; inSISIDXREG(SISSR, 0x33, temp); /* Synchronous DRAM Timing? */ @@ -575,7 +576,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; @@ -584,12 +589,15 @@ SIS6326SetupImageVideo(ScreenPtr pScreen) xvColorKey = MAKE_ATOM("XV_COLORKEY"); xvAutopaintColorKey = MAKE_ATOM("XV_AUTOPAINT_COLORKEY"); xvSetDefaults = MAKE_ATOM("XV_SET_DEFAULTS"); + 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) static Bool RegionsEqual(RegionPtr A, RegionPtr B) { @@ -618,6 +626,7 @@ RegionsEqual(RegionPtr A, RegionPtr B) return TRUE; } +#endif static int SIS6326SetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, @@ -626,44 +635,50 @@ SIS6326SetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, SISPortPrivPtr pPriv = (SISPortPrivPtr)data; if(attribute == xvBrightness) { - if((value < -128) || (value > 127)) - return BadValue; - pPriv->brightness = value; + if((value < -128) || (value > 127)) + return BadValue; + pPriv->brightness = value; } else if(attribute == xvContrast) { - if((value < 0) || (value > 7)) - return BadValue; - pPriv->contrast = value; + if((value < 0) || (value > 7)) + return BadValue; + pPriv->contrast = value; } else if(attribute == xvColorKey) { - pPriv->colorKey = value; - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + pPriv->colorKey = value; + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); } else if (attribute == xvAutopaintColorKey) { - if ((value < 0) || (value > 1)) - return BadValue; + if((value < 0) || (value > 1)) + return BadValue; pPriv->autopaintColorKey = value; + } else if(attribute == xvDisableGfx) { + if((value < 0) || (value > 1)) + return BadValue; + pPriv->disablegfx = value; } else if (attribute == xvSetDefaults) { - SIS6326SetPortDefaults(pScrn, pPriv); + SIS6326SetPortDefaults(pScrn, pPriv); } else return BadMatch; return Success; } -static int +static int SIS6326GetPortAttribute( - ScrnInfoPtr pScrn, + ScrnInfoPtr pScrn, Atom attribute, - INT32 *value, + INT32 *value, pointer data ){ SISPortPrivPtr pPriv = (SISPortPrivPtr)data; if(attribute == xvBrightness) { - *value = pPriv->brightness; + *value = pPriv->brightness; } else if(attribute == xvContrast) { - *value = pPriv->contrast; + *value = pPriv->contrast; } else if(attribute == xvColorKey) { - *value = pPriv->colorKey; - } else if (attribute == xvAutopaintColorKey) - *value = (pPriv->autopaintColorKey) ? 1 : 0; - else return BadMatch; + *value = pPriv->colorKey; + } else if (attribute == xvAutopaintColorKey) { + *value = (pPriv->autopaintColorKey) ? 1 : 0; + } else if (attribute == xvDisableGfx) { + *value = (pPriv->disablegfx) ? 1 : 0; + } else return BadMatch; return Success; } @@ -722,7 +737,7 @@ calc_scale_factor(SISPtr pSiS, SISOverlayPtr pOverlay, ScrnInfoPtr pScrn, if(temp > 63) temp = 63; pOverlay->HUSF = temp; } else { - /* TW: 6326 can't scale below factor .440 - to check with 530/620 */ + /* 6326 can't scale below factor .440 - to check with 530/620 */ if(((dstW * 1000) / srcW) < 440) dstW = ((srcW * 440) / 1000) + 1; temp = srcW / dstW; if(temp > 15) temp = 15; @@ -742,7 +757,7 @@ calc_scale_factor(SISPtr pSiS, SISOverlayPtr pOverlay, ScrnInfoPtr pScrn, pOverlay->VUSF = temp; pOverlay->PitchMult = 1; } else { - /* TW: 6326 can't scale below factor .440 - to check with 530/620 */ + /* 6326 can't scale below factor .440 - to check with 530/620 */ if(((dstH * 1000) / srcH) < 440) dstH = ((srcH * 440) / 1000) + 1; temp = srcH / dstH; if(srcH % dstH) { @@ -755,7 +770,7 @@ calc_scale_factor(SISPtr pSiS, SISOverlayPtr pOverlay, ScrnInfoPtr pScrn, } } -static void /* V 530/6326 */ +static void calc_line_buf_size(SISOverlayPtr pOverlay) { CARD32 I; @@ -775,7 +790,7 @@ calc_line_buf_size(SISOverlayPtr pOverlay) pOverlay->lineBufSize = (CARD8)I; } -static void /* V 530/6326 */ +static void merge_line_buf(SISPtr pSiS, SISPortPrivPtr pPriv, Bool enable) { if(enable) { @@ -785,7 +800,7 @@ merge_line_buf(SISPtr pSiS, SISPortPrivPtr pPriv, Bool enable) } } -static void /* V 530/6326 */ +static void set_format(SISPtr pSiS, SISOverlayPtr pOverlay) { CARD8 fmt, misc0, misc1, misc4; @@ -840,7 +855,7 @@ set_format(SISPtr pSiS, SISOverlayPtr pOverlay) } } -static void /* V 6326/530 */ +static void set_colorkey(SISPtr pSiS, CARD32 colorkey) { CARD8 r, g, b, s; @@ -864,13 +879,13 @@ set_colorkey(SISPtr pSiS, CARD32 colorkey) setvideoreg(pSiS, Index_VI6326_Overlay_ColorKey_Red_Max ,(CARD8)r); } -static void +static __inline void set_brightness(SISPtr pSiS, CARD8 brightness) { setvideoreg(pSiS, Index_VI6326_Brightness, brightness); } -static void +static __inline void set_contrast(SISPtr pSiS, CARD8 contrast) { setvideoregmask(pSiS, Index_VI6326_Contrast_Enh_Ctrl, contrast, 0x07); @@ -896,6 +911,12 @@ set_contrast_data(SISPtr pSiS, int value) setvideoreg(pSiS, Index_VI6326_Contrast_Factor, temp); } +static __inline void +set_disablegfx(SISPtr pSiS, Bool mybool) +{ + setvideoregmask(pSiS, Index_VI6326_Control_Misc0, mybool ? 0x10 : 0x00, 0x10); +} + static void set_overlay(SISPtr pSiS, SISOverlayPtr pOverlay, SISPortPrivPtr pPriv, int index) { @@ -1033,11 +1054,14 @@ set_overlay(SISPtr pSiS, SISOverlayPtr pOverlay, SISPortPrivPtr pPriv, int index set_contrast(pSiS, pPriv->contrast); } + /* enable/disable graphics display around overlay */ + set_disablegfx(pSiS, pPriv->disablegfx); + /* set format */ set_format(pSiS, pOverlay); } -/* TW: Overlay MUST NOT be switched off while beam is over it */ +/* Overlay MUST NOT be switched off while beam is over it */ static void close_overlay(SISPtr pSiS, SISPortPrivPtr pPriv) { @@ -1271,9 +1295,10 @@ SIS6326PutImage( ){ SISPtr pSiS = SISPTR(pScrn); SISPortPrivPtr pPriv = (SISPortPrivPtr)data; - int totalSize=0; int depth = pSiS->CurrentLayout.bitsPerPixel >> 3; + CARD32 *src, *dest; + unsigned long i; if(pPriv->grabbedByV4L) return Success; @@ -1331,6 +1356,10 @@ SIS6326PutImage( totalSize = pPriv->srcPitch * height; } + /* make it a multiple of 16 to simplify to copy loop */ + totalSize += 15; + totalSize &= ~15; + pPriv->totalSize = totalSize; /* allocate memory (we do doublebuffering) */ @@ -1343,21 +1372,40 @@ SIS6326PutImage( pPriv->bufAddr[1] = pPriv->bufAddr[0] + totalSize; /* copy data */ - memcpy(pSiS->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); + if((pSiS->XvUseMemcpy) || (totalSize < 16)) { + memcpy(pSiS->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); + } else { + dest = (CARD32 *)(pSiS->FbBase + pPriv->bufAddr[pPriv->currentBuf]); + src = (CARD32 *)buf; + for(i = 0; i < (totalSize/16); i++) { + *dest++ = *src++; + *dest++ = *src++; + *dest++ = *src++; + *dest++ = *src++; + } + } SIS6326DisplayVideo(pScrn, pPriv); /* update cliplist */ if( pPriv->autopaintColorKey && - (pPriv->grabbedByV4L || !RegionsEqual(&pPriv->clip, clipBoxes))) { + (pPriv->grabbedByV4L || +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,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(pScreen, &pPriv->clip, clipBoxes); + if(!pPriv->grabbedByV4L) + REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); /* draw these */ - /* xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - for X4.2 */ +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); +#else + xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); +#endif } pPriv->currentBuf ^= 1; @@ -1469,7 +1517,7 @@ SIS6326VideoTimerCallback (ScrnInfoPtr pScrn, Time now) } } -/* TW: Offscreen surface stuff for v4l */ +/* Offscreen surface stuff for v4l */ static int SIS6326AllocSurface ( @@ -1611,9 +1659,13 @@ SIS6326DisplaySurface ( SIS6326DisplayVideo(pScrn, pPriv); if(pPriv->autopaintColorKey) { +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); +#else + xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); +#endif } pPriv->videoStatus = CLIENT_VIDEO_ON; @@ -1656,7 +1708,5 @@ SIS6326InitOffscreenImages(ScreenPtr pScrn) { xf86XVRegisterOffscreenImages(pScrn, SIS6326OffscreenImages, 2); } -#else -int sis_foo; -#endif + diff --git a/src/sis_accel.c b/src/sis_accel.c index a9d305f..12ecb73 100644 --- a/src/sis_accel.c +++ b/src/sis_accel.c @@ -1,21 +1,23 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c,v 1.25 2003/01/29 15:42:16 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c,v 1.34 2003/11/03 17:02:52 twini Exp $ */ /* + * 2D acceleration for SiS5597/5598 and 6326 + * * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Parts Copyright 2002 Thomas Winischhofer, Vienna, Austria. + * Parts Copyright 2002-2003 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 Alan Hourihane not be used in + * 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. Alan Hourihane makes no representations + * 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. * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * 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 @@ -212,7 +214,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); @@ -257,6 +259,7 @@ static void SiSDisableClipping (ScrnInfoPtr pScrn) pSiS->ClipEnabled = FALSE; } +#ifdef CTSCE static const int sisALUConv[] = { 0x00, /* dest = 0; 0, GXclear, 0 */ @@ -296,7 +299,7 @@ static const int sisPatALUConv[] = 0x5F, /* dest = ~src|~dest; DPan, GXnand, 0xE */ 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ }; - +#endif /* Screen to screen copy */ static void diff --git a/src/sis_accel.h b/src/sis_accel.h index e0d2d3f..a5c59b5 100644 --- a/src/sis_accel.h +++ b/src/sis_accel.h @@ -1,20 +1,24 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.h,v 1.2 2003/01/29 15:42:16 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.h,v 1.9 2003/11/03 17:02:53 twini Exp $ */ /* + * 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. * * 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 Alan Hourihane not be used in + * 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. Alan Hourihane makes no representations + * 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. * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * 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 @@ -28,6 +32,7 @@ * Thomas Winischhofer <thomas@winischhofer.net> */ + /* Definitions for the SIS engine communication. ------------------------------------ */ /* For pre-530 chipsets only!!! */ @@ -111,6 +116,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 */ diff --git a/src/sis_cursor.c b/src/sis_cursor.c index b8aed78..122493f 100644 --- a/src/sis_cursor.c +++ b/src/sis_cursor.c @@ -1,7 +1,9 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c,v 1.10 2003/01/30 21:43:33 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c,v 1.22 2003/11/03 17:02:53 twini Exp $ */ /* + * SiS hardware cursor handling + * * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Parts Copyright 2001, 2002 by Thomas Winischhofer, Vienna, Austria. + * Copyright 2001, 2002, 2003 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 @@ -26,7 +28,7 @@ * Juanjo Santamarta <santamarta@ctv.es>, * Mitani Hiroshi <hmitani@drl.mei.co.jp> * David Thomas <davtom@dream.org.uk>. - * Thomas Winischhofer <thomas@winischhofer.net>: + * Thomas Winischhofer <thomas@winischhofer.net> */ #include "xf86.h" @@ -40,10 +42,132 @@ #if 0 #define SIS300_USE_ARGB16 +#else +#undef SIS300_USE_ARGB16 #endif extern void SISWaitRetraceCRT1(ScrnInfoPtr pScrn); extern void SISWaitRetraceCRT2(ScrnInfoPtr pScrn); +extern Bool InRegion(int x, int y, region r); + +/* Helper function for Xabre to convert mono image to ARGB */ +/* The Xabre's cursor engine for CRT2 is buggy and can't + * handle mono cursors. We therefore convert the mono image + * to ARGB + */ +static void +SiSXConvertMono2ARGB(SISPtr pSiS) +{ + unsigned char *src = pSiS->CurMonoSrc; + CARD32 *dest = pSiS->CurARGBDest; + CARD8 chunk, mask; + CARD32 fg = pSiS->CurFGCol | 0xff000000; + CARD32 bg = pSiS->CurBGCol | 0xff000000; + int i,j,k; + + 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++; + for(k = 128; k != 0; k >>= 1) { + if(mask & k) *dest++ = 0x00000000; + else if(chunk & k) *dest++ = fg; + else *dest++ = bg; + } + } + src += 8; + } +} + +static void +SiSHideCursor(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + unsigned char sridx, cridx; + + sridx = inSISREG(SISSR); cridx = inSISREG(SISCR); + +#ifdef UNLOCK_ALWAYS + sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); +#endif + + andSISIDXREG(SISSR, 0x06, 0xBF); + + outSISREG(SISSR, sridx); outSISREG(SISCR, cridx); +} + +static void +SiS300HideCursor(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(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) + } + } else { +#endif + sis300DisableHWCursor() + sis300SetCursorPositionY(2000, 0) + if(pSiS->VBFlags & CRT2_ENABLE) { + sis301DisableHWCursor() + sis301SetCursorPositionY(2000, 0) + } +#ifdef SISDUALHEAD + } +#endif +} + +static void +SiS310HideCursor(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + + pSiS->HWCursorIsVisible = FALSE; + +#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_CRT2HWCKaputt) { + sis301DisableHWCursor330() + sis301SetCursorPositionY330(2000, 0) + } else { + sis301DisableHWCursor310() + sis301SetCursorPositionY310(2000, 0) + } + } + } else { +#endif + sis310DisableHWCursor() + sis310SetCursorPositionY(2000, 0) + if(pSiS->VBFlags & VB_VIDEOBRIDGE) { + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + sis301DisableHWCursor330() + sis301SetCursorPositionY330(2000, 0) + } else { + sis301DisableHWCursor310() + sis301SetCursorPositionY310(2000, 0) + } + } +#ifdef SISDUALHEAD + } +#endif +} static void SiSShowCursor(ScrnInfoPtr pScrn) @@ -51,8 +175,8 @@ SiSShowCursor(ScrnInfoPtr pScrn) SISPtr pSiS = SISPTR(pScrn); unsigned char sridx, cridx; - /* TW: Backup current indices of SR and CR since we run async:ly - * and might be interrupting an on-going register read/write + /* Backup current indices of SR and CR since we run async:ly + * and might be interrupting an on-going register read/write */ sridx = inSISREG(SISSR); cridx = inSISREG(SISCR); @@ -98,7 +222,7 @@ SiS300ShowCursor(ScrnInfoPtr pScrn) } else { #endif if(pSiS->UseHWARGBCursor) { -#ifdef SIS300_USE_ARGB16 +#ifdef SIS300_USE_ARGB16 sis300EnableHWARGB16Cursor() #else sis300EnableHWARGBCursor() @@ -121,12 +245,19 @@ SiS300ShowCursor(ScrnInfoPtr pScrn) #endif } -/* TW: 310/325 series */ static void SiS310ShowCursor(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); + if(pSiS->HideHWCursor) { + SiS310HideCursor(pScrn); + pSiS->HWCursorIsVisible = TRUE; + return; + } + + pSiS->HWCursorIsVisible = TRUE; + #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { if(pSiS->SecondHead) { @@ -138,23 +269,38 @@ SiS310ShowCursor(ScrnInfoPtr pScrn) } } else { /* TW: Head 1 is always CRT2 */ - if(pSiS->UseHWARGBCursor) { - sis301EnableHWARGBCursor310() + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + sis301EnableHWCursor330() } else { - sis301EnableHWCursor310() + if(pSiS->UseHWARGBCursor) { + sis301EnableHWARGBCursor310() + } else { + sis301EnableHWCursor310() + } } } } else { #endif - if(pSiS->UseHWARGBCursor) { - sis310EnableHWARGBCursor() - if(pSiS->VBFlags & CRT2_ENABLE) { - sis301EnableHWARGBCursor310() - } + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + if(pSiS->UseHWARGBCursor) { + sis310EnableHWARGBCursor() + } else { + sis310EnableHWCursor() + } + if(pSiS->VBFlags & CRT2_ENABLE) { + sis301EnableHWCursor330() + } } else { - sis310EnableHWCursor() - if(pSiS->VBFlags & CRT2_ENABLE) { - sis301EnableHWCursor310() + if(pSiS->UseHWARGBCursor) { + sis310EnableHWARGBCursor() + if(pSiS->VBFlags & CRT2_ENABLE) { + sis301EnableHWARGBCursor310() + } + } else { + sis310EnableHWCursor() + if(pSiS->VBFlags & CRT2_ENABLE) { + sis301EnableHWCursor310() + } } } #ifdef SISDUALHEAD @@ -163,89 +309,14 @@ SiS310ShowCursor(ScrnInfoPtr pScrn) } static void -SiSHideCursor(ScrnInfoPtr pScrn) -{ - SISPtr pSiS = SISPTR(pScrn); - unsigned char sridx, cridx; - - sridx = inSISREG(SISSR); cridx = inSISREG(SISCR); - -#ifdef UNLOCK_ALWAYS - sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); -#endif - - andSISIDXREG(SISSR, 0x06, 0xBF); - - outSISREG(SISSR, sridx); outSISREG(SISCR, cridx); -} - -static void -SiS300HideCursor(ScrnInfoPtr pScrn) -{ - SISPtr pSiS = SISPTR(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) - } - } else { -#endif - sis300DisableHWCursor() - sis300SetCursorPositionY(2000, 0) - if(pSiS->VBFlags & CRT2_ENABLE) { - sis301DisableHWCursor() - sis301SetCursorPositionY(2000, 0) - } -#ifdef SISDUALHEAD - } -#endif -} - -/* TW: 310/325 series */ -static void -SiS310HideCursor(ScrnInfoPtr pScrn) -{ - SISPtr pSiS = SISPTR(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 */ - sis301DisableHWCursor310() - sis301SetCursorPositionY310(2000, 0) - } - } else { -#endif - sis310DisableHWCursor() - sis310SetCursorPositionY(2000, 0) - if(pSiS->VBFlags & CRT2_ENABLE) { - sis301DisableHWCursor310() - sis301SetCursorPositionY310(2000, 0) - } -#ifdef SISDUALHEAD - } -#endif -} - -static void SiSSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) { - SISPtr pSiS = SISPTR(pScrn); - unsigned char x_preset = 0; - unsigned char y_preset = 0; - int temp; - unsigned char sridx, cridx; + SISPtr pSiS = SISPTR(pScrn); + DisplayModePtr mode = pSiS->CurrentLayout.mode; /* pScrn->currentMode; */ + unsigned char x_preset = 0; + unsigned char y_preset = 0; + int temp; + unsigned char sridx, cridx; sridx = inSISREG(SISSR); cridx = inSISREG(SISCR); @@ -263,11 +334,8 @@ SiSSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) y = 0; } - /* are we in interlaced/doublescan mode? */ - if (pScrn->currentMode->Flags & V_INTERLACE) - y /= 2; - else if (pScrn->currentMode->Flags & V_DBLSCAN) - y *= 2; + if(mode->Flags & V_INTERLACE) y /= 2; + else if(mode->Flags & V_DBLSCAN) y *= 2; outSISIDXREG(SISSR, 0x1A, x & 0xff); outSISIDXREG(SISSR, 0x1B, (x & 0xff00) >> 8); @@ -283,12 +351,95 @@ SiSSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) outSISREG(SISSR, sridx); outSISREG(SISCR, cridx); } +#ifdef SISMERGED +static void +SiSSetCursorPositionMerged(ScrnInfoPtr pScrn1, int x, int y) +{ + SISPtr pSiS = SISPTR(pScrn1); + ScrnInfoPtr pScrn2 = pSiS->CRT2pScrn; + DisplayModePtr mode1 = CDMPTR->CRT1; + DisplayModePtr mode2 = CDMPTR->CRT2; + unsigned short x1_preset = 0, x2_preset = 0; + unsigned short y1_preset = 0, y2_preset = 0; + unsigned short maxpreset; + int x1, y1, x2, y2; + + x += pScrn1->frameX0; + y += pScrn1->frameY0; + + x1 = x - pSiS->CRT1frameX0; + y1 = y - pSiS->CRT1frameY0; + + x2 = x - pScrn2->frameX0; + y2 = y - pScrn2->frameY0; + + maxpreset = 63; + 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; + } + if(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; + } + if(y2 < 0) { + y2_preset = (-y2); + if(y2_preset > maxpreset) y2_preset = maxpreset; + y2 = 0; + } + + if(mode1->Flags & V_INTERLACE) { y1 /= 2; y1_preset /= 2; } + else if(mode1->Flags & V_DBLSCAN) { y1 *= 2; y1_preset *= 2; } + + 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) + sis301SetCursorPositionX(x2 + 13, x2_preset) + sis301SetCursorPositionY(y2, y2_preset) + } else { + sis310SetCursorPositionX(x1, x1_preset) + sis310SetCursorPositionY(y1, y1_preset) + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + sis301SetCursorPositionX330(x2 + 17, x2_preset) + sis301SetCursorPositionY330(y2, y2_preset) + } else { + sis301SetCursorPositionX310(x2 + 17, x2_preset) + sis301SetCursorPositionY310(y2, y2_preset) + } + } +} +#endif + static void SiS300SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) { - SISPtr pSiS = SISPTR(pScrn); - unsigned char x_preset = 0; - unsigned char y_preset = 0; + SISPtr pSiS = SISPTR(pScrn); + DisplayModePtr mode = pSiS->CurrentLayout.mode; /* pScrn->currentMode; */ + unsigned short x_preset = 0; + unsigned short y_preset = 0; + +#ifdef SISMERGED + if(pSiS->MergedFB) { + SiSSetCursorPositionMerged(pScrn, x, y); + return; + } +#endif if (x < 0) { x_preset = (-x); @@ -299,21 +450,18 @@ SiS300SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) y = 0; } - /* are we in interlaced/doublescan mode? */ - if(pScrn->currentMode->Flags & V_INTERLACE) - y /= 2; - else if(pScrn->currentMode->Flags & V_DBLSCAN) - y *= 2; + if(mode->Flags & V_INTERLACE) y /= 2; + else if(mode->Flags & V_DBLSCAN) y *= 2; #ifdef SISDUALHEAD - if (pSiS->DualHeadMode) { - if (pSiS->SecondHead) { + 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) + sis301SetCursorPositionX(x + 13, x_preset) sis301SetCursorPositionY(y, y_preset) } } else { @@ -321,7 +469,7 @@ SiS300SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) sis300SetCursorPositionX(x, x_preset) sis300SetCursorPositionY(y, y_preset) if(pSiS->VBFlags & CRT2_ENABLE) { - sis301SetCursorPositionX(x+13, x_preset) + sis301SetCursorPositionX(x + 13, x_preset) sis301SetCursorPositionY(y, y_preset) } #ifdef SISDUALHEAD @@ -332,9 +480,17 @@ SiS300SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) static void SiS310SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) { - SISPtr pSiS = SISPTR(pScrn); - unsigned char x_preset = 0; - unsigned char y_preset = 0; + SISPtr pSiS = SISPTR(pScrn); + DisplayModePtr mode = pSiS->CurrentLayout.mode; + unsigned short x_preset = 0; + unsigned short y_preset = 0; + +#ifdef SISMERGED + if(pSiS->MergedFB) { + SiSSetCursorPositionMerged(pScrn, x, y); + return; + } +#endif if (x < 0) { x_preset = (-x); @@ -345,36 +501,44 @@ SiS310SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) y = 0; } - /* are we in interlaced/doublescan mode? */ - if(pScrn->currentMode->Flags & V_INTERLACE) - y /= 2; - else if(pScrn->currentMode->Flags & V_DBLSCAN) - y *= 2; + if(mode->Flags & V_INTERLACE) y /= 2; + else if(mode->Flags & V_DBLSCAN) y *= 2; #ifdef SISDUALHEAD - if (pSiS->DualHeadMode) { - if (pSiS->SecondHead) { + 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 */ - sis301SetCursorPositionX310(x + 17, x_preset) - sis301SetCursorPositionY310(y, y_preset) + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + sis301SetCursorPositionX330(x + 17, x_preset) + sis301SetCursorPositionY330(y, y_preset) + } else { + sis301SetCursorPositionX310(x + 17, x_preset) + sis301SetCursorPositionY310(y, y_preset) + } } } else { #endif sis310SetCursorPositionX(x, x_preset) sis310SetCursorPositionY(y, y_preset) - if (pSiS->VBFlags & CRT2_ENABLE) { - sis301SetCursorPositionX310(x + 17, x_preset) - sis301SetCursorPositionY310(y, y_preset) + if(pSiS->VBFlags & CRT2_ENABLE) { + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + sis301SetCursorPositionX330(x + 17, x_preset) + sis301SetCursorPositionY330(y, y_preset) + } else { + sis301SetCursorPositionX310(x + 17, x_preset) + sis301SetCursorPositionY310(y, y_preset) + } } #ifdef SISDUALHEAD } #endif } + static void SiSSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) { @@ -411,6 +575,8 @@ SiS300SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) { SISPtr pSiS = SISPTR(pScrn); + if(pSiS->UseHWARGBCursor) return; + #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { if(pSiS->SecondHead) { @@ -440,6 +606,8 @@ SiS310SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) { SISPtr pSiS = SISPTR(pScrn); + if(pSiS->UseHWARGBCursor) return; + #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { if(pSiS->SecondHead) { @@ -448,16 +616,33 @@ SiS310SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) sis310SetCursorFGColor(fg) } else { /* TW: Head 1 is always CRT2 */ - sis301SetCursorBGColor310(bg) - sis301SetCursorFGColor310(fg) + 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) + } } } else { #endif sis310SetCursorBGColor(bg) sis310SetCursorFGColor(fg) - if(pSiS->VBFlags & CRT2_ENABLE) { - sis301SetCursorBGColor310(bg) - sis301SetCursorFGColor310(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 } @@ -467,10 +652,11 @@ SiS310SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) static void SiSLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) { - SISPtr pSiS = SISPTR(pScrn); - int cursor_addr; - unsigned char temp; - unsigned char sridx, cridx; + SISPtr pSiS = SISPTR(pScrn); + DisplayModePtr mode = pSiS->CurrentLayout.mode; + int cursor_addr; + unsigned char temp; + unsigned char sridx, cridx; sridx = inSISREG(SISSR); cridx = inSISREG(SISCR); @@ -479,7 +665,7 @@ SiSLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) #endif cursor_addr = pScrn->videoRam - 1; - if(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { + if(mode->Flags & V_DBLSCAN) { int i; for(i = 0; i < 32; i++) { memcpy((unsigned char *)pSiS->FbBase + (cursor_addr * 1024) + (32 * i), @@ -520,41 +706,42 @@ SiS300LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) SISPtr pSiS = SISPTR(pScrn); int cursor_addr; CARD32 status1 = 0, status2 = 0; - + unsigned char *dest = pSiS->FbBase; + BOOLEAN sizedouble = FALSE; #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; #endif - + +#ifdef SISMERGED + if(pSiS->MergedFB) { + if((CDMPTR->CRT1->Flags & V_DBLSCAN) && (CDMPTR->CRT2->Flags & V_DBLSCAN)) { + sizedouble = TRUE; + } + } else +#endif + if(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { + sizedouble = TRUE; + } + cursor_addr = pScrn->videoRam - pSiS->cursorOffset - (pSiS->CursorSize/1024); /* 1K boundary */ #ifdef SISDUALHEAD - if(pSiS->DualHeadMode) { - /* TW: Use the global (real) FbBase in DHM */ - if(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { - int i; - for(i = 0; i < 32; i++) { - memcpy((unsigned char *)pSiSEnt->FbBase + (cursor_addr * 1024) + (32 * i), - src + (16 * i), 16); - memcpy((unsigned char *)pSiSEnt->FbBase + (cursor_addr * 1024) + (32 * i) + 16, - src + (16 * i), 16); - } - } else { - memcpy((unsigned char *)pSiSEnt->FbBase + (cursor_addr * 1024), src, 1024); - } - } else + /* TW: Use the global (real) FbBase in DHM */ + if(pSiS->DualHeadMode) dest = pSiSEnt->FbBase; #endif - if(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { - int i; - for(i = 0; i < 32; i++) { - memcpy((unsigned char *)pSiS->FbBase + (cursor_addr * 1024) + (32 * i), - src + (16 * i), 16); - memcpy((unsigned char *)pSiS->FbBase + (cursor_addr * 1024) + (32 * i) + 16, - src + (16 * i), 16); - } + + if(sizedouble) { + int i; + for(i = 0; i < 32; i++) { + memcpy((unsigned char *)dest + (cursor_addr * 1024) + (32 * i), + src + (16 * i), 16); + memcpy((unsigned char *)dest + (cursor_addr * 1024) + (32 * i) + 16, + src + (16 * i), 16); + } } else { - memcpy((unsigned char *)pSiS->FbBase + (cursor_addr * 1024), src, 1024); + memcpy((unsigned char *)dest + (cursor_addr * 1024), src, 1024); } - + if(pSiS->UseHWARGBCursor) { if(pSiS->VBFlags & DISPTYPE_CRT1) { status1 = sis300GetCursorStatus; @@ -594,73 +781,107 @@ static void SiS310LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) { SISPtr pSiS = SISPTR(pScrn); - int cursor_addr; + unsigned long cursor_addr, cursor_addr2 = 0; CARD32 status1 = 0, status2 = 0; - + unsigned char *dest = pSiS->FbBase; + BOOLEAN sizedouble = FALSE; #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; #endif +#ifdef SISMERGED + if(pSiS->MergedFB) { + if((CDMPTR->CRT1->Flags & V_DBLSCAN) && (CDMPTR->CRT2->Flags & V_DBLSCAN)) { + sizedouble = TRUE; + } + } else +#endif + if(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { + sizedouble = TRUE; + } + cursor_addr = pScrn->videoRam - pSiS->cursorOffset - (pSiS->CursorSize/1024); /* 1K boundary */ #ifdef SISDUALHEAD - if (pSiS->DualHeadMode) { - /* TW: Use the global (real) FbBase in DHM */ - if(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { - int i; - for(i = 0; i < 32; i++) { - memcpy((unsigned char *)pSiSEnt->FbBase + (cursor_addr * 1024) + (32 * i), - src + (16 * i), 16); - memcpy((unsigned char *)pSiSEnt->FbBase + (cursor_addr * 1024) + (32 * i) + 16, - src + (16 * i), 16); - } - } else { - memcpy((unsigned char *)pSiSEnt->FbBase + (cursor_addr * 1024), src, 1024); - } - } else + /* TW: Use the global (real) FbBase in DHM */ + if(pSiS->DualHeadMode) dest = pSiSEnt->FbBase; #endif - if(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { - int i; - for(i = 0; i < 32; i++) { - memcpy((unsigned char *)pSiS->FbBase + (cursor_addr * 1024) + (32 * i), - src + (16 * i), 16); - memcpy((unsigned char *)pSiS->FbBase + (cursor_addr * 1024) + (32 * i) + 16, - src + (16 * i), 16); - } + + if(sizedouble) { + int i; + for(i = 0; i < 32; i++) { + memcpy((unsigned char *)dest + (cursor_addr * 1024) + (32 * i), + src + (16 * i), 16); + memcpy((unsigned char *)dest + (cursor_addr * 1024) + (32 * i) + 16, + src + (16 * i), 16); + } } else { - memcpy((unsigned char *)pSiS->FbBase + (cursor_addr * 1024), src, 1024); + memcpy((unsigned char *)dest + (cursor_addr * 1024), src, 1024); } - - if(pSiS->UseHWARGBCursor) { - if(pSiS->VBFlags & DISPTYPE_CRT1) { - status1 = sis310GetCursorStatus; - sis310DisableHWCursor() - if(pSiS->VBFlags & CRT2_ENABLE) { - status2 = sis301GetCursorStatus310; - sis301DisableHWCursor310() + + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + + /* Convert Mono image to color image */ + + cursor_addr2 = pScrn->videoRam - pSiS->cursorOffset - ((pSiS->CursorSize/1024) * 2); + + pSiS->CurMonoSrc = (unsigned char *)dest + (cursor_addr * 1024); + pSiS->CurARGBDest = (CARD32 *)((unsigned char *)dest + (cursor_addr2 * 1024)); + + SiSXConvertMono2ARGB(pSiS); + + if(pSiS->UseHWARGBCursor) { + if(pSiS->VBFlags & DISPTYPE_CRT1) { + status1 = sis310GetCursorStatus; + sis310DisableHWCursor(); + SISWaitRetraceCRT1(pScrn); + sis310SwitchToMONOCursor(); } - SISWaitRetraceCRT1(pScrn); - sis310SwitchToMONOCursor(); - if(pSiS->VBFlags & CRT2_ENABLE) { - SISWaitRetraceCRT2(pScrn); - sis301SwitchToMONOCursor310(); + } + + } 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); } } } + sis310SetCursorAddress(cursor_addr); sis310SetCursorPatternSelect(0); if(status1) sis310SetCursorStatus(status1) - - if(pSiS->VBFlags & CRT2_ENABLE) { - if((pSiS->UseHWARGBCursor) && (!pSiS->VBFlags & DISPTYPE_CRT1)) { - status2 = sis301GetCursorStatus310; - sis301DisableHWCursor310() - SISWaitRetraceCRT2(pScrn); - sis301SwitchToMONOCursor310(); - } - sis301SetCursorAddress310(cursor_addr) - sis301SetCursorPatternSelect310(0) - if(status2) sis301SetCursorStatus310(status2) + + if(pSiS->VBFlags & CRT2_ENABLE) { + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + sis301SetCursorAddress330(cursor_addr2) + sis301SetCursorPatternSelect330(0) + } else { + if((pSiS->UseHWARGBCursor) && (!pSiS->VBFlags & DISPTYPE_CRT1)) { + status2 = sis301GetCursorStatus310; + sis301DisableHWCursor310() + SISWaitRetraceCRT2(pScrn); + sis301SwitchToMONOCursor310(); + } + sis301SetCursorAddress310(cursor_addr) + sis301SetCursorPatternSelect310(0) + if(status2) sis301SetCursorStatus310(status2) + } } pSiS->UseHWARGBCursor = FALSE; @@ -670,9 +891,9 @@ static Bool SiSUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - DisplayModePtr mode = pScrn->currentMode; SISPtr pSiS = SISPTR(pScrn); - + DisplayModePtr mode = pSiS->CurrentLayout.mode; /* pScrn->currentMode; */ + if(pSiS->Chipset != PCI_CHIP_SIS6326) return TRUE; if(!(pSiS->SiS6326Flags & SIS6326_TVDETECTED)) return TRUE; if((strcmp(mode->name, "PAL800x600U") == 0) || @@ -688,6 +909,14 @@ SiS300UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; SISPtr pSiS = SISPTR(pScrn); DisplayModePtr mode = pSiS->CurrentLayout.mode; /* pScrn->currentMode; */ +#ifdef SISMERGED + DisplayModePtr mode2 = NULL; + + if(pSiS->MergedFB) { + mode = CDMPTR->CRT1; + mode2 = CDMPTR->CRT2; + } +#endif switch (pSiS->Chipset) { case PCI_CHIP_SIS300: @@ -697,6 +926,14 @@ SiS300UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) return FALSE; if((mode->Flags & V_DBLSCAN) && (pCurs->bits->height > 32)) return FALSE; +#ifdef SISMERGED + if(pSiS->MergedFB) { + if(mode2->Flags & V_INTERLACE) + return FALSE; + if((mode2->Flags & V_DBLSCAN) && (pCurs->bits->height > 32)) + return FALSE; + } +#endif break; case PCI_CHIP_SIS550: case PCI_CHIP_SIS650: @@ -704,10 +941,31 @@ SiS300UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) case PCI_CHIP_SIS315H: case PCI_CHIP_SIS315PRO: case PCI_CHIP_SIS330: + case PCI_CHIP_SIS660: if(mode->Flags & V_INTERLACE) return FALSE; if((mode->Flags & V_DBLSCAN) && (pCurs->bits->height > 32)) return FALSE; +#ifdef SISMERGED + if(pSiS->MergedFB) { + if(mode2->Flags & V_INTERLACE) + return FALSE; + if((mode2->Flags & V_DBLSCAN) && (pCurs->bits->height > 32)) + 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: if(mode->Flags & V_INTERLACE) @@ -726,9 +984,17 @@ static Bool SiSUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - DisplayModePtr mode = pScrn->currentMode; SISPtr pSiS = SISPTR(pScrn); - + DisplayModePtr mode = pSiS->CurrentLayout.mode; /* pScrn->currentMode; */ +#ifdef SISMERGED + DisplayModePtr mode2 = NULL; + + if(pSiS->MergedFB) { + mode = CDMPTR->CRT1; + mode2 = CDMPTR->CRT2; + } +#endif + switch (pSiS->Chipset) { case PCI_CHIP_SIS300: case PCI_CHIP_SIS630: @@ -739,6 +1005,14 @@ SiSUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs) return FALSE; if((mode->Flags & V_DBLSCAN) && (pCurs->bits->height > 16)) return FALSE; +#ifdef SISMERGED + if(pSiS->MergedFB) { + if(mode2->Flags & V_INTERLACE) + return FALSE; + if((mode2->Flags & V_DBLSCAN) && (pCurs->bits->height > 16)) + return FALSE; + } +#endif break; case PCI_CHIP_SIS550: case PCI_CHIP_SIS650: @@ -746,12 +1020,42 @@ SiSUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs) case PCI_CHIP_SIS315H: case PCI_CHIP_SIS315PRO: case PCI_CHIP_SIS330: + case PCI_CHIP_SIS660: if(mode->Flags & V_INTERLACE) return FALSE; if(pCurs->bits->height > 64 || pCurs->bits->width > 64) return FALSE; - if((mode->Flags & V_DBLSCAN) && (pCurs->bits->height > 32)) + if(mode->Flags & V_DBLSCAN) { + if(pCurs->bits->height > 32) + return FALSE; +#ifdef SISDUALHEAD + if((!pSiS->DualHeadMode) || (pSiS->SecondHead)) +#endif + if(pSiS->VBFlags & CRT1_LCDA) + return FALSE; + } + if((pSiS->CurrentLayout.bitsPerPixel == 8) && (pSiS->VBFlags & CRT2_ENABLE)) return FALSE; +#ifdef SISMERGED + if(pSiS->MergedFB) { + if(mode2->Flags & V_INTERLACE) + return FALSE; + if((mode->Flags & V_DBLSCAN) && (pCurs->bits->height > 32)) + 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: return FALSE; @@ -774,28 +1078,37 @@ static void SiS300LoadCursorImageARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) #endif int srcwidth = pCurs->bits->width; int srcheight = pCurs->bits->height; - BOOLEAN sizedouble = FALSE; CARD32 temp, status1 = 0, status2 = 0; - + BOOLEAN sizedouble = FALSE; #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; #endif +#ifdef SISMERGED + if(pSiS->MergedFB) { + if((CDMPTR->CRT1->Flags & V_DBLSCAN) && (CDMPTR->CRT2->Flags & V_DBLSCAN)) { + sizedouble = TRUE; + } + } else +#endif + if(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { + sizedouble = TRUE; + } + cursor_addr = pScrn->videoRam - pSiS->cursorOffset - ((pSiS->CursorSize/1024) * 2); - + if(srcwidth > 32) srcwidth = 32; if(srcheight > 32) srcheight = 32; #ifdef SISDUALHEAD - if (pSiS->DualHeadMode) + if (pSiS->DualHeadMode) /* TW: Use the global (real) FbBase in DHM */ - dest = (MYSISPTRTYPE *)((unsigned char *)pSiSEnt->FbBase + (cursor_addr * 1024)); + dest = (MYSISPTRTYPE *)((unsigned char *)pSiSEnt->FbBase + (cursor_addr * 1024)); else #endif - dest = (MYSISPTRTYPE *)((unsigned char *)pSiS->FbBase + (cursor_addr * 1024)); + dest = (MYSISPTRTYPE *)((unsigned char *)pSiS->FbBase + (cursor_addr * 1024)); - if(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { - sizedouble = TRUE; + if(sizedouble) { if(srcheight > 16) srcheight = 16; maxheight = 16; } @@ -920,28 +1233,37 @@ static void SiS310LoadCursorImageARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) CARD32 *src = pCurs->bits->argb, *p, *pb, *dest; int srcwidth = pCurs->bits->width; int srcheight = pCurs->bits->height; - BOOLEAN sizedouble = FALSE; CARD32 status1 = 0, status2 = 0; - + BOOLEAN sizedouble = FALSE; #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; #endif - + +#ifdef SISMERGED + if(pSiS->MergedFB) { + if((CDMPTR->CRT1->Flags & V_DBLSCAN) && (CDMPTR->CRT2->Flags & V_DBLSCAN)) { + sizedouble = TRUE; + } + } else +#endif + if(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { + sizedouble = TRUE; + } + cursor_addr = pScrn->videoRam - pSiS->cursorOffset - ((pSiS->CursorSize/1024) * 2); - + if(srcwidth > 64) srcwidth = 64; if(srcheight > 64) srcheight = 64; #ifdef SISDUALHEAD - if(pSiS->DualHeadMode) + if(pSiS->DualHeadMode) /* TW: Use the global (real) FbBase in DHM */ - dest = (CARD32 *)((unsigned char *)pSiSEnt->FbBase + (cursor_addr * 1024)); + 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(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { - sizedouble = TRUE; + if(sizedouble) { if(srcheight > 32) srcheight = 32; maxheight = 32; } @@ -968,36 +1290,56 @@ static void SiS310LoadCursorImageARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) } } - if(!pSiS->UseHWARGBCursor) { - if(pSiS->VBFlags & DISPTYPE_CRT1) { - status1 = sis310GetCursorStatus; - sis310DisableHWCursor() - if(pSiS->VBFlags & CRT2_ENABLE) { - status2 = sis301GetCursorStatus310; - sis301DisableHWCursor310() - } - SISWaitRetraceCRT1(pScrn); - sis310SwitchToRGBCursor(); - if(pSiS->VBFlags & CRT2_ENABLE) { - SISWaitRetraceCRT2(pScrn); - sis301SwitchToRGBCursor310(); - } - } + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + + if(!pSiS->UseHWARGBCursor) { + if(pSiS->VBFlags & DISPTYPE_CRT1) { + status1 = sis310GetCursorStatus; + sis310DisableHWCursor() + } + SISWaitRetraceCRT1(pScrn); + sis310SwitchToRGBCursor(); + } + + } else { + + if(!pSiS->UseHWARGBCursor) { + if(pSiS->VBFlags & DISPTYPE_CRT1) { + status1 = sis310GetCursorStatus; + sis310DisableHWCursor() + if(pSiS->VBFlags & CRT2_ENABLE) { + status2 = sis301GetCursorStatus310; + sis301DisableHWCursor310() + } + } + SISWaitRetraceCRT1(pScrn); + sis310SwitchToRGBCursor(); + if(pSiS->VBFlags & CRT2_ENABLE) { + SISWaitRetraceCRT2(pScrn); + sis301SwitchToRGBCursor310(); + } + } } + sis310SetCursorAddress(cursor_addr); sis310SetCursorPatternSelect(0); if(status1) sis310SetCursorStatus(status1) - if(pSiS->VBFlags & CRT2_ENABLE) { - if((!pSiS->UseHWARGBCursor) && (!pSiS->VBFlags & DISPTYPE_CRT1)) { - status2 = sis301GetCursorStatus310; - sis301DisableHWCursor310() - SISWaitRetraceCRT2(pScrn); - sis301SwitchToRGBCursor310(); - } - sis301SetCursorAddress310(cursor_addr) - sis301SetCursorPatternSelect310(0) - if(status2) sis301SetCursorStatus310(status2) + if(pSiS->VBFlags & CRT2_ENABLE) { + if(pSiS->ChipFlags & SiSCF_CRT2HWCKaputt) { + sis301SetCursorAddress330(cursor_addr) + sis301SetCursorPatternSelect330(0) + } else { + if((!pSiS->UseHWARGBCursor) && (!pSiS->VBFlags & DISPTYPE_CRT1)) { + status2 = sis301GetCursorStatus310; + sis301DisableHWCursor310() + SISWaitRetraceCRT2(pScrn); + sis301SwitchToRGBCursor310(); + } + sis301SetCursorAddress310(cursor_addr) + sis301SetCursorPatternSelect310(0) + if(status2) sis301SetCursorStatus310(status2) + } } pSiS->UseHWARGBCursor = TRUE; @@ -1013,15 +1355,14 @@ SiSHWCursorInit(ScreenPtr pScreen) SISPtr pSiS = SISPTR(pScrn); xf86CursorInfoPtr infoPtr; - PDEBUG(ErrorF("HW Cursor Init\n")); infoPtr = xf86CreateCursorInfoRec(); - if(!infoPtr) - return FALSE; + if(!infoPtr) return FALSE; pSiS->CursorInfoPtr = infoPtr; pSiS->UseHWARGBCursor = FALSE; switch (pSiS->Chipset) { + case PCI_CHIP_SIS300: case PCI_CHIP_SIS630: case PCI_CHIP_SIS540: @@ -1051,12 +1392,14 @@ SiSHWCursorInit(ScreenPtr pScreen) HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK | HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64; break; + case PCI_CHIP_SIS550: case PCI_CHIP_SIS650: case PCI_CHIP_SIS315: case PCI_CHIP_SIS315H: case PCI_CHIP_SIS315PRO: case PCI_CHIP_SIS330: + case PCI_CHIP_SIS660: infoPtr->MaxWidth = 64; infoPtr->MaxHeight = 64; infoPtr->ShowCursor = SiS310ShowCursor; @@ -1083,6 +1426,7 @@ SiSHWCursorInit(ScreenPtr pScreen) HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK | HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64; break; + default: infoPtr->MaxWidth = 64; infoPtr->MaxHeight = 64; diff --git a/src/sis_cursor.h b/src/sis_cursor.h index 76258ac..5de0070 100644 --- a/src/sis_cursor.h +++ b/src/sis_cursor.h @@ -1,7 +1,10 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.h,v 1.5 2003/02/06 13:14:04 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.h,v 1.11 2003/10/30 18:53:42 twini Exp $ */ /* + * SiS hardware cursor handling + * Definitions + * * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Parts Copyright 2001, 2002 by Thomas Winischhofer, Vienna, Austria. + * Copyright 2001, 2002, 2003 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 @@ -227,7 +230,7 @@ MMIO_OUT32(pSiS->IOBase,CS(8),temp); \ } -/* 310/325/330 series CRT1 */ +/* 315/330 series CRT1 */ /* 80000000 = RGB(1) - MONO(0) * 40000000 = enable(1) - disable(0) @@ -246,7 +249,7 @@ temp |= status; \ MMIO_OUT32(pSiS->IOBase, CS(0), temp); \ } - + #define sis310EnableHWCursor()\ { \ unsigned long temp; \ @@ -271,7 +274,7 @@ temp = MMIO_IN32(pSiS->IOBase, CS(0)); \ temp &= 0x4fffffff; \ MMIO_OUT32(pSiS->IOBase, CS(0), temp); \ - } + } #define sis310SwitchToRGBCursor() \ { \ @@ -290,13 +293,15 @@ MMIO_OUT32(pSiS->IOBase, CS(0), temp); \ } -#define sis310SetCursorBGColor(color)\ +#define sis310SetCursorBGColor(color) \ MMIO_OUT32(pSiS->IOBase, CS(1), (color)); + #define sis310SetCursorFGColor(color)\ MMIO_OUT32(pSiS->IOBase, CS(2), (color)); #define sis310SetCursorPositionX(x,preset)\ MMIO_OUT32(pSiS->IOBase, CS(3), ((x) | ((preset) << 16))); + #define sis310SetCursorPositionY(y,preset)\ MMIO_OUT32(pSiS->IOBase, CS(4), ((y) | ((preset) << 16))); @@ -318,17 +323,17 @@ MMIO_OUT32(pSiS->IOBase,CS(0),temp); \ } -/* 310/325/330 series CRT2 */ +/* 315 series CRT2 */ /* 80000000 = RGB(1) - MONO(0) * 40000000 = enable(1) - disable(0) * 20000000 = 32(1) / 16(1) bit RGB * 10000000 = "ghost"(1) - Alpha Blend(0) ? */ - + #define sis301GetCursorStatus310 \ MMIO_IN32(pSiS->IOBase, CS(8)) & 0x40000000; - + #define sis301SetCursorStatus310(status) \ { \ unsigned long temp; \ @@ -337,32 +342,32 @@ temp |= status; \ MMIO_OUT32(pSiS->IOBase, CS(8), temp); \ } - + #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); \ - } + { \ + 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); \ + } #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); \ - } + { \ + 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); \ + } #define sis301SwitchToRGBCursor310() \ { \ @@ -372,7 +377,7 @@ temp |= 0xA0000000; \ MMIO_OUT32(pSiS->IOBase, CS(8), temp); \ } - + #define sis301SwitchToMONOCursor310() \ { \ unsigned long temp; \ @@ -380,7 +385,7 @@ temp &= 0x4fffffff; \ MMIO_OUT32(pSiS->IOBase, CS(8), temp); \ } - + #define sis301DisableHWCursor310()\ { \ unsigned long temp; \ @@ -398,7 +403,7 @@ MMIO_OUT32(pSiS->IOBase, CS(11), ((x) | ((preset) << 16))); #define sis301SetCursorPositionY310(y,preset)\ MMIO_OUT32(pSiS->IOBase, CS(12), ((y) | ((preset) << 16))); - + #define sis301SetCursorAddress310(address)\ { \ unsigned long temp; \ @@ -425,3 +430,77 @@ MMIO_OUT32(pSiS->IOBase,CS(8),temp); \ } +/* 330 series CRT2 */ + +/* Mono cursor engine for CRT2 on SiS330 (Xabre) has bugs + * and cannot be used! + */ + +/* 80000000 = RGB(1) - MONO(0) + * 40000000 = enable(1) - disable(0) + * 20000000 = 32(1) / 16(1) bit RGB + * 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 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 0ce8e74..6a429e7 100644 --- a/src/sis_dac.c +++ b/src/sis_dac.c @@ -1,7 +1,9 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c,v 1.30 2003/02/05 17:53:22 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c,v 1.49 2003/11/19 21:27:41 twini Exp $ */ /* - * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Parts Copyright 2001, 2002 by Thomas Winischhofer, Vienna, Austria. + * 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. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -21,12 +23,14 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Authors: Alan Hourihane <alanh@fairlite.demon.co.uk> - * Mike Chapman <mike@paranoia.com>, - * Juanjo Santamarta <santamarta@ctv.es>, - * Mitani Hiroshi <hmitani@drl.mei.co.jp> - * David Thomas <davtom@dream.org.uk>. - * Thomas Winischhofer <thomas@winischhofer.net> + * Author: Thomas Winischhofer <thomas@winischhofer.net> + * + * MemClock functions by: + * Alan Hourihane <alanh@fairlite.demon.co.uk> + * Mike Chapman <mike@paranoia.com>, + * Juanjo Santamarta <santamarta@ctv.es>, + * Mitani Hiroshi <hmitani@drl.mei.co.jp> + * David Thomas <davtom@dream.org.uk>. */ #include "xf86.h" @@ -46,23 +50,18 @@ static void SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg); static void SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg); static void SiS300Save(ScrnInfoPtr pScrn, SISRegPtr sisReg); -static void SiS310Save(ScrnInfoPtr pScrn, SISRegPtr sisReg); +static void SiS315Save(ScrnInfoPtr pScrn, SISRegPtr sisReg); static void SiS301Save(ScrnInfoPtr pScrn, SISRegPtr sisReg); static void SiS301BSave(ScrnInfoPtr pScrn, SISRegPtr sisReg); static void SiSLVDSChrontelSave(ScrnInfoPtr pScrn, SISRegPtr sisReg); static void SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg); -static void SiS310Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg); +static void SiS315Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg); static void SiS301Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg); 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); -#if 0 -Bool SiSI2CInit(ScrnInfoPtr pScrn); -#endif static const unsigned short ch700xidx[] = { 0x00,0x07,0x08,0x0a,0x0b,0x04,0x09,0x20,0x21,0x18,0x19,0x1a, @@ -73,8 +72,8 @@ static const unsigned short ch700xidx[] = { 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 - }; + 0x06,0x07,0x08,0x15,0x1f,0x0c,0x0d,0x0e,0x0f,0x10,0x66 + }; int SiS_compute_vclk( int Clock, @@ -122,54 +121,55 @@ int SiS_compute_vclk( * * ** this function can select VCLK ranged from 18.75 to 250 Mhz */ + f = (float) Clock; f /= 1000.0; - if ((f > 250.0) || (f < 18.75)) - return 0; + if((f > 250.0) || (f < 18.75)) + return 0; min_error = f; y = 1.0; x = f; - while (x > 31.25) { - y *= 2.0; - x /= 2.0; + while(x > 31.25) { + y *= 2.0; + x /= 2.0; } - if (x >= 18.25) { - x *= 8.0; - y = 8.0 / y; - } else if (x >= 15.625) { - x *= 12.0; - y = 12.0 / y; + if(x >= 18.25) { + x *= 8.0; + y = 8.0 / y; + } else if(x >= 15.625) { + x *= 12.0; + y = 12.0 / y; } t = y; - if (t == (float) 1.5) { - *out_div = 2; - t *= 2.0; + if(t == (float) 1.5) { + *out_div = 2; + t *= 2.0; } else { - *out_div = 1; + *out_div = 1; } - if (t > (float) 4.0) { - *out_sbit = 1; - t /= 2.0; + if(t > (float) 4.0) { + *out_sbit = 1; + t /= 2.0; } else { - *out_sbit = 0; + *out_sbit = 0; } *out_scale = (int) t; - for (dn=2;dn<=32;dn++) { - for (n=1;n<=128;n++) { - error = x; - error -= ((float) 14.318 * (float) n / (float) dn); - if (error < (float) 0) - error = -error; - if (error < min_error) { - min_error = error; - best_n = n; - best_dn = dn; - } - } + for(dn = 2; dn <= 32; dn++) { + for(n = 1; n <= 128; n++) { + error = x; + error -= ((float) 14.318 * (float) n / (float) dn); + if(error < (float) 0) + error = -error; + if(error < min_error) { + min_error = error; + best_n = n; + best_dn = dn; + } + } } *out_n = best_n; *out_dn = best_dn; @@ -186,15 +186,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 @@ -216,142 +219,138 @@ SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD, unsigned int *vclk) #define MAX_PSN 0 /* no pre scaler for this chip */ #define TOLERANCE 0.01 /* search smallest M and N in this tolerance */ - int M_min = 2; + int M_min = 2; int M_max = 128; - -/* abest=10000.0; */ - + target = clock * 1000; - - if (pSiS->Chipset == PCI_CHIP_SIS5597 || pSiS->Chipset == PCI_CHIP_SIS6326){ - int low_N = 2; - int high_N = 5; - - PSN = 1; - P = 1; - if (target < MAX_VCO_5597 / 2) - P = 2; - if (target < MAX_VCO_5597 / 3) - P = 3; - if (target < MAX_VCO_5597 / 4) - P = 4; - if (target < MAX_VCO_5597 / 6) - P = 6; - if (target < MAX_VCO_5597 / 8) - P = 8; - - Fvco = P * target; - - for (N = low_N; N <= high_N; N++){ - double M_desired = Fvco / Fref * N; - if (M_desired > M_max * max_VLD) - continue; - - if ( M_desired > M_max ) { - M = M_desired / 2 + 0.5; - VLD = 2; - } else { - M = Fvco / Fref * N + 0.5; - VLD = 1; - } - - Fout = (double)Fref * (M * VLD)/(N * P); - - error = (target - Fout) / target; - aerror = (error < 0) ? -error : error; -/* if (aerror < abest && abest > TOLERANCE) */ - if (aerror < abest) { - abest = aerror; - bestError = error; - bestM = M; - bestN = N; - bestP = P; - bestPSN = PSN; - bestVLD = VLD; - bestFout = Fout; - } - } + + if(pSiS->Chipset == PCI_CHIP_SIS5597 || pSiS->Chipset == PCI_CHIP_SIS6326) { + + int low_N = 2; + int high_N = 5; + + PSN = 1; + P = 1; + if(target < MAX_VCO_5597 / 2) P = 2; + if(target < MAX_VCO_5597 / 3) P = 3; + if(target < MAX_VCO_5597 / 4) P = 4; + if(target < MAX_VCO_5597 / 6) P = 6; + if(target < MAX_VCO_5597 / 8) P = 8; + + Fvco = P * target; + + for(N = low_N; N <= high_N; N++) { + + double M_desired = Fvco / Fref * N; + if(M_desired > M_max * max_VLD) continue; + + if(M_desired > M_max) { + M = M_desired / 2 + 0.5; + VLD = 2; + } else { + M = Fvco / Fref * N + 0.5; + VLD = 1; + } + + Fout = (double)Fref * (M * VLD)/(N * P); + + error = (target - Fout) / target; + aerror = (error < 0) ? -error : error; + if(aerror < abest) { + abest = aerror; + bestM = M; + bestN = N; + bestP = P; + bestPSN = PSN; + bestVLD = VLD; +#ifdef DEBUG + bestFout = Fout; +#endif + } } - else { - for (PSNx = 0; PSNx <= MAX_PSN ; PSNx++) { - int low_N, high_N; - double FrefVLDPSN; - - PSN = !PSNx ? 1 : 4; - - low_N = 2; - high_N = 32; - - for ( VLD = 1 ; VLD <= max_VLD ; VLD++ ) { - - FrefVLDPSN = (double)Fref * VLD / PSN; - for (N = low_N; N <= high_N; N++) { - double tmp = FrefVLDPSN / N; - - for (P = 1; P <= 4; P++) { - double Fvco_desired = target * ( P ); - double M_desired = Fvco_desired / tmp; - - /* Which way will M_desired be rounded? - * Do all three just to be safe. - */ - int M_low = M_desired - 1; - int M_hi = M_desired + 1; - - if (M_hi < M_min || M_low > M_max) - continue; - - if (M_low < M_min) - M_low = M_min; - if (M_hi > M_max) - M_hi = M_max; - - for (M = M_low; M <= M_hi; M++) { - Fvco = tmp * M; - if (Fvco <= MIN_VCO) - continue; - if (Fvco > MAX_VCO) - break; - - Fout = Fvco / ( P ); - - error = (target - Fout) / target; - aerror = (error < 0) ? -error : error; - if (aerror < abest) { - abest = aerror; - bestError = error; - bestM = M; - bestN = N; - bestP = P; - bestPSN = PSN; - bestVLD = VLD; - bestFout = Fout; - } - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,3, + + } else { + + for(PSNx = 0; PSNx <= MAX_PSN ; PSNx++) { + + int low_N, high_N; + double FrefVLDPSN; + + PSN = !PSNx ? 1 : 4; + + low_N = 2; + high_N = 32; + + for(VLD = 1 ; VLD <= max_VLD ; VLD++) { + + FrefVLDPSN = (double)Fref * VLD / PSN; + + for(N = low_N; N <= high_N; N++) { + double tmp = FrefVLDPSN / N; + + for(P = 1; P <= 4; P++) { + double Fvco_desired = target * ( P ); + double M_desired = Fvco_desired / tmp; + + /* Which way will M_desired be rounded? + * Do all three just to be safe. + */ + int M_low = M_desired - 1; + int M_hi = M_desired + 1; + + if(M_hi < M_min || M_low > M_max) continue; + + if(M_low < M_min) M_low = M_min; + + if(M_hi > M_max) M_hi = M_max; + + for(M = M_low; M <= M_hi; M++) { + Fvco = tmp * M; + if(Fvco <= MIN_VCO) continue; + if(Fvco > MAX_VCO) break; + + Fout = Fvco / ( P ); + + error = (target - Fout) / target; + aerror = (error < 0) ? -error : error; + if(aerror < abest) { + abest = aerror; + bestM = M; + bestN = N; + bestP = P; + bestPSN = PSN; + bestVLD = VLD; +#ifdef DEBUG + bestFout = Fout; +#endif + } +#ifdef TWDEBUG + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,3, "Freq. selected: %.2f MHz, M=%d, N=%d, VLD=%d, P=%d, PSN=%d\n", (float)(clock / 1000.), M, N, P, VLD, PSN); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,3, + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,3, "Freq. set: %.2f MHz\n", Fout / 1.0e6); - } - } - } - } - } +#endif + } + } + } + } + } } - vclk[Midx] = bestM; - vclk[Nidx] = bestN; - vclk[VLDidx] = bestVLD; - vclk[Pidx] = bestP; - vclk[PSNidx] = bestPSN; + vclk[Midx] = bestM; + vclk[Nidx] = bestN; + vclk[VLDidx] = bestVLD; + vclk[Pidx] = bestP; + vclk[PSNidx] = bestPSN; - PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Freq. selected: %.2f MHz, M=%d, N=%d, VLD=%d, P=%d, PSN=%d\n", - (float)(clock / 1000.), vclk[Midx], vclk[Nidx], vclk[VLDidx], + (float)(clock / 1000.), vclk[Midx], vclk[Nidx], vclk[VLDidx], vclk[Pidx], vclk[PSNidx])); - PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Freq. set: %.2f MHz\n", bestFout / 1.0e6)); - PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "VCO Freq.: %.2f MHz\n", bestFout*bestP / 1.0e6)); } @@ -369,7 +368,7 @@ SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg) sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - switch (pSiS->Chipset) { + switch(pSiS->Chipset) { case PCI_CHIP_SIS5597: max=0x3C; break; @@ -383,22 +382,18 @@ SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg) } /* Save extended SR registers */ - for (i = 0x06; i <= max; i++) { - inSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); -#ifdef DEBUG - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "XR%02X Contents - %02X \n", i, sisReg->sisRegs3C4[i]); -#endif + for(i = 0x00; i <= max; 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, + for(i = 0x00; i <= 0x3f; i++) { + inSISIDXREG(SISCR, i, max); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CR%02X - %02X \n", i,max); } #endif @@ -412,9 +407,9 @@ SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg) 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 } @@ -427,9 +422,6 @@ SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) SISPtr pSiS = SISPTR(pScrn); int i,max; unsigned char tmp; -#ifdef DEBUG - int temp; -#endif xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, "SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n"); @@ -438,7 +430,7 @@ SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - switch (pSiS->Chipset) { + switch(pSiS->Chipset) { case PCI_CHIP_SIS5597: max = 0x3C; break; @@ -459,48 +451,10 @@ SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) SiS6326SetTVReg(pScrn, 0x00, tmp); } - /* Restore VCLKs */ -#if 0 /* TW: No, we didn't save SR2x-1 and SR2x-2! */ - andSISIDXREG(SISSR, 0x38, 0xfc); - inSISIDXREG(SISSR, 0x13, tmp); - tmp &= ~0x40; - tmp |= (sisReg->sisRegs3C4[0x13] & 0x40); - outSISIDXREG(SISSR, 0x13, tmp); - outSISIDXREG(SISSR, 0x2a, sisReg->sisRegs3C4[0x2a]); - outSISIDXREG(SISSR, 0x2b, sisReg->sisRegs3C4[0x2b]); - orSISIDXREG(SISSR, 0x38, 0x01); - inSISIDXREG(SISSR, 0x13, tmp); - tmp &= ~0x40; - tmp |= (sisReg->sisRegs3C4[0x13] & 0x40); - outSISIDXREG(SISSR, 0x13, tmp); - outSISIDXREG(SISSR, 0x2a, sisReg->sisRegs3C4[0x2a]); - outSISIDXREG(SISSR, 0x2b, sisReg->sisRegs3C4[0x2b]); - andSISIDXREG(SISSR, 0x38, 0xfc); - orSISIDXREG(SISSR, 0x38, 0x02); - inSISIDXREG(SISSR, 0x13, tmp); - tmp &= ~0x40; - tmp |= (sisReg->sisRegs3C4[0x13] & 0x40); - outSISIDXREG(SISSR, 0x13, tmp); - outSISIDXREG(SISSR, 0x2a, sisReg->sisRegs3C4[0x2a]); - outSISIDXREG(SISSR, 0x2b, sisReg->sisRegs3C4[0x2b]); - andSISIDXREG(SISSR, 0x38, 0xfc); -#endif - /* Restore other extended SR registers */ - for (i = 0x06; i <= max; i++) { - if((i == 0x13) || (i == 0x2a) || (i == 0x2b)) continue; -#ifdef DEBUG - inSISIDXREG(SISSR, i, temp); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "SR%X Contents: %02X - ", i, temp); -#endif - outSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); -#ifdef DEBUG - inSISIDXREG(SISSR, i, temp); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "Restored to %02X - Read: %02X\n", - sisReg->sisRegs3C4[i], temp); -#endif + 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) */ @@ -520,9 +474,9 @@ SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) 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 @@ -556,23 +510,23 @@ SiS300Save(ScrnInfoPtr pScrn, SISRegPtr sisReg) #endif /* Save SR registers */ - for (i = 0x00; i <= 0x3D; i++) { - inSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); + for(i = 0x00; i <= 0x3D; 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 } /* Save CR registers */ - for (i = 0x00; i < 0x40; i++) { - inSISIDXREG(SISCR, i, sisReg->sisRegs3D4[i]); + for(i = 0x00; i < 0x40; 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 Misc register */ sisReg->sisRegs3C2 = inSISREG(SISMISCR); @@ -592,12 +546,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|VB_303)) - (*pSiS->SiSSave2)(pScrn, sisReg); - if (pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) - (*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 @@ -606,7 +560,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, @@ -630,68 +584,68 @@ 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->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 */ - if(pSiS->VBFlags & (VB_LVDS | VB_301B)) { + + /* Restore VCLK and ECLK */ + if(pSiS->VBFlags & (VB_LVDS | VB_301B | VB_301C)) { outSISIDXREG(SISSR,0x31,0x20); outSISIDXREG(SISSR,0x2b,sisReg->sisRegs3C4[0x2b]); outSISIDXREG(SISSR,0x2c,sisReg->sisRegs3C4[0x2c]); @@ -705,7 +659,7 @@ SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) outSISIDXREG(SISSR,0x2b,sisReg->sisRegs3C4[0x2b]); outSISIDXREG(SISSR,0x2c,sisReg->sisRegs3C4[0x2c]); outSISIDXREG(SISSR,0x2d,0x80); - if(pSiS->VBFlags & (VB_LVDS | VB_301B)) { + if(pSiS->VBFlags & (VB_LVDS | VB_301B | VB_301C)) { outSISIDXREG(SISSR,0x31,0x20); outSISIDXREG(SISSR,0x2e,sisReg->sisRegs3C4[0x2e]); outSISIDXREG(SISSR,0x2f,sisReg->sisRegs3C4[0x2f]); @@ -716,10 +670,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); @@ -729,9 +683,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; @@ -739,20 +693,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|VB_303)) - (*pSiS->SiSRestore2)(pScrn, sisReg); - if (pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) - (*pSiS->SiSRestore3)(pScrn, sisReg); + 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|VB_302ELV)) + (*pSiS->SiSRestore3)(pScrn, sisReg); } - + /* MemClock needs this to take effect */ outSISIDXREG(SISSR, 0x00, 0x01); /* Synchronous Reset */ outSISIDXREG(SISSR, 0x00, 0x03); /* End Reset */ @@ -761,65 +715,75 @@ 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 SiS310 series register contents */ +/* Save SiS315 series register contents */ static void -SiS310Save(ScrnInfoPtr pScrn, SISRegPtr sisReg) +SiS315Save(ScrnInfoPtr pScrn, SISRegPtr sisReg) { SISPtr pSiS = SISPTR(pScrn); int i; PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "SiS310Save(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n")); + "SiS315Save(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n")); #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif /* Save SR registers */ - for (i = 0x00; i <= 0x3F; i++) { - inSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); -#ifdef DEBUG - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "SR%02X - %02X \n", i,sisReg->sisRegs3C4[i]); -#endif + 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 } - /* TW: Save command queue location */ + /* Save command queue location */ sisReg->sisMMIO85C0 = MMIO_IN32(pSiS->IOBase, 0x85C0); /* Save CR registers */ - for (i = 0x00; i <= 0x5f; i++) { - inSISIDXREG(SISCR, i, sisReg->sisRegs3D4[i]); -#ifdef DEBUG - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "CR%02X - %02X \n", i,sisReg->sisRegs3D4[i]); -#endif + for(i = 0x00; i <= 0x7a; 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]); +#ifdef TWDEBUG + 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]); +#ifdef TWDEBUG + 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|VB_303)) - (*pSiS->SiSSave2)(pScrn, sisReg); - if (pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) - (*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 @@ -828,43 +792,37 @@ SiS310Save(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, + "BIOS mode ds:449 = 0x%x\n", pSiS->BIOSModeSave); +#endif } -/* Restore SiS310 series register contents */ +/* Restore SiS315/330 series register contents */ static void -SiS310Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) +SiS315Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) { SISPtr pSiS = SISPTR(pScrn); int i,temp; xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "SiS310Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n"); + "SiS315Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n"); #ifdef UNLOCK_ALWAYS 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)) { /* TW: 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){}; - } - - /* Restore extended CR registers */ - for (i = 0x19; i < 0x5C; i++) { - outSISIDXREG(SISCR, i, sisReg->sisRegs3D4[i]); - } - - /* TW: 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(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){}; } - /* TW: We reset the command queue before restoring. + /* We reset the command queue before restoring. * This might be required because we never know what * console driver (like the kernel framebuffer driver) * or application is running and which queue mode it @@ -873,68 +831,74 @@ SiS310Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) outSISIDXREG(SISSR, 0x27, 0x1F); outSISIDXREG(SISSR, 0x26, 0x01); + /* Restore extended CR registers */ + 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, 0x63, sisReg->sisRegs3D4[0x63]); + + /* 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]); + } + /* Restore extended SR registers */ - for (i = 0x06; i <= 0x3F; i++) { -#ifdef DEBUG - inSISIDXREG(SISSR, i, temp); -#endif - outSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); -#ifdef DEBUG - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "XR%X Contents %02X - ", i, temp); - inSISIDXREG(SISSR, i, temp); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "Restored to %02X - Read: %02X\n", - sisReg->sisRegs3C4[i], temp); -#endif + for(i = 0x06; i <= 0x3F; i++) { + outSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]); } - /* TW: Restore VCLK and ECLK */ + /* 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); } - /* TW: Initialize read/write pointer for command queue */ +#ifndef SISVRAMQ + /* Initialize read/write pointer for command queue */ MMIO_OUT32(pSiS->IOBase, 0x85C4, MMIO_IN32(pSiS->IOBase, 0x85C8)); - /* TW: Restore queue location */ +#endif + /* Restore queue location */ MMIO_OUT32(pSiS->IOBase, 0x85C0, sisReg->sisMMIO85C0); /* Restore Misc register */ outSISREG(SISMISCW, sisReg->sisRegs3C2); /* 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|VB_303)) - (*pSiS->SiSRestore2)(pScrn, sisReg); - if (pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) - (*pSiS->SiSRestore3)(pScrn, sisReg); + 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|VB_302ELV)) + (*pSiS->SiSRestore3)(pScrn, sisReg); } /* MemClock needs this to take effect */ @@ -948,56 +912,56 @@ SiS310Restore(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 } +} - sisReg->VBPart2[0] &= ~0x20; /* Disable VB Processor */ +/* Save SiS301 bridge register contents */ +static void +SiS301Save(ScrnInfoPtr pScrn, SISRegPtr sisReg) +{ + SISPtr pSiS = SISPTR(pScrn); + int Part1max, Part2max, Part3max, Part4max; + + /* 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 */ } @@ -1006,27 +970,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); @@ -1039,22 +995,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: - /* TW: Nothing special here. */ - break; - case SIS_315_VGA: - /* TW: Restore extra registers on 310 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 */ @@ -1074,99 +1025,50 @@ 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_30xLV|VB_30xLVX)) - Part4max = 0x24; - 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_30xLV|VB_30xLVX)) - Part4max = 0x24; - else - Part4max = 0x23; - break; - } + int Part1max, Part2max, Part3max, Part4max; - 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 - } - 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 - } - sisReg->VBPart2[0] &= ~0x20; /* Disable VB Processor */ + Part1max = 0x37; /* 0x23, but we also need 2c-2e, 35-37 */ + Part2max = 0x4d; + Part3max = 0x3e; + if(pSiS->VBFlags & (VB_301LV|VB_302LV|VB_302ELV)) + Part4max = 0x34; + else + Part4max = 0x23; + + 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_30xLV|VB_30xLVX)) - Part4max = 0x24; - else - Part4max = 0x22; - break; - case SIS_315_VGA: - Part1max = 0x23; - Part2max = 0x4d; - Part3max = 0x3e; - if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) - Part4max = 0x24; - else - Part4max = 0x22; - break; - } + int Part1max, Part2max, Part3max, Part4max; - SiS_DisableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); + Part1max = 0x23; + Part2max = 0x4d; + Part3max = 0x3e; + if(pSiS->VBFlags & (VB_301LV|VB_302LV|VB_302ELV)) + Part4max = 0x24; + else + Part4max = 0x22; - SiS_UnLockCRT2(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); /* Pre-restore Part1 */ outSISIDXREG(SISPART1, 0x04, 0x00); @@ -1174,18 +1076,19 @@ SiS301BRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) outSISIDXREG(SISPART1, 0x06, 0x00); outSISIDXREG(SISPART1, 0x00, sisReg->VBPart1[0x00]); outSISIDXREG(SISPART1, 0x01, sisReg->VBPart1[0x01]); - /* Mode reg 0x01 became 0x2e on 310 series (0x01 still contains FIFO) */ - if(pSiS->VGAEngine == SIS_315_VGA) - outSISIDXREG(SISPART1, 0x2e, sisReg->VBPart1[0x2e]); + /* Mode reg 0x01 became 0x2e on 315 series (0x01 still contains FIFO) */ + 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 */ @@ -1211,9 +1114,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 */ @@ -1224,30 +1127,34 @@ 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<34; 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, + "LVDSSave: Chrontel 0x%02x = 0x%02x\n", + ch701xidx[i], sisReg->ch70xx[i]); +#endif } } } @@ -1263,24 +1170,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); } } } @@ -1290,200 +1197,70 @@ 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 */ } - /* TW: For 550 DSTN registers */ - if (pSiS->DSTN) { - SetBlock(SISPART1, 0x25, 0x2E, &(sisReg->VBPart1[0x25])); - SetBlock(SISPART1, 0x30, 0x45, &(sisReg->VBPart1[0x30])); + /* For 550 DSTN registers */ + 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); } -/* TW: Restore output selection registers (CR30, 31, 33, 35/38) */ +/* Restore output selection registers */ 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]); - 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 <= 0x39; i++) { + if(i == 0x34) continue; + outSISIDXREG(SISCR, i, sisReg->sisRegs3D4[i]); } -} - -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: I2C functions not in use */ -/* -static void -SiS_I2CGetBits(I2CBusPtr b, int *clock, int *data) -{ - SISPtr pSiS = SISPTR(xf86Screens[b->scrnIndex]); - unsigned char val; - - outSISIDXREG(SISSR, 0x05, 0x86); - inSISIDXREG(SISSR, pSiS->SiS_DDC2_Index, val); - *clock = (val & pSiS->SiS_DDC2_Clk) != 0; - *data = (val & pSiS->SiS_DDC2_Data) != 0; -} - -static void -SiS_I2CPutBits(I2CBusPtr b, int clock, int data) -{ - SISPtr pSiS = SISPTR(xf86Screens[b->scrnIndex]); - unsigned char temp; - - outSISIDXREG(SISSR, 0x05, 0x86); - inSISIDXREG(SISSR, pSiS->SiS_DDC2_Index, temp); - - temp &= ~(pSiS->SiS_DDC2_Clk | pSiS->SiS_DDC2_Data); - - temp |= ((clock ? pSiS->SiS_DDC2_Clk : 0) | (data ? pSiS->SiS_DDC2_Data : 0)); - - outSISIDXREG(SISSR, pSiS->SiS_DDC2_Index, temp); -} -*/ - -static Bool -SiS_I2CAddress(I2CDevPtr d, I2CSlaveAddr addr) -{ - I2CBusPtr b = d->pI2CBus; - SISPtr pSiS = SISPTR(xf86Screens[b->scrnIndex]); - SiS_SetSwitchDDC2(pSiS->SiS_Pr); - return(SiS_I2C_Address(pSiS->SiS_Pr, addr)); -} - -static void -SiS_I2CStop(I2CDevPtr d) -{ - I2CBusPtr b = d->pI2CBus; - SISPtr pSiS = SISPTR(xf86Screens[b->scrnIndex]); - SiS_I2C_Stop(pSiS->SiS_Pr); -} - -static Bool -SiS_I2CGetByte(I2CDevPtr d, I2CByte *data, Bool last) -{ - I2CBusPtr b = d->pI2CBus; - SISPtr pSiS = SISPTR(xf86Screens[b->scrnIndex]); - USHORT temp = SiS_I2C_GetByte(pSiS->SiS_Pr); - if(temp == 0xffff) return FALSE; - return TRUE; -} - -static Bool -SiS_I2CPutByte(I2CDevPtr d, I2CByte data) -{ - I2CBusPtr b = d->pI2CBus; - SISPtr pSiS = SISPTR(xf86Screens[b->scrnIndex]); - return(SiS_I2C_PutByte(pSiS->SiS_Pr, (USHORT)data)); -} - -Bool -SiSI2CInit(ScrnInfoPtr pScrn) -{ - SISPtr pSiS = SISPTR(pScrn); - I2CBusPtr I2CPtr; - USHORT temp, i; - unsigned char buffer[256]; - xf86MonPtr pMonitor; - - I2CPtr = xf86CreateI2CBusRec(); - if(!I2CPtr) return FALSE; - - pSiS->I2C = I2CPtr; - - I2CPtr->BusName = "DDC"; - I2CPtr->scrnIndex = pScrn->scrnIndex; -/* - I2CPtr->I2CPutBits = SiS_I2CPutBits; - I2CPtr->I2CGetBits = SiS_I2CGetBits; -*/ - I2CPtr->I2CPutByte = SiS_I2CPutByte; - I2CPtr->I2CGetByte = SiS_I2CGetByte; - I2CPtr->I2CAddress = SiS_I2CAddress; - I2CPtr->I2CStop = SiS_I2CStop; - I2CPtr->AcknTimeout = 30; - - - - pSiS->SiS_Pr->SiS_DDC_Index = pSiS->SiS_DDC2_Index; - pSiS->SiS_Pr->SiS_DDC_Data = pSiS->SiS_DDC2_Data; - pSiS->SiS_Pr->SiS_DDC_Clk = pSiS->SiS_DDC2_Clk; - pSiS->SiS_Pr->SiS_DDC_DataShift = 0x00; - - if (!xf86I2CBusInit(I2CPtr)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not create I2C bus record\n"); - return FALSE; - } - - return TRUE; + if(pSiS->VGAEngine == SIS_315_VGA) { + outSISIDXREG(SISCR, 0x63, sisReg->sisRegs3D4[0x63]); + if(pSiS->sishw_ext.jChipType < SIS_661) { + outSISIDXREG(SISCR, 0x79, sisReg->sisRegs3D4[0x79]); + } + } } -#endif -#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. +#if 0 /* 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) @@ -1534,17 +1311,8 @@ SiS_CalcSpecial530Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, int index) } #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) */ -/* TW: Not for 530/620 if UMA (on these, the mclk is stored in SR10) */ +/* Not for 530/620 if UMA (on these, the mclk is stored in SR10) */ int SiSMclk(SISPtr pSiS) { @@ -1552,30 +1320,7 @@ SiSMclk(SISPtr pSiS) unsigned char Num, Denum, Base; switch (pSiS->Chipset) { - case PCI_CHIP_SIS5597: - case PCI_CHIP_SIS6326: - case PCI_CHIP_SIS530: - /* Numerator */ - inSISIDXREG(SISSR, MemClock0, Num); - mclk = 14318 * ((Num & 0x7f) + 1); - - /* Denumerator */ - inSISIDXREG(SISSR, MemClock1, Denum); - mclk = mclk / ((Denum & 0x1f) + 1); - - /* Divider. Doesn't seem to work for mclk in older cards */ - if((Num & 0x80) != 0) mclk *= 2; - /* Post-scaler. Values' meaning depends on SR13 bit 7 */ - inSISIDXREG(SISSR, ClockBase, Base); - if((Base & 0x80) == 0) { - 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; - } - break; case PCI_CHIP_SIS300: case PCI_CHIP_SIS540: case PCI_CHIP_SIS630: @@ -1585,6 +1330,7 @@ SiSMclk(SISPtr pSiS) case PCI_CHIP_SIS315H: case PCI_CHIP_SIS315PRO: case PCI_CHIP_SIS330: + case PCI_CHIP_SIS660: /* Numerator */ inSISIDXREG(SISSR, 0x28, Num); mclk = 14318 * ((Num & 0x7f) + 1); @@ -1598,30 +1344,53 @@ 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; + + case PCI_CHIP_SIS5597: + case PCI_CHIP_SIS6326: + case PCI_CHIP_SIS530: default: - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR, - "Internal error: SiSMClk() called with invalid chipset (0x%x)\n", - pSiS->Chipset); - mclk = 0; + /* Numerator */ + inSISIDXREG(SISSR, 0x28, Num); + mclk = 14318 * ((Num & 0x7f) + 1); + + /* Denumerator */ + inSISIDXREG(SISSR, 0x29, Denum); + mclk = mclk / ((Denum & 0x1f) + 1); + + /* Divider. Doesn't work on older cards */ + if(pSiS->oldChipset >= OC_SIS5597) { + if(Num & 0x80) mclk *= 2; + } + + /* Post-scaler. Values' meaning depends on SR13 bit 7 */ + inSISIDXREG(SISSR, 0x13, Base); + if((Base & 0x80) == 0) { + 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; + } + break; } return(mclk); } -/* TW: This estimates the CRT2 clock we are going to use. - * The total bandwidth is to be reduced by the value - * returned here in order to get an idea of the maximum - * dotclock left for CRT1. - * Since we don't know yet, what mode the user chose, - * we return the maximum dotclock used by - * - either the LCD attached, or - * - TV - * For VGA2, we share the bandwith equally. +/* This estimates the CRT2 clock we are going to use. + * The total bandwidth is to be reduced by the value + * returned here in order to get an idea of the maximum + * dotclock left for CRT1. + * Since we don't know yet, what mode the user chose, + * we return the maximum dotclock used by + * - either the LCD attached, or + * - TV + * For VGA2, we share the bandwith equally. */ static int SiSEstimateCRT2Clock(ScrnInfoPtr pScrn) @@ -1629,37 +1398,39 @@ SiSEstimateCRT2Clock(ScrnInfoPtr pScrn) 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)) - return 65000; - else if(pSiS->VBLCDFlags & (VB_LCD_1152x768 | VB_LCD_1280x1024 | VB_LCD_1280x960)) - return 108000; - else if(pSiS->VBLCDFlags & VB_LCD_1400x1050) - return 122000; - else if(pSiS->VBLCDFlags & VB_LCD_1600x1200) - return 162000; - 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_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; } 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) { + return 70000; + } } return 0; } /* Calculate the maximum dotclock */ -int SiSMemBandWidth(ScrnInfoPtr pScrn) +int SiSMemBandWidth(ScrnInfoPtr pScrn, BOOLEAN IsForCRT2) { SISPtr pSiS = SISPTR(pScrn); #ifdef SISDUALHEAD @@ -1670,14 +1441,15 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn) int mclk = pSiS->MemClock; int bpp = pSiS->CurrentLayout.bitsPerPixel; int bytesperpixel = (bpp + 7) / 8; - float magic=0.0, total, crt2used; + float magic=0.0, total, crt2used, maxcrt2; int crt2clock, max=0; 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 }; + BOOLEAN DHM, GetForCRT1; - switch (pSiS->Chipset) { + switch(pSiS->Chipset) { case PCI_CHIP_SIS5597: total = ((mclk * (bus / 8)) * 0.7) / bytesperpixel; @@ -1712,6 +1484,7 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn) case PCI_CHIP_SIS550: case PCI_CHIP_SIS650: case PCI_CHIP_SIS330: + case PCI_CHIP_SIS660: switch(pSiS->Chipset) { case PCI_CHIP_SIS300: magic = magic300[bus/64]; @@ -1730,9 +1503,21 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn) max = 780000; break; case PCI_CHIP_SIS550: + magic = magic550[bus/64]; + max = 620000; + break; case PCI_CHIP_SIS650: magic = magic550[bus/64]; - max = 780000; + max = 680000; + break; + 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 = 680000; } PDEBUG(ErrorF("mclk: %d, bus: %d, magic: %g, bpp: %d\n", @@ -1743,18 +1528,39 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn) xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Memory bandwidth at %d bpp is %g MHz\n", bpp, total/1000); - if(pSiS->VBFlags & CRT2_ENABLE) { + if((pSiS->VBFlags & CRT2_ENABLE) && (!pSiS->CRT1off)) { + + maxcrt2 = 135000; + if(pSiS->VBFlags & (VB_301B|VB_302B)) maxcrt2 = 162000; + 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); if(crt2clock) { crt2used = crt2clock + 2000; } + DHM = FALSE; + GetForCRT1 = FALSE; #ifdef SISDUALHEAD if((pSiS->DualHeadMode) && (pSiSEnt)) { + DHM = TRUE; + if(pSiS->SecondHead) GetForCRT1 = TRUE; + } +#endif +#ifdef SISMERGED + if(pSiS->MergedFB && IsForCRT2) { + DHM = TRUE; + GetForCRT1 = FALSE; + } +#endif + + if(DHM) { - if(!pSiS->SecondHead) { + if(!GetForCRT1) { /* TW: First head = CRT2 */ @@ -1769,22 +1575,30 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn) * calculation below. */ total = crt2used * magic; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Bandwidth reserved for CRT2 is %g Mhz\n", - crt2used/1000); + } else { /* We don't know about the second head's * depth yet. So we assume it uses the - * same. + * same. But since the maximum dotclock + * is limited on CRT2, we can assume a + * maximum here. */ - total /= 2; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Bandwidth reserved for CRT2 is %g Mhz\n", - total/1000); + if((total / 2) > (maxcrt2 + 2000)) { + total = (maxcrt2 + 2000) * magic; + crt2used = maxcrt2 + 2000; + } else { + total /= 2; + crt2used = total; + } + } + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Bandwidth reserved for CRT2 is %g Mhz\n", + crt2used/1000); } else { - +#ifdef SISDUALHEAD /* TW: Second head = CRT1 */ /* Now We know about the first head's depth, @@ -1807,104 +1621,138 @@ int SiSMemBandWidth(ScrnInfoPtr pScrn) xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Bandwidth available for CRT1 is %g MHz\n", total/1000); - +#endif } } else { -#endif + if(crt2clock) { total -= crt2used; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Bandwidth reserved for CRT2 is %g Mhz\n", crt2used/1000); } else { - total /= 2; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Bandwidth reserved for CRT2 is %g Mhz\n", total/1000); + if((total / 2) > (maxcrt2 + 2000)) { + total -= (maxcrt2 + 2000); + crt2used = maxcrt2 + 2000; + } else { + total /= 2; + crt2used = total; + } } + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Bandwidth reserved for CRT2 is %g Mhz\n", crt2used/1000); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Bandwidth available for CRT1 is %g MHz\n", total/1000); -#ifdef SISDUALHEAD + } -#endif } total /= magic; if(total > (max / 2)) total = max / 2; - return (int)(total); + return(int)(total); default: - return 135000; /* guessed */ + return(135000); } } -/* TW: Load the palette. We do this for all supported color depths - * in order to support gamma correction. We hereby convert the - * given colormap to a complete 24bit color palette and enable - * the correspoding bit in SR7 to enable the 24bit lookup table. - * Gamma correction is only supported on CRT1. - * Why are there 6-bit-RGB values submitted even if bpp is 16 and - * weight is 565? (Maybe because rgbBits is 6?) +/* Load the palette. We do this for all supported color depths + * in order to support gamma correction. We hereby convert the + * given colormap to a complete 24bit color palette and enable + * the correspoding bit in SR7 to enable the 24bit lookup table. + * Gamma correction is only supported on CRT1. + * Why are there 6-bit-RGB values submitted even if bpp is 16 and + * weight is 565? (Maybe because rgbBits is 6?) */ void SISLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual) { - SISPtr pSiS = SISPTR(pScrn); - int i, j, index; + 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; + + if(pSiS->DualHeadMode) dogamma1 = pSiSEnt->CRT1gamma; +#endif - PDEBUG(ErrorF("SiSLoadPalette(%d)\n", numColors)); + PDEBUG(ErrorF("SiSLoadPalette(%d)\n", numColors)); #ifdef SISDUALHEAD - /* TW: No palette changes on CRT2 if in dual head mode */ - if((pSiS->DualHeadMode) && (!pSiS->SecondHead)) return; + 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: - orSISIDXREG(SISSR, 0x07, 0x04); - for(i=0; i<numColors; i++) { - index = indices[i]; - if(index < 32) { /* Paranoia */ - for(j=0; j<8; j++) { - outSISREG(SISCOLIDX, (index * 8) + j); - outSISREG(SISCOLDATA, colors[index].red << (8- pScrn->rgbBits)); - outSISREG(SISCOLDATA, colors[index].green << (8 - pScrn->rgbBits)); - outSISREG(SISCOLDATA, colors[index].blue << (8 - pScrn->rgbBits)); + if(dogamma1) { + orSISIDXREG(SISSR, 0x07, 0x04); + for(i=0; i<numColors; i++) { + index = indices[i]; + if(index < 32) { /* Paranoia */ + for(j=0; j<8; j++) { + outSISREG(SISCOLIDX, (index * 8) + j); + outSISREG(SISCOLDATA, colors[index].red << (8- pScrn->rgbBits)); + outSISREG(SISCOLDATA, colors[index].green << (8 - pScrn->rgbBits)); + outSISREG(SISCOLDATA, colors[index].blue << (8 - pScrn->rgbBits)); + } } - } - } + } + } else { + andSISIDXREG(SISSR, 0x07, ~0x04); + } break; case 16: - orSISIDXREG(SISSR, 0x07, 0x04); - for(i=0; i<numColors; i++) { - index = indices[i]; - if(index < 64) { /* Paranoia */ - for(j=0; j<4; j++) { - outSISREG(SISCOLIDX, (index * 4) + j); - outSISREG(SISCOLDATA, colors[index/2].red << (8 - pScrn->rgbBits)); - outSISREG(SISCOLDATA, colors[index].green << (8 - pScrn->rgbBits)); - outSISREG(SISCOLDATA, colors[index/2].blue << (8 - pScrn->rgbBits)); + if(dogamma1) { + orSISIDXREG(SISSR, 0x07, 0x04); + for(i=0; i<numColors; i++) { + index = indices[i]; + if(index < 64) { /* Paranoia */ + for(j=0; j<4; j++) { + outSISREG(SISCOLIDX, (index * 4) + j); + outSISREG(SISCOLDATA, colors[index/2].red << (8 - pScrn->rgbBits)); + outSISREG(SISCOLDATA, colors[index].green << (8 - pScrn->rgbBits)); + outSISREG(SISCOLDATA, colors[index/2].blue << (8 - pScrn->rgbBits)); + } } - } - } + } + } else { + andSISIDXREG(SISSR, 0x07, ~0x04); + } break; case 24: - orSISIDXREG(SISSR, 0x07, 0x04); - for(i=0; i<numColors; i++) { - index = indices[i]; - if(index < 256) { /* Paranoia */ - outSISREG(SISCOLIDX, index); - outSISREG(SISCOLDATA, colors[index].red); - outSISREG(SISCOLDATA, colors[index].green); - outSISREG(SISCOLDATA, colors[index].blue); - } - } + if(dogamma1) { + orSISIDXREG(SISSR, 0x07, 0x04); + for(i=0; i<numColors; i++) { + index = indices[i]; + if(index < 256) { /* Paranoia */ + outSISREG(SISCOLIDX, index); + outSISREG(SISCOLDATA, colors[index].red); + outSISREG(SISCOLDATA, colors[index].green); + outSISREG(SISCOLDATA, colors[index].blue); + } + } + } else { + andSISIDXREG(SISSR, 0x07, ~0x04); + } break; #endif default: - if(pScrn->rgbBits == 8) + if((pScrn->rgbBits == 8) && (dogamma1)) orSISIDXREG(SISSR, 0x07, 0x04); else andSISIDXREG(SISSR, 0x07, ~0x04); @@ -1917,18 +1765,34 @@ SISLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, } } - 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; - } + 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)) { +#endif + + 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 } @@ -1937,110 +1801,88 @@ SiS301LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual) { SISPtr pSiS = SISPTR(pScrn); - int i, index; + int i, j, index; + Bool dogamma2 = pSiS->CRT2gamma; +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; + + if(pSiS->DualHeadMode) dogamma2 = pSiSEnt->CRT2gamma; +#endif PDEBUG(ErrorF("SiS301LoadPalette(%d)\n", numColors)); - for(i=0; i<numColors; i++) { + /* 301B-DH does not support a color palette for LCD */ + if((pSiS->VBFlags & VB_30xBDH) && (pSiS->VBFlags & CRT2_LCD)) return; + + switch(pSiS->CurrentLayout.depth) { +#ifdef SISGAMMA + case 15: + if(dogamma2) { + orSISIDXREG(SISPART4, 0x0d, 0x08); + for(i=0; i<numColors; i++) { + index = indices[i]; + if(index < 32) { /* Paranoia */ + for(j=0; j<8; j++) { + outSISREG(SISCOL2IDX, (index * 8) + j); + outSISREG(SISCOL2DATA, colors[index].red << (8- pScrn->rgbBits)); + outSISREG(SISCOL2DATA, colors[index].green << (8 - pScrn->rgbBits)); + outSISREG(SISCOL2DATA, colors[index].blue << (8 - pScrn->rgbBits)); + } + } + } + } else { + andSISIDXREG(SISPART4, 0x0d, ~0x08); + } + break; + case 16: + if(dogamma2) { + orSISIDXREG(SISPART4, 0x0d, 0x08); + for(i=0; i<numColors; i++) { + index = indices[i]; + if(index < 64) { /* Paranoia */ + for(j=0; j<4; j++) { + outSISREG(SISCOL2IDX, (index * 4) + j); + outSISREG(SISCOL2DATA, colors[index/2].red << (8 - pScrn->rgbBits)); + outSISREG(SISCOL2DATA, colors[index].green << (8 - pScrn->rgbBits)); + outSISREG(SISCOL2DATA, colors[index/2].blue << (8 - pScrn->rgbBits)); + } + } + } + } else { + andSISIDXREG(SISPART4, 0x0d, ~0x08); + } + break; + case 24: + if(dogamma2) { + orSISIDXREG(SISPART4, 0x0d, 0x08); + for(i=0; i<numColors; i++) { + index = indices[i]; + if(index < 256) { /* Paranoia */ + outSISREG(SISCOL2IDX, index); + outSISREG(SISCOL2DATA, colors[index].red); + outSISREG(SISCOL2DATA, colors[index].green); + outSISREG(SISCOL2DATA, colors[index].blue); + } + } + } else { + andSISIDXREG(SISPART4, 0x0d, ~0x08); + } + break; +#endif + default: + if((pScrn->rgbBits == 8) && (dogamma2)) + orSISIDXREG(SISPART4, 0x0d, 0x08); + else + andSISIDXREG(SISPART4, 0x0d, ~0x08); + for(i=0; i<numColors; i++) { index = indices[i]; outSISREG(SISCOL2IDX, index); outSISREG(SISCOL2DATA, colors[index].red); outSISREG(SISCOL2DATA, colors[index].green); outSISREG(SISCOL2DATA, colors[index].blue); - } -} - - -#ifdef DEBUG -/* TW: Debug function to dump registers */ -void SiSIODump(ScrnInfoPtr pScrn) -{ - SISPtr pSiS = SISPTR(pScrn); - int i, max3c4, min3d4, max3d4; - unsigned char temp; - - switch (pSiS->Chipset) { - case PCI_CHIP_SIS6326: - max3c4 = 0x3F; - max3d4 = 0x19; - min3d4 = 0x26; - break; - case PCI_CHIP_SIS530: - max3c4 = 0x3F; - max3d4 = 0x19; - min3d4 = 0x26; - break; - case PCI_CHIP_SIS300: - case PCI_CHIP_SIS630: - case PCI_CHIP_SIS540: - max3c4 = 0x3D; - max3d4 = 0x37; - min3d4 = 0x30; - break; - case PCI_CHIP_SIS550: - case PCI_CHIP_SIS650: - case PCI_CHIP_SIS315: - case PCI_CHIP_SIS315H: - case PCI_CHIP_SIS315PRO: - case PCI_CHIP_SIS330: - max3c4 = 0x3D; - max3d4 = 0x5f; - min3d4 = 0x30; - break; - default: - max3c4 = 0x38; - max3d4 = 0x19; - min3d4 = 0x26; - } - /* dump Misc Registers */ - temp = inb(pSiS->RelIO+0x4c); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Misc Output 3CC=%x\n", temp); - - temp = inb(pSiS->RelIO+0x4a); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Feature Control 3CA=%x\n", temp); - - /* Dump GR */ - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "-------------\n"); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Registers 3CE\n"); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "-------------\n"); - for (i=0; i<=8; i++) { - inSISIDXREG(SISGR, i, temp); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); - } - - /* dump SR0 ~ SR4 */ - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "-------------\n"); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Registers 3C4\n"); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "-------------\n"); - for (i=0; i<=4; i++) { - inSISIDXREG(SISSR, i, temp); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); - } - - /* dump extended SR */ -#ifdef UNLOCK_ALWAYS - sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); -#endif - for (i=5; i<=max3c4; i++) { - inSISIDXREG(SISSR, i, temp); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); - } - - /* dump CR0 ~ CR18 */ - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "-------------\n"); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Registers 3D4\n"); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "-------------\n"); - for (i=0; i<=0x18; i++) { - inSISIDXREG(SISCR, i, temp); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); - } - /* dump extended CR */ - for (i=min3d4; i<=max3d4; i++) { - inSISIDXREG(SISCR, i, temp); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); - } + } + } } -#endif void SISDACPreInit(ScrnInfoPtr pScrn) @@ -2054,23 +1896,22 @@ SISDACPreInit(ScrnInfoPtr pScrn) case PCI_CHIP_SIS315H: case PCI_CHIP_SIS315PRO: case PCI_CHIP_SIS330: - pSiS->MaxClock = SiSMemBandWidth(pScrn); - pSiS->SiSSave = SiS310Save; + case PCI_CHIP_SIS660: + pSiS->MaxClock = SiSMemBandWidth(pScrn, FALSE); + pSiS->SiSSave = SiS315Save; pSiS->SiSSave2 = SiS301Save; pSiS->SiSSave3 = SiS301BSave; pSiS->SiSSaveLVDSChrontel = SiSLVDSChrontelSave; - pSiS->SiSRestore = SiS310Restore; + pSiS->SiSRestore = SiS315Restore; pSiS->SiSRestore2 = SiS301Restore; pSiS->SiSRestore3 = SiS301BRestore; pSiS->SiSRestoreLVDSChrontel = SiSLVDSChrontelRestore; pSiS->LoadCRT2Palette = SiS301LoadPalette; - pSiS->SetThreshold = SiSThreshold; - pSiS->i2cInit = NULL; /* SiSI2CInit; */ break; case PCI_CHIP_SIS300: case PCI_CHIP_SIS630: case PCI_CHIP_SIS540: - pSiS->MaxClock = SiSMemBandWidth(pScrn); + pSiS->MaxClock = SiSMemBandWidth(pScrn, FALSE); pSiS->SiSSave = SiS300Save; pSiS->SiSSave2 = SiS301Save; pSiS->SiSSave3 = SiS301BSave; @@ -2080,18 +1921,14 @@ SISDACPreInit(ScrnInfoPtr pScrn) pSiS->SiSRestore3 = SiS301BRestore; pSiS->SiSRestoreLVDSChrontel = SiSLVDSChrontelRestore; pSiS->LoadCRT2Palette = SiS301LoadPalette; - pSiS->SetThreshold = SiSThreshold; - pSiS->i2cInit = NULL; /* SiSI2CInit; */ break; case PCI_CHIP_SIS5597: case PCI_CHIP_SIS6326: case PCI_CHIP_SIS530: default: - pSiS->MaxClock = SiSMemBandWidth(pScrn); + pSiS->MaxClock = SiSMemBandWidth(pScrn, FALSE); pSiS->SiSRestore = SiSRestore; pSiS->SiSSave = SiSSave; - pSiS->SetThreshold = SiSThreshold; - pSiS->i2cInit = NULL; break; } } @@ -2101,8 +1938,8 @@ SetBlock(CARD16 port, CARD8 from, CARD8 to, CARD8 *DataPtr) { CARD8 index; - for (index=from; index <= to; index++, DataPtr++) { - outSISIDXREG(port, index, *DataPtr); + for(index = from; index <= to; index++, DataPtr++) { + outSISIDXREG(port, index, *DataPtr); } } @@ -2120,12 +1957,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 @@ -2139,10 +1976,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 907a990..fec0643 100644 --- a/src/sis_dac.h +++ b/src/sis_dac.h @@ -1,16 +1,46 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.h,v 1.7 2003/01/29 15:42:17 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.h,v 1.15 2003/10/30 18:53:42 twini Exp $ */ +/* + * 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. + * + * 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. + * + * 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. + * + * Authors: Alan Hourihane <alanh@fairlite.demon.co.uk> + * Mike Chapman <mike@paranoia.com>, + * Juanjo Santamarta <santamarta@ctv.es>, + * Mitani Hiroshi <hmitani@drl.mei.co.jp> + * David Thomas <davtom@dream.org.uk>. + * Thomas Winischhofer <thomas@winischhofer.net> + */ -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); +int SiSMemBandWidth(ScrnInfoPtr pScrn, BOOLEAN IsForCRT2); int SiSMclk(SISPtr pSiS); void SiSRestoreBridge(ScrnInfoPtr pScrn, SISRegPtr sisReg); @@ -21,11 +51,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); @@ -34,18 +64,16 @@ 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_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime); -extern USHORT SiS_HandleDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, - USHORT DDCdatatype, unsigned char *buffer); -extern void SiS_WhatIsThis(SiS_Private *SiS_Pr, USHORT myvbinfo); +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); extern void SiS_DisplayOn(SiS_Private *SiS_Pr); extern unsigned char SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id); -#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 +extern void SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable); +extern void SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable); + + diff --git a/src/sis_dga.c b/src/sis_dga.c index d455679..549ffbe 100644 --- a/src/sis_dga.c +++ b/src/sis_dga.c @@ -1,7 +1,9 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dga.c,v 1.5 2003/01/29 15:42:17 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dga.c,v 1.11 2003/10/30 18:53:42 twini Exp $ */ /* + * SiS DGA handling + * * Copyright 2000 by Alan Hourihane, Sychdyn, North Wales, UK. - * Copyright 2002 by Thomas Winischhofer, Vienna, Austria + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria * * Portions from radeon_dga.c which is * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and @@ -99,7 +101,7 @@ SISSetupDGAMode( pMode = firstMode = pScrn->modes; - while (pMode) { + while(pMode) { otherPitch = secondPitch ? secondPitch : pMode->HDisplay; @@ -138,9 +140,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; @@ -188,8 +190,8 @@ SECOND_PASS: } pMode = pMode->next; - if (pMode == firstMode) - break; + if(pMode == firstMode) + break; } return modes; @@ -205,17 +207,23 @@ SISDGAInit(ScreenPtr pScreen) int num = 0; /* 8 */ -#ifdef SISDUALHEAD - /* TW: 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 @@ -228,21 +236,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 5eb43f5..97be829 100644 --- a/src/sis_dri.c +++ b/src/sis_dri.c @@ -1,10 +1,12 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c,v 1.25 2003/01/29 15:42:17 eich Exp $ */ - +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c,v 1.39 2003/11/20 19:53:23 twini Exp $ */ /* - * DRI wrapper for 300, 540, 630, 730 - * (310/325 series experimental and incomplete) + * DRI wrapper for 300 and 315 series + * + * Preliminary 315/330 support by Thomas Winischhofer + * Mesa 4/5 changes by Eric Anholt + * + * Taken and modified from tdfx_dri.c, mga_dri.c * - * taken and modified from tdfx_dri.c, mga_dri.c */ #include "xf86.h" @@ -19,26 +21,27 @@ #include "GL/glxtokens.h" #include "sis.h" -#include "sis_dri.h" #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,2,99,0,0) #include "xf86drmCompat.h" #endif -/* TW: Idle function for 300 series */ +#ifdef SISNEWDRI +#include "sis_common.h" +#endif + +/* Idle function for 300 series */ #define BR(x) (0x8200 | (x) << 2) #define SiSIdle \ while((MMIO_IN16(pSiS->IOBase, BR(16)+2) & 0xE000) != 0xE000){}; \ while((MMIO_IN16(pSiS->IOBase, BR(16)+2) & 0xE000) != 0xE000){}; \ MMIO_IN16(pSiS->IOBase, 0x8240); -/* TW: Idle function for 310/325 series */ +/* Idle function for 315/330 series */ #define Q_STATUS 0x85CC -#define SiS310Idle \ +#define SiS315Idle \ { \ while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000){}; \ while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000){}; \ - while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000){}; \ - MMIO_IN16(pSiS->IOBase, Q_STATUS); \ } @@ -48,12 +51,6 @@ extern void GlxSetVisualConfigs( void **configprivs ); -#define AGP_PAGE_SIZE 4096 -#define AGP_PAGES 2048 -#define AGP_SIZE (AGP_PAGE_SIZE * AGP_PAGES) -#define AGP_CMDBUF_PAGES 256 -#define AGP_CMDBUF_SIZE (AGP_PAGE_SIZE * AGP_CMDBUF_PAGES) - static char SISKernelDriverName[] = "sis"; static char SISClientDriverName[] = "sis"; @@ -87,9 +84,9 @@ SISInitVisualConfigs(ScreenPtr pScreen) SISConfigPrivPtr *pSISConfigPtrs = 0; int i, db, z_stencil, accum; Bool useZ16 = FALSE; - - if(getenv("SIS_FORCE_Z16")){ - useZ16 = TRUE; + + if(getenv("SIS_FORCE_Z16")) { + useZ16 = TRUE; } switch (pScrn->bitsPerPixel) { @@ -98,30 +95,29 @@ SISInitVisualConfigs(ScreenPtr pScreen) break; case 16: case 32: - numConfigs = (useZ16)?8:16; + numConfigs = (useZ16) ? 8 : 16; - if (!(pConfigs = (__GLXvisualConfig*)xcalloc(sizeof(__GLXvisualConfig), + if(!(pConfigs = (__GLXvisualConfig*)xcalloc(sizeof(__GLXvisualConfig), numConfigs))) { - return FALSE; + return FALSE; } - if (!(pSISConfigs = (SISConfigPrivPtr)xcalloc(sizeof(SISConfigPrivRec), + if(!(pSISConfigs = (SISConfigPrivPtr)xcalloc(sizeof(SISConfigPrivRec), numConfigs))) { - xfree(pConfigs); - return FALSE; + xfree(pConfigs); + return FALSE; } - if (!(pSISConfigPtrs = (SISConfigPrivPtr*)xcalloc(sizeof(SISConfigPrivPtr), + if(!(pSISConfigPtrs = (SISConfigPrivPtr*)xcalloc(sizeof(SISConfigPrivPtr), numConfigs))) { - xfree(pConfigs); - xfree(pSISConfigs); - return FALSE; + xfree(pConfigs); + xfree(pSISConfigs); + return FALSE; } - for (i=0; i<numConfigs; i++) - pSISConfigPtrs[i] = &pSISConfigs[i]; + for(i=0; i<numConfigs; i++) pSISConfigPtrs[i] = &pSISConfigs[i]; i = 0; - for (accum = 0; accum <= 1; accum++) { - for (z_stencil=0; z_stencil<(useZ16?2:4); z_stencil++) { - for (db = 0; db <= 1; db++) { + for(accum = 0; accum <= 1; accum++) { + for(z_stencil=0; z_stencil<(useZ16?2:4); z_stencil++) { + for(db = 0; db <= 1; db++) { pConfigs[i].vid = -1; pConfigs[i].class = -1; pConfigs[i].rgba = TRUE; @@ -132,7 +128,7 @@ SISInitVisualConfigs(ScreenPtr pScreen) pConfigs[i].greenMask = -1; pConfigs[i].blueMask = -1; pConfigs[i].alphaMask = 0; - if (accum) { + if(accum) { pConfigs[i].accumRedSize = 16; pConfigs[i].accumGreenSize = 16; pConfigs[i].accumBlueSize = 16; @@ -143,13 +139,11 @@ SISInitVisualConfigs(ScreenPtr pScreen) pConfigs[i].accumBlueSize = 0; pConfigs[i].accumAlphaSize = 0; } - if (db) - pConfigs[i].doubleBuffer = TRUE; - else - pConfigs[i].doubleBuffer = FALSE; + if(db) pConfigs[i].doubleBuffer = TRUE; + else pConfigs[i].doubleBuffer = FALSE; pConfigs[i].stereo = FALSE; pConfigs[i].bufferSize = -1; - switch (z_stencil){ + switch(z_stencil) { case 0: pConfigs[i].depthSize = 0; pConfigs[i].stencilSize = 0; @@ -180,10 +174,10 @@ SISInitVisualConfigs(ScreenPtr pScreen) } } } - if (i != numConfigs) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "[dri] Incorrect initialization of visuals. Disabling DRI.\n"); - return FALSE; + if(i != numConfigs) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "[dri] Incorrect initialization of visuals. Disabling DRI.\n"); + return FALSE; } break; } @@ -202,18 +196,24 @@ Bool SISDRIScreenInit(ScreenPtr pScreen) SISPtr pSIS = SISPTR(pScrn); DRIInfoPtr pDRIInfo; SISDRIPtr pSISDRI; -#if 000 +#ifdef SISNEWDRI drmVersionPtr version; #endif + pSIS->cmdQueueLenPtrBackup = NULL; +#ifdef SIS315DRI + 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")) { + * 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"); + "[dri] SISDRIScreenInit failed (libdri.a too old)\n"); return FALSE; } @@ -221,11 +221,11 @@ Bool SISDRIScreenInit(ScreenPtr pScreen) { int major, minor, patch; DRIQueryVersion(&major, &minor, &patch); - if (major != 4 || minor < 0) { + if(major != 4 || minor < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] SISDRIScreenInit failed because of a version mismatch.\n" - "[dri] libDRI version is %d.%d.%d but version 4.0.x is needed.\n" - "[dri] Disabling DRI.\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; } @@ -237,15 +237,33 @@ Bool SISDRIScreenInit(ScreenPtr pScreen) pDRIInfo->drmDriverName = SISKernelDriverName; pDRIInfo->clientDriverName = SISClientDriverName; - 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(xf86LoaderCheckSymbol("DRICreatePCIBusID")) { + pDRIInfo->busIdString = DRICreatePCIBusID(pSiS->PciInfo); + } else { +#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 + } +#endif + + /* Hack to keep old DRI working -- checked for major==1 and + * minor==1. + */ +#ifdef SISNEWDRI + pDRIInfo->ddxDriverMajorVersion = SIS_MAJOR_VERSION; + pDRIInfo->ddxDriverMinorVersion = SIS_MINOR_VERSION; + pDRIInfo->ddxDriverPatchVersion = SIS_PATCHLEVEL; +#else pDRIInfo->ddxDriverMajorVersion = 0; pDRIInfo->ddxDriverMinorVersion = 1; pDRIInfo->ddxDriverPatchVersion = 0; - +#endif + pDRIInfo->frameBufferPhysicalAddress = pSIS->FbAddress; /* TW: This was FbMapSize which is wrong as we must not @@ -263,10 +281,10 @@ Bool SISDRIScreenInit(ScreenPtr pScreen) pDRIInfo->ddxDrawableTableEntry = SIS_MAX_DRAWABLES; - if (SAREA_MAX_DRAWABLES < SIS_MAX_DRAWABLES) - pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES; + if(SAREA_MAX_DRAWABLES < SIS_MAX_DRAWABLES) + pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES; else - pDRIInfo->maxDrawableTableEntry = SIS_MAX_DRAWABLES; + pDRIInfo->maxDrawableTableEntry = SIS_MAX_DRAWABLES; #ifdef NOT_DONE /* FIXME need to extend DRI protocol to pass this size back to client @@ -280,18 +298,18 @@ Bool SISDRIScreenInit(ScreenPtr pScreen) /* For now the mapping works by using a fixed size defined * in the SAREA header */ - if (sizeof(XF86DRISAREARec)+sizeof(SISSAREAPriv) > SAREA_MAX) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Data does not fit in SAREA\n"); - return FALSE; + if(sizeof(XF86DRISAREARec)+sizeof(SISSAREAPriv) > SAREA_MAX) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Data does not fit in SAREA\n"); + return FALSE; } pDRIInfo->SAREASize = SAREA_MAX; #endif - if (!(pSISDRI = (SISDRIPtr)xcalloc(sizeof(SISDRIRec),1))) { - DRIDestroyInfoRec(pSIS->pDRIInfo); - pSIS->pDRIInfo=0; - return FALSE; + if(!(pSISDRI = (SISDRIPtr)xcalloc(sizeof(SISDRIRec),1))) { + DRIDestroyInfoRec(pSIS->pDRIInfo); + pSIS->pDRIInfo = 0; + return FALSE; } pDRIInfo->devPrivate = pSISDRI; pDRIInfo->devPrivateSize = sizeof(SISDRIRec); @@ -304,110 +322,179 @@ Bool SISDRIScreenInit(ScreenPtr pScreen) pDRIInfo->MoveBuffers = SISDRIMoveBuffers; pDRIInfo->bufferRequests = DRI_ALL_WINDOWS; - if (!DRIScreenInit(pScreen, pDRIInfo, &pSIS->drmSubFD)) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[dri] DRIScreenInit failed. Disabling DRI.\n"); - xfree(pDRIInfo->devPrivate); - pDRIInfo->devPrivate=0; - DRIDestroyInfoRec(pSIS->pDRIInfo); - pSIS->pDRIInfo=0; - pSIS->drmSubFD = -1; - return FALSE; + if(!DRIScreenInit(pScreen, pDRIInfo, &pSIS->drmSubFD)) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[dri] DRIScreenInit failed. Disabling DRI.\n"); + xfree(pDRIInfo->devPrivate); + pDRIInfo->devPrivate = 0; + DRIDestroyInfoRec(pSIS->pDRIInfo); + pSIS->pDRIInfo = 0; + pSIS->drmSubFD = -1; + return FALSE; } -#if 000 - /* XXX Check DRM kernel version here */ - version = drmGetVersion(info->drmFD); - if (version) { - if (version->version_major != 1 || - version->version_minor < 0) { +#ifdef SISNEWDRI + /* 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, "[dri] SISDRIScreenInit failed because of a version mismatch.\n" - "[dri] sis.o kernel module version is %d.%d.%d but version 1.0.x is needed.\n" - "[dri] Disabling the DRI.\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); - R128DRICloseScreen(pScreen); + 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); } #endif pSISDRI->regs.size = SISIOMAPSIZE; pSISDRI->regs.map = 0; - if (drmAddMap(pSIS->drmSubFD, (drmHandle)pSIS->IOAddress, - pSISDRI->regs.size, DRM_REGISTERS, 0, - &pSISDRI->regs.handle)<0) - { - SISDRICloseScreen(pScreen); - return FALSE; + if(drmAddMap(pSIS->drmSubFD, (drmHandle)pSIS->IOAddress, + pSISDRI->regs.size, DRM_REGISTERS, 0, + &pSISDRI->regs.handle) < 0) { + SISDRICloseScreen(pScreen); + return FALSE; } xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Registers = 0x%08lx\n", pSISDRI->regs.handle); /* AGP */ - do{ + do { + pSIS->agpWantedSize = pSIS->agpWantedPages * AGP_PAGE_SIZE; pSIS->agpSize = 0; pSIS->agpCmdBufSize = 0; pSISDRI->AGPCmdBufSize = 0; - - if (drmAgpAcquire(pSIS->drmSubFD) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpAcquire failed\n"); - break; + + if(!pSIS->IsAGPCard) + break; + + if(drmAgpAcquire(pSIS->drmSubFD) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] Failed to acquire AGP, AGP disabled\n"); + break; } - - /* TODO: default value is 2x? */ - if (drmAgpEnable(pSIS->drmSubFD, drmAgpGetMode(pSIS->drmSubFD)&~0x0) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpEnable failed\n"); - break; + + if(pSIS->VGAEngine == SIS_315_VGA) { +#ifdef SIS315DRI + /* Default to 1X agp mode in SIS315 */ + if(drmAgpEnable(pSIS->drmSubFD, drmAgpGetMode(pSIS->drmSubFD) & ~0x00000002) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] Failed to enable AGP, AGP disabled\n"); + break; + } +#endif + } else { + /* TODO: default value is 2x? */ + if(drmAgpEnable(pSIS->drmSubFD, drmAgpGetMode(pSIS->drmSubFD) & ~0x0) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] Failed to enable AGP, AGP disabled\n"); + break; + } } - xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] drmAgpEnabled succeeded\n"); - if (drmAgpAlloc(pSIS->drmSubFD, AGP_SIZE, 0, NULL, &pSIS->agpHandle) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] drmAgpAlloc failed\n"); - drmAgpRelease(pSIS->drmSubFD); - break; + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] AGP enabled\n"); + +#define AGP_DEFAULT_SIZE_MB 8 +#define AGP_DEFAULT_SIZE (AGP_DEFAULT_SIZE_MB * 1024 * 1024) + + if(drmAgpAlloc(pSIS->drmSubFD, pSIS->agpWantedSize, 0, NULL, &pSIS->agpHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] Failed to allocate %dMB AGP memory\n", + (int)(pSIS->agpWantedSize / (1024 * 1024))); + if(pSIS->agpWantedSize > AGP_DEFAULT_SIZE) { + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Retrying with %dMB\n", AGP_DEFAULT_SIZE_MB); + pSIS->agpWantedSize = AGP_DEFAULT_SIZE; + if(drmAgpAlloc(pSIS->drmSubFD, pSIS->agpWantedSize, 0, NULL, &pSIS->agpHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] Failed to allocate %dMB AGP memory, AGP disabled\n", + AGP_DEFAULT_SIZE_MB); + drmAgpRelease(pSIS->drmSubFD); + break; + } + } else { + drmAgpRelease(pSIS->drmSubFD); + break; + } } - - if (drmAgpBind(pSIS->drmSubFD, pSIS->agpHandle, 0) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] drmAgpBind failed\n"); - drmAgpFree(pSIS->drmSubFD, pSIS->agpHandle); - drmAgpRelease(pSIS->drmSubFD); - break; + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Allocated %dMB AGP memory\n", + (int)(pSIS->agpWantedSize / (1024 * 1024))); + + if(drmAgpBind(pSIS->drmSubFD, pSIS->agpHandle, 0) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] Failed to bind AGP memory\n"); + drmAgpFree(pSIS->drmSubFD, pSIS->agpHandle); + if(pSIS->agpWantedSize > AGP_DEFAULT_SIZE) { + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Retrying with %dMB\n", AGP_DEFAULT_SIZE_MB); + pSIS->agpWantedSize = AGP_DEFAULT_SIZE; + if(drmAgpAlloc(pSIS->drmSubFD, pSIS->agpWantedSize, 0, NULL, &pSIS->agpHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] Failed to re-allocate AGP memory, AGP disabled\n"); + drmAgpRelease(pSIS->drmSubFD); + break; + } else if(drmAgpBind(pSIS->drmSubFD, pSIS->agpHandle, 0) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] Failed to bind AGP memory again, AGP disabled\n"); + drmAgpFree(pSIS->drmSubFD, pSIS->agpHandle); + drmAgpRelease(pSIS->drmSubFD); + break; + } + } else { + drmAgpRelease(pSIS->drmSubFD); + break; + } } - pSIS->agpSize = AGP_SIZE; + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Bound %dMB AGP memory\n", + (int)(pSIS->agpWantedSize / (1024 * 1024))); + + pSIS->agpSize = pSIS->agpWantedSize; pSIS->agpAddr = drmAgpBase(pSIS->drmSubFD); /* pSIS->agpBase = */ pSISDRI->agp.size = pSIS->agpSize; - if (drmAddMap(pSIS->drmSubFD, (drmHandle)0, - pSISDRI->agp.size, DRM_AGP, 0, - &pSISDRI->agp.handle) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] Failed to map public agp area\n"); - pSISDRI->agp.size = 0; - break; - } - - pSIS->agpCmdBufSize = AGP_CMDBUF_SIZE; - pSIS->agpCmdBufAddr = pSIS->agpAddr; - pSIS->agpCmdBufBase = pSIS->agpCmdBufAddr - pSIS->agpAddr + - pSIS->agpBase; - pSIS->agpCmdBufFree = 0; + if(drmAddMap(pSIS->drmSubFD, (drmHandle)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; + } + + if(pSIS->VGAEngine == SIS_315_VGA) { +#ifdef SIS315DRI + pSIS->agpVtxBufSize = AGP_VTXBUF_SIZE; /* = 2MB */ + pSIS->agpVtxBufAddr = pSIS->agpAddr; + pSIS->agpVtxBufBase = pSIS->agpVtxBufAddr - pSIS->agpAddr + pSIS->agpBase; + pSIS->agpVtxBufFree = 0; + + pSISDRI->AGPVtxBufOffset = pSIS->agpVtxBufAddr - pSIS->agpAddr; + pSISDRI->AGPVtxBufSize = pSIS->agpVtxBufSize; + + drmSiSAgpInit(pSIS->drmSubFD, AGP_VTXBUF_SIZE,(pSIS->agpSize - AGP_VTXBUF_SIZE)); +#endif + } else { + + pSIS->agpCmdBufSize = AGP_CMDBUF_SIZE; + pSIS->agpCmdBufAddr = pSIS->agpAddr; + pSIS->agpCmdBufBase = pSIS->agpCmdBufAddr - pSIS->agpAddr + pSIS->agpBase; + pSIS->agpCmdBufFree = 0; - pSISDRI->AGPCmdBufOffset = pSIS->agpCmdBufAddr - pSIS->agpAddr; - pSISDRI->AGPCmdBufSize = pSIS->agpCmdBufSize; + pSISDRI->AGPCmdBufOffset = pSIS->agpCmdBufAddr - pSIS->agpAddr; + pSISDRI->AGPCmdBufSize = pSIS->agpCmdBufSize; - drmSiSAgpInit(pSIS->drmSubFD, AGP_CMDBUF_SIZE,(AGP_SIZE - AGP_CMDBUF_SIZE)); + drmSiSAgpInit(pSIS->drmSubFD, AGP_CMDBUF_SIZE,(pSIS->agpSize - AGP_CMDBUF_SIZE)); + } } while(0); @@ -417,25 +504,23 @@ Bool SISDRIScreenInit(ScreenPtr pScreen) ((pciConfigPtr)pSIS->PciInfo->thisCard)->devnum, ((pciConfigPtr)pSIS->PciInfo->thisCard)->funcnum); - if((drmCtlInstHandler(pSIS->drmSubFD, pSIS->irq)) != 0) - { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[drm] failure adding irq %d handler, stereo disabled\n", + if((drmCtlInstHandler(pSIS->drmSubFD, pSIS->irq)) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[drm] Failed to add IRQ %d handler, stereo disabled\n", pSIS->irq); - pSIS->irqEnabled = FALSE; - } - else - { - pSIS->irqEnabled = TRUE; - } + pSIS->irqEnabled = FALSE; + } else { + pSIS->irqEnabled = TRUE; + } pSISDRI->irqEnabled = pSIS->irqEnabled; - if (!(SISInitVisualConfigs(pScreen))) { - SISDRICloseScreen(pScreen); - return FALSE; + if(!(SISInitVisualConfigs(pScreen))) { + SISDRICloseScreen(pScreen); + return FALSE; } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] visual configs initialized.\n" ); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] Visual configs initialized.\n" ); return TRUE; } @@ -446,23 +531,36 @@ SISDRICloseScreen(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; SISPtr pSIS = SISPTR(pScrn); + if(pSIS->VGAEngine == SIS_315_VGA) { +#ifdef SIS315DRI + if(pSIS->cmdQ_SharedWritePortBackup) { + pSIS->cmdQ_SharedWritePort = pSIS->cmdQ_SharedWritePortBackup; + } +#endif + } else { + if(pSIS->cmdQueueLenPtrBackup) { + pSIS->cmdQueueLenPtr = pSIS->cmdQueueLenPtrBackup; + *(pSIS->cmdQueueLenPtr) = 0; + } + } + DRICloseScreen(pScreen); - if (pSIS->pDRIInfo) { - if (pSIS->pDRIInfo->devPrivate) { - xfree(pSIS->pDRIInfo->devPrivate); - pSIS->pDRIInfo->devPrivate=0; - } - DRIDestroyInfoRec(pSIS->pDRIInfo); - pSIS->pDRIInfo=0; + if(pSIS->pDRIInfo) { + if(pSIS->pDRIInfo->devPrivate) { + xfree(pSIS->pDRIInfo->devPrivate); + pSIS->pDRIInfo->devPrivate=0; + } + DRIDestroyInfoRec(pSIS->pDRIInfo); + pSIS->pDRIInfo=0; } - if (pSIS->pVisualConfigs) xfree(pSIS->pVisualConfigs); - if (pSIS->pVisualConfigsPriv) xfree(pSIS->pVisualConfigsPriv); + if(pSIS->pVisualConfigs) xfree(pSIS->pVisualConfigs); + if(pSIS->pVisualConfigsPriv) xfree(pSIS->pVisualConfigsPriv); if(pSIS->agpSize){ - xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Freeing agp memory\n"); + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Freeing AGP memory\n"); drmAgpFree(pSIS->drmSubFD, pSIS->agpHandle); - xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Releasing agp module\n"); + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Releasing AGP module\n"); drmAgpRelease(pSIS->drmSubFD); } } @@ -516,28 +614,32 @@ SISDRIFinishScreenInit(ScreenPtr pScreen) { SISSAREAPriv *saPriv; - saPriv=(SISSAREAPriv*)DRIGetSAREAPrivate(pScreen); + saPriv = (SISSAREAPriv*)DRIGetSAREAPrivate(pScreen); assert(saPriv); saPriv->CtxOwner = -1; - saPriv->QueueLength = 0; + saPriv->QueueLength = *(pSiS->cmdQueueLenPtr); + pSiS->cmdQueueLenPtrBackup = pSiS->cmdQueueLenPtr; pSiS->cmdQueueLenPtr = &(saPriv->QueueLength); - saPriv->AGPCmdBufNext = 0; - /* frame control */ - saPriv->FrameCount = 0; - if (pSiS->VGAEngine == SIS_315_VGA) { /* 310/325 series */ -#if 0 - *(unsigned long *)(pSiS->IOBase+0x8a2c) = 0; /* FIXME: Where is this on the 310 series ? */ + if(pSiS->VGAEngine == SIS_315_VGA) { +#ifdef SIS315DRI + saPriv->AGPVtxBufNext = 0; + saPriv->sharedWPoffset = pSiS->cmdQ_SharedWritePort_2D; + pSiS->cmdQ_SharedWritePortBackup = pSiS->cmdQ_SharedWritePort; + pSiS->cmdQ_SharedWritePort = &(saPriv->sharedWPoffset); #endif - SiS310Idle - } else { /* 300 series (and below) */ + } else { + saPriv->AGPCmdBufNext = 0; + + /* frame control */ + saPriv->FrameCount = 0; *(unsigned long *)(pSiS->IOBase+0x8a2c) = 0; SiSIdle } } - + return DRIFinishScreenInit(pScreen); } @@ -565,14 +667,13 @@ SISDRISwapContext(ScreenPtr pScreen, DRISyncType syncType, * TODO: do this only if X-Server get lock. If kernel supports delayed * signal, needless to do this */ - if (pSiS->VGAEngine == SIS_315_VGA) { -#if 0 - *(pSiS->IOBase + 0x8B50) = 0xff; /* FIXME: Where is this on 310 series */ - *(unsigned int *)(pSiS->IOBase + 0x8B60) = -1; /* FIXME: Where is this on 310 series */ + if(pSiS->VGAEngine == SIS_315_VGA) { +#ifdef SIS315DRI + /* ? */ #endif } else { - *(pSiS->IOBase + 0x8B50) = 0xff; - *(unsigned int *)(pSiS->IOBase + 0x8B60) = -1; + *(pSiS->IOBase + 0x8B50) = 0xff; + *(unsigned int *)(pSiS->IOBase + 0x8B60) = -1; } } @@ -583,10 +684,12 @@ SISDRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; SISPtr pSiS = SISPTR(pScrn); - if (pSiS->VGAEngine == SIS_315_VGA) { - SiS310Idle /* 310/325 series */ + if(pSiS->VGAEngine == SIS_315_VGA) { +#ifdef SIS315DRI + SiS315Idle /* 315 series */ +#endif } else { - SiSIdle /* 300 series */ + SiSIdle /* 300 series */ } } @@ -598,10 +701,12 @@ SISDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; SISPtr pSiS = SISPTR(pScrn); - if (pSiS->VGAEngine == SIS_315_VGA) { - SiS310Idle /* 310/325 series */ + if(pSiS->VGAEngine == SIS_315_VGA) { +#ifdef SIS315DRI + SiS315Idle /* 315 series */ +#endif } else { - SiSIdle /* 300 series and below */ + SiSIdle /* 300 series */ } } diff --git a/src/sis_dri.h b/src/sis_dri.h index 55714d0..90473a4 100644 --- a/src/sis_dri.h +++ b/src/sis_dri.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h,v 1.6 2001/05/16 13:43:17 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h,v 1.10 2003/10/30 18:53:42 twini Exp $ */ /* modified from tdfx_dri.h */ @@ -15,7 +15,20 @@ typedef struct { int QueueLength; unsigned int AGPCmdBufNext; unsigned int FrameCount; -} SISSAREAPriv; +#ifdef SIS315DRI + /* For 315 series */ + unsigned long sharedWPoffset; +#endif +#if 0 + unsigned char *AGPCmdBufBase; + unsigned long AGPCmdBufAddr; + unsigned long AGPCmdBufOffset; + unsigned int AGPCmdBufSize; + unsigned long AGPCmdBufNext; +#endif +} SISSAREAPriv, *SISSAREAPrivPtr; + +#define AGPVtxBufNext AGPCmdBufNext #define SIS_FRONT 0 #define SIS_BACK 1 @@ -32,21 +45,24 @@ typedef struct { int deviceID; int width; int height; - int mem; + int mem; /* unused in Mesa 3 DRI */ int bytesPerPixel; - int priv1; - int priv2; - int fbOffset; - int backOffset; - int depthOffset; - int textureOffset; - int textureSize; + int priv1; /* unused in Mesa 3 DRI */ + int priv2; /* unused in Mesa 3 DRI */ + int fbOffset; /* unused in Mesa 3 DRI */ + int backOffset; /* unused in Mesa 3 DRI */ + int depthOffset; /* unused in Mesa 3 DRI */ + int textureOffset; /* unused in Mesa 3 DRI */ + int textureSize; /* unused in Mesa 3 DRI */ unsigned int AGPCmdBufOffset; unsigned int AGPCmdBufSize; - int irqEnabled; - unsigned int scrnX, scrnY; + int irqEnabled; /* unused in Mesa 3 DRI */ + unsigned int scrnX, scrnY; /* unused in Mesa 3 DRI */ } SISDRIRec, *SISDRIPtr; +#define AGPVtxBufOffset AGPCmdBufOffset +#define AGPVtxBufSize AGPCmdBufSize + typedef struct { /* Nothing here yet */ int dummy; diff --git a/src/sis_driver.c b/src/sis_driver.c index eb89fe2..833e3c3 100644 --- a/src/sis_driver.c +++ b/src/sis_driver.c @@ -1,7 +1,9 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c,v 1.86 2003/02/04 02:44:29 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c,v 1.156 2003/11/20 19:53:23 twini Exp $ */ /* + * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria. + * + * Formerly based on old code which is * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Parts Copyright 2001, 2002, 2003 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 @@ -21,36 +23,45 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Authors: Alan Hourihane, alanh@fairlite.demon.co.uk + * Author: Thomas Winischhofer <thomas@winischhofer.net> + * - driver entirely rewritten, only basic structure taken from old code + * (except sis_dri.c, sis_shadow.c and parts of sis_dga.c; + * these were taken over; sis_dri.c was slightly adapted): + * - rewritten for 5597/5598, 6326 and 530/620 chipsets, + * - rewritten for 300 series (300/540/630/730), + * - 315 series (315/550/650/651/M650/661FX/M661FX/M661MX/740/741) support + * - 330 series (330/760) support + * - dual head support for 300, 315 and 330 series + * - merged-framebuffer support for 300, 315 and 330 series + * - pseudo-xinerama extension for MergedFB mode + * - SiS video bridge support for 300, 315 and 330 series (LCD, TV, VGA2), + * - LVDS support for 300 and 315 series, + * - Chrontel 7019/LVDS support (650, 740; up to 1600x1200) + * - Chrontel 700x, 701x support for TV output + * - VESA mode switching (deprecated), + * - plasma panel support, + * - entirely rewritten Xv support for 300 series + * - Xv support for 5597/5598, 6326, 530/620, 315 and 330 series + * - TV and hi-res support for the 6326 + * - color HW cursor support for 300(emulated), 315 and 330 series + * - SiSCtrl interface for 300, 315 and 330 series + * - etc. etc. etc. + * + * This notice covers the entire driver code + * + * Authors of old code: + * Alan Hourihane, alanh@fairlite.demon.co.uk * Mike Chapman <mike@paranoia.com>, * Juanjo Santamarta <santamarta@ctv.es>, * Mitani Hiroshi <hmitani@drl.mei.co.jp> * David Thomas <davtom@dream.org.uk>. - * - * Thomas Winischhofer <thomas@winischhofer.net>: - * - 310/325 series (315/550/650/651/740/M650) support - * - (possibly incomplete) Xabre (SiS330) support - * - new mode switching code for 300, 310/325 and 330 series - * - many fixes for 300/540/630/730 chipsets, - * - many fixes for 5597/5598, 6326 and 530/620 chipsets, - * - VESA mode switching (deprecated), - * - extended CRT2/video bridge handling support, - * - dual head support on 300, 310/325 and 330 series - * - 650/LVDS (up to 1400x1050), 650/Chrontel 701x support - * - 30xB/30xLV/30xLVX video bridge support (300, 310/325, 330 series) - * - Xv support for 5597/5598, 6326, 530/620 and 310/325 series - * - video overlay enhancements for 300 series - * - TV and hi-res support for the 6326 - * - Color HW cursor support for 300(emulated), 310/325 and 330 series - * - etc. */ #include "fb.h" -#include "xf1bpp.h" -#include "xf4bpp.h" #include "mibank.h" #include "micmap.h" #include "xf86.h" +#include "xf86Priv.h" #include "xf86_OSproc.h" #include "xf86Resources.h" #include "xf86_ansic.h" @@ -68,7 +79,7 @@ #include "mipointer.h" #include "mibstore.h" - + #include "sis.h" #include "sis_regs.h" #include "sis_vb.h" @@ -80,10 +91,11 @@ #include "extensions/xf86dgastr.h" #include "globals.h" + #define DPMS_SERVER #include "extensions/dpms.h" -#ifdef XvExtension +#if (XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,99,0,0)) || (defined(XvExtension)) #include "xf86xv.h" #include "Xv.h" #endif @@ -92,82 +104,29 @@ #include "dri.h" #endif -/* 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 int SISValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, - int flags); - -/* Internally used functions */ -static Bool SISMapMem(ScrnInfoPtr pScrn); -static Bool SISUnmapMem(ScrnInfoPtr pScrn); -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); -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); - -BOOLEAN SiSBridgeIsInSlaveMode(ScrnInfoPtr pScrn); -#ifdef CYCLECRT2 -Bool SISCycleCRT2Type(int scrnIndex, DisplayModePtr mode); -#endif +/* Globals (yes, these ARE really required to be global) */ -#ifdef DEBUG -static void SiSDumpModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode); -#endif - -/* TW: New mode switching functions */ -extern BOOLEAN SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom); -extern BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch); -extern USHORT SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode); -extern USHORT SiS_CheckCalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags); -extern void SiSRegInit(SiS_Private *SiS_Pr, USHORT BaseAddr); -extern DisplayModePtr SiSBuildBuiltInModeList(ScrnInfoPtr pScrn); #ifdef SISDUALHEAD -extern BOOLEAN SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom); -extern BOOLEAN SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, - ScrnInfoPtr pScrn, DisplayModePtr mode); +static int SISEntityIndex = -1; #endif -/* TW: For power management for 310/325 series */ -extern void SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr); -extern void SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr); -extern void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); -extern void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension); +#ifdef SISMERGED +#ifdef SISXINERAMA +static Bool SiSnoPanoramiXExtension = TRUE; +int SiSXineramaPixWidth = 0; +int SiSXineramaPixHeight = 0; +int SiSXineramaNumScreens = 0; +SiSXineramaData *SiSXineramadataPtr = NULL; +static int SiSXineramaGeneration; -#ifdef SISDUALHEAD -static int SISEntityIndex = -1; +int SiSProcXineramaQueryVersion(ClientPtr client); +int SiSProcXineramaGetState(ClientPtr client); +int SiSProcXineramaGetScreenCount(ClientPtr client); +int SiSProcXineramaGetScreenSize(ClientPtr client); +int SiSProcXineramaIsActive(ClientPtr client); +int SiSProcXineramaQueryScreens(ClientPtr client); +int SiSSProcXineramaDispatch(ClientPtr client); +#endif #endif /* @@ -206,9 +165,8 @@ static SymTabRec SISChipsets[] = { { PCI_CHIP_SIS315PRO, "SIS315PRO" }, { PCI_CHIP_SIS550, "SIS550" }, { PCI_CHIP_SIS650, "SIS650/M650/651/740" }, -#ifdef INCL_SIS330 /* TW: New for SiS330 (untested) */ { PCI_CHIP_SIS330, "SIS330(Xabre)" }, -#endif + { PCI_CHIP_SIS660, "SIS660/661FX/M661FX/M661MX/741/760" }, { -1, NULL } }; @@ -224,9 +182,8 @@ static PciChipsets SISPciChipsets[] = { { PCI_CHIP_SIS315H, PCI_CHIP_SIS315H, RES_SHARED_VGA }, { PCI_CHIP_SIS315PRO, PCI_CHIP_SIS315PRO, RES_SHARED_VGA }, { PCI_CHIP_SIS650, PCI_CHIP_SIS650, RES_SHARED_VGA }, -#ifdef INCL_SIS330 /* TW: New for SiS330 */ { PCI_CHIP_SIS330, PCI_CHIP_SIS330, RES_SHARED_VGA }, -#endif + { PCI_CHIP_SIS660, PCI_CHIP_SIS660, RES_SHARED_VGA }, { -1, -1, RES_UNDEFINED } }; @@ -234,7 +191,10 @@ 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 @@ -248,6 +208,7 @@ static const char *vgahwSymbols[] = { "vgaHWInit", "vgaHWLock", "vgaHWMapMem", + "vgaHWUnmapMem", "vgaHWProtect", "vgaHWRestore", "vgaHWSave", @@ -256,12 +217,6 @@ static const char *vgahwSymbols[] = { NULL }; -static const char *miscfbSymbols[] = { - "xf1bppScreenInit", - "xf4bppScreenInit", - NULL -}; - static const char *fbSymbols[] = { "fbPictureInit", "fbScreenInit", @@ -284,16 +239,6 @@ static const char *ddcSymbols[] = { "xf86PrintEDID", "xf86SetDDCproperties", "xf86InterpretEDID", - "xf86DoEDID_DDC1", -#ifdef SISI2C - "xf86DoEDID_DDC2", -#endif - NULL -}; - -static const char *i2cSymbols[] = { - "xf86I2CBusInit", - "xf86CreateI2CBusRec", NULL }; @@ -351,6 +296,9 @@ static const char *driSymbols[] = { "DRIScreenInit", "DRIUnlock", "GlxSetVisualConfigs", +#ifdef SISNEWDRI2 + "DRICreatePCIBusID" +#endif NULL }; #endif @@ -380,20 +328,20 @@ sisSetup(pointer module, pointer opts, int *errmaj, int *errmin) { static Bool setupDone = FALSE; - if (!setupDone) { - setupDone = TRUE; - xf86AddDriver(&SIS, module, 0); - LoaderRefSymLists(vgahwSymbols, fbSymbols, i2cSymbols, xaaSymbols, - miscfbSymbols, shadowSymbols, ramdacSymbols, - vbeSymbols, int10Symbols, + if(!setupDone) { + setupDone = TRUE; + xf86AddDriver(&SIS, module, 0); + LoaderRefSymLists(vgahwSymbols, fbSymbols, xaaSymbols, + shadowSymbols, ramdacSymbols, + vbeSymbols, int10Symbols, #ifdef XF86DRI - drmSymbols, driSymbols, + drmSymbols, driSymbols, #endif - NULL); - return (pointer)TRUE; - } + NULL); + return (pointer)TRUE; + } - if (errmaj) *errmaj = LDR_ONCEONLY; + if(errmaj) *errmaj = LDR_ONCEONLY; return NULL; } @@ -407,8 +355,7 @@ SISGetRec(ScrnInfoPtr pScrn) * pScrn->driverPrivate is initialised to NULL, so we can check if * the allocation has already been done. */ - if (pScrn->driverPrivate != NULL) - return TRUE; + if(pScrn->driverPrivate != NULL) return TRUE; pScrn->driverPrivate = xnfcalloc(sizeof(SISRec), 1); @@ -426,43 +373,93 @@ SISFreeRec(ScrnInfoPtr pScrn) SISEntPtr pSiSEnt = NULL; #endif - /* TW: Just to make sure... */ + /* Just to make sure... */ if(!pSiS) return; +#ifdef SISDUALHEAD pSiSEnt = pSiS->entityPrivate; +#endif if(pSiS->pstate) xfree(pSiS->pstate); pSiS->pstate = NULL; if(pSiS->fonts) xfree(pSiS->fonts); pSiS->fonts = NULL; + #ifdef SISDUALHEAD if(pSiSEnt) { - if(!pSiS->SecondHead) { - /* TW: Free memory only if we are first head; in case of an error - * during init of the second head, the server will continue - - * and we need the BIOS image and SiS_Private for the first - * head. + if(!pSiS->SecondHead) { + /* Free memory only if we are first head; in case of an error + * during init of the second head, the server will continue - + * and we need the BIOS image and SiS_Private for the first + * head. */ if(pSiSEnt->BIOS) xfree(pSiSEnt->BIOS); pSiSEnt->BIOS = pSiS->BIOS = NULL; if(pSiSEnt->SiS_Pr) xfree(pSiSEnt->SiS_Pr); pSiSEnt->SiS_Pr = pSiS->SiS_Pr = NULL; - } else { + if(pSiSEnt->RenderAccelArray) xfree(pSiSEnt->RenderAccelArray); + pSiSEnt->RenderAccelArray = pSiS->RenderAccelArray = NULL; + } else { pSiS->BIOS = NULL; pSiS->SiS_Pr = NULL; - } + pSiS->RenderAccelArray = NULL; + } } else { #endif - if(pSiS->BIOS) xfree(pSiS->BIOS); - pSiS->BIOS = NULL; - if(pSiS->SiS_Pr) xfree(pSiS->SiS_Pr); - pSiS->SiS_Pr = NULL; -#ifdef SISDUALHEAD + if(pSiS->BIOS) xfree(pSiS->BIOS); + pSiS->BIOS = NULL; + if(pSiS->SiS_Pr) xfree(pSiS->SiS_Pr); + pSiS->SiS_Pr = NULL; + if(pSiS->RenderAccelArray) xfree(pSiS->RenderAccelArray); + pSiS->RenderAccelArray = NULL; +#ifdef SISDUALHEAD + } +#endif +#ifdef SISMERGED + if(pSiS->CRT2HSync) xfree(pSiS->CRT2HSync); + pSiS->CRT2HSync = NULL; + if(pSiS->CRT2VRefresh) xfree(pSiS->CRT2VRefresh); + pSiS->CRT2VRefresh = NULL; + if(pSiS->MetaModes) xfree(pSiS->MetaModes); + pSiS->MetaModes = NULL; + if(pSiS->CRT2pScrn) { + if(pSiS->CRT2pScrn->modes) { + while(pSiS->CRT2pScrn->modes) + xf86DeleteMode(&pSiS->CRT2pScrn->modes, pSiS->CRT2pScrn->modes); + } + if(pSiS->CRT2pScrn->monitor) { + if(pSiS->CRT2pScrn->monitor->Modes) { + while(pSiS->CRT2pScrn->monitor->Modes) + xf86DeleteMode(&pSiS->CRT2pScrn->monitor->Modes, pSiS->CRT2pScrn->monitor->Modes); + } + if(pSiS->CRT2pScrn->monitor->DDC) xfree(pSiS->CRT2pScrn->monitor->DDC); + xfree(pSiS->CRT2pScrn->monitor); + } + xfree(pSiS->CRT2pScrn); + pSiS->CRT2pScrn = NULL; + } + if(pSiS->CRT1Modes) { + if(pSiS->CRT1Modes != pScrn->modes) { + if(pScrn->modes) { + pScrn->currentMode = pScrn->modes; + do { + DisplayModePtr p = pScrn->currentMode->next; + if(pScrn->currentMode->Private) + xfree(pScrn->currentMode->Private); + xfree(pScrn->currentMode); + pScrn->currentMode = p; + } while(pScrn->currentMode != pScrn->modes); + } + pScrn->currentMode = pSiS->CRT1CurrentMode; + pScrn->modes = pSiS->CRT1Modes; + pSiS->CRT1CurrentMode = NULL; + pSiS->CRT1Modes = NULL; + } } #endif - if (pSiS->pVbe) vbeFree(pSiS->pVbe); + if(pSiS->pVbe) vbeFree(pSiS->pVbe); pSiS->pVbe = NULL; - if (pScrn->driverPrivate == NULL) + if(pScrn->driverPrivate == NULL) return; xfree(pScrn->driverPrivate); pScrn->driverPrivate = NULL; @@ -472,290 +469,197 @@ static void SISDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags) { SISPtr pSiS = SISPTR(pScrn); - unsigned char extDDC_PCR=0; - unsigned char crtc17, seq1; + BOOLEAN docrt1 = TRUE, docrt2 = TRUE; + unsigned char sr1=0, cr17=0, cr63=0, sr11=0, pmreg=0, sr7=0; + unsigned char p1_13=0, p2_0=0, oldpmreg=0; + BOOLEAN backlight = TRUE; xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "SISDisplayPowerManagementSet(%d)\n",PowerManagementMode); - /* unlock registers */ +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + if(pSiS->SecondHead) docrt2 = FALSE; + else docrt1 = FALSE; + } +#endif + #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - /* Read CR17 */ - inSISIDXREG(SISCR, 0x17, crtc17); - - /* Read SR1 */ - inSISIDXREG(SISSR, 0x01, seq1); - - if(pSiS->VBFlags & CRT2_LCD) { - if(((pSiS->VGAEngine == SIS_300_VGA) && - (!(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)))) || - ((pSiS->VGAEngine == SIS_315_VGA) && - ((pSiS->VBFlags & (VB_LVDS | VB_CHRONTEL)) == VB_LVDS))) { - /* Read Power Control Register (SR11) */ - inSISIDXREG(SISSR, 0x11, extDDC_PCR); - /* if not blanked, obtain state of LCD blank flags set by BIOS */ - if(!pSiS->Blank) { - pSiS->LCDon = extDDC_PCR; - } - /* erase LCD blank flags */ - extDDC_PCR &= ~0x0C; - } + if(docrt2) { + if(pSiS->VBFlags & CRT2_LCD) { + if(((pSiS->VGAEngine == SIS_300_VGA) && + (pSiS->VBFlags & (VB_301|VB_30xBDH|VB_LVDS))) || + ((pSiS->VGAEngine == SIS_315_VGA) && + ((pSiS->VBFlags & (VB_LVDS | VB_CHRONTEL)) == VB_LVDS))) { +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + if(!pSiS->BlankCRT2) inSISIDXREG(SISSR, 0x11, pSiS->LCDon); + } else +#endif + if(!pSiS->Blank) inSISIDXREG(SISSR, 0x11, pSiS->LCDon); + } + } } switch (PowerManagementMode) { case DPMSModeOn: /* HSync: On, VSync: On */ - - pSiS->Blank = FALSE; - seq1 &= ~0x20; - crtc17 |= 0x80; - if(pSiS->VBFlags & CRT2_LCD) { - if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->VBFlags & VB_CHRONTEL) { - SiS_Chrontel701xBLOn(pSiS->SiS_Pr); - } else if(pSiS->VBFlags & VB_LVDS) { - extDDC_PCR |= (pSiS->LCDon & 0x0C); - } else if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - SiS_SiS30xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); - } - } else if(pSiS->VGAEngine == SIS_300_VGA) { - if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - SiS_SiS30xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); - } else { - extDDC_PCR |= (pSiS->LCDon & 0x0C); - } - } - } + if(docrt1) pSiS->Blank = FALSE; +#ifdef SISDUALHEAD + else pSiS->BlankCRT2 = FALSE; +#endif + sr1 = 0x00; + cr17 = 0x80; + pmreg = 0x00; + cr63 = 0x00; + sr7 = 0x10; + sr11 = (pSiS->LCDon & 0x0C); + p2_0 = 0x20; + p1_13 = 0x00; + backlight = TRUE; break; - case DPMSModeStandby: /* HSync: Off, VSync: On */ case DPMSModeSuspend: /* HSync: On, VSync: Off */ + if(docrt1) pSiS->Blank = TRUE; +#ifdef SISDUALHEAD + else pSiS->BlankCRT2 = TRUE; +#endif + sr1 = 0x20; + cr17 = 0x80; + pmreg = 0x80; + cr63 = 0x40; + sr7 = 0x00; + sr11 = 0x08; + p2_0 = 0x40; + p1_13 = 0x80; + backlight = FALSE; + break; - pSiS->Blank = TRUE; - seq1 |= 0x20 ; - if(pSiS->VBFlags & CRT2_LCD) { - if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->VBFlags & VB_CHRONTEL) { - SiS_Chrontel701xBLOff(pSiS->SiS_Pr); - } else if(pSiS->VBFlags & VB_LVDS) { - extDDC_PCR |= 0x08; - } else if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); - } - } else if(pSiS->VGAEngine == SIS_300_VGA) { - if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); - } else { - extDDC_PCR |= 0x08; - } - } - } + case DPMSModeStandby: /* HSync: Off, VSync: On */ + if(docrt1) pSiS->Blank = TRUE; +#ifdef SISDUALHEAD + else pSiS->BlankCRT2 = TRUE; +#endif + sr1 = 0x20; + cr17 = 0x80; + pmreg = 0x40; + cr63 = 0x40; + sr7 = 0x00; + sr11 = 0x08; + p2_0 = 0x80; + p1_13 = 0x40; + backlight = FALSE; break; case DPMSModeOff: /* HSync: Off, VSync: Off */ - - pSiS->Blank = TRUE; - seq1 |= 0x20; - if(pSiS->VGAEngine == SIS_300_VGA || - pSiS->VGAEngine == SIS_315_VGA) { - /* TW: We can't switch off CRT1 if bridge is in slavemode */ - if(pSiS->VBFlags & CRT2_ENABLE) { - if(!(SiSBridgeIsInSlaveMode(pScrn))) crtc17 &= ~0x80; - } else crtc17 &= ~0x80; - } else { - crtc17 &= ~0x80; - } - if(pSiS->VBFlags & CRT2_LCD) { - if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->VBFlags & VB_CHRONTEL) { - SiS_Chrontel701xBLOff(pSiS->SiS_Pr); - } else if(pSiS->VBFlags & VB_LVDS) { - extDDC_PCR |= 0x0C; - } else if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); - } - } else if(pSiS->VGAEngine == SIS_300_VGA) { - if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); - } else { - extDDC_PCR |= 0x0C; - } - } - } + if(docrt1) pSiS->Blank = TRUE; +#ifdef SISDUALHEAD + else pSiS->BlankCRT2 = TRUE; +#endif + sr1 = 0x20; + cr17 = 0x00; + pmreg = 0xc0; + cr63 = 0x40; + sr7 = 0x00; + sr11 = 0x08; + p2_0 = 0xc0; + p1_13 = 0xc0; + backlight = FALSE; break; + default: + return; } - outSISIDXREG(SISSR, 0x01, seq1); /* Set/Clear "Display On" bit */ - - outSISIDXREG(SISCR, 0x17, crtc17); - - if(pSiS->VBFlags & CRT2_LCD) { - if(((pSiS->VGAEngine == SIS_300_VGA) && - (!(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)))) || - ((pSiS->VGAEngine == SIS_315_VGA) && - ((pSiS->VBFlags & (VB_LVDS | VB_CHRONTEL)) == VB_LVDS))) { - outSISIDXREG(SISSR, 0x11, extDDC_PCR); - } + if(docrt2) { + if(pSiS->VGAEngine == SIS_315_VGA) { + if(pSiS->VBFlags & CRT2_LCD) { + if(pSiS->VBFlags & VB_CHRONTEL) { + if(backlight) { + SiS_Chrontel701xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); + } else { + SiS_Chrontel701xBLOff(pSiS->SiS_Pr); + } + } + } + } } - outSISIDXREG(SISSR, 0x00, 0x01); /* Synchronous Reset */ - usleep(10000); - outSISIDXREG(SISSR, 0x00, 0x03); /* End Reset */ - -} - -#ifdef SISDUALHEAD -/* TW: DPMS for dual head mode */ -static void -SISDisplayPowerManagementSetDH(ScrnInfoPtr pScrn, int PowerManagementMode, int flags) -{ - SISPtr pSiS = SISPTR(pScrn); - unsigned char crtc17 = 0; - unsigned char extDDC_PCR=0; - unsigned char seq1 = 0; - - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "SISDisplayPowerManagementSetDH(%d)\n",PowerManagementMode); - - /* unlock registers */ -#ifdef UNLOCK_ALWAYS - sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); -#endif - - if (pSiS->SecondHead) { - - /* TW: Second (slave) head is always CRT1 */ - - /* Read CR17 and SR01 */ - inSISIDXREG(SISCR, 0x17, crtc17); - inSISIDXREG(SISSR, 0x01, seq1); - - switch (PowerManagementMode) - { - case DPMSModeOn: /* HSync: On, VSync: On */ - seq1 &= ~0x20 ; - crtc17 |= 0x80; - pSiS->BlankCRT1 = FALSE; - break; - - case DPMSModeStandby: /* HSync: Off, VSync: On */ - case DPMSModeSuspend: /* HSync: On, VSync: Off */ - seq1 |= 0x20; - pSiS->BlankCRT1 = TRUE; - break; - - case DPMSModeOff: /* HSync: Off, VSync: Off */ - seq1 |= 0x20 ; - pSiS->BlankCRT1 = TRUE; - crtc17 &= ~0x80; - break; - } - outSISIDXREG(SISSR, 0x00, 0x01); /* Synchronous Reset */ - - outSISIDXREG(SISSR, 0x01, seq1); /* Set/Clear "Display On" bit */ - - usleep(10000); - - outSISIDXREG(SISCR, 0x17, crtc17); - - outSISIDXREG(SISSR, 0x00, 0x03); /* End Reset */ - - } else { - - /* TW: Master head is always CRT2 */ - - /* TV can not be managed */ - if(!(pSiS->VBFlags & CRT2_LCD)) return; - - if(((pSiS->VGAEngine == SIS_300_VGA) && - (!(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)))) || - ((pSiS->VGAEngine == SIS_315_VGA) && - ((pSiS->VBFlags & (VB_LVDS | VB_CHRONTEL)) == VB_LVDS))) { - /* Read Power Control Register (SR11) */ - inSISIDXREG(SISSR, 0x11, extDDC_PCR); - /* if not blanked obtain state of LCD blank flags set by BIOS */ - if(!pSiS->BlankCRT2) { - pSiS->LCDon = extDDC_PCR; - } - /* erase LCD blank flags */ - extDDC_PCR &= ~0xC; - } - - switch (PowerManagementMode) { - - case DPMSModeOn: - pSiS->BlankCRT2 = FALSE; - if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->VBFlags & VB_CHRONTEL) { - SiS_Chrontel701xBLOn(pSiS->SiS_Pr); - } else if(pSiS->VBFlags & VB_LVDS) { - extDDC_PCR |= (pSiS->LCDon & 0x0C); - } else if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - SiS_SiS30xBLOn(pSiS->SiS_Pr, &pSiS->sishw_ext); - } - } else if(pSiS->VGAEngine == SIS_300_VGA) { - if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - SiS_SiS30xBLOn(pSiS->SiS_Pr, &pSiS->sishw_ext); - } else { - extDDC_PCR |= (pSiS->LCDon & 0x0C); - } - } - break; + if(pSiS->VBFlags & (VB_301LV|VB_302LV|VB_302ELV)) { + if((docrt2 && (pSiS->VBFlags & CRT2_LCD)) || (docrt1 && (pSiS->VBFlags & CRT1_LCDA))) { + if(backlight) { + SiS_SiS30xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); + } else { + SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); + } + } + } - case DPMSModeStandby: - case DPMSModeSuspend: - pSiS->BlankCRT2 = TRUE; - if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->VBFlags & VB_CHRONTEL) { - SiS_Chrontel701xBLOff(pSiS->SiS_Pr); - } else if(pSiS->VBFlags & VB_LVDS) { - extDDC_PCR |= 0x08; - } else if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - SiS_SiS30xBLOff(pSiS->SiS_Pr, &pSiS->sishw_ext); - } - } else if(pSiS->VGAEngine == SIS_300_VGA) { - if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - SiS_SiS30xBLOff(pSiS->SiS_Pr, &pSiS->sishw_ext); - } else { - extDDC_PCR |= 0x08; - } + if(docrt1) { + setSISIDXREG(SISSR, 0x01, ~0x20, sr1); /* Set/Clear "Display On" bit */ + switch(pSiS->VGAEngine) { + case SIS_OLD_VGA: + case SIS_530_VGA: + inSISIDXREG(SISSR, 0x11, oldpmreg); + setSISIDXREG(SISCR, 0x17, 0x7f, cr17); + setSISIDXREG(SISSR, 0x11, 0x3f, pmreg); + break; + case SIS_315_VGA: + if((!pSiS->CRT1off) && ((!(pSiS->VBFlags & CRT1_LCDA)) || (pSiS->VBFlags & VB_301C))) { + setSISIDXREG(SISCR, 0x63, 0xbf, cr63); + setSISIDXREG(SISSR, 0x07, 0xef, sr7); } - break; - - case DPMSModeOff: - pSiS->BlankCRT2 = TRUE; - if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->VBFlags & VB_CHRONTEL) { - SiS_Chrontel701xBLOff(pSiS->SiS_Pr); - } else if(pSiS->VBFlags & VB_LVDS) { - extDDC_PCR |= 0x0C; - } else if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - SiS_SiS30xBLOff(pSiS->SiS_Pr, &pSiS->sishw_ext); - } - } else if(pSiS->VGAEngine == SIS_300_VGA) { - if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - SiS_SiS30xBLOff(pSiS->SiS_Pr, &pSiS->sishw_ext); - } else { - extDDC_PCR |= 0x0C; - } - } - break; - } + /* fall through */ + default: + if((!(pSiS->VBFlags & CRT1_LCDA)) || (pSiS->VBFlags & VB_301C)) { + inSISIDXREG(SISSR, 0x1f, oldpmreg); + if(!pSiS->CRT1off) { + 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; + } - if(((pSiS->VGAEngine == SIS_300_VGA) && - (!(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)))) || - ((pSiS->VGAEngine == SIS_315_VGA) && - ((pSiS->VBFlags & (VB_LVDS | VB_CHRONTEL)) == VB_LVDS))) { - outSISIDXREG(SISSR, 0x11, extDDC_PCR); - } + if(docrt2) { + if(pSiS->VBFlags & CRT2_LCD) { + if(((pSiS->VGAEngine == SIS_300_VGA) && + (pSiS->VBFlags & (VB_301|VB_30xBDH|VB_LVDS))) || + ((pSiS->VGAEngine == SIS_315_VGA) && + ((pSiS->VBFlags & (VB_LVDS | VB_CHRONTEL)) == VB_LVDS))) { + setSISIDXREG(SISSR, 0x11, ~0x0c, sr11); + } + if(pSiS->VGAEngine == SIS_300_VGA) { + if((pSiS->VBFlags & (VB_301B|VB_301C|VB_302B)) && + (!(pSiS->VBFlags & VB_30xBDH))) { + setSISIDXREG(SISPART1, 0x13, 0x3f, p1_13); + } + } else if(pSiS->VGAEngine == SIS_315_VGA) { + if((pSiS->VBFlags & (VB_301B|VB_301C|VB_302B)) && + (!(pSiS->VBFlags & VB_30xBDH))) { + setSISIDXREG(SISPART2, 0x00, 0x1f, p2_0); + } + } + } else if(pSiS->VBFlags & CRT2_VGA) { + if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B)) { + setSISIDXREG(SISPART2, 0x00, 0x1f, p2_0); + } + } + } + if((docrt1) && (pmreg != oldpmreg) && ((!(pSiS->VBFlags & CRT1_LCDA)) || (pSiS->VBFlags & VB_301C))) { + outSISIDXREG(SISSR, 0x00, 0x01); /* Synchronous Reset */ + usleep(10000); + outSISIDXREG(SISSR, 0x00, 0x03); /* End Reset */ } + } -#endif /* Mandatory */ static void @@ -764,20 +668,80 @@ SISIdentify(int flags) xf86PrintChipsets(SIS_NAME, "driver for SiS chipsets", SISChipsets); } +#if 0 +/* This won't work as long as noone added the symbols to the symlist */ static void -SIS1bppColorMap(ScrnInfoPtr pScrn) +SISCalculateGammaRamp(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); + int i, j, nramp; + unsigned short *ramp[3]; + float gamma_max[3], gamma_prescale[3], framp; + + gamma_max[0] = (float)pSiS->GammaBriR / 1000; + gamma_max[1] = (float)pSiS->GammaBriG / 1000; + gamma_max[2] = (float)pSiS->GammaBriB / 1000; + gamma_prescale[0] = (float)pSiS->GammaPBriR / 1000; + gamma_prescale[1] = (float)pSiS->GammaPBriG / 1000; + gamma_prescale[2] = (float)pSiS->GammaPBriB / 1000; + + if(!(nramp = xf86GetGammaRampSize(pScrn->pScreen))) return; + + for(i=0; i<3; i++) { + ramp[i] = (unsigned short *)xalloc(nramp * sizeof(unsigned short)); + if(!ramp[i]) { + if(ramp[0]) { xfree(ramp[0]); ramp[0] = NULL; } + if(ramp[1]) { xfree(ramp[1]); ramp[1] = NULL; } + return; + } + } - outSISREG(SISCOLIDX, 0x00); - outSISREG(SISCOLDATA, 0x00); - outSISREG(SISCOLDATA, 0x00); - outSISREG(SISCOLDATA, 0x00); + for(i = 0; i < 3; i++) { + int fullscale = 65535 * gamma_max[i]; + float dramp = 1. / (nramp - 1); + float invgamma=0.0, v; - outSISREG(SISCOLIDX, 0x3f); - outSISREG(SISCOLDATA, 0x3f); - outSISREG(SISCOLDATA, 0x3f); - outSISREG(SISCOLDATA, 0x3f); + switch(i) { + case 0: invgamma = 1. / pScrn->gamma.red; break; + case 1: invgamma = 1. / pScrn->gamma.green; break; + case 2: invgamma = 1. / pScrn->gamma.blue; break; + } + + for(j = 0; j < nramp; j++) { + framp = pow(gamma_prescale[i] * j * dramp, invgamma); + + v = (fullscale < 0) ? (65535 + fullscale * framp) : + fullscale * framp; + if(v < 0) v = 0; + else if(v > 65535) v = 65535; + ramp[i][j] = (unsigned short)v; + } + } + + xf86ChangeGammaRamp(pScrn->pScreen, nramp, ramp[0], ramp[1], ramp[2]); + + xfree(ramp[0]); + xfree(ramp[1]); + xfree(ramp[2]); + ramp[0] = ramp[1] = ramp[2] = NULL; +} +#endif + +static void +SISErrorLog(ScrnInfoPtr pScrn, const char *format, ...) +{ + va_list ap; + static const char *str = "**************************************************\n"; + + va_start(ap, format); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, str); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + " ERROR:\n"); + xf86VDrvMsgVerb(pScrn->scrnIndex, X_ERROR, 1, format, ap); + va_end(ap); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + " END OF MESSAGE\n"); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, str); } /* Mandatory */ @@ -811,13 +775,12 @@ SISProbe(DriverPtr drv, int flags) * specified. */ - if ((numDevSections = xf86MatchDevice(SIS_DRIVER_NAME, - &devSections)) <= 0) { - /* - * There's no matching device section in the config file, so quit - * now. - */ - return FALSE; + if((numDevSections = xf86MatchDevice(SIS_DRIVER_NAME, &devSections)) <= 0) { + /* + * There's no matching device section in the config file, so quit + * now. + */ + return FALSE; } /* @@ -830,26 +793,25 @@ SISProbe(DriverPtr drv, int flags) * All of the cards this driver supports are PCI, so the "probing" just * amounts to checking the PCI data that the server has already collected. */ - if (xf86GetPciVideoInfo() == NULL) { - /* - * We won't let anything in the config file override finding no - * PCI video cards at all. This seems reasonable now, but we'll see. - */ - return FALSE; + if(xf86GetPciVideoInfo() == NULL) { + /* + * We won't let anything in the config file override finding no + * PCI video cards at all. This seems reasonable now, but we'll see. + */ + return FALSE; } numUsed = xf86MatchPciInstances(SIS_NAME, PCI_VENDOR_SIS, - SISChipsets, SISPciChipsets, devSections, - numDevSections, drv, &usedChips); + SISChipsets, SISPciChipsets, devSections, + numDevSections, drv, &usedChips); /* Free it since we don't need that list after this */ xfree(devSections); - if (numUsed <= 0) - return FALSE; + if(numUsed <= 0) return FALSE; - if (flags & PROBE_DETECT) + if(flags & PROBE_DETECT) { foundScreen = TRUE; - else for (i = 0; i < numUsed; i++) { + } else for(i = 0; i < numUsed; i++) { ScrnInfoPtr pScrn; #ifdef SISDUALHEAD EntityInfoPtr pEnt; @@ -858,7 +820,7 @@ SISProbe(DriverPtr drv, int flags) /* Allocate a ScrnInfoRec and claim the slot */ pScrn = NULL; - if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i], + if((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i], SISPciChipsets, NULL, NULL, NULL, NULL, NULL))) { /* Fill in what we can of the ScrnInfoRec */ @@ -879,37 +841,37 @@ SISProbe(DriverPtr drv, int flags) #ifdef SISDUALHEAD pEnt = xf86GetEntityInfo(usedChips[i]); - /* TW: I assume these chipsets as - basically - dual head capable. */ - if (pEnt->chipset == PCI_CHIP_SIS630 || pEnt->chipset == PCI_CHIP_SIS540 || - 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) { + if(pEnt->chipset == PCI_CHIP_SIS630 || pEnt->chipset == PCI_CHIP_SIS540 || + 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) { SISEntPtr pSiSEnt = NULL; DevUnion *pPriv; xf86SetEntitySharable(usedChips[i]); - if (SISEntityIndex < 0) - SISEntityIndex = xf86AllocateEntityPrivateIndex(); + if(SISEntityIndex < 0) { + SISEntityIndex = xf86AllocateEntityPrivateIndex(); + } pPriv = xf86GetEntityPrivate(pScrn->entityList[0], SISEntityIndex); - if (!pPriv->ptr) { - pPriv->ptr = xnfcalloc(sizeof(SISEntRec), 1); - pSiSEnt = pPriv->ptr; - pSiSEnt->lastInstance = -1; - pSiSEnt->DisableDual = FALSE; - pSiSEnt->ErrorAfterFirst = FALSE; - pSiSEnt->MapCountIOBase = pSiSEnt->MapCountFbBase = 0; - pSiSEnt->FbBase = pSiSEnt->IOBase = NULL; - pSiSEnt->forceUnmapIOBase = FALSE; - pSiSEnt->forceUnmapFbBase = FALSE; + if(!pPriv->ptr) { + pPriv->ptr = xnfcalloc(sizeof(SISEntRec), 1); + pSiSEnt = pPriv->ptr; + pSiSEnt->lastInstance = -1; + pSiSEnt->DisableDual = FALSE; + pSiSEnt->ErrorAfterFirst = FALSE; + pSiSEnt->MapCountIOBase = pSiSEnt->MapCountFbBase = 0; + pSiSEnt->FbBase = pSiSEnt->IOBase = NULL; + pSiSEnt->forceUnmapIOBase = FALSE; + pSiSEnt->forceUnmapFbBase = FALSE; #ifdef __alpha__ - pSiSEnt->MapCountIOBaseDense = 0; - pSiSEnt->IOBaseDense = NULL; - pSiSEnt->forceUnmapIOBaseDense = FALSE; + pSiSEnt->MapCountIOBaseDense = 0; + pSiSEnt->IOBaseDense = NULL; + pSiSEnt->forceUnmapIOBaseDense = FALSE; #endif } else { - pSiSEnt = pPriv->ptr; + pSiSEnt = pPriv->ptr; } pSiSEnt->lastInstance++; xf86SetEntityInstanceForScreen(pScrn, pScrn->entityList[0], @@ -922,9 +884,11 @@ SISProbe(DriverPtr drv, int flags) } -/* TW: If monitor section has no HSync/VRefresh data, - * derive it from DDC data. +/* If monitor section has no HSync/VRefresh data, + * derive it from DDC data. Done by common layer + * since 4.3.99.14. */ +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,14,0) static void SiSSetSyncRangeFromEdid(ScrnInfoPtr pScrn, int flag) { @@ -961,19 +925,19 @@ SiSSetSyncRangeFromEdid(ScrnInfoPtr pScrn, int flag) }; /* "Future modes"; we only check the really high ones */ const myddcstdmodes mystdmodes[8] = { - { 1280, 1024, 85, 91.1 }, - { 1600, 1200, 60, 75.0 }, - { 1600, 1200, 65, 81.3 }, - { 1600, 1200, 70, 87.5 }, - { 1600, 1200, 75, 93.8 }, + { 1280, 1024, 85, 91.1 }, + { 1600, 1200, 60, 75.0 }, + { 1600, 1200, 65, 81.3 }, + { 1600, 1200, 70, 87.5 }, + { 1600, 1200, 75, 93.8 }, { 1600, 1200, 85, 106.3 }, - { 1920, 1440, 60, 90.0 }, + { 1920, 1440, 60, 90.0 }, { 1920, 1440, 75, 112.5 } }; if(flag) { /* HSync */ - for (i = 0; i < 4; i++) { - if (ddc->det_mon[i].type == DS_RANGES) { + for(i = 0; i < 4; i++) { + if(ddc->det_mon[i].type == DS_RANGES) { mon->nHsync = 1; mon->hsync[0].lo = ddc->det_mon[i].section.ranges.min_h; mon->hsync[0].hi = ddc->det_mon[i].section.ranges.max_h; @@ -987,13 +951,13 @@ SiSSetSyncRangeFromEdid(ScrnInfoPtr pScrn, int flag) if(myhtiming[i].whichone == 1) temp = ddc->timings1.t1; else temp = ddc->timings1.t2; if(temp & myhtiming[i].mask) { - if((i==0) || (myhlow > myhtiming[i].rate)) + if((i==0) || (myhlow > myhtiming[i].rate)) myhlow = myhtiming[i].rate; } if(myhtiming[10-i].whichone == 1) temp = ddc->timings1.t1; else temp = ddc->timings1.t2; if(temp & myhtiming[10-i].mask) { - if((i==0) || (myhhigh < myhtiming[10-i].rate)) + if((i==0) || (myhhigh < myhtiming[10-i].rate)) myhhigh = myhtiming[10-i].rate; } } @@ -1018,8 +982,8 @@ SiSSetSyncRangeFromEdid(ScrnInfoPtr pScrn, int flag) } else { /* Vrefresh */ - for (i = 0; i < 4; i++) { - if (ddc->det_mon[i].type == DS_RANGES) { + for(i = 0; i < 4; i++) { + if(ddc->det_mon[i].type == DS_RANGES) { mon->nVrefresh = 1; mon->vrefresh[0].lo = ddc->det_mon[i].section.ranges.min_v; mon->vrefresh[0].hi = ddc->det_mon[i].section.ranges.max_v; @@ -1032,13 +996,13 @@ SiSSetSyncRangeFromEdid(ScrnInfoPtr pScrn, int flag) if(myvtiming[i].whichone == 1) temp = ddc->timings1.t1; else temp = ddc->timings1.t2; if(temp & myvtiming[i].mask) { - if((i==0) || (myvlow > myvtiming[i].rate)) + if((i==0) || (myvlow > myvtiming[i].rate)) myvlow = myvtiming[i].rate; } if(myvtiming[9-i].whichone == 1) temp = ddc->timings1.t1; else temp = ddc->timings1.t2; if(temp & myvtiming[9-i].mask) { - if((i==0) || (myvhigh < myvtiming[9-i].rate)) + if((i==0) || (myvhigh < myvtiming[9-i].rate)) myvhigh = myvtiming[9-i].rate; } } @@ -1062,68 +1026,1225 @@ SiSSetSyncRangeFromEdid(ScrnInfoPtr pScrn, int flag) } } +#endif + +/* Some helper functions for MergedFB mode */ + +#ifdef SISMERGED + +/* Helper function for CRT2 monitor vrefresh/hsync options + * (Code base from mga driver) + */ +static int +SiSStrToRanges(range *r, char *s, int max) +{ + float num = 0.0; + int rangenum = 0; + Bool gotdash = FALSE; + Bool nextdash = FALSE; + char* strnum = NULL; + do { + switch(*s) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '.': + if(strnum == NULL) { + strnum = s; + gotdash = nextdash; + nextdash = FALSE; + } + break; + case '-': + case ' ': + case 0: + if(strnum == NULL) break; + sscanf(strnum, "%f", &num); + strnum = NULL; + if(gotdash) { + r[rangenum - 1].hi = num; + } else { + r[rangenum].lo = num; + r[rangenum].hi = num; + rangenum++; + } + if(*s == '-') nextdash = (rangenum != 0); + else if(rangenum >= max) return rangenum; + break; + default: + return 0; + } + + } while(*(s++) != 0); + + return rangenum; +} + +/* Copy and link two modes form mergedfb mode + * (Code base taken from mga driver) + * Copys mode i, links the result to dest, and returns it. + * Links i and j in Private record. + * If dest is NULL, return value is copy of i linked to itself. + * For mergedfb auto-config, we only check the dimension + * against virtualX/Y, if they were user-provided. + */ +static DisplayModePtr +SiSCopyModeNLink(ScrnInfoPtr pScrn, DisplayModePtr dest, + DisplayModePtr i, DisplayModePtr j, + SiSScrn2Rel srel) +{ + SISPtr pSiS = SISPTR(pScrn); + DisplayModePtr mode; + int dx = 0,dy = 0; + + if(!((mode = xalloc(sizeof(DisplayModeRec))))) return dest; + memcpy(mode, i, sizeof(DisplayModeRec)); + if(!((mode->Private = xalloc(sizeof(SiSMergedDisplayModeRec))))) { + xfree(mode); + return dest; + } + ((SiSMergedDisplayModePtr)mode->Private)->CRT1 = i; + ((SiSMergedDisplayModePtr)mode->Private)->CRT2 = j; + ((SiSMergedDisplayModePtr)mode->Private)->CRT2Position = srel; + mode->PrivSize = 0; + + switch(srel) { + case sisLeftOf: + case sisRightOf: + if(!(pScrn->display->virtualX)) { + dx = i->HDisplay + j->HDisplay; + } else { + dx = min(pScrn->virtualX, i->HDisplay + j->HDisplay); + } + dx -= mode->HDisplay; + if(!(pScrn->display->virtualY)) { + dy = max(i->VDisplay, j->VDisplay); + } else { + dy = min(pScrn->virtualY, max(i->VDisplay, j->VDisplay)); + } + dy -= mode->VDisplay; + break; + case sisAbove: + case sisBelow: + if(!(pScrn->display->virtualY)) { + dy = i->VDisplay + j->VDisplay; + } else { + dy = min(pScrn->virtualY, i->VDisplay + j->VDisplay); + } + dy -= mode->VDisplay; + if(!(pScrn->display->virtualX)) { + dx = max(i->HDisplay, j->HDisplay); + } else { + dx = min(pScrn->virtualX, max(i->HDisplay, j->HDisplay)); + } + dx -= mode->HDisplay; + break; + case sisClone: + if(!(pScrn->display->virtualX)) { + dx = max(i->HDisplay, j->HDisplay); + } else { + dx = min(pScrn->virtualX, max(i->HDisplay, j->HDisplay)); + } + dx -= mode->HDisplay; + if(!(pScrn->display->virtualY)) { + dy = max(i->VDisplay, j->VDisplay); + } else { + dy = min(pScrn->virtualY, max(i->VDisplay, j->VDisplay)); + } + dy -= mode->VDisplay; + break; + } + mode->HDisplay += dx; + mode->HSyncStart += dx; + mode->HSyncEnd += dx; + mode->HTotal += dx; + mode->VDisplay += dy; + mode->VSyncStart += dy; + mode->VSyncEnd += dy; + mode->VTotal += dy; + mode->Clock = 0; + + if( ((mode->HDisplay * ((pScrn->bitsPerPixel + 7) / 8) * mode->VDisplay) > pSiS->maxxfbmem) || + (mode->HDisplay > 4088) || + (mode->VDisplay > 4096) ) { + + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Skipped %dx%d, not enough video RAM or beyond hardware specs\n", + mode->HDisplay, mode->VDisplay); + xfree(mode->Private); + xfree(mode); + + return dest; + } + +#ifdef SISXINERAMA + if(srel != sisClone) { + pSiS->AtLeastOneNonClone = TRUE; + } +#endif + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Merged %dx%d and %dx%d to %dx%d%s\n", + i->HDisplay, i->VDisplay, j->HDisplay, j->VDisplay, + mode->HDisplay, mode->VDisplay, (srel == sisClone) ? " (Clone)" : ""); + + mode->next = mode; + mode->prev = mode; + + if(dest) { + mode->next = dest->next; /* Insert node after "dest" */ + dest->next->prev = mode; + mode->prev = dest; + dest->next = mode; + } + + return mode; +} + +/* Helper function to find a mode from a given name + * (Code base taken from mga driver) + */ +static DisplayModePtr +SiSGetModeFromName(char* str, DisplayModePtr i) +{ + DisplayModePtr c = i; + if(!i) return NULL; + do { + if(strcmp(str, c->name) == 0) return c; + c = c->next; + } while(c != i); + return NULL; +} + +static DisplayModePtr +SiSFindWidestTallestMode(DisplayModePtr i, Bool tallest) +{ + DisplayModePtr c = i, d = NULL; + int max = 0; + if(!i) return NULL; + do { + if(tallest) { + if(c->VDisplay > max) { + max = c->VDisplay; + d = c; + } + } else { + if(c->HDisplay > max) { + max = c->HDisplay; + d = c; + } + } + c = c->next; + } while(c != i); + return d; +} + +static DisplayModePtr +SiSGenerateModeListFromLargestModes(ScrnInfoPtr pScrn, + DisplayModePtr i, DisplayModePtr j, + SiSScrn2Rel srel) +{ +#ifdef SISXINERAMA + SISPtr pSiS = SISPTR(pScrn); +#endif + DisplayModePtr mode1 = NULL; + DisplayModePtr mode2 = NULL; + DisplayModePtr result = NULL; + +#ifdef SISXINERAMA + pSiS->AtLeastOneNonClone = FALSE; +#endif + + switch(srel) { + case sisLeftOf: + case sisRightOf: + mode1 = SiSFindWidestTallestMode(i, FALSE); + mode2 = SiSFindWidestTallestMode(j, FALSE); + break; + case sisAbove: + case sisBelow: + mode1 = SiSFindWidestTallestMode(i, TRUE); + mode2 = SiSFindWidestTallestMode(j, TRUE); + break; + case sisClone: + mode1 = i; + mode2 = j; + } + + if(mode1 && mode2) { + return(SiSCopyModeNLink(pScrn, result, mode1, mode2, srel)); + } else { + return NULL; + } +} + +/* Generate the merged-fb mode modelist from metamodes + * (Code base taken from mga driver) + */ +static DisplayModePtr +SiSGenerateModeListFromMetaModes(ScrnInfoPtr pScrn, char* str, + DisplayModePtr i, DisplayModePtr j, + SiSScrn2Rel srel) +{ +#ifdef SISXINERAMA + SISPtr pSiS = SISPTR(pScrn); +#endif + char* strmode = str; + char modename[256]; + Bool gotdash = FALSE; + SiSScrn2Rel sr; + DisplayModePtr mode1 = NULL; + DisplayModePtr mode2 = NULL; + DisplayModePtr result = NULL; + +#ifdef SISXINERAMA + pSiS->AtLeastOneNonClone = FALSE; +#endif + + do { + switch(*str) { + case 0: + case '-': + case ' ': + if((strmode != str)) { + + strncpy(modename, strmode, str - strmode); + modename[str - strmode] = 0; + + if(gotdash) { + if(mode1 == NULL) return NULL; + mode2 = SiSGetModeFromName(modename, j); + if(!mode2) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Mode \"%s\" is not a supported mode for CRT2\n", modename); + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Skipping metamode \"%s-%s\".\n", mode1->name, modename); + mode1 = NULL; + } + } else { + mode1 = SiSGetModeFromName(modename, i); + if(!mode1) { + char* tmps = str; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Mode \"%s\" is not a supported mode for CRT1\n", modename); + gotdash = FALSE; + while(*tmps == ' ') tmps++; + if(*tmps == '-') { /* skip the next mode */ + tmps++; + while((*tmps == ' ') && (*tmps != 0)) tmps++; /* skip spaces */ + while((*tmps != ' ') && (*tmps != '-') && (*tmps != 0)) tmps++; /* skip modename */ + strncpy(modename,strmode,tmps - strmode); + modename[tmps - strmode] = 0; + str = tmps-1; + } + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Skipping metamode \"%s\".\n", modename); + mode1 = NULL; + } + } + gotdash = FALSE; + } + strmode = str + 1; + gotdash |= (*str == '-'); + + if(*str != 0) break; + /* Fall through otherwise */ + + default: + if(!gotdash && mode1) { + sr = srel; + if(!mode2) { + mode2 = SiSGetModeFromName(mode1->name, j); + sr = sisClone; + } + if(!mode2) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Mode: \"%s\" is not a supported mode for CRT2\n", mode1->name); + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Skipping metamode \"%s\".\n", modename); + mode1 = NULL; + } else { + result = SiSCopyModeNLink(pScrn, result, mode1, mode2, sr); + mode1 = NULL; + mode2 = NULL; + } + } + break; + + } + + } while(*(str++) != 0); + + return result; +} + +static DisplayModePtr +SiSGenerateModeList(ScrnInfoPtr pScrn, char* str, + DisplayModePtr i, DisplayModePtr j, + SiSScrn2Rel srel) +{ + if(str != NULL) { + return(SiSGenerateModeListFromMetaModes(pScrn, str, i, j, srel)); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "No MetaModes given, linking %s modes by default\n", + (srel == sisClone) ? "first" : + (((srel == sisLeftOf) || (srel == sisRightOf)) ? "widest" : "tallest")); + return(SiSGenerateModeListFromLargestModes(pScrn, i, j, srel)); + } +} + +static void +SiSRecalcDefaultVirtualSize(ScrnInfoPtr pScrn) +{ + DisplayModePtr mode, bmode; + int max; + static const char *str = "MergedFB: Virtual %s %d\n"; + + if(!(pScrn->display->virtualX)) { + mode = bmode = pScrn->modes; + max = 0; + do { + if(mode->HDisplay > max) max = mode->HDisplay; + mode = mode->next; + } while(mode != bmode); + pScrn->virtualX = max; + pScrn->displayWidth = max; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, str, "width", max); + } + if(!(pScrn->display->virtualY)) { + mode = bmode = pScrn->modes; + max = 0; + do { + if(mode->VDisplay > max) max = mode->VDisplay; + mode = mode->next; + } while(mode != bmode); + pScrn->virtualY = max; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, str, "height", max); + } +} + +static void +SiSMergedFBSetDpi(ScrnInfoPtr pScrn1, ScrnInfoPtr pScrn2, SiSScrn2Rel srel) +{ + SISPtr pSiS = SISPTR(pScrn1); + MessageType from = X_DEFAULT; + xf86MonPtr DDC1 = (xf86MonPtr)(pScrn1->monitor->DDC); + xf86MonPtr DDC2 = (xf86MonPtr)(pScrn2->monitor->DDC); + int ddcWidthmm = 0, ddcHeightmm = 0; + const char *dsstr = "MergedFB: Display dimensions: (%d, %d) mm\n"; + + /* This sets the DPI for MergedFB mode. The problem is that + * this can never be exact, because the output devices may + * have different dimensions. This function tries to compromise + * through a few assumptions, and it just calculates an average DPI + * value for both monitors. + */ + + /* Given DisplaySize should regard BOTH monitors */ + pScrn1->widthmm = pScrn1->monitor->widthmm; + pScrn1->heightmm = pScrn1->monitor->heightmm; + + /* Get DDC display size; if only either CRT1 or CRT2 provided these, + * assume equal dimensions for both, otherwise add dimensions + */ + if( (DDC1 && (DDC1->features.hsize > 0 && DDC1->features.vsize > 0)) && + (DDC2 && (DDC2->features.hsize > 0 && DDC2->features.vsize > 0)) ) { + ddcWidthmm = max(DDC1->features.hsize, DDC2->features.hsize) * 10; + ddcHeightmm = max(DDC1->features.vsize, DDC2->features.vsize) * 10; + switch(srel) { + case sisLeftOf: + case sisRightOf: + ddcWidthmm = (DDC1->features.hsize + DDC2->features.hsize) * 10; + break; + case sisAbove: + case sisBelow: + ddcHeightmm = (DDC1->features.vsize + DDC2->features.vsize) * 10; + default: + break; + } + } else if(DDC1 && (DDC1->features.hsize > 0 && DDC1->features.vsize > 0)) { + ddcWidthmm = DDC1->features.hsize * 10; + ddcHeightmm = DDC1->features.vsize * 10; + switch(srel) { + case sisLeftOf: + case sisRightOf: + ddcWidthmm *= 2; + break; + case sisAbove: + case sisBelow: + ddcHeightmm *= 2; + default: + break; + } + } else if(DDC2 && (DDC2->features.hsize > 0 && DDC2->features.vsize > 0) ) { + ddcWidthmm = DDC2->features.hsize * 10; + ddcHeightmm = DDC2->features.vsize * 10; + switch(srel) { + case sisLeftOf: + case sisRightOf: + ddcWidthmm *= 2; + break; + case sisAbove: + case sisBelow: + ddcHeightmm *= 2; + default: + break; + } + } + + if(monitorResolution > 0) { + + /* Set command line given values (overrules given options) */ + pScrn1->xDpi = monitorResolution; + pScrn1->yDpi = monitorResolution; + from = X_CMDLINE; + + } else if(pSiS->MergedFBXDPI) { + + /* Set option-wise given values (overrule DisplaySize) */ + pScrn1->xDpi = pSiS->MergedFBXDPI; + pScrn1->yDpi = pSiS->MergedFBYDPI; + from = X_CONFIG; + + } else if(pScrn1->widthmm > 0 || pScrn1->heightmm > 0) { + + /* Set values calculated from given DisplaySize */ + from = X_CONFIG; + if(pScrn1->widthmm > 0) { + pScrn1->xDpi = (int)((double)pScrn1->virtualX * 25.4 / pScrn1->widthmm); + } + if(pScrn1->heightmm > 0) { + pScrn1->yDpi = (int)((double)pScrn1->virtualY * 25.4 / pScrn1->heightmm); + } + xf86DrvMsg(pScrn1->scrnIndex, from, dsstr, pScrn1->widthmm, pScrn1->heightmm); + + } else if(ddcWidthmm && ddcHeightmm) { + + /* Set values from DDC-provided display size */ + from = X_PROBED; + xf86DrvMsg(pScrn1->scrnIndex, from, dsstr, ddcWidthmm, ddcHeightmm ); + pScrn1->widthmm = ddcWidthmm; + pScrn1->heightmm = ddcHeightmm; + if(pScrn1->widthmm > 0) { + pScrn1->xDpi = (int)((double)pScrn1->virtualX * 25.4 / pScrn1->widthmm); + } + if(pScrn1->heightmm > 0) { + pScrn1->yDpi = (int)((double)pScrn1->virtualY * 25.4 / pScrn1->heightmm); + } + + } else { + + pScrn1->xDpi = pScrn1->yDpi = DEFAULT_DPI; + + } + + /* Sanity check */ + if(pScrn1->xDpi > 0 && pScrn1->yDpi <= 0) + pScrn1->yDpi = pScrn1->xDpi; + if(pScrn1->yDpi > 0 && pScrn1->xDpi <= 0) + pScrn1->xDpi = pScrn1->yDpi; + + pScrn2->xDpi = pScrn1->xDpi; + pScrn2->yDpi = pScrn1->yDpi; + + xf86DrvMsg(pScrn1->scrnIndex, from, "MergedFB: DPI set to (%d, %d)\n", + pScrn1->xDpi, pScrn1->yDpi); +} + +/* Pseudo-Xinerama extension for MergedFB mode */ +#ifdef SISXINERAMA + +static void +SiSUpdateXineramaScreenInfo(ScrnInfoPtr pScrn1) +{ + SISPtr pSiS = SISPTR(pScrn1); + int crt1scrnnum = 0, crt2scrnnum = 1; + int x1=0, x2=0, y1=0, y2=0, h1=0, h2=0, w1=0, w2=0; + DisplayModePtr currentMode, firstMode; + Bool infochanged = FALSE; + + if(!pSiS->MergedFB) return; + + if(SiSnoPanoramiXExtension) return; + + if(!SiSXineramadataPtr) return; + + if(pSiS->CRT2IsScrn0) { + crt1scrnnum = 1; + crt2scrnnum = 0; + } + + /* Attention: Usage of RandR may lead into virtual X and Y values + * actually smaller than our MetaModes! To avoid this, we calculate + * the maxCRT fields here (and not somewhere else, like in CopyNLink) + */ + + if((pSiS->SiSXineramaVX != pScrn1->virtualX) || (pSiS->SiSXineramaVY != pScrn1->virtualY)) { + + if(!(pScrn1->modes)) return; + + pSiS->maxCRT1_X1 = pSiS->maxCRT1_X2 = 0; + pSiS->maxCRT1_Y1 = pSiS->maxCRT1_Y2 = 0; + pSiS->maxCRT2_X1 = pSiS->maxCRT2_X2 = 0; + pSiS->maxCRT2_Y1 = pSiS->maxCRT2_Y2 = 0; + pSiS->maxClone_X1 = pSiS->maxClone_X2 = 0; + pSiS->maxClone_Y1 = pSiS->maxClone_Y2 = 0; + + currentMode = firstMode = pScrn1->modes; + + do { + + DisplayModePtr p = currentMode->next; + DisplayModePtr i = ((SiSMergedDisplayModePtr)currentMode->Private)->CRT1; + DisplayModePtr j = ((SiSMergedDisplayModePtr)currentMode->Private)->CRT2; + SiSScrn2Rel srel = ((SiSMergedDisplayModePtr)currentMode->Private)->CRT2Position; + + if((i->HDisplay <= pScrn1->virtualX) && (j->HDisplay <= pScrn1->virtualX) && + (i->VDisplay <= pScrn1->virtualY) && (j->VDisplay <= pScrn1->virtualY)) { + + if(srel != sisClone) { + if(pSiS->maxCRT1_X1 <= i->HDisplay) { + pSiS->maxCRT1_X1 = i->HDisplay; /* Largest CRT1 mode */ + if(pSiS->maxCRT1_X2 < j->HDisplay) { + pSiS->maxCRT1_X2 = j->HDisplay; /* Largest X of CRT2 mode displayed with largest CRT1 mode */ + } + } + if(pSiS->maxCRT2_X2 <= j->HDisplay) { + pSiS->maxCRT2_X2 = j->HDisplay; /* Largest CRT2 mode */ + if(pSiS->maxCRT2_X1 < i->HDisplay) { + pSiS->maxCRT2_X1 = i->HDisplay; /* Largest X of CRT1 mode displayed with largest CRT2 mode */ + } + } + if(pSiS->maxCRT1_Y1 <= i->VDisplay) { + pSiS->maxCRT1_Y1 = i->VDisplay; + if(pSiS->maxCRT1_Y2 < j->VDisplay) { + pSiS->maxCRT1_Y2 = j->VDisplay; + } + } + if(pSiS->maxCRT2_Y2 <= j->VDisplay) { + pSiS->maxCRT2_Y2 = j->VDisplay; + if(pSiS->maxCRT2_Y1 < i->VDisplay) { + pSiS->maxCRT2_Y1 = i->VDisplay; + } + } + } else { + if(pSiS->maxClone_X1 < i->HDisplay) { + pSiS->maxClone_X1 = i->HDisplay; + } + if(pSiS->maxClone_X2 < j->HDisplay) { + pSiS->maxClone_X2 = j->HDisplay; + } + if(pSiS->maxClone_Y1 < i->VDisplay) { + pSiS->maxClone_Y1 = i->VDisplay; + } + if(pSiS->maxClone_Y2 < j->VDisplay) { + pSiS->maxClone_Y2 = j->VDisplay; + } + } + } + currentMode = p; + + } while((currentMode) && (currentMode != firstMode)); + + pSiS->SiSXineramaVX = pScrn1->virtualX; + pSiS->SiSXineramaVY = pScrn1->virtualY; + infochanged = TRUE; + + } + + switch(pSiS->CRT2Position) { + case sisLeftOf: + x1 = min(pSiS->maxCRT1_X2, pScrn1->virtualX - pSiS->maxCRT1_X1); + if(x1 < 0) x1 = 0; + y1 = 0; + w1 = pScrn1->virtualX - x1; + h1 = pScrn1->virtualY; + x2 = 0; + y2 = 0; + w2 = max(pSiS->maxCRT2_X2, pScrn1->virtualX - pSiS->maxCRT2_X1); + if(w2 > pScrn1->virtualX) w2 = pScrn1->virtualX; + h2 = pScrn1->virtualY; + break; + case sisRightOf: + x1 = 0; + y1 = 0; + w1 = max(pSiS->maxCRT1_X1, pScrn1->virtualX - pSiS->maxCRT1_X2); + if(w1 > pScrn1->virtualX) w1 = pScrn1->virtualX; + h1 = pScrn1->virtualY; + x2 = min(pSiS->maxCRT2_X1, pScrn1->virtualX - pSiS->maxCRT2_X2); + if(x2 < 0) x2 = 0; + y2 = 0; + w2 = pScrn1->virtualX - x2; + h2 = pScrn1->virtualY; + break; + case sisAbove: + x1 = 0; + y1 = min(pSiS->maxCRT1_Y2, pScrn1->virtualY - pSiS->maxCRT1_Y1); + if(y1 < 0) y1 = 0; + w1 = pScrn1->virtualX; + h1 = pScrn1->virtualY - y1; + x2 = 0; + y2 = 0; + w2 = pScrn1->virtualX; + h2 = max(pSiS->maxCRT2_Y2, pScrn1->virtualY - pSiS->maxCRT2_Y1); + if(h2 > pScrn1->virtualY) h2 = pScrn1->virtualY; + break; + case sisBelow: + x1 = 0; + y1 = 0; + w1 = pScrn1->virtualX; + h1 = max(pSiS->maxCRT1_Y1, pScrn1->virtualY - pSiS->maxCRT1_Y2); + if(h1 > pScrn1->virtualY) h1 = pScrn1->virtualY; + x2 = 0; + y2 = min(pSiS->maxCRT2_Y1, pScrn1->virtualY - pSiS->maxCRT2_Y2); + if(y2 < 0) y2 = 0; + w2 = pScrn1->virtualX; + h2 = pScrn1->virtualY - y2; + default: + break; + } + + SiSXineramadataPtr[crt1scrnnum].x = x1; + SiSXineramadataPtr[crt1scrnnum].y = y1; + SiSXineramadataPtr[crt1scrnnum].width = w1; + SiSXineramadataPtr[crt1scrnnum].height = h1; + SiSXineramadataPtr[crt2scrnnum].x = x2; + SiSXineramadataPtr[crt2scrnnum].y = y2; + SiSXineramadataPtr[crt2scrnnum].width = w2; + SiSXineramadataPtr[crt2scrnnum].height = h2; + + if(infochanged) { + xf86DrvMsg(pScrn1->scrnIndex, X_INFO, + "Pseudo-Xinerama: CRT1 (Screen %d) (%d,%d)-(%d,%d)\n", + crt1scrnnum, x1, y1, w1+x1-1, h1+y1-1); + xf86DrvMsg(pScrn1->scrnIndex, X_INFO, + "Pseudo-Xinerama: CRT2 (Screen %d) (%d,%d)-(%d,%d)\n", + crt2scrnnum, x2, y2, w2+x2-1, h2+y2-1); + } +} + +/* Proc */ + +int +SiSProcXineramaQueryVersion(ClientPtr client) +{ + xPanoramiXQueryVersionReply rep; + register int n; + + REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = SIS_XINERAMA_MAJOR_VERSION; + rep.minorVersion = SIS_XINERAMA_MINOR_VERSION; + if(client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + } + WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + +int +SiSProcXineramaGetState(ClientPtr client) +{ + REQUEST(xPanoramiXGetStateReq); + WindowPtr pWin; + xPanoramiXGetStateReply rep; + register int n; + + REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); + pWin = LookupWindow(stuff->window, client); + if(!pWin) return BadWindow; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.state = !SiSnoPanoramiXExtension; + if(client->swapped) { + swaps (&rep.sequenceNumber, n); + swapl (&rep.length, n); + swaps (&rep.state, n); + } + WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *)&rep); + return client->noClientException; +} + +int +SiSProcXineramaGetScreenCount(ClientPtr client) +{ + REQUEST(xPanoramiXGetScreenCountReq); + WindowPtr pWin; + xPanoramiXGetScreenCountReply rep; + register int n; + + REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); + pWin = LookupWindow(stuff->window, client); + if(!pWin) return BadWindow; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.ScreenCount = SiSXineramaNumScreens; + if(client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.ScreenCount, n); + } + WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep); + return client->noClientException; +} + +int +SiSProcXineramaGetScreenSize(ClientPtr client) +{ + REQUEST(xPanoramiXGetScreenSizeReq); + WindowPtr pWin; + xPanoramiXGetScreenSizeReply rep; + register int n; + + REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); + pWin = LookupWindow (stuff->window, client); + if(!pWin) return BadWindow; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.width = SiSXineramadataPtr[stuff->screen].width; + rep.height = SiSXineramadataPtr[stuff->screen].height; + if(client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.width, n); + swaps(&rep.height, n); + } + WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep); + return client->noClientException; +} + +int +SiSProcXineramaIsActive(ClientPtr client) +{ + xXineramaIsActiveReply rep; + + REQUEST_SIZE_MATCH(xXineramaIsActiveReq); + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.state = !SiSnoPanoramiXExtension; + if(client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.state, n); + } + WriteToClient(client, sizeof(xXineramaIsActiveReply), (char *) &rep); + return client->noClientException; +} + +int +SiSProcXineramaQueryScreens(ClientPtr client) +{ + xXineramaQueryScreensReply rep; + + REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.number = (SiSnoPanoramiXExtension) ? 0 : SiSXineramaNumScreens; + rep.length = rep.number * sz_XineramaScreenInfo >> 2; + if(client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.number, n); + } + WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *)&rep); + + if(!SiSnoPanoramiXExtension) { + xXineramaScreenInfo scratch; + int i; + + for(i = 0; i < SiSXineramaNumScreens; i++) { + scratch.x_org = SiSXineramadataPtr[i].x; + scratch.y_org = SiSXineramadataPtr[i].y; + scratch.width = SiSXineramadataPtr[i].width; + scratch.height = SiSXineramadataPtr[i].height; + if(client->swapped) { + register int n; + swaps(&scratch.x_org, n); + swaps(&scratch.y_org, n); + swaps(&scratch.width, n); + swaps(&scratch.height, n); + } + WriteToClient(client, sz_XineramaScreenInfo, (char *)&scratch); + } + } + + return client->noClientException; +} + +static int +SiSProcXineramaDispatch(ClientPtr client) +{ + REQUEST(xReq); + switch (stuff->data) { + case X_PanoramiXQueryVersion: + return SiSProcXineramaQueryVersion(client); + case X_PanoramiXGetState: + return SiSProcXineramaGetState(client); + case X_PanoramiXGetScreenCount: + return SiSProcXineramaGetScreenCount(client); + case X_PanoramiXGetScreenSize: + return SiSProcXineramaGetScreenSize(client); + case X_XineramaIsActive: + return SiSProcXineramaIsActive(client); + case X_XineramaQueryScreens: + return SiSProcXineramaQueryScreens(client); + } + return BadRequest; +} + +/* SProc */ + +static int +SiSSProcXineramaQueryVersion (ClientPtr client) +{ + REQUEST(xPanoramiXQueryVersionReq); + register int n; + swaps(&stuff->length,n); + REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq); + return SiSProcXineramaQueryVersion(client); +} + +static int +SiSSProcXineramaGetState(ClientPtr client) +{ + REQUEST(xPanoramiXGetStateReq); + register int n; + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); + return SiSProcXineramaGetState(client); +} + +static int +SiSSProcXineramaGetScreenCount(ClientPtr client) +{ + REQUEST(xPanoramiXGetScreenCountReq); + register int n; + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); + return SiSProcXineramaGetScreenCount(client); +} + +static int +SiSSProcXineramaGetScreenSize(ClientPtr client) +{ + REQUEST(xPanoramiXGetScreenSizeReq); + register int n; + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); + return SiSProcXineramaGetScreenSize(client); +} + +static int +SiSSProcXineramaIsActive(ClientPtr client) +{ + REQUEST(xXineramaIsActiveReq); + register int n; + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xXineramaIsActiveReq); + return SiSProcXineramaIsActive(client); +} + +static int +SiSSProcXineramaQueryScreens(ClientPtr client) +{ + REQUEST(xXineramaQueryScreensReq); + register int n; + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); + return SiSProcXineramaQueryScreens(client); +} + +int +SiSSProcXineramaDispatch(ClientPtr client) +{ + REQUEST(xReq); + switch (stuff->data) { + case X_PanoramiXQueryVersion: + return SiSSProcXineramaQueryVersion(client); + case X_PanoramiXGetState: + return SiSSProcXineramaGetState(client); + case X_PanoramiXGetScreenCount: + return SiSSProcXineramaGetScreenCount(client); + case X_PanoramiXGetScreenSize: + return SiSSProcXineramaGetScreenSize(client); + case X_XineramaIsActive: + return SiSSProcXineramaIsActive(client); + case X_XineramaQueryScreens: + return SiSSProcXineramaQueryScreens(client); + } + return BadRequest; +} + +static void +SiSXineramaResetProc(ExtensionEntry* extEntry) +{ + /* Called by CloseDownExtensions() */ + if(SiSXineramadataPtr) { + Xfree(SiSXineramadataPtr); + SiSXineramadataPtr = NULL; + } +} + +static void +SiSXineramaExtensionInit(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + Bool success = FALSE; + + if(!(SiSXineramadataPtr)) { + + if(!pSiS->MergedFB) { + SiSnoPanoramiXExtension = TRUE; + return; + } + +#ifdef PANORAMIX + if(!noPanoramiXExtension) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Xinerama active, not initializing SiS Pseudo-Xinerama\n"); + SiSnoPanoramiXExtension = TRUE; + return; + } +#endif + + if(SiSnoPanoramiXExtension) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "SiS Pseudo-Xinerama disabled\n"); + return; + } + + if(pSiS->CRT2Position == sisClone) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Running MergedFB in Clone mode, SiS Pseudo-Xinerama disabled\n"); + SiSnoPanoramiXExtension = TRUE; + return; + } + + if(!(pSiS->AtLeastOneNonClone)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Only Clone modes defined, SiS Pseudo-Xinerama disabled\n"); + SiSnoPanoramiXExtension = TRUE; + return; + } + + SiSXineramaNumScreens = 2; + + while(SiSXineramaGeneration != serverGeneration) { + + pSiS->XineramaExtEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0,0, + SiSProcXineramaDispatch, + SiSSProcXineramaDispatch, + SiSXineramaResetProc, + StandardMinorOpcode); + + if(!pSiS->XineramaExtEntry) break; + + if(!(SiSXineramadataPtr = (SiSXineramaData *) + xcalloc(SiSXineramaNumScreens, sizeof(SiSXineramaData)))) break; + + SiSXineramaGeneration = serverGeneration; + success = TRUE; + } + + if(!success) { + SISErrorLog(pScrn, "Failed to initialize SiS Pseudo-Xinerama extension\n"); + SiSnoPanoramiXExtension = TRUE; + return; + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "SiS Pseudo-Xinerama extension initialized\n"); + + pSiS->SiSXineramaVX = 0; + pSiS->SiSXineramaVY = 0; + + } + + SiSUpdateXineramaScreenInfo(pScrn); + +} +#endif /* End of PseudoXinerama */ + +static void +SiSFreeCRT2Structs(SISPtr pSiS) +{ + if(pSiS->CRT2pScrn) { + if(pSiS->CRT2pScrn->modes) { + while(pSiS->CRT2pScrn->modes) + xf86DeleteMode(&pSiS->CRT2pScrn->modes, pSiS->CRT2pScrn->modes); + } + if(pSiS->CRT2pScrn->monitor) { + if(pSiS->CRT2pScrn->monitor->Modes) { + while(pSiS->CRT2pScrn->monitor->Modes) + xf86DeleteMode(&pSiS->CRT2pScrn->monitor->Modes, pSiS->CRT2pScrn->monitor->Modes); + } + if(pSiS->CRT2pScrn->monitor->DDC) xfree(pSiS->CRT2pScrn->monitor->DDC); + xfree(pSiS->CRT2pScrn->monitor); + } + xfree(pSiS->CRT2pScrn); + pSiS->CRT2pScrn = NULL; + } +} + +#endif /* End of MergedFB helpers */ static xf86MonPtr SiSInternalDDC(ScrnInfoPtr pScrn, int crtno) { SISPtr pSiS = SISPTR(pScrn); - USHORT temp, i; + USHORT temp = 0xffff, temp1, i, realcrtno = crtno; unsigned char buffer[256]; xf86MonPtr pMonitor = NULL; - /* TW: If CRT1 is off, skip DDC */ + /* If CRT1 is off, skip DDC */ if((pSiS->CRT1off) && (!crtno)) return NULL; - temp = SiS_HandleDDC(pSiS->SiS_Pr, pSiS, crtno, 0, &buffer[0]); - if((!temp) || (temp == 0xffff)) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "CRT%d DDC probing failed, now trying via VBE\n", crtno + 1); - return(NULL); + if(crtno) { + if(pSiS->VBFlags & CRT2_LCD) realcrtno = 1; + else if(pSiS->VBFlags & CRT2_VGA) realcrtno = 2; + else return NULL; } else { + /* If CRT1 is LCDA, skip DDC (except 301C: DDC allowed, but uses CRT2 port!) */ + if(pSiS->VBFlags & CRT1_LCDA) { + if(pSiS->VBFlags & VB_301C) realcrtno = 1; + else return NULL; + } + } + + i = 3; /* Number of retrys */ + do { + temp1 = SiS_HandleDDC(pSiS->SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, realcrtno, 0, &buffer[0]); + if((temp1) && (temp1 != 0xffff)) temp = temp1; + } while((temp == 0xffff) && i--); + if(temp != 0xffff) { xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "CRT%d DDC supported\n", crtno + 1); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "CRT%d DDC level: %s%s%s%s\n", crtno + 1, (temp & 0x1a) ? "" : "[none of the supported]", (temp & 0x02) ? "2 " : "", - (temp & 0x08) ? "3 " : "", - (temp & 0x10) ? "4" : ""); + (temp & 0x08) ? "D&P" : "", + (temp & 0x10) ? "FPDI-2" : ""); if(temp & 0x02) { - i = 3; /* Number of retrys */ + i = 5; /* Number of retrys */ do { - temp = SiS_HandleDDC(pSiS->SiS_Pr, pSiS, crtno, 1, &buffer[0]); + temp = SiS_HandleDDC(pSiS->SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, realcrtno, 1, &buffer[0]); } while((temp) && i--); if(!temp) { if((pMonitor = xf86InterpretEDID(pScrn->scrnIndex, &buffer[0]))) { return(pMonitor); } else { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "CRT%d DDC EDID corrupt\n", crtno + 1); return(NULL); } } else { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "CRT%d DDC reading failed\n", crtno + 1); return(NULL); } - } else { + } else if(!crtno) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "DDC levels 3 and 4 not supported by this driver yet.\n"); + "DDC for VESA D&P and FPDI-2 not supported for CRT1.\n"); return(NULL); - } + } else if(temp & 0x18) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "DDC for VESA D&P and FPDI-2 not supported for CRT2 yet.\n"); + return(NULL); + } + return(NULL); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "CRT%d DDC probing failed\n", crtno + 1); + return(NULL); } } static xf86MonPtr -SiSDoPrivateDDC(ScrnInfoPtr pScrn) +SiSDoPrivateDDC(ScrnInfoPtr pScrn, int *crtnum) { SISPtr pSiS = SISPTR(pScrn); #ifdef SISDUALHEAD - if((pSiS->DualHeadMode) && (!pSiS->SecondHead)) - return(SiSInternalDDC(pScrn, 1)); - else + if(pSiS->DualHeadMode) { + if(pSiS->SecondHead) { + *crtnum = 1; + return(SiSInternalDDC(pScrn, 0)); + } else { + *crtnum = 2; + return(SiSInternalDDC(pScrn, 1)); + } + } else #endif - return(SiSInternalDDC(pScrn, 0)); + if(pSiS->CRT1off) { + *crtnum = 2; + return(SiSInternalDDC(pScrn, 1)); + } else { + *crtnum = 1; + return(SiSInternalDDC(pScrn, 0)); + } +} + +static BOOLEAN +SiSMakeOwnModeList(ScrnInfoPtr pScrn, BOOLEAN acceptcustommodes, BOOLEAN includelcdmodes, + BOOLEAN isfordvi, BOOLEAN *havecustommodes) +{ + DisplayModePtr tempmode, delmode, mymodes; + + if((mymodes = SiSBuildBuiltInModeList(pScrn, includelcdmodes, isfordvi))) { + if(!acceptcustommodes) { + while(pScrn->monitor->Modes) + xf86DeleteMode(&pScrn->monitor->Modes, pScrn->monitor->Modes); + pScrn->monitor->Modes = mymodes; + } else { + delmode = pScrn->monitor->Modes; + while(delmode) { + if(delmode->type & M_T_DEFAULT) { + tempmode = delmode->next; + xf86DeleteMode(&pScrn->monitor->Modes, delmode); + delmode = tempmode; + } else { + delmode = delmode->next; + } + } + tempmode = pScrn->monitor->Modes; + if(tempmode) *havecustommodes = TRUE; + pScrn->monitor->Modes = mymodes; + while(mymodes) { + if(!mymodes->next) break; + else mymodes = mymodes->next; + } + mymodes->next = tempmode; + if(tempmode) { + tempmode->prev = mymodes; + } + } + return TRUE; + } else + return FALSE; } /* Mandatory */ @@ -1133,18 +2254,18 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) SISPtr pSiS; MessageType from; unsigned char usScratchCR17, CR5F; - unsigned char usScratchCR32; + unsigned char usScratchCR32, usScratchCR63; + unsigned char usScratchSR1F; unsigned long int i; int temp; ClockRangePtr clockRanges; - char *mod = NULL; - const char *Sym = NULL; int pix24flags; #ifdef SISDUALHEAD SISEntPtr pSiSEnt = NULL; #endif +#if defined(SISMERGED) || defined(SISDUALHEAD) DisplayModePtr first, p, n; - DisplayModePtr tempmode, delmode, mymodes; +#endif unsigned char srlockReg,crlockReg; unsigned char tempreg; xf86MonPtr pMonitor = NULL; @@ -1153,20 +2274,37 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) vbeInfoPtr pVbe; VbeInfoBlock *vbe; - if (flags & PROBE_DETECT) { - if (xf86LoadSubModule(pScrn, "vbe")) { - int index = xf86GetEntityInfo(pScrn->entityList[0])->index; - + static const char *ddcsstr = "CRT%d DDC monitor info: ************************************\n"; + static const char *ddcestr = "End of CRT%d DDC monitor info ******************************\n"; +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,14,0) + static const char *subshstr = "Substituting missing CRT%d monitor HSync data by DDC data\n"; + static const char *subsvstr = "Substituting missing CRT%d monitor VRefresh data by DDC data\n"; +#endif +#ifdef SISMERGED + static const char *mergednocrt1 = "CRT1 not detected or forced off. %s.\n"; + static const char *mergednocrt2 = "No CRT2 output selected or no bridge detected. %s.\n"; + static const char *mergeddisstr = "MergedFB mode disabled"; + static const char *modesforstr = "Modes for CRT%d: *********************************************\n"; + static const char *crtsetupstr = "------------------------ CRT%d setup -------------------------\n"; +#endif +#if defined(SISDUALHEAD) || defined(SISMERGED) + static const char *notsuitablestr = "Not using mode \"%s\" (not suitable for %s mode)\n"; +#endif + + if(flags & PROBE_DETECT) { + if(xf86LoadSubModule(pScrn, "vbe")) { + int index = xf86GetEntityInfo(pScrn->entityList[0])->index; + #if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) - if((pVbe = VBEInit(NULL,index))) { + if((pVbe = VBEInit(NULL,index))) { #else - if((pVbe = VBEExtendedInit(NULL,index,0))) { + if((pVbe = VBEExtendedInit(NULL,index,0))) { #endif - ConfiguredMonitor = vbeDoEDID(pVbe, NULL); - vbeFree(pVbe); - } - } - return TRUE; + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + vbeFree(pVbe); + } + } + return TRUE; } /* @@ -1184,39 +2322,47 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) /* Check the number of entities, and fail if it isn't one. */ if(pScrn->numEntities != 1) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Number of entities is not 1\n"); - return FALSE; + SISErrorLog(pScrn, "Number of entities is not 1\n"); + return FALSE; } /* The vgahw module should be loaded here when needed */ if(!xf86LoadSubModule(pScrn, "vgahw")) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not load vgahw module\n"); - return FALSE; + SISErrorLog(pScrn, "Could not load vgahw module\n"); + return FALSE; } xf86LoaderReqSymLists(vgahwSymbols, NULL); xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "SiS driver (31/01/03-1) by " - "Thomas Winischhofer <thomas@winischhofer.net>\n"); + "SiS driver (%d/%02d/%02d-%d) by " + "Thomas Winischhofer <thomas@winischhofer.net>\n", + SISDRIVERVERSIONYEAR + 2000, SISDRIVERVERSIONMONTH, + SISDRIVERVERSIONDAY, SISDRIVERREVISION); xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "See http://www.winischhofer.net/linuxsisvga.shtml " - "for documentation and updates\n"); + "Compiled for XFree86 %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 XFree86!\n"); + } +#endif + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "See http://www.winischhofer.net/linuxsisvga.shtml " + "for documentation and updates\n"); /* Allocate a vgaHWRec */ if(!vgaHWGetHWRec(pScrn)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not allocate VGA private\n"); - return FALSE; + SISErrorLog(pScrn, "Could not allocate VGA private\n"); + return FALSE; } /* Allocate the SISRec driverPrivate */ if(!SISGetRec(pScrn)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not allocate memory for pSiS private\n"); - return FALSE; + SISErrorLog(pScrn, "Could not allocate memory for pSiS private\n"); + return FALSE; } pSiS = SISPTR(pScrn); pSiS->pScrn = pScrn; @@ -1230,26 +2376,24 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) /* Get the entity, and make sure it is PCI. */ pSiS->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if(pSiS->pEnt->location.type != BUS_PCI) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Entity's bus type is not PCI\n"); - SISFreeRec(pScrn); - return FALSE; + SISErrorLog(pScrn, "Entity's bus type is not PCI\n"); + SISFreeRec(pScrn); + return FALSE; } #ifdef SISDUALHEAD - /* TW: Allocate an entity private if necessary */ + /* Allocate an entity private if necessary */ if(xf86IsEntityShared(pScrn->entityList[0])) { - pSiSEnt = xf86GetEntityPrivate(pScrn->entityList[0], + pSiSEnt = xf86GetEntityPrivate(pScrn->entityList[0], SISEntityIndex)->ptr; - pSiS->entityPrivate = pSiSEnt; + pSiS->entityPrivate = pSiSEnt; - /* TW: If something went wrong, quit here */ - if ((pSiSEnt->DisableDual) || (pSiSEnt->ErrorAfterFirst)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "First head encountered fatal error, can't continue\n"); - SISFreeRec(pScrn); - return FALSE; - } + /* If something went wrong, quit here */ + if((pSiSEnt->DisableDual) || (pSiSEnt->ErrorAfterFirst)) { + SISErrorLog(pScrn, "First head encountered fatal error, can't continue\n"); + SISFreeRec(pScrn); + return FALSE; + } } #endif @@ -1266,16 +2410,15 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) if(pSiS->Primary) { VGAHWPTR(pScrn)->MapSize = 0x10000; /* Standard 64k VGA window */ if(!vgaHWMapMem(pScrn)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not map VGA memory\n"); + SISErrorLog(pScrn, "Could not map VGA memory\n"); SISFreeRec(pScrn); return FALSE; } } vgaHWGetIOBase(VGAHWPTR(pScrn)); - /* TW: We "patch" the PIOOffset inside vgaHW in order to force - * the vgaHW module to use our relocated i/o ports. + /* 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; @@ -1291,8 +2434,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->pInt = xf86InitInt10(pSiS->pEnt->index); #endif } else { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not load int10 module\n"); + SISErrorLog(pScrn, "Could not load int10 module\n"); } } @@ -1315,14 +2457,13 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) /* The ramdac module should be loaded here when needed */ if(!xf86LoadSubModule(pScrn, "ramdac")) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not load ramdac module\n"); + SISErrorLog(pScrn, "Could not load ramdac module\n"); #ifdef SISDUALHEAD - if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; + if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif - if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); - SISFreeRec(pScrn); - return FALSE; + if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + SISFreeRec(pScrn); + return FALSE; } xf86LoaderReqSymLists(ramdacSymbols, NULL); @@ -1334,32 +2475,32 @@ 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) { - pScrn->chipset = pSiS->pEnt->device->chipset; - pSiS->Chipset = xf86StringToToken(SISChipsets, pScrn->chipset); - from = X_CONFIG; - } else if (pSiS->pEnt->device->chipID >= 0) { - pSiS->Chipset = pSiS->pEnt->device->chipID; - pScrn->chipset = (char *)xf86TokenToString(SISChipsets, pSiS->Chipset); - - from = X_CONFIG; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", + if(pSiS->pEnt->device->chipset && *pSiS->pEnt->device->chipset) { + pScrn->chipset = pSiS->pEnt->device->chipset; + pSiS->Chipset = xf86StringToToken(SISChipsets, pScrn->chipset); + from = X_CONFIG; + } else if(pSiS->pEnt->device->chipID >= 0) { + pSiS->Chipset = pSiS->pEnt->device->chipID; + pScrn->chipset = (char *)xf86TokenToString(SISChipsets, pSiS->Chipset); + + from = X_CONFIG; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", pSiS->Chipset); } else { - from = X_PROBED; - pSiS->Chipset = pSiS->PciInfo->chipType; - pScrn->chipset = (char *)xf86TokenToString(SISChipsets, pSiS->Chipset); + from = X_PROBED; + pSiS->Chipset = pSiS->PciInfo->chipType; + pScrn->chipset = (char *)xf86TokenToString(SISChipsets, pSiS->Chipset); } - if (pSiS->pEnt->device->chipRev >= 0) { - pSiS->ChipRev = pSiS->pEnt->device->chipRev; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", + if(pSiS->pEnt->device->chipRev >= 0) { + pSiS->ChipRev = pSiS->pEnt->device->chipRev; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", pSiS->ChipRev); } else { - pSiS->ChipRev = pSiS->PciInfo->chipRev; + pSiS->ChipRev = pSiS->PciInfo->chipRev; } pSiS->sishw_ext.jChipRevision = pSiS->ChipRev; - /* TW: Determine SiS6326 chiprevision. This is not yet used for + /* Determine SiS6326 chiprevision. This is not yet used for * anything, but it will as soon as I found out on which revisions * the hardware video overlay really works. * According to SiS the only differences are: @@ -1370,19 +2511,19 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) */ pSiS->SiS6326Flags = 0; if(pSiS->Chipset == PCI_CHIP_SIS6326) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Chipset is SiS6326 %s (revision 0x%02x)\n", (pSiS->ChipRev == 0xaf) ? "(Ax)" : ((pSiS->ChipRev == 0x0a) ? "AGP (G0)" : ((pSiS->ChipRev == 0x0b) ? "AGP (H0)" : - (((pSiS->ChipRev & 0xf0) == 0xd0) ? "DVD (Dx)" : + (((pSiS->ChipRev & 0xf0) == 0xd0) ? "DVD (Dx/H0)" : (((pSiS->ChipRev & 0xf0) == 0x90) ? "(9x)" : (((pSiS->ChipRev & 0xf0) == 0xc0) ? "(Cx)" : "(unknown)"))))), pSiS->ChipRev); - if((pSiS->ChipRev != 0x0a) && (pSiS->ChipRev != 0x0b)) { + if((pSiS->ChipRev != 0x0a) && (pSiS->ChipRev != 0x0b)) { pSiS->SiS6326Flags |= SIS6326_HASTV; - } + } } @@ -1390,71 +2531,122 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) * This shouldn't happen because such problems should be caught in * SISProbe(), but check it just in case. */ - if (pScrn->chipset == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "ChipID 0x%04X is not recognised\n", pSiS->Chipset); + if(pScrn->chipset == NULL) { + SISErrorLog(pScrn, "ChipID 0x%04X is not recognised\n", pSiS->Chipset); #ifdef SISDUALHEAD - if (pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; + if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif - if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); - SISFreeRec(pScrn); - return FALSE; + if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + SISFreeRec(pScrn); + return FALSE; } - if (pSiS->Chipset < 0) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Chipset \"%s\" is not recognised\n", pScrn->chipset); + if(pSiS->Chipset < 0) { + SISErrorLog(pScrn, "Chipset \"%s\" is not recognised\n", pScrn->chipset); #ifdef SISDUALHEAD - if (pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; + if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif - if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); - SISFreeRec(pScrn); - return FALSE; + if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + SISFreeRec(pScrn); + return FALSE; } - /* TW: Determine chipset and VGA engine type for new mode switching code */ + /* Determine chipset and VGA engine type */ + pSiS->ChipFlags = 0; + pSiS->SiS_SD_Flags = 0; + switch(pSiS->Chipset) { case PCI_CHIP_SIS300: pSiS->sishw_ext.jChipType = SIS_300; pSiS->VGAEngine = SIS_300_VGA; + pSiS->SiS_SD_Flags |= SiS_SD_IS300SERIES; break; case PCI_CHIP_SIS630: /* 630 + 730 */ pSiS->sishw_ext.jChipType = SIS_630; if(pciReadLong(0x00000000, 0x00) == 0x07301039) { - pSiS->sishw_ext.jChipType = SIS_730; + pSiS->sishw_ext.jChipType = SIS_730; } pSiS->VGAEngine = SIS_300_VGA; + pSiS->SiS_SD_Flags |= SiS_SD_IS300SERIES; break; case PCI_CHIP_SIS540: pSiS->sishw_ext.jChipType = SIS_540; pSiS->VGAEngine = SIS_300_VGA; + pSiS->SiS_SD_Flags |= SiS_SD_IS300SERIES; break; case PCI_CHIP_SIS315H: pSiS->sishw_ext.jChipType = SIS_315H; pSiS->VGAEngine = SIS_315_VGA; + pSiS->ChipFlags |= SiSCF_315Core; + pSiS->SiS_SD_Flags |= SiS_SD_IS315SERIES; break; case PCI_CHIP_SIS315: - /* TW: Override for simplicity */ + /* Override for simplicity */ pSiS->Chipset = PCI_CHIP_SIS315H; pSiS->sishw_ext.jChipType = SIS_315; + pSiS->ChipFlags |= SiSCF_315Core; pSiS->VGAEngine = SIS_315_VGA; + pSiS->SiS_SD_Flags |= SiS_SD_IS315SERIES; break; case PCI_CHIP_SIS315PRO: - /* TW: Override for simplicity */ + /* Override for simplicity */ pSiS->Chipset = PCI_CHIP_SIS315H; pSiS->sishw_ext.jChipType = SIS_315PRO; + pSiS->ChipFlags |= SiSCF_315Core; pSiS->VGAEngine = SIS_315_VGA; + pSiS->SiS_SD_Flags |= SiS_SD_IS315SERIES; break; case PCI_CHIP_SIS550: pSiS->sishw_ext.jChipType = SIS_550; pSiS->VGAEngine = SIS_315_VGA; + pSiS->ChipFlags |= SiSCF_Integrated; + pSiS->SiS_SD_Flags |= SiS_SD_IS315SERIES; break; case PCI_CHIP_SIS650: /* 650 + 740 */ pSiS->sishw_ext.jChipType = SIS_650; + if(pciReadLong(0x00000000, 0x00) == 0x07401039) { + pSiS->sishw_ext.jChipType = SIS_740; + } pSiS->VGAEngine = SIS_315_VGA; + pSiS->ChipFlags |= (SiSCF_Integrated | SiSCF_Real256ECore); + pSiS->SiS_SD_Flags |= SiS_SD_IS315SERIES; break; case PCI_CHIP_SIS330: pSiS->sishw_ext.jChipType = SIS_330; - pSiS->VGAEngine = SIS_315_VGA; + pSiS->VGAEngine = SIS_315_VGA; + pSiS->ChipFlags |= SiSCF_XabreCore; + pSiS->SiS_SD_Flags |= SiS_SD_IS330SERIES; + break; + case PCI_CHIP_SIS660: /* 660, 661, 741, 760 */ + { + unsigned long hpciid = pciReadLong(0x00000000, 0x00); + switch(hpciid) { + case 0x06601039: + pSiS->sishw_ext.jChipType = SIS_660; + pSiS->ChipFlags |= SiSCF_Ultra256Core; + break; + case 0x07601039: + pSiS->sishw_ext.jChipType = SIS_760; + pSiS->ChipFlags |= SiSCF_Ultra256Core; + break; + case 0x07411039: + pSiS->sishw_ext.jChipType = SIS_741; + pSiS->ChipFlags |= SiSCF_Real256ECore; + break; + case 0x06611039: + default: + pSiS->sishw_ext.jChipType = SIS_661; + pSiS->ChipFlags |= SiSCF_Real256ECore; + } + /* Detection could also be done by CR5C & 0xf8: + 0x10 = 661 (CR5F & 0xc0: 0x00 both A0 and A1) + 0x80 = 760 (CR5F & 0xc0: 0x00 A0, 0x40 A1) + 0x90 = 741 (CR5F & 0xc0: 0x00 A0,A1 0x40 A2) + other: 660 (CR5F & 0xc0: 0x00 A0 0x40 A1) (DOA?) + */ + pSiS->VGAEngine = SIS_315_VGA; + pSiS->ChipFlags |= SiSCF_Integrated; + pSiS->SiS_SD_Flags |= SiS_SD_IS330SERIES; + } break; case PCI_CHIP_SIS530: pSiS->sishw_ext.jChipType = SIS_530; @@ -1466,172 +2658,194 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) break; } - /* TW: Now check if sisfb is loaded. Since sisfb only supports - * the 300 and 310/325 series, we only do this for these chips. + /* Now check if sisfb is loaded. Since sisfb only supports + * the 300 and 315 series, we only do this for these chips. * 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). - * That only works if sisfb is completely running, ie with - * a video mode (because the fbdev will not be installed otherwise.) + * Under kernel 2.4.y, 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 + * the framebuffer device in any way and running it with mode=none + * is no longer supported (or necessary). */ pSiS->donttrustpdc = FALSE; pSiS->sisfbpdc = 0; + pSiS->sisfblcda = 0xff; + pSiS->sisfbscalelcd = -1; + pSiS->sisfbspecialtiming = CUT_NONE; + pSiS->OldMode = 0; + pSiS->sisfbfound = FALSE; if(pSiS->VGAEngine == SIS_300_VGA || pSiS->VGAEngine == SIS_315_VGA) { int fd, i; sisfb_info mysisfbinfo; - BOOL found = FALSE; char name[10]; + CARD32 sisfbversion; - i=0; - do { - sprintf(name, "/dev/fb%1d", i); - if((fd = open(name, 'r'))) { + { + i=0; + do { + sprintf(name, "/dev/fb%1d", i); + if((fd = open(name, 'r')) != -1) { - if(!ioctl(fd, SISFB_GET_INFO, &mysisfbinfo)) { + if(!ioctl(fd, SISFB_GET_INFO, &mysisfbinfo)) { - if(mysisfbinfo.sisfb_id == SISFB_ID) { + if(mysisfbinfo.sisfb_id == SISFB_ID) { - if((mysisfbinfo.sisfb_version >= 1) && - (mysisfbinfo.sisfb_revision >=5) && - (mysisfbinfo.sisfb_patchlevel >= 8)) { - /* TW: Added PCI bus/slot/func into in sisfb Version 1.5.08. + 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) ) { - found = TRUE; - } - } else found = TRUE; - - if(found) { - 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, - pSiS->PciInfo->bus, - pSiS->PciInfo->device, - pSiS->PciInfo->func); - /* TW: 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; - /* TW: 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", pSiS->sisfbMem); - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "sisfb: using video mode 0x%02x\n", mysisfbinfo.fbvidmode); - if((mysisfbinfo.sisfb_version >= 1) && - (mysisfbinfo.sisfb_revision >=5) && - (mysisfbinfo.sisfb_patchlevel >= 6)) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "sisfb: %sreserved hardware cursor, using %s command queue\n", - (mysisfbinfo.sisfb_caps & 0x80) ? "" : "not ", - (mysisfbinfo.sisfb_caps & 0x40) ? "SiS300 series Turbo" : - (mysisfbinfo.sisfb_caps & 0x20) ? "SiS310/325 series AGP" : - (mysisfbinfo.sisfb_caps & 0x10) ? "SiS310/325 series VRAM" : - (mysisfbinfo.sisfb_caps & 0x08) ? "SiS310/325 series MMIO" : - "no"); - } - if((mysisfbinfo.sisfb_version >= 1) && - (mysisfbinfo.sisfb_revision >=5) && - (mysisfbinfo.sisfb_patchlevel >= 10)) { - /* TW: We can trust the pdc value if sisfb is of recent version */ - pSiS->donttrustpdc = FALSE; - if(mysisfbinfo.sisfb_patchlevel >= 11) { - pSiS->sisfbpdc = mysisfbinfo.sisfb_lcdpdc; + */ + 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, + "%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, + 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); + 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" : + "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(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; + } + } + } + } } - } - } - } - } - close (fd); - } - i++; - - } while((i <= 7) && (!found)); + } + } + close (fd); + } + i++; + } while((i <= 7) && (!pSiS->sisfbfound)); + if(!pSiS->sisfbfound) xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "sisfb not found\n"); + } } /* * The first thing we should figure out is the depth, bpp, etc. - * TW: Additionally, determine the size of the HWCursor memory - * area. + * Additionally, determine the size of the HWCursor memory area. */ - switch (pSiS->VGAEngine) { + switch(pSiS->VGAEngine) { case SIS_300_VGA: pSiS->CursorSize = 4096; - pix24flags = Support32bppFb | - SupportConvert24to32; + pix24flags = Support32bppFb; break; case SIS_315_VGA: pSiS->CursorSize = 16384; - pix24flags = Support32bppFb | - SupportConvert24to32; + pix24flags = Support32bppFb; break; case SIS_530_VGA: pSiS->CursorSize = 2048; pix24flags = Support32bppFb | - Support24bppFb | - SupportConvert24to32 | - SupportConvert32to24; + Support24bppFb; break; default: pSiS->CursorSize = 2048; - pix24flags = Support24bppFb | - SupportConvert32to24 | - PreferConvert32to24; + pix24flags = Support24bppFb; break; } #ifdef SISDUALHEAD - /* TW: In case of Dual Head, we need to determine if we are the "master" head or - * the "slave" head. In order to do that, we set PrimInit to DONE in the - * shared entity at the end of the first initialization. The second - * initialization then knows that some things have already been done. THIS - * ALWAYS ASSUMES THAT THE FIRST DEVICE INITIALIZED IS THE MASTER! + /* In case of Dual Head, we need to determine if we are the "master" head or + * the "slave" head. In order to do that, we set PrimInit to DONE in the + * shared entity at the end of the first initialization. The second + * initialization then knows that some things have already been done. THIS + * ALWAYS ASSUMES THAT THE FIRST DEVICE INITIALIZED IS THE MASTER! */ if(xf86IsEntityShared(pScrn->entityList[0])) { - if(pSiSEnt->lastInstance > 0) { - if(!xf86IsPrimInitDone(pScrn->entityList[0])) { - /* First Head (always CRT2) */ - pSiS->SecondHead = FALSE; - pSiSEnt->pScrn_1 = pScrn; - pSiSEnt->CRT1ModeNo = pSiSEnt->CRT2ModeNo = -1; - pSiS->DualHeadMode = TRUE; - pSiSEnt->DisableDual = FALSE; - pSiSEnt->BIOS = NULL; - pSiSEnt->SiS_Pr = NULL; - } else { - /* Second Head (always CRT1) */ - pSiS->SecondHead = TRUE; - pSiSEnt->pScrn_2 = pScrn; - pSiS->DualHeadMode = TRUE; - } - } else { - /* TW: Only one screen in config file - disable dual head mode */ - pSiS->SecondHead = FALSE; - pSiS->DualHeadMode = FALSE; - pSiSEnt->DisableDual = TRUE; - } + if(pSiSEnt->lastInstance > 0) { + if(!xf86IsPrimInitDone(pScrn->entityList[0])) { + /* First Head (always CRT2) */ + pSiS->SecondHead = FALSE; + pSiSEnt->pScrn_1 = pScrn; + pSiSEnt->CRT1ModeNo = pSiSEnt->CRT2ModeNo = -1; + pSiSEnt->CRT2ModeSet = FALSE; + pSiS->DualHeadMode = TRUE; + pSiSEnt->DisableDual = FALSE; + pSiSEnt->BIOS = NULL; + pSiSEnt->SiS_Pr = NULL; + pSiSEnt->RenderAccelArray = NULL; + } else { + /* Second Head (always CRT1) */ + pSiS->SecondHead = TRUE; + pSiSEnt->pScrn_2 = pScrn; + pSiS->DualHeadMode = TRUE; + } + } else { + /* Only one screen in config file - disable dual head mode */ + pSiS->SecondHead = FALSE; + pSiS->DualHeadMode = FALSE; + pSiSEnt->DisableDual = TRUE; + } } else { - /* TW: Entity is not shared - disable dual head mode */ - pSiS->SecondHead = FALSE; - pSiS->DualHeadMode = FALSE; + /* Entity is not shared - disable dual head mode */ + pSiS->SecondHead = FALSE; + pSiS->DualHeadMode = FALSE; } #endif pSiS->ForceCursorOff = FALSE; - /* TW: Allocate SiS_Private (for mode switching code) and initialize it */ + /* Allocate SiS_Private (for mode switching code) and initialize it */ pSiS->SiS_Pr = NULL; #ifdef SISDUALHEAD if(pSiSEnt) { @@ -1640,43 +2854,50 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) #endif if(!pSiS->SiS_Pr) { if(!(pSiS->SiS_Pr = xnfcalloc(sizeof(SiS_Private), 1))) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not allocate memory for SiS_Pr private\n"); + SISErrorLog(pScrn, "Could not allocate memory for SiS_Pr private\n"); #ifdef SISDUALHEAD - if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; + if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif - if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); - SISFreeRec(pScrn); - return FALSE; + if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + SISFreeRec(pScrn); + return FALSE; } #ifdef SISDUALHEAD if(pSiSEnt) pSiSEnt->SiS_Pr = pSiS->SiS_Pr; #endif memset(pSiS->SiS_Pr, 0, sizeof(SiS_Private)); + pSiS->SiS_Pr->SiS_Backup70xx = 0xff; + pSiS->SiS_Pr->SiS_CHOverScan = -1; + pSiS->SiS_Pr->SiS_ChSW = FALSE; + pSiS->SiS_Pr->SiS_CustomT = CUT_NONE; + pSiS->SiS_Pr->CRT1UsesCustomMode = FALSE; + pSiS->SiS_Pr->LVDSHL = -1; } - pSiS->SiS_Pr->SiS_Backup70xx = 0xff; - pSiS->SiS_Pr->SiS_CHOverScan = -1; - pSiS->SiS_Pr->SiS_ChSW = FALSE; - pSiS->SiS_Pr->CRT1UsesCustomMode = FALSE; - /* TW: Get our relocated IO registers */ - pSiS->RelIO = (pSiS->PciInfo->ioBase[2] & 0xFFFC) + pSiS->IODBase; - pSiS->sishw_ext.ulIOAddress = pSiS->RelIO + 0x30; + /* Get our relocated IO registers */ + pSiS->RelIO = (SISIOADDRESS)((pSiS->PciInfo->ioBase[2] & 0xFFFC) + 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); - /* TW: Initialize SiS Port Reg definitions for externally used - * BIOS emulation (init.c/init301.c) functions. + /* Initialize SiS Port Reg definitions for externally used + * init.c/init301.c functions. */ SiSRegInit(pSiS->SiS_Pr, pSiS->RelIO + 0x30); - /* TW: The following identifies the old chipsets. This is only - * partly used since the really old chips are not supported, - * but I keep it here for future use. + /* The following identifies the old chipsets. This is only + * partly used since the really old chips are not supported, + * but I keep it here for future use. + * 205, 215 and 225 are to be treated the same way, 201 and 202 + * are different. */ if(pSiS->VGAEngine == SIS_OLD_VGA || pSiS->VGAEngine == SIS_530_VGA) { switch(pSiS->Chipset) { - case PCI_CHIP_SG86C205: /* Just for making it complete */ + case PCI_CHIP_SG86C201: + pSiS->oldChipset = OC_SIS86201; break; + case PCI_CHIP_SG86C202: + pSiS->oldChipset = OC_SIS86202; break; + case PCI_CHIP_SG86C205: { unsigned char temp; sisSaveUnlockExtRegisterLock(pSiS, &srlockReg, &crlockReg); @@ -1686,65 +2907,80 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) OC_SIS6205C : OC_SIS6205A; break; } - case PCI_CHIP_SIS82C204: /* Just for making it complete */ + case PCI_CHIP_SIS82C204: pSiS->oldChipset = OC_SIS82204; break; - case 0x6225: /* Just for making it complete */ + case 0x6225: pSiS->oldChipset = OC_SIS6225; break; case PCI_CHIP_SIS5597: pSiS->oldChipset = OC_SIS5597; break; case PCI_CHIP_SIS6326: pSiS->oldChipset = OC_SIS6326; break; case PCI_CHIP_SIS530: - if((pSiS->ChipRev & 0x0f) < 0x0a) - pSiS->oldChipset = OC_SIS530A; - else pSiS->oldChipset = OC_SIS530B; + if(pciReadLong(0x00000000, 0x00) == 0x06201039) { + pSiS->oldChipset = OC_SIS620; + } else { + if((pSiS->ChipRev & 0x0f) < 0x0a) + pSiS->oldChipset = OC_SIS530A; + else pSiS->oldChipset = OC_SIS530B; + } break; default: pSiS->oldChipset = OC_UNKNOWN; } } - if(!xf86SetDepthBpp(pScrn, 8, 8, 8, pix24flags)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "xf86SetDepthBpp() error\n"); + if(!xf86SetDepthBpp(pScrn, 0, 0, 0, pix24flags)) { + SISErrorLog(pScrn, "xf86SetDepthBpp() error\n"); #ifdef SISDUALHEAD - if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; + if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif - if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); - SISFreeRec(pScrn); - return FALSE; + if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + SISFreeRec(pScrn); + return FALSE; } /* Check that the returned depth is one we support */ temp = 0; switch(pScrn->depth) { - case 8: - case 16: - case 24: - break; - case 15: - if((pSiS->VGAEngine == SIS_300_VGA) || - (pSiS->VGAEngine == SIS_315_VGA)) - temp = 1; - break; - default: - temp = 1; + case 8: + case 16: + case 24: + break; + case 15: + if((pSiS->VGAEngine == SIS_300_VGA) || + (pSiS->VGAEngine == SIS_315_VGA)) { + temp = 1; + } + break; + default: + temp = 1; } if(temp) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Given depth (%d) is not supported by this driver/chipset\n", + SISErrorLog(pScrn, + "Given color depth (%d) is not supported by this driver/chipset\n", pScrn->depth); - if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); - SISFreeRec(pScrn); - return FALSE; + if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + SISFreeRec(pScrn); + return FALSE; } xf86PrintDepthBpp(pScrn); + if( (((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) && + (pScrn->bitsPerPixel == 24)) || + ((pSiS->VGAEngine == SIS_OLD_VGA) && (pScrn->bitsPerPixel == 32)) ) { + SISErrorLog(pScrn, + "Framebuffer bpp %d not supported for this chipset\n", pScrn->bitsPerPixel); + if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + SISFreeRec(pScrn); + return FALSE; + } + /* Get the depth24 pixmap format */ - if(pScrn->depth == 24 && pix24bpp == 0) - pix24bpp = xf86GetBppFromDepth(pScrn, 24); + if(pScrn->depth == 24 && pix24bpp == 0) { + pix24bpp = xf86GetBppFromDepth(pScrn, 24); + } /* * This must happen after pScrn->display has been set because @@ -1755,8 +2991,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) rgb zeros = {0, 0, 0}; if(!xf86SetWeight(pScrn, zeros, zeros)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "xf86SetWeight() error\n"); + SISErrorLog(pScrn, "xf86SetWeight() error\n"); #ifdef SISDUALHEAD if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif @@ -1783,10 +3018,10 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) break; } if(ret) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "RGB Weight %d%d%d at depth %d not supported by hardware\n", - pScrn->weight.red, pScrn->weight.green, - pScrn->weight.blue, pScrn->depth); + SISErrorLog(pScrn, + "RGB weight %d%d%d at depth %d not supported by hardware\n", + (int)pScrn->weight.red, (int)pScrn->weight.green, + (int)pScrn->weight.blue, pScrn->depth); #ifdef SISDUALHEAD if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif @@ -1797,28 +3032,27 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) } } - /* TW: Set the current layout parameters */ + /* Set the current layout parameters */ pSiS->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel; pSiS->CurrentLayout.depth = pScrn->depth; /* (Inside this function, we can use pScrn's contents anyway) */ if(!xf86SetDefaultVisual(pScrn, -1)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "xf86SetDefaultVisual() error\n"); + SISErrorLog(pScrn, "xf86SetDefaultVisual() error\n"); #ifdef SISDUALHEAD - if (pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; + if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); SISFreeRec(pScrn); return FALSE; } else { /* We don't support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual " - "(%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); + if(pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { + SISErrorLog(pScrn, + "Given default visual (%s) is not supported at depth %d\n", + xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); #ifdef SISDUALHEAD - if (pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; + if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); SISFreeRec(pScrn); @@ -1826,6 +3060,17 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) } } +#ifdef SISDUALHEAD + /* Due to palette & timing problems we don't support 8bpp in DHM */ + if((pSiS->DualHeadMode) && (pScrn->bitsPerPixel == 8)) { + SISErrorLog(pScrn, "Color depth 8 not supported in Dual Head mode.\n"); + if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; + if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + SISFreeRec(pScrn); + return FALSE; + } +#endif + /* * The cmap layer needs this to be initialised. */ @@ -1833,8 +3078,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) Gamma zeros = {0.0, 0.0, 0.0}; if(!xf86SetGamma(pScrn, zeros)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "xf86SetGamma() error\n"); + SISErrorLog(pScrn, "xf86SetGamma() error\n"); #ifdef SISDUALHEAD if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif @@ -1849,35 +3093,29 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) /* Set the bits per RGB for 8bpp mode */ if(pScrn->depth == 8) { - pScrn->rgbBits = 6; + pScrn->rgbBits = 6; } - pSiS->ddc1Read = SiSddc1Read; - from = X_DEFAULT; /* Unlock registers */ sisSaveUnlockExtRegisterLock(pSiS, &srlockReg, &crlockReg); - /* TW: We need no backup area (300/310/325 new mode switching code) */ - pSiS->sishw_ext.pSR = NULL; - pSiS->sishw_ext.pCR = NULL; - - /* TW: Read BIOS for 300 and 310/325 series customization */ + /* Read BIOS for 300 and 315/330 series customization */ pSiS->sishw_ext.pjVirtualRomBase = NULL; pSiS->BIOS = NULL; pSiS->sishw_ext.UseROM = FALSE; if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { #ifdef SISDUALHEAD - if(pSiSEnt) { + if(pSiSEnt) { if(pSiSEnt->BIOS) { - pSiS->BIOS = pSiSEnt->BIOS; - pSiS->sishw_ext.pjVirtualRomBase = pSiS->BIOS; + pSiS->BIOS = pSiSEnt->BIOS; + pSiS->sishw_ext.pjVirtualRomBase = pSiS->BIOS; } - } + } #endif - if(!pSiS->BIOS) { + if(!pSiS->BIOS) { if(!(pSiS->BIOS = xcalloc(1, BIOS_SIZE))) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Could not allocate memory for video BIOS image\n"); @@ -1887,15 +3125,15 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) BOOLEAN found; int i; static const char sis_rom_sig[] = "Silicon Integrated Systems"; - static const char *sis_sig[10] = { + static const char *sis_sig[15] = { "300", "540", "630", "730", - "315", "315", "315", "5315", "6325", - "Xabre" + "315", "315", "315", "5315", "6325", "6325", + "Xabre", "6330", "6330", "6330", "6330" }; - static const unsigned short sis_nums[10] = { + static const unsigned short sis_nums[15] = { SIS_300, SIS_540, SIS_630, SIS_730, - SIS_315PRO, SIS_315H, SIS_315, SIS_550, SIS_650, - SIS_330 + SIS_315PRO, SIS_315H, SIS_315, SIS_550, SIS_650, SIS_740, + SIS_330, SIS_661, SIS_741, SIS_660, SIS_760 }; found = FALSE; @@ -1915,16 +3153,21 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) romptr = pSiS->BIOS[0x14] | (pSiS->BIOS[0x15] << 8); if(romptr > (BIOS_SIZE - 5)) continue; - for(i = 0; (i < 10) && (!found); i++) { - if(strncmp(sis_sig[i], (char *)&pSiS->BIOS[romptr], strlen(sis_sig[i])) == 0) { - if(sis_nums[i] == pSiS->sishw_ext.jChipType) { - found = TRUE; - break; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Ignoring BIOS for SiS %s at %p\n", sis_sig[i], segstart); - } - } + for(i = 0; (i < 15) && (!found); i++) { + if(strncmp(sis_sig[i], (char *)&pSiS->BIOS[romptr], strlen(sis_sig[i])) == 0) { + if(sis_nums[i] == pSiS->sishw_ext.jChipType) { + found = TRUE; + break; + } else { + if((pSiS->sishw_ext.jChipType != SIS_740) && + (pSiS->sishw_ext.jChipType != SIS_661) && + (pSiS->sishw_ext.jChipType != SIS_741) && + (pSiS->sishw_ext.jChipType != SIS_660)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Ignoring BIOS for SiS %s at 0x%lx\n", sis_sig[i], segstart); + } + } + } } if(found) break; } @@ -1941,38 +3184,48 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->sishw_ext.pjVirtualRomBase = pSiS->BIOS; romptr = pSiS->BIOS[0x16] | (pSiS->BIOS[0x17] << 8); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Video BIOS version \"%7s\" found at %p\n", + "Video BIOS version \"%7s\" found at 0x%lx\n", &pSiS->BIOS[romptr], segstart); } - } - } - if(pSiS->BIOS) pSiS->sishw_ext.UseROM = TRUE; - else pSiS->sishw_ext.UseROM = FALSE; + } + if(pSiS->BIOS) pSiS->sishw_ext.UseROM = TRUE; + else pSiS->sishw_ext.UseROM = FALSE; } /* Evaluate options */ SiSOptions(pScrn); +#ifdef SISMERGED + /* Due to palette & timing problems we don't support 8bpp in MFBM */ + if((pSiS->MergedFB) && (pScrn->bitsPerPixel == 8)) { + SISErrorLog(pScrn, "MergedFB: Color depth 8 not supported, %s\n", mergeddisstr); + pSiS->MergedFB = pSiS->MergedFBAuto = FALSE; + } +#endif + #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { if(!pSiS->SecondHead) { - /* TW: Copy some option settings to entity private */ + /* Copy some option settings to entity private */ pSiSEnt->HWCursor = pSiS->HWCursor; + pSiSEnt->NoAccel = pSiS->NoAccel; + pSiSEnt->restorebyset = pSiS->restorebyset; + pSiSEnt->OptROMUsage = pSiS->OptROMUsage; + pSiSEnt->OptUseOEM = pSiS->OptUseOEM; + pSiSEnt->TurboQueue = pSiS->TurboQueue; + pSiSEnt->forceCRT1 = pSiS->forceCRT1; + pSiSEnt->ForceCRT1Type = pSiS->ForceCRT1Type; pSiSEnt->ForceCRT2Type = pSiS->ForceCRT2Type; pSiSEnt->ForceTVType = pSiS->ForceTVType; - pSiSEnt->TurboQueue = pSiS->TurboQueue; + pSiSEnt->UsePanelScaler = pSiS->UsePanelScaler; pSiSEnt->PDC = pSiS->PDC; + pSiSEnt->DSTN = pSiS->DSTN; pSiSEnt->OptTVStand = pSiS->OptTVStand; pSiSEnt->NonDefaultPAL = pSiS->NonDefaultPAL; + pSiSEnt->NonDefaultNTSC = pSiS->NonDefaultNTSC; pSiSEnt->OptTVOver = pSiS->OptTVOver; pSiSEnt->OptTVSOver = pSiS->OptTVSOver; - pSiSEnt->OptROMUsage = pSiS->OptROMUsage; - pSiSEnt->DSTN = pSiS->DSTN; - pSiSEnt->XvOnCRT2 = pSiS->XvOnCRT2; - pSiSEnt->NoAccel = pSiS->NoAccel; - pSiSEnt->NoXvideo = pSiS->NoXvideo; - pSiSEnt->forceCRT1 = pSiS->forceCRT1; pSiSEnt->chtvlumabandwidthcvbs = pSiS->chtvlumabandwidthcvbs; pSiSEnt->chtvlumabandwidthsvideo = pSiS->chtvlumabandwidthsvideo; pSiSEnt->chtvlumaflickerfilter = pSiS->chtvlumaflickerfilter; @@ -1984,9 +3237,28 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiSEnt->sistvedgeenhance = pSiS->sistvedgeenhance; pSiSEnt->sistvantiflicker = pSiS->sistvantiflicker; pSiSEnt->sistvsaturation = pSiS->sistvsaturation; + pSiSEnt->sistvcfilter = pSiS->sistvcfilter; + pSiSEnt->sistvyfilter = pSiS->sistvyfilter; + pSiSEnt->sistvcolcalibc = pSiS->sistvcolcalibc; + pSiSEnt->sistvcolcalibf = pSiS->sistvcolcalibf; pSiSEnt->tvxpos = pSiS->tvxpos; pSiSEnt->tvypos = pSiS->tvypos; - pSiSEnt->restorebyset = pSiS->restorebyset; + pSiSEnt->tvxscale = pSiS->tvxscale; + pSiSEnt->tvyscale = pSiS->tvyscale; + pSiSEnt->CRT1gamma = pSiS->CRT1gamma; + pSiSEnt->CRT1gammaGiven = pSiS->CRT1gammaGiven; + pSiSEnt->XvGammaRed = pSiS->XvGammaRed; + pSiSEnt->XvGammaGreen = pSiS->XvGammaGreen; + pSiSEnt->XvGammaBlue = pSiS->XvGammaBlue; + pSiSEnt->XvGamma = pSiS->XvGamma; + pSiSEnt->XvGammaGiven = pSiS->XvGammaGiven; + pSiSEnt->CRT2gamma = pSiS->CRT2gamma; + pSiSEnt->XvOnCRT2 = pSiS->XvOnCRT2; + pSiSEnt->AllowHotkey = pSiS->AllowHotkey; + pSiSEnt->enablesisctrl = pSiS->enablesisctrl; +#ifdef SIS_CP + SIS_CP_DRIVER_COPYOPTIONSENT +#endif } else { /* We always use same cursor type on both screens */ if(pSiS->HWCursor != pSiSEnt->HWCursor) { @@ -1997,85 +3269,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) "Master head ruled: HWCursor shall be %s\n", pSiS->HWCursor ? "enabled" : "disabled"); } - /* We need to use identical CRT2 Type setting */ - if(pSiS->ForceCRT2Type != pSiSEnt->ForceCRT2Type) { - if(pSiS->ForceCRT2Type != CRT2_DEFAULT) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Ignoring inconsistent ForceCRT2Type setting. Master head rules\n"); - } - pSiS->ForceCRT2Type = pSiSEnt->ForceCRT2Type; - } - if(pSiS->ForceTVType != pSiSEnt->ForceTVType) { - if(pSiS->ForceTVType != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Ignoring inconsistent ForceTVType setting. Master head rules\n"); - } - pSiS->ForceTVType = pSiSEnt->ForceTVType; - } - /* We need identical TurboQueue setting */ - if(pSiS->TurboQueue != pSiSEnt->TurboQueue) { - pSiS->TurboQueue = pSiSEnt->TurboQueue; - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent TurboQueue setting\n"); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Master head ruled: Turboqueue shall be %s\n", - pSiS->TurboQueue ? "enabled" : "disabled"); - } - /* We need identical PDC setting */ - if(pSiS->PDC != pSiSEnt->PDC) { - pSiS->PDC = pSiSEnt->PDC; - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent PanelDelayCompensation setting\n"); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Master head ruled: PanelDelayCompensation shall be %d%s\n", - pSiS->PDC, - (pSiS->PDC == -1) ? " (autodetected)" : ""); - } - /* We need identical TVStandard setting */ - if( (pSiS->OptTVStand != pSiSEnt->OptTVStand) || - (pSiS->NonDefaultPAL != pSiSEnt->NonDefaultPAL) ) { - if(pSiS->OptTVStand != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent TVStandard setting\n"); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Master head ruled: TVStandard shall be %s\n", - (pSiSEnt->OptTVStand ? - ( (pSiSEnt->NonDefaultPAL == -1) ? "PAL" : - ((pSiSEnt->NonDefaultPAL) ? "PALM" : "PALN") ) - : "NTSC")); - } - pSiS->OptTVStand = pSiSEnt->OptTVStand; - pSiS->NonDefaultPAL = pSiSEnt->NonDefaultPAL; - } - /* We need identical UseROMData setting */ - if(pSiS->OptROMUsage != pSiSEnt->OptROMUsage) { - if(pSiS->OptROMUsage != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent UseROMData setting\n"); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Master head ruled: Video ROM data usage shall be %s\n", - pSiSEnt->OptROMUsage ? "enabled" : "disabled"); - } - pSiS->OptROMUsage = pSiSEnt->OptROMUsage; - } - /* We need identical DSTN setting */ - if(pSiS->DSTN != pSiSEnt->DSTN) { - pSiS->DSTN = pSiSEnt->DSTN; - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent DSTN setting\n"); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Master head ruled: DSTN shall be %s\n", - pSiS->DSTN ? "enabled" : "disabled"); - } - /* We need identical XvOnCRT2 setting */ - if(pSiS->XvOnCRT2 != pSiSEnt->XvOnCRT2) { - pSiS->XvOnCRT2 = pSiSEnt->XvOnCRT2; - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent XvOnCRT2 setting\n"); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Master head ruled: Xv shall be used on CRT%d\n", - pSiS->XvOnCRT2 ? 2 : 1); - } + /* We need identical NoAccel setting */ if(pSiS->NoAccel != pSiSEnt->NoAccel) { pSiS->NoAccel = pSiSEnt->NoAccel; @@ -2085,197 +3279,103 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) "Master head ruled: Acceleration shall be %s\n", pSiS->NoAccel ? "disabled" : "enabled"); } - /* We need identical ForceCRT1 setting */ - if(pSiS->forceCRT1 != pSiSEnt->forceCRT1) { - if(pSiS->forceCRT1 != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent ForceCRT1 setting\n"); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Master head ruled: CRT1 shall be %s\n", - pSiSEnt->forceCRT1 ? "enabled" : "disabled"); - } - pSiS->forceCRT1 = pSiSEnt->forceCRT1; - } - /* We need identical TVOverscan setting */ - if(pSiS->OptTVOver != pSiSEnt->OptTVOver) { - if(pSiS->OptTVOver != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent CHTVOverscan setting\n"); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Master head ruled: CHTVOverscan shall be %s\n", - pSiSEnt->OptTVOver ? "true (=overscan)" : "false (=underscan)"); - } - pSiS->OptTVOver = pSiSEnt->OptTVOver; - } - /* We need identical TVSOverscan setting */ - if(pSiS->OptTVSOver != pSiSEnt->OptTVSOver) { - if(pSiS->OptTVSOver != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent CHTVSuperOverscan setting\n"); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Master head ruled: CHTVSuperOverscan shall be %s\n", - pSiSEnt->OptTVSOver ? "true" : "false"); - } - pSiS->OptTVSOver = pSiSEnt->OptTVSOver; - } - /* We need identical TV settings */ - if(pSiS->chtvtype != pSiSEnt->chtvtype) { - if(pSiS->chtvtype != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent CHTVType setting; set to %s\n", - (pSiSEnt->chtvtype) ? "SCART" : "HDTV"); - } - pSiS->chtvtype = pSiSEnt->chtvtype; - } - if(pSiS->chtvlumabandwidthcvbs != pSiSEnt->chtvlumabandwidthcvbs) { - if(pSiS->chtvlumabandwidthcvbs != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent CHTVLumaBandWidthCVBS setting; set to %d\n", - pSiSEnt->chtvlumabandwidthcvbs); - } - pSiS->chtvlumabandwidthcvbs = pSiSEnt->chtvlumabandwidthcvbs; - } - if(pSiS->chtvlumabandwidthsvideo != pSiSEnt->chtvlumabandwidthsvideo) { - if(pSiS->chtvlumabandwidthsvideo != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent CHTVLumaBandWidthSVIDEO setting; set to %d\n", - pSiSEnt->chtvlumabandwidthsvideo); - } - pSiS->chtvlumabandwidthsvideo = pSiSEnt->chtvlumabandwidthsvideo; - } - if(pSiS->chtvlumaflickerfilter != pSiSEnt->chtvlumaflickerfilter) { - if(pSiS->chtvlumaflickerfilter != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent CHTVLumaFlickerFilter setting; set to %d\n", - pSiSEnt->chtvlumaflickerfilter); - } - pSiS->chtvlumaflickerfilter = pSiSEnt->chtvlumaflickerfilter; - } - if(pSiS->chtvchromabandwidth != pSiSEnt->chtvchromabandwidth) { - if(pSiS->chtvchromabandwidth != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent CHTVChromaBandWidth setting; set to %d\n", - pSiSEnt->chtvchromabandwidth); - } - pSiS->chtvchromabandwidth = pSiSEnt->chtvchromabandwidth; - } - if(pSiS->chtvchromaflickerfilter != pSiSEnt->chtvchromaflickerfilter) { - if(pSiS->chtvchromaflickerfilter != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent CHTVChromaFlickerFilter setting; set to %d\n", - pSiSEnt->chtvchromaflickerfilter); - } - pSiS->chtvchromaflickerfilter = pSiSEnt->chtvchromaflickerfilter; - } - if(pSiS->chtvcvbscolor != pSiSEnt->chtvcvbscolor) { - if(pSiS->chtvcvbscolor != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent CHTVCVBSColor setting; set to %s\n", - pSiSEnt->chtvcvbscolor ? "true" : "false"); - } - pSiS->chtvcvbscolor = pSiSEnt->chtvcvbscolor; - } - if(pSiS->chtvtextenhance != pSiSEnt->chtvtextenhance) { - if(pSiS->chtvtextenhance != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent CHTVTextEnhance setting; set to %d\n", - pSiSEnt->chtvtextenhance); - } - pSiS->chtvtextenhance = pSiSEnt->chtvtextenhance; - } - if(pSiS->chtvcontrast != pSiSEnt->chtvcontrast) { - if(pSiS->chtvcontrast != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent CHTVContrast setting; set to %d\n", - pSiSEnt->chtvcontrast); - } - pSiS->chtvcontrast = pSiSEnt->chtvcontrast; - } - if(pSiS->sistvedgeenhance != pSiSEnt->sistvedgeenhance) { - if(pSiS->sistvedgeenhance != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent SISTVEdgeEnhance setting; set to %d\n", - pSiSEnt->sistvedgeenhance); - } - pSiS->sistvedgeenhance = pSiSEnt->sistvedgeenhance; - } - if(pSiS->sistvantiflicker != pSiSEnt->sistvantiflicker) { - if(pSiS->sistvantiflicker != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent SISTVAntiFlicker setting; set to %d\n", - pSiSEnt->sistvantiflicker); - } - pSiS->sistvantiflicker = pSiSEnt->sistvantiflicker; - } - if(pSiS->sistvsaturation != pSiSEnt->sistvsaturation) { - if(pSiS->sistvsaturation != -1) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent SISTVSaturation setting; set to %d\n", - pSiSEnt->sistvsaturation); - } - pSiS->sistvsaturation = pSiSEnt->sistvsaturation; - } - if(pSiS->tvxpos != pSiSEnt->tvxpos) { - if(pSiS->tvxpos != 0) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent TVXPosOffset setting; set to %d\n", - pSiSEnt->tvxpos); - } - pSiS->tvxpos = pSiSEnt->tvxpos; + + pSiS->TurboQueue = pSiSEnt->TurboQueue; + pSiS->restorebyset = pSiSEnt->restorebyset; + pSiS->AllowHotkey = pSiS->AllowHotkey; + pSiS->OptROMUsage = pSiSEnt->OptROMUsage; + pSiS->OptUseOEM = pSiSEnt->OptUseOEM; + pSiS->forceCRT1 = pSiSEnt->forceCRT1; + pSiS->nocrt2ddcdetection = FALSE; + pSiS->forcecrt2redetection = FALSE; + pSiS->ForceCRT1Type = pSiSEnt->ForceCRT1Type; + pSiS->ForceCRT2Type = pSiSEnt->ForceCRT2Type; + pSiS->UsePanelScaler = pSiSEnt->UsePanelScaler; + pSiS->PDC = pSiSEnt->PDC; + pSiS->DSTN = pSiSEnt->DSTN; + pSiS->OptTVStand = pSiSEnt->OptTVStand; + pSiS->NonDefaultPAL = pSiSEnt->NonDefaultPAL; + pSiS->NonDefaultNTSC = pSiSEnt->NonDefaultNTSC; + pSiS->chtvtype = pSiSEnt->chtvtype; + pSiS->ForceTVType = pSiSEnt->ForceTVType; + pSiS->OptTVOver = pSiSEnt->OptTVOver; + pSiS->OptTVSOver = pSiSEnt->OptTVSOver; + pSiS->chtvlumabandwidthcvbs = pSiSEnt->chtvlumabandwidthcvbs; + pSiS->chtvlumabandwidthsvideo = pSiSEnt->chtvlumabandwidthsvideo; + pSiS->chtvlumaflickerfilter = pSiSEnt->chtvlumaflickerfilter; + pSiS->chtvchromabandwidth = pSiSEnt->chtvchromabandwidth; + pSiS->chtvchromaflickerfilter = pSiSEnt->chtvchromaflickerfilter; + pSiS->chtvcvbscolor = pSiSEnt->chtvcvbscolor; + pSiS->chtvtextenhance = pSiSEnt->chtvtextenhance; + pSiS->chtvcontrast = pSiSEnt->chtvcontrast; + pSiS->sistvedgeenhance = pSiSEnt->sistvedgeenhance; + pSiS->sistvantiflicker = pSiSEnt->sistvantiflicker; + pSiS->sistvsaturation = pSiSEnt->sistvsaturation; + pSiS->sistvcfilter = pSiSEnt->sistvcfilter; + pSiS->sistvyfilter = pSiSEnt->sistvyfilter; + pSiS->sistvcolcalibc = pSiSEnt->sistvcolcalibc; + pSiS->sistvcolcalibf = pSiSEnt->sistvcolcalibf; + pSiS->tvxpos = pSiSEnt->tvxpos; + pSiS->tvypos = pSiSEnt->tvypos; + pSiS->tvxscale = pSiSEnt->tvxscale; + pSiS->tvyscale = pSiSEnt->tvyscale; + if(!pSiS->CRT1gammaGiven) { + if(pSiSEnt->CRT1gammaGiven) + pSiS->CRT1gamma = pSiSEnt->CRT1gamma; } - if(pSiS->tvypos != pSiSEnt->tvypos) { - if(pSiS->tvypos != 0) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Ignoring inconsistent TVYPosOffset setting; set to %d\n", - pSiSEnt->tvypos); + pSiS->CRT2gamma = pSiSEnt->CRT2gamma; + if(!pSiS->XvGammaGiven) { + if(pSiSEnt->XvGammaGiven) { + pSiS->XvGamma = pSiSEnt->XvGamma; + pSiS->XvGammaRed = pSiS->XvGammaRedDef = pSiSEnt->XvGammaRed; + pSiS->XvGammaGreen = pSiS->XvGammaGreenDef = pSiSEnt->XvGammaGreen; + pSiS->XvGammaBlue = pSiS->XvGammaBlueDef = pSiSEnt->XvGammaBlue; } - pSiS->tvypos = pSiSEnt->tvypos; - } - if(pSiS->restorebyset != pSiSEnt->restorebyset) { - pSiS->restorebyset = pSiSEnt->restorebyset; } + pSiS->XvOnCRT2 = pSiSEnt->XvOnCRT2; + pSiS->enablesisctrl = pSiSEnt->enablesisctrl; + /* Copy gamma brightness to Ent for Xinerama */ + pSiSEnt->GammaBriR = pSiS->GammaBriR; + pSiSEnt->GammaBriG = pSiS->GammaBriG; + pSiSEnt->GammaBriB = pSiS->GammaBriB; + pSiSEnt->GammaPBriR = pSiS->GammaPBriR; + pSiSEnt->GammaPBriG = pSiS->GammaPBriG; + pSiSEnt->GammaPBriB = pSiS->GammaPBriB; +#ifdef SIS_CP + SIS_CP_DRIVER_COPYOPTIONS +#endif } } #endif - /* TW: Handle UseROMData and NoOEM options */ + + /* Handle UseROMData, NoOEM and UsePanelScaler options */ if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { from = X_PROBED; if(pSiS->OptROMUsage == 0) { - pSiS->sishw_ext.UseROM = FALSE; - from = X_CONFIG; + pSiS->sishw_ext.UseROM = FALSE; + from = X_CONFIG; + xf86DrvMsg(pScrn->scrnIndex, from, "Video ROM data usage is disabled\n"); } - xf86DrvMsg(pScrn->scrnIndex, from, "Video ROM data usage is %s\n", - pSiS->sishw_ext.UseROM ? "enabled" : "disabled"); if(!pSiS->OptUseOEM) - xf86DrvMsg(pScrn->scrnIndex, from, "Internal OEM LCD/TV data usage is disabled\n"); - - if(pSiS->sbiosn) { - if(pSiS->BIOS) { - FILE *fd = NULL; - int i; - if((fd = fopen(pSiS->sbiosn, "w" ))) { - i = fwrite(pSiS->BIOS, 65536, 1, fd); - fclose(fd); - } - } - xfree(pSiS->sbiosn); - } + xf86DrvMsg(pScrn->scrnIndex, from, "Internal OEM LCD/TV/VGA2 data usage is disabled\n"); + + pSiS->SiS_Pr->UsePanelScaler = pSiS->UsePanelScaler; } /* Do basic configuration */ SiSSetup(pScrn); from = X_PROBED; - if (pSiS->pEnt->device->MemBase != 0) { - /* - * XXX Should check that the config file value matches one of the - * PCI base address values. - */ - pSiS->FbAddress = pSiS->pEnt->device->MemBase; - from = X_CONFIG; + if(pSiS->pEnt->device->MemBase != 0) { + /* + * XXX Should check that the config file value matches one of the + * PCI base address values. + */ + pSiS->FbAddress = pSiS->pEnt->device->MemBase; + from = X_CONFIG; } else { - pSiS->FbAddress = pSiS->PciInfo->memBase[0] & 0xFFFFFFF0; + pSiS->FbAddress = pSiS->PciInfo->memBase[0] & 0xFFFFFFF0; } pSiS->realFbAddress = pSiS->FbAddress; @@ -2289,15 +3389,15 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, from, "Linear framebuffer at 0x%lX\n", (unsigned long)pSiS->FbAddress); - if (pSiS->pEnt->device->IOBase != 0) { + if(pSiS->pEnt->device->IOBase != 0) { /* * XXX Should check that the config file value matches one of the * PCI base address values. */ - pSiS->IOAddress = pSiS->pEnt->device->IOBase; - from = X_CONFIG; + pSiS->IOAddress = pSiS->pEnt->device->IOBase; + from = X_CONFIG; } else { - pSiS->IOAddress = pSiS->PciInfo->memBase[1] & 0xFFFFFFF0; + pSiS->IOAddress = pSiS->PciInfo->memBase[1] & 0xFFFFFFF0; } xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at 0x%lX\n", @@ -2306,24 +3406,29 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) /* Register the PCI-assigned resources. */ if(xf86RegisterResources(pSiS->pEnt->index, NULL, ResExclusive)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "xf86RegisterResources() found resource conflicts\n"); + SISErrorLog(pScrn, "xf86RegisterResources() found resource conflicts\n"); #ifdef SISDUALHEAD - if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; + if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif - if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); - sisRestoreExtRegisterLock(pSiS,srlockReg,crlockReg); - SISFreeRec(pScrn); - return FALSE; + if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + sisRestoreExtRegisterLock(pSiS,srlockReg,crlockReg); + SISFreeRec(pScrn); + return FALSE; } from = X_PROBED; - if (pSiS->pEnt->device->videoRam != 0) { - pScrn->videoRam = pSiS->pEnt->device->videoRam; - from = X_CONFIG; + if(pSiS->pEnt->device->videoRam != 0) { + if(pSiS->Chipset == PCI_CHIP_SIS6326) { + pScrn->videoRam = pSiS->pEnt->device->videoRam; + from = X_CONFIG; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Option \"VideoRAM\" ignored\n"); + } } pSiS->RealVideoRam = pScrn->videoRam; + if((pSiS->Chipset == PCI_CHIP_SIS6326) && (pScrn->videoRam > 4096) && (from != X_CONFIG)) { @@ -2331,9 +3436,10 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, from, "SiS6326: Detected %d KB VideoRAM, limiting to %d KB\n", pSiS->RealVideoRam, pScrn->videoRam); - } else + } else { xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d KB\n", pScrn->videoRam); + } if((pSiS->Chipset == PCI_CHIP_SIS6326) && (pScrn->videoRam > 4096)) { @@ -2351,21 +3457,27 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->sishw_ext.ulVideoMemorySize = pScrn->videoRam * 1024; pSiS->sishw_ext.bSkipDramSizing = TRUE; - /* TW: Calculate real availMem according to Accel/TurboQueue and - * HWCursur setting. Also, initialize some variables used - * in other modules. + /* Calculate real availMem according to Accel/TurboQueue and + * HWCursur setting. Also, initialize some variables used + * in other modules. */ + pSiS->cursorOffset = 0; - switch (pSiS->VGAEngine) { + pSiS->CurARGBDest = NULL; + pSiS->CurMonoSrc = NULL; + pSiS->CurFGCol = pSiS->CurBGCol = 0; + + switch(pSiS->VGAEngine) { + case SIS_300_VGA: pSiS->TurboQueueLen = 512; if(pSiS->TurboQueue) { - pSiS->availMem -= (pSiS->TurboQueueLen*1024); - pSiS->cursorOffset = 512; + pSiS->availMem -= (pSiS->TurboQueueLen*1024); + pSiS->cursorOffset = 512; } - if(pSiS->HWCursor) { - pSiS->availMem -= pSiS->CursorSize; - if(pSiS->OptUseColorCursor) pSiS->availMem -= pSiS->CursorSize; + if(pSiS->HWCursor) { + pSiS->availMem -= pSiS->CursorSize; + if(pSiS->OptUseColorCursor) pSiS->availMem -= pSiS->CursorSize; } pSiS->CmdQueLenMask = 0xFFFF; pSiS->CmdQueLenFix = 0; @@ -2374,150 +3486,255 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) if(pSiSEnt) pSiSEnt->cursorBufferNum = 0; #endif break; + case SIS_315_VGA: +#ifdef SISVRAMQ + pSiS->cmdQueueSizeMask = pSiS->cmdQueueSize - 1; /* VRAM Command Queue is variable (in therory) */ + pSiS->cmdQueueOffset = (pScrn->videoRam * 1024) - pSiS->cmdQueueSize; + pSiS->cmdQueueLen = 0; + pSiS->cmdQueueLenMin = 0x200; + pSiS->cmdQueueLenMax = pSiS->cmdQueueSize - pSiS->cmdQueueLenMin; + pSiS->cmdQueueSize_div2 = pSiS->cmdQueueSize / 2; + pSiS->cmdQueueSize_div4 = pSiS->cmdQueueSize / 4; + pSiS->cmdQueueSize_4_3 = (pSiS->cmdQueueSize / 4) * 3; + pSiS->availMem -= pSiS->cmdQueueSize; + pSiS->cursorOffset = (pSiS->cmdQueueSize / 1024); +#else if(pSiS->TurboQueue) { - pSiS->availMem -= (512*1024); /* Command Queue is 512k */ - pSiS->cursorOffset = 512; + pSiS->availMem -= (512*1024); /* MMIO Command Queue is 512k (variable in theory) */ + pSiS->cursorOffset = 512; } - if(pSiS->HWCursor) { - pSiS->availMem -= pSiS->CursorSize; - if(pSiS->OptUseColorCursor) pSiS->availMem -= pSiS->CursorSize; +#endif + if(pSiS->HWCursor) { + pSiS->availMem -= pSiS->CursorSize; + if(pSiS->OptUseColorCursor) pSiS->availMem -= pSiS->CursorSize; } pSiS->cursorBufferNum = 0; #ifdef SISDUALHEAD if(pSiSEnt) pSiSEnt->cursorBufferNum = 0; #endif break; + default: - /* TW: cursorOffset not used in cursor functions for 530 and - * older chips, because the cursor is *above* the TQ. - * On 5597 and older revisions of the 6326, the TQ is - * max 32K, on newer 6326 revisions and the 530 either 30 - * (or 32?) or 62K (or 64?). However, to make sure, we - * use only 30K (or 32?), but reduce the available memory - * by 64, and locate the TQ at the beginning of this last - * 64K block. (We do this that way even when using the - * HWCursor, because the cursor only takes 2K, and the queue - * does not seem to last that far anyway.) - * The TQ must be located at 32KB boundaries. + /* cursorOffset not used in cursor functions for 530 and + * older chips, because the cursor is *above* the TQ. + * On 5597 and older revisions of the 6326, the TQ is + * max 32K, on newer 6326 revisions and the 530 either 30 + * (or 32?) or 62K (or 64?). However, to make sure, we + * use only 30K (or 32?), but reduce the available memory + * by 64, and locate the TQ at the beginning of this last + * 64K block. (We do this that way even when using the + * HWCursor, because the cursor only takes 2K and the + * queue does not seem to last that far anyway.) + * The TQ must be located at 32KB boundaries. */ if(pSiS->RealVideoRam < 3072) { - if(pSiS->TurboQueue) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Not enough video RAM for TurboQueue. TurboQueue disabled\n"); - } - pSiS->TurboQueue = FALSE; + if(pSiS->TurboQueue) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Not enough video RAM for TurboQueue. TurboQueue disabled\n"); + pSiS->TurboQueue = FALSE; + } } pSiS->CmdQueMaxLen = 32; if(pSiS->TurboQueue) { pSiS->availMem -= (64*1024); - pSiS->CmdQueMaxLen = 900; /* TW: To make sure; should be 992 */ - } else if (pSiS->HWCursor) { + pSiS->CmdQueMaxLen = 900; /* To make sure; should be 992 */ + } else if(pSiS->HWCursor) { pSiS->availMem -= pSiS->CursorSize; } if(pSiS->Chipset == PCI_CHIP_SIS530) { - /* TW: Check if Flat Panel is enabled */ + /* Check if Flat Panel is enabled */ inSISIDXREG(SISSR, 0x0e, tempreg); if(!tempreg & 0x04) pSiS->availMem -= pSiS->CursorSize; - /* TW: Set up mask for MMIO register */ + /* Set up mask for MMIO register */ pSiS->CmdQueLenMask = (pSiS->TurboQueue) ? 0x1FFF : 0x00FF; } else { - /* TW: TQ is never used on 6326/5597, because the accelerator - * always Syncs. So this is just cosmentic work. (And I - * am not even sure that 0x7fff is correct. MMIO 0x83a8 - * holds 0xec0 if (30k) TQ is enabled, 0x20 if TQ disabled. - * The datasheet has no real explanation on the queue length - * if the TQ is enabled. Not syncing and waiting for a - * suitable queue length instead does not work. + /* TQ is never used on 6326/5597, because the accelerator + * always Syncs. So this is just cosmentic work. (And I + * am not even sure that 0x7fff is correct. MMIO 0x83a8 + * holds 0xec0 if (30k) TQ is enabled, 0x20 if TQ disabled. + * The datasheet has no real explanation on the queue length + * if the TQ is enabled. Not syncing and waiting for a + * suitable queue length instead does not work. */ pSiS->CmdQueLenMask = (pSiS->TurboQueue) ? 0x7FFF : 0x003F; } - /* TW: This is to be subtracted from MMIO queue length register contents - * for getting the real Queue length. + /* This is to be subtracted from MMIO queue length register contents + * for getting the real Queue length. */ pSiS->CmdQueLenFix = (pSiS->TurboQueue) ? 32 : 0; } #ifdef SISDUALHEAD - /* TW: In dual head mode, we share availMem equally - so align it - * to 8KB; this way, the address of the FB of the second - * head is aligned to 4KB for mapping. + /* In dual head mode, we share availMem equally - so align it + * to 8KB; this way, the address of the FB of the second + * head is aligned to 4KB for mapping. */ - if (pSiS->DualHeadMode) - pSiS->availMem &= 0xFFFFE000; + if(pSiS->DualHeadMode) + pSiS->availMem &= 0xFFFFE000; #endif - /* TW: Check MaxXFBMem setting */ + /* Check MaxXFBMem setting */ #ifdef SISDUALHEAD - /* TW: Since DRI is not supported in dual head mode, we - don't need MaxXFBMem setting. */ - if (pSiS->DualHeadMode) { - if(pSiS->maxxfbmem) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + /* Since DRI is not supported in dual head mode, we + don't need the MaxXFBMem setting. */ + if(pSiS->DualHeadMode) { + if(pSiS->maxxfbmem) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "MaxXFBMem not used in Dual Head mode. Using all VideoRAM.\n"); - } - pSiS->maxxfbmem = pSiS->availMem; + } + pSiS->maxxfbmem = pSiS->availMem; } else #endif - if (pSiS->maxxfbmem) { - if (pSiS->maxxfbmem > pSiS->availMem) { - if (pSiS->sisfbMem) { - pSiS->maxxfbmem = pSiS->sisfbMem * 1024; - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Invalid MaxXFBMem setting. Using sisfb heap start information\n"); - } else { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Invalid MaxXFBMem setting. Using all VideoRAM for framebuffer\n"); - pSiS->maxxfbmem = pSiS->availMem; - } - } else if (pSiS->sisfbMem) { - if (pSiS->maxxfbmem > pSiS->sisfbMem * 1024) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "MaxXFBMem beyond sisfb heap start. Using sisfb heap start information\n"); - pSiS->maxxfbmem = pSiS->sisfbMem * 1024; - } - } - } else if (pSiS->sisfbMem) { - pSiS->maxxfbmem = pSiS->sisfbMem * 1024; + if(pSiS->maxxfbmem) { + if(pSiS->maxxfbmem > pSiS->availMem) { + if(pSiS->sisfbMem) { + pSiS->maxxfbmem = pSiS->sisfbMem * 1024; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Invalid MaxXFBMem setting. Using sisfb heap start information\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Invalid MaxXFBMem setting. Using all VideoRAM for framebuffer\n"); + pSiS->maxxfbmem = pSiS->availMem; + } + } else if(pSiS->sisfbMem) { + if(pSiS->maxxfbmem > pSiS->sisfbMem * 1024) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "MaxXFBMem beyond sisfb heap start. Using sisfb heap start\n"); + pSiS->maxxfbmem = pSiS->sisfbMem * 1024; + } + } + } else if(pSiS->sisfbMem) { + pSiS->maxxfbmem = pSiS->sisfbMem * 1024; } else pSiS->maxxfbmem = pSiS->availMem; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using %dK of framebuffer memory\n", - pSiS->maxxfbmem / 1024); - - /* TW: Check if the chipset supports two video overlays */ - pSiS->Flags650 = 0; - if ( (!pSiS->NoXvideo) && - ( pSiS->VGAEngine == SIS_300_VGA || - pSiS->VGAEngine == SIS_315_VGA || - pSiS->Chipset == PCI_CHIP_SIS530 || - pSiS->Chipset == PCI_CHIP_SIS6326 || - pSiS->Chipset == PCI_CHIP_SIS5597 ) ) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using %ldK of framebuffer memory\n", + pSiS->maxxfbmem / 1024); + + /* Find out about sub-classes of some chipsets and check + * if the chipset supports two video overlays + */ + if(pSiS->VGAEngine == SIS_300_VGA || + pSiS->VGAEngine == SIS_315_VGA || + pSiS->Chipset == PCI_CHIP_SIS530 || + pSiS->Chipset == PCI_CHIP_SIS6326 || + pSiS->Chipset == PCI_CHIP_SIS5597) { pSiS->hasTwoOverlays = FALSE; - switch (pSiS->Chipset) { + switch(pSiS->Chipset) { case PCI_CHIP_SIS300: case PCI_CHIP_SIS630: - case PCI_CHIP_SIS550: - case PCI_CHIP_SIS330: /* ? */ - pSiS->hasTwoOverlays = TRUE; + case PCI_CHIP_SIS550: + pSiS->hasTwoOverlays = TRUE; + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORT2OVL; + break; + case PCI_CHIP_SIS315PRO: + pSiS->ChipFlags |= SiSCF_LARGEOVERLAY; + break; + case PCI_CHIP_SIS330: + pSiS->ChipFlags |= SiSCF_LARGEOVERLAY; + pSiS->ChipFlags |= SiSCF_CRT2HWCKaputt; break; + case PCI_CHIP_SIS660: + { +#if 0 + static const char *id661str[] = { + "661 ?", "661 ?", "661 ?", "661 ?", + "661 ?", "661 ?", "661 ?", "661 ?", + "661 ?", "661 ?", "661 ?", "661 ?", + "661 ?", "661 ?", "661 ?", "661 ?" + }; +#endif + pSiS->ChipFlags |= SiSCF_LARGEOVERLAY; + pSiS->hasTwoOverlays = TRUE; + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORT2OVL; +#if 0 + if(pSiS->sishw_ext.jChipType == SIS_661) { + inSISIDXREG(SISCR, 0x5f, CR5F); + CR5F &= 0xf0; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiS661FX revision ID %x (%s)\n", CR5F, id661str[CR5F >> 4]); + } +#endif + break; + } case PCI_CHIP_SIS650: { + unsigned char tempreg1, tempreg2; static const char *id650str[] = { - "0", "0", "0", "0", - "0 A0 AA", "0 A2 CA", "0", "0", - "0M A0", "0M A1 AA", "1 A0 AA", "1 A1 AA" - "0", "0", "0", "0" + "650", "650", "650", "650", + "650 A0 AA", "650 A2 CA", "650", "650", + "M650 A0", "M650 A1 AA","651 A0 AA", "651 A1 AA", + "M650", "65?", "651", "65?" }; - inSISIDXREG(SISCR, 0x5F, CR5F); - CR5F &= 0xf0; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "SiS650 revision ID %x (SiS65%s)\n", CR5F, id650str[CR5F >> 4]); - if((CR5F == 0x80) || (CR5F == 0x90) || (CR5F == 0xa0) || (CR5F == 0xb0)) { - pSiS->hasTwoOverlays = TRUE; /* TW: This is an M650 or 651 */ - pSiS->Flags650 |= SiS650_LARGEOVERLAY; + pSiS->ChipFlags |= SiSCF_LARGEOVERLAY; + if(pSiS->sishw_ext.jChipType == SIS_650) { + inSISIDXREG(SISCR, 0x5f, CR5F); + CR5F &= 0xf0; + andSISIDXREG(SISCR, 0x5c, 0x07); + inSISIDXREG(SISCR, 0x5c, tempreg1); + tempreg1 &= 0xf8; + orSISIDXREG(SISCR, 0x5c, 0xf8); + inSISIDXREG(SISCR, 0x5c, tempreg2); + tempreg2 &= 0xf8; + if((!tempreg1) || (tempreg2)) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiS650 revision ID %x (%s)\n", CR5F, id650str[CR5F >> 4]); + if(CR5F & 0x80) { + pSiS->hasTwoOverlays = TRUE; /* M650 or 651 */ + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORT2OVL; + } + switch(CR5F) { + case 0xa0: + case 0xb0: + case 0xe0: + pSiS->ChipFlags |= SiSCF_Is651; + break; + case 0x80: + case 0x90: + case 0xc0: + pSiS->ChipFlags |= SiSCF_IsM650; + break; + } + } else { + pSiS->hasTwoOverlays = TRUE; + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORT2OVL; + switch(CR5F) { + case 0x90: + inSISIDXREG(SISCR, 0x5c, tempreg1); + tempreg1 &= 0xf8; + switch(tempreg1) { + case 0x00: + pSiS->ChipFlags |= SiSCF_IsM652; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiSM652 revision ID %x\n", CR5F); + break; + case 0x40: + pSiS->ChipFlags |= SiSCF_IsM653; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiSM653 revision ID %x\n", CR5F); + break; + default: + pSiS->ChipFlags |= SiSCF_IsM650; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiSM650 revision ID %x\n", CR5F); + break; + } + break; + case 0xb0: + pSiS->ChipFlags |= SiSCF_Is652; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiS652 revision ID %x\n", CR5F); + break; + default: + pSiS->ChipFlags |= SiSCF_IsM650; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiSM650 revision ID %x\n", CR5F); + break; + } + } } break; } @@ -2528,119 +3745,279 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->hasTwoOverlays ? "s" : ""); } - /* TW: Backup VB connection and CRT1 on/off register */ + /* Backup VB connection and CRT1 on/off register */ if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - inSISIDXREG(SISCR, 0x32, pSiS->oldCR32); - inSISIDXREG(SISCR, 0x17, pSiS->oldCR17); - pSiS->postVBCR32 = pSiS->oldCR32; - } - - if(pSiS->forceCRT1 != -1) { - if(pSiS->forceCRT1) pSiS->CRT1off = 0; - else pSiS->CRT1off = 1; - } else pSiS->CRT1off = -1; - - /* TW: There are some strange machines out there which require a special - * manupulation of ISA bridge registers in order to make the Chrontel - * work. Try to find out if we're running on such a machine. + inSISIDXREG(SISCR, 0x32, pSiS->oldCR32); + inSISIDXREG(SISCR, 0x17, pSiS->oldCR17); + inSISIDXREG(SISCR, 0x63, pSiS->oldCR63); + inSISIDXREG(SISSR, 0x1f, pSiS->oldSR1F); + pSiS->postVBCR32 = pSiS->oldCR32; + } + + /* There are some machines out there which require a special + * setup of the GPIO registers in order to make the Chrontel + * work. Try to find out if we're running on such a machine. + * Furthermore, there is some highly customized hardware, + * which requires some non-standard LVDS timing. Since the + * vendors don't seem to care about PCI subsystem ID's we + * need to find out using the BIOS version and date strings. */ pSiS->SiS_Pr->SiS_ChSW = FALSE; if(pSiS->Chipset == PCI_CHIP_SIS630) { - int i=0; - do { - if(mychswtable[i].subsysVendor == pSiS->PciInfo->subsysVendor && - mychswtable[i].subsysCard == pSiS->PciInfo->subsysCard) { + int i = 0; + do { + if(mychswtable[i].subsysVendor == pSiS->PciInfo->subsysVendor && + mychswtable[i].subsysCard == pSiS->PciInfo->subsysCard) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "PCI subsystem ID found in list for Chrontel/GPIO setup\n"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Vendor/Card: %s %s (ID %04x)\n", + mychswtable[i].vendorName, + mychswtable[i].cardName, + pSiS->PciInfo->subsysCard); + pSiS->SiS_Pr->SiS_ChSW = TRUE; + break; + } + i++; + } while(mychswtable[i].subsysVendor != 0); + } + + if(pSiS->SiS_Pr->SiS_CustomT == CUT_NONE) { + int i = 0, j; + unsigned short bversptr = 0; + BOOLEAN footprint; + unsigned long chksum = 0; + + if(pSiS->sishw_ext.UseROM) { + bversptr = pSiS->BIOS[0x16] | (pSiS->BIOS[0x17] << 8); + for(i=0; i<32768; i++) chksum += pSiS->BIOS[i]; + } + + i = 0; + do { + if( (mycustomttable[i].chipID == pSiS->sishw_ext.jChipType) && + ((!strlen(mycustomttable[i].biosversion)) || + (pSiS->sishw_ext.UseROM && + (!strncmp(mycustomttable[i].biosversion, (char *)&pSiS->BIOS[bversptr], + strlen(mycustomttable[i].biosversion))))) && + ((!strlen(mycustomttable[i].biosdate)) || + (pSiS->sishw_ext.UseROM && + (!strncmp(mycustomttable[i].biosdate, (char *)&pSiS->BIOS[0x2c], + strlen(mycustomttable[i].biosdate))))) && + ((!mycustomttable[i].bioschksum) || + (pSiS->sishw_ext.UseROM && + (mycustomttable[i].bioschksum == chksum))) && + (mycustomttable[i].pcisubsysvendor == pSiS->PciInfo->subsysVendor) && + (mycustomttable[i].pcisubsyscard == pSiS->PciInfo->subsysCard) ) { + footprint = TRUE; + for(j=0; j<5; j++) { + if(mycustomttable[i].biosFootprintAddr[j]) { + if(pSiS->sishw_ext.UseROM) { + if(pSiS->BIOS[mycustomttable[i].biosFootprintAddr[j]] != + mycustomttable[i].biosFootprintData[j]) + footprint = FALSE; + } else footprint = FALSE; + } + } + if(footprint) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "PCI card/vendor found in list for Chrontel/ISA bridge poking\n"); - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Vendor: %s (ID %04x)\n", - mychswtable[i].vendorName, pSiS->PciInfo->subsysCard); - pSiS->SiS_Pr->SiS_ChSW = TRUE; - } - i++; - } while(mychswtable[i].subsysVendor != 0); + "Identified %s %s, special timing applies\n", + mycustomttable[i].vendorName, mycustomttable[i].cardName); + pSiS->SiS_Pr->SiS_CustomT = mycustomttable[i].SpecialID; + break; + } + } + i++; + } while(mycustomttable[i].chipID); } - /* TW: Detect video bridge and sense connected devices */ + /* Handle ForceCRT1 option */ + if(pSiS->forceCRT1 != -1) { + if(pSiS->forceCRT1) pSiS->CRT1off = 0; + else pSiS->CRT1off = 1; + } else pSiS->CRT1off = -1; + + /* Detect video bridge and sense TV/VGA2 */ SISVGAPreInit(pScrn); - /* TW: Detect CRT1 */ + + /* Detect CRT1 (via DDC1 and DDC2, hence via VGA port; regardless of LCDA) */ SISCRT1PreInit(pScrn); - /* TW: Detect CRT2-LCD and LCD size */ + + /* Detect LCD (connected via CRT2, regardless of LCDA) and LCD resolution */ SISLCDPreInit(pScrn); - /* TW: Detect CRT2-TV and PAL/NTSC mode */ + + /* LCDA only supported under these conditions: */ + if(pSiS->ForceCRT1Type == CRT1_LCDA) { + if( ((pSiS->sishw_ext.jChipType != SIS_650) && + (pSiS->sishw_ext.jChipType < SIS_661)) || + (!(pSiS->VBFlags & (VB_301C | VB_302B | VB_301LV | VB_302LV))) ) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Chipset/Video bridge does not support LCD-via-CRT1\n"); + pSiS->ForceCRT1Type = CRT1_VGA; + } else if(!(pSiS->VBFlags & CRT2_LCD)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "No digitally connected LCD panel found, LCD-via-CRT1 disabled\n"); + pSiS->ForceCRT1Type = CRT1_VGA; + } else if(!(pSiS->VBLCDFlags & (VB_LCD_1024x768|VB_LCD_1280x1024|VB_LCD_1400x1050|VB_LCD_1600x1200))) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "LCD-via-CRT1 not supported for this LCD resolution\n"); + pSiS->ForceCRT1Type = CRT1_VGA; + } + } + + /* Detect CRT2-TV and PAL/NTSC mode */ SISTVPreInit(pScrn); - /* TW: Detect CRT2-VGA */ + + /* Detect CRT2-VGA */ SISCRT2PreInit(pScrn); - /* TW: Backup detected CRT2 devices */ - pSiS->detectedCRT2Devices = pSiS->VBFlags & (CRT2_LCD | CRT2_TV | CRT2_VGA); + /* Backup detected CRT2 devices */ + pSiS->detectedCRT2Devices = pSiS->VBFlags & (CRT2_LCD | CRT2_TV | CRT2_VGA | TV_AVIDEO | TV_SVIDEO | TV_SCART); + + /* Setup SD flags */ + pSiS->SiS_SD_Flags |= SiS_SD_ADDLSUPFLAG; + + if(pSiS->VBFlags & (VB_SISTVBRIDGE | VB_CHRONTEL)) { + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTTV; + } + + if((pSiS->VBFlags & VB_SISTVBRIDGE) || + ((pSiS->VBFlags & VB_CHRONTEL) && (pSiS->ChrontelType == CHRONTEL_701x))) { + pSiS->SiS_SD_Flags |= (SiS_SD_SUPPORTPALMN | SiS_SD_SUPPORTNTSCJ); + } + if((pSiS->VBFlags & VB_SISTVBRIDGE) || + ((pSiS->VBFlags & VB_CHRONTEL) && (pSiS->ChrontelType == CHRONTEL_700x))) { + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTTVPOS; + } + if(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)) { + pSiS->SiS_SD_Flags |= (SiS_SD_SUPPORTSCART | SiS_SD_SUPPORTVGA2); + } + if(pSiS->VBFlags & VB_CHRONTEL) { + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTOVERSCAN; + if(pSiS->ChrontelType == CHRONTEL_700x) { + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTSOVER; + } + } + + 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->VBLCDFlags & (VB_LCD_1024x768|VB_LCD_1280x1024|VB_LCD_1400x1050|VB_LCD_1600x1200)) && + (pSiS->VESA != 1) ) { + pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTLCDA; + } else { + /* Paranoia */ + pSiS->ForceCRT1Type = CRT1_VGA; + } + + pSiS->VBFlags |= pSiS->ForceCRT1Type; - /* TW: Eventually overrule detected CRT2 type */ + /* Eventually overrule detected CRT2 type + * If no type forced, use the detected devices in the order VGA2->TV->LCD + * Since the Chrontel 7005 sometimes delivers wrong detection results, + * we use a different order on such machines (LCD->TV) + */ if(pSiS->ForceCRT2Type == CRT2_DEFAULT) { - if(pSiS->VBFlags & CRT2_VGA) - pSiS->ForceCRT2Type = CRT2_VGA; - else if(pSiS->VBFlags & CRT2_LCD) - pSiS->ForceCRT2Type = CRT2_LCD; - else if(pSiS->VBFlags & CRT2_TV) - pSiS->ForceCRT2Type = CRT2_TV; + if(pSiS->VBFlags & CRT2_VGA) + pSiS->ForceCRT2Type = CRT2_VGA; + else if((pSiS->VBFlags & CRT2_TV) && (!((pSiS->VBFlags & VB_CHRONTEL) && (pSiS->VGAEngine == SIS_300_VGA)))) + pSiS->ForceCRT2Type = CRT2_TV; + else if((pSiS->VBFlags & CRT2_LCD) && (pSiS->ForceCRT1Type == CRT1_VGA)) + pSiS->ForceCRT2Type = CRT2_LCD; + else if(pSiS->VBFlags & CRT2_TV) + pSiS->ForceCRT2Type = CRT2_TV; } switch(pSiS->ForceCRT2Type) { - case CRT2_TV: - pSiS->VBFlags = pSiS->VBFlags & ~(CRT2_LCD | CRT2_VGA); - if(pSiS->VBFlags & VB_VIDEOBRIDGE) - pSiS->VBFlags = pSiS->VBFlags | CRT2_TV; - else - pSiS->VBFlags = pSiS->VBFlags & ~(CRT2_TV); - break; - case CRT2_LCD: - pSiS->VBFlags = pSiS->VBFlags & ~(CRT2_TV | CRT2_VGA); - if((pSiS->VBFlags & VB_VIDEOBRIDGE) && (pSiS->VBLCDFlags)) - pSiS->VBFlags = pSiS->VBFlags | CRT2_LCD; - else { - pSiS->VBFlags = pSiS->VBFlags & ~(CRT2_LCD); - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Can't force CRT2 to LCD, no panel detected\n"); - } - break; - case CRT2_VGA: - if(pSiS->VBFlags & VB_LVDS) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "LVDS does not support secondary VGA\n"); - break; - } - if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "SiS30xLV bridge does not support secondary VGA\n"); - break; - } - pSiS->VBFlags = pSiS->VBFlags & ~(CRT2_TV | CRT2_LCD); - if(pSiS->VBFlags & VB_VIDEOBRIDGE) - pSiS->VBFlags = pSiS->VBFlags | CRT2_VGA; - else - pSiS->VBFlags = pSiS->VBFlags & ~(CRT2_VGA); - break; - default: - pSiS->VBFlags &= ~(CRT2_TV | CRT2_LCD | CRT2_VGA); + case CRT2_TV: + pSiS->VBFlags &= ~(CRT2_LCD | CRT2_VGA); + if(pSiS->VBFlags & (VB_SISTVBRIDGE | VB_CHRONTEL)) + pSiS->VBFlags |= CRT2_TV; + else { + pSiS->VBFlags &= ~(CRT2_TV); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Hardware does not support TV output\n"); + } + break; + case CRT2_LCD: + pSiS->VBFlags &= ~(CRT2_TV | CRT2_VGA); + if((pSiS->VBFlags & VB_VIDEOBRIDGE) && (pSiS->VBLCDFlags)) + pSiS->VBFlags |= CRT2_LCD; + else { + pSiS->VBFlags &= ~(CRT2_LCD); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Can't force CRT2 to LCD, no LCD detected\n"); + } + break; + case CRT2_VGA: + pSiS->VBFlags &= ~(CRT2_TV | CRT2_LCD); + if(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)) + pSiS->VBFlags |= CRT2_VGA; + else { + pSiS->VBFlags &= ~(CRT2_VGA); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Hardware does not support secondary VGA\n"); + } + break; + default: + pSiS->VBFlags &= ~(CRT2_TV | CRT2_LCD | CRT2_VGA); } - /* TW: Eventually overrule TV Type (SVIDEO, COMPOSITE, SCART) */ - if(pSiS->ForceTVType != -1) { - if(pSiS->VBFlags & VB_SISBRIDGE) { - pSiS->VBFlags &= ~(TV_INTERFACE); - pSiS->VBFlags |= pSiS->ForceTVType; - } +#ifdef SISDUALHEAD + if((!pSiS->DualHeadMode) || (pSiS->SecondHead)) { +#endif + xf86DrvMsg(pScrn->scrnIndex, pSiS->CRT1gammaGiven ? X_CONFIG : X_INFO, + "CRT1 gamma correction is %s\n", + pSiS->CRT1gamma ? "enabled" : "disabled"); + + if((pSiS->VGAEngine == SIS_315_VGA) && (!(pSiS->NoXvideo))) { + xf86DrvMsg(pScrn->scrnIndex, pSiS->XvGammaGiven ? X_CONFIG : X_INFO, + "Separate Xv gamma correction for CRT1 is %s\n", + pSiS->XvGamma ? "enabled" : "disabled"); + if(pSiS->XvGamma) { + xf86DrvMsg(pScrn->scrnIndex, pSiS->XvGammaGiven ? X_CONFIG : X_INFO, + "Xv gamma correction: %.3f %.3f %.3f\n", + (float)((float)pSiS->XvGammaRed / 1000), + (float)((float)pSiS->XvGammaGreen / 1000), + (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"); + } + } + } +#ifdef SISDUALHEAD + } +#endif + + if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { + if( (pSiS->VBFlags & VB_SISBRIDGE) && + (!((pSiS->VBFlags & VB_30xBDH) && (pSiS->VBFlags & CRT2_LCD))) ) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CRT2 gamma correction is %s\n", + pSiS->CRT2gamma ? "enabled" : "disabled"); + } } - /* TW: Handle ForceCRT1 option */ + /* Eventually overrule TV Type (SVIDEO, COMPOSITE, SCART) */ + if(pSiS->VBFlags & VB_SISTVBRIDGE) { + if(pSiS->ForceTVType != -1) { + pSiS->VBFlags &= ~(TV_INTERFACE); + pSiS->VBFlags |= pSiS->ForceTVType; + } + } + + /* Handle ForceCRT1 option (part 2) */ pSiS->CRT1changed = FALSE; if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { usScratchCR17 = pSiS->oldCR17; + usScratchCR63 = pSiS->oldCR63; + usScratchSR1F = pSiS->oldSR1F; usScratchCR32 = pSiS->postVBCR32; if(pSiS->VESA != 1) { - /* TW: Copy forceCRT1 option to CRT1off if option is given */ + /* Copy forceCRT1 option to CRT1off if option is given */ #ifdef SISDUALHEAD - /* TW: In DHM, handle this option only for master head, not the slave */ + /* In DHM, handle this option only for master head, not the slave */ if( (pSiS->forceCRT1 != -1) && (!(pSiS->DualHeadMode && pSiS->SecondHead)) ) { #else @@ -2650,20 +4027,36 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) "CRT1 detection overruled by ForceCRT1 option\n"); if(pSiS->forceCRT1) { pSiS->CRT1off = 0; - if (!(usScratchCR17 & 0x80)) pSiS->CRT1changed = TRUE; + if(pSiS->VGAEngine == SIS_300_VGA) { + if(!(usScratchCR17 & 0x80)) pSiS->CRT1changed = TRUE; + } else { + if(usScratchCR63 & 0x40) pSiS->CRT1changed = TRUE; + } usScratchCR17 |= 0x80; usScratchCR32 |= 0x20; + usScratchCR63 &= ~0x40; + usScratchSR1F &= ~0xc0; } else { if( ! ( (pScrn->bitsPerPixel == 8) && - ( (pSiS->VBFlags & VB_LVDS) || - ((pSiS->VGAEngine == SIS_300_VGA) && (pSiS->VBFlags & VB_301B)) ) ) ) { + ( (pSiS->VBFlags & (VB_LVDS | VB_CHRONTEL)) || + ((pSiS->VBFlags & VB_30xBDH) && (pSiS->VBFlags & CRT2_LCD)) ) ) ) { pSiS->CRT1off = 1; - if (usScratchCR17 & 0x80) pSiS->CRT1changed = TRUE; + if(pSiS->VGAEngine == SIS_300_VGA) { + if(usScratchCR17 & 0x80) pSiS->CRT1changed = TRUE; + } else { + if(!(usScratchCR63 & 0x40)) pSiS->CRT1changed = TRUE; + } usScratchCR32 &= ~0x20; - /* TW: We must not actually switch off CRT1 before we changed the mode! */ + /* We must not actually switch off CRT1 before we changed the mode! */ } } + /* Here we can write to CR17 even on 315 series as we only ENABLE + * the bit here + */ outSISIDXREG(SISCR, 0x17, usScratchCR17); + if(pSiS->VGAEngine == SIS_315_VGA) { + outSISIDXREG(SISCR, 0x63, usScratchCR63); + } outSISIDXREG(SISCR, 0x32, usScratchCR32); if(pSiS->CRT1changed) { outSISIDXREG(SISSR, 0x00, 0x01); /* Synchronous Reset */ @@ -2672,29 +4065,30 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CRT1 status changed by ForceCRT1 option\n"); } + outSISIDXREG(SISSR, 0x1f, usScratchSR1F); } } - /* TW: Store the new VB connection register contents for later mode changes */ + /* Store the new VB connection register contents for later mode changes */ pSiS->newCR32 = usScratchCR32; } - /* TW: Check if CRT1 used (or needed; this eg. if no CRT2 detected) */ - if (pSiS->VBFlags & VB_VIDEOBRIDGE) { - - /* TW: No CRT2 output? Then we NEED CRT1! - * We also need CRT1 if depth = 8 and bridge=LVDS|630+301B + /* Check if CRT1 used (or needed; this eg. if no CRT2 detected) */ + if(pSiS->VBFlags & VB_VIDEOBRIDGE) { + + /* No CRT2 output? Then we NEED CRT1! + * We also need CRT1 if depth = 8 and bridge=LVDS|301B-DH */ - if ( (!(pSiS->VBFlags & (CRT2_VGA | CRT2_LCD | CRT2_TV))) || - ( (pScrn->bitsPerPixel == 8) && - ( (pSiS->VBFlags & (VB_LVDS | VB_CHRONTEL)) || - ((pSiS->VGAEngine == SIS_300_VGA) && (pSiS->VBFlags & VB_301B)) ) ) ) { + if( (!(pSiS->VBFlags & (CRT2_VGA | CRT2_LCD | CRT2_TV))) || + ( (pScrn->bitsPerPixel == 8) && + ( (pSiS->VBFlags & (VB_LVDS | VB_CHRONTEL)) || + ((pSiS->VBFlags & VB_30xBDH) && (pSiS->VBFlags & CRT2_LCD)) ) ) ) { pSiS->CRT1off = 0; } - /* TW: No CRT2 output? Then we can't use Xv on CRT2 */ - if (!(pSiS->VBFlags & (CRT2_VGA | CRT2_LCD | CRT2_TV))) + /* No CRT2 output? Then we can't use Xv on CRT2 */ + if(!(pSiS->VBFlags & (CRT2_VGA | CRT2_LCD | CRT2_TV))) pSiS->XvOnCRT2 = FALSE; - } else { /* TW: no video bridge? */ + } else { /* no video bridge? */ /* Then we NEED CRT1... */ pSiS->CRT1off = 0; @@ -2702,86 +4096,146 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->XvOnCRT2 = FALSE; } - /* TW: Handle TVStandard option */ - if(pSiS->NonDefaultPAL != -1) { - if( (!(pSiS->VBFlags & VB_SISBRIDGE)) && - (!((pSiS->VBFlags & VB_CHRONTEL)) && (pSiS->ChrontelType == CHRONTEL_701x)) ) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "PALM and PALN only supported on Chrontel 701x and SiS30x/B/LV\n"); - pSiS->NonDefaultPAL = -1; - pSiS->VBFlags &= ~(TV_PALN | TV_PALM); - } - } - if(pSiS->NonDefaultPAL != -1) { - if((pSiS->Chipset == PCI_CHIP_SIS300) || (pSiS->Chipset == PCI_CHIP_SIS540)) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "PALM and PALN not supported on SiS300 and SiS540\n"); - pSiS->NonDefaultPAL = -1; - pSiS->VBFlags &= ~(TV_PALN | TV_PALM); - } + /* LCDA? Then we don't switch off CRT1 */ + if(pSiS->VBFlags & CRT1_LCDA) pSiS->CRT1off = 0; + + /* Handle TVStandard option */ + if((pSiS->NonDefaultPAL != -1) || (pSiS->NonDefaultNTSC != -1)) { + if( (!(pSiS->VBFlags & VB_SISTVBRIDGE)) && + (!((pSiS->VBFlags & VB_CHRONTEL)) && (pSiS->ChrontelType == CHRONTEL_701x)) ) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "PALM, PALN and NTSCJ not supported on this hardware\n"); + pSiS->NonDefaultPAL = pSiS->NonDefaultNTSC = -1; + pSiS->VBFlags &= ~(TV_PALN | TV_PALM | TV_NTSCJ); + pSiS->SiS_SD_Flags &= ~(SiS_SD_SUPPORTPALMN | SiS_SD_SUPPORTNTSCJ); + } } if(pSiS->OptTVStand != -1) { - if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - if(!(pSiS->Flags & (TV_CHSCART | TV_CHHDTV))) { - pSiS->VBFlags &= ~(TV_PAL | TV_NTSC | TV_PALN | TV_PALM); - if(pSiS->OptTVStand) pSiS->VBFlags |= TV_PAL; - else pSiS->VBFlags |= TV_NTSC; - if(pSiS->NonDefaultPAL == 1) pSiS->VBFlags |= TV_PALM; - else if(!pSiS->NonDefaultPAL) pSiS->VBFlags |= TV_PALN; - } else { - pSiS->OptTVStand = pSiS->NonDefaultPAL = -1; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Option TVStandard ignored for SCART and 480i HDTV\n"); - } - } else if(pSiS->Chipset == PCI_CHIP_SIS6326) { - pSiS->SiS6326Flags &= ~SIS6326_TVPAL; - if(pSiS->OptTVStand) pSiS->SiS6326Flags |= SIS6326_TVPAL; - } + if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { + if(!(pSiS->VBFlags & (TV_CHSCART | TV_CHHDTV))) { + pSiS->VBFlags &= ~(TV_PAL | TV_NTSC | TV_PALN | TV_PALM | TV_NTSCJ); + if(pSiS->OptTVStand) { + pSiS->VBFlags |= TV_PAL; + if(pSiS->NonDefaultPAL == 1) pSiS->VBFlags |= TV_PALM; + else if(!pSiS->NonDefaultPAL) pSiS->VBFlags |= TV_PALN; + } else { + pSiS->VBFlags |= TV_NTSC; + if(pSiS->NonDefaultNTSC == 1) pSiS->VBFlags |= TV_NTSCJ; + } + } else { + pSiS->OptTVStand = pSiS->NonDefaultPAL = -1; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Option TVStandard ignored for SCART and 480i HDTV\n"); + } + } else if(pSiS->Chipset == PCI_CHIP_SIS6326) { + pSiS->SiS6326Flags &= ~SIS6326_TVPAL; + if(pSiS->OptTVStand) pSiS->SiS6326Flags |= SIS6326_TVPAL; + } + } + + /* SCART only supported for PAL */ + if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { + if((pSiS->VBFlags & VB_SISBRIDGE) && (pSiS->VBFlags & TV_SCART)) { + pSiS->VBFlags &= ~(TV_NTSC | TV_PALN | TV_PALM | TV_NTSCJ); + pSiS->VBFlags |= TV_PAL; + pSiS->OptTVStand = 1; + pSiS->NonDefaultPAL = pSiS->NonDefaultNTSC = -1; + } } - /* TW: Do some checks */ +#ifdef SIS_CP + SIS_CP_DRIVER_RECONFIGOPT +#endif + + if((pSiS->Chipset == PCI_CHIP_SIS6326) && (pSiS->SiS6326Flags & SIS6326_HASTV)) { + if(pSiS->sis6326tvplug != -1) { + pSiS->SiS6326Flags &= ~(SIS6326_TVSVIDEO | SIS6326_TVCVBS); + pSiS->SiS6326Flags |= SIS6326_TVDETECTED; + if(pSiS->sis6326tvplug == 1) pSiS->SiS6326Flags |= SIS6326_TVCVBS; + else pSiS->SiS6326Flags |= SIS6326_TVSVIDEO; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "SiS6326 TV plug type detection overruled by %s\n", + (pSiS->SiS6326Flags & SIS6326_TVCVBS) ? "COMPOSITE" : "SVIDEO"); + } + } + + /* Do some checks */ if(pSiS->OptTVOver != -1) { - if(pSiS->VBFlags & VB_CHRONTEL) { - pSiS->UseCHOverScan = pSiS->OptTVOver; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "CHTVOverscan option only supported on CHRONTEL 70xx\n"); - pSiS->UseCHOverScan = -1; - } + if(pSiS->VBFlags & VB_CHRONTEL) { + pSiS->UseCHOverScan = pSiS->OptTVOver; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "CHTVOverscan only supported on CHRONTEL 70xx\n"); + pSiS->UseCHOverScan = -1; + } } else pSiS->UseCHOverScan = -1; - + if(pSiS->sistvedgeenhance != -1) { - if(!(pSiS->VBFlags & VB_301)) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "SISTVEdgeEnhance option only supported on SiS301\n"); - pSiS->sistvedgeenhance = -1; - } + if(!(pSiS->VBFlags & VB_301)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "SISTVEdgeEnhance only supported on SiS301\n"); + pSiS->sistvedgeenhance = -1; + } + } + if(pSiS->sistvsaturation != -1) { + if(pSiS->VBFlags & VB_301) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "SISTVSaturation not supported on SiS301\n"); + pSiS->sistvsaturation = -1; + } + } + + /* Do some MergedFB mode initialisation */ +#ifdef SISMERGED + if(pSiS->MergedFB) { + pSiS->CRT2pScrn = xalloc(sizeof(ScrnInfoRec)); + if(!pSiS->CRT2pScrn) { + SISErrorLog(pScrn, "Failed to allocate memory for 2nd pScrn, %s\n", mergeddisstr); + pSiS->MergedFB = FALSE; + } else { + memcpy(pSiS->CRT2pScrn, pScrn, sizeof(ScrnInfoRec)); + } } +#endif + - /* TW: Determine CRT1<>CRT2 mode + /* Determine CRT1<>CRT2 mode * Note: When using VESA or if the bridge is in slavemode, display * is ALWAYS in MIRROR_MODE! * This requires extra checks in functions using this flag! * (see sis_video.c for example) */ if(pSiS->VBFlags & DISPTYPE_DISP2) { - if(pSiS->CRT1off) { /* TW: CRT2 only ------------------------------- */ + if(pSiS->CRT1off) { /* CRT2 only ------------------------------- */ #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + SISErrorLog(pScrn, "CRT1 not detected or forced off. Dual Head mode can't initialize.\n"); if(pSiSEnt) pSiSEnt->DisableDual = TRUE; if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + pSiS->pInt = NULL; sisRestoreExtRegisterLock(pSiS,srlockReg,crlockReg); SISFreeRec(pScrn); return FALSE; } #endif +#ifdef SISMERGED + if(pSiS->MergedFB) { + if(pSiS->MergedFBAuto) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, mergednocrt1, mergeddisstr); + } else { + SISErrorLog(pScrn, mergednocrt1, mergeddisstr); + } + if(pSiS->CRT2pScrn) xfree(pSiS->CRT2pScrn); + pSiS->CRT2pScrn = NULL; + pSiS->MergedFB = FALSE; + } +#endif pSiS->VBFlags |= VB_DISPMODE_SINGLE; - /* TW: No CRT1? Then we use the video overlay on CRT2 */ + /* No CRT1? Then we use the video overlay on CRT2 */ pSiS->XvOnCRT2 = TRUE; - } else /* TW: CRT1 and CRT2 - mirror or dual head ----- */ + } else /* CRT1 and CRT2 - mirror or dual head ----- */ #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { pSiS->VBFlags |= (VB_DISPMODE_DUAL | DISPTYPE_CRT1); @@ -2789,73 +4243,94 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VESA option not used in Dual Head mode. VESA disabled.\n"); } - if (pSiSEnt) pSiSEnt->DisableDual = FALSE; + if(pSiSEnt) pSiSEnt->DisableDual = FALSE; pSiS->VESA = 0; } else #endif +#ifdef SISMERGED + if(pSiS->MergedFB) { + pSiS->VBFlags |= (VB_DISPMODE_MIRROR | DISPTYPE_CRT1); + if(pSiS->VESA != -1) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "VESA option not used in MergedFB mode. VESA disabled.\n"); + } + pSiS->VESA = 0; + } else +#endif pSiS->VBFlags |= (VB_DISPMODE_MIRROR | DISPTYPE_CRT1); - } else { /* TW: CRT1 only ------------------------------- */ + } else { /* CRT1 only ------------------------------- */ #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + SISErrorLog(pScrn, "No CRT2 output selected or no bridge detected. " "Dual Head mode can't initialize.\n"); if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + pSiS->pInt = NULL; sisRestoreExtRegisterLock(pSiS,srlockReg,crlockReg); SISFreeRec(pScrn); return FALSE; } #endif +#ifdef SISMERGED + if(pSiS->MergedFB) { + if(pSiS->MergedFBAuto) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, mergednocrt2, mergeddisstr); + } else { + SISErrorLog(pScrn, mergednocrt2, mergeddisstr); + } + if(pSiS->CRT2pScrn) xfree(pSiS->CRT2pScrn); + pSiS->CRT2pScrn = NULL; + pSiS->MergedFB = FALSE; + } +#endif pSiS->VBFlags |= (VB_DISPMODE_SINGLE | DISPTYPE_CRT1); } - if( (pSiS->VGAEngine == SIS_315_VGA) || - (pSiS->VGAEngine == SIS_300_VGA) ) { - if ( (!pSiS->NoXvideo) && - (!pSiS->hasTwoOverlays) ) { - xf86DrvMsg(pScrn->scrnIndex, from, - "Using Xv overlay on CRT%d\n", - pSiS->XvOnCRT2 ? 2 : 1); + if((pSiS->VGAEngine == SIS_315_VGA) || + (pSiS->VGAEngine == SIS_300_VGA) ) { + if((!pSiS->NoXvideo) && (!pSiS->hasTwoOverlays)) { + xf86DrvMsg(pScrn->scrnIndex, from, + "Using Xv overlay by default on CRT%d\n", + pSiS->XvOnCRT2 ? 2 : 1); } } - /* TW: Init Ptrs for Save/Restore functions and calc MaxClock */ + /* Init Ptrs for Save/Restore functions and calc MaxClock */ SISDACPreInit(pScrn); /* ********** end of VBFlags setup ********** */ - /* TW: VBFlags are initialized now. Back them up for SlaveMode modes. */ + /* VBFlags are initialized now. Back them up for SlaveMode modes. */ pSiS->VBFlags_backup = pSiS->VBFlags; - /* TW: Find out about paneldelaycompensation and evaluate option */ + /* Find out about paneldelaycompensation and evaluate option */ pSiS->sishw_ext.pdc = 0; if(pSiS->VGAEngine == SIS_300_VGA) { - - if(pSiS->VBFlags & (VB_LVDS | VB_301B | VB_302B)) { - /* TW: Save the current PDC if the panel is used at the moment. - * This seems by far the safest way to find out about it. - * If the system is using an old version of sisfb, we can't - * trust the pdc register value. If sisfb saved the pdc for - * us, use it. + if(pSiS->VBFlags & (VB_LVDS | VB_30xBDH)) { + /* Save the current PDC if the panel is used at the moment. + * This seems by far the safest way to find out about it. + * If the system is using an old version of sisfb, we can't + * trust the pdc register value. If sisfb saved the pdc for + * us, use it. */ if(pSiS->sisfbpdc) { pSiS->sishw_ext.pdc = pSiS->sisfbpdc; } else { - if(!(pSiS->donttrustpdc)) { - unsigned char tmp; - inSISIDXREG(SISCR, 0x30, tmp); - if(tmp & 0x20) { - inSISIDXREG(SISPART1, 0x13, pSiS->sishw_ext.pdc); - } else { + if(!(pSiS->donttrustpdc)) { + unsigned char tmp; + inSISIDXREG(SISCR, 0x30, tmp); + if(tmp & 0x20) { + inSISIDXREG(SISPART1, 0x13, pSiS->sishw_ext.pdc); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Unable to detect LCD PanelDelayCompensation, LCD is not active\n"); + } + } else { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Unable to detect LCD PanelDelayCompensation, LCD is not active\n"); - } - } else { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Unable to detect LCD PanelDelayCompensation, please update sisfb\n"); - } + "Unable to detect LCD PanelDelayCompensation, please update sisfb\n"); + } } pSiS->sishw_ext.pdc &= 0x3c; if(pSiS->sishw_ext.pdc) { @@ -2872,7 +4347,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) if(mypdctable[i].subsysVendor == pSiS->PciInfo->subsysVendor && mypdctable[i].subsysCard == pSiS->PciInfo->subsysCard) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "PCI card/vendor found in list for non-default PanelDelayCompensation\n"); + "PCI card/vendor identified for non-default PanelDelayCompensation\n"); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Vendor: %s, card: %s (ID %04x), PanelDelayCompensation: %d\n", mypdctable[i].vendorName, mypdctable[i].cardName, @@ -2917,14 +4392,61 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) } } + if(pSiS->VGAEngine == SIS_315_VGA) { + if(pSiS->VBFlags & (VB_301LV | VB_302LV | VB_302ELV)) { + /* Save the current PDC if the panel is used at the moment. + * This seems by far the safest way to find out about it. + */ + if(pSiS->sisfbpdc) { + pSiS->sishw_ext.pdc = pSiS->sisfbpdc; + } else { + if(!(pSiS->donttrustpdc)) { + unsigned char tmp; + inSISIDXREG(SISCR, 0x30, tmp); + if(tmp & 0x20) { + inSISIDXREG(SISPART1, 0x2D, pSiS->sishw_ext.pdc); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Unable to detect LCD PanelDelayCompensation, LCD is not active\n"); + } + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Unable to detect LCD PanelDelayCompensation, please update sisfb\n"); + } + } + if(pSiS->sishw_ext.pdc) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Detected LCD PanelDelayCompensation %d\n", + pSiS->sishw_ext.pdc); + } + if(pSiS->PDC != -1) { + pSiS->sishw_ext.pdc = pSiS->PDC & 0xff; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using LCD PanelDelayCompensation %d\n", + pSiS->sishw_ext.pdc); + } + } else if(pSiS->Chipset == PCI_CHIP_SIS660) { + /* Since I have no idea about the required PDC on + * the new chips, let the user specify one. But + * we only use the lower nibble. + */ + if(pSiS->PDC != -1) { + pSiS->sishw_ext.pdc = pSiS->PDC & 0x0f; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using LCD PanelDelayCompensation %d\n", + pSiS->sishw_ext.pdc); + } + } + } + #ifdef SISDUALHEAD - /* TW: In dual head mode, both heads (currently) share the maxxfbmem equally. - * If memory sharing is done differently, the following has to be changed; - * the other modules (eg. accel and Xv) use dhmOffset for hardware - * pointer settings relative to VideoRAM start and won't need to be changed. + /* In dual head mode, both heads (currently) share the maxxfbmem equally. + * If memory sharing is done differently, the following has to be changed; + * the other modules (eg. accel and Xv) use dhmOffset for hardware + * pointer settings relative to VideoRAM start and won't need to be changed. */ - if (pSiS->DualHeadMode) { - if (pSiS->SecondHead == FALSE) { + if(pSiS->DualHeadMode) { + if(pSiS->SecondHead == FALSE) { /* ===== First head (always CRT2) ===== */ /* We use only half of the memory available */ pSiS->maxxfbmem /= 2; @@ -2936,7 +4458,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiSEnt->slaveFbAddress = pSiS->FbAddress + pSiS->maxxfbmem; pSiSEnt->slaveFbSize = pSiS->maxxfbmem; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "%dKB video RAM at 0x%lx available for master head (CRT2)\n", + "%ldKB video RAM at 0x%lx available for master head (CRT2)\n", pSiS->maxxfbmem/1024, pSiS->FbAddress); } else { /* ===== Second head (always CRT1) ===== */ @@ -2947,62 +4469,80 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) /* Initialize dhmOffset */ pSiS->dhmOffset = pSiS->availMem - pSiS->maxxfbmem; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "%dKB video RAM at 0x%lx available for slave head (CRT1)\n", + "%ldKB video RAM at 0x%lx available for slave head (CRT1)\n", pSiS->maxxfbmem/1024, pSiS->FbAddress); } } else pSiS->dhmOffset = 0; #endif - /* TW: Note: Do not use availMem for anything from now. Use - * maxxfbmem instead. (availMem does not take dual head - * mode into account.) + /* Note: Do not use availMem for anything from now. Use + * maxxfbmem instead. (availMem does not take dual head + * mode into account.) */ - /* TW: Now for something completely different: DDC. - For 300 and 310/325 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 - the wheel there. + pSiS->DRIheapstart = pSiS->maxxfbmem; + pSiS->DRIheapend = pSiS->availMem; +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + pSiS->DRIheapstart = pSiS->DRIheapend = 0; + } else +#endif + if(pSiS->DRIheapstart == pSiS->DRIheapend) { +#if 0 /* For future use */ + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "No memory for DRI heap. Please set the option \"MaxXFBMem\" to\n" + "\tlimit the memory XFree should use and leave the rest to DRI\n"); +#endif + pSiS->DRIheapstart = pSiS->DRIheapend = 0; + } + + /* Now for something completely different: DDC. + * For 300 and 315/330 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 + * the wheel there. */ pSiS->pVbe = NULL; didddc2 = FALSE; if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - if(xf86LoadSubModule(pScrn, "ddc")) { + if(xf86LoadSubModule(pScrn, "ddc")) { + int crtnum = 0; xf86LoaderReqSymLists(ddcSymbols, NULL); - if((pMonitor = SiSDoPrivateDDC(pScrn))) { + if((pMonitor = SiSDoPrivateDDC(pScrn, &crtnum))) { didddc2 = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "DDC monitor info:\n"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, ddcsstr, crtnum); xf86PrintEDID(pMonitor); - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "End of DDC monitor info\n"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, ddcestr, crtnum); xf86SetDDCproperties(pScrn, pMonitor); pScrn->monitor->DDC = pMonitor; } - } + } } #ifdef SISDUALHEAD - /* TW: In dual head mode, probe DDC using VBE only for CRT1 (second head) */ + /* In dual head mode, probe DDC using VBE only for CRT1 (second head) */ if((pSiS->DualHeadMode) && (!didddc2) && (!pSiS->SecondHead)) didddc2 = TRUE; #endif - /* TW: If CRT1 is off (eventually forced), skip DDC */ - if((!didddc2) && (pSiS->CRT1off)) didddc2 = TRUE; + if(!didddc2) { + /* If CRT1 is off or LCDA, skip DDC via VBE */ + if((pSiS->CRT1off) || (pSiS->VBFlags & CRT1_LCDA)) + didddc2 = TRUE; + } - /* TW: Now (re-)load and initialize the DDC module */ + /* Now (re-)load and initialize the DDC module */ if(!didddc2) { if(xf86LoadSubModule(pScrn, "ddc")) { xf86LoaderReqSymLists(ddcSymbols, NULL); - /* TW: Now load and initialize VBE module. */ + /* Now load and initialize VBE module. */ if(xf86LoadSubModule(pScrn, "vbe")) { xf86LoaderReqSymLists(vbeSymbols, NULL); #if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) @@ -3023,10 +4563,10 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) if(pSiS->pVbe) { if((pMonitor = vbeDoEDID(pSiS->pVbe,NULL))) { xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "VBE DDC monitor info:\n"); + "VBE CRT1 DDC monitor info:\n"); xf86SetDDCproperties(pScrn, xf86PrintEDID(pMonitor)); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "End of VBE DDC monitor info:\n"); + "End of VBE CRT1 DDC monitor info:\n"); pScrn->monitor->DDC = pMonitor; } } else { @@ -3036,16 +4576,118 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) } } -#if 0 /* TW: DDC1 obviously no longer supported by SiS chipsets */ - if (!ret && pSiS->ddc1Read) - xf86SetDDCproperties(pScrn, xf86PrintEDID(xf86DoEDID_DDC1( - pScrn->scrnIndex,vgaHWddc1SetSpeed,pSiS->ddc1Read ))); +#ifdef SISMERGED + if(pSiS->MergedFB) { + pSiS->CRT2pScrn->monitor = xalloc(sizeof(MonRec)); + if(pSiS->CRT2pScrn->monitor) { + DisplayModePtr tempm = NULL, currentm = NULL, newm = NULL; + memcpy(pSiS->CRT2pScrn->monitor, pScrn->monitor, sizeof(MonRec)); + pSiS->CRT2pScrn->monitor->DDC = NULL; + pSiS->CRT2pScrn->monitor->Modes = NULL; + tempm = pScrn->monitor->Modes; + while(tempm) { + if(!(newm = xalloc(sizeof(DisplayModeRec)))) break; + memcpy(newm, tempm, sizeof(DisplayModeRec)); + if(!(newm->name = xalloc(strlen(tempm->name) + 1))) { + xfree(newm); + break; + } + strcpy(newm->name, tempm->name); + if(!pSiS->CRT2pScrn->monitor->Modes) pSiS->CRT2pScrn->monitor->Modes = newm; + if(currentm) { + currentm->next = newm; + newm->prev = currentm; + } + currentm = newm; + tempm = tempm->next; + } + if(pSiS->CRT2HSync) { + pSiS->CRT2pScrn->monitor->nHsync = + SiSStrToRanges(pSiS->CRT2pScrn->monitor->hsync, pSiS->CRT2HSync, MAX_HSYNC); + } + if(pSiS->CRT2VRefresh) { + pSiS->CRT2pScrn->monitor->nVrefresh = + SiSStrToRanges(pSiS->CRT2pScrn->monitor->vrefresh, pSiS->CRT2VRefresh, MAX_VREFRESH); + } + if((pMonitor = SiSInternalDDC(pSiS->CRT2pScrn, 1))) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, ddcsstr, 2); + xf86PrintEDID(pMonitor); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, ddcestr, 2); + xf86SetDDCproperties(pSiS->CRT2pScrn, pMonitor); + pSiS->CRT2pScrn->monitor->DDC = pMonitor; + /* use DDC data if no ranges in config file */ + if(!pSiS->CRT2HSync) { + pSiS->CRT2pScrn->monitor->nHsync = 0; + } + if(!pSiS->CRT2VRefresh) { + pSiS->CRT2pScrn->monitor->nVrefresh = 0; + } + } else { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Failed to read DDC data for CRT2\n"); + } + } else { + SISErrorLog(pScrn, "Failed to allocate memory for CRT2 monitor, %s.\n", + mergeddisstr); + if(pSiS->CRT2pScrn) xfree(pSiS->CRT2pScrn); + pSiS->CRT2pScrn = NULL; + pSiS->MergedFB = FALSE; + } + } +#endif + + /* If there is no HSync or VRefresh data for the monitor, + * derive it from DDC data. Done by common layer since + * 4.3.99.14. + */ +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,14,0) + if(pScrn->monitor->DDC) { + if(pScrn->monitor->nHsync <= 0) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, subshstr, +#ifdef SISDUALHEAD + pSiS->DualHeadMode ? (pSiS->SecondHead ? 1 : 2) : +#endif + pSiS->CRT1off ? 2 : 1); + SiSSetSyncRangeFromEdid(pScrn, 1); + } + if(pScrn->monitor->nVrefresh <= 0) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, subsvstr, +#ifdef SISDUALHEAD + pSiS->DualHeadMode ? (pSiS->SecondHead ? 1 : 2) : +#endif + pSiS->CRT1off ? 2 : 1); + SiSSetSyncRangeFromEdid(pScrn, 0); + } + } +#endif + +#ifdef SISMERGED + if(pSiS->MergedFB) { +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,14,0) + if(pSiS->CRT2pScrn->monitor->DDC) { + if(pSiS->CRT2pScrn->monitor->nHsync <= 0) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, subshstr, 2); + SiSSetSyncRangeFromEdid(pSiS->CRT2pScrn, 1); + } + if(pSiS->CRT2pScrn->monitor->nVrefresh <= 0) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, subsvstr, 2); + SiSSetSyncRangeFromEdid(pSiS->CRT2pScrn, 0); + } + } #endif + xf86DrvMsg(pScrn->scrnIndex, X_INFO, crtsetupstr, 1); + } +#endif /* end of DDC */ + /* From here, we mainly deal with clocks and modes */ + /* Set the min pixel clock */ - pSiS->MinClock = 12000; /* XXX Guess, need to check this (TW: good for even 50Hz interlace) */ + pSiS->MinClock = 5000; + if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { + pSiS->MinClock = 12000; + } xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Min pixel clock is %d MHz\n", pSiS->MinClock / 1000); @@ -3091,106 +4733,109 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) clockRanges->interlaceAllowed = TRUE; clockRanges->doubleScanAllowed = TRUE; - /* TW: If there is no HSync or VRefresh data for the monitor, - derive it from DDC data. (Idea taken from radeon driver) - */ - if(pScrn->monitor->DDC) { - if(pScrn->monitor->nHsync <= 0) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Substituting missing monitor HSync data by DDC data\n"); - SiSSetSyncRangeFromEdid(pScrn, 1); - } - if(pScrn->monitor->nVrefresh <= 0) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Substituting missing monitor VRefresh data by DDC data\n"); - SiSSetSyncRangeFromEdid(pScrn, 0); - } - } - /* - * TW: Since we have lots of built-in modes for 300/310/325/330 series - * with vb support, we replace the given default mode list with our - * own. In case the video bridge is to be used, no other than our - * built-in modes are supported; therefore, delete the entire modelist - * given. + * Since we have lots of built-in modes for 300/315/330 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 + * -) vbtype is 301, 301B, 301C or 302B, and + * -) crt2 device is not TV, and + * -) crt1 is not LCDA */ - - pSiS->HaveCustomModes = FALSE; if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - if(!(pSiS->noInternalModes)) { - if((mymodes = SiSBuildBuiltInModeList(pScrn))) { -#ifdef SISDUALHEAD - if( (pSiS->UseVESA) || - ((pSiS->DualHeadMode) && (!pSiS->SecondHead)) || - ((!pSiS->DualHeadMode) && (pSiS->VBFlags & DISPTYPE_DISP2)) ) { -#else - if((pSiS->UseVESA) || (pSiS->VBFlags & DISPTYPE_DISP2)) { -#endif - while(pScrn->monitor->Modes) - xf86DeleteMode(&pScrn->monitor->Modes, pScrn->monitor->Modes); - pScrn->monitor->Modes = mymodes; - } else { - delmode = pScrn->monitor->Modes; - while(delmode) { - if(delmode->type & M_T_DEFAULT) { - tempmode = delmode->next; - xf86DeleteMode(&pScrn->monitor->Modes, delmode); - delmode = tempmode; - } else { - delmode = delmode->next; - } - } - tempmode = pScrn->monitor->Modes; - if(tempmode) pSiS->HaveCustomModes = TRUE; - pScrn->monitor->Modes = mymodes; - while(mymodes) { - if(!mymodes->next) break; - else mymodes = mymodes->next; - } - mymodes->next = tempmode; - if(tempmode) { - tempmode->prev = mymodes; - } - } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Replaced %s mode list with built-in modes\n", - pSiS->HaveCustomModes ? "default" : "entire"); + if(!(pSiS->noInternalModes)) { + BOOLEAN acceptcustommodes = TRUE; + BOOLEAN includelcdmodes = TRUE; + BOOLEAN isfordvi = FALSE; + if(pSiS->UseVESA) { + acceptcustommodes = FALSE; + includelcdmodes = FALSE; + } +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + if(!pSiS->SecondHead) { + if((pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)) && (!(pSiS->VBFlags & VB_30xBDH))) { + if(!(pSiS->VBFlags & (CRT2_LCD|CRT2_VGA))) includelcdmodes = FALSE; + if(pSiS->VBFlags & CRT2_LCD) isfordvi = TRUE; + if(pSiS->VBFlags & CRT2_TV) acceptcustommodes = FALSE; + } else { + acceptcustommodes = FALSE; + includelcdmodes = FALSE; + } + clockRanges->interlaceAllowed = FALSE; + } else { + includelcdmodes = FALSE; + if(pSiS->VBFlags & CRT1_LCDA) { + acceptcustommodes = FALSE; + /* Ignore interlace, mode switching code will handle this */ + } + } + } else +#endif +#ifdef SISMERGED + if(pSiS->MergedFB) { + includelcdmodes = FALSE; + if(pSiS->VBFlags & CRT1_LCDA) { + acceptcustommodes = FALSE; + /* Ignore interlace, mode switching code will handle this */ + } + } else +#endif + if((pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)) && (!(pSiS->VBFlags & VB_30xBDH))) { + if(!(pSiS->VBFlags & (CRT2_LCD|CRT2_VGA))) includelcdmodes = FALSE; + if(pSiS->VBFlags & CRT2_LCD) isfordvi = TRUE; + if(pSiS->VBFlags & (CRT2_TV|CRT1_LCDA)) acceptcustommodes = FALSE; + } else if(pSiS->VBFlags & (CRT2_ENABLE | CRT1_LCDA)) { + acceptcustommodes = FALSE; + includelcdmodes = FALSE; + } else { + includelcdmodes = FALSE; + } + /* Ignore interlace, mode switching code will handle this */ + + pSiS->HaveCustomModes = FALSE; + if(SiSMakeOwnModeList(pScrn, acceptcustommodes, includelcdmodes, isfordvi, &pSiS->HaveCustomModes)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Replaced %s mode list with built-in modes\n", + pSiS->HaveCustomModes ? "default" : "entire"); #ifdef TWDEBUG - pScrn->modes = pScrn->monitor->Modes; - xf86PrintModes(pScrn); - pScrn->modes = NULL; -#endif - } else { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + pScrn->modes = pScrn->monitor->Modes; + xf86PrintModes(pScrn); + pScrn->modes = NULL; +#endif + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Building list of built-in modes failed, using XFree86 defaults\n"); - } - } + } + } else { + pSiS->HaveCustomModes = TRUE; + } } /* - * TW: Add our built-in modes for TV on the 6326 + * Add our built-in modes for TV on the 6326 */ if((pSiS->Chipset == PCI_CHIP_SIS6326) && (pSiS->SiS6326Flags & SIS6326_HASTV)) { - if(pSiS->SiS6326Flags & SIS6326_TVDETECTED) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + if(pSiS->SiS6326Flags & SIS6326_TVDETECTED) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Adding %s TV modes for 6326 to mode list:\n", (pSiS->SiS6326Flags & SIS6326_TVPAL) ? "PAL" : "NTSC"); - if(pSiS->SiS6326Flags & SIS6326_TVPAL) { - SiS6326PAL800x600Mode.next = pScrn->monitor->Modes; - pScrn->monitor->Modes = &SiS6326PAL640x480Mode; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "\"PAL800x600\" \"PAL800x600U\" \"PAL720x540\" \"PAL640x480\"\n"); - } else { - SiS6326NTSC640x480Mode.next = pScrn->monitor->Modes; - pScrn->monitor->Modes = &SiS6326NTSC640x400Mode; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "\"NTSC640x480\" \"NTSC640x480U\" \"NTSC640x400\"\n"); - } - } + if(pSiS->SiS6326Flags & SIS6326_TVPAL) { + SiS6326PAL800x600Mode.next = pScrn->monitor->Modes; + pScrn->monitor->Modes = &SiS6326PAL640x480Mode; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "\t\"PAL800x600\" \"PAL800x600U\" \"PAL720x540\" \"PAL640x480\"\n"); + } else { + SiS6326NTSC640x480Mode.next = pScrn->monitor->Modes; + pScrn->monitor->Modes = &SiS6326NTSC640x400Mode; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "\t\"NTSC640x480\" \"NTSC640x480U\" \"NTSC640x400\"\n"); + } + } } /* - * TW: Add our built-in hi-res modes on the 6326 + * Add our built-in hi-res modes on the 6326 */ if(pSiS->Chipset == PCI_CHIP_SIS6326) { if(pScrn->bitsPerPixel == 8) { @@ -3223,21 +4868,44 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) /* Select valid modes from those available */ /* - * Assuming min pitch 256, max 4096 ==> 8192 - * Assuming min height 128, max 4096 + * Assuming min pitch 256, min height 128 */ - i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, - pScrn->display->modes, clockRanges, - NULL, 256, 8192, - pScrn->bitsPerPixel * 8, 128, 4096, + { + int minpitch, maxpitch, minheight, maxheight; + minpitch = 256; + minheight = 128; + switch(pSiS->VGAEngine) { + case SIS_OLD_VGA: + case SIS_530_VGA: + maxpitch = 2040; + maxheight = 2048; + break; + case SIS_300_VGA: + case SIS_315_VGA: + maxpitch = 4088; + maxheight = 4096; + break; + default: + maxpitch = 2048; + maxheight = 2048; + break; + } +#ifdef SISMERGED + pSiS->CheckForCRT2 = FALSE; +#endif + i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, + pScrn->display->modes, clockRanges, NULL, + minpitch, maxpitch, + pScrn->bitsPerPixel * 8, + minheight, maxheight, pScrn->display->virtualX, pScrn->display->virtualY, pSiS->maxxfbmem, LOOKUP_BEST_REFRESH); + } if(i == -1) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "xf86ValidateModes() error\n"); + SISErrorLog(pScrn, "xf86ValidateModes() error\n"); #ifdef SISDUALHEAD if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif @@ -3247,129 +4915,74 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) return FALSE; } - /* TW: Go through mode list and mark all those modes as bad, - * - which are unsuitable for dual head mode (if running dhm), - * - which exceed the LCD panels specs (if running on LCD) - * - TODO: which exceed TV capabilities (if running on TV) - * Also, find the highest used pixelclock on the master head. - */ -#ifdef SISDUALHEAD - if(pSiS->DualHeadMode) { - if(!pSiS->SecondHead) pSiSEnt->maxUsedClock = 0; - } -#endif - if((p = first = pScrn->modes)) { - do { - n = p->next; - - /* TW: Check the modes if they comply with our built-in tables. - * This is of practical use only if the user disabled the - * usage of the internal (built-in) modes. - */ - if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - if(p->type & M_T_DEFAULT) { - if( ( (strcmp(p->name, "320x200") != 0) && - (strcmp(p->name, "320x240") != 0) && - (strcmp(p->name, "400x300") != 0) && - (strcmp(p->name, "512x384") != 0) ) && - (p->Flags & V_DBLSCAN) ) { - p->status = MODE_NO_DBLESCAN; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Not using mode \"%s\" (mode not supported as doublescan)\n", p->name); - } - if( ( (strcmp(p->name, "1024x768") != 0) && - (strcmp(p->name, "1280x1024") != 0) && - (strcmp(p->name, "848x480") != 0) && - (strcmp(p->name, "856x480") != 0)) && - (p->Flags & V_INTERLACE) ) { - p->status = MODE_NO_INTERLACE; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Not using mode \"%s\" (mode not supported as interlaced)\n", p->name); - } - if( ( (strcmp(p->name, "320x200") == 0) || - (strcmp(p->name, "320x240") == 0) || - (strcmp(p->name, "400x300") == 0) || - (strcmp(p->name, "512x384") == 0) ) && - (!(p->Flags & V_DBLSCAN)) ) { - p->status = MODE_CLOCK_RANGE; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Not using mode \"%s\" (only supported as doublescan)\n", p->name); - } - } - } + /* Check the virtual screen against the available memory */ + { + unsigned long memreq = (pScrn->virtualX * ((pScrn->bitsPerPixel + 7) / 8)) * pScrn->virtualY; + + if(memreq > pSiS->maxxfbmem) { + SISErrorLog(pScrn, + "Virtual screen too big for memory; %ldK needed, %ldK available\n", + memreq/1024, pSiS->maxxfbmem/1024); #ifdef SISDUALHEAD - /* TW: Modes that require the bridge to operate in SlaveMode - * are not suitable for Dual Head mode. Also check for - * modes that exceed panel dimension. - */ - if(pSiS->DualHeadMode) { - if(pSiS->SecondHead == FALSE) { - if( (strcmp(p->name, "320x200") == 0) || - (strcmp(p->name, "320x240") == 0) || - (strcmp(p->name, "400x300") == 0) || - (strcmp(p->name, "512x384") == 0) || - (strcmp(p->name, "640x400") == 0) ) { - p->status = MODE_BAD; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Not using mode \"%s\" (not suitable for dual head mode)\n", - p->name); - } - } - if(pSiS->VBFlags & DISPTYPE_DISP2) { - if(pSiS->VBFlags & CRT2_LCD) { - if(pSiS->SecondHead == FALSE) { - if((p->HDisplay > pSiS->LCDwidth) || (p->VDisplay > pSiS->LCDheight)) { - p->status = MODE_PANEL; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Not using mode \"%s\" (exceeds LCD panel dimension)\n", p->name); - } - if(p->Flags & V_INTERLACE) { - p->status = MODE_BAD; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Not using mode \"%s\" (interlace on LCD not supported)\n", - p->name); - } - } - } - /* TO DO: TV */ - } - /* TW: Search for the highest clock on first head in order to calculate - * max clock for second head (CRT1) - */ - if(!pSiS->SecondHead) { - if((p->status == MODE_OK) && (p->Clock > pSiSEnt->maxUsedClock)) { - pSiSEnt->maxUsedClock = p->Clock; - } - } - } else { + if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif - if(pSiS->VBFlags & DISPTYPE_DISP2) { - if(pSiS->VBFlags & CRT2_LCD) { - if((p->HDisplay > pSiS->LCDwidth) || (p->VDisplay > pSiS->LCDheight)) { - p->status = MODE_PANEL; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Not using mode \"%s\" (exceeds LCD panel dimension)\n", p->name); - } - if(p->Flags & V_INTERLACE) { - p->status = MODE_BAD; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Not using mode \"%s\" (interlace on LCD not supported)\n", - p->name); - } - } - } + if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + pSiS->pInt = NULL; + sisRestoreExtRegisterLock(pSiS,srlockReg,crlockReg); + SISFreeRec(pScrn); + return FALSE; + } + } + + /* Dual Head: + * -) Go through mode list and mark all those modes as bad, + * which are unsuitable for dual head mode. + * -) Find the highest used pixelclock on the master head. + */ #ifdef SISDUALHEAD - } -#endif - p = n; - } while (p != NULL && p != first); + if(pSiS->DualHeadMode) { + + if(!pSiS->SecondHead) { + + pSiSEnt->maxUsedClock = 0; + + if((p = first = pScrn->modes)) { + do { + n = p->next; + + /* Modes that require the bridge to operate in SlaveMode + * are not suitable for Dual Head mode. + */ + if( (pSiS->VGAEngine == SIS_300_VGA) && + ( (strcmp(p->name, "320x200") == 0) || + (strcmp(p->name, "320x240") == 0) || + (strcmp(p->name, "400x300") == 0) || + (strcmp(p->name, "512x384") == 0) || + (strcmp(p->name, "640x400") == 0) ) ) { + p->status = MODE_BAD; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, notsuitablestr, p->name, "dual head"); + } + + /* Search for the highest clock on first head in order to calculate + * max clock for second head (CRT1) + */ + if((p->status == MODE_OK) && (p->Clock > pSiSEnt->maxUsedClock)) { + pSiSEnt->maxUsedClock = p->Clock; + } + + p = n; + + } while (p != NULL && p != first); + } + } } +#endif /* Prune the modes marked as invalid */ xf86PruneDriverModes(pScrn); if(i == 0 || pScrn->modes == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + SISErrorLog(pScrn, "No valid modes found\n"); #ifdef SISDUALHEAD if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif @@ -3384,50 +4997,191 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) /* Set the current mode to the first in the list */ pScrn->currentMode = pScrn->modes; - /* TW: Copy to CurrentLayout */ + /* Copy to CurrentLayout */ pSiS->CurrentLayout.mode = pScrn->currentMode; pSiS->CurrentLayout.displayWidth = pScrn->displayWidth; +#ifdef SISMERGED + if(pSiS->MergedFB) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, modesforstr, 1); + } +#endif + /* Print the list of modes being used */ xf86PrintModes(pScrn); -#ifdef SISDUALHEAD - /* TW: Due to palette & timing problems we don't support 8bpp in DHM */ - if((pSiS->DualHeadMode) && (pScrn->bitsPerPixel == 8)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Colordepth 8 not supported in Dual Head mode.\n"); - if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; - if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); - sisRestoreExtRegisterLock(pSiS,srlockReg,crlockReg); - SISFreeRec(pScrn); - return FALSE; +#ifdef SISMERGED + if(pSiS->MergedFB) { + BOOLEAN acceptcustommodes = TRUE; + BOOLEAN includelcdmodes = TRUE; + BOOLEAN isfordvi = FALSE; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, crtsetupstr, 2); + + clockRanges->next = NULL; + clockRanges->minClock = pSiS->MinClock; + clockRanges->maxClock = SiSMemBandWidth(pSiS->CRT2pScrn, TRUE); + clockRanges->clockIndex = -1; + clockRanges->interlaceAllowed = FALSE; + clockRanges->doubleScanAllowed = FALSE; + if(pSiS->VGAEngine == SIS_315_VGA) { + clockRanges->doubleScanAllowed = TRUE; + } + + xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Min pixel clock for CRT2 is %d MHz\n", + clockRanges->minClock / 1000); + xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Max pixel clock for CRT2 is %d MHz\n", + clockRanges->maxClock / 1000); + + if((pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)) && (!(pSiS->VBFlags & VB_30xBDH))) { + if(!(pSiS->VBFlags & (CRT2_LCD|CRT2_VGA))) includelcdmodes = FALSE; + if(pSiS->VBFlags & CRT2_LCD) isfordvi = TRUE; + if(pSiS->VBFlags & CRT2_TV) acceptcustommodes = FALSE; + } else { + includelcdmodes = FALSE; + acceptcustommodes = FALSE; + } + + pSiS->HaveCustomModes2 = FALSE; + if(!SiSMakeOwnModeList(pSiS->CRT2pScrn, acceptcustommodes, includelcdmodes, isfordvi, &pSiS->HaveCustomModes2)) { + + SISErrorLog(pScrn, "Building list of built-in modes for CRT2 failed, %s\n", + mergeddisstr); + SiSFreeCRT2Structs(pSiS); + pSiS->MergedFB = FALSE; + + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Replaced %s mode list for CRT2 with built-in modes\n", + pSiS->HaveCustomModes2 ? "default" : "entire"); + } + + } + + if(pSiS->MergedFB) { + + pSiS->CheckForCRT2 = TRUE; + i = xf86ValidateModes(pSiS->CRT2pScrn, pSiS->CRT2pScrn->monitor->Modes, + pSiS->CRT2pScrn->display->modes, clockRanges, + NULL, 256, 4088, + pSiS->CRT2pScrn->bitsPerPixel * 8, 128, 4096, + pScrn->display->virtualX ? pScrn->virtualX : 0, + pScrn->display->virtualY ? pScrn->virtualY : 0, + pSiS->maxxfbmem, + LOOKUP_BEST_REFRESH); + pSiS->CheckForCRT2 = FALSE; + + if(i == -1) { + SISErrorLog(pScrn, "xf86ValidateModes() error, %s.\n", mergeddisstr); + SiSFreeCRT2Structs(pSiS); + pSiS->MergedFB = FALSE; + } + + } + + if(pSiS->MergedFB) { + + if((p = first = pSiS->CRT2pScrn->modes)) { + do { + n = p->next; + if( (pSiS->VGAEngine == SIS_300_VGA) && + ( (strcmp(p->name, "320x200") == 0) || + (strcmp(p->name, "320x240") == 0) || + (strcmp(p->name, "400x300") == 0) || + (strcmp(p->name, "512x384") == 0) || + (strcmp(p->name, "640x400") == 0) ) ) { + p->status = MODE_BAD; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, notsuitablestr, p->name, "MergedFB"); + } + p = n; + } while (p != NULL && p != first); + } + + xf86PruneDriverModes(pSiS->CRT2pScrn); + + if(i == 0 || pSiS->CRT2pScrn->modes == NULL) { + SISErrorLog(pScrn, "No valid modes found for CRT2; %s\n", mergeddisstr); + SiSFreeCRT2Structs(pSiS); + pSiS->MergedFB = FALSE; + } + + } + + if(pSiS->MergedFB) { + + xf86SetCrtcForModes(pSiS->CRT2pScrn, INTERLACE_HALVE_V); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, modesforstr, 2); + + xf86PrintModes(pSiS->CRT2pScrn); + + pSiS->CRT1Modes = pScrn->modes; + pSiS->CRT1CurrentMode = pScrn->currentMode; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Generating MergedFB mode list\n"); + + pScrn->modes = SiSGenerateModeList(pScrn, pSiS->MetaModes, + pSiS->CRT1Modes, pSiS->CRT2pScrn->modes, + pSiS->CRT2Position); + + if(!pScrn->modes) { + + SISErrorLog(pScrn, "Failed to parse MetaModes or no modes found. %s.\n", + mergeddisstr); + SiSFreeCRT2Structs(pSiS); + pScrn->modes = pSiS->CRT1Modes; + pSiS->CRT1Modes = NULL; + pSiS->MergedFB = FALSE; + + } + + } + + if(pSiS->MergedFB) { + + /* If no virtual dimension was given by the user, + * calculate a sane one now. Adapts pScrn->virtualX, + * pScrn->virtualY and pScrn->displayWidth. + */ + SiSRecalcDefaultVirtualSize(pScrn); + + pScrn->modes = pScrn->modes->next; /* We get the last from GenerateModeList(), skip to first */ + pScrn->currentMode = pScrn->modes; + + /* Update CurrentLayout */ + pSiS->CurrentLayout.mode = pScrn->currentMode; + pSiS->CurrentLayout.displayWidth = pScrn->displayWidth; + } #endif /* Set display resolution */ - xf86SetDpi(pScrn, 0, 0); +#ifdef SISMERGED + if(pSiS->MergedFB) { + SiSMergedFBSetDpi(pScrn, pSiS->CRT2pScrn, pSiS->CRT2Position); + } else +#endif + xf86SetDpi(pScrn, 0, 0); - /* Load bpp-specific modules */ + /* Load fb module */ switch(pScrn->bitsPerPixel) { - case 1: - mod = "xf1bpp"; - Sym = "xf1bppScreenInit"; - break; - case 4: - mod = "xf4bpp"; - Sym = "xf4bppScreenInit"; - break; case 8: case 16: case 24: case 32: - mod = "fb"; + if(!xf86LoadSubModule(pScrn, "fb")) { + SISErrorLog(pScrn, "Failed to load fb module"); +#ifdef SISDUALHEAD + if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; +#endif + if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); + sisRestoreExtRegisterLock(pSiS,srlockReg,crlockReg); + SISFreeRec(pScrn); + return FALSE; + } break; - } - - if(mod && xf86LoadSubModule(pScrn, mod) == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not load %s module", mod); + default: + SISErrorLog(pScrn, "Unsupported framebuffer bpp (%d)\n", pScrn->bitsPerPixel); #ifdef SISDUALHEAD if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif @@ -3436,21 +5190,13 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) SISFreeRec(pScrn); return FALSE; } - - if(mod) { - if(Sym) { - xf86LoaderReqSymbols(Sym, NULL); - } else { - xf86LoaderReqSymLists(fbSymbols, NULL); - } - } + xf86LoaderReqSymLists(fbSymbols, NULL); /* Load XAA if needed */ if(!pSiS->NoAccel) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Accel enabled\n"); if(!xf86LoadSubModule(pScrn, "xaa")) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not load xaa module\n"); + SISErrorLog(pScrn, "Could not load xaa module\n"); #ifdef SISDUALHEAD if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif @@ -3465,8 +5211,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) /* Load shadowfb if needed */ if(pSiS->ShadowFB) { if(!xf86LoadSubModule(pScrn, "shadowfb")) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not load shadowfb module\n"); + SISErrorLog(pScrn, "Could not load shadowfb module\n"); #ifdef SISDUALHEAD if(pSiSEnt) pSiSEnt->ErrorAfterFirst = TRUE; #endif @@ -3478,8 +5223,22 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) xf86LoaderReqSymLists(shadowSymbols, NULL); } + /* Load the dri module if requested. */ +#ifdef XF86DRI + if(pSiS->loadDRI) { + if(xf86LoadSubModule(pScrn, "dri")) { + xf86LoaderReqSymLists(driSymbols, drmSymbols, NULL); + } else { +#ifdef SISDUALHEAD + if(!pSiS->DualHeadMode) +#endif + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Remove >Load \"dri\"< from the Module section of your XF86Config file\n"); + } + } +#endif - /* TW: Now load and initialize VBE module for VESA. */ + /* Now load and initialize VBE module for VESA and mode restoring. */ pSiS->UseVESA = 0; if(pSiS->VESA == 1) { if(!pSiS->pVbe) { @@ -3489,24 +5248,27 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) pSiS->pVbe = VBEInit(pSiS->pInt,pSiS->pEnt->index); #else pSiS->pVbe = VBEExtendedInit(pSiS->pInt,pSiS->pEnt->index, - SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH); + SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH); #endif } } if(pSiS->pVbe) { - vbe = VBEGetVBEInfo(pSiS->pVbe); - pSiS->vesamajor = (unsigned)(vbe->VESAVersion >> 8); - pSiS->vesaminor = vbe->VESAVersion & 0xff; - pSiS->vbeInfo = vbe; - SiSBuildVesaModeList(pScrn, pSiS->pVbe, vbe); - VBEFreeVBEInfo(vbe); - pSiS->UseVESA = 1; + vbe = VBEGetVBEInfo(pSiS->pVbe); + pSiS->vesamajor = (unsigned)(vbe->VESAVersion >> 8); + pSiS->vesaminor = vbe->VESAVersion & 0xff; + pSiS->vbeInfo = vbe; + if(pSiS->VESA == 1) { + SiSBuildVesaModeList(pScrn, pSiS->pVbe, vbe); + VBEFreeVBEInfo(vbe); + pSiS->UseVESA = 1; + } } else { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Could not load and initialize VBE module. VESA disabled.\n"); + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Could not load and initialize VBE module.%s\n", + (pSiS->VESA == 1) ? " VESA disabled." : ""); } - } - + } + if(pSiS->pVbe) { vbeFree(pSiS->pVbe); pSiS->pVbe = NULL; @@ -3521,6 +5283,28 @@ SISPreInit(ScrnInfoPtr pScrn, int flags) if(pSiS->pInt) xf86FreeInt10(pSiS->pInt); pSiS->pInt = NULL; + if(pSiS->VGAEngine == SIS_315_VGA) pSiS->SiS_SD_Flags |= SiS_SD_SUPPORTXVGAMMA1; + +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + pSiS->SiS_SD_Flags |= SiS_SD_ISDUALHEAD; + if(pSiS->SecondHead) pSiS->SiS_SD_Flags |= SiS_SD_ISDHSECONDHEAD; + else pSiS->SiS_SD_Flags &= ~(SiS_SD_SUPPORTXVGAMMA1); +#ifdef PANORAMIX + if(!noPanoramiXExtension) { + pSiS->SiS_SD_Flags |= SiS_SD_ISDHXINERAMA; + pSiS->SiS_SD_Flags &= ~(SiS_SD_SUPPORTXVGAMMA1); + } +#endif + } +#endif + +#ifdef SISMERGED + if(pSiS->MergedFB) pSiS->SiS_SD_Flags |= SiS_SD_ISMERGEDFB; +#endif + + if(pSiS->enablesisctrl) pSiS->SiS_SD_Flags |= SiS_SD_ENABLED; + return TRUE; } @@ -3560,7 +5344,7 @@ SISMapMem(ScrnInfoPtr pScrn) if(pSiS->DualHeadMode) { pSiSEnt->MapCountIOBase++; if(!(pSiSEnt->IOBase)) { - /* TW: Only map if not mapped previously */ + /* Only map if not mapped previously */ pSiSEnt->IOBase = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, pSiS->PciTag, pSiS->IOAddress, 0x10000); } @@ -3571,8 +5355,7 @@ SISMapMem(ScrnInfoPtr pScrn) pSiS->PciTag, pSiS->IOAddress, 0x10000); if(pSiS->IOBase == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not map MMIO area\n"); + SISErrorLog(pScrn, "Could not map MMIO area\n"); return FALSE; } @@ -3585,7 +5368,7 @@ SISMapMem(ScrnInfoPtr pScrn) if(pSiS->DualHeadMode) { pSiSEnt->MapCountIOBaseDense++; if(!(pSiSEnt->IOBaseDense)) { - /* TW: Only map if not mapped previously */ + /* Only map if not mapped previously */ pSiSEnt->IOBaseDense = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pSiS->PciTag, pSiS->IOAddress, 0x10000); } @@ -3596,9 +5379,8 @@ SISMapMem(ScrnInfoPtr pScrn) pSiS->PciTag, pSiS->IOAddress, 0x10000); if(pSiS->IOBaseDense == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not map MMIO dense area\n"); - return FALSE; + SISErrorLog(pScrn, "Could not map MMIO dense area\n"); + return FALSE; } #endif /* __alpha__ */ @@ -3607,14 +5389,14 @@ SISMapMem(ScrnInfoPtr pScrn) if(pSiS->DualHeadMode) { pSiSEnt->MapCountFbBase++; if(!(pSiSEnt->FbBase)) { - /* TW: Only map if not mapped previously */ + /* Only map if not mapped previously */ pSiSEnt->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, pSiS->PciTag, (unsigned long)pSiS->realFbAddress, pSiS->FbMapSize); pSiS->sishw_ext.pjVideoMemoryAddress = (UCHAR *)pSiSEnt->FbBase; } pSiS->FbBase = pSiSEnt->FbBase; - /* TW: Adapt FbBase (for DHM; dhmOffset is 0 otherwise) */ + /* Adapt FbBase (for DHM; dhmOffset is 0 otherwise) */ pSiS->FbBase += pSiS->dhmOffset; } else { #endif @@ -3627,9 +5409,8 @@ SISMapMem(ScrnInfoPtr pScrn) #endif if(pSiS->FbBase == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not map framebuffer area\n"); - return FALSE; + SISErrorLog(pScrn, "Could not map framebuffer area\n"); + return FALSE; } return TRUE; @@ -3654,14 +5435,14 @@ SISUnmapMem(ScrnInfoPtr pScrn) pSiSEnt = pSiS->entityPrivate; #endif -/* TW: In dual head mode, we must not unmap if the other head still - * assumes memory as mapped -*/ +/* In dual head mode, we must not unmap if the other head still + * assumes memory as mapped + */ #ifdef SISDUALHEAD - if (pSiS->DualHeadMode) { - if (pSiSEnt->MapCountIOBase) { + if(pSiS->DualHeadMode) { + if(pSiSEnt->MapCountIOBase) { pSiSEnt->MapCountIOBase--; - if ((pSiSEnt->MapCountIOBase == 0) || (pSiSEnt->forceUnmapIOBase)) { + if((pSiSEnt->MapCountIOBase == 0) || (pSiSEnt->forceUnmapIOBase)) { xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pSiSEnt->IOBase, 0x10000); pSiSEnt->IOBase = NULL; pSiSEnt->MapCountIOBase = 0; @@ -3670,9 +5451,9 @@ SISUnmapMem(ScrnInfoPtr pScrn) pSiS->IOBase = NULL; } #ifdef __alpha__ - if (pSiSEnt->MapCountIOBaseDense) { + if(pSiSEnt->MapCountIOBaseDense) { pSiSEnt->MapCountIOBaseDense--; - if ((pSiSEnt->MapCountIOBaseDense == 0) || (pSiSEnt->forceUnmapIOBaseDense)) { + if((pSiSEnt->MapCountIOBaseDense == 0) || (pSiSEnt->forceUnmapIOBaseDense)) { xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pSiSEnt->IOBaseDense, 0x10000); pSiSEnt->IOBaseDense = NULL; pSiSEnt->MapCountIOBaseDense = 0; @@ -3681,9 +5462,9 @@ SISUnmapMem(ScrnInfoPtr pScrn) pSiS->IOBaseDense = NULL; } #endif /* __alpha__ */ - if (pSiSEnt->MapCountFbBase) { + if(pSiSEnt->MapCountFbBase) { pSiSEnt->MapCountFbBase--; - if ((pSiSEnt->MapCountFbBase == 0) || (pSiSEnt->forceUnmapFbBase)) { + if((pSiSEnt->MapCountFbBase == 0) || (pSiSEnt->forceUnmapFbBase)) { xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pSiSEnt->FbBase, pSiS->FbMapSize); pSiSEnt->FbBase = NULL; pSiSEnt->MapCountFbBase = 0; @@ -3721,39 +5502,51 @@ SISSave(ScrnInfoPtr pScrn) pSiS = SISPTR(pScrn); #ifdef SISDUALHEAD - /* TW: We always save master & slave */ + /* We always save master & slave */ if(pSiS->DualHeadMode && pSiS->SecondHead) return; #endif vgaReg = &VGAHWPTR(pScrn)->SavedReg; sisReg = &pSiS->SavedReg; - vgaHWSave(pScrn, vgaReg, VGA_SR_ALL); + 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); + } + } else { + vgaHWSave(pScrn, vgaReg, VGA_SR_ALL); + } sisSaveUnlockExtRegisterLock(pSiS,&sisReg->sisRegs3C4[0x05],&sisReg->sisRegs3D4[0x80]); (*pSiS->SiSSave)(pScrn, sisReg); - + if(pSiS->UseVESA) SISVESASaveRestore(pScrn, MODE_SAVE); - - /* TW: Save these as they may have been changed prior to SISSave() call */ + + /* "Save" these again as they may have been changed prior to SISSave() call */ if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - sisReg->sisRegs3D4[0x17] = pSiS->oldCR17; - if(vgaReg->numCRTC >= 0x17) vgaReg->CRTC[0x17] = pSiS->oldCR17; - sisReg->sisRegs3D4[0x32] = pSiS->oldCR32; + sisReg->sisRegs3D4[0x17] = pSiS->oldCR17; + if(vgaReg->numCRTC >= 0x17) vgaReg->CRTC[0x17] = pSiS->oldCR17; + sisReg->sisRegs3D4[0x32] = pSiS->oldCR32; + sisReg->sisRegs3C4[0x1f] = pSiS->oldSR1F; + if(pSiS->VGAEngine == SIS_315_VGA) { + sisReg->sisRegs3D4[0x63] = pSiS->oldCR63; + } } } -/* - * TW: Just adapted from the std* functions in vgaHW.c - */ static void SiS_WriteAttr(SISPtr pSiS, int index, int value) { - CARD8 tmp; - - tmp = inb(pSiS->IODBase + VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); - + (void) inb(pSiS->IODBase + VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); index |= 0x20; outb(pSiS->IODBase + VGA_ATTR_INDEX, index); outb(pSiS->IODBase + VGA_ATTR_DATA_W, value); @@ -3762,15 +5555,13 @@ SiS_WriteAttr(SISPtr pSiS, int index, int value) static int SiS_ReadAttr(SISPtr pSiS, int index) { - CARD8 tmp; - - tmp = inb(pSiS->IODBase + VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); - + (void) inb(pSiS->IODBase + VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); index |= 0x20; outb(pSiS->IODBase + VGA_ATTR_INDEX, index); - return (inb(pSiS->IODBase + VGA_ATTR_DATA_R)); + return(inb(pSiS->IODBase + VGA_ATTR_DATA_R)); } +#define SIS_FONTS_SIZE (8 * 8192) static void SiS_SaveFonts(ScrnInfoPtr pScrn) @@ -3783,15 +5574,17 @@ SiS_SaveFonts(ScrnInfoPtr pScrn) pointer vgaIOBase = VGAHWPTR(pScrn)->Base; #endif - if (pSiS->fonts != NULL) - return; + if(pSiS->fonts) return; /* If in graphics mode, don't save anything */ attr10 = SiS_ReadAttr(pSiS, 0x10); - if (attr10 & 0x01) - return; + if(attr10 & 0x01) return; - pSiS->fonts = xalloc(16384); + if(!(pSiS->fonts = xalloc(SIS_FONTS_SIZE * 2))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Could not save console fonts, mem allocation failed\n"); + return; + } /* save the registers that are needed here */ miscOut = inSISREG(SISMISCR); @@ -3817,7 +5610,7 @@ SiS_SaveFonts(ScrnInfoPtr pScrn) outSISIDXREG(SISGR, 0x04, 0x02); /* read plane 2 */ outSISIDXREG(SISGR, 0x05, 0x00); /* write mode 0, read mode 0 */ outSISIDXREG(SISGR, 0x06, 0x05); /* set graphics */ - slowbcopy_frombus(vgaIOBase, pSiS->fonts, 8192); + slowbcopy_frombus(vgaIOBase, pSiS->fonts, SIS_FONTS_SIZE); /* font2 */ outSISIDXREG(SISSR, 0x02, 0x08); /* write to plane 3 */ @@ -3825,7 +5618,7 @@ SiS_SaveFonts(ScrnInfoPtr pScrn) outSISIDXREG(SISGR, 0x04, 0x03); /* read plane 3 */ outSISIDXREG(SISGR, 0x05, 0x00); /* write mode 0, read mode 0 */ outSISIDXREG(SISGR, 0x06, 0x05); /* set graphics */ - slowbcopy_frombus(vgaIOBase, pSiS->fonts + 8192, 8192); + slowbcopy_frombus(vgaIOBase, pSiS->fonts + SIS_FONTS_SIZE, SIS_FONTS_SIZE); inSISIDXREG(SISSR, 0x01, scrn); outSISIDXREG(SISSR, 0x00, 0x01); @@ -3853,13 +5646,7 @@ SiS_RestoreFonts(ScrnInfoPtr pScrn) pointer vgaIOBase = VGAHWPTR(pScrn)->Base; #endif - if (pSiS->fonts == NULL) - return; - -#if 0 - if (pVesa->mapPhys == 0xa0000 && pVesa->curBank != 0) - VESABankSwitch(pScrn->pScreen, 0); -#endif + if(!pSiS->fonts) return; /* save the registers that are needed here */ miscOut = inSISREG(SISMISCR); @@ -3881,10 +5668,10 @@ SiS_RestoreFonts(ScrnInfoPtr pScrn) outSISIDXREG(SISSR, 0x00, 0x03); SiS_WriteAttr(pSiS, 0x10, 0x01); /* graphics mode */ - if (pScrn->depth == 4) { - outSISIDXREG(SISGR, 0x03, 0x00); /* don't rotate, write unmodified */ - outSISIDXREG(SISGR, 0x08, 0xFF); /* write all bits in a byte */ - outSISIDXREG(SISGR, 0x01, 0x00); /* all planes come from CPU */ + if(pScrn->depth == 4) { + outSISIDXREG(SISGR, 0x03, 0x00); /* don't rotate, write unmodified */ + outSISIDXREG(SISGR, 0x08, 0xFF); /* write all bits in a byte */ + outSISIDXREG(SISGR, 0x01, 0x00); /* all planes come from CPU */ } outSISIDXREG(SISSR, 0x02, 0x04); /* write to plane 2 */ @@ -3892,14 +5679,14 @@ SiS_RestoreFonts(ScrnInfoPtr pScrn) outSISIDXREG(SISGR, 0x04, 0x02); /* read plane 2 */ outSISIDXREG(SISGR, 0x05, 0x00); /* write mode 0, read mode 0 */ outSISIDXREG(SISGR, 0x06, 0x05); /* set graphics */ - slowbcopy_tobus(pSiS->fonts, vgaIOBase, 8192); + slowbcopy_tobus(pSiS->fonts, vgaIOBase, SIS_FONTS_SIZE); outSISIDXREG(SISSR, 0x02, 0x08); /* write to plane 3 */ outSISIDXREG(SISSR, 0x04, 0x06); /* enable plane graphics */ outSISIDXREG(SISGR, 0x04, 0x03); /* read plane 3 */ outSISIDXREG(SISGR, 0x05, 0x00); /* write mode 0, read mode 0 */ outSISIDXREG(SISGR, 0x06, 0x05); /* set graphics */ - slowbcopy_tobus(pSiS->fonts + 8192, vgaIOBase, 8192); + slowbcopy_tobus(pSiS->fonts + SIS_FONTS_SIZE, vgaIOBase, SIS_FONTS_SIZE); inSISIDXREG(SISSR, 0x01, scrn); outSISIDXREG(SISSR, 0x00, 0x01); @@ -3919,93 +5706,62 @@ SiS_RestoreFonts(ScrnInfoPtr pScrn) outSISIDXREG(SISSR, 0x04, seq4); } -/* TW: VESASaveRestore taken from vesa driver */ +#undef SIS_FONTS_SIZE + +/* VESASaveRestore taken from vesa driver */ static void SISVESASaveRestore(ScrnInfoPtr pScrn, vbeSaveRestoreFunction function) { - SISPtr pSiS; - - pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); /* Query amount of memory to save state */ - if (function == MODE_QUERY || - (function == MODE_SAVE && pSiS->state == NULL)) { - - /* Make sure we save at least this information in case of failure */ - (void)VBEGetVBEMode(pSiS->pVbe, &pSiS->stateMode); - SiS_SaveFonts(pScrn); + if((function == MODE_QUERY) || + (function == MODE_SAVE && pSiS->state == NULL)) { - if (pSiS->vesamajor > 1) { - if (!VBESaveRestore(pSiS->pVbe,function,(pointer)&pSiS->state, - &pSiS->stateSize,&pSiS->statePage)) - return; + /* Make sure we save at least this information in case of failure */ + (void)VBEGetVBEMode(pSiS->pVbe, &pSiS->stateMode); + SiS_SaveFonts(pScrn); - } + if(pSiS->vesamajor > 1) { + if(!VBESaveRestore(pSiS->pVbe, function, (pointer)&pSiS->state, + &pSiS->stateSize, &pSiS->statePage)) { + return; + } + } } /* Save/Restore Super VGA state */ - if (function != MODE_QUERY) { - Bool retval = TRUE; - - if (pSiS->vesamajor > 1) { - if (function == MODE_RESTORE) - memcpy(pSiS->state, pSiS->pstate, pSiS->stateSize); - - if ((retval = VBESaveRestore(pSiS->pVbe,function, - (pointer)&pSiS->state, - &pSiS->stateSize,&pSiS->statePage)) - && function == MODE_SAVE) { - /* don't rely on the memory not being touched */ - if (pSiS->pstate == NULL) - pSiS->pstate = xalloc(pSiS->stateSize); - memcpy(pSiS->pstate, pSiS->state, pSiS->stateSize); - } - } + if(function != MODE_QUERY) { - if (function == MODE_RESTORE) { - VBESetVBEMode(pSiS->pVbe, pSiS->stateMode, NULL); - SiS_RestoreFonts(pScrn); - } -#if 0 - if (!retval) - return (FALSE); -#endif + if(pSiS->vesamajor > 1) { + if(function == MODE_RESTORE) { + memcpy(pSiS->state, pSiS->pstate, pSiS->stateSize); + } + + if(VBESaveRestore(pSiS->pVbe,function,(pointer)&pSiS->state, + &pSiS->stateSize,&pSiS->statePage) && + (function == MODE_SAVE)) { + /* don't rely on the memory not being touched */ + if(!pSiS->pstate) { + pSiS->pstate = xalloc(pSiS->stateSize); + } + memcpy(pSiS->pstate, pSiS->state, pSiS->stateSize); + } + } + + if(function == MODE_RESTORE) { + VBESetVBEMode(pSiS->pVbe, pSiS->stateMode, NULL); + SiS_RestoreFonts(pScrn); + } } -#if 0 - if ( (pSiS->vesamajor > 1) && - (function == MODE_SAVE || pSiS->pstate) ) { - if (function == MODE_RESTORE) - memcpy(pSiS->state, pSiS->pstate, pSiS->stateSize); - if ((VBESaveRestore(pSiS->pVbe,function, - (pointer)&pSiS->state, - &pSiS->stateSize,&pSiS->statePage))) { - if (function == MODE_SAVE) { - /* don't rely on the memory not being touched */ - if (pSiS->pstate == NULL) - pSiS->pstate = xalloc(pSiS->stateSize); - memcpy(pSiS->pstate, pSiS->state, pSiS->stateSize); - } - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "VBESaveRestore done with success\n"); - return; - } - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "VBESaveRestore done\n"); - } else { - if (function == MODE_SAVE) - (void)VBEGetVBEMode(pSiS->pVbe, &pSiS->stateMode); - else - VBESetVBEMode(pSiS->pVbe, pSiS->stateMode, NULL); - } -#endif } /* * Initialise a new mode. This is currently done using the * "initialise struct, restore/write struct to HW" model for * the old chipsets (5597/530/6326). For newer chipsets, - * we use either VESA or our own mode switching code. + * we use our own mode switching code (or VESA). */ static Bool @@ -4015,197 +5771,226 @@ SISModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) vgaRegPtr vgaReg; SISPtr pSiS = SISPTR(pScrn); SISRegPtr sisReg; +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = NULL; +#endif - vgaHWUnlock(hwp); + andSISIDXREG(SISCR,0x11,0x7f); /* Unlock CRTC registers */ - SISModifyModeInfo(mode); + SISModifyModeInfo(mode); /* Quick check of the mode parameters */ - /* TW: Initialize SiS Port Register definitions for externally used - * BIOS emulation (native code switching) functions. - */ - if( pSiS->VGAEngine == SIS_300_VGA || - pSiS->VGAEngine == SIS_315_VGA ) { + if(pSiS->VGAEngine == SIS_300_VGA || pSiS->VGAEngine == SIS_315_VGA) { SiSRegInit(pSiS->SiS_Pr, pSiS->RelIO+0x30); } - if (pSiS->UseVESA) { /* With VESA: */ + if(pSiS->UseVESA) { /* With VESA: */ #ifdef SISDUALHEAD - /* TW: No dual head mode when using VESA */ - if (pSiS->SecondHead) return TRUE; + /* No dual head mode when using VESA */ + if(pSiS->SecondHead) return TRUE; #endif - /* - * TW: This order is required: - * The video bridge needs to be adjusted before the - * BIOS is run as the BIOS sets up CRT2 according to - * these register settings. - * After the BIOS is run, the bridges and turboqueue - * registers need to be readjusted as the BIOS may - * very probably have messed them up. - */ - if( pSiS->VGAEngine == SIS_300_VGA || - pSiS->VGAEngine == SIS_315_VGA ) { - SiSPreSetMode(pScrn, mode); - } - if(!SiSSetVESAMode(pScrn, mode)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "SiSSetVESAMode() failed\n"); - return FALSE; - } - sisSaveUnlockExtRegisterLock(pSiS,NULL,NULL); - if( pSiS->VGAEngine == SIS_300_VGA || - pSiS->VGAEngine == SIS_315_VGA ) { - SiSPreSetMode(pScrn, mode); - SiSPostSetMode(pScrn, &pSiS->ModeReg); - } - /* TW: Prepare some register contents and set - * up some mode dependent variables. - */ + + pScrn->vtSema = TRUE; + + /* + * This order is required: + * The video bridge needs to be adjusted before the + * BIOS is run as the BIOS sets up CRT2 according to + * these register settings. + * After the BIOS is run, the bridges and turboqueue + * registers need to be readjusted as the BIOS may + * very probably have messed them up. + */ + if(pSiS->VGAEngine == SIS_300_VGA || pSiS->VGAEngine == SIS_315_VGA) { + SiSPreSetMode(pScrn, mode, SIS_MODE_SIMU); + } + if(!SiSSetVESAMode(pScrn, mode)) { + SISErrorLog(pScrn, "SiSSetVESAMode() failed\n"); + return FALSE; + } + sisSaveUnlockExtRegisterLock(pSiS,NULL,NULL); + if(pSiS->VGAEngine == SIS_300_VGA || pSiS->VGAEngine == SIS_315_VGA) { + SiSPreSetMode(pScrn, mode, SIS_MODE_SIMU); + SiSPostSetMode(pScrn, &pSiS->ModeReg); + } #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "REAL REGISTER CONTENTS AFTER SETMODE:\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "REAL REGISTER CONTENTS AFTER SETMODE:\n"); #endif - if (!(*pSiS->ModeInit)(pScrn, mode)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "ModeInit() failed\n"); - return FALSE; - } - - pScrn->vtSema = TRUE; + if(!(*pSiS->ModeInit)(pScrn, mode)) { + SISErrorLog(pScrn, "ModeInit() failed\n"); + return FALSE; + } - /* Program the registers */ - vgaHWProtect(pScrn, TRUE); - (*pSiS->SiSRestore)(pScrn, &pSiS->ModeReg); - vgaHWProtect(pScrn, FALSE); - PDEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "HDisplay: %d, VDisplay: %d \n", - mode->HDisplay, mode->VDisplay)); + vgaHWProtect(pScrn, TRUE); + (*pSiS->SiSRestore)(pScrn, &pSiS->ModeReg); + vgaHWProtect(pScrn, FALSE); } else { /* Without VESA: */ + #ifdef SISDUALHEAD - if(pSiS->DualHeadMode) { - if(!(*pSiS->ModeInit)(pScrn, mode)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "ModeInit() failed\n"); - return FALSE; - } + if(pSiS->DualHeadMode) { - pScrn->vtSema = TRUE; - - if(!(pSiS->SecondHead)) { - /* TW: Head 1 (master) is always CRT2 */ - SiSPreSetMode(pScrn, mode); - if (!SiSBIOSSetModeCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pScrn, mode)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "SiSBIOSSetModeCRT2() failed\n"); - return FALSE; - } - SiSPostSetMode(pScrn, &pSiS->ModeReg); - } else { - /* TW: Head 2 (slave) is always CRT1 */ - SiSPreSetMode(pScrn, mode); - if (!SiSBIOSSetModeCRT1(pSiS->SiS_Pr, &pSiS->sishw_ext, pScrn, mode, pSiS->IsCustom)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "SiSBIOSSetModeCRT1() failed\n"); - return FALSE; - } - SiSPostSetMode(pScrn, &pSiS->ModeReg); - } - } else { + if(!(*pSiS->ModeInit)(pScrn, mode)) { + SISErrorLog(pScrn, "ModeInit() failed\n"); + return FALSE; + } + + pScrn->vtSema = TRUE; + + pSiSEnt = pSiS->entityPrivate; + + if(!(pSiS->SecondHead)) { + /* Head 1 (master) is always CRT2 */ + SiSPreSetMode(pScrn, mode, SIS_MODE_CRT2); + if(!SiSBIOSSetModeCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pScrn, mode, pSiS->IsCustom)) { + SISErrorLog(pScrn, "SiSBIOSSetModeCRT2() failed\n"); + return FALSE; + } + SiSPostSetMode(pScrn, &pSiS->ModeReg); + SISAdjustFrame(pSiSEnt->pScrn_2->scrnIndex, + pSiSEnt->pScrn_2->frameX0, + pSiSEnt->pScrn_2->frameY0, 0); + } else { + /* Head 2 (slave) is always CRT1 */ + SiSPreSetMode(pScrn, mode, SIS_MODE_CRT1); + if(!SiSBIOSSetModeCRT1(pSiS->SiS_Pr, &pSiS->sishw_ext, pScrn, mode, pSiS->IsCustom)) { + SISErrorLog(pScrn, "SiSBIOSSetModeCRT1() failed\n"); + return FALSE; + } + SiSPostSetMode(pScrn, &pSiS->ModeReg); + SISAdjustFrame(pSiSEnt->pScrn_1->scrnIndex, + pSiSEnt->pScrn_1->frameX0, + pSiSEnt->pScrn_1->frameY0, 0); + } + + } else { #endif - if(pSiS->VGAEngine == SIS_300_VGA || - pSiS->VGAEngine == SIS_315_VGA) { - - /* TW: Prepare the register contents; On 300/310/325, - * we actually "abuse" this only for setting - * up some variables; the registers are NOT - * being written to the hardware as the BIOS - * emulation (native mode switching code) - * takes care of this. - */ - if(!(*pSiS->ModeInit)(pScrn, mode)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "ModeInit() failed\n"); - return FALSE; - } - pScrn->vtSema = TRUE; + if(pSiS->VGAEngine == SIS_300_VGA || pSiS->VGAEngine == SIS_315_VGA) { - /* 300/310/325 series: Use our own code for mode switching */ - SiSPreSetMode(pScrn, mode); + if(!(*pSiS->ModeInit)(pScrn, mode)) { + SISErrorLog(pScrn, "ModeInit() failed\n"); + return FALSE; + } - if(!SiSBIOSSetMode(pSiS->SiS_Pr, &pSiS->sishw_ext, pScrn, mode, pSiS->IsCustom)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "SiSBIOSSetMode() failed\n"); - return FALSE; - } + pScrn->vtSema = TRUE; - SiSPostSetMode(pScrn, &pSiS->ModeReg); -#ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "REAL REGISTER CONTENTS AFTER SETMODE:\n"); - (*pSiS->ModeInit)(pScrn, mode); +#ifdef SISMERGED + if(pSiS->MergedFB) { + + xf86DrvMsg(0, X_INFO, "Setting MergedFB mode %dx%d\n", + mode->HDisplay, mode->VDisplay); + + SiSPreSetMode(pScrn, mode, SIS_MODE_CRT1); + + if(!SiSBIOSSetModeCRT1(pSiS->SiS_Pr, &pSiS->sishw_ext, pScrn, + ((SiSMergedDisplayModePtr)mode->Private)->CRT1, + pSiS->IsCustom)) { + SISErrorLog(pScrn, "SiSBIOSSetModeCRT1() failed\n"); + return FALSE; + } + + SiSPreSetMode(pScrn, mode, SIS_MODE_CRT2); + + if(!SiSBIOSSetModeCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pScrn, + ((SiSMergedDisplayModePtr)mode->Private)->CRT2, + pSiS->IsCustomCRT2)) { + SISErrorLog(pScrn, "SiSBIOSSetModeCRT2() failed\n"); + return FALSE; + } + + } else { #endif + + if(pSiS->VBFlags & CRT1_LCDA) { + SiSPreSetMode(pScrn, mode, SIS_MODE_CRT1); + if(!SiSBIOSSetModeCRT1(pSiS->SiS_Pr, &pSiS->sishw_ext, pScrn, + mode, pSiS->IsCustom)) { + SISErrorLog(pScrn, "SiSBIOSSetModeCRT1() failed\n"); + return FALSE; + } + SiSPreSetMode(pScrn, mode, SIS_MODE_CRT2); + if(!SiSBIOSSetModeCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pScrn, + mode, pSiS->IsCustom)) { + SISErrorLog(pScrn, "SiSBIOSSetModeCRT2() failed\n"); + return FALSE; + } } else { + SiSPreSetMode(pScrn, mode, SIS_MODE_SIMU); + if(!SiSBIOSSetMode(pSiS->SiS_Pr, &pSiS->sishw_ext, pScrn, + mode, pSiS->IsCustom)) { + SISErrorLog(pScrn, "SiSBIOSSetModeCRT() failed\n"); + return FALSE; + } + } - /* For other chipsets, use the old method */ +#ifdef SISMERGED + } +#endif + SiSPostSetMode(pScrn, &pSiS->ModeReg); - /* Initialise the ModeReg values */ - if(!vgaHWInit(pScrn, mode)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "vgaHWInit() failed\n"); - return FALSE; - } +#ifdef TWDEBUG + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "REAL REGISTER CONTENTS AFTER SETMODE:\n"); + (*pSiS->ModeInit)(pScrn, mode); +#endif - /* Reset our PIOOffset as vgaHWInit might have reset it */ - VGAHWPTR(pScrn)->PIOOffset = pSiS->IODBase + (pSiS->PciInfo->ioBase[2] & 0xFFFC) - 0x380; + } else { - /* Prepare the register contents */ - if(!(*pSiS->ModeInit)(pScrn, mode)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "ModeInit() failed\n"); - return FALSE; - } + /* For other chipsets, use the old method */ - pScrn->vtSema = TRUE; + /* Initialise the ModeReg values */ + if(!vgaHWInit(pScrn, mode)) { + SISErrorLog(pScrn, "vgaHWInit() failed\n"); + return FALSE; + } - /* Program the registers */ - vgaHWProtect(pScrn, TRUE); - vgaReg = &hwp->ModeReg; - sisReg = &pSiS->ModeReg; + /* Reset our PIOOffset as vgaHWInit might have reset it */ + VGAHWPTR(pScrn)->PIOOffset = pSiS->IODBase + (pSiS->PciInfo->ioBase[2] & 0xFFFC) - 0x380; - vgaReg->Attribute[0x10] = 0x01; - if(pScrn->bitsPerPixel > 8) { - vgaReg->Graphics[0x05] = 0x00; - } + /* Prepare the register contents */ + if(!(*pSiS->ModeInit)(pScrn, mode)) { + SISErrorLog(pScrn, "ModeInit() failed\n"); + return FALSE; + } - vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE); + pScrn->vtSema = TRUE; - (*pSiS->SiSRestore)(pScrn, sisReg); + /* Program the registers */ + vgaHWProtect(pScrn, TRUE); + vgaReg = &hwp->ModeReg; + sisReg = &pSiS->ModeReg; - if((pSiS->Chipset == PCI_CHIP_SIS6326) && (pSiS->SiS6326Flags & SIS6326_HASTV)) { - SiS6326PostSetMode(pScrn, &pSiS->ModeReg); - } + vgaReg->Attribute[0x10] = 0x01; + if(pScrn->bitsPerPixel > 8) { + vgaReg->Graphics[0x05] = 0x00; + } + + vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE); + + (*pSiS->SiSRestore)(pScrn, sisReg); + + if((pSiS->Chipset == PCI_CHIP_SIS6326) && (pSiS->SiS6326Flags & SIS6326_HASTV)) { + SiS6326PostSetMode(pScrn, &pSiS->ModeReg); + } #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "REAL REGISTER CONTENTS AFTER SETMODE:\n"); - (*pSiS->ModeInit)(pScrn, mode); + (*pSiS->ModeInit)(pScrn, mode); #endif - vgaHWProtect(pScrn, FALSE); - } + vgaHWProtect(pScrn, FALSE); + } #ifdef SISDUALHEAD - } + } #endif } - /* TW: Update Currentlayout */ + /* Update Currentlayout */ pSiS->CurrentLayout.mode = mode; - /* Debug */ -/* SiSDumpModeInfo(pScrn, mode); */ - return TRUE; } @@ -4217,28 +6002,94 @@ SiSSetVESAMode(ScrnInfoPtr pScrn, DisplayModePtr pMode) pSiS = SISPTR(pScrn); - if (!(mode = SiSCalcVESAModeIndex(pScrn, pMode))) return FALSE; + if(!(mode = SiSCalcVESAModeIndex(pScrn, pMode))) return FALSE; - mode |= 1 << 15; /* TW: Don't clear framebuffer */ - mode |= 1 << 14; /* TW: Use linear adressing */ + mode |= (1 << 15); /* Don't clear framebuffer */ + mode |= (1 << 14); /* Use linear adressing */ if(VBESetVBEMode(pSiS->pVbe, mode, NULL) == FALSE) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Setting VESA mode 0x%x failed\n", + SISErrorLog(pScrn, "Setting VESA mode 0x%x failed\n", mode & 0x0fff); - return (FALSE); + return (FALSE); } - if(pMode->HDisplay != pScrn->virtualX) - VBESetLogicalScanline(pSiS->pVbe, pScrn->virtualX); + if(pMode->HDisplay != pScrn->virtualX) { + VBESetLogicalScanline(pSiS->pVbe, pScrn->virtualX); + } xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Setting VESA mode 0x%x succeeded\n", - mode & 0x0fff); + "Setting VESA mode 0x%x succeeded\n", + mode & 0x0fff); return (TRUE); } +static void +SISSpecialRestore(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + SISRegPtr sisReg = &pSiS->SavedReg; + unsigned char temp; + int i; + + /* 1.11.04 and later for 651 and 301B(DH) do strange register + * fiddling after the usual mode change. This happens + * depending on the result of a call of int 2f (with + * ax=0x1680) and if modeno <= 0x13. I have no idea if + * that is specific for the 651 or that very machine. + * So this perhaps requires some more checks in the beginning + * (although it should not do any harm on other chipsets/bridges + * etc.) However, even if I call the VBE to restore mode 0x03, + * these registers don't get restored correctly, possibly + * because that int-2f-call for some reason results non-zero. So + * what I do here is to restore these few registers + * manually. + */ + + if(!(pSiS->ChipFlags & SiSCF_Is65x)) return; + inSISIDXREG(SISCR, 0x34, temp); + if(temp > 0x13) return; + +#ifdef UNLOCK_ALWAYS + sisSaveUnlockExtRegisterLock(pSiS, NULL,NULL); +#endif + + SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); + + outSISIDXREG(SISCAP, 0x3f, sisReg->sisCapt[0x3f]); + outSISIDXREG(SISCAP, 0x00, sisReg->sisCapt[0x00]); + for(i = 0; i < 0x4f; i++) { + outSISIDXREG(SISCAP, i, sisReg->sisCapt[i]); + } + outSISIDXREG(SISVID, 0x32, (sisReg->sisVid[0x32] & ~0x05)); + outSISIDXREG(SISVID, 0x30, sisReg->sisVid[0x30]); + outSISIDXREG(SISVID, 0x32, ((sisReg->sisVid[0x32] & ~0x04) | 0x01)); + outSISIDXREG(SISVID, 0x30, sisReg->sisVid[0x30]); + + if(!(pSiS->ChipFlags & SiSCF_Is651)) return; + if(!(pSiS->VBFlags & VB_SISBRIDGE)) return; + + inSISIDXREG(SISCR, 0x30, temp); + if(temp & 0x40) { + unsigned char myregs[] = { + 0x2f, 0x08, 0x09, 0x03, 0x0a, 0x0c, + 0x0b, 0x0d, 0x0e, 0x12, 0x0f, 0x10, + 0x11, 0x04, 0x05, 0x06, 0x07, 0x00, + 0x2e + }; + for(i = 0; i <= 18; i++) { + outSISIDXREG(SISPART1, myregs[i], sisReg->VBPart1[myregs[i]]); + } + } else if((temp & 0x20) || (temp & 0x9c)) { + unsigned char myregs[] = { + 0x04, 0x05, 0x06, 0x07, 0x00, 0x2e + }; + for(i = 0; i <= 5; i++) { + outSISIDXREG(SISPART1, myregs[i], sisReg->VBPart1[myregs[i]]); + } + } +} + /* * Restore the initial mode. To be used internally only! */ @@ -4250,15 +6101,26 @@ SISRestore(ScrnInfoPtr pScrn) vgaHWPtr hwp = VGAHWPTR(pScrn); vgaRegPtr vgaReg = &hwp->SavedReg; Bool doit = FALSE, doitlater = FALSE; + Bool vesasuccess = FALSE; + + /* WARNING: Don't ever touch this. It now seems to work on + * all chipset/bridge combinations - but finding out the + * correct combination was pure hell. + */ + + /* Wait for the accelerators */ + if(pSiS->AccelInfoPtr) { + (*pSiS->AccelInfoPtr->Sync)(pScrn); + } if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { #ifdef SISDUALHEAD - /* TW: We always restore master AND slave */ + /* We always restore master AND slave */ if(pSiS->DualHeadMode && pSiS->SecondHead) return; #endif - /* TW: We must not disable the sequencer if the bridge is in SlaveMode! */ + /* We must not disable the sequencer if the bridge is in SlaveMode! */ if(!(SiSBridgeIsInSlaveMode(pScrn))) { vgaHWProtect(pScrn, TRUE); } @@ -4267,66 +6129,127 @@ SISRestore(ScrnInfoPtr pScrn) sisSaveUnlockExtRegisterLock(pSiS, NULL,NULL); #endif - /* TW: First, restore CRT1 on/off and VB connection registers */ + /* First, restore CRT1 on/off and VB connection registers */ outSISIDXREG(SISCR, 0x32, pSiS->oldCR32); - if(!(pSiS->oldCR17 & 0x80)) { /* TW: CRT1 was off */ - if(!(SiSBridgeIsInSlaveMode(pScrn))) { /* TW: Bridge is NOT in SlaveMode now -> do it */ - doit = TRUE; - } else { - doitlater = TRUE; - } - } else { /* TW: CRT1 was on -> do it now */ - doit = TRUE; + if(!(pSiS->oldCR17 & 0x80)) { /* CRT1 was off */ + if(!(SiSBridgeIsInSlaveMode(pScrn))) { /* Bridge is NOT in SlaveMode now -> do it */ + doit = TRUE; + } else { + doitlater = TRUE; + } + } else { /* CRT1 was on -> do it now */ + doit = TRUE; } if(doit) { - outSISIDXREG(SISCR, 0x17, pSiS->oldCR17); + outSISIDXREG(SISCR, 0x17, pSiS->oldCR17); } + if(pSiS->VGAEngine == SIS_315_VGA) { + outSISIDXREG(SISCR, 0x63, pSiS->oldCR63); + } + + outSISIDXREG(SISSR, 0x1f, pSiS->oldSR1F); - /* TW: For 30xB/LV, restoring the registers does not - * work. We "manually" set the old mode, instead. - * The same applies for SiS730 machines with LVDS. - * Finally, this behavior can be forced by setting - * the option RestoreBySetMode. + /* For 30xB/LV, restoring the registers does not + * work. We "manually" set the old mode, instead. + * The same applies for SiS730 machines with LVDS. + * Finally, this behavior can be forced by setting + * the option RestoreBySetMode. */ if( ( (pSiS->restorebyset) || - (pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) || + (pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)) || ((pSiS->sishw_ext.jChipType == SIS_730) && (pSiS->VBFlags & VB_LVDS)) ) && (pSiS->OldMode) ) { - if(pSiS->AccelInfoPtr) { - (*pSiS->AccelInfoPtr->Sync)(pScrn); - } - + Bool changedmode = FALSE; + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Restoring by setting old mode 0x%02x\n", pSiS->OldMode); + + if(((pSiS->OldMode <= 0x13) || (!pSiS->sisfbfound)) && (pSiS->pVbe)) { + int vmode = SiSTranslateToVESA(pScrn, pSiS->OldMode); + if(vmode > 0) { + if(vmode > 0x13) vmode |= ((1 << 15) | (1 << 14)); + if(VBESetVBEMode(pSiS->pVbe, vmode, NULL) == TRUE) { + SISSpecialRestore(pScrn); + SiS_GetSetModeID(pScrn,pSiS->OldMode); + vesasuccess = TRUE; + } else { + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "VBE failed to restore mode 0x%x\n", pSiS->OldMode); + } + } else { + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Can't identify VESA mode number for mode 0x%x\n", pSiS->OldMode); + } + } + + if(vesasuccess == FALSE) { + + int backupscaler = pSiS->SiS_Pr->UsePanelScaler; + unsigned long backupspecialtiming = pSiS->SiS_Pr->SiS_CustomT; + + if((pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV))) { + /* !!! REQUIRED for 630+301B-DH, otherwise the text modes + * will not be restored correctly !!! + * !!! Do this ONLY for LCD; VGA2 will not be restored + * correctly otherwise. + */ + unsigned char temp; + inSISIDXREG(SISCR, 0x30, temp); + if(temp & 0x20) { + if(pSiS->OldMode == 0x03) { + pSiS->OldMode = 0x13; + changedmode = TRUE; + } + } + } + + pSiS->SiS_Pr->UseCustomMode = FALSE; + pSiS->SiS_Pr->CRT1UsesCustomMode = FALSE; + pSiS->SiS_Pr->UsePanelScaler = pSiS->sisfbscalelcd; + pSiS->SiS_Pr->SiS_CustomT = pSiS->sisfbspecialtiming; + SiSSetMode(pSiS->SiS_Pr, &pSiS->sishw_ext, pScrn, pSiS->OldMode, FALSE); + if(changedmode) { + pSiS->OldMode = 0x03; + outSISIDXREG(SISCR,0x34,0x03); + } + SISSpecialRestore(pScrn); + SiS_GetSetModeID(pScrn,pSiS->OldMode); + pSiS->SiS_Pr->UsePanelScaler = backupscaler; + pSiS->SiS_Pr->SiS_CustomT = backupspecialtiming; - if( (pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) && - (!pSiS->restorebyset) ) { - if(pSiS->OldMode == 0x03) pSiS->OldMode = 0x13; } - - pSiS->SiS_Pr->UseCustomMode = FALSE; - pSiS->SiS_Pr->CRT1UsesCustomMode = FALSE; - SiSSetMode(pSiS->SiS_Pr, &pSiS->sishw_ext, pScrn, pSiS->OldMode, FALSE); -#ifdef TWDEBUG - { - SISRegPtr pReg = &pSiS->ModeReg; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "REAL REGISTER CONTENTS AFTER RESTORE BY SETMODE:\n"); - (*pSiS->SiSSave)(pScrn, pReg); - } + + /* Restore CRT1 status */ + if(pSiS->VGAEngine == SIS_315_VGA) { + outSISIDXREG(SISCR, 0x63, pSiS->oldCR63); + } + outSISIDXREG(SISSR, 0x1f, pSiS->oldSR1F); + +#ifdef SISVRAMQ + /* Restore queue mode registers on 315/330 series */ + /* (This became necessary due to the switch to VRAM queue) */ + if(pSiS->VGAEngine == SIS_315_VGA) { + unsigned char tempCR55; + inSISIDXREG(SISCR,0x55,tempCR55); + andSISIDXREG(SISCR,0x55,0x33); + outSISIDXREG(SISSR,0x26,0x01); + MMIO_OUT32(pSiS->IOBase, 0x85c4, 0); + outSISIDXREG(SISSR,0x27,sisReg->sisRegs3C4[0x27]); + outSISIDXREG(SISSR,0x26,sisReg->sisRegs3C4[0x26]); + MMIO_OUT32(pSiS->IOBase, 0x85C0, sisReg->sisMMIO85C0); + outSISIDXREG(SISCR,0x55,tempCR55); + } #endif } else { if(pSiS->VBFlags & VB_VIDEOBRIDGE) { - /* TW: If a video bridge is present, we need to restore - * non-extended (=standard VGA) SR and CR registers - * before restoring the extended ones and the bridge - * registers itself. Unfortunately, the vgaHWRestore - * routine clears CR17[7] - which must not be done if - * the bridge is in slave mode. + /* If a video bridge is present, we need to restore + * non-extended (=standard VGA) SR and CR registers + * before restoring the extended ones and the bridge + * registers itself. */ if(!(SiSBridgeIsInSlaveMode(pScrn))) { vgaHWProtect(pScrn, TRUE); @@ -4345,41 +6268,56 @@ SISRestore(ScrnInfoPtr pScrn) outSISIDXREG(SISCR, 0x17, pSiS->oldCR17); } - sisRestoreExtRegisterLock(pSiS,sisReg->sisRegs3C4[0x05],sisReg->sisRegs3D4[0x80]); - - if( ( (pSiS->sishw_ext.jChipType == SIS_730) && (pSiS->VBFlags & VB_LVDS)) || - (pSiS->restorebyset) ) { - - /* TW: SiS730/LVDS has extreme problems restoring the text display due - * to over-sensible LCD panels - */ - - vgaHWProtect(pScrn, TRUE); - - if(pSiS->Primary) { - vgaHWRestore(pScrn, vgaReg, (VGA_SR_FONTS | VGA_SR_CMAP)); - } - - vgaHWProtect(pScrn, FALSE); - - } else { - - vgaHWProtect(pScrn, TRUE); - - if(pSiS->Primary) { + if(pSiS->Primary) { + if((pSiS->VBFlags & VB_VIDEOBRIDGE) && (SiSBridgeIsInSlaveMode(pScrn))) { + /* IMPORTANT: The 30xLV does not handle well being disabled if in + * LCDA mode! In LCDA mode, the bridge is NOT in slave mode, + * so this is the only safe way: Disable the bridge ONLY if + * in Slave Mode, and don't bother if not. + */ + 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); + + 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 { + vgaHWProtect(pScrn, TRUE); + + /* We now restore ALL to overcome the vga=extended problem */ vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL); + + vgaHWProtect(pScrn, FALSE); } - - vgaHWProtect(pScrn, FALSE); - } + +#ifdef TWDEBUG + { + SISRegPtr pReg = &pSiS->ModeReg; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "REAL REGISTER CONTENTS AFTER RESTORE BY SETMODE:\n"); + (*pSiS->SiSSave)(pScrn, pReg); + } +#endif + + sisRestoreExtRegisterLock(pSiS,sisReg->sisRegs3C4[0x05],sisReg->sisRegs3D4[0x80]); } else { /* All other chipsets */ vgaHWProtect(pScrn, TRUE); + #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL,NULL); #endif + (*pSiS->SiSRestore)(pScrn, sisReg); vgaHWProtect(pScrn, TRUE); @@ -4387,36 +6325,36 @@ SISRestore(ScrnInfoPtr pScrn) vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL); } - /* TW: Restore TV. This is rather complicated, but if we don't do it, - * TV output will flicker terribly + /* Restore TV. This is rather complicated, but if we don't do it, + * TV output will flicker terribly */ if((pSiS->Chipset == PCI_CHIP_SIS6326) && (pSiS->SiS6326Flags & SIS6326_HASTV)) { - if(sisReg->sis6326tv[0] & 0x04) { - unsigned char tmp; - int val; - - orSISIDXREG(SISSR, 0x01, 0x20); - tmp = SiS6326GetTVReg(pScrn,0x00); - tmp &= ~0x04; - while(!(inSISREG(SISINPSTAT) & 0x08)); /* Wait while NOT vb */ - SiS6326SetTVReg(pScrn,0x00,tmp); - for(val=0; val < 2; val++) { - while(!(inSISREG(SISINPSTAT) & 0x08)); /* Wait while NOT vb */ - while(inSISREG(SISINPSTAT) & 0x08); /* wait while vb */ - } - SiS6326SetTVReg(pScrn, 0x00, sisReg->sis6326tv[0]); - tmp = inSISREG(SISINPSTAT); - outSISREG(SISAR, 0x20); - tmp = inSISREG(SISINPSTAT); - while(inSISREG(SISINPSTAT) & 0x01); - while(!(inSISREG(SISINPSTAT) & 0x01)); - andSISIDXREG(SISSR, 0x01, ~0x20); - for(val=0; val < 10; val++) { + if(sisReg->sis6326tv[0] & 0x04) { + unsigned char tmp; + int val; + + orSISIDXREG(SISSR, 0x01, 0x20); + tmp = SiS6326GetTVReg(pScrn,0x00); + tmp &= ~0x04; while(!(inSISREG(SISINPSTAT) & 0x08)); /* Wait while NOT vb */ - while(inSISREG(SISINPSTAT) & 0x08); /* wait while vb */ - } - andSISIDXREG(SISSR, 0x01, ~0x20); - } + SiS6326SetTVReg(pScrn,0x00,tmp); + for(val=0; val < 2; val++) { + while(!(inSISREG(SISINPSTAT) & 0x08)); /* Wait while NOT vb */ + while(inSISREG(SISINPSTAT) & 0x08); /* wait while vb */ + } + SiS6326SetTVReg(pScrn, 0x00, sisReg->sis6326tv[0]); + tmp = inSISREG(SISINPSTAT); + outSISREG(SISAR, 0x20); + tmp = inSISREG(SISINPSTAT); + while(inSISREG(SISINPSTAT) & 0x01); + while(!(inSISREG(SISINPSTAT) & 0x01)); + andSISIDXREG(SISSR, 0x01, ~0x20); + for(val=0; val < 10; val++) { + while(!(inSISREG(SISINPSTAT) & 0x08)); /* Wait while NOT vb */ + while(inSISREG(SISINPSTAT) & 0x08); /* wait while vb */ + } + andSISIDXREG(SISSR, 0x01, ~0x20); + } } sisRestoreExtRegisterLock(pSiS,sisReg->sisRegs3C4[5],sisReg->sisRegs3D4[0x80]); @@ -4430,10 +6368,28 @@ SISVESARestore(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - if(pSiS->UseVESA) SISVESASaveRestore(pScrn, MODE_RESTORE); + if(pSiS->UseVESA) { + SISVESASaveRestore(pScrn, MODE_RESTORE); +#ifdef SISVRAMQ + /* Restore queue mode registers on 315/330 series */ + /* (This became necessary due to the switch to VRAM queue) */ + if(pSiS->VGAEngine == SIS_315_VGA) { + SISRegPtr sisReg = &pSiS->SavedReg; + unsigned char tempCR55; + inSISIDXREG(SISCR,0x55,tempCR55); + andSISIDXREG(SISCR,0x55,0x33); + outSISIDXREG(SISSR,0x26,0x01); + MMIO_OUT32(pSiS->IOBase, 0x85c4, 0); + outSISIDXREG(SISSR,0x27,sisReg->sisRegs3C4[0x27]); + outSISIDXREG(SISSR,0x26,sisReg->sisRegs3C4[0x26]); + MMIO_OUT32(pSiS->IOBase, 0x85C0, sisReg->sisMMIO85C0); + outSISIDXREG(SISCR,0x55,tempCR55); + } +#endif + } } -/* TW: Restore bridge registers - to be called BEFORE VESARestore */ +/* Restore bridge config registers - to be called BEFORE VESARestore */ static void SISBridgeRestore(ScrnInfoPtr pScrn) { @@ -4449,7 +6405,7 @@ SISBridgeRestore(ScrnInfoPtr pScrn) } } -/* TW: Our generic BlockHandler for Xv */ +/* Our generic BlockHandler for Xv */ static void SISBlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask) { @@ -4462,16 +6418,20 @@ SISBlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask) pScreen->BlockHandler = SISBlockHandler; if(pSiS->VideoTimerCallback) { - (*pSiS->VideoTimerCallback)(pScrn, currentTime.milliseconds); + (*pSiS->VideoTimerCallback)(pScrn, currentTime.milliseconds); + } + + if(pSiS->RenderCallback) { + (*pSiS->RenderCallback)(pScrn); } } /* Mandatory * This gets called at the start of each server generation * - * TW: We use pScrn and not CurrentLayout here, because the - * properties we use have not changed (displayWidth, - * depth, bitsPerPixel) + * We use pScrn and not CurrentLayout here, because the + * properties we use have not changed (displayWidth, + * depth, bitsPerPixel) */ static Bool SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) @@ -4480,7 +6440,6 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) vgaHWPtr hwp; SISPtr pSiS; int ret; - int init_picture = 0; VisualPtr visual; unsigned long OnScreenSize; int height, width, displayWidth; @@ -4495,19 +6454,28 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pSiS = SISPTR(pScrn); - if(pSiS->UseVESA) { +#ifdef SISDUALHEAD + if((!pSiS->DualHeadMode) || (!pSiS->SecondHead)) { +#endif + if(xf86LoadSubModule(pScrn, "vbe")) { + xf86LoaderReqSymLists(vbeSymbols, NULL); #if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) - pSiS->pVbe = VBEInit(NULL, pSiS->pEnt->index); + pSiS->pVbe = VBEInit(NULL, pSiS->pEnt->index); #else - pSiS->pVbe = VBEExtendedInit(NULL, pSiS->pEnt->index, + pSiS->pVbe = VBEExtendedInit(NULL, pSiS->pEnt->index, SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH); #endif + } else { + SISErrorLog(pScrn, "Failed to load VBE submodule\n"); + } +#ifdef SISDUALHEAD } +#endif #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { - pSiSEnt = pSiS->entityPrivate; - pSiSEnt->refCount++; + pSiSEnt = pSiS->entityPrivate; + pSiSEnt->refCount++; } #endif @@ -4515,69 +6483,107 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if(pSiS->Primary) { hwp->MapSize = 0x10000; /* Standard 64k VGA window */ if(!vgaHWMapMem(pScrn)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Could not map VGA window\n"); + SISErrorLog(pScrn, "Could not map VGA memory window\n"); return FALSE; } } vgaHWGetIOBase(hwp); - - /* TW: Patch the PIOOffset inside vgaHW to use - * our relocated IO ports. + + /* 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)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "SiSMapMem() failed\n"); - return FALSE; + SISErrorLog(pScrn, "SiSMapMem() failed\n"); + return FALSE; } #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - /* TW: Enable TurboQueue so that SISSave() saves it in enabled - * state. If we don't do this, X will hang after a restart! - * (Happens for some unknown reason only when using VESA - * for mode switching; assumingly a BIOS issue.) - * This is done on 300 and 310/325 series only. + /* Enable TurboQueue so that SISSave() saves it in enabled + * state. If we don't do this, X will hang after a restart! + * (Happens for some unknown reason only when using VESA + * for mode switching; assumingly a BIOS issue.) + * This is done on 300 and 315 series only. */ if(pSiS->UseVESA) { - SiSEnableTurboQueue(pScrn); +#ifdef SISVRAMQ + if(pSiS->VGAEngine != SIS_315_VGA) +#endif + SiSEnableTurboQueue(pScrn); + } /* Save the current state */ SISSave(pScrn); - /* TW: Save the current mode number */ if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - inSISIDXREG(SISCR, 0x34, pSiS->OldMode); + + if(!pSiS->OldMode) { + + /* Try to find out current (=old) mode number + * (Do this only if not sisfb has told us its mode yet) + */ + + /* Read 0:449 which the BIOS sets to the current mode number + * Unfortunately, this not reliable since the int10 emulation + * does not change this. So if we call the VBE later, this + * byte won't be touched. (which is why we set this manually + * then) + */ + unsigned char myoldmode = SiS_GetSetModeID(pScrn,0xFF); + unsigned char cr30, cr31; + + /* Read CR34 which the BIOS sets to the current mode number for CRT2 + * This is - of course - not reliable if the machine has no video + * bridge... + */ + inSISIDXREG(SISCR, 0x34, pSiS->OldMode); + inSISIDXREG(SISCR, 0x30, cr30); + inSISIDXREG(SISCR, 0x31, cr31); + + /* What if CR34 is different from the BIOS byte? */ + if(pSiS->OldMode != myoldmode) { + /* If no bridge output is active, trust the BIOS byte */ + if(!cr31 && !cr30) pSiS->OldMode = myoldmode; + /* ..else trust CR34 */ + } + + /* Newer 650 BIOSes set CR34 to 0xff if the mode has been + * "patched", for instance for 80x50 text mode. (That mode + * has no number of its own, it's 0x03 like 80x25). In this + * case, we trust the BIOS byte (provided that any of these + * two is valid). + */ + if(pSiS->OldMode > 0x7f) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Previous video mode (%02x) invalid, using BIOS scratch (%02x)\n", + pSiS->OldMode, myoldmode); + pSiS->OldMode = myoldmode; + } + } } /* Initialise the first mode */ if(!SISModeInit(pScrn, pScrn->currentMode)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "SiSModeInit() failed\n"); - return FALSE; + SISErrorLog(pScrn, "SiSModeInit() failed\n"); + return FALSE; } /* Darken the screen for aesthetic reasons */ - /* TW: Not using Dual Head variant on purpose; we darken - * the screen for both displays, and un-darken - * it when the second head is finished + /* Not using Dual Head variant on purpose; we darken + * the screen for both displays, and un-darken + * it when the second head is finished */ SISSaveScreen(pScreen, SCREEN_SAVER_ON); /* Set the viewport */ SISAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); - /* Clear frame buffer */ - OnScreenSize = pScrn->displayWidth * pScrn->currentMode->VDisplay - * (pScrn->bitsPerPixel / 8); - bzero(pSiS->FbBase, OnScreenSize); - /* * The next step is to setup the screen's visuals, and initialise the * framebuffer code. In cases where the framebuffer's default @@ -4601,23 +6607,14 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) * For bpp > 8, the default visuals are not acceptable because we only * support TrueColor and not DirectColor. */ - if(pScrn->bitsPerPixel > 8) { - if(!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - pScrn->defaultVisual)) { - SISSaveScreen(pScreen, SCREEN_SAVER_OFF); - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "miSetVisualTypes() failed (bpp %d)\n", pScrn->bitsPerPixel); - return FALSE; - } - } else { - if(!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) { - SISSaveScreen(pScreen, SCREEN_SAVER_OFF); - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "miSetVisualTypes() failed (bpp %d)\n", pScrn->bitsPerPixel); - return FALSE; - } + if(!miSetVisualTypes(pScrn->depth, + (pScrn->bitsPerPixel > 8) ? + TrueColorMask : miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) { + SISSaveScreen(pScreen, SCREEN_SAVER_OFF); + SISErrorLog(pScrn, "miSetVisualTypes() failed (bpp %d)\n", + pScrn->bitsPerPixel); + return FALSE; } width = pScrn->virtualX; @@ -4625,132 +6622,124 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) displayWidth = pScrn->displayWidth; if(pSiS->Rotate) { - height = pScrn->virtualX; - width = pScrn->virtualY; + height = pScrn->virtualX; + width = pScrn->virtualY; } if(pSiS->ShadowFB) { - pSiS->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * width); - pSiS->ShadowPtr = xalloc(pSiS->ShadowPitch * height); - displayWidth = pSiS->ShadowPitch / (pScrn->bitsPerPixel >> 3); - FBStart = pSiS->ShadowPtr; + pSiS->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * width); + pSiS->ShadowPtr = xalloc(pSiS->ShadowPitch * height); + displayWidth = pSiS->ShadowPitch / (pScrn->bitsPerPixel >> 3); + FBStart = pSiS->ShadowPtr; } else { - pSiS->ShadowPtr = NULL; - FBStart = pSiS->FbBase; + pSiS->ShadowPtr = NULL; + FBStart = pSiS->FbBase; } if(!miSetPixmapDepths()) { - SISSaveScreen(pScreen, SCREEN_SAVER_OFF); - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "miSetPixmapDepths() failed\n"); - return FALSE; + SISSaveScreen(pScreen, SCREEN_SAVER_OFF); + SISErrorLog(pScrn, "miSetPixmapDepths() failed\n"); + return FALSE; } + /* Point cmdQueuePtr to pSiSEnt for shared usage + * (same technique is then eventually used in DRIScreeninit) + * For 315/330 series, this is done in EnableTurboQueue + * which has already been called during ModeInit(). + */ #ifdef SISDUALHEAD if(pSiS->SecondHead) - pSiS->cmdQueueLenPtr = &(SISPTR(pSiSEnt->pScrn_1)->cmdQueueLen); + pSiS->cmdQueueLenPtr = &(SISPTR(pSiSEnt->pScrn_1)->cmdQueueLen); else #endif - pSiS->cmdQueueLenPtr = &(pSiS->cmdQueueLen); + pSiS->cmdQueueLenPtr = &(pSiS->cmdQueueLen); - pSiS->cmdQueueLen = 0; /* TW: Force an EngineIdle() at start */ + pSiS->cmdQueueLen = 0; /* Force an EngineIdle() at start */ #ifdef XF86DRI + if(pSiS->loadDRI) { #ifdef SISDUALHEAD - /* TW: No DRI in dual head mode */ - if(pSiS->DualHeadMode) { - pSiS->directRenderingEnabled = FALSE; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + /* No DRI in dual head mode */ + if(pSiS->DualHeadMode) { + pSiS->directRenderingEnabled = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DRI not supported in Dual Head mode\n"); - } else + } else #endif - /* Force the initialization of the context */ - if(pSiS->VGAEngine != SIS_315_VGA) { - pSiS->directRenderingEnabled = SISDRIScreenInit(pScreen); + /* Force the initialization of the context */ + if(pSiS->VGAEngine != SIS_315_VGA) { + pSiS->directRenderingEnabled = SISDRIScreenInit(pScreen); } else { xf86DrvMsg(pScrn->scrnIndex, X_NOT_IMPLEMENTED, - "DRI not supported on this chipset\n"); + "DRI not supported on this chipset\n"); pSiS->directRenderingEnabled = FALSE; } + } #endif /* * Call the framebuffer layer's ScreenInit function, and fill in other * pScreen fields. */ - switch(pScrn->bitsPerPixel) { - case 1: - ret = xf1bppScreenInit(pScreen, FBStart, width, - height, pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - case 4: - ret = xf4bppScreenInit(pScreen, FBStart, width, - height, pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; + case 24: + if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { + ret = FALSE; + break; + } case 8: case 16: - case 24: case 32: ret = fbScreenInit(pScreen, FBStart, width, height, pScrn->xDpi, pScrn->yDpi, displayWidth, pScrn->bitsPerPixel); - - init_picture = 1; break; default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Internal error: invalid bpp (%d) in SISScrnInit\n", - pScrn->bitsPerPixel); - ret = FALSE; + ret = FALSE; break; } - if (!ret) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "xf1bpp/xf4bpp/fbScreenInit() failed\n"); - SISSaveScreen(pScreen, SCREEN_SAVER_OFF); - return FALSE; + if(!ret) { + SISErrorLog(pScrn, "Unsupported bpp (%d) or fbScreenInit() failed\n", + pScrn->bitsPerPixel); + SISSaveScreen(pScreen, SCREEN_SAVER_OFF); + return FALSE; } if(pScrn->bitsPerPixel > 8) { - /* Fixup RGB ordering */ - visual = pScreen->visuals + pScreen->numVisuals; - while (--visual >= pScreen->visuals) { - if ((visual->class | DynamicClass) == DirectColor) { - visual->offsetRed = pScrn->offset.red; - visual->offsetGreen = pScrn->offset.green; - visual->offsetBlue = pScrn->offset.blue; - visual->redMask = pScrn->mask.red; - visual->greenMask = pScrn->mask.green; - visual->blueMask = pScrn->mask.blue; - } - } - } else if(pScrn->depth == 1) { - SIS1bppColorMap(pScrn); + /* Fixup RGB ordering */ + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } } /* Initialize RENDER ext; must be after RGB ordering fixed */ - if(init_picture) fbPictureInit(pScreen, 0, 0); + fbPictureInit(pScreen, 0, 0); /* hardware cursor needs to wrap this layer <-- TW: what does that mean? */ - if(!pSiS->ShadowFB) SISDGAInit(pScreen); + if(!pSiS->ShadowFB) SISDGAInit(pScreen); xf86SetBlackWhitePixels(pScreen); if(!pSiS->NoAccel) { - switch(pSiS->VGAEngine) { + switch(pSiS->VGAEngine) { case SIS_530_VGA: case SIS_300_VGA: SiS300AccelInit(pScreen); break; case SIS_315_VGA: - SiS310AccelInit(pScreen); + SiS315AccelInit(pScreen); break; default: SiSAccelInit(pScreen); - } + } } miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); @@ -4759,26 +6748,33 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Initialise cursor functions */ miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); - if(pSiS->HWCursor) - SiSHWCursorInit(pScreen); + if(pSiS->HWCursor) { + SiSHWCursorInit(pScreen); + } /* Initialise default colourmap */ if(!miCreateDefColormap(pScreen)) { - SISSaveScreen(pScreen, SCREEN_SAVER_OFF); - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "miCreateDefColormap() failed\n"); - return FALSE; + SISSaveScreen(pScreen, SCREEN_SAVER_OFF); + SISErrorLog(pScrn, "miCreateDefColormap() failed\n"); + return FALSE; } - + if(!xf86HandleColormaps(pScreen, 256, (pScrn->depth == 8) ? 8 : pScrn->rgbBits, SISLoadPalette, NULL, CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) { - SISSaveScreen(pScreen, SCREEN_SAVER_OFF); - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "xf86HandleColormaps() failed\n"); - return FALSE; + SISSaveScreen(pScreen, SCREEN_SAVER_OFF); + SISErrorLog(pScrn, "xf86HandleColormaps() failed\n"); + return FALSE; } +#if 0 + if((pSiS->GammaBriR != 1000) || (pSiS->GammaBriG != 1000) || + (pSiS->GammaBriB != 1000) || (pSiS->GammaPBriR != 1000) || + (pSiS->GammaPBriG != 1000) || (pSiS->GammaPBriB != 1000)) { + SISCalculateGammaRamp(pScrn); + } +#endif + if(pSiS->ShadowFB) { RefreshAreaFuncPtr refreshArea = SISRefreshArea; @@ -4794,104 +6790,114 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) case 24: refreshArea = SISRefreshArea24; break; case 32: refreshArea = SISRefreshArea32; break; } +#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0) + xf86DisableRandR(); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Driver rotation enabled, RandR disabled\n"); +#endif } ShadowFBInit(pScreen, refreshArea); } -#ifdef SISDUALHEAD - if(pSiS->DualHeadMode) - /* TW: DPMS for dual head mode */ - xf86DPMSInit(pScreen, (DPMSSetProcPtr)SISDisplayPowerManagementSetDH, 0); - else -#endif - xf86DPMSInit(pScreen, (DPMSSetProcPtr)SISDisplayPowerManagementSet, 0); + xf86DPMSInit(pScreen, (DPMSSetProcPtr)SISDisplayPowerManagementSet, 0); /* Init memPhysBase and fbOffset in pScrn */ pScrn->memPhysBase = pSiS->FbAddress; pScrn->fbOffset = 0; + + pSiS->ResetXv = pSiS->ResetXvGamma = NULL; -#ifdef XvExtension +#if (XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,99,0,0)) || (defined(XvExtension)) if(!pSiS->NoXvideo) { -#ifdef SISDUALHEAD - /* TW: On chipsets with only one overlay, we support - * Xv only in "real" dual head mode, not Xinerama - */ - if ( ((pSiS->VGAEngine == SIS_300_VGA) || - (pSiS->VGAEngine == SIS_315_VGA) ) - && - ((pSiS->hasTwoOverlays) || - (!pSiS->DualHeadMode) || - (noPanoramiXExtension) ) ) { -#else - if ( (pSiS->VGAEngine == SIS_300_VGA) || - (pSiS->VGAEngine == SIS_315_VGA) ) { -#endif -#ifdef SISDUALHEAD - if (pSiS->DualHeadMode) { - if ( pSiS->hasTwoOverlays || - (pSiS->XvOnCRT2 && (!pSiS->SecondHead)) || - ((!pSiS->XvOnCRT2 && pSiS->SecondHead)) ) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Using SiS300/310/325 series HW Xv on CRT%d\n", - (pSiS->SecondHead ? 1 : 2)); - SISInitVideo(pScreen); - } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Not using SiS300/310/325 series HW Xv on CRT%d\n", - (pSiS->SecondHead ? 1 : 2)); + if( (pSiS->VGAEngine == SIS_300_VGA) || + (pSiS->VGAEngine == SIS_315_VGA) ) { +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using SiS300/315 series HW Xv on CRT%d\n", + (pSiS->SecondHead ? 1 : 2)); + if(!pSiS->hasTwoOverlays) { + if( (pSiS->XvOnCRT2 && pSiS->SecondHead) || + (!pSiS->XvOnCRT2 && !pSiS->SecondHead) ) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "However, overlay will by default only be visible on CRT%d\n", + pSiS->XvOnCRT2 ? 2 : 1); + } } + SISInitVideo(pScreen); } else { #endif - if (pSiS->hasTwoOverlays) - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Using SiS300/310/325 series HW Xv\n" ); + if(pSiS->hasTwoOverlays) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using SiS300/315/330 series HW Xv\n" ); else - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Using SiS300/310/325 series HW Xv on CRT%d\n", - (pSiS->XvOnCRT2 ? 2 : 1)); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using SiS300/315/330 series HW Xv by default on CRT%d\n", + (pSiS->XvOnCRT2 ? 2 : 1)); SISInitVideo(pScreen); #ifdef SISDUALHEAD } #endif -#ifdef USE6326VIDEO } else if( pSiS->Chipset == PCI_CHIP_SIS6326 || pSiS->Chipset == PCI_CHIP_SIS530 || pSiS->Chipset == PCI_CHIP_SIS5597 ) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using SiS5597/5598/6326/530/620 HW Xv\n" ); SIS6326InitVideo(pScreen); -#endif + } else { /* generic Xv */ XF86VideoAdaptorPtr *ptr; int n; n = xf86XVListGenericAdaptors(pScrn, &ptr); - if (n) { + if(n) { xf86XVScreenInit(pScreen, ptr, n); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using generic Xv\n" ); } - if (!noPanoramiXExtension) - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "HW Xv not supported in Xinerama mode\n"); + } } #endif #ifdef XF86DRI - if(pSiS->directRenderingEnabled) { - /* Now that mi, drm and others have done their thing, - * complete the DRI setup. - */ - pSiS->directRenderingEnabled = SISDRIFinishScreenInit(pScreen); + if(pSiS->loadDRI) { + if(pSiS->directRenderingEnabled) { + /* Now that mi, drm and others have done their thing, + * complete the DRI setup. + */ + pSiS->directRenderingEnabled = SISDRIFinishScreenInit(pScreen); + } + if(pSiS->directRenderingEnabled) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering enabled\n"); + /* TODO */ + /* SISSetLFBConfig(pSiS); */ + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering disabled\n"); + } } - if(pSiS->directRenderingEnabled) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering enabled\n"); - /* TODO */ - /* SISSetLFBConfig(pSiS); */ - } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering disabled\n"); +#endif + + /* Wrap some funcs and setup remaining SD flags */ + + pSiS->SiS_SD_Flags &= ~(SiS_SD_PSEUDOXINERAMA); +#ifdef SISMERGED + if(pSiS->MergedFB) { + pSiS->PointerMoved = pScrn->PointerMoved; + pScrn->PointerMoved = SISMergePointerMoved; + pSiS->Rotate = FALSE; + pSiS->ShadowFB = FALSE; +#ifdef SISXINERAMA + if(pSiS->UseSiSXinerama) { + SiSnoPanoramiXExtension = FALSE; + SiSXineramaExtensionInit(pScrn); + if(!SiSnoPanoramiXExtension) { + pSiS->SiS_SD_Flags |= SiS_SD_PSEUDOXINERAMA; + } + } +#endif } #endif @@ -4899,10 +6905,10 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pScreen->CloseScreen = SISCloseScreen; #ifdef SISDUALHEAD if(pSiS->DualHeadMode) - pScreen->SaveScreen = SISSaveScreenDH; + pScreen->SaveScreen = SISSaveScreenDH; else #endif - pScreen->SaveScreen = SISSaveScreen; + pScreen->SaveScreen = SISSaveScreen; /* Install BlockHandler */ pSiS->BlockHandler = pScreen->BlockHandler; @@ -4910,18 +6916,45 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Report any unused options (only for the first generation) */ if(serverGeneration == 1) { - xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); } + /* Clear frame buffer */ + /* For CRT2, we don't do that at this point in dual head + * mode since the mode isn't switched at this time (it will + * be reset when setting the CRT1 mode). Hence, we just + * save the necessary data and clear the screen when + * going through this for CRT1. + */ + + OnScreenSize = pScrn->displayWidth * pScrn->currentMode->VDisplay + * (pScrn->bitsPerPixel >> 3); + /* Turn on the screen now */ - /* TW: We do this in dual head mode after second head is finished */ + /* We do this in dual head mode after second head is finished */ #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { - if(pSiS->SecondHead) - SISSaveScreen(pScreen, SCREEN_SAVER_OFF); - } else + if(pSiS->SecondHead) { + bzero(pSiS->FbBase, OnScreenSize); + bzero(pSiSEnt->FbBase1, pSiSEnt->OnScreenSize1); + SISSaveScreen(pScreen, SCREEN_SAVER_OFF); + } else { + pSiSEnt->FbBase1 = pSiS->FbBase; + pSiSEnt->OnScreenSize1 = OnScreenSize; + } + } else { #endif - SISSaveScreen(pScreen, SCREEN_SAVER_OFF); + SISSaveScreen(pScreen, SCREEN_SAVER_OFF); + bzero(pSiS->FbBase, OnScreenSize); +#ifdef SISDUALHEAD + } +#endif + + pSiS->SiS_SD_Flags &= ~SiS_SD_ISDEPTH8; + if(pSiS->CurrentLayout.bitsPerPixel == 8) { + pSiS->SiS_SD_Flags |= SiS_SD_ISDEPTH8; + pSiS->SiS_SD_Flags &= ~SiS_SD_SUPPORTXVGAMMA1; + } return TRUE; } @@ -4935,187 +6968,701 @@ SISSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) if(!pSiS->NoAccel) { if(pSiS->AccelInfoPtr) { - (*pSiS->AccelInfoPtr->Sync)(pScrn); + (*pSiS->AccelInfoPtr->Sync)(pScrn); } } - return SISModeInit(xf86Screens[scrnIndex], mode); + if(!(SISModeInit(xf86Screens[scrnIndex], mode))) return FALSE; + + /* Since RandR (indirectly) uses SwitchMode(), we need to + * update our Xinerama info here, too, in case of resizing + */ +#ifdef SISMERGED +#ifdef SISXINERAMA + if(pSiS->MergedFB) { + SiSUpdateXineramaScreenInfo(pScrn); + } +#endif +#endif + return TRUE; } -#ifdef CYCLECRT2 -/* TW: Cycle CRT2 output devices */ Bool -SISCycleCRT2Type(int scrnIndex, DisplayModePtr mode) +SISSwitchCRT2Type(ScrnInfoPtr pScrn, unsigned long newvbflags) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; SISPtr pSiS = SISPTR(pScrn); - int i = 0; + BOOLEAN hcm; + DisplayModePtr mode = pScrn->currentMode; - /* TW: Only on 300 and 310/325 series */ + /* Do NOT use this to switch from CRT2_LCD to CRT1_LCDA */ + + /* Only on 300 and 315/330 series */ if(pSiS->VGAEngine != SIS_300_VGA && pSiS->VGAEngine != SIS_315_VGA) return FALSE; - /* TW: Only if there is a video bridge */ - if(pSiS->VBFlags & VB_VIDEOBRIDGE) return FALSE; + /* Only if there is a video bridge */ + if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) return FALSE; + +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) return FALSE; +#endif + +#define SiS_NewVBMask (CRT2_ENABLE|CRT1_LCDA|TV_PAL|TV_NTSC|TV_PALM|TV_PALN|TV_NTSCJ|TV_AVIDEO|TV_SVIDEO|TV_SCART) + + newvbflags &= SiS_NewVBMask; + newvbflags |= pSiS->VBFlags & ~SiS_NewVBMask; + + if(!(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTLCDA)) { + newvbflags &= ~CRT1_LCDA; + } + +#ifdef SISMERGED + if(pSiS->MergedFB) { + if(!(newvbflags & CRT2_ENABLE)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "CRT2 can't be switched off in MergedFB mode\n"); + return FALSE; + } + hcm = pSiS->HaveCustomModes2; + if(mode->Private) { + mode = ((SiSMergedDisplayModePtr)mode->Private)->CRT2; + } + } else +#endif + hcm = pSiS->HaveCustomModes; + + if((!(newvbflags & CRT2_ENABLE)) && (!newvbflags & DISPTYPE_CRT1)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "CRT2 can't be switched off while CRT1 is off\n"); + return FALSE; + } - /* TW: Only if there were more than 1 CRT2 devices detected */ - if(pSiS->detectedCRT2Devices & CRT2_VGA) i++; - if(pSiS->detectedCRT2Devices & CRT2_LCD) i++; - if(pSiS->detectedCRT2Devices & CRT2_TV) i++; - if(i <= 1) return FALSE; + /* CRT2_LCD overrules LCDA */ + if(newvbflags & CRT2_LCD) { + newvbflags &= ~CRT1_LCDA; + } - /* TW: Cycle CRT2 type */ - i = (pSiS->VBFlags & DISPTYPE_DISP2) << 1; - while(!(i & pSiS->detectedCRT2Devices)) { - i <<= 1; - if(i > CRT2_VGA) i = CRT2_LCD; + /* Check if the current mode is suitable for desired output device (if any) */ + if(newvbflags & CRT2_ENABLE) { + if(!SiS_CheckCalcModeIndex(pScrn, mode, newvbflags, hcm)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Current mode not suitable for desired CRT2 output device\n"); + return FALSE; + } } - /* TW: Check if mode is suitable for desired output device */ - if(!SiS_CheckCalcModeIndex(pScrn, pScrn->currentMode, - ((pSiS->VBFlags & ~(DISPTYPE_DISP2)) | i))) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Current mode not suitable for desired CRT2 output device\n"); - return FALSE; + /* Remember: Dualhead not supported */ + newvbflags &= ~(SINGLE_MODE | MIRROR_MODE); + if((newvbflags & DISPTYPE_CRT1) && (newvbflags & CRT2_ENABLE)) { + newvbflags |= MIRROR_MODE; + } else { + newvbflags |= SINGLE_MODE; } - /* TW: Sync the accelerators */ + /* Sync the accelerators */ if(!pSiS->NoAccel) { - if(pSiS->AccelInfoPtr) { - (*pSiS->AccelInfoPtr->Sync)(pScrn); - } + if(pSiS->AccelInfoPtr) { + (*pSiS->AccelInfoPtr->Sync)(pScrn); + } } - pSiS->VBFlags &= ~(DISPTYPE_DISP2); - pSiS->VBFlags |= i; + pSiS->VBFlags = pSiS->VBFlags_backup = newvbflags; - return SISModeInit(xf86Screens[scrnIndex], mode); + if(!(pScrn->SwitchMode(pScrn->scrnIndex, pScrn->currentMode, 0))) return FALSE; + SISAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + return TRUE; +} + +Bool +SISCheckModeIndexForCRT2Type(ScrnInfoPtr pScrn, unsigned short cond, unsigned short index, Bool quiet) +{ + SISPtr pSiS = SISPTR(pScrn); + BOOLEAN hcm = pSiS->HaveCustomModes; + DisplayModePtr mode = pScrn->modes, mastermode; + int i; + unsigned long vbflags = pSiS->VBFlags; + + /* This has been extended to handle LCDA as well */ + + /* Only on 300 and 315/330 series */ + if(pSiS->VGAEngine != SIS_300_VGA && + pSiS->VGAEngine != SIS_315_VGA) return FALSE; + + /* Mode is OK if there is no video bridge */ + /* (Requires screen size check in app) */ + if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) return TRUE; + + /* No special treatment for NTSC-J here */ + if(cond) { + vbflags &= ~(CRT2_ENABLE | TV_TYPE | TV_PALM | TV_PALN | CRT1_LCDA); + if(cond & SiS_CF2_LCD) { + vbflags |= CRT2_LCD; + } else if(cond & SiS_CF2_TV) { + vbflags |= CRT2_TV; + if(cond & SiS_CF2_TVPAL) vbflags |= TV_PAL; + else if(cond & SiS_CF2_TVPALM) vbflags |= (TV_PAL | TV_PALM); + else if(cond & SiS_CF2_TVPALN) vbflags |= (TV_PAL | TV_PALN); + else if(cond & SiS_CF2_TVNTSC) vbflags |= TV_NTSC; + } else if(cond & SiS_CF2_VGA2) { + vbflags |= CRT2_VGA; + } else if(cond & SiS_CF2_CRT1LCDA) { + vbflags |= CRT1_LCDA; + } + } + + /* Mode is obviously OK if video bridge is disabled */ + /* (Requires extra check for eventual screen size problems in app) */ + if(!(vbflags & (CRT2_ENABLE | CRT1_LCDA))) return TRUE; + + /* Find mode of given index */ + if(index) { + for(i = 0; i < index; i++) { + if(!mode) return FALSE; + mode = mode->next; + } + } + + mastermode = mode; + +#ifdef SISDUALHEAD + if((!pSiS->DualHeadMode) || (!pSiS->SecondHead)) { +#endif + + if(vbflags & CRT2_ENABLE) { + +#ifdef SISMERGED + if(pSiS->MergedFB) { + hcm = pSiS->HaveCustomModes2; + if(mode->Private) { + mode = ((SiSMergedDisplayModePtr)mode->Private)->CRT2; + } + } +#endif + + /* For RandR */ + if((mode->HDisplay > pScrn->virtualX) || (mode->VDisplay > pScrn->virtualY)) { + if(!quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Desired mode too large for current screen size\n"); + } + return FALSE; + } + + /* Check if the desired mode is suitable for current CRT2 output device */ + if(!SiS_CheckCalcModeIndex(pScrn, mode, vbflags, hcm)) { + if((!cond) && (!quiet)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Desired mode not suitable for current CRT2 output device\n"); + } + return FALSE; + } + + } + +#ifdef SISDUALHEAD + } +#endif + + mode = mastermode; + +#ifdef SISDUALHEAD + if((!pSiS->DualHeadMode) || (pSiS->SecondHead)) { +#endif + + if(vbflags & CRT1_LCDA) { + +#ifdef SISMERGED + if(pSiS->MergedFB) { + hcm = pSiS->HaveCustomModes; + if(mode->Private) { + mode = ((SiSMergedDisplayModePtr)mode->Private)->CRT1; + } + } +#endif + + /* For RandR */ + if((mode->HDisplay > pScrn->virtualX) || (mode->VDisplay > pScrn->virtualY)) { + if(!quiet) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Desired mode too large for current screen size\n"); + } + return FALSE; + } + + /* Check if the desired mode is suitable for current CRT1 output device */ + if(!SiS_CalcModeIndex(pScrn, mode, vbflags, hcm)) { + if((!cond) && (!quiet)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Desired mode not suitable for current CRT1 output device\n"); + } + return FALSE; + } + + } + +#ifdef SISDUALHEAD + } +#endif + + return TRUE; +} + +Bool +SISSwitchCRT1Status(ScrnInfoPtr pScrn, int onoff) +{ + SISPtr pSiS = SISPTR(pScrn); + DisplayModePtr mode = pScrn->currentMode; + unsigned long vbflags = pSiS->VBFlags; + int crt1off; + + /* onoff: 0=OFF, 1=ON(VGA), 2=ON(LCDA) */ + /* Switching to LCDA will disable CRT2 if previously LCD */ + + /* Do NOT use this to switch from CRT1_LCDA to CRT2_LCD */ + + /* Only on 300 and 315/330 series */ + if(pSiS->VGAEngine != SIS_300_VGA && + pSiS->VGAEngine != SIS_315_VGA) return FALSE; + + /* Off only if at least one CRT2 device is active */ + if((!onoff) && (!(vbflags & CRT2_ENABLE))) return FALSE; + +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) return FALSE; +#endif + + /* Can't switch to LCDA of not supported (duh!) */ + 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"); + return FALSE; + } + } + +#ifdef SISMERGED + if(pSiS->MergedFB) { + if(!onoff) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "CRT1 can't be switched off in MergedFB mode\n"); + return FALSE; + } else if(onoff == 2) { + if(vbflags & CRT2_LCD) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "CRT2 type can't be LCD while CRT1 is LCD-via-CRT1\n"); + return FALSE; + } + } + if(mode->Private) { + mode = ((SiSMergedDisplayModePtr)mode->Private)->CRT1; + } + } +#endif + + vbflags &= ~(DISPTYPE_CRT1 | SINGLE_MODE | MIRROR_MODE | CRT1_LCDA); + crt1off = 1; + if(onoff > 0) { + vbflags |= DISPTYPE_CRT1; + crt1off = 0; + if(onoff == 2) { + vbflags |= CRT1_LCDA; + vbflags &= ~CRT2_LCD; + } + /* Remember: Dualhead not supported */ + if(vbflags & CRT2_ENABLE) vbflags |= MIRROR_MODE; + else vbflags |= SINGLE_MODE; + } else { + vbflags |= SINGLE_MODE; + } + + if(vbflags & CRT1_LCDA) { + if(!SiS_CalcModeIndex(pScrn, mode, vbflags, pSiS->HaveCustomModes)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Current mode not suitable for LCD-via-CRT1\n"); + return FALSE; + } + } + + pSiS->CRT1off = crt1off; + pSiS->VBFlags = pSiS->VBFlags_backup = vbflags; + + /* 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); + return TRUE; +} + +static void +SISSetStartAddressCRT1(SISPtr pSiS, unsigned long base) +{ + unsigned char cr11backup; + + inSISIDXREG(SISCR, 0x11, cr11backup); /* Unlock CRTC registers */ + andSISIDXREG(SISCR, 0x11, 0x7F); + outSISIDXREG(SISCR, 0x0D, base & 0xFF); + outSISIDXREG(SISCR, 0x0C, (base >> 8) & 0xFF); + outSISIDXREG(SISSR, 0x0D, (base >> 16) & 0xFF); + if(pSiS->VGAEngine == SIS_315_VGA) { + setSISIDXREG(SISSR, 0x37, 0xFE, (base >> 24) & 0x01); + } + /* Eventually lock CRTC registers */ + setSISIDXREG(SISCR, 0x11, 0x7F,(cr11backup & 0x80)); +} + +static void +SISSetStartAddressCRT2(SISPtr pSiS, unsigned long base) +{ + SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); + outSISIDXREG(SISPART1, 0x06, GETVAR8(base)); + outSISIDXREG(SISPART1, 0x05, GETBITS(base, 15:8)); + outSISIDXREG(SISPART1, 0x04, GETBITS(base, 23:16)); + if(pSiS->VGAEngine == SIS_315_VGA) { + setSISIDXREG(SISPART1, 0x02, 0x7F, ((base >> 24) & 0x01) << 7); + } + SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext); +} + +#ifdef SISMERGED +Bool +InRegion(int x, int y, region r) +{ + return (r.x0 <= x) && (x <= r.x1) && (r.y0 <= y) && (y <= r.y1); +} + +static void +SISAdjustFrameHW_CRT1(ScrnInfoPtr pScrn, int x, int y) +{ + SISPtr pSiS = SISPTR(pScrn); + unsigned long base; + + base = y * pSiS->CurrentLayout.displayWidth + x; + switch(pSiS->CurrentLayout.bitsPerPixel) { + case 16: base >>= 1; break; + case 32: break; + default: base >>= 2; + } + SISSetStartAddressCRT1(pSiS, base); +} + +static void +SISAdjustFrameHW_CRT2(ScrnInfoPtr pScrn, int x, int y) +{ + SISPtr pSiS = SISPTR(pScrn); + unsigned long base; + + base = y * pSiS->CurrentLayout.displayWidth + x; + switch(pSiS->CurrentLayout.bitsPerPixel) { + case 16: base >>= 1; break; + case 32: break; + default: base >>= 2; + } + SISSetStartAddressCRT2(pSiS, base); +} + +static void +SISMergePointerMoved(int scrnIndex, int x, int y) +{ + ScrnInfoPtr pScrn1 = xf86Screens[scrnIndex]; + SISPtr pSiS = SISPTR(pScrn1); + ScrnInfoPtr pScrn2 = pSiS->CRT2pScrn; + region out, in1, in2, f2, f1; + int deltax, deltay; + + f1.x0 = pSiS->CRT1frameX0; + f1.x1 = pSiS->CRT1frameX1; + f1.y0 = pSiS->CRT1frameY0; + f1.y1 = pSiS->CRT1frameY1; + f2.x0 = pScrn2->frameX0; + f2.x1 = pScrn2->frameX1; + f2.y0 = pScrn2->frameY0; + f2.y1 = pScrn2->frameY1; + + /* Define the outer region. Crossing this causes all frames to move */ + out.x0 = pScrn1->frameX0; + out.x1 = pScrn1->frameX1; + out.y0 = pScrn1->frameY0; + out.y1 = pScrn1->frameY1; + + /* + * Define the inner sliding window. Being outsize both frames but + * inside the outer clipping window will slide corresponding frame + */ + in1 = out; + in2 = out; + switch(((SiSMergedDisplayModePtr)pSiS->CurrentLayout.mode->Private)->CRT2Position) { + case sisLeftOf: + in1.x0 = f1.x0; + in2.x1 = f2.x1; + break; + case sisRightOf: + in1.x1 = f1.x1; + in2.x0 = f2.x0; + break; + case sisBelow: + in1.y1 = f1.y1; + in2.y0 = f2.y0; + break; + case sisAbove: + in1.y0 = f1.y0; + in2.y1 = f2.y1; + break; + case sisClone: + break; + } + + deltay = 0; + deltax = 0; + + if(InRegion(x, y, out)) { /* inside outer region */ + + if(InRegion(x, y, in1) && !InRegion(x, y, f1)) { + REBOUND(f1.x0, f1.x1, x); + REBOUND(f1.y0, f1.y1, y); + deltax = 1; + } + if(InRegion(x, y, in2) && !InRegion(x, y, f2)) { + REBOUND(f2.x0, f2.x1, x); + REBOUND(f2.y0, f2.y1, y); + deltax = 1; + } + + } else { /* outside outer region */ + + if(out.x0 > x) { + deltax = x - out.x0; + } + if(out.x1 < x) { + deltax = x - out.x1; + } + if(deltax) { + pScrn1->frameX0 += deltax; + pScrn1->frameX1 += deltax; + f1.x0 += deltax; + f1.x1 += deltax; + f2.x0 += deltax; + f2.x1 += deltax; + } + + if(out.y0 > y) { + deltay = y - out.y0; + } + if(out.y1 < y) { + deltay = y - out.y1; + } + if(deltay) { + pScrn1->frameY0 += deltay; + pScrn1->frameY1 += deltay; + f1.y0 += deltay; + f1.y1 += deltay; + f2.y0 += deltay; + f2.y1 += deltay; + } + + switch(((SiSMergedDisplayModePtr)pSiS->CurrentLayout.mode->Private)->CRT2Position) { + case sisLeftOf: + if(x >= f1.x0) { REBOUND(f1.y0, f1.y1, y); } + if(x <= f2.x1) { REBOUND(f2.y0, f2.y1, y); } + break; + case sisRightOf: + if(x <= f1.x1) { REBOUND(f1.y0, f1.y1, y); } + if(x >= f2.x0) { REBOUND(f2.y0, f2.y1, y); } + break; + case sisBelow: + if(y <= f1.y1) { REBOUND(f1.x0, f1.x1, x); } + if(y >= f2.y0) { REBOUND(f2.x0, f2.x1, x); } + break; + case sisAbove: + if(y >= f1.y0) { REBOUND(f1.x0, f1.x1, x); } + if(y <= f2.y1) { REBOUND(f2.x0, f2.x1, x); } + break; + case sisClone: + break; + } + + } + + if(deltax || deltay) { + pSiS->CRT1frameX0 = f1.x0; + pSiS->CRT1frameY0 = f1.y0; + pScrn2->frameX0 = f2.x0; + pScrn2->frameY0 = f2.y0; + + pSiS->CRT1frameX1 = pSiS->CRT1frameX0 + CDMPTR->CRT1->HDisplay - 1; + pSiS->CRT1frameY1 = pSiS->CRT1frameY0 + CDMPTR->CRT1->VDisplay - 1; + pScrn2->frameX1 = pScrn2->frameX0 + CDMPTR->CRT2->HDisplay - 1; + pScrn2->frameY1 = pScrn2->frameY0 + CDMPTR->CRT2->VDisplay - 1; + pScrn1->frameX1 = pScrn1->frameX0 + pSiS->CurrentLayout.mode->HDisplay - 1; + pScrn1->frameY1 = pScrn1->frameY0 + pSiS->CurrentLayout.mode->VDisplay - 1; + + SISAdjustFrameHW_CRT1(pScrn1, pSiS->CRT1frameX0, pSiS->CRT1frameY0); + SISAdjustFrameHW_CRT2(pScrn1, pScrn2->frameX0, pScrn2->frameY0); + } +} + +static void +SISAdjustFrameMerged(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn1 = xf86Screens[scrnIndex]; + SISPtr pSiS = SISPTR(pScrn1); + ScrnInfoPtr pScrn2 = pSiS->CRT2pScrn; + int VTotal = pSiS->CurrentLayout.mode->VDisplay; + int HTotal = pSiS->CurrentLayout.mode->HDisplay; + int VMax = VTotal; + int HMax = HTotal; + + BOUND(x, 0, pScrn1->virtualX - HTotal); + BOUND(y, 0, pScrn1->virtualY - VTotal); + + switch(SDMPTR(pScrn1)->CRT2Position) { + case sisLeftOf: + pScrn2->frameX0 = x; + BOUND(pScrn2->frameY0, y, y + VMax - CDMPTR->CRT2->VDisplay); + pSiS->CRT1frameX0 = x + CDMPTR->CRT2->HDisplay; + BOUND(pSiS->CRT1frameY0, y, y + VMax - CDMPTR->CRT1->VDisplay); + break; + case sisRightOf: + pSiS->CRT1frameX0 = x; + BOUND(pSiS->CRT1frameY0, y, y + VMax - CDMPTR->CRT1->VDisplay); + pScrn2->frameX0 = x + CDMPTR->CRT1->HDisplay; + BOUND(pScrn2->frameY0, y, y + VMax - CDMPTR->CRT2->VDisplay); + break; + case sisAbove: + BOUND(pScrn2->frameX0, x, x + HMax - CDMPTR->CRT2->HDisplay); + pScrn2->frameY0 = y; + BOUND(pSiS->CRT1frameX0, x, x + HMax - CDMPTR->CRT1->HDisplay); + pSiS->CRT1frameY0 = y + CDMPTR->CRT2->VDisplay; + break; + case sisBelow: + BOUND(pSiS->CRT1frameX0, x, x + HMax - CDMPTR->CRT1->HDisplay); + pSiS->CRT1frameY0 = y; + BOUND(pScrn2->frameX0, x, x + HMax - CDMPTR->CRT2->HDisplay); + pScrn2->frameY0 = y + CDMPTR->CRT1->VDisplay; + break; + case sisClone: + BOUND(pSiS->CRT1frameX0, x, x + HMax - CDMPTR->CRT1->HDisplay); + BOUND(pSiS->CRT1frameY0, y, y + VMax - CDMPTR->CRT1->VDisplay); + BOUND(pScrn2->frameX0, x, x + HMax - CDMPTR->CRT2->HDisplay); + BOUND(pScrn2->frameY0, y, y + VMax - CDMPTR->CRT2->VDisplay); + break; + } + + BOUND(pSiS->CRT1frameX0, 0, pScrn1->virtualX - CDMPTR->CRT1->HDisplay); + BOUND(pSiS->CRT1frameY0, 0, pScrn1->virtualY - CDMPTR->CRT1->VDisplay); + BOUND(pScrn2->frameX0, 0, pScrn1->virtualX - CDMPTR->CRT2->HDisplay); + BOUND(pScrn2->frameY0, 0, pScrn1->virtualY - CDMPTR->CRT2->VDisplay); + + pScrn1->frameX0 = x; + pScrn1->frameY0 = y; + + pSiS->CRT1frameX1 = pSiS->CRT1frameX0 + CDMPTR->CRT1->HDisplay - 1; + pSiS->CRT1frameY1 = pSiS->CRT1frameY0 + CDMPTR->CRT1->VDisplay - 1; + pScrn2->frameX1 = pScrn2->frameX0 + CDMPTR->CRT2->HDisplay - 1; + pScrn2->frameY1 = pScrn2->frameY0 + CDMPTR->CRT2->VDisplay - 1; + pScrn1->frameX1 = pScrn1->frameX0 + pSiS->CurrentLayout.mode->HDisplay - 1; + pScrn1->frameY1 = pScrn1->frameY0 + pSiS->CurrentLayout.mode->VDisplay - 1; + + SISAdjustFrameHW_CRT1(pScrn1, pSiS->CRT1frameX0, pSiS->CRT1frameY0); + SISAdjustFrameHW_CRT2(pScrn1, pScrn2->frameX0, pScrn2->frameY0); } #endif /* * This function is used to initialize the Start Address - the first * displayed location in the video memory. + * + * Usually mandatory */ -/* Usually mandatory */ void SISAdjustFrame(int scrnIndex, int x, int y, int flags) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - SISPtr pSiS; - vgaHWPtr hwp; - int base; - unsigned char temp; - - hwp = VGAHWPTR(pScrn); - pSiS = SISPTR(pScrn); - - base = y * pSiS->CurrentLayout.displayWidth + x; + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SISPtr pSiS = SISPTR(pScrn); + unsigned long base; + unsigned char temp, cr11backup; + +#ifdef SISMERGED + if(pSiS->MergedFB) { + SISAdjustFrameMerged(scrnIndex, x, y, flags); + return; + } +#endif if(pSiS->UseVESA) { - - /* TW: Let BIOS adjust frame if using VESA */ VBESetDisplayStart(pSiS->pVbe, x, y, TRUE); + return; + } + if(pScrn->bitsPerPixel < 8) { + base = (y * pSiS->CurrentLayout.displayWidth + x + 3) >> 3; } else { + base = y * pSiS->CurrentLayout.displayWidth + x; + + /* calculate base bpp dep. */ + switch(pSiS->CurrentLayout.bitsPerPixel) { + case 16: + base >>= 1; + break; + case 24: + base = ((base * 3)) >> 2; + base -= base % 6; + break; + case 32: + break; + default: /* 8bpp */ + base >>= 2; + break; + } + } #ifdef UNLOCK_ALWAYS - sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); + sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - if(pScrn->bitsPerPixel < 8) { - base = (y * pSiS->CurrentLayout.displayWidth + x + 3) >> 3; - } else { - base = y * pSiS->CurrentLayout.displayWidth + x; - - /* calculate base bpp dep. */ - switch(pSiS->CurrentLayout.bitsPerPixel) { - case 16: - base >>= 1; - break; - case 24: - base = ((base * 3)) >> 2; - base -= base % 6; - break; - case 32: - break; - default: /* 8bpp */ - base >>= 2; - break; - } - } - -#ifdef SISDUALHEAD - if (pSiS->DualHeadMode) { - /* TW: We assume that DualHeadMode only can be true for - * dual head capable chipsets (and thus save the check - * for chipset here) - */ - if (!pSiS->SecondHead) { - /* TW: Head 1 (master) is always CRT2 */ - SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); - outSISIDXREG(SISPART1, 0x06, GETVAR8(base)); - outSISIDXREG(SISPART1, 0x05, GETBITS(base, 15:8)); - outSISIDXREG(SISPART1, 0x04, GETBITS(base, 23:16)); - if (pSiS->VGAEngine == SIS_315_VGA) { - setSISIDXREG(SISPART1, 0x02, 0x7F, ((base >> 24) & 0x01) << 7); - } - SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); - } else { - /* TW: Head 2 (slave) is always CRT1 */ - base += (pSiS->dhmOffset/4); - outSISIDXREG(SISCR, 0x0D, base & 0xFF); - outSISIDXREG(SISCR, 0x0C, (base >> 8) & 0xFF); - outSISIDXREG(SISSR, 0x0D, (base >> 16) & 0xFF); - if (pSiS->VGAEngine == SIS_315_VGA) { - setSISIDXREG(SISSR, 0x37, 0xFE, (base >> 24) & 0x01); - } - } - } else { +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + if(!pSiS->SecondHead) { + /* Head 1 (master) is always CRT2 */ + SISSetStartAddressCRT2(pSiS, base); + } else { + /* TW: Head 2 (slave) is always CRT1 */ + base += (pSiS->dhmOffset/4); + SISSetStartAddressCRT1(pSiS, base); + } + } else { #endif - switch (pSiS->VGAEngine) { - case SIS_300_VGA: - outSISIDXREG(SISCR, 0x0D, base & 0xFF); - outSISIDXREG(SISCR, 0x0C, (base >> 8) & 0xFF); - outSISIDXREG(SISSR, 0x0D, (base >> 16) & 0xFF); - if (pSiS->VBFlags & CRT2_ENABLE) { - SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); - outSISIDXREG(SISPART1, 0x06, GETVAR8(base)); - outSISIDXREG(SISPART1, 0x05, GETBITS(base, 15:8)); - outSISIDXREG(SISPART1, 0x04, GETBITS(base, 23:16)); - SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); - } - break; - case SIS_315_VGA: - outSISIDXREG(SISCR, 0x0D, base & 0xFF); - outSISIDXREG(SISCR, 0x0C, (base >> 8) & 0xFF); - outSISIDXREG(SISSR, 0x0D, (base >> 16) & 0xFF); - setSISIDXREG(SISSR, 0x37, 0xFE, (base >> 24) & 0x01); - if (pSiS->VBFlags & CRT2_ENABLE) { - SiS_UnLockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); - outSISIDXREG(SISPART1, 0x06, GETVAR8(base)); - outSISIDXREG(SISPART1, 0x05, GETBITS(base, 15:8)); - outSISIDXREG(SISPART1, 0x04, GETBITS(base, 23:16)); - setSISIDXREG(SISPART1, 0x02, 0x7F, ((base >> 24) & 0x01) << 7); - SiS_LockCRT2(pSiS->SiS_Pr, &pSiS->sishw_ext, pSiS->RelIO+0x30); - } - break; - default: - outSISIDXREG(SISCR, 0x0D, base & 0xFF); - outSISIDXREG(SISCR, 0x0C, (base >> 8) & 0xFF); - inSISIDXREG(SISSR, 0x27, temp); - temp &= 0xF0; - temp |= (base & 0x0F0000) >> 16; - outSISIDXREG(SISSR, 0x27, temp); - } + switch(pSiS->VGAEngine) { + case SIS_300_VGA: + case SIS_315_VGA: + SISSetStartAddressCRT1(pSiS, base); + if(pSiS->VBFlags & CRT2_ENABLE) { + SISSetStartAddressCRT2(pSiS, base); + } + break; + default: + /* Unlock CRTC registers */ + inSISIDXREG(SISCR, 0x11, cr11backup); + andSISIDXREG(SISCR, 0x11, 0x7F); + outSISIDXREG(SISCR, 0x0D, base & 0xFF); + outSISIDXREG(SISCR, 0x0C, (base >> 8) & 0xFF); + inSISIDXREG(SISSR, 0x27, temp); + temp &= 0xF0; + temp |= (base & 0x0F0000) >> 16; + outSISIDXREG(SISSR, 0x27, temp); + /* Eventually lock CRTC registers */ + setSISIDXREG(SISCR, 0x11, 0x7F, (cr11backup & 0x80)); + } #ifdef SISDUALHEAD - } + } #endif - } /* if not VESA */ } - /* * This is called when VT switching back to the X server. Its job is * to reinitialise the video mode. @@ -5130,19 +7677,26 @@ SISEnterVT(int scrnIndex, int flags) sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); if(!SISModeInit(pScrn, pScrn->currentMode)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "SiSEnterVT: SISModeInit() failed\n"); - return FALSE; + SISErrorLog(pScrn, "SiSEnterVT: SISModeInit() failed\n"); + return FALSE; } SISAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); #ifdef XF86DRI - /* TW: this is to be done AFTER switching the mode */ - if(pSiS->directRenderingEnabled) - DRIUnlock(screenInfo.screens[scrnIndex]); + /* this is to be done AFTER switching the mode */ + if(pSiS->directRenderingEnabled) { + DRIUnlock(screenInfo.screens[scrnIndex]); + } #endif +#ifdef SISDUALHEAD + if((!pSiS->DualHeadMode) || (!pSiS->SecondHead)) +#endif + if(pSiS->ResetXv) { + (pSiS->ResetXv)(pScrn); + } + return TRUE; } @@ -5160,10 +7714,10 @@ SISLeaveVT(int scrnIndex, int flags) #ifdef XF86DRI ScreenPtr pScreen; - /* TW: to be done before mode change */ + /* to be done before mode change */ if(pSiS->directRenderingEnabled) { - pScreen = screenInfo.screens[scrnIndex]; - DRILock(pScreen, 0); + pScreen = screenInfo.screens[scrnIndex]; + DRILock(pScreen, 0); } #endif @@ -5175,12 +7729,12 @@ SISLeaveVT(int scrnIndex, int flags) #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { if(!pSiS->SecondHead) { - pSiS->ForceCursorOff = TRUE; - pSiS->CursorInfoPtr->HideCursor(pScrn); - SISWaitVBRetrace(pScrn); - pSiS->ForceCursorOff = FALSE; + pSiS->ForceCursorOff = TRUE; + pSiS->CursorInfoPtr->HideCursor(pScrn); + SISWaitVBRetrace(pScrn); + pSiS->ForceCursorOff = FALSE; } - } else { + } else { #endif pSiS->CursorInfoPtr->HideCursor(pScrn); SISWaitVBRetrace(pScrn); @@ -5193,20 +7747,29 @@ SISLeaveVT(int scrnIndex, int flags) if(pSiS->UseVESA) { - /* TW: This is a q&d work-around for a BIOS bug. In case we disabled CRT2, - * VBESaveRestore() does not restore CRT1. So we set any mode now, - * because VBESetVBEMode correctly restores CRT1. Afterwards, we - * can call VBESaveRestore to restore original mode. - */ - if ( (pSiS->VBFlags & VB_VIDEOBRIDGE) && (!(pSiS->VBFlags & DISPTYPE_DISP2)) ) - VBESetVBEMode(pSiS->pVbe, (pSiS->SISVESAModeList->n) | 0xc000, NULL); + /* This is a q&d work-around for a BIOS bug. In case we disabled CRT2, + * VBESaveRestore() does not restore CRT1. So we set any mode now, + * because VBESetVBEMode correctly restores CRT1. Afterwards, we + * can call VBESaveRestore to restore original mode. + */ + if((pSiS->VBFlags & VB_VIDEOBRIDGE) && (!(pSiS->VBFlags & DISPTYPE_DISP2))) + VBESetVBEMode(pSiS->pVbe, (pSiS->SISVESAModeList->n) | 0xc000, NULL); - SISVESARestore(pScrn); + SISVESARestore(pScrn); } else { - + SISRestore(pScrn); - + + } + + /* We use this (otherwise unused) bit to indicate that we are running + * to keep sisfb to change the displaymode (this would result in + * lethal display corruption upon quitting X or changing to a VT + * until a reboot) + */ + if(pSiS->VGAEngine == SIS_300_VGA || pSiS->VGAEngine == SIS_315_VGA) { + orSISIDXREG(SISCR,0x34,0x80); } vgaHWLock(hwp); @@ -5230,15 +7793,15 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen) #ifdef XF86DRI if(pSiS->directRenderingEnabled) { - SISDRICloseScreen(pScreen); - pSiS->directRenderingEnabled = FALSE; + SISDRICloseScreen(pScreen); + pSiS->directRenderingEnabled = FALSE; } #endif if(pScrn->vtSema) { if(pSiS->CursorInfoPtr) { -#ifdef SISDUALHEAD +#ifdef SISDUALHEAD if(pSiS->DualHeadMode) { if(!pSiS->SecondHead) { pSiS->ForceCursorOff = TRUE; @@ -5246,26 +7809,26 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen) SISWaitVBRetrace(pScrn); pSiS->ForceCursorOff = FALSE; } - } else { + } else { #endif pSiS->CursorInfoPtr->HideCursor(pScrn); SISWaitVBRetrace(pScrn); -#ifdef SISDUALHEAD - } -#endif +#ifdef SISDUALHEAD + } +#endif } SISBridgeRestore(pScrn); if(pSiS->UseVESA) { - /* TW: This is a q&d work-around for a BIOS bug. In case we disabled CRT2, - * VBESaveRestore() does not restore CRT1. So we set any mode now, - * because VBESetVBEMode correctly restores CRT1. Afterwards, we - * can call VBESaveRestore to restore original mode. + /* This is a q&d work-around for a BIOS bug. In case we disabled CRT2, + * VBESaveRestore() does not restore CRT1. So we set any mode now, + * because VBESetVBEMode correctly restores CRT1. Afterwards, we + * can call VBESaveRestore to restore original mode. */ - if( (pSiS->VBFlags & VB_VIDEOBRIDGE) && (!(pSiS->VBFlags & DISPTYPE_DISP2))) - VBESetVBEMode(pSiS->pVbe, (pSiS->SISVESAModeList->n) | 0xc000, NULL); + if((pSiS->VBFlags & VB_VIDEOBRIDGE) && (!(pSiS->VBFlags & DISPTYPE_DISP2))) + VBESetVBEMode(pSiS->pVbe, (pSiS->SISVESAModeList->n) | 0xc000, NULL); SISVESARestore(pScrn); @@ -5278,44 +7841,53 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen) vgaHWLock(hwp); } + if(pSiS->VGAEngine == SIS_300_VGA || pSiS->VGAEngine == SIS_315_VGA) { + andSISIDXREG(SISCR,0x34,0x7f); + } + SISUnmapMem(pScrn); vgaHWUnmapMem(pScrn); - + #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { - pSiSEnt = pSiS->entityPrivate; - pSiSEnt->refCount--; + pSiSEnt = pSiS->entityPrivate; + pSiSEnt->refCount--; } -#endif +#endif if(pSiS->pInt) { - xf86FreeInt10(pSiS->pInt); - pSiS->pInt = NULL; + xf86FreeInt10(pSiS->pInt); + pSiS->pInt = NULL; + } + + if(pSiS->AccelLinearScratch) { + xf86FreeOffscreenLinear(pSiS->AccelLinearScratch); + pSiS->AccelLinearScratch = NULL; } if(pSiS->AccelInfoPtr) { - XAADestroyInfoRec(pSiS->AccelInfoPtr); - pSiS->AccelInfoPtr = NULL; + XAADestroyInfoRec(pSiS->AccelInfoPtr); + pSiS->AccelInfoPtr = NULL; } if(pSiS->CursorInfoPtr) { - xf86DestroyCursorInfoRec(pSiS->CursorInfoPtr); - pSiS->CursorInfoPtr = NULL; + xf86DestroyCursorInfoRec(pSiS->CursorInfoPtr); + pSiS->CursorInfoPtr = NULL; } if(pSiS->ShadowPtr) { - xfree(pSiS->ShadowPtr); - pSiS->ShadowPtr = NULL; + xfree(pSiS->ShadowPtr); + pSiS->ShadowPtr = NULL; } if(pSiS->DGAModes) { - xfree(pSiS->DGAModes); - pSiS->DGAModes = NULL; + xfree(pSiS->DGAModes); + pSiS->DGAModes = NULL; } if(pSiS->adaptor) { - xfree(pSiS->adaptor); - pSiS->adaptor = NULL; + xfree(pSiS->adaptor); + pSiS->adaptor = NULL; } pScrn->vtSema = FALSE; @@ -5324,7 +7896,8 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen) pScreen->BlockHandler = pSiS->BlockHandler; pScreen->CloseScreen = pSiS->CloseScreen; - return (*pScreen->CloseScreen)(scrnIndex, pScreen); + + return(*pScreen->CloseScreen)(scrnIndex, pScreen); } @@ -5334,116 +7907,150 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen) static void SISFreeScreen(int scrnIndex, int flags) { - if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) - vgaHWFreeHWRec(xf86Screens[scrnIndex]); + if(xf86LoaderCheckSymbol("vgaHWFreeHWRec")) { + vgaHWFreeHWRec(xf86Screens[scrnIndex]); + } + SISFreeRec(xf86Screens[scrnIndex]); } /* Checks if a mode is suitable for the selected chipset. */ -/* Optional */ -static int +static ModeStatus SISValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; SISPtr pSiS = SISPTR(pScrn); if(pSiS->UseVESA) { - if(SiSCalcVESAModeIndex(pScrn, mode)) - return(MODE_OK); - else - return(MODE_BAD); + if(SiSCalcVESAModeIndex(pScrn, mode)) + return(MODE_OK); + else + return(MODE_BAD); } + if(pSiS->VGAEngine == SIS_300_VGA || pSiS->VGAEngine == SIS_315_VGA) { #ifdef SISDUALHEAD - if((pSiS->DualHeadMode) && (pSiS->SecondHead)) { - /* DHM: Only check modes for CRT1 */ - if(SiS_CalcModeIndex(pScrn, mode) < 0x14) - return(MODE_BAD); - } else -#endif - if(SiS_CheckCalcModeIndex(pScrn, mode, pSiS->VBFlags) < 0x14) + if(pSiS->DualHeadMode) { + if(pSiS->SecondHead) { + if(SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes) < 0x14) + return(MODE_BAD); + } else { + if(SiS_CheckCalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes) < 0x14) return(MODE_BAD); + } + } else +#endif +#ifdef SISMERGED + if(pSiS->MergedFB) { + if(!mode->Private) { + if(!pSiS->CheckForCRT2) { + if(SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes) < 0x14) + return(MODE_BAD); + } else { + if(SiS_CheckCalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes2) < 0x14) + return(MODE_BAD); + } + } else { + if(SiS_CalcModeIndex(pScrn, ((SiSMergedDisplayModePtr)mode->Private)->CRT1, + pSiS->VBFlags, pSiS->HaveCustomModes) < 0x14) + return(MODE_BAD); + + if(SiS_CheckCalcModeIndex(pScrn, ((SiSMergedDisplayModePtr)mode->Private)->CRT2, + pSiS->VBFlags, pSiS->HaveCustomModes2) < 0x14) + return(MODE_BAD); + } + } else +#endif + { + if(pSiS->VBFlags & CRT1_LCDA) { + if(SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes) < 0x14) + return(MODE_BAD); + } + if(SiS_CheckCalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes) < 0x14) + return(MODE_BAD); + } } - + return(MODE_OK); } -/* Do screen blanking */ - -/* Mandatory */ +/* Do screen blanking + * + * Mandatory + */ static Bool SISSaveScreen(ScreenPtr pScreen, int mode) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - if ((pScrn != NULL) && pScrn->vtSema) { + if((pScrn != NULL) && pScrn->vtSema) { SISPtr pSiS = SISPTR(pScrn); - /* enable access to extended sequencer registers */ #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - if(pSiS->VGAEngine == SIS_300_VGA) { + if(pSiS->VBFlags & (CRT2_LCD | CRT1_LCDA)) { - if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - if(!xf86IsUnblank(mode)) { - pSiS->Blank = TRUE; - SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); - } else { - pSiS->Blank = FALSE; - SiS_SiS30xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); - } - } else { - /* if not blanked obtain state of LCD blank flags set by BIOS */ - if(!pSiS->Blank) { - inSISIDXREG(SISSR, 0x11, pSiS->LCDon); - } + if(pSiS->VGAEngine == SIS_300_VGA) { - if(!xf86IsUnblank(mode)) { - pSiS->Blank = TRUE; - outSISIDXREG(SISSR, 0x11, pSiS->LCDon | 0x08); - } else { - pSiS->Blank = FALSE; - /* don't just unblanking; use LCD state set by BIOS */ - outSISIDXREG(SISSR, 0x11, pSiS->LCDon); + if(pSiS->VBFlags & (VB_301LV|VB_302LV|VB_302ELV)) { + if(!xf86IsUnblank(mode)) { + pSiS->Blank = TRUE; + SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); + } else { + pSiS->Blank = FALSE; + SiS_SiS30xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); + } + } else if(pSiS->VBFlags & (VB_LVDS | VB_30xBDH)) { + if(!pSiS->Blank) { + inSISIDXREG(SISSR, 0x11, pSiS->LCDon); + } + if(!xf86IsUnblank(mode)) { + pSiS->Blank = TRUE; + outSISIDXREG(SISSR, 0x11, pSiS->LCDon | 0x08); + } else { + pSiS->Blank = FALSE; + outSISIDXREG(SISSR, 0x11, pSiS->LCDon); + } } - } - } else if(pSiS->VGAEngine == SIS_315_VGA) { + } else if(pSiS->VGAEngine == SIS_315_VGA) { - if(!pSiS->Blank) { - inSISIDXREG(SISSR, 0x11, pSiS->LCDon); - } + if(!pSiS->Blank) { + inSISIDXREG(SISSR, 0x11, pSiS->LCDon); + } + + if(pSiS->VBFlags & VB_CHRONTEL) { + if(!xf86IsUnblank(mode)) { + pSiS->Blank = TRUE; + SiS_Chrontel701xBLOff(pSiS->SiS_Pr); + } else { + pSiS->Blank = FALSE; + SiS_Chrontel701xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); + } + } else if(pSiS->VBFlags & VB_LVDS) { + if(!xf86IsUnblank(mode)) { + pSiS->Blank = TRUE; + outSISIDXREG(SISSR, 0x11, pSiS->LCDon | 0x08); + } else { + pSiS->Blank = FALSE; + outSISIDXREG(SISSR, 0x11, pSiS->LCDon); + } + } else if(pSiS->VBFlags & (VB_301LV|VB_302LV|VB_302ELV)) { + if(!xf86IsUnblank(mode)) { + pSiS->Blank = TRUE; + SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); + } else { + pSiS->Blank = FALSE; + SiS_SiS30xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); + } + } - if(pSiS->VBFlags & VB_CHRONTEL) { - if(!xf86IsUnblank(mode)) { - pSiS->Blank = TRUE; - SiS_Chrontel701xBLOff(pSiS->SiS_Pr); - } else { - pSiS->Blank = FALSE; - SiS_Chrontel701xBLOn(pSiS->SiS_Pr); - } - } else if(pSiS->VBFlags & VB_LVDS) { - if(!xf86IsUnblank(mode)) { - pSiS->Blank = TRUE; - outSISIDXREG(SISSR, 0x11, pSiS->LCDon | 0x08); - } else { - pSiS->Blank = FALSE; - outSISIDXREG(SISSR, 0x11, pSiS->LCDon); - } - } else if(pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) { - if(!xf86IsUnblank(mode)) { - pSiS->Blank = TRUE; - SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); - } else { - pSiS->Blank = FALSE; - SiS_SiS30xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); - } } } @@ -5454,99 +8061,101 @@ SISSaveScreen(ScreenPtr pScreen, int mode) } #ifdef SISDUALHEAD -/* TW: SaveScreen for dual head mode */ +/* SaveScreen for dual head mode */ static Bool SISSaveScreenDH(ScreenPtr pScreen, int mode) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + Bool checkit = FALSE; - if ((pScrn != NULL) && pScrn->vtSema) { + if((pScrn != NULL) && pScrn->vtSema) { - SISPtr pSiS = SISPTR(pScrn); - if (pSiS->SecondHead) { + SISPtr pSiS = SISPTR(pScrn); - /* Slave head is always CRT1 */ - return vgaHWSaveScreen(pScreen, mode); + if((pSiS->SecondHead) && ((!(pSiS->VBFlags & CRT1_LCDA)) || (pSiS->VBFlags & VB_301C))) { - } else { + /* Slave head is always CRT1 */ + if(pSiS->VBFlags & CRT1_LCDA) pSiS->Blank = xf86IsUnblank(mode) ? FALSE : TRUE; + + return vgaHWSaveScreen(pScreen, mode); - /* Master head is always CRT2 */ + } else { - /* We can only blank LCD, not other CRT2 devices */ - if(!(pSiS->VBFlags & CRT2_LCD)) return TRUE; + /* Master head is always CRT2 */ + /* But we land here if CRT1 is LCDA, too */ - /* enable access to extended sequencer registers */ + /* We can only blank LCD, not other CRT2 devices */ + if(!(pSiS->VBFlags & (CRT2_LCD|CRT1_LCDA))) return TRUE; + + /* enable access to extended sequencer registers */ #ifdef UNLOCK_ALWAYS - sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); + sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - if(pSiS->VGAEngine == SIS_300_VGA) { + if(pSiS->VGAEngine == SIS_300_VGA) { - if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - if(!xf86IsUnblank(mode)) { - pSiS->BlankCRT2 = TRUE; - SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); - } else { - pSiS->BlankCRT2 = FALSE; - SiS_SiS30xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); - } + if(pSiS->VBFlags & (VB_301LV|VB_302LV|VB_302ELV)) { + checkit = TRUE; + if(!xf86IsUnblank(mode)) { + SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); } else { - /* if not blanked obtain state of LCD blank flags set by BIOS */ - if(!pSiS->BlankCRT2) { - inSISIDXREG(SISSR, 0x11, pSiS->LCDon); - } - - if (!xf86IsUnblank(mode)) { - pSiS->BlankCRT2 = TRUE; - outSISIDXREG(SISSR, 0x11, pSiS->LCDon | 0x08); - } else { - pSiS->BlankCRT2 = FALSE; - /* don't just unblank; use LCD state set by BIOS */ - outSISIDXREG(SISSR, 0x11, pSiS->LCDon); - } + SiS_SiS30xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); + } + } else if(pSiS->VBFlags & (VB_LVDS|VB_30xBDH)) { + if(!pSiS->BlankCRT2) { + inSISIDXREG(SISSR, 0x11, pSiS->LCDon); + } + checkit = TRUE; + if(!xf86IsUnblank(mode)) { + outSISIDXREG(SISSR, 0x11, pSiS->LCDon | 0x08); + } else { + outSISIDXREG(SISSR, 0x11, pSiS->LCDon); } + } - } else if(pSiS->VGAEngine == SIS_315_VGA) { + } else if(pSiS->VGAEngine == SIS_315_VGA) { - if(!pSiS->BlankCRT2) { - inSISIDXREG(SISSR, 0x11, pSiS->LCDon); - } + if(!pSiS->BlankCRT2) { + inSISIDXREG(SISSR, 0x11, pSiS->LCDon); + } - if(pSiS->VBFlags & VB_CHRONTEL) { - if(!xf86IsUnblank(mode)) { - pSiS->BlankCRT2 = TRUE; - SiS_Chrontel701xBLOff(pSiS->SiS_Pr); - } else { - pSiS->BlankCRT2 = FALSE; - SiS_Chrontel701xBLOn(pSiS->SiS_Pr); - } - } else if(pSiS->VBFlags & VB_LVDS) { - if(!xf86IsUnblank(mode)) { - pSiS->BlankCRT2 = TRUE; - outSISIDXREG(SISSR, 0x11, pSiS->LCDon | 0x08); - } else { - pSiS->BlankCRT2 = FALSE; - outSISIDXREG(SISSR, 0x11, pSiS->LCDon); - } - } else if(pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) { - if(!xf86IsUnblank(mode)) { - pSiS->BlankCRT2 = TRUE; - SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); - } else { - pSiS->BlankCRT2 = FALSE; - SiS_SiS30xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); - } + if(pSiS->VBFlags & VB_CHRONTEL) { + checkit = TRUE; + if(!xf86IsUnblank(mode)) { + SiS_Chrontel701xBLOff(pSiS->SiS_Pr); + } else { + SiS_Chrontel701xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); } + } else if(pSiS->VBFlags & VB_LVDS) { + checkit = TRUE; + if(!xf86IsUnblank(mode)) { + outSISIDXREG(SISSR, 0x11, pSiS->LCDon | 0x08); + } else { + outSISIDXREG(SISSR, 0x11, pSiS->LCDon); + } + } else if(pSiS->VBFlags & (VB_301LV|VB_302LV|VB_302ELV)) { + checkit = TRUE; + if(!xf86IsUnblank(mode)) { + SiS_SiS30xBLOff(pSiS->SiS_Pr,&pSiS->sishw_ext); + } else { + SiS_SiS30xBLOn(pSiS->SiS_Pr,&pSiS->sishw_ext); + } + } - } - } + } + + if(checkit) { + if(!pSiS->SecondHead) pSiS->BlankCRT2 = xf86IsUnblank(mode) ? FALSE : TRUE; + else if(pSiS->VBFlags & CRT1_LCDA) pSiS->Blank = xf86IsUnblank(mode) ? FALSE : TRUE; + } + + } } return TRUE; } #endif #ifdef DEBUG -/* locally used for debug */ static void SiSDumpModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode) { @@ -5569,11 +8178,9 @@ SiSDumpModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode) } #endif -/* local used for debug */ static void SISModifyModeInfo(DisplayModePtr mode) { -#if 1 if(mode->CrtcHBlankStart == mode->CrtcHDisplay) mode->CrtcHBlankStart++; if(mode->CrtcHBlankEnd == mode->CrtcHTotal) @@ -5582,10 +8189,9 @@ SISModifyModeInfo(DisplayModePtr mode) mode->CrtcVBlankStart++; if(mode->CrtcVBlankEnd == mode->CrtcVTotal) mode->CrtcVBlankEnd--; -#endif } -/* TW: Enable the TurboQueue (For 300 and 310/325 series only) */ +/* Enable the Turboqueue/Commandqueue (For 300 and 315/330 series only) */ void SiSEnableTurboQueue(ScrnInfoPtr pScrn) { @@ -5595,7 +8201,7 @@ SiSEnableTurboQueue(ScrnInfoPtr pScrn) switch (pSiS->VGAEngine) { case SIS_300_VGA: - if ((!pSiS->NoAccel) && (pSiS->TurboQueue)) { + if((!pSiS->NoAccel) && (pSiS->TurboQueue)) { /* TQ size is always 512k */ temp = (pScrn->videoRam/64) - 8; SR26 = temp & 0xFF; @@ -5606,27 +8212,19 @@ SiSEnableTurboQueue(ScrnInfoPtr pScrn) outSISIDXREG(SISSR, 0x27, SR27); } break; + case SIS_315_VGA: - if (!pSiS->NoAccel) { - /* TW: On 310/325 series, there are three queue modes available - * which are chosen by setting bits 7:5 in SR26: + if(!pSiS->NoAccel) { + /* On 315/330 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 * on. This is the one comparable to the 300 series. * 2. VRAM queue mode (bit 6, 0x40). In this case, one will - * have to do queue management himself. Register 0x85c4 will - * hold the location of the next free queue slot, 0x85c8 - * is the "queue read pointer" whose way of working is - * unknown to me. Anyway, this mode would require a - * translation of the MMIO commands to some kind of - * accelerator assembly and writing these commands - * to the memory location pointed to by 0x85c4. - * We will not use this, as nobody knows how this - * "assembly" works, and as it would require a complete - * re-write of the accelerator code. + * have to do queue management himself. * 3. AGP queue mode (bit 7, 0x80). Works as 2., but keeps the * queue in AGP memory space. - * We go MMIO here. + * We go VRAM or MMIO here. * SR26 bit 4 is called "Bypass H/W queue". * SR26 bit 1 is called "Enable Command Queue Auto Correction" * SR26 bit 0 resets the queue @@ -5637,31 +8235,71 @@ SiSEnableTurboQueue(ScrnInfoPtr pScrn) * 11 (0x0C) 4M * The queue location is to be written to 0x85C0. */ -#if 0 - if (pSiS->TurboQueue) { -#endif - /* TW: We only use MMIO Cmd Queue, not VRAM or AGP */ - /* TW: Set Command Queue Threshold to max value 11111b */ - outSISIDXREG(SISSR, 0x27, 0x1F); - /* TW: Syncronous reset for Command Queue */ - outSISIDXREG(SISSR, 0x26, 0x01); - /* TW: Do some magic (cp readport to writeport) */ - temp = MMIO_IN32(pSiS->IOBase, 0x85C8); - MMIO_OUT32(pSiS->IOBase, 0x85C4, temp); - /* TW: Enable MMIO Command Queue mode (0x20), - * Enable_command_queue_auto_correction (0x02) - * (no idea, but sounds good, so use it) - * 512k (0x00) (does this apply to MMIO mode?) */ - outSISIDXREG(SISSR, 0x26, 0x22); - /* TW: Calc Command Queue position (Q is always 512k)*/ - temp = (pScrn->videoRam - 512) * 1024; - /* TW: Set Q position */ - MMIO_OUT32(pSiS->IOBase, 0x85C0, temp); -#if 0 - } else { - /* TW: Is there a non-TurboQueue mode within MMIO mode? */ +#ifdef SISVRAMQ + /* We use VRAM Cmd Queue, not MMIO or AGP */ + unsigned char tempCR55; + +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + SISEntPtr pSiSEnt = pSiS->entityPrivate; + pSiS->cmdQ_SharedWritePort = &(pSiSEnt->cmdQ_SharedWritePort_2D); + } else +#endif + pSiS->cmdQ_SharedWritePort = &(pSiS->cmdQ_SharedWritePort_2D); + + /* Set Command Queue Threshold to max value 11111b (?) */ + outSISIDXREG(SISSR, 0x27, 0x1F); + /* No idea what this does */ + inSISIDXREG(SISCR, 0x55, tempCR55) ; + andSISIDXREG(SISCR, 0x55, 0x33) ; + /* Syncronous reset for Command Queue */ + outSISIDXREG(SISSR, 0x26, 0x01); + MMIO_OUT32(pSiS->IOBase, 0x85c4, 0); + /* Enable VRAM Command Queue mode */ + switch(pSiS->cmdQueueSize) { + case 1*1024*1024: SR26 = (0x40 | 0x04 | 0x01); break; + case 2*1024*1024: SR26 = (0x40 | 0x08 | 0x01); break; + case 4*1024*1024: SR26 = (0x40 | 0x0C | 0x01); break; + default: + pSiS->cmdQueueSize = 512 * 1024; + case 512*1024: SR26 = (0x40 | 0x00 | 0x01); + } + outSISIDXREG(SISSR, 0x26, SR26); + SR26 &= 0xfe; + outSISIDXREG(SISSR, 0x26, SR26); + pSiS->cmdQ_SharedWritePort_2D = (unsigned long)(MMIO_IN32(pSiS->IOBase, 0x85c8)); + *(pSiS->cmdQ_SharedWritePort) = pSiS->cmdQ_SharedWritePort_2D; + MMIO_OUT32(pSiS->IOBase, 0x85c4, pSiS->cmdQ_SharedWritePort_2D); + MMIO_OUT32(pSiS->IOBase, 0x85C0, pSiS->cmdQueueOffset); + temp = (unsigned long)pSiS->FbBase; +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + SISEntPtr pSiSEnt = pSiS->entityPrivate; + temp = (unsigned long)pSiSEnt->FbBase; } #endif + temp += pSiS->cmdQueueOffset; + pSiS->cmdQueueBase = (unsigned long *)temp; + outSISIDXREG(SISCR, 0x55, tempCR55); +#else + /* For MMIO */ + /* Set Command Queue Threshold to max value 11111b */ + outSISIDXREG(SISSR, 0x27, 0x1F); + /* Syncronous reset for Command Queue */ + outSISIDXREG(SISSR, 0x26, 0x01); + /* Do some magic (cp readport to writeport) */ + temp = MMIO_IN32(pSiS->IOBase, 0x85C8); + MMIO_OUT32(pSiS->IOBase, 0x85C4, temp); + /* Enable MMIO Command Queue mode (0x20), + * Enable_command_queue_auto_correction (0x02) + * (no idea, but sounds good, so use it) + * 512k (0x00) (does this apply to MMIO mode?) */ + outSISIDXREG(SISSR, 0x26, 0x22); + /* Calc Command Queue position (Q is always 512k)*/ + temp = (pScrn->videoRam - 512) * 1024; + /* Set Q position */ + MMIO_OUT32(pSiS->IOBase, 0x85C0, temp); +#endif } break; default: @@ -5669,194 +8307,422 @@ SiSEnableTurboQueue(ScrnInfoPtr pScrn) } } -/* TW: Things to do before a ModeSwitch. We set up the - * video bridge configuration and the TurboQueue. +/* Things to do before a ModeSwitch. We set up the + * video bridge configuration and the TurboQueue. */ -void SiSPreSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode) +void SiSPreSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int viewmode) { SISPtr pSiS = SISPTR(pScrn); - unsigned char usScratchCR30, usScratchCR31; - unsigned char usScratchCR32, usScratchCR33; - unsigned char usScratchCR17, usScratchCR38 = 0; - int vbflag, temp = 0; + unsigned char CR30, CR31; + unsigned char CR32, CR33; + unsigned char CR17, CR38 = 0; + unsigned char CR35 = 0, CR79 = 0; + unsigned long vbflag; + int temp = 0, i; int crt1rateindex = 0; + DisplayModePtr mymode; +#ifdef SISMERGED + DisplayModePtr mymode2 = NULL; +#endif -#ifdef UNLOCK_ALWAYS - sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); /* Unlock Registers */ +#ifdef SISMERGED + if(pSiS->MergedFB) { + mymode = ((SiSMergedDisplayModePtr)mode->Private)->CRT1; + mymode2 = ((SiSMergedDisplayModePtr)mode->Private)->CRT2; + } else #endif + mymode = mode; vbflag = pSiS->VBFlags; pSiS->IsCustom = FALSE; - - if(pSiS->HaveCustomModes) { - if(!(mode->type & M_T_DEFAULT)) { - pSiS->IsCustom = TRUE; +#ifdef SISMERGED + pSiS->IsCustomCRT2 = FALSE; + + if(pSiS->MergedFB) { + /* CRT2 */ + if(vbflag & CRT2_LCD) { + if(pSiS->SiS_Pr->CP_HaveCustomData) { + for(i=0; i<7; i++) { + if(pSiS->SiS_Pr->CP_DataValid[i]) { + if((mymode2->HDisplay == pSiS->SiS_Pr->CP_HDisplay[i]) && + (mymode2->VDisplay == pSiS->SiS_Pr->CP_VDisplay[i])) { + if(mymode2->type & M_T_BUILTIN) { + pSiS->IsCustomCRT2 = TRUE; + } + } + } + } + } + } + if(vbflag & (CRT2_VGA|CRT2_LCD)) { + if(pSiS->AddedPlasmaModes) { + if(mymode2->type & M_T_BUILTIN) { + pSiS->IsCustomCRT2 = TRUE; + } + } + if(pSiS->HaveCustomModes2) { + if(!(mymode2->type & M_T_DEFAULT)) { + pSiS->IsCustomCRT2 = TRUE; + } + } + } + /* CRT1 */ + if(pSiS->HaveCustomModes) { + if(!(mymode->type & M_T_DEFAULT)) { + pSiS->IsCustom = TRUE; + } + } + } else +#endif +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + if(!pSiS->SecondHead) { + /* CRT2 */ + if(vbflag & CRT2_LCD) { + if(pSiS->SiS_Pr->CP_HaveCustomData) { + for(i=0; i<7; i++) { + if(pSiS->SiS_Pr->CP_DataValid[i]) { + if((mymode->HDisplay == pSiS->SiS_Pr->CP_HDisplay[i]) && + (mymode->VDisplay == pSiS->SiS_Pr->CP_VDisplay[i])) { + if(mymode->type & M_T_BUILTIN) { + pSiS->IsCustom = TRUE; + } + } + } + } + } + } + if(vbflag & (CRT2_VGA|CRT2_LCD)) { + if(pSiS->AddedPlasmaModes) { + if(mymode->type & M_T_BUILTIN) { + pSiS->IsCustom = TRUE; + } + } + if(pSiS->HaveCustomModes) { + if(!(mymode->type & M_T_DEFAULT)) { + pSiS->IsCustom = TRUE; + } + } + } + } else { + /* CRT1 */ + if(pSiS->HaveCustomModes) { + if(!(mymode->type & M_T_DEFAULT)) { + pSiS->IsCustom = TRUE; + } + } + } + } else +#endif + { + if(vbflag & CRT2_LCD) { + if(pSiS->SiS_Pr->CP_HaveCustomData) { + for(i=0; i<7; i++) { + if(pSiS->SiS_Pr->CP_DataValid[i]) { + if((mymode->HDisplay == pSiS->SiS_Pr->CP_HDisplay[i]) && + (mymode->VDisplay == pSiS->SiS_Pr->CP_VDisplay[i])) { + if(mymode->type & M_T_BUILTIN) { + pSiS->IsCustom = TRUE; + } + } + } + } + } + } + if(vbflag & (CRT2_LCD|CRT2_VGA)) { + if(pSiS->AddedPlasmaModes) { + if(mymode->type & M_T_BUILTIN) { + pSiS->IsCustom = TRUE; + } + } + } + if((pSiS->HaveCustomModes) && (!(vbflag & CRT2_TV))) { + if(!(mymode->type & M_T_DEFAULT)) { + pSiS->IsCustom = TRUE; + } } } - /* TW: The CR3x registers are for communicating with our BIOS emulation - * code (native code in init.c/init301.c) or the BIOS (via VESA) - */ - inSISIDXREG(SISCR, 0x30, usScratchCR30); /* Bridge config */ - inSISIDXREG(SISCR, 0x31, usScratchCR31); /* Bridge config */ - usScratchCR32 = pSiS->newCR32; /* Bridge connection info (use our new value) */ - inSISIDXREG(SISCR, 0x33, usScratchCR33); /* CRT1 refresh rate index */ - if(pSiS->Chipset != PCI_CHIP_SIS300) { - switch(pSiS->VGAEngine) { - case SIS_300_VGA: temp = 0x35; break; - case SIS_315_VGA: temp = 0x38; break; +#ifdef UNLOCK_ALWAYS + sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); /* Unlock Registers */ +#endif + + if(pSiS->Chipset == PCI_CHIP_SIS660) { + + inSISIDXREG(SISCR, 0x30, CR30); + inSISIDXREG(SISCR, 0x31, CR31); + CR32 = pSiS->newCR32; + inSISIDXREG(SISCR, 0x33, CR33); + inSISIDXREG(SISCR, 0x35, CR35); + inSISIDXREG(SISCR, 0x38, CR38); + xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED, 4, + "Before: CR30=0x%02x,CR31=0x%02x,CR32=0x%02x,CR33=0x%02x,CR35=0x%02x,CR38=0x%02x\n", + CR30, CR31, CR32, CR33, CR35, CR38); + CR38 &= ~0x03; + + } else { + + inSISIDXREG(SISCR, 0x30, CR30); + inSISIDXREG(SISCR, 0x31, CR31); + CR32 = pSiS->newCR32; + inSISIDXREG(SISCR, 0x33, CR33); + 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) inSISIDXREG(SISCR, temp, CR38); + } + if(pSiS->VGAEngine == SIS_315_VGA) { + inSISIDXREG(SISCR, 0x79, CR79); + CR38 &= ~0x03; /* Clear LCDA/DualEdge bits */ } + xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED, 4, + "Before: CR30=0x%02x, CR31=0x%02x, CR32=0x%02x, CR33=0x%02x, CR%02x=0x%02x\n", + CR30, CR31, CR32, CR33, temp, CR38); } - if(temp) inSISIDXREG(SISCR, temp, usScratchCR38); /* PAL-M, PAL-N selection */ - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "VBFlags=0x%x\n", pSiS->VBFlags); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, "VBFlags=0x%lx\n", pSiS->VBFlags); - xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED, 3, - "Before: CR30=0x%02x, CR31=0x%02x, CR32=0x%02x, CR33=0x%02x, CR%02x=0x%02x\n", - usScratchCR30, usScratchCR31, usScratchCR32, usScratchCR33, temp, usScratchCR38); + CR30 = 0x00; + CR31 &= ~0x60; /* Clear VB_Drivermode & VB_OutputDisable */ + CR31 |= 0x04; /* Set VB_NotSimuMode (not for 30xB/1400x1050?) */ + CR35 = 0x00; - usScratchCR30 = 0; - usScratchCR31 &= ~0x60; /* TW: Clear VB_Drivermode & VB_OutputDisable */ -#if 0 /* TW: For future use */ - if( (pSiS->VBFlags & VB_LVDS) || - (pSiS->VBFlags & VB_301) || - ( (pSiS->VBFlags & (VB_301B | VB_302B |VB_30xLV | VB_30xLVX)) && - (!(pSiS->VBLCDFlags & VB_LCD_1400x1050)) ) ) { -#endif - usScratchCR31 |= 0x04; /* TW: Set VB_NotSimuMode (not for 30xB/1400x1050?) */ -#if 0 + if(pSiS->Chipset != PCI_CHIP_SIS660) { + if(!pSiS->AllowHotkey) { + CR31 |= 0x80; /* Disable hotkey-switch */ + } + CR79 &= ~0x10; /* Enable Backlight control on 315 series */ } + + SiS_SetEnableDstn(pSiS->SiS_Pr, FALSE); + SiS_SetEnableFstn(pSiS->SiS_Pr, FALSE); + + if((vbflag & CRT1_LCDA) && (viewmode == SIS_MODE_CRT1)) { + + CR38 |= 0x02; + + } else { + + switch(vbflag & (CRT2_TV|CRT2_LCD|CRT2_VGA)) { + + case CRT2_TV: + + CR38 &= ~0xC0; + + if(vbflag & TV_CHSCART) { + CR30 |= 0x10; + CR38 |= 0x04; + CR31 |= 0x01; + } else if(vbflag & TV_CHHDTV) { + CR38 |= 0x08; + CR31 &= ~0x01; + } else if(vbflag & TV_HIVISION) + CR30 |= 0x80; + else if(vbflag & TV_SCART) + CR30 |= 0x10; + else { + if(vbflag & TV_SVIDEO) CR30 |= 0x08; + if(vbflag & TV_AVIDEO) CR30 |= 0x04; + if(!(CR30 & 0x0c)) CR30 |= 0x08; /* default: SVIDEO */ + } + + if(!(vbflag & (TV_CHSCART | TV_CHHDTV))) { + if(vbflag & TV_PAL) { + CR31 |= 0x01; + CR35 |= 0x01; + if( (vbflag & VB_SISBRIDGE) || + ((vbflag & VB_CHRONTEL) && (pSiS->ChrontelType == CHRONTEL_701x)) ) { + if(vbflag & TV_PALM) { + CR38 |= 0x40; + CR35 |= 0x04; + } else if(vbflag & TV_PALN) { + CR38 |= 0x80; + CR35 |= 0x08; + } + } + } else { + CR31 &= ~0x01; + CR35 &= ~0x01; + if(vbflag & TV_NTSCJ) { + CR38 |= 0x40; /* TW, not BIOS */ + CR35 |= 0x02; + } + } + } + + CR31 &= ~0x04; /* Clear NotSimuMode */ + pSiS->SiS_Pr->SiS_CHOverScan = pSiS->UseCHOverScan; + if((pSiS->OptTVSOver == 1) && (pSiS->ChrontelType == CHRONTEL_700x)) { + pSiS->SiS_Pr->SiS_CHSOverScan = TRUE; + } else { + pSiS->SiS_Pr->SiS_CHSOverScan = FALSE; + } +#ifdef SIS_CP + SIS_CP_DRIVER_CONFIG #endif + break; - switch(vbflag & (CRT2_TV|CRT2_LCD|CRT2_VGA)) { - case CRT2_TV: - if(vbflag & TV_CHSCART) { - usScratchCR38 |= 0x04; - usScratchCR31 |= 0x01; - } else if(vbflag & TV_CHHDTV) { - usScratchCR38 |= 0x08; - usScratchCR31 &= ~0x01; - } else if(vbflag & TV_HIVISION) - usScratchCR30 |= 0x80; - else if(vbflag & TV_SVIDEO) - usScratchCR30 |= 0x08; - else if(vbflag & TV_AVIDEO) - usScratchCR30 |= 0x04; - else if(vbflag & TV_SCART) - usScratchCR30 |= 0x10; - else - usScratchCR30 |= 0x08; /* default: SVIDEO */ - - if(!(vbflag & (TV_CHSCART | TV_CHHDTV))) { - if(vbflag & TV_PAL) { - usScratchCR31 |= 0x01; - usScratchCR38 &= ~0xC0; - if( (vbflag & VB_SISBRIDGE) || - ((vbflag & VB_CHRONTEL) && (pSiS->ChrontelType == CHRONTEL_701x)) ) { - if(vbflag & TV_PALM) usScratchCR38 |= 0x40; - else if(vbflag & TV_PALN) usScratchCR38 |= 0x80; - } - } else - usScratchCR31 &= ~0x01; - } + case CRT2_LCD: + CR30 |= 0x20; + SiS_SetEnableDstn(pSiS->SiS_Pr, pSiS->DSTN); + SiS_SetEnableFstn(pSiS->SiS_Pr, pSiS->FSTN); + break; - usScratchCR30 |= 0x01; /* Set SimuScanMode */ + case CRT2_VGA: + CR30 |= 0x40; + break; - usScratchCR31 &= ~0x04; /* Clear NotSimuMode */ - pSiS->SiS_Pr->SiS_CHOverScan = pSiS->UseCHOverScan; - if(pSiS->OptTVSOver == 1) { - pSiS->SiS_Pr->SiS_CHSOverScan = TRUE; - } else { - pSiS->SiS_Pr->SiS_CHSOverScan = FALSE; - } - break; - case CRT2_LCD: - usScratchCR30 |= 0x21; /* LCD + SimuScanMode */ - break; - case CRT2_VGA: - usScratchCR30 |= 0x41; /* VGA2 + SimuScanMode */ - break; - default: - usScratchCR30 |= 0x00; - usScratchCR31 |= 0x20; /* VB_OUTPUT_DISABLE */ - if(pSiS->UseVESA) { - crt1rateindex = SISSearchCRT1Rate(pScrn, mode); - } + default: + CR30 |= 0x00; + CR31 |= 0x20; /* VB_OUTPUT_DISABLE */ + if(pSiS->UseVESA) { + crt1rateindex = SISSearchCRT1Rate(pScrn, mymode); + } + } + + } + + if(vbflag & CRT1_LCDA) { + switch(viewmode) { + case SIS_MODE_CRT1: + CR38 |= 0x01; + break; + case SIS_MODE_CRT2: + if(vbflag & (CRT2_TV|CRT2_VGA)) { + CR30 |= 0x02; + CR38 |= 0x01; + } else { + CR38 |= 0x03; + } + break; + case SIS_MODE_SIMU: + default: + if(vbflag & (CRT2_TV|CRT2_LCD|CRT2_VGA)) { + CR30 |= 0x01; + } + break; + } + } else { + if(vbflag & (CRT2_TV|CRT2_LCD|CRT2_VGA)) { + CR30 |= 0x01; + } } - /* TW: for VESA: no DRIVERMODE, otherwise + + /* for VESA: no DRIVERMODE, otherwise * -) CRT2 will not be initialized correctly when using mode * where LCD has to scale, and * -) CRT1 will have too low rate */ - if (pSiS->UseVESA) { - usScratchCR31 &= 0x40; /* TW: Clear Drivermode */ + if(pSiS->UseVESA) { + CR31 &= ~0x40; /* Clear Drivermode */ + CR31 |= 0x06; /* Set SlaveMode, Enable SimuMode in Slavemode */ #ifdef TWDEBUG - usScratchCR31 |= 0x40; /* DEBUG (for non-slave mode VESA) */ - crt1rateindex = SISSearchCRT1Rate(pScrn, mode); + CR31 |= 0x40; /* DEBUG (for non-slave mode VESA) */ + crt1rateindex = SISSearchCRT1Rate(pScrn, mymode); #endif } else { - usScratchCR31 |= 0x40; /* TW: Set Drivermode */ + CR31 |= 0x40; /* Set Drivermode */ + CR31 &= ~0x06; /* Disable SlaveMode, disable SimuMode in SlaveMode */ if(!pSiS->IsCustom) { - crt1rateindex = SISSearchCRT1Rate(pScrn, mode); + crt1rateindex = SISSearchCRT1Rate(pScrn, mymode); } else { - crt1rateindex = usScratchCR33; + crt1rateindex = CR33; } } - outSISIDXREG(SISCR, 0x30, usScratchCR30); - outSISIDXREG(SISCR, 0x31, usScratchCR31); - if(temp) { - usScratchCR38 &= ~0x03; /* Clear LCDA/DualEdge bits */ - outSISIDXREG(SISCR, temp, usScratchCR38); - } - - pSiS->SiS_Pr->SiS_UseOEM = pSiS->OptUseOEM; #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { if(pSiS->SecondHead) { /* CRT1 */ - usScratchCR33 &= 0xf0; - usScratchCR33 |= (crt1rateindex & 0x0f); + CR33 &= 0xf0; + if(!(vbflag & CRT1_LCDA)) { + CR33 |= (crt1rateindex & 0x0f); + } } else { /* CRT2 */ - usScratchCR33 &= 0x0f; - if(vbflag & CRT2_VGA) usScratchCR33 |= ((crt1rateindex << 4) & 0xf0); + CR33 &= 0x0f; + if(vbflag & CRT2_VGA) { + CR33 |= ((crt1rateindex << 4) & 0xf0); + } } - } else { + } else #endif +#ifdef SISMERGED + if(pSiS->MergedFB) { + CR33 = 0; + if(!(vbflag & CRT1_LCDA)) { + CR33 |= (crt1rateindex & 0x0f); + } if(vbflag & CRT2_VGA) { - usScratchCR33 = (crt1rateindex & 0x0f) | ((crt1rateindex & 0x0f) << 4); - } else { - usScratchCR33 = crt1rateindex & 0x0f; + if(!pSiS->IsCustomCRT2) { + CR33 |= (SISSearchCRT1Rate(pScrn, mymode2) << 4); + } + } + } else +#endif + { + CR33 = 0; + if(!(vbflag & CRT1_LCDA)) { + CR33 |= (crt1rateindex & 0x0f); + } + if(vbflag & CRT2_VGA) { + CR33 |= ((crt1rateindex & 0x0f) << 4); } if((!(pSiS->UseVESA)) && (vbflag & CRT2_ENABLE)) { -#ifndef TWDEBUG - if(pSiS->CRT1off) usScratchCR33 &= 0xf0; -#endif + if(pSiS->CRT1off) CR33 &= 0xf0; } -#ifdef SISDUALHEAD } -#endif - outSISIDXREG(SISCR, 0x33, usScratchCR33); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "After: CR30=0x%02x, CR31=0x%02x, CR33=0x%02x\n", - usScratchCR30, usScratchCR31, usScratchCR33); + if(pSiS->Chipset == PCI_CHIP_SIS660) { + + CR31 &= 0xfe; /* Clear PAL flag (now in CR35) */ + CR38 &= 0x03; /* Use only LCDA bits */ + outSISIDXREG(SISCR, 0x30, CR30); + outSISIDXREG(SISCR, 0x31, CR31); + outSISIDXREG(SISCR, 0x33, CR33); + outSISIDXREG(SISCR, 0x35, CR35); + setSISIDXREG(SISCR, 0x38, 0xfc, CR38); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + "After: CR30=0x%02x,CR31=0x%02x,CR33=0x%02x,CR35=0x%02x,CR38=%02x\n", + CR30, CR31, CR33, CR35, CR38); + + } else { + + outSISIDXREG(SISCR, 0x30, CR30); + outSISIDXREG(SISCR, 0x31, CR31); + outSISIDXREG(SISCR, 0x33, CR33); + if(temp) { + outSISIDXREG(SISCR, temp, CR38); + } + if(pSiS->VGAEngine == SIS_315_VGA) { + outSISIDXREG(SISCR, 0x79, CR79); + } + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + "After: CR30=0x%02x,CR31=0x%02x,CR33=0x%02x,CR%02x=%02x\n", + CR30, CR31, CR33, temp, CR38); + } + + pSiS->SiS_Pr->SiS_UseOEM = pSiS->OptUseOEM; /* Enable TurboQueue */ - SiSEnableTurboQueue(pScrn); +#ifdef SISVRAMQ + if(pSiS->VGAEngine != SIS_315_VGA) +#endif + SiSEnableTurboQueue(pScrn); if((!pSiS->UseVESA) && (pSiS->VBFlags & CRT2_ENABLE)) { /* Switch on CRT1 for modes that require the bridge in SlaveMode */ - inSISIDXREG(SISCR, 0x17, usScratchCR17); - if(!(usScratchCR17 & 0x80)) { - orSISIDXREG(SISCR, 0x17, 0x80); - outSISIDXREG(SISSR, 0x00, 0x01); - usleep(10000); - outSISIDXREG(SISSR, 0x00, 0x03); + andSISIDXREG(SISSR,0x1f,0x3f); + inSISIDXREG(SISCR, 0x17, CR17); + if(!(CR17 & 0x80)) { + orSISIDXREG(SISCR, 0x17, 0x80); + outSISIDXREG(SISSR, 0x00, 0x01); + usleep(10000); + outSISIDXREG(SISSR, 0x00, 0x03); } } - } /* Functions for adjusting various TV settings */ @@ -6041,7 +8907,10 @@ void SiS_SetCHTVlumaflickerfilter(ScrnInfoPtr pScrn, int val) case CHRONTEL_700x: val /= 6; if((val >= 0) && (val <= 2)) { - SiS_SetCH70xxANDOR(pSiS->SiS_Pr, ((val << 10) | 0x01),0xF3); + unsigned short reg = 0; + reg = SiS_GetCH70xx(pSiS->SiS_Pr, 0x01); + reg = (reg & 0xf0) | ((reg & 0x0c) >> 2) | (val << 2); + SiS_SetCH70xx(pSiS->SiS_Pr, ((reg << 8) | 0x01)); } break; case CHRONTEL_701x: @@ -6073,7 +8942,7 @@ int SiS_GetCHTVlumaflickerfilter(ScrnInfoPtr pScrn) #endif switch(pSiS->ChrontelType) { case CHRONTEL_700x: - return(int)(((SiS_GetCH70xx(pSiS->SiS_Pr, 0x01) & 0x0c) >> 2) * 6); + return(int)((SiS_GetCH70xx(pSiS->SiS_Pr, 0x01) & 0x03) * 6); case CHRONTEL_701x: return(int)(((SiS_GetCH70xx(pSiS->SiS_Pr, 0x01) & 0x0c) >> 2) * 4); default: @@ -6169,7 +9038,10 @@ void SiS_SetCHTVchromaflickerfilter(ScrnInfoPtr pScrn, int val) case CHRONTEL_700x: val /= 6; if((val >= 0) && (val <= 2)) { - SiS_SetCH70xxANDOR(pSiS->SiS_Pr, ((val << 12) | 0x01),0xCF); + unsigned short reg = 0; + reg = SiS_GetCH70xx(pSiS->SiS_Pr, 0x01); + reg = (reg & 0xc0) | ((reg & 0x0c) >> 2) | ((reg & 0x03) << 2) | (val << 4); + SiS_SetCH70xx(pSiS->SiS_Pr, ((reg << 8) | 0x01)); } break; case CHRONTEL_701x: @@ -6221,14 +9093,14 @@ void SiS_SetCHTVcvbscolor(ScrnInfoPtr pScrn, int val) #ifdef SISDUALHEAD if(pSiSEnt) pSiSEnt->chtvcvbscolor = pSiS->chtvcvbscolor; #endif - + if(!(pSiS->VBFlags & CRT2_TV)) return; if(!(pSiS->VBFlags & VB_CHRONTEL)) return; - + #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - + switch(pSiS->ChrontelType) { case CHRONTEL_700x: if(!val) SiS_SetCH70xxANDOR(pSiS->SiS_Pr, 0x4003,0x00); @@ -6238,7 +9110,7 @@ void SiS_SetCHTVcvbscolor(ScrnInfoPtr pScrn, int val) if(!val) SiS_SetCH70xxANDOR(pSiS->SiS_Pr, 0x0002,~0x20); else SiS_SetCH70xxANDOR(pSiS->SiS_Pr, 0x2002,0x00); break; - } + } } int SiS_GetCHTVcvbscolor(ScrnInfoPtr pScrn) @@ -6249,8 +9121,8 @@ int SiS_GetCHTVcvbscolor(ScrnInfoPtr pScrn) #endif if(!(pSiS->VBFlags & VB_CHRONTEL && pSiS->VBFlags & CRT2_TV)) { -#ifdef SISDUALHEAD - if(pSiSEnt && pSiS->DualHeadMode) +#ifdef SISDUALHEAD + if(pSiSEnt && pSiS->DualHeadMode) return (int)pSiSEnt->chtvcvbscolor; else #endif @@ -6265,9 +9137,9 @@ int SiS_GetCHTVcvbscolor(ScrnInfoPtr pScrn) case CHRONTEL_701x: return(int)(((SiS_GetCH70xx(pSiS->SiS_Pr, 0x02) & 0x20) >> 5) ^ 0x01); default: - return -2; + return -2; } - } + } } void SiS_SetCHTVtextenhance(ScrnInfoPtr pScrn, int val) @@ -6281,10 +9153,10 @@ void SiS_SetCHTVtextenhance(ScrnInfoPtr pScrn, int val) #ifdef SISDUALHEAD if(pSiSEnt) pSiSEnt->chtvtextenhance = val; #endif - + if(!(pSiS->VBFlags & CRT2_TV)) return; if(!(pSiS->VBFlags & VB_CHRONTEL)) return; - + #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif @@ -6293,7 +9165,10 @@ void SiS_SetCHTVtextenhance(ScrnInfoPtr pScrn, int val) case CHRONTEL_700x: val /= 6; if((val >= 0) && (val <= 2)) { - SiS_SetCH70xxANDOR(pSiS->SiS_Pr, ((val << 8) | 0x01),0xFC); + unsigned short reg = 0; + reg = SiS_GetCH70xx(pSiS->SiS_Pr, 0x01); + reg = (reg & 0xf0) | ((reg & 0x03) << 2) | val; + SiS_SetCH70xx(pSiS->SiS_Pr, ((reg << 8) | 0x01)); } break; case CHRONTEL_701x: @@ -6302,7 +9177,7 @@ void SiS_SetCHTVtextenhance(ScrnInfoPtr pScrn, int val) SiS_SetCH70xxANDOR(pSiS->SiS_Pr, ((val << 8) | 0x03),0xF8); } break; - } + } } int SiS_GetCHTVtextenhance(ScrnInfoPtr pScrn) @@ -6325,11 +9200,11 @@ int SiS_GetCHTVtextenhance(ScrnInfoPtr pScrn) #endif switch(pSiS->ChrontelType) { case CHRONTEL_700x: - return(int)((SiS_GetCH70xx(pSiS->SiS_Pr, 0x01) & 0x03) * 6); + return(int)(((SiS_GetCH70xx(pSiS->SiS_Pr, 0x01) & 0x0c) >> 2) * 6); case CHRONTEL_701x: return(int)((SiS_GetCH70xx(pSiS->SiS_Pr, 0x03) & 0x07) * 2); default: - return -2; + return -2; } } } @@ -6362,8 +9237,9 @@ void SiS_SetCHTVcontrast(ScrnInfoPtr pScrn, int val) case CHRONTEL_701x: SiS_SetCH70xxANDOR(pSiS->SiS_Pr, ((val << 8) | 0x08),0xF8); break; - } - } + } + SiS_DDC2Delay(pSiS->SiS_Pr, 1000); + } } int SiS_GetCHTVcontrast(ScrnInfoPtr pScrn) @@ -6463,8 +9339,8 @@ void SiS_SetSISTVantiflicker(ScrnInfoPtr pScrn, int val) sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - val /= 2; - if((val >= 0) && (val <= 7)) { + /* Valid values: 0=off, 1=low, 2=med, 3=high, 4=adaptive */ + if((val >= 0) && (val <= 4)) { setSISIDXREG(SISPART2,0x0A,0x8F, (val << 4)); } } @@ -6482,14 +9358,14 @@ int SiS_GetSISTVantiflicker(ScrnInfoPtr pScrn) return (int)pSiSEnt->sistvantiflicker; else #endif - return (int)pSiS->sistvantiflicker; + return (int)pSiS->sistvantiflicker; } else { unsigned char temp; #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif inSISIDXREG(SISPART2, 0x0a, temp); - return(int)(((temp & 0x70) >> 4) * 2); + return(int)((temp & 0x70) >> 4); } } @@ -6507,7 +9383,8 @@ void SiS_SetSISTVsaturation(ScrnInfoPtr pScrn, int val) if(!(pSiS->VBFlags & CRT2_TV)) return; if(!(pSiS->VBFlags & VB_SISBRIDGE)) return; - + if(pSiS->VBFlags & VB_301) return; + #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif @@ -6524,33 +9401,305 @@ int SiS_GetSISTVsaturation(ScrnInfoPtr pScrn) #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; #endif - - if(!(pSiS->VBFlags & VB_SISBRIDGE && pSiS->VBFlags & CRT2_TV)) { -#ifdef SISDUALHEAD - if(pSiSEnt && pSiS->DualHeadMode) + + if(!(pSiS->VBFlags & VB_SISBRIDGE && + (!(pSiS->VBFlags & VB_301)) && + pSiS->VBFlags & CRT2_TV)) { +#ifdef SISDUALHEAD + if(pSiSEnt && pSiS->DualHeadMode) return (int)pSiSEnt->sistvsaturation; else -#endif +#endif return (int)pSiS->sistvsaturation; } else { unsigned char temp; #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); -#endif +#endif inSISIDXREG(SISPART4, 0x21, temp); return(int)((temp & 0x07) * 2); } } +void SiS_SetSISTVcolcalib(ScrnInfoPtr pScrn, int val, Bool coarse) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; +#endif + int ccoarse, cfine, cbase = pSiS->sistvccbase; + unsigned char temp; + +#ifdef SISDUALHEAD + if(pSiSEnt) cbase = pSiSEnt->sistvccbase; +#endif + + if(coarse) { + pSiS->sistvcolcalibc = ccoarse = val; + cfine = pSiS->sistvcolcalibf; +#ifdef SISDUALHEAD + if(pSiSEnt) { + pSiSEnt->sistvcolcalibc = val; + cfine = pSiSEnt->sistvcolcalibf; + } +#endif + } else { + pSiS->sistvcolcalibf = cfine = val; + ccoarse = pSiS->sistvcolcalibc; +#ifdef SISDUALHEAD + if(pSiSEnt) { + pSiSEnt->sistvcolcalibf = val; + ccoarse = pSiSEnt->sistvcolcalibc; + } +#endif + } + + if(!(pSiS->VBFlags & CRT2_TV)) return; + if(!(pSiS->VBFlags & VB_SISBRIDGE)) return; + +#ifdef UNLOCK_ALWAYS + sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); +#endif + + if((cfine >= -128) && (cfine <= 127) && (ccoarse >= -120) && (ccoarse <= 120)) { + long finalcc = cbase + (((ccoarse * 256) + cfine) * 256); + + inSISIDXREG(SISPART4,0x1f,temp); + if(!(temp & 0x01)) { +#if 0 + if(pSiS->VBFlags & TV_NTSC) finalcc += 0x21ed8620; + else if(pSiS->VBFlags & TV_PALM) finalcc += ?; + else if(pSiS->VBFlags & TV_PALM) finalcc += ?; + else finalcc += 0x2a05d300; +#endif + } + setSISIDXREG(SISPART2,0x31,0x80,((finalcc >> 24) & 0x7f)); + outSISIDXREG(SISPART2,0x32,((finalcc >> 16) & 0xff)); + outSISIDXREG(SISPART2,0x33,((finalcc >> 8) & 0xff)); + outSISIDXREG(SISPART2,0x34,(finalcc & 0xff)); + } +} + +int SiS_GetSISTVcolcalib(ScrnInfoPtr pScrn, Bool coarse) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; + + if(pSiSEnt && pSiS->DualHeadMode) + if(coarse) + return (int)pSiSEnt->sistvcolcalibc; + else + return (int)pSiSEnt->sistvcolcalibf; + else +#endif + if(coarse) + return (int)pSiS->sistvcolcalibc; + else + return (int)pSiS->sistvcolcalibf; +} + +void SiS_SetSISTVcfilter(ScrnInfoPtr pScrn, int val) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; +#endif + + pSiS->sistvcfilter = val ? 1 : 0; +#ifdef SISDUALHEAD + if(pSiSEnt) pSiSEnt->sistvcfilter = pSiS->sistvcfilter; +#endif + + if(!(pSiS->VBFlags & CRT2_TV)) return; + if(!(pSiS->VBFlags & VB_SISBRIDGE)) return; + +#ifdef UNLOCK_ALWAYS + sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); +#endif + + setSISIDXREG(SISPART2,0x30,~0x10,((pSiS->sistvcfilter << 4) & 0x10)); +} + +int SiS_GetSISTVcfilter(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; +#endif + + if(!(pSiS->VBFlags & VB_SISBRIDGE && pSiS->VBFlags & CRT2_TV)) { +#ifdef SISDUALHEAD + if(pSiSEnt && pSiS->DualHeadMode) + return (int)pSiSEnt->sistvcfilter; + else +#endif + return (int)pSiS->sistvcfilter; + } else { + unsigned char temp; +#ifdef UNLOCK_ALWAYS + sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); +#endif + inSISIDXREG(SISPART2, 0x30, temp); + return(int)((temp & 0x10) ? 1 : 0); + } +} + +void SiS_SetSISTVyfilter(ScrnInfoPtr pScrn, int val) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; +#endif + unsigned char p35,p36,p37,p38,p48,p49,p4a,p30; + int i,j; + + pSiS->sistvyfilter = val; +#ifdef SISDUALHEAD + if(pSiSEnt) pSiSEnt->sistvyfilter = pSiS->sistvyfilter; +#endif + + if(!(pSiS->VBFlags & CRT2_TV)) return; + if(!(pSiS->VBFlags & VB_SISBRIDGE)) return; + + p35 = pSiS->p2_35; p36 = pSiS->p2_36; + p37 = pSiS->p2_37; p38 = pSiS->p2_38; + p48 = pSiS->p2_48; p49 = pSiS->p2_49; + p4a = pSiS->p2_4a; p30 = pSiS->p2_30; +#ifdef SISDUALHEAD + if(pSiSEnt) { + p35 = pSiSEnt->p2_35; p36 = pSiSEnt->p2_36; + p37 = pSiSEnt->p2_37; p38 = pSiSEnt->p2_38; + p48 = pSiSEnt->p2_48; p49 = pSiSEnt->p2_49; + p4a = pSiSEnt->p2_4a; p30 = pSiSEnt->p2_30; + } +#endif + p30 &= 0x20; + +#ifdef UNLOCK_ALWAYS + sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); +#endif + + switch(pSiS->sistvyfilter) { + case 0: + andSISIDXREG(SISPART2,0x30,0xdf); + break; + case 1: + outSISIDXREG(SISPART2,0x35,p35); + outSISIDXREG(SISPART2,0x36,p36); + outSISIDXREG(SISPART2,0x37,p37); + outSISIDXREG(SISPART2,0x38,p38); + if(!(pSiS->VBFlags & VB_301)) { + outSISIDXREG(SISPART2,0x48,p48); + outSISIDXREG(SISPART2,0x49,p49); + outSISIDXREG(SISPART2,0x4a,p4a); + } + setSISIDXREG(SISPART2,0x30,0xdf,p30); + break; + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + if(!(pSiS->VBFlags & (TV_PALM | TV_PALN | TV_NTSCJ))) { + int yindex301 = -1, yindex301B = -1; + unsigned char p3d4_34; + + inSISIDXREG(SISCR,0x34,p3d4_34); + + switch((p3d4_34 & 0x7f)) { + case 0x59: /* 320x200 */ + case 0x41: + case 0x4f: + case 0x50: /* 320x240 */ + case 0x56: + case 0x53: + yindex301 = (pSiS->VBFlags & TV_NTSC) ? 0 : 4; + break; + case 0x2f: /* 640x400 */ + case 0x5d: + case 0x5e: + case 0x2e: /* 640x480 */ + case 0x44: + case 0x62: + yindex301 = (pSiS->VBFlags & TV_NTSC) ? 1 : 5; + yindex301B = (pSiS->VBFlags & TV_NTSC) ? 0 : 4; + break; + case 0x31: /* 720x480 */ + case 0x33: + case 0x35: + case 0x32: /* 720x576 */ + case 0x34: + case 0x36: + case 0x5f: /* 768x576 */ + case 0x60: + case 0x61: + yindex301 = (pSiS->VBFlags & TV_NTSC) ? 2 : 6; + yindex301B = (pSiS->VBFlags & TV_NTSC) ? 1 : 5; + break; + case 0x51: /* 400x300 */ + case 0x57: + case 0x54: + case 0x30: /* 800x600 */ + case 0x47: + case 0x63: + yindex301 = (pSiS->VBFlags & TV_NTSC) ? 3 : 7; + yindex301B = (pSiS->VBFlags & TV_NTSC) ? 2 : 6; + break; + case 0x52: /* 512x384 */ + case 0x58: + case 0x5c: + case 0x38: /* 1024x768 */ + case 0x4a: + case 0x64: + yindex301B = (pSiS->VBFlags & TV_NTSC) ? 3 : 7; + break; + } + if(pSiS->VBFlags & VB_301) { + if(yindex301 >= 0) { + for(i=0, j=0x35; i<=3; i++, j++) { + outSISIDXREG(SISPART2,j,(SiSTVFilter301[yindex301].filter[pSiS->sistvyfilter-2][i])); + } + } + } else { + if(yindex301B >= 0) { + for(i=0, j=0x35; i<=3; i++, j++) { + outSISIDXREG(SISPART2,j,(SiSTVFilter301B[yindex301B].filter[pSiS->sistvyfilter-2][i])); + } + for(i=4, j=0x48; i<=6; i++, j++) { + outSISIDXREG(SISPART2,j,(SiSTVFilter301B[yindex301B].filter[pSiS->sistvyfilter-2][i])); + } + } + } + orSISIDXREG(SISPART2,0x30,0x20); + } + } +} + +int SiS_GetSISTVyfilter(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; + + if(pSiSEnt && pSiS->DualHeadMode) + return (int)pSiSEnt->sistvyfilter; + else +#endif + return (int)pSiS->sistvyfilter; +} + void SiS_SetSIS6326TVantiflicker(ScrnInfoPtr pScrn, int val) { SISPtr pSiS = SISPTR(pScrn); unsigned char tmp; - - pSiS->sis6326antiflicker = val; + + pSiS->sistvantiflicker = val; if(!(pSiS->SiS6326Flags & SIS6326_TVDETECTED)) return; - + #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif @@ -6572,7 +9721,7 @@ int SiS_GetSIS6326TVantiflicker(ScrnInfoPtr pScrn) unsigned char tmp; if(!(pSiS->SiS6326Flags & SIS6326_TVDETECTED)) { - return (int)pSiS->sis6326antiflicker; + return (int)pSiS->sistvantiflicker; } #ifdef UNLOCK_ALWAYS @@ -6581,7 +9730,7 @@ int SiS_GetSIS6326TVantiflicker(ScrnInfoPtr pScrn) tmp = SiS6326GetTVReg(pScrn,0x00); if(!(tmp & 0x04)) { - return (int)pSiS->sis6326antiflicker; + return (int)pSiS->sistvantiflicker; } else { return (int)((tmp >> 5) & 0x07); } @@ -6689,7 +9838,7 @@ void SiS_SetTVxposoffset(ScrnInfoPtr pScrn, int val) #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; #endif - + #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif @@ -6700,11 +9849,11 @@ void SiS_SetTVxposoffset(ScrnInfoPtr pScrn, int val) #endif if(pSiS->VGAEngine == SIS_300_VGA || pSiS->VGAEngine == SIS_315_VGA) { - + if(pSiS->VBFlags & CRT2_TV) { - + if(pSiS->VBFlags & VB_CHRONTEL) { - + int x = pSiS->tvx; #ifdef SISDUALHEAD if(pSiSEnt && pSiS->DualHeadMode) x = pSiSEnt->tvx; @@ -6719,114 +9868,91 @@ void SiS_SetTVxposoffset(ScrnInfoPtr pScrn, int val) } break; case CHRONTEL_701x: - /* TO DO */ + /* Not supported by hardware */ break; } - + } else if(pSiS->VBFlags & VB_SISBRIDGE) { - + if((val >= -32) && (val <= 32)) { - unsigned char p2_1f,p2_2b,p2_2c,p2_2d,p2_43; - const unsigned char p2_left_ntsc[8][4] = { - { 0x48, 0x63, 0x49, 0xf4 }, - { 0x45, 0x60, 0x46, 0xf1 }, - { 0x43, 0x6e, 0x44, 0xff }, - { 0x40, 0x6b, 0x41, 0xfc }, - { 0x3e, 0x69, 0x3f, 0xfa }, - { 0x3c, 0x67, 0x3d, 0xf8 }, - { 0x39, 0x64, 0x3a, 0xf5 }, - { 0x37, 0x62, 0x38, 0xf3 } - }; - const unsigned char p2_right_ntsc[8][4] = { - { 0x4b, 0x66, 0x4c, 0xf7 }, - { 0x4c, 0x67, 0x4d, 0xf8 }, - { 0x4e, 0x69, 0x4f, 0xfa }, - { 0x4f, 0x6a, 0x50, 0xfb }, - { 0x51, 0x6c, 0x52, 0xfd }, - { 0x53, 0x6e, 0x54, 0xff }, - { 0x55, 0x60, 0x56, 0xf1 }, - { 0x56, 0x61, 0x57, 0xf2 } - }; - const unsigned char p2_left_pal[8][4] = { - { 0x5b, 0x66, 0x5c, 0x87 }, - { 0x59, 0x64, 0x5a, 0x85 }, - { 0x56, 0x61, 0x57, 0x82 }, - { 0x53, 0x6e, 0x54, 0x8f }, - { 0x50, 0x6b, 0x51, 0x8c }, - { 0x4d, 0x68, 0x4e, 0x89 }, - { 0x4a, 0x65, 0x4b, 0x86 }, - { 0x49, 0x64, 0x4a, 0x85 } - }; - const unsigned char p2_right_pal[8][4] = { - { 0x5f, 0x6a, 0x60, 0x8b }, - { 0x61, 0x6c, 0x62, 0x8d }, - { 0x63, 0x6e, 0x64, 0x8f }, - { 0x65, 0x60, 0x66, 0x81 }, - { 0x66, 0x61, 0x67, 0x82 }, - { 0x68, 0x63, 0x69, 0x84 }, - { 0x69, 0x64, 0x6a, 0x85 }, - { 0x6b, 0x66, 0x6c, 0x87 } - }; - val /= 4; - p2_2d = pSiS->p2_2d; -#ifdef SISDUALHEAD - if(pSiSEnt && pSiS->DualHeadMode) p2_2d = pSiSEnt->p2_2d; -#endif - p2_2d &= 0xf0; - if(val < 0) { - val = -val; - if(val == 8) val = 7; - if(pSiS->VBFlags & TV_PAL) { - p2_1f = p2_left_pal[val][0]; - p2_2b = p2_left_pal[val][1]; - p2_2c = p2_left_pal[val][2]; - p2_2d |= (p2_left_pal[val][3] & 0x0f); - } else { - p2_1f = p2_left_ntsc[val][0]; - p2_2b = p2_left_ntsc[val][1]; - p2_2c = p2_left_ntsc[val][2]; - p2_2d |= (p2_left_ntsc[val][3] & 0x0f); - } + + unsigned char p2_1f,p2_20,p2_2b,p2_43,p3d4_34; + unsigned short temp; + int myadd2, mysub; + + p2_1f = pSiS->p2_1f; + p2_20 = pSiS->p2_20; +#ifdef SISDUALHEAD + if(pSiSEnt && pSiS->DualHeadMode) { + p2_1f = pSiSEnt->p2_1f; + p2_20 = pSiSEnt->p2_20; + } +#endif + inSISIDXREG(SISCR,0x34,p3d4_34); + p3d4_34 &= 0x7f; + + temp = p2_1f | ((p2_20 & 0xf0) << 4); + temp += (val * 2); + + p2_1f = temp & 0xff; + p2_20 = (temp & 0xf00) >> 4; + + if((pSiS->VBFlags & (TV_NTSC | TV_PALM)) && + ((p3d4_34 == 0x64) || (p3d4_34 == 0x4a) || (p3d4_34 == 0x38))) { + temp += 1514; + myadd2 = 4; + mysub = 4; } else { - if(val == 8) val = 7; - if(pSiS->VBFlags & TV_PAL) { - p2_1f = p2_right_pal[val][0]; - p2_2b = p2_right_pal[val][1]; - p2_2c = p2_right_pal[val][2]; - p2_2d |= (p2_right_pal[val][3] & 0x0f); - } else { - p2_1f = p2_right_ntsc[val][0]; - p2_2b = p2_right_ntsc[val][1]; - p2_2c = p2_right_ntsc[val][2]; - p2_2d |= (p2_right_ntsc[val][3] & 0x0f); - } + temp += 1363; + myadd2 = 3; + if(pSiS->VBFlags & VB_301) myadd2 += 3; + mysub = 5; + } + + p2_2b = ((temp & 0xf00) >> 4) | ((p2_1f - mysub) & 0x0f); + p2_43 = p2_1f + myadd2; + +#if 0 + p2_1f += (val * 2); + if((pSiS->VBFlags & (TV_NTSC | TV_PALM)) && + ((p3d4_34 == 0x64) || (p3d4_34 == 0x4a) || (p3d4_34 == 0x38))) { + p2_2b = ((p2_1f - 4) & 0x0f) | 0x70; + p2_2c = p2_1f - 22; + p2_2d = ((p2_2c - 4) & 0x0f) | 0xe0; + p2_43 = p2_1f + 4; + } else { + p2_2b = ((p2_1f - 5) & 0x0f) | 0x60; + p2_2c = p2_1f + 1; + p2_2d = ((p2_2c - 5) & 0x0f) | (pSiS->VBFlags & TV_PAL ? 0x80 : 0xf0); + p2_43 = p2_1f + 3; + if(pSiS->VBFlags & VB_301) p2_43 += 3; } - p2_43 = p2_1f + 3; +#endif + SISWaitRetraceCRT2(pScrn); outSISIDXREG(SISPART2,0x1f,p2_1f); + setSISIDXREG(SISPART2,0x20,0x0F,p2_20); outSISIDXREG(SISPART2,0x2b,p2_2b); - outSISIDXREG(SISPART2,0x2c,p2_2c); - outSISIDXREG(SISPART2,0x2d,p2_2d); outSISIDXREG(SISPART2,0x43,p2_43); } } } - + } else if(pSiS->Chipset == PCI_CHIP_SIS6326) { - + if(pSiS->SiS6326Flags & SIS6326_TVDETECTED) { - + unsigned char tmp; unsigned short temp1, temp2, temp3; - + tmp = SiS6326GetTVReg(pScrn,0x00); if(tmp & 0x04) { - + temp1 = pSiS->tvx1; temp2 = pSiS->tvx2; temp3 = pSiS->tvx3; if((val >= -16) && (val <= 16)) { - if(val > 0) { + if(val > 0) { temp1 += (val * 4); temp2 += (val * 4); while((temp1 > 0x0fff) || (temp2 > 0x0fff)) { @@ -6866,11 +9992,11 @@ int SiS_GetTVxposoffset(ScrnInfoPtr pScrn) SISPtr pSiS = SISPTR(pScrn); #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; - - if(pSiSEnt && pSiS->DualHeadMode) + + if(pSiSEnt && pSiS->DualHeadMode) return (int)pSiSEnt->tvxpos; else -#endif +#endif return (int)pSiS->tvxpos; } @@ -6891,11 +10017,11 @@ void SiS_SetTVyposoffset(ScrnInfoPtr pScrn, int val) #endif if(pSiS->VGAEngine == SIS_300_VGA || pSiS->VGAEngine == SIS_315_VGA) { - + if(pSiS->VBFlags & CRT2_TV) { - + if(pSiS->VBFlags & VB_CHRONTEL) { - + int y = pSiS->tvy; #ifdef SISDUALHEAD if(pSiSEnt && pSiS->DualHeadMode) y = pSiSEnt->tvy; @@ -6910,12 +10036,12 @@ void SiS_SetTVyposoffset(ScrnInfoPtr pScrn, int val) } break; case CHRONTEL_701x: - /* TO DO */ + /* Not supported by hardware */ break; } - + } else if(pSiS->VBFlags & VB_SISBRIDGE) { - + if((val >= -32) && (val <= 32)) { char p2_01, p2_02; val /= 4; @@ -6931,7 +10057,7 @@ void SiS_SetTVyposoffset(ScrnInfoPtr pScrn, int val) p2_02 += (val * 2); while((p2_01 <= 0) || (p2_02 <= 0)) { p2_01 += 2; - p2_02 += 2; + p2_02 += 2; } SISWaitRetraceCRT2(pScrn); outSISIDXREG(SISPART2,0x01,p2_01); @@ -6939,18 +10065,18 @@ void SiS_SetTVyposoffset(ScrnInfoPtr pScrn, int val) } } - } + } } else if(pSiS->Chipset == PCI_CHIP_SIS6326) { - + if(pSiS->SiS6326Flags & SIS6326_TVDETECTED) { - + unsigned char tmp; int temp1, limit; - + tmp = SiS6326GetTVReg(pScrn,0x00); if(tmp & 0x04) { - + if((val >= -16) && (val <= 16)) { temp1 = (unsigned short)pSiS->tvy1; limit = (pSiS->SiS6326Flags & SIS6326_TVPAL) ? 625 : 525; @@ -6991,19 +10117,314 @@ int SiS_GetTVyposoffset(ScrnInfoPtr pScrn) SISPtr pSiS = SISPTR(pScrn); #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; - - if(pSiSEnt && pSiS->DualHeadMode) + + if(pSiSEnt && pSiS->DualHeadMode) return (int)pSiSEnt->tvypos; - else -#endif + else +#endif return (int)pSiS->tvypos; } -/* TW: Disable CRT1 for saving bandwidth. This doesn't work with VESA; - * VESA uses the bridge in SlaveMode and switching CRT1 off while the - * bridge is in SlaveMode not that clever... +void SiS_SetTVxscale(ScrnInfoPtr pScrn, int val) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; +#endif + +#ifdef UNLOCK_ALWAYS + sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); +#endif + + pSiS->tvxscale = val; +#ifdef SISDUALHEAD + if(pSiSEnt) pSiSEnt->tvxscale = val; +#endif + + if(pSiS->VGAEngine == SIS_300_VGA || pSiS->VGAEngine == SIS_315_VGA) { + + if((pSiS->VBFlags & CRT2_TV) && (pSiS->VBFlags & VB_SISBRIDGE)) { + + if((val >= -16) && (val <= 16)) { + + unsigned char p2_44,p2_45,p2_46; + int scalingfactor; + + p2_44 = pSiS->p2_44; + p2_45 = pSiS->p2_45 & 0x3f; + p2_46 = pSiS->p2_46 & 0x07; +#ifdef SISDUALHEAD + if(pSiSEnt && pSiS->DualHeadMode) { + p2_44 = pSiSEnt->p2_44; + p2_45 = pSiSEnt->p2_45 & 0x3f; + p2_46 = pSiSEnt->p2_46 & 0x07; + } +#endif + scalingfactor = (p2_46 << 13) | ((p2_45 & 0x1f) << 8) | p2_44; + + if(val < 0) { + p2_45 &= 0xdf; + scalingfactor += ((-val) * 64); + if(scalingfactor > 0xffff) scalingfactor = 0xffff; + } else if(val > 0) { + p2_45 &= 0xdf; + scalingfactor -= (val * 64); + if(scalingfactor < 1) scalingfactor = 1; + } + + p2_44 = scalingfactor & 0xff; + p2_45 &= 0xe0; + p2_45 |= ((scalingfactor >> 8) & 0x1f); + p2_46 = ((scalingfactor >> 13) & 0x07); + + SISWaitRetraceCRT2(pScrn); + outSISIDXREG(SISPART2,0x44,p2_44); + setSISIDXREG(SISPART2,0x45,0xC0,p2_45); + if(!(pSiS->VBFlags & VB_301)) { + setSISIDXREG(SISPART2,0x46,0xF8,p2_46); + } + } + + } + + } +} + +int SiS_GetTVxscale(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; + + if(pSiSEnt && pSiS->DualHeadMode) + return (int)pSiSEnt->tvxscale; + else +#endif + return (int)pSiS->tvxscale; +} + +void SiS_SetTVyscale(ScrnInfoPtr pScrn, int val) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; +#endif + +#ifdef UNLOCK_ALWAYS + sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); +#endif + + if(val < -4) val = -4; + if(val > 3) val = 3; + + pSiS->tvyscale = val; +#ifdef SISDUALHEAD + if(pSiSEnt) pSiSEnt->tvyscale = val; +#endif + + if(pSiS->VBFlags & (TV_HIVISION | TV_HIVISION_LV)) return; + + if(pSiS->VGAEngine == SIS_315_VGA || pSiS->VGAEngine == SIS_315_VGA) { + + if((pSiS->VBFlags & CRT2_TV) && (pSiS->VBFlags & VB_SISBRIDGE)) { + + int srindex = -1; + int newvde, i=0, j, temp; + int vlimit = (pSiS->VBFlags & (TV_NTSC | TV_PALM)) ? 259 : 309; + unsigned char p3d4_34; + + inSISIDXREG(SISCR,0x34,p3d4_34); + + switch((p3d4_34 & 0x7f)) { +#if 0 + case 0x50: /* 320x240 - hdclk mode */ + case 0x56: + case 0x53: +#endif + case 0x2e: /* 640x480 */ + case 0x44: + case 0x62: + srindex = (pSiS->VBFlags & (TV_NTSC | TV_PALM)) ? 0 : 21; + break; + case 0x31: /* 720x480 */ + case 0x33: + case 0x35: + case 0x32: /* 720x576 */ + case 0x34: + case 0x36: + case 0x5f: /* 768x576 */ + case 0x60: + case 0x61: + if(pSiS->VGAEngine == SIS_315_VGA) { + srindex = (pSiS->VBFlags & (TV_NTSC | TV_PALM)) ? 7 : 28; + } + break; +#if 0 + case 0x51: /* 400x300 - hdclk mode */ + case 0x57: + case 0x54: +#endif + case 0x30: /* 800x600 */ + case 0x47: + case 0x63: + srindex = (pSiS->VBFlags & (TV_NTSC | TV_PALM)) ? 14 : 35; + } + + if(srindex >= 0) { + Bool found = FALSE; + if(pSiS->tvyscale != 0) { + for(j=0; j<=1; j++) { + for(i=0; i<=6; i++) { + if(SiSTVVScale[srindex+i].sindex == pSiS->tvyscale) { + found = TRUE; + break; + } + } + if(found) break; + if(pSiS->tvyscale > 0) pSiS->tvyscale--; + else pSiS->tvyscale++; + } + } +#ifdef SISDUALHEAD + if(pSiSEnt) pSiSEnt->tvyscale = pSiS->tvyscale; +#endif + if(pSiS->tvyscale == 0) { + unsigned char p2_0a = pSiS->p2_0a; + unsigned char p2_2f = pSiS->p2_2f; + unsigned char p2_30 = pSiS->p2_30; + unsigned char p2_46 = pSiS->p2_46; + unsigned char p2_47 = pSiS->p2_47; + unsigned char p1scaling[9], p4scaling[9]; + + for(i=0; i<9; i++) { + p1scaling[i] = pSiS->scalingp1[i]; + } + for(i=0; i<9; i++) { + p4scaling[i] = pSiS->scalingp4[i]; + } +#ifdef SISDUALHEAD + if(pSiSEnt) { + p2_0a = pSiSEnt->p2_0a; + p2_2f = pSiSEnt->p2_2f; + p2_30 = pSiSEnt->p2_30; + p2_46 = pSiSEnt->p2_46; + p2_47 = pSiSEnt->p2_47; + for(i=0; i<9; i++) { + p1scaling[i] = pSiSEnt->scalingp1[i]; + } + for(i=0; i<9; i++) { + p4scaling[i] = pSiSEnt->scalingp4[i]; + } + } +#endif + SISWaitRetraceCRT2(pScrn); + for(i=0; i<9; i++) { + outSISIDXREG(SISPART1,SiSScalingP1Regs[i],p1scaling[i]); + } + for(i=0; i<9; i++) { + outSISIDXREG(SISPART4,SiSScalingP4Regs[i],p4scaling[i]); + } + + setSISIDXREG(SISPART2,0x0a,0x7f,(p2_0a & 0x80)); + outSISIDXREG(SISPART2,0x2f,p2_2f); + setSISIDXREG(SISPART2,0x30,0x3f,(p2_30 & 0xc0)); + if(!(pSiS->VBFlags & VB_301)) { + setSISIDXREG(SISPART2,0x46,0x9f,(p2_46 & 0x60)); + outSISIDXREG(SISPART2,0x47,p2_47); + } + + } else { + + int so = (pSiS->VGAEngine == SIS_300_VGA) ? 12 : 0; + int realvde; + unsigned long calctemp; + + srindex += i; + newvde = SiSTVVScale[srindex].ScaleVDE; + realvde = SiSTVVScale[srindex].RealVDE; + + do { + inSISIDXREG(SISPART2,0x01,temp); + temp = vlimit - (temp & 0x7f); + if((temp - (((newvde >> 1) - 2) + 9)) > 0) break; + SiS_SetTVyposoffset(pScrn, pSiS->tvypos - 1); + } while(1); + + SISWaitRetraceCRT2(pScrn); + if(!(pSiS->VBFlags & VB_301)) { + temp = (newvde >> 1) - 3; + setSISIDXREG(SISPART2,0x46,0x9f,((temp & 0x0300) >> 3)); + outSISIDXREG(SISPART2,0x47,(temp & 0xff)); + } + outSISIDXREG(SISPART1,0x08,(SiSTVVScale[srindex].reg[so+0] & 0xff)); + setSISIDXREG(SISPART1,0x09,0x0f,((SiSTVVScale[srindex].reg[so+0] >> 4) & 0xf0)); + outSISIDXREG(SISPART1,0x0b,(SiSTVVScale[srindex].reg[so+1] & 0xff)); + setSISIDXREG(SISPART1,0x0c,0xf0,((SiSTVVScale[srindex].reg[so+1] >> 8) & 0x0f)); + outSISIDXREG(SISPART1,0x0d,(SiSTVVScale[srindex].reg[so+2] & 0xff)); + outSISIDXREG(SISPART1,0x0e,(SiSTVVScale[srindex].reg[so+3] & 0xff)); + setSISIDXREG(SISPART1,0x12,0xf8,((SiSTVVScale[srindex].reg[so+3] >> 8 ) & 0x07)); + outSISIDXREG(SISPART1,0x10,(SiSTVVScale[srindex].reg[so+4] & 0xff)); + setSISIDXREG(SISPART1,0x11,0x8f,((SiSTVVScale[srindex].reg[so+4] >> 4) & 0x70)); + setSISIDXREG(SISPART1,0x11,0xf0,(SiSTVVScale[srindex].reg[so+5] & 0x0f)); + + setSISIDXREG(SISPART2,0x0a,0x7f,((SiSTVVScale[srindex].reg[so+6] << 7) & 0x80)); + outSISIDXREG(SISPART2,0x2f,((newvde / 2) - 2)); + setSISIDXREG(SISPART2,0x30,0x3f,((((newvde / 2) - 2) >> 2) & 0xc0)); + + outSISIDXREG(SISPART4,0x13,(SiSTVVScale[srindex].reg[so+7] & 0xff)); + outSISIDXREG(SISPART4,0x14,(SiSTVVScale[srindex].reg[so+8] & 0xff)); + setSISIDXREG(SISPART4,0x15,0x7f,((SiSTVVScale[srindex].reg[so+8] >> 1) & 0x80)); + + outSISIDXREG(SISPART4,0x16,(SiSTVVScale[srindex].reg[so+9] & 0xff)); + setSISIDXREG(SISPART4,0x15,0x87,((SiSTVVScale[srindex].reg[so+9] >> 5) & 0x78)); + + outSISIDXREG(SISPART4,0x17,(SiSTVVScale[srindex].reg[so+10] & 0xff)); + setSISIDXREG(SISPART4,0x15,0xf8,((SiSTVVScale[srindex].reg[so+10] >> 8) & 0x07)); + + outSISIDXREG(SISPART4,0x18,(SiSTVVScale[srindex].reg[so+11] & 0xff)); + setSISIDXREG(SISPART4,0x19,0xf0,((SiSTVVScale[srindex].reg[so+11] >> 8) & 0x0f)); + + temp = 0x40; + if(realvde <= newvde) temp = 0; + else realvde -= newvde; + + calctemp = (realvde * 256 * 1024) / newvde; + if((realvde * 256 * 1024) % newvde) calctemp++; + outSISIDXREG(SISPART4,0x1b,(calctemp & 0xff)); + outSISIDXREG(SISPART4,0x1a,((calctemp >> 8) & 0xff)); + setSISIDXREG(SISPART4,0x19,0x8f,(((calctemp >> 12) & 0x30) | temp)); + } + } + + } + + } +} + +int SiS_GetTVyscale(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; + + if(pSiSEnt && pSiS->DualHeadMode) + return (int)pSiSEnt->tvyscale; + else +#endif + return (int)pSiS->tvyscale; +} + +/* PostSetMode: + * -) Disable CRT1 for saving bandwidth. This doesn't work with VESA; + * VESA uses the bridge in SlaveMode and switching CRT1 off while + * the bridge is in SlaveMode not that clever... + * -) Check if overlay can be used (depending on dotclock) + * -) Check if Panel Scaler is active on LVDS for overlay re-scaling + * -) Save TV registers for further processing + * -) Apply TV settings */ -void SiSPostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) +static void +SiSPostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) { SISPtr pSiS = SISPTR(pScrn); #ifdef SISDUALHEAD @@ -7012,12 +10433,15 @@ void SiSPostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) unsigned char usScratchCR17; Bool flag = FALSE; Bool doit = TRUE; - int temp; + int myclock, temp; + unsigned char sr2b, sr2c, tmpreg; + float num, denum, postscalar, divider; #ifdef TWDEBUG xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CRT1off is %d\n", pSiS->CRT1off); #endif + pSiS->CRT1isoff = pSiS->CRT1off; #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); @@ -7026,55 +10450,164 @@ void SiSPostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) if((!pSiS->UseVESA) && (pSiS->VBFlags & CRT2_ENABLE)) { if(pSiS->VBFlags != pSiS->VBFlags_backup) { - pSiS->VBFlags = pSiS->VBFlags_backup; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, + pSiS->VBFlags = pSiS->VBFlags_backup; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VBFlags restored to %0lx\n", pSiS->VBFlags); } - /* TW: -) We can't switch off CRT1 if bridge is in SlaveMode. - * -) If we change to a SlaveMode-Mode (like 512x384), we - * need to adapt VBFlags for eg. Xv. + /* -) We can't switch off CRT1 if bridge is in SlaveMode. + * -) If we change to a SlaveMode-Mode (like 512x384), we + * need to adapt VBFlags for eg. Xv. */ #ifdef SISDUALHEAD if(!pSiS->DualHeadMode) { #endif - if(SiSBridgeIsInSlaveMode(pScrn)) { - doit = FALSE; - temp = pSiS->VBFlags; - pSiS->VBFlags &= (~VB_DISPMODE_SINGLE); - pSiS->VBFlags |= (VB_DISPMODE_MIRROR | DISPTYPE_DISP1); - if(temp != pSiS->VBFlags) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "VBFlags changed to 0x%0lx\n", pSiS->VBFlags); - } + if(SiSBridgeIsInSlaveMode(pScrn)) { + doit = FALSE; + temp = pSiS->VBFlags; + pSiS->VBFlags &= (~VB_DISPMODE_SINGLE); + pSiS->VBFlags |= (VB_DISPMODE_MIRROR | DISPTYPE_DISP1); + if(temp != pSiS->VBFlags) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "VBFlags changed to 0x%0lx\n", pSiS->VBFlags); + } } #ifdef SISDUALHEAD } #endif - if(doit) { - inSISIDXREG(SISCR, 0x17, usScratchCR17); - if(pSiS->CRT1off) { - if(usScratchCR17 & 0x80) flag = TRUE; - usScratchCR17 &= ~0x80; - } else { - if(!(usScratchCR17 & 0x80)) flag = TRUE; - usScratchCR17 |= 0x80; - } - outSISIDXREG(SISCR, 0x17, usScratchCR17); - /* TW: Reset only if status changed */ - if(flag) { - outSISIDXREG(SISSR, 0x00, 0x01); /* Synchronous Reset */ - usleep(10000); - outSISIDXREG(SISSR, 0x00, 0x03); /* End Reset */ + + if(pSiS->VGAEngine == SIS_315_VGA) { + + if((pSiS->CRT1off) && (doit)) { + orSISIDXREG(SISCR,0x63,0x40); + orSISIDXREG(SISSR,0x1f,0xc0); + } else { + andSISIDXREG(SISCR,0x63,0xBF); + andSISIDXREG(SISSR,0x1f,0x3f); + } + + } else { + + if(doit) { + inSISIDXREG(SISCR, 0x17, usScratchCR17); + if(pSiS->CRT1off) { + if(usScratchCR17 & 0x80) { + flag = TRUE; + usScratchCR17 &= ~0x80; + } + orSISIDXREG(SISSR,0x1f,0xc0); + } else { + if(!(usScratchCR17 & 0x80)) { + flag = TRUE; + usScratchCR17 |= 0x80; + } + andSISIDXREG(SISSR,0x1f,0x3f); + } + /* Reset only if status changed */ + if(flag) { + outSISIDXREG(SISCR, 0x17, usScratchCR17); + outSISIDXREG(SISSR, 0x00, 0x01); /* Synchronous Reset */ + usleep(10000); + outSISIDXREG(SISSR, 0x00, 0x03); /* End Reset */ + } } } + } - /* TW: Apply TV settings given by options + /* Determine if the video overlay can be used */ + if(!pSiS->NoXvideo) { + inSISIDXREG(SISSR,0x2b,sr2b); + inSISIDXREG(SISSR,0x2c,sr2c); + divider = (sr2b & 0x80) ? 2.0 : 1.0; + postscalar = (sr2c & 0x80) ? + ( (((sr2c >> 5) & 0x03) == 0x02) ? 6.0 : 8.0 ) : + ( ((sr2c >> 5) & 0x03) + 1.0 ); + num = (sr2b & 0x7f) + 1.0; + denum = (sr2c & 0x1f) + 1.0; + myclock = (int)((14318 * (divider / postscalar) * (num / denum)) / 1000); + + pSiS->MiscFlags &= ~(MISC_CRT1OVERLAY | MISC_CRT1OVERLAYGAMMA); + switch(pSiS->sishw_ext.jChipType) { + case SIS_300: + case SIS_540: + case SIS_630: + case SIS_730: + if(myclock < 150) { + pSiS->MiscFlags |= MISC_CRT1OVERLAY; + } + break; + case SIS_550: + case SIS_650: + case SIS_740: + if(myclock < 175) { + pSiS->MiscFlags |= MISC_CRT1OVERLAY; + if(myclock < 166) { + pSiS->MiscFlags |= MISC_CRT1OVERLAYGAMMA; + } + } + break; + case SIS_315H: + case SIS_315: + case SIS_315PRO: + case SIS_330: + case SIS_661: + case SIS_741: + case SIS_660: + case SIS_760: + if(myclock < 180) { + pSiS->MiscFlags |= MISC_CRT1OVERLAY; + if(myclock < 166) { + pSiS->MiscFlags |= MISC_CRT1OVERLAYGAMMA; + } + } + break; + } + if(!(pSiS->MiscFlags & MISC_CRT1OVERLAY)) { +#ifdef SISDUALHEAD + if((!pSiS->DualHeadMode) || (pSiS->SecondHead)) +#endif + xf86DrvMsgVerb(pScrn->scrnIndex, X_WARNING, 3, + "Current dotclock (%dMhz) too high for video overlay on CRT1\n", + myclock); + } + } + + /* Determine if the Panel Link scaler is active */ + pSiS->MiscFlags &= ~MISC_PANELLINKSCALER; + if(pSiS->VBFlags & (CRT2_LCD | CRT1_LCDA)) { + if(pSiS->VGAEngine == SIS_300_VGA) { + if(pSiS->VBFlags & (VB_LVDS | VB_30xBDH)) { + inSISIDXREG(SISPART1,0x1e,tmpreg); + tmpreg &= 0x3f; + if(tmpreg) pSiS->MiscFlags |= MISC_PANELLINKSCALER; + } + } else { + if(pSiS->VBFlags & (VB_LVDS | VB_30xBDH | CRT1_LCDA)) { + inSISIDXREG(SISPART1,0x35,tmpreg); + tmpreg &= 0x04; + if(!tmpreg) pSiS->MiscFlags |= MISC_PANELLINKSCALER; + } + } + } + +#ifdef SISVRAMQ + if(pSiS->VGAEngine == SIS_315_VGA) { + /* Re-Enable command queue */ + SiSEnableTurboQueue(pScrn); + } +#endif + + /* Reset XV gamma correction */ + if(pSiS->ResetXvGamma) { + (pSiS->ResetXvGamma)(pScrn); + } + + /* Apply TV settings given by options Do this even in DualHeadMode: - if this is called by SetModeCRT1, CRT2 mode has been reset by SetModeCRT1 - if this is called by SetModeCRT2, CRT2 mode has changed (duh!) - -> In both cases, the settings must be re-applied. + -> Hence, in both cases, the settings must be re-applied. */ if(pSiS->VBFlags & CRT2_TV) { int val; @@ -7089,7 +10622,7 @@ void SiSPostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) int mychtvcontrast = pSiS->chtvcontrast; int mytvxpos = pSiS->tvxpos; int mytvypos = pSiS->tvypos; -#ifdef SISDUALHEAD +#ifdef SISDUALHEAD if(pSiSEnt && pSiS->DualHeadMode) { mychtvlumabandwidthcvbs = pSiSEnt->chtvlumabandwidthcvbs; mychtvlumabandwidthsvideo = pSiSEnt->chtvlumabandwidthsvideo; @@ -7139,10 +10672,10 @@ void SiSPostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) pSiSEnt->tvx = pSiS->tvx; pSiSEnt->tvy = pSiS->tvy; } -#endif +#endif break; case CHRONTEL_701x: - /* TO DO */ + /* Not supported by hardware */ break; } if((val = mytvxpos) != 0) { @@ -7158,7 +10691,7 @@ void SiSPostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) if(pSiSEnt && pSiS->DualHeadMode) { mysistvedgeenhance = pSiSEnt->sistvedgeenhance; } -#endif +#endif if((val = mysistvedgeenhance) != -1) { SiS_SetSISTVedgeenhance(pScrn, val); } @@ -7166,53 +10699,135 @@ void SiSPostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) if(pSiS->VBFlags & VB_SISBRIDGE) { int mysistvantiflicker = pSiS->sistvantiflicker; int mysistvsaturation = pSiS->sistvsaturation; + int mysistvcolcalibf = pSiS->sistvcolcalibf; + int mysistvcolcalibc = pSiS->sistvcolcalibc; + int mysistvcfilter = pSiS->sistvcfilter; + int mysistvyfilter = pSiS->sistvyfilter; int mytvxpos = pSiS->tvxpos; int mytvypos = pSiS->tvypos; + int mytvxscale = pSiS->tvxscale; + int mytvyscale = pSiS->tvyscale; + int i; + unsigned long cbase; + unsigned char ctemp; #ifdef SISDUALHEAD if(pSiSEnt && pSiS->DualHeadMode) { mysistvantiflicker = pSiSEnt->sistvantiflicker; mysistvsaturation = pSiSEnt->sistvsaturation; + mysistvcolcalibf = pSiSEnt->sistvcolcalibf; + mysistvcolcalibc = pSiSEnt->sistvcolcalibc; + mysistvcfilter = pSiSEnt->sistvcfilter; + mysistvyfilter = pSiSEnt->sistvyfilter; mytvxpos = pSiSEnt->tvxpos; mytvypos = pSiSEnt->tvypos; + mytvxscale = pSiSEnt->tvxscale; + mytvyscale = pSiSEnt->tvyscale; } -#endif - /* Backup default TV position registers */ - inSISIDXREG(SISPART2,0x2d,pSiS->p2_2d); +#endif + /* Backup default TV position, scale and colcalib registers */ + inSISIDXREG(SISPART2,0x1f,pSiS->p2_1f); + inSISIDXREG(SISPART2,0x20,pSiS->p2_20); inSISIDXREG(SISPART2,0x01,pSiS->p2_01); inSISIDXREG(SISPART2,0x02,pSiS->p2_02); + inSISIDXREG(SISPART2,0x44,pSiS->p2_44); + inSISIDXREG(SISPART2,0x45,pSiS->p2_45); + if(!(pSiS->VBFlags & VB_301)) { + inSISIDXREG(SISPART2,0x46,pSiS->p2_46); + } else { + pSiS->p2_46 = 0; + } + inSISIDXREG(SISPART2,0x0a,pSiS->p2_0a); + inSISIDXREG(SISPART2,0x31,cbase); + cbase = (cbase & 0x7f) << 8; + inSISIDXREG(SISPART2,0x32,ctemp); + cbase = (cbase | ctemp) << 8; + inSISIDXREG(SISPART2,0x33,ctemp); + cbase = (cbase | ctemp) << 8; + inSISIDXREG(SISPART2,0x34,ctemp); + pSiS->sistvccbase = (cbase | ctemp); + inSISIDXREG(SISPART2,0x35,pSiS->p2_35); + inSISIDXREG(SISPART2,0x36,pSiS->p2_36); + inSISIDXREG(SISPART2,0x37,pSiS->p2_37); + inSISIDXREG(SISPART2,0x38,pSiS->p2_38); + if(!(pSiS->VBFlags & VB_301)) { + inSISIDXREG(SISPART2,0x47,pSiS->p2_47); + inSISIDXREG(SISPART2,0x48,pSiS->p2_48); + inSISIDXREG(SISPART2,0x49,pSiS->p2_49); + inSISIDXREG(SISPART2,0x4a,pSiS->p2_4a); + } + inSISIDXREG(SISPART2,0x2f,pSiS->p2_2f); + inSISIDXREG(SISPART2,0x30,pSiS->p2_30); + for(i=0; i<9; i++) { + inSISIDXREG(SISPART1,SiSScalingP1Regs[i],pSiS->scalingp1[i]); + } + for(i=0; i<9; i++) { + inSISIDXREG(SISPART4,SiSScalingP4Regs[i],pSiS->scalingp4[i]); + } #ifdef SISDUALHEAD if(pSiSEnt && pSiS->DualHeadMode) { - pSiSEnt->p2_2d = pSiS->p2_2d; - pSiSEnt->p2_01 = pSiS->p2_01; - pSiSEnt->p2_02 = pSiS->p2_02; + pSiSEnt->p2_1f = pSiS->p2_1f; pSiSEnt->p2_20 = pSiS->p2_20; + pSiSEnt->p2_01 = pSiS->p2_01; pSiSEnt->p2_02 = pSiS->p2_02; + pSiSEnt->p2_44 = pSiS->p2_44; pSiSEnt->p2_45 = pSiS->p2_45; + pSiSEnt->p2_46 = pSiS->p2_46; pSiSEnt->p2_0a = pSiS->p2_0a; + pSiSEnt->sistvccbase = pSiS->sistvccbase; + pSiSEnt->p2_35 = pSiS->p2_35; pSiSEnt->p2_36 = pSiS->p2_36; + pSiSEnt->p2_37 = pSiS->p2_37; pSiSEnt->p2_38 = pSiS->p2_38; + pSiSEnt->p2_48 = pSiS->p2_48; pSiSEnt->p2_49 = pSiS->p2_49; + pSiSEnt->p2_4a = pSiS->p2_4a; pSiSEnt->p2_2f = pSiS->p2_2f; + pSiSEnt->p2_30 = pSiS->p2_30; pSiSEnt->p2_47 = pSiS->p2_47; + for(i=0; i<9; i++) { + pSiSEnt->scalingp1[i] = pSiS->scalingp1[i]; + } + for(i=0; i<9; i++) { + pSiSEnt->scalingp4[i] = pSiS->scalingp4[i]; + } } -#endif +#endif if((val = mysistvantiflicker) != -1) { SiS_SetSISTVantiflicker(pScrn, val); } if((val = mysistvsaturation) != -1) { SiS_SetSISTVsaturation(pScrn, val); } + if((val = mysistvcfilter) != -1) { + SiS_SetSISTVcfilter(pScrn, val); + } + if((val = mysistvyfilter) != 1) { + SiS_SetSISTVyfilter(pScrn, val); + } + if((val = mysistvcolcalibc) != 0) { + SiS_SetSISTVcolcalib(pScrn, val, TRUE); + } + if((val = mysistvcolcalibf) != 0) { + SiS_SetSISTVcolcalib(pScrn, val, FALSE); + } if((val = mytvxpos) != 0) { SiS_SetTVxposoffset(pScrn, val); } if((val = mytvypos) != 0) { - SiS_SetTVyposoffset(pScrn, val); - } + SiS_SetTVyposoffset(pScrn, val); + } + if((val = mytvxscale) != 0) { + SiS_SetTVxscale(pScrn, val); + } + if((val = mytvyscale) != 0) { + SiS_SetTVyscale(pScrn, val); + } } } } /* Post-set SiS6326 TV registers */ -void SiS6326PostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) +static void +SiS6326PostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) { SISPtr pSiS = SISPTR(pScrn); unsigned char tmp; int val; if(!(pSiS->SiS6326Flags & SIS6326_TVDETECTED)) return; - + #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif @@ -7227,7 +10842,7 @@ void SiS6326PostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) pSiS->tvy1 = SiS6326GetTVReg(pScrn,0x11); pSiS->tvy1 |= ((SiS6326GetTVReg(pScrn,0x13) & 0x30) << 4); - /* TW: Handle TVPosOffset options (BEFORE switching on TV) */ + /* Handle TVPosOffset options (BEFORE switching on TV) */ if((val = pSiS->tvxpos) != 0) { SiS_SetTVxposoffset(pScrn, val); } @@ -7235,8 +10850,8 @@ void SiS6326PostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) SiS_SetTVyposoffset(pScrn, val); } - /* TW: Switch on TV output. This is rather complicated, but - * if we don't do it, TV output will flicker terribly. + /* Switch on TV output. This is rather complicated, but + * if we don't do it, TV output will flicker terribly. */ if(pSiS->SiS6326Flags & SIS6326_TVON) { orSISIDXREG(SISSR, 0x01, 0x20); @@ -7265,8 +10880,8 @@ void SiS6326PostSetMode(ScrnInfoPtr pScrn, SISRegPtr sisReg) tmp = SiS6326GetTVReg(pScrn,0x00); if(!(tmp & 0x04)) return; - /* TW: Apply TV settings given by options */ - if((val = pSiS->sis6326antiflicker) != -1) { + /* Apply TV settings given by options */ + if((val = pSiS->sistvantiflicker) != -1) { SiS_SetSIS6326TVantiflicker(pScrn, val); } if((val = pSiS->sis6326enableyfilter) != -1) { @@ -7296,7 +10911,7 @@ SiSBridgeIsInSlaveMode(ScrnInfoPtr pScrn) } } -/* TW: Build a list of the VESA modes the BIOS reports as valid */ +/* Build a list of the VESA modes the BIOS reports as valid */ static void SiSBuildVesaModeList(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock *vbe) { @@ -7309,7 +10924,7 @@ SiSBuildVesaModeList(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock *vbe) int id = vbe->VideoModePtr[i++]; int bpp; - if ((mode = VBEGetModeInfo(pVbe, id)) == NULL) + if((mode = VBEGetModeInfo(pVbe, id)) == NULL) continue; bpp = mode->BitsPerPixel; @@ -7322,7 +10937,7 @@ SiSBuildVesaModeList(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock *vbe) m->next = pSiS->SISVESAModeList; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "BIOS reported VESA mode 0x%x: x:%i y:%i bpp:%i\n", + "BIOS supports VESA mode 0x%x: x:%i y:%i bpp:%i\n", m->n, m->width, m->height, m->bpp); pSiS->SISVESAModeList = m; @@ -7331,7 +10946,7 @@ SiSBuildVesaModeList(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock *vbe) } } -/* TW: Calc VESA mode from given resolution/depth */ +/* Calc VESA mode from given resolution/depth */ static UShort SiSCalcVESAModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode) { @@ -7353,6 +10968,16 @@ SiSCalcVESAModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode) mode->HDisplay, mode->VDisplay, pScrn->bitsPerPixel); switch(mode->HDisplay) { + case 320: + if(mode->VDisplay == 200) + ModeIndex = VESAModeIndex_320x200[i]; + else if(mode->VDisplay == 240) + ModeIndex = VESAModeIndex_320x240[i]; + break; + case 400: + if(mode->VDisplay == 300) + ModeIndex = VESAModeIndex_400x300[i]; + break; case 512: if(mode->VDisplay == 384) ModeIndex = VESAModeIndex_512x384[i]; @@ -7360,6 +10985,8 @@ SiSCalcVESAModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode) case 640: if(mode->VDisplay == 480) ModeIndex = VESAModeIndex_640x480[i]; + else if(mode->VDisplay == 400) + ModeIndex = VESAModeIndex_640x400[i]; break; case 800: if(mode->VDisplay == 600) @@ -7390,7 +11017,97 @@ SiSCalcVESAModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode) return(ModeIndex); } -/* TW: Calculate the vertical refresh rate from a mode */ +USHORT +SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, unsigned long VBFlags, BOOLEAN havecustommodes) +{ + SISPtr pSiS = SISPTR(pScrn); + UShort i = (pSiS->CurrentLayout.bitsPerPixel+7)/8 - 1; + + if(!(VBFlags & CRT1_LCDA)) { + if((havecustommodes) && (!(mode->type & M_T_DEFAULT))) { + return 0xfe; + } + } else { + if((mode->HDisplay > pSiS->LCDwidth) || + (mode->VDisplay > pSiS->LCDheight)) { + return 0; + } + } + + return(SiS_GetModeID(pSiS->VGAEngine, VBFlags, mode->HDisplay, mode->VDisplay, i, pSiS->FSTN)); +} + +USHORT +SiS_CheckCalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, unsigned long VBFlags, BOOLEAN havecustommodes) +{ + SISPtr pSiS = SISPTR(pScrn); + UShort i = (pSiS->CurrentLayout.bitsPerPixel+7)/8 - 1; + UShort ModeIndex = 0; + int j; + +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "Inside CheckCalcModeIndex (VBFlags %x, mode %dx%d)\n", + VBFlags,mode->HDisplay, mode->VDisplay); +#endif + + if(VBFlags & CRT2_LCD) { /* CRT2 is LCD */ + + if(pSiS->SiS_Pr->CP_HaveCustomData) { + for(j=0; j<7; j++) { + if((pSiS->SiS_Pr->CP_DataValid[j]) && + (mode->HDisplay == pSiS->SiS_Pr->CP_HDisplay[j]) && + (mode->VDisplay == pSiS->SiS_Pr->CP_VDisplay[j]) && + (mode->type & M_T_BUILTIN)) + return 0xfe; + } + } + + if((pSiS->AddedPlasmaModes) && (mode->type & M_T_BUILTIN)) + return 0xfe; + + if((havecustommodes) && + (!(mode->type & M_T_DEFAULT)) && + (!(mode->Flags & V_INTERLACE))) + return 0xfe; + + if( ((mode->HDisplay <= pSiS->LCDwidth) && + (mode->VDisplay <= pSiS->LCDheight)) || + ((pSiS->SiS_Pr->SiS_CustomT == CUT_PANEL848) && + (((mode->HDisplay == 1360) && (mode->HDisplay == 768)) || + ((mode->HDisplay == 1024) && (mode->HDisplay == 768)) || + ((mode->HDisplay == 800) && (mode->HDisplay == 600)))) ) { + + ModeIndex = SiS_GetModeID_LCD(pSiS->VGAEngine, VBFlags, mode->HDisplay, mode->VDisplay, i, + pSiS->FSTN, pSiS->SiS_Pr->SiS_CustomT, pSiS->LCDwidth, pSiS->LCDheight); + + } + + } else if(VBFlags & CRT2_TV) { /* CRT2 is TV */ + + ModeIndex = SiS_GetModeID_TV(pSiS->VGAEngine, VBFlags, mode->HDisplay, mode->VDisplay, i); + + } else if(VBFlags & CRT2_VGA) { /* CRT2 is VGA2 */ + + if((pSiS->AddedPlasmaModes) && (mode->type & M_T_BUILTIN)) + return 0xfe; + + if((havecustommodes) && + (!(mode->type & M_T_DEFAULT)) && + (!(mode->Flags & V_INTERLACE))) + return 0xfe; + + ModeIndex = SiS_GetModeID_VGA2(pSiS->VGAEngine, VBFlags, mode->HDisplay, mode->VDisplay, i); + + } else { /* CRT1 only, no CRT2 */ + + ModeIndex = SiS_CalcModeIndex(pScrn, mode, VBFlags, havecustommodes); + + } + + return(ModeIndex); +} + +/* Calculate the vertical refresh rate from a mode */ int SiSCalcVRate(DisplayModePtr mode) { @@ -7423,10 +11140,10 @@ SiSCalcVRate(DisplayModePtr mode) return((int)(refresh)); } -/* TW: Calculate CR33 (rate index) for CRT1. - * Calculation is done using currentmode, therefore it is - * recommended to set VertRefresh and HorizSync to correct - * values in config file. +/* Calculate CR33 (rate index) for CRT1. + * Calculation is done using currentmode, therefore it is + * recommended to set VertRefresh and HorizSync to correct + * values in config file. */ unsigned char SISSearchCRT1Rate(ScrnInfoPtr pScrn, DisplayModePtr mode) @@ -7441,8 +11158,8 @@ SISSearchCRT1Rate(ScrnInfoPtr pScrn, DisplayModePtr mode) irefresh = SiSCalcVRate(mode); if(!irefresh) { - if(xres == 800 || xres == 1024 || xres == 1280) return 0x02; - else return 0x01; + if(xres == 800 || xres == 1024 || xres == 1280) return 0x02; + else return 0x01; } /* SiS730 has troubles on CRT2 if CRT1 is at 32bpp */ @@ -7462,8 +11179,8 @@ SISSearchCRT1Rate(ScrnInfoPtr pScrn, DisplayModePtr mode) } #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "Debug: CalcVRate returned %d\n", irefresh); -#endif + xf86DrvMsg(0, X_INFO, "Debug: CalcVRate returned %d\n", irefresh); +#endif /* We need the REAL refresh rate here */ if(mode->Flags & V_INTERLACE) @@ -7471,8 +11188,8 @@ SISSearchCRT1Rate(ScrnInfoPtr pScrn, DisplayModePtr mode) /* Do not multiply by 2 when DBLSCAN! */ -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "Debug: Rate after correction = %d\n", irefresh); +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "Debug: Rate after correction = %d\n", irefresh); #endif index = 0; @@ -7491,6 +11208,9 @@ SISSearchCRT1Rate(ScrnInfoPtr pScrn, DisplayModePtr mode) index = sisx_vrate[i - 1].idx; } break; + } else if((irefresh - sisx_vrate[i].refresh) <= 2) { + index = sisx_vrate[i].idx; + break; } } } @@ -7499,7 +11219,7 @@ SISSearchCRT1Rate(ScrnInfoPtr pScrn, DisplayModePtr mode) if(index > 0) return index; else { - /* TW: Default Rate index */ + /* Default Rate index */ if(xres == 800 || xres == 1024 || xres == 1280) return 0x02; else return 0x01; } @@ -7515,10 +11235,13 @@ SISWaitRetraceCRT1(ScrnInfoPtr pScrn) inSISIDXREG(SISCR,0x17,temp); if(!(temp & 0x80)) return; - watchdog = 65536; - while((!(inSISREG(SISINPSTAT) & 0x08)) && --watchdog); + inSISIDXREG(SISSR,0x1f,temp); + if(temp & 0xc0) return; + watchdog = 65536; while((inSISREG(SISINPSTAT) & 0x08) && --watchdog); + watchdog = 65536; + while((!(inSISREG(SISINPSTAT) & 0x08)) && --watchdog); } void @@ -7528,12 +11251,17 @@ SISWaitRetraceCRT2(ScrnInfoPtr pScrn) int watchdog; unsigned char temp, reg; + if(SiSBridgeIsInSlaveMode(pScrn)) { + SISWaitRetraceCRT1(pScrn); + return; + } + switch(pSiS->VGAEngine) { case SIS_300_VGA: - reg = 0x28; + reg = 0x25; break; case SIS_315_VGA: - reg = 0x33; + reg = 0x30; break; default: return; @@ -7542,12 +11270,12 @@ SISWaitRetraceCRT2(ScrnInfoPtr pScrn) watchdog = 65536; do { inSISIDXREG(SISPART1, reg, temp); - if(temp & 0x80) break; + if(!(temp & 0x02)) break; } while(--watchdog); watchdog = 65536; do { inSISIDXREG(SISPART1, reg, temp); - if(!(temp & 0x80)) break; + if(temp & 0x02) break; } while(--watchdog); } @@ -7556,25 +11284,60 @@ SISWaitVBRetrace(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); + if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { #ifdef SISDUALHEAD - if(pSiS->DualHeadMode) { - if(pSiS->SecondHead) - SISWaitRetraceCRT1(pScrn); - else - SISWaitRetraceCRT2(pScrn); - } else { + if(pSiS->DualHeadMode) { + if(pSiS->SecondHead) + SISWaitRetraceCRT1(pScrn); + else + SISWaitRetraceCRT2(pScrn); + } else { #endif - if(pSiS->VBFlags & DISPTYPE_DISP1) { - SISWaitRetraceCRT1(pScrn); - } - if(pSiS->VBFlags & DISPTYPE_DISP2) { - if(!(SiSBridgeIsInSlaveMode(pScrn))) { - SISWaitRetraceCRT2(pScrn); - } - } + if(pSiS->VBFlags & DISPTYPE_DISP1) { + SISWaitRetraceCRT1(pScrn); + } + if(pSiS->VBFlags & DISPTYPE_DISP2) { + if(!(SiSBridgeIsInSlaveMode(pScrn))) { + SISWaitRetraceCRT2(pScrn); + } + } #ifdef SISDUALHEAD - } + } #endif + } else { + SISWaitRetraceCRT1(pScrn); + } +} + +#define MODEID_OFF 0x449 + +unsigned char +SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id) +{ + return(SiS_GetSetBIOSScratch(pScrn, MODEID_OFF, id)); +} + +unsigned char +SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, unsigned char value) +{ + unsigned char ret; + unsigned char *base; + + base = xf86MapVidMem(pScrn->scrnIndex, VIDMEM_MMIO, 0, 0x2000); + if(!base) { + SISErrorLog(pScrn, "(Could not map BIOS scratch area)\n"); + return 0; + } + + ret = *(base + offset); + + /* value != 0xff means: set register */ + if(value != 0xff) + *(base + offset) = value; + + xf86UnMapVidMem(pScrn->scrnIndex, base, 0x2000); + + return ret; } void @@ -7599,15 +11362,16 @@ sisSaveUnlockExtRegisterLock(SISPtr pSiS, unsigned char *reg1, unsigned char *re unsigned char val1, val2; int i; #endif - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR, - "Failed to unlock sr registers (%p, %x, 0x%02x; %d)\n", - pSiS, pSiS->RelIO, val, mylockcalls); + SISErrorLog(pSiS->pScrn, + "Failed to unlock sr registers (%p, %lx, 0x%02x; %ld)\n", + (void *)pSiS, (unsigned long)pSiS->RelIO, val, mylockcalls); #ifdef TWDEBUG for(i = 0; i <= 0x3f; i++) { inSISIDXREG(SISSR, i, val1); inSISIDXREG(0x3c4, i, val2); xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, - "SR%02d: RelIO=0x%02x 0x3c4=0x%02x (%d)\n", i, val1, val2, mylockcalls); + "SR%02d: RelIO=0x%02x 0x3c4=0x%02x (%d)\n", + i, val1, val2, mylockcalls); } #endif if((pSiS->VGAEngine == SIS_OLD_VGA) || (pSiS->VGAEngine == SIS_530_VGA)) { @@ -7626,9 +11390,9 @@ sisSaveUnlockExtRegisterLock(SISPtr pSiS, unsigned char *reg1, unsigned char *re outSISIDXREG(SISCR, 0x80, 0x86); inSISIDXREG(SISCR, 0x80, val); if(val != 0xA1) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR, - "Failed to unlock cr registers (%p, %x, 0x%02x)\n", - pSiS, pSiS->RelIO, val); + SISErrorLog(pSiS->pScrn, + "Failed to unlock cr registers (%p, %lx, 0x%02x)\n", + (void *)pSiS, (unsigned long)pSiS->RelIO, val); } } } diff --git a/src/sis_driver.h b/src/sis_driver.h index 8a53cae..4c085ef 100644 --- a/src/sis_driver.h +++ b/src/sis_driver.h @@ -1,8 +1,8 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.h,v 1.7 2003/02/04 02:44:29 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.h,v 1.27 2003/11/19 00:49:05 twini Exp $ */ /* - * sis_driver.h + * Global data and definitions * - * Copyright 2002 by Thomas Winischhofer, Vienna, Austria. + * Copyright 2002, 2003 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 @@ -22,30 +22,23 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Author: Thomas Winischhofer <thomas@winischhofer.net>: - * - 310/325 series (315/550/650/651/740/M650) support - * - new mode switching code for 300 and 310/325 series - * - many fixes for 300/540/630/730 chipsets, - * - many fixes for 5597/5598, 6326 and 530/620 chipsets, - * - VESA mode switching (deprecated), - * - extended CRT2/video bridge handling support, - * - dual head support on 300 and 310/325 series - * - 650/LVDS (up to 1400x1050), 650/Chrontel 701x support - * - 30xB/30xLV/30xLVX video bridge support (300, 310/325 series) - * - Xv support for 5597/5598, 6326, 530/620 and 310/325 series - * - video overlay enhancements for 300 series - * - etc. + * Author: Thomas Winischhofer <thomas@winischhofer.net> + * */ /* VESA */ -/* TW: The following is included because there are BIOSes out there that +/* The following is included because there are BIOSes out there that * report incomplete mode lists. These are 630 BIOS versions <2.01.2x * - * -) VBE 3.0 on SiS300 and 310/325 series do not support 24 fpp modes - * -) Only SiS310/325 series support 1920x1440x32 + * -) VBE 3.0 on SiS300 and 315 series do not support 24 fpp modes + * -) Only SiS315 series support 1920x1440x32 */ /* 8 16 (24) 32 */ +static const UShort VESAModeIndex_320x200[] = {0x138, 0x10e, 0x000, 0x000}; +static const UShort VESAModeIndex_320x240[] = {0x132, 0x135, 0x000, 0x000}; +static const UShort VESAModeIndex_400x300[] = {0x133, 0x136, 0x000, 0x000}; static const UShort VESAModeIndex_512x384[] = {0x134, 0x137, 0x000, 0x000}; +static const UShort VESAModeIndex_640x400[] = {0x100, 0x139, 0x000, 0x000}; static const UShort VESAModeIndex_640x480[] = {0x101, 0x111, 0x000, 0x13a}; static const UShort VESAModeIndex_800x600[] = {0x103, 0x114, 0x000, 0x13b}; static const UShort VESAModeIndex_1024x768[] = {0x105, 0x117, 0x000, 0x13c}; @@ -53,7 +46,7 @@ static const UShort VESAModeIndex_1280x1024[] = {0x107, 0x11a, 0x000, 0x13d}; static const UShort VESAModeIndex_1600x1200[] = {0x130, 0x131, 0x000, 0x13e}; static const UShort VESAModeIndex_1920x1440[] = {0x13f, 0x140, 0x000, 0x141}; -/* TW: For calculating refresh rate index (CR33) */ +/* For calculating refresh rate index (CR33) */ static const struct _sis_vrate { CARD16 idx; CARD16 xres; @@ -61,44 +54,48 @@ static const struct _sis_vrate { CARD16 refresh; BOOLEAN SiS730valid32bpp; } sisx_vrate[] = { + {1, 320, 200, 70, TRUE}, + {1, 320, 240, 60, TRUE}, + {1, 400, 300, 60, TRUE}, {1, 512, 384, 60, TRUE}, {1, 640, 400, 72, TRUE}, {1, 640, 480, 60, TRUE}, {2, 640, 480, 72, TRUE}, {3, 640, 480, 75, TRUE}, {4, 640, 480, 85, TRUE}, {5, 640, 480, 100, TRUE}, {6, 640, 480, 120, TRUE}, - {7, 640, 480, 160, TRUE}, {8, 640, 480, 200, TRUE}, + {7, 640, 480, 160, FALSE}, {8, 640, 480, 200, FALSE}, {1, 720, 480, 60, TRUE}, {1, 720, 576, 58, TRUE}, + {1, 768, 576, 58, TRUE}, {1, 800, 480, 60, TRUE}, {2, 800, 480, 75, TRUE}, {3, 800, 480, 85, TRUE}, {1, 800, 600, 56, TRUE}, {2, 800, 600, 60, TRUE}, {3, 800, 600, 72, TRUE}, {4, 800, 600, 75, TRUE}, {5, 800, 600, 85, TRUE}, {6, 800, 600, 105, TRUE}, - {7, 800, 600, 120, TRUE}, {8, 800, 600, 160, TRUE}, + {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, 1024, 768, 43, TRUE}, {2, 1024, 768, 60, TRUE}, {3, 1024, 768, 70, FALSE}, - {4, 1024, 768, 75, FALSE}, {5, 1024, 768, 85, TRUE}, {6, 1024, 768, 100, TRUE}, - {7, 1024, 768, 120, TRUE}, {1, 1024, 576, 60, TRUE}, {2, 1024, 576, 75, TRUE}, {3, 1024, 576, 85, TRUE}, {1, 1024, 600, 60, TRUE}, + {1, 1024, 768, 43, TRUE}, {2, 1024, 768, 60, TRUE}, {3, 1024, 768, 70, FALSE}, + {4, 1024, 768, 75, FALSE}, {5, 1024, 768, 85, TRUE}, {6, 1024, 768, 100, TRUE}, + {7, 1024, 768, 120, TRUE}, {1, 1152, 768, 60, TRUE}, - {1, 1152, 864, 75, TRUE}, {2, 1152, 864, 84, TRUE}, - {1, 1280, 720, 60, TRUE}, {2, 1280, 720, 75, TRUE}, {3, 1280, 720, 85, TRUE}, + {1, 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, 1024, 43, TRUE}, {2, 1280, 1024, 60, TRUE}, {3, 1280, 1024, 75, TRUE}, - {4, 1280, 1024, 85, 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}, {7, 1600, 1200, 120, TRUE}, - {1, 1920, 1440, 60, TRUE}, {2, 1920, 1440, 65, TRUE}, {3, 1920, 1440, 70, TRUE}, + {1, 1920, 1440, 60, TRUE}, {2, 1920, 1440, 65, TRUE}, {3, 1920, 1440, 70, TRUE}, {4, 1920, 1440, 75, TRUE}, {5, 1920, 1440, 85, TRUE}, {6, 1920, 1440, 100, TRUE}, {1, 2048, 1536, 60, TRUE}, {2, 2048, 1536, 65, TRUE}, {3, 2048, 1536, 70, TRUE}, {4, 2048, 1536, 75, TRUE}, {5, 2048, 1536, 85, TRUE}, {0, 0, 0, 0, FALSE} }; -/* TW: Some 300-series laptops have a badly designed BIOS and make it +/* Some 300-series laptops have a badly designed BIOS and make it * impossible to detect the correct panel delay compensation. This * table used to detect such machines by their PCI subsystem IDs; * however, I don't know how reliable this method is. (With Asus @@ -110,12 +107,112 @@ 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, "" , "" } }; -/* TW: Our TV modes for the 6326. The data in these structures +/* 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, "BARCO_1366" + }, + { SIS_630, "2.00.07", "09/27/2002-13:38:25", + 0x323FBD, + { 0x220, 0x227, 0x228, 0x229, 0x0ee }, + { 0x00, 0x5a, 0x64, 0x41, 0xef }, + 0x1039, 0x6300, + "Barco", "iQ G200L/300/400/500", CUT_BARCO1024, "BARCO_1024" + }, + { SIS_650, "", "", + 0, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x0e11, 0x083c, + "Inventec (Compaq)", "3017cl/3045US", CUT_COMPAQ12802, "COMPAQ_1280" + }, + { SIS_650, "", "", + 0, + { 0x00c, 0, 0, 0, 0 }, + { 'e' , 0, 0, 0, 0 }, + 0x1558, 0x0287, + "Clevo", "L285/L287 (Version 1)", CUT_CLEVO1024, "CLEVO_L28X_1" + }, + { SIS_650, "", "", + 0, + { 0x00c, 0, 0, 0, 0 }, + { 'y' , 0, 0, 0, 0 }, + 0x1558, 0x0287, + "Clevo", "L285/L287 (Version 2)", CUT_CLEVO10242, "CLEVO_L28X_2" + }, + { SIS_650, "", "", + 0, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1558, 0x0400, /* possibly 401 and 402 as well; not panelsize specific (?) */ + "Clevo", "D400S/D410S/D400H/D410H", CUT_CLEVO1400, "CLEVO_D4X0" + }, + { SIS_650, "", "", + 0, /* Shift LCD in LCD-via-CRT1 mode */ + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1558, 0x2263, + "Clevo", "D22ES/D27ES", CUT_UNIWILL1024, "CLEVO_D2X0ES" + }, + { SIS_650, "", "", + 0, /* Shift LCD in LCD-via-CRT1 mode */ + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1734, 0x101f, + "Uniwill", "N243S9", CUT_UNIWILL1024, "UNIWILL_N243S9" + }, + { SIS_650, "", "", + 0, /* Shift LCD in LCD-via-CRT1 mode */ + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1584, 0x5103, + "Uniwill", "N35BS1", CUT_UNIWILL10242, "UNIWILL_N35BS1" + }, + { SIS_650, "1.09.2c", "", /* Other versions, too? */ + 0, /* Shift LCD in LCD-via-CRT1 mode */ + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1019, 0x0f05, + "ECS", "A928", CUT_UNIWILL1024, "ECS_A928" + }, + { SIS_740, "1.11.27a", "", + 0, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0x1043, 0x1612, + "Asus", "L3000D/L3500D", CUT_ASUSL3000D, "ASUS_L3X00" + }, + { 4321, "", "", /* never autodetected */ + 0, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0, 0, + "Generic", "LVDS/Parallel 848x480", CUT_PANEL848, "PANEL848x480" + }, + { 0, "", "", + 0, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + 0, 0, + "", "", CUT_NONE, "" + } +}; + +/* Our TV modes for the 6326. The data in these structures * is mainly correct, but since we use our private CR and * clock values anyway, small errors do no matter. */ @@ -159,7 +256,7 @@ static DisplayModeRec SiS6326PAL800x600Mode = { 0.0 /* VRefresh */ }; -/* TW: Due to the scaling method this mode uses, the vertical data here +/* Due to the scaling method this mode uses, the vertical data here * does not match the CR data. But this does not matter, we use our * private CR data anyway. */ @@ -326,7 +423,7 @@ static DisplayModeRec SiS6326NTSC640x480Mode = { 0.0 /* VRefresh */ }; -/* TW: Due to the scaling method this mode uses, the vertical data here +/* Due to the scaling method this mode uses, the vertical data here * does not match the CR data. But this does not matter, we use our * private CR data anyway. */ @@ -413,7 +510,7 @@ static DisplayModeRec SiS6326NTSC640x400Mode = { 0.0 /* VRefresh */ }; -/* TW: Built-in hi-res modes for the 6326. +/* Built-in hi-res modes for the 6326. * For some reason, our default mode lines and the * clock calculation functions in sis_dac.c do no * good job on higher clocks. It seems, the hardware @@ -510,3 +607,471 @@ static DisplayModeRec SiS6326SIS1600x1200_60Mode = { 0.0 /* VRefresh */ }; +/* TV filters for SiS video bridges + */ +static const struct _SiSTVFilter301 { + unsigned char filter[7][4]; +} SiSTVFilter301[] = { + {{ {0x00,0xE0,0x10,0x60}, /* NTSCFilter - 320 */ + {0x00,0xEE,0x10,0x44}, + {0x00,0xF4,0x10,0x38}, + {0xF8,0xF4,0x18,0x38}, + {0xFC,0xFB,0x14,0x2A}, + {0x00,0x00,0x10,0x20}, + {0x00,0x04,0x10,0x18} }}, + {{ {0xF5,0xEE,0x1B,0x44}, /* NTSCFilter - 640 */ + {0xF8,0xF4,0x18,0x38}, + {0xEB,0x04,0x25,0x18}, + {0xF1,0x05,0x1F,0x16}, + {0xF6,0x06,0x1A,0x14}, + {0xFA,0x06,0x16,0x14}, + {0x00,0x04,0x10,0x18} }}, + {{ {0xEB,0x04,0x25,0x18}, /* NTSCFilter - 720 */ + {0xE7,0x0E,0x29,0x04}, + {0xEE,0x0C,0x22,0x08}, + {0xF6,0x0B,0x1A,0x0A}, + {0xF9,0x0A,0x17,0x0C}, + {0xFC,0x0A,0x14,0x0C}, + {0x00,0x08,0x10,0x10} }}, + {{ {0xEC,0x02,0x24,0x1C}, /* NTSCFilter - 800/400 */ + {0xF2,0x04,0x1E,0x18}, + {0xEB,0x15,0x25,0xF6}, + {0xF4,0x10,0x1C,0x00}, + {0xF8,0x0F,0x18,0x02}, + {0x00,0x04,0x10,0x18}, + {0x01,0x06,0x0F,0x14} }}, + {{ {0x00,0xE0,0x10,0x60}, /* PALFilter - 320 */ + {0x00,0xEE,0x10,0x44}, + {0x00,0xF4,0x10,0x38}, + {0xF8,0xF4,0x18,0x38}, + {0xFC,0xFB,0x14,0x2A}, + {0x00,0x00,0x10,0x20}, + {0x00,0x04,0x10,0x18} }}, + {{ {0xF5,0xEE,0x1B,0x44}, /* PALFilter - 640 */ + {0xF8,0xF4,0x18,0x38}, + {0xF1,0xF7,0x1F,0x32}, + {0xF5,0xFB,0x1B,0x2A}, + {0xF9,0xFF,0x17,0x22}, + {0xFB,0x01,0x15,0x1E}, + {0x00,0x04,0x10,0x18} }}, + {{ {0xF5,0xEE,0x1B,0x2A}, /* PALFilter - 720 */ + {0xEE,0xFE,0x22,0x24}, + {0xF3,0x00,0x1D,0x20}, + {0xF9,0x03,0x17,0x1A}, + {0xFB,0x02,0x14,0x1E}, + {0xFB,0x04,0x15,0x18}, + {0x00,0x06,0x10,0x14} }}, + {{ {0xF5,0xEE,0x1B,0x44}, /* PALFilter - 800/400 */ + {0xF8,0xF4,0x18,0x38}, + {0xFC,0xFB,0x14,0x2A}, + {0xEB,0x05,0x25,0x16}, + {0xF1,0x05,0x1F,0x16}, + {0xFA,0x07,0x16,0x12}, + {0x00,0x07,0x10,0x12} }} +}; + +static const struct _SiSTVFilter301B { + unsigned char filter[7][7]; +} SiSTVFilter301B[] = { + {{ {0x01,0x02,0xfb,0xf8,0x06,0x27,0x3a}, /* NTSC - 640 */ + {0x01,0x02,0xfe,0xf7,0x03,0x27,0x3c}, + {0x01,0x01,0x00,0xf6,0x00,0x28,0x40}, + {0xff,0x03,0x02,0xf6,0xfc,0x27,0x46}, + {0xff,0x01,0x04,0xf8,0xfa,0x27,0x46}, + {0xff,0x01,0x05,0xf9,0xf7,0x26,0x4a}, + {0xff,0xff,0x05,0xfc,0xf4,0x24,0x52} }}, + {{ {0x01,0x00,0xfb,0xfb,0x0b,0x25,0x32}, /* NTSC - 720 (?) */ + {0x01,0x01,0xfb,0xf9,0x09,0x26,0x36}, + {0x01,0x02,0xfc,0xf8,0x06,0x27,0x38}, + {0x01,0x02,0xfe,0xf7,0x03,0x27,0x3c}, + {0x01,0x03,0xff,0xf6,0x00,0x27,0x40}, + {0xff,0x03,0x02,0xf6,0xfe,0x27,0x42}, + {0xff,0x02,0x03,0xf7,0xfb,0x27,0x46} }}, + {{ {0x01,0xfe,0xfb,0xfe,0x0e,0x23,0x2e}, /* NTSC - 800 */ + {0x01,0xff,0xfb,0xfc,0x0c,0x25,0x30}, + {0x01,0x00,0xfb,0xfa,0x0a,0x26,0x34}, + {0x01,0x01,0xfc,0xf8,0x08,0x26,0x38}, + {0x01,0x02,0xfd,0xf7,0x06,0x27,0x38}, + {0x01,0x02,0xfe,0xf7,0x03,0x27,0x3c}, + {0xff,0x03,0x00,0xf6,0x00,0x27,0x42} }}, + {{ {0xff,0xfd,0xfe,0x05,0x11,0x1e,0x24}, /* NTSC - 1024 */ + {0xff,0xfd,0xfd,0x04,0x11,0x1f,0x26}, + {0xff,0xfd,0xfc,0x02,0x10,0x22,0x28}, + {0xff,0xff,0xfc,0x00,0x0f,0x22,0x28}, + {0x01,0xfe,0xfb,0xff,0x0e,0x23,0x2c}, + {0x01,0xff,0xfb,0xfd,0x0d,0x24,0x2e}, + {0x01,0xff,0xfb,0xfb,0x0c,0x25,0x32} }}, + {{ {0x01,0x02,0xfb,0xf8,0x06,0x27,0x3a}, /* PAL - 640 */ + {0x01,0x02,0xfe,0xf7,0x03,0x27,0x3c}, + {0x01,0x01,0x00,0xf6,0x00,0x28,0x40}, + {0xff,0x03,0x02,0xf6,0xfc,0x27,0x46}, + {0xff,0x01,0x04,0xf8,0xfa,0x27,0x46}, + {0xff,0x01,0x05,0xf9,0xf7,0x26,0x4a}, + {0xff,0xff,0x05,0xfc,0xf4,0x24,0x52} }}, + {{ {0x01,0x00,0xfb,0xfb,0x0b,0x25,0x32}, /* PAL - 720/768 */ + {0x01,0x01,0xfb,0xf9,0x09,0x26,0x36}, + {0x01,0x02,0xfc,0xf8,0x06,0x27,0x38}, + {0x01,0x02,0xfe,0xf7,0x03,0x27,0x3c}, + {0x01,0x03,0xff,0xf6,0x00,0x27,0x40}, + {0xff,0x03,0x02,0xf6,0xfe,0x27,0x42}, + {0xff,0x02,0x03,0xf7,0xfb,0x27,0x46} }}, + {{ {0x01,0xfe,0xfb,0xfe,0x0e,0x23,0x2e}, /* PAL - 800 */ + {0x01,0xff,0xfb,0xfc,0x0c,0x25,0x30}, + {0x01,0x00,0xfb,0xfa,0x0a,0x26,0x34}, + {0x01,0x01,0xfc,0xf8,0x08,0x26,0x38}, + {0x01,0x02,0xfd,0xf7,0x06,0x27,0x38}, + {0x01,0x02,0xfe,0xf7,0x03,0x27,0x3c}, + {0xff,0x03,0x00,0xf6,0x00,0x27,0x42} }}, + {{ {0xff,0xfd,0xfe,0x05,0x11,0x1e,0x24}, /* PAL - 1024 */ + {0xff,0xfd,0xfd,0x04,0x11,0x1f,0x26}, + {0xff,0xfd,0xfc,0x02,0x10,0x22,0x28}, + {0xff,0xff,0xfc,0x00,0x0f,0x22,0x28}, + {0x01,0xfe,0xfb,0xff,0x0e,0x23,0x2c}, + {0x01,0xff,0xfb,0xfd,0x0d,0x24,0x2e}, + {0x01,0xff,0xfb,0xfb,0x0c,0x25,0x32} }} +}; + +/* TV scaling data for SiS video bridges + */ +typedef struct _SiSTVVScale { + unsigned short ScaleVDE; + int sindex; + unsigned short RealVDE; +#if 0 + unsigned short HT, HRS, HRE, VT, VRS, VRE; + unsigned short NFF, HCFACT, HCMAX, VBHT, VBVT, VBHRS; + unsigned short HT300, HRS300, HRE300, VT300, VRS300, VRE300; + unsigned short NFF300, HCFACT300, HCMAX300, VBHT300, VBVT300, VBHRS300; +#endif + unsigned short reg[24]; +} MySiSTVVScale, *MySiSTVVScalePtr; + +static const MySiSTVVScale SiSTVVScale[] = { + { 0x01D6, 3, 480, /* NTSC 640 */ + { 0x037C, 0x02B0, 0x00EF, 0x01FA, 0x01E7, 0x01E9, + 0x0000, 0x004C, 0x008F, 0x037C, 0x01FB, 0x00D4, + 0x037C, 0x02CB, 0x0049, 0x01FB, 0x01EE, 0x01F0, + 0x0000, 0x004C, 0x008F, 0x037C, 0x01FB, 0x00E0 } + }, + { 0x01CC, 2, 480, + { 0x0369, 0x02AD, 0x00E7, 0x01FF, 0x01E8, 0x01EB, + 0x0000, 0x004C, 0x008F, 0x0369, 0x0200, 0x00D4, + 0x0369, 0x02C6, 0x003A, 0x0200, 0x01F0, 0x01F3, + 0x0000, 0x004C, 0x008F, 0x0369, 0x0200, 0x00E0 } + }, + { 0x01C2, 1, 480, + { 0x0356, 0x02AB, 0x00E0, 0x0204, 0x01E9, 0x01EC, + 0x0000, 0x004C, 0x008F, 0x0356, 0x0205, 0x00D4, + 0x0356, 0x02C1, 0x002B, 0x0205, 0x01F3, 0x01F6, + 0x0000, 0x004C, 0x008F, 0x0356, 0x0205, 0x00E0 } + }, + { 0x01B8, 0, 480, /* default */ + { 0x0343, 0x02A9, 0x00DA, 0x0209, 0x01EA, 0x01ED, + 0x0000, 0x004C, 0x008F, 0x0343, 0x020A, 0x00D4, + 0x0343, 0x02BD, 0x001F, 0x020A, 0x01F5, 0x01F8, + 0x0000, 0x004C, 0x008F, 0x0343, 0x020A, 0x00E0 } + }, + { 0x01AE, -1, 480, + { 0x035B, 0x02AC, 0x00E3, 0x020E, 0x01EC, 0x01F0, + 0x0000, 0x0050, 0x008F, 0x035B, 0x020F, 0x0152, + 0x035B, 0x02C3, 0x0031, 0x020F, 0x01F8, 0x01FC, + 0x0000, 0x0050, 0x008F, 0x035B, 0x020F, 0x015E } + }, + { 0x01A4, -2, 480, + { 0x0347, 0x02A9, 0x00DB, 0x0213, 0x01ED, 0x01F1, + 0x0000, 0x0050, 0x008F, 0x0347, 0x0214, 0x0102, + 0x0347, 0x02BE, 0x0022, 0x0214, 0x01FA, 0x01FE, + 0x0000, 0x0050, 0x008F, 0x0347, 0x0214, 0x010E } + }, + { 0x019A, -3, 480, + { 0x0333, 0x02A7, 0x00D4, 0x0218, 0x01EE, 0x01F2, + 0x0000, 0x0050, 0x008F, 0x0333, 0x0219, 0x016A, + 0x0333, 0x02B9, 0x0013, 0x0219, 0x01FD, 0x0201, + 0x0000, 0x0050, 0x008F, 0x0333, 0x0219, 0x016A } + }, + { 0x01D6, 3, 480, /* NTSC 720 */ + { 0x037C, 0x0307, 0x005D, 0x01FB, 0x01EE, 0x01F0, + 0x0000, 0x004C, 0x008F, 0x037C, 0x01FB, 0x0090 } + }, + { 0x01CC, 2, 480, + { 0x0369, 0x0302, 0x004E, 0x0200, 0x01F0, 0x01F3, + 0x0000, 0x004C, 0x008F, 0x0369, 0x0200, 0x0090 } + }, + { 0x01C2, 1, 480, + { 0x0356, 0x02FD, 0x003F, 0x0205, 0x01F3, 0x01F6, + 0x0000, 0x004C, 0x008F, 0x0356, 0x0205, 0x0090 } + }, + { 0x01B8, 0, 480, /* default */ + { 0x0343, 0x02F9, 0x0033, 0x020A, 0x01F5, 0x01F8, + 0x0000, 0x004C, 0x008F, 0x0343, 0x020A, 0x0090 } + }, + { 0x01AE, -1, 480, + { 0x035B, 0x02FF, 0x0045, 0x020F, 0x01F8, 0x01FC, + 0x0000, 0x0050, 0x008F, 0x035B, 0x020F, 0x010E } + }, + { 0x01A4, -2, 480, + { 0x0347, 0x02FA, 0x0036, 0x0214, 0x01FA, 0x01FE, + 0x0000, 0x0050, 0x008F, 0x0347, 0x0214, 0x00BE } + }, + { 0x019A, -3, 480, + { 0x0333, 0x02F5, 0x0027, 0x0219, 0x01FD, 0x0201, + 0x0000, 0x0050, 0x008F, 0x0333, 0x0219, 0x0136 } + }, + { 0x01D6, 3, 600, /* NTSC 800 */ + { 0x0438, 0x0353, 0x0099, 0x0272, 0x025F, 0x0261, + 0x0000, 0x0073, 0x008F, 0x0438, 0x0273, 0x020A, + 0x0438, 0x0372, 0x00FE, 0x0273, 0x0266, 0x0268, + 0x0000, 0x0073, 0x008F, 0x0438, 0x0273, 0x020A } + }, + { 0x01CC, 2, 600, + { 0x0421, 0x0350, 0x0090, 0x0277, 0x0260, 0x0263, + 0x0000, 0x0073, 0x008F, 0x0421, 0x0278, 0x020A, + 0x0421, 0x036C, 0x00EC, 0x0278, 0x0268, 0x026B, + 0x0000, 0x0073, 0x008F, 0x0421, 0x0278, 0x020A } + }, + { 0x01C2, 1, 600, + { 0x0413, 0x034F, 0x008C, 0x027C, 0x0261, 0x0264, + 0x0000, 0x0074, 0x008F, 0x0413, 0x027D, 0x01FE, + 0x0413, 0x0369, 0x00E3, 0x027D, 0x026B, 0x026E, + 0x0000, 0x0074, 0x008F, 0x0413, 0x027D, 0x020C } + }, + { 0x01B8, 0, 600, /* default */ + { 0x041F, 0x0350, 0x0090, 0x0281, 0x0262, 0x0265, + 0x0000, 0x0078, 0x008F, 0x041F, 0x0282, 0x0220, + 0x041F, 0x036C, 0x00EC, 0x0282, 0x026D, 0x0270, + 0x0001, 0x0078, 0x008F, 0x041F, 0x0282, 0x0220 } + }, + { 0x01AE, -1, 600, + { 0x0407, 0x034D, 0x0087, 0x0286, 0x0264, 0x0268, + 0x0000, 0x0078, 0x008F, 0x0407, 0x0287, 0x0220, + 0x0407, 0x0366, 0x00DA, 0x0287, 0x0270, 0x0274, + 0x0001, 0x0078, 0x008F, 0x0407, 0x0287, 0x0220 } + }, + { 0x01A4, -2, 600, + { 0x03EF, 0x034A, 0x007E, 0x028B, 0x0265, 0x0269, + 0x0000, 0x0078, 0x008F, 0x03EF, 0x028C, 0x0220, + 0x03EF, 0x0360, 0x00C8, 0x028C, 0x0272, 0x0276, + 0x0001, 0x0078, 0x008F, 0x03EF, 0x028C, 0x0220 } + }, + { 0x019A, -3, 600, + { 0x0429, 0x0351, 0x0093, 0x0290, 0x0266, 0x026A, + 0x0000, 0x0082, 0x008F, 0x0429, 0x0291, 0x024E, + 0x0429, 0x036E, 0x00F2, 0x0291, 0x0275, 0x0279, + 0x0001, 0x0082, 0x008F, 0x0429, 0x0291, 0x024E } + }, + { 0x0230, 3, 480, /* PAL 640 */ + { 0x0371, 0x02AE, 0x00EA, 0x01FF, 0x01E8, 0x01EB, + 0x0000, 0x0007, 0x0010, 0x0371, 0x0200, 0x0032, + 0x0371, 0x02C8, 0x0040, 0x0200, 0x01F0, 0x01F3, + 0x0000, 0x000E, 0x0020, 0x0371, 0x0200, 0x0032 } + }, + { 0x0226, 2, 480, + { 0x0383, 0x02B1, 0x00F2, 0x0204, 0x01E9, 0x01EC, + 0x0000, 0x0005, 0x000B, 0x0383, 0x0205, 0x0032, + 0x0383, 0x02CD, 0x004F, 0x0205, 0x01F3, 0x01F6, + 0x0000, 0x0005, 0x000B, 0x0383, 0x0205, 0x0032 } + }, + { 0x021C, 1, 480, + { 0x035F, 0x02AC, 0x00E4, 0x0209, 0x01EA, 0x01ED, + 0x0000, 0x0004, 0x0009, 0x035F, 0x020A, 0x0032, + 0x035F, 0x02C4, 0x0034, 0x020A, 0x01F5, 0x01F8, + 0x0000, 0x0004, 0x0009, 0x035F, 0x020A, 0x0032 } + }, + { 0x0212, 0, 480, /* default */ + { 0x034F, 0x02AA, 0x00DE, 0x020E, 0x01EC, 0x01F0, + 0x0000, 0x0004, 0x0009, 0x034F, 0x020F, 0x0032, + 0x034F, 0x02C0, 0x0028, 0x020F, 0x01F8, 0x01FC, + 0x0000, 0x0004, 0x0009, 0x034F, 0x020F, 0x0032 } + }, + { 0x0208, -1, 480, + { 0x033F, 0x02A8, 0x00D8, 0x0213, 0x01ED, 0x01F1, + 0x0000, 0x0004, 0x0009, 0x033F, 0x0214, 0x0032, + 0x033F, 0x02BC, 0x001C, 0x0214, 0x01FA, 0x01FE, + 0x0000, 0x0004, 0x0009, 0x033F, 0x0214, 0x0032 } + }, + { 0x01FE, -2, 480, + { 0x0395, 0x02B3, 0x00F8, 0x0218, 0x01EE, 0x01F2, + 0x0000, 0x0001, 0x0002, 0x0395, 0x0219, 0x0032, + 0x0395, 0x02D1, 0x005B, 0x0219, 0x01FD, 0x0201, + 0x0000, 0x0001, 0x0002, 0x0395, 0x0219, 0x0032 } + }, + { 0x01F4, -3, 480, + { 0x0383, 0x02B1, 0x00F2, 0x021D, 0x01EF, 0x01F3, + 0x0000, 0x0001, 0x0002, 0x0383, 0x021E, 0x0032, + 0x0383, 0x02CD, 0x004F, 0x021E, 0x01FF, 0x0203, + 0x0000, 0x0001, 0x0002, 0x0383, 0x021E, 0x0032 } + }, + { 0x0230, 2, 576, /* PAL 720 */ + { 0x03BF, 0x0318, 0x0090, 0x0260, 0x0250, 0x0253, + 0x0000, 0x0004, 0x0007, 0x03BF, 0x0260, 0x00E0, + 0x6954, 0x6C6C, 0x5320, 0x666F, 0x6169, 0x4220, + 0x7265, 0x746E, 0x7373, 0x6E6F, 0x0260, 0x00E0 } + }, + { 0x0226, 1, 576, + { 0x03DD, 0x031F, 0x00A5, 0x0265, 0x0253, 0x0256, + 0x0000, 0x0003, 0x0005, 0x03DD, 0x0265, 0x013B, + 0x7242, 0x756F, 0x6867, 0x2074, 0x6F74, 0x7920, + 0x756F, 0x6220, 0x2079, 0x6F6E, 0x2074, 0x2061 } + }, + { 0x021C, 0, 576, /* default */ + { 0x0437, 0x0336, 0x00EA, 0x026A, 0x0255, 0x0258, + 0x0000, 0x0002, 0x0003, 0x0437, 0x026A, 0x0180, + 0x656D, 0x6572, 0x5720, 0x7A69, 0x7261, 0x2064, + 0x7562, 0x2074, 0x6874, 0x2065, 0x0274, 0x01CE } + }, + { 0x0212, -1, 576, + { 0x0423, 0x0331, 0x00DB, 0x026F, 0x0258, 0x025C, + 0x0001, 0x0002, 0x0003, 0x0423, 0x026F, 0x01CA, + 0x6957, 0x617A, 0x6472, 0x4520, 0x7478, 0x6172, + 0x726F, 0x6964, 0x616E, 0x7269, 0x3A65, 0x01CE } + }, + { 0x0208, -2, 576, + { 0x040F, 0x032C, 0x00CC, 0x0274, 0x025A, 0x025E, + 0x0000, 0x0002, 0x0003, 0x040F, 0x0274, 0x01CA, + 0x6854, 0x6D6F, 0x7361, 0x5720, 0x6E69, 0x7369, + 0x6863, 0x6F68, 0x6566, 0x2172, 0x027E, 0x01CA } + }, + { 0x01FE, -3, 576, + { 0x03FB, 0x0327, 0x00BD, 0x0279, 0x025D, 0x0261, + 0x0000, 0x0002, 0x0003, 0x03FB, 0x0279, 0x01CA, + } + }, + { 0x01F4, -4, 576, + { 0x03E7, 0x0322, 0x00AE, 0x027E, 0x025F, 0x0263, + 0x0000, 0x0002, 0x0003, 0x03E7, 0x027E, 0x01CA, + 0x6854, 0x7369, 0x7320, 0x6170, 0x6563, 0x6620, + 0x726F, 0x7320, 0x6C61, 0x0365, 0x027F, 0x01FE } + }, + { 0x0230, 3, 600, /* PAL 800 */ + { 0x047F, 0x035C, 0x00B4, 0x0277, 0x0260, 0x0263, + 0x0000, 0x0005, 0x0007, 0x047F, 0x0278, 0x0170, + 0x047F, 0x0384, 0x0034, 0x0278, 0x0268, 0x026B, + 0x0000, 0x0005, 0x0007, 0x047F, 0x0278, 0x017E } + }, + { 0x0226, 2, 600, + { 0x044B, 0x0356, 0x00A1, 0x027C, 0x0261, 0x0264, + 0x0000, 0x0019, 0x0024, 0x044B, 0x027D, 0x0150, + 0x044B, 0x0377, 0x000D, 0x027D, 0x026B, 0x026E, + 0x0000, 0x0019, 0x0024, 0x044B, 0x027D, 0x015E } + }, + { 0x021C, 1, 600, + { 0x0437, 0x0353, 0x0099, 0x0281, 0x0262, 0x0265, + 0x0000, 0x0019, 0x0024, 0x0437, 0x0282, 0x0150, + 0x0437, 0x0372, 0x00FE, 0x0282, 0x026D, 0x0270, + 0x0000, 0x0019, 0x0024, 0x0437, 0x0282, 0x015E } + }, + { 0x0212, 0, 600, /* default */ + { 0x0423, 0x0351, 0x0092, 0x0286, 0x0264, 0x0268, + 0x0000, 0x0019, 0x0024, 0x0423, 0x0287, 0x01C8, + 0x0423, 0x036D, 0x00EF, 0x0287, 0x0270, 0x0274, + 0x0000, 0x0019, 0x0024, 0x0423, 0x0287, 0x01D6 } + }, + { 0x0208, -1, 600, + { 0x040F, 0x034E, 0x008A, 0x028B, 0x0265, 0x0269, + 0x0000, 0x0019, 0x0024, 0x040F, 0x028C, 0x01A0, + 0x040F, 0x0368, 0x00E0, 0x028C, 0x0272, 0x0276, + 0x0000, 0x0019, 0x0024, 0x040F, 0x028C, 0x01AE } + }, + { 0x01FE, -2, 600, + { 0x03FB, 0x034C, 0x0083, 0x0290, 0x0266, 0x026A, + 0x0000, 0x0019, 0x0024, 0x03FB, 0x0291, 0x01C8, + 0x03FB, 0x0363, 0x00D1, 0x0291, 0x0275, 0x0279, + 0x0000, 0x0019, 0x0024, 0x03FB, 0x0291, 0x01D6 } + }, + { 0x01F4, -3, 600, + { 0x0437, 0x0353, 0x0099, 0x0295, 0x0267, 0x026B, + 0x0000, 0x0003, 0x0004, 0x0437, 0x0296, 0x01BF, + 0x0437, 0x0372, 0x00FE, 0x0296, 0x0277, 0x027B, + 0x0000, 0x0003, 0x0004, 0x0437, 0x0296, 0x01BA } + }, +}; + +unsigned const char SiSScalingP1Regs[] = { + 0x08,0x09,0x0b,0x0c,0x0d,0x0e,0x10,0x11,0x12 +}; +unsigned const char SiSScalingP4Regs[] = { + 0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b +}; + +/* 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); +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); +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 + +extern USHORT SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, BOOL FSTN); +extern USHORT SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, + BOOLEAN FSTN, USHORT CustomT, int LCDwith, int LCDheight); +extern USHORT SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth); +extern USHORT SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth); +extern int SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber); +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); + +/* 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 bd8be86..add8168 100644 --- a/src/sis_opt.c +++ b/src/sis_opt.c @@ -1,9 +1,10 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c,v 1.15 2003/02/04 02:44:29 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c,v 1.45 2003/11/11 18:04:31 twini Exp $ */ /* - * * SiS driver option evaluation * - * Parts Copyright 2001, 2002 by Thomas Winischhofer, Vienna, Austria + * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * + * Based on code by ? (included in XFree86 4.1) * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -23,8 +24,8 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Authors: ? - * Thomas Winischhofer <thomas@winischhofer.net> + * Authors: Thomas Winischhofer <thomas@winischhofer.net> + * ? */ #include "xf86.h" @@ -34,30 +35,33 @@ #include "sis.h" +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_SHADOW_FB, + OPTION_DRI, + OPTION_AGP_SIZE, + OPTION_AGP_SIZE2, OPTION_ROTATE, OPTION_NOXVIDEO, OPTION_VESA, OPTION_MAXXFBMEM, OPTION_FORCECRT1, - OPTION_DSTN, OPTION_XVONCRT2, OPTION_PDC, OPTION_TVSTANDARD, OPTION_USEROMDATA, OPTION_NOINTERNALMODES, OPTION_USEOEM, - OPTION_SBIOSN, OPTION_NOYV12, OPTION_CHTVOVERSCAN, OPTION_CHTVSOVERSCAN, @@ -72,67 +76,173 @@ typedef enum { OPTION_SISTVEDGEENHANCE, OPTION_SISTVANTIFLICKER, OPTION_SISTVSATURATION, + OPTION_SISTVCHROMAFILTER, + OPTION_SISTVLUMAFILTER, + OPTION_SISTVCOLCALIBFINE, + OPTION_SISTVCOLCALIBCOARSE, OPTION_TVXPOSOFFSET, OPTION_TVYPOSOFFSET, + OPTION_TVXSCALE, + OPTION_TVYSCALE, OPTION_SIS6326ANTIFLICKER, OPTION_SIS6326ENABLEYFILTER, OPTION_SIS6326YFILTERSTRONG, + OPTION_SIS6326FORCETVPPLUG, + OPTION_SIS6326FSCADJUST, OPTION_CHTVTYPE, OPTION_USERGBCURSOR, OPTION_USERGBCURSORBLEND, OPTION_USERGBCURSORBLENDTH, - OPTION_RESTOREBYSET + OPTION_RESTOREBYSET, + OPTION_NODDCFORCRT2, + OPTION_FORCECRT2REDETECTION, + OPTION_CRT1GAMMA, + OPTION_CRT2GAMMA, + OPTION_XVGAMMA, + OPTION_XVDEFCONTRAST, + OPTION_XVDEFBRIGHTNESS, + OPTION_XVDEFHUE, + OPTION_XVDEFSATURATION, + OPTION_XVDEFDISABLEGFX, + OPTION_XVDEFDISABLEGFXLR, + OPTION_XVMEMCPY, + OPTION_XVUSECHROMAKEY, + OPTION_XVCHROMAMIN, + OPTION_XVCHROMAMAX, + OPTION_XVDISABLECOLORKEY, + OPTION_XVINSIDECHROMAKEY, + OPTION_XVYUVCHROMAKEY, + OPTION_SCALELCD, + OPTION_SPECIALTIMING, + OPTION_LVDSHL, + OPTION_ENABLEHOTKEY, + OPTION_MERGEDFB, + OPTION_MERGEDFBAUTO, + OPTION_CRT2HSYNC, + OPTION_CRT2VREFRESH, + OPTION_CRT2POS, + OPTION_METAMODES, + OPTION_MERGEDFB2, + OPTION_CRT2HSYNC2, + OPTION_CRT2VREFRESH2, + OPTION_CRT2POS2, + OPTION_NOSISXINERAMA, + OPTION_NOSISXINERAMA2, + OPTION_CRT2ISSCRN0, + OPTION_MERGEDDPI, + OPTION_ENABLESISCTRL, + OPTION_STOREDBRI, + OPTION_STOREDPBRI, +#ifdef SIS_CP + SIS_CP_OPT_OPTIONS +#endif + OPTION_PSEUDO } SISOpts; 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_FORCE_CRT2TYPE, "ForceCRT2Type", OPTV_ANYSTR, {0}, FALSE }, - { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {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_DSTN, "DSTN", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_XVONCRT2, "XvOnCRT2", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_PDC, "PanelDelayCompensation", OPTV_INTEGER, {0}, -1 }, - { OPTION_TVSTANDARD, "TVStandard", OPTV_STRING, {0}, -1 }, - { OPTION_USEROMDATA, "UseROMData", OPTV_BOOLEAN, {0}, -1 }, - { OPTION_NOINTERNALMODES, "NoInternalModes", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_USEOEM, "UseOEMData", OPTV_BOOLEAN, {0}, -1 }, - { OPTION_SBIOSN, "BIOSFile", OPTV_STRING, {0}, FALSE }, - { OPTION_NOYV12, "NoYV12", OPTV_BOOLEAN, {0}, -1 }, - { OPTION_CHTVTYPE, "CHTVType", OPTV_BOOLEAN, {0}, -1 }, - { OPTION_CHTVOVERSCAN, "CHTVOverscan", OPTV_BOOLEAN, {0}, -1 }, - { OPTION_CHTVSOVERSCAN, "CHTVSuperOverscan", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_TURBOQUEUE, "TurboQueue", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FAST_VRAM, "FastVram", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NOHOSTBUS, "NoHostBus", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_RENDER, "RenderAcceleration", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FORCE_CRT1TYPE, "ForceCRT1Type", OPTV_STRING, {0}, FALSE }, + { OPTION_FORCE_CRT2TYPE, "ForceCRT2Type", OPTV_STRING, {0}, FALSE }, + { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {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_TVSTANDARD, "TVStandard", OPTV_STRING, {0}, -1 }, + { OPTION_USEROMDATA, "UseROMData", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_NOINTERNALMODES, "NoInternalModes", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_USEOEM, "UseOEMData", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_NOYV12, "NoYV12", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_CHTVTYPE, "CHTVType", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_CHTVOVERSCAN, "CHTVOverscan", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_CHTVSOVERSCAN, "CHTVSuperOverscan", OPTV_BOOLEAN, {0}, -1 }, { OPTION_CHTVLUMABANDWIDTHCVBS, "CHTVLumaBandwidthCVBS", OPTV_INTEGER, {0}, -1 }, { OPTION_CHTVLUMABANDWIDTHSVIDEO, "CHTVLumaBandwidthSVIDEO",OPTV_INTEGER, {0}, -1 }, { OPTION_CHTVLUMAFLICKERFILTER, "CHTVLumaFlickerFilter", OPTV_INTEGER, {0}, -1 }, { OPTION_CHTVCHROMABANDWIDTH, "CHTVChromaBandwidth", OPTV_INTEGER, {0}, -1 }, { OPTION_CHTVCHROMAFLICKERFILTER, "CHTVChromaFlickerFilter",OPTV_INTEGER, {0}, -1 }, - { OPTION_CHTVCVBSCOLOR, "CHTVCVBSColor", OPTV_BOOLEAN, {0}, -1 }, - { OPTION_CHTVTEXTENHANCE, "CHTVTextEnhance", OPTV_INTEGER, {0}, -1 }, - { OPTION_CHTVCONTRAST, "CHTVContrast", OPTV_INTEGER, {0}, -1 }, - { OPTION_SISTVEDGEENHANCE, "SISTVEdgeEnhance", OPTV_INTEGER, {0}, -1 }, - { OPTION_SISTVANTIFLICKER, "SISTVAntiFlicker", OPTV_INTEGER, {0}, -1 }, - { OPTION_SISTVSATURATION, "SISTVSaturation", OPTV_INTEGER, {0}, -1 }, - { OPTION_TVXPOSOFFSET, "TVXPosOffset", OPTV_INTEGER, {0}, -1 }, - { OPTION_TVYPOSOFFSET, "TVYPosOffset", OPTV_INTEGER, {0}, -1 }, + { OPTION_CHTVCVBSCOLOR, "CHTVCVBSColor", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_CHTVTEXTENHANCE, "CHTVTextEnhance", OPTV_INTEGER, {0}, -1 }, + { OPTION_CHTVCONTRAST, "CHTVContrast", OPTV_INTEGER, {0}, -1 }, + { OPTION_SISTVEDGEENHANCE, "SISTVEdgeEnhance", OPTV_INTEGER, {0}, -1 }, + { OPTION_SISTVANTIFLICKER, "SISTVAntiFlicker", OPTV_STRING, {0}, FALSE }, + { OPTION_SISTVSATURATION, "SISTVSaturation", OPTV_INTEGER, {0}, -1 }, + { OPTION_SISTVCHROMAFILTER, "SISTVCFilter", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_SISTVLUMAFILTER, "SISTVYFilter", OPTV_INTEGER, {0}, -1 }, + { OPTION_SISTVCOLCALIBFINE, "SISTVColorCalibFine", OPTV_INTEGER, {0}, -1 }, + { OPTION_SISTVCOLCALIBCOARSE, "SISTVColorCalibCoarse", OPTV_INTEGER, {0}, -1 }, + { OPTION_TVXSCALE, "SISTVXScale", OPTV_INTEGER, {0}, -1 }, + { OPTION_TVYSCALE, "SISTVYScale", OPTV_INTEGER, {0}, -1 }, + { OPTION_TVXPOSOFFSET, "TVXPosOffset", OPTV_INTEGER, {0}, -1 }, + { OPTION_TVYPOSOFFSET, "TVYPosOffset", OPTV_INTEGER, {0}, -1 }, { OPTION_SIS6326ANTIFLICKER, "SIS6326TVAntiFlicker", OPTV_STRING, {0}, FALSE }, { OPTION_SIS6326ENABLEYFILTER, "SIS6326TVEnableYFilter", OPTV_BOOLEAN, {0}, -1 }, { OPTION_SIS6326YFILTERSTRONG, "SIS6326TVYFilterStrong", OPTV_BOOLEAN, {0}, -1 }, - { OPTION_USERGBCURSOR, "UseColorHWCursor", OPTV_BOOLEAN, {0}, -1 }, - { OPTION_USERGBCURSORBLEND, "ColorHWCursorBlending", OPTV_BOOLEAN, {0}, -1 }, - { OPTION_USERGBCURSORBLENDTH, "ColorHWCursorBlendThreshold", OPTV_INTEGER, {0}, -1 }, - { OPTION_RESTOREBYSET, "RestoreBySetMode", OPTV_BOOLEAN, {0}, -1 }, - { -1, NULL, OPTV_NONE, {0}, FALSE } + { OPTION_SIS6326FORCETVPPLUG, "SIS6326TVForcePlug", OPTV_STRING, {0}, -1 }, + { 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_RESTOREBYSET, "RestoreBySetMode", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_NODDCFORCRT2, "NoCRT2Detection", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_FORCECRT2REDETECTION, "ForceCRT2ReDetection", 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 }, + { OPTION_XVDEFSATURATION, "XvDefaultSaturation", OPTV_INTEGER, {0}, -1 }, + { OPTION_XVDEFDISABLEGFX, "XvDefaultDisableGfx", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_XVDEFDISABLEGFXLR, "XvDefaultDisableGfxLR", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_XVCHROMAMIN, "XvChromaMin", OPTV_INTEGER, {0}, -1 }, + { OPTION_XVCHROMAMAX, "XvChromaMax", OPTV_INTEGER, {0}, -1 }, + { OPTION_XVUSECHROMAKEY, "XvUseChromaKey", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_XVINSIDECHROMAKEY, "XvInsideChromaKey", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_XVYUVCHROMAKEY, "XvYUVChromaKey", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_XVDISABLECOLORKEY, "XvDisableColorKey", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_XVMEMCPY, "XvUseMemcpy", OPTV_BOOLEAN, {0}, -1 }, + { OPTION_SCALELCD, "ScaleLCD", 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 }, +#ifdef SISMERGED + { OPTION_MERGEDFB, "MergedFB", OPTV_BOOLEAN, {0}, FALSE }, + { 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_NOSISXINERAMA2, "NoTwinviewXineramaInfo", OPTV_BOOLEAN, {0}, FALSE }, /* alias */ + { OPTION_CRT2ISSCRN0, "MergedXineramaCRT2IsScreen0",OPTV_BOOLEAN,{0},FALSE }, +#endif +#endif +#ifdef SIS_CP + SIS_CP_OPTION_DETAIL +#endif + { -1, NULL, OPTV_NONE, {0}, FALSE } }; void @@ -142,41 +252,54 @@ SiSOptions(ScrnInfoPtr 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"; + static const char *enabledstr = "enabled"; + static const char *ilrangestr = "Illegal %s parameter. Valid range is %d through %d\n"; /* Collect all of the relevant option flags (fill in pScrn->options) */ 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)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pSiS->Options); - /* initalize some defaults */ - pSiS->newFastVram = -1; /* TW: Default: write only; if set, read + write */ + /* Set defaults */ + + pSiS->newFastVram = -1; pSiS->NoHostBus = FALSE; /* pSiS->UsePCIRetry = TRUE; */ pSiS->TurboQueue = TRUE; +#ifdef SISVRAMQ + /* TODO: Option (315 series VRAM command queue) */ + /* But beware: sisfb does not know about this!!! */ + pSiS->cmdQueueSize = 512*1024; +#endif + pSiS->doRender = TRUE; pSiS->HWCursor = TRUE; pSiS->Rotate = FALSE; pSiS->ShadowFB = FALSE; + pSiS->loadDRI = TRUE; + pSiS->agpWantedPages = AGP_PAGES; pSiS->VESA = -1; pSiS->NoXvideo = FALSE; pSiS->maxxfbmem = 0; pSiS->forceCRT1 = -1; - pSiS->DSTN = FALSE; /* TW: For using 550 FSTN/DSTN registers */ - pSiS->XvOnCRT2 = FALSE; /* TW: For chipsets with only one overlay */ + pSiS->DSTN = FALSE; + pSiS->FSTN = FALSE; + pSiS->XvOnCRT2 = FALSE; pSiS->NoYV12 = -1; - pSiS->PDC = -1; /* TW: Panel Delay Compensation for 300 (and 310/325) series */ + pSiS->PDC = -1; pSiS->OptTVStand = -1; pSiS->OptROMUsage = -1; pSiS->noInternalModes = FALSE; pSiS->OptUseOEM = -1; pSiS->OptTVOver = -1; pSiS->OptTVSOver = -1; - pSiS->chtvlumabandwidthcvbs = -1; /* TW: Chrontel TV settings */ + pSiS->chtvlumabandwidthcvbs = -1; pSiS->chtvlumabandwidthsvideo = -1; pSiS->chtvlumaflickerfilter = -1; pSiS->chtvchromabandwidth = -1; @@ -184,17 +307,94 @@ SiSOptions(ScrnInfoPtr pScrn) pSiS->chtvcvbscolor = -1; pSiS->chtvtextenhance = -1; pSiS->chtvcontrast = -1; - pSiS->sistvedgeenhance = -1; /* TW: SiS30x TV settings */ + pSiS->sistvedgeenhance = -1; pSiS->sistvantiflicker = -1; pSiS->sistvsaturation = -1; - pSiS->sis6326antiflicker = -1; /* TW: SiS6326 TV settings */ + pSiS->sistvcfilter = -1; + pSiS->sistvyfilter = 1; /* 0 = off, 1 = default, 2-8 = filter no */ + pSiS->sistvcolcalibc = 0; + pSiS->sistvcolcalibf = 0; pSiS->sis6326enableyfilter = -1; pSiS->sis6326yfilterstrong = -1; - pSiS->tvxpos = 0; /* TW: Some day hopefully general TV settings */ + pSiS->sis6326tvplug = -1; + pSiS->sis6326fscadjust = 0; + pSiS->tvxpos = 0; pSiS->tvypos = 0; - pSiS->NonDefaultPAL = -1; + pSiS->tvxscale = 0; + pSiS->tvyscale = 0; + pSiS->NonDefaultPAL = pSiS->NonDefaultNTSC = -1; pSiS->chtvtype = -1; -#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) + pSiS->restorebyset = TRUE; + pSiS->nocrt2ddcdetection = FALSE; + pSiS->forcecrt2redetection = TRUE; /* default changed since 13/09/2003 */ + pSiS->ForceCRT1Type = CRT1_VGA; + pSiS->ForceCRT2Type = CRT2_DEFAULT; + 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; + } else { + pSiS->XvDefBri = 0; + pSiS->XvDefCon = 4; + } + pSiS->XvDefHue = 0; + pSiS->XvDefSat = 0; + pSiS->XvDefDisableGfx = FALSE; + pSiS->XvDefDisableGfxLR = FALSE; + pSiS->UsePanelScaler = -1; + pSiS->XvUseMemcpy = TRUE; + pSiS->XvUseChromaKey = FALSE; + pSiS->XvDisableColorKey = FALSE; + pSiS->XvInsideChromaKey = FALSE; + 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 = 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; +#endif +#endif +#ifdef SIS_CP + SIS_CP_OPT_DEFAULT +#endif + + /* Chipset dependent defaults */ + + if(pSiS->Chipset == PCI_CHIP_SIS530) { + /* TW: TQ still broken on 530/620? */ + pSiS->TurboQueue = FALSE; + } + + if(pSiS->Chipset == PCI_CHIP_SIS6326) { + pSiS->newFastVram = 1; + } + + if(pSiS->sishw_ext.jChipType == SIS_315H || + pSiS->sishw_ext.jChipType == SIS_315) { + /* Cursor engine seriously broken */ + pSiS->HWCursor = FALSE; + } + +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) pSiS->OptUseColorCursor = 0; #else if(pSiS->VGAEngine == SIS_300_VGA) { @@ -204,15 +404,86 @@ SiSOptions(ScrnInfoPtr pScrn) } else if(pSiS->VGAEngine == SIS_315_VGA) { pSiS->OptUseColorCursor = 1; } -#endif - pSiS->restorebyset = 0; +#endif + if(pSiS->VGAEngine == SIS_300_VGA) { + pSiS->AllowHotkey = 0; + } else if(pSiS->VGAEngine == SIS_315_VGA) { + pSiS->AllowHotkey = 1; + } - if(pSiS->Chipset == PCI_CHIP_SIS530) { - /* TW: TQ still broken on 530/620? */ - pSiS->TurboQueue = FALSE; + /* Collect the options */ + + /* 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)) { + from = X_CONFIG; + } + xf86DrvMsg(pScrn->scrnIndex, from, "Fast VRAM %s\n", + (pSiS->newFastVram == -1) ? + ((pSiS->oldChipset == OC_SIS620) ? "enabled (for read only)" : + "enabled (for write only)") : + (pSiS->newFastVram ? "enabled (for read and write)" : disabledstr)); } - /* sw/hw cursor */ + /* NoHostBus (5597/5598 only) + */ + if((pSiS->Chipset == PCI_CHIP_SIS5597)) { + from = X_DEFAULT; + if(xf86GetOptValBool(pSiS->Options, OPTION_NOHOSTBUS, &pSiS->NoHostBus)) { + from = X_CONFIG; + } + xf86DrvMsg(pScrn->scrnIndex, from, "SiS5597/5598 VGA-to-CPU host bus %s\n", + 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. + */ + if(xf86GetOptValULong(pSiS->Options, OPTION_MAXXFBMEM, + &pSiS->maxxfbmem)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "MaxXFBMem: Framebuffer memory shall be limited to %ld KB\n", + pSiS->maxxfbmem); + pSiS->maxxfbmem *= 1024; + } + + /* NoAccel + * Turns off 2D acceleration + */ + if(xf86ReturnOptValBool(pSiS->Options, OPTION_NOACCEL, FALSE)) { + pSiS->NoAccel = TRUE; +#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 + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "2D Acceleration disabled\n"); +#endif + + } + + /* RenderAcceleration + * En/Disables RENDER acceleration (315/330 series only) + */ + if((pSiS->VGAEngine == SIS_315_VGA) && (!pSiS->NoAccel)) { + if(xf86GetOptValBool(pSiS->Options, OPTION_RENDER, &pSiS->doRender)) { + if(!pSiS->doRender) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "RENDER Acceleration disabled\n"); + } + } + } + + /* SWCursor + * HWCursor + * Chooses whether to use the hardware or software cursor + */ from = X_DEFAULT; if(xf86GetOptValBool(pSiS->Options, OPTION_HW_CURSOR, &pSiS->HWCursor)) { from = X_CONFIG; @@ -224,18 +495,28 @@ SiSOptions(ScrnInfoPtr pScrn) } xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", pSiS->HWCursor ? "HW" : "SW"); - + + /* + * UseColorHWCursor + * ColorHWCursorBlending + * ColorHWCursorBlendThreshold + * + * Enable/disable color hardware cursors; + * enable/disable color hw cursor emulation for 300 series + * select emultation transparency threshold for 300 series + * + */ #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,2,99,0,0) #ifdef ARGB_CURSOR -#ifdef SIS_ARGB_CURSOR +#ifdef SIS_ARGB_CURSOR if((pSiS->HWCursor) && ((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA))) { from = X_DEFAULT; if(xf86GetOptValBool(pSiS->Options, OPTION_USERGBCURSOR, &pSiS->OptUseColorCursor)) { from = X_CONFIG; } xf86DrvMsg(pScrn->scrnIndex, from, "Color HW cursor is %s\n", - pSiS->OptUseColorCursor ? "enabled" : "disabled"); - + pSiS->OptUseColorCursor ? enabledstr : disabledstr); + if(pSiS->VGAEngine == SIS_300_VGA) { from = X_DEFAULT; if(xf86GetOptValBool(pSiS->Options, OPTION_USERGBCURSORBLEND, &pSiS->OptUseColorCursorBlend)) { @@ -244,9 +525,9 @@ SiSOptions(ScrnInfoPtr pScrn) if(pSiS->OptUseColorCursor) { xf86DrvMsg(pScrn->scrnIndex, from, "HW cursor color blending emulation is %s\n", - (pSiS->OptUseColorCursorBlend) ? "enabled" : "disabled"); + (pSiS->OptUseColorCursorBlend) ? enabledstr : disabledstr); } - { + { int temp; from = X_DEFAULT; if(xf86GetOptValInteger(pSiS->Options, OPTION_USERGBCURSORBLENDTH, &temp)) { @@ -258,7 +539,9 @@ SiSOptions(ScrnInfoPtr pScrn) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Illegal color HW cursor blending threshold, valid range 0-255\n"); } - } + } else { + temp = pSiS->OptColorCursorBlendThreshold >> 24; + } if(pSiS->OptUseColorCursor) { if(pSiS->OptUseColorCursorBlend) { xf86DrvMsg(pScrn->scrnIndex, from, @@ -272,499 +555,1162 @@ SiSOptions(ScrnInfoPtr pScrn) #endif #endif - /* Accel */ - if(xf86ReturnOptValBool(pSiS->Options, OPTION_NOACCEL, FALSE)) { - pSiS->NoAccel = TRUE; - pSiS->NoXvideo = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration and Xv disabled\n"); - } - -#if 0 - /* PCI retry - TW: 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 ? "enabled" : "disabled"); -#endif - - /* Mem clock */ -#if 0 /* TW: 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); - } + /* + * MergedFB + * + * Enable/disable and configure merged framebuffer mode + * + */ +#ifdef SISMERGED +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + Bool val; + if(xf86GetOptValBool(pSiS->Options, OPTION_MERGEDFB, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Option \"MergedFB\" cannot be used in Dual Head mode\n"); + } + } else #endif - - /* Fast VRAM (not for 300/310/325 series) */ - if((pSiS->VGAEngine != SIS_300_VGA) && (pSiS->VGAEngine != SIS_315_VGA)) { - from = X_DEFAULT; - if(xf86GetOptValBool(pSiS->Options, OPTION_FAST_VRAM, &pSiS->newFastVram)) { - from = X_CONFIG; + 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; + pSiS->MergedFBAuto = FALSE; + } + } else if(xf86GetOptValBool(pSiS->Options, OPTION_MERGEDFB2, &val)) { + if(val) { + pSiS->MergedFB = TRUE; + pSiS->MergedFBAuto = FALSE; + } } - xf86DrvMsg(pScrn->scrnIndex, from, "Fast VRAM %s\n", - (pSiS->newFastVram == -1) ? "enabled (for write only)" : - (pSiS->newFastVram ? "enabled (for read and write)" : "disabled")); - } - /* NoHostBus (5597/5598 only) */ - if((pSiS->Chipset == PCI_CHIP_SIS5597)) { - from = X_DEFAULT; - if(xf86GetOptValBool(pSiS->Options, OPTION_NOHOSTBUS, &pSiS->NoHostBus)) { - from = X_CONFIG; + 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"); + } } - xf86DrvMsg(pScrn->scrnIndex, from, "SiS5597/5598 VGA-to-CPU host bus %s\n", - pSiS->NoHostBus ? "disabled" : "enabled"); - } - if(pSiS->VGAEngine != SIS_315_VGA) { - /* Turbo QUEUE */ - /* (TW: We always use this on 310/325 series) */ - from = X_DEFAULT; - if(xf86GetOptValBool(pSiS->Options, OPTION_TURBOQUEUE, &pSiS->TurboQueue)) { - from = X_CONFIG; + if(pSiS->MergedFB) { + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2POS); + if(!strptr) { + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2POS2); + } + if(strptr) { + if(!xf86NameCmp(strptr,"LeftOf")) { + pSiS->CRT2Position = sisLeftOf; +#ifdef SISXINERAMA + pSiS->CRT2IsScrn0 = TRUE; +#endif + } else if(!xf86NameCmp(strptr,"RightOf")) { + pSiS->CRT2Position = sisRightOf; +#ifdef SISXINERAMA + pSiS->CRT2IsScrn0 = FALSE; +#endif + } else if(!xf86NameCmp(strptr,"Above")) { + pSiS->CRT2Position = sisAbove; +#ifdef SISXINERAMA + pSiS->CRT2IsScrn0 = FALSE; +#endif + } else if(!xf86NameCmp(strptr,"Below")) { + pSiS->CRT2Position = sisBelow; +#ifdef SISXINERAMA + pSiS->CRT2IsScrn0 = TRUE; +#endif + } else if(!xf86NameCmp(strptr,"Clone")) { + pSiS->CRT2Position = sisClone; +#ifdef SISXINERAMA + pSiS->CRT2IsScrn0 = TRUE; +#endif + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "CRT2Position"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Valid parameters are \"RightOf\", \"LeftOf\", \"Above\", \"Below\", or \"Clone\"\n"); + } + } + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_METAMODES); + if(strptr) { + pSiS->MetaModes = xalloc(strlen(strptr) + 1); + if(pSiS->MetaModes) memcpy(pSiS->MetaModes, 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"); + } + } +#ifdef SISXINERAMA + if(pSiS->MergedFB) { + if(xf86GetOptValBool(pSiS->Options, OPTION_NOSISXINERAMA, &val)) { + if(val) pSiS->UseSiSXinerama = FALSE; + } else if(xf86GetOptValBool(pSiS->Options, OPTION_NOSISXINERAMA2, &val)) { + if(val) pSiS->UseSiSXinerama = FALSE; + } + if(pSiS->UseSiSXinerama) { + if(xf86GetOptValBool(pSiS->Options, OPTION_CRT2ISSCRN0, &val)) { + pSiS->CRT2IsScrn0 = val ? TRUE : FALSE; + } + } + } +#endif } - xf86DrvMsg(pScrn->scrnIndex, from, "TurboQueue %s\n", - pSiS->TurboQueue ? "enabled" : "disabled"); } +#endif - /* Force CRT2 type (300/310/325 series only) - TW: SVIDEO, COMPOSITE and SCART for overriding detection + /* Some options can only be specified in the Master Head's Device + * section. Here we give the user a hint in the log. */ - pSiS->ForceCRT2Type = CRT2_DEFAULT; - pSiS->ForceTVType = -1; - if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_FORCE_CRT2TYPE); - if(strptr != NULL) { - if((!strcmp(strptr,"TV")) || (!strcmp(strptr,"tv"))) - pSiS->ForceCRT2Type = CRT2_TV; - else if((!strcmp(strptr,"SVIDEO")) || (!strcmp(strptr,"svideo"))) { - pSiS->ForceCRT2Type = CRT2_TV; - pSiS->ForceTVType = TV_SVIDEO; - } else if((!strcmp(strptr,"COMPOSITE")) || (!strcmp(strptr,"composite"))) { - pSiS->ForceCRT2Type = CRT2_TV; - pSiS->ForceTVType = TV_AVIDEO; - } else if((!strcmp(strptr,"SCART")) || (!strcmp(strptr,"scart"))) { - pSiS->ForceCRT2Type = CRT2_TV; - pSiS->ForceTVType = TV_SCART; - } else if((!strcmp(strptr,"LCD")) || (!strcmp(strptr,"lcd"))) - pSiS->ForceCRT2Type = CRT2_LCD; - else if((!strcmp(strptr,"DVI")) || (!strcmp(strptr,"dvi"))) - pSiS->ForceCRT2Type = CRT2_LCD; - else if((!strcmp(strptr,"VGA")) || (!strcmp(strptr,"vga"))) - pSiS->ForceCRT2Type = CRT2_VGA; - else if((!strcmp(strptr,"NONE")) || (!strcmp(strptr,"none"))) - pSiS->ForceCRT2Type = 0; - else { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "\"%s\" is not a valid parameter for Option \"ForceCRT2Type\"\n", strptr); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Valid parameters are \"LCD\" (alias \"DVI\"), \"TV\", \"SVIDEO\", \"COMPOSITE\", \"SCART\", \"VGA\" or \"NONE\"\n"); - } +#ifdef SISDUALHEAD + if((pSiS->DualHeadMode) && (pSiS->SecondHead)) { + static const char *mystring = "Option \"%s\" is only accepted in Master Head's device section\n"; + Bool val; + int vali; + if(pSiS->VGAEngine != SIS_315_VGA) { + if(xf86GetOptValBool(pSiS->Options, OPTION_TURBOQUEUE, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "TurboQueue"); + } + } + if(xf86GetOptValBool(pSiS->Options, OPTION_RESTOREBYSET, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "RestoreBySetMode"); + } + if(xf86GetOptValBool(pSiS->Options, OPTION_ENABLEHOTKEY, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "EnableHotKey"); + } + if(xf86GetOptValBool(pSiS->Options, OPTION_ENABLESISCTRL, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "EnableSiSCtrl"); + } + if(xf86GetOptValBool(pSiS->Options, OPTION_USEROMDATA, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "UseROMData"); + } + if(xf86GetOptValBool(pSiS->Options, OPTION_USEOEM, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "UseOEMData"); + } + if(xf86GetOptValBool(pSiS->Options, OPTION_FORCECRT1, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "ForceCRT1"); + } + if(xf86GetOptValBool(pSiS->Options, OPTION_NODDCFORCRT2, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "NoCRT2Detection"); + } + if(xf86GetOptValBool(pSiS->Options, OPTION_FORCECRT2REDETECTION, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "ForceCRT2ReDetection"); + } + 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(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(xf86GetOptValString(pSiS->Options, OPTION_SPECIALTIMING)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "SpecialTiming"); + } + if(xf86GetOptValString(pSiS->Options, OPTION_LVDSHL)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "LVDSHL"); + } + if(xf86GetOptValString(pSiS->Options, OPTION_TVSTANDARD)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "TVStandard"); + } + if(xf86GetOptValString(pSiS->Options, OPTION_CHTVTYPE)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "CHTVType"); + } + if(xf86GetOptValBool(pSiS->Options, OPTION_CHTVOVERSCAN, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "CHTVOverscan"); + } + if(xf86GetOptValBool(pSiS->Options, OPTION_CHTVSOVERSCAN, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "CHTVSuperOverscan"); + } + if((xf86GetOptValInteger(pSiS->Options, OPTION_CHTVLUMABANDWIDTHCVBS, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_CHTVLUMABANDWIDTHSVIDEO, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_CHTVLUMAFLICKERFILTER, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_CHTVCHROMABANDWIDTH, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_CHTVCHROMAFLICKERFILTER, &vali)) || + (xf86GetOptValBool(pSiS->Options, OPTION_CHTVCVBSCOLOR, &val)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_CHTVTEXTENHANCE, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_CHTVCONTRAST, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_SISTVEDGEENHANCE, &vali)) || + (xf86GetOptValString(pSiS->Options, OPTION_SISTVANTIFLICKER)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_SISTVSATURATION, &vali)) || + (xf86GetOptValBool(pSiS->Options, OPTION_SISTVCHROMAFILTER, &val)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_SISTVLUMAFILTER, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_SISTVCOLCALIBCOARSE, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_SISTVCOLCALIBFINE, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_TVXPOSOFFSET, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_TVYPOSOFFSET, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_TVXSCALE, &vali)) || + (xf86GetOptValInteger(pSiS->Options, OPTION_TVYSCALE, &vali))) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "TV related options are only accepted in Master Head's device section"); + } + 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"); + } +#ifdef SIS_CP + SIS_CP_OPT_DH_WARN +#endif + } else +#endif + { + if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->ForceCRT2Type != CRT2_DEFAULT) - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "CRT2 type shall be %s\n", strptr); - } - strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CHTVTYPE); - if(strptr != NULL) { - if((!strcmp(strptr,"SCART")) || (!strcmp(strptr,"scart"))) - pSiS->chtvtype = 1; - else if((!strcmp(strptr,"HDTV")) || (!strcmp(strptr,"hdtv"))) - pSiS->chtvtype = 0; - else { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "\"%s\" is not a valid parameter for Option \"CHTVType\"\n", strptr); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Valid parameters are \"SCART\" or \"HDTV\"\n"); - } - if(pSiS->chtvtype != -1) - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Chrontel TV type shall be %s\n", strptr); - } - } +#ifdef SISVRAMQ + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using VRAM command queue, size %dk\n", + pSiS->cmdQueueSize / 1024); +#else + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using MMIO command queue, size 512k\n"); +#endif - /* ShadowFB */ - from = X_DEFAULT; - if(xf86GetOptValBool(pSiS->Options, OPTION_SHADOW_FB, &pSiS->ShadowFB)) { - from = X_CONFIG; - } - if(pSiS->ShadowFB) { - pSiS->NoAccel = TRUE; - pSiS->NoXvideo = TRUE; - xf86DrvMsg(pScrn->scrnIndex, from, - "Using \"Shadow Frame Buffer\" - acceleration and Xv disabled\n"); - } + } else { - /* Rotate */ - if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_ROTATE))) { - if(!xf86NameCmp(strptr, "CW")) { - pSiS->ShadowFB = TRUE; - pSiS->NoAccel = TRUE; - pSiS->NoXvideo = TRUE; - pSiS->HWCursor = FALSE; - pSiS->Rotate = 1; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Rotating screen clockwise (acceleration and Xv disabled)\n"); - } else - if(!xf86NameCmp(strptr, "CCW")) { - pSiS->ShadowFB = TRUE; - pSiS->NoAccel = TRUE; - pSiS->NoXvideo = TRUE; - pSiS->HWCursor = FALSE; - pSiS->Rotate = -1; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Rotating screen counter clockwise (acceleration and Xv disabled)\n"); - } else { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "\"%s\" is not a valid parameter for Option \"Rotate\"\n", strptr); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Valid parameters are \"CW\" or \"CCW\"\n"); - } - } - - /* RestoreBySetMode */ - /* TW: Set this to force the driver to set the old mode instead of restoring - * the register contents. This can be used to overcome problems with - * LCD panels and video bridges. - */ - if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - Bool val; - if(xf86GetOptValBool(pSiS->Options, OPTION_RESTOREBYSET, &val)) { - if(val) pSiS->restorebyset = TRUE; - else pSiS->restorebyset = FALSE; + /* TurboQueue */ + + from = X_DEFAULT; + if(xf86GetOptValBool(pSiS->Options, OPTION_TURBOQUEUE, &pSiS->TurboQueue)) { + from = X_CONFIG; + } + xf86DrvMsg(pScrn->scrnIndex, from, "TurboQueue %s\n", + pSiS->TurboQueue ? enabledstr : disabledstr); } - } - - /* NOXvideo: - * Set this to TRUE to disable Xv hardware video acceleration - */ - if(!pSiS->NoAccel) { - if(xf86ReturnOptValBool(pSiS->Options, OPTION_NOXVIDEO, FALSE)) { - pSiS->NoXvideo = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "XVideo extension disabled\n"); - } - - if(!pSiS->NoXvideo) { - Bool val; - if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - /* TW: XvOnCRT2: - * On chipsets with only one overlay (315, 650), the user should - * choose to display the overlay on CRT1 or CRT2. By setting this - * option to TRUE, the overlay will be displayed on CRT2. The - * default is: CRT1 if only CRT1 available, CRT2 if only CRT2 - * available, and CRT1 if both is available and detected. + + if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { + + Bool val; + + /* RestoreBySetMode (300/315/330 series only) + * Set this to force the driver to set the old mode instead of restoring + * the register contents. This can be used to overcome problems with + * LCD panels and video bridges. + */ + if(xf86GetOptValBool(pSiS->Options, OPTION_RESTOREBYSET, &val)) { + pSiS->restorebyset = val ? TRUE : FALSE; + } + + /* EnableHotkey (300/315/330 series only) + * Enables or disables the BIOS hotkey switch for + * switching the output device on laptops. + * This key causes a total machine hang on many 300 series + * machines, it is therefore by default disabled on such. + * In dual head mode, using the hotkey is lethal, so we + * forbid it then in any case. + * However, although the driver disables the hotkey as + * BIOS developers intented to do that, some buggy BIOSes + * still cause the machine to freeze. Hence the warning. */ - if(xf86GetOptValBool(pSiS->Options, OPTION_XVONCRT2, &val)) { - if(val) pSiS->XvOnCRT2 = TRUE; - else pSiS->XvOnCRT2 = FALSE; + { + int flag = 0; +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + pSiS->AllowHotkey = 0; + flag = 1; + } else +#endif + if(xf86GetOptValBool(pSiS->Options, OPTION_ENABLEHOTKEY, &val)) { + pSiS->AllowHotkey = val ? 1 : 0; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Hotkey display switching is %s%s\n", + pSiS->AllowHotkey ? enabledstr : disabledstr, + flag ? " in dual head mode" : ""); + if(pSiS->Chipset == PCI_CHIP_SIS630 || + pSiS->Chipset == PCI_CHIP_SIS650 || + pSiS->Chipset == PCI_CHIP_SIS660) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "WARNING: Using the Hotkey might freeze your machine, regardless\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "\twhether enabled or disabled. This is no driver bug.\n"); } - } - if((pSiS->VGAEngine == SIS_OLD_VGA) || (pSiS->VGAEngine == SIS_530_VGA)) { - /* TW: NoYV12 (for 5597/5598, 6326 and 530/620 only) - * YV12 has problems with videos larger than 384x288. So - * allow the user to disable YV12 support to force the - * application to use YUV2 instead. - */ - if(xf86GetOptValBool(pSiS->Options, OPTION_NOYV12, &val)) { - if(val) pSiS->NoYV12 = 1; - else pSiS->NoYV12 = 0; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Xv YV12/I420 support is %s\n", - pSiS->NoYV12 ? "disabled" : "enabled"); } - } - } - } - /* TW: VESA - DEPRECATED - * This option is for forcing the driver to use - * the VESA BIOS extension for mode switching. - */ - { - Bool val; + /* UseROMData (300/315/330 series only) + * This option is enabling/disabling usage of some machine + * specific data from the BIOS ROM. This option can - and + * should - be used in case the driver makes problems + * because SiS changed the location of this data. + */ + if(xf86GetOptValBool(pSiS->Options, OPTION_USEROMDATA, &val)) { + pSiS->OptROMUsage = val ? 1 : 0; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Video ROM data usage shall be %s\n", + val ? enabledstr : disabledstr); + } - if(xf86GetOptValBool(pSiS->Options, OPTION_VESA, &val)) { - if(val) pSiS->VESA = 1; - else pSiS->VESA = 0; + /* UseOEMData (300/315/330 series only) + * The driver contains quite a lot data for OEM LCD panels + * and TV connector specifics which override the defaults. + * If this data is incorrect, the TV may lose color and + * the LCD panel might show some strange effects. Use this + * option to disable the usage of this data. + */ + if(xf86GetOptValBool(pSiS->Options, OPTION_USEOEM, &val)) { + pSiS->OptUseOEM = val ? 1 : 0; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Internal LCD/TV/VGA2 OEM data usage shall be %s\n", + val ? enabledstr : disabledstr); + } - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "VESA: VESA usage shall be %s\n", - val ? "enabled":"disabled"); - } - } + /* 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 + * VGA monitors connected to the secondary VGA plug. Since LCD and + * VGA share the same DDC channel, it might in some cases be impossible + * to determine if the device is a CRT monitor or a flat panel. + */ + if(xf86GetOptValBool(pSiS->Options, OPTION_NODDCFORCRT2, &val)) { + pSiS->nocrt2ddcdetection = val ? TRUE : FALSE; + } - /* TW: MaxXFBMem - * With the option "MaxXFBMem" you can limit the amount of video memory X - * uses for screen and off-screen buffers. This option should be used if - * you intend to use DRI/DRM. The 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 you limit - * the amount of memory X uses, you avoid a clash between the framebuffer - * driver and X as regards overwriting memory portions of each other. - * 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", - pSiS->maxxfbmem); - pSiS->maxxfbmem *= 1024; - } + /* ForceCRT2ReDetection (315/330 series only) + * If set to true, it forces re-detection of the LCD panel and + * a secondary VGA connection even if the BIOS already had found + * about it. This is meant for custom panels (ie such with + * non-standard resolutions) which the BIOS will "detect" according + * to the established timings, resulting in only a very vague idea + * about the panels real resolution. As for secondary VGA, this + * enables us to include a Plasma panel's proprietary modes. + */ + if(xf86GetOptValBool(pSiS->Options, OPTION_FORCECRT2REDETECTION, &val)) { + if(val) { + pSiS->forcecrt2redetection = TRUE; + pSiS->nocrt2ddcdetection = FALSE; + } else pSiS->forcecrt2redetection = FALSE; + } - if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - /* TW: ForceCRT1 (300/310/325 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. - */ - Bool val; - if(xf86GetOptValBool(pSiS->Options, OPTION_FORCECRT1, &val)) { - if(val) pSiS->forceCRT1 = 1; - else pSiS->forceCRT1 = 0; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CRT1 shall be forced to %s\n", - val ? "ON" : "OFF"); - } - } + /* 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 with 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,"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\"\n"); + } + } + } - if(pSiS->Chipset == PCI_CHIP_SIS550) { - /* TW: SiS 550 DSTN/FSTN - * This is for notifying the driver to use the DSTN registers on 550. - * DSTN/FSTN is a special LCD port of the SiS550 (notably not the 551 - * and 552, which I don't know how to detect) that uses an extended - * register range. The only effect of this option is that the driver - * saves and restores these registers. DSTN display modes are chosen - * by using resultion 320x480x8 or 320x480x16. - */ - if(xf86ReturnOptValBool(pSiS->Options, OPTION_DSTN, FALSE)) { - pSiS->DSTN = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "SiS 550 DSTN/FSTN enabled\n"); - } else { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "SiS 550 DSTN/FSTN disabled\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 to %s\n", + val ? "ON" : "OFF"); + if(!pSiS->forceCRT1) pSiS->ForceCRT1Type = CRT1_VGA; + } - /* TW: PanelDelayCompensation (300/310/325 series only) - * This might be required if the LCD panel shows "small waves". - * The parameter is an integer, usually either 4, 32 or 24. - * Why this option? Simply because SiS did poor BIOS design. - * The PDC value depends on the very LCD panel used in a - * particular machine. For most panels, the driver is able - * to detect the correct value. However, some panels require - * a different setting. The value given must be within the mask 0x3c. - */ - if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - if(xf86GetOptValInteger(pSiS->Options, OPTION_PDC, &pSiS->PDC)) { - if(pSiS->PDC & ~0x3c) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Illegal PanelDelayCompensation value\n"); - pSiS->PDC = -1; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Panel delay compensation shall be %d\n", - pSiS->PDC); - } - } - } + /* ForceCRT2Type (300/315/330 series only) + * Used for forcing the driver to initialize a given + * CRT2 device type. + * (SVIDEO, COMPOSITE and SCART for overriding detection) + */ + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_FORCE_CRT2TYPE); + if(strptr != NULL) { + if(!xf86NameCmp(strptr,"TV")) + pSiS->ForceCRT2Type = CRT2_TV; + else if(!xf86NameCmp(strptr,"SVIDEO")) { + pSiS->ForceCRT2Type = CRT2_TV; + pSiS->ForceTVType = TV_SVIDEO; + } else if(!xf86NameCmp(strptr,"COMPOSITE")) { + 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"))) { + 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"))) + pSiS->ForceCRT2Type = CRT2_VGA; + else if(!xf86NameCmp(strptr,"NONE")) + pSiS->ForceCRT2Type = 0; + else if(pSiS->Chipset == PCI_CHIP_SIS550) { + if(!xf86NameCmp(strptr,"DSTN")) { + if(pSiS->ForceCRT1Type == CRT1_VGA) { + pSiS->ForceCRT2Type = CRT2_LCD; + pSiS->DSTN = TRUE; + } + } else if(!xf86NameCmp(strptr,"FSTN")) { + if(pSiS->ForceCRT1Type == CRT1_VGA) { + pSiS->ForceCRT2Type = CRT2_LCD; + pSiS->FSTN = TRUE; + } + } + } 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\"SVIDEO+COMPOSITE\", \"SCART\", \"VGA\" (=\"DVI-A\") or \"NONE\", on the SiS550\n" + "\talso \"DSTN\" and \"FSTN\"\n"); + } - /* TW: TVStandard (300/310/325 series and 6326 w/ TV only) - * This option is for overriding the autodetection of - * the BIOS option for PAL / NTSC - */ - if((pSiS->VGAEngine == SIS_300_VGA) || - (pSiS->VGAEngine == SIS_315_VGA) || - ((pSiS->Chipset == PCI_CHIP_SIS6326) && (pSiS->SiS6326Flags & SIS6326_HASTV))) { - strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_TVSTANDARD); - if(strptr != NULL) { - if((!strcmp(strptr,"PAL")) || (!strcmp(strptr,"pal"))) - pSiS->OptTVStand = 1; - else if((!strcmp(strptr,"PALM")) || (!strcmp(strptr,"palm"))) { - pSiS->OptTVStand = 1; - pSiS->NonDefaultPAL = 1; - } else if((!strcmp(strptr,"PALN")) || (!strcmp(strptr,"paln"))) { - pSiS->OptTVStand = 1; - pSiS->NonDefaultPAL = 0; - } else if((!strcmp(strptr,"NTSC")) || (!strcmp(strptr,"ntsc"))) - pSiS->OptTVStand = 0; - else { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "\"%s\" is not a valid parameter for Option \"TVStandard\"\n", strptr); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Valid options are \"PAL\", \"PALM\", \"PALN\" or \"NTSC\"\n"); + if(pSiS->ForceCRT2Type != CRT2_DEFAULT) + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "CRT2 type shall be %s\n", strptr); + } + + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_SPECIALTIMING); + if(strptr != NULL) { + int i = 0; + BOOLEAN found = FALSE; + if(!xf86NameCmp(strptr,"NONE")) { + pSiS->SiS_Pr->SiS_CustomT = CUT_FORCENONE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Special timing disabled\n"); + } else { + while(mycustomttable[i].chipID != 0) { + if(!xf86NameCmp(strptr,mycustomttable[i].optionName)) { + pSiS->SiS_Pr->SiS_CustomT = mycustomttable[i].SpecialID; + found = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Special timing for %s %s forced\n", + mycustomttable[i].vendorName, mycustomttable[i].cardName); + break; + } + i++; + } + if(!found) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "SpecialTiming"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Valid parameters are:\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\t\"NONE\" (to disable special timings)\n"); + i = 0; + while(mycustomttable[i].chipID != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "\t\"%s\" (for %s %s)\n", + mycustomttable[i].optionName, + mycustomttable[i].vendorName, + mycustomttable[i].cardName); + i++; + } + } + } } - if(pSiS->OptTVStand != -1) { - if(pSiS->Chipset == PCI_CHIP_SIS6326) { - pSiS->NonDefaultPAL = -1; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "TV Standard shall be %s\n", - pSiS->OptTVStand ? "PAL" : "NTSC"); + /* EnableSiSCtrl */ + /* Allow sisctrl tool to change driver settings */ + from = X_DEFAULT; + if(xf86GetOptValBool(pSiS->Options, OPTION_ENABLESISCTRL, &val)) { + if(val) pSiS->enablesisctrl = TRUE; + from = X_CONFIG; + } + xf86DrvMsg(pScrn->scrnIndex, from, "SiSCtrl utility interface is %s\n", + pSiS->enablesisctrl ? enabledstr : disabledstr); + + /* ScaleLCD (300/315/330 series only) + * Can be used to force the bridge/panel link to [do|not do] the + * scaling of modes lower than the panel's native resolution. + * Setting this to TRUE will force the bridge/panel link + * to scale; FALSE will rely on the panel's capabilities. + * Not supported on all machines. + */ + if(xf86GetOptValBool(pSiS->Options, OPTION_SCALELCD, &val)) { + pSiS->UsePanelScaler = val ? 0 : 1; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "LCD scaling is %s\n", + pSiS->UsePanelScaler ? disabledstr : enabledstr); + } + + /* PanelDelayCompensation (300/315/330 series only) + * This might be required if the LCD panel shows "small waves". + * 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. + * The PDC value depends on the very LCD panel used in a + * 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. + */ + if(xf86GetOptValInteger(pSiS->Options, OPTION_PDC, &pSiS->PDC)) { + if((pSiS->VGAEngine == SIS_300_VGA) && (pSiS->PDC & ~0x3c)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Illegal PanelDelayCompensation parameter\n"); + pSiS->PDC = -1; } else { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "TV Standard shall be %s\n", - (pSiS->OptTVStand ? - ( (pSiS->NonDefaultPAL == -1) ? "PAL" : - ((pSiS->NonDefaultPAL) ? "PALM" : "PALN") ) - : "NTSC")); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Panel delay compensation shall be %d\n", + pSiS->PDC); } - } - } - } + } - /* TW: TVOverscan (300/310/325 series only) - * This option is for overriding the BIOS option for - * TV Overscan. Some BIOS don't even have such an option. - * This is only effective on LVDS+CHRONTEL 70xx systems. - */ - if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - Bool val; - if(xf86GetOptValBool(pSiS->Options, OPTION_CHTVOVERSCAN, &val)) { - if(val) pSiS->OptTVOver = 1; - else pSiS->OptTVOver = 0; + /* 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. + */ + if(xf86GetOptValInteger(pSiS->Options, OPTION_LVDSHL, &pSiS->SiS_Pr->LVDSHL)) { + if((pSiS->SiS_Pr->LVDSHL < 0) || (pSiS->SiS_Pr->LVDSHL > 3)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Illegal LVDSHL parameter, valid is 0 through 3\n"); + pSiS->SiS_Pr->LVDSHL = -1; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "LVDSHL will be %d\n", + pSiS->SiS_Pr->LVDSHL); + } + } - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Chrontel: TV overscan shall be %s\n", - val ? "enabled":"disabled"); - } - if(xf86GetOptValBool(pSiS->Options, OPTION_CHTVSOVERSCAN, &pSiS->OptTVSOver)) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Chrontel: TV super overscan shall be %s\n", - pSiS->OptTVSOver ? "enabled":"disabled"); - } - } + } - /* TW: UseROMData (300/310/325 series only) - * This option is enabling/disabling usage of some machine - * specific data from the BIOS ROM. This option can - and - * should - be used in case the driver makes problems - * because SiS changed the location of this data. - * TW: NoOEM (300/310/325 series only) - * The driver contains quite a lot data for OEM LCD panels - * and TV connector specifics which override the defaults. - * If this data is incorrect, the TV may lose color and - * the LCD panel might show some strange effects. Use this - * option to disable the usage of this data. - */ - if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - Bool val; - if(xf86GetOptValBool(pSiS->Options, OPTION_USEROMDATA, &val)) { - if(val) pSiS->OptROMUsage = 1; - else pSiS->OptROMUsage = 0; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Video ROM data usage shall be %s\n", - val ? "enabled":"disabled"); - } - if(xf86GetOptValBool(pSiS->Options, OPTION_USEOEM, &val)) { - if(val) pSiS->OptUseOEM = 1; - else pSiS->OptUseOEM = 0; + /* TVStandard (300/315/330 series and 6326 w/ TV only) + * This option is for overriding the autodetection of + * the BIOS/Jumper option for PAL / NTSC + */ + if((pSiS->VGAEngine == SIS_300_VGA) || + (pSiS->VGAEngine == SIS_315_VGA) || + ((pSiS->Chipset == PCI_CHIP_SIS6326) && (pSiS->SiS6326Flags & SIS6326_HASTV))) { + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_TVSTANDARD); + if(strptr != NULL) { + if(!xf86NameCmp(strptr,"PAL")) + pSiS->OptTVStand = 1; + else if((!xf86NameCmp(strptr,"PALM")) || + (!xf86NameCmp(strptr,"PAL-M"))) { + pSiS->OptTVStand = 1; + pSiS->NonDefaultPAL = 1; + } else if((!xf86NameCmp(strptr,"PALN")) || + (!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\", \"NTSC\", \"NTSCJ\"\n"); + } - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Internal LCD/TV OEM data usage shall be %s\n", - val ? "enabled":"disabled"); - } - pSiS->sbiosn = NULL; - strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_SBIOSN); - if(strptr != NULL) { - pSiS->sbiosn = xalloc(strlen(strptr)+1); - if(pSiS->sbiosn) strcpy(pSiS->sbiosn, strptr); - } - } + 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") ) : + (pSiS->NonDefaultNTSC == -1) ? "NTSC" : "NTSCJ")); + } + } + } + } - /* TW: NoInternalModes (300/310/325 series only) - * Since the mode switching code for these chipsets is a - * Asm-to-C translation of BIOS code, we only have timings - * for a pre-defined number of modes. The default behavior - * is to replace XFree's default modes with a mode list - * generated out of the known and supported modes. Use - * this option to disable this. However, even if using - * out built-in mode list will NOT make it possible to - * use modelines. - */ - if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { - from = X_DEFAULT; - if(xf86GetOptValBool(pSiS->Options, OPTION_NOINTERNALMODES, &pSiS->noInternalModes)) - from = X_CONFIG; + /* CHTVType (315/330 series only) + * Used for telling the driver if the TV output shall + * be i480 HDTV 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")) + pSiS->chtvtype = 0; + else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "CHTVType"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Valid parameters are \"SCART\" or \"HDTV\"\n"); + } + if(pSiS->chtvtype != -1) + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Chrontel: TV type shall be %s\n", strptr); + } + } - xf86DrvMsg(pScrn->scrnIndex, from, "Usage of built-in modes is %s\n", - pSiS->noInternalModes ? "disabled":"enabled"); - } + /* 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)) { + pSiS->OptTVOver = val ? 1 : 0; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Chrontel: TV overscan shall be %s\n", + val ? enabledstr : disabledstr); + } + if(xf86GetOptValBool(pSiS->Options, OPTION_CHTVSOVERSCAN, &pSiS->OptTVSOver)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Chrontel: TV super overscan shall be %s\n", + pSiS->OptTVSOver ? enabledstr : disabledstr); + } + } - /* TW: 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, + /* 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, &pSiS->chtvlumabandwidthcvbs); - xf86GetOptValInteger(pSiS->Options, OPTION_CHTVLUMABANDWIDTHSVIDEO, + xf86GetOptValInteger(pSiS->Options, OPTION_CHTVLUMABANDWIDTHSVIDEO, &pSiS->chtvlumabandwidthsvideo); - xf86GetOptValInteger(pSiS->Options, OPTION_CHTVLUMAFLICKERFILTER, + xf86GetOptValInteger(pSiS->Options, OPTION_CHTVLUMAFLICKERFILTER, &pSiS->chtvlumaflickerfilter); - xf86GetOptValInteger(pSiS->Options, OPTION_CHTVCHROMABANDWIDTH, + xf86GetOptValInteger(pSiS->Options, OPTION_CHTVCHROMABANDWIDTH, &pSiS->chtvchromabandwidth); - xf86GetOptValInteger(pSiS->Options, OPTION_CHTVCHROMAFLICKERFILTER, + xf86GetOptValInteger(pSiS->Options, OPTION_CHTVCHROMAFLICKERFILTER, &pSiS->chtvchromaflickerfilter); - xf86GetOptValBool(pSiS->Options, OPTION_CHTVCVBSCOLOR, + xf86GetOptValBool(pSiS->Options, OPTION_CHTVCVBSCOLOR, &pSiS->chtvcvbscolor); - xf86GetOptValInteger(pSiS->Options, OPTION_CHTVTEXTENHANCE, + xf86GetOptValInteger(pSiS->Options, OPTION_CHTVTEXTENHANCE, &pSiS->chtvtextenhance); - xf86GetOptValInteger(pSiS->Options, OPTION_CHTVCONTRAST, + xf86GetOptValInteger(pSiS->Options, OPTION_CHTVCONTRAST, &pSiS->chtvcontrast); - xf86GetOptValInteger(pSiS->Options, OPTION_SISTVEDGEENHANCE, + xf86GetOptValInteger(pSiS->Options, OPTION_SISTVEDGEENHANCE, &pSiS->sistvedgeenhance); - xf86GetOptValInteger(pSiS->Options, OPTION_SISTVANTIFLICKER, - &pSiS->sistvantiflicker); - xf86GetOptValInteger(pSiS->Options, OPTION_SISTVSATURATION, + xf86GetOptValInteger(pSiS->Options, OPTION_SISTVSATURATION, &pSiS->sistvsaturation); - xf86GetOptValInteger(pSiS->Options, OPTION_TVXPOSOFFSET, + xf86GetOptValInteger(pSiS->Options, OPTION_SISTVLUMAFILTER, + &pSiS->sistvyfilter); + if((pSiS->sistvyfilter < 0) || (pSiS->sistvyfilter > 8)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Illegal Y Filter number; valid is 0 (off), 1 (default), 2-8 (filter number 1-7)\n"); + pSiS->sistvyfilter = 1; + } + xf86GetOptValBool(pSiS->Options, OPTION_SISTVCHROMAFILTER, + &pSiS->sistvcfilter); + xf86GetOptValInteger(pSiS->Options, OPTION_SISTVCOLCALIBCOARSE, + &pSiS->sistvcolcalibc); + xf86GetOptValInteger(pSiS->Options, OPTION_SISTVCOLCALIBFINE, + &pSiS->sistvcolcalibf); + if((pSiS->sistvcolcalibf > 127) || (pSiS->sistvcolcalibf < -128) || + (pSiS->sistvcolcalibc > 120) || (pSiS->sistvcolcalibc < -120)) { + pSiS->sistvcolcalibf = pSiS->sistvcolcalibc = 0; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Illegal Color Calibration. Range is -128 to 127 (fine), -120 to 120 (coarse)\n"); + } + xf86GetOptValInteger(pSiS->Options, OPTION_TVXPOSOFFSET, &pSiS->tvxpos); - xf86GetOptValInteger(pSiS->Options, OPTION_TVYPOSOFFSET, + xf86GetOptValInteger(pSiS->Options, OPTION_TVYPOSOFFSET, &pSiS->tvypos); - if(pSiS->tvxpos > 32) { pSiS->tvxpos = 32; tmp = 1; } - if(pSiS->tvxpos < -32) { pSiS->tvxpos = -32; tmp = 1; } - if(pSiS->tvypos > 32) { pSiS->tvypos = 32; tmp = 1; } - if(pSiS->tvypos < -32) { pSiS->tvypos = -32; tmp = 1; } - if(tmp) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + if(pSiS->tvxpos > 32) { pSiS->tvxpos = 32; tmp = 1; } + if(pSiS->tvxpos < -32) { pSiS->tvxpos = -32; tmp = 1; } + if(pSiS->tvypos > 32) { pSiS->tvypos = 32; tmp = 1; } + if(pSiS->tvypos < -32) { pSiS->tvypos = -32; tmp = 1; } + if(tmp) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Illegal TV x or y offset. Range is from -32 to 32\n"); - } - if((pSiS->Chipset == PCI_CHIP_SIS6326) && (pSiS->SiS6326Flags & SIS6326_HASTV)) { - int tmp = 0; - strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_SIS6326ANTIFLICKER); - if (strptr != NULL) { - if((!strcmp(strptr,"OFF")) || (!strcmp(strptr,"off"))) - pSiS->sis6326antiflicker = 0; - else if((!strcmp(strptr,"LOW")) || (!strcmp(strptr,"low"))) - pSiS->sis6326antiflicker = 1; - else if((!strcmp(strptr,"MED")) || (!strcmp(strptr,"med"))) - pSiS->sis6326antiflicker = 2; - else if((!strcmp(strptr,"HIGH")) || (!strcmp(strptr,"high"))) - pSiS->sis6326antiflicker = 3; - else if((!strcmp(strptr,"ADAPTIVE")) || (!strcmp(strptr,"adaptive"))) - pSiS->sis6326antiflicker = 4; - else { - pSiS->sis6326antiflicker = -1; - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "\"%s\" is not a valid parameter for Option \"SIS6326TVAntiFlicker\"\n", strptr); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Valid parameters are \"OFF\", \"LOW\", \"MED\", \"HIGH\" or \"ADAPTIVE\"\n"); + tmp = 0; + xf86GetOptValInteger(pSiS->Options, OPTION_TVXSCALE, + &pSiS->tvxscale); + xf86GetOptValInteger(pSiS->Options, OPTION_TVYSCALE, + &pSiS->tvyscale); + if(pSiS->tvxscale > 16) { pSiS->tvxscale = 16; tmp = 1; } + if(pSiS->tvxscale < -16) { pSiS->tvxscale = -16; tmp = 1; } + if(pSiS->tvyscale > 3) { pSiS->tvyscale = 3; tmp = 1; } + if(pSiS->tvyscale < -4) { pSiS->tvyscale = -4; tmp = 1; } + if(tmp) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Illegal TV x or y scaling parameter. Range is from -16 to 16 (X), -4 to 3 (Y)\n"); + } + + if((pSiS->Chipset == PCI_CHIP_SIS6326) && (pSiS->SiS6326Flags & SIS6326_HASTV)) { + int tmp = 0; + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_SIS6326FORCETVPPLUG); + if(strptr) { + if(!xf86NameCmp(strptr,"COMPOSITE")) + pSiS->sis6326tvplug = 1; + else if(!xf86NameCmp(strptr,"SVIDEO")) + pSiS->sis6326tvplug = 0; + else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "SIS6326TVForcePlug"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Valid parameters are \"COMPOSITE\" or \"SVIDEO\"\n"); + } } - } - xf86GetOptValBool(pSiS->Options, OPTION_SIS6326ENABLEYFILTER, + xf86GetOptValBool(pSiS->Options, OPTION_SIS6326ENABLEYFILTER, &pSiS->sis6326enableyfilter); - xf86GetOptValBool(pSiS->Options, OPTION_SIS6326YFILTERSTRONG, + xf86GetOptValBool(pSiS->Options, OPTION_SIS6326YFILTERSTRONG, &pSiS->sis6326yfilterstrong); - xf86GetOptValInteger(pSiS->Options, OPTION_TVXPOSOFFSET, + xf86GetOptValInteger(pSiS->Options, OPTION_TVXPOSOFFSET, &pSiS->tvxpos); - xf86GetOptValInteger(pSiS->Options, OPTION_TVYPOSOFFSET, + xf86GetOptValInteger(pSiS->Options, OPTION_TVYPOSOFFSET, &pSiS->tvypos); - if(pSiS->tvxpos > 16) { pSiS->tvxpos = 16; tmp = 1; } - if(pSiS->tvxpos < -16) { pSiS->tvxpos = -16; tmp = 1; } - if(pSiS->tvypos > 16) { pSiS->tvypos = 16; tmp = 1; } - if(pSiS->tvypos < -16) { pSiS->tvypos = -16; tmp = 1; } - if(tmp) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + if(pSiS->tvxpos > 16) { pSiS->tvxpos = 16; tmp = 1; } + if(pSiS->tvxpos < -16) { pSiS->tvxpos = -16; tmp = 1; } + if(pSiS->tvypos > 16) { pSiS->tvypos = 16; tmp = 1; } + if(pSiS->tvypos < -16) { pSiS->tvypos = -16; tmp = 1; } + if(tmp) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Illegal TV x or y offset. Range is from -16 to 16\n"); + xf86GetOptValInteger(pSiS->Options, OPTION_SIS6326FSCADJUST, + &pSiS->sis6326fscadjust); + if(pSiS->sis6326fscadjust) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Adjusting the default FSC by %d\n", + pSiS->sis6326fscadjust); + } + } + + if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA) || + ((pSiS->Chipset == PCI_CHIP_SIS6326) && (pSiS->SiS6326Flags & SIS6326_HASTV))) { + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_SISTVANTIFLICKER); + if(!strptr) { + strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_SIS6326ANTIFLICKER); + } + if(strptr) { + if(!xf86NameCmp(strptr,"OFF")) + pSiS->sistvantiflicker = 0; + else if(!xf86NameCmp(strptr,"LOW")) + pSiS->sistvantiflicker = 1; + else if(!xf86NameCmp(strptr,"MED")) + pSiS->sistvantiflicker = 2; + else if(!xf86NameCmp(strptr,"HIGH")) + pSiS->sistvantiflicker = 3; + else if(!xf86NameCmp(strptr,"ADAPTIVE")) + pSiS->sistvantiflicker = 4; + else { + pSiS->sistvantiflicker = -1; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "SISTVAntiFlicker"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Valid parameters are \"OFF\", \"LOW\", \"MED\", \"HIGH\" or \"ADAPTIVE\"\n"); + } + } + } + + /* 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; + } + } + +#ifdef SIS_CP + SIS_CP_OPT_DOOPT +#endif + + } /* DualHead */ + + /* CRT1Gamma - enable/disable gamma correction for CRT1 + */ + { + 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, + "VESA: VESA usage shall be %s\n", + val ? enabledstr : disabledstr); + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "*** Option \"VESA\" is deprecated. *** \n"); + if(pSiS->VESA) pSiS->ForceCRT1Type = CRT1_VGA; + } + } + + if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { + + /* NoInternalModes (300/315/330 series only) + * Since the mode switching code for these chipsets is a + * Asm-to-C translation of BIOS code, we only have timings + * for a pre-defined number of modes. The default behavior + * is to replace XFree's default modes with a mode list + * 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_CONFIG; + xf86DrvMsg(pScrn->scrnIndex, from, "Usage of built-in modes is %s\n", + pSiS->noInternalModes ? disabledstr : enabledstr); } + + /* ShadowFB */ + from = X_DEFAULT; + if(xf86GetOptValBool(pSiS->Options, OPTION_SHADOW_FB, &pSiS->ShadowFB)) { +#ifdef SISMERGED + if(pSiS->MergedFB) { + pSiS->ShadowFB = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Shadow Frame Buffer not supported in MergedFB mode\n"); + } else +#endif + from = X_CONFIG; + } + if(pSiS->ShadowFB) { + pSiS->NoAccel = TRUE; +#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"); +#else + xf86DrvMsg(pScrn->scrnIndex, from, + "Using \"Shadow Frame Buffer\" - 2D acceleration disabled\n"); +#endif + } + + /* Rotate */ + if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_ROTATE))) { +#ifdef SISMERGED + if(pSiS->MergedFB) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Screen rotation not supported in MergedFB mode\n"); + } else +#endif + if(!xf86NameCmp(strptr, "CW")) { + pSiS->Rotate = 1; + } else if(!xf86NameCmp(strptr, "CCW")) { + pSiS->Rotate = -1; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "Rotate"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Valid parameters are \"CW\" or \"CCW\"\n"); + } + + if(pSiS->Rotate) { + pSiS->ShadowFB = TRUE; + pSiS->NoAccel = TRUE; + pSiS->HWCursor = FALSE; +#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", + (pSiS->Rotate == -1) ? "counter " : ""); +#else + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Rotating screen %sclockwise (2D acceleration %sdisabled)\n", + (pSiS->Rotate == -1) ? "counter " : "", +#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0) + "and RandR extension " +#else + "" +#endif + ); + +#endif + + } + } + +#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) { +#endif + if(xf86ReturnOptValBool(pSiS->Options, OPTION_NOXVIDEO, FALSE)) { + pSiS->NoXvideo = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "XVideo extension disabled\n"); + } + + if(!pSiS->NoXvideo) { + Bool val; + int tmp; + + if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { + /* XvOnCRT2 + * On chipsets with only one overlay (315, 650, 740, 330), the user can + * choose to display the overlay on CRT1 or CRT2. By setting this + * option to TRUE, the overlay will be displayed on CRT2. The + * default is: CRT1 if only CRT1 available, CRT2 if only CRT2 + * available, and CRT1 if both is available and detected. + * Since implementation of the XV_SWITCHCRT Xv property this only + * selects the default CRT. + */ + if(xf86GetOptValBool(pSiS->Options, OPTION_XVONCRT2, &val)) { + pSiS->XvOnCRT2 = val ? TRUE : FALSE; + } + } + + if((pSiS->VGAEngine == SIS_OLD_VGA) || (pSiS->VGAEngine == SIS_530_VGA)) { + /* NoYV12 (for 5597/5598, 6326 and 530/620 only) + * YV12 has problems with videos larger than 384x288. So + * allow the user to disable YV12 support to force the + * application to use YUV2 instead. + */ + if(xf86GetOptValBool(pSiS->Options, OPTION_NOYV12, &val)) { + pSiS->NoYV12 = val ? 1 : 0; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Xv YV12/I420 support is %s\n", + pSiS->NoYV12 ? disabledstr : enabledstr); + } + } + + /* Some Xv properties' defaults can be set by options */ + if(xf86GetOptValInteger(pSiS->Options, OPTION_XVDEFCONTRAST, &tmp)) { + if((tmp >= 0) && (tmp <= 7)) pSiS->XvDefCon = tmp; + else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, + "XvDefaultContrast" ,0, 7); + } + if(xf86GetOptValInteger(pSiS->Options, OPTION_XVDEFBRIGHTNESS, &tmp)) { + if((tmp >= -128) && (tmp <= 127)) pSiS->XvDefBri = tmp; + else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, + "XvDefaultBrightness", -128, 127); + } + if(pSiS->VGAEngine == SIS_315_VGA) { + if(xf86GetOptValInteger(pSiS->Options, OPTION_XVDEFHUE, &tmp)) { + if((tmp >= -8) && (tmp <= 7)) pSiS->XvDefHue = tmp; + else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, + "XvDefaultHue", -8, 7); + } + if(xf86GetOptValInteger(pSiS->Options, OPTION_XVDEFSATURATION, &tmp)) { + if((tmp >= -7) && (tmp <= 7)) pSiS->XvDefSat = tmp; + else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, + "XvDefaultSaturation", -7, 7); + } + } + if(xf86GetOptValBool(pSiS->Options, OPTION_XVDEFDISABLEGFX, &val)) { + if(val) pSiS->XvDefDisableGfx = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Graphics display will be %s during Xv usage\n", + val ? disabledstr : enabledstr); + } + if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA)) { + if(xf86GetOptValBool(pSiS->Options, OPTION_XVDEFDISABLEGFXLR, &val)) { + if(val) pSiS->XvDefDisableGfxLR = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Graphics display left/right of overlay will be %s during Xv usage\n", + val ? disabledstr : enabledstr); + } + if(xf86GetOptValBool(pSiS->Options, OPTION_XVDISABLECOLORKEY, &val)) { + if(val) pSiS->XvDisableColorKey = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Xv Color key is %s\n", + val ? disabledstr : enabledstr); + } + if(xf86GetOptValBool(pSiS->Options, OPTION_XVUSECHROMAKEY, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Xv Chroma-keying is %s\n", + val ? enabledstr : disabledstr); + if(val) pSiS->XvUseChromaKey = TRUE; + } + if(xf86GetOptValBool(pSiS->Options, OPTION_XVINSIDECHROMAKEY, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Xv: Video is transparent if %s chroma key range\n", + val ? "inside" : "outside"); + if(val) pSiS->XvInsideChromaKey = TRUE; + } + if(pSiS->VGAEngine == SIS_300_VGA) { + if(xf86GetOptValBool(pSiS->Options, OPTION_XVYUVCHROMAKEY, &val)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Xv: Chroma key is in %s format\n", + val ? "YUV" : "RGB"); + if(val) pSiS->XvYUVChromaKey = TRUE; + } + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Xv: Chroma key is of same format as video source\n"); + } + if(xf86GetOptValInteger(pSiS->Options, OPTION_XVCHROMAMIN, &tmp)) { + if((tmp >= 0) && (tmp <= 0xffffff)) pSiS->XvChromaMin = tmp; + else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, + "XvChromaMin", 0, 0xffffff); + } + if(xf86GetOptValInteger(pSiS->Options, OPTION_XVCHROMAMAX, &tmp)) { + if((tmp >= 0) && (tmp <= 0xffffff)) pSiS->XvChromaMax = tmp; + else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ilrangestr, + "XvChromaMax", 0, 0xffffff); + } + } + if(xf86GetOptValBool(pSiS->Options, OPTION_XVMEMCPY, &val)) { + pSiS->XvUseMemcpy = val ? TRUE : FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Xv will %suse memcpy()\n", + val ? "" : "not "); + } + /* XvGamma - enable/disable gamma correction for Xv + * Supported for CRT1 only + */ + if(pSiS->VGAEngine == SIS_315_VGA) { + 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)) { + 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((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"); + } + } + } + } const OptionInfoRec * diff --git a/src/sis_regs.h b/src/sis_regs.h index 928f1dc..4298b3f 100644 --- a/src/sis_regs.h +++ b/src/sis_regs.h @@ -1,7 +1,9 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h,v 1.17 2003/01/29 15:42:17 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h,v 1.24 2003/10/30 18:53:43 twini Exp $ */ /* + * 2D Acceleration for SiS300, SiS540, SiS630, SiS730, SiS530, SiS620 + * * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Parts Copyright 2001, 2002 by Thomas Winischhofer, Vienna, Austria. + * Copyright 2002, 2003 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 @@ -13,36 +15,16 @@ * about the suitability of this software for any purpose. It is provided * "as is" without express or implied warranty. * - * THE PROVIDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * THE COPYRIGHT HOLDER 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 + * 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 - * Mike Chapman <mike@paranoia.com>, - * Juanjo Santamarta <santamarta@ctv.es>, - * Mitani Hiroshi <hmitani@drl.mei.co.jp> - * David Thomas <davtom@dream.org.uk> - * - * Thomas Winischhofer <thomas@winischhofer.net> - * - 310/325 series (315/550/650/651/740/M650) support - * - (possibly incomplete) Xabre (SiS330) support - * - new mode switching code for 300, 310/325 and 330 series - * - many fixes for 300/540/630/730 chipsets, - * - many fixes for 5597/5598, 6326 and 530/620 chipsets, - * - VESA mode switching (deprecated), - * - extended CRT2/video bridge handling support, - * - dual head support on 300, 310/325 and 330 series - * - 650/LVDS (up to 1400x1050), 650/Chrontel 701x support - * - 30xB/30xLV/30xLVX video bridge support (300, 310/325, 330 series) - * - Xv support for 5597/5598, 6326, 530/620 and 310/325 series - * - video overlay enhancements for 300 series - * - TV and hi-res support for the 6326 - * - etc. */ + /* For general use --------------------------------------------------------------- */ @@ -95,23 +77,23 @@ #define GETVAR8(var) ((var)&0xFF) #define SETVAR8(var,val) (var) = GETVAR8(val) -/* #define VGA_RELIO_BASE 0x380 */ - -#define AROFFSET 0x40 /* VGA_ATTR_INDEX - VGA_RELIO_BASE */ -#define ARROFFSET 0x41 /* VGA_ATTR_DATA_R - VGA_RELIO_BASE */ -#define GROFFSET 0x4e /* VGA_GRAPH_INDEX - VGA_RELIO_BASE */ -#define SROFFSET 0x44 /* VGA_SEQ_INDEX - VGA_RELIO_BASE */ -#define CROFFSET 0x54 /* VGA_CRTC_INDEX_OFFSET + VGA_IOBASE_COLOR - VGA_RELIO_BASE */ -#define MISCROFFSET 0x4c /* VGA_MISC_OUT_R - VGA_RELIO_BASE */ -#define MISCWOFFSET 0x42 /* VGA_MISC_OUT_W - VGA_RELIO_BASE */ +#define AROFFSET 0x40 +#define ARROFFSET 0x41 +#define GROFFSET 0x4e +#define SROFFSET 0x44 +#define CROFFSET 0x54 +#define MISCROFFSET 0x4c +#define MISCWOFFSET 0x42 #define INPUTSTATOFFSET 0x5A #define PART1OFFSET 0x04 #define PART2OFFSET 0x10 #define PART3OFFSET 0x12 #define PART4OFFSET 0x14 #define PART5OFFSET 0x16 +#define CAPTUREOFFSET 0x00 #define VIDEOOFFSET 0x02 #define COLREGOFFSET 0x48 +#define PELMASKOFFSET 0x46 #define SISAR pSiS->RelIO + AROFFSET #define SISARR pSiS->RelIO + ARROFFSET @@ -126,15 +108,16 @@ #define SISPART3 pSiS->RelIO + PART3OFFSET #define SISPART4 pSiS->RelIO + PART4OFFSET #define SISPART5 pSiS->RelIO + PART5OFFSET +#define SISCAP pSiS->RelIO + CAPTUREOFFSET #define SISVID pSiS->RelIO + VIDEOOFFSET #define SISCOLIDX pSiS->RelIO + COLREGOFFSET #define SISCOLDATA pSiS->RelIO + COLREGOFFSET + 1 #define SISCOL2IDX SISPART5 #define SISCOL2DATA SISPART5 + 1 +#define SISPEL pSiS->RelIO + PELMASKOFFSET - -#define vc_index_offset 0x00 /* Video capture - unused */ -#define vc_data_offset 0x01 +#define vc_index_offset CAPTUREOFFSET /* Video capture - unused */ +#define vc_data_offset (CAPTUREOFFSET + 1) #define vi_index_offset VIDEOOFFSET #define vi_data_offset (VIDEOOFFSET + 1) #define crt2_index_offset PART1OFFSET @@ -326,9 +309,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 310/325 series */ +/* TW: The following registers only exist on the 315 series */ -/* TW: Bit 16:24 of Y_U_V buf start address (?) */ +/* TW: 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 @@ -345,35 +328,41 @@ #define Index_VI_Control_Misc3 0x74 +/* 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 */ #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 */ #define VI_Misc0_Fmt_YVU420P 0x0C /* YUV420 Planar (I420, YV12) */ -#define VI_Misc0_Fmt_YUYV 0x28 /* YUYV Packed (YUY2) */ +#define VI_Misc0_Fmt_YUYV 0x28 /* YUYV Packed (=YUY2) */ #define VI_Misc0_Fmt_UYVY 0x08 /* (UYVY) */ +#define VI_Misc0_Fmt_YVYU 0x38 /* (YVYU) (315 series only?) */ +#define VI_Misc0_Fmt_NV21 0x5c /* (330 series only?) */ +#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 */ -/* #define VI_Misc1_? 0x01 */ -#define VI_Misc1_BOB_Enable 0x02 +#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 -#define VI_Misc1_Field_Mode 0x08 -/* #define VI_Misc1_? 0x10 */ -#define VI_Misc1_Non_Interleave 0x20 /* 300 series only? */ -#define VI_Misc1_Buf_Addr_Lock 0x20 /* 310 series only? */ +#define VI_Misc1_Field_Mode 0x08 /* ? */ +#define VI_Misc1_Non_Interleave 0x10 /* ? 0x20 ? - Odd and Even fields are not interleaved ? */ +#define VI_Misc1_Buf_Addr_Lock 0x20 /* 315 series only? */ /* #define VI_Misc1_? 0x40 */ /* #define VI_Misc1_? 0x80 */ /* TW: Bits for Index_VI_Control_Misc2 */ #define VI_Misc2_Select_Video2 0x01 #define VI_Misc2_Video2_On_Top 0x02 -/* #define VI_Misc2_? 0x04 */ +#define VI_Misc2_DisableGraphics 0x04 /* Disable graphics display entirely (<= 650 only, not >= M650, 651) */ #define VI_Misc2_Vertical_Interpol 0x08 -#define VI_Misc2_Dual_Line_Merge 0x10 -#define VI_Misc2_All_Line_Merge 0x20 /* 310 series only? */ -#define VI_Misc2_Auto_Flip_Enable 0x40 /* 300 series only? */ -#define VI_Misc2_Video_Reg_Write_Enable 0x80 /* 310 series only? */ +#define VI_Misc2_Dual_Line_Merge 0x10 /* dual-overlay chips only; "dual video windows relative line buffer merge" */ +#define VI_Misc2_All_Line_Merge 0x20 /* > 315 only */ +#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 */ #define VI_Misc3_Submit_Video_1 0x01 /* AKA "address ready" */ @@ -383,6 +372,8 @@ /* TW: Values for Index_VI_Key_Overlay_OP (0x2F) */ #define VI_ROP_Never 0x00 #define VI_ROP_DestKey 0x03 +#define VI_ROP_ChromaKey 0x05 +#define VI_ROP_NotChromaKey 0x0A #define VI_ROP_Always 0x0F @@ -456,7 +447,7 @@ #define Index_VI6326_Brightness 0xB4 #define Index_VI6326_Contrast_Enh_Ctrl 0xB5 -/* Alpha (ALL 6326 only?) */ +/* Alpha */ #define Index_VI6326_AlphaGraph 0xA7 #define Index_VI6326_AlphaVideo 0xA8 @@ -570,7 +561,7 @@ #define _VIN_FIELD_BOTH 4 -/* i2c registers (TW; not on 300/310/325 series) */ +/* i2c registers (TW; not on 300/315 series) */ #define X_INDEXREG 0x14 #define X_PORTREG 0x15 #define X_DATA 0x0f diff --git a/src/sis_setup.c b/src/sis_setup.c index a26d191..36e625b 100644 --- a/src/sis_setup.c +++ b/src/sis_setup.c @@ -1,9 +1,8 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c,v 1.9 2003/02/04 02:44:29 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c,v 1.25 2003/11/06 19:10:01 twini Exp $ */ /* * Basic hardware and memory detection * - * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Parts Copyright 2001, 2002 by Thomas Winischhofer, Vienna, Austria. + * Copyright 2001, 2002, 2003 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 @@ -23,12 +22,8 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Authors: Alan Hourihane, alanh@fairlite.demon.co.uk - * Mike Chapman <mike@paranoia.com>, - * Juanjo Santamarta <santamarta@ctv.es>, - * Mitani Hiroshi <hmitani@drl.mei.co.jp> - * David Thomas <davtom@dream.org.uk>. - * Thomas Winischhofer <thomas@winischhofer.net> + * Author: Thomas Winischhofer <thomas@winischhofer.net> + * */ #include "xf86PciInfo.h" @@ -42,7 +37,6 @@ #include "xf86_ansic.h" #include "xf86Version.h" -#include "xf86pciBus.h" #include "xf86cmap.h" #include "sis.h" @@ -61,11 +55,12 @@ static const char *dramTypeStr[] = { "2 cycle EDO RAM", "1 cycle EDO RAM", "SDRAM/SGRAM", - "SDRAM", + "SDR SDRAM", "SGRAM", "ESDRAM", - "DDR RAM", /* for 550/650 */ - "DDR RAM", /* for 550/650 */ + "DDR SDRAM", /* for 550/650/etc */ + "DDR SDRAM", /* for 550/650/etc */ + "VCM" /* for 630 */ "" }; /* TW: MCLK tables for SiS6326 */ @@ -104,7 +99,7 @@ static const struct _sis6326mclk { {134, 0, 0x4a, 0xa3 } }; -/* For 5597, 6326, 530/620 */ +/* For old chipsets, 5597, 6326, 530/620 */ static void sisOldSetup(ScrnInfoPtr pScrn) { @@ -115,23 +110,28 @@ 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 pciConfigPtr pdptr, *systemPCIdevices = NULL; - if(pSiS->Chipset == PCI_CHIP_SIS5597) { - inSISIDXREG(SISSR, FBSize, temp); + if(pSiS->oldChipset <= OC_SIS6225) { + inSISIDXREG(SISSR, 0x0F, temp); + pScrn->videoRam = (1 << (temp & 0x03)) * 1024; + if(pScrn->videoRam > 4096) pScrn->videoRam = 4096; + pSiS->BusWidth = 32; + } else if(pSiS->Chipset == PCI_CHIP_SIS5597) { + inSISIDXREG(SISSR, 0x2F, temp); pScrn->videoRam = ((temp & 0x07) + 1) * 256; - inSISIDXREG(SISSR, Mode64, temp); + inSISIDXREG(SISSR, 0x0C, temp); if(temp & 0x06) { pScrn->videoRam *= 2; pSiS->BusWidth = 64; } else pSiS->BusWidth = 32; } else { - inSISIDXREG(SISSR, RAMSize, temp); - config = ((temp & 0x10) >> 2 ) | ((temp & 0x6) >> 1); + inSISIDXREG(SISSR, 0x0C, temp); + config = ((temp & 0x10) >> 2 ) | ((temp & 0x06) >> 1); pScrn->videoRam = ramsize[config] * 1024; pSiS->BusWidth = buswidth[config]; } @@ -141,18 +141,19 @@ sisOldSetup(ScrnInfoPtr pScrn) inSISIDXREG(SISSR, 0x0D, temp); pSiS->Flags &= ~(UMA); if(temp & 0x01) { - pSiS->Flags |= UMA; /* TW: Shared fb mode */ + pSiS->Flags |= UMA; /* Shared fb mode */ inSISIDXREG(SISSR, 0x10, temp); pSiS->MemClock = clockTable[temp & 0x03] * 1000; - } else pSiS->MemClock = SiSMclk(pSiS); /* TW: Local fb mode */ + } else pSiS->MemClock = SiSMclk(pSiS); /* Local fb mode */ } else if(pSiS->Chipset == PCI_CHIP_SIS6326) { inSISIDXREG(SISSR,0x0e,temp); + i = temp & 0x03; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected DRAM type: %s\n", + "DRAM type: %s\n", dramTypeStr[ramtype[i]]); temp = (temp >> 5) & 0x07; @@ -192,13 +193,13 @@ 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 */ pSiS->Flags |= RAMFLAG; /* 530: Enable SGRAM timing | reserved (0) */ - } else if(sr23 & 0x20) { /* 5597, 6326: EDO DRAM enabled */ - pSiS->Flags |= SYNCDRAM; /* 530/620: reserved (0) */ - } + } else if((pSiS->oldChipset < OC_SIS530A) && (sr23 & 0x20)) { + pSiS->Flags |= SYNCDRAM; /* 5597, 6326: EDO DRAM enabled */ + } /* 530/620: reserved (0) */ } pSiS->Flags &= ~(ESS137xPRESENT); @@ -238,12 +239,19 @@ sisOldSetup(ScrnInfoPtr pScrn) } xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected memory clock: %3.3f MHz\n", + "Memory clock: %3.3f MHz\n", pSiS->MemClock/1000.0); - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected DRAM bus width: %d bit\n", + if(pSiS->oldChipset > OC_SIS6225) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "DRAM bus width: %d bit\n", pSiS->BusWidth); + } + +#ifdef TWDEBUG + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "oldChipset = %d, Flags %x\n", pSiS->oldChipset, pSiS->Flags); +#endif } static void @@ -255,28 +263,52 @@ sis300Setup(ScrnInfoPtr pScrn) 100, 100, 100, 100}; const int adaptermclk300[8] = { 125, 125, 125, 100, 100, 100, 100, 100}; - unsigned int config; + unsigned int config, pciconfig, sr3a, ramtype; unsigned char temp; int cpubuswidth; - int from = X_PROBED; + MessageType from = X_PROBED; pSiS->MemClock = SiSMclk(pSiS); inSISIDXREG(SISSR, 0x14, config); - pScrn->videoRam = ((config & 0x3F) + 1) * 1024; cpubuswidth = bus[config >> 6]; - + + inSISIDXREG(SISSR, 0x3A, sr3a); + ramtype = (sr3a & 0x03) + 4; + switch(pSiS->Chipset) { case PCI_CHIP_SIS300: + pScrn->videoRam = ((config & 0x3F) + 1) * 1024; pSiS->BusWidth = cpubuswidth; + pSiS->IsAGPCard = ((sr3a & 0x30) == 0x30) ? FALSE : TRUE; break; case PCI_CHIP_SIS540: - pSiS->BusWidth = 64; - from = X_INFO; - break; case PCI_CHIP_SIS630: - pSiS->BusWidth = 64; - from = X_INFO; + pSiS->IsAGPCard = TRUE; + pciconfig = pciReadByte(0x00000000, 0x63); + if(pciconfig & 0x80) { + pScrn->videoRam = (1 << (((pciconfig & 0x70) >> 4) + 21)) / 1024; + pSiS->BusWidth = 64; + pciconfig = pciReadByte(0x00000000, 0x64); + if((pciconfig & 0x30) == 0x30) { + pSiS->BusWidth = 128; + pScrn->videoRam <<= 1; + } + ramtype = pciReadByte(0x00000000,0x65); + ramtype &= 0x03; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Shared Memory Area is on DIMM%d\n", ramtype); + ramtype = pciReadByte(0x00000000,(0x60 + ramtype)); + if(ramtype & 0x80) ramtype = 9; + else ramtype = 4; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Shared Memory Area is disabled - awaiting doom\n"); + pScrn->videoRam = ((config & 0x3F) + 1) * 1024; + pSiS->BusWidth = 64; + ramtype = 4; + from = X_INFO; + } break; default: xf86DrvMsg(pScrn->scrnIndex, X_ERROR, @@ -285,14 +317,12 @@ sis300Setup(ScrnInfoPtr pScrn) from = X_INFO; } - inSISIDXREG(SISSR, 0x3A, config); - config &= 0x03; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected DRAM type: %s\n", - dramTypeStr[config+4]); + "DRAM type: %s\n", + dramTypeStr[ramtype]); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected memory clock: %3.3f MHz\n", + "Memory clock: %3.3f MHz\n", pSiS->MemClock/1000.0); if(pSiS->Chipset == PCI_CHIP_SIS300) { @@ -310,21 +340,20 @@ sis300Setup(ScrnInfoPtr pScrn) } xf86DrvMsg(pScrn->scrnIndex, from, - "%s DRAM bus width: %d bit\n", - (from == X_PROBED) ? "Detected" : "Assuming", + "DRAM bus width: %d bit\n", pSiS->BusWidth); } -/* TW: for 315, 315H, 315PRO, 330 */ +/* For 315, 315H, 315PRO, 330 */ static void -sis310Setup(ScrnInfoPtr pScrn) +sis315Setup(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); int busSDR[4] = {64, 64, 128, 128}; int busDDR[4] = {32, 32, 64, 64}; int busDDRA[4] = {64+32, 64+32 , (64+32)*2, (64+32)*2}; - unsigned int config, config1, config2; - char *dramTypeStr310[] = { + 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", @@ -361,17 +390,21 @@ sis310Setup(ScrnInfoPtr pScrn) inSISIDXREG(SISSR, 0x14, config); config1 = (config & 0x0C) >> 2; - inSISIDXREG(SISSR, 0x3A, config2); - config2 &= 0x03; + inSISIDXREG(SISSR, 0x3A, sr3a); + config2 = sr3a & 0x03; pScrn->videoRam = (1 << ((config & 0xF0) >> 4)) * 1024; if(pSiS->Chipset == PCI_CHIP_SIS330) { + pSiS->IsAGPCard = TRUE; + if(config1) pScrn->videoRam <<= 1; } 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)) pScrn->videoRam <<= 1; @@ -385,13 +418,13 @@ sis310Setup(ScrnInfoPtr pScrn) pSiS->MemClock = SiSMclk(pSiS); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected DRAM type: %s\n", + "DRAM type: %s\n", (pSiS->Chipset == PCI_CHIP_SIS330) ? dramTypeStr330[(config1 * 4) + (config2 & 0x02)] : - dramTypeStr310[(config1 * 4) + config2]); + dramTypeStr315[(config1 * 4) + config2]); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected memory clock: %3.3f MHz\n", + "Memory clock: %3.3f MHz\n", pSiS->MemClock/1000.0); /* TW: DDR -> mclk * 2 - needed for bandwidth calculation */ @@ -421,71 +454,178 @@ sis310Setup(ScrnInfoPtr pScrn) } xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected DRAM bus width: %d bit\n", + "DRAM bus width: %d bit\n", pSiS->BusWidth); } -/* TW: for 550, 650, 740 */ +/* For 550, 65x, 740, 661, 741, 660, 760 */ static void sis550Setup(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - unsigned int config; - CARD8 pcimemcode; + unsigned int config, ramtype=0, i; + CARD8 pciconfig, temp; + BOOLEAN alldone = FALSE; - /* TW: Some of the following is guessed; however, - since our mode switching code is omniscient - anyway, we only need some reasonable values - to prevent X from deleting modes from the - list - */ + pSiS->IsAGPCard = TRUE; - inSISIDXREG(SISSR, 0x14, config); + pSiS->MemClock = SiSMclk(pSiS); - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected DRAM type: %s\n", - dramTypeStr[(((config & 0x80) >> 7) << 2) + 4]); + if(pSiS->Chipset == PCI_CHIP_SIS660) { - pSiS->MemClock = SiSMclk(pSiS); + if(pSiS->sishw_ext.jChipType >= SIS_660) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected memory clock: %3.3f MHz\n", - pSiS->MemClock/1000.0); + /* UMA - shared fb */ + pSiS->ChipFlags &= ~SiSCF_760UMA; + 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\n", + pScrn->videoRam); + } else pScrn->videoRam = 0; + + /* LFB - local framebuffer */ + pciconfig = (pciReadByte(0x00000800, 0xcd) >> 1) & 0x03; + if(pciconfig == 0x01) pScrn->videoRam += 32768; + else if(pciconfig == 0x03) pScrn->videoRam += 65536; + + if((pScrn->videoRam < 32768) || (pScrn->videoRam > 131072)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal video Ram size (%d) detected, using BIOS setting\n", + pScrn->videoRam); + } else { + pSiS->BusWidth = 64; + ramtype = 8; + alldone = TRUE; + } + + } else { + + int dimmnum, maxmem; + + if(pSiS->sishw_ext.jChipType == SIS_741) { + dimmnum = 4; + maxmem = 131072; + } else { /* 661 */ + dimmnum = 3; + maxmem = 65536; + } - /* TW: DDR -> Mclk * 2 - needed for bandwidth calculation */ - if(config & 0x80) pSiS->MemClock *= 2; + pciconfig = pciReadByte(0x00000000, 0x64); + if(pciconfig & 0x80) { + pScrn->videoRam = (1 << (((pciconfig & 0x70) >> 4) - 1)) * 32768; + if((pScrn->videoRam < 32768) || (pScrn->videoRam > maxmem)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal video RAM size (%d) detected, using BIOS 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); + if(pciconfig & 0x02) ramtype = 8; + else ramtype = 4; + if(pSiS->sishw_ext.jChipType == SIS_741) { + /* Is this really correct? */ + ramtype = 12 - ramtype; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SiS741 PCI RamType %d\n", ramtype); + /* For now, we don't trust it */ + inSISIDXREG(SISSR, 0x79, config); + ramtype = (config & 0x01) ? 8 : 4; + } + alldone = TRUE; + } + } - pSiS->BusWidth = (config & 0x40) ? 128 : 64; + } + + } else if(pSiS->Chipset == PCI_CHIP_SIS650) { + + 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); + } + } + pciconfig = pciReadByte(0x00000000, 0x7c); + if(pciconfig & 0x02) ramtype = 8; + else ramtype = 4; + alldone = TRUE; + } + + } else { + + pciconfig = pciReadByte(0x00000000, 0x63); + if(pciconfig & 0x80) { + pScrn->videoRam = (1 << (((pciconfig & 0x70) >> 4) + 21)) / 1024; + pSiS->BusWidth = 64; + ramtype = pciReadByte(0x00000000,0x65); + ramtype &= 0x01; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Shared Memory Area is on DIMM%d\n", ramtype); + ramtype = 4; + alldone = TRUE; + } + + } + + if(!alldone) { + + if(pSiS->Chipset == PCI_CHIP_SIS660) { + inSISIDXREG(SISSR, 0x79, config); + pScrn->videoRam = (1 << ((config & 0xf0) >> 4)) * 1024; + pSiS->BusWidth = (config & 0x04) ? 128 : 64; + ramtype = (config & 0x01) ? 8 : 4; + } else { + 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; + } + } + } + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "DRAM type: %s\n", + dramTypeStr[ramtype]); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Memory clock: %3.3f MHz\n", + pSiS->MemClock/1000.0); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected DRAM bus width: %d bit\n", + "DRAM bus width: %d bit\n", pSiS->BusWidth); - pScrn->videoRam = (((config & 0x3F) + 1) * 4) * 1024; - - /* TW: Some 550 BIOSes don't seem to set SR14 correctly. We have - * to read PCI configuration in order to get a correct size. - */ - if (pSiS->Chipset == PCI_CHIP_SIS550) { - if((pScrn->videoRam != 4*1024) && - (pScrn->videoRam != 8*1024) && - (pScrn->videoRam != 16*1024) && - (pScrn->videoRam != 24*1024) && - (pScrn->videoRam != 32*1024) && - (pScrn->videoRam != 48*1024) && - (pScrn->videoRam != 64*1024) && - (pScrn->videoRam != 96*1024) && - (pScrn->videoRam != 128*1024) && - (pScrn->videoRam != 256*1024)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Invalid memory size (%d) encountered, reading PCI configuration\n", - pScrn->videoRam); - pcimemcode = pciReadByte(0x00000000, 0x63); - pScrn->videoRam = (1 << (((pcimemcode & 0x70) >> 4) + 21)) / 1024; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "PCI config reported %dKB video RAM\n", pScrn->videoRam); - } - } + /* DDR -> Mclk * 2 - needed for bandwidth calculation */ + if(ramtype == 8) pSiS->MemClock *= 2; } void @@ -497,11 +637,6 @@ SiSSetup(ScrnInfoPtr pScrn) pSiS->VBFlags = 0; switch (SISPTR(pScrn)->Chipset) { - case PCI_CHIP_SIS5597: - case PCI_CHIP_SIS6326: - case PCI_CHIP_SIS530: - sisOldSetup(pScrn); - break; case PCI_CHIP_SIS300: case PCI_CHIP_SIS630: /* +730 */ case PCI_CHIP_SIS540: @@ -511,16 +646,18 @@ SiSSetup(ScrnInfoPtr pScrn) case PCI_CHIP_SIS315H: case PCI_CHIP_SIS315PRO: case PCI_CHIP_SIS330: - sis310Setup(pScrn); + sis315Setup(pScrn); break; case PCI_CHIP_SIS550: case PCI_CHIP_SIS650: /* + 740 */ + case PCI_CHIP_SIS660: /* + 661,741,660,760 */ sis550Setup(pScrn); break; + case PCI_CHIP_SIS5597: + case PCI_CHIP_SIS6326: + case PCI_CHIP_SIS530: default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Internal error: SiSSetup() called with invalid Chipset (0x%x)\n", - pSiS->Chipset); + sisOldSetup(pScrn); break; } } diff --git a/src/sis_shadow.c b/src/sis_shadow.c index dfc920e..2c85f79 100644 --- a/src/sis_shadow.c +++ b/src/sis_shadow.c @@ -1,7 +1,25 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_shadow.c,v 1.4 2003/01/29 15:42:17 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_shadow.c,v 1.8 2003/10/30 18:53:43 twini Exp $ */ /* - * Copyright (c) 1999, The XFree86 Project Inc. - * based on code written by Mark Vojkovich <markv@valinux.com> + * Copyright (c) 1999, The XFree86 Project Inc. + * based on code written by Mark Vojkovich <markv@valinux.com> + * + * 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. * * TW: This module doesn't use CurrentLayout, because it is never * active when DGA is active and vice versa. diff --git a/src/sis_vb.c b/src/sis_vb.c index d8ed114..cbfeb07 100644 --- a/src/sis_vb.c +++ b/src/sis_vb.c @@ -1,29 +1,29 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.c,v 1.10 2003/01/29 15:42:17 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.c,v 1.31 2003/11/19 00:49:06 twini Exp $ */ /* - * Video bridge detection and configuration for 300 and 310/325 series + * Video bridge detection and configuration for 300, 315 and 330 series * - * Copyright 2002 by Thomas Winischhofer, Vienna, Austria + * Copyright 2002, 2003 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 Thomas Winischhofer not be used in + * 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. Thomas Winischhofer makes no representations + * 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. * - * THOMAS WINISCHHOFER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THOMAS WINISCHHOFER BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * 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 <thomas@winischhofer.net> - * (Completely rewritten) + * */ #include "xf86.h" @@ -34,117 +34,175 @@ #include "sis.h" #include "sis_regs.h" #include "sis_vb.h" +#include "sis_dac.h" + +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, 1}, /* 0 - invalid */ - { VB_LCD_800x600, 800, 600, LCD_800x600, 0}, /* 1 */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1}, /* 2 */ - { VB_LCD_1280x1024,1280, 1024, LCD_1280x1024, 2}, /* 3 */ - { VB_LCD_1280x960, 1280, 960, LCD_1280x960, 3}, /* 4 */ - { VB_LCD_640x480, 640, 480, LCD_640x480, 4}, /* 5 */ - { VB_LCD_1024x600, 1024, 600, LCD_1024x600, 10}, /* 6 */ - { VB_LCD_1152x768, 1152, 768, LCD_1152x768, 7}, /* 7 */ - { VB_LCD_320x480, 320, 480, LCD_320x480, 6}, /* 8 */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1}, /* 9 */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1}, /* a */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1}, /* b */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1}, /* c */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1}, /* d */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1}, /* e */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1}, /* f */ + { 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 */ }; -static const SiS_LCD_StStruct SiS310_LCD_Type[]= +static const SiS_LCD_StStruct SiS315_LCD_Type[]= { - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1}, /* 0 - invalid */ - { VB_LCD_800x600, 800, 600, LCD_800x600, 0}, /* 1 */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1}, /* 2 */ - { VB_LCD_1280x1024, 1280,1024, LCD_1280x1024, 2}, /* 3 */ - { VB_LCD_640x480, 640, 480, LCD_640x480, 4}, /* 4 */ - { VB_LCD_1024x600, 1024, 600, LCD_1024x600, 10}, /* 5 */ - { VB_LCD_1152x864, 1152, 864, LCD_1152x864, 11}, /* 6 */ - { VB_LCD_1280x960, 1280, 960, LCD_1280x960, 3}, /* 7 */ - { VB_LCD_1152x768, 1152, 768, LCD_1152x768, 7}, /* 8 */ - { VB_LCD_1400x1050, 1400,1050, LCD_1400x1050, 8}, /* 9 */ - { VB_LCD_1280x768, 1280, 768, LCD_1280x768, 9}, /* a */ - { VB_LCD_1600x1200, 1600,1200, LCD_1600x1200, 5}, /* b */ - { VB_LCD_320x480, 320, 480, LCD_320x480, 6}, /* c */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1}, /* d */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1}, /* e */ - { VB_LCD_1024x768, 1024, 768, LCD_1024x768, 1} /* f */ + { 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 */ }; -static const char *panelres[] = { - "800x600", - "1024x768", - "1280x1024", - "1280x960", - "640x480", - "1600x1200", - "320x480", - "1152x768", - "1400x1050", - "1280x768", - "1024x600", - "1152x864" -}; +static Bool +TestDDC1(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + unsigned short old; + int count = 48; + + old = SiS_ReadDDC1Bit(pSiS->SiS_Pr); + do { + if(old != SiS_ReadDDC1Bit(pSiS->SiS_Pr)) break; + } while(count--); + return (count == -1) ? FALSE : TRUE; +} + +static int +SiS_SISDetectCRT1(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + 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); + if(SR1F & 0xc0) mustwait = TRUE; + + if(pSiS->VGAEngine == SIS_315_VGA) { + inSISIDXREG(SISCR,0x63,CR63); + CR63 &= 0x40; + andSISIDXREG(SISCR,0x63,0xBF); + } + + inSISIDXREG(SISCR,0x17,CR17); + CR17 &= 0x80; + if(!CR17) { + orSISIDXREG(SISCR,0x17,0x80); + mustwait = TRUE; + outSISIDXREG(SISSR, 0x00, 0x01); + outSISIDXREG(SISSR, 0x00, 0x03); + } + + if(mustwait) { + for(i=0; i < 10; i++) SISWaitRetraceCRT1(pScrn); + } + + i = 3; + do { + temp = SiS_HandleDDC(pSiS->SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 0, 0, NULL); + } while(((temp == 0) || (temp == 0xffff)) && i--); + + if((temp == 0) || (temp == 0xffff)) { + if(TestDDC1(pScrn)) temp = 1; + } + + if((temp) && (temp != 0xffff)) { + orSISIDXREG(SISCR,0x32,0x20); + ret = 1; + } + + if(pSiS->VGAEngine == SIS_315_VGA) { + setSISIDXREG(SISCR,0x63,0xBF,CR63); + } + + setSISIDXREG(SISCR,0x17,0x7F,CR17); + + outSISIDXREG(SISSR,0x1F,SR1F); + + return ret; +} /* Detect CRT1 */ void SISCRT1PreInit(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - unsigned char CR32, SR17; + unsigned char CR32; unsigned char CRT1Detected = 0; unsigned char OtherDevices = 0; if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) { - pSiS->CRT1off = 0; - return; + pSiS->CRT1off = 0; + return; } #ifdef SISDUALHEAD - if(pSiS->DualHeadMode && pSiS->SecondHead) { - pSiS->CRT1off = 0; - return; + if(pSiS->DualHeadMode) { + pSiS->CRT1off = 0; + return; } #endif - inSISIDXREG(SISCR, 0x32, CR32); - inSISIDXREG(SISSR, 0x17, SR17); - - if ( (pSiS->VGAEngine == SIS_300_VGA) && - (pSiS->Chipset != PCI_CHIP_SIS300) && - (SR17 & 0x0F) ) { - - if(SR17 & 0x01) CRT1Detected = 1; - if(SR17 & 0x0E) OtherDevices = 1; +#ifdef SISMERGED + if((pSiS->MergedFB) && (!(pSiS->MergedFBAuto))) { + pSiS->CRT1off = 0; + return; + } +#endif - } else { + inSISIDXREG(SISCR, 0x32, CR32); - if(CR32 & 0x20) CRT1Detected = 1; - if(CR32 & 0x5F) OtherDevices = 1; + if(CR32 & 0x20) CRT1Detected = 1; + else CRT1Detected = SiS_SISDetectCRT1(pScrn); - } + if(CR32 & 0x5F) OtherDevices = 1; if(pSiS->CRT1off == -1) { - if(!CRT1Detected) { + if(!CRT1Detected) { - /* BIOS detected no CRT1. */ - /* If other devices exist, switch it off */ - if(OtherDevices) pSiS->CRT1off = 1; - else pSiS->CRT1off = 0; + /* No CRT1 detected. */ + /* If other devices exist, switch it off */ + if(OtherDevices) pSiS->CRT1off = 1; + else pSiS->CRT1off = 0; - } else { + } else { - /* BIOS detected CRT1, leave/switch it on */ - pSiS->CRT1off = 0; + /* 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 "); } @@ -152,85 +210,163 @@ void SISCRT1PreInit(ScrnInfoPtr pScrn) void SISLCDPreInit(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - unsigned char CR32, SR17, CR36, CR37; - USHORT textindex; + unsigned char CR32, CR36, CR37; - if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) { - return; - } + if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) return; inSISIDXREG(SISCR, 0x32, CR32); - inSISIDXREG(SISSR, 0x17, SR17); - - if( (pSiS->VGAEngine == SIS_300_VGA) && - (pSiS->Chipset != PCI_CHIP_SIS300) && - (SR17 & 0x0F) ) { - if(SR17 & 0x02) - pSiS->VBFlags |= CRT2_LCD; - } else { - if(CR32 & 0x08) - pSiS->VBFlags |= CRT2_LCD; + + if(CR32 & 0x08) pSiS->VBFlags |= CRT2_LCD; + + /* 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 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))) { + + if(pSiS->forcecrt2redetection) { + pSiS->VBFlags &= ~CRT2_LCD; + } + + 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(SiS_SenseLCDDDC(pSiS->SiS_Pr, pSiS)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "DDC error during LCD panel detection\n"); + } else { + inSISIDXREG(SISCR, 0x32, CR32); + if(CR32 & 0x08) { + pSiS->VBFlags |= CRT2_LCD; + pSiS->postVBCR32 |= 0x08; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "No LCD/Plasma panel detected\n"); + } + } + } + } + + } +#ifdef SISDUALHEAD } +#endif if(pSiS->VBFlags & CRT2_LCD) { - inSISIDXREG(SISCR, 0x36, CR36); - inSISIDXREG(SISCR, 0x37, CR37); - if((pSiS->VGAEngine == SIS_315_VGA) && (!CR36)) { - /* TW: 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; - else pSiS->SiS_Pr->SiS_IF_DEF_LVDS = 0; - SiS_GetPanelID(pSiS->SiS_Pr, &pSiS->sishw_ext); - inSISIDXREG(SISCR, 0x36, CR36); - inSISIDXREG(SISCR, 0x37, CR37); - } - if(pSiS->VGAEngine == SIS_300_VGA) { - 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; - textindex = SiS300_LCD_Type[(CR36 & 0x0f)].LCDrestextindex; - } else { - pSiS->VBLCDFlags |= SiS310_LCD_Type[(CR36 & 0x0f)].VBLCD_lcdflag; - pSiS->LCDheight = SiS310_LCD_Type[(CR36 & 0x0f)].LCDheight; - pSiS->LCDwidth = SiS310_LCD_Type[(CR36 & 0x0f)].LCDwidth; - pSiS->sishw_ext.ulCRT2LCDType = SiS310_LCD_Type[(CR36 & 0x0f)].LCDtype; - textindex = SiS310_LCD_Type[(CR36 & 0x0f)].LCDrestextindex; - } - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected LCD panel resolution %s (type %d, %s%s)\n", - panelres[textindex], - (pSiS->VGAEngine == SIS_315_VGA) ? ((CR36 & 0x0f) - 1) : ((CR36 & 0xf0) >> 4), - (pSiS->VBFlags & VB_LVDS) ? - (CR37 & 0x10 ? "non-expanding, " : "expanding, ") : - ( ((pSiS->VBFlags & VB_301B) && (pSiS->VGAEngine == SIS_300_VGA)) ? - (CR37 & 0x10 ? "non-expanding, " : "expanding, ") : - (CR37 & 0x10 ? "self-scaling, " : "non-self-scaling, ") ), - CR37 & 0x01 ? "RGB18" : "RGB24"); + inSISIDXREG(SISCR, 0x36, CR36); + inSISIDXREG(SISCR, 0x37, CR37); + if(pSiS->SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + pSiS->VBLCDFlags |= VB_LCD_BARCO1366; + pSiS->LCDwidth = 1360; + pSiS->LCDheight = 1024; + if(CR37 & 0x10) pSiS->VBLCDFlags |= VB_LCD_EXPANDING; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Detected LCD panel (%dx%d, type %d, %sexpanding, RGB%d)\n", + pSiS->LCDwidth, pSiS->LCDheight, + ((CR36 & 0xf0) >> 4), + (CR37 & 0x10) ? "" : "non-", + (CR37 & 0x01) ? 18 : 24); + } else if(pSiS->SiS_Pr->SiS_CustomT == CUT_PANEL848) { + pSiS->VBLCDFlags |= VB_LCD_848x480; + 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 */ + 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; + else pSiS->SiS_Pr->SiS_IF_DEF_LVDS = 0; + SiS_GetPanelID(pSiS->SiS_Pr, &pSiS->sishw_ext); + inSISIDXREG(SISCR, 0x36, CR36); + inSISIDXREG(SISCR, 0x37, CR37); + } + if(((CR36 & 0x0f) == 0x0f) && (pSiS->SiS_Pr->CP_HaveCustomData)) { + 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", + pSiS->SiS_Pr->CP_MaxX, pSiS->SiS_Pr->CP_MaxY, + pSiS->SiS_Pr->CP_PreferredX, pSiS->SiS_Pr->CP_PreferredY, + (CR37 & 0x01) ? 18 : 24); + } else { + if(pSiS->VGAEngine == SIS_300_VGA) { + 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 { + 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, %d, %sexp., RGB%d [%02x%02x])\n", + pSiS->LCDwidth, pSiS->LCDheight, + ((pSiS->VGAEngine == SIS_315_VGA) && + (pSiS->Chipset != PCI_CHIP_SIS660)) ? + ((CR36 & 0x0f) - 1) : ((CR36 & 0xf0) >> 4), + (CR37 & 0x10) ? "" : "non-", + (CR37 & 0x01) ? 18 : 24, + CR36, CR37); + } + } } + } /* Detect CRT2-TV connector type and PAL/NTSC flag */ void SISTVPreInit(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - unsigned char SR16, SR17, SR38, CR32, CR38=0, CR79; + unsigned char SR16, SR38, CR32, CR35=0, CR38=0, CR79; int temp = 0; if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) return; inSISIDXREG(SISCR, 0x32, CR32); - inSISIDXREG(SISSR, 0x17, SR17); inSISIDXREG(SISSR, 0x16, SR16); inSISIDXREG(SISSR, 0x38, SR38); switch(pSiS->VGAEngine) { case SIS_300_VGA: - if(pSiS->Chipset != PCI_CHIP_SIS300) temp = 0x35; + if(pSiS->Chipset == PCI_CHIP_SIS630) temp = 0x35; break; case SIS_315_VGA: - temp = 0x38; + if(pSiS->Chipset != PCI_CHIP_SIS660) temp = 0x38; break; } if(temp) { @@ -238,83 +374,84 @@ void SISTVPreInit(ScrnInfoPtr pScrn) } #ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "(vb.c: SR17=%02x CR32=%02x)\n", SR17, CR32); - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "(vb.c: SR16=%02x SR38=%02x)\n", SR16, SR38); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "(vb.c: CR32=%02x SR16=%02x SR38=%02x)\n", + CR32, SR16, SR38); #endif - if( (pSiS->VGAEngine == SIS_300_VGA) && - (pSiS->Chipset != PCI_CHIP_SIS300) && - (SR17 & 0x0F) ) { - - if(SR17 & 0x04) - pSiS->VBFlags |= CRT2_TV; - - if(SR17 & 0x20) - pSiS->VBFlags |= TV_SVIDEO; - else if (SR17 & 0x10) - pSiS->VBFlags |= TV_AVIDEO; - - if(pSiS->VBFlags & (TV_SVIDEO | TV_AVIDEO)) { - if(SR16 & 0x20) - pSiS->VBFlags |= TV_PAL; - else - pSiS->VBFlags |= TV_NTSC; - } - - } else { - - if(CR32 & 0x47) - pSiS->VBFlags |= CRT2_TV; - - if(CR32 & 0x04) - pSiS->VBFlags |= TV_SCART; - 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_CHRONTEL)) - pSiS->VBFlags |= (TV_CHSCART | TV_PAL); - else if((CR38 & 0x08) && (pSiS->VBFlags & VB_CHRONTEL)) - pSiS->VBFlags |= (TV_CHHDTV | TV_NTSC); + if(CR32 & 0x47) + pSiS->VBFlags |= CRT2_TV; + + if(CR32 & 0x04) + pSiS->VBFlags |= TV_SCART; + 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_301C | VB_301LV | VB_302LV | VB_302ELV))) + pSiS->VBFlags |= TV_HIVISION_LV; + 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)) { - if( (pSiS->Chipset == PCI_CHIP_SIS550) || /* TW: ? */ - (pSiS->Chipset == PCI_CHIP_SIS650) ) { - inSISIDXREG(SISCR, 0x79, CR79); - if(CR79 & 0x20) { - pSiS->VBFlags |= TV_PAL; - if(CR38 & 0x40) pSiS->VBFlags |= TV_PALM; - else if(CR38 & 0x80) pSiS->VBFlags |= TV_PALN; - } else - pSiS->VBFlags |= TV_NTSC; - } else if(pSiS->VGAEngine == SIS_300_VGA) { - /* TW: Should be SR38 here as well, but this - * does not work. Looks like a BIOS bug (2.04.5c). - */ - if(SR16 & 0x20) - pSiS->VBFlags |= TV_PAL; - else - pSiS->VBFlags |= TV_NTSC; - } else { /* 315, 330 */ - if(SR38 & 0x01) { - pSiS->VBFlags |= TV_PAL; - if(CR38 & 0x40) pSiS->VBFlags |= TV_PALM; - else if(CR38 & 0x80) pSiS->VBFlags |= TV_PALN; - } else - pSiS->VBFlags |= TV_NTSC; - } - } + if(pSiS->VBFlags & (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION | TV_HIVISION_LV)) { + if(pSiS->VGAEngine == SIS_300_VGA) { + /* TW: Should be SR38, but this does not work. */ + if(SR16 & 0x20) + pSiS->VBFlags |= TV_PAL; + else + pSiS->VBFlags |= TV_NTSC; + } else if(pSiS->Chipset == PCI_CHIP_SIS550) { + inSISIDXREG(SISCR, 0x7a, CR79); + if(CR79 & 0x08) { + inSISIDXREG(SISCR, 0x79, CR79); + CR79 >>= 5; + } + if(CR79 & 0x01) { + pSiS->VBFlags |= TV_PAL; + if(CR38 & 0x40) pSiS->VBFlags |= TV_PALM; + else if(CR38 & 0x80) pSiS->VBFlags |= TV_PALN; + } else + pSiS->VBFlags |= TV_NTSC; + } else if(pSiS->Chipset == PCI_CHIP_SIS650) { + inSISIDXREG(SISCR, 0x79, CR79); + if(CR79 & 0x20) { + pSiS->VBFlags |= TV_PAL; + if(CR38 & 0x40) pSiS->VBFlags |= TV_PALM; + else if(CR38 & 0x80) pSiS->VBFlags |= TV_PALN; + } else + pSiS->VBFlags |= TV_NTSC; + } else if(pSiS->Chipset == PCI_CHIP_SIS660) { + inSISIDXREG(SISCR, 0x35, CR35); + 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; + if(CR38 & 0x40) pSiS->VBFlags |= TV_PALM; + else if(CR38 & 0x80) pSiS->VBFlags |= TV_PALN; + } else + pSiS->VBFlags |= TV_NTSC; + } } - if(pSiS->VBFlags & (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION | TV_CHSCART | TV_CHHDTV)) { + + 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_NTSC) ? + ((pSiS->VBFlags & TV_CHHDTV) ? "480i HDTV" : + ((pSiS->VBFlags & TV_NTSCJ) ? "NTSCJ" : "NTSC")) : ((pSiS->VBFlags & TV_PALM) ? "PALM" : - ((pSiS->VBFlags & TV_PALN) ? "PALN" : "PAL"))); + ((pSiS->VBFlags & TV_PALN) ? "PALN" : "PAL")) ); } } @@ -322,31 +459,62 @@ void SISTVPreInit(ScrnInfoPtr pScrn) void SISCRT2PreInit(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - unsigned char SR17, CR32; + unsigned char CR32; - if (!(pSiS->VBFlags & VB_VIDEOBRIDGE)) - return; + if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) + return; - /* CRT2-VGA not supported on LVDS and 30xLV(X) */ - if (pSiS->VBFlags & (VB_LVDS|VB_30xLV|VB_30xLVX)) - return; + /* CRT2-VGA not supported on LVDS and 30xLV */ + if(pSiS->VBFlags & (VB_LVDS|VB_301LV|VB_302LV|VB_302ELV)) + return; inSISIDXREG(SISCR, 0x32, CR32); - inSISIDXREG(SISSR, 0x17, SR17); - - if( (pSiS->VGAEngine == SIS_300_VGA) && - (pSiS->Chipset != PCI_CHIP_SIS300) && - (SR17 & 0x0F) ) { - - if(SR17 & 0x08) - pSiS->VBFlags |= CRT2_VGA; + + if(CR32 & 0x10) pSiS->VBFlags |= CRT2_VGA; - } else { +#ifdef SISDUALHEAD + if((!pSiS->DualHeadMode) || (!pSiS->SecondHead)) { +#endif - if(CR32 & 0x10) - pSiS->VBFlags |= CRT2_VGA; - + if(pSiS->forcecrt2redetection) { + pSiS->VBFlags &= ~CRT2_VGA; + } + + /* We don't trust the normal sensing method for VGA2 since + * it is performed by the BIOS during POST, and it is + * impossible to sense VGA2 if the bridge is disabled. + * Therefore, we try sensing VGA2 by DDC as well (if not + * detected otherwise and only if there is no LCD panel + * 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 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, + "Detected secondary VGA connection\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "No secondary VGA connection detected\n"); + } + } + } + } + } +#ifdef SISDUALHEAD } +#endif } diff --git a/src/sis_vga.c b/src/sis_vga.c index 0ab8b8d..1e056c7 100644 --- a/src/sis_vga.c +++ b/src/sis_vga.c @@ -1,9 +1,11 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c,v 1.16 2003/01/29 15:42:17 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c,v 1.38 2003/11/19 00:49:06 twini Exp $ */ /* - * Mode setup and video bridge detection + * Mode setup and basic video bridge detection * - * Copyright 1998,1999 by Alan Hourihane, Wigan, England. - * Parts Copyright 2001, 2002 by Thomas Winischhofer, Vienna, Austria. + * Copyright 2001, 2002, 2003 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. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -23,12 +25,9 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Authors: Alan Hourihane, alanh@fairlite.demon.co.uk - * Mike Chapman <mike@paranoia.com>, - * Juanjo Santamarta <santamarta@ctv.es>, - * Mitani Hiroshi <hmitani@drl.mei.co.jp> - * David Thomas <davtom@dream.org.uk>. - * Thomas Winischhofer <thomas@winischhofer.net> + * Authors: Thomas Winischhofer <thomas@winischhofer.net> + * ... + * */ #include "xf86.h" @@ -42,39 +41,43 @@ #include "sis_regs.h" #include "sis_dac.h" -#define Midx 0 -#define Nidx 1 -#define VLDidx 2 -#define Pidx 3 -#define PSNidx 4 -#define Fref 14318180 -/* stability constraints for internal VCO -- MAX_VCO also determines - * the maximum Video pixel clock */ -#define MIN_VCO Fref -#define MAX_VCO 135000000 -#define MAX_VCO_5597 353000000 -#define MAX_PSN 0 /* no pre scaler for this chip */ -#define TOLERANCE 0.01 /* search smallest M and N in this tolerance */ - +#if 0 +#define TV6326TEST +#endif static Bool SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode); static Bool SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode); -/* TW: 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); +/* To be used internally only */ +static int SISDoSense(ScrnInfoPtr pScrn, int tempbl, int tempbh, int tempcl, int tempch); +static void SISSense30x(ScrnInfoPtr pScrn); +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); + +const CARD8 SiS6326TVRegs1[14] = { + 0x00,0x01,0x02,0x03,0x04,0x11,0x12,0x13,0x21,0x26,0x27,0x3a,0x3c,0x43 +}; const CARD8 SiS6326TVRegs1_NTSC[6][14] = { {0x81,0x3f,0x49,0x1b,0xa9,0x03,0x00,0x09,0x08,0x7d,0x00,0x88,0x30,0x60}, {0x81,0x3f,0x49,0x1d,0xa0,0x03,0x00,0x09,0x08,0x7d,0x00,0x88,0x30,0x60}, {0x81,0x45,0x24,0x8e,0x26,0x0b,0x00,0x09,0x02,0xfe,0x00,0x09,0x51,0x60}, {0x81,0x45,0x24,0x8e,0x26,0x07,0x00,0x29,0x04,0x30,0x10,0x3b,0x61,0x60}, - {0x81,0x3f,0x24,0x8e,0x26,0x09,0x00,0x09,0x02,0x30,0x10,0x3b,0x51,0x60}, + {0x81,0x3f,0x24,0x8e,0x26,0x09,0x00,0x09,0x02,0x30,0x10,0x3b,0x51,0x60}, /* 640x400, 640x480 */ {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, @@ -111,12 +114,23 @@ const CARD8 SiS6326TVRegs2_NTSC[6][54] = { const CARD8 SiS6326TVRegs1_PAL[6][14] = { {0x81,0x2d,0xc8,0x07,0xb2,0x0b,0x00,0x09,0x02,0xed,0x00,0xf8,0x30,0x40}, {0x80,0x2d,0xa4,0x03,0xd9,0x0b,0x00,0x09,0x02,0xed,0x10,0xf8,0x71,0x40}, - {0x81,0x2d,0xa4,0x03,0xd9,0x0b,0x00,0x09,0x02,0xed,0x10,0xf8,0x71,0x40}, - {0x81,0x2d,0xa4,0x03,0xd9,0x0b,0x00,0x09,0x02,0x8f,0x10,0x9a,0x71,0x40}, + {0x81,0x2d,0xa4,0x03,0xd9,0x0b,0x00,0x09,0x02,0xed,0x10,0xf8,0x71,0x40}, /* 640x480 */ + {0x81,0x2d,0xa4,0x03,0xd9,0x0b,0x00,0x09,0x02,0x8f,0x10,0x9a,0x71,0x40}, /* 800x600 */ {0x83,0x63,0xa1,0x7a,0xa3,0x0a,0x00,0x09,0x02,0xb5,0x11,0xc0,0x81,0x59}, /* 800x600u */ {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, @@ -128,12 +142,12 @@ const CARD8 SiS6326TVRegs2_PAL[6][54] = { 0xE5, 0xDF, 0x94, 0xDF, 0xB2, 0x07, 0xFB, 0x07, 0xF7, 0x30, 0x90, 0x98, 0x00, 0x4F, 0x3F, 0x40, 0x62, 0x52, 0x73, 0x57, 0x47, 0x40, 0x6A, 0x5A, 0x73, 0x03, 0xC1, 0xF8, 0x63, 0xB6, 0x03, 0xA0}, - {0x15, 0x4E, 0x35, 0x6E, 0x94, 0x02, 0x04, 0x38, 0x3A, 0x50, 0x3D, + {0x15, 0x4E, 0x35, 0x6E, 0x94, 0x02, 0x04, 0x38, 0x3A, 0x50, 0x3D, /* 640x480 */ 0x70, 0x06, 0x3E, 0x35, 0x6D, 0x94, 0x05, 0x3F, 0x36, 0x6E, 0x94, 0xE5, 0xDF, 0x94, 0xDF, 0xB2, 0x07, 0xFB, 0x07, 0xF7, 0x30, 0x90, 0x98, 0x00, 0x4F, 0x3F, 0x40, 0x62, 0x52, 0x73, 0x57, 0x47, 0x40, 0x6A, 0x5A, 0x73, 0x03, 0xC1, 0xF8, 0x63, 0xB6, 0x03, 0xA0}, - {0x15, 0x4E, 0x35, 0x6E, 0x94, 0x02, 0x04, 0x38, 0x3A, 0x50, 0x3D, + {0x15, 0x4E, 0x35, 0x6E, 0x94, 0x02, 0x04, 0x38, 0x3A, 0x50, 0x3D, /* 800x600 */ 0x70, 0x06, 0x3E, 0x35, 0x6D, 0x94, 0x05, 0x3F, 0x36, 0x6E, 0x94, 0xE5, 0xDF, 0x94, 0xDF, 0xB2, 0x07, 0xFB, 0x07, 0xF7, 0x30, 0x90, 0x98, 0x00, 0x4F, 0x3F, 0x40, 0x62, 0x52, 0x73, 0x57, 0x47, 0x40, @@ -150,9 +164,6 @@ const CARD8 SiS6326TVRegs2_PAL[6][54] = { 0x6A, 0x5A, 0x73, 0xA0, 0xC1, 0x95, 0x73, 0xB6, 0x03, 0xA0} }; -const CARD8 SiS6326TVRegs1[14] = { - 0x00,0x01,0x02,0x03,0x04,0x11,0x12,0x13,0x21,0x26,0x27,0x3a,0x3c,0x43 -}; const CARD8 SiS6326CR[9][15] = { {0x79,0x63,0x64,0x1d,0x6a,0x93,0x00,0x6f,0xf0,0x58,0x8a,0x57,0x57,0x70,0x20}, /* PAL 800x600 */ @@ -195,329 +206,380 @@ SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode) /* Save the registers for further processing */ (*pSiS->SiSSave)(pScrn, pReg); - /* TW: Determine if chosen mode is suitable for TV on the 6326 - and if the mode is one of our special hi-res modes. + /* Determine if chosen mode is suitable for TV on the 6326 + * and if the mode is one of our special hi-res modes. */ sis6326tvmode = FALSE; sis6326himode = FALSE; if(pSiS->Chipset == PCI_CHIP_SIS6326) { - if(pSiS->SiS6326Flags & SIS6326_HASTV) { - if((pSiS->SiS6326Flags & SIS6326_TVDETECTED) && - ((strcmp(mode->name, "PAL800x600") == 0) || /* TW: Special TV modes */ - (strcmp(mode->name, "PAL800x600U") == 0) || - (strcmp(mode->name, "PAL720x540") == 0) || - (strcmp(mode->name, "PAL640x480") == 0) || - (strcmp(mode->name, "NTSC640x480") == 0) || - (strcmp(mode->name, "NTSC640x480U") == 0) || - (strcmp(mode->name, "NTSC640x400") == 0))) { - sis6326tvmode = TRUE; - } else { - pReg->sis6326tv[0x00] &= 0xfb; - } - } - if((strcmp(mode->name, "SIS1280x1024-75") == 0) || /* TW: Special high-res modes */ - (strcmp(mode->name, "SIS1600x1200-60") == 0)) { - sis6326himode = TRUE; - } + if(pSiS->SiS6326Flags & SIS6326_HASTV) { + if((pSiS->SiS6326Flags & SIS6326_TVDETECTED) && + ((strcmp(mode->name, "PAL800x600") == 0) || /* Special TV modes */ + (strcmp(mode->name, "PAL800x600U") == 0) || + (strcmp(mode->name, "PAL720x540") == 0) || + (strcmp(mode->name, "PAL640x480") == 0) || + (strcmp(mode->name, "NTSC640x480") == 0) || + (strcmp(mode->name, "NTSC640x480U") == 0) || + (strcmp(mode->name, "NTSC640x400") == 0))) { + sis6326tvmode = TRUE; + } else { + pReg->sis6326tv[0x00] &= 0xfb; + } + } + if((strcmp(mode->name, "SIS1280x1024-75") == 0) || /* Special high-res modes */ + (strcmp(mode->name, "SIS1600x1200-60") == 0)) { + sis6326himode = TRUE; + } } #ifdef UNLOCK_ALWAYS outSISIDXREG(SISSR, 0x05, 0x86); #endif - pReg->sisRegs3C4[0x06] &= 0x01; + if(!pSiS->UseVESA) { + pReg->sisRegs3C4[0x06] &= 0x01; + } /* set interlace */ if(!(mode->Flags & V_INTERLACE)) { - offset = pSiS->CurrentLayout.displayWidth >> 3; + offset = pSiS->CurrentLayout.displayWidth >> 3; } else { - offset = pSiS->CurrentLayout.displayWidth >> 2; - pReg->sisRegs3C4[0x06] |= 0x20; + offset = pSiS->CurrentLayout.displayWidth >> 2; + if(!pSiS->UseVESA) { + pReg->sisRegs3C4[0x06] |= 0x20; + } } /* Enable Linear and Enhanced Gfx Mode */ - pReg->sisRegs3C4[0x06] |= 0x82; + if(!pSiS->UseVESA) { + pReg->sisRegs3C4[0x06] |= 0x82; + } /* Enable MMIO at PCI Register 14H (D[6:5]: 11) */ - pReg->sisRegs3C4[0x0B] |= 0x60; + if(pSiS->oldChipset >= OC_SIS5597) { + pReg->sisRegs3C4[0x0B] |= 0x60; + } else { + pReg->sisRegs3C4[0x0B] |= 0x20; + pReg->sisRegs3C4[0x0B] &= ~0x40; + } - /* Enable 32bit mem access (D7), read-ahead cache (D4) */ - pReg->sisRegs3C4[0x0C] |= 0xA0; + if(!pSiS->UseVESA) { - /* TW: Some speed-up stuff */ - switch(pSiS->Chipset) { - case PCI_CHIP_SIS5597: - /* TW: enable host bus */ - if(pSiS->NoHostBus) { - pReg->sisRegs3C4[0x34] &= ~0x08; - } else { - pReg->sisRegs3C4[0x34] |= 0x08; - } - /* TW: fall through */ - case PCI_CHIP_SIS6326: - case PCI_CHIP_SIS530: - /* TW: Enable "dual segment register mode" (D2) and "i/o gating while - * write buffer is not empty" (D3) - */ - pReg->sisRegs3C4[0x0B] |= 0x0C; - } + /* Enable 32bit mem access (D7), read-ahead cache (D5) */ + pReg->sisRegs3C4[0x0C] |= 0x80; + if(pSiS->oldChipset > OC_SIS6225) { + pReg->sisRegs3C4[0x0C] |= 0x20; + } - /* set colordepth */ - if(pSiS->Chipset == PCI_CHIP_SIS530) { - pReg->sisRegs3C4[0x09] &= 0x7F; - } - switch(pSiS->CurrentLayout.bitsPerPixel) { - case 8: - break; - case 16: - offset <<= 1; - if(pSiS->CurrentLayout.depth == 15) + /* Some speed-up stuff */ + switch(pSiS->Chipset) { + case PCI_CHIP_SIS5597: + /* enable host bus */ + if(pSiS->NoHostBus) { + pReg->sisRegs3C4[0x34] &= ~0x08; + } else { + pReg->sisRegs3C4[0x34] |= 0x08; + } + /* fall through */ + case PCI_CHIP_SIS6326: + case PCI_CHIP_SIS530: + /* Enable "dual segment register mode" (D2) and "i/o gating while + * write buffer is not empty" (D3) + */ + pReg->sisRegs3C4[0x0B] |= 0x0C; + } + + /* set colordepth */ + if(pSiS->Chipset == PCI_CHIP_SIS530) { + pReg->sisRegs3C4[0x09] &= 0x7F; + } + switch(pSiS->CurrentLayout.bitsPerPixel) { + case 8: + break; + case 16: + offset <<= 1; + if(pSiS->CurrentLayout.depth == 15) pReg->sisRegs3C4[0x06] |= 0x04; - else + else pReg->sisRegs3C4[0x06] |= 0x08; - break; - case 24: - offset += (offset << 1); - pReg->sisRegs3C4[0x06] |= 0x10; - pReg->sisRegs3C4[0x0B] |= 0x90; - break; - case 32: - if(pSiS->Chipset == PCI_CHIP_SIS530) { + break; + case 24: + offset += (offset << 1); + pReg->sisRegs3C4[0x06] |= 0x10; + pReg->sisRegs3C4[0x0B] |= 0x90; + break; + case 32: + if(pSiS->Chipset == PCI_CHIP_SIS530) { offset <<= 2; - pReg->sisRegs3C4[0x06] |= 0x10; + if(pSiS->oldChipset != OC_SIS620) { + pReg->sisRegs3C4[0x06] |= 0x10; + } pReg->sisRegs3C4[0x0B] |= 0x90; pReg->sisRegs3C4[0x09] |= 0x80; - } else return FALSE; - break; + } else return FALSE; + break; + } } /* save screen pitch for acceleration functions */ pSiS->scrnOffset = pSiS->CurrentLayout.displayWidth * ((pSiS->CurrentLayout.bitsPerPixel + 7) / 8); - /* set linear framebuffer addresses */ - switch(pScrn->videoRam) { - case 512: - temp = 0x00; break; - case 1024: - temp = 0x20; break; - case 2048: - temp = 0x40; break; - case 4096: - temp = 0x60; break; - case 8192: - temp = 0x80; break; - default: - temp = 0x20; - } - pReg->sisRegs3C4[0x20] = (pSiS->FbAddress & 0x07F80000) >> 19; - pReg->sisRegs3C4[0x21] = ((pSiS->FbAddress & 0xF8000000) >> 27) | temp; + if(!pSiS->UseVESA) { - /* Set screen offset */ - vgaReg->CRTC[0x13] = offset & 0xFF; + /* set linear framebuffer addresses */ + switch(pScrn->videoRam) { + case 512: temp = 0x00; break; + case 1024: temp = 0x20; break; + case 2048: temp = 0x40; break; + case 4096: temp = 0x60; break; + case 8192: temp = 0x80; break; + default: temp = 0x20; + } + pReg->sisRegs3C4[0x20] = (pSiS->FbAddress & 0x07F80000) >> 19; + pReg->sisRegs3C4[0x21] = ((pSiS->FbAddress & 0xF8000000) >> 27) | temp; - /* Set CR registers for our built-in TV and hi-res modes */ - if((sis6326tvmode) || (sis6326himode)) { + /* Set screen offset */ + vgaReg->CRTC[0x13] = offset & 0xFF; - int index,i; + /* Set CR registers for our built-in TV and hi-res modes */ + if((sis6326tvmode) || (sis6326himode)) { - /* TW: We need our very private data for hi-res and TV modes */ - if(sis6326himode) { - if(strcmp(mode->name, "SIS1280x1024-75") == 0) index = 7; - else index = 8; - } else { - if(pSiS->SiS6326Flags & SIS6326_TVPAL) { - switch(width) { - case 800: - if((strcmp(mode->name, "PAL800x600U") == 0)) - index = 4; - else - index = 0; - break; - case 720: - index = 5; - break; - case 640: - default: - index = 1; - } + int index,i; + + /* We need our very private data for hi-res and TV modes */ + if(sis6326himode) { + if(strcmp(mode->name, "SIS1280x1024-75") == 0) index = 7; + else index = 8; } else { - switch(height) { - case 400: - index = 3; - break; - case 480: - default: - if((strcmp(mode->name, "NTSC640x480U") == 0)) - index = 6; - else - index = 2; - } + if(pSiS->SiS6326Flags & SIS6326_TVPAL) { + switch(width) { + case 800: + if((strcmp(mode->name, "PAL800x600U") == 0)) + index = 4; + else + index = 0; + break; + case 720: + index = 5; + break; + case 640: + default: + index = 1; + } + } else { + switch(height) { + case 400: + index = 3; + break; + case 480: + default: + if((strcmp(mode->name, "NTSC640x480U") == 0)) + index = 6; + else + index = 2; + } + } + } + for(i=0; i<=5; i++) { + vgaReg->CRTC[i] = SiS6326CR[index][i]; } - } - for(i=0; i<=5; i++) { - vgaReg->CRTC[i] = SiS6326CR[index][i]; - } - pReg->sisRegs3C4[0x12] = SiS6326CR[index][6]; - vgaReg->CRTC[6] = SiS6326CR[index][7]; - vgaReg->CRTC[7] = SiS6326CR[index][8]; - vgaReg->CRTC[0x10] = SiS6326CR[index][9]; - vgaReg->CRTC[0x11] = SiS6326CR[index][10]; - vgaReg->CRTC[0x12] = SiS6326CR[index][11]; - vgaReg->CRTC[0x15] = SiS6326CR[index][12]; - vgaReg->CRTC[0x16] = SiS6326CR[index][13]; - vgaReg->CRTC[9] &= ~0x20; - vgaReg->CRTC[9] |= (SiS6326CR[index][14] & 0x20); - pReg->sisRegs3C4[0x0A] = ((offset & 0xF00) >> 4) | (SiS6326CR[index][14] & 0x0f); - - } else { - - /* Set extended vertical overflow register */ - pReg->sisRegs3C4[0x0A] = ((offset & 0xF00) >> 4) | - (((mode->CrtcVTotal-2) & 0x400) >> 10 ) | - (((mode->CrtcVDisplay-1) & 0x400) >> 9 ) | -/* (((mode->CrtcVSyncStart-1) & 0x400) >> 8 ) | */ - (((mode->CrtcVBlankStart-1)& 0x400) >> 8 ) | -/* (((mode->CrtcVBlankStart-1)& 0x400) >> 7 ); */ - (((mode->CrtcVSyncStart) & 0x400) >> 7 ); - - /* Set extended horizontal overflow register */ - pReg->sisRegs3C4[0x12] &= 0xE0; - pReg->sisRegs3C4[0x12] |= ( - (((mode->CrtcHTotal >> 3) - 5) & 0x100) >> 8 | - (((mode->CrtcHDisplay >> 3) - 1) & 0x100) >> 7 | -/* (((mode->CrtcHSyncStart >> 3) - 1) & 0x100) >> 6 | */ - (((mode->CrtcHBlankStart >> 3) - 1) & 0x100) >> 6 | - ((mode->CrtcHSyncStart >> 3) & 0x100) >> 5 | - (((mode->CrtcHBlankEnd >> 3) - 1) & 0x40) >> 2); - } + pReg->sisRegs3C4[0x12] = SiS6326CR[index][6]; + vgaReg->CRTC[6] = SiS6326CR[index][7]; + vgaReg->CRTC[7] = SiS6326CR[index][8]; + vgaReg->CRTC[0x10] = SiS6326CR[index][9]; + vgaReg->CRTC[0x11] = SiS6326CR[index][10]; + vgaReg->CRTC[0x12] = SiS6326CR[index][11]; + vgaReg->CRTC[0x15] = SiS6326CR[index][12]; + vgaReg->CRTC[0x16] = SiS6326CR[index][13]; + vgaReg->CRTC[9] &= ~0x20; + vgaReg->CRTC[9] |= (SiS6326CR[index][14] & 0x20); + pReg->sisRegs3C4[0x0A] = ((offset & 0xF00) >> 4) | (SiS6326CR[index][14] & 0x0f); + + } else { + + /* Set extended vertical overflow register */ + pReg->sisRegs3C4[0x0A] = ((offset & 0xF00) >> 4) | + (((mode->CrtcVTotal-2) & 0x400) >> 10 ) | + (((mode->CrtcVDisplay-1) & 0x400) >> 9 ) | +/* (((mode->CrtcVSyncStart-1) & 0x400) >> 8 ) | */ + (((mode->CrtcVBlankStart-1)& 0x400) >> 8 ) | +/* (((mode->CrtcVBlankStart-1)& 0x400) >> 7 ); */ + (((mode->CrtcVSyncStart) & 0x400) >> 7 ); + + /* Set extended horizontal overflow register */ + pReg->sisRegs3C4[0x12] &= 0xE0; + pReg->sisRegs3C4[0x12] |= ( + (((mode->CrtcHTotal >> 3) - 5) & 0x100) >> 8 | + (((mode->CrtcHDisplay >> 3) - 1) & 0x100) >> 7 | +/* (((mode->CrtcHSyncStart >> 3) - 1) & 0x100) >> 6 | */ + (((mode->CrtcHBlankStart >> 3) - 1) & 0x100) >> 6 | + ((mode->CrtcHSyncStart >> 3) & 0x100) >> 5 | + (((mode->CrtcHBlankEnd >> 3) - 1) & 0x40) >> 2); + } #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "HDisplay %d HSyncStart %d HSyncEnd %d HTotal %d\n", + xf86DrvMsg(0, X_INFO, "HDisplay %d HSyncStart %d HSyncEnd %d HTotal %d\n", mode->CrtcHDisplay, mode->CrtcHSyncStart, mode->CrtcHSyncEnd, mode->CrtcHTotal); - xf86DrvMsg(0, X_INFO, "HBlankSt %d HBlankE %d\n", + xf86DrvMsg(0, X_INFO, "HBlankSt %d HBlankE %d\n", mode->CrtcHBlankStart, mode->CrtcHBlankEnd); - xf86DrvMsg(0, X_INFO, "VDisplay %d VSyncStart %d VSyncEnd %d VTotal %d\n", + xf86DrvMsg(0, X_INFO, "VDisplay %d VSyncStart %d VSyncEnd %d VTotal %d\n", mode->CrtcVDisplay, mode->CrtcVSyncStart, mode->CrtcVSyncEnd, mode->CrtcVTotal); - xf86DrvMsg(0, X_INFO, "VBlankSt %d VBlankE %d\n", + xf86DrvMsg(0, X_INFO, "VBlankSt %d VBlankE %d\n", mode->CrtcVBlankStart, mode->CrtcVBlankEnd); #endif - /* enable (or disable) line compare */ - if(mode->CrtcVDisplay >= 1024) - pReg->sisRegs3C4[0x38] |= 0x04; - else - pReg->sisRegs3C4[0x38] &= 0xFB; - - /* Enable (or disable) high speed DCLK (some 6326 and 530/620 only) */ - if( ( (pSiS->Chipset == PCI_CHIP_SIS6326) && - ( (pSiS->ChipRev == 0xd0) || (pSiS->ChipRev == 0xd1) || - (pSiS->ChipRev == 0xd2) || (pSiS->ChipRev == 0x92) || - (pSiS->Flags & A6326REVAB) ) ) || - (pSiS->oldChipset > OC_SIS6326) ) { - if( (pSiS->CurrentLayout.bitsPerPixel == 24) || - (pSiS->CurrentLayout.bitsPerPixel == 32) || - (mode->CrtcHDisplay >= 1280) ) - pReg->sisRegs3C4[0x3E] |= 0x01; - else - pReg->sisRegs3C4[0x3E] &= 0xFE; - } + /* enable (or disable) line compare */ + if(mode->CrtcVDisplay >= 1024) + pReg->sisRegs3C4[0x38] |= 0x04; + else + pReg->sisRegs3C4[0x38] &= 0xFB; + + /* Enable (or disable) high speed DCLK (some 6326 and 530/620 only) */ + if( ( (pSiS->Chipset == PCI_CHIP_SIS6326) && + ( (pSiS->ChipRev == 0xd0) || (pSiS->ChipRev == 0xd1) || + (pSiS->ChipRev == 0xd2) || (pSiS->ChipRev == 0x92) || + (pSiS->Flags & A6326REVAB) ) ) || + (pSiS->oldChipset > OC_SIS6326) ) { + if( (pSiS->CurrentLayout.bitsPerPixel == 24) || + (pSiS->CurrentLayout.bitsPerPixel == 32) || + (mode->CrtcHDisplay >= 1280) ) + pReg->sisRegs3C4[0x3E] |= 0x01; + else + pReg->sisRegs3C4[0x3E] &= 0xFE; + } - /* We use the internal VCLK */ - pReg->sisRegs3C4[0x38] &= 0xFC; + /* We use the internal VCLK */ + pReg->sisRegs3C4[0x38] &= 0xFC; - /* Set VCLK */ - if((sis6326tvmode) || (sis6326himode)) { - /* TW: For our built-in modes, the calculation is not suitable */ - if(sis6326himode) { - if((strcmp(mode->name, "SIS1280x1024-75") == 0)) { - pReg->sisRegs3C4[0x2A] = 0x5d; /* 1280x1024-75 */ - pReg->sisRegs3C4[0x2B] = 0xa4; - } else { - pReg->sisRegs3C4[0x2A] = 0x59; /* 1600x1200-60 */ - pReg->sisRegs3C4[0x2B] = 0xa3; - } - pReg->sisRegs3C4[0x13] &= ~0x40; - } else { - if(pSiS->SiS6326Flags & SIS6326_TVPAL) { - /* PAL: 31.500 Mhz */ - if((strcmp(mode->name, "PAL800x600U") == 0)) { - pReg->sisRegs3C4[0x2A] = 0x46; - pReg->sisRegs3C4[0x2B] = 0x49; - } else { - pReg->sisRegs3C4[0x2A] = 0xab; - pReg->sisRegs3C4[0x2B] = 0xe9; - } - pReg->sisRegs3C4[0x13] &= ~0x40; - } else { - /* NTSC: 27.000 Mhz */ - if((strcmp(mode->name, "NTSC640x480U") == 0)) { - pReg->sisRegs3C4[0x2A] = 0x5a; - pReg->sisRegs3C4[0x2B] = 0x65; - } else { - pReg->sisRegs3C4[0x2A] = 0x29; - pReg->sisRegs3C4[0x2B] = 0xe2; - } - pReg->sisRegs3C4[0x13] |= 0x40; - } - } - } else if(SiS_compute_vclk(clock, &num, &denum, &div, &sbit, &scale)) { - pReg->sisRegs3C4[0x2A] = (num - 1) & 0x7f ; - pReg->sisRegs3C4[0x2A] |= (div == 2) ? 0x80 : 0; - pReg->sisRegs3C4[0x2B] = ((denum - 1) & 0x1f); - pReg->sisRegs3C4[0x2B] |= (((scale -1) & 3) << 5); - - /* When setting VCLK, we should set SR13 first */ - if(sbit) - pReg->sisRegs3C4[0x13] |= 0x40; - else - pReg->sisRegs3C4[0x13] &= 0xBF; + /* Programmable Clock */ + pReg->sisRegs3C2 = inb(SISMISCR) | 0x0C; + + if(pSiS->oldChipset <= OC_SIS86202) { + /* TODO: Handle SR07 for clock selection */ + /* 86C201 does not even have a programmable clock... */ + /* pReg->sisRegs3C4[0x07] &= 0x??; */ + } + + /* Set VCLK */ + if((sis6326tvmode) || (sis6326himode)) { + + /* For our built-in modes, the calculation is not suitable */ + if(sis6326himode) { + if((strcmp(mode->name, "SIS1280x1024-75") == 0)) { + pReg->sisRegs3C4[0x2A] = 0x5d; /* 1280x1024-75 */ + pReg->sisRegs3C4[0x2B] = 0xa4; + } else { + pReg->sisRegs3C4[0x2A] = 0x59; /* 1600x1200-60 */ + pReg->sisRegs3C4[0x2B] = 0xa3; + } + pReg->sisRegs3C4[0x13] &= ~0x40; + } else { + if(pSiS->SiS6326Flags & SIS6326_TVPAL) { + /* PAL: 31.500 Mhz */ + if((strcmp(mode->name, "PAL800x600U") == 0)) { + pReg->sisRegs3C4[0x2A] = 0x46; + pReg->sisRegs3C4[0x2B] = 0x49; + } else { + pReg->sisRegs3C4[0x2A] = 0xab; + pReg->sisRegs3C4[0x2B] = 0xe9; + } + pReg->sisRegs3C4[0x13] &= ~0x40; + } else { + /* NTSC: 27.000 Mhz */ + if((strcmp(mode->name, "NTSC640x480U") == 0)) { + pReg->sisRegs3C4[0x2A] = 0x5a; + pReg->sisRegs3C4[0x2B] = 0x65; + } else { + pReg->sisRegs3C4[0x2A] = 0x29; + pReg->sisRegs3C4[0x2B] = 0xe2; + } + pReg->sisRegs3C4[0x13] |= 0x40; + } + } + + } else if(SiS_compute_vclk(clock, &num, &denum, &div, &sbit, &scale)) { + + pReg->sisRegs3C4[0x2A] = (num - 1) & 0x7f ; + pReg->sisRegs3C4[0x2A] |= (div == 2) ? 0x80 : 0; + pReg->sisRegs3C4[0x2B] = ((denum - 1) & 0x1f); + pReg->sisRegs3C4[0x2B] |= (((scale -1) & 3) << 5); + + /* When setting VCLK, we should set SR13 first */ + if(sbit) + pReg->sisRegs3C4[0x13] |= 0x40; + else + pReg->sisRegs3C4[0x13] &= 0xBF; #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "2a: %x 2b: %x 13: %x clock %d\n", + xf86DrvMsg(0, X_INFO, "2a: %x 2b: %x 13: %x clock %d\n", pReg->sisRegs3C4[0x2A], pReg->sisRegs3C4[0x2B], pReg->sisRegs3C4[0x13], clock); #endif - } else { - /* if SiS_compute_vclk cannot handle the requested clock, try sisCalcClock */ - SiSCalcClock(pScrn, clock, 2, vclk); + } else { - pReg->sisRegs3C4[0x2A] = (vclk[Midx] - 1) & 0x7f; - pReg->sisRegs3C4[0x2A] |= ((vclk[VLDidx] == 2) ? 1 : 0) << 7; + /* if SiS_compute_vclk cannot handle the requested clock, try sisCalcClock */ + SiSCalcClock(pScrn, clock, 2, vclk); - /* bits [4:0] contain denumerator */ - pReg->sisRegs3C4[0x2B] = (vclk[Nidx] - 1) & 0x1f; +#define Midx 0 +#define Nidx 1 +#define VLDidx 2 +#define Pidx 3 +#define PSNidx 4 - if (vclk[Pidx] <= 4){ - /* postscale 1,2,3,4 */ - pReg->sisRegs3C4[0x2B] |= (vclk[Pidx] - 1) << 5; - pReg->sisRegs3C4[0x13] &= 0xBF; - } else { - /* postscale 6,8 */ - pReg->sisRegs3C4[0x2B] |= ((vclk[Pidx] / 2) - 1) << 5; - pReg->sisRegs3C4[0x13] |= 0x40; - } - pReg->sisRegs3C4[0x2B] |= 0x80 ; /* gain for high frequency */ - } + pReg->sisRegs3C4[0x2A] = (vclk[Midx] - 1) & 0x7f; + pReg->sisRegs3C4[0x2A] |= ((vclk[VLDidx] == 2) ? 1 : 0) << 7; - /* High speed DAC */ - if(clock > 135000) - pReg->sisRegs3C4[0x07] |= 0x02; + /* bits [4:0] contain denumerator */ + pReg->sisRegs3C4[0x2B] = (vclk[Nidx] - 1) & 0x1f; - /* Programmable Clock */ - pReg->sisRegs3C2 = inb(SISMISCR) | 0x0C; + if(vclk[Pidx] <= 4){ + /* postscale 1,2,3,4 */ + pReg->sisRegs3C4[0x2B] |= (vclk[Pidx] - 1) << 5; + pReg->sisRegs3C4[0x13] &= 0xBF; + } else { + /* postscale 6,8 */ + pReg->sisRegs3C4[0x2B] |= ((vclk[Pidx] / 2) - 1) << 5; + pReg->sisRegs3C4[0x13] |= 0x40; + } + pReg->sisRegs3C4[0x2B] |= 0x80 ; /* gain for high frequency */ - /* 1 or 2 cycle DRAM (set by option FastVram) */ - if(pSiS->newFastVram == -1) { - pReg->sisRegs3C4[0x34] |= 0x80; - pReg->sisRegs3C4[0x34] &= ~0x40; - } else if(pSiS->newFastVram == 1) - pReg->sisRegs3C4[0x34] |= 0xC0; - else - pReg->sisRegs3C4[0x34] &= ~0xC0; + } + + /* High speed DAC */ + if(clock > 135000) + pReg->sisRegs3C4[0x07] |= 0x02; + + if(pSiS->oldChipset > OC_SIS6225) { + /* 1 or 2 cycle DRAM (set by option FastVram) */ + if(pSiS->newFastVram == -1) { + if(pSiS->oldChipset == OC_SIS620) { + /* Use different default on the 620 */ + pReg->sisRegs3C4[0x34] |= 0x40; + pReg->sisRegs3C4[0x34] &= ~0x80; + } else { + pReg->sisRegs3C4[0x34] |= 0x80; + pReg->sisRegs3C4[0x34] &= ~0x40; + } + } else if(pSiS->newFastVram == 1) + pReg->sisRegs3C4[0x34] |= 0xC0; + else + pReg->sisRegs3C4[0x34] &= ~0xC0; + + if(pSiS->oldChipset == OC_SIS620) { + /* Enable SGRAM burst timing (= bit clear) on the 620 */ + if(pSiS->Flags & SYNCDRAM) { + pReg->sisRegs3C4[0x35] &= ~0x20; + } else { + pReg->sisRegs3C4[0x35] |= 0x20; + } + } + } + + } /* VESA */ /* Logical line length */ pSiS->ValidWidth = TRUE; @@ -547,254 +609,273 @@ SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode) /* Acceleration stuff */ if(!pSiS->NoAccel) { - pReg->sisRegs3C4[0x27] |= 0x40; /* Enable engine programming registers */ - if( (pSiS->TurboQueue) && /* Handle TurboQueue */ - ( (pSiS->Chipset != PCI_CHIP_SIS530) || - (pSiS->CurrentLayout.bitsPerPixel != 24) ) ) { - pReg->sisRegs3C4[0x27] |= 0x80; /* Enable TQ */ - if((pSiS->Chipset == PCI_CHIP_SIS530) || - ((pSiS->Chipset == PCI_CHIP_SIS6326 && - (pSiS->ChipRev == 0xd0 || pSiS->ChipRev == 0xd1 || - pSiS->ChipRev == 0xd2 || pSiS->ChipRev == 0x92 || - pSiS->ChipRev == 0x0a || pSiS->ChipRev == 0x1a || - pSiS->ChipRev == 0x2a || pSiS->ChipRev == 0x0b || - pSiS->ChipRev == 0x1b || pSiS->ChipRev == 0x2b) ) ) ) { - /* pReg->sisRegs3C4[0x3D] |= 0x80; */ /* Queue is 62K (530/620 specs) */ - pReg->sisRegs3C4[0x3D] &= 0x7F; /* Queue is 30K (530/620 specs) */ - } - /* TW: Locate the TQ at the beginning of the last 64K block of - * video RAM. The address is to be specified in 32K steps. - */ - pReg->sisRegs3C4[0x2C] = (pScrn->videoRam - 64) / 32; - if(pSiS->Chipset != PCI_CHIP_SIS530) { /* 530/620: Reserved (don't touch) */ - pReg->sisRegs3C4[0x3C] &= 0xFC; /* 6326: Queue is all for 2D */ - } /* 5597: Must be 0 */ - } else { - pReg->sisRegs3C4[0x27] &= 0x7F; + pReg->sisRegs3C4[0x27] |= 0x40; /* Enable engine programming registers */ + if( (pSiS->TurboQueue) && /* Handle TurboQueue */ + (pSiS->oldChipset > OC_SIS6225) && + ( (pSiS->Chipset != PCI_CHIP_SIS530) || + (pSiS->CurrentLayout.bitsPerPixel != 24) ) ) { + pReg->sisRegs3C4[0x27] |= 0x80; /* Enable TQ */ + if((pSiS->Chipset == PCI_CHIP_SIS530) || + ((pSiS->Chipset == PCI_CHIP_SIS6326 && + (pSiS->ChipRev == 0xd0 || pSiS->ChipRev == 0xd1 || + pSiS->ChipRev == 0xd2 || pSiS->ChipRev == 0x92 || + pSiS->ChipRev == 0x0a || pSiS->ChipRev == 0x1a || + pSiS->ChipRev == 0x2a || pSiS->ChipRev == 0x0b || + pSiS->ChipRev == 0x1b || pSiS->ChipRev == 0x2b) ) ) ) { + /* pReg->sisRegs3C4[0x3D] |= 0x80; */ /* Queue is 62K (530/620 specs) */ + pReg->sisRegs3C4[0x3D] &= 0x7F; /* Queue is 30K (530/620 specs) */ } + /* Locate the TQ at the beginning of the last 64K block of + * video RAM. The address is to be specified in 32K steps. + */ + pReg->sisRegs3C4[0x2C] = (pScrn->videoRam - 64) / 32; + if(pSiS->Chipset != PCI_CHIP_SIS530) { /* 530/620: Reserved (don't touch) */ + pReg->sisRegs3C4[0x3C] &= 0xFC; /* 6326: Queue is all for 2D */ + } /* 5597: Must be 0 */ + } else { + pReg->sisRegs3C4[0x27] &= 0x7F; + } } - /* TW: No idea what this does. The Windows driver does it, so we do it as well */ - if(pSiS->Chipset == PCI_CHIP_SIS6326) { - if((pSiS->ChipRev == 0xd0) || (pSiS->ChipRev == 0xd1) || - (pSiS->ChipRev == 0xd2) || (pSiS->ChipRev == 0x92) || - (pSiS->Flags & A6326REVAB)) { - if((pSiS->Flags & (SYNCDRAM | RAMFLAG)) == (SYNCDRAM | RAMFLAG)) { - if(!(pReg->sisRegs3C4[0x0E] & 0x03)) { - pReg->sisRegs3C4[0x3E] |= 0x02; + + if(!pSiS->UseVESA) { + + /* TW: No idea what this does. The Windows driver does it, so we do it as well */ + if(pSiS->Chipset == PCI_CHIP_SIS6326) { + if((pSiS->ChipRev == 0xd0) || (pSiS->ChipRev == 0xd1) || + (pSiS->ChipRev == 0xd2) || (pSiS->ChipRev == 0x92) || + (pSiS->Flags & A6326REVAB)) { + if((pSiS->Flags & (SYNCDRAM | RAMFLAG)) == (SYNCDRAM | RAMFLAG)) { + if(!(pReg->sisRegs3C4[0x0E] & 0x03)) { + pReg->sisRegs3C4[0x3E] |= 0x02; + } } - } + } } - } - - /* Set memclock */ + /* Set memclock */ #if 0 - /* TW: We don't need to do this; the SetMClk option was not used since 4.0. */ - if((pSiS->Chipset == PCI_CHIP_SIS5597) || (pSiS->Chipset == PCI_CHIP_SIS6326)) { - if(pSiS->MemClock > 66000) { - SiSCalcClock(pScrn, pSiS->MemClock, 1, vclk); - - pReg->sisRegs3C4[0x28] = (vclk[Midx] - 1) & 0x7f ; - pReg->sisRegs3C4[0x28] |= ((vclk[VLDidx] == 2 ) ? 1 : 0 ) << 7 ; - pReg->sisRegs3C4[0x29] = (vclk[Nidx] -1) & 0x1f ; /* bits [4:0] contain denumerator -MC */ - if(vclk[Pidx] <= 4) { - pReg->sisRegs3C4[0x29] |= (vclk[Pidx] - 1) << 5 ; /* postscale 1,2,3,4 */ - pReg->sisRegs3C4[0x13] &= 0x7F; - } else { - pReg->sisRegs3C4[0x29] |= ((vclk[Pidx] / 2) - 1) << 5 ; /* postscale 6,8 */ - pReg->sisRegs3C4[0x13] |= 0x80; - } - /* Check programmed memory clock. Enable only to check the above code */ + /* We don't need to do this; the SetMClk option was not used since 4.0. */ + if((pSiS->Chipset == PCI_CHIP_SIS5597) || (pSiS->Chipset == PCI_CHIP_SIS6326)) { + if(pSiS->MemClock > 66000) { + SiSCalcClock(pScrn, pSiS->MemClock, 1, vclk); + + pReg->sisRegs3C4[0x28] = (vclk[Midx] - 1) & 0x7f ; + pReg->sisRegs3C4[0x28] |= ((vclk[VLDidx] == 2 ) ? 1 : 0 ) << 7 ; + pReg->sisRegs3C4[0x29] = (vclk[Nidx] -1) & 0x1f ; /* bits [4:0] contain denumerator -MC */ + if(vclk[Pidx] <= 4) { + pReg->sisRegs3C4[0x29] |= (vclk[Pidx] - 1) << 5 ; /* postscale 1,2,3,4 */ + pReg->sisRegs3C4[0x13] &= 0x7F; + } else { + pReg->sisRegs3C4[0x29] |= ((vclk[Pidx] / 2) - 1) << 5 ; /* postscale 6,8 */ + pReg->sisRegs3C4[0x13] |= 0x80; + } + /* Check programmed memory clock. Enable only to check the above code */ /* - mclk = 14318 * ((pReg->sisRegs3C4[0x28] & 0x7f) + 1); - mclk /= ((pReg->sisRegs3C4[0x29] & 0x0f) + 1); - if(!(pReg->sisRegs3C4[0x13] & 0x80)) { - mclk /= (((pReg->sisRegs3C4[0x29] & 0x60) >> 5) + 1); - } else { - if ((pReg->sisRegs3C4[0x29] & 0x60) == 0x40) mclk /= 6; - if ((pReg->sisRegs3C4[0x29] & 0x60) == 0x60) mclk /= 8; - } - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,2, + mclk = 14318 * ((pReg->sisRegs3C4[0x28] & 0x7f) + 1); + mclk /= ((pReg->sisRegs3C4[0x29] & 0x0f) + 1); + if(!(pReg->sisRegs3C4[0x13] & 0x80)) { + mclk /= (((pReg->sisRegs3C4[0x29] & 0x60) >> 5) + 1); + } else { + if((pReg->sisRegs3C4[0x29] & 0x60) == 0x40) mclk /= 6; + if((pReg->sisRegs3C4[0x29] & 0x60) == 0x60) mclk /= 8; + } + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,2, "Setting memory clock to %.3f MHz\n", mclk/1000.0); */ - } - } + } + } #endif - /* TW: set threshold values (rewritten) */ - /* - * CPU/CRT Threshold: FIFO - * MCLK ___________ VCLK - * cpu/engine <---o o--------->|___________| -----------> CRT - * ^ ^ ^ ^ - * \ / | | - * \ / |< gap >| - * \ / | | - * selector switch Thrsh. low high - * - * CRT consumes the data in the FIFO during scanline display. When the - * amount of data in the FIFO reaches the Threshold low value, the selector - * switch will switch to the right, and the FIFO will be refilled with data. - * When the amount of data in the FIFO reaches the Threshold high value, the - * selector switch will switch to the left and allows the CPU and the chip - * engines to access video RAM. - * - * The Threshold low values should be increased at higher bpps, simply because - * there is more data needed for the CRT. When Threshold low and high are very - * close to each other, the selector switch will be activated more often, which - * decreases performance. - * - */ - switch(pSiS->Chipset) { - case PCI_CHIP_SIS5597: factor = 65; break; - case PCI_CHIP_SIS6326: factor = 30; break; - case PCI_CHIP_SIS530: factor = (pSiS->Flags & UMA) ? 60 : 30; break; - default: factor = (pScrn->videoRam > (1024*1024)) ? 24 : 12; - } - a = width * height * rate * 1.40 * factor * ((pSiS->CurrentLayout.bitsPerPixel + 1) / 8); - b = (mclk / 1000) * 999488.0 * (buswidth / 8); - c = ((a / b) + 1.0) / 2; - d = (int)c + 2; + /* Set threshold values */ + /* + * CPU/CRT Threshold: FIFO + * MCLK ___________ VCLK + * cpu/engine <---o o--------->|___________| -----------> CRT + * ^ ^ ^ ^ + * \ / | | + * \ / |< gap >| + * \ / | | + * selector switch Thrsh. low high + * + * CRT consumes the data in the FIFO during scanline display. When the + * amount of data in the FIFO reaches the Threshold low value, the selector + * switch will switch to the right, and the FIFO will be refilled with data. + * When the amount of data in the FIFO reaches the Threshold high value, the + * selector switch will switch to the left and allows the CPU and the chip + * engines to access the video RAM. + * + * The Threshold low values should be increased at higher bpps, simply because + * there is more data needed for the CRT. When Threshold low and high are very + * close to each other, the selector switch will be activated more often, which + * decreases performance. + * + */ + switch(pSiS->Chipset) { + case PCI_CHIP_SIS5597: factor = 65; break; + case PCI_CHIP_SIS6326: factor = 30; break; + case PCI_CHIP_SIS530: factor = (pSiS->Flags & UMA) ? 60 : 30; break; + default: factor = (pScrn->videoRam > 1024) ? 24 : 12; + } + a = width * height * rate * 1.40 * factor * ((pSiS->CurrentLayout.bitsPerPixel + 1) / 8); + b = (mclk / 1000) * 999488.0 * (buswidth / 8); + c = ((a / b) + 1.0) / 2; + d = (int)c + 2; #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, - "Debug: w %d h %d r %d mclk %d bus %d factor %d bpp %d\n", - width, height, rate, mclk/1000, buswidth, factor, - pSiS->CurrentLayout.bitsPerPixel); - xf86DrvMsg(0, X_INFO, "Debug: a %f b %f c %f d %d (flags %x)\n", - a, b, c, d, pSiS->Flags); + xf86DrvMsg(0, X_INFO, + "Debug: w %d h %d r %d mclk %d bus %d factor %d bpp %d\n", + width, height, rate, mclk/1000, buswidth, factor, + pSiS->CurrentLayout.bitsPerPixel); + xf86DrvMsg(0, X_INFO, "Debug: a %f b %f c %f d %d (flags %x)\n", + a, b, c, d, pSiS->Flags); #endif - CRT_CPUthresholdLow = d; - if((pSiS->Flags & (RAMFLAG | SYNCDRAM)) == (RAMFLAG | SYNCDRAM)) { - CRT_CPUthresholdLow += 2; - } - CRT_CPUthresholdHigh = CRT_CPUthresholdLow + 3; + CRT_CPUthresholdLow = d; + if((pSiS->Flags & (RAMFLAG | SYNCDRAM)) == (RAMFLAG | SYNCDRAM)) { + CRT_CPUthresholdLow += 2; + } + CRT_CPUthresholdHigh = CRT_CPUthresholdLow + 3; - CRT_ENGthreshold = 0x0F; + CRT_ENGthreshold = 0x0F; #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "Debug: Thlow %d thhigh %d\n", - CRT_CPUthresholdLow, CRT_CPUthresholdHigh); + xf86DrvMsg(0, X_INFO, "Debug: Thlow %d thhigh %d\n", + CRT_CPUthresholdLow, CRT_CPUthresholdHigh); #endif -#if 0 /* TW: See comment in sis_dac.c on why this is commented */ - if(pSiS->Chipset == PCI_CHIP_SIS530) { - if((pSiS->oldChipset == OC_SIS530A) && - (pSiS->Flags & UMA) && - (mclk == 100000) && - (pSiS->Flags & ESS137xPRESENT)) { - if(!(pSiS->Flags & SECRETFLAG)) index = 0; - if((temp = SiS_CalcSpecial530Threshold(pSiS, mode, index)) { - CRT_CPUthresholdLow = temp; - break; - } +#if 0 /* See comment in sis_dac.c on why this is commented */ + if(pSiS->Chipset == PCI_CHIP_SIS530) { + if((pSiS->oldChipset == OC_SIS530A) && + (pSiS->Flags & UMA) && + (mclk == 100000) && + (pSiS->Flags & ESS137xPRESENT)) { + if(!(pSiS->Flags & SECRETFLAG)) index = 0; + if((temp = SiS_CalcSpecial530Threshold(pSiS, mode, index)) { + CRT_CPUthresholdLow = temp; + break; + } + } } - } #endif - switch(pSiS->Chipset) { - case PCI_CHIP_SIS530: - if(CRT_CPUthresholdLow > 0x1f) CRT_CPUthresholdLow = 0x1f; - CRT_CPUthresholdHigh = 0x1f; - break; - case PCI_CHIP_SIS5597: - case PCI_CHIP_SIS6326: - default: - if(CRT_CPUthresholdLow > 0x0f) CRT_CPUthresholdLow = 0x0f; - if(CRT_CPUthresholdHigh > 0x0f) CRT_CPUthresholdHigh = 0x0f; - } + switch(pSiS->Chipset) { + case PCI_CHIP_SIS530: + if(CRT_CPUthresholdLow > 0x1f) CRT_CPUthresholdLow = 0x1f; + CRT_CPUthresholdHigh = 0x1f; + break; + case PCI_CHIP_SIS5597: + case PCI_CHIP_SIS6326: + default: + if(CRT_CPUthresholdLow > 0x0f) CRT_CPUthresholdLow = 0x0f; + if(CRT_CPUthresholdHigh > 0x0f) CRT_CPUthresholdHigh = 0x0f; + } - pReg->sisRegs3C4[0x08] = ((CRT_CPUthresholdLow & 0x0F) << 4) | - (CRT_ENGthreshold & 0x0F); + pReg->sisRegs3C4[0x08] = ((CRT_CPUthresholdLow & 0x0F) << 4) | + (CRT_ENGthreshold & 0x0F); - pReg->sisRegs3C4[0x09] &= 0xF0; - pReg->sisRegs3C4[0x09] |= (CRT_CPUthresholdHigh & 0x0F); + pReg->sisRegs3C4[0x09] &= 0xF0; + pReg->sisRegs3C4[0x09] |= (CRT_CPUthresholdHigh & 0x0F); - pReg->sisRegs3C4[0x3F] &= 0xEB; - pReg->sisRegs3C4[0x3F] |= (CRT_CPUthresholdHigh & 0x10) | - ((CRT_CPUthresholdLow & 0x10) >> 2); + pReg->sisRegs3C4[0x3F] &= 0xEB; + pReg->sisRegs3C4[0x3F] |= (CRT_CPUthresholdHigh & 0x10) | + ((CRT_CPUthresholdLow & 0x10) >> 2); - if(pSiS->oldChipset >= OC_SIS530A) { - pReg->sisRegs3C4[0x3F] &= 0xDF; - pReg->sisRegs3C4[0x3F] |= 0x58; - } + if(pSiS->oldChipset >= OC_SIS530A) { + pReg->sisRegs3C4[0x3F] &= 0xDF; + pReg->sisRegs3C4[0x3F] |= 0x58; + } - /* TW: Set SiS6326 TV registers */ - if((pSiS->Chipset == PCI_CHIP_SIS6326) && (sis6326tvmode)) { - unsigned char tmp; - int index=0, i, j, k; - - if(pSiS->SiS6326Flags & SIS6326_TVPAL) { - pReg->sisRegs3C4[0x0D] |= 0x04; - switch(width) { - case 800: - if((strcmp(mode->name, "PAL800x600U") == 0)) index = 4; - else index = 3; - break; - case 720: - index = 5; - break; - case 640: - default: - index = 2; - break; - } - for(i=0; i<14; i++) { - pReg->sis6326tv[SiS6326TVRegs1[i]] = SiS6326TVRegs1_PAL[index][i]; - } - } else { - pReg->sisRegs3C4[0x0D] &= ~0x04; - if((strcmp(mode->name, "NTSC640x480U") == 0)) index = 5; - else index = 4; - for(i=0; i<14; i++) { - pReg->sis6326tv[SiS6326TVRegs1[i]] = SiS6326TVRegs1_NTSC[index][i]; - } - } - tmp = pReg->sis6326tv[0x43]; - if(pSiS->SiS6326Flags & SIS6326_TVCVBS) tmp |= 0x10; - tmp |= 0x08; - pReg->sis6326tv[0x43] = tmp; - j = 0; k = 0; - for(i=0; i<=0x44; i++) { - if(SiS6326TVRegs1[j] == i) { + /* Set SiS6326 TV registers */ + if((pSiS->Chipset == PCI_CHIP_SIS6326) && (sis6326tvmode)) { + unsigned char tmp; + int index=0, i, j, k; + int fsc; + + if(pSiS->SiS6326Flags & SIS6326_TVPAL) { + pReg->sisRegs3C4[0x0D] |= 0x04; + switch(width) { + case 800: + if((strcmp(mode->name, "PAL800x600U") == 0)) index = 4; + else index = 3; + break; + case 720: index = 5; break; + case 640: + default: index = 2; + } + 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]); + } else { + pReg->sisRegs3C4[0x0D] &= ~0x04; + if((strcmp(mode->name, "NTSC640x480U") == 0)) index = 5; + else index = 4; + 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]); + } + if(pSiS->sis6326fscadjust) { + fsc += pSiS->sis6326fscadjust; + pReg->sis6326tv[2] = (fsc >> 16) & 0xff; + pReg->sis6326tv[3] = (fsc >> 8) & 0xff; + pReg->sis6326tv[4] = fsc & 0xff; + } + tmp = pReg->sis6326tv[0x43]; + if(pSiS->SiS6326Flags & SIS6326_TVCVBS) tmp |= 0x10; + tmp |= 0x08; + pReg->sis6326tv[0x43] = tmp; + j = 0; k = 0; + for(i=0; i<=0x44; i++) { + if(SiS6326TVRegs1[j] == i) { j++; continue; - } - if(pSiS->SiS6326Flags & SIS6326_TVPAL) { + } + if(pSiS->SiS6326Flags & SIS6326_TVPAL) { tmp = SiS6326TVRegs2_PAL[index][k]; - } else { + } else { tmp = SiS6326TVRegs2_NTSC[index][k]; - } - pReg->sis6326tv[i] = tmp; - k++; - } - pReg->sis6326tv[0x43] |= 0x08; - if((pSiS->ChipRev == 0xc1) || (pSiS->ChipRev == 0xc2)) { - pReg->sis6326tv[0x43] &= ~0x08; - } - - tmp = pReg->sis6326tv[0]; - tmp |= 0x18; - if(pSiS->SiS6326Flags & SIS6326_TVCVBS) tmp &= ~0x10; - else tmp &= ~0x08; - tmp |= 0x04; - pReg->sis6326tv[0] = tmp; - } + } + pReg->sis6326tv[i] = tmp; + k++; + } + pReg->sis6326tv[0x43] |= 0x08; + if((pSiS->ChipRev == 0xc1) || (pSiS->ChipRev == 0xc2)) { + pReg->sis6326tv[0x43] &= ~0x08; + } + + tmp = pReg->sis6326tv[0]; + tmp |= 0x18; + if(pSiS->SiS6326Flags & SIS6326_TVCVBS) tmp &= ~0x10; + if(pSiS->SiS6326Flags & SIS6326_TVSVIDEO) tmp &= ~0x08; + tmp |= 0x04; + pReg->sis6326tv[0] = tmp; + } + + } /* VESA */ return(TRUE); } -/* TW: Init a mode for SiS 300 and 310/325 series - * The original intention of the followling procedure was - * to initialize various registers for the selected mode. - * This was actually done to a structure, not the hardware. - * (SiSRestore would write the structure to the hardware - * registers.) - * This function is now only used for setting up some - * variables (eg. scrnOffset). +/* Init a mode for SiS 300, 315 and 330 series + * This function is now only used for setting up some + * variables (eg. scrnOffset). */ Bool SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode) @@ -802,22 +883,33 @@ SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode) SISPtr pSiS = SISPTR(pScrn); SISRegPtr pReg = &pSiS->ModeReg; unsigned short temp; + DisplayModePtr realmode = mode; - 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", pScrn->virtualX, pSiS->CurrentLayout.bitsPerPixel, pScrn->virtualX * pSiS->CurrentLayout.bitsPerPixel/8); +#ifdef SISMERGED + if(pSiS->MergedFB) { + realmode = ((SiSMergedDisplayModePtr)mode->Private)->CRT1; + } +#endif + /* Copy current register settings to structure */ (*pSiS->SiSSave)(pScrn, pReg); - /* TW: Calculate Offset/Display Pitch */ + /* Calculate Offset/Display Pitch */ pSiS->scrnOffset = pSiS->CurrentLayout.displayWidth * - ((pSiS->CurrentLayout.bitsPerPixel+7)/8); - pSiS->scrnPitch = pSiS->scrnOffset; - if (mode->Flags & V_INTERLACE) pSiS->scrnPitch <<= 1; + ((pSiS->CurrentLayout.bitsPerPixel + 7) / 8); + + pSiS->scrnPitch = pSiS->scrnPitch2 = pSiS->scrnOffset; + 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); @@ -843,30 +935,32 @@ SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode) break; } - /* TW: Enable PCI LINEAR ADDRESSING (0x80), MMIO (0x01), PCI_IO (0x20) */ + /* Enable PCI LINEAR ADDRESSING (0x80), MMIO (0x01), PCI_IO (0x20) */ pReg->sisRegs3C4[0x20] = 0xA1; -/* TW: Now initialize TurboQueue. TB is always located at the very top of - * the videoRAM (notably NOT the x framebuffer memory, which can/should - * be limited by MaxXFbMem when using DRI). Also, enable the accelerators. - */ - if (!pSiS->NoAccel) { - pReg->sisRegs3C4[0x1E] |= 0x42; /* TW: Enable 2D accelerator */ - pReg->sisRegs3C4[0x1E] |= 0x18; /* TW: Enable 3D accelerator */ - switch (pSiS->VGAEngine) { + /* Now initialize TurboQueue. TB is always located at the very top of + * the videoRAM (notably NOT the x framebuffer memory, which can/should + * be limited by MaxXFbMem when using DRI). Also, enable the accelerators. + */ + if(!pSiS->NoAccel) { + pReg->sisRegs3C4[0x1E] |= 0x42; /* Enable 2D accelerator */ + pReg->sisRegs3C4[0x1E] |= 0x18; /* Enable 3D accelerator */ + switch(pSiS->VGAEngine) { case SIS_300_VGA: - if(pSiS->TurboQueue) { /* set Turbo Queue as 512k */ - temp = ((pScrn->videoRam/64)-8); /* TW: 8=512k, 4=256k, 2=128k, 1=64k */ + if(pSiS->TurboQueue) { /* set Turbo Queue as 512k */ + temp = ((pScrn->videoRam/64)-8); /* 8=512k, 4=256k, 2=128k, 1=64k */ pReg->sisRegs3C4[0x26] = temp & 0xFF; pReg->sisRegs3C4[0x27] = (pReg->sisRegs3C4[0x27] & 0xfc) | (((temp >> 8) & 3) | 0xF0); - } /* TW: line above new for saving D2&3 of status register */ + } /* line above new for saving D2&3 of status register */ break; case SIS_315_VGA: +#ifndef SISVRAMQ /* See comments in sis_driver.c */ pReg->sisRegs3C4[0x27] = 0x1F; pReg->sisRegs3C4[0x26] = 0x22; pReg->sisMMIO85C0 = (pScrn->videoRam - 512) * 1024; +#endif break; } } @@ -874,7 +968,7 @@ SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode) return(TRUE); } -int +static int SISDoSense(ScrnInfoPtr pScrn, int tempbl, int tempbh, int tempcl, int tempch) { SISPtr pSiS = SISPTR(pScrn); @@ -883,199 +977,218 @@ SISDoSense(ScrnInfoPtr pScrn, int tempbl, int tempbh, int tempcl, int tempch) outSISIDXREG(SISPART4,0x11,tempbl); temp = tempbh | tempcl; setSISIDXREG(SISPART4,0x10,0xe0,temp); - usleep(200000); + SiS_DDC2Delay(pSiS->SiS_Pr, 0x1000); tempch &= 0x7f; inSISIDXREG(SISPART4,0x03,temp); temp ^= 0x0e; temp &= tempch; - return(temp); + return((temp == tempch)); } -/* TW: Sense connected devices on 30x */ -void SISSense30x(ScrnInfoPtr pScrn) +/* Sense connected devices on 30x */ +static void +SISSense30x(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - unsigned char backupP4_0d,biosflag; - unsigned char testsvhs_tempbl, testsvhs_tempbh; - unsigned char testsvhs_tempcl, testsvhs_tempch; - unsigned char testcvbs_tempbl, testcvbs_tempbh; - unsigned char testcvbs_tempcl, testcvbs_tempch; - unsigned char testvga2_tempbl, testvga2_tempbh; - unsigned char testvga2_tempcl, testvga2_tempch; - int myflag, result; + 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; unsigned short temp; inSISIDXREG(SISPART4,0x0d,backupP4_0d); outSISIDXREG(SISPART4,0x0d,(backupP4_0d | 0x04)); - if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->sishw_ext.UseROM) { - temp = 0xf3; - if(pSiS->Chipset == PCI_CHIP_SIS330) temp = 0x11b; - if(pSiS->BIOS[temp] & 0x08) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "SiS30x: Video bridge has (unsupported) DVI combo connector\n"); - orSISIDXREG(SISCR, 0x32, 0x80); - } else { - andSISIDXREG(SISCR, 0x32, 0x7f); - } + inSISIDXREG(SISPART2,0x00,backupP2_00); + outSISIDXREG(SISPART2,0x00,(backupP2_00 | 0x1c)); + + SISDoSense(pScrn, 0, 0, 0, 0); + + if(pSiS->Chipset != PCI_CHIP_SIS660) { + 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 if(pSiS->Chipset == PCI_CHIP_SIS330) temp = 0x11b; + else temp = 0xf3; + 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) { - testvga2_tempbh = pSiS->BIOS[0xf9]; testvga2_tempbl = pSiS->BIOS[0xf8]; - testsvhs_tempbh = pSiS->BIOS[0xfb]; testsvhs_tempbl = pSiS->BIOS[0xfa]; - testcvbs_tempbh = pSiS->BIOS[0xfd]; testcvbs_tempbl = pSiS->BIOS[0xfc]; + 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 { - testvga2_tempbh = 0x00; testvga2_tempbl = 0xd1; - testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xb9; - testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xb3; - biosflag = 0; + vga2_bh = 0x00; vga2_bl = 0xd1; + svhs_bh = 0x00; svhs_bl = 0xb9; + cvbs_bh = 0x00; cvbs_bl = 0xb3; + biosflag = 2; } - if(pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) { - testvga2_tempbh = 0x01; testvga2_tempbl = 0x90; - testsvhs_tempbh = 0x01; testsvhs_tempbl = 0x6b; - testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x74; + if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)) { + 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) { - testvga2_tempbh = 0x00; testvga2_tempbl = 0xfd; - testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xdd; - testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xee; + 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; + } } - testvga2_tempch = 0x0e; testvga2_tempcl = 0x08; - testsvhs_tempch = 0x06; testsvhs_tempcl = 0x04; - testcvbs_tempch = 0x08; testcvbs_tempcl = 0x04; - } else if((pSiS->Chipset == PCI_CHIP_SIS315) || - (pSiS->Chipset == PCI_CHIP_SIS315H) || - (pSiS->Chipset == PCI_CHIP_SIS315PRO)) { + } else if(pSiS->Chipset == PCI_CHIP_SIS660) { - if(pSiS->sishw_ext.UseROM) { - testvga2_tempbh = pSiS->BIOS[0xbe]; testvga2_tempbl = pSiS->BIOS[0xbd]; - testsvhs_tempbh = pSiS->BIOS[0xc0]; testsvhs_tempbl = pSiS->BIOS[0xbf]; - testcvbs_tempbh = pSiS->BIOS[0xc2]; testcvbs_tempbl = pSiS->BIOS[0xc1]; - biosflag = pSiS->BIOS[0xf3]; + if(pSiS->sishw_ext.UseROM) { + biosflag = pSiS->BIOS[0x58]; + temp = pSiS->BIOS[0x254] | (pSiS->BIOS[0x255] << 8); + if(pSiS->VBFlags & VB_301) temp += 6; + else if(pSiS->VBFlags & VB_301B) temp += 12; + else if(pSiS->VBFlags & VB_301C) temp += 18; + else if(pSiS->VBFlags & VB_301LV) temp += 12; + else if(pSiS->VBFlags & VB_302LV) temp += 12; + else if(pSiS->VBFlags & VB_302ELV) temp += 18; + vga2_bh = pSiS->BIOS[temp+1]; vga2_bl = pSiS->BIOS[temp]; + svhs_bh = pSiS->BIOS[temp+3]; svhs_bl = pSiS->BIOS[temp+2]; + cvbs_bh = pSiS->BIOS[temp+5]; cvbs_bl = pSiS->BIOS[temp+4]; } else { - testvga2_tempbh = 0x00; testvga2_tempbl = 0xd1; - testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xb9; - testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xb3; - biosflag = 0; - } - if(pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) { - if(pSiS->sishw_ext.UseROM) { - testvga2_tempbh = pSiS->BIOS[0xc4]; testvga2_tempbl = pSiS->BIOS[0xc3]; - testsvhs_tempbh = pSiS->BIOS[0xc6]; testsvhs_tempbl = pSiS->BIOS[0xc5]; - testcvbs_tempbh = pSiS->BIOS[0xc8]; testcvbs_tempbl = pSiS->BIOS[0xc7]; + biosflag = 2; + if(pSiS->VBFlags & (VB_301B | VB_301LV | VB_302LV)) { + vga2_bh = 0x01; vga2_bl = 0x90; + svhs_bh = 0x01; svhs_bl = 0x6b; /* Are these really correct for LV? */ + cvbs_bh = 0x01; cvbs_bl = 0x74; + } else if(pSiS->VBFlags & (VB_301C | VB_302ELV)) { + vga2_bh = 0x01; vga2_bl = 0x90; + svhs_bh = 0x01; svhs_bl = 0x6b; + cvbs_bh = 0x01; cvbs_bl = 0x10; } else { - testvga2_tempbh = 0x01; testvga2_tempbl = 0x90; - testsvhs_tempbh = 0x01; testsvhs_tempbl = 0x6b; - testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x74; + vga2_bh = 0x00; vga2_bl = 0xfd; + svhs_bh = 0x00; svhs_bl = 0xdd; + cvbs_bh = 0x00; cvbs_bl = 0xee; } } - inSISIDXREG(SISPART4,0x01,myflag); - if(myflag & 0x04) { - testvga2_tempbh = 0x00; testvga2_tempbl = 0xfd; - testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xdd; - testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xee; + + vga2_ch = 0x0e; vga2_cl = 0x08; + svhs_ch = 0x04; svhs_cl = 0x04; + cvbs_ch = 0x08; cvbs_cl = 0x04; + + if(pSiS->VBFlags & (VB_301LV|VB_302LV|VB_302ELV)) { + vga2_bh = 0x00; vga2_bl = 0x00; + vga2_ch = 0x00; vga2_cl = 0x00; + svhs_ch = 0x04; svhs_cl = 0x08; + cvbs_ch = 0x08; cvbs_cl = 0x08; } - testvga2_tempch = 0x0e; testvga2_tempcl = 0x08; - testsvhs_tempch = 0x06; testsvhs_tempcl = 0x04; - testcvbs_tempch = 0x08; testcvbs_tempcl = 0x04; - } else if(pSiS->Chipset == PCI_CHIP_SIS330) { + } else { if(pSiS->sishw_ext.UseROM) { - testvga2_tempbh = pSiS->BIOS[0xe6]; testvga2_tempbl = pSiS->BIOS[0xe5]; - testsvhs_tempbh = pSiS->BIOS[0xe8]; testsvhs_tempbl = pSiS->BIOS[0xe7]; - testcvbs_tempbh = pSiS->BIOS[0xea]; testcvbs_tempbl = pSiS->BIOS[0xe9]; - biosflag = pSiS->BIOS[0x11b]; + if(pSiS->Chipset == PCI_CHIP_SIS330) { + 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 { - testvga2_tempbh = 0x00; testvga2_tempbl = 0xd1; - testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xb9; - testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xb3; - biosflag = 0; + vga2_bh = 0x00; vga2_bl = 0xd1; + svhs_bh = 0x00; svhs_bl = 0xb9; + cvbs_bh = 0x00; cvbs_bl = 0xb3; + biosflag = 2; } - if(pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) { + + if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)) { if(pSiS->sishw_ext.UseROM) { - testvga2_tempbh = pSiS->BIOS[0xec]; testvga2_tempbl = pSiS->BIOS[0xeb]; - testsvhs_tempbh = pSiS->BIOS[0xee]; testsvhs_tempbl = pSiS->BIOS[0xed]; - testcvbs_tempbh = pSiS->BIOS[0xf0]; testcvbs_tempbl = pSiS->BIOS[0xef]; + if(pSiS->Chipset == PCI_CHIP_SIS330) { + 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 { - testvga2_tempbh = 0x01; testvga2_tempbl = 0x90; - testsvhs_tempbh = 0x01; testsvhs_tempbl = 0x6b; - testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x74; + 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; + } } } - inSISIDXREG(SISPART4,0x01,myflag); - if(myflag & 0x04) { - testvga2_tempbh = 0x00; testvga2_tempbl = 0xfd; - testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xdd; - testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xee; + + if(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; + } } - testvga2_tempch = 0x0e; testvga2_tempcl = 0x08; - testsvhs_tempch = 0x06; testsvhs_tempcl = 0x04; - testcvbs_tempch = 0x08; testcvbs_tempcl = 0x04; - - } else { /* 550?, 650, 740 */ - - if(pSiS->sishw_ext.UseROM) { - testvga2_tempbh = pSiS->BIOS[0xbe]; testvga2_tempbl = pSiS->BIOS[0xbd]; - testsvhs_tempbh = pSiS->BIOS[0xc0]; testsvhs_tempbl = pSiS->BIOS[0xbf]; - testcvbs_tempbh = pSiS->BIOS[0xc2]; testcvbs_tempbl = pSiS->BIOS[0xc1]; - biosflag = pSiS->BIOS[0xf3]; + + if(pSiS->VBFlags & (VB_301LV|VB_302LV|VB_302ELV)) { + /* 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 { - testvga2_tempbh = 0x00; testvga2_tempbl = 0xd1; - testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xb9; - testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xb3; - biosflag = 0; - } - testvga2_tempch = 0x0e; testvga2_tempcl = 0x08; - testsvhs_tempch = 0x06; testsvhs_tempcl = 0x04; - testcvbs_tempch = 0x08; testcvbs_tempcl = 0x04; - - /* TW: Different BIOS versions use different values for the 301LV. - These values are from the newest versions 1.10.6? and 1.10.7?. - I have no idea if these values are suitable for the 301B as well. - */ - - if(pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) { - if(pSiS->sishw_ext.UseROM) { - testvga2_tempbh = pSiS->BIOS[0xc4]; testvga2_tempbl = pSiS->BIOS[0xc3]; - testsvhs_tempbh = pSiS->BIOS[0xc6]; testsvhs_tempbl = pSiS->BIOS[0xc5]; - testcvbs_tempbh = pSiS->BIOS[0xc8]; testcvbs_tempbl = pSiS->BIOS[0xc7]; - biosflag = pSiS->BIOS[0xf3]; - } else { - testvga2_tempbh = 0x01; testvga2_tempbl = 0x90; - testsvhs_tempbh = 0x02; testsvhs_tempbl = 0x00; - testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x00; - biosflag = 0; - } - testvga2_tempch = 0x0e; testvga2_tempcl = 0x08; - testsvhs_tempch = 0x04; testsvhs_tempcl = 0x08; - testcvbs_tempch = 0x08; testcvbs_tempcl = 0x08; + vga2_ch = 0x0e; vga2_cl = 0x08; + svhs_ch = 0x04; svhs_cl = 0x04; + cvbs_ch = 0x08; cvbs_cl = 0x04; } - } - - /* TW: No VGA2 or SCART on LV bridges */ - if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) { - testvga2_tempbh = testvga2_tempbl = 0x00; - testvga2_tempch = testvga2_tempcl = 0x00; - } + } - if(testvga2_tempch || testvga2_tempcl || testvga2_tempbh || testvga2_tempbl) { + 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", - testvga2_tempbh, testvga2_tempbl, testvga2_tempch, testvga2_tempcl); + vga2_bh, vga2_bl, vga2_ch, vga2_cl); #endif - result = SISDoSense(pScrn, testvga2_tempbl, testvga2_tempbh, - testvga2_tempcl, testvga2_tempch); + 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, @@ -1083,7 +1196,7 @@ void SISSense30x(ScrnInfoPtr pScrn) pSiS->VBFlags |= TV_SCART; orSISIDXREG(SISCR, 0x32, 0x04); pSiS->postVBCR32 |= 0x04; - } else if(!(pSiS->VBFlags & (VB_30xLV|VB_30xLVX))) { + } else { xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "SiS30x: Detected secondary VGA connection\n"); pSiS->VBFlags |= VGA2_CONNECTED; @@ -1091,41 +1204,61 @@ void SISSense30x(ScrnInfoPtr pScrn) 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", - testsvhs_tempbh, testsvhs_tempbl, testsvhs_tempch, testsvhs_tempcl, - testcvbs_tempbh, testcvbs_tempbl, testcvbs_tempch, testcvbs_tempcl); + svhs_bh, svhs_bl, svhs_ch, svhs_cl, + cvbs_bh, cvbs_bl, cvbs_ch, cvbs_cl); #endif - result = SISDoSense(pScrn, testsvhs_tempbl, testsvhs_tempbh, - testsvhs_tempcl, testsvhs_tempch); + andSISIDXREG(SISCR, 0x32, ~0x03); + pSiS->postVBCR32 &= ~0x03; + + if(pSiS->VBFlags & (VB_301C | VB_302ELV)) { + orSISIDXREG(SISPART4,0x0d,0x04); + } + + 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"); - /* TW: So we can be sure that there IS a SVIDEO output */ - pSiS->VBFlags |= TV_SVIDEO; - orSISIDXREG(SISCR, 0x32, 0x02); - pSiS->postVBCR32 |= 0x02; + 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))) { - result = SISDoSense(pScrn, testcvbs_tempbl, testcvbs_tempbh, - testcvbs_tempcl, testcvbs_tempch); - if(result) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + 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"); - /* TW: So we can be sure that there IS a CVBS output */ - pSiS->VBFlags |= TV_AVIDEO; - orSISIDXREG(SISCR, 0x32, 0x01); - pSiS->postVBCR32 |= 0x01; - } + 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); } @@ -1139,9 +1272,10 @@ SiS6326TVDelay(ScrnInfoPtr pScrn, int delay) for(i=0; i<delay; i++) { inSISIDXREG(SISSR, 0x05, temp); } + (void)temp; } -int +static int SIS6326DoSense(ScrnInfoPtr pScrn, int tempbh, int tempbl, int tempch, int tempcl) { unsigned char temp; @@ -1161,7 +1295,7 @@ SIS6326DoSense(ScrnInfoPtr pScrn, int tempbh, int tempbl, int tempch, int tempcl return(tempcl); } -void +static void SISSense6326(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); @@ -1183,22 +1317,29 @@ SISSense6326(ScrnInfoPtr pScrn) pSiS->SiS6326Flags |= SIS6326_TVDETECTED; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "SiS6326: Detected TV connected to %s output\n", - (pSiS->SiS6326Flags & SIS6326_TVSVIDEO) ? - "SVIDEO" : "COMPOSITE"); + (((pSiS->SiS6326Flags & (SIS6326_TVSVIDEO | SIS6326_TVCVBS)) == + (SIS6326_TVSVIDEO | SIS6326_TVCVBS)) ? + "both SVIDEO and COMPOSITE" : + ((pSiS->SiS6326Flags & SIS6326_TVSVIDEO) ? + "SVIDEO" : "COMPOSITE"))); } else { xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "SiS6326: No TV detected\n"); } } -/* TW: Detect video bridge and set VBFlags accordingly */ +/* Detect video bridge and set VBFlags accordingly */ void SISVGAPreInit(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - int temp,temp1,temp2; + int temp,temp1,temp2, i; int upperlimitlvds, lowerlimitlvds; int upperlimitch, lowerlimitch; - int chronteltype, chrontelidreg; + int chronteltype, chrontelidreg, upperlimitvb; + unsigned char test[3]; +#if 0 + unsigned char sr17=0; +#endif static const char *ChrontelTypeStr[] = { "7004", "7005", @@ -1221,6 +1362,7 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) case PCI_CHIP_SIS315H: case PCI_CHIP_SIS315PRO: case PCI_CHIP_SIS330: + case PCI_CHIP_SIS660: pSiS->ModeInit = SIS300Init; break; default: @@ -1237,33 +1379,53 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) } pSiS->VBFlags = 0; /* reset VBFlags */ + pSiS->SiS_Pr->SiS_UseLCDA = FALSE; + pSiS->SiS_Pr->Backup = FALSE; - /* TW: Videobridges only available for 300/310/325 series */ + /* Videobridges only available for 300/315 series */ if((pSiS->VGAEngine != SIS_300_VGA) && (pSiS->VGAEngine != SIS_315_VGA)) return; - + inSISIDXREG(SISPART4, 0x00, temp); temp &= 0x0F; - if (temp == 1) { + if(temp == 1) { inSISIDXREG(SISPART4, 0x01, temp1); temp1 &= 0xff; - if (temp1 >= 0xE0) { - pSiS->VBFlags |= VB_30xLVX; - pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LVX; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS301LVX video bridge (Revision 0x%x)\n", + if(temp1 >= 0xE0) { + inSISIDXREG(SISPART4, 0x39, temp2); + if(temp2 == 0xff) { + 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); + } else { + pSiS->VBFlags |= VB_302ELV; + pSiS->sishw_ext.ujVBChipID = VB_CHIP_302ELV; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Detected SiS302ELV video bridge (ID 1; Revision 0x%x)\n", temp1); - } else if (temp1 >= 0xD0) { - pSiS->VBFlags |= VB_30xLV; + } + } else if(temp1 >= 0xD0) { + pSiS->VBFlags |= VB_301LV; pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LV; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS301LV video bridge (Revision 0x%x)\n", + "Detected SiS301LV video bridge (ID 1; Revision 0x%x)\n", + 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); - } else if (temp1 >= 0xB0) { + } 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 video bridge (Revision 0x%x)\n", + "Detected SiS301B%s video bridge (Revision 0x%x)\n", + (temp2 & 0x02) ? "" : " (DH)", temp1); } else { pSiS->VBFlags |= VB_301; @@ -1272,113 +1434,88 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) "Detected SiS301 video bridge (Revision 0x%x)\n", temp1); } - if (pSiS->VBFlags & (VB_30xLV | VB_30xLVX)) { - inSISIDXREG(SISCR, 0x38, temp); - if((temp & 0x03) == 0x03) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "[SiS301LV/LVX: LCD channel A]\n"); - } - } - SISSense30x(pScrn); + SISSense30x(pScrn); } else if (temp == 2) { inSISIDXREG(SISPART4, 0x01, temp1); temp1 &= 0xff; - if (temp1 >= 0xE0) { - pSiS->VBFlags |= VB_30xLVX; - pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LVX; + if(temp1 >= 0xE0) { + pSiS->VBFlags |= VB_302LV; + pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LV; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS302LVX video bridge (Revision 0x%x)\n", + "Detected SiS302LV video bridge (ID 2; Revision 0x%x)\n", temp1); - } else if (temp1 >= 0xD0) { - pSiS->VBFlags |= VB_30xLV; - pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LV; + } else if(temp1 >= 0xD0) { + pSiS->VBFlags |= VB_301LV; + pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LV; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS302LV video bridge (Revision 0x%x)\n", + "Detected SiS301LV video bridge (ID 2; Revision 0x%x)\n", 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 video bridge (Revision 0x%x)\n", + "Detected SiS302B%s video bridge (Revision 0x%x)\n", + (temp2 & 0x02) ? "" : " (DH)", temp1); } - if (pSiS->VBFlags & (VB_302B | VB_30xLV | VB_30xLVX)) { - inSISIDXREG(SISCR, 0x38, temp); - if((temp & 0x03) == 0x03) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "[SiS302B/LV/LVX: LCD channel A]\n"); - } - } SISSense30x(pScrn); } else if (temp == 3) { - pSiS->VBFlags |= VB_303; - pSiS->sishw_ext.ujVBChipID = VB_CHIP_303; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected SiS303 video bridge\n"); + "Detected SiS303 video bridge - not supported\n"); } 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->Chipset == PCI_CHIP_SIS660) { + 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->Chipset == PCI_CHIP_SIS660) { + 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"); - } - if(temp1 & 0x08) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "[LVDS: HDTV]\n"); - } - if(temp1 & 0x08) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "[LVDS: SCART]\n"); - } - } } if((temp >= lowerlimitch) && (temp <= upperlimitch)) { - /* TW: Set global for init301.c */ + /* Set global for init301.c */ pSiS->SiS_Pr->SiS_IF_DEF_CH70xx = chronteltype; if(chronteltype == 1) { - /* TW: Do something mysterious (found in Mitac BIOS) */ - SiS_WhatIsThis(pSiS->SiS_Pr, 0x9c); + /* Set general purpose IO for Chrontel communication */ + SiS_SetChrontelGPIO(pSiS->SiS_Pr, 0x9c); } - /* TW: Read Chrontel version number */ + /* Read Chrontel version number */ temp1 = SiS_GetCH70xx(pSiS->SiS_Pr, chrontelidreg); if(chronteltype == 1) { - /* TW: See Chrontel TB31 for explanation */ + /* See Chrontel TB31 for explanation */ temp2 = SiS_GetCH700x(pSiS->SiS_Pr, 0x0e); - if(((temp2 & 0x07) == 0x01) || (temp & 0x04)) { + if(((temp2 & 0x07) == 0x01) || (temp2 & 0x04)) { SiS_SetCH700x(pSiS->SiS_Pr, 0x0b0e); SiS_DDC2Delay(pSiS->SiS_Pr, 300); } @@ -1388,6 +1525,8 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) if(temp1 == 0xFFFF) { /* 0xFFFF = error reading DDC port */ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Detected Chrontel 70xx, but encountered error reading I2C port\n"); + andSISIDXREG(SISCR, 0x32, ~0x07); + pSiS->postVBCR32 &= ~0x07; } /* TW: We only support device ids 0x19-200; other values may indicate DDC problems */ else if((temp1 >= 0x19) && (temp1 <= 200)) { @@ -1407,42 +1546,54 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) "Detected Chrontel %s TV encoder (ID 0x%02x; bridge type %d)\n", ChrontelTypeStr[temp2], temp1, temp); - /* TW: Sense connected TV's */ + /* Sense connected TV's */ if(chronteltype == 1) { /* Chrontel 700x */ - /* TW: Read power status */ + /* 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); } - /* TW: Sense connected TV devices */ - 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)) temp1 = 0x02; - else if(!(temp1 & 0x02)) temp1 = 0x01; - else temp1 = 0; + /* 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 */ - /* TW: Backup Power register */ + /* Backup Power register */ temp1 = SiS_GetCH701x(pSiS->SiS_Pr, 0x49); - /* TW: Enable TV path */ + /* Enable TV path */ SiS_SetCH701x(pSiS->SiS_Pr, 0x2049); SiS_DDC2Delay(pSiS->SiS_Pr, 0x96); - /* TW: Sense connected TV devices */ + /* Sense connected TV devices */ temp2 = SiS_GetCH701x(pSiS->SiS_Pr, 0x20); temp2 |= 0x01; SiS_SetCH701x(pSiS->SiS_Pr, (temp2 << 8) | 0x20); @@ -1456,7 +1607,7 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) temp2 = SiS_GetCH701x(pSiS->SiS_Pr, 0x20); - /* TW: Restore Power register */ + /* Restore Power register */ SiS_SetCH701x(pSiS->SiS_Pr, (temp1 << 8) | 0x49); temp1 = 0; @@ -1472,18 +1623,20 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) case 0x01: xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Chrontel: Detected TV connected to COMPOSITE output\n"); - /* TW: So we can be sure that there IS a CVBS output */ 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"); - /* TW: So we can be sure that there IS a SVIDEO output */ 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, @@ -1503,33 +1656,149 @@ void SISVGAPreInit(ScrnInfoPtr pScrn) default: xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Chrontel: No TV detected.\n"); + andSISIDXREG(SISCR, 0x32, ~0x07); + pSiS->postVBCR32 &= ~0x07; } } else if(temp1==0) { - /* TW: This indicates a communication problem, but it only occures if there - * is no TV attached. + /* This indicates a communication problem, but it only occures if there + * is no TV attached. So we don't use TV in this case. */ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Detected Chrontel TV encoder in promiscuous state (DDC/I2C mix-up)\n"); + andSISIDXREG(SISCR, 0x32, ~0x07); + pSiS->postVBCR32 &= ~0x07; } else { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Chrontel: Unsupported device id (%d) detected\n",temp1); + andSISIDXREG(SISCR, 0x32, ~0x07); + pSiS->postVBCR32 &= ~0x07; } if(chronteltype == 1) { - /* TW: Do something mysterious (found in Mitac BIOS) */ - SiS_WhatIsThis(pSiS->SiS_Pr, 0x00); + /* Set general purpose IO for Chrontel communication */ + SiS_SetChrontelGPIO(pSiS->SiS_Pr, 0x00); } } - if ((pSiS->VGAEngine == SIS_300_VGA) && (temp == 3)) { - pSiS->VBFlags |= VB_TRUMPION; + if((pSiS->Chipset == PCI_CHIP_SIS660) && (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)) { xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Detected Trumpion Zurac (I/II/III) LVDS scaler\n"); + "Detected Trumpion Zurac (I/II/III) LVDS scaler - UNSUPPORTED\n"); } - if (temp > upperlimitlvds) { + if(temp > upperlimitvb) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Detected unknown bridge type (%d)\n", temp); } } + + /* Old BIOSes store the detected CRT2 type in SR17, 16 and 13 + * instead of CR32. However, since our detection routines + * store their results to CR32, we now copy the + * remaining bits (for LCD and VGA) to CR32 for unified usage. + * SR17[0] CRT1 [1] LCD [2] TV [3] VGA2 + * [4] AVIDEO [5] SVIDEO + * SR13[0] SCART [1] HiVision + * SR16[5] PAL/NTSC [6] LCD-SCALE [7] OVERSCAN + */ + +#if 0 + inSISIDXREG(SISSR, 0x17, sr17); + if( (pSiS->VGAEngine == SIS_300_VGA) && + (pSiS->Chipset != PCI_CHIP_SIS300) && + (sr17 & 0x0F) ) { + + unsigned char cr32; + inSISIDXREG(SISCR, 0x32, cr32); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Converting SR17 (%02x) to CR32 (%02x)\n", sr17, cr32); + + if(sr17 & 0x01) { /* CRT1 */ + orSISIDXREG(SISCR, 0x32, 0x20); + pSiS->postVBCR32 |= 0x20; + } else { + andSISIDXREG(SISCR, 0x32, ~0x20); + pSiS->postVBCR32 &= ~0x20; + } + + if(sr17 & 0x02) { /* LCD */ + orSISIDXREG(SISCR, 0x32, 0x08); + pSiS->postVBCR32 |= 0x08; + } else { + andSISIDXREG(SISCR, 0x32, ~0x08); + pSiS->postVBCR32 &= ~0x08; + } + + /* No Hivision, no DVI here */ + andSISIDXREG(SISCR,0x32,~0xc0); + pSiS->postVBCR32 &= ~0xc0; + } +#endif + + /* Try to find out if the bridge uses LCDA for low resolution and + * text modes. If sisfb saved this for us, use it. Otherwise, + * check if we are running on a low mode on LCD and read the + * relevant registers ourselves. + */ + if(pSiS->VGAEngine == SIS_315_VGA) { + + 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->ChipFlags |= SiSCF_UseLCDA; + } + } else { + inSISIDXREG(SISCR,0x34,temp); + if(temp <= 0x13) { + inSISIDXREG(SISCR,0x38,temp); + if((temp & 0x03) == 0x03) { + pSiS->SiS_Pr->SiS_UseLCDA = TRUE; + pSiS->ChipFlags |= SiSCF_UseLCDA; + pSiS->SiS_Pr->Backup = TRUE; + } else { + inSISIDXREG(SISCR,0x35,temp); + if(temp & 0x01) { + pSiS->SiS_Pr->SiS_UseLCDA = TRUE; + 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->ChipFlags |= SiSCF_UseLCDA; + pSiS->SiS_Pr->Backup = TRUE; + } + } + } + } + } + } + if(pSiS->ChipFlags & SiSCF_UseLCDA) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Bridge 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); + inSISIDXREG(SISPART1,0x15,pSiS->SiS_Pr->Backup_15); + inSISIDXREG(SISPART1,0x16,pSiS->SiS_Pr->Backup_16); + inSISIDXREG(SISPART1,0x17,pSiS->SiS_Pr->Backup_17); + inSISIDXREG(SISPART1,0x18,pSiS->SiS_Pr->Backup_18); + inSISIDXREG(SISPART1,0x19,pSiS->SiS_Pr->Backup_19); + inSISIDXREG(SISPART1,0x1a,pSiS->SiS_Pr->Backup_1a); + inSISIDXREG(SISPART1,0x1b,pSiS->SiS_Pr->Backup_1b); + inSISIDXREG(SISPART1,0x1c,pSiS->SiS_Pr->Backup_1c); + inSISIDXREG(SISPART1,0x1d,pSiS->SiS_Pr->Backup_1d); + } + } + } + } } diff --git a/src/sis_video.c b/src/sis_video.c index 35a14a7..afe3012 100644 --- a/src/sis_video.c +++ b/src/sis_video.c @@ -1,65 +1,84 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_video.c,v 1.10 2003/02/04 02:44:29 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_video.c,v 1.41 2003/11/19 00:49:06 twini Exp $ */ /* - * Xv driver for SiS 300 and 310/325 series. + * Xv driver for SiS 300, 315 and 330 series. * - * (Based on the mga Xv driver by Mark Vojkovich and i810 Xv - * driver by Jonathan Bian <jonathan.bian@intel.com>.) - * - * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. - * Copyright 2002,2003 by Thomas Winischhofer, Vienna, Austria. + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria. * All Rights Reserved. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: + * Basic structure based on the mga Xv driver by Mark Vojkovich + * and i810 Xv driver by Jonathan Bian <jonathan.bian@intel.com>. * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. + * Formerly based on a mostly non-working fragment for the 630 by + * Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * 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. * - * Authors: - * Sung-Ching Lin <sclin@sis.com.tw> + * 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 <thomas@winischhofer.net>: - * - 310/325 series (315/550/650/651/740/M650) support - * - (possibly incomplete) Xabre (SiS330) support - * - new mode switching code for 300, 310/325 and 330 series - * - many fixes for 300/540/630/730 chipsets, - * - many fixes for 5597/5598, 6326 and 530/620 chipsets, - * - VESA mode switching (deprecated), - * - extended CRT2/video bridge handling support, - * - dual head support on 300, 310/325 and 330 series - * - 650/LVDS (up to 1400x1050), 650/Chrontel 701x support - * - 30xB/30xLV/30xLVX video bridge support (300, 310/325, 330 series) - * - Xv support for 5597/5598, 6326, 530/620 and 310/325 series - * - video overlay enhancements for 300 series - * - TV and hi-res support for the 6326 - * - etc. + * (Original code fragment for 630 by + * Sung-Ching Lin <sclin@sis.com.tw>) * - * TW: This supports the following chipsets: - * SiS300: No registers >0x65, offers one overlay - * SiS630/730: No registers >0x6b, offers two overlays (one used for CRT1, one for CRT2) - * SiS550: Full register range, offers two overlays (one used for CRT1, one for CRT2) - * SiS315: Full register range, offers one overlay (used for both CRT1 and CRT2 alt.) - * SiS650/740: Full register range, offers one overlay (used for both CRT1 and CRT2 alt.) + * + * All comments in this file are by Thomas Winischhofer. + * + * This 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) + * SiS315: Full register range, one overlay (used for both CRT1 and CRT2 alt.) + * 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.) + * SiS661/741/760: Full register range, two overlays (one used for CRT1, one for CRT2) * * Help for reading the code: - * 315/550/650/740/M650/651 = 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: + * + * -) dual head mode: + * 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), 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), 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. + * DISPMODE is either SINGLE1 or SINGLE2. Overlay is used accordingly on either + * 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), 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. */ #include "xf86.h" @@ -82,17 +101,6 @@ #include "sis_regs.h" -#define OFF_DELAY 200 /* milliseconds */ -#define FREE_DELAY 60000 - -#define OFF_TIMER 0x01 -#define FREE_TIMER 0x02 -#define CLIENT_VIDEO_ON 0x04 - -#define TIMER_MASK (OFF_TIMER | FREE_TIMER) - -#define WATCHDOG_DELAY 500000 /* Watchdog counter for Vertical Restrace waiting */ - static XF86VideoAdaptorPtr SISSetupImageVideo(ScreenPtr); static void SISStopVideo(ScrnInfoPtr, pointer, Bool); static int SISSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); @@ -106,187 +114,62 @@ static int SISQueryImageAttributes(ScrnInfoPtr, int, unsigned short *, unsigned short *, int *, int *); static void SISVideoTimerCallback(ScrnInfoPtr pScrn, Time now); static void SISInitOffscreenImages(ScreenPtr pScrn); - -#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) - extern BOOLEAN SiSBridgeIsInSlaveMode(ScrnInfoPtr pScrn); -#define IMAGE_MIN_WIDTH 32 /* Minimum and maximum source image sizes */ -#define IMAGE_MIN_HEIGHT 24 -#define IMAGE_MAX_WIDTH 720 -#define IMAGE_MAX_HEIGHT 576 -#define IMAGE_MAX_WIDTH_M650 1920 -#define IMAGE_MAX_HEIGHT_M650 1080 - -#define OVERLAY_MIN_WIDTH 32 /* Minimum overlay sizes */ -#define OVERLAY_MIN_HEIGHT 24 - -#define DISPMODE_SINGLE1 0x1 /* TW: CRT1 only */ -#define DISPMODE_SINGLE2 0x2 /* TW: CRT2 only */ -#define DISPMODE_MIRROR 0x4 /* TW: CRT1 + CRT2 MIRROR (see note below) */ - -#ifdef SISDUALHEAD -#define HEADOFFSET (pSiS->dhmOffset) -#endif - -/* TW: 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 - * refresh rate. The same applies to modes which require the bridge to - * operate in slave mode. - * When not using VESA and the bridge is not in slave mode otherwise, - * CRT1 and CRT2 have the same resolution but possibly a different - * 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 getvideoreg(SISPtr pSiS, CARD8 reg) -{ - CARD8 ret; - inSISIDXREG(SISVID, reg, ret); - return(ret); -} - -static void setvideoreg(SISPtr pSiS, CARD8 reg, CARD8 data) -{ - outSISIDXREG(SISVID, reg, data); -} - -static 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); -} +#define OFF_DELAY 200 /* milliseconds */ +#define FREE_DELAY 60000 -#if 0 -static CARD8 getsisreg(SISPtr pSiS, CARD8 index_offset, CARD8 reg) -{ - CARD8 ret; - inSISIDXREG(index_offset, reg, ret); - return(ret); -} -#endif +#define OFF_TIMER 0x01 +#define FREE_TIMER 0x02 +#define CLIENT_VIDEO_ON 0x04 -/* VBlank */ -static CARD8 vblank_active_CRT1(SISPtr pSiS) -{ - return (inSISREG(SISINPSTAT) & 0x08); -} +#define TIMER_MASK (OFF_TIMER | FREE_TIMER) -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); -} +#define WATCHDOG_DELAY 500000 /* Watchdog counter for Vertical Restrace waiting */ -/* Scanline - unused */ -#if 0 -static CARD32 get_scanline_CRT1(SISPtr pSiS) -{ - CARD32 line; +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) - _siswrite (pSiS, REG_PRIM_CRT_COUNTER, 0x00000001); - line = _sisread (pSiS, REG_PRIM_CRT_COUNTER); +#define IMAGE_MIN_WIDTH 32 /* Minimum and maximum source image sizes */ +#define IMAGE_MIN_HEIGHT 24 +#define IMAGE_MAX_WIDTH_300 720 +#define IMAGE_MAX_HEIGHT_300 576 +#define IMAGE_MAX_WIDTH_315 1920 +#define IMAGE_MAX_HEIGHT_315 1080 - return ((line >> 16) & 0x07FF); -} +#define OVERLAY_MIN_WIDTH 32 /* Minimum overlay sizes */ +#define OVERLAY_MIN_HEIGHT 24 -static CARD32 get_scanline_CRT2(SISPtr pSiS) -{ - CARD32 line; +#define DISPMODE_SINGLE1 0x1 /* CRT1 only */ +#define DISPMODE_SINGLE2 0x2 /* CRT2 only */ +#define DISPMODE_MIRROR 0x4 /* CRT1 + CRT2 MIRROR (see note below) */ - line = (CARD32)(getsisreg(pSiS, SISPART1, Index_CRT2_FC_VCount1) & 0x70) * 16 - + getsisreg(pSiS, SISPART1, Index_CRT2_FC_VCount); +#define LINEBUFLIMIT1 384 /* Limits at which line buffers must be merged */ +#define LINEBUFLIMIT2 720 +#define LINEBUFLIMIT3 576 - return line; -} +#ifdef SISDUALHEAD +#define HEADOFFSET (pSiS->dhmOffset) #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); +#define GET_PORT_PRIVATE(pScrn) \ + (SISPortPrivPtr)((SISPTR(pScrn))->adaptor->pPortPrivates[0].ptr) - if(newAdaptors) - xfree(newAdaptors); -} +/* 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 + * refresh rate. The same applies to modes which require the bridge to + * operate in slave mode. + * When not using VESA and the bridge is not in slave mode otherwise, + * CRT1 and CRT2 have the same resolution but possibly a different + * refresh rate. + */ /* client libraries expect an encoding */ static XF86VideoEncodingRec DummyEncoding = { 0, "XV_IMAGE", - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - {1, 1} -}; - -static XF86VideoEncodingRec DummyEncoding_M650 = -{ - 0, - "XV_IMAGE", - IMAGE_MAX_WIDTH_M650, IMAGE_MAX_HEIGHT_M650, + 0, 0, /* Will be filled in */ {1, 1} }; @@ -299,46 +182,242 @@ static XF86VideoFormatRec SISFormats[NUM_FORMATS] = {24, TrueColor} }; -#define NUM_ATTRIBUTES_300 5 -#define NUM_ATTRIBUTES_325 7 +static char sisxvcolorkey[] = "XV_COLORKEY"; +static char sisxvbrightness[] = "XV_BRIGHTNESS"; +static char sisxvcontrast[] = "XV_CONTRAST"; +static char sisxvsaturation[] = "XV_SATURATION"; +static char sisxvhue[] = "XV_HUE"; +static char sisxvautopaintcolorkey[] = "XV_AUTOPAINT_COLORKEY"; +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"; +static char sisxvusechromakey[] = "XV_USE_CHROMAKEY"; +static char sisxvinsidechromakey[] = "XV_INSIDE_CHROMAKEY"; +static char sisxvyuvchromakey[] = "XV_YUV_CHROMAKEY"; +static char sisxvchromamin[] = "XV_CHROMAMIN"; +static char sisxvchromamax[] = "XV_CHROMAMAX"; +static char sisxvqueryvbflags[] = "XV_QUERYVBFLAGS"; +static char sisxvsdgetdriverversion[] = "XV_SD_GETDRIVERVERSION"; +static char sisxvsdgethardwareinfo[] = "XV_SD_GETHARDWAREINFO"; +static char sisxvsdgetbusid[] = "XV_SD_GETBUSID"; +static char sisxvsdqueryvbflagsversion[] = "XV_SD_QUERYVBFLAGSVERSION"; +static char sisxvsdgetsdflags[] = "XV_SD_GETSDFLAGS"; +static char sisxvsdunlocksisdirect[] = "XV_SD_UNLOCKSISDIRECT"; +static char sisxvsdsetvbflags[] = "XV_SD_SETVBFLAGS"; +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 sisxvsdsisantiflicker[] = "XV_SD_SISANTIFLICKER"; +static char sisxvsdsissaturation[] = "XV_SD_SISSATURATION"; +static char sisxvsdsisedgeenhance[] = "XV_SD_SISEDGEENHANCE"; +static char sisxvsdsiscolcalibf[] = "XV_SD_SISCOLCALIBF"; +static char sisxvsdsiscolcalibc[] = "XV_SD_SISCOLCALIBC"; +static char sisxvsdsiscfilter[] = "XV_SD_SISCFILTER"; +static char sisxvsdsisyfilter[] = "XV_SD_SISYFILTER"; +static char sisxvsdchcontrast[] = "XV_SD_CHCONTRAST"; +static char sisxvsdchtextenhance[] = "XV_SD_CHTEXTENHANCE"; +static char sisxvsdchchromaflickerfilter[] = "XV_SD_CHCHROMAFLICKERFILTER"; +static char sisxvsdchlumaflickerfilter[] = "XV_SD_CHLUMAFLICKERFILTER"; +static char sisxvsdchcvbscolor[] = "XV_SD_CHCVBSCOLOR"; +static char sisxvsdchoverscan[] = "XV_SD_CHOVERSCAN"; +static char sisxvsdenablegamma[] = "XV_SD_ENABLEGAMMA"; +static char sisxvsdtvxscale[] = "XV_SD_TVXSCALE"; +static char sisxvsdtvyscale[] = "XV_SD_TVYSCALE"; +static char sisxvsdgetscreensize[] = "XV_SD_GETSCREENSIZE"; +static char sisxvsdstorebrir[] = "XV_SD_STOREDGAMMABRIR"; +static char sisxvsdstorebrig[] = "XV_SD_STOREDGAMMABRIG"; +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"; +#ifdef TWDEBUG +static char sisxvsetreg[] = "XV_SD_SETREG"; +#endif + +#ifndef SIS_CP +#define NUM_ATTRIBUTES_300 56 +#ifdef TWDEBUG +#define NUM_ATTRIBUTES_315 63 +#else +#define NUM_ATTRIBUTES_315 62 +#endif +#endif static XF86AttributeRec SISAttributes_300[NUM_ATTRIBUTES_300] = { - {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"}, - {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"}, - {XvSettable | XvGettable, 0, 7, "XV_CONTRAST"}, - {XvSettable | XvGettable, 0, 1, "XV_AUTOPAINT_COLORKEY"}, - {XvSettable , 0, 0, "XV_SET_DEFAULTS"} + {XvSettable | XvGettable, 0, (1 << 24) - 1, sisxvcolorkey}, + {XvSettable | XvGettable, -128, 127, sisxvbrightness}, + {XvSettable | XvGettable, 0, 7, sisxvcontrast}, + {XvSettable | XvGettable, 0, 1, sisxvautopaintcolorkey}, + {XvSettable , 0, 0, sisxvsetdefaults}, + {XvSettable | XvGettable, -32, 32, sisxvtvxposition}, + {XvSettable | XvGettable, -32, 32, sisxvtvyposition}, + {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}, + {XvSettable | XvGettable, 0, (1 << 24) - 1, sisxvchromamin}, + {XvSettable | XvGettable, 0, (1 << 24) - 1, sisxvchromamax}, + { XvGettable, 0, 0xffffffff, sisxvqueryvbflags}, + { XvGettable, 0, 0xffffffff, sisxvsdgetdriverversion}, + { XvGettable, 0, 0xffffffff, sisxvsdgethardwareinfo}, + { XvGettable, 0, 0xffffffff, sisxvsdgetbusid}, + { XvGettable, 0, 0xffffffff, sisxvsdqueryvbflagsversion}, + { XvGettable, 0, 0xffffffff, sisxvsdgetsdflags}, + {XvSettable | XvGettable, 0, 0xffffffff, sisxvsdunlocksisdirect}, + {XvSettable , 0, 0xffffffff, sisxvsdsetvbflags}, + { XvGettable, 0, 0xffffffff, sisxvsdquerydetecteddevices}, + {XvSettable | XvGettable, 0, 1, sisxvsdcrt1status}, + {XvSettable , 0, 0xffffffff, sisxvsdcheckmodeindexforcrt2}, + { XvGettable, 0, 0xffffffff, sisxvsdresultcheckmodeindexforcrt2}, + {XvSettable | XvGettable, 0, 4, sisxvsdsisantiflicker}, + {XvSettable | XvGettable, 0, 15, sisxvsdsissaturation}, + {XvSettable | XvGettable, 0, 15, sisxvsdsisedgeenhance}, + {XvSettable | XvGettable, -128, 127, sisxvsdsiscolcalibf}, + {XvSettable | XvGettable, -120, 120, sisxvsdsiscolcalibc}, + {XvSettable | XvGettable, 0, 1, sisxvsdsiscfilter}, + {XvSettable | XvGettable, 0, 8, sisxvsdsisyfilter}, + {XvSettable | XvGettable, 0, 15, sisxvsdchcontrast}, + {XvSettable | XvGettable, 0, 15, sisxvsdchtextenhance}, + {XvSettable | XvGettable, 0, 15, sisxvsdchchromaflickerfilter}, + {XvSettable | XvGettable, 0, 15, sisxvsdchlumaflickerfilter}, + {XvSettable | XvGettable, 0, 1, sisxvsdchcvbscolor}, + {XvSettable | XvGettable, 0, 3, sisxvsdchoverscan}, + {XvSettable | XvGettable, 0, 3, sisxvsdenablegamma}, + {XvSettable | XvGettable, -16, 16, sisxvsdtvxscale}, + {XvSettable | XvGettable, -4, 3, sisxvsdtvyscale}, + { XvGettable, 0, 0xffffffff, sisxvsdgetscreensize}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorebrir}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorebrig}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorebrib}, + {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}, +#ifdef SIS_CP + SIS_CP_VIDEO_ATTRIBUTES +#endif }; -static XF86AttributeRec SISAttributes_325[NUM_ATTRIBUTES_325] = +static XF86AttributeRec SISAttributes_315[NUM_ATTRIBUTES_315] = { - {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"}, - {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"}, - {XvSettable | XvGettable, 0, 7, "XV_CONTRAST"}, - {XvSettable | XvGettable, -7, 7, "XV_SATURATION"}, - {XvSettable | XvGettable, -8, 7, "XV_HUE"}, - {XvSettable | XvGettable, 0, 1, "XV_AUTOPAINT_COLORKEY"}, - {XvSettable , 0, 0, "XV_SET_DEFAULTS"} + {XvSettable | XvGettable, 0, (1 << 24) - 1, sisxvcolorkey}, + {XvSettable | XvGettable, -128, 127, sisxvbrightness}, + {XvSettable | XvGettable, 0, 7, sisxvcontrast}, + {XvSettable | XvGettable, -7, 7, sisxvsaturation}, + {XvSettable | XvGettable, -8, 7, sisxvhue}, + {XvSettable | XvGettable, 0, 1, sisxvautopaintcolorkey}, + {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 << 24) - 1, sisxvchromamin}, + {XvSettable | XvGettable, 0, (1 << 24) - 1, sisxvchromamax}, + { XvGettable, 0, 0xffffffff, sisxvqueryvbflags}, + { XvGettable, 0, 0xffffffff, sisxvsdgetdriverversion}, + { XvGettable, 0, 0xffffffff, sisxvsdgethardwareinfo}, + { XvGettable, 0, 0xffffffff, sisxvsdgetbusid}, + { XvGettable, 0, 0xffffffff, sisxvsdqueryvbflagsversion}, + { XvGettable, 0, 0xffffffff, sisxvsdgetsdflags}, + {XvSettable | XvGettable, 0, 0xffffffff, sisxvsdunlocksisdirect}, + {XvSettable , 0, 0xffffffff, sisxvsdsetvbflags}, + { XvGettable, 0, 0xffffffff, sisxvsdquerydetecteddevices}, + {XvSettable | XvGettable, 0, 1, sisxvsdcrt1status}, + {XvSettable , 0, 0xffffffff, sisxvsdcheckmodeindexforcrt2}, + { XvGettable, 0, 0xffffffff, sisxvsdresultcheckmodeindexforcrt2}, + {XvSettable | XvGettable, 0, 4, sisxvsdsisantiflicker}, + {XvSettable | XvGettable, 0, 15, sisxvsdsissaturation}, + {XvSettable | XvGettable, 0, 15, sisxvsdsisedgeenhance}, + {XvSettable | XvGettable, -128, 127, sisxvsdsiscolcalibf}, + {XvSettable | XvGettable, -120, 120, sisxvsdsiscolcalibc}, + {XvSettable | XvGettable, 0, 1, sisxvsdsiscfilter}, + {XvSettable | XvGettable, 0, 8, sisxvsdsisyfilter}, + {XvSettable | XvGettable, 0, 15, sisxvsdchcontrast}, + {XvSettable | XvGettable, 0, 15, sisxvsdchtextenhance}, + {XvSettable | XvGettable, 0, 15, sisxvsdchchromaflickerfilter}, + {XvSettable | XvGettable, 0, 15, sisxvsdchlumaflickerfilter}, + {XvSettable | XvGettable, 0, 1, sisxvsdchcvbscolor}, + {XvSettable | XvGettable, 0, 3, sisxvsdchoverscan}, + {XvSettable | XvGettable, 0, 7, sisxvsdenablegamma}, + {XvSettable | XvGettable, -16, 16, sisxvsdtvxscale}, + {XvSettable | XvGettable, -4, 3, sisxvsdtvyscale}, + { XvGettable, 0, 0xffffffff, sisxvsdgetscreensize}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorebrir}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorebrig}, + {XvSettable | XvGettable, 100, 10000, sisxvsdstorebrib}, + {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}, +#ifdef TWDEBUG + {XvSettable , 0, 0xffffffff, sisxvsetreg}, +#endif +#ifdef SIS_CP + SIS_CP_VIDEO_ATTRIBUTES +#endif + {XvSettable | XvGettable, 0, 1, sisxvswitchcrt}, }; -#define NUM_IMAGES 6 +#define NUM_IMAGES_300 6 +#define NUM_IMAGES_315 7 /* 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 */ + +/* TODO: */ +#define PIXEL_FMT_RAW8 0x38574152 -static XF86ImageRec SISImages[NUM_IMAGES] = +static XF86ImageRec SISImages[NUM_IMAGES_330] = { - XVIMAGE_YUY2, /* TW: If order is changed, SISOffscreenImages must be adapted */ + XVIMAGE_YUY2, /* If order is changed, SISOffscreenImages must be adapted */ XVIMAGE_YV12, XVIMAGE_UYVY, XVIMAGE_I420 , { /* RGB 555 */ - 0x35315652, + PIXEL_FMT_RGB5, XvRGB, LSBFirst, {'R','V','1','5', @@ -356,7 +435,7 @@ static XF86ImageRec SISImages[NUM_IMAGES] = XvTopToBottom }, { /* RGB 565 */ - 0x36315652, + PIXEL_FMT_RGB6, XvRGB, LSBFirst, {'R','V','1','6', @@ -372,10 +451,129 @@ static XF86ImageRec SISImages[NUM_IMAGES] = {'R', 'V', 'B',0, 0,0,0,0,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 - } + }, + { /* 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 + }, }; 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; + +} SISPortPrivRec, *SISPortPrivPtr; + +typedef struct { int pixelFormat; CARD16 pitch; @@ -395,22 +593,46 @@ typedef struct { CARD32 PSY; CARD32 PSV; CARD32 PSU; + + CARD16 SCREENheight; + + CARD8 lineBufSize; + + DisplayModePtr currentmode; + +#ifdef SISMERGED + CARD16 pitch2; + CARD16 HUSF2; + CARD16 VUSF2; + CARD8 IntBit2; + CARD8 wHPre2; + + CARD16 srcW2; + CARD16 srcH2; + BoxRec dstBox2; + CARD32 PSY2; + CARD32 PSV2; + CARD32 PSU2; + CARD16 SCREENheight2; + CARD8 lineBufSize2; + + DisplayModePtr currentmode2; + + Bool DoFirst, DoSecond; +#endif + CARD8 bobEnable; CARD8 contrastCtrl; CARD8 contrastFactor; - CARD8 lineBufSize; - - CARD8 (*VBlankActiveFunc)(SISPtr); + CARD8 (*VBlankActiveFunc)(SISPtr, SISPortPrivPtr); #if 0 CARD32 (*GetScanLineFunc)(SISPtr pSiS); #endif - CARD16 SCREENheight; - #if 0 - /* TW: The following are not used yet */ + /* The following are not used yet */ CARD16 SubPictHUSF; /* Subpicture scaling */ CARD16 SubpictVUSF; CARD8 SubpictIntBit; @@ -426,68 +648,264 @@ typedef struct { CARD32 MPEG_Y; /* MPEG Y Buffer Addr */ CARD32 MPEG_UV; /* MPEG UV Buffer Addr */ #endif - + } SISOverlayRec, *SISOverlayPtr; -typedef struct { - FBLinearPtr linear; /* TW: We now use Linear, not Area */ - 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; - char saturation; +/**************************************************************************** + * 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. + ****************************************************************************/ - RegionRec clip; - CARD32 colorKey; - Bool autopaintColorKey; +#if 0 +static CARD32 _sisread(SISPtr pSiS, CARD32 reg) +{ + return *(pSiS->IOBase + reg); +} - CARD32 videoStatus; - Time offTime; - Time freeTime; +static void _siswrite(SISPtr pSiS, CARD32 reg, CARD32 data) +{ + *(pSiS->IOBase + reg) = data; +} +#endif - CARD32 displayMode; - Bool bridgeIsSlave; +static CARD8 getsrreg(SISPtr pSiS, CARD8 reg) +{ + CARD8 ret; + inSISIDXREG(SISSR, reg, ret); + return(ret); +} - Bool hasTwoOverlays; /* TW: Chipset has two overlays */ - Bool dualHeadMode; /* TW: We're running in DHM */ +static CARD8 getvideoreg(SISPtr pSiS, CARD8 reg) +{ + CARD8 ret; + inSISIDXREG(SISVID, reg, ret); + return(ret); +} - Bool needToScale; /* TW: Need to scale video */ +static __inline void setvideoreg(SISPtr pSiS, CARD8 reg, CARD8 data) +{ + outSISIDXREG(SISVID, reg, data); +} - int shiftValue; /* 550/650 need word addr/pitch, 630 double word */ +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); +} - short oldx1, oldx2, oldy1, oldy2; - int mustwait; +static void setsrregmask(SISPtr pSiS, CARD8 reg, CARD8 data, CARD8 mask) +{ + CARD8 old; - Bool grabbedByV4L; /* V4L stuff */ - int pitch; - int offset; + 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); +} -} SISPortPrivRec, *SISPortPrivPtr; +static CARD8 vblank_active_CRT2(SISPtr pSiS, SISPortPrivPtr pPriv) +{ + CARD8 ret; -#define GET_PORT_PRIVATE(pScrn) \ - (SISPortPrivPtr)((SISPTR(pScrn))->adaptor->pPortPrivates[0].ptr) + 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) ^ 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 static void -SISSetPortDefaults (ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) +SiSComputeXvGamma(SISPtr pSiS) { - pPriv->colorKey = 0x000101fe; + 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]; + 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); +} + +static void +SISSetPortDefaults(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) +{ + SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate;; +#endif + + pPriv->colorKey = pSiS->colorKey = 0x000101fe; pPriv->videoStatus = 0; - pPriv->brightness = 0; - pPriv->contrast = 4; - pPriv->hue = 0; - pPriv->saturation = 0; + pPriv->brightness = pSiS->XvDefBri; + pPriv->contrast = pSiS->XvDefCon; + pPriv->hue = pSiS->XvDefHue; + pPriv->saturation = pSiS->XvDefSat; pPriv->autopaintColorKey = TRUE; + pPriv->disablegfx = pSiS->XvDefDisableGfx; + pPriv->disablegfxlr= pSiS->XvDefDisableGfxLR; + pSiS->disablecolorkeycurrent = pSiS->XvDisableColorKey; + pPriv->usechromakey = pSiS->XvUseChromaKey; + pPriv->insidechromakey = pSiS->XvInsideChromaKey; + pPriv->yuvchromakey = pSiS->XvYUVChromaKey; + pPriv->chromamin = pSiS->XvChromaMin; + pPriv->chromamax = pSiS->XvChromaMax; + if(pPriv->dualHeadMode) { +#ifdef SISDUALHEAD + if(!pSiS->SecondHead) { + pPriv->tvxpos = pSiS->tvxpos; + pPriv->tvypos = pSiS->tvypos; + pPriv->updatetvxpos = TRUE; + pPriv->updatetvypos = TRUE; + } +#endif + } else { + pPriv->tvxpos = pSiS->tvxpos; + pPriv->tvypos = pSiS->tvypos; + pPriv->updatetvxpos = TRUE; + pPriv->updatetvypos = TRUE; + } +#ifdef SIS_CP + SIS_CP_VIDEO_DEF +#endif + if(pPriv->dualHeadMode) { +#ifdef SISDUALHEAD + pPriv->crtnum = + pSiSEnt->curxvcrtnum = + pSiSEnt->XvOnCRT2 ? 1 : 0; +#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 +static void SISResetVideo(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); @@ -497,28 +915,40 @@ SISResetVideo(ScrnInfoPtr pScrn) #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif - if (getvideoreg (pSiS, Index_VI_Passwd) != 0xa1) { + if(getvideoreg (pSiS, Index_VI_Passwd) != 0xa1) { setvideoreg (pSiS, Index_VI_Passwd, 0x86); - if (getvideoreg (pSiS, Index_VI_Passwd) != 0xa1) + if(getvideoreg (pSiS, Index_VI_Passwd) != 0xa1) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Xv: Video password could not unlock registers\n"); } /* Initialize first overlay (CRT1) ------------------------------- */ - /* Write-enable video registers */ - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x80, 0x81); + /* This bit has obviously a different meaning on 315 series (linebuffer-related) */ + if(pSiS->VGAEngine == SIS_300_VGA) { + /* Write-enable video registers */ + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x80, 0x81); + } else { + /* Select overlay 2, clear all linebuffer related bits */ + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0xb1); + } /* Disable overlay */ setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); - /* Disable bobEnable */ - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x02, 0x02); + /* Disable bob de-interlacer and some strange bit */ + setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x82); + + /* Select RGB chroma key format (300 series only) */ + if(pSiS->VGAEngine == SIS_300_VGA) { + setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x40); + } /* Reset scale control and contrast */ + /* (Enable DDA (interpolation)) */ setvideoregmask(pSiS, Index_VI_Scale_Control, 0x60, 0x60); setvideoregmask(pSiS, Index_VI_Contrast_Enh_Ctrl, 0x04, 0x1F); - + setvideoreg(pSiS, Index_VI_Disp_Y_Buf_Preset_Low, 0x00); setvideoreg(pSiS, Index_VI_Disp_Y_Buf_Preset_Middle, 0x00); setvideoreg(pSiS, Index_VI_UV_Buf_Preset_Low, 0x00); @@ -527,18 +957,43 @@ SISResetVideo(ScrnInfoPtr pScrn) setvideoreg(pSiS, Index_VI_Play_Threshold_Low, 0x00); setvideoreg(pSiS, Index_VI_Play_Threshold_High, 0x00); - /* Initialize second overlay (CRT2) ---- only for 630/730, 550, M650/651 */ - if (pPriv->hasTwoOverlays) { - /* Write-enable video registers */ - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x81, 0x81); + 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, 0x2c, 0x3c); + } + + if((pSiS->ChipFlags & SiSCF_Is65x) || (pSiS->Chipset == PCI_CHIP_SIS660)) { + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0x04); + } + + /* 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) { + /* Write-enable video registers */ + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x81, 0x81); + } else { + /* Select overlay 2, clear all linebuffer related bits */ + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, 0xb1); + } /* Disable overlay */ setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); - /* Disable bobEnable */ - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x02, 0x02); + /* Disable bob de-interlacer and some strange bit */ + setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x82); + + /* Select RGB chroma key format */ + if(pSiS->VGAEngine == SIS_300_VGA) { + setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x40); + } /* Reset scale control and contrast */ + /* (Enable DDA (interpolation)) */ setvideoregmask(pSiS, Index_VI_Scale_Control, 0x60, 0x60); setvideoregmask(pSiS, Index_VI_Contrast_Enh_Ctrl, 0x04, 0x1F); @@ -549,70 +1004,83 @@ 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_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); + } + } /* set default properties for overlay 1 (CRT1) -------------------------- */ - setvideoregmask (pSiS, Index_VI_Control_Misc2, 0x00, 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, 0x00, 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); } - /* set default properties for overlay 2(CRT2) only 630/730 and 550 ------ */ - 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); - } + /* 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); + } + } + + /* Reset Xv gamma correction */ + if(pSiS->VGAEngine == SIS_315_VGA) { + SiSUpdateXvGamma(pSiS, pPriv); } } -/* TW: Set display mode (single CRT1/CRT2, mirror). - * MIRROR mode is only available on chipsets with two overlays. - * On the other chipsets, if only CRT1 or only CRT2 are used, - * the correct display CRT is chosen automatically. If both - * CRT1 and CRT2 are connected, the user can choose between CRT1 and - * CRT2 by using the option XvOnCRT2. +/* Set display mode (single CRT1/CRT2, mirror). + * MIRROR mode is only available on chipsets with two overlays. + * On the other chipsets, if only CRT1 or only CRT2 are used, + * the correct display CRT is chosen automatically. If both + * CRT1 and CRT2 are connected, the user can choose between CRT1 and + * CRT2 by using the option XvOnCRT2. */ static void set_dispmode(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) { SISPtr pSiS = SISPTR(pScrn); - + pPriv->dualHeadMode = pPriv->bridgeIsSlave = FALSE; if(SiSBridgeIsInSlaveMode(pScrn)) pPriv->bridgeIsSlave = TRUE; if( (pSiS->VBFlags & VB_DISPMODE_MIRROR) || ((pPriv->bridgeIsSlave) && (pSiS->VBFlags & DISPTYPE_DISP2)) ) { - if(pPriv->hasTwoOverlays) - pPriv->displayMode = DISPMODE_MIRROR; /* TW: CRT1 + CRT2 (2 overlays) */ - else if(pSiS->XvOnCRT2) - pPriv->displayMode = DISPMODE_SINGLE2; - else - pPriv->displayMode = DISPMODE_SINGLE1; + 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) - /* TW: Slave is always CRT1 */ - pPriv->displayMode = DISPMODE_SINGLE1; - else - /* TW: Master is always CRT2 */ - pPriv->displayMode = DISPMODE_SINGLE2; - } else -#endif - if(pSiS->VBFlags & DISPTYPE_DISP1) { - pPriv->displayMode = DISPMODE_SINGLE1; /* TW: CRT1 only */ - } else { - pPriv->displayMode = DISPMODE_SINGLE2; /* TW: CRT2 only */ - } + 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 */ + } } } @@ -620,8 +1088,14 @@ static void set_disptype_regs(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) { SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; + int crtnum = 0; + + if(pPriv->dualHeadMode) crtnum = pSiSEnt->curxvcrtnum; +#endif - /* TW: + /* * SR06[7:6] * Bit 7: Enable overlay 2 on CRT2 * Bit 6: Enable overlay 1 on CRT2 @@ -636,52 +1110,132 @@ set_disptype_regs(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) * 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. + * 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. + * * For chipsets with only one overlay, user must choose whether * to display the overlay on CRT1 or CRT2 by setting XvOnCRT2 - * to TRUE (CRT2) or FALSE (CRT1). The hardware does not - * support any kind of "Mirror" mode on these chipsets. + * to TRUE (CRT2) or FALSE (CRT1). The driver does this auto- + * matically if only CRT1 or only CRT2 is used. */ #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif + switch (pPriv->displayMode) { - case DISPMODE_SINGLE1: /* TW: CRT1 only */ - if (pPriv->hasTwoOverlays) { - if (pPriv->dualHeadMode) { - setsrregmask (pSiS, 0x06, 0x00, 0x40); - setsrregmask (pSiS, 0x32, 0x00, 0x40); + case DISPMODE_SINGLE1: /* CRT1-only mode: */ + if(pPriv->hasTwoOverlays) { + if(pPriv->dualHeadMode) { + setsrregmask(pSiS, 0x06, 0x00, 0x40); /* overlay 1 -> CRT1 */ + setsrregmask(pSiS, 0x32, 0x00, 0x40); } else { - setsrregmask (pSiS, 0x06, 0x00, 0xc0); - setsrregmask (pSiS, 0x32, 0x00, 0xc0); + setsrregmask(pSiS, 0x06, 0x00, 0xc0); /* both overlays -> CRT1 */ + setsrregmask(pSiS, 0x32, 0x00, 0xc0); } } else { - setsrregmask (pSiS, 0x06, 0x00, 0xc0); - setsrregmask (pSiS, 0x32, 0x00, 0xc0); +#ifdef SISDUALHEAD + if((!pPriv->dualHeadMode) || (crtnum == 0)) { +#endif + setsrregmask(pSiS, 0x06, 0x00, 0xc0); /* only overlay -> CRT1 */ + setsrregmask(pSiS, 0x32, 0x00, 0xc0); +#ifdef SISDUALHEAD + } +#endif } break; - case DISPMODE_SINGLE2: /* TW: CRT2 only */ - if (pPriv->hasTwoOverlays) { - if (pPriv->dualHeadMode) { - setsrregmask (pSiS, 0x06, 0x80, 0x80); - setsrregmask (pSiS, 0x32, 0x80, 0x80); + + case DISPMODE_SINGLE2: /* CRT2-only mode: */ + if(pPriv->hasTwoOverlays) { + if(pPriv->dualHeadMode) { + setsrregmask(pSiS, 0x06, 0x80, 0x80); /* overlay 2 -> CRT2 */ + setsrregmask(pSiS, 0x32, 0x80, 0x80); } else { - setsrregmask (pSiS, 0x06, 0x80, 0xc0); - setsrregmask (pSiS, 0x32, 0x80, 0xc0); + setsrregmask(pSiS, 0x06, 0x40, 0xc0); /* overlay 1 -> CRT2 */ + setsrregmask(pSiS, 0x32, 0xc0, 0xc0); /* (although both clocks for CRT2!) */ } } else { - setsrregmask (pSiS, 0x06, 0x40, 0xc0); - setsrregmask (pSiS, 0x32, 0x40, 0xc0); +#ifdef SISDUALHEAD + if((!pPriv->dualHeadMode) || (crtnum == 1)) { +#endif + setsrregmask(pSiS, 0x06, 0x40, 0xc0); /* only overlay -> CRT2 */ + setsrregmask(pSiS, 0x32, 0x40, 0xc0); +#ifdef SISDUALHEAD + } +#endif } break; - case DISPMODE_MIRROR: /* TW: CRT1 + CRT2 */ - default: - setsrregmask (pSiS, 0x06, 0x80, 0xc0); - setsrregmask (pSiS, 0x32, 0x80, 0xc0); + + 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, 0x32, 0x80, 0xc0); break; } } +static void +set_allowswitchcrt(SISPtr pSiS, SISPortPrivPtr pPriv) +{ + if(pSiS->hasTwoOverlays) { + pPriv->AllowSwitchCRT = FALSE; + } else { + pPriv->AllowSwitchCRT = TRUE; + if(pSiS->XvOnCRT2) { + if(!(pSiS->VBFlags & DISPTYPE_DISP1)) { + pPriv->AllowSwitchCRT = FALSE; + } + } else { + if(!(pSiS->VBFlags & DISPTYPE_DISP2)) { + pPriv->AllowSwitchCRT = FALSE; + } + } + } +} + +static void +set_maxencoding(SISPtr pSiS, SISPortPrivPtr pPriv) +{ + if(pSiS->VGAEngine == SIS_300_VGA) { + DummyEncoding.width = IMAGE_MAX_WIDTH_300; + DummyEncoding.height = IMAGE_MAX_HEIGHT_300; + } else { + DummyEncoding.width = IMAGE_MAX_WIDTH_315; + DummyEncoding.height = IMAGE_MAX_HEIGHT_315; + if(pPriv->hasTwoOverlays) { + /* Only half width available if both overlays + * are going to be used + */ +#ifdef SISDUALHEAD + if(pSiS->DualHeadMode) { + if(pSiS->Chipset == PCI_CHIP_SIS660) { + DummyEncoding.width = 1536; + } else { + DummyEncoding.width >>= 1; + } + } else +#endif +#ifdef SISMERGED + if(pSiS->MergedFB) { + if(pSiS->Chipset == PCI_CHIP_SIS660) { + DummyEncoding.width = 1536; + } else { + DummyEncoding.width >>= 1; + } + } else +#endif + if(pPriv->displayMode == DISPMODE_MIRROR) { + if(pSiS->Chipset == PCI_CHIP_SIS660) { + DummyEncoding.width = 1536; + } else { + DummyEncoding.width >>= 1; + } + } + } + } +} + static XF86VideoAdaptorPtr SISSetupImageVideo(ScreenPtr pScreen) { @@ -697,29 +1251,53 @@ SISSetupImageVideo(ScreenPtr pScreen) adapt->type = XvWindowMask | XvInputMask | XvImageMask; adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - adapt->name = "SIS 300/310/325 series Video Overlay"; + adapt->name = "SIS 300/315/330 series Video Overlay"; adapt->nEncodings = 1; - if(pSiS->Flags650 & SiS650_LARGEOVERLAY) { - adapt->pEncodings = &DummyEncoding_M650; - } else { - adapt->pEncodings = &DummyEncoding; - } + adapt->pEncodings = &DummyEncoding; + adapt->nFormats = NUM_FORMATS; adapt->pFormats = SISFormats; adapt->nPorts = 1; adapt->pPortPrivates = (DevUnion*)(&adapt[1]); pPriv = (SISPortPrivPtr)(&adapt->pPortPrivates[1]); + + /* Setup chipset type helpers */ + if(pSiS->hasTwoOverlays) { + pPriv->hasTwoOverlays = TRUE; + pPriv->AllowSwitchCRT = FALSE; + } else { + pPriv->hasTwoOverlays = FALSE; + pPriv->AllowSwitchCRT = TRUE; + if(pSiS->XvOnCRT2) { + if(!(pSiS->VBFlags & DISPTYPE_DISP1)) { + pPriv->AllowSwitchCRT = FALSE; + } + } else { + if(!(pSiS->VBFlags & DISPTYPE_DISP2)) { + pPriv->AllowSwitchCRT = FALSE; + } + } + } + + set_allowswitchcrt(pSiS, pPriv); adapt->pPortPrivates[0].ptr = (pointer)(pPriv); - adapt->nImages = NUM_IMAGES; if(pSiS->VGAEngine == SIS_300_VGA) { + adapt->nImages = NUM_IMAGES_300; adapt->pAttributes = SISAttributes_300; adapt->nAttributes = NUM_ATTRIBUTES_300; } else { - adapt->pAttributes = SISAttributes_325; - adapt->nAttributes = NUM_ATTRIBUTES_325; + if(pSiS->sishw_ext.jChipType >= SIS_330) { + adapt->nImages = NUM_IMAGES_330; + } else { + adapt->nImages = NUM_IMAGES_315; + } + adapt->pAttributes = SISAttributes_315; + adapt->nAttributes = NUM_ATTRIBUTES_315; + if(pPriv->hasTwoOverlays) adapt->nAttributes--; } + adapt->pImages = SISImages; adapt->PutVideo = NULL; adapt->PutStill = NULL; @@ -736,32 +1314,93 @@ SISSetupImageVideo(ScreenPtr pScreen) pPriv->currentBuf = 0; pPriv->linear = NULL; pPriv->grabbedByV4L= FALSE; - - SISSetPortDefaults(pScrn, pPriv); + pPriv->NoOverlay = FALSE; + pPriv->PrevOverlay = 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; - pSiS->xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); - pSiS->xvContrast = MAKE_ATOM("XV_CONTRAST"); - pSiS->xvColorKey = MAKE_ATOM("XV_COLORKEY"); - if(pSiS->VGAEngine == SIS_315_VGA) { - pSiS->xvSaturation = MAKE_ATOM("XV_SATURATION"); - pSiS->xvHue = MAKE_ATOM("XV_HUE"); - } - pSiS->xvAutopaintColorKey = MAKE_ATOM("XV_AUTOPAINT_COLORKEY"); - pSiS->xvSetDefaults = MAKE_ATOM("XV_SET_DEFAULTS"); + pSiS->xvBrightness = MAKE_ATOM(sisxvbrightness); + pSiS->xvContrast = MAKE_ATOM(sisxvcontrast); + pSiS->xvColorKey = MAKE_ATOM(sisxvcolorkey); + pSiS->xvSaturation = MAKE_ATOM(sisxvsaturation); + pSiS->xvHue = MAKE_ATOM(sisxvhue); + pSiS->xvSwitchCRT = MAKE_ATOM(sisxvswitchcrt); + pSiS->xvAutopaintColorKey = MAKE_ATOM(sisxvautopaintcolorkey); + pSiS->xvSetDefaults = MAKE_ATOM(sisxvsetdefaults); + pSiS->xvDisableGfx = MAKE_ATOM(sisxvdisablegfx); + 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); + pSiS->xvYUVChromakey = MAKE_ATOM(sisxvyuvchromakey); + pSiS->xvChromaMin = MAKE_ATOM(sisxvchromamin); + pSiS->xvChromaMax = MAKE_ATOM(sisxvchromamax); + pSiS->xv_QVF = MAKE_ATOM(sisxvqueryvbflags); + pSiS->xv_GDV = MAKE_ATOM(sisxvsdgetdriverversion); + pSiS->xv_GHI = MAKE_ATOM(sisxvsdgethardwareinfo); + pSiS->xv_GBI = MAKE_ATOM(sisxvsdgetbusid); + pSiS->xv_QVV = MAKE_ATOM(sisxvsdqueryvbflagsversion); + pSiS->xv_GSF = MAKE_ATOM(sisxvsdgetsdflags); + pSiS->xv_USD = MAKE_ATOM(sisxvsdunlocksisdirect); + pSiS->xv_SVF = MAKE_ATOM(sisxvsdsetvbflags); + pSiS->xv_QDD = MAKE_ATOM(sisxvsdquerydetecteddevices); + pSiS->xv_CT1 = MAKE_ATOM(sisxvsdcrt1status); + pSiS->xv_CMD = MAKE_ATOM(sisxvsdcheckmodeindexforcrt2); + pSiS->xv_CMDR = MAKE_ATOM(sisxvsdresultcheckmodeindexforcrt2); + pSiS->xv_TAF = MAKE_ATOM(sisxvsdsisantiflicker); + pSiS->xv_TSA = MAKE_ATOM(sisxvsdsissaturation); + pSiS->xv_TEE = MAKE_ATOM(sisxvsdsisedgeenhance); + pSiS->xv_COC = MAKE_ATOM(sisxvsdsiscolcalibc); + pSiS->xv_COF = MAKE_ATOM(sisxvsdsiscolcalibf); + pSiS->xv_CFI = MAKE_ATOM(sisxvsdsiscfilter); + pSiS->xv_YFI = MAKE_ATOM(sisxvsdsisyfilter); + pSiS->xv_TCO = MAKE_ATOM(sisxvsdchcontrast); + pSiS->xv_TTE = MAKE_ATOM(sisxvsdchtextenhance); + pSiS->xv_TCF = MAKE_ATOM(sisxvsdchchromaflickerfilter); + pSiS->xv_TLF = MAKE_ATOM(sisxvsdchlumaflickerfilter); + pSiS->xv_TCC = MAKE_ATOM(sisxvsdchcvbscolor); + pSiS->xv_OVR = MAKE_ATOM(sisxvsdchoverscan); + pSiS->xv_SGA = MAKE_ATOM(sisxvsdenablegamma); + pSiS->xv_TXS = MAKE_ATOM(sisxvsdtvxscale); + pSiS->xv_TYS = MAKE_ATOM(sisxvsdtvyscale); + pSiS->xv_GSS = MAKE_ATOM(sisxvsdgetscreensize); + pSiS->xv_BRR = MAKE_ATOM(sisxvsdstorebrir); + pSiS->xv_BRG = MAKE_ATOM(sisxvsdstorebrig); + pSiS->xv_BRB = MAKE_ATOM(sisxvsdstorebrib); + 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); +#ifdef TWDEBUG + pSiS->xv_STR = MAKE_ATOM(sisxvsetreg); +#endif +#ifdef SIS_CP + SIS_CP_VIDEO_ATOMS +#endif - /* TW: Setup chipset type helpers */ - if (pSiS->hasTwoOverlays) - pPriv->hasTwoOverlays = TRUE; - else - pPriv->hasTwoOverlays = FALSE; + pSiS->xv_sisdirectunlocked = 0; + pSiS->xv_sd_result = 0; - /* TW: 300 series require double words for addresses and pitches, - * 310/325 series accept word. + /* 300 series require double words for addresses and pitches, + * 315/330 series require word. */ switch (pSiS->VGAEngine) { case SIS_315_VGA: @@ -776,14 +1415,64 @@ SISSetupImageVideo(ScreenPtr pScreen) /* Set displayMode according to VBFlags */ set_dispmode(pScrn, pPriv); + /* Now for the linebuffer stuff. + * 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 ? 720x576 + * 630/730 2 ? 720x576 + * 315 2 960? 1920x1080 + * 650/740 2 960 ("120x128") 1920x1080 + * M650/651.. 4 480 1920x1080 + * 330 2 960 1920x1080 + * 661/741/760 4 768 1920x1080 + * 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). + * To use the maximum width (eg 1920x1080 on the 315 series, including + * the M650, 651 and later), *all* line buffers must be merged. Hence, + * we can only use one overlay. This should be set up for modes where + * 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, or 1536 on 661/741/760. + */ + + pPriv->linebufMergeLimit = LINEBUFLIMIT1; + if(pSiS->Chipset == PCI_CHIP_SIS660) { + pPriv->linebufMergeLimit = LINEBUFLIMIT3; + } + + set_maxencoding(pSiS, pPriv); + + if(pSiS->VGAEngine == SIS_300_VGA) { + pPriv->linebufmask = 0x11; + } else { + pPriv->linebufmask = 0xb1; + if(!(pPriv->hasTwoOverlays)) { + /* On machines with only one overlay, the linebuffers are + * generally larger, so our merging-limit is higher, too. + */ + pPriv->linebufMergeLimit = LINEBUFLIMIT2; + } + } + + /* Reset the properties to their defaults */ + SISSetPortDefaults(pScrn, pPriv); + /* Set SR(06, 32) registers according to DISPMODE */ 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) static Bool RegionsEqual(RegionPtr A, RegionPtr B) { @@ -812,6 +1501,7 @@ RegionsEqual(RegionPtr A, RegionPtr B) return TRUE; } +#endif static int SISSetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, @@ -819,72 +1509,599 @@ SISSetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, { SISPortPrivPtr pPriv = (SISPortPrivPtr)data; SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate;; +#endif if(attribute == pSiS->xvBrightness) { - if((value < -128) || (value > 127)) - return BadValue; - pPriv->brightness = value; + if((value < -128) || (value > 127)) + return BadValue; + pPriv->brightness = value; } else if(attribute == pSiS->xvContrast) { - if((value < 0) || (value > 7)) - return BadValue; - pPriv->contrast = value; + if((value < 0) || (value > 7)) + return BadValue; + pPriv->contrast = value; } else if(attribute == pSiS->xvColorKey) { - pPriv->colorKey = value; - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + pPriv->colorKey = pSiS->colorKey = value; + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); } else if(attribute == pSiS->xvAutopaintColorKey) { - if ((value < 0) || (value > 1)) - return BadValue; + if((value < 0) || (value > 1)) + return BadValue; pPriv->autopaintColorKey = value; } else if(attribute == pSiS->xvSetDefaults) { - SISSetPortDefaults(pScrn, pPriv); + SISSetPortDefaults(pScrn, pPriv); + } else if(attribute == pSiS->xvDisableGfx) { + if((value < 0) || (value > 1)) + return BadValue; + pPriv->disablegfx = value; + } else if(attribute == pSiS->xvDisableGfxLR) { + if((value < 0) || (value > 1)) + return BadValue; + pPriv->disablegfxlr = value; + } else if(attribute == pSiS->xvTVXPosition) { + if((value < -32) || (value > 32)) + return BadValue; + pPriv->tvxpos = value; + if(pSiS->xv_sisdirectunlocked) { + SiS_SetTVxposoffset(pScrn, pPriv->tvxpos); + pPriv->updatetvxpos = FALSE; + } else { + pSiS->tvxpos = pPriv->tvxpos; +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) pSiSEnt->tvxpos = pPriv->tvxpos; +#endif + pPriv->updatetvxpos = TRUE; + } + } else if(attribute == pSiS->xvTVYPosition) { + if((value < -32) || (value > 32)) + return BadValue; + pPriv->tvypos = value; + if(pSiS->xv_sisdirectunlocked) { + SiS_SetTVyposoffset(pScrn, pPriv->tvypos); + pPriv->updatetvypos = FALSE; + } else { + pSiS->tvypos = pPriv->tvypos; +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) pSiSEnt->tvypos = pPriv->tvypos; +#endif + pPriv->updatetvypos = TRUE; + } + } else if(attribute == pSiS->xvDisableColorkey) { + if((value < 0) || (value > 1)) + return BadValue; + pSiS->disablecolorkeycurrent = value; + } else if(attribute == pSiS->xvUseChromakey) { + if((value < 0) || (value > 1)) + return BadValue; + pPriv->usechromakey = value; + } else if(attribute == pSiS->xvInsideChromakey) { + if((value < 0) || (value > 1)) + return BadValue; + pPriv->insidechromakey = value; + } else if(attribute == pSiS->xvYUVChromakey) { + if((value < 0) || (value > 1)) + return BadValue; + pPriv->yuvchromakey = value; + } else if(attribute == pSiS->xvChromaMin) { + pPriv->chromamin = value; + } else if(attribute == pSiS->xvChromaMax) { + pPriv->chromamax = value; + } else if(attribute == pSiS->xv_USD) { + 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_allowswitchcrt(pSiS, pPriv); + set_maxencoding(pSiS, pPriv); + } + } else if(attribute == pSiS->xv_CT1) { +#ifdef SISDUALHEAD + if(!pPriv->dualHeadMode) +#endif + if(pSiS->xv_sisdirectunlocked) { + SISSwitchCRT1Status(pScrn, (unsigned long)value); + 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_TSA) { + if(pSiS->xv_sisdirectunlocked) { + SiS_SetSISTVsaturation(pScrn, (int)value); + } + } else if(attribute == pSiS->xv_TEE) { + if(pSiS->xv_sisdirectunlocked) { + SiS_SetSISTVedgeenhance(pScrn, (int)value); + } + } else if(attribute == pSiS->xv_CFI) { + if(pSiS->xv_sisdirectunlocked) { + SiS_SetSISTVcfilter(pScrn, value ? 1 : 0); + } + } else if(attribute == pSiS->xv_YFI) { + if(pSiS->xv_sisdirectunlocked) { + SiS_SetSISTVyfilter(pScrn, value); + } + } else if(attribute == pSiS->xv_COC) { + if(pSiS->xv_sisdirectunlocked) { + SiS_SetSISTVcolcalib(pScrn, (int)value, TRUE); + } + } else if(attribute == pSiS->xv_COF) { + if(pSiS->xv_sisdirectunlocked) { + SiS_SetSISTVcolcalib(pScrn, (int)value, FALSE); + } + } else if(attribute == pSiS->xv_TCO) { + if(pSiS->xv_sisdirectunlocked) { + SiS_SetCHTVcontrast(pScrn, (int)value); + } + } else if(attribute == pSiS->xv_TTE) { + if(pSiS->xv_sisdirectunlocked) { + SiS_SetCHTVtextenhance(pScrn, (int)value); + } + } else if(attribute == pSiS->xv_TCF) { + if(pSiS->xv_sisdirectunlocked) { + SiS_SetCHTVchromaflickerfilter(pScrn, (int)value); + } + } else if(attribute == pSiS->xv_TLF) { + if(pSiS->xv_sisdirectunlocked) { + SiS_SetCHTVlumaflickerfilter(pScrn, (int)value); + } + } else if(attribute == pSiS->xv_TCC) { + if(pSiS->xv_sisdirectunlocked) { + SiS_SetCHTVcvbscolor(pScrn, value ? 1 : 0); + } + } else if(attribute == pSiS->xv_OVR) { + if(pSiS->xv_sisdirectunlocked) { + pSiS->UseCHOverScan = -1; + pSiS->OptTVSOver = FALSE; + if(value == 3) { + if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTSOVER) { + pSiS->OptTVSOver = TRUE; + } + pSiS->UseCHOverScan = 1; + } else if(value == 2) pSiS->UseCHOverScan = 1; + else if(value == 1) pSiS->UseCHOverScan = 0; + } + } else if(attribute == pSiS->xv_CMD) { + if(pSiS->xv_sisdirectunlocked) { + pSiS->xv_sd_result = (value & 0xffffff00); + if(SISCheckModeIndexForCRT2Type(pScrn, (unsigned short)(value & 0xff), + (unsigned short)((value >> 8) & 0xff), + FALSE)) { + pSiS->xv_sd_result |= 0x01; + } + } + } 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 = 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)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { + SiS_SetTVxscale(pScrn, value); + } + } else if(attribute == pSiS->xv_TYS) { + if((value < -4) || (value > 3)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { + SiS_SetTVyscale(pScrn, value); + } + } else if(attribute == pSiS->xv_BRR) { + if((value < 100) || (value > 10000)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { + pSiS->GammaBriR = value; + } + } else if(attribute == pSiS->xv_BRG) { + if((value < 100) || (value > 10000)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { + pSiS->GammaBriG = value; + } + } else if(attribute == pSiS->xv_BRB) { + if((value < 100) || (value > 10000)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { + pSiS->GammaBriB = value; + } + } else if(attribute == pSiS->xv_PBR) { + if((value < 100) || (value > 10000)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { + pSiS->GammaPBriR = value; + } + } else if(attribute == pSiS->xv_PBG) { + if((value < 100) || (value > 10000)) + return BadValue; + if(pSiS->xv_sisdirectunlocked) { + pSiS->GammaPBriG = value; + } + } else if(attribute == pSiS->xv_PBB) { + if((value < 100) || (value > 10000)) + return BadValue; + 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; + pSiS->HideHWCursor = value ? TRUE : FALSE; + if(pSiS->CursorInfoPtr) { + if(VisibleBackup) { + if(value) { + (pSiS->CursorInfoPtr->HideCursor)(pScrn); + } else { + (pSiS->CursorInfoPtr->ShowCursor)(pScrn); + } + } + pSiS->HWCursorIsVisible = VisibleBackup; + } + } +#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 } else if(pSiS->VGAEngine == SIS_315_VGA) { - if(attribute == pSiS->xvHue) { + if(attribute == pSiS->xvSwitchCRT) { + if(pPriv->AllowSwitchCRT) { + if((value < 0) || (value > 1)) + return BadValue; + pPriv->crtnum = value; +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) pSiSEnt->curxvcrtnum = value; +#endif + } + } 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 ){ SISPortPrivPtr pPriv = (SISPortPrivPtr)data; SISPtr pSiS = SISPTR(pScrn); +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate;; +#endif if(attribute == pSiS->xvBrightness) { - *value = pPriv->brightness; + *value = pPriv->brightness; } else if(attribute == pSiS->xvContrast) { - *value = pPriv->contrast; + *value = pPriv->contrast; } else if(attribute == pSiS->xvColorKey) { - *value = pPriv->colorKey; - } else if (attribute == pSiS->xvAutopaintColorKey) { - *value = (pPriv->autopaintColorKey) ? 1 : 0; + *value = pPriv->colorKey; + } else if(attribute == pSiS->xvAutopaintColorKey) { + *value = (pPriv->autopaintColorKey) ? 1 : 0; + } else if(attribute == pSiS->xvDisableGfx) { + *value = (pPriv->disablegfx) ? 1 : 0; + } else if(attribute == pSiS->xvDisableGfxLR) { + *value = (pPriv->disablegfxlr) ? 1 : 0; + } else if(attribute == pSiS->xvTVXPosition) { + *value = SiS_GetTVxposoffset(pScrn); + } else if(attribute == pSiS->xvTVYPosition) { + *value = SiS_GetTVyposoffset(pScrn); + } else if(attribute == pSiS->xvDisableColorkey) { + *value = (pSiS->disablecolorkeycurrent) ? 1 : 0; + } else if(attribute == pSiS->xvUseChromakey) { + *value = (pPriv->usechromakey) ? 1 : 0; + } else if(attribute == pSiS->xvInsideChromakey) { + *value = (pPriv->insidechromakey) ? 1 : 0; + } else if(attribute == pSiS->xvYUVChromakey) { + *value = (pPriv->yuvchromakey) ? 1 : 0; + } else if(attribute == pSiS->xvChromaMin) { + *value = pPriv->chromamin; + } else if(attribute == pSiS->xvChromaMax) { + *value = pPriv->chromamax; + } else if(attribute == pSiS->xv_QVF) { + *value = pSiS->VBFlags; + } else if(attribute == pSiS->xv_GDV) { + *value = SISDRIVERIVERSION; + } else if(attribute == pSiS->xv_GHI) { + *value = (pSiS->ChipFlags & 0xffff) | (pSiS->sishw_ext.jChipType << 16) | (pSiS->ChipRev << 24); + } else if(attribute == pSiS->xv_GBI) { + *value = (pSiS->PciInfo->bus << 16) | (pSiS->PciInfo->device << 8) | pSiS->PciInfo->func; + } else if(attribute == pSiS->xv_QVV) { + *value = SIS_VBFlagsVersion; + } else if(attribute == pSiS->xv_QDD) { + *value = pSiS->detectedCRT2Devices; + } else if(attribute == pSiS->xv_CT1) { + *value = pSiS->CRT1isoff ? 0 : 1; + } else if(attribute == pSiS->xv_GSF) { + *value = pSiS->SiS_SD_Flags; + } else if(attribute == pSiS->xv_USD) { + *value = pSiS->xv_sisdirectunlocked; + } else if(attribute == pSiS->xv_TAF) { + *value = SiS_GetSISTVantiflicker(pScrn); + } else if(attribute == pSiS->xv_TSA) { + *value = SiS_GetSISTVsaturation(pScrn); + } else if(attribute == pSiS->xv_TEE) { + *value = SiS_GetSISTVedgeenhance(pScrn); + } else if(attribute == pSiS->xv_CFI) { + *value = SiS_GetSISTVcfilter(pScrn); + } else if(attribute == pSiS->xv_YFI) { + *value = SiS_GetSISTVyfilter(pScrn); + } else if(attribute == pSiS->xv_COC) { + *value = SiS_GetSISTVcolcalib(pScrn, TRUE); + } else if(attribute == pSiS->xv_COF) { + *value = SiS_GetSISTVcolcalib(pScrn, FALSE); + } else if(attribute == pSiS->xv_TCO) { + *value = SiS_GetCHTVcontrast(pScrn); + } else if(attribute == pSiS->xv_TTE) { + *value = SiS_GetCHTVtextenhance(pScrn); + } else if(attribute == pSiS->xv_TCF) { + *value = SiS_GetCHTVchromaflickerfilter(pScrn); + } else if(attribute == pSiS->xv_TLF) { + *value = SiS_GetCHTVlumaflickerfilter(pScrn); + } else if(attribute == pSiS->xv_TCC) { + *value = SiS_GetCHTVcvbscolor(pScrn); + } else if(attribute == pSiS->xv_CMDR) { + *value = pSiS->xv_sd_result; + } else if(attribute == pSiS->xv_OVR) { + *value = 0; + if(pSiS->OptTVSOver == 1) *value = 3; + else if(pSiS->UseCHOverScan == 1) *value = 2; + else if(pSiS->UseCHOverScan == 0) *value = 1; + } else if(attribute == pSiS->xv_SGA) { + *value = 0; +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) { + if(pSiSEnt->CRT1gamma) *value |= 0x01; + if(pSiSEnt->CRT2gamma) *value |= 0x02; + } else { +#endif + if(pSiS->CRT1gamma) *value |= 0x01; + if(pSiS->CRT2gamma) *value |= 0x02; +#ifdef SISDUALHEAD + } + if(pSiS->XvGamma) *value |= 0x04; +#endif + } else if(attribute == pSiS->xv_TXS) { + *value = SiS_GetTVxscale(pScrn); + } else if(attribute == pSiS->xv_TYS) { + *value = SiS_GetTVyscale(pScrn); + } else if(attribute == pSiS->xv_GSS) { + *value = (pScrn->virtualX << 16) | pScrn->virtualY; + } else if(attribute == pSiS->xv_BRR) { + *value = pSiS->GammaBriR; + } else if(attribute == pSiS->xv_BRG) { + *value = pSiS->GammaBriG; + } else if(attribute == pSiS->xv_BRB) { + *value = pSiS->GammaBriB; + } else if(attribute == pSiS->xv_PBR) { + *value = pSiS->GammaPBriR; + } else if(attribute == pSiS->xv_PBG) { + *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; +#ifdef SIS_CP + SIS_CP_VIDEO_GETATTRIBUTE +#endif } else if(pSiS->VGAEngine == SIS_315_VGA) { - if(attribute == pSiS->xvHue) { - *value = pPriv->hue; - } else if(attribute == pSiS->xvSaturation) { - *value = pPriv->saturation; - } else return BadMatch; + if(attribute == pSiS->xvSwitchCRT) { +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) + *value = pSiSEnt->curxvcrtnum; + else +#endif + *value = pPriv->crtnum; + } else if(attribute == pSiS->xvHue) { + *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; } -static void +#if 0 /* For future use */ +static int +SiSHandleSiSDirectCommand(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv, sisdirectcommand *sdcbuf) +{ + SISPtr pSiS = SISPTR(pScrn); + int i; + unsigned long j; + + if(sdcbuf->sdc_id != SDC_ID) return BadMatch; + + j = sdcbuf->sdc_header; + j += sdcbuf->sdc_command; + for(i = 0; i < SDC_NUM_PARM; i++) { + j += sdcbuf->sdc_parm[i]; + } + if(j != sdcbuf->sdc_chksum) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "SiS Direct: Bad packet checksum\n"); + return BadMatch; + } + sdcbuf->sdc_header = SDC_RESULT_OK; + switch(sdcbuf->sdc_command) { + case SDC_CMD_GETVERSION: + sdcbuf->sdc_parm[0] = SDC_VERSION; + 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; + } + break; + default: + sdcbuf->sdc_header = SDC_RESULT_UNDEFCMD; + } + + return Success; +} +#endif + +static void SISQueryBestSize( - ScrnInfoPtr pScrn, + ScrnInfoPtr pScrn, Bool motion, - short vid_w, short vid_h, - short drw_w, short drw_h, + short vid_w, short vid_h, + short drw_w, short drw_h, unsigned int *p_w, unsigned int *p_h, pointer data ){ @@ -907,258 +2124,496 @@ calc_scale_factor(SISOverlayPtr pOverlay, ScrnInfoPtr pScrn, CARD16 LCDheight = pSiS->LCDheight; int srcPitch = pOverlay->origPitch; int origdstH = dstH; + int modeflags = pOverlay->currentmode->Flags; - /* TW: Stretch image due to idiotic LCD "auto"-scaling on LVDS (and 630+301B) */ - 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) { - dstH = (dstH * LCDheight) / pOverlay->SCREENheight; - } else if( (pSiS->VGAEngine == SIS_300_VGA) && - (pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) ) { - dstH = (dstH * LCDheight) / pOverlay->SCREENheight; - } - } else if(iscrt2) { - if (pSiS->VBFlags & VB_LVDS) { - dstH = (dstH * LCDheight) / pOverlay->SCREENheight; - if (pPriv->displayMode == DISPMODE_MIRROR) flag = 1; - } else if ( (pSiS->VGAEngine == SIS_300_VGA) && - (pSiS->VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) ) { - dstH = (dstH * LCDheight) / pOverlay->SCREENheight; - if (pPriv->displayMode == DISPMODE_MIRROR) flag = 1; + if(pSiS->VBFlags & (VB_LVDS | VB_30xBDH)) { + if(pSiS->MiscFlags & MISC_PANELLINKSCALER) { + dstH = (dstH * LCDheight) / pOverlay->SCREENheight; + } + } + } 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; + } } } } - /* TW: For double scan modes, we need to double the height - * (Perhaps we also need to scale LVDS, but I'm not sure.) - * On 310/325 series, we need to double the width as well. - * Interlace mode vice versa. + + /* For double scan modes, we need to double the height + * On 315 and 550 (?), we need to double the width as well. + * Interlace mode vice versa. */ - if(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { - dstH = origdstH << 1; - flag = 0; - if(pSiS->VGAEngine == SIS_315_VGA) { - dstW <<= 1; - } + if(modeflags & V_DBLSCAN) { + dstH = origdstH << 1; + flag = 0; + if((pSiS->sishw_ext.jChipType >= SIS_315H) && + (pSiS->sishw_ext.jChipType <= SIS_550)) { + dstW <<= 1; + } } - if(pSiS->CurrentLayout.mode->Flags & V_INTERLACE) { - dstH = origdstH >> 1; - flag = 0; + if(modeflags & V_INTERLACE) { + 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; - } else if (dstW > srcW) { - dstW += 2; - pOverlay->HUSF = (srcW << 16) / dstW; - pOverlay->IntBit = 0x04; - pOverlay->wHPre = 0; + if(dstW == srcW) { + 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; } else { - int tmpW = dstW; + 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; + } - /* TW: 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 310/325 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; + } - I = 0; - pOverlay->IntBit = 0x01; - while (srcW >= tmpW) { - tmpW <<= 1; - I++; + if(dstH < OVERLAY_MIN_HEIGHT) dstH = OVERLAY_MIN_HEIGHT; + if(dstH == srcH) { + pOverlay->VUSF = 0x00; + pOverlay->IntBit |= 0x0A; + } else if(dstH > srcH) { + dstH += 0x02; + pOverlay->VUSF = (srcH << 16) / dstH; + pOverlay->IntBit |= 0x08; + } else { + + 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 0 + if(((pOverlay->bobEnable & 0x08) == 0x00) && + (((srcPitch * I)>>2) > 0xFFF)){ + pOverlay->bobEnable |= 0x08; + srcPitch >>= 1; } - pOverlay->wHPre = (CARD8)(I - 1); - dstW <<= (I - 1); - if ((srcW % dstW)) - pOverlay->HUSF = ((srcW - dstW) << 16) / dstW; - else - pOverlay->HUSF = 0x00; +#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); + } + } +} + +#ifdef SISMERGED +static void +calc_scale_factor_2(SISOverlayPtr pOverlay, ScrnInfoPtr pScrn, + SISPortPrivPtr pPriv, int index, int iscrt2) +{ + SISPtr pSiS = SISPTR(pScrn); + CARD32 I=0,mult=0; + int flag=0; + + int dstW = pOverlay->dstBox2.x2 - pOverlay->dstBox2.x1; + int dstH = pOverlay->dstBox2.y2 - pOverlay->dstBox2.y1; + int srcW = pOverlay->srcW2; + int srcH = pOverlay->srcH2; + CARD16 LCDheight = pSiS->LCDheight; + int srcPitch = pOverlay->origPitch; + int origdstH = dstH; + int modeflags = pOverlay->currentmode2->Flags; + + /* Stretch image due to panel link scaling */ + if(pSiS->VBFlags & CRT2_LCD) { + if(pSiS->VBFlags & (VB_LVDS | VB_30xBDH)) { + if(pSiS->MiscFlags & MISC_PANELLINKSCALER) { + dstH = (dstH * LCDheight) / pOverlay->SCREENheight2; + flag = 1; + } + } + } + /* For double scan modes, we need to double the height + * On 315 and 550 (?), we need to double the width as well. + * 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; + } + } + if(modeflags & V_INTERLACE) { + 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; + } else if(dstW > srcW) { + 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; + } + + 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->VUSF = 0x00; - pOverlay->IntBit |= 0x0A; - } else if (dstH > srcH) { - dstH += 0x02; - pOverlay->VUSF = (srcH << 16) / dstH; - pOverlay->IntBit |= 0x08; + if(dstH == srcH) { + pOverlay->VUSF2 = 0x00; + pOverlay->IntBit2 |= 0x0A; + } else if(dstH > srcH) { + dstH += 0x02; + pOverlay->VUSF2 = (srcH << 16) / dstH; + pOverlay->IntBit2 |= 0x08; } else { - CARD32 realI; - I = realI = srcH / dstH; - pOverlay->IntBit |= 0x02; + I = srcH / dstH; + pOverlay->IntBit2 |= 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->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->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->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 void -set_line_buf_size(SISOverlayPtr pOverlay) +static CARD8 +calc_line_buf_size(CARD32 srcW, CARD8 wHPre, CARD32 pixelFormat) { CARD8 preHIDF; CARD32 I; - CARD32 line = pOverlay->srcW; + CARD32 line = srcW; - if ( (pOverlay->pixelFormat == PIXEL_FMT_YV12) || - (pOverlay->pixelFormat == PIXEL_FMT_I420) ) + if( (pixelFormat == PIXEL_FMT_YV12) || + (pixelFormat == PIXEL_FMT_I420) || + (pixelFormat == PIXEL_FMT_NV12) || + (pixelFormat == PIXEL_FMT_NV21) ) { - preHIDF = pOverlay->wHPre & 0x07; + preHIDF = wHPre & 0x07; switch (preHIDF) { case 3 : - if ((line & 0xffffff00) == line) + if((line & 0xffffff00) == line) I = (line >> 8); else I = (line >> 8) + 1; - pOverlay->lineBufSize = (CARD8)(I * 32 - 1); - break; + return((CARD8)(I * 32 - 1)); case 4 : - if ((line & 0xfffffe00) == line) + if((line & 0xfffffe00) == line) I = (line >> 9); else I = (line >> 9) + 1; - pOverlay->lineBufSize = (CARD8)(I * 64 - 1); - break; + return((CARD8)(I * 64 - 1)); case 5 : - if ((line & 0xfffffc00) == line) + if((line & 0xfffffc00) == line) I = (line >> 10); else I = (line >> 10) + 1; - pOverlay->lineBufSize = (CARD8)(I * 128 - 1); - break; + return((CARD8)(I * 128 - 1)); case 6 : - if ((line & 0xfffff800) == line) - I = (line >> 11); - else - I = (line >> 11) + 1; - pOverlay->lineBufSize = (CARD8)(I * 256 - 1); - break; + return((CARD8)(255)); default : - if ((line & 0xffffff80) == line) + if((line & 0xffffff80) == line) I = (line >> 7); else I = (line >> 7) + 1; - pOverlay->lineBufSize = (CARD8)(I * 16 - 1); - break; + return((CARD8)(I * 16 - 1)); } } else { /* YUV2, UYVY */ - if ((line & 0xffffff8) == line) - I = (line >> 3); + if((line & 0xffffff8) == line) + I = (line >> 3); else - I = (line >> 3) + 1; - pOverlay->lineBufSize = (CARD8)(I - 1); + I = (line >> 3) + 1; + return((CARD8)(I - 1)); } } +static __inline void +set_line_buf_size_1(SISOverlayPtr pOverlay) +{ + pOverlay->lineBufSize = calc_line_buf_size(pOverlay->srcW,pOverlay->wHPre, pOverlay->pixelFormat); +} + +#ifdef SISMERGED +static __inline void +set_line_buf_size_2(SISOverlayPtr pOverlay) +{ + pOverlay->lineBufSize2 = calc_line_buf_size(pOverlay->srcW2,pOverlay->wHPre2, pOverlay->pixelFormat); +} + static void -merge_line_buf(SISPtr pSiS, SISPortPrivPtr pPriv, Bool enable) +merge_line_buf_mfb(SISPtr pSiS, SISPortPrivPtr pPriv, Bool enable1, Bool enable2, + short width1, short width2, short limit) { - if(enable) { - switch (pPriv->displayMode){ + unsigned char misc1, misc2, mask = pPriv->linebufmask; + + 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 = 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 */ + + 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); + + } +} +#endif + +/* About linebuffer merging: + * + * For example the 651: + * Each overlay has 4 line buffers, 384 bytes each (<-- Is that really correct? 1920 / 384 = 5 !!!) + * If the source width is greater than 384, line buffers must be merged. + * Dual merge: Only O1 usable (uses overlay 2's linebuffer), maximum width 384*2 + * Individual merge: Both overlays available, maximum width 384*2 + * All merge: Only overlay 1 available, maximum width = 384*4 (<--- should be 1920, is 1536...) + * + * + * Normally: Dual merge: Individual merge + * Overlay 1 Overlay 2 Overlay 1 only! Both overlays + * ___1___ ___5___ ___1___ ___2___ -\ O1 ___1___ ___2___ + * ___2___ ___6___ ___3___ ___4___ \_ O 1 O1 ___3___ ___4___ + * ___3___ ___7___ ___5___ ___6___ / O2 ___5___ ___6___ + * ___4___ ___8___ ___7___ ___8___ -/ O2 ___7___ ___8___ + * + * + * All merge: ___1___ ___2___ ___3___ ___4___ + * (Overlay 1 only!) ___5___ ___6___ ___7___ ___8___ + * + * 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. + * + */ + + +static void +merge_line_buf(SISPtr pSiS, SISPortPrivPtr pPriv, Bool enable, short width, short limit) +{ + unsigned char misc1, misc2, mask = pPriv->linebufmask; + + if(enable) { /* ----- enable linebuffer merge */ + + switch(pPriv->displayMode){ case DISPMODE_SINGLE1: - if (pPriv->hasTwoOverlays) { - if (pPriv->dualHeadMode) { - /* line merge */ - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0x11); - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x04, 0x04); + if(pSiS->VGAEngine == SIS_300_VGA) { + if(pPriv->dualHeadMode) { + misc2 = 0x00; + misc1 = 0x04; } else { - /* dual line merge */ - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x10, 0x11); - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x04); + misc2 = 0x10; + misc1 = 0x00; } } else { - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x10, 0x11); - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x04); + if(pPriv->hasTwoOverlays) { + if(pPriv->dualHeadMode) { + misc2 = 0x00; + misc1 = 0x04; + } else { + if(width > (limit * 2)) { + misc2 = 0x20; + } else { + misc2 = 0x10; + } + misc1 = 0x00; + } + } else { + misc2 = 0x00; + misc1 = 0x04; + } } + setvideoregmask(pSiS, Index_VI_Control_Misc2, misc2, mask); + setvideoregmask(pSiS, Index_VI_Control_Misc1, misc1, 0x04); break; + case DISPMODE_SINGLE2: - if (pPriv->hasTwoOverlays) { - if (pPriv->dualHeadMode) { - /* line merge */ - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, 0x11); - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x04, 0x04); + if(pSiS->VGAEngine == SIS_300_VGA) { + if(pPriv->dualHeadMode) { + misc2 = 0x01; + misc1 = 0x04; } else { - /* line merge */ - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, 0x11); - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x04, 0x04); + misc2 = 0x10; + misc1 = 0x00; } } else { - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x10, 0x11); - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x04); + if(pPriv->hasTwoOverlays) { + if(pPriv->dualHeadMode) { + misc2 = 0x01; + misc1 = 0x04; + } else { + if(width > (limit * 2)) { + misc2 = 0x20; + } else { + misc2 = 0x10; + } + misc1 = 0x00; + } + } else { + misc2 = 0x00; + misc1 = 0x04; + } } + setvideoregmask(pSiS, Index_VI_Control_Misc2, misc2, mask); + setvideoregmask(pSiS, Index_VI_Control_Misc1, misc1, 0x04); break; - case DISPMODE_MIRROR: + + case DISPMODE_MIRROR: /* This can only be on chips with 2 overlays */ default: - /* line merge */ - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0x11); + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, mask); setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x04, 0x04); - if (pPriv->hasTwoOverlays) { - /* line merge */ - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, 0x11); - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x04, 0x04); - } - break; + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, mask); + setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x04, 0x04); + break; } - } else { - switch (pPriv->displayMode) { + + } else { /* ----- disable linebuffer merge */ + + switch(pPriv->displayMode) { + case DISPMODE_SINGLE1: - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0x11); + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, mask); setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x04); break; + case DISPMODE_SINGLE2: - if (pPriv->hasTwoOverlays) { - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, 0x11); - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x04); - } else { - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0x11); - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x04); + if(pSiS->VGAEngine == SIS_300_VGA) { + if(pPriv->dualHeadMode) misc2 = 0x01; + else misc2 = 0x00; + } else { + if(pPriv->hasTwoOverlays) { + if(pPriv->dualHeadMode) misc2 = 0x01; + else misc2 = 0x00; + } else { + misc2 = 0x00; + } } + setvideoregmask(pSiS, Index_VI_Control_Misc2, misc2, mask); + setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x04); break; - case DISPMODE_MIRROR: + + case DISPMODE_MIRROR: /* This can only be on chips with 2 overlays */ default: - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0x11); + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, mask); + setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x04); + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, mask); setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x04); - if (pPriv->hasTwoOverlays) { - setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, 0x11); - setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x04); - } break; } } } -static void +static __inline void set_format(SISPtr pSiS, SISOverlayPtr pOverlay) { CARD8 fmt; @@ -1169,11 +2624,20 @@ set_format(SISPtr pSiS, SISOverlayPtr pOverlay) fmt = 0x0c; break; case PIXEL_FMT_YUY2: - fmt = 0x28; + fmt = 0x28; break; case PIXEL_FMT_UYVY: fmt = 0x08; break; + case PIXEL_FMT_YVYU: + fmt = 0x38; + break; + case PIXEL_FMT_NV12: + fmt = 0x4c; + break; + case PIXEL_FMT_NV21: + fmt = 0x5c; + break; case PIXEL_FMT_RGB5: /* D[5:4] : 00 RGB555, 01 RGB 565 */ fmt = 0x00; break; @@ -1184,10 +2648,10 @@ set_format(SISPtr pSiS, SISOverlayPtr pOverlay) fmt = 0x00; break; } - setvideoregmask(pSiS, Index_VI_Control_Misc0, fmt, 0x7c); + setvideoregmask(pSiS, Index_VI_Control_Misc0, fmt, 0xfc); } -static void +static __inline void set_colorkey(SISPtr pSiS, CARD32 colorkey) { CARD8 r, g, b; @@ -1196,7 +2660,6 @@ set_colorkey(SISPtr pSiS, CARD32 colorkey) g = (CARD8)((colorkey>>8) & 0xFF); r = (CARD8)((colorkey>>16) & 0xFF); - /* Activate the colorkey mode */ setvideoreg(pSiS, Index_VI_Overlay_ColorKey_Blue_Min ,(CARD8)b); setvideoreg(pSiS, Index_VI_Overlay_ColorKey_Green_Min ,(CARD8)g); setvideoreg(pSiS, Index_VI_Overlay_ColorKey_Red_Min ,(CARD8)r); @@ -1206,281 +2669,136 @@ set_colorkey(SISPtr pSiS, CARD32 colorkey) setvideoreg(pSiS, Index_VI_Overlay_ColorKey_Red_Max ,(CARD8)r); } -static void +static __inline void +set_chromakey(SISPtr pSiS, CARD32 chromamin, CARD32 chromamax) +{ + CARD8 r1, g1, b1; + CARD8 r2, g2, b2; + + b1 = (CARD8)(chromamin & 0xFF); + g1 = (CARD8)((chromamin>>8) & 0xFF); + r1 = (CARD8)((chromamin>>16) & 0xFF); + b2 = (CARD8)(chromamax & 0xFF); + g2 = (CARD8)((chromamax>>8) & 0xFF); + r2 = (CARD8)((chromamax>>16) & 0xFF); + + setvideoreg(pSiS, Index_VI_Overlay_ChromaKey_Blue_V_Min ,(CARD8)b1); + setvideoreg(pSiS, Index_VI_Overlay_ChromaKey_Green_U_Min ,(CARD8)g1); + setvideoreg(pSiS, Index_VI_Overlay_ChromaKey_Red_Y_Min ,(CARD8)r1); + + setvideoreg(pSiS, Index_VI_Overlay_ChromaKey_Blue_V_Max ,(CARD8)b2); + setvideoreg(pSiS, Index_VI_Overlay_ChromaKey_Green_U_Max ,(CARD8)g2); + setvideoreg(pSiS, Index_VI_Overlay_ChromaKey_Red_Y_Max ,(CARD8)r2); +} + +static __inline void set_brightness(SISPtr pSiS, CARD8 brightness) { setvideoreg(pSiS, Index_VI_Brightness, brightness); } -static void +static __inline void set_contrast(SISPtr pSiS, CARD8 contrast) { - setvideoregmask(pSiS, Index_VI_Contrast_Enh_Ctrl, contrast, 0x07); + setvideoregmask(pSiS, Index_VI_Contrast_Enh_Ctrl, contrast ^ 0x07, 0x07); } -/* 310/325 series only */ -static void -set_saturation(SISPtr pSiS, char saturation) +/* 315 series and later only */ +static __inline void +set_saturation(SISPtr pSiS, short saturation) { CARD8 temp = 0; - + if(saturation < 0) { temp |= 0x88; saturation = -saturation; } temp |= (saturation & 0x07); temp |= ((saturation & 0x07) << 4); - + setvideoreg(pSiS, Index_VI_Saturation, temp); } -/* 310/325 series only */ -static void +/* 315 series and later only */ +static __inline void set_hue(SISPtr pSiS, CARD8 hue) { - setvideoreg(pSiS, Index_VI_Hue, (hue & 0x08) ? (hue ^ 0x07) : hue); -} - -#ifdef NOT_YET_IMPLEMENTED /* ----------- TW: FOR FUTURE USE -------------------- */ - -/* TW: Set Alpha */ -static void -set_alpha(SISPtr pSiS, CARD8 alpha) -{ - CARD8 data; - - data = getvideoreg(pSiS, Index_VI_Key_Overlay_OP); - data &= 0x0F; - setvideoreg(pSiS,Index_VI_Key_Overlay_OP, data | (alpha << 4)); + setvideoregmask(pSiS, Index_VI_Hue, (hue & 0x08) ? (hue ^ 0x07) : hue, 0x0F); } -/* TW: Set SubPicture Start Address (yet unused) */ -static void -set_subpict_start_offset(SISPtr pSiS, SISOverlayPtr pOverlay, int index) +static __inline void +set_disablegfx(SISPtr pSiS, Bool mybool, SISOverlayPtr pOverlay) { - CARD32 temp; - CARD8 data; - - temp = pOverlay->SubPictAddr >> 4; /* TW: 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); + /* This is not supported on M65x, 65x (x>0) or later */ + /* For CRT1 ONLY!!! */ + if((!(pSiS->ChipFlags & SiSCF_Is65x)) && (pSiS->Chipset != PCI_CHIP_SIS660)) { + setvideoregmask(pSiS, Index_VI_Control_Misc2, mybool ? 0x04 : 0x00, 0x04); + if(mybool) pOverlay->keyOP = VI_ROP_Always; } } -/* TW: Set SubPicture Pitch (yet unused) */ -static void -set_subpict_pitch(SISPtr pSiS, SISOverlayPtr pOverlay, int index) -{ - CARD32 temp; - CARD8 data; - - temp = pOverlay->SubPictPitch >> 4; /* TW: 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); - } -} - -/* TW: 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; - - 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; - - /* TW: Stretch image due to idiotic LCD "auto"-scaling */ - /* INCOMPLETE - 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; - } - - 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; - - 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; - - pOverlay->SubPictIntBit = 0x01; - } - - 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; - - I = realI = srcH / dstH; - pOverlay->SubPictIntBit |= 0x02; - - 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); -} - -/* TW: Set SubPicture Preset (yet unused) */ -static void -set_subpict_preset(SISPtr pSiS, SISOverlayPtr pOverlay) -{ - 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); -} - -static void -enable_subpict_overlay(SISPtr pSiS, Bool enable) -{ - setvideoregmask(pSiS, Index_VI_SubPict_Scale_Control, - enable ? 0x40 : 0x00, - 0x40); -} - -/* TW: Set overlay for subpicture */ -static void -set_subpict_overlay(SISPtr pSiS, SISOverlayPtr pOverlay, SISPortPrivPtr pPriv, int index) -{ - ScrnInfoPtr pScrn = pSiS->pScrn; - - 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); */ -} - - -/* TW: 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); - - 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); - - setvideoreg(pSiS,Index_MPEG_Y_UV_Buf_Preset_High, - ((pOverlay->MPEG_Y>>16) & 0x0F) | ((pOverlay->MPEG_UV>>12) & 0xF0)); -} - -static void -set_mpegfield_scale(SISPtr pSiS, SISOverlayPtr pOverlay) +static __inline void +set_disablegfxlr(SISPtr pSiS, Bool mybool, SISOverlayPtr pOverlay) { - /* Empty for now */ + setvideoregmask(pSiS, Index_VI_Control_Misc1, mybool ? 0x01 : 0x00, 0x01); + if(mybool) pOverlay->keyOP = VI_ROP_Always; } -#endif /* ------------------------------------------------------------------- */ +#ifdef SIS_CP + SIS_CP_VIDEO_SUBS +#endif static void -set_overlay(SISPtr pSiS, SISOverlayPtr pOverlay, SISPortPrivPtr pPriv, int index) +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 screenX = pSiS->CurrentLayout.mode->HDisplay; - CARD16 screenY = pSiS->CurrentLayout.mode->VDisplay; + CARD16 screenX, screenY; + int modeflags, watchdog; CARD8 data; - CARD32 watchdog; + CARD32 PSY; + +#ifdef SISMERGED + if(pSiS->MergedFB && iscrt2) { + screenX = pOverlay->currentmode2->HDisplay; + screenY = pOverlay->currentmode2->VDisplay; + modeflags = pOverlay->currentmode2->Flags; + top = pOverlay->dstBox2.y1; + bottom = pOverlay->dstBox2.y2; + left = pOverlay->dstBox2.x1; + right = pOverlay->dstBox2.x2; + pitch = pOverlay->pitch2 >> pPriv->shiftValue; + } else { +#endif + screenX = pOverlay->currentmode->HDisplay; + screenY = pOverlay->currentmode->VDisplay; + modeflags = pOverlay->currentmode->Flags; + top = pOverlay->dstBox.y1; + bottom = pOverlay->dstBox.y2; + left = pOverlay->dstBox.x1; + right = pOverlay->dstBox.x2; + pitch = pOverlay->pitch >> pPriv->shiftValue; +#ifdef SISMERGED + } +#endif - top = pOverlay->dstBox.y1; - bottom = pOverlay->dstBox.y2; - if (bottom > screenY) { + if(bottom > screenY) { bottom = screenY; } - - left = pOverlay->dstBox.x1; - right = pOverlay->dstBox.x2; - if (right > screenX) { + if(right > screenX) { right = screenX; } - /* TW: DoubleScan modes require Y coordinates * 2 */ - if(pSiS->CurrentLayout.mode->Flags & V_DBLSCAN) { + /* DoubleScan modes require Y coordinates * 2 */ + if(modeflags & V_DBLSCAN) { top <<= 1; bottom <<= 1; } - /* TW: Interlace modes require Y coordinates / 2 */ - if(pSiS->CurrentLayout.mode->Flags & V_INTERLACE) { + /* Interlace modes require Y coordinates / 2 */ + if(modeflags & V_INTERLACE) { top >>= 1; bottom >>= 1; } @@ -1488,94 +2806,137 @@ set_overlay(SISPtr pSiS, SISOverlayPtr pOverlay, SISPortPrivPtr pPriv, int index h_over = (((left>>8) & 0x0f) | ((right>>4) & 0xf0)); v_over = (((top>>8) & 0x0f) | ((bottom>>4) & 0xf0)); - pitch = pOverlay->pitch >> pPriv->shiftValue; - /* set line buffer size */ - setvideoreg(pSiS, Index_VI_Line_Buffer_Size, pOverlay->lineBufSize); +#ifdef SISMERGED + if(pSiS->MergedFB && iscrt2) + setvideoreg(pSiS, Index_VI_Line_Buffer_Size, pOverlay->lineBufSize2); + else +#endif + setvideoreg(pSiS, Index_VI_Line_Buffer_Size, pOverlay->lineBufSize); /* set color key mode */ - setvideoregmask (pSiS, Index_VI_Key_Overlay_OP, pOverlay->keyOP, 0x0f); + setvideoregmask(pSiS, Index_VI_Key_Overlay_OP, pOverlay->keyOP, 0x0f); - /* TW: We don't have to wait for vertical retrace in all cases */ + /* We don't have to wait for vertical retrace in all cases */ if(pPriv->mustwait) { + if((pSiS->VGAEngine == SIS_315_VGA) && (index)) { + /* overlay 2 needs special treatment */ + setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); + } watchdog = WATCHDOG_DELAY; - while (pOverlay->VBlankActiveFunc(pSiS) && --watchdog); + while(pOverlay->VBlankActiveFunc(pSiS, pPriv) && --watchdog); watchdog = WATCHDOG_DELAY; - while ((!pOverlay->VBlankActiveFunc(pSiS)) && --watchdog); - if (!watchdog) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + while((!pOverlay->VBlankActiveFunc(pSiS, pPriv)) && --watchdog); + if(!watchdog) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Xv: Waiting for vertical retrace timed-out\n"); } /* Unlock address registers */ data = getvideoreg(pSiS, Index_VI_Control_Misc1); - setvideoreg (pSiS, Index_VI_Control_Misc1, data | 0x20); - /* TEST: Is this required? */ - setvideoreg (pSiS, Index_VI_Control_Misc1, data | 0x20); - /* TEST end */ + setvideoreg(pSiS, Index_VI_Control_Misc1, data | 0x20); + /* Is this required? */ + setvideoreg(pSiS, Index_VI_Control_Misc1, data | 0x20); - /* TEST: Is this required? */ - if (pSiS->Chipset == SIS_315_VGA) - setvideoreg (pSiS, Index_VI_Control_Misc3, 0x00); - /* TEST end */ + /* Is this required? (seems so) */ + if((pSiS->Chipset == SIS_315_VGA) && !index) + setvideoregmask(pSiS, Index_VI_Control_Misc3, 0x00, (1 << index)); /* Set Y buf pitch */ - setvideoreg (pSiS, Index_VI_Disp_Y_Buf_Pitch_Low, (CARD8)(pitch)); - setvideoregmask (pSiS, Index_VI_Disp_Y_UV_Buf_Pitch_Middle, (CARD8)(pitch>>8), 0x0f); + setvideoreg(pSiS, Index_VI_Disp_Y_Buf_Pitch_Low, (CARD8)(pitch)); + setvideoregmask(pSiS, Index_VI_Disp_Y_UV_Buf_Pitch_Middle, (CARD8)(pitch >> 8), 0x0f); /* Set Y start address */ - setvideoreg (pSiS, Index_VI_Disp_Y_Buf_Start_Low, (CARD8)(pOverlay->PSY)); - setvideoreg (pSiS, Index_VI_Disp_Y_Buf_Start_Middle, (CARD8)((pOverlay->PSY)>>8)); - setvideoreg (pSiS, Index_VI_Disp_Y_Buf_Start_High, (CARD8)((pOverlay->PSY)>>16)); - - /* set 310/325 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)((pOverlay->PSY)>>24) & 0x01)); +#ifdef SISMERGED + if(pSiS->MergedFB && iscrt2) { + PSY = pOverlay->PSY2; + } else +#endif + PSY = pOverlay->PSY; + + setvideoreg(pSiS, Index_VI_Disp_Y_Buf_Start_Low, (CARD8)(PSY)); + setvideoreg(pSiS, Index_VI_Disp_Y_Buf_Start_Middle, (CARD8)(PSY >> 8)); + setvideoreg(pSiS, Index_VI_Disp_Y_Buf_Start_High, (CARD8)(PSY >> 16)); + + /* 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)); } - /* Set U/V data if using plane formats */ - if ( (pOverlay->pixelFormat == PIXEL_FMT_YV12) || - (pOverlay->pixelFormat == PIXEL_FMT_I420) ) { + /* 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) ) { - CARD32 PSU=0, PSV=0; + CARD32 PSU=0, PSV=0, uvpitch = pitch; 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; + } /* Set U/V pitch */ - setvideoreg (pSiS, Index_VI_Disp_UV_Buf_Pitch_Low, (CARD8)(pitch >> 1)); - setvideoregmask (pSiS, Index_VI_Disp_Y_UV_Buf_Pitch_Middle, (CARD8)(pitch >> 5), 0xf0); + 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); /* 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_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)); - - /* 310/325 series overflow bits */ - if (pSiS->VGAEngine == SIS_315_VGA) { - setvideoreg (pSiS, Index_VI_Disp_UV_Buf_Pitch_High, (CARD8)(pitch>>13)); - setvideoreg (pSiS, Index_VI_U_Buf_Start_Over, ((CARD8)(PSU>>24) & 0x01)); - setvideoreg (pSiS, Index_VI_V_Buf_Start_Over, ((CARD8)(PSV>>24) & 0x01)); + 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)); + 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)); + } } } - if (pSiS->VGAEngine == SIS_315_VGA) { - /* Trigger register copy for 310 series */ - setvideoreg(pSiS, Index_VI_Control_Misc3, 1 << index); - } - /* set scale factor */ - 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)); +#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)); + + 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)); + + setvideoregmask (pSiS, Index_VI_Scale_Control, (pOverlay->IntBit << 3) + |(pOverlay->wHPre), 0x7f); +#ifdef SISMERGED + } +#endif - setvideoregmask (pSiS, Index_VI_Scale_Control, (pOverlay->IntBit << 3) - |(pOverlay->wHPre), 0x7f); + if((pSiS->VGAEngine == SIS_315_VGA) && (index)){ + /* Trigger register copy for 315/330 series */ + /* setvideoreg(pSiS, Index_VI_Control_Misc3, (1 << index)); */ + setvideoregmask(pSiS, Index_VI_Control_Misc3, (1 << index), (1 << index)); + } /* set destination window position */ setvideoreg(pSiS, Index_VI_Win_Hor_Disp_Start_Low, (CARD8)left); @@ -1592,50 +2953,85 @@ set_overlay(SISPtr pSiS, SISOverlayPtr pOverlay, SISPortPrivPtr pPriv, int index setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x20); } -/* TW: Overlay MUST NOT be switched off while beam is over it */ +/* Overlay MUST NOT be switched off while beam is over it */ static void close_overlay(SISPtr pSiS, SISPortPrivPtr pPriv) { CARD32 watchdog; - if ((pPriv->displayMode == DISPMODE_SINGLE2) || - (pPriv->displayMode == DISPMODE_MIRROR)) { - if (pPriv->hasTwoOverlays) { - setvideoregmask (pSiS, Index_VI_Control_Misc2, 0x01, 0x01); - watchdog = WATCHDOG_DELAY; - while(vblank_active_CRT2(pSiS) && --watchdog); - watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT2(pSiS)) && --watchdog); - setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); - watchdog = WATCHDOG_DELAY; - while(vblank_active_CRT2(pSiS) && --watchdog); - watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT2(pSiS)) && --watchdog); - } else if (pPriv->displayMode == DISPMODE_SINGLE2) { - setvideoregmask (pSiS, Index_VI_Control_Misc2, 0x00, 0x01); - watchdog = WATCHDOG_DELAY; - while(vblank_active_CRT1(pSiS) && --watchdog); - watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT1(pSiS)) && --watchdog); - setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); - watchdog = WATCHDOG_DELAY; - while(vblank_active_CRT1(pSiS) && --watchdog); - watchdog = WATCHDOG_DELAY; - while((!vblank_active_CRT1(pSiS)) && --watchdog); + if(!(pPriv->overlayStatus)) return; + pPriv->overlayStatus = FALSE; + + if(pPriv->displayMode & (DISPMODE_MIRROR | DISPMODE_SINGLE2)) { + + /* CRT2: MIRROR or SINGLE2 + * 1 overlay: Uses overlay 0 + * 2 overlays: Uses Overlay 1 if MIRROR or DUAL HEAD + * Uses Overlay 0 if SINGLE2 and not DUAL HEAD + */ + + if(pPriv->hasTwoOverlays) { + + if((pPriv->dualHeadMode) || (pPriv->displayMode == DISPMODE_MIRROR)) { + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, 0x01); + } else { + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0x01); + } + + } else if(pPriv->displayMode == DISPMODE_SINGLE2) { + +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) { + /* Check if overlay already grabbed by other head */ + if(!(getsrreg(pSiS, 0x06) & 0x40)) return; + } +#endif + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0x01); + } + + setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x01); + watchdog = WATCHDOG_DELAY; + while(vblank_active_CRT2(pSiS, pPriv) && --watchdog); + watchdog = WATCHDOG_DELAY; + while((!vblank_active_CRT2(pSiS, pPriv)) && --watchdog); + setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); + watchdog = WATCHDOG_DELAY; + while(vblank_active_CRT2(pSiS, pPriv) && --watchdog); + watchdog = WATCHDOG_DELAY; + while((!vblank_active_CRT2(pSiS, pPriv)) && --watchdog); + +#ifdef SIS_CP + SIS_CP_RESET_CP +#endif + } - if ((pPriv->displayMode == DISPMODE_SINGLE1) || - (pPriv->displayMode == DISPMODE_MIRROR)) { - setvideoregmask (pSiS, Index_VI_Control_Misc2, 0x00, 0x01); + + if(pPriv->displayMode & (DISPMODE_SINGLE1 | DISPMODE_MIRROR)) { + + /* CRT1: Always uses overlay 0 + */ + +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) { + if(!pPriv->hasTwoOverlays) { + /* Check if overlay already grabbed by other head */ + if(getsrreg(pSiS, 0x06) & 0x40) return; + } + } +#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); + } } @@ -1643,140 +3039,494 @@ static void SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) { SISPtr pSiS = SISPTR(pScrn); - +#ifdef SISDUALHEAD + SISEntPtr pSiSEnt = pSiS->entityPrivate; +#endif short srcPitch = pPriv->srcPitch; short height = pPriv->height; + unsigned short screenwidth; SISOverlayRec overlay; int srcOffsetX=0, srcOffsetY=0; - int sx, sy; + int sx=0, sy=0; int index = 0, iscrt2 = 0; +#ifdef SISMERGED + unsigned char temp; + unsigned short screen2width=0; + int srcOffsetX2=0, srcOffsetY2=0; + int sx2=0, sy2=0, watchdog; +#endif + + pPriv->NoOverlay = FALSE; +#ifdef SISDUALHEAD + if(pPriv->dualHeadMode) { + if(!pPriv->hasTwoOverlays) { + if(pSiS->SecondHead) { + if(pSiSEnt->curxvcrtnum != 0) { + if(pPriv->overlayStatus) { + close_overlay(pSiS, pPriv); + } + pPriv->NoOverlay = TRUE; + return; + } + } else { + if(pSiSEnt->curxvcrtnum != 1) { + if(pPriv->overlayStatus) { + close_overlay(pSiS, pPriv); + } + pPriv->NoOverlay = TRUE; + return; + } + } + } + } +#endif + + /* setup dispmode (MIRROR, SINGLEx) */ + set_dispmode(pScrn, pPriv); + + /* Check if overlay is supported with current mode */ +#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)); + overlay.pixelFormat = pPriv->id; overlay.pitch = overlay.origPitch = srcPitch; - overlay.keyOP = 0x03; /* DestKey mode */ + if(pPriv->usechromakey) { + overlay.keyOP = (pPriv->insidechromakey) ? VI_ROP_ChromaKey : VI_ROP_NotChromaKey; + } else { + overlay.keyOP = VI_ROP_DestKey; + } /* overlay.bobEnable = 0x02; */ - overlay.bobEnable = 0x00; /* Disable BOB (whatever that is) */ + overlay.bobEnable = 0x00; /* Disable BOB de-interlacer */ + +#ifdef SISMERGED + if(pSiS->MergedFB) { + overlay.DoFirst = TRUE; + overlay.DoSecond = TRUE; + overlay.pitch2 = overlay.origPitch; + overlay.currentmode = ((SiSMergedDisplayModePtr)pSiS->CurrentLayout.mode->Private)->CRT1; + overlay.currentmode2 = ((SiSMergedDisplayModePtr)pSiS->CurrentLayout.mode->Private)->CRT2; + overlay.SCREENheight = overlay.currentmode->VDisplay; + overlay.SCREENheight2 = overlay.currentmode2->VDisplay; + screenwidth = overlay.currentmode->HDisplay; + screen2width = overlay.currentmode2->HDisplay; + overlay.dstBox.x1 = pPriv->drw_x - pSiS->CRT1frameX0; + overlay.dstBox.x2 = overlay.dstBox.x1 + pPriv->drw_w; + overlay.dstBox.y1 = pPriv->drw_y - pSiS->CRT1frameY0; + overlay.dstBox.y2 = overlay.dstBox.y1 + pPriv->drw_h; + overlay.dstBox2.x1 = pPriv->drw_x - pSiS->CRT2pScrn->frameX0; + overlay.dstBox2.x2 = overlay.dstBox2.x1 + pPriv->drw_w; + overlay.dstBox2.y1 = pPriv->drw_y - pSiS->CRT2pScrn->frameY0; + overlay.dstBox2.y2 = overlay.dstBox2.y1 + pPriv->drw_h; + /* xf86DrvMsg(0, X_INFO, "DV(1): %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); */ + } else { +#endif + overlay.currentmode = pSiS->CurrentLayout.mode; + overlay.SCREENheight = overlay.currentmode->VDisplay; + screenwidth = overlay.currentmode->HDisplay; + overlay.dstBox.x1 = pPriv->drw_x - pScrn->frameX0; + 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 - overlay.SCREENheight = pSiS->CurrentLayout.mode->VDisplay; - - overlay.dstBox.x1 = pPriv->drw_x - pScrn->frameX0; - 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; + /* Note: x2/y2 is actually real coordinate + 1 */ - if((overlay.dstBox.x1 > overlay.dstBox.x2) || - (overlay.dstBox.y1 > overlay.dstBox.y2)) - return; + if((overlay.dstBox.x1 >= overlay.dstBox.x2) || + (overlay.dstBox.y1 >= overlay.dstBox.y2)) { +#ifdef SISMERGED + if(pSiS->MergedFB) overlay.DoFirst = FALSE; + else +#endif + return; + } - if((overlay.dstBox.x2 < 0) || (overlay.dstBox.y2 < 0)) - return; + if((overlay.dstBox.x2 <= 0) || (overlay.dstBox.y2 <= 0)) { +#ifdef SISMERGED + if(pSiS->MergedFB) overlay.DoFirst = FALSE; + else +#endif + return; + } + + if((overlay.dstBox.x1 >= screenwidth) || (overlay.dstBox.y1 >= overlay.SCREENheight)) { +#ifdef SISMERGED + if(pSiS->MergedFB) overlay.DoFirst = FALSE; + else +#endif + 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; + srcOffsetX = pPriv->src_w * (-overlay.dstBox.x1) / pPriv->drw_w; + overlay.dstBox.x1 = 0; } if(overlay.dstBox.y1 < 0) { - srcOffsetY = pPriv->src_h * (-overlay.dstBox.y1) / pPriv->drw_h; - overlay.dstBox.y1 = 0; + srcOffsetY = pPriv->src_h * (-overlay.dstBox.y1) / pPriv->drw_h; + overlay.dstBox.y1 = 0; } - switch(pPriv->id){ +#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)) + overlay.DoSecond = FALSE; + + if((overlay.dstBox2.x1 >= screen2width) || (overlay.dstBox2.y1 >= overlay.SCREENheight2)) + overlay.DoSecond = FALSE; + + if(overlay.dstBox2.x1 < 0) { + 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 neither overlay is to be displayed, disable them if they are currently enabled */ + if((!overlay.DoFirst) && (!overlay.DoSecond)) { + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0x05); + setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x01); + temp = getvideoreg(pSiS,Index_VI_Control_Misc0); + if(temp & 0x02) { + watchdog = WATCHDOG_DELAY; + if(pPriv->hasTwoOverlays) { + while(vblank_active_CRT1(pSiS, pPriv) && --watchdog); + watchdog = WATCHDOG_DELAY; + while((!vblank_active_CRT1(pSiS, pPriv)) && --watchdog); + } else { + temp = getsrreg(pSiS, 0x06); + if(!(temp & 0x40)) { + while(vblank_active_CRT1(pSiS, pPriv) && --watchdog); + watchdog = WATCHDOG_DELAY; + while((!vblank_active_CRT1(pSiS, pPriv)) && --watchdog); + } else { + while(vblank_active_CRT2(pSiS, pPriv) && --watchdog); + watchdog = WATCHDOG_DELAY; + while((!vblank_active_CRT2(pSiS, pPriv)) && --watchdog); + } + } + setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); + } + if(pPriv->hasTwoOverlays) { + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, 0x01); + setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x01); + temp = getvideoreg(pSiS,Index_VI_Control_Misc0); + if(temp & 0x02) { + watchdog = WATCHDOG_DELAY; + while(vblank_active_CRT2(pSiS, pPriv) && --watchdog); + watchdog = WATCHDOG_DELAY; + while((!vblank_active_CRT2(pSiS, pPriv)) && --watchdog); + setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); + } + } + pPriv->overlayStatus = FALSE; + return; + } + } +#endif + + switch(pPriv->id) { + case PIXEL_FMT_YV12: - sx = (pPriv->src_x + srcOffsetX) & ~7; - sy = (pPriv->src_y + srcOffsetY) & ~1; - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; - overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); - overlay.PSU = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch*5/4 + ((sx + sy*srcPitch/2) >> 1); +#ifdef SISMERGED + if((!pSiS->MergedFB) || (overlay.DoFirst)) { +#endif + sx = (pPriv->src_x + srcOffsetX) & ~7; + sy = (pPriv->src_y + srcOffsetY) & ~1; + overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; + overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); + overlay.PSU = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch*5/4 + ((sx + sy*srcPitch/2) >> 1); #ifdef SISDUALHEAD - overlay.PSY += HEADOFFSET; - overlay.PSV += HEADOFFSET; - overlay.PSU += HEADOFFSET; + overlay.PSY += HEADOFFSET; + overlay.PSV += HEADOFFSET; + overlay.PSU += HEADOFFSET; +#endif + overlay.PSY >>= pPriv->shiftValue; + overlay.PSV >>= pPriv->shiftValue; + overlay.PSU >>= pPriv->shiftValue; +#ifdef SISMERGED + } + if((pSiS->MergedFB) && (overlay.DoSecond)) { + sx2 = (pPriv->src_x + srcOffsetX2) & ~7; + sy2 = (pPriv->src_y + srcOffsetY2) & ~1; + overlay.PSY2 = pPriv->bufAddr[pPriv->currentBuf] + sx2 + sy2*srcPitch; + overlay.PSV2 = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx2 + sy2*srcPitch/2) >> 1); + overlay.PSU2 = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch*5/4 + ((sx2 + sy2*srcPitch/2) >> 1); + overlay.PSY2 >>= pPriv->shiftValue; + overlay.PSV2 >>= pPriv->shiftValue; + overlay.PSU2 >>= pPriv->shiftValue; + } #endif - overlay.PSY >>= pPriv->shiftValue; - overlay.PSV >>= pPriv->shiftValue; - overlay.PSU >>= pPriv->shiftValue; break; + case PIXEL_FMT_I420: - sx = (pPriv->src_x + srcOffsetX) & ~7; - sy = (pPriv->src_y + srcOffsetY) & ~1; - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; - overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch*5/4 + ((sx + sy*srcPitch/2) >> 1); - overlay.PSU = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); +#ifdef SISMERGED + if((!pSiS->MergedFB) || (overlay.DoFirst)) { +#endif + sx = (pPriv->src_x + srcOffsetX) & ~7; + sy = (pPriv->src_y + srcOffsetY) & ~1; + overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; + overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch*5/4 + ((sx + sy*srcPitch/2) >> 1); + overlay.PSU = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); #ifdef SISDUALHEAD - overlay.PSY += HEADOFFSET; - overlay.PSV += HEADOFFSET; - overlay.PSU += HEADOFFSET; + overlay.PSY += HEADOFFSET; + overlay.PSV += HEADOFFSET; + overlay.PSU += HEADOFFSET; +#endif + overlay.PSY >>= pPriv->shiftValue; + overlay.PSV >>= pPriv->shiftValue; + overlay.PSU >>= pPriv->shiftValue; +#ifdef SISMERGED + } + if((pSiS->MergedFB) && (overlay.DoSecond)) { + sx2 = (pPriv->src_x + srcOffsetX2) & ~7; + sy2 = (pPriv->src_y + srcOffsetY2) & ~1; + overlay.PSY2 = pPriv->bufAddr[pPriv->currentBuf] + sx2 + sy2*srcPitch; + overlay.PSV2 = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch*5/4 + ((sx2 + sy2*srcPitch/2) >> 1); + overlay.PSU2 = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx2 + sy2*srcPitch/2) >> 1); + overlay.PSY2 >>= pPriv->shiftValue; + overlay.PSV2 >>= pPriv->shiftValue; + overlay.PSU2 >>= pPriv->shiftValue; + } #endif - overlay.PSY >>= pPriv->shiftValue; - overlay.PSV >>= pPriv->shiftValue; - overlay.PSU >>= pPriv->shiftValue; break; + + case PIXEL_FMT_NV12: + case PIXEL_FMT_NV21: +#ifdef SISMERGED + if((!pSiS->MergedFB) || (overlay.DoFirst)) { +#endif + sx = (pPriv->src_x + srcOffsetX) & ~7; + sy = (pPriv->src_y + srcOffsetY) & ~1; + overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; + overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); +#ifdef SISDUALHEAD + overlay.PSY += HEADOFFSET; + overlay.PSV += HEADOFFSET; +#endif + overlay.PSY >>= pPriv->shiftValue; + overlay.PSV >>= pPriv->shiftValue; + overlay.PSU = overlay.PSV; +#ifdef SISMERGED + } + if((pSiS->MergedFB) && (overlay.DoSecond)) { + sx2 = (pPriv->src_x + srcOffsetX2) & ~7; + sy2 = (pPriv->src_y + srcOffsetY2) & ~1; + overlay.PSY2 = pPriv->bufAddr[pPriv->currentBuf] + sx2 + sy2*srcPitch; + overlay.PSV2 = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx2 + sy2*srcPitch/2) >> 1); + overlay.PSY2 >>= pPriv->shiftValue; + overlay.PSV2 >>= pPriv->shiftValue; + overlay.PSU2 = overlay.PSV2; + } +#endif + break; + case PIXEL_FMT_YUY2: case PIXEL_FMT_UYVY: + case PIXEL_FMT_YVYU: case PIXEL_FMT_RGB6: case PIXEL_FMT_RGB5: default: - sx = (pPriv->src_x + srcOffsetX) & ~1; - sy = (pPriv->src_y + srcOffsetY); - overlay.PSY = (pPriv->bufAddr[pPriv->currentBuf] + sx*2 + sy*srcPitch); +#ifdef SISMERGED + if((!pSiS->MergedFB) || (overlay.DoFirst)) { +#endif + sx = (pPriv->src_x + srcOffsetX) & ~1; + sy = (pPriv->src_y + srcOffsetY); + overlay.PSY = (pPriv->bufAddr[pPriv->currentBuf] + sx*2 + sy*srcPitch); #ifdef SISDUALHEAD - overlay.PSY += HEADOFFSET; + overlay.PSY += HEADOFFSET; +#endif + overlay.PSY >>= pPriv->shiftValue; +#ifdef SISMERGED + } + if((pSiS->MergedFB) && (overlay.DoSecond)) { + sx2 = (pPriv->src_x + srcOffsetX2) & ~1; + sy2 = (pPriv->src_y + srcOffsetY2); + overlay.PSY2 = (pPriv->bufAddr[pPriv->currentBuf] + sx2*2 + sy2*srcPitch); + overlay.PSY2 >>= pPriv->shiftValue; + } #endif - overlay.PSY >>= pPriv->shiftValue; - break; + break; } - /* FIXME: is it possible that srcW < 0 */ - overlay.srcW = pPriv->src_w - (sx - pPriv->src_x); - overlay.srcH = pPriv->src_h - (sy - pPriv->src_y); - - if ( (pPriv->oldx1 != overlay.dstBox.x1) || - (pPriv->oldx2 != overlay.dstBox.x2) || - (pPriv->oldy1 != overlay.dstBox.y1) || - (pPriv->oldy2 != overlay.dstBox.y2) ) { - pPriv->mustwait = 1; - pPriv->oldx1 = overlay.dstBox.x1; pPriv->oldx2 = overlay.dstBox.x2; - pPriv->oldy1 = overlay.dstBox.y1; pPriv->oldy2 = overlay.dstBox.y2; + /* Some clipping checks */ +#ifdef SISMERGED + if((!pSiS->MergedFB) || (overlay.DoFirst)) { +#endif + overlay.srcW = pPriv->src_w - (sx - pPriv->src_x); + overlay.srcH = pPriv->src_h - (sy - pPriv->src_y); + if( (pPriv->oldx1 != overlay.dstBox.x1) || + (pPriv->oldx2 != overlay.dstBox.x2) || + (pPriv->oldy1 != overlay.dstBox.y1) || + (pPriv->oldy2 != overlay.dstBox.y2) ) { + pPriv->mustwait = 1; + pPriv->oldx1 = overlay.dstBox.x1; pPriv->oldx2 = overlay.dstBox.x2; + pPriv->oldy1 = overlay.dstBox.y1; pPriv->oldy2 = overlay.dstBox.y2; + } +#ifdef SISMERGED } + if((pSiS->MergedFB) && (overlay.DoSecond)) { + overlay.srcW2 = pPriv->src_w - (sx2 - pPriv->src_x); + overlay.srcH2 = pPriv->src_h - (sy2 - pPriv->src_y); + if( (pPriv->oldx1_2 != overlay.dstBox2.x1) || + (pPriv->oldx2_2 != overlay.dstBox2.x2) || + (pPriv->oldy1_2 != overlay.dstBox2.y1) || + (pPriv->oldy2_2 != overlay.dstBox2.y2) ) { + pPriv->mustwait = 1; + pPriv->oldx1_2 = overlay.dstBox2.x1; pPriv->oldx2_2 = overlay.dstBox2.x2; + pPriv->oldy1_2 = overlay.dstBox2.y1; pPriv->oldy2_2 = overlay.dstBox2.y2; + } + } +#endif - /* TW: setup dispmode (MIRROR, SINGLEx) */ - set_dispmode(pScrn, pPriv); +#ifdef SISMERGED + /* Disable an overlay if it is not to be displayed (but enabled currently) */ + if((pSiS->MergedFB) && (pPriv->hasTwoOverlays)) { + if(!overlay.DoFirst) { + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x00, 0x05); + setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x01); + temp = getvideoreg(pSiS,Index_VI_Control_Misc0); + if(temp & 0x02) { + watchdog = WATCHDOG_DELAY; + while(vblank_active_CRT1(pSiS, pPriv) && --watchdog); + watchdog = WATCHDOG_DELAY; + while((!vblank_active_CRT1(pSiS, pPriv)) && --watchdog); + setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); + } + } else if(!overlay.DoSecond) { + setvideoregmask(pSiS, Index_VI_Control_Misc2, 0x01, 0x01); + setvideoregmask(pSiS, Index_VI_Control_Misc1, 0x00, 0x01); + temp = getvideoreg(pSiS,Index_VI_Control_Misc0); + if(temp & 0x02) { + watchdog = WATCHDOG_DELAY; + while(vblank_active_CRT2(pSiS, pPriv) && --watchdog); + watchdog = WATCHDOG_DELAY; + while((!vblank_active_CRT2(pSiS, pPriv)) && --watchdog); + setvideoregmask(pSiS, Index_VI_Control_Misc0, 0x00, 0x02); + } + } + } +#endif + + /* Loop head */ + if(pPriv->displayMode & DISPMODE_SINGLE2) { + if(pPriv->hasTwoOverlays) { /* We have 2 overlays: */ + if(pPriv->dualHeadMode) { + /* Dual head: We use overlay 2 for CRT2 */ + index = 1; iscrt2 = 1; + } else { + /* Single head: We use overlay 1 for CRT2 */ + index = 0; iscrt2 = 1; + } + } else { /* We have 1 overlay */ + /* We use that only overlay for CRT2 */ + index = 0; iscrt2 = 1; + } + overlay.VBlankActiveFunc = vblank_active_CRT2; +#ifdef SISMERGED + if(!pPriv->hasTwoOverlays) { + if((pSiS->MergedFB) && (!overlay.DoSecond)) { + index = 0; iscrt2 = 0; + overlay.VBlankActiveFunc = vblank_active_CRT1; + pPriv->displayMode = DISPMODE_SINGLE1; + } + } +#endif + } else { + index = 0; iscrt2 = 0; + overlay.VBlankActiveFunc = vblank_active_CRT1; +#ifdef SISMERGED + if((pSiS->MergedFB) && (!overlay.DoFirst)) { + if(pPriv->hasTwoOverlays) index = 1; + iscrt2 = 1; + overlay.VBlankActiveFunc = vblank_active_CRT2; + if(!pPriv->hasTwoOverlays) { + pPriv->displayMode = DISPMODE_SINGLE2; + } + } +#endif + } - /* TW: set display mode SR06,32 (CRT1, CRT2 or mirror) */ + /* set display mode SR06,32 (CRT1, CRT2 or mirror) */ set_disptype_regs(pScrn, pPriv); /* set (not only calc) merge line buffer */ - merge_line_buf(pSiS, pPriv, (overlay.srcW > 384)); - - /* calculate (not set!) line buffer length */ - set_line_buf_size(&overlay); - - if (pPriv->displayMode == DISPMODE_SINGLE2) { - if (pPriv->hasTwoOverlays) { - /* TW: On chips with two overlays we use - * overlay 2 for CRT2 */ - index = 1; iscrt2 = 1; - } else { - /* TW: On chips with only one overlay we - * use that only overlay for CRT2 */ - index = 0; iscrt2 = 1; - } - overlay.VBlankActiveFunc = vblank_active_CRT2; - /* overlay.GetScanLineFunc = get_scanline_CRT2; */ +#ifdef SISMERGED + if(!pSiS->MergedFB) { +#endif + merge_line_buf(pSiS, pPriv, (overlay.srcW > pPriv->linebufMergeLimit), overlay.srcW, + pPriv->linebufMergeLimit); +#ifdef SISMERGED } else { - index = 0; iscrt2 = 0; - overlay.VBlankActiveFunc = vblank_active_CRT1; - /* overlay.GetScanLineFunc = get_scanline_CRT1; */ + Bool temp1 = FALSE, temp2 = FALSE; + if(overlay.DoFirst) { + if(overlay.srcW > pPriv->linebufMergeLimit) temp1 = TRUE; + } + if(overlay.DoSecond) { + if(overlay.srcW2 > pPriv->linebufMergeLimit) temp2 = TRUE; + } + merge_line_buf_mfb(pSiS, pPriv, temp1, temp2, overlay.srcW, overlay.srcW2, pPriv->linebufMergeLimit); } +#endif - /* TW: Do the following in a loop for CRT1 and CRT2 ----------------- */ + /* calculate (not set!) line buffer length */ +#ifdef SISMERGED + if((!pSiS->MergedFB) || (overlay.DoFirst)) +#endif + set_line_buf_size_1(&overlay); +#ifdef SISMERGED + if((pSiS->MergedFB) && (overlay.DoSecond)) + set_line_buf_size_2(&overlay); +#endif + + /* Do the following in a loop for CRT1 and CRT2 ----------------- */ MIRROR: /* calculate (not set!) scale factor */ - calc_scale_factor(&overlay, pScrn, pPriv, index, iscrt2); +#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 video2 (used for CRT2) */ + /* Select overlay 1 (used for CRT1/or CRT2) or overlay 2 (used for CRT2) */ setvideoregmask(pSiS, Index_VI_Control_Misc2, index, 0x01); /* set format */ @@ -1785,29 +3535,90 @@ MIRROR: /* set color key */ set_colorkey(pSiS, pPriv->colorKey); - /* set brightness, contrast, hue and saturation */ + if(pPriv->usechromakey) { + /* Select chroma key format (300 series only) */ + if(pSiS->VGAEngine == SIS_300_VGA) { + setvideoregmask(pSiS, Index_VI_Control_Misc0, + (pPriv->yuvchromakey ? 0x40 : 0x00), 0x40); + } + set_chromakey(pSiS, pPriv->chromamin, pPriv->chromamax); + } + + /* set brightness, contrast, hue, saturation */ set_brightness(pSiS, pPriv->brightness); set_contrast(pSiS, pPriv->contrast); - if (pSiS->VGAEngine == SIS_315_VGA) { - set_hue(pSiS, pPriv->hue); - set_saturation(pSiS, pPriv->saturation); + if(pSiS->VGAEngine == SIS_315_VGA) { + set_hue(pSiS, pPriv->hue); + 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; + } } - /* set overlay */ - set_overlay(pSiS, &overlay, pPriv, index); + /* 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); + } + set_disablegfxlr(pSiS, pPriv->disablegfxlr, &overlay); + +#ifdef SIS_CP + SIS_CP_VIDEO_SET_CP +#endif + + /* set overlay parameters */ + set_overlay(pSiS, &overlay, pPriv, index, iscrt2); + + if((pSiS->VGAEngine == SIS_315_VGA) && !index) { + /* 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); - if(index == 0 && - pPriv->displayMode == DISPMODE_MIRROR && + /* loop foot */ + if(pPriv->displayMode & DISPMODE_MIRROR && + index == 0 && pPriv->hasTwoOverlays) { - index = 1; iscrt2 = 1; - overlay.VBlankActiveFunc = vblank_active_CRT2; - /* overlay.GetScanLineFunc = get_scanline_CRT2; */ - goto MIRROR; +#ifdef SISMERGED + if((!pSiS->MergedFB) || overlay.DoSecond) { +#endif + index = 1; iscrt2 = 1; + overlay.VBlankActiveFunc = vblank_active_CRT2; + goto MIRROR; +#ifdef SISMERGED + } +#endif } + pPriv->mustwait = 0; + pPriv->overlayStatus = TRUE; } static FBLinearPtr @@ -1846,7 +3657,7 @@ SISAllocateOverlayMemory( new_linear = xf86AllocateOffscreenLinear(pScreen, size, 8, NULL, NULL, NULL); } - if (!new_linear) + if(!new_linear) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Xv: Failed to allocate %dK of video memory\n", size/1024); #ifdef TWDEBUG @@ -1875,24 +3686,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; + pPriv->videoStatus = OFF_TIMER | CLIENT_VIDEO_ON; + pPriv->offTime = currentTime.milliseconds + OFF_DELAY; + pSiS->VideoTimerCallback = SISVideoTimerCallback; } } } @@ -1914,9 +3724,15 @@ SISPutImage( int totalSize=0; int depth = pSiS->CurrentLayout.bitsPerPixel >> 3; + int myreds[] = { 0x000000ff, 0x0000f800, 0, 0x00ff0000 }; + +#if 0 + if(id == SDC_ID) { + return(SiSHandleSiSDirectCommand(pScrn, pPriv, (sisdirectcommand *)buf)); + } +#endif - if(pPriv->grabbedByV4L) - return Success; + if(pPriv->grabbedByV4L) return Success; pPriv->drw_x = drw_x; pPriv->drw_y = drw_y; @@ -1929,7 +3745,7 @@ SISPutImage( pPriv->id = id; pPriv->height = height; - /* 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) @@ -1951,17 +3767,22 @@ SISPutImage( 3. I420: Like YU12, but planes U and V are in reverse order. 4. YUY2: Like UYVY, but order is Y0 U0 Y1 V0 Y2 U2 Y3 V2 ... + 5. YVYU: Like YUY2, but order is + Y0 V0 Y1 U0 Y2 V2 Y3 U2 ... */ switch(id){ case PIXEL_FMT_YV12: case PIXEL_FMT_I420: + case PIXEL_FMT_NV12: + case PIXEL_FMT_NV21: pPriv->srcPitch = (width + 7) & ~7; /* Size = width * height * 3 / 2 */ totalSize = (pPriv->srcPitch * height * 3) >> 1; /* Verified */ break; case PIXEL_FMT_YUY2: case PIXEL_FMT_UYVY: + case PIXEL_FMT_YVYU: case PIXEL_FMT_RGB6: case PIXEL_FMT_RGB5: default: @@ -1970,6 +3791,10 @@ SISPutImage( totalSize = pPriv->srcPitch * height; } + /* make it a multiple of 16 to simplify to copy loop */ + totalSize += 15; + totalSize &= ~15; + /* allocate memory (we do doublebuffering) */ if(!(pPriv->linear = SISAllocateOverlayMemory(pScrn, pPriv->linear, totalSize<<1))) @@ -1980,22 +3805,54 @@ SISPutImage( pPriv->bufAddr[1] = pPriv->bufAddr[0] + totalSize; /* copy data */ - /* TODO: subimage */ - memcpy(pSiS->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); + if((pSiS->XvUseMemcpy) || (totalSize < 16)) { + memcpy(pSiS->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); + } else { + unsigned long i; + CARD32 *src = (CARD32 *)buf; + CARD32 *dest = (CARD32 *)(pSiS->FbBase + pPriv->bufAddr[pPriv->currentBuf]); + for(i = 0; i < (totalSize/16); i++) { + *dest++ = *src++; + *dest++ = *src++; + *dest++ = *src++; + *dest++ = *src++; + } + } SISDisplayVideo(pScrn, pPriv); /* update cliplist */ if(pPriv->autopaintColorKey && - (pPriv->grabbedByV4L || !RegionsEqual(&pPriv->clip, clipBoxes))) { - /* We always paint colorkey for V4L */ - if (!pPriv->grabbedByV4L) - REGION_COPY(pScreen, &pPriv->clip, clipBoxes); + (pPriv->grabbedByV4L || +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,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) { + REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); + } /* draw these */ - /* xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - for X4.2 */ - XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, - REGION_NUM_RECTS(clipBoxes), - REGION_RECTS(clipBoxes)); + pPriv->PrevOverlay = pPriv->NoOverlay; + if((pPriv->NoOverlay) && (!pSiS->NoAccel)) { + XAAFillMono8x8PatternRects(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,2,99,0,0) + XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); +#else + xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); +#endif + } + } + } pPriv->currentBuf ^= 1; @@ -2016,18 +3873,12 @@ SISQueryImageAttributes( ){ int pitchY, pitchUV; int size, sizeY, sizeUV; - SISPtr pSiS = SISPTR(pScrn); if(*w < IMAGE_MIN_WIDTH) *w = IMAGE_MIN_WIDTH; if(*h < IMAGE_MIN_HEIGHT) *h = IMAGE_MIN_HEIGHT; - if(pSiS->Flags650 & SiS650_LARGEOVERLAY) { - if(*w > IMAGE_MAX_WIDTH_M650) *w = IMAGE_MAX_WIDTH_M650; - if(*h > IMAGE_MAX_HEIGHT_M650) *h = IMAGE_MAX_HEIGHT_M650; - } else { - if(*w > IMAGE_MAX_WIDTH) *w = IMAGE_MAX_WIDTH; - if(*h > IMAGE_MAX_HEIGHT) *h = IMAGE_MAX_HEIGHT; - } + if(*w > DummyEncoding.width) *w = DummyEncoding.width; + if(*h > DummyEncoding.height) *h = DummyEncoding.height; switch(id) { case PIXEL_FMT_YV12: @@ -2049,8 +3900,27 @@ SISQueryImageAttributes( } size = sizeY + (sizeUV << 1); break; + case PIXEL_FMT_NV12: + case PIXEL_FMT_NV21: + *w = (*w + 7) & ~7; + *h = (*h + 1) & ~1; + 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: case PIXEL_FMT_RGB6: case PIXEL_FMT_RGB5: default: @@ -2066,7 +3936,7 @@ SISQueryImageAttributes( } static void -SISVideoTimerCallback (ScrnInfoPtr pScrn, Time now) +SISVideoTimerCallback(ScrnInfoPtr pScrn, Time now) { SISPtr pSiS = SISPTR(pScrn); SISPortPrivPtr pPriv = NULL; @@ -2076,38 +3946,37 @@ SISVideoTimerCallback (ScrnInfoPtr pScrn, Time now) if(!pScrn->vtSema) return; - if (pSiS->adaptor) { - pPriv = GET_PORT_PRIVATE(pScrn); - if(!pPriv->videoStatus) - pPriv = NULL; + 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; + 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 - if(pPriv->videoStatus & FREE_TIMER) { - SISFreeOverlayMemory(pScrn); - pPriv->mustwait = 1; - pPriv->videoStatus = 0; - } - } else - pSiS->VideoTimerCallback = SISVideoTimerCallback; - } - } + pSiS->VideoTimerCallback = SISVideoTimerCallback; + } + } } -/* TW: Offscreen surface stuff */ +/* Offscreen surface stuff */ static int SISAllocSurface ( @@ -2128,13 +3997,8 @@ SISAllocSurface ( if((w < IMAGE_MIN_WIDTH) || (h < IMAGE_MIN_HEIGHT)) return BadValue; - if(pSiS->Flags650 & SiS650_LARGEOVERLAY) { - if((w > IMAGE_MAX_WIDTH_M650) || (h > IMAGE_MAX_HEIGHT_M650)) - return BadValue; - } else { - if((w > IMAGE_MAX_WIDTH) || (h > IMAGE_MAX_HEIGHT)) + if((w > DummyEncoding.width) || (h > DummyEncoding.height)) return BadValue; - } if(pPriv->grabbedByV4L) return BadAlloc; @@ -2172,9 +4036,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; } @@ -2185,9 +4049,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; } @@ -2227,14 +4091,15 @@ SISDisplaySurface ( ) { ScrnInfoPtr pScrn = surface->pScrn; + SISPtr pSiS = SISPTR(pScrn); SISPortPrivPtr pPriv = (SISPortPrivPtr)(surface->devPrivate.ptr); + int myreds[] = { 0x000000ff, 0x0000f800, 0, 0x00ff0000 }; #ifdef TWDEBUG 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; @@ -2253,9 +4118,23 @@ SISDisplaySurface ( SISDisplayVideo(pScrn, pPriv); if(pPriv->autopaintColorKey) { - XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, - REGION_NUM_RECTS(clipBoxes), - REGION_RECTS(clipBoxes)); + if((pPriv->NoOverlay) && (!(pSiS->NoAccel))) { + XAAFillMono8x8PatternRects(pScrn, + myreds[(pSiS->CurrentLayout.bitsPerPixel >> 3) - 1], + 0x000000, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes), + 0x00422418, 0x18244200, 0, 0); + + } else { +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) + XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); +#else + xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); +#endif + } } pPriv->videoStatus = CLIENT_VIDEO_ON; @@ -2263,66 +4142,10 @@ SISDisplaySurface ( return Success; } -#define NUMOFFSCRIMAGES 4 - -static XF86OffscreenImageRec SISOffscreenImages_300[NUMOFFSCRIMAGES] = -{ - { - &SISImages[0], /* YUV2 */ - VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT, - SISAllocSurface, - SISFreeSurface, - SISDisplaySurface, - SISStopSurface, - SISGetSurfaceAttribute, - SISSetSurfaceAttribute, - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - NUM_ATTRIBUTES_300, - &SISAttributes_300[0] /* Support all attributes */ - }, - { - &SISImages[2], /* UYVY */ - VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT, - SISAllocSurface, - SISFreeSurface, - SISDisplaySurface, - SISStopSurface, - SISGetSurfaceAttribute, - SISSetSurfaceAttribute, - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - NUM_ATTRIBUTES_300, - &SISAttributes_300[0] /* Support all attributes */ - } - , - { - &SISImages[4], /* RV15 */ - VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT, - SISAllocSurface, - SISFreeSurface, - SISDisplaySurface, - SISStopSurface, - SISGetSurfaceAttribute, - SISSetSurfaceAttribute, - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - NUM_ATTRIBUTES_300, - &SISAttributes_300[0] /* Support all attributes */ - }, - { - &SISImages[5], /* RV16 */ - VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT, - SISAllocSurface, - SISFreeSurface, - SISDisplaySurface, - SISStopSurface, - SISGetSurfaceAttribute, - SISSetSurfaceAttribute, - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - NUM_ATTRIBUTES_300, - &SISAttributes_300[0] /* Support all attributes */ - } -}; +#define NUMOFFSCRIMAGES_300 4 +#define NUMOFFSCRIMAGES_315 5 -static XF86OffscreenImageRec SISOffscreenImages_325[NUMOFFSCRIMAGES] = +static XF86OffscreenImageRec SISOffscreenImages[NUMOFFSCRIMAGES_315] = { { &SISImages[0], /* YUV2 */ @@ -2333,9 +4156,9 @@ static XF86OffscreenImageRec SISOffscreenImages_325[NUMOFFSCRIMAGES] = SISStopSurface, SISGetSurfaceAttribute, SISSetSurfaceAttribute, - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - NUM_ATTRIBUTES_325, - &SISAttributes_325[0] /* Support all attributes */ + 0, 0, /* Rest will be filled in */ + 0, + NULL }, { &SISImages[2], /* UYVY */ @@ -2346,9 +4169,9 @@ static XF86OffscreenImageRec SISOffscreenImages_325[NUMOFFSCRIMAGES] = SISStopSurface, SISGetSurfaceAttribute, SISSetSurfaceAttribute, - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - NUM_ATTRIBUTES_325, - &SISAttributes_325[0] /* Support all attributes */ + 0, 0, /* Rest will be filled in */ + 0, + NULL } , { @@ -2360,9 +4183,9 @@ static XF86OffscreenImageRec SISOffscreenImages_325[NUMOFFSCRIMAGES] = SISStopSurface, SISGetSurfaceAttribute, SISSetSurfaceAttribute, - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - NUM_ATTRIBUTES_325, - &SISAttributes_325[0] /* Support all attributes */ + 0, 0, /* Rest will be filled in */ + 0, + NULL }, { &SISImages[5], /* RV16 */ @@ -2373,56 +4196,12 @@ static XF86OffscreenImageRec SISOffscreenImages_325[NUMOFFSCRIMAGES] = SISStopSurface, SISGetSurfaceAttribute, SISSetSurfaceAttribute, - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - NUM_ATTRIBUTES_325, - &SISAttributes_325[0] /* Support all attributes */ - } -}; - -static XF86OffscreenImageRec SISOffscreenImages_M650[NUMOFFSCRIMAGES] = -{ - { - &SISImages[0], /* YUV2 */ - VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT, - SISAllocSurface, - SISFreeSurface, - SISDisplaySurface, - SISStopSurface, - SISGetSurfaceAttribute, - SISSetSurfaceAttribute, - IMAGE_MAX_WIDTH_M650, IMAGE_MAX_HEIGHT_M650, - NUM_ATTRIBUTES_325, - &SISAttributes_325[0] /* Support all attributes */ - }, - { - &SISImages[2], /* UYVY */ - VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT, - SISAllocSurface, - SISFreeSurface, - SISDisplaySurface, - SISStopSurface, - SISGetSurfaceAttribute, - SISSetSurfaceAttribute, - IMAGE_MAX_WIDTH_M650, IMAGE_MAX_HEIGHT_M650, - NUM_ATTRIBUTES_325, - &SISAttributes_325[0] /* Support all attributes */ - } - , - { - &SISImages[4], /* RV15 */ - VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT, - SISAllocSurface, - SISFreeSurface, - SISDisplaySurface, - SISStopSurface, - SISGetSurfaceAttribute, - SISSetSurfaceAttribute, - IMAGE_MAX_WIDTH_M650, IMAGE_MAX_HEIGHT_M650, - NUM_ATTRIBUTES_325, - &SISAttributes_325[0] /* Support all attributes */ + 0, 0, /* Rest will be filled in */ + 0, + NULL }, { - &SISImages[5], /* RV16 */ + &SISImages[6], /* YVYU */ VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT, SISAllocSurface, SISFreeSurface, @@ -2430,9 +4209,9 @@ static XF86OffscreenImageRec SISOffscreenImages_M650[NUMOFFSCRIMAGES] = SISStopSurface, SISGetSurfaceAttribute, SISSetSurfaceAttribute, - IMAGE_MAX_WIDTH_M650, IMAGE_MAX_HEIGHT_M650, - NUM_ATTRIBUTES_325, - &SISAttributes_325[0] /* Support all attributes */ + 0, 0, /* Rest will be filled in */ + 0, + NULL } }; @@ -2441,14 +4220,232 @@ SISInitOffscreenImages(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; SISPtr pSiS = SISPTR(pScrn); - - if(pSiS->VGAEngine == SIS_300_VGA) { - xf86XVRegisterOffscreenImages(pScreen, SISOffscreenImages_300, NUMOFFSCRIMAGES); - } else { - if(pSiS->Flags650 & SiS650_LARGEOVERLAY) { - xf86XVRegisterOffscreenImages(pScreen, SISOffscreenImages_M650, NUMOFFSCRIMAGES); + SISPortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); + int i, num; + + if(pSiS->VGAEngine == SIS_300_VGA) num = NUMOFFSCRIMAGES_300; + else num = NUMOFFSCRIMAGES_315; + + for(i = 0; i <= num; i++) { + SISOffscreenImages[i].max_width = DummyEncoding.width; + SISOffscreenImages[i].max_height = DummyEncoding.height; + if(pSiS->VGAEngine == SIS_300_VGA) { + SISOffscreenImages[i].num_attributes = NUM_ATTRIBUTES_300; + SISOffscreenImages[i].attributes = &SISAttributes_300[0]; } else { - xf86XVRegisterOffscreenImages(pScreen, SISOffscreenImages_325, NUMOFFSCRIMAGES); + if(pPriv->hasTwoOverlays) { + SISOffscreenImages[i].num_attributes = NUM_ATTRIBUTES_315; + } else { + SISOffscreenImages[i].num_attributes = NUM_ATTRIBUTES_315 - 1; + } + SISOffscreenImages[i].attributes = &SISAttributes_315[0]; } } + xf86XVRegisterOffscreenImages(pScreen, SISOffscreenImages, num); +} + +#ifdef NOT_YET_IMPLEMENTED /* ----------- TW: FOR FUTURE USE -------------------- */ + +/* Set alpha - does not work */ +static void +set_alpha(SISPtr pSiS, CARD8 alpha) +{ + setvideoregmask(pSiS, Index_VI_Key_Overlay_OP, ((alpha & 0x0f) << 4), 0xf0); +} + +/* Set SubPicture Start Address (yet unused) */ +static void +set_subpict_start_offset(SISPtr pSiS, SISOverlayPtr pOverlay, int index) +{ + 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) +{ + 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); + } +} + +/* 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; + + 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; + + /* 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; + } + + 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; + + 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; + + pOverlay->SubPictIntBit = 0x01; + } + + if(dstH == srcH) { + pOverlay->SubPictVUSF = 0x00; + pOverlay->SubPictIntBit |= 0x02; + } else if(dstH > srcH) { + dstH += 0x02; + pOverlay->SubPictVUSF = (srcH << 16) / dstH; + /* pOverlay->SubPictIntBit |= 0x00; */ + } else { + + I = srcH / dstH; + pOverlay->SubPictIntBit |= 0x02; + + 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); +} + +/* Set SubPicture Preset (yet unused) */ +static void +set_subpict_preset(SISPtr pSiS, SISOverlayPtr pOverlay) +{ + 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); +} + +static void +enable_subpict_overlay(SISPtr pSiS, Bool enable) +{ + setvideoregmask(pSiS, Index_VI_SubPict_Scale_Control, + enable ? 0x40 : 0x00, + 0x40); +} + +/* Set overlay for subpicture */ +static void +set_subpict_overlay(SISPtr pSiS, SISOverlayPtr pOverlay, SISPortPrivPtr pPriv, int index) +{ + ScrnInfoPtr pScrn = pSiS->pScrn; + + 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); */ +} + + +/* 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); + + 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); + + setvideoreg(pSiS,Index_MPEG_Y_UV_Buf_Preset_High, + ((pOverlay->MPEG_Y>>16) & 0x0F) | ((pOverlay->MPEG_UV>>12) & 0xF0)); +} + +static void +set_mpegfield_scale(SISPtr pSiS, SISOverlayPtr pOverlay) +{ + /* Empty for now */ +} + +#endif /* ------------------------------------------------------------------- */ + + + diff --git a/src/vgatypes.h b/src/vgatypes.h index d377dee..0daafed 100644 --- a/src/vgatypes.h +++ b/src/vgatypes.h @@ -1,20 +1,48 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/vgatypes.h,v 1.3 2003/02/10 01:14:16 tsi Exp $ */ - +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/vgatypes.h,v 1.15 2003/11/19 00:49:06 twini Exp $ */ +/* + * General type definitions for universal mode switching modules + * + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the linux kernel, the contents of this file + * is entirely covered by the GPL. + * + * Otherwise, the following 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. + * + * 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 <thomas@winischhofer.net> + * Silicon Integrated Systems + * + */ #ifndef _VGATYPES_ #define _VGATYPES_ #ifdef LINUX_XF86 +#include "xf86Version.h" #include "xf86Pci.h" #endif -#ifdef LINUX_KERNEL /* TW: We don't want the X driver to depend on kernel source */ +#ifdef LINUX_KERNEL /* We don't want the X driver to depend on kernel source */ #include <linux/ioctl.h> #endif -#ifndef TC -#define far -#endif - #ifndef FALSE #define FALSE 0 #endif @@ -51,47 +79,34 @@ typedef unsigned short USHORT; typedef unsigned long ULONG; #endif -#ifndef PUCHAR -typedef UCHAR far *PUCHAR; -#endif - -#ifndef PUSHORT -typedef USHORT far *PUSHORT; -#endif - -#ifndef PULONG -typedef ULONG far *PULONG; -#endif - -#ifndef PVOID -typedef void far *PVOID; -#endif -#ifndef VOID -typedef void VOID; -#endif - #ifndef BOOLEAN typedef UCHAR BOOLEAN; #endif -#ifndef WINCE_HEADER #ifndef bool typedef UCHAR bool; #endif -#endif /*WINCE_HEADER*/ -#ifndef VBIOS_VER_MAX_LENGTH -#define VBIOS_VER_MAX_LENGTH 4 +#ifdef LINUX_KERNEL +typedef unsigned long SISIOADDRESS; #endif -#ifndef LINUX_KERNEL /* For kernel, this is defined in sisfb.h */ -#ifndef WIN2000 +#ifdef LINUX_XF86 +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,0,0,0) +typedef unsigned long IOADDRESS; +typedef unsigned long SISIOADDRESS; +#else +typedef IOADDRESS SISIOADDRESS; +#endif +#endif + +#ifndef LINUX_KERNEL /* For the linux kernel, this is defined in sisfb.h */ #ifndef SIS_CHIP_TYPE typedef enum _SIS_CHIP_TYPE { SIS_VGALegacy = 0, #ifdef LINUX_XF86 - SIS_530, /* TW */ - SIS_OLD, /* TW */ + SIS_530, + SIS_OLD, #endif SIS_300, SIS_630, @@ -103,33 +118,32 @@ typedef enum _SIS_CHIP_TYPE { SIS_550, SIS_650, SIS_740, - SIS_330, + SIS_330, + SIS_661, + SIS_741, + SIS_660, + SIS_760, MAX_SIS_CHIP } SIS_CHIP_TYPE; #endif #endif -#endif -#ifndef WIN2000 #ifndef SIS_VB_CHIP_TYPE typedef enum _SIS_VB_CHIP_TYPE { VB_CHIP_Legacy = 0, VB_CHIP_301, - VB_CHIP_301B, + VB_CHIP_301B, VB_CHIP_301LV, - VB_CHIP_301LVX, VB_CHIP_302, VB_CHIP_302B, VB_CHIP_302LV, - VB_CHIP_302LVX, - VB_CHIP_303, + VB_CHIP_301C, + VB_CHIP_302ELV, VB_CHIP_UNKNOWN, /* other video bridge or no video bridge */ MAX_VB_CHIP } SIS_VB_CHIP_TYPE; #endif -#endif -#ifndef WIN2000 #ifndef SIS_LCD_TYPE typedef enum _SIS_LCD_TYPE { LCD_INVALID = 0, @@ -141,18 +155,20 @@ typedef enum _SIS_LCD_TYPE { LCD_1600x1200, LCD_1920x1440, LCD_2048x1536, - LCD_320x480, /* TW: FSTN */ + LCD_320x480, /* FSTN, DSTN */ LCD_1400x1050, LCD_1152x864, LCD_1152x768, LCD_1280x768, LCD_1024x600, + LCD_640x480_2, /* FSTN, DSTN */ + LCD_640x480_3, /* FSTN, DSTN */ + LCD_848x480, + LCD_CUSTOM, LCD_UNKNOWN } SIS_LCD_TYPE; #endif -#endif -#ifndef WIN2000 /* mark by Paul, Move definition to sisv.h*/ #ifndef PSIS_DSReg typedef struct _SIS_DSReg { @@ -161,36 +177,27 @@ typedef struct _SIS_DSReg } SIS_DSReg, *PSIS_DSReg; #endif -#ifndef SIS_HW_DEVICE_INFO - -typedef struct _SIS_HW_DEVICE_INFO SIS_HW_DEVICE_INFO, *PSIS_HW_DEVICE_INFO; +#ifndef SIS_HW_INFO -typedef BOOLEAN (*PSIS_QUERYSPACE) (PSIS_HW_DEVICE_INFO, ULONG, ULONG, ULONG *); +typedef struct _SIS_HW_INFO SIS_HW_INFO, *PSIS_HW_INFO; +typedef BOOLEAN (*PSIS_QUERYSPACE) (PSIS_HW_INFO, ULONG, ULONG, ULONG *); -struct _SIS_HW_DEVICE_INFO +struct _SIS_HW_INFO { - PVOID pDevice; /* The pointer to the physical device data structure - in each OS or NULL for unused. */ - UCHAR *pjVirtualRomBase; /* base virtual address of VBIOS ROM Space */ - /* or base virtual address of ROM image file. */ - /* if NULL, then read from pjROMImage; */ - /* Note:ROM image file is the file of VBIOS ROM */ - - 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) */ UCHAR jChipType; /* Used to Identify SiS Graphics Chip */ /* defined in the data structure type */ /* "SIS_CHIP_TYPE" */ @@ -199,20 +206,12 @@ struct _SIS_HW_DEVICE_INFO UCHAR ujVBChipID; /* the ID of video bridge */ /* defined in the data structure type */ /* "SIS_VB_CHIP_TYPE" */ +#ifdef LINUX_KERNEL + BOOLEAN Is301BDH; +#endif - USHORT usExternalChip; /* NO VB or other video bridge(not */ + USHORT usExternalChip; /* NO VB or other video bridge (other than */ /* SiS video bridge) */ - /* if ujVBChipID = VB_CHIP_UNKNOWN, */ - /* then bit0=1 : LVDS,bit1=1 : trumpion, */ - /* bit2=1 : CH7005 & no video bridge if */ - /* usExternalChip = 0. */ - /* Note: CR37[3:1]: */ - /* 001:SiS 301 */ - /* 010:LVDS */ - /* 011:Trumpion LVDS Scaling Chip */ - /* 100:LVDS(LCD-out)+Chrontel 7005 */ - /* 101:Single Chrontel 7005 */ - /* TW: This has changed on 310/325 series! */ ULONG ulCRT2LCDType; /* defined in the data structure type */ /* "SIS_LCD_TYPE" */ @@ -220,6 +219,8 @@ struct _SIS_HW_DEVICE_INFO BOOLEAN bIntegratedMMEnabled;/* supporting integration MM enable */ BOOLEAN bSkipDramSizing; /* True: Skip video memory sizing. */ + +#ifdef LINUX_KERNEL PSIS_DSReg pSR; /* restore SR registers in initial function. */ /* end data :(idx, val) = (FF, FF). */ /* Note : restore SR registers if */ @@ -229,6 +230,7 @@ struct _SIS_HW_DEVICE_INFO /* end data :(idx, val) = (FF, FF) */ /* Note : restore cR registers if */ /* bSkipDramSizing = TRUE */ +#endif PSIS_QUERYSPACE pQueryVGAConfigSpace; /* Get/Set VGA Configuration */ /* space */ @@ -236,27 +238,19 @@ struct _SIS_HW_DEVICE_INFO PSIS_QUERYSPACE pQueryNorthBridgeSpace;/* Get/Set North Bridge */ /* space */ - UCHAR szVBIOSVer[VBIOS_VER_MAX_LENGTH]; - - UCHAR pdc; /* TW: PanelDelayCompensation */ - -#ifdef LINUX_XF86 - PCITAG PciTag; /* PCI Tag for Linux XF86 */ -#endif + UCHAR pdc; /* PanelDelayCompensation */ }; #endif -#endif - -/* TW: Addtional IOCTL for communication sisfb <> X driver */ -/* If changing this, sisfb.h must also be changed (for sisfb) */ +/* Addtional IOCTL for communication sisfb <> X driver */ +/* If changing this, sisfb.h must also be changed (for sisfb) */ #ifdef LINUX_XF86 /* We don't want the X driver to depend on the kernel source */ -/* TW: ioctl for identifying and giving some info (esp. memory heap start) */ +/* ioctl for identifying and giving some info (esp. memory heap start) */ #define SISFB_GET_INFO 0x80046ef8 /* Wow, what a terrible hack... */ -/* TW: Structure argument for SISFB_GET_INFO ioctl */ +/* Structure argument for SISFB_GET_INFO ioctl */ typedef struct _SISFB_INFO sisfb_info, *psisfb_info; struct _SISFB_INFO { @@ -282,87 +276,18 @@ struct _SISFB_INFO { unsigned int sisfb_pcifunc; unsigned char sisfb_lcdpdc; + + unsigned char sisfb_lcda; - char reserved[236]; /* for future use */ -}; -#endif - -#ifndef WIN2000 -#ifndef WINCE_HEADER -#ifndef BUS_DATA_TYPE -typedef enum _BUS_DATA_TYPE { - ConfigurationSpaceUndefined = -1, - Cmos, - EisaConfiguration, - Pos, - CbusConfiguration, - PCIConfiguration, - VMEConfiguration, - NuBusConfiguration, - PCMCIAConfiguration, - MPIConfiguration, - MPSAConfiguration, - PNPISAConfiguration, - MaximumBusDataType -} BUS_DATA_TYPE, *PBUS_DATA_TYPE; -#endif -#endif /* WINCE_HEADER */ - -#ifndef PCI_TYPE0_ADDRESSES -#define PCI_TYPE0_ADDRESSES 6 -#endif + unsigned long sisfb_vbflags; + unsigned long sisfb_currentvbflags; -#ifndef PCI_TYPE1_ADDRESSES -#define PCI_TYPE1_ADDRESSES 2 -#endif + int sisfb_scalelcd; + unsigned long sisfb_specialtiming; -#ifndef WINCE_HEADER -#ifndef PCI_COMMON_CONFIG -typedef struct _PCI_COMMON_CONFIG { - USHORT VendorID; /* (ro) */ - USHORT DeviceID; /* (ro) */ - USHORT Command; /* Device control */ - USHORT Status; - UCHAR RevisionID; /* (ro) */ - UCHAR ProgIf; /* (ro) */ - UCHAR SubClass; /* (ro) */ - UCHAR BaseClass; /* (ro) */ - UCHAR CacheLineSize; /* (ro+) */ - UCHAR LatencyTimer; /* (ro+) */ - UCHAR HeaderType; /* (ro) */ - UCHAR BIST; /* Built in self test */ - - union { - struct _PCI_HEADER_TYPE_0 { - ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; - ULONG CIS; - USHORT SubVendorID; - USHORT SubSystemID; - ULONG ROMBaseAddress; - ULONG Reserved2[2]; - - UCHAR InterruptLine; /* */ - UCHAR InterruptPin; /* (ro) */ - UCHAR MinimumGrant; /* (ro) */ - UCHAR MaximumLatency; /* (ro) */ - } type0; - - - } u; - - UCHAR DeviceSpecific[192]; - -} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; + char reserved[219]; /* for future use */ +}; #endif -#endif /* WINCE_HEADER */ -#ifndef FIELD_OFFSET -#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field)) #endif -#ifndef PCI_COMMON_HDR_LENGTH -#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET (PCI_COMMON_CONFIG, DeviceSpecific)) -#endif -#endif - -#endif diff --git a/src/vstruct.h b/src/vstruct.h index 7005986..c200559 100644 --- a/src/vstruct.h +++ b/src/vstruct.h @@ -1,5 +1,37 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/vstruct.h,v 1.3 2003/02/10 01:14:17 tsi Exp $ */ - +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/vstruct.h,v 1.22 2003/11/03 17:02:54 twini Exp $ */ +/* + * General structure definitions for universal mode switching modules + * + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the linux kernel, the contents of this file + * is entirely covered by the GPL. + * + * Otherwise, the following 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. + * + * 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 <thomas@winischhofer.net> + * Silicon Integrated Systems + * + */ + #ifdef _INIT_ #define EXTERN #else @@ -60,7 +92,6 @@ typedef struct _SiS_LVDSCRT1DataStruct UCHAR CR[15]; } SiS_LVDSCRT1DataStruct; -/*add for LCDA*/ typedef struct _SiS_LCDACRT1DataStruct { UCHAR CR[17]; @@ -81,6 +112,7 @@ typedef struct _SiS_StStruct UCHAR VB_StTVFlickerIndex; UCHAR VB_StTVEdgeIndex; UCHAR VB_StTVYFilterIndex; + UCHAR St_PDC; } SiS_StStruct; typedef struct _SiS_VBModeStruct @@ -112,14 +144,13 @@ typedef struct _SiS_ExtStruct { UCHAR Ext_ModeID; USHORT Ext_ModeFlag; - USHORT Ext_ModeInfo; - USHORT Ext_Point; + UCHAR Ext_ModeOffset; USHORT Ext_VESAID; - UCHAR Ext_VESAMEMSize; UCHAR Ext_RESINFO; UCHAR VB_ExtTVFlickerIndex; UCHAR VB_ExtTVEdgeIndex; UCHAR VB_ExtTVYFilterIndex; + UCHAR VB_ExtTVYFilterIndexROM661; UCHAR REFindex; } SiS_ExtStruct; @@ -132,7 +163,7 @@ typedef struct _SiS_Ext2Struct UCHAR ModeID; USHORT XRes; USHORT YRes; - USHORT ROM_OFFSET; + UCHAR Ext_PDC; } SiS_Ext2Struct; typedef struct _SiS_Part2PortTblStruct @@ -151,12 +182,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; @@ -185,39 +210,67 @@ typedef struct _SiS_ModeResInfoStruct typedef UCHAR DRAM4Type[4]; +/* Defines for SiS_CustomT */ +/* Never change these for sisfb compatibility */ +#define CUT_NONE 0 +#define CUT_FORCENONE 1 +#define CUT_BARCO1366 2 +#define CUT_BARCO1024 3 +#define CUT_COMPAQ1280 4 +#define CUT_COMPAQ12802 5 +#define CUT_PANEL848 6 +#define CUT_CLEVO1024 7 +#define CUT_CLEVO10242 8 +#define CUT_CLEVO1400 9 +#define CUT_CLEVO14002 10 +#define CUT_UNIWILL1024 11 +#define CUT_ASUSL3000D 12 +#define CUT_UNIWILL10242 13 + typedef struct _SiS_Private { #ifdef LINUX_KERNEL - USHORT RelIO; + SISIOADDRESS RelIO; #endif - USHORT SiS_P3c4; - USHORT SiS_P3d4; - USHORT SiS_P3c0; - USHORT SiS_P3ce; - USHORT SiS_P3c2; - USHORT SiS_P3ca; - USHORT SiS_P3c6; - USHORT SiS_P3c7; - USHORT SiS_P3c8; - USHORT SiS_P3c9; - USHORT SiS_P3da; - USHORT SiS_Part1Port; - USHORT SiS_Part2Port; - USHORT SiS_Part3Port; - USHORT SiS_Part4Port; - USHORT SiS_Part5Port; + SISIOADDRESS SiS_P3c4; + SISIOADDRESS SiS_P3d4; + SISIOADDRESS SiS_P3c0; + SISIOADDRESS SiS_P3ce; + SISIOADDRESS SiS_P3c2; + SISIOADDRESS SiS_P3ca; + SISIOADDRESS SiS_P3c6; + SISIOADDRESS SiS_P3c7; + SISIOADDRESS SiS_P3c8; + SISIOADDRESS SiS_P3c9; + SISIOADDRESS SiS_P3cb; + SISIOADDRESS SiS_P3cd; + SISIOADDRESS SiS_P3da; + SISIOADDRESS SiS_Part1Port; + SISIOADDRESS SiS_Part2Port; + SISIOADDRESS SiS_Part3Port; + SISIOADDRESS SiS_Part4Port; + SISIOADDRESS SiS_Part5Port; + SISIOADDRESS SiS_VidCapt; + SISIOADDRESS SiS_VidPlay; USHORT SiS_IF_DEF_LVDS; + USHORT SiS_IF_DEF_CH70xx; + USHORT SiS_IF_DEF_CONEX; USHORT SiS_IF_DEF_TRUMPION; USHORT SiS_IF_DEF_DSTN; USHORT SiS_IF_DEF_FSTN; - USHORT SiS_IF_DEF_CH70xx; USHORT SiS_IF_DEF_HiVision; + USHORT SiS_SysFlags; UCHAR SiS_VGAINFO; +#ifndef LINUX_KERNEL + USHORT SiS_CP1, SiS_CP2, SiS_CP3, SiS_CP4; +#endif BOOLEAN SiS_UseROM; int SiS_CHOverScan; BOOLEAN SiS_CHSOverScan; BOOLEAN SiS_ChSW; + BOOLEAN SiS_UseLCDA; int SiS_UseOEM; + ULONG SiS_CustomT; USHORT SiS_Backup70xx; USHORT SiS_CRT1Mode; USHORT SiS_flag_clearbuffer; @@ -226,9 +279,11 @@ 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; @@ -271,22 +326,24 @@ typedef struct _SiS_Private USHORT SiS_Panel1280x768; USHORT SiS_Panel1024x600; USHORT SiS_Panel640x480; + USHORT SiS_Panel640x480_2; + USHORT SiS_Panel640x480_3; USHORT SiS_Panel1152x864; + USHORT SiS_PanelCustom; + USHORT SiS_PanelBarco1366; USHORT SiS_PanelMax; USHORT SiS_PanelMinLVDS; USHORT SiS_PanelMin301; USHORT SiS_ChrontelInit; - /* Pointers: */ const SiS_StStruct *SiS_SModeIDTable; - const SiS_StandTableStruct *SiS_StandTable; + SiS_StandTableStruct *SiS_StandTable; const SiS_ExtStruct *SiS_EModeIDTable; const SiS_Ext2Struct *SiS_RefIndex; const SiS_VBModeStruct *SiS_VBModeIDTable; const SiS_CRT1TableStruct *SiS_CRT1Table; const SiS_MCLKDataStruct *SiS_MCLKData_0; const SiS_MCLKDataStruct *SiS_MCLKData_1; - const SiS_ECLKDataStruct *SiS_ECLKData; const SiS_VCLKDataStruct *SiS_VCLKData; const SiS_VBVCLKDataStruct *SiS_VBVCLKData; const SiS_StResInfoStruct *SiS_StResInfo; @@ -317,7 +374,7 @@ typedef struct _SiS_Private const USHORT *pSiS_RGBSenseData; const USHORT *pSiS_VideoSenseData; const USHORT *pSiS_YCSenseData; - const USHORT *pSiS_RGBSenseData2; /*301b*/ + const USHORT *pSiS_RGBSenseData2; const USHORT *pSiS_VideoSenseData2; const USHORT *pSiS_YCSenseData2; #endif @@ -330,6 +387,8 @@ typedef struct _SiS_Private const UCHAR *SiS_PALMPhase2; const UCHAR *SiS_PALNPhase2; const UCHAR *SiS_SpecialPhase; + const UCHAR *SiS_SpecialPhaseM; + const UCHAR *SiS_SpecialPhaseJ; const SiS_LCDDataStruct *SiS_StLCD1024x768Data; const SiS_LCDDataStruct *SiS_ExtLCD1024x768Data; const SiS_LCDDataStruct *SiS_St2LCD1024x768Data; @@ -341,22 +400,22 @@ typedef struct _SiS_Private const SiS_LCDDataStruct *SiS_LCD1280x960Data; const SiS_LCDDataStruct *SiS_NoScaleData1400x1050; const SiS_LCDDataStruct *SiS_NoScaleData1600x1200; + const SiS_LCDDataStruct *SiS_NoScaleData1280x768; const SiS_LCDDataStruct *SiS_StLCD1400x1050Data; const SiS_LCDDataStruct *SiS_StLCD1600x1200Data; + const SiS_LCDDataStruct *SiS_StLCD1280x768Data; const SiS_LCDDataStruct *SiS_ExtLCD1400x1050Data; const SiS_LCDDataStruct *SiS_ExtLCD1600x1200Data; + const SiS_LCDDataStruct *SiS_ExtLCD1280x768Data; + const SiS_LCDDataStruct *SiS_NoScaleData; const SiS_TVDataStruct *SiS_StPALData; const SiS_TVDataStruct *SiS_ExtPALData; const SiS_TVDataStruct *SiS_StNTSCData; const SiS_TVDataStruct *SiS_ExtNTSCData; -#ifdef oldHV - const SiS_TVDataStruct *SiS_St1HiTVData; const SiS_TVDataStruct *SiS_St2HiTVData; const SiS_TVDataStruct *SiS_ExtHiTVData; -#endif const UCHAR *SiS_NTSCTiming; const UCHAR *SiS_PALTiming; -#ifdef oldHV const UCHAR *SiS_HiTVExtTiming; const UCHAR *SiS_HiTVSt1Timing; const UCHAR *SiS_HiTVSt2Timing; @@ -364,7 +423,6 @@ typedef struct _SiS_Private const UCHAR *SiS_HiTVGroup3Data; const UCHAR *SiS_HiTVGroup3Simu; const UCHAR *SiS_HiTVGroup3Text; -#endif const SiS_PanelDelayTblStruct *SiS_PanelDelayTbl; const SiS_PanelDelayTblStruct *SiS_PanelDelayTblLVDS; const SiS_LVDSDataStruct *SiS_LVDS800x600Data_1; @@ -377,6 +435,8 @@ typedef struct _SiS_Private const SiS_LVDSDataStruct *SiS_LVDS1280x960Data_2; const SiS_LVDSDataStruct *SiS_LVDS1400x1050Data_1; const SiS_LVDSDataStruct *SiS_LVDS1400x1050Data_2; + const SiS_LVDSDataStruct *SiS_LVDS1600x1200Data_1; + const SiS_LVDSDataStruct *SiS_LVDS1600x1200Data_2; const SiS_LVDSDataStruct *SiS_LVDS1280x768Data_1; const SiS_LVDSDataStruct *SiS_LVDS1280x768Data_2; const SiS_LVDSDataStruct *SiS_LVDS1024x600Data_1; @@ -384,12 +444,23 @@ typedef struct _SiS_Private const SiS_LVDSDataStruct *SiS_LVDS1152x768Data_1; const SiS_LVDSDataStruct *SiS_LVDS1152x768Data_2; const SiS_LVDSDataStruct *SiS_LVDS640x480Data_1; + const SiS_LVDSDataStruct *SiS_LVDS640x480Data_2; const SiS_LVDSDataStruct *SiS_LVDS320x480Data_1; + const SiS_LVDSDataStruct *SiS_LCDA1024x768Data_1; + const SiS_LVDSDataStruct *SiS_LCDA1024x768Data_2; + const SiS_LVDSDataStruct *SiS_LCDA1280x1024Data_1; + const SiS_LVDSDataStruct *SiS_LCDA1280x1024Data_2; const SiS_LVDSDataStruct *SiS_LCDA1400x1050Data_1; const SiS_LVDSDataStruct *SiS_LCDA1400x1050Data_2; const SiS_LVDSDataStruct *SiS_LCDA1600x1200Data_1; const SiS_LVDSDataStruct *SiS_LCDA1600x1200Data_2; const SiS_LVDSDataStruct *SiS_LVDSXXXxXXXData_1; + const SiS_LVDSDataStruct *SiS_LVDSBARCO1366Data_1; + const SiS_LVDSDataStruct *SiS_LVDSBARCO1366Data_2; + const SiS_LVDSDataStruct *SiS_LVDSBARCO1024Data_1; + const SiS_LVDSDataStruct *SiS_LVDSBARCO1024Data_2; + const SiS_LVDSDataStruct *SiS_LVDS848x480Data_1; + const SiS_LVDSDataStruct *SiS_LVDS848x480Data_2; const SiS_LVDSDataStruct *SiS_CHTVUNTSCData; const SiS_LVDSDataStruct *SiS_CHTVONTSCData; const SiS_LVDSDataStruct *SiS_CHTVUPALData; @@ -415,6 +486,7 @@ typedef struct _SiS_Private const SiS_LVDSDesStruct *SiS_PanelType0d_1; const SiS_LVDSDesStruct *SiS_PanelType0e_1; const SiS_LVDSDesStruct *SiS_PanelType0f_1; + const SiS_LVDSDesStruct *SiS_PanelTypeNS_1; const SiS_LVDSDesStruct *SiS_PanelType00_2; const SiS_LVDSDesStruct *SiS_PanelType01_2; const SiS_LVDSDesStruct *SiS_PanelType02_2; @@ -431,6 +503,7 @@ typedef struct _SiS_Private const SiS_LVDSDesStruct *SiS_PanelType0d_2; 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; @@ -479,6 +552,12 @@ typedef struct _SiS_Private const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11600x1200_2_H; const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1XXXxXXX_1; const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1XXXxXXX_1_H; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_1; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_1_H; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_2; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_2_H; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_3; + const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_3_H; const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1UNTSC; const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1ONTSC; const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1UPAL; @@ -487,28 +566,23 @@ typedef struct _SiS_Private const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1320x480_1; - const SiS_LCDACRT1DataStruct *SiS_LCDACRT1800x600_1; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11024x768_1; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11280x1024_1; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11400x1050_1; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11600x1200_1; - const SiS_LCDACRT1DataStruct *SiS_LCDACRT1800x600_1_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11024x768_1_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11280x1024_1_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11400x1050_1_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11600x1200_1_H; - const SiS_LCDACRT1DataStruct *SiS_LCDACRT1800x600_2; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11024x768_2; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11280x1024_2; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11400x1050_2; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11600x1200_2; - const SiS_LCDACRT1DataStruct *SiS_LCDACRT1800x600_2_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11024x768_2_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11280x1024_2_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11400x1050_2_H; const SiS_LCDACRT1DataStruct *SiS_LCDACRT11600x1200_2_H; - /* TW: New for 650/301LV */ const SiS_Part2PortTblStruct *SiS_CRT2Part2_1024x768_1; const SiS_Part2PortTblStruct *SiS_CRT2Part2_1280x1024_1; const SiS_Part2PortTblStruct *SiS_CRT2Part2_1400x1050_1; @@ -540,6 +614,9 @@ typedef struct _SiS_Private const UCHAR *SiS_CHTVVCLKUPALN; const UCHAR *SiS_CHTVVCLKOPALN; const UCHAR *SiS_CHTVVCLKSOPAL; + + USHORT PanelXRes; + USHORT PanelYRes; BOOLEAN UseCustomMode; BOOLEAN CRT1UsesCustomMode; @@ -561,10 +638,41 @@ typedef struct _SiS_Private UCHAR CSR2B; UCHAR CSR2C; USHORT CSRClock; + USHORT CSRClock_CRT1; USHORT CModeFlag; + USHORT CModeFlag_CRT1; USHORT CInfoFlag; - BOOLEAN SiS_CHPALM; - BOOLEAN SiS_CHPALN; + + int LVDSHL; + + BOOLEAN Backup; + UCHAR Backup_Mode; + UCHAR Backup_14; + UCHAR Backup_15; + UCHAR Backup_16; + UCHAR Backup_17; + UCHAR Backup_18; + UCHAR Backup_19; + UCHAR Backup_1a; + UCHAR Backup_1b; + UCHAR Backup_1c; + UCHAR Backup_1d; + + int UsePanelScaler; + + USHORT CP_Vendor, CP_Product; + BOOLEAN CP_HaveCustomData; + int CP_PreferredX, CP_PreferredY; + int CP_MaxX, CP_MaxY, CP_MaxClock; + int CP_HDisplay[7], CP_VDisplay[7]; /* For Custom LCD panel dimensions */ + int CP_HTotal[7], CP_VTotal[7]; + int CP_HSyncStart[7], CP_VSyncStart[7]; + int CP_HSyncEnd[7], CP_VSyncEnd[7]; + int CP_HBlankStart[7], CP_VBlankStart[7]; + int CP_HBlankEnd[7], CP_VBlankEnd[7]; + int CP_Clock[7]; + BOOLEAN CP_DataValid[7]; + BOOLEAN CP_HSync_P[7], CP_VSync_P[7], CP_SyncValid[7]; } SiS_Private; #endif |