xref: /utopia/UTPA2-700.0.x/projects/tmplib/include/drvAVD.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 //    Software and any modification/derivatives thereof.
18 //    No right, ownership, or interest to MStar Software and any
19 //    modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 //    supplied together with third party`s software and the use of MStar
23 //    Software may require additional licenses from third parties.
24 //    Therefore, you hereby agree it is your sole responsibility to separately
25 //    obtain any and all third party right and license necessary for your use of
26 //    such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 //    MStar`s confidential information and you agree to keep MStar`s
30 //    confidential information in strictest confidence and not disclose to any
31 //    third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 //    kind. Any warranties are hereby expressly disclaimed by MStar, including
35 //    without limitation, any warranties of merchantability, non-infringement of
36 //    intellectual property rights, fitness for a particular purpose, error free
37 //    and in conformity with any international standard.  You agree to waive any
38 //    claim against MStar for any loss, damage, cost or expense that you may
39 //    incur related to your use of MStar Software.
40 //    In no event shall MStar be liable for any direct, indirect, incidental or
41 //    consequential damages, including without limitation, lost of profit or
42 //    revenues, lost or damage of data, and unauthorized system use.
43 //    You agree that this Section 4 shall still apply without being affected
44 //    even if MStar Software has been modified by MStar in accordance with your
45 //    request or instruction for your use, except otherwise agreed by both
46 //    parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 //    services in relation with MStar Software to you for your use of
50 //    MStar Software in conjunction with your or your customer`s product
51 //    ("Services").
52 //    You understand and agree that, except otherwise agreed by both parties in
53 //    writing, Services are provided on an "AS IS" basis and the warranty
54 //    disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 //    or otherwise:
58 //    (a) conferring any license or right to use MStar name, trademark, service
59 //        mark, symbol or any other identification;
60 //    (b) obligating MStar or any of its affiliates to furnish any person,
61 //        including without limitation, you and your customers, any assistance
62 //        of any kind whatsoever, or any information; or
63 //    (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 //    of Taiwan, R.O.C., excluding its conflict of law rules.
67 //    Any and all dispute arising out hereof or related hereto shall be finally
68 //    settled by arbitration referred to the Chinese Arbitration Association,
69 //    Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 //    Rules of the Association by three (3) arbitrators appointed in accordance
71 //    with the said Rules.
72 //    The place of arbitration shall be in Taipei, Taiwan and the language shall
73 //    be English.
74 //    The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // ("MStar Confidential Information") by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 //
93 ////////////////////////////////////////////////////////////////////////////////
94 
95 ///////////////////////////////////////////////////////////////////////////////////////////////////
96 ///
97 /// @file   drvAVD.h
98 /// @brief  AVD Driver Interface
99 /// @author MStar Semiconductor Inc.
100 ///////////////////////////////////////////////////////////////////////////////////////////////////
101 
102 /*! \defgroup VDEC VDEC modules
103 
104  *! \defgroup AVD AVD interface (drvAVD.h)
105  *  \ingroup VDEC
106 
107      AVD (Analog Video Decoder) gets CVBS signal status from VDMCU through VD mailbox. VDMCU reports information like H/V sync status, video standard...\n
108      AVD separate CVBS signal into Y/C signal by using 2D/3D COMB filter.
109 
110      <b>Features</b>
111 
112      - detect CVBS signal status and video stadnard
113      - 3D COMB filter
114      - Get signal Noise
115      - CVBS color on/off
116 
117      <b> AVD Block Diagram: </b> \n
118      \image html drvAVD_1.png
119 
120      <b> AVD Code Flow: </b> \n
121      \image html drvAVD_2.png
122 
123  *! \defgroup VDMCU VDMCU
124  *  \ingroup AVD
125 
126  *! \defgroup VD_Info VD_Info
127  *  \ingroup AVD
128 
129  *! \defgroup VD_Task VD_Task
130  *  \ingroup AVD
131 
132  *! \defgroup COMB COMB relative
133  *  \ingroup AVD
134 
135  *! \defgroup AVD_ToBeModified AVD api to be modified
136  *  \ingroup AVD
137 
138  *! \defgroup AVD_ToBeRemove AVD api to be removed
139  *  \ingroup AVD
140 
141  *! \defgroup Get_VD_Info Get_VD_Info
142  *  \ingroup VD_Info
143 
144  *! \defgroup Set_VD_Info Set_VD_Info
145  *  \ingroup VD_Info
146 
147  */
148 
149 
150 #ifndef _DRV_AVD_H_
151 #define _DRV_AVD_H_
152 
153 #include "MsCommon.h"
154 
155 #ifdef __cplusplus
156 extern "C"
157 {
158 #endif
159 
160 
161 //-------------------------------------------------------------------------------------------------
162 //  Driver Capability
163 //-------------------------------------------------------------------------------------------------
164 
165 
166 //-------------------------------------------------------------------------------------------------
167 //  Macro and Define
168 //-------------------------------------------------------------------------------------------------
169 #define MSIF_AVD_LIB_CODE                   {'A','V','D','_'} //Lib code
170 #define MSIF_AVD_LIBVER                        {'1','1'}      //LIB version
171 #define MSIF_AVD_BUILDNUM                 {'0','0' }    //Build Number
172 #define MSIF_AVD_CHANGELIST             {'0','0','6','1','6','9','9','1'} //P4 ChangeList Number
173 
174 #define AVD_VER                 /* Character String for DRV/API version             */  \
175     MSIF_TAG,                           /* 'MSIF'                                           */  \
176     MSIF_CLASS,                         /* '00'                                             */  \
177     MSIF_CUS,                           /* 0x0000                                           */  \
178     MSIF_MOD,                           /* 0x0000                                           */  \
179     MSIF_CHIP,                                                                                  \
180     MSIF_CPU,                                                                                   \
181     MSIF_AVD_LIB_CODE,                  /* IP__                                             */  \
182     MSIF_AVD_LIBVER,                       /* 0.0 ~ Z.Z                                        */  \
183     MSIF_AVD_BUILDNUM,                 /* 00 ~ 99                                          */  \
184     MSIF_AVD_CHANGELIST,             /* CL#                                              */  \
185     MSIF_OS
186 
187 // video decoder status
188 #define VD_SYNC_LOCKED                  ((BIT_(15)))
189 #define VD_HSYNC_LOCKED                 ((BIT_(14)))
190 #define VD_INTERLACED                   ((BIT_(13)))
191 #define VD_VSYNC_50HZ                   ((BIT_(12)))
192 #define VD_RESET_ON                     ((BIT_(11)))
193 #define VD_COLOR_LOCKED                 ((BIT_(10)))
194 #define VD_PAL_SWITCH                   ((BIT_(9)))
195 #define VD_FSC_TYPE                     ((BIT_(7))|(BIT_(6))|(BIT_(5)))
196 #define VD_FSC_3579                     ((BIT_(6)))              // NTSC
197 #define VD_FSC_3575                     ((BIT_(7)))              // PAL(M)
198 #define VD_FSC_3582                     ((BIT_(7))|(BIT_(6)))         // PAL(Nc)
199 #define VD_FSC_4433                     (0)                 // PAL or NTSC443
200 #define VD_FSC_4285                     (BIT_(5))              // SECAM
201 #define VD_VCR_MODE                     (BIT_(4))
202 #define VD_VCR_PAUSE                    (BIT_(3))
203 #define VD_MACROVISION                  (BIT_(2))
204 #define VD_BURST_ON                        (BIT_(1))
205 #define VD_STATUS_RDY                   (BIT_(0))
206 #define VD_MODE_DETECT_MASK             (VD_SYNC_LOCKED|VD_HSYNC_LOCKED|VD_VSYNC_50HZ|VD_FSC_TYPE|VD_RESET_ON) // 20100331 remove BURST check first because too many burst on/off issues
207 
208 // Gain Control (Auto/Fix/Mix) Define
209 #define VD_USE_FIX_GAIN                 0
210 #define VD_USE_AUTO_GAIN                1
211 // Gain Control (Auto/Fix/Mix) Define
212 //#define AVD_AGC_ENABLE                              0x00
213 //#define AVD_AGC_DISABLE                             0x03
214 
215 
216 #define IS_BITS_SET(val, bits)                  (((val)&(bits)) == (bits))
217 #define VD_MODE_STANDARD_MASK                   (VD_VSYNC_50HZ | VD_PAL_SWITCH | VD_FSC_TYPE | VD_STATUS_RDY)
218 
219 #define FSC_AUTO_DET_ENABLE                     0x00
220 #define FSC_AUTO_DET_DISABLE                    0x01
221 
222 #define VD_USE_FB                               0
223 
224 // VD Check Hsync Thresholdffff
225 #define VD_CHK_HSYNC_WAIT                1         // ms
226 #define VD_CHK_HSYNC_CONT                60//40        // timeout=VD_CHK_HSYNC_CONT*VD_CHK_HSYNC_WAIT=20ms
227 #define VD_CHK_HSYNC_OK_THR             2   //7
228 #define VD_CHK_DEBOUNCE_WAIT         20        // ms
229 #define VD_CHK_DEBOUNCE_CONT         40        // timeout=VD_CHK_COLOR_CONT*VD_CHK_COLOR_WAIT=800ms
230 #define VD_CHK_NSPL_WAIT                   1       //ms
231 #define VD_CHK_NSPL_CONT                   500       //timeout=VD_CHK_NSPL_WAIT*VD_CHK_NSPL_CONT=400ms
232 #define VD_CHK_NSPL_OK_THR              20//10
233 #define VD_CHK_VideoSys_CONT                   250       //timeout=VD_CHK_NSPL_WAIT*VD_CHK_NSPL_CONT=400ms
234 
235 #define DSP_VER_OFFSET 255
236 
237 
238 //-------------------------------------------------------------------------------------------------
239 //  Type and Structure
240 //-------------------------------------------------------------------------------------------------
241 typedef enum
242 {
243     AVD_LOAD_CODE_BDMA_FROM_SPI,
244     AVD_LOAD_CODE_BDMA_FROM_DRAM,
245     AVD_LOAD_CODE_BYTE_WRITE,
246 } AVD_LoadCodeType;
247 
248 typedef enum
249 {
250     DEMODE_NORMAL                   = 0,
251     DEMODE_MSTAR_VIF                = 1,
252     DEMODE_MSTAR_VIF_MSB1210        = 2,
253 } AVD_DemodType;
254 
255 typedef enum
256 {
257     E_VIDEO_SYSTEM_ATSC,
258     E_VIDEO_SYSTEM_DVB
259 } AVD_VideoSystem;
260 
261 typedef enum
262 {
263     E_VIDEO_FQ_NOSIGNAL             = 0,     // Video Frequency No signal
264     E_VIDEO_FQ_50Hz                 = 50,    // Video Frequency 50Hz
265     E_VIDEO_FQ_60Hz                 = 60     // Video Frequency 60Hz
266 } AVD_VideoFreq;
267 
268 typedef enum
269 {
270     E_FREERUN_FQ_AUTO               = 0x00,
271     E_FREERUN_FQ_50Hz               = 0x01,
272     E_FREERUN_FQ_60Hz               = 0x02,
273     E_FREERUN_FQ_MAX
274 } AVD_FreeRunFreq;
275 
276 typedef enum
277 {
278     E_VIDEOSTANDARD_PAL_BGHI        = 0x00,        // Video standard PAL BGHI
279     E_VIDEOSTANDARD_NTSC_M          = 0x01,        // Video standard NTSC M
280     E_VIDEOSTANDARD_SECAM           = 0x02,        // Video standard SECAM
281     E_VIDEOSTANDARD_NTSC_44         = 0x03,        // Video standard  NTSC 44
282     E_VIDEOSTANDARD_PAL_M           = 0x04,        // Video standard  PAL M
283     E_VIDEOSTANDARD_PAL_N           = 0x05,        // Video standard  PAL N
284     E_VIDEOSTANDARD_PAL_60          = 0x06,        // Video standard PAL 60
285     E_VIDEOSTANDARD_NOTSTANDARD     = 0x07,        // NOT Video standard
286     E_VIDEOSTANDARD_AUTO            = 0x08,         // Video standard AUTO
287     E_VIDEOSTANDARD_MAX                                // Max Number
288 } AVD_VideoStandardType;
289 
290 typedef enum
291 {
292     E_INPUT_SOURCE_INVALID                  =   0x00,               // Video source Invalid
293     E_INPUT_SOURCE_ATV                      =   0x01,               // Video source ATV
294     E_INPUT_SOURCE_CVBS1                    =   0x02,               // Video source CVBS 1
295     E_INPUT_SOURCE_CVBS2                    =   0x03,               // Video source CVBS 2
296     E_INPUT_SOURCE_CVBS3                    =   0x04,               // Video source CVBS 2
297     E_INPUT_SOURCE_SVIDEO1                  =   0x05,               // Video source SVIDEO 1
298     E_INPUT_SOURCE_SVIDEO2                  =   0x06,               // Video source SVIDEO 2
299     E_INPUT_SOURCE_SCART1                   =   0x07,               // Video source SCART 1
300     E_INPUT_SOURCE_SCART2                   =   0x08,               // Video source SCART 2
301     E_INPUT_SOURCE_YPbPr                    =   0x09,               // Video source YPbPr
302     E_INPUT_SOURCE_THROUGH_3DCOMB           =   0x50,               // Video source through 3D Comb
303     E_INPUT_SOURCE_THROUGH_3DCOMB_ATV       =   (E_INPUT_SOURCE_THROUGH_3DCOMB | E_INPUT_SOURCE_ATV),   // through 3D Comb ATV
304     E_INPUT_SOURCE_THROUGH_3DCOMB_CVBS1     =   (E_INPUT_SOURCE_THROUGH_3DCOMB | E_INPUT_SOURCE_CVBS1),// through 3D Comb CVBS1
305     E_INPUT_SOURCE_THROUGH_3DCOMB_CVBS2     =   (E_INPUT_SOURCE_THROUGH_3DCOMB | E_INPUT_SOURCE_CVBS2),// through 3D Comb CVBS2
306     E_INPUT_SOURCE_THROUGH_3DCOMB_SCART1    =   (E_INPUT_SOURCE_THROUGH_3DCOMB | E_INPUT_SOURCE_SCART1),// through 3D Comb SCART1
307     E_INPUT_SOURCE_THROUGH_3DCOMB_SCART2    =   (E_INPUT_SOURCE_THROUGH_3DCOMB | E_INPUT_SOURCE_SCART2),// through 3D Comb SCART2
308     E_INPUT_SOURCE_MAX                      =   0x60
309 } AVD_InputSourceType;
310 
311 /// Auto AV Source type
312 typedef enum
313 {
314     E_AUTOAV_SOURCE_1   =   E_INPUT_SOURCE_SCART1,       // Auto AV source SCART 1
315     E_AUTOAV_SOURCE_2   =   E_INPUT_SOURCE_SCART2,       // Auto AV source SCART 2
316     E_AUTOAV_SOURCE_ALL =   0xFF                // Auto AV source ALL
317 } AVD_AutoAVSourceType;
318 
319 typedef enum    // 0x2580[5:4]
320 {
321     SCART_FB_NONE = 0x00,
322     SCART_FB0,
323     SCART_FB1,
324     SCART_FB2,
325 } AVD_INPUT_SCART_FB;
326 
327 typedef enum
328 {
329     E_ATV_CLK_ORIGIN_43P2MHZ   =    0x00,
330     E_ATV_CLK_TYPE1_42MHZ         =    0x01,
331     E_ATV_CLK_TYPE2_44P4MHZ     =    0x02,
332 }AVD_ATV_CLK_TYPE;
333 
334 typedef struct
335 {
336     MS_U8 u8DetectWinBeforeLock;
337     MS_U8 u8DetectWinAfterLock;
338     MS_U8 u8CNTRFailBeforeLock;
339     MS_U8 u8CNTRSyncBeforeLock;
340     MS_U8 u8CNTRSyncAfterLock;
341 } VD_HSYNC_SENSITIVITY;
342 
343 typedef enum
344 {
345     AVD_DBGLV_NONE,    // disable all the debug message
346     AVD_DBGLV_INFO,    // information
347     AVD_DBGLV_NOTICE,  // normal but significant condition
348     AVD_DBGLV_WARNING, // warning conditions
349     AVD_DBGLV_ERR,     // error conditions
350     AVD_DBGLV_CRIT,    // critical conditions
351     AVD_DBGLV_ALERT,   // action must be taken immediately
352     AVD_DBGLV_EMERG,   // system is unusable
353     AVD_DBGLV_DEBUG,   // debug-level messages
354 } AVD_DbgLv;
355 
356 #define AVD_PATCH_NONE 0
357 #define AVD_PATCH_NTSC_50 BIT_(0)
358 #define AVD_PATCH_FINE_TUNE_FH_DOT BIT_(1)
359 #define AVD_PATCH_FINE_TUNE_COMB_F2 BIT_(2)
360 #define AVD_PATCH_FINE_TUNE_3D_COMB BIT_(3)
361 #define AVD_PATCH_FINE_TUNE_FSC_SHIFT BIT_(4)
362 #define AVD_PATCH_NON_STANDARD_VTOTAL BIT_(5)
363 #define AVD_PATCH_FINE_TUNE_STILL_IMAGE BIT_(6)
364 
365 #define AVD_PATCH_HTOTAL_1135_MUL_15 0
366 #define AVD_PATCH_HTOTAL_1135 BIT_(8)
367 #define AVD_PATCH_HTOTAL_DYNAMIC BIT_(9)
368 #define AVD_PATCH_HTOTAL_USER (BIT_(9)|BIT_(8))
369 #define AVD_PATCH_HTOTAL_MASK (BIT_(9)|BIT_(8))
370 #define AVD_PATCH_SCART_SVIDEO (BIT_(10))
371 #define AVD_PATCH_CVBS_NEGATIVESIG (BIT_(11))
372 
373 #define AVD_PATCH_DISABLE_PWS BIT_(24)    // used to store ENABLE_PWS
374 /// For vd init
375 typedef struct
376 {
377         // register init
378     MS_U8 *u8VdDecInitializeExt; // TODO use system variable type
379 
380     MS_U32 u32XTAL_Clock;
381     AVD_LoadCodeType eLoadCodeType;
382     MS_U32 u32VD_DSP_Code_Address;
383     MS_U8 *pu8VD_DSP_Code_Address;
384     MS_U32 u32VD_DSP_Code_Len;
385     // VIF related
386     AVD_DemodType eDemodType;
387 
388     // afec related
389     MS_U16 u16VDDSPBinID;
390     MS_U8 bRFGainSel;
391     MS_U8 bAVGainSel;
392     MS_U8 u8RFGain;
393     MS_U8 u8AVGain;
394     MS_U32  u32VDPatchFlag;
395     MS_U8 u8ColorKillHighBound;
396     MS_U8 u8ColorKillLowBound;
397     MS_U8 u8SwingThreshold;
398     VD_HSYNC_SENSITIVITY eVDHsyncSensitivityNormal;
399     VD_HSYNC_SENSITIVITY eVDHsyncSensitivityTuning;
400 
401     // comb related
402     MS_PHY u32COMB_3D_ADR;
403     MS_U32 u32COMB_3D_LEN;
404 
405 } VD_INITDATA;
406 
407 typedef enum
408 {
409     E_AVD_FAIL=0,
410     E_AVD_OK=1
411 } AVD_Result;
412 
413 
414 typedef struct
415 {
416     AVD_InputSourceType eVDInputSource;
417     AVD_VideoStandardType eVideoSystem;
418     AVD_VideoStandardType eLastStandard;
419     MS_U8  u8AutoDetMode;
420     MS_U16 u16CurVDStatus;
421     MS_U8 u8AutoTuningIsProgress;
422 } AVD_Info;
423 
424 typedef struct
425 {
426     MS_U8 u8Threshold1;
427     MS_U8 u8Threshold2;
428     MS_U8 u8Threshold3;
429     MS_U8 u8Threshold4;
430 
431     MS_U8 u8Str1_COMB37;
432     MS_U8 u8Str1_COMB38;
433     MS_U8 u8Str1_COMB7C;
434     MS_U8 u8Str1_COMBED;
435 
436     MS_U8 u8Str2_COMB37;
437     MS_U8 u8Str2_COMB38;
438     MS_U8 u8Str2_COMB7C;
439     MS_U8 u8Str2_COMBED;
440 
441     MS_U8 u8Str3_COMB37;
442     MS_U8 u8Str3_COMB38;
443     MS_U8 u8Str3_COMB7C;
444     MS_U8 u8Str3_COMBED;
445 
446     MS_BOOL bMessageOn;
447 } AVD_Still_Image_Param;
448 
449 typedef enum
450 {
451     E_FACTORY_PARA_AFEC_D4,
452     E_FACTORY_PARA_AFEC_D8,
453     E_FACTORY_PARA_AFEC_D5_BIT2,
454     E_FACTORY_PARA_AFEC_D9_BIT0,
455     E_FACTORY_PARA_AFEC_A0,
456     E_FACTORY_PARA_AFEC_A1,
457     E_FACTORY_PARA_AFEC_66_BIT67,
458     E_FACTORY_PARA_AFEC_6E_BIT7654,
459     E_FACTORY_PARA_AFEC_6E_BIT3210,
460     E_FACTORY_PARA_AFEC_43,
461     E_FACTORY_PARA_AFEC_44,
462     E_FACTORY_PARA_AFEC_CB,
463     E_FACTORY_PARA_AFEC_CF_BIT2,
464     E_FACTORY_PARA_AFEC_D5_BIT3,
465     E_FACTORY_PARA_AFEC_MAX
466 }AVD_Factory_Para;
467 
468 //typedef void(*P_AVD_ISR_Proc)(MS_U8 u8AVDID);
469 
470 
471 //-------------------------------------------------------------------------------------------------
472 //  Function and Variable
473 //-------------------------------------------------------------------------------------------------
474 //-------------------------------------------------------------------------------------------------
475 /// Set VDMCU freeze
476 /// @ingroup VDMCU
477 /// @param  bEnable   \b IN: MCU freeze enable
478 /// @return NA
479 //-------------------------------------------------------------------------------------------------
480 // extern void MDrv_AVD_MCUFreeze(MS_BOOL bEnable);
481 
482 //-------------------------------------------------------------------------------------------------
483 /// Turn OFF AVD
484 /// @ingroup VD_Task
485 /// @return NA
486 //-------------------------------------------------------------------------------------------------
487 extern void MDrv_AVD_Exit(void);
488 ////////////////////////////////////////////////////////////////////////////////
489 /// To initialize Video Decoder.\n
490 /// When turning power on or waking up from power saving mode,\n
491 /// this function should be called before using all funcions\n
492 /// MS_U32 u32XTAL_Clock        : external crystal clock.\n
493 /// MS_U32 u32VD_DSP_Code_Address        : absolute flash address of VDDSP bin file\n
494 /// MS_U8 *pu8VD_DSP_Code_Address        : address of VDDSP code\n
495 /// MS_U32 u32VD_DSP_Code_Len        : VDDSP code length.\n
496 /// AVD_DemodType eDemodType        : analog Demod. type.\n
497 /// MS_U16 u16VDDSPBinID     : binary ID of VD DSP code.\n
498 /// MS_U8 bRFGainSel        : RF auto/fix gain selection\n
499 /// MS_U8 bAVGainSel        : AV auto/fix gain selection\n
500 /// MS_U8 u8RFGain        : when RF is fix gain, u8RFGain will set gain value\n
501 /// MS_U8 u8AVGain        : when AV is fix gain, u8AVGain will set gain value\n
502 /// MS_U32 u32VDPatchFlag        : set AVD control flag\n
503 /// MS_U8 u8ColorKillHighBound        : when color burst is detected and color burst S/N is lower than u8ColorKillLowBound, turn off color.\n
504 /// MS_U8 u8ColorKillLowBound        : when color burst is not detected and color burst S/N is higher than u8ColorKillHighBound, turn on color.\n
505 ///                                                                          u8ColorKillHighBound should be larger than u8ColorKillLowBound for hysteresis\n
506 /// MS_U8 u8SwingThreshold        : when signal swing(top-bottom) is smaller than u8SwingThreshold*16mV, report no sync\n
507 ///                                                                      this threshold is used to filter out false channel, but the value should be set to 0 at channel scan to prevent channel lost\n
508 /// VD_HSYNC_SENSITIVITY eVDHsyncSensitivityNormal        : hsync sensitivity at normal condition\n
509 /// VD_HSYNC_SENSITIVITY eVDHsyncSensitivityTuning        : hsync sensitivity at channel scan\n
510 /// MS_U32 u32COMB_3D_ADR    : 3D COMB protected memory buffer start address.\n
511 /// MS_U32 u32COMB_3D_LEN    : 3D COMB protected memory length.\n
512 /// MS_U8 *u8VdDecInitializeExt    : additional initial table for different project requirements\n
513 ///
514 /// MS_U32 u32InitDataLen : used to check data size correct or not
515 ////////////////////////////////////////////////////////////////////////////////
516 //-------------------------------------------------------------------------------------------------
517 /// Initialize AVD
518 /// @ingroup VD_Task
519 /// @param  pVD_InitData   \b IN: AVD initialize parameters
520 /// @param  u32InitDataLen   \b IN: InitData length
521 /// @return NA
522 //-------------------------------------------------------------------------------------------------
523 extern AVD_Result MDrv_AVD_Init(VD_INITDATA *pVD_InitData, MS_U32 u32InitDataLen);
524 
525 //-------------------------------------------------------------------------------------------------
526 /// Reset VDMCU
527 /// @ingroup VDMCU
528 /// @return TRUE : succeed
529 /// @return FALSE : fail
530 //-------------------------------------------------------------------------------------------------
531 extern MS_BOOL MDrv_AVD_McuReset(void);
532 ////////////////////////////////////////////////////////////////////////////////
533 /// Get video decoder status
534 /// VD_SYNC_LOCKED                  ((BIT(15)))\n
535 /// VD_HSYNC_LOCKED                 ((BIT(14)))\n
536 /// VD_INTERLACED                   ((BIT(13)))\n
537 /// VD_VSYNC_50HZ                   ((BIT(12)))\n
538 /// VD_RESET_ON                     ((BIT(11)))\n
539 /// VD_COLOR_LOCKED                 ((BIT(10)))\n
540 /// VD_PAL_SWITCH                   ((BIT(9)))\n
541 /// VD_FSC_TYPE                     ((BIT(7))|(BIT(6))|(BIT(5)))\n
542 /// VD_FSC_3579                     ((BIT(6)))              // NTSC\n
543 /// VD_FSC_3575                     ((BIT(7)))              // PAL(M)\n
544 /// VD_FSC_3582                     ((BIT(7))|(BIT(6)))         // PAL(Nc)\n
545 /// VD_FSC_4433                     (0)                 // PAL or NTSC443\n
546 /// VD_FSC_4285                     (BIT(5))              // SECAM\n
547 /// VD_VCR_MODE                     (BIT(4))\n
548 /// VD_VCR_PAUSE                    (BIT(3))\n
549 /// VD_MACROVISION                  (BIT(2))\n
550 /// VD_BURST_ON                        (BIT(1))\n
551 /// VD_STATUS_RDY                   (BIT(0))\n
552 ////////////////////////////////////////////////////////////////////////////////
553 //-------------------------------------------------------------------------------------------------
554 /// Get VD Status
555 /// @ingroup Get_VD_Info
556 /// @return U16 parameters : AVD U16 Status
557 //-------------------------------------------------------------------------------------------------
558 extern MS_U16 MDrv_AVD_GetStatus(void);
559 //-------------------------------------------------------------------------------------------------
560 /// Get VD Status
561 /// @ingroup AVD_ToBeRemove
562 /// @return U16 parameters : AVD U16 Status
563 //-------------------------------------------------------------------------------------------------
564 // extern AVD_Result MDrv_AVD_GetLibVer(const MSIF_Version **ppVersion);
565 //-------------------------------------------------------------------------------------------------
566 /// Set AVD debug parameters
567 /// @ingroup Set_VD_Info
568 /// @param  u8DbgLevel   \b IN: debug parameters
569 /// @return TRUE : succeed
570 /// @return FALSE : fail
571 //-------------------------------------------------------------------------------------------------
572 extern MS_BOOL MDrv_AVD_SetDbgLevel(AVD_DbgLv u8DbgLevel);
573 
574 //-------------------------------------------------------------------------------------------------
575 /// Get AVD Info(standard, source type, VD status)
576 /// @ingroup Get_VD_Info
577 /// @return : AVD Info struct
578 //-------------------------------------------------------------------------------------------------
579 extern const AVD_Info* MDrv_AVD_GetInfo(void);
580 
581 //-------------------------------------------------------------------------------------------------
582 /// Get Hsync lock information
583 /// @ingroup Get_VD_Info
584 /// @return TRUE: Hsync lock
585 /// @return FALSE: Hsync unlock
586 //-------------------------------------------------------------------------------------------------
587 extern MS_BOOL MDrv_AVD_IsSyncLocked(void);
588 #if 0 // use MDrv_AVD_IsHsyncLocked
589 extern MS_BOOL MDrv_VD_IsSyncDetected(void);
590 #endif
591 //-------------------------------------------------------------------------------------------------
592 /// Get Hsync lock information while ATV auto-tuning
593 /// @ingroup Get_VD_Info
594 /// @param  u8HtotalTolerance   \b IN: Htotal tolerance for Hsync lock detection
595 /// @return TRUE : Find legal channel while auto-tuning
596 /// @return FALSE : No legal channel while auto-tuning
597 //-------------------------------------------------------------------------------------------------
598 extern MS_U16 MDrv_AVD_Scan_HsyncCheck(MS_U8 u8HtotalTolerance); //TODO should add delay between register read
599 
600 //-------------------------------------------------------------------------------------------------
601 /// Get VD Status
602 /// @ingroup AVD_ToBeRemove
603 /// @return U16 parameters : AVD U16 Status
604 //-------------------------------------------------------------------------------------------------
605 // extern MS_BOOL MDrv_AVD_IsSignalInterlaced(void);
606 
607 //-------------------------------------------------------------------------------------------------
608 /// Get VD Status
609 /// @ingroup AVD_ToBeRemove
610 /// @return U16 parameters : AVD U16 Status
611 //-------------------------------------------------------------------------------------------------
612 // extern MS_BOOL MDrv_AVD_IsColorOn(void);
613 #if 0 // BY 20090403 unused function
614 MS_BOOL MDrv_VD_IsStandardValid(void);
615 #endif
616 //-------------------------------------------------------------------------------------------------
617 /// Get Vsync freq information
618 /// @ingroup Get_VD_Info
619 /// @return Vsync frequency
620 //-------------------------------------------------------------------------------------------------
621 extern AVD_VideoFreq MDrv_AVD_GetVerticalFreq(void);
622 
623 //-------------------------------------------------------------------------------------------------
624 /// Get V total
625 /// @ingroup Get_VD_Info
626 /// @return U16 Vtotal
627 //-------------------------------------------------------------------------------------------------
628 extern MS_U16 MDrv_AVD_GetVTotal(void);
629 
630 //-------------------------------------------------------------------------------------------------
631 /// Get Noise magnitude
632 /// @ingroup Get_VD_Info
633 /// @return U8 Noise
634 //-------------------------------------------------------------------------------------------------
635 extern MS_U8 MDrv_AVD_GetNoiseMag(void);
636 
637 //-------------------------------------------------------------------------------------------------
638 /// Set Input source and MUX
639 /// @ingroup VD_Task
640 /// @param  eSource   \b IN: Input source type
641 /// @param  u8ScartFB   \b IN: Fast blanking setting
642 /// @return TRUE: succeed
643 /// @return FALSE: fail
644 //-------------------------------------------------------------------------------------------------
645 extern MS_BOOL MDrv_AVD_SetInput(AVD_InputSourceType eSource, MS_U8 u8ScartFB);
646 
647 //-------------------------------------------------------------------------------------------------
648 /// Set Video standard
649 /// @ingroup Set_VD_Info
650 /// @param  eStandard   \b IN: Input video standard type
651 /// @param  bIsInAutoTuning   \b IN: Auto-tuning flag
652 /// @return TRUE: succeed
653 /// @return FALSE: fail
654 //-------------------------------------------------------------------------------------------------
655 extern MS_BOOL MDrv_AVD_SetVideoStandard(AVD_VideoStandardType eStandard, MS_BOOL bIsInAutoTuning);
656 
657 //-------------------------------------------------------------------------------------------------
658 /// Set auto standard detection from force standard
659 /// @ingroup Set_VD_Info
660 /// @return NA
661 //-------------------------------------------------------------------------------------------------
662 extern void MDrv_AVD_StartAutoStandardDetection(void);
663 #if 0 // BY 20090403 unused function
664 extern void MDrv_VD_StopAutoStandardDetection(void);
665 #endif
666 //-------------------------------------------------------------------------------------------------
667 /// Force video standard and disable auto standard detection
668 /// @ingroup Set_VD_Info
669 /// @param  eVideoStandardType   \b IN: Force video standard type
670 /// @return TRUE: succeed
671 /// @return FALSE: fail
672 //-------------------------------------------------------------------------------------------------
673 extern MS_BOOL MDrv_AVD_ForceVideoStandard(AVD_VideoStandardType eVideoStandardType);
674 #if 0 // BY 20090403 use MDrv_VD_StartAutoStandardDetection, not supported
675 extern void MDrv_VD_DisableForceMode(void);
676 #endif
677 #if 0 // BY 20090403 use MDrv_VD_GetStandardDetection, not supported
678 extern AVD_VIDEOSTANDARD_TYPE MDrv_VD_GetResultOfAutoStandardDetection(void);
679 #endif
680 //-------------------------------------------------------------------------------------------------
681 /// Get video standard
682 /// @ingroup Get_VD_Info
683 /// @param  u16LatchStatus   \b IN: AVD status
684 /// @return AVD video standard
685 //-------------------------------------------------------------------------------------------------
686 extern AVD_VideoStandardType MDrv_AVD_GetStandardDetection(MS_U16 *u16LatchStatus);
687 #if 0 // BY 20090408 unused function
688 extern AVD_VIDEOSTANDARD_TYPE MDrv_VD_DetectStandardAutomatically(void);
689 #endif
690 //-------------------------------------------------------------------------------------------------
691 /// Get VD Status
692 /// @ingroup AVD_ToBeRemove
693 /// @return U16 parameters : AVD U16 Status
694 //-------------------------------------------------------------------------------------------------
695 // extern AVD_VideoStandardType MDrv_AVD_GetLastDetectedStandard(void);
696 #if 0 // BY 20090403 unused function
697 extern void MDrv_VD_EnableAutoGainControl(MS_BOOL bEnable);
698 #endif
699 //-------------------------------------------------------------------------------------------------
700 /// Set 3D COMB para
701 /// @ingroup COMB relative
702 /// @param  bEnable   \b IN: set 3D COMB enable
703 //-------------------------------------------------------------------------------------------------
704 extern void MDrv_AVD_Set3dComb(MS_BOOL bEnable);
705 
706 //-------------------------------------------------------------------------------------------------
707 /// Set 3D COMB speed up settings
708 /// @ingroup COMB relative
709 //-------------------------------------------------------------------------------------------------
710 extern void MDrv_AVD_3DCombSpeedup(void);
711 
712 //-------------------------------------------------------------------------------------------------
713 /// Get VD Status
714 /// @ingroup AVD_ToBeRemove
715 /// @return U16 parameters : AVD U16 Status
716 //-------------------------------------------------------------------------------------------------
717 // extern void MDrv_AVD_SetFreerunPLL(AVD_VideoFreq eVideoFreq);// 060508 chris
718 
719 //-------------------------------------------------------------------------------------------------
720 /// Set free run vertical lines
721 /// @ingroup COMB relative
722 /// @param  eFreerunfreq   \b IN: input freen run frequency
723 //-------------------------------------------------------------------------------------------------
724 extern void MDrv_AVD_SetFreerunFreq(AVD_FreeRunFreq eFreerunfreq);
725 
726 //-------------------------------------------------------------------------------------------------
727 /// Set register from DSP and monitor register settings
728 /// @ingroup VD_Task
729 //-------------------------------------------------------------------------------------------------
730 extern void MDrv_AVD_SetRegFromDSP(void);
731 
732 //-------------------------------------------------------------------------------------------------
733 /// Set AVD patch flag
734 /// @ingroup Set_VD_Info
735 /// @param  u32VDPatchFlag   \b IN: AVD patch flag
736 //-------------------------------------------------------------------------------------------------
737 extern void MDrv_AVD_SetFlag(MS_U32  u32VDPatchFlag);
738 
739 //-------------------------------------------------------------------------------------------------
740 /// Get AVD patch flag
741 /// @ingroup Get_VD_Info
742 /// @return AVD patch flag
743 //-------------------------------------------------------------------------------------------------
744 extern MS_U32 MDrv_AVD_GetFlag(void);
745 
746 //-------------------------------------------------------------------------------------------------
747 /// Set output sampling htotal by user
748 /// @ingroup Set_VD_Info
749 /// @param  u16Htt   \b IN: output htotal
750 //-------------------------------------------------------------------------------------------------
751 extern void MDrv_AVD_Set_Htt_UserMD(MS_U16 u16Htt);
752 
753 //-------------------------------------------------------------------------------------------------
754 /// Reset DSP AGC duriing ATV channel change
755 /// @ingroup Set_VD_Info
756 //-------------------------------------------------------------------------------------------------
757 extern void MDrv_AVD_SetChannelChange(void);
758 
759 //-------------------------------------------------------------------------------------------------
760 /// Set Hsync lock sensitivity for auto-tuning/normal
761 /// @ingroup Set_VD_Info
762 /// @param  bEnable   \b IN: auto-tuning:1  normal:0   Hsync sensitivity settings
763 //-------------------------------------------------------------------------------------------------
764 extern void MDrv_AVD_SetHsyncDetectionForTuning(MS_BOOL bEnable);
765 
766 //-------------------------------------------------------------------------------------------------
767 /// Set AVD register
768 /// @ingroup Set_VD_Info
769 /// @param  u16Addr   \b IN: register address
770 /// @param  u8Value   \b IN: register value
771 //-------------------------------------------------------------------------------------------------
772 extern void MDrv_AVD_SetRegValue(MS_U16 u16Addr,MS_U8 u8Value);
773 
774 //-------------------------------------------------------------------------------------------------
775 /// Get AVD register value
776 /// @ingroup Get_VD_Info
777 /// @param  u16Addr   \b IN: register address
778 /// @return register value
779 //-------------------------------------------------------------------------------------------------
780 extern MS_U8 MDrv_AVD_GetRegValue(MS_U16 u16Addr);
781 
782 //-------------------------------------------------------------------------------------------------
783 /// Load VD DSP code
784 /// @ingroup AVD_ToBeRemove
785 //-------------------------------------------------------------------------------------------------
786 // extern void MDrv_AVD_LoadDSP(MS_U8 *pu8VD_DSP, MS_U32 len);
787 
788 //-------------------------------------------------------------------------------------------------
789 /// Set fixed gain enable
790 /// @ingroup AVD_ToBeRemove
791 //-------------------------------------------------------------------------------------------------
792 // extern void MDrv_AVD_SetPQFineTune(void);
793 
794 //-------------------------------------------------------------------------------------------------
795 /// Set 3D COMB speed para
796 /// @ingroup COMB relative
797 /// @param  u8COMB57   \b IN: set BK_COMB_57 value
798 /// @param  u8COMB58   \b IN: set BK_COMB_58 value
799 //-------------------------------------------------------------------------------------------------
800 // extern void MDrv_AVD_Set3dCombSpeed(MS_U8 u8COMB57, MS_U8 u8COMB58);
801 
802 //-------------------------------------------------------------------------------------------------
803 /// Get capture window
804 /// @ingroup AVD_ToBeRemove
805 //-------------------------------------------------------------------------------------------------
806 extern void MDrv_AVD_GetCaptureWindow(void *stCapWin, AVD_VideoStandardType eVideoStandardType);
807 
808 //-------------------------------------------------------------------------------------------------
809 /// Read value from VD mailbox
810 /// @ingroup AVD_ToBeRemove
811 //-------------------------------------------------------------------------------------------------
812 extern MS_U8 MDrv_AVD_MBX_ReadByteByVDMbox(MS_U8 u8Addr);
813 
814 //-------------------------------------------------------------------------------------------------
815 /// Get Hsync edge
816 /// @ingroup Get_VD_Info
817 /// @return Hsync edge
818 //-------------------------------------------------------------------------------------------------
819 extern MS_U8 MDrv_AVD_GetHsyncEdge(void);
820 
821 //-------------------------------------------------------------------------------------------------
822 /// Set 3D COMB stillimage parameters
823 /// @ingroup COMB relative
824 /// @param  param   \b IN: Stillimage parameters
825 //-------------------------------------------------------------------------------------------------
826 extern void MDrv_AVD_SetStillImageParam(AVD_Still_Image_Param param);
827 
828 //-------------------------------------------------------------------------------------------------
829 /// Set BK_AFEC_D4 value
830 /// @ingroup AVD_ToBeRemove
831 //-------------------------------------------------------------------------------------------------
832 // extern void MDrv_AVD_SetAFECD4Factory(MS_U8 u8Value);
833 
834 //-------------------------------------------------------------------------------------------------
835 /// Set 2D/3D COMB patch
836 /// @ingroup AVD_ToBeRemove
837 //-------------------------------------------------------------------------------------------------
838 // extern void MDrv_AVD_Set2D3DPatchOnOff(MS_BOOL bEnable);
839 
840 //-------------------------------------------------------------------------------------------------
841 /// Set back porch position
842 /// @ingroup AVD_ToBeRemove
843 //-------------------------------------------------------------------------------------------------
844 // extern void MDrv_AVD_BackPorchWindowPositon(MS_BOOL bEnable , MS_U8 u8Value);
845 
846 //-------------------------------------------------------------------------------------------------
847 /// Set AVD factory parameters
848 /// @ingroup Set_VD_Info
849 /// @param  FactoryPara   \b IN: factory parameters/register
850 /// @param  u8Value   \b IN: setting value
851 //-------------------------------------------------------------------------------------------------
852 extern void MDrv_AVD_SetFactoryPara(AVD_Factory_Para FactoryPara,MS_U8 u8Value);
853 
854 //-------------------------------------------------------------------------------------------------
855 /// Set fixed gain
856 /// @ingroup AVD_ToBeRemove
857 //-------------------------------------------------------------------------------------------------
858 // extern MS_U8 MDrv_AVD_SetAutoFineGainToFixed(void);
859 
860 //-------------------------------------------------------------------------------------------------
861 /// Get DSP fine gain value
862 /// @ingroup Get_VD_Info
863 /// @return fine gain
864 //-------------------------------------------------------------------------------------------------
865 extern MS_U8 MDrv_AVD_GetDSPFineGain(void);
866 
867 //-------------------------------------------------------------------------------------------------
868 /// Get DSP version
869 /// @ingroup Get_VD_Info
870 /// @return DSP version
871 //-------------------------------------------------------------------------------------------------
872 extern MS_U16 MDrv_AVD_GetDSPVersion(void);
873 
874 //-------------------------------------------------------------------------------------------------
875 /// Shift clock function
876 /// @ingroup AVD_ToBeRemove
877 //-------------------------------------------------------------------------------------------------
878 // extern void MDrv_AVD_ShiftClk(AVD_ATV_CLK_TYPE eShiftMode);
879 
880 //-------------------------------------------------------------------------------------------------
881 /// Set shift clock parameters
882 /// @ingroup Set_VD_Info
883 /// @param  bEnable   \b IN: shift clock enable
884 /// @param  eShiftMode   \b IN: shift clock mode
885 //-------------------------------------------------------------------------------------------------
886 extern void MDrv_AVD_SetShiftClk(MS_BOOL bEnable,AVD_ATV_CLK_TYPE eShiftMode);
887 
888 //-------------------------------------------------------------------------------------------------
889 /// shift clock monitor function
890 /// @ingroup VD_Task
891 //-------------------------------------------------------------------------------------------------
892 // extern void MDrv_AVD_ShifClk_Monitor(void);
893 
894 //-------------------------------------------------------------------------------------------------
895 /// SCART monitor function
896 /// @ingroup VD_Task
897 //-------------------------------------------------------------------------------------------------
898 // extern void MDrv_AVD_SCART_Monitor(void);
899 
900 //-------------------------------------------------------------------------------------------------
901 /// Set AVD STR(resume/suspend) state
902 /// @ingroup Set_VD_Info
903 /// @param  u16PowerState   \b IN: STR state
904 /// @return status
905 //-------------------------------------------------------------------------------------------------
906 extern MS_U32 MDrv_AVD_SetPowerState(EN_POWER_MODE u16PowerState);
907 
908 //-------------------------------------------------------------------------------------------------
909 /// Get MacroVision detection
910 /// @ingroup Get_VD_Info
911 /// @return Macro Vision detection status
912 //-------------------------------------------------------------------------------------------------
913 // extern MS_BOOL MDrv_AVD_GetMacroVisionDetect(void);
914 
915 //-------------------------------------------------------------------------------------------------
916 /// Get VBI CGMS detection
917 /// @ingroup Get_VD_Info
918 /// @return CGMS detection status
919 //-------------------------------------------------------------------------------------------------
920 // extern MS_BOOL MDrv_AVD_GetCGMSDetect(void);
921 #ifdef __cplusplus
922 }
923 #endif
924 
925 
926 #endif // _DRV_AVD_H_
927 
928