xref: /utopia/UTPA2-700.0.x/modules/hdmi/hal/maldives/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      1
96 #define MHL_FUNCTION_SUPPORT_PORTD      1
97 
98 #define DMHL_CDR_SW_MODE                0 // MHL CDR  SW mode
99 #define DMHL_CDR_HW_MODE                (!DMHL_CDR_SW_MODE)    // power down dvi pll till clock stable
100 
101 #define MHL_ICONTROL_VALUE              0
102 #define MHL_IMPEDANCE_VALUE             0
103 #define MHL_PHASE_CODE_VALUE            0x60
104 #define MHL_DIGITAL_UNLOCK_RANGE        0x3E8
105 #define MHL_LOCK_RESOLUTION             0x1
106 #define MHL_UNLOCK_RESOLUTION           0x1E
107 
108 #define MHL_EQ_SETTING_VALUE            13
109 #define MHL_HDMI_EQ_SETTING_VALUE       13
110 
111 #define MHL_CHIP_ID_MUNICH              0
112 
113 #define MHL_CDR_STABLE_COUNTER          10
114 #define MHL_CDR_FORCE_COUNTER           20
115 #define MHL_CDR_STABLE_OFFSET           1
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           20
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        0   // Use SW polling to reply MSC command
126 #define MHL_CBUS_SW_ISR_MODE            1   // Use SW interrupt to reply MSC command
127 #define MHL_CBUS_HW_ISR_MODE            2   // Use SW interrupt to clear MSC receiver flag to trigger HW auto reply
128 #define MHL_CBUS_HW_REPLY_MODE          3   // 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            1
133 #define MHL_VBUS_INVERSE_MODE           2
134 #define MHL_VBUS_LOW_ENABLE_MODE        4
135 #define MHL_VBUS_HIGH_ENABLE_MODE       8
136 
137 #define MHL_SCALER_MUX_SELECT_DVI       0x1
138 #define MHL_SCALER_MUX_SELECT_MHL       0xD
139 
140 #define MHL_EFUSE_FUNCTION_CONTROL      0
141 
142 #define MHL_TMDS_MULTIPLE_ENGINE        1
143 #define MHL_INTERRUPT_USE_PM_IRQ        0
144 #define MHL_ECBUS_ENGINE_SUPPORT        0
145 
146 #define MHL_CHIP_CAPABILITY0            MHL_TMDS_MULTIPLE_ENGINE
147 #define MHL_CHIP_CAPABILITY1            MHL_INTERRUPT_USE_PM_IRQ
148 #define MHL_CHIP_CAPABILITY2            MHL_ECBUS_ENGINE_SUPPORT
149 #define MHL_CHIP_CAPABILITY3            0
150 #define MHL_CHIP_CAPABILITY4            0
151 #define MHL_CHIP_CAPABILITY5            0
152 #define MHL_CHIP_CAPABILITY6            0
153 #define MHL_CHIP_CAPABILITY7            0
154 
155 #define MHL_CHIP_FUNCTION_CAPABILITY_L  (MHL_CHIP_CAPABILITY0 |(MHL_CHIP_CAPABILITY1 << 1) |(MHL_CHIP_CAPABILITY2 << 2) |(MHL_CHIP_CAPABILITY3 << 3))
156 #define MHL_CHIP_FUNCTION_CAPABILITY_H  (MHL_CHIP_CAPABILITY4 |(MHL_CHIP_CAPABILITY5 << 1) |(MHL_CHIP_CAPABILITY6 << 2) |(MHL_CHIP_CAPABILITY7 << 3))
157 
158 #define MHL_CHIP_FUNCTION_CAPABILITY    (MHL_CHIP_FUNCTION_CAPABILITY_L |(MHL_CHIP_FUNCTION_CAPABILITY_H << 4))
159 
160 enum MHL_DVI_PORT_TYPE
161 {
162     MHL_DVI_PORT_A = 0,
163     MHL_DVI_PORT_B,
164     MHL_DVI_PORT_D,
165     MHL_DVI_PORT_C,
166 };
167 
168 enum MHL_CBUS_SELECT_TYPE
169 {
170     MHL_CBUS_SELECT_PORTA = 0,
171     MHL_CBUS_SELECT_PORTB,
172     MHL_CBUS_SELECT_PORTC,
173     MHL_CBUS_SELECT_PORTD,
174     MHL_CBUS_SELECT_MASK,
175 };
176 
177 enum MHL_PATH_SUPPORT_TYPE
178 {
179     MHL_PATH_SUPPORT_PORTA_FLAG = 0x01,
180     MHL_PATH_SUPPORT_PORTB_FLAG = 0x02,
181     MHL_PATH_SUPPORT_PORTC_FLAG = 0x04,
182     MHL_PATH_SUPPORT_PORTD_FLAG = 0x08,
183 };
184 
185 enum MHL_CABLE_DETECT_SELECT_TYPE
186 {
187     MHL_CABLE_DETECT_SELECT_PORTA = 0x01,
188     MHL_CABLE_DETECT_SELECT_PORTB = 0x02,
189     MHL_CABLE_DETECT_SELECT_PORTC = 0x04,
190     MHL_CABLE_DETECT_SELECT_PORTD = 0x08,
191 };
192 
193 #define MHL_CBUS_SELECT_PORT_INITIAL    MHL_CBUS_SELECT_PORTC
194 
195 //-------------------------------------------------------------------------------------------------
196 //  Type and Structure
197 //-------------------------------------------------------------------------------------------------
198 extern MS_U8 ucMHLSupportPort;
199 
200 #define GET_MHL_PATH_SUPPORT_PORTA()    (MS_BOOL)((ucMHLSupportPort & MHL_PATH_SUPPORT_PORTA_FLAG) ?TRUE :FALSE)
201 #define SET_MHL_PATH_SUPPORT_PORTA()    (ucMHLSupportPort |= MHL_PATH_SUPPORT_PORTA_FLAG)
202 #define CLR_MHL_PATH_SUPPORT_PORTA()    (ucMHLSupportPort &= ~MHL_PATH_SUPPORT_PORTA_FLAG)
203 
204 #define GET_MHL_PATH_SUPPORT_PORTB()    (MS_BOOL)((ucMHLSupportPort & MHL_PATH_SUPPORT_PORTB_FLAG) ?TRUE :FALSE)
205 #define SET_MHL_PATH_SUPPORT_PORTB()    (ucMHLSupportPort |= MHL_PATH_SUPPORT_PORTB_FLAG)
206 #define CLR_MHL_PATH_SUPPORT_PORTB()    (ucMHLSupportPort &= ~MHL_PATH_SUPPORT_PORTB_FLAG)
207 
208 #define GET_MHL_PATH_SUPPORT_PORTC()    (MS_BOOL)((ucMHLSupportPort & MHL_PATH_SUPPORT_PORTC_FLAG) ?TRUE :FALSE)
209 #define SET_MHL_PATH_SUPPORT_PORTC()    (ucMHLSupportPort |= MHL_PATH_SUPPORT_PORTC_FLAG)
210 #define CLR_MHL_PATH_SUPPORT_PORTC()    (ucMHLSupportPort &= ~MHL_PATH_SUPPORT_PORTC_FLAG)
211 
212 #define GET_MHL_PATH_SUPPORT_PORTD()    (MS_BOOL)((ucMHLSupportPort & MHL_PATH_SUPPORT_PORTD_FLAG) ?TRUE :FALSE)
213 #define SET_MHL_PATH_SUPPORT_PORTD()    (ucMHLSupportPort |= MHL_PATH_SUPPORT_PORTD_FLAG)
214 #define CLR_MHL_PATH_SUPPORT_PORTD()    (ucMHLSupportPort &= ~MHL_PATH_SUPPORT_PORTD_FLAG)
215 
216 //-------------------------------------------------------------------------------------------------
217 //  Function Prototype
218 //-------------------------------------------------------------------------------------------------
219 MS_U8 mhal_mhl_GetCbusSelect(MS_U8 ucPort);
220 MS_U8 mhal_mhl_GetInputPort(void);
221 MS_BOOL mhal_mhl_CheckInputPort(MS_U8 ucCbusSelect);
222 MS_BOOL mhal_mhl_CheckPIPWindow(void);
223 void mhal_mhl_MHLSupportPath(MS_U8 ucSelect);
224 MS_BOOL mhal_mhl_CheckEfuseControlFlag(MS_BOOL bEfuseFlag);
225 void mhal_mhl_InsertChipIDforCheck(MS_U8 ucChipID);
226 void mhal_mhl_CbusSelectSetMux(MS_U8 ucCbusSelect);
227 MS_BOOL mhal_mhl_CableDetect(MS_U8 ucCbusSelect);
228 void mhal_mhl_Accumulator_Clr(MS_U8 ucCbusSelect);
229 MS_BOOL mhal_mhl_CDRModeMonitor(MS_U8 ucCbusSelect, MS_BOOL bPathEnable);
230 void mhal_mhl_CbusIsolate(MS_U8 ucCbusSelect, MS_BOOL bFlag);
231 void mhal_mhl_VbusCharge(MS_U8 ucCbusSelect, MS_U8 bState);
232 void mhal_mhl_CbusFloating(MS_BOOL bFlag);
233 void mhal_mhl_CbusStucktoLow(MS_BOOL bFlag);
234 void mhal_mhl_CbusWakeupInterrupt(MS_BOOL bFlag);
235 void mhal_mhl_SetVenderID(MS_U8 ucVenderID);
236 void mhal_mhl_LoadEDID(MS_U8 *edid);
237 void mhal_mhl_ReadEDID(MS_U16 usSize, MS_U8 *edid);
238 void mhal_mhl_LoadDeviceCapability(MS_U8 *devcap);
239 MS_U8 mhal_mhl_initial(MS_U8 *edid, MS_U8 *devcap, MS_U8 ucVenderID);
240 void mhal_mhl_InvertCableDetect(MS_U8 ucCbusSelect, MS_BOOL bCableDetectInvert);
241 void mhal_mhl_VbusConfigSetting(MS_U8 ucCbusSelect, MS_U8 ucState);
242 void mhal_mhl_CableDetectPadSetting(MS_U8 ucSelect);
243 void mhal_mhl_CbusPadConfigSwitch(MS_U8 ucCbusSelect, MS_BOOL bFlag);
244 MS_U16 mhal_mhl_CbusStatus(void);
245 
246 MS_BOOL mhal_mhl_CbusIsMscMsgReceived(void);
247 MS_BOOL mhal_mhl_CbusStucktoLowFlag(void);
248 MS_BOOL mhal_mhl_CbusWakeupIntFlag(void);
249 MS_BOOL mhal_mhl_CBusWrite(mhalCbusFifo_S *pdatabuf);
250 void mhal_mhl_Cbus_SetPathEn(MS_BOOL bflag);
251 MS_BOOL mhal_mhl_CbusIntCB(MS_U8 *rcstate, MS_U8 *rccmd, MS_U8 *rcdata, MS_U8 *rclen, MS_U8 *bIsCmdInData);
252 MS_BOOL mhal_mhl_CBusCheckBCHError(void);
253 
254 void mhal_mhl_CablePlugProc(MS_U8 ucCbusSelect);
255 void mhal_mhl_CableRemoveProc(MS_U8 ucCbusSelect);
256 void mhal_mhl_CbusConnectProc(MS_U8 ucCbusSelect);
257 void mhal_mhl_CbusStucktoLowProc(MS_U8 ucCbusSelect);
258 void mhal_mhl_SourceChangeProc(MS_U8 ucCbusSelect);
259 void mhal_mhl_ClockModeSwitchProc(MS_U8 ucCbusSelect, MS_BOOL bPPmode);
260 void mhal_mhl_CbusWakeupIntSetting(MS_U8 ucCbusSelect, MS_BOOL bFlag);
261 void mhal_mhl_RtermControlHWMode(MS_U8 ucCbusSelect, MS_BOOL bFlag);
262 void mhal_mhl_AdjustSettingIControl(MS_U8 ucIControl);
263 void mhal_mhl_AdjustImpedanceSetting(MS_U8 ucImpedance);
264 MS_BOOL mhal_mhl_GetSignalStableFlag(void);
265 
266 void mhal_mhl_LoadPowerOnTbl(void);
267 void mhal_mhl_LoadPowerStandbyTbl(void);
268 void mhal_mhl_LoadPowerDownTbl(void);
269 void mhal_mhl_SetHPD(MS_BOOL bflag);
270 MS_U8 mhal_mhl_GetDDCErrorCode(void);
271 
272 #if(MHL_CBUS_OPERATION_MODE == MHL_CBUS_HW_REPLY_MODE)
273 MS_BOOL mhal_mhl_CheckSRAMReceiveBuffer(void);
274 MS_U16 mhal_mhl_GetSRAMReceiveData(void);
275 #endif
276 
277 #if(DMHL_TEST_SIGNAL_SUPPORT)
278 void mhal_mhl_TestSignal(MS_BOOL bflag);
279 #endif
280 
281 #endif //_MHAL_MHL_H_
282 
283