162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. 462306a36Sopenharmony_ci * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#include <linux/via-core.h> 962306a36Sopenharmony_ci#include "global.h" 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_cistruct io_reg CN400_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01}, 1262306a36Sopenharmony_ci{VIASR, SR15, 0x02, 0x02}, 1362306a36Sopenharmony_ci{VIASR, SR16, 0xBF, 0x08}, 1462306a36Sopenharmony_ci{VIASR, SR17, 0xFF, 0x1F}, 1562306a36Sopenharmony_ci{VIASR, SR18, 0xFF, 0x4E}, 1662306a36Sopenharmony_ci{VIASR, SR1A, 0xFB, 0x08}, 1762306a36Sopenharmony_ci{VIASR, SR1E, 0x0F, 0x01}, 1862306a36Sopenharmony_ci{VIASR, SR2A, 0xFF, 0x00}, 1962306a36Sopenharmony_ci{VIACR, CR32, 0xFF, 0x00}, 2062306a36Sopenharmony_ci{VIACR, CR33, 0xFF, 0x00}, 2162306a36Sopenharmony_ci{VIACR, CR35, 0xFF, 0x00}, 2262306a36Sopenharmony_ci{VIACR, CR36, 0x08, 0x00}, 2362306a36Sopenharmony_ci{VIACR, CR69, 0xFF, 0x00}, 2462306a36Sopenharmony_ci{VIACR, CR6A, 0xFF, 0x40}, 2562306a36Sopenharmony_ci{VIACR, CR6B, 0xFF, 0x00}, 2662306a36Sopenharmony_ci{VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ 2762306a36Sopenharmony_ci{VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ 2862306a36Sopenharmony_ci{VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ 2962306a36Sopenharmony_ci{VIACR, CR8B, 0xFF, 0x69}, /* LCD Power Sequence Control 0 */ 3062306a36Sopenharmony_ci{VIACR, CR8C, 0xFF, 0x57}, /* LCD Power Sequence Control 1 */ 3162306a36Sopenharmony_ci{VIACR, CR8D, 0xFF, 0x00}, /* LCD Power Sequence Control 2 */ 3262306a36Sopenharmony_ci{VIACR, CR8E, 0xFF, 0x7B}, /* LCD Power Sequence Control 3 */ 3362306a36Sopenharmony_ci{VIACR, CR8F, 0xFF, 0x03}, /* LCD Power Sequence Control 4 */ 3462306a36Sopenharmony_ci{VIACR, CR90, 0xFF, 0x30}, /* LCD Power Sequence Control 5 */ 3562306a36Sopenharmony_ci{VIACR, CR91, 0xFF, 0xA0}, /* 24/12 bit LVDS Data off */ 3662306a36Sopenharmony_ci{VIACR, CR96, 0xFF, 0x00}, 3762306a36Sopenharmony_ci{VIACR, CR97, 0xFF, 0x00}, 3862306a36Sopenharmony_ci{VIACR, CR99, 0xFF, 0x00}, 3962306a36Sopenharmony_ci{VIACR, CR9B, 0xFF, 0x00} 4062306a36Sopenharmony_ci}; 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* Video Mode Table for VT3314 chipset*/ 4362306a36Sopenharmony_ci/* Common Setting for Video Mode */ 4462306a36Sopenharmony_cistruct io_reg CN700_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01}, 4562306a36Sopenharmony_ci{VIASR, SR15, 0x02, 0x02}, 4662306a36Sopenharmony_ci{VIASR, SR16, 0xBF, 0x08}, 4762306a36Sopenharmony_ci{VIASR, SR17, 0xFF, 0x1F}, 4862306a36Sopenharmony_ci{VIASR, SR18, 0xFF, 0x4E}, 4962306a36Sopenharmony_ci{VIASR, SR1A, 0xFB, 0x82}, 5062306a36Sopenharmony_ci{VIASR, SR1B, 0xFF, 0xF0}, 5162306a36Sopenharmony_ci{VIASR, SR1F, 0xFF, 0x00}, 5262306a36Sopenharmony_ci{VIASR, SR1E, 0xFF, 0x01}, 5362306a36Sopenharmony_ci{VIASR, SR22, 0xFF, 0x1F}, 5462306a36Sopenharmony_ci{VIASR, SR2A, 0x0F, 0x00}, 5562306a36Sopenharmony_ci{VIASR, SR2E, 0xFF, 0xFF}, 5662306a36Sopenharmony_ci{VIASR, SR3F, 0xFF, 0xFF}, 5762306a36Sopenharmony_ci{VIASR, SR40, 0xF7, 0x00}, 5862306a36Sopenharmony_ci{VIASR, CR30, 0xFF, 0x04}, 5962306a36Sopenharmony_ci{VIACR, CR32, 0xFF, 0x00}, 6062306a36Sopenharmony_ci{VIACR, CR33, 0x7F, 0x00}, 6162306a36Sopenharmony_ci{VIACR, CR35, 0xFF, 0x00}, 6262306a36Sopenharmony_ci{VIACR, CR36, 0xFF, 0x31}, 6362306a36Sopenharmony_ci{VIACR, CR41, 0xFF, 0x80}, 6462306a36Sopenharmony_ci{VIACR, CR42, 0xFF, 0x00}, 6562306a36Sopenharmony_ci{VIACR, CR55, 0x80, 0x00}, 6662306a36Sopenharmony_ci{VIACR, CR5D, 0x80, 0x00}, /*Horizontal Retrace Start bit[11] should be 0*/ 6762306a36Sopenharmony_ci{VIACR, CR68, 0xFF, 0x67}, /* Default FIFO For IGA2 */ 6862306a36Sopenharmony_ci{VIACR, CR69, 0xFF, 0x00}, 6962306a36Sopenharmony_ci{VIACR, CR6A, 0xFD, 0x40}, 7062306a36Sopenharmony_ci{VIACR, CR6B, 0xFF, 0x00}, 7162306a36Sopenharmony_ci{VIACR, CR77, 0xFF, 0x00}, /* LCD scaling Factor */ 7262306a36Sopenharmony_ci{VIACR, CR78, 0xFF, 0x00}, /* LCD scaling Factor */ 7362306a36Sopenharmony_ci{VIACR, CR79, 0xFF, 0x00}, /* LCD scaling Factor */ 7462306a36Sopenharmony_ci{VIACR, CR9F, 0x03, 0x00}, /* LCD scaling Factor */ 7562306a36Sopenharmony_ci{VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ 7662306a36Sopenharmony_ci{VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ 7762306a36Sopenharmony_ci{VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ 7862306a36Sopenharmony_ci{VIACR, CR8B, 0xFF, 0x5D}, /* LCD Power Sequence Control 0 */ 7962306a36Sopenharmony_ci{VIACR, CR8C, 0xFF, 0x2B}, /* LCD Power Sequence Control 1 */ 8062306a36Sopenharmony_ci{VIACR, CR8D, 0xFF, 0x6F}, /* LCD Power Sequence Control 2 */ 8162306a36Sopenharmony_ci{VIACR, CR8E, 0xFF, 0x2B}, /* LCD Power Sequence Control 3 */ 8262306a36Sopenharmony_ci{VIACR, CR8F, 0xFF, 0x01}, /* LCD Power Sequence Control 4 */ 8362306a36Sopenharmony_ci{VIACR, CR90, 0xFF, 0x01}, /* LCD Power Sequence Control 5 */ 8462306a36Sopenharmony_ci{VIACR, CR91, 0xFF, 0xA0}, /* 24/12 bit LVDS Data off */ 8562306a36Sopenharmony_ci{VIACR, CR96, 0xFF, 0x00}, 8662306a36Sopenharmony_ci{VIACR, CR97, 0xFF, 0x00}, 8762306a36Sopenharmony_ci{VIACR, CR99, 0xFF, 0x00}, 8862306a36Sopenharmony_ci{VIACR, CR9B, 0xFF, 0x00}, 8962306a36Sopenharmony_ci{VIACR, CR9D, 0xFF, 0x80}, 9062306a36Sopenharmony_ci{VIACR, CR9E, 0xFF, 0x80} 9162306a36Sopenharmony_ci}; 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_cistruct io_reg KM400_ModeXregs[] = { 9462306a36Sopenharmony_ci {VIASR, SR10, 0xFF, 0x01}, /* Unlock Register */ 9562306a36Sopenharmony_ci {VIASR, SR16, 0xFF, 0x08}, /* Display FIFO threshold Control */ 9662306a36Sopenharmony_ci {VIASR, SR17, 0xFF, 0x1F}, /* Display FIFO Control */ 9762306a36Sopenharmony_ci {VIASR, SR18, 0xFF, 0x4E}, /* GFX PREQ threshold */ 9862306a36Sopenharmony_ci {VIASR, SR1A, 0xFF, 0x0a}, /* GFX PREQ threshold */ 9962306a36Sopenharmony_ci {VIASR, SR1F, 0xFF, 0x00}, /* Memory Control 0 */ 10062306a36Sopenharmony_ci {VIASR, SR1B, 0xFF, 0xF0}, /* Power Management Control 0 */ 10162306a36Sopenharmony_ci {VIASR, SR1E, 0xFF, 0x01}, /* Power Management Control */ 10262306a36Sopenharmony_ci {VIASR, SR20, 0xFF, 0x00}, /* Sequencer Arbiter Control 0 */ 10362306a36Sopenharmony_ci {VIASR, SR21, 0xFF, 0x00}, /* Sequencer Arbiter Control 1 */ 10462306a36Sopenharmony_ci {VIASR, SR22, 0xFF, 0x1F}, /* Display Arbiter Control 1 */ 10562306a36Sopenharmony_ci {VIASR, SR2A, 0xFF, 0x00}, /* Power Management Control 5 */ 10662306a36Sopenharmony_ci {VIASR, SR2D, 0xFF, 0xFF}, /* Power Management Control 1 */ 10762306a36Sopenharmony_ci {VIASR, SR2E, 0xFF, 0xFF}, /* Power Management Control 2 */ 10862306a36Sopenharmony_ci {VIACR, CR33, 0xFF, 0x00}, 10962306a36Sopenharmony_ci {VIACR, CR55, 0x80, 0x00}, 11062306a36Sopenharmony_ci {VIACR, CR5D, 0x80, 0x00}, 11162306a36Sopenharmony_ci {VIACR, CR36, 0xFF, 0x01}, /* Power Mangement 3 */ 11262306a36Sopenharmony_ci {VIACR, CR68, 0xFF, 0x67}, /* Default FIFO For IGA2 */ 11362306a36Sopenharmony_ci {VIACR, CR6A, 0x20, 0x20}, /* Extended FIFO On */ 11462306a36Sopenharmony_ci {VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ 11562306a36Sopenharmony_ci {VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ 11662306a36Sopenharmony_ci {VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ 11762306a36Sopenharmony_ci {VIACR, CR8B, 0xFF, 0x2D}, /* LCD Power Sequence Control 0 */ 11862306a36Sopenharmony_ci {VIACR, CR8C, 0xFF, 0x2D}, /* LCD Power Sequence Control 1 */ 11962306a36Sopenharmony_ci {VIACR, CR8D, 0xFF, 0xC8}, /* LCD Power Sequence Control 2 */ 12062306a36Sopenharmony_ci {VIACR, CR8E, 0xFF, 0x36}, /* LCD Power Sequence Control 3 */ 12162306a36Sopenharmony_ci {VIACR, CR8F, 0xFF, 0x00}, /* LCD Power Sequence Control 4 */ 12262306a36Sopenharmony_ci {VIACR, CR90, 0xFF, 0x10}, /* LCD Power Sequence Control 5 */ 12362306a36Sopenharmony_ci {VIACR, CR91, 0xFF, 0xA0}, /* 24/12 bit LVDS Data off */ 12462306a36Sopenharmony_ci {VIACR, CR96, 0xFF, 0x03}, /* DVP0 ; DVP0 Clock Skew */ 12562306a36Sopenharmony_ci {VIACR, CR97, 0xFF, 0x03}, /* DFP high ; DFPH Clock Skew */ 12662306a36Sopenharmony_ci {VIACR, CR99, 0xFF, 0x03}, /* DFP low ; DFPL Clock Skew*/ 12762306a36Sopenharmony_ci {VIACR, CR9B, 0xFF, 0x07} /* DVI on DVP1 ; DVP1 Clock Skew*/ 12862306a36Sopenharmony_ci}; 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci/* For VT3324: Common Setting for Video Mode */ 13162306a36Sopenharmony_cistruct io_reg CX700_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01}, 13262306a36Sopenharmony_ci{VIASR, SR15, 0x02, 0x02}, 13362306a36Sopenharmony_ci{VIASR, SR16, 0xBF, 0x08}, 13462306a36Sopenharmony_ci{VIASR, SR17, 0xFF, 0x1F}, 13562306a36Sopenharmony_ci{VIASR, SR18, 0xFF, 0x4E}, 13662306a36Sopenharmony_ci{VIASR, SR1A, 0xFB, 0x08}, 13762306a36Sopenharmony_ci{VIASR, SR1B, 0xFF, 0xF0}, 13862306a36Sopenharmony_ci{VIASR, SR1E, 0xFF, 0x01}, 13962306a36Sopenharmony_ci{VIASR, SR2A, 0xFF, 0x00}, 14062306a36Sopenharmony_ci{VIASR, SR2D, 0xC0, 0xC0}, /* delayed E3_ECK */ 14162306a36Sopenharmony_ci{VIACR, CR32, 0xFF, 0x00}, 14262306a36Sopenharmony_ci{VIACR, CR33, 0xFF, 0x00}, 14362306a36Sopenharmony_ci{VIACR, CR35, 0xFF, 0x00}, 14462306a36Sopenharmony_ci{VIACR, CR36, 0x08, 0x00}, 14562306a36Sopenharmony_ci{VIACR, CR47, 0xC8, 0x00}, /* Clear VCK Plus. */ 14662306a36Sopenharmony_ci{VIACR, CR69, 0xFF, 0x00}, 14762306a36Sopenharmony_ci{VIACR, CR6A, 0xFF, 0x40}, 14862306a36Sopenharmony_ci{VIACR, CR6B, 0xFF, 0x00}, 14962306a36Sopenharmony_ci{VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ 15062306a36Sopenharmony_ci{VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ 15162306a36Sopenharmony_ci{VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ 15262306a36Sopenharmony_ci{VIACR, CRD4, 0xFF, 0x81}, /* Second power sequence control */ 15362306a36Sopenharmony_ci{VIACR, CR8B, 0xFF, 0x5D}, /* LCD Power Sequence Control 0 */ 15462306a36Sopenharmony_ci{VIACR, CR8C, 0xFF, 0x2B}, /* LCD Power Sequence Control 1 */ 15562306a36Sopenharmony_ci{VIACR, CR8D, 0xFF, 0x6F}, /* LCD Power Sequence Control 2 */ 15662306a36Sopenharmony_ci{VIACR, CR8E, 0xFF, 0x2B}, /* LCD Power Sequence Control 3 */ 15762306a36Sopenharmony_ci{VIACR, CR8F, 0xFF, 0x01}, /* LCD Power Sequence Control 4 */ 15862306a36Sopenharmony_ci{VIACR, CR90, 0xFF, 0x01}, /* LCD Power Sequence Control 5 */ 15962306a36Sopenharmony_ci{VIACR, CR91, 0xFF, 0x80}, /* 24/12 bit LVDS Data off */ 16062306a36Sopenharmony_ci{VIACR, CR96, 0xFF, 0x00}, 16162306a36Sopenharmony_ci{VIACR, CR97, 0xFF, 0x00}, 16262306a36Sopenharmony_ci{VIACR, CR99, 0xFF, 0x00}, 16362306a36Sopenharmony_ci{VIACR, CR9B, 0xFF, 0x00} 16462306a36Sopenharmony_ci}; 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_cistruct io_reg VX855_ModeXregs[] = { 16762306a36Sopenharmony_ci{VIASR, SR10, 0xFF, 0x01}, 16862306a36Sopenharmony_ci{VIASR, SR15, 0x02, 0x02}, 16962306a36Sopenharmony_ci{VIASR, SR16, 0xBF, 0x08}, 17062306a36Sopenharmony_ci{VIASR, SR17, 0xFF, 0x1F}, 17162306a36Sopenharmony_ci{VIASR, SR18, 0xFF, 0x4E}, 17262306a36Sopenharmony_ci{VIASR, SR1A, 0xFB, 0x08}, 17362306a36Sopenharmony_ci{VIASR, SR1B, 0xFF, 0xF0}, 17462306a36Sopenharmony_ci{VIASR, SR1E, 0x07, 0x01}, 17562306a36Sopenharmony_ci{VIASR, SR2A, 0xF0, 0x00}, 17662306a36Sopenharmony_ci{VIASR, SR58, 0xFF, 0x00}, 17762306a36Sopenharmony_ci{VIASR, SR59, 0xFF, 0x00}, 17862306a36Sopenharmony_ci{VIASR, SR2D, 0xC0, 0xC0}, /* delayed E3_ECK */ 17962306a36Sopenharmony_ci{VIACR, CR32, 0xFF, 0x00}, 18062306a36Sopenharmony_ci{VIACR, CR33, 0x7F, 0x00}, 18162306a36Sopenharmony_ci{VIACR, CR35, 0xFF, 0x00}, 18262306a36Sopenharmony_ci{VIACR, CR36, 0x08, 0x00}, 18362306a36Sopenharmony_ci{VIACR, CR69, 0xFF, 0x00}, 18462306a36Sopenharmony_ci{VIACR, CR6A, 0xFD, 0x60}, 18562306a36Sopenharmony_ci{VIACR, CR6B, 0xFF, 0x00}, 18662306a36Sopenharmony_ci{VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ 18762306a36Sopenharmony_ci{VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ 18862306a36Sopenharmony_ci{VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ 18962306a36Sopenharmony_ci{VIACR, CRD4, 0xFF, 0x81}, /* Second power sequence control */ 19062306a36Sopenharmony_ci{VIACR, CR91, 0xFF, 0x80}, /* 24/12 bit LVDS Data off */ 19162306a36Sopenharmony_ci{VIACR, CR96, 0xFF, 0x00}, 19262306a36Sopenharmony_ci{VIACR, CR97, 0xFF, 0x00}, 19362306a36Sopenharmony_ci{VIACR, CR99, 0xFF, 0x00}, 19462306a36Sopenharmony_ci{VIACR, CR9B, 0xFF, 0x00}, 19562306a36Sopenharmony_ci{VIACR, CRD2, 0xFF, 0xFF} /* TMDS/LVDS control register. */ 19662306a36Sopenharmony_ci}; 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ci/* Video Mode Table */ 19962306a36Sopenharmony_ci/* Common Setting for Video Mode */ 20062306a36Sopenharmony_cistruct io_reg CLE266_ModeXregs[] = { {VIASR, SR1E, 0xF0, 0x00}, 20162306a36Sopenharmony_ci{VIASR, SR2A, 0x0F, 0x00}, 20262306a36Sopenharmony_ci{VIASR, SR15, 0x02, 0x02}, 20362306a36Sopenharmony_ci{VIASR, SR16, 0xBF, 0x08}, 20462306a36Sopenharmony_ci{VIASR, SR17, 0xFF, 0x1F}, 20562306a36Sopenharmony_ci{VIASR, SR18, 0xFF, 0x4E}, 20662306a36Sopenharmony_ci{VIASR, SR1A, 0xFB, 0x08}, 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci{VIACR, CR32, 0xFF, 0x00}, 20962306a36Sopenharmony_ci{VIACR, CR35, 0xFF, 0x00}, 21062306a36Sopenharmony_ci{VIACR, CR36, 0x08, 0x00}, 21162306a36Sopenharmony_ci{VIACR, CR6A, 0xFF, 0x80}, 21262306a36Sopenharmony_ci{VIACR, CR6A, 0xFF, 0xC0}, 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_ci{VIACR, CR55, 0x80, 0x00}, 21562306a36Sopenharmony_ci{VIACR, CR5D, 0x80, 0x00}, 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci{VIAGR, GR20, 0xFF, 0x00}, 21862306a36Sopenharmony_ci{VIAGR, GR21, 0xFF, 0x00}, 21962306a36Sopenharmony_ci{VIAGR, GR22, 0xFF, 0x00}, 22062306a36Sopenharmony_ci 22162306a36Sopenharmony_ci}; 22262306a36Sopenharmony_ci 22362306a36Sopenharmony_ci/* Mode:1024X768 */ 22462306a36Sopenharmony_cistruct io_reg PM1024x768[] = { {VIASR, 0x16, 0xBF, 0x0C}, 22562306a36Sopenharmony_ci{VIASR, 0x18, 0xFF, 0x4C} 22662306a36Sopenharmony_ci}; 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_cistruct patch_table res_patch_table[] = { 22962306a36Sopenharmony_ci {ARRAY_SIZE(PM1024x768), PM1024x768} 23062306a36Sopenharmony_ci}; 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ci/* struct VPITTable { 23362306a36Sopenharmony_ci unsigned char Misc; 23462306a36Sopenharmony_ci unsigned char SR[StdSR]; 23562306a36Sopenharmony_ci unsigned char CR[StdCR]; 23662306a36Sopenharmony_ci unsigned char GR[StdGR]; 23762306a36Sopenharmony_ci unsigned char AR[StdAR]; 23862306a36Sopenharmony_ci };*/ 23962306a36Sopenharmony_ci 24062306a36Sopenharmony_cistruct VPITTable VPIT = { 24162306a36Sopenharmony_ci /* Msic */ 24262306a36Sopenharmony_ci 0xC7, 24362306a36Sopenharmony_ci /* Sequencer */ 24462306a36Sopenharmony_ci {0x01, 0x0F, 0x00, 0x0E}, 24562306a36Sopenharmony_ci /* Graphic Controller */ 24662306a36Sopenharmony_ci {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF}, 24762306a36Sopenharmony_ci /* Attribute Controller */ 24862306a36Sopenharmony_ci {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 24962306a36Sopenharmony_ci 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 25062306a36Sopenharmony_ci 0x01, 0x00, 0x0F, 0x00} 25162306a36Sopenharmony_ci}; 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_ci/********************/ 25462306a36Sopenharmony_ci/* Mode Table */ 25562306a36Sopenharmony_ci/********************/ 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_cistatic const struct fb_videomode viafb_modes[] = { 25862306a36Sopenharmony_ci {NULL, 60, 480, 640, 40285, 72, 24, 19, 1, 48, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 25962306a36Sopenharmony_ci {NULL, 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2, 0, 0, 0}, 26062306a36Sopenharmony_ci {NULL, 75, 640, 480, 31746, 120, 16, 16, 1, 64, 3, 0, 0, 0}, 26162306a36Sopenharmony_ci {NULL, 85, 640, 480, 27780, 80, 56, 25, 1, 56, 3, 0, 0, 0}, 26262306a36Sopenharmony_ci {NULL, 100, 640, 480, 23167, 104, 40, 25, 1, 64, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 26362306a36Sopenharmony_ci {NULL, 120, 640, 480, 19081, 104, 40, 31, 1, 64, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 26462306a36Sopenharmony_ci {NULL, 60, 720, 480, 37426, 88, 16, 13, 1, 72, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 26562306a36Sopenharmony_ci {NULL, 60, 720, 576, 30611, 96, 24, 17, 1, 72, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 26662306a36Sopenharmony_ci {NULL, 60, 800, 600, 25131, 88, 40, 23, 1, 128, 4, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 26762306a36Sopenharmony_ci {NULL, 75, 800, 600, 20202, 160, 16, 21, 1, 80, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 26862306a36Sopenharmony_ci {NULL, 85, 800, 600, 17790, 152, 32, 27, 1, 64, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 26962306a36Sopenharmony_ci {NULL, 100, 800, 600, 14667, 136, 48, 32, 1, 88, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 27062306a36Sopenharmony_ci {NULL, 120, 800, 600, 11911, 144, 56, 39, 1, 88, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 27162306a36Sopenharmony_ci {NULL, 60, 800, 480, 33602, 96, 24, 10, 3, 72, 7, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 27262306a36Sopenharmony_ci {NULL, 60, 848, 480, 31565, 104, 24, 12, 3, 80, 5, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 27362306a36Sopenharmony_ci {NULL, 60, 856, 480, 31517, 104, 16, 13, 1, 88, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 27462306a36Sopenharmony_ci {NULL, 60, 1024, 512, 24218, 136, 32, 15, 1, 104, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 27562306a36Sopenharmony_ci {NULL, 60, 1024, 600, 20423, 144, 40, 18, 1, 104, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 27662306a36Sopenharmony_ci {NULL, 60, 1024, 768, 15385, 160, 24, 29, 3, 136, 6, 0, 0, 0}, 27762306a36Sopenharmony_ci {NULL, 75, 1024, 768, 12703, 176, 16, 28, 1, 96, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 27862306a36Sopenharmony_ci {NULL, 85, 1024, 768, 10581, 208, 48, 36, 1, 96, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 27962306a36Sopenharmony_ci {NULL, 100, 1024, 768, 8825, 184, 72, 42, 1, 112, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 28062306a36Sopenharmony_ci {NULL, 75, 1152, 864, 9259, 256, 64, 32, 1, 128, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 28162306a36Sopenharmony_ci {NULL, 60, 1280, 768, 12478, 200, 64, 23, 1, 136, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 28262306a36Sopenharmony_ci {NULL, 50, 1280, 768, 15342, 184, 56, 19, 1, 128, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 28362306a36Sopenharmony_ci {NULL, 60, 960, 600, 21964, 128, 32, 15, 3, 96, 6, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 28462306a36Sopenharmony_ci {NULL, 60, 1000, 600, 20803, 144, 40, 18, 1, 104, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 28562306a36Sopenharmony_ci {NULL, 60, 1024, 576, 21278, 144, 40, 17, 1, 104, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 28662306a36Sopenharmony_ci {NULL, 60, 1088, 612, 18825, 152, 48, 16, 3, 104, 5, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 28762306a36Sopenharmony_ci {NULL, 60, 1152, 720, 14974, 168, 56, 19, 3, 112, 6, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 28862306a36Sopenharmony_ci {NULL, 60, 1200, 720, 14248, 184, 56, 22, 1, 128, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 28962306a36Sopenharmony_ci {NULL, 49, 1200, 900, 17703, 21, 11, 1, 1, 32, 10, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 29062306a36Sopenharmony_ci {NULL, 60, 1280, 600, 16259, 184, 56, 18, 1, 128, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 29162306a36Sopenharmony_ci {NULL, 60, 1280, 800, 11938, 200, 72, 22, 3, 128, 6, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 29262306a36Sopenharmony_ci {NULL, 60, 1280, 960, 9259, 312, 96, 36, 1, 112, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 29362306a36Sopenharmony_ci {NULL, 60, 1280, 1024, 9262, 248, 48, 38, 1, 112, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 29462306a36Sopenharmony_ci {NULL, 75, 1280, 1024, 7409, 248, 16, 38, 1, 144, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 29562306a36Sopenharmony_ci {NULL, 85, 1280, 1024, 6351, 224, 64, 44, 1, 160, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 29662306a36Sopenharmony_ci {NULL, 60, 1360, 768, 11759, 208, 72, 22, 3, 136, 5, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 29762306a36Sopenharmony_ci {NULL, 60, 1368, 768, 11646, 216, 72, 23, 1, 144, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 29862306a36Sopenharmony_ci {NULL, 50, 1368, 768, 14301, 200, 56, 19, 1, 144, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 29962306a36Sopenharmony_ci {NULL, 60, 1368, 768, 11646, 216, 72, 23, 1, 144, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 30062306a36Sopenharmony_ci {NULL, 60, 1440, 900, 9372, 232, 80, 25, 3, 152, 6, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 30162306a36Sopenharmony_ci {NULL, 75, 1440, 900, 7311, 248, 96, 33, 3, 152, 6, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 30262306a36Sopenharmony_ci {NULL, 60, 1440, 1040, 7993, 248, 96, 33, 1, 152, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 30362306a36Sopenharmony_ci {NULL, 60, 1600, 900, 8449, 256, 88, 26, 3, 168, 5, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 30462306a36Sopenharmony_ci {NULL, 60, 1600, 1024, 7333, 272, 104, 32, 1, 168, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 30562306a36Sopenharmony_ci {NULL, 60, 1600, 1200, 6172, 304, 64, 46, 1, 192, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 30662306a36Sopenharmony_ci {NULL, 75, 1600, 1200, 4938, 304, 64, 46, 1, 192, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 0, 0}, 30762306a36Sopenharmony_ci {NULL, 60, 1680, 1050, 6832, 280, 104, 30, 3, 176, 6, 0, 0, 0}, 30862306a36Sopenharmony_ci {NULL, 75, 1680, 1050, 5339, 296, 120, 40, 3, 176, 6, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 30962306a36Sopenharmony_ci {NULL, 60, 1792, 1344, 4883, 328, 128, 46, 1, 200, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 31062306a36Sopenharmony_ci {NULL, 60, 1856, 1392, 4581, 352, 96, 43, 1, 224, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 31162306a36Sopenharmony_ci {NULL, 60, 1920, 1440, 4273, 344, 128, 56, 1, 208, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 31262306a36Sopenharmony_ci {NULL, 75, 1920, 1440, 3367, 352, 144, 56, 1, 224, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 31362306a36Sopenharmony_ci {NULL, 60, 2048, 1536, 3738, 376, 152, 49, 3, 224, 4, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 31462306a36Sopenharmony_ci {NULL, 60, 1280, 720, 13484, 216, 112, 20, 5, 40, 5, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 31562306a36Sopenharmony_ci {NULL, 50, 1280, 720, 16538, 176, 48, 17, 1, 128, 3, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 31662306a36Sopenharmony_ci {NULL, 60, 1920, 1080, 5776, 328, 128, 32, 3, 200, 5, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 31762306a36Sopenharmony_ci {NULL, 60, 1920, 1200, 5164, 336, 136, 36, 3, 200, 6, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 31862306a36Sopenharmony_ci {NULL, 60, 1400, 1050, 8210, 232, 88, 32, 3, 144, 4, FB_SYNC_VERT_HIGH_ACT, 0, 0}, 31962306a36Sopenharmony_ci {NULL, 75, 1400, 1050, 6398, 248, 104, 42, 3, 144, 4, FB_SYNC_VERT_HIGH_ACT, 0, 0} }; 32062306a36Sopenharmony_ci 32162306a36Sopenharmony_cistatic const struct fb_videomode viafb_rb_modes[] = { 32262306a36Sopenharmony_ci {NULL, 60, 1360, 768, 13879, 80, 48, 14, 3, 32, 5, FB_SYNC_HOR_HIGH_ACT, 0, 0}, 32362306a36Sopenharmony_ci {NULL, 60, 1440, 900, 11249, 80, 48, 17, 3, 32, 6, FB_SYNC_HOR_HIGH_ACT, 0, 0}, 32462306a36Sopenharmony_ci {NULL, 60, 1400, 1050, 9892, 80, 48, 23, 3, 32, 4, FB_SYNC_HOR_HIGH_ACT, 0, 0}, 32562306a36Sopenharmony_ci {NULL, 60, 1600, 900, 10226, 80, 48, 18, 3, 32, 5, FB_SYNC_HOR_HIGH_ACT, 0, 0}, 32662306a36Sopenharmony_ci {NULL, 60, 1680, 1050, 8387, 80, 48, 21, 3, 32, 6, FB_SYNC_HOR_HIGH_ACT, 0, 0}, 32762306a36Sopenharmony_ci {NULL, 60, 1920, 1080, 7212, 80, 48, 23, 3, 32, 5, FB_SYNC_HOR_HIGH_ACT, 0, 0}, 32862306a36Sopenharmony_ci {NULL, 60, 1920, 1200, 6488, 80, 48, 26, 3, 32, 6, FB_SYNC_HOR_HIGH_ACT, 0, 0} }; 32962306a36Sopenharmony_ci 33062306a36Sopenharmony_ciint NUM_TOTAL_CN400_ModeXregs = ARRAY_SIZE(CN400_ModeXregs); 33162306a36Sopenharmony_ciint NUM_TOTAL_CN700_ModeXregs = ARRAY_SIZE(CN700_ModeXregs); 33262306a36Sopenharmony_ciint NUM_TOTAL_KM400_ModeXregs = ARRAY_SIZE(KM400_ModeXregs); 33362306a36Sopenharmony_ciint NUM_TOTAL_CX700_ModeXregs = ARRAY_SIZE(CX700_ModeXregs); 33462306a36Sopenharmony_ciint NUM_TOTAL_VX855_ModeXregs = ARRAY_SIZE(VX855_ModeXregs); 33562306a36Sopenharmony_ciint NUM_TOTAL_CLE266_ModeXregs = ARRAY_SIZE(CLE266_ModeXregs); 33662306a36Sopenharmony_ciint NUM_TOTAL_PATCH_MODE = ARRAY_SIZE(res_patch_table); 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_ci 33962306a36Sopenharmony_cistatic const struct fb_videomode *get_best_mode( 34062306a36Sopenharmony_ci const struct fb_videomode *modes, int n, 34162306a36Sopenharmony_ci int hres, int vres, int refresh) 34262306a36Sopenharmony_ci{ 34362306a36Sopenharmony_ci const struct fb_videomode *best = NULL; 34462306a36Sopenharmony_ci int i; 34562306a36Sopenharmony_ci 34662306a36Sopenharmony_ci for (i = 0; i < n; i++) { 34762306a36Sopenharmony_ci if (modes[i].xres != hres || modes[i].yres != vres) 34862306a36Sopenharmony_ci continue; 34962306a36Sopenharmony_ci 35062306a36Sopenharmony_ci if (!best || abs(modes[i].refresh - refresh) < 35162306a36Sopenharmony_ci abs(best->refresh - refresh)) 35262306a36Sopenharmony_ci best = &modes[i]; 35362306a36Sopenharmony_ci } 35462306a36Sopenharmony_ci 35562306a36Sopenharmony_ci return best; 35662306a36Sopenharmony_ci} 35762306a36Sopenharmony_ci 35862306a36Sopenharmony_ciconst struct fb_videomode *viafb_get_best_mode(int hres, int vres, int refresh) 35962306a36Sopenharmony_ci{ 36062306a36Sopenharmony_ci return get_best_mode(viafb_modes, ARRAY_SIZE(viafb_modes), 36162306a36Sopenharmony_ci hres, vres, refresh); 36262306a36Sopenharmony_ci} 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ciconst struct fb_videomode *viafb_get_best_rb_mode(int hres, int vres, 36562306a36Sopenharmony_ci int refresh) 36662306a36Sopenharmony_ci{ 36762306a36Sopenharmony_ci return get_best_mode(viafb_rb_modes, ARRAY_SIZE(viafb_rb_modes), 36862306a36Sopenharmony_ci hres, vres, refresh); 36962306a36Sopenharmony_ci} 370