viamode.c 40.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.

 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation;
 * either version 2, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE.See the GNU General Public License
 * for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc.,
 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

22
#include <linux/via-core.h>
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
#include "global.h"

struct io_reg CN400_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01},
{VIASR, SR15, 0x02, 0x02},
{VIASR, SR16, 0xBF, 0x08},
{VIASR, SR17, 0xFF, 0x1F},
{VIASR, SR18, 0xFF, 0x4E},
{VIASR, SR1A, 0xFB, 0x08},
{VIASR, SR1E, 0x0F, 0x01},
{VIASR, SR2A, 0xFF, 0x00},
{VIACR, CR0A, 0xFF, 0x1E},	/* Cursor Start                        */
{VIACR, CR0B, 0xFF, 0x00},	/* Cursor End                          */
{VIACR, CR0E, 0xFF, 0x00},	/* Cursor Location High                */
{VIACR, CR0F, 0xFF, 0x00},	/* Cursor Localtion Low                */
{VIACR, CR32, 0xFF, 0x00},
{VIACR, CR33, 0xFF, 0x00},
{VIACR, CR35, 0xFF, 0x00},
{VIACR, CR36, 0x08, 0x00},
{VIACR, CR69, 0xFF, 0x00},
{VIACR, CR6A, 0xFF, 0x40},
{VIACR, CR6B, 0xFF, 0x00},
{VIACR, CR6C, 0xFF, 0x00},
{VIACR, CR7A, 0xFF, 0x01},	/* LCD Scaling Parameter 1             */
{VIACR, CR7B, 0xFF, 0x02},	/* LCD Scaling Parameter 2             */
{VIACR, CR7C, 0xFF, 0x03},	/* LCD Scaling Parameter 3             */
{VIACR, CR7D, 0xFF, 0x04},	/* LCD Scaling Parameter 4             */
{VIACR, CR7E, 0xFF, 0x07},	/* LCD Scaling Parameter 5             */
{VIACR, CR7F, 0xFF, 0x0A},	/* LCD Scaling Parameter 6             */
{VIACR, CR80, 0xFF, 0x0D},	/* LCD Scaling Parameter 7             */
{VIACR, CR81, 0xFF, 0x13},	/* LCD Scaling Parameter 8             */
{VIACR, CR82, 0xFF, 0x16},	/* LCD Scaling Parameter 9             */
{VIACR, CR83, 0xFF, 0x19},	/* LCD Scaling Parameter 10            */
{VIACR, CR84, 0xFF, 0x1C},	/* LCD Scaling Parameter 11            */
{VIACR, CR85, 0xFF, 0x1D},	/* LCD Scaling Parameter 12            */
{VIACR, CR86, 0xFF, 0x1E},	/* LCD Scaling Parameter 13            */
{VIACR, CR87, 0xFF, 0x1F},	/* LCD Scaling Parameter 14            */
{VIACR, CR88, 0xFF, 0x40},	/* LCD Panel Type                      */
{VIACR, CR89, 0xFF, 0x00},	/* LCD Timing Control 0                */
{VIACR, CR8A, 0xFF, 0x88},	/* LCD Timing Control 1                */
{VIACR, CR8B, 0xFF, 0x69},	/* LCD Power Sequence Control 0        */
{VIACR, CR8C, 0xFF, 0x57},	/* LCD Power Sequence Control 1        */
{VIACR, CR8D, 0xFF, 0x00},	/* LCD Power Sequence Control 2        */
{VIACR, CR8E, 0xFF, 0x7B},	/* LCD Power Sequence Control 3        */
{VIACR, CR8F, 0xFF, 0x03},	/* LCD Power Sequence Control 4        */
{VIACR, CR90, 0xFF, 0x30},	/* LCD Power Sequence Control 5        */
{VIACR, CR91, 0xFF, 0xA0},	/* 24/12 bit LVDS Data off             */
{VIACR, CR96, 0xFF, 0x00},
{VIACR, CR97, 0xFF, 0x00},
{VIACR, CR99, 0xFF, 0x00},
{VIACR, CR9B, 0xFF, 0x00}
};

/* Video Mode Table for VT3314 chipset*/
/* Common Setting for Video Mode */
struct io_reg CN700_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01},
{VIASR, SR15, 0x02, 0x02},
{VIASR, SR16, 0xBF, 0x08},
{VIASR, SR17, 0xFF, 0x1F},
{VIASR, SR18, 0xFF, 0x4E},
{VIASR, SR1A, 0xFB, 0x82},
{VIASR, SR1B, 0xFF, 0xF0},
{VIASR, SR1F, 0xFF, 0x00},
{VIASR, SR1E, 0xFF, 0x01},
{VIASR, SR22, 0xFF, 0x1F},
{VIASR, SR2A, 0x0F, 0x00},
{VIASR, SR2E, 0xFF, 0xFF},
{VIASR, SR3F, 0xFF, 0xFF},
{VIASR, SR40, 0xF7, 0x00},
{VIASR, CR30, 0xFF, 0x04},
{VIACR, CR32, 0xFF, 0x00},
{VIACR, CR33, 0x7F, 0x00},
{VIACR, CR35, 0xFF, 0x00},
{VIACR, CR36, 0xFF, 0x31},
{VIACR, CR41, 0xFF, 0x80},
{VIACR, CR42, 0xFF, 0x00},
{VIACR, CR55, 0x80, 0x00},
{VIACR, CR5D, 0x80, 0x00},	/*Horizontal Retrace Start bit[11] should be 0*/
{VIACR, CR68, 0xFF, 0x67},	/* Default FIFO For IGA2 */
{VIACR, CR69, 0xFF, 0x00},
{VIACR, CR6A, 0xFD, 0x40},
{VIACR, CR6B, 0xFF, 0x00},
{VIACR, CR6C, 0xFF, 0x00},
{VIACR, CR77, 0xFF, 0x00},	/* LCD scaling Factor */
{VIACR, CR78, 0xFF, 0x00},	/* LCD scaling Factor */
{VIACR, CR79, 0xFF, 0x00},	/* LCD scaling Factor */
{VIACR, CR9F, 0x03, 0x00},	/* LCD scaling Factor */
{VIACR, CR7A, 0xFF, 0x01},	/* LCD Scaling Parameter 1 */
{VIACR, CR7B, 0xFF, 0x02},	/* LCD Scaling Parameter 2 */
{VIACR, CR7C, 0xFF, 0x03},	/* LCD Scaling Parameter 3 */
{VIACR, CR7D, 0xFF, 0x04},	/* LCD Scaling Parameter 4 */
{VIACR, CR7E, 0xFF, 0x07},	/* LCD Scaling Parameter 5 */
{VIACR, CR7F, 0xFF, 0x0A},	/* LCD Scaling Parameter 6 */
{VIACR, CR80, 0xFF, 0x0D},	/* LCD Scaling Parameter 7 */
{VIACR, CR81, 0xFF, 0x13},	/* LCD Scaling Parameter 8 */
{VIACR, CR82, 0xFF, 0x16},	/* LCD Scaling Parameter 9 */
{VIACR, CR83, 0xFF, 0x19},	/* LCD Scaling Parameter 10 */
{VIACR, CR84, 0xFF, 0x1C},	/* LCD Scaling Parameter 11 */
{VIACR, CR85, 0xFF, 0x1D},	/* LCD Scaling Parameter 12 */
{VIACR, CR86, 0xFF, 0x1E},	/* LCD Scaling Parameter 13 */
{VIACR, CR87, 0xFF, 0x1F},	/* LCD Scaling Parameter 14 */
{VIACR, CR88, 0xFF, 0x40},	/* LCD Panel Type */
{VIACR, CR89, 0xFF, 0x00},	/* LCD Timing Control 0 */
{VIACR, CR8A, 0xFF, 0x88},	/* LCD Timing Control 1 */
{VIACR, CR8B, 0xFF, 0x5D},	/* LCD Power Sequence Control 0 */
{VIACR, CR8C, 0xFF, 0x2B},	/* LCD Power Sequence Control 1 */
{VIACR, CR8D, 0xFF, 0x6F},	/* LCD Power Sequence Control 2 */
{VIACR, CR8E, 0xFF, 0x2B},	/* LCD Power Sequence Control 3 */
{VIACR, CR8F, 0xFF, 0x01},	/* LCD Power Sequence Control 4 */
{VIACR, CR90, 0xFF, 0x01},	/* LCD Power Sequence Control 5 */
{VIACR, CR91, 0xFF, 0xA0},	/* 24/12 bit LVDS Data off */
{VIACR, CR96, 0xFF, 0x00},
{VIACR, CR97, 0xFF, 0x00},
{VIACR, CR99, 0xFF, 0x00},
{VIACR, CR9B, 0xFF, 0x00},
{VIACR, CR9D, 0xFF, 0x80},
{VIACR, CR9E, 0xFF, 0x80}
};

struct io_reg KM400_ModeXregs[] = {
	{VIASR, SR10, 0xFF, 0x01},	/* Unlock Register                 */
	{VIASR, SR16, 0xFF, 0x08},	/* Display FIFO threshold Control  */
	{VIASR, SR17, 0xFF, 0x1F},	/* Display FIFO Control            */
	{VIASR, SR18, 0xFF, 0x4E},	/* GFX PREQ threshold              */
	{VIASR, SR1A, 0xFF, 0x0a},	/* GFX PREQ threshold              */
	{VIASR, SR1F, 0xFF, 0x00},	/* Memory Control 0                */
	{VIASR, SR1B, 0xFF, 0xF0},	/* Power Management Control 0      */
	{VIASR, SR1E, 0xFF, 0x01},	/* Power Management Control        */
	{VIASR, SR20, 0xFF, 0x00},	/* Sequencer Arbiter Control 0     */
	{VIASR, SR21, 0xFF, 0x00},	/* Sequencer Arbiter Control 1     */
	{VIASR, SR22, 0xFF, 0x1F},	/* Display Arbiter Control 1       */
	{VIASR, SR2A, 0xFF, 0x00},	/* Power Management Control 5      */
	{VIASR, SR2D, 0xFF, 0xFF},	/* Power Management Control 1      */
	{VIASR, SR2E, 0xFF, 0xFF},	/* Power Management Control 2      */
	{VIACR, CR0A, 0xFF, 0x1E},	/* Cursor Start                    */
	{VIACR, CR0B, 0xFF, 0x00},	/* Cursor End                      */
	{VIACR, CR0E, 0xFF, 0x00},	/* Cursor Location High            */
	{VIACR, CR0F, 0xFF, 0x00},	/* Cursor Localtion Low            */
	{VIACR, CR33, 0xFF, 0x00},
	{VIACR, CR55, 0x80, 0x00},
	{VIACR, CR5D, 0x80, 0x00},
	{VIACR, CR36, 0xFF, 0x01},	/* Power Mangement 3                  */
	{VIACR, CR68, 0xFF, 0x67},	/* Default FIFO For IGA2              */
	{VIACR, CR6A, 0x20, 0x20},	/* Extended FIFO On                   */
	{VIACR, CR7A, 0xFF, 0x01},	/* LCD Scaling Parameter 1            */
	{VIACR, CR7B, 0xFF, 0x02},	/* LCD Scaling Parameter 2            */
	{VIACR, CR7C, 0xFF, 0x03},	/* LCD Scaling Parameter 3            */
	{VIACR, CR7D, 0xFF, 0x04},	/* LCD Scaling Parameter 4            */
	{VIACR, CR7E, 0xFF, 0x07},	/* LCD Scaling Parameter 5            */
	{VIACR, CR7F, 0xFF, 0x0A},	/* LCD Scaling Parameter 6            */
	{VIACR, CR80, 0xFF, 0x0D},	/* LCD Scaling Parameter 7            */
	{VIACR, CR81, 0xFF, 0x13},	/* LCD Scaling Parameter 8            */
	{VIACR, CR82, 0xFF, 0x16},	/* LCD Scaling Parameter 9            */
	{VIACR, CR83, 0xFF, 0x19},	/* LCD Scaling Parameter 10           */
	{VIACR, CR84, 0xFF, 0x1C},	/* LCD Scaling Parameter 11           */
	{VIACR, CR85, 0xFF, 0x1D},	/* LCD Scaling Parameter 12           */
	{VIACR, CR86, 0xFF, 0x1E},	/* LCD Scaling Parameter 13           */
	{VIACR, CR87, 0xFF, 0x1F},	/* LCD Scaling Parameter 14           */
	{VIACR, CR88, 0xFF, 0x40},	/* LCD Panel Type                     */
	{VIACR, CR89, 0xFF, 0x00},	/* LCD Timing Control 0               */
	{VIACR, CR8A, 0xFF, 0x88},	/* LCD Timing Control 1               */
	{VIACR, CR8B, 0xFF, 0x2D},	/* LCD Power Sequence Control 0       */
	{VIACR, CR8C, 0xFF, 0x2D},	/* LCD Power Sequence Control 1       */
	{VIACR, CR8D, 0xFF, 0xC8},	/* LCD Power Sequence Control 2       */
	{VIACR, CR8E, 0xFF, 0x36},	/* LCD Power Sequence Control 3       */
	{VIACR, CR8F, 0xFF, 0x00},	/* LCD Power Sequence Control 4       */
	{VIACR, CR90, 0xFF, 0x10},	/* LCD Power Sequence Control 5       */
	{VIACR, CR91, 0xFF, 0xA0},	/* 24/12 bit LVDS Data off            */
	{VIACR, CR96, 0xFF, 0x03},	/* DVP0        ; DVP0 Clock Skew */
	{VIACR, CR97, 0xFF, 0x03},	/* DFP high    ; DFPH Clock Skew */
	{VIACR, CR99, 0xFF, 0x03},	/* DFP low           ; DFPL Clock Skew*/
	{VIACR, CR9B, 0xFF, 0x07}	/* DVI on DVP1       ; DVP1 Clock Skew*/
};

/* For VT3324: Common Setting for Video Mode */
struct io_reg CX700_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01},
{VIASR, SR15, 0x02, 0x02},
{VIASR, SR16, 0xBF, 0x08},
{VIASR, SR17, 0xFF, 0x1F},
{VIASR, SR18, 0xFF, 0x4E},
{VIASR, SR1A, 0xFB, 0x08},
{VIASR, SR1B, 0xFF, 0xF0},
{VIASR, SR1E, 0xFF, 0x01},
{VIASR, SR2A, 0xFF, 0x00},
{VIASR, SR2D, 0xFF, 0xFF},	/* VCK and LCK PLL power on.           */
{VIACR, CR0A, 0xFF, 0x1E},	/* Cursor Start                        */
{VIACR, CR0B, 0xFF, 0x00},	/* Cursor End                          */
{VIACR, CR0E, 0xFF, 0x00},	/* Cursor Location High                */
{VIACR, CR0F, 0xFF, 0x00},	/* Cursor Localtion Low                */
{VIACR, CR32, 0xFF, 0x00},
{VIACR, CR33, 0xFF, 0x00},
{VIACR, CR35, 0xFF, 0x00},
{VIACR, CR36, 0x08, 0x00},
{VIACR, CR47, 0xC8, 0x00},	/* Clear VCK Plus. */
{VIACR, CR69, 0xFF, 0x00},
{VIACR, CR6A, 0xFF, 0x40},
{VIACR, CR6B, 0xFF, 0x00},
{VIACR, CR6C, 0xFF, 0x00},
{VIACR, CR7A, 0xFF, 0x01},	/* LCD Scaling Parameter 1             */
{VIACR, CR7B, 0xFF, 0x02},	/* LCD Scaling Parameter 2             */
{VIACR, CR7C, 0xFF, 0x03},	/* LCD Scaling Parameter 3             */
{VIACR, CR7D, 0xFF, 0x04},	/* LCD Scaling Parameter 4             */
{VIACR, CR7E, 0xFF, 0x07},	/* LCD Scaling Parameter 5             */
{VIACR, CR7F, 0xFF, 0x0A},	/* LCD Scaling Parameter 6             */
{VIACR, CR80, 0xFF, 0x0D},	/* LCD Scaling Parameter 7             */
{VIACR, CR81, 0xFF, 0x13},	/* LCD Scaling Parameter 8             */
{VIACR, CR82, 0xFF, 0x16},	/* LCD Scaling Parameter 9             */
{VIACR, CR83, 0xFF, 0x19},	/* LCD Scaling Parameter 10            */
{VIACR, CR84, 0xFF, 0x1C},	/* LCD Scaling Parameter 11            */
{VIACR, CR85, 0xFF, 0x1D},	/* LCD Scaling Parameter 12            */
{VIACR, CR86, 0xFF, 0x1E},	/* LCD Scaling Parameter 13            */
{VIACR, CR87, 0xFF, 0x1F},	/* LCD Scaling Parameter 14            */
{VIACR, CR88, 0xFF, 0x40},	/* LCD Panel Type                      */
{VIACR, CR89, 0xFF, 0x00},	/* LCD Timing Control 0                */
{VIACR, CR8A, 0xFF, 0x88},	/* LCD Timing Control 1                */
{VIACR, CRD4, 0xFF, 0x81},	/* Second power sequence control       */
{VIACR, CR8B, 0xFF, 0x5D},	/* LCD Power Sequence Control 0        */
{VIACR, CR8C, 0xFF, 0x2B},	/* LCD Power Sequence Control 1        */
{VIACR, CR8D, 0xFF, 0x6F},	/* LCD Power Sequence Control 2        */
{VIACR, CR8E, 0xFF, 0x2B},	/* LCD Power Sequence Control 3        */
{VIACR, CR8F, 0xFF, 0x01},	/* LCD Power Sequence Control 4        */
{VIACR, CR90, 0xFF, 0x01},	/* LCD Power Sequence Control 5        */
{VIACR, CR91, 0xFF, 0x80},	/* 24/12 bit LVDS Data off             */
{VIACR, CR96, 0xFF, 0x00},
{VIACR, CR97, 0xFF, 0x00},
{VIACR, CR99, 0xFF, 0x00},
248
{VIACR, CR9B, 0xFF, 0x00}
249 250
};

251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
struct io_reg VX855_ModeXregs[] = {
{VIASR, SR10, 0xFF, 0x01},
{VIASR, SR15, 0x02, 0x02},
{VIASR, SR16, 0xBF, 0x08},
{VIASR, SR17, 0xFF, 0x1F},
{VIASR, SR18, 0xFF, 0x4E},
{VIASR, SR1A, 0xFB, 0x08},
{VIASR, SR1B, 0xFF, 0xF0},
{VIASR, SR1E, 0x07, 0x01},
{VIASR, SR2A, 0xF0, 0x00},
{VIASR, SR58, 0xFF, 0x00},
{VIASR, SR59, 0xFF, 0x00},
{VIASR, SR2D, 0xFF, 0xFF},	/* VCK and LCK PLL power on.           */
{VIACR, CR09, 0xFF, 0x00},	/* Initial CR09=0*/
{VIACR, CR11, 0x8F, 0x00},	/* IGA1 initial  Vertical end       */
{VIACR, CR17, 0x7F, 0x00}, 	/* IGA1 CRT Mode control init   */
{VIACR, CR0A, 0xFF, 0x1E},	/* Cursor Start                        */
{VIACR, CR0B, 0xFF, 0x00},	/* Cursor End                          */
{VIACR, CR0E, 0xFF, 0x00},	/* Cursor Location High                */
{VIACR, CR0F, 0xFF, 0x00},	/* Cursor Localtion Low                */
{VIACR, CR32, 0xFF, 0x00},
{VIACR, CR33, 0x7F, 0x00},
{VIACR, CR35, 0xFF, 0x00},
{VIACR, CR36, 0x08, 0x00},
{VIACR, CR69, 0xFF, 0x00},
{VIACR, CR6A, 0xFD, 0x60},
{VIACR, CR6B, 0xFF, 0x00},
{VIACR, CR6C, 0xFF, 0x00},
{VIACR, CR7A, 0xFF, 0x01},          /* LCD Scaling Parameter 1             */
{VIACR, CR7B, 0xFF, 0x02},          /* LCD Scaling Parameter 2             */
{VIACR, CR7C, 0xFF, 0x03},          /* LCD Scaling Parameter 3             */
{VIACR, CR7D, 0xFF, 0x04},          /* LCD Scaling Parameter 4             */
{VIACR, CR7E, 0xFF, 0x07},          /* LCD Scaling Parameter 5             */
{VIACR, CR7F, 0xFF, 0x0A},          /* LCD Scaling Parameter 6             */
{VIACR, CR80, 0xFF, 0x0D},          /* LCD Scaling Parameter 7             */
{VIACR, CR81, 0xFF, 0x13},          /* LCD Scaling Parameter 8             */
{VIACR, CR82, 0xFF, 0x16},          /* LCD Scaling Parameter 9             */
{VIACR, CR83, 0xFF, 0x19},          /* LCD Scaling Parameter 10            */
{VIACR, CR84, 0xFF, 0x1C},          /* LCD Scaling Parameter 11            */
{VIACR, CR85, 0xFF, 0x1D},          /* LCD Scaling Parameter 12            */
{VIACR, CR86, 0xFF, 0x1E},          /* LCD Scaling Parameter 13            */
{VIACR, CR87, 0xFF, 0x1F},          /* LCD Scaling Parameter 14            */
{VIACR, CR88, 0xFF, 0x40},          /* LCD Panel Type                      */
{VIACR, CR89, 0xFF, 0x00},          /* LCD Timing Control 0                */
{VIACR, CR8A, 0xFF, 0x88},          /* LCD Timing Control 1                */
{VIACR, CRD4, 0xFF, 0x81},          /* Second power sequence control       */
{VIACR, CR91, 0xFF, 0x80},          /* 24/12 bit LVDS Data off             */
{VIACR, CR96, 0xFF, 0x00},
{VIACR, CR97, 0xFF, 0x00},
{VIACR, CR99, 0xFF, 0x00},
{VIACR, CR9B, 0xFF, 0x00},
{VIACR, CRD2, 0xFF, 0xFF}           /* TMDS/LVDS control register.         */
};

305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
/* Video Mode Table */
/* Common Setting for Video Mode */
struct io_reg CLE266_ModeXregs[] = { {VIASR, SR1E, 0xF0, 0x00},
{VIASR, SR2A, 0x0F, 0x00},
{VIASR, SR15, 0x02, 0x02},
{VIASR, SR16, 0xBF, 0x08},
{VIASR, SR17, 0xFF, 0x1F},
{VIASR, SR18, 0xFF, 0x4E},
{VIASR, SR1A, 0xFB, 0x08},

{VIACR, CR32, 0xFF, 0x00},
{VIACR, CR35, 0xFF, 0x00},
{VIACR, CR36, 0x08, 0x00},
{VIACR, CR6A, 0xFF, 0x80},
{VIACR, CR6A, 0xFF, 0xC0},

{VIACR, CR55, 0x80, 0x00},
{VIACR, CR5D, 0x80, 0x00},

{VIAGR, GR20, 0xFF, 0x00},
{VIAGR, GR21, 0xFF, 0x00},
{VIAGR, GR22, 0xFF, 0x00},
	/* LCD Parameters */
{VIACR, CR7A, 0xFF, 0x01},	/* LCD Parameter 1 */
{VIACR, CR7B, 0xFF, 0x02},	/* LCD Parameter 2 */
{VIACR, CR7C, 0xFF, 0x03},	/* LCD Parameter 3 */
{VIACR, CR7D, 0xFF, 0x04},	/* LCD Parameter 4 */
{VIACR, CR7E, 0xFF, 0x07},	/* LCD Parameter 5 */
{VIACR, CR7F, 0xFF, 0x0A},	/* LCD Parameter 6 */
{VIACR, CR80, 0xFF, 0x0D},	/* LCD Parameter 7 */
{VIACR, CR81, 0xFF, 0x13},	/* LCD Parameter 8 */
{VIACR, CR82, 0xFF, 0x16},	/* LCD Parameter 9 */
{VIACR, CR83, 0xFF, 0x19},	/* LCD Parameter 10 */
{VIACR, CR84, 0xFF, 0x1C},	/* LCD Parameter 11 */
{VIACR, CR85, 0xFF, 0x1D},	/* LCD Parameter 12 */
{VIACR, CR86, 0xFF, 0x1E},	/* LCD Parameter 13 */
{VIACR, CR87, 0xFF, 0x1F},	/* LCD Parameter 14 */

};

/* Mode:1024X768 */
struct io_reg PM1024x768[] = { {VIASR, 0x16, 0xBF, 0x0C},
{VIASR, 0x18, 0xFF, 0x4C}
};

struct patch_table res_patch_table[] = {
351
	{ARRAY_SIZE(PM1024x768), PM1024x768}
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
};

/* struct VPITTable {
	unsigned char  Misc;
	unsigned char  SR[StdSR];
	unsigned char  CR[StdCR];
	unsigned char  GR[StdGR];
	unsigned char  AR[StdAR];
 };*/

struct VPITTable VPIT = {
	/* Msic */
	0xC7,
	/* Sequencer */
	{0x01, 0x0F, 0x00, 0x0E},
	/* Graphic Controller */
	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
	/* Attribute Controller */
	{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
	 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
	 0x01, 0x00, 0x0F, 0x00}
};

/********************/
/* Mode Table       */
/********************/

/* 480x640 */
380
static struct crt_mode_table CRTM480x640[] = {
381 382 383 384 385 386 387
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_25_175M, M480X640_R60_HSP, M480X640_R60_VSP,
	 {624, 480, 480, 144, 504, 48, 663, 640, 640, 23, 641, 3} }	/* GTF*/
};

/* 640x480*/
388
static struct crt_mode_table CRTM640x480[] = {
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
	/*r_rate,vclk,hsp,vsp */
	/*HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_25_175M, M640X480_R60_HSP, M640X480_R60_VSP,
	 {800, 640, 648, 144, 656, 96, 525, 480, 480, 45, 490, 2} },
	{REFRESH_75, CLK_31_500M, M640X480_R75_HSP, M640X480_R75_VSP,
	 {840, 640, 640, 200, 656, 64, 500, 480, 480, 20, 481, 3} },
	{REFRESH_85, CLK_36_000M, M640X480_R85_HSP, M640X480_R85_VSP,
	 {832, 640, 640, 192, 696, 56, 509, 480, 480, 29, 481, 3} },
	{REFRESH_100, CLK_43_163M, M640X480_R100_HSP, M640X480_R100_VSP,
	 {848, 640, 640, 208, 680, 64, 509, 480, 480, 29, 481, 3} }, /*GTF*/
	    {REFRESH_120, CLK_52_406M, M640X480_R120_HSP,
	     M640X480_R120_VSP,
	     {848, 640, 640, 208, 680, 64, 515, 480, 480, 35, 481,
	      3} } /*GTF*/
};

/*720x480 (GTF)*/
406
static struct crt_mode_table CRTM720x480[] = {
407 408 409 410 411 412 413 414
	/*r_rate,vclk,hsp,vsp      */
	/*HT, HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_26_880M, M720X480_R60_HSP, M720X480_R60_VSP,
	 {896, 720, 720, 176, 736, 72, 497, 480, 480, 17, 481, 3} }

};

/*720x576 (GTF)*/
415
static struct crt_mode_table CRTM720x576[] = {
416 417 418 419 420 421 422
	/*r_rate,vclk,hsp,vsp */
	/*HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_32_668M, M720X576_R60_HSP, M720X576_R60_VSP,
	 {912, 720, 720, 192, 744, 72, 597, 576, 576, 21, 577, 3} }
};

/* 800x480 (CVT) */
423
static struct crt_mode_table CRTM800x480[] = {
424 425 426 427 428 429 430
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_29_581M, M800X480_R60_HSP, M800X480_R60_VSP,
	 {992, 800, 800, 192, 824, 72, 500, 480, 480, 20, 483, 7} }
};

/* 800x600*/
431
static struct crt_mode_table CRTM800x600[] = {
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
	/*r_rate,vclk,hsp,vsp     */
	/*HT,   HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_40_000M, M800X600_R60_HSP, M800X600_R60_VSP,
	 {1056, 800, 800, 256, 840, 128, 628, 600, 600, 28, 601, 4} },
	{REFRESH_75, CLK_49_500M, M800X600_R75_HSP, M800X600_R75_VSP,
	 {1056, 800, 800, 256, 816, 80, 625, 600, 600, 25, 601, 3} },
	{REFRESH_85, CLK_56_250M, M800X600_R85_HSP, M800X600_R85_VSP,
	 {1048, 800, 800, 248, 832, 64, 631, 600, 600, 31, 601, 3} },
	{REFRESH_100, CLK_68_179M, M800X600_R100_HSP, M800X600_R100_VSP,
	 {1072, 800, 800, 272, 848, 88, 636, 600, 600, 36, 601, 3} },
	{REFRESH_120, CLK_83_950M, M800X600_R120_HSP,
		  M800X600_R120_VSP,
		  {1088, 800, 800, 288, 856, 88, 643, 600, 600, 43, 601,
		   3} }
};

/* 848x480 (CVT) */
449
static struct crt_mode_table CRTM848x480[] = {
450 451 452 453 454 455 456
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_31_500M, M848X480_R60_HSP, M848X480_R60_VSP,
	 {1056, 848, 848, 208, 872, 80, 500, 480, 480, 20, 483, 5} }
};

/*856x480 (GTF) convert to 852x480*/
457
static struct crt_mode_table CRTM852x480[] = {
458 459 460 461 462 463 464
	/*r_rate,vclk,hsp,vsp     */
	/*HT,   HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_31_728M, M852X480_R60_HSP, M852X480_R60_VSP,
	{1064, 856, 856, 208, 872, 88, 497, 480, 480, 17, 481, 3} }
};

/*1024x512 (GTF)*/
465
static struct crt_mode_table CRTM1024x512[] = {
466 467 468 469 470 471 472 473
	/*r_rate,vclk,hsp,vsp     */
	/*HT,   HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_41_291M, M1024X512_R60_HSP, M1024X512_R60_VSP,
	 {1296, 1024, 1024, 272, 1056, 104, 531, 512, 512, 19, 513, 3} }

};

/* 1024x600*/
474
static struct crt_mode_table CRTM1024x600[] = {
475 476 477 478 479 480 481
	/*r_rate,vclk,hsp,vsp */
	/*HT,  HA,   HBS,  HBE, HSS,  HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_48_875M, M1024X600_R60_HSP, M1024X600_R60_VSP,
	 {1312, 1024, 1024, 288, 1064, 104, 622, 600, 600, 22, 601, 3} },
};

/* 1024x768*/
482
static struct crt_mode_table CRTM1024x768[] = {
483 484 485 486 487 488 489 490 491 492 493 494 495
	/*r_rate,vclk,hsp,vsp */
	/*HT,  HA,   HBS,  HBE, HSS,  HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_65_000M, M1024X768_R60_HSP, M1024X768_R60_VSP,
	{1344, 1024, 1024, 320, 1048, 136, 806, 768, 768, 38, 771, 6} },
	{REFRESH_75, CLK_78_750M, M1024X768_R75_HSP, M1024X768_R75_VSP,
	{1312, 1024, 1024, 288, 1040, 96, 800, 768, 768, 32, 769, 3} },
	{REFRESH_85, CLK_94_500M, M1024X768_R85_HSP, M1024X768_R85_VSP,
	{1376, 1024, 1024, 352, 1072, 96, 808, 768, 768, 40, 769, 3} },
	{REFRESH_100, CLK_113_309M, M1024X768_R100_HSP, M1024X768_R100_VSP,
	{1392, 1024, 1024, 368, 1096, 112, 814, 768, 768, 46, 769, 3} }
};

/* 1152x864*/
496
static struct crt_mode_table CRTM1152x864[] = {
497 498 499 500 501 502 503 504
	/*r_rate,vclk,hsp,vsp      */
	/*HT,  HA,   HBS,  HBE, HSS,  HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_75, CLK_108_000M, M1152X864_R75_HSP, M1152X864_R75_VSP,
	 {1600, 1152, 1152, 448, 1216, 128, 900, 864, 864, 36, 865, 3} }

};

/* 1280x720 (HDMI 720P)*/
505
static struct crt_mode_table CRTM1280x720[] = {
506 507 508 509 510 511 512 513 514
	/*r_rate,vclk,hsp,vsp */
	/*HT,  HA,   HBS,  HBE, HSS,  HSE, VT,  VA,  VBS, VBE, VSS, VSE      */
	{REFRESH_60, CLK_74_481M, M1280X720_R60_HSP, M1280X720_R60_VSP,
	 {1648, 1280, 1280, 368, 1392, 40, 750, 720, 720, 30, 725, 5} },
	{REFRESH_50, CLK_60_466M, M1280X720_R50_HSP, M1280X720_R50_VSP,
	 {1632, 1280, 1280, 352, 1328, 128, 741, 720, 720, 21, 721, 3} }
};

/*1280x768 (GTF)*/
515
static struct crt_mode_table CRTM1280x768[] = {
516 517 518 519 520 521 522 523 524
	/*r_rate,vclk,hsp,vsp     */
	/*HT,  HA,   HBS,  HBE, HSS,  HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_80_136M, M1280X768_R60_HSP, M1280X768_R60_VSP,
	 {1680, 1280, 1280, 400, 1344, 136, 795, 768, 768, 27, 769, 3} },
	{REFRESH_50, CLK_65_178M, M1280X768_R50_HSP, M1280X768_R50_VSP,
	 {1648, 1280, 1280, 368, 1336, 128, 791, 768, 768, 23, 769, 3} }
};

/* 1280x800 (CVT) */
525
static struct crt_mode_table CRTM1280x800[] = {
526 527 528 529 530 531 532
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_83_375M, M1280X800_R60_HSP, M1280X800_R60_VSP,
	 {1680, 1280, 1280, 400, 1352, 128, 831, 800, 800, 31, 803, 6} }
};

/*1280x960*/
533
static struct crt_mode_table CRTM1280x960[] = {
534 535 536 537 538 539 540
	/*r_rate,vclk,hsp,vsp */
	/*HT,  HA,   HBS,  HBE, HSS,  HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_108_000M, M1280X960_R60_HSP, M1280X960_R60_VSP,
	 {1800, 1280, 1280, 520, 1376, 112, 1000, 960, 960, 40, 961, 3} }
};

/* 1280x1024*/
541
static struct crt_mode_table CRTM1280x1024[] = {
542 543 544 545 546 547 548 549 550 551 552 553 554
	/*r_rate,vclk,,hsp,vsp */
	/*HT,  HA,   HBS,  HBE, HSS,  HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_108_000M, M1280X1024_R60_HSP, M1280X1024_R60_VSP,
	 {1688, 1280, 1280, 408, 1328, 112, 1066, 1024, 1024, 42, 1025,
	  3} },
	{REFRESH_75, CLK_135_000M, M1280X1024_R75_HSP, M1280X1024_R75_VSP,
	 {1688, 1280, 1280, 408, 1296, 144, 1066, 1024, 1024, 42, 1025,
	  3} },
	{REFRESH_85, CLK_157_500M, M1280X1024_R85_HSP, M1280X1024_R85_VSP,
	 {1728, 1280, 1280, 448, 1344, 160, 1072, 1024, 1024, 48, 1025, 3} }
};

/* 1368x768 (GTF) */
555
static struct crt_mode_table CRTM1368x768[] = {
556 557 558 559 560 561 562
	/* r_rate,  vclk, hsp, vsp */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_85_860M, M1368X768_R60_HSP, M1368X768_R60_VSP,
	 {1800, 1368, 1368, 432, 1440, 144, 795, 768, 768, 27, 769, 3} }
};

/*1440x1050 (GTF)*/
563
static struct crt_mode_table CRTM1440x1050[] = {
564 565 566 567 568 569 570
	/*r_rate,vclk,hsp,vsp      */
	/*HT,  HA,   HBS,  HBE, HSS,  HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_125_104M, M1440X1050_R60_HSP, M1440X1050_R60_VSP,
	 {1936, 1440, 1440, 496, 1536, 152, 1077, 1040, 1040, 37, 1041, 3} }
};

/* 1600x1200*/
571
static struct crt_mode_table CRTM1600x1200[] = {
572 573 574 575 576 577 578 579 580 581 582
	/*r_rate,vclk,hsp,vsp */
	/*HT,  HA,   HBS,  HBE, HSS,  HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_162_000M, M1600X1200_R60_HSP, M1600X1200_R60_VSP,
	 {2160, 1600, 1600, 560, 1664, 192, 1250, 1200, 1200, 50, 1201,
	  3} },
	{REFRESH_75, CLK_202_500M, M1600X1200_R75_HSP, M1600X1200_R75_VSP,
	 {2160, 1600, 1600, 560, 1664, 192, 1250, 1200, 1200, 50, 1201, 3} }

};

/* 1680x1050 (CVT) */
583
static struct crt_mode_table CRTM1680x1050[] = {
584 585 586 587 588 589 590 591 592 593
	/* r_rate,          vclk,              hsp,             vsp  */
	/* HT,  HA,  HBS, HBE, HSS, HSE,    VT,  VA,  VBS, VBE,  VSS, VSE */
	{REFRESH_60, CLK_146_760M, M1680x1050_R60_HSP, M1680x1050_R60_VSP,
	 {2240, 1680, 1680, 560, 1784, 176, 1089, 1050, 1050, 39, 1053,
	  6} },
	{REFRESH_75, CLK_187_000M, M1680x1050_R75_HSP, M1680x1050_R75_VSP,
	 {2272, 1680, 1680, 592, 1800, 176, 1099, 1050, 1050, 49, 1053, 6} }
};

/* 1680x1050 (CVT Reduce Blanking) */
594
static struct crt_mode_table CRTM1680x1050_RB[] = {
595 596 597 598 599 600 601 602
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE,    VT,  VA,  VBS, VBE,  VSS, VSE */
	{REFRESH_60, CLK_119_000M, M1680x1050_RB_R60_HSP,
	 M1680x1050_RB_R60_VSP,
	 {1840, 1680, 1680, 160, 1728, 32, 1080, 1050, 1050, 30, 1053, 6} }
};

/* 1920x1080 (CVT)*/
603
static struct crt_mode_table CRTM1920x1080[] = {
604 605 606 607 608 609 610
	/*r_rate,vclk,hsp,vsp */
	/*HT,  HA,   HBS,  HBE, HSS,  HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_172_798M, M1920X1080_R60_HSP, M1920X1080_R60_VSP,
	 {2576, 1920, 1920, 656, 2048, 200, 1120, 1080, 1080, 40, 1083, 5} }
};

/* 1920x1080 (CVT with Reduce Blanking) */
611
static struct crt_mode_table CRTM1920x1080_RB[] = {
612 613 614 615 616 617 618 619
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_138_400M, M1920X1080_RB_R60_HSP,
	 M1920X1080_RB_R60_VSP,
	 {2080, 1920, 1920, 160, 1968, 32, 1111, 1080, 1080, 31, 1083, 5} }
};

/* 1920x1440*/
620
static struct crt_mode_table CRTM1920x1440[] = {
621 622 623 624 625 626 627 628 629 630
	/*r_rate,vclk,hsp,vsp */
	/*HT,  HA,   HBS,  HBE, HSS,  HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_234_000M, M1920X1440_R60_HSP, M1920X1440_R60_VSP,
	 {2600, 1920, 1920, 680, 2048, 208, 1500, 1440, 1440, 60, 1441,
	  3} },
	{REFRESH_75, CLK_297_500M, M1920X1440_R75_HSP, M1920X1440_R75_VSP,
	 {2640, 1920, 1920, 720, 2064, 224, 1500, 1440, 1440, 60, 1441, 3} }
};

/* 1400x1050 (CVT) */
631
static struct crt_mode_table CRTM1400x1050[] = {
632 633 634 635 636 637 638 639 640 641
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE,  HSS, HSE,   VT,  VA,  VBS, VBE,  VSS, VSE */
	{REFRESH_60, CLK_121_750M, M1400X1050_R60_HSP, M1400X1050_R60_VSP,
	 {1864, 1400, 1400, 464, 1488, 144, 1089, 1050, 1050, 39, 1053,
	  4} },
	{REFRESH_75, CLK_156_000M, M1400X1050_R75_HSP, M1400X1050_R75_VSP,
	 {1896, 1400, 1400, 496, 1504, 144, 1099, 1050, 1050, 49, 1053, 4} }
};

/* 1400x1050 (CVT Reduce Blanking) */
642
static struct crt_mode_table CRTM1400x1050_RB[] = {
643 644 645 646 647 648 649 650
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE,  HSS, HSE,   VT,  VA,  VBS, VBE,  VSS, VSE */
	{REFRESH_60, CLK_101_000M, M1400X1050_RB_R60_HSP,
	 M1400X1050_RB_R60_VSP,
	 {1560, 1400, 1400, 160, 1448, 32, 1080, 1050, 1050, 30, 1053, 4} }
};

/* 960x600 (CVT) */
651
static struct crt_mode_table CRTM960x600[] = {
652 653 654 655 656 657 658
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_45_250M, M960X600_R60_HSP, M960X600_R60_VSP,
	 {1216, 960, 960, 256, 992, 96, 624, 600, 600, 24, 603, 6} }
};

/* 1000x600 (GTF) */
659
static struct crt_mode_table CRTM1000x600[] = {
660 661 662 663 664 665 666
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_48_000M, M1000X600_R60_HSP, M1000X600_R60_VSP,
	 {1288, 1000, 1000, 288, 1040, 104, 622, 600, 600, 22, 601, 3} }
};

/* 1024x576 (GTF) */
667
static struct crt_mode_table CRTM1024x576[] = {
668 669 670 671 672 673 674
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_46_996M, M1024X576_R60_HSP, M1024X576_R60_VSP,
	 {1312, 1024, 1024, 288, 1064, 104, 597, 576, 576, 21, 577, 3} }
};

/* 1088x612 (CVT) */
675
static struct crt_mode_table CRTM1088x612[] = {
676 677 678 679 680 681 682
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_52_977M, M1088X612_R60_HSP, M1088X612_R60_VSP,
	 {1392, 1088, 1088, 304, 1136, 104, 636, 612, 612, 24, 615, 5} }
};

/* 1152x720 (CVT) */
683
static struct crt_mode_table CRTM1152x720[] = {
684 685 686 687 688 689 690
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_66_750M, M1152X720_R60_HSP, M1152X720_R60_VSP,
	 {1488, 1152, 1152, 336, 1208, 112, 748, 720, 720, 28, 723, 6} }
};

/* 1200x720 (GTF) */
691
static struct crt_mode_table CRTM1200x720[] = {
692 693 694 695 696 697
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_70_159M, M1200X720_R60_HSP, M1200X720_R60_VSP,
	 {1568, 1200, 1200, 368, 1256, 128, 746, 720, 720, 26, 721, 3} }
};

698
/* 1200x900 (DCON) */
699
static struct crt_mode_table DCON1200x900[] = {
700 701 702 703 704 705 706 707
	/* r_rate,          vclk,               hsp,               vsp   */
	{REFRESH_60, CLK_57_275M, M1200X900_R60_HSP, M1200X900_R60_VSP,
	/* The correct htotal is 1240, but this doesn't raster on VX855. */
	/* Via suggested changing to a multiple of 16, hence 1264.       */
	/*  HT,   HA,  HBS, HBE,  HSS, HSE,  VT,  VA, VBS, VBE, VSS, VSE */
	 {1264, 1200, 1200,  64, 1211,  32, 912, 900, 900,  12, 901, 10} }
};

708
/* 1280x600 (GTF) */
709
static struct crt_mode_table CRTM1280x600[] = {
710 711 712 713 714 715 716
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE,  HSS, HSE, VT,  VA,  VBS, VBE,  VSS, VSE */
	{REFRESH_60, CLK_61_500M, M1280x600_R60_HSP, M1280x600_R60_VSP,
	 {1648, 1280, 1280, 368, 1336, 128, 622, 600, 600, 22, 601, 3} }
};

/* 1360x768 (CVT) */
717
static struct crt_mode_table CRTM1360x768[] = {
718 719 720 721 722 723 724
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_84_750M, M1360X768_R60_HSP, M1360X768_R60_VSP,
	 {1776, 1360, 1360, 416, 1432, 136, 798, 768, 768, 30, 771, 5} }
};

/* 1360x768 (CVT Reduce Blanking) */
725
static struct crt_mode_table CRTM1360x768_RB[] = {
726 727 728 729 730 731 732 733
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_72_000M, M1360X768_RB_R60_HSP,
	 M1360X768_RB_R60_VSP,
	 {1520, 1360, 1360, 160, 1408, 32, 790, 768, 768, 22, 771, 5} }
};

/* 1366x768 (GTF) */
734
static struct crt_mode_table CRTM1366x768[] = {
735 736 737 738 739 740 741 742 743
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_85_860M, M1368X768_R60_HSP, M1368X768_R60_VSP,
	 {1800, 1368, 1368, 432, 1440, 144, 795, 768, 768, 27, 769, 3} },
	{REFRESH_50, CLK_69_924M, M1368X768_R50_HSP, M1368X768_R50_VSP,
	 {1768, 1368, 1368, 400, 1424, 144, 791, 768, 768, 23, 769, 3} }
};

/* 1440x900 (CVT) */
744
static struct crt_mode_table CRTM1440x900[] = {
745 746 747 748 749 750 751 752 753
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_106_500M, M1440X900_R60_HSP, M1440X900_R60_VSP,
	 {1904, 1440, 1440, 464, 1520, 152, 934, 900, 900, 34, 903, 6} },
	{REFRESH_75, CLK_136_700M, M1440X900_R75_HSP, M1440X900_R75_VSP,
	 {1936, 1440, 1440, 496, 1536, 152, 942, 900, 900, 42, 903, 6} }
};

/* 1440x900 (CVT Reduce Blanking) */
754
static struct crt_mode_table CRTM1440x900_RB[] = {
755 756 757 758 759 760 761 762
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_88_750M, M1440X900_RB_R60_HSP,
	 M1440X900_RB_R60_VSP,
	 {1600, 1440, 1440, 160, 1488, 32, 926, 900, 900, 26, 903, 6} }
};

/* 1600x900 (CVT) */
763
static struct crt_mode_table CRTM1600x900[] = {
764 765 766 767 768 769 770
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_118_840M, M1600X900_R60_HSP, M1600X900_R60_VSP,
	 {2112, 1600, 1600, 512, 1688, 168, 934, 900, 900, 34, 903, 5} }
};

/* 1600x900 (CVT Reduce Blanking) */
771
static struct crt_mode_table CRTM1600x900_RB[] = {
772 773 774 775 776 777 778 779
	/* r_rate,        vclk,           hsp,        vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_97_750M, M1600X900_RB_R60_HSP,
	 M1600X900_RB_R60_VSP,
	 {1760, 1600, 1600, 160, 1648, 32, 926, 900, 900, 26, 903, 5} }
};

/* 1600x1024 (GTF) */
780
static struct crt_mode_table CRTM1600x1024[] = {
781 782 783 784 785 786 787
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE,  HSS, HSE,   VT,  VA,  VBS, VBE,  VSS, VSE */
	{REFRESH_60, CLK_136_700M, M1600X1024_R60_HSP, M1600X1024_R60_VSP,
	 {2144, 1600, 1600, 544, 1704, 168, 1060, 1024, 1024, 36, 1025, 3} }
};

/* 1792x1344 (DMT) */
788
static struct crt_mode_table CRTM1792x1344[] = {
789 790 791 792 793 794 795
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE,  HSS, HSE,   VT,  VA,  VBS, VBE,  VSS, VSE */
	{REFRESH_60, CLK_204_000M, M1792x1344_R60_HSP, M1792x1344_R60_VSP,
	 {2448, 1792, 1792, 656, 1920, 200, 1394, 1344, 1344, 50, 1345, 3} }
};

/* 1856x1392 (DMT) */
796
static struct crt_mode_table CRTM1856x1392[] = {
797 798 799 800 801 802 803
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE,  HSS, HSE,   VT,  VA,  VBS, VBE,  VSS, VSE */
	{REFRESH_60, CLK_218_500M, M1856x1392_R60_HSP, M1856x1392_R60_VSP,
	 {2528, 1856, 1856, 672, 1952, 224, 1439, 1392, 1392, 47, 1393, 3} }
};

/* 1920x1200 (CVT) */
804
static struct crt_mode_table CRTM1920x1200[] = {
805 806 807 808 809 810 811
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_193_295M, M1920X1200_R60_HSP, M1920X1200_R60_VSP,
	 {2592, 1920, 1920, 672, 2056, 200, 1245, 1200, 1200, 45, 1203, 6} }
};

/* 1920x1200 (CVT with Reduce Blanking) */
812
static struct crt_mode_table CRTM1920x1200_RB[] = {
813 814 815 816 817 818 819 820
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE, HSS, HSE, VT,  VA,  VBS, VBE, VSS, VSE */
	{REFRESH_60, CLK_153_920M, M1920X1200_RB_R60_HSP,
	 M1920X1200_RB_R60_VSP,
	 {2080, 1920, 1920, 160, 1968, 32, 1235, 1200, 1200, 35, 1203, 6} }
};

/* 2048x1536 (CVT) */
821
static struct crt_mode_table CRTM2048x1536[] = {
822 823 824 825 826 827
	/* r_rate,          vclk,              hsp,             vsp   */
	/* HT,  HA,  HBS, HBE,  HSS, HSE,   VT,  VA,  VBS, VBE,  VSS, VSE */
	{REFRESH_60, CLK_267_250M, M2048x1536_R60_HSP, M2048x1536_R60_VSP,
	 {2800, 2048, 2048, 752, 2200, 224, 1592, 1536, 1536, 56, 1539, 4} }
};

828
static struct VideoModeTable viafb_modes[] = {
829
	/* Display : 480x640 (GTF) */
830
	{CRTM480x640, ARRAY_SIZE(CRTM480x640)},
831 832

	/* Display : 640x480 */
833
	{CRTM640x480, ARRAY_SIZE(CRTM640x480)},
834 835

	/* Display : 720x480 (GTF) */
836
	{CRTM720x480, ARRAY_SIZE(CRTM720x480)},
837 838

	/* Display : 720x576 (GTF) */
839
	{CRTM720x576, ARRAY_SIZE(CRTM720x576)},
840 841

	/* Display : 800x600 */
842
	{CRTM800x600, ARRAY_SIZE(CRTM800x600)},
843 844

	/* Display : 800x480 (CVT) */
845
	{CRTM800x480, ARRAY_SIZE(CRTM800x480)},
846 847

	/* Display : 848x480 (CVT) */
848
	{CRTM848x480, ARRAY_SIZE(CRTM848x480)},
849 850

	/* Display : 852x480 (GTF) */
851
	{CRTM852x480, ARRAY_SIZE(CRTM852x480)},
852 853

	/* Display : 1024x512 (GTF) */
854
	{CRTM1024x512, ARRAY_SIZE(CRTM1024x512)},
855 856

	/* Display : 1024x600 */
857
	{CRTM1024x600, ARRAY_SIZE(CRTM1024x600)},
858 859

	/* Display : 1024x768 */
860
	{CRTM1024x768, ARRAY_SIZE(CRTM1024x768)},
861 862

	/* Display : 1152x864 */
863
	{CRTM1152x864, ARRAY_SIZE(CRTM1152x864)},
864 865

	/* Display : 1280x768 (GTF) */
866
	{CRTM1280x768, ARRAY_SIZE(CRTM1280x768)},
867 868

	/* Display : 960x600 (CVT) */
869
	{CRTM960x600, ARRAY_SIZE(CRTM960x600)},
870 871

	/* Display : 1000x600 (GTF) */
872
	{CRTM1000x600, ARRAY_SIZE(CRTM1000x600)},
873 874

	/* Display : 1024x576 (GTF) */
875
	{CRTM1024x576, ARRAY_SIZE(CRTM1024x576)},
876 877

	/* Display : 1088x612 (GTF) */
878
	{CRTM1088x612, ARRAY_SIZE(CRTM1088x612)},
879 880

	/* Display : 1152x720 (CVT) */
881
	{CRTM1152x720, ARRAY_SIZE(CRTM1152x720)},
882 883

	/* Display : 1200x720 (GTF) */
884
	{CRTM1200x720, ARRAY_SIZE(CRTM1200x720)},
885

886 887 888
	/* Display : 1200x900 (DCON) */
	{DCON1200x900, ARRAY_SIZE(DCON1200x900)},

889
	/* Display : 1280x600 (GTF) */
890
	{CRTM1280x600, ARRAY_SIZE(CRTM1280x600)},
891 892

	/* Display : 1280x800 (CVT) */
893
	{CRTM1280x800, ARRAY_SIZE(CRTM1280x800)},
894 895

	/* Display : 1280x960 */
896
	{CRTM1280x960, ARRAY_SIZE(CRTM1280x960)},
897 898

	/* Display : 1280x1024 */
899
	{CRTM1280x1024, ARRAY_SIZE(CRTM1280x1024)},
900 901

	/* Display : 1360x768 (CVT) */
902
	{CRTM1360x768, ARRAY_SIZE(CRTM1360x768)},
903 904

	/* Display : 1366x768 */
905
	{CRTM1366x768, ARRAY_SIZE(CRTM1366x768)},
906 907

	/* Display : 1368x768 (GTF) */
908
	{CRTM1368x768, ARRAY_SIZE(CRTM1368x768)},
909 910

	/* Display : 1440x900 (CVT) */
911
	{CRTM1440x900, ARRAY_SIZE(CRTM1440x900)},
912 913

	/* Display : 1440x1050 (GTF) */
914
	{CRTM1440x1050, ARRAY_SIZE(CRTM1440x1050)},
915 916

	/* Display : 1600x900 (CVT) */
917
	{CRTM1600x900, ARRAY_SIZE(CRTM1600x900)},
918 919

	/* Display : 1600x1024 (GTF) */
920
	{CRTM1600x1024, ARRAY_SIZE(CRTM1600x1024)},
921 922

	/* Display : 1600x1200 */
923
	{CRTM1600x1200, ARRAY_SIZE(CRTM1600x1200)},
924 925

	/* Display : 1680x1050 (CVT) */
926
	{CRTM1680x1050, ARRAY_SIZE(CRTM1680x1050)},
927 928

	/* Display : 1792x1344 (DMT) */
929
	{CRTM1792x1344, ARRAY_SIZE(CRTM1792x1344)},
930 931

	/* Display : 1856x1392 (DMT) */
932
	{CRTM1856x1392, ARRAY_SIZE(CRTM1856x1392)},
933 934

	/* Display : 1920x1440 */
935
	{CRTM1920x1440, ARRAY_SIZE(CRTM1920x1440)},
936 937

	/* Display : 2048x1536 */
938
	{CRTM2048x1536, ARRAY_SIZE(CRTM2048x1536)},
939 940

	/* Display : 1280x720 */
941
	{CRTM1280x720, ARRAY_SIZE(CRTM1280x720)},
942 943

	/* Display : 1920x1080 (CVT) */
944
	{CRTM1920x1080, ARRAY_SIZE(CRTM1920x1080)},
945 946

	/* Display : 1920x1200 (CVT) */
947
	{CRTM1920x1200, ARRAY_SIZE(CRTM1920x1200)},
948 949

	/* Display : 1400x1050 (CVT) */
950
	{CRTM1400x1050, ARRAY_SIZE(CRTM1400x1050)}
951
};
952

953
static struct VideoModeTable viafb_rb_modes[] = {
954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975
	/* Display : 1360x768 (CVT Reduce Blanking) */
	{CRTM1360x768_RB, ARRAY_SIZE(CRTM1360x768_RB)},

	/* Display : 1440x900 (CVT Reduce Blanking) */
	{CRTM1440x900_RB, ARRAY_SIZE(CRTM1440x900_RB)},

	/* Display : 1400x1050 (CVT Reduce Blanking) */
	{CRTM1400x1050_RB, ARRAY_SIZE(CRTM1400x1050_RB)},

	/* Display : 1600x900 (CVT Reduce Blanking) */
	{CRTM1600x900_RB, ARRAY_SIZE(CRTM1600x900_RB)},

	/* Display : 1680x1050 (CVT Reduce Blanking) */
	{CRTM1680x1050_RB, ARRAY_SIZE(CRTM1680x1050_RB)},

	/* Display : 1920x1080 (CVT Reduce Blanking) */
	{CRTM1920x1080_RB, ARRAY_SIZE(CRTM1920x1080_RB)},

	/* Display : 1920x1200 (CVT Reduce Blanking) */
	{CRTM1920x1200_RB, ARRAY_SIZE(CRTM1920x1200_RB)}
};

976 977 978 979 980 981 982 983 984 985 986 987 988 989
struct crt_mode_table CEAM1280x720[] = {
	{REFRESH_60, CLK_74_270M, M1280X720_CEA_R60_HSP,
	 M1280X720_CEA_R60_VSP,
	 /* HT,    HA,   HBS,  HBE,  HSS, HSE,  VT,   VA,  VBS, VBE, VSS, VSE */
	 {1650, 1280, 1280, 370, 1390, 40, 750, 720, 720, 30, 725, 5} }
};
struct crt_mode_table CEAM1920x1080[] = {
	{REFRESH_60, CLK_148_500M, M1920X1080_CEA_R60_HSP,
	 M1920X1080_CEA_R60_VSP,
	 /* HT,    HA,   HBS,  HBE,  HSS, HSE,  VT,  VA, VBS, VBE,  VSS, VSE */
	 {2200, 1920, 1920, 300, 2008, 44, 1125, 1080, 1080, 45, 1084, 5} }
};
struct VideoModeTable CEA_HDMI_Modes[] = {
	/* Display : 1280x720 */
990 991
	{CEAM1280x720, ARRAY_SIZE(CEAM1280x720)},
	{CEAM1920x1080, ARRAY_SIZE(CEAM1920x1080)}
992
};
993 994 995 996 997 998

int NUM_TOTAL_CEA_MODES = ARRAY_SIZE(CEA_HDMI_Modes);
int NUM_TOTAL_CN400_ModeXregs = ARRAY_SIZE(CN400_ModeXregs);
int NUM_TOTAL_CN700_ModeXregs = ARRAY_SIZE(CN700_ModeXregs);
int NUM_TOTAL_KM400_ModeXregs = ARRAY_SIZE(KM400_ModeXregs);
int NUM_TOTAL_CX700_ModeXregs = ARRAY_SIZE(CX700_ModeXregs);
999
int NUM_TOTAL_VX855_ModeXregs = ARRAY_SIZE(VX855_ModeXregs);
1000 1001
int NUM_TOTAL_CLE266_ModeXregs = ARRAY_SIZE(CLE266_ModeXregs);
int NUM_TOTAL_PATCH_MODE = ARRAY_SIZE(res_patch_table);
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026


struct VideoModeTable *viafb_get_mode(int hres, int vres)
{
	u32 i;
	for (i = 0; i < ARRAY_SIZE(viafb_modes); i++)
		if (viafb_modes[i].mode_array &&
			viafb_modes[i].crtc[0].crtc.hor_addr == hres &&
			viafb_modes[i].crtc[0].crtc.ver_addr == vres)
			return &viafb_modes[i];

	return NULL;
}

struct VideoModeTable *viafb_get_rb_mode(int hres, int vres)
{
	u32 i;
	for (i = 0; i < ARRAY_SIZE(viafb_rb_modes); i++)
		if (viafb_rb_modes[i].mode_array &&
			viafb_rb_modes[i].crtc[0].crtc.hor_addr == hres &&
			viafb_rb_modes[i].crtc[0].crtc.ver_addr == vres)
			return &viafb_rb_modes[i];

	return NULL;
}