tw88.lst
来自「显示屏驱动源代码」· LST 代码 · 共 1,576 行 · 第 1/5 页
LST
1,576 行
C51 COMPILER V7.06 TW88 02/21/2008 14:00:30 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE TW88
OBJECT MODULE PLACED IN .\Output\TW88.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE TW88.c COMPACT OPTIMIZE(9,SIZE) BROWSE INCDIR(.\Include\) DEBUG OBJECTEXTEN
-D PRINT(.\Source\TW88.lst) OBJECT(.\Output\TW88.obj)
stmt level source
1 #include "Config.h"
2
3 #include "reg.h"
4 #include "typedefs.h"
5 #include "i2c.h"
6 #include "main.h"
7 #include "tw88.h"
8 #include "etc_eep.h"
9 #include "pc_eep.h"
10 #include "measure.h"
11 #include "adc.h"
12 #include "CPU.h"
13 #include "Printf.h"
14 #include "rgbmix.h" // for TW8801
15 #include "panel.h"
16 #include "osdmenu.h"
17 #include "osdbasic.h"
18 #include "Dispinfo.h"
19 #include "Tuner.h"
20 #include "Audio.h"
21
22 ///extern IDATA BYTE adc_i2c_address, CurrentADC;
23 extern BYTE CheckBuf;
24 extern CODE struct _PANELDATA PanelData; // Hans
25 extern BYTE VInputStdDetectMode; // Hans
26 extern BYTE DebugLevel;
27 extern IDATA BYTE PcMode;
28 extern CODE struct _PCMDATA PCMDATA[];
29
30 CODE BYTE cModeIndex[] =
31 {
32 EE_YPbPr_480I,
33 EE_YPbPr_576I,
34 EE_YPbPr_480P,
35 EE_YPbPr_576P,
36 };
37
38 // UNKNOWN 0
39 // COMPOSITE 1
40 // SVIDEO 2
41 // COMPONENT 3
42 // DTV 4
43 // TV 5
44 // SCART 6
45 // PC 7
46 // DIGITALVGA 8
47 CODE struct _INPUT_MATRIX InputMatrix[] =
48 {
49 // cYSEL, cCSEL, cVSEL, cIFSEL, cDataOrder, cDataFormat, cInputRo
-ute
50 { YIN0, NOTUSE, NOTUSE, D_VIDEO, ORDER_RGB_YPbPr, IF_YUV_444, IS_DECODER}, // unk
-nown default to COMPOSITE
51 { YIN0, NOTUSE, NOTUSE, D_VIDEO, ORDER_RGB_YPbPr, IF_YUV_444, IS_DECODER}, // COM
-POSITE
C51 COMPILER V7.06 TW88 02/21/2008 14:00:30 PAGE 2
52 { YIN1, CIN0, NOTUSE, D_SVIDEO, ORDER_RGB_YPbPr, IF_YUV_444, IS_DECODER}, // S
-VIDEO
53 { YIN2, CIN1, VIN0, D_COMPONENT_P, ORDER_RGB_YPbPr, IF_YUV_444, IS_DECODER}, // COM
-PONENT
54 { NOTUSE, NOTUSE, NOTUSE, D_UNUSED, ORDER_GBR_PbPrY, IF_ITU656, IS_DTV}, //
-DTV
55 { YIN1, NOTUSE, NOTUSE, D_VIDEO, ORDER_RGB_YPbPr, IF_YUV_444, IS_DECODER}, // TV
56 { NOTUSE, NOTUSE, NOTUSE, D_VIDEO, ORDER_RGB_YPbPr, IF_YUV_444, IS_DECODER}, // SCART
- //not used
57 { YIN3, CIN2, VIN1, D_UNUSED, ORDER_RGB_YPbPr, IF_RGB_444, IS_ADC},
- // PC
58 { NOTUSE, NOTUSE, NOTUSE, D_UNUSED, ORDER_GBR_PbPrY, IF_RGB_444, IS_DTV}, // D
-IGITALVGA //not used
59 };
60
61 CODE struct _DECODER_FORMAT DecoderFormat[] = {
62 //ScaleWidth, ScaleHeight, HActive, VActive, HDelay, VDelay
63 { 690, 228, 720, 240, 0x12, 0x15}, // 480i
64 { 690, 274, 720, 288, 0x12, 0x16}, // 576i
65 { 622, 460, 720, 480, 0x40, 0x2A}, // 480P
66 { 630, 538, 720, 576, 0x3f, 0x31}, // 576P
67 };
68
69 BYTE IsDecoderSource(void)
70 {
71 1 BYTE Temp = ReadTW88(0x44);
72 1
73 1 if ((Temp & 0x03) == 0)
74 1 return TRUE; //Internal analog video decoder
75 1 else
76 1 return FALSE;
77 1 }
78 //=============================================================================
79 // Auto Detect
80 //=============================================================================
81 void SetAutoDetectStd(void)
82 {
83 1 BYTE val;
84 1
85 1 // if( GetInputSelection()==COMPONENT ) return;
86 1
87 1 dPuts("\r\nSetAutoDetectStd");
88 1 val = 0x80 | GetPossibleAutoDetectStdEE(); //AutoDetectStd
89 1 WriteDecoder(SDTR, val); // SDTR
90 1 val = ReadDecoder(SDT); // SDT
91 1 WriteDecoder(SDT, val | 0x07); // SDT
92 1 }
93
94 void ClearAutoDetectStd(BYTE std)
95 {
96 1 BYTE val;
97 1
98 1 // if( GetInputSelection()==COMPONENT ) return;
99 1
100 1 dPuts("\r\nClearAutoDetectStd");
101 1
102 1 val = ReadDecoder(SDT); // SDT
103 1 val = (val & 0xf8) | std;
104 1 WriteDecoder(SDT, val );
105 1 }
106 //=============================================================================
107 // Auto Panel H Period Control
C51 COMPILER V7.06 TW88 02/21/2008 14:00:30 PAGE 3
108 //=============================================================================
109 void AutoPHPCalEnable(void)
110 {
111 1 dPuts("\r\n +++++++++++++++++=>Auto PHP Enable");
112 1 WriteDecoder( 0xb6, (ReadDecoder(0xb6) & 0x7f) ); // Auto PHP Enable
113 1 WriteDecoder( 0xb2, ReadDecoder(0xb2) );
114 1
115 1 }
116
117 void AutoPHPCalDisable(void)
118 {
119 1 #if 1
120 1 BYTE cTemp = ReadDecoder(0xb6);
121 1 dPuts("\r\n +++++++++++++++++=>Auto PHP Disable");
122 1 cTemp |= 0x80; // Auto PHP Disable
123 1 cTemp &= 0xf0; // clear High four bits of hperiod
124 1 cTemp |= (BYTE)((PanelData.HPeriod & 0xf00) >> 8);
125 1 WriteTW88(0xb6, cTemp);
126 1 WriteTW88(0xb2, (PanelData.HPeriod & 0xff));
127 1 #else
dPuts("\r\n +++++++++++++++++=>Auto PHP Disable");
WriteDecoder( 0xb6, (ReadDecoder(0xb6) | 0x80) ); // Auto PHP Disable
WriteDecoder( 0xb2, (ReadDecoder(0xb2)));
#endif
132 1
133 1 }
134
135
136 //=============================================================================
137 // Video Input Functions
138 //=============================================================================
139 #ifdef SUPPORT_TV
BYTE IsVideoInput(void)
{
if( ( ReadDecoder(CSTATUS) & 0xc0 )==0x40 )
return 1;
return 0;
}
#endif
147
148 //=============================================================================
149 // Detect Video System by Decoder
150 //=============================================================================
151 #ifndef ID_CHECK_BY_FW
152 BYTE DetectDecoderInput(void)
153 {
154 1 BYTE std;
155 1 BYTE val;
156 1
157 1 //----- Check No Input
158 1 val = ReadDecoder(CSTATUS); // Decoder status Register
159 1 if( (val & 0xc0) != 0x40 ) { // no decoder input
160 2 std = NOINPUT;
161 2 return std;
162 2 }
163 1 //----- Check Color System by decoder
164 1 val = ReadDecoder(SDT); // SDT
165 1 if( val & 0x80 ) { // Detection in proress
166 2 std = UNKNOWN;
167 2 }
168 1 else {
169 2 val >>= 4;
C51 COMPILER V7.06 TW88 02/21/2008 14:00:30 PAGE 4
170 2 if( val==0x07 ) std = UNKNOWN;
171 2 else std = val + 1;
172 2 }
173 1
174 1 return std;
175 1 }
176 #endif // ID_CHECK_BY_FW
177
178 //=============================================================================
179 // Power Functions
180 //=============================================================================
181 BYTE GetLCDPowerState(void)
182 {
183 1 BYTE val;
184 1
185 1 val = ReadDecoder(0xd5);
186 1 val &= 0x30;
187 1 val >>= 4;
188 1 return val;
189 1 }
190
191 /*
192 void SetLCDPowerState(BYTE dat)
193 {
194 WriteDecoder( 0xd4, 0x01 ); // timer prescaler
195 WriteDecoder( 0xd6, 0x11 ); // suspend->standby on->suspend
196 WriteDecoder( 0xd7, 0x11 ); // off->standby(!) standby->off
197 WriteDecoder( 0xd8, 0x11 ); // standby->suspend(*) suspend->on
198
199 WriteDecoder( 0xd5, dat ); // Auto Power
200 }
201 */
202 /*
203 BYTE IsFreeRun(void)
204 {
205 BYTE val;
206
207 val = ReadDecoder(0xbe);
208 if( val & 0x04 ) return 1;
209 else return 0;
210 }
211 */
212
213 void PanelFreeRun(BYTE on)
214 {
215 1 BYTE val;
216 1 #ifndef QVGA
217 1 if( on ) AutoPHPCalDisable();
218 1 else AutoPHPCalEnable();
219 1 #endif
220 1
221 1 val = ReadDecoder(0xbe);
222 1 if( on ) val |= 0x04;
223 1 else val &= 0xfb;
224 1
225 1 WriteDecoder(0xbe, val);
226 1
227 1 }
228
229 void PanelBlack(BYTE on)
230 {
231 1 BYTE val, tmp;
C51 COMPILER V7.06 TW88 02/21/2008 14:00:30 PAGE 5
232 1
233 1 tmp = ReadDecoder(0xff);
234 1 WriteDecoder(0xff, 0x01);
235 1
236 1 val = ReadDecoder(0xf3);
237 1 // val = ReadDecoder(0xB4);
238 1 if( on ) val |= 0x20;
239 1 else val &= 0xdf;
240 1
241 1 WaitEndofDisplayArea();
242 1 WriteDecoder(0xf3, val);
243 1 // WriteDecoder(0xB4, val);
244 1
245 1 WriteDecoder(0xff, tmp);
246 1 }
247
248 void PanelMute(BYTE on)
249 {
250 1 if( on ){ // Mute
251 2 PanelBlack(on);
252 2 PanelFreeRun(on);
253 2 }
254 1 else
255 1 { // Recover
256 2 PanelFreeRun(on);
257 2 PanelBlack(on);
258 2 }
259 1 }
260
261 void ON_LVDS(void)
262 {
263 1 #ifdef TICONLESS
#else
266 1 BYTE val;
267 1 val = ReadDecoder(0x4e);
268 1 WriteDecoder(0x4e, val|0x10); // GPIO0 En
269 1
270 1 val = ReadDecoder(0x4f) & 0xf9;
271 1 WriteDecoder(0x4f, val | 0x08); // GPIO0 = 1
272 1 #ifdef INTERNAL_MCU
P2_0 = 1;
#endif
275 1 dPuts("\r\n--ON_LVDS");
276 1 #endif
277 1 }
278
279 void OFF_LVDS(void)
280 {
281 1 #ifdef TICONLESS
#else
284 1 BYTE val;
285 1 val = ReadDecoder(0x4e);
286 1 WriteDecoder(0x4e, val&~(0x10)); // GPIO0 En
287 1
288 1 val = ReadDecoder(0x4f) & 0xf0;//0xf9;
289 1 WriteDecoder(0x4f, val | 0x09); // GPIO0 = 0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?