xref: /utopia/UTPA2-700.0.x/modules/xc/drv/xc/include/mhal_ip.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_ip.h]
96 // Date: 20081203
97 // Descriptions: Add a new layer for HW setting
98 //==============================================================================
99 #ifndef MHAL_IP_H
100 #define MHAL_IP_H
101 
102 #include "hwreg_sc.h"
103 
104 //==============================================================================
105 //==============================================================================
106 
107 #define MST_H_PERIOD_MASK           0x3FFF
108 #define MST_V_TOTAL_MASK            0x1FFF
109 
110 //==============================================================================
111 //==============================================================================
112 #ifdef MHAL_IP_C
113 #define INTERFACE
114 #else
115 #define INTERFACE extern
116 #endif
117 
118 //for BK01_0x03[4:3]
119 #define LEADING_EDGE    0
120 #define TAILING_EDGE    1
121 
122 //for BK01_0x03[5]
123 #define DELAY_QUARTER_HSYNC 0
124 #define NO_DELAY            1
125 
126 //for BK01_0x24[5]
127 #define PC_SOURCE           0
128 #define COMPONENT_VIDEO     1
129 
130 //for BK01_0x26[2]
131 #define NORMAL_MODE     0
132 #define GLITCH_REMOVAL  1
133 
134 //pure color ip pattern value
135 #define PURE_COR_IP_PATTERN_VALUE 0x1841
136 
137 // Force interlace mode for HDMI by HW/SW/Auto
138 typedef enum
139 {
140     ForceI_HW,    //<<< set REG_SC_BK12_05[10] = 1'b1, then HW will do it.
141     ForceI_SW,    //<<< Need to adjust Vtt/Capture..
142     ForceI_Auto,    //<<< don't have to do anything , HW auto do
143 } EN_FORCEi_SUPPORT_TYPE;
144 
145 INTERFACE MS_U16 Hal_SC_ip_de_hstart_info(void *pInstance, SCALER_WIN eWindow);
146 INTERFACE MS_U16 Hal_SC_ip_de_hend_info(void *pInstance, SCALER_WIN eWindow);
147 
148 INTERFACE MS_U16 Hal_SC_ip_de_vstart_info(void *pInstance, SCALER_WIN eWindow);
149 INTERFACE MS_U16 Hal_SC_ip_de_vend_info(void *pInstance, SCALER_WIN eWindow);
150 
151 INTERFACE MS_U8 Hal_SC_ip_get_sync_flag(void *pInstance, SCALER_WIN eWindow);
152 
153 INTERFACE MS_U8 Hal_SC_ip_get_input_vsync_polarity(void *pInstance);
154 INTERFACE MS_U8 Hal_SC_ip_get_input_vsync_value(void *pInstance, SCALER_WIN eWindow);
155 INTERFACE MS_U8 Hal_SC_ip_get_output_vsync_value(void *pInstance, SCALER_WIN eWindow);
156 
157 INTERFACE MS_U8 Hal_SC_ip_get_sync_detect_status(void *pInstance, SCALER_WIN eWindow);
158 
159 INTERFACE MS_U8 Hal_SC_ip_get_interlace_status (void *pInstance, SCALER_WIN eWindow);
160 INTERFACE void Hal_SC_ip_set_ms_filter(void *pInstance, MS_BOOL bEnable, MS_U16 u16FilterRange, SCALER_WIN eWindow );
161 INTERFACE void Hal_SC_ip_set_coast_window(void *pInstance, MS_U8 u8Start, MS_U8 u8End, SCALER_WIN eWindow);
162 
163 INTERFACE void Hal_SC_ip_sog_detect(void *pInstance);
164 
165 
166 INTERFACE void Hal_SC_IPMux_Gen_SpecificTiming(void *pInstance, XC_Internal_TimingType timingtype );  //scaler 480p timing setting
167 INTERFACE MS_U16  Hal_SC_ip_get_h_position(void); //NO_USE
168 INTERFACE MS_U16  Hal_SC_ip_get_v_position(void); //NO_USE
169 INTERFACE void Hal_SC_ip_get_capture_window(void *pInstance, MS_WINDOW_TYPE* capture_win, SCALER_WIN eWindow);
170 INTERFACE void Hal_SC_ip_set_capture_v_start(void *pInstance, MS_U16 u16Vstart , SCALER_WIN eWindow);
171 INTERFACE void Hal_SC_ip_set_capture_h_start(void *pInstance, MS_U16 u16Hstart , SCALER_WIN eWindow);
172 INTERFACE void Hal_SC_ip_set_capture_v_start_with_Menuload(void *pInstance, MS_U16 u16Vstart , SCALER_WIN eWindow);
173 INTERFACE void Hal_SC_ip_set_capture_h_start_with_Menuload(void *pInstance, MS_U16 u16Hstart , SCALER_WIN eWindow);
174 INTERFACE void Hal_SC_ip_set_capture_v_size(void *pInstance, MS_U16 u16Vsize , SCALER_WIN eWindow);
175 INTERFACE void Hal_SC_ip_set_capture_h_size(void *pInstance, MS_U16 u16Hsize , SCALER_WIN eWindow);
176 INTERFACE void Hal_SC_ip_set_fir_down_sample_divider(void *pInstance, MS_U8 u8Enable, MS_U16 u16OverSampleCount,SCALER_WIN eWindow);
177 INTERFACE MS_BOOL Hal_XC_MApi_XC_IPAutoNoSignal_GetCaps(void); //NO_NEED
178 INTERFACE void Hal_SC_ip_set_IPAutoNoSignal(void *pInstance, MS_BOOL bEnable, SCALER_WIN eWindow );
179 INTERFACE MS_BOOL Hal_SC_ip_get_IPAutoNoSignal(void *pInstance, SCALER_WIN eWindow);
180 INTERFACE void Hal_SC_ip_enable_turnoff_OP1_for_AutoNoSignal(void *pInstance, MS_BOOL bEnable);
181 INTERFACE void Hal_SC_ip_set_auto_gain_function(void *pInstance, MS_U8 u8Enable, SCALER_WIN eWindow);
182 INTERFACE MS_BOOL Hal_SC_ip_is_auto_gain_result_ready(void *pInstance, SCALER_WIN eWindow);
183 INTERFACE MS_U8 Hal_SC_ip_auto_gain_min_value_status(void *pInstance, SCALER_WIN eWindow);
184 INTERFACE MS_U8 Hal_SC_ip_auto_gain_max_value_status(void *pInstance, SCALER_WIN eWindow);
185 INTERFACE MS_BOOL Hal_SC_ip_is_auto_phase_result_ready(void *pInstance, SCALER_WIN eWindow);
186 INTERFACE MS_U32 Hal_SC_ip_get_auto_phase_value(void *pInstance, SCALER_WIN eWindow);
187 INTERFACE MS_BOOL Hal_SC_ip_is_auto_position_result_ready(void *pInstance, SCALER_WIN eWindow);
188 INTERFACE void Hal_SC_ip_set_auto_position_function(void *pInstance, MS_U8 u8Enable, SCALER_WIN eWindow);
189 INTERFACE void Hal_SC_ip_set_valid_data_threshold( void *pInstance, MS_U8 u8Threshold, SCALER_WIN eWindow );
190 INTERFACE MS_U16 Hal_SC_ip_get_auto_position_v_start(void *pInstance, SCALER_WIN eWindow );
191 INTERFACE MS_U16 Hal_SC_ip_get_auto_position_h_start(void *pInstance, SCALER_WIN eWindow );
192 INTERFACE MS_U16 Hal_SC_ip_get_auto_position_v_end(void *pInstance, SCALER_WIN eWindow );
193 INTERFACE MS_U16 Hal_SC_ip_get_auto_position_h_end(void *pInstance, SCALER_WIN eWindow );
194 INTERFACE void Hal_SC_ip_set_auto_range_window(void *pInstance, MS_U16 u16Vstart, MS_U16 u16Hstart, MS_U16 u16Vsize , MS_U16 u16Hsize, SCALER_WIN eWindow);
195 INTERFACE void Hal_SC_ip_set_auto_range_function(void *pInstance, MS_U8 u8Enable, SCALER_WIN eWindow );
196 INTERFACE void Hal_SC_ip_set_reg_usr_vspolmd(void *pInstance, MS_U8 u8Enable, SCALER_WIN eWindow );
197 INTERFACE void Hal_SC_ip_init_reg_in_timingchange(void *pInstance, SCALER_WIN eWindow);
198 
199 INTERFACE MS_BOOL HAL_SC_set_GOP_Enable(void *pInstance, MS_U8 MaxGOP ,MS_U8 UseNum, MS_U8 u8MuxNum, MS_BOOL bEnable);
200 INTERFACE void HAL_SC_ip_sel_for_gop(void *pInstance, MS_U8 u8MuxNum ,MS_XC_IPSEL_GOP ipSelGop);
201 INTERFACE void HAL_SC_SetVOPNBL(void *pInstance);
202 
203 void Hal_SC_ip_software_reset(void *pInstance, MS_U8 u8Reset, SCALER_WIN eWindow);
204 void Hal_SC_ip_set_input_source(void *pInstance, MS_U8 u8InputSrcSel, MS_U8 u8SyncSel, MS_U8 u8VideoSel, MS_U8 u8isYPbPr, SCALER_WIN eWindow);
205 MS_BOOL Hal_SC_Check_IP_Gen_Timing(void *pInstance);
206 void hal_ip_set_input_10bit(void *pInstance, MS_BOOL bInput10Bit, SCALER_WIN eWindow);
207 void Hal_SC_ip_set_image_wrap(void *pInstance, MS_BOOL bHEnable, MS_BOOL bVEnable, SCALER_WIN eWindow);
208 void Hal_SC_ip_set_input_sync_reference_edge(void *pInstance, MS_BOOL bHRef, MS_BOOL bVRef, SCALER_WIN eWindow);
209 void Hal_SC_ip_set_input_vsync_delay(void *pInstance, MS_BOOL bDelay, SCALER_WIN eWindow);
210 void Hal_SC_ip_set_de_only_mode(void *pInstance, MS_BOOL bEnable, SCALER_WIN eWindow);
211 void Hal_SC_ip_set_coast_input(void *pInstance, MS_BOOL bInputSel, SCALER_WIN eWindow);
212 void Hal_SC_ip_set_DE_Mode_Glitch(void *pInstance, MS_U8 u8Setting , SCALER_WIN eWindow );
213 void Hal_SC_ip_set_input_sync_sample_mode(void *pInstance, MS_BOOL bMode, SCALER_WIN eWindow);
214 void Hal_SC_ip_set_post_glitch_removal(void *pInstance, MS_BOOL bEnble, MS_U8 u8Range, SCALER_WIN eWindow);
215 
216 MS_U8 HAL_SC_ip_get_ipmux(void *pInstance);
217 void HAL_SC_ip_set_ipmux(void *pInstance, MS_U8 u8Val);
218 MS_U8 HAL_SC_ip_get_ipclk(void *pInstance);
219 void HAL_SC_ip_set_ipclk(void *pInstance, MS_U8 u8Val);
220 MS_U8 HAL_SC_ip_get_capturesource(void *pInstance);
221 void HAL_SC_ip_set_capturesource(void *pInstance, MS_U8 u8Val);
222 
223 void Hal_SC_set_skp_fd(void *pInstance, MS_BOOL bEnable, SCALER_WIN eWindow);
224 MS_U8 Hal_SC_ip_get_user_def_interlace_status(void *pInstance);
225 void Hal_SC_ip_set_user_def_interlace_status(void *pInstance, MS_BOOL bEnable, MS_BOOL bIsInterlace,SCALER_WIN eWindow);
226 MS_U8 HAL_SC_ip_get_capture_method(void *pInstance);
227 MS_BOOL HAL_SC_ip_get_capture_format(void *pInstance);
228 void HAL_SC_ip_set_capture_format(void *pInstance, MS_BOOL bIsRGB);
229 
230 
231 MS_BOOL HAL_SC_ip_get_h_predown_info(void *pInstance);
232 MS_BOOL HAL_SC_ip_get_v_predown_info(void *pInstance);
233 void HAL_SC_ip_set_h_predown_info(void *pInstance, MS_BOOL bEnable);
234 void HAL_SC_ip_set_v_predown_info(void *pInstance, MS_BOOL bEnable);
235 
236 MS_BOOL HAL_SC_ip_get_444to422_filter_mod(void *pInstance);
237 void HAL_SC_ip_set_444to422_filter_mod(void *pInstance, MS_BOOL bEnable);
238 
239 MS_U8 HAL_SC_get_memory_fmt(void *pInstance);
240 MS_U8 HAL_SC_get_IPM_memory_fmt(void *pInstance);
241 void HAL_SC_set_IPM_memory_fmt(void *pInstance, MS_U8 u8Value);
242 MS_U8 HAL_SC_get_OPM_memory_fmt(void *pInstance);
243 void HAL_SC_set_OPM_memory_fmt(void *pInstance, MS_U8 u8Value);
244 void HAL_SC_set_capture_image2ip(void *pInstance, MS_BOOL bEnable);
245 MS_U8 HAL_SC_get_VOP_mux(void *pInstance);
246 void HAL_SC_set_VOP_mux(void *pInstance, MS_U8 u8Val);
247 MS_U8 HAL_SC_get_memory_bit_fmt(void *pInstance, SCALER_WIN eWindow);
248 void HAL_SC_set_memory_bit_fmt(void *pInstance, MS_BOOL bEnable_8bit, MS_BOOL bEnable_10bit);
249 void HAL_SC_set_IPM_capture_start(void *pInstance, MS_BOOL bEnable);
250 MS_U32 HAL_SC_get_IRQ_mask_0_31(void *pInstance);
251 void HAL_SC_set_IRQ_mask_0_31(void *pInstance, MS_U32 u32Val);
252 
253 void Hal_SC_ip_set_handshaking_md(void *pInstance, MS_U8 u8MD, SCALER_WIN eWindow);
254 void Hal_SC_ip_Set_TestPattern(void *pInstance, MS_U16 u16Enable, MS_U32 u32Pattern_type, SCALER_WIN eWindow);
255 void Hal_SC_adc_Set_TestPattern(void *pInstance,MS_U8 u8EnableADCType,MS_U16 u16Ramp);
256 void Hal_SC_ipmux_Set_TestPattern(void *pInstance,MS_BOOL bEnable, MS_U16 u16R_CR_Data, MS_U16 u16G_Y_Data ,MS_U16 u16B_CB_Data);
257 void Hal_SC_op_Set_TestPattern(void *pInstance,MS_BOOL bMiuLineBuff, MS_BOOL bLineBuffHVSP);
258 void Hal_SC_vop_Set_TestPattern(void *pInstance,MS_U8 u8Enable);
259 void Hal_SC_vop2_Set_TestPattern(void *pInstance,MS_BOOL bEnable, MS_U16 u16R_Data, MS_U16 u16G_Data ,MS_U16 u16B_Data);
260 void Hal_SC_mod_Set_TestPattern(void *pInstance,MS_BOOL bEnable, MS_U16 u16R_Data, MS_U16 u16G_Data ,MS_U16 u16B_Data);
261 void HAL_SC_ip_3DMainSub_IPSync(void *pInstance);
262 void HAL_SC_ip_detect_mode(void *pInstance, MS_BOOL bEnable, SCALER_WIN eWindow);
263 void HAL_SC_SetVGASogEn(void *pInstance, MS_BOOL bVGASogEn);
264 MS_BOOL HAL_SC_GetVGASogEn(void *pInstance);
265 
266 void HAL_SC_SetSogDetectStatus(void *pInstance, MS_U8  u8SogDetectStatus);
267 MS_U8  HAL_SC_GetSogDetectStatus(void *pInstance);
268 
269 MS_U8 Hal_SC_ip_get_h_v_sync_active(void *pInstance, SCALER_WIN eWindow);
270 MS_U32 HAL_SC_ip_get_verticalperiod(void *pInstance, SCALER_WIN eWindow);
271 
272 void HAL_SC_ip_Set_FD_Mask_ByWin(void *pInstance, MS_BOOL bEnable, SCALER_WIN eWindow);
273 MS_BOOL HAL_SC_ip_Get_FD_Mask_ByWin(void *pInstance, SCALER_WIN eWindow);
274 MS_BOOL HAL_SC_ip_Get_FD_Mask_Status(void *pInstance, SCALER_WIN eWindow);
275 EN_FORCEi_SUPPORT_TYPE HAL_SC_ip_get_forceI_support_type(void *pInstance);
276 void HAL_SC_ip_set_hv_sync_status_check(void *pInstance, MS_BOOL bEnable, SCALER_WIN eWindow);
277 void HAL_SC_ip_set_new_mode_interlaced_detect(void *pInstance, MS_BOOL bEnable, SCALER_WIN eWindow);
278 void HAL_SC_ip_set_hv_sync_source_select(void *pInstance, MS_U8 u8Source, SCALER_WIN eWindow);
279 void HAL_SC_ip_set_vtotal_count_by_pixel_clock(void *pInstance, MS_BOOL bEnable, SCALER_WIN eWindow);
280 void HAL_SC_ip_set_vsync_invert(void *pInstance, MS_BOOL bInvert, SCALER_WIN eWindow);
281 void HAL_SC_ip_set_hsync_invert(void *pInstance, MS_BOOL bInvert, SCALER_WIN eWindow);
282 
283 #undef INTERFACE
284 #endif /* MHAL_IP_H */
285 
286