measure.lst
来自「显示屏驱动源代码」· LST 代码 · 共 1,339 行 · 第 1/5 页
LST
1,339 行
#endif
768 1
769 1 //----- Get HPN ---------------------
770 1 hpn = GetHPN(); // HPN = H Period Num
771 1 sync = GetHSYNCPulse(); // H sync Pulse Width = HSYNC interval
772 1
773 1 #ifdef DEBUG_PC
dPrintf("\r\n HPN:%04x(%d) HSYNC:%04x(%d)", hpn, hpn, sync, sync);
dPrintf("\r\n PPF:%08lx(%ld)", GetPPF(), GetPPF() );
#endif
777 1
778 1 if( sync >= (hpn/3) ) {
779 2 SyncPol = ReadDecoder(0x40); // INVERT SYNC POLARITY
780 2 if ( SyncPol & 0x04 ) // b'2 is HSYNC POL
781 2 SyncPol &= 0xfb;
782 2 else SyncPol |= 0x04;
783 2 WriteDecoder(0x40, SyncPol);
784 2
785 2 MeasureAndWait(3);
786 2 sync = GetHSYNCPulse(); // H sync Pulse Width = HSYNC interval
787 2 hpn = GetHPN(); // HPN = H Period Num
788 2 }
789 1
790 1 //----- Get New HPN -------------
791 1 IHF = (GetPPF()+hpn/2) / hpn; // IHF = PPF / HPN
792 1
793 1 //----- Get New VPN -------------
794 1 vpn = GetVPN();
C51 COMPILER V7.06 MEASURE 02/21/2008 14:00:27 PAGE 14
795 1 IVF = (WORD)((IHF+vpn/2)/vpn); // IVF = IHF / VPN
796 1
797 1 #ifdef DEBUG_PC
dPrintf("\r\nIHF(New):%08lx(%ld)", IHF, IHF);
dPrintf("\r\nHPN(New):%04x(%d) HSYNC(New):%04x(%d)", hpn, hpn, sync, sync);
dPrintf("\r\nVPN(New):%04x(%d)", vpn, vpn);
dPrintf("\r\nIVF(New):%04x(%d)", IVF, IVF);
dPuts("\r\n-------");
#endif
804 1
805 1 DebugLevel = en;
806 1 return vpn;
807 1 }
808
809 //=============================================================================
810 // Return V active Start
811 //=============================================================================
812 WORD GetVerticalActiveArea(void)
813 {
814 1 WORD vstart, vstart1, vend;
815 1 char off=0;
816 1
817 1 dPuts("\r\n----- Get V Active Area");
818 1
819 1 //----- if current mode is DTV, use default value----------------
820 1
821 1 //#ifdef SUPPORT_DTV
822 1 if( IsDTVInput() ) {
823 2
824 2 #ifdef DEBUG_DTV
dPrintf(" ---> Use fixed data Vstart=%d VAN=%d", PCMDATA[PcMode].Vstart, PCMDATA[PcMode].VAN);
#endif
827 2
828 2 SetVactiveStart( PCMDATA[PcMode].Vstart );
829 2
830 2 switch (PcMode) {
831 3 case EE_YPbPr_480I: off = 4; break;
832 3 case EE_YPbPr_1080I: off = 2; break;
833 3 case EE_RGB_1080I: off = 4; break;
834 3 default: off = 0; break;
835 3 }
836 2 SetVactiveLen( PCMDATA[PcMode].VAN+off+20 );
837 2
838 2 return PCMDATA[PcMode].Vstart;
839 2 }
840 1 //#endif
841 1
842 1 //======================== Get the Bottom End ========================
843 1
844 1 vend = GetVend();
845 1 if( vend >= GetVPN() ) {
846 2 #ifdef DEBUG_PC
dPrintf("\r\nToo big vend [%04x]", vend);
#endif
849 2 vend = GetVPN()-1;
850 2 }
851 1 vstart = vend - PCMDATA[PcMode].VAN + 1;
852 1 vstart1 = GetVstart();
853 1 // vstart = GetVstart();
854 1
855 1 #ifdef DEBUG_PC
dPrintf("\r\nFind Vend --- %04x %04x", vstart, vend);
C51 COMPILER V7.06 MEASURE 02/21/2008 14:00:27 PAGE 15
#endif
858 1
859 1 //================================================= HHY 2.00
860 1 if( PcMode >= EE_1152_60 && PcMode <=EE_1152_75 ) {
861 2 if( vstart1 > vstart && vstart1 <= vstart+3 ) {
862 3 vstart = vstart1;
863 3 vend = vstart + PCMDATA[PcMode].VAN - 1;
864 3 #ifdef DEBUG_PC
dPuts(" -------> Use Vstart");
#endif
867 3 }
868 2 }
869 1 //=================================================
870 1
871 1 #ifdef DEBUG_PC
dPrintf("\r\nAuto Measure Vstart=%04x(%d) Vend=%04x(%d)", vstart, vstart, vend, vend);
#endif
874 1
875 1 if( (vstart > PCMDATA[PcMode].Vstart + 30) || ((int)vstart < ((int)PCMDATA[PcMode].Vstart - 30) ) ) {
876 2
877 2 #ifdef DEBUG_PC
ePrintf(" ==> Out Of Range V Active");
#endif
880 2
881 2 vstart = GetVactiveStartEE(PcMode);
882 2 vend = vstart + PCMDATA[PcMode].VAN - 1;
883 2 }
884 1
885 1 //----- Compensation mode by mode -------------------------------
886 1
887 1 #ifdef VGA
if( PcMode>=EE_VGA_60 || PcMode<=EE_VGA_85 ) {
vstart -= 5;
dPrintf("\r\n ----------- VGA Bypass !!!");
}
#endif
893 1
894 1 if( PcMode==EE_SP2 ) vstart = PCMDATA[EE_SP2].Vstart; // HHY 1.62 640x350
895 1
896 1 //----- set the register values ( Vstart, VAN ) -----------------
897 1
898 1 SetVactiveStart(vstart);
899 1
900 1 SetVactiveLen(PCMDATA[PcMode].VAN); // with VAN
901 1
902 1 #ifdef DEBUG_PC
ePrintf("\r\n@@@@@ Vstart=%04x[%d] Vend=%04x[%d]", vstart, vstart, vend, vend);
#endif
905 1
906 1 return vstart;
907 1 }
908 //=============================================================================
909 //
910 //=============================================================================
911 BYTE GetHorizontalActiveArea(void)
912 {
913 1 WORD hstart, hend;
914 1
915 1 dPuts("\r\n----- Get H Active Area ");
916 1
917 1 #ifdef SUPPORT_DTV
if( IsDTVInput() ) {
C51 COMPILER V7.06 MEASURE 02/21/2008 14:00:27 PAGE 16
hstart = PCMDATA[PcMode].Hstart;
hend = hstart + PCMDATA[PcMode].HAN + 1;
#ifdef DEBUG_PC
dPrintf(" ---> Use fixed data Hstart=%d HAN=%d Hend=%d", hstart, PCMDATA[PcMode].HAN, hend);
#endif
SetHactiveStart( hstart );
SetHactiveEnd( hend+3 ); // with HAN, Hstart
return TRUE;
}
#endif
931 1
932 1 //======================== Get the Right End ========================
933 1
934 1 hstart = GetHstart();
935 1
936 1 hend = hstart + PCMDATA[PcMode].HAN + hstart;
937 1
938 1 #ifdef DEBUG_PC
dPrintf("\r\nAuto Measure Hstart=%04x(%d) Hend=%04x(%d)", hstart, hstart, hend, hend);
#endif
941 1
942 1 if( (hstart > PCMDATA[PcMode].Hstart + 100) || ((int)hstart < (int)PCMDATA[PcMode].Hstart - 100) ) {
943 2
944 2 #ifdef DEBUG_PC
ePuts(" ==> Out Of Range H Active");
#endif
947 2
948 2 hstart = GetHactiveStartEE(PcMode);
949 2 hend = hstart + PCMDATA[PcMode].HAN + 1;
950 2
951 2 SetHactiveStart(hstart); // with Hstart
952 2 SetHactiveEnd( hend ); // with HAN, Hstart
953 2
954 2 return TRUE;
955 2 }
956 1
957 1 //----- Compensation mode by mode -------------------------------
958 1
959 1 if( PcMode < EE_XGA_60 ) hend++;
960 1
961 1 if( !IsBypassmode() ) {
962 2 hstart -= 3;
963 2 hend -= 3;
964 2 }
965 1
966 1
967 1 #ifdef XGA
if( PcMode>=EE_1152_60 ) {
hstart+=3;
hend+=3;
}
#endif
973 1
974 1 #ifdef SXGA
if( PcMode>=EE_1152_60 && PcMode<=EE_1152_75 ) {
hstart+=2;
hend+=2;
}
#endif
980 1
C51 COMPILER V7.06 MEASURE 02/21/2008 14:00:27 PAGE 17
981 1 //----- set the register values ( Hstart, Hend ) ----------------
982 1
983 1 SetHactiveStart(hstart); // with Hstart
984 1 SetHactiveEnd( hend ); // with HAN, Hstart
985 1
986 1 #ifdef DEBUG_PC
ePrintf("\r\n@@@@@ Hstart=%04x[%d] Hend=%04x[%d]", hstart, hstart, hend, hend);
#endif
989 1
990 1 return TRUE;
991 1 }
992
993 //-----------------------------------------------------------------------------
994 // Calcurate and Save VOback(0xb9) & PVP(0xb7,0xbb)
995 // - Refer to additional document
996 //-----------------------------------------------------------------------------
997 void SetVValueForPanel(WORD VIstart)
998 {
999 1 WORD PVR, VAN, VScale, VIsync;
1000 1 BYTE VOsync, VOback;
1001 1
1002 1 VIstart = VIstart;
1003 1 VIsync = VIstart; // active pulse width
1004 1 PVR = GetPVR();
1005 1 VAN = PCMDATA[PcMode].VAN;
1006 1 VOsync = ReadTW88(0xb8);
1007 1
1008 1 // dtmp = VIstart + 3 - VIsync - 1;
1009 1 // dtmp = VIstart + 3;
1010 1 // dtmp = (dtmp * PVR * 10) / VAN; // +5 means round-up.
1011 1 VScale = ReadTW88(0x63) & 0x0c;
1012 1 VScale <<= 6;
1013 1 VScale += ReadTW88(0x62); // read VScale
1014 1 // VIsync--;
1015 1 VIsync <<= 8; // multiply by 256
1016 1 // VIsync += 128;
1017 1 VIsync /= VScale; // divide by scale, calculate
1018 1 VOback = VIsync - VOsync - 1;
1019 1
1020 1 #ifdef DEBUG_PC
dPrintf("\r\n************************");
dPrintf("\r\nVScale=%d VIsync=%d PVR=%d VAN=%d ", (WORD)VScale, (WORD)VIsync, (WORD)PVR, (WORD)VAN);
dPrintf("\r\nVIstart=%d VIsync=%d PVR=%d VAN=%d ", (WORD)VIstart, (WORD)VIsync, (WORD)PVR, (WORD)VAN);
dPrintf("VOsync=%d", (WORD)VOsync);
dPrintf("==> VOback=%02bx(%bd)", VOback, VOback);
dPrintf("\r\n************************");
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?