[Xorg-commit] xc/programs/Xserver/hw/xfree86/drivers/sis 300vtbl.h,1.1.4.1,1.1.4.2 310vtbl.h,1.1.4.1,1.1.4.2 init.c,1.1.4.3,1.1.4.4 init.h,1.1.4.3,1.1.4.4 init301.c,1.1.4.3,1.1.4.4 init301.h,1.1.4.3,1.1.4.4 initdef.h,1.1.4.2,1.1.4.3 oem300.h,1.1.4.1,1.1.4.2 oem310.h,1.1.4.2,1.1.4.3 osdef.h,1.1.4.1,1.1.4.2 sis.h,1.1.4.4,1.1.4.5 sis300_accel.c,1.1.4.1,1.1.4.2 sis300_accel.h,1.1.4.1,1.1.4.2 sis310_accel.c,1.1.4.1,1.1.4.2 sis310_accel.h,1.1.4.1,1.1.4.2 sis6326_video.c,1.1.4.1,1.1.4.2 sis_accel.c,1.1.4.1,1.1.4.2 sis_accel.h,1.1.4.1,1.1.4.2 sis_common.h,1.1,1.1.4.1 sis_cursor.c,1.1.4.1,1.1.4.2 sis_cursor.h,1.1.4.1,1.1.4.2 sis_dac.c,1.1.4.2,1.1.4.3 sis_dac.h,1.1.4.1,1.1.4.2 sis_dga.c,1.1.4.1,1.1.4.2 sis_dri.c,1.1.4.1,1.1.4.2 sis_dri.h,1.1.4.1,1.1.4.2 sis_driver.c,1.1.4.4,1.1.4.5 sis_driver.h,1.1.4.3,1.1.4.4 sis_opt.c,1.1.4.3,1.1.4.4 sis_regs.h,1.1.4.1,1.1.4.2 sis_setup.c,1.1.4.1,1.1.4.2 sis_shadow.c,1.1.4.1,1.1.4.2 sis_shadow.h,1.1.4.1,1.1.4.2 sis_vb.c,1.1.4.3,1.1.4.4 sis_vb.h,1.1.4.2,1.1.4.3 sis_vga.c,1.1.4.2,1.1.4.3 sis_video.c,1.1.4.2,1.1.4.3 vgatypes.h,1.1.4.3,1.1.4.4 vstruct.h,1.1.4.3,1.1.4.4

Kaleb Keithley xorg-commit at pdx.freedesktop.org
Wed May 9 17:30:30 EEST 2007


Committed by: kaleb

Update of /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis
In directory pdx:/home/kaleb/xorg/xc.XORG-CURRENT/programs/Xserver/hw/xfree86/drivers/sis

Modified Files:
      Tag: XORG-CURRENT
	300vtbl.h 310vtbl.h init.c init.h init301.c init301.h 
	initdef.h oem300.h oem310.h osdef.h sis.h sis300_accel.c 
	sis300_accel.h sis310_accel.c sis310_accel.h sis6326_video.c 
	sis_accel.c sis_accel.h sis_common.h sis_cursor.c sis_cursor.h 
	sis_dac.c sis_dac.h sis_dga.c sis_dri.c sis_dri.h sis_driver.c 
	sis_driver.h sis_opt.c sis_regs.h sis_setup.c sis_shadow.c 
	sis_shadow.h sis_vb.c sis_vb.h sis_vga.c sis_video.c 
	vgatypes.h vstruct.h 
Log Message:
merge most of XFree86 RC3 (4.3.99.903) from vendor branch.
bug #214


Index: 300vtbl.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/300vtbl.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/300vtbl.h	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/300vtbl.h	23 Feb 2004 21:35:44 -0000	1.1.4.2
@@ -1,36 +1,55 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/300vtbl.h,v 1.20 2003/11/19 00:49:02 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/300vtbl.h,v 1.23 2004/01/23 22:29:01 twini Exp $ */
 /*
  * Register settings for SiS 300 series
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * If distributed as part of the linux kernel, the contents of this file
- * is entirely covered by the GPL.
+ * If distributed as part of the Linux kernel, the following license terms
+ * apply:
  *
- * Otherwise, the following terms apply:
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation; either version 2 of the named License,
+ * * or any later version.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Otherwise, the following license terms apply:
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * * Redistribution and use in source and binary forms, with or without
+ * * modification, are permitted provided that the following conditions
+ * * are met:
+ * * 1) Redistributions of source code must retain the above copyright
+ * *    notice, this list of conditions and the following disclaimer.
+ * * 2) Redistributions in binary form must reproduce the above copyright
+ * *    notice, this list of conditions and the following disclaimer in the
+ * *    documentation and/or other materials provided with the distribution.
+ * * 3) All advertising materials mentioning features or use of this software
+ * *    must display the following acknowledgement: "This product includes
+ * *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * * 4) The name of the author may not be used to endorse or promote products
+ * *    derived from this software without specific prior written permission.
+ * *
+ * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
  *
- * Based on code by Silicon Intergrated Systems
- *
  */
 
 typedef struct _SiS300_StStruct

Index: 310vtbl.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/310vtbl.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/310vtbl.h	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/310vtbl.h	23 Feb 2004 21:35:44 -0000	1.1.4.2
@@ -1,36 +1,55 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/310vtbl.h,v 1.20 2003/11/19 00:49:02 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/310vtbl.h,v 1.23 2004/01/23 22:29:01 twini Exp $ */
 /*
  * Register settings for SiS 315/330 series
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * If distributed as part of the linux kernel, the contents of this file
- * is entirely covered by the GPL.
+ * If distributed as part of the Linux kernel, the following license terms
+ * apply:
  *
- * Otherwise, the following terms apply:
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation; either version 2 of the named License,
+ * * or any later version.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Otherwise, the following license terms apply:
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * * Redistribution and use in source and binary forms, with or without
+ * * modification, are permitted provided that the following conditions
+ * * are met:
+ * * 1) Redistributions of source code must retain the above copyright
+ * *    notice, this list of conditions and the following disclaimer.
+ * * 2) Redistributions in binary form must reproduce the above copyright
+ * *    notice, this list of conditions and the following disclaimer in the
+ * *    documentation and/or other materials provided with the distribution.
+ * * 3) All advertising materials mentioning features or use of this software
+ * *    must display the following acknowledgement: "This product includes
+ * *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * * 4) The name of the author may not be used to endorse or promote products
+ * *    derived from this software without specific prior written permission.
+ * *
+ * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
  *
- * Based on code by Silicon Intergrated Systems
- *
  */
 
 typedef struct _SiS310_StStruct

Index: init.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/init.c,v
retrieving revision 1.1.4.3
retrieving revision 1.1.4.4
diff -u -d -r1.1.4.3 -r1.1.4.4
--- a/init.c	20 Dec 2003 00:28:27 -0000	1.1.4.3
+++ b/init.c	23 Feb 2004 21:35:45 -0000	1.1.4.4
@@ -1,37 +1,60 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.c,v 1.40 2003/12/03 23:07:47 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.c,v 1.46 2004/01/24 21:29:20 twini Exp $ */
 /*
  * 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
+ *     SiS 315/550/650/M650/651/661FX/M661FX/740/741/M741/330/660/M660/760/M760
  * (Universal module for Linux kernel framebuffer and XFree86 4.x)
  *
- * Assembler-To-C translation
- * Copyright 2002, 2003 by Thomas Winischhofer <thomas at winischhofer.net>
- * Formerly based on non-functional code-fragements by SiS, Inc.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * If distributed as part of the linux kernel, the contents of this file
- * is entirely covered by the GPL.
+ * If distributed as part of the Linux kernel, the following license terms
+ * apply:
  *
- * Otherwise, the following terms apply:
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation; either version 2 of the named License,
+ * * or any later version.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Otherwise, the following license terms apply:
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * * Redistribution and use in source and binary forms, with or without
+ * * modification, are permitted provided that the following conditions
+ * * are met:
+ * * 1) Redistributions of source code must retain the above copyright
+ * *    notice, this list of conditions and the following disclaimer.
+ * * 2) Redistributions in binary form must reproduce the above copyright
+ * *    notice, this list of conditions and the following disclaimer in the
+ * *    documentation and/or other materials provided with the distribution.
+ * * 3) All advertising materials mentioning features or use of this software
+ * *    must display the following acknowledgement: "This product includes
+ * *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * * 4) The name of the author may not be used to endorse or promote products
+ * *    derived from this software without specific prior written permission.
+ * *
+ * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
+ *
+ * Formerly based on non-functional code-fragements for 300 series by SiS, Inc.
+ * Used by permission.
  *
  * TW says: This code looks awful, I know. But please don't do anything about
  * this otherwise debugging will be hell.
@@ -69,35 +92,44 @@
    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_NTSCPhase     = SiS_NTSCPhase;
+   SiS_Pr->SiS_PALPhase      = SiS_PALPhase;
+   SiS_Pr->SiS_NTSCPhase2    = SiS_NTSCPhase2;
+   SiS_Pr->SiS_PALPhase2     = SiS_PALPhase2;
+   SiS_Pr->SiS_PALMPhase     = SiS_PALMPhase;
+   SiS_Pr->SiS_PALNPhase     = SiS_PALNPhase;
+   SiS_Pr->SiS_PALMPhase2    = SiS_PALMPhase2;
+   SiS_Pr->SiS_PALNPhase2    = SiS_PALNPhase2;
+   SiS_Pr->SiS_SpecialPhase  = SiS_SpecialPhase;
+   SiS_Pr->SiS_SpecialPhaseM = SiS_SpecialPhaseM;
+   SiS_Pr->SiS_SpecialPhaseJ = SiS_SpecialPhaseJ;
 
    SiS_Pr->SiS_NTSCTiming     = SiS_NTSCTiming;
    SiS_Pr->SiS_PALTiming      = SiS_PALTiming;
    SiS_Pr->SiS_HiTVSt1Timing  = SiS_HiTVSt1Timing;
    SiS_Pr->SiS_HiTVSt2Timing  = SiS_HiTVSt2Timing;
-   SiS_Pr->SiS_HiTVTextTiming = SiS_HiTVTextTiming;
+
    SiS_Pr->SiS_HiTVExtTiming  = SiS_HiTVExtTiming;
    SiS_Pr->SiS_HiTVGroup3Data = SiS_HiTVGroup3Data;
    SiS_Pr->SiS_HiTVGroup3Simu = SiS_HiTVGroup3Simu;
+#if 0
+   SiS_Pr->SiS_HiTVTextTiming = SiS_HiTVTextTiming;
    SiS_Pr->SiS_HiTVGroup3Text = SiS_HiTVGroup3Text;
+#endif
 
    SiS_Pr->SiS_StPALData   = SiS_StPALData;
    SiS_Pr->SiS_ExtPALData  = SiS_ExtPALData;
    SiS_Pr->SiS_StNTSCData  = SiS_StNTSCData;
    SiS_Pr->SiS_ExtNTSCData = SiS_ExtNTSCData;
-/* SiS_Pr->SiS_St1HiTVData = SiS_St1HiTVData;  */
+   SiS_Pr->SiS_St1HiTVData = SiS_StHiTVData; 
    SiS_Pr->SiS_St2HiTVData = SiS_St2HiTVData;
    SiS_Pr->SiS_ExtHiTVData = SiS_ExtHiTVData;
+   SiS_Pr->SiS_St525iData  = SiS_StNTSCData;
+   SiS_Pr->SiS_St525pData  = SiS_St525pData;
+   SiS_Pr->SiS_St750pData  = SiS_St750pData;
+   SiS_Pr->SiS_Ext525iData = SiS_ExtNTSCData;
+   SiS_Pr->SiS_Ext525pData = SiS_ExtNTSCData;
+   SiS_Pr->SiS_Ext750pData = SiS_Ext750pData;
 
    SiS_Pr->pSiS_OutputSelect = &SiS_OutputSelect;
    SiS_Pr->pSiS_SoftSetting  = &SiS_SoftSetting;
@@ -992,7 +1024,9 @@
              if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth];
              break;
       	case 512:
-	     if((VBFlags & TV_PAL) && (!(VBFlags & TV_PALM))) {
+	     if( ((VBFlags & TV_YPBPR) && (VBFlags & (TV_YPBPR525P | TV_YPBPR750P | TV_YPBPR1080I))) ||
+	         (VBFlags & TV_HIVISION) 					    		     ||
+	         ((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) ) {
 	        if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth];
 	     }
 	     break;
@@ -1001,19 +1035,19 @@
 	     else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth];
 	     break;
 	case 720:
-	     if(!(VBFlags & (TV_HIVISION | TV_YPBPR))) {
+	     if((!(VBFlags & TV_HIVISION)) && (!((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I)))) {
                 if(VDisplay == 480) {
-		   if((VBFlags & TV_NTSC) || (VBFlags & TV_PALM))
+		   if((VBFlags & TV_YPBPR) || (VBFlags & (TV_NTSC | TV_PALM)))
                       ModeIndex = ModeIndex_720x480[Depth];
                 } else if(VDisplay == 576) {
-		   if((VBFlags & TV_PAL) && (!(VBFlags & TV_PALM)))
+		   if((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL))
                       ModeIndex = ModeIndex_720x576[Depth];
                 }
 	     }
              break;
 	case 768:
-	     if(!(VBFlags & (TV_HIVISION | TV_YPBPR))) {
-	        if((VBFlags & TV_PAL) && (!(VBFlags & TV_PALM))) {
+	     if((!(VBFlags & TV_HIVISION)) && (!((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I)))) {
+	        if((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) {
           	   if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth];
 		}
              }
@@ -1021,8 +1055,8 @@
 	case 800:
 	     if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth];
 	     else if(VDisplay == 480) {
-	        if(VBFlags & (TV_HIVISION | TV_YPBPR)) {
-		    ModeIndex = ModeIndex_800x480[Depth];
+	        if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) {
+		   ModeIndex = ModeIndex_800x480[Depth];
 		}
 	     }
 	     break;
@@ -1032,13 +1066,13 @@
 		   ModeIndex = ModeIndex_1024x768[Depth];
 		}
 	     } else if(VDisplay == 576) {
-	        if(VBFlags & (TV_HIVISION | TV_YPBPR)) {
+	        if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) {
 		   ModeIndex = ModeIndex_1024x576[Depth];
 		}
 	     }
 	     break;
 	case 1280:
-	     if(VBFlags & (TV_HIVISION | TV_YPBPR)) {
+	     if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) {
 	        if(VDisplay == 720)       ModeIndex = ModeIndex_1280x720[Depth];
 		else if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth];
 	     }
@@ -1270,6 +1304,15 @@
 {
    unsigned char cr5f, temp1, temp2;
 
+   /* 661 and newer: NEVER write non-zero to SR11[7:4] */
+   /* (SR11 is used for DDC and in enable/disablebridge) */
+   SiS_Pr->SiS_SensibleSR11 = FALSE;
+   SiS_Pr->SiS_MyCR63 = 0x63;
+   if(HwInfo->jChipType >= SIS_661) {
+      SiS_Pr->SiS_SensibleSR11 = TRUE;
+      SiS_Pr->SiS_MyCR63 = 0x53;
+   }
+
    /* You should use the macros, not these flags directly */
 
    SiS_Pr->SiS_SysFlags = 0;
@@ -2293,7 +2336,7 @@
 
      modeflag = SiS_Pr->CModeFlag;
 
-     for(i=0,j=0;i<=07;i++,j++) {
+     for(i=0,j=0;i<=7;i++,j++) {
         SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]);
      }
      for(j=0x10;i<=10;i++,j++) {
@@ -2311,7 +2354,7 @@
 
      temp = (SiS_Pr->CCRT1CRTC[16] & 0x01) << 5;
      if(modeflag & DoubleScanMode) temp |= 0x80;
-     SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,temp);
+     SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,temp);
 
   } else {
 
@@ -2373,7 +2416,7 @@
 
         temp = ((LCDACRT1Ptr+ResIndex)->CR[16] & 0x01) << 5;
         if(modeflag & DoubleScanMode) temp |= 0x80;
-        SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,temp);
+        SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,temp);
 
 #endif
 
@@ -2381,7 +2424,7 @@
 
         index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
 
-        for(i=0,j=0;i<=07;i++,j++) {
+        for(i=0,j=0;i<=7;i++,j++) {
           SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]);
         }
         for(j=0x10;i<=10;i++,j++) {
@@ -2399,7 +2442,7 @@
 
         temp = ((SiS_Pr->SiS_CRT1Table[index].CR[16]) & 0x01) << 5;
         if(modeflag & DoubleScanMode)  temp |= 0x80;
-        SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,temp);
+        SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,temp);
 
      }
   }
@@ -3160,39 +3203,33 @@
         SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x6c);
      }
 #if 0   /* What is SR0E[D5:6]? */
+        /* These are in the CRT1 table, and we set by CRT1CRTC */
      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(ModeNo > 0x13) {
+	      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;
+	         }
+	         if(resinfo == SIS_RI_1152x864) {
+		    data = 0x40;
+	         }
+	         if(resinfo == SIS_RI_1400x1050) { /* TW */
+		    data = 0x60;
+	         }
 	      }
 	   }
 	}
@@ -3445,12 +3482,12 @@
 static void
 SiS_HandleCRT1(SiS_Private *SiS_Pr)
 {
-  SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x63,0xbf);
+  SiS_SetRegAND(SiS_Pr->SiS_P3d4,SiS_Pr->SiS_MyCR63,0xbf);
 #if 0
   if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x15) & 0x01)) {
      if((SiS_GetReg(SiS_Pr->SiS_P3c4,0x15) & 0x0a) ||
         (SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x01)) {
-        SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x63,0x40);
+        SiS_SetRegOR(SiS_Pr->SiS_P3d4,SiS_Pr->SiS_MyCR63,0x40);
      }
   }
 #endif
@@ -3546,7 +3583,7 @@
    USHORT  ModeIdIndex;
    UCHAR  *ROMAddr  = HwInfo->pjVirtualRomBase;
    SISIOADDRESS BaseAddr = HwInfo->ulIOAddress;
-   unsigned char backupreg=0, tempr1, tempr2;
+   unsigned char backupreg=0;
 #ifndef LINUX_XF86
    USHORT  KeepLockReg;
 
@@ -3559,9 +3596,7 @@
    }
 
    SiSInitPtr(SiS_Pr, HwInfo);
-
    SiSRegInit(SiS_Pr, BaseAddr);
-
    SiS_GetSysFlags(SiS_Pr, HwInfo);
 
 #ifdef LINUX_XF86
@@ -3571,25 +3606,16 @@
          SiS_Pr->SiS_VGAINFO = 0x11;
 
    SiSInitPCIetc(SiS_Pr, HwInfo);
-
    SiSSetLVDSetc(SiS_Pr, HwInfo);
-
    SiSDetermineROMUsage(SiS_Pr, HwInfo);
 
-   if(!SiS_Pr->UseCustomMode) {
-      ModeNo = ((ModeNo & 0x80) << 8) | (ModeNo & 0x7f);
-   }
+   SiS_Pr->SiS_flag_clearbuffer = 0;
 
-#ifdef LINUX_XF86
-   /* We never clear the buffer in X */
-   ModeNo |= 0x8000;
+   if(!SiS_Pr->UseCustomMode) {
+#ifndef LINUX_XF86
+      if(!(ModeNo & 0x80)) SiS_Pr->SiS_flag_clearbuffer = 1;
 #endif
-
-   if(ModeNo & 0x8000) {
-     	ModeNo &= 0x7fff;
-     	SiS_Pr->SiS_flag_clearbuffer = 0;
-   } else {
-     	SiS_Pr->SiS_flag_clearbuffer = 1;
+      ModeNo &= 0x7f;
    }
 
 #ifndef LINUX_XF86
@@ -3608,15 +3634,19 @@
    SiS_GetVBType(SiS_Pr, HwInfo);
 
    /* 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) {
+	 if(ROMAddr && SiS_Pr->SiS_UseROM) {
+	    if(HwInfo->jChipType < SIS_330) {
                temp = ROMAddr[VB310Data_1_2_Offset];
 	       temp |= 0x40;
-               SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp);
-            }
+	       SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp);
+            } else if(HwInfo->jChipType >= SIS_661) {
+	       temp = ROMAddr[0x7e];
+	       if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x7b) >= 100) temp |= 0x40;
+	       SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp);
+	    }
 	 }
 	 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10);
 
@@ -3652,11 +3682,15 @@
       }
 #endif
 
-      if(IS_SIS650) {
-         if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
+      if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
+         if(IS_SIS650) {
 	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
 	    if(IS_SIS651) SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x20);
 	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
+	 } else if(IS_SIS661741660760) {
+	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
+	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
+	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x3a,0xef);
 	 }
       }
    }
@@ -3712,14 +3746,6 @@
 
 	 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);
@@ -3727,7 +3753,7 @@
             }
 	 }
 
-	 if(tempr1 & SetCRT2ToLCD) {
+	 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD) {
 	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc);
 	 }
       } else if((HwInfo->jChipType == SIS_630) ||
@@ -3804,7 +3830,7 @@
    UCHAR  *ROMAddr  = HwInfo->pjVirtualRomBase;
    SISIOADDRESS BaseAddr = HwInfo->ulIOAddress;
    UShort  ModeNo   = 0;
-   unsigned char tempr1, tempr2, backupreg=0;
+   unsigned char backupreg=0;
    SISPtr  pSiS     = SISPTR(pScrn);
 #ifdef SISDUALHEAD
    SISEntPtr pSiSEnt = pSiS->entityPrivate;
@@ -3836,17 +3862,11 @@
    }
 
    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 */
@@ -3907,12 +3927,17 @@
    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) {
+         if(ROMAddr && SiS_Pr->SiS_UseROM) {
+	    if(HwInfo->jChipType < SIS_330) {
                temp = ROMAddr[VB310Data_1_2_Offset];
 	       temp |= 0x40;
                SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp);
             }
+	    if(HwInfo->jChipType > SIS_330) {
+	       temp = ROMAddr[0x7e];
+	       if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x7b) >= 100) temp |= 0x40;
+	       SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp);
+	    }
 	 }
 	 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10);
 
@@ -3969,15 +3994,7 @@
 
 	 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) {
+	 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD) {
 	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc);
 	 }
       } else if((HwInfo->jChipType == SIS_630) ||
@@ -4035,17 +4052,11 @@
    }
 
    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 */
@@ -4091,11 +4102,15 @@
       }
 #endif
 
-      if(IS_SIS650) {
-         if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
+      if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
+         if(IS_SIS650) {
 	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
 	    if(IS_SIS651) SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x20);
 	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
+	 } else if(IS_SIS661741660760) {
+	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
+	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
+	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x3a,0xef);
 	 }
       }
    }

Index: init.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/init.h,v
retrieving revision 1.1.4.3
retrieving revision 1.1.4.4
diff -u -d -r1.1.4.3 -r1.1.4.4
--- a/init.h	20 Dec 2003 00:28:27 -0000	1.1.4.3
+++ b/init.h	23 Feb 2004 21:35:45 -0000	1.1.4.4
@@ -1,37 +1,55 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.h,v 1.38 2003/12/16 17:59:08 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.h,v 1.46 2004/01/27 11:58:27 twini Exp $ */
 /*
  * Data and prototypes for init.c
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * If distributed as part of the linux kernel, the contents of this file
- * is entirely covered by the GPL.
+ * If distributed as part of the Linux kernel, the following license terms
+ * apply:
  *
- * Otherwise, the following terms apply:
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation; either version 2 of the named License,
+ * * or any later version.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Otherwise, the following license terms apply:
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * * Redistribution and use in source and binary forms, with or without
+ * * modification, are permitted provided that the following conditions
+ * * are met:
+ * * 1) Redistributions of source code must retain the above copyright
+ * *    notice, this list of conditions and the following disclaimer.
+ * * 2) Redistributions in binary form must reproduce the above copyright
+ * *    notice, this list of conditions and the following disclaimer in the
+ * *    documentation and/or other materials provided with the distribution.
+ * * 3) All advertising materials mentioning features or use of this software
+ * *    must display the following acknowledgement: "This product includes
+ * *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * * 4) The name of the author may not be used to endorse or promote products
+ * *    derived from this software without specific prior written permission.
+ * *
+ * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
  *
- * Based on code by Silicon Intergrated Systems
- *
  */
 
 #ifndef _INIT_
@@ -740,6 +758,7 @@
 	0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00
 };
 
+#if 0
 static const UCHAR SiS_HiTVTextTiming[] = {
         0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65,
 	0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
@@ -750,6 +769,7 @@
         0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96,
 	0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00
 };
+#endif
 
 static const UCHAR SiS_HiTVGroup3Data[] = {
         0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f,
@@ -773,6 +793,7 @@
 	0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
 };
 
+#if 0
 static const UCHAR SiS_HiTVGroup3Text[] = {
         0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7,
 	0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6,
@@ -783,6 +804,7 @@
 	0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75,
 	0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
 };
+#endif
 
 static const UCHAR SiS_NTSCPhase[]    = {0x21,0xed,0xba,0x08};
 static const UCHAR SiS_PALPhase[]     = {0x2a,0x05,0xe3,0x00};
@@ -796,7 +818,7 @@
 static const UCHAR SiS_SpecialPhaseM[]= {0x1e,0x83,0x0a,0xe0};
 static const UCHAR SiS_SpecialPhaseJ[]= {0x25,0xd4,0xfd,0x5e};
 
-static const SiS_TVDataStruct  SiS_StPALData[]=
+static const SiS_TVDataStruct  SiS_StPALData[] =
 {
  {    1,   1, 864, 525,1270, 400, 100,   0, 760,0xf4,0xff,0x1c,0x22},
  {    1,   1, 864, 525,1270, 350, 100,   0, 760,0xf4,0xff,0x1c,0x22},
@@ -816,10 +838,11 @@
 /*{  36,  25,1060, 648,1316, 530, 438,   0, 438,0xeb,0x05,0x25,0x16},*//* 800x600, 400x300 */
  {   36,  25,1060, 648,1270, 530, 438,   0, 438,0xeb,0x05,0x25,0x16},  /* 800x600, 400x300 - better */
  {    3,   2,1080, 619,1270, 540, 438,   0, 438,0xf3,0x00,0x1d,0x20},  /* 720x576 */
- {    1,   1,1170, 821,1270, 520, 686,   0, 686,0xF3,0x00,0x1D,0x20}   /* 1024x768 */
+ {    1,   1,1170, 821,1270, 520, 686,   0, 686,0xF3,0x00,0x1D,0x20},  /* 1024x768 */
+ {    1,   1,1170, 821,1270, 520, 686,   0, 686,0xF3,0x00,0x1D,0x20}   /* 1024x768 (for NTSC equ) */
 };
 
-static const SiS_TVDataStruct  SiS_StNTSCData[]=
+static const SiS_TVDataStruct  SiS_StNTSCData[] =
 {
  {    1,   1, 858, 525,1270, 400,  50,   0, 760,0xf1,0x04,0x1f,0x18},
  {    1,   1, 858, 525,1270, 350,  50,   0, 640,0xf1,0x04,0x1f,0x18},
@@ -828,7 +851,7 @@
  {    1,   1, 858, 525,1270, 480,   0,   0, 760,0xf1,0x04,0x1f,0x18}
 };
 
-static const SiS_TVDataStruct  SiS_ExtNTSCData[]=
+static const SiS_TVDataStruct  SiS_ExtNTSCData[] =
 {
  {  143,  65, 858, 443,1270, 440, 171,   0, 171,0xf1,0x04,0x1f,0x18},    /* 640x400, 320x200 */
  {   88,  35, 858, 393,1270, 440, 171,   0, 171,0xf1,0x04,0x1f,0x18},
@@ -836,37 +859,78 @@
  {  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 */
+ {  143,  76, 836, 523,1270, 440,   0, 128,   0,0xee,0x0c,0x22,0x08},    /* 720x480 - BETTER (from 300 series) */
+/*{  65,  64,1056, 791,1270, 480, 638,   0,   0,0xEE,0x0C,0x22,0x08} */  /* 1024x768 (525i) */
+ {    1,   1,1100, 811,1412, 440,   0, 128,   0,0xee,0x0c,0x22,0x08},    /* 1024x768 (525i) CORRECTED */
+ {   65,  64,1056, 791,1270, 480, 455,   0,   0,0x00,0x00,0x00,0x00}     /* 1024x768 (525p) */
 };
 
-static const SiS_TVDataStruct  SiS_St2HiTVData[]=
+static const SiS_TVDataStruct  SiS_StHiTVData[] =  /* Slave + TVSimu */
+{
+ {    1,   1, 0x37c,0x233,0x2b2,0x320,    0,  0, 0, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x37c,0x233,0x2b2,0x2bc,    0,  0, 0, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x37c,0x233,0x2b2,0x320,    0,  0, 0, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x37c,0x233,0x2b2,0x2bc,    0,  0, 0, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x37c,0x233,0x2b2,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
+ {    8,   5, 0x41a,0x2ab,0x670,0x3c0,0x150,128, 0, 0x00,0x00,0x00,0x00}
+};
+
+static const SiS_TVDataStruct  SiS_St2HiTVData[] = /* Slave */
 {
  {    3,   1, 0x348,0x1e3,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
  {    1,   1, 0x37c,0x233,0x2b2,0x2bc, 	  0,  0, 0, 0x00,0x00,0x00,0x00},
  {    3,   1, 0x348,0x1e3,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
- {    1,   1, 0x3e8,0x233,0x311,0x2bc,    0,  0, 0, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x37c,0x233,0x2b2,0x2bc,    0,  0, 0, 0x00,0x00,0x00,0x00},
  {    5,   2, 0x348,0x233,0x670,0x3c0,0x08d,128, 0, 0x00,0x00,0x00,0x00},
  {    8,   5, 0x41a,0x2ab,0x670,0x3c0,0x17c,128, 0, 0x00,0x00,0x00,0x00}
 };
 
-static const SiS_TVDataStruct  SiS_ExtHiTVData[]=
+static const SiS_TVDataStruct  SiS_ExtHiTVData[] =
 {
  {    6,   1, 0x348,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
  {    3,   1, 0x3c0,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
- {    3,   1, 0x348,0x1e3,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
+ {    6,   1, 0x348,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
  {    3,   1, 0x3c0,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
  {    5,   1, 0x348,0x233,0x670,0x3c0,0x166,128, 0, 0x00,0x00,0x00,0x00},  /* 640x480   */
  {   16,   5, 0x41a,0x2ab,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00},  /* 800x600   */
  {   25,  12, 0x4ec,0x353,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},  /* 1024x768  */
  {    5,   4, 0x627,0x464,0x670,0x3c0,0x128,  0, 0, 0x00,0x00,0x00,0x00},  /* 1280x1024 */
- {    4,   1, 0x41a,0x233,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00},  /* 800x480   */
+ {    4,   1, 0x41a,0x233,0x60c,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00},  /* 800x480   */
  {    5,   2, 0x578,0x293,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},  /* 1024x576  */
  {    8,   5, 0x6d6,0x323,0x670,0x3c0,0x128,  0, 0, 0x00,0x00,0x00,0x00}   /* 1280x720  */
 };
 
+static const SiS_TVDataStruct  SiS_St525pData[] =
+{
+ {    1,   1, 0x6b4,0x20d,0x4f6,0x190,   50,  0, 0x2f8, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x6b4,0x20d,0x4f6,0x15e,   50,  0, 0x280, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x6b4,0x20d,0x4f6,0x190,   50,  0, 0x2f8, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x6b4,0x20d,0x4f6,0x15e,   50,  0, 0x280, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x6b4,0x20d,0x4f6,0x1e0,    0,  0, 0x2f8, 0x00,0x00,0x00,0x00}
+};
+
+static const SiS_TVDataStruct  SiS_St750pData[] =
+{
+ {    1,   1, 0x672,0x2ee,0x500,0x190,   50,  0, 0x2f8, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x672,0x2ee,0x500,0x15e,   50,  0, 0x280, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x672,0x2ee,0x500,0x190,    0,  0, 0x2d0, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x672,0x2ee,0x500,0x15e,    0,  0, 0x2d0, 0x00,0x00,0x00,0x00},
+ {    1,   1, 0x672,0x2ee,0x500,0x1e0,    0,  0, 0x2f8, 0x00,0x00,0x00,0x00}
+};
+
+static const SiS_TVDataStruct  SiS_Ext750pData[] =
+{
+ {    3,   1, 0x3a7,0x1d6,0x500,0x2a8,   50,  0,     0, 0x00,0x00,0x00,0x00},
+ {   24,   7, 0x3a7,0x1a4,0x500,0x2a8,   50,  0,     0, 0x00,0x00,0x00,0x00},
+ {    3,   1, 0x3a7,0x1d6,0x500,0x2a8,   50,  0,     0, 0x00,0x00,0x00,0x00},
+ {   24,   7, 0x3a7,0x1a4,0x500,0x2a8,   50,  0,     0, 0x00,0x00,0x00,0x00},
+ {   99,  32, 0x320,0x1fe,0x500,0x2d0,   50,  0,     0, 0x00,0x00,0x00,0x00},  /* 640x480   */
+ {    5,   4, 0x5d8,0x29e,0x500,0x2a8,   50,  0,     0, 0x00,0x00,0x00,0x00},  /* 800x600   */
+ {    2,   1, 0x35a,0x1f7,0x4f6,0x1e0,    0,128,     0, 0x00,0x00,0x00,0x00},  /* 720x480   */
+ {   68,  64, 0x55f,0x346,0x500,0x2a8,0x27e,  0,     0, 0x00,0x00,0x00,0x00},  /* 1024x768  */
+};
+
 static const SiS_LCDDataStruct  SiS_LCD1280x960Data[] =
 {
 	{    9,   2, 800, 500,1800,1000},
@@ -1104,7 +1168,7 @@
 };
 
 static const SiS_LVDSDataStruct  SiS_LCDA1600x1200Data_1[]=
-{ /* Clevo (Temporary data)  */
+{ /* Clevo, 651+301C */
 	{1200, 450, 2048,1250},
 	{1200, 400, 2048,1250},
 	{1280, 450, 2048,1250},
@@ -1114,14 +1178,16 @@
 	{1584, 818, 2048,1250},
 	{1688,1066, 2048,1250},
 	{1688,1066, 2048,1250},
-	{2048,1250, 2048,1250}   /* this should be correct */
 #if 0
+	{2048,1250, 2048,1250}   /* this should be correct */
+#endif
+#if 1
 	{2160,1250, 2048,1250}   /* ? */
 #endif
 };
 
 static const SiS_LVDSDataStruct  SiS_LCDA1600x1200Data_2[]=
-{ /* Clevo (Temporary data. Seems invalid.) */
+{ /* Clevo, 651+301C */
 	{2160,1250, 2160,1250},
 	{2160,1250, 2160,1250},
 	{2160,1250, 2160,1250},

Index: init301.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c,v
retrieving revision 1.1.4.3
retrieving revision 1.1.4.4
diff -u -d -r1.1.4.3 -r1.1.4.4
--- a/init301.c	20 Dec 2003 00:28:27 -0000	1.1.4.3
+++ b/init301.c	23 Feb 2004 21:35:45 -0000	1.1.4.4
@@ -1,36 +1,60 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c,v 1.59 2003/12/16 17:35:05 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c,v 1.69 2004/01/23 22:29:02 twini Exp $ */
 /*
  * 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
+ *     SiS 315/550/650/M650/651/661FX/M661xX/740/741/M741/330/660/M660/760/M760
  * (Universal module for Linux kernel framebuffer and XFree86 4.x)
  *
- * Copyright 2002, 2003 by Thomas Winischhofer <thomas at winischhofer.net>
[...3591 lines suppressed...]
   } else {
      if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) index += 2;
@@ -12322,7 +12538,7 @@
   UCHAR  *ROMAddr = HwInfo->pjVirtualRomBase;
   USHORT index,i,j,temp,romptr=0;
 
-  if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr) return;
+  if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) return;
 
   if(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSetNTSCJ | TVSetPALM | TVSetPALN)) return;
 
@@ -12363,7 +12579,7 @@
   UCHAR  *ROMAddr = HwInfo->pjVirtualRomBase;
   USHORT index,temp,i,j,romptr=0;
 
-  if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSCART | SetCRT2ToYPbPr)) return;
+  if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSCART | SetCRT2ToHiVision | SetCRT2ToYPbPr525750)) return;
 
   if((ROMAddr) && SiS_Pr->SiS_UseROM) {
      if(!(ROMAddr[0x238] & 0x01)) return;

Index: init301.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/init301.h,v
retrieving revision 1.1.4.3
retrieving revision 1.1.4.4
diff -u -d -r1.1.4.3 -r1.1.4.4
--- a/init301.h	20 Dec 2003 00:28:27 -0000	1.1.4.3
+++ b/init301.h	23 Feb 2004 21:35:45 -0000	1.1.4.4
@@ -1,37 +1,55 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.h,v 1.36 2003/12/16 17:59:08 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.h,v 1.42 2004/01/27 11:58:27 twini Exp $ */
 /*
  * Data and prototypes for init301.c
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * If distributed as part of the linux kernel, the contents of this file
- * is entirely covered by the GPL.
+ * If distributed as part of the Linux kernel, the following license terms
+ * apply:
  *
- * Otherwise, the following terms apply:
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation; either version 2 of the named License,
+ * * or any later version.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Otherwise, the following license terms apply:
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * * Redistribution and use in source and binary forms, with or without
+ * * modification, are permitted provided that the following conditions
+ * * are met:
+ * * 1) Redistributions of source code must retain the above copyright
+ * *    notice, this list of conditions and the following disclaimer.
+ * * 2) Redistributions in binary form must reproduce the above copyright
+ * *    notice, this list of conditions and the following disclaimer in the
+ * *    documentation and/or other materials provided with the distribution.
+ * * 3) All advertising materials mentioning features or use of this software
+ * *    must display the following acknowledgement: "This product includes
+ * *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * * 4) The name of the author may not be used to endorse or promote products
+ * *    derived from this software without specific prior written permission.
+ * *
+ * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
  *
- * Based on code by Silicon Intergrated Systems 
- *
  */
 
 #ifndef  _INIT301_
@@ -68,34 +86,34 @@
 
 const UCHAR SiS_YPbPrTable[3][64] = {
   {
-    0x17, 0x1d, 0x03, 0x09, 0x05, 0x06, 0x0c, 0x0c,
-    0x94, 0x49, 0x01, 0x0a, 0x06, 0x0d, 0x04, 0x0a,
-    0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x1b,
-    0x0c, 0x50, 0x00, 0x97, 0x00, 0xd4, 0x4a, 0x17,
-    0x7d, 0x05, 0x4b, 0x00, 0x00, 0xe2, 0x00, 0x02,
-    0x03, 0x0a, 0x65, 0x9d, 0x08, 0x92, 0x8f, 0x40,
-    0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x14, 0x53,
-    0x00, 0x40, 0x44, 0x00, 0xdb, 0x02, 0x3b, 0x00
+    0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c,
+    0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a,
+    0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b,
+    0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17,
+    0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02,
+    0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40,
+    0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x53,
+    0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00
   },
   {
-    0x1d, 0x1d, 0x06, 0x09, 0x0b, 0x0c, 0x0c, 0x0c,
-    0x98, 0x0a, 0x01, 0x0d, 0x06, 0x0d, 0x04, 0x0a,
-    0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x3f,
-    0x0c, 0x50, 0xb2, 0x2e, 0x16, 0xb5, 0xf4, 0x03,
-    0x7d, 0x11, 0x7d, 0xea, 0x30, 0x36, 0x18, 0x96,
-    0x21, 0x0a, 0x58, 0xee, 0x42, 0x92, 0x0f, 0x40,
-    0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x04, 0xf3,
-    0x00, 0x40, 0x11, 0x00, 0xfc, 0xff, 0x32, 0x00
+    0x1d,0x11,0x06,0x09,0x0b,0x0c,0x0c,0x0c,
+    0x98,0x0a,0x01,0x0d,0x06,0x0d,0x04,0x0a,
+    0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
+    0x0c,0x50,0xb2,0x9f,0x16,0x59,0x4f,0x13,
+    0xad,0x11,0xad,0x1d,0x40,0x8a,0x3d,0xb8,
+    0x51,0x5e,0x60,0x49,0x7d,0x92,0x0f,0x40,
+    0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x4b,
+    0x43,0x41,0x11,0x00,0xfc,0xff,0x32,0x00
   },
   {
-    0x13, 0x1d, 0xe8, 0x09, 0x09, 0xed, 0x0c, 0x0c,
-    0x98, 0x0a, 0x01, 0x0c, 0x06, 0x0d, 0x04, 0x0a,
-    0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x3f,
-    0xed, 0x50, 0x70, 0x9f, 0x16, 0x59, 0x2b, 0x13,
-    0x27, 0x0b, 0x27, 0xfc, 0x30, 0x27, 0x1c, 0xb0,
-    0x4b, 0x4b, 0x6f, 0x2f, 0x63, 0x92, 0x0f, 0x40,
-    0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x14, 0x2a,
-    0x00, 0x40, 0x11, 0x00, 0xfc, 0xff, 0x32, 0x00
+    0x13,0x1d,0xe8,0x09,0x09,0xed,0x0c,0x0c,
+    0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a,
+    0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
+    0xed,0x50,0x70,0x9f,0x16,0x59,0x2b,0x13,
+    0x27,0x0b,0x27,0xfc,0x30,0x27,0x1c,0xb0,
+    0x4b,0x4b,0x6f,0x2f,0x63,0x92,0x0f,0x40,
+    0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x27,
+    0x00,0x40,0x11,0x00,0xfc,0xff,0x32,0x00
   }
 };
 
@@ -139,7 +157,7 @@
     0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E
 };
 
-static const UCHAR SiS_Part2CLVX_3[] = {  /* NTSC */
+static const UCHAR SiS_Part2CLVX_3[] = {  /* NTSC, 525i, 525p */
     0xE0,0x01,
     0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D,0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D,
     0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C,0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C,
@@ -177,6 +195,25 @@
     0xFF,0xFF
 };
 
+static const UCHAR SiS_Part2CLVX_5[] = {   /* 750p */
+    0x00,0x03,
+    0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D,
+    0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D,
+    0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E,
+    0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04,
+    0xFF,0xFF
+};
+
+static const UCHAR SiS_Part2CLVX_6[] = {   /* 1080i */
+    0x00,0x04,
+    0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E,0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D,
+    0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x1D /* 0x7D? */ ,0x7C,0x0D,0x18,0x7F,
+    0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1B,0x02,
+    0xFF,0xFF,
+};
+
+
 #ifdef SIS315H
 /* 661 et al LCD data structure */
 static const UCHAR SiS_LCDStruct661[] = {

Index: initdef.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/initdef.h,v
retrieving revision 1.1.4.2
retrieving revision 1.1.4.3
diff -u -d -r1.1.4.2 -r1.1.4.3
--- a/initdef.h	6 Dec 2003 13:24:25 -0000	1.1.4.2
+++ b/initdef.h	23 Feb 2004 21:35:45 -0000	1.1.4.3
@@ -1,37 +1,55 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/initdef.h,v 1.26 2003/11/29 12:08:02 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/initdef.h,v 1.32 2004/01/23 22:29:03 twini Exp $ */
 /*
  * Global definitions for init.c and init301.c
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * If distributed as part of the linux kernel, the contents of this file
- * is entirely covered by the GPL.
+ * If distributed as part of the Linux kernel, the following license terms
+ * apply:
  *
- * Otherwise, the following terms apply:
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation; either version 2 of the named License,
+ * * or any later version.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Otherwise, the following license terms apply:
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * * Redistribution and use in source and binary forms, with or without
+ * * modification, are permitted provided that the following conditions
+ * * are met:
+ * * 1) Redistributions of source code must retain the above copyright
+ * *    notice, this list of conditions and the following disclaimer.
+ * * 2) Redistributions in binary form must reproduce the above copyright
+ * *    notice, this list of conditions and the following disclaimer in the
+ * *    documentation and/or other materials provided with the distribution.
+ * * 3) All advertising materials mentioning features or use of this software
+ * *    must display the following acknowledgement: "This product includes
+ * *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * * 4) The name of the author may not be used to endorse or promote products
+ * *    derived from this software without specific prior written permission.
+ * *
+ * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
  *
- * Based on code by Silicon Integrated Systems
- *
  */
 
 #ifndef _INITDEF_
@@ -76,23 +94,26 @@
 #define SetCRT2ToSCART          0x0010
 #define SetCRT2ToLCD            0x0020
 #define SetCRT2ToRAMDAC         0x0040
-#define SetCRT2ToYPbPr	        0x0080	/* Needs change in sis_vga.c if changed (GPIO) */
-#define SetCRT2ToTV             (SetCRT2ToYPbPr | SetCRT2ToSCART | SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)
-#define SetCRT2ToTVNoYPbPr  	(SetCRT2ToSCART | SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)
+#define SetCRT2ToHiVision       0x0080   		/* for SiS bridge */
+#define SetCRT2ToCHYPbPr       	SetCRT2ToHiVision	/* for Chrontel   */
 #define SetNTSCTV               0x0000   /* CR 31 */
 #define SetPALTV                0x0100   		/* Deprecated here, now in TVMode */
 #define SetInSlaveMode          0x0200
 #define SetNotSimuMode          0x0400
-#define SetNotSimuTVMode        0x0400
+#define SetNotSimuTVMode        SetNotSimuMode
 #define SetDispDevSwitch        0x0800
+#define SetCRT2ToYPbPr525750    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 HotKeySwitch            0x8000
 #define SetCRT2ToLCDA           0x8000
 
+/* v-- Needs change in sis_vga.c if changed (GPIO) --v */
+#define SetCRT2ToTV             (SetCRT2ToYPbPr525750|SetCRT2ToHiVision|SetCRT2ToSCART|SetCRT2ToSVIDEO|SetCRT2ToAVIDEO)
+#define SetCRT2ToTVNoYPbPrHiVision (SetCRT2ToSCART | SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)
+#define SetCRT2ToTVNoHiVision  	(SetCRT2ToYPbPr525750 | SetCRT2ToSCART | SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)
+
 /* SiS_ModeType */
 #define ModeText                0x00
 #define ModeCGA                 0x01
@@ -123,8 +144,8 @@
 #define SupportTV1024           0x0800
 #define SupportCHTV 		0x0800
 #define Support64048060Hz       0x0800  /* Special for 640x480 LCD */
-#define SupportYPbPr            0x0010
-#define SupportYPbPr2           0x1000
+#define SupportHiVision         0x0010
+#define SupportYPbPr            0x1000  /* TODO */
 #define SupportLCD              0x0020
 #define SupportRAMDAC2          0x0040	/* All           (<= 100Mhz) */
 #define SupportRAMDAC2_135      0x0100  /* All except DH (<= 135Mhz) */
@@ -153,16 +174,20 @@
 #define TVSetPALM		0x0004
 #define TVSetPALN		0x0008
 #define TVSetCHOverScan		0x0010
+#define TVSetYPbPr525i		0x0020
+#define TVSetYPbPr525p		0x0040
+#define TVSetYPbPr750p		0x0080
+#define TVSetHiVision		0x0100  /* = 1080i, software-wise identical */
 #define TVSetTVSimuMode		0x0800
 #define TVRPLLDIV2XO		0x1000
 #define TVSetNTSC1024		0x2000
 
-/* YPbPr flag (YPbPr not supported yet) */
-#define YPbPr750                0x0001	/* 750p (must be a single bit, checked logially) */
-#define YPbPr525                0x0002	/* 525p (must be a single bit, checked logially) */
-#define YPbPrHiVision           0x0003	/* old HiVision */
-#define YPbPrModeMask           (YPbPr750 | YPbPr525 | YPbPrHiVision)
-#define YPbPrSetSVideo     	0x0004	/* (sets SVIDEO flag) */
+/* YPbPr flag (>=315, <661; converted to TVMode) */
+#define YPbPr525p               0x0001
+#define YPbPr750p               0x0002
+#define YPbPr525i               0x0004
+#define YPbPrHiVision           0x0008
+#define YPbPrModeMask           (YPbPr750p | YPbPr525p | YPbPr525i | YPbPrHiVision)
 
 /* SysFlags (to identify special versions) */
 #define SF_Is651                0x0001
@@ -198,10 +223,11 @@
    [2]    1 = PALM (if D0 = 1)
    [3]    1 = PALN (if D0 = 1)
    [4]    1 = Overscan (Chrontel only)
-   [7:5]  000  525i  (not supported yet)
+   [7:5]  (only if D2 in CR38 is set)
+          000  525i
  	  001  525p
 	  010  750p
-	  011  1080i
+	  011  1080i (or HiVision on 301, 301B)
 
    These bits are being translated to TVMode flag.
 
@@ -255,13 +281,13 @@
 /* CR38 (315 series) */
 #define EnableDualEdge 		0x01
 #define SetToLCDA		0x02   /* LCD channel A (301C/302B/30x(E)LV and 650+LVDS only) */
-#define EnableSiSYPbPr          0x04   /* YPbPr on SiS bridge (not used) */
 #define EnableCHScart           0x04   /* Scart on Ch7019 (unofficial definition - TW) */
 #define EnableCHYPbPr           0x08   /* YPbPr on Ch7019 (480i HDTV); only on 650/Ch7019 systems */
-#define EnableYPbPr750          0x08   /* Enable 750P YPbPr mode (30xLV/301C only) (not supported) */
-#define EnableYPbPr525          0x10   /* Enable 525P YPbPr mode (30xLV/301C only) (not supported) */
-#define EnableYPbPrHiVision     0x18   /* Enable HiVision (not supported) */
-#define EnableYPbPrsetSVideo    0x20   /* Enable YPbPr and set SVideo */
+#define EnableSiSYPbPr          0x08   /* Enable YPbPr mode (30xLV/301C only) */
+#define EnableYPbPr525i         0x00   /* Enable 525i YPbPr mode (30xLV/301C only) (mask 0x30) */
+#define EnableYPbPr525p         0x10   /* Enable 525p YPbPr mode (30xLV/301C only) (mask 0x30) */
+#define EnableYPbPr750p         0x20   /* Enable 750p YPbPr mode (30xLV/301C only) (mask 0x30) */
+#define EnableYPbPr1080i        0x30   /* Enable 1080i YPbPr mode (30xLV/301C only) (mask 0x30) */
 #define EnablePALM              0x40   /* 1 = Set PALM */
 #define EnablePALN              0x80   /* 1 = Set PALN */
 #define EnableNTSCJ             EnablePALM  /* Not BIOS */
@@ -272,6 +298,8 @@
 	  010 LVDS
 	  011 Chrontel 7019
 	  100 Conexant
+  D2      Enable YPbPr output (see CR35)
+  D[1:0]  LCDA (like before)
 */
 
 #define EnablePALMN             0x40   /* Romflag: 1 = Allow PALM/PALN */
@@ -280,6 +308,18 @@
 #define LCDPass1_1		0x01   /* LVDS only; set by driver to pass 1:1 data to LVDS output  */
 #define Enable302LV_DualLink    0x04   /* 302LV only; enable dual link */
 
+/* CR39 (661 and later)
+   D[1:0] YPbPr Aspect Ratio
+          00 4:3 letterbox
+	  01 4:3
+	  10 16:9
+	  11 4:3
+*/
+
+/* CR3B (651+301C)
+   D[1:0] YPbPr Aspect Ratio
+          ?
+*/
 
 /* CR79 (315/330 series only; not 661 and later)
    [3-0] Notify driver
@@ -345,6 +385,8 @@
 #define Panel_Custom		0x0f
 #define Panel_Barco1366         0x10
 #define Panel_848x480		0x11
+#define Panel_1280x800		0x12    /* 661etc: 0x0c */
+#define Panel_1680x1050         0x13    /* 661etc: 0x0d */
 
 /* Index in ModeResInfo table */
 #define SIS_RI_320x200    0
@@ -420,6 +462,7 @@
 #define HiTVVCLK                0x03   /* Index relative to TVCLKBASE */
 #define HiTVSimuVCLK            0x04   /* Index relative to TVCLKBASE */
 #define HiTVTextVCLK            0x05   /* Index relative to TVCLKBASE */
+#define YPbPr750pVCLK		0x0f   /* NOT relative to TVCLKBASE ! */
 
 /* ------------------------------ */
 

Index: oem300.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/oem300.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/oem300.h	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/oem300.h	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,36 +1,55 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/oem300.h,v 1.11 2003/10/30 18:53:42 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/oem300.h,v 1.14 2004/01/23 22:29:03 twini Exp $ */
 /*
  * OEM Data for 300 series
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * If distributed as part of the linux kernel, the contents of this file
- * is entirely covered by the GPL.
+ * If distributed as part of the Linux kernel, the following license terms
+ * apply:
  *
- * Otherwise, the following terms apply:
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation; either version 2 of the named License,
+ * * or any later version.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Otherwise, the following license terms apply:
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * * Redistribution and use in source and binary forms, with or without
+ * * modification, are permitted provided that the following conditions
+ * * are met:
+ * * 1) Redistributions of source code must retain the above copyright
+ * *    notice, this list of conditions and the following disclaimer.
+ * * 2) Redistributions in binary form must reproduce the above copyright
+ * *    notice, this list of conditions and the following disclaimer in the
+ * *    documentation and/or other materials provided with the distribution.
+ * * 3) All advertising materials mentioning features or use of this software
+ * *    must display the following acknowledgement: "This product includes
+ * *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * * 4) The name of the author may not be used to endorse or promote products
+ * *    derived from this software without specific prior written permission.
+ * *
+ * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
  *
- * Based on code by Silicon Intergrated Systems
- *
  */
 
 const UCHAR SiS300_OEMTVDelay301[8][4] =

Index: oem310.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/oem310.h,v
retrieving revision 1.1.4.2
retrieving revision 1.1.4.3
diff -u -d -r1.1.4.2 -r1.1.4.3
--- a/oem310.h	20 Dec 2003 00:28:27 -0000	1.1.4.2
+++ b/oem310.h	23 Feb 2004 21:35:45 -0000	1.1.4.3
@@ -1,37 +1,55 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/oem310.h,v 1.19 2003/12/16 17:35:06 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/oem310.h,v 1.24 2004/01/23 22:29:03 twini Exp $ */
 /*
  * OEM Data for 315/330 series
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * If distributed as part of the linux kernel, the contents of this file
- * is entirely covered by the GPL.
+ * If distributed as part of the Linux kernel, the following license terms
+ * apply:
  *
- * Otherwise, the following terms apply:
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation; either version 2 of the named License,
+ * * or any later version.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Otherwise, the following license terms apply:
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * * Redistribution and use in source and binary forms, with or without
+ * * modification, are permitted provided that the following conditions
+ * * are met:
+ * * 1) Redistributions of source code must retain the above copyright
+ * *    notice, this list of conditions and the following disclaimer.
+ * * 2) Redistributions in binary form must reproduce the above copyright
+ * *    notice, this list of conditions and the following disclaimer in the
+ * *    documentation and/or other materials provided with the distribution.
+ * * 3) All advertising materials mentioning features or use of this software
+ * *    must display the following acknowledgement: "This product includes
+ * *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * * 4) The name of the author may not be used to endorse or promote products
+ * *    derived from this software without specific prior written permission.
+ * *
+ * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
  *
- * Based on code by Silicon Intergrated Systems 
- *
  */
 
 static const UCHAR SiS310_LCDDelayCompensation_301[] =	    		/* 301 */
@@ -54,7 +72,7 @@
 };
 
 /* 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 */
+static const UCHAR SiS310_LCDDelayCompensation_650301LV[] =	   	/* 650 + 30xLV */
 {
 		 0x01,0x01,0x01,    /*   800x600 */
 		 0x01,0x01,0x01,    /*  1024x768 */
@@ -73,65 +91,7 @@
 		 0x02,0x02,0x02
 };
 
-/* 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 */
-		 0x00,0x00,0x00,    /* 1280x1024 */
-		 0x00,0x00,0x00,    /*   640x480 (unknown) */
-		 0x00,0x00,0x00,    /*  1024x600 (unknown) */
-		 0x00,0x00,0x00,    /*  1152x864 (unknown) */
-		 0x00,0x00,0x00,    /*  1280x960 (guessed) */
-		 0x00,0x00,0x00,    /*  1152x768 (unknown) */
-		 0x00,0x00,0x00,    /* 1400x1050 */
-		 0x00,0x00,0x00,    /*  1280x768  (guessed) */
-		 0x00,0x00,0x00,    /* 1600x1200 */
-		 0x00,0x00,0x00,
-		 0x00,0x00,0x00,
-		 0x00,0x00,0x00,
-		 0x00,0x00,0x00
-};
-
-static const UCHAR SiS310_LCDDelayCompensation_LVDS740[] =   	/* LVDS */
-{
-                 0x03,0x03,0x03,    /*   800x600 */
-		 0x03,0x03,0x03,    /*  1024x768 */
-		 0x03,0x03,0x03,    /* 1280x1024 */
-		 0x03,0x03,0x03,    /*   640x480 (unknown) */
-		 0x03,0x03,0x03,    /*  1024x600 (unknown) */
-		 0x03,0x03,0x03,    /*  1152x864 (unknown) */
-		 0x03,0x03,0x03,    /*  1280x960 (guessed) */
-		 0x03,0x03,0x03,    /*  1152x768 (unknown) */
-		 0x03,0x03,0x03,    /* 1400x1050 */
-		 0x03,0x03,0x03,    /*  1280x768  (guessed) */
-		 0x03,0x03,0x03,    /* 1600x1200 */
-		 0x00,0x00,0x00,
-		 0x00,0x00,0x00,
-		 0x00,0x00,0x00,
-		 0x00,0x00,0x00
-};
-
-static const UCHAR SiS310_LCDDelayCompensation_651301LV[] =	  /* M650/651 301LV */
+static const UCHAR SiS310_LCDDelayCompensation_651301LV[] =	  	/* M650/651 301LV */
 {
                  0x33,0x33,0x33,    /*   800x600 (guessed) - new: PanelType, not PanelRes ! */
 		 0x33,0x33,0x33,    /*  1024x768 */
@@ -150,7 +110,7 @@
 		 0x33,0x33,0x33
 };
 
-static const UCHAR SiS310_LCDDelayCompensation_651302LV[] =	   /* M650/651 302LV */
+static const UCHAR SiS310_LCDDelayCompensation_651302LV[] =	   	/* M650/651 302LV */
 {
                  0x33,0x33,0x33,    /*   800x600 (guessed) */
 		 0x33,0x33,0x33,    /*  1024x768 */
@@ -169,6 +129,25 @@
 		 0x33,0x33,0x33
 };
 
+static const UCHAR SiS310_LCDDelayCompensation_3xx301B[] =	   	/* 30xB,LV */
+{
+		 0x01,0x01,0x01,    /*   800x600 */
+		 0x0C,0x0C,0x0C,    /*  1024x768 */
+		 0x0C,0x0C,0x0C,    /* 1280x1024 */
+                 0x08,0x08,0x08,    /*   640x480 */
+		 0x0C,0x0C,0x0C,    /*  1024x600 (guessed) */
+		 0x0C,0x0C,0x0C,    /*  1152x864 (guessed) */
+		 0x0C,0x0C,0x0C,    /*  1280x960 (guessed) */
+		 0x0C,0x0C,0x0C,    /*  1152x768 (guessed) */
+		 0x0C,0x0C,0x0C,    /* 1400x1050 (guessed) */
+		 0x0C,0x0C,0x0C,    /*  1280x768 (guessed) */
+		 0x0C,0x0C,0x0C,    /* 1600x1200 (guessed) */
+		 0x02,0x02,0x02,
+		 0x02,0x02,0x02,
+		 0x02,0x02,0x02,
+		 0x02,0x02,0x02
+};
+
 static const UCHAR SiS310_TVDelayCompensation_301[] = 		/* 301 */
 {
 		 0x02,0x02,    /* NTSC Enhanced, Standard */
@@ -190,13 +169,6 @@
 		 0x05,0x05
 };
 
-static const UCHAR SiS310_TVDelayCompensation_LVDS[] =		/* LVDS */
-{
-		 0x0a,0x0a,
-		 0x0a,0x0a,
-		 0x0a,0x0a
-};
-
 static const UCHAR SiS310_TVDelayCompensation_651301LV[] =	/* M650, 651, 301LV */
 {
 		 0x33,0x33,
@@ -231,17 +203,30 @@
 		 0x44,0x44
 };
 
-static const UCHAR SiS310_TVAntiFlick1[3][2] =
+static const UCHAR SiS310_TVDelayCompensation_LVDS[] =		/* LVDS */
+{
+		 0x0a,0x0a,
+		 0x0a,0x0a,
+		 0x0a,0x0a
+};
+
+static const UCHAR SiS310_TVAntiFlick1[6][2] =
 {
             {0x4,0x0},
 	    {0x4,0x8},
+	    {0x0,0x0},
+	    {0x0,0x0},
+	    {0x0,0x0},
 	    {0x0,0x0}
 };
 
-static const UCHAR SiS310_TVEdge1[3][2] =
+static const UCHAR SiS310_TVEdge1[6][2] =
 {
             {0x0,0x4},
 	    {0x0,0x4},
+	    {0x0,0x0},
+	    {0x0,0x0},
+	    {0x0,0x0},
 	    {0x0,0x0}
 };
 

Index: osdef.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/osdef.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/osdef.h	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/osdef.h	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,6 +1,57 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/osdef.h,v 1.5 2003/10/30 18:53:42 twini Exp $ */
-
-/* OS depending defines */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/osdef.h,v 1.8 2004/01/23 22:29:03 twini Exp $ */
+/*
+ * OS depending defines
+ *
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
+ *
+ * If distributed as part of the Linux kernel, the following license terms
+ * apply:
+ *
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation; either version 2 of the named License,
+ * * or any later version.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Otherwise, the following license terms apply:
+ *
+ * * Redistribution and use in source and binary forms, with or without
+ * * modification, are permitted provided that the following conditions
+ * * are met:
+ * * 1) Redistributions of source code must retain the above copyright
+ * *    notice, this list of conditions and the following disclaimer.
+ * * 2) Redistributions in binary form must reproduce the above copyright
+ * *    notice, this list of conditions and the following disclaimer in the
+ * *    documentation and/or other materials provided with the distribution.
+ * * 3) All advertising materials mentioning features or use of this software
+ * *    must display the following acknowledgement: "This product includes
+ * *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * * 4) The name of the author may not be used to endorse or promote products
+ * *    derived from this software without specific prior written permission.
+ * *
+ * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
+ *		Silicon Integrated Systems, Inc. (used by permission)
+ *
+ */
 
 /* The choices are: */
 /* #define LINUX_KERNEL	 */  	/* Kernel framebuffer */

Index: sis.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h,v
retrieving revision 1.1.4.4
retrieving revision 1.1.4.5
diff -u -d -r1.1.4.4 -r1.1.4.5
--- a/sis.h	20 Dec 2003 00:28:27 -0000	1.1.4.4
+++ b/sis.h	23 Feb 2004 21:35:45 -0000	1.1.4.5
@@ -1,43 +1,48 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h,v 1.99 2003/12/16 17:45:19 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h,v 1.108 2004/01/27 11:58:27 twini Exp $ */
 /*
  * 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
- * 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.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * Authors:
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- *      Thomas Winischhofer <thomas at winischhofer.net>
- *      ?
+ * Authors:   Thomas Winischhofer <thomas at winischhofer.net>
+ *            others (old code base)
  *
  */
+
 #ifndef _SIS_H
 #define _SIS_H_
 
 /* Always unlock the registers (should be set!) */
 #define UNLOCK_ALWAYS
 
-#define SISDRIVERVERSIONYEAR    3
-#define SISDRIVERVERSIONMONTH   12
-#define SISDRIVERVERSIONDAY     15
+#define SISDRIVERVERSIONYEAR    4
+#define SISDRIVERVERSIONMONTH   1
+#define SISDRIVERVERSIONDAY     27
 #define SISDRIVERREVISION       1
 
 #define SISDRIVERIVERSION (SISDRIVERVERSIONYEAR << 16) | (SISDRIVERVERSIONMONTH << 8) \
@@ -108,6 +113,10 @@
 #define SIS_ARGB_CURSOR
 #endif
 
+#if 1				/* Include YPbPr support on SiS bridges (315 series and 661/741/760) */
+#define ENABLE_YPBPR
+#endif
+
 #ifdef SISMERGED
 #ifdef SISXINERAMA
 #define NEED_REPLIES  		/* ? */
@@ -178,29 +187,24 @@
 #define CRT2_LCD                0x00000002  /* TW: Never change the order of the CRT2_XXX entries */
 #define CRT2_TV                 0x00000004  /*     (see SISCycleCRT2Type())                       */
 #define CRT2_VGA                0x00000008
-#define CRT2_ENABLE		(CRT2_LCD | CRT2_TV | CRT2_VGA)
-#define DISPTYPE_DISP2		CRT2_ENABLE
 #define TV_NTSC                 0x00000010
 #define TV_PAL                  0x00000020
-#define TV_HIVISION             0x00000040 /* Not supported */
-#define TV_YPBPR                0x00000080 /* Not supported */
-#define TV_TYPE                 (TV_NTSC | TV_PAL | TV_HIVISION | TV_YPBPR)
+#define TV_HIVISION             0x00000040
+#define TV_YPBPR                0x00000080
 #define TV_AVIDEO               0x00000100
 #define TV_SVIDEO               0x00000200
 #define TV_SCART                0x00000400
-#define TV_INTERFACE            (TV_AVIDEO | TV_SVIDEO | TV_SCART | TV_CHSCART | TV_CHHDTV)
 #define VB_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 TV_CHYPBPR525I          0x00010000
 #define CRT1_VGA		0x00000000
 #define CRT1_LCDA		0x00020000
 #define VGA2_CONNECTED          0x00040000
 #define DISPTYPE_CRT1		0x00080000  	/* CRT1 connected and used */
-#define DISPTYPE_DISP1		DISPTYPE_CRT1
 #define VB_301                  0x00100000	/* Video bridge type */
 #define VB_301B                 0x00200000
 #define VB_302B                 0x00400000
@@ -210,14 +214,35 @@
 #define VB_301LV                0x04000000
 #define VB_302LV                0x08000000
 #define VB_301C			0x10000000
+#define SINGLE_MODE             0x20000000   	/* CRT1 or CRT2; determined by DISPTYPE_CRTx */
+#define MIRROR_MODE		0x40000000   	/* CRT1 + CRT2 identical (mirror mode) */
+#define DUALVIEW_MODE		0x80000000   	/* CRT1 + CRT2 independent (dual head mode) */
+
+/* Aliases: */
+#define CRT2_ENABLE		(CRT2_LCD | CRT2_TV | CRT2_VGA)
+#define TV_STANDARD             (TV_NTSC | TV_PAL | TV_PALM | TV_PALN | TV_NTSCJ)
+#define TV_INTERFACE            (TV_AVIDEO|TV_SVIDEO|TV_SCART|TV_HIVISION|TV_YPBPR)
+
+/* Only if TV_YPBPR is set: */
+#define TV_YPBPR525I		TV_NTSC
+#define TV_YPBPR525P		TV_PAL
+#define TV_YPBPR750P		TV_PALM
+#define TV_YPBPR1080I	        TV_PALN
+#define TV_YPBPRALL 		(TV_YPBPR525I | TV_YPBPR525P | TV_YPBPR750P | TV_YPBPR1080I)
+
+#define TV_YPBPR43LB		TV_CHSCART
+#define TV_YPBPR43		TV_CHYPBPR525I
+#define TV_YPBPR169 		(TV_CHSCART | TV_CHYPBPR525I)
+#define TV_YPBPRAR              (TV_CHSCART | TV_CHYPBPR525I)
+
 #define VB_SISBRIDGE            (VB_301|VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)
 #define VB_SISTVBRIDGE          (VB_301|VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV)
-#define VB_VIDEOBRIDGE		(VB_SISBRIDGE|VB_LVDS|VB_CHRONTEL|VB_CONEXANT)
-#define SINGLE_MODE             0x20000000   	/* CRT1 or CRT2; determined by DISPTYPE_CRTx */
+#define VB_VIDEOBRIDGE		(VB_SISBRIDGE | VB_LVDS | VB_CHRONTEL | VB_CONEXANT)
+
+#define DISPTYPE_DISP2		CRT2_ENABLE
+#define DISPTYPE_DISP1		DISPTYPE_CRT1
 #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)
 
@@ -238,6 +263,8 @@
 #define VB_LCD_640x480_2	0x00002000  	/* DSTN/FSTN */
 #define VB_LCD_640x480_3	0x00004000  	/* DSTN/FSTN */
 #define VB_LCD_848x480		0x00008000	/* LVDS only, otherwise handled as custom */
+#define VB_LCD_1280x800		0x00010000
+#define VB_LCD_1680x1050	0x00020000
 #define VB_LCD_BARCO1366        0x20000000
 #define VB_LCD_CUSTOM  		0x40000000
 #define VB_LCD_EXPANDING	0x80000000
@@ -251,6 +278,7 @@
 #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 */
+#define MISC_TVNTSC1024		0x00000008  /* Current display mode is TV NTSC/PALM/YPBPR525I 1024x768  */
 
 /* SiS6326Flags */
 #define SIS6326_HASTV		0x00000001
@@ -330,7 +358,7 @@
 #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_SUPPORT2OVL     0x00000010   /* set = 2 overlays, clear = support SWITCHCRT xv prop */
 #define SiS_SD_SUPPORTTVPOS    0x00000020   /* supports changing tv position */
 #define SiS_SD_ISDUALHEAD      0x00000040   /* Driver is in dual head mode */
 #define SiS_SD_ISMERGEDFB      0x00000080   /* Driver is in merged fb mode */
@@ -349,18 +377,29 @@
 #define SiS_SD_SUPPORTOVERSCAN 0x00100000   /* Overscan flag supported */
 #define SiS_SD_SUPPORTXVGAMMA1 0x00200000   /* Xv Gamma correction for CRT1 supported */
 #define SiS_SD_SUPPORTTV       0x00400000   /* CRT2=TV supported */
+#define SiS_SD_SUPPORTYPBPR    0x00800000   /* CRT2=YPbPr (525i, 525p, 750p, 1080i) is supported */
+#define SiS_SD_SUPPORTHIVISION 0x01000000   /* CRT2=HiVision is supported */
+#define SiS_SD_SUPPORTYPBPRAR  0x02000000   /* YPbPr aspect ratio is supported */
 
 #define SIS_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
+#define SiS_CF2_LCD          0x01
+#define SiS_CF2_TV           0x02
+#define SiS_CF2_VGA2         0x04
+#define SiS_CF2_TVPAL        0x08
+#define SiS_CF2_TVNTSC       0x10  /* + NTSC-J */
+#define SiS_CF2_TVPALM       0x20
+#define SiS_CF2_TVPALN       0x40
+#define SiS_CF2_CRT1LCDA     0x80
+#define SiS_CF2_TYPEMASK     (SiS_CF2_LCD | SiS_CF2_TV | SiS_CF2_VGA2 | SiS_CF2_CRT1LCDA)
+#define SiS_CF2_TVSPECIAL    (SiS_CF2_LCD | SiS_CF2_TV)
+#define SiS_CF2_TVSPECMASK   (SiS_CF2_TVPAL | SiS_CF2_TVNTSC | SiS_CF2_TVPALM | SiS_CF2_TVPALN)
+#define SiS_CF2_TVHIVISION   SiS_CF2_TVPAL
+#define SiS_CF2_TVYPBPR525I  SiS_CF2_TVNTSC
+#define SiS_CF2_TVYPBPR525P  (SiS_CF2_TVPAL | SiS_CF2_TVNTSC)
+#define SiS_CF2_TVYPBPR750P  SiS_CF2_TVPALM
+#define SiS_CF2_TVYPBPR1080I (SiS_CF2_TVPALM | SiS_CF2_TVPAL)
 
 /* AGP stuff for DRI */
 #define AGP_PAGE_SIZE 4096
@@ -494,6 +533,7 @@
     int			tvxpos, tvypos;
     int		      	tvxscale, tvyscale;
     int			ForceTVType;
+    unsigned long	ForceYPbPrType, ForceYPbPrAR;
     int			chtvtype;
     int                 NonDefaultPAL, NonDefaultNTSC;
     unsigned short	tvx, tvy;
@@ -502,7 +542,7 @@
     unsigned long       sistvccbase;
     unsigned char       p2_35, p2_36, p2_37, p2_38, p2_48, p2_49, p2_4a;
     unsigned char	p2_0a, p2_2f, p2_30, p2_47;
-    unsigned char       scalingp1[9], scalingp4[9];
+    unsigned char       scalingp1[9], scalingp4[9], scalingp2[64];
     unsigned short      cursorBufferNum;
     BOOLEAN		restorebyset;
     BOOLEAN		CRT1gamma, CRT1gammaGiven, CRT2gamma, XvGamma, XvGammaGiven;
@@ -518,6 +558,7 @@
     unsigned char *	FbBase1;
     unsigned long	OnScreenSize1;
     unsigned char       OldMode;
+    int			HWCursorMBufNum, HWCursorCBufNum;
 #ifdef SIS_CP
     SIS_CP_H_ENT
 #endif
@@ -595,7 +636,7 @@
     Bool		CRT1changed;
     unsigned char       oldCR17, oldCR63, oldSR1F;
     unsigned char       oldCR32, oldCR36, oldCR37;
-    unsigned char       myCR32, myCR36, myCR37;
+    unsigned char       myCR32, myCR36, myCR37, myCR63;
     unsigned char       newCR32;
     unsigned long   	VBFlags;		/* Video bridge configuration */
     unsigned long       VBFlags_backup;         /* Backup for SlaveMode-modes */
@@ -806,6 +847,7 @@
     int			newFastVram;		/* Replaces FastVram */
     int			ForceTVType;
     int                 NonDefaultPAL, NonDefaultNTSC;
+    unsigned long	ForceYPbPrType, ForceYPbPrAR;
     unsigned long       lockcalls;		/* Count unlock calls for debug */
     unsigned short	tvx, tvy;		/* Backup TV position registers */
     unsigned char	p2_01, p2_02, p2_1f, p2_20;    /* Backup TV position registers */
@@ -814,7 +856,7 @@
     unsigned long       sistvccbase;
     unsigned char       p2_35, p2_36, p2_37, p2_38, p2_48, p2_49, p2_4a;
     unsigned char	p2_0a, p2_2f, p2_30, p2_47;
-    unsigned char       scalingp1[9], scalingp4[9];
+    unsigned char       scalingp1[9], scalingp4[9], scalingp2[64];
     BOOLEAN		ForceCursorOff;
     BOOLEAN		HaveCustomModes;
     BOOLEAN		IsCustom;
@@ -882,6 +924,8 @@
     int			GammaPBriR, GammaPBriG, GammaPBriB;
     Bool		HideHWCursor;  /* Custom application */
     Bool		HWCursorIsVisible;
+    unsigned long       HWCursorBackup[16];
+    int			HWCursorMBufNum, HWCursorCBufNum;
 #ifdef SISMERGED
     Bool		MergedFB, MergedFBAuto;
     SiSScrn2Rel		CRT2Position;

Index: sis300_accel.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis300_accel.c	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis300_accel.c	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,32 +1,36 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c,v 1.23 2003/10/30 18:53:42 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c,v 1.27 2004/01/23 22:29:04 twini Exp $ */
 /*
- * 2D Acceleration for SiS300, SiS540, SiS630, SiS730, SiS530, SiS620
- *
- * Copyright Xavier Ducoin <x.ducoin at lectra.com>
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * 2D Acceleration for SiS 530, 620, 300, 540, 630, 730.
  *
- * 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.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- *      Authors:
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- *      Xavier Ducoin <x.ducoin at lectra.com>
- *      Thomas Winischhofer <thomas at winischhofer.net>
+ * Authors:   Thomas Winischhofer <thomas at winischhofer.net>
+ *	      Can-Ru Yeou, SiS Inc.
  *
  */
 
@@ -42,6 +46,7 @@
 #include "compiler.h"
 #include "xaa.h"
 #include "xaalocal.h"
+#include "xaarop.h"
 
 #include "sis.h"
 #include "sis300_accel.h"
@@ -371,46 +376,6 @@
 }
 #endif
 
-static const int sisALUConv[] =
-{
-    0x00,       /* dest = 0;            0,      GXclear,        0 */
-    0x88,       /* dest &= src;         DSa,    GXand,          0x1 */
-    0x44,       /* dest = src & ~dest;  SDna,   GXandReverse,   0x2 */
-    0xCC,       /* dest = src;          S,      GXcopy,         0x3 */
-    0x22,       /* dest &= ~src;        DSna,   GXandInverted,  0x4 */
-    0xAA,       /* dest = dest;         D,      GXnoop,         0x5 */
-    0x66,       /* dest = ^src;         DSx,    GXxor,          0x6 */
-    0xEE,       /* dest |= src;         DSo,    GXor,           0x7 */
-    0x11,       /* dest = ~src & ~dest; DSon,   GXnor,          0x8 */
-    0x99,       /* dest ^= ~src ;       DSxn,   GXequiv,        0x9 */
-    0x55,       /* dest = ~dest;        Dn,     GXInvert,       0xA */
-    0xDD,       /* dest = src|~dest ;   SDno,   GXorReverse,    0xB */
-    0x33,       /* dest = ~src;         Sn,     GXcopyInverted, 0xC */
-    0xBB,       /* dest |= ~src;        DSno,   GXorInverted,   0xD */
-    0x77,       /* dest = ~src|~dest;   DSan,   GXnand,         0xE */
-    0xFF,       /* dest = 0xFF;         1,      GXset,          0xF */
-};
-/* same ROP but with Pattern as Source */
-static const int sisPatALUConv[] =
-{
-    0x00,       /* dest = 0;            0,      GXclear,        0 */
-    0xA0,       /* dest &= src;         DPa,    GXand,          0x1 */
-    0x50,       /* dest = src & ~dest;  PDna,   GXandReverse,   0x2 */
-    0xF0,       /* dest = src;          P,      GXcopy,         0x3 */
-    0x0A,       /* dest &= ~src;        DPna,   GXandInverted,  0x4 */
-    0xAA,       /* dest = dest;         D,      GXnoop,         0x5 */
-    0x5A,       /* dest = ^src;         DPx,    GXxor,          0x6 */
-    0xFA,       /* dest |= src;         DPo,    GXor,           0x7 */
-    0x05,       /* dest = ~src & ~dest; DPon,   GXnor,          0x8 */
-    0xA5,       /* dest ^= ~src ;       DPxn,   GXequiv,        0x9 */
-    0x55,       /* dest = ~dest;        Dn,     GXInvert,       0xA */
-    0xF5,       /* dest = src|~dest ;   PDno,   GXorReverse,    0xB */
-    0x0F,       /* dest = ~src;         Pn,     GXcopyInverted, 0xC */
-    0xAF,       /* dest |= ~src;        DPno,   GXorInverted,   0xD */
-    0x5F,       /* dest = ~src|~dest;   DPan,   GXnand,         0xE */
-    0xFF,       /* dest = 0xFF;         1,      GXset,          0xF */
-};
-
 static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn,
                                 int xdir, int ydir, int rop,
                                 unsigned int planemask, int trans_color)
@@ -429,7 +394,7 @@
 	   SiSSetupSRCTrans(trans_color)
 	   SiSSetupCMDFlag(TRANSPARENT_BITBLT)
 	} else {
-	   SiSSetupROP(sisALUConv[rop])
+	   SiSSetupROP(XAACopyROP[rop])
 	}
 	if(xdir > 0) {
 	   SiSSetupCMDFlag(X_INC)
@@ -499,7 +464,7 @@
 	SiSSetupPATFG(color)
 	SiSSetupDSTRect(pSiS->scrnOffset, -1)
 	SiSSetupDSTColorDepth(pSiS->DstColor);
-	SiSSetupROP(sisPatALUConv[rop])
+	SiSSetupROP(XAAPatternROP[rop])
 	/* SiSSetupCMDFlag(PATFG) - is zero */
 }
 
@@ -657,7 +622,7 @@
 	SiSSetupPATFG(color)
 	SiSSetupDSTRect(pSiS->scrnOffset, -1)
 	SiSSetupDSTColorDepth(pSiS->DstColor);
-	SiSSetupROP(sisPatALUConv[rop])
+	SiSSetupROP(XAAPatternROP[rop])
 	SiSSetupCMDFlag(PATFG | LINE)
 }
 
@@ -746,7 +711,7 @@
 	SiSSetupStyleLow(*pattern)
 	SiSSetupStyleHigh(*(pattern+4))
 	SiSSetupStylePeriod(length-1);
-	SiSSetupROP(sisPatALUConv[rop])
+	SiSSetupROP(XAAPatternROP[rop])
 	SiSSetupPATFG(fg)
 	SiSSetupCMDFlag(LINE | LINE_STYLE)
 	if(bg != -1) {
@@ -806,7 +771,7 @@
 	SiSSetupDSTColorDepth(pSiS->DstColor);
 	SiSSetupMONOPAT(patx,paty)
 	SiSSetupPATFG(fg)
-	SiSSetupROP(sisPatALUConv[rop])
+	SiSSetupROP(XAAPatternROP[rop])
 	SiSSetupCMDFlag(PATMONO)
 	if(bg != -1) {
 	   SiSSetupPATBG(bg)
@@ -940,7 +905,7 @@
 	SiSSetupDSTColorDepth(pSiS->DstColor);
 	SiSSetupSRCXY(0,0)
 	SiSSetupSRCFG(fg)
-	SiSSetupROP(sisPatALUConv[rop])
+	SiSSetupROP(XAAPatternROP[rop])
 	SiSSetupCMDFlag(X_INC | Y_INC | COLOREXP)
 	if(bg == -1) {
 	   SiSSetupCMDFlag(TRANSPARENT)
@@ -992,7 +957,7 @@
 
 	SiSSetupDSTColorDepth(pSiS->DstColor)
 	SiSSetupDSTRect(pSiS->scrnOffset, -1)
-	SiSSetupROP(sisALUConv[rop])
+	SiSSetupROP(XAACopyROP[rop])
 	SiSSetupSRCFG(fg)
 	/* SiSSetupSRCXY(0,0) */
 
@@ -1158,7 +1123,7 @@
 	while((MMIO_IN16(pSiS->IOBase, 0x8242) & 0x1F00) != 0) {} /* WDR: == 0x10 */
 
 	SiSSetupSRCXY(0,0);
-	SiSSetupROP(sisALUConv[rop]);
+	SiSSetupROP(XAACopyROP[rop]);
 	SiSSetupSRCFG(fg);
 	SiSSetupDSTRect(pSiS->scrnOffset, -1);
 	SiSSetupDSTColorDepth(pSiS->DstColor);

Index: sis300_accel.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis300_accel.h	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis300_accel.h	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,33 +1,37 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h,v 1.16 2003/11/03 17:02:52 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h,v 1.19 2004/01/23 22:29:04 twini Exp $ */
 /*
- * 2D Acceleration for SiS300, SiS540, SiS630, SiS730, SiS530, SiS620
+ * 2D Acceleration for SiS 530, 620, 300, 540, 630, 730.
  * Definitions for the SIS engine communication
  *
- * Copyright Xavier Ducoin <x.ducoin at 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 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.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- *      Authors:
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- *      Xavier Ducoin <x.ducoin at lectra.com>
- *      Thomas Winischhofer <thomas at winischhofer.net>
+ * Authors:   Thomas Winischhofer <thomas at winischhofer.net>
+ *	      Can-Ru Yeou, SiS Inc. (code base)
  *
  */
 

Index: sis310_accel.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis310_accel.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis310_accel.c	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis310_accel.c	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,33 +1,39 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis310_accel.c,v 1.32 2003/11/06 19:10:01 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis310_accel.c,v 1.37 2004/01/27 11:58:27 twini Exp $ */
 /*
  * 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, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * Based on sis300_accel.c
- * 2003/08/18: Rewritten for using VRAM command queue (TW)
  *
  * Author:  	Thomas Winischhofer <thomas at winischhofer.net>
  *
+ * 2003/08/18: Rewritten for using VRAM command queue
+ *
  */
 
 #include "xf86.h"
@@ -38,6 +44,7 @@
 #include "compiler.h"
 #include "xaa.h"
 #include "xaalocal.h"
+#include "xaarop.h"
 
 #include "sis.h"
 #include "sis310_accel.h"
@@ -182,10 +189,10 @@
 				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 };		
+extern CARD32 SiSAlphaTextureFormats[3];
+extern CARD32 SiSTextureFormats[2];
+CARD32 SiSAlphaTextureFormats[3] = { PICT_a8,       PICT_a8r8g8b8, 0 };
+CARD32 SiSTextureFormats[2]      = { PICT_a8r8g8b8, 0 };
 #endif
 #endif
 
@@ -410,8 +417,7 @@
 	      infoPtr->SetupForCPUToScreenAlphaTexture = SiSSetupForCPUToScreenAlphaTexture;
 	      infoPtr->SubsequentCPUToScreenAlphaTexture = SiSSubsequentCPUToScreenTexture;
 	      infoPtr->CPUToScreenAlphaTextureFormats = SiSAlphaTextureFormats;
-	      infoPtr->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE |
-	      					      XAA_RENDER_NO_SRC_ALPHA;
+	      infoPtr->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE;
 
               infoPtr->SetupForCPUToScreenTexture = SiSSetupForCPUToScreenTexture;
               infoPtr->SubsequentCPUToScreenTexture = SiSSubsequentCPUToScreenTexture;
@@ -522,47 +528,6 @@
 }
 #endif
 
-static const int sisALUConv[] =
-{
-    0x00,       /* dest = 0;            0,      GXclear,        0 */
-    0x88,       /* dest &= src;         DSa,    GXand,          0x1 */
-    0x44,       /* dest = src & ~dest;  SDna,   GXandReverse,   0x2 */
-    0xCC,       /* dest = src;          S,      GXcopy,         0x3 */
-    0x22,       /* dest &= ~src;        DSna,   GXandInverted,  0x4 */
-    0xAA,       /* dest = dest;         D,      GXnoop,         0x5 */
-    0x66,       /* dest = ^src;         DSx,    GXxor,          0x6 */
-    0xEE,       /* dest |= src;         DSo,    GXor,           0x7 */
-    0x11,       /* dest = ~src & ~dest; DSon,   GXnor,          0x8 */
-    0x99,       /* dest ^= ~src ;       DSxn,   GXequiv,        0x9 */
-    0x55,       /* dest = ~dest;        Dn,     GXInvert,       0xA */
-    0xDD,       /* dest = src|~dest ;   SDno,   GXorReverse,    0xB */
-    0x33,       /* dest = ~src;         Sn,     GXcopyInverted, 0xC */
-    0xBB,       /* dest |= ~src;        DSno,   GXorInverted,   0xD */
-    0x77,       /* dest = ~src|~dest;   DSan,   GXnand,         0xE */
-    0xFF,       /* dest = 0xFF;         1,      GXset,          0xF */
-};
-
-/* same ROP but with Pattern as Source */
-static const int sisPatALUConv[] =
-{
-    0x00,       /* dest = 0;            0,      GXclear,        0 */
-    0xA0,       /* dest &= src;         DPa,    GXand,          0x1 */
-    0x50,       /* dest = src & ~dest;  PDna,   GXandReverse,   0x2 */
-    0xF0,       /* dest = src;          P,      GXcopy,         0x3 */
-    0x0A,       /* dest &= ~src;        DPna,   GXandInverted,  0x4 */
-    0xAA,       /* dest = dest;         D,      GXnoop,         0x5 */
-    0x5A,       /* dest = ^src;         DPx,    GXxor,          0x6 */
-    0xFA,       /* dest |= src;         DPo,    GXor,           0x7 */
-    0x05,       /* dest = ~src & ~dest; DPon,   GXnor,          0x8 */
-    0xA5,       /* dest ^= ~src ;       DPxn,   GXequiv,        0x9 */
-    0x55,       /* dest = ~dest;        Dn,     GXInvert,       0xA */
-    0xF5,       /* dest = src|~dest ;   PDno,   GXorReverse,    0xB */
-    0x0F,       /* dest = ~src;         Pn,     GXcopyInverted, 0xC */
-    0xAF,       /* dest |= ~src;        DPno,   GXorInverted,   0xD */
-    0x5F,       /* dest = ~src|~dest;   DPan,   GXnand,         0xE */
-    0xFF,       /* dest = 0xFF;         1,      GXset,          0xF */
-};
-
 static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn,
                                 int xdir, int ydir, int rop,
                                 unsigned int planemask, int trans_color)
@@ -587,7 +552,7 @@
 	   SiSSetupSRCTrans(trans_color)
 	   SiSSetupCMDFlag(TRANSPARENT_BITBLT)
 	} else {
-	   SiSSetupROP(sisALUConv[rop])
+	   SiSSetupROP(XAACopyROP[rop])
 	   /* Set command - not needed, both 0 */
 	   /* SiSSetupCMDFlag(BITBLT | SRCVIDEO) */
 	}
@@ -710,14 +675,14 @@
 	SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth);
 	SiSCheckQueue(16 * 1);
 	SiSSetupPATFGDSTRect(color, pSiS->scrnOffset, -1)
-	SiSSetupROP(sisPatALUConv[rop])
+	SiSSetupROP(XAAPatternROP[rop])
 	SiSSetupCMDFlag(PATFG)
         SiSSyncWP
 #else
   	SiSSetupPATFG(color)
 	SiSSetupDSTRect(pSiS->scrnOffset, -1)
 	SiSSetupDSTColorDepth(pSiS->DstColor);
-	SiSSetupROP(sisPatALUConv[rop])
+	SiSSetupROP(XAAPatternROP[rop])
 	SiSSetupCMDFlag(PATFG | pSiS->SiS310_AccelDepth)
 #endif
 }
@@ -855,7 +820,7 @@
 	SiSCheckQueue(16 * 3);
         SiSSetupLineCountPeriod(1, 1)
 	SiSSetupPATFGDSTRect(color, pSiS->scrnOffset, -1)
-	SiSSetupROP(sisPatALUConv[rop])
+	SiSSetupROP(XAAPatternROP[rop])
 	SiSSetupCMDFlag(PATFG | LINE)
         SiSSyncWP
 #else
@@ -863,7 +828,7 @@
 	SiSSetupPATFG(color)
 	SiSSetupDSTRect(pSiS->scrnOffset, -1)
 	SiSSetupDSTColorDepth(pSiS->DstColor)
-	SiSSetupROP(sisPatALUConv[rop])
+	SiSSetupROP(XAAPatternROP[rop])
 	SiSSetupCMDFlag(PATFG | LINE | pSiS->SiS310_AccelDepth)
 #endif
 }
@@ -974,7 +939,7 @@
 	SiSSetupPATFG(fg)
 #endif
 
-	SiSSetupROP(sisPatALUConv[rop])
+	SiSSetupROP(XAAPatternROP[rop])
 
 	SiSSetupCMDFlag(LINE | LINE_STYLE)
 
@@ -1054,7 +1019,7 @@
 
 	SiSSetupMONOPAT(patx,paty)
 
-	SiSSetupROP(sisPatALUConv[rop])
+	SiSSetupROP(XAAPatternROP[rop])
 
 #ifdef SISVRAMQ
         SiSSetupCMDFlag(PATMONO)
@@ -1213,7 +1178,7 @@
 	   patadr += 16;  /* = 64 due to (CARD32 *) */
 	}
 
-	SiSSetupROP(sisPatALUConv[rop])
+	SiSSetupROP(XAAPatternROP[rop])
 
 	SiSSetupCMDFlag(PATPATREG)
 
@@ -1272,7 +1237,7 @@
 
 #ifdef SISVRAMQ
         SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth);
-	SiSSetupROP(sisALUConv[rop]);
+	SiSSetupROP(XAACopyROP[rop]);
 	SiSSetupSRCFGDSTRect(fg, pSiS->scrnOffset, -1)
 	if(bg == -1) {
 	   SiSSetupCMDFlag(TRANSPARENT | ENCOLOREXP | SRCVIDEO);
@@ -1283,7 +1248,7 @@
         SiSSyncWP
 #else
 	SiSSetupSRCXY(0,0);
-	SiSSetupROP(sisALUConv[rop]);
+	SiSSetupROP(XAACopyROP[rop]);
 	SiSSetupSRCFG(fg);
 	SiSSetupDSTRect(pSiS->scrnOffset, -1);
 	SiSSetupDSTColorDepth(pSiS->DstColor);
@@ -1384,7 +1349,7 @@
 #endif
 	SiSSetupSRCXY(0,0);
 
-	SiSSetupROP(sisALUConv[rop]);
+	SiSSetupROP(XAACopyROP[rop]);
 	SiSSetupSRCFG(fg);
 	SiSSetupDSTRect(pSiS->scrnOffset, -1);
 #ifndef SISVRAMQ
@@ -1512,7 +1477,7 @@
 	SiSSetupDSTColorDepth(pSiS->DstColor)
 #endif
 	SiSSetupDSTRect(pSiS->scrnOffset, -1)
-	SiSSetupROP(sisALUConv[rop])
+	SiSSetupROP(XAACopyROP[rop])
 	SiSSetupSRCFG(fg)
 	/* SiSSetupSRCXY(0,0) */
 
@@ -1731,14 +1696,14 @@
    			int height, int	flags)
 {
     	SISPtr pSiS = SISPTR(pScrn);
-    	int x, pitch, sizeNeeded, offset;
+    	int x, y, 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);
+	xf86DrvMsg(0, X_INFO, "AT: op %d ARGB %x %x %x %x, w %d h %d A-pitch %d\n",
+		op, alpha, red, green, blue, width, height, alphaPitch);
 #endif
 
     	if(op != PictOpOver) return FALSE;
@@ -1749,16 +1714,16 @@
     	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;
 
+	red &= 0xff00;
+	green &= 0xff00;
+	blue &= 0xff00;
+
 #ifdef SISVRAMQ
         SiSSetupDSTColorDepth(pSiS->SiS310_AccelDepth);
 	SiSSetupSRCPitchDSTRect((pitch << 2), pSiS->scrnOffset, -1);
@@ -1782,17 +1747,77 @@
 	   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;
+	if(alphaType == PICT_a8) {
+
+	   if(alpha == 0xffff) {
+
+              while(height--) {
+	         for(x = 0; x < width; x++) {
+	            myalpha = alphaPtr[x];
+	            dstPtr[x] = (renderaccelarray[red + myalpha] << 16)  |
+	   	   	        (renderaccelarray[green + myalpha] << 8) |
+			        renderaccelarray[blue + myalpha]         |
+			        myalpha << 24;
+	         }
+	         dstPtr += pitch;
+	         alphaPtr += alphaPitch;
+              }
+
+	   } else {
+
+	      alpha &= 0xff00;
+
+	      while(height--) {
+	         for(x = 0; x < width; x++) {
+	            myalpha = alphaPtr[x];
+	            dstPtr[x] = (renderaccelarray[alpha + myalpha] << 24) |
+		    	 	(renderaccelarray[red + myalpha] << 16)   |
+	   	    	        (renderaccelarray[green + myalpha] << 8)  |
+			        renderaccelarray[blue + myalpha];
+	         }
+	         dstPtr += pitch;
+	         alphaPtr += alphaPitch;
+              }
+
 	   }
-	   dstPtr += pitch;
-	   alphaPtr += alphaPitch;
-        }
+
+	} else {
+
+	   width <<= 2;
+
+	   if(alpha == 0xffff) {
+
+	      while(height--) {
+	         for(x = 0, y = 0; x < width; x+=4, y++) {
+	            myalpha = alphaPtr[x];
+	            dstPtr[y] = (renderaccelarray[red + myalpha] << 16)  |
+	   	    	        (renderaccelarray[green + myalpha] << 8) |
+			        renderaccelarray[blue + myalpha]         |
+			        myalpha << 24;
+	         }
+	         dstPtr += pitch;
+	         alphaPtr += alphaPitch;
+              }
+
+	   } else {
+
+	      alpha &= 0xff00;
+
+	      while(height--) {
+	         for(x = 0, y = 0; x < width; x+=4, y++) {
+	            myalpha = alphaPtr[x];
+	            dstPtr[y] = (renderaccelarray[alpha + myalpha] << 24) |
+		    		(renderaccelarray[red + myalpha] << 16)   |
+	   	    	        (renderaccelarray[green + myalpha] << 8)  |
+			        renderaccelarray[blue + myalpha];
+	         }
+	         dstPtr += pitch;
+	         alphaPtr += alphaPitch;
+              }
+
+	   }
+
+	}
 
     	return TRUE;
 }
@@ -1869,8 +1894,7 @@
 	long srcbase, dstbase;
 
 	srcbase = pSiS->AccelLinearScratch->offset << 1;
-	if(pScrn->bitsPerPixel == 32)
-	   srcbase <<= 1;
+	if(pScrn->bitsPerPixel == 32) srcbase <<= 1;
 
 #ifdef ACCELDEBUG
 	xf86DrvMsg(0, X_INFO, "FIRE: scrbase %x dx %d dy %d w %d h %d\n",

Index: sis310_accel.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis310_accel.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis310_accel.h	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis310_accel.h	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,33 +1,39 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis310_accel.h,v 1.14 2003/10/30 18:53:42 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis310_accel.h,v 1.17 2004/01/23 22:29:04 twini Exp $ */
 /*
  * 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 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.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * Based on sis300_accel.h
- * 2003/08/18: Added VRAM queue support
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author:  	Thomas Winischhofer <thomas at winischhofer.net>
  *
+ * 2003/08/18: Added VRAM queue support
+ *
  */
 
 /* SiS315 and 330 engine commands */

Index: sis6326_video.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis6326_video.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis6326_video.c	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis6326_video.c	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,31 +1,36 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis6326_video.c,v 1.14 2003/11/11 18:04:30 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis6326_video.c,v 1.17 2004/01/23 22:29:04 twini Exp $ */
 /*
  * Xv driver for SiS 5597/5598, 6236 and 530/620.
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria.
- *
- * Based on sis_video.c which is
- *    Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria.
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author:	Thomas Winischhofer <thomas at winischhofer.net>
+ *
  */
 
 #include "sis.h"

Index: sis_accel.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis_accel.c	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis_accel.c	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,34 +1,36 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c,v 1.34 2003/11/03 17:02:52 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c,v 1.37 2004/01/04 18:07:59 twini Exp $ */
 /*
  * 2D acceleration for SiS5597/5598 and 6326
  *
- * Copyright 1998,1999 by Alan Hourihane, Wigan, England.
- * Parts Copyright 2002-2003 Thomas Winischhofer, Vienna, Austria.
+ * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England.
+ * Parts Copyright (C) 2001-2004 Thomas Winischhofer, Vienna, Austria.
+ *
+ * Licensed under the following terms:
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
+ * the above copyright notice appears in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * and that the name of the copyright holder not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holder makes no representations
  * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * "as is" without expressed or implied warranty.
  *
  * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
  * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  *
- * Authors:  Alan Hourihane, alanh at fairlite.demon.co.uk
+ * Authors:  Alan Hourihane <alanh at fairlite.demon.co.uk>,
  *           Mike Chapman <mike at paranoia.com>,
  *           Juanjo Santamarta <santamarta at ctv.es>,
- *           Mitani Hiroshi <hmitani at drl.mei.co.jp>
- *           David Thomas <davtom at dream.org.uk>
- *	     Thomas Winischhofer <thomas at winischhofer.net>
+ *           Mitani Hiroshi <hmitani at drl.mei.co.jp>,
+ *           David Thomas <davtom at dream.org.uk>,
+ *	     Thomas Winischhofer <thomas at winischhofer.net>.
  */
 
 #if 0
@@ -242,7 +244,7 @@
 }
 
 /* Clipping */
-static void SiSSetClippingRectangle ( ScrnInfoPtr pScrn,
+static void SiSSetClippingRectangle( ScrnInfoPtr pScrn,
                 int left, int top, int right, int bottom)
 {
     SISPtr pSiS = SISPTR(pScrn);
@@ -253,54 +255,12 @@
     pSiS->ClipEnabled = TRUE;
 }
 
-static void SiSDisableClipping (ScrnInfoPtr pScrn)
+static void SiSDisableClipping(ScrnInfoPtr pScrn)
 {
     SISPtr pSiS = SISPTR(pScrn);
     pSiS->ClipEnabled = FALSE;
 }
 
-#ifdef CTSCE
-static const int sisALUConv[] =
-{
-    0x00,       /* dest = 0;            0,      GXclear,        0 */
-    0x88,       /* dest &= src;         DSa,    GXand,          0x1 */
-    0x44,       /* dest = src & ~dest;  SDna,   GXandReverse,   0x2 */
-    0xCC,       /* dest = src;          S,      GXcopy,         0x3 */
-    0x22,       /* dest &= ~src;        DSna,   GXandInverted,  0x4 */
-    0xAA,       /* dest = dest;         D,      GXnoop,         0x5 */
-    0x66,       /* dest = ^src;         DSx,    GXxor,          0x6 */
-    0xEE,       /* dest |= src;         DSo,    GXor,           0x7 */
-    0x11,       /* dest = ~src & ~dest; DSon,   GXnor,          0x8 */
-    0x99,       /* dest ^= ~src ;       DSxn,   GXequiv,        0x9 */
-    0x55,       /* dest = ~dest;        Dn,     GXInvert,       0xA */
-    0xDD,       /* dest = src|~dest ;   SDno,   GXorReverse,    0xB */
-    0x33,       /* dest = ~src;         Sn,     GXcopyInverted, 0xC */
-    0xBB,       /* dest |= ~src;        DSno,   GXorInverted,   0xD */
-    0x77,       /* dest = ~src|~dest;   DSan,   GXnand,         0xE */
-    0xFF,       /* dest = 0xFF;         1,      GXset,          0xF */
-};
-/* same ROP but with Pattern as Source */
-static const int sisPatALUConv[] =
-{
-    0x00,       /* dest = 0;            0,      GXclear,        0 */
-    0xA0,       /* dest &= src;         DPa,    GXand,          0x1 */
-    0x50,       /* dest = src & ~dest;  PDna,   GXandReverse,   0x2 */
-    0xF0,       /* dest = src;          P,      GXcopy,         0x3 */
-    0x0A,       /* dest &= ~src;        DPna,   GXandInverted,  0x4 */
-    0xAA,       /* dest = dest;         D,      GXnoop,         0x5 */
-    0x5A,       /* dest = ^src;         DPx,    GXxor,          0x6 */
-    0xFA,       /* dest |= src;         DPo,    GXor,           0x7 */
-    0x05,       /* dest = ~src & ~dest; DPon,   GXnor,          0x8 */
-    0xA5,       /* dest ^= ~src ;       DPxn,   GXequiv,        0x9 */
-    0x55,       /* dest = ~dest;        Dn,     GXInvert,       0xA */
-    0xF5,       /* dest = src|~dest ;   PDno,   GXorReverse,    0xB */
-    0x0F,       /* dest = ~src;         Pn,     GXcopyInverted, 0xC */
-    0xAF,       /* dest |= ~src;        DPno,   GXorInverted,   0xD */
-    0x5F,       /* dest = ~src|~dest;   DPan,   GXnand,         0xE */
-    0xFF,       /* dest = 0xFF;         1,      GXset,          0xF */
-};
-#endif
-
 /* Screen to screen copy */
 static void
 SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir,
@@ -578,11 +538,11 @@
         sisSETROPBG(0xAA);             /* dst = dst (=noop) */
 	pSiS->CommandReg |= sisSRCFG;
     } else {
-        sisSETBGROPCOL(sisPatALUConv[rop], bg);
+        sisSETBGROPCOL(XAAPatternROP[rop], bg);
 	pSiS->CommandReg |= sisSRCFG | sisPATBG;
     }
 
-    sisSETFGROPCOL(sisALUConv[rop], fg);
+    sisSETFGROPCOL(XAACopyROP[rop], fg);
 
     sisSETDSTPITCH(pSiS->scrnOffset);
 }

Index: sis_accel.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis_accel.h	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis_accel.h	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,35 +1,37 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.h,v 1.9 2003/11/03 17:02:53 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.h,v 1.11 2004/01/04 18:07:59 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.
+ * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England.
+ * Parts Copyright (C) 2001-2004 Thomas Winischhofer, Vienna, Austria.
+ *
+ * Licensed under the following terms:
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
+ * the above copyright notice appears in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * and that the name of the copyright holder not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holder makes no representations
  * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * "as is" without expressed or implied warranty.
  *
  * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
  * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  *
- * Authors:  Alan Hourihane, alanh at fairlite.demon.co.uk
+ * Authors:  Alan Hourihane <alanh at fairlite.demon.co.uk>,
  *           Mike Chapman <mike at paranoia.com>,
  *           Juanjo Santamarta <santamarta at ctv.es>,
- *           Mitani Hiroshi <hmitani at drl.mei.co.jp>
- *           David Thomas <davtom at dream.org.uk>
- *	     Thomas Winischhofer <thomas at winischhofer.net>
+ *           Mitani Hiroshi <hmitani at drl.mei.co.jp>,
+ *           David Thomas <davtom at dream.org.uk>,
+ *	     Thomas Winischhofer <thomas at winischhofer.net>.
  */
 
 

Index: sis_common.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_common.h,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -d -r1.1 -r1.1.4.1
--- a/sis_common.h	25 Nov 2003 19:28:39 -0000	1.1
+++ b/sis_common.h	23 Feb 2004 21:35:45 -0000	1.1.4.1
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_common.h,v 1.2 2003/10/30 18:53:42 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_common.h,v 1.3 2004/01/03 20:08:02 twini Exp $ */
 /*
  * Common header definitions for SiS 2D/3D/DRM suite
  *
@@ -6,16 +6,16 @@
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
+ * the above copyright notice appears in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * and that the name of the copyright holder not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holder makes no representations
  * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * "as is" without expressed or implied warranty.
  *
  * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
  * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER

Index: sis_cursor.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis_cursor.c	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis_cursor.c	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,34 +1,38 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c,v 1.22 2003/11/03 17:02:53 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c,v 1.27 2004/01/23 22:29:04 twini Exp $ */
 /*
  * SiS hardware cursor handling
  *
- * Copyright 1998,1999 by Alan Hourihane, Wigan, England.
- * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria.
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
[...1188 lines suppressed...]
        } else {
           if((!pSiS->UseHWARGBCursor) && (!pSiS->VBFlags & DISPTYPE_CRT1)) {
 	     status2 = sis301GetCursorStatus310;
@@ -1337,7 +1317,6 @@
 	     sis301SwitchToRGBCursor310();
 	  }
           sis301SetCursorAddress310(cursor_addr)
-          sis301SetCursorPatternSelect310(0)
 	  if(status2) sis301SetCursorStatus310(status2)
        }
     }
@@ -1400,7 +1379,7 @@
       case PCI_CHIP_SIS315PRO:
       case PCI_CHIP_SIS330:
       case PCI_CHIP_SIS660:
-        infoPtr->MaxWidth  = 64;   
+        infoPtr->MaxWidth  = 64;
         infoPtr->MaxHeight = 64;
         infoPtr->ShowCursor = SiS310ShowCursor;
         infoPtr->HideCursor = SiS310HideCursor;

Index: sis_cursor.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis_cursor.h	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis_cursor.h	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,38 +1,42 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.h,v 1.11 2003/10/30 18:53:42 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.h,v 1.15 2004/01/23 22:29:04 twini Exp $ */
 /*
  * SiS hardware cursor handling
  * Definitions
  *
- * Copyright 1998,1999 by Alan Hourihane, Wigan, England.
- * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria.
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holders not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holders make no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Author:   Thomas Winischhofer <thomas at winischhofer.net>
+ *
+ * Idea based on code by Can-Ru Yeou, SiS Inc.
  *
- * Authors:  Alan Hourihane, alanh at fairlite.demon.co.uk
- *           Mike Chapman <mike at paranoia.com>,
- *           Juanjo Santamarta <santamarta at ctv.es>,
- *           Mitani Hiroshi <hmitani at drl.mei.co.jp>
- *           David Thomas <davtom at dream.org.uk>.
- *	     Thomas Winischhofer <thomas at winischhofer.net>:
  */
 
-#define CS(x)   (0x8500+(x<<2))
+#define CS(x)   (0x8500 + (x << 2))
 
 /* 300 series, CRT1 */
 
@@ -118,20 +122,11 @@
   { \
   unsigned long temp; \
   temp = MMIO_IN32(pSiS->IOBase, CS(0)); \
-  temp &= 0xFFFF0000; \
+  temp &= 0xF0FF0000; \
   temp |= address; \
   MMIO_OUT32(pSiS->IOBase,CS(0),temp); \
   }
 
-#define sis300SetCursorPatternSelect(pat_id)\
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(0)); \
-  temp &= 0xF0FFFFFF; \
-  temp |= (pat_id) << 24; \
-  MMIO_OUT32(pSiS->IOBase,CS(0),temp); \
-  }
-
 /* 300 series, CRT2 */
 
 /* 80000000 = RGB(1) - MONO(0)
@@ -216,20 +211,11 @@
   { \
   unsigned long temp; \
   temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0xFFFF0000; \
+  temp &= 0xF0FF0000; \
   temp |= address; \
   MMIO_OUT32(pSiS->IOBase,CS(8),temp); \
   }
 
-#define sis301SetCursorPatternSelect(pat_id)\
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0xF0FFFFFF; \
-  temp |= (pat_id) << 24; \
-  MMIO_OUT32(pSiS->IOBase,CS(8),temp); \
-  }
-
 /* 315/330 series CRT1 */
 
 /* 80000000 = RGB(1) - MONO(0)
@@ -242,86 +228,69 @@
   MMIO_IN32(pSiS->IOBase, CS(0)) & 0x40000000;
   
 #define sis310SetCursorStatus(status) \
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(0)); \
-  temp &= 0xbfffffff; \
-  temp |= status; \
-  MMIO_OUT32(pSiS->IOBase, CS(0), temp); \
-  }
+  pSiS->HWCursorBackup[0] &= 0xbfffffff; \
+  pSiS->HWCursorBackup[0] |= status; \
+  MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \
+  MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \
+  MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]);
 
 #define sis310EnableHWCursor()\
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(0)); \
-  temp &= 0x0fffffff; \
-  temp |= 0x40000000; \
-  MMIO_OUT32(pSiS->IOBase, CS(0), temp); \
-  }
+  pSiS->HWCursorBackup[0] &= 0x0fffffff; \
+  pSiS->HWCursorBackup[0] |= 0x40000000; \
+  MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \
+  MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \
+  MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]);
   
 #define sis310EnableHWARGBCursor()\
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(0)); \
-  temp &= 0x0FFFFFFF; \
-  temp |= 0xE0000000; \
-  MMIO_OUT32(pSiS->IOBase, CS(0), temp); \
-  }
+  pSiS->HWCursorBackup[0] &= 0x0FFFFFFF; \
+  pSiS->HWCursorBackup[0] |= 0xE0000000; \
+  MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \
+  MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \
+  MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]);
 
 #define sis310SwitchToMONOCursor() \
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(0)); \
-  temp &= 0x4fffffff; \
-  MMIO_OUT32(pSiS->IOBase, CS(0), temp); \
-  }
-  
+  pSiS->HWCursorBackup[0] &= 0x4fffffff; \
+  MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \
+  MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \
+  MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]);
+
 #define sis310SwitchToRGBCursor() \
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(0)); \
-  temp &= 0xBFFFFFFF; \
-  temp |= 0xA0000000; \
-  MMIO_OUT32(pSiS->IOBase, CS(0), temp); \
-  }
-  
+  pSiS->HWCursorBackup[0] &= 0xBFFFFFFF; \
+  pSiS->HWCursorBackup[0] |= 0xA0000000; \
+  MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \
+  MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \
+  MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]);
+
 #define sis310DisableHWCursor()\
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(0)); \
-  temp &= 0xBFFFFFFF; \
-  MMIO_OUT32(pSiS->IOBase, CS(0), temp); \
-  }
+  pSiS->HWCursorBackup[0] &= 0xBFFFFFFF; \
+  MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \
+  MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \
+  MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]);
   
 #define sis310SetCursorBGColor(color) \
-  MMIO_OUT32(pSiS->IOBase, CS(1), (color));
+  MMIO_OUT32(pSiS->IOBase, CS(1), (color)); \
+  pSiS->HWCursorBackup[1] = color;
 
 #define sis310SetCursorFGColor(color)\
-  MMIO_OUT32(pSiS->IOBase, CS(2), (color));
+  MMIO_OUT32(pSiS->IOBase, CS(2), (color)); \
+  pSiS->HWCursorBackup[2] = color;
 
-#define sis310SetCursorPositionX(x,preset)\
-  MMIO_OUT32(pSiS->IOBase, CS(3), ((x) | ((preset) << 16)));
+#define sis310SetCursorPositionX(x,preset) \
+  pSiS->HWCursorBackup[3] = ((x) | ((preset) << 16)); \
+  MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]);
 
-#define sis310SetCursorPositionY(y,preset)\
-  MMIO_OUT32(pSiS->IOBase, CS(4), ((y) | ((preset) << 16)));
+#define sis310SetCursorPositionY(y,preset) \
+  pSiS->HWCursorBackup[4] = ((y) | ((preset) << 16)); \
+  MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]);
 
 #define sis310SetCursorAddress(address)\
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(0)); \
-  temp &= 0xFFF00000; \
-  temp |= address; \
-  MMIO_OUT32(pSiS->IOBase,CS(0),temp); \
-  }
-
-#define sis310SetCursorPatternSelect(pat_id)\
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(0)); \
-  temp &= 0xF0FFFFFF; \
-  temp |= (pat_id) << 24; \
-  MMIO_OUT32(pSiS->IOBase,CS(0),temp); \
-  }
+  pSiS->HWCursorBackup[0] &= 0xF0F00000; \
+  pSiS->HWCursorBackup[0] |= address; \
+  MMIO_OUT32(pSiS->IOBase, CS(0), pSiS->HWCursorBackup[0]); \
+  MMIO_OUT32(pSiS->IOBase, CS(1), pSiS->HWCursorBackup[1]); \
+  MMIO_OUT32(pSiS->IOBase, CS(2), pSiS->HWCursorBackup[2]); \
+  MMIO_OUT32(pSiS->IOBase, CS(3), pSiS->HWCursorBackup[3]); \
+  MMIO_OUT32(pSiS->IOBase, CS(4), pSiS->HWCursorBackup[4]);
 
 /* 315 series CRT2 */
 
@@ -335,78 +304,62 @@
   MMIO_IN32(pSiS->IOBase, CS(8)) & 0x40000000;
 
 #define sis301SetCursorStatus310(status) \
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0xbfffffff; \
-  temp |= status; \
-  MMIO_OUT32(pSiS->IOBase, CS(8), temp); \
-  }
+  pSiS->HWCursorBackup[8] &= 0xbfffffff; \
+  pSiS->HWCursorBackup[8] |= status; \
+  MMIO_OUT32(pSiS->IOBase, CS(8),  pSiS->HWCursorBackup[8]); \
+  MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \
+  MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]);
 
 #define sis301EnableHWCursor310()\
-  { \
-  unsigned long temp, temp1, temp2; \
-  temp1 = MMIO_IN32(pSiS->IOBase, CS(11)); \
-  temp2 = MMIO_IN32(pSiS->IOBase, CS(12)); \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0x0fffffff; \
-  temp |= 0x40000000; \
-  MMIO_OUT32(pSiS->IOBase, CS(8), temp); \
-  MMIO_OUT32(pSiS->IOBase, CS(11), temp1); \
-  MMIO_OUT32(pSiS->IOBase, CS(12), temp2); \
-  }
+  pSiS->HWCursorBackup[8] &= 0x0fffffff; \
+  pSiS->HWCursorBackup[8] |= 0x40000000; \
+  MMIO_OUT32(pSiS->IOBase, CS(8),  pSiS->HWCursorBackup[8]); \
+  MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \
+  MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]);
 
 #define sis301EnableHWARGBCursor310()\
-  { \
-  unsigned long temp, temp1, temp2; \
-  temp1 = MMIO_IN32(pSiS->IOBase, CS(11)); \
-  temp2 = MMIO_IN32(pSiS->IOBase, CS(12)); \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0x0FFFFFFF; \
-  temp |= 0xE0000000; \
-  MMIO_OUT32(pSiS->IOBase, CS(8), temp); \
-  MMIO_OUT32(pSiS->IOBase, CS(11), temp1); \
-  MMIO_OUT32(pSiS->IOBase, CS(12), temp2); \
-  }
+  pSiS->HWCursorBackup[8] &= 0x0FFFFFFF; \
+  pSiS->HWCursorBackup[8] |= 0xE0000000; \
+  MMIO_OUT32(pSiS->IOBase, CS(8),  pSiS->HWCursorBackup[8]); \
+  MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \
+  MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]);
 
 #define sis301SwitchToRGBCursor310() \
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0xBFFFFFFF; \
-  temp |= 0xA0000000; \
-  MMIO_OUT32(pSiS->IOBase, CS(8), temp); \
-  }
+  pSiS->HWCursorBackup[8] &= 0xBFFFFFFF; \
+  pSiS->HWCursorBackup[8] |= 0xA0000000; \
+  MMIO_OUT32(pSiS->IOBase, CS(8),  pSiS->HWCursorBackup[8]); \
+  MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \
+  MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]);
 
 #define sis301SwitchToMONOCursor310() \
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0x4fffffff; \
-  MMIO_OUT32(pSiS->IOBase, CS(8), temp); \
-  }
+  pSiS->HWCursorBackup[8] &= 0x4fffffff; \
+  MMIO_OUT32(pSiS->IOBase, CS(8),  pSiS->HWCursorBackup[8]); \
+  MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \
+  MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]);
 
 #define sis301DisableHWCursor310()\
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0xBFFFFFFF; \
-  MMIO_OUT32(pSiS->IOBase, CS(8), temp); \
-  }
+  pSiS->HWCursorBackup[8] &= 0xBFFFFFFF; \
+  MMIO_OUT32(pSiS->IOBase, CS(8),  pSiS->HWCursorBackup[8]); \
+  MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \
+  MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]);
 
-#define sis301SetCursorBGColor310(color)\
-  MMIO_OUT32(pSiS->IOBase, CS(9), (color));
-#define sis301SetCursorFGColor310(color)\
-  MMIO_OUT32(pSiS->IOBase, CS(10), (color));
+#define sis301SetCursorBGColor310(color) \
+  MMIO_OUT32(pSiS->IOBase, CS(9), (color)); \
+  pSiS->HWCursorBackup[9] = color;
 
-#define sis301SetCursorPositionX310(x,preset)\
-  MMIO_OUT32(pSiS->IOBase, CS(11), ((x) | ((preset) << 16)));
-#define sis301SetCursorPositionY310(y,preset)\
-  MMIO_OUT32(pSiS->IOBase, CS(12), ((y) | ((preset) << 16)));
+#define sis301SetCursorFGColor310(color) \
+  MMIO_OUT32(pSiS->IOBase, CS(10), (color)); \
+  pSiS->HWCursorBackup[10] = color;
 
-#define sis301SetCursorAddress310(address)\
-  { \
-  unsigned long temp; \
+#define sis301SetCursorPositionX310(x,preset) \
+  pSiS->HWCursorBackup[11] = ((x) | ((preset) << 16)); \
+  MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]);
+
+#define sis301SetCursorPositionY310(y,preset) \
+  pSiS->HWCursorBackup[12] = ((y) | ((preset) << 16)); \
+  MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]);
+
+#define sis301SetCursorAddress310(address) \
   if(pSiS->sishw_ext.jChipType == SIS_315H) { \
      if(address & 0x10000) { \
         address &= ~0x10000; \
@@ -415,25 +368,18 @@
         andSISIDXREG(SISSR, 0x37, 0x7f); \
      } \
   } \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0xFFF00000; \
-  temp |= address; \
-  MMIO_OUT32(pSiS->IOBase,CS(8),temp); \
-  }
-
-#define sis301SetCursorPatternSelect310(pat_id)\
-  { \
-  unsigned long temp; \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0xF0FFFFFF; \
-  temp |= (pat_id) << 24; \
-  MMIO_OUT32(pSiS->IOBase,CS(8),temp); \
-  }
+  pSiS->HWCursorBackup[8] &= 0xF0F00000; \
+  pSiS->HWCursorBackup[8] |= address; \
+  MMIO_OUT32(pSiS->IOBase, CS(8),  pSiS->HWCursorBackup[8]);  \
+  MMIO_OUT32(pSiS->IOBase, CS(9),  pSiS->HWCursorBackup[9]);  \
+  MMIO_OUT32(pSiS->IOBase, CS(10), pSiS->HWCursorBackup[10]); \
+  MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \
+  MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]);
 
 /* 330 series CRT2 */
 
 /* Mono cursor engine for CRT2 on SiS330 (Xabre) has bugs
- * and cannot be used!
+ * and cannot be used! Will hang engine.
  */
 
 /* 80000000 = RGB(1) - MONO(0)
@@ -442,65 +388,14 @@
  * 10000000 = "ghost"(1) - Alpha Blend(0)  ?
  */
 
-#define sis301EnableHWCursor330()\
-  { \
-  unsigned long temp, temp1, temp2; \
-  andSISIDXREG(SISCR,0x5b,~0x10); \
-  temp1 = MMIO_IN32(pSiS->IOBase, CS(11)); \
-  temp2 = MMIO_IN32(pSiS->IOBase, CS(12)); \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0x0fffffff; \
-  temp |= 0xE0000000; \
-  MMIO_OUT32(pSiS->IOBase, CS(8), temp); \
-  MMIO_OUT32(pSiS->IOBase, CS(11), temp1); \
-  MMIO_OUT32(pSiS->IOBase, CS(12), temp2); \
-  orSISIDXREG(SISCR,0x5b,0x10); \
-  }
-
-#define sis301DisableHWCursor330()\
-  { \
-  unsigned long temp; \
-  andSISIDXREG(SISCR,0x5b,~0x10); \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0xBFFFFFFF; \
-  MMIO_OUT32(pSiS->IOBase, CS(8), temp); \
-  orSISIDXREG(SISCR,0x5b,0x10); \
-  }
-
-#define sis301SetCursorPositionX330(x,preset)\
-  andSISIDXREG(SISCR,0x5b,~0x10); \
-  MMIO_OUT32(pSiS->IOBase, CS(11), ((x) | ((preset) << 16))); \
-  orSISIDXREG(SISCR,0x5b,0x10);
-
-#define sis301SetCursorPositionY330(y,preset)\
-  andSISIDXREG(SISCR,0x5b,~0x10); \
-  MMIO_OUT32(pSiS->IOBase, CS(12), ((y) | ((preset) << 16))); \
-  orSISIDXREG(SISCR,0x5b,0x10); \
-
-#define sis301SetCursorAddress330(address)\
-  { \
-  unsigned long temp, temp1, temp2; \
-  temp1 = MMIO_IN32(pSiS->IOBase, CS(11)); \
-  temp2 = MMIO_IN32(pSiS->IOBase, CS(12)); \
-  andSISIDXREG(SISCR,0x5b,~0x10); \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0xFFF00000; \
-  temp |= address; \
-  MMIO_OUT32(pSiS->IOBase,CS(8),temp); \
-  MMIO_OUT32(pSiS->IOBase, CS(11), temp1); \
-  MMIO_OUT32(pSiS->IOBase, CS(12), temp2); \
-  orSISIDXREG(SISCR,0x5b,0x10); \
-  }
+#define sis301EnableHWCursor330() \
+  /* andSISIDXREG(SISCR,0x5b,~0x10); */ \
+  pSiS->HWCursorBackup[8] &= 0x0fffffff; \
+  pSiS->HWCursorBackup[8] |= 0xE0000000; \
+  MMIO_OUT32(pSiS->IOBase, CS(8),  pSiS->HWCursorBackup[8]); \
+  MMIO_OUT32(pSiS->IOBase, CS(11), pSiS->HWCursorBackup[11]); \
+  MMIO_OUT32(pSiS->IOBase, CS(12), pSiS->HWCursorBackup[12]); \
+  /* orSISIDXREG(SISCR,0x5b,0x10); */
 
-#define sis301SetCursorPatternSelect330(pat_id)\
-  { \
-  unsigned long temp; \
-  andSISIDXREG(SISCR,0x5b,~0x10); \
-  temp = MMIO_IN32(pSiS->IOBase, CS(8)); \
-  temp &= 0xF0FFFFFF; \
-  temp |= (pat_id) << 24; \
-  MMIO_OUT32(pSiS->IOBase,CS(8),temp); \
-  orSISIDXREG(SISCR,0x5b,0x10); \
-  }
 
 

Index: sis_dac.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c,v
retrieving revision 1.1.4.2
retrieving revision 1.1.4.3
diff -u -d -r1.1.4.2 -r1.1.4.3
--- a/sis_dac.c	6 Dec 2003 13:24:25 -0000	1.1.4.2
+++ b/sis_dac.c	23 Feb 2004 21:35:45 -0000	1.1.4.3
@@ -1,37 +1,48 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c,v 1.51 2003/11/30 22:29:52 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c,v 1.57 2004/02/02 03:55:29 dawes Exp $ */
 /*
  * DAC helper functions (Save/Restore, MemClk, etc)
  *
- * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria.
- * Parts Copyright 1998,1999 by Alan Hourihane, Wigan, England.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria.
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the provider not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The provider makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * THE PROVIDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE PROVIDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author:  	Thomas Winischhofer <thomas at winischhofer.net>
  *
- * MemClock functions by:
- *	 	Alan Hourihane <alanh at fairlite.demon.co.uk>
- *           	Mike Chapman <mike at paranoia.com>,
- *           	Juanjo Santamarta <santamarta at ctv.es>,
- *           	Mitani Hiroshi <hmitani at drl.mei.co.jp>
- *           	David Thomas <davtom at dream.org.uk>.
+ * SiS_compute_vclk(), SiSCalcClock() and parts of SiSMclk():
+ * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England
+ * Written by:
+ *	 Alan Hourihane <alanh at fairlite.demon.co.uk>,
+ *       Mike Chapman <mike at paranoia.com>,
+ *       Juanjo Santamarta <santamarta at ctv.es>,
+ *       Mitani Hiroshi <hmitani at drl.mei.co.jp>,
+ *       David Thomas <davtom at dream.org.uk>,
+ *	 Thomas Winischhofer <thomas at winischhofer.net>.
+ * Licensed under the terms of the XFree86 license
+ * (http://www.xfree86.org/current/LICENSE1.html)
+ *
  */
 
 #include "xf86.h"
@@ -839,7 +850,7 @@
     if(pSiS->sishw_ext.jChipType < SIS_661) {
        outSISIDXREG(SISCR, 0x79, sisReg->sisRegs3D4[0x79]);
     }
-    outSISIDXREG(SISCR, 0x63, sisReg->sisRegs3D4[0x63]);
+    outSISIDXREG(SISCR, pSiS->myCR63, sisReg->sisRegs3D4[pSiS->myCR63]);
 
     /* Leave PCI_IO_ENABLE on if accelerators are on (Is this required?) */
     if(sisReg->sisRegs3C4[0x1e] & 0x50) {  /*0x40=2D, 0x10=3D*/
@@ -848,6 +859,9 @@
     }
 
     /* Restore extended SR registers */
+    if(pSiS->sishw_ext.jChipType >= SIS_661) {
+       sisReg->sisRegs3C4[0x11] &= 0x0f;
+    }
     for(i = 0x06; i <= 0x3F; i++) {
        outSISIDXREG(SISSR, i, sisReg->sisRegs3C4[i]);
     }
@@ -1042,10 +1056,13 @@
     Part2max = 0x4d;
     Part3max = 0x3e;
     Part4max = 0x23;
-    if(pSiS->VBFlags & (VB_301C|VB_302ELV))
+    if(pSiS->VBFlags & (VB_301C|VB_302ELV)) {
        Part2max = 0xff;
-    if(pSiS->VBFlags & (VB_301C|VB_301LV|VB_302LV|VB_302ELV))
+       Part4max = 0x3c;
+    }
+    if(pSiS->VBFlags & (VB_301LV|VB_302LV)) {
        Part4max = 0x34;
+    }
 
     SiSVBSave(pScrn, sisReg, Part1max, Part2max, Part3max, Part4max);
 
@@ -1064,10 +1081,13 @@
     Part2max = 0x4d;
     Part3max = 0x3e;
     Part4max = 0x22;
-    if(pSiS->VBFlags & (VB_301C|VB_302ELV))
+    if(pSiS->VBFlags & (VB_301C|VB_302ELV)) {
        Part2max = 0xff;
-    if(pSiS->VBFlags & (VB_301LV|VB_302LV|VB_302ELV))
-       Part4max = 0x24;
+       Part4max = 0x3c;
+    }
+    if(pSiS->VBFlags & (VB_301LV|VB_302LV)) {
+       Part4max = 0x34;
+    }
 
     SiS_DisableBridge(pSiS->SiS_Pr, &pSiS->sishw_ext);
 
@@ -1246,13 +1266,13 @@
    sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL);
 #endif
 
-   for(i = 0x30; i <= 0x39; i++) {
+   for(i = 0x30; i <= 0x3b; i++) {
       if(i == 0x34) continue;
       outSISIDXREG(SISCR, i, sisReg->sisRegs3D4[i]);
    }
 
    if(pSiS->VGAEngine == SIS_315_VGA) {
-      outSISIDXREG(SISCR, 0x63, sisReg->sisRegs3D4[0x63]);
+      outSISIDXREG(SISCR, pSiS->myCR63, sisReg->sisRegs3D4[pSiS->myCR63]);
       if(pSiS->sishw_ext.jChipType < SIS_661) {
          outSISIDXREG(SISCR, 0x79, sisReg->sisRegs3D4[0x79]);
       }
@@ -1429,7 +1449,10 @@
 		 return 70000;
 	      }
 	   } else if(pSiS->VBFlags & VB_SISBRIDGE) {
-	      return 70000;
+	      if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTYPBPR)
+	         return 75000;
+	      else
+	         return 70000;
 	   }
 	}
 
@@ -1450,10 +1473,16 @@
 	int             bytesperpixel = (bpp + 7) / 8;
         float   	magic=0.0, total, crt2used, maxcrt2;
 	int		crt2clock, max=0;
+#ifdef __SUNPRO_C
+#define const
+#endif
         const float     magic300[4] = { 1.2,      1.368421, 2.263158, 1.2};
         const float     magic630[4] = { 1.441177, 1.441177, 2.588235, 1.441177 };
 	const float     magic315[4] = { 1.2,      1.368421, 1.368421, 1.2 };
 	const float     magic550[4] = { 1.441177, 1.441177, 2.588235, 1.441177 };
+#ifdef __SUNPRO_C
+#undef const
+#endif
 	BOOLEAN	        DHM, GetForCRT1;
 
         switch(pSiS->Chipset) {

Index: sis_dac.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis_dac.h	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis_dac.h	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,35 +1,35 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.h,v 1.15 2003/10/30 18:53:42 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.h,v 1.18 2004/01/23 22:29:04 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.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria.
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the provider not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The provider makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * THE PROVIDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE PROVIDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * Authors:  Alan Hourihane <alanh at fairlite.demon.co.uk>
- *           Mike Chapman <mike at paranoia.com>,
- *           Juanjo Santamarta <santamarta at ctv.es>,
- *           Mitani Hiroshi <hmitani at drl.mei.co.jp>
- *           David Thomas <davtom at dream.org.uk>.
- *	     Thomas Winischhofer <thomas at winischhofer.net>
  */
 
 int  SiS_compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div,
@@ -72,10 +72,3 @@
 extern unsigned char SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id);
 extern void     SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable);
 extern void     SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable);
-
-
-
-
-
-
-

Index: sis_dga.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dga.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis_dga.c	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis_dga.c	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,14 +1,16 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dga.c,v 1.11 2003/10/30 18:53:42 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dga.c,v 1.13 2004/01/04 18:08:00 twini Exp $ */
 /*
  * SiS DGA handling
  *
- * Copyright 2000 by Alan Hourihane, Sychdyn, North Wales, UK.
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2000 by Alan Hourihane, Sychdyn, North Wales, UK.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
  * Portions from radeon_dga.c which is
  *          Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
  *                         VA Linux Systems Inc., Fremont, California.
  *
+ * Licensed under the following terms:
+ *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that

Index: sis_dri.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis_dri.c	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis_dri.c	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,12 +1,38 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c,v 1.39 2003/11/20 19:53:23 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c,v 1.41 2004/01/04 18:08:00 twini Exp $ */
 /*
- *  DRI wrapper for 300 and 315 series
+ * DRI wrapper for 300 and 315 series
  *
- *  Preliminary 315/330 support by Thomas Winischhofer
- *  Mesa 4/5 changes by Eric Anholt
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- *  Taken and modified from tdfx_dri.c, mga_dri.c
+ * Preliminary 315/330 support by Thomas Winischhofer
+ * Portions of Mesa 4/5 changes by Eric Anholt
+ *
+ * Licensed under the following terms:
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appears in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * and that the name of the copyright holder not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holder makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without expressed or implied warranty.
+ *
+ * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * 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.
+ *
+ * Previously taken and modified from tdfx_dri.c, mga_dri.c
  *
+ * Authors:	Can-Ru Yeou, SiS Inc.
+ *		Alan Hourihane, Wigan, England,
+ *		Thomas Winischhofer <thomas at winischhofer.net>
+ *		others.
  */
 
 #include "xf86.h"

Index: sis_dri.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis_dri.h	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis_dri.h	23 Feb 2004 21:35:45 -0000	1.1.4.2
@@ -1,6 +1,35 @@
-/* $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 */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h,v 1.12 2004/01/04 18:08:00 twini Exp $ */
+/*
+ * SiS DRI wrapper
+ *
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
+ *
+ * Licensed under the following terms:
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appears in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * and that the name of the copyright holder not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holder makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without expressed or implied warranty.
+ *
+ * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * 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: 	Can-Ru Yeou, SiS Inc.,
+ *		Thomas Winischhofer <thomas at winischhofer.net>,
+ *		others.
+ *
+ * Previously taken and modified from tdfx_dri.h
+ */
 
 #ifndef _SIS_DRI_
 #define _SIS_DRI_

Index: sis_driver.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c,v
retrieving revision 1.1.4.4
retrieving revision 1.1.4.5
diff -u -d -r1.1.4.4 -r1.1.4.5
--- a/sis_driver.c	20 Dec 2003 00:28:28 -0000	1.1.4.4
+++ b/sis_driver.c	23 Feb 2004 21:35:45 -0000	1.1.4.5
@@ -1,60 +1,49 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c,v 1.166 2003/12/16 17:59:08 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c,v 1.176 2004/01/24 21:29:20 twini Exp $ */
 /*
- * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria.
+ * SiS driver main code
  *
- * Formerly based on old code which is
- * Copyright 1998,1999 by Alan Hourihane, Wigan, England.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria.
  *
[...1526 lines suppressed...]
+	     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];
+	     }
+	     if(pSiS->VBFlags & (VB_301C | VB_302ELV)) {
+	        for(i=0; i<64; i++) {
+	           pSiSEnt->scalingp2[i] = pSiS->scalingp2[i];
+  	        }
+	     }
 	  }
 #endif
           if((val = mysistvantiflicker) != -1) {

Index: sis_driver.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.h,v
retrieving revision 1.1.4.3
retrieving revision 1.1.4.4
diff -u -d -r1.1.4.3 -r1.1.4.4
--- a/sis_driver.h	20 Dec 2003 00:28:28 -0000	1.1.4.3
+++ b/sis_driver.h	23 Feb 2004 21:35:46 -0000	1.1.4.4
@@ -1,27 +1,33 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.h,v 1.30 2003/12/16 17:35:07 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.h,v 1.36 2004/01/23 22:29:05 twini Exp $ */
 /*
  * Global data and definitions
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author:     	Thomas Winischhofer <thomas at winischhofer.net>
  *
@@ -1029,6 +1035,232 @@
 	0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b
 };
 
+static const unsigned char SiS301CScaling[] = {
+
+    /* NTSC/PAL-M/525ip 640x480 */
+
+    0x03,0x1C,0x03,0x7E,0x01,0x1C,0x05,0x7E,0x00,0x1C,0x06,0x7E,0x7F,0x1B,0x09,0x7D,
+    0x7E,0x1A,0x0B,0x7D,0x7D,0x19,0x0D,0x7D,0x7D,0x18,0x0F,0x7C,0x7C,0x16,0x12,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x12,0x16,0x7C,0x7C,0x0F,0x18,0x7D,0x7C,0x0D,0x19,0x7E,
+    0x7D,0x0B,0x1A,0x7E,0x7D,0x09,0x1B,0x7F,0x7E,0x06,0x1C,0x00,0x7E,0x05,0x1C,0x01,
+
+    0x03,0x1B,0x03,0x7F,0x02,0x1B,0x05,0x7E,0x00,0x1B,0x07,0x7E,0x7F,0x1B,0x09,0x7D,
+    0x7E,0x1A,0x0B,0x7D,0x7D,0x19,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7C,0x16,0x12,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x12,0x16,0x7C,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x19,0x7E,
+    0x7D,0x0B,0x1A,0x7E,0x7D,0x09,0x1B,0x7F,0x7E,0x07,0x1B,0x00,0x7E,0x05,0x1B,0x02,
+
+    0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E,0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D,
+    0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x18,0x7F,
+    0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1B,0x02,
+
+    0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D,0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D,
+    0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C,0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C,
+    0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E,
+    0x7D,0x0C,0x19,0x7E,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02,
+
+    0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x19,0x0A,0x7C,
+    0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x10,0x7C,0x7D,0x15,0x11,0x7D,
+    0x7D,0x13,0x13,0x7D,0x7D,0x11,0x15,0x7D,0x7D,0x10,0x16,0x7D,0x7D,0x0E,0x17,0x7E,
+    0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04,
+
+    0x05,0x18,0x05,0x7E,0x04,0x19,0x07,0x7C,0x02,0x18,0x08,0x7E,0x01,0x18,0x0A,0x7D,
+    0x00,0x17,0x0C,0x7D,0x7F,0x17,0x0E,0x7C,0x7E,0x15,0x0F,0x7E,0x7E,0x14,0x11,0x7D,
+    0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x17,0x7E,
+    0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x18,0x03,0x7D,0x07,0x19,0x03,
+
+    0x05,0x18,0x05,0x7E,0x04,0x18,0x07,0x7D,0x03,0x18,0x09,0x7C,0x02,0x17,0x0A,0x7D,
+    0x01,0x17,0x0C,0x7C,0x00,0x16,0x0E,0x7C,0x7F,0x15,0x0F,0x7D,0x7E,0x14,0x11,0x7D,
+    0x7E,0x12,0x12,0x7E,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x16,0x7F,
+    0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x17,0x02,0x7D,0x09,0x18,0x02,0x7D,0x07,0x18,0x04,
+
+    /* NTSC/PAL-M/525ip 720x480 */
+
+    0x03,0x1C,0x03,0x7E,0x01,0x1C,0x05,0x7E,0x00,0x1C,0x06,0x7E,0x7F,0x1B,0x09,0x7D,
+    0x7E,0x1A,0x0B,0x7D,0x7D,0x19,0x0D,0x7D,0x7D,0x18,0x0F,0x7C,0x7C,0x16,0x12,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x12,0x16,0x7C,0x7C,0x0F,0x18,0x7D,0x7C,0x0D,0x19,0x7E,
+    0x7D,0x0B,0x1A,0x7E,0x7D,0x09,0x1B,0x7F,0x7E,0x06,0x1C,0x00,0x7E,0x05,0x1C,0x01,
+
+    0x03,0x1B,0x03,0x7F,0x02,0x1B,0x05,0x7E,0x00,0x1B,0x07,0x7E,0x7F,0x1B,0x09,0x7D,
+    0x7E,0x1A,0x0B,0x7D,0x7D,0x19,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7C,0x16,0x12,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x12,0x16,0x7C,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x19,0x7E,
+    0x7D,0x0B,0x1A,0x7E,0x7D,0x09,0x1B,0x7F,0x7E,0x07,0x1B,0x00,0x7E,0x05,0x1B,0x02,
+
+    0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E,0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D,
+    0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x18,0x7F,
+    0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1B,0x02,
+
+    0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D,0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D,
+    0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C,0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C,
+    0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E,
+    0x7D,0x0C,0x19,0x7E,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02,
+
+    0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x19,0x0A,0x7C,
+    0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x10,0x7C,0x7D,0x15,0x11,0x7D,
+    0x7D,0x13,0x13,0x7D,0x7D,0x11,0x15,0x7D,0x7D,0x10,0x16,0x7D,0x7D,0x0E,0x17,0x7E,
+    0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04,
+
+    0x05,0x18,0x05,0x7E,0x04,0x19,0x07,0x7C,0x02,0x18,0x08,0x7E,0x01,0x18,0x0A,0x7D,
+    0x00,0x17,0x0C,0x7D,0x7F,0x17,0x0E,0x7C,0x7E,0x15,0x0F,0x7E,0x7E,0x14,0x11,0x7D,
+    0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x17,0x7E,
+    0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x18,0x03,0x7D,0x07,0x19,0x03,
+
+    0x05,0x18,0x05,0x7E,0x04,0x18,0x07,0x7D,0x03,0x18,0x09,0x7C,0x02,0x17,0x0A,0x7D,
+    0x01,0x17,0x0C,0x7C,0x00,0x16,0x0E,0x7C,0x7F,0x15,0x0F,0x7D,0x7E,0x14,0x11,0x7D,
+    0x7E,0x12,0x12,0x7E,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x16,0x7F,
+    0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x17,0x02,0x7D,0x09,0x18,0x02,0x7D,0x07,0x18,0x04,
+
+    /* NTSC/PAL-M/525i 800x600 */
+
+    0x07,0x15,0x07,0x7D,0x05,0x15,0x08,0x7E,0x04,0x15,0x09,0x7E,0x03,0x15,0x0B,0x7D,
+    0x02,0x14,0x0C,0x7E,0x01,0x14,0x0D,0x7E,0x00,0x13,0x0F,0x7E,0x00,0x12,0x10,0x7E,
+    0x7F,0x11,0x11,0x7F,0x7E,0x10,0x12,0x00,0x7E,0x0F,0x13,0x00,0x7E,0x0D,0x14,0x01,
+    0x7D,0x0C,0x14,0x03,0x7D,0x0B,0x15,0x03,0x7D,0x09,0x15,0x05,0x7D,0x08,0x15,0x06,
+
+    0x07,0x15,0x07,0x7D,0x06,0x15,0x08,0x7D,0x05,0x15,0x09,0x7D,0x04,0x14,0x0B,0x7D,
+    0x03,0x14,0x0C,0x7D,0x02,0x13,0x0D,0x7E,0x01,0x13,0x0E,0x7E,0x00,0x12,0x10,0x7E,
+    0x7F,0x11,0x11,0x7F,0x7F,0x10,0x12,0x7F,0x7E,0x0E,0x13,0x01,0x7E,0x0D,0x13,0x02,
+    0x7E,0x0C,0x14,0x02,0x7D,0x0B,0x14,0x04,0x7D,0x09,0x15,0x05,0x7D,0x08,0x15,0x06,
+
+    0x07,0x14,0x07,0x7E,0x06,0x14,0x08,0x7E,0x05,0x14,0x0A,0x7D,0x04,0x14,0x0B,0x7D,
+    0x03,0x13,0x0C,0x7E,0x02,0x13,0x0D,0x7E,0x01,0x12,0x0E,0x7F,0x00,0x11,0x0F,0x00,
+    0x00,0x10,0x10,0x00,0x7F,0x0F,0x11,0x01,0x7F,0x0E,0x12,0x01,0x7E,0x0D,0x13,0x02,
+    0x7E,0x0C,0x13,0x03,0x7E,0x0B,0x14,0x03,0x7D,0x0A,0x14,0x05,0x7D,0x08,0x14,0x07,
+
+    0x07,0x14,0x07,0x7E,0x06,0x14,0x09,0x7D,0x05,0x14,0x0A,0x7D,0x04,0x13,0x0B,0x7E,
+    0x03,0x13,0x0C,0x7E,0x02,0x12,0x0D,0x7F,0x01,0x12,0x0E,0x7F,0x01,0x11,0x0F,0x7F,
+    0x00,0x10,0x10,0x00,0x7F,0x0F,0x11,0x01,0x7F,0x0E,0x12,0x01,0x7E,0x0D,0x12,0x03,
+    0x7E,0x0C,0x13,0x03,0x7E,0x0B,0x13,0x04,0x7E,0x0A,0x14,0x04,0x7D,0x09,0x14,0x06,
+
+    0x08,0x13,0x08,0x7D,0x07,0x13,0x09,0x7D,0x05,0x13,0x0A,0x7E,0x04,0x13,0x0B,0x7E,
+    0x04,0x12,0x0C,0x7E,0x03,0x12,0x0D,0x7E,0x02,0x11,0x0E,0x7F,0x01,0x10,0x0F,0x00,
+    0x00,0x10,0x10,0x00,0x00,0x0F,0x10,0x01,0x7F,0x0E,0x11,0x02,0x7F,0x0D,0x12,0x02,
+    0x7E,0x0C,0x12,0x04,0x7E,0x0B,0x13,0x04,0x7E,0x0A,0x13,0x05,0x7E,0x09,0x13,0x06,
+
+    0x08,0x13,0x08,0x7D,0x07,0x13,0x09,0x7D,0x06,0x12,0x0A,0x7E,0x05,0x12,0x0B,0x7E,
+    0x04,0x12,0x0C,0x7E,0x03,0x11,0x0D,0x7F,0x02,0x11,0x0E,0x7F,0x01,0x10,0x0E,0x01,
+    0x01,0x0F,0x0F,0x01,0x00,0x0E,0x10,0x02,0x00,0x0E,0x11,0x01,0x7F,0x0D,0x11,0x03,
+    0x7F,0x0C,0x12,0x03,0x7E,0x0B,0x12,0x05,0x7E,0x0A,0x12,0x06,0x7E,0x09,0x13,0x06,
+
+    0x08,0x12,0x08,0x7E,0x07,0x12,0x09,0x7E,0x06,0x12,0x0A,0x7E,0x05,0x12,0x0B,0x7E,
+    0x04,0x11,0x0C,0x7F,0x03,0x11,0x0D,0x7F,0x02,0x10,0x0D,0x01,0x02,0x10,0x0E,0x00,
+    0x01,0x0F,0x0F,0x01,0x00,0x0E,0x10,0x02,0x00,0x0D,0x10,0x03,0x7F,0x0D,0x11,0x03,
+    0x7F,0x0C,0x11,0x04,0x7F,0x0B,0x12,0x04,0x7E,0x0A,0x12,0x06,0x7E,0x09,0x12,0x07,
+
+    /* PAL/PAL-N 640x480 */
+
+    0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E,
+    0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C,
+    0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E,
+
+    0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E,
+    0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C,
+    0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E,
+
+    0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E,
+    0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C,
+    0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E,
+
+    0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E,
+    0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C,
+    0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E,
+
+    0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E,
+    0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C,
+    0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E,
+
+    0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E,
+    0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C,
+    0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E,
+
+    0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E,
+    0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C,
+    0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E,
+
+    /* PAL/PAL-N 720x576, 768x576 */
+
+    0x03,0x1C,0x03,0x7E,0x01,0x1C,0x05,0x7E,0x00,0x1C,0x07,0x7D,0x7F,0x1B,0x09,0x7D,
+    0x7E,0x1A,0x0B,0x7D,0x7D,0x19,0x0D,0x7D,0x7D,0x18,0x0F,0x7C,0x7C,0x16,0x12,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x12,0x16,0x7C,0x7C,0x0F,0x18,0x7D,0x7C,0x0D,0x19,0x7E,
+    0x7D,0x0B,0x1A,0x7E,0x7D,0x09,0x1B,0x7F,0x7E,0x07,0x1C,0x7F,0x7E,0x05,0x1C,0x01,
+
+    0x03,0x1B,0x03,0x7F,0x02,0x1B,0x05,0x7E,0x01,0x1B,0x07,0x7D,0x7F,0x1B,0x09,0x7D,
+    0x7E,0x1A,0x0B,0x7D,0x7E,0x19,0x0D,0x7C,0x7D,0x17,0x10,0x7C,0x7C,0x16,0x12,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x12,0x16,0x7C,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x19,0x7E,
+    0x7D,0x0B,0x1A,0x7E,0x7D,0x09,0x1B,0x7F,0x7D,0x07,0x1B,0x01,0x7E,0x05,0x1B,0x02,
+
+    0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E,0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D,
+    0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x18,0x7F,
+    0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1B,0x02,
+
+    0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D,0x01,0x1A,0x08,0x7D,0x00,0x1A,0x09,0x7D,
+    0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0E,0x7C,0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C,
+    0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E,
+    0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02,
+
+    0x04,0x19,0x04,0x7F,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x19,0x0A,0x7C,
+    0x7F,0x18,0x0C,0x7D,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x10,0x7C,0x7D,0x15,0x11,0x7D,
+    0x7D,0x13,0x13,0x7D,0x7D,0x11,0x15,0x7D,0x7C,0x10,0x16,0x7E,0x7C,0x0E,0x17,0x7F,
+    0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04,
+
+    0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D,
+    0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D,
+    0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E,
+    0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04,
+
+    0x05,0x18,0x05,0x7E,0x04,0x18,0x07,0x7D,0x03,0x18,0x08,0x7D,0x01,0x18,0x0A,0x7D,
+    0x00,0x17,0x0C,0x7D,0x7F,0x16,0x0E,0x7D,0x7F,0x15,0x0F,0x7D,0x7E,0x14,0x11,0x7D,
+    0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x16,0x7F,
+    0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x18,0x03,0x7D,0x07,0x18,0x04,
+
+    /* PAL/PAL-N 800x600 */
+
+    0x04,0x1A,0x04,0x7E,0x02,0x1A,0x05,0x7F,0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D,
+    0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C,
+    0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x18,0x7F,
+    0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1A,0x03,
+
+    0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D,0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D,
+    0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C,0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C,
+    0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E,
+    0x7D,0x0C,0x19,0x7E,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02,
+
+    0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x19,0x0A,0x7C,
+    0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x10,0x7C,0x7D,0x15,0x11,0x7D,
+    0x7D,0x13,0x13,0x7D,0x7D,0x11,0x15,0x7D,0x7C,0x10,0x16,0x7E,0x7C,0x0E,0x17,0x7F,
+    0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04,
+
+    0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D,
+    0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D,
+    0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E,
+    0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04,
+
+    0x05,0x18,0x05,0x7E,0x04,0x18,0x07,0x7D,0x03,0x18,0x08,0x7D,0x01,0x18,0x0A,0x7D,
+    0x00,0x17,0x0C,0x7D,0x7F,0x16,0x0E,0x7D,0x7F,0x15,0x0F,0x7D,0x7E,0x14,0x11,0x7D,
+    0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x16,0x7F,
+    0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x18,0x03,0x7D,0x07,0x18,0x04,
+
+    0x06,0x18,0x06,0x7C,0x04,0x18,0x07,0x7D,0x03,0x18,0x09,0x7C,0x02,0x17,0x0A,0x7D,
+    0x01,0x17,0x0C,0x7C,0x00,0x16,0x0E,0x7C,0x7F,0x15,0x0F,0x7D,0x7E,0x14,0x11,0x7D,
+    0x7E,0x12,0x12,0x7E,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x15,0x7F,0x7D,0x0E,0x16,0x7F,
+    0x7D,0x0C,0x17,0x00,0x7D,0x0A,0x17,0x02,0x7D,0x09,0x18,0x02,0x7D,0x07,0x18,0x04,
+
+    0x06,0x17,0x06,0x7D,0x05,0x17,0x07,0x7D,0x03,0x17,0x09,0x7D,0x02,0x17,0x0A,0x7D,
+    0x01,0x16,0x0C,0x7D,0x00,0x15,0x0E,0x7D,0x7F,0x14,0x0F,0x7E,0x7F,0x13,0x11,0x7D,
+    0x7E,0x12,0x12,0x7E,0x7E,0x11,0x13,0x7E,0x7D,0x0F,0x14,0x00,0x7D,0x0E,0x15,0x00,
+    0x7D,0x0C,0x16,0x01,0x7D,0x0A,0x17,0x02,0x7D,0x09,0x17,0x03,0x7D,0x07,0x17,0x05
+};
+
+
 /* Mandatory functions */
 static void SISIdentify(int flags);
 static Bool SISProbe(DriverPtr drv, int flags);
@@ -1070,7 +1302,7 @@
 static void    SISWaitVBRetrace(ScrnInfoPtr pScrn);
 void           SISWaitRetraceCRT1(ScrnInfoPtr pScrn);
 void           SISWaitRetraceCRT2(ScrnInfoPtr pScrn);
-Bool           InRegion(int x, int y, region r);
+static Bool    InRegion(int x, int y, region r);
 #ifdef SISMERGED
 static void    SISMergePointerMoved(int scrnIndex, int x, int y);
 #endif

Index: sis_opt.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c,v
retrieving revision 1.1.4.3
retrieving revision 1.1.4.4
diff -u -d -r1.1.4.3 -r1.1.4.4
--- a/sis_opt.c	20 Dec 2003 00:28:28 -0000	1.1.4.3
+++ b/sis_opt.c	23 Feb 2004 21:35:46 -0000	1.1.4.4
@@ -1,32 +1,40 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c,v 1.50 2003/12/09 17:49:26 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c,v 1.55 2004/01/23 22:29:05 twini Exp $ */
 /*
  * SiS driver option evaluation
  *
- * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * Based on code by ? (included in XFree86 4.1)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the supplier not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The supplier makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * THE SUPPLIER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * "NoAccel", "NoXVideo", "SWCursor", "HWCursor" and "Rotate" option portions
+ * Copyright (C) 1999-2004 The XFree86 Project, Inc. Licensed under the terms
+ * of the XFree86 license (http://www.xfree86.org/current/LICENSE1.html).
  *
  * Authors:  	Thomas Winischhofer <thomas at winischhofer.net>
- *		?
+ *              ?
  */
 
 #include "xf86.h"
@@ -48,6 +56,7 @@
     OPTION_RENDER,
     OPTION_FORCE_CRT1TYPE,
     OPTION_FORCE_CRT2TYPE,
+    OPTION_YPBPRAR,
     OPTION_SHADOW_FB,
     OPTION_DRI,
     OPTION_AGP_SIZE,
@@ -151,6 +160,7 @@
     { OPTION_RENDER,        		"RenderAcceleration",     OPTV_BOOLEAN,   {0}, FALSE },
     { OPTION_FORCE_CRT1TYPE,    	"ForceCRT1Type",          OPTV_STRING,    {0}, FALSE },
     { OPTION_FORCE_CRT2TYPE,    	"ForceCRT2Type",          OPTV_STRING,    {0}, FALSE },
+    { OPTION_YPBPRAR,  		  	"YPbPrAspectRatio",       OPTV_STRING,    {0}, FALSE },
     { OPTION_SHADOW_FB,         	"ShadowFB",               OPTV_BOOLEAN,   {0}, FALSE },
     { OPTION_DRI,         		"DRI",               	  OPTV_BOOLEAN,   {0}, FALSE },
     { OPTION_AGP_SIZE,			"AGPSize",      	  OPTV_INTEGER,   {0}, FALSE },
@@ -331,6 +341,7 @@
     pSiS->forcecrt2redetection = TRUE;   /* default changed since 13/09/2003 */
     pSiS->ForceCRT1Type = CRT1_VGA;
     pSiS->ForceCRT2Type = CRT2_DEFAULT;
+    pSiS->ForceYPbPrAR = TV_YPBPR169;
     pSiS->ForceTVType = -1;
     pSiS->CRT1gamma = TRUE;
     pSiS->CRT1gammaGiven = FALSE;
@@ -737,6 +748,9 @@
        if(xf86GetOptValString(pSiS->Options, OPTION_FORCE_CRT2TYPE)) {
           xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "ForceCRT2Type");
        }
+       if(xf86GetOptValString(pSiS->Options, OPTION_YPBPRAR)) {
+          xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "YPbPrAspectRatio");
+       }
        if(xf86GetOptValBool(pSiS->Options, OPTION_SCALELCD, &val)) {
           xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mystring, "ScaleLCD");
        }
@@ -994,24 +1008,52 @@
                 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 if((!xf86NameCmp(strptr,"DSTN")) && (pSiS->Chipset == PCI_CHIP_SIS550)) {
+		if(pSiS->ForceCRT1Type == CRT1_VGA) {
+		   pSiS->ForceCRT2Type = CRT2_LCD;
+		   pSiS->DSTN = TRUE;
 		}
+	     } else if((!xf86NameCmp(strptr,"FSTN")) && (pSiS->Chipset == PCI_CHIP_SIS550)) {
+		if(pSiS->ForceCRT1Type == CRT1_VGA) {
+		   pSiS->ForceCRT2Type = CRT2_LCD;
+		   pSiS->FSTN = TRUE;
+		}
+#ifdef ENABLE_YPBPR
+	     } else if(!xf86NameCmp(strptr,"HIVISION")) {
+		pSiS->ForceCRT2Type = CRT2_TV;
+	        pSiS->ForceTVType = TV_HIVISION;
+	     } else if((!xf86NameCmp(strptr,"YPBPR1080I")) && (pSiS->VGAEngine == SIS_315_VGA)) {
+	        pSiS->ForceCRT2Type = CRT2_TV;
+		pSiS->ForceTVType = TV_YPBPR;
+		pSiS->ForceYPbPrType = TV_YPBPR1080I;
+	     } else if(((!xf86NameCmp(strptr,"YPBPR525I")) || (!xf86NameCmp(strptr,"YPBPR480I"))) &&
+	               (pSiS->VGAEngine == SIS_315_VGA)) {
+		pSiS->ForceCRT2Type = CRT2_TV;
+		pSiS->ForceTVType = TV_YPBPR;
+		pSiS->ForceYPbPrType = TV_YPBPR525I;
+	     } else if(((!xf86NameCmp(strptr,"YPBPR525P")) || (!xf86NameCmp(strptr,"YPBPR480P"))) &&
+	               (pSiS->VGAEngine == SIS_315_VGA)) {
+		pSiS->ForceCRT2Type = CRT2_TV;
+		pSiS->ForceTVType = TV_YPBPR;
+		pSiS->ForceYPbPrType = TV_YPBPR525P;
+	     } else if(((!xf86NameCmp(strptr,"YPBPR750P")) || (!xf86NameCmp(strptr,"YPBPR720P"))) &&
+	               (pSiS->VGAEngine == SIS_315_VGA)) {
+		pSiS->ForceCRT2Type = CRT2_TV;
+		pSiS->ForceTVType = TV_YPBPR;
+		pSiS->ForceYPbPrType = TV_YPBPR750P;
+#endif
 	     } else {
 	        xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "ForceCRT2Type");
 	        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 	            "Valid parameters are \"LCD\" (=\"DVI-D\"), \"TV\", \"SVIDEO\", \"COMPOSITE\",\n"
-		    "\t\"SVIDEO+COMPOSITE\", \"SCART\", \"VGA\" (=\"DVI-A\") or \"NONE\", on the SiS550\n"
-		    "\talso \"DSTN\" and \"FSTN\"\n");
+		    "\t\"SVIDEO+COMPOSITE\", \"SCART\", \"VGA\" (=\"DVI-A\") or \"NONE\"; on the SiS550\n"
+		    "\talso \"DSTN\" and \"FSTN\""
+#ifdef ENABLE_YPBPR
+		    				"; on SiS 301/301B bridges also \"HIVISION\", and on\n"
+		    "\tSiS315/330 series with 301C/30xLV bridge also \"YPBPR480I\", \"YPBPR480P\",\n"
+		    "\t\"YPBPR720P\" and \"YPBPR1080I\""
+#endif
+		    "\n");
 	     }
 
              if(pSiS->ForceCRT2Type != CRT2_DEFAULT)
@@ -1019,6 +1061,23 @@
                     "CRT2 type shall be %s\n", strptr);
           }
 
+	  if(pSiS->ForceTVType == TV_YPBPR) {
+	     strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_YPBPRAR);
+             if(strptr != NULL) {
+	        if(!xf86NameCmp(strptr,"4:3LB"))
+                   pSiS->ForceYPbPrAR = TV_YPBPR43LB;
+		else if(!xf86NameCmp(strptr,"4:3"))
+                   pSiS->ForceYPbPrAR = TV_YPBPR43;
+		else if(!xf86NameCmp(strptr,"16:9"))
+                   pSiS->ForceYPbPrAR = TV_YPBPR169;
+		else {
+		   xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "YPbPrAspectRatio");
+		   xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+	            	"Valid parameters are \"4:3LB\", \"4:3\" and \"16:9\"\n");
+		}
+	     }
+	  }
+
 	  strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_SPECIALTIMING);
           if(strptr != NULL) {
 	     int i = 0;
@@ -1192,21 +1251,21 @@
           }
        }
 
-      /* CHTVType  (315/330 series only)
+      /* CHTVType  (315/330 series + Chrontel only)
        * Used for telling the driver if the TV output shall
-       * be 480i HDTV or SCART.
+       * be 525i YPbPr or SCART.
        */
        if(pSiS->VGAEngine == SIS_315_VGA) {
           strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CHTVTYPE);
           if(strptr != NULL) {
              if(!xf86NameCmp(strptr,"SCART"))
                 pSiS->chtvtype = 1;
- 	     else if(!xf86NameCmp(strptr,"HDTV"))
+ 	     else if(!xf86NameCmp(strptr,"YPBPR525I"))
 	        pSiS->chtvtype = 0;
 	     else {
 	        xf86DrvMsg(pScrn->scrnIndex, X_WARNING, mybadparm, strptr, "CHTVType");
 	        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-	          "Valid parameters are \"SCART\" or \"HDTV\"\n");
+	          "Valid parameters are \"SCART\" or \"YPBPR525I\"\n");
 	     }
              if(pSiS->chtvtype != -1)
                 xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,

Index: sis_regs.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis_regs.h	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis_regs.h	23 Feb 2004 21:35:46 -0000	1.1.4.2
@@ -1,30 +1,41 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h,v 1.24 2003/10/30 18:53:43 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h,v 1.27 2004/01/23 22:29:05 twini Exp $ */
 /*
- * 2D Acceleration for SiS300, SiS540, SiS630, SiS730, SiS530, SiS620
+ * Register definitions for old and 300 series
  *
- * Copyright 1998,1999 by Alan Hourihane, Wigan, England.
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Old series register definitions
+ * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England.
+ *
+ * Authors:	Thomas Winischhofer <thomas at winischhofer.net>
+ *		Alan Hourihane
  *
  */
- 
 
 /* For general use --------------------------------------------------------------- */
 

Index: sis_setup.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis_setup.c	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis_setup.c	23 Feb 2004 21:35:46 -0000	1.1.4.2
@@ -1,28 +1,37 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c,v 1.25 2003/11/06 19:10:01 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c,v 1.29 2004/01/23 22:29:05 twini Exp $ */
 /*
  * Basic hardware and memory detection
  *
- * Copyright 2001, 2002, 2003 by Thomas Winischhofer, Vienna, Austria.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria.
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * Author:  Thomas Winischhofer <thomas at winischhofer.net>
+ * Author:  	Thomas Winischhofer <thomas at winischhofer.net>
+ *
+ * Ideas and methods for old series based on code by Can-Ru Yeou, SiS Inc.
  *
  */
  
@@ -593,7 +602,7 @@
     if(!alldone) {
 
        if(pSiS->Chipset == PCI_CHIP_SIS660) {
-          inSISIDXREG(SISSR, 0x79, config);
+          inSISIDXREG(SISCR, 0x79, config);
 	  pScrn->videoRam = (1 << ((config & 0xf0) >> 4)) * 1024;
 	  pSiS->BusWidth = (config & 0x04) ? 128 : 64;
           ramtype = (config & 0x01) ? 8 : 4;
@@ -650,7 +659,7 @@
 	break;
     case    PCI_CHIP_SIS550:
     case    PCI_CHIP_SIS650: /* + 740 */
-    case    PCI_CHIP_SIS660: /* + 661,741,660,760 */
+    case    PCI_CHIP_SIS660: /* + 661,741,760 */
         sis550Setup(pScrn);
 	break;
     case    PCI_CHIP_SIS5597:

Index: sis_shadow.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_shadow.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis_shadow.c	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis_shadow.c	23 Feb 2004 21:35:46 -0000	1.1.4.2
@@ -1,28 +1,30 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_shadow.c,v 1.8 2003/10/30 18:53:43 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_shadow.c,v 1.10 2004/01/04 18:08:00 twini Exp $ */
 /*
- * Copyright (c) 1999,  The XFree86 Project Inc.
- * based on code written by Mark Vojkovich <markv at valinux.com>
+ * Copyright (C) 1999-2004 by The XFree86 Project, Inc.
+ * based on code written by Mark Vojkovich
+ *
+ * Licensed under the following terms:
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
+ * the above copyright notice appears in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * and that the name of the copyright holder not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holder makes no representations
  * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * "as is" without expressed or implied warranty.
  *
  * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
  * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  *
- *  TW: This module doesn't use CurrentLayout, because it is never
- *      active when DGA is active and vice versa.
+ * TW: This module doesn't use CurrentLayout, because it is never
+ *     active when DGA is active and vice versa.
  */
 
 #include "xf86.h"

Index: sis_shadow.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_shadow.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sis_shadow.h	26 Nov 2003 22:49:00 -0000	1.1.4.1
+++ b/sis_shadow.h	23 Feb 2004 21:35:46 -0000	1.1.4.2
@@ -1,17 +1,21 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_shadow.h,v 1.6 2003/10/30 18:53:43 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_shadow.h,v 1.8 2004/01/04 18:08:00 twini Exp $ */
 /*
+ * Copyright (C) 1999-2004 by The XFree86 Project, Inc.
+ *
+ * Licensed under the following terms:
+ *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
+ * the above copyright notice appears in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * and that the name of the copyright holder not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holder makes no representations
  * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * "as is" without expressed or implied warranty.
  *
  * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
  * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
@@ -19,7 +23,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  *
  */
- 
+
 void SISPointerMoved(int index, int x, int y);
 void SISRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
 void SISRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox);

Index: sis_vb.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.c,v
retrieving revision 1.1.4.3
retrieving revision 1.1.4.4
diff -u -d -r1.1.4.3 -r1.1.4.4
--- a/sis_vb.c	20 Dec 2003 00:28:28 -0000	1.1.4.3
+++ b/sis_vb.c	23 Feb 2004 21:35:46 -0000	1.1.4.4
@@ -1,27 +1,33 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.c,v 1.34 2003/12/16 17:35:07 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.c,v 1.41 2004/01/23 22:29:06 twini Exp $ */
 /*
  * Video bridge detection and configuration for 300, 315 and 330 series
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
  *		
@@ -80,6 +86,26 @@
 	{ VB_LCD_CUSTOM,      0,    0, LCD_CUSTOM,   }   /* f */
 };
 
+static const SiS_LCD_StStruct SiS661_LCD_Type[]=
+{
+        { VB_LCD_1024x768, 1024,  768, LCD_1024x768  },  /* 0 - invalid */
+	{ VB_LCD_800x600,   800,  600, LCD_800x600   },  /* 1 */
+	{ VB_LCD_1024x768, 1024,  768, LCD_1024x768  },  /* 2 */
+	{ VB_LCD_1280x1024,1280, 1024, LCD_1280x1024 },  /* 3 */
+	{ VB_LCD_640x480,   640,  480, LCD_640x480   },  /* 4 */
+	{ VB_LCD_1024x600, 1024,  600, LCD_1024x600  },  /* 5 */
+	{ VB_LCD_1152x864, 1152,  864, LCD_1152x864  },  /* 6 */
+	{ VB_LCD_1280x960, 1280,  960, LCD_1280x960  },  /* 7 */
+	{ VB_LCD_1152x768, 1152,  768, LCD_1152x768  },  /* 8 */
+	{ VB_LCD_1400x1050,1400, 1050, LCD_1400x1050 },  /* 9 */
+	{ VB_LCD_1280x768, 1280,  768, LCD_1280x768  },  /* a */
+	{ VB_LCD_1600x1200,1600, 1200, LCD_1600x1200 },  /* b */
+	{ VB_LCD_1280x800, 1280,  800, LCD_1280x800  },  /* c */
+	{ VB_LCD_1680x1050,1680, 1050, LCD_1680x1050 },  /* d */
+	{ VB_LCD_320x480,   320,  480, LCD_320x480   },  /* e */
+	{ VB_LCD_CUSTOM,      0,    0, LCD_CUSTOM,   }   /* f */
+};
+
 static Bool
 TestDDC1(ScrnInfoPtr pScrn)
 {
@@ -109,9 +135,9 @@
     if(SR1F & 0xc0) mustwait = TRUE;
 
     if(pSiS->VGAEngine == SIS_315_VGA) {
-       inSISIDXREG(SISCR,0x63,CR63);
+       inSISIDXREG(SISCR,pSiS->myCR63,CR63);
        CR63 &= 0x40;
-       andSISIDXREG(SISCR,0x63,0xBF);
+       andSISIDXREG(SISCR,pSiS->myCR63,0xBF);
     }
 
     inSISIDXREG(SISCR,0x17,CR17);
@@ -142,7 +168,7 @@
     }
 
     if(pSiS->VGAEngine == SIS_315_VGA) {
-       setSISIDXREG(SISCR,0x63,0xBF,CR63);
+       setSISIDXREG(SISCR,pSiS->myCR63,0xBF,CR63);
     }
 
     setSISIDXREG(SISCR,0x17,0x7F,CR17);
@@ -329,12 +355,18 @@
 	        pSiS->LCDwidth = SiS300_LCD_Type[(CR36 & 0x0f)].LCDwidth;
                 pSiS->sishw_ext.ulCRT2LCDType = SiS300_LCD_Type[(CR36 & 0x0f)].LCDtype;
 	        if(CR37 & 0x10) pSiS->VBLCDFlags |= VB_LCD_EXPANDING;
-	     } else {
+	     } else if(pSiS->sishw_ext.jChipType < SIS_661) {
 	        pSiS->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;
+	     } else {
+		pSiS->VBLCDFlags |= SiS661_LCD_Type[(CR36 & 0x0f)].VBLCD_lcdflag;
+                pSiS->LCDheight = SiS661_LCD_Type[(CR36 & 0x0f)].LCDheight;
+	        pSiS->LCDwidth = SiS661_LCD_Type[(CR36 & 0x0f)].LCDwidth;
+                pSiS->sishw_ext.ulCRT2LCDType = SiS661_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",
@@ -355,12 +387,13 @@
 void SISTVPreInit(ScrnInfoPtr pScrn)
 {
     SISPtr  pSiS = SISPTR(pScrn);
-    unsigned char SR16, SR38, CR32, CR35=0, CR38=0, CR79;
+    unsigned char SR16, SR38, CR32, CR35=0, CR38=0, CR79, CR39;
     int temp = 0;
 
     if(!(pSiS->VBFlags & VB_VIDEOBRIDGE)) return;
 
     inSISIDXREG(SISCR, 0x32, CR32);
+    inSISIDXREG(SISCR, 0x35, CR35);
     inSISIDXREG(SISSR, 0x16, SR16);
     inSISIDXREG(SISSR, 0x38, SR38);
     switch(pSiS->VGAEngine) {
@@ -368,7 +401,7 @@
        if(pSiS->Chipset == PCI_CHIP_SIS630) temp = 0x35;
        break;
     case SIS_315_VGA:
-       if(pSiS->Chipset != PCI_CHIP_SIS660) temp = 0x38;
+       temp = 0x38;
        break;
     }
     if(temp) {
@@ -381,27 +414,64 @@
 	CR32, SR16, SR38);
 #endif
 
-    if(CR32 & 0x47)
-       pSiS->VBFlags |= CRT2_TV;
+    if(CR32 & 0x47) pSiS->VBFlags |= CRT2_TV;
 
-    if(CR32 & 0x04)
-       pSiS->VBFlags |= TV_SCART;
+    if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTYPBPR) {
+       if(CR32 & 0x80) pSiS->VBFlags |= CRT2_TV;
+    } else {
+       CR32 &= 0x7f;
+    }
+
+    if(CR32 & 0x01)
+       pSiS->VBFlags |= TV_AVIDEO;
     else if(CR32 & 0x02)
        pSiS->VBFlags |= TV_SVIDEO;
-    else if(CR32 & 0x01)
-       pSiS->VBFlags |= TV_AVIDEO;
-    else if((CR32 & 0x40) && (!(pSiS->VBFlags & (VB_301C | VB_301LV | VB_302LV | VB_302ELV))))
-       pSiS->VBFlags |= (TV_SVIDEO | TV_HIVISION);
-    else if((CR38 & 0x04) && (pSiS->VBFlags & (VB_301C | VB_301LV | VB_302LV | VB_302ELV)))
+    else if(CR32 & 0x04)
+       pSiS->VBFlags |= TV_SCART;
+    else if((CR32 & 0x40) && (pSiS->SiS_SD_Flags & SiS_SD_SUPPORTHIVISION))
+       pSiS->VBFlags |= (TV_HIVISION | TV_PAL);
+    else if((CR32 & 0x80) && (pSiS->SiS_SD_Flags & SiS_SD_SUPPORTYPBPR)) {
        pSiS->VBFlags |= TV_YPBPR;
-    else if((CR38 & 0x04) && (pSiS->VBFlags & VB_CHRONTEL))
+       if(pSiS->Chipset == PCI_CHIP_SIS660) {
+          if(CR38 & 0x04) {
+             switch((CR35 & 0xE0)) {
+             case 0x20: pSiS->VBFlags |= TV_YPBPR525P; break;
+	     case 0x40: pSiS->VBFlags |= TV_YPBPR750P; break;
+	     case 0x60: pSiS->VBFlags |= TV_YPBPR1080I; break;
+	     default:   pSiS->VBFlags |= TV_YPBPR525I;
+	     }
+          }
+          inSISIDXREG(SISCR,0x39,CR39);
+	  CR39 &= 0x03;
+	  if(CR39 == 0x00)      pSiS->VBFlags |= TV_YPBPR43LB;
+	  else if(CR39 == 0x01) pSiS->VBFlags |= TV_YPBPR43;
+	  else if(CR39 == 0x02) pSiS->VBFlags |= TV_YPBPR169;
+	  else			pSiS->VBFlags |= TV_YPBPR43;
+       } else if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTYPBPR) {
+          if(CR38 & 0x08) {
+	     switch((CR38 & 0x30)) {
+	     case 0x10: pSiS->VBFlags |= TV_YPBPR525P; break;
+	     case 0x20: pSiS->VBFlags |= TV_YPBPR750P; break;
+	     case 0x30: pSiS->VBFlags |= TV_YPBPR1080I; break;
+	     default:   pSiS->VBFlags |= TV_YPBPR525I;
+	     }
+	  }
+	  if(pSiS->SiS_SD_Flags & SiS_SD_SUPPORTYPBPRAR) {
+             inSISIDXREG(SISCR,0x3B,CR39);
+	     CR39 &= 0x03;
+	     if(CR39 == 0x00)      pSiS->VBFlags |= TV_YPBPR43LB;
+	     else if(CR39 == 0x01) pSiS->VBFlags |= TV_YPBPR169;
+	     else if(CR39 == 0x03) pSiS->VBFlags |= TV_YPBPR43;
+	  }
+       }
+    } else if((CR38 & 0x04) && (pSiS->VBFlags & VB_CHRONTEL))
        pSiS->VBFlags |= (TV_CHSCART | TV_PAL);
     else if((CR38 & 0x08) && (pSiS->VBFlags & VB_CHRONTEL))
-       pSiS->VBFlags |= (TV_CHHDTV | TV_NTSC);
-	        
-    if(pSiS->VBFlags & (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION | TV_YPBPR)) {
+       pSiS->VBFlags |= (TV_CHYPBPR525I | TV_NTSC);
+
+    if(pSiS->VBFlags & (TV_SCART | TV_SVIDEO | TV_AVIDEO)) {
        if(pSiS->VGAEngine == SIS_300_VGA) {
-	  /* TW: Should be SR38, but this does not work. */
+	  /* Should be SR38, but this does not work. */
 	  if(SR16 & 0x20)
 	     pSiS->VBFlags |= TV_PAL;
           else
@@ -427,14 +497,14 @@
  	  } 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
+	  } else {
 	     pSiS->VBFlags |= TV_NTSC;
 	     if(CR35 & 0x02)      pSiS->VBFlags |= TV_NTSCJ;
+	  }
        } else {	/* 315, 330 */
 	  if(SR38 & 0x01) {
              pSiS->VBFlags |= TV_PAL;
@@ -444,16 +514,29 @@
 	     pSiS->VBFlags |= TV_NTSC;
        }
     }
-    
-    if(pSiS->VBFlags & (TV_SCART|TV_SVIDEO|TV_AVIDEO|TV_HIVISION|TV_YPBPR|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" :
-			      ((pSiS->VBFlags & TV_NTSCJ) ? "NTSCJ" : "NTSC")) :
-			   ((pSiS->VBFlags & TV_PALM) ? "PALM" :
-			   	((pSiS->VBFlags & TV_PALN) ? "PALN" : "PAL")) );
+
+    if(pSiS->VBFlags & (TV_SCART|TV_SVIDEO|TV_AVIDEO)) {
+       xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected default TV standard %s\n",
+          (pSiS->VBFlags & TV_NTSC) ?
+	     ((pSiS->VBFlags & TV_NTSCJ) ? "NTSCJ" : "NTSC") :
+	         ((pSiS->VBFlags & TV_PALM) ? "PALM" :
+		     ((pSiS->VBFlags & TV_PALN) ? "PALN" : "PAL")));
+    }
+
+    if(pSiS->VBFlags & TV_HIVISION) {
+       xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "BIOS reports HiVision TV\n");
+    }
+
+    if((pSiS->VBFlags & VB_CHRONTEL) && (pSiS->VBFlags & (TV_CHSCART|TV_CHYPBPR525I))) {
+       xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Chrontel: %s forced\n",
+       	(pSiS->VBFlags & TV_CHSCART) ? "SCART (PAL)" : "YPbPr (480i)");
+    }
+
+    if(pSiS->VBFlags & TV_YPBPR) {
+       xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected YPbPr TV (%s)\n",
+         (pSiS->VBFlags & TV_YPBPR525I) ? "480i" :
+	     ((pSiS->VBFlags & TV_YPBPR525P) ? "480p" :
+	        ((pSiS->VBFlags & TV_YPBPR750P) ? "720p" : "1080i")));
     }
 }
 

Index: sis_vb.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.h,v
retrieving revision 1.1.4.2
retrieving revision 1.1.4.3
diff -u -d -r1.1.4.2 -r1.1.4.3
--- a/sis_vb.h	6 Dec 2003 13:24:25 -0000	1.1.4.2
+++ b/sis_vb.h	23 Feb 2004 21:35:46 -0000	1.1.4.3
@@ -1,30 +1,37 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.h,v 1.12 2003/10/30 18:53:43 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.h,v 1.15 2004/01/23 22:29:06 twini Exp $ */
 /*
  * Video bridge detection and configuration for 300, 315 and 330 series
  * Data and prototypes
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
+ *
  */
 
 typedef struct _SiS_LCD_StStruct

Index: sis_vga.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c,v
retrieving revision 1.1.4.2
retrieving revision 1.1.4.3
diff -u -d -r1.1.4.2 -r1.1.4.3
--- a/sis_vga.c	6 Dec 2003 13:24:25 -0000	1.1.4.2
+++ b/sis_vga.c	23 Feb 2004 21:35:46 -0000	1.1.4.3
@@ -1,34 +1,39 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c,v 1.39 2003/11/24 19:08:53 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c,v 1.43 2004/01/23 22:29:06 twini Exp $ */
 /*
  * Mode setup and basic video bridge detection
  *
- * 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.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria.
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * Authors: 	Thomas Winischhofer <thomas at winischhofer.net>
- *          	...
+ * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
  *
+ * Init() function for old series (except for TV and FIFO calculation)
+ * previously based on code which is Copyright (C) 1998,1999 by Alan
+ * Hourihane, Wigan, England
  */
 
 #include "xf86.h"
@@ -978,7 +983,7 @@
     outSISIDXREG(SISPART4,0x11,tempbl);
     temp = tempbh | tempcl;
     setSISIDXREG(SISPART4,0x10,0xe0,temp);
-    SiS_DDC2Delay(pSiS->SiS_Pr, 0x1000);
+    SiS_DDC2Delay(pSiS->SiS_Pr, 0x1500);
     tempch &= 0x7f;
     inSISIDXREG(SISPART4,0x03,temp);
     temp ^= 0x0e;
@@ -991,42 +996,26 @@
 SISSense30x(ScrnInfoPtr pScrn)
 {
     SISPtr  pSiS = SISPTR(pScrn);
-    unsigned char backupP4_0d,backupP2_00,biosflag;
-    unsigned char svhs_bl, svhs_bh;
+    unsigned char backupP4_0d,backupP2_00,biosflag=0;
+    unsigned char svhs_bl=0, svhs_bh=0;
+    unsigned char cvbs_bl=0, cvbs_bh=0;
+    unsigned char vga2_bl=0, vga2_bh=0;
     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->VBFlags & (VB_301C | VB_302ELV))) {
+       outSISIDXREG(SISPART4,0x0d,(backupP4_0d | 0x04));
+    }
 
     inSISIDXREG(SISPART2,0x00,backupP2_00);
     outSISIDXREG(SISPART2,0x00,(backupP2_00 | 0x1c));
 
     SISDoSense(pScrn, 0, 0, 0, 0);
 
-    if(pSiS->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) {
@@ -1040,21 +1029,35 @@
 	   cvbs_bh = 0x00; cvbs_bl = 0xb3;
 	   biosflag = 2;
 	}
-	if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)) {
+
+	if(pSiS->VBFlags & (VB_301B|VB_302B|VB_301LV|VB_302LV)) {
 	   vga2_bh = 0x01; vga2_bl = 0x90;
 	   svhs_bh = 0x01; svhs_bl = 0x6b;
 	   cvbs_bh = 0x01; cvbs_bl = 0x74;
+	} else 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 {
+	   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;
+	   }
 	}
-	inSISIDXREG(SISPART4,0x01,myflag);
-	if(myflag & 0x04) {
-	   vga2_bh = 0x00; vga2_bl = 0xfd;
-	   svhs_bh = 0x00; svhs_bl = 0xdd;
-	   cvbs_bh = 0x00; cvbs_bl = 0xee;
-	}
+
 	vga2_ch = 0x0e;	vga2_cl = 0x08;
 	svhs_ch = 0x04;	svhs_cl = 0x04;
 	cvbs_ch = 0x08; cvbs_cl = 0x04;
 
+	if(pSiS->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;
+	}
+
 	if(pSiS->Chipset == PCI_CHIP_SIS300) {
 	   inSISIDXREG(SISSR,0x3b,myflag);
 	   if(!(myflag & 0x01)) {
@@ -1107,26 +1110,35 @@
 
     } else {
 
-	if(pSiS->sishw_ext.UseROM) {
-	   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];
+	if(pSiS->VBFlags & VB_301) {
+
+	   if(pSiS->sishw_ext.UseROM) {
+	      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 {
-	      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];
+	      vga2_bh = 0x00; vga2_bl = 0xd1;
+              svhs_bh = 0x00; svhs_bl = 0xb9;
+	      cvbs_bh = 0x00; cvbs_bl = 0xb3;
+	      biosflag = 2;
 	   }
-	} else {
-	   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_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)) {
+	   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;
+	   }
+
+	} else if(pSiS->VBFlags & (VB_301B|VB_302B|VB_301LV|VB_302LV)) {
+
 	   if(pSiS->sishw_ext.UseROM) {
 	      if(pSiS->Chipset == PCI_CHIP_SIS330) {
 	         vga2_bh = pSiS->BIOS[0xec]; vga2_bl = pSiS->BIOS[0xeb];
@@ -1138,7 +1150,7 @@
 	         cvbs_bh = pSiS->BIOS[0xc8]; cvbs_bl = pSiS->BIOS[0xc7];
 	      }
 	   } else {
-	      if(pSiS->VBFlags & (VB_301B|VB_301C|VB_302B)) {
+	      if(pSiS->VBFlags & (VB_301B|VB_302B)) {
 	         vga2_bh = 0x01; vga2_bl = 0x90;
 	         svhs_bh = 0x01; svhs_bl = 0x6b;
 	         cvbs_bh = 0x01; cvbs_bl = 0x74;
@@ -1148,19 +1160,17 @@
 	         cvbs_bh = 0x01; cvbs_bl = 0x00;
 	      }
 	   }
-	}
-	
-	if(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)) {
-	   inSISIDXREG(SISPART4,0x01,myflag);
-	   if(myflag & 0x04) {
-	      vga2_bh = 0x00; vga2_bl = 0xfd;
-	      svhs_bh = 0x00; svhs_bl = 0xdd;
-	      cvbs_bh = 0x00; cvbs_bl = 0xee;
-	   }
+
+	} 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;
+
 	}
 	
 	if(pSiS->VBFlags & (VB_301LV|VB_302LV|VB_302ELV)) {
-	   /* TW: No VGA2 or SCART on LV bridges */
+	   /* 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;
@@ -1175,6 +1185,7 @@
 
     andSISIDXREG(SISCR, 0x32, ~0x14);
     pSiS->postVBCR32 &= ~0x14;
+    
     if(vga2_ch || vga2_cl || vga2_bh || vga2_bl) {
 #ifdef TWDEBUG
        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -1208,6 +1219,37 @@
        if(biosflag & 0x01) pSiS->SiS_SD_Flags |= SiS_SD_VBHASSCART;
     }
 
+    if(pSiS->VBFlags & (VB_301C | VB_302ELV)) {
+       orSISIDXREG(SISPART4,0x0d,0x04);
+    }
+
+    andSISIDXREG(SISCR, 0x32, 0x3f);
+    pSiS->postVBCR32 &= 0x3f;
+
+    if((pSiS->VGAEngine == SIS_315_VGA) && (pSiS->VBFlags & (VB_301C|VB_301LV|VB_302LV|VB_302ELV))) {
+       outSISIDXREG(SISPART4,0x11,svhs_bl);
+       setSISIDXREG(SISPART4,0x10,0xE0,(svhs_bh|0x04));
+       SiS_DDC2Delay(pSiS->SiS_Pr, 0x1000);
+       inSISIDXREG(SISPART4,0x03,temp);
+       temp ^= 0x0E;
+       temp &= 0x06;
+       if(temp == 0x06) {
+          outSISIDXREG(SISPART4,0x11,cvbs_bl);
+	  setSISIDXREG(SISPART4,0x10,0xE0,(cvbs_bh|0x04));
+	  SiS_DDC2Delay(pSiS->SiS_Pr, 0x1000);
+	  inSISIDXREG(SISPART4,0x03,temp);
+          temp ^= 0x0E;
+	  temp &= 0x08;
+	  if(temp) {
+	     xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+     		"SiS30x: Detected TV connected to YPBPR output\n");
+	     orSISIDXREG(SISCR,0x32,0x80);
+	     pSiS->VBFlags |= TV_YPBPR;
+	     pSiS->postVBCR32 |= 0x80;
+	  }
+       }
+    }
+
 #ifdef TWDEBUG
     xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                 "SiS30x: Scanning for TV (%x %x %x %x; %x %x %x %x)\n",
@@ -1218,43 +1260,43 @@
     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");
-       pSiS->VBFlags |= TV_SVIDEO;
-       orSISIDXREG(SISCR, 0x32, 0x02);
-       pSiS->postVBCR32 |= 0x02;
-    }
-
-    if((biosflag & 0x02) || (!(result))) {
+    if(!(pSiS->VBFlags & TV_YPBPR)) {
 
        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))
+             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 COMPOSITE output\n");
-	  pSiS->VBFlags |= TV_AVIDEO;
-	  orSISIDXREG(SISCR, 0x32, 0x01);
-	  pSiS->postVBCR32 |= 0x01;
+          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))) {
+
+          for(j = 0; j < 10; j++) {
+             result = 0;
+             for(i = 0; i < 3; i++) {
+                if(SISDoSense(pScrn, cvbs_bl, cvbs_bh, cvbs_cl, cvbs_ch))
+	           result++;
+             }
+             if((result == 0) || (result >= 2)) break;
+          }
+          if(result) {
+	     xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+	             "SiS30x: Detected TV connected to COMPOSITE output\n");
+	     pSiS->VBFlags |= TV_AVIDEO;
+	     orSISIDXREG(SISCR, 0x32, 0x01);
+	     pSiS->postVBCR32 |= 0x01;
+          }
        }
+
     }
 
     SISDoSense(pScrn, 0, 0, 0, 0);
@@ -1418,7 +1460,7 @@
 		inSISIDXREG(SISPART4, 0x23, temp2);
 		if(!(temp2 & 0x02)) pSiS->VBFlags |= VB_30xBDH;
     		xf86DrvMsg(pScrn->scrnIndex, X_PROBED, detectvb,
-				(temp2 & 0x02) ? "SiS301B" : "SiS301B-DH", temp1);
+				(temp2 & 0x02) ? "SiS301B" : "SiS301B-DH", 1, temp1);
 	} else {
 	        pSiS->VBFlags |= VB_301;
 		pSiS->sishw_ext.ujVBChipID = VB_CHIP_301;
@@ -1445,7 +1487,7 @@
 		inSISIDXREG(SISPART4, 0x23, temp2);
 		if(!(temp & 0x02)) pSiS->VBFlags |= VB_30xBDH;
     		xf86DrvMsg(pScrn->scrnIndex, X_PROBED, detectvb,
-				(temp2 & 0x02) ? "SiS302B" : "SiS302B-DH", temp1);
+				(temp2 & 0x02) ? "SiS302B" : "SiS302B-DH", 2, temp1);
 	}
 
 	SISSense30x(pScrn);
@@ -1623,10 +1665,10 @@
                         break;
 		     case 0x04:
 			xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
-			   "Chrontel: Detected TV connected to SCART output or 480i HDTV\n");
+			   "Chrontel: Detected TV connected to SCART or YPBPR output\n");
 			if(pSiS->chtvtype == -1) {
 			   xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-			      "Chrontel: Use CHTVType option to select either SCART or HDTV\n");
+			      "Chrontel: Use CHTVType option to select either SCART or YPBPR525I\n");
 			   xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 			      "Chrontel: Using SCART by default\n");
 			   pSiS->chtvtype = 1;
@@ -1634,7 +1676,7 @@
 			if(pSiS->chtvtype)
 			    pSiS->VBFlags |= TV_CHSCART;
 			else
-			    pSiS->VBFlags |= TV_CHHDTV;
+			    pSiS->VBFlags |= TV_CHYPBPR525I;
                         break;
 		     default:
 		        xf86DrvMsg(pScrn->scrnIndex, X_PROBED,

Index: sis_video.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_video.c,v
retrieving revision 1.1.4.2
retrieving revision 1.1.4.3
diff -u -d -r1.1.4.2 -r1.1.4.3
--- a/sis_video.c	20 Dec 2003 00:28:28 -0000	1.1.4.2
+++ b/sis_video.c	23 Feb 2004 21:35:46 -0000	1.1.4.3
@@ -1,40 +1,42 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_video.c,v 1.44 2003/12/16 17:35:07 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_video.c,v 1.48 2004/01/23 22:29:06 twini Exp $ */
 /*
  * Xv driver for SiS 300, 315 and 330 series.
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria.
- * All Rights Reserved.
- *
- * Basic structure based on the mga Xv driver by Mark Vojkovich
- * and i810 Xv driver by Jonathan Bian <jonathan.bian at intel.com>.
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria.
  *
- * Formerly based on a mostly non-working fragment for the 630 by
- * Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1) Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2) Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3) All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement: "This product includes
+ *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * 4) The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * Author:    Thomas Winischhofer <thomas at winischhofer.net>
  *
- * Authors:
- *	Thomas Winischhofer <thomas at winischhofer.net>:
- *      (Original code fragment for 630 by
- *            Sung-Ching Lin <sclin at sis.com.tw>)
+ * Formerly based on a mostly non-working code fragment for the 630 by
+ * Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan which is
+ * Copyright (C) 2000 Silicon Integrated Systems Corp, Inc.
  *
+ * Basic structure based on the mga Xv driver by Mark Vojkovich
+ * and i810 Xv driver by Jonathan Bian <jonathan.bian at intel.com>.
  *
  * All comments in this file are by Thomas Winischhofer.
  *
@@ -1603,6 +1605,7 @@
 #endif
         if(pSiS->xv_sisdirectunlocked) {
 	   SISSwitchCRT2Type(pScrn, (unsigned long)value);
+	   set_dispmode(pScrn, pPriv);
 	   set_allowswitchcrt(pSiS, pPriv);
 	   set_maxencoding(pSiS, pPriv);
         }
@@ -1612,6 +1615,7 @@
 #endif
         if(pSiS->xv_sisdirectunlocked) {
 	   SISSwitchCRT1Status(pScrn, (unsigned long)value);
+	   set_dispmode(pScrn, pPriv);
 	   set_allowswitchcrt(pSiS, pPriv);
 	   set_maxencoding(pSiS, pPriv);
         }

Index: vgatypes.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/vgatypes.h,v
retrieving revision 1.1.4.3
retrieving revision 1.1.4.4
diff -u -d -r1.1.4.3 -r1.1.4.4
--- a/vgatypes.h	20 Dec 2003 00:28:29 -0000	1.1.4.3
+++ b/vgatypes.h	23 Feb 2004 21:35:46 -0000	1.1.4.4
@@ -1,37 +1,57 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/vgatypes.h,v 1.18 2003/12/16 17:45:20 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/vgatypes.h,v 1.21 2004/01/23 22:29:06 twini Exp $ */
 /*
  * General type definitions for universal mode switching modules
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * If distributed as part of the linux kernel, the contents of this file
- * is entirely covered by the GPL.
+ * If distributed as part of the Linux kernel, the following license terms
+ * apply:
  *
- * Otherwise, the following terms apply:
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation; either version 2 of the named License,
+ * * or any later version.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Otherwise, the following license terms apply:
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * * Redistribution and use in source and binary forms, with or without
+ * * modification, are permitted provided that the following conditions
+ * * are met:
+ * * 1) Redistributions of source code must retain the above copyright
+ * *    notice, this list of conditions and the following disclaimer.
+ * * 2) Redistributions in binary form must reproduce the above copyright
+ * *    notice, this list of conditions and the following disclaimer in the
+ * *    documentation and/or other materials provided with the distribution.
+ * * 3) All advertising materials mentioning features or use of this software
+ * *    must display the following acknowledgement: "This product includes
+ * *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * * 4) The name of the author may not be used to endorse or promote products
+ * *    derived from this software without specific prior written permission.
+ * *
+ * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * Authors: 	Thomas Winischhofer <thomas at winischhofer.net>
- *		Silicon Integrated Systems
+ * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
  *
  */
+
 #ifndef _VGATYPES_
 #define _VGATYPES_
 
@@ -165,6 +185,8 @@
     LCD_640x480_2,     /* FSTN, DSTN */
     LCD_640x480_3,     /* FSTN, DSTN */
     LCD_848x480,
+    LCD_1280x800,
+    LCD_1680x1050,
     LCD_CUSTOM,
     LCD_UNKNOWN
 } SIS_LCD_TYPE;

Index: vstruct.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/sis/vstruct.h,v
retrieving revision 1.1.4.3
retrieving revision 1.1.4.4
diff -u -d -r1.1.4.3 -r1.1.4.4
--- a/vstruct.h	20 Dec 2003 00:28:29 -0000	1.1.4.3
+++ b/vstruct.h	23 Feb 2004 21:35:46 -0000	1.1.4.4
@@ -1,35 +1,54 @@
-/* $XdotOrg$ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/vstruct.h,v 1.26 2003/12/16 17:35:07 twini Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/vstruct.h,v 1.32 2004/01/23 22:29:06 twini Exp $ */
 /*
  * General structure definitions for universal mode switching modules
  *
- * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
+ * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
  *
- * If distributed as part of the linux kernel, the contents of this file
- * is entirely covered by the GPL.
+ * If distributed as part of the Linux kernel, the following license terms
+ * apply:
  *
- * Otherwise, the following terms apply:
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation; either version 2 of the named License,
+ * * or any later version.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holder not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holder makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
+ * Otherwise, the following license terms apply:
  *
- * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * * Redistribution and use in source and binary forms, with or without
+ * * modification, are permitted provided that the following conditions
+ * * are met:
+ * * 1) Redistributions of source code must retain the above copyright
+ * *    notice, this list of conditions and the following disclaimer.
+ * * 2) Redistributions in binary form must reproduce the above copyright
+ * *    notice, this list of conditions and the following disclaimer in the
+ * *    documentation and/or other materials provided with the distribution.
+ * * 3) All advertising materials mentioning features or use of this software
+ * *    must display the following acknowledgement: "This product includes
+ * *    software developed by Thomas Winischhofer, Vienna, Austria."
+ * * 4) The name of the author may not be used to endorse or promote products
+ * *    derived from this software without specific prior written permission.
+ * *
+ * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+ * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * Authors: 	Thomas Winischhofer <thomas at winischhofer.net>
- *              Silicon Integrated Systems
+ * Author: 	Thomas Winischhofer <thomas at winischhofer.net>
  *
  */
  
@@ -281,7 +300,8 @@
 	BOOLEAN HaveEMILCD;
 	BOOLEAN OverruleEMI;
 	UCHAR  EMI_30,EMI_31,EMI_32,EMI_33;
-	UCHAR  PDC;
+	SHORT  PDC;
+	UCHAR  SiS_MyCR63;
 	USHORT SiS_CRT1Mode;
 	USHORT SiS_flag_clearbuffer;
 	int    SiS_RAMType;
@@ -320,11 +340,13 @@
 	USHORT SiS_DDC_Port;
 	USHORT SiS_DDC_Index;
 	USHORT SiS_DDC_Data;
+	USHORT SiS_DDC_NData;
 	USHORT SiS_DDC_Clk;
-	USHORT SiS_DDC_DataShift;
+	USHORT SiS_DDC_NClk;
 	USHORT SiS_DDC_DeviceAddr;
 	USHORT SiS_DDC_ReadAddr;
 	USHORT SiS_DDC_SecAddr;
+	BOOLEAN SiS_SensibleSR11;
 	USHORT SiS_Panel800x600;
 	USHORT SiS_Panel1024x768;
 	USHORT SiS_Panel1280x1024;
@@ -422,17 +444,26 @@
 	const SiS_TVDataStruct   *SiS_ExtPALData;
 	const SiS_TVDataStruct   *SiS_StNTSCData;
 	const SiS_TVDataStruct   *SiS_ExtNTSCData;
+	const SiS_TVDataStruct   *SiS_St1HiTVData;
 	const SiS_TVDataStruct   *SiS_St2HiTVData;
 	const SiS_TVDataStruct   *SiS_ExtHiTVData;
+	const SiS_TVDataStruct   *SiS_St525iData;
+	const SiS_TVDataStruct   *SiS_St525pData;
+	const SiS_TVDataStruct   *SiS_St750pData;
+	const SiS_TVDataStruct   *SiS_Ext525iData;
+	const SiS_TVDataStruct   *SiS_Ext525pData;
+	const SiS_TVDataStruct   *SiS_Ext750pData;
 	const UCHAR *SiS_NTSCTiming;
 	const UCHAR *SiS_PALTiming;
 	const UCHAR *SiS_HiTVExtTiming;
 	const UCHAR *SiS_HiTVSt1Timing;
 	const UCHAR *SiS_HiTVSt2Timing;
-	const UCHAR *SiS_HiTVTextTiming;
 	const UCHAR *SiS_HiTVGroup3Data;
 	const UCHAR *SiS_HiTVGroup3Simu;
+#if 0
+	const UCHAR *SiS_HiTVTextTiming;
 	const UCHAR *SiS_HiTVGroup3Text;
+#endif
 	const SiS_PanelDelayTblStruct *SiS_PanelDelayTbl;
 	const SiS_PanelDelayTblStruct *SiS_PanelDelayTblLVDS;
 	const SiS_LVDSDataStruct  *SiS_LVDS800x600Data_1;





More information about the xorg-commit mailing list