xref: /utopia/UTPA2-700.0.x/modules/xc/hal/mooney/xc/include/mhal_adc.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!!L) 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 // [mhal_adc.h]
96 // Date: 20081203
97 // Descriptions: Add a new layer for HW setting
98 //==============================================================================
99 #ifndef MHAL_ADC_H
100 #define MHAL_ADC_H
101 
102 
103 //#include "hwreg_utility.h"
104 #include "MsCommon.h"
105 
106 #define ADC_SOG_FILTER_THRSHLD      40
107 
108 #define ADC_BANDWIDTH_CLK_THRSHLD0    6 // 8/0.75
109 #define ADC_BANDWIDTH_CLK_THRSHLD1    14 // 8/0.75
110 #define ADC_BANDWIDTH_CLK_THRSHLD2    15 // 8/0.75
111 #define ADC_BANDWIDTH_CLK_THRSHLD3    16 // 8/0.75
112 #define ADC_BANDWIDTH_CLK_THRSHLD4    17 // 8/0.75
113 #define ADC_BANDWIDTH_CLK_THRSHLD5    18 // 8/0.75
114 #define ADC_BANDWIDTH_CLK_THRSHLD6    20 // 8/0.75
115 #define ADC_BANDWIDTH_CLK_THRSHLD7    21 // 8/0.75
116 #define ADC_BANDWIDTH_CLK_THRSHLD8    23 // 8/0.75
117 #define ADC_BANDWIDTH_CLK_THRSHLD9    25 // 20/0.75
118 #define ADC_BANDWIDTH_CLK_THRSHLD10    30 // 50/0.75
119 #define ADC_BANDWIDTH_CLK_THRSHLD11    60 // 100/0.75
120 #define ADC_BANDWIDTH_CLK_THRSHLD12    120 // 200/0.75
121 #define ADC_BANDWIDTH_CLK_THRSHLD13    150 // 300/0.75
122 #define ADC_BANDWIDTH_CLK_THRSHLD14    190 // 400/0.75
123 #define ADC_BANDWIDTH_CLK_THRSHLD15    260 // 500/0.75
124 
125 #define ADC_REFERENCE_VOLATAGE_LDO      0
126 #define ADC_REFERENCE_VOLATAGE_BANDGAP  1
127 
128 #define ADC_IDAC_CURRENT_MODE_FULL 0
129 #define ADC_IDAC_CURRENT_MODE_HALF 1
130 #define ADC_IDAC_CURRENT_MODE_QUART 2
131 /******************************************************************************/
132 /*                   Function Prototypes                     */
133 /******************************************************************************/
134 
135 void Hal_ADC_set_cvbs_out(void *pInstance, E_ADC_CVBSOUT_TYPE e_cvbs_out_type);
136 MS_BOOL Hal_ADC_is_cvbs_out_enabled(void *pInstance, E_MUX_OUTPUTPORT outputPort);
137 void Hal_ADC_clk_gen_setting(void *pInstance, ADC_Gen_Clock_Type clocktype);
138 void Hal_ADC_set_mux(void *pInstance, E_MUX_INPUTPORT port);
139 void Hal_ADC_set_CVBSOMux(void *pInstance, ADC_CVBSOPortNumber CVBSOPortNumber, E_MUX_INPUTPORT port);
140 
141 void Hal_ADC_gainoffset_reset(void *pInstance);
142 void Hal_ADC_offset_setting(void *pInstance, XC_AdcGainOffsetSetting *pstADCSetting);
143 void Hal_ADC_gain_setting(void *pInstance, XC_AdcGainOffsetSetting *pstADCSetting);
144 void Hal_ADC_ExitExternalCalibration(void *pInstance, ADC_INPUTSOURCE_TYPE eADC_Source,XC_AdcGainOffsetSetting* InitialGainOffset);
145 MS_BOOL Hal_ADC_InitExternalCalibration(void *pInstance, ADC_INPUTSOURCE_TYPE enAdcSource);
146 void Hal_ADC_InitInternalCalibration(void *pInstance, ADC_INPUTSOURCE_TYPE enAdcSource, SCALER_WIN eWindow);
147 void Hal_ADC_ext_clk_en(void *pInstance, MS_BOOL benable);
148 void Hal_ADC_hdmi_vco_ctrl(void *pInstance, MS_U16 u16InputClock);
149 void Hal_ADC_vco_ctrl(void *pInstance, MS_U16 u16InputClock);
150 void Hal_XC_ADC_Set_VClamp_level(void *pInstance, ADC_VClamp_Level_Type type);
151 void Hal_ADC_set_vco_ctrl(void *pInstance, MS_BOOL bIsDVIPort, MS_U16 u16InputClock);
152 
153 
154 void Hal_ADC_sog_filter_en(void *pInstance, MS_BOOL bEnable);
155 void Hal_ADC_reset(void *pInstance, MS_U16 u16Reset);
156 
157 void Hal_ADC_dtop_internaldc_setting(void *pInstance, ADC_Internal_Voltage InternalVoltage);
158 
159 //  Set RGB Gain setting
160 void Hal_ADC_SetGainR(void *pInstance, MS_U16 u16value);
161 void Hal_ADC_SetGainG(void *pInstance, MS_U16 u16value);
162 void Hal_ADC_SetGainB(void *pInstance, MS_U16 u16value);
163 //  Get RGB Gain setting
164 MS_U16 Hal_ADC_GetGainR(void *pInstance);
165 MS_U16 Hal_ADC_GetGainG(void *pInstance);
166 MS_U16 Hal_ADC_GetGainB(void *pInstance);
167 
168 //  Set RGB Offset setting
169 void Hal_ADC_SetOffsetR(void *pInstance, MS_U16 u16value);
170 void Hal_ADC_SetOffsetG(void *pInstance, MS_U16 u16value);
171 void Hal_ADC_SetOffsetB(void *pInstance, MS_U16 u16value);
172 //  Get RGB Offset setting
173 MS_U16 Hal_ADC_GetOffsetR(void *pInstance);
174 MS_U16 Hal_ADC_GetOffsetG(void *pInstance);
175 MS_U16 Hal_ADC_GetOffsetB(void *pInstance);
176 
177 void Hal_ADC_dtop_calibration_target_setting(void *pInstance, MS_BOOL bIsYPbPrFlag);
178 void Hal_ADC_dtop_sw_mode_setting(void *pInstance, MS_BOOL bEnable, MS_BOOL bIsAutoSWMode);
179 
180 void Hal_ADC_reset(void *pInstance, MS_U16 u16Reset);
181 void Hal_ADC_Set_Source(void *pInstance, ADC_INPUTSOURCE_TYPE enADC_SourceType, E_MUX_INPUTPORT* enInputPortType, MS_U8 u8PortCount);
182 void Hal_ADC_dtop_clk_setting ( void *pInstance, MS_U16 u16Value );
183 void Hal_ADC_hpolarity_setting(void *pInstance, MS_BOOL bHightActive);
184 void Hal_ADC_set_phase(void *pInstance, MS_U8 u8Value);
185 void Hal_ADC_set_phaseEx(void *pInstance, MS_U16 u16Value);
186 MS_U16 Hal_ADC_get_phase_range(void *pInstance);
187 MS_U8 Hal_ADC_get_phase(void *pInstance);
188 MS_U16 Hal_ADC_get_phaseEx(void *pInstance);
189 void Hal_ADC_Set_Source_Calibration(void *pInstance, ADC_INPUTSOURCE_TYPE enADC_SourceType);
190 void Hal_ADC_clamp_placement_setting(void *pInstance, MS_U16 u16InputClockMHz);
191 void Hal_ADC_dvi_setting(void *pInstance);
192 void Hal_ADC_poweroff(void *pInstance);
193 void Hal_XC_ADC_poweron_source(void *pInstance, ADC_INPUTSOURCE_TYPE enADC_SourceType);
194 
195 void Hal_ADC_set_mode(void *pInstance, ADC_INPUTSOURCE_TYPE enADCInput, MS_U16 u16PixelClockPerSecond, MS_U16 u16HorizontalTotal, MS_U16 u16SamplingRatio);
196 void Hal_ADC_SourceSwitch(void *pInstance, MS_BOOL bSwitch);
197 
198 void Hal_ADC_auto_adc_backup(void *pInstance, SCALER_WIN eWindow);
199 void Hal_ADC_auto_adc_restore(void *pInstance, SCALER_WIN eWindow);
200 
201 void Hal_ADC_disable_csc(void *pInstance, SCALER_WIN eWindow);
202 MS_BOOL Hal_ADC_is_scart_rgb(void *pInstance);
203 MS_U16 Hal_ADC_get_clk (void *pInstance);
204 void Hal_ADC_get_SoG_LevelRange(void *pInstance, MS_U32 *u32Min, MS_U32 *u32Max, MS_U32 *u32Recommend_value);
205 void Hal_ADC_set_SoG_Level(void *pInstance, MS_U32 u32Value);
206 MS_BOOL Hal_ADC_set_SoG_Calibration(void *pInstance);
207 
208 void Hal_ADC_set_RGB_PIPE_Delay(void *pInstance, MS_U8 u8Value);
209 void Hal_ADC_set_ScartRGB_SOG_ClampDelay(void *pInstance, MS_U16 u16Clpdly, MS_U16 u16Caldur);
210 void Hal_ADC_set_YPbPrLooseLPF(void *pInstance, MS_BOOL benable);
211 void Hal_ADC_Set_SOGBW(void *pInstance, MS_U16 u16value);
212 
213 void Hal_ADC_dtop_iClampDuration_setting(void *pInstance, MS_U16 u16value);
214 void Hal_ADC_dtop_vClampDuration_setting(void *pInstance, MS_U16 u16value);
215 
216 void Hal_ADC_Enable_HWCalibration(void *pInstance, MS_BOOL bEnable);
217 MS_BOOL Hal_ADC_SetCalibrationRefSource(void *pInstance, MS_U16 type);
218 MS_U16 Hal_ADC_GetCalibrationRefSource(void *pInstance);
219 
220 void Hal_ADC_ISOG_Enable(void *pInstance, MS_BOOL bEnable);
221 MS_BOOL Hal_ADC_ISOG_CheckEnabled(void *pInstance);
222 void Hal_ADC_ISOG_SetResetWidth(void *pInstance, MS_U8 u8value);
223 
224 MS_BOOL Hal_ADC_SetIdacCurrentMode(void *pInstance, MS_U16 u16mode);
225 MS_U16 Hal_ADC_GetIdacCurrentMode(void *pInstance);
226 #endif // MHAL_ADC_H
227 
228