1/*
2 * Data and prototypes for init301.c
3 *
4 * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria
5 *
6 * If distributed as part of the Linux kernel, the following license terms
7 * apply:
8 *
9 * * This program is free software; you can redistribute it and/or modify
10 * * it under the terms of the GNU General Public License as published by
11 * * the Free Software Foundation; either version 2 of the named License,
12 * * or any later version.
13 * *
14 * * This program is distributed in the hope that it will be useful,
15 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * * GNU General Public License for more details.
18 * *
19 * * You should have received a copy of the GNU General Public License
20 * * along with this program; if not, write to the Free Software
21 * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
22 *
23 * Otherwise, the following license terms apply:
24 *
25 * * Redistribution and use in source and binary forms, with or without
26 * * modification, are permitted provided that the following conditions
27 * * are met:
28 * * 1) Redistributions of source code must retain the above copyright
29 * *    notice, this list of conditions and the following disclaimer.
30 * * 2) Redistributions in binary form must reproduce the above copyright
31 * *    notice, this list of conditions and the following disclaimer in the
32 * *    documentation and/or other materials provided with the distribution.
33 * * 3) The name of the author may not be used to endorse or promote products
34 * *    derived from this software without specific prior written permission.
35 * *
36 * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
37 * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38 * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
39 * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
40 * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
45 * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 *
47 * Author: 	Thomas Winischhofer <thomas@winischhofer.net>
48 *
49 */
50
51#ifndef  _INIT301_H_
52#define  _INIT301_H_
53
54#include "osdef.h"
55#include "initdef.h"
56
57#ifdef SIS_XORG_XF86
58#include "sis.h"
59#include "sis_regs.h"
60#endif
61
62#ifdef SIS_LINUX_KERNEL
63#include "vgatypes.h"
64#include "vstruct.h"
65#ifdef SIS_CP
66#undef SIS_CP
67#endif
68#include <linux/config.h>
69#include <linux/version.h>
70#include <linux/types.h>
71#include <asm/io.h>
72#include <linux/fb.h>
73#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
74#include <video/fbcon.h>
75#endif
76#include "sis.h"
77#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
78#include <linux/sisfb.h>
79#else
80#include <video/sisfb.h>
81#endif
82#endif
83
84static const unsigned char SiS_YPbPrTable[5][64] = {
85	{	/* 525i */
86		0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c,
87		0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a,
88		0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b,
89		0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17,
90		0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02,
91		0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40,
92		0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x53,
93		0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00
94	},
95	{	/* 525p */
96		0x33,0x06,0x06,0x09,0x0b,0x0c,0x0c,0x0c,
97		0x98,0x0a,0x01,0x0d,0x06,0x0d,0x04,0x0a,
98		0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
99		0x0c,0x50,0xb2,0x9f,0x16,0x59,0x4f,0x13,
100		0xad,0x11,0xad,0x1d,0x40,0x8a,0x3d,0xb8,
101		0x51,0x5e,0x60,0x49,0x7d,0x92,0x0f,0x40,
102		0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x4e,
103		0x43,0x41,0x11,0x00,0xfc,0xff,0x32,0x00
104	},
105	{	/* 750p */
106#if 0 /* OK, but sticks to left edge */
107		0x13,0x1d,0xe8,0x09,0x09,0xed,0x0c,0x0c,
108		0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a,
109		0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
110		0xed,0x50,0x70,0x9f,0x16,0x59,0x21 /*0x2b*/,0x13,
111		0x27,0x0b,0x27,0xfc,0x30,0x27,0x1c,0xb0,
112		0x4b,0x4b,0x65 /*0x6f*/,0x2f,0x63,0x92,0x0f,0x40,
113		0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x27,
114		0x00,0x40,0x11,0x00,0xfc,0xff,0x32,0x00
115#endif
116		0x23,0x2d,0xe8,0x09,0x09,0xed,0x0c,0x0c,
117		0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a,
118		0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
119		0xed,0x50,0x70,0x9f,0x16,0x59,0x60,0x13,
120		0x27,0x0b,0x27,0xfc,0x30,0x27,0x1c,0xb0,
121		0x4b,0x4b,0x6f,0x2f,0x63,0x92,0x0f,0x40,
122		0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x73,
123		0x00,0x40,0x11,0x00,0xfc,0xff,0x32,0x00
124	},
125	{	/* 625i */
126		0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70,
127		0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d,
128		0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b,
129		0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17,
130		0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02,
131		0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40,
132		0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63,
133		0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00
134	},
135	{	/* 625p */
136		0x3a,0x06,0x6a,0x6e,0x0b,0x70,0x0c,0x0c,
137		0x98,0x0a,0x01,0x0d,0x06,0x0d,0x04,0x0a,
138		0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
139		0x70,0x50,0xb2,0x9f,0x16,0x59,0x4f,0x13,
140		0xad,0x11,0xad,0x1d,0x40,0x8a,0x3d,0xb8,
141		0x51,0x5e,0x60,0x49,0x7d,0x92,0x0f,0x40,
142		0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x4e,
143		0x43,0x41,0x11,0x00,0xfc,0xff,0x32,0x00
144	}
145};
146
147static const unsigned char SiS_TVPhase[] =
148{
149	0x21,0xED,0xBA,0x08,	/* 0x00 SiS_NTSCPhase */
150	0x2A,0x05,0xE3,0x00,	/* 0x01 SiS_PALPhase */
151	0x21,0xE4,0x2E,0x9B,	/* 0x02 SiS_PALMPhase */
152	0x21,0xF4,0x3E,0xBA,	/* 0x03 SiS_PALNPhase */
153	0x1E,0x8B,0xA2,0xA7,
154	0x1E,0x83,0x0A,0xE0,	/* 0x05 SiS_SpecialPhaseM */
155	0x00,0x00,0x00,0x00,
156	0x00,0x00,0x00,0x00,
157	0x21,0xF0,0x7B,0xD6,	/* 0x08 SiS_NTSCPhase2 */
158	0x2A,0x09,0x86,0xE9,	/* 0x09 SiS_PALPhase2 */
159	0x21,0xE6,0xEF,0xA4,	/* 0x0a SiS_PALMPhase2 */
160	0x21,0xF6,0x94,0x46,	/* 0x0b SiS_PALNPhase2 */
161	0x1E,0x8B,0xA2,0xA7,
162	0x1E,0x83,0x0A,0xE0,	/* 0x0d SiS_SpecialPhaseM */
163	0x00,0x00,0x00,0x00,
164	0x00,0x00,0x00,0x00,
165	0x1e,0x8c,0x5c,0x7a,	/* 0x10 SiS_SpecialPhase */
166	0x25,0xd4,0xfd,0x5e	/* 0x11 SiS_SpecialPhaseJ */
167};
168
169static const unsigned char SiS_HiTVGroup3_1[] = {
170	0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x13,
171	0xb1, 0x41, 0x62, 0x62, 0xff, 0xf4, 0x45, 0xa6,
172	0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20,
173	0xac, 0xda, 0x60, 0xfe, 0x6a, 0x9a, 0x06, 0x10,
174	0xd1, 0x04, 0x18, 0x0a, 0xff, 0x80, 0x00, 0x80,
175	0x3b, 0x77, 0x00, 0xef, 0xe0, 0x10, 0xb0, 0xe0,
176	0x10, 0x4f, 0x0f, 0x0f, 0x05, 0x0f, 0x08, 0x6e,
177	0x1a, 0x1f, 0x25, 0x2a, 0x4c, 0xaa, 0x01
178};
179
180static const unsigned char SiS_HiTVGroup3_2[] = {
181	0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x7a,
182	0x54, 0x41, 0xe7, 0xe7, 0xff, 0xf4, 0x45, 0xa6,
183	0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20,
184	0xac, 0x6a, 0x60, 0x2b, 0x52, 0xcd, 0x61, 0x10,
185	0x51, 0x04, 0x18, 0x0a, 0x1f, 0x80, 0x00, 0x80,
186	0xff, 0xa4, 0x04, 0x2b, 0x94, 0x21, 0x72, 0x94,
187	0x26, 0x05, 0x01, 0x0f, 0xed, 0x0f, 0x0a, 0x64,
188	0x18, 0x1d, 0x23, 0x28, 0x4c, 0xaa, 0x01
189};
190
191#ifdef SIS315H
192/* 661 et al LCD data structure (2.03.00) */
193static const unsigned char SiS_LCDStruct661[] = {
194    /* 1024x768 */
195/*  type|CR37|   HDE   |   VDE   |    HT   |    VT   |   hss    | hse   */
196    0x02,0xC0,0x00,0x04,0x00,0x03,0x40,0x05,0x26,0x03,0x10,0x00,0x88,
197    0x00,0x02,0x00,0x06,0x00,0x41,0x5A,0x64,0x00,0x00,0x00,0x00,0x04,
198    /*  | vss     |    vse  |clck|  clock  |CRT2DataP|CRT2DataP|idx     */
199    /*					      VESA    non-VESA  noscale */
200    /* 1280x1024 */
201    0x03,0xC0,0x00,0x05,0x00,0x04,0x98,0x06,0x2A,0x04,0x30,0x00,0x70,
202    0x00,0x01,0x00,0x03,0x00,0x6C,0xF8,0x2F,0x00,0x00,0x00,0x00,0x08,
203    /* 1400x1050 */
204    0x09,0x20,0x78,0x05,0x1A,0x04,0x98,0x06,0x2A,0x04,0x18,0x00,0x38,
205    0x00,0x01,0x00,0x03,0x00,0x6C,0xF8,0x2F,0x00,0x00,0x00,0x00,0x09,
206    /* 1600x1200 */
207    0x0B,0xE0,0x40,0x06,0xB0,0x04,0x70,0x08,0xE2,0x04,0x40,0x00,0xC0,
208    0x00,0x01,0x00,0x03,0x00,0xA2,0x70,0x24,0x00,0x00,0x00,0x00,0x0A,
209    /* 1280x768 (_2) */
210    0x0A,0xE0,0x00,0x05,0x00,0x03,0x7C,0x06,0x26,0x03,0x30,0x00,0x70,
211    0x00,0x03,0x00,0x06,0x00,0x4D,0xC8,0x48,0x00,0x00,0x00,0x00,0x06,
212    /* 1280x720 */
213    0x0E,0xE0,0x00,0x05,0xD0,0x02,0x80,0x05,0x26,0x03,0x10,0x00,0x20,
214    0x00,0x01,0x00,0x06,0x00,0x45,0x9C,0x62,0x00,0x00,0x00,0x00,0x05,
215    /* 1280x800 (_2) */
216    0x0C,0xE0,0x00,0x05,0x20,0x03,0x10,0x06,0x2C,0x03,0x30,0x00,0x70,
217    0x00,0x04,0x00,0x03,0x00,0x49,0xCE,0x1E,0x00,0x00,0x00,0x00,0x09,
218    /* 1680x1050 */
219    0x0D,0xE0,0x90,0x06,0x1A,0x04,0x6C,0x07,0x2A,0x04,0x1A,0x00,0x4C,
220    0x00,0x03,0x00,0x06,0x00,0x79,0xBE,0x44,0x00,0x00,0x00,0x00,0x06,
221    /* 1280x800_3 */
222    0x0C,0xE0,0x00,0x05,0x20,0x03,0xAA,0x05,0x2E,0x03,0x30,0x00,0x50,
223    0x00,0x04,0x00,0x03,0x00,0x47,0xA9,0x10,0x00,0x00,0x00,0x00,0x07,
224    /* 800x600 */
225    0x01,0xC0,0x20,0x03,0x58,0x02,0x20,0x04,0x74,0x02,0x2A,0x00,0x80,
226    0x00,0x06,0x00,0x04,0x00,0x28,0x63,0x4B,0x00,0x00,0x00,0x00,0x00,
227    /* 1280x854 */
228    0x08,0xE0,0x00,0x05,0x56,0x03,0x80,0x06,0x5d,0x03,0x10,0x00,0x70,
229    0x00,0x01,0x00,0x03,0x00,0x54,0x75,0x13,0x00,0x00,0x00,0x00,0x08
230};
231#endif
232
233#ifdef SIS300
234static unsigned char SiS300_TrumpionData[14][80] = {
235  { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02,
236    0x20,0x03,0x0B,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x10,0x00,0x00,0x04,0x23,
237    0x00,0x00,0x03,0x28,0x03,0x10,0x05,0x08,0x40,0x10,0x00,0x10,0x04,0x23,0x00,0x23,
238    0x03,0x11,0x60,0xBC,0x01,0xFF,0x03,0xFF,0x19,0x01,0x00,0x05,0x09,0x04,0x04,0x05,
239    0x04,0x0C,0x09,0x05,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5A,0x01,0xBE,0x01,0x00 },
240  { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x27,0x00,0x80,0x02,
241    0x20,0x03,0x07,0x00,0x5E,0x01,0x0D,0x02,0x60,0x0C,0x30,0x11,0x00,0x00,0x04,0x23,
242    0x00,0x00,0x03,0x80,0x03,0x28,0x06,0x08,0x40,0x11,0x00,0x11,0x04,0x23,0x00,0x23,
243    0x03,0x11,0x60,0x90,0x01,0xFF,0x0F,0xF4,0x19,0x01,0x00,0x05,0x01,0x00,0x04,0x05,
244    0x04,0x0C,0x02,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEC,0x57,0x01,0xBE,0x01,0x00 },
245  { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x8A,0x00,0xD8,0x02,
246    0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23,
247    0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23,
248    0x03,0x11,0x60,0xD9,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05,
249    0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x59,0x01,0xBE,0x01,0x00 },
250  { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x72,0x00,0xD8,0x02,
251    0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23,
252    0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23,
253    0x03,0x11,0x60,0xDA,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05,
254    0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 },
255  { 0x02,0x0A,0x02,0x00,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02,
256    0x20,0x03,0x16,0x00,0xE0,0x01,0x0D,0x02,0x60,0x0C,0x30,0x98,0x00,0x00,0x04,0x23,
257    0x00,0x01,0x03,0x45,0x03,0x48,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x23,0x00,0x23,
258    0x03,0x11,0x60,0xF4,0x01,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x05,0x01,0x00,0x05,0x05,
259    0x04,0x0C,0x08,0x05,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 },
260  { 0x02,0x0A,0x02,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0xBF,0x00,0x20,0x03,
261    0x20,0x04,0x0D,0x00,0x58,0x02,0x71,0x02,0x80,0x0C,0x30,0x9A,0x00,0xFA,0x03,0x1D,
262    0x00,0x01,0x03,0x22,0x03,0x28,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x1D,0x00,0x1D,
263    0x03,0x11,0x60,0x39,0x03,0x40,0x05,0xF4,0x18,0x07,0x02,0x06,0x04,0x01,0x06,0x0B,
264    0x02,0x0A,0x20,0x19,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 },
265  { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0xEF,0x00,0x00,0x04,
266    0x40,0x05,0x13,0x00,0x00,0x03,0x26,0x03,0x88,0x0C,0x30,0x90,0x00,0x00,0x04,0x23,
267    0x00,0x01,0x03,0x24,0x03,0x28,0x06,0x08,0x40,0x90,0x00,0x90,0x04,0x23,0x00,0x23,
268    0x03,0x11,0x60,0x40,0x05,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x08,0x01,0x00,0x08,0x01,
269    0x00,0x08,0x01,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 },
270  /* variant 2 */
271  { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02,
272    0x20,0x03,0x15,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x18,0x00,0x00,0x04,0x23,
273    0x00,0x01,0x03,0x44,0x03,0x28,0x06,0x08,0x40,0x18,0x00,0x18,0x04,0x23,0x00,0x23,
274    0x03,0x11,0x60,0xA6,0x01,0xFF,0x03,0xFF,0x19,0x01,0x00,0x05,0x13,0x04,0x04,0x05,
275    0x04,0x0C,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 },
276  { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02,
277    0x20,0x03,0x15,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x18,0x00,0x00,0x04,0x23,
278    0x00,0x01,0x03,0x44,0x03,0x28,0x06,0x08,0x40,0x18,0x00,0x18,0x04,0x23,0x00,0x23,
279    0x03,0x11,0x60,0xA6,0x01,0xFF,0x03,0xFF,0x19,0x01,0x00,0x05,0x13,0x04,0x04,0x05,
280    0x04,0x0C,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 },
281  { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x8A,0x00,0xD8,0x02,
282    0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23,
283    0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23,
284    0x03,0x11,0x60,0xDA,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05,
285    0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 },
286  { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x72,0x00,0xD8,0x02,
287    0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23,
288    0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23,
289    0x03,0x11,0x60,0xDA,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05,
290    0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 },
291  { 0x02,0x0A,0x02,0x00,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02,
292    0x20,0x03,0x16,0x00,0xE0,0x01,0x0D,0x02,0x60,0x0C,0x30,0x98,0x00,0x00,0x04,0x23,
293    0x00,0x01,0x03,0x45,0x03,0x48,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x23,0x00,0x23,
294    0x03,0x11,0x60,0xF4,0x01,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x05,0x01,0x00,0x05,0x05,
295    0x04,0x0C,0x08,0x05,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEA,0x58,0x01,0xBE,0x01,0x00 },
296  { 0x02,0x0A,0x02,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0xBF,0x00,0x20,0x03,
297    0x20,0x04,0x0D,0x00,0x58,0x02,0x71,0x02,0x80,0x0C,0x30,0x9A,0x00,0xFA,0x03,0x1D,
298    0x00,0x01,0x03,0x22,0x03,0x28,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x1D,0x00,0x1D,
299    0x03,0x11,0x60,0x39,0x03,0x40,0x05,0xF4,0x18,0x07,0x02,0x06,0x04,0x01,0x06,0x0B,
300    0x02,0x0A,0x20,0x19,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEA,0x58,0x01,0xBE,0x01,0x00 },
301  { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0xEF,0x00,0x00,0x04,
302    0x40,0x05,0x13,0x00,0x00,0x03,0x26,0x03,0x88,0x0C,0x30,0x90,0x00,0x00,0x04,0x23,
303    0x00,0x01,0x03,0x24,0x03,0x28,0x06,0x08,0x40,0x90,0x00,0x90,0x04,0x23,0x00,0x23,
304    0x03,0x11,0x60,0x40,0x05,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x08,0x01,0x00,0x08,0x01,
305    0x00,0x08,0x01,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEA,0x58,0x01,0xBE,0x01,0x00 }
306};
307#endif
308
309void		SiS_UnLockCRT2(struct SiS_Private *SiS_Pr);
310#ifndef SIS_LINUX_KERNEL
311void		SiS_LockCRT2(struct SiS_Private *SiS_Pr);
312#endif
313void		SiS_EnableCRT2(struct SiS_Private *SiS_Pr);
314unsigned short	SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex);
315void		SiS_WaitRetrace1(struct SiS_Private *SiS_Pr);
316BOOLEAN		SiS_IsDualEdge(struct SiS_Private *SiS_Pr);
317BOOLEAN		SiS_IsVAMode(struct SiS_Private *SiS_Pr);
318void		SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
319			unsigned short ModeIdIndex, int checkcrt2mode);
320void		SiS_SetYPbPr(struct SiS_Private *SiS_Pr);
321void    	SiS_SetTVMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
322			unsigned short ModeIdIndex);
323void		SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
324		unsigned short ModeIdIndex);
325unsigned short	SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
326			unsigned short RefreshRateTableIndex);
327unsigned short	SiS_GetResInfo(struct SiS_Private *SiS_Pr,unsigned short ModeNo,unsigned short ModeIdIndex);
328void		SiS_DisableBridge(struct SiS_Private *SiS_Pr);
329#ifndef SIS_LINUX_KERNEL
330void		SiS_EnableBridge(struct SiS_Private *SiS_Pr);
331#endif
332BOOLEAN		SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo);
333void		SiS_SiS30xBLOn(struct SiS_Private *SiS_Pr);
334void		SiS_SiS30xBLOff(struct SiS_Private *SiS_Pr);
335
336void		SiS_SetCH700x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val);
337unsigned short	SiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short tempax);
338void		SiS_SetCH701x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val);
339unsigned short	SiS_GetCH701x(struct SiS_Private *SiS_Pr, unsigned short tempax);
340#ifndef SIS_LINUX_KERNEL
341void		SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val);
342unsigned short	SiS_GetCH70xx(struct SiS_Private *SiS_Pr, unsigned short tempax);
343#endif
344void		SiS_SetCH70xxANDOR(struct SiS_Private *SiS_Pr, unsigned short reg,
345			unsigned char orval,unsigned short andval);
346#ifdef SIS315H
347static void	SiS_Chrontel701xOn(struct SiS_Private *SiS_Pr);
348static void	SiS_Chrontel701xOff(struct SiS_Private *SiS_Pr);
349static void	SiS_ChrontelInitTVVSync(struct SiS_Private *SiS_Pr);
350static void	SiS_ChrontelDoSomething1(struct SiS_Private *SiS_Pr);
351void		SiS_Chrontel701xBLOn(struct SiS_Private *SiS_Pr);
352void		SiS_Chrontel701xBLOff(struct SiS_Private *SiS_Pr);
353#endif /* 315 */
354
355#ifdef SIS300
356static  BOOLEAN	SiS_SetTrumpionBlock(struct SiS_Private *SiS_Pr, unsigned char *dataptr);
357void		SiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo);
358#endif
359
360void		SiS_DDC2Delay(struct SiS_Private *SiS_Pr, unsigned int delaytime);
361unsigned short	SiS_ReadDDC1Bit(struct SiS_Private *SiS_Pr);
362unsigned short	SiS_HandleDDC(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine,
363			unsigned short adaptnum, unsigned short DDCdatatype,
364			unsigned char *buffer, unsigned int VBFlags2);
365
366#ifdef SIS_XORG_XF86
367unsigned short		SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags,
368				int VGAEngine, unsigned short adaptnum, unsigned short DDCdatatype,
369				BOOLEAN checkcr32, unsigned int VBFlags2);
370unsigned short		SiS_ProbeDDC(struct SiS_Private *SiS_Pr);
371unsigned short		SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype,
372				unsigned char *buffer);
373#else
374static unsigned short	SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags,
375				int VGAEngine, unsigned short adaptnum, unsigned short DDCdatatype,
376				BOOLEAN checkcr32, unsigned int VBFlags2);
377static unsigned short	SiS_ProbeDDC(struct SiS_Private *SiS_Pr);
378static unsigned short	SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype,
379				unsigned char *buffer);
380#endif
381static void		SiS_SetSwitchDDC2(struct SiS_Private *SiS_Pr);
382static unsigned short	SiS_SetStart(struct SiS_Private *SiS_Pr);
383static unsigned short	SiS_SetStop(struct SiS_Private *SiS_Pr);
384static unsigned short	SiS_SetSCLKLow(struct SiS_Private *SiS_Pr);
385static unsigned short	SiS_SetSCLKHigh(struct SiS_Private *SiS_Pr);
386static unsigned short	SiS_ReadDDC2Data(struct SiS_Private *SiS_Pr);
387static unsigned short	SiS_WriteDDC2Data(struct SiS_Private *SiS_Pr, unsigned short tempax);
388static unsigned short	SiS_CheckACK(struct SiS_Private *SiS_Pr);
389static unsigned short	SiS_WriteDABDDC(struct SiS_Private *SiS_Pr);
390static unsigned short	SiS_PrepareReadDDC(struct SiS_Private *SiS_Pr);
391static unsigned short	SiS_PrepareDDC(struct SiS_Private *SiS_Pr);
392static void		SiS_SendACK(struct SiS_Private *SiS_Pr, unsigned short yesno);
393static unsigned short	SiS_DoProbeDDC(struct SiS_Private *SiS_Pr);
394
395#ifdef SIS300
396static void		SiS_OEM300Setting(struct SiS_Private *SiS_Pr,
397				unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefTabindex);
398static void		SetOEMLCDData2(struct SiS_Private *SiS_Pr,
399				unsigned short ModeNo, unsigned short ModeIdIndex,unsigned short RefTableIndex);
400#endif
401#ifdef SIS315H
402static void		SiS_OEM310Setting(struct SiS_Private *SiS_Pr,
403				unsigned short ModeNo,unsigned short ModeIdIndex, unsigned short RRTI);
404static void		SiS_OEM661Setting(struct SiS_Private *SiS_Pr,
405				unsigned short ModeNo,unsigned short ModeIdIndex, unsigned short RRTI);
406static void		SiS_FinalizeLCD(struct SiS_Private *, unsigned short, unsigned short);
407#endif
408
409extern void		SiS_SetReg(SISIOADDRESS, unsigned short, unsigned short);
410extern void		SiS_SetRegByte(SISIOADDRESS, unsigned short);
411extern void		SiS_SetRegShort(SISIOADDRESS, unsigned short);
412extern void		SiS_SetRegLong(SISIOADDRESS, unsigned int);
413extern unsigned char	SiS_GetReg(SISIOADDRESS, unsigned short);
414extern unsigned char	SiS_GetRegByte(SISIOADDRESS);
415extern unsigned short	SiS_GetRegShort(SISIOADDRESS);
416extern unsigned int	SiS_GetRegLong(SISIOADDRESS);
417extern void		SiS_SetRegANDOR(SISIOADDRESS, unsigned short, unsigned short, unsigned short);
418extern void		SiS_SetRegOR(SISIOADDRESS, unsigned short, unsigned short);
419extern void		SiS_SetRegAND(SISIOADDRESS, unsigned short, unsigned short);
420extern void		SiS_DisplayOff(struct SiS_Private *SiS_Pr);
421extern void		SiS_DisplayOn(struct SiS_Private *SiS_Pr);
422extern BOOLEAN		SiS_SearchModeID(struct SiS_Private *, unsigned short *, unsigned short *);
423extern unsigned short	SiS_GetModeFlag(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
424				unsigned short ModeIdIndex);
425extern unsigned short	SiS_GetModePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex);
426extern unsigned short	SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex);
427extern unsigned short	SiS_GetOffset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
428				unsigned short RefreshRateTableIndex);
429extern void		SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
430				unsigned short ModeIdIndex);
431extern void		SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
432				unsigned short ModeIdIndex);
433extern void		SiS_CalcCRRegisters(struct SiS_Private *SiS_Pr, int depth);
434extern unsigned short	SiS_GetRefCRTVCLK(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide);
435extern unsigned short	SiS_GetRefCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide);
436#ifdef SIS300
437extern void		SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *tempbx,
438				unsigned short *tempcl);
439extern unsigned short	SiS_GetFIFOThresholdB300(unsigned short tempbx, unsigned short tempcl);
440extern unsigned short	SiS_GetLatencyFactor630(struct SiS_Private *SiS_Pr, unsigned short index);
441#ifdef SIS_LINUX_KERNEL
442extern unsigned int	sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg);
443extern unsigned int	sisfb_read_lpc_pci_dword(struct SiS_Private *SiS_Pr, int reg);
444#endif
445#endif
446#ifdef SIS315H
447extern void		SiS_SetGroup2_C_ELV(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
448				unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex);
449#endif
450
451#endif
452