📄 al242_decoder.lst
字号:
C51 COMPILER V7.50 AL242_DECODER 08/11/2008 14:05:28 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE AL242_DECODER
OBJECT MODULE PLACED IN .\Output\AL242_DECODER.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE AL242_DECODER.C BROWSE DEBUG OBJECTEXTEND PRINT(.\Output\AL242_DECODER.lst)
- OBJECT(.\Output\AL242_DECODER.obj)
line level source
1 /*--------------------------------------------------------------------------
2 AL242_DECODER.C
3 C file for AL242_DECODER
4
5 History:
6 07/20/2006 : First Version V0.1 ---HsinChu Office
7
8 Copyright (c) 1998-2006 AverLogic Inc
9 All rights reserved.
10 --------------------------------------------------------------------------*/
11 #include <REG52.h>
12 #include <stdio.h>
13 #include <intrins.h>
14 #include <math.h>
15 #include "DATATYPE.H"
16 #include "DEFINE.H"
17 #include "AL242_DECODER.H"
18 #include "I2C.H"
19 #include "AL320_OSDDISPLAY.H"
20 #include "autodetection.H"
21 #include "EEPROM.H"
22
23 Byte gucVideoStandard, gucDisplayMode;
24 extern ROM Byte AL320_INO_NTSC_M_1[];
25 extern ROM Byte AL320_INO_NTSC_M_2[];
26 extern ROM Byte AL320_INO_PAL_M_1[];
27 extern ROM Byte AL320_INO_PAL_M_2[];
28 extern ROM Byte AL320_INO_SECAM_M_1[];
29
30 bit bSStNoSignal;
31 unsigned char signaldetectcount;
32 bdata unsigned char cSignalStatus;
33 sbit bSStBwSignal = cSignalStatus ^ 0;
34 sbit bSStHvLock = cSignalStatus ^ 1;
35 sbit bSSt625line = cSignalStatus ^ 2;
36 sbit bSStChromaLock = cSignalStatus ^ 3;
37
38 sbit bSStPal = cSignalStatus ^ 4;
39 sbit bSStSecam = cSignalStatus ^ 5;
40 sbit bSStFcMore = cSignalStatus ^ 6;
41 sbit bSStFcLess = cSignalStatus ^ 7;
42
43 bit bSStLowSignal;
44
45 bit bWaitStable;
46 bit bUpdateStandard=TRUE;
47
48 unsigned char cPreSignalStatus;
49 unsigned char cWaitStableCount;
50 unsigned char cDetectStatus = NO_SIGNAL;
51 unsigned char cPreDetectStatus;
52 unsigned char cCurStandard = NTSC_M;
53 unsigned char cNewStandard = NTSC_M;
54 unsigned char cDetectedStandard = NTSC_M;
C51 COMPILER V7.50 AL242_DECODER 08/11/2008 14:05:28 PAGE 2
55 unsigned char cNoSignalCount;
56
57
58 Byte gucInputChannel;
59 Word uiVideoStandard;
60 extern Bool gbFirstLoadData;
61 code double _Crystal[]={
62 14.318,
63 20.0,
64 20.25,
65 24.00,
66 24.576,
67 27.0,
68 28.6364
69 };
70
71 code double _4xSubCarrier[9]={
72 14.31818182, // _NTSC_M 0
73 17.73447500, // _NTSC_443 2
74 17.73447500, // _PAL_I 3
75 14.30244596, // _PAL_M 5
76 17.73447500, // _PAL_N 4
77 17.14400000, // _SECAM 8
78 14.32822500, // _PAL_CN 6
79 17.73447500, // _PAL_60 7
80 14.31818182 // _NTSC_J 1
81 };
82
83
84
85 ROM Word VideoSpec[14][11]={
86 //COLOUR_MODE
87 {0,0,1,2,1,4,3,1,0,0,1},
88 //VLINE_625
89 {0,0,1,0,1,1,1,0,0,0,1},
90 //HPIXEL
91 {0,0,1,0,1,1,1,0,0,0,1},
92 //PED
93 {0,1,0,0,0,1,0,0,0,1,0},
94 //HAGC
95 {221,221,220,221,220,220,220,220,221,221,220},
96 //HACTIVE_START
97 {0x88,0x88,0x8c,0x88,0x8c,0x8c,0x8c,0x88,0x88,0x88,0x8c}, //{0x88,0x88,0x8c,0x88,0x8c,0x8c,0x8c,0x88,0x8
-8}, 11/21 for al320b jason
98 //VACTIVE_START
99 {34,34,40,34,40,40,40,34,34,34,40},
100 //VACTIVE_HIGH
101 {97,97,193,97,193,193,193,97,97,97,193},
102 //ADAPTIVE_MODE
103 {0,139,2,2,2,0,2,2,1,0,2}, //jason ntsc 443 3->139 9/27
104 //CAUTOPOS
105 {0x2c,0x2c,0x2c,0x2c,0x2c,0x25,0x2c,0x2c,0x2c,0x2c,0x2c},
106 //CAGE
107 {0,0,103,0,0,0,0,0,0,0,103},
108 //COMB_WIDE_BAND
109 {0,0,1,0,0,0,0,0,0,0,1},
110 //CHROMA_BURST
111 {1,1,1,1,0,0,0,0,0,1,1},
112 //CHROMA_BW_LO
113 {0x02,0x01,0x02,0x02,0x02,0x01,0x02,0x02,0x02,0x02,0x02}
114 };
115
C51 COMPILER V7.50 AL242_DECODER 08/11/2008 14:05:28 PAGE 3
116 ROM Word ComponentHStart[11]=
117 {0x74,0x74,0x7a,0x74,0x7a,0x7a,0x7a,0x7a,0x74,0x74,0x7a};
118
119 // ********************************************************************************
120 // Function: AL242_GetEVBOSCType
121 // Description: Setup OSC Type
122 // Input parameters: None.
123 // Return values: None.
124 // ********************************************************************************
125 Byte AL242_GetEVBOSCType(void){
126 1
127 1 Byte ucOSCTypeX;
128 1
129 1 ucOSCTypeX=OSC_20_0;
130 1 return(ucOSCTypeX);
131 1 }
132
133 // ********************************************************************************
134 // Function: SoftWareResetAL242
135 // Description: Software reset to AL242
136 // Input parameters: None.
137 // Return values: None.
138 // ********************************************************************************
139 void AL242_SoftWareReset(void){
140 1
141 1 SetReg(SLAVE_ADDRESS_AL242, 0x3f, 0x01);
142 1 SetReg(SLAVE_ADDRESS_AL242, 0x3f, 0x00);
143 1 }
144
145 // ********************************************************************************
146 // Function: SetupAL242VideoModeX;
147 // Description: Setup AL242 decoder to assigned video standard.
148 // Input parameters: uiVideoModeX, ucAL242InputMode
149 // NTSC_M 0
150 // NTSC_443 1
151 // PAL_I 2
152 // PAL_M 3
153 // PAL_N 4
154 // SECAMx 5
155 // PAL_CN 6
156 // PAL_60 7
157 // NTSC_J 8
158 // Return values: None.
159 // ********************************************************************************
160 void AL242_SetupVideoModeX(Word uiVideoModeX, Byte ucAL242InputMode){
161 1
162 1 Byte ucTemp;
163 1 DWord ulTemp;
164 1 Word uiTemp;
165 1 double _Scale;
166 1 double _OSC;
167 1
168 1 SetReg(SLAVE_ADDRESS_AL320, 0xff, 0x00); //Switch to Page1
169 1
170 1 _OSC = _Crystal[AL242_GetEVBOSCType()];
171 1 _Scale = _OSC/27;
172 1 SetReg(SLAVE_ADDRESS_AL242, 0xc1, 0x1b); //add in Ver.302
173 1
174 1 ucTemp = GetReg(SLAVE_ADDRESS_AL242, 0x00);
175 1 ucTemp &= 0x81;
176 1 ucTemp |= (VideoSpec[COLOUR_MODE][uiVideoModeX] << 1)+
177 1 (VideoSpec[VLINE_625][uiVideoModeX] << 4)+
C51 COMPILER V7.50 AL242_DECODER 08/11/2008 14:05:28 PAGE 4
178 1 (VideoSpec[HPIXEL][uiVideoModeX] << 5);
179 1 SetReg(SLAVE_ADDRESS_AL242, 0x00, ucTemp);
180 1
181 1 ucTemp = GetReg(SLAVE_ADDRESS_AL242, 0x01);
182 1
183 1 if(ucAL242InputMode==INPUT2){
184 2
185 2 ucTemp = 0x49;
186 2 }
187 1 else{
188 2
189 2 ucTemp &= 0x00;
190 2 ucTemp |= VideoSpec[PED][uiVideoModeX];
191 2 ucTemp |= VideoSpec[CHROMA_BURST][uiVideoModeX]<< 1; //jason 10/9
192 2 ucTemp |= VideoSpec[CHROMA_BW_LO][uiVideoModeX] << 2;
193 2 }
194 1
195 1 SetReg(SLAVE_ADDRESS_AL242, 0x01, ucTemp);
196 1
197 1 ucTemp=VideoSpec[HAGC][uiVideoModeX];
198 1 SetReg(SLAVE_ADDRESS_AL242, 0x04, ucTemp);
199 1
200 1 ulTemp=((_4xSubCarrier[uiVideoModeX]/_OSC)*0x40000000);
201 1
202 1 for(uiTemp=0; uiTemp<4; uiTemp++){
203 2 SetReg(SLAVE_ADDRESS_AL242, (0x1b - uiTemp), (unsigned char)(ulTemp & 0x00ff));
204 2
205 2 ulTemp >>= 8;
206 2 }
207 1
208 1 switch(uiVideoModeX){
209 2 case PAL_M:
210 2 SetReg(SLAVE_ADDRESS_AL242, 0x1b , 0x50);
211 2 break;
212 2 case NTSC_M:
213 2 case NTSC_J:
214 2 SetReg(SLAVE_ADDRESS_AL242, 0x1b , 0x5d);
215 2 break;
216 2 case PAL_60:
217 2 case NTSC_443:
218 2 case PAL_I:
219 2 case PAL_N:
220 2 SetReg(SLAVE_ADDRESS_AL242, 0x1b , 0xf8);
221 2 break;
222 2 case PAL_CN:
223 2 SetReg(SLAVE_ADDRESS_AL242, 0x1b , 0x92);
224 2 break;
225 2 case SECAMx:
226 2 SetReg(SLAVE_ADDRESS_AL242, 0x1b , 0x63);
227 2 break;
228 2
229 2 }
230 1
231 1 if (ucAL242InputMode != INPUT2){ // If input source=component, get different h_start setting
232 2 ucTemp = VideoSpec[HACTIVE_START][uiVideoModeX];
233 2 if ((uiVideoModeX == PAL_I) && (gucDisplayMode == MODE2)){ //for Pal Mode2
234 3 ucTemp = 0x88;
235 3 }
236 2 }
237 1 else{
238 2
239 2 ucTemp = ComponentHStart[uiVideoModeX];
C51 COMPILER V7.50 AL242_DECODER 08/11/2008 14:05:28 PAGE 5
240 2
241 2 }
242 1
243 1 //SetReg(SLAVE_ADDRESS_AL242, 0x2e, ucTemp); //jack
244 1
245 1 ucTemp = VideoSpec[VACTIVE_START][uiVideoModeX];
246 1 SetReg(SLAVE_ADDRESS_AL242, 0x30, ucTemp);
247 1
248 1 ucTemp = VideoSpec[VACTIVE_HIGH][uiVideoModeX];
249 1 SetReg(SLAVE_ADDRESS_AL242, 0x31, ucTemp);
250 1
251 1 /*
252 1 if (ucAL242InputMode == INPUT1){ //S-Video Filter Setup 2005/08/11
253 1
254 1 if(uiVideoModeX == NTSC_M){
255 1 ucTemp = GetReg(SLAVE_ADDRESS_AL242, 0x03);
256 1 ucTemp &= 0xf8;
257 1 ucTemp |= 0x03;
258 1 SetReg(SLAVE_ADDRESS_AL242, 0x03, ucTemp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -