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 /// @file Mdrv_mhl.h 81 /// @author MStar Semiconductor Inc. 82 /// @brief MHL driver Function 83 /////////////////////////////////////////////////////////////////////////////////////////////////// 84 85 #ifndef _MMHL_MHL_H_ 86 #define _MMHL_MHL_H_ 87 88 #include "mdrv_mhl_st.h" 89 90 //------------------------------------------------------------------------------------------------- 91 // Macro and Define 92 //------------------------------------------------------------------------------------------------- 93 #define MHL_FUNCTION_SUPPORT_PORTA 0 94 #define MHL_FUNCTION_SUPPORT_PORTB 0 95 #define MHL_FUNCTION_SUPPORT_PORTC 0 96 #define MHL_FUNCTION_SUPPORT_PORTD 0 97 98 #define MHL_ICONTROL_PD_24BIT_MODE0 8U 99 #define MHL_ICONTROL_PD_24BIT_MODE1 7U 100 #define MHL_ICONTROL_PD_PP_MODE0 8U 101 #define MHL_ICONTROL_PD_PP_MODE1 7U 102 #define MHL_ICONTROL_PD_600_MODE 2U 103 #define MHL_ICONTROL_PD_300_MODE 2U 104 #define MHL_ICONTROL_PD_150_MODE 4U 105 #define MHL_ICONTROL_PFD_24BIT_MODE0 15U 106 #define MHL_ICONTROL_PFD_24BIT_MODE1 15U 107 #define MHL_ICONTROL_PFD_PP_MODE0 15U 108 #define MHL_ICONTROL_PFD_PP_MODE1 15U 109 #define MHL_ICONTROL_PFD_600_MODE 15U 110 #define MHL_ICONTROL_PFD_300_MODE 8U 111 #define MHL_ICONTROL_PFD_150_MODE 8U 112 113 #define MHL_IMPEDANCE_VALUE 0U 114 #define MHL_ICONTROL_PD_20_VALUE 4U 115 #define MHL_ICONTROL_PD_30_VALUE 2U 116 #define MHL_DIGITAL_UNLOCK_RANGE 0x3E8U 117 #define MHL_LOCK_RESOLUTION 0x1U 118 #define MHL_UNLOCK_RESOLUTION 0x1EU 119 120 #define MHL_EQ_20_SETTING_VALUE 4U 121 #define MHL_EQ_30_SETTING_VALUE 16U 122 #define MHL_HDMI_EQ_SETTING_VALUE 12U 123 124 #define MHL_LOCK_TIME_VALUE 0x7FU 125 #define MHL_HDMI_LOCK_TIME_VALUE 0x1FU 126 127 #define MHL_CHIP_ID_MAXIM 0U 128 129 #define MHL_CDR_STABLE_COUNTER 200U 130 #define MHL_CDR_FORCE_COUNTER 10U 131 #define MHL_AUTO_EQ_ENABLE_COUNTER 5U 132 #define MHL_CDR_STABLE_OFFSET 1U 133 #define MHL_CDR_STABLE_THRESHOLD (MHL_CDR_STABLE_COUNTER +MHL_CDR_STABLE_OFFSET) 134 #define MHL_CDR_FORCE_THRESHOLD (MHL_CDR_STABLE_THRESHOLD +MHL_CDR_FORCE_COUNTER) 135 136 #define CBUS_CDR_CLOCK_TARGET 20U 137 #define CBUS_CLOCK_DETECT_LEVEL (CBUS_CDR_CLOCK_TARGET *128 /12) 138 139 #define CBUS_CDR_OFFSET_TARGET 0.5 140 #define CBUS_CLOCK_DETECT_OFFSET (CBUS_CDR_OFFSET_TARGET *128 /12) 141 142 #define MHL_CBUS_SW_POLLING_MODE 0U // Use SW polling to reply MSC command 143 #define MHL_CBUS_SW_ISR_MODE 1U // Use SW interrupt to reply MSC command 144 #define MHL_CBUS_HW_ISR_MODE 2U // Use SW interrupt to clear MSC receiver flag to trigger HW auto reply 145 #define MHL_CBUS_HW_REPLY_MODE 3U // Use xdata to saving MSC command to trigger HW auto reply 146 147 #define MHL_CBUS_OPERATION_MODE MHL_CBUS_HW_REPLY_MODE 148 149 #define MHL_VBUS_OUTPUT_MODE 1U 150 #define MHL_VBUS_INVERSE_MODE 2U 151 #define MHL_VBUS_LOW_ENABLE_MODE 4U 152 #define MHL_VBUS_HIGH_ENABLE_MODE 8U 153 154 #define MHL_SCALER_MUX_SELECT_DVI 0x1U 155 #define MHL_SCALER_MUX_SELECT_MHL 0xDU 156 157 #define MHL_CBUS_CONNECT_CHECK_VALUE 0xC8U 158 159 #define MHL_CLOCK_THRESHOLD_24BIT_MODE 50U 160 #define MHL_CLOCK_THRESHOLD_PP_MODE0 37U 161 #define MHL_CLOCK_THRESHOLD_PP_MODE1 62U 162 163 #define MHL_ECBUS_AUTO_TRAINING 0 164 165 #define MHL_ECBUS_COMMAND_PARSING 0U 166 #define MHL_BUFFER_ECBUS_DATA_LENGTH 800U 167 168 #define MHL_AUTO_EQ_FUNCTION_ENABLE 1 169 #define MHL_COARSE_TUNE_30_MIN 0x12U 170 #define MHL_COARSE_TUNE_30_DETECT_TIME 0xFFU 171 #define MHL_COARSE_TUNE_30_AABA_NUMBER 0x50U 172 #define MHL_FINE_TUNE_AABA_30_NUMBER 0x1FFFU 173 #define MHL_FINE_TUNE_UNDER_30_THRESHOLD 0x9FFU 174 175 #define MHL_EFUSE_FUNCTION_CONTROL 0 176 177 #define MHL_TMDS_MULTIPLE_ENGINE 1 178 #define MHL_INTERRUPT_USE_PM_IRQ 0 179 #define MHL_ECBUS_ENGINE_SUPPORT 1 180 #define MHL_SELF_CREATE_TASK 1 181 182 #define MHL_CHIP_CAPABILITY0 MHL_TMDS_MULTIPLE_ENGINE 183 #define MHL_CHIP_CAPABILITY1 MHL_INTERRUPT_USE_PM_IRQ 184 #define MHL_CHIP_CAPABILITY2 MHL_ECBUS_ENGINE_SUPPORT 185 #define MHL_CHIP_CAPABILITY3 MHL_SELF_CREATE_TASK 186 #define MHL_CHIP_CAPABILITY4 0 187 #define MHL_CHIP_CAPABILITY5 0 188 #define MHL_CHIP_CAPABILITY6 0 189 #define MHL_CHIP_CAPABILITY7 0 190 191 #define MHL_CHIP_FUNCTION_CAPABILITY_L (MHL_CHIP_CAPABILITY0 |(MHL_CHIP_CAPABILITY1 << 1) |(MHL_CHIP_CAPABILITY2 << 2) |(MHL_CHIP_CAPABILITY3 << 3)) 192 #define MHL_CHIP_FUNCTION_CAPABILITY_H (MHL_CHIP_CAPABILITY4 |(MHL_CHIP_CAPABILITY5 << 1) |(MHL_CHIP_CAPABILITY6 << 2) |(MHL_CHIP_CAPABILITY7 << 3)) 193 194 #define MHL_CHIP_FUNCTION_CAPABILITY (MHL_CHIP_FUNCTION_CAPABILITY_L |(MHL_CHIP_FUNCTION_CAPABILITY_H << 4)) 195 196 enum MHL_DVI_PORT_TYPE 197 { 198 MHL_DVI_PORT_A = 0, 199 MHL_DVI_PORT_B, 200 MHL_DVI_PORT_C, 201 MHL_DVI_PORT_D, 202 }; 203 204 enum MHL_CBUS_SELECT_TYPE 205 { 206 MHL_CBUS_SELECT_PORTA = 0, 207 MHL_CBUS_SELECT_PORTB, 208 MHL_CBUS_SELECT_PORTC, 209 MHL_CBUS_SELECT_PORTD, 210 MHL_CBUS_SELECT_MASK, 211 }; 212 213 enum MHL_PATH_SUPPORT_TYPE 214 { 215 MHL_PATH_SUPPORT_PORTA_FLAG = 0x01, 216 MHL_PATH_SUPPORT_PORTB_FLAG = 0x02, 217 MHL_PATH_SUPPORT_PORTC_FLAG = 0x04, 218 MHL_PATH_SUPPORT_PORTD_FLAG = 0x08, 219 }; 220 221 enum MHL_CABLE_DETECT_SELECT_TYPE 222 { 223 MHL_CABLE_DETECT_SELECT_PORTA = 0x01, 224 MHL_CABLE_DETECT_SELECT_PORTB = 0x02, 225 MHL_CABLE_DETECT_SELECT_PORTC = 0x04, 226 MHL_CABLE_DETECT_SELECT_PORTD = 0x08, 227 }; 228 229 enum MHL_DVI_MUX_SELECT_TYPE 230 { 231 MHL_DVI_MUX_SELECT0 = 0, 232 MHL_DVI_MUX_SELECT1, 233 }; 234 235 enum MHL_AUTO_EQ_STATE_TYPE 236 { 237 MHL_AUTO_EQ_START = 0, 238 MHL_AUTO_EQ_ENABLE, 239 MHL_AUTO_EQ_WAIT_DONE, 240 MHL_AUTO_EQ_STABLE_DONE, 241 }; 242 243 #define MHL_CBUS_SELECT_PORT_INITIAL MHL_CBUS_SELECT_PORTC 244 245 //------------------------------------------------------------------------------------------------- 246 // Type and Structure 247 //------------------------------------------------------------------------------------------------- 248 249 //------------------------------------------------------------------------------------------------- 250 // Function Prototype 251 //------------------------------------------------------------------------------------------------- 252 void mhal_mhl_SetRegisterBaseAddress(MS_VIRT ulRiuBassAddress, MS_VIRT ulPMRiuBassAddress); 253 MS_U8 mhal_mhl_GetCbusSelect(MS_U8 ucPort); 254 MS_U8 mhal_mhl_GetInputPort(void); 255 MS_BOOL mhal_mhl_CheckInputPort(MS_U8 ucCbusSelect); 256 MS_BOOL mhal_mhl_CheckPIPWindow(void); 257 void mhal_mhl_MHLSupportPath(MS_U8 ucSelect); 258 MS_BOOL mhal_mhl_CheckEfuseControlFlag(MS_BOOL bEfuseFlag); 259 void mhal_mhl_InsertChipIDforCheck(MS_U8 ucChipID); 260 MS_BOOL mhal_mhl_CableDetect(MS_U8 ucCbusSelect); 261 void mhal_mhl_Accumulator_Clr(MS_U8 ucCbusSelect); 262 MS_BOOL mhal_mhl_CDRModeMonitor(MS_U8 ucCbusSelect, MS_BOOL bPathEnable, stMHL_SIGNAL_STATUS_INFO *pMHLSignalStatus); 263 void mhal_mhl_CbusIsolate(MS_U8 ucCbusSelect, MS_BOOL bFlag); 264 void mhal_mhl_VbusCharge(MS_U8 ucCbusSelect, MS_U8 bState); 265 void mhal_mhl_CbusFloating(MS_BOOL bFlag); 266 void mhal_mhl_CbusStucktoLow(MS_BOOL bFlag); 267 void mhal_mhl_CbusWakeupInterrupt(MS_BOOL bFlag); 268 void mhal_mhl_SetVenderID(MS_U8 ucVenderID); 269 void mhal_mhl_LoadEDID(MS_U8 *edid); 270 void mhal_mhl_ReadEDID(MS_U16 usSize, MS_U8 *edid); 271 void mhal_mhl_LoadDeviceCapability(MS_U8 *devcap); 272 MS_U8 mhal_mhl_initial(MS_U8 ucCbusSelect, MS_U8 *edid, MS_U8 *devcap, MS_U8 ucVenderID); 273 void mhal_mhl_InvertCableDetect(MS_U8 ucCbusSelect, MS_BOOL bCableDetectInvert); 274 void mhal_mhl_VbusConfigSetting(MS_U8 ucCbusSelect, MS_U8 ucState); 275 void mhal_mhl_CableDetectPadSetting(MS_U8 ucSelect); 276 void mhal_mhl_CbusPadConfigSwitch(MS_U8 ucCbusSelect, MS_BOOL bFlag); 277 MS_U16 mhal_mhl_CbusStatus(void); 278 279 MS_BOOL mhal_mhl_CbusIsMscMsgReceived(void); 280 MS_BOOL mhal_mhl_CbusStucktoLowFlag(void); 281 MS_BOOL mhal_mhl_CbusWakeupIntFlag(void); 282 MS_BOOL mhal_mhl_GetECbusStateChangeFlag(stMHL_SIGNAL_STATUS_INFO *pMHLSignalStatus, stMHL_BIST_MODE_INFO *pBISTParameterInfo); 283 MS_BOOL mhal_mhl_GetEMSCReceiveFlag(void); 284 MS_U8 mhal_mhl_GetEMSCSendStatus(void); 285 MS_BOOL mhal_mhl_CBusWrite(MS_BOOL bECbusEnableFlag, mhalCbusFifo_S *pdatabuf); 286 void mhal_mhl_Cbus_SetPathEn(MS_BOOL bflag); 287 MS_BOOL mhal_mhl_CbusIntCB(MS_U8 *rcstate, MS_U8 *rccmd, MS_U8 *rcdata, MS_U8 *rclen, MS_U8 *bIsCmdInData); 288 MS_BOOL mhal_mhl_CBusCheckBCHError(void); 289 290 void mhal_mhl_CablePlugProc(MS_U8 ucCbusSelect, stMHL_SIGNAL_STATUS_INFO *pMHLSignalStatus); 291 void mhal_mhl_CableRemoveProc(MS_U8 ucCbusSelect, stMHL_SIGNAL_STATUS_INFO *pMHLSignalStatus); 292 void mhal_mhl_CbusConnectProc(MS_U8 ucCbusSelect); 293 void mhal_mhl_CbusStucktoLowProc(MS_U8 ucCbusSelect); 294 void mhal_mhl_SourceChangeProc(MS_U8 ucCbusSelect, MS_U8 ucLinkRate); 295 void mhal_mhl_ClockModeSwitchProc(MS_U8 ucCbusSelect, MS_BOOL bPPmode, stMHL_SIGNAL_STATUS_INFO *pMHLSignalStatus); 296 void mhal_mhl_CbusWakeupIntSetting(MS_U8 ucCbusSelect, MS_BOOL bFlag); 297 void mhal_mhl_RtermControlHWMode(MS_U8 ucCbusSelect, MS_BOOL bFlag); 298 299 void mhal_mhl_LoadPowerOnTbl(void); 300 void mhal_mhl_LoadPowerStandbyTbl(void); 301 void mhal_mhl_LoadPowerDownTbl(void); 302 void mhal_mhl_SetHPD(MS_BOOL bflag); 303 MS_U8 mhal_mhl_GetDDCErrorCode(void); 304 305 #if(MHL_CBUS_OPERATION_MODE == MHL_CBUS_HW_REPLY_MODE) 306 MS_BOOL mhal_mhl_CheckSRAMReceiveBuffer(void); 307 MS_U16 mhal_mhl_GetSRAMReceiveData(void); 308 #endif 309 310 #if(DMHL_TEST_SIGNAL_SUPPORT) 311 void mhal_mhl_TestSignal(MS_BOOL bflag); 312 #endif 313 314 void mhal_mhl_SetMainLinkRate(MS_U8 ucCbusSelect, MS_U8 ucLinkRate); 315 MS_U8 mhal_mhl_GetECbusStatusFlag(void); 316 void mhal_mhl_ECbusEventProc(MS_U8 ucCbusSelect, MS_U8 ucECbusEvent, MS_BOOL bBISTEnableFlag, stMHL_BIST_MODE_INFO *pBISTParameterInfo); 317 void mhal_mhl_SetBISTParameterInfo(MS_U8 ucCbusSelect, stMHL_BIST_MODE_INFO *pBISTParameterInfo); 318 void mhal_mhl_GetBISTErrorCount(MS_U8 ucCbusSelect, stMHL_BIST_MODE_INFO *pBISTParameterInfo); 319 void mhal_mhl_GetEMSCReceiveData(MS_U8 *bReveiceEMSC); 320 void mhal_mhl_InsertEMSCSendData(MS_U8 ucLength, MS_U8 *bSendEMSC); 321 void mhal_mhl_AutoEQEventProc(MS_U8 ucCbusSelect, stMHL_SIGNAL_STATUS_INFO *pMHLSignalStatus); 322 323 #endif //_MHAL_MHL_H_ 324 325