Merge branch 'master' into for_paulus
[linux-drm-fsl-dcu.git] / drivers / video / sis / init.h
1 /* $XFree86$ */
2 /* $XdotOrg$ */
3 /*
4  * Data and prototypes for init.c
5  *
6  * Copyright (C) 2001-2005 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_H_
54 #define _INIT_H_
55
56 #include "osdef.h"
57 #include "initdef.h"
58
59 #ifdef SIS_XORG_XF86
60 #include "sis.h"
61 #define SIS_NEED_inSISREG
62 #define SIS_NEED_inSISREGW
63 #define SIS_NEED_inSISREGL
64 #define SIS_NEED_outSISREG
65 #define SIS_NEED_outSISREGW
66 #define SIS_NEED_outSISREGL
67 #include "sis_regs.h"
68 #endif
69
70 #ifdef SIS_LINUX_KERNEL
71 #include "vgatypes.h"
72 #include "vstruct.h"
73 #ifdef SIS_CP
74 #undef SIS_CP
75 #endif
76 #include <linux/version.h>
77 #include <linux/types.h>
78 #include <asm/io.h>
79 #include <linux/fb.h>
80 #include "sis.h"
81 #include <video/sisfb.h>
82 #endif
83
84 /* Mode numbers */
85 static const unsigned short ModeIndex_320x200[]      = {0x59, 0x41, 0x00, 0x4f};
86 static const unsigned short ModeIndex_320x240[]      = {0x50, 0x56, 0x00, 0x53};
87 static const unsigned short ModeIndex_320x240_FSTN[] = {0x5a, 0x5b, 0x00, 0x00};  /* FSTN */
88 static const unsigned short ModeIndex_400x300[]      = {0x51, 0x57, 0x00, 0x54};
89 static const unsigned short ModeIndex_512x384[]      = {0x52, 0x58, 0x00, 0x5c};
90 static const unsigned short ModeIndex_640x400[]      = {0x2f, 0x5d, 0x00, 0x5e};
91 static const unsigned short ModeIndex_640x480[]      = {0x2e, 0x44, 0x00, 0x62};
92 static const unsigned short ModeIndex_720x480[]      = {0x31, 0x33, 0x00, 0x35};
93 static const unsigned short ModeIndex_720x576[]      = {0x32, 0x34, 0x00, 0x36};
94 static const unsigned short ModeIndex_768x576[]      = {0x5f, 0x60, 0x00, 0x61};
95 static const unsigned short ModeIndex_800x480[]      = {0x70, 0x7a, 0x00, 0x76};
96 static const unsigned short ModeIndex_800x600[]      = {0x30, 0x47, 0x00, 0x63};
97 static const unsigned short ModeIndex_848x480[]      = {0x39, 0x3b, 0x00, 0x3e};
98 static const unsigned short ModeIndex_856x480[]      = {0x3f, 0x42, 0x00, 0x45};
99 static const unsigned short ModeIndex_960x540[]      = {0x1d, 0x1e, 0x00, 0x1f};  /* 315 series only */
100 static const unsigned short ModeIndex_960x600[]      = {0x20, 0x21, 0x00, 0x22};  /* 315 series only */
101 static const unsigned short ModeIndex_1024x768[]     = {0x38, 0x4a, 0x00, 0x64};
102 static const unsigned short ModeIndex_1024x576[]     = {0x71, 0x74, 0x00, 0x77};
103 static const unsigned short ModeIndex_1024x600[]     = {0x20, 0x21, 0x00, 0x22};  /* 300 series only */
104 static const unsigned short ModeIndex_1280x1024[]    = {0x3a, 0x4d, 0x00, 0x65};
105 static const unsigned short ModeIndex_1280x960[]     = {0x7c, 0x7d, 0x00, 0x7e};
106 static const unsigned short ModeIndex_1152x768[]     = {0x23, 0x24, 0x00, 0x25};  /* 300 series only */
107 static const unsigned short ModeIndex_1152x864[]     = {0x29, 0x2a, 0x00, 0x2b};
108 static const unsigned short ModeIndex_300_1280x768[] = {0x55, 0x5a, 0x00, 0x5b};
109 static const unsigned short ModeIndex_310_1280x768[] = {0x23, 0x24, 0x00, 0x25};
110 static const unsigned short ModeIndex_1280x720[]     = {0x79, 0x75, 0x00, 0x78};
111 static const unsigned short ModeIndex_1280x800[]     = {0x14, 0x15, 0x00, 0x16};
112 static const unsigned short ModeIndex_1280x854[]     = {0x1a, 0x1b, 0x00, 0x1c};
113 static const unsigned short ModeIndex_1360x768[]     = {0x48, 0x4b, 0x00, 0x4e};
114 static const unsigned short ModeIndex_300_1360x1024[]= {0x67, 0x6f, 0x00, 0x72};  /* 300 series, BARCO only */
115 static const unsigned short ModeIndex_1400x1050[]    = {0x26, 0x27, 0x00, 0x28};  /* 315 series only */
116 static const unsigned short ModeIndex_1680x1050[]    = {0x17, 0x18, 0x00, 0x19};  /* 315 series only */
117 static const unsigned short ModeIndex_1600x1200[]    = {0x3c, 0x3d, 0x00, 0x66};
118 static const unsigned short ModeIndex_1920x1080[]    = {0x2c, 0x2d, 0x00, 0x73};  /* 315 series only */
119 static const unsigned short ModeIndex_1920x1440[]    = {0x68, 0x69, 0x00, 0x6b};
120 static const unsigned short ModeIndex_300_2048x1536[]= {0x6c, 0x6d, 0x00, 0x00};
121 static const unsigned short ModeIndex_310_2048x1536[]= {0x6c, 0x6d, 0x00, 0x6e};
122
123 static const unsigned short SiS_DRAMType[17][5]={
124         {0x0C,0x0A,0x02,0x40,0x39},
125         {0x0D,0x0A,0x01,0x40,0x48},
126         {0x0C,0x09,0x02,0x20,0x35},
127         {0x0D,0x09,0x01,0x20,0x44},
128         {0x0C,0x08,0x02,0x10,0x31},
129         {0x0D,0x08,0x01,0x10,0x40},
130         {0x0C,0x0A,0x01,0x20,0x34},
131         {0x0C,0x09,0x01,0x08,0x32},
132         {0x0B,0x08,0x02,0x08,0x21},
133         {0x0C,0x08,0x01,0x08,0x30},
134         {0x0A,0x08,0x02,0x04,0x11},
135         {0x0B,0x0A,0x01,0x10,0x28},
136         {0x09,0x08,0x02,0x02,0x01},
137         {0x0B,0x09,0x01,0x08,0x24},
138         {0x0B,0x08,0x01,0x04,0x20},
139         {0x0A,0x08,0x01,0x02,0x10},
140         {0x09,0x08,0x01,0x01,0x00}
141 };
142
143 static const unsigned short SiS_SDRDRAM_TYPE[13][5] =
144 {
145         { 2,12, 9,64,0x35},
146         { 1,13, 9,64,0x44},
147         { 2,12, 8,32,0x31},
148         { 2,11, 9,32,0x25},
149         { 1,12, 9,32,0x34},
150         { 1,13, 8,32,0x40},
151         { 2,11, 8,16,0x21},
152         { 1,12, 8,16,0x30},
153         { 1,11, 9,16,0x24},
154         { 1,11, 8, 8,0x20},
155         { 2, 9, 8, 4,0x01},
156         { 1,10, 8, 4,0x10},
157         { 1, 9, 8, 2,0x00}
158 };
159
160 static const unsigned short SiS_DDRDRAM_TYPE[4][5] =
161 {
162         { 2,12, 9,64,0x35},
163         { 2,12, 8,32,0x31},
164         { 2,11, 8,16,0x21},
165         { 2, 9, 8, 4,0x01}
166 };
167
168 static const unsigned char SiS_MDA_DAC[] =
169 {
170         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
171         0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
172         0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
173         0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
174         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
175         0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
176         0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
177         0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F
178 };
179
180 static const unsigned char SiS_CGA_DAC[] =
181 {
182         0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
183         0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
184         0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
185         0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
186         0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
187         0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
188         0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
189         0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F
190 };
191
192 static const unsigned char SiS_EGA_DAC[] =
193 {
194         0x00,0x10,0x04,0x14,0x01,0x11,0x05,0x15,
195         0x20,0x30,0x24,0x34,0x21,0x31,0x25,0x35,
196         0x08,0x18,0x0C,0x1C,0x09,0x19,0x0D,0x1D,
197         0x28,0x38,0x2C,0x3C,0x29,0x39,0x2D,0x3D,
198         0x02,0x12,0x06,0x16,0x03,0x13,0x07,0x17,
199         0x22,0x32,0x26,0x36,0x23,0x33,0x27,0x37,
200         0x0A,0x1A,0x0E,0x1E,0x0B,0x1B,0x0F,0x1F,
201         0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F
202 };
203
204 static const unsigned char SiS_VGA_DAC[] =
205 {
206         0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
207         0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
208         0x00,0x05,0x08,0x0B,0x0E,0x11,0x14,0x18,
209         0x1C,0x20,0x24,0x28,0x2D,0x32,0x38,0x3F,
210         0x00,0x10,0x1F,0x2F,0x3F,0x1F,0x27,0x2F,
211         0x37,0x3F,0x2D,0x31,0x36,0x3A,0x3F,0x00,
212         0x07,0x0E,0x15,0x1C,0x0E,0x11,0x15,0x18,
213         0x1C,0x14,0x16,0x18,0x1A,0x1C,0x00,0x04,
214         0x08,0x0C,0x10,0x08,0x0A,0x0C,0x0E,0x10,
215         0x0B,0x0C,0x0D,0x0F,0x10
216 };
217
218 static const struct SiS_St SiS_SModeIDTable[] =
219 {
220         {0x01,0x9208,0x01,0x00,0x00,0x00,0x01,0x00,0x40},
221         {0x01,0x1210,0x14,0x01,0x01,0x00,0x01,0x00,0x40},
222         {0x01,0x1010,0x17,0x02,0x02,0x00,0x01,0x01,0x40},
223         {0x03,0x8208,0x03,0x00,0x00,0x00,0x01,0x02,0x40},
224         {0x03,0x0210,0x16,0x01,0x01,0x00,0x01,0x02,0x40},
225         {0x03,0x0010,0x18,0x02,0x02,0x00,0x01,0x03,0x40},
226         {0x05,0x9209,0x05,0x00,0x00,0x00,0x00,0x04,0x40},
227         {0x06,0x8209,0x06,0x00,0x00,0x00,0x00,0x05,0x40},
228         {0x07,0x0000,0x07,0x03,0x03,0x00,0x01,0x03,0x40},
229         {0x07,0x0000,0x19,0x02,0x02,0x00,0x01,0x03,0x40},
230         {0x0d,0x920a,0x0d,0x00,0x00,0x00,0x00,0x04,0x40},
231         {0x0e,0x820a,0x0e,0x00,0x00,0x00,0x00,0x05,0x40},
232         {0x0f,0x0202,0x11,0x01,0x01,0x00,0x00,0x05,0x40},
233         {0x10,0x0212,0x12,0x01,0x01,0x00,0x00,0x05,0x40},
234         {0x11,0x0212,0x1a,0x04,0x04,0x00,0x00,0x05,0x40},
235         {0x12,0x0212,0x1b,0x04,0x04,0x00,0x00,0x05,0x40},
236         {0x13,0x021b,0x1c,0x00,0x00,0x00,0x00,0x04,0x40},
237         {0x12,0x0010,0x18,0x02,0x02,0x00,0x00,0x05,0x40},
238         {0x12,0x0210,0x18,0x01,0x01,0x00,0x00,0x05,0x40},
239         {0xff,0x0000,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
240 };
241
242 static const struct SiS_StResInfo_S SiS_StResInfo[]=
243 {
244         { 640,400},
245         { 640,350},
246         { 720,400},
247         { 720,350},
248         { 640,480}
249 };
250
251 static const struct SiS_ModeResInfo_S SiS_ModeResInfo[] =
252 {
253         {  320, 200, 8, 8},   /* 0x00 */
254         {  320, 240, 8, 8},   /* 0x01 */
255         {  320, 400, 8, 8},   /* 0x02 */
256         {  400, 300, 8, 8},   /* 0x03 */
257         {  512, 384, 8, 8},   /* 0x04 */
258         {  640, 400, 8,16},   /* 0x05 */
259         {  640, 480, 8,16},   /* 0x06 */
260         {  800, 600, 8,16},   /* 0x07 */
261         { 1024, 768, 8,16},   /* 0x08 */
262         { 1280,1024, 8,16},   /* 0x09 */
263         { 1600,1200, 8,16},   /* 0x0a */
264         { 1920,1440, 8,16},   /* 0x0b */
265         { 2048,1536, 8,16},   /* 0x0c */
266         {  720, 480, 8,16},   /* 0x0d */
267         {  720, 576, 8,16},   /* 0x0e */
268         { 1280, 960, 8,16},   /* 0x0f */
269         {  800, 480, 8,16},   /* 0x10 */
270         { 1024, 576, 8,16},   /* 0x11 */
271         { 1280, 720, 8,16},   /* 0x12 */
272         {  856, 480, 8,16},   /* 0x13 */
273         { 1280, 768, 8,16},   /* 0x14 */
274         { 1400,1050, 8,16},   /* 0x15 */
275         { 1152, 864, 8,16},   /* 0x16 */
276         {  848, 480, 8,16},   /* 0x17 */
277         { 1360, 768, 8,16},   /* 0x18 */
278         { 1024, 600, 8,16},   /* 0x19 */
279         { 1152, 768, 8,16},   /* 0x1a */
280         {  768, 576, 8,16},   /* 0x1b */
281         { 1360,1024, 8,16},   /* 0x1c */
282         { 1680,1050, 8,16},   /* 0x1d */
283         { 1280, 800, 8,16},   /* 0x1e */
284         { 1920,1080, 8,16},   /* 0x1f */
285         {  960, 540, 8,16},   /* 0x20 */
286         {  960, 600, 8,16},   /* 0x21 */
287         { 1280, 854, 8,16}    /* 0x22 */
288 };
289
290 #if defined(SIS300) || defined(SIS315H)
291 static const struct SiS_StandTable_S SiS_StandTable[]=
292 {
293 /* 0x00: MD_0_200 */
294  {
295   0x28,0x18,0x08,0x0800,
296   {0x09,0x03,0x00,0x02},
297   0x63,
298   {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
299    0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
300    0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
301    0xff},
302   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
303    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
304    0x08,0x00,0x0f,0x00},
305   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
306    0xff}
307  },
308 /* 0x01: MD_1_200 */
309  {
310   0x28,0x18,0x08,0x0800,
311   {0x09,0x03,0x00,0x02},
312   0x63,
313   {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
314    0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
315    0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
316    0xff},
317   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
318    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
319    0x08,0x00,0x0f,0x00},
320   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
321    0xff}
322  },
323 /* 0x02: MD_2_200 */
324  {
325   0x50,0x18,0x08,0x1000,
326   {0x01,0x03,0x00,0x02},
327   0x63,
328   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
329    0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
330    0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
331    0xff},
332   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
333    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
334    0x08,0x00,0x0f,0x00},
335   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
336    0xff}
337  },
338 /* 0x03: MD_3_200 - mode 0x03 - 0 */
339  {
340   0x50,0x18,0x08,0x1000,
341   {0x01,0x03,0x00,0x02},
342   0x63,
343   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
344    0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
345    0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
346    0xff},
347   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
348    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
349    0x08,0x00,0x0f,0x00},
350   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
351    0xff}
352  },
353 /* 0x04: MD_4 */
354  {
355   0x28,0x18,0x08,0x4000,
356   {0x09,0x03,0x00,0x02},
357   0x63,
358   {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,   /* 0x2c is 2b for 300 */
359    0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
360    0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
361    0xff},
362   {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
363    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
364    0x01,0x00,0x03,0x00},
365   {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
366    0xff}
367  },
368 /* 0x05: MD_5 */
369  {
370   0x28,0x18,0x08,0x4000,
371   {0x09,0x03,0x00,0x02},
372   0x63,
373   {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,   /* 0x2c is 2b for 300 */
374    0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
375    0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
376    0xff},
377   {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
378    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
379    0x01,0x00,0x03,0x00},
380   {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
381    0xff}
382  },
383 /* 0x06: MD_6 */
384  {
385   0x50,0x18,0x08,0x4000,
386   {0x01,0x01,0x00,0x06},
387   0x63,
388   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,   /* 55,81 is 54,80 for 300 */
389    0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
390    0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2,
391    0xff},
392   {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
393    0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
394    0x01,0x00,0x01,0x00},
395   {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00,
396    0xff}
397  },
398 /* 0x07: MD_7 */
399  {
400   0x50,0x18,0x0e,0x1000,
401   {0x00,0x03,0x00,0x03},
402   0xa6,
403   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
404    0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
405    0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3,
406    0xff},
407   {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
408    0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
409    0x0e,0x00,0x0f,0x08},
410   {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
411    0xff}
412  },
413 /* 0x08: MDA_DAC */
414  {
415   0x00,0x00,0x00,0x0000,
416   {0x00,0x00,0x00,0x15},
417   0x15,
418   {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
419    0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f,
420    0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,
421    0x00},
422   {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15,
423    0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
424    0x15,0x15,0x15,0x15},
425   {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
426    0x3f}
427  },
428 /* 0x09: CGA_DAC */
429  {
430   0x00,0x10,0x04,0x0114,
431   {0x11,0x09,0x15,0x00},
432   0x10,
433   {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,
434    0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a,
435    0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10,
436    0x04},
437   {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04,
438    0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e,
439    0x3e,0x2b,0x3b,0x2f},
440   {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
441    0x3f}
442  },
443 /* 0x0a: EGA_DAC */
444  {
445   0x00,0x10,0x04,0x0114,
446   {0x11,0x05,0x15,0x20},
447   0x30,
448   {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18,
449    0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38,
450    0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12,
451    0x06},
452   {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26,
453    0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e,
454    0x1e,0x0b,0x1b,0x0f},
455   {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
456    0x3f}
457  },
458 /* 0x0b: VGA_DAC */
459  {
460   0x00,0x10,0x04,0x0114,
461   {0x11,0x09,0x15,0x2a},
462   0x3a,
463   {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05,
464    0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20,
465    0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10,
466    0x1f},
467   {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d,
468    0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15,
469    0x1c,0x0e,0x11,0x15},
470   {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00,
471    0x04}
472  },
473 /* 0x0c */
474  {
475   0x08,0x0c,0x10,0x0a08,
476   {0x0c,0x0e,0x10,0x0b},
477   0x0c,
478   {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00,
479    0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00,
480    0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00,
481    0x06},
482   {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08,
483    0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00,
484    0x00,0x00,0x00,0x00},
485   {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
486    0x00}
487  },
488 /* 0x0d: MD_D */
489  {
490   0x28,0x18,0x08,0x2000,
491   {0x09,0x0f,0x00,0x06},
492   0x63,
493   {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,     /* 2c is 2b for 300 */
494    0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
495    0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3,
496    0xff},
497   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
498    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
499    0x01,0x00,0x0f,0x00},
500   {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
501    0xff}
502  },
503 /* 0x0e: MD_E */
504  {
505   0x50,0x18,0x08,0x4000,
506   {0x01,0x0f,0x00,0x06},
507   0x63,
508   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,     /* 55,81 is 54,80 for 300 */
509    0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
510    0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3,
511    0xff},
512   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
513    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
514    0x01,0x00,0x0f,0x00},
515   {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
516    0xff}
517  },
518 /* 0x0f: ExtVGATable - modes > 0x13 */
519  {
520   0x00,0x00,0x00,0x0000,
521   {0x01,0x0f,0x00,0x0e},
522   0x23,
523   {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e,
524    0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
525    0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3,
526    0xff},
527   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
528    0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
529    0x01,0x00,0x00,0x00},
530   {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
531    0xff}
532  },
533 /* 0x10: ROM_SAVEPTR - totally different for 300 */
534  {
535   0x9f,0x3b,0x00,0x00c0,
536   {0x00,0x00,0x00,0x00},
537   0x00,
538   {0x00,0x00,0x00,0x00,0x00,0x00,0xbb,0x3f,
539    0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
540    0x00,0x00,0x1a,0x00,0xac,0x3e,0x00,0xc0,
541    0x00},
542   {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
543    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
544    0x00,0x00,0x00,0x00},
545   {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
546    0x00}
547  },
548 /* 0x11: MD_F */
549  {
550   0x50,0x18,0x0e,0x8000,
551   {0x01,0x0f,0x00,0x06},
552   0xa2,
553   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,    /* 55,81 is 54,80 on 300 */
554    0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
555    0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3,    /* 82,84 is 83,85 on 300 */
556    0xff},
557   {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00,
558    0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00,
559    0x0b,0x00,0x05,0x00},
560   {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,
561    0xff}
562  },
563 /* 0x12: MD_10 */
564  {
565   0x50,0x18,0x0e,0x8000,
566   {0x01,0x0f,0x00,0x06},
567   0xa3,
568   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,    /* 55,81 is 54,80 on 300 */
569    0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
570    0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3,    /* 82,84 is 83,85 on 300 */
571    0xff},
572   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
573    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
574    0x01,0x00,0x0f,0x00},
575   {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
576    0xff}
577  },
578 /* 0x13: MD_0_350 */
579  {
580   0x28,0x18,0x0e,0x0800,
581   {0x09,0x03,0x00,0x02},
582   0xa3,
583   {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f,    /* b1 is a0 on 300 */
584    0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
585    0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
586    0xff},
587   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
588    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
589    0x08,0x00,0x0f,0x00},
590   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
591    0xff}
592  },
593 /* 0x14: MD_1_350 */
594  {
595   0x28,0x18,0x0e,0x0800,
596   {0x09,0x03,0x00,0x02},
597   0xa3,
598   {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
599    0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
600    0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
601    0xff},
602   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
603    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
604    0x08,0x00,0x0f,0x00},
605   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
606    0xff}
607  },
608 /* 0x15: MD_2_350 */
609  {
610   0x50,0x18,0x0e,0x1000,
611   {0x01,0x03,0x00,0x02},
612   0xa3,
613   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
614    0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
615    0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
616    0xff},
617   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
618    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
619    0x08,0x00,0x0f,0x00},
620   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
621    0xff}
622  },
623 /* 0x16: MD_3_350 - mode 0x03 - 1 */
624  {
625   0x50,0x18,0x0e,0x1000,
626   {0x01,0x03,0x00,0x02},
627   0xa3,
628   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
629    0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
630    0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
631    0xff},
632   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
633    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
634    0x08,0x00,0x0f,0x00},
635   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
636    0xff}
637  },
638 /* 0x17: MD_0_1_400 */
639  {
640   0x28,0x18,0x10,0x0800,
641   {0x08,0x03,0x00,0x02},
642   0x67,
643   {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f,    /* b1 is a0 on 300 */
644    0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
645    0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
646    0xff},
647   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
648    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
649    0x0c,0x00,0x0f,0x08},
650   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
651    0xff}
652  },
653 /* 0x18: MD_2_3_400 - mode 0x03 - 2 */
654  {
655   0x50,0x18,0x10,0x1000,
656   {0x00,0x03,0x00,0x02},
657   0x67,
658   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
659    0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
660    0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
661    0xff},
662   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
663    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
664    0x0c,0x00,0x0f,0x08},
665   {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
666    0xff}
667  },
668 /* 0x19: MD_7_400 */
669  {
670   0x50,0x18,0x10,0x1000,
671   {0x00,0x03,0x00,0x02},
672   0x66,
673   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
674    0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
675    0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3,
676    0xff},
677   {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
678    0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
679    0x0e,0x00,0x0f,0x08},
680   {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
681    0xff}
682  },
683 /* 0x1a: MD_11 */
684  {
685   0x50,0x1d,0x10,0xa000,
686   {0x01,0x0f,0x00,0x06},
687   0xe3,
688   {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,    /* 55,81 is 54,80 on 300 */
689    0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
690    0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xc3,    /* e9,8b is ea,8c on 300 */
691    0xff},
692   {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
693    0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
694    0x01,0x00,0x0f,0x00},
695   {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01,
696    0xff}
697  },
698 /* 0x1b: ExtEGATable - Modes <= 0x02 */
699  {
700   0x50,0x1d,0x10,0xa000,
701   {0x01,0x0f,0x00,0x06},
702   0xe3,
703   {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,    /* 55,81 is 54,80 on 300 */
704    0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
705    0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xe3,    /* e9,8b is ea,8c on 300 */
706    0xff},
707   {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
708    0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
709    0x01,0x00,0x0f,0x00},
710   {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
711    0xff}
712  },
713 /* 0x1c: MD_13 */
714  {
715   0x28,0x18,0x08,0x2000,
716   {0x01,0x0f,0x00,0x0e},
717   0x63,
718   {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,    /* 55,81 is 54,80 on 300 */
719    0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,
720    0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3,
721    0xff},
722   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
723    0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
724    0x41,0x00,0x0f,0x00},
725   {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
726    0xff}
727  }
728 };
729 #endif
730
731 /**************************************************************/
732 /* SIS VIDEO BRIDGE ----------------------------------------- */
733 /**************************************************************/
734
735 static const unsigned char SiS_SoftSetting  = 0x30;   /* RAM setting */
736
737 static const unsigned char SiS_OutputSelect = 0x40;
738
739 static const unsigned char SiS_NTSCTiming[] = {
740         0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c,
741         0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a,
742         0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b,
743         0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17,
744         0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02,
745         0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40,
746         0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50,
747         0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00
748 };
749
750 static const unsigned char SiS_PALTiming[] = {
751         0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70,
752         0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d,
753         0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b,
754         0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17,
755         0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02,
756         0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40,
757         0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63,
758         0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00
759 };
760
761 static const unsigned char SiS_HiTVExtTiming[] = {
762         0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64,
763         0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
764         0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
765         0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13,
766         0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40,
767         0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40,
768         0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d,
769         0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00
770 };
771
772 static const unsigned char SiS_HiTVSt1Timing[] = {
773         0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65,
774         0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
775         0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
776         0x65,0x90,0x7b,0xa8,0x03,0xf0,0x87,0x03,
777         0x11,0x15,0x11,0xcf,0x10,0x11,0xcf,0x10,
778         0x35,0x35,0x3b,0x69,0x1d,0x92,0x0f,0x40,
779         0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x86,
780         0xaf,0x5d,0x0e,0x00,0xfc,0xff,0x2d,0x00
781 };
782
783 static const unsigned char SiS_HiTVSt2Timing[] = {
784         0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64,
785         0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
786         0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
787         0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13,
788         0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40,
789         0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40,
790         0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d,
791         0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00
792 };
793
794 #if 0
795 static const unsigned char SiS_HiTVTextTiming[] = {
796         0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65,
797         0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
798         0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
799         0x65,0x90,0xe7,0xbc,0x03,0x0c,0x97,0x03,
800         0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20,
801         0xc8,0xc8,0x3b,0xd2,0x26,0x92,0x0f,0x40,
802         0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96,
803         0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00
804 };
805 #endif
806
807 static const unsigned char SiS_HiTVGroup3Data[] = {
808         0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f,
809         0x05,0x21,0xb2,0xb2,0x55,0x77,0x2a,0xa6,
810         0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
811         0x8c,0x6e,0x60,0x2e,0x58,0x48,0x72,0x44,
812         0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
813         0x4f,0x7f,0x03,0xa8,0x7d,0x20,0x1a,0xa9,
814         0x14,0x05,0x03,0x7e,0x64,0x31,0x14,0x75,
815         0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
816 };
817
818 static const unsigned char SiS_HiTVGroup3Simu[] = {
819         0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95,
820         0xdb,0x20,0xb8,0xb8,0x55,0x47,0x2a,0xa6,
821         0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
822         0x8c,0x6e,0x60,0x15,0x26,0xd3,0xe4,0x11,
823         0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
824         0x67,0x36,0x01,0x47,0x0e,0x10,0xbe,0xb4,
825         0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75,
826         0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
827 };
828
829 #if 0
830 static const unsigned char SiS_HiTVGroup3Text[] = {
831         0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7,
832         0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6,
833         0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
834         0x8c,0x6e,0x60,0x18,0x2c,0x0c,0x20,0x22,
835         0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
836         0x93,0x3c,0x01,0x50,0x2f,0x10,0xf4,0xca,
837         0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75,
838         0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
839 };
840 #endif
841
842 static const struct SiS_TVData SiS_StPALData[] =
843 {
844  {    1,   1, 864, 525,1270, 400, 100, 0, 760,    0,0xf4,0xff,0x1c,0x22},
845  {    1,   1, 864, 525,1270, 350, 100, 0, 760,    0,0xf4,0xff,0x1c,0x22},
846  {    1,   1, 864, 525,1270, 400,   0, 0, 720,    0,0xf1,0x04,0x1f,0x18},
847  {    1,   1, 864, 525,1270, 350,   0, 0, 720,    0,0xf4,0x0b,0x1c,0x0a},
848  {    1,   1, 864, 525,1270, 480,  50, 0, 760,    0,0xf4,0xff,0x1c,0x22},
849  {    1,   1, 864, 525,1270, 600,  50, 0,   0,0x300,0xf4,0xff,0x1c,0x22}
850 };
851
852 static const struct SiS_TVData SiS_ExtPALData[] =
853 {
854  {   27,  10, 848, 448,1270, 530,  50, 0,  50,    0,0xf4,0xff,0x1c,0x22},  /* 640x400, 320x200 */
855  {  108,  35, 848, 398,1270, 530,  50, 0,  50,    0,0xf4,0xff,0x1c,0x22},
856  {   12,   5, 954, 448,1270, 530,  50, 0,  50,    0,0xf1,0x04,0x1f,0x18},
857  {    9,   4, 960, 463,1644, 438,  50, 0,  50,    0,0xf4,0x0b,0x1c,0x0a},
858  {    9,   4, 848, 528,1270, 530,   0, 0,  50,    0,0xf5,0xfb,0x1b,0x2a},  /* 640x480, 320x240 */
859  {   36,  25,1060, 648,1270, 530, 438, 0, 438,    0,0xeb,0x05,0x25,0x16},  /* 800x600, 400x300 */
860  {    3,   2,1080, 619,1270, 540, 438, 0, 438,    0,0xf3,0x00,0x1d,0x20},  /* 720x576 */
861  {    1,   1,1170, 821,1270, 520, 686, 0, 686,    0,0xF3,0x00,0x1D,0x20},  /* 1024x768 */
862  {    1,   1,1170, 821,1270, 520, 686, 0, 686,    0,0xF3,0x00,0x1D,0x20},  /* 1024x768 (for NTSC equ) */
863  {    9,   4, 848, 528,1270, 530,   0, 0,  50,    0,0xf5,0xfb,0x1b,0x2a}   /* 720x480 */
864 };
865
866 static const struct SiS_TVData SiS_StNTSCData[] =
867 {
868  {    1,   1, 858, 525,1270, 400,  50, 0, 760,    0,0xf1,0x04,0x1f,0x18},
869  {    1,   1, 858, 525,1270, 350,  50, 0, 640,    0,0xf1,0x04,0x1f,0x18},
870  {    1,   1, 858, 525,1270, 400,   0, 0, 720,    0,0xf1,0x04,0x1f,0x18},
871  {    1,   1, 858, 525,1270, 350,   0, 0, 720,    0,0xf4,0x0b,0x1c,0x0a},
872  {    1,   1, 858, 525,1270, 480,   0, 0, 760,    0,0xf1,0x04,0x1f,0x18}
873 };
874
875 static const struct SiS_TVData SiS_ExtNTSCData[] =
876 {
877  {  143,  65, 858, 443,1270, 440, 171, 0, 171,    0,0xf1,0x04,0x1f,0x18},    /* 640x400, 320x200 */
878  {   88,  35, 858, 393,1270, 440, 171, 0, 171,    0,0xf1,0x04,0x1f,0x18},
879  {  143,  70, 924, 443,1270, 440,  92, 0,  92,    0,0xf1,0x04,0x1f,0x18},
880  {  143,  70, 924, 393,1270, 440,  92, 0,  92,    0,0xf4,0x0b,0x1c,0x0a},
881  {  143,  76, 836, 523,1270, 440, 224, 0,   0,    0,0xf1,0x05,0x1f,0x16},    /* 640x480, 320x240 */
882  {  143, 120,1056, 643,1270, 440,   0, 1,   0,    0,0xf4,0x10,0x1c,0x00},    /* 800x600, 400x300  */
883  {  143,  76, 836, 523,1270, 440,   0, 1,   0,    0,0xee,0x0c,0x22,0x08},    /* 720x480 - BETTER (from 300 series) */
884  {    1,   1,1100, 811,1412, 440,   0, 1,   0,    0,0xee,0x0c,0x22,0x08},    /* 1024x768 (525i) CORRECTED */
885 #if 0  /* flimmert und ist unten abgeschnitten (NTSCHT, NTSC clock) */
886  {   65,  64,1056, 791,1270, 480, 455, 0,   0,    0,0x00,0x00,0x00,0x00}     /* 1024x768 (525p) */
887 #endif
888 #if 0
889  {    1,   1,1100, 811,1412, 440,   0, 1,   0,    0,0x00,0x00,0x00,0x00}     /* 1024x768 (525p) */
890 #endif
891 #if 0
892  {    1,   1,1120, 821,1516, 420,   0, 1,   0,    0,0x00,0x00,0x00,0x00}     /* 1024x768 (525p) */
893 #endif
894 #if 0
895  {    1,   1, 938, 821,1516, 420,   0, 1,   0,    0,0x00,0x00,0x00,0x00}     /* 1024x768 (525p) */
896 #endif
897 #if 0 /* zoom hin, unten abgeschnitten (NTSC2HT, NTSC1024 clock) */
898  {    1,   1,1072, 791,1270, 480, 455, 0,   0,    0,0x00,0x00,0x00,0x00}     /* 1024x768 (525p) */
899 #endif
900 #if 1 /* zu weit links (squeezed) (NTSC2HT, NTSC1024 clock) */
901  {    1,   1,1100, 846,1270, 440, 455, 0,   0,    0,0x00,0x00,0x00,0x00}     /* 1024x768 (525p) */
902 #endif
903 #if 0 /* zu weit links, rechts abgeschnitten (NTSC2HT, NTSC1024 clock) */
904  {    1,   1,1100, 846,1412, 440, 455, 0,   0,    0,0x00,0x00,0x00,0x00}     /* 1024x768 (525p) */
905 #endif
906 };
907
908 static const struct SiS_TVData SiS_StHiTVData[] =  /* Slave + TVSimu */
909 {
910  {    1,   1, 0x37c,0x233,0x2b2,0x320,    0, 0, 0, 0, 0, 0, 0, 0},
911  {    1,   1, 0x37c,0x233,0x2b2,0x2bc,    0, 0, 0, 0, 0, 0, 0, 0},
912  {    1,   1, 0x37c,0x233,0x2b2,0x320,    0, 0, 0, 0, 0, 0, 0, 0},
913  {    1,   1, 0x37c,0x233,0x2b2,0x2bc,    0, 0, 0, 0, 0, 0, 0, 0},
914  {    1,   1, 0x37c,0x233,0x2b2,0x3c0,    0, 0, 0, 0, 0, 0, 0, 0},
915  {    8,   5, 0x41a,0x2ab,0x670,0x3c0,0x150, 1, 0, 0, 0, 0, 0, 0}
916 };
917
918 static const struct SiS_TVData SiS_St2HiTVData[] = /* Slave */
919 {
920  {    3,   1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0, 0, 0, 0, 0},
921  {    1,   1, 0x37c,0x233,0x2b2,0x2bc,    0, 0, 0, 0, 0, 0, 0, 0},
922  {    3,   1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0, 0, 0, 0, 0},
923  {    1,   1, 0x37c,0x233,0x2b2,0x2bc,    0, 0, 0, 0, 0, 0, 0, 0},
924  {    5,   2, 0x348,0x233,0x670,0x3c0,0x08d, 1, 0, 0, 0, 0, 0, 0},
925  {    8,   5, 0x41a,0x2ab,0x670,0x3c0,0x17c, 1, 0, 0, 0, 0, 0, 0}
926 };
927
928 static const struct SiS_TVData SiS_ExtHiTVData[] =
929 { /* all ok */
930  {    6,   1, 0x348,0x233,0x660,0x3c0,    0, 0, 0, 0, 0, 0, 0, 0},
931  {    3,   1, 0x3c0,0x233,0x660,0x3c0,    0, 0, 0, 0, 0, 0, 0, 0},
932  {    6,   1, 0x348,0x233,0x660,0x3c0,    0, 0, 0, 0, 0, 0, 0, 0},
933  {    3,   1, 0x3c0,0x233,0x660,0x3c0,    0, 0, 0, 0, 0, 0, 0, 0},
934  {    5,   1, 0x348,0x233,0x670,0x3c0,0x166, 1, 0, 0, 0, 0, 0, 0},  /* 640x480   */
935  {   16,   5, 0x41a,0x2ab,0x670,0x3c0,0x143, 1, 0, 0, 0, 0, 0, 0},  /* 800x600   */
936  {   25,  12, 0x4ec,0x353,0x670,0x3c0,0x032, 0, 0, 0, 0, 0, 0, 0},  /* 1024x768  */
937  {    5,   4, 0x627,0x464,0x670,0x3c0,0x128, 0, 0, 0, 0, 0, 0, 0},  /* 1280x1024 */
938  {    4,   1, 0x41a,0x233,0x60c,0x3c0,0x143, 1, 0, 0, 0, 0, 0, 0},  /* 800x480   */
939  {    5,   2, 0x578,0x293,0x670,0x3c0,0x032, 0, 0, 0, 0, 0, 0, 0},  /* 1024x576  */
940  {    8,   5, 0x6d6,0x323,0x670,0x3c0,0x128, 0, 0, 0, 0, 0, 0, 0},  /* 1280x720  */
941  {    8,   3, 0x4ec,0x353,0x670,0x3c0,0x032, 0, 0, 0, 0, 0, 0, 0},  /* 960x600  */
942 };
943
944 static const struct SiS_TVData SiS_St525pData[] =
945 {
946  {    1,   1, 0x6b4,0x20d,0x4f6,0x190,   50, 0, 0x2f8, 0, 0, 0, 0, 0},
947  {    1,   1, 0x6b4,0x20d,0x4f6,0x15e,   50, 0, 0x280, 0, 0, 0, 0, 0},
948  {    1,   1, 0x6b4,0x20d,0x4f6,0x190,   50, 0, 0x2f8, 0, 0, 0, 0, 0},
949  {    1,   1, 0x6b4,0x20d,0x4f6,0x15e,   50, 0, 0x280, 0, 0, 0, 0, 0},
950  {    1,   1, 0x6b4,0x20d,0x4f6,0x1e0,    0, 0, 0x2f8, 0, 0, 0, 0, 0}
951 };
952
953 static const struct SiS_TVData SiS_St750pData[] =
954 {
955  {    1,   1, 0x672,0x2ee,0x500,0x190,   50, 0, 0x2f8, 0, 0, 0, 0, 0},
956  {    1,   1, 0x672,0x2ee,0x500,0x15e,   50, 0, 0x280, 0, 0, 0, 0, 0},
957  {    1,   1, 0x672,0x2ee,0x500,0x190,    0, 0, 0x2d0, 0, 0, 0, 0, 0},
958  {    1,   1, 0x672,0x2ee,0x500,0x15e,    0, 0, 0x2d0, 0, 0, 0, 0, 0},
959  {    1,   1, 0x672,0x2ee,0x500,0x1e0,    0, 0, 0x2f8, 0, 0, 0, 0, 0}
960 };
961
962 static const struct SiS_TVData SiS_Ext750pData[] =
963 { /* all ok */
964  {    3,  1,  935, 470, 1130, 680,  50, 0, 0, 0, 0, 0, 0, 0},  /* 320x200/640x400 */
965  {   24,  7,  935, 420, 1130, 680,  50, 0, 0, 0, 0, 0, 0, 0},
966  {    3,  1,  935, 470, 1130, 680,  50, 0, 0, 0, 0, 0, 0, 0},
967  {   24,  7,  935, 420, 1130, 680,  50, 0, 0, 0, 0, 0, 0, 0},
968  {    2,  1, 1100, 590, 1130, 640,  50, 0, 0, 0, 0, 0, 0, 0},  /* 640x480 */
969  {    3,  2, 1210, 690, 1130, 660,  50, 0, 0, 0, 0, 0, 0, 0},  /* 800x600 OK */
970  {    2,  1, 1100, 562, 1130, 640,   0, 1, 0, 0, 0, 0, 0, 0},  /* 720x480 OK */
971  {    1,  1, 1375, 878, 1130, 640, 638, 0, 0, 0, 0, 0, 0, 0},  /* 1024x768 OK */
972  {    5,  3, 1100, 675, 1130, 640,   0, 1, 0, 0, 0, 0, 0, 0},  /* 720/768x576 OK */
973  {   25, 24, 1496, 755, 1120, 680,  50, 0, 0, 0, 0, 0, 0, 0}   /* 1280x720 OK */
974 };
975
976 static const struct SiS_LCDData SiS_LCD1280x720Data[] =  /* 2.03.00 */
977 {
978         {  44,   15,  864,  430, 1408,  806 }, /* 640x400 */
979         { 128,   35,  792,  385, 1408,  806 },
980         {  44,   15,  864,  430, 1408,  806 },
981         { 128,   35,  792,  385, 1408,  806 },
982         {  22,    9,  864,  516, 1408,  806 }, /* 640x480 */
983         {   8,    5, 1056,  655, 1408,  806 }, /* 800x600 */
984         {   0,    0,    0,    0,    0,    0 }, /* 1024x768 */
985         {   0,    0,    0,    0,    0,    0 }, /* 1280x1024 */
986         {   0,    0,    0,    0,    0,    0 },
987         {   0,    0,    0,    0,    0,    0 },
988         {   1,    1, 1408,  806, 1408,  806 }  /* 1280x720 */
989 };
990
991 /* About 1280x768: For TMDS, Panel_1280x768 will only be set if
992  * the panel is a Fujitsu 7911 (VL-17WDX8) (with clock 81, 1688x802)
993  * Other TMDS panels of this resolution will be treated as custom.
994  * For LVDS, we know another type (_2).
995  * (Note: 1280x768_3 is now special for SiS301/NetVista
996  */
997
998 static const struct SiS_LCDData SiS_StLCD1280x768_2Data[] = /* 2.03.00 */
999 {
1000         {  64,   21,  858,  434, 1408,  806 }, /* 640x400 */
1001         {  32,    9,  858,  372, 1408,  806 },
1002         {  64,   21,  858,  434, 1408,  806 },
1003         {  32,    9,  858,  372, 1408,  806 },
1004         { 143,   68, 1024,  527, 1408,  806 }, /* 640x480 */
1005         {  64,   51, 1364,  663, 1408,  806 }, /* 800x600 */
1006         {  88,   81, 1296,  806, 1408,  806 }, /* 1024x768 */
1007         {   0,    0,    0,    0,    0,    0 },
1008         {   1,    1, 1408,  806, 1408,  806 }, /* 1280x768 */
1009         {   0,    0,    0,    0,    0,    0 },
1010         {  16,   15, 1600,  750, 1600,  806 }  /* 1280x720 - from Ext */
1011 };
1012
1013 static const struct SiS_LCDData SiS_ExtLCD1280x768_2Data[] = /* 2.03.00 */
1014 {
1015         {  16,    5,  960,  410, 1600,  806 }, /* 640x400 */
1016         {  64,   21, 1152,  364, 1600,  806 },
1017         {  16,    5,  960,  410, 1600,  806 },
1018         {  64,   21, 1152,  364, 1600,  806 },
1019         {  32,   13, 1040,  493, 1600,  806 }, /* 640x480 */
1020         {  16,    9, 1152,  618, 1600,  806 }, /* 800x600 */
1021         {  25,   21, 1344,  796, 1600,  806 }, /* 1024x768 */
1022         {   0,    0,    0,    0,    0,    0 },
1023         {   1,    1, 1600,  806, 1600,  806 }, /* 1280x768 */
1024         {   0,    0,    0,    0,    0,    0 },
1025         {  16,   15, 1600,  750, 1600,  806 }  /* 1280x720 */
1026 };
1027
1028 #if 0  /* Not used; _3 now reserved for NetVista (SiS301) */
1029 static const struct SiS_LCDData SiS_LCD1280x768_3Data[] =
1030 {
1031         {  64,   25, 1056,  422, 1664,  798 },                  /* 640x400 */
1032         { 128,   39,  884,  396, 1408,  806 }, /* ,640 */
1033         {  64,   25, 1056,  422, 1664,  798 },                  /* 640x400 */
1034         { 128,   39,  884,  396, 1408,  806 }, /* ,640 */
1035         {  32,   15, 1056,  513, 1408,  806 }, /* ,664 */       /* 640x480 */
1036         { 176,  125, 1280,  640, 1408,  806 }, /* ,768 */       /* 800x600 */
1037         {  64,   61, 1342,  806, 1408,  806 },                  /* 1024x768 */
1038         {   0,    0,    0,    0,    0,    0 },
1039         {   1,    1, 1408,  806, 1408,  806 },                  /* 1280x768 */
1040         {   0,    0,    0,    0,    0,    0 },
1041         {  16,   15, 1600,  750, 1600,  806 }  /* 1280x720  from above */
1042 };
1043 #endif
1044
1045 static const struct SiS_LCDData SiS_LCD1280x800Data[] = /* 0.93.12a (TMDS) */
1046 {
1047         { 128,   51, 1122,  412, 1408,  816 },  /* 640x400 */
1048         { 128,   49, 1232,  361, 1408,  816 },
1049         { 128,   51, 1122,  412, 1408,  816 },
1050         { 128,   49, 1232,  361, 1408,  816 },
1051         {   8,    3,  880,  491, 1408,  816 },  /* 640x480 */
1052         {  11,    6, 1024,  612, 1408,  816 },  /* 800x600 */
1053         {  22,   21, 1400,  784, 1408,  816 },  /* 1024x768 */
1054         {   0,    0,    0,    0,    0,    0 },  /* 1280x1024 */
1055         {   1,    1, 1408,  816, 1408,  816 },  /* 1280x800 */
1056         {   0,    0,    0,    0,    0,    0 },  /* 1280x768 (patch index) */
1057         {   0,    0,    0,    0,    0,    0 }   /* 1280x720 */
1058 };
1059
1060 static const struct SiS_LCDData SiS_LCD1280x800_2Data[] = /* 2.03.00 (LVDS) */
1061 {
1062         {  97,   42, 1344,  409, 1552,  812 }, /* 640x400 */
1063         {  97,   35, 1280,  358, 1552,  812 },
1064         {  97,   42, 1344,  409, 1552,  812 },
1065         {  97,   35, 1280,  358, 1552,  812 },
1066         {  97,   39, 1040,  488, 1552,  812 }, /* 640x480 */
1067         { 194,  105, 1120,  608, 1552,  812 }, /* 800x600 */
1068         {  97,   84, 1400,  780, 1552,  812 }, /* 1024x768 */
1069         {   0,    0,    0,    0,    0,    0 }, /* 1280x1024 */
1070         {   1,    1, 1552,  812, 1552,  812 }, /* 1280x800 */
1071         {  97,   96, 1600,  780, 1552,  812 }, /* 1280x768 - patch index */
1072         {  97,   90, 1600,  730, 1552,  812 }  /* 1280x720 */
1073 };
1074
1075 #if 0
1076 static const struct SiS_LCDData SiS_LCD1280x800_3Data[] = /* 2.02.05a (LVDS); m250 */
1077 {
1078         { 128,   51, 1122,  412, 1408,  816 }, /* 640x400 */
1079         { 128,   49, 1232,  361, 1408,  816 },
1080         { 128,   51, 1122,  412, 1408,  816 },
1081         { 128,   49, 1232,  361, 1408,  816 },
1082         {   8,    3,  880,  491, 1408,  816 }, /* 640x480 */
1083         {  11,    6, 1024,  612, 1408,  816 }, /* 800x600 */
1084         {  22,   21, 1400,  784, 1408,  816 }, /* 1024x768 */
1085         {   0,    0,    0,    0,    0,    0 }, /* 1280x1024 */
1086         {   1,    1, 1408,  816, 1408,  816 }, /* 1280x800 */
1087         {   0,    0,    0,    0,    0,    0 }, /* 1280x768 - patch index */
1088         {   0,    0,    0,    0,    0,    0 }  /* 1280x720 */
1089 };
1090 #endif
1091
1092 static const struct SiS_LCDData SiS_LCD1280x854Data[] = /* 2.21.00CS (LVDS) */
1093 {
1094         {  56,   15,  936,  410, 1664,  861 },  /* 640x400 */
1095         {  64,   25, 1586,  355, 1664,  861 },
1096         {  56,   15,  936,  410, 1664,  861 },
1097         {  64,   25, 1586,  355, 1664,  861 },
1098         {  91,   45, 1464,  485, 1664,  861 },  /* 640x480 */
1099         { 182,   75,  976,  605, 1664,  861 },  /* 800x600 */
1100         {  91,   66, 1342,  774, 1664,  861 },  /* 1024x768 */
1101         {   0,    0,    0,    0,    0,    0 },  /* 1280x1024 */
1102         {  26,   25, 1708,  807, 1664,  861 },  /* 1280x800 */
1103         {  13,   12, 1708,  774, 1664,  861 },  /* 1280x768 - patch index */
1104         {  52,   45, 1708,  725, 1664,  861 },  /* 1280x720 */
1105         {   0,    0,    0,    0,    0,    0 },
1106         {   0,    0,    0,    0,    0,    0 },
1107         {   1,    1, 1664,  861, 1664,  861 }   /* 1280x854 */
1108 };
1109
1110 static const struct SiS_LCDData SiS_LCD1280x960Data[] =
1111 {
1112         {    9,   2,  800,  500, 1800, 1000 },
1113         {    9,   2,  800,  500, 1800, 1000 },
1114         {    4,   1,  900,  500, 1800, 1000 },
1115         {    4,   1,  900,  500, 1800, 1000 },
1116         {    9,   2,  800,  500, 1800, 1000 },
1117         {   30,  11, 1056,  625, 1800, 1000 },
1118         {    5,   3, 1350,  800, 1800, 1000 },
1119         {    1,   1, 1576, 1050, 1576, 1050 },
1120         {    1,   1, 1800, 1000, 1800, 1000 },
1121         {   0,    0,    0,    0,    0,    0 },
1122         {   0,    0,    0,    0,    0,    0 },
1123         {   0,    0,    0,    0,    0,    0 },
1124         {   0,    0,    0,    0,    0,    0 },
1125         {   0,    0,    0,    0,    0,    0 }
1126 };
1127
1128 static const struct SiS_LCDData SiS_StLCD1400x1050Data[] =
1129 {
1130         { 211,  100, 2100,  408, 1688, 1066 },
1131         { 211,   64, 1536,  358, 1688, 1066 },
1132         { 211,  100, 2100,  408, 1688, 1066 },
1133         { 211,   64, 1536,  358, 1688, 1066 },
1134         { 211,   48,  840,  488, 1688, 1066 },
1135         { 211,   72, 1008,  609, 1688, 1066 },
1136         { 211,  128, 1400,  776, 1688, 1066 },
1137         { 211,  205, 1680, 1041, 1688, 1066 },
1138         {   1,    1, 1688, 1066, 1688, 1066 },
1139         {   0,    0,    0,    0,    0,    0 },
1140         {   0,    0,    0,    0,    0,    0 },
1141         {   0,    0,    0,    0,    0,    0 },
1142         {   0,    0,    0,    0,    0,    0 },
1143         {   0,    0,    0,    0,    0,    0 }
1144 };
1145
1146 static const struct SiS_LCDData SiS_ExtLCD1400x1050Data[] =
1147 {
1148 /*      { 211,   60, 1260,  410, 1688, 1066 },    640x400 (6330) */
1149         { 211,  100, 2100,  408, 1688, 1066 }, /* 640x400 (6325) WORKS */
1150         { 211,   64, 1536,  358, 1688, 1066 },
1151         { 211,  100, 2100,  408, 1688, 1066 },
1152         { 211,   64, 1536,  358, 1688, 1066 },
1153 /*      { 211,   80, 1400,  490, 1688, 1066 },    640x480 (6330) */
1154         { 211,   48,  840,  488, 1688, 1066 }, /* 640x480 (6325) WORKS */
1155 /*      { 211,  117, 1638,  613, 1688, 1066 },    800x600 (6330) */
1156         { 211,   72, 1008,  609, 1688, 1066 }, /* 800x600 (6325) WORKS */
1157         { 211,  128, 1400,  776, 1688, 1066 }, /* 1024x768 */
1158         { 211,  205, 1680, 1041, 1688, 1066 }, /* 1280x1024 - not used (always unscaled) */
1159         {   1,    1, 1688, 1066, 1688, 1066 }, /* 1400x1050 */
1160         {   0,    0,    0,    0,    0,    0 }, /* kludge */
1161         { 211,  120, 1400,  730, 1688, 1066 }, /* 1280x720 */
1162         {   0,    0,    0,    0,    0,    0 },
1163         {   0,    0,    0,    0,    0,    0 },
1164         {   0,    0,    0,    0,    0,    0 }
1165 };
1166
1167 static const struct SiS_LCDData SiS_LCD1680x1050Data[] =
1168 {
1169         {  95,   24, 1260,  410, 1900, 1066 }, /*  0 640x400 */
1170         {  10,    3, 1710,  362, 1900, 1066 },
1171         {  95,   24, 1260,  410, 1900, 1066 },
1172         {  10,    3, 1710,  362, 1900, 1066 },
1173         {  95,   32, 1400,  490, 1900, 1066 }, /*  4 640x480 */
1174         {  95,   42, 1470,  610, 1900, 1066 }, /*  5 800x600 */
1175         {  95,   64, 1750,  784, 1900, 1066 }, /*  6 1024x768 */
1176         {  95,   94, 1900, 1055, 1900, 1066 }, /*  7 1280x1024 */
1177         {  41,   31, 1900,  806, 1900, 1066 }, /*  8 1280x768 */
1178         {  95,   69, 1800,  817, 1900, 1066 }, /*  9 1280x800 patch index */
1179         {  13,    9, 1900,  739, 1900, 1066 }, /* 10 1280x720 */
1180         {  95,   94, 1880, 1066, 1900, 1066 }, /* 11 1400x1050 patch index */
1181         {   1,    1, 1900, 1066, 1900, 1066 }, /* 12 1680x1050 */
1182         {   0,    0,    0,    0,    0,    0 }
1183 };
1184
1185 static const struct SiS_LCDData SiS_StLCD1600x1200Data[] =
1186 {
1187         {27,  4, 800, 500, 2160, 1250 },
1188         {27,  4, 800, 500, 2160, 1250 },
1189         { 6,  1, 900, 500, 2160, 1250 },
1190         { 6,  1, 900, 500, 2160, 1250 },
1191         {27,  1, 800, 500, 2160, 1250 },
1192         { 4,  1,1080, 625, 2160, 1250 },
1193         { 5,  2,1350, 800, 2160, 1250 },
1194         {135,88,1600,1100, 2160, 1250 },
1195         {72, 49,1680,1092, 2160, 1250 },
1196         { 1,  1,2160,1250, 2160, 1250 },
1197         { 0,  0,   0,   0,    0,    0 },
1198         { 0,  0,   0,   0,    0,    0 },
1199         { 0,  0,   0,   0,    0,    0 },
1200         { 0,  0,   0,   0,    0,    0 }
1201 };
1202
1203 static const struct SiS_LCDData SiS_ExtLCD1600x1200Data[] =
1204 {
1205         {72,11, 990, 422, 2160, 1250 }, /* 640x400 (6330) WORKS */
1206 /*      {27, 4, 800, 500, 2160, 1250 },    640x400 (6235) */
1207         {27, 4, 800, 500, 2160, 1250 },
1208         { 6, 1, 900, 500, 2160, 1250 },
1209         { 6, 1, 900, 500, 2160, 1250 },
1210         {45, 8, 960, 505, 2160, 1250 }, /* 640x480 (6330) WORKS */
1211 /*      {27, 1, 800, 500, 2160, 1250 },    640x480 (6325) */
1212         { 4, 1,1080, 625, 2160, 1250 },
1213         { 5, 2,1350, 800, 2160, 1250 },
1214         {27,16,1500,1064, 2160, 1250 }, /* 1280x1024 */
1215         {72,49,1680,1092, 2160, 1250 }, /* 1400x1050 (6330, was not supported on 6325) */
1216         { 1, 1,2160,1250, 2160, 1250 },
1217         { 0, 0,   0,   0,    0,    0 },
1218         { 0, 0,   0,   0,    0,    0 },
1219         { 0, 0,   0,   0,    0,    0 },
1220         { 0, 0,   0,   0,    0,    0 }
1221 };
1222
1223 static const struct SiS_LCDData SiS_NoScaleData[] =
1224 {
1225         { 1, 1, 800, 449, 800, 449 },  /* 0x00: 320x200, 640x400 */
1226         { 1, 1, 800, 449, 800, 449 },
1227         { 1, 1, 900, 449, 900, 449 },
1228         { 1, 1, 900, 449, 900, 449 },
1229         { 1, 1, 800, 525, 800, 525 },  /* 0x04: 320x240, 640x480  */
1230         { 1, 1,1056, 628,1056, 628 },  /* 0x05: 400x300, 800x600  */
1231         { 1, 1,1344, 806,1344, 806 },  /* 0x06: 512x384, 1024x768 */
1232         { 1, 1,1688,1066,1688,1066 },  /* 0x07: 1280x1024 */
1233         { 1, 1,1688, 802,1688, 802 },  /* 0x08: 1280x768: Fujitsu, TMDS only */
1234         { 1, 1,2160,1250,2160,1250 },  /* 0x09: 1600x1200 */
1235         { 1, 1,1800,1000,1800,1000 },  /* 0x0a: 1280x960  */
1236         { 1, 1,1688,1066,1688,1066 },  /* 0x0b: 1400x1050 */
1237         { 1, 1,1650, 750,1650, 750 },  /* 0x0c: 1280x720 (TMDS, projector)  */
1238         { 1, 1,1552, 812,1552, 812 },  /* 0x0d: 1280x800_2 (LVDS) (was: 1408,816/ 1656,841) */
1239         { 1, 1,1900,1066,1900,1066 },  /* 0x0e: 1680x1050 (LVDS) */
1240         { 1, 1,1660, 806,1660, 806 },  /* 0x0f: 1280x768_2 (LVDS) */
1241         { 1, 1,1664, 798,1664, 798 },  /* 0x10: 1280x768_3 (NetVista SiS 301) - TODO */
1242         { 1, 1,1688, 802,1688, 802 },  /* 0x11: 1280x768   (TMDS Fujitsu) */
1243         { 1, 1,1408, 806,1408, 806 },  /* 0x12: 1280x720 (LVDS) */
1244         { 1, 1, 896, 497, 896, 497 },  /* 0x13: 720x480 */
1245         { 1, 1, 912, 597, 912, 597 },  /* 0x14: 720x576 */
1246         { 1, 1, 912, 597, 912, 597 },  /* 0x15: 768x576 */
1247         { 1, 1,1056, 497,1056, 497 },  /* 0x16: 848x480 */
1248         { 1, 1,1064, 497,1064, 497 },  /* 0x17: 856x480 */
1249         { 1, 1,1056, 497,1056, 497 },  /* 0x18: 800x480 */
1250         { 1, 1,1328, 739,1328, 739 },  /* 0x19: 1024x576 */
1251         { 1, 1,1680, 892,1680, 892 },  /* 0x1a: 1152x864 */
1252         { 1, 1,1808, 808,1808, 808 },  /* 0x1b: 1360x768 */
1253         { 1, 1,1104, 563,1104, 563 },  /* 0x1c: 960x540 */
1254         { 1, 1,1120, 618,1120, 618 },  /* 0x1d: 960x600 */
1255         { 1, 1,1408, 816,1408, 816 },  /* 0x1f: 1280x800 (TMDS special) */
1256         { 1, 1,1760,1235,1760,1235 },  /* 0x20: 1600x1200 for LCDA */
1257         { 1, 1,2048,1320,2048,1320 },  /* 0x21: 1600x1200 for non-SiS LVDS */
1258         { 1, 1,1664, 861,1664, 861 }   /* 0x22: 1280x854 */
1259 };
1260
1261 /**************************************************************/
1262 /* LVDS ----------------------------------------------------- */
1263 /**************************************************************/
1264
1265 /* FSTN/DSTN 320x240, 2 variants */
1266 static const struct SiS_LVDSData SiS_LVDS320x240Data_1[]=
1267 {
1268         { 848, 433, 400, 525},
1269         { 848, 389, 400, 525},
1270         { 848, 433, 400, 525},
1271         { 848, 389, 400, 525},
1272         { 848, 518, 400, 525},
1273         {1056, 628, 400, 525},
1274         { 400, 525, 400, 525}  /* xSTN */
1275 };
1276
1277 static const struct SiS_LVDSData SiS_LVDS320x240Data_2[]=
1278 {
1279         { 800, 445, 800, 525},
1280         { 800, 395, 800, 525},
1281         { 800, 445, 800, 525},
1282         { 800, 395, 800, 525},
1283         { 800, 525, 800, 525},
1284         {1056, 628,1056, 628},
1285         { 480, 525, 480, 525} /* xSTN */
1286 };
1287
1288 static const struct SiS_LVDSData SiS_LVDS640x480Data_1[]=
1289 {
1290         { 800, 445, 800, 525},   /* 800, 449, 800, 449 */
1291         { 800, 395, 800, 525},
1292         { 800, 445, 800, 525},
1293         { 800, 395, 800, 525},
1294         { 800, 525, 800, 525}
1295 };
1296
1297 static const struct SiS_LVDSData SiS_LVDS800x600Data_1[]=
1298 {
1299         { 848, 433,1060, 629},
1300         { 848, 389,1060, 629},
1301         { 848, 433,1060, 629},
1302         { 848, 389,1060, 629},
1303         { 848, 518,1060, 629},
1304         {1056, 628,1056, 628}
1305 };
1306
1307 static const struct SiS_LVDSData SiS_LVDS1024x600Data_1[] =
1308 {
1309         { 840, 604,1344, 800},
1310         { 840, 560,1344, 800},
1311         { 840, 604,1344, 800},
1312         { 840, 560,1344, 800},
1313         { 840, 689,1344, 800},
1314         {1050, 800,1344, 800},
1315         {1344, 800,1344, 800}
1316 };
1317
1318 static const struct SiS_LVDSData SiS_LVDS1024x768Data_1[]=
1319 {
1320         { 840, 438,1344, 806},
1321         { 840, 409,1344, 806},
1322         { 840, 438,1344, 806},
1323         { 840, 409,1344, 806},
1324         { 840, 518,1344, 806},   /* 640x480 */
1325         {1050, 638,1344, 806},   /* 800x600 */
1326         {1344, 806,1344, 806},   /* 1024x768 */
1327 };
1328
1329 static const struct SiS_LVDSData SiS_CHTVUNTSCData[]=
1330 {
1331         { 840, 600, 840, 600},
1332         { 840, 600, 840, 600},
1333         { 840, 600, 840, 600},
1334         { 840, 600, 840, 600},
1335         { 784, 600, 784, 600},
1336         {1064, 750,1064, 750},
1337         {1160, 945,1160, 945}
1338 };
1339
1340 static const struct SiS_LVDSData SiS_CHTVONTSCData[]=
1341 {
1342         { 840, 525, 840, 525},
1343         { 840, 525, 840, 525},
1344         { 840, 525, 840, 525},
1345         { 840, 525, 840, 525},
1346         { 784, 525, 784, 525},
1347         {1040, 700,1040, 700},
1348         {1160, 840,1160, 840}
1349 };
1350
1351 /* CRT1 CRTC data for slave modes */
1352
1353 static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1320x240_1[] =
1354 {
1355  {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f,
1356    0x90,0x85,0x8f,0xab,0x30,0x00,0x05,
1357    0x00 }},
1358  {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
1359    0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
1360    0x00 }},
1361  {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f,
1362    0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
1363    0x00 }},
1364  {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
1365    0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
1366    0x00 }},
1367  {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e,
1368    0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05,
1369    0x00 }},
1370  {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
1371    0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
1372    0x01 }},
1373  {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
1374    0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
1375    0x00 }}
1376 };
1377
1378 static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1320x240_2[] =
1379 {
1380  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1381    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1382    0x00}},
1383  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1384    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1385    0x00}},
1386  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1387    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1388    0x00}},
1389  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1390    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1391    0x00}},
1392  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1393    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1394    0x00}},
1395  {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
1396    0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
1397    0x01}},
1398 #if 0
1399  {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
1400    0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
1401    0x00}}
1402 #endif
1403  {{0x5f,0x4f,0x83,0x55,0x81,0x0b,0x3e,
1404    0xe9,0x8b,0xe8,0x0c,0x00,0x00,0x05,
1405    0x00}},
1406 };
1407
1408 static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1320x240_2_H[] =
1409 {
1410  {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f,
1411    0x90,0x85,0x8f,0xab,0x30,0x00,0x05,
1412    0x00}},
1413  {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
1414    0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
1415    0x00}},
1416  {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f,
1417    0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
1418    0x00}},
1419  {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
1420    0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
1421    0x00}},
1422  {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e,
1423    0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05,
1424    0x00}},
1425  {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
1426    0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
1427    0x01}},
1428  {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
1429    0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
1430    0x00}}
1431 };
1432
1433 static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1320x240_3[] =
1434 {
1435  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1436    0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
1437    0x00}},
1438  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1439    0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
1440    0x00}},
1441  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1442    0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
1443    0x00}},
1444  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1445    0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
1446    0x00}},
1447  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1448    0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
1449    0x00}},
1450  {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
1451    0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
1452    0x01}},
1453  {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
1454    0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
1455    0x00}}
1456 };
1457
1458 static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1320x240_3_H[] =
1459 {
1460  {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f,
1461    0x90,0x85,0x8f,0xab,0x30,0x00,0x05,
1462    0x00}},
1463  {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
1464    0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
1465    0x00}},
1466  {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f,
1467    0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
1468    0x00}},
1469  {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
1470    0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
1471    0x00}},
1472  {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e,
1473    0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05,
1474    0x00}},
1475  {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
1476    0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
1477    0x01}},
1478  {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
1479    0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
1480    0x00}}
1481 };
1482
1483 static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1640x480_1[] =
1484 {
1485  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1486    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1487    0x00}},
1488  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1489    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1490    0x00}},
1491  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1492    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1493    0x00}},
1494  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1495    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1496    0x00}},
1497  {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
1498    0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
1499    0x00}},
1500  {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
1501    0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
1502    0x01}}
1503 };
1504
1505 static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1640x480_1_H[] =
1506 {
1507  {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
1508    0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00,
1509    0x00}},
1510  {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
1511    0x83,0x85,0x63,0xba,0x00,0x00,0x00,
1512    0x00}},
1513  {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
1514    0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00,
1515    0x00}},
1516  {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
1517    0x83,0x85,0x63,0xba,0x00,0x00,0x00,
1518    0x00}},
1519  {{0x2d,0x28,0x90,0x2c,0x80,0x0b,0x3e,
1520    0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
1521    0x00}}
1522 };
1523
1524 bool            SiSInitPtr(struct SiS_Private *SiS_Pr);
1525 #ifdef SIS_XORG_XF86
1526 unsigned short  SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay,
1527                                 int Depth, bool FSTN, int LCDwith, int LCDheight);
1528 #endif
1529 unsigned short  SiS_GetModeID_LCD(int VGAEngine, unsigned int VBFlags, int HDisplay,
1530                                 int VDisplay, int Depth, bool FSTN,
1531                                 unsigned short CustomT, int LCDwith, int LCDheight,
1532                                 unsigned int VBFlags2);
1533 unsigned short  SiS_GetModeID_TV(int VGAEngine, unsigned int VBFlags, int HDisplay,
1534                                 int VDisplay, int Depth, unsigned int VBFlags2);
1535 unsigned short  SiS_GetModeID_VGA2(int VGAEngine, unsigned int VBFlags, int HDisplay,
1536                                 int VDisplay, int Depth, unsigned int VBFlags2);
1537
1538 void            SiS_SetReg(SISIOADDRESS port, unsigned short index, unsigned short data);
1539 void            SiS_SetRegByte(SISIOADDRESS port, unsigned short data);
1540 void            SiS_SetRegShort(SISIOADDRESS port, unsigned short data);
1541 void            SiS_SetRegLong(SISIOADDRESS port, unsigned int data);
1542 unsigned char   SiS_GetReg(SISIOADDRESS port, unsigned short index);
1543 unsigned char   SiS_GetRegByte(SISIOADDRESS port);
1544 unsigned short  SiS_GetRegShort(SISIOADDRESS port);
1545 unsigned int    SiS_GetRegLong(SISIOADDRESS port);
1546 void            SiS_SetRegANDOR(SISIOADDRESS Port, unsigned short Index, unsigned short DataAND,
1547                                 unsigned short DataOR);
1548 void            SiS_SetRegAND(SISIOADDRESS Port,unsigned short Index, unsigned short DataAND);
1549 void            SiS_SetRegOR(SISIOADDRESS Port,unsigned short Index, unsigned short DataOR);
1550
1551 void            SiS_DisplayOn(struct SiS_Private *SiS_Pr);
1552 void            SiS_DisplayOff(struct SiS_Private *SiS_Pr);
1553 void            SiSRegInit(struct SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr);
1554 #ifndef SIS_LINUX_KERNEL
1555 void            SiSSetLVDSetc(struct SiS_Private *SiS_Pr);
1556 #endif
1557 void            SiS_SetEnableDstn(struct SiS_Private *SiS_Pr, int enable);
1558 void            SiS_SetEnableFstn(struct SiS_Private *SiS_Pr, int enable);
1559 unsigned short  SiS_GetModeFlag(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1560                                 unsigned short ModeIdIndex);
1561 bool            SiSDetermineROMLayout661(struct SiS_Private *SiS_Pr);
1562 #ifndef SIS_LINUX_KERNEL
1563 void            SiS_GetVBType(struct SiS_Private *SiS_Pr);
1564 #endif
1565
1566 bool            SiS_SearchModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo,
1567                                 unsigned short *ModeIdIndex);
1568 unsigned short  SiS_GetModePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1569                                 unsigned short ModeIdIndex);
1570 unsigned short  SiS_GetRefCRTVCLK(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide);
1571 unsigned short  SiS_GetRefCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide);
1572 unsigned short  SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1573                                 unsigned short ModeIdIndex);
1574 unsigned short  SiS_GetOffset(struct SiS_Private *SiS_Pr,unsigned short ModeNo,
1575                                 unsigned short ModeIdIndex, unsigned short RRTI);
1576 #ifdef SIS300
1577 void            SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *idx1,
1578                                 unsigned short *idx2);
1579 unsigned short  SiS_GetFIFOThresholdB300(unsigned short idx1, unsigned short idx2);
1580 unsigned short  SiS_GetLatencyFactor630(struct SiS_Private *SiS_Pr, unsigned short index);
1581 #endif
1582 void            SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex);
1583 #ifdef SIS_XORG_XF86
1584 bool            SiSSetMode(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, unsigned short ModeNo,
1585                                 bool dosetpitch);
1586 bool            SiSBIOSSetMode(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn,
1587                                 DisplayModePtr mode, bool IsCustom);
1588 bool            SiSBIOSSetModeCRT2(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn,
1589                                 DisplayModePtr mode, bool IsCustom);
1590 bool            SiSBIOSSetModeCRT1(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn,
1591                                 DisplayModePtr mode, bool IsCustom);
1592 #endif
1593 #ifdef SIS_LINUX_KERNEL
1594 bool            SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo);
1595 #endif
1596 void            SiS_CalcCRRegisters(struct SiS_Private *SiS_Pr, int depth);
1597 void            SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1598                                 unsigned short ModeIdIndex);
1599 #ifdef SIS_XORG_XF86
1600 void            SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, int xres,
1601                                 int yres, DisplayModePtr current);
1602 #endif
1603 #ifdef SIS_LINUX_KERNEL
1604 void            SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, int xres,
1605                                 int yres, struct fb_var_screeninfo *var, bool writeres);
1606 #endif
1607
1608 /* From init301.c: */
1609 extern void             SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1610                                 unsigned short ModeIdIndex, int chkcrt2mode);
1611 extern void             SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1612                                 unsigned short ModeIdIndex);
1613 extern void             SiS_SetYPbPr(struct SiS_Private *SiS_Pr);
1614 extern void             SiS_SetTVMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1615                                 unsigned short ModeIdIndex);
1616 extern void             SiS_UnLockCRT2(struct SiS_Private *SiS_Pr);
1617 extern void             SiS_DisableBridge(struct SiS_Private *);
1618 extern bool             SiS_SetCRT2Group(struct SiS_Private *, unsigned short);
1619 extern unsigned short   SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1620                                 unsigned short ModeIdIndex);
1621 extern void             SiS_WaitRetrace1(struct SiS_Private *SiS_Pr);
1622 extern unsigned short   SiS_GetResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1623                                 unsigned short ModeIdIndex);
1624 extern unsigned short   SiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short tempax);
1625 extern unsigned short   SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1626                                 unsigned short ModeIdIndex, unsigned short RRTI);
1627 extern bool             SiS_IsVAMode(struct SiS_Private *);
1628 extern bool             SiS_IsDualEdge(struct SiS_Private *);
1629
1630 #ifdef SIS_XORG_XF86
1631 /* From other modules: */
1632 extern unsigned short   SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode,
1633                                 unsigned int VBFlags);
1634 extern unsigned char    SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, unsigned short offset,
1635                                 unsigned char value);
1636 extern unsigned char    SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id);
1637 extern unsigned short   SiS_GetModeNumber(ScrnInfoPtr pScrn, DisplayModePtr mode,
1638                                 unsigned int VBFlags);
1639 #endif
1640
1641 #ifdef SIS_LINUX_KERNEL
1642 #ifdef SIS300
1643 extern unsigned int     sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg);
1644 extern void             sisfb_write_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg,
1645                                 unsigned int val);
1646 #endif
1647 #ifdef SIS315H
1648 extern void             sisfb_write_nbridge_pci_byte(struct SiS_Private *SiS_Pr, int reg,
1649                                 unsigned char val);
1650 extern unsigned int     sisfb_read_mio_pci_word(struct SiS_Private *SiS_Pr, int reg);
1651 #endif
1652 #endif
1653
1654 #endif
1655