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 apiXC_Adc_EX.h 98 /// @brief MStar ADC API 99 /// @author MStar Semiconductor Inc. 100 /////////////////////////////////////////////////////////////////////////////////////////////////// 101 102 #ifndef _API_XC_ADC_EX_H_ 103 #define _API_XC_ADC_EX_H_ 104 105 // Common 106 #include "MsCommon.h" 107 108 //#include "drvXC_IOPort_EX.h" 109 #include "apiXC_EX.h" 110 111 #ifdef __cplusplus 112 extern "C" 113 { 114 #endif 115 116 //------------------------------------------------------------------------------------------------- 117 // Macro and Define 118 //------------------------------------------------------------------------------------------------- 119 120 //------------------------------------------------------------------------------------------------- 121 // Type and Structure 122 //------------------------------------------------------------------------------------------------- 123 124 /// Struct for store ADC Gain and Offset 125 typedef struct 126 { 127 MS_U16 u16RedGain; ///< ADC red gain 128 MS_U16 u16GreenGain; ///< ADC green gain 129 MS_U16 u16BlueGain; ///< ADC blue gain 130 MS_U16 u16RedOffset; ///< ADC red offset 131 MS_U16 u16GreenOffset; ///< ADC green offset 132 MS_U16 u16BlueOffset; ///< ADC blue offset 133 } XC_ADC_EX_AdcGainOffsetSetting; 134 135 /// ADC output internal voltage type 136 typedef enum 137 { 138 E_XC_ADC_EX_Internal_0V, ///< Output 0V 139 E_XC_ADC_EX_Internal_0_1V, ///< Output 0.1V 140 E_XC_ADC_EX_Internal_0_6V, ///< Output 0.6V 141 E_XC_ADC_EX_Internal_None, ///< OFF 142 } XC_ADC_EX_Internal_Voltage; 143 144 /// ADC output Clock type 145 typedef enum 146 { 147 E_XC_ADC_EX_Gen_480P_Clk, ///< ADC output 480P 148 E_XC_ADC_EX_Gen_720P_Clk, ///< ADC output 720P 149 E_XC_ADC_EX_Gen_1080P_Clk, ///< ADC output 1080P 150 } XC_ADC_EX_Gen_Clock_Type; 151 152 /// ADC V Clamping type 153 typedef enum 154 { 155 E_XC_ADC_EX_VClamp_0_85V, ///< Clamp to 0.85V 156 E_XC_ADC_EX_VClamp_0_9V, ///< Clamp to 0.9V 157 E_XC_ADC_EX_VClamp_0_95V, ///< Clamp to 0.95V 158 E_XC_ADC_EX_VClamp_1_0V, ///< Clamp to 1.0V 159 E_XC_ADC_EX_VClamp_1_05V, ///< Clamp to 1.05V 160 E_XC_ADC_EX_VClamp_1_2V, ///< Clamp to 1.2V 161 E_XC_ADC_EX_VClamp_1_5V, ///< Clamp to 1.5V 162 } XC_ADC_EX_VClamp_Level_Type; 163 164 /// Update Gain / Offset for specific channel. This is used in MApi_XC_ADC_EX_SetGain or MApi_XC_ADC_EX_SetOffset 165 typedef enum 166 { 167 E_XC_ADC_EX_CHR = 0, ///< Channel R 168 E_XC_ADC_EX_CHG, ///< Channel G 169 E_XC_ADC_EX_CHB, ///< Channel B 170 E_XC_ADC_EX_ALL, ///< All Channel 171 } XC_ADC_EX_CHANNEL_t; 172 173 /// Software reset for ADCDVIPLL block 174 typedef enum 175 { 176 E_XC_ADC_EX_REST_ATOP = _XC_EX_BIT(7), ///< Reset ATOP 177 E_XC_ADC_EX_REST_HDMI = _XC_EX_BIT(6), 178 E_XC_ADC_EX_REST_HDCP = _XC_EX_BIT(5), 179 E_XC_ADC_EX_REST_DVI = _XC_EX_BIT(4), 180 E_XC_ADC_EX_REST_PLL_DIG_B = _XC_EX_BIT(3), 181 E_XC_ADC_EX_REST_ADC_DIG_B = _XC_EX_BIT(2), 182 E_XC_ADC_EX_REST_PLL_DIG_A = _XC_EX_BIT(1), 183 E_XC_ADC_EX_REST_ADC_DIG_A = _XC_EX_BIT(0), 184 E_XC_ADC_EX_REST_PLL = ( E_XC_ADC_EX_REST_PLL_DIG_B | E_XC_ADC_EX_REST_PLL_DIG_A ), ///< Reset PLL 185 E_XC_ADC_EX_REST_ADC = ( E_XC_ADC_EX_REST_ADC_DIG_B | E_XC_ADC_EX_REST_ADC_DIG_A ), ///< Reset All ADC 186 } XC_ADC_EX_RESET; 187 188 189 //------------------------------------------------------------------------------------------------- 190 // Function and Variable 191 //------------------------------------------------------------------------------------------------- 192 //****************************************************************************** 193 /// Enable and Disable CVBS out. This will setup ADC part for CVBS out (monitor out). 194 /// @param bEnable \b IN Enable CVBS Out 195 /// @param enInputPortType \b IN The source need to monitor out. 196 /// @param isDigitalSource \b IN Tell the driver current source is digital source or not. (ex. If internal VIF used in ATV, it will be digital source) 197 //****************************************************************************** 198 DLL_PUBLIC void MApi_XC_ADC_EX_SetCVBSOut(XC_DEVICE_ID *pDeviceId, MS_BOOL bEnable, XC_EX_DEST_TYPE enOutputType , XC_EX_INPUT_SOURCE_TYPE enInputPortType, MS_BOOL isDigitalSource); 199 DLL_PUBLIC MS_BOOL MApi_XC_ADC_EX_IsCVBSOutEnabled(XC_DEVICE_ID *pDeviceId, XC_EX_DEST_TYPE enOutputType); 200 201 /******************************************************************************/ 202 /// Set ADC Sample clock 203 /// @param u16Value \b IN value need to be set. 204 /******************************************************************************/ 205 DLL_PUBLIC void MApi_XC_ADC_EX_SetPcClock(XC_DEVICE_ID *pDeviceId, MS_U16 u16Clock); 206 207 /******************************************************************************/ 208 /// Set ADC Phase, pls use MApi_XC_ADC_SetPhaseEx instead 209 /// @param u8Value \b IN The adc phase need to be update 210 /******************************************************************************/ 211 DLL_PUBLIC void MApi_XC_ADC_EX_SetPhase(XC_DEVICE_ID *pDeviceId, MS_U8 u8Value); 212 213 /******************************************************************************/ 214 /// Set ADC Phase Ex 215 /// @param u16Value \b IN The adc phase need to be update 216 /******************************************************************************/ 217 DLL_PUBLIC void MApi_XC_ADC_EX_SetPhaseEx(XC_DEVICE_ID *pDeviceId, MS_U16 u16Value); 218 219 //****************************************************************************** 220 /// Get current ADC Phase set 221 /// @return Current Phase 222 //****************************************************************************** 223 DLL_PUBLIC MS_U16 MApi_XC_ADC_EX_GetPhaseRange( XC_DEVICE_ID *pDeviceId ); 224 225 //****************************************************************************** 226 /// Get current ADC Phase set 227 /// @return Current Phase 228 //****************************************************************************** 229 DLL_PUBLIC MS_U8 MApi_XC_ADC_EX_GetPhase( XC_DEVICE_ID *pDeviceId ); 230 DLL_PUBLIC MS_U16 MApi_XC_ADC_EX_GetPhaseEx( XC_DEVICE_ID *pDeviceId ); 231 232 DLL_PUBLIC MS_BOOL MApi_XC_ADC_EX_IsScartRGB(XC_DEVICE_ID *pDeviceId); 233 DLL_PUBLIC MS_U16 MApi_XC_ADC_EX_GetPcClock(XC_DEVICE_ID *pDeviceId ); 234 235 /******************************************************************************/ 236 ///Get SOG level range 237 ///@param u32Min \b OUT: min of SOG level 238 ///@param u32Max \b OUT: max of SOG level 239 ///@param u32Recommend_value \b OUT: recommend value 240 /******************************************************************************/ 241 DLL_PUBLIC void MApi_XC_ADC_EX_GetSoGLevelRange(XC_DEVICE_ID *pDeviceId, MS_U32 *u32min, MS_U32 *u32max, MS_U32 *u32Recommend_value); 242 243 /******************************************************************************/ 244 ///Set SOG level 245 ///@param u32Min \b IN: set SOG level 246 /******************************************************************************/ 247 DLL_PUBLIC void MApi_XC_ADC_EX_SetSoGLevel(XC_DEVICE_ID *pDeviceId, MS_U32 u32Value); 248 249 // power 250 //****************************************************************************** 251 /// Turn off ADC 252 //****************************************************************************** 253 DLL_PUBLIC void MApi_XC_ADC_EX_PowerOff(XC_DEVICE_ID *pDeviceId); 254 255 // ADC calibration 256 //****************************************************************************** 257 /// Get ADC Default gain / offset by referring input structure. 258 /// @param eSource \b IN The input source 259 /// @param pstADCSetting \b IN gain / offset need to be set 260 //****************************************************************************** 261 DLL_PUBLIC void MApi_XC_ADC_EX_GetDefaultGainOffset(XC_DEVICE_ID *pDeviceId, XC_EX_INPUT_SOURCE_TYPE eSource , XC_ADC_EX_AdcGainOffsetSetting* pstADCSetting); 262 263 //****************************************************************************** 264 /// get maximal value of offset 265 /// @param 266 /// @return maximal value of offset 267 //****************************************************************************** 268 DLL_PUBLIC MS_U16 MApi_XC_ADC_EX_GetMaximalOffsetValue(XC_DEVICE_ID *pDeviceId); 269 270 //****************************************************************************** 271 /// get maximal value of gain 272 /// @param 273 /// @return maximal value of gain 274 //****************************************************************************** 275 DLL_PUBLIC MS_U16 MApi_XC_ADC_EX_GetMaximalGainValue(XC_DEVICE_ID *pDeviceId); 276 277 //****************************************************************************** 278 /// get center value of gain 279 /// @param 280 /// @return center value of gain 281 //****************************************************************************** 282 DLL_PUBLIC MS_U16 MApi_XC_ADC_EX_GetCenterGain(XC_DEVICE_ID *pDeviceId); 283 284 //****************************************************************************** 285 /// get center value of offset 286 /// @param 287 /// @return center value of offset 288 //****************************************************************************** 289 DLL_PUBLIC MS_U16 MApi_XC_ADC_EX_GetCenterOffset(XC_DEVICE_ID *pDeviceId); 290 291 // Set Gain & Offset 292 // u8Color is one of ADC_CHANNEL_t. 293 //****************************************************************************** 294 /// Set Gain value 295 /// @param u8color \b IN The channel type need to be set 296 /// @param u16value \b IN The value need to be set. 297 //****************************************************************************** 298 DLL_PUBLIC void MApi_XC_ADC_EX_SetGain(XC_DEVICE_ID *pDeviceId, MS_U8 u8color, MS_U16 u16value); 299 300 //****************************************************************************** 301 /// Set offset value 302 /// @param u8color \b IN The channel type need to be set 303 /// @param u16value \b IN The value need to be set. 304 //****************************************************************************** 305 DLL_PUBLIC void MApi_XC_ADC_EX_SetOffset(XC_DEVICE_ID *pDeviceId, MS_U8 u8color, MS_U16 u16value); 306 307 //****************************************************************************** 308 /// Set ADC gain / offset by referring input structure. 309 /// @param pstADCSetting \b IN gain / offset need to be set 310 //****************************************************************************** 311 DLL_PUBLIC void MApi_XC_ADC_EX_AdjustGainOffset(XC_DEVICE_ID *pDeviceId, XC_ADC_EX_AdcGainOffsetSetting* pstADCSetting); 312 313 //****************************************************************************** 314 /// Set ADC Internal calibration. (need to be set during set mode) 315 /// @param enInputSourceType \b IN current input source. 316 //****************************************************************************** 317 DLL_PUBLIC void MApi_XC_ADC_EX_Source_Calibrate(XC_DEVICE_ID *pDeviceId, XC_EX_INPUT_SOURCE_TYPE enInputSourceType); 318 319 /******************************************************************************/ 320 ///Set SOG level 321 ///@param u32Min \b IN: set SOG calibration 322 /******************************************************************************/ 323 DLL_PUBLIC void MApi_XC_ADC_EX_SetSoGCal(XC_DEVICE_ID *pDeviceId); 324 325 //Set SCART RGB PIPE Delay 326 DLL_PUBLIC void MApi_XC_ADC_EX_SetRGB_PIPE_Delay(XC_DEVICE_ID *pDeviceId, MS_U8 u8Value); 327 328 //Set Scart RGB Sync on green clamp delay value 329 DLL_PUBLIC void MApi_XC_ADC_EX_ScartRGB_SOG_ClampDelay(XC_DEVICE_ID *pDeviceId, MS_U16 u16Clpdly, MS_U16 u16Caldur); 330 331 DLL_PUBLIC void MApi_XC_ADC_EX_Set_YPbPrLooseLPF(XC_DEVICE_ID *pDeviceId, MS_BOOL benable); 332 333 /******************************************************************************/ 334 ///Set SOG BW 335 ///@param u16value \b IN: set SOG BW 336 /******************************************************************************/ 337 DLL_PUBLIC void MApi_XC_ADC_EX_Set_SOGBW(XC_DEVICE_ID *pDeviceId, MS_U16 u16value); 338 339 // Set Clamp Duration 340 DLL_PUBLIC void MApi_XC_ADC_EX_SetClampDuration(XC_DEVICE_ID *pDeviceId, MS_U16 u16Value); 341 342 /******************************************************************************/ 343 ///Enable HW calibration, will load hw adc table when changing source 344 ///@param bEnable \b IN: enable hw calibration 345 /******************************************************************************/ 346 DLL_PUBLIC MS_BOOL MApi_XC_ADC_EX_EnableHWCalibration(XC_DEVICE_ID *pDeviceId, MS_BOOL bEnable); 347 348 #ifdef __cplusplus 349 } 350 #endif 351 352 #endif // _API_XC_ADC_EX_H_ 353 354