39 #include <linux/module.h>
40 #include <linux/kernel.h>
41 #include <linux/errno.h>
42 #include <linux/poll.h>
48 #ifdef INCL_SISUSB_CON
56 static void SiSUSB_InitPtr(
struct SiS_Private *SiS_Pr)
75 unsigned short index,
unsigned short data)
109 unsigned short index,
unsigned short DataAND,
110 unsigned short DataOR)
117 unsigned short index,
unsigned short DataAND)
124 unsigned short index,
unsigned short DataOR)
142 static void SiSUSBRegInit(
struct SiS_Private *SiS_Pr,
unsigned long BaseAddr)
165 static void SiS_GetSysFlags(
struct SiS_Private *SiS_Pr)
174 static void SiSInitPCIetc(
struct SiS_Private *SiS_Pr)
190 static void SiS_SetSegRegLower(
struct SiS_Private *SiS_Pr,
unsigned short value)
196 temp |= (value >> 4);
199 temp |= (value & 0x0f);
203 static void SiS_SetSegRegUpper(
struct SiS_Private *SiS_Pr,
unsigned short value)
209 temp |= (value & 0xf0);
212 temp |= (value << 4);
216 static void SiS_SetSegmentReg(
struct SiS_Private *SiS_Pr,
unsigned short value)
218 SiS_SetSegRegLower(SiS_Pr, value);
219 SiS_SetSegRegUpper(SiS_Pr, value);
222 static void SiS_ResetSegmentReg(
struct SiS_Private *SiS_Pr)
224 SiS_SetSegmentReg(SiS_Pr, 0);
230 unsigned short temp = value >> 8;
235 SiS_SetSegmentReg(SiS_Pr, value);
238 static void SiS_ResetSegmentRegOver(
struct SiS_Private *SiS_Pr)
240 SiS_SetSegmentRegOver(SiS_Pr, 0);
243 static void SiS_ResetSegmentRegisters(
struct SiS_Private *SiS_Pr)
245 SiS_ResetSegmentReg(SiS_Pr);
246 SiS_ResetSegmentRegOver(SiS_Pr);
255 unsigned short *ModeIdIndex)
257 if ((*ModeNo) <= 0x13) {
259 if ((*ModeNo) != 0x03)
266 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
286 static void SiS_HandleCRT1(
struct SiS_Private *SiS_Pr)
296 static unsigned short
298 unsigned short ModeIdIndex)
300 static const unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
301 unsigned short modeflag;
304 if (ModeNo <= 0x13) {
313 return ColorDepth[
index];
320 static unsigned short
322 unsigned short ModeIdIndex,
unsigned short rrti)
324 unsigned short xres,
temp, colordepth, infoflag;
339 temp += (colordepth >> 1);
349 SiS_SetSeqRegs(
struct SiS_Private *SiS_Pr,
unsigned short StandTableIndex)
351 unsigned char SRdata;
359 for (i = 2; i <= 4; i++) {
370 SiS_SetMiscRegs(
struct SiS_Private *SiS_Pr,
unsigned short StandTableIndex)
372 unsigned char Miscdata = SiS_Pr->
SiS_StandTable[StandTableIndex].MISC;
382 SiS_SetCRTCRegs(
struct SiS_Private *SiS_Pr,
unsigned short StandTableIndex)
384 unsigned char CRTCdata;
389 for (i = 0; i <= 0x18; i++) {
400 SiS_SetATTRegs(
struct SiS_Private *SiS_Pr,
unsigned short StandTableIndex)
402 unsigned char ARdata;
405 for (i = 0; i <= 0x13; i++) {
425 SiS_SetGRCRegs(
struct SiS_Private *SiS_Pr,
unsigned short StandTableIndex)
427 unsigned char GRdata;
430 for (i = 0; i <= 0x08; i++) {
445 static void SiS_ClearExt1Regs(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo)
449 for (i = 0x0A; i <= 0x0E; i++) {
460 static unsigned short
462 unsigned short ModeIdIndex)
483 if (temp < SiS_Pr->SiS_ModeType)
488 }
while (index != 0xFFFF);
499 static void SiS_SetCRT1Sync(
struct SiS_Private *SiS_Pr,
unsigned short rrti)
512 SiS_SetCRT1CRTC(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
513 unsigned short ModeIdIndex,
unsigned short rrti)
516 unsigned short temp,
i,
j, modeflag;
524 for (i = 0, j = 0; i <= 7; i++, j++) {
528 for (j = 0x10; i <= 10; i++, j++) {
532 for (j = 0x15; i <= 12; i++, j++) {
536 for (j = 0x0A; i <= 15; i++, j++) {
560 SiS_SetCRT1Offset(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
561 unsigned short ModeIdIndex,
unsigned short rrti)
563 unsigned short du =
SiS_GetOffset(SiS_Pr, ModeNo, ModeIdIndex, rrti);
564 unsigned short infoflag = SiS_Pr->
SiS_RefIndex[rrti].Ext_InfoFlag;
567 temp = (du >> 8) & 0x0f;
572 if (infoflag & InterlaceMode)
576 temp = (du >> 8) & 0xff;
588 SiS_SetCRT1VCLK(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
591 unsigned short index = SiS_Pr->
SiS_RefIndex[rrti].Ext_CRTVCLK;
607 SiS_SetCRT1FIFO_310(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
621 if ((!(modeflag & DoubleScanMode)) || (!(modeflag &
HalfDCLK))) {
632 SiS_SetVCLKState(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
635 unsigned short data = 0, VCLK = 0, index = 0;
653 else if (VCLK >= 160)
655 else if (VCLK >= 135)
662 SiS_SetCRT1ModeRegs(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
663 unsigned short ModeIdIndex,
unsigned short rrti)
665 unsigned short data, infoflag = 0, modeflag;
683 if (infoflag & InterlaceMode)
689 if (infoflag & InterlaceMode) {
699 data = hrs - (hto >> 1) + 3;
725 SiS_SetVCLKState(SiS_Pr, ModeNo, rrti);
738 SiS_WriteDAC(
struct SiS_Private *SiS_Pr,
unsigned long DACData,
739 unsigned short shiftflag,
unsigned short dl,
unsigned short ah,
740 unsigned short al,
unsigned short dh)
742 unsigned short d1,
d2, d3;
770 unsigned short si, di, bx,
sf;
771 unsigned long DACAddr, DACData;
784 else if (data == 0x08)
786 else if (data == 0x10)
801 for (i = 0; i <
j; i++) {
803 for (k = 0; k < 3; k++) {
815 for (i = 16; i < 32; i++) {
816 data = table[
i] <<
sf;
817 for (k = 0; k < 3; k++)
821 for (m = 0; m < 9; m++) {
824 for (n = 0; n < 3; n++) {
825 for (o = 0; o < 5; o++) {
826 SiS_WriteDAC(SiS_Pr, DACData, sf, n,
827 table[di], table[bx],
832 for (o = 0; o < 3; o++) {
833 SiS_WriteDAC(SiS_Pr, DACData, sf, n,
834 table[di], table[si],
849 SiS_SetCRT1Group(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
850 unsigned short ModeIdIndex)
852 unsigned short StandTableIndex, rrti;
861 SiS_ResetSegmentRegisters(SiS_Pr);
862 SiS_SetSeqRegs(SiS_Pr, StandTableIndex);
863 SiS_SetMiscRegs(SiS_Pr, StandTableIndex);
864 SiS_SetCRTCRegs(SiS_Pr, StandTableIndex);
865 SiS_SetATTRegs(SiS_Pr, StandTableIndex);
866 SiS_SetGRCRegs(SiS_Pr, StandTableIndex);
867 SiS_ClearExt1Regs(SiS_Pr, ModeNo);
871 if (rrti != 0xFFFF) {
872 SiS_SetCRT1Sync(SiS_Pr, rrti);
873 SiS_SetCRT1CRTC(SiS_Pr, ModeNo, ModeIdIndex, rrti);
874 SiS_SetCRT1Offset(SiS_Pr, ModeNo, ModeIdIndex, rrti);
875 SiS_SetCRT1VCLK(SiS_Pr, ModeNo, rrti);
878 SiS_SetCRT1FIFO_310(SiS_Pr, ModeNo, ModeIdIndex);
880 SiS_SetCRT1ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, rrti);
893 unsigned short ModeIdIndex;
894 unsigned long BaseAddr = SiS_Pr->
IOAddress;
896 SiSUSB_InitPtr(SiS_Pr);
897 SiSUSBRegInit(SiS_Pr, BaseAddr);
898 SiS_GetSysFlags(SiS_Pr);
905 SiSInitPCIetc(SiS_Pr);
915 SiS_SetCRT1Group(SiS_Pr, ModeNo, ModeIdIndex);
917 SiS_HandleCRT1(SiS_Pr);
930 unsigned short ModeNo = 0;
933 SiSUSB_InitPtr(SiS_Pr);
935 if (VModeNo == 0x03) {