tw88.lst
来自「显示屏驱动源代码」· LST 代码 · 共 1,576 行 · 第 1/5 页
LST
1,576 行
902 1 return ((post>>6) & 0x03); // change register position
903 1 }
904
905 DWORD GetPPF(void)
906 {
907 1 DWORD ppf, Freq;
908 1 BYTE i;
909 1
910 1 Freq = ReadDecoder(TW88_FPLL0);
911 1 Freq &= 0x0f;
912 1 Freq <<= 8;
913 1 Freq |= ReadDecoder(TW88_FPLL1);
C51 COMPILER V7.06 TW88 02/21/2008 14:00:30 PAGE 16
914 1 Freq <<= 8;
915 1 Freq |= ReadDecoder(TW88_FPLL2);
916 1
917 1 #ifdef DEBUG_PC
dPrintf("\r\n(GetFBDN) :%ld", Freq);
#endif
920 1 // 27000000 * 4 * FREQ / 2^17 / 2^POST
921 1 ppf = 824L * ( Freq );
922 1 // ppf = 412L * ( GetFBDN() );
923 1
924 1 i= GetPOST();
925 1
926 1 for(; i>0; i-- ) ppf /= 2;
927 1
928 1 #ifdef DEBUG_PC
dPrintf("\r\n(GetPPF) :%ld", ppf);
#endif
931 1 return ppf;
932 1 }
933 #endif
934
935 #if defined SUPPORT_PC || defined SUPPORT_DTV
936 //=============================================================================
937 // Set Measurement Window Functions
938 //=============================================================================
939 void SetMeasureWindowH(WORD start, WORD stop)
940 {
941 1 BYTE val;
942 1
943 1 #ifdef DEBUG_PC
dPrintf("\r\nSetWindow H. Range(%04x, %04x)", start, stop);
#endif
946 1
947 1 // TW8804 write LSByte first
948 1 val = (BYTE)((stop >> 4) & 0xf0);
949 1 val |= (BYTE)((start>>8) & 0x07);
950 1 WriteDecoder(0x53, val); // H-start and H-stop
951 1
952 1 WriteDecoder(0x51, (BYTE)start); // H-start
953 1 WriteDecoder(0x52, (BYTE)stop); // H-stop
954 1 }
955
956 void SetMeasureWindowV(WORD start, WORD stop)
957 {
958 1 BYTE val;
959 1
960 1 #ifdef DEBUG_PC
dPrintf("\r\nSetWindow V. Range(%04x, %04x)", start, stop);
#endif
963 1
964 1 // TW8804 write LSByte first
965 1 val = (BYTE)((stop>>4) & 0x70);
966 1 val |= (BYTE)((start>>8) & 0x07);
967 1 WriteDecoder(0x56, val); // V-start & V-stop
968 1
969 1 WriteDecoder(0x54, (BYTE)start); // V-start
970 1 WriteDecoder(0x55, (BYTE)stop); // V-stop
971 1 }
972 #endif // SUPPORT_PC || defined SUPPORT_DTV
973
974 //=============================================================================
975 // ZoomControl
C51 COMPILER V7.06 TW88 02/21/2008 14:00:30 PAGE 17
976 //=============================================================================
977 #ifndef WIDE_SCREEN
#if defined(SUPPORT_PC) || defined(SUPPORT_DTV)
void BypassZoom()
{
#ifdef WXGA
WriteDecoder(TW88_XUSCALELO, 0xcd);
WriteDecoder(TW88_YUSCALELO, 0x80);
WriteDecoder(TW88_XDSCALELO, 0x00);
WriteDecoder(TW88_XYSCALEHI, 0x06);
#else
//SetBypassmode=1;
WriteDecoder(TW88_XUSCALELO, 0x00);
WriteDecoder(TW88_XDSCALELO, 0x80);
WriteDecoder(TW88_YUSCALELO, 0x00);
WriteDecoder(TW88_XYSCALEHI, 0x15); //Set bit 4 to 1
#endif
}
#endif
#endif
996
997 void XscaleU(DWORD scale)
998 {
999 1 BYTE val;
1000 1
1001 1 WriteDecoder( TW88_XUSCALEFINE, (BYTE)scale);
1002 1
1003 1 scale >>= 8;
1004 1 WriteDecoder( TW88_XUSCALELO, (BYTE)scale);
1005 1
1006 1 scale >>= 8;
1007 1 val = ReadDecoder(TW88_XYSCALEHI);
1008 1 val &= 0xfe;
1009 1 val |= (BYTE)scale;
1010 1 WriteDecoder( TW88_XYSCALEHI, val );
1011 1 }
1012
1013 void XscaleD(DWORD scale)
1014 {
1015 1 BYTE val;
1016 1
1017 1 WriteDecoder( TW88_XDSCALELO, (BYTE)scale);
1018 1
1019 1 scale >>= 8;
1020 1 scale <<= 1;
1021 1 val = ReadDecoder(TW88_XYSCALEHI);
1022 1 val &= 0xfd;
1023 1 val |= (BYTE)scale;
1024 1 WriteDecoder( TW88_XYSCALEHI, val );
1025 1 }
1026
1027 void XScale2(DWORD scale)
1028 {
1029 1 if( scale==0x10000 ) { // No Scale
1030 2 XscaleU(0x10000);
1031 2 XscaleD(0x80);
1032 2 }
1033 1 else if( scale<0x10000 ) { // Up Scale
1034 2 XscaleU(scale);
1035 2 XscaleD(0x80);
1036 2 }
1037 1 else { // Down Scale
C51 COMPILER V7.06 TW88 02/21/2008 14:00:30 PAGE 18
1038 2 XscaleU(0x10000);
1039 2 XscaleD(scale/2/256);
1040 2 }
1041 1 }
1042
1043 void YScale2(DWORD scale)
1044 {
1045 1 BYTE val;
1046 1
1047 1 // max down scale rate is 1/2. Hans
1048 1 if (scale > 0x1ff00) scale = 0x1ff00;
1049 1
1050 1 WriteDecoder( TW88_YUSCALEFINE, (BYTE)(scale));
1051 1
1052 1 scale >>= 8;
1053 1 WriteDecoder( TW88_YUSCALELO, (BYTE)(scale));
1054 1
1055 1 scale >>= 8;
1056 1 scale <<= 2;
1057 1 val = ReadDecoder(TW88_XYSCALEHI) & 0xf3;
1058 1 val |= (BYTE)scale;
1059 1 WriteDecoder( TW88_XYSCALEHI, val );
1060 1 }
1061
1062 // PLL = 108MHz *FPLL / 2^17
1063 // FPLL = PLL * 2^17 / 108MHz
1064 void ChangeInternPLL(DWORD _PPF)
1065 {
1066 1 BYTE ppf, CURR, VCO, POST, i;
1067 1 DWORD FPLL;
1068 1
1069 1 #ifdef DEBUG_PC
dPrintf("\r\n++ ChangeInternPLL ++_PPF:%08lx(%ld) ", _PPF, _PPF);
#endif
1072 1
1073 1 ppf = _PPF/1000000;
1074 1
1075 1 //----- Frequency Range --------------------
1076 1 if ( ppf < 27 ) { VCO=0; CURR=0; POST=0; } // step = 0.5MHz
1077 1 else if( ppf < 54 ) { VCO=1; CURR=0; POST=1; } // step = 1.0MHz
1078 1 else if( ppf < 108 ) { VCO=2; CURR=0; POST=2; } // step = 1.0MHz
1079 1 else { VCO=3; CURR=0; POST=2; } // step = 1.0MHz
1080 1
1081 1 //----- Get FBDN
1082 1 FPLL = (_PPF/100000L)*2427L;
1083 1
1084 1 i = POST;
1085 1 for(; i>0; i-- )
1086 1 FPLL *= 2;
1087 1
1088 1 FPLL = FPLL / 20L;
1089 1
1090 1 //----- Setting Registers : below is different with 8806
1091 1 WriteDecoder( TW88_FPLL0, (FPLL>>16));
1092 1 WriteDecoder( TW88_FPLL1, (BYTE)(FPLL>>8));
1093 1 WriteDecoder( TW88_FPLL2, (BYTE)FPLL );
1094 1
1095 1 WriteDecoder( TW88_PLL_DIV, (VCO<<4) | (POST<<6) |CURR );
1096 1 }
1097
1098 /**
1099 #if defined(SUPPORT_PC) || defined(SUPPORT_DTV)
C51 COMPILER V7.06 TW88 02/21/2008 14:00:30 PAGE 19
1100 WORD GetYScale(void)
1101 {
1102 WORD scale;
1103 BYTE val;
1104
1105 scale = ReadDecoder(TW88_YUSCALELO);
1106 val = ReadDecoder(TW88_XYSCALEHI);
1107 val = (val >> 2) & 0x03;
1108 scale = scale + val*0x100;
1109
1110 return scale;
1111 }
1112 #endif // SUPPORT_PC || SUPPORT_DTV
1113 **/
1114
1115 //=============================================================================
1116 // Panel related..
1117 //=============================================================================
1118 /***
1119 #if (defined SERIAL) || (defined WIDE_SCREEN)
1120 void SetPVR(WORD pvr)
1121 {
1122 BYTE buf;
1123
1124 // TW8804 write LSByte first
1125 buf = ReadDecoder(0xbb) & 0x0f;
1126 buf = buf | ( (pvr>>4) & 0xf0 );
1127 WriteDecoder( 0xbb, buf );
1128
1129 WriteDecoder( 0xba, (BYTE)pvr );
1130 }
1131
1132 void SetPHR(WORD phr)
1133 {
1134 BYTE buf;
1135
1136 // TW8804 write LSByte first
1137 buf = ReadDecoder(0xb6) & 0x0f;
1138 buf = buf | ( (phr>>4) & 0xf0 );
1139 WriteDecoder( 0xb6, buf );
1140
1141 WriteDecoder( 0xb5, (BYTE)phr );
1142 }
1143 #endif // SERIAL || WIDE_SCREEN
1144 ***/
1145
1146 #if defined( SUPPORT_PC ) || defined( SUPPORT_DTV ) || defined( DEBUG_SETPANEL)
1147 //----- Panel V Resolution
1148 WORD GetPVR(void)
1149 {
1150 1 /* WORD pvr;
1151 1 BYTE val;
1152 1
1153 1 val = ReadDecoder(0xbb);
1154 1 pvr = (val & 0x70) << 4; // pppp xxxx -> pppp 0000 0000
1155 1 pvr |= ReadDecoder(0xba);
1156 1
1157 1 return pvr;*/
1158 1 return PVR_;
1159 1 }
1160
1161 //----- Panel H Resolution
C51 COMPILER V7.06 TW88 02/21/2008 14:00:30 PAGE 20
1162 WORD GetPHR(void)
1163 {
1164 1 /* WORD phr;
1165 1 BYTE val;
1166 1
1167 1 val = ReadDecoder(0xb6);
1168 1 phr = (val & 0x70) << 4; // pppp xxxx -> pppp 0000 0000
1169 1 phr |= ReadDecoder(0xb5);
1170 1
1171 1 return phr;*/
1172 1 return PHR_;
1173 1 }
1174
1175 WORD GetHPN(void)
1176 {
1177 1 WORD buf;
1178 1
1179 1 ClearEnDet(); // HHY 05.29.03 protect changing during read out
1180 1
1181 1 WriteDecoder(0x5b, 0x50); // HSYNC period and VSYNC period
1182 1
1183 1 buf = ReadDecoder(0x58); // from MSB
1184 1 buf = buf << 8;
1185 1 buf = buf | ReadDecoder(0x57);
1186 1
1187 1 SetEnDet(); // HHY 05.29.03 release protection
1188 1
1189 1 return buf;
1190 1
1191 1
1192 1 }
1193 /*
1194 WORD GetHPN(void)
1195 {
1196 WORD buf, sum;
1197 BYTE i;
1198
1199 //Get HPN
1200 WriteDecoder(0x5b, 0x50); // HSYNC period and VSYNC period
1201
1202 //HPN
1203
1204 for(i=0, sum=0; i<5; i++) { // HHY 1.45 take average
1205 buf = (WORD)ReadDecoder(0x58) << 8;// from MSB
1206 buf |= ReadDecoder(0x57);
1207 sum += buf;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?