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 Mapi_mhl.h 81 /// @author MStar Semiconductor Inc. 82 /// @brief MHL driver Function 83 /////////////////////////////////////////////////////////////////////////////////////////////////// 84 85 /* 86 */ 87 88 /*! \defgroup MISC MISC modules 89 * \defgroup MHL MHL interface (apiMHL.h) 90 * \ingroup MISC 91 <b>Operation Flow</b> 92 -# Check whether MHL cable is plugged or not in Rx side 93 -# Disable R-term and output Vbus 94 -# Check whether Cbus is connected(discovery pulse completed) 95 -# Sink -> Source: "SET_HPD" 96 -# Sink -> Source: Write_Stat - "DCAP_RDY" and Write_INT - "DCAP_CHG" 97 -# Sink -> Source: Write_Stat - "PATH_EN" 98 99 100 * \defgroup MHL_BASIC MHL Module basic 101 * \ingroup MHL 102 * \defgroup MHL_CAPABILITY MHL capability setting 103 * \ingroup MHL 104 * \defgroup MHL_CONFIG MHL pad config 105 * \ingroup MHL 106 * \defgroup MHL_STATUS MHL status flag 107 * \ingroup MHL 108 * \defgroup MHL_SEND MHL Tx send function 109 * \ingroup MHL 110 * \defgroup MHL_RECEIVE MHL Rx recevice data 111 * \ingroup MHL 112 * \defgroup MHL_CALLBACK MHL call back function 113 * \ingroup MHL 114 * \defgroup MHL_REMOVE MHL want to remove function 115 * \ingroup MHL 116 */ 117 118 #ifndef _API_MHL_H_ 119 #define _API_MHL_H_ 120 121 #include "MsTypes.h" 122 #include "MsDevice.h" 123 #include "MsCommon.h" 124 125 #ifdef __cplusplus 126 extern "C" 127 { 128 #endif 129 130 ////////////////////////////////////////////////// 131 // MHL SW Version // 132 ////////////////////////////////////////////////// 133 #define P4_CHANGELIST "00522289" 134 #define FW_VER_MAJOR "04" 135 #define FW_VER_MINOR "18" 136 137 typedef MS_U8 (*link_cbus_event_handle_func)(MS_U8); 138 139 typedef enum 140 { 141 E_MHL_POWER_ON, 142 E_MHL_POWER_STANDBY, 143 E_MHL_POWER_DOWN 144 } E_MHL_POWERCTRL_Mode; 145 146 enum 147 { 148 RCP_KEYID_SELECT = 0x00, 149 RCP_KEYID_UP = 0x01, 150 RCP_KEYID_DOWN = 0x02, 151 RCP_KEYID_LEFT = 0x03, 152 RCP_KEYID_RIGHT = 0x04, 153 RCP_KEYID_RIGHT_UP = 0x05, 154 RCP_KEYID_RIGHT_DOWN = 0x06, 155 RCP_KEYID_LEFT_UP = 0x07, 156 RCP_KEYID_LEFT_DOWN = 0x08, 157 RCP_KEYID_ROOT_MENU = 0x09, 158 RCP_KEYID_SETUP_MENU = 0x0A, 159 RCP_KEYID_CONTENTS_MENU = 0x0B, 160 RCP_KEYID_FAVORITE_MENU = 0x0C, 161 RCP_KEYID_EXIT = 0x0D, 162 //0x0E - 0x1F are reserved 163 RCP_KEYID_NUM_0 = 0x20, 164 RCP_KEYID_NUM_1 = 0x21, 165 RCP_KEYID_NUM_2 = 0x22, 166 RCP_KEYID_NUM_3 = 0x23, 167 RCP_KEYID_NUM_4 = 0x24, 168 RCP_KEYID_NUM_5 = 0x25, 169 RCP_KEYID_NUM_6 = 0x26, 170 RCP_KEYID_NUM_7 = 0x27, 171 RCP_KEYID_NUM_8 = 0x28, 172 RCP_KEYID_NUM_9 = 0x29, 173 RCP_KEYID_DOT = 0x2A, 174 RCP_KEYID_ENTER = 0x2B, 175 RCP_KEYID_CLEAR = 0x2C, 176 //0x2D - 0x2F are reserved 177 RCP_KEYID_CH_UP = 0x30, 178 RCP_KEYID_CH_DOWN = 0x31, 179 RCP_KEYID_PRE_CH = 0x32, 180 RCP_KEYID_SOUND_SELECT = 0x33, 181 RCP_KEYID_INPUT_SELECT = 0x34, 182 RCP_KEYID_SHOW_INFO = 0x35, 183 RCP_KEYID_HELP = 0x36, 184 RCP_KEYID_PAGE_UP = 0x37, 185 RCP_KEYID_PAGE_DOWN = 0x38, 186 //0x39 - 0x40 are reserved 187 RCP_KEYID_VOL_UP = 0x41, 188 RCP_KEYID_VOL_DOWN = 0x42, 189 RCP_KEYID_MUTE = 0x43, 190 RCP_KEYID_PLAY = 0x44, 191 RCP_KEYID_STOP = 0x45, 192 RCP_KEYID_PAUSE = 0x46, 193 RCP_KEYID_RECORD = 0x47, 194 RCP_KEYID_REWIND = 0x48, 195 RCP_KEYID_FAST_FWD = 0x49, 196 RCP_KEYID_EJECT = 0x4A, 197 RCP_KEYID_FORWARD = 0x4B, 198 RCP_KEYID_BACKWARD = 0x4C, 199 //0x4D - 0x4F are reserved 200 RCP_KEYID_ANGLE = 0x50, 201 RCP_KEYID_SUBPICTURE = 0x51, 202 //0x52 - 0x5F are reserved 203 RCP_KEYID_PLAY_FUNC = 0x60, 204 RCP_KEYID_PAUSE_PLAY_FUNC = 0x61, 205 RCP_KEYID_RECORD_FUNC = 0x62, 206 RCP_KEYID_PAUSE_REC_FUNC = 0x63, 207 RCP_KEYID_STOP_FUNC = 0x64, 208 RCP_KEYID_MUTE_FUNC = 0x65, 209 RCP_KEYID_UN_MUTE_FUNC = 0x66, 210 RCP_KEYID_TUNE_FUNC = 0x67, 211 RCP_KEYID_MEDIA_FUNC = 0x68, 212 //0x69 - 0x70 are reserved 213 RCP_KEYID_F1 = 0x71, 214 RCP_KEYID_F2 = 0x72, 215 RCP_KEYID_F3 = 0x73, 216 RCP_KEYID_F4 = 0x74, 217 RCP_KEYID_F5 = 0x75, 218 //0x76 - 0x7D are reserved 219 RCP_KEYID_VENDOR_SPECIFIC = 0x7E, 220 RCP_KEYID_RESERVED = 0x7F, 221 RCP_KEYID_SELECT_RELEASE = 0x80, 222 }; // MscRcpKcode_T; 223 224 typedef enum 225 { 226 MSC_RAP_POLL = 0x00, 227 MSC_RAP_CONTENT_ON = 0x10, 228 MSC_RAP_CONTENT_OFF = 0x11, 229 } MscRapActionCode_T; 230 231 enum 232 { 233 MSC_RCP_NO_ERROR = 0x00, // RCP No Error 234 MSC_RCP_INEFFECTIVE_KEY_CODE = 0x01, // The key code in the RCP sub-command is not recognized 235 MSC_RCP_RESPONDER_BUSY = 0x02, // RCP Response busy 236 }; //MscRcpStatusCode_T; 237 238 enum 239 { 240 MSC_RAP_NO_ERROR = 0x00, // RAP No Error 241 MSC_RAP_UNRECOGNIZED_ACTION_CODE = 0x01, 242 MSC_RAP_UNSUPPORTED_ACTION_CODE = 0x02, 243 MSC_RAP_RESPONDER_BUSY = 0x03, 244 }; //MscRapStatusCode_T; 245 246 enum MHL_CBUS_CONTROL_TYPE 247 { 248 MHL_FORCE_HDMI_BY_PASS = 0, 249 MHL_FORCE_24BIT_MODE, 250 MHL_FORCE_PACKET_PIXEL_MODE, 251 MHL_CBUS_ISOLATION_ON, 252 MHL_CBUS_ISOLATION_OFF, 253 MHL_CBUS_FLOATING_ON, 254 MHL_CBUS_FLOATING_OFF, 255 MHL_CBUS_RTERM_OFF, 256 MHL_CBUS_FORCE_CLEAR_HPD, 257 MHL_CBUS_FORCE_RESET_HPD, 258 MHL_VBUS_HW_DETCET, 259 MHL_VBUS_CHARGE_ON, 260 MHL_VBUS_CHARGE_OFF, 261 MHL_CBUS_FORCE_READY_DEVCAP, 262 MHL_CBUS_FORCE_RECEIVE_3D_REQ, 263 MHL_CBUS_FORCE_SEND_COMMAND_ENABLE, 264 MHL_CBUS_FORCE_SEND_COMMAND_DISABLE, 265 MHL_CBUS_CHECK_CONTEND_ON_ENABLE, 266 MHL_CBUS_CHECK_CONTEND_ON_DISABLE, 267 }; 268 269 enum MHL_CBUS_STATUS_FLAG_TYPE 270 { 271 MHL_CBUS_STATUS_FLAG_CABLE_DETECT = 0, 272 MHL_CBUS_STATUS_FLAG_CBUS_CONNECT, 273 MHL_CBUS_STATUS_FLAG_PATH_EN, 274 MHL_CBUS_STATUS_FLAG_RECEIVE_PATH_EN, 275 MHL_CBUS_STATUS_FLAG_RECEIVE_MUTED, 276 }; 277 278 enum MHL_CABLE_DETECT_USE_TYPE 279 { 280 MHL_CABLE_DETECT_USE_PORTA = 0x01, 281 MHL_CABLE_DETECT_USE_PORTB = 0x02, 282 MHL_CABLE_DETECT_USE_PORTC = 0x04, 283 MHL_CABLE_DETECT_USE_PORTD = 0x08, 284 }; 285 286 //------------------------------------------------------------------------------------------------- 287 // Function Prototype 288 //------------------------------------------------------------------------------------------------- 289 //------------------------------------------------------------------------------------------------- 290 /// Assign which HDMI port support MHL 291 /// @ingroup MHL_BASIC 292 /// @param ucSelect \b IN: MHL support port 293 /// @return None 294 //------------------------------------------------------------------------------------------------- 295 void mapi_mhl_MHLSupportPath(MS_U8 ucSelect); 296 297 //------------------------------------------------------------------------------------------------- 298 /// Initialize MHL 299 /// @ingroup MHL_BASIC 300 /// @param edid \b IN: point to MHL EDID 301 /// @param DevCap \b IN: point to MHL capability 302 /// @return None 303 //------------------------------------------------------------------------------------------------- 304 void mapi_mhl_init(MS_U8 *edid, MS_U8 *DevCap); 305 void mapi_mhl_LoadEDID(MS_U8 *edid); 306 307 //------------------------------------------------------------------------------------------------- 308 /// MHL read EDID 309 /// @ingroup MHL_CAPABILITY 310 /// @param usSize \b IN: Size of EDID want to read back 311 /// @param edid \b IN: point to MHL EDID 312 /// @return None 313 //------------------------------------------------------------------------------------------------- 314 void mapi_mhl_ReadEDID(MS_U16 usSize, MS_U8 *edid); 315 316 //------------------------------------------------------------------------------------------------- 317 /// MHL load device capability 318 /// @ingroup MHL_CAPABILITY 319 /// @param DevCap \b IN: point to MHL capability 320 /// @return None 321 //------------------------------------------------------------------------------------------------- 322 void mapi_mhl_LoadDeviceCapability(MS_U8 *devcap); 323 324 //------------------------------------------------------------------------------------------------- 325 /// MHL load vender ID 326 /// @ingroup MHL_CAPABILITY 327 /// @param ucVenderID \b IN: point to MHL capability 328 /// @return None 329 //------------------------------------------------------------------------------------------------- 330 // void mapi_mhl_SetVenderID(MS_U8 ucVenderID); 331 332 //------------------------------------------------------------------------------------------------- 333 /// MHL set cable detect invert 334 /// @ingroup MHL_CONFIG 335 /// @param bCableDetectInvert \b IN: cable detect invert flag 336 /// @return None 337 //------------------------------------------------------------------------------------------------- 338 // void mapi_mhl_InvertCableDetect(MS_BOOL bCableDetectInvert); 339 340 //------------------------------------------------------------------------------------------------- 341 /// MHL set Vbus config mode 342 /// @ingroup MHL_CONFIG 343 /// @param ucState \b IN: Vbus config mode 344 /// @return None 345 //------------------------------------------------------------------------------------------------- 346 void mapi_mhl_VbusConfigSetting(MS_U8 ucState); 347 // void mapi_mhl_CableDetectPadSetting(MS_U8 ucSelect); 348 void mapi_mhl_handler(void); 349 void mapi_mhl_PowerCtrl(E_MHL_POWERCTRL_Mode pctrl); 350 // MHL flag check function 351 MS_BOOL mapi_mhl_CableDetect(void); 352 353 //------------------------------------------------------------------------------------------------- 354 /// MHL get Cbus connection flag 355 /// @ingroup MHL_STATUS 356 /// @return TRUE : MHL Cbus connection 357 /// @return FALSE : MHL Cbus disconnection 358 //------------------------------------------------------------------------------------------------- 359 MS_BOOL mapi_mhl_CbusStatus(void); 360 361 //------------------------------------------------------------------------------------------------- 362 /// MHL get wake up pulse interrupt flag 363 /// @ingroup MHL_STATUS 364 /// @return TRUE : MHL receive wake up pulse 365 /// @return FALSE : MHL not receive wake up pulse 366 //------------------------------------------------------------------------------------------------- 367 MS_BOOL mapi_mhl_CbusWakeupIntFlag(void); 368 // MS_BOOL mapi_mhl_ReadDevcapFlag(void); 369 // MS_BOOL mapi_mhl_SrcRCPSupportFlag(void); 370 371 //------------------------------------------------------------------------------------------------- 372 /// MHL source support RAP flag 373 /// @ingroup MHL_STATUS 374 /// @return TRUE : MHL source support RAP 375 /// @return FALSE : MHL source nots support RAP or unknow 376 //------------------------------------------------------------------------------------------------- 377 // MS_BOOL mapi_mhl_SrcRAPSupportFlag(void); 378 // MS_BOOL mapi_mhl_SrcMSGResponseFlag(void); 379 // MHL Tx function 380 // MS_BOOL mapi_mhl_SendMSGCmdFlag(void); 381 MS_BOOL mapi_mhl_SendRAPCmd(MS_U8 databuf); 382 MS_BOOL mapi_mhl_SendRCPCmd(MS_U8 databuf); 383 MS_BOOL mapi_mhl_SendRCP_PressRelease_Cmd(MS_U8 u8RCPKey, MS_BOOL bIsRelease); 384 MS_BOOL mapi_mhl_SendRCPAutoReleaseCmd(MS_U8 ucKeyCode); 385 386 //------------------------------------------------------------------------------------------------- 387 /// MHL send UCP command 388 /// @ingroup MHL_SEND 389 /// @param databuf \b IN: key code 390 /// @return TRUE : MHL send UCP success 391 /// @return FALSE : MHL send UCP fail or not ready 392 //------------------------------------------------------------------------------------------------- 393 // MS_BOOL mapi_mhl_SendUCPCmd(MS_U8 databuf); 394 395 //------------------------------------------------------------------------------------------------- 396 /// MHL send write burst command directly 397 /// @ingroup MHL_SEND 398 /// @param ucAddr \b IN: Write burst address always 0x40 399 /// @param ucLength \b IN: Write burst data length 400 /// @param buffer \b IN: Write burst data content 401 /// @return TRUE : MHL send write burst success 402 /// @return FALSE : MHL send write burst fail or not ready 403 //------------------------------------------------------------------------------------------------- 404 MS_BOOL mapi_mhl_SendWriteBurst(MS_U8 ucAddr, MS_U8 ucLength, MS_U8 *buffer); 405 406 //------------------------------------------------------------------------------------------------- 407 /// MHL send write burst command use write request / write grant 408 /// @ingroup MHL_SEND 409 /// @param ucLength \b IN: Write burst data length 410 /// @param pBuffer \b IN: Write burst data content 411 /// @return TRUE : MHL send write burst success 412 /// @return FALSE : MHL send write burst fail or not ready 413 //------------------------------------------------------------------------------------------------- 414 // MS_BOOL SYMBOL_WEAK mapi_mhl_CbusSendUserWriteBurst(MS_U8 ucLength, MS_U8 *pBuffer); 415 // MS_BOOL mapi_mhl_ReadDeviceCapacibility(MS_U8 ucAddr, MS_U8 *ucData); 416 MS_BOOL mapi_mhl_GetDeviceCapacibility(MS_U16 usDevcapMask, MS_U8 *ucDevcap); 417 418 //------------------------------------------------------------------------------------------------- 419 /// MHL send write read extend device capability 420 /// @ingroup MHL_SEND 421 /// @param usExtendDevcapMask \b IN: Which data want to read 422 /// @param ucExtendDevcap \b IN: Read extend device capability buffer 423 /// @return TRUE : MHL read extend device capability success 424 /// @return FALSE : MHL read extend device capability fail or not ready 425 //------------------------------------------------------------------------------------------------- 426 MS_BOOL SYMBOL_WEAK mapi_mhl_GetExtendDeviceCapacibility(MS_U16 usExtendDevcapMask, MS_U8 *ucExtendDevcap); 427 428 //------------------------------------------------------------------------------------------------- 429 /// MHL send get vender ID 430 /// @ingroup MHL_SEND 431 /// @param ucVenderID \b IN: Vender buffer 432 /// @return TRUE : MHL get vender ID success 433 /// @return FALSE : MHL get vender ID fail or not ready 434 //------------------------------------------------------------------------------------------------- 435 MS_BOOL mapi_mhl_GetDeviceVenderID(MS_U8 *ucVenderID); 436 437 //------------------------------------------------------------------------------------------------- 438 /// MHL receive write burst data 439 /// @ingroup MHL_RECEIVE 440 /// @param ucData \b IN: Write burst data buffer 441 /// @return TRUE : MHL receive write burst data success 442 /// @return FALSE : MHL receive write burst data fail or not yeah 443 //------------------------------------------------------------------------------------------------- 444 MS_BOOL mapi_mhl_GetWriteBurstData(MS_U8 *ucData); 445 void mapi_mhl_Send3DInformation(void); 446 // void mapi_mhl_CbusSendCommand(void); 447 // MHL others function 448 // void mapi_mhl_CbusIsolate(void); 449 void mapi_mhl_CbusWakeupIntSetting(void); 450 MS_BOOL mapi_mhl_AutoSwitchHandler(MS_BOOL bReset, MS_U8 *ucCbusPath); 451 // void mapi_mhl_AdjustSettingIControl(MS_U8 ucIControl); 452 // void mapi_mhl_AdjustImpedanceSetting(MS_U8 ucImpedance); 453 // MS_BOOL mapi_mhl_WakeupDetect(void); 454 MS_U32 mapi_mhl_SetPowerState(EN_POWER_MODE u16PowerState); 455 void mapi_mhl_SetHPD(MS_BOOL bflag); 456 // void mapi_mhl_SetPsCtrl(MS_U8 u8Ctrl); 457 void mapi_mhl_CbusControl(MS_U8 ucState); 458 MS_BOOL mapi_mhl_CbusGetStatusFlag(MS_U8 ucState); 459 // void mapi_mhl_GetSWVersion(void); 460 // char* mapi_mhl_GetP4CL(void); 461 // char* mapi_mhl_GetMajorVersion(void); 462 // char* mapi_mhl_GetMinorVersion(void); 463 void mapi_mhl_RegisterCallBackFunctions(link_cbus_event_handle_func rcp, link_cbus_event_handle_func rap); 464 //void mapi_mhl_RegisterRcpCallBackFunction(link_cbus_event_handle_func rcp); 465 //void mapi_mhl_RegisterRapCallBackFunction(link_cbus_event_handle_func rap); 466 void mapi_mhl_RegisterUcpCallBackFunction(link_cbus_event_handle_func Ucp); 467 //void SYMBOL_WEAK mapi_mhl_RegisterAttCallBackFunction(link_cbus_event_handle_func Att); 468 //void SYMBOL_WEAK mapi_mhl_RegisterRbpCallBackFunction(link_cbus_event_handle_func Rbp); 469 470 #ifdef __cplusplus 471 } 472 #endif 473 474 #endif //_API_MHL_H_ 475