18c2ecf20Sopenharmony_ci/* $XFree86$ */ 28c2ecf20Sopenharmony_ci/* $XdotOrg$ */ 38c2ecf20Sopenharmony_ci/* 48c2ecf20Sopenharmony_ci * Mode initializing code (CRT2 section) 58c2ecf20Sopenharmony_ci * for SiS 300/305/540/630/730, 68c2ecf20Sopenharmony_ci * SiS 315/550/[M]650/651/[M]661[FGM]X/[M]74x[GX]/330/[M]76x[GX], 78c2ecf20Sopenharmony_ci * XGI V3XT/V5/V8, Z7 88c2ecf20Sopenharmony_ci * (Universal module for Linux kernel framebuffer and X.org/XFree86 4.x) 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * If distributed as part of the Linux kernel, the following license terms 138c2ecf20Sopenharmony_ci * apply: 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * * This program is free software; you can redistribute it and/or modify 168c2ecf20Sopenharmony_ci * * it under the terms of the GNU General Public License as published by 178c2ecf20Sopenharmony_ci * * the Free Software Foundation; either version 2 of the named License, 188c2ecf20Sopenharmony_ci * * or any later version. 198c2ecf20Sopenharmony_ci * * 208c2ecf20Sopenharmony_ci * * This program is distributed in the hope that it will be useful, 218c2ecf20Sopenharmony_ci * * but WITHOUT ANY WARRANTY; without even the implied warranty of 228c2ecf20Sopenharmony_ci * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 238c2ecf20Sopenharmony_ci * * GNU General Public License for more details. 248c2ecf20Sopenharmony_ci * * 258c2ecf20Sopenharmony_ci * * You should have received a copy of the GNU General Public License 268c2ecf20Sopenharmony_ci * * along with this program; if not, write to the Free Software 278c2ecf20Sopenharmony_ci * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA 288c2ecf20Sopenharmony_ci * 298c2ecf20Sopenharmony_ci * Otherwise, the following license terms apply: 308c2ecf20Sopenharmony_ci * 318c2ecf20Sopenharmony_ci * * Redistribution and use in source and binary forms, with or without 328c2ecf20Sopenharmony_ci * * modification, are permitted provided that the following conditions 338c2ecf20Sopenharmony_ci * * are met: 348c2ecf20Sopenharmony_ci * * 1) Redistributions of source code must retain the above copyright 358c2ecf20Sopenharmony_ci * * notice, this list of conditions and the following disclaimer. 368c2ecf20Sopenharmony_ci * * 2) Redistributions in binary form must reproduce the above copyright 378c2ecf20Sopenharmony_ci * * notice, this list of conditions and the following disclaimer in the 388c2ecf20Sopenharmony_ci * * documentation and/or other materials provided with the distribution. 398c2ecf20Sopenharmony_ci * * 3) The name of the author may not be used to endorse or promote products 408c2ecf20Sopenharmony_ci * * derived from this software without specific prior written permission. 418c2ecf20Sopenharmony_ci * * 428c2ecf20Sopenharmony_ci * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 438c2ecf20Sopenharmony_ci * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 448c2ecf20Sopenharmony_ci * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 458c2ecf20Sopenharmony_ci * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 468c2ecf20Sopenharmony_ci * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 478c2ecf20Sopenharmony_ci * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 488c2ecf20Sopenharmony_ci * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 498c2ecf20Sopenharmony_ci * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 508c2ecf20Sopenharmony_ci * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 518c2ecf20Sopenharmony_ci * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 528c2ecf20Sopenharmony_ci * 538c2ecf20Sopenharmony_ci * Author: Thomas Winischhofer <thomas@winischhofer.net> 548c2ecf20Sopenharmony_ci * 558c2ecf20Sopenharmony_ci * Formerly based on non-functional code-fragements for 300 series by SiS, Inc. 568c2ecf20Sopenharmony_ci * Used by permission. 578c2ecf20Sopenharmony_ci * 588c2ecf20Sopenharmony_ci */ 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#if 1 618c2ecf20Sopenharmony_ci#define SET_EMI /* 302LV/ELV: Set EMI values */ 628c2ecf20Sopenharmony_ci#endif 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#if 1 658c2ecf20Sopenharmony_ci#define SET_PWD /* 301/302LV: Set PWD */ 668c2ecf20Sopenharmony_ci#endif 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define COMPAL_HACK /* Needed for Compal 1400x1050 (EMI) */ 698c2ecf20Sopenharmony_ci#define COMPAQ_HACK /* Needed for Inventec/Compaq 1280x1024 (EMI) */ 708c2ecf20Sopenharmony_ci#define ASUS_HACK /* Needed for Asus A2H 1024x768 (EMI) */ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#include "init301.h" 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 758c2ecf20Sopenharmony_ci#include "oem300.h" 768c2ecf20Sopenharmony_ci#endif 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 798c2ecf20Sopenharmony_ci#include "oem310.h" 808c2ecf20Sopenharmony_ci#endif 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#define SiS_I2CDELAY 1000 838c2ecf20Sopenharmony_ci#define SiS_I2CDELAYSHORT 150 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_cistatic const unsigned char SiS_YPbPrTable[3][64] = { 868c2ecf20Sopenharmony_ci { 878c2ecf20Sopenharmony_ci 0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c, 888c2ecf20Sopenharmony_ci 0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a, 898c2ecf20Sopenharmony_ci 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b, 908c2ecf20Sopenharmony_ci 0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17, 918c2ecf20Sopenharmony_ci 0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02, 928c2ecf20Sopenharmony_ci 0x03,0x0a,0x65,0x9d /*0x8d*/,0x08,0x92,0x8f,0x40, 938c2ecf20Sopenharmony_ci 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x53 /*0x50*/, 948c2ecf20Sopenharmony_ci 0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00 958c2ecf20Sopenharmony_ci }, 968c2ecf20Sopenharmony_ci { 978c2ecf20Sopenharmony_ci 0x33,0x06,0x06,0x09,0x0b,0x0c,0x0c,0x0c, 988c2ecf20Sopenharmony_ci 0x98,0x0a,0x01,0x0d,0x06,0x0d,0x04,0x0a, 998c2ecf20Sopenharmony_ci 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f, 1008c2ecf20Sopenharmony_ci 0x0c,0x50,0xb2,0x9f,0x16,0x59,0x4f,0x13, 1018c2ecf20Sopenharmony_ci 0xad,0x11,0xad,0x1d,0x40,0x8a,0x3d,0xb8, 1028c2ecf20Sopenharmony_ci 0x51,0x5e,0x60,0x49,0x7d,0x92,0x0f,0x40, 1038c2ecf20Sopenharmony_ci 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x4e, 1048c2ecf20Sopenharmony_ci 0x43,0x41,0x11,0x00,0xfc,0xff,0x32,0x00 1058c2ecf20Sopenharmony_ci }, 1068c2ecf20Sopenharmony_ci { 1078c2ecf20Sopenharmony_ci#if 0 /* OK, but sticks to left edge */ 1088c2ecf20Sopenharmony_ci 0x13,0x1d,0xe8,0x09,0x09,0xed,0x0c,0x0c, 1098c2ecf20Sopenharmony_ci 0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a, 1108c2ecf20Sopenharmony_ci 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f, 1118c2ecf20Sopenharmony_ci 0xed,0x50,0x70,0x9f,0x16,0x59,0x21 /*0x2b*/,0x13, 1128c2ecf20Sopenharmony_ci 0x27,0x0b,0x27,0xfc,0x30,0x27,0x1c,0xb0, 1138c2ecf20Sopenharmony_ci 0x4b,0x4b,0x65 /*0x6f*/,0x2f,0x63,0x92,0x0f,0x40, 1148c2ecf20Sopenharmony_ci 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x27, 1158c2ecf20Sopenharmony_ci 0x00,0x40,0x11,0x00,0xfc,0xff,0x32,0x00 1168c2ecf20Sopenharmony_ci#endif 1178c2ecf20Sopenharmony_ci#if 1 /* Perfect */ 1188c2ecf20Sopenharmony_ci 0x23,0x2d,0xe8,0x09,0x09,0xed,0x0c,0x0c, 1198c2ecf20Sopenharmony_ci 0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a, 1208c2ecf20Sopenharmony_ci 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f, 1218c2ecf20Sopenharmony_ci 0xed,0x50,0x70,0x9f,0x16,0x59,0x60,0x13, 1228c2ecf20Sopenharmony_ci 0x27,0x0b,0x27,0xfc,0x30,0x27,0x1c,0xb0, 1238c2ecf20Sopenharmony_ci 0x4b,0x4b,0x6f,0x2f,0x63,0x92,0x0f,0x40, 1248c2ecf20Sopenharmony_ci 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x73, 1258c2ecf20Sopenharmony_ci 0x00,0x40,0x11,0x00,0xfc,0xff,0x32,0x00 1268c2ecf20Sopenharmony_ci#endif 1278c2ecf20Sopenharmony_ci } 1288c2ecf20Sopenharmony_ci}; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_cistatic const unsigned char SiS_TVPhase[] = 1318c2ecf20Sopenharmony_ci{ 1328c2ecf20Sopenharmony_ci 0x21,0xED,0xBA,0x08, /* 0x00 SiS_NTSCPhase */ 1338c2ecf20Sopenharmony_ci 0x2A,0x05,0xE3,0x00, /* 0x01 SiS_PALPhase */ 1348c2ecf20Sopenharmony_ci 0x21,0xE4,0x2E,0x9B, /* 0x02 SiS_PALMPhase */ 1358c2ecf20Sopenharmony_ci 0x21,0xF4,0x3E,0xBA, /* 0x03 SiS_PALNPhase */ 1368c2ecf20Sopenharmony_ci 0x1E,0x8B,0xA2,0xA7, 1378c2ecf20Sopenharmony_ci 0x1E,0x83,0x0A,0xE0, /* 0x05 SiS_SpecialPhaseM */ 1388c2ecf20Sopenharmony_ci 0x00,0x00,0x00,0x00, 1398c2ecf20Sopenharmony_ci 0x00,0x00,0x00,0x00, 1408c2ecf20Sopenharmony_ci 0x21,0xF0,0x7B,0xD6, /* 0x08 SiS_NTSCPhase2 */ 1418c2ecf20Sopenharmony_ci 0x2A,0x09,0x86,0xE9, /* 0x09 SiS_PALPhase2 */ 1428c2ecf20Sopenharmony_ci 0x21,0xE6,0xEF,0xA4, /* 0x0a SiS_PALMPhase2 */ 1438c2ecf20Sopenharmony_ci 0x21,0xF6,0x94,0x46, /* 0x0b SiS_PALNPhase2 */ 1448c2ecf20Sopenharmony_ci 0x1E,0x8B,0xA2,0xA7, 1458c2ecf20Sopenharmony_ci 0x1E,0x83,0x0A,0xE0, /* 0x0d SiS_SpecialPhaseM */ 1468c2ecf20Sopenharmony_ci 0x00,0x00,0x00,0x00, 1478c2ecf20Sopenharmony_ci 0x00,0x00,0x00,0x00, 1488c2ecf20Sopenharmony_ci 0x1e,0x8c,0x5c,0x7a, /* 0x10 SiS_SpecialPhase */ 1498c2ecf20Sopenharmony_ci 0x25,0xd4,0xfd,0x5e /* 0x11 SiS_SpecialPhaseJ */ 1508c2ecf20Sopenharmony_ci}; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_cistatic const unsigned char SiS_HiTVGroup3_1[] = { 1538c2ecf20Sopenharmony_ci 0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x13, 1548c2ecf20Sopenharmony_ci 0xb1, 0x41, 0x62, 0x62, 0xff, 0xf4, 0x45, 0xa6, 1558c2ecf20Sopenharmony_ci 0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20, 1568c2ecf20Sopenharmony_ci 0xac, 0xda, 0x60, 0xfe, 0x6a, 0x9a, 0x06, 0x10, 1578c2ecf20Sopenharmony_ci 0xd1, 0x04, 0x18, 0x0a, 0xff, 0x80, 0x00, 0x80, 1588c2ecf20Sopenharmony_ci 0x3b, 0x77, 0x00, 0xef, 0xe0, 0x10, 0xb0, 0xe0, 1598c2ecf20Sopenharmony_ci 0x10, 0x4f, 0x0f, 0x0f, 0x05, 0x0f, 0x08, 0x6e, 1608c2ecf20Sopenharmony_ci 0x1a, 0x1f, 0x25, 0x2a, 0x4c, 0xaa, 0x01 1618c2ecf20Sopenharmony_ci}; 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_cistatic const unsigned char SiS_HiTVGroup3_2[] = { 1648c2ecf20Sopenharmony_ci 0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x7a, 1658c2ecf20Sopenharmony_ci 0x54, 0x41, 0xe7, 0xe7, 0xff, 0xf4, 0x45, 0xa6, 1668c2ecf20Sopenharmony_ci 0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20, 1678c2ecf20Sopenharmony_ci 0xac, 0x6a, 0x60, 0x2b, 0x52, 0xcd, 0x61, 0x10, 1688c2ecf20Sopenharmony_ci 0x51, 0x04, 0x18, 0x0a, 0x1f, 0x80, 0x00, 0x80, 1698c2ecf20Sopenharmony_ci 0xff, 0xa4, 0x04, 0x2b, 0x94, 0x21, 0x72, 0x94, 1708c2ecf20Sopenharmony_ci 0x26, 0x05, 0x01, 0x0f, 0xed, 0x0f, 0x0a, 0x64, 1718c2ecf20Sopenharmony_ci 0x18, 0x1d, 0x23, 0x28, 0x4c, 0xaa, 0x01 1728c2ecf20Sopenharmony_ci}; 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci/* 301C / 302ELV extended Part2 TV registers (4 tap scaler) */ 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_cistatic const unsigned char SiS_Part2CLVX_1[] = { 1778c2ecf20Sopenharmony_ci 0x00,0x00, 1788c2ecf20Sopenharmony_ci 0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, 1798c2ecf20Sopenharmony_ci 0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, 1808c2ecf20Sopenharmony_ci 0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C, 1818c2ecf20Sopenharmony_ci 0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E 1828c2ecf20Sopenharmony_ci}; 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_cistatic const unsigned char SiS_Part2CLVX_2[] = { 1858c2ecf20Sopenharmony_ci 0x00,0x00, 1868c2ecf20Sopenharmony_ci 0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, 1878c2ecf20Sopenharmony_ci 0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, 1888c2ecf20Sopenharmony_ci 0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C,0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C, 1898c2ecf20Sopenharmony_ci 0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E 1908c2ecf20Sopenharmony_ci}; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_cistatic const unsigned char SiS_Part2CLVX_3[] = { /* NTSC, 525i, 525p */ 1938c2ecf20Sopenharmony_ci 0xE0,0x01, 1948c2ecf20Sopenharmony_ci 0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D,0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D, 1958c2ecf20Sopenharmony_ci 0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C,0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C, 1968c2ecf20Sopenharmony_ci 0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E, 1978c2ecf20Sopenharmony_ci 0x7D,0x0C,0x19,0x7E,0x7D,0x0A,0x19,0x00,0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02, 1988c2ecf20Sopenharmony_ci 0x58,0x02, 1998c2ecf20Sopenharmony_ci 0x07,0x14,0x07,0x7E,0x06,0x14,0x09,0x7D,0x05,0x14,0x0A,0x7D,0x04,0x13,0x0B,0x7E, 2008c2ecf20Sopenharmony_ci 0x03,0x13,0x0C,0x7E,0x02,0x12,0x0D,0x7F,0x01,0x12,0x0E,0x7F,0x01,0x11,0x0F,0x7F, 2018c2ecf20Sopenharmony_ci 0x00,0x10,0x10,0x00,0x7F,0x0F,0x11,0x01,0x7F,0x0E,0x12,0x01,0x7E,0x0D,0x12,0x03, 2028c2ecf20Sopenharmony_ci 0x7E,0x0C,0x13,0x03,0x7E,0x0B,0x13,0x04,0x7E,0x0A,0x14,0x04,0x7D,0x09,0x14,0x06, 2038c2ecf20Sopenharmony_ci 0x00,0x03, 2048c2ecf20Sopenharmony_ci 0x09,0x0F,0x09,0x7F,0x08,0x0F,0x09,0x00,0x07,0x0F,0x0A,0x00,0x06,0x0F,0x0A,0x01, 2058c2ecf20Sopenharmony_ci 0x06,0x0E,0x0B,0x01,0x05,0x0E,0x0B,0x02,0x04,0x0E,0x0C,0x02,0x04,0x0D,0x0C,0x03, 2068c2ecf20Sopenharmony_ci 0x03,0x0D,0x0D,0x03,0x02,0x0C,0x0D,0x05,0x02,0x0C,0x0E,0x04,0x01,0x0B,0x0E,0x06, 2078c2ecf20Sopenharmony_ci 0x01,0x0B,0x0E,0x06,0x00,0x0A,0x0F,0x07,0x00,0x0A,0x0F,0x07,0x00,0x09,0x0F,0x08, 2088c2ecf20Sopenharmony_ci 0xFF,0xFF 2098c2ecf20Sopenharmony_ci}; 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_cistatic const unsigned char SiS_Part2CLVX_4[] = { /* PAL */ 2128c2ecf20Sopenharmony_ci 0x58,0x02, 2138c2ecf20Sopenharmony_ci 0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D, 2148c2ecf20Sopenharmony_ci 0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D, 2158c2ecf20Sopenharmony_ci 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E, 2168c2ecf20Sopenharmony_ci 0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04, 2178c2ecf20Sopenharmony_ci 0x00,0x03, 2188c2ecf20Sopenharmony_ci 0x08,0x12,0x08,0x7E,0x07,0x12,0x09,0x7E,0x06,0x12,0x0A,0x7E,0x05,0x11,0x0B,0x7F, 2198c2ecf20Sopenharmony_ci 0x04,0x11,0x0C,0x7F,0x03,0x11,0x0C,0x00,0x03,0x10,0x0D,0x00,0x02,0x0F,0x0E,0x01, 2208c2ecf20Sopenharmony_ci 0x01,0x0F,0x0F,0x01,0x01,0x0E,0x0F,0x02,0x00,0x0D,0x10,0x03,0x7F,0x0C,0x11,0x04, 2218c2ecf20Sopenharmony_ci 0x7F,0x0C,0x11,0x04,0x7F,0x0B,0x11,0x05,0x7E,0x0A,0x12,0x06,0x7E,0x09,0x12,0x07, 2228c2ecf20Sopenharmony_ci 0x40,0x02, 2238c2ecf20Sopenharmony_ci 0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E,0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D, 2248c2ecf20Sopenharmony_ci 0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C, 2258c2ecf20Sopenharmony_ci 0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x18,0x7F, 2268c2ecf20Sopenharmony_ci 0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1B,0x02, 2278c2ecf20Sopenharmony_ci 0xFF,0xFF 2288c2ecf20Sopenharmony_ci}; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_cistatic const unsigned char SiS_Part2CLVX_5[] = { /* 750p */ 2318c2ecf20Sopenharmony_ci 0x00,0x03, 2328c2ecf20Sopenharmony_ci 0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D, 2338c2ecf20Sopenharmony_ci 0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D, 2348c2ecf20Sopenharmony_ci 0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E,0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E, 2358c2ecf20Sopenharmony_ci 0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01,0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04, 2368c2ecf20Sopenharmony_ci 0xFF,0xFF 2378c2ecf20Sopenharmony_ci}; 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_cistatic const unsigned char SiS_Part2CLVX_6[] = { /* 1080i */ 2408c2ecf20Sopenharmony_ci 0x00,0x04, 2418c2ecf20Sopenharmony_ci 0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E,0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D, 2428c2ecf20Sopenharmony_ci 0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C, 2438c2ecf20Sopenharmony_ci 0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D,0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x18,0x7F, 2448c2ecf20Sopenharmony_ci 0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00,0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1B,0x02, 2458c2ecf20Sopenharmony_ci 0xFF,0xFF, 2468c2ecf20Sopenharmony_ci}; 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 2498c2ecf20Sopenharmony_ci/* 661 et al LCD data structure (2.03.00) */ 2508c2ecf20Sopenharmony_cistatic const unsigned char SiS_LCDStruct661[] = { 2518c2ecf20Sopenharmony_ci /* 1024x768 */ 2528c2ecf20Sopenharmony_ci/* type|CR37| HDE | VDE | HT | VT | hss | hse */ 2538c2ecf20Sopenharmony_ci 0x02,0xC0,0x00,0x04,0x00,0x03,0x40,0x05,0x26,0x03,0x10,0x00,0x88, 2548c2ecf20Sopenharmony_ci 0x00,0x02,0x00,0x06,0x00,0x41,0x5A,0x64,0x00,0x00,0x00,0x00,0x04, 2558c2ecf20Sopenharmony_ci /* | vss | vse |clck| clock |CRT2DataP|CRT2DataP|idx */ 2568c2ecf20Sopenharmony_ci /* VESA non-VESA noscale */ 2578c2ecf20Sopenharmony_ci /* 1280x1024 */ 2588c2ecf20Sopenharmony_ci 0x03,0xC0,0x00,0x05,0x00,0x04,0x98,0x06,0x2A,0x04,0x30,0x00,0x70, 2598c2ecf20Sopenharmony_ci 0x00,0x01,0x00,0x03,0x00,0x6C,0xF8,0x2F,0x00,0x00,0x00,0x00,0x08, 2608c2ecf20Sopenharmony_ci /* 1400x1050 */ 2618c2ecf20Sopenharmony_ci 0x09,0x20,0x78,0x05,0x1A,0x04,0x98,0x06,0x2A,0x04,0x18,0x00,0x38, 2628c2ecf20Sopenharmony_ci 0x00,0x01,0x00,0x03,0x00,0x6C,0xF8,0x2F,0x00,0x00,0x00,0x00,0x09, 2638c2ecf20Sopenharmony_ci /* 1600x1200 */ 2648c2ecf20Sopenharmony_ci 0x0B,0xE0,0x40,0x06,0xB0,0x04,0x70,0x08,0xE2,0x04,0x40,0x00,0xC0, 2658c2ecf20Sopenharmony_ci 0x00,0x01,0x00,0x03,0x00,0xA2,0x70,0x24,0x00,0x00,0x00,0x00,0x0A, 2668c2ecf20Sopenharmony_ci /* 1280x768 (_2) */ 2678c2ecf20Sopenharmony_ci 0x0A,0xE0,0x00,0x05,0x00,0x03,0x7C,0x06,0x26,0x03,0x30,0x00,0x70, 2688c2ecf20Sopenharmony_ci 0x00,0x03,0x00,0x06,0x00,0x4D,0xC8,0x48,0x00,0x00,0x00,0x00,0x06, 2698c2ecf20Sopenharmony_ci /* 1280x720 */ 2708c2ecf20Sopenharmony_ci 0x0E,0xE0,0x00,0x05,0xD0,0x02,0x80,0x05,0x26,0x03,0x10,0x00,0x20, 2718c2ecf20Sopenharmony_ci 0x00,0x01,0x00,0x06,0x00,0x45,0x9C,0x62,0x00,0x00,0x00,0x00,0x05, 2728c2ecf20Sopenharmony_ci /* 1280x800 (_2) */ 2738c2ecf20Sopenharmony_ci 0x0C,0xE0,0x00,0x05,0x20,0x03,0x10,0x06,0x2C,0x03,0x30,0x00,0x70, 2748c2ecf20Sopenharmony_ci 0x00,0x04,0x00,0x03,0x00,0x49,0xCE,0x1E,0x00,0x00,0x00,0x00,0x09, 2758c2ecf20Sopenharmony_ci /* 1680x1050 */ 2768c2ecf20Sopenharmony_ci 0x0D,0xE0,0x90,0x06,0x1A,0x04,0x6C,0x07,0x2A,0x04,0x1A,0x00,0x4C, 2778c2ecf20Sopenharmony_ci 0x00,0x03,0x00,0x06,0x00,0x79,0xBE,0x44,0x00,0x00,0x00,0x00,0x06, 2788c2ecf20Sopenharmony_ci /* 1280x800_3 */ 2798c2ecf20Sopenharmony_ci 0x0C,0xE0,0x00,0x05,0x20,0x03,0xAA,0x05,0x2E,0x03,0x30,0x00,0x50, 2808c2ecf20Sopenharmony_ci 0x00,0x04,0x00,0x03,0x00,0x47,0xA9,0x10,0x00,0x00,0x00,0x00,0x07, 2818c2ecf20Sopenharmony_ci /* 800x600 */ 2828c2ecf20Sopenharmony_ci 0x01,0xC0,0x20,0x03,0x58,0x02,0x20,0x04,0x74,0x02,0x2A,0x00,0x80, 2838c2ecf20Sopenharmony_ci 0x00,0x06,0x00,0x04,0x00,0x28,0x63,0x4B,0x00,0x00,0x00,0x00,0x00, 2848c2ecf20Sopenharmony_ci /* 1280x854 */ 2858c2ecf20Sopenharmony_ci 0x08,0xE0,0x00,0x05,0x56,0x03,0x80,0x06,0x5d,0x03,0x10,0x00,0x70, 2868c2ecf20Sopenharmony_ci 0x00,0x01,0x00,0x03,0x00,0x54,0x75,0x13,0x00,0x00,0x00,0x00,0x08 2878c2ecf20Sopenharmony_ci}; 2888c2ecf20Sopenharmony_ci#endif 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 2918c2ecf20Sopenharmony_cistatic unsigned char SiS300_TrumpionData[14][80] = { 2928c2ecf20Sopenharmony_ci { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02, 2938c2ecf20Sopenharmony_ci 0x20,0x03,0x0B,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x10,0x00,0x00,0x04,0x23, 2948c2ecf20Sopenharmony_ci 0x00,0x00,0x03,0x28,0x03,0x10,0x05,0x08,0x40,0x10,0x00,0x10,0x04,0x23,0x00,0x23, 2958c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0xBC,0x01,0xFF,0x03,0xFF,0x19,0x01,0x00,0x05,0x09,0x04,0x04,0x05, 2968c2ecf20Sopenharmony_ci 0x04,0x0C,0x09,0x05,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5A,0x01,0xBE,0x01,0x00 }, 2978c2ecf20Sopenharmony_ci { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x27,0x00,0x80,0x02, 2988c2ecf20Sopenharmony_ci 0x20,0x03,0x07,0x00,0x5E,0x01,0x0D,0x02,0x60,0x0C,0x30,0x11,0x00,0x00,0x04,0x23, 2998c2ecf20Sopenharmony_ci 0x00,0x00,0x03,0x80,0x03,0x28,0x06,0x08,0x40,0x11,0x00,0x11,0x04,0x23,0x00,0x23, 3008c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0x90,0x01,0xFF,0x0F,0xF4,0x19,0x01,0x00,0x05,0x01,0x00,0x04,0x05, 3018c2ecf20Sopenharmony_ci 0x04,0x0C,0x02,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEC,0x57,0x01,0xBE,0x01,0x00 }, 3028c2ecf20Sopenharmony_ci { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x8A,0x00,0xD8,0x02, 3038c2ecf20Sopenharmony_ci 0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23, 3048c2ecf20Sopenharmony_ci 0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23, 3058c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0xD9,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05, 3068c2ecf20Sopenharmony_ci 0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x59,0x01,0xBE,0x01,0x00 }, 3078c2ecf20Sopenharmony_ci { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x72,0x00,0xD8,0x02, 3088c2ecf20Sopenharmony_ci 0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23, 3098c2ecf20Sopenharmony_ci 0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23, 3108c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0xDA,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05, 3118c2ecf20Sopenharmony_ci 0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 }, 3128c2ecf20Sopenharmony_ci { 0x02,0x0A,0x02,0x00,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02, 3138c2ecf20Sopenharmony_ci 0x20,0x03,0x16,0x00,0xE0,0x01,0x0D,0x02,0x60,0x0C,0x30,0x98,0x00,0x00,0x04,0x23, 3148c2ecf20Sopenharmony_ci 0x00,0x01,0x03,0x45,0x03,0x48,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x23,0x00,0x23, 3158c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0xF4,0x01,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x05,0x01,0x00,0x05,0x05, 3168c2ecf20Sopenharmony_ci 0x04,0x0C,0x08,0x05,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 }, 3178c2ecf20Sopenharmony_ci { 0x02,0x0A,0x02,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0xBF,0x00,0x20,0x03, 3188c2ecf20Sopenharmony_ci 0x20,0x04,0x0D,0x00,0x58,0x02,0x71,0x02,0x80,0x0C,0x30,0x9A,0x00,0xFA,0x03,0x1D, 3198c2ecf20Sopenharmony_ci 0x00,0x01,0x03,0x22,0x03,0x28,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x1D,0x00,0x1D, 3208c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0x39,0x03,0x40,0x05,0xF4,0x18,0x07,0x02,0x06,0x04,0x01,0x06,0x0B, 3218c2ecf20Sopenharmony_ci 0x02,0x0A,0x20,0x19,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 }, 3228c2ecf20Sopenharmony_ci { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0xEF,0x00,0x00,0x04, 3238c2ecf20Sopenharmony_ci 0x40,0x05,0x13,0x00,0x00,0x03,0x26,0x03,0x88,0x0C,0x30,0x90,0x00,0x00,0x04,0x23, 3248c2ecf20Sopenharmony_ci 0x00,0x01,0x03,0x24,0x03,0x28,0x06,0x08,0x40,0x90,0x00,0x90,0x04,0x23,0x00,0x23, 3258c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0x40,0x05,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x08,0x01,0x00,0x08,0x01, 3268c2ecf20Sopenharmony_ci 0x00,0x08,0x01,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 }, 3278c2ecf20Sopenharmony_ci /* variant 2 */ 3288c2ecf20Sopenharmony_ci { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02, 3298c2ecf20Sopenharmony_ci 0x20,0x03,0x15,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x18,0x00,0x00,0x04,0x23, 3308c2ecf20Sopenharmony_ci 0x00,0x01,0x03,0x44,0x03,0x28,0x06,0x08,0x40,0x18,0x00,0x18,0x04,0x23,0x00,0x23, 3318c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0xA6,0x01,0xFF,0x03,0xFF,0x19,0x01,0x00,0x05,0x13,0x04,0x04,0x05, 3328c2ecf20Sopenharmony_ci 0x04,0x0C,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 }, 3338c2ecf20Sopenharmony_ci { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02, 3348c2ecf20Sopenharmony_ci 0x20,0x03,0x15,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x18,0x00,0x00,0x04,0x23, 3358c2ecf20Sopenharmony_ci 0x00,0x01,0x03,0x44,0x03,0x28,0x06,0x08,0x40,0x18,0x00,0x18,0x04,0x23,0x00,0x23, 3368c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0xA6,0x01,0xFF,0x03,0xFF,0x19,0x01,0x00,0x05,0x13,0x04,0x04,0x05, 3378c2ecf20Sopenharmony_ci 0x04,0x0C,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 }, 3388c2ecf20Sopenharmony_ci { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x8A,0x00,0xD8,0x02, 3398c2ecf20Sopenharmony_ci 0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23, 3408c2ecf20Sopenharmony_ci 0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23, 3418c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0xDA,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05, 3428c2ecf20Sopenharmony_ci 0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 }, 3438c2ecf20Sopenharmony_ci { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x72,0x00,0xD8,0x02, 3448c2ecf20Sopenharmony_ci 0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23, 3458c2ecf20Sopenharmony_ci 0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23, 3468c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0xDA,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05, 3478c2ecf20Sopenharmony_ci 0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 }, 3488c2ecf20Sopenharmony_ci { 0x02,0x0A,0x02,0x00,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02, 3498c2ecf20Sopenharmony_ci 0x20,0x03,0x16,0x00,0xE0,0x01,0x0D,0x02,0x60,0x0C,0x30,0x98,0x00,0x00,0x04,0x23, 3508c2ecf20Sopenharmony_ci 0x00,0x01,0x03,0x45,0x03,0x48,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x23,0x00,0x23, 3518c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0xF4,0x01,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x05,0x01,0x00,0x05,0x05, 3528c2ecf20Sopenharmony_ci 0x04,0x0C,0x08,0x05,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEA,0x58,0x01,0xBE,0x01,0x00 }, 3538c2ecf20Sopenharmony_ci { 0x02,0x0A,0x02,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0xBF,0x00,0x20,0x03, 3548c2ecf20Sopenharmony_ci 0x20,0x04,0x0D,0x00,0x58,0x02,0x71,0x02,0x80,0x0C,0x30,0x9A,0x00,0xFA,0x03,0x1D, 3558c2ecf20Sopenharmony_ci 0x00,0x01,0x03,0x22,0x03,0x28,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x1D,0x00,0x1D, 3568c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0x39,0x03,0x40,0x05,0xF4,0x18,0x07,0x02,0x06,0x04,0x01,0x06,0x0B, 3578c2ecf20Sopenharmony_ci 0x02,0x0A,0x20,0x19,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEA,0x58,0x01,0xBE,0x01,0x00 }, 3588c2ecf20Sopenharmony_ci { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0xEF,0x00,0x00,0x04, 3598c2ecf20Sopenharmony_ci 0x40,0x05,0x13,0x00,0x00,0x03,0x26,0x03,0x88,0x0C,0x30,0x90,0x00,0x00,0x04,0x23, 3608c2ecf20Sopenharmony_ci 0x00,0x01,0x03,0x24,0x03,0x28,0x06,0x08,0x40,0x90,0x00,0x90,0x04,0x23,0x00,0x23, 3618c2ecf20Sopenharmony_ci 0x03,0x11,0x60,0x40,0x05,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x08,0x01,0x00,0x08,0x01, 3628c2ecf20Sopenharmony_ci 0x00,0x08,0x01,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEA,0x58,0x01,0xBE,0x01,0x00 } 3638c2ecf20Sopenharmony_ci}; 3648c2ecf20Sopenharmony_ci#endif 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 3678c2ecf20Sopenharmony_cistatic void SiS_Chrontel701xOn(struct SiS_Private *SiS_Pr); 3688c2ecf20Sopenharmony_cistatic void SiS_Chrontel701xOff(struct SiS_Private *SiS_Pr); 3698c2ecf20Sopenharmony_cistatic void SiS_ChrontelInitTVVSync(struct SiS_Private *SiS_Pr); 3708c2ecf20Sopenharmony_cistatic void SiS_ChrontelDoSomething1(struct SiS_Private *SiS_Pr); 3718c2ecf20Sopenharmony_ci#endif /* 315 */ 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 3748c2ecf20Sopenharmony_cistatic bool SiS_SetTrumpionBlock(struct SiS_Private *SiS_Pr, unsigned char *dataptr); 3758c2ecf20Sopenharmony_ci#endif 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_cistatic unsigned short SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags, 3788c2ecf20Sopenharmony_ci int VGAEngine, unsigned short adaptnum, unsigned short DDCdatatype, 3798c2ecf20Sopenharmony_ci bool checkcr32, unsigned int VBFlags2); 3808c2ecf20Sopenharmony_cistatic unsigned short SiS_ProbeDDC(struct SiS_Private *SiS_Pr); 3818c2ecf20Sopenharmony_cistatic unsigned short SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype, 3828c2ecf20Sopenharmony_ci unsigned char *buffer); 3838c2ecf20Sopenharmony_cistatic void SiS_SetSwitchDDC2(struct SiS_Private *SiS_Pr); 3848c2ecf20Sopenharmony_cistatic unsigned short SiS_SetStart(struct SiS_Private *SiS_Pr); 3858c2ecf20Sopenharmony_cistatic unsigned short SiS_SetStop(struct SiS_Private *SiS_Pr); 3868c2ecf20Sopenharmony_cistatic unsigned short SiS_SetSCLKLow(struct SiS_Private *SiS_Pr); 3878c2ecf20Sopenharmony_cistatic unsigned short SiS_SetSCLKHigh(struct SiS_Private *SiS_Pr); 3888c2ecf20Sopenharmony_cistatic unsigned short SiS_ReadDDC2Data(struct SiS_Private *SiS_Pr); 3898c2ecf20Sopenharmony_cistatic unsigned short SiS_WriteDDC2Data(struct SiS_Private *SiS_Pr, unsigned short tempax); 3908c2ecf20Sopenharmony_cistatic unsigned short SiS_CheckACK(struct SiS_Private *SiS_Pr); 3918c2ecf20Sopenharmony_cistatic unsigned short SiS_WriteDABDDC(struct SiS_Private *SiS_Pr); 3928c2ecf20Sopenharmony_cistatic unsigned short SiS_PrepareReadDDC(struct SiS_Private *SiS_Pr); 3938c2ecf20Sopenharmony_cistatic unsigned short SiS_PrepareDDC(struct SiS_Private *SiS_Pr); 3948c2ecf20Sopenharmony_cistatic void SiS_SendACK(struct SiS_Private *SiS_Pr, unsigned short yesno); 3958c2ecf20Sopenharmony_cistatic unsigned short SiS_DoProbeDDC(struct SiS_Private *SiS_Pr); 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 3988c2ecf20Sopenharmony_cistatic void SiS_OEM300Setting(struct SiS_Private *SiS_Pr, 3998c2ecf20Sopenharmony_ci unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefTabindex); 4008c2ecf20Sopenharmony_cistatic void SetOEMLCDData2(struct SiS_Private *SiS_Pr, 4018c2ecf20Sopenharmony_ci unsigned short ModeNo, unsigned short ModeIdIndex,unsigned short RefTableIndex); 4028c2ecf20Sopenharmony_ci#endif 4038c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 4048c2ecf20Sopenharmony_cistatic void SiS_OEM310Setting(struct SiS_Private *SiS_Pr, 4058c2ecf20Sopenharmony_ci unsigned short ModeNo,unsigned short ModeIdIndex, unsigned short RRTI); 4068c2ecf20Sopenharmony_cistatic void SiS_OEM661Setting(struct SiS_Private *SiS_Pr, 4078c2ecf20Sopenharmony_ci unsigned short ModeNo,unsigned short ModeIdIndex, unsigned short RRTI); 4088c2ecf20Sopenharmony_cistatic void SiS_FinalizeLCD(struct SiS_Private *, unsigned short, unsigned short); 4098c2ecf20Sopenharmony_ci#endif 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_cistatic unsigned short SiS_GetBIOSLCDResInfo(struct SiS_Private *SiS_Pr); 4128c2ecf20Sopenharmony_cistatic void SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val); 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci/*********************************************/ 4158c2ecf20Sopenharmony_ci/* HELPER: Lock/Unlock CRT2 */ 4168c2ecf20Sopenharmony_ci/*********************************************/ 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_civoid 4198c2ecf20Sopenharmony_ciSiS_UnLockCRT2(struct SiS_Private *SiS_Pr) 4208c2ecf20Sopenharmony_ci{ 4218c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == XGI_20) 4228c2ecf20Sopenharmony_ci return; 4238c2ecf20Sopenharmony_ci else if(SiS_Pr->ChipType >= SIS_315H) 4248c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2f,0x01); 4258c2ecf20Sopenharmony_ci else 4268c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01); 4278c2ecf20Sopenharmony_ci} 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_cistatic 4308c2ecf20Sopenharmony_civoid 4318c2ecf20Sopenharmony_ciSiS_LockCRT2(struct SiS_Private *SiS_Pr) 4328c2ecf20Sopenharmony_ci{ 4338c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == XGI_20) 4348c2ecf20Sopenharmony_ci return; 4358c2ecf20Sopenharmony_ci else if(SiS_Pr->ChipType >= SIS_315H) 4368c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2F,0xFE); 4378c2ecf20Sopenharmony_ci else 4388c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x24,0xFE); 4398c2ecf20Sopenharmony_ci} 4408c2ecf20Sopenharmony_ci 4418c2ecf20Sopenharmony_ci/*********************************************/ 4428c2ecf20Sopenharmony_ci/* HELPER: Write SR11 */ 4438c2ecf20Sopenharmony_ci/*********************************************/ 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_cistatic void 4468c2ecf20Sopenharmony_ciSiS_SetRegSR11ANDOR(struct SiS_Private *SiS_Pr, unsigned short DataAND, unsigned short DataOR) 4478c2ecf20Sopenharmony_ci{ 4488c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_661) { 4498c2ecf20Sopenharmony_ci DataAND &= 0x0f; 4508c2ecf20Sopenharmony_ci DataOR &= 0x0f; 4518c2ecf20Sopenharmony_ci } 4528c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,DataAND,DataOR); 4538c2ecf20Sopenharmony_ci} 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci/*********************************************/ 4568c2ecf20Sopenharmony_ci/* HELPER: Get Pointer to LCD structure */ 4578c2ecf20Sopenharmony_ci/*********************************************/ 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 4608c2ecf20Sopenharmony_cistatic unsigned char * 4618c2ecf20Sopenharmony_ciGetLCDStructPtr661(struct SiS_Private *SiS_Pr) 4628c2ecf20Sopenharmony_ci{ 4638c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 4648c2ecf20Sopenharmony_ci unsigned char *myptr = NULL; 4658c2ecf20Sopenharmony_ci unsigned short romindex = 0, reg = 0, idx = 0; 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ci /* Use the BIOS tables only for LVDS panels; TMDS is unreliable 4688c2ecf20Sopenharmony_ci * due to the variaty of panels the BIOS doesn't know about. 4698c2ecf20Sopenharmony_ci * Exception: If the BIOS has better knowledge (such as in case 4708c2ecf20Sopenharmony_ci * of machines with a 301C and a panel that does not support DDC) 4718c2ecf20Sopenharmony_ci * use the BIOS data as well. 4728c2ecf20Sopenharmony_ci */ 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_ROMNew) && 4758c2ecf20Sopenharmony_ci ((SiS_Pr->SiS_VBType & VB_SISLVDS) || (!SiS_Pr->PanelSelfDetected))) { 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_661) reg = 0x3c; 4788c2ecf20Sopenharmony_ci else reg = 0x7d; 4798c2ecf20Sopenharmony_ci 4808c2ecf20Sopenharmony_ci idx = (SiS_GetReg(SiS_Pr->SiS_P3d4,reg) & 0x1f) * 26; 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_ci if(idx < (8*26)) { 4838c2ecf20Sopenharmony_ci myptr = (unsigned char *)&SiS_LCDStruct661[idx]; 4848c2ecf20Sopenharmony_ci } 4858c2ecf20Sopenharmony_ci romindex = SISGETROMW(0x100); 4868c2ecf20Sopenharmony_ci if(romindex) { 4878c2ecf20Sopenharmony_ci romindex += idx; 4888c2ecf20Sopenharmony_ci myptr = &ROMAddr[romindex]; 4898c2ecf20Sopenharmony_ci } 4908c2ecf20Sopenharmony_ci } 4918c2ecf20Sopenharmony_ci return myptr; 4928c2ecf20Sopenharmony_ci} 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_cistatic unsigned short 4958c2ecf20Sopenharmony_ciGetLCDStructPtr661_2(struct SiS_Private *SiS_Pr) 4968c2ecf20Sopenharmony_ci{ 4978c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 4988c2ecf20Sopenharmony_ci unsigned short romptr = 0; 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_ci /* Use the BIOS tables only for LVDS panels; TMDS is unreliable 5018c2ecf20Sopenharmony_ci * due to the variaty of panels the BIOS doesn't know about. 5028c2ecf20Sopenharmony_ci * Exception: If the BIOS has better knowledge (such as in case 5038c2ecf20Sopenharmony_ci * of machines with a 301C and a panel that does not support DDC) 5048c2ecf20Sopenharmony_ci * use the BIOS data as well. 5058c2ecf20Sopenharmony_ci */ 5068c2ecf20Sopenharmony_ci 5078c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_ROMNew) && 5088c2ecf20Sopenharmony_ci ((SiS_Pr->SiS_VBType & VB_SISLVDS) || (!SiS_Pr->PanelSelfDetected))) { 5098c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x102); 5108c2ecf20Sopenharmony_ci romptr += ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) * SiS_Pr->SiS661LCD2TableSize); 5118c2ecf20Sopenharmony_ci } 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_ci return romptr; 5148c2ecf20Sopenharmony_ci} 5158c2ecf20Sopenharmony_ci#endif 5168c2ecf20Sopenharmony_ci 5178c2ecf20Sopenharmony_ci/*********************************************/ 5188c2ecf20Sopenharmony_ci/* Adjust Rate for CRT2 */ 5198c2ecf20Sopenharmony_ci/*********************************************/ 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_cistatic bool 5228c2ecf20Sopenharmony_ciSiS_AdjustCRT2Rate(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 5238c2ecf20Sopenharmony_ci unsigned short RRTI, unsigned short *i) 5248c2ecf20Sopenharmony_ci{ 5258c2ecf20Sopenharmony_ci unsigned short checkmask=0, modeid, infoflag; 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_ci modeid = SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID; 5288c2ecf20Sopenharmony_ci 5298c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_ci checkmask |= SupportRAMDAC2; 5348c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 5358c2ecf20Sopenharmony_ci checkmask |= SupportRAMDAC2_135; 5368c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 5378c2ecf20Sopenharmony_ci checkmask |= SupportRAMDAC2_162; 5388c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISRAMDAC202) { 5398c2ecf20Sopenharmony_ci checkmask |= SupportRAMDAC2_202; 5408c2ecf20Sopenharmony_ci } 5418c2ecf20Sopenharmony_ci } 5428c2ecf20Sopenharmony_ci } 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 5458c2ecf20Sopenharmony_ci 5468c2ecf20Sopenharmony_ci checkmask |= SupportLCD; 5478c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 5488c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 5498c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { 5508c2ecf20Sopenharmony_ci if(modeid == 0x2e) checkmask |= Support64048060Hz; 5518c2ecf20Sopenharmony_ci } 5528c2ecf20Sopenharmony_ci } 5538c2ecf20Sopenharmony_ci } 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_ci checkmask |= SupportHiVision; 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750|SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) { 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci checkmask |= SupportTV; 5628c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 5638c2ecf20Sopenharmony_ci checkmask |= SupportTV1024; 5648c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 5658c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { 5668c2ecf20Sopenharmony_ci checkmask |= SupportYPbPr750p; 5678c2ecf20Sopenharmony_ci } 5688c2ecf20Sopenharmony_ci } 5698c2ecf20Sopenharmony_ci } 5708c2ecf20Sopenharmony_ci 5718c2ecf20Sopenharmony_ci } 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_ci } else { /* LVDS */ 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 5768c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 5778c2ecf20Sopenharmony_ci checkmask |= SupportCHTV; 5788c2ecf20Sopenharmony_ci } 5798c2ecf20Sopenharmony_ci } 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 5828c2ecf20Sopenharmony_ci checkmask |= SupportLCD; 5838c2ecf20Sopenharmony_ci } 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_ci } 5868c2ecf20Sopenharmony_ci 5878c2ecf20Sopenharmony_ci /* Look backwards in table for matching CRT2 mode */ 5888c2ecf20Sopenharmony_ci for(; SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID == modeid; (*i)--) { 5898c2ecf20Sopenharmony_ci infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag; 5908c2ecf20Sopenharmony_ci if(infoflag & checkmask) return true; 5918c2ecf20Sopenharmony_ci if((*i) == 0) break; 5928c2ecf20Sopenharmony_ci } 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ci /* Look through the whole mode-section of the table from the beginning 5958c2ecf20Sopenharmony_ci * for a matching CRT2 mode if no mode was found yet. 5968c2ecf20Sopenharmony_ci */ 5978c2ecf20Sopenharmony_ci for((*i) = 0; ; (*i)++) { 5988c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID != modeid) break; 5998c2ecf20Sopenharmony_ci infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag; 6008c2ecf20Sopenharmony_ci if(infoflag & checkmask) return true; 6018c2ecf20Sopenharmony_ci } 6028c2ecf20Sopenharmony_ci return false; 6038c2ecf20Sopenharmony_ci} 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci/*********************************************/ 6068c2ecf20Sopenharmony_ci/* Get rate index */ 6078c2ecf20Sopenharmony_ci/*********************************************/ 6088c2ecf20Sopenharmony_ci 6098c2ecf20Sopenharmony_ciunsigned short 6108c2ecf20Sopenharmony_ciSiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 6118c2ecf20Sopenharmony_ci{ 6128c2ecf20Sopenharmony_ci unsigned short RRTI,i,backup_i; 6138c2ecf20Sopenharmony_ci unsigned short modeflag,index,temp,backupindex; 6148c2ecf20Sopenharmony_ci static const unsigned short LCDRefreshIndex[] = { 6158c2ecf20Sopenharmony_ci 0x00, 0x00, 0x01, 0x01, 6168c2ecf20Sopenharmony_ci 0x01, 0x01, 0x01, 0x01, 6178c2ecf20Sopenharmony_ci 0x01, 0x01, 0x01, 0x01, 6188c2ecf20Sopenharmony_ci 0x01, 0x01, 0x01, 0x01, 6198c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00 6208c2ecf20Sopenharmony_ci }; 6218c2ecf20Sopenharmony_ci 6228c2ecf20Sopenharmony_ci /* Do NOT check for UseCustomMode here, will skrew up FIFO */ 6238c2ecf20Sopenharmony_ci if(ModeNo == 0xfe) return 0; 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 6268c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 6278c2ecf20Sopenharmony_ci } else { 6288c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 6298c2ecf20Sopenharmony_ci } 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 6328c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 6338c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) return 0; 6348c2ecf20Sopenharmony_ci } 6358c2ecf20Sopenharmony_ci } 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ci if(ModeNo < 0x14) return 0xFFFF; 6388c2ecf20Sopenharmony_ci 6398c2ecf20Sopenharmony_ci index = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x33) >> SiS_Pr->SiS_SelectCRT2Rate) & 0x0F; 6408c2ecf20Sopenharmony_ci backupindex = index; 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_ci if(index > 0) index--; 6438c2ecf20Sopenharmony_ci 6448c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { 6458c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 6468c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 6478c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_NoLCD) index = 0; 6488c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index = backupindex = 0; 6498c2ecf20Sopenharmony_ci } 6508c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 6518c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) { 6528c2ecf20Sopenharmony_ci temp = LCDRefreshIndex[SiS_GetBIOSLCDResInfo(SiS_Pr)]; 6538c2ecf20Sopenharmony_ci if(index > temp) index = temp; 6548c2ecf20Sopenharmony_ci } 6558c2ecf20Sopenharmony_ci } 6568c2ecf20Sopenharmony_ci } else { 6578c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0; 6588c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 6598c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) index = 0; 6608c2ecf20Sopenharmony_ci } 6618c2ecf20Sopenharmony_ci } 6628c2ecf20Sopenharmony_ci } 6638c2ecf20Sopenharmony_ci 6648c2ecf20Sopenharmony_ci RRTI = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; 6658c2ecf20Sopenharmony_ci ModeNo = SiS_Pr->SiS_RefIndex[RRTI].ModeID; 6668c2ecf20Sopenharmony_ci 6678c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 6688c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & DriverMode)) { 6698c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x105) || 6708c2ecf20Sopenharmony_ci (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x107) ) { 6718c2ecf20Sopenharmony_ci if(backupindex <= 1) RRTI++; 6728c2ecf20Sopenharmony_ci } 6738c2ecf20Sopenharmony_ci } 6748c2ecf20Sopenharmony_ci } 6758c2ecf20Sopenharmony_ci 6768c2ecf20Sopenharmony_ci i = 0; 6778c2ecf20Sopenharmony_ci do { 6788c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_RefIndex[RRTI + i].ModeID != ModeNo) break; 6798c2ecf20Sopenharmony_ci temp = SiS_Pr->SiS_RefIndex[RRTI + i].Ext_InfoFlag; 6808c2ecf20Sopenharmony_ci temp &= ModeTypeMask; 6818c2ecf20Sopenharmony_ci if(temp < SiS_Pr->SiS_ModeType) break; 6828c2ecf20Sopenharmony_ci i++; 6838c2ecf20Sopenharmony_ci index--; 6848c2ecf20Sopenharmony_ci } while(index != 0xFFFF); 6858c2ecf20Sopenharmony_ci 6868c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { 6878c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 6888c2ecf20Sopenharmony_ci temp = SiS_Pr->SiS_RefIndex[RRTI + i - 1].Ext_InfoFlag; 6898c2ecf20Sopenharmony_ci if(temp & InterlaceMode) i++; 6908c2ecf20Sopenharmony_ci } 6918c2ecf20Sopenharmony_ci } 6928c2ecf20Sopenharmony_ci 6938c2ecf20Sopenharmony_ci i--; 6948c2ecf20Sopenharmony_ci 6958c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_SetFlag & ProgrammingCRT2) && (!(SiS_Pr->SiS_VBInfo & DisableCRT2Display))) { 6968c2ecf20Sopenharmony_ci backup_i = i; 6978c2ecf20Sopenharmony_ci if(!(SiS_AdjustCRT2Rate(SiS_Pr, ModeNo, ModeIdIndex, RRTI, &i))) { 6988c2ecf20Sopenharmony_ci i = backup_i; 6998c2ecf20Sopenharmony_ci } 7008c2ecf20Sopenharmony_ci } 7018c2ecf20Sopenharmony_ci 7028c2ecf20Sopenharmony_ci return (RRTI + i); 7038c2ecf20Sopenharmony_ci} 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_ci/*********************************************/ 7068c2ecf20Sopenharmony_ci/* STORE CRT2 INFO in CR34 */ 7078c2ecf20Sopenharmony_ci/*********************************************/ 7088c2ecf20Sopenharmony_ci 7098c2ecf20Sopenharmony_cistatic void 7108c2ecf20Sopenharmony_ciSiS_SaveCRT2Info(struct SiS_Private *SiS_Pr, unsigned short ModeNo) 7118c2ecf20Sopenharmony_ci{ 7128c2ecf20Sopenharmony_ci unsigned short temp1, temp2; 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_ci /* Store CRT1 ModeNo in CR34 */ 7158c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3d4,0x34,ModeNo); 7168c2ecf20Sopenharmony_ci temp1 = (SiS_Pr->SiS_VBInfo & SetInSlaveMode) >> 8; 7178c2ecf20Sopenharmony_ci temp2 = ~(SetInSlaveMode >> 8); 7188c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x31,temp2,temp1); 7198c2ecf20Sopenharmony_ci} 7208c2ecf20Sopenharmony_ci 7218c2ecf20Sopenharmony_ci/*********************************************/ 7228c2ecf20Sopenharmony_ci/* HELPER: GET SOME DATA FROM BIOS ROM */ 7238c2ecf20Sopenharmony_ci/*********************************************/ 7248c2ecf20Sopenharmony_ci 7258c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 7268c2ecf20Sopenharmony_cistatic bool 7278c2ecf20Sopenharmony_ciSiS_CR36BIOSWord23b(struct SiS_Private *SiS_Pr) 7288c2ecf20Sopenharmony_ci{ 7298c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 7308c2ecf20Sopenharmony_ci unsigned short temp,temp1; 7318c2ecf20Sopenharmony_ci 7328c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 7338c2ecf20Sopenharmony_ci if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { 7348c2ecf20Sopenharmony_ci temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f); 7358c2ecf20Sopenharmony_ci temp1 = SISGETROMW(0x23b); 7368c2ecf20Sopenharmony_ci if(temp1 & temp) return true; 7378c2ecf20Sopenharmony_ci } 7388c2ecf20Sopenharmony_ci } 7398c2ecf20Sopenharmony_ci return false; 7408c2ecf20Sopenharmony_ci} 7418c2ecf20Sopenharmony_ci 7428c2ecf20Sopenharmony_cistatic bool 7438c2ecf20Sopenharmony_ciSiS_CR36BIOSWord23d(struct SiS_Private *SiS_Pr) 7448c2ecf20Sopenharmony_ci{ 7458c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 7468c2ecf20Sopenharmony_ci unsigned short temp,temp1; 7478c2ecf20Sopenharmony_ci 7488c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 7498c2ecf20Sopenharmony_ci if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { 7508c2ecf20Sopenharmony_ci temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f); 7518c2ecf20Sopenharmony_ci temp1 = SISGETROMW(0x23d); 7528c2ecf20Sopenharmony_ci if(temp1 & temp) return true; 7538c2ecf20Sopenharmony_ci } 7548c2ecf20Sopenharmony_ci } 7558c2ecf20Sopenharmony_ci return false; 7568c2ecf20Sopenharmony_ci} 7578c2ecf20Sopenharmony_ci#endif 7588c2ecf20Sopenharmony_ci 7598c2ecf20Sopenharmony_ci/*********************************************/ 7608c2ecf20Sopenharmony_ci/* HELPER: DELAY FUNCTIONS */ 7618c2ecf20Sopenharmony_ci/*********************************************/ 7628c2ecf20Sopenharmony_ci 7638c2ecf20Sopenharmony_civoid 7648c2ecf20Sopenharmony_ciSiS_DDC2Delay(struct SiS_Private *SiS_Pr, unsigned int delaytime) 7658c2ecf20Sopenharmony_ci{ 7668c2ecf20Sopenharmony_ci while (delaytime-- > 0) 7678c2ecf20Sopenharmony_ci SiS_GetReg(SiS_Pr->SiS_P3c4, 0x05); 7688c2ecf20Sopenharmony_ci} 7698c2ecf20Sopenharmony_ci 7708c2ecf20Sopenharmony_ci#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315) 7718c2ecf20Sopenharmony_cistatic void 7728c2ecf20Sopenharmony_ciSiS_GenericDelay(struct SiS_Private *SiS_Pr, unsigned short delay) 7738c2ecf20Sopenharmony_ci{ 7748c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr, delay * 36); 7758c2ecf20Sopenharmony_ci} 7768c2ecf20Sopenharmony_ci#endif 7778c2ecf20Sopenharmony_ci 7788c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 7798c2ecf20Sopenharmony_cistatic void 7808c2ecf20Sopenharmony_ciSiS_LongDelay(struct SiS_Private *SiS_Pr, unsigned short delay) 7818c2ecf20Sopenharmony_ci{ 7828c2ecf20Sopenharmony_ci while(delay--) { 7838c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 6623); 7848c2ecf20Sopenharmony_ci } 7858c2ecf20Sopenharmony_ci} 7868c2ecf20Sopenharmony_ci#endif 7878c2ecf20Sopenharmony_ci 7888c2ecf20Sopenharmony_ci#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315) 7898c2ecf20Sopenharmony_cistatic void 7908c2ecf20Sopenharmony_ciSiS_ShortDelay(struct SiS_Private *SiS_Pr, unsigned short delay) 7918c2ecf20Sopenharmony_ci{ 7928c2ecf20Sopenharmony_ci while(delay--) { 7938c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 66); 7948c2ecf20Sopenharmony_ci } 7958c2ecf20Sopenharmony_ci} 7968c2ecf20Sopenharmony_ci#endif 7978c2ecf20Sopenharmony_ci 7988c2ecf20Sopenharmony_cistatic void 7998c2ecf20Sopenharmony_ciSiS_PanelDelay(struct SiS_Private *SiS_Pr, unsigned short DelayTime) 8008c2ecf20Sopenharmony_ci{ 8018c2ecf20Sopenharmony_ci#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315) 8028c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 8038c2ecf20Sopenharmony_ci unsigned short PanelID, DelayIndex, Delay=0; 8048c2ecf20Sopenharmony_ci#endif 8058c2ecf20Sopenharmony_ci 8068c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 8078c2ecf20Sopenharmony_ci 8088c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 8098c2ecf20Sopenharmony_ci 8108c2ecf20Sopenharmony_ci PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); 8118c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 8128c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS301) PanelID &= 0xf7; 8138c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x18) & 0x10)) PanelID = 0x12; 8148c2ecf20Sopenharmony_ci } 8158c2ecf20Sopenharmony_ci DelayIndex = PanelID >> 4; 8168c2ecf20Sopenharmony_ci if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { 8178c2ecf20Sopenharmony_ci Delay = 3; 8188c2ecf20Sopenharmony_ci } else { 8198c2ecf20Sopenharmony_ci if(DelayTime >= 2) DelayTime -= 2; 8208c2ecf20Sopenharmony_ci if(!(DelayTime & 0x01)) { 8218c2ecf20Sopenharmony_ci Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; 8228c2ecf20Sopenharmony_ci } else { 8238c2ecf20Sopenharmony_ci Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; 8248c2ecf20Sopenharmony_ci } 8258c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 8268c2ecf20Sopenharmony_ci if(ROMAddr[0x220] & 0x40) { 8278c2ecf20Sopenharmony_ci if(!(DelayTime & 0x01)) Delay = (unsigned short)ROMAddr[0x225]; 8288c2ecf20Sopenharmony_ci else Delay = (unsigned short)ROMAddr[0x226]; 8298c2ecf20Sopenharmony_ci } 8308c2ecf20Sopenharmony_ci } 8318c2ecf20Sopenharmony_ci } 8328c2ecf20Sopenharmony_ci SiS_ShortDelay(SiS_Pr, Delay); 8338c2ecf20Sopenharmony_ci 8348c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_300 */ 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_ci } else { 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 8398c2ecf20Sopenharmony_ci 8408c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType >= SIS_661) || 8418c2ecf20Sopenharmony_ci (SiS_Pr->ChipType <= SIS_315PRO) || 8428c2ecf20Sopenharmony_ci (SiS_Pr->ChipType == SIS_330) || 8438c2ecf20Sopenharmony_ci (SiS_Pr->SiS_ROMNew)) { 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_ci if(!(DelayTime & 0x01)) { 8468c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr, 0x1000); 8478c2ecf20Sopenharmony_ci } else { 8488c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr, 0x4000); 8498c2ecf20Sopenharmony_ci } 8508c2ecf20Sopenharmony_ci 8518c2ecf20Sopenharmony_ci } else if (SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 315 series, LVDS; Special */ 8528c2ecf20Sopenharmony_ci 8538c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 8548c2ecf20Sopenharmony_ci PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); 8558c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_CLEVO1400) { 8568c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1b) & 0x10)) PanelID = 0x12; 8578c2ecf20Sopenharmony_ci } 8588c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { 8598c2ecf20Sopenharmony_ci DelayIndex = PanelID & 0x0f; 8608c2ecf20Sopenharmony_ci } else { 8618c2ecf20Sopenharmony_ci DelayIndex = PanelID >> 4; 8628c2ecf20Sopenharmony_ci } 8638c2ecf20Sopenharmony_ci if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { 8648c2ecf20Sopenharmony_ci Delay = 3; 8658c2ecf20Sopenharmony_ci } else { 8668c2ecf20Sopenharmony_ci if(DelayTime >= 2) DelayTime -= 2; 8678c2ecf20Sopenharmony_ci if(!(DelayTime & 0x01)) { 8688c2ecf20Sopenharmony_ci Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[0]; 8698c2ecf20Sopenharmony_ci } else { 8708c2ecf20Sopenharmony_ci Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[1]; 8718c2ecf20Sopenharmony_ci } 8728c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { 8738c2ecf20Sopenharmony_ci if(ROMAddr[0x13c] & 0x40) { 8748c2ecf20Sopenharmony_ci if(!(DelayTime & 0x01)) { 8758c2ecf20Sopenharmony_ci Delay = (unsigned short)ROMAddr[0x17e]; 8768c2ecf20Sopenharmony_ci } else { 8778c2ecf20Sopenharmony_ci Delay = (unsigned short)ROMAddr[0x17f]; 8788c2ecf20Sopenharmony_ci } 8798c2ecf20Sopenharmony_ci } 8808c2ecf20Sopenharmony_ci } 8818c2ecf20Sopenharmony_ci } 8828c2ecf20Sopenharmony_ci SiS_ShortDelay(SiS_Pr, Delay); 8838c2ecf20Sopenharmony_ci } 8848c2ecf20Sopenharmony_ci 8858c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 315 series, all bridges */ 8868c2ecf20Sopenharmony_ci 8878c2ecf20Sopenharmony_ci DelayIndex = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4; 8888c2ecf20Sopenharmony_ci if(!(DelayTime & 0x01)) { 8898c2ecf20Sopenharmony_ci Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; 8908c2ecf20Sopenharmony_ci } else { 8918c2ecf20Sopenharmony_ci Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; 8928c2ecf20Sopenharmony_ci } 8938c2ecf20Sopenharmony_ci Delay <<= 8; 8948c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr, Delay); 8958c2ecf20Sopenharmony_ci 8968c2ecf20Sopenharmony_ci } 8978c2ecf20Sopenharmony_ci 8988c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_315 */ 8998c2ecf20Sopenharmony_ci 9008c2ecf20Sopenharmony_ci } 9018c2ecf20Sopenharmony_ci} 9028c2ecf20Sopenharmony_ci 9038c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 9048c2ecf20Sopenharmony_cistatic void 9058c2ecf20Sopenharmony_ciSiS_PanelDelayLoop(struct SiS_Private *SiS_Pr, unsigned short DelayTime, unsigned short DelayLoop) 9068c2ecf20Sopenharmony_ci{ 9078c2ecf20Sopenharmony_ci int i; 9088c2ecf20Sopenharmony_ci for(i = 0; i < DelayLoop; i++) { 9098c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, DelayTime); 9108c2ecf20Sopenharmony_ci } 9118c2ecf20Sopenharmony_ci} 9128c2ecf20Sopenharmony_ci#endif 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ci/*********************************************/ 9158c2ecf20Sopenharmony_ci/* HELPER: WAIT-FOR-RETRACE FUNCTIONS */ 9168c2ecf20Sopenharmony_ci/*********************************************/ 9178c2ecf20Sopenharmony_ci 9188c2ecf20Sopenharmony_civoid 9198c2ecf20Sopenharmony_ciSiS_WaitRetrace1(struct SiS_Private *SiS_Pr) 9208c2ecf20Sopenharmony_ci{ 9218c2ecf20Sopenharmony_ci unsigned short watchdog; 9228c2ecf20Sopenharmony_ci 9238c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return; 9248c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80)) return; 9258c2ecf20Sopenharmony_ci 9268c2ecf20Sopenharmony_ci watchdog = 65535; 9278c2ecf20Sopenharmony_ci while((SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08) && --watchdog); 9288c2ecf20Sopenharmony_ci watchdog = 65535; 9298c2ecf20Sopenharmony_ci while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); 9308c2ecf20Sopenharmony_ci} 9318c2ecf20Sopenharmony_ci 9328c2ecf20Sopenharmony_ci#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315) 9338c2ecf20Sopenharmony_cistatic void 9348c2ecf20Sopenharmony_ciSiS_WaitRetrace2(struct SiS_Private *SiS_Pr, unsigned short reg) 9358c2ecf20Sopenharmony_ci{ 9368c2ecf20Sopenharmony_ci unsigned short watchdog; 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_ci watchdog = 65535; 9398c2ecf20Sopenharmony_ci while((SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02) && --watchdog); 9408c2ecf20Sopenharmony_ci watchdog = 65535; 9418c2ecf20Sopenharmony_ci while((!(SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02)) && --watchdog); 9428c2ecf20Sopenharmony_ci} 9438c2ecf20Sopenharmony_ci#endif 9448c2ecf20Sopenharmony_ci 9458c2ecf20Sopenharmony_cistatic void 9468c2ecf20Sopenharmony_ciSiS_WaitVBRetrace(struct SiS_Private *SiS_Pr) 9478c2ecf20Sopenharmony_ci{ 9488c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 9498c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 9508c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 9518c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return; 9528c2ecf20Sopenharmony_ci } 9538c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x80)) { 9548c2ecf20Sopenharmony_ci SiS_WaitRetrace1(SiS_Pr); 9558c2ecf20Sopenharmony_ci } else { 9568c2ecf20Sopenharmony_ci SiS_WaitRetrace2(SiS_Pr, 0x25); 9578c2ecf20Sopenharmony_ci } 9588c2ecf20Sopenharmony_ci#endif 9598c2ecf20Sopenharmony_ci } else { 9608c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 9618c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) { 9628c2ecf20Sopenharmony_ci SiS_WaitRetrace1(SiS_Pr); 9638c2ecf20Sopenharmony_ci } else { 9648c2ecf20Sopenharmony_ci SiS_WaitRetrace2(SiS_Pr, 0x30); 9658c2ecf20Sopenharmony_ci } 9668c2ecf20Sopenharmony_ci#endif 9678c2ecf20Sopenharmony_ci } 9688c2ecf20Sopenharmony_ci} 9698c2ecf20Sopenharmony_ci 9708c2ecf20Sopenharmony_cistatic void 9718c2ecf20Sopenharmony_ciSiS_VBWait(struct SiS_Private *SiS_Pr) 9728c2ecf20Sopenharmony_ci{ 9738c2ecf20Sopenharmony_ci unsigned short tempal,temp,i,j; 9748c2ecf20Sopenharmony_ci 9758c2ecf20Sopenharmony_ci temp = 0; 9768c2ecf20Sopenharmony_ci for(i = 0; i < 3; i++) { 9778c2ecf20Sopenharmony_ci for(j = 0; j < 100; j++) { 9788c2ecf20Sopenharmony_ci tempal = SiS_GetRegByte(SiS_Pr->SiS_P3da); 9798c2ecf20Sopenharmony_ci if(temp & 0x01) { 9808c2ecf20Sopenharmony_ci if((tempal & 0x08)) continue; 9818c2ecf20Sopenharmony_ci else break; 9828c2ecf20Sopenharmony_ci } else { 9838c2ecf20Sopenharmony_ci if(!(tempal & 0x08)) continue; 9848c2ecf20Sopenharmony_ci else break; 9858c2ecf20Sopenharmony_ci } 9868c2ecf20Sopenharmony_ci } 9878c2ecf20Sopenharmony_ci temp ^= 0x01; 9888c2ecf20Sopenharmony_ci } 9898c2ecf20Sopenharmony_ci} 9908c2ecf20Sopenharmony_ci 9918c2ecf20Sopenharmony_cistatic void 9928c2ecf20Sopenharmony_ciSiS_VBLongWait(struct SiS_Private *SiS_Pr) 9938c2ecf20Sopenharmony_ci{ 9948c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 9958c2ecf20Sopenharmony_ci SiS_VBWait(SiS_Pr); 9968c2ecf20Sopenharmony_ci } else { 9978c2ecf20Sopenharmony_ci SiS_WaitRetrace1(SiS_Pr); 9988c2ecf20Sopenharmony_ci } 9998c2ecf20Sopenharmony_ci} 10008c2ecf20Sopenharmony_ci 10018c2ecf20Sopenharmony_ci/*********************************************/ 10028c2ecf20Sopenharmony_ci/* HELPER: MISC */ 10038c2ecf20Sopenharmony_ci/*********************************************/ 10048c2ecf20Sopenharmony_ci 10058c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 10068c2ecf20Sopenharmony_cistatic bool 10078c2ecf20Sopenharmony_ciSiS_Is301B(struct SiS_Private *SiS_Pr) 10088c2ecf20Sopenharmony_ci{ 10098c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01) >= 0xb0) return true; 10108c2ecf20Sopenharmony_ci return false; 10118c2ecf20Sopenharmony_ci} 10128c2ecf20Sopenharmony_ci#endif 10138c2ecf20Sopenharmony_ci 10148c2ecf20Sopenharmony_cistatic bool 10158c2ecf20Sopenharmony_ciSiS_CRT2IsLCD(struct SiS_Private *SiS_Pr) 10168c2ecf20Sopenharmony_ci{ 10178c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_730) { 10188c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x20) return true; 10198c2ecf20Sopenharmony_ci } 10208c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & 0x20) return true; 10218c2ecf20Sopenharmony_ci return false; 10228c2ecf20Sopenharmony_ci} 10238c2ecf20Sopenharmony_ci 10248c2ecf20Sopenharmony_cibool 10258c2ecf20Sopenharmony_ciSiS_IsDualEdge(struct SiS_Private *SiS_Pr) 10268c2ecf20Sopenharmony_ci{ 10278c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 10288c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 10298c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType != SIS_650) || (SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) { 10308c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableDualEdge) return true; 10318c2ecf20Sopenharmony_ci } 10328c2ecf20Sopenharmony_ci } 10338c2ecf20Sopenharmony_ci#endif 10348c2ecf20Sopenharmony_ci return false; 10358c2ecf20Sopenharmony_ci} 10368c2ecf20Sopenharmony_ci 10378c2ecf20Sopenharmony_cibool 10388c2ecf20Sopenharmony_ciSiS_IsVAMode(struct SiS_Private *SiS_Pr) 10398c2ecf20Sopenharmony_ci{ 10408c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 10418c2ecf20Sopenharmony_ci unsigned short flag; 10428c2ecf20Sopenharmony_ci 10438c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 10448c2ecf20Sopenharmony_ci flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 10458c2ecf20Sopenharmony_ci if((flag & EnableDualEdge) && (flag & SetToLCDA)) return true; 10468c2ecf20Sopenharmony_ci } 10478c2ecf20Sopenharmony_ci#endif 10488c2ecf20Sopenharmony_ci return false; 10498c2ecf20Sopenharmony_ci} 10508c2ecf20Sopenharmony_ci 10518c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 10528c2ecf20Sopenharmony_cistatic bool 10538c2ecf20Sopenharmony_ciSiS_IsVAorLCD(struct SiS_Private *SiS_Pr) 10548c2ecf20Sopenharmony_ci{ 10558c2ecf20Sopenharmony_ci if(SiS_IsVAMode(SiS_Pr)) return true; 10568c2ecf20Sopenharmony_ci if(SiS_CRT2IsLCD(SiS_Pr)) return true; 10578c2ecf20Sopenharmony_ci return false; 10588c2ecf20Sopenharmony_ci} 10598c2ecf20Sopenharmony_ci#endif 10608c2ecf20Sopenharmony_ci 10618c2ecf20Sopenharmony_cistatic bool 10628c2ecf20Sopenharmony_ciSiS_IsDualLink(struct SiS_Private *SiS_Pr) 10638c2ecf20Sopenharmony_ci{ 10648c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 10658c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 10668c2ecf20Sopenharmony_ci if((SiS_CRT2IsLCD(SiS_Pr)) || 10678c2ecf20Sopenharmony_ci (SiS_IsVAMode(SiS_Pr))) { 10688c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDDualLink) return true; 10698c2ecf20Sopenharmony_ci } 10708c2ecf20Sopenharmony_ci } 10718c2ecf20Sopenharmony_ci#endif 10728c2ecf20Sopenharmony_ci return false; 10738c2ecf20Sopenharmony_ci} 10748c2ecf20Sopenharmony_ci 10758c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 10768c2ecf20Sopenharmony_cistatic bool 10778c2ecf20Sopenharmony_ciSiS_TVEnabled(struct SiS_Private *SiS_Pr) 10788c2ecf20Sopenharmony_ci{ 10798c2ecf20Sopenharmony_ci if((SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) != 0x0c) return true; 10808c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISYPBPR) { 10818c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_Part2Port,0x4d) & 0x10) return true; 10828c2ecf20Sopenharmony_ci } 10838c2ecf20Sopenharmony_ci return false; 10848c2ecf20Sopenharmony_ci} 10858c2ecf20Sopenharmony_ci#endif 10868c2ecf20Sopenharmony_ci 10878c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 10888c2ecf20Sopenharmony_cistatic bool 10898c2ecf20Sopenharmony_ciSiS_LCDAEnabled(struct SiS_Private *SiS_Pr) 10908c2ecf20Sopenharmony_ci{ 10918c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) return true; 10928c2ecf20Sopenharmony_ci return false; 10938c2ecf20Sopenharmony_ci} 10948c2ecf20Sopenharmony_ci#endif 10958c2ecf20Sopenharmony_ci 10968c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 10978c2ecf20Sopenharmony_cistatic bool 10988c2ecf20Sopenharmony_ciSiS_WeHaveBacklightCtrl(struct SiS_Private *SiS_Pr) 10998c2ecf20Sopenharmony_ci{ 11008c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) { 11018c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x79) & 0x10) return true; 11028c2ecf20Sopenharmony_ci } 11038c2ecf20Sopenharmony_ci return false; 11048c2ecf20Sopenharmony_ci} 11058c2ecf20Sopenharmony_ci#endif 11068c2ecf20Sopenharmony_ci 11078c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 11088c2ecf20Sopenharmony_cistatic bool 11098c2ecf20Sopenharmony_ciSiS_IsNotM650orLater(struct SiS_Private *SiS_Pr) 11108c2ecf20Sopenharmony_ci{ 11118c2ecf20Sopenharmony_ci unsigned short flag; 11128c2ecf20Sopenharmony_ci 11138c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_650) { 11148c2ecf20Sopenharmony_ci flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0; 11158c2ecf20Sopenharmony_ci /* Check for revision != A0 only */ 11168c2ecf20Sopenharmony_ci if((flag == 0xe0) || (flag == 0xc0) || 11178c2ecf20Sopenharmony_ci (flag == 0xb0) || (flag == 0x90)) return false; 11188c2ecf20Sopenharmony_ci } else if(SiS_Pr->ChipType >= SIS_661) return false; 11198c2ecf20Sopenharmony_ci return true; 11208c2ecf20Sopenharmony_ci} 11218c2ecf20Sopenharmony_ci#endif 11228c2ecf20Sopenharmony_ci 11238c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 11248c2ecf20Sopenharmony_cistatic bool 11258c2ecf20Sopenharmony_ciSiS_IsYPbPr(struct SiS_Private *SiS_Pr) 11268c2ecf20Sopenharmony_ci{ 11278c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 11288c2ecf20Sopenharmony_ci /* YPrPb = 0x08 */ 11298c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableCHYPbPr) return true; 11308c2ecf20Sopenharmony_ci } 11318c2ecf20Sopenharmony_ci return false; 11328c2ecf20Sopenharmony_ci} 11338c2ecf20Sopenharmony_ci#endif 11348c2ecf20Sopenharmony_ci 11358c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 11368c2ecf20Sopenharmony_cistatic bool 11378c2ecf20Sopenharmony_ciSiS_IsChScart(struct SiS_Private *SiS_Pr) 11388c2ecf20Sopenharmony_ci{ 11398c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 11408c2ecf20Sopenharmony_ci /* Scart = 0x04 */ 11418c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableCHScart) return true; 11428c2ecf20Sopenharmony_ci } 11438c2ecf20Sopenharmony_ci return false; 11448c2ecf20Sopenharmony_ci} 11458c2ecf20Sopenharmony_ci#endif 11468c2ecf20Sopenharmony_ci 11478c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 11488c2ecf20Sopenharmony_cistatic bool 11498c2ecf20Sopenharmony_ciSiS_IsTVOrYPbPrOrScart(struct SiS_Private *SiS_Pr) 11508c2ecf20Sopenharmony_ci{ 11518c2ecf20Sopenharmony_ci unsigned short flag; 11528c2ecf20Sopenharmony_ci 11538c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 11548c2ecf20Sopenharmony_ci flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 11558c2ecf20Sopenharmony_ci if(flag & SetCRT2ToTV) return true; 11568c2ecf20Sopenharmony_ci flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 11578c2ecf20Sopenharmony_ci if(flag & EnableCHYPbPr) return true; /* = YPrPb = 0x08 */ 11588c2ecf20Sopenharmony_ci if(flag & EnableCHScart) return true; /* = Scart = 0x04 - TW */ 11598c2ecf20Sopenharmony_ci } else { 11608c2ecf20Sopenharmony_ci flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 11618c2ecf20Sopenharmony_ci if(flag & SetCRT2ToTV) return true; 11628c2ecf20Sopenharmony_ci } 11638c2ecf20Sopenharmony_ci return false; 11648c2ecf20Sopenharmony_ci} 11658c2ecf20Sopenharmony_ci#endif 11668c2ecf20Sopenharmony_ci 11678c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 11688c2ecf20Sopenharmony_cistatic bool 11698c2ecf20Sopenharmony_ciSiS_IsLCDOrLCDA(struct SiS_Private *SiS_Pr) 11708c2ecf20Sopenharmony_ci{ 11718c2ecf20Sopenharmony_ci unsigned short flag; 11728c2ecf20Sopenharmony_ci 11738c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 11748c2ecf20Sopenharmony_ci flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 11758c2ecf20Sopenharmony_ci if(flag & SetCRT2ToLCD) return true; 11768c2ecf20Sopenharmony_ci flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 11778c2ecf20Sopenharmony_ci if(flag & SetToLCDA) return true; 11788c2ecf20Sopenharmony_ci } else { 11798c2ecf20Sopenharmony_ci flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 11808c2ecf20Sopenharmony_ci if(flag & SetCRT2ToLCD) return true; 11818c2ecf20Sopenharmony_ci } 11828c2ecf20Sopenharmony_ci return false; 11838c2ecf20Sopenharmony_ci} 11848c2ecf20Sopenharmony_ci#endif 11858c2ecf20Sopenharmony_ci 11868c2ecf20Sopenharmony_cistatic bool 11878c2ecf20Sopenharmony_ciSiS_HaveBridge(struct SiS_Private *SiS_Pr) 11888c2ecf20Sopenharmony_ci{ 11898c2ecf20Sopenharmony_ci unsigned short flag; 11908c2ecf20Sopenharmony_ci 11918c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 11928c2ecf20Sopenharmony_ci return true; 11938c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 11948c2ecf20Sopenharmony_ci flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); 11958c2ecf20Sopenharmony_ci if((flag == 1) || (flag == 2)) return true; 11968c2ecf20Sopenharmony_ci } 11978c2ecf20Sopenharmony_ci return false; 11988c2ecf20Sopenharmony_ci} 11998c2ecf20Sopenharmony_ci 12008c2ecf20Sopenharmony_cistatic bool 12018c2ecf20Sopenharmony_ciSiS_BridgeIsEnabled(struct SiS_Private *SiS_Pr) 12028c2ecf20Sopenharmony_ci{ 12038c2ecf20Sopenharmony_ci unsigned short flag; 12048c2ecf20Sopenharmony_ci 12058c2ecf20Sopenharmony_ci if(SiS_HaveBridge(SiS_Pr)) { 12068c2ecf20Sopenharmony_ci flag = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); 12078c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 12088c2ecf20Sopenharmony_ci flag &= 0xa0; 12098c2ecf20Sopenharmony_ci if((flag == 0x80) || (flag == 0x20)) return true; 12108c2ecf20Sopenharmony_ci } else { 12118c2ecf20Sopenharmony_ci flag &= 0x50; 12128c2ecf20Sopenharmony_ci if((flag == 0x40) || (flag == 0x10)) return true; 12138c2ecf20Sopenharmony_ci } 12148c2ecf20Sopenharmony_ci } 12158c2ecf20Sopenharmony_ci return false; 12168c2ecf20Sopenharmony_ci} 12178c2ecf20Sopenharmony_ci 12188c2ecf20Sopenharmony_cistatic bool 12198c2ecf20Sopenharmony_ciSiS_BridgeInSlavemode(struct SiS_Private *SiS_Pr) 12208c2ecf20Sopenharmony_ci{ 12218c2ecf20Sopenharmony_ci unsigned short flag1; 12228c2ecf20Sopenharmony_ci 12238c2ecf20Sopenharmony_ci flag1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); 12248c2ecf20Sopenharmony_ci if(flag1 & (SetInSlaveMode >> 8)) return true; 12258c2ecf20Sopenharmony_ci return false; 12268c2ecf20Sopenharmony_ci} 12278c2ecf20Sopenharmony_ci 12288c2ecf20Sopenharmony_ci/*********************************************/ 12298c2ecf20Sopenharmony_ci/* GET VIDEO BRIDGE CONFIG INFO */ 12308c2ecf20Sopenharmony_ci/*********************************************/ 12318c2ecf20Sopenharmony_ci 12328c2ecf20Sopenharmony_ci/* Setup general purpose IO for Chrontel communication */ 12338c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 12348c2ecf20Sopenharmony_civoid 12358c2ecf20Sopenharmony_ciSiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo) 12368c2ecf20Sopenharmony_ci{ 12378c2ecf20Sopenharmony_ci unsigned int acpibase; 12388c2ecf20Sopenharmony_ci unsigned short temp; 12398c2ecf20Sopenharmony_ci 12408c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_ChSW)) return; 12418c2ecf20Sopenharmony_ci 12428c2ecf20Sopenharmony_ci acpibase = sisfb_read_lpc_pci_dword(SiS_Pr, 0x74); 12438c2ecf20Sopenharmony_ci acpibase &= 0xFFFF; 12448c2ecf20Sopenharmony_ci if(!acpibase) return; 12458c2ecf20Sopenharmony_ci temp = SiS_GetRegShort((acpibase + 0x3c)); /* ACPI register 0x3c: GP Event 1 I/O mode select */ 12468c2ecf20Sopenharmony_ci temp &= 0xFEFF; 12478c2ecf20Sopenharmony_ci SiS_SetRegShort((acpibase + 0x3c), temp); 12488c2ecf20Sopenharmony_ci temp = SiS_GetRegShort((acpibase + 0x3c)); 12498c2ecf20Sopenharmony_ci temp = SiS_GetRegShort((acpibase + 0x3a)); /* ACPI register 0x3a: GP Pin Level (low/high) */ 12508c2ecf20Sopenharmony_ci temp &= 0xFEFF; 12518c2ecf20Sopenharmony_ci if(!(myvbinfo & SetCRT2ToTV)) temp |= 0x0100; 12528c2ecf20Sopenharmony_ci SiS_SetRegShort((acpibase + 0x3a), temp); 12538c2ecf20Sopenharmony_ci temp = SiS_GetRegShort((acpibase + 0x3a)); 12548c2ecf20Sopenharmony_ci} 12558c2ecf20Sopenharmony_ci#endif 12568c2ecf20Sopenharmony_ci 12578c2ecf20Sopenharmony_civoid 12588c2ecf20Sopenharmony_ciSiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 12598c2ecf20Sopenharmony_ci unsigned short ModeIdIndex, int checkcrt2mode) 12608c2ecf20Sopenharmony_ci{ 12618c2ecf20Sopenharmony_ci unsigned short tempax, tempbx, temp; 12628c2ecf20Sopenharmony_ci unsigned short modeflag, resinfo = 0; 12638c2ecf20Sopenharmony_ci 12648c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag = 0; 12658c2ecf20Sopenharmony_ci 12668c2ecf20Sopenharmony_ci modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); 12678c2ecf20Sopenharmony_ci 12688c2ecf20Sopenharmony_ci SiS_Pr->SiS_ModeType = modeflag & ModeTypeMask; 12698c2ecf20Sopenharmony_ci 12708c2ecf20Sopenharmony_ci if((ModeNo > 0x13) && (!SiS_Pr->UseCustomMode)) { 12718c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 12728c2ecf20Sopenharmony_ci } 12738c2ecf20Sopenharmony_ci 12748c2ecf20Sopenharmony_ci tempbx = 0; 12758c2ecf20Sopenharmony_ci 12768c2ecf20Sopenharmony_ci if(SiS_HaveBridge(SiS_Pr)) { 12778c2ecf20Sopenharmony_ci 12788c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 12798c2ecf20Sopenharmony_ci tempbx |= temp; 12808c2ecf20Sopenharmony_ci tempax = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) << 8; 12818c2ecf20Sopenharmony_ci tempax &= (DriverMode | LoadDACFlag | SetNotSimuMode | SetPALTV); 12828c2ecf20Sopenharmony_ci tempbx |= tempax; 12838c2ecf20Sopenharmony_ci 12848c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 12858c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 12868c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLCDA) { 12878c2ecf20Sopenharmony_ci if(ModeNo == 0x03) { 12888c2ecf20Sopenharmony_ci /* Mode 0x03 is never in driver mode */ 12898c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x31,0xbf); 12908c2ecf20Sopenharmony_ci } 12918c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8))) { 12928c2ecf20Sopenharmony_ci /* Reset LCDA setting if not driver mode */ 12938c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); 12948c2ecf20Sopenharmony_ci } 12958c2ecf20Sopenharmony_ci if(IS_SIS650) { 12968c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseLCDA) { 12978c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xF0) { 12988c2ecf20Sopenharmony_ci if((ModeNo <= 0x13) || (!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8)))) { 12998c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA)); 13008c2ecf20Sopenharmony_ci } 13018c2ecf20Sopenharmony_ci } 13028c2ecf20Sopenharmony_ci } 13038c2ecf20Sopenharmony_ci } 13048c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 13058c2ecf20Sopenharmony_ci if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) { 13068c2ecf20Sopenharmony_ci tempbx |= SetCRT2ToLCDA; 13078c2ecf20Sopenharmony_ci } 13088c2ecf20Sopenharmony_ci } 13098c2ecf20Sopenharmony_ci 13108c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_661) { /* New CR layout */ 13118c2ecf20Sopenharmony_ci tempbx &= ~(SetCRT2ToYPbPr525750 | SetCRT2ToHiVision); 13128c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & 0x04) { 13138c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0; 13148c2ecf20Sopenharmony_ci if(temp == 0x60) tempbx |= SetCRT2ToHiVision; 13158c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VBType & VB_SISYPBPR) { 13168c2ecf20Sopenharmony_ci tempbx |= SetCRT2ToYPbPr525750; 13178c2ecf20Sopenharmony_ci } 13188c2ecf20Sopenharmony_ci } 13198c2ecf20Sopenharmony_ci } 13208c2ecf20Sopenharmony_ci 13218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 13228c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 13238c2ecf20Sopenharmony_ci if(temp & SetToLCDA) { 13248c2ecf20Sopenharmony_ci tempbx |= SetCRT2ToLCDA; 13258c2ecf20Sopenharmony_ci } 13268c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 13278c2ecf20Sopenharmony_ci if(temp & EnableCHYPbPr) { 13288c2ecf20Sopenharmony_ci tempbx |= SetCRT2ToCHYPbPr; 13298c2ecf20Sopenharmony_ci } 13308c2ecf20Sopenharmony_ci } 13318c2ecf20Sopenharmony_ci } 13328c2ecf20Sopenharmony_ci } 13338c2ecf20Sopenharmony_ci 13348c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_315 */ 13358c2ecf20Sopenharmony_ci 13368c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBType & VB_SISVGA2)) { 13378c2ecf20Sopenharmony_ci tempbx &= ~(SetCRT2ToRAMDAC); 13388c2ecf20Sopenharmony_ci } 13398c2ecf20Sopenharmony_ci 13408c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 13418c2ecf20Sopenharmony_ci temp = SetCRT2ToSVIDEO | 13428c2ecf20Sopenharmony_ci SetCRT2ToAVIDEO | 13438c2ecf20Sopenharmony_ci SetCRT2ToSCART | 13448c2ecf20Sopenharmony_ci SetCRT2ToLCDA | 13458c2ecf20Sopenharmony_ci SetCRT2ToLCD | 13468c2ecf20Sopenharmony_ci SetCRT2ToRAMDAC | 13478c2ecf20Sopenharmony_ci SetCRT2ToHiVision | 13488c2ecf20Sopenharmony_ci SetCRT2ToYPbPr525750; 13498c2ecf20Sopenharmony_ci } else { 13508c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 13518c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 13528c2ecf20Sopenharmony_ci temp = SetCRT2ToAVIDEO | 13538c2ecf20Sopenharmony_ci SetCRT2ToSVIDEO | 13548c2ecf20Sopenharmony_ci SetCRT2ToSCART | 13558c2ecf20Sopenharmony_ci SetCRT2ToLCDA | 13568c2ecf20Sopenharmony_ci SetCRT2ToLCD | 13578c2ecf20Sopenharmony_ci SetCRT2ToCHYPbPr; 13588c2ecf20Sopenharmony_ci } else { 13598c2ecf20Sopenharmony_ci temp = SetCRT2ToLCDA | 13608c2ecf20Sopenharmony_ci SetCRT2ToLCD; 13618c2ecf20Sopenharmony_ci } 13628c2ecf20Sopenharmony_ci } else { 13638c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 13648c2ecf20Sopenharmony_ci temp = SetCRT2ToTV | SetCRT2ToLCD; 13658c2ecf20Sopenharmony_ci } else { 13668c2ecf20Sopenharmony_ci temp = SetCRT2ToLCD; 13678c2ecf20Sopenharmony_ci } 13688c2ecf20Sopenharmony_ci } 13698c2ecf20Sopenharmony_ci } 13708c2ecf20Sopenharmony_ci 13718c2ecf20Sopenharmony_ci if(!(tempbx & temp)) { 13728c2ecf20Sopenharmony_ci tempax = DisableCRT2Display; 13738c2ecf20Sopenharmony_ci tempbx = 0; 13748c2ecf20Sopenharmony_ci } 13758c2ecf20Sopenharmony_ci 13768c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 13778c2ecf20Sopenharmony_ci 13788c2ecf20Sopenharmony_ci unsigned short clearmask = ( DriverMode | 13798c2ecf20Sopenharmony_ci DisableCRT2Display | 13808c2ecf20Sopenharmony_ci LoadDACFlag | 13818c2ecf20Sopenharmony_ci SetNotSimuMode | 13828c2ecf20Sopenharmony_ci SetInSlaveMode | 13838c2ecf20Sopenharmony_ci SetPALTV | 13848c2ecf20Sopenharmony_ci SwitchCRT2 | 13858c2ecf20Sopenharmony_ci SetSimuScanMode ); 13868c2ecf20Sopenharmony_ci 13878c2ecf20Sopenharmony_ci if(tempbx & SetCRT2ToLCDA) tempbx &= (clearmask | SetCRT2ToLCDA); 13888c2ecf20Sopenharmony_ci if(tempbx & SetCRT2ToRAMDAC) tempbx &= (clearmask | SetCRT2ToRAMDAC); 13898c2ecf20Sopenharmony_ci if(tempbx & SetCRT2ToLCD) tempbx &= (clearmask | SetCRT2ToLCD); 13908c2ecf20Sopenharmony_ci if(tempbx & SetCRT2ToSCART) tempbx &= (clearmask | SetCRT2ToSCART); 13918c2ecf20Sopenharmony_ci if(tempbx & SetCRT2ToHiVision) tempbx &= (clearmask | SetCRT2ToHiVision); 13928c2ecf20Sopenharmony_ci if(tempbx & SetCRT2ToYPbPr525750) tempbx &= (clearmask | SetCRT2ToYPbPr525750); 13938c2ecf20Sopenharmony_ci 13948c2ecf20Sopenharmony_ci } else { 13958c2ecf20Sopenharmony_ci 13968c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 13978c2ecf20Sopenharmony_ci if(tempbx & SetCRT2ToLCDA) { 13988c2ecf20Sopenharmony_ci tempbx &= (0xFF00|SwitchCRT2|SetSimuScanMode); 13998c2ecf20Sopenharmony_ci } 14008c2ecf20Sopenharmony_ci } 14018c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 14028c2ecf20Sopenharmony_ci if(tempbx & SetCRT2ToTV) { 14038c2ecf20Sopenharmony_ci tempbx &= (0xFF00|SetCRT2ToTV|SwitchCRT2|SetSimuScanMode); 14048c2ecf20Sopenharmony_ci } 14058c2ecf20Sopenharmony_ci } 14068c2ecf20Sopenharmony_ci if(tempbx & SetCRT2ToLCD) { 14078c2ecf20Sopenharmony_ci tempbx &= (0xFF00|SetCRT2ToLCD|SwitchCRT2|SetSimuScanMode); 14088c2ecf20Sopenharmony_ci } 14098c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 14108c2ecf20Sopenharmony_ci if(tempbx & SetCRT2ToLCDA) { 14118c2ecf20Sopenharmony_ci tempbx |= SetCRT2ToLCD; 14128c2ecf20Sopenharmony_ci } 14138c2ecf20Sopenharmony_ci } 14148c2ecf20Sopenharmony_ci 14158c2ecf20Sopenharmony_ci } 14168c2ecf20Sopenharmony_ci 14178c2ecf20Sopenharmony_ci if(tempax & DisableCRT2Display) { 14188c2ecf20Sopenharmony_ci if(!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { 14198c2ecf20Sopenharmony_ci tempbx = SetSimuScanMode | DisableCRT2Display; 14208c2ecf20Sopenharmony_ci } 14218c2ecf20Sopenharmony_ci } 14228c2ecf20Sopenharmony_ci 14238c2ecf20Sopenharmony_ci if(!(tempbx & DriverMode)) tempbx |= SetSimuScanMode; 14248c2ecf20Sopenharmony_ci 14258c2ecf20Sopenharmony_ci /* LVDS/CHRONTEL (LCD/TV) and 301BDH (LCD) can only be slave in 8bpp modes */ 14268c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType <= ModeVGA) { 14278c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || 14288c2ecf20Sopenharmony_ci ((SiS_Pr->SiS_VBType & VB_NoLCD) && (tempbx & SetCRT2ToLCD)) ) { 14298c2ecf20Sopenharmony_ci modeflag &= (~CRT2Mode); 14308c2ecf20Sopenharmony_ci } 14318c2ecf20Sopenharmony_ci } 14328c2ecf20Sopenharmony_ci 14338c2ecf20Sopenharmony_ci if(!(tempbx & SetSimuScanMode)) { 14348c2ecf20Sopenharmony_ci if(tempbx & SwitchCRT2) { 14358c2ecf20Sopenharmony_ci if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { 14368c2ecf20Sopenharmony_ci if(resinfo != SIS_RI_1600x1200) { 14378c2ecf20Sopenharmony_ci tempbx |= SetSimuScanMode; 14388c2ecf20Sopenharmony_ci } 14398c2ecf20Sopenharmony_ci } 14408c2ecf20Sopenharmony_ci } else { 14418c2ecf20Sopenharmony_ci if(SiS_BridgeIsEnabled(SiS_Pr)) { 14428c2ecf20Sopenharmony_ci if(!(tempbx & DriverMode)) { 14438c2ecf20Sopenharmony_ci if(SiS_BridgeInSlavemode(SiS_Pr)) { 14448c2ecf20Sopenharmony_ci tempbx |= SetSimuScanMode; 14458c2ecf20Sopenharmony_ci } 14468c2ecf20Sopenharmony_ci } 14478c2ecf20Sopenharmony_ci } 14488c2ecf20Sopenharmony_ci } 14498c2ecf20Sopenharmony_ci } 14508c2ecf20Sopenharmony_ci 14518c2ecf20Sopenharmony_ci if(!(tempbx & DisableCRT2Display)) { 14528c2ecf20Sopenharmony_ci if(tempbx & DriverMode) { 14538c2ecf20Sopenharmony_ci if(tempbx & SetSimuScanMode) { 14548c2ecf20Sopenharmony_ci if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { 14558c2ecf20Sopenharmony_ci if(resinfo != SIS_RI_1600x1200) { 14568c2ecf20Sopenharmony_ci tempbx |= SetInSlaveMode; 14578c2ecf20Sopenharmony_ci } 14588c2ecf20Sopenharmony_ci } 14598c2ecf20Sopenharmony_ci } 14608c2ecf20Sopenharmony_ci } else { 14618c2ecf20Sopenharmony_ci tempbx |= SetInSlaveMode; 14628c2ecf20Sopenharmony_ci } 14638c2ecf20Sopenharmony_ci } 14648c2ecf20Sopenharmony_ci 14658c2ecf20Sopenharmony_ci } 14668c2ecf20Sopenharmony_ci 14678c2ecf20Sopenharmony_ci SiS_Pr->SiS_VBInfo = tempbx; 14688c2ecf20Sopenharmony_ci 14698c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 14708c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_630) { 14718c2ecf20Sopenharmony_ci SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo); 14728c2ecf20Sopenharmony_ci } 14738c2ecf20Sopenharmony_ci#endif 14748c2ecf20Sopenharmony_ci 14758c2ecf20Sopenharmony_ci#if 0 14768c2ecf20Sopenharmony_ci printk(KERN_DEBUG "sisfb: (init301: VBInfo= 0x%04x, SetFlag=0x%04x)\n", 14778c2ecf20Sopenharmony_ci SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag); 14788c2ecf20Sopenharmony_ci#endif 14798c2ecf20Sopenharmony_ci} 14808c2ecf20Sopenharmony_ci 14818c2ecf20Sopenharmony_ci/*********************************************/ 14828c2ecf20Sopenharmony_ci/* DETERMINE YPbPr MODE */ 14838c2ecf20Sopenharmony_ci/*********************************************/ 14848c2ecf20Sopenharmony_ci 14858c2ecf20Sopenharmony_civoid 14868c2ecf20Sopenharmony_ciSiS_SetYPbPr(struct SiS_Private *SiS_Pr) 14878c2ecf20Sopenharmony_ci{ 14888c2ecf20Sopenharmony_ci 14898c2ecf20Sopenharmony_ci unsigned char temp; 14908c2ecf20Sopenharmony_ci 14918c2ecf20Sopenharmony_ci /* Note: This variable is only used on 30xLV systems. 14928c2ecf20Sopenharmony_ci * CR38 has a different meaning on LVDS/CH7019 systems. 14938c2ecf20Sopenharmony_ci * On 661 and later, these bits moved to CR35. 14948c2ecf20Sopenharmony_ci * 14958c2ecf20Sopenharmony_ci * On 301, 301B, only HiVision 1080i is supported. 14968c2ecf20Sopenharmony_ci * On 30xLV, 301C, only YPbPr 1080i is supported. 14978c2ecf20Sopenharmony_ci */ 14988c2ecf20Sopenharmony_ci 14998c2ecf20Sopenharmony_ci SiS_Pr->SiS_YPbPr = 0; 15008c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_661) return; 15018c2ecf20Sopenharmony_ci 15028c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType) { 15038c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 15048c2ecf20Sopenharmony_ci SiS_Pr->SiS_YPbPr = YPbPrHiVision; 15058c2ecf20Sopenharmony_ci } 15068c2ecf20Sopenharmony_ci } 15078c2ecf20Sopenharmony_ci 15088c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 15098c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISYPBPR) { 15108c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 15118c2ecf20Sopenharmony_ci if(temp & 0x08) { 15128c2ecf20Sopenharmony_ci switch((temp >> 4)) { 15138c2ecf20Sopenharmony_ci case 0x00: SiS_Pr->SiS_YPbPr = YPbPr525i; break; 15148c2ecf20Sopenharmony_ci case 0x01: SiS_Pr->SiS_YPbPr = YPbPr525p; break; 15158c2ecf20Sopenharmony_ci case 0x02: SiS_Pr->SiS_YPbPr = YPbPr750p; break; 15168c2ecf20Sopenharmony_ci case 0x03: SiS_Pr->SiS_YPbPr = YPbPrHiVision; break; 15178c2ecf20Sopenharmony_ci } 15188c2ecf20Sopenharmony_ci } 15198c2ecf20Sopenharmony_ci } 15208c2ecf20Sopenharmony_ci } 15218c2ecf20Sopenharmony_ci 15228c2ecf20Sopenharmony_ci} 15238c2ecf20Sopenharmony_ci 15248c2ecf20Sopenharmony_ci/*********************************************/ 15258c2ecf20Sopenharmony_ci/* DETERMINE TVMode flag */ 15268c2ecf20Sopenharmony_ci/*********************************************/ 15278c2ecf20Sopenharmony_ci 15288c2ecf20Sopenharmony_civoid 15298c2ecf20Sopenharmony_ciSiS_SetTVMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 15308c2ecf20Sopenharmony_ci{ 15318c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 15328c2ecf20Sopenharmony_ci unsigned short temp, temp1, resinfo = 0, romindex = 0; 15338c2ecf20Sopenharmony_ci unsigned char OutputSelect = *SiS_Pr->pSiS_OutputSelect; 15348c2ecf20Sopenharmony_ci 15358c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode = 0; 15368c2ecf20Sopenharmony_ci 15378c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; 15388c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) return; 15398c2ecf20Sopenharmony_ci 15408c2ecf20Sopenharmony_ci if(ModeNo > 0x13) { 15418c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 15428c2ecf20Sopenharmony_ci } 15438c2ecf20Sopenharmony_ci 15448c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_661) { 15458c2ecf20Sopenharmony_ci 15468c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetPALTV) SiS_Pr->SiS_TVMode |= TVSetPAL; 15478c2ecf20Sopenharmony_ci 15488c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 15498c2ecf20Sopenharmony_ci temp = 0; 15508c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType == SIS_630) || 15518c2ecf20Sopenharmony_ci (SiS_Pr->ChipType == SIS_730)) { 15528c2ecf20Sopenharmony_ci temp = 0x35; 15538c2ecf20Sopenharmony_ci romindex = 0xfe; 15548c2ecf20Sopenharmony_ci } else if(SiS_Pr->ChipType >= SIS_315H) { 15558c2ecf20Sopenharmony_ci temp = 0x38; 15568c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < XGI_20) { 15578c2ecf20Sopenharmony_ci romindex = 0xf3; 15588c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_330) romindex = 0x11b; 15598c2ecf20Sopenharmony_ci } 15608c2ecf20Sopenharmony_ci } 15618c2ecf20Sopenharmony_ci if(temp) { 15628c2ecf20Sopenharmony_ci if(romindex && SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { 15638c2ecf20Sopenharmony_ci OutputSelect = ROMAddr[romindex]; 15648c2ecf20Sopenharmony_ci if(!(OutputSelect & EnablePALMN)) { 15658c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3d4,temp,0x3F); 15668c2ecf20Sopenharmony_ci } 15678c2ecf20Sopenharmony_ci } 15688c2ecf20Sopenharmony_ci temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,temp); 15698c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) { 15708c2ecf20Sopenharmony_ci if(temp1 & EnablePALM) { /* 0x40 */ 15718c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetPALM; 15728c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode &= ~TVSetPAL; 15738c2ecf20Sopenharmony_ci } else if(temp1 & EnablePALN) { /* 0x80 */ 15748c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetPALN; 15758c2ecf20Sopenharmony_ci } 15768c2ecf20Sopenharmony_ci } else { 15778c2ecf20Sopenharmony_ci if(temp1 & EnableNTSCJ) { /* 0x40 */ 15788c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetNTSCJ; 15798c2ecf20Sopenharmony_ci } 15808c2ecf20Sopenharmony_ci } 15818c2ecf20Sopenharmony_ci } 15828c2ecf20Sopenharmony_ci /* Translate HiVision/YPbPr to our new flags */ 15838c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 15848c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_YPbPr == YPbPr750p) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; 15858c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_YPbPr == YPbPr525p) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; 15868c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_YPbPr == YPbPrHiVision) SiS_Pr->SiS_TVMode |= TVSetHiVision; 15878c2ecf20Sopenharmony_ci else SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; 15888c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p | TVSetYPbPr525i)) { 15898c2ecf20Sopenharmony_ci SiS_Pr->SiS_VBInfo &= ~SetCRT2ToHiVision; 15908c2ecf20Sopenharmony_ci SiS_Pr->SiS_VBInfo |= SetCRT2ToYPbPr525750; 15918c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_TVMode & TVSetHiVision) { 15928c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetPAL; 15938c2ecf20Sopenharmony_ci } 15948c2ecf20Sopenharmony_ci } 15958c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 15968c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CHOverScan) { 15978c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { 15988c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); 15998c2ecf20Sopenharmony_ci if((temp & TVOverScan) || (SiS_Pr->SiS_CHOverScan == 1)) { 16008c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetCHOverScan; 16018c2ecf20Sopenharmony_ci } 16028c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 16038c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x79); 16048c2ecf20Sopenharmony_ci if((temp & 0x80) || (SiS_Pr->SiS_CHOverScan == 1)) { 16058c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetCHOverScan; 16068c2ecf20Sopenharmony_ci } 16078c2ecf20Sopenharmony_ci } 16088c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CHSOverScan) { 16098c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetCHOverScan; 16108c2ecf20Sopenharmony_ci } 16118c2ecf20Sopenharmony_ci } 16128c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 16138c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 16148c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) { 16158c2ecf20Sopenharmony_ci if(temp & EnablePALM) SiS_Pr->SiS_TVMode |= TVSetPALM; 16168c2ecf20Sopenharmony_ci else if(temp & EnablePALN) SiS_Pr->SiS_TVMode |= TVSetPALN; 16178c2ecf20Sopenharmony_ci } else { 16188c2ecf20Sopenharmony_ci if(temp & EnableNTSCJ) { 16198c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetNTSCJ; 16208c2ecf20Sopenharmony_ci } 16218c2ecf20Sopenharmony_ci } 16228c2ecf20Sopenharmony_ci } 16238c2ecf20Sopenharmony_ci } 16248c2ecf20Sopenharmony_ci 16258c2ecf20Sopenharmony_ci } else { /* 661 and later */ 16268c2ecf20Sopenharmony_ci 16278c2ecf20Sopenharmony_ci temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); 16288c2ecf20Sopenharmony_ci if(temp1 & 0x01) { 16298c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetPAL; 16308c2ecf20Sopenharmony_ci if(temp1 & 0x08) { 16318c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetPALN; 16328c2ecf20Sopenharmony_ci } else if(temp1 & 0x04) { 16338c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 16348c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode &= ~TVSetPAL; 16358c2ecf20Sopenharmony_ci } 16368c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetPALM; 16378c2ecf20Sopenharmony_ci } 16388c2ecf20Sopenharmony_ci } else { 16398c2ecf20Sopenharmony_ci if(temp1 & 0x02) { 16408c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetNTSCJ; 16418c2ecf20Sopenharmony_ci } 16428c2ecf20Sopenharmony_ci } 16438c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 16448c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CHOverScan) { 16458c2ecf20Sopenharmony_ci if((temp1 & 0x10) || (SiS_Pr->SiS_CHOverScan == 1)) { 16468c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetCHOverScan; 16478c2ecf20Sopenharmony_ci } 16488c2ecf20Sopenharmony_ci } 16498c2ecf20Sopenharmony_ci } 16508c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 16518c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 16528c2ecf20Sopenharmony_ci temp1 &= 0xe0; 16538c2ecf20Sopenharmony_ci if(temp1 == 0x00) SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; 16548c2ecf20Sopenharmony_ci else if(temp1 == 0x20) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; 16558c2ecf20Sopenharmony_ci else if(temp1 == 0x40) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; 16568c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 16578c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= (TVSetHiVision | TVSetPAL); 16588c2ecf20Sopenharmony_ci } 16598c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750 | SetCRT2ToHiVision)) { 16608c2ecf20Sopenharmony_ci if(resinfo == SIS_RI_800x480 || resinfo == SIS_RI_1024x576 || resinfo == SIS_RI_1280x720) { 16618c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVAspect169; 16628c2ecf20Sopenharmony_ci } else { 16638c2ecf20Sopenharmony_ci temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x39); 16648c2ecf20Sopenharmony_ci if(temp1 & 0x02) { 16658c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetHiVision)) { 16668c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVAspect169; 16678c2ecf20Sopenharmony_ci } else { 16688c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVAspect43LB; 16698c2ecf20Sopenharmony_ci } 16708c2ecf20Sopenharmony_ci } else { 16718c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVAspect43; 16728c2ecf20Sopenharmony_ci } 16738c2ecf20Sopenharmony_ci } 16748c2ecf20Sopenharmony_ci } 16758c2ecf20Sopenharmony_ci } 16768c2ecf20Sopenharmony_ci } 16778c2ecf20Sopenharmony_ci 16788c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) SiS_Pr->SiS_TVMode |= TVSetPAL; 16798c2ecf20Sopenharmony_ci 16808c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 16818c2ecf20Sopenharmony_ci 16828c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 16838c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetPAL; 16848c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode &= ~(TVSetPALM | TVSetPALN | TVSetNTSCJ); 16858c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 16868c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525i | TVSetYPbPr525p | TVSetYPbPr750p)) { 16878c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode &= ~(TVSetPAL | TVSetNTSCJ | TVSetPALM | TVSetPALN); 16888c2ecf20Sopenharmony_ci } 16898c2ecf20Sopenharmony_ci } 16908c2ecf20Sopenharmony_ci 16918c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 16928c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { 16938c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; 16948c2ecf20Sopenharmony_ci } 16958c2ecf20Sopenharmony_ci } 16968c2ecf20Sopenharmony_ci 16978c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { 16988c2ecf20Sopenharmony_ci if(resinfo == SIS_RI_1024x768) { 16998c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { 17008c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSet525p1024; 17018c2ecf20Sopenharmony_ci } else if(!(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr750p))) { 17028c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVSetNTSC1024; 17038c2ecf20Sopenharmony_ci } 17048c2ecf20Sopenharmony_ci } 17058c2ecf20Sopenharmony_ci } 17068c2ecf20Sopenharmony_ci 17078c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode |= TVRPLLDIV2XO; 17088c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) && 17098c2ecf20Sopenharmony_ci (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 17108c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; 17118c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { 17128c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; 17138c2ecf20Sopenharmony_ci } else if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) { 17148c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { 17158c2ecf20Sopenharmony_ci SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; 17168c2ecf20Sopenharmony_ci } 17178c2ecf20Sopenharmony_ci } 17188c2ecf20Sopenharmony_ci 17198c2ecf20Sopenharmony_ci } 17208c2ecf20Sopenharmony_ci 17218c2ecf20Sopenharmony_ci SiS_Pr->SiS_VBInfo &= ~SetPALTV; 17228c2ecf20Sopenharmony_ci} 17238c2ecf20Sopenharmony_ci 17248c2ecf20Sopenharmony_ci/*********************************************/ 17258c2ecf20Sopenharmony_ci/* GET LCD INFO */ 17268c2ecf20Sopenharmony_ci/*********************************************/ 17278c2ecf20Sopenharmony_ci 17288c2ecf20Sopenharmony_cistatic unsigned short 17298c2ecf20Sopenharmony_ciSiS_GetBIOSLCDResInfo(struct SiS_Private *SiS_Pr) 17308c2ecf20Sopenharmony_ci{ 17318c2ecf20Sopenharmony_ci unsigned short temp = SiS_Pr->SiS_LCDResInfo; 17328c2ecf20Sopenharmony_ci /* Translate my LCDResInfo to BIOS value */ 17338c2ecf20Sopenharmony_ci switch(temp) { 17348c2ecf20Sopenharmony_ci case Panel_1280x768_2: temp = Panel_1280x768; break; 17358c2ecf20Sopenharmony_ci case Panel_1280x800_2: temp = Panel_1280x800; break; 17368c2ecf20Sopenharmony_ci case Panel_1280x854: temp = Panel661_1280x854; break; 17378c2ecf20Sopenharmony_ci } 17388c2ecf20Sopenharmony_ci return temp; 17398c2ecf20Sopenharmony_ci} 17408c2ecf20Sopenharmony_ci 17418c2ecf20Sopenharmony_cistatic void 17428c2ecf20Sopenharmony_ciSiS_GetLCDInfoBIOS(struct SiS_Private *SiS_Pr) 17438c2ecf20Sopenharmony_ci{ 17448c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 17458c2ecf20Sopenharmony_ci unsigned char *ROMAddr; 17468c2ecf20Sopenharmony_ci unsigned short temp; 17478c2ecf20Sopenharmony_ci 17488c2ecf20Sopenharmony_ci if((ROMAddr = GetLCDStructPtr661(SiS_Pr))) { 17498c2ecf20Sopenharmony_ci if((temp = SISGETROMW(6)) != SiS_Pr->PanelHT) { 17508c2ecf20Sopenharmony_ci SiS_Pr->SiS_NeedRomModeData = true; 17518c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = temp; 17528c2ecf20Sopenharmony_ci } 17538c2ecf20Sopenharmony_ci if((temp = SISGETROMW(8)) != SiS_Pr->PanelVT) { 17548c2ecf20Sopenharmony_ci SiS_Pr->SiS_NeedRomModeData = true; 17558c2ecf20Sopenharmony_ci SiS_Pr->PanelVT = temp; 17568c2ecf20Sopenharmony_ci } 17578c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = SISGETROMW(10); 17588c2ecf20Sopenharmony_ci SiS_Pr->PanelHRE = SISGETROMW(12); 17598c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = SISGETROMW(14); 17608c2ecf20Sopenharmony_ci SiS_Pr->PanelVRE = SISGETROMW(16); 17618c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315; 17628c2ecf20Sopenharmony_ci SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].CLOCK = 17638c2ecf20Sopenharmony_ci SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].CLOCK = (unsigned short)((unsigned char)ROMAddr[18]); 17648c2ecf20Sopenharmony_ci SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2B = 17658c2ecf20Sopenharmony_ci SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_A = ROMAddr[19]; 17668c2ecf20Sopenharmony_ci SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2C = 17678c2ecf20Sopenharmony_ci SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_B = ROMAddr[20]; 17688c2ecf20Sopenharmony_ci 17698c2ecf20Sopenharmony_ci } 17708c2ecf20Sopenharmony_ci#endif 17718c2ecf20Sopenharmony_ci} 17728c2ecf20Sopenharmony_ci 17738c2ecf20Sopenharmony_cistatic void 17748c2ecf20Sopenharmony_ciSiS_CheckScaling(struct SiS_Private *SiS_Pr, unsigned short resinfo, 17758c2ecf20Sopenharmony_ci const unsigned char *nonscalingmodes) 17768c2ecf20Sopenharmony_ci{ 17778c2ecf20Sopenharmony_ci int i = 0; 17788c2ecf20Sopenharmony_ci while(nonscalingmodes[i] != 0xff) { 17798c2ecf20Sopenharmony_ci if(nonscalingmodes[i++] == resinfo) { 17808c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) || 17818c2ecf20Sopenharmony_ci (SiS_Pr->UsePanelScaler == -1)) { 17828c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 17838c2ecf20Sopenharmony_ci } 17848c2ecf20Sopenharmony_ci break; 17858c2ecf20Sopenharmony_ci } 17868c2ecf20Sopenharmony_ci } 17878c2ecf20Sopenharmony_ci} 17888c2ecf20Sopenharmony_ci 17898c2ecf20Sopenharmony_civoid 17908c2ecf20Sopenharmony_ciSiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 17918c2ecf20Sopenharmony_ci{ 17928c2ecf20Sopenharmony_ci unsigned short temp,modeflag,resinfo=0,modexres=0,modeyres=0; 17938c2ecf20Sopenharmony_ci bool panelcanscale = false; 17948c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 17958c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 17968c2ecf20Sopenharmony_ci static const unsigned char SiS300SeriesLCDRes[] = 17978c2ecf20Sopenharmony_ci { 0, 1, 2, 3, 7, 4, 5, 8, 17988c2ecf20Sopenharmony_ci 0, 0, 10, 0, 0, 0, 0, 15 }; 17998c2ecf20Sopenharmony_ci#endif 18008c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 18018c2ecf20Sopenharmony_ci unsigned char *myptr = NULL; 18028c2ecf20Sopenharmony_ci#endif 18038c2ecf20Sopenharmony_ci 18048c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo = 0; 18058c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDTypeInfo = 0; 18068c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo = 0; 18078c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 999; /* HSync start */ 18088c2ecf20Sopenharmony_ci SiS_Pr->PanelHRE = 999; /* HSync end */ 18098c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 999; /* VSync start */ 18108c2ecf20Sopenharmony_ci SiS_Pr->PanelVRE = 999; /* VSync end */ 18118c2ecf20Sopenharmony_ci SiS_Pr->SiS_NeedRomModeData = false; 18128c2ecf20Sopenharmony_ci 18138c2ecf20Sopenharmony_ci /* Alternative 1600x1200@60 timing for 1600x1200 LCDA */ 18148c2ecf20Sopenharmony_ci SiS_Pr->Alternate1600x1200 = false; 18158c2ecf20Sopenharmony_ci 18168c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return; 18178c2ecf20Sopenharmony_ci 18188c2ecf20Sopenharmony_ci modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); 18198c2ecf20Sopenharmony_ci 18208c2ecf20Sopenharmony_ci if((ModeNo > 0x13) && (!SiS_Pr->UseCustomMode)) { 18218c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 18228c2ecf20Sopenharmony_ci modexres = SiS_Pr->SiS_ModeResInfo[resinfo].HTotal; 18238c2ecf20Sopenharmony_ci modeyres = SiS_Pr->SiS_ModeResInfo[resinfo].VTotal; 18248c2ecf20Sopenharmony_ci } 18258c2ecf20Sopenharmony_ci 18268c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); 18278c2ecf20Sopenharmony_ci 18288c2ecf20Sopenharmony_ci /* For broken BIOSes: Assume 1024x768 */ 18298c2ecf20Sopenharmony_ci if(temp == 0) temp = 0x02; 18308c2ecf20Sopenharmony_ci 18318c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { 18328c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDTypeInfo = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x7c) >> 2; 18338c2ecf20Sopenharmony_ci } else if((SiS_Pr->ChipType < SIS_315H) || (SiS_Pr->ChipType >= SIS_661)) { 18348c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDTypeInfo = temp >> 4; 18358c2ecf20Sopenharmony_ci } else { 18368c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1; 18378c2ecf20Sopenharmony_ci } 18388c2ecf20Sopenharmony_ci temp &= 0x0f; 18398c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 18408c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 18418c2ecf20Sopenharmony_ci /* Very old BIOSes only know 7 sizes (NetVista 2179, 1.01g) */ 18428c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS301) { 18438c2ecf20Sopenharmony_ci if(temp < 0x0f) temp &= 0x07; 18448c2ecf20Sopenharmony_ci } 18458c2ecf20Sopenharmony_ci /* Translate 300 series LCDRes to 315 series for unified usage */ 18468c2ecf20Sopenharmony_ci temp = SiS300SeriesLCDRes[temp]; 18478c2ecf20Sopenharmony_ci } 18488c2ecf20Sopenharmony_ci#endif 18498c2ecf20Sopenharmony_ci 18508c2ecf20Sopenharmony_ci /* Translate to our internal types */ 18518c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 18528c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_550) { 18538c2ecf20Sopenharmony_ci if (temp == Panel310_1152x768) temp = Panel_320x240_2; /* Verified working */ 18548c2ecf20Sopenharmony_ci else if(temp == Panel310_320x240_2) temp = Panel_320x240_2; 18558c2ecf20Sopenharmony_ci else if(temp == Panel310_320x240_3) temp = Panel_320x240_3; 18568c2ecf20Sopenharmony_ci } else if(SiS_Pr->ChipType >= SIS_661) { 18578c2ecf20Sopenharmony_ci if(temp == Panel661_1280x854) temp = Panel_1280x854; 18588c2ecf20Sopenharmony_ci } 18598c2ecf20Sopenharmony_ci#endif 18608c2ecf20Sopenharmony_ci 18618c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* SiS LVDS */ 18628c2ecf20Sopenharmony_ci if(temp == Panel310_1280x768) { 18638c2ecf20Sopenharmony_ci temp = Panel_1280x768_2; 18648c2ecf20Sopenharmony_ci } 18658c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ROMNew) { 18668c2ecf20Sopenharmony_ci if(temp == Panel661_1280x800) { 18678c2ecf20Sopenharmony_ci temp = Panel_1280x800_2; 18688c2ecf20Sopenharmony_ci } 18698c2ecf20Sopenharmony_ci } 18708c2ecf20Sopenharmony_ci } 18718c2ecf20Sopenharmony_ci 18728c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo = temp; 18738c2ecf20Sopenharmony_ci 18748c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 18758c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 18768c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { 18778c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo = Panel_Barco1366; 18788c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { 18798c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo = Panel_848x480; 18808c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_CustomT == CUT_PANEL856) { 18818c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo = Panel_856x480; 18828c2ecf20Sopenharmony_ci } 18838c2ecf20Sopenharmony_ci } 18848c2ecf20Sopenharmony_ci#endif 18858c2ecf20Sopenharmony_ci 18868c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 18878c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMin301) 18888c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMin301; 18898c2ecf20Sopenharmony_ci } else { 18908c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMinLVDS) 18918c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMinLVDS; 18928c2ecf20Sopenharmony_ci } 18938c2ecf20Sopenharmony_ci 18948c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); 18958c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo = temp & ~0x000e; 18968c2ecf20Sopenharmony_ci /* Need temp below! */ 18978c2ecf20Sopenharmony_ci 18988c2ecf20Sopenharmony_ci /* These must/can't scale no matter what */ 18998c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 19008c2ecf20Sopenharmony_ci case Panel_320x240_1: 19018c2ecf20Sopenharmony_ci case Panel_320x240_2: 19028c2ecf20Sopenharmony_ci case Panel_320x240_3: 19038c2ecf20Sopenharmony_ci case Panel_1280x960: 19048c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; 19058c2ecf20Sopenharmony_ci break; 19068c2ecf20Sopenharmony_ci case Panel_640x480: 19078c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 19088c2ecf20Sopenharmony_ci } 19098c2ecf20Sopenharmony_ci 19108c2ecf20Sopenharmony_ci panelcanscale = (bool)(SiS_Pr->SiS_LCDInfo & DontExpandLCD); 19118c2ecf20Sopenharmony_ci 19128c2ecf20Sopenharmony_ci if(!SiS_Pr->UsePanelScaler) SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; 19138c2ecf20Sopenharmony_ci else if(SiS_Pr->UsePanelScaler == 1) SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 19148c2ecf20Sopenharmony_ci 19158c2ecf20Sopenharmony_ci /* Dual link, Pass 1:1 BIOS default, etc. */ 19168c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 19178c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_661) { 19188c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 19198c2ecf20Sopenharmony_ci if(temp & 0x08) SiS_Pr->SiS_LCDInfo |= LCDPass11; 19208c2ecf20Sopenharmony_ci } 19218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) { 19228c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ROMNew) { 19238c2ecf20Sopenharmony_ci if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink; 19248c2ecf20Sopenharmony_ci } else if((myptr = GetLCDStructPtr661(SiS_Pr))) { 19258c2ecf20Sopenharmony_ci if(myptr[2] & 0x01) SiS_Pr->SiS_LCDInfo |= LCDDualLink; 19268c2ecf20Sopenharmony_ci } 19278c2ecf20Sopenharmony_ci } 19288c2ecf20Sopenharmony_ci } else if(SiS_Pr->ChipType >= SIS_315H) { 19298c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 19308c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x01) SiS_Pr->SiS_LCDInfo |= LCDPass11; 19318c2ecf20Sopenharmony_ci } 19328c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_ROMNew) && (!(SiS_Pr->PanelSelfDetected))) { 19338c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo &= ~(LCDRGB18Bit); 19348c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); 19358c2ecf20Sopenharmony_ci if(temp & 0x01) SiS_Pr->SiS_LCDInfo |= LCDRGB18Bit; 19368c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) { 19378c2ecf20Sopenharmony_ci if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink; 19388c2ecf20Sopenharmony_ci } 19398c2ecf20Sopenharmony_ci } else if(!(SiS_Pr->SiS_ROMNew)) { 19408c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) { 19418c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_CustomT == CUT_CLEVO1024) && 19428c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1024x768)) { 19438c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= LCDDualLink; 19448c2ecf20Sopenharmony_ci } 19458c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || 19468c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || 19478c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) || 19488c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1680x1050)) { 19498c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= LCDDualLink; 19508c2ecf20Sopenharmony_ci } 19518c2ecf20Sopenharmony_ci } 19528c2ecf20Sopenharmony_ci } 19538c2ecf20Sopenharmony_ci } 19548c2ecf20Sopenharmony_ci#endif 19558c2ecf20Sopenharmony_ci 19568c2ecf20Sopenharmony_ci /* Pass 1:1 */ 19578c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBType & VB_NoLCD)) { 19588c2ecf20Sopenharmony_ci /* Always center screen on LVDS (if scaling is disabled) */ 19598c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo &= ~LCDPass11; 19608c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 19618c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 19628c2ecf20Sopenharmony_ci /* Always center screen on SiS LVDS (if scaling is disabled) */ 19638c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo &= ~LCDPass11; 19648c2ecf20Sopenharmony_ci } else { 19658c2ecf20Sopenharmony_ci /* By default, pass 1:1 on SiS TMDS (if scaling is supported) */ 19668c2ecf20Sopenharmony_ci if(panelcanscale) SiS_Pr->SiS_LCDInfo |= LCDPass11; 19678c2ecf20Sopenharmony_ci if(SiS_Pr->CenterScreen == 1) SiS_Pr->SiS_LCDInfo &= ~LCDPass11; 19688c2ecf20Sopenharmony_ci } 19698c2ecf20Sopenharmony_ci } 19708c2ecf20Sopenharmony_ci 19718c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK65_300; 19728c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; 19738c2ecf20Sopenharmony_ci 19748c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 19758c2ecf20Sopenharmony_ci case Panel_320x240_1: 19768c2ecf20Sopenharmony_ci case Panel_320x240_2: 19778c2ecf20Sopenharmony_ci case Panel_320x240_3: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; 19788c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 24; SiS_Pr->PanelVRE = 3; 19798c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK28; 19808c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK28; 19818c2ecf20Sopenharmony_ci break; 19828c2ecf20Sopenharmony_ci case Panel_640x480: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; 19838c2ecf20Sopenharmony_ci SiS_Pr->PanelVRE = 3; 19848c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK28; 19858c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK28; 19868c2ecf20Sopenharmony_ci break; 19878c2ecf20Sopenharmony_ci case Panel_800x600: SiS_Pr->PanelXRes = 800; SiS_Pr->PanelYRes = 600; 19888c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1056; SiS_Pr->PanelVT = 628; 19898c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 40; SiS_Pr->PanelHRE = 128; 19908c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 4; 19918c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK40; 19928c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK40; 19938c2ecf20Sopenharmony_ci break; 19948c2ecf20Sopenharmony_ci case Panel_1024x600: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 600; 19958c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 800; 19968c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; 19978c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 2 /* 88 */ ; SiS_Pr->PanelVRE = 6; 19988c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK65_300; 19998c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK65_315; 20008c2ecf20Sopenharmony_ci break; 20018c2ecf20Sopenharmony_ci case Panel_1024x768: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; 20028c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; 20038c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; 20048c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; 20058c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 20068c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 23; 20078c2ecf20Sopenharmony_ci SiS_Pr->PanelVRE = 5; 20088c2ecf20Sopenharmony_ci } 20098c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK65_300; 20108c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK65_315; 20118c2ecf20Sopenharmony_ci SiS_GetLCDInfoBIOS(SiS_Pr); 20128c2ecf20Sopenharmony_ci break; 20138c2ecf20Sopenharmony_ci case Panel_1152x768: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 768; 20148c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; 20158c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; 20168c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; 20178c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 20188c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 23; 20198c2ecf20Sopenharmony_ci SiS_Pr->PanelVRE = 5; 20208c2ecf20Sopenharmony_ci } 20218c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK65_300; 20228c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK65_315; 20238c2ecf20Sopenharmony_ci break; 20248c2ecf20Sopenharmony_ci case Panel_1152x864: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 864; 20258c2ecf20Sopenharmony_ci break; 20268c2ecf20Sopenharmony_ci case Panel_1280x720: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 720; 20278c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1650; SiS_Pr->PanelVT = 750; 20288c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 110; SiS_Pr->PanelHRE = 40; 20298c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 5; SiS_Pr->PanelVRE = 5; 20308c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK_1280x720; 20318c2ecf20Sopenharmony_ci /* Data above for TMDS (projector); get from BIOS for LVDS */ 20328c2ecf20Sopenharmony_ci SiS_GetLCDInfoBIOS(SiS_Pr); 20338c2ecf20Sopenharmony_ci break; 20348c2ecf20Sopenharmony_ci case Panel_1280x768: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; 20358c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 20368c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 806; 20378c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK81_300; /* ? */ 20388c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK81_315; /* ? */ 20398c2ecf20Sopenharmony_ci } else { 20408c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 802; 20418c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; 20428c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; 20438c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK81_300; 20448c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK81_315; 20458c2ecf20Sopenharmony_ci } 20468c2ecf20Sopenharmony_ci break; 20478c2ecf20Sopenharmony_ci case Panel_1280x768_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; 20488c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1660; SiS_Pr->PanelVT = 806; 20498c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; 20508c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; 20518c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK_1280x768_2; 20528c2ecf20Sopenharmony_ci SiS_GetLCDInfoBIOS(SiS_Pr); 20538c2ecf20Sopenharmony_ci break; 20548c2ecf20Sopenharmony_ci case Panel_1280x800: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800; 20558c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 816; 20568c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 21; SiS_Pr->PanelHRE = 24; 20578c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 4; SiS_Pr->PanelVRE = 3; 20588c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK_1280x800_315; 20598c2ecf20Sopenharmony_ci SiS_GetLCDInfoBIOS(SiS_Pr); 20608c2ecf20Sopenharmony_ci break; 20618c2ecf20Sopenharmony_ci case Panel_1280x800_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800; 20628c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1552; SiS_Pr->PanelVT = 812; 20638c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; 20648c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 4; SiS_Pr->PanelVRE = 3; 20658c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK_1280x800_315_2; 20668c2ecf20Sopenharmony_ci SiS_GetLCDInfoBIOS(SiS_Pr); 20678c2ecf20Sopenharmony_ci break; 20688c2ecf20Sopenharmony_ci case Panel_1280x854: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 854; 20698c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1664; SiS_Pr->PanelVT = 861; 20708c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 16; SiS_Pr->PanelHRE = 112; 20718c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; 20728c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK_1280x854; 20738c2ecf20Sopenharmony_ci SiS_GetLCDInfoBIOS(SiS_Pr); 20748c2ecf20Sopenharmony_ci break; 20758c2ecf20Sopenharmony_ci case Panel_1280x960: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 960; 20768c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1800; SiS_Pr->PanelVT = 1000; 20778c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300; 20788c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK108_3_315; 20798c2ecf20Sopenharmony_ci if(resinfo == SIS_RI_1280x1024) { 20808c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK100_300; 20818c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK100_315; 20828c2ecf20Sopenharmony_ci } 20838c2ecf20Sopenharmony_ci break; 20848c2ecf20Sopenharmony_ci case Panel_1280x1024: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 1024; 20858c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; 20868c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; 20878c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; 20888c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300; 20898c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; 20908c2ecf20Sopenharmony_ci SiS_GetLCDInfoBIOS(SiS_Pr); 20918c2ecf20Sopenharmony_ci break; 20928c2ecf20Sopenharmony_ci case Panel_1400x1050: SiS_Pr->PanelXRes = 1400; SiS_Pr->PanelYRes = 1050; 20938c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; 20948c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; 20958c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; 20968c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; 20978c2ecf20Sopenharmony_ci SiS_GetLCDInfoBIOS(SiS_Pr); 20988c2ecf20Sopenharmony_ci break; 20998c2ecf20Sopenharmony_ci case Panel_1600x1200: SiS_Pr->PanelXRes = 1600; SiS_Pr->PanelYRes = 1200; 21008c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 2160; SiS_Pr->PanelVT = 1250; 21018c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 64; SiS_Pr->PanelHRE = 192; 21028c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; 21038c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK162_315; 21048c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISTMDSLCDA) { 21058c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 21068c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1760; SiS_Pr->PanelVT = 1235; 21078c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 32; 21088c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 2; SiS_Pr->PanelVRE = 4; 21098c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK130_315; 21108c2ecf20Sopenharmony_ci SiS_Pr->Alternate1600x1200 = true; 21118c2ecf20Sopenharmony_ci } 21128c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_IF_DEF_LVDS) { 21138c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 2048; SiS_Pr->PanelVT = 1320; 21148c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = SiS_Pr->PanelHRE = 999; 21158c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = SiS_Pr->PanelVRE = 999; 21168c2ecf20Sopenharmony_ci } 21178c2ecf20Sopenharmony_ci SiS_GetLCDInfoBIOS(SiS_Pr); 21188c2ecf20Sopenharmony_ci break; 21198c2ecf20Sopenharmony_ci case Panel_1680x1050: SiS_Pr->PanelXRes = 1680; SiS_Pr->PanelYRes = 1050; 21208c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1900; SiS_Pr->PanelVT = 1066; 21218c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 26; SiS_Pr->PanelHRE = 76; 21228c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; 21238c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK121_315; 21248c2ecf20Sopenharmony_ci SiS_GetLCDInfoBIOS(SiS_Pr); 21258c2ecf20Sopenharmony_ci break; 21268c2ecf20Sopenharmony_ci case Panel_Barco1366: SiS_Pr->PanelXRes = 1360; SiS_Pr->PanelYRes = 1024; 21278c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; 21288c2ecf20Sopenharmony_ci break; 21298c2ecf20Sopenharmony_ci case Panel_848x480: SiS_Pr->PanelXRes = 848; SiS_Pr->PanelYRes = 480; 21308c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525; 21318c2ecf20Sopenharmony_ci break; 21328c2ecf20Sopenharmony_ci case Panel_856x480: SiS_Pr->PanelXRes = 856; SiS_Pr->PanelYRes = 480; 21338c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525; 21348c2ecf20Sopenharmony_ci break; 21358c2ecf20Sopenharmony_ci case Panel_Custom: SiS_Pr->PanelXRes = SiS_Pr->CP_MaxX; 21368c2ecf20Sopenharmony_ci SiS_Pr->PanelYRes = SiS_Pr->CP_MaxY; 21378c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = SiS_Pr->CHTotal; 21388c2ecf20Sopenharmony_ci SiS_Pr->PanelVT = SiS_Pr->CVTotal; 21398c2ecf20Sopenharmony_ci if(SiS_Pr->CP_PreferredIndex != -1) { 21408c2ecf20Sopenharmony_ci SiS_Pr->PanelXRes = SiS_Pr->CP_HDisplay[SiS_Pr->CP_PreferredIndex]; 21418c2ecf20Sopenharmony_ci SiS_Pr->PanelYRes = SiS_Pr->CP_VDisplay[SiS_Pr->CP_PreferredIndex]; 21428c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = SiS_Pr->CP_HTotal[SiS_Pr->CP_PreferredIndex]; 21438c2ecf20Sopenharmony_ci SiS_Pr->PanelVT = SiS_Pr->CP_VTotal[SiS_Pr->CP_PreferredIndex]; 21448c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = SiS_Pr->CP_HSyncStart[SiS_Pr->CP_PreferredIndex]; 21458c2ecf20Sopenharmony_ci SiS_Pr->PanelHRE = SiS_Pr->CP_HSyncEnd[SiS_Pr->CP_PreferredIndex]; 21468c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = SiS_Pr->CP_VSyncStart[SiS_Pr->CP_PreferredIndex]; 21478c2ecf20Sopenharmony_ci SiS_Pr->PanelVRE = SiS_Pr->CP_VSyncEnd[SiS_Pr->CP_PreferredIndex]; 21488c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS -= SiS_Pr->PanelXRes; 21498c2ecf20Sopenharmony_ci SiS_Pr->PanelHRE -= SiS_Pr->PanelHRS; 21508c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS -= SiS_Pr->PanelYRes; 21518c2ecf20Sopenharmony_ci SiS_Pr->PanelVRE -= SiS_Pr->PanelVRS; 21528c2ecf20Sopenharmony_ci if(SiS_Pr->CP_PrefClock) { 21538c2ecf20Sopenharmony_ci int idx; 21548c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315; 21558c2ecf20Sopenharmony_ci SiS_Pr->PanelVCLKIdx300 = VCLK_CUSTOM_300; 21568c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) idx = VCLK_CUSTOM_300; 21578c2ecf20Sopenharmony_ci else idx = VCLK_CUSTOM_315; 21588c2ecf20Sopenharmony_ci SiS_Pr->SiS_VCLKData[idx].CLOCK = 21598c2ecf20Sopenharmony_ci SiS_Pr->SiS_VBVCLKData[idx].CLOCK = SiS_Pr->CP_PrefClock; 21608c2ecf20Sopenharmony_ci SiS_Pr->SiS_VCLKData[idx].SR2B = 21618c2ecf20Sopenharmony_ci SiS_Pr->SiS_VBVCLKData[idx].Part4_A = SiS_Pr->CP_PrefSR2B; 21628c2ecf20Sopenharmony_ci SiS_Pr->SiS_VCLKData[idx].SR2C = 21638c2ecf20Sopenharmony_ci SiS_Pr->SiS_VBVCLKData[idx].Part4_B = SiS_Pr->CP_PrefSR2C; 21648c2ecf20Sopenharmony_ci } 21658c2ecf20Sopenharmony_ci } 21668c2ecf20Sopenharmony_ci break; 21678c2ecf20Sopenharmony_ci default: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; 21688c2ecf20Sopenharmony_ci SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; 21698c2ecf20Sopenharmony_ci break; 21708c2ecf20Sopenharmony_ci } 21718c2ecf20Sopenharmony_ci 21728c2ecf20Sopenharmony_ci /* Special cases */ 21738c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_IF_DEF_FSTN) || 21748c2ecf20Sopenharmony_ci (SiS_Pr->SiS_IF_DEF_DSTN) || 21758c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_BARCO1366) || 21768c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || 21778c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_PANEL848) || 21788c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) { 21798c2ecf20Sopenharmony_ci SiS_Pr->PanelHRS = 999; 21808c2ecf20Sopenharmony_ci SiS_Pr->PanelHRE = 999; 21818c2ecf20Sopenharmony_ci } 21828c2ecf20Sopenharmony_ci 21838c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_CustomT == CUT_BARCO1366) || 21848c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || 21858c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_PANEL848) || 21868c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) { 21878c2ecf20Sopenharmony_ci SiS_Pr->PanelVRS = 999; 21888c2ecf20Sopenharmony_ci SiS_Pr->PanelVRE = 999; 21898c2ecf20Sopenharmony_ci } 21908c2ecf20Sopenharmony_ci 21918c2ecf20Sopenharmony_ci /* DontExpand overrule */ 21928c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { 21938c2ecf20Sopenharmony_ci 21948c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (modeflag & NoSupportLCDScale)) { 21958c2ecf20Sopenharmony_ci /* No scaling for this mode on any panel (LCD=CRT2)*/ 21968c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 21978c2ecf20Sopenharmony_ci } 21988c2ecf20Sopenharmony_ci 21998c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 22008c2ecf20Sopenharmony_ci 22018c2ecf20Sopenharmony_ci case Panel_Custom: 22028c2ecf20Sopenharmony_ci case Panel_1152x864: 22038c2ecf20Sopenharmony_ci case Panel_1280x768: /* TMDS only */ 22048c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 22058c2ecf20Sopenharmony_ci break; 22068c2ecf20Sopenharmony_ci 22078c2ecf20Sopenharmony_ci case Panel_800x600: { 22088c2ecf20Sopenharmony_ci static const unsigned char nonscalingmodes[] = { 22098c2ecf20Sopenharmony_ci SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, 0xff 22108c2ecf20Sopenharmony_ci }; 22118c2ecf20Sopenharmony_ci SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 22128c2ecf20Sopenharmony_ci break; 22138c2ecf20Sopenharmony_ci } 22148c2ecf20Sopenharmony_ci case Panel_1024x768: { 22158c2ecf20Sopenharmony_ci static const unsigned char nonscalingmodes[] = { 22168c2ecf20Sopenharmony_ci SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 22178c2ecf20Sopenharmony_ci SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 22188c2ecf20Sopenharmony_ci 0xff 22198c2ecf20Sopenharmony_ci }; 22208c2ecf20Sopenharmony_ci SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 22218c2ecf20Sopenharmony_ci break; 22228c2ecf20Sopenharmony_ci } 22238c2ecf20Sopenharmony_ci case Panel_1280x720: { 22248c2ecf20Sopenharmony_ci static const unsigned char nonscalingmodes[] = { 22258c2ecf20Sopenharmony_ci SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 22268c2ecf20Sopenharmony_ci SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 22278c2ecf20Sopenharmony_ci 0xff 22288c2ecf20Sopenharmony_ci }; 22298c2ecf20Sopenharmony_ci SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 22308c2ecf20Sopenharmony_ci if(SiS_Pr->PanelHT == 1650) { 22318c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 22328c2ecf20Sopenharmony_ci } 22338c2ecf20Sopenharmony_ci break; 22348c2ecf20Sopenharmony_ci } 22358c2ecf20Sopenharmony_ci case Panel_1280x768_2: { /* LVDS only */ 22368c2ecf20Sopenharmony_ci static const unsigned char nonscalingmodes[] = { 22378c2ecf20Sopenharmony_ci SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 22388c2ecf20Sopenharmony_ci SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 22398c2ecf20Sopenharmony_ci SIS_RI_1152x768,0xff 22408c2ecf20Sopenharmony_ci }; 22418c2ecf20Sopenharmony_ci SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 22428c2ecf20Sopenharmony_ci switch(resinfo) { 22438c2ecf20Sopenharmony_ci case SIS_RI_1280x720: if(SiS_Pr->UsePanelScaler == -1) { 22448c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 22458c2ecf20Sopenharmony_ci } 22468c2ecf20Sopenharmony_ci break; 22478c2ecf20Sopenharmony_ci } 22488c2ecf20Sopenharmony_ci break; 22498c2ecf20Sopenharmony_ci } 22508c2ecf20Sopenharmony_ci case Panel_1280x800: { /* SiS TMDS special (Averatec 6200 series) */ 22518c2ecf20Sopenharmony_ci static const unsigned char nonscalingmodes[] = { 22528c2ecf20Sopenharmony_ci SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 22538c2ecf20Sopenharmony_ci SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 22548c2ecf20Sopenharmony_ci SIS_RI_1152x768,SIS_RI_1280x720,SIS_RI_1280x768,0xff 22558c2ecf20Sopenharmony_ci }; 22568c2ecf20Sopenharmony_ci SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 22578c2ecf20Sopenharmony_ci break; 22588c2ecf20Sopenharmony_ci } 22598c2ecf20Sopenharmony_ci case Panel_1280x800_2: { /* SiS LVDS */ 22608c2ecf20Sopenharmony_ci static const unsigned char nonscalingmodes[] = { 22618c2ecf20Sopenharmony_ci SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 22628c2ecf20Sopenharmony_ci SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 22638c2ecf20Sopenharmony_ci SIS_RI_1152x768,0xff 22648c2ecf20Sopenharmony_ci }; 22658c2ecf20Sopenharmony_ci SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 22668c2ecf20Sopenharmony_ci switch(resinfo) { 22678c2ecf20Sopenharmony_ci case SIS_RI_1280x720: 22688c2ecf20Sopenharmony_ci case SIS_RI_1280x768: if(SiS_Pr->UsePanelScaler == -1) { 22698c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 22708c2ecf20Sopenharmony_ci } 22718c2ecf20Sopenharmony_ci break; 22728c2ecf20Sopenharmony_ci } 22738c2ecf20Sopenharmony_ci break; 22748c2ecf20Sopenharmony_ci } 22758c2ecf20Sopenharmony_ci case Panel_1280x854: { /* SiS LVDS */ 22768c2ecf20Sopenharmony_ci static const unsigned char nonscalingmodes[] = { 22778c2ecf20Sopenharmony_ci SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 22788c2ecf20Sopenharmony_ci SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 22798c2ecf20Sopenharmony_ci SIS_RI_1152x768,0xff 22808c2ecf20Sopenharmony_ci }; 22818c2ecf20Sopenharmony_ci SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 22828c2ecf20Sopenharmony_ci switch(resinfo) { 22838c2ecf20Sopenharmony_ci case SIS_RI_1280x720: 22848c2ecf20Sopenharmony_ci case SIS_RI_1280x768: 22858c2ecf20Sopenharmony_ci case SIS_RI_1280x800: if(SiS_Pr->UsePanelScaler == -1) { 22868c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 22878c2ecf20Sopenharmony_ci } 22888c2ecf20Sopenharmony_ci break; 22898c2ecf20Sopenharmony_ci } 22908c2ecf20Sopenharmony_ci break; 22918c2ecf20Sopenharmony_ci } 22928c2ecf20Sopenharmony_ci case Panel_1280x960: { 22938c2ecf20Sopenharmony_ci static const unsigned char nonscalingmodes[] = { 22948c2ecf20Sopenharmony_ci SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 22958c2ecf20Sopenharmony_ci SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 22968c2ecf20Sopenharmony_ci SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800, 22978c2ecf20Sopenharmony_ci SIS_RI_1280x854,0xff 22988c2ecf20Sopenharmony_ci }; 22998c2ecf20Sopenharmony_ci SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 23008c2ecf20Sopenharmony_ci break; 23018c2ecf20Sopenharmony_ci } 23028c2ecf20Sopenharmony_ci case Panel_1280x1024: { 23038c2ecf20Sopenharmony_ci static const unsigned char nonscalingmodes[] = { 23048c2ecf20Sopenharmony_ci SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 23058c2ecf20Sopenharmony_ci SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 23068c2ecf20Sopenharmony_ci SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800, 23078c2ecf20Sopenharmony_ci SIS_RI_1280x854,SIS_RI_1280x960,0xff 23088c2ecf20Sopenharmony_ci }; 23098c2ecf20Sopenharmony_ci SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 23108c2ecf20Sopenharmony_ci break; 23118c2ecf20Sopenharmony_ci } 23128c2ecf20Sopenharmony_ci case Panel_1400x1050: { 23138c2ecf20Sopenharmony_ci static const unsigned char nonscalingmodes[] = { 23148c2ecf20Sopenharmony_ci SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 23158c2ecf20Sopenharmony_ci SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 23168c2ecf20Sopenharmony_ci SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x768,SIS_RI_1280x800,SIS_RI_1280x854, 23178c2ecf20Sopenharmony_ci SIS_RI_1280x960,0xff 23188c2ecf20Sopenharmony_ci }; 23198c2ecf20Sopenharmony_ci SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 23208c2ecf20Sopenharmony_ci switch(resinfo) { 23218c2ecf20Sopenharmony_ci case SIS_RI_1280x720: if(SiS_Pr->UsePanelScaler == -1) { 23228c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 23238c2ecf20Sopenharmony_ci } 23248c2ecf20Sopenharmony_ci break; 23258c2ecf20Sopenharmony_ci case SIS_RI_1280x1024: SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 23268c2ecf20Sopenharmony_ci break; 23278c2ecf20Sopenharmony_ci } 23288c2ecf20Sopenharmony_ci break; 23298c2ecf20Sopenharmony_ci } 23308c2ecf20Sopenharmony_ci case Panel_1600x1200: { 23318c2ecf20Sopenharmony_ci static const unsigned char nonscalingmodes[] = { 23328c2ecf20Sopenharmony_ci SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 23338c2ecf20Sopenharmony_ci SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 23348c2ecf20Sopenharmony_ci SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800, 23358c2ecf20Sopenharmony_ci SIS_RI_1280x854,SIS_RI_1280x960,SIS_RI_1360x768,SIS_RI_1360x1024,0xff 23368c2ecf20Sopenharmony_ci }; 23378c2ecf20Sopenharmony_ci SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 23388c2ecf20Sopenharmony_ci break; 23398c2ecf20Sopenharmony_ci } 23408c2ecf20Sopenharmony_ci case Panel_1680x1050: { 23418c2ecf20Sopenharmony_ci static const unsigned char nonscalingmodes[] = { 23428c2ecf20Sopenharmony_ci SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 23438c2ecf20Sopenharmony_ci SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 23448c2ecf20Sopenharmony_ci SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x854,SIS_RI_1280x960,SIS_RI_1360x768, 23458c2ecf20Sopenharmony_ci SIS_RI_1360x1024,0xff 23468c2ecf20Sopenharmony_ci }; 23478c2ecf20Sopenharmony_ci SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 23488c2ecf20Sopenharmony_ci break; 23498c2ecf20Sopenharmony_ci } 23508c2ecf20Sopenharmony_ci } 23518c2ecf20Sopenharmony_ci } 23528c2ecf20Sopenharmony_ci 23538c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 23548c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 23558c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) { 23568c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20; /* neg h/v sync, RGB24(D0 = 0) */ 23578c2ecf20Sopenharmony_ci } 23588c2ecf20Sopenharmony_ci } 23598c2ecf20Sopenharmony_ci 23608c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 23618c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 23628c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 23638c2ecf20Sopenharmony_ci if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { 23648c2ecf20Sopenharmony_ci if(!(ROMAddr[0x235] & 0x02)) { 23658c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); 23668c2ecf20Sopenharmony_ci } 23678c2ecf20Sopenharmony_ci } 23688c2ecf20Sopenharmony_ci } 23698c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 23708c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10))) { 23718c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); 23728c2ecf20Sopenharmony_ci } 23738c2ecf20Sopenharmony_ci } 23748c2ecf20Sopenharmony_ci } 23758c2ecf20Sopenharmony_ci#endif 23768c2ecf20Sopenharmony_ci 23778c2ecf20Sopenharmony_ci /* Special cases */ 23788c2ecf20Sopenharmony_ci 23798c2ecf20Sopenharmony_ci if(modexres == SiS_Pr->PanelXRes && modeyres == SiS_Pr->PanelYRes) { 23808c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo &= ~LCDPass11; 23818c2ecf20Sopenharmony_ci } 23828c2ecf20Sopenharmony_ci 23838c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_TRUMPION) { 23848c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11); 23858c2ecf20Sopenharmony_ci } 23868c2ecf20Sopenharmony_ci 23878c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 23888c2ecf20Sopenharmony_ci case Panel_640x480: 23898c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11); 23908c2ecf20Sopenharmony_ci break; 23918c2ecf20Sopenharmony_ci case Panel_1280x800: 23928c2ecf20Sopenharmony_ci /* Don't pass 1:1 by default (TMDS special) */ 23938c2ecf20Sopenharmony_ci if(SiS_Pr->CenterScreen == -1) SiS_Pr->SiS_LCDInfo &= ~LCDPass11; 23948c2ecf20Sopenharmony_ci break; 23958c2ecf20Sopenharmony_ci case Panel_1280x960: 23968c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo &= ~LCDPass11; 23978c2ecf20Sopenharmony_ci break; 23988c2ecf20Sopenharmony_ci case Panel_Custom: 23998c2ecf20Sopenharmony_ci if((!SiS_Pr->CP_PrefClock) || 24008c2ecf20Sopenharmony_ci (modexres > SiS_Pr->PanelXRes) || (modeyres > SiS_Pr->PanelYRes)) { 24018c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= LCDPass11; 24028c2ecf20Sopenharmony_ci } 24038c2ecf20Sopenharmony_ci break; 24048c2ecf20Sopenharmony_ci } 24058c2ecf20Sopenharmony_ci 24068c2ecf20Sopenharmony_ci if((SiS_Pr->UseCustomMode) || (SiS_Pr->SiS_CustomT == CUT_UNKNOWNLCD)) { 24078c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11); 24088c2ecf20Sopenharmony_ci } 24098c2ecf20Sopenharmony_ci 24108c2ecf20Sopenharmony_ci /* (In)validate LCDPass11 flag */ 24118c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { 24128c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo &= ~LCDPass11; 24138c2ecf20Sopenharmony_ci } 24148c2ecf20Sopenharmony_ci 24158c2ecf20Sopenharmony_ci /* LVDS DDA */ 24168c2ecf20Sopenharmony_ci if(!((SiS_Pr->ChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) { 24178c2ecf20Sopenharmony_ci 24188c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBType & VB_NoLCD)) { 24198c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { 24208c2ecf20Sopenharmony_ci if(ModeNo == 0x12) { 24218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDPass11) { 24228c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 24238c2ecf20Sopenharmony_ci } 24248c2ecf20Sopenharmony_ci } else if(ModeNo > 0x13) { 24258c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x600) { 24268c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { 24278c2ecf20Sopenharmony_ci if((resinfo == SIS_RI_800x600) || (resinfo == SIS_RI_400x300)) { 24288c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 24298c2ecf20Sopenharmony_ci } 24308c2ecf20Sopenharmony_ci } 24318c2ecf20Sopenharmony_ci } 24328c2ecf20Sopenharmony_ci } 24338c2ecf20Sopenharmony_ci } 24348c2ecf20Sopenharmony_ci } 24358c2ecf20Sopenharmony_ci 24368c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) { 24378c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_TRUMPION == 1) { 24388c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 24398c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 24408c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 24418c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_LCDResInfo == Panel_640x480) { 24428c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 24438c2ecf20Sopenharmony_ci } else if(ModeNo > 0x13) { 24448c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 24458c2ecf20Sopenharmony_ci if(resinfo == SIS_RI_512x384) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 24468c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_LCDResInfo == Panel_800x600) { 24478c2ecf20Sopenharmony_ci if(resinfo == SIS_RI_400x300) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 24488c2ecf20Sopenharmony_ci } 24498c2ecf20Sopenharmony_ci } 24508c2ecf20Sopenharmony_ci } 24518c2ecf20Sopenharmony_ci 24528c2ecf20Sopenharmony_ci } 24538c2ecf20Sopenharmony_ci 24548c2ecf20Sopenharmony_ci /* VESA timing */ 24558c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 24568c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) { 24578c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag |= LCDVESATiming; 24588c2ecf20Sopenharmony_ci } 24598c2ecf20Sopenharmony_ci } else { 24608c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag |= LCDVESATiming; 24618c2ecf20Sopenharmony_ci } 24628c2ecf20Sopenharmony_ci 24638c2ecf20Sopenharmony_ci#if 0 24648c2ecf20Sopenharmony_ci printk(KERN_DEBUG "sisfb: (LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)\n", 24658c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo); 24668c2ecf20Sopenharmony_ci#endif 24678c2ecf20Sopenharmony_ci} 24688c2ecf20Sopenharmony_ci 24698c2ecf20Sopenharmony_ci/*********************************************/ 24708c2ecf20Sopenharmony_ci/* GET VCLK */ 24718c2ecf20Sopenharmony_ci/*********************************************/ 24728c2ecf20Sopenharmony_ci 24738c2ecf20Sopenharmony_ciunsigned short 24748c2ecf20Sopenharmony_ciSiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 24758c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 24768c2ecf20Sopenharmony_ci{ 24778c2ecf20Sopenharmony_ci unsigned short CRT2Index, VCLKIndex = 0, VCLKIndexGEN = 0, VCLKIndexGENCRT = 0; 24788c2ecf20Sopenharmony_ci unsigned short resinfo, tempbx; 24798c2ecf20Sopenharmony_ci const unsigned char *CHTVVCLKPtr = NULL; 24808c2ecf20Sopenharmony_ci 24818c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 24828c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; 24838c2ecf20Sopenharmony_ci CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 24848c2ecf20Sopenharmony_ci VCLKIndexGEN = (SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)) >> 2) & 0x03; 24858c2ecf20Sopenharmony_ci VCLKIndexGENCRT = VCLKIndexGEN; 24868c2ecf20Sopenharmony_ci } else { 24878c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 24888c2ecf20Sopenharmony_ci CRT2Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 24898c2ecf20Sopenharmony_ci VCLKIndexGEN = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; 24908c2ecf20Sopenharmony_ci VCLKIndexGENCRT = SiS_GetRefCRTVCLK(SiS_Pr, RefreshRateTableIndex, 24918c2ecf20Sopenharmony_ci (SiS_Pr->SiS_SetFlag & ProgrammingCRT2) ? SiS_Pr->SiS_UseWideCRT2 : SiS_Pr->SiS_UseWide); 24928c2ecf20Sopenharmony_ci } 24938c2ecf20Sopenharmony_ci 24948c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 30x/B/LV */ 24958c2ecf20Sopenharmony_ci 24968c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { 24978c2ecf20Sopenharmony_ci 24988c2ecf20Sopenharmony_ci CRT2Index >>= 6; 24998c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* LCD */ 25008c2ecf20Sopenharmony_ci 25018c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 25028c2ecf20Sopenharmony_ci VCLKIndex = SiS_Pr->PanelVCLKIdx300; 25038c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { 25048c2ecf20Sopenharmony_ci VCLKIndex = VCLKIndexGEN; 25058c2ecf20Sopenharmony_ci } 25068c2ecf20Sopenharmony_ci } else { 25078c2ecf20Sopenharmony_ci VCLKIndex = SiS_Pr->PanelVCLKIdx315; 25088c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { 25098c2ecf20Sopenharmony_ci switch(resinfo) { 25108c2ecf20Sopenharmony_ci /* Correct those whose IndexGEN doesn't match VBVCLK array */ 25118c2ecf20Sopenharmony_ci case SIS_RI_720x480: VCLKIndex = VCLK_720x480; break; 25128c2ecf20Sopenharmony_ci case SIS_RI_720x576: VCLKIndex = VCLK_720x576; break; 25138c2ecf20Sopenharmony_ci case SIS_RI_768x576: VCLKIndex = VCLK_768x576; break; 25148c2ecf20Sopenharmony_ci case SIS_RI_848x480: VCLKIndex = VCLK_848x480; break; 25158c2ecf20Sopenharmony_ci case SIS_RI_856x480: VCLKIndex = VCLK_856x480; break; 25168c2ecf20Sopenharmony_ci case SIS_RI_800x480: VCLKIndex = VCLK_800x480; break; 25178c2ecf20Sopenharmony_ci case SIS_RI_1024x576: VCLKIndex = VCLK_1024x576; break; 25188c2ecf20Sopenharmony_ci case SIS_RI_1152x864: VCLKIndex = VCLK_1152x864; break; 25198c2ecf20Sopenharmony_ci case SIS_RI_1280x720: VCLKIndex = VCLK_1280x720; break; 25208c2ecf20Sopenharmony_ci case SIS_RI_1360x768: VCLKIndex = VCLK_1360x768; break; 25218c2ecf20Sopenharmony_ci default: VCLKIndex = VCLKIndexGEN; 25228c2ecf20Sopenharmony_ci } 25238c2ecf20Sopenharmony_ci 25248c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 25258c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType <= SIS_315PRO) { 25268c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42; 25278c2ecf20Sopenharmony_ci } else { 25288c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x00; 25298c2ecf20Sopenharmony_ci } 25308c2ecf20Sopenharmony_ci } 25318c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType <= SIS_315PRO) { 25328c2ecf20Sopenharmony_ci if(VCLKIndex == 0) VCLKIndex = 0x41; 25338c2ecf20Sopenharmony_ci if(VCLKIndex == 1) VCLKIndex = 0x43; 25348c2ecf20Sopenharmony_ci if(VCLKIndex == 4) VCLKIndex = 0x44; 25358c2ecf20Sopenharmony_ci } 25368c2ecf20Sopenharmony_ci } 25378c2ecf20Sopenharmony_ci } 25388c2ecf20Sopenharmony_ci 25398c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */ 25408c2ecf20Sopenharmony_ci 25418c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 25428c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = HiTVVCLKDIV2; 25438c2ecf20Sopenharmony_ci else VCLKIndex = HiTVVCLK; 25448c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) VCLKIndex = HiTVSimuVCLK; 25458c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) VCLKIndex = YPbPr750pVCLK; 25468c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) VCLKIndex = TVVCLKDIV2; 25478c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = TVVCLKDIV2; 25488c2ecf20Sopenharmony_ci else VCLKIndex = TVVCLK; 25498c2ecf20Sopenharmony_ci 25508c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) VCLKIndex += TVCLKBASE_300; 25518c2ecf20Sopenharmony_ci else VCLKIndex += TVCLKBASE_315; 25528c2ecf20Sopenharmony_ci 25538c2ecf20Sopenharmony_ci } else { /* VGA2 */ 25548c2ecf20Sopenharmony_ci 25558c2ecf20Sopenharmony_ci VCLKIndex = VCLKIndexGENCRT; 25568c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 25578c2ecf20Sopenharmony_ci if(ModeNo > 0x13) { 25588c2ecf20Sopenharmony_ci if( (SiS_Pr->ChipType == SIS_630) && 25598c2ecf20Sopenharmony_ci (SiS_Pr->ChipRevision >= 0x30)) { 25608c2ecf20Sopenharmony_ci if(VCLKIndex == 0x14) VCLKIndex = 0x34; 25618c2ecf20Sopenharmony_ci } 25628c2ecf20Sopenharmony_ci /* Better VGA2 clock for 1280x1024@75 */ 25638c2ecf20Sopenharmony_ci if(VCLKIndex == 0x17) VCLKIndex = 0x45; 25648c2ecf20Sopenharmony_ci } 25658c2ecf20Sopenharmony_ci } 25668c2ecf20Sopenharmony_ci } 25678c2ecf20Sopenharmony_ci 25688c2ecf20Sopenharmony_ci } else { /* If not programming CRT2 */ 25698c2ecf20Sopenharmony_ci 25708c2ecf20Sopenharmony_ci VCLKIndex = VCLKIndexGENCRT; 25718c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 25728c2ecf20Sopenharmony_ci if(ModeNo > 0x13) { 25738c2ecf20Sopenharmony_ci if( (SiS_Pr->ChipType != SIS_630) && 25748c2ecf20Sopenharmony_ci (SiS_Pr->ChipType != SIS_300) ) { 25758c2ecf20Sopenharmony_ci if(VCLKIndex == 0x1b) VCLKIndex = 0x48; 25768c2ecf20Sopenharmony_ci } 25778c2ecf20Sopenharmony_ci } 25788c2ecf20Sopenharmony_ci } 25798c2ecf20Sopenharmony_ci } 25808c2ecf20Sopenharmony_ci 25818c2ecf20Sopenharmony_ci } else { /* LVDS */ 25828c2ecf20Sopenharmony_ci 25838c2ecf20Sopenharmony_ci VCLKIndex = CRT2Index; 25848c2ecf20Sopenharmony_ci 25858c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { 25868c2ecf20Sopenharmony_ci 25878c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { 25888c2ecf20Sopenharmony_ci 25898c2ecf20Sopenharmony_ci VCLKIndex &= 0x1f; 25908c2ecf20Sopenharmony_ci tempbx = 0; 25918c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; 25928c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) { 25938c2ecf20Sopenharmony_ci tempbx += 2; 25948c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType > ModeVGA) { 25958c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CHSOverScan) tempbx = 8; 25968c2ecf20Sopenharmony_ci } 25978c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPALM) { 25988c2ecf20Sopenharmony_ci tempbx = 4; 25998c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; 26008c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { 26018c2ecf20Sopenharmony_ci tempbx = 6; 26028c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; 26038c2ecf20Sopenharmony_ci } 26048c2ecf20Sopenharmony_ci } 26058c2ecf20Sopenharmony_ci switch(tempbx) { 26068c2ecf20Sopenharmony_ci case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break; 26078c2ecf20Sopenharmony_ci case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break; 26088c2ecf20Sopenharmony_ci case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break; 26098c2ecf20Sopenharmony_ci case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; 26108c2ecf20Sopenharmony_ci case 4: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALM; break; 26118c2ecf20Sopenharmony_ci case 5: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALM; break; 26128c2ecf20Sopenharmony_ci case 6: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALN; break; 26138c2ecf20Sopenharmony_ci case 7: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALN; break; 26148c2ecf20Sopenharmony_ci case 8: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKSOPAL; break; 26158c2ecf20Sopenharmony_ci default: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; 26168c2ecf20Sopenharmony_ci } 26178c2ecf20Sopenharmony_ci VCLKIndex = CHTVVCLKPtr[VCLKIndex]; 26188c2ecf20Sopenharmony_ci 26198c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 26208c2ecf20Sopenharmony_ci 26218c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 26228c2ecf20Sopenharmony_ci VCLKIndex = SiS_Pr->PanelVCLKIdx300; 26238c2ecf20Sopenharmony_ci } else { 26248c2ecf20Sopenharmony_ci VCLKIndex = SiS_Pr->PanelVCLKIdx315; 26258c2ecf20Sopenharmony_ci } 26268c2ecf20Sopenharmony_ci 26278c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 26288c2ecf20Sopenharmony_ci /* Special Timing: Barco iQ Pro R series */ 26298c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) VCLKIndex = 0x44; 26308c2ecf20Sopenharmony_ci 26318c2ecf20Sopenharmony_ci /* Special Timing: 848x480 and 856x480 parallel lvds panels */ 26328c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) { 26338c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 26348c2ecf20Sopenharmony_ci VCLKIndex = VCLK34_300; 26358c2ecf20Sopenharmony_ci /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ 26368c2ecf20Sopenharmony_ci } else { 26378c2ecf20Sopenharmony_ci VCLKIndex = VCLK34_315; 26388c2ecf20Sopenharmony_ci /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ 26398c2ecf20Sopenharmony_ci } 26408c2ecf20Sopenharmony_ci } 26418c2ecf20Sopenharmony_ci#endif 26428c2ecf20Sopenharmony_ci 26438c2ecf20Sopenharmony_ci } else { 26448c2ecf20Sopenharmony_ci 26458c2ecf20Sopenharmony_ci VCLKIndex = VCLKIndexGENCRT; 26468c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 26478c2ecf20Sopenharmony_ci if(ModeNo > 0x13) { 26488c2ecf20Sopenharmony_ci if( (SiS_Pr->ChipType == SIS_630) && 26498c2ecf20Sopenharmony_ci (SiS_Pr->ChipRevision >= 0x30) ) { 26508c2ecf20Sopenharmony_ci if(VCLKIndex == 0x14) VCLKIndex = 0x2e; 26518c2ecf20Sopenharmony_ci } 26528c2ecf20Sopenharmony_ci } 26538c2ecf20Sopenharmony_ci } 26548c2ecf20Sopenharmony_ci } 26558c2ecf20Sopenharmony_ci 26568c2ecf20Sopenharmony_ci } else { /* if not programming CRT2 */ 26578c2ecf20Sopenharmony_ci 26588c2ecf20Sopenharmony_ci VCLKIndex = VCLKIndexGENCRT; 26598c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 26608c2ecf20Sopenharmony_ci if(ModeNo > 0x13) { 26618c2ecf20Sopenharmony_ci if( (SiS_Pr->ChipType != SIS_630) && 26628c2ecf20Sopenharmony_ci (SiS_Pr->ChipType != SIS_300) ) { 26638c2ecf20Sopenharmony_ci if(VCLKIndex == 0x1b) VCLKIndex = 0x48; 26648c2ecf20Sopenharmony_ci } 26658c2ecf20Sopenharmony_ci#if 0 26668c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_730) { 26678c2ecf20Sopenharmony_ci if(VCLKIndex == 0x0b) VCLKIndex = 0x40; /* 1024x768-70 */ 26688c2ecf20Sopenharmony_ci if(VCLKIndex == 0x0d) VCLKIndex = 0x41; /* 1024x768-75 */ 26698c2ecf20Sopenharmony_ci } 26708c2ecf20Sopenharmony_ci#endif 26718c2ecf20Sopenharmony_ci } 26728c2ecf20Sopenharmony_ci } 26738c2ecf20Sopenharmony_ci 26748c2ecf20Sopenharmony_ci } 26758c2ecf20Sopenharmony_ci 26768c2ecf20Sopenharmony_ci } 26778c2ecf20Sopenharmony_ci 26788c2ecf20Sopenharmony_ci return VCLKIndex; 26798c2ecf20Sopenharmony_ci} 26808c2ecf20Sopenharmony_ci 26818c2ecf20Sopenharmony_ci/*********************************************/ 26828c2ecf20Sopenharmony_ci/* SET CRT2 MODE TYPE REGISTERS */ 26838c2ecf20Sopenharmony_ci/*********************************************/ 26848c2ecf20Sopenharmony_ci 26858c2ecf20Sopenharmony_cistatic void 26868c2ecf20Sopenharmony_ciSiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 26878c2ecf20Sopenharmony_ci{ 26888c2ecf20Sopenharmony_ci unsigned short i, j, modeflag, tempah=0; 26898c2ecf20Sopenharmony_ci short tempcl; 26908c2ecf20Sopenharmony_ci#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315) 26918c2ecf20Sopenharmony_ci unsigned short tempbl; 26928c2ecf20Sopenharmony_ci#endif 26938c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 26948c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 26958c2ecf20Sopenharmony_ci unsigned short tempah2, tempbl2; 26968c2ecf20Sopenharmony_ci#endif 26978c2ecf20Sopenharmony_ci 26988c2ecf20Sopenharmony_ci modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); 26998c2ecf20Sopenharmony_ci 27008c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 27018c2ecf20Sopenharmony_ci 27028c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xAF,0x40); 27038c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2E,0xF7); 27048c2ecf20Sopenharmony_ci 27058c2ecf20Sopenharmony_ci } else { 27068c2ecf20Sopenharmony_ci 27078c2ecf20Sopenharmony_ci for(i=0,j=4; i<3; i++,j++) SiS_SetReg(SiS_Pr->SiS_Part1Port,j,0); 27088c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 27098c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0x7F); 27108c2ecf20Sopenharmony_ci } 27118c2ecf20Sopenharmony_ci 27128c2ecf20Sopenharmony_ci tempcl = SiS_Pr->SiS_ModeType; 27138c2ecf20Sopenharmony_ci 27148c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 27158c2ecf20Sopenharmony_ci 27168c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 /* ---- 300 series ---- */ 27178c2ecf20Sopenharmony_ci 27188c2ecf20Sopenharmony_ci /* For 301BDH: (with LCD via LVDS) */ 27198c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_NoLCD) { 27208c2ecf20Sopenharmony_ci tempbl = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32); 27218c2ecf20Sopenharmony_ci tempbl &= 0xef; 27228c2ecf20Sopenharmony_ci tempbl |= 0x02; 27238c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) || (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { 27248c2ecf20Sopenharmony_ci tempbl |= 0x10; 27258c2ecf20Sopenharmony_ci tempbl &= 0xfd; 27268c2ecf20Sopenharmony_ci } 27278c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,tempbl); 27288c2ecf20Sopenharmony_ci } 27298c2ecf20Sopenharmony_ci 27308c2ecf20Sopenharmony_ci if(ModeNo > 0x13) { 27318c2ecf20Sopenharmony_ci tempcl -= ModeVGA; 27328c2ecf20Sopenharmony_ci if(tempcl >= 0) { 27338c2ecf20Sopenharmony_ci tempah = ((0x10 >> tempcl) | 0x80); 27348c2ecf20Sopenharmony_ci } 27358c2ecf20Sopenharmony_ci } else tempah = 0x80; 27368c2ecf20Sopenharmony_ci 27378c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0; 27388c2ecf20Sopenharmony_ci 27398c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_300 */ 27408c2ecf20Sopenharmony_ci 27418c2ecf20Sopenharmony_ci } else { 27428c2ecf20Sopenharmony_ci 27438c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 /* ------- 315/330 series ------ */ 27448c2ecf20Sopenharmony_ci 27458c2ecf20Sopenharmony_ci if(ModeNo > 0x13) { 27468c2ecf20Sopenharmony_ci tempcl -= ModeVGA; 27478c2ecf20Sopenharmony_ci if(tempcl >= 0) { 27488c2ecf20Sopenharmony_ci tempah = (0x08 >> tempcl); 27498c2ecf20Sopenharmony_ci if (tempah == 0) tempah = 1; 27508c2ecf20Sopenharmony_ci tempah |= 0x40; 27518c2ecf20Sopenharmony_ci } 27528c2ecf20Sopenharmony_ci } else tempah = 0x40; 27538c2ecf20Sopenharmony_ci 27548c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50; 27558c2ecf20Sopenharmony_ci 27568c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_315 */ 27578c2ecf20Sopenharmony_ci 27588c2ecf20Sopenharmony_ci } 27598c2ecf20Sopenharmony_ci 27608c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; 27618c2ecf20Sopenharmony_ci 27628c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 27638c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); 27648c2ecf20Sopenharmony_ci } else { 27658c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 27668c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 27678c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); 27688c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 27698c2ecf20Sopenharmony_ci if(IS_SIS740) { 27708c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); 27718c2ecf20Sopenharmony_ci } else { 27728c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); 27738c2ecf20Sopenharmony_ci } 27748c2ecf20Sopenharmony_ci } 27758c2ecf20Sopenharmony_ci#endif 27768c2ecf20Sopenharmony_ci } 27778c2ecf20Sopenharmony_ci 27788c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 27798c2ecf20Sopenharmony_ci 27808c2ecf20Sopenharmony_ci tempah = 0x01; 27818c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 27828c2ecf20Sopenharmony_ci tempah |= 0x02; 27838c2ecf20Sopenharmony_ci } 27848c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { 27858c2ecf20Sopenharmony_ci tempah ^= 0x05; 27868c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { 27878c2ecf20Sopenharmony_ci tempah ^= 0x01; 27888c2ecf20Sopenharmony_ci } 27898c2ecf20Sopenharmony_ci } 27908c2ecf20Sopenharmony_ci 27918c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 27928c2ecf20Sopenharmony_ci 27938c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; 27948c2ecf20Sopenharmony_ci 27958c2ecf20Sopenharmony_ci tempah = (tempah << 5) & 0xFF; 27968c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); 27978c2ecf20Sopenharmony_ci tempah = (tempah >> 5) & 0xFF; 27988c2ecf20Sopenharmony_ci 27998c2ecf20Sopenharmony_ci } else { 28008c2ecf20Sopenharmony_ci 28018c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0x08; 28028c2ecf20Sopenharmony_ci else if(!(SiS_IsDualEdge(SiS_Pr))) tempah |= 0x08; 28038c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF0,tempah); 28048c2ecf20Sopenharmony_ci tempah &= ~0x08; 28058c2ecf20Sopenharmony_ci 28068c2ecf20Sopenharmony_ci } 28078c2ecf20Sopenharmony_ci 28088c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { 28098c2ecf20Sopenharmony_ci tempah |= 0x10; 28108c2ecf20Sopenharmony_ci } 28118c2ecf20Sopenharmony_ci 28128c2ecf20Sopenharmony_ci tempah |= 0x80; 28138c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS301) { 28148c2ecf20Sopenharmony_ci if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah &= ~0x80; 28158c2ecf20Sopenharmony_ci } 28168c2ecf20Sopenharmony_ci 28178c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 28188c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p))) { 28198c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 28208c2ecf20Sopenharmony_ci tempah |= 0x20; 28218c2ecf20Sopenharmony_ci } 28228c2ecf20Sopenharmony_ci } 28238c2ecf20Sopenharmony_ci } 28248c2ecf20Sopenharmony_ci 28258c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah); 28268c2ecf20Sopenharmony_ci 28278c2ecf20Sopenharmony_ci tempah = 0x80; 28288c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS301) { 28298c2ecf20Sopenharmony_ci if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah = 0; 28308c2ecf20Sopenharmony_ci } 28318c2ecf20Sopenharmony_ci 28328c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) tempah |= 0x40; 28338c2ecf20Sopenharmony_ci 28348c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 28358c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) { 28368c2ecf20Sopenharmony_ci tempah |= 0x40; 28378c2ecf20Sopenharmony_ci } 28388c2ecf20Sopenharmony_ci } 28398c2ecf20Sopenharmony_ci 28408c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0C,tempah); 28418c2ecf20Sopenharmony_ci 28428c2ecf20Sopenharmony_ci } else { /* LVDS */ 28438c2ecf20Sopenharmony_ci 28448c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 28458c2ecf20Sopenharmony_ci 28468c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 28478c2ecf20Sopenharmony_ci /* LVDS can only be slave in 8bpp modes */ 28488c2ecf20Sopenharmony_ci tempah = 0x80; 28498c2ecf20Sopenharmony_ci if((modeflag & CRT2Mode) && (SiS_Pr->SiS_ModeType > ModeVGA)) { 28508c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & DriverMode) { 28518c2ecf20Sopenharmony_ci tempah |= 0x02; 28528c2ecf20Sopenharmony_ci } 28538c2ecf20Sopenharmony_ci } 28548c2ecf20Sopenharmony_ci 28558c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) tempah |= 0x02; 28568c2ecf20Sopenharmony_ci 28578c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah ^= 0x01; 28588c2ecf20Sopenharmony_ci 28598c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 1; 28608c2ecf20Sopenharmony_ci 28618c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah); 28628c2ecf20Sopenharmony_ci#endif 28638c2ecf20Sopenharmony_ci 28648c2ecf20Sopenharmony_ci } else { 28658c2ecf20Sopenharmony_ci 28668c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 28678c2ecf20Sopenharmony_ci tempah = 0; 28688c2ecf20Sopenharmony_ci if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { 28698c2ecf20Sopenharmony_ci tempah |= 0x02; 28708c2ecf20Sopenharmony_ci } 28718c2ecf20Sopenharmony_ci tempah <<= 5; 28728c2ecf20Sopenharmony_ci 28738c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; 28748c2ecf20Sopenharmony_ci 28758c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); 28768c2ecf20Sopenharmony_ci#endif 28778c2ecf20Sopenharmony_ci 28788c2ecf20Sopenharmony_ci } 28798c2ecf20Sopenharmony_ci 28808c2ecf20Sopenharmony_ci } 28818c2ecf20Sopenharmony_ci 28828c2ecf20Sopenharmony_ci } /* LCDA */ 28838c2ecf20Sopenharmony_ci 28848c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 28858c2ecf20Sopenharmony_ci 28868c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 28878c2ecf20Sopenharmony_ci 28888c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 28898c2ecf20Sopenharmony_ci /* unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); */ 28908c2ecf20Sopenharmony_ci 28918c2ecf20Sopenharmony_ci /* The following is nearly unpreditable and varies from machine 28928c2ecf20Sopenharmony_ci * to machine. Especially the 301DH seems to be a real trouble 28938c2ecf20Sopenharmony_ci * maker. Some BIOSes simply set the registers (like in the 28948c2ecf20Sopenharmony_ci * NoLCD-if-statements here), some set them according to the 28958c2ecf20Sopenharmony_ci * LCDA stuff. It is very likely that some machines are not 28968c2ecf20Sopenharmony_ci * treated correctly in the following, very case-orientated 28978c2ecf20Sopenharmony_ci * code. What do I do then...? 28988c2ecf20Sopenharmony_ci */ 28998c2ecf20Sopenharmony_ci 29008c2ecf20Sopenharmony_ci /* 740 variants match for 30xB, 301B-DH, 30xLV */ 29018c2ecf20Sopenharmony_ci 29028c2ecf20Sopenharmony_ci if(!(IS_SIS740)) { 29038c2ecf20Sopenharmony_ci tempah = 0x04; /* For all bridges */ 29048c2ecf20Sopenharmony_ci tempbl = 0xfb; 29058c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 29068c2ecf20Sopenharmony_ci tempah = 0x00; 29078c2ecf20Sopenharmony_ci if(SiS_IsDualEdge(SiS_Pr)) { 29088c2ecf20Sopenharmony_ci tempbl = 0xff; 29098c2ecf20Sopenharmony_ci } 29108c2ecf20Sopenharmony_ci } 29118c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); 29128c2ecf20Sopenharmony_ci } 29138c2ecf20Sopenharmony_ci 29148c2ecf20Sopenharmony_ci /* The following two are responsible for eventually wrong colors 29158c2ecf20Sopenharmony_ci * in TV output. The DH (VB_NoLCD) conditions are unknown; the 29168c2ecf20Sopenharmony_ci * b0 was found in some 651 machine (Pim; P4_23=0xe5); the b1 version 29178c2ecf20Sopenharmony_ci * in a 650 box (Jake). What is the criteria? 29188c2ecf20Sopenharmony_ci * Addendum: Another combination 651+301B-DH(b1) (Rapo) needs same 29198c2ecf20Sopenharmony_ci * treatment like the 651+301B-DH(b0) case. Seems more to be the 29208c2ecf20Sopenharmony_ci * chipset than the bridge revision. 29218c2ecf20Sopenharmony_ci */ 29228c2ecf20Sopenharmony_ci 29238c2ecf20Sopenharmony_ci if((IS_SIS740) || (SiS_Pr->ChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { 29248c2ecf20Sopenharmony_ci tempah = 0x30; 29258c2ecf20Sopenharmony_ci tempbl = 0xc0; 29268c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || 29278c2ecf20Sopenharmony_ci ((SiS_Pr->SiS_ROMNew) && (!(ROMAddr[0x5b] & 0x04)))) { 29288c2ecf20Sopenharmony_ci tempah = 0x00; 29298c2ecf20Sopenharmony_ci tempbl = 0x00; 29308c2ecf20Sopenharmony_ci } 29318c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xcf,tempah); 29328c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,tempbl); 29338c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SIS301) { 29348c2ecf20Sopenharmony_ci /* Fixes "TV-blue-bug" on 315+301 */ 29358c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xcf); /* For 301 */ 29368c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); 29378c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 29388c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xLV */ 29398c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0); 29408c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { /* For 301B-DH */ 29418c2ecf20Sopenharmony_ci tempah = 0x30; tempah2 = 0xc0; 29428c2ecf20Sopenharmony_ci tempbl = 0xcf; tempbl2 = 0x3f; 29438c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVBlue == 0) { 29448c2ecf20Sopenharmony_ci tempah = tempah2 = 0x00; 29458c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_TVBlue == -1) { 29468c2ecf20Sopenharmony_ci /* Set on 651/M650, clear on 315/650 */ 29478c2ecf20Sopenharmony_ci if(!(IS_SIS65x)) /* (bridgerev != 0xb0) */ { 29488c2ecf20Sopenharmony_ci tempah = tempah2 = 0x00; 29498c2ecf20Sopenharmony_ci } 29508c2ecf20Sopenharmony_ci } 29518c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah); 29528c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl2,tempah2); 29538c2ecf20Sopenharmony_ci } else { 29548c2ecf20Sopenharmony_ci tempah = 0x30; tempah2 = 0xc0; /* For 30xB, 301C */ 29558c2ecf20Sopenharmony_ci tempbl = 0xcf; tempbl2 = 0x3f; 29568c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 29578c2ecf20Sopenharmony_ci tempah = tempah2 = 0x00; 29588c2ecf20Sopenharmony_ci if(SiS_IsDualEdge(SiS_Pr)) { 29598c2ecf20Sopenharmony_ci tempbl = tempbl2 = 0xff; 29608c2ecf20Sopenharmony_ci } 29618c2ecf20Sopenharmony_ci } 29628c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah); 29638c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl2,tempah2); 29648c2ecf20Sopenharmony_ci } 29658c2ecf20Sopenharmony_ci 29668c2ecf20Sopenharmony_ci if(IS_SIS740) { 29678c2ecf20Sopenharmony_ci tempah = 0x80; 29688c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0x00; 29698c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,0x7f,tempah); 29708c2ecf20Sopenharmony_ci } else { 29718c2ecf20Sopenharmony_ci tempah = 0x00; 29728c2ecf20Sopenharmony_ci tempbl = 0x7f; 29738c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 29748c2ecf20Sopenharmony_ci tempbl = 0xff; 29758c2ecf20Sopenharmony_ci if(!(SiS_IsDualEdge(SiS_Pr))) tempah = 0x80; 29768c2ecf20Sopenharmony_ci } 29778c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah); 29788c2ecf20Sopenharmony_ci } 29798c2ecf20Sopenharmony_ci 29808c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_315 */ 29818c2ecf20Sopenharmony_ci 29828c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 29838c2ecf20Sopenharmony_ci 29848c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 29858c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); 29868c2ecf20Sopenharmony_ci 29878c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || 29888c2ecf20Sopenharmony_ci ((SiS_Pr->SiS_VBType & VB_NoLCD) && 29898c2ecf20Sopenharmony_ci (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD))) { 29908c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x23,0x7F); 29918c2ecf20Sopenharmony_ci } else { 29928c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x23,0x80); 29938c2ecf20Sopenharmony_ci } 29948c2ecf20Sopenharmony_ci#endif 29958c2ecf20Sopenharmony_ci 29968c2ecf20Sopenharmony_ci } 29978c2ecf20Sopenharmony_ci 29988c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 29998c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x0D,0x80); 30008c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) { 30018c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x3A,0xC0); 30028c2ecf20Sopenharmony_ci } 30038c2ecf20Sopenharmony_ci } 30048c2ecf20Sopenharmony_ci 30058c2ecf20Sopenharmony_ci } else { /* LVDS */ 30068c2ecf20Sopenharmony_ci 30078c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 30088c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 30098c2ecf20Sopenharmony_ci 30108c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 30118c2ecf20Sopenharmony_ci 30128c2ecf20Sopenharmony_ci tempah = 0x04; 30138c2ecf20Sopenharmony_ci tempbl = 0xfb; 30148c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 30158c2ecf20Sopenharmony_ci tempah = 0x00; 30168c2ecf20Sopenharmony_ci if(SiS_IsDualEdge(SiS_Pr)) tempbl = 0xff; 30178c2ecf20Sopenharmony_ci } 30188c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); 30198c2ecf20Sopenharmony_ci 30208c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { 30218c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); 30228c2ecf20Sopenharmony_ci } 30238c2ecf20Sopenharmony_ci 30248c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); 30258c2ecf20Sopenharmony_ci 30268c2ecf20Sopenharmony_ci } else if(SiS_Pr->ChipType == SIS_550) { 30278c2ecf20Sopenharmony_ci 30288c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); 30298c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); 30308c2ecf20Sopenharmony_ci 30318c2ecf20Sopenharmony_ci } 30328c2ecf20Sopenharmony_ci 30338c2ecf20Sopenharmony_ci } 30348c2ecf20Sopenharmony_ci#endif 30358c2ecf20Sopenharmony_ci 30368c2ecf20Sopenharmony_ci } 30378c2ecf20Sopenharmony_ci 30388c2ecf20Sopenharmony_ci} 30398c2ecf20Sopenharmony_ci 30408c2ecf20Sopenharmony_ci/*********************************************/ 30418c2ecf20Sopenharmony_ci/* GET RESOLUTION DATA */ 30428c2ecf20Sopenharmony_ci/*********************************************/ 30438c2ecf20Sopenharmony_ci 30448c2ecf20Sopenharmony_ciunsigned short 30458c2ecf20Sopenharmony_ciSiS_GetResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 30468c2ecf20Sopenharmony_ci{ 30478c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) 30488c2ecf20Sopenharmony_ci return ((unsigned short)SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo); 30498c2ecf20Sopenharmony_ci else 30508c2ecf20Sopenharmony_ci return ((unsigned short)SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO); 30518c2ecf20Sopenharmony_ci} 30528c2ecf20Sopenharmony_ci 30538c2ecf20Sopenharmony_cistatic void 30548c2ecf20Sopenharmony_ciSiS_GetCRT2ResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 30558c2ecf20Sopenharmony_ci{ 30568c2ecf20Sopenharmony_ci unsigned short xres, yres, modeflag=0, resindex; 30578c2ecf20Sopenharmony_ci 30588c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 30598c2ecf20Sopenharmony_ci xres = SiS_Pr->CHDisplay; 30608c2ecf20Sopenharmony_ci if(SiS_Pr->CModeFlag & HalfDCLK) xres <<= 1; 30618c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; 30628c2ecf20Sopenharmony_ci /* DoubleScanMode-check done in CheckCalcCustomMode()! */ 30638c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = SiS_Pr->CVDisplay; 30648c2ecf20Sopenharmony_ci return; 30658c2ecf20Sopenharmony_ci } 30668c2ecf20Sopenharmony_ci 30678c2ecf20Sopenharmony_ci resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex); 30688c2ecf20Sopenharmony_ci 30698c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 30708c2ecf20Sopenharmony_ci xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; 30718c2ecf20Sopenharmony_ci yres = SiS_Pr->SiS_StResInfo[resindex].VTotal; 30728c2ecf20Sopenharmony_ci } else { 30738c2ecf20Sopenharmony_ci xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; 30748c2ecf20Sopenharmony_ci yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal; 30758c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 30768c2ecf20Sopenharmony_ci } 30778c2ecf20Sopenharmony_ci 30788c2ecf20Sopenharmony_ci if(!SiS_Pr->SiS_IF_DEF_DSTN && !SiS_Pr->SiS_IF_DEF_FSTN) { 30798c2ecf20Sopenharmony_ci 30808c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) { 30818c2ecf20Sopenharmony_ci if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) { 30828c2ecf20Sopenharmony_ci if(yres == 350) yres = 400; 30838c2ecf20Sopenharmony_ci } 30848c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x3a) & 0x01) { 30858c2ecf20Sopenharmony_ci if(ModeNo == 0x12) yres = 400; 30868c2ecf20Sopenharmony_ci } 30878c2ecf20Sopenharmony_ci } 30888c2ecf20Sopenharmony_ci 30898c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) xres <<= 1; 30908c2ecf20Sopenharmony_ci if(modeflag & DoubleScanMode) yres <<= 1; 30918c2ecf20Sopenharmony_ci 30928c2ecf20Sopenharmony_ci } 30938c2ecf20Sopenharmony_ci 30948c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { 30958c2ecf20Sopenharmony_ci 30968c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 30978c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 30988c2ecf20Sopenharmony_ci case Panel_1024x768: 30998c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { 31008c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { 31018c2ecf20Sopenharmony_ci if(yres == 350) yres = 357; 31028c2ecf20Sopenharmony_ci if(yres == 400) yres = 420; 31038c2ecf20Sopenharmony_ci if(yres == 480) yres = 525; 31048c2ecf20Sopenharmony_ci } 31058c2ecf20Sopenharmony_ci } 31068c2ecf20Sopenharmony_ci break; 31078c2ecf20Sopenharmony_ci case Panel_1280x1024: 31088c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { 31098c2ecf20Sopenharmony_ci /* BIOS bug - does this regardless of scaling */ 31108c2ecf20Sopenharmony_ci if(yres == 400) yres = 405; 31118c2ecf20Sopenharmony_ci } 31128c2ecf20Sopenharmony_ci if(yres == 350) yres = 360; 31138c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { 31148c2ecf20Sopenharmony_ci if(yres == 360) yres = 375; 31158c2ecf20Sopenharmony_ci } 31168c2ecf20Sopenharmony_ci break; 31178c2ecf20Sopenharmony_ci case Panel_1600x1200: 31188c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { 31198c2ecf20Sopenharmony_ci if(yres == 1024) yres = 1056; 31208c2ecf20Sopenharmony_ci } 31218c2ecf20Sopenharmony_ci break; 31228c2ecf20Sopenharmony_ci } 31238c2ecf20Sopenharmony_ci } 31248c2ecf20Sopenharmony_ci 31258c2ecf20Sopenharmony_ci } else { 31268c2ecf20Sopenharmony_ci 31278c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 31288c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVision)) { 31298c2ecf20Sopenharmony_ci if(xres == 720) xres = 640; 31308c2ecf20Sopenharmony_ci } 31318c2ecf20Sopenharmony_ci } else if(xres == 720) xres = 640; 31328c2ecf20Sopenharmony_ci 31338c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & SetDOSMode) { 31348c2ecf20Sopenharmony_ci yres = 400; 31358c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 31368c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480; 31378c2ecf20Sopenharmony_ci } else { 31388c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480; 31398c2ecf20Sopenharmony_ci } 31408c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) yres = 480; 31418c2ecf20Sopenharmony_ci } 31428c2ecf20Sopenharmony_ci 31438c2ecf20Sopenharmony_ci } 31448c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; 31458c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; 31468c2ecf20Sopenharmony_ci} 31478c2ecf20Sopenharmony_ci 31488c2ecf20Sopenharmony_ci/*********************************************/ 31498c2ecf20Sopenharmony_ci/* GET CRT2 TIMING DATA */ 31508c2ecf20Sopenharmony_ci/*********************************************/ 31518c2ecf20Sopenharmony_ci 31528c2ecf20Sopenharmony_cistatic void 31538c2ecf20Sopenharmony_ciSiS_GetCRT2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 31548c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex, unsigned short *CRT2Index, 31558c2ecf20Sopenharmony_ci unsigned short *ResIndex) 31568c2ecf20Sopenharmony_ci{ 31578c2ecf20Sopenharmony_ci unsigned short tempbx=0, tempal=0, resinfo=0; 31588c2ecf20Sopenharmony_ci 31598c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 31608c2ecf20Sopenharmony_ci tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 31618c2ecf20Sopenharmony_ci } else { 31628c2ecf20Sopenharmony_ci tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 31638c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 31648c2ecf20Sopenharmony_ci } 31658c2ecf20Sopenharmony_ci 31668c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_IF_DEF_LVDS == 0)) { 31678c2ecf20Sopenharmony_ci 31688c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */ 31698c2ecf20Sopenharmony_ci 31708c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_LCDResInfo; 31718c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx += 32; 31728c2ecf20Sopenharmony_ci 31738c2ecf20Sopenharmony_ci /* patch index */ 31748c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1680x1050) { 31758c2ecf20Sopenharmony_ci if (resinfo == SIS_RI_1280x800) tempal = 9; 31768c2ecf20Sopenharmony_ci else if(resinfo == SIS_RI_1400x1050) tempal = 11; 31778c2ecf20Sopenharmony_ci } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x800) || 31788c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1280x800_2) || 31798c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1280x854)) { 31808c2ecf20Sopenharmony_ci if (resinfo == SIS_RI_1280x768) tempal = 9; 31818c2ecf20Sopenharmony_ci } 31828c2ecf20Sopenharmony_ci 31838c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 31848c2ecf20Sopenharmony_ci /* Pass 1:1 only (center-screen handled outside) */ 31858c2ecf20Sopenharmony_ci /* This is never called for the panel's native resolution */ 31868c2ecf20Sopenharmony_ci /* since Pass1:1 will not be set in this case */ 31878c2ecf20Sopenharmony_ci tempbx = 100; 31888c2ecf20Sopenharmony_ci if(ModeNo >= 0x13) { 31898c2ecf20Sopenharmony_ci tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS; 31908c2ecf20Sopenharmony_ci } 31918c2ecf20Sopenharmony_ci } 31928c2ecf20Sopenharmony_ci 31938c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 31948c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { 31958c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { 31968c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { 31978c2ecf20Sopenharmony_ci tempbx = 200; 31988c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++; 31998c2ecf20Sopenharmony_ci } 32008c2ecf20Sopenharmony_ci } 32018c2ecf20Sopenharmony_ci } 32028c2ecf20Sopenharmony_ci#endif 32038c2ecf20Sopenharmony_ci 32048c2ecf20Sopenharmony_ci } else { /* TV */ 32058c2ecf20Sopenharmony_ci 32068c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 32078c2ecf20Sopenharmony_ci /* if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_TVMode &= (~TVSetTVSimuMode); */ 32088c2ecf20Sopenharmony_ci tempbx = 2; 32098c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 32108c2ecf20Sopenharmony_ci tempbx = 13; 32118c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) tempbx = 14; 32128c2ecf20Sopenharmony_ci } 32138c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 32148c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempbx = 7; 32158c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempbx = 6; 32168c2ecf20Sopenharmony_ci else tempbx = 5; 32178c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; 32188c2ecf20Sopenharmony_ci } else { 32198c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) tempbx = 3; 32208c2ecf20Sopenharmony_ci else tempbx = 4; 32218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; 32228c2ecf20Sopenharmony_ci } 32238c2ecf20Sopenharmony_ci 32248c2ecf20Sopenharmony_ci } 32258c2ecf20Sopenharmony_ci 32268c2ecf20Sopenharmony_ci tempal &= 0x3F; 32278c2ecf20Sopenharmony_ci 32288c2ecf20Sopenharmony_ci if(ModeNo > 0x13) { 32298c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) { 32308c2ecf20Sopenharmony_ci switch(resinfo) { 32318c2ecf20Sopenharmony_ci case SIS_RI_720x480: 32328c2ecf20Sopenharmony_ci tempal = 6; 32338c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetPALN)) tempal = 9; 32348c2ecf20Sopenharmony_ci break; 32358c2ecf20Sopenharmony_ci case SIS_RI_720x576: 32368c2ecf20Sopenharmony_ci case SIS_RI_768x576: 32378c2ecf20Sopenharmony_ci case SIS_RI_1024x576: /* Not in NTSC or YPBPR mode (except 1080i)! */ 32388c2ecf20Sopenharmony_ci tempal = 6; 32398c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 32408c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempal = 8; 32418c2ecf20Sopenharmony_ci } 32428c2ecf20Sopenharmony_ci break; 32438c2ecf20Sopenharmony_ci case SIS_RI_800x480: 32448c2ecf20Sopenharmony_ci tempal = 4; 32458c2ecf20Sopenharmony_ci break; 32468c2ecf20Sopenharmony_ci case SIS_RI_512x384: 32478c2ecf20Sopenharmony_ci case SIS_RI_1024x768: 32488c2ecf20Sopenharmony_ci tempal = 7; 32498c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 32508c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempal = 8; 32518c2ecf20Sopenharmony_ci } 32528c2ecf20Sopenharmony_ci break; 32538c2ecf20Sopenharmony_ci case SIS_RI_1280x720: 32548c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 32558c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempal = 9; 32568c2ecf20Sopenharmony_ci } 32578c2ecf20Sopenharmony_ci break; 32588c2ecf20Sopenharmony_ci } 32598c2ecf20Sopenharmony_ci } 32608c2ecf20Sopenharmony_ci } 32618c2ecf20Sopenharmony_ci 32628c2ecf20Sopenharmony_ci *CRT2Index = tempbx; 32638c2ecf20Sopenharmony_ci *ResIndex = tempal; 32648c2ecf20Sopenharmony_ci 32658c2ecf20Sopenharmony_ci } else { /* LVDS, 301B-DH (if running on LCD) */ 32668c2ecf20Sopenharmony_ci 32678c2ecf20Sopenharmony_ci tempbx = 0; 32688c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { 32698c2ecf20Sopenharmony_ci 32708c2ecf20Sopenharmony_ci tempbx = 90; 32718c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) { 32728c2ecf20Sopenharmony_ci tempbx = 92; 32738c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType > ModeVGA) { 32748c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; 32758c2ecf20Sopenharmony_ci } 32768c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPALM) tempbx = 94; 32778c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetPALN) tempbx = 96; 32788c2ecf20Sopenharmony_ci } 32798c2ecf20Sopenharmony_ci if(tempbx != 99) { 32808c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx++; 32818c2ecf20Sopenharmony_ci } 32828c2ecf20Sopenharmony_ci 32838c2ecf20Sopenharmony_ci } else { 32848c2ecf20Sopenharmony_ci 32858c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 32868c2ecf20Sopenharmony_ci case Panel_640x480: tempbx = 12; break; 32878c2ecf20Sopenharmony_ci case Panel_320x240_1: tempbx = 10; break; 32888c2ecf20Sopenharmony_ci case Panel_320x240_2: 32898c2ecf20Sopenharmony_ci case Panel_320x240_3: tempbx = 14; break; 32908c2ecf20Sopenharmony_ci case Panel_800x600: tempbx = 16; break; 32918c2ecf20Sopenharmony_ci case Panel_1024x600: tempbx = 18; break; 32928c2ecf20Sopenharmony_ci case Panel_1152x768: 32938c2ecf20Sopenharmony_ci case Panel_1024x768: tempbx = 20; break; 32948c2ecf20Sopenharmony_ci case Panel_1280x768: tempbx = 22; break; 32958c2ecf20Sopenharmony_ci case Panel_1280x1024: tempbx = 24; break; 32968c2ecf20Sopenharmony_ci case Panel_1400x1050: tempbx = 26; break; 32978c2ecf20Sopenharmony_ci case Panel_1600x1200: tempbx = 28; break; 32988c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 32998c2ecf20Sopenharmony_ci case Panel_Barco1366: tempbx = 80; break; 33008c2ecf20Sopenharmony_ci#endif 33018c2ecf20Sopenharmony_ci } 33028c2ecf20Sopenharmony_ci 33038c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 33048c2ecf20Sopenharmony_ci case Panel_320x240_1: 33058c2ecf20Sopenharmony_ci case Panel_320x240_2: 33068c2ecf20Sopenharmony_ci case Panel_320x240_3: 33078c2ecf20Sopenharmony_ci case Panel_640x480: 33088c2ecf20Sopenharmony_ci break; 33098c2ecf20Sopenharmony_ci default: 33108c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; 33118c2ecf20Sopenharmony_ci } 33128c2ecf20Sopenharmony_ci 33138c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempbx = 30; 33148c2ecf20Sopenharmony_ci 33158c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 33168c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { 33178c2ecf20Sopenharmony_ci tempbx = 82; 33188c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; 33198c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) { 33208c2ecf20Sopenharmony_ci tempbx = 84; 33218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; 33228c2ecf20Sopenharmony_ci } 33238c2ecf20Sopenharmony_ci#endif 33248c2ecf20Sopenharmony_ci 33258c2ecf20Sopenharmony_ci } 33268c2ecf20Sopenharmony_ci 33278c2ecf20Sopenharmony_ci (*CRT2Index) = tempbx; 33288c2ecf20Sopenharmony_ci (*ResIndex) = tempal & 0x1F; 33298c2ecf20Sopenharmony_ci } 33308c2ecf20Sopenharmony_ci} 33318c2ecf20Sopenharmony_ci 33328c2ecf20Sopenharmony_cistatic void 33338c2ecf20Sopenharmony_ciSiS_GetRAMDAC2DATA(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 33348c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 33358c2ecf20Sopenharmony_ci{ 33368c2ecf20Sopenharmony_ci unsigned short tempax=0, tempbx=0, index, dotclock; 33378c2ecf20Sopenharmony_ci unsigned short temp1=0, modeflag=0, tempcx=0; 33388c2ecf20Sopenharmony_ci 33398c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCMAX = 1; 33408c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCFACT = 1; 33418c2ecf20Sopenharmony_ci 33428c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 33438c2ecf20Sopenharmony_ci 33448c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 33458c2ecf20Sopenharmony_ci index = SiS_GetModePtr(SiS_Pr,ModeNo,ModeIdIndex); 33468c2ecf20Sopenharmony_ci 33478c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_StandTable[index].CRTC[0]; 33488c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_StandTable[index].CRTC[6]; 33498c2ecf20Sopenharmony_ci temp1 = SiS_Pr->SiS_StandTable[index].CRTC[7]; 33508c2ecf20Sopenharmony_ci 33518c2ecf20Sopenharmony_ci dotclock = (modeflag & Charx8Dot) ? 8 : 9; 33528c2ecf20Sopenharmony_ci 33538c2ecf20Sopenharmony_ci } else { 33548c2ecf20Sopenharmony_ci 33558c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 33568c2ecf20Sopenharmony_ci index = SiS_GetRefCRT1CRTC(SiS_Pr, RefreshRateTableIndex, SiS_Pr->SiS_UseWideCRT2); 33578c2ecf20Sopenharmony_ci 33588c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_CRT1Table[index].CR[0]; 33598c2ecf20Sopenharmony_ci tempax |= (SiS_Pr->SiS_CRT1Table[index].CR[14] << 8); 33608c2ecf20Sopenharmony_ci tempax &= 0x03FF; 33618c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_CRT1Table[index].CR[6]; 33628c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_CRT1Table[index].CR[13] << 8; 33638c2ecf20Sopenharmony_ci tempcx &= 0x0100; 33648c2ecf20Sopenharmony_ci tempcx <<= 2; 33658c2ecf20Sopenharmony_ci tempbx |= tempcx; 33668c2ecf20Sopenharmony_ci temp1 = SiS_Pr->SiS_CRT1Table[index].CR[7]; 33678c2ecf20Sopenharmony_ci 33688c2ecf20Sopenharmony_ci dotclock = 8; 33698c2ecf20Sopenharmony_ci 33708c2ecf20Sopenharmony_ci } 33718c2ecf20Sopenharmony_ci 33728c2ecf20Sopenharmony_ci if(temp1 & 0x01) tempbx |= 0x0100; 33738c2ecf20Sopenharmony_ci if(temp1 & 0x20) tempbx |= 0x0200; 33748c2ecf20Sopenharmony_ci 33758c2ecf20Sopenharmony_ci tempax += 5; 33768c2ecf20Sopenharmony_ci tempax *= dotclock; 33778c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempax <<= 1; 33788c2ecf20Sopenharmony_ci 33798c2ecf20Sopenharmony_ci tempbx++; 33808c2ecf20Sopenharmony_ci 33818c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; 33828c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = tempbx; 33838c2ecf20Sopenharmony_ci} 33848c2ecf20Sopenharmony_ci 33858c2ecf20Sopenharmony_cistatic void 33868c2ecf20Sopenharmony_ciSiS_CalcPanelLinkTiming(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 33878c2ecf20Sopenharmony_ci unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex) 33888c2ecf20Sopenharmony_ci{ 33898c2ecf20Sopenharmony_ci unsigned short ResIndex; 33908c2ecf20Sopenharmony_ci 33918c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 33928c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDPass11) { 33938c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 33948c2ecf20Sopenharmony_ci ResIndex = SiS_Pr->CHTotal; 33958c2ecf20Sopenharmony_ci if(SiS_Pr->CModeFlag & HalfDCLK) ResIndex <<= 1; 33968c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = ResIndex; 33978c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal; 33988c2ecf20Sopenharmony_ci } else { 33998c2ecf20Sopenharmony_ci if(ModeNo < 0x13) { 34008c2ecf20Sopenharmony_ci ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 34018c2ecf20Sopenharmony_ci } else { 34028c2ecf20Sopenharmony_ci ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS; 34038c2ecf20Sopenharmony_ci } 34048c2ecf20Sopenharmony_ci if(ResIndex == 0x09) { 34058c2ecf20Sopenharmony_ci if(SiS_Pr->Alternate1600x1200) ResIndex = 0x20; /* 1600x1200 LCDA */ 34068c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) ResIndex = 0x21; /* 1600x1200 LVDS */ 34078c2ecf20Sopenharmony_ci } 34088c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAHT; 34098c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAVT; 34108c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDHT; 34118c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDVT; 34128c2ecf20Sopenharmony_ci } 34138c2ecf20Sopenharmony_ci } else { 34148c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->PanelHT; 34158c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->PanelVT; 34168c2ecf20Sopenharmony_ci } 34178c2ecf20Sopenharmony_ci } else { 34188c2ecf20Sopenharmony_ci /* This handles custom modes and custom panels */ 34198c2ecf20Sopenharmony_ci SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; 34208c2ecf20Sopenharmony_ci SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; 34218c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = SiS_Pr->PanelHT; 34228c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = SiS_Pr->PanelVT; 34238c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT - (SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE); 34248c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT - (SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE); 34258c2ecf20Sopenharmony_ci } 34268c2ecf20Sopenharmony_ci} 34278c2ecf20Sopenharmony_ci 34288c2ecf20Sopenharmony_cistatic void 34298c2ecf20Sopenharmony_ciSiS_GetCRT2DataLVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 34308c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 34318c2ecf20Sopenharmony_ci{ 34328c2ecf20Sopenharmony_ci unsigned short CRT2Index, ResIndex, backup; 34338c2ecf20Sopenharmony_ci const struct SiS_LVDSData *LVDSData = NULL; 34348c2ecf20Sopenharmony_ci 34358c2ecf20Sopenharmony_ci SiS_GetCRT2ResInfo(SiS_Pr, ModeNo, ModeIdIndex); 34368c2ecf20Sopenharmony_ci 34378c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 34388c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCMAX = 1; 34398c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCFACT = 1; 34408c2ecf20Sopenharmony_ci SiS_Pr->SiS_NewFlickerMode = 0; 34418c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHRS = 50; 34428c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY1COE = 0; 34438c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY2COE = 0; 34448c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY3COE = 0; 34458c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY4COE = 0; 34468c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHRS2 = 0; 34478c2ecf20Sopenharmony_ci } 34488c2ecf20Sopenharmony_ci 34498c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 34508c2ecf20Sopenharmony_ci 34518c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 34528c2ecf20Sopenharmony_ci SiS_CalcPanelLinkTiming(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 34538c2ecf20Sopenharmony_ci SiS_CalcLCDACRT1Timing(SiS_Pr, ModeNo, ModeIdIndex); 34548c2ecf20Sopenharmony_ci#endif 34558c2ecf20Sopenharmony_ci 34568c2ecf20Sopenharmony_ci } else { 34578c2ecf20Sopenharmony_ci 34588c2ecf20Sopenharmony_ci /* 301BDH needs LVDS Data */ 34598c2ecf20Sopenharmony_ci backup = SiS_Pr->SiS_IF_DEF_LVDS; 34608c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { 34618c2ecf20Sopenharmony_ci SiS_Pr->SiS_IF_DEF_LVDS = 1; 34628c2ecf20Sopenharmony_ci } 34638c2ecf20Sopenharmony_ci 34648c2ecf20Sopenharmony_ci SiS_GetCRT2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, 34658c2ecf20Sopenharmony_ci &CRT2Index, &ResIndex); 34668c2ecf20Sopenharmony_ci 34678c2ecf20Sopenharmony_ci SiS_Pr->SiS_IF_DEF_LVDS = backup; 34688c2ecf20Sopenharmony_ci 34698c2ecf20Sopenharmony_ci switch(CRT2Index) { 34708c2ecf20Sopenharmony_ci case 10: LVDSData = SiS_Pr->SiS_LVDS320x240Data_1; break; 34718c2ecf20Sopenharmony_ci case 14: LVDSData = SiS_Pr->SiS_LVDS320x240Data_2; break; 34728c2ecf20Sopenharmony_ci case 12: LVDSData = SiS_Pr->SiS_LVDS640x480Data_1; break; 34738c2ecf20Sopenharmony_ci case 16: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break; 34748c2ecf20Sopenharmony_ci case 18: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_1; break; 34758c2ecf20Sopenharmony_ci case 20: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; 34768c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 34778c2ecf20Sopenharmony_ci case 80: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_1; break; 34788c2ecf20Sopenharmony_ci case 81: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_2; break; 34798c2ecf20Sopenharmony_ci case 82: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_1; break; 34808c2ecf20Sopenharmony_ci case 84: LVDSData = SiS_Pr->SiS_LVDS848x480Data_1; break; 34818c2ecf20Sopenharmony_ci case 85: LVDSData = SiS_Pr->SiS_LVDS848x480Data_2; break; 34828c2ecf20Sopenharmony_ci#endif 34838c2ecf20Sopenharmony_ci case 90: LVDSData = SiS_Pr->SiS_CHTVUNTSCData; break; 34848c2ecf20Sopenharmony_ci case 91: LVDSData = SiS_Pr->SiS_CHTVONTSCData; break; 34858c2ecf20Sopenharmony_ci case 92: LVDSData = SiS_Pr->SiS_CHTVUPALData; break; 34868c2ecf20Sopenharmony_ci case 93: LVDSData = SiS_Pr->SiS_CHTVOPALData; break; 34878c2ecf20Sopenharmony_ci case 94: LVDSData = SiS_Pr->SiS_CHTVUPALMData; break; 34888c2ecf20Sopenharmony_ci case 95: LVDSData = SiS_Pr->SiS_CHTVOPALMData; break; 34898c2ecf20Sopenharmony_ci case 96: LVDSData = SiS_Pr->SiS_CHTVUPALNData; break; 34908c2ecf20Sopenharmony_ci case 97: LVDSData = SiS_Pr->SiS_CHTVOPALNData; break; 34918c2ecf20Sopenharmony_ci case 99: LVDSData = SiS_Pr->SiS_CHTVSOPALData; break; 34928c2ecf20Sopenharmony_ci } 34938c2ecf20Sopenharmony_ci 34948c2ecf20Sopenharmony_ci if(LVDSData) { 34958c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = (LVDSData+ResIndex)->VGAHT; 34968c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = (LVDSData+ResIndex)->VGAVT; 34978c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = (LVDSData+ResIndex)->LCDHT; 34988c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = (LVDSData+ResIndex)->LCDVT; 34998c2ecf20Sopenharmony_ci } else { 35008c2ecf20Sopenharmony_ci SiS_CalcPanelLinkTiming(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 35018c2ecf20Sopenharmony_ci } 35028c2ecf20Sopenharmony_ci 35038c2ecf20Sopenharmony_ci if( (!(SiS_Pr->SiS_VBType & VB_SISVB)) && 35048c2ecf20Sopenharmony_ci (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && 35058c2ecf20Sopenharmony_ci (!(SiS_Pr->SiS_LCDInfo & LCDPass11)) ) { 35068c2ecf20Sopenharmony_ci if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || 35078c2ecf20Sopenharmony_ci (SiS_Pr->SiS_SetFlag & SetDOSMode) ) { 35088c2ecf20Sopenharmony_ci SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; 35098c2ecf20Sopenharmony_ci SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; 35108c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 35118c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { 35128c2ecf20Sopenharmony_ci if(ResIndex < 0x08) { 35138c2ecf20Sopenharmony_ci SiS_Pr->SiS_HDE = 1280; 35148c2ecf20Sopenharmony_ci SiS_Pr->SiS_VDE = 1024; 35158c2ecf20Sopenharmony_ci } 35168c2ecf20Sopenharmony_ci } 35178c2ecf20Sopenharmony_ci#endif 35188c2ecf20Sopenharmony_ci } 35198c2ecf20Sopenharmony_ci } 35208c2ecf20Sopenharmony_ci } 35218c2ecf20Sopenharmony_ci} 35228c2ecf20Sopenharmony_ci 35238c2ecf20Sopenharmony_cistatic void 35248c2ecf20Sopenharmony_ciSiS_GetCRT2Data301(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 35258c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 35268c2ecf20Sopenharmony_ci{ 35278c2ecf20Sopenharmony_ci unsigned char *ROMAddr = NULL; 35288c2ecf20Sopenharmony_ci unsigned short tempax, tempbx, modeflag, romptr=0; 35298c2ecf20Sopenharmony_ci unsigned short resinfo, CRT2Index, ResIndex; 35308c2ecf20Sopenharmony_ci const struct SiS_LCDData *LCDPtr = NULL; 35318c2ecf20Sopenharmony_ci const struct SiS_TVData *TVPtr = NULL; 35328c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 35338c2ecf20Sopenharmony_ci short resinfo661; 35348c2ecf20Sopenharmony_ci#endif 35358c2ecf20Sopenharmony_ci 35368c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 35378c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 35388c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; 35398c2ecf20Sopenharmony_ci } else if(SiS_Pr->UseCustomMode) { 35408c2ecf20Sopenharmony_ci modeflag = SiS_Pr->CModeFlag; 35418c2ecf20Sopenharmony_ci resinfo = 0; 35428c2ecf20Sopenharmony_ci } else { 35438c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 35448c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 35458c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 35468c2ecf20Sopenharmony_ci resinfo661 = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].ROMMODEIDX661; 35478c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && 35488c2ecf20Sopenharmony_ci (SiS_Pr->SiS_SetFlag & LCDVESATiming) && 35498c2ecf20Sopenharmony_ci (resinfo661 >= 0) && 35508c2ecf20Sopenharmony_ci (SiS_Pr->SiS_NeedRomModeData) ) { 35518c2ecf20Sopenharmony_ci if((ROMAddr = GetLCDStructPtr661(SiS_Pr))) { 35528c2ecf20Sopenharmony_ci if((romptr = (SISGETROMW(21)))) { 35538c2ecf20Sopenharmony_ci romptr += (resinfo661 * 10); 35548c2ecf20Sopenharmony_ci ROMAddr = SiS_Pr->VirtualRomBase; 35558c2ecf20Sopenharmony_ci } 35568c2ecf20Sopenharmony_ci } 35578c2ecf20Sopenharmony_ci } 35588c2ecf20Sopenharmony_ci#endif 35598c2ecf20Sopenharmony_ci } 35608c2ecf20Sopenharmony_ci 35618c2ecf20Sopenharmony_ci SiS_Pr->SiS_NewFlickerMode = 0; 35628c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHRS = 50; 35638c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY1COE = 0; 35648c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY2COE = 0; 35658c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY3COE = 0; 35668c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY4COE = 0; 35678c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHRS2 = 0; 35688c2ecf20Sopenharmony_ci 35698c2ecf20Sopenharmony_ci SiS_GetCRT2ResInfo(SiS_Pr,ModeNo,ModeIdIndex); 35708c2ecf20Sopenharmony_ci 35718c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { 35728c2ecf20Sopenharmony_ci 35738c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 35748c2ecf20Sopenharmony_ci 35758c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCMAX = 1; 35768c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCFACT = 1; 35778c2ecf20Sopenharmony_ci SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE; 35788c2ecf20Sopenharmony_ci SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; 35798c2ecf20Sopenharmony_ci 35808c2ecf20Sopenharmony_ci tempax = SiS_Pr->CHTotal; 35818c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempax <<= 1; 35828c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; 35838c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal; 35848c2ecf20Sopenharmony_ci 35858c2ecf20Sopenharmony_ci } else { 35868c2ecf20Sopenharmony_ci 35878c2ecf20Sopenharmony_ci SiS_GetRAMDAC2DATA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 35888c2ecf20Sopenharmony_ci 35898c2ecf20Sopenharmony_ci } 35908c2ecf20Sopenharmony_ci 35918c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 35928c2ecf20Sopenharmony_ci 35938c2ecf20Sopenharmony_ci SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, 35948c2ecf20Sopenharmony_ci &CRT2Index,&ResIndex); 35958c2ecf20Sopenharmony_ci 35968c2ecf20Sopenharmony_ci switch(CRT2Index) { 35978c2ecf20Sopenharmony_ci case 2: TVPtr = SiS_Pr->SiS_ExtHiTVData; break; 35988c2ecf20Sopenharmony_ci case 3: TVPtr = SiS_Pr->SiS_ExtPALData; break; 35998c2ecf20Sopenharmony_ci case 4: TVPtr = SiS_Pr->SiS_ExtNTSCData; break; 36008c2ecf20Sopenharmony_ci case 5: TVPtr = SiS_Pr->SiS_Ext525iData; break; 36018c2ecf20Sopenharmony_ci case 6: TVPtr = SiS_Pr->SiS_Ext525pData; break; 36028c2ecf20Sopenharmony_ci case 7: TVPtr = SiS_Pr->SiS_Ext750pData; break; 36038c2ecf20Sopenharmony_ci case 8: TVPtr = SiS_Pr->SiS_StPALData; break; 36048c2ecf20Sopenharmony_ci case 9: TVPtr = SiS_Pr->SiS_StNTSCData; break; 36058c2ecf20Sopenharmony_ci case 10: TVPtr = SiS_Pr->SiS_St525iData; break; 36068c2ecf20Sopenharmony_ci case 11: TVPtr = SiS_Pr->SiS_St525pData; break; 36078c2ecf20Sopenharmony_ci case 12: TVPtr = SiS_Pr->SiS_St750pData; break; 36088c2ecf20Sopenharmony_ci case 13: TVPtr = SiS_Pr->SiS_St1HiTVData; break; 36098c2ecf20Sopenharmony_ci case 14: TVPtr = SiS_Pr->SiS_St2HiTVData; break; 36108c2ecf20Sopenharmony_ci default: TVPtr = SiS_Pr->SiS_StPALData; break; 36118c2ecf20Sopenharmony_ci } 36128c2ecf20Sopenharmony_ci 36138c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCMAX = (TVPtr+ResIndex)->RVBHCMAX; 36148c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCFACT = (TVPtr+ResIndex)->RVBHCFACT; 36158c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = (TVPtr+ResIndex)->VGAHT; 36168c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = (TVPtr+ResIndex)->VGAVT; 36178c2ecf20Sopenharmony_ci SiS_Pr->SiS_HDE = (TVPtr+ResIndex)->TVHDE; 36188c2ecf20Sopenharmony_ci SiS_Pr->SiS_VDE = (TVPtr+ResIndex)->TVVDE; 36198c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHRS2 = (TVPtr+ResIndex)->RVBHRS2 & 0x0fff; 36208c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) { 36218c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->HALFRVBHRS; 36228c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_RVBHRS2) { 36238c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHRS2 = ((SiS_Pr->SiS_RVBHRS2 + 3) >> 1) - 3; 36248c2ecf20Sopenharmony_ci tempax = ((TVPtr+ResIndex)->RVBHRS2 >> 12) & 0x07; 36258c2ecf20Sopenharmony_ci if((TVPtr+ResIndex)->RVBHRS2 & 0x8000) SiS_Pr->SiS_RVBHRS2 -= tempax; 36268c2ecf20Sopenharmony_ci else SiS_Pr->SiS_RVBHRS2 += tempax; 36278c2ecf20Sopenharmony_ci } 36288c2ecf20Sopenharmony_ci } else { 36298c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->RVBHRS; 36308c2ecf20Sopenharmony_ci } 36318c2ecf20Sopenharmony_ci SiS_Pr->SiS_NewFlickerMode = ((TVPtr+ResIndex)->FlickerMode) << 7; 36328c2ecf20Sopenharmony_ci 36338c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 36348c2ecf20Sopenharmony_ci 36358c2ecf20Sopenharmony_ci if((resinfo == SIS_RI_960x600) || 36368c2ecf20Sopenharmony_ci (resinfo == SIS_RI_1024x768) || 36378c2ecf20Sopenharmony_ci (resinfo == SIS_RI_1280x1024) || 36388c2ecf20Sopenharmony_ci (resinfo == SIS_RI_1280x720)) { 36398c2ecf20Sopenharmony_ci SiS_Pr->SiS_NewFlickerMode = 0x40; 36408c2ecf20Sopenharmony_ci } 36418c2ecf20Sopenharmony_ci 36428c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE == 350) SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; 36438c2ecf20Sopenharmony_ci 36448c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = ExtHiTVHT; 36458c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = ExtHiTVVT; 36468c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 36478c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { 36488c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = StHiTVHT; 36498c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = StHiTVVT; 36508c2ecf20Sopenharmony_ci } 36518c2ecf20Sopenharmony_ci } 36528c2ecf20Sopenharmony_ci 36538c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 36548c2ecf20Sopenharmony_ci 36558c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { 36568c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = 1650; 36578c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = 750; 36588c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { 36598c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = NTSCHT; 36608c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSet525p1024) SiS_Pr->SiS_HT = NTSC2HT; 36618c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = NTSCVT; 36628c2ecf20Sopenharmony_ci } else { 36638c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = NTSCHT; 36648c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT; 36658c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = NTSCVT; 36668c2ecf20Sopenharmony_ci } 36678c2ecf20Sopenharmony_ci 36688c2ecf20Sopenharmony_ci } else { 36698c2ecf20Sopenharmony_ci 36708c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY1COE = (TVPtr+ResIndex)->RY1COE; 36718c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY2COE = (TVPtr+ResIndex)->RY2COE; 36728c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY3COE = (TVPtr+ResIndex)->RY3COE; 36738c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY4COE = (TVPtr+ResIndex)->RY4COE; 36748c2ecf20Sopenharmony_ci 36758c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) { 36768c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY1COE = 0x00; 36778c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY2COE = 0xf4; 36788c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY3COE = 0x10; 36798c2ecf20Sopenharmony_ci SiS_Pr->SiS_RY4COE = 0x38; 36808c2ecf20Sopenharmony_ci } 36818c2ecf20Sopenharmony_ci 36828c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { 36838c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = NTSCHT; 36848c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT; 36858c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = NTSCVT; 36868c2ecf20Sopenharmony_ci } else { 36878c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = PALHT; 36888c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = PALVT; 36898c2ecf20Sopenharmony_ci } 36908c2ecf20Sopenharmony_ci 36918c2ecf20Sopenharmony_ci } 36928c2ecf20Sopenharmony_ci 36938c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 36948c2ecf20Sopenharmony_ci 36958c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCMAX = 1; 36968c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCFACT = 1; 36978c2ecf20Sopenharmony_ci 36988c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 36998c2ecf20Sopenharmony_ci 37008c2ecf20Sopenharmony_ci SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE; 37018c2ecf20Sopenharmony_ci SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; 37028c2ecf20Sopenharmony_ci 37038c2ecf20Sopenharmony_ci tempax = SiS_Pr->CHTotal; 37048c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempax <<= 1; 37058c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; 37068c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal; 37078c2ecf20Sopenharmony_ci 37088c2ecf20Sopenharmony_ci } else { 37098c2ecf20Sopenharmony_ci 37108c2ecf20Sopenharmony_ci bool gotit = false; 37118c2ecf20Sopenharmony_ci 37128c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { 37138c2ecf20Sopenharmony_ci 37148c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT; 37158c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; 37168c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = SiS_Pr->PanelHT; 37178c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = SiS_Pr->PanelVT; 37188c2ecf20Sopenharmony_ci gotit = true; 37198c2ecf20Sopenharmony_ci 37208c2ecf20Sopenharmony_ci } else if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) && (romptr) && (ROMAddr) ) { 37218c2ecf20Sopenharmony_ci 37228c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 37238c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCMAX = ROMAddr[romptr]; 37248c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCFACT = ROMAddr[romptr+1]; 37258c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = ROMAddr[romptr+2] | ((ROMAddr[romptr+3] & 0x0f) << 8); 37268c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = (ROMAddr[romptr+4] << 4) | ((ROMAddr[romptr+3] & 0xf0) >> 4); 37278c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = ROMAddr[romptr+5] | ((ROMAddr[romptr+6] & 0x0f) << 8); 37288c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = (ROMAddr[romptr+7] << 4) | ((ROMAddr[romptr+6] & 0xf0) >> 4); 37298c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHRS2 = ROMAddr[romptr+8] | ((ROMAddr[romptr+9] & 0x0f) << 8); 37308c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_RVBHRS2) && (modeflag & HalfDCLK)) { 37318c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHRS2 = ((SiS_Pr->SiS_RVBHRS2 + 3) >> 1) - 3; 37328c2ecf20Sopenharmony_ci tempax = (ROMAddr[romptr+9] >> 4) & 0x07; 37338c2ecf20Sopenharmony_ci if(ROMAddr[romptr+9] & 0x80) SiS_Pr->SiS_RVBHRS2 -= tempax; 37348c2ecf20Sopenharmony_ci else SiS_Pr->SiS_RVBHRS2 += tempax; 37358c2ecf20Sopenharmony_ci } 37368c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAHT) gotit = true; 37378c2ecf20Sopenharmony_ci else { 37388c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 37398c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDInfo &= ~LCDPass11; 37408c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCMAX = 1; 37418c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCFACT = 1; 37428c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT; 37438c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; 37448c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = SiS_Pr->PanelHT; 37458c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = SiS_Pr->PanelVT; 37468c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHRS2 = 0; 37478c2ecf20Sopenharmony_ci gotit = true; 37488c2ecf20Sopenharmony_ci } 37498c2ecf20Sopenharmony_ci#endif 37508c2ecf20Sopenharmony_ci 37518c2ecf20Sopenharmony_ci } 37528c2ecf20Sopenharmony_ci 37538c2ecf20Sopenharmony_ci if(!gotit) { 37548c2ecf20Sopenharmony_ci 37558c2ecf20Sopenharmony_ci SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, 37568c2ecf20Sopenharmony_ci &CRT2Index,&ResIndex); 37578c2ecf20Sopenharmony_ci 37588c2ecf20Sopenharmony_ci switch(CRT2Index) { 37598c2ecf20Sopenharmony_ci case Panel_1024x768 : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; 37608c2ecf20Sopenharmony_ci case Panel_1024x768 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1024x768Data; break; 37618c2ecf20Sopenharmony_ci case Panel_1280x720 : 37628c2ecf20Sopenharmony_ci case Panel_1280x720 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x720Data; break; 37638c2ecf20Sopenharmony_ci case Panel_1280x768_2 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x768_2Data; break; 37648c2ecf20Sopenharmony_ci case Panel_1280x768_2+ 32: LCDPtr = SiS_Pr->SiS_StLCD1280x768_2Data; break; 37658c2ecf20Sopenharmony_ci case Panel_1280x800 : 37668c2ecf20Sopenharmony_ci case Panel_1280x800 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x800Data; break; 37678c2ecf20Sopenharmony_ci case Panel_1280x800_2 : 37688c2ecf20Sopenharmony_ci case Panel_1280x800_2+ 32: LCDPtr = SiS_Pr->SiS_LCD1280x800_2Data; break; 37698c2ecf20Sopenharmony_ci case Panel_1280x854 : 37708c2ecf20Sopenharmony_ci case Panel_1280x854 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x854Data; break; 37718c2ecf20Sopenharmony_ci case Panel_1280x960 : 37728c2ecf20Sopenharmony_ci case Panel_1280x960 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x960Data; break; 37738c2ecf20Sopenharmony_ci case Panel_1280x1024 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data; break; 37748c2ecf20Sopenharmony_ci case Panel_1280x1024 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; 37758c2ecf20Sopenharmony_ci case Panel_1400x1050 : LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data; break; 37768c2ecf20Sopenharmony_ci case Panel_1400x1050 + 32: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break; 37778c2ecf20Sopenharmony_ci case Panel_1600x1200 : LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break; 37788c2ecf20Sopenharmony_ci case Panel_1600x1200 + 32: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break; 37798c2ecf20Sopenharmony_ci case Panel_1680x1050 : 37808c2ecf20Sopenharmony_ci case Panel_1680x1050 + 32: LCDPtr = SiS_Pr->SiS_LCD1680x1050Data; break; 37818c2ecf20Sopenharmony_ci case 100 : LCDPtr = SiS_Pr->SiS_NoScaleData; break; 37828c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 37838c2ecf20Sopenharmony_ci case 200 : LCDPtr = SiS310_ExtCompaq1280x1024Data; break; 37848c2ecf20Sopenharmony_ci case 201 : LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; 37858c2ecf20Sopenharmony_ci#endif 37868c2ecf20Sopenharmony_ci default : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; 37878c2ecf20Sopenharmony_ci } 37888c2ecf20Sopenharmony_ci 37898c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX; 37908c2ecf20Sopenharmony_ci SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT; 37918c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT; 37928c2ecf20Sopenharmony_ci SiS_Pr->SiS_VGAVT = (LCDPtr+ResIndex)->VGAVT; 37938c2ecf20Sopenharmony_ci SiS_Pr->SiS_HT = (LCDPtr+ResIndex)->LCDHT; 37948c2ecf20Sopenharmony_ci SiS_Pr->SiS_VT = (LCDPtr+ResIndex)->LCDVT; 37958c2ecf20Sopenharmony_ci 37968c2ecf20Sopenharmony_ci } 37978c2ecf20Sopenharmony_ci 37988c2ecf20Sopenharmony_ci tempax = SiS_Pr->PanelXRes; 37998c2ecf20Sopenharmony_ci tempbx = SiS_Pr->PanelYRes; 38008c2ecf20Sopenharmony_ci 38018c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 38028c2ecf20Sopenharmony_ci case Panel_1024x768: 38038c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { 38048c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 38058c2ecf20Sopenharmony_ci if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; 38068c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; 38078c2ecf20Sopenharmony_ci } 38088c2ecf20Sopenharmony_ci } else { 38098c2ecf20Sopenharmony_ci if (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527; 38108c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620; 38118c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775; 38128c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775; 38138c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; 38148c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; 38158c2ecf20Sopenharmony_ci } 38168c2ecf20Sopenharmony_ci break; 38178c2ecf20Sopenharmony_ci case Panel_1280x960: 38188c2ecf20Sopenharmony_ci if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 700; 38198c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 800; 38208c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960; 38218c2ecf20Sopenharmony_ci break; 38228c2ecf20Sopenharmony_ci case Panel_1280x1024: 38238c2ecf20Sopenharmony_ci if (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768; 38248c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800; 38258c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864; 38268c2ecf20Sopenharmony_ci break; 38278c2ecf20Sopenharmony_ci case Panel_1600x1200: 38288c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { 38298c2ecf20Sopenharmony_ci if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 875; 38308c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 1000; 38318c2ecf20Sopenharmony_ci } 38328c2ecf20Sopenharmony_ci break; 38338c2ecf20Sopenharmony_ci } 38348c2ecf20Sopenharmony_ci 38358c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 38368c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_VGAHDE; 38378c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_VGAVDE; 38388c2ecf20Sopenharmony_ci } 38398c2ecf20Sopenharmony_ci 38408c2ecf20Sopenharmony_ci SiS_Pr->SiS_HDE = tempax; 38418c2ecf20Sopenharmony_ci SiS_Pr->SiS_VDE = tempbx; 38428c2ecf20Sopenharmony_ci } 38438c2ecf20Sopenharmony_ci } 38448c2ecf20Sopenharmony_ci} 38458c2ecf20Sopenharmony_ci 38468c2ecf20Sopenharmony_cistatic void 38478c2ecf20Sopenharmony_ciSiS_GetCRT2Data(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 38488c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 38498c2ecf20Sopenharmony_ci{ 38508c2ecf20Sopenharmony_ci 38518c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 38528c2ecf20Sopenharmony_ci 38538c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 38548c2ecf20Sopenharmony_ci SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 38558c2ecf20Sopenharmony_ci } else { 38568c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { 38578c2ecf20Sopenharmony_ci /* Need LVDS Data for LCD on 301B-DH */ 38588c2ecf20Sopenharmony_ci SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 38598c2ecf20Sopenharmony_ci } else { 38608c2ecf20Sopenharmony_ci SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 38618c2ecf20Sopenharmony_ci } 38628c2ecf20Sopenharmony_ci } 38638c2ecf20Sopenharmony_ci 38648c2ecf20Sopenharmony_ci } else { 38658c2ecf20Sopenharmony_ci 38668c2ecf20Sopenharmony_ci SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 38678c2ecf20Sopenharmony_ci 38688c2ecf20Sopenharmony_ci } 38698c2ecf20Sopenharmony_ci} 38708c2ecf20Sopenharmony_ci 38718c2ecf20Sopenharmony_ci/*********************************************/ 38728c2ecf20Sopenharmony_ci/* GET LVDS DES (SKEW) DATA */ 38738c2ecf20Sopenharmony_ci/*********************************************/ 38748c2ecf20Sopenharmony_ci 38758c2ecf20Sopenharmony_cistatic const struct SiS_LVDSDes * 38768c2ecf20Sopenharmony_ciSiS_GetLVDSDesPtr(struct SiS_Private *SiS_Pr) 38778c2ecf20Sopenharmony_ci{ 38788c2ecf20Sopenharmony_ci const struct SiS_LVDSDes *PanelDesPtr = NULL; 38798c2ecf20Sopenharmony_ci 38808c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 38818c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 38828c2ecf20Sopenharmony_ci 38838c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 38848c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDTypeInfo == 4) { 38858c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { 38868c2ecf20Sopenharmony_ci PanelDesPtr = SiS_Pr->SiS_PanelType04_1a; 38878c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 38888c2ecf20Sopenharmony_ci PanelDesPtr = SiS_Pr->SiS_PanelType04_2a; 38898c2ecf20Sopenharmony_ci } 38908c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { 38918c2ecf20Sopenharmony_ci PanelDesPtr = SiS_Pr->SiS_PanelType04_1b; 38928c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 38938c2ecf20Sopenharmony_ci PanelDesPtr = SiS_Pr->SiS_PanelType04_2b; 38948c2ecf20Sopenharmony_ci } 38958c2ecf20Sopenharmony_ci } 38968c2ecf20Sopenharmony_ci } 38978c2ecf20Sopenharmony_ci } 38988c2ecf20Sopenharmony_ci } 38998c2ecf20Sopenharmony_ci#endif 39008c2ecf20Sopenharmony_ci return PanelDesPtr; 39018c2ecf20Sopenharmony_ci} 39028c2ecf20Sopenharmony_ci 39038c2ecf20Sopenharmony_cistatic void 39048c2ecf20Sopenharmony_ciSiS_GetLVDSDesData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 39058c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 39068c2ecf20Sopenharmony_ci{ 39078c2ecf20Sopenharmony_ci unsigned short modeflag, ResIndex; 39088c2ecf20Sopenharmony_ci const struct SiS_LVDSDes *PanelDesPtr = NULL; 39098c2ecf20Sopenharmony_ci 39108c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDHDES = 0; 39118c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = 0; 39128c2ecf20Sopenharmony_ci 39138c2ecf20Sopenharmony_ci /* Some special cases */ 39148c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 39158c2ecf20Sopenharmony_ci 39168c2ecf20Sopenharmony_ci /* Trumpion */ 39178c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_TRUMPION) { 39188c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 39198c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { 39208c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; 39218c2ecf20Sopenharmony_ci } 39228c2ecf20Sopenharmony_ci } 39238c2ecf20Sopenharmony_ci return; 39248c2ecf20Sopenharmony_ci } 39258c2ecf20Sopenharmony_ci 39268c2ecf20Sopenharmony_ci /* 640x480 on LVDS */ 39278c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 39288c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_640x480 && SiS_Pr->SiS_LCDTypeInfo == 3) { 39298c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDHDES = 8; 39308c2ecf20Sopenharmony_ci if (SiS_Pr->SiS_VGAVDE >= 480) SiS_Pr->SiS_LCDVDES = 512; 39318c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE >= 400) SiS_Pr->SiS_LCDVDES = 436; 39328c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE >= 350) SiS_Pr->SiS_LCDVDES = 440; 39338c2ecf20Sopenharmony_ci return; 39348c2ecf20Sopenharmony_ci } 39358c2ecf20Sopenharmony_ci } 39368c2ecf20Sopenharmony_ci 39378c2ecf20Sopenharmony_ci } /* LCD */ 39388c2ecf20Sopenharmony_ci 39398c2ecf20Sopenharmony_ci if( (SiS_Pr->UseCustomMode) || 39408c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_Custom) || 39418c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_PANEL848) || 39428c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_PANEL856) || 39438c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDInfo & LCDPass11) ) { 39448c2ecf20Sopenharmony_ci return; 39458c2ecf20Sopenharmony_ci } 39468c2ecf20Sopenharmony_ci 39478c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 39488c2ecf20Sopenharmony_ci else ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 39498c2ecf20Sopenharmony_ci 39508c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 39518c2ecf20Sopenharmony_ci 39528c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 39538c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 39548c2ecf20Sopenharmony_ci /* non-pass 1:1 only, see above */ 39558c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) { 39568c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2); 39578c2ecf20Sopenharmony_ci } 39588c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE != SiS_Pr->PanelYRes) { 39598c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE) / 2); 39608c2ecf20Sopenharmony_ci } 39618c2ecf20Sopenharmony_ci } 39628c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { 39638c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_CustomT) { 39648c2ecf20Sopenharmony_ci case CUT_UNIWILL1024: 39658c2ecf20Sopenharmony_ci case CUT_UNIWILL10242: 39668c2ecf20Sopenharmony_ci case CUT_CLEVO1400: 39678c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 39688c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; 39698c2ecf20Sopenharmony_ci } 39708c2ecf20Sopenharmony_ci break; 39718c2ecf20Sopenharmony_ci } 39728c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 39738c2ecf20Sopenharmony_ci case Panel_1280x1024: 39748c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) { 39758c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; 39768c2ecf20Sopenharmony_ci } 39778c2ecf20Sopenharmony_ci break; 39788c2ecf20Sopenharmony_ci case Panel_1280x800: /* Verified for Averatec 6240 */ 39798c2ecf20Sopenharmony_ci case Panel_1280x800_2: /* Verified for Asus A4L */ 39808c2ecf20Sopenharmony_ci case Panel_1280x854: /* Not verified yet FIXME */ 39818c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; 39828c2ecf20Sopenharmony_ci break; 39838c2ecf20Sopenharmony_ci } 39848c2ecf20Sopenharmony_ci } 39858c2ecf20Sopenharmony_ci#endif 39868c2ecf20Sopenharmony_ci 39878c2ecf20Sopenharmony_ci } else { 39888c2ecf20Sopenharmony_ci 39898c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { 39908c2ecf20Sopenharmony_ci 39918c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) { 39928c2ecf20Sopenharmony_ci if(ResIndex <= 3) SiS_Pr->SiS_LCDHDES = 256; 39938c2ecf20Sopenharmony_ci } 39948c2ecf20Sopenharmony_ci 39958c2ecf20Sopenharmony_ci } else if((PanelDesPtr = SiS_GetLVDSDesPtr(SiS_Pr))) { 39968c2ecf20Sopenharmony_ci 39978c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES; 39988c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = (PanelDesPtr+ResIndex)->LCDVDES; 39998c2ecf20Sopenharmony_ci 40008c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 40018c2ecf20Sopenharmony_ci 40028c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) { 40038c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2); 40048c2ecf20Sopenharmony_ci } 40058c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE != SiS_Pr->PanelYRes) { 40068c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE) / 2); 40078c2ecf20Sopenharmony_ci } else { 40088c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 40098c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; 40108c2ecf20Sopenharmony_ci } else { 40118c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 40128c2ecf20Sopenharmony_ci case Panel_800x600: 40138c2ecf20Sopenharmony_ci case Panel_1024x768: 40148c2ecf20Sopenharmony_ci case Panel_1280x1024: 40158c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT; 40168c2ecf20Sopenharmony_ci break; 40178c2ecf20Sopenharmony_ci case Panel_1400x1050: 40188c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; 40198c2ecf20Sopenharmony_ci break; 40208c2ecf20Sopenharmony_ci } 40218c2ecf20Sopenharmony_ci } 40228c2ecf20Sopenharmony_ci } 40238c2ecf20Sopenharmony_ci 40248c2ecf20Sopenharmony_ci } else { 40258c2ecf20Sopenharmony_ci 40268c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 40278c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 40288c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 40298c2ecf20Sopenharmony_ci case Panel_800x600: 40308c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { 40318c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; 40328c2ecf20Sopenharmony_ci } else { 40338c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDHDES = SiS_Pr->PanelHT + 3; 40348c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT; 40358c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE == 400) SiS_Pr->SiS_LCDVDES -= 2; 40368c2ecf20Sopenharmony_ci else SiS_Pr->SiS_LCDVDES -= 4; 40378c2ecf20Sopenharmony_ci } 40388c2ecf20Sopenharmony_ci break; 40398c2ecf20Sopenharmony_ci case Panel_1024x768: 40408c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { 40418c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; 40428c2ecf20Sopenharmony_ci } else { 40438c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDHDES = SiS_Pr->PanelHT - 1; 40448c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE <= 400) SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 8; 40458c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE <= 350) SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 12; 40468c2ecf20Sopenharmony_ci } 40478c2ecf20Sopenharmony_ci break; 40488c2ecf20Sopenharmony_ci case Panel_1024x600: 40498c2ecf20Sopenharmony_ci default: 40508c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_VGAHDE == SiS_Pr->PanelXRes) && 40518c2ecf20Sopenharmony_ci (SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) ) { 40528c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; 40538c2ecf20Sopenharmony_ci } else { 40548c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDHDES = SiS_Pr->PanelHT - 1; 40558c2ecf20Sopenharmony_ci } 40568c2ecf20Sopenharmony_ci break; 40578c2ecf20Sopenharmony_ci } 40588c2ecf20Sopenharmony_ci 40598c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDTypeInfo) { 40608c2ecf20Sopenharmony_ci case 1: 40618c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; 40628c2ecf20Sopenharmony_ci break; 40638c2ecf20Sopenharmony_ci case 3: /* 640x480 only? */ 40648c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDHDES = 8; 40658c2ecf20Sopenharmony_ci if (SiS_Pr->SiS_VGAVDE >= 480) SiS_Pr->SiS_LCDVDES = 512; 40668c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE >= 400) SiS_Pr->SiS_LCDVDES = 436; 40678c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VGAVDE >= 350) SiS_Pr->SiS_LCDVDES = 440; 40688c2ecf20Sopenharmony_ci break; 40698c2ecf20Sopenharmony_ci } 40708c2ecf20Sopenharmony_ci#endif 40718c2ecf20Sopenharmony_ci } else { 40728c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 40738c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 40748c2ecf20Sopenharmony_ci case Panel_1024x768: 40758c2ecf20Sopenharmony_ci case Panel_1280x1024: 40768c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { 40778c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; 40788c2ecf20Sopenharmony_ci } 40798c2ecf20Sopenharmony_ci break; 40808c2ecf20Sopenharmony_ci case Panel_320x240_1: 40818c2ecf20Sopenharmony_ci case Panel_320x240_2: 40828c2ecf20Sopenharmony_ci case Panel_320x240_3: 40838c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDVDES = 524; 40848c2ecf20Sopenharmony_ci break; 40858c2ecf20Sopenharmony_ci } 40868c2ecf20Sopenharmony_ci#endif 40878c2ecf20Sopenharmony_ci } 40888c2ecf20Sopenharmony_ci } 40898c2ecf20Sopenharmony_ci 40908c2ecf20Sopenharmony_ci if((ModeNo <= 0x13) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { 40918c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 40928c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 40938c2ecf20Sopenharmony_ci if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 632; 40948c2ecf20Sopenharmony_ci } else if(!(SiS_Pr->SiS_SetFlag & SetDOSMode)) { 40958c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) { 40968c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo >= Panel_1024x768) { 40978c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 40988c2ecf20Sopenharmony_ci if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 320; 40998c2ecf20Sopenharmony_ci } else { 41008c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 41018c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) SiS_Pr->SiS_LCDHDES = 480; 41028c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 804; 41038c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 704; 41048c2ecf20Sopenharmony_ci if(!(modeflag & HalfDCLK)) { 41058c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDHDES = 320; 41068c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 632; 41078c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 542; 41088c2ecf20Sopenharmony_ci } 41098c2ecf20Sopenharmony_ci#endif 41108c2ecf20Sopenharmony_ci } 41118c2ecf20Sopenharmony_ci } 41128c2ecf20Sopenharmony_ci } 41138c2ecf20Sopenharmony_ci } 41148c2ecf20Sopenharmony_ci } 41158c2ecf20Sopenharmony_ci } 41168c2ecf20Sopenharmony_ci} 41178c2ecf20Sopenharmony_ci 41188c2ecf20Sopenharmony_ci/*********************************************/ 41198c2ecf20Sopenharmony_ci/* DISABLE VIDEO BRIDGE */ 41208c2ecf20Sopenharmony_ci/*********************************************/ 41218c2ecf20Sopenharmony_ci 41228c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 41238c2ecf20Sopenharmony_cistatic int 41248c2ecf20Sopenharmony_ciSiS_HandlePWD(struct SiS_Private *SiS_Pr) 41258c2ecf20Sopenharmony_ci{ 41268c2ecf20Sopenharmony_ci int ret = 0; 41278c2ecf20Sopenharmony_ci#ifdef SET_PWD 41288c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 41298c2ecf20Sopenharmony_ci unsigned short romptr = GetLCDStructPtr661_2(SiS_Pr); 41308c2ecf20Sopenharmony_ci unsigned char drivermode = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40; 41318c2ecf20Sopenharmony_ci unsigned short temp; 41328c2ecf20Sopenharmony_ci 41338c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_VBType & VB_SISPWD) && 41348c2ecf20Sopenharmony_ci (romptr) && 41358c2ecf20Sopenharmony_ci (SiS_Pr->SiS_PWDOffset) ) { 41368c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2b,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 0]); 41378c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2c,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 1]); 41388c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2d,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 2]); 41398c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2e,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 3]); 41408c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2f,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 4]); 41418c2ecf20Sopenharmony_ci temp = 0x00; 41428c2ecf20Sopenharmony_ci if((ROMAddr[romptr + 2] & (0x06 << 1)) && !drivermode) { 41438c2ecf20Sopenharmony_ci temp = 0x80; 41448c2ecf20Sopenharmony_ci ret = 1; 41458c2ecf20Sopenharmony_ci } 41468c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x27,0x7f,temp); 41478c2ecf20Sopenharmony_ci } 41488c2ecf20Sopenharmony_ci#endif 41498c2ecf20Sopenharmony_ci return ret; 41508c2ecf20Sopenharmony_ci} 41518c2ecf20Sopenharmony_ci#endif 41528c2ecf20Sopenharmony_ci 41538c2ecf20Sopenharmony_ci/* NEVER use any variables (VBInfo), this will be called 41548c2ecf20Sopenharmony_ci * from outside the context of modeswitch! 41558c2ecf20Sopenharmony_ci * MUST call getVBType before calling this 41568c2ecf20Sopenharmony_ci */ 41578c2ecf20Sopenharmony_civoid 41588c2ecf20Sopenharmony_ciSiS_DisableBridge(struct SiS_Private *SiS_Pr) 41598c2ecf20Sopenharmony_ci{ 41608c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 41618c2ecf20Sopenharmony_ci unsigned short tempah, pushax=0, modenum; 41628c2ecf20Sopenharmony_ci#endif 41638c2ecf20Sopenharmony_ci unsigned short temp=0; 41648c2ecf20Sopenharmony_ci 41658c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 41668c2ecf20Sopenharmony_ci 41678c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* ===== For 30xB/C/LV ===== */ 41688c2ecf20Sopenharmony_ci 41698c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 41708c2ecf20Sopenharmony_ci 41718c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 /* 300 series */ 41728c2ecf20Sopenharmony_ci 41738c2ecf20Sopenharmony_ci if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { 41748c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 41758c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); 41768c2ecf20Sopenharmony_ci } else { 41778c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); 41788c2ecf20Sopenharmony_ci } 41798c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 3); 41808c2ecf20Sopenharmony_ci } 41818c2ecf20Sopenharmony_ci if(SiS_Is301B(SiS_Pr)) { 41828c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0x3f); 41838c2ecf20Sopenharmony_ci SiS_ShortDelay(SiS_Pr,1); 41848c2ecf20Sopenharmony_ci } 41858c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); 41868c2ecf20Sopenharmony_ci SiS_DisplayOff(SiS_Pr); 41878c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); 41888c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); 41898c2ecf20Sopenharmony_ci SiS_UnLockCRT2(SiS_Pr); 41908c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBType & VB_SISLVDS)) { 41918c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); 41928c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); 41938c2ecf20Sopenharmony_ci } 41948c2ecf20Sopenharmony_ci if( (!(SiS_CRT2IsLCD(SiS_Pr))) || 41958c2ecf20Sopenharmony_ci (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) { 41968c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 2); 41978c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 41988c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); 41998c2ecf20Sopenharmony_ci } else { 42008c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); 42018c2ecf20Sopenharmony_ci } 42028c2ecf20Sopenharmony_ci } 42038c2ecf20Sopenharmony_ci 42048c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_300 */ 42058c2ecf20Sopenharmony_ci 42068c2ecf20Sopenharmony_ci } else { 42078c2ecf20Sopenharmony_ci 42088c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 /* 315 series */ 42098c2ecf20Sopenharmony_ci 42108c2ecf20Sopenharmony_ci int didpwd = 0; 42118c2ecf20Sopenharmony_ci bool custom1 = (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || 42128c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_CLEVO1400); 42138c2ecf20Sopenharmony_ci 42148c2ecf20Sopenharmony_ci modenum = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34) & 0x7f; 42158c2ecf20Sopenharmony_ci 42168c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 42178c2ecf20Sopenharmony_ci 42188c2ecf20Sopenharmony_ci#ifdef SET_EMI 42198c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISEMI) { 42208c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { 42218c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); 42228c2ecf20Sopenharmony_ci } 42238c2ecf20Sopenharmony_ci } 42248c2ecf20Sopenharmony_ci#endif 42258c2ecf20Sopenharmony_ci 42268c2ecf20Sopenharmony_ci didpwd = SiS_HandlePWD(SiS_Pr); 42278c2ecf20Sopenharmony_ci 42288c2ecf20Sopenharmony_ci if( (modenum <= 0x13) || 42298c2ecf20Sopenharmony_ci (SiS_IsVAMode(SiS_Pr)) || 42308c2ecf20Sopenharmony_ci (!(SiS_IsDualEdge(SiS_Pr))) ) { 42318c2ecf20Sopenharmony_ci if(!didpwd) { 42328c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xfe); 42338c2ecf20Sopenharmony_ci if(custom1) SiS_PanelDelay(SiS_Pr, 3); 42348c2ecf20Sopenharmony_ci } else { 42358c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xfc); 42368c2ecf20Sopenharmony_ci } 42378c2ecf20Sopenharmony_ci } 42388c2ecf20Sopenharmony_ci 42398c2ecf20Sopenharmony_ci if(!custom1) { 42408c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr,0xff00); 42418c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr,0xe000); 42428c2ecf20Sopenharmony_ci SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); 42438c2ecf20Sopenharmony_ci pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06); 42448c2ecf20Sopenharmony_ci if(IS_SIS740) { 42458c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); 42468c2ecf20Sopenharmony_ci } 42478c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 3); 42488c2ecf20Sopenharmony_ci } 42498c2ecf20Sopenharmony_ci 42508c2ecf20Sopenharmony_ci } 42518c2ecf20Sopenharmony_ci 42528c2ecf20Sopenharmony_ci if(!(SiS_IsNotM650orLater(SiS_Pr))) { 42538c2ecf20Sopenharmony_ci /* if(SiS_Pr->ChipType < SIS_340) {*/ 42548c2ecf20Sopenharmony_ci tempah = 0xef; 42558c2ecf20Sopenharmony_ci if(SiS_IsVAMode(SiS_Pr)) tempah = 0xf7; 42568c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); 42578c2ecf20Sopenharmony_ci /*}*/ 42588c2ecf20Sopenharmony_ci } 42598c2ecf20Sopenharmony_ci 42608c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 42618c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,~0x10); 42628c2ecf20Sopenharmony_ci } 42638c2ecf20Sopenharmony_ci 42648c2ecf20Sopenharmony_ci tempah = 0x3f; 42658c2ecf20Sopenharmony_ci if(SiS_IsDualEdge(SiS_Pr)) { 42668c2ecf20Sopenharmony_ci tempah = 0x7f; 42678c2ecf20Sopenharmony_ci if(!(SiS_IsVAMode(SiS_Pr))) tempah = 0xbf; 42688c2ecf20Sopenharmony_ci } 42698c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); 42708c2ecf20Sopenharmony_ci 42718c2ecf20Sopenharmony_ci if((SiS_IsVAMode(SiS_Pr)) || 42728c2ecf20Sopenharmony_ci ((SiS_Pr->SiS_VBType & VB_SISLVDS) && (modenum <= 0x13))) { 42738c2ecf20Sopenharmony_ci 42748c2ecf20Sopenharmony_ci SiS_DisplayOff(SiS_Pr); 42758c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 42768c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 2); 42778c2ecf20Sopenharmony_ci } 42788c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); 42798c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF); 42808c2ecf20Sopenharmony_ci 42818c2ecf20Sopenharmony_ci } 42828c2ecf20Sopenharmony_ci 42838c2ecf20Sopenharmony_ci if((!(SiS_IsVAMode(SiS_Pr))) || 42848c2ecf20Sopenharmony_ci ((SiS_Pr->SiS_VBType & VB_SISLVDS) && (modenum <= 0x13))) { 42858c2ecf20Sopenharmony_ci 42868c2ecf20Sopenharmony_ci if(!(SiS_IsDualEdge(SiS_Pr))) { 42878c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf); 42888c2ecf20Sopenharmony_ci SiS_DisplayOff(SiS_Pr); 42898c2ecf20Sopenharmony_ci } 42908c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); 42918c2ecf20Sopenharmony_ci 42928c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 42938c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 2); 42948c2ecf20Sopenharmony_ci } 42958c2ecf20Sopenharmony_ci 42968c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); 42978c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); 42988c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); 42998c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); 43008c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); 43018c2ecf20Sopenharmony_ci 43028c2ecf20Sopenharmony_ci } 43038c2ecf20Sopenharmony_ci 43048c2ecf20Sopenharmony_ci if(SiS_IsNotM650orLater(SiS_Pr)) { 43058c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); 43068c2ecf20Sopenharmony_ci } 43078c2ecf20Sopenharmony_ci 43088c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 43098c2ecf20Sopenharmony_ci 43108c2ecf20Sopenharmony_ci if( (!(SiS_IsVAMode(SiS_Pr))) && 43118c2ecf20Sopenharmony_ci (!(SiS_CRT2IsLCD(SiS_Pr))) && 43128c2ecf20Sopenharmony_ci (!(SiS_IsDualEdge(SiS_Pr))) ) { 43138c2ecf20Sopenharmony_ci 43148c2ecf20Sopenharmony_ci if(custom1) SiS_PanelDelay(SiS_Pr, 2); 43158c2ecf20Sopenharmony_ci if(!didpwd) { 43168c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); 43178c2ecf20Sopenharmony_ci } 43188c2ecf20Sopenharmony_ci if(custom1) SiS_PanelDelay(SiS_Pr, 4); 43198c2ecf20Sopenharmony_ci } 43208c2ecf20Sopenharmony_ci 43218c2ecf20Sopenharmony_ci if(!custom1) { 43228c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); 43238c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISEMI) { 43248c2ecf20Sopenharmony_ci if(SiS_IsVAorLCD(SiS_Pr)) { 43258c2ecf20Sopenharmony_ci SiS_PanelDelayLoop(SiS_Pr, 3, 20); 43268c2ecf20Sopenharmony_ci } 43278c2ecf20Sopenharmony_ci } 43288c2ecf20Sopenharmony_ci } 43298c2ecf20Sopenharmony_ci 43308c2ecf20Sopenharmony_ci } 43318c2ecf20Sopenharmony_ci 43328c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_315 */ 43338c2ecf20Sopenharmony_ci 43348c2ecf20Sopenharmony_ci } 43358c2ecf20Sopenharmony_ci 43368c2ecf20Sopenharmony_ci } else { /* ============ For 301 ================ */ 43378c2ecf20Sopenharmony_ci 43388c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 43398c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 43408c2ecf20Sopenharmony_ci if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { 43418c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); 43428c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 3); 43438c2ecf20Sopenharmony_ci } 43448c2ecf20Sopenharmony_ci#endif 43458c2ecf20Sopenharmony_ci } 43468c2ecf20Sopenharmony_ci 43478c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */ 43488c2ecf20Sopenharmony_ci SiS_DisplayOff(SiS_Pr); 43498c2ecf20Sopenharmony_ci 43508c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 43518c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); 43528c2ecf20Sopenharmony_ci } 43538c2ecf20Sopenharmony_ci 43548c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */ 43558c2ecf20Sopenharmony_ci 43568c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 43578c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); 43588c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); 43598c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); 43608c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); 43618c2ecf20Sopenharmony_ci } else { 43628c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 43638c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */ 43648c2ecf20Sopenharmony_ci if( (!(SiS_CRT2IsLCD(SiS_Pr))) || 43658c2ecf20Sopenharmony_ci (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) { 43668c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 2); 43678c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); 43688c2ecf20Sopenharmony_ci } 43698c2ecf20Sopenharmony_ci#endif 43708c2ecf20Sopenharmony_ci } 43718c2ecf20Sopenharmony_ci 43728c2ecf20Sopenharmony_ci } 43738c2ecf20Sopenharmony_ci 43748c2ecf20Sopenharmony_ci } else { /* ============ For LVDS =============*/ 43758c2ecf20Sopenharmony_ci 43768c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 43778c2ecf20Sopenharmony_ci 43788c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 /* 300 series */ 43798c2ecf20Sopenharmony_ci 43808c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { 43818c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x0E,0x09); 43828c2ecf20Sopenharmony_ci } 43838c2ecf20Sopenharmony_ci 43848c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_730) { 43858c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { 43868c2ecf20Sopenharmony_ci SiS_WaitVBRetrace(SiS_Pr); 43878c2ecf20Sopenharmony_ci } 43888c2ecf20Sopenharmony_ci if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { 43898c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); 43908c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 3); 43918c2ecf20Sopenharmony_ci } 43928c2ecf20Sopenharmony_ci } else { 43938c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { 43948c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { 43958c2ecf20Sopenharmony_ci if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { 43968c2ecf20Sopenharmony_ci SiS_WaitVBRetrace(SiS_Pr); 43978c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) { 43988c2ecf20Sopenharmony_ci SiS_DisplayOff(SiS_Pr); 43998c2ecf20Sopenharmony_ci } 44008c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); 44018c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 3); 44028c2ecf20Sopenharmony_ci } 44038c2ecf20Sopenharmony_ci } 44048c2ecf20Sopenharmony_ci } 44058c2ecf20Sopenharmony_ci } 44068c2ecf20Sopenharmony_ci 44078c2ecf20Sopenharmony_ci SiS_DisplayOff(SiS_Pr); 44088c2ecf20Sopenharmony_ci 44098c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); 44108c2ecf20Sopenharmony_ci 44118c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); 44128c2ecf20Sopenharmony_ci SiS_UnLockCRT2(SiS_Pr); 44138c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); 44148c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); 44158c2ecf20Sopenharmony_ci 44168c2ecf20Sopenharmony_ci if( (!(SiS_CRT2IsLCD(SiS_Pr))) || 44178c2ecf20Sopenharmony_ci (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) { 44188c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 2); 44198c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); 44208c2ecf20Sopenharmony_ci } 44218c2ecf20Sopenharmony_ci 44228c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_300 */ 44238c2ecf20Sopenharmony_ci 44248c2ecf20Sopenharmony_ci } else { 44258c2ecf20Sopenharmony_ci 44268c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 /* 315 series */ 44278c2ecf20Sopenharmony_ci 44288c2ecf20Sopenharmony_ci if(!(SiS_IsNotM650orLater(SiS_Pr))) { 44298c2ecf20Sopenharmony_ci /*if(SiS_Pr->ChipType < SIS_340) { */ /* XGI needs this */ 44308c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,~0x18); 44318c2ecf20Sopenharmony_ci /* } */ 44328c2ecf20Sopenharmony_ci } 44338c2ecf20Sopenharmony_ci 44348c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 44358c2ecf20Sopenharmony_ci 44368c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 44378c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x61); 44388c2ecf20Sopenharmony_ci if(temp < 1) { 44398c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x76,0xac); 44408c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x66,0x00); 44418c2ecf20Sopenharmony_ci } 44428c2ecf20Sopenharmony_ci 44438c2ecf20Sopenharmony_ci if( (!(SiS_IsDualEdge(SiS_Pr))) || 44448c2ecf20Sopenharmony_ci (SiS_IsTVOrYPbPrOrScart(SiS_Pr)) ) { 44458c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x49,0x3e); 44468c2ecf20Sopenharmony_ci } 44478c2ecf20Sopenharmony_ci } 44488c2ecf20Sopenharmony_ci 44498c2ecf20Sopenharmony_ci if( (!(SiS_IsDualEdge(SiS_Pr))) || 44508c2ecf20Sopenharmony_ci (SiS_IsVAMode(SiS_Pr)) ) { 44518c2ecf20Sopenharmony_ci SiS_Chrontel701xBLOff(SiS_Pr); 44528c2ecf20Sopenharmony_ci SiS_Chrontel701xOff(SiS_Pr); 44538c2ecf20Sopenharmony_ci } 44548c2ecf20Sopenharmony_ci 44558c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType != SIS_740) { 44568c2ecf20Sopenharmony_ci if( (!(SiS_IsDualEdge(SiS_Pr))) || 44578c2ecf20Sopenharmony_ci (SiS_IsTVOrYPbPrOrScart(SiS_Pr)) ) { 44588c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x49,0x01); 44598c2ecf20Sopenharmony_ci } 44608c2ecf20Sopenharmony_ci } 44618c2ecf20Sopenharmony_ci 44628c2ecf20Sopenharmony_ci } 44638c2ecf20Sopenharmony_ci 44648c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 44658c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); 44668c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 3); 44678c2ecf20Sopenharmony_ci } 44688c2ecf20Sopenharmony_ci 44698c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || 44708c2ecf20Sopenharmony_ci (!(SiS_IsDualEdge(SiS_Pr))) || 44718c2ecf20Sopenharmony_ci (!(SiS_IsTVOrYPbPrOrScart(SiS_Pr))) ) { 44728c2ecf20Sopenharmony_ci SiS_DisplayOff(SiS_Pr); 44738c2ecf20Sopenharmony_ci } 44748c2ecf20Sopenharmony_ci 44758c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || 44768c2ecf20Sopenharmony_ci (!(SiS_IsDualEdge(SiS_Pr))) || 44778c2ecf20Sopenharmony_ci (!(SiS_IsVAMode(SiS_Pr))) ) { 44788c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); 44798c2ecf20Sopenharmony_ci } 44808c2ecf20Sopenharmony_ci 44818c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 44828c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); 44838c2ecf20Sopenharmony_ci } 44848c2ecf20Sopenharmony_ci 44858c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); 44868c2ecf20Sopenharmony_ci 44878c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || 44888c2ecf20Sopenharmony_ci (!(SiS_IsDualEdge(SiS_Pr))) || 44898c2ecf20Sopenharmony_ci (!(SiS_IsVAMode(SiS_Pr))) ) { 44908c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); 44918c2ecf20Sopenharmony_ci } 44928c2ecf20Sopenharmony_ci 44938c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 44948c2ecf20Sopenharmony_ci if(SiS_CRT2IsLCD(SiS_Pr)) { 44958c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); 44968c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_550) { 44978c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xbf); 44988c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xef); 44998c2ecf20Sopenharmony_ci } 45008c2ecf20Sopenharmony_ci } 45018c2ecf20Sopenharmony_ci } else { 45028c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 45038c2ecf20Sopenharmony_ci if(SiS_IsLCDOrLCDA(SiS_Pr)) { 45048c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); 45058c2ecf20Sopenharmony_ci } 45068c2ecf20Sopenharmony_ci } else if(SiS_IsVAMode(SiS_Pr)) { 45078c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); 45088c2ecf20Sopenharmony_ci } 45098c2ecf20Sopenharmony_ci } 45108c2ecf20Sopenharmony_ci 45118c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 45128c2ecf20Sopenharmony_ci if(SiS_IsDualEdge(SiS_Pr)) { 45138c2ecf20Sopenharmony_ci /* SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xff); */ 45148c2ecf20Sopenharmony_ci } else { 45158c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); 45168c2ecf20Sopenharmony_ci } 45178c2ecf20Sopenharmony_ci } 45188c2ecf20Sopenharmony_ci 45198c2ecf20Sopenharmony_ci SiS_UnLockCRT2(SiS_Pr); 45208c2ecf20Sopenharmony_ci 45218c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_550) { 45228c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); /* DirectDVD PAL?*/ 45238c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); /* VB clock / 4 ? */ 45248c2ecf20Sopenharmony_ci } else if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || 45258c2ecf20Sopenharmony_ci (!(SiS_IsDualEdge(SiS_Pr))) || 45268c2ecf20Sopenharmony_ci (!(SiS_IsVAMode(SiS_Pr))) ) { 45278c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); 45288c2ecf20Sopenharmony_ci } 45298c2ecf20Sopenharmony_ci 45308c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 45318c2ecf20Sopenharmony_ci if(SiS_CRT2IsLCD(SiS_Pr)) { 45328c2ecf20Sopenharmony_ci if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { 45338c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 2); 45348c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); 45358c2ecf20Sopenharmony_ci } 45368c2ecf20Sopenharmony_ci } 45378c2ecf20Sopenharmony_ci } 45388c2ecf20Sopenharmony_ci 45398c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_315 */ 45408c2ecf20Sopenharmony_ci 45418c2ecf20Sopenharmony_ci } /* 315 series */ 45428c2ecf20Sopenharmony_ci 45438c2ecf20Sopenharmony_ci } /* LVDS */ 45448c2ecf20Sopenharmony_ci 45458c2ecf20Sopenharmony_ci} 45468c2ecf20Sopenharmony_ci 45478c2ecf20Sopenharmony_ci/*********************************************/ 45488c2ecf20Sopenharmony_ci/* ENABLE VIDEO BRIDGE */ 45498c2ecf20Sopenharmony_ci/*********************************************/ 45508c2ecf20Sopenharmony_ci 45518c2ecf20Sopenharmony_ci/* NEVER use any variables (VBInfo), this will be called 45528c2ecf20Sopenharmony_ci * from outside the context of a mode switch! 45538c2ecf20Sopenharmony_ci * MUST call getVBType before calling this 45548c2ecf20Sopenharmony_ci */ 45558c2ecf20Sopenharmony_cistatic 45568c2ecf20Sopenharmony_civoid 45578c2ecf20Sopenharmony_ciSiS_EnableBridge(struct SiS_Private *SiS_Pr) 45588c2ecf20Sopenharmony_ci{ 45598c2ecf20Sopenharmony_ci unsigned short temp=0, tempah; 45608c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 45618c2ecf20Sopenharmony_ci unsigned short temp1, pushax=0; 45628c2ecf20Sopenharmony_ci bool delaylong = false; 45638c2ecf20Sopenharmony_ci#endif 45648c2ecf20Sopenharmony_ci 45658c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 45668c2ecf20Sopenharmony_ci 45678c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* ====== For 301B et al ====== */ 45688c2ecf20Sopenharmony_ci 45698c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 45708c2ecf20Sopenharmony_ci 45718c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 /* 300 series */ 45728c2ecf20Sopenharmony_ci 45738c2ecf20Sopenharmony_ci if(SiS_CRT2IsLCD(SiS_Pr)) { 45748c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 45758c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); 45768c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { 45778c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00); 45788c2ecf20Sopenharmony_ci } 45798c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & (VB_SISLVDS | VB_NoLCD)) { 45808c2ecf20Sopenharmony_ci if(!(SiS_CR36BIOSWord23d(SiS_Pr))) { 45818c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 0); 45828c2ecf20Sopenharmony_ci } 45838c2ecf20Sopenharmony_ci } 45848c2ecf20Sopenharmony_ci } 45858c2ecf20Sopenharmony_ci 45868c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_NoLCD) && 45878c2ecf20Sopenharmony_ci (SiS_CRT2IsLCD(SiS_Pr))) { 45888c2ecf20Sopenharmony_ci 45898c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* Enable CRT2 */ 45908c2ecf20Sopenharmony_ci SiS_DisplayOn(SiS_Pr); 45918c2ecf20Sopenharmony_ci SiS_UnLockCRT2(SiS_Pr); 45928c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); 45938c2ecf20Sopenharmony_ci if(SiS_BridgeInSlavemode(SiS_Pr)) { 45948c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); 45958c2ecf20Sopenharmony_ci } else { 45968c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); 45978c2ecf20Sopenharmony_ci } 45988c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { 45998c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { 46008c2ecf20Sopenharmony_ci if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { 46018c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 1); 46028c2ecf20Sopenharmony_ci } 46038c2ecf20Sopenharmony_ci SiS_WaitVBRetrace(SiS_Pr); 46048c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00); 46058c2ecf20Sopenharmony_ci } 46068c2ecf20Sopenharmony_ci } 46078c2ecf20Sopenharmony_ci 46088c2ecf20Sopenharmony_ci } else { 46098c2ecf20Sopenharmony_ci 46108c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ 46118c2ecf20Sopenharmony_ci if(SiS_BridgeInSlavemode(SiS_Pr)) { 46128c2ecf20Sopenharmony_ci tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 46138c2ecf20Sopenharmony_ci if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; 46148c2ecf20Sopenharmony_ci } 46158c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); 46168c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); 46178c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ 46188c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0); 46198c2ecf20Sopenharmony_ci SiS_DisplayOn(SiS_Pr); 46208c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 46218c2ecf20Sopenharmony_ci if(SiS_CRT2IsLCD(SiS_Pr)) { 46228c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { 46238c2ecf20Sopenharmony_ci if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { 46248c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 1); 46258c2ecf20Sopenharmony_ci } 46268c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); 46278c2ecf20Sopenharmony_ci } 46288c2ecf20Sopenharmony_ci } 46298c2ecf20Sopenharmony_ci } 46308c2ecf20Sopenharmony_ci 46318c2ecf20Sopenharmony_ci } 46328c2ecf20Sopenharmony_ci 46338c2ecf20Sopenharmony_ci 46348c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_300 */ 46358c2ecf20Sopenharmony_ci 46368c2ecf20Sopenharmony_ci } else { 46378c2ecf20Sopenharmony_ci 46388c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 /* 315 series */ 46398c2ecf20Sopenharmony_ci 46408c2ecf20Sopenharmony_ci#ifdef SET_EMI 46418c2ecf20Sopenharmony_ci unsigned char r30=0, r31=0, r32=0, r33=0, cr36=0; 46428c2ecf20Sopenharmony_ci int didpwd = 0; 46438c2ecf20Sopenharmony_ci /* unsigned short emidelay=0; */ 46448c2ecf20Sopenharmony_ci#endif 46458c2ecf20Sopenharmony_ci 46468c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 46478c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0xef); 46488c2ecf20Sopenharmony_ci#ifdef SET_EMI 46498c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISEMI) { 46508c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); 46518c2ecf20Sopenharmony_ci } 46528c2ecf20Sopenharmony_ci#endif 46538c2ecf20Sopenharmony_ci } 46548c2ecf20Sopenharmony_ci 46558c2ecf20Sopenharmony_ci if(!(SiS_IsNotM650orLater(SiS_Pr))) { 46568c2ecf20Sopenharmony_ci /*if(SiS_Pr->ChipType < SIS_340) { */ 46578c2ecf20Sopenharmony_ci tempah = 0x10; 46588c2ecf20Sopenharmony_ci if(SiS_LCDAEnabled(SiS_Pr)) { 46598c2ecf20Sopenharmony_ci if(SiS_TVEnabled(SiS_Pr)) tempah = 0x18; 46608c2ecf20Sopenharmony_ci else tempah = 0x08; 46618c2ecf20Sopenharmony_ci } 46628c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4c,tempah); 46638c2ecf20Sopenharmony_ci /*}*/ 46648c2ecf20Sopenharmony_ci } 46658c2ecf20Sopenharmony_ci 46668c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 46678c2ecf20Sopenharmony_ci 46688c2ecf20Sopenharmony_ci SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); 46698c2ecf20Sopenharmony_ci SiS_DisplayOff(SiS_Pr); 46708c2ecf20Sopenharmony_ci pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06); 46718c2ecf20Sopenharmony_ci if(IS_SIS740) { 46728c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); 46738c2ecf20Sopenharmony_ci } 46748c2ecf20Sopenharmony_ci 46758c2ecf20Sopenharmony_ci didpwd = SiS_HandlePWD(SiS_Pr); 46768c2ecf20Sopenharmony_ci 46778c2ecf20Sopenharmony_ci if(SiS_IsVAorLCD(SiS_Pr)) { 46788c2ecf20Sopenharmony_ci if(!didpwd) { 46798c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { 46808c2ecf20Sopenharmony_ci SiS_PanelDelayLoop(SiS_Pr, 3, 2); 46818c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); 46828c2ecf20Sopenharmony_ci SiS_PanelDelayLoop(SiS_Pr, 3, 2); 46838c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISEMI) { 46848c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 17664); 46858c2ecf20Sopenharmony_ci } 46868c2ecf20Sopenharmony_ci } 46878c2ecf20Sopenharmony_ci } else { 46888c2ecf20Sopenharmony_ci SiS_PanelDelayLoop(SiS_Pr, 3, 2); 46898c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISEMI) { 46908c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 17664); 46918c2ecf20Sopenharmony_ci } 46928c2ecf20Sopenharmony_ci } 46938c2ecf20Sopenharmony_ci } 46948c2ecf20Sopenharmony_ci 46958c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40)) { 46968c2ecf20Sopenharmony_ci SiS_PanelDelayLoop(SiS_Pr, 3, 10); 46978c2ecf20Sopenharmony_ci delaylong = true; 46988c2ecf20Sopenharmony_ci } 46998c2ecf20Sopenharmony_ci 47008c2ecf20Sopenharmony_ci } 47018c2ecf20Sopenharmony_ci 47028c2ecf20Sopenharmony_ci if(!(SiS_IsVAMode(SiS_Pr))) { 47038c2ecf20Sopenharmony_ci 47048c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; 47058c2ecf20Sopenharmony_ci if(SiS_BridgeInSlavemode(SiS_Pr)) { 47068c2ecf20Sopenharmony_ci tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 47078c2ecf20Sopenharmony_ci if(!(tempah & SetCRT2ToRAMDAC)) { 47088c2ecf20Sopenharmony_ci if(!(SiS_LCDAEnabled(SiS_Pr))) temp |= 0x20; 47098c2ecf20Sopenharmony_ci } 47108c2ecf20Sopenharmony_ci } 47118c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); 47128c2ecf20Sopenharmony_ci 47138c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ 47148c2ecf20Sopenharmony_ci 47158c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); 47168c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); 47178c2ecf20Sopenharmony_ci 47188c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 47198c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 2); 47208c2ecf20Sopenharmony_ci } 47218c2ecf20Sopenharmony_ci 47228c2ecf20Sopenharmony_ci } else { 47238c2ecf20Sopenharmony_ci 47248c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x20); 47258c2ecf20Sopenharmony_ci 47268c2ecf20Sopenharmony_ci } 47278c2ecf20Sopenharmony_ci 47288c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); 47298c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); 47308c2ecf20Sopenharmony_ci 47318c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISPOWER) { 47328c2ecf20Sopenharmony_ci if( (SiS_LCDAEnabled(SiS_Pr)) || 47338c2ecf20Sopenharmony_ci (SiS_CRT2IsLCD(SiS_Pr)) ) { 47348c2ecf20Sopenharmony_ci /* Enable "LVDS PLL power on" (even on 301C) */ 47358c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x2a,0x7f); 47368c2ecf20Sopenharmony_ci /* Enable "LVDS Driver Power on" (even on 301C) */ 47378c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x7f); 47388c2ecf20Sopenharmony_ci } 47398c2ecf20Sopenharmony_ci } 47408c2ecf20Sopenharmony_ci 47418c2ecf20Sopenharmony_ci tempah = 0xc0; 47428c2ecf20Sopenharmony_ci if(SiS_IsDualEdge(SiS_Pr)) { 47438c2ecf20Sopenharmony_ci tempah = 0x80; 47448c2ecf20Sopenharmony_ci if(!(SiS_IsVAMode(SiS_Pr))) tempah = 0x40; 47458c2ecf20Sopenharmony_ci } 47468c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah); 47478c2ecf20Sopenharmony_ci 47488c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 47498c2ecf20Sopenharmony_ci 47508c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 2); 47518c2ecf20Sopenharmony_ci 47528c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1f,0x10); 47538c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); 47548c2ecf20Sopenharmony_ci 47558c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { 47568c2ecf20Sopenharmony_ci#ifdef SET_EMI 47578c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISEMI) { 47588c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); 47598c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 2048); 47608c2ecf20Sopenharmony_ci } 47618c2ecf20Sopenharmony_ci#endif 47628c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c); 47638c2ecf20Sopenharmony_ci 47648c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISEMI) { 47658c2ecf20Sopenharmony_ci#ifdef SET_EMI 47668c2ecf20Sopenharmony_ci cr36 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); 47678c2ecf20Sopenharmony_ci 47688c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ROMNew) { 47698c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 47708c2ecf20Sopenharmony_ci unsigned short romptr = GetLCDStructPtr661_2(SiS_Pr); 47718c2ecf20Sopenharmony_ci if(romptr) { 47728c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */ 47738c2ecf20Sopenharmony_ci SiS_Pr->EMI_30 = 0; 47748c2ecf20Sopenharmony_ci SiS_Pr->EMI_31 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 0]; 47758c2ecf20Sopenharmony_ci SiS_Pr->EMI_32 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 1]; 47768c2ecf20Sopenharmony_ci SiS_Pr->EMI_33 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 2]; 47778c2ecf20Sopenharmony_ci if(ROMAddr[romptr + 1] & 0x10) SiS_Pr->EMI_30 = 0x40; 47788c2ecf20Sopenharmony_ci /* emidelay = SISGETROMW((romptr + 0x22)); */ 47798c2ecf20Sopenharmony_ci SiS_Pr->HaveEMI = SiS_Pr->HaveEMILCD = SiS_Pr->OverruleEMI = true; 47808c2ecf20Sopenharmony_ci } 47818c2ecf20Sopenharmony_ci } 47828c2ecf20Sopenharmony_ci 47838c2ecf20Sopenharmony_ci /* (P4_30|0x40) */ 47848c2ecf20Sopenharmony_ci /* Compal 1400x1050: 0x05, 0x60, 0x00 YES (1.10.7w; CR36=69) */ 47858c2ecf20Sopenharmony_ci /* Compal 1400x1050: 0x0d, 0x70, 0x40 YES (1.10.7x; CR36=69) */ 47868c2ecf20Sopenharmony_ci /* Acer 1280x1024: 0x12, 0xd0, 0x6b NO (1.10.9k; CR36=73) */ 47878c2ecf20Sopenharmony_ci /* Compaq 1280x1024: 0x0d, 0x70, 0x6b YES (1.12.04b; CR36=03) */ 47888c2ecf20Sopenharmony_ci /* Clevo 1024x768: 0x05, 0x60, 0x33 NO (1.10.8e; CR36=12, DL!) */ 47898c2ecf20Sopenharmony_ci /* Clevo 1024x768: 0x0d, 0x70, 0x40 (if type == 3) YES (1.10.8y; CR36=?2) */ 47908c2ecf20Sopenharmony_ci /* Clevo 1024x768: 0x05, 0x60, 0x33 (if type != 3) YES (1.10.8y; CR36=?2) */ 47918c2ecf20Sopenharmony_ci /* Asus 1024x768: ? ? (1.10.8o; CR36=?2) */ 47928c2ecf20Sopenharmony_ci /* Asus 1024x768: 0x08, 0x10, 0x3c (problematic) YES (1.10.8q; CR36=22) */ 47938c2ecf20Sopenharmony_ci 47948c2ecf20Sopenharmony_ci if(SiS_Pr->HaveEMI) { 47958c2ecf20Sopenharmony_ci r30 = SiS_Pr->EMI_30; r31 = SiS_Pr->EMI_31; 47968c2ecf20Sopenharmony_ci r32 = SiS_Pr->EMI_32; r33 = SiS_Pr->EMI_33; 47978c2ecf20Sopenharmony_ci } else { 47988c2ecf20Sopenharmony_ci r30 = 0; 47998c2ecf20Sopenharmony_ci } 48008c2ecf20Sopenharmony_ci 48018c2ecf20Sopenharmony_ci /* EMI_30 is read at driver start; however, the BIOS sets this 48028c2ecf20Sopenharmony_ci * (if it is used) only if the LCD is in use. In case we caught 48038c2ecf20Sopenharmony_ci * the machine while on TV output, this bit is not set and we 48048c2ecf20Sopenharmony_ci * don't know if it should be set - hence our detection is wrong. 48058c2ecf20Sopenharmony_ci * Work-around this here: 48068c2ecf20Sopenharmony_ci */ 48078c2ecf20Sopenharmony_ci 48088c2ecf20Sopenharmony_ci if((!SiS_Pr->HaveEMI) || (!SiS_Pr->HaveEMILCD)) { 48098c2ecf20Sopenharmony_ci switch((cr36 & 0x0f)) { 48108c2ecf20Sopenharmony_ci case 2: 48118c2ecf20Sopenharmony_ci r30 |= 0x40; 48128c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) r30 &= ~0x40; 48138c2ecf20Sopenharmony_ci if(!SiS_Pr->HaveEMI) { 48148c2ecf20Sopenharmony_ci r31 = 0x05; r32 = 0x60; r33 = 0x33; 48158c2ecf20Sopenharmony_ci if((cr36 & 0xf0) == 0x30) { 48168c2ecf20Sopenharmony_ci r31 = 0x0d; r32 = 0x70; r33 = 0x40; 48178c2ecf20Sopenharmony_ci } 48188c2ecf20Sopenharmony_ci } 48198c2ecf20Sopenharmony_ci break; 48208c2ecf20Sopenharmony_ci case 3: /* 1280x1024 */ 48218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) r30 |= 0x40; 48228c2ecf20Sopenharmony_ci if(!SiS_Pr->HaveEMI) { 48238c2ecf20Sopenharmony_ci r31 = 0x12; r32 = 0xd0; r33 = 0x6b; 48248c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { 48258c2ecf20Sopenharmony_ci r31 = 0x0d; r32 = 0x70; r33 = 0x6b; 48268c2ecf20Sopenharmony_ci } 48278c2ecf20Sopenharmony_ci } 48288c2ecf20Sopenharmony_ci break; 48298c2ecf20Sopenharmony_ci case 9: /* 1400x1050 */ 48308c2ecf20Sopenharmony_ci r30 |= 0x40; 48318c2ecf20Sopenharmony_ci if(!SiS_Pr->HaveEMI) { 48328c2ecf20Sopenharmony_ci r31 = 0x05; r32 = 0x60; r33 = 0x00; 48338c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_COMPAL1400_2) { 48348c2ecf20Sopenharmony_ci r31 = 0x0d; r32 = 0x70; r33 = 0x40; /* BIOS values */ 48358c2ecf20Sopenharmony_ci } 48368c2ecf20Sopenharmony_ci } 48378c2ecf20Sopenharmony_ci break; 48388c2ecf20Sopenharmony_ci case 11: /* 1600x1200 - unknown */ 48398c2ecf20Sopenharmony_ci r30 |= 0x40; 48408c2ecf20Sopenharmony_ci if(!SiS_Pr->HaveEMI) { 48418c2ecf20Sopenharmony_ci r31 = 0x05; r32 = 0x60; r33 = 0x00; 48428c2ecf20Sopenharmony_ci } 48438c2ecf20Sopenharmony_ci } 48448c2ecf20Sopenharmony_ci } 48458c2ecf20Sopenharmony_ci 48468c2ecf20Sopenharmony_ci /* BIOS values don't work so well sometimes */ 48478c2ecf20Sopenharmony_ci if(!SiS_Pr->OverruleEMI) { 48488c2ecf20Sopenharmony_ci#ifdef COMPAL_HACK 48498c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_COMPAL1400_2) { 48508c2ecf20Sopenharmony_ci if((cr36 & 0x0f) == 0x09) { 48518c2ecf20Sopenharmony_ci r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x00; 48528c2ecf20Sopenharmony_ci } 48538c2ecf20Sopenharmony_ci } 48548c2ecf20Sopenharmony_ci#endif 48558c2ecf20Sopenharmony_ci#ifdef COMPAQ_HACK 48568c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { 48578c2ecf20Sopenharmony_ci if((cr36 & 0x0f) == 0x03) { 48588c2ecf20Sopenharmony_ci r30 = 0x20; r31 = 0x12; r32 = 0xd0; r33 = 0x6b; 48598c2ecf20Sopenharmony_ci } 48608c2ecf20Sopenharmony_ci } 48618c2ecf20Sopenharmony_ci#endif 48628c2ecf20Sopenharmony_ci#ifdef ASUS_HACK 48638c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { 48648c2ecf20Sopenharmony_ci if((cr36 & 0x0f) == 0x02) { 48658c2ecf20Sopenharmony_ci /* r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 2 */ 48668c2ecf20Sopenharmony_ci /* r30 = 0x20; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 3 */ 48678c2ecf20Sopenharmony_ci /* r30 = 0x60; r31 = 0x0d; r32 = 0x70; r33 = 0x40; */ /* rev 4 */ 48688c2ecf20Sopenharmony_ci /* r30 = 0x20; r31 = 0x0d; r32 = 0x70; r33 = 0x40; */ /* rev 5 */ 48698c2ecf20Sopenharmony_ci } 48708c2ecf20Sopenharmony_ci } 48718c2ecf20Sopenharmony_ci#endif 48728c2ecf20Sopenharmony_ci } 48738c2ecf20Sopenharmony_ci 48748c2ecf20Sopenharmony_ci if(!(SiS_Pr->OverruleEMI && (!r30) && (!r31) && (!r32) && (!r33))) { 48758c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */ 48768c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 2048); 48778c2ecf20Sopenharmony_ci } 48788c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,r31); 48798c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,r32); 48808c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x33,r33); 48818c2ecf20Sopenharmony_ci#endif /* SET_EMI */ 48828c2ecf20Sopenharmony_ci 48838c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); 48848c2ecf20Sopenharmony_ci 48858c2ecf20Sopenharmony_ci#ifdef SET_EMI 48868c2ecf20Sopenharmony_ci if( (SiS_LCDAEnabled(SiS_Pr)) || 48878c2ecf20Sopenharmony_ci (SiS_CRT2IsLCD(SiS_Pr)) ) { 48888c2ecf20Sopenharmony_ci if(r30 & 0x40) { 48898c2ecf20Sopenharmony_ci /*SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x2a,0x80);*/ 48908c2ecf20Sopenharmony_ci SiS_PanelDelayLoop(SiS_Pr, 3, 5); 48918c2ecf20Sopenharmony_ci if(delaylong) { 48928c2ecf20Sopenharmony_ci SiS_PanelDelayLoop(SiS_Pr, 3, 5); 48938c2ecf20Sopenharmony_ci delaylong = false; 48948c2ecf20Sopenharmony_ci } 48958c2ecf20Sopenharmony_ci SiS_WaitVBRetrace(SiS_Pr); 48968c2ecf20Sopenharmony_ci SiS_WaitVBRetrace(SiS_Pr); 48978c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { 48988c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 1280); 48998c2ecf20Sopenharmony_ci } 49008c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); /* Enable */ 49018c2ecf20Sopenharmony_ci /*SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x2a,0x7f);*/ 49028c2ecf20Sopenharmony_ci } 49038c2ecf20Sopenharmony_ci } 49048c2ecf20Sopenharmony_ci#endif 49058c2ecf20Sopenharmony_ci } 49068c2ecf20Sopenharmony_ci } 49078c2ecf20Sopenharmony_ci 49088c2ecf20Sopenharmony_ci if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { 49098c2ecf20Sopenharmony_ci if(SiS_IsVAorLCD(SiS_Pr)) { 49108c2ecf20Sopenharmony_ci SiS_PanelDelayLoop(SiS_Pr, 3, 10); 49118c2ecf20Sopenharmony_ci if(delaylong) { 49128c2ecf20Sopenharmony_ci SiS_PanelDelayLoop(SiS_Pr, 3, 10); 49138c2ecf20Sopenharmony_ci } 49148c2ecf20Sopenharmony_ci SiS_WaitVBRetrace(SiS_Pr); 49158c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISEMI) { 49168c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 2048); 49178c2ecf20Sopenharmony_ci SiS_WaitVBRetrace(SiS_Pr); 49188c2ecf20Sopenharmony_ci } 49198c2ecf20Sopenharmony_ci if(!didpwd) { 49208c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); 49218c2ecf20Sopenharmony_ci } else { 49228c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x03); 49238c2ecf20Sopenharmony_ci } 49248c2ecf20Sopenharmony_ci } 49258c2ecf20Sopenharmony_ci } 49268c2ecf20Sopenharmony_ci 49278c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); 49288c2ecf20Sopenharmony_ci SiS_DisplayOn(SiS_Pr); 49298c2ecf20Sopenharmony_ci SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xff); 49308c2ecf20Sopenharmony_ci 49318c2ecf20Sopenharmony_ci } 49328c2ecf20Sopenharmony_ci 49338c2ecf20Sopenharmony_ci if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { 49348c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); 49358c2ecf20Sopenharmony_ci } 49368c2ecf20Sopenharmony_ci 49378c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_315 */ 49388c2ecf20Sopenharmony_ci 49398c2ecf20Sopenharmony_ci } 49408c2ecf20Sopenharmony_ci 49418c2ecf20Sopenharmony_ci } else { /* ============ For 301 ================ */ 49428c2ecf20Sopenharmony_ci 49438c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 49448c2ecf20Sopenharmony_ci if(SiS_CRT2IsLCD(SiS_Pr)) { 49458c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00); 49468c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 0); 49478c2ecf20Sopenharmony_ci } 49488c2ecf20Sopenharmony_ci } 49498c2ecf20Sopenharmony_ci 49508c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ 49518c2ecf20Sopenharmony_ci if(SiS_BridgeInSlavemode(SiS_Pr)) { 49528c2ecf20Sopenharmony_ci tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 49538c2ecf20Sopenharmony_ci if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; 49548c2ecf20Sopenharmony_ci } 49558c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); 49568c2ecf20Sopenharmony_ci 49578c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ 49588c2ecf20Sopenharmony_ci 49598c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 49608c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); 49618c2ecf20Sopenharmony_ci if(!(temp & 0x80)) { 49628c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); /* BVBDOENABLE=1 */ 49638c2ecf20Sopenharmony_ci } 49648c2ecf20Sopenharmony_ci } 49658c2ecf20Sopenharmony_ci 49668c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ 49678c2ecf20Sopenharmony_ci 49688c2ecf20Sopenharmony_ci SiS_VBLongWait(SiS_Pr); 49698c2ecf20Sopenharmony_ci SiS_DisplayOn(SiS_Pr); 49708c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 49718c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); 49728c2ecf20Sopenharmony_ci } 49738c2ecf20Sopenharmony_ci SiS_VBLongWait(SiS_Pr); 49748c2ecf20Sopenharmony_ci 49758c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 49768c2ecf20Sopenharmony_ci if(SiS_CRT2IsLCD(SiS_Pr)) { 49778c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 1); 49788c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00); 49798c2ecf20Sopenharmony_ci } 49808c2ecf20Sopenharmony_ci } 49818c2ecf20Sopenharmony_ci 49828c2ecf20Sopenharmony_ci } 49838c2ecf20Sopenharmony_ci 49848c2ecf20Sopenharmony_ci } else { /* =================== For LVDS ================== */ 49858c2ecf20Sopenharmony_ci 49868c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 49878c2ecf20Sopenharmony_ci 49888c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 /* 300 series */ 49898c2ecf20Sopenharmony_ci 49908c2ecf20Sopenharmony_ci if(SiS_CRT2IsLCD(SiS_Pr)) { 49918c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_730) { 49928c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 1); 49938c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 1); 49948c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 1); 49958c2ecf20Sopenharmony_ci } 49968c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00); 49978c2ecf20Sopenharmony_ci if(!(SiS_CR36BIOSWord23d(SiS_Pr))) { 49988c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 0); 49998c2ecf20Sopenharmony_ci } 50008c2ecf20Sopenharmony_ci } 50018c2ecf20Sopenharmony_ci 50028c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); 50038c2ecf20Sopenharmony_ci SiS_DisplayOn(SiS_Pr); 50048c2ecf20Sopenharmony_ci SiS_UnLockCRT2(SiS_Pr); 50058c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); 50068c2ecf20Sopenharmony_ci if(SiS_BridgeInSlavemode(SiS_Pr)) { 50078c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); 50088c2ecf20Sopenharmony_ci } else { 50098c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); 50108c2ecf20Sopenharmony_ci } 50118c2ecf20Sopenharmony_ci 50128c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { 50138c2ecf20Sopenharmony_ci if(!(SiS_CRT2IsLCD(SiS_Pr))) { 50148c2ecf20Sopenharmony_ci SiS_WaitVBRetrace(SiS_Pr); 50158c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x0E,0x0B); 50168c2ecf20Sopenharmony_ci } 50178c2ecf20Sopenharmony_ci } 50188c2ecf20Sopenharmony_ci 50198c2ecf20Sopenharmony_ci if(SiS_CRT2IsLCD(SiS_Pr)) { 50208c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { 50218c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { 50228c2ecf20Sopenharmony_ci if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { 50238c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 1); 50248c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 1); 50258c2ecf20Sopenharmony_ci } 50268c2ecf20Sopenharmony_ci SiS_WaitVBRetrace(SiS_Pr); 50278c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00); 50288c2ecf20Sopenharmony_ci } 50298c2ecf20Sopenharmony_ci } 50308c2ecf20Sopenharmony_ci } 50318c2ecf20Sopenharmony_ci 50328c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_300 */ 50338c2ecf20Sopenharmony_ci 50348c2ecf20Sopenharmony_ci } else { 50358c2ecf20Sopenharmony_ci 50368c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 /* 315 series */ 50378c2ecf20Sopenharmony_ci 50388c2ecf20Sopenharmony_ci if(!(SiS_IsNotM650orLater(SiS_Pr))) { 50398c2ecf20Sopenharmony_ci /*if(SiS_Pr->ChipType < SIS_340) {*/ /* XGI needs this */ 50408c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x18); 50418c2ecf20Sopenharmony_ci /*}*/ 50428c2ecf20Sopenharmony_ci } 50438c2ecf20Sopenharmony_ci 50448c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 50458c2ecf20Sopenharmony_ci if(SiS_CRT2IsLCD(SiS_Pr)) { 50468c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00); 50478c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 0); 50488c2ecf20Sopenharmony_ci } 50498c2ecf20Sopenharmony_ci } 50508c2ecf20Sopenharmony_ci 50518c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); 50528c2ecf20Sopenharmony_ci SiS_UnLockCRT2(SiS_Pr); 50538c2ecf20Sopenharmony_ci 50548c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); 50558c2ecf20Sopenharmony_ci 50568c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 50578c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x66); 50588c2ecf20Sopenharmony_ci temp &= 0x20; 50598c2ecf20Sopenharmony_ci SiS_Chrontel701xBLOff(SiS_Pr); 50608c2ecf20Sopenharmony_ci } 50618c2ecf20Sopenharmony_ci 50628c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType != SIS_550) { 50638c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); 50648c2ecf20Sopenharmony_ci } 50658c2ecf20Sopenharmony_ci 50668c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 50678c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 50688c2ecf20Sopenharmony_ci if(SiS_IsLCDOrLCDA(SiS_Pr)) { 50698c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); 50708c2ecf20Sopenharmony_ci } 50718c2ecf20Sopenharmony_ci } 50728c2ecf20Sopenharmony_ci } 50738c2ecf20Sopenharmony_ci 50748c2ecf20Sopenharmony_ci temp1 = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); 50758c2ecf20Sopenharmony_ci if(!(temp1 & 0x80)) { 50768c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); 50778c2ecf20Sopenharmony_ci } 50788c2ecf20Sopenharmony_ci 50798c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 50808c2ecf20Sopenharmony_ci if(temp) { 50818c2ecf20Sopenharmony_ci SiS_Chrontel701xBLOn(SiS_Pr); 50828c2ecf20Sopenharmony_ci } 50838c2ecf20Sopenharmony_ci } 50848c2ecf20Sopenharmony_ci 50858c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 50868c2ecf20Sopenharmony_ci if(SiS_CRT2IsLCD(SiS_Pr)) { 50878c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); 50888c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_550) { 50898c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x40); 50908c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x10); 50918c2ecf20Sopenharmony_ci } 50928c2ecf20Sopenharmony_ci } 50938c2ecf20Sopenharmony_ci } else if(SiS_IsVAMode(SiS_Pr)) { 50948c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType != SIS_740) { 50958c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); 50968c2ecf20Sopenharmony_ci } 50978c2ecf20Sopenharmony_ci } 50988c2ecf20Sopenharmony_ci 50998c2ecf20Sopenharmony_ci if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { 51008c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); 51018c2ecf20Sopenharmony_ci } 51028c2ecf20Sopenharmony_ci 51038c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 51048c2ecf20Sopenharmony_ci if(SiS_IsTVOrYPbPrOrScart(SiS_Pr)) { 51058c2ecf20Sopenharmony_ci SiS_Chrontel701xOn(SiS_Pr); 51068c2ecf20Sopenharmony_ci } 51078c2ecf20Sopenharmony_ci if( (SiS_IsVAMode(SiS_Pr)) || 51088c2ecf20Sopenharmony_ci (SiS_IsLCDOrLCDA(SiS_Pr)) ) { 51098c2ecf20Sopenharmony_ci SiS_ChrontelDoSomething1(SiS_Pr); 51108c2ecf20Sopenharmony_ci } 51118c2ecf20Sopenharmony_ci } 51128c2ecf20Sopenharmony_ci 51138c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 51148c2ecf20Sopenharmony_ci if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { 51158c2ecf20Sopenharmony_ci if( (SiS_IsVAMode(SiS_Pr)) || 51168c2ecf20Sopenharmony_ci (SiS_IsLCDOrLCDA(SiS_Pr)) ) { 51178c2ecf20Sopenharmony_ci SiS_Chrontel701xBLOn(SiS_Pr); 51188c2ecf20Sopenharmony_ci SiS_ChrontelInitTVVSync(SiS_Pr); 51198c2ecf20Sopenharmony_ci } 51208c2ecf20Sopenharmony_ci } 51218c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 51228c2ecf20Sopenharmony_ci if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { 51238c2ecf20Sopenharmony_ci if(SiS_CRT2IsLCD(SiS_Pr)) { 51248c2ecf20Sopenharmony_ci SiS_PanelDelay(SiS_Pr, 1); 51258c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00); 51268c2ecf20Sopenharmony_ci } 51278c2ecf20Sopenharmony_ci } 51288c2ecf20Sopenharmony_ci } 51298c2ecf20Sopenharmony_ci 51308c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_315 */ 51318c2ecf20Sopenharmony_ci 51328c2ecf20Sopenharmony_ci } /* 310 series */ 51338c2ecf20Sopenharmony_ci 51348c2ecf20Sopenharmony_ci } /* LVDS */ 51358c2ecf20Sopenharmony_ci 51368c2ecf20Sopenharmony_ci} 51378c2ecf20Sopenharmony_ci 51388c2ecf20Sopenharmony_ci/*********************************************/ 51398c2ecf20Sopenharmony_ci/* SET PART 1 REGISTER GROUP */ 51408c2ecf20Sopenharmony_ci/*********************************************/ 51418c2ecf20Sopenharmony_ci 51428c2ecf20Sopenharmony_ci/* Set CRT2 OFFSET / PITCH */ 51438c2ecf20Sopenharmony_cistatic void 51448c2ecf20Sopenharmony_ciSiS_SetCRT2Offset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 51458c2ecf20Sopenharmony_ci unsigned short RRTI) 51468c2ecf20Sopenharmony_ci{ 51478c2ecf20Sopenharmony_ci unsigned short offset; 51488c2ecf20Sopenharmony_ci unsigned char temp; 51498c2ecf20Sopenharmony_ci 51508c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) return; 51518c2ecf20Sopenharmony_ci 51528c2ecf20Sopenharmony_ci offset = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex,RRTI); 51538c2ecf20Sopenharmony_ci 51548c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(offset & 0xFF)); 51558c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,(offset >> 8)); 51568c2ecf20Sopenharmony_ci 51578c2ecf20Sopenharmony_ci temp = (unsigned char)(((offset >> 3) & 0xFF) + 1); 51588c2ecf20Sopenharmony_ci if(offset & 0x07) temp++; 51598c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,temp); 51608c2ecf20Sopenharmony_ci} 51618c2ecf20Sopenharmony_ci 51628c2ecf20Sopenharmony_ci/* Set CRT2 sync and PanelLink mode */ 51638c2ecf20Sopenharmony_cistatic void 51648c2ecf20Sopenharmony_ciSiS_SetCRT2Sync(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short RefreshRateTableIndex) 51658c2ecf20Sopenharmony_ci{ 51668c2ecf20Sopenharmony_ci unsigned short tempah=0, tempbl, infoflag; 51678c2ecf20Sopenharmony_ci 51688c2ecf20Sopenharmony_ci tempbl = 0xC0; 51698c2ecf20Sopenharmony_ci 51708c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 51718c2ecf20Sopenharmony_ci infoflag = SiS_Pr->CInfoFlag; 51728c2ecf20Sopenharmony_ci } else { 51738c2ecf20Sopenharmony_ci infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; 51748c2ecf20Sopenharmony_ci } 51758c2ecf20Sopenharmony_ci 51768c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */ 51778c2ecf20Sopenharmony_ci 51788c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 51798c2ecf20Sopenharmony_ci tempah = 0; 51808c2ecf20Sopenharmony_ci } else if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDInfo & LCDSync)) { 51818c2ecf20Sopenharmony_ci tempah = SiS_Pr->SiS_LCDInfo; 51828c2ecf20Sopenharmony_ci } else tempah = infoflag >> 8; 51838c2ecf20Sopenharmony_ci tempah &= 0xC0; 51848c2ecf20Sopenharmony_ci tempah |= 0x20; 51858c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; 51868c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 51878c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || 51888c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { 51898c2ecf20Sopenharmony_ci tempah |= 0xf0; 51908c2ecf20Sopenharmony_ci } 51918c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_IF_DEF_FSTN) || 51928c2ecf20Sopenharmony_ci (SiS_Pr->SiS_IF_DEF_DSTN) || 51938c2ecf20Sopenharmony_ci (SiS_Pr->SiS_IF_DEF_TRUMPION) || 51948c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_PANEL848) || 51958c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) { 51968c2ecf20Sopenharmony_ci tempah |= 0x30; 51978c2ecf20Sopenharmony_ci } 51988c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_IF_DEF_FSTN) || 51998c2ecf20Sopenharmony_ci (SiS_Pr->SiS_IF_DEF_DSTN) ) { 52008c2ecf20Sopenharmony_ci tempah &= ~0xc0; 52018c2ecf20Sopenharmony_ci } 52028c2ecf20Sopenharmony_ci } 52038c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 52048c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 52058c2ecf20Sopenharmony_ci tempah >>= 3; 52068c2ecf20Sopenharmony_ci tempah &= 0x18; 52078c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xE7,tempah); 52088c2ecf20Sopenharmony_ci /* Don't care about 12/18/24 bit mode - TV is via VGA, not PL */ 52098c2ecf20Sopenharmony_ci } else { 52108c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,0xe0); 52118c2ecf20Sopenharmony_ci } 52128c2ecf20Sopenharmony_ci } else { 52138c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); 52148c2ecf20Sopenharmony_ci } 52158c2ecf20Sopenharmony_ci 52168c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 52178c2ecf20Sopenharmony_ci 52188c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 52198c2ecf20Sopenharmony_ci 52208c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 /* ---- 300 series --- */ 52218c2ecf20Sopenharmony_ci 52228c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* 630 - 301B(-DH) */ 52238c2ecf20Sopenharmony_ci 52248c2ecf20Sopenharmony_ci tempah = infoflag >> 8; 52258c2ecf20Sopenharmony_ci tempbl = 0; 52268c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 52278c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDSync) { 52288c2ecf20Sopenharmony_ci tempah = SiS_Pr->SiS_LCDInfo; 52298c2ecf20Sopenharmony_ci tempbl = (tempah >> 6) & 0x03; 52308c2ecf20Sopenharmony_ci } 52318c2ecf20Sopenharmony_ci } 52328c2ecf20Sopenharmony_ci tempah &= 0xC0; 52338c2ecf20Sopenharmony_ci tempah |= 0x20; 52348c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; 52358c2ecf20Sopenharmony_ci tempah |= 0xc0; 52368c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); 52378c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { 52388c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); 52398c2ecf20Sopenharmony_ci } 52408c2ecf20Sopenharmony_ci 52418c2ecf20Sopenharmony_ci } else { /* 630 - 301 */ 52428c2ecf20Sopenharmony_ci 52438c2ecf20Sopenharmony_ci tempah = ((infoflag >> 8) & 0xc0) | 0x20; 52448c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; 52458c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); 52468c2ecf20Sopenharmony_ci 52478c2ecf20Sopenharmony_ci } 52488c2ecf20Sopenharmony_ci 52498c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_300 */ 52508c2ecf20Sopenharmony_ci 52518c2ecf20Sopenharmony_ci } else { 52528c2ecf20Sopenharmony_ci 52538c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 /* ------- 315 series ------ */ 52548c2ecf20Sopenharmony_ci 52558c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* 315 - LVDS */ 52568c2ecf20Sopenharmony_ci 52578c2ecf20Sopenharmony_ci tempbl = 0; 52588c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) && 52598c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { 52608c2ecf20Sopenharmony_ci tempah = infoflag >> 8; 52618c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDSync) { 52628c2ecf20Sopenharmony_ci tempbl = ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6); 52638c2ecf20Sopenharmony_ci } 52648c2ecf20Sopenharmony_ci } else if((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) && 52658c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050)) { 52668c2ecf20Sopenharmony_ci tempah = infoflag >> 8; 52678c2ecf20Sopenharmony_ci tempbl = 0x03; 52688c2ecf20Sopenharmony_ci } else { 52698c2ecf20Sopenharmony_ci tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); 52708c2ecf20Sopenharmony_ci tempbl = (tempah >> 6) & 0x03; 52718c2ecf20Sopenharmony_ci tempbl |= 0x08; 52728c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempbl |= 0x04; 52738c2ecf20Sopenharmony_ci } 52748c2ecf20Sopenharmony_ci tempah &= 0xC0; 52758c2ecf20Sopenharmony_ci tempah |= 0x20; 52768c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; 52778c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) tempah |= 0xc0; 52788c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); 52798c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 52808c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 52818c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); 52828c2ecf20Sopenharmony_ci } 52838c2ecf20Sopenharmony_ci } 52848c2ecf20Sopenharmony_ci 52858c2ecf20Sopenharmony_ci } else { /* 315 - TMDS */ 52868c2ecf20Sopenharmony_ci 52878c2ecf20Sopenharmony_ci tempah = tempbl = infoflag >> 8; 52888c2ecf20Sopenharmony_ci if(!SiS_Pr->UseCustomMode) { 52898c2ecf20Sopenharmony_ci tempbl = 0; 52908c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_SIS30xC) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { 52918c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 52928c2ecf20Sopenharmony_ci tempah = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); 52938c2ecf20Sopenharmony_ci } 52948c2ecf20Sopenharmony_ci } 52958c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 52968c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 52978c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDSync) { 52988c2ecf20Sopenharmony_ci tempah = SiS_Pr->SiS_LCDInfo; 52998c2ecf20Sopenharmony_ci tempbl = (tempah >> 6) & 0x03; 53008c2ecf20Sopenharmony_ci } 53018c2ecf20Sopenharmony_ci } 53028c2ecf20Sopenharmony_ci } 53038c2ecf20Sopenharmony_ci } 53048c2ecf20Sopenharmony_ci tempah &= 0xC0; 53058c2ecf20Sopenharmony_ci tempah |= 0x20; 53068c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; 53078c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_NoLCD) { 53088c2ecf20Sopenharmony_ci /* Imitate BIOS bug */ 53098c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah |= 0xc0; 53108c2ecf20Sopenharmony_ci } 53118c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_SIS30xC) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { 53128c2ecf20Sopenharmony_ci tempah >>= 3; 53138c2ecf20Sopenharmony_ci tempah &= 0x18; 53148c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xe7,tempah); 53158c2ecf20Sopenharmony_ci } else { 53168c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); 53178c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 53188c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 53198c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); 53208c2ecf20Sopenharmony_ci } 53218c2ecf20Sopenharmony_ci } 53228c2ecf20Sopenharmony_ci } 53238c2ecf20Sopenharmony_ci 53248c2ecf20Sopenharmony_ci } 53258c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_315 */ 53268c2ecf20Sopenharmony_ci } 53278c2ecf20Sopenharmony_ci } 53288c2ecf20Sopenharmony_ci} 53298c2ecf20Sopenharmony_ci 53308c2ecf20Sopenharmony_ci/* Set CRT2 FIFO on 300/540/630/730 */ 53318c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 53328c2ecf20Sopenharmony_cistatic void 53338c2ecf20Sopenharmony_ciSiS_SetCRT2FIFO_300(struct SiS_Private *SiS_Pr,unsigned short ModeNo) 53348c2ecf20Sopenharmony_ci{ 53358c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 53368c2ecf20Sopenharmony_ci unsigned short temp, index, modeidindex, refreshratetableindex; 53378c2ecf20Sopenharmony_ci unsigned short VCLK = 0, MCLK, colorth = 0, data2 = 0; 53388c2ecf20Sopenharmony_ci unsigned short tempbx, tempcl, CRT1ModeNo, CRT2ModeNo, SelectRate_backup; 53398c2ecf20Sopenharmony_ci unsigned int data, pci50, pciA0; 53408c2ecf20Sopenharmony_ci static const unsigned char colortharray[] = { 53418c2ecf20Sopenharmony_ci 1, 1, 2, 2, 3, 4 53428c2ecf20Sopenharmony_ci }; 53438c2ecf20Sopenharmony_ci 53448c2ecf20Sopenharmony_ci SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate; 53458c2ecf20Sopenharmony_ci 53468c2ecf20Sopenharmony_ci if(!SiS_Pr->CRT1UsesCustomMode) { 53478c2ecf20Sopenharmony_ci 53488c2ecf20Sopenharmony_ci CRT1ModeNo = SiS_Pr->SiS_CRT1Mode; /* get CRT1 ModeNo */ 53498c2ecf20Sopenharmony_ci SiS_SearchModeID(SiS_Pr, &CRT1ModeNo, &modeidindex); 53508c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); 53518c2ecf20Sopenharmony_ci SiS_Pr->SiS_SelectCRT2Rate = 0; 53528c2ecf20Sopenharmony_ci refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT1ModeNo, modeidindex); 53538c2ecf20Sopenharmony_ci 53548c2ecf20Sopenharmony_ci if(CRT1ModeNo >= 0x13) { 53558c2ecf20Sopenharmony_ci /* Get VCLK */ 53568c2ecf20Sopenharmony_ci index = SiS_GetRefCRTVCLK(SiS_Pr, refreshratetableindex, SiS_Pr->SiS_UseWide); 53578c2ecf20Sopenharmony_ci VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; 53588c2ecf20Sopenharmony_ci 53598c2ecf20Sopenharmony_ci /* Get colordepth */ 53608c2ecf20Sopenharmony_ci colorth = SiS_GetColorDepth(SiS_Pr,CRT1ModeNo,modeidindex) >> 1; 53618c2ecf20Sopenharmony_ci if(!colorth) colorth++; 53628c2ecf20Sopenharmony_ci } 53638c2ecf20Sopenharmony_ci 53648c2ecf20Sopenharmony_ci } else { 53658c2ecf20Sopenharmony_ci 53668c2ecf20Sopenharmony_ci CRT1ModeNo = 0xfe; 53678c2ecf20Sopenharmony_ci 53688c2ecf20Sopenharmony_ci /* Get VCLK */ 53698c2ecf20Sopenharmony_ci VCLK = SiS_Pr->CSRClock_CRT1; 53708c2ecf20Sopenharmony_ci 53718c2ecf20Sopenharmony_ci /* Get color depth */ 53728c2ecf20Sopenharmony_ci colorth = colortharray[((SiS_Pr->CModeFlag_CRT1 & ModeTypeMask) - 2)]; 53738c2ecf20Sopenharmony_ci 53748c2ecf20Sopenharmony_ci } 53758c2ecf20Sopenharmony_ci 53768c2ecf20Sopenharmony_ci if(CRT1ModeNo >= 0x13) { 53778c2ecf20Sopenharmony_ci /* Get MCLK */ 53788c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_300) { 53798c2ecf20Sopenharmony_ci index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A); 53808c2ecf20Sopenharmony_ci } else { 53818c2ecf20Sopenharmony_ci index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A); 53828c2ecf20Sopenharmony_ci } 53838c2ecf20Sopenharmony_ci index &= 0x07; 53848c2ecf20Sopenharmony_ci MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; 53858c2ecf20Sopenharmony_ci 53868c2ecf20Sopenharmony_ci temp = ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) >> 6) & 0x03) << 1; 53878c2ecf20Sopenharmony_ci if(!temp) temp++; 53888c2ecf20Sopenharmony_ci temp <<= 2; 53898c2ecf20Sopenharmony_ci 53908c2ecf20Sopenharmony_ci data2 = temp - ((colorth * VCLK) / MCLK); 53918c2ecf20Sopenharmony_ci 53928c2ecf20Sopenharmony_ci temp = (28 * 16) % data2; 53938c2ecf20Sopenharmony_ci data2 = (28 * 16) / data2; 53948c2ecf20Sopenharmony_ci if(temp) data2++; 53958c2ecf20Sopenharmony_ci 53968c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_300) { 53978c2ecf20Sopenharmony_ci 53988c2ecf20Sopenharmony_ci SiS_GetFIFOThresholdIndex300(SiS_Pr, &tempbx, &tempcl); 53998c2ecf20Sopenharmony_ci data = SiS_GetFIFOThresholdB300(tempbx, tempcl); 54008c2ecf20Sopenharmony_ci 54018c2ecf20Sopenharmony_ci } else { 54028c2ecf20Sopenharmony_ci 54038c2ecf20Sopenharmony_ci pci50 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50); 54048c2ecf20Sopenharmony_ci pciA0 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xa0); 54058c2ecf20Sopenharmony_ci 54068c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_730) { 54078c2ecf20Sopenharmony_ci 54088c2ecf20Sopenharmony_ci index = (unsigned short)(((pciA0 >> 28) & 0x0f) * 3); 54098c2ecf20Sopenharmony_ci index += (unsigned short)(((pci50 >> 9)) & 0x03); 54108c2ecf20Sopenharmony_ci 54118c2ecf20Sopenharmony_ci /* BIOS BUG (2.04.5d, 2.04.6a use ah here, which is unset!) */ 54128c2ecf20Sopenharmony_ci index = 0; /* -- do it like the BIOS anyway... */ 54138c2ecf20Sopenharmony_ci 54148c2ecf20Sopenharmony_ci } else { 54158c2ecf20Sopenharmony_ci 54168c2ecf20Sopenharmony_ci pci50 >>= 24; 54178c2ecf20Sopenharmony_ci pciA0 >>= 24; 54188c2ecf20Sopenharmony_ci 54198c2ecf20Sopenharmony_ci index = (pci50 >> 1) & 0x07; 54208c2ecf20Sopenharmony_ci 54218c2ecf20Sopenharmony_ci if(pci50 & 0x01) index += 6; 54228c2ecf20Sopenharmony_ci if(!(pciA0 & 0x01)) index += 24; 54238c2ecf20Sopenharmony_ci 54248c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x80) index += 12; 54258c2ecf20Sopenharmony_ci 54268c2ecf20Sopenharmony_ci } 54278c2ecf20Sopenharmony_ci 54288c2ecf20Sopenharmony_ci data = SiS_GetLatencyFactor630(SiS_Pr, index) + 15; 54298c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x80)) data += 5; 54308c2ecf20Sopenharmony_ci 54318c2ecf20Sopenharmony_ci } 54328c2ecf20Sopenharmony_ci 54338c2ecf20Sopenharmony_ci data += data2; /* CRT1 Request Period */ 54348c2ecf20Sopenharmony_ci 54358c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; 54368c2ecf20Sopenharmony_ci SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; 54378c2ecf20Sopenharmony_ci 54388c2ecf20Sopenharmony_ci if(!SiS_Pr->UseCustomMode) { 54398c2ecf20Sopenharmony_ci 54408c2ecf20Sopenharmony_ci CRT2ModeNo = ModeNo; 54418c2ecf20Sopenharmony_ci SiS_SearchModeID(SiS_Pr, &CRT2ModeNo, &modeidindex); 54428c2ecf20Sopenharmony_ci 54438c2ecf20Sopenharmony_ci refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT2ModeNo, modeidindex); 54448c2ecf20Sopenharmony_ci 54458c2ecf20Sopenharmony_ci /* Get VCLK */ 54468c2ecf20Sopenharmony_ci index = SiS_GetVCLK2Ptr(SiS_Pr, CRT2ModeNo, modeidindex, refreshratetableindex); 54478c2ecf20Sopenharmony_ci VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; 54488c2ecf20Sopenharmony_ci 54498c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { 54508c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 54518c2ecf20Sopenharmony_ci if(ROMAddr[0x220] & 0x01) { 54528c2ecf20Sopenharmony_ci VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8); 54538c2ecf20Sopenharmony_ci } 54548c2ecf20Sopenharmony_ci } 54558c2ecf20Sopenharmony_ci } 54568c2ecf20Sopenharmony_ci 54578c2ecf20Sopenharmony_ci } else { 54588c2ecf20Sopenharmony_ci 54598c2ecf20Sopenharmony_ci /* Get VCLK */ 54608c2ecf20Sopenharmony_ci CRT2ModeNo = 0xfe; 54618c2ecf20Sopenharmony_ci VCLK = SiS_Pr->CSRClock; 54628c2ecf20Sopenharmony_ci 54638c2ecf20Sopenharmony_ci } 54648c2ecf20Sopenharmony_ci 54658c2ecf20Sopenharmony_ci /* Get colordepth */ 54668c2ecf20Sopenharmony_ci colorth = SiS_GetColorDepth(SiS_Pr,CRT2ModeNo,modeidindex) >> 1; 54678c2ecf20Sopenharmony_ci if(!colorth) colorth++; 54688c2ecf20Sopenharmony_ci 54698c2ecf20Sopenharmony_ci data = data * VCLK * colorth; 54708c2ecf20Sopenharmony_ci temp = data % (MCLK << 4); 54718c2ecf20Sopenharmony_ci data = data / (MCLK << 4); 54728c2ecf20Sopenharmony_ci if(temp) data++; 54738c2ecf20Sopenharmony_ci 54748c2ecf20Sopenharmony_ci if(data < 6) data = 6; 54758c2ecf20Sopenharmony_ci else if(data > 0x14) data = 0x14; 54768c2ecf20Sopenharmony_ci 54778c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_300) { 54788c2ecf20Sopenharmony_ci temp = 0x16; 54798c2ecf20Sopenharmony_ci if((data <= 0x0f) || (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) 54808c2ecf20Sopenharmony_ci temp = 0x13; 54818c2ecf20Sopenharmony_ci } else { 54828c2ecf20Sopenharmony_ci temp = 0x16; 54838c2ecf20Sopenharmony_ci if(( (SiS_Pr->ChipType == SIS_630) || 54848c2ecf20Sopenharmony_ci (SiS_Pr->ChipType == SIS_730) ) && 54858c2ecf20Sopenharmony_ci (SiS_Pr->ChipRevision >= 0x30)) 54868c2ecf20Sopenharmony_ci temp = 0x1b; 54878c2ecf20Sopenharmony_ci } 54888c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0xe0,temp); 54898c2ecf20Sopenharmony_ci 54908c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType == SIS_630) && 54918c2ecf20Sopenharmony_ci (SiS_Pr->ChipRevision >= 0x30)) { 54928c2ecf20Sopenharmony_ci if(data > 0x13) data = 0x13; 54938c2ecf20Sopenharmony_ci } 54948c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,0xe0,data); 54958c2ecf20Sopenharmony_ci 54968c2ecf20Sopenharmony_ci } else { /* If mode <= 0x13, we just restore everything */ 54978c2ecf20Sopenharmony_ci 54988c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; 54998c2ecf20Sopenharmony_ci SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; 55008c2ecf20Sopenharmony_ci 55018c2ecf20Sopenharmony_ci } 55028c2ecf20Sopenharmony_ci} 55038c2ecf20Sopenharmony_ci#endif 55048c2ecf20Sopenharmony_ci 55058c2ecf20Sopenharmony_ci/* Set CRT2 FIFO on 315/330 series */ 55068c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 55078c2ecf20Sopenharmony_cistatic void 55088c2ecf20Sopenharmony_ciSiS_SetCRT2FIFO_310(struct SiS_Private *SiS_Pr) 55098c2ecf20Sopenharmony_ci{ 55108c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,0x3B); 55118c2ecf20Sopenharmony_ci if( (SiS_Pr->ChipType == SIS_760) && 55128c2ecf20Sopenharmony_ci (SiS_Pr->SiS_SysFlags & SF_760LFB) && 55138c2ecf20Sopenharmony_ci (SiS_Pr->SiS_ModeType == Mode32Bpp) && 55148c2ecf20Sopenharmony_ci (SiS_Pr->SiS_VGAHDE >= 1280) && 55158c2ecf20Sopenharmony_ci (SiS_Pr->SiS_VGAVDE >= 1024) ) { 55168c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2f,0x03); 55178c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,0x3b); 55188c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4d,0xc0); 55198c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2f,0x01); 55208c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4d,0xc0); 55218c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,0x6e); 55228c2ecf20Sopenharmony_ci } else { 55238c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,~0x3f,0x04); 55248c2ecf20Sopenharmony_ci } 55258c2ecf20Sopenharmony_ci 55268c2ecf20Sopenharmony_ci} 55278c2ecf20Sopenharmony_ci#endif 55288c2ecf20Sopenharmony_ci 55298c2ecf20Sopenharmony_cistatic unsigned short 55308c2ecf20Sopenharmony_ciSiS_GetVGAHT2(struct SiS_Private *SiS_Pr) 55318c2ecf20Sopenharmony_ci{ 55328c2ecf20Sopenharmony_ci unsigned int tempax,tempbx; 55338c2ecf20Sopenharmony_ci 55348c2ecf20Sopenharmony_ci tempbx = (SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) * SiS_Pr->SiS_RVBHCMAX; 55358c2ecf20Sopenharmony_ci tempax = (SiS_Pr->SiS_VT - SiS_Pr->SiS_VDE) * SiS_Pr->SiS_RVBHCFACT; 55368c2ecf20Sopenharmony_ci tempax = (tempax * SiS_Pr->SiS_HT) / tempbx; 55378c2ecf20Sopenharmony_ci return (unsigned short)tempax; 55388c2ecf20Sopenharmony_ci} 55398c2ecf20Sopenharmony_ci 55408c2ecf20Sopenharmony_ci/* Set Part 1 / SiS bridge slave mode */ 55418c2ecf20Sopenharmony_cistatic void 55428c2ecf20Sopenharmony_ciSiS_SetGroup1_301(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex, 55438c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 55448c2ecf20Sopenharmony_ci{ 55458c2ecf20Sopenharmony_ci unsigned short temp, modeflag, i, j, xres=0, VGAVDE; 55468c2ecf20Sopenharmony_ci static const unsigned short CRTranslation[] = { 55478c2ecf20Sopenharmony_ci /* CR0 CR1 CR2 CR3 CR4 CR5 CR6 CR7 */ 55488c2ecf20Sopenharmony_ci 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 55498c2ecf20Sopenharmony_ci /* CR8 CR9 SR0A SR0B SR0C SR0D SR0E CR0F */ 55508c2ecf20Sopenharmony_ci 0x00, 0x0b, 0x17, 0x18, 0x19, 0x00, 0x1a, 0x00, 55518c2ecf20Sopenharmony_ci /* CR10 CR11 CR12 CR13 CR14 CR15 CR16 CR17 */ 55528c2ecf20Sopenharmony_ci 0x0c, 0x0d, 0x0e, 0x00, 0x0f, 0x10, 0x11, 0x00 55538c2ecf20Sopenharmony_ci }; 55548c2ecf20Sopenharmony_ci 55558c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 55568c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 55578c2ecf20Sopenharmony_ci } else if(SiS_Pr->UseCustomMode) { 55588c2ecf20Sopenharmony_ci modeflag = SiS_Pr->CModeFlag; 55598c2ecf20Sopenharmony_ci xres = SiS_Pr->CHDisplay; 55608c2ecf20Sopenharmony_ci } else { 55618c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 55628c2ecf20Sopenharmony_ci xres = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes; 55638c2ecf20Sopenharmony_ci } 55648c2ecf20Sopenharmony_ci 55658c2ecf20Sopenharmony_ci /* The following is only done if bridge is in slave mode: */ 55668c2ecf20Sopenharmony_ci 55678c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 55688c2ecf20Sopenharmony_ci if(xres >= 1600) { /* BIOS: == 1600 */ 55698c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x31,0x04); 55708c2ecf20Sopenharmony_ci } 55718c2ecf20Sopenharmony_ci } 55728c2ecf20Sopenharmony_ci 55738c2ecf20Sopenharmony_ci SiS_Pr->CHTotal = 8224; /* Max HT, 0x2020, results in 0x3ff in registers */ 55748c2ecf20Sopenharmony_ci 55758c2ecf20Sopenharmony_ci SiS_Pr->CHDisplay = SiS_Pr->SiS_VGAHDE; 55768c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) SiS_Pr->CHDisplay >>= 1; 55778c2ecf20Sopenharmony_ci 55788c2ecf20Sopenharmony_ci SiS_Pr->CHBlankStart = SiS_Pr->CHDisplay; 55798c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 55808c2ecf20Sopenharmony_ci SiS_Pr->CHBlankStart += 16; 55818c2ecf20Sopenharmony_ci } 55828c2ecf20Sopenharmony_ci 55838c2ecf20Sopenharmony_ci SiS_Pr->CHBlankEnd = 32; 55848c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 55858c2ecf20Sopenharmony_ci if(xres == 1600) SiS_Pr->CHBlankEnd += 80; 55868c2ecf20Sopenharmony_ci } 55878c2ecf20Sopenharmony_ci 55888c2ecf20Sopenharmony_ci temp = SiS_Pr->SiS_VGAHT - 96; 55898c2ecf20Sopenharmony_ci if(!(modeflag & HalfDCLK)) temp -= 32; 55908c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDPass11) { 55918c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x04); 55928c2ecf20Sopenharmony_ci temp |= ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x0b) & 0xc0) << 2); 55938c2ecf20Sopenharmony_ci temp -= 3; 55948c2ecf20Sopenharmony_ci temp <<= 3; 55958c2ecf20Sopenharmony_ci } else { 55968c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_RVBHRS2) temp = SiS_Pr->SiS_RVBHRS2; 55978c2ecf20Sopenharmony_ci } 55988c2ecf20Sopenharmony_ci SiS_Pr->CHSyncStart = temp; 55998c2ecf20Sopenharmony_ci 56008c2ecf20Sopenharmony_ci SiS_Pr->CHSyncEnd = 0xffe8; /* results in 0x2000 in registers */ 56018c2ecf20Sopenharmony_ci 56028c2ecf20Sopenharmony_ci SiS_Pr->CVTotal = 2049; /* Max VT, 0x0801, results in 0x7ff in registers */ 56038c2ecf20Sopenharmony_ci 56048c2ecf20Sopenharmony_ci VGAVDE = SiS_Pr->SiS_VGAVDE; 56058c2ecf20Sopenharmony_ci if (VGAVDE == 357) VGAVDE = 350; 56068c2ecf20Sopenharmony_ci else if(VGAVDE == 360) VGAVDE = 350; 56078c2ecf20Sopenharmony_ci else if(VGAVDE == 375) VGAVDE = 350; 56088c2ecf20Sopenharmony_ci else if(VGAVDE == 405) VGAVDE = 400; 56098c2ecf20Sopenharmony_ci else if(VGAVDE == 420) VGAVDE = 400; 56108c2ecf20Sopenharmony_ci else if(VGAVDE == 525) VGAVDE = 480; 56118c2ecf20Sopenharmony_ci else if(VGAVDE == 1056) VGAVDE = 1024; 56128c2ecf20Sopenharmony_ci SiS_Pr->CVDisplay = VGAVDE; 56138c2ecf20Sopenharmony_ci 56148c2ecf20Sopenharmony_ci SiS_Pr->CVBlankStart = SiS_Pr->CVDisplay; 56158c2ecf20Sopenharmony_ci 56168c2ecf20Sopenharmony_ci SiS_Pr->CVBlankEnd = 1; 56178c2ecf20Sopenharmony_ci if(ModeNo == 0x3c) SiS_Pr->CVBlankEnd = 226; 56188c2ecf20Sopenharmony_ci 56198c2ecf20Sopenharmony_ci temp = (SiS_Pr->SiS_VGAVT - VGAVDE) >> 1; 56208c2ecf20Sopenharmony_ci SiS_Pr->CVSyncStart = VGAVDE + temp; 56218c2ecf20Sopenharmony_ci 56228c2ecf20Sopenharmony_ci temp >>= 3; 56238c2ecf20Sopenharmony_ci SiS_Pr->CVSyncEnd = SiS_Pr->CVSyncStart + temp; 56248c2ecf20Sopenharmony_ci 56258c2ecf20Sopenharmony_ci SiS_CalcCRRegisters(SiS_Pr, 0); 56268c2ecf20Sopenharmony_ci SiS_Pr->CCRT1CRTC[16] &= ~0xE0; 56278c2ecf20Sopenharmony_ci 56288c2ecf20Sopenharmony_ci for(i = 0; i <= 7; i++) { 56298c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[i]); 56308c2ecf20Sopenharmony_ci } 56318c2ecf20Sopenharmony_ci for(i = 0x10, j = 8; i <= 0x12; i++, j++) { 56328c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[j]); 56338c2ecf20Sopenharmony_ci } 56348c2ecf20Sopenharmony_ci for(i = 0x15, j = 11; i <= 0x16; i++, j++) { 56358c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[j]); 56368c2ecf20Sopenharmony_ci } 56378c2ecf20Sopenharmony_ci for(i = 0x0a, j = 13; i <= 0x0c; i++, j++) { 56388c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[j]); 56398c2ecf20Sopenharmony_ci } 56408c2ecf20Sopenharmony_ci 56418c2ecf20Sopenharmony_ci temp = SiS_Pr->CCRT1CRTC[16] & 0xE0; 56428c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,CRTranslation[0x0E],0x1F,temp); 56438c2ecf20Sopenharmony_ci 56448c2ecf20Sopenharmony_ci temp = (SiS_Pr->CCRT1CRTC[16] & 0x01) << 5; 56458c2ecf20Sopenharmony_ci if(modeflag & DoubleScanMode) temp |= 0x80; 56468c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,CRTranslation[0x09],0x5F,temp); 56478c2ecf20Sopenharmony_ci 56488c2ecf20Sopenharmony_ci temp = 0; 56498c2ecf20Sopenharmony_ci temp |= (SiS_GetReg(SiS_Pr->SiS_P3c4,0x01) & 0x01); 56508c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) temp |= 0x08; 56518c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* SR01: HalfDCLK[3], 8/9 div dotclock[0] */ 56528c2ecf20Sopenharmony_ci 56538c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* CR14: (text mode: underline location) */ 56548c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,0x00); /* CR17: n/a */ 56558c2ecf20Sopenharmony_ci 56568c2ecf20Sopenharmony_ci temp = 0; 56578c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { 56588c2ecf20Sopenharmony_ci temp = (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) << 7; 56598c2ecf20Sopenharmony_ci } 56608c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* SR0E, dither[7] */ 56618c2ecf20Sopenharmony_ci 56628c2ecf20Sopenharmony_ci temp = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); 56638c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); /* ? */ 56648c2ecf20Sopenharmony_ci} 56658c2ecf20Sopenharmony_ci 56668c2ecf20Sopenharmony_ci/* Setup panel link 56678c2ecf20Sopenharmony_ci * This is used for LVDS, LCDA and Chrontel TV output 56688c2ecf20Sopenharmony_ci * 300/LVDS+TV, 300/301B-DH, 315/LVDS+TV, 315/LCDA 56698c2ecf20Sopenharmony_ci */ 56708c2ecf20Sopenharmony_cistatic void 56718c2ecf20Sopenharmony_ciSiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 56728c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 56738c2ecf20Sopenharmony_ci{ 56748c2ecf20Sopenharmony_ci unsigned short modeflag, resinfo = 0; 56758c2ecf20Sopenharmony_ci unsigned short push2, tempax, tempbx, tempcx, temp; 56768c2ecf20Sopenharmony_ci unsigned int tempeax = 0, tempebx, tempecx, tempvcfact = 0; 56778c2ecf20Sopenharmony_ci bool islvds = false, issis = false, chkdclkfirst = false; 56788c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 56798c2ecf20Sopenharmony_ci unsigned short crt2crtc = 0; 56808c2ecf20Sopenharmony_ci#endif 56818c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 56828c2ecf20Sopenharmony_ci unsigned short pushcx; 56838c2ecf20Sopenharmony_ci#endif 56848c2ecf20Sopenharmony_ci 56858c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 56868c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 56878c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; 56888c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 56898c2ecf20Sopenharmony_ci crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 56908c2ecf20Sopenharmony_ci#endif 56918c2ecf20Sopenharmony_ci } else if(SiS_Pr->UseCustomMode) { 56928c2ecf20Sopenharmony_ci modeflag = SiS_Pr->CModeFlag; 56938c2ecf20Sopenharmony_ci } else { 56948c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 56958c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 56968c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 56978c2ecf20Sopenharmony_ci crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 56988c2ecf20Sopenharmony_ci#endif 56998c2ecf20Sopenharmony_ci } 57008c2ecf20Sopenharmony_ci 57018c2ecf20Sopenharmony_ci /* is lvds if really LVDS, or 301B-DH with external LVDS transmitter */ 57028c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBType & VB_NoLCD)) { 57038c2ecf20Sopenharmony_ci islvds = true; 57048c2ecf20Sopenharmony_ci } 57058c2ecf20Sopenharmony_ci 57068c2ecf20Sopenharmony_ci /* is really sis if sis bridge, but not 301B-DH */ 57078c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { 57088c2ecf20Sopenharmony_ci issis = true; 57098c2ecf20Sopenharmony_ci } 57108c2ecf20Sopenharmony_ci 57118c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType >= SIS_315H) && (islvds) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA))) { 57128c2ecf20Sopenharmony_ci if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { 57138c2ecf20Sopenharmony_ci chkdclkfirst = true; 57148c2ecf20Sopenharmony_ci } 57158c2ecf20Sopenharmony_ci } 57168c2ecf20Sopenharmony_ci 57178c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 57188c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 57198c2ecf20Sopenharmony_ci if(IS_SIS330) { 57208c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); 57218c2ecf20Sopenharmony_ci } else if(IS_SIS740) { 57228c2ecf20Sopenharmony_ci if(islvds) { 57238c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04); 57248c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x03); 57258c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 57268c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); 57278c2ecf20Sopenharmony_ci } 57288c2ecf20Sopenharmony_ci } else { 57298c2ecf20Sopenharmony_ci if(islvds) { 57308c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04); 57318c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x00); 57328c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 57338c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2D,0x0f); 57348c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xC) { 57358c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDResInfo == Panel_1024x768) || 57368c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { 57378c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x20); 57388c2ecf20Sopenharmony_ci } 57398c2ecf20Sopenharmony_ci } 57408c2ecf20Sopenharmony_ci } 57418c2ecf20Sopenharmony_ci } 57428c2ecf20Sopenharmony_ci } 57438c2ecf20Sopenharmony_ci#endif 57448c2ecf20Sopenharmony_ci 57458c2ecf20Sopenharmony_ci /* Horizontal */ 57468c2ecf20Sopenharmony_ci 57478c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_LCDHDES; 57488c2ecf20Sopenharmony_ci if(islvds) { 57498c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 57508c2ecf20Sopenharmony_ci if(!SiS_Pr->SiS_IF_DEF_FSTN && !SiS_Pr->SiS_IF_DEF_DSTN) { 57518c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) && 57528c2ecf20Sopenharmony_ci (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { 57538c2ecf20Sopenharmony_ci tempax -= 8; 57548c2ecf20Sopenharmony_ci } 57558c2ecf20Sopenharmony_ci } 57568c2ecf20Sopenharmony_ci } 57578c2ecf20Sopenharmony_ci } 57588c2ecf20Sopenharmony_ci 57598c2ecf20Sopenharmony_ci temp = (tempax & 0x0007); 57608c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* BPLHDESKEW[2:0] */ 57618c2ecf20Sopenharmony_ci temp = (tempax >> 3) & 0x00FF; 57628c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* BPLHDESKEW[10:3] */ 57638c2ecf20Sopenharmony_ci 57648c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_HDE; 57658c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 57668c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 57678c2ecf20Sopenharmony_ci tempbx = SiS_Pr->PanelXRes; 57688c2ecf20Sopenharmony_ci } 57698c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDResInfo == Panel_320x240_1) || 57708c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_320x240_2) || 57718c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_320x240_3)) { 57728c2ecf20Sopenharmony_ci tempbx >>= 1; 57738c2ecf20Sopenharmony_ci } 57748c2ecf20Sopenharmony_ci } 57758c2ecf20Sopenharmony_ci 57768c2ecf20Sopenharmony_ci tempax += tempbx; 57778c2ecf20Sopenharmony_ci if(tempax >= SiS_Pr->SiS_HT) tempax -= SiS_Pr->SiS_HT; 57788c2ecf20Sopenharmony_ci 57798c2ecf20Sopenharmony_ci temp = tempax; 57808c2ecf20Sopenharmony_ci if(temp & 0x07) temp += 8; 57818c2ecf20Sopenharmony_ci temp >>= 3; 57828c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* BPLHDEE */ 57838c2ecf20Sopenharmony_ci 57848c2ecf20Sopenharmony_ci tempcx = (SiS_Pr->SiS_HT - tempbx) >> 2; 57858c2ecf20Sopenharmony_ci 57868c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 57878c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 57888c2ecf20Sopenharmony_ci if(SiS_Pr->PanelHRS != 999) tempcx = SiS_Pr->PanelHRS; 57898c2ecf20Sopenharmony_ci } 57908c2ecf20Sopenharmony_ci } 57918c2ecf20Sopenharmony_ci 57928c2ecf20Sopenharmony_ci tempcx += tempax; 57938c2ecf20Sopenharmony_ci if(tempcx >= SiS_Pr->SiS_HT) tempcx -= SiS_Pr->SiS_HT; 57948c2ecf20Sopenharmony_ci 57958c2ecf20Sopenharmony_ci temp = (tempcx >> 3) & 0x00FF; 57968c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 57978c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_TRUMPION) { 57988c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 57998c2ecf20Sopenharmony_ci switch(ModeNo) { 58008c2ecf20Sopenharmony_ci case 0x04: 58018c2ecf20Sopenharmony_ci case 0x05: 58028c2ecf20Sopenharmony_ci case 0x0d: temp = 0x56; break; 58038c2ecf20Sopenharmony_ci case 0x10: temp = 0x60; break; 58048c2ecf20Sopenharmony_ci case 0x13: temp = 0x5f; break; 58058c2ecf20Sopenharmony_ci case 0x40: 58068c2ecf20Sopenharmony_ci case 0x41: 58078c2ecf20Sopenharmony_ci case 0x4f: 58088c2ecf20Sopenharmony_ci case 0x43: 58098c2ecf20Sopenharmony_ci case 0x44: 58108c2ecf20Sopenharmony_ci case 0x62: 58118c2ecf20Sopenharmony_ci case 0x56: 58128c2ecf20Sopenharmony_ci case 0x53: 58138c2ecf20Sopenharmony_ci case 0x5d: 58148c2ecf20Sopenharmony_ci case 0x5e: temp = 0x54; break; 58158c2ecf20Sopenharmony_ci } 58168c2ecf20Sopenharmony_ci } 58178c2ecf20Sopenharmony_ci } 58188c2ecf20Sopenharmony_ci } 58198c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,temp); /* BPLHRS */ 58208c2ecf20Sopenharmony_ci 58218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 58228c2ecf20Sopenharmony_ci temp += 2; 58238c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 58248c2ecf20Sopenharmony_ci temp += 8; 58258c2ecf20Sopenharmony_ci if(SiS_Pr->PanelHRE != 999) { 58268c2ecf20Sopenharmony_ci temp = tempcx + SiS_Pr->PanelHRE; 58278c2ecf20Sopenharmony_ci if(temp >= SiS_Pr->SiS_HT) temp -= SiS_Pr->SiS_HT; 58288c2ecf20Sopenharmony_ci temp >>= 3; 58298c2ecf20Sopenharmony_ci } 58308c2ecf20Sopenharmony_ci } 58318c2ecf20Sopenharmony_ci } else { 58328c2ecf20Sopenharmony_ci temp += 10; 58338c2ecf20Sopenharmony_ci } 58348c2ecf20Sopenharmony_ci 58358c2ecf20Sopenharmony_ci temp &= 0x1F; 58368c2ecf20Sopenharmony_ci temp |= ((tempcx & 0x07) << 5); 58378c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,temp); /* BPLHRE */ 58388c2ecf20Sopenharmony_ci 58398c2ecf20Sopenharmony_ci /* Vertical */ 58408c2ecf20Sopenharmony_ci 58418c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_VGAVDE; 58428c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 58438c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 58448c2ecf20Sopenharmony_ci tempax = SiS_Pr->PanelYRes; 58458c2ecf20Sopenharmony_ci } 58468c2ecf20Sopenharmony_ci } 58478c2ecf20Sopenharmony_ci 58488c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_LCDVDES + tempax; 58498c2ecf20Sopenharmony_ci if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; 58508c2ecf20Sopenharmony_ci 58518c2ecf20Sopenharmony_ci push2 = tempbx; 58528c2ecf20Sopenharmony_ci 58538c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE; 58548c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 58558c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 58568c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 58578c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->PanelYRes; 58588c2ecf20Sopenharmony_ci } 58598c2ecf20Sopenharmony_ci } 58608c2ecf20Sopenharmony_ci } 58618c2ecf20Sopenharmony_ci if(islvds) tempcx >>= 1; 58628c2ecf20Sopenharmony_ci else tempcx >>= 2; 58638c2ecf20Sopenharmony_ci 58648c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) && 58658c2ecf20Sopenharmony_ci (!(SiS_Pr->SiS_LCDInfo & LCDPass11)) && 58668c2ecf20Sopenharmony_ci (SiS_Pr->PanelVRS != 999) ) { 58678c2ecf20Sopenharmony_ci tempcx = SiS_Pr->PanelVRS; 58688c2ecf20Sopenharmony_ci tempbx += tempcx; 58698c2ecf20Sopenharmony_ci if(issis) tempbx++; 58708c2ecf20Sopenharmony_ci } else { 58718c2ecf20Sopenharmony_ci tempbx += tempcx; 58728c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) tempbx++; 58738c2ecf20Sopenharmony_ci else if(issis) tempbx++; 58748c2ecf20Sopenharmony_ci } 58758c2ecf20Sopenharmony_ci 58768c2ecf20Sopenharmony_ci if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; 58778c2ecf20Sopenharmony_ci 58788c2ecf20Sopenharmony_ci temp = tempbx & 0x00FF; 58798c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_TRUMPION) { 58808c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 58818c2ecf20Sopenharmony_ci if(ModeNo == 0x10) temp = 0xa9; 58828c2ecf20Sopenharmony_ci } 58838c2ecf20Sopenharmony_ci } 58848c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); /* BPLVRS */ 58858c2ecf20Sopenharmony_ci 58868c2ecf20Sopenharmony_ci tempcx >>= 3; 58878c2ecf20Sopenharmony_ci tempcx++; 58888c2ecf20Sopenharmony_ci 58898c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 58908c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 58918c2ecf20Sopenharmony_ci if(SiS_Pr->PanelVRE != 999) tempcx = SiS_Pr->PanelVRE; 58928c2ecf20Sopenharmony_ci } 58938c2ecf20Sopenharmony_ci } 58948c2ecf20Sopenharmony_ci 58958c2ecf20Sopenharmony_ci tempcx += tempbx; 58968c2ecf20Sopenharmony_ci temp = tempcx & 0x000F; 58978c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp); /* BPLVRE */ 58988c2ecf20Sopenharmony_ci 58998c2ecf20Sopenharmony_ci temp = ((tempbx >> 8) & 0x07) << 3; 59008c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) { 59018c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_HDE != 640) { 59028c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40; 59038c2ecf20Sopenharmony_ci } 59048c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40; 59058c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40; 59068c2ecf20Sopenharmony_ci tempbx = 0x87; 59078c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType >= SIS_315H) || 59088c2ecf20Sopenharmony_ci (SiS_Pr->ChipRevision >= 0x30)) { 59098c2ecf20Sopenharmony_ci tempbx = 0x07; 59108c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_IF_DEF_CH70xx == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { 59118c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x03) temp |= 0x80; 59128c2ecf20Sopenharmony_ci } 59138c2ecf20Sopenharmony_ci /* Chrontel 701x operates in 24bit mode (8-8-8, 2x12bit multiplexed) via VGA2 */ 59148c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { 59158c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 59168c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x10) temp |= 0x80; 59178c2ecf20Sopenharmony_ci } else { 59188c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) temp |= 0x80; 59198c2ecf20Sopenharmony_ci } 59208c2ecf20Sopenharmony_ci } 59218c2ecf20Sopenharmony_ci } 59228c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,tempbx,temp); 59238c2ecf20Sopenharmony_ci 59248c2ecf20Sopenharmony_ci tempbx = push2; /* BPLVDEE */ 59258c2ecf20Sopenharmony_ci 59268c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_LCDVDES; /* BPLVDES */ 59278c2ecf20Sopenharmony_ci 59288c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 59298c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 59308c2ecf20Sopenharmony_ci case Panel_640x480: 59318c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_VGAVDE - 1; 59328c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_VGAVDE; 59338c2ecf20Sopenharmony_ci break; 59348c2ecf20Sopenharmony_ci case Panel_800x600: 59358c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 59368c2ecf20Sopenharmony_ci if(resinfo == SIS_RI_800x600) tempcx++; 59378c2ecf20Sopenharmony_ci } 59388c2ecf20Sopenharmony_ci break; 59398c2ecf20Sopenharmony_ci case Panel_1024x600: 59408c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 59418c2ecf20Sopenharmony_ci if(resinfo == SIS_RI_1024x600) tempcx++; 59428c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 59438c2ecf20Sopenharmony_ci if(resinfo == SIS_RI_800x600) tempcx++; 59448c2ecf20Sopenharmony_ci } 59458c2ecf20Sopenharmony_ci } 59468c2ecf20Sopenharmony_ci break; 59478c2ecf20Sopenharmony_ci case Panel_1024x768: 59488c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 59498c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 59508c2ecf20Sopenharmony_ci if(resinfo == SIS_RI_1024x768) tempcx++; 59518c2ecf20Sopenharmony_ci } 59528c2ecf20Sopenharmony_ci } 59538c2ecf20Sopenharmony_ci break; 59548c2ecf20Sopenharmony_ci } 59558c2ecf20Sopenharmony_ci } 59568c2ecf20Sopenharmony_ci 59578c2ecf20Sopenharmony_ci temp = ((tempbx >> 8) & 0x07) << 3; 59588c2ecf20Sopenharmony_ci temp |= ((tempcx >> 8) & 0x07); 59598c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1D,temp); 59608c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1C,tempbx); 59618c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1B,tempcx); 59628c2ecf20Sopenharmony_ci 59638c2ecf20Sopenharmony_ci /* Vertical scaling */ 59648c2ecf20Sopenharmony_ci 59658c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 59668c2ecf20Sopenharmony_ci 59678c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 /* 300 series */ 59688c2ecf20Sopenharmony_ci tempeax = SiS_Pr->SiS_VGAVDE << 6; 59698c2ecf20Sopenharmony_ci temp = (tempeax % (unsigned int)SiS_Pr->SiS_VDE); 59708c2ecf20Sopenharmony_ci tempeax = tempeax / (unsigned int)SiS_Pr->SiS_VDE; 59718c2ecf20Sopenharmony_ci if(temp) tempeax++; 59728c2ecf20Sopenharmony_ci 59738c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempeax = 0x3F; 59748c2ecf20Sopenharmony_ci 59758c2ecf20Sopenharmony_ci temp = (unsigned short)(tempeax & 0x00FF); 59768c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1E,temp); /* BPLVCFACT */ 59778c2ecf20Sopenharmony_ci tempvcfact = temp; 59788c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_300 */ 59798c2ecf20Sopenharmony_ci 59808c2ecf20Sopenharmony_ci } else { 59818c2ecf20Sopenharmony_ci 59828c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 /* 315 series */ 59838c2ecf20Sopenharmony_ci tempeax = SiS_Pr->SiS_VGAVDE << 18; 59848c2ecf20Sopenharmony_ci tempebx = SiS_Pr->SiS_VDE; 59858c2ecf20Sopenharmony_ci temp = (tempeax % tempebx); 59868c2ecf20Sopenharmony_ci tempeax = tempeax / tempebx; 59878c2ecf20Sopenharmony_ci if(temp) tempeax++; 59888c2ecf20Sopenharmony_ci tempvcfact = tempeax; 59898c2ecf20Sopenharmony_ci 59908c2ecf20Sopenharmony_ci temp = (unsigned short)(tempeax & 0x00FF); 59918c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,temp); 59928c2ecf20Sopenharmony_ci temp = (unsigned short)((tempeax & 0x00FF00) >> 8); 59938c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,temp); 59948c2ecf20Sopenharmony_ci temp = (unsigned short)((tempeax & 0x00030000) >> 16); 59958c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04; 59968c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,temp); 59978c2ecf20Sopenharmony_ci 59988c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISPART4SCALER) { 59998c2ecf20Sopenharmony_ci temp = (unsigned short)(tempeax & 0x00FF); 60008c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3c,temp); 60018c2ecf20Sopenharmony_ci temp = (unsigned short)((tempeax & 0x00FF00) >> 8); 60028c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3b,temp); 60038c2ecf20Sopenharmony_ci temp = (unsigned short)(((tempeax & 0x00030000) >> 16) << 6); 60048c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0x3f,temp); 60058c2ecf20Sopenharmony_ci temp = 0; 60068c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VDE != SiS_Pr->SiS_VGAVDE) temp |= 0x08; 60078c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x30,0xf3,temp); 60088c2ecf20Sopenharmony_ci } 60098c2ecf20Sopenharmony_ci#endif 60108c2ecf20Sopenharmony_ci 60118c2ecf20Sopenharmony_ci } 60128c2ecf20Sopenharmony_ci 60138c2ecf20Sopenharmony_ci /* Horizontal scaling */ 60148c2ecf20Sopenharmony_ci 60158c2ecf20Sopenharmony_ci tempeax = SiS_Pr->SiS_VGAHDE; /* 1f = ( (VGAHDE * 65536) / ( (VGAHDE * 65536) / HDE ) ) - 1*/ 60168c2ecf20Sopenharmony_ci if(chkdclkfirst) { 60178c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempeax >>= 1; 60188c2ecf20Sopenharmony_ci } 60198c2ecf20Sopenharmony_ci tempebx = tempeax << 16; 60208c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_HDE == tempeax) { 60218c2ecf20Sopenharmony_ci tempecx = 0xFFFF; 60228c2ecf20Sopenharmony_ci } else { 60238c2ecf20Sopenharmony_ci tempecx = tempebx / SiS_Pr->SiS_HDE; 60248c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 60258c2ecf20Sopenharmony_ci if(tempebx % SiS_Pr->SiS_HDE) tempecx++; 60268c2ecf20Sopenharmony_ci } 60278c2ecf20Sopenharmony_ci } 60288c2ecf20Sopenharmony_ci 60298c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 60308c2ecf20Sopenharmony_ci tempeax = (tempebx / tempecx) - 1; 60318c2ecf20Sopenharmony_ci } else { 60328c2ecf20Sopenharmony_ci tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1; 60338c2ecf20Sopenharmony_ci } 60348c2ecf20Sopenharmony_ci tempecx = (tempecx << 16) | (tempeax & 0xFFFF); 60358c2ecf20Sopenharmony_ci temp = (unsigned short)(tempecx & 0x00FF); 60368c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1F,temp); 60378c2ecf20Sopenharmony_ci 60388c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 60398c2ecf20Sopenharmony_ci tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact; 60408c2ecf20Sopenharmony_ci tempbx = (unsigned short)(tempeax & 0xFFFF); 60418c2ecf20Sopenharmony_ci } else { 60428c2ecf20Sopenharmony_ci tempeax = SiS_Pr->SiS_VGAVDE << 6; 60438c2ecf20Sopenharmony_ci tempbx = tempvcfact & 0x3f; 60448c2ecf20Sopenharmony_ci if(tempbx == 0) tempbx = 64; 60458c2ecf20Sopenharmony_ci tempeax /= tempbx; 60468c2ecf20Sopenharmony_ci tempbx = (unsigned short)(tempeax & 0xFFFF); 60478c2ecf20Sopenharmony_ci } 60488c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tempbx--; 60498c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) { 60508c2ecf20Sopenharmony_ci if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) tempbx = 1; 60518c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) tempbx = 1; 60528c2ecf20Sopenharmony_ci } 60538c2ecf20Sopenharmony_ci 60548c2ecf20Sopenharmony_ci temp = ((tempbx >> 8) & 0x07) << 3; 60558c2ecf20Sopenharmony_ci temp = temp | ((tempecx >> 8) & 0x07); 60568c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x20,temp); 60578c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x21,tempbx); 60588c2ecf20Sopenharmony_ci 60598c2ecf20Sopenharmony_ci tempecx >>= 16; /* BPLHCFACT */ 60608c2ecf20Sopenharmony_ci if(!chkdclkfirst) { 60618c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempecx >>= 1; 60628c2ecf20Sopenharmony_ci } 60638c2ecf20Sopenharmony_ci temp = (unsigned short)((tempecx & 0xFF00) >> 8); 60648c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x22,temp); 60658c2ecf20Sopenharmony_ci temp = (unsigned short)(tempecx & 0x00FF); 60668c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp); 60678c2ecf20Sopenharmony_ci 60688c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 60698c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 60708c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 60718c2ecf20Sopenharmony_ci if((islvds) || (SiS_Pr->SiS_VBInfo & VB_SISLVDS)) { 60728c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x20); 60738c2ecf20Sopenharmony_ci } 60748c2ecf20Sopenharmony_ci } else { 60758c2ecf20Sopenharmony_ci if(islvds) { 60768c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 60778c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x03); 60788c2ecf20Sopenharmony_ci } else { 60798c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x23); 60808c2ecf20Sopenharmony_ci } 60818c2ecf20Sopenharmony_ci } 60828c2ecf20Sopenharmony_ci } 60838c2ecf20Sopenharmony_ci } 60848c2ecf20Sopenharmony_ci#endif 60858c2ecf20Sopenharmony_ci 60868c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 60878c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_TRUMPION) { 60888c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 60898c2ecf20Sopenharmony_ci unsigned char *trumpdata; 60908c2ecf20Sopenharmony_ci int i, j = crt2crtc; 60918c2ecf20Sopenharmony_ci unsigned char TrumpMode13[4] = { 0x01, 0x10, 0x2c, 0x00 }; 60928c2ecf20Sopenharmony_ci unsigned char TrumpMode10_1[4] = { 0x01, 0x10, 0x27, 0x00 }; 60938c2ecf20Sopenharmony_ci unsigned char TrumpMode10_2[4] = { 0x01, 0x16, 0x10, 0x00 }; 60948c2ecf20Sopenharmony_ci 60958c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 60968c2ecf20Sopenharmony_ci trumpdata = &ROMAddr[0x8001 + (j * 80)]; 60978c2ecf20Sopenharmony_ci } else { 60988c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDTypeInfo == 0x0e) j += 7; 60998c2ecf20Sopenharmony_ci trumpdata = &SiS300_TrumpionData[j][0]; 61008c2ecf20Sopenharmony_ci } 61018c2ecf20Sopenharmony_ci 61028c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xbf); 61038c2ecf20Sopenharmony_ci for(i=0; i<5; i++) { 61048c2ecf20Sopenharmony_ci SiS_SetTrumpionBlock(SiS_Pr, trumpdata); 61058c2ecf20Sopenharmony_ci } 61068c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 61078c2ecf20Sopenharmony_ci if(ModeNo == 0x13) { 61088c2ecf20Sopenharmony_ci for(i=0; i<4; i++) { 61098c2ecf20Sopenharmony_ci SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode13[0]); 61108c2ecf20Sopenharmony_ci } 61118c2ecf20Sopenharmony_ci } else if(ModeNo == 0x10) { 61128c2ecf20Sopenharmony_ci for(i=0; i<4; i++) { 61138c2ecf20Sopenharmony_ci SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode10_1[0]); 61148c2ecf20Sopenharmony_ci SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode10_2[0]); 61158c2ecf20Sopenharmony_ci } 61168c2ecf20Sopenharmony_ci } 61178c2ecf20Sopenharmony_ci } 61188c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); 61198c2ecf20Sopenharmony_ci } 61208c2ecf20Sopenharmony_ci#endif 61218c2ecf20Sopenharmony_ci 61228c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 61238c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) { 61248c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x25,0x00); 61258c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x26,0x00); 61268c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x27,0x00); 61278c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x28,0x87); 61288c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x29,0x5A); 61298c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2A,0x4B); 61308c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x07,0x03); 61318c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_HDE; /* Blps = lcdhdee(lcdhdes+HDE) + 64 */ 61328c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || 61338c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || 61348c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1; 61358c2ecf20Sopenharmony_ci tempax += 64; 61368c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,tempax & 0xff); 61378c2ecf20Sopenharmony_ci temp = (tempax >> 8) << 3; 61388c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,~0x078,temp); 61398c2ecf20Sopenharmony_ci tempax += 32; /* Blpe = lBlps+32 */ 61408c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,tempax & 0xff); 61418c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3A,0x00); /* Bflml = 0 */ 61428c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x3C,~0x007); 61438c2ecf20Sopenharmony_ci 61448c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_VDE; 61458c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || 61468c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || 61478c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1; 61488c2ecf20Sopenharmony_ci tempax >>= 1; 61498c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3B,tempax & 0xff); 61508c2ecf20Sopenharmony_ci temp = (tempax >> 8) << 3; 61518c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x038,temp); 61528c2ecf20Sopenharmony_ci 61538c2ecf20Sopenharmony_ci tempeax = SiS_Pr->SiS_HDE; 61548c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || 61558c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || 61568c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempeax >>= 1; 61578c2ecf20Sopenharmony_ci tempeax <<= 2; /* BDxFIFOSTOP = (HDE*4)/128 */ 61588c2ecf20Sopenharmony_ci temp = tempeax & 0x7f; 61598c2ecf20Sopenharmony_ci tempeax >>= 7; 61608c2ecf20Sopenharmony_ci if(temp) tempeax++; 61618c2ecf20Sopenharmony_ci temp = tempeax & 0x3f; 61628c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x45,temp); 61638c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3F,0x00); /* BDxWadrst0 */ 61648c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3E,0x00); 61658c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3D,0x10); 61668c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x3C,~0x040); 61678c2ecf20Sopenharmony_ci 61688c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_HDE; 61698c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || 61708c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || 61718c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1; 61728c2ecf20Sopenharmony_ci tempax >>= 4; /* BDxWadroff = HDE*4/8/8 */ 61738c2ecf20Sopenharmony_ci pushcx = tempax; 61748c2ecf20Sopenharmony_ci temp = tempax & 0x00FF; 61758c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,temp); 61768c2ecf20Sopenharmony_ci temp = ((tempax & 0xFF00) >> 8) << 3; 61778c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port, 0x44, 0x07, temp); 61788c2ecf20Sopenharmony_ci 61798c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_VDE; /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */ 61808c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || 61818c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || 61828c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1; 61838c2ecf20Sopenharmony_ci tempeax = tempax * pushcx; 61848c2ecf20Sopenharmony_ci temp = tempeax & 0xFF; 61858c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x42,temp); 61868c2ecf20Sopenharmony_ci temp = (tempeax & 0xFF00) >> 8; 61878c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x41,temp); 61888c2ecf20Sopenharmony_ci temp = ((tempeax & 0xFF0000) >> 16) | 0x10; 61898c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,temp); 61908c2ecf20Sopenharmony_ci temp = ((tempeax & 0x01000000) >> 24) << 7; 61918c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port, 0x3C, 0x7F, temp); 61928c2ecf20Sopenharmony_ci 61938c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x03); 61948c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0x50); 61958c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x04,0x00); 61968c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x01); 61978c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0x38); 61988c2ecf20Sopenharmony_ci 61998c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_FSTN) { 62008c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2b,0x02); 62018c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2c,0x00); 62028c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x00); 62038c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,0x0c); 62048c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,0x00); 62058c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,0x00); 62068c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,0x80); 62078c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,0xA0); 62088c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3a,0x00); 62098c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3b,0xf0); 62108c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3c,0x00); 62118c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3d,0x10); 62128c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3e,0x00); 62138c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3f,0x00); 62148c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,0x10); 62158c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x41,0x25); 62168c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x42,0x80); 62178c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,0x14); 62188c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x44,0x03); 62198c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x45,0x0a); 62208c2ecf20Sopenharmony_ci } 62218c2ecf20Sopenharmony_ci } 62228c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_315 */ 62238c2ecf20Sopenharmony_ci} 62248c2ecf20Sopenharmony_ci 62258c2ecf20Sopenharmony_ci/* Set Part 1 */ 62268c2ecf20Sopenharmony_cistatic void 62278c2ecf20Sopenharmony_ciSiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 62288c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 62298c2ecf20Sopenharmony_ci{ 62308c2ecf20Sopenharmony_ci#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315) 62318c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 62328c2ecf20Sopenharmony_ci#endif 62338c2ecf20Sopenharmony_ci unsigned short temp=0, tempax=0, tempbx=0, tempcx=0, bridgeadd=0; 62348c2ecf20Sopenharmony_ci unsigned short pushbx=0, CRT1Index=0, modeflag, resinfo=0; 62358c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 62368c2ecf20Sopenharmony_ci unsigned short tempbl=0; 62378c2ecf20Sopenharmony_ci#endif 62388c2ecf20Sopenharmony_ci 62398c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 62408c2ecf20Sopenharmony_ci SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 62418c2ecf20Sopenharmony_ci return; 62428c2ecf20Sopenharmony_ci } 62438c2ecf20Sopenharmony_ci 62448c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 62458c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 62468c2ecf20Sopenharmony_ci } else if(SiS_Pr->UseCustomMode) { 62478c2ecf20Sopenharmony_ci modeflag = SiS_Pr->CModeFlag; 62488c2ecf20Sopenharmony_ci } else { 62498c2ecf20Sopenharmony_ci CRT1Index = SiS_GetRefCRT1CRTC(SiS_Pr, RefreshRateTableIndex, SiS_Pr->SiS_UseWideCRT2); 62508c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 62518c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 62528c2ecf20Sopenharmony_ci } 62538c2ecf20Sopenharmony_ci 62548c2ecf20Sopenharmony_ci SiS_SetCRT2Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 62558c2ecf20Sopenharmony_ci 62568c2ecf20Sopenharmony_ci if( ! ((SiS_Pr->ChipType >= SIS_315H) && 62578c2ecf20Sopenharmony_ci (SiS_Pr->SiS_IF_DEF_LVDS == 1) && 62588c2ecf20Sopenharmony_ci (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) { 62598c2ecf20Sopenharmony_ci 62608c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H ) { 62618c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 62628c2ecf20Sopenharmony_ci SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo); 62638c2ecf20Sopenharmony_ci#endif 62648c2ecf20Sopenharmony_ci } else { 62658c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 62668c2ecf20Sopenharmony_ci SiS_SetCRT2FIFO_310(SiS_Pr); 62678c2ecf20Sopenharmony_ci#endif 62688c2ecf20Sopenharmony_ci } 62698c2ecf20Sopenharmony_ci 62708c2ecf20Sopenharmony_ci /* 1. Horizontal setup */ 62718c2ecf20Sopenharmony_ci 62728c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H ) { 62738c2ecf20Sopenharmony_ci 62748c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 /* ------------- 300 series --------------*/ 62758c2ecf20Sopenharmony_ci 62768c2ecf20Sopenharmony_ci temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ 62778c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ 62788c2ecf20Sopenharmony_ci 62798c2ecf20Sopenharmony_ci temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4; 62808c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */ 62818c2ecf20Sopenharmony_ci 62828c2ecf20Sopenharmony_ci temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ 62838c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */ 62848c2ecf20Sopenharmony_ci 62858c2ecf20Sopenharmony_ci pushbx = SiS_Pr->SiS_VGAHDE + 12; /* bx BTVGA2HRS 0x0B,0x0C */ 62868c2ecf20Sopenharmony_ci tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2; 62878c2ecf20Sopenharmony_ci tempbx = pushbx + tempcx; 62888c2ecf20Sopenharmony_ci tempcx <<= 1; 62898c2ecf20Sopenharmony_ci tempcx += tempbx; 62908c2ecf20Sopenharmony_ci 62918c2ecf20Sopenharmony_ci bridgeadd = 12; 62928c2ecf20Sopenharmony_ci 62938c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_300 */ 62948c2ecf20Sopenharmony_ci 62958c2ecf20Sopenharmony_ci } else { 62968c2ecf20Sopenharmony_ci 62978c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 /* ------------------- 315/330 series --------------- */ 62988c2ecf20Sopenharmony_ci 62998c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HT 0x08,0x09 */ 63008c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) { 63018c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 63028c2ecf20Sopenharmony_ci tempcx >>= 1; 63038c2ecf20Sopenharmony_ci } else { 63048c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_VGAHDE >> 1; 63058c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE + tempax; 63068c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 63078c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_HT - tempax; 63088c2ecf20Sopenharmony_ci } 63098c2ecf20Sopenharmony_ci } 63108c2ecf20Sopenharmony_ci } 63118c2ecf20Sopenharmony_ci tempcx--; 63128c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,tempcx); /* CRT2 Horizontal Total */ 63138c2ecf20Sopenharmony_ci temp = (tempcx >> 4) & 0xF0; 63148c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0F,temp); /* CRT2 Horizontal Total Overflow [7:4] */ 63158c2ecf20Sopenharmony_ci 63168c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HDEE 0x0A,0x0C */ 63178c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_VGAHDE; 63188c2ecf20Sopenharmony_ci tempcx -= tempbx; 63198c2ecf20Sopenharmony_ci tempcx >>= 2; 63208c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) { 63218c2ecf20Sopenharmony_ci tempbx >>= 1; 63228c2ecf20Sopenharmony_ci tempcx >>= 1; 63238c2ecf20Sopenharmony_ci } 63248c2ecf20Sopenharmony_ci tempbx += 16; 63258c2ecf20Sopenharmony_ci 63268c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,tempbx); /* CRT2 Horizontal Display Enable End */ 63278c2ecf20Sopenharmony_ci 63288c2ecf20Sopenharmony_ci pushbx = tempbx; 63298c2ecf20Sopenharmony_ci tempcx >>= 1; 63308c2ecf20Sopenharmony_ci tempbx += tempcx; 63318c2ecf20Sopenharmony_ci tempcx += tempbx; 63328c2ecf20Sopenharmony_ci 63338c2ecf20Sopenharmony_ci bridgeadd = 16; 63348c2ecf20Sopenharmony_ci 63358c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 63368c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_661) { 63378c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) || 63388c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { 63398c2ecf20Sopenharmony_ci if(resinfo == SIS_RI_1280x1024) { 63408c2ecf20Sopenharmony_ci tempcx = (tempcx & 0xff00) | 0x30; 63418c2ecf20Sopenharmony_ci } else if(resinfo == SIS_RI_1600x1200) { 63428c2ecf20Sopenharmony_ci tempcx = (tempcx & 0xff00) | 0xff; 63438c2ecf20Sopenharmony_ci } 63448c2ecf20Sopenharmony_ci } 63458c2ecf20Sopenharmony_ci } 63468c2ecf20Sopenharmony_ci } 63478c2ecf20Sopenharmony_ci 63488c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_315 */ 63498c2ecf20Sopenharmony_ci 63508c2ecf20Sopenharmony_ci } /* 315/330 series */ 63518c2ecf20Sopenharmony_ci 63528c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 63538c2ecf20Sopenharmony_ci 63548c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 63558c2ecf20Sopenharmony_ci tempbx = SiS_Pr->CHSyncStart + bridgeadd; 63568c2ecf20Sopenharmony_ci tempcx = SiS_Pr->CHSyncEnd + bridgeadd; 63578c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_VGAHT; 63588c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempax >>= 1; 63598c2ecf20Sopenharmony_ci tempax--; 63608c2ecf20Sopenharmony_ci if(tempcx > tempax) tempcx = tempax; 63618c2ecf20Sopenharmony_ci } 63628c2ecf20Sopenharmony_ci 63638c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { 63648c2ecf20Sopenharmony_ci unsigned char cr4, cr14, cr5, cr15; 63658c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 63668c2ecf20Sopenharmony_ci cr4 = SiS_Pr->CCRT1CRTC[4]; 63678c2ecf20Sopenharmony_ci cr14 = SiS_Pr->CCRT1CRTC[14]; 63688c2ecf20Sopenharmony_ci cr5 = SiS_Pr->CCRT1CRTC[5]; 63698c2ecf20Sopenharmony_ci cr15 = SiS_Pr->CCRT1CRTC[15]; 63708c2ecf20Sopenharmony_ci } else { 63718c2ecf20Sopenharmony_ci cr4 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4]; 63728c2ecf20Sopenharmony_ci cr14 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14]; 63738c2ecf20Sopenharmony_ci cr5 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5]; 63748c2ecf20Sopenharmony_ci cr15 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15]; 63758c2ecf20Sopenharmony_ci } 63768c2ecf20Sopenharmony_ci tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 3) << 3; /* (VGAHRS-3)*8 */ 63778c2ecf20Sopenharmony_ci tempcx = (((cr5 & 0x1f) | ((cr15 & 0x04) << (5-2))) - 3) << 3; /* (VGAHRE-3)*8 */ 63788c2ecf20Sopenharmony_ci tempcx &= 0x00FF; 63798c2ecf20Sopenharmony_ci tempcx |= (tempbx & 0xFF00); 63808c2ecf20Sopenharmony_ci tempbx += bridgeadd; 63818c2ecf20Sopenharmony_ci tempcx += bridgeadd; 63828c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_VGAHT; 63838c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempax >>= 1; 63848c2ecf20Sopenharmony_ci tempax--; 63858c2ecf20Sopenharmony_ci if(tempcx > tempax) tempcx = tempax; 63868c2ecf20Sopenharmony_ci } 63878c2ecf20Sopenharmony_ci 63888c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSet525p1024)) { 63898c2ecf20Sopenharmony_ci tempbx = 1040; 63908c2ecf20Sopenharmony_ci tempcx = 1044; /* HWCursor bug! */ 63918c2ecf20Sopenharmony_ci } 63928c2ecf20Sopenharmony_ci 63938c2ecf20Sopenharmony_ci } 63948c2ecf20Sopenharmony_ci 63958c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,tempbx); /* CRT2 Horizontal Retrace Start */ 63968c2ecf20Sopenharmony_ci 63978c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,tempcx); /* CRT2 Horizontal Retrace End */ 63988c2ecf20Sopenharmony_ci 63998c2ecf20Sopenharmony_ci temp = ((tempbx >> 8) & 0x0F) | ((pushbx >> 4) & 0xF0); 64008c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0C,temp); /* Overflow */ 64018c2ecf20Sopenharmony_ci 64028c2ecf20Sopenharmony_ci /* 2. Vertical setup */ 64038c2ecf20Sopenharmony_ci 64048c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_VGAVT - 1; 64058c2ecf20Sopenharmony_ci temp = tempcx & 0x00FF; 64068c2ecf20Sopenharmony_ci 64078c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_661) { 64088c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 64098c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 64108c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 64118c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) { 64128c2ecf20Sopenharmony_ci temp--; 64138c2ecf20Sopenharmony_ci } 64148c2ecf20Sopenharmony_ci } 64158c2ecf20Sopenharmony_ci } else { 64168c2ecf20Sopenharmony_ci temp--; 64178c2ecf20Sopenharmony_ci } 64188c2ecf20Sopenharmony_ci } else if(SiS_Pr->ChipType >= SIS_315H) { 64198c2ecf20Sopenharmony_ci temp--; 64208c2ecf20Sopenharmony_ci } 64218c2ecf20Sopenharmony_ci } 64228c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0E,temp); /* CRT2 Vertical Total */ 64238c2ecf20Sopenharmony_ci 64248c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_VGAVDE - 1; 64258c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,tempbx); /* CRT2 Vertical Display Enable End */ 64268c2ecf20Sopenharmony_ci 64278c2ecf20Sopenharmony_ci temp = ((tempbx >> 5) & 0x38) | ((tempcx >> 8) & 0x07); 64288c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,temp); /* Overflow */ 64298c2ecf20Sopenharmony_ci 64308c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) { 64318c2ecf20Sopenharmony_ci tempbx++; 64328c2ecf20Sopenharmony_ci tempax = tempbx; 64338c2ecf20Sopenharmony_ci tempcx++; 64348c2ecf20Sopenharmony_ci tempcx -= tempax; 64358c2ecf20Sopenharmony_ci tempcx >>= 2; 64368c2ecf20Sopenharmony_ci tempbx += tempcx; 64378c2ecf20Sopenharmony_ci if(tempcx < 4) tempcx = 4; 64388c2ecf20Sopenharmony_ci tempcx >>= 2; 64398c2ecf20Sopenharmony_ci tempcx += tempbx; 64408c2ecf20Sopenharmony_ci tempcx++; 64418c2ecf20Sopenharmony_ci } else { 64428c2ecf20Sopenharmony_ci tempbx = (SiS_Pr->SiS_VGAVT + SiS_Pr->SiS_VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */ 64438c2ecf20Sopenharmony_ci tempcx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */ 64448c2ecf20Sopenharmony_ci } 64458c2ecf20Sopenharmony_ci 64468c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 64478c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 64488c2ecf20Sopenharmony_ci tempbx = SiS_Pr->CVSyncStart; 64498c2ecf20Sopenharmony_ci tempcx = SiS_Pr->CVSyncEnd; 64508c2ecf20Sopenharmony_ci } 64518c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { 64528c2ecf20Sopenharmony_ci unsigned char cr8, cr7, cr13; 64538c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 64548c2ecf20Sopenharmony_ci cr8 = SiS_Pr->CCRT1CRTC[8]; 64558c2ecf20Sopenharmony_ci cr7 = SiS_Pr->CCRT1CRTC[7]; 64568c2ecf20Sopenharmony_ci cr13 = SiS_Pr->CCRT1CRTC[13]; 64578c2ecf20Sopenharmony_ci tempcx = SiS_Pr->CCRT1CRTC[9]; 64588c2ecf20Sopenharmony_ci } else { 64598c2ecf20Sopenharmony_ci cr8 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[8]; 64608c2ecf20Sopenharmony_ci cr7 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7]; 64618c2ecf20Sopenharmony_ci cr13 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]; 64628c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9]; 64638c2ecf20Sopenharmony_ci } 64648c2ecf20Sopenharmony_ci tempbx = cr8; 64658c2ecf20Sopenharmony_ci if(cr7 & 0x04) tempbx |= 0x0100; 64668c2ecf20Sopenharmony_ci if(cr7 & 0x80) tempbx |= 0x0200; 64678c2ecf20Sopenharmony_ci if(cr13 & 0x08) tempbx |= 0x0400; 64688c2ecf20Sopenharmony_ci } 64698c2ecf20Sopenharmony_ci } 64708c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,tempbx); /* CRT2 Vertical Retrace Start */ 64718c2ecf20Sopenharmony_ci 64728c2ecf20Sopenharmony_ci temp = ((tempbx >> 4) & 0x70) | (tempcx & 0x0F); 64738c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x11,temp); /* CRT2 Vert. Retrace End; Overflow */ 64748c2ecf20Sopenharmony_ci 64758c2ecf20Sopenharmony_ci /* 3. Panel delay compensation */ 64768c2ecf20Sopenharmony_ci 64778c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 64788c2ecf20Sopenharmony_ci 64798c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 /* ---------- 300 series -------------- */ 64808c2ecf20Sopenharmony_ci 64818c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 64828c2ecf20Sopenharmony_ci temp = 0x20; 64838c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_300) { 64848c2ecf20Sopenharmony_ci temp = 0x10; 64858c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) temp = 0x2c; 64868c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) temp = 0x20; 64878c2ecf20Sopenharmony_ci } 64888c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS301) { 64898c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) temp = 0x20; 64908c2ecf20Sopenharmony_ci } 64918c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1280x960) temp = 0x24; 64928c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) temp = 0x2c; 64938c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x08; 64948c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 64958c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c; 64968c2ecf20Sopenharmony_ci else temp = 0x20; 64978c2ecf20Sopenharmony_ci } 64988c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 64998c2ecf20Sopenharmony_ci if(ROMAddr[0x220] & 0x80) { 65008c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) 65018c2ecf20Sopenharmony_ci temp = ROMAddr[0x221]; 65028c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) 65038c2ecf20Sopenharmony_ci temp = ROMAddr[0x222]; 65048c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) 65058c2ecf20Sopenharmony_ci temp = ROMAddr[0x223]; 65068c2ecf20Sopenharmony_ci else 65078c2ecf20Sopenharmony_ci temp = ROMAddr[0x224]; 65088c2ecf20Sopenharmony_ci } 65098c2ecf20Sopenharmony_ci } 65108c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 65118c2ecf20Sopenharmony_ci if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC; 65128c2ecf20Sopenharmony_ci } 65138c2ecf20Sopenharmony_ci 65148c2ecf20Sopenharmony_ci } else { 65158c2ecf20Sopenharmony_ci temp = 0x20; 65168c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { 65178c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_640x480) temp = 0x04; 65188c2ecf20Sopenharmony_ci } 65198c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 65208c2ecf20Sopenharmony_ci if(ROMAddr[0x220] & 0x80) { 65218c2ecf20Sopenharmony_ci temp = ROMAddr[0x220]; 65228c2ecf20Sopenharmony_ci } 65238c2ecf20Sopenharmony_ci } 65248c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 65258c2ecf20Sopenharmony_ci if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC; 65268c2ecf20Sopenharmony_ci } 65278c2ecf20Sopenharmony_ci } 65288c2ecf20Sopenharmony_ci 65298c2ecf20Sopenharmony_ci temp &= 0x3c; 65308c2ecf20Sopenharmony_ci 65318c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */ 65328c2ecf20Sopenharmony_ci 65338c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_300 */ 65348c2ecf20Sopenharmony_ci 65358c2ecf20Sopenharmony_ci } else { 65368c2ecf20Sopenharmony_ci 65378c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 /* --------------- 315/330 series ---------------*/ 65388c2ecf20Sopenharmony_ci 65398c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_661) { 65408c2ecf20Sopenharmony_ci 65418c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 65428c2ecf20Sopenharmony_ci 65438c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) temp = 0x03; 65448c2ecf20Sopenharmony_ci else temp = 0x00; 65458c2ecf20Sopenharmony_ci 65468c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x0a; 65478c2ecf20Sopenharmony_ci tempbl = 0xF0; 65488c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_650) { 65498c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 65508c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempbl = 0x0F; 65518c2ecf20Sopenharmony_ci } 65528c2ecf20Sopenharmony_ci } 65538c2ecf20Sopenharmony_ci 65548c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) { 65558c2ecf20Sopenharmony_ci temp = 0x08; 65568c2ecf20Sopenharmony_ci tempbl = 0; 65578c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { 65588c2ecf20Sopenharmony_ci if(ROMAddr[0x13c] & 0x80) tempbl = 0xf0; 65598c2ecf20Sopenharmony_ci } 65608c2ecf20Sopenharmony_ci } 65618c2ecf20Sopenharmony_ci 65628c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,tempbl,temp); /* Panel Link Delay Compensation */ 65638c2ecf20Sopenharmony_ci } 65648c2ecf20Sopenharmony_ci 65658c2ecf20Sopenharmony_ci } /* < 661 */ 65668c2ecf20Sopenharmony_ci 65678c2ecf20Sopenharmony_ci tempax = 0; 65688c2ecf20Sopenharmony_ci if(modeflag & DoubleScanMode) tempax |= 0x80; 65698c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempax |= 0x40; 65708c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax); 65718c2ecf20Sopenharmony_ci 65728c2ecf20Sopenharmony_ci#endif /* CONFIG_FB_SIS_315 */ 65738c2ecf20Sopenharmony_ci 65748c2ecf20Sopenharmony_ci } 65758c2ecf20Sopenharmony_ci 65768c2ecf20Sopenharmony_ci } /* Slavemode */ 65778c2ecf20Sopenharmony_ci 65788c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 65798c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { 65808c2ecf20Sopenharmony_ci /* For 301BDH with LCD, we set up the Panel Link */ 65818c2ecf20Sopenharmony_ci SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 65828c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 65838c2ecf20Sopenharmony_ci SiS_SetGroup1_301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 65848c2ecf20Sopenharmony_ci } 65858c2ecf20Sopenharmony_ci } else { 65868c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 65878c2ecf20Sopenharmony_ci SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 65888c2ecf20Sopenharmony_ci } else { 65898c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 65908c2ecf20Sopenharmony_ci if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 65918c2ecf20Sopenharmony_ci SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex,RefreshRateTableIndex); 65928c2ecf20Sopenharmony_ci } 65938c2ecf20Sopenharmony_ci } else { 65948c2ecf20Sopenharmony_ci SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex,RefreshRateTableIndex); 65958c2ecf20Sopenharmony_ci } 65968c2ecf20Sopenharmony_ci } 65978c2ecf20Sopenharmony_ci } 65988c2ecf20Sopenharmony_ci} 65998c2ecf20Sopenharmony_ci 66008c2ecf20Sopenharmony_ci/*********************************************/ 66018c2ecf20Sopenharmony_ci/* SET PART 2 REGISTER GROUP */ 66028c2ecf20Sopenharmony_ci/*********************************************/ 66038c2ecf20Sopenharmony_ci 66048c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 66058c2ecf20Sopenharmony_cistatic unsigned char * 66068c2ecf20Sopenharmony_ciSiS_GetGroup2CLVXPtr(struct SiS_Private *SiS_Pr, int tabletype) 66078c2ecf20Sopenharmony_ci{ 66088c2ecf20Sopenharmony_ci const unsigned char *tableptr = NULL; 66098c2ecf20Sopenharmony_ci unsigned short a, b, p = 0; 66108c2ecf20Sopenharmony_ci 66118c2ecf20Sopenharmony_ci a = SiS_Pr->SiS_VGAHDE; 66128c2ecf20Sopenharmony_ci b = SiS_Pr->SiS_HDE; 66138c2ecf20Sopenharmony_ci if(tabletype) { 66148c2ecf20Sopenharmony_ci a = SiS_Pr->SiS_VGAVDE; 66158c2ecf20Sopenharmony_ci b = SiS_Pr->SiS_VDE; 66168c2ecf20Sopenharmony_ci } 66178c2ecf20Sopenharmony_ci 66188c2ecf20Sopenharmony_ci if(a < b) { 66198c2ecf20Sopenharmony_ci tableptr = SiS_Part2CLVX_1; 66208c2ecf20Sopenharmony_ci } else if(a == b) { 66218c2ecf20Sopenharmony_ci tableptr = SiS_Part2CLVX_2; 66228c2ecf20Sopenharmony_ci } else { 66238c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) { 66248c2ecf20Sopenharmony_ci tableptr = SiS_Part2CLVX_4; 66258c2ecf20Sopenharmony_ci } else { 66268c2ecf20Sopenharmony_ci tableptr = SiS_Part2CLVX_3; 66278c2ecf20Sopenharmony_ci } 66288c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 66298c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr525i) tableptr = SiS_Part2CLVX_3; 66308c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tableptr = SiS_Part2CLVX_3; 66318c2ecf20Sopenharmony_ci else tableptr = SiS_Part2CLVX_5; 66328c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 66338c2ecf20Sopenharmony_ci tableptr = SiS_Part2CLVX_6; 66348c2ecf20Sopenharmony_ci } 66358c2ecf20Sopenharmony_ci do { 66368c2ecf20Sopenharmony_ci if((tableptr[p] | tableptr[p+1] << 8) == a) break; 66378c2ecf20Sopenharmony_ci p += 0x42; 66388c2ecf20Sopenharmony_ci } while((tableptr[p] | tableptr[p+1] << 8) != 0xffff); 66398c2ecf20Sopenharmony_ci if((tableptr[p] | tableptr[p+1] << 8) == 0xffff) p -= 0x42; 66408c2ecf20Sopenharmony_ci } 66418c2ecf20Sopenharmony_ci p += 2; 66428c2ecf20Sopenharmony_ci return ((unsigned char *)&tableptr[p]); 66438c2ecf20Sopenharmony_ci} 66448c2ecf20Sopenharmony_ci 66458c2ecf20Sopenharmony_cistatic void 66468c2ecf20Sopenharmony_ciSiS_SetGroup2_C_ELV(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 66478c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 66488c2ecf20Sopenharmony_ci{ 66498c2ecf20Sopenharmony_ci unsigned char *tableptr; 66508c2ecf20Sopenharmony_ci unsigned char temp; 66518c2ecf20Sopenharmony_ci int i, j; 66528c2ecf20Sopenharmony_ci 66538c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBType & VB_SISTAP4SCALER)) return; 66548c2ecf20Sopenharmony_ci 66558c2ecf20Sopenharmony_ci tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 0); 66568c2ecf20Sopenharmony_ci for(i = 0x80, j = 0; i <= 0xbf; i++, j++) { 66578c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]); 66588c2ecf20Sopenharmony_ci } 66598c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 66608c2ecf20Sopenharmony_ci tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 1); 66618c2ecf20Sopenharmony_ci for(i = 0xc0, j = 0; i <= 0xff; i++, j++) { 66628c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]); 66638c2ecf20Sopenharmony_ci } 66648c2ecf20Sopenharmony_ci } 66658c2ecf20Sopenharmony_ci temp = 0x10; 66668c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp |= 0x04; 66678c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4e,0xeb,temp); 66688c2ecf20Sopenharmony_ci} 66698c2ecf20Sopenharmony_ci 66708c2ecf20Sopenharmony_cistatic bool 66718c2ecf20Sopenharmony_ciSiS_GetCRT2Part2Ptr(struct SiS_Private *SiS_Pr,unsigned short ModeNo,unsigned short ModeIdIndex, 66728c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex,unsigned short *CRT2Index, 66738c2ecf20Sopenharmony_ci unsigned short *ResIndex) 66748c2ecf20Sopenharmony_ci{ 66758c2ecf20Sopenharmony_ci 66768c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) return false; 66778c2ecf20Sopenharmony_ci 66788c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) 66798c2ecf20Sopenharmony_ci (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 66808c2ecf20Sopenharmony_ci else 66818c2ecf20Sopenharmony_ci (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 66828c2ecf20Sopenharmony_ci 66838c2ecf20Sopenharmony_ci (*ResIndex) &= 0x3f; 66848c2ecf20Sopenharmony_ci (*CRT2Index) = 0; 66858c2ecf20Sopenharmony_ci 66868c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 66878c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { 66888c2ecf20Sopenharmony_ci (*CRT2Index) = 200; 66898c2ecf20Sopenharmony_ci } 66908c2ecf20Sopenharmony_ci } 66918c2ecf20Sopenharmony_ci 66928c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { 66938c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 66948c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LCDVESATiming) (*CRT2Index) = 206; 66958c2ecf20Sopenharmony_ci } 66968c2ecf20Sopenharmony_ci } 66978c2ecf20Sopenharmony_ci return (((*CRT2Index) != 0)); 66988c2ecf20Sopenharmony_ci} 66998c2ecf20Sopenharmony_ci#endif 67008c2ecf20Sopenharmony_ci 67018c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 67028c2ecf20Sopenharmony_cistatic void 67038c2ecf20Sopenharmony_ciSiS_Group2LCDSpecial(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short crt2crtc) 67048c2ecf20Sopenharmony_ci{ 67058c2ecf20Sopenharmony_ci unsigned short tempcx; 67068c2ecf20Sopenharmony_ci static const unsigned char atable[] = { 67078c2ecf20Sopenharmony_ci 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02, 67088c2ecf20Sopenharmony_ci 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02 67098c2ecf20Sopenharmony_ci }; 67108c2ecf20Sopenharmony_ci 67118c2ecf20Sopenharmony_ci if(!SiS_Pr->UseCustomMode) { 67128c2ecf20Sopenharmony_ci if( ( ( (SiS_Pr->ChipType == SIS_630) || 67138c2ecf20Sopenharmony_ci (SiS_Pr->ChipType == SIS_730) ) && 67148c2ecf20Sopenharmony_ci (SiS_Pr->ChipRevision > 2) ) && 67158c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1024x768) && 67168c2ecf20Sopenharmony_ci (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) && 67178c2ecf20Sopenharmony_ci (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) { 67188c2ecf20Sopenharmony_ci if(ModeNo == 0x13) { 67198c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xB9); 67208c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0xCC); 67218c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xA6); 67228c2ecf20Sopenharmony_ci } else if((crt2crtc & 0x3F) == 4) { 67238c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x2B); 67248c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x13); 67258c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xE5); 67268c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0x08); 67278c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xE2); 67288c2ecf20Sopenharmony_ci } 67298c2ecf20Sopenharmony_ci } 67308c2ecf20Sopenharmony_ci 67318c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 67328c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) { 67338c2ecf20Sopenharmony_ci crt2crtc &= 0x1f; 67348c2ecf20Sopenharmony_ci tempcx = 0; 67358c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { 67368c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 67378c2ecf20Sopenharmony_ci tempcx += 7; 67388c2ecf20Sopenharmony_ci } 67398c2ecf20Sopenharmony_ci } 67408c2ecf20Sopenharmony_ci tempcx += crt2crtc; 67418c2ecf20Sopenharmony_ci if(crt2crtc >= 4) { 67428c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xff); 67438c2ecf20Sopenharmony_ci } 67448c2ecf20Sopenharmony_ci 67458c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { 67468c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 67478c2ecf20Sopenharmony_ci if(crt2crtc == 4) { 67488c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x28); 67498c2ecf20Sopenharmony_ci } 67508c2ecf20Sopenharmony_ci } 67518c2ecf20Sopenharmony_ci } 67528c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x18); 67538c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]); 67548c2ecf20Sopenharmony_ci } 67558c2ecf20Sopenharmony_ci } 67568c2ecf20Sopenharmony_ci } 67578c2ecf20Sopenharmony_ci} 67588c2ecf20Sopenharmony_ci 67598c2ecf20Sopenharmony_ci/* For ECS A907. Highly preliminary. */ 67608c2ecf20Sopenharmony_cistatic void 67618c2ecf20Sopenharmony_ciSiS_Set300Part2Regs(struct SiS_Private *SiS_Pr, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, 67628c2ecf20Sopenharmony_ci unsigned short ModeNo) 67638c2ecf20Sopenharmony_ci{ 67648c2ecf20Sopenharmony_ci const struct SiS_Part2PortTbl *CRT2Part2Ptr = NULL; 67658c2ecf20Sopenharmony_ci unsigned short crt2crtc, resindex; 67668c2ecf20Sopenharmony_ci int i, j; 67678c2ecf20Sopenharmony_ci 67688c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType != SIS_300) return; 67698c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) return; 67708c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) return; 67718c2ecf20Sopenharmony_ci 67728c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 67738c2ecf20Sopenharmony_ci crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 67748c2ecf20Sopenharmony_ci } else { 67758c2ecf20Sopenharmony_ci crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 67768c2ecf20Sopenharmony_ci } 67778c2ecf20Sopenharmony_ci 67788c2ecf20Sopenharmony_ci resindex = crt2crtc & 0x3F; 67798c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LCDVESATiming) CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; 67808c2ecf20Sopenharmony_ci else CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_2; 67818c2ecf20Sopenharmony_ci 67828c2ecf20Sopenharmony_ci /* The BIOS code (1.16.51,56) is obviously a fragment! */ 67838c2ecf20Sopenharmony_ci if(ModeNo > 0x13) { 67848c2ecf20Sopenharmony_ci CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; 67858c2ecf20Sopenharmony_ci resindex = 4; 67868c2ecf20Sopenharmony_ci } 67878c2ecf20Sopenharmony_ci 67888c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]); 67898c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]); 67908c2ecf20Sopenharmony_ci for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) { 67918c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); 67928c2ecf20Sopenharmony_ci } 67938c2ecf20Sopenharmony_ci for(j = 0x1c; j <= 0x1d; i++, j++ ) { 67948c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); 67958c2ecf20Sopenharmony_ci } 67968c2ecf20Sopenharmony_ci for(j = 0x1f; j <= 0x21; i++, j++ ) { 67978c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); 67988c2ecf20Sopenharmony_ci } 67998c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]); 68008c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]); 68018c2ecf20Sopenharmony_ci} 68028c2ecf20Sopenharmony_ci#endif 68038c2ecf20Sopenharmony_ci 68048c2ecf20Sopenharmony_cistatic void 68058c2ecf20Sopenharmony_ciSiS_SetTVSpecial(struct SiS_Private *SiS_Pr, unsigned short ModeNo) 68068c2ecf20Sopenharmony_ci{ 68078c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) return; 68088c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) return; 68098c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) return; 68108c2ecf20Sopenharmony_ci 68118c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { 68128c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { 68138c2ecf20Sopenharmony_ci static const unsigned char specialtv[] = { 68148c2ecf20Sopenharmony_ci 0xa7,0x07,0xf2,0x6e,0x17,0x8b,0x73,0x53, 68158c2ecf20Sopenharmony_ci 0x13,0x40,0x34,0xf4,0x63,0xbb,0xcc,0x7a, 68168c2ecf20Sopenharmony_ci 0x58,0xe4,0x73,0xda,0x13 68178c2ecf20Sopenharmony_ci }; 68188c2ecf20Sopenharmony_ci int i, j; 68198c2ecf20Sopenharmony_ci for(i = 0x1c, j = 0; i <= 0x30; i++, j++) { 68208c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,specialtv[j]); 68218c2ecf20Sopenharmony_ci } 68228c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,0x72); 68238c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750)) { 68248c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPALM) { 68258c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x14); 68268c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1b); 68278c2ecf20Sopenharmony_ci } else { 68288c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x14); /* 15 */ 68298c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1a); /* 1b */ 68308c2ecf20Sopenharmony_ci } 68318c2ecf20Sopenharmony_ci } 68328c2ecf20Sopenharmony_ci } 68338c2ecf20Sopenharmony_ci } else { 68348c2ecf20Sopenharmony_ci if((ModeNo == 0x38) || (ModeNo == 0x4a) || (ModeNo == 0x64) || 68358c2ecf20Sopenharmony_ci (ModeNo == 0x52) || (ModeNo == 0x58) || (ModeNo == 0x5c)) { 68368c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b); /* 21 */ 68378c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54); /* 5a */ 68388c2ecf20Sopenharmony_ci } else { 68398c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1a); /* 21 */ 68408c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x53); /* 5a */ 68418c2ecf20Sopenharmony_ci } 68428c2ecf20Sopenharmony_ci } 68438c2ecf20Sopenharmony_ci} 68448c2ecf20Sopenharmony_ci 68458c2ecf20Sopenharmony_cistatic void 68468c2ecf20Sopenharmony_ciSiS_SetGroup2_Tail(struct SiS_Private *SiS_Pr, unsigned short ModeNo) 68478c2ecf20Sopenharmony_ci{ 68488c2ecf20Sopenharmony_ci unsigned short temp; 68498c2ecf20Sopenharmony_ci 68508c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { 68518c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE == 525) { 68528c2ecf20Sopenharmony_ci temp = 0xc3; 68538c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType <= ModeVGA) { 68548c2ecf20Sopenharmony_ci temp++; 68558c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) temp += 2; 68568c2ecf20Sopenharmony_ci } 68578c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); 68588c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,0xb3); 68598c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VGAVDE == 420) { 68608c2ecf20Sopenharmony_ci temp = 0x4d; 68618c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType <= ModeVGA) { 68628c2ecf20Sopenharmony_ci temp++; 68638c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) temp++; 68648c2ecf20Sopenharmony_ci } 68658c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); 68668c2ecf20Sopenharmony_ci } 68678c2ecf20Sopenharmony_ci } 68688c2ecf20Sopenharmony_ci 68698c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 68708c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) { 68718c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xB) { 68728c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x1a,0x03); 68738c2ecf20Sopenharmony_ci /* Not always for LV, see SetGrp2 */ 68748c2ecf20Sopenharmony_ci } 68758c2ecf20Sopenharmony_ci temp = 1; 68768c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) temp = 3; 68778c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0b,temp); 68788c2ecf20Sopenharmony_ci } 68798c2ecf20Sopenharmony_ci#if 0 68808c2ecf20Sopenharmony_ci /* 651+301C, for 1280x768 - do I really need that? */ 68818c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_PanelXRes == 1280) && (SiS_Pr->SiS_PanelYRes == 768)) { 68828c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { 68838c2ecf20Sopenharmony_ci if(((SiS_Pr->SiS_HDE == 640) && (SiS_Pr->SiS_VDE == 480)) || 68848c2ecf20Sopenharmony_ci ((SiS_Pr->SiS_HDE == 320) && (SiS_Pr->SiS_VDE == 240))) { 68858c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Part2Port,0x01,0x2b); 68868c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Part2Port,0x02,0x13); 68878c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Part2Port,0x04,0xe5); 68888c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Part2Port,0x05,0x08); 68898c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Part2Port,0x06,0xe2); 68908c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Part2Port,0x1c,0x21); 68918c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Part2Port,0x1d,0x45); 68928c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Part2Port,0x1f,0x0b); 68938c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Part2Port,0x20,0x00); 68948c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Part2Port,0x21,0xa9); 68958c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Part2Port,0x23,0x0b); 68968c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Part2Port,0x25,0x04); 68978c2ecf20Sopenharmony_ci } 68988c2ecf20Sopenharmony_ci } 68998c2ecf20Sopenharmony_ci } 69008c2ecf20Sopenharmony_ci#endif 69018c2ecf20Sopenharmony_ci } 69028c2ecf20Sopenharmony_ci} 69038c2ecf20Sopenharmony_ci 69048c2ecf20Sopenharmony_cistatic void 69058c2ecf20Sopenharmony_ciSiS_SetGroup2(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 69068c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 69078c2ecf20Sopenharmony_ci{ 69088c2ecf20Sopenharmony_ci unsigned short i, j, tempax, tempbx, tempcx, tempch, tempcl, temp; 69098c2ecf20Sopenharmony_ci unsigned short push2, modeflag, crt2crtc, bridgeoffset; 69108c2ecf20Sopenharmony_ci unsigned int longtemp, PhaseIndex; 69118c2ecf20Sopenharmony_ci bool newtvphase; 69128c2ecf20Sopenharmony_ci const unsigned char *TimingPoint; 69138c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 69148c2ecf20Sopenharmony_ci unsigned short resindex, CRT2Index; 69158c2ecf20Sopenharmony_ci const struct SiS_Part2PortTbl *CRT2Part2Ptr = NULL; 69168c2ecf20Sopenharmony_ci 69178c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; 69188c2ecf20Sopenharmony_ci#endif 69198c2ecf20Sopenharmony_ci 69208c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 69218c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 69228c2ecf20Sopenharmony_ci crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 69238c2ecf20Sopenharmony_ci } else if(SiS_Pr->UseCustomMode) { 69248c2ecf20Sopenharmony_ci modeflag = SiS_Pr->CModeFlag; 69258c2ecf20Sopenharmony_ci crt2crtc = 0; 69268c2ecf20Sopenharmony_ci } else { 69278c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 69288c2ecf20Sopenharmony_ci crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 69298c2ecf20Sopenharmony_ci } 69308c2ecf20Sopenharmony_ci 69318c2ecf20Sopenharmony_ci temp = 0; 69328c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToAVIDEO)) temp |= 0x08; 69338c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) temp |= 0x04; 69348c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) temp |= 0x02; 69358c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) temp |= 0x01; 69368c2ecf20Sopenharmony_ci 69378c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) temp |= 0x10; 69388c2ecf20Sopenharmony_ci 69398c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x00,temp); 69408c2ecf20Sopenharmony_ci 69418c2ecf20Sopenharmony_ci PhaseIndex = 0x01; /* SiS_PALPhase */ 69428c2ecf20Sopenharmony_ci TimingPoint = SiS_Pr->SiS_PALTiming; 69438c2ecf20Sopenharmony_ci 69448c2ecf20Sopenharmony_ci newtvphase = false; 69458c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_VBType & VB_SIS30xBLV) && 69468c2ecf20Sopenharmony_ci ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || 69478c2ecf20Sopenharmony_ci (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { 69488c2ecf20Sopenharmony_ci newtvphase = true; 69498c2ecf20Sopenharmony_ci } 69508c2ecf20Sopenharmony_ci 69518c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 69528c2ecf20Sopenharmony_ci 69538c2ecf20Sopenharmony_ci TimingPoint = SiS_Pr->SiS_HiTVExtTiming; 69548c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 69558c2ecf20Sopenharmony_ci TimingPoint = SiS_Pr->SiS_HiTVSt2Timing; 69568c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { 69578c2ecf20Sopenharmony_ci TimingPoint = SiS_Pr->SiS_HiTVSt1Timing; 69588c2ecf20Sopenharmony_ci } 69598c2ecf20Sopenharmony_ci } 69608c2ecf20Sopenharmony_ci 69618c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 69628c2ecf20Sopenharmony_ci 69638c2ecf20Sopenharmony_ci i = 0; 69648c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) i = 2; 69658c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) i = 1; 69668c2ecf20Sopenharmony_ci 69678c2ecf20Sopenharmony_ci TimingPoint = &SiS_YPbPrTable[i][0]; 69688c2ecf20Sopenharmony_ci 69698c2ecf20Sopenharmony_ci PhaseIndex = 0x00; /* SiS_NTSCPhase */ 69708c2ecf20Sopenharmony_ci 69718c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_TVMode & TVSetPAL) { 69728c2ecf20Sopenharmony_ci 69738c2ecf20Sopenharmony_ci if(newtvphase) PhaseIndex = 0x09; /* SiS_PALPhase2 */ 69748c2ecf20Sopenharmony_ci 69758c2ecf20Sopenharmony_ci } else { 69768c2ecf20Sopenharmony_ci 69778c2ecf20Sopenharmony_ci TimingPoint = SiS_Pr->SiS_NTSCTiming; 69788c2ecf20Sopenharmony_ci PhaseIndex = (SiS_Pr->SiS_TVMode & TVSetNTSCJ) ? 0x01 : 0x00; /* SiS_PALPhase : SiS_NTSCPhase */ 69798c2ecf20Sopenharmony_ci if(newtvphase) PhaseIndex += 8; /* SiS_PALPhase2 : SiS_NTSCPhase2 */ 69808c2ecf20Sopenharmony_ci 69818c2ecf20Sopenharmony_ci } 69828c2ecf20Sopenharmony_ci 69838c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetPALM | TVSetPALN)) { 69848c2ecf20Sopenharmony_ci PhaseIndex = (SiS_Pr->SiS_TVMode & TVSetPALM) ? 0x02 : 0x03; /* SiS_PALMPhase : SiS_PALNPhase */ 69858c2ecf20Sopenharmony_ci if(newtvphase) PhaseIndex += 8; /* SiS_PALMPhase2 : SiS_PALNPhase2 */ 69868c2ecf20Sopenharmony_ci } 69878c2ecf20Sopenharmony_ci 69888c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { 69898c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPALM) { 69908c2ecf20Sopenharmony_ci PhaseIndex = 0x05; /* SiS_SpecialPhaseM */ 69918c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { 69928c2ecf20Sopenharmony_ci PhaseIndex = 0x11; /* SiS_SpecialPhaseJ */ 69938c2ecf20Sopenharmony_ci } else { 69948c2ecf20Sopenharmony_ci PhaseIndex = 0x10; /* SiS_SpecialPhase */ 69958c2ecf20Sopenharmony_ci } 69968c2ecf20Sopenharmony_ci } 69978c2ecf20Sopenharmony_ci 69988c2ecf20Sopenharmony_ci for(i = 0x31, j = 0; i <= 0x34; i++, j++) { 69998c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS_TVPhase[(PhaseIndex * 4) + j]); 70008c2ecf20Sopenharmony_ci } 70018c2ecf20Sopenharmony_ci 70028c2ecf20Sopenharmony_ci for(i = 0x01, j = 0; i <= 0x2D; i++, j++) { 70038c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); 70048c2ecf20Sopenharmony_ci } 70058c2ecf20Sopenharmony_ci for(i = 0x39; i <= 0x45; i++, j++) { 70068c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); 70078c2ecf20Sopenharmony_ci } 70088c2ecf20Sopenharmony_ci 70098c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 70108c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType != ModeText) { 70118c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F); 70128c2ecf20Sopenharmony_ci } 70138c2ecf20Sopenharmony_ci } 70148c2ecf20Sopenharmony_ci 70158c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x0A,SiS_Pr->SiS_NewFlickerMode); 70168c2ecf20Sopenharmony_ci 70178c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x35,SiS_Pr->SiS_RY1COE); 70188c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x36,SiS_Pr->SiS_RY2COE); 70198c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x37,SiS_Pr->SiS_RY3COE); 70208c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x38,SiS_Pr->SiS_RY4COE); 70218c2ecf20Sopenharmony_ci 70228c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempax = 950; 70238c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempax = 680; 70248c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetPAL) tempax = 520; 70258c2ecf20Sopenharmony_ci else tempax = 440; /* NTSC, YPbPr 525 */ 70268c2ecf20Sopenharmony_ci 70278c2ecf20Sopenharmony_ci if( ((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) && (SiS_Pr->SiS_VDE <= tempax)) || 70288c2ecf20Sopenharmony_ci ( (SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) && 70298c2ecf20Sopenharmony_ci ((SiS_Pr->SiS_VGAHDE == 1024) || (SiS_Pr->SiS_VDE <= tempax)) ) ) { 70308c2ecf20Sopenharmony_ci 70318c2ecf20Sopenharmony_ci tempax -= SiS_Pr->SiS_VDE; 70328c2ecf20Sopenharmony_ci tempax >>= 1; 70338c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) { 70348c2ecf20Sopenharmony_ci tempax >>= 1; 70358c2ecf20Sopenharmony_ci } 70368c2ecf20Sopenharmony_ci tempax &= 0x00ff; 70378c2ecf20Sopenharmony_ci 70388c2ecf20Sopenharmony_ci temp = tempax + (unsigned short)TimingPoint[0]; 70398c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); 70408c2ecf20Sopenharmony_ci 70418c2ecf20Sopenharmony_ci temp = tempax + (unsigned short)TimingPoint[1]; 70428c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp); 70438c2ecf20Sopenharmony_ci 70448c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) && (SiS_Pr->SiS_VGAHDE >= 1024)) { 70458c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) { 70468c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b); 70478c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54); 70488c2ecf20Sopenharmony_ci } else { 70498c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x17); 70508c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1d); 70518c2ecf20Sopenharmony_ci } 70528c2ecf20Sopenharmony_ci } 70538c2ecf20Sopenharmony_ci 70548c2ecf20Sopenharmony_ci } 70558c2ecf20Sopenharmony_ci 70568c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_HT; 70578c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) tempcx >>= 1; 70588c2ecf20Sopenharmony_ci tempcx--; 70598c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) tempcx--; 70608c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1B,tempcx); 70618c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0xF0,((tempcx >> 8) & 0x0f)); 70628c2ecf20Sopenharmony_ci 70638c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_HT >> 1; 70648c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) tempcx >>= 1; 70658c2ecf20Sopenharmony_ci tempcx += 7; 70668c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4; 70678c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x22,0x0F,((tempcx << 4) & 0xf0)); 70688c2ecf20Sopenharmony_ci 70698c2ecf20Sopenharmony_ci tempbx = TimingPoint[j] | (TimingPoint[j+1] << 8); 70708c2ecf20Sopenharmony_ci tempbx += tempcx; 70718c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x24,tempbx); 70728c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0F,((tempbx >> 4) & 0xf0)); 70738c2ecf20Sopenharmony_ci 70748c2ecf20Sopenharmony_ci tempbx += 8; 70758c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 70768c2ecf20Sopenharmony_ci tempbx -= 4; 70778c2ecf20Sopenharmony_ci tempcx = tempbx; 70788c2ecf20Sopenharmony_ci } 70798c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x29,0x0F,((tempbx << 4) & 0xf0)); 70808c2ecf20Sopenharmony_ci 70818c2ecf20Sopenharmony_ci j += 2; 70828c2ecf20Sopenharmony_ci tempcx += (TimingPoint[j] | (TimingPoint[j+1] << 8)); 70838c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x27,tempcx); 70848c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x28,0x0F,((tempcx >> 4) & 0xf0)); 70858c2ecf20Sopenharmony_ci 70868c2ecf20Sopenharmony_ci tempcx += 8; 70878c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4; 70888c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2A,0x0F,((tempcx << 4) & 0xf0)); 70898c2ecf20Sopenharmony_ci 70908c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_HT >> 1; 70918c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) tempcx >>= 1; 70928c2ecf20Sopenharmony_ci j += 2; 70938c2ecf20Sopenharmony_ci tempcx -= (TimingPoint[j] | ((TimingPoint[j+1]) << 8)); 70948c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2D,0x0F,((tempcx << 4) & 0xf0)); 70958c2ecf20Sopenharmony_ci 70968c2ecf20Sopenharmony_ci tempcx -= 11; 70978c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { 70988c2ecf20Sopenharmony_ci tempcx = SiS_GetVGAHT2(SiS_Pr) - 1; 70998c2ecf20Sopenharmony_ci } 71008c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2E,tempcx); 71018c2ecf20Sopenharmony_ci 71028c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_VDE; 71038c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 71048c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE == 360) tempbx = 746; 71058c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 746; 71068c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 853; 71078c2ecf20Sopenharmony_ci } else if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && 71088c2ecf20Sopenharmony_ci (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p))) ) { 71098c2ecf20Sopenharmony_ci tempbx >>= 1; 71108c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 71118c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { 71128c2ecf20Sopenharmony_ci if((ModeNo <= 0x13) && (crt2crtc == 1)) tempbx++; 71138c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 71148c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType <= ModeVGA) { 71158c2ecf20Sopenharmony_ci if(crt2crtc == 4) tempbx++; 71168c2ecf20Sopenharmony_ci } 71178c2ecf20Sopenharmony_ci } 71188c2ecf20Sopenharmony_ci } 71198c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 71208c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 71218c2ecf20Sopenharmony_ci if((ModeNo == 0x2f) || (ModeNo == 0x5d) || (ModeNo == 0x5e)) tempbx++; 71228c2ecf20Sopenharmony_ci } 71238c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { 71248c2ecf20Sopenharmony_ci if(ModeNo == 0x03) tempbx++; /* From 1.10.7w - doesn't make sense */ 71258c2ecf20Sopenharmony_ci } 71268c2ecf20Sopenharmony_ci } 71278c2ecf20Sopenharmony_ci } 71288c2ecf20Sopenharmony_ci tempbx -= 2; 71298c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2F,tempbx); 71308c2ecf20Sopenharmony_ci 71318c2ecf20Sopenharmony_ci temp = (tempcx >> 8) & 0x0F; 71328c2ecf20Sopenharmony_ci temp |= ((tempbx >> 2) & 0xC0); 71338c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) { 71348c2ecf20Sopenharmony_ci temp |= 0x10; 71358c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToAVIDEO) temp |= 0x20; 71368c2ecf20Sopenharmony_ci } 71378c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,temp); 71388c2ecf20Sopenharmony_ci 71398c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISPART4OVERFLOW) { 71408c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xdf,((tempbx & 0x0400) >> 5)); 71418c2ecf20Sopenharmony_ci } 71428c2ecf20Sopenharmony_ci 71438c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 71448c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_VDE; 71458c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && 71468c2ecf20Sopenharmony_ci (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) ) { 71478c2ecf20Sopenharmony_ci tempbx >>= 1; 71488c2ecf20Sopenharmony_ci } 71498c2ecf20Sopenharmony_ci tempbx -= 3; 71508c2ecf20Sopenharmony_ci temp = ((tempbx >> 3) & 0x60) | 0x18; 71518c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x46,temp); 71528c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x47,tempbx); 71538c2ecf20Sopenharmony_ci 71548c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISPART4OVERFLOW) { 71558c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xbf,((tempbx & 0x0400) >> 4)); 71568c2ecf20Sopenharmony_ci } 71578c2ecf20Sopenharmony_ci } 71588c2ecf20Sopenharmony_ci 71598c2ecf20Sopenharmony_ci tempbx = 0; 71608c2ecf20Sopenharmony_ci if(!(modeflag & HalfDCLK)) { 71618c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAHDE >= SiS_Pr->SiS_HDE) { 71628c2ecf20Sopenharmony_ci tempax = 0; 71638c2ecf20Sopenharmony_ci tempbx |= 0x20; 71648c2ecf20Sopenharmony_ci } 71658c2ecf20Sopenharmony_ci } 71668c2ecf20Sopenharmony_ci 71678c2ecf20Sopenharmony_ci tempch = tempcl = 0x01; 71688c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 71698c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAHDE >= 960) { 71708c2ecf20Sopenharmony_ci if((!(modeflag & HalfDCLK)) || (SiS_Pr->ChipType < SIS_315H)) { 71718c2ecf20Sopenharmony_ci tempcl = 0x20; 71728c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAHDE >= 1280) { 71738c2ecf20Sopenharmony_ci tempch = 20; 71748c2ecf20Sopenharmony_ci tempbx &= ~0x20; 71758c2ecf20Sopenharmony_ci } else { 71768c2ecf20Sopenharmony_ci tempch = 25; /* OK */ 71778c2ecf20Sopenharmony_ci } 71788c2ecf20Sopenharmony_ci } 71798c2ecf20Sopenharmony_ci } 71808c2ecf20Sopenharmony_ci } 71818c2ecf20Sopenharmony_ci 71828c2ecf20Sopenharmony_ci if(!(tempbx & 0x20)) { 71838c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempcl <<= 1; 71848c2ecf20Sopenharmony_ci longtemp = ((SiS_Pr->SiS_VGAHDE * tempch) / tempcl) << 13; 71858c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) longtemp <<= 3; 71868c2ecf20Sopenharmony_ci tempax = longtemp / SiS_Pr->SiS_HDE; 71878c2ecf20Sopenharmony_ci if(longtemp % SiS_Pr->SiS_HDE) tempax++; 71888c2ecf20Sopenharmony_ci tempbx |= ((tempax >> 8) & 0x1F); 71898c2ecf20Sopenharmony_ci tempcx = tempax >> 13; 71908c2ecf20Sopenharmony_ci } 71918c2ecf20Sopenharmony_ci 71928c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x44,tempax); 71938c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,tempbx); 71948c2ecf20Sopenharmony_ci 71958c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 71968c2ecf20Sopenharmony_ci 71978c2ecf20Sopenharmony_ci tempcx &= 0x07; 71988c2ecf20Sopenharmony_ci if(tempbx & 0x20) tempcx = 0; 71998c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x46,0xF8,tempcx); 72008c2ecf20Sopenharmony_ci 72018c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) { 72028c2ecf20Sopenharmony_ci tempbx = 0x0382; 72038c2ecf20Sopenharmony_ci tempcx = 0x007e; 72048c2ecf20Sopenharmony_ci } else { 72058c2ecf20Sopenharmony_ci tempbx = 0x0369; 72068c2ecf20Sopenharmony_ci tempcx = 0x0061; 72078c2ecf20Sopenharmony_ci } 72088c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4B,tempbx); 72098c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4C,tempcx); 72108c2ecf20Sopenharmony_ci temp = (tempcx & 0x0300) >> 6; 72118c2ecf20Sopenharmony_ci temp |= ((tempbx >> 8) & 0x03); 72128c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 72138c2ecf20Sopenharmony_ci temp |= 0x10; 72148c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) temp |= 0x20; 72158c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) temp |= 0x40; 72168c2ecf20Sopenharmony_ci } 72178c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4D,temp); 72188c2ecf20Sopenharmony_ci 72198c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43); 72208c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,(temp - 3)); 72218c2ecf20Sopenharmony_ci 72228c2ecf20Sopenharmony_ci SiS_SetTVSpecial(SiS_Pr, ModeNo); 72238c2ecf20Sopenharmony_ci 72248c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) { 72258c2ecf20Sopenharmony_ci temp = 0; 72268c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 8; 72278c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4e,0xf7,temp); 72288c2ecf20Sopenharmony_ci } 72298c2ecf20Sopenharmony_ci 72308c2ecf20Sopenharmony_ci } 72318c2ecf20Sopenharmony_ci 72328c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPALM) { 72338c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & TVSetNTSC1024)) { 72348c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x01); 72358c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,(temp - 1)); 72368c2ecf20Sopenharmony_ci } 72378c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xEF); 72388c2ecf20Sopenharmony_ci } 72398c2ecf20Sopenharmony_ci 72408c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 72418c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 72428c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0B,0x00); 72438c2ecf20Sopenharmony_ci } 72448c2ecf20Sopenharmony_ci } 72458c2ecf20Sopenharmony_ci 72468c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) return; 72478c2ecf20Sopenharmony_ci 72488c2ecf20Sopenharmony_ci /* From here: Part2 LCD setup */ 72498c2ecf20Sopenharmony_ci 72508c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_HDE; 72518c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; 72528c2ecf20Sopenharmony_ci tempbx--; /* RHACTE = HDE - 1 */ 72538c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2C,tempbx); 72548c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,((tempbx >> 4) & 0xf0)); 72558c2ecf20Sopenharmony_ci 72568c2ecf20Sopenharmony_ci temp = 0x01; 72578c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { 72588c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType == ModeEGA) { 72598c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAHDE >= 1024) { 72608c2ecf20Sopenharmony_ci temp = 0x02; 72618c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { 72628c2ecf20Sopenharmony_ci temp = 0x01; 72638c2ecf20Sopenharmony_ci } 72648c2ecf20Sopenharmony_ci } 72658c2ecf20Sopenharmony_ci } 72668c2ecf20Sopenharmony_ci } 72678c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0B,temp); 72688c2ecf20Sopenharmony_ci 72698c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_VDE - 1; 72708c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x03,tempbx); 72718c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0C,0xF8,((tempbx >> 8) & 0x07)); 72728c2ecf20Sopenharmony_ci 72738c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_VT - 1; 72748c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x19,tempcx); 72758c2ecf20Sopenharmony_ci temp = (tempcx >> 3) & 0xE0; 72768c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { 72778c2ecf20Sopenharmony_ci /* Enable dithering; only do this for 32bpp mode */ 72788c2ecf20Sopenharmony_ci if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { 72798c2ecf20Sopenharmony_ci temp |= 0x10; 72808c2ecf20Sopenharmony_ci } 72818c2ecf20Sopenharmony_ci } 72828c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1A,0x0f,temp); 72838c2ecf20Sopenharmony_ci 72848c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x09,0xF0); 72858c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x0A,0xF0); 72868c2ecf20Sopenharmony_ci 72878c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x17,0xFB); 72888c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x18,0xDF); 72898c2ecf20Sopenharmony_ci 72908c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 72918c2ecf20Sopenharmony_ci if(SiS_GetCRT2Part2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, 72928c2ecf20Sopenharmony_ci &CRT2Index, &resindex)) { 72938c2ecf20Sopenharmony_ci switch(CRT2Index) { 72948c2ecf20Sopenharmony_ci case 206: CRT2Part2Ptr = SiS310_CRT2Part2_Asus1024x768_3; break; 72958c2ecf20Sopenharmony_ci default: 72968c2ecf20Sopenharmony_ci case 200: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; break; 72978c2ecf20Sopenharmony_ci } 72988c2ecf20Sopenharmony_ci 72998c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]); 73008c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]); 73018c2ecf20Sopenharmony_ci for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) { 73028c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); 73038c2ecf20Sopenharmony_ci } 73048c2ecf20Sopenharmony_ci for(j = 0x1c; j <= 0x1d; i++, j++ ) { 73058c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); 73068c2ecf20Sopenharmony_ci } 73078c2ecf20Sopenharmony_ci for(j = 0x1f; j <= 0x21; i++, j++ ) { 73088c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); 73098c2ecf20Sopenharmony_ci } 73108c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]); 73118c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]); 73128c2ecf20Sopenharmony_ci 73138c2ecf20Sopenharmony_ci SiS_SetGroup2_Tail(SiS_Pr, ModeNo); 73148c2ecf20Sopenharmony_ci 73158c2ecf20Sopenharmony_ci } else { 73168c2ecf20Sopenharmony_ci#endif 73178c2ecf20Sopenharmony_ci 73188c2ecf20Sopenharmony_ci /* Checked for 1024x768, 1280x1024, 1400x1050, 1600x1200 */ 73198c2ecf20Sopenharmony_ci /* Clevo dual-link 1024x768 */ 73208c2ecf20Sopenharmony_ci /* Compaq 1280x1024 has HT 1696 sometimes (calculation OK, if given HT is correct) */ 73218c2ecf20Sopenharmony_ci /* Acer: OK, but uses different setting for VESA timing at 640/800/1024 and 640x400 */ 73228c2ecf20Sopenharmony_ci 73238c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 73248c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDInfo & LCDPass11) || (SiS_Pr->PanelYRes == SiS_Pr->SiS_VDE)) { 73258c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_VDE - 1; 73268c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_VT - 1; 73278c2ecf20Sopenharmony_ci } else { 73288c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_VDE + ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VDE) / 2); 73298c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VDE) / 2); 73308c2ecf20Sopenharmony_ci } 73318c2ecf20Sopenharmony_ci } else { 73328c2ecf20Sopenharmony_ci tempbx = SiS_Pr->PanelYRes; 73338c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_VT; 73348c2ecf20Sopenharmony_ci tempax = 1; 73358c2ecf20Sopenharmony_ci if(SiS_Pr->PanelYRes != SiS_Pr->SiS_VDE) { 73368c2ecf20Sopenharmony_ci tempax = SiS_Pr->PanelYRes; 73378c2ecf20Sopenharmony_ci /* if(SiS_Pr->SiS_VGAVDE == 525) tempax += 0x3c; */ /* 651+301C */ 73388c2ecf20Sopenharmony_ci if(SiS_Pr->PanelYRes < SiS_Pr->SiS_VDE) { 73398c2ecf20Sopenharmony_ci tempax = tempcx = 0; 73408c2ecf20Sopenharmony_ci } else { 73418c2ecf20Sopenharmony_ci tempax -= SiS_Pr->SiS_VDE; 73428c2ecf20Sopenharmony_ci } 73438c2ecf20Sopenharmony_ci tempax >>= 1; 73448c2ecf20Sopenharmony_ci } 73458c2ecf20Sopenharmony_ci tempcx -= tempax; /* lcdvdes */ 73468c2ecf20Sopenharmony_ci tempbx -= tempax; /* lcdvdee */ 73478c2ecf20Sopenharmony_ci } 73488c2ecf20Sopenharmony_ci 73498c2ecf20Sopenharmony_ci /* Non-expanding: lcdvdes = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */ 73508c2ecf20Sopenharmony_ci 73518c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,tempcx); /* lcdvdes */ 73528c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,tempbx); /* lcdvdee */ 73538c2ecf20Sopenharmony_ci 73548c2ecf20Sopenharmony_ci temp = (tempbx >> 5) & 0x38; 73558c2ecf20Sopenharmony_ci temp |= ((tempcx >> 8) & 0x07); 73568c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp); 73578c2ecf20Sopenharmony_ci 73588c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_VDE; 73598c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { 73608c2ecf20Sopenharmony_ci tempax = SiS_Pr->PanelYRes; 73618c2ecf20Sopenharmony_ci } 73628c2ecf20Sopenharmony_ci tempcx = (SiS_Pr->SiS_VT - tempax) >> 4; 73638c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { 73648c2ecf20Sopenharmony_ci if(SiS_Pr->PanelYRes != SiS_Pr->SiS_VDE) { 73658c2ecf20Sopenharmony_ci tempcx = (SiS_Pr->SiS_VT - tempax) / 10; 73668c2ecf20Sopenharmony_ci } 73678c2ecf20Sopenharmony_ci } 73688c2ecf20Sopenharmony_ci 73698c2ecf20Sopenharmony_ci tempbx = ((SiS_Pr->SiS_VT + SiS_Pr->SiS_VDE) >> 1) - 1; 73708c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 73718c2ecf20Sopenharmony_ci if(SiS_Pr->PanelYRes != SiS_Pr->SiS_VDE) { 73728c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { /* ? */ 73738c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_VT - SiS_Pr->PanelYRes; 73748c2ecf20Sopenharmony_ci if(tempax % 4) { tempax >>= 2; tempax++; } 73758c2ecf20Sopenharmony_ci else { tempax >>= 2; } 73768c2ecf20Sopenharmony_ci tempbx -= (tempax - 1); 73778c2ecf20Sopenharmony_ci } else { 73788c2ecf20Sopenharmony_ci tempbx -= 10; 73798c2ecf20Sopenharmony_ci if(tempbx <= SiS_Pr->SiS_VDE) tempbx = SiS_Pr->SiS_VDE + 1; 73808c2ecf20Sopenharmony_ci } 73818c2ecf20Sopenharmony_ci } 73828c2ecf20Sopenharmony_ci } 73838c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 73848c2ecf20Sopenharmony_ci tempbx++; 73858c2ecf20Sopenharmony_ci if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (crt2crtc == 6)) { 73868c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { 73878c2ecf20Sopenharmony_ci tempbx = 770; 73888c2ecf20Sopenharmony_ci tempcx = 3; 73898c2ecf20Sopenharmony_ci } 73908c2ecf20Sopenharmony_ci } 73918c2ecf20Sopenharmony_ci } 73928c2ecf20Sopenharmony_ci 73938c2ecf20Sopenharmony_ci /* non-expanding: lcdvrs = ((VT + VDE) / 2) - 10 */ 73948c2ecf20Sopenharmony_ci 73958c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 73968c2ecf20Sopenharmony_ci tempbx = SiS_Pr->CVSyncStart; 73978c2ecf20Sopenharmony_ci } 73988c2ecf20Sopenharmony_ci 73998c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,tempbx); /* lcdvrs */ 74008c2ecf20Sopenharmony_ci 74018c2ecf20Sopenharmony_ci temp = (tempbx >> 4) & 0xF0; 74028c2ecf20Sopenharmony_ci tempbx += (tempcx + 1); 74038c2ecf20Sopenharmony_ci temp |= (tempbx & 0x0F); 74048c2ecf20Sopenharmony_ci 74058c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 74068c2ecf20Sopenharmony_ci temp &= 0xf0; 74078c2ecf20Sopenharmony_ci temp |= (SiS_Pr->CVSyncEnd & 0x0f); 74088c2ecf20Sopenharmony_ci } 74098c2ecf20Sopenharmony_ci 74108c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); 74118c2ecf20Sopenharmony_ci 74128c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 74138c2ecf20Sopenharmony_ci SiS_Group2LCDSpecial(SiS_Pr, ModeNo, crt2crtc); 74148c2ecf20Sopenharmony_ci#endif 74158c2ecf20Sopenharmony_ci 74168c2ecf20Sopenharmony_ci bridgeoffset = 7; 74178c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) bridgeoffset += 2; 74188c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) bridgeoffset += 2; /* OK for Averatec 1280x800 (301C) */ 74198c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) bridgeoffset++; 74208c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VBType & VB_SIS302LV) bridgeoffset++; /* OK for Asus A4L 1280x800 */ 74218c2ecf20Sopenharmony_ci /* Higher bridgeoffset shifts to the LEFT */ 74228c2ecf20Sopenharmony_ci 74238c2ecf20Sopenharmony_ci temp = 0; 74248c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { 74258c2ecf20Sopenharmony_ci if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) { 74268c2ecf20Sopenharmony_ci temp = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2); 74278c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) temp >>= 1; 74288c2ecf20Sopenharmony_ci } 74298c2ecf20Sopenharmony_ci } 74308c2ecf20Sopenharmony_ci temp += bridgeoffset; 74318c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1F,temp); /* lcdhdes */ 74328c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x20,0x0F,((temp >> 4) & 0xf0)); 74338c2ecf20Sopenharmony_ci 74348c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_HT; 74358c2ecf20Sopenharmony_ci tempax = tempbx = SiS_Pr->SiS_HDE; 74368c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { 74378c2ecf20Sopenharmony_ci if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) { 74388c2ecf20Sopenharmony_ci tempax = SiS_Pr->PanelXRes; 74398c2ecf20Sopenharmony_ci tempbx = SiS_Pr->PanelXRes - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2); 74408c2ecf20Sopenharmony_ci } 74418c2ecf20Sopenharmony_ci } 74428c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) { 74438c2ecf20Sopenharmony_ci tempcx >>= 1; 74448c2ecf20Sopenharmony_ci tempbx >>= 1; 74458c2ecf20Sopenharmony_ci tempax >>= 1; 74468c2ecf20Sopenharmony_ci } 74478c2ecf20Sopenharmony_ci 74488c2ecf20Sopenharmony_ci tempbx += bridgeoffset; 74498c2ecf20Sopenharmony_ci 74508c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,tempbx); /* lcdhdee */ 74518c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0xF0,((tempbx >> 8) & 0x0f)); 74528c2ecf20Sopenharmony_ci 74538c2ecf20Sopenharmony_ci tempcx = (tempcx - tempax) >> 2; 74548c2ecf20Sopenharmony_ci 74558c2ecf20Sopenharmony_ci tempbx += tempcx; 74568c2ecf20Sopenharmony_ci push2 = tempbx; 74578c2ecf20Sopenharmony_ci 74588c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { 74598c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 74608c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDPass11) { 74618c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_HDE == 1280) tempbx = (tempbx & 0xff00) | 0x47; 74628c2ecf20Sopenharmony_ci } 74638c2ecf20Sopenharmony_ci } 74648c2ecf20Sopenharmony_ci } 74658c2ecf20Sopenharmony_ci 74668c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 74678c2ecf20Sopenharmony_ci tempbx = SiS_Pr->CHSyncStart; 74688c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempbx <<= 1; 74698c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; 74708c2ecf20Sopenharmony_ci tempbx += bridgeoffset; 74718c2ecf20Sopenharmony_ci } 74728c2ecf20Sopenharmony_ci 74738c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1C,tempbx); /* lcdhrs */ 74748c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,((tempbx >> 4) & 0xf0)); 74758c2ecf20Sopenharmony_ci 74768c2ecf20Sopenharmony_ci tempbx = push2; 74778c2ecf20Sopenharmony_ci 74788c2ecf20Sopenharmony_ci tempcx <<= 1; 74798c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { 74808c2ecf20Sopenharmony_ci if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) tempcx >>= 2; 74818c2ecf20Sopenharmony_ci } 74828c2ecf20Sopenharmony_ci tempbx += tempcx; 74838c2ecf20Sopenharmony_ci 74848c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 74858c2ecf20Sopenharmony_ci tempbx = SiS_Pr->CHSyncEnd; 74868c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempbx <<= 1; 74878c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; 74888c2ecf20Sopenharmony_ci tempbx += bridgeoffset; 74898c2ecf20Sopenharmony_ci } 74908c2ecf20Sopenharmony_ci 74918c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,tempbx); /* lcdhre */ 74928c2ecf20Sopenharmony_ci 74938c2ecf20Sopenharmony_ci SiS_SetGroup2_Tail(SiS_Pr, ModeNo); 74948c2ecf20Sopenharmony_ci 74958c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 74968c2ecf20Sopenharmony_ci SiS_Set300Part2Regs(SiS_Pr, ModeIdIndex, RefreshRateTableIndex, ModeNo); 74978c2ecf20Sopenharmony_ci#endif 74988c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 74998c2ecf20Sopenharmony_ci } /* CRT2-LCD from table */ 75008c2ecf20Sopenharmony_ci#endif 75018c2ecf20Sopenharmony_ci} 75028c2ecf20Sopenharmony_ci 75038c2ecf20Sopenharmony_ci/*********************************************/ 75048c2ecf20Sopenharmony_ci/* SET PART 3 REGISTER GROUP */ 75058c2ecf20Sopenharmony_ci/*********************************************/ 75068c2ecf20Sopenharmony_ci 75078c2ecf20Sopenharmony_cistatic void 75088c2ecf20Sopenharmony_ciSiS_SetGroup3(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 75098c2ecf20Sopenharmony_ci{ 75108c2ecf20Sopenharmony_ci unsigned short i; 75118c2ecf20Sopenharmony_ci const unsigned char *tempdi; 75128c2ecf20Sopenharmony_ci 75138c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; 75148c2ecf20Sopenharmony_ci 75158c2ecf20Sopenharmony_ci#ifndef SIS_CP 75168c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part3Port,0x00,0x00); 75178c2ecf20Sopenharmony_ci#else 75188c2ecf20Sopenharmony_ci SIS_CP_INIT301_CP 75198c2ecf20Sopenharmony_ci#endif 75208c2ecf20Sopenharmony_ci 75218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) { 75228c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xFA); 75238c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xC8); 75248c2ecf20Sopenharmony_ci } else { 75258c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xF5); 75268c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xB7); 75278c2ecf20Sopenharmony_ci } 75288c2ecf20Sopenharmony_ci 75298c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPALM) { 75308c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xFA); 75318c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xC8); 75328c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part3Port,0x3D,0xA8); 75338c2ecf20Sopenharmony_ci } 75348c2ecf20Sopenharmony_ci 75358c2ecf20Sopenharmony_ci tempdi = NULL; 75368c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 75378c2ecf20Sopenharmony_ci tempdi = SiS_Pr->SiS_HiTVGroup3Data; 75388c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { 75398c2ecf20Sopenharmony_ci tempdi = SiS_Pr->SiS_HiTVGroup3Simu; 75408c2ecf20Sopenharmony_ci } 75418c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 75428c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & TVSetYPbPr525i)) { 75438c2ecf20Sopenharmony_ci tempdi = SiS_HiTVGroup3_1; 75448c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempdi = SiS_HiTVGroup3_2; 75458c2ecf20Sopenharmony_ci } 75468c2ecf20Sopenharmony_ci } 75478c2ecf20Sopenharmony_ci if(tempdi) { 75488c2ecf20Sopenharmony_ci for(i=0; i<=0x3E; i++) { 75498c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part3Port,i,tempdi[i]); 75508c2ecf20Sopenharmony_ci } 75518c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) { 75528c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { 75538c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part3Port,0x28,0x3f); 75548c2ecf20Sopenharmony_ci } 75558c2ecf20Sopenharmony_ci } 75568c2ecf20Sopenharmony_ci } 75578c2ecf20Sopenharmony_ci 75588c2ecf20Sopenharmony_ci#ifdef SIS_CP 75598c2ecf20Sopenharmony_ci SIS_CP_INIT301_CP2 75608c2ecf20Sopenharmony_ci#endif 75618c2ecf20Sopenharmony_ci} 75628c2ecf20Sopenharmony_ci 75638c2ecf20Sopenharmony_ci/*********************************************/ 75648c2ecf20Sopenharmony_ci/* SET PART 4 REGISTER GROUP */ 75658c2ecf20Sopenharmony_ci/*********************************************/ 75668c2ecf20Sopenharmony_ci 75678c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 75688c2ecf20Sopenharmony_ci#if 0 75698c2ecf20Sopenharmony_cistatic void 75708c2ecf20Sopenharmony_ciSiS_ShiftXPos(struct SiS_Private *SiS_Pr, int shift) 75718c2ecf20Sopenharmony_ci{ 75728c2ecf20Sopenharmony_ci unsigned short temp, temp1, temp2; 75738c2ecf20Sopenharmony_ci 75748c2ecf20Sopenharmony_ci temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x1f); 75758c2ecf20Sopenharmony_ci temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x20); 75768c2ecf20Sopenharmony_ci temp = (unsigned short)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); 75778c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1f,temp); 75788c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x20,0x0f,((temp >> 4) & 0xf0)); 75798c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x2b) & 0x0f; 75808c2ecf20Sopenharmony_ci temp = (unsigned short)((int)(temp) + shift); 75818c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2b,0xf0,(temp & 0x0f)); 75828c2ecf20Sopenharmony_ci temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43); 75838c2ecf20Sopenharmony_ci temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x42); 75848c2ecf20Sopenharmony_ci temp = (unsigned short)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); 75858c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,temp); 75868c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x42,0x0f,((temp >> 4) & 0xf0)); 75878c2ecf20Sopenharmony_ci} 75888c2ecf20Sopenharmony_ci#endif 75898c2ecf20Sopenharmony_ci 75908c2ecf20Sopenharmony_cistatic void 75918c2ecf20Sopenharmony_ciSiS_SetGroup4_C_ELV(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 75928c2ecf20Sopenharmony_ci{ 75938c2ecf20Sopenharmony_ci unsigned short temp, temp1; 75948c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 75958c2ecf20Sopenharmony_ci 75968c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBType & VB_SIS30xCLV)) return; 75978c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToHiVision | SetCRT2ToYPbPr525750))) return; 75988c2ecf20Sopenharmony_ci 75998c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= XGI_20) return; 76008c2ecf20Sopenharmony_ci 76018c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType >= SIS_661) && (SiS_Pr->SiS_ROMNew)) { 76028c2ecf20Sopenharmony_ci if(!(ROMAddr[0x61] & 0x04)) return; 76038c2ecf20Sopenharmony_ci } 76048c2ecf20Sopenharmony_ci 76058c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x3a,0x08); 76068c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x3a); 76078c2ecf20Sopenharmony_ci if(!(temp & 0x01)) { 76088c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3a,0xdf); 76098c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xfc); 76108c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType < SIS_661) && (!(SiS_Pr->SiS_ROMNew))) { 76118c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xf8); 76128c2ecf20Sopenharmony_ci } 76138c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x0f,0xfb); 76148c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) temp = 0x0000; 76158c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) temp = 0x0002; 76168c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetHiVision) temp = 0x0400; 76178c2ecf20Sopenharmony_ci else temp = 0x0402; 76188c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { 76198c2ecf20Sopenharmony_ci temp1 = 0; 76208c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVAspect43) temp1 = 4; 76218c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0f,0xfb,temp1); 76228c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVAspect43LB) temp |= 0x01; 76238c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0x7c,(temp & 0xff)); 76248c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8)); 76258c2ecf20Sopenharmony_ci if(ModeNo > 0x13) { 76268c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x39,0xfd); 76278c2ecf20Sopenharmony_ci } 76288c2ecf20Sopenharmony_ci } else { 76298c2ecf20Sopenharmony_ci temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x3b) & 0x03; 76308c2ecf20Sopenharmony_ci if(temp1 == 0x01) temp |= 0x01; 76318c2ecf20Sopenharmony_ci if(temp1 == 0x03) temp |= 0x04; /* ? why not 0x10? */ 76328c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xf8,(temp & 0xff)); 76338c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8)); 76348c2ecf20Sopenharmony_ci if(ModeNo > 0x13) { 76358c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3b,0xfd); 76368c2ecf20Sopenharmony_ci } 76378c2ecf20Sopenharmony_ci } 76388c2ecf20Sopenharmony_ci 76398c2ecf20Sopenharmony_ci#if 0 76408c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_661) { /* ? */ 76418c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVAspect43) { 76428c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { 76438c2ecf20Sopenharmony_ci if(resinfo == SIS_RI_1024x768) { 76448c2ecf20Sopenharmony_ci SiS_ShiftXPos(SiS_Pr, 97); 76458c2ecf20Sopenharmony_ci } else { 76468c2ecf20Sopenharmony_ci SiS_ShiftXPos(SiS_Pr, 111); 76478c2ecf20Sopenharmony_ci } 76488c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_TVMode & TVSetHiVision) { 76498c2ecf20Sopenharmony_ci SiS_ShiftXPos(SiS_Pr, 136); 76508c2ecf20Sopenharmony_ci } 76518c2ecf20Sopenharmony_ci } 76528c2ecf20Sopenharmony_ci } 76538c2ecf20Sopenharmony_ci#endif 76548c2ecf20Sopenharmony_ci 76558c2ecf20Sopenharmony_ci } 76568c2ecf20Sopenharmony_ci 76578c2ecf20Sopenharmony_ci} 76588c2ecf20Sopenharmony_ci#endif 76598c2ecf20Sopenharmony_ci 76608c2ecf20Sopenharmony_cistatic void 76618c2ecf20Sopenharmony_ciSiS_SetCRT2VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 76628c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 76638c2ecf20Sopenharmony_ci{ 76648c2ecf20Sopenharmony_ci unsigned short vclkindex, temp, reg1, reg2; 76658c2ecf20Sopenharmony_ci 76668c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 76678c2ecf20Sopenharmony_ci reg1 = SiS_Pr->CSR2B; 76688c2ecf20Sopenharmony_ci reg2 = SiS_Pr->CSR2C; 76698c2ecf20Sopenharmony_ci } else { 76708c2ecf20Sopenharmony_ci vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 76718c2ecf20Sopenharmony_ci reg1 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A; 76728c2ecf20Sopenharmony_ci reg2 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B; 76738c2ecf20Sopenharmony_ci } 76748c2ecf20Sopenharmony_ci 76758c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 76768c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSet525p1024)) { 76778c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,0x57); 76788c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,0x46); 76798c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1f,0xf6); 76808c2ecf20Sopenharmony_ci } else { 76818c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,reg1); 76828c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,reg2); 76838c2ecf20Sopenharmony_ci } 76848c2ecf20Sopenharmony_ci } else { 76858c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,0x01); 76868c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,reg2); 76878c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,reg1); 76888c2ecf20Sopenharmony_ci } 76898c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x12,0x00); 76908c2ecf20Sopenharmony_ci temp = 0x08; 76918c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) temp |= 0x20; 76928c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x12,temp); 76938c2ecf20Sopenharmony_ci} 76948c2ecf20Sopenharmony_ci 76958c2ecf20Sopenharmony_cistatic void 76968c2ecf20Sopenharmony_ciSiS_SetDualLinkEtc(struct SiS_Private *SiS_Pr) 76978c2ecf20Sopenharmony_ci{ 76988c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 76998c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) { 77008c2ecf20Sopenharmony_ci if((SiS_CRT2IsLCD(SiS_Pr)) || 77018c2ecf20Sopenharmony_ci (SiS_IsVAMode(SiS_Pr))) { 77028c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDDualLink) { 77038c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); 77048c2ecf20Sopenharmony_ci } else { 77058c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,~0x20); 77068c2ecf20Sopenharmony_ci } 77078c2ecf20Sopenharmony_ci } 77088c2ecf20Sopenharmony_ci } 77098c2ecf20Sopenharmony_ci } 77108c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISEMI) { 77118c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); 77128c2ecf20Sopenharmony_ci#ifdef SET_EMI 77138c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); 77148c2ecf20Sopenharmony_ci#endif 77158c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); 77168c2ecf20Sopenharmony_ci } 77178c2ecf20Sopenharmony_ci} 77188c2ecf20Sopenharmony_ci 77198c2ecf20Sopenharmony_cistatic void 77208c2ecf20Sopenharmony_ciSiS_SetGroup4(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 77218c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 77228c2ecf20Sopenharmony_ci{ 77238c2ecf20Sopenharmony_ci unsigned short tempax, tempcx, tempbx, modeflag, temp, resinfo; 77248c2ecf20Sopenharmony_ci unsigned int tempebx, tempeax, templong; 77258c2ecf20Sopenharmony_ci 77268c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 77278c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 77288c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; 77298c2ecf20Sopenharmony_ci } else if(SiS_Pr->UseCustomMode) { 77308c2ecf20Sopenharmony_ci modeflag = SiS_Pr->CModeFlag; 77318c2ecf20Sopenharmony_ci resinfo = 0; 77328c2ecf20Sopenharmony_ci } else { 77338c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 77348c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 77358c2ecf20Sopenharmony_ci } 77368c2ecf20Sopenharmony_ci 77378c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 77388c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 77398c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 77408c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); 77418c2ecf20Sopenharmony_ci } 77428c2ecf20Sopenharmony_ci } 77438c2ecf20Sopenharmony_ci } 77448c2ecf20Sopenharmony_ci 77458c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & (VB_SIS30xCLV | VB_SIS302LV)) { 77468c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 77478c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f); 77488c2ecf20Sopenharmony_ci } 77498c2ecf20Sopenharmony_ci } 77508c2ecf20Sopenharmony_ci 77518c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 77528c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 77538c2ecf20Sopenharmony_ci SiS_SetDualLinkEtc(SiS_Pr); 77548c2ecf20Sopenharmony_ci return; 77558c2ecf20Sopenharmony_ci } 77568c2ecf20Sopenharmony_ci } 77578c2ecf20Sopenharmony_ci 77588c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x13,SiS_Pr->SiS_RVBHCFACT); 77598c2ecf20Sopenharmony_ci 77608c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_RVBHCMAX; 77618c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x14,tempbx); 77628c2ecf20Sopenharmony_ci 77638c2ecf20Sopenharmony_ci temp = (tempbx >> 1) & 0x80; 77648c2ecf20Sopenharmony_ci 77658c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_VGAHT - 1; 77668c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x16,tempcx); 77678c2ecf20Sopenharmony_ci 77688c2ecf20Sopenharmony_ci temp |= ((tempcx >> 5) & 0x78); 77698c2ecf20Sopenharmony_ci 77708c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_VGAVT - 1; 77718c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempcx -= 5; 77728c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x17,tempcx); 77738c2ecf20Sopenharmony_ci 77748c2ecf20Sopenharmony_ci temp |= ((tempcx >> 8) & 0x07); 77758c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x15,temp); 77768c2ecf20Sopenharmony_ci 77778c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_VGAHDE; 77788c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempbx >>= 1; 77798c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; 77808c2ecf20Sopenharmony_ci 77818c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 77828c2ecf20Sopenharmony_ci temp = 0; 77838c2ecf20Sopenharmony_ci if(tempbx > 800) temp = 0x60; 77848c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 77858c2ecf20Sopenharmony_ci temp = 0; 77868c2ecf20Sopenharmony_ci if(tempbx > 1024) temp = 0xC0; 77878c2ecf20Sopenharmony_ci else if(tempbx >= 960) temp = 0xA0; 77888c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { 77898c2ecf20Sopenharmony_ci temp = 0; 77908c2ecf20Sopenharmony_ci if(tempbx >= 1280) temp = 0x40; 77918c2ecf20Sopenharmony_ci else if(tempbx >= 1024) temp = 0x20; 77928c2ecf20Sopenharmony_ci } else { 77938c2ecf20Sopenharmony_ci temp = 0x80; 77948c2ecf20Sopenharmony_ci if(tempbx >= 1024) temp = 0xA0; 77958c2ecf20Sopenharmony_ci } 77968c2ecf20Sopenharmony_ci 77978c2ecf20Sopenharmony_ci temp |= SiS_Pr->Init_P4_0E; 77988c2ecf20Sopenharmony_ci 77998c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS301) { 78008c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) { 78018c2ecf20Sopenharmony_ci temp &= 0xf0; 78028c2ecf20Sopenharmony_ci temp |= 0x0A; 78038c2ecf20Sopenharmony_ci } 78048c2ecf20Sopenharmony_ci } 78058c2ecf20Sopenharmony_ci 78068c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0E,0x10,temp); 78078c2ecf20Sopenharmony_ci 78088c2ecf20Sopenharmony_ci tempeax = SiS_Pr->SiS_VGAVDE; 78098c2ecf20Sopenharmony_ci tempebx = SiS_Pr->SiS_VDE; 78108c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 78118c2ecf20Sopenharmony_ci if(!(temp & 0xE0)) tempebx >>=1; 78128c2ecf20Sopenharmony_ci } 78138c2ecf20Sopenharmony_ci 78148c2ecf20Sopenharmony_ci tempcx = SiS_Pr->SiS_RVBHRS; 78158c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x18,tempcx); 78168c2ecf20Sopenharmony_ci tempcx >>= 8; 78178c2ecf20Sopenharmony_ci tempcx |= 0x40; 78188c2ecf20Sopenharmony_ci 78198c2ecf20Sopenharmony_ci if(tempeax <= tempebx) { 78208c2ecf20Sopenharmony_ci tempcx ^= 0x40; 78218c2ecf20Sopenharmony_ci } else { 78228c2ecf20Sopenharmony_ci tempeax -= tempebx; 78238c2ecf20Sopenharmony_ci } 78248c2ecf20Sopenharmony_ci 78258c2ecf20Sopenharmony_ci tempeax *= (256 * 1024); 78268c2ecf20Sopenharmony_ci templong = tempeax % tempebx; 78278c2ecf20Sopenharmony_ci tempeax /= tempebx; 78288c2ecf20Sopenharmony_ci if(templong) tempeax++; 78298c2ecf20Sopenharmony_ci 78308c2ecf20Sopenharmony_ci temp = (unsigned short)(tempeax & 0x000000FF); 78318c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1B,temp); 78328c2ecf20Sopenharmony_ci temp = (unsigned short)((tempeax & 0x0000FF00) >> 8); 78338c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1A,temp); 78348c2ecf20Sopenharmony_ci temp = (unsigned short)((tempeax >> 12) & 0x70); /* sic! */ 78358c2ecf20Sopenharmony_ci temp |= (tempcx & 0x4F); 78368c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x19,temp); 78378c2ecf20Sopenharmony_ci 78388c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 78398c2ecf20Sopenharmony_ci 78408c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1C,0x28); 78418c2ecf20Sopenharmony_ci 78428c2ecf20Sopenharmony_ci /* Calc Linebuffer max address and set/clear decimode */ 78438c2ecf20Sopenharmony_ci tempbx = 0; 78448c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr750p)) tempbx = 0x08; 78458c2ecf20Sopenharmony_ci tempax = SiS_Pr->SiS_VGAHDE; 78468c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) tempax >>= 1; 78478c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) tempax >>= 1; 78488c2ecf20Sopenharmony_ci if(tempax > 800) { 78498c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 78508c2ecf20Sopenharmony_ci tempax -= 800; 78518c2ecf20Sopenharmony_ci } else { 78528c2ecf20Sopenharmony_ci tempbx = 0x08; 78538c2ecf20Sopenharmony_ci if(tempax == 960) tempax *= 25; /* Correct */ 78548c2ecf20Sopenharmony_ci else if(tempax == 1024) tempax *= 25; 78558c2ecf20Sopenharmony_ci else tempax *= 20; 78568c2ecf20Sopenharmony_ci temp = tempax % 32; 78578c2ecf20Sopenharmony_ci tempax /= 32; 78588c2ecf20Sopenharmony_ci if(temp) tempax++; 78598c2ecf20Sopenharmony_ci tempax++; 78608c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 78618c2ecf20Sopenharmony_ci if(resinfo == SIS_RI_1024x768 || 78628c2ecf20Sopenharmony_ci resinfo == SIS_RI_1024x576 || 78638c2ecf20Sopenharmony_ci resinfo == SIS_RI_1280x1024 || 78648c2ecf20Sopenharmony_ci resinfo == SIS_RI_1280x720) { 78658c2ecf20Sopenharmony_ci /* Otherwise white line or garbage at right edge */ 78668c2ecf20Sopenharmony_ci tempax = (tempax & 0xff00) | 0x20; 78678c2ecf20Sopenharmony_ci } 78688c2ecf20Sopenharmony_ci } 78698c2ecf20Sopenharmony_ci } 78708c2ecf20Sopenharmony_ci } 78718c2ecf20Sopenharmony_ci tempax--; 78728c2ecf20Sopenharmony_ci temp = ((tempax >> 4) & 0x30) | tempbx; 78738c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1D,tempax); 78748c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1E,temp); 78758c2ecf20Sopenharmony_ci 78768c2ecf20Sopenharmony_ci temp = 0x0036; tempbx = 0xD0; 78778c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { 78788c2ecf20Sopenharmony_ci temp = 0x0026; tempbx = 0xC0; /* See En/DisableBridge() */ 78798c2ecf20Sopenharmony_ci } 78808c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 78818c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSetHiVision | TVSetYPbPr750p | TVSetYPbPr525p))) { 78828c2ecf20Sopenharmony_ci temp |= 0x01; 78838c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 78848c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) { 78858c2ecf20Sopenharmony_ci temp &= ~0x01; 78868c2ecf20Sopenharmony_ci } 78878c2ecf20Sopenharmony_ci } 78888c2ecf20Sopenharmony_ci } 78898c2ecf20Sopenharmony_ci } 78908c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,tempbx,temp); 78918c2ecf20Sopenharmony_ci 78928c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_HT >> 1; 78938c2ecf20Sopenharmony_ci if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; 78948c2ecf20Sopenharmony_ci tempbx -= 2; 78958c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x22,tempbx); 78968c2ecf20Sopenharmony_ci temp = (tempbx >> 5) & 0x38; 78978c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp); 78988c2ecf20Sopenharmony_ci 78998c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 79008c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 79018c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); 79028c2ecf20Sopenharmony_ci /* LCD-too-dark-error-source, see FinalizeLCD() */ 79038c2ecf20Sopenharmony_ci } 79048c2ecf20Sopenharmony_ci } 79058c2ecf20Sopenharmony_ci 79068c2ecf20Sopenharmony_ci SiS_SetDualLinkEtc(SiS_Pr); 79078c2ecf20Sopenharmony_ci 79088c2ecf20Sopenharmony_ci } /* 301B */ 79098c2ecf20Sopenharmony_ci 79108c2ecf20Sopenharmony_ci SiS_SetCRT2VCLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 79118c2ecf20Sopenharmony_ci} 79128c2ecf20Sopenharmony_ci 79138c2ecf20Sopenharmony_ci/*********************************************/ 79148c2ecf20Sopenharmony_ci/* SET PART 5 REGISTER GROUP */ 79158c2ecf20Sopenharmony_ci/*********************************************/ 79168c2ecf20Sopenharmony_ci 79178c2ecf20Sopenharmony_cistatic void 79188c2ecf20Sopenharmony_ciSiS_SetGroup5(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 79198c2ecf20Sopenharmony_ci{ 79208c2ecf20Sopenharmony_ci 79218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; 79228c2ecf20Sopenharmony_ci 79238c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType == ModeVGA) { 79248c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))) { 79258c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); 79268c2ecf20Sopenharmony_ci SiS_LoadDAC(SiS_Pr, ModeNo, ModeIdIndex); 79278c2ecf20Sopenharmony_ci } 79288c2ecf20Sopenharmony_ci } 79298c2ecf20Sopenharmony_ci} 79308c2ecf20Sopenharmony_ci 79318c2ecf20Sopenharmony_ci/*********************************************/ 79328c2ecf20Sopenharmony_ci/* MODIFY CRT1 GROUP FOR SLAVE MODE */ 79338c2ecf20Sopenharmony_ci/*********************************************/ 79348c2ecf20Sopenharmony_ci 79358c2ecf20Sopenharmony_cistatic bool 79368c2ecf20Sopenharmony_ciSiS_GetLVDSCRT1Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 79378c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex, unsigned short *ResIndex, 79388c2ecf20Sopenharmony_ci unsigned short *DisplayType) 79398c2ecf20Sopenharmony_ci { 79408c2ecf20Sopenharmony_ci unsigned short modeflag = 0; 79418c2ecf20Sopenharmony_ci bool checkhd = true; 79428c2ecf20Sopenharmony_ci 79438c2ecf20Sopenharmony_ci /* Pass 1:1 not supported here */ 79448c2ecf20Sopenharmony_ci 79458c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 79468c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 79478c2ecf20Sopenharmony_ci (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 79488c2ecf20Sopenharmony_ci } else { 79498c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 79508c2ecf20Sopenharmony_ci (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 79518c2ecf20Sopenharmony_ci } 79528c2ecf20Sopenharmony_ci 79538c2ecf20Sopenharmony_ci (*ResIndex) &= 0x3F; 79548c2ecf20Sopenharmony_ci 79558c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { 79568c2ecf20Sopenharmony_ci 79578c2ecf20Sopenharmony_ci (*DisplayType) = 80; 79588c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) { 79598c2ecf20Sopenharmony_ci (*DisplayType) = 82; 79608c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType > ModeVGA) { 79618c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CHSOverScan) (*DisplayType) = 84; 79628c2ecf20Sopenharmony_ci } 79638c2ecf20Sopenharmony_ci } 79648c2ecf20Sopenharmony_ci if((*DisplayType) != 84) { 79658c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++; 79668c2ecf20Sopenharmony_ci } 79678c2ecf20Sopenharmony_ci 79688c2ecf20Sopenharmony_ci } else { 79698c2ecf20Sopenharmony_ci 79708c2ecf20Sopenharmony_ci (*DisplayType = 0); 79718c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 79728c2ecf20Sopenharmony_ci case Panel_320x240_1: (*DisplayType) = 50; 79738c2ecf20Sopenharmony_ci checkhd = false; 79748c2ecf20Sopenharmony_ci break; 79758c2ecf20Sopenharmony_ci case Panel_320x240_2: (*DisplayType) = 14; 79768c2ecf20Sopenharmony_ci break; 79778c2ecf20Sopenharmony_ci case Panel_320x240_3: (*DisplayType) = 18; 79788c2ecf20Sopenharmony_ci break; 79798c2ecf20Sopenharmony_ci case Panel_640x480: (*DisplayType) = 10; 79808c2ecf20Sopenharmony_ci break; 79818c2ecf20Sopenharmony_ci case Panel_1024x600: (*DisplayType) = 26; 79828c2ecf20Sopenharmony_ci break; 79838c2ecf20Sopenharmony_ci default: return true; 79848c2ecf20Sopenharmony_ci } 79858c2ecf20Sopenharmony_ci 79868c2ecf20Sopenharmony_ci if(checkhd) { 79878c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) (*DisplayType)++; 79888c2ecf20Sopenharmony_ci } 79898c2ecf20Sopenharmony_ci 79908c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x600) { 79918c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) (*DisplayType) += 2; 79928c2ecf20Sopenharmony_ci } 79938c2ecf20Sopenharmony_ci 79948c2ecf20Sopenharmony_ci } 79958c2ecf20Sopenharmony_ci 79968c2ecf20Sopenharmony_ci return true; 79978c2ecf20Sopenharmony_ci} 79988c2ecf20Sopenharmony_ci 79998c2ecf20Sopenharmony_cistatic void 80008c2ecf20Sopenharmony_ciSiS_ModCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 80018c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 80028c2ecf20Sopenharmony_ci{ 80038c2ecf20Sopenharmony_ci unsigned short tempah, i, modeflag, j, ResIndex, DisplayType; 80048c2ecf20Sopenharmony_ci const struct SiS_LVDSCRT1Data *LVDSCRT1Ptr=NULL; 80058c2ecf20Sopenharmony_ci static const unsigned short CRIdx[] = { 80068c2ecf20Sopenharmony_ci 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 80078c2ecf20Sopenharmony_ci 0x07, 0x10, 0x11, 0x15, 0x16 80088c2ecf20Sopenharmony_ci }; 80098c2ecf20Sopenharmony_ci 80108c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || 80118c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || 80128c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_PANEL848) || 80138c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) 80148c2ecf20Sopenharmony_ci return; 80158c2ecf20Sopenharmony_ci 80168c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS) { 80178c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 80188c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return; 80198c2ecf20Sopenharmony_ci } 80208c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 80218c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return; 80228c2ecf20Sopenharmony_ci } else return; 80238c2ecf20Sopenharmony_ci 80248c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDPass11) return; 80258c2ecf20Sopenharmony_ci 80268c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 80278c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & SetDOSMode) return; 80288c2ecf20Sopenharmony_ci } 80298c2ecf20Sopenharmony_ci 80308c2ecf20Sopenharmony_ci if(!(SiS_GetLVDSCRT1Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, 80318c2ecf20Sopenharmony_ci &ResIndex, &DisplayType))) { 80328c2ecf20Sopenharmony_ci return; 80338c2ecf20Sopenharmony_ci } 80348c2ecf20Sopenharmony_ci 80358c2ecf20Sopenharmony_ci switch(DisplayType) { 80368c2ecf20Sopenharmony_ci case 50: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_1; break; /* xSTN */ 80378c2ecf20Sopenharmony_ci case 14: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_2; break; /* xSTN */ 80388c2ecf20Sopenharmony_ci case 15: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_2_H; break; /* xSTN */ 80398c2ecf20Sopenharmony_ci case 18: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_3; break; /* xSTN */ 80408c2ecf20Sopenharmony_ci case 19: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_3_H; break; /* xSTN */ 80418c2ecf20Sopenharmony_ci case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1; break; 80428c2ecf20Sopenharmony_ci case 11: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1_H; break; 80438c2ecf20Sopenharmony_ci#if 0 /* Works better with calculated numbers */ 80448c2ecf20Sopenharmony_ci case 26: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1; break; 80458c2ecf20Sopenharmony_ci case 27: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1_H; break; 80468c2ecf20Sopenharmony_ci case 28: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2; break; 80478c2ecf20Sopenharmony_ci case 29: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2_H; break; 80488c2ecf20Sopenharmony_ci#endif 80498c2ecf20Sopenharmony_ci case 80: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UNTSC; break; 80508c2ecf20Sopenharmony_ci case 81: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1ONTSC; break; 80518c2ecf20Sopenharmony_ci case 82: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UPAL; break; 80528c2ecf20Sopenharmony_ci case 83: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break; 80538c2ecf20Sopenharmony_ci case 84: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1SOPAL; break; 80548c2ecf20Sopenharmony_ci } 80558c2ecf20Sopenharmony_ci 80568c2ecf20Sopenharmony_ci if(LVDSCRT1Ptr) { 80578c2ecf20Sopenharmony_ci 80588c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); 80598c2ecf20Sopenharmony_ci 80608c2ecf20Sopenharmony_ci for(i = 0; i <= 10; i++) { 80618c2ecf20Sopenharmony_ci tempah = (LVDSCRT1Ptr + ResIndex)->CR[i]; 80628c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3d4,CRIdx[i],tempah); 80638c2ecf20Sopenharmony_ci } 80648c2ecf20Sopenharmony_ci 80658c2ecf20Sopenharmony_ci for(i = 0x0A, j = 11; i <= 0x0C; i++, j++) { 80668c2ecf20Sopenharmony_ci tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; 80678c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,i,tempah); 80688c2ecf20Sopenharmony_ci } 80698c2ecf20Sopenharmony_ci 80708c2ecf20Sopenharmony_ci tempah = (LVDSCRT1Ptr + ResIndex)->CR[14] & 0xE0; 80718c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah); 80728c2ecf20Sopenharmony_ci 80738c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 80748c2ecf20Sopenharmony_ci else modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 80758c2ecf20Sopenharmony_ci 80768c2ecf20Sopenharmony_ci tempah = ((LVDSCRT1Ptr + ResIndex)->CR[14] & 0x01) << 5; 80778c2ecf20Sopenharmony_ci if(modeflag & DoubleScanMode) tempah |= 0x80; 80788c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah); 80798c2ecf20Sopenharmony_ci 80808c2ecf20Sopenharmony_ci } else { 80818c2ecf20Sopenharmony_ci 80828c2ecf20Sopenharmony_ci SiS_CalcLCDACRT1Timing(SiS_Pr, ModeNo, ModeIdIndex); 80838c2ecf20Sopenharmony_ci 80848c2ecf20Sopenharmony_ci } 80858c2ecf20Sopenharmony_ci} 80868c2ecf20Sopenharmony_ci 80878c2ecf20Sopenharmony_ci/*********************************************/ 80888c2ecf20Sopenharmony_ci/* SET CRT2 ECLK */ 80898c2ecf20Sopenharmony_ci/*********************************************/ 80908c2ecf20Sopenharmony_ci 80918c2ecf20Sopenharmony_cistatic void 80928c2ecf20Sopenharmony_ciSiS_SetCRT2ECLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 80938c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 80948c2ecf20Sopenharmony_ci{ 80958c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 80968c2ecf20Sopenharmony_ci unsigned short clkbase, vclkindex = 0; 80978c2ecf20Sopenharmony_ci unsigned char sr2b, sr2c; 80988c2ecf20Sopenharmony_ci 80998c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDPass11) { 81008c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); 81018c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK == 2) { 81028c2ecf20Sopenharmony_ci RefreshRateTableIndex--; 81038c2ecf20Sopenharmony_ci } 81048c2ecf20Sopenharmony_ci vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, 81058c2ecf20Sopenharmony_ci RefreshRateTableIndex); 81068c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; 81078c2ecf20Sopenharmony_ci } else { 81088c2ecf20Sopenharmony_ci vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, 81098c2ecf20Sopenharmony_ci RefreshRateTableIndex); 81108c2ecf20Sopenharmony_ci } 81118c2ecf20Sopenharmony_ci 81128c2ecf20Sopenharmony_ci sr2b = SiS_Pr->SiS_VCLKData[vclkindex].SR2B; 81138c2ecf20Sopenharmony_ci sr2c = SiS_Pr->SiS_VCLKData[vclkindex].SR2C; 81148c2ecf20Sopenharmony_ci 81158c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { 81168c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 81178c2ecf20Sopenharmony_ci if(ROMAddr[0x220] & 0x01) { 81188c2ecf20Sopenharmony_ci sr2b = ROMAddr[0x227]; 81198c2ecf20Sopenharmony_ci sr2c = ROMAddr[0x228]; 81208c2ecf20Sopenharmony_ci } 81218c2ecf20Sopenharmony_ci } 81228c2ecf20Sopenharmony_ci } 81238c2ecf20Sopenharmony_ci 81248c2ecf20Sopenharmony_ci clkbase = 0x02B; 81258c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 81268c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 81278c2ecf20Sopenharmony_ci clkbase += 3; 81288c2ecf20Sopenharmony_ci } 81298c2ecf20Sopenharmony_ci } 81308c2ecf20Sopenharmony_ci 81318c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x20); 81328c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase,sr2b); 81338c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase+1,sr2c); 81348c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x10); 81358c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase,sr2b); 81368c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase+1,sr2c); 81378c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x00); 81388c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase,sr2b); 81398c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase+1,sr2c); 81408c2ecf20Sopenharmony_ci} 81418c2ecf20Sopenharmony_ci 81428c2ecf20Sopenharmony_ci/*********************************************/ 81438c2ecf20Sopenharmony_ci/* SET UP CHRONTEL CHIPS */ 81448c2ecf20Sopenharmony_ci/*********************************************/ 81458c2ecf20Sopenharmony_ci 81468c2ecf20Sopenharmony_cistatic void 81478c2ecf20Sopenharmony_ciSiS_SetCHTVReg(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 81488c2ecf20Sopenharmony_ci unsigned short RefreshRateTableIndex) 81498c2ecf20Sopenharmony_ci{ 81508c2ecf20Sopenharmony_ci unsigned short TVType, resindex; 81518c2ecf20Sopenharmony_ci const struct SiS_CHTVRegData *CHTVRegData = NULL; 81528c2ecf20Sopenharmony_ci 81538c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) 81548c2ecf20Sopenharmony_ci resindex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 81558c2ecf20Sopenharmony_ci else 81568c2ecf20Sopenharmony_ci resindex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 81578c2ecf20Sopenharmony_ci 81588c2ecf20Sopenharmony_ci resindex &= 0x3F; 81598c2ecf20Sopenharmony_ci 81608c2ecf20Sopenharmony_ci TVType = 0; 81618c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; 81628c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) { 81638c2ecf20Sopenharmony_ci TVType += 2; 81648c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType > ModeVGA) { 81658c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CHSOverScan) TVType = 8; 81668c2ecf20Sopenharmony_ci } 81678c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPALM) { 81688c2ecf20Sopenharmony_ci TVType = 4; 81698c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; 81708c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { 81718c2ecf20Sopenharmony_ci TVType = 6; 81728c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; 81738c2ecf20Sopenharmony_ci } 81748c2ecf20Sopenharmony_ci } 81758c2ecf20Sopenharmony_ci 81768c2ecf20Sopenharmony_ci switch(TVType) { 81778c2ecf20Sopenharmony_ci case 0: CHTVRegData = SiS_Pr->SiS_CHTVReg_UNTSC; break; 81788c2ecf20Sopenharmony_ci case 1: CHTVRegData = SiS_Pr->SiS_CHTVReg_ONTSC; break; 81798c2ecf20Sopenharmony_ci case 2: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPAL; break; 81808c2ecf20Sopenharmony_ci case 3: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; 81818c2ecf20Sopenharmony_ci case 4: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALM; break; 81828c2ecf20Sopenharmony_ci case 5: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALM; break; 81838c2ecf20Sopenharmony_ci case 6: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALN; break; 81848c2ecf20Sopenharmony_ci case 7: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALN; break; 81858c2ecf20Sopenharmony_ci case 8: CHTVRegData = SiS_Pr->SiS_CHTVReg_SOPAL; break; 81868c2ecf20Sopenharmony_ci default: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; 81878c2ecf20Sopenharmony_ci } 81888c2ecf20Sopenharmony_ci 81898c2ecf20Sopenharmony_ci 81908c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { 81918c2ecf20Sopenharmony_ci 81928c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 81938c2ecf20Sopenharmony_ci 81948c2ecf20Sopenharmony_ci /* Chrontel 7005 - I assume that it does not come with a 315 series chip */ 81958c2ecf20Sopenharmony_ci 81968c2ecf20Sopenharmony_ci /* We don't support modes >800x600 */ 81978c2ecf20Sopenharmony_ci if (resindex > 5) return; 81988c2ecf20Sopenharmony_ci 81998c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) { 82008c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x04,0x43); /* 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/ 82018c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x09,0x69); /* Black level for PAL (105)*/ 82028c2ecf20Sopenharmony_ci } else { 82038c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x04,0x03); /* upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/ 82048c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x09,0x71); /* Black level for NTSC (113)*/ 82058c2ecf20Sopenharmony_ci } 82068c2ecf20Sopenharmony_ci 82078c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x00,CHTVRegData[resindex].Reg[0]); /* Mode register */ 82088c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x07,CHTVRegData[resindex].Reg[1]); /* Start active video register */ 82098c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x08,CHTVRegData[resindex].Reg[2]); /* Position overflow register */ 82108c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x0a,CHTVRegData[resindex].Reg[3]); /* Horiz Position register */ 82118c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x0b,CHTVRegData[resindex].Reg[4]); /* Vertical Position register */ 82128c2ecf20Sopenharmony_ci 82138c2ecf20Sopenharmony_ci /* Set minimum flicker filter for Luma channel (SR1-0=00), 82148c2ecf20Sopenharmony_ci minimum text enhancement (S3-2=10), 82158c2ecf20Sopenharmony_ci maximum flicker filter for Chroma channel (S5-4=10) 82168c2ecf20Sopenharmony_ci =00101000=0x28 (When reading, S1-0->S3-2, and S3-2->S1-0!) 82178c2ecf20Sopenharmony_ci */ 82188c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x01,0x28); 82198c2ecf20Sopenharmony_ci 82208c2ecf20Sopenharmony_ci /* Set video bandwidth 82218c2ecf20Sopenharmony_ci High bandwidth Luma composite video filter(S0=1) 82228c2ecf20Sopenharmony_ci low bandwidth Luma S-video filter (S2-1=00) 82238c2ecf20Sopenharmony_ci disable peak filter in S-video channel (S3=0) 82248c2ecf20Sopenharmony_ci high bandwidth Chroma Filter (S5-4=11) 82258c2ecf20Sopenharmony_ci =00110001=0x31 82268c2ecf20Sopenharmony_ci */ 82278c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr,0x03,0xb1); /* old: 3103 */ 82288c2ecf20Sopenharmony_ci 82298c2ecf20Sopenharmony_ci /* Register 0x3D does not exist in non-macrovision register map 82308c2ecf20Sopenharmony_ci (Maybe this is a macrovision register?) 82318c2ecf20Sopenharmony_ci */ 82328c2ecf20Sopenharmony_ci#ifndef SIS_CP 82338c2ecf20Sopenharmony_ci SiS_SetCH70xx(SiS_Pr,0x3d,0x00); 82348c2ecf20Sopenharmony_ci#endif 82358c2ecf20Sopenharmony_ci 82368c2ecf20Sopenharmony_ci /* Register 0x10 only contains 1 writable bit (S0) for sensing, 82378c2ecf20Sopenharmony_ci all other bits a read-only. Macrovision? 82388c2ecf20Sopenharmony_ci */ 82398c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x10,0x00,0x1F); 82408c2ecf20Sopenharmony_ci 82418c2ecf20Sopenharmony_ci /* Register 0x11 only contains 3 writable bits (S0-S2) for 82428c2ecf20Sopenharmony_ci contrast enhancement (set to 010 -> gain 1 Yout = 17/16*(Yin-30) ) 82438c2ecf20Sopenharmony_ci */ 82448c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x11,0x02,0xF8); 82458c2ecf20Sopenharmony_ci 82468c2ecf20Sopenharmony_ci /* Clear DSEN 82478c2ecf20Sopenharmony_ci */ 82488c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1c,0x00,0xEF); 82498c2ecf20Sopenharmony_ci 82508c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { /* ---- NTSC ---- */ 82518c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) { 82528c2ecf20Sopenharmony_ci if(resindex == 0x04) { /* 640x480 overscan: Mode 16 */ 82538c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ 82548c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); /* ACIV on, no need to set FSCI */ 82558c2ecf20Sopenharmony_ci } else if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */ 82568c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x18,0x01,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */ 82578c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x19,0x0C,0xF0); 82588c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1a,0x00,0xF0); 82598c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1b,0x00,0xF0); 82608c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1c,0x00,0xF0); 82618c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1d,0x00,0xF0); 82628c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1e,0x00,0xF0); 82638c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1f,0x00,0xF0); 82648c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x01,0xEF); /* Loop filter on for mode 23 */ 82658c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x00,0xFE); /* ACIV off, need to set FSCI */ 82668c2ecf20Sopenharmony_ci } 82678c2ecf20Sopenharmony_ci } else { 82688c2ecf20Sopenharmony_ci if(resindex == 0x04) { /* ----- 640x480 underscan; Mode 17 */ 82698c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ 82708c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); 82718c2ecf20Sopenharmony_ci } else if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */ 82728c2ecf20Sopenharmony_ci#if 0 82738c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x18,0x01,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */ 82748c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x19,0x09,0xF0); /* FSCI for mode 24 is 428,554,851 */ 82758c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1a,0x08,0xF0); /* 198b3a63 */ 82768c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1b,0x0b,0xF0); 82778c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1c,0x04,0xF0); 82788c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1d,0x01,0xF0); 82798c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1e,0x06,0xF0); 82808c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x1f,0x05,0xF0); 82818c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off for mode 24 */ 82828c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x00,0xFE); * ACIV off, need to set FSCI */ 82838c2ecf20Sopenharmony_ci#endif /* All alternatives wrong (datasheet wrong?), don't use FSCI */ 82848c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ 82858c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); 82868c2ecf20Sopenharmony_ci } 82878c2ecf20Sopenharmony_ci } 82888c2ecf20Sopenharmony_ci } else { /* ---- PAL ---- */ 82898c2ecf20Sopenharmony_ci /* We don't play around with FSCI in PAL mode */ 82908c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr, 0x20, 0x00, 0xEF); /* loop filter off */ 82918c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr, 0x21, 0x01, 0xFE); /* ACIV on */ 82928c2ecf20Sopenharmony_ci } 82938c2ecf20Sopenharmony_ci 82948c2ecf20Sopenharmony_ci#endif /* 300 */ 82958c2ecf20Sopenharmony_ci 82968c2ecf20Sopenharmony_ci } else { 82978c2ecf20Sopenharmony_ci 82988c2ecf20Sopenharmony_ci /* Chrontel 7019 - assumed that it does not come with a 300 series chip */ 82998c2ecf20Sopenharmony_ci 83008c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 83018c2ecf20Sopenharmony_ci 83028c2ecf20Sopenharmony_ci unsigned short temp; 83038c2ecf20Sopenharmony_ci 83048c2ecf20Sopenharmony_ci /* We don't support modes >1024x768 */ 83058c2ecf20Sopenharmony_ci if (resindex > 6) return; 83068c2ecf20Sopenharmony_ci 83078c2ecf20Sopenharmony_ci temp = CHTVRegData[resindex].Reg[0]; 83088c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) temp |= 0x10; 83098c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x00,temp); 83108c2ecf20Sopenharmony_ci 83118c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x01,CHTVRegData[resindex].Reg[1]); 83128c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x02,CHTVRegData[resindex].Reg[2]); 83138c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x04,CHTVRegData[resindex].Reg[3]); 83148c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x03,CHTVRegData[resindex].Reg[4]); 83158c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x05,CHTVRegData[resindex].Reg[5]); 83168c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x06,CHTVRegData[resindex].Reg[6]); 83178c2ecf20Sopenharmony_ci 83188c2ecf20Sopenharmony_ci temp = CHTVRegData[resindex].Reg[7]; 83198c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) temp = 0x66; 83208c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x07,temp); 83218c2ecf20Sopenharmony_ci 83228c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x08,CHTVRegData[resindex].Reg[8]); 83238c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x15,CHTVRegData[resindex].Reg[9]); 83248c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x1f,CHTVRegData[resindex].Reg[10]); 83258c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x0c,CHTVRegData[resindex].Reg[11]); 83268c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x0d,CHTVRegData[resindex].Reg[12]); 83278c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x0e,CHTVRegData[resindex].Reg[13]); 83288c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x0f,CHTVRegData[resindex].Reg[14]); 83298c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x10,CHTVRegData[resindex].Reg[15]); 83308c2ecf20Sopenharmony_ci 83318c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x21) & ~0x02; 83328c2ecf20Sopenharmony_ci /* D1 should be set for PAL, PAL-N and NTSC-J, 83338c2ecf20Sopenharmony_ci but I won't do that for PAL unless somebody 83348c2ecf20Sopenharmony_ci tells me to do so. Since the BIOS uses 83358c2ecf20Sopenharmony_ci non-default CIV values and blacklevels, 83368c2ecf20Sopenharmony_ci this might be compensated anyway. 83378c2ecf20Sopenharmony_ci */ 83388c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetPALN | TVSetNTSCJ)) temp |= 0x02; 83398c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x21,temp); 83408c2ecf20Sopenharmony_ci 83418c2ecf20Sopenharmony_ci#endif /* 315 */ 83428c2ecf20Sopenharmony_ci 83438c2ecf20Sopenharmony_ci } 83448c2ecf20Sopenharmony_ci 83458c2ecf20Sopenharmony_ci#ifdef SIS_CP 83468c2ecf20Sopenharmony_ci SIS_CP_INIT301_CP3 83478c2ecf20Sopenharmony_ci#endif 83488c2ecf20Sopenharmony_ci 83498c2ecf20Sopenharmony_ci} 83508c2ecf20Sopenharmony_ci 83518c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 /* ----------- 315 series only ---------- */ 83528c2ecf20Sopenharmony_ci 83538c2ecf20Sopenharmony_civoid 83548c2ecf20Sopenharmony_ciSiS_Chrontel701xBLOn(struct SiS_Private *SiS_Pr) 83558c2ecf20Sopenharmony_ci{ 83568c2ecf20Sopenharmony_ci unsigned short temp; 83578c2ecf20Sopenharmony_ci 83588c2ecf20Sopenharmony_ci /* Enable Chrontel 7019 LCD panel backlight */ 83598c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 83608c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 83618c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x66,0x65); 83628c2ecf20Sopenharmony_ci } else { 83638c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x66); 83648c2ecf20Sopenharmony_ci temp |= 0x20; 83658c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x66,temp); 83668c2ecf20Sopenharmony_ci } 83678c2ecf20Sopenharmony_ci } 83688c2ecf20Sopenharmony_ci} 83698c2ecf20Sopenharmony_ci 83708c2ecf20Sopenharmony_civoid 83718c2ecf20Sopenharmony_ciSiS_Chrontel701xBLOff(struct SiS_Private *SiS_Pr) 83728c2ecf20Sopenharmony_ci{ 83738c2ecf20Sopenharmony_ci unsigned short temp; 83748c2ecf20Sopenharmony_ci 83758c2ecf20Sopenharmony_ci /* Disable Chrontel 7019 LCD panel backlight */ 83768c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 83778c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x66); 83788c2ecf20Sopenharmony_ci temp &= 0xDF; 83798c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x66,temp); 83808c2ecf20Sopenharmony_ci } 83818c2ecf20Sopenharmony_ci} 83828c2ecf20Sopenharmony_ci 83838c2ecf20Sopenharmony_cistatic void 83848c2ecf20Sopenharmony_ciSiS_ChrontelPowerSequencing(struct SiS_Private *SiS_Pr) 83858c2ecf20Sopenharmony_ci{ 83868c2ecf20Sopenharmony_ci static const unsigned char regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b }; 83878c2ecf20Sopenharmony_ci static const unsigned char table1024_740[] = { 0x01, 0x02, 0x01, 0x01, 0x01 }; 83888c2ecf20Sopenharmony_ci static const unsigned char table1400_740[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 }; 83898c2ecf20Sopenharmony_ci static const unsigned char asus1024_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; 83908c2ecf20Sopenharmony_ci static const unsigned char asus1400_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; 83918c2ecf20Sopenharmony_ci static const unsigned char table1024_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; 83928c2ecf20Sopenharmony_ci static const unsigned char table1400_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; 83938c2ecf20Sopenharmony_ci const unsigned char *tableptr = NULL; 83948c2ecf20Sopenharmony_ci int i; 83958c2ecf20Sopenharmony_ci 83968c2ecf20Sopenharmony_ci /* Set up Power up/down timing */ 83978c2ecf20Sopenharmony_ci 83988c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 83998c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 84008c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1024_740; 84018c2ecf20Sopenharmony_ci else tableptr = table1024_740; 84028c2ecf20Sopenharmony_ci } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || 84038c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || 84048c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) { 84058c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1400_740; 84068c2ecf20Sopenharmony_ci else tableptr = table1400_740; 84078c2ecf20Sopenharmony_ci } else return; 84088c2ecf20Sopenharmony_ci } else { 84098c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 84108c2ecf20Sopenharmony_ci tableptr = table1024_650; 84118c2ecf20Sopenharmony_ci } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || 84128c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || 84138c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) { 84148c2ecf20Sopenharmony_ci tableptr = table1400_650; 84158c2ecf20Sopenharmony_ci } else return; 84168c2ecf20Sopenharmony_ci } 84178c2ecf20Sopenharmony_ci 84188c2ecf20Sopenharmony_ci for(i=0; i<5; i++) { 84198c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr, regtable[i], tableptr[i]); 84208c2ecf20Sopenharmony_ci } 84218c2ecf20Sopenharmony_ci} 84228c2ecf20Sopenharmony_ci 84238c2ecf20Sopenharmony_cistatic void 84248c2ecf20Sopenharmony_ciSiS_SetCH701xForLCD(struct SiS_Private *SiS_Pr) 84258c2ecf20Sopenharmony_ci{ 84268c2ecf20Sopenharmony_ci const unsigned char *tableptr = NULL; 84278c2ecf20Sopenharmony_ci unsigned short tempbh; 84288c2ecf20Sopenharmony_ci int i; 84298c2ecf20Sopenharmony_ci static const unsigned char regtable[] = { 84308c2ecf20Sopenharmony_ci 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71, 84318c2ecf20Sopenharmony_ci 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66 84328c2ecf20Sopenharmony_ci }; 84338c2ecf20Sopenharmony_ci static const unsigned char table1024_740[] = { 84348c2ecf20Sopenharmony_ci 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, 84358c2ecf20Sopenharmony_ci 0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44 84368c2ecf20Sopenharmony_ci }; 84378c2ecf20Sopenharmony_ci static const unsigned char table1280_740[] = { 84388c2ecf20Sopenharmony_ci 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, 84398c2ecf20Sopenharmony_ci 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 84408c2ecf20Sopenharmony_ci }; 84418c2ecf20Sopenharmony_ci static const unsigned char table1400_740[] = { 84428c2ecf20Sopenharmony_ci 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, 84438c2ecf20Sopenharmony_ci 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 84448c2ecf20Sopenharmony_ci }; 84458c2ecf20Sopenharmony_ci static const unsigned char table1600_740[] = { 84468c2ecf20Sopenharmony_ci 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, 84478c2ecf20Sopenharmony_ci 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44 84488c2ecf20Sopenharmony_ci }; 84498c2ecf20Sopenharmony_ci static const unsigned char table1024_650[] = { 84508c2ecf20Sopenharmony_ci 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, 84518c2ecf20Sopenharmony_ci 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 84528c2ecf20Sopenharmony_ci }; 84538c2ecf20Sopenharmony_ci static const unsigned char table1280_650[] = { 84548c2ecf20Sopenharmony_ci 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, 84558c2ecf20Sopenharmony_ci 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02 84568c2ecf20Sopenharmony_ci }; 84578c2ecf20Sopenharmony_ci static const unsigned char table1400_650[] = { 84588c2ecf20Sopenharmony_ci 0x60, 0x03, 0x11, 0x00, 0x40, 0xef, 84598c2ecf20Sopenharmony_ci 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 84608c2ecf20Sopenharmony_ci }; 84618c2ecf20Sopenharmony_ci static const unsigned char table1600_650[] = { 84628c2ecf20Sopenharmony_ci 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, 84638c2ecf20Sopenharmony_ci 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a 84648c2ecf20Sopenharmony_ci }; 84658c2ecf20Sopenharmony_ci 84668c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 84678c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tableptr = table1024_740; 84688c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) tableptr = table1280_740; 84698c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) tableptr = table1400_740; 84708c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) tableptr = table1600_740; 84718c2ecf20Sopenharmony_ci else return; 84728c2ecf20Sopenharmony_ci } else { 84738c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tableptr = table1024_650; 84748c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) tableptr = table1280_650; 84758c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) tableptr = table1400_650; 84768c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) tableptr = table1600_650; 84778c2ecf20Sopenharmony_ci else return; 84788c2ecf20Sopenharmony_ci } 84798c2ecf20Sopenharmony_ci 84808c2ecf20Sopenharmony_ci tempbh = SiS_GetCH701x(SiS_Pr,0x74); 84818c2ecf20Sopenharmony_ci if((tempbh == 0xf6) || (tempbh == 0xc7)) { 84828c2ecf20Sopenharmony_ci tempbh = SiS_GetCH701x(SiS_Pr,0x73); 84838c2ecf20Sopenharmony_ci if(tempbh == 0xc8) { 84848c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) return; 84858c2ecf20Sopenharmony_ci } else if(tempbh == 0xdb) { 84868c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) return; 84878c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) return; 84888c2ecf20Sopenharmony_ci } else if(tempbh == 0xde) { 84898c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) return; 84908c2ecf20Sopenharmony_ci } 84918c2ecf20Sopenharmony_ci } 84928c2ecf20Sopenharmony_ci 84938c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) tempbh = 0x0d; 84948c2ecf20Sopenharmony_ci else tempbh = 0x0c; 84958c2ecf20Sopenharmony_ci 84968c2ecf20Sopenharmony_ci for(i = 0; i < tempbh; i++) { 84978c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr, regtable[i], tableptr[i]); 84988c2ecf20Sopenharmony_ci } 84998c2ecf20Sopenharmony_ci SiS_ChrontelPowerSequencing(SiS_Pr); 85008c2ecf20Sopenharmony_ci tempbh = SiS_GetCH701x(SiS_Pr,0x1e); 85018c2ecf20Sopenharmony_ci tempbh |= 0xc0; 85028c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x1e,tempbh); 85038c2ecf20Sopenharmony_ci 85048c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 85058c2ecf20Sopenharmony_ci tempbh = SiS_GetCH701x(SiS_Pr,0x1c); 85068c2ecf20Sopenharmony_ci tempbh &= 0xfb; 85078c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x1c,tempbh); 85088c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); 85098c2ecf20Sopenharmony_ci tempbh = SiS_GetCH701x(SiS_Pr,0x64); 85108c2ecf20Sopenharmony_ci tempbh |= 0x40; 85118c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x64,tempbh); 85128c2ecf20Sopenharmony_ci tempbh = SiS_GetCH701x(SiS_Pr,0x03); 85138c2ecf20Sopenharmony_ci tempbh &= 0x3f; 85148c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x03,tempbh); 85158c2ecf20Sopenharmony_ci } 85168c2ecf20Sopenharmony_ci} 85178c2ecf20Sopenharmony_ci 85188c2ecf20Sopenharmony_cistatic void 85198c2ecf20Sopenharmony_ciSiS_ChrontelResetVSync(struct SiS_Private *SiS_Pr) 85208c2ecf20Sopenharmony_ci{ 85218c2ecf20Sopenharmony_ci unsigned char temp, temp1; 85228c2ecf20Sopenharmony_ci 85238c2ecf20Sopenharmony_ci temp1 = SiS_GetCH701x(SiS_Pr,0x49); 85248c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x49,0x3e); 85258c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x47); 85268c2ecf20Sopenharmony_ci temp &= 0x7f; /* Use external VSYNC */ 85278c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x47,temp); 85288c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 3); 85298c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x47); 85308c2ecf20Sopenharmony_ci temp |= 0x80; /* Use internal VSYNC */ 85318c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x47,temp); 85328c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x49,temp1); 85338c2ecf20Sopenharmony_ci} 85348c2ecf20Sopenharmony_ci 85358c2ecf20Sopenharmony_cistatic void 85368c2ecf20Sopenharmony_ciSiS_Chrontel701xOn(struct SiS_Private *SiS_Pr) 85378c2ecf20Sopenharmony_ci{ 85388c2ecf20Sopenharmony_ci unsigned short temp; 85398c2ecf20Sopenharmony_ci 85408c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 85418c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 85428c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x1c); 85438c2ecf20Sopenharmony_ci temp |= 0x04; /* Invert XCLK phase */ 85448c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x1c,temp); 85458c2ecf20Sopenharmony_ci } 85468c2ecf20Sopenharmony_ci if(SiS_IsYPbPr(SiS_Pr)) { 85478c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x01); 85488c2ecf20Sopenharmony_ci temp &= 0x3f; 85498c2ecf20Sopenharmony_ci temp |= 0x80; /* Enable YPrPb (HDTV) */ 85508c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x01,temp); 85518c2ecf20Sopenharmony_ci } 85528c2ecf20Sopenharmony_ci if(SiS_IsChScart(SiS_Pr)) { 85538c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x01); 85548c2ecf20Sopenharmony_ci temp &= 0x3f; 85558c2ecf20Sopenharmony_ci temp |= 0xc0; /* Enable SCART + CVBS */ 85568c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x01,temp); 85578c2ecf20Sopenharmony_ci } 85588c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 85598c2ecf20Sopenharmony_ci SiS_ChrontelResetVSync(SiS_Pr); 85608c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x49,0x20); /* Enable TV path */ 85618c2ecf20Sopenharmony_ci } else { 85628c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x49,0x20); /* Enable TV path */ 85638c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x49); 85648c2ecf20Sopenharmony_ci if(SiS_IsYPbPr(SiS_Pr)) { 85658c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x73); 85668c2ecf20Sopenharmony_ci temp |= 0x60; 85678c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x73,temp); 85688c2ecf20Sopenharmony_ci } 85698c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x47); 85708c2ecf20Sopenharmony_ci temp &= 0x7f; 85718c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x47,temp); 85728c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 2); 85738c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x47); 85748c2ecf20Sopenharmony_ci temp |= 0x80; 85758c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x47,temp); 85768c2ecf20Sopenharmony_ci } 85778c2ecf20Sopenharmony_ci } 85788c2ecf20Sopenharmony_ci} 85798c2ecf20Sopenharmony_ci 85808c2ecf20Sopenharmony_cistatic void 85818c2ecf20Sopenharmony_ciSiS_Chrontel701xOff(struct SiS_Private *SiS_Pr) 85828c2ecf20Sopenharmony_ci{ 85838c2ecf20Sopenharmony_ci unsigned short temp; 85848c2ecf20Sopenharmony_ci 85858c2ecf20Sopenharmony_ci /* Complete power down of LVDS */ 85868c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 85878c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 85888c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 1); 85898c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 5887); 85908c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x76,0xac); 85918c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x66,0x00); 85928c2ecf20Sopenharmony_ci } else { 85938c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 2); 85948c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x76); 85958c2ecf20Sopenharmony_ci temp &= 0xfc; 85968c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x76,temp); 85978c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x66,0x00); 85988c2ecf20Sopenharmony_ci } 85998c2ecf20Sopenharmony_ci } 86008c2ecf20Sopenharmony_ci} 86018c2ecf20Sopenharmony_ci 86028c2ecf20Sopenharmony_cistatic void 86038c2ecf20Sopenharmony_ciSiS_ChrontelResetDB(struct SiS_Private *SiS_Pr) 86048c2ecf20Sopenharmony_ci{ 86058c2ecf20Sopenharmony_ci unsigned short temp; 86068c2ecf20Sopenharmony_ci 86078c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 86088c2ecf20Sopenharmony_ci 86098c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x4a); /* Version ID */ 86108c2ecf20Sopenharmony_ci temp &= 0x01; 86118c2ecf20Sopenharmony_ci if(!temp) { 86128c2ecf20Sopenharmony_ci 86138c2ecf20Sopenharmony_ci if(SiS_WeHaveBacklightCtrl(SiS_Pr)) { 86148c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x49); 86158c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x49,0x3e); 86168c2ecf20Sopenharmony_ci } 86178c2ecf20Sopenharmony_ci 86188c2ecf20Sopenharmony_ci /* Reset Chrontel 7019 datapath */ 86198c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x48,0x10); 86208c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 1); 86218c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x48,0x18); 86228c2ecf20Sopenharmony_ci 86238c2ecf20Sopenharmony_ci if(SiS_WeHaveBacklightCtrl(SiS_Pr)) { 86248c2ecf20Sopenharmony_ci SiS_ChrontelResetVSync(SiS_Pr); 86258c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x49,temp); 86268c2ecf20Sopenharmony_ci } 86278c2ecf20Sopenharmony_ci 86288c2ecf20Sopenharmony_ci } else { 86298c2ecf20Sopenharmony_ci 86308c2ecf20Sopenharmony_ci /* Clear/set/clear GPIO */ 86318c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x5c); 86328c2ecf20Sopenharmony_ci temp &= 0xef; 86338c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x5c,temp); 86348c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x5c); 86358c2ecf20Sopenharmony_ci temp |= 0x10; 86368c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x5c,temp); 86378c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x5c); 86388c2ecf20Sopenharmony_ci temp &= 0xef; 86398c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x5c,temp); 86408c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x61); 86418c2ecf20Sopenharmony_ci if(!temp) { 86428c2ecf20Sopenharmony_ci SiS_SetCH701xForLCD(SiS_Pr); 86438c2ecf20Sopenharmony_ci } 86448c2ecf20Sopenharmony_ci } 86458c2ecf20Sopenharmony_ci 86468c2ecf20Sopenharmony_ci } else { /* 650 */ 86478c2ecf20Sopenharmony_ci /* Reset Chrontel 7019 datapath */ 86488c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x48,0x10); 86498c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 1); 86508c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x48,0x18); 86518c2ecf20Sopenharmony_ci } 86528c2ecf20Sopenharmony_ci} 86538c2ecf20Sopenharmony_ci 86548c2ecf20Sopenharmony_cistatic void 86558c2ecf20Sopenharmony_ciSiS_ChrontelInitTVVSync(struct SiS_Private *SiS_Pr) 86568c2ecf20Sopenharmony_ci{ 86578c2ecf20Sopenharmony_ci unsigned short temp; 86588c2ecf20Sopenharmony_ci 86598c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 86608c2ecf20Sopenharmony_ci 86618c2ecf20Sopenharmony_ci if(SiS_WeHaveBacklightCtrl(SiS_Pr)) { 86628c2ecf20Sopenharmony_ci SiS_ChrontelResetVSync(SiS_Pr); 86638c2ecf20Sopenharmony_ci } 86648c2ecf20Sopenharmony_ci 86658c2ecf20Sopenharmony_ci } else { 86668c2ecf20Sopenharmony_ci 86678c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x76,0xaf); /* Power up LVDS block */ 86688c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x49); 86698c2ecf20Sopenharmony_ci temp &= 1; 86708c2ecf20Sopenharmony_ci if(temp != 1) { /* TV block powered? (0 = yes, 1 = no) */ 86718c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x47); 86728c2ecf20Sopenharmony_ci temp &= 0x70; 86738c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x47,temp); /* enable VSYNC */ 86748c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 3); 86758c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x47); 86768c2ecf20Sopenharmony_ci temp |= 0x80; 86778c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x47,temp); /* disable VSYNC */ 86788c2ecf20Sopenharmony_ci } 86798c2ecf20Sopenharmony_ci 86808c2ecf20Sopenharmony_ci } 86818c2ecf20Sopenharmony_ci} 86828c2ecf20Sopenharmony_ci 86838c2ecf20Sopenharmony_cistatic void 86848c2ecf20Sopenharmony_ciSiS_ChrontelDoSomething3(struct SiS_Private *SiS_Pr, unsigned short ModeNo) 86858c2ecf20Sopenharmony_ci{ 86868c2ecf20Sopenharmony_ci unsigned short temp,temp1; 86878c2ecf20Sopenharmony_ci 86888c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 86898c2ecf20Sopenharmony_ci 86908c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x61); 86918c2ecf20Sopenharmony_ci if(temp < 1) { 86928c2ecf20Sopenharmony_ci temp++; 86938c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x61,temp); 86948c2ecf20Sopenharmony_ci } 86958c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x66,0x45); /* Panel power on */ 86968c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x76,0xaf); /* All power on */ 86978c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 1); 86988c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 5887); 86998c2ecf20Sopenharmony_ci 87008c2ecf20Sopenharmony_ci } else { /* 650 */ 87018c2ecf20Sopenharmony_ci 87028c2ecf20Sopenharmony_ci temp1 = 0; 87038c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x61); 87048c2ecf20Sopenharmony_ci if(temp < 2) { 87058c2ecf20Sopenharmony_ci temp++; 87068c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x61,temp); 87078c2ecf20Sopenharmony_ci temp1 = 1; 87088c2ecf20Sopenharmony_ci } 87098c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x76,0xac); 87108c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x66); 87118c2ecf20Sopenharmony_ci temp |= 0x5f; 87128c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x66,temp); 87138c2ecf20Sopenharmony_ci if(ModeNo > 0x13) { 87148c2ecf20Sopenharmony_ci if(SiS_WeHaveBacklightCtrl(SiS_Pr)) { 87158c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 1023); 87168c2ecf20Sopenharmony_ci } else { 87178c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 767); 87188c2ecf20Sopenharmony_ci } 87198c2ecf20Sopenharmony_ci } else { 87208c2ecf20Sopenharmony_ci if(!temp1) 87218c2ecf20Sopenharmony_ci SiS_GenericDelay(SiS_Pr, 767); 87228c2ecf20Sopenharmony_ci } 87238c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x76); 87248c2ecf20Sopenharmony_ci temp |= 0x03; 87258c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x76,temp); 87268c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x66); 87278c2ecf20Sopenharmony_ci temp &= 0x7f; 87288c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x66,temp); 87298c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 1); 87308c2ecf20Sopenharmony_ci 87318c2ecf20Sopenharmony_ci } 87328c2ecf20Sopenharmony_ci} 87338c2ecf20Sopenharmony_ci 87348c2ecf20Sopenharmony_cistatic void 87358c2ecf20Sopenharmony_ciSiS_ChrontelDoSomething2(struct SiS_Private *SiS_Pr) 87368c2ecf20Sopenharmony_ci{ 87378c2ecf20Sopenharmony_ci unsigned short temp; 87388c2ecf20Sopenharmony_ci 87398c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 1); 87408c2ecf20Sopenharmony_ci 87418c2ecf20Sopenharmony_ci do { 87428c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x66); 87438c2ecf20Sopenharmony_ci temp &= 0x04; /* PLL stable? -> bail out */ 87448c2ecf20Sopenharmony_ci if(temp == 0x04) break; 87458c2ecf20Sopenharmony_ci 87468c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 87478c2ecf20Sopenharmony_ci /* Power down LVDS output, PLL normal operation */ 87488c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x76,0xac); 87498c2ecf20Sopenharmony_ci } 87508c2ecf20Sopenharmony_ci 87518c2ecf20Sopenharmony_ci SiS_SetCH701xForLCD(SiS_Pr); 87528c2ecf20Sopenharmony_ci 87538c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x76); 87548c2ecf20Sopenharmony_ci temp &= 0xfb; /* Reset PLL */ 87558c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x76,temp); 87568c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 2); 87578c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x76); 87588c2ecf20Sopenharmony_ci temp |= 0x04; /* PLL normal operation */ 87598c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x76,temp); 87608c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 87618c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x78,0xe0); /* PLL loop filter */ 87628c2ecf20Sopenharmony_ci } else { 87638c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x78,0x60); 87648c2ecf20Sopenharmony_ci } 87658c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 2); 87668c2ecf20Sopenharmony_ci } while(0); 87678c2ecf20Sopenharmony_ci 87688c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x77,0x00); /* MV? */ 87698c2ecf20Sopenharmony_ci} 87708c2ecf20Sopenharmony_ci 87718c2ecf20Sopenharmony_cistatic void 87728c2ecf20Sopenharmony_ciSiS_ChrontelDoSomething1(struct SiS_Private *SiS_Pr) 87738c2ecf20Sopenharmony_ci{ 87748c2ecf20Sopenharmony_ci unsigned short temp; 87758c2ecf20Sopenharmony_ci 87768c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x03); 87778c2ecf20Sopenharmony_ci temp |= 0x80; /* Set datapath 1 to TV */ 87788c2ecf20Sopenharmony_ci temp &= 0xbf; /* Set datapath 2 to LVDS */ 87798c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x03,temp); 87808c2ecf20Sopenharmony_ci 87818c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_740) { 87828c2ecf20Sopenharmony_ci 87838c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x1c); 87848c2ecf20Sopenharmony_ci temp &= 0xfb; /* Normal XCLK phase */ 87858c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x1c,temp); 87868c2ecf20Sopenharmony_ci 87878c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); 87888c2ecf20Sopenharmony_ci 87898c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x64); 87908c2ecf20Sopenharmony_ci temp |= 0x40; /* ? Bit not defined */ 87918c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x64,temp); 87928c2ecf20Sopenharmony_ci 87938c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x03); 87948c2ecf20Sopenharmony_ci temp &= 0x3f; /* D1 input to both LVDS and TV */ 87958c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x03,temp); 87968c2ecf20Sopenharmony_ci 87978c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) { 87988c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x63,0x40); /* LVDS off */ 87998c2ecf20Sopenharmony_ci SiS_LongDelay(SiS_Pr, 1); 88008c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x63,0x00); /* LVDS on */ 88018c2ecf20Sopenharmony_ci SiS_ChrontelResetDB(SiS_Pr); 88028c2ecf20Sopenharmony_ci SiS_ChrontelDoSomething2(SiS_Pr); 88038c2ecf20Sopenharmony_ci SiS_ChrontelDoSomething3(SiS_Pr, 0); 88048c2ecf20Sopenharmony_ci } else { 88058c2ecf20Sopenharmony_ci temp = SiS_GetCH701x(SiS_Pr,0x66); 88068c2ecf20Sopenharmony_ci if(temp != 0x45) { 88078c2ecf20Sopenharmony_ci SiS_ChrontelResetDB(SiS_Pr); 88088c2ecf20Sopenharmony_ci SiS_ChrontelDoSomething2(SiS_Pr); 88098c2ecf20Sopenharmony_ci SiS_ChrontelDoSomething3(SiS_Pr, 0); 88108c2ecf20Sopenharmony_ci } 88118c2ecf20Sopenharmony_ci } 88128c2ecf20Sopenharmony_ci 88138c2ecf20Sopenharmony_ci } else { /* 650 */ 88148c2ecf20Sopenharmony_ci 88158c2ecf20Sopenharmony_ci SiS_ChrontelResetDB(SiS_Pr); 88168c2ecf20Sopenharmony_ci SiS_ChrontelDoSomething2(SiS_Pr); 88178c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34); 88188c2ecf20Sopenharmony_ci SiS_ChrontelDoSomething3(SiS_Pr,temp); 88198c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr,0x76,0xaf); /* All power on, LVDS normal operation */ 88208c2ecf20Sopenharmony_ci 88218c2ecf20Sopenharmony_ci } 88228c2ecf20Sopenharmony_ci 88238c2ecf20Sopenharmony_ci} 88248c2ecf20Sopenharmony_ci#endif /* 315 series */ 88258c2ecf20Sopenharmony_ci 88268c2ecf20Sopenharmony_ci/*********************************************/ 88278c2ecf20Sopenharmony_ci/* MAIN: SET CRT2 REGISTER GROUP */ 88288c2ecf20Sopenharmony_ci/*********************************************/ 88298c2ecf20Sopenharmony_ci 88308c2ecf20Sopenharmony_cibool 88318c2ecf20Sopenharmony_ciSiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo) 88328c2ecf20Sopenharmony_ci{ 88338c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 88348c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 88358c2ecf20Sopenharmony_ci#endif 88368c2ecf20Sopenharmony_ci unsigned short ModeIdIndex, RefreshRateTableIndex; 88378c2ecf20Sopenharmony_ci 88388c2ecf20Sopenharmony_ci SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; 88398c2ecf20Sopenharmony_ci 88408c2ecf20Sopenharmony_ci if(!SiS_Pr->UseCustomMode) { 88418c2ecf20Sopenharmony_ci SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex); 88428c2ecf20Sopenharmony_ci } else { 88438c2ecf20Sopenharmony_ci ModeIdIndex = 0; 88448c2ecf20Sopenharmony_ci } 88458c2ecf20Sopenharmony_ci 88468c2ecf20Sopenharmony_ci /* Used for shifting CR33 */ 88478c2ecf20Sopenharmony_ci SiS_Pr->SiS_SelectCRT2Rate = 4; 88488c2ecf20Sopenharmony_ci 88498c2ecf20Sopenharmony_ci SiS_UnLockCRT2(SiS_Pr); 88508c2ecf20Sopenharmony_ci 88518c2ecf20Sopenharmony_ci RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex); 88528c2ecf20Sopenharmony_ci 88538c2ecf20Sopenharmony_ci SiS_SaveCRT2Info(SiS_Pr,ModeNo); 88548c2ecf20Sopenharmony_ci 88558c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LowModeTests) { 88568c2ecf20Sopenharmony_ci SiS_DisableBridge(SiS_Pr); 88578c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->ChipType == SIS_730)) { 88588c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,0x80); 88598c2ecf20Sopenharmony_ci } 88608c2ecf20Sopenharmony_ci SiS_SetCRT2ModeRegs(SiS_Pr, ModeNo, ModeIdIndex); 88618c2ecf20Sopenharmony_ci } 88628c2ecf20Sopenharmony_ci 88638c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { 88648c2ecf20Sopenharmony_ci SiS_LockCRT2(SiS_Pr); 88658c2ecf20Sopenharmony_ci SiS_DisplayOn(SiS_Pr); 88668c2ecf20Sopenharmony_ci return true; 88678c2ecf20Sopenharmony_ci } 88688c2ecf20Sopenharmony_ci 88698c2ecf20Sopenharmony_ci SiS_GetCRT2Data(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 88708c2ecf20Sopenharmony_ci 88718c2ecf20Sopenharmony_ci /* Set up Panel Link for LVDS and LCDA */ 88728c2ecf20Sopenharmony_ci SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; 88738c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || 88748c2ecf20Sopenharmony_ci ((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) || 88758c2ecf20Sopenharmony_ci ((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS30xBLV)) ) { 88768c2ecf20Sopenharmony_ci SiS_GetLVDSDesData(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 88778c2ecf20Sopenharmony_ci } 88788c2ecf20Sopenharmony_ci 88798c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LowModeTests) { 88808c2ecf20Sopenharmony_ci SiS_SetGroup1(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 88818c2ecf20Sopenharmony_ci } 88828c2ecf20Sopenharmony_ci 88838c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 88848c2ecf20Sopenharmony_ci 88858c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LowModeTests) { 88868c2ecf20Sopenharmony_ci 88878c2ecf20Sopenharmony_ci SiS_SetGroup2(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 88888c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 88898c2ecf20Sopenharmony_ci SiS_SetGroup2_C_ELV(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 88908c2ecf20Sopenharmony_ci#endif 88918c2ecf20Sopenharmony_ci SiS_SetGroup3(SiS_Pr, ModeNo, ModeIdIndex); 88928c2ecf20Sopenharmony_ci SiS_SetGroup4(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 88938c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 88948c2ecf20Sopenharmony_ci SiS_SetGroup4_C_ELV(SiS_Pr, ModeNo, ModeIdIndex); 88958c2ecf20Sopenharmony_ci#endif 88968c2ecf20Sopenharmony_ci SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex); 88978c2ecf20Sopenharmony_ci 88988c2ecf20Sopenharmony_ci SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex); 88998c2ecf20Sopenharmony_ci 89008c2ecf20Sopenharmony_ci /* For 301BDH (Panel link initialization): */ 89018c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { 89028c2ecf20Sopenharmony_ci 89038c2ecf20Sopenharmony_ci if(!((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10)))) { 89048c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 89058c2ecf20Sopenharmony_ci SiS_ModCRT1CRTC(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 89068c2ecf20Sopenharmony_ci } 89078c2ecf20Sopenharmony_ci } 89088c2ecf20Sopenharmony_ci SiS_SetCRT2ECLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 89098c2ecf20Sopenharmony_ci } 89108c2ecf20Sopenharmony_ci } 89118c2ecf20Sopenharmony_ci 89128c2ecf20Sopenharmony_ci } else { 89138c2ecf20Sopenharmony_ci 89148c2ecf20Sopenharmony_ci SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex); 89158c2ecf20Sopenharmony_ci 89168c2ecf20Sopenharmony_ci SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex); 89178c2ecf20Sopenharmony_ci 89188c2ecf20Sopenharmony_ci SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex); 89198c2ecf20Sopenharmony_ci 89208c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LowModeTests) { 89218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 89228c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 89238c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 89248c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 89258c2ecf20Sopenharmony_ci SiS_SetCH701xForLCD(SiS_Pr); 89268c2ecf20Sopenharmony_ci#endif 89278c2ecf20Sopenharmony_ci } 89288c2ecf20Sopenharmony_ci } 89298c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 89308c2ecf20Sopenharmony_ci SiS_SetCHTVReg(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex); 89318c2ecf20Sopenharmony_ci } 89328c2ecf20Sopenharmony_ci } 89338c2ecf20Sopenharmony_ci } 89348c2ecf20Sopenharmony_ci 89358c2ecf20Sopenharmony_ci } 89368c2ecf20Sopenharmony_ci 89378c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 89388c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_315H) { 89398c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LowModeTests) { 89408c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseOEM) { 89418c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_UseROM) && (SiS_Pr->SiS_UseOEM == -1)) { 89428c2ecf20Sopenharmony_ci if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { 89438c2ecf20Sopenharmony_ci SiS_OEM300Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 89448c2ecf20Sopenharmony_ci } 89458c2ecf20Sopenharmony_ci } else { 89468c2ecf20Sopenharmony_ci SiS_OEM300Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 89478c2ecf20Sopenharmony_ci } 89488c2ecf20Sopenharmony_ci } 89498c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 89508c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || 89518c2ecf20Sopenharmony_ci (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { 89528c2ecf20Sopenharmony_ci SetOEMLCDData2(SiS_Pr, ModeNo, ModeIdIndex,RefreshRateTableIndex); 89538c2ecf20Sopenharmony_ci } 89548c2ecf20Sopenharmony_ci SiS_DisplayOn(SiS_Pr); 89558c2ecf20Sopenharmony_ci } 89568c2ecf20Sopenharmony_ci } 89578c2ecf20Sopenharmony_ci } 89588c2ecf20Sopenharmony_ci#endif 89598c2ecf20Sopenharmony_ci 89608c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 89618c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_315H) { 89628c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LowModeTests) { 89638c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_661) { 89648c2ecf20Sopenharmony_ci SiS_FinalizeLCD(SiS_Pr, ModeNo, ModeIdIndex); 89658c2ecf20Sopenharmony_ci SiS_OEM310Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 89668c2ecf20Sopenharmony_ci } else { 89678c2ecf20Sopenharmony_ci SiS_OEM661Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 89688c2ecf20Sopenharmony_ci } 89698c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40); 89708c2ecf20Sopenharmony_ci } 89718c2ecf20Sopenharmony_ci } 89728c2ecf20Sopenharmony_ci#endif 89738c2ecf20Sopenharmony_ci 89748c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LowModeTests) { 89758c2ecf20Sopenharmony_ci SiS_EnableBridge(SiS_Pr); 89768c2ecf20Sopenharmony_ci } 89778c2ecf20Sopenharmony_ci 89788c2ecf20Sopenharmony_ci SiS_DisplayOn(SiS_Pr); 89798c2ecf20Sopenharmony_ci 89808c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { 89818c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 89828c2ecf20Sopenharmony_ci /* Disable LCD panel when using TV */ 89838c2ecf20Sopenharmony_ci SiS_SetRegSR11ANDOR(SiS_Pr,0xFF,0x0C); 89848c2ecf20Sopenharmony_ci } else { 89858c2ecf20Sopenharmony_ci /* Disable TV when using LCD */ 89868c2ecf20Sopenharmony_ci SiS_SetCH70xxANDOR(SiS_Pr,0x0e,0x01,0xf8); 89878c2ecf20Sopenharmony_ci } 89888c2ecf20Sopenharmony_ci } 89898c2ecf20Sopenharmony_ci 89908c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LowModeTests) { 89918c2ecf20Sopenharmony_ci SiS_LockCRT2(SiS_Pr); 89928c2ecf20Sopenharmony_ci } 89938c2ecf20Sopenharmony_ci 89948c2ecf20Sopenharmony_ci return true; 89958c2ecf20Sopenharmony_ci} 89968c2ecf20Sopenharmony_ci 89978c2ecf20Sopenharmony_ci 89988c2ecf20Sopenharmony_ci/*********************************************/ 89998c2ecf20Sopenharmony_ci/* ENABLE/DISABLE LCD BACKLIGHT (SIS) */ 90008c2ecf20Sopenharmony_ci/*********************************************/ 90018c2ecf20Sopenharmony_ci 90028c2ecf20Sopenharmony_civoid 90038c2ecf20Sopenharmony_ciSiS_SiS30xBLOn(struct SiS_Private *SiS_Pr) 90048c2ecf20Sopenharmony_ci{ 90058c2ecf20Sopenharmony_ci /* Switch on LCD backlight on SiS30xLV */ 90068c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr,0xff00); 90078c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { 90088c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); 90098c2ecf20Sopenharmony_ci SiS_WaitVBRetrace(SiS_Pr); 90108c2ecf20Sopenharmony_ci } 90118c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x01)) { 90128c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); 90138c2ecf20Sopenharmony_ci } 90148c2ecf20Sopenharmony_ci} 90158c2ecf20Sopenharmony_ci 90168c2ecf20Sopenharmony_civoid 90178c2ecf20Sopenharmony_ciSiS_SiS30xBLOff(struct SiS_Private *SiS_Pr) 90188c2ecf20Sopenharmony_ci{ 90198c2ecf20Sopenharmony_ci /* Switch off LCD backlight on SiS30xLV */ 90208c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); 90218c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr,0xff00); 90228c2ecf20Sopenharmony_ci} 90238c2ecf20Sopenharmony_ci 90248c2ecf20Sopenharmony_ci/*********************************************/ 90258c2ecf20Sopenharmony_ci/* DDC RELATED FUNCTIONS */ 90268c2ecf20Sopenharmony_ci/*********************************************/ 90278c2ecf20Sopenharmony_ci 90288c2ecf20Sopenharmony_cistatic void 90298c2ecf20Sopenharmony_ciSiS_SetupDDCN(struct SiS_Private *SiS_Pr) 90308c2ecf20Sopenharmony_ci{ 90318c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NData = ~SiS_Pr->SiS_DDC_Data; 90328c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NClk = ~SiS_Pr->SiS_DDC_Clk; 90338c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_DDC_Index == 0x11) && (SiS_Pr->SiS_SensibleSR11)) { 90348c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NData &= 0x0f; 90358c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NClk &= 0x0f; 90368c2ecf20Sopenharmony_ci } 90378c2ecf20Sopenharmony_ci} 90388c2ecf20Sopenharmony_ci 90398c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 90408c2ecf20Sopenharmony_cistatic unsigned char * 90418c2ecf20Sopenharmony_ciSiS_SetTrumpBlockLoop(struct SiS_Private *SiS_Pr, unsigned char *dataptr) 90428c2ecf20Sopenharmony_ci{ 90438c2ecf20Sopenharmony_ci int i, j, num; 90448c2ecf20Sopenharmony_ci unsigned short tempah,temp; 90458c2ecf20Sopenharmony_ci unsigned char *mydataptr; 90468c2ecf20Sopenharmony_ci 90478c2ecf20Sopenharmony_ci for(i=0; i<20; i++) { /* Do 20 attempts to write */ 90488c2ecf20Sopenharmony_ci mydataptr = dataptr; 90498c2ecf20Sopenharmony_ci num = *mydataptr++; 90508c2ecf20Sopenharmony_ci if(!num) return mydataptr; 90518c2ecf20Sopenharmony_ci if(i) { 90528c2ecf20Sopenharmony_ci SiS_SetStop(SiS_Pr); 90538c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT * 2); 90548c2ecf20Sopenharmony_ci } 90558c2ecf20Sopenharmony_ci if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ 90568c2ecf20Sopenharmony_ci tempah = SiS_Pr->SiS_DDC_DeviceAddr; 90578c2ecf20Sopenharmony_ci temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write DAB (S0=0=write) */ 90588c2ecf20Sopenharmony_ci if(temp) continue; /* (ERROR: no ack) */ 90598c2ecf20Sopenharmony_ci tempah = *mydataptr++; 90608c2ecf20Sopenharmony_ci temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write register number */ 90618c2ecf20Sopenharmony_ci if(temp) continue; /* (ERROR: no ack) */ 90628c2ecf20Sopenharmony_ci for(j=0; j<num; j++) { 90638c2ecf20Sopenharmony_ci tempah = *mydataptr++; 90648c2ecf20Sopenharmony_ci temp = SiS_WriteDDC2Data(SiS_Pr,tempah);/* Write DAB (S0=0=write) */ 90658c2ecf20Sopenharmony_ci if(temp) break; 90668c2ecf20Sopenharmony_ci } 90678c2ecf20Sopenharmony_ci if(temp) continue; 90688c2ecf20Sopenharmony_ci if(SiS_SetStop(SiS_Pr)) continue; 90698c2ecf20Sopenharmony_ci return mydataptr; 90708c2ecf20Sopenharmony_ci } 90718c2ecf20Sopenharmony_ci return NULL; 90728c2ecf20Sopenharmony_ci} 90738c2ecf20Sopenharmony_ci 90748c2ecf20Sopenharmony_cistatic bool 90758c2ecf20Sopenharmony_ciSiS_SetTrumpionBlock(struct SiS_Private *SiS_Pr, unsigned char *dataptr) 90768c2ecf20Sopenharmony_ci{ 90778c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB (Device Address Byte) */ 90788c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ 90798c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ 90808c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ 90818c2ecf20Sopenharmony_ci SiS_SetupDDCN(SiS_Pr); 90828c2ecf20Sopenharmony_ci 90838c2ecf20Sopenharmony_ci SiS_SetSwitchDDC2(SiS_Pr); 90848c2ecf20Sopenharmony_ci 90858c2ecf20Sopenharmony_ci while(*dataptr) { 90868c2ecf20Sopenharmony_ci dataptr = SiS_SetTrumpBlockLoop(SiS_Pr, dataptr); 90878c2ecf20Sopenharmony_ci if(!dataptr) return false; 90888c2ecf20Sopenharmony_ci } 90898c2ecf20Sopenharmony_ci return true; 90908c2ecf20Sopenharmony_ci} 90918c2ecf20Sopenharmony_ci#endif 90928c2ecf20Sopenharmony_ci 90938c2ecf20Sopenharmony_ci/* The Chrontel 700x is connected to the 630/730 via 90948c2ecf20Sopenharmony_ci * the 630/730's DDC/I2C port. 90958c2ecf20Sopenharmony_ci * 90968c2ecf20Sopenharmony_ci * On 630(S)T chipset, the index changed from 0x11 to 90978c2ecf20Sopenharmony_ci * 0x0a, possibly for working around the DDC problems 90988c2ecf20Sopenharmony_ci */ 90998c2ecf20Sopenharmony_ci 91008c2ecf20Sopenharmony_cistatic bool 91018c2ecf20Sopenharmony_ciSiS_SetChReg(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val, unsigned short myor) 91028c2ecf20Sopenharmony_ci{ 91038c2ecf20Sopenharmony_ci unsigned short temp, i; 91048c2ecf20Sopenharmony_ci 91058c2ecf20Sopenharmony_ci for(i=0; i<20; i++) { /* Do 20 attempts to write */ 91068c2ecf20Sopenharmony_ci if(i) { 91078c2ecf20Sopenharmony_ci SiS_SetStop(SiS_Pr); 91088c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT * 4); 91098c2ecf20Sopenharmony_ci } 91108c2ecf20Sopenharmony_ci if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ 91118c2ecf20Sopenharmony_ci temp = SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr); /* Write DAB (S0=0=write) */ 91128c2ecf20Sopenharmony_ci if(temp) continue; /* (ERROR: no ack) */ 91138c2ecf20Sopenharmony_ci temp = SiS_WriteDDC2Data(SiS_Pr, (reg | myor)); /* Write RAB (700x: set bit 7, see datasheet) */ 91148c2ecf20Sopenharmony_ci if(temp) continue; /* (ERROR: no ack) */ 91158c2ecf20Sopenharmony_ci temp = SiS_WriteDDC2Data(SiS_Pr, val); /* Write data */ 91168c2ecf20Sopenharmony_ci if(temp) continue; /* (ERROR: no ack) */ 91178c2ecf20Sopenharmony_ci if(SiS_SetStop(SiS_Pr)) continue; /* Set stop condition */ 91188c2ecf20Sopenharmony_ci SiS_Pr->SiS_ChrontelInit = 1; 91198c2ecf20Sopenharmony_ci return true; 91208c2ecf20Sopenharmony_ci } 91218c2ecf20Sopenharmony_ci return false; 91228c2ecf20Sopenharmony_ci} 91238c2ecf20Sopenharmony_ci 91248c2ecf20Sopenharmony_ci/* Write to Chrontel 700x */ 91258c2ecf20Sopenharmony_civoid 91268c2ecf20Sopenharmony_ciSiS_SetCH700x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val) 91278c2ecf20Sopenharmony_ci{ 91288c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ 91298c2ecf20Sopenharmony_ci 91308c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); 91318c2ecf20Sopenharmony_ci 91328c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_ChrontelInit)) { 91338c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ 91348c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ 91358c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ 91368c2ecf20Sopenharmony_ci SiS_SetupDDCN(SiS_Pr); 91378c2ecf20Sopenharmony_ci } 91388c2ecf20Sopenharmony_ci 91398c2ecf20Sopenharmony_ci if( (!(SiS_SetChReg(SiS_Pr, reg, val, 0x80))) && 91408c2ecf20Sopenharmony_ci (!(SiS_Pr->SiS_ChrontelInit)) ) { 91418c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index = 0x0a; 91428c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data = 0x80; 91438c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Clk = 0x40; 91448c2ecf20Sopenharmony_ci SiS_SetupDDCN(SiS_Pr); 91458c2ecf20Sopenharmony_ci 91468c2ecf20Sopenharmony_ci SiS_SetChReg(SiS_Pr, reg, val, 0x80); 91478c2ecf20Sopenharmony_ci } 91488c2ecf20Sopenharmony_ci} 91498c2ecf20Sopenharmony_ci 91508c2ecf20Sopenharmony_ci/* Write to Chrontel 701x */ 91518c2ecf20Sopenharmony_ci/* Parameter is [Data (S15-S8) | Register no (S7-S0)] */ 91528c2ecf20Sopenharmony_civoid 91538c2ecf20Sopenharmony_ciSiS_SetCH701x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val) 91548c2ecf20Sopenharmony_ci{ 91558c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ 91568c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ 91578c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ 91588c2ecf20Sopenharmony_ci SiS_SetupDDCN(SiS_Pr); 91598c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ 91608c2ecf20Sopenharmony_ci SiS_SetChReg(SiS_Pr, reg, val, 0); 91618c2ecf20Sopenharmony_ci} 91628c2ecf20Sopenharmony_ci 91638c2ecf20Sopenharmony_cistatic 91648c2ecf20Sopenharmony_civoid 91658c2ecf20Sopenharmony_ciSiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val) 91668c2ecf20Sopenharmony_ci{ 91678c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) 91688c2ecf20Sopenharmony_ci SiS_SetCH700x(SiS_Pr, reg, val); 91698c2ecf20Sopenharmony_ci else 91708c2ecf20Sopenharmony_ci SiS_SetCH701x(SiS_Pr, reg, val); 91718c2ecf20Sopenharmony_ci} 91728c2ecf20Sopenharmony_ci 91738c2ecf20Sopenharmony_cistatic unsigned short 91748c2ecf20Sopenharmony_ciSiS_GetChReg(struct SiS_Private *SiS_Pr, unsigned short myor) 91758c2ecf20Sopenharmony_ci{ 91768c2ecf20Sopenharmony_ci unsigned short tempah, temp, i; 91778c2ecf20Sopenharmony_ci 91788c2ecf20Sopenharmony_ci for(i=0; i<20; i++) { /* Do 20 attempts to read */ 91798c2ecf20Sopenharmony_ci if(i) { 91808c2ecf20Sopenharmony_ci SiS_SetStop(SiS_Pr); 91818c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT * 4); 91828c2ecf20Sopenharmony_ci } 91838c2ecf20Sopenharmony_ci if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ 91848c2ecf20Sopenharmony_ci temp = SiS_WriteDDC2Data(SiS_Pr,SiS_Pr->SiS_DDC_DeviceAddr); /* Write DAB (S0=0=write) */ 91858c2ecf20Sopenharmony_ci if(temp) continue; /* (ERROR: no ack) */ 91868c2ecf20Sopenharmony_ci temp = SiS_WriteDDC2Data(SiS_Pr,SiS_Pr->SiS_DDC_ReadAddr | myor); /* Write RAB (700x: | 0x80) */ 91878c2ecf20Sopenharmony_ci if(temp) continue; /* (ERROR: no ack) */ 91888c2ecf20Sopenharmony_ci if (SiS_SetStart(SiS_Pr)) continue; /* Re-start */ 91898c2ecf20Sopenharmony_ci temp = SiS_WriteDDC2Data(SiS_Pr,SiS_Pr->SiS_DDC_DeviceAddr | 0x01);/* DAB (S0=1=read) */ 91908c2ecf20Sopenharmony_ci if(temp) continue; /* (ERROR: no ack) */ 91918c2ecf20Sopenharmony_ci tempah = SiS_ReadDDC2Data(SiS_Pr); /* Read byte */ 91928c2ecf20Sopenharmony_ci if(SiS_SetStop(SiS_Pr)) continue; /* Stop condition */ 91938c2ecf20Sopenharmony_ci SiS_Pr->SiS_ChrontelInit = 1; 91948c2ecf20Sopenharmony_ci return tempah; 91958c2ecf20Sopenharmony_ci } 91968c2ecf20Sopenharmony_ci return 0xFFFF; 91978c2ecf20Sopenharmony_ci} 91988c2ecf20Sopenharmony_ci 91998c2ecf20Sopenharmony_ci/* Read from Chrontel 700x */ 92008c2ecf20Sopenharmony_ci/* Parameter is [Register no (S7-S0)] */ 92018c2ecf20Sopenharmony_ciunsigned short 92028c2ecf20Sopenharmony_ciSiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short tempbx) 92038c2ecf20Sopenharmony_ci{ 92048c2ecf20Sopenharmony_ci unsigned short result; 92058c2ecf20Sopenharmony_ci 92068c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ 92078c2ecf20Sopenharmony_ci 92088c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); 92098c2ecf20Sopenharmony_ci 92108c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_ChrontelInit)) { 92118c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ 92128c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ 92138c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ 92148c2ecf20Sopenharmony_ci SiS_SetupDDCN(SiS_Pr); 92158c2ecf20Sopenharmony_ci } 92168c2ecf20Sopenharmony_ci 92178c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_ReadAddr = tempbx; 92188c2ecf20Sopenharmony_ci 92198c2ecf20Sopenharmony_ci if( ((result = SiS_GetChReg(SiS_Pr,0x80)) == 0xFFFF) && 92208c2ecf20Sopenharmony_ci (!SiS_Pr->SiS_ChrontelInit) ) { 92218c2ecf20Sopenharmony_ci 92228c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index = 0x0a; 92238c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data = 0x80; 92248c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Clk = 0x40; 92258c2ecf20Sopenharmony_ci SiS_SetupDDCN(SiS_Pr); 92268c2ecf20Sopenharmony_ci 92278c2ecf20Sopenharmony_ci result = SiS_GetChReg(SiS_Pr,0x80); 92288c2ecf20Sopenharmony_ci } 92298c2ecf20Sopenharmony_ci return result; 92308c2ecf20Sopenharmony_ci} 92318c2ecf20Sopenharmony_ci 92328c2ecf20Sopenharmony_ci/* Read from Chrontel 701x */ 92338c2ecf20Sopenharmony_ci/* Parameter is [Register no (S7-S0)] */ 92348c2ecf20Sopenharmony_ciunsigned short 92358c2ecf20Sopenharmony_ciSiS_GetCH701x(struct SiS_Private *SiS_Pr, unsigned short tempbx) 92368c2ecf20Sopenharmony_ci{ 92378c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ 92388c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ 92398c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ 92408c2ecf20Sopenharmony_ci SiS_SetupDDCN(SiS_Pr); 92418c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ 92428c2ecf20Sopenharmony_ci 92438c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_ReadAddr = tempbx; 92448c2ecf20Sopenharmony_ci 92458c2ecf20Sopenharmony_ci return SiS_GetChReg(SiS_Pr,0); 92468c2ecf20Sopenharmony_ci} 92478c2ecf20Sopenharmony_ci 92488c2ecf20Sopenharmony_ci/* Read from Chrontel 70xx */ 92498c2ecf20Sopenharmony_ci/* Parameter is [Register no (S7-S0)] */ 92508c2ecf20Sopenharmony_cistatic 92518c2ecf20Sopenharmony_ciunsigned short 92528c2ecf20Sopenharmony_ciSiS_GetCH70xx(struct SiS_Private *SiS_Pr, unsigned short tempbx) 92538c2ecf20Sopenharmony_ci{ 92548c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) 92558c2ecf20Sopenharmony_ci return SiS_GetCH700x(SiS_Pr, tempbx); 92568c2ecf20Sopenharmony_ci else 92578c2ecf20Sopenharmony_ci return SiS_GetCH701x(SiS_Pr, tempbx); 92588c2ecf20Sopenharmony_ci} 92598c2ecf20Sopenharmony_ci 92608c2ecf20Sopenharmony_civoid 92618c2ecf20Sopenharmony_ciSiS_SetCH70xxANDOR(struct SiS_Private *SiS_Pr, unsigned short reg, 92628c2ecf20Sopenharmony_ci unsigned char myor, unsigned short myand) 92638c2ecf20Sopenharmony_ci{ 92648c2ecf20Sopenharmony_ci unsigned short tempbl; 92658c2ecf20Sopenharmony_ci 92668c2ecf20Sopenharmony_ci tempbl = (SiS_GetCH70xx(SiS_Pr, (reg & 0xFF)) & myand) | myor; 92678c2ecf20Sopenharmony_ci SiS_SetCH70xx(SiS_Pr, reg, tempbl); 92688c2ecf20Sopenharmony_ci} 92698c2ecf20Sopenharmony_ci 92708c2ecf20Sopenharmony_ci/* Our own DDC functions */ 92718c2ecf20Sopenharmony_cistatic 92728c2ecf20Sopenharmony_ciunsigned short 92738c2ecf20Sopenharmony_ciSiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine, 92748c2ecf20Sopenharmony_ci unsigned short adaptnum, unsigned short DDCdatatype, bool checkcr32, 92758c2ecf20Sopenharmony_ci unsigned int VBFlags2) 92768c2ecf20Sopenharmony_ci{ 92778c2ecf20Sopenharmony_ci unsigned char ddcdtype[] = { 0xa0, 0xa0, 0xa0, 0xa2, 0xa6 }; 92788c2ecf20Sopenharmony_ci unsigned char flag, cr32; 92798c2ecf20Sopenharmony_ci unsigned short temp = 0, myadaptnum = adaptnum; 92808c2ecf20Sopenharmony_ci 92818c2ecf20Sopenharmony_ci if(adaptnum != 0) { 92828c2ecf20Sopenharmony_ci if(!(VBFlags2 & VB2_SISTMDSBRIDGE)) return 0xFFFF; 92838c2ecf20Sopenharmony_ci if((VBFlags2 & VB2_30xBDH) && (adaptnum == 1)) return 0xFFFF; 92848c2ecf20Sopenharmony_ci } 92858c2ecf20Sopenharmony_ci 92868c2ecf20Sopenharmony_ci /* adapternum for SiS bridges: 0 = CRT1, 1 = LCD, 2 = VGA2 */ 92878c2ecf20Sopenharmony_ci 92888c2ecf20Sopenharmony_ci SiS_Pr->SiS_ChrontelInit = 0; /* force re-detection! */ 92898c2ecf20Sopenharmony_ci 92908c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_SecAddr = 0; 92918c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_DeviceAddr = ddcdtype[DDCdatatype]; 92928c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_P3c4; 92938c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index = 0x11; 92948c2ecf20Sopenharmony_ci flag = 0xff; 92958c2ecf20Sopenharmony_ci 92968c2ecf20Sopenharmony_ci cr32 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x32); 92978c2ecf20Sopenharmony_ci 92988c2ecf20Sopenharmony_ci#if 0 92998c2ecf20Sopenharmony_ci if(VBFlags2 & VB2_SISBRIDGE) { 93008c2ecf20Sopenharmony_ci if(myadaptnum == 0) { 93018c2ecf20Sopenharmony_ci if(!(cr32 & 0x20)) { 93028c2ecf20Sopenharmony_ci myadaptnum = 2; 93038c2ecf20Sopenharmony_ci if(!(cr32 & 0x10)) { 93048c2ecf20Sopenharmony_ci myadaptnum = 1; 93058c2ecf20Sopenharmony_ci if(!(cr32 & 0x08)) { 93068c2ecf20Sopenharmony_ci myadaptnum = 0; 93078c2ecf20Sopenharmony_ci } 93088c2ecf20Sopenharmony_ci } 93098c2ecf20Sopenharmony_ci } 93108c2ecf20Sopenharmony_ci } 93118c2ecf20Sopenharmony_ci } 93128c2ecf20Sopenharmony_ci#endif 93138c2ecf20Sopenharmony_ci 93148c2ecf20Sopenharmony_ci if(VGAEngine == SIS_300_VGA) { /* 300 series */ 93158c2ecf20Sopenharmony_ci 93168c2ecf20Sopenharmony_ci if(myadaptnum != 0) { 93178c2ecf20Sopenharmony_ci flag = 0; 93188c2ecf20Sopenharmony_ci if(VBFlags2 & VB2_SISBRIDGE) { 93198c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port; 93208c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index = 0x0f; 93218c2ecf20Sopenharmony_ci } 93228c2ecf20Sopenharmony_ci } 93238c2ecf20Sopenharmony_ci 93248c2ecf20Sopenharmony_ci if(!(VBFlags2 & VB2_301)) { 93258c2ecf20Sopenharmony_ci if((cr32 & 0x80) && (checkcr32)) { 93268c2ecf20Sopenharmony_ci if(myadaptnum >= 1) { 93278c2ecf20Sopenharmony_ci if(!(cr32 & 0x08)) { 93288c2ecf20Sopenharmony_ci myadaptnum = 1; 93298c2ecf20Sopenharmony_ci if(!(cr32 & 0x10)) return 0xFFFF; 93308c2ecf20Sopenharmony_ci } 93318c2ecf20Sopenharmony_ci } 93328c2ecf20Sopenharmony_ci } 93338c2ecf20Sopenharmony_ci } 93348c2ecf20Sopenharmony_ci 93358c2ecf20Sopenharmony_ci temp = 4 - (myadaptnum * 2); 93368c2ecf20Sopenharmony_ci if(flag) temp = 0; 93378c2ecf20Sopenharmony_ci 93388c2ecf20Sopenharmony_ci } else { /* 315/330 series */ 93398c2ecf20Sopenharmony_ci 93408c2ecf20Sopenharmony_ci /* here we simplify: 0 = CRT1, 1 = CRT2 (VGA, LCD) */ 93418c2ecf20Sopenharmony_ci 93428c2ecf20Sopenharmony_ci if(VBFlags2 & VB2_SISBRIDGE) { 93438c2ecf20Sopenharmony_ci if(myadaptnum == 2) { 93448c2ecf20Sopenharmony_ci myadaptnum = 1; 93458c2ecf20Sopenharmony_ci } 93468c2ecf20Sopenharmony_ci } 93478c2ecf20Sopenharmony_ci 93488c2ecf20Sopenharmony_ci if(myadaptnum == 1) { 93498c2ecf20Sopenharmony_ci flag = 0; 93508c2ecf20Sopenharmony_ci if(VBFlags2 & VB2_SISBRIDGE) { 93518c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port; 93528c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index = 0x0f; 93538c2ecf20Sopenharmony_ci } 93548c2ecf20Sopenharmony_ci } 93558c2ecf20Sopenharmony_ci 93568c2ecf20Sopenharmony_ci if((cr32 & 0x80) && (checkcr32)) { 93578c2ecf20Sopenharmony_ci if(myadaptnum >= 1) { 93588c2ecf20Sopenharmony_ci if(!(cr32 & 0x08)) { 93598c2ecf20Sopenharmony_ci myadaptnum = 1; 93608c2ecf20Sopenharmony_ci if(!(cr32 & 0x10)) return 0xFFFF; 93618c2ecf20Sopenharmony_ci } 93628c2ecf20Sopenharmony_ci } 93638c2ecf20Sopenharmony_ci } 93648c2ecf20Sopenharmony_ci 93658c2ecf20Sopenharmony_ci temp = myadaptnum; 93668c2ecf20Sopenharmony_ci if(myadaptnum == 1) { 93678c2ecf20Sopenharmony_ci temp = 0; 93688c2ecf20Sopenharmony_ci if(VBFlags2 & VB2_LVDS) flag = 0xff; 93698c2ecf20Sopenharmony_ci } 93708c2ecf20Sopenharmony_ci 93718c2ecf20Sopenharmony_ci if(flag) temp = 0; 93728c2ecf20Sopenharmony_ci } 93738c2ecf20Sopenharmony_ci 93748c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data = 0x02 << temp; 93758c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Clk = 0x01 << temp; 93768c2ecf20Sopenharmony_ci 93778c2ecf20Sopenharmony_ci SiS_SetupDDCN(SiS_Pr); 93788c2ecf20Sopenharmony_ci 93798c2ecf20Sopenharmony_ci return 0; 93808c2ecf20Sopenharmony_ci} 93818c2ecf20Sopenharmony_ci 93828c2ecf20Sopenharmony_cistatic unsigned short 93838c2ecf20Sopenharmony_ciSiS_WriteDABDDC(struct SiS_Private *SiS_Pr) 93848c2ecf20Sopenharmony_ci{ 93858c2ecf20Sopenharmony_ci if(SiS_SetStart(SiS_Pr)) return 0xFFFF; 93868c2ecf20Sopenharmony_ci if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr)) { 93878c2ecf20Sopenharmony_ci return 0xFFFF; 93888c2ecf20Sopenharmony_ci } 93898c2ecf20Sopenharmony_ci if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_SecAddr)) { 93908c2ecf20Sopenharmony_ci return 0xFFFF; 93918c2ecf20Sopenharmony_ci } 93928c2ecf20Sopenharmony_ci return 0; 93938c2ecf20Sopenharmony_ci} 93948c2ecf20Sopenharmony_ci 93958c2ecf20Sopenharmony_cistatic unsigned short 93968c2ecf20Sopenharmony_ciSiS_PrepareReadDDC(struct SiS_Private *SiS_Pr) 93978c2ecf20Sopenharmony_ci{ 93988c2ecf20Sopenharmony_ci if(SiS_SetStart(SiS_Pr)) return 0xFFFF; 93998c2ecf20Sopenharmony_ci if(SiS_WriteDDC2Data(SiS_Pr, (SiS_Pr->SiS_DDC_DeviceAddr | 0x01))) { 94008c2ecf20Sopenharmony_ci return 0xFFFF; 94018c2ecf20Sopenharmony_ci } 94028c2ecf20Sopenharmony_ci return 0; 94038c2ecf20Sopenharmony_ci} 94048c2ecf20Sopenharmony_ci 94058c2ecf20Sopenharmony_cistatic unsigned short 94068c2ecf20Sopenharmony_ciSiS_PrepareDDC(struct SiS_Private *SiS_Pr) 94078c2ecf20Sopenharmony_ci{ 94088c2ecf20Sopenharmony_ci if(SiS_WriteDABDDC(SiS_Pr)) SiS_WriteDABDDC(SiS_Pr); 94098c2ecf20Sopenharmony_ci if(SiS_PrepareReadDDC(SiS_Pr)) return (SiS_PrepareReadDDC(SiS_Pr)); 94108c2ecf20Sopenharmony_ci return 0; 94118c2ecf20Sopenharmony_ci} 94128c2ecf20Sopenharmony_ci 94138c2ecf20Sopenharmony_cistatic void 94148c2ecf20Sopenharmony_ciSiS_SendACK(struct SiS_Private *SiS_Pr, unsigned short yesno) 94158c2ecf20Sopenharmony_ci{ 94168c2ecf20Sopenharmony_ci SiS_SetSCLKLow(SiS_Pr); 94178c2ecf20Sopenharmony_ci if(yesno) { 94188c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 94198c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index, 94208c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NData, 94218c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data); 94228c2ecf20Sopenharmony_ci } else { 94238c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 94248c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index, 94258c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NData, 94268c2ecf20Sopenharmony_ci 0); 94278c2ecf20Sopenharmony_ci } 94288c2ecf20Sopenharmony_ci SiS_SetSCLKHigh(SiS_Pr); 94298c2ecf20Sopenharmony_ci} 94308c2ecf20Sopenharmony_ci 94318c2ecf20Sopenharmony_cistatic unsigned short 94328c2ecf20Sopenharmony_ciSiS_DoProbeDDC(struct SiS_Private *SiS_Pr) 94338c2ecf20Sopenharmony_ci{ 94348c2ecf20Sopenharmony_ci unsigned char mask, value; 94358c2ecf20Sopenharmony_ci unsigned short temp, ret=0; 94368c2ecf20Sopenharmony_ci bool failed = false; 94378c2ecf20Sopenharmony_ci 94388c2ecf20Sopenharmony_ci SiS_SetSwitchDDC2(SiS_Pr); 94398c2ecf20Sopenharmony_ci if(SiS_PrepareDDC(SiS_Pr)) { 94408c2ecf20Sopenharmony_ci SiS_SetStop(SiS_Pr); 94418c2ecf20Sopenharmony_ci return 0xFFFF; 94428c2ecf20Sopenharmony_ci } 94438c2ecf20Sopenharmony_ci mask = 0xf0; 94448c2ecf20Sopenharmony_ci value = 0x20; 94458c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { 94468c2ecf20Sopenharmony_ci temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr); 94478c2ecf20Sopenharmony_ci SiS_SendACK(SiS_Pr, 0); 94488c2ecf20Sopenharmony_ci if(temp == 0) { 94498c2ecf20Sopenharmony_ci mask = 0xff; 94508c2ecf20Sopenharmony_ci value = 0xff; 94518c2ecf20Sopenharmony_ci } else { 94528c2ecf20Sopenharmony_ci failed = true; 94538c2ecf20Sopenharmony_ci ret = 0xFFFF; 94548c2ecf20Sopenharmony_ci } 94558c2ecf20Sopenharmony_ci } 94568c2ecf20Sopenharmony_ci if(!failed) { 94578c2ecf20Sopenharmony_ci temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr); 94588c2ecf20Sopenharmony_ci SiS_SendACK(SiS_Pr, 1); 94598c2ecf20Sopenharmony_ci temp &= mask; 94608c2ecf20Sopenharmony_ci if(temp == value) ret = 0; 94618c2ecf20Sopenharmony_ci else { 94628c2ecf20Sopenharmony_ci ret = 0xFFFF; 94638c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { 94648c2ecf20Sopenharmony_ci if(temp == 0x30) ret = 0; 94658c2ecf20Sopenharmony_ci } 94668c2ecf20Sopenharmony_ci } 94678c2ecf20Sopenharmony_ci } 94688c2ecf20Sopenharmony_ci SiS_SetStop(SiS_Pr); 94698c2ecf20Sopenharmony_ci return ret; 94708c2ecf20Sopenharmony_ci} 94718c2ecf20Sopenharmony_ci 94728c2ecf20Sopenharmony_cistatic 94738c2ecf20Sopenharmony_ciunsigned short 94748c2ecf20Sopenharmony_ciSiS_ProbeDDC(struct SiS_Private *SiS_Pr) 94758c2ecf20Sopenharmony_ci{ 94768c2ecf20Sopenharmony_ci unsigned short flag; 94778c2ecf20Sopenharmony_ci 94788c2ecf20Sopenharmony_ci flag = 0x180; 94798c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; 94808c2ecf20Sopenharmony_ci if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x02; 94818c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; 94828c2ecf20Sopenharmony_ci if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x08; 94838c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; 94848c2ecf20Sopenharmony_ci if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x10; 94858c2ecf20Sopenharmony_ci if(!(flag & 0x1a)) flag = 0; 94868c2ecf20Sopenharmony_ci return flag; 94878c2ecf20Sopenharmony_ci} 94888c2ecf20Sopenharmony_ci 94898c2ecf20Sopenharmony_cistatic 94908c2ecf20Sopenharmony_ciunsigned short 94918c2ecf20Sopenharmony_ciSiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype, unsigned char *buffer) 94928c2ecf20Sopenharmony_ci{ 94938c2ecf20Sopenharmony_ci unsigned short flag, length, i; 94948c2ecf20Sopenharmony_ci unsigned char chksum,gotcha; 94958c2ecf20Sopenharmony_ci 94968c2ecf20Sopenharmony_ci if(DDCdatatype > 4) return 0xFFFF; 94978c2ecf20Sopenharmony_ci 94988c2ecf20Sopenharmony_ci flag = 0; 94998c2ecf20Sopenharmony_ci SiS_SetSwitchDDC2(SiS_Pr); 95008c2ecf20Sopenharmony_ci if(!(SiS_PrepareDDC(SiS_Pr))) { 95018c2ecf20Sopenharmony_ci length = 127; 95028c2ecf20Sopenharmony_ci if(DDCdatatype != 1) length = 255; 95038c2ecf20Sopenharmony_ci chksum = 0; 95048c2ecf20Sopenharmony_ci gotcha = 0; 95058c2ecf20Sopenharmony_ci for(i=0; i<length; i++) { 95068c2ecf20Sopenharmony_ci buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr); 95078c2ecf20Sopenharmony_ci chksum += buffer[i]; 95088c2ecf20Sopenharmony_ci gotcha |= buffer[i]; 95098c2ecf20Sopenharmony_ci SiS_SendACK(SiS_Pr, 0); 95108c2ecf20Sopenharmony_ci } 95118c2ecf20Sopenharmony_ci buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr); 95128c2ecf20Sopenharmony_ci chksum += buffer[i]; 95138c2ecf20Sopenharmony_ci SiS_SendACK(SiS_Pr, 1); 95148c2ecf20Sopenharmony_ci if(gotcha) flag = (unsigned short)chksum; 95158c2ecf20Sopenharmony_ci else flag = 0xFFFF; 95168c2ecf20Sopenharmony_ci } else { 95178c2ecf20Sopenharmony_ci flag = 0xFFFF; 95188c2ecf20Sopenharmony_ci } 95198c2ecf20Sopenharmony_ci SiS_SetStop(SiS_Pr); 95208c2ecf20Sopenharmony_ci return flag; 95218c2ecf20Sopenharmony_ci} 95228c2ecf20Sopenharmony_ci 95238c2ecf20Sopenharmony_ci/* Our private DDC functions 95248c2ecf20Sopenharmony_ci 95258c2ecf20Sopenharmony_ci It complies somewhat with the corresponding VESA function 95268c2ecf20Sopenharmony_ci in arguments and return values. 95278c2ecf20Sopenharmony_ci 95288c2ecf20Sopenharmony_ci Since this is probably called before the mode is changed, 95298c2ecf20Sopenharmony_ci we use our pre-detected pSiS-values instead of SiS_Pr as 95308c2ecf20Sopenharmony_ci regards chipset and video bridge type. 95318c2ecf20Sopenharmony_ci 95328c2ecf20Sopenharmony_ci Arguments: 95338c2ecf20Sopenharmony_ci adaptnum: 0=CRT1(analog), 1=CRT2/LCD(digital), 2=CRT2/VGA2(analog) 95348c2ecf20Sopenharmony_ci CRT2 DDC is only supported on SiS301, 301B, 301C, 302B. 95358c2ecf20Sopenharmony_ci LCDA is CRT1, but DDC is read from CRT2 port. 95368c2ecf20Sopenharmony_ci DDCdatatype: 0=Probe, 1=EDID, 2=EDID+VDIF, 3=EDID V2 (P&D), 4=EDID V2 (FPDI-2) 95378c2ecf20Sopenharmony_ci buffer: ptr to 256 data bytes which will be filled with read data. 95388c2ecf20Sopenharmony_ci 95398c2ecf20Sopenharmony_ci Returns 0xFFFF if error, otherwise 95408c2ecf20Sopenharmony_ci if DDCdatatype > 0: Returns 0 if reading OK (included a correct checksum) 95418c2ecf20Sopenharmony_ci if DDCdatatype = 0: Returns supported DDC modes 95428c2ecf20Sopenharmony_ci 95438c2ecf20Sopenharmony_ci */ 95448c2ecf20Sopenharmony_ciunsigned short 95458c2ecf20Sopenharmony_ciSiS_HandleDDC(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine, 95468c2ecf20Sopenharmony_ci unsigned short adaptnum, unsigned short DDCdatatype, unsigned char *buffer, 95478c2ecf20Sopenharmony_ci unsigned int VBFlags2) 95488c2ecf20Sopenharmony_ci{ 95498c2ecf20Sopenharmony_ci unsigned char sr1f, cr17=1; 95508c2ecf20Sopenharmony_ci unsigned short result; 95518c2ecf20Sopenharmony_ci 95528c2ecf20Sopenharmony_ci if(adaptnum > 2) 95538c2ecf20Sopenharmony_ci return 0xFFFF; 95548c2ecf20Sopenharmony_ci 95558c2ecf20Sopenharmony_ci if(DDCdatatype > 4) 95568c2ecf20Sopenharmony_ci return 0xFFFF; 95578c2ecf20Sopenharmony_ci 95588c2ecf20Sopenharmony_ci if((!(VBFlags2 & VB2_VIDEOBRIDGE)) && (adaptnum > 0)) 95598c2ecf20Sopenharmony_ci return 0xFFFF; 95608c2ecf20Sopenharmony_ci 95618c2ecf20Sopenharmony_ci if(SiS_InitDDCRegs(SiS_Pr, VBFlags, VGAEngine, adaptnum, DDCdatatype, false, VBFlags2) == 0xFFFF) 95628c2ecf20Sopenharmony_ci return 0xFFFF; 95638c2ecf20Sopenharmony_ci 95648c2ecf20Sopenharmony_ci sr1f = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f); 95658c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1f,0x3f,0x04); 95668c2ecf20Sopenharmony_ci if(VGAEngine == SIS_300_VGA) { 95678c2ecf20Sopenharmony_ci cr17 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80; 95688c2ecf20Sopenharmony_ci if(!cr17) { 95698c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x17,0x80); 95708c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x01); 95718c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x03); 95728c2ecf20Sopenharmony_ci } 95738c2ecf20Sopenharmony_ci } 95748c2ecf20Sopenharmony_ci if((sr1f) || (!cr17)) { 95758c2ecf20Sopenharmony_ci SiS_WaitRetrace1(SiS_Pr); 95768c2ecf20Sopenharmony_ci SiS_WaitRetrace1(SiS_Pr); 95778c2ecf20Sopenharmony_ci SiS_WaitRetrace1(SiS_Pr); 95788c2ecf20Sopenharmony_ci SiS_WaitRetrace1(SiS_Pr); 95798c2ecf20Sopenharmony_ci } 95808c2ecf20Sopenharmony_ci 95818c2ecf20Sopenharmony_ci if(DDCdatatype == 0) { 95828c2ecf20Sopenharmony_ci result = SiS_ProbeDDC(SiS_Pr); 95838c2ecf20Sopenharmony_ci } else { 95848c2ecf20Sopenharmony_ci result = SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer); 95858c2ecf20Sopenharmony_ci if((!result) && (DDCdatatype == 1)) { 95868c2ecf20Sopenharmony_ci if((buffer[0] == 0x00) && (buffer[1] == 0xff) && 95878c2ecf20Sopenharmony_ci (buffer[2] == 0xff) && (buffer[3] == 0xff) && 95888c2ecf20Sopenharmony_ci (buffer[4] == 0xff) && (buffer[5] == 0xff) && 95898c2ecf20Sopenharmony_ci (buffer[6] == 0xff) && (buffer[7] == 0x00) && 95908c2ecf20Sopenharmony_ci (buffer[0x12] == 1)) { 95918c2ecf20Sopenharmony_ci if(!SiS_Pr->DDCPortMixup) { 95928c2ecf20Sopenharmony_ci if(adaptnum == 1) { 95938c2ecf20Sopenharmony_ci if(!(buffer[0x14] & 0x80)) result = 0xFFFE; 95948c2ecf20Sopenharmony_ci } else { 95958c2ecf20Sopenharmony_ci if(buffer[0x14] & 0x80) result = 0xFFFE; 95968c2ecf20Sopenharmony_ci } 95978c2ecf20Sopenharmony_ci } 95988c2ecf20Sopenharmony_ci } 95998c2ecf20Sopenharmony_ci } 96008c2ecf20Sopenharmony_ci } 96018c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_P3c4,0x1f,sr1f); 96028c2ecf20Sopenharmony_ci if(VGAEngine == SIS_300_VGA) { 96038c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x17,0x7f,cr17); 96048c2ecf20Sopenharmony_ci } 96058c2ecf20Sopenharmony_ci return result; 96068c2ecf20Sopenharmony_ci} 96078c2ecf20Sopenharmony_ci 96088c2ecf20Sopenharmony_ci/* Generic I2C functions for Chrontel & DDC --------- */ 96098c2ecf20Sopenharmony_ci 96108c2ecf20Sopenharmony_cistatic void 96118c2ecf20Sopenharmony_ciSiS_SetSwitchDDC2(struct SiS_Private *SiS_Pr) 96128c2ecf20Sopenharmony_ci{ 96138c2ecf20Sopenharmony_ci SiS_SetSCLKHigh(SiS_Pr); 96148c2ecf20Sopenharmony_ci SiS_WaitRetrace1(SiS_Pr); 96158c2ecf20Sopenharmony_ci 96168c2ecf20Sopenharmony_ci SiS_SetSCLKLow(SiS_Pr); 96178c2ecf20Sopenharmony_ci SiS_WaitRetrace1(SiS_Pr); 96188c2ecf20Sopenharmony_ci} 96198c2ecf20Sopenharmony_ci 96208c2ecf20Sopenharmony_ciunsigned short 96218c2ecf20Sopenharmony_ciSiS_ReadDDC1Bit(struct SiS_Private *SiS_Pr) 96228c2ecf20Sopenharmony_ci{ 96238c2ecf20Sopenharmony_ci SiS_WaitRetrace1(SiS_Pr); 96248c2ecf20Sopenharmony_ci return ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x02) >> 1); 96258c2ecf20Sopenharmony_ci} 96268c2ecf20Sopenharmony_ci 96278c2ecf20Sopenharmony_ci/* Set I2C start condition */ 96288c2ecf20Sopenharmony_ci/* This is done by a SD high-to-low transition while SC is high */ 96298c2ecf20Sopenharmony_cistatic unsigned short 96308c2ecf20Sopenharmony_ciSiS_SetStart(struct SiS_Private *SiS_Pr) 96318c2ecf20Sopenharmony_ci{ 96328c2ecf20Sopenharmony_ci if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ 96338c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 96348c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index, 96358c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NData, 96368c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data); /* SD->high */ 96378c2ecf20Sopenharmony_ci if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ 96388c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 96398c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index, 96408c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NData, 96418c2ecf20Sopenharmony_ci 0x00); /* SD->low = start condition */ 96428c2ecf20Sopenharmony_ci if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->low) */ 96438c2ecf20Sopenharmony_ci return 0; 96448c2ecf20Sopenharmony_ci} 96458c2ecf20Sopenharmony_ci 96468c2ecf20Sopenharmony_ci/* Set I2C stop condition */ 96478c2ecf20Sopenharmony_ci/* This is done by a SD low-to-high transition while SC is high */ 96488c2ecf20Sopenharmony_cistatic unsigned short 96498c2ecf20Sopenharmony_ciSiS_SetStop(struct SiS_Private *SiS_Pr) 96508c2ecf20Sopenharmony_ci{ 96518c2ecf20Sopenharmony_ci if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ 96528c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 96538c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index, 96548c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NData, 96558c2ecf20Sopenharmony_ci 0x00); /* SD->low */ 96568c2ecf20Sopenharmony_ci if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ 96578c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 96588c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index, 96598c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NData, 96608c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data); /* SD->high = stop condition */ 96618c2ecf20Sopenharmony_ci if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->high) */ 96628c2ecf20Sopenharmony_ci return 0; 96638c2ecf20Sopenharmony_ci} 96648c2ecf20Sopenharmony_ci 96658c2ecf20Sopenharmony_ci/* Write 8 bits of data */ 96668c2ecf20Sopenharmony_cistatic unsigned short 96678c2ecf20Sopenharmony_ciSiS_WriteDDC2Data(struct SiS_Private *SiS_Pr, unsigned short tempax) 96688c2ecf20Sopenharmony_ci{ 96698c2ecf20Sopenharmony_ci unsigned short i,flag,temp; 96708c2ecf20Sopenharmony_ci 96718c2ecf20Sopenharmony_ci flag = 0x80; 96728c2ecf20Sopenharmony_ci for(i = 0; i < 8; i++) { 96738c2ecf20Sopenharmony_ci SiS_SetSCLKLow(SiS_Pr); /* SC->low */ 96748c2ecf20Sopenharmony_ci if(tempax & flag) { 96758c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 96768c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index, 96778c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NData, 96788c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data); /* Write bit (1) to SD */ 96798c2ecf20Sopenharmony_ci } else { 96808c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 96818c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index, 96828c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NData, 96838c2ecf20Sopenharmony_ci 0x00); /* Write bit (0) to SD */ 96848c2ecf20Sopenharmony_ci } 96858c2ecf20Sopenharmony_ci SiS_SetSCLKHigh(SiS_Pr); /* SC->high */ 96868c2ecf20Sopenharmony_ci flag >>= 1; 96878c2ecf20Sopenharmony_ci } 96888c2ecf20Sopenharmony_ci temp = SiS_CheckACK(SiS_Pr); /* Check acknowledge */ 96898c2ecf20Sopenharmony_ci return temp; 96908c2ecf20Sopenharmony_ci} 96918c2ecf20Sopenharmony_ci 96928c2ecf20Sopenharmony_cistatic unsigned short 96938c2ecf20Sopenharmony_ciSiS_ReadDDC2Data(struct SiS_Private *SiS_Pr) 96948c2ecf20Sopenharmony_ci{ 96958c2ecf20Sopenharmony_ci unsigned short i, temp, getdata; 96968c2ecf20Sopenharmony_ci 96978c2ecf20Sopenharmony_ci getdata = 0; 96988c2ecf20Sopenharmony_ci for(i = 0; i < 8; i++) { 96998c2ecf20Sopenharmony_ci getdata <<= 1; 97008c2ecf20Sopenharmony_ci SiS_SetSCLKLow(SiS_Pr); 97018c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 97028c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index, 97038c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NData, 97048c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data); 97058c2ecf20Sopenharmony_ci SiS_SetSCLKHigh(SiS_Pr); 97068c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); 97078c2ecf20Sopenharmony_ci if(temp & SiS_Pr->SiS_DDC_Data) getdata |= 0x01; 97088c2ecf20Sopenharmony_ci } 97098c2ecf20Sopenharmony_ci return getdata; 97108c2ecf20Sopenharmony_ci} 97118c2ecf20Sopenharmony_ci 97128c2ecf20Sopenharmony_cistatic unsigned short 97138c2ecf20Sopenharmony_ciSiS_SetSCLKLow(struct SiS_Private *SiS_Pr) 97148c2ecf20Sopenharmony_ci{ 97158c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 97168c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index, 97178c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NClk, 97188c2ecf20Sopenharmony_ci 0x00); /* SetSCLKLow() */ 97198c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); 97208c2ecf20Sopenharmony_ci return 0; 97218c2ecf20Sopenharmony_ci} 97228c2ecf20Sopenharmony_ci 97238c2ecf20Sopenharmony_cistatic unsigned short 97248c2ecf20Sopenharmony_ciSiS_SetSCLKHigh(struct SiS_Private *SiS_Pr) 97258c2ecf20Sopenharmony_ci{ 97268c2ecf20Sopenharmony_ci unsigned short temp, watchdog=1000; 97278c2ecf20Sopenharmony_ci 97288c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 97298c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index, 97308c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NClk, 97318c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Clk); /* SetSCLKHigh() */ 97328c2ecf20Sopenharmony_ci do { 97338c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); 97348c2ecf20Sopenharmony_ci } while((!(temp & SiS_Pr->SiS_DDC_Clk)) && --watchdog); 97358c2ecf20Sopenharmony_ci if (!watchdog) { 97368c2ecf20Sopenharmony_ci return 0xFFFF; 97378c2ecf20Sopenharmony_ci } 97388c2ecf20Sopenharmony_ci SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); 97398c2ecf20Sopenharmony_ci return 0; 97408c2ecf20Sopenharmony_ci} 97418c2ecf20Sopenharmony_ci 97428c2ecf20Sopenharmony_ci/* Check I2C acknowledge */ 97438c2ecf20Sopenharmony_ci/* Returns 0 if ack ok, non-0 if ack not ok */ 97448c2ecf20Sopenharmony_cistatic unsigned short 97458c2ecf20Sopenharmony_ciSiS_CheckACK(struct SiS_Private *SiS_Pr) 97468c2ecf20Sopenharmony_ci{ 97478c2ecf20Sopenharmony_ci unsigned short tempah; 97488c2ecf20Sopenharmony_ci 97498c2ecf20Sopenharmony_ci SiS_SetSCLKLow(SiS_Pr); /* (SC->low) */ 97508c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 97518c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Index, 97528c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_NData, 97538c2ecf20Sopenharmony_ci SiS_Pr->SiS_DDC_Data); /* (SD->high) */ 97548c2ecf20Sopenharmony_ci SiS_SetSCLKHigh(SiS_Pr); /* SC->high = clock impulse for ack */ 97558c2ecf20Sopenharmony_ci tempah = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); /* Read SD */ 97568c2ecf20Sopenharmony_ci SiS_SetSCLKLow(SiS_Pr); /* SC->low = end of clock impulse */ 97578c2ecf20Sopenharmony_ci if(tempah & SiS_Pr->SiS_DDC_Data) return 1; /* Ack OK if bit = 0 */ 97588c2ecf20Sopenharmony_ci return 0; 97598c2ecf20Sopenharmony_ci} 97608c2ecf20Sopenharmony_ci 97618c2ecf20Sopenharmony_ci/* End of I2C functions ----------------------- */ 97628c2ecf20Sopenharmony_ci 97638c2ecf20Sopenharmony_ci 97648c2ecf20Sopenharmony_ci/* =============== SiS 315/330 O.E.M. ================= */ 97658c2ecf20Sopenharmony_ci 97668c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_315 97678c2ecf20Sopenharmony_ci 97688c2ecf20Sopenharmony_cistatic unsigned short 97698c2ecf20Sopenharmony_ciGetRAMDACromptr(struct SiS_Private *SiS_Pr) 97708c2ecf20Sopenharmony_ci{ 97718c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 97728c2ecf20Sopenharmony_ci unsigned short romptr; 97738c2ecf20Sopenharmony_ci 97748c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_330) { 97758c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x128); 97768c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xB) 97778c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x12a); 97788c2ecf20Sopenharmony_ci } else { 97798c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x1a8); 97808c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xB) 97818c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x1aa); 97828c2ecf20Sopenharmony_ci } 97838c2ecf20Sopenharmony_ci return romptr; 97848c2ecf20Sopenharmony_ci} 97858c2ecf20Sopenharmony_ci 97868c2ecf20Sopenharmony_cistatic unsigned short 97878c2ecf20Sopenharmony_ciGetLCDromptr(struct SiS_Private *SiS_Pr) 97888c2ecf20Sopenharmony_ci{ 97898c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 97908c2ecf20Sopenharmony_ci unsigned short romptr; 97918c2ecf20Sopenharmony_ci 97928c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_330) { 97938c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x120); 97948c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) 97958c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x122); 97968c2ecf20Sopenharmony_ci } else { 97978c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x1a0); 97988c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) 97998c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x1a2); 98008c2ecf20Sopenharmony_ci } 98018c2ecf20Sopenharmony_ci return romptr; 98028c2ecf20Sopenharmony_ci} 98038c2ecf20Sopenharmony_ci 98048c2ecf20Sopenharmony_cistatic unsigned short 98058c2ecf20Sopenharmony_ciGetTVromptr(struct SiS_Private *SiS_Pr) 98068c2ecf20Sopenharmony_ci{ 98078c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 98088c2ecf20Sopenharmony_ci unsigned short romptr; 98098c2ecf20Sopenharmony_ci 98108c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType < SIS_330) { 98118c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x114); 98128c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) 98138c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x11a); 98148c2ecf20Sopenharmony_ci } else { 98158c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x194); 98168c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) 98178c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x19a); 98188c2ecf20Sopenharmony_ci } 98198c2ecf20Sopenharmony_ci return romptr; 98208c2ecf20Sopenharmony_ci} 98218c2ecf20Sopenharmony_ci 98228c2ecf20Sopenharmony_cistatic unsigned short 98238c2ecf20Sopenharmony_ciGetLCDPtrIndexBIOS(struct SiS_Private *SiS_Pr) 98248c2ecf20Sopenharmony_ci{ 98258c2ecf20Sopenharmony_ci unsigned short index; 98268c2ecf20Sopenharmony_ci 98278c2ecf20Sopenharmony_ci if((IS_SIS650) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { 98288c2ecf20Sopenharmony_ci if(!(SiS_IsNotM650orLater(SiS_Pr))) { 98298c2ecf20Sopenharmony_ci if((index = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0)) { 98308c2ecf20Sopenharmony_ci index >>= 4; 98318c2ecf20Sopenharmony_ci index *= 3; 98328c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; 98338c2ecf20Sopenharmony_ci else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++; 98348c2ecf20Sopenharmony_ci return index; 98358c2ecf20Sopenharmony_ci } 98368c2ecf20Sopenharmony_ci } 98378c2ecf20Sopenharmony_ci } 98388c2ecf20Sopenharmony_ci 98398c2ecf20Sopenharmony_ci index = SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F; 98408c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) index -= 5; 98418c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS301C) { /* 1.15.20 and later (not VB specific) */ 98428c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 5; 98438c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1280x768) index -= 5; 98448c2ecf20Sopenharmony_ci } else { 98458c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 6; 98468c2ecf20Sopenharmony_ci } 98478c2ecf20Sopenharmony_ci index--; 98488c2ecf20Sopenharmony_ci index *= 3; 98498c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; 98508c2ecf20Sopenharmony_ci else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++; 98518c2ecf20Sopenharmony_ci return index; 98528c2ecf20Sopenharmony_ci} 98538c2ecf20Sopenharmony_ci 98548c2ecf20Sopenharmony_cistatic unsigned short 98558c2ecf20Sopenharmony_ciGetLCDPtrIndex(struct SiS_Private *SiS_Pr) 98568c2ecf20Sopenharmony_ci{ 98578c2ecf20Sopenharmony_ci unsigned short index; 98588c2ecf20Sopenharmony_ci 98598c2ecf20Sopenharmony_ci index = ((SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F) - 1) * 3; 98608c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; 98618c2ecf20Sopenharmony_ci else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++; 98628c2ecf20Sopenharmony_ci return index; 98638c2ecf20Sopenharmony_ci} 98648c2ecf20Sopenharmony_ci 98658c2ecf20Sopenharmony_cistatic unsigned short 98668c2ecf20Sopenharmony_ciGetTVPtrIndex(struct SiS_Private *SiS_Pr) 98678c2ecf20Sopenharmony_ci{ 98688c2ecf20Sopenharmony_ci unsigned short index; 98698c2ecf20Sopenharmony_ci 98708c2ecf20Sopenharmony_ci index = 0; 98718c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1; 98728c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) index = 2; 98738c2ecf20Sopenharmony_ci 98748c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) index = 0; 98758c2ecf20Sopenharmony_ci 98768c2ecf20Sopenharmony_ci index <<= 1; 98778c2ecf20Sopenharmony_ci 98788c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && 98798c2ecf20Sopenharmony_ci (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) { 98808c2ecf20Sopenharmony_ci index++; 98818c2ecf20Sopenharmony_ci } 98828c2ecf20Sopenharmony_ci 98838c2ecf20Sopenharmony_ci return index; 98848c2ecf20Sopenharmony_ci} 98858c2ecf20Sopenharmony_ci 98868c2ecf20Sopenharmony_cistatic unsigned int 98878c2ecf20Sopenharmony_ciGetOEMTVPtr661_2_GEN(struct SiS_Private *SiS_Pr, int addme) 98888c2ecf20Sopenharmony_ci{ 98898c2ecf20Sopenharmony_ci unsigned short index = 0, temp = 0; 98908c2ecf20Sopenharmony_ci 98918c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1; 98928c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPALM) index = 2; 98938c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPALN) index = 3; 98948c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) index = 6; 98958c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { 98968c2ecf20Sopenharmony_ci index = 4; 98978c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPALM) index++; 98988c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) index = 7; 98998c2ecf20Sopenharmony_ci } 99008c2ecf20Sopenharmony_ci 99018c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 99028c2ecf20Sopenharmony_ci if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || 99038c2ecf20Sopenharmony_ci (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) { 99048c2ecf20Sopenharmony_ci index += addme; 99058c2ecf20Sopenharmony_ci temp++; 99068c2ecf20Sopenharmony_ci } 99078c2ecf20Sopenharmony_ci temp += 0x0100; 99088c2ecf20Sopenharmony_ci } 99098c2ecf20Sopenharmony_ci return (unsigned int)(index | (temp << 16)); 99108c2ecf20Sopenharmony_ci} 99118c2ecf20Sopenharmony_ci 99128c2ecf20Sopenharmony_cistatic unsigned int 99138c2ecf20Sopenharmony_ciGetOEMTVPtr661_2_OLD(struct SiS_Private *SiS_Pr) 99148c2ecf20Sopenharmony_ci{ 99158c2ecf20Sopenharmony_ci return (GetOEMTVPtr661_2_GEN(SiS_Pr, 8)); 99168c2ecf20Sopenharmony_ci} 99178c2ecf20Sopenharmony_ci 99188c2ecf20Sopenharmony_ci#if 0 99198c2ecf20Sopenharmony_cistatic unsigned int 99208c2ecf20Sopenharmony_ciGetOEMTVPtr661_2_NEW(struct SiS_Private *SiS_Pr) 99218c2ecf20Sopenharmony_ci{ 99228c2ecf20Sopenharmony_ci return (GetOEMTVPtr661_2_GEN(SiS_Pr, 6)); 99238c2ecf20Sopenharmony_ci} 99248c2ecf20Sopenharmony_ci#endif 99258c2ecf20Sopenharmony_ci 99268c2ecf20Sopenharmony_cistatic int 99278c2ecf20Sopenharmony_ciGetOEMTVPtr661(struct SiS_Private *SiS_Pr) 99288c2ecf20Sopenharmony_ci{ 99298c2ecf20Sopenharmony_ci int index = 0; 99308c2ecf20Sopenharmony_ci 99318c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 2; 99328c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ROMNew) { 99338c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr525i) index = 4; 99348c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) index = 6; 99358c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) index = 8; 99368c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetHiVision) index = 10; 99378c2ecf20Sopenharmony_ci } else { 99388c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetHiVision) index = 4; 99398c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr525i) index = 6; 99408c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) index = 8; 99418c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) index = 10; 99428c2ecf20Sopenharmony_ci } 99438c2ecf20Sopenharmony_ci 99448c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) index++; 99458c2ecf20Sopenharmony_ci 99468c2ecf20Sopenharmony_ci return index; 99478c2ecf20Sopenharmony_ci} 99488c2ecf20Sopenharmony_ci 99498c2ecf20Sopenharmony_cistatic void 99508c2ecf20Sopenharmony_ciSetDelayComp(struct SiS_Private *SiS_Pr, unsigned short ModeNo) 99518c2ecf20Sopenharmony_ci{ 99528c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 99538c2ecf20Sopenharmony_ci unsigned short delay=0,index,myindex,temp,romptr=0; 99548c2ecf20Sopenharmony_ci bool dochiptest = true; 99558c2ecf20Sopenharmony_ci 99568c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 99578c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x20,0xbf); 99588c2ecf20Sopenharmony_ci } else { 99598c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x35,0x7f); 99608c2ecf20Sopenharmony_ci } 99618c2ecf20Sopenharmony_ci 99628c2ecf20Sopenharmony_ci /* Find delay (from ROM, internal tables, PCI subsystem) */ 99638c2ecf20Sopenharmony_ci 99648c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { /* ------------ VGA */ 99658c2ecf20Sopenharmony_ci 99668c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { 99678c2ecf20Sopenharmony_ci romptr = GetRAMDACromptr(SiS_Pr); 99688c2ecf20Sopenharmony_ci } 99698c2ecf20Sopenharmony_ci if(romptr) delay = ROMAddr[romptr]; 99708c2ecf20Sopenharmony_ci else { 99718c2ecf20Sopenharmony_ci delay = 0x04; 99728c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xB) { 99738c2ecf20Sopenharmony_ci if(IS_SIS650) { 99748c2ecf20Sopenharmony_ci delay = 0x0a; 99758c2ecf20Sopenharmony_ci } else if(IS_SIS740) { 99768c2ecf20Sopenharmony_ci delay = 0x00; 99778c2ecf20Sopenharmony_ci } else { 99788c2ecf20Sopenharmony_ci delay = 0x0c; 99798c2ecf20Sopenharmony_ci } 99808c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 99818c2ecf20Sopenharmony_ci delay = 0x00; 99828c2ecf20Sopenharmony_ci } 99838c2ecf20Sopenharmony_ci } 99848c2ecf20Sopenharmony_ci 99858c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD|SetCRT2ToLCDA)) { /* ---------- LCD/LCDA */ 99868c2ecf20Sopenharmony_ci 99878c2ecf20Sopenharmony_ci bool gotitfrompci = false; 99888c2ecf20Sopenharmony_ci 99898c2ecf20Sopenharmony_ci /* Could we detect a PDC for LCD or did we get a user-defined? If yes, use it */ 99908c2ecf20Sopenharmony_ci 99918c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 99928c2ecf20Sopenharmony_ci if(SiS_Pr->PDC != -1) { 99938c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0xf0,((SiS_Pr->PDC >> 1) & 0x0f)); 99948c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,0x7f,((SiS_Pr->PDC & 0x01) << 7)); 99958c2ecf20Sopenharmony_ci return; 99968c2ecf20Sopenharmony_ci } 99978c2ecf20Sopenharmony_ci } else { 99988c2ecf20Sopenharmony_ci if(SiS_Pr->PDCA != -1) { 99998c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,((SiS_Pr->PDCA << 3) & 0xf0)); 100008c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x20,0xbf,((SiS_Pr->PDCA & 0x01) << 6)); 100018c2ecf20Sopenharmony_ci return; 100028c2ecf20Sopenharmony_ci } 100038c2ecf20Sopenharmony_ci } 100048c2ecf20Sopenharmony_ci 100058c2ecf20Sopenharmony_ci /* Custom Panel? */ 100068c2ecf20Sopenharmony_ci 100078c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) { 100088c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 100098c2ecf20Sopenharmony_ci delay = 0x00; 100108c2ecf20Sopenharmony_ci if((SiS_Pr->PanelXRes <= 1280) && (SiS_Pr->PanelYRes <= 1024)) { 100118c2ecf20Sopenharmony_ci delay = 0x20; 100128c2ecf20Sopenharmony_ci } 100138c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,delay); 100148c2ecf20Sopenharmony_ci } else { 100158c2ecf20Sopenharmony_ci delay = 0x0c; 100168c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS301C) { 100178c2ecf20Sopenharmony_ci delay = 0x03; 100188c2ecf20Sopenharmony_ci if((SiS_Pr->PanelXRes > 1280) && (SiS_Pr->PanelYRes > 1024)) { 100198c2ecf20Sopenharmony_ci delay = 0x00; 100208c2ecf20Sopenharmony_ci } 100218c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 100228c2ecf20Sopenharmony_ci if(IS_SIS740) delay = 0x01; 100238c2ecf20Sopenharmony_ci else delay = 0x03; 100248c2ecf20Sopenharmony_ci } 100258c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0xf0,delay); 100268c2ecf20Sopenharmony_ci } 100278c2ecf20Sopenharmony_ci return; 100288c2ecf20Sopenharmony_ci } 100298c2ecf20Sopenharmony_ci 100308c2ecf20Sopenharmony_ci /* This is a piece of typical SiS crap: They code the OEM LCD 100318c2ecf20Sopenharmony_ci * delay into the code, at no defined place in the BIOS. 100328c2ecf20Sopenharmony_ci * We now have to start doing a PCI subsystem check here. 100338c2ecf20Sopenharmony_ci */ 100348c2ecf20Sopenharmony_ci 100358c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_CustomT) { 100368c2ecf20Sopenharmony_ci case CUT_COMPAQ1280: 100378c2ecf20Sopenharmony_ci case CUT_COMPAQ12802: 100388c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { 100398c2ecf20Sopenharmony_ci gotitfrompci = true; 100408c2ecf20Sopenharmony_ci dochiptest = false; 100418c2ecf20Sopenharmony_ci delay = 0x03; 100428c2ecf20Sopenharmony_ci } 100438c2ecf20Sopenharmony_ci break; 100448c2ecf20Sopenharmony_ci case CUT_CLEVO1400: 100458c2ecf20Sopenharmony_ci case CUT_CLEVO14002: 100468c2ecf20Sopenharmony_ci gotitfrompci = true; 100478c2ecf20Sopenharmony_ci dochiptest = false; 100488c2ecf20Sopenharmony_ci delay = 0x02; 100498c2ecf20Sopenharmony_ci break; 100508c2ecf20Sopenharmony_ci case CUT_CLEVO1024: 100518c2ecf20Sopenharmony_ci case CUT_CLEVO10242: 100528c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 100538c2ecf20Sopenharmony_ci gotitfrompci = true; 100548c2ecf20Sopenharmony_ci dochiptest = false; 100558c2ecf20Sopenharmony_ci delay = 0x33; 100568c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2D,delay); 100578c2ecf20Sopenharmony_ci delay &= 0x0f; 100588c2ecf20Sopenharmony_ci } 100598c2ecf20Sopenharmony_ci break; 100608c2ecf20Sopenharmony_ci } 100618c2ecf20Sopenharmony_ci 100628c2ecf20Sopenharmony_ci /* Could we find it through the PCI ID? If no, use ROM or table */ 100638c2ecf20Sopenharmony_ci 100648c2ecf20Sopenharmony_ci if(!gotitfrompci) { 100658c2ecf20Sopenharmony_ci 100668c2ecf20Sopenharmony_ci index = GetLCDPtrIndexBIOS(SiS_Pr); 100678c2ecf20Sopenharmony_ci myindex = GetLCDPtrIndex(SiS_Pr); 100688c2ecf20Sopenharmony_ci 100698c2ecf20Sopenharmony_ci if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { 100708c2ecf20Sopenharmony_ci 100718c2ecf20Sopenharmony_ci if(SiS_IsNotM650orLater(SiS_Pr)) { 100728c2ecf20Sopenharmony_ci 100738c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { 100748c2ecf20Sopenharmony_ci /* Always use the second pointer on 650; some BIOSes */ 100758c2ecf20Sopenharmony_ci /* still carry old 301 data at the first location */ 100768c2ecf20Sopenharmony_ci /* romptr = SISGETROMW(0x120); */ 100778c2ecf20Sopenharmony_ci /* if(SiS_Pr->SiS_VBType & VB_SIS302LV) */ 100788c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x122); 100798c2ecf20Sopenharmony_ci if(!romptr) return; 100808c2ecf20Sopenharmony_ci delay = ROMAddr[(romptr + index)]; 100818c2ecf20Sopenharmony_ci } else { 100828c2ecf20Sopenharmony_ci delay = SiS310_LCDDelayCompensation_650301LV[myindex]; 100838c2ecf20Sopenharmony_ci } 100848c2ecf20Sopenharmony_ci 100858c2ecf20Sopenharmony_ci } else { 100868c2ecf20Sopenharmony_ci 100878c2ecf20Sopenharmony_ci delay = SiS310_LCDDelayCompensation_651301LV[myindex]; 100888c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) 100898c2ecf20Sopenharmony_ci delay = SiS310_LCDDelayCompensation_651302LV[myindex]; 100908c2ecf20Sopenharmony_ci 100918c2ecf20Sopenharmony_ci } 100928c2ecf20Sopenharmony_ci 100938c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_UseROM && 100948c2ecf20Sopenharmony_ci (!(SiS_Pr->SiS_ROMNew)) && 100958c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) && 100968c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo != Panel_1280x768) && 100978c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo != Panel_1280x960) && 100988c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDResInfo != Panel_1600x1200) && 100998c2ecf20Sopenharmony_ci ((romptr = GetLCDromptr(SiS_Pr)))) { 101008c2ecf20Sopenharmony_ci 101018c2ecf20Sopenharmony_ci /* Data for 1280x1024 wrong in 301B BIOS */ 101028c2ecf20Sopenharmony_ci /* Data for 1600x1200 wrong in 301C BIOS */ 101038c2ecf20Sopenharmony_ci delay = ROMAddr[(romptr + index)]; 101048c2ecf20Sopenharmony_ci 101058c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 101068c2ecf20Sopenharmony_ci 101078c2ecf20Sopenharmony_ci if(IS_SIS740) delay = 0x03; 101088c2ecf20Sopenharmony_ci else delay = 0x00; 101098c2ecf20Sopenharmony_ci 101108c2ecf20Sopenharmony_ci } else { 101118c2ecf20Sopenharmony_ci 101128c2ecf20Sopenharmony_ci delay = SiS310_LCDDelayCompensation_301[myindex]; 101138c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 101148c2ecf20Sopenharmony_ci if(IS_SIS740) delay = 0x01; 101158c2ecf20Sopenharmony_ci else if(SiS_Pr->ChipType <= SIS_315PRO) delay = SiS310_LCDDelayCompensation_3xx301LV[myindex]; 101168c2ecf20Sopenharmony_ci else delay = SiS310_LCDDelayCompensation_650301LV[myindex]; 101178c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SIS301C) { 101188c2ecf20Sopenharmony_ci if(IS_SIS740) delay = 0x01; /* ? */ 101198c2ecf20Sopenharmony_ci else delay = 0x03; 101208c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) delay = 0x00; /* experience */ 101218c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBType & VB_SIS30xB) { 101228c2ecf20Sopenharmony_ci if(IS_SIS740) delay = 0x01; 101238c2ecf20Sopenharmony_ci else delay = SiS310_LCDDelayCompensation_3xx301B[myindex]; 101248c2ecf20Sopenharmony_ci } 101258c2ecf20Sopenharmony_ci 101268c2ecf20Sopenharmony_ci } 101278c2ecf20Sopenharmony_ci 101288c2ecf20Sopenharmony_ci } /* got it from PCI */ 101298c2ecf20Sopenharmony_ci 101308c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 101318c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,((delay << 4) & 0xf0)); 101328c2ecf20Sopenharmony_ci dochiptest = false; 101338c2ecf20Sopenharmony_ci } 101348c2ecf20Sopenharmony_ci 101358c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* ------------ TV */ 101368c2ecf20Sopenharmony_ci 101378c2ecf20Sopenharmony_ci index = GetTVPtrIndex(SiS_Pr); 101388c2ecf20Sopenharmony_ci 101398c2ecf20Sopenharmony_ci if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { 101408c2ecf20Sopenharmony_ci 101418c2ecf20Sopenharmony_ci if(SiS_IsNotM650orLater(SiS_Pr)) { 101428c2ecf20Sopenharmony_ci 101438c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { 101448c2ecf20Sopenharmony_ci /* Always use the second pointer on 650; some BIOSes */ 101458c2ecf20Sopenharmony_ci /* still carry old 301 data at the first location */ 101468c2ecf20Sopenharmony_ci /* romptr = SISGETROMW(0x114); */ 101478c2ecf20Sopenharmony_ci /* if(SiS_Pr->SiS_VBType & VB_SIS302LV) */ 101488c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x11a); 101498c2ecf20Sopenharmony_ci if(!romptr) return; 101508c2ecf20Sopenharmony_ci delay = ROMAddr[romptr + index]; 101518c2ecf20Sopenharmony_ci 101528c2ecf20Sopenharmony_ci } else { 101538c2ecf20Sopenharmony_ci 101548c2ecf20Sopenharmony_ci delay = SiS310_TVDelayCompensation_301B[index]; 101558c2ecf20Sopenharmony_ci 101568c2ecf20Sopenharmony_ci } 101578c2ecf20Sopenharmony_ci 101588c2ecf20Sopenharmony_ci } else { 101598c2ecf20Sopenharmony_ci 101608c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_CustomT) { 101618c2ecf20Sopenharmony_ci case CUT_COMPAQ1280: 101628c2ecf20Sopenharmony_ci case CUT_COMPAQ12802: 101638c2ecf20Sopenharmony_ci case CUT_CLEVO1400: 101648c2ecf20Sopenharmony_ci case CUT_CLEVO14002: 101658c2ecf20Sopenharmony_ci delay = 0x02; 101668c2ecf20Sopenharmony_ci dochiptest = false; 101678c2ecf20Sopenharmony_ci break; 101688c2ecf20Sopenharmony_ci case CUT_CLEVO1024: 101698c2ecf20Sopenharmony_ci case CUT_CLEVO10242: 101708c2ecf20Sopenharmony_ci delay = 0x03; 101718c2ecf20Sopenharmony_ci dochiptest = false; 101728c2ecf20Sopenharmony_ci break; 101738c2ecf20Sopenharmony_ci default: 101748c2ecf20Sopenharmony_ci delay = SiS310_TVDelayCompensation_651301LV[index]; 101758c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS302LV) { 101768c2ecf20Sopenharmony_ci delay = SiS310_TVDelayCompensation_651302LV[index]; 101778c2ecf20Sopenharmony_ci } 101788c2ecf20Sopenharmony_ci } 101798c2ecf20Sopenharmony_ci } 101808c2ecf20Sopenharmony_ci 101818c2ecf20Sopenharmony_ci } else if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { 101828c2ecf20Sopenharmony_ci 101838c2ecf20Sopenharmony_ci romptr = GetTVromptr(SiS_Pr); 101848c2ecf20Sopenharmony_ci if(!romptr) return; 101858c2ecf20Sopenharmony_ci delay = ROMAddr[romptr + index]; 101868c2ecf20Sopenharmony_ci 101878c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 101888c2ecf20Sopenharmony_ci 101898c2ecf20Sopenharmony_ci delay = SiS310_TVDelayCompensation_LVDS[index]; 101908c2ecf20Sopenharmony_ci 101918c2ecf20Sopenharmony_ci } else { 101928c2ecf20Sopenharmony_ci 101938c2ecf20Sopenharmony_ci delay = SiS310_TVDelayCompensation_301[index]; 101948c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 101958c2ecf20Sopenharmony_ci if(IS_SIS740) { 101968c2ecf20Sopenharmony_ci delay = SiS310_TVDelayCompensation_740301B[index]; 101978c2ecf20Sopenharmony_ci /* LV: use 301 data? BIOS bug? */ 101988c2ecf20Sopenharmony_ci } else { 101998c2ecf20Sopenharmony_ci delay = SiS310_TVDelayCompensation_301B[index]; 102008c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS301C) delay = 0x02; 102018c2ecf20Sopenharmony_ci } 102028c2ecf20Sopenharmony_ci } 102038c2ecf20Sopenharmony_ci 102048c2ecf20Sopenharmony_ci } 102058c2ecf20Sopenharmony_ci 102068c2ecf20Sopenharmony_ci if(SiS_LCDAEnabled(SiS_Pr)) { 102078c2ecf20Sopenharmony_ci delay &= 0x0f; 102088c2ecf20Sopenharmony_ci dochiptest = false; 102098c2ecf20Sopenharmony_ci } 102108c2ecf20Sopenharmony_ci 102118c2ecf20Sopenharmony_ci } else return; 102128c2ecf20Sopenharmony_ci 102138c2ecf20Sopenharmony_ci /* Write delay */ 102148c2ecf20Sopenharmony_ci 102158c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 102168c2ecf20Sopenharmony_ci 102178c2ecf20Sopenharmony_ci if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SISLVDS) && dochiptest) { 102188c2ecf20Sopenharmony_ci 102198c2ecf20Sopenharmony_ci temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0) >> 4; 102208c2ecf20Sopenharmony_ci if(temp == 8) { /* 1400x1050 BIOS (COMPAL) */ 102218c2ecf20Sopenharmony_ci delay &= 0x0f; 102228c2ecf20Sopenharmony_ci delay |= 0xb0; 102238c2ecf20Sopenharmony_ci } else if(temp == 6) { 102248c2ecf20Sopenharmony_ci delay &= 0x0f; 102258c2ecf20Sopenharmony_ci delay |= 0xc0; 102268c2ecf20Sopenharmony_ci } else if(temp > 7) { /* 1280x1024 BIOS (which one?) */ 102278c2ecf20Sopenharmony_ci delay = 0x35; 102288c2ecf20Sopenharmony_ci } 102298c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2D,delay); 102308c2ecf20Sopenharmony_ci 102318c2ecf20Sopenharmony_ci } else { 102328c2ecf20Sopenharmony_ci 102338c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); 102348c2ecf20Sopenharmony_ci 102358c2ecf20Sopenharmony_ci } 102368c2ecf20Sopenharmony_ci 102378c2ecf20Sopenharmony_ci } else { /* LVDS */ 102388c2ecf20Sopenharmony_ci 102398c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 102408c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); 102418c2ecf20Sopenharmony_ci } else { 102428c2ecf20Sopenharmony_ci if(IS_SIS650 && (SiS_Pr->SiS_IF_DEF_CH70xx != 0)) { 102438c2ecf20Sopenharmony_ci delay <<= 4; 102448c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,delay); 102458c2ecf20Sopenharmony_ci } else { 102468c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay); 102478c2ecf20Sopenharmony_ci } 102488c2ecf20Sopenharmony_ci } 102498c2ecf20Sopenharmony_ci 102508c2ecf20Sopenharmony_ci } 102518c2ecf20Sopenharmony_ci 102528c2ecf20Sopenharmony_ci} 102538c2ecf20Sopenharmony_ci 102548c2ecf20Sopenharmony_cistatic void 102558c2ecf20Sopenharmony_ciSetAntiFlicker(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 102568c2ecf20Sopenharmony_ci{ 102578c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 102588c2ecf20Sopenharmony_ci unsigned short index,temp,temp1,romptr=0; 102598c2ecf20Sopenharmony_ci 102608c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p|TVSetYPbPr525p)) return; 102618c2ecf20Sopenharmony_ci 102628c2ecf20Sopenharmony_ci if(ModeNo<=0x13) 102638c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex; 102648c2ecf20Sopenharmony_ci else 102658c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex; 102668c2ecf20Sopenharmony_ci 102678c2ecf20Sopenharmony_ci temp = GetTVPtrIndex(SiS_Pr); 102688c2ecf20Sopenharmony_ci temp >>= 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */ 102698c2ecf20Sopenharmony_ci temp1 = temp; 102708c2ecf20Sopenharmony_ci 102718c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { 102728c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_661) { 102738c2ecf20Sopenharmony_ci temp1 = GetOEMTVPtr661(SiS_Pr); 102748c2ecf20Sopenharmony_ci temp1 >>= 1; 102758c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x260); 102768c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_760) { 102778c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x360); 102788c2ecf20Sopenharmony_ci } 102798c2ecf20Sopenharmony_ci } else if(SiS_Pr->ChipType >= SIS_330) { 102808c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x192); 102818c2ecf20Sopenharmony_ci } else { 102828c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x112); 102838c2ecf20Sopenharmony_ci } 102848c2ecf20Sopenharmony_ci } 102858c2ecf20Sopenharmony_ci 102868c2ecf20Sopenharmony_ci if(romptr) { 102878c2ecf20Sopenharmony_ci temp1 <<= 1; 102888c2ecf20Sopenharmony_ci temp = ROMAddr[romptr + temp1 + index]; 102898c2ecf20Sopenharmony_ci } else { 102908c2ecf20Sopenharmony_ci temp = SiS310_TVAntiFlick1[temp][index]; 102918c2ecf20Sopenharmony_ci } 102928c2ecf20Sopenharmony_ci temp <<= 4; 102938c2ecf20Sopenharmony_ci 102948c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0A,0x8f,temp); /* index 0A D[6:4] */ 102958c2ecf20Sopenharmony_ci} 102968c2ecf20Sopenharmony_ci 102978c2ecf20Sopenharmony_cistatic void 102988c2ecf20Sopenharmony_ciSetEdgeEnhance(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex) 102998c2ecf20Sopenharmony_ci{ 103008c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 103018c2ecf20Sopenharmony_ci unsigned short index,temp,temp1,romptr=0; 103028c2ecf20Sopenharmony_ci 103038c2ecf20Sopenharmony_ci temp = temp1 = GetTVPtrIndex(SiS_Pr) >> 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */ 103048c2ecf20Sopenharmony_ci 103058c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) 103068c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex; 103078c2ecf20Sopenharmony_ci else 103088c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; 103098c2ecf20Sopenharmony_ci 103108c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { 103118c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_661) { 103128c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x26c); 103138c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_760) { 103148c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x36c); 103158c2ecf20Sopenharmony_ci } 103168c2ecf20Sopenharmony_ci temp1 = GetOEMTVPtr661(SiS_Pr); 103178c2ecf20Sopenharmony_ci temp1 >>= 1; 103188c2ecf20Sopenharmony_ci } else if(SiS_Pr->ChipType >= SIS_330) { 103198c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x1a4); 103208c2ecf20Sopenharmony_ci } else { 103218c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x124); 103228c2ecf20Sopenharmony_ci } 103238c2ecf20Sopenharmony_ci } 103248c2ecf20Sopenharmony_ci 103258c2ecf20Sopenharmony_ci if(romptr) { 103268c2ecf20Sopenharmony_ci temp1 <<= 1; 103278c2ecf20Sopenharmony_ci temp = ROMAddr[romptr + temp1 + index]; 103288c2ecf20Sopenharmony_ci } else { 103298c2ecf20Sopenharmony_ci temp = SiS310_TVEdge1[temp][index]; 103308c2ecf20Sopenharmony_ci } 103318c2ecf20Sopenharmony_ci temp <<= 5; 103328c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x3A,0x1F,temp); /* index 0A D[7:5] */ 103338c2ecf20Sopenharmony_ci} 103348c2ecf20Sopenharmony_ci 103358c2ecf20Sopenharmony_cistatic void 103368c2ecf20Sopenharmony_ciSetYFilter(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex) 103378c2ecf20Sopenharmony_ci{ 103388c2ecf20Sopenharmony_ci unsigned short index, temp, i, j; 103398c2ecf20Sopenharmony_ci 103408c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 103418c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex; 103428c2ecf20Sopenharmony_ci } else { 103438c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; 103448c2ecf20Sopenharmony_ci } 103458c2ecf20Sopenharmony_ci 103468c2ecf20Sopenharmony_ci temp = GetTVPtrIndex(SiS_Pr) >> 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */ 103478c2ecf20Sopenharmony_ci 103488c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) temp = 1; /* NTSC-J uses PAL */ 103498c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 3; /* PAL-M */ 103508c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetPALN) temp = 4; /* PAL-N */ 103518c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) temp = 1; /* HiVision uses PAL */ 103528c2ecf20Sopenharmony_ci 103538c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 103548c2ecf20Sopenharmony_ci for(i=0x35, j=0; i<=0x38; i++, j++) { 103558c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); 103568c2ecf20Sopenharmony_ci } 103578c2ecf20Sopenharmony_ci for(i=0x48; i<=0x4A; i++, j++) { 103588c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); 103598c2ecf20Sopenharmony_ci } 103608c2ecf20Sopenharmony_ci } else { 103618c2ecf20Sopenharmony_ci for(i=0x35, j=0; i<=0x38; i++, j++) { 103628c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter1[temp][index][j]); 103638c2ecf20Sopenharmony_ci } 103648c2ecf20Sopenharmony_ci } 103658c2ecf20Sopenharmony_ci} 103668c2ecf20Sopenharmony_ci 103678c2ecf20Sopenharmony_cistatic void 103688c2ecf20Sopenharmony_ciSetPhaseIncr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 103698c2ecf20Sopenharmony_ci{ 103708c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 103718c2ecf20Sopenharmony_ci unsigned short index,temp,i,j,resinfo,romptr=0; 103728c2ecf20Sopenharmony_ci unsigned int lindex; 103738c2ecf20Sopenharmony_ci 103748c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; 103758c2ecf20Sopenharmony_ci 103768c2ecf20Sopenharmony_ci /* NTSC-J data not in BIOS, and already set in SetGroup2 */ 103778c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) return; 103788c2ecf20Sopenharmony_ci 103798c2ecf20Sopenharmony_ci if((SiS_Pr->ChipType >= SIS_661) || SiS_Pr->SiS_ROMNew) { 103808c2ecf20Sopenharmony_ci lindex = GetOEMTVPtr661_2_OLD(SiS_Pr) & 0xffff; 103818c2ecf20Sopenharmony_ci lindex <<= 2; 103828c2ecf20Sopenharmony_ci for(j=0, i=0x31; i<=0x34; i++, j++) { 103838c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS_TVPhase[lindex + j]); 103848c2ecf20Sopenharmony_ci } 103858c2ecf20Sopenharmony_ci return; 103868c2ecf20Sopenharmony_ci } 103878c2ecf20Sopenharmony_ci 103888c2ecf20Sopenharmony_ci /* PAL-M, PAL-N not in BIOS, and already set in SetGroup2 */ 103898c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetPALM | TVSetPALN)) return; 103908c2ecf20Sopenharmony_ci 103918c2ecf20Sopenharmony_ci if(ModeNo<=0x13) { 103928c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; 103938c2ecf20Sopenharmony_ci } else { 103948c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 103958c2ecf20Sopenharmony_ci } 103968c2ecf20Sopenharmony_ci 103978c2ecf20Sopenharmony_ci temp = GetTVPtrIndex(SiS_Pr); 103988c2ecf20Sopenharmony_ci /* 0: NTSC Graphics, 1: NTSC Text, 2: PAL Graphics, 103998c2ecf20Sopenharmony_ci * 3: PAL Text, 4: HiTV Graphics 5: HiTV Text 104008c2ecf20Sopenharmony_ci */ 104018c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 104028c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x116); 104038c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_330) { 104048c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x196); 104058c2ecf20Sopenharmony_ci } 104068c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 104078c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x11c); 104088c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_330) { 104098c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x19c); 104108c2ecf20Sopenharmony_ci } 104118c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode))) { 104128c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x116); 104138c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= SIS_330) { 104148c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x196); 104158c2ecf20Sopenharmony_ci } 104168c2ecf20Sopenharmony_ci } 104178c2ecf20Sopenharmony_ci } 104188c2ecf20Sopenharmony_ci } 104198c2ecf20Sopenharmony_ci if(romptr) { 104208c2ecf20Sopenharmony_ci romptr += (temp << 2); 104218c2ecf20Sopenharmony_ci for(j=0, i=0x31; i<=0x34; i++, j++) { 104228c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); 104238c2ecf20Sopenharmony_ci } 104248c2ecf20Sopenharmony_ci } else { 104258c2ecf20Sopenharmony_ci index = temp % 2; 104268c2ecf20Sopenharmony_ci temp >>= 1; /* 0:NTSC, 1:PAL, 2:HiTV */ 104278c2ecf20Sopenharmony_ci for(j=0, i=0x31; i<=0x34; i++, j++) { 104288c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) 104298c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]); 104308c2ecf20Sopenharmony_ci else if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) 104318c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr2[temp][index][j]); 104328c2ecf20Sopenharmony_ci else 104338c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]); 104348c2ecf20Sopenharmony_ci } 104358c2ecf20Sopenharmony_ci } 104368c2ecf20Sopenharmony_ci 104378c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision))) { 104388c2ecf20Sopenharmony_ci if((!(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetYPbPr525p | TVSetYPbPr750p))) && (ModeNo > 0x13)) { 104398c2ecf20Sopenharmony_ci if((resinfo == SIS_RI_640x480) || 104408c2ecf20Sopenharmony_ci (resinfo == SIS_RI_800x600)) { 104418c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x31,0x21); 104428c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x32,0xf0); 104438c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x33,0xf5); 104448c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x34,0x7f); 104458c2ecf20Sopenharmony_ci } else if(resinfo == SIS_RI_1024x768) { 104468c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x31,0x1e); 104478c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x32,0x8b); 104488c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x33,0xfb); 104498c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x34,0x7b); 104508c2ecf20Sopenharmony_ci } 104518c2ecf20Sopenharmony_ci } 104528c2ecf20Sopenharmony_ci } 104538c2ecf20Sopenharmony_ci} 104548c2ecf20Sopenharmony_ci 104558c2ecf20Sopenharmony_cistatic void 104568c2ecf20Sopenharmony_ciSetDelayComp661(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 104578c2ecf20Sopenharmony_ci unsigned short ModeIdIndex, unsigned short RTI) 104588c2ecf20Sopenharmony_ci{ 104598c2ecf20Sopenharmony_ci unsigned short delay = 0, romptr = 0, index, lcdpdcindex; 104608c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 104618c2ecf20Sopenharmony_ci 104628c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToRAMDAC))) 104638c2ecf20Sopenharmony_ci return; 104648c2ecf20Sopenharmony_ci 104658c2ecf20Sopenharmony_ci /* 1. New ROM: VGA2 and LCD/LCDA-Pass1:1 */ 104668c2ecf20Sopenharmony_ci /* (If a custom mode is used, Pass1:1 is always set; hence we do this:) */ 104678c2ecf20Sopenharmony_ci 104688c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ROMNew) { 104698c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) || 104708c2ecf20Sopenharmony_ci ((SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) && 104718c2ecf20Sopenharmony_ci (SiS_Pr->SiS_LCDInfo & LCDPass11))) { 104728c2ecf20Sopenharmony_ci index = 25; 104738c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) { 104748c2ecf20Sopenharmony_ci index = SiS_Pr->CSRClock; 104758c2ecf20Sopenharmony_ci } else if(ModeNo > 0x13) { 104768c2ecf20Sopenharmony_ci index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RTI); 104778c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_VCLKData[index].CLOCK; 104788c2ecf20Sopenharmony_ci } 104798c2ecf20Sopenharmony_ci if(index < 25) index = 25; 104808c2ecf20Sopenharmony_ci index = ((index / 25) - 1) << 1; 104818c2ecf20Sopenharmony_ci if((ROMAddr[0x5b] & 0x80) || (SiS_Pr->SiS_VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD))) { 104828c2ecf20Sopenharmony_ci index++; 104838c2ecf20Sopenharmony_ci } 104848c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x104); 104858c2ecf20Sopenharmony_ci delay = ROMAddr[romptr + index]; 104868c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD)) { 104878c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0xf0,((delay >> 1) & 0x0f)); 104888c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,0x7f,((delay & 0x01) << 7)); 104898c2ecf20Sopenharmony_ci } else { 104908c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,((delay << 3) & 0xf0)); 104918c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x20,0xbf,((delay & 0x01) << 6)); 104928c2ecf20Sopenharmony_ci } 104938c2ecf20Sopenharmony_ci return; 104948c2ecf20Sopenharmony_ci } 104958c2ecf20Sopenharmony_ci } 104968c2ecf20Sopenharmony_ci 104978c2ecf20Sopenharmony_ci /* 2. Old ROM: VGA2 and LCD/LCDA-Pass 1:1 */ 104988c2ecf20Sopenharmony_ci 104998c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) delay = 0x04; 105008c2ecf20Sopenharmony_ci else if(ModeNo <= 0x13) delay = 0x04; 105018c2ecf20Sopenharmony_ci else delay = (SiS_Pr->SiS_RefIndex[RTI].Ext_PDC >> 4); 105028c2ecf20Sopenharmony_ci delay |= (delay << 8); 105038c2ecf20Sopenharmony_ci 105048c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType >= XGI_20) { 105058c2ecf20Sopenharmony_ci 105068c2ecf20Sopenharmony_ci delay = 0x0606; 105078c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 105088c2ecf20Sopenharmony_ci 105098c2ecf20Sopenharmony_ci delay = 0x0404; 105108c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_XGIROM) { 105118c2ecf20Sopenharmony_ci index = GetTVPtrIndex(SiS_Pr); 105128c2ecf20Sopenharmony_ci if((romptr = SISGETROMW(0x35e))) { 105138c2ecf20Sopenharmony_ci delay = (ROMAddr[romptr + index] & 0x0f) << 1; 105148c2ecf20Sopenharmony_ci delay |= (delay << 8); 105158c2ecf20Sopenharmony_ci } 105168c2ecf20Sopenharmony_ci } 105178c2ecf20Sopenharmony_ci 105188c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 105198c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == XGI_40 && SiS_Pr->ChipRevision == 0x02) { 105208c2ecf20Sopenharmony_ci delay -= 0x0404; 105218c2ecf20Sopenharmony_ci } 105228c2ecf20Sopenharmony_ci } 105238c2ecf20Sopenharmony_ci } 105248c2ecf20Sopenharmony_ci 105258c2ecf20Sopenharmony_ci } else if(SiS_Pr->ChipType >= SIS_340) { 105268c2ecf20Sopenharmony_ci 105278c2ecf20Sopenharmony_ci delay = 0x0606; 105288c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 105298c2ecf20Sopenharmony_ci delay = 0x0404; 105308c2ecf20Sopenharmony_ci } 105318c2ecf20Sopenharmony_ci /* TODO (eventually) */ 105328c2ecf20Sopenharmony_ci 105338c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 105348c2ecf20Sopenharmony_ci 105358c2ecf20Sopenharmony_ci /* 3. TV */ 105368c2ecf20Sopenharmony_ci 105378c2ecf20Sopenharmony_ci index = GetOEMTVPtr661(SiS_Pr); 105388c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ROMNew) { 105398c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x106); 105408c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_UMC) romptr += 12; 105418c2ecf20Sopenharmony_ci delay = ROMAddr[romptr + index]; 105428c2ecf20Sopenharmony_ci } else { 105438c2ecf20Sopenharmony_ci delay = 0x04; 105448c2ecf20Sopenharmony_ci if(index > 3) delay = 0; 105458c2ecf20Sopenharmony_ci } 105468c2ecf20Sopenharmony_ci 105478c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 105488c2ecf20Sopenharmony_ci 105498c2ecf20Sopenharmony_ci /* 4. LCD, LCDA (for new ROM only LV and non-Pass 1:1) */ 105508c2ecf20Sopenharmony_ci 105518c2ecf20Sopenharmony_ci if( (SiS_Pr->SiS_LCDResInfo != Panel_Custom) && 105528c2ecf20Sopenharmony_ci ((romptr = GetLCDStructPtr661_2(SiS_Pr))) ) { 105538c2ecf20Sopenharmony_ci 105548c2ecf20Sopenharmony_ci lcdpdcindex = (SiS_Pr->SiS_VBType & VB_UMC) ? 14 : 12; 105558c2ecf20Sopenharmony_ci 105568c2ecf20Sopenharmony_ci /* For LVDS (and sometimes TMDS), the BIOS must know about the correct value */ 105578c2ecf20Sopenharmony_ci delay = ROMAddr[romptr + lcdpdcindex + 1]; /* LCD */ 105588c2ecf20Sopenharmony_ci delay |= (ROMAddr[romptr + lcdpdcindex] << 8); /* LCDA */ 105598c2ecf20Sopenharmony_ci 105608c2ecf20Sopenharmony_ci } else { 105618c2ecf20Sopenharmony_ci 105628c2ecf20Sopenharmony_ci /* TMDS: Set our own, since BIOS has no idea */ 105638c2ecf20Sopenharmony_ci /* (This is done on >=661 only, since <661 is calling this only for LVDS) */ 105648c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 105658c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_LCDResInfo) { 105668c2ecf20Sopenharmony_ci case Panel_1024x768: delay = 0x0008; break; 105678c2ecf20Sopenharmony_ci case Panel_1280x720: delay = 0x0004; break; 105688c2ecf20Sopenharmony_ci case Panel_1280x768: 105698c2ecf20Sopenharmony_ci case Panel_1280x768_2:delay = 0x0004; break; 105708c2ecf20Sopenharmony_ci case Panel_1280x800: 105718c2ecf20Sopenharmony_ci case Panel_1280x800_2:delay = 0x0004; break; /* Verified for 1280x800 */ 105728c2ecf20Sopenharmony_ci case Panel_1280x854: delay = 0x0004; break; /* FIXME */ 105738c2ecf20Sopenharmony_ci case Panel_1280x1024: delay = 0x1e04; break; 105748c2ecf20Sopenharmony_ci case Panel_1400x1050: delay = 0x0004; break; 105758c2ecf20Sopenharmony_ci case Panel_1600x1200: delay = 0x0400; break; 105768c2ecf20Sopenharmony_ci case Panel_1680x1050: delay = 0x0e04; break; 105778c2ecf20Sopenharmony_ci default: 105788c2ecf20Sopenharmony_ci if((SiS_Pr->PanelXRes <= 1024) && (SiS_Pr->PanelYRes <= 768)) { 105798c2ecf20Sopenharmony_ci delay = 0x0008; 105808c2ecf20Sopenharmony_ci } else if((SiS_Pr->PanelXRes == 1280) && (SiS_Pr->PanelYRes == 1024)) { 105818c2ecf20Sopenharmony_ci delay = 0x1e04; 105828c2ecf20Sopenharmony_ci } else if((SiS_Pr->PanelXRes <= 1400) && (SiS_Pr->PanelYRes <= 1050)) { 105838c2ecf20Sopenharmony_ci delay = 0x0004; 105848c2ecf20Sopenharmony_ci } else if((SiS_Pr->PanelXRes <= 1600) && (SiS_Pr->PanelYRes <= 1200)) { 105858c2ecf20Sopenharmony_ci delay = 0x0400; 105868c2ecf20Sopenharmony_ci } else 105878c2ecf20Sopenharmony_ci delay = 0x0e04; 105888c2ecf20Sopenharmony_ci break; 105898c2ecf20Sopenharmony_ci } 105908c2ecf20Sopenharmony_ci } 105918c2ecf20Sopenharmony_ci 105928c2ecf20Sopenharmony_ci /* Override by detected or user-set values */ 105938c2ecf20Sopenharmony_ci /* (but only if, for some reason, we can't read value from BIOS) */ 105948c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->PDC != -1)) { 105958c2ecf20Sopenharmony_ci delay = SiS_Pr->PDC & 0x1f; 105968c2ecf20Sopenharmony_ci } 105978c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) && (SiS_Pr->PDCA != -1)) { 105988c2ecf20Sopenharmony_ci delay = (SiS_Pr->PDCA & 0x1f) << 8; 105998c2ecf20Sopenharmony_ci } 106008c2ecf20Sopenharmony_ci 106018c2ecf20Sopenharmony_ci } 106028c2ecf20Sopenharmony_ci 106038c2ecf20Sopenharmony_ci } 106048c2ecf20Sopenharmony_ci 106058c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 106068c2ecf20Sopenharmony_ci delay >>= 8; 106078c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,((delay << 3) & 0xf0)); 106088c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x20,0xbf,((delay & 0x01) << 6)); 106098c2ecf20Sopenharmony_ci } else { 106108c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0xf0,((delay >> 1) & 0x0f)); 106118c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,0x7f,((delay & 0x01) << 7)); 106128c2ecf20Sopenharmony_ci } 106138c2ecf20Sopenharmony_ci} 106148c2ecf20Sopenharmony_ci 106158c2ecf20Sopenharmony_cistatic void 106168c2ecf20Sopenharmony_ciSetCRT2SyncDither661(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short RTI) 106178c2ecf20Sopenharmony_ci{ 106188c2ecf20Sopenharmony_ci unsigned short infoflag; 106198c2ecf20Sopenharmony_ci unsigned char temp; 106208c2ecf20Sopenharmony_ci 106218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 106228c2ecf20Sopenharmony_ci 106238c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 106248c2ecf20Sopenharmony_ci infoflag = SiS_GetRegByte(SiS_Pr->SiS_P3ca+2); 106258c2ecf20Sopenharmony_ci } else if(SiS_Pr->UseCustomMode) { 106268c2ecf20Sopenharmony_ci infoflag = SiS_Pr->CInfoFlag; 106278c2ecf20Sopenharmony_ci } else { 106288c2ecf20Sopenharmony_ci infoflag = SiS_Pr->SiS_RefIndex[RTI].Ext_InfoFlag; 106298c2ecf20Sopenharmony_ci } 106308c2ecf20Sopenharmony_ci 106318c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 106328c2ecf20Sopenharmony_ci infoflag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); /* No longer check D5 */ 106338c2ecf20Sopenharmony_ci } 106348c2ecf20Sopenharmony_ci 106358c2ecf20Sopenharmony_ci infoflag &= 0xc0; 106368c2ecf20Sopenharmony_ci 106378c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 106388c2ecf20Sopenharmony_ci temp = (infoflag >> 6) | 0x0c; 106398c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { 106408c2ecf20Sopenharmony_ci temp ^= 0x04; 106418c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType >= Mode24Bpp) temp |= 0x10; 106428c2ecf20Sopenharmony_ci } 106438c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xe0,temp); 106448c2ecf20Sopenharmony_ci } else { 106458c2ecf20Sopenharmony_ci temp = 0x30; 106468c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) temp = 0x20; 106478c2ecf20Sopenharmony_ci temp |= infoflag; 106488c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0f,temp); 106498c2ecf20Sopenharmony_ci temp = 0; 106508c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { 106518c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ModeType >= Mode24Bpp) temp |= 0x80; 106528c2ecf20Sopenharmony_ci } 106538c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1a,0x7f,temp); 106548c2ecf20Sopenharmony_ci } 106558c2ecf20Sopenharmony_ci 106568c2ecf20Sopenharmony_ci } 106578c2ecf20Sopenharmony_ci} 106588c2ecf20Sopenharmony_ci 106598c2ecf20Sopenharmony_cistatic void 106608c2ecf20Sopenharmony_ciSetPanelParms661(struct SiS_Private *SiS_Pr) 106618c2ecf20Sopenharmony_ci{ 106628c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 106638c2ecf20Sopenharmony_ci unsigned short romptr, temp1, temp2; 106648c2ecf20Sopenharmony_ci 106658c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & (VB_SISLVDS | VB_SIS30xC)) { 106668c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x24,0x0f); 106678c2ecf20Sopenharmony_ci } 106688c2ecf20Sopenharmony_ci 106698c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 106708c2ecf20Sopenharmony_ci if(SiS_Pr->LVDSHL != -1) { 106718c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,SiS_Pr->LVDSHL); 106728c2ecf20Sopenharmony_ci } 106738c2ecf20Sopenharmony_ci } 106748c2ecf20Sopenharmony_ci 106758c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ROMNew) { 106768c2ecf20Sopenharmony_ci 106778c2ecf20Sopenharmony_ci if((romptr = GetLCDStructPtr661_2(SiS_Pr))) { 106788c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 106798c2ecf20Sopenharmony_ci temp1 = (ROMAddr[romptr] & 0x03) | 0x0c; 106808c2ecf20Sopenharmony_ci temp2 = 0xfc; 106818c2ecf20Sopenharmony_ci if(SiS_Pr->LVDSHL != -1) { 106828c2ecf20Sopenharmony_ci temp1 &= 0xfc; 106838c2ecf20Sopenharmony_ci temp2 = 0xf3; 106848c2ecf20Sopenharmony_ci } 106858c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,temp2,temp1); 106868c2ecf20Sopenharmony_ci } 106878c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 106888c2ecf20Sopenharmony_ci temp1 = (ROMAddr[romptr + 1] & 0x80) >> 1; 106898c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0d,0xbf,temp1); 106908c2ecf20Sopenharmony_ci } 106918c2ecf20Sopenharmony_ci } 106928c2ecf20Sopenharmony_ci 106938c2ecf20Sopenharmony_ci } 106948c2ecf20Sopenharmony_ci} 106958c2ecf20Sopenharmony_ci 106968c2ecf20Sopenharmony_cistatic void 106978c2ecf20Sopenharmony_ciSiS_OEM310Setting(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RRTI) 106988c2ecf20Sopenharmony_ci{ 106998c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_ROMNew) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { 107008c2ecf20Sopenharmony_ci SetDelayComp661(SiS_Pr, ModeNo, ModeIdIndex, RRTI); 107018c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 107028c2ecf20Sopenharmony_ci SetCRT2SyncDither661(SiS_Pr, ModeNo, RRTI); 107038c2ecf20Sopenharmony_ci SetPanelParms661(SiS_Pr); 107048c2ecf20Sopenharmony_ci } 107058c2ecf20Sopenharmony_ci } else { 107068c2ecf20Sopenharmony_ci SetDelayComp(SiS_Pr,ModeNo); 107078c2ecf20Sopenharmony_ci } 107088c2ecf20Sopenharmony_ci 107098c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { 107108c2ecf20Sopenharmony_ci SetAntiFlicker(SiS_Pr,ModeNo,ModeIdIndex); 107118c2ecf20Sopenharmony_ci SetPhaseIncr(SiS_Pr,ModeNo,ModeIdIndex); 107128c2ecf20Sopenharmony_ci SetYFilter(SiS_Pr,ModeNo,ModeIdIndex); 107138c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS301) { 107148c2ecf20Sopenharmony_ci SetEdgeEnhance(SiS_Pr,ModeNo,ModeIdIndex); 107158c2ecf20Sopenharmony_ci } 107168c2ecf20Sopenharmony_ci } 107178c2ecf20Sopenharmony_ci} 107188c2ecf20Sopenharmony_ci 107198c2ecf20Sopenharmony_cistatic void 107208c2ecf20Sopenharmony_ciSiS_OEM661Setting(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 107218c2ecf20Sopenharmony_ci unsigned short ModeIdIndex, unsigned short RRTI) 107228c2ecf20Sopenharmony_ci{ 107238c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 107248c2ecf20Sopenharmony_ci 107258c2ecf20Sopenharmony_ci SetDelayComp661(SiS_Pr, ModeNo, ModeIdIndex, RRTI); 107268c2ecf20Sopenharmony_ci 107278c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 107288c2ecf20Sopenharmony_ci SetCRT2SyncDither661(SiS_Pr, ModeNo, RRTI); 107298c2ecf20Sopenharmony_ci SetPanelParms661(SiS_Pr); 107308c2ecf20Sopenharmony_ci } 107318c2ecf20Sopenharmony_ci 107328c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 107338c2ecf20Sopenharmony_ci SetPhaseIncr(SiS_Pr, ModeNo, ModeIdIndex); 107348c2ecf20Sopenharmony_ci SetYFilter(SiS_Pr, ModeNo, ModeIdIndex); 107358c2ecf20Sopenharmony_ci SetAntiFlicker(SiS_Pr, ModeNo, ModeIdIndex); 107368c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS301) { 107378c2ecf20Sopenharmony_ci SetEdgeEnhance(SiS_Pr, ModeNo, ModeIdIndex); 107388c2ecf20Sopenharmony_ci } 107398c2ecf20Sopenharmony_ci } 107408c2ecf20Sopenharmony_ci } 107418c2ecf20Sopenharmony_ci} 107428c2ecf20Sopenharmony_ci 107438c2ecf20Sopenharmony_ci/* FinalizeLCD 107448c2ecf20Sopenharmony_ci * This finalizes some CRT2 registers for the very panel used. 107458c2ecf20Sopenharmony_ci * If we have a backup if these registers, we use it; otherwise 107468c2ecf20Sopenharmony_ci * we set the register according to most BIOSes. However, this 107478c2ecf20Sopenharmony_ci * function looks quite different in every BIOS, so you better 107488c2ecf20Sopenharmony_ci * pray that we have a backup... 107498c2ecf20Sopenharmony_ci */ 107508c2ecf20Sopenharmony_cistatic void 107518c2ecf20Sopenharmony_ciSiS_FinalizeLCD(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 107528c2ecf20Sopenharmony_ci{ 107538c2ecf20Sopenharmony_ci unsigned short tempcl,tempch,tempbl,tempbh,tempbx,tempax,temp; 107548c2ecf20Sopenharmony_ci unsigned short resinfo,modeflag; 107558c2ecf20Sopenharmony_ci 107568c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBType & VB_SISLVDS)) return; 107578c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_ROMNew) return; 107588c2ecf20Sopenharmony_ci 107598c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 107608c2ecf20Sopenharmony_ci if(SiS_Pr->LVDSHL != -1) { 107618c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,SiS_Pr->LVDSHL); 107628c2ecf20Sopenharmony_ci } 107638c2ecf20Sopenharmony_ci } 107648c2ecf20Sopenharmony_ci 107658c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) return; 107668c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) return; 107678c2ecf20Sopenharmony_ci 107688c2ecf20Sopenharmony_ci switch(SiS_Pr->SiS_CustomT) { 107698c2ecf20Sopenharmony_ci case CUT_COMPAQ1280: 107708c2ecf20Sopenharmony_ci case CUT_COMPAQ12802: 107718c2ecf20Sopenharmony_ci case CUT_CLEVO1400: 107728c2ecf20Sopenharmony_ci case CUT_CLEVO14002: 107738c2ecf20Sopenharmony_ci return; 107748c2ecf20Sopenharmony_ci } 107758c2ecf20Sopenharmony_ci 107768c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 107778c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; 107788c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 107798c2ecf20Sopenharmony_ci } else { 107808c2ecf20Sopenharmony_ci resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 107818c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 107828c2ecf20Sopenharmony_ci } 107838c2ecf20Sopenharmony_ci 107848c2ecf20Sopenharmony_ci if(IS_SIS650) { 107858c2ecf20Sopenharmony_ci if(!(SiS_GetReg(SiS_Pr->SiS_P3d4, 0x5f) & 0xf0)) { 107868c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { 107878c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x02); 107888c2ecf20Sopenharmony_ci } else { 107898c2ecf20Sopenharmony_ci SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x03); 107908c2ecf20Sopenharmony_ci } 107918c2ecf20Sopenharmony_ci } 107928c2ecf20Sopenharmony_ci } 107938c2ecf20Sopenharmony_ci 107948c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) { 107958c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 107968c2ecf20Sopenharmony_ci /* Maybe all panels? */ 107978c2ecf20Sopenharmony_ci if(SiS_Pr->LVDSHL == -1) { 107988c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01); 107998c2ecf20Sopenharmony_ci } 108008c2ecf20Sopenharmony_ci return; 108018c2ecf20Sopenharmony_ci } 108028c2ecf20Sopenharmony_ci } 108038c2ecf20Sopenharmony_ci 108048c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_CLEVO10242) { 108058c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 108068c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 108078c2ecf20Sopenharmony_ci if(SiS_Pr->LVDSHL == -1) { 108088c2ecf20Sopenharmony_ci /* Maybe all panels? */ 108098c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01); 108108c2ecf20Sopenharmony_ci } 108118c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 108128c2ecf20Sopenharmony_ci tempch = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4; 108138c2ecf20Sopenharmony_ci if(tempch == 3) { 108148c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); 108158c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x25); 108168c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,0x00); 108178c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x1b); 108188c2ecf20Sopenharmony_ci } 108198c2ecf20Sopenharmony_ci } 108208c2ecf20Sopenharmony_ci return; 108218c2ecf20Sopenharmony_ci } 108228c2ecf20Sopenharmony_ci } 108238c2ecf20Sopenharmony_ci } 108248c2ecf20Sopenharmony_ci 108258c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 108268c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 108278c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISEMI) { 108288c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); 108298c2ecf20Sopenharmony_ci#ifdef SET_EMI 108308c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); 108318c2ecf20Sopenharmony_ci#endif 108328c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); 108338c2ecf20Sopenharmony_ci } 108348c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { 108358c2ecf20Sopenharmony_ci if(SiS_Pr->LVDSHL == -1) { 108368c2ecf20Sopenharmony_ci /* Maybe ACER only? */ 108378c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01); 108388c2ecf20Sopenharmony_ci } 108398c2ecf20Sopenharmony_ci } 108408c2ecf20Sopenharmony_ci tempch = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4; 108418c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 108428c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) { 108438c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1f,0x76); 108448c2ecf20Sopenharmony_ci } else if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 108458c2ecf20Sopenharmony_ci if(tempch == 0x03) { 108468c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); 108478c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x25); 108488c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,0x00); 108498c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x1b); 108508c2ecf20Sopenharmony_ci } 108518c2ecf20Sopenharmony_ci if(SiS_Pr->Backup && (SiS_Pr->Backup_Mode == ModeNo)) { 108528c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,SiS_Pr->Backup_14); 108538c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,SiS_Pr->Backup_15); 108548c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,SiS_Pr->Backup_16); 108558c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,SiS_Pr->Backup_17); 108568c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,SiS_Pr->Backup_18); 108578c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,SiS_Pr->Backup_19); 108588c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1a,SiS_Pr->Backup_1a); 108598c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,SiS_Pr->Backup_1b); 108608c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,SiS_Pr->Backup_1c); 108618c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,SiS_Pr->Backup_1d); 108628c2ecf20Sopenharmony_ci } else if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { /* 1.10.8w */ 108638c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,0x90); 108648c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 108658c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x11); 108668c2ecf20Sopenharmony_ci if((resinfo == 0) || (resinfo == 2)) return; 108678c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x18); 108688c2ecf20Sopenharmony_ci if((resinfo == 1) || (resinfo == 3)) return; 108698c2ecf20Sopenharmony_ci } 108708c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); 108718c2ecf20Sopenharmony_ci if((ModeNo > 0x13) && (resinfo == SIS_RI_1024x768)) { 108728c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); /* 1.10.7u */ 108738c2ecf20Sopenharmony_ci#if 0 108748c2ecf20Sopenharmony_ci tempbx = 806; /* 0x326 */ /* other older BIOSes */ 108758c2ecf20Sopenharmony_ci tempbx--; 108768c2ecf20Sopenharmony_ci temp = tempbx & 0xff; 108778c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); 108788c2ecf20Sopenharmony_ci temp = (tempbx >> 8) & 0x03; 108798c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1d,0xf8,temp); 108808c2ecf20Sopenharmony_ci#endif 108818c2ecf20Sopenharmony_ci } 108828c2ecf20Sopenharmony_ci } else if(ModeNo <= 0x13) { 108838c2ecf20Sopenharmony_ci if(ModeNo <= 1) { 108848c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x70); 108858c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0xff); 108868c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x48); 108878c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x12); 108888c2ecf20Sopenharmony_ci } 108898c2ecf20Sopenharmony_ci if(!(modeflag & HalfDCLK)) { 108908c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,0x20); 108918c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,0x1a); 108928c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,0x28); 108938c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,0x00); 108948c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x4c); 108958c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0xdc); 108968c2ecf20Sopenharmony_ci if(ModeNo == 0x12) { 108978c2ecf20Sopenharmony_ci switch(tempch) { 108988c2ecf20Sopenharmony_ci case 0: 108998c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x95); 109008c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0xdc); 109018c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1a,0x10); 109028c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x95); 109038c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,0x48); 109048c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x12); 109058c2ecf20Sopenharmony_ci break; 109068c2ecf20Sopenharmony_ci case 2: 109078c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x95); 109088c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x48); 109098c2ecf20Sopenharmony_ci break; 109108c2ecf20Sopenharmony_ci case 3: 109118c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x95); 109128c2ecf20Sopenharmony_ci break; 109138c2ecf20Sopenharmony_ci } 109148c2ecf20Sopenharmony_ci } 109158c2ecf20Sopenharmony_ci } 109168c2ecf20Sopenharmony_ci } 109178c2ecf20Sopenharmony_ci } 109188c2ecf20Sopenharmony_ci } else { 109198c2ecf20Sopenharmony_ci tempcl = tempbh = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x01); 109208c2ecf20Sopenharmony_ci tempcl &= 0x0f; 109218c2ecf20Sopenharmony_ci tempbh &= 0x70; 109228c2ecf20Sopenharmony_ci tempbh >>= 4; 109238c2ecf20Sopenharmony_ci tempbl = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x04); 109248c2ecf20Sopenharmony_ci tempbx = (tempbh << 8) | tempbl; 109258c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 109268c2ecf20Sopenharmony_ci if((resinfo == SIS_RI_1024x768) || (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD))) { 109278c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { 109288c2ecf20Sopenharmony_ci tempbx = 770; 109298c2ecf20Sopenharmony_ci } else { 109308c2ecf20Sopenharmony_ci if(tempbx > 770) tempbx = 770; 109318c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE < 600) { 109328c2ecf20Sopenharmony_ci tempax = 768 - SiS_Pr->SiS_VGAVDE; 109338c2ecf20Sopenharmony_ci tempax >>= 4; /* 1.10.7w; 1.10.6s: 3; */ 109348c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VGAVDE <= 480) tempax >>= 4; /* 1.10.7w; 1.10.6s: < 480; >>=1; */ 109358c2ecf20Sopenharmony_ci tempbx -= tempax; 109368c2ecf20Sopenharmony_ci } 109378c2ecf20Sopenharmony_ci } 109388c2ecf20Sopenharmony_ci } else return; 109398c2ecf20Sopenharmony_ci } 109408c2ecf20Sopenharmony_ci temp = tempbx & 0xff; 109418c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,temp); 109428c2ecf20Sopenharmony_ci temp = ((tempbx & 0xff00) >> 4) | tempcl; 109438c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,temp); 109448c2ecf20Sopenharmony_ci } 109458c2ecf20Sopenharmony_ci } 109468c2ecf20Sopenharmony_ci} 109478c2ecf20Sopenharmony_ci 109488c2ecf20Sopenharmony_ci#endif 109498c2ecf20Sopenharmony_ci 109508c2ecf20Sopenharmony_ci/* ================= SiS 300 O.E.M. ================== */ 109518c2ecf20Sopenharmony_ci 109528c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_SIS_300 109538c2ecf20Sopenharmony_ci 109548c2ecf20Sopenharmony_cistatic void 109558c2ecf20Sopenharmony_ciSetOEMLCDData2(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex, 109568c2ecf20Sopenharmony_ci unsigned short RefTabIndex) 109578c2ecf20Sopenharmony_ci{ 109588c2ecf20Sopenharmony_ci unsigned short crt2crtc=0, modeflag, myindex=0; 109598c2ecf20Sopenharmony_ci unsigned char temp; 109608c2ecf20Sopenharmony_ci int i; 109618c2ecf20Sopenharmony_ci 109628c2ecf20Sopenharmony_ci if(ModeNo <= 0x13) { 109638c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 109648c2ecf20Sopenharmony_ci crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 109658c2ecf20Sopenharmony_ci } else { 109668c2ecf20Sopenharmony_ci modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 109678c2ecf20Sopenharmony_ci crt2crtc = SiS_Pr->SiS_RefIndex[RefTabIndex].Ext_CRT2CRTC; 109688c2ecf20Sopenharmony_ci } 109698c2ecf20Sopenharmony_ci 109708c2ecf20Sopenharmony_ci crt2crtc &= 0x3f; 109718c2ecf20Sopenharmony_ci 109728c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { 109738c2ecf20Sopenharmony_ci SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xdf); 109748c2ecf20Sopenharmony_ci } 109758c2ecf20Sopenharmony_ci 109768c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { 109778c2ecf20Sopenharmony_ci if(modeflag & HalfDCLK) myindex = 1; 109788c2ecf20Sopenharmony_ci 109798c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_SetFlag & LowModeTests) { 109808c2ecf20Sopenharmony_ci for(i=0; i<7; i++) { 109818c2ecf20Sopenharmony_ci if(barco_p1[myindex][crt2crtc][i][0]) { 109828c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port, 109838c2ecf20Sopenharmony_ci barco_p1[myindex][crt2crtc][i][0], 109848c2ecf20Sopenharmony_ci barco_p1[myindex][crt2crtc][i][2], 109858c2ecf20Sopenharmony_ci barco_p1[myindex][crt2crtc][i][1]); 109868c2ecf20Sopenharmony_ci } 109878c2ecf20Sopenharmony_ci } 109888c2ecf20Sopenharmony_ci } 109898c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); 109908c2ecf20Sopenharmony_ci if(temp & 0x80) { 109918c2ecf20Sopenharmony_ci temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x18); 109928c2ecf20Sopenharmony_ci temp++; 109938c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); 109948c2ecf20Sopenharmony_ci } 109958c2ecf20Sopenharmony_ci } 109968c2ecf20Sopenharmony_ci} 109978c2ecf20Sopenharmony_ci 109988c2ecf20Sopenharmony_cistatic unsigned short 109998c2ecf20Sopenharmony_ciGetOEMLCDPtr(struct SiS_Private *SiS_Pr, int Flag) 110008c2ecf20Sopenharmony_ci{ 110018c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 110028c2ecf20Sopenharmony_ci unsigned short tempbx=0,romptr=0; 110038c2ecf20Sopenharmony_ci static const unsigned char customtable300[] = { 110048c2ecf20Sopenharmony_ci 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 110058c2ecf20Sopenharmony_ci 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff 110068c2ecf20Sopenharmony_ci }; 110078c2ecf20Sopenharmony_ci static const unsigned char customtable630[] = { 110088c2ecf20Sopenharmony_ci 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 110098c2ecf20Sopenharmony_ci 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff 110108c2ecf20Sopenharmony_ci }; 110118c2ecf20Sopenharmony_ci 110128c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType == SIS_300) { 110138c2ecf20Sopenharmony_ci 110148c2ecf20Sopenharmony_ci tempbx = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0x0f; 110158c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS301) tempbx &= 0x07; 110168c2ecf20Sopenharmony_ci tempbx -= 2; 110178c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx += 4; 110188c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 110198c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 3; 110208c2ecf20Sopenharmony_ci } 110218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 110228c2ecf20Sopenharmony_ci if(ROMAddr[0x235] & 0x80) { 110238c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_LCDTypeInfo; 110248c2ecf20Sopenharmony_ci if(Flag) { 110258c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x255); 110268c2ecf20Sopenharmony_ci if(romptr) tempbx = ROMAddr[romptr + SiS_Pr->SiS_LCDTypeInfo]; 110278c2ecf20Sopenharmony_ci else tempbx = customtable300[SiS_Pr->SiS_LCDTypeInfo]; 110288c2ecf20Sopenharmony_ci if(tempbx == 0xFF) return 0xFFFF; 110298c2ecf20Sopenharmony_ci } 110308c2ecf20Sopenharmony_ci tempbx <<= 1; 110318c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++; 110328c2ecf20Sopenharmony_ci } 110338c2ecf20Sopenharmony_ci } 110348c2ecf20Sopenharmony_ci 110358c2ecf20Sopenharmony_ci } else { 110368c2ecf20Sopenharmony_ci 110378c2ecf20Sopenharmony_ci if(Flag) { 110388c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 110398c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x255); 110408c2ecf20Sopenharmony_ci if(romptr) tempbx = ROMAddr[romptr + SiS_Pr->SiS_LCDTypeInfo]; 110418c2ecf20Sopenharmony_ci else tempbx = 0xff; 110428c2ecf20Sopenharmony_ci } else { 110438c2ecf20Sopenharmony_ci tempbx = customtable630[SiS_Pr->SiS_LCDTypeInfo]; 110448c2ecf20Sopenharmony_ci } 110458c2ecf20Sopenharmony_ci if(tempbx == 0xFF) return 0xFFFF; 110468c2ecf20Sopenharmony_ci tempbx <<= 2; 110478c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempbx += 2; 110488c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; 110498c2ecf20Sopenharmony_ci return tempbx; 110508c2ecf20Sopenharmony_ci } 110518c2ecf20Sopenharmony_ci tempbx = SiS_Pr->SiS_LCDTypeInfo << 2; 110528c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempbx += 2; 110538c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; 110548c2ecf20Sopenharmony_ci 110558c2ecf20Sopenharmony_ci } 110568c2ecf20Sopenharmony_ci 110578c2ecf20Sopenharmony_ci return tempbx; 110588c2ecf20Sopenharmony_ci} 110598c2ecf20Sopenharmony_ci 110608c2ecf20Sopenharmony_cistatic void 110618c2ecf20Sopenharmony_ciSetOEMLCDDelay(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex) 110628c2ecf20Sopenharmony_ci{ 110638c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 110648c2ecf20Sopenharmony_ci unsigned short index,temp,romptr=0; 110658c2ecf20Sopenharmony_ci 110668c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) return; 110678c2ecf20Sopenharmony_ci 110688c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 110698c2ecf20Sopenharmony_ci if(!(ROMAddr[0x237] & 0x01)) return; 110708c2ecf20Sopenharmony_ci if(!(ROMAddr[0x237] & 0x02)) return; 110718c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x24b); 110728c2ecf20Sopenharmony_ci } 110738c2ecf20Sopenharmony_ci 110748c2ecf20Sopenharmony_ci /* The Panel Compensation Delay should be set according to tables 110758c2ecf20Sopenharmony_ci * here. Unfortunately, various BIOS versions don't care about 110768c2ecf20Sopenharmony_ci * a uniform way using eg. ROM byte 0x220, but use different 110778c2ecf20Sopenharmony_ci * hard coded delays (0x04, 0x20, 0x18) in SetGroup1(). 110788c2ecf20Sopenharmony_ci * Thus we don't set this if the user selected a custom pdc or if 110798c2ecf20Sopenharmony_ci * we otherwise detected a valid pdc. 110808c2ecf20Sopenharmony_ci */ 110818c2ecf20Sopenharmony_ci if(SiS_Pr->PDC != -1) return; 110828c2ecf20Sopenharmony_ci 110838c2ecf20Sopenharmony_ci temp = GetOEMLCDPtr(SiS_Pr, 0); 110848c2ecf20Sopenharmony_ci 110858c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) 110868c2ecf20Sopenharmony_ci index = 0; 110878c2ecf20Sopenharmony_ci else 110888c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex; 110898c2ecf20Sopenharmony_ci 110908c2ecf20Sopenharmony_ci if(SiS_Pr->ChipType != SIS_300) { 110918c2ecf20Sopenharmony_ci if(romptr) { 110928c2ecf20Sopenharmony_ci romptr += (temp * 2); 110938c2ecf20Sopenharmony_ci romptr = SISGETROMW(romptr); 110948c2ecf20Sopenharmony_ci romptr += index; 110958c2ecf20Sopenharmony_ci temp = ROMAddr[romptr]; 110968c2ecf20Sopenharmony_ci } else { 110978c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 110988c2ecf20Sopenharmony_ci temp = SiS300_OEMLCDDelay2[temp][index]; 110998c2ecf20Sopenharmony_ci } else { 111008c2ecf20Sopenharmony_ci temp = SiS300_OEMLCDDelay3[temp][index]; 111018c2ecf20Sopenharmony_ci } 111028c2ecf20Sopenharmony_ci } 111038c2ecf20Sopenharmony_ci } else { 111048c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM && (ROMAddr[0x235] & 0x80)) { 111058c2ecf20Sopenharmony_ci if(romptr) { 111068c2ecf20Sopenharmony_ci romptr += (temp * 2); 111078c2ecf20Sopenharmony_ci romptr = SISGETROMW(romptr); 111088c2ecf20Sopenharmony_ci romptr += index; 111098c2ecf20Sopenharmony_ci temp = ROMAddr[romptr]; 111108c2ecf20Sopenharmony_ci } else { 111118c2ecf20Sopenharmony_ci temp = SiS300_OEMLCDDelay5[temp][index]; 111128c2ecf20Sopenharmony_ci } 111138c2ecf20Sopenharmony_ci } else { 111148c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 111158c2ecf20Sopenharmony_ci romptr = ROMAddr[0x249] | (ROMAddr[0x24a] << 8); 111168c2ecf20Sopenharmony_ci if(romptr) { 111178c2ecf20Sopenharmony_ci romptr += (temp * 2); 111188c2ecf20Sopenharmony_ci romptr = SISGETROMW(romptr); 111198c2ecf20Sopenharmony_ci romptr += index; 111208c2ecf20Sopenharmony_ci temp = ROMAddr[romptr]; 111218c2ecf20Sopenharmony_ci } else { 111228c2ecf20Sopenharmony_ci temp = SiS300_OEMLCDDelay4[temp][index]; 111238c2ecf20Sopenharmony_ci } 111248c2ecf20Sopenharmony_ci } else { 111258c2ecf20Sopenharmony_ci temp = SiS300_OEMLCDDelay4[temp][index]; 111268c2ecf20Sopenharmony_ci } 111278c2ecf20Sopenharmony_ci } 111288c2ecf20Sopenharmony_ci } 111298c2ecf20Sopenharmony_ci temp &= 0x3c; 111308c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* index 0A D[6:4] */ 111318c2ecf20Sopenharmony_ci} 111328c2ecf20Sopenharmony_ci 111338c2ecf20Sopenharmony_cistatic void 111348c2ecf20Sopenharmony_ciSetOEMLCDData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 111358c2ecf20Sopenharmony_ci{ 111368c2ecf20Sopenharmony_ci#if 0 /* Unfinished; Data table missing */ 111378c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 111388c2ecf20Sopenharmony_ci unsigned short index,temp; 111398c2ecf20Sopenharmony_ci 111408c2ecf20Sopenharmony_ci if((SiS_Pr->SiS_UseROM) { 111418c2ecf20Sopenharmony_ci if(!(ROMAddr[0x237] & 0x01)) return; 111428c2ecf20Sopenharmony_ci if(!(ROMAddr[0x237] & 0x04)) return; 111438c2ecf20Sopenharmony_ci /* No rom pointer in BIOS header! */ 111448c2ecf20Sopenharmony_ci } 111458c2ecf20Sopenharmony_ci 111468c2ecf20Sopenharmony_ci temp = GetOEMLCDPtr(SiS_Pr, 1); 111478c2ecf20Sopenharmony_ci if(temp == 0xFFFF) return; 111488c2ecf20Sopenharmony_ci 111498c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex]._VB_LCDHIndex; 111508c2ecf20Sopenharmony_ci for(i=0x14, j=0; i<=0x17; i++, j++) { 111518c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,i,SiS300_LCDHData[temp][index][j]); 111528c2ecf20Sopenharmony_ci } 111538c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_SiS_Part1Port,0x1a, 0xf8, (SiS300_LCDHData[temp][index][j] & 0x07)); 111548c2ecf20Sopenharmony_ci 111558c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex]._VB_LCDVIndex; 111568c2ecf20Sopenharmony_ci SiS_SetReg(SiS_SiS_Part1Port,0x18, SiS300_LCDVData[temp][index][0]); 111578c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_SiS_Part1Port,0x19, 0xF0, SiS300_LCDVData[temp][index][1]); 111588c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_SiS_Part1Port,0x1A, 0xC7, (SiS300_LCDVData[temp][index][2] & 0x38)); 111598c2ecf20Sopenharmony_ci for(i=0x1b, j=3; i<=0x1d; i++, j++) { 111608c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part1Port,i,SiS300_LCDVData[temp][index][j]); 111618c2ecf20Sopenharmony_ci } 111628c2ecf20Sopenharmony_ci#endif 111638c2ecf20Sopenharmony_ci} 111648c2ecf20Sopenharmony_ci 111658c2ecf20Sopenharmony_cistatic unsigned short 111668c2ecf20Sopenharmony_ciGetOEMTVPtr(struct SiS_Private *SiS_Pr) 111678c2ecf20Sopenharmony_ci{ 111688c2ecf20Sopenharmony_ci unsigned short index; 111698c2ecf20Sopenharmony_ci 111708c2ecf20Sopenharmony_ci index = 0; 111718c2ecf20Sopenharmony_ci if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) index += 4; 111728c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 111738c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) index += 2; 111748c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) index += 3; 111758c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetPAL) index += 1; 111768c2ecf20Sopenharmony_ci } else { 111778c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) index += 2; 111788c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPAL) index += 1; 111798c2ecf20Sopenharmony_ci } 111808c2ecf20Sopenharmony_ci return index; 111818c2ecf20Sopenharmony_ci} 111828c2ecf20Sopenharmony_ci 111838c2ecf20Sopenharmony_cistatic void 111848c2ecf20Sopenharmony_ciSetOEMTVDelay(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 111858c2ecf20Sopenharmony_ci{ 111868c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 111878c2ecf20Sopenharmony_ci unsigned short index,temp,romptr=0; 111888c2ecf20Sopenharmony_ci 111898c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 111908c2ecf20Sopenharmony_ci if(!(ROMAddr[0x238] & 0x01)) return; 111918c2ecf20Sopenharmony_ci if(!(ROMAddr[0x238] & 0x02)) return; 111928c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x241); 111938c2ecf20Sopenharmony_ci } 111948c2ecf20Sopenharmony_ci 111958c2ecf20Sopenharmony_ci temp = GetOEMTVPtr(SiS_Pr); 111968c2ecf20Sopenharmony_ci 111978c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVDelayIndex; 111988c2ecf20Sopenharmony_ci 111998c2ecf20Sopenharmony_ci if(romptr) { 112008c2ecf20Sopenharmony_ci romptr += (temp * 2); 112018c2ecf20Sopenharmony_ci romptr = SISGETROMW(romptr); 112028c2ecf20Sopenharmony_ci romptr += index; 112038c2ecf20Sopenharmony_ci temp = ROMAddr[romptr]; 112048c2ecf20Sopenharmony_ci } else { 112058c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 112068c2ecf20Sopenharmony_ci temp = SiS300_OEMTVDelay301[temp][index]; 112078c2ecf20Sopenharmony_ci } else { 112088c2ecf20Sopenharmony_ci temp = SiS300_OEMTVDelayLVDS[temp][index]; 112098c2ecf20Sopenharmony_ci } 112108c2ecf20Sopenharmony_ci } 112118c2ecf20Sopenharmony_ci temp &= 0x3c; 112128c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); 112138c2ecf20Sopenharmony_ci} 112148c2ecf20Sopenharmony_ci 112158c2ecf20Sopenharmony_cistatic void 112168c2ecf20Sopenharmony_ciSetOEMAntiFlicker(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 112178c2ecf20Sopenharmony_ci{ 112188c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 112198c2ecf20Sopenharmony_ci unsigned short index,temp,romptr=0; 112208c2ecf20Sopenharmony_ci 112218c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 112228c2ecf20Sopenharmony_ci if(!(ROMAddr[0x238] & 0x01)) return; 112238c2ecf20Sopenharmony_ci if(!(ROMAddr[0x238] & 0x04)) return; 112248c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x243); 112258c2ecf20Sopenharmony_ci } 112268c2ecf20Sopenharmony_ci 112278c2ecf20Sopenharmony_ci temp = GetOEMTVPtr(SiS_Pr); 112288c2ecf20Sopenharmony_ci 112298c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVFlickerIndex; 112308c2ecf20Sopenharmony_ci 112318c2ecf20Sopenharmony_ci if(romptr) { 112328c2ecf20Sopenharmony_ci romptr += (temp * 2); 112338c2ecf20Sopenharmony_ci romptr = SISGETROMW(romptr); 112348c2ecf20Sopenharmony_ci romptr += index; 112358c2ecf20Sopenharmony_ci temp = ROMAddr[romptr]; 112368c2ecf20Sopenharmony_ci } else { 112378c2ecf20Sopenharmony_ci temp = SiS300_OEMTVFlicker[temp][index]; 112388c2ecf20Sopenharmony_ci } 112398c2ecf20Sopenharmony_ci temp &= 0x70; 112408c2ecf20Sopenharmony_ci SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0A,0x8F,temp); 112418c2ecf20Sopenharmony_ci} 112428c2ecf20Sopenharmony_ci 112438c2ecf20Sopenharmony_cistatic void 112448c2ecf20Sopenharmony_ciSetOEMPhaseIncr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex) 112458c2ecf20Sopenharmony_ci{ 112468c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 112478c2ecf20Sopenharmony_ci unsigned short index,i,j,temp,romptr=0; 112488c2ecf20Sopenharmony_ci 112498c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) return; 112508c2ecf20Sopenharmony_ci 112518c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSetNTSCJ | TVSetPALM | TVSetPALN)) return; 112528c2ecf20Sopenharmony_ci 112538c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 112548c2ecf20Sopenharmony_ci if(!(ROMAddr[0x238] & 0x01)) return; 112558c2ecf20Sopenharmony_ci if(!(ROMAddr[0x238] & 0x08)) return; 112568c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x245); 112578c2ecf20Sopenharmony_ci } 112588c2ecf20Sopenharmony_ci 112598c2ecf20Sopenharmony_ci temp = GetOEMTVPtr(SiS_Pr); 112608c2ecf20Sopenharmony_ci 112618c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVPhaseIndex; 112628c2ecf20Sopenharmony_ci 112638c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 112648c2ecf20Sopenharmony_ci for(i=0x31, j=0; i<=0x34; i++, j++) { 112658c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Phase2[temp][index][j]); 112668c2ecf20Sopenharmony_ci } 112678c2ecf20Sopenharmony_ci } else { 112688c2ecf20Sopenharmony_ci if(romptr) { 112698c2ecf20Sopenharmony_ci romptr += (temp * 2); 112708c2ecf20Sopenharmony_ci romptr = SISGETROMW(romptr); 112718c2ecf20Sopenharmony_ci romptr += (index * 4); 112728c2ecf20Sopenharmony_ci for(i=0x31, j=0; i<=0x34; i++, j++) { 112738c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); 112748c2ecf20Sopenharmony_ci } 112758c2ecf20Sopenharmony_ci } else { 112768c2ecf20Sopenharmony_ci for(i=0x31, j=0; i<=0x34; i++, j++) { 112778c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Phase1[temp][index][j]); 112788c2ecf20Sopenharmony_ci } 112798c2ecf20Sopenharmony_ci } 112808c2ecf20Sopenharmony_ci } 112818c2ecf20Sopenharmony_ci} 112828c2ecf20Sopenharmony_ci 112838c2ecf20Sopenharmony_cistatic void 112848c2ecf20Sopenharmony_ciSetOEMYFilter(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 112858c2ecf20Sopenharmony_ci{ 112868c2ecf20Sopenharmony_ci unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 112878c2ecf20Sopenharmony_ci unsigned short index,temp,i,j,romptr=0; 112888c2ecf20Sopenharmony_ci 112898c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSCART | SetCRT2ToHiVision | SetCRT2ToYPbPr525750)) return; 112908c2ecf20Sopenharmony_ci 112918c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_UseROM) { 112928c2ecf20Sopenharmony_ci if(!(ROMAddr[0x238] & 0x01)) return; 112938c2ecf20Sopenharmony_ci if(!(ROMAddr[0x238] & 0x10)) return; 112948c2ecf20Sopenharmony_ci romptr = SISGETROMW(0x247); 112958c2ecf20Sopenharmony_ci } 112968c2ecf20Sopenharmony_ci 112978c2ecf20Sopenharmony_ci temp = GetOEMTVPtr(SiS_Pr); 112988c2ecf20Sopenharmony_ci 112998c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 8; 113008c2ecf20Sopenharmony_ci else if(SiS_Pr->SiS_TVMode & TVSetPALN) temp = 9; 113018c2ecf20Sopenharmony_ci /* NTSCJ uses NTSC filters */ 113028c2ecf20Sopenharmony_ci 113038c2ecf20Sopenharmony_ci index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVYFilterIndex; 113048c2ecf20Sopenharmony_ci 113058c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 113068c2ecf20Sopenharmony_ci for(i=0x35, j=0; i<=0x38; i++, j++) { 113078c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); 113088c2ecf20Sopenharmony_ci } 113098c2ecf20Sopenharmony_ci for(i=0x48; i<=0x4A; i++, j++) { 113108c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); 113118c2ecf20Sopenharmony_ci } 113128c2ecf20Sopenharmony_ci } else { 113138c2ecf20Sopenharmony_ci if((romptr) && (!(SiS_Pr->SiS_TVMode & (TVSetPALM|TVSetPALN)))) { 113148c2ecf20Sopenharmony_ci romptr += (temp * 2); 113158c2ecf20Sopenharmony_ci romptr = SISGETROMW(romptr); 113168c2ecf20Sopenharmony_ci romptr += (index * 4); 113178c2ecf20Sopenharmony_ci for(i=0x35, j=0; i<=0x38; i++, j++) { 113188c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]); 113198c2ecf20Sopenharmony_ci } 113208c2ecf20Sopenharmony_ci } else { 113218c2ecf20Sopenharmony_ci for(i=0x35, j=0; i<=0x38; i++, j++) { 113228c2ecf20Sopenharmony_ci SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter1[temp][index][j]); 113238c2ecf20Sopenharmony_ci } 113248c2ecf20Sopenharmony_ci } 113258c2ecf20Sopenharmony_ci } 113268c2ecf20Sopenharmony_ci} 113278c2ecf20Sopenharmony_ci 113288c2ecf20Sopenharmony_cistatic unsigned short 113298c2ecf20Sopenharmony_ciSiS_SearchVBModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo) 113308c2ecf20Sopenharmony_ci{ 113318c2ecf20Sopenharmony_ci unsigned short ModeIdIndex; 113328c2ecf20Sopenharmony_ci unsigned char VGAINFO = SiS_Pr->SiS_VGAINFO; 113338c2ecf20Sopenharmony_ci 113348c2ecf20Sopenharmony_ci if(*ModeNo <= 5) *ModeNo |= 1; 113358c2ecf20Sopenharmony_ci 113368c2ecf20Sopenharmony_ci for(ModeIdIndex=0; ; ModeIdIndex++) { 113378c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == *ModeNo) break; 113388c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == 0xFF) return 0; 113398c2ecf20Sopenharmony_ci } 113408c2ecf20Sopenharmony_ci 113418c2ecf20Sopenharmony_ci if(*ModeNo != 0x07) { 113428c2ecf20Sopenharmony_ci if(*ModeNo > 0x03) return ModeIdIndex; 113438c2ecf20Sopenharmony_ci if(VGAINFO & 0x80) return ModeIdIndex; 113448c2ecf20Sopenharmony_ci ModeIdIndex++; 113458c2ecf20Sopenharmony_ci } 113468c2ecf20Sopenharmony_ci 113478c2ecf20Sopenharmony_ci if(VGAINFO & 0x10) ModeIdIndex++; /* 400 lines */ 113488c2ecf20Sopenharmony_ci /* else 350 lines */ 113498c2ecf20Sopenharmony_ci return ModeIdIndex; 113508c2ecf20Sopenharmony_ci} 113518c2ecf20Sopenharmony_ci 113528c2ecf20Sopenharmony_cistatic void 113538c2ecf20Sopenharmony_ciSiS_OEM300Setting(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 113548c2ecf20Sopenharmony_ci unsigned short RefTableIndex) 113558c2ecf20Sopenharmony_ci{ 113568c2ecf20Sopenharmony_ci unsigned short OEMModeIdIndex = 0; 113578c2ecf20Sopenharmony_ci 113588c2ecf20Sopenharmony_ci if(!SiS_Pr->UseCustomMode) { 113598c2ecf20Sopenharmony_ci OEMModeIdIndex = SiS_SearchVBModeID(SiS_Pr,&ModeNo); 113608c2ecf20Sopenharmony_ci if(!(OEMModeIdIndex)) return; 113618c2ecf20Sopenharmony_ci } 113628c2ecf20Sopenharmony_ci 113638c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 113648c2ecf20Sopenharmony_ci SetOEMLCDDelay(SiS_Pr, ModeNo, OEMModeIdIndex); 113658c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 113668c2ecf20Sopenharmony_ci SetOEMLCDData(SiS_Pr, ModeNo, OEMModeIdIndex); 113678c2ecf20Sopenharmony_ci } 113688c2ecf20Sopenharmony_ci } 113698c2ecf20Sopenharmony_ci if(SiS_Pr->UseCustomMode) return; 113708c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 113718c2ecf20Sopenharmony_ci SetOEMTVDelay(SiS_Pr, ModeNo,OEMModeIdIndex); 113728c2ecf20Sopenharmony_ci if(SiS_Pr->SiS_VBType & VB_SISVB) { 113738c2ecf20Sopenharmony_ci SetOEMAntiFlicker(SiS_Pr, ModeNo, OEMModeIdIndex); 113748c2ecf20Sopenharmony_ci SetOEMPhaseIncr(SiS_Pr, ModeNo, OEMModeIdIndex); 113758c2ecf20Sopenharmony_ci SetOEMYFilter(SiS_Pr, ModeNo, OEMModeIdIndex); 113768c2ecf20Sopenharmony_ci } 113778c2ecf20Sopenharmony_ci } 113788c2ecf20Sopenharmony_ci} 113798c2ecf20Sopenharmony_ci#endif 113808c2ecf20Sopenharmony_ci 11381