~ubuntu-branches/ubuntu/trusty/linux-armadaxp/trusty

« back to all changes in this revision

Viewing changes to drivers/staging/xgifb/vb_setmode.c

  • Committer: Package Import Robot
  • Author(s): Michael Casadevall, Bryan Wu, Dann Frazier, Michael Casadeall
  • Date: 2012-03-10 15:00:54 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120310150054-flugb39zon8vvgwe
Tags: 3.2.0-1600.1
[ Bryan Wu ]
* UBUNTU: import debian/debian.env and debian.armadaxp

[ Dann Frazier ]
* ARM: Armada XP: remove trailing '/' in dirnames in mvRules.mk

[ Michael Casadeall ]
* tools: add some tools for Marvell Armada XP processor
* kernel: timer tick hacking from Marvell
* kernel: Sheeva Errata: add delay on Sheeva when powering down
* net: add Marvell NFP netfilter
* net: socket and skb modifications made by Marvell
* miscdevice: add minor IDs for some Marvell Armada drivers
* fs: introduce memory pool for splice()
* video: EDID detection updates from Marvell Armada XP patchset
* video: backlight: add Marvell Dove LCD backlight driver
* video: display: add THS8200 display driver
* video: framebuffer: add Marvell Dove and Armada XP processor onchip LCD controller driver
* usbtest: add Interrupt transfer testing by Marvell Armada XP code
* usb: ehci: add support for Marvell EHCI controler
* tty/serial: 8250: add support for Marvell Armada XP processor and DeviceTree work
* rtc: add support for Marvell Armada XP onchip RTC controller
* net: pppoe: add Marvell ethernet NFP hook in PPPoE networking driver
* mtd: nand: add support for Marvell Armada XP Nand Flash Controller
* mtd: maps: add Marvell Armada XP specific map driver
* mmc: add support for Marvell Armada XP MMC/SD host controller
* i2c: add support for Marvell Armada XP onchip i2c bus controller
* hwmon: add Kconfig option for Armada XP onchip thermal sensor driver
* dmaengine: add Net DMA support for splice and update Marvell XOR DMA engine driver
* ata: add support for Marvell Armada XP SATA controller and update some quirks
* ARM: add Marvell Armada XP machine to mach-types
* ARM: oprofile: add support for Marvell PJ4B core
* ARM: mm: more ARMv6 switches for Marvell Armada XP
* ARM: remove static declaration to allow compilation
* ARM: alignment access fault trick
* ARM: mm: skip some fault fixing when run on NONE SMP ARMv6 mode during early abort event
* ARM: mm: add Marvell Sheeva CPU Architecture for PJ4B
* ARM: introduce optimized copy operation for Marvell Armada XP
* ARM: SAUCE: hardware breakpoint trick for Marvell Armada XP
* ARM: big endian and little endian tricks for Marvell Armada XP
* ARM: SAUCE: Add Marvell Armada XP build rules to arch/arm/kernel/Makefile
* ARM: vfp: add special handling for Marvell Armada XP
* ARM: add support for Marvell U-Boot
* ARM: add mv_controller_num for ARM PCI drivers
* ARM: add support for local PMUs, general SMP tweaks and cache flushing
* ARM: add Marvell device identifies in glue-proc.h
* ARM: add IPC driver support for Marvell platforms
* ARM: add DMA mapping for Marvell platforms
* ARM: add Sheeva errata and PJ4B code for booting
* ARM: update Kconfig and Makefile to include Marvell Armada XP platforms
* ARM: Armada XP: import LSP from Marvell for Armada XP 3.2 kernel enablement

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#include <linux/io.h>
3
3
#include <linux/delay.h>
4
4
#include <linux/types.h>
5
 
#include <linux/version.h>
6
5
#include "XGIfb.h"
7
6
 
8
7
 
9
8
#include "vb_def.h"
10
9
#include "vgatypes.h"
11
10
#include "vb_struct.h"
 
11
#include "vb_init.h"
12
12
#include "vb_util.h"
13
13
#include "vb_table.h"
14
14
#include "vb_setmode.h"
15
15
 
16
16
 
17
17
#define  IndexMask 0xff
18
 
#ifndef XGI_MASK_DUAL_CHIP
19
 
#define XGI_MASK_DUAL_CHIP        0x04  /* SR3A */
20
 
#endif
21
18
 
22
 
static unsigned short XGINew_MDA_DAC[] = {
 
19
static const unsigned short XGINew_MDA_DAC[] = {
23
20
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24
21
        0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
25
22
        0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
29
26
        0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
30
27
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
31
28
 
32
 
static unsigned short XGINew_CGA_DAC[] = {
 
29
static const unsigned short XGINew_CGA_DAC[] = {
33
30
        0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
34
31
        0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
35
32
        0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
39
36
        0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
40
37
        0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
41
38
 
42
 
static unsigned short XGINew_EGA_DAC[] = {
 
39
static const unsigned short XGINew_EGA_DAC[] = {
43
40
        0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
44
41
        0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
45
42
        0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
49
46
        0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
50
47
        0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
51
48
 
52
 
static unsigned short XGINew_VGA_DAC[] = {
 
49
static const unsigned short XGINew_VGA_DAC[] = {
53
50
        0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
54
51
        0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
55
52
        0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
145
142
        pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV;
146
143
        pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table;
147
144
 
148
 
        pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC;
149
 
        pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC;
150
 
        pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL;
151
 
        pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL;
152
 
 
153
145
        /* 310 customization related */
154
146
        if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV))
155
147
                pVBInfo->LCDCapList = XGI_LCDDLCapList;
208
200
        return index; /* Get pVBInfo->StandTable index */
209
201
}
210
202
 
211
 
/*
212
 
unsigned char XGI_SetBIOSData(unsigned short ModeNo,
213
 
                              unsigned short ModeIdIndex) {
214
 
        return (0);
215
 
}
216
 
*/
217
 
 
218
 
/* unsigned char XGI_ClearBankRegs(unsigned short ModeNo,
219
 
                                   unsigned short ModeIdIndex) {
220
 
        return( 0 ) ;
221
 
}
222
 
*/
223
 
 
224
203
static void XGI_SetSeqRegs(unsigned short ModeNo,
225
204
                           unsigned short StandTableIndex,
226
205
                           unsigned short ModeIdIndex,
491
470
                        }
492
471
                }
493
472
        } else { /* for LVDS */
494
 
                if (pVBInfo->IF_DEF_CH7005 == 1) {
495
 
                        if (pVBInfo->VBInfo & SetCRT2ToTV)
496
 
                                tempax |= SupportCHTV;
497
 
                }
498
 
 
499
473
                if (pVBInfo->VBInfo & SetCRT2ToLCD) {
500
474
                        tempax |= SupportLCD;
501
475
 
1002
976
        }
1003
977
}
1004
978
 
1005
 
/* --------------------------------------------------------------------- */
1006
 
/* Function : XGI_SetXG21LCD */
1007
 
/* Input : */
1008
 
/* Output : FCLK duty cycle, FCLK delay compensation */
1009
 
/* Description : All values set zero */
1010
 
/* --------------------------------------------------------------------- */
1011
 
static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo,
1012
 
                unsigned short RefreshRateTableIndex, unsigned short ModeNo)
 
979
static void xgifb_set_lcd(int chip_id,
 
980
                          struct vb_device_info *pVBInfo,
 
981
                          unsigned short RefreshRateTableIndex,
 
982
                          unsigned short ModeNo)
1013
983
{
1014
984
        unsigned short Data, Temp, b3CC;
1015
985
        unsigned short XGI_P3cc;
1020
990
        xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
1021
991
        xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
1022
992
        xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
 
993
 
 
994
        if (chip_id == XG27) {
 
995
                Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
 
996
                if ((Temp & 0x03) == 0) { /* dual 12 */
 
997
                        xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13);
 
998
                        xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13);
 
999
                }
 
1000
        }
 
1001
 
1023
1002
        if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1024
1003
                xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1025
1004
                xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1027
1006
                xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1028
1007
        }
1029
1008
 
1030
 
        Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
1031
 
 
1032
 
        if (Temp & 0x01) {
1033
 
                xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */
1034
 
                xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40);
1035
 
        }
1036
 
 
1037
 
        xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
1038
 
 
1039
 
        xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20);
1040
 
        xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80);
1041
 
 
1042
 
        if (ModeNo <= 0x13) {
1043
 
                b3CC = (unsigned char) inb(XGI_P3cc);
1044
 
                if (b3CC & 0x40)
1045
 
                        /* Hsync polarity */
1046
 
                        xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
1047
 
                if (b3CC & 0x80)
1048
 
                        /* Vsync polarity */
1049
 
                        xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
 
1009
        if (chip_id == XG27) {
 
1010
                XGI_SetXG27FPBits(pVBInfo);
1050
1011
        } else {
1051
 
                Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1052
 
                if (Data & 0x4000)
1053
 
                        /* Hsync polarity */
1054
 
                        xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
1055
 
                if (Data & 0x8000)
1056
 
                        /* Vsync polarity */
1057
 
                        xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
1058
 
        }
1059
 
}
1060
 
 
1061
 
static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
1062
 
                           unsigned short RefreshRateTableIndex,
1063
 
                           unsigned short ModeNo)
1064
 
{
1065
 
        unsigned short Data, Temp, b3CC;
1066
 
        unsigned short XGI_P3cc;
1067
 
 
1068
 
        XGI_P3cc = pVBInfo->P3cc;
1069
 
 
1070
 
        xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00);
1071
 
        xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
1072
 
        xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
1073
 
        xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
1074
 
 
1075
 
        Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
1076
 
        if ((Temp & 0x03) == 0) { /* dual 12 */
1077
 
                xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13);
1078
 
                xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13);
1079
 
        }
1080
 
 
1081
 
        if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1082
 
                xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1083
 
                xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1084
 
                xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1085
 
                xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1086
 
        }
1087
 
 
1088
 
        XGI_SetXG27FPBits(pVBInfo);
 
1012
                Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
 
1013
                if (Temp & 0x01) {
 
1014
                        /* 18 bits FP */
 
1015
                        xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40);
 
1016
                        xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40);
 
1017
                }
 
1018
        }
1089
1019
 
1090
1020
        xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
1091
1021
 
1337
1267
                struct xgi_hw_device_info *HwDeviceExtension,
1338
1268
                struct vb_device_info *pVBInfo)
1339
1269
{
1340
 
        unsigned short tempbx;
1341
 
 
1342
1270
        unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2,
1343
1271
                                           VCLK65 + 2,
1344
1272
                                           VCLK65 + 2,
1359
1287
 
1360
1288
        unsigned short CRT2Index, VCLKIndex;
1361
1289
        unsigned short modeflag, resinfo;
1362
 
        unsigned char *CHTVVCLKPtr = NULL;
1363
1290
 
1364
1291
        if (ModeNo <= 0x13) {
1365
1292
                /* si+St_ResInfo */
1460
1387
                else
1461
1388
                        VCLKIndex = CRT2Index;
1462
1389
 
1463
 
                if (pVBInfo->IF_DEF_CH7005 == 1) {
1464
 
                        if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) {
1465
 
                                VCLKIndex &= 0x1f;
1466
 
                                tempbx = 0;
1467
 
 
1468
 
                                if (pVBInfo->VBInfo & SetPALTV)
1469
 
                                        tempbx += 2;
1470
 
 
1471
 
                                if (pVBInfo->VBInfo & SetCHTVOverScan)
1472
 
                                        tempbx += 1;
1473
 
 
1474
 
                                switch (tempbx) {
1475
 
                                case 0:
1476
 
                                        CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
1477
 
                                        break;
1478
 
                                case 1:
1479
 
                                        CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
1480
 
                                        break;
1481
 
                                case 2:
1482
 
                                        CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
1483
 
                                        break;
1484
 
                                case 3:
1485
 
                                        CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
1486
 
                                        break;
1487
 
                                default:
1488
 
                                        break;
1489
 
                                }
1490
 
 
1491
 
                                VCLKIndex = CHTVVCLKPtr[VCLKIndex];
1492
 
                        }
1493
 
                } else {
1494
 
                        VCLKIndex = VCLKIndex >> 6;
1495
 
                        if ((pVBInfo->LCDResInfo == Panel800x600) ||
1496
 
                            (pVBInfo->LCDResInfo == Panel320x480))
1497
 
                                VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
1498
 
                        else if ((pVBInfo->LCDResInfo == Panel1024x768) ||
1499
 
                                 (pVBInfo->LCDResInfo == Panel1024x768x75))
1500
 
                                VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
1501
 
                        else
1502
 
                                VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
1503
 
                }
 
1390
                VCLKIndex = VCLKIndex >> 6;
 
1391
                if ((pVBInfo->LCDResInfo == Panel800x600) ||
 
1392
                    (pVBInfo->LCDResInfo == Panel320x480))
 
1393
                        VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
 
1394
                else if ((pVBInfo->LCDResInfo == Panel1024x768) ||
 
1395
                         (pVBInfo->LCDResInfo == Panel1024x768x75))
 
1396
                        VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
 
1397
                else
 
1398
                        VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
1504
1399
        }
1505
1400
        /* VCLKIndex = VCLKIndex&IndexMask; */
1506
1401
 
1772
1667
 
1773
1668
}
1774
1669
 
1775
 
/*
1776
 
void XGI_VesaLowResolution(unsigned short ModeNo,
1777
 
                           unsigned short ModeIdIndex,
1778
 
                           struct vb_device_info *pVBInfo)
1779
 
{
1780
 
        unsigned short modeflag;
1781
 
 
1782
 
        if (ModeNo > 0x13)
1783
 
                modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1784
 
        else
1785
 
                modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1786
 
 
1787
 
        if (ModeNo > 0x13) {
1788
 
                if (modeflag & DoubleScanMode) {
1789
 
                        if (modeflag & HalfDCLK) {
1790
 
                                if (pVBInfo->VBType & VB_XGI301B |
1791
 
                                                      VB_XGI302B |
1792
 
                                                      VB_XGI301LV |
1793
 
                                                      VB_XGI302LV |
1794
 
                                                      VB_XGI301C)) {
1795
 
                                        if (!(pVBInfo->VBInfo &
1796
 
                                             SetCRT2ToRAMDAC)) {
1797
 
                                                if (pVBInfo->VBInfo &
1798
 
                                                    SetInSlaveMode) {
1799
 
                                                        xgifb_reg_and_or(
1800
 
                                                                pVBInfo->P3c4,
1801
 
                                                                0x01,
1802
 
                                                                0xf7,
1803
 
                                                                0x00);
1804
 
                                                        xgifb_reg_and_or(
1805
 
                                                                pVBInfo->P3c4,
1806
 
                                                                0x0f,
1807
 
                                                                0x7f,
1808
 
                                                                0x00);
1809
 
                                                        return;
1810
 
                                                }
1811
 
                                        }
1812
 
                                }
1813
 
                                xgifb_reg_and_or(pVBInfo->P3c4,
1814
 
                                                 0x0f,
1815
 
                                                 0xff,
1816
 
                                                 0x80);
1817
 
                                xgifb_reg_and_or(pVBInfo->P3c4,
1818
 
                                                 0x01,
1819
 
                                                 0xf7,
1820
 
                                                 0x00);
1821
 
                                return;
1822
 
                        }
1823
 
                }
1824
 
        }
1825
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
1826
 
}
1827
 
*/
1828
 
 
1829
1670
static void XGI_WriteDAC(unsigned short dl,
1830
1671
                         unsigned short ah,
1831
1672
                         unsigned short al,
1860
1701
                struct vb_device_info *pVBInfo)
1861
1702
{
1862
1703
        unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al,
1863
 
                        ah, dh, *table = NULL;
 
1704
                        ah, dh;
 
1705
        const unsigned short *table = NULL;
1864
1706
 
1865
1707
        if (ModeNo <= 0x13)
1866
1708
                data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2062
1904
 
2063
1905
        switch (tempbx) {
2064
1906
        case 0:
2065
 
                tempdi = XGI_EPLLCDCRT1Ptr_H;
2066
 
                break;
2067
1907
        case 1:
2068
 
                tempdi = XGI_EPLLCDCRT1Ptr_V;
 
1908
                tempdi = xgifb_epllcd_crt1;
2069
1909
                break;
2070
1910
        case 2:
2071
1911
                tempdi = XGI_EPLLCDDataPtr;
2315
2155
                        return &XGI_CetLCD1280x1024Data[tempal];
2316
2156
                        break;
2317
2157
                case 6:
2318
 
                        return &XGI_ExtLCD1400x1050Data[tempal];
2319
 
                        break;
2320
2158
                case 7:
2321
 
                        return &XGI_StLCD1400x1050Data[tempal];
 
2159
                        return &xgifb_lcd_1400x1050[tempal];
2322
2160
                        break;
2323
2161
                case 8:
2324
2162
                        return &XGI_CetLCD1400x1050Data[tempal];
2342
2180
                        return &XGI_CetLCD1024x768x75Data[tempal];
2343
2181
                        break;
2344
2182
                case 15:
2345
 
                        return &XGI_ExtLCD1280x1024x75Data[tempal];
2346
 
                        break;
2347
2183
                case 16:
2348
 
                        return &XGI_StLCD1280x1024x75Data[tempal];
 
2184
                        return &xgifb_lcd_1280x1024x75[tempal];
2349
2185
                        break;
2350
2186
                case 17:
2351
2187
                        return &XGI_CetLCD1280x1024x75Data[tempal];
2389
2225
                                return &XGI_CetLCDDes1280x1024Data[tempal];
2390
2226
                        break;
2391
2227
                case 6:
2392
 
                        if ((pVBInfo->VBType & VB_XGI301LV) ||
2393
 
                            (pVBInfo->VBType & VB_XGI302LV))
2394
 
                                return &XGI_ExtLCDDLDes1400x1050Data[tempal];
2395
 
                        else
2396
 
                                return &XGI_ExtLCDDes1400x1050Data[tempal];
2397
 
                        break;
2398
2228
                case 7:
2399
2229
                        if ((pVBInfo->VBType & VB_XGI301LV) ||
2400
2230
                            (pVBInfo->VBType & VB_XGI302LV))
2401
 
                                return &XGI_StLCDDLDes1400x1050Data[tempal];
 
2231
                                return &xgifb_lcddldes_1400x1050[tempal];
2402
2232
                        else
2403
 
                                return &XGI_StLCDDes1400x1050Data[tempal];
 
2233
                                return &xgifb_lcddes_1400x1050[tempal];
2404
2234
                        break;
2405
2235
                case 8:
2406
2236
                        return &XGI_CetLCDDes1400x1050Data[tempal];
2426
2256
                        return &XGI_NoScalingDesData[tempal];
2427
2257
                        break;
2428
2258
                case 13:
2429
 
                        return &XGI_ExtLCDDes1024x768x75Data[tempal];
2430
 
                        break;
2431
2259
                case 14:
2432
 
                        return &XGI_StLCDDes1024x768x75Data[tempal];
 
2260
                        return &xgifb_lcddes_1024x768x75[tempal];
2433
2261
                        break;
2434
2262
                case 15:
2435
2263
                        return &XGI_CetLCDDes1024x768x75Data[tempal];
2436
2264
                        break;
2437
2265
                case 16:
2438
 
                        if ((pVBInfo->VBType & VB_XGI301LV) ||
2439
 
                            (pVBInfo->VBType & VB_XGI302LV))
2440
 
                                return &XGI_ExtLCDDLDes1280x1024x75Data[tempal];
2441
 
                        else
2442
 
                                return &XGI_ExtLCDDes1280x1024x75Data[tempal];
2443
 
                        break;
2444
2266
                case 17:
2445
2267
                        if ((pVBInfo->VBType & VB_XGI301LV) ||
2446
2268
                            (pVBInfo->VBType & VB_XGI302LV))
2447
 
                                return &XGI_StLCDDLDes1280x1024x75Data[tempal];
 
2269
                                return &xgifb_lcddldes_1280x1024x75[tempal];
2448
2270
                        else
2449
 
                                return &XGI_StLCDDes1280x1024x75Data[tempal];
 
2271
                                return &xgifb_lcddes_1280x1024x75[tempal];
2450
2272
                        break;
2451
2273
                case 18:
2452
2274
                        if ((pVBInfo->VBType & VB_XGI301LV) ||
2500
2322
        switch (tempbx) {
2501
2323
        case 0:
2502
2324
                tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
2503
 
                if (pVBInfo->IF_DEF_CH7007 == 1)
2504
 
                        tempdi = XGI_EPLCHTVCRT1Ptr;
2505
 
 
2506
2325
                break;
2507
2326
        case 1:
2508
2327
                tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
2509
 
                if (pVBInfo->IF_DEF_CH7007 == 1)
2510
 
                        tempdi = XGI_EPLCHTVCRT1Ptr;
2511
 
 
2512
2328
                break;
2513
2329
        case 2:
2514
 
                tempdi = XGI_EPLCHTVDataPtr;
 
2330
        case 6:
 
2331
                tempdi = xgifb_chrontel_tv;
2515
2332
                break;
2516
2333
        case 3:
2517
2334
                tempdi = NULL;
2522
2339
        case 5:
2523
2340
                tempdi = NULL;
2524
2341
                break;
2525
 
        case 6:
2526
 
                tempdi = XGI_EPLCHTVRegPtr;
2527
 
                break;
2528
2342
        default:
2529
2343
                break;
2530
2344
        }
2626
2440
{
2627
2441
        unsigned short tempbx;
2628
2442
        struct XGI330_LVDSDataStruct *LCDPtr = NULL;
2629
 
        struct XGI330_CHTVDataStruct *TVPtr = NULL;
2630
2443
 
2631
2444
        tempbx = 2;
2632
2445
 
2639
2452
                pVBInfo->HT = LCDPtr->LCDHT;
2640
2453
                pVBInfo->VT = LCDPtr->LCDVT;
2641
2454
        }
2642
 
        if (pVBInfo->IF_DEF_CH7017 == 1) {
2643
 
                if (pVBInfo->VBInfo & SetCRT2ToTV) {
2644
 
                        TVPtr = (struct XGI330_CHTVDataStruct *) XGI_GetTVPtr(
2645
 
                                        tempbx, ModeNo, ModeIdIndex,
2646
 
                                        RefreshRateTableIndex, pVBInfo);
2647
 
                        pVBInfo->VGAHT = TVPtr->VGAHT;
2648
 
                        pVBInfo->VGAVT = TVPtr->VGAVT;
2649
 
                        pVBInfo->HT = TVPtr->LCDHT;
2650
 
                        pVBInfo->VT = TVPtr->LCDVT;
2651
 
                }
2652
 
        }
2653
2455
 
2654
2456
        if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2655
2457
                if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
2682
2484
        unsigned short tempbx, i;
2683
2485
        struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2684
2486
        struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2685
 
        /* struct XGI330_CHTVDataStruct *TVPtr = NULL; */
2686
 
        struct XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2687
 
        struct XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2688
2487
 
2689
2488
        if (ModeNo <= 0x13)
2690
2489
                index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2693
2492
 
2694
2493
        index = index & IndexMask;
2695
2494
 
2696
 
        if ((pVBInfo->IF_DEF_ScaleLCD == 0) ||
2697
 
            ((pVBInfo->IF_DEF_ScaleLCD == 1) &&
2698
 
            (!(pVBInfo->LCDInfo & EnableScalingLCD)))) {
2699
 
                tempbx = 0;
2700
 
 
2701
 
                if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2702
 
                        LCDPtr = (struct XGI_LVDSCRT1HDataStruct *)
2703
 
                                        XGI_GetLcdPtr(tempbx, ModeNo,
2704
 
                                                      ModeIdIndex,
2705
 
                                                      RefreshRateTableIndex,
2706
 
                                                      pVBInfo);
2707
 
 
2708
 
                        for (i = 0; i < 8; i++)
2709
 
                                pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
2710
 
                }
2711
 
 
2712
 
                if (pVBInfo->IF_DEF_CH7007 == 1) {
2713
 
                        if (pVBInfo->VBInfo & SetCRT2ToTV) {
2714
 
                                CH7007TV_TimingHPtr =
2715
 
                                        (struct XGI_CH7007TV_TimingHStruct *)
2716
 
                                                XGI_GetTVPtr(
2717
 
                                                        tempbx,
2718
 
                                                        ModeNo,
2719
 
                                                        ModeIdIndex,
2720
 
                                                        RefreshRateTableIndex,
2721
 
                                                        pVBInfo);
2722
 
 
2723
 
                                for (i = 0; i < 8; i++)
2724
 
                                        pVBInfo->TimingH[0].data[i] =
2725
 
                                                CH7007TV_TimingHPtr[0].data[i];
2726
 
                        }
2727
 
                }
2728
 
 
2729
 
                /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2730
 
                        if (pVBInfo->VBInfo & SetCRT2ToTV)
2731
 
                                TVPtr = (struct XGI330_CHTVDataStruct *)
2732
 
                                                XGI_GetTVPtr(
2733
 
                                                        tempbx,
2734
 
                                                        ModeNo,
2735
 
                                                        ModeIdIndex,
2736
 
                                                        RefreshRateTableIndex,
2737
 
                                                        pVBInfo);
2738
 
                }
2739
 
                */
2740
 
 
2741
 
                XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
2742
 
 
2743
 
                if (pVBInfo->IF_DEF_CH7007 == 1) {
2744
 
                        xgifb_reg_set(pVBInfo->P3c4, 0x2E,
2745
 
                                        CH7007TV_TimingHPtr[0].data[8]);
2746
 
                        xgifb_reg_set(pVBInfo->P3c4, 0x2F,
2747
 
                                        CH7007TV_TimingHPtr[0].data[9]);
2748
 
                }
2749
 
 
2750
 
                tempbx = 1;
2751
 
 
2752
 
                if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2753
 
                        LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *)
2754
 
                                        XGI_GetLcdPtr(
2755
 
                                                tempbx,
2756
 
                                                ModeNo,
2757
 
                                                ModeIdIndex,
2758
 
                                                RefreshRateTableIndex,
2759
 
                                                pVBInfo);
2760
 
                        for (i = 0; i < 7; i++)
2761
 
                                pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
2762
 
                }
2763
 
 
2764
 
                if (pVBInfo->IF_DEF_CH7007 == 1) {
2765
 
                        if (pVBInfo->VBInfo & SetCRT2ToTV) {
2766
 
                                CH7007TV_TimingVPtr =
2767
 
                                        (struct XGI_CH7007TV_TimingVStruct *)
2768
 
                                                XGI_GetTVPtr(
2769
 
                                                        tempbx,
2770
 
                                                        ModeNo,
2771
 
                                                        ModeIdIndex,
2772
 
                                                        RefreshRateTableIndex,
2773
 
                                                        pVBInfo);
2774
 
 
2775
 
                                for (i = 0; i < 7; i++)
2776
 
                                        pVBInfo->TimingV[0].data[i] =
2777
 
                                                CH7007TV_TimingVPtr[0].data[i];
2778
 
                        }
2779
 
                }
2780
 
                /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2781
 
                        if (pVBInfo->VBInfo & SetCRT2ToTV)
2782
 
                                TVPtr = (struct XGI330_CHTVDataStruct *)
2783
 
                                        XGI_GetTVPtr(tempbx,
2784
 
                                                     ModeNo,
2785
 
                                                     ModeIdIndex,
2786
 
                                                     RefreshRateTableIndex,
2787
 
                                                     pVBInfo);
2788
 
                }
2789
 
                */
2790
 
 
2791
 
                XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
2792
 
 
2793
 
                if (pVBInfo->IF_DEF_CH7007 == 1) {
2794
 
                        xgifb_reg_and_or(pVBInfo->P3c4, 0x33, ~0x01,
2795
 
                                        CH7007TV_TimingVPtr[0].data[7] & 0x01);
2796
 
                        xgifb_reg_set(pVBInfo->P3c4, 0x34,
2797
 
                                        CH7007TV_TimingVPtr[0].data[8]);
2798
 
                        xgifb_reg_set(pVBInfo->P3c4, 0x3F,
2799
 
                                        CH7007TV_TimingVPtr[0].data[9]);
2800
 
 
2801
 
                }
2802
 
        }
 
2495
        tempbx = 0;
 
2496
 
 
2497
        if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
 
2498
                LCDPtr = (struct XGI_LVDSCRT1HDataStruct *)
 
2499
                                XGI_GetLcdPtr(tempbx, ModeNo,
 
2500
                                              ModeIdIndex,
 
2501
                                              RefreshRateTableIndex,
 
2502
                                              pVBInfo);
 
2503
 
 
2504
                for (i = 0; i < 8; i++)
 
2505
                        pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
 
2506
        }
 
2507
 
 
2508
        XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
 
2509
 
 
2510
        tempbx = 1;
 
2511
 
 
2512
        if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
 
2513
                LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *)
 
2514
                                XGI_GetLcdPtr(
 
2515
                                        tempbx,
 
2516
                                        ModeNo,
 
2517
                                        ModeIdIndex,
 
2518
                                        RefreshRateTableIndex,
 
2519
                                        pVBInfo);
 
2520
                for (i = 0; i < 7; i++)
 
2521
                        pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
 
2522
        }
 
2523
 
 
2524
        XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
2803
2525
}
2804
2526
 
2805
2527
static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
2888
2610
        else
2889
2611
                modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2890
2612
 
2891
 
        if (!(pVBInfo->SetFlag & Win9xDOSMode)) {
2892
 
                if ((pVBInfo->IF_DEF_CH7017 == 0) || (pVBInfo->VBInfo
2893
 
                                & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
2894
 
                        if (pVBInfo->IF_DEF_OEMUtil == 1) {
2895
 
                                tempbx = 8;
2896
 
                                LCDPtr = (struct XGI330_LCDDataDesStruct *)
2897
 
                                        XGI_GetLcdPtr(tempbx,
2898
 
                                                      ModeNo,
2899
 
                                                      ModeIdIndex,
2900
 
                                                      RefreshRateTableIndex,
2901
 
                                                      pVBInfo);
2902
 
                        }
2903
 
 
2904
 
                        if ((pVBInfo->IF_DEF_OEMUtil == 0) ||
2905
 
                            (LCDPtr == NULL)) {
2906
 
                                tempbx = 3;
2907
 
                                if (pVBInfo->LCDInfo & EnableScalingLCD)
2908
 
                                        LCDPtr1 =
2909
 
                                            (struct XGI330_LCDDataDesStruct2 *)
2910
 
                                                        XGI_GetLcdPtr(
2911
 
                                                          tempbx,
2912
 
                                                          ModeNo,
2913
 
                                                          ModeIdIndex,
2914
 
                                                          RefreshRateTableIndex,
2915
 
                                                          pVBInfo);
2916
 
                                else
2917
 
                                        LCDPtr =
2918
 
                                            (struct XGI330_LCDDataDesStruct *)
2919
 
                                                        XGI_GetLcdPtr(
2920
 
                                                          tempbx,
2921
 
                                                          ModeNo,
2922
 
                                                          ModeIdIndex,
2923
 
                                                          RefreshRateTableIndex,
2924
 
                                                          pVBInfo);
2925
 
                        }
2926
 
 
2927
 
                        XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
2928
 
                        push1 = tempbx;
2929
 
                        push2 = tempax;
2930
 
 
2931
 
                        /* GetLCDResInfo */
2932
 
                        if ((pVBInfo->LCDResInfo == Panel1024x768) ||
2933
 
                            (pVBInfo->LCDResInfo == Panel1024x768x75)) {
2934
 
                                tempax = 1024;
2935
 
                                tempbx = 768;
2936
 
                        } else if ((pVBInfo->LCDResInfo == Panel1280x1024) ||
2937
 
                                   (pVBInfo->LCDResInfo == Panel1280x1024x75)) {
2938
 
                                tempax = 1280;
2939
 
                                tempbx = 1024;
2940
 
                        } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2941
 
                                tempax = 1400;
2942
 
                                tempbx = 1050;
2943
 
                        } else {
2944
 
                                tempax = 1600;
2945
 
                                tempbx = 1200;
2946
 
                        }
2947
 
 
2948
 
                        if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
2949
 
                                pVBInfo->HDE = tempax;
2950
 
                                pVBInfo->VDE = tempbx;
2951
 
                                pVBInfo->VGAHDE = tempax;
2952
 
                                pVBInfo->VGAVDE = tempbx;
2953
 
                        }
2954
 
 
2955
 
                        if ((pVBInfo->IF_DEF_ScaleLCD == 1) &&
2956
 
                            (pVBInfo->LCDInfo & EnableScalingLCD)) {
2957
 
                                tempax = pVBInfo->HDE;
2958
 
                                tempbx = pVBInfo->VDE;
2959
 
                        }
2960
 
 
2961
 
                        tempax = pVBInfo->HT;
2962
 
 
2963
 
                        if (pVBInfo->LCDInfo & EnableScalingLCD)
2964
 
                                tempbx = LCDPtr1->LCDHDES;
2965
 
                        else
2966
 
                                tempbx = LCDPtr->LCDHDES;
2967
 
 
2968
 
                        tempcx = pVBInfo->HDE;
2969
 
                        tempbx = tempbx & 0x0fff;
2970
 
                        tempcx += tempbx;
2971
 
 
2972
 
                        if (tempcx >= tempax)
2973
 
                                tempcx -= tempax;
2974
 
 
2975
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
2976
 
 
2977
 
                        tempcx = tempcx >> 3;
2978
 
                        tempbx = tempbx >> 3;
2979
 
 
2980
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x16,
2981
 
                                        (unsigned short) (tempbx & 0xff));
2982
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x17,
2983
 
                                        (unsigned short) (tempcx & 0xff));
2984
 
 
2985
 
                        tempax = pVBInfo->HT;
2986
 
 
2987
 
                        if (pVBInfo->LCDInfo & EnableScalingLCD)
2988
 
                                tempbx = LCDPtr1->LCDHRS;
2989
 
                        else
2990
 
                                tempbx = LCDPtr->LCDHRS;
2991
 
 
2992
 
                        tempcx = push2;
2993
 
 
2994
 
                        if (pVBInfo->LCDInfo & EnableScalingLCD)
2995
 
                                tempcx = LCDPtr1->LCDHSync;
2996
 
 
2997
 
                        tempcx += tempbx;
2998
 
 
2999
 
                        if (tempcx >= tempax)
3000
 
                                tempcx -= tempax;
3001
 
 
3002
 
                        tempax = tempbx & 0x07;
3003
 
                        tempax = tempax >> 5;
3004
 
                        tempcx = tempcx >> 3;
3005
 
                        tempbx = tempbx >> 3;
3006
 
 
3007
 
                        tempcx &= 0x1f;
3008
 
                        tempax |= tempcx;
3009
 
 
3010
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax);
3011
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x14,
3012
 
                                        (unsigned short) (tempbx & 0xff));
3013
 
 
3014
 
                        tempax = pVBInfo->VT;
3015
 
                        if (pVBInfo->LCDInfo & EnableScalingLCD)
3016
 
                                tempbx = LCDPtr1->LCDVDES;
3017
 
                        else
3018
 
                                tempbx = LCDPtr->LCDVDES;
3019
 
                        tempcx = pVBInfo->VDE;
3020
 
 
3021
 
                        tempbx = tempbx & 0x0fff;
3022
 
                        tempcx += tempbx;
3023
 
                        if (tempcx >= tempax)
3024
 
                                tempcx -= tempax;
3025
 
 
3026
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x1b,
3027
 
                                        (unsigned short) (tempbx & 0xff));
3028
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x1c,
3029
 
                                        (unsigned short) (tempcx & 0xff));
3030
 
 
3031
 
                        tempbx = (tempbx >> 8) & 0x07;
3032
 
                        tempcx = (tempcx >> 8) & 0x07;
3033
 
 
3034
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x1d,
3035
 
                                        (unsigned short) ((tempcx << 3)
3036
 
                                                        | tempbx));
3037
 
 
3038
 
                        tempax = pVBInfo->VT;
3039
 
                        if (pVBInfo->LCDInfo & EnableScalingLCD)
3040
 
                                tempbx = LCDPtr1->LCDVRS;
3041
 
                        else
3042
 
                                tempbx = LCDPtr->LCDVRS;
3043
 
 
3044
 
                        /* tempbx = tempbx >> 4; */
3045
 
                        tempcx = push1;
3046
 
 
3047
 
                        if (pVBInfo->LCDInfo & EnableScalingLCD)
3048
 
                                tempcx = LCDPtr1->LCDVSync;
3049
 
 
3050
 
                        tempcx += tempbx;
3051
 
                        if (tempcx >= tempax)
3052
 
                                tempcx -= tempax;
3053
 
 
3054
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x18,
3055
 
                                        (unsigned short) (tempbx & 0xff));
3056
 
                        xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f,
3057
 
                                        (unsigned short) (tempcx & 0x0f));
3058
 
 
3059
 
                        tempax = ((tempbx >> 8) & 0x07) << 3;
3060
 
 
3061
 
                        tempbx = pVBInfo->VGAVDE;
3062
 
                        if (tempbx != pVBInfo->VDE)
3063
 
                                tempax |= 0x40;
3064
 
 
3065
 
                        if (pVBInfo->LCDInfo & EnableLVDSDDA)
3066
 
                                tempax |= 0x40;
3067
 
 
3068
 
                        xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07,
3069
 
                                        tempax);
3070
 
 
3071
 
                        tempcx = pVBInfo->VGAVT;
3072
 
                        tempbx = pVBInfo->VDE;
3073
 
                        tempax = pVBInfo->VGAVDE;
3074
 
                        tempcx -= tempax;
3075
 
 
3076
 
                        temp = tempax; /* 0430 ylshieh */
3077
 
                        temp1 = (temp << 18) / tempbx;
3078
 
 
3079
 
                        tempdx = (unsigned short) ((temp << 18) % tempbx);
3080
 
 
3081
 
                        if (tempdx != 0)
3082
 
                                temp1 += 1;
3083
 
 
3084
 
                        temp2 = temp1;
3085
 
                        push3 = temp2;
3086
 
 
3087
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x37,
3088
 
                                        (unsigned short) (temp2 & 0xff));
3089
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x36,
3090
 
                                        (unsigned short) ((temp2 >> 8) & 0xff));
3091
 
 
3092
 
                        tempbx = (unsigned short) (temp2 >> 16);
3093
 
                        tempax = tempbx & 0x03;
3094
 
 
3095
 
                        tempbx = pVBInfo->VGAVDE;
3096
 
                        if (tempbx == pVBInfo->VDE)
3097
 
                                tempax |= 0x04;
3098
 
 
3099
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax);
3100
 
 
3101
 
                        if (pVBInfo->VBType & VB_XGI301C) {
3102
 
                                temp2 = push3;
3103
 
                                xgifb_reg_set(pVBInfo->Part4Port,
3104
 
                                              0x3c,
3105
 
                                              (unsigned short) (temp2 & 0xff));
3106
 
                                xgifb_reg_set(pVBInfo->Part4Port,
3107
 
                                              0x3b,
3108
 
                                              (unsigned short) ((temp2 >> 8) &
3109
 
                                              0xff));
3110
 
                                tempbx = (unsigned short) (temp2 >> 16);
3111
 
                                xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a,
3112
 
                                                ~0xc0,
3113
 
                                                (unsigned short) ((tempbx &
3114
 
                                                                   0xff) << 6));
3115
 
 
3116
 
                                tempcx = pVBInfo->VGAVDE;
3117
 
                                if (tempcx == pVBInfo->VDE)
3118
 
                                        xgifb_reg_and_or(pVBInfo->Part4Port,
3119
 
                                                        0x30, ~0x0c, 0x00);
3120
 
                                else
3121
 
                                        xgifb_reg_and_or(pVBInfo->Part4Port,
3122
 
                                                        0x30, ~0x0c, 0x08);
3123
 
                        }
3124
 
 
3125
 
                        tempcx = pVBInfo->VGAHDE;
3126
 
                        tempbx = pVBInfo->HDE;
3127
 
 
3128
 
                        temp1 = tempcx << 16;
3129
 
 
3130
 
                        tempax = (unsigned short) (temp1 / tempbx);
3131
 
 
3132
 
                        if ((tempbx & 0xffff) == (tempcx & 0xffff))
3133
 
                                tempax = 65535;
3134
 
 
3135
 
                        temp3 = tempax;
3136
 
                        temp1 = pVBInfo->VGAHDE << 16;
3137
 
 
3138
 
                        temp1 /= temp3;
3139
 
                        temp3 = temp3 << 16;
3140
 
                        temp1 -= 1;
3141
 
 
3142
 
                        temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
3143
 
 
3144
 
                        tempax = (unsigned short) (temp3 & 0xff);
3145
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax);
3146
 
 
3147
 
                        temp1 = pVBInfo->VGAVDE << 18;
3148
 
                        temp1 = temp1 / push3;
3149
 
                        tempbx = (unsigned short) (temp1 & 0xffff);
3150
 
 
3151
 
                        if (pVBInfo->LCDResInfo == Panel1024x768)
3152
 
                                tempbx -= 1;
3153
 
 
3154
 
                        tempax = ((tempbx >> 8) & 0xff) << 3;
3155
 
                        tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
3156
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x20,
3157
 
                                        (unsigned short) (tempax & 0xff));
3158
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x21,
3159
 
                                        (unsigned short) (tempbx & 0xff));
3160
 
 
3161
 
                        temp3 = temp3 >> 16;
3162
 
 
3163
 
                        if (modeflag & HalfDCLK)
3164
 
                                temp3 = temp3 >> 1;
3165
 
 
3166
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x22,
3167
 
                                        (unsigned short) ((temp3 >> 8) & 0xff));
3168
 
                        xgifb_reg_set(pVBInfo->Part1Port, 0x23,
3169
 
                                        (unsigned short) (temp3 & 0xff));
3170
 
                }
3171
 
        }
 
2613
        tempbx = 3;
 
2614
        if (pVBInfo->LCDInfo & EnableScalingLCD)
 
2615
                LCDPtr1 =
 
2616
                    (struct XGI330_LCDDataDesStruct2 *)
 
2617
                                XGI_GetLcdPtr(
 
2618
                                          tempbx,
 
2619
                                          ModeNo,
 
2620
                                          ModeIdIndex,
 
2621
                                          RefreshRateTableIndex,
 
2622
                                          pVBInfo);
 
2623
        else
 
2624
                LCDPtr =
 
2625
                    (struct XGI330_LCDDataDesStruct *)
 
2626
                                XGI_GetLcdPtr(
 
2627
                                          tempbx,
 
2628
                                          ModeNo,
 
2629
                                          ModeIdIndex,
 
2630
                                          RefreshRateTableIndex,
 
2631
                                          pVBInfo);
 
2632
 
 
2633
        XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
 
2634
        push1 = tempbx;
 
2635
        push2 = tempax;
 
2636
 
 
2637
        /* GetLCDResInfo */
 
2638
        if ((pVBInfo->LCDResInfo == Panel1024x768) ||
 
2639
            (pVBInfo->LCDResInfo == Panel1024x768x75)) {
 
2640
                tempax = 1024;
 
2641
                tempbx = 768;
 
2642
        } else if ((pVBInfo->LCDResInfo == Panel1280x1024) ||
 
2643
                   (pVBInfo->LCDResInfo == Panel1280x1024x75)) {
 
2644
                tempax = 1280;
 
2645
                tempbx = 1024;
 
2646
        } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
 
2647
                tempax = 1400;
 
2648
                tempbx = 1050;
 
2649
        } else {
 
2650
                tempax = 1600;
 
2651
                tempbx = 1200;
 
2652
        }
 
2653
 
 
2654
        if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
 
2655
                pVBInfo->HDE = tempax;
 
2656
                pVBInfo->VDE = tempbx;
 
2657
                pVBInfo->VGAHDE = tempax;
 
2658
                pVBInfo->VGAVDE = tempbx;
 
2659
        }
 
2660
 
 
2661
        tempax = pVBInfo->HT;
 
2662
 
 
2663
        if (pVBInfo->LCDInfo & EnableScalingLCD)
 
2664
                tempbx = LCDPtr1->LCDHDES;
 
2665
        else
 
2666
                tempbx = LCDPtr->LCDHDES;
 
2667
 
 
2668
        tempcx = pVBInfo->HDE;
 
2669
        tempbx = tempbx & 0x0fff;
 
2670
        tempcx += tempbx;
 
2671
 
 
2672
        if (tempcx >= tempax)
 
2673
                tempcx -= tempax;
 
2674
 
 
2675
        xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
 
2676
 
 
2677
        tempcx = tempcx >> 3;
 
2678
        tempbx = tempbx >> 3;
 
2679
 
 
2680
        xgifb_reg_set(pVBInfo->Part1Port, 0x16,
 
2681
                        (unsigned short) (tempbx & 0xff));
 
2682
        xgifb_reg_set(pVBInfo->Part1Port, 0x17,
 
2683
                        (unsigned short) (tempcx & 0xff));
 
2684
 
 
2685
        tempax = pVBInfo->HT;
 
2686
 
 
2687
        if (pVBInfo->LCDInfo & EnableScalingLCD)
 
2688
                tempbx = LCDPtr1->LCDHRS;
 
2689
        else
 
2690
                tempbx = LCDPtr->LCDHRS;
 
2691
 
 
2692
        tempcx = push2;
 
2693
 
 
2694
        if (pVBInfo->LCDInfo & EnableScalingLCD)
 
2695
                tempcx = LCDPtr1->LCDHSync;
 
2696
 
 
2697
        tempcx += tempbx;
 
2698
 
 
2699
        if (tempcx >= tempax)
 
2700
                tempcx -= tempax;
 
2701
 
 
2702
        tempax = tempbx & 0x07;
 
2703
        tempax = tempax >> 5;
 
2704
        tempcx = tempcx >> 3;
 
2705
        tempbx = tempbx >> 3;
 
2706
 
 
2707
        tempcx &= 0x1f;
 
2708
        tempax |= tempcx;
 
2709
 
 
2710
        xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax);
 
2711
        xgifb_reg_set(pVBInfo->Part1Port, 0x14,
 
2712
                        (unsigned short) (tempbx & 0xff));
 
2713
 
 
2714
        tempax = pVBInfo->VT;
 
2715
        if (pVBInfo->LCDInfo & EnableScalingLCD)
 
2716
                tempbx = LCDPtr1->LCDVDES;
 
2717
        else
 
2718
                tempbx = LCDPtr->LCDVDES;
 
2719
        tempcx = pVBInfo->VDE;
 
2720
 
 
2721
        tempbx = tempbx & 0x0fff;
 
2722
        tempcx += tempbx;
 
2723
        if (tempcx >= tempax)
 
2724
                tempcx -= tempax;
 
2725
 
 
2726
        xgifb_reg_set(pVBInfo->Part1Port, 0x1b,
 
2727
                        (unsigned short) (tempbx & 0xff));
 
2728
        xgifb_reg_set(pVBInfo->Part1Port, 0x1c,
 
2729
                        (unsigned short) (tempcx & 0xff));
 
2730
 
 
2731
        tempbx = (tempbx >> 8) & 0x07;
 
2732
        tempcx = (tempcx >> 8) & 0x07;
 
2733
 
 
2734
        xgifb_reg_set(pVBInfo->Part1Port, 0x1d,
 
2735
                        (unsigned short) ((tempcx << 3)
 
2736
                                        | tempbx));
 
2737
 
 
2738
        tempax = pVBInfo->VT;
 
2739
        if (pVBInfo->LCDInfo & EnableScalingLCD)
 
2740
                tempbx = LCDPtr1->LCDVRS;
 
2741
        else
 
2742
                tempbx = LCDPtr->LCDVRS;
 
2743
 
 
2744
        /* tempbx = tempbx >> 4; */
 
2745
        tempcx = push1;
 
2746
 
 
2747
        if (pVBInfo->LCDInfo & EnableScalingLCD)
 
2748
                tempcx = LCDPtr1->LCDVSync;
 
2749
 
 
2750
        tempcx += tempbx;
 
2751
        if (tempcx >= tempax)
 
2752
                tempcx -= tempax;
 
2753
 
 
2754
        xgifb_reg_set(pVBInfo->Part1Port, 0x18,
 
2755
                        (unsigned short) (tempbx & 0xff));
 
2756
        xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f,
 
2757
                        (unsigned short) (tempcx & 0x0f));
 
2758
 
 
2759
        tempax = ((tempbx >> 8) & 0x07) << 3;
 
2760
 
 
2761
        tempbx = pVBInfo->VGAVDE;
 
2762
        if (tempbx != pVBInfo->VDE)
 
2763
                tempax |= 0x40;
 
2764
 
 
2765
        if (pVBInfo->LCDInfo & EnableLVDSDDA)
 
2766
                tempax |= 0x40;
 
2767
 
 
2768
        xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07,
 
2769
                                tempax);
 
2770
 
 
2771
        tempcx = pVBInfo->VGAVT;
 
2772
        tempbx = pVBInfo->VDE;
 
2773
        tempax = pVBInfo->VGAVDE;
 
2774
        tempcx -= tempax;
 
2775
 
 
2776
        temp = tempax; /* 0430 ylshieh */
 
2777
        temp1 = (temp << 18) / tempbx;
 
2778
 
 
2779
        tempdx = (unsigned short) ((temp << 18) % tempbx);
 
2780
 
 
2781
        if (tempdx != 0)
 
2782
                temp1 += 1;
 
2783
 
 
2784
        temp2 = temp1;
 
2785
        push3 = temp2;
 
2786
 
 
2787
        xgifb_reg_set(pVBInfo->Part1Port, 0x37,
 
2788
                        (unsigned short) (temp2 & 0xff));
 
2789
        xgifb_reg_set(pVBInfo->Part1Port, 0x36,
 
2790
                        (unsigned short) ((temp2 >> 8) & 0xff));
 
2791
 
 
2792
        tempbx = (unsigned short) (temp2 >> 16);
 
2793
        tempax = tempbx & 0x03;
 
2794
 
 
2795
        tempbx = pVBInfo->VGAVDE;
 
2796
        if (tempbx == pVBInfo->VDE)
 
2797
                tempax |= 0x04;
 
2798
 
 
2799
        xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax);
 
2800
 
 
2801
        if (pVBInfo->VBType & VB_XGI301C) {
 
2802
                temp2 = push3;
 
2803
                xgifb_reg_set(pVBInfo->Part4Port,
 
2804
                              0x3c,
 
2805
                              (unsigned short) (temp2 & 0xff));
 
2806
                xgifb_reg_set(pVBInfo->Part4Port,
 
2807
                              0x3b,
 
2808
                              (unsigned short) ((temp2 >> 8) &
 
2809
                              0xff));
 
2810
                tempbx = (unsigned short) (temp2 >> 16);
 
2811
                xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a,
 
2812
                                ~0xc0,
 
2813
                                (unsigned short) ((tempbx &
 
2814
                                                   0xff) << 6));
 
2815
 
 
2816
                tempcx = pVBInfo->VGAVDE;
 
2817
                if (tempcx == pVBInfo->VDE)
 
2818
                        xgifb_reg_and_or(pVBInfo->Part4Port,
 
2819
                                        0x30, ~0x0c, 0x00);
 
2820
                else
 
2821
                        xgifb_reg_and_or(pVBInfo->Part4Port,
 
2822
                                        0x30, ~0x0c, 0x08);
 
2823
        }
 
2824
 
 
2825
        tempcx = pVBInfo->VGAHDE;
 
2826
        tempbx = pVBInfo->HDE;
 
2827
 
 
2828
        temp1 = tempcx << 16;
 
2829
 
 
2830
        tempax = (unsigned short) (temp1 / tempbx);
 
2831
 
 
2832
        if ((tempbx & 0xffff) == (tempcx & 0xffff))
 
2833
                tempax = 65535;
 
2834
 
 
2835
        temp3 = tempax;
 
2836
        temp1 = pVBInfo->VGAHDE << 16;
 
2837
 
 
2838
        temp1 /= temp3;
 
2839
        temp3 = temp3 << 16;
 
2840
        temp1 -= 1;
 
2841
 
 
2842
        temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
 
2843
 
 
2844
        tempax = (unsigned short) (temp3 & 0xff);
 
2845
        xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax);
 
2846
 
 
2847
        temp1 = pVBInfo->VGAVDE << 18;
 
2848
        temp1 = temp1 / push3;
 
2849
        tempbx = (unsigned short) (temp1 & 0xffff);
 
2850
 
 
2851
        if (pVBInfo->LCDResInfo == Panel1024x768)
 
2852
                tempbx -= 1;
 
2853
 
 
2854
        tempax = ((tempbx >> 8) & 0xff) << 3;
 
2855
        tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
 
2856
        xgifb_reg_set(pVBInfo->Part1Port, 0x20,
 
2857
                        (unsigned short) (tempax & 0xff));
 
2858
        xgifb_reg_set(pVBInfo->Part1Port, 0x21,
 
2859
                        (unsigned short) (tempbx & 0xff));
 
2860
 
 
2861
        temp3 = temp3 >> 16;
 
2862
 
 
2863
        if (modeflag & HalfDCLK)
 
2864
                temp3 = temp3 >> 1;
 
2865
 
 
2866
        xgifb_reg_set(pVBInfo->Part1Port, 0x22,
 
2867
                        (unsigned short) ((temp3 >> 8) & 0xff));
 
2868
        xgifb_reg_set(pVBInfo->Part1Port, 0x23,
 
2869
                        (unsigned short) (temp3 & 0xff));
3172
2870
}
3173
2871
 
3174
2872
/* --------------------------------------------------------------------- */
3183
2881
        unsigned short index;
3184
2882
 
3185
2883
        if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
3186
 
                if (pVBInfo->IF_DEF_ScaleLCD == 1) {
3187
 
                        if (pVBInfo->LCDInfo & EnableScalingLCD)
3188
 
                                return;
3189
 
                }
3190
 
 
3191
2884
                /* index = XGI_GetLCDCapPtr(pVBInfo); */
3192
2885
                index = XGI_GetLCDCapPtr1(pVBInfo);
3193
2886
 
3208
2901
{
3209
2902
 
3210
2903
        unsigned short index, modeflag;
3211
 
        unsigned short tempbx;
3212
2904
        unsigned char tempal;
3213
 
        unsigned char *CHTVVCLKPtr = NULL;
3214
2905
 
3215
2906
        if (ModeNo <= 0x13)
3216
2907
                /* si+St_ResInfo */
3268
2959
                        if (pVBInfo->VBInfo & SetCRT2ToTV)
3269
2960
                                return tempal;
3270
2961
                }
3271
 
                /* else if ((pVBInfo->IF_DEF_CH7017==1) &&
3272
 
                            (pVBInfo->VBType&VB_CH7017)) {
3273
 
                        if (ModeNo<=0x13)
3274
 
                                *tempal = pVBInfo->SModeIDTable[ModeIdIndex].
3275
 
                                                St_CRT2CRTC;
3276
 
                        else
3277
 
                                *tempal = pVBInfo->RefIndex[
3278
 
                                        RefreshRateTableIndex].Ext_CRT2CRTC;
3279
 
                        *tempal = *tempal & 0x1F;
3280
 
                        tempbx = 0;
3281
 
                        if (pVBInfo->TVInfo & SetPALTV)
3282
 
                                tempbx = tempbx + 2;
3283
 
                        if (pVBInfo->TVInfo & SetCHTVOverScan)
3284
 
                                tempbx++;
3285
 
                        tempbx = tempbx << 1;
3286
 
                } */
3287
2962
        } /* {End of VB} */
3288
2963
 
3289
 
        if ((pVBInfo->IF_DEF_CH7007 == 1) &&
3290
 
            (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */
3291
 
                /* VideoDebugPrint((
3292
 
                        0,
3293
 
                        "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
3294
 
                if ((pVBInfo->VBInfo & SetCRT2ToTV)) {
3295
 
                        if (ModeNo <= 0x13) {
3296
 
                                tempal = pVBInfo->SModeIDTable[ModeIdIndex].
3297
 
                                        St_CRT2CRTC;
3298
 
                        } else {
3299
 
                                tempal = pVBInfo->RefIndex[
3300
 
                                        RefreshRateTableIndex].Ext_CRT2CRTC;
3301
 
                        }
3302
 
 
3303
 
                        tempal = tempal & 0x0F;
3304
 
                        tempbx = 0;
3305
 
 
3306
 
                        if (pVBInfo->TVInfo & SetPALTV)
3307
 
                                tempbx = tempbx + 2;
3308
 
 
3309
 
                        if (pVBInfo->TVInfo & SetCHTVOverScan)
3310
 
                                tempbx++;
3311
 
 
3312
 
                        /** tempbx = tempbx << 1; CH7007 ? **/
3313
 
 
3314
 
                        /* [Billy]07/05/29 CH7007 */
3315
 
                        if (pVBInfo->IF_DEF_CH7007 == 1) {
3316
 
                                switch (tempbx) {
3317
 
                                case 0:
3318
 
                                        CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC;
3319
 
                                        break;
3320
 
                                case 1:
3321
 
                                        CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC;
3322
 
                                        break;
3323
 
                                case 2:
3324
 
                                        CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL;
3325
 
                                        break;
3326
 
                                case 3:
3327
 
                                        CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL;
3328
 
                                        break;
3329
 
                                default:
3330
 
                                        break;
3331
 
 
3332
 
                                }
3333
 
                        }
3334
 
                        /* else {
3335
 
                                switch(tempbx) {
3336
 
                                case 0:
3337
 
                                        CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
3338
 
                                        break;
3339
 
                                case 1:
3340
 
                                        CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
3341
 
                                        break;
3342
 
                                case 2:
3343
 
                                        CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
3344
 
                                        break;
3345
 
                                case 3:
3346
 
                                        CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
3347
 
                                        break;
3348
 
                                default:
3349
 
                                        break;
3350
 
                                }
3351
 
                        }
3352
 
                        */
3353
 
 
3354
 
                        tempal = CHTVVCLKPtr[tempal];
3355
 
                        return tempal;
3356
 
                }
3357
 
 
3358
 
        }
3359
 
 
3360
2964
        tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02));
3361
2965
        tempal = tempal >> 2;
3362
2966
        tempal &= 0x03;
3375
2979
static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
3376
2980
                unsigned char *di_1, struct vb_device_info *pVBInfo)
3377
2981
{
3378
 
        if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */
3379
 
                /* VideoDebugPrint((
3380
 
                        0,
3381
 
                        "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
3382
 
                *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B;
3383
 
                *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C;
3384
 
        } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
 
2982
        if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
3385
2983
                        | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
3386
2984
                if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag
3387
2985
                                & ProgrammingCRT2)) {
3409
3007
        for (i = 0; i < 4; i++) {
3410
3008
                xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30,
3411
3009
                                (unsigned short) (0x10 * i));
3412
 
                if (pVBInfo->IF_DEF_CH7007 == 1) {
3413
 
                        xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0);
3414
 
                        xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1);
3415
 
                } else if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
 
3010
                if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
3416
3011
                                && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
3417
3012
                        xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0);
3418
3013
                        xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1);
3527
3122
{
3528
3123
        unsigned short flag, tempbx, tempah;
3529
3124
 
3530
 
        if (pVBInfo->IF_DEF_CH7007 == 1) {
3531
 
                pVBInfo->VBType = VB_CH7007;
3532
 
                return;
3533
 
        }
3534
3125
        if (pVBInfo->IF_DEF_LVDS == 0) {
3535
3126
                tempbx = VB_XGI302B;
3536
3127
                flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
3567
3158
                }
3568
3159
                pVBInfo->VBType = tempbx;
3569
3160
        }
3570
 
        /*
3571
 
        else if (pVBInfo->IF_DEF_CH7017 == 1)
3572
 
                pVBInfo->VBType = VB_CH7017;
3573
 
        else //LVDS
3574
 
                pVBInfo->VBType = VB_LVDS_NS;
3575
 
         */
3576
 
 
3577
3161
}
3578
3162
 
3579
3163
void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3631
3215
                                                                  SetCRT2ToLCDA;
3632
3216
                                                }
3633
3217
                                        }
3634
 
                                } else if (pVBInfo->IF_DEF_CH7017 == 1) {
3635
 
                                        if (pVBInfo->VBType & VB_CH7017) {
3636
 
                                                if (temp & EnableDualEdge) {
3637
 
                                                        tempbx |=
3638
 
                                                            SetCRT2ToDualEdge;
3639
 
 
3640
 
                                                        if (temp & SetToLCDA)
3641
 
                                                                tempbx |=
3642
 
                                                                  SetCRT2ToLCDA;
3643
 
                                                }
3644
 
                                        }
3645
3218
                                }
3646
3219
                        }
3647
3220
                }
3651
3224
                        if (((pVBInfo->IF_DEF_LVDS == 0) &&
3652
3225
                            ((pVBInfo->VBType & VB_XGI301LV) ||
3653
3226
                            (pVBInfo->VBType & VB_XGI302LV) ||
3654
 
                            (pVBInfo->VBType & VB_XGI301C))) ||
3655
 
                            ((pVBInfo->IF_DEF_CH7017 == 1) &&
3656
 
                            (pVBInfo->VBType & VB_CH7017)) ||
3657
 
                            ((pVBInfo->IF_DEF_CH7007 == 1) &&
3658
 
                            (pVBInfo->VBType & VB_CH7007))) {
 
3227
                            (pVBInfo->VBType & VB_XGI301C)))) {
3659
3228
                                if (temp & SetYPbPr) { /* temp = CR38 */
3660
3229
                                        if (pVBInfo->IF_DEF_HiVision == 1) {
3661
3230
                                                /* shampoo add for new
3694
3263
                                        temp = 0x017C;
3695
3264
                        }
3696
3265
                } else { /* 3nd party chip */
3697
 
                        if (pVBInfo->IF_DEF_CH7017 == 1)
3698
 
                                temp = (SetCRT2ToTV |
3699
 
                                        SetCRT2ToLCD |
3700
 
                                        SetCRT2ToLCDA);
3701
 
                        /* [Billy] 07/05/03 */
3702
 
                        else if (pVBInfo->IF_DEF_CH7007 == 1)
3703
 
                                temp = SetCRT2ToTV;
3704
 
                        else
3705
 
                                temp = SetCRT2ToLCD;
 
3266
                        temp = SetCRT2ToLCD;
3706
3267
                }
3707
3268
 
3708
3269
                if (!(tempbx & temp)) {
3790
3351
                                                tempbx |= (SetInSlaveMode |
3791
3352
                                                           SetSimuScanMode);
3792
3353
                                }
3793
 
 
3794
 
                                if (pVBInfo->IF_DEF_VideoCapture == 1) {
3795
 
                                        if (((HwDeviceExtension->jChipType ==
3796
 
                                              XG40) &&
3797
 
                                             (pVBInfo->Set_VGAType == XG40)) ||
3798
 
                                            ((HwDeviceExtension->jChipType ==
3799
 
                                              XG41) &&
3800
 
                                             (pVBInfo->Set_VGAType == XG41)) ||
3801
 
                                            ((HwDeviceExtension->jChipType ==
3802
 
                                              XG42) &&
3803
 
                                             (pVBInfo->Set_VGAType == XG42)) ||
3804
 
                                            ((HwDeviceExtension->jChipType ==
3805
 
                                              XG45) &&
3806
 
                                             (pVBInfo->Set_VGAType == XG45))) {
3807
 
                                                if (ModeNo <= 13) {
3808
 
                                                        if (!(tempbx &
3809
 
                                                             SetCRT2ToRAMDAC)) {
3810
 
                                                                /*CRT2 not need
3811
 
                                                                 * to support*/
3812
 
                                                                tempbx &=
3813
 
                                                                  (0x00FF |
3814
 
                                                                  (~SetInSlaveMode));
3815
 
                                                                pVBInfo->SetFlag
3816
 
                                                                                |= EnableVCMode;
3817
 
                                                        }
3818
 
                                                }
3819
 
                                        }
3820
 
                                }
3821
3354
                        }
3822
3355
 
3823
3356
                        /* LCD+TV can't support in slave mode
3884
3417
                        */
3885
3418
                }
3886
3419
 
3887
 
                if (pVBInfo->IF_DEF_CH7017 == 1) {
3888
 
                        tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3889
 
 
3890
 
                        if (tempbx & TVOverScan)
3891
 
                                tempbx |= SetCHTVOverScan;
3892
 
                }
3893
 
 
3894
 
                if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */
3895
 
                        tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3896
 
 
3897
 
                        if (tempbx & TVOverScan)
3898
 
                                tempbx |= SetCHTVOverScan;
3899
 
                }
3900
 
 
3901
3420
                if (pVBInfo->IF_DEF_LVDS == 0) {
3902
3421
                        if (pVBInfo->VBInfo & SetCRT2ToSCART)
3903
3422
                                tempbx |= SetPALTV;
4004
3523
 
4005
3524
        /* End of LCD75 */
4006
3525
 
4007
 
        if (pVBInfo->IF_DEF_OEMUtil == 1)
4008
 
                pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4;
4009
 
 
4010
3526
        if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
4011
3527
                return 0;
4012
3528
 
4016
3532
 
4017
3533
        temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
4018
3534
 
4019
 
        if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding))
4020
 
                temp &= ~EnableScalingLCD;
4021
 
 
4022
3535
        tempbx |= temp;
4023
3536
 
4024
3537
        LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
4032
3545
                }
4033
3546
        }
4034
3547
 
4035
 
        if (pVBInfo->IF_DEF_CH7017 == 1) {
4036
 
                if (tempax & LCDDualLink)
4037
 
                        tempbx |= SetLCDDualLink;
4038
 
        }
4039
 
 
4040
3548
        if (pVBInfo->IF_DEF_LVDS == 0) {
4041
3549
                if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo
4042
3550
                                & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo
4078
3586
 
4079
3587
        pVBInfo->LCDInfo = tempbx;
4080
3588
 
4081
 
        if (pVBInfo->IF_DEF_PWD == 1) {
4082
 
                if (pVBInfo->LCDInfo & SetPWDEnable) {
4083
 
                        if ((pVBInfo->VBType & VB_XGI302LV) ||
4084
 
                            (pVBInfo->VBType & VB_XGI301C)) {
4085
 
                                if (!(tempax & PWDEnable))
4086
 
                                        pVBInfo->LCDInfo &= ~SetPWDEnable;
4087
 
                        }
4088
 
                }
4089
 
        }
4090
 
 
4091
3589
        if (pVBInfo->IF_DEF_LVDS == 0) {
4092
3590
                if (tempax & (LockLCDBToA | StLCDBToA)) {
4093
3591
                        if (pVBInfo->VBInfo & SetInSlaveMode) {
4170
3668
        return 1;
4171
3669
}
4172
3670
 
4173
 
/* win2000 MM adapter not support standard mode! */
4174
 
 
4175
 
#if 0
4176
 
static unsigned char XGINew_CheckMemorySize(
4177
 
                struct xgi_hw_device_info *HwDeviceExtension,
4178
 
                unsigned short ModeNo,
4179
 
                unsigned short ModeIdIndex,
4180
 
                struct vb_device_info *pVBInfo)
4181
 
{
4182
 
        unsigned short memorysize, modeflag, temp, temp1, tmp;
4183
 
 
4184
 
        /*
4185
 
        if ((HwDeviceExtension->jChipType == XGI_650) ||
4186
 
        (HwDeviceExtension->jChipType == XGI_650M)) {
4187
 
                return 1;
4188
 
        }
4189
 
        */
4190
 
 
4191
 
        if (ModeNo <= 0x13)
4192
 
                modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4193
 
        else
4194
 
                modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4195
 
 
4196
 
        /* ModeType = modeflag&ModeInfoFlag; // Get mode type */
4197
 
 
4198
 
        memorysize = modeflag & MemoryInfoFlag;
4199
 
        memorysize = memorysize > MemorySizeShift;
4200
 
        memorysize++; /* Get memory size */
4201
 
 
4202
 
        temp = xgifb_reg_get(pVBInfo->P3c4, 0x14); /* Get DRAM Size */
4203
 
        tmp = temp;
4204
 
 
4205
 
        if (HwDeviceExtension->jChipType == XG40) {
4206
 
                /* memory size per channel SR14[7:4] */
4207
 
                temp = 1 << ((temp & 0x0F0) >> 4);
4208
 
                if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
4209
 
                        temp <<= 2;
4210
 
                } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */
4211
 
                        temp <<= 1;
4212
 
                }
4213
 
        } else if (HwDeviceExtension->jChipType == XG42) {
4214
 
                /* memory size per channel SR14[7:4] */
4215
 
                temp = 1 << ((temp & 0x0F0) >> 4);
4216
 
                if ((tmp & 0x04) == 0x04) { /* Dual channels */
4217
 
                        temp <<= 1;
4218
 
                }
4219
 
        } else if (HwDeviceExtension->jChipType == XG45) {
4220
 
                /* memory size per channel SR14[7:4] */
4221
 
                temp = 1 << ((temp & 0x0F0) >> 4);
4222
 
                if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
4223
 
                        temp <<= 2;
4224
 
                } else if ((tmp & 0x0c) == 0x08) { /* triple channels */
4225
 
                        temp1 = temp;
4226
 
                        temp <<= 1;
4227
 
                        temp += temp1;
4228
 
                } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */
4229
 
                        temp <<= 1;
4230
 
                }
4231
 
        }
4232
 
        if (temp < memorysize)
4233
 
                return 0;
4234
 
        else
4235
 
                return 1;
4236
 
}
4237
 
#endif
4238
 
 
4239
 
/*
4240
 
void XGINew_IsLowResolution(unsigned short ModeNo,
4241
 
                            unsigned short ModeIdIndex,
4242
 
                            unsigned char XGINew_CheckMemorySize(
4243
 
                                struct xgi_hw_device_info *HwDeviceExtension,
4244
 
                                unsigned short ModeNo,
4245
 
                                unsigned short ModeIdIndex,
4246
 
                                struct vb_device_info *pVBInfo)
4247
 
{
4248
 
        unsigned short data ;
4249
 
        unsigned short ModeFlag ;
4250
 
 
4251
 
        data = xgifb_reg_get(pVBInfo->P3c4, 0x0F);
4252
 
        data &= 0x7F;
4253
 
        xgifb_reg_set(pVBInfo->P3c4, 0x0F, data);
4254
 
 
4255
 
        if (ModeNo > 0x13) {
4256
 
                ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4257
 
                if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) {
4258
 
                        data = xgifb_reg_get(pVBInfo->P3c4, 0x0F);
4259
 
                        data |= 0x80;
4260
 
                        xgifb_reg_set(pVBInfo->P3c4, 0x0F, data);
4261
 
                        data = xgifb_reg_get(pVBInfo->P3c4, 0x01);
4262
 
                        data &= 0xF7;
4263
 
                        xgifb_reg_set(pVBInfo->P3c4, 0x01, data);
4264
 
                }
4265
 
        }
4266
 
}
4267
 
*/
4268
 
 
4269
3671
static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
4270
3672
{
4271
3673
        unsigned char ujRet = 0;
4349
3751
 
4350
3752
        }
4351
3753
 
4352
 
        /* [Billy] 07/05/23 For CH7007 */
4353
 
        if (pVBInfo->IF_DEF_CH7007 == 1) {
4354
 
        }
4355
 
 
4356
3754
        if (pXGIHWDE->jChipType == XG27) {
4357
3755
                if (pVBInfo->IF_DEF_LVDS == 1) {
4358
3756
                        if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
4389
3787
                }
4390
3788
        }
4391
3789
 
4392
 
        if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
4393
 
                /* if (IsCH7007TVMode(pVBInfo) == 0) */
4394
 
                {
4395
 
                }
4396
 
        }
4397
 
 
4398
3790
        if (pXGIHWDE->jChipType == XG27) {
4399
3791
                if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
4400
3792
                        /* LVDS backlight off */
4419
3811
                break;
4420
3812
}
4421
3813
 
4422
 
#if 0
4423
 
static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
4424
 
{
4425
 
        while (!(inb(pVBInfo->P3da) & 0x01))
4426
 
                ;
4427
 
        while (inb(pVBInfo->P3da) & 0x01)
4428
 
                ;
4429
 
}
4430
 
#endif
4431
 
 
4432
3814
static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
4433
3815
{
4434
 
        if (!(pVBInfo->SetFlag & Win9xDOSMode))
4435
 
                xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40);
 
3816
        xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40);
4436
3817
}
4437
3818
 
4438
3819
static void XGI_SaveCRT2Info(unsigned short ModeNo,
5027
4408
        tempcx = (pVBInfo->VGAVT - 1);
5028
4409
        temp = tempcx & 0x00FF;
5029
4410
 
5030
 
        if (pVBInfo->IF_DEF_CH7005 == 1) {
5031
 
                if (pVBInfo->VBInfo & 0x0C)
5032
 
                        temp--;
5033
 
        }
5034
 
 
5035
4411
        xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
5036
4412
        tempbx = pVBInfo->VGAVDE - 1;
5037
4413
        temp = tempbx & 0x00FF;
6177
5553
                tempbx = pVBInfo->VDE;
6178
5554
        }
6179
5555
 
6180
 
        if (tempax < tempbx)
6181
 
                return &EnlargeTap4Timing[0];
6182
 
        else if (tempax == tempbx)
6183
 
                return &NoScaleTap4Timing[0]; /* 1:1 */
 
5556
        if (tempax <= tempbx)
 
5557
                return &xgifb_tap4_timing[0];
6184
5558
        else
6185
 
                Tap4TimingPtr = NTSCTap4Timing; /* NTSC */
 
5559
                Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */
6186
5560
 
6187
5561
        if (pVBInfo->TVInfo & SetPALTV)
6188
5562
                Tap4TimingPtr = PALTap4Timing;
6189
5563
 
6190
5564
        if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
6191
 
                if (pVBInfo->TVInfo & SetYPbPrMode525i)
6192
 
                        Tap4TimingPtr = YPbPr525iTap4Timing;
6193
 
                if (pVBInfo->TVInfo & SetYPbPrMode525p)
6194
 
                        Tap4TimingPtr = YPbPr525pTap4Timing;
 
5565
                if ((pVBInfo->TVInfo & SetYPbPrMode525i) ||
 
5566
                        (pVBInfo->TVInfo & SetYPbPrMode525p))
 
5567
                        Tap4TimingPtr = xgifb_ntsc_525_tap4_timing;
6195
5568
                if (pVBInfo->TVInfo & SetYPbPrMode750p)
6196
5569
                        Tap4TimingPtr = YPbPr750pTap4Timing;
6197
5570
        }
6198
5571
 
6199
5572
        if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
6200
 
                Tap4TimingPtr = HiTVTap4Timing;
 
5573
                Tap4TimingPtr = xgifb_tap4_timing;
6201
5574
 
6202
5575
        i = 0;
6203
5576
        while (Tap4TimingPtr[i].DE != 0xFFFF) {
6217
5590
        if (!(pVBInfo->VBType & VB_XGI301C))
6218
5591
                return;
6219
5592
 
6220
 
#ifndef Tap4
6221
 
        xgifb_reg_and(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */
6222
 
#else            /* Tap4 Setting */
6223
 
 
6224
5593
        Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
6225
5594
        for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
6226
5595
                xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
6242
5611
        else
6243
5612
                /* Enable H.Scaling */
6244
5613
                xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10);
6245
 
#endif
6246
5614
}
6247
5615
 
6248
5616
static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
6743
6111
 
6744
6112
}
6745
6113
 
6746
 
static void XGI_SetXG21LVDSPara(unsigned short ModeNo,
6747
 
                                unsigned short ModeIdIndex,
6748
 
                                struct vb_device_info *pVBInfo)
6749
 
{
6750
 
        unsigned char temp, Miscdata;
6751
 
        unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6752
 
        unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6753
 
        unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6754
 
        unsigned short value;
6755
 
 
6756
 
        lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6757
 
 
6758
 
        temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].
6759
 
                                                LVDS_Capability &
6760
 
                                (LCDPolarity << 8)) >> 8);
6761
 
        temp &= LCDPolarity;
6762
 
        Miscdata = (unsigned char) inb(pVBInfo->P3cc);
6763
 
 
6764
 
        outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
6765
 
 
6766
 
        temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].
6767
 
                                                LVDS_Capability & LCDPolarity);
6768
 
        /* SR35[7] FP VSync polarity */
6769
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80);
6770
 
        /* SR30[5] FP HSync polarity */
6771
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
6772
 
 
6773
 
        XGI_SetXG21FPBits(pVBInfo);
6774
 
        resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6775
 
        if (ModeNo <= 0x13) {
6776
 
                xres = pVBInfo->StResInfo[resindex].HTotal;
6777
 
                yres = pVBInfo->StResInfo[resindex].VTotal;
6778
 
                /* si+St_ResInfo */
6779
 
                modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6780
 
        } else {
6781
 
                xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6782
 
                yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6783
 
                /* si+St_ModeFlag */
6784
 
                modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6785
 
        }
6786
 
 
6787
 
        if (!(modeflag & Charx8Dot))
6788
 
                xres = xres * 8 / 9;
6789
 
 
6790
 
        LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
6791
 
 
6792
 
        LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
6793
 
                        - xres) / 2;
6794
 
        if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
6795
 
                LVDSHBS -= xres / 4;
6796
 
 
6797
 
        if (LVDSHBS > LVDSHT)
6798
 
                LVDSHBS -= LVDSHT;
6799
 
 
6800
 
        LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
6801
 
        if (LVDSHRS > LVDSHT)
6802
 
                LVDSHRS -= LVDSHT;
6803
 
 
6804
 
        LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
6805
 
        if (LVDSHRE > LVDSHT)
6806
 
                LVDSHRE -= LVDSHT;
6807
 
 
6808
 
        LVDSHBE = LVDSHBS + LVDSHT
6809
 
                        - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
6810
 
 
6811
 
        LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
6812
 
 
6813
 
        LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
6814
 
                        - yres) / 2;
6815
 
        if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6816
 
                LVDSVBS += yres / 2;
6817
 
 
6818
 
        if (LVDSVBS > LVDSVT)
6819
 
                LVDSVBS -= LVDSVT;
6820
 
 
6821
 
        LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
6822
 
        if (LVDSVRS > LVDSVT)
6823
 
                LVDSVRS -= LVDSVT;
6824
 
 
6825
 
        LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
6826
 
        if (LVDSVRE > LVDSVT)
6827
 
                LVDSVRE -= LVDSVT;
6828
 
 
6829
 
        LVDSVBE = LVDSVBS + LVDSVT
6830
 
                        - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
6831
 
 
6832
 
        temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
6833
 
        xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
6834
 
 
6835
 
        if (!(modeflag & Charx8Dot))
6836
 
                xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1);
6837
 
 
6838
 
        /* HT SR0B[1:0] CR00 */
6839
 
        value = (LVDSHT >> 3) - 5;
6840
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
6841
 
        xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF));
6842
 
 
6843
 
        /* HBS SR0B[5:4] CR02 */
6844
 
        value = (LVDSHBS >> 3) - 1;
6845
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
6846
 
        xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF));
6847
 
 
6848
 
        /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
6849
 
        value = (LVDSHBE >> 3) - 1;
6850
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
6851
 
        xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
6852
 
        xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
6853
 
 
6854
 
        /* HRS SR0B[7:6] CR04 */
6855
 
        value = (LVDSHRS >> 3) + 2;
6856
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
6857
 
        xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF));
6858
 
 
6859
 
        /* Panel HRS SR2F[1:0] SR2E[7:0]  */
6860
 
        value--;
6861
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
6862
 
        xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF));
6863
 
 
6864
 
        /* HRE SR0C[2] CR05[4:0] */
6865
 
        value = (LVDSHRE >> 3) + 2;
6866
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
6867
 
        xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
6868
 
 
6869
 
        /* Panel HRE SR2F[7:2]  */
6870
 
        value--;
6871
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
6872
 
 
6873
 
        /* VT SR0A[0] CR07[5][0] CR06 */
6874
 
        value = LVDSVT - 2;
6875
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
6876
 
        xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
6877
 
        xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
6878
 
        xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF));
6879
 
 
6880
 
        /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
6881
 
        value = LVDSVBS - 1;
6882
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
6883
 
        xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
6884
 
        xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
6885
 
        xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF));
6886
 
 
6887
 
        /* VBE SR0A[4] CR16 */
6888
 
        value = LVDSVBE - 1;
6889
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
6890
 
        xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF));
6891
 
 
6892
 
        /* VRS SR0A[3] CR7[7][2] CR10 */
6893
 
        value = LVDSVRS - 1;
6894
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
6895
 
        xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
6896
 
        xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
6897
 
        xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
6898
 
 
6899
 
        /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
6900
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9);
6901
 
        xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
6902
 
        xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
6903
 
 
6904
 
        /* VRE SR0A[5] CR11[3:0] */
6905
 
        value = LVDSVRE - 1;
6906
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
6907
 
        xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
6908
 
 
6909
 
        /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */
6910
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C);
6911
 
 
6912
 
        for (temp = 0, value = 0; temp < 3; temp++) {
6913
 
 
6914
 
                xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
6915
 
                xgifb_reg_set(pVBInfo->P3c4,
6916
 
                              0x2B,
6917
 
                              pVBInfo->XG21_LVDSCapList[lvdstableindex].
6918
 
                                                VCLKData1);
6919
 
                xgifb_reg_set(pVBInfo->P3c4,
6920
 
                              0x2C,
6921
 
                              pVBInfo->XG21_LVDSCapList[lvdstableindex].
6922
 
                                                VCLKData2);
6923
 
                value += 0x10;
6924
 
        }
6925
 
 
6926
 
        if (!(modeflag & Charx8Dot)) {
6927
 
                inb(pVBInfo->P3da); /* reset 3da */
6928
 
                outb(0x13, pVBInfo->P3c0); /* set index */
6929
 
                /* set data, panning = 0, shift left 1 dot*/
6930
 
                outb(0x00, pVBInfo->P3c0);
6931
 
 
6932
 
                inb(pVBInfo->P3da); /* Enable Attribute */
6933
 
                outb(0x20, pVBInfo->P3c0);
6934
 
 
6935
 
                inb(pVBInfo->P3da); /* reset 3da */
6936
 
        }
6937
 
 
6938
 
}
6939
 
 
6940
 
/* no shadow case */
6941
 
static void XGI_SetXG27LVDSPara(unsigned short ModeNo,
6942
 
                                unsigned short ModeIdIndex,
6943
 
                                struct vb_device_info *pVBInfo)
 
6114
static void xgifb_set_lvds(int chip_id,
 
6115
                           unsigned short ModeNo,
 
6116
                           unsigned short ModeIdIndex,
 
6117
                           struct vb_device_info *pVBInfo)
6944
6118
{
6945
6119
        unsigned char temp, Miscdata;
6946
6120
        unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6964
6138
        /* SR30[5] FP HSync polarity */
6965
6139
        xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
6966
6140
 
6967
 
        XGI_SetXG27FPBits(pVBInfo);
 
6141
        if (chip_id == XG27)
 
6142
                XGI_SetXG27FPBits(pVBInfo);
 
6143
        else
 
6144
                XGI_SetXG21FPBits(pVBInfo);
 
6145
 
6968
6146
        resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6969
6147
        if (ModeNo <= 0x13) {
6970
6148
                xres = pVBInfo->StResInfo[resindex].HTotal;
7091
6269
        xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
7092
6270
        xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
7093
6271
 
7094
 
        /* Panel VRS SR35[2:0] SR34[7:0] */
7095
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8);
7096
 
        xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF);
 
6272
        if (chip_id == XG27) {
 
6273
                /* Panel VRS SR35[2:0] SR34[7:0] */
 
6274
                xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07,
 
6275
                                        (value & 0x700) >> 8);
 
6276
                xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF);
 
6277
        } else {
 
6278
                /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
 
6279
                xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03,
 
6280
                                        (value & 0x600) >> 9);
 
6281
                xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
 
6282
                xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
 
6283
        }
7097
6284
 
7098
6285
        /* VRE SR0A[5] CR11[3:0] */
7099
6286
        value = LVDSVRE - 1;
7101
6288
        xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
7102
6289
 
7103
6290
        /* Panel VRE SR3F[7:2] */
7104
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC);
 
6291
        if (chip_id == XG27)
 
6292
                xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
 
6293
                                        (value << 2) & 0xFC);
 
6294
        else
 
6295
                /* SR3F[7] has to be 0, h/w bug */
 
6296
                xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
 
6297
                                        (value << 2) & 0x7C);
7105
6298
 
7106
6299
        for (temp = 0, value = 0; temp < 3; temp++) {
7107
6300
 
7210
6403
{
7211
6404
        unsigned short tempah = 0;
7212
6405
 
7213
 
        if (pVBInfo->SetFlag == Win9xDOSMode)
7214
 
                return;
7215
 
 
7216
 
        /*
7217
 
        if (CH7017) {
7218
 
                if (!(pVBInfo->VBInfo &
7219
 
                    (SetCRT2ToLCD | SetCRT2toLCDA)) ||
7220
 
                    (XGI_DisableChISLCD(pVBInfo))) {
7221
 
                        if (!XGI_IsLCDON(pVBInfo)) {
7222
 
                                if (DISCHARGE) {
7223
 
                                        tempbx = XGINew_GetCH7005(0x61);
7224
 
                                        // first time we power up
7225
 
                                        if (tempbx < 0x01)
7226
 
                                                // and disable power sequence
7227
 
                                                XGINew_SetCH7005(0x0066);
7228
 
                                        else
7229
 
                                                // leave VDD on - disable power
7230
 
                                                XGINew_SetCH7005(0x5f66);
7231
 
                                }
7232
 
                        }
7233
 
                }
7234
 
        }
7235
 
        */
7236
 
 
7237
6406
        if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7238
6407
                        | VB_XGI302LV | VB_XGI301C)) {
7239
6408
                tempah = 0x3F;
7713
6882
        case 0x02:
7714
6883
        case 0x05:
7715
6884
        case 0x0D:
7716
 
                filterPtr = PALMYFilter1;
7717
 
                break;
7718
 
 
7719
6885
        case 0x03:
7720
 
                filterPtr = PALNYFilter1;
 
6886
                filterPtr = xgifb_palmn_yfilter1;
7721
6887
                break;
7722
6888
 
7723
6889
        case 0x08:
7724
6890
        case 0x0C:
7725
 
                filterPtr = NTSCYFilter2;
7726
 
                break;
7727
 
 
7728
6891
        case 0x0A:
7729
 
                filterPtr = PALMYFilter2;
7730
 
                break;
7731
 
 
7732
6892
        case 0x0B:
7733
 
                filterPtr = PALNYFilter2;
7734
 
                break;
7735
 
 
7736
6893
        case 0x09:
7737
 
                filterPtr = PALYFilter2;
 
6894
                filterPtr = xgifb_yfilter2;
7738
6895
                break;
7739
6896
 
7740
6897
        default:
7783
6940
                              unsigned short ModeIdIndex,
7784
6941
                              struct vb_device_info *pVBInfo)
7785
6942
{
7786
 
        if (pVBInfo->SetFlag & Win9xDOSMode)
7787
 
                return;
7788
 
 
7789
6943
        /* GetPart1IO(); */
7790
6944
        XGI_SetDelayComp(pVBInfo);
7791
6945
 
8034
7188
 
8035
7189
}
8036
7190
 
8037
 
void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8038
 
                struct vb_device_info *pVBInfo)
8039
 
{
8040
 
        unsigned short tempbx;
8041
 
        tempbx = 0;
8042
 
}
8043
 
 
8044
7191
void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8045
7192
                struct vb_device_info *pVBInfo)
8046
7193
{
8138
7285
        else
8139
7286
                modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8140
7287
 
8141
 
        if (pVBInfo->IF_DEF_CH7005 == 1) {
8142
 
                if (pVBInfo->VBInfo & SetCRT2ToTV) {
8143
 
                        if (modeflag & HalfDCLK)
8144
 
                                return 0;
8145
 
                }
8146
 
        }
8147
 
 
8148
7288
        if (ModeNo < 0x14)
8149
7289
                return 0xFFFF;
8150
7290
 
8159
7299
                index--;
8160
7300
 
8161
7301
        if (pVBInfo->SetFlag & ProgrammingCRT2) {
8162
 
                if (pVBInfo->IF_DEF_CH7005 == 1) {
8163
 
                        if (pVBInfo->VBInfo & SetCRT2ToTV)
8164
 
                                index = 0;
8165
 
                }
8166
 
 
8167
7302
                if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
8168
7303
                        if (pVBInfo->IF_DEF_LVDS == 0) {
8169
7304
                                if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
8402
7537
{
8403
7538
        unsigned short tempah;
8404
7539
 
8405
 
        if (pVBInfo->SetFlag == Win9xDOSMode) {
8406
 
                if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8407
 
                                | VB_XGI302LV | VB_XGI301C)) {
8408
 
                        XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8409
 
                        return;
8410
 
                } else
8411
 
                        /* LVDS or CH7017 */
8412
 
                        return;
8413
 
        }
8414
 
 
8415
7540
        if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8416
7541
                        | VB_XGI302LV | VB_XGI301C)) {
8417
7542
                if (!(pVBInfo->SetFlag & DisableChA)) {
8512
7637
                /* EnablePart4_1F */
8513
7638
                xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah);
8514
7639
 
8515
 
                if (pVBInfo->SetFlag & Win9xDOSMode) {
8516
 
                        XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8517
 
                        return;
8518
 
                }
8519
 
 
8520
7640
                if (!(pVBInfo->SetFlag & DisableChA)) {
8521
7641
                        XGI_VBLongWait(pVBInfo);
8522
7642
                        if (!(pVBInfo->SetFlag & GatingCRT)) {
8630
7750
                        XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
8631
7751
                                        RefreshRateTableIndex);
8632
7752
 
8633
 
                        if (HwDeviceExtension->jChipType == XG27)
8634
 
                                XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex,
8635
 
                                                ModeNo);
8636
 
                        else
8637
 
                                XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex,
8638
 
                                                ModeNo);
 
7753
                        xgifb_set_lcd(HwDeviceExtension->jChipType,
 
7754
                                        pVBInfo, RefreshRateTableIndex, ModeNo);
8639
7755
 
8640
 
                        if (pVBInfo->IF_DEF_LVDS == 1) {
8641
 
                                if (HwDeviceExtension->jChipType == XG27)
8642
 
                                        XGI_SetXG27LVDSPara(ModeNo,
8643
 
                                                        ModeIdIndex, pVBInfo);
8644
 
                                else
8645
 
                                        XGI_SetXG21LVDSPara(ModeNo,
8646
 
                                                        ModeIdIndex, pVBInfo);
8647
 
                        }
 
7756
                        if (pVBInfo->IF_DEF_LVDS == 1)
 
7757
                                xgifb_set_lvds(HwDeviceExtension->jChipType,
 
7758
                                                ModeNo, ModeIdIndex, pVBInfo);
8648
7759
                        /* P. ON */
8649
7760
                        /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); */
8650
7761
                }
8672
7783
        pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
8673
7784
        pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
8674
7785
        pVBInfo->IF_DEF_LVDS = 0;
8675
 
        pVBInfo->IF_DEF_CH7005 = 0;
8676
7786
        pVBInfo->IF_DEF_LCDA = 1;
8677
 
        pVBInfo->IF_DEF_CH7017 = 0;
8678
 
        pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */
8679
 
        pVBInfo->IF_DEF_VideoCapture = 0;
8680
 
        pVBInfo->IF_DEF_ScaleLCD = 0;
8681
 
        pVBInfo->IF_DEF_OEMUtil = 0;
8682
 
        pVBInfo->IF_DEF_PWD = 0;
8683
7787
 
8684
7788
        if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */
8685
7789
                pVBInfo->IF_DEF_YPbPr = 0;
8749
7853
                XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
8750
7854
                XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
8751
7855
                XGI_DisableBridge(HwDeviceExtension, pVBInfo);
8752
 
                /* XGI_OpenCRTC(HwDeviceExtension, pVBInfo); */
8753
7856
 
8754
7857
                if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) {
8755
7858
                        XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
8809
7912
                }
8810
7913
 
8811
7914
                pVBInfo->SetFlag = 0;
8812
 
                if (pVBInfo->IF_DEF_CH7007 != 1)
8813
 
                        pVBInfo->VBInfo = DisableCRT2Display;
 
7915
                pVBInfo->VBInfo = DisableCRT2Display;
8814
7916
 
8815
7917
                XGI_DisplayOff(HwDeviceExtension, pVBInfo);
8816
7918