vserver 2.0 rc7
[linux-2.6.git] / drivers / video / sis / init.h
1 /* $XFree86$ */
2 /* $XdotOrg$ */
3 /*
4  * Data and prototypes for init.c
5  *
6  * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
7  *
8  * If distributed as part of the Linux kernel, the following license terms
9  * apply:
10  *
11  * * This program is free software; you can redistribute it and/or modify
12  * * it under the terms of the GNU General Public License as published by
13  * * the Free Software Foundation; either version 2 of the named License,
14  * * or any later version.
15  * *
16  * * This program is distributed in the hope that it will be useful,
17  * * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * * GNU General Public License for more details.
20  * *
21  * * You should have received a copy of the GNU General Public License
22  * * along with this program; if not, write to the Free Software
23  * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
24  *
25  * Otherwise, the following license terms apply:
26  *
27  * * Redistribution and use in source and binary forms, with or without
28  * * modification, are permitted provided that the following conditions
29  * * are met:
30  * * 1) Redistributions of source code must retain the above copyright
31  * *    notice, this list of conditions and the following disclaimer.
32  * * 2) Redistributions in binary form must reproduce the above copyright
33  * *    notice, this list of conditions and the following disclaimer in the
34  * *    documentation and/or other materials provided with the distribution.
35  * * 3) The name of the author may not be used to endorse or promote products
36  * *    derived from this software without specific prior written permission.
37  * *
38  * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
39  * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
41  * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
42  * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43  * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44  * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
45  * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46  * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
47  * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48  *
49  * Author:      Thomas Winischhofer <thomas@winischhofer.net>
50  *
51  */
52
53 #ifndef _INIT_
54 #define _INIT_
55
56 #include "osdef.h"
57 #include "initdef.h"
58
59 #ifdef LINUX_XF86
60 #include "sis.h"
61 #include "sis_regs.h"
62 #endif
63
64 #ifdef LINUX_KERNEL
65 #include "vgatypes.h"
66 #include "vstruct.h"
67 #ifdef SIS_CP
68 #undef SIS_CP
69 #endif
70 #include <linux/config.h>
71 #include <linux/version.h>
72 #include <linux/types.h>
73 #include <asm/io.h>
74 #include <linux/fb.h>
75 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
76 #include <linux/sisfb.h>
77 #else
78 #include <video/sisfb.h>
79 #endif
80 #endif
81
82 /* Mode numbers */
83 static const USHORT ModeIndex_320x200[]      = {0x59, 0x41, 0x00, 0x4f};
84 static const USHORT ModeIndex_320x240[]      = {0x50, 0x56, 0x00, 0x53};
85 static const USHORT ModeIndex_320x240_FSTN[] = {0x5a, 0x5b, 0x00, 0x00};  /* FSTN */
86 static const USHORT ModeIndex_400x300[]      = {0x51, 0x57, 0x00, 0x54};
87 static const USHORT ModeIndex_512x384[]      = {0x52, 0x58, 0x00, 0x5c};
88 static const USHORT ModeIndex_640x400[]      = {0x2f, 0x5d, 0x00, 0x5e};
89 static const USHORT ModeIndex_640x480[]      = {0x2e, 0x44, 0x00, 0x62};
90 static const USHORT ModeIndex_720x480[]      = {0x31, 0x33, 0x00, 0x35};
91 static const USHORT ModeIndex_720x576[]      = {0x32, 0x34, 0x00, 0x36};
92 static const USHORT ModeIndex_768x576[]      = {0x5f, 0x60, 0x00, 0x61};
93 static const USHORT ModeIndex_800x480[]      = {0x70, 0x7a, 0x00, 0x76};
94 static const USHORT ModeIndex_800x600[]      = {0x30, 0x47, 0x00, 0x63};
95 static const USHORT ModeIndex_848x480[]      = {0x39, 0x3b, 0x00, 0x3e};
96 static const USHORT ModeIndex_856x480[]      = {0x3f, 0x42, 0x00, 0x45};
97 static const USHORT ModeIndex_960x540[]      = {0x1d, 0x1e, 0x00, 0x1f};  /* 315 series only */
98 static const USHORT ModeIndex_960x600[]      = {0x20, 0x21, 0x00, 0x22};  /* 315 series only */
99 static const USHORT ModeIndex_1024x768[]     = {0x38, 0x4a, 0x00, 0x64};
100 static const USHORT ModeIndex_1024x576[]     = {0x71, 0x74, 0x00, 0x77};
101 static const USHORT ModeIndex_1024x600[]     = {0x20, 0x21, 0x00, 0x22};  /* 300 series only */
102 static const USHORT ModeIndex_1280x1024[]    = {0x3a, 0x4d, 0x00, 0x65};
103 static const USHORT ModeIndex_1280x960[]     = {0x7c, 0x7d, 0x00, 0x7e};
104 static const USHORT ModeIndex_1152x768[]     = {0x23, 0x24, 0x00, 0x25};  /* 300 series only */
105 static const USHORT ModeIndex_1152x864[]     = {0x29, 0x2a, 0x00, 0x2b};
106 static const USHORT ModeIndex_300_1280x768[] = {0x55, 0x5a, 0x00, 0x5b};
107 static const USHORT ModeIndex_310_1280x768[] = {0x23, 0x24, 0x00, 0x25};
108 static const USHORT ModeIndex_1280x720[]     = {0x79, 0x75, 0x00, 0x78};
109 static const USHORT ModeIndex_1280x800[]     = {0x14, 0x15, 0x00, 0x16};
110 static const USHORT ModeIndex_1360x768[]     = {0x48, 0x4b, 0x00, 0x4e};
111 static const USHORT ModeIndex_300_1360x1024[]= {0x67, 0x6f, 0x00, 0x72};  /* 300 series, BARCO only */
112 static const USHORT ModeIndex_1400x1050[]    = {0x26, 0x27, 0x00, 0x28};  /* 315 series only */
113 static const USHORT ModeIndex_1680x1050[]    = {0x17, 0x18, 0x00, 0x19};  /* 315 series only */
114 static const USHORT ModeIndex_1600x1200[]    = {0x3c, 0x3d, 0x00, 0x66};
115 static const USHORT ModeIndex_1920x1080[]    = {0x2c, 0x2d, 0x00, 0x73};  /* 315 series only */
116 static const USHORT ModeIndex_1920x1440[]    = {0x68, 0x69, 0x00, 0x6b};
117 static const USHORT ModeIndex_300_2048x1536[]= {0x6c, 0x6d, 0x00, 0x00};
118 static const USHORT ModeIndex_310_2048x1536[]= {0x6c, 0x6d, 0x00, 0x6e};
119
120 static const USHORT SiS_DRAMType[17][5]={
121         {0x0C,0x0A,0x02,0x40,0x39},
122         {0x0D,0x0A,0x01,0x40,0x48},
123         {0x0C,0x09,0x02,0x20,0x35},
124         {0x0D,0x09,0x01,0x20,0x44},
125         {0x0C,0x08,0x02,0x10,0x31},
126         {0x0D,0x08,0x01,0x10,0x40},
127         {0x0C,0x0A,0x01,0x20,0x34},
128         {0x0C,0x09,0x01,0x08,0x32},
129         {0x0B,0x08,0x02,0x08,0x21},
130         {0x0C,0x08,0x01,0x08,0x30},
131         {0x0A,0x08,0x02,0x04,0x11},
132         {0x0B,0x0A,0x01,0x10,0x28},
133         {0x09,0x08,0x02,0x02,0x01},
134         {0x0B,0x09,0x01,0x08,0x24},
135         {0x0B,0x08,0x01,0x04,0x20},
136         {0x0A,0x08,0x01,0x02,0x10},
137         {0x09,0x08,0x01,0x01,0x00}
138 };
139
140 static const USHORT SiS_SDRDRAM_TYPE[13][5] =
141 {
142         { 2,12, 9,64,0x35},
143         { 1,13, 9,64,0x44},
144         { 2,12, 8,32,0x31},
145         { 2,11, 9,32,0x25},
146         { 1,12, 9,32,0x34},
147         { 1,13, 8,32,0x40},
148         { 2,11, 8,16,0x21},
149         { 1,12, 8,16,0x30},
150         { 1,11, 9,16,0x24},
151         { 1,11, 8, 8,0x20},
152         { 2, 9, 8, 4,0x01},
153         { 1,10, 8, 4,0x10},
154         { 1, 9, 8, 2,0x00}
155 };
156
157 static const USHORT SiS_DDRDRAM_TYPE[4][5] =
158 {
159         { 2,12, 9,64,0x35},
160         { 2,12, 8,32,0x31},
161         { 2,11, 8,16,0x21},
162         { 2, 9, 8, 4,0x01}
163 };
164
165 static const USHORT SiS_MDA_DAC[] =
166 {
167         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
168         0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
169         0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
170         0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
171         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
172         0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
173         0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
174         0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F
175 };
176
177 static const USHORT SiS_CGA_DAC[] =
178 {
179         0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
180         0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
181         0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
182         0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
183         0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
184         0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
185         0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
186         0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F
187 };
188
189 static const USHORT SiS_EGA_DAC[] =
190 {
191         0x00,0x10,0x04,0x14,0x01,0x11,0x05,0x15,
192         0x20,0x30,0x24,0x34,0x21,0x31,0x25,0x35,
193         0x08,0x18,0x0C,0x1C,0x09,0x19,0x0D,0x1D,
194         0x28,0x38,0x2C,0x3C,0x29,0x39,0x2D,0x3D,
195         0x02,0x12,0x06,0x16,0x03,0x13,0x07,0x17,
196         0x22,0x32,0x26,0x36,0x23,0x33,0x27,0x37,
197         0x0A,0x1A,0x0E,0x1E,0x0B,0x1B,0x0F,0x1F,
198         0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F
199 };
200
201 static const USHORT SiS_VGA_DAC[] =
202 {
203         0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
204         0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
205         0x00,0x05,0x08,0x0B,0x0E,0x11,0x14,0x18,
206         0x1C,0x20,0x24,0x28,0x2D,0x32,0x38,0x3F,
207         0x00,0x10,0x1F,0x2F,0x3F,0x1F,0x27,0x2F,
208         0x37,0x3F,0x2D,0x31,0x36,0x3A,0x3F,0x00,
209         0x07,0x0E,0x15,0x1C,0x0E,0x11,0x15,0x18,
210         0x1C,0x14,0x16,0x18,0x1A,0x1C,0x00,0x04,
211         0x08,0x0C,0x10,0x08,0x0A,0x0C,0x0E,0x10,
212         0x0B,0x0C,0x0D,0x0F,0x10
213 };
214
215 static const SiS_StResInfoStruct SiS_StResInfo[]=
216 {
217         { 640,400},
218         { 640,350},
219         { 720,400},
220         { 720,350},
221         { 640,480}
222 };
223
224 static const SiS_ModeResInfoStruct SiS_ModeResInfo[] =
225 {
226         {  320, 200, 8, 8},   /* 0x00 */
227         {  320, 240, 8, 8},   /* 0x01 */
228         {  320, 400, 8, 8},   /* 0x02 */
229         {  400, 300, 8, 8},   /* 0x03 */
230         {  512, 384, 8, 8},   /* 0x04 */
231         {  640, 400, 8,16},   /* 0x05 */
232         {  640, 480, 8,16},   /* 0x06 */
233         {  800, 600, 8,16},   /* 0x07 */
234         { 1024, 768, 8,16},   /* 0x08 */
235         { 1280,1024, 8,16},   /* 0x09 */
236         { 1600,1200, 8,16},   /* 0x0a */
237         { 1920,1440, 8,16},   /* 0x0b */
238         { 2048,1536, 8,16},   /* 0x0c */
239         {  720, 480, 8,16},   /* 0x0d */
240         {  720, 576, 8,16},   /* 0x0e */
241         { 1280, 960, 8,16},   /* 0x0f */
242         {  800, 480, 8,16},   /* 0x10 */
243         { 1024, 576, 8,16},   /* 0x11 */
244         { 1280, 720, 8,16},   /* 0x12 */
245         {  856, 480, 8,16},   /* 0x13 */
246         { 1280, 768, 8,16},   /* 0x14 */
247         { 1400,1050, 8,16},   /* 0x15 */
248         { 1152, 864, 8,16},   /* 0x16 */
249         {  848, 480, 8,16},   /* 0x17 */
250         { 1360, 768, 8,16},   /* 0x18 */
251         { 1024, 600, 8,16},   /* 0x19 */
252         { 1152, 768, 8,16},   /* 0x1a */
253         {  768, 576, 8,16},   /* 0x1b */
254         { 1360,1024, 8,16},   /* 0x1c */
255         { 1680,1050, 8,16},   /* 0x1d */
256         { 1280, 800, 8,16},   /* 0x1e */
257         { 1920,1080, 8,16},   /* 0x1f */
258         {  960, 540, 8,16},   /* 0x20 */
259         {  960, 600, 8,16}    /* 0x21 */
260 };
261
262 #if defined(SIS300) || defined(SIS315H)
263 static const SiS_StandTableStruct SiS_StandTable[]=
264 {
265 /* 0x00: MD_0_200 */
266  {
267   0x28,0x18,0x08,0x0800,
268   {0x09,0x03,0x00,0x02},
269   0x63,
270   {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
271    0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
272    0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
273    0xff},
274   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
275    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
276    0x08,0x00,0x0f,0x00},
277   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
278    0xff}
279  },
280 /* 0x01: MD_1_200 */
281  {
282   0x28,0x18,0x08,0x0800,
283   {0x09,0x03,0x00,0x02},
284   0x63,
285   {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
286    0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
287    0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
288    0xff},
289   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
290    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
291    0x08,0x00,0x0f,0x00},
292   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
293    0xff}
294  },
295 /* 0x02: MD_2_200 */
296  {
297   0x50,0x18,0x08,0x1000,
298   {0x01,0x03,0x00,0x02},
299   0x63,
300   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
301    0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
302    0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
303    0xff},
304   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
305    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
306    0x08,0x00,0x0f,0x00},
307   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
308    0xff}
309  },
310 /* 0x03: MD_3_200 - mode 0x03 - 0 */
311  {
312   0x50,0x18,0x08,0x1000,
313   {0x01,0x03,0x00,0x02},
314   0x63,
315   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
316    0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
317    0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
318    0xff},
319   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
320    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
321    0x08,0x00,0x0f,0x00},
322   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
323    0xff}
324  },
325 /* 0x04: MD_4 */
326  {
327   0x28,0x18,0x08,0x4000,
328   {0x09,0x03,0x00,0x02},
329   0x63,
330   {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,   /* 0x2c is 2b for 300 */
331    0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
332    0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
333    0xff},
334   {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
335    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
336    0x01,0x00,0x03,0x00},
337   {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
338    0xff}
339  },
340 /* 0x05: MD_5 */
341  {
342   0x28,0x18,0x08,0x4000,
343   {0x09,0x03,0x00,0x02},
344   0x63,
345   {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,   /* 0x2c is 2b for 300 */
346    0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
347    0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
348    0xff},
349   {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
350    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
351    0x01,0x00,0x03,0x00},
352   {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
353    0xff}
354  },
355 /* 0x06: MD_6 */
356  {
357   0x50,0x18,0x08,0x4000,
358   {0x01,0x01,0x00,0x06},
359   0x63,
360   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,   /* 55,81 is 54,80 for 300 */
361    0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
362    0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2,
363    0xff},
364   {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
365    0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
366    0x01,0x00,0x01,0x00},
367   {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00,
368    0xff}
369  },
370 /* 0x07: MD_7 */
371  {
372   0x50,0x18,0x0e,0x1000,
373   {0x00,0x03,0x00,0x03},
374   0xa6,
375   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
376    0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
377    0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3,
378    0xff},
379   {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
380    0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
381    0x0e,0x00,0x0f,0x08},
382   {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
383    0xff}
384  },
385 /* 0x08: MDA_DAC */
386  {
387   0x00,0x00,0x00,0x0000,
388   {0x00,0x00,0x00,0x15},
389   0x15,
390   {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
391    0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f,
392    0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,
393    0x00},
394   {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15,
395    0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
396    0x15,0x15,0x15,0x15},
397   {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
398    0x3f}
399  },
400 /* 0x09: CGA_DAC */
401  {
402   0x00,0x10,0x04,0x0114,
403   {0x11,0x09,0x15,0x00},
404   0x10,
405   {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,
406    0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a,
407    0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10,
408    0x04},
409   {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04,
410    0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e,
411    0x3e,0x2b,0x3b,0x2f},
412   {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
413    0x3f}
414  },
415 /* 0x0a: EGA_DAC */
416  {
417   0x00,0x10,0x04,0x0114,
418   {0x11,0x05,0x15,0x20},
419   0x30,
420   {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18,
421    0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38,
422    0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12,
423    0x06},
424   {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26,
425    0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e,
426    0x1e,0x0b,0x1b,0x0f},
427   {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
428    0x3f}
429  },
430 /* 0x0b: VGA_DAC */
431  {
432   0x00,0x10,0x04,0x0114,
433   {0x11,0x09,0x15,0x2a},
434   0x3a,
435   {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05,
436    0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20,
437    0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10,
438    0x1f},
439   {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d,
440    0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15,
441    0x1c,0x0e,0x11,0x15},
442   {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00,
443    0x04}
444  },
445 /* 0x0c */
446  {
447   0x08,0x0c,0x10,0x0a08,
448   {0x0c,0x0e,0x10,0x0b},
449   0x0c,
450   {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00,
451    0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00,
452    0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00,
453    0x06},
454   {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08,
455    0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00,
456    0x00,0x00,0x00,0x00},
457   {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
458    0x00}
459  },
460 /* 0x0d: MD_D */
461  {
462   0x28,0x18,0x08,0x2000,
463   {0x09,0x0f,0x00,0x06},
464   0x63,
465   {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,     /* 2c is 2b for 300 */
466    0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
467    0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3,
468    0xff},
469   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
470    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
471    0x01,0x00,0x0f,0x00},
472   {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
473    0xff}
474  },
475 /* 0x0e: MD_E */
476  {
477   0x50,0x18,0x08,0x4000,
478   {0x01,0x0f,0x00,0x06},
479   0x63,
480   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,     /* 55,81 is 54,80 for 300 */
481    0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
482    0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3,
483    0xff},
484   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
485    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
486    0x01,0x00,0x0f,0x00},
487   {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
488    0xff}
489  },
490 /* 0x0f: ExtVGATable - modes > 0x13 */
491  {
492   0x00,0x00,0x00,0x0000,
493   {0x01,0x0f,0x00,0x0e},
494   0x23,
495   {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e,
496    0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
497    0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3,
498    0xff},
499   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
500    0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
501    0x01,0x00,0x00,0x00},
502   {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
503    0xff}
504  },
505 /* 0x10: ROM_SAVEPTR - totally different for 300 */
506  {
507   0x9f,0x3b,0x00,0x00c0,
508   {0x00,0x00,0x00,0x00},
509   0x00,
510   {0x00,0x00,0x00,0x00,0x00,0x00,0xbb,0x3f,
511    0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
512    0x00,0x00,0x1a,0x00,0xac,0x3e,0x00,0xc0,
513    0x00},
514   {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
515    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
516    0x00,0x00,0x00,0x00},
517   {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
518    0x00}
519  },
520 /* 0x11: MD_F */
521  {
522   0x50,0x18,0x0e,0x8000,
523   {0x01,0x0f,0x00,0x06},
524   0xa2,
525   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,    /* 55,81 is 54,80 on 300 */
526    0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
527    0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3,    /* 82,84 is 83,85 on 300 */
528    0xff},
529   {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00,
530    0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00,
531    0x0b,0x00,0x05,0x00},
532   {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,
533    0xff}
534  },
535 /* 0x12: MD_10 */
536  {
537   0x50,0x18,0x0e,0x8000,
538   {0x01,0x0f,0x00,0x06},
539   0xa3,
540   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,    /* 55,81 is 54,80 on 300 */
541    0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
542    0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3,    /* 82,84 is 83,85 on 300 */
543    0xff},
544   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
545    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
546    0x01,0x00,0x0f,0x00},
547   {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
548    0xff}
549  },
550 /* 0x13: MD_0_350 */
551  {
552   0x28,0x18,0x0e,0x0800,
553   {0x09,0x03,0x00,0x02},
554   0xa3,
555   {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f,    /* b1 is a0 on 300 */
556    0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
557    0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
558    0xff},
559   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
560    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
561    0x08,0x00,0x0f,0x00},
562   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
563    0xff}
564  },
565 /* 0x14: MD_1_350 */
566  {
567   0x28,0x18,0x0e,0x0800,
568   {0x09,0x03,0x00,0x02},
569   0xa3,
570   {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
571    0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
572    0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
573    0xff},
574   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
575    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
576    0x08,0x00,0x0f,0x00},
577   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
578    0xff}
579  },
580 /* 0x15: MD_2_350 */
581  {
582   0x50,0x18,0x0e,0x1000,
583   {0x01,0x03,0x00,0x02},
584   0xa3,
585   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
586    0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
587    0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
588    0xff},
589   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
590    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
591    0x08,0x00,0x0f,0x00},
592   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
593    0xff}
594  },
595 /* 0x16: MD_3_350 - mode 0x03 - 1 */
596  {
597   0x50,0x18,0x0e,0x1000,
598   {0x01,0x03,0x00,0x02},
599   0xa3,
600   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
601    0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
602    0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
603    0xff},
604   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
605    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
606    0x08,0x00,0x0f,0x00},
607   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
608    0xff}
609  },
610 /* 0x17: MD_0_1_400 */
611  {
612   0x28,0x18,0x10,0x0800,
613   {0x08,0x03,0x00,0x02},
614   0x67,
615   {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f,    /* b1 is a0 on 300 */
616    0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
617    0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
618    0xff},
619   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
620    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
621    0x0c,0x00,0x0f,0x08},
622   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
623    0xff}
624  },
625 /* 0x18: MD_2_3_400 - mode 0x03 - 2 */
626  {
627   0x50,0x18,0x10,0x1000,
628   {0x00,0x03,0x00,0x02},
629   0x67,
630   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
631    0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
632    0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
633    0xff},
634   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
635    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
636    0x0c,0x00,0x0f,0x08},
637   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
638    0xff}
639  },
640 /* 0x19: MD_7_400 */
641  {
642   0x50,0x18,0x10,0x1000,
643   {0x00,0x03,0x00,0x02},
644   0x66,
645   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
646    0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
647    0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3,
648    0xff},
649   {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
650    0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
651    0x0e,0x00,0x0f,0x08},
652   {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
653    0xff}
654  },
655 /* 0x1a: MD_11 */
656  {
657   0x50,0x1d,0x10,0xa000,
658   {0x01,0x0f,0x00,0x06},
659   0xe3,
660   {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,    /* 55,81 is 54,80 on 300 */
661    0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
662    0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xc3,    /* e9,8b is ea,8c on 300 */
663    0xff},
664   {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
665    0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
666    0x01,0x00,0x0f,0x00},
667   {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01,
668    0xff}
669  },
670 /* 0x1b: ExtEGATable - Modes <= 0x02 */
671  {
672   0x50,0x1d,0x10,0xa000,
673   {0x01,0x0f,0x00,0x06},
674   0xe3,
675   {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,    /* 55,81 is 54,80 on 300 */
676    0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
677    0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xe3,    /* e9,8b is ea,8c on 300 */
678    0xff},
679   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
680    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
681    0x01,0x00,0x0f,0x00},
682   {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
683    0xff}
684  },
685 /* 0x1c: MD_13 */
686  {
687   0x28,0x18,0x08,0x2000,
688   {0x01,0x0f,0x00,0x0e},
689   0x63,
690   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,    /* 55,81 is 54,80 on 300 */
691    0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,
692    0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3,
693    0xff},
694   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
695    0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
696    0x41,0x00,0x0f,0x00},
697   {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
698    0xff}
699  }
700 };
701 #endif
702
703 /**************************************************************/
704 /* SIS VIDEO BRIDGE ----------------------------------------- */
705 /**************************************************************/
706
707 static const UCHAR SiS_SoftSetting  = 0x30;   /* RAM setting */
708
709 static const UCHAR SiS_OutputSelect = 0x40;
710
711 static const UCHAR SiS_NTSCTiming[] = {
712         0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c,
713         0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a,
714         0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b,
715         0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17,
716         0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02,
717         0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40,
718         0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50,
719         0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00
720 };
721
722 static const UCHAR SiS_PALTiming[] = {
723         0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70,
724         0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d,
725         0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b,
726         0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17,
727         0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02,
728         0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40,
729         0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63,
730         0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00
731 };
732
733 static const UCHAR SiS_HiTVExtTiming[] = {
734         0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64,
735         0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
736         0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
737         0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13,
738         0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40,
739         0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40,
740         0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d,
741         0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00
742 };
743
744 static const UCHAR SiS_HiTVSt1Timing[] = {
745         0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65,
746         0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
747         0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
748         0x65,0x90,0x7b,0xa8,0x03,0xf0,0x87,0x03,
749         0x11,0x15,0x11,0xcf,0x10,0x11,0xcf,0x10,
750         0x35,0x35,0x3b,0x69,0x1d,0x92,0x0f,0x40,
751         0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x86,
752         0xaf,0x5d,0x0e,0x00,0xfc,0xff,0x2d,0x00
753 };
754
755 static const UCHAR SiS_HiTVSt2Timing[] = {
756         0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64,
757         0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
758         0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
759         0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13,
760         0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40,
761         0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40,
762         0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d,
763         0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00
764 };
765
766 #if 0
767 static const UCHAR SiS_HiTVTextTiming[] = {
768         0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65,
769         0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
770         0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
771         0x65,0x90,0xe7,0xbc,0x03,0x0c,0x97,0x03,
772         0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20,
773         0xc8,0xc8,0x3b,0xd2,0x26,0x92,0x0f,0x40,
774         0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96,
775         0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00
776 };
777 #endif
778
779 static const UCHAR SiS_HiTVGroup3Data[] = {
780         0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f,
781         0x05,0x21,0xb2,0xb2,0x55,0x77,0x2a,0xa6,
782         0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
783         0x8c,0x6e,0x60,0x2e,0x58,0x48,0x72,0x44,
784         0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
785         0x4f,0x7f,0x03,0xa8,0x7d,0x20,0x1a,0xa9,
786         0x14,0x05,0x03,0x7e,0x64,0x31,0x14,0x75,
787         0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
788 };
789
790 static const UCHAR SiS_HiTVGroup3Simu[] = {
791         0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95,
792         0xdb,0x20,0xb8,0xb8,0x55,0x47,0x2a,0xa6,
793         0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
794         0x8c,0x6e,0x60,0x15,0x26,0xd3,0xe4,0x11,
795         0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
796         0x67,0x36,0x01,0x47,0x0e,0x10,0xbe,0xb4,
797         0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75,
798         0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
799 };
800
801 #if 0
802 static const UCHAR SiS_HiTVGroup3Text[] = {
803         0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7,
804         0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6,
805         0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
806         0x8c,0x6e,0x60,0x18,0x2c,0x0c,0x20,0x22,
807         0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
808         0x93,0x3c,0x01,0x50,0x2f,0x10,0xf4,0xca,
809         0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75,
810         0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
811 };
812 #endif
813
814 static const UCHAR SiS_NTSCPhase[]    = {0x21,0xed,0xba,0x08};
815 static const UCHAR SiS_PALPhase[]     = {0x2a,0x05,0xe3,0x00};
816 static const UCHAR SiS_PALMPhase[]    = {0x21,0xE4,0x2E,0x9B};
817 static const UCHAR SiS_PALNPhase[]    = {0x21,0xF4,0x3E,0xBA};
818 static const UCHAR SiS_NTSCPhase2[]   = {0x21,0xF0,0x7B,0xD6};
819 static const UCHAR SiS_PALPhase2[]    = {0x2a,0x09,0x86,0xe9};
820 static const UCHAR SiS_PALMPhase2[]   = {0x21,0xE6,0xEF,0xA4};
821 static const UCHAR SiS_PALNPhase2[]   = {0x21,0xF6,0x94,0x46};
822 static const UCHAR SiS_SpecialPhase[] = {0x1e,0x8c,0x5c,0x7a};
823 static const UCHAR SiS_SpecialPhaseM[]= {0x1e,0x83,0x0a,0xe0};
824 static const UCHAR SiS_SpecialPhaseJ[]= {0x25,0xd4,0xfd,0x5e};
825
826 static const SiS_TVDataStruct  SiS_StPALData[] =
827 {
828  {    1,   1, 864, 525,1270, 400, 100,   0, 760,0xf4,0xff,0x1c,0x22},
829  {    1,   1, 864, 525,1270, 350, 100,   0, 760,0xf4,0xff,0x1c,0x22},
830  {    1,   1, 864, 525,1270, 400,   0,   0, 720,0xf1,0x04,0x1f,0x18},
831  {    1,   1, 864, 525,1270, 350,   0,   0, 720,0xf4,0x0b,0x1c,0x0a},
832  {    1,   1, 864, 525,1270, 480,  50,   0, 760,0xf4,0xff,0x1c,0x22},
833  {    1,   1, 864, 525,1270, 600,  50,   0,   0,0xf4,0xff,0x1c,0x22}
834 };
835
836 static const SiS_TVDataStruct  SiS_ExtPALData[] =
837 {
838  {   27,  10, 848, 448,1270, 530,  50,   0,  50,0xf4,0xff,0x1c,0x22},  /* 640x400, 320x200 */
839  {  108,  35, 848, 398,1270, 530,  50,   0,  50,0xf4,0xff,0x1c,0x22},
840  {   12,   5, 954, 448,1270, 530,  50,   0,  50,0xf1,0x04,0x1f,0x18},
841  {    9,   4, 960, 463,1644, 438,  50,   0,  50,0xf4,0x0b,0x1c,0x0a},
842  {    9,   4, 848, 528,1270, 530,   0,   0,  50,0xf5,0xfb,0x1b,0x2a},  /* 640x480, 320x240 */
843 /*{  36,  25,1060, 648,1316, 530, 438,   0, 438,0xeb,0x05,0x25,0x16},*//* 800x600, 400x300 */
844  {   36,  25,1060, 648,1270, 530, 438,   0, 438,0xeb,0x05,0x25,0x16},  /* 800x600, 400x300 - better */
845  {    3,   2,1080, 619,1270, 540, 438,   0, 438,0xf3,0x00,0x1d,0x20},  /* 720x576 */
846  {    1,   1,1170, 821,1270, 520, 686,   0, 686,0xF3,0x00,0x1D,0x20},  /* 1024x768 */
847  {    1,   1,1170, 821,1270, 520, 686,   0, 686,0xF3,0x00,0x1D,0x20},  /* 1024x768 (for NTSC equ) */
848  {    9,   4, 848, 528,1270, 530,   0,   0,  50,0xf5,0xfb,0x1b,0x2a}   /* 720x480 test */
849 };
850
851 static const SiS_TVDataStruct  SiS_StNTSCData[] =
852 {
853  {    1,   1, 858, 525,1270, 400,  50,   0, 760,0xf1,0x04,0x1f,0x18},
854  {    1,   1, 858, 525,1270, 350,  50,   0, 640,0xf1,0x04,0x1f,0x18},
855  {    1,   1, 858, 525,1270, 400,   0,   0, 720,0xf1,0x04,0x1f,0x18},
856  {    1,   1, 858, 525,1270, 350,   0,   0, 720,0xf4,0x0b,0x1c,0x0a},
857  {    1,   1, 858, 525,1270, 480,   0,   0, 760,0xf1,0x04,0x1f,0x18}
858 };
859
860 static const SiS_TVDataStruct  SiS_ExtNTSCData[] =
861 {
862  {  143,  65, 858, 443,1270, 440, 171,   0, 171,0xf1,0x04,0x1f,0x18},    /* 640x400, 320x200 */
863  {   88,  35, 858, 393,1270, 440, 171,   0, 171,0xf1,0x04,0x1f,0x18},
864  {  143,  70, 924, 443,1270, 440,  92,   0,  92,0xf1,0x04,0x1f,0x18},
865  {  143,  70, 924, 393,1270, 440,  92,   0,  92,0xf4,0x0b,0x1c,0x0a},
866  {  143,  76, 836, 523,1270, 440, 224,   0,   0,0xf1,0x05,0x1f,0x16},    /* 640x480, 320x240 */
867  {  143, 120,1056, 643,1270, 440,   0, 128,   0,0xf4,0x10,0x1c,0x00},    /* 800x600, 400x300  */
868 /*{   2,   1, 858, 503,1270, 480,   0, 128,   0,0xee,0x0c,0x22,0x08},*/  /* 720x480  (old, from 650) */
869  {  143,  76, 836, 523,1270, 440,   0, 128,   0,0xee,0x0c,0x22,0x08},    /* 720x480 - BETTER (from 300 series) */
870 /*{  65,  64,1056, 791,1270, 480, 638,   0,   0,0xEE,0x0C,0x22,0x08} */  /* 1024x768 (525i) */
871  {    1,   1,1100, 811,1412, 440,   0, 128,   0,0xee,0x0c,0x22,0x08},    /* 1024x768 (525i) CORRECTED */
872  {   65,  64,1056, 791,1270, 480, 455,   0,   0,0x00,0x00,0x00,0x00}     /* 1024x768 (525p) */
873 };
874
875 static const SiS_TVDataStruct  SiS_StHiTVData[] =  /* Slave + TVSimu */
876 {
877  {    1,   1, 0x37c,0x233,0x2b2,0x320,    0,  0, 0, 0x00,0x00,0x00,0x00},
878  {    1,   1, 0x37c,0x233,0x2b2,0x2bc,    0,  0, 0, 0x00,0x00,0x00,0x00},
879  {    1,   1, 0x37c,0x233,0x2b2,0x320,    0,  0, 0, 0x00,0x00,0x00,0x00},
880  {    1,   1, 0x37c,0x233,0x2b2,0x2bc,    0,  0, 0, 0x00,0x00,0x00,0x00},
881  {    1,   1, 0x37c,0x233,0x2b2,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
882  {    8,   5, 0x41a,0x2ab,0x670,0x3c0,0x150,128, 0, 0x00,0x00,0x00,0x00}
883 };
884
885 static const SiS_TVDataStruct  SiS_St2HiTVData[] = /* Slave */
886 {
887  {    3,   1, 0x348,0x1e3,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
888  {    1,   1, 0x37c,0x233,0x2b2,0x2bc,    0,  0, 0, 0x00,0x00,0x00,0x00},
889  {    3,   1, 0x348,0x1e3,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
890  {    1,   1, 0x37c,0x233,0x2b2,0x2bc,    0,  0, 0, 0x00,0x00,0x00,0x00},
891  {    5,   2, 0x348,0x233,0x670,0x3c0,0x08d,128, 0, 0x00,0x00,0x00,0x00},
892  {    8,   5, 0x41a,0x2ab,0x670,0x3c0,0x17c,128, 0, 0x00,0x00,0x00,0x00}
893 };
894
895 static const SiS_TVDataStruct  SiS_ExtHiTVData[] =
896 {
897  {    6,   1, 0x348,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
898  {    3,   1, 0x3c0,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
899  {    6,   1, 0x348,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
900  {    3,   1, 0x3c0,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
901  {    5,   1, 0x348,0x233,0x670,0x3c0,0x166,128, 0, 0x00,0x00,0x00,0x00},  /* 640x480   */
902  {   16,   5, 0x41a,0x2ab,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00},  /* 800x600   */
903  {   25,  12, 0x4ec,0x353,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},  /* 1024x768  */
904  {    5,   4, 0x627,0x464,0x670,0x3c0,0x128,  0, 0, 0x00,0x00,0x00,0x00},  /* 1280x1024 */
905  {    4,   1, 0x41a,0x233,0x60c,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00},  /* 800x480   */
906  {    5,   2, 0x578,0x293,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},  /* 1024x576  */
907  {    8,   5, 0x6d6,0x323,0x670,0x3c0,0x128,  0, 0, 0x00,0x00,0x00,0x00},  /* 1280x720  */
908  {  137,  32, 0x3d4,0x233,0x663,0x3bf,0x143,  0, 0, 0x00,0x00,0x00,0x00}   /* 960x600  */
909 };
910
911 static const SiS_TVDataStruct  SiS_St525pData[] =
912 {
913  {    1,   1, 0x6b4,0x20d,0x4f6,0x190,   50,  0, 0x2f8, 0x00,0x00,0x00,0x00},
914  {    1,   1, 0x6b4,0x20d,0x4f6,0x15e,   50,  0, 0x280, 0x00,0x00,0x00,0x00},
915  {    1,   1, 0x6b4,0x20d,0x4f6,0x190,   50,  0, 0x2f8, 0x00,0x00,0x00,0x00},
916  {    1,   1, 0x6b4,0x20d,0x4f6,0x15e,   50,  0, 0x280, 0x00,0x00,0x00,0x00},
917  {    1,   1, 0x6b4,0x20d,0x4f6,0x1e0,    0,  0, 0x2f8, 0x00,0x00,0x00,0x00}
918 };
919
920 static const SiS_TVDataStruct  SiS_St750pData[] =
921 {
922  {    1,   1, 0x672,0x2ee,0x500,0x190,   50,  0, 0x2f8, 0x00,0x00,0x00,0x00},
923  {    1,   1, 0x672,0x2ee,0x500,0x15e,   50,  0, 0x280, 0x00,0x00,0x00,0x00},
924  {    1,   1, 0x672,0x2ee,0x500,0x190,    0,  0, 0x2d0, 0x00,0x00,0x00,0x00},
925  {    1,   1, 0x672,0x2ee,0x500,0x15e,    0,  0, 0x2d0, 0x00,0x00,0x00,0x00},
926  {    1,   1, 0x672,0x2ee,0x500,0x1e0,    0,  0, 0x2f8, 0x00,0x00,0x00,0x00}
927 };
928
929 static const SiS_TVDataStruct  SiS_Ext750pData[] =
930 {
931  {  143,  65, 0x35a,0x1bb,0x4f6,0x1b8,0x0ab,  0, 0x0ab, 0x00,0x00,0x00,0x00},
932  {   88,  35, 0x35a,0x189,0x4f6,0x1b8,0x0ab,  0, 0x0ab, 0x00,0x00,0x00,0x00},
933  {   18,   5, 0x339,0x1ae,0x500,0x2d0,0x05c,  0, 0x05c, 0x00,0x00,0x00,0x00},
934  {  143,  70, 0x39c,0x189,0x4f6,0x1b8,0x05c,  0, 0x05c, 0x00,0x00,0x00,0x00},
935  {   99,  32, 0x320,0x1fe,0x500,0x2d0,   50,  0,     0, 0x00,0x00,0x00,0x00},  /* 640x480  */
936  {    5,   4, 0x5d8,0x29e,0x500,0x2a8,   50,  0,     0, 0x00,0x00,0x00,0x00},  /* 800x600  */
937  {   99,  32, 0x320,0x1fe,0x500,0x2d0,   50,  0,     0, 0x00,0x00,0x00,0x00},  /* 720x480 test WORKS */
938  {   68,  64, 0x55f,0x346,0x500,0x2a8,0x27e,  0,     0, 0x00,0x00,0x00,0x00},  /* 1024x768 */
939  {    5,   2, 0x3a7,0x226,0x500,0x2a8,    0,128,     0, 0x00,0x00,0x00,0x00},  /* 720x576  */
940  {   25,  24, 0x5d8,0x2f3,0x460,0x2a8,   50,  0,     0, 0x00,0x00,0x00,0x00}   /* 1280x720 WORKS */
941 };
942
943 static const SiS_LCDDataStruct  SiS_LCD1280x720Data[] =  /* 2.03.00 */
944 {
945         {  44,   15,  864,  430, 1408,  806 }, /* 640x400 */
946         { 128,   35,  792,  385, 1408,  806 },
947         {  44,   15,  864,  430, 1408,  806 },
948         { 128,   35,  792,  385, 1408,  806 },
949         {  22,    9,  864,  516, 1408,  806 }, /* 640x480 */
950         {   8,    5, 1056,  655, 1408,  806 }, /* 800x600 */
951         {   0,    0,    0,    0,    0,    0 }, /* 1024x768 */
952         {   0,    0,    0,    0,    0,    0 }, /* 1280x1024 */
953         {   0,    0,    0,    0,    0,    0 },
954         {   0,    0,    0,    0,    0,    0 },
955         {   1,    1, 1408,  806, 1408,  806 }  /* 1280x720 */
956 };
957
958 /* About 1280x768: For TMDS, Panel_1280x768 will only be set if
959  * the panel is a Fujitsu 7911 (VL-17WDX8) (with clock 81, 1688x802)
960  * Other TMDS panels of this resolution will be treated as custom.
961  * For LVDS, we know another type (_2).
962  * (Note: 1280x768_3 is now special for SiS301/NetVista
963  */
964
965 static const SiS_LCDDataStruct  SiS_StLCD1280x768_2Data[] = /* 2.03.00 */
966 {
967         {  64,   21,  858,  434, 1408,  806 }, /* 640x400 */
968         {  32,    9,  858,  372, 1408,  806 },
969         {  64,   21,  858,  434, 1408,  806 },
970         {  32,    9,  858,  372, 1408,  806 },
971         { 143,   68, 1024,  527, 1408,  806 }, /* 640x480 */
972         {  64,   51, 1364,  663, 1408,  806 }, /* 800x600 */
973         {  88,   81, 1296,  806, 1408,  806 }, /* 1024x768 */
974         {   0,    0,    0,    0,    0,    0 },
975         {   1,    1, 1408,  806, 1408,  806 }, /* 1280x768 */
976         {   0,    0,    0,    0,    0,    0 },
977         {  16,   15, 1600,  750, 1600,  806 }  /* 1280x720 - from Ext */
978 };
979
980 static const SiS_LCDDataStruct  SiS_ExtLCD1280x768_2Data[] = /* 2.03.00 */
981 {
982         {  16,    5,  960,  410, 1600,  806 }, /* 640x400 */
983         {  64,   21, 1152,  364, 1600,  806 },
984         {  16,    5,  960,  410, 1600,  806 },
985         {  64,   21, 1152,  364, 1600,  806 },
986         {  32,   13, 1040,  493, 1600,  806 }, /* 640x480 */
987         {  16,    9, 1152,  618, 1600,  806 }, /* 800x600 */
988         {  25,   21, 1344,  796, 1600,  806 }, /* 1024x768 */
989         {   0,    0,    0,    0,    0,    0 },
990         {   1,    1, 1600,  806, 1600,  806 }, /* 1280x768 */
991         {   0,    0,    0,    0,    0,    0 },
992         {  16,   15, 1600,  750, 1600,  806 }  /* 1280x720 */
993 };
994
995 #if 0  /* Not used; _3 now reserved for NetVista (SiS301) */
996 static const SiS_LCDDataStruct  SiS_LCD1280x768_3Data[] =
997 {
998         {  64,   25, 1056,  422, 1664,  798 },                  /* 640x400 */
999         { 128,   39,  884,  396, 1408,  806 }, /* ,640 */
1000         {  64,   25, 1056,  422, 1664,  798 },                  /* 640x400 */
1001         { 128,   39,  884,  396, 1408,  806 }, /* ,640 */
1002         {  32,   15, 1056,  513, 1408,  806 }, /* ,664 */       /* 640x480 */
1003         { 176,  125, 1280,  640, 1408,  806 }, /* ,768 */       /* 800x600 */
1004         {  64,   61, 1342,  806, 1408,  806 },                  /* 1024x768 */
1005         {   0,    0,    0,    0,    0,    0 },
1006         {   1,    1, 1408,  806, 1408,  806 },                  /* 1280x768 */
1007         {   0,    0,    0,    0,    0,    0 },
1008         {  16,   15, 1600,  750, 1600,  806 }  /* 1280x720  from above */
1009 };
1010 #endif
1011
1012 static const SiS_LCDDataStruct  SiS_LCD1280x800Data[] = /* 0.93.12a (TMDS) */
1013 {
1014         { 128,   51, 1122,  412, 1408,  816 },  /* 640x400 */
1015         { 128,   49, 1232,  361, 1408,  816 },
1016         { 128,   51, 1122,  412, 1408,  816 },
1017         { 128,   49, 1232,  361, 1408,  816 },
1018         {   8,    3,  880,  491, 1408,  816 },  /* 640x480 */
1019         {  11,    6, 1024,  612, 1408,  816 },  /* 800x600 */
1020         {  22,   21, 1400,  784, 1408,  816 },  /* 1024x768 */
1021         {   0,    0,    0,    0,    0,    0 },  /* 1280x1024 */
1022         {   1,    1, 1408,  816, 1408,  816 },  /* 1280x800 */
1023         {   0,    0,    0,    0,    0,    0 },  /* 1280x768 (patch index) */
1024         {   0,    0,    0,    0,    0,    0 }   /* 1280x720 */
1025 };
1026
1027 static const SiS_LCDDataStruct  SiS_LCD1280x800_2Data[] = /* 2.03.00 (LVDS) */
1028 {
1029         {  97,   42, 1344,  409, 1552,  812 }, /* 640x400 */
1030         {  97,   35, 1280,  358, 1552,  812 },
1031         {  97,   42, 1344,  409, 1552,  812 },
1032         {  97,   35, 1280,  358, 1552,  812 },
1033         {  97,   39, 1040,  488, 1552,  812 }, /* 640x480 */
1034         { 194,  105, 1120,  608, 1552,  812 }, /* 800x600 */
1035         {  97,   84, 1400,  780, 1552,  812 }, /* 1024x768 */
1036         {   0,    0,    0,    0,    0,    0 }, /* 1280x1024 */
1037         {   1,    1, 1552,  812, 1552,  812 }, /* 1280x800 */
1038         {  97,   96, 1600,  780, 1552,  812 }, /* 1280x768 - patch index */
1039         {  97,   90, 1600,  730, 1552,  812 }  /* 1280x720 */
1040 };
1041
1042 static const SiS_LCDDataStruct  SiS_LCD1280x960Data[] =
1043 {
1044         {    9,   2,  800,  500, 1800, 1000 },
1045         {    9,   2,  800,  500, 1800, 1000 },
1046         {    4,   1,  900,  500, 1800, 1000 },
1047         {    4,   1,  900,  500, 1800, 1000 },
1048         {    9,   2,  800,  500, 1800, 1000 },
1049         {   30,  11, 1056,  625, 1800, 1000 },
1050         {    5,   3, 1350,  800, 1800, 1000 },
1051         {    1,   1, 1576, 1050, 1576, 1050 },
1052         {    1,   1, 1800, 1000, 1800, 1000 }
1053 };
1054
1055 static const SiS_LCDDataStruct  SiS_StLCD1400x1050Data[] =
1056 {
1057         { 211,  100, 2100,  408, 1688, 1066 },
1058         { 211,   64, 1536,  358, 1688, 1066 },
1059         { 211,  100, 2100,  408, 1688, 1066 },
1060         { 211,   64, 1536,  358, 1688, 1066 },
1061         { 211,   48,  840,  488, 1688, 1066 },
1062         { 211,   72, 1008,  609, 1688, 1066 },
1063         { 211,  128, 1400,  776, 1688, 1066 },
1064         { 211,  205, 1680, 1041, 1688, 1066 },
1065         {   1,    1, 1688, 1066, 1688, 1066 }
1066 };
1067
1068 static const SiS_LCDDataStruct  SiS_ExtLCD1400x1050Data[] =
1069 {
1070 /*      { 211,   60, 1260,  410, 1688, 1066 },    640x400 (6330) */
1071         { 211,  100, 2100,  408, 1688, 1066 }, /* 640x400 (6325) WORKS */
1072         { 211,   64, 1536,  358, 1688, 1066 },
1073         { 211,  100, 2100,  408, 1688, 1066 },
1074         { 211,   64, 1536,  358, 1688, 1066 },
1075 /*      { 211,   80, 1400,  490, 1688, 1066 },    640x480 (6330) */
1076         { 211,   48,  840,  488, 1688, 1066 }, /* 640x480 (6325) WORKS */
1077 /*      { 211,  117, 1638,  613, 1688, 1066 },    800x600 (6330) */
1078         { 211,   72, 1008,  609, 1688, 1066 }, /* 800x600 (6325) WORKS */
1079         { 211,  128, 1400,  776, 1688, 1066 }, /* 1024x768 */
1080         { 211,  205, 1680, 1041, 1688, 1066 }, /* 1280x1024 - not used (always unscaled) */
1081         {   1,    1, 1688, 1066, 1688, 1066 }, /* 1400x1050 */
1082         {   0,    0,    0,    0,    0,    0 }, /* kludge */
1083         { 211,  120, 1400,  730, 1688, 1066 }  /* 1280x720 */
1084 };
1085
1086 static const SiS_LCDDataStruct  SiS_LCD1680x1050Data[] =
1087 {
1088         {  95,   24, 1260,  410, 1900, 1066 }, /*  0 640x400 */
1089         {  10,    3, 1710,  362, 1900, 1066 },
1090         {  95,   24, 1260,  410, 1900, 1066 },
1091         {  10,    3, 1710,  362, 1900, 1066 },
1092         {  95,   32, 1400,  490, 1900, 1066 }, /*  4 640x480 */
1093         {  95,   42, 1470,  610, 1900, 1066 }, /*  5 800x600 */
1094         {  95,   64, 1750,  784, 1900, 1066 }, /*  6 1024x768 */
1095         {  95,   94, 1900, 1055, 1900, 1066 }, /*  7 1280x1024 */
1096         {  41,   31, 1900,  806, 1900, 1066 }, /*  8 1280x768 */
1097         {  95,   69, 1800,  817, 1900, 1066 }, /*  9 1280x800 patch index */
1098         {  13,    9, 1900,  739, 1900, 1066 }, /* 10 1280x720 */
1099         {  95,   94, 1880, 1066, 1900, 1066 }, /* 11 1400x1050 patch index */
1100         {   1,    1, 1900, 1066, 1900, 1066 }  /* 12 1680x1050 */
1101 };
1102
1103 static const SiS_LCDDataStruct  SiS_StLCD1600x1200Data[] =
1104 {
1105         {27,  4, 800, 500, 2160, 1250 },
1106         {27,  4, 800, 500, 2160, 1250 },
1107         { 6,  1, 900, 500, 2160, 1250 },
1108         { 6,  1, 900, 500, 2160, 1250 },
1109         {27,  1, 800, 500, 2160, 1250 },
1110         { 4,  1,1080, 625, 2160, 1250 },
1111         { 5,  2,1350, 800, 2160, 1250 },
1112         {135,88,1600,1100, 2160, 1250 },
1113         {72, 49,1680,1092, 2160, 1250 },
1114         { 1,  1,2160,1250, 2160, 1250 }
1115 };
1116
1117 static const SiS_LCDDataStruct  SiS_ExtLCD1600x1200Data[] =
1118 {
1119         {72,11, 990, 422, 2160, 1250 }, /* 640x400 (6330) WORKS */
1120 /*      {27, 4, 800, 500, 2160, 1250 },    640x400 (6235) */
1121         {27, 4, 800, 500, 2160, 1250 },
1122         { 6, 1, 900, 500, 2160, 1250 },
1123         { 6, 1, 900, 500, 2160, 1250 },
1124         {45, 8, 960, 505, 2160, 1250 }, /* 640x480 (6330) WORKS */
1125 /*      {27, 1, 800, 500, 2160, 1250 },    640x480 (6325) */
1126         { 4, 1,1080, 625, 2160, 1250 },
1127         { 5, 2,1350, 800, 2160, 1250 },
1128         {27,16,1500,1064, 2160, 1250 }, /* 1280x1024 */
1129         {72,49,1680,1092, 2160, 1250 }, /* 1400x1050 (6330, was not supported on 6325) */
1130         { 1, 1,2160,1250, 2160, 1250 }
1131 };
1132
1133 static const SiS_LCDDataStruct  SiS_NoScaleData[] =
1134 {
1135         { 1, 1, 800, 449, 800, 449 },  /* 0x00: 320x200, 640x400 */
1136         { 1, 1, 800, 449, 800, 449 },
1137         { 1, 1, 900, 449, 900, 449 },
1138         { 1, 1, 900, 449, 900, 449 },
1139         { 1, 1, 800, 525, 800, 525 },  /* 0x04: 320x240, 640x480  */
1140         { 1, 1,1056, 628,1056, 628 },  /* 0x05: 400x300, 800x600  */
1141         { 1, 1,1344, 806,1344, 806 },  /* 0x06: 512x384, 1024x768 */
1142         { 1, 1,1688,1066,1688,1066 },  /* 0x07: 1280x1024 */
1143         { 1, 1,1688, 802,1688, 802 },  /* 0x08: 1280x768: Fujitsu, TMDS only */
1144         { 1, 1,2160,1250,2160,1250 },  /* 0x09: 1600x1200 */
1145         { 1, 1,1800,1000,1800,1000 },  /* 0x0a: 1280x960  */
1146         { 1, 1,1688,1066,1688,1066 },  /* 0x0b: 1400x1050 */
1147         { 1, 1,1650, 750,1650, 750 },  /* 0x0c: 1280x720 (TMDS, projector)  */
1148         { 1, 1,1552, 812,1552, 812 },  /* 0x0d: 1280x800_2 (LVDS) (was: 1408,816/ 1656,841) */
1149         { 1, 1,1900,1066,1900,1066 },  /* 0x0e: 1680x1050 (LVDS) */
1150         { 1, 1,1660, 806,1660, 806 },  /* 0x0f: 1280x768_2 (LVDS) */
1151         { 1, 1,1664, 798,1664, 798 },  /* 0x10: 1280x768_3 (NetVista SiS 301) - TODO */
1152         { 1, 1,1688, 802,1688, 802 },  /* 0x11: 1280x768   (TMDS Fujitsu) */
1153         { 1, 1,1408, 806,1408, 806 },  /* 0x12: 1280x720 (LVDS) */
1154         { 1, 1, 896, 497, 896, 497 },  /* 0x13: 720x480 */
1155         { 1, 1, 912, 597, 912, 597 },  /* 0x14: 720x576 */
1156         { 1, 1, 912, 597, 912, 597 },  /* 0x15: 768x576 */
1157         { 1, 1,1056, 497,1056, 497 },  /* 0x16: 848x480 */
1158         { 1, 1,1064, 497,1064, 497 },  /* 0x17: 856x480 */
1159         { 1, 1,1056, 497,1056, 497 },  /* 0x18: 800x480 */
1160         { 1, 1,1328, 739,1328, 739 },  /* 0x19: 1024x576 */
1161         { 1, 1,1680, 892,1680, 892 },  /* 0x1a: 1152x864 */
1162         { 1, 1,1808, 808,1808, 808 },  /* 0x1b: 1360x768 */
1163         { 1, 1,1104, 563,1104, 563 },  /* 0x1c: 960x540 */
1164         { 1, 1,1120, 618,1120, 618 },  /* 0x1d: 960x600 */
1165         { 1, 1,1408, 816,1408, 816 }   /* 0x1f: 1280x800 (TMDS special) */
1166 };
1167
1168 /**************************************************************/
1169 /* LVDS ----------------------------------------------------- */
1170 /**************************************************************/
1171
1172 static const SiS_LVDSDataStruct  SiS_LVDS320x480Data_1[]=
1173 {
1174         { 848, 433, 400, 525},
1175         { 848, 389, 400, 525},
1176         { 848, 433, 400, 525},
1177         { 848, 389, 400, 525},
1178         { 848, 518, 400, 525},
1179         {1056, 628, 400, 525},
1180         { 400, 525, 400, 525},
1181         { 800, 449,1000, 644},
1182         { 800, 525,1000, 635}
1183 };
1184
1185 static const SiS_LVDSDataStruct  SiS_LVDS640x480Data_1[]=
1186 {
1187         { 800, 445, 800, 525},   /* 800, 449, 800, 449 */
1188         { 800, 395, 800, 525},
1189         { 800, 445, 800, 525},
1190         { 800, 395, 800, 525},
1191         { 800, 525, 800, 525},
1192         { 800, 525, 800, 525},   /* pseudo */
1193         { 800, 525, 800, 525}    /* pseudo */
1194 };
1195
1196 /* FSTN 320x240 */
1197 static const SiS_LVDSDataStruct  SiS_LVDS640x480Data_2[]=
1198 {
1199         { 800, 445, 800, 525},
1200         { 800, 395, 800, 525},
1201         { 800, 445, 800, 525},
1202         { 800, 395, 800, 525},
1203         { 800, 525, 800, 525},
1204         { 800, 525, 800, 525},   /* pseudo */
1205         { 800, 525, 800, 525}    /* pseudo */
1206 };
1207
1208 static const SiS_LVDSDataStruct  SiS_LVDS800x600Data_1[]=
1209 {
1210         { 848, 433,1060, 629},
1211         { 848, 389,1060, 629},
1212         { 848, 433,1060, 629},
1213         { 848, 389,1060, 629},
1214         { 848, 518,1060, 629},
1215         {1056, 628,1056, 628},
1216         {1056, 628,1056, 628}
1217 };
1218
1219 static const SiS_LVDSDataStruct  SiS_LVDS800x600Data_2[]=
1220 {
1221         {1056, 628,1056, 628}
1222 };
1223
1224 static const SiS_LVDSDataStruct  SiS_LVDS1024x768Data_1[]=
1225 {
1226         { 840, 438,1344, 806},
1227         { 840, 409,1344, 806},
1228         { 840, 438,1344, 806},
1229         { 840, 409,1344, 806},
1230         { 840, 518,1344, 806},   /* 640x480 */
1231         {1050, 638,1344, 806},   /* 800x600 */
1232         {1344, 806,1344, 806},   /* 1024x768 */
1233 };
1234
1235 static const SiS_LVDSDataStruct  SiS_LVDS1024x768Data_2[]=
1236 {
1237         {1344, 806,1344, 806}
1238 };
1239
1240 static const SiS_LVDSDataStruct  SiS_LVDS1280x1024Data_1[]=
1241 {
1242         {1048, 442,1688,1066},
1243         {1048, 392,1688,1066},
1244         {1048, 442,1688,1066},
1245         {1048, 392,1688,1066},
1246         {1048, 522,1688,1066},
1247         {1208, 642,1688,1066},
1248         {1432, 810,1688,1066},
1249         {1688,1066,1688,1066}
1250 };
1251
1252 static const SiS_LVDSDataStruct  SiS_LVDS1280x1024Data_2[]=
1253 {
1254         {1688,1066,1688,1066}
1255 };
1256
1257 static const SiS_LVDSDataStruct  SiS_LVDS1400x1050Data_1[]=
1258 {
1259         { 928, 416, 1688,1066},
1260         { 928, 366, 1688,1066},
1261         { 928, 416, 1688,1066},
1262         { 928, 366, 1688,1066},
1263         { 928, 496, 1688,1066},
1264         {1088, 616, 1688,1066},
1265         {1312, 784, 1688,1066},
1266         {1568,1040, 1688,1066},
1267         {1688,1066, 1688,1066}
1268 };
1269
1270 static const SiS_LVDSDataStruct  SiS_LVDS1400x1050Data_2[]=
1271 {
1272         {1688,1066, 1688,1066}
1273 };
1274
1275 static const SiS_LVDSDataStruct  SiS_LVDS1600x1200Data_1[]=
1276 {
1277         {1088, 520, 2048,1320},
1278         {1088, 470, 2048,1320},
1279         {1088, 520, 2048,1320},
1280         {1088, 470, 2048,1320},
1281         {1088, 600, 2048,1320},
1282         {1248, 720, 2048,1320},
1283         {1472, 888, 2048,1320},
1284         {1728,1144, 2048,1320},
1285         {1848,1170, 2048,1320},
1286         {2048,1320, 2048,1320}
1287 };
1288
1289 static const SiS_LVDSDataStruct  SiS_LVDS1600x1200Data_2[]=
1290 {
1291         {2048,1320, 2048,1320}
1292 };
1293
1294 static const SiS_LVDSDataStruct  SiS_LVDS1280x960Data_1[]=
1295 {
1296         { 840, 438,1344, 806},
1297         { 840, 409,1344, 806},
1298         { 840, 438,1344, 806},
1299         { 840, 409,1344, 806},
1300         { 840, 518,1344, 806},
1301         {1050, 638,1344, 806},
1302         {1344, 806,1344, 806},
1303         { 800, 449,1280, 801},
1304         { 800, 525,1280, 813}
1305 };
1306
1307 static const SiS_LVDSDataStruct  SiS_LVDS1280x960Data_2[]=
1308 {
1309         {1344, 806,1344, 806}
1310 };
1311
1312 static const SiS_LVDSDataStruct  SiS_LVDS1280x768Data_1[]=
1313 {
1314         { 768, 438, 1408, 806},
1315         { 768, 388, 1408, 806},
1316         { 768, 438, 1408, 806},
1317         { 768, 388, 1408, 806},
1318         { 768, 518, 1408, 806},
1319         { 928, 638, 1408, 806},
1320         {1152, 806, 1408, 806},
1321         {1408, 806, 1408, 806},
1322         {1408, 806, 1408, 806}
1323 };
1324
1325 static const SiS_LVDSDataStruct  SiS_LVDS1280x768Data_2[]=
1326 {
1327         {1408, 806, 1408, 806}
1328 };
1329
1330 static const SiS_LVDSDataStruct  SiS_LVDS1024x600Data_1[] =
1331 {
1332         { 840, 604,1344, 800},
1333         { 840, 560,1344, 800},
1334         { 840, 604,1344, 800},
1335         { 840, 560,1344, 800},
1336         { 840, 689,1344, 800},
1337         {1050, 800,1344, 800},
1338         {1344, 800,1344, 800}
1339 };
1340
1341 static const SiS_LVDSDataStruct  SiS_LVDS1024x600Data_2[] =
1342 {
1343         {1344, 800,1344, 800}
1344 };
1345
1346 static const SiS_LVDSDataStruct  SiS_LVDS1152x768Data_1[] =
1347 {
1348         { 840, 438,1344, 806},
1349         { 840, 409,1344, 806},
1350         { 840, 438,1344, 806},
1351         { 840, 409,1344, 806},
1352         { 840, 518,1344, 806},
1353         {1050, 638,1344, 806},
1354         {1344, 806,1344, 806}
1355 };
1356
1357 static const SiS_LVDSDataStruct  SiS_LVDS1152x768Data_2[] =
1358 {
1359         {1344, 806,1344, 806}
1360 };
1361
1362 /* Pass 1:1 data */
1363 static const SiS_LVDSDataStruct  SiS_LVDSXXXxXXXData_1[]=
1364 {
1365         { 800, 449,  800, 449},
1366         { 800, 449,  800, 449},
1367         { 900, 449,  900, 449},
1368         { 900, 449,  900, 449},
1369         { 800, 525,  800, 525},  /*  640x480  */
1370         {1056, 628, 1056, 628},  /*  800x600  */
1371         {1344, 806, 1344, 806},  /* 1024x768  */
1372         {1688,1066, 1688,1066},  /* 1280x1024 */  /* INSERTED */
1373         {1688, 806, 1688, 806},  /* 1280x768  */
1374 };
1375
1376 /* Custom data for Barco iQ R series */
1377 static const SiS_LVDSDataStruct  SiS_LVDSBARCO1366Data_1[]=
1378 {
1379         { 832, 438,1331, 806},
1380         { 832, 388,1331, 806},
1381         { 832, 438,1331, 806},
1382         { 832, 388,1331, 806},
1383         { 832, 518,1331, 806},
1384         {1050, 638,1344, 806},
1385         {1344, 806,1344, 806},
1386         {1688,1066,1688,1066},
1387         {1688,1066,1688,1066}   /* 1360x1024 */
1388 };
1389
1390 /* Custom data for Barco iQ R series */
1391 static const SiS_LVDSDataStruct  SiS_LVDSBARCO1366Data_2[]=
1392 {
1393         {1344, 806,1344, 806},
1394         {1344, 806,1344, 806},
1395         {1344, 806,1344, 806},
1396         {1344, 806,1344, 806},
1397         {1344, 806,1344, 806},
1398         {1344, 806,1344, 806},
1399         {1344, 806,1344, 806},
1400         {1688,1066,1688,1066},
1401         {1688,1066,1688,1066}   /* 1360x1024 */
1402 };
1403
1404 /* Custom data for Barco iQ G series */
1405 static const SiS_LVDSDataStruct  SiS_LVDSBARCO1024Data_1[]=
1406 {
1407         { 832, 438,1331, 806},
1408         { 832, 409,1331, 806},
1409         { 832, 438,1331, 806},
1410         { 832, 409,1331, 806},
1411         { 832, 518,1331, 806},   /* 640x480 */
1412         {1050, 638,1344, 806},   /* 800x600 */
1413         {1344, 806,1344, 806},   /* 1024x768 */
1414 };
1415
1416 /* Custom data for Barco iQ G series */
1417 static const SiS_LVDSDataStruct  SiS_LVDSBARCO1024Data_2[]=
1418 {
1419         {1344, 806,1344, 806}
1420 };
1421
1422 /* Custom data for 848x480 parallel panel */
1423 static const SiS_LVDSDataStruct  SiS_LVDS848x480Data_1[]=
1424 {
1425         {   0,   0,   0,   0},
1426         {   0,   0,   0,   0},
1427         {   0,   0,   0,   0},
1428         {   0,   0,   0,   0},
1429         {1088, 525,1088, 525},  /* 640x480 TODO */
1430         {1088, 525,1088, 525},  /* 800x600 TODO */
1431         {1088, 525,1088, 525},  /* 1024x768 TODO */
1432         {   0,   0,   0,   0},
1433         {   0,   0,   0,   0},
1434         {   0,   0,   0,   0},
1435         {   0,   0,   0,   0},
1436         {1088, 525,1088, 525},  /* 848x480 */
1437         {1088, 525,1088, 525}   /* 1360x768 TODO */
1438 };
1439
1440 /* Custom data for 848x480 parallel panel */
1441 static const SiS_LVDSDataStruct  SiS_LVDS848x480Data_2[]=
1442 {
1443         {   0,   0,   0,   0},
1444         {   0,   0,   0,   0},
1445         {   0,   0,   0,   0},
1446         {   0,   0,   0,   0},
1447         {1088, 525,1088, 525},  /*  640x480 */
1448         {1088, 525,1088, 525},  /*  800x600 */
1449         {1088, 525,1088, 525},  /* 1024x768 */
1450         {   0,   0,   0,   0},
1451         {   0,   0,   0,   0},
1452         {   0,   0,   0,   0},
1453         {   0,   0,   0,   0},
1454         {1088, 525,1088, 525},  /* 848x480 */
1455         {1088, 525,1088, 525}   /* 1360x768 TODO */
1456 };
1457
1458 static const SiS_LVDSDataStruct  SiS_CHTVUNTSCData[]=
1459 {
1460         { 840, 600, 840, 600},
1461         { 840, 600, 840, 600},
1462         { 840, 600, 840, 600},
1463         { 840, 600, 840, 600},
1464         { 784, 600, 784, 600},
1465         {1064, 750,1064, 750},
1466         {1160, 945,1160, 945}
1467 };
1468
1469 static const SiS_LVDSDataStruct  SiS_CHTVONTSCData[]=
1470 {
1471         { 840, 525, 840, 525},
1472         { 840, 525, 840, 525},
1473         { 840, 525, 840, 525},
1474         { 840, 525, 840, 525},
1475         { 784, 525, 784, 525},
1476         {1040, 700,1040, 700},
1477         {1160, 840,1160, 840}
1478 };
1479
1480 /* Chrontel TV Skew */
1481
1482 static const SiS_LVDSDesStruct  SiS_CHTVUNTSCDesData[]=
1483 {
1484         { 0,   0},
1485         { 0,   0},
1486         { 0,   0},
1487         { 0,   0},
1488         { 0,   0},
1489         { 0,   0},
1490         { 0,   0}
1491 };
1492
1493 static const SiS_LVDSDesStruct  SiS_CHTVONTSCDesData[]=
1494 {
1495         { 0,   0},
1496         { 0,   0},
1497         { 0,   0},
1498         { 0,   0},
1499         { 0,   0},
1500         { 0,   0},
1501         { 0,   0}
1502 };
1503
1504 static const SiS_LVDSDesStruct  SiS_CHTVUPALDesData[]=
1505 {
1506         {256,  0},
1507         {256,  0},
1508         {256,  0},
1509         {256,  0},
1510         { 0,   0},
1511         { 0,   0},
1512         { 0,   0}
1513 };
1514
1515 static const SiS_LVDSDesStruct  SiS_CHTVOPALDesData[]=
1516 {
1517         {256,  0},
1518         {256,  0},
1519         {256,  0},
1520         {256,  0},
1521         { 0,   0},
1522         { 0,   0},
1523         { 0,   0}
1524 };
1525
1526 /* CRT1 CRTC data for slave modes */
1527
1528 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1320x480_1[] =
1529 {
1530  {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f,
1531    0x90,0x85,0x8f,0xab,0x30,0x00,0x05,
1532    0x00 }},
1533  {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
1534    0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
1535    0x00 }},
1536  {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f,
1537    0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
1538    0x00 }},
1539  {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
1540    0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
1541    0x00 }},
1542  {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e,
1543    0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05,
1544    0x00 }},
1545  {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
1546    0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
1547    0x01 }},
1548  {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
1549    0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
1550    0x00 }}
1551 };
1552
1553 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1640x480_1[] =
1554 {
1555  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1556    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1557    0x00}},
1558  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1559    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1560    0x00}},
1561  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1562    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1563    0x00}},
1564  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1565    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1566    0x00}},
1567  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1568    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1569    0x00}},
1570  {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
1571    0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
1572    0x01}}
1573 };
1574
1575 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1640x480_1_H[] =
1576 {
1577  {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
1578    0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00,
1579    0x00}},
1580  {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
1581    0x83,0x85,0x63,0xba,0x00,0x00,0x00,
1582    0x00}},
1583  {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
1584    0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00,
1585    0x00}},
1586  {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
1587    0x83,0x85,0x63,0xba,0x00,0x00,0x00,
1588    0x00}},
1589  {{0x2d,0x28,0x90,0x2c,0x80,0x0b,0x3e,
1590    0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
1591    0x00}}
1592 };
1593
1594 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1640x480_2[] =
1595 {
1596  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1597    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1598    0x00}},
1599  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1600    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1601    0x00}},
1602  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1603    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1604    0x00}},
1605  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1606    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1607    0x00}},
1608  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1609    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1610    0x00}},
1611  {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
1612    0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
1613    0x01}},
1614  {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
1615    0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
1616    0x00}}
1617 };
1618
1619 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1640x480_2_H[] =
1620 {
1621  {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f,
1622    0x90,0x85,0x8f,0xab,0x30,0x00,0x05,
1623    0x00}},
1624  {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
1625    0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
1626    0x00}},
1627  {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f,
1628    0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
1629    0x00}},
1630  {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
1631    0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
1632    0x00}},
1633  {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e,
1634    0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05,
1635    0x00}},
1636  {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
1637    0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
1638    0x01}},
1639  {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
1640    0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
1641    0x00}}
1642 };
1643
1644 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1640x480_3[] =
1645 {
1646  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1647    0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
1648    0x00}},
1649  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1650    0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
1651    0x00}},
1652  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1653    0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
1654    0x00}},
1655  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1656    0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
1657    0x00}},
1658  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1659    0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
1660    0x00}},
1661  {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
1662    0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
1663    0x01}},
1664  {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
1665    0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
1666    0x00}}
1667 };
1668
1669 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1640x480_3_H[] =
1670 {
1671  {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f,
1672    0x90,0x85,0x8f,0xab,0x30,0x00,0x05,
1673    0x00}},
1674  {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
1675    0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
1676    0x00}},
1677  {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f,
1678    0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
1679    0x00}},
1680  {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
1681    0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
1682    0x00}},
1683  {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e,
1684    0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05,
1685    0x00}},
1686  {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
1687    0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
1688    0x01}},
1689  {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
1690    0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
1691    0x00}}
1692 };
1693
1694 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11024x600_1[] =
1695 {
1696  {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e,
1697    0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01,
1698    0x00}},
1699  {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e,
1700    0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01,
1701    0x00}},
1702  {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e,
1703    0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01,
1704    0x00}},
1705  {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e,
1706    0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01,
1707    0x00}},
1708  {{0x64,0x4f,0x88,0x54,0x9f,0xaf,0xba,
1709    0x3b,0x82,0xdf,0xb0,0x00,0x00,0x01,
1710    0x00}},
1711  {{0x7e,0x63,0x82,0x68,0x15,0x1e,0xf1,
1712    0xae,0x85,0x57,0x1f,0x30,0x00,0x26,
1713    0x01}},
1714  {{0xa3,0x7f,0x87,0x86,0x97,0x1e,0xf1,
1715    0xae,0x85,0x57,0x1f,0x30,0x00,0x02,
1716    0x01}}
1717 };
1718
1719 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11024x600_1_H[] =
1720 {
1721  {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
1722    0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
1723    0x00}},
1724  {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
1725    0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
1726    0x00}},
1727  {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
1728    0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
1729    0x00}},
1730  {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
1731    0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
1732    0x00}},
1733  {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e,
1734    0xe2,0x89,0xdf,0x05,0x00,0x00,0x44,
1735    0x00}},
1736  {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0,
1737    0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55,
1738    0x01}},
1739  {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
1740    0x02,0x88,0xff,0x25,0x10,0x00,0x01,
1741    0x01}}
1742 };
1743
1744 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11024x600_2[] =
1745 {
1746  {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
1747    0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
1748    0x00}},
1749  {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
1750    0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
1751    0x00}},
1752  {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
1753    0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
1754    0x00}},
1755  {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
1756    0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
1757    0x00}},
1758  {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
1759    0x72,0x88,0xdf,0x25,0x30,0x00,0x06,
1760    0x00}},
1761  {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1,
1762    0xae,0x84,0x57,0x25,0x30,0x00,0x02,
1763    0x01}},
1764  {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
1765    0x02,0x88,0xff,0x25,0x10,0x00,0x02,
1766    0x01}}
1767 };
1768
1769 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11024x600_2_H[] =
1770 {
1771  {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
1772    0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
1773    0x00}},
1774  {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
1775    0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
1776    0x00}},
1777  {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
1778    0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
1779    0x00}},
1780  {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
1781    0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
1782    0x00}},
1783  {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
1784    0x72,0x88,0xdf,0x25,0x30,0x00,0x01,
1785    0x00}},
1786  {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1,
1787    0xae,0x84,0x57,0x25,0x30,0x00,0x01,
1788    0x01}},
1789  {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
1790    0x02,0x88,0xff,0x25,0x10,0x00,0x01,
1791    0x01}}
1792 };
1793
1794 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11152x768_1[] =
1795 {
1796  {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f,
1797    0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
1798    0x00}},
1799  {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f,
1800    0x60,0x87,0x5d,0x83,0x10,0x00,0x01,
1801    0x00}},
1802  {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f,
1803    0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
1804    0x00}},
1805  {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f,
1806    0x60,0x87,0x5d,0x83,0x10,0x00,0x01,
1807    0x00}},
1808  {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e,
1809    0xe2,0x89,0xdf,0x05,0x00,0x00,0x01,
1810    0x00}},
1811  {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0,
1812    0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26,
1813    0x01}},
1814  {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
1815    0x02,0x88,0xff,0x25,0x10,0x00,0x02,
1816    0x01}}
1817 };
1818
1819 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11152x768_1_H[] =
1820 {
1821  {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
1822    0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
1823    0x00}},
1824  {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
1825    0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
1826    0x00}},
1827  {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
1828    0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
1829    0x00}},
1830  {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
1831    0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
1832    0x00}},
1833  {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e,
1834    0xe2,0x89,0xdf,0x05,0x00,0x00,0x44,
1835    0x00}},
1836  {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0,
1837    0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55,
1838    0x01}},
1839  {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
1840    0x02,0x88,0xff,0x25,0x10,0x00,0x01,
1841    0x01}}
1842 };
1843
1844 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11152x768_2[] =
1845 {
1846  {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
1847    0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
1848    0x00}},
1849  {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
1850    0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
1851    0x00}},
1852  {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
1853    0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
1854    0x00}},
1855  {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
1856    0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
1857    0x00}},
1858  {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
1859    0x72,0x88,0xdf,0x25,0x30,0x00,0x06,
1860    0x00}},
1861  {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1,
1862    0xae,0x84,0x57,0x25,0x30,0x00,0x02,
1863    0x01}},
1864  {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
1865    0x02,0x88,0xff,0x25,0x10,0x00,0x02,
1866    0x01}}
1867 };
1868
1869 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11152x768_2_H[] =
1870 {
1871  {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
1872    0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
1873    0x00}},
1874  {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
1875    0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
1876    0x00}},
1877  {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
1878    0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
1879    0x00}},
1880  {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
1881    0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
1882    0x00}},
1883  {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
1884    0x72,0x88,0xdf,0x25,0x30,0x00,0x01,
1885    0x00}},
1886  {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1,
1887    0xae,0x84,0x57,0x25,0x30,0x00,0x01,
1888    0x01}},
1889  {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
1890    0x02,0x88,0xff,0x25,0x10,0x00,0x01,
1891    0x01}}
1892 };
1893
1894 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11280x768_1[] =
1895 {
1896  {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f,
1897    0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01,
1898    0x00}},
1899  {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f,
1900    0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01,
1901    0x00}},
1902  {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f,
1903    0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01,
1904    0x00}},
1905  {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f,
1906    0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01,
1907    0x00}},
1908  {{0x5b,0x4f,0x9f,0x55,0x19,0x04,0x3e,
1909    0xec,0x8e,0xdf,0x05,0x20,0x00,0x01,
1910    0x00}},
1911  {{0x6f,0x63,0x93,0x69,0x8d,0x7c,0xf0,
1912    0x64,0x86,0x57,0x7d,0x20,0x00,0x05,
1913    0x01}},
1914  {{0x8b,0x7f,0x8f,0x85,0x09,0x24,0xf5,
1915    0x0c,0x8e,0xff,0x25,0x30,0x00,0x02,
1916    0x01}},
1917  {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5,
1918    0x0c,0x8e,0xff,0x25,0x30,0x00,0x06,
1919    0x01}},
1920  {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5,
1921    0x0c,0x8e,0xff,0x25,0x30,0x00,0x06,
1922    0x01}}
1923 };
1924
1925 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11280x768_1_H[] =
1926 {
1927  {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f,
1928    0x93,0x86,0x8f,0x9f,0x30,0x00,0x05,
1929    0x00}},
1930  {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f,
1931    0x60,0x84,0x5d,0x6d,0x10,0x00,0x05,
1932    0x00}},
1933  {{0x47,0x27,0x8b,0x30,0x1e,0x9e,0x1f,
1934    0x92,0x86,0x8f,0x9f,0x30,0x00,0x05,
1935    0x00}},
1936  {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f,
1937    0x60,0x84,0x5d,0x6d,0x10,0x00,0x05,
1938    0x00}},
1939  {{0x47,0x27,0x8b,0x2c,0x1a,0xee,0x1f,
1940    0xe2,0x86,0xdf,0xef,0x10,0x00,0x05,
1941    0x00}},
1942  {{0x51,0x31,0x95,0x36,0x04,0x66,0xf0,
1943    0x5a,0x8e,0x57,0x67,0x20,0x00,0x01,
1944    0x01}},
1945  {{0x5f,0x3f,0x83,0x44,0x92,0x0e,0xf5,
1946    0x02,0x86,0xff,0x0f,0x10,0x00,0x01,
1947    0x01}},
1948  {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a,
1949    0x02,0x86,0xff,0x0f,0x09,0x00,0x05,
1950    0x01}},
1951  {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a,
1952    0x02,0x86,0xff,0x0f,0x09,0x00,0x05,
1953    0x01}}
1954 };
1955
1956 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11280x768_2[] =
1957 {
1958  {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb,
1959    0x54,0x86,0xdb,0xda,0x00,0x00,0x02,
1960    0x00}},
1961  {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb,
1962    0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02,
1963    0x00}},
1964  {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb,
1965    0x54,0x86,0xdb,0xda,0x00,0x00,0x02,
1966    0x00}},
1967  {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb,
1968    0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02,
1969    0x00}},
1970  {{0xab,0x60,0x9f,0x80,0x04,0x24,0xb3,
1971    0x7c,0x8e,0x03,0x02,0x10,0x00,0x02,
1972    0x01}},
1973  {{0xab,0x63,0x8f,0x8a,0x8e,0x24,0xf1,
1974    0xb6,0x88,0x57,0x25,0x10,0x00,0x02,
1975    0x01}},
1976  {{0xab,0x7f,0x8f,0x98,0x9c,0x24,0xf5,
1977    0x0a,0x8c,0xff,0x25,0x30,0x00,0x02,
1978    0x01}},
1979  {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5,
1980    0x0a,0x8c,0xff,0x25,0x30,0x00,0x06,
1981    0x01}},
1982  {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5,
1983    0x0a,0x8c,0xff,0x25,0x30,0x00,0x06,
1984    0x01}}
1985 };
1986
1987 static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11280x768_2_H[] =
1988 {
1989  {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb,
1990    0x54,0x86,0xdb,0xda,0x00,0x00,0x01,
1991    0x00}},
1992  {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb,
1993    0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01,
1994    0x00}},
1995  {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb,
1996    0x54,0x86,0xdb,0xda,0x00,0x00,0x01,
1997    0x00}},
1998  {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb,
1999    0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01,
2000    0x00}},
2001  {{0x83,0x38,0x97,0x58,0x9c,0x24,0xb3,
2002    0x7c,0x8e,0x03,0x02,0x10,0x00,0x01,
2003    0x01}},
2004  {{0x79,0x31,0x9d,0x58,0x9c,0x24,0xf1,
2005    0xb6,0x88,0x57,0x25,0x10,0x00,0x01,
2006    0x01}},
2007  {{0x6b,0x3f,0x8f,0x58,0x9c,0x24,0xf5,
2008    0x0a,0x8c,0xff,0x25,0x30,0x00,0x01,
2009    0x01}},
2010  {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5,
2011    0x0a,0x8c,0xff,0x25,0x30,0x00,0x06,
2012    0x01}},
2013  {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5,
2014    0x0a,0x8c,0xff,0x25,0x30,0x00,0x06,
2015    0x01}}
2016 };
2017
2018 /**************************************************************/
2019 /* COMMON --------------------------------------------------- */
2020 /**************************************************************/
2021
2022 #ifdef LINUX_XF86
2023
2024 #define SIS_PL_HSYNCP 0x01
2025 #define SIS_PL_HSYNCN 0x02
2026 #define SIS_PL_VSYNCP 0x04
2027 #define SIS_PL_VSYNCN 0x08
2028 #define SIS_PL_DVI    0x80
2029
2030 typedef struct _SiS_PlasmaModes
2031 {
2032   const char *name;
2033   ULONG  clock;
2034   USHORT HDisplay, HTotal, HFrontPorch, HSyncWidth;
2035   USHORT VDisplay, VTotal, VFrontPorch, VSyncWidth;
2036   UCHAR  SyncFlags;
2037 } SiS_PlasmaModes;
2038
2039 typedef struct _SiS_PlasmaTables
2040 {
2041    USHORT vendor;
2042    UCHAR  productnum;
2043    USHORT product[5];
2044    const char *DDCnames[5];
2045    const char *plasmaname;
2046    USHORT maxx,maxy;
2047    USHORT prefx, prefy;
2048    UCHAR  modenum;
2049    UCHAR  plasmamodes[20];  /* | 0x80 = DVI-capable, | 0x40 = analog */
2050 } SiS_PlasmaTables;
2051
2052 static const SiS_PlasmaModes SiS_PlasmaMode[] = {
2053    {  "640x400",                /* 00: IBM 400@70 */
2054       25175,
2055        640,  800, 17,  64,
2056        400,  449, 13,   2,
2057       SIS_PL_HSYNCN | SIS_PL_VSYNCN },
2058    {  "640x480",                /* 01: VESA 480@72 */
2059       31500,
2060        640,  832, 24,  40,
2061        480,  520,  9,   3,
2062       SIS_PL_HSYNCN | SIS_PL_VSYNCN },
2063    {  "800x600",                /* 02: VESA 600@72 */
2064       50000,
2065        800, 1040, 56, 120,
2066        600,  666, 37,   6,
2067       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2068    {  "864x480",                /* 03: Cereb wide 1 */
2069       42526,
2070        864, 1134, 22,  86,
2071        480,  500,  1,   3,
2072       SIS_PL_HSYNCP | SIS_PL_VSYNCN },
2073    {  "848x480",                /* 04: VESA wide (NEC1) */
2074       33750,
2075        848, 1088, 16, 112,
2076        480,  517,  6,   8,
2077       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2078    {  "1024x576",               /* 05: VESA wide (NEC2) */
2079       47250,
2080       1024, 1320, 16, 144,
2081        576,  596,  2,   4,
2082       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2083    {  "1280x720",               /* 06: VESA wide (NEC3) */
2084       76500,
2085       1280, 1696, 48, 176,
2086        720,  750,  4,   8,
2087       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2088    {  "1360x765",               /* 07: VESA wide (NEC4) */
2089       85500,
2090       1360, 1792, 64, 176,
2091        765,  795,  4,   8,
2092       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2093    {  "1024x600",               /* 08: CEREB wide 2 */
2094       51200,
2095       1024, 1352, 51, 164,
2096        600,  628,  1,   4,
2097       SIS_PL_HSYNCN | SIS_PL_VSYNCP },
2098    {  "1024x768",               /* 09: VESA 768@75 */
2099       78750,
2100       1024, 1312,  16, 96,
2101        768,  800,   1,  3,
2102       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2103    {  "1152x864",               /* 10: VESA 1152x864@75 */
2104       108000,
2105       1152, 1600, 64, 128,
2106        864,  900,  1,   3,
2107       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2108    {  "1280x1024",              /* 11: VESA 1024@60 */
2109       108000,
2110       1280, 1688, 48, 112,
2111       1024, 1066,  1,   3,
2112       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2113    {  "1280x768",               /* 12: W_XGA */
2114       81000,
2115       1280, 1688, 48, 112,
2116        768,  802,  3,   6,
2117       SIS_PL_HSYNCP | SIS_PL_VSYNCN },
2118    {  "1280x768",               /* 13: I/O Data W_XGA@56Hz */
2119       76064,
2120       1280, 1688, 48, 112,
2121        768,  802,  2,   3,
2122       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2123    {  "1376x768",               /* 14: I/O Wide XGA */
2124       87340,
2125       1376, 1808, 32, 128,
2126        768,  806,  3,   6,
2127       SIS_PL_HSYNCN | SIS_PL_VSYNCP },
2128    {  "1280x960",               /* 15: VESA 960@60 */
2129       108000,
2130       1280, 1800, 96, 112,
2131        960, 1000,  1,   3,
2132       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2133    {  "1400x1050",              /* 16: VESA 1050@60Hz */
2134       108000,
2135       1400, 1688, 48, 112,
2136       1050, 1066,  1,   3,
2137       SIS_PL_HSYNCN | SIS_PL_VSYNCN },
2138    {  "1360x768",               /* 17: VESA wide (NEC4/2) */
2139       85500,
2140       1360, 1792, 64, 112,
2141        765,  795,  3,   6,
2142       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2143    {  "800x600",                /* 18: VESA 600@56 */
2144       36000,
2145        800, 1024, 24,   2,
2146        600,  625,  1,   2,
2147       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2148    {  "1072x600",               /* 19: Panasonic 1072x600 (sync?) */
2149       54100,
2150        1072, 1424, 48, 176,
2151         600,  628, 16,   1,
2152       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2153    {  "848x480",                /* 20: Panasonic 848x480 (sync?) */
2154       33070,                    /* is 852x480, but we can't use 852 */
2155         848, 1068, 20,  40,     /* differs from DDC data, better centered */
2156         480,  516,  3,   5,     /* won't work assumingly, because data is % 8 */
2157       SIS_PL_HSYNCN | SIS_PL_VSYNCN },
2158    {  "1280x720",               /* 21: WIDE720(60) (aka "750p") (Panasonic) */
2159       74300,
2160       1280, 1650,110,  40,
2161        720,  750,  5,   5,
2162       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2163    {  "1280x768",               /* 22: 1280x768@56.5 (Panasonic) */
2164       76200,                    /* (According to manual not supported for HDMI; but works) */
2165       1280, 1680, 16,  24,
2166        768,  802,  2,   5,
2167       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2168    {  "1280x720@50",            /* 23: WIDE720(50) (aka "750p") (Panasonic) */
2169       74300,                    /* Panasonic states 45.0kHz. Not possible. This one works (with some overscan) */
2170       1280, 1980,400,  80,
2171        720,  750,  1,   2,
2172       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2173    {  "720x480",                /* 24: 720x480 (aka "525p" and "480p") (Panasonic) */
2174       27000,
2175        720,  856, 40,  32,
2176        480,  525,  1,   3,
2177       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2178    {  "720x576",                /* 25: 720x576 (aka "625p"and "576p") (Panasonic) */
2179       27500,
2180        720,  864, 16,  64,
2181        576,  625,  5,   6,
2182       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2183    {  "1280x720@50",            /* 26: WIDE720(50) (aka "750p") (Generic) */
2184       74300,
2185       1280, 1980,400,  80,
2186        720,  750,  5,   5,
2187       SIS_PL_HSYNCP | SIS_PL_VSYNCP },
2188 };
2189
2190 /*
2191 27.00  720 755 791 858  480 480 484 525
2192 27.50  720 732 795 864  576 581 587 625
2193 */
2194
2195 static const SiS_PlasmaTables SiS_PlasmaTable[] = {
2196 #if 0  /* Product IDs missing */
2197    { 0x38a3, 4,
2198      { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
2199      { "", "", "", "", "" },
2200      "NEC PlasmaSync 42VP4/42VP4D/42VP4G/42VP4DG",
2201      0, 0,
2202      0, 0,
2203      11,   /* All DVI, except 0, 7, 13 */
2204      { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0,
2205       17|0xc0, 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2206    },
2207 #endif
2208 #if 0  /* Product IDs missing */
2209    { 0x38a3, 3,
2210      { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
2211      { "", "", "", "", "" },
2212      "NEC PlasmaSync 42PD1/50PD1/50PD2",
2213      0, 0,
2214      0, 0,
2215      5,   /* DVI entirely unknown */
2216      { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0, 0     , 0     , 0     , 0     , 0     ,
2217        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2218    },
2219    { 0x38a3, 1,
2220      { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
2221      { "", "", "", "", "" },
2222      "NEC PlasmaSync 42PD3",
2223      0, 0,
2224      0, 0,
2225      10,   /* DVI entirely unknown */
2226      { 0|0x40, 1|0xc0, 2|0xc0, 3|0xc0, 4|0xc0, 5|0xc0, 6|0xc0, 7|0x40, 8|0xc0, 9|0xc0,
2227        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2228    },
2229    { 0x38a3, 2,
2230      { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
2231      { "", "", "", "", "" },
2232      "NEC PlasmaSync 42VM3/61XM1",
2233      0, 0,
2234      0, 0,
2235      11,  /* DVI entirely unknown */
2236      { 0|0x40, 1|0xc0, 2|0xc0, 3|0xc0, 4|0xc0, 5|0xc0, 6|0xc0, 8|0xc0, 9|0xc0,11|0xc0,
2237       17|0xc0, 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2238    },
2239    { 0x38a3, 2,
2240      { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
2241      { "", "", "", "", "" },
2242      "NEC PlasmaSync 42MP1/42MP2",
2243      0, 0,
2244      0, 0,
2245      6,   /* DVI entirely unknown */
2246      { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0,11|0xc0, 0     , 0     , 0     , 0     ,
2247        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2248    },
2249    { 0x38a3, 1,
2250      { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
2251      { "", "", "", "", "" },
2252      "NEC PlasmaSync 50MP1",
2253      0, 0,
2254      0, 0,
2255      10,   /* DVI entirely unknown */
2256      { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0,
2257        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2258    },
2259 #endif
2260    { 0x38a3, 4,
2261      { 0xa482, 0xa483, 0x0000, 0x0000, 0x0000 },
2262      { "PX-42VM", "", "", "", "" },
2263      "NEC PlasmaSync 42MP3/42MP4/50MP2/61MP1",
2264      0, 0,
2265      0, 0,
2266      11,   /* All DVI except 0, 7, 13, 17 */
2267      { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0,
2268       17|0x40, 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2269    },
2270 #if 0  /* Product IDs missing */
2271    { 0x38a3, 1,
2272      { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
2273      { "", "", "", "", "" },
2274      "NEC PlasmaSync 3300W",
2275      0, 0,
2276      0, 0,
2277      3,
2278      { 0|0x40, 1|0xc0,18|0xc0, 0     , 0     , 0     , 0     , 0     , 0     , 0     ,
2279        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2280    },
2281    { 0x38a3, 1,
2282      { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
2283      { "", "", "", "", "" },
2284      "NEC PlasmaSync 4200W",
2285      4,   /* DVI entirely unknown */
2286      { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 0     , 0     , 0     , 0     , 0     , 0     ,
2287        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2288    },
2289    { 0x38a3, 1,
2290      { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
2291      { "", "", "", "", "" },
2292      "NEC PlasmaSync 4210W",
2293      0, 0,
2294      0, 0,
2295      6,   /* DVI entirely unknown */
2296      { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0,11|0xc0, 0     , 0     , 0     , 0     ,
2297        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2298    },
2299    { 0x38a3, 1,
2300      { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
2301      { "", "", "", "", "" },
2302      "NEC PlasmaSync 5000W",
2303      0, 0,
2304      0, 0,
2305      7,   /* DVI entirely unknown */
2306      { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,11|0xc0, 0     , 0     , 0     ,
2307        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2308    },
2309 #endif
2310    { 0x412f, 2,
2311      { 0x000c, 0x000b, 0x0000, 0x0000, 0x0000 },
2312      { "", "", "", "", "" },
2313      "Pioneer 503CMX/PDA-5002",
2314      0, 0,
2315      0, 0,
2316      6,   /* DVI unknown */
2317      { 1|0xc0, 2|0xc0, 9|0xc0,11|0xc0,12|0xc0,15|0xc0, 0     , 0     , 0     , 0     ,
2318        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2319    },
2320    { 0x34a9, 1,
2321      { 0xa00e, 0x0000, 0x0000, 0x0000, 0x0000 },
2322      { "", "", "", "", "" },
2323      "Panasonic TH-42",
2324      0, 0,
2325      0, 0,
2326      5,   /* No DVI output */
2327      { 1|0x40, 2|0x40, 4|0x40, 9|0x40,15|0x40, 0     , 0     , 0     , 0     , 0     ,
2328        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2329    },
2330    { 0x34a9, 1,
2331      { 0xa005, 0x0000, 0x0000, 0x0000, 0x0000 },
2332      { "TH-42PW*4", "", "", "", "" },
2333      "Panasonic TH-42PW5",
2334      0, 0,
2335      0, 0,
2336      1,   /* No special modes otherwise; no DVI. */
2337      {20|0x40,19|0x40, 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     ,
2338        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2339    },
2340    { 0x4c2e, 1,
2341      { 0x9b05, 0x0000, 0x0000, 0x0000, 0x0000 },
2342      { "PLV-Z2", "", "", "", "" },
2343      "Sanyo PLV-Z2 (non HDCP-mode)",    /* HDCP mode would be id 9b06, but not needed */
2344      1280, 768,                         /* as it then advertises correct size */
2345      1280, 720,
2346      1,   /* 1280x720, no special modes otherwise */
2347      {21|0xc0, 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     ,
2348        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2349    },
2350    { 0x34a9, 1,
2351      { 0xd034, 0x0000, 0x0000, 0x0000, 0x0000 },
2352      { "AE500U (DVI-D)", "", "", "", "" },
2353      "Panasonic AE500U",
2354      1280, 768,
2355      1280, 720,
2356      1,   /* 1280x720, no special modes otherwise */
2357      {21|0xc0, 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     ,
2358        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2359    },
2360    { 0x34a9, 1,
2361      { 0xd043, 0x0000, 0x0000, 0x0000, 0x0000 },
2362      { "AE700U (HDMI)", "", "", "", "" },
2363      "Panasonic AE700U",
2364      1360, 768,
2365      1280, 720,
2366      6,   /* 1280x720/60, 1280x720/50, 1280x768@56(digital/analog), 720x480, 720x576 */
2367      {21|0xc0,23|0xc0,22|0x80,13|0x40,24|0x80,25|0x80, 0     , 0     , 0     , 0     ,
2368        0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
2369    },
2370    { 0x0000 }
2371 };
2372 #endif
2373
2374 #ifdef LINUX_XF86
2375 USHORT  SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay,
2376                           int Depth, BOOLEAN FSTN, int LCDwith, int LCDheight);
2377 #endif
2378 USHORT  SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, BOOLEAN FSTN,
2379                           USHORT CustomT, int LCDwith, int LCDheight);
2380 USHORT  SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth);
2381 USHORT  SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth);
2382
2383 void    SiS_SetReg(SISIOADDRESS port, USHORT index, USHORT data);
2384 void    SiS_SetRegByte(SISIOADDRESS port, USHORT data);
2385 void    SiS_SetRegShort(SISIOADDRESS port, USHORT data);
2386 void    SiS_SetRegLong(SISIOADDRESS port, ULONG data);
2387 UCHAR   SiS_GetReg(SISIOADDRESS port, USHORT index);
2388 UCHAR   SiS_GetRegByte(SISIOADDRESS port);
2389 USHORT  SiS_GetRegShort(SISIOADDRESS port);
2390 ULONG   SiS_GetRegLong(SISIOADDRESS port);
2391 void    SiS_SetRegANDOR(SISIOADDRESS Port, USHORT Index, USHORT DataAND, USHORT DataOR);
2392 void    SiS_SetRegAND(SISIOADDRESS Port,USHORT Index, USHORT DataAND);
2393 void    SiS_SetRegOR(SISIOADDRESS Port,USHORT Index, USHORT DataOR);
2394 void    SiS_DisplayOn(SiS_Private *SiS_Pr);
2395 void    SiS_DisplayOff(SiS_Private *SiS_Pr);
2396 void    SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr);
2397 BOOLEAN SiSDetermineROMLayout661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2398 void    SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable);
2399 void    SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable);
2400 BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex);
2401 UCHAR   SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex);
2402 USHORT  SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex);
2403 USHORT  SiS_GetOffset(SiS_Private *SiS_Pr,USHORT ModeNo, USHORT ModeIdIndex,
2404               USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo);
2405 void    SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT ModeIdIndex);
2406 void    SiS_CalcLCDACRT1Timing(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex);
2407
2408 #ifdef LINUX_XF86
2409 BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch);
2410 BOOLEAN SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn,
2411                DisplayModePtr mode, BOOLEAN IsCustom);
2412 BOOLEAN SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn,
2413                DisplayModePtr mode, BOOLEAN IsCustom);
2414 BOOLEAN SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn,
2415                DisplayModePtr mode, BOOLEAN IsCustom);
2416 int     SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber);
2417 int     SiSTranslateToOldMode(int modenumber);
2418 BOOLEAN SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_INFO);
2419 USHORT  SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags);
2420 DisplayModePtr SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfordvi);
2421 int     SiS_FindPanelFromDB(SISPtr pSiS, USHORT panelvendor, USHORT panelproduct, int *maxx, int *maxy, int *prefx, int *prefy);
2422 void    SiS_MakeClockRegs(ScrnInfoPtr pScrn, int clock, UCHAR *p2b, UCHAR *p2c);
2423 #else
2424 BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,USHORT ModeNo);
2425 #endif
2426
2427 #ifdef LINUX_KERNEL
2428 int     sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
2429                               UCHAR modeno, UCHAR rateindex);
2430 int     sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
2431                         UCHAR modeno, UCHAR rateindex,
2432                         struct fb_var_screeninfo *var);
2433 BOOLEAN sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
2434                         UCHAR modeno, int *htotal, int *vtotal, UCHAR rateindex);
2435 #endif
2436
2437 /* init301.c: */
2438 extern void     SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2439                                 PSIS_HW_INFO HwInfo, int chkcrt2mode);
2440 extern void     SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2441                                 PSIS_HW_INFO HwInfo);
2442 extern void     SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2443 extern void     SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo);
2444 extern void     SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2445 extern void     SiS_DisableBridge(SiS_Private *, PSIS_HW_INFO);
2446 extern BOOLEAN  SiS_SetCRT2Group(SiS_Private *, PSIS_HW_INFO, USHORT);
2447 extern USHORT   SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2448                                 PSIS_HW_INFO HwInfo);
2449 extern void     SiS_WaitRetrace1(SiS_Private *SiS_Pr);
2450 extern USHORT   SiS_GetResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex);
2451 extern USHORT   SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax);
2452 extern USHORT   SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2453                                 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo);
2454 extern BOOLEAN  SiS_IsVAMode(SiS_Private *, PSIS_HW_INFO);
2455 extern BOOLEAN  SiS_IsDualEdge(SiS_Private *, PSIS_HW_INFO);
2456
2457 #ifdef LINUX_XF86
2458 /* From other sis driver modules: */
2459 extern int      SiS_compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div,
2460                                 int *out_sbit, int *out_scale);
2461 extern void     SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD, unsigned int *vclk);
2462
2463 extern UCHAR    SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, UCHAR value);
2464 extern UCHAR    SiS_GetSetModeID(ScrnInfoPtr pScrn, UCHAR id);
2465 extern USHORT   SiS_GetModeNumber(ScrnInfoPtr pScrn, DisplayModePtr mode, ULONG VBFlags);
2466 #endif
2467
2468 #endif
2469