xref: /utopia/UTPA2-700.0.x/modules/hdmi/hal/mooney/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      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_VALUE           5U
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         12U
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_MONET               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_MASK,
200 };
201 
202 enum MHL_PATH_SUPPORT_TYPE
203 {
204     MHL_PATH_SUPPORT_PORTA_FLAG = 0x01,
205     MHL_PATH_SUPPORT_PORTB_FLAG = 0x02,
206     MHL_PATH_SUPPORT_PORTC_FLAG = 0x04,
207     MHL_PATH_SUPPORT_PORTD_FLAG = 0x08,
208 };
209 
210 enum MHL_CABLE_DETECT_SELECT_TYPE
211 {
212     MHL_CABLE_DETECT_SELECT_PORTA = 0x01,
213     MHL_CABLE_DETECT_SELECT_PORTB = 0x02,
214     MHL_CABLE_DETECT_SELECT_PORTC = 0x04,
215     MHL_CABLE_DETECT_SELECT_PORTD = 0x08,
216 };
217 
218 enum MHL_DVI_MUX_SELECT_TYPE
219 {
220     MHL_DVI_MUX_SELECT0 = 0,
221     MHL_DVI_MUX_SELECT1,
222 };
223 
224 #define MHL_CBUS_SELECT_PORT_INITIAL    MHL_CBUS_SELECT_PORTC
225 
226 //-------------------------------------------------------------------------------------------------
227 //  Type and Structure
228 //-------------------------------------------------------------------------------------------------
229 extern MS_U8 ucMHLSupportPort;
230 
231 #define GET_MHL_PATH_SUPPORT_PORTA()    (MS_BOOL)((ucMHLSupportPort & MHL_PATH_SUPPORT_PORTA_FLAG) ?TRUE :FALSE)
232 #define SET_MHL_PATH_SUPPORT_PORTA()    (ucMHLSupportPort |= MHL_PATH_SUPPORT_PORTA_FLAG)
233 #define CLR_MHL_PATH_SUPPORT_PORTA()    (ucMHLSupportPort &= ~MHL_PATH_SUPPORT_PORTA_FLAG)
234 
235 #define GET_MHL_PATH_SUPPORT_PORTB()    (MS_BOOL)((ucMHLSupportPort & MHL_PATH_SUPPORT_PORTB_FLAG) ?TRUE :FALSE)
236 #define SET_MHL_PATH_SUPPORT_PORTB()    (ucMHLSupportPort |= MHL_PATH_SUPPORT_PORTB_FLAG)
237 #define CLR_MHL_PATH_SUPPORT_PORTB()    (ucMHLSupportPort &= ~MHL_PATH_SUPPORT_PORTB_FLAG)
238 
239 #define GET_MHL_PATH_SUPPORT_PORTC()    (MS_BOOL)((ucMHLSupportPort & MHL_PATH_SUPPORT_PORTC_FLAG) ?TRUE :FALSE)
240 #define SET_MHL_PATH_SUPPORT_PORTC()    (ucMHLSupportPort |= MHL_PATH_SUPPORT_PORTC_FLAG)
241 #define CLR_MHL_PATH_SUPPORT_PORTC()    (ucMHLSupportPort &= ~MHL_PATH_SUPPORT_PORTC_FLAG)
242 
243 #define GET_MHL_PATH_SUPPORT_PORTD()    (MS_BOOL)((ucMHLSupportPort & MHL_PATH_SUPPORT_PORTD_FLAG) ?TRUE :FALSE)
244 #define SET_MHL_PATH_SUPPORT_PORTD()    (ucMHLSupportPort |= MHL_PATH_SUPPORT_PORTD_FLAG)
245 #define CLR_MHL_PATH_SUPPORT_PORTD()    (ucMHLSupportPort &= ~MHL_PATH_SUPPORT_PORTD_FLAG)
246 
247 //-------------------------------------------------------------------------------------------------
248 //  Function Prototype
249 //-------------------------------------------------------------------------------------------------
250 MS_U8 mhal_mhl_GetCbusSelect(MS_U8 ucPort);
251 MS_U8 mhal_mhl_GetInputPort(void);
252 MS_BOOL mhal_mhl_CheckInputPort(MS_U8 ucCbusSelect);
253 MS_BOOL mhal_mhl_CheckPIPWindow(void);
254 void mhal_mhl_MHLSupportPath(MS_U8 ucSelect);
255 MS_BOOL mhal_mhl_CheckEfuseControlFlag(MS_BOOL bEfuseFlag);
256 void mhal_mhl_InsertChipIDforCheck(MS_U8 ucChipID);
257 void mhal_mhl_CbusSelectSetMux(MS_U8 ucCbusSelect);
258 MS_BOOL mhal_mhl_CableDetect(MS_U8 ucCbusSelect);
259 void mhal_mhl_Accumulator_Clr(MS_U8 ucCbusSelect);
260 MS_BOOL mhal_mhl_CDRModeMonitor(MS_U8 ucCbusSelect, MS_BOOL bPathEnable);
261 void mhal_mhl_CbusIsolate(MS_U8 ucCbusSelect, MS_BOOL bFlag);
262 void mhal_mhl_VbusCharge(MS_U8 ucCbusSelect, MS_U8 bState);
263 void mhal_mhl_CbusFloating(MS_BOOL bFlag);
264 void mhal_mhl_CbusStucktoLow(MS_BOOL bFlag);
265 void mhal_mhl_CbusWakeupInterrupt(MS_BOOL bFlag);
266 void mhal_mhl_SetVenderID(MS_U8 ucVenderID);
267 void mhal_mhl_LoadEDID(MS_U8 *edid);
268 void mhal_mhl_ReadEDID(MS_U16 usSize, MS_U8 *edid);
269 void mhal_mhl_LoadDeviceCapability(MS_U8 *devcap);
270 MS_U8 mhal_mhl_initial(MS_U8 *edid, MS_U8 *devcap, MS_U8 ucVenderID);
271 void mhal_mhl_InvertCableDetect(MS_U8 ucCbusSelect, MS_BOOL bCableDetectInvert);
272 void mhal_mhl_VbusConfigSetting(MS_U8 ucCbusSelect, MS_U8 ucState);
273 void mhal_mhl_CableDetectPadSetting(MS_U8 ucSelect);
274 void mhal_mhl_CbusPadConfigSwitch(MS_U8 ucCbusSelect, MS_BOOL bFlag);
275 MS_U16 mhal_mhl_CbusStatus(void);
276 
277 MS_BOOL mhal_mhl_CbusIsMscMsgReceived(void);
278 MS_BOOL mhal_mhl_CbusStucktoLowFlag(void);
279 MS_BOOL mhal_mhl_CbusWakeupIntFlag(void);
280 MS_BOOL mhal_mhl_GetECbusStateChangeFlag(void);
281 MS_BOOL mhal_mhl_GetEMSCReceiveFlag(void);
282 MS_U8 mhal_mhl_GetEMSCSendStatus(void);
283 MS_BOOL mhal_mhl_CBusWrite(mhalCbusFifo_S *pdatabuf);
284 void mhal_mhl_Cbus_SetPathEn(MS_BOOL bflag);
285 MS_BOOL mhal_mhl_CbusIntCB(MS_U8 *rcstate, MS_U8 *rccmd, MS_U8 *rcdata, MS_U8 *rclen, MS_U8 *bIsCmdInData);
286 MS_BOOL mhal_mhl_CBusCheckBCHError(void);
287 
288 void mhal_mhl_CablePlugProc(MS_U8 ucCbusSelect);
289 void mhal_mhl_CableRemoveProc(MS_U8 ucCbusSelect);
290 void mhal_mhl_CbusConnectProc(MS_U8 ucCbusSelect);
291 void mhal_mhl_CbusStucktoLowProc(MS_U8 ucCbusSelect);
292 void mhal_mhl_SourceChangeProc(MS_U8 ucCbusSelect);
293 void mhal_mhl_ClockModeSwitchProc(MS_U8 ucCbusSelect, MS_BOOL bPPmode);
294 void mhal_mhl_CbusWakeupIntSetting(MS_U8 ucCbusSelect, MS_BOOL bFlag);
295 void mhal_mhl_RtermControlHWMode(MS_U8 ucCbusSelect, MS_BOOL bFlag);
296 void mhal_mhl_AdjustSettingIControl(MS_U8 ucIControl);
297 void mhal_mhl_AdjustImpedanceSetting(MS_U8 ucImpedance);
298 MS_BOOL mhal_mhl_GetSignalStableFlag(void);
299 
300 void mhal_mhl_LoadPowerOnTbl(void);
301 void mhal_mhl_LoadPowerStandbyTbl(void);
302 void mhal_mhl_LoadPowerDownTbl(void);
303 void mhal_mhl_SetHPD(MS_BOOL bflag);
304 MS_U8 mhal_mhl_GetDDCErrorCode(void);
305 
306 #if(MHL_CBUS_OPERATION_MODE == MHL_CBUS_HW_REPLY_MODE)
307 MS_BOOL mhal_mhl_CheckSRAMReceiveBuffer(void);
308 MS_U16 mhal_mhl_GetSRAMReceiveData(void);
309 #endif
310 
311 #if(DMHL_TEST_SIGNAL_SUPPORT)
312 void mhal_mhl_TestSignal(MS_BOOL bflag);
313 #endif
314 
315 void mhal_mhl_SetMainLinkRate(MS_U8 ucCbusSelect, MS_U8 ucLinkRate);
316 MS_U8 mhal_mhl_GetECbusStatusFlag(void);
317 void mhal_mhl_ECbusEventProc(MS_U8 ucCbusSelect, MS_U8 ucECbusEvent);
318 void mhal_mhl_GetEMSCReceiveData(MS_U8 *bReveiceEMSC);
319 void mhal_mhl_InsertEMSCSendData(MS_U8 ucLength, MS_U8 *bSendEMSC);
320 
321 #endif //_MHAL_MHL_H_
322 
323