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_IMPEDANCE_VALUE 0U 99 #define MHL_DIGITAL_UNLOCK_RANGE 0x3E8U 100 #define MHL_LOCK_RESOLUTION 0x1U 101 #define MHL_UNLOCK_RESOLUTION 0x1EU 102 #define MHL_ICONTROL_PD_VALUE 7 103 104 #define MHL_EQ_20_SETTING_VALUE 4U 105 #define MHL_EQ_30_SETTING_VALUE 10U 106 #define MHL_HDMI_EQ_SETTING_VALUE 12U 107 108 #define MHL_LOCK_TIME_VALUE 0x7FU 109 #define MHL_HDMI_LOCK_TIME_VALUE 0x1FU 110 111 #define MHL_CHIP_ID_MESSI 0U 112 113 #define MHL_CDR_STABLE_COUNTER 200U 114 #define MHL_CDR_FORCE_COUNTER 20U 115 #define MHL_CDR_STABLE_OFFSET 1U 116 #define MHL_CDR_STABLE_THRESHOLD (MHL_CDR_STABLE_COUNTER +MHL_CDR_STABLE_OFFSET) 117 #define MHL_CDR_FORCE_THRESHOLD (MHL_CDR_STABLE_THRESHOLD +MHL_CDR_FORCE_COUNTER) 118 119 #define CBUS_CDR_CLOCK_TARGET 20U 120 #define CBUS_CLOCK_DETECT_LEVEL (CBUS_CDR_CLOCK_TARGET *128 /12) 121 122 #define CBUS_CDR_OFFSET_TARGET 0.5 123 #define CBUS_CLOCK_DETECT_OFFSET (CBUS_CDR_OFFSET_TARGET *128 /12) 124 125 #define MHL_CBUS_SW_POLLING_MODE 0U // Use SW polling to reply MSC command 126 #define MHL_CBUS_SW_ISR_MODE 1U // Use SW interrupt to reply MSC command 127 #define MHL_CBUS_HW_ISR_MODE 2U // Use SW interrupt to clear MSC receiver flag to trigger HW auto reply 128 #define MHL_CBUS_HW_REPLY_MODE 3U // Use xdata to saving MSC command to trigger HW auto reply 129 130 #define MHL_CBUS_OPERATION_MODE MHL_CBUS_HW_REPLY_MODE 131 132 #define MHL_VBUS_OUTPUT_MODE 1U 133 #define MHL_VBUS_INVERSE_MODE 2U 134 #define MHL_VBUS_LOW_ENABLE_MODE 4U 135 #define MHL_VBUS_HIGH_ENABLE_MODE 8U 136 137 #define MHL_CBUS_CONNECT_CHECK_VALUE 0xC8U 138 139 #define MHL_ECBUS_AUTO_TRAINING 0 140 141 #define MHL_SCALER_MUX_SELECT_DVI 0x1U 142 143 #define MHL_ECBUS_COMMAND_PARSING 0 144 #define MHL_BUFFER_ECBUS_DATA_LENGTH 800 145 146 #define MHL_EFUSE_FUNCTION_CONTROL 0 147 148 #define MHL_TMDS_MULTIPLE_ENGINE 0 149 #define MHL_INTERRUPT_USE_PM_IRQ 0 150 #define MHL_ECBUS_ENGINE_SUPPORT 1 151 152 #define MHL_CHIP_CAPABILITY0 MHL_TMDS_MULTIPLE_ENGINE 153 #define MHL_CHIP_CAPABILITY1 MHL_INTERRUPT_USE_PM_IRQ 154 #define MHL_CHIP_CAPABILITY2 MHL_ECBUS_ENGINE_SUPPORT 155 #define MHL_CHIP_CAPABILITY3 0 156 #define MHL_CHIP_CAPABILITY4 0 157 #define MHL_CHIP_CAPABILITY5 0 158 #define MHL_CHIP_CAPABILITY6 0 159 #define MHL_CHIP_CAPABILITY7 0 160 161 #define MHL_CHIP_FUNCTION_CAPABILITY_L (MHL_CHIP_CAPABILITY0 |(MHL_CHIP_CAPABILITY1 << 1) |(MHL_CHIP_CAPABILITY2 << 2) |(MHL_CHIP_CAPABILITY3 << 3)) 162 #define MHL_CHIP_FUNCTION_CAPABILITY_H (MHL_CHIP_CAPABILITY4 |(MHL_CHIP_CAPABILITY5 << 1) |(MHL_CHIP_CAPABILITY6 << 2) |(MHL_CHIP_CAPABILITY7 << 3)) 163 164 #define MHL_CHIP_FUNCTION_CAPABILITY (MHL_CHIP_FUNCTION_CAPABILITY_L |(MHL_CHIP_FUNCTION_CAPABILITY_H << 4)) 165 166 enum MHL_DVI_PORT_TYPE 167 { 168 MHL_DVI_PORT_A = BIT(0), 169 MHL_DVI_PORT_B = BIT(1), 170 MHL_DVI_PORT_C = BIT(2), 171 }; 172 173 enum MHL_CBUS_SELECT_TYPE 174 { 175 MHL_CBUS_SELECT_PORTA = 0, 176 MHL_CBUS_SELECT_PORTB, 177 MHL_CBUS_SELECT_PORTC, 178 MHL_CBUS_SELECT_MASK, 179 }; 180 181 enum MHL_PATH_SUPPORT_TYPE 182 { 183 MHL_PATH_SUPPORT_PORTA_FLAG = 0x01, 184 MHL_PATH_SUPPORT_PORTB_FLAG = 0x02, 185 MHL_PATH_SUPPORT_PORTC_FLAG = 0x04, 186 MHL_PATH_SUPPORT_PORTD_FLAG = 0x08, 187 }; 188 189 enum MHL_CABLE_DETECT_SELECT_TYPE 190 { 191 MHL_CABLE_DETECT_SELECT_PORTA = 0x01, 192 MHL_CABLE_DETECT_SELECT_PORTB = 0x02, 193 MHL_CABLE_DETECT_SELECT_PORTC = 0x04, 194 MHL_CABLE_DETECT_SELECT_PORTD = 0x08, 195 }; 196 197 #define MHL_CBUS_SELECT_PORT_INITIAL MHL_CBUS_SELECT_PORTB 198 199 //------------------------------------------------------------------------------------------------- 200 // Type and Structure 201 //------------------------------------------------------------------------------------------------- 202 extern MS_U8 ucMHLSupportPort; 203 204 #define GET_MHL_PATH_SUPPORT_PORTA() (MS_BOOL)((ucMHLSupportPort & MHL_PATH_SUPPORT_PORTA_FLAG) ?TRUE :FALSE) 205 #define SET_MHL_PATH_SUPPORT_PORTA() (ucMHLSupportPort |= MHL_PATH_SUPPORT_PORTA_FLAG) 206 #define CLR_MHL_PATH_SUPPORT_PORTA() (ucMHLSupportPort &= ~MHL_PATH_SUPPORT_PORTA_FLAG) 207 208 #define GET_MHL_PATH_SUPPORT_PORTB() (MS_BOOL)((ucMHLSupportPort & MHL_PATH_SUPPORT_PORTB_FLAG) ?TRUE :FALSE) 209 #define SET_MHL_PATH_SUPPORT_PORTB() (ucMHLSupportPort |= MHL_PATH_SUPPORT_PORTB_FLAG) 210 #define CLR_MHL_PATH_SUPPORT_PORTB() (ucMHLSupportPort &= ~MHL_PATH_SUPPORT_PORTB_FLAG) 211 212 #define GET_MHL_PATH_SUPPORT_PORTC() (MS_BOOL)((ucMHLSupportPort & MHL_PATH_SUPPORT_PORTC_FLAG) ?TRUE :FALSE) 213 #define SET_MHL_PATH_SUPPORT_PORTC() (ucMHLSupportPort |= MHL_PATH_SUPPORT_PORTC_FLAG) 214 #define CLR_MHL_PATH_SUPPORT_PORTC() (ucMHLSupportPort &= ~MHL_PATH_SUPPORT_PORTC_FLAG) 215 216 #define GET_MHL_PATH_SUPPORT_PORTD() (MS_BOOL)((ucMHLSupportPort & MHL_PATH_SUPPORT_PORTD_FLAG) ?TRUE :FALSE) 217 #define SET_MHL_PATH_SUPPORT_PORTD() (ucMHLSupportPort |= MHL_PATH_SUPPORT_PORTD_FLAG) 218 #define CLR_MHL_PATH_SUPPORT_PORTD() (ucMHLSupportPort &= ~MHL_PATH_SUPPORT_PORTD_FLAG) 219 220 //------------------------------------------------------------------------------------------------- 221 // Function Prototype 222 //------------------------------------------------------------------------------------------------- 223 MS_U8 mhal_mhl_GetCbusSelect(MS_U8 ucPort); 224 MS_U8 mhal_mhl_GetInputPort(void); 225 MS_BOOL mhal_mhl_CheckInputPort(MS_U8 ucCbusSelect); 226 MS_BOOL mhal_mhl_CheckPIPWindow(void); 227 void mhal_mhl_MHLSupportPath(MS_U8 ucSelect); 228 MS_BOOL mhal_mhl_CheckEfuseControlFlag(MS_BOOL bEfuseFlag); 229 void mhal_mhl_InsertChipIDforCheck(MS_U8 ucChipID); 230 void mhal_mhl_CbusSelectSetMux(MS_U8 ucCbusSelect); 231 MS_BOOL mhal_mhl_CableDetect(MS_U8 ucCbusSelect); 232 void mhal_mhl_Accumulator_Clr(MS_U8 ucCbusSelect); 233 MS_BOOL mhal_mhl_CDRModeMonitor(MS_U8 ucCbusSelect, MS_BOOL bPathEnable); 234 void mhal_mhl_CbusIsolate(MS_U8 ucCbusSelect, MS_BOOL bFlag); 235 void mhal_mhl_VbusCharge(MS_U8 ucCbusSelect, MS_U8 bState); 236 void mhal_mhl_CbusFloating(MS_BOOL bFlag); 237 void mhal_mhl_CbusStucktoLow(MS_BOOL bFlag); 238 void mhal_mhl_CbusWakeupInterrupt(MS_BOOL bFlag); 239 void mhal_mhl_SetVenderID(MS_U8 ucVenderID); 240 void mhal_mhl_LoadEDID(MS_U8 *edid); 241 void mhal_mhl_ReadEDID(MS_U16 usSize, MS_U8 *edid); 242 void mhal_mhl_LoadDeviceCapability(MS_U8 *devcap); 243 MS_U8 mhal_mhl_initial(MS_U8 *edid, MS_U8 *devcap, MS_U8 ucVenderID); 244 void mhal_mhl_InvertCableDetect(MS_U8 ucCbusSelect, MS_BOOL bCableDetectInvert); 245 void mhal_mhl_VbusConfigSetting(MS_U8 ucCbusSelect, MS_U8 ucState); 246 void mhal_mhl_CableDetectPadSetting(MS_U8 ucSelect); 247 void mhal_mhl_CbusPadConfigSwitch(MS_U8 ucCbusSelect, MS_BOOL bFlag); 248 MS_U16 mhal_mhl_CbusStatus(void); 249 250 MS_BOOL mhal_mhl_CbusIsMscMsgReceived(void); 251 MS_BOOL mhal_mhl_CbusStucktoLowFlag(void); 252 MS_BOOL mhal_mhl_CbusWakeupIntFlag(void); 253 MS_BOOL mhal_mhl_GetECbusStateChangeFlag(void); 254 MS_BOOL mhal_mhl_GetEMSCReceiveFlag(void); 255 MS_U8 mhal_mhl_GetEMSCSendStatus(void); 256 MS_BOOL mhal_mhl_CBusWrite(mhalCbusFifo_S *pdatabuf); 257 void mhal_mhl_Cbus_SetPathEn(MS_BOOL bflag); 258 MS_BOOL mhal_mhl_CbusIntCB(MS_U8 *rcstate, MS_U8 *rccmd, MS_U8 *rcdata, MS_U8 *rclen, MS_U8 *bIsCmdInData); 259 MS_BOOL mhal_mhl_CBusCheckBCHError(void); 260 261 void mhal_mhl_CablePlugProc(MS_U8 ucCbusSelect); 262 void mhal_mhl_CableRemoveProc(MS_U8 ucCbusSelect); 263 void mhal_mhl_CbusConnectProc(MS_U8 ucCbusSelect); 264 void mhal_mhl_CbusStucktoLowProc(MS_U8 ucCbusSelect); 265 void mhal_mhl_SourceChangeProc(MS_U8 ucCbusSelect); 266 void mhal_mhl_ClockModeSwitchProc(MS_U8 ucCbusSelect, MS_BOOL bPPmode); 267 void mhal_mhl_CbusWakeupIntSetting(MS_U8 ucCbusSelect, MS_BOOL bFlag); 268 void mhal_mhl_RtermControlHWMode(MS_U8 ucCbusSelect, MS_BOOL bFlag); 269 void mhal_mhl_AdjustSettingIControl(MS_U8 ucIControl); 270 void mhal_mhl_AdjustImpedanceSetting(MS_U8 ucImpedance); 271 MS_BOOL mhal_mhl_GetSignalStableFlag(void); 272 273 void mhal_mhl_LoadPowerOnTbl(void); 274 void mhal_mhl_LoadPowerStandbyTbl(void); 275 void mhal_mhl_LoadPowerDownTbl(void); 276 void mhal_mhl_SetHPD(MS_BOOL bflag); 277 MS_U8 mhal_mhl_GetDDCErrorCode(void); 278 279 #if(MHL_CBUS_OPERATION_MODE == MHL_CBUS_HW_REPLY_MODE) 280 MS_BOOL mhal_mhl_CheckSRAMReceiveBuffer(void); 281 MS_U16 mhal_mhl_GetSRAMReceiveData(void); 282 #endif 283 284 #if(DMHL_TEST_SIGNAL_SUPPORT) 285 void mhal_mhl_TestSignal(MS_BOOL bflag); 286 #endif 287 288 void mhal_mhl_SetMainLinkRate(MS_U8 ucCbusSelect, MS_U8 ucLinkRate); 289 MS_U8 mhal_mhl_GetECbusStatusFlag(void); 290 void mhal_mhl_ECbusEventProc(MS_U8 ucCbusSelect, MS_U8 ucECbusEvent); 291 void mhal_mhl_GetEMSCReceiveData(MS_U8 *bReveiceEMSC); 292 void mhal_mhl_InsertEMSCSendData(MS_U8 ucLength, MS_U8 *bSendEMSC); 293 294 #endif //_MHAL_MHL_H_ 295 296