Merge ../torvalds-2.6/
[pandora-kernel.git] / drivers / video / sis / init301.h
1 /* $XFree86$ */
2 /* $XdotOrg$ */
3 /*
4  * Data and prototypes for init301.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  _INIT301_H_
54 #define  _INIT301_H_
55
56 #include "osdef.h"
57 #include "initdef.h"
58
59 #ifdef SIS_XORG_XF86
60 #include "sis.h"
61 #include "sis_regs.h"
62 #endif
63
64 #ifdef SIS_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 <video/fbcon.h>
77 #endif
78 #include "sis.h"
79 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
80 #include <linux/sisfb.h>
81 #else
82 #include <video/sisfb.h>
83 #endif
84 #endif
85
86 static const unsigned char SiS_YPbPrTable[3][64] = {
87   {
88     0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c,
89     0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a,
90     0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b,
91     0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17,
92     0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02,
93     0x03,0x0a,0x65,0x9d /*0x8d*/,0x08,0x92,0x8f,0x40,
94     0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x53 /*0x50*/,
95     0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00
96   },
97   {
98     0x33,0x06,0x06,0x09,0x0b,0x0c,0x0c,0x0c,
99     0x98,0x0a,0x01,0x0d,0x06,0x0d,0x04,0x0a,
100     0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
101     0x0c,0x50,0xb2,0x9f,0x16,0x59,0x4f,0x13,
102     0xad,0x11,0xad,0x1d,0x40,0x8a,0x3d,0xb8,
103     0x51,0x5e,0x60,0x49,0x7d,0x92,0x0f,0x40,
104     0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x4e,
105     0x43,0x41,0x11,0x00,0xfc,0xff,0x32,0x00
106   },
107   {
108 #if 0 /* OK, but sticks to left edge */
109     0x13,0x1d,0xe8,0x09,0x09,0xed,0x0c,0x0c,
110     0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a,
111     0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
112     0xed,0x50,0x70,0x9f,0x16,0x59,0x21 /*0x2b*/,0x13,
113     0x27,0x0b,0x27,0xfc,0x30,0x27,0x1c,0xb0,
114     0x4b,0x4b,0x65 /*0x6f*/,0x2f,0x63,0x92,0x0f,0x40,
115     0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x27,
116     0x00,0x40,0x11,0x00,0xfc,0xff,0x32,0x00
117 #endif
118 #if 1 /* Perfect */
119     0x23,0x2d,0xe8,0x09,0x09,0xed,0x0c,0x0c,
120     0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a,
121     0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
122     0xed,0x50,0x70,0x9f,0x16,0x59,0x60,0x13,
123     0x27,0x0b,0x27,0xfc,0x30,0x27,0x1c,0xb0,
124     0x4b,0x4b,0x6f,0x2f,0x63,0x92,0x0f,0x40,
125     0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x73,
126     0x00,0x40,0x11,0x00,0xfc,0xff,0x32,0x00
127 #endif
128   }
129 };
130
131 static const unsigned char SiS_TVPhase[] =
132 {
133         0x21,0xED,0xBA,0x08,    /* 0x00 SiS_NTSCPhase */
134         0x2A,0x05,0xE3,0x00,    /* 0x01 SiS_PALPhase */
135         0x21,0xE4,0x2E,0x9B,    /* 0x02 SiS_PALMPhase */
136         0x21,0xF4,0x3E,0xBA,    /* 0x03 SiS_PALNPhase */
137         0x1E,0x8B,0xA2,0xA7,
138         0x1E,0x83,0x0A,0xE0,    /* 0x05 SiS_SpecialPhaseM */
139         0x00,0x00,0x00,0x00,
140         0x00,0x00,0x00,0x00,
141         0x21,0xF0,0x7B,0xD6,    /* 0x08 SiS_NTSCPhase2 */
142         0x2A,0x09,0x86,0xE9,    /* 0x09 SiS_PALPhase2 */
143         0x21,0xE6,0xEF,0xA4,    /* 0x0a SiS_PALMPhase2 */
144         0x21,0xF6,0x94,0x46,    /* 0x0b SiS_PALNPhase2 */
145         0x1E,0x8B,0xA2,0xA7,
146         0x1E,0x83,0x0A,0xE0,    /* 0x0d SiS_SpecialPhaseM */
147         0x00,0x00,0x00,0x00,
148         0x00,0x00,0x00,0x00,
149         0x1e,0x8c,0x5c,0x7a,    /* 0x10 SiS_SpecialPhase */
150         0x25,0xd4,0xfd,0x5e     /* 0x11 SiS_SpecialPhaseJ */
151 };
152
153 static const unsigned char SiS_HiTVGroup3_1[] = {
154     0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x13,
155     0xb1, 0x41, 0x62, 0x62, 0xff, 0xf4, 0x45, 0xa6,
156     0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20,
157     0xac, 0xda, 0x60, 0xfe, 0x6a, 0x9a, 0x06, 0x10,
158     0xd1, 0x04, 0x18, 0x0a, 0xff, 0x80, 0x00, 0x80,
159     0x3b, 0x77, 0x00, 0xef, 0xe0, 0x10, 0xb0, 0xe0,
160     0x10, 0x4f, 0x0f, 0x0f, 0x05, 0x0f, 0x08, 0x6e,
161     0x1a, 0x1f, 0x25, 0x2a, 0x4c, 0xaa, 0x01
162 };
163
164 static const unsigned char SiS_HiTVGroup3_2[] = {
165     0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x7a,
166     0x54, 0x41, 0xe7, 0xe7, 0xff, 0xf4, 0x45, 0xa6,
167     0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20,
168     0xac, 0x6a, 0x60, 0x2b, 0x52, 0xcd, 0x61, 0x10,
169     0x51, 0x04, 0x18, 0x0a, 0x1f, 0x80, 0x00, 0x80,
170     0xff, 0xa4, 0x04, 0x2b, 0x94, 0x21, 0x72, 0x94,
171     0x26, 0x05, 0x01, 0x0f, 0xed, 0x0f, 0x0a, 0x64,
172     0x18, 0x1d, 0x23, 0x28, 0x4c, 0xaa, 0x01
173 };
174
175 /* 301C / 302ELV extended Part2 TV registers (4 tap scaler) */
176
177 static const unsigned char SiS_Part2CLVX_1[] = {
178     0x00,0x00,
179     0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E,
180     0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C,
181     0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C,
182     0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E
183 };
184
185 static const unsigned char SiS_Part2CLVX_2[] = {
186     0x00,0x00,
187     0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E,
188     0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C,
189     0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C,
190     0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E
191 };
192
193 static const unsigned char SiS_Part2CLVX_3[] = {  /* NTSC, 525i, 525p */
194     0xE0,0x01,
195     0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D,0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D,
196     0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C,0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C,
197     0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E,
198     0x7D,0x0C,0x19,0x7E,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02,
199     0x58,0x02,
200     0x07,0x14,0x07,0x7E,0x06,0x14,0x09,0x7D,0x05,0x14,0x0A,0x7D,0x04,0x13,0x0B,0x7E,
201     0x03,0x13,0x0C,0x7E,0x02,0x12,0x0D,0x7F,0x01,0x12,0x0E,0x7F,0x01,0x11,0x0F,0x7F,
202     0x00,0x10,0x10,0x00,0x7F,0x0F,0x11,0x01,0x7F,0x0E,0x12,0x01,0x7E,0x0D,0x12,0x03,
203     0x7E,0x0C,0x13,0x03,0x7E,0x0B,0x13,0x04,0x7E,0x0A,0x14,0x04,0x7D,0x09,0x14,0x06,
204     0x00,0x03,
205     0x09,0x0F,0x09,0x7F,0x08,0x0F,0x09,0x00,0x07,0x0F,0x0A,0x00,0x06,0x0F,0x0A,0x01,
206     0x06,0x0E,0x0B,0x01,0x05,0x0E,0x0B,0x02,0x04,0x0E,0x0C,0x02,0x04,0x0D,0x0C,0x03,
207     0x03,0x0D,0x0D,0x03,0x02,0x0C,0x0D,0x05,0x02,0x0C,0x0E,0x04,0x01,0x0B,0x0E,0x06,
208     0x01,0x0B,0x0E,0x06,0x00,0x0A,0x0F,0x07,0x00,0x0A,0x0F,0x07,0x00,0x09,0x0F,0x08,
209     0xFF,0xFF
210 };
211
212 static const unsigned char SiS_Part2CLVX_4[] = {   /* PAL */
213     0x58,0x02,
214     0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D,
215     0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D,
216     0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E,
217     0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04,
218     0x00,0x03,
219     0x08,0x12,0x08,0x7E,0x07,0x12,0x09,0x7E,0x06,0x12,0x0A,0x7E,0x05,0x11,0x0B,0x7F,
220     0x04,0x11,0x0C,0x7F,0x03,0x11,0x0C,0x00,0x03,0x10,0x0D,0x00,0x02,0x0F,0x0E,0x01,
221     0x01,0x0F,0x0F,0x01,0x01,0x0E,0x0F,0x02,0x00,0x0D,0x10,0x03,0x7F,0x0C,0x11,0x04,
222     0x7F,0x0C,0x11,0x04,0x7F,0x0B,0x11,0x05,0x7E,0x0A,0x12,0x06,0x7E,0x09,0x12,0x07,
223     0x40,0x02,
224     0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E,0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D,
225     0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C,
226     0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x18,0x7F,
227     0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1B,0x02,
228     0xFF,0xFF
229 };
230
231 static const unsigned char SiS_Part2CLVX_5[] = {   /* 750p */
232     0x00,0x03,
233     0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D,
234     0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D,
235     0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E,
236     0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04,
237     0xFF,0xFF
238 };
239
240 static const unsigned char SiS_Part2CLVX_6[] = {   /* 1080i */
241     0x00,0x04,
242     0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E,0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D,
243     0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C,
244     0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x18,0x7F,
245     0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1B,0x02,
246     0xFF,0xFF,
247 };
248
249 #ifdef SIS315H
250 /* 661 et al LCD data structure (2.03.00) */
251 static const unsigned char SiS_LCDStruct661[] = {
252     /* 1024x768 */
253 /*  type|CR37|   HDE   |   VDE   |    HT   |    VT   |   hss    | hse   */
254     0x02,0xC0,0x00,0x04,0x00,0x03,0x40,0x05,0x26,0x03,0x10,0x00,0x88,
255     0x00,0x02,0x00,0x06,0x00,0x41,0x5A,0x64,0x00,0x00,0x00,0x00,0x04,
256     /*  | vss     |    vse  |clck|  clock  |CRT2DataP|CRT2DataP|idx     */
257     /*                                        VESA    non-VESA  noscale */
258     /* 1280x1024 */
259     0x03,0xC0,0x00,0x05,0x00,0x04,0x98,0x06,0x2A,0x04,0x30,0x00,0x70,
260     0x00,0x01,0x00,0x03,0x00,0x6C,0xF8,0x2F,0x00,0x00,0x00,0x00,0x08,
261     /* 1400x1050 */
262     0x09,0x20,0x78,0x05,0x1A,0x04,0x98,0x06,0x2A,0x04,0x18,0x00,0x38,
263     0x00,0x01,0x00,0x03,0x00,0x6C,0xF8,0x2F,0x00,0x00,0x00,0x00,0x09,
264     /* 1600x1200 */
265     0x0B,0xE0,0x40,0x06,0xB0,0x04,0x70,0x08,0xE2,0x04,0x40,0x00,0xC0,
266     0x00,0x01,0x00,0x03,0x00,0xA2,0x70,0x24,0x00,0x00,0x00,0x00,0x0A,
267     /* 1280x768 (_2) */
268     0x0A,0xE0,0x00,0x05,0x00,0x03,0x7C,0x06,0x26,0x03,0x30,0x00,0x70,
269     0x00,0x03,0x00,0x06,0x00,0x4D,0xC8,0x48,0x00,0x00,0x00,0x00,0x06,
270     /* 1280x720 */
271     0x0E,0xE0,0x00,0x05,0xD0,0x02,0x80,0x05,0x26,0x03,0x10,0x00,0x20,
272     0x00,0x01,0x00,0x06,0x00,0x45,0x9C,0x62,0x00,0x00,0x00,0x00,0x05,
273     /* 1280x800 (_2) */
274     0x0C,0xE0,0x00,0x05,0x20,0x03,0x10,0x06,0x2C,0x03,0x30,0x00,0x70,
275     0x00,0x04,0x00,0x03,0x00,0x49,0xCE,0x1E,0x00,0x00,0x00,0x00,0x09,
276     /* 1680x1050 */
277     0x0D,0xE0,0x90,0x06,0x1A,0x04,0x6C,0x07,0x2A,0x04,0x1A,0x00,0x4C,
278     0x00,0x03,0x00,0x06,0x00,0x79,0xBE,0x44,0x00,0x00,0x00,0x00,0x06,
279     /* 1280x800_3 */
280     0x0C,0xE0,0x00,0x05,0x20,0x03,0xAA,0x05,0x2E,0x03,0x30,0x00,0x50,
281     0x00,0x04,0x00,0x03,0x00,0x47,0xA9,0x10,0x00,0x00,0x00,0x00,0x07,
282     /* 800x600 */
283     0x01,0xC0,0x20,0x03,0x58,0x02,0x20,0x04,0x74,0x02,0x2A,0x00,0x80,
284     0x00,0x06,0x00,0x04,0x00,0x28,0x63,0x4B,0x00,0x00,0x00,0x00,0x00,
285     /* 1280x854 */
286     0x08,0xE0,0x00,0x05,0x56,0x03,0x80,0x06,0x5d,0x03,0x10,0x00,0x70,
287     0x00,0x01,0x00,0x03,0x00,0x54,0x75,0x13,0x00,0x00,0x00,0x00,0x08
288 };
289 #endif
290
291 #ifdef SIS300
292 static unsigned char SiS300_TrumpionData[14][80] = {
293   { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02,
294     0x20,0x03,0x0B,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x10,0x00,0x00,0x04,0x23,
295     0x00,0x00,0x03,0x28,0x03,0x10,0x05,0x08,0x40,0x10,0x00,0x10,0x04,0x23,0x00,0x23,
296     0x03,0x11,0x60,0xBC,0x01,0xFF,0x03,0xFF,0x19,0x01,0x00,0x05,0x09,0x04,0x04,0x05,
297     0x04,0x0C,0x09,0x05,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5A,0x01,0xBE,0x01,0x00 },
298   { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x27,0x00,0x80,0x02,
299     0x20,0x03,0x07,0x00,0x5E,0x01,0x0D,0x02,0x60,0x0C,0x30,0x11,0x00,0x00,0x04,0x23,
300     0x00,0x00,0x03,0x80,0x03,0x28,0x06,0x08,0x40,0x11,0x00,0x11,0x04,0x23,0x00,0x23,
301     0x03,0x11,0x60,0x90,0x01,0xFF,0x0F,0xF4,0x19,0x01,0x00,0x05,0x01,0x00,0x04,0x05,
302     0x04,0x0C,0x02,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEC,0x57,0x01,0xBE,0x01,0x00 },
303   { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x8A,0x00,0xD8,0x02,
304     0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23,
305     0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23,
306     0x03,0x11,0x60,0xD9,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05,
307     0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x59,0x01,0xBE,0x01,0x00 },
308   { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x72,0x00,0xD8,0x02,
309     0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23,
310     0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23,
311     0x03,0x11,0x60,0xDA,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05,
312     0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 },
313   { 0x02,0x0A,0x02,0x00,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02,
314     0x20,0x03,0x16,0x00,0xE0,0x01,0x0D,0x02,0x60,0x0C,0x30,0x98,0x00,0x00,0x04,0x23,
315     0x00,0x01,0x03,0x45,0x03,0x48,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x23,0x00,0x23,
316     0x03,0x11,0x60,0xF4,0x01,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x05,0x01,0x00,0x05,0x05,
317     0x04,0x0C,0x08,0x05,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 },
318   { 0x02,0x0A,0x02,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0xBF,0x00,0x20,0x03,
319     0x20,0x04,0x0D,0x00,0x58,0x02,0x71,0x02,0x80,0x0C,0x30,0x9A,0x00,0xFA,0x03,0x1D,
320     0x00,0x01,0x03,0x22,0x03,0x28,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x1D,0x00,0x1D,
321     0x03,0x11,0x60,0x39,0x03,0x40,0x05,0xF4,0x18,0x07,0x02,0x06,0x04,0x01,0x06,0x0B,
322     0x02,0x0A,0x20,0x19,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 },
323   { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0xEF,0x00,0x00,0x04,
324     0x40,0x05,0x13,0x00,0x00,0x03,0x26,0x03,0x88,0x0C,0x30,0x90,0x00,0x00,0x04,0x23,
325     0x00,0x01,0x03,0x24,0x03,0x28,0x06,0x08,0x40,0x90,0x00,0x90,0x04,0x23,0x00,0x23,
326     0x03,0x11,0x60,0x40,0x05,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x08,0x01,0x00,0x08,0x01,
327     0x00,0x08,0x01,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 },
328   /* variant 2 */
329   { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02,
330     0x20,0x03,0x15,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x18,0x00,0x00,0x04,0x23,
331     0x00,0x01,0x03,0x44,0x03,0x28,0x06,0x08,0x40,0x18,0x00,0x18,0x04,0x23,0x00,0x23,
332     0x03,0x11,0x60,0xA6,0x01,0xFF,0x03,0xFF,0x19,0x01,0x00,0x05,0x13,0x04,0x04,0x05,
333     0x04,0x0C,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 },
334   { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02,
335     0x20,0x03,0x15,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x18,0x00,0x00,0x04,0x23,
336     0x00,0x01,0x03,0x44,0x03,0x28,0x06,0x08,0x40,0x18,0x00,0x18,0x04,0x23,0x00,0x23,
337     0x03,0x11,0x60,0xA6,0x01,0xFF,0x03,0xFF,0x19,0x01,0x00,0x05,0x13,0x04,0x04,0x05,
338     0x04,0x0C,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 },
339   { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x8A,0x00,0xD8,0x02,
340     0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23,
341     0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23,
342     0x03,0x11,0x60,0xDA,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05,
343     0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 },
344   { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x72,0x00,0xD8,0x02,
345     0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23,
346     0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23,
347     0x03,0x11,0x60,0xDA,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05,
348     0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 },
349   { 0x02,0x0A,0x02,0x00,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02,
350     0x20,0x03,0x16,0x00,0xE0,0x01,0x0D,0x02,0x60,0x0C,0x30,0x98,0x00,0x00,0x04,0x23,
351     0x00,0x01,0x03,0x45,0x03,0x48,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x23,0x00,0x23,
352     0x03,0x11,0x60,0xF4,0x01,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x05,0x01,0x00,0x05,0x05,
353     0x04,0x0C,0x08,0x05,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEA,0x58,0x01,0xBE,0x01,0x00 },
354   { 0x02,0x0A,0x02,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0xBF,0x00,0x20,0x03,
355     0x20,0x04,0x0D,0x00,0x58,0x02,0x71,0x02,0x80,0x0C,0x30,0x9A,0x00,0xFA,0x03,0x1D,
356     0x00,0x01,0x03,0x22,0x03,0x28,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x1D,0x00,0x1D,
357     0x03,0x11,0x60,0x39,0x03,0x40,0x05,0xF4,0x18,0x07,0x02,0x06,0x04,0x01,0x06,0x0B,
358     0x02,0x0A,0x20,0x19,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEA,0x58,0x01,0xBE,0x01,0x00 },
359   { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0xEF,0x00,0x00,0x04,
360     0x40,0x05,0x13,0x00,0x00,0x03,0x26,0x03,0x88,0x0C,0x30,0x90,0x00,0x00,0x04,0x23,
361     0x00,0x01,0x03,0x24,0x03,0x28,0x06,0x08,0x40,0x90,0x00,0x90,0x04,0x23,0x00,0x23,
362     0x03,0x11,0x60,0x40,0x05,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x08,0x01,0x00,0x08,0x01,
363     0x00,0x08,0x01,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEA,0x58,0x01,0xBE,0x01,0x00 }
364 };
365 #endif
366
367 void            SiS_UnLockCRT2(struct SiS_Private *SiS_Pr);
368 #ifndef SIS_LINUX_KERNEL
369 void            SiS_LockCRT2(struct SiS_Private *SiS_Pr);
370 #endif
371 void            SiS_EnableCRT2(struct SiS_Private *SiS_Pr);
372 unsigned short  SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex);
373 void            SiS_WaitRetrace1(struct SiS_Private *SiS_Pr);
374 BOOLEAN         SiS_IsDualEdge(struct SiS_Private *SiS_Pr);
375 BOOLEAN         SiS_IsVAMode(struct SiS_Private *SiS_Pr);
376 void            SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
377                         unsigned short ModeIdIndex, int checkcrt2mode);
378 void            SiS_SetYPbPr(struct SiS_Private *SiS_Pr);
379 void            SiS_SetTVMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
380                         unsigned short ModeIdIndex);
381 void            SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
382                 unsigned short ModeIdIndex);
383 unsigned short  SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
384                         unsigned short RefreshRateTableIndex);
385 unsigned short  SiS_GetResInfo(struct SiS_Private *SiS_Pr,unsigned short ModeNo,unsigned short ModeIdIndex);
386 void            SiS_DisableBridge(struct SiS_Private *SiS_Pr);
387 #ifndef SIS_LINUX_KERNEL
388 void            SiS_EnableBridge(struct SiS_Private *SiS_Pr);
389 #endif
390 BOOLEAN         SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo);
391 void            SiS_SiS30xBLOn(struct SiS_Private *SiS_Pr);
392 void            SiS_SiS30xBLOff(struct SiS_Private *SiS_Pr);
393
394 void            SiS_SetCH700x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val);
395 unsigned short  SiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short tempax);
396 void            SiS_SetCH701x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val);
397 unsigned short  SiS_GetCH701x(struct SiS_Private *SiS_Pr, unsigned short tempax);
398 #ifndef SIS_LINUX_KERNEL
399 void            SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val);
400 unsigned short  SiS_GetCH70xx(struct SiS_Private *SiS_Pr, unsigned short tempax);
401 #endif
402 void            SiS_SetCH70xxANDOR(struct SiS_Private *SiS_Pr, unsigned short reg,
403                         unsigned char orval,unsigned short andval);
404 #ifdef SIS315H
405 static void     SiS_Chrontel701xOn(struct SiS_Private *SiS_Pr);
406 static void     SiS_Chrontel701xOff(struct SiS_Private *SiS_Pr);
407 static void     SiS_ChrontelInitTVVSync(struct SiS_Private *SiS_Pr);
408 static void     SiS_ChrontelDoSomething1(struct SiS_Private *SiS_Pr);
409 void            SiS_Chrontel701xBLOn(struct SiS_Private *SiS_Pr);
410 void            SiS_Chrontel701xBLOff(struct SiS_Private *SiS_Pr);
411 #endif /* 315 */
412
413 #ifdef SIS300
414 static  BOOLEAN SiS_SetTrumpionBlock(struct SiS_Private *SiS_Pr, unsigned char *dataptr);
415 void            SiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo);
416 #endif
417
418 void            SiS_DDC2Delay(struct SiS_Private *SiS_Pr, unsigned int delaytime);
419 unsigned short  SiS_ReadDDC1Bit(struct SiS_Private *SiS_Pr);
420 unsigned short  SiS_HandleDDC(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine,
421                         unsigned short adaptnum, unsigned short DDCdatatype,
422                         unsigned char *buffer, unsigned int VBFlags2);
423
424 #ifdef SIS_XORG_XF86
425 unsigned short          SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags,
426                                 int VGAEngine, unsigned short adaptnum, unsigned short DDCdatatype,
427                                 BOOLEAN checkcr32, unsigned int VBFlags2);
428 unsigned short          SiS_ProbeDDC(struct SiS_Private *SiS_Pr);
429 unsigned short          SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype,
430                                 unsigned char *buffer);
431 #else
432 static unsigned short   SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags,
433                                 int VGAEngine, unsigned short adaptnum, unsigned short DDCdatatype,
434                                 BOOLEAN checkcr32, unsigned int VBFlags2);
435 static unsigned short   SiS_ProbeDDC(struct SiS_Private *SiS_Pr);
436 static unsigned short   SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype,
437                                 unsigned char *buffer);
438 #endif
439 static void             SiS_SetSwitchDDC2(struct SiS_Private *SiS_Pr);
440 static unsigned short   SiS_SetStart(struct SiS_Private *SiS_Pr);
441 static unsigned short   SiS_SetStop(struct SiS_Private *SiS_Pr);
442 static unsigned short   SiS_SetSCLKLow(struct SiS_Private *SiS_Pr);
443 static unsigned short   SiS_SetSCLKHigh(struct SiS_Private *SiS_Pr);
444 static unsigned short   SiS_ReadDDC2Data(struct SiS_Private *SiS_Pr);
445 static unsigned short   SiS_WriteDDC2Data(struct SiS_Private *SiS_Pr, unsigned short tempax);
446 static unsigned short   SiS_CheckACK(struct SiS_Private *SiS_Pr);
447 static unsigned short   SiS_WriteDABDDC(struct SiS_Private *SiS_Pr);
448 static unsigned short   SiS_PrepareReadDDC(struct SiS_Private *SiS_Pr);
449 static unsigned short   SiS_PrepareDDC(struct SiS_Private *SiS_Pr);
450 static void             SiS_SendACK(struct SiS_Private *SiS_Pr, unsigned short yesno);
451 static unsigned short   SiS_DoProbeDDC(struct SiS_Private *SiS_Pr);
452
453 #ifdef SIS300
454 static void             SiS_OEM300Setting(struct SiS_Private *SiS_Pr,
455                                 unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefTabindex);
456 static void             SetOEMLCDData2(struct SiS_Private *SiS_Pr,
457                                 unsigned short ModeNo, unsigned short ModeIdIndex,unsigned short RefTableIndex);
458 #endif
459 #ifdef SIS315H
460 static void             SiS_OEM310Setting(struct SiS_Private *SiS_Pr,
461                                 unsigned short ModeNo,unsigned short ModeIdIndex, unsigned short RRTI);
462 static void             SiS_OEM661Setting(struct SiS_Private *SiS_Pr,
463                                 unsigned short ModeNo,unsigned short ModeIdIndex, unsigned short RRTI);
464 static void             SiS_FinalizeLCD(struct SiS_Private *, unsigned short, unsigned short);
465 #endif
466
467 extern void             SiS_SetReg(SISIOADDRESS, unsigned short, unsigned short);
468 extern void             SiS_SetRegByte(SISIOADDRESS, unsigned short);
469 extern void             SiS_SetRegShort(SISIOADDRESS, unsigned short);
470 extern void             SiS_SetRegLong(SISIOADDRESS, unsigned int);
471 extern unsigned char    SiS_GetReg(SISIOADDRESS, unsigned short);
472 extern unsigned char    SiS_GetRegByte(SISIOADDRESS);
473 extern unsigned short   SiS_GetRegShort(SISIOADDRESS);
474 extern unsigned int     SiS_GetRegLong(SISIOADDRESS);
475 extern void             SiS_SetRegANDOR(SISIOADDRESS, unsigned short, unsigned short, unsigned short);
476 extern void             SiS_SetRegOR(SISIOADDRESS, unsigned short, unsigned short);
477 extern void             SiS_SetRegAND(SISIOADDRESS, unsigned short, unsigned short);
478 extern void             SiS_DisplayOff(struct SiS_Private *SiS_Pr);
479 extern void             SiS_DisplayOn(struct SiS_Private *SiS_Pr);
480 extern BOOLEAN          SiS_SearchModeID(struct SiS_Private *, unsigned short *, unsigned short *);
481 extern unsigned short   SiS_GetModeFlag(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
482                                 unsigned short ModeIdIndex);
483 extern unsigned short   SiS_GetModePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex);
484 extern unsigned short   SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex);
485 extern unsigned short   SiS_GetOffset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
486                                 unsigned short RefreshRateTableIndex);
487 extern void             SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
488                                 unsigned short ModeIdIndex);
489 extern void             SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
490                                 unsigned short ModeIdIndex);
491 extern void             SiS_CalcCRRegisters(struct SiS_Private *SiS_Pr, int depth);
492 extern unsigned short   SiS_GetRefCRTVCLK(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide);
493 extern unsigned short   SiS_GetRefCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide);
494 #ifdef SIS300
495 extern void             SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *tempbx,
496                                 unsigned short *tempcl);
497 extern unsigned short   SiS_GetFIFOThresholdB300(unsigned short tempbx, unsigned short tempcl);
498 extern unsigned short   SiS_GetLatencyFactor630(struct SiS_Private *SiS_Pr, unsigned short index);
499 #ifdef SIS_LINUX_KERNEL
500 extern unsigned int     sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg);
501 extern unsigned int     sisfb_read_lpc_pci_dword(struct SiS_Private *SiS_Pr, int reg);
502 #endif
503 #endif
504
505 #endif