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