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 MapiHDMIRx_private.h 81 /// @author MStar Semiconductor Inc. 82 /// @brief MHL driver Function 83 /////////////////////////////////////////////////////////////////////////////////////////////////// 84 85 86 #ifndef _API_HDMI_RX_PRIVATE_H_ 87 #define _API_HDMI_RX_PRIVATE_H_ 88 89 #include "MsTypes.h" 90 #include "MsDevice.h" 91 #include "MsCommon.h" 92 93 #ifdef __cplusplus 94 extern "C" 95 { 96 #endif 97 98 #include "mhal_hdmi.h" 99 #include "drvXC_HDMI_if.h" 100 101 #ifndef UNUSED 102 #define UNUSED(x) (void)(x) 103 #endif 104 105 #define GET_HDMI_FLAG(a, b) (MS_BOOL)((a &b) ?TRUE :FALSE) 106 #define SET_HDMI_FLAG(a, b) (a |= b) 107 #define CLR_HDMI_FLAG(a, b) (a &= ~b) 108 109 //------------------------------------------------------------------------------------------------- 110 // Local Defines 111 //------------------------------------------------------------------------------------------------- 112 #define HDMI_HDCP_KEY_LENGTH 289U 113 #define HDMI_HDCP_BKSV_LENGTH 5U 114 #define HDMI_HDCP22_RIV_LENGTH 8U 115 #define HDMI_HDCP22_SESSION_KEY_LENGTH 16U 116 #define HDMI_HDCP22_MESSAGE_LENGTH 129U 117 #define HDMI_POLLING_STACK_SIZE 1U 118 #define HDMI_HDCP_INTERRUPT_STACK_SIZE 1U 119 #define HDMI_PACKET_RECEIVE_COUNT 5U // 5 x 10ms = 50ms 120 #define HDMI_HDCP14_RI_COUNT 550U // 550 x 10ms = 5.5s 121 #define HDMI_HDCP_KSV_LIST_LENGTH 635U // max: 127x5 122 #define HDMI_HDCP_VPRIME_LENGTH 20U 123 #define HDMI_HDCP_EVENT_POLLING_STATUS 0x100U 124 #define HDMI_HDCP_EVENT_RECEIVE_AKE_INIT 0x200U 125 #define HDMI_HDCP_EVENT_WAIT_MESSAGE 0x300U 126 #define HDMI_HDCP_EVENT_WRITE_DONE 0x400U 127 #define HDMI_HDCP_EVENT_STR_SUSPEND 0x500U 128 #define HDMI_HDCP_EVENT_STR_RESUME 0x600U 129 #define HDMI_HDCP_EVENT_INDEX_MASK 0xFFFFFF00U 130 #define HDMI_HDCP_EVENT_STATUS_MASK 0x000000FFU 131 #define HDMI_HDCP_ALL_EVENT 0xFFFFFFFFU 132 133 //------------------------------------------------------------------------------------------------- 134 // Local Structures 135 //------------------------------------------------------------------------------------------------- 136 typedef struct _HDMI_RX_RESOURCE_PRIVATE 137 { 138 MS_BOOL bSelfCreateTaskFlag; 139 MS_BOOL bHDMITaskProcFlag; 140 MS_BOOL bImmeswitchSupport; 141 MS_BOOL bHDCP14KeyVaildFlag; 142 MS_BOOL bHPDInvertFlag[4]; 143 MS_BOOL bHDCPIRQAttachFlag; 144 MS_BOOL bHDCP22IRQMaskFlag[4]; 145 MS_BOOL bHDCP14RiFlag[4]; 146 MS_BOOL bHDCP14RxREEFlag; 147 MS_U8 ucInitialIndex; 148 MS_U8 ucMHLSupportPath; 149 MS_U8 ucHDCPKeyTable[HDMI_HDCP_KEY_LENGTH]; 150 MS_U8 ucCheckPacketState[HDMI_INFO_SOURCE_MAX]; 151 MS_U8 ucReceiveInterval[HDMI_INFO_SOURCE_MAX]; 152 MS_U8 ucReceiveIntervalCount[HDMI_INFO_SOURCE_MAX]; 153 MS_U8 ucHDMIPollingStack[HDMI_POLLING_STACK_SIZE]; 154 MS_U8 ucHDCP22RecvIDListSend[4]; 155 MS_U8 ucHDCPWriteDoneIndex; 156 MS_U8 ucHDCPReadDoneIndex; 157 MS_U16 usHDCP14RiCount[4]; 158 MS_U32 ulPacketStatus[HDMI_INFO_SOURCE_MAX]; 159 MS_S32 slHDMIPollingTaskID; 160 MS_S32 slHDMIHDCPEventID; 161 EN_POWER_MODE usPrePowerState; 162 stHDMI_POLLING_INFO stHDMIPollingInfo[4]; 163 }HDMI_RX_RESOURCE_PRIVATE; 164 165 typedef void (*IOCTL_HDMIRX_INITIAL) (void*, stHDMI_INITIAL_TABLE); 166 typedef void (*IOCTL_HDMIRX_STABLE_POLLING) (void*); 167 typedef MS_U8 (*IOCTL_HDMIRX_GET_SOURCE_VERSION) (void*, E_MUX_INPUTPORT); 168 typedef MS_U8 (*IOCTL_HDMIRX_CHECK_HDCP_STATE) (void*, E_MUX_INPUTPORT); 169 typedef MS_U8 (*IOCTL_HDMIRX_CHECK_HDCP_ENC_STATE) (void*, E_MUX_INPUTPORT); 170 typedef void (*IOCTL_HDMIRX_CHECK_HDCP14_KEY_VAILD) (void*, MS_U8*); 171 typedef MS_BOOL (*IOCTL_HDMIRX_GET_HDCP14_KEY_VAILD_FLAG) (void*); 172 typedef void (*IOCTL_HDMIRX_SET_HPD_INVERT_FLAG) (void*, E_MUX_INPUTPORT, MS_BOOL); 173 typedef MS_U32 (*IOCTL_HDMIRX_GET_PACKET_RECEIVE) (void*, MS_U8); 174 /*************************** HDCP Repeater ***************************/ 175 typedef void (*IOCTL_HDMIRX_WRITE_X74) (void*, E_MUX_INPUTPORT, MS_U8, MS_U8); 176 typedef MS_U8 (*IOCTL_HDMIRX_READ_X74) (void*, E_MUX_INPUTPORT, MS_U8); 177 typedef void (*IOCTL_HDMIRX_SET_REPEATER) (void*, E_MUX_INPUTPORT, MS_BOOL); 178 typedef void (*IOCTL_HDMIRX_SET_BSTATUS) (void*, E_MUX_INPUTPORT, MS_U16); 179 typedef void (*IOCTL_HDMIRX_SET_HDMI_MODE) (void*, E_MUX_INPUTPORT, MS_BOOL); 180 typedef MS_U8 (*IOCTL_HDMIRX_GET_INTERRUPT_STATUS) (void*, E_MUX_INPUTPORT); 181 typedef void (*IOCTL_HDMIRX_WRITE_KSV_LIST) (void*, E_MUX_INPUTPORT, MS_U8*, MS_U32); 182 typedef void (*IOCTL_HDMIRX_SET_VPRIME) (void*, E_MUX_INPUTPORT, MS_U8*); 183 /*************************** HDCP Repeater ***************************/ 184 /*************************** HDCP22 ***************************/ 185 typedef void (*IOCTL_HDMIRX_FILL_CIPHER_KEY) (void*, MS_U8, MS_U8*, MS_U8*); 186 typedef void (*IOCTL_HDMIRX_PORT_INIT) (void*, MS_U8); 187 typedef MS_BOOL (*IOCTL_HDMIRX_POLLING_READ_DONE) (void*, MS_U8); 188 typedef void (*IOCTL_HDMIRX_ENABLE_CIPHER) (void*, MS_U8, MS_U8, MS_BOOL); 189 typedef void (*IOCTL_HDMIRX_SEND_MESSAGE) (void*, MS_U8, MS_U8, MS_U8*, MS_U32, void*); 190 typedef MS_BOOL (*IOCTL_HDMIRX_HDCP22_HANDER) (void*, MS_U8, MS_U8*, MS_U8*, MS_U32*, MS_BOOL); 191 typedef MS_U8 (*IOCTL_HDMIRX_HDCP22_WAIT_EVENT) (void*); 192 /*************************** HDCP22 ***************************/ 193 194 typedef struct _HDMI_RX_INSTANT_PRIVATE 195 { 196 MS_U32 ulDeviceID; 197 IOCTL_HDMIRX_INITIAL fpHDMIRxInitial; 198 IOCTL_HDMIRX_STABLE_POLLING fpHDMIRxStablePolling; 199 IOCTL_HDMIRX_GET_SOURCE_VERSION fpHDMIRxGetSourceVersion; 200 IOCTL_HDMIRX_CHECK_HDCP_STATE fpHDMIRxCheckHDCPState; 201 IOCTL_HDMIRX_CHECK_HDCP_ENC_STATE fpHDMIRxCheckHDCPENCState; 202 IOCTL_HDMIRX_CHECK_HDCP14_KEY_VAILD fpHDMIRxCheckHDCP14KeyVaild; 203 IOCTL_HDMIRX_GET_HDCP14_KEY_VAILD_FLAG fpHDMIRxGetHDCP14KeyVaildFlag; 204 IOCTL_HDMIRX_SET_HPD_INVERT_FLAG fpHDMIRxSetHPDInvertFlag; 205 IOCTL_HDMIRX_GET_PACKET_RECEIVE fpHDMIRxGetPacketReceive; 206 /*************************** HDCP Repeater ***************************/ 207 IOCTL_HDMIRX_WRITE_X74 fpHDMIRxWriteX74; 208 IOCTL_HDMIRX_READ_X74 fpHDMIRxReadX74; 209 IOCTL_HDMIRX_SET_REPEATER fpHDMIRxSetRepeater; 210 IOCTL_HDMIRX_SET_BSTATUS fpHDMIRxSetBstatus; 211 IOCTL_HDMIRX_SET_HDMI_MODE fpHDMIRxSetHDMIMode; 212 IOCTL_HDMIRX_GET_INTERRUPT_STATUS fpHDMIRxGetInterruptStatus; 213 IOCTL_HDMIRX_WRITE_KSV_LIST fpHDMIRxWriteKSVList; 214 IOCTL_HDMIRX_SET_VPRIME fpHDMIRxSetVPrime; 215 /*************************** HDCP Repeater ***************************/ 216 IOCTL_HDMIRX_FILL_CIPHER_KEY fpHDMIRxFillCipherKey; 217 IOCTL_HDMIRX_PORT_INIT fpHDMIRxPortInit; 218 IOCTL_HDMIRX_POLLING_READ_DONE fpHDMIRxPollingReadDone; 219 IOCTL_HDMIRX_ENABLE_CIPHER fpHDMIRxEnableCipher; 220 IOCTL_HDMIRX_SEND_MESSAGE fpHDMIRxSendMessage; 221 IOCTL_HDMIRX_HDCP22_HANDER fpHDMIRxHDCP22Handler; 222 IOCTL_HDMIRX_HDCP22_WAIT_EVENT fpHDMIRxHDCP22WaitEvent; 223 }HDMI_RX_INSTANT_PRIVATE; 224 225 typedef enum 226 { 227 HDMI_RX_POOL = 0, 228 HDMI_RX_POOL_MAX, 229 }eHDMIRxPoolID; 230 231 //------------------------------------------------------------------------------------------------- 232 // Global Variables 233 //------------------------------------------------------------------------------------------------- 234 235 //------------------------------------------------------------------------------------------------- 236 // Function Prototype 237 //------------------------------------------------------------------------------------------------- 238 MS_U32 mdrv_HDMI_STREventProc(void* pModule, EN_POWER_MODE usPowerState); 239 void mdrv_HDMI_InitialSetting(void* pInstance, stHDMI_INITIAL_TABLE stInitialTable); 240 void mdrv_HDMI_StablePolling(void* pInstance); 241 MS_U8 mdrv_HDMI_GetSourceVersion(void* pInstance, E_MUX_INPUTPORT enInputPortType); 242 MS_U8 mdrv_HDMI_CheckHDCPState(void* pInstance, E_MUX_INPUTPORT enInputPortType); 243 MS_U8 mdrv_HDMI_CheckHDCPENCState(void* pInstance, E_MUX_INPUTPORT enInputPortType); 244 void mdrv_HDMI_CheckHDCP14KeyVaild(void* pInstance, MS_U8 *ucHDCPKeyData); 245 MS_BOOL mdrv_HDMI_GetHDCP14KeyVaildFlag(void* pInstance); 246 void mdrv_HDMI_SetHPDInvertFlag(void* pInstance, E_MUX_INPUTPORT enInputPortType, MS_BOOL bHPDInvertFlag); 247 MS_U32 mdrv_HDMI_GetPacketReceiveStatus(void* pInstance, MS_U8 ucHDMIInfoSource); 248 #ifdef CONFIG_UTOPIA_PROC_DBG_SUPPORT 249 void mdrv_HDMI_MDCMDEchoCommand(void* pInstance, MS_U64* u64ReqHdl, char* pcCmdLine); 250 void mdrv_HDMI_MDCMDGetInfo(void* pInstance, MS_U64* u64ReqHdl); 251 #endif 252 /*************************** HDCP Repeater ***************************/ 253 void mdrv_HDCP_WriteX74(void* pInstance, E_MUX_INPUTPORT enInputPortType, MS_U8 ucOffset, MS_U8 ucData); 254 MS_U8 mdrv_HDCP_ReadX74(void* pInstance, E_MUX_INPUTPORT enInputPortType, MS_U8 ucOffset); 255 void mdrv_HDCP_SetRepeater(void* pInstance, E_MUX_INPUTPORT enInputPortType, MS_BOOL bIsRepeater); 256 void mdrv_HDCP_SetBstatus(void* pInstance, E_MUX_INPUTPORT enInputPortType, MS_U16 usBstatus); 257 void mdrv_HDCP_SetHDMIMode(void* pInstance, E_MUX_INPUTPORT enInputPortType, MS_BOOL bHDMIMode); 258 MS_U8 mdrv_HDCP_GetInterruptStatus(void* pInstance, E_MUX_INPUTPORT enInputPortType); 259 void mdrv_HDCP_WriteKSVList(void* pInstance, E_MUX_INPUTPORT enInputPortType, MS_U8* pucKSV, MS_U32 ulDataLen); 260 void mdrv_HDCP_SetVPrime(void* pInstance, E_MUX_INPUTPORT enInputPortType, MS_U8* pucVPrime); 261 /*************************** HDCP Repeater ***************************/ 262 MS_BOOL MDrv_HDMI_IOCTL(MS_U32 ulCommand, void *pBuffer, MS_U32 ulBufferSize); 263 void mdrv_HDCP22_FillCipherKey(void* pInstance, MS_U8 ucPortIdx, MS_U8* pucRiv, MS_U8* pucSessionKey); 264 void mdrv_HDCP22_PortInit(void* pInstance, MS_U8 ucPortIdx); 265 MS_BOOL mdrv_HDCP22_PollingReadDone(void* pInstance, MS_U8 ucPortIdx); 266 void mdrv_HDCP22_EnableCipher(void* pInstance, MS_U8 ucPortType, MS_U8 ucPortIdx, MS_BOOL bIsEnable); 267 void mdrv_HDCP22_SendMessage(void* pInstance, MS_U8 ucPortType, MS_U8 ucPortIdx, MS_U8* pucData, MS_U32 dwDataLen, void* pDummy); 268 MS_BOOL mdrv_HDCP22_Handler(void* pInstance, MS_U8 ucPortIdx, MS_U8* ucPortType, MS_U8* pucMsgData, MS_U32* wMsgLen, MS_BOOL bIRQModeFlag); 269 MS_U8 mdrv_HDCP22_WaitEvent(void* pInstance); 270 271 #endif //_API_HDMI_RX_PRIVATE_H_ 272