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 // Copyright (c) 2006-2009 MStar Semiconductor, Inc. 81 // All rights reserved. 82 // 83 // Unless otherwise stipulated in writing, any and all information contained 84 // herein regardless in any format shall remain the sole proprietary of 85 // MStar Semiconductor Inc. and be kept in strict confidence 86 // ("MStar Confidential Information") by the recipient. 87 // Any unauthorized act including without limitation unauthorized disclosure, 88 // copying, use, reproduction, sale, distribution, modification, disassembling, 89 // reverse engineering and compiling of the contents of MStar Confidential 90 // Information is unlawful and strictly prohibited. MStar hereby reserves the 91 // rights to any and all damages, losses, costs and expenses resulting therefrom. 92 // 93 //////////////////////////////////////////////////////////////////////////////// 94 95 //////////////////////////////////////////////////////////////////////////////////////////////////// 96 /// 97 /// file drvDscmb.h 98 /// @brief Descrambler (Dscmb) Driver Interface 99 /// @author MStar Semiconductor,Inc. 100 /// @attention 101 //////////////////////////////////////////////////////////////////////////////////////////////////// 102 103 #ifndef __HAL_DSCMB_H__ 104 #define __HAL_DSCMB_H__ 105 106 #include "drvDSCMB.h" 107 108 #define HAL_DSCMB_FLT_NULL 0xFFFFFFFFUL 109 110 typedef enum 111 { 112 E_HAL_DSCMB_TYPE_CSA = 0, // CSA, NSA as ESA 113 E_HAL_DSCMB_TYPE_CSA_CONF, // CSA conformance mechanism 114 E_HAL_DSCMB_TYPE_DES, // CI+ DES 115 E_HAL_DSCMB_TYPE_AES, // CI+ AES 116 E_HAL_DSCMB_TYPE_AES_CTR, // HDCP2 AES CTR 117 E_HAL_DSCMB_TYPE_NSA_AS_ESA,// NSA as ESA 118 E_HAL_DSCMB_TYPE_AES_LEADING_CLR_CBC, 119 E_HAL_DSCMB_TYPE_AES_LEADING_CLR_EBC, 120 E_HAL_DSCMB_TYPE_CSA3, 121 E_HAL_DSCMB_TYPE_DES_CBC, 122 E_HAL_DSCMB_TYPE_TDES_CBC, 123 E_HAL_DSCMB_TYPE_AES_ECB, 124 E_HAL_DSCMB_TYPE_AES_SCTE52, // DBook, AES+CBC, T8 new 125 E_HAL_DSCMB_TYPE_TDES_ECB, 126 E_HAL_DSCMB_TYPE_TDES_SCTE52, 127 128 E_HAL_DSCMB_TYPE_MULTI2, 129 E_HAL_DSCMB_TYPE_OC, // OpenCable 130 E_HAL_DSCMB_TYPE_INVALID = 0xFFFFFFFFUL // NSA as ESA 131 } HAL_DSCMB_Type; 132 133 typedef enum 134 { 135 E_HAL_DSCMB_NONE= 0x00000000, 136 E_HAL_DSCMB_TS= 0x00000001, 137 E_HAL_DSCMB_PES= 0x00000002, 138 E_HAL_DSCMB_TS_PES= (E_HAL_DSCMB_TS| E_HAL_DSCMB_PES), 139 } HAL_Scmb_Level; 140 141 // descrambler key ladder 142 typedef enum 143 { 144 E_HAL_DSCMB_KLAD_SRC_ACPU = 0, 145 E_HAL_DSCMB_KLAD_SRC_SECRET_KEY1 = 1, 146 E_HAL_DSCMB_KLAD_SRC_SECRET_KEY2 = 2, 147 E_HAL_DSCMB_KLAD_SRC_SECRET_KEY3 = 3, 148 E_HAL_DSCMB_KLAD_SRC_SECRET_KEY4 = 4, 149 E_HAL_DSCMB_KLAD_SRC_VGK = 7, 150 } HAL_DscmbKLadderSrc; 151 152 typedef enum 153 { 154 E_HAL_DSCMB_KLAD_DST_KTAB_ESA = 0x4, 155 E_HAL_DSCMB_KLAD_DST_KTAB_NSA = 0x2, 156 E_HAL_DSCMB_KLAD_DST_AESDMA_AES = 0x8, 157 E_HAL_DSCMB_KLAD_DST_AESDMA_TDES = 0x10, 158 E_HAL_DSCMB_KLAD_DST_ACPU = 0x1, 159 } HAL_DscmbKLadderDst; 160 161 typedef enum 162 { 163 // descrambler engine 164 E_HAL_DSCMB_CAP_ENGINE_NUM, 165 // descrambler slot 166 E_HAL_DSCMB_CAP_FLT_NUM, 167 // descrambler type supported 168 E_HAL_DSCMB_CAP_SUPPORT_ALGORITHM, 169 // descrambler mapping, start tsp pid filter 170 E_HAL_DSCMB_CAP_PIDFILTER_MAP_START, 171 // descrambler mapping, end tsp pid filter 172 E_HAL_DSCMB_CAP_PIDFILTER_MAP_END, 173 // share key slot max number 174 E_HAL_DSCMB_CAP_SHARE_KEY_SLOT_NUM, 175 // share key slot max number 176 E_HAL_DSCMB_CAP_SHARE_KEY_SLOT_MAX_NUM, 177 // share key region number 178 E_HAL_DSCMB_CAP_SHARE_KEY_REGION_NUM, 179 // share key region start 180 E_HAL_DSCMB_CAP_SHARE_KEY_REGION_START, 181 // share key region end 182 E_HAL_DSCMB_CAP_SHARE_KEY_REGION_END, 183 } HAL_DSCMB_Query_Type; 184 185 typedef enum 186 { 187 // HDCP2.2 Errata 188 E_HAL_DSCMB_CFG_HDCP2_TX_CONTENT_CATEGORY_SUPPORT, 189 190 // update scramble bit @ PUSI packet 191 E_HAL_DSCMB_CFG_SCMB_STATUS_PUSI_ONLY, 192 } HAL_DSCMB_Option; 193 194 MS_BOOL HAL_DSCMB_SetBank(MS_VIRT u32Bank); 195 MS_BOOL HAL_DSCMB_Init(void); 196 MS_BOOL HAL_DSCMB_CheckShareConnect(MS_U32 u32EngId, MS_U32 u32FltId, DSCMB_SLOT_Type SlotType); 197 MS_BOOL HAL_DSCMB_GetCap(MS_U32 u32EngId, HAL_DSCMB_Query_Type eQueryType, void* pInData, void* pOutData); 198 MS_BOOL HAL_DSCMB_OptConfig(MS_U32 u32EngId, HAL_DSCMB_Option eOpt, void* pInput, void* pOutput, MS_BOOL bSet); 199 200 // MS_BOOL HAL_DSCMB_SlotAlloc(MS_U32 u32DscmbId, HAL_DscmbKey_Type DscmbKeyType, MS_U32* pu32SlotId); 201 // MS_BOOL HAL_DSCMB_SlotFree(MS_U32 u32DscmbId, HAL_DscmbKey_Type, MS_U32 u32SlotId); 202 MS_BOOL HAL_DSCMB_SlotConnectPidFltId(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type KeyType, MS_U32 u32SlotId, MS_U32 u32PidFltId); 203 MS_BOOL HAL_DSCMB_SlotDisconnectPidFltId(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type KeyType, MS_U32 u32SlotId, MS_U32 u32PidFltId); 204 MS_BOOL HAL_DSCMB_FltTypeSet(MS_U32 u32EngId, MS_U32 u32PidFltId, MS_U32 u32Slot, HAL_DSCMB_Type DscmbType, MS_BOOL bDscmb); 205 MS_BOOL HAL_DSCMB_FltKeySet(MS_U32 u32EngId, MS_U32 u32PidFltId, MS_U32 u32Slot, HAL_DSCMB_Type DscmbType, DSCMB_Key_Type, MS_U8* pu8Key); 206 MS_BOOL HAL_DSCMB_FltKeyReset(MS_U32 u32EngId, MS_U32 u32PidFltId, MS_U32 u32Slot, HAL_DSCMB_Type DscmbType, DSCMB_Key_Type eKeyType); 207 MS_BOOL HAL_DSCMB_FltIVSet(MS_U32 u32EngId, MS_U32 u32PidFltId, MS_U32 u32Slot, HAL_DSCMB_Type DscmbType, DSCMB_Key_Type eKeyType, MS_U8* pu8IV); 208 209 MS_BOOL HAL_DSCMB_EcmCorruptSet(MS_U8 u8CorruptDataBytes, MS_U8 u8FromByte); 210 MS_BOOL HAL_DSCMB_EcmCorruptEnable(MS_U32 u32PidFltId, MS_BOOL bEnable); 211 212 MS_BOOL HAL_DSCMB_PidFlt_ScmbStatus(MS_U32 u32EngId, MS_U32 u32PidFltId, HAL_Scmb_Level* pScmbLevel); 213 214 MS_BOOL HAL_DSCMB_KLadder_Reset(void); 215 MS_BOOL HAL_DSCMB_KLadder_SetInput(MS_U32 u32Level, MS_U8* pu8In, MS_U32 u32InLen); 216 MS_BOOL HAL_DSCMB_KLadder_SetKey(HAL_DscmbKLadderSrc KLSrc, MS_U8* pu8Key, MS_U32 u32KeyLen); 217 MS_BOOL HAL_DSCMB_KLadder_SetDst(HAL_DscmbKLadderDst KLDst); 218 void HAL_DSCMB_KLadder_Decrypt(MS_BOOL bDecrypt); 219 void HAL_DSCMB_KLadder_ByteInv(MS_BOOL bInverse); 220 void HAL_DSCMB_KLadder_KeepRound(MS_BOOL bKeepRound); 221 void HAL_DSCMB_KLadder_Round(MS_U32 u32Round); 222 void HAL_DSCMB_KLadder_EngMode(MS_U32 u32Mode); 223 MS_BOOL HAL_DSCMB_KLadder_Start(void); 224 MS_BOOL HAL_DSCMB_KLadder_IsComplete(void); 225 MS_BOOL HAL_DSCMB_KLadder_Stop(void); 226 MS_BOOL HAL_DSCMB_KLadder_Output_Start(MS_U32 u32PidFltId, MS_U32 u32Slot, HAL_DSCMB_Type DscmbType, DSCMB_Key_Type eKeyType); 227 MS_BOOL HAL_DSCMB_KLadder_Output_IsComplete(void); 228 MS_BOOL HAL_DSCMB_KLadder_Output_Stop(void); 229 230 MS_BOOL HAL_DSCMB_KLadder_Acpu_Data(MS_U8* pu8Out); 231 MS_BOOL HAL_DSCMB_KLadder_Acpu_Ack(MS_BOOL bEn); 232 233 MS_BOOL HAL_DSCMB_HDCP2_SetRiv(MS_U32 u32EngId, MS_U8* pu8RIV); 234 // Only for scramble 235 MS_BOOL HAL_DSCMB_2ndarySet(MS_U32 u32PidPrim, MS_U32 u32Pid2ndary); 236 MS_BOOL HAL_DSCMB_2ndaryReset(MS_U32 u32PidPrim); 237 238 MS_BOOL HAL_DSCMB_Multi2_SetRound(MS_U32 u32EngId, MS_U32 u32Round); 239 MS_BOOL HAL_DSCMB_Multi2_SetSystemKey(MS_U32 u32EngId, MS_U8* u8SysKey); 240 241 #endif 242