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 #define HAL_DSCMB_FLT_NULL 0xFFFFFFFFUL 107 108 typedef enum 109 { 110 E_HAL_DSCMB_TYPE_CSA = 0, // CSA, NSA as ESA 111 E_HAL_DSCMB_TYPE_CSA_CONF, // CSA conformance mechanism 112 E_HAL_DSCMB_TYPE_DES, // CI+ DES 113 E_HAL_DSCMB_TYPE_AES, // CI+ AES 114 E_HAL_DSCMB_TYPE_AES_CTR, // HDCP2 AES CTR 115 E_HAL_DSCMB_TYPE_NSA_AS_ESA,// NSA as ESA 116 E_HAL_DSCMB_TYPE_AES_LEADING_CLR_CBC, 117 E_HAL_DSCMB_TYPE_AES_LEADING_CLR_EBC, 118 E_HAL_DSCMB_TYPE_CSA3, 119 E_HAL_DSCMB_TYPE_DES_CBC, 120 E_HAL_DSCMB_TYPE_TDES_CBC, 121 E_HAL_DSCMB_TYPE_AES_ECB, 122 E_HAL_DSCMB_TYPE_AES_SCTE52, // DBook, AES+CBC, T8 new 123 E_HAL_DSCMB_TYPE_TDES_ECB, 124 E_HAL_DSCMB_TYPE_TDES_SCTE52, 125 126 E_HAL_DSCMB_TYPE_MULTI2, 127 E_HAL_DSCMB_TYPE_OC, // OpenCable 128 E_HAL_DSCMB_TYPE_INVALID = 0xFFFFFFFFUL // NSA as ESA 129 } HAL_DSCMB_Type; 130 131 typedef enum 132 { 133 E_HAL_DSCMB_NONE= 0x00000000, 134 E_HAL_DSCMB_TS= 0x00000001, 135 E_HAL_DSCMB_PES= 0x00000002, 136 E_HAL_DSCMB_TS_PES= (E_HAL_DSCMB_TS| E_HAL_DSCMB_PES), 137 } HAL_Scmb_Level; 138 139 // descrambler key ladder 140 typedef enum 141 { 142 E_HAL_DSCMB_KLAD_SRC_ACPU = 0, 143 E_HAL_DSCMB_KLAD_SRC_SECRET_KEY1 = 1, 144 E_HAL_DSCMB_KLAD_SRC_SECRET_KEY2 = 2, 145 E_HAL_DSCMB_KLAD_SRC_SECRET_KEY3 = 3, 146 E_HAL_DSCMB_KLAD_SRC_SECRET_KEY4 = 4, 147 E_HAL_DSCMB_KLAD_SRC_VGK = 7, 148 } HAL_DscmbKLadderSrc; 149 150 typedef enum 151 { 152 E_HAL_DSCMB_KLAD_DST_KTAB_ESA = 0x4, 153 E_HAL_DSCMB_KLAD_DST_KTAB_NSA = 0x2, 154 E_HAL_DSCMB_KLAD_DST_AESDMA_AES = 0x8, 155 E_HAL_DSCMB_KLAD_DST_AESDMA_TDES = 0x10, 156 E_HAL_DSCMB_KLAD_DST_ACPU = 0x1, 157 } HAL_DscmbKLadderDst; 158 159 typedef enum 160 { 161 // descrambler engine 162 E_HAL_DSCMB_CAP_ENGINE_NUM, 163 // descrambler slot 164 E_HAL_DSCMB_CAP_FLT_NUM, 165 // descrambler type supported 166 E_HAL_DSCMB_CAP_SUPPORT_ALGORITHM, 167 // descrambler mapping, start tsp pid filter 168 E_HAL_DSCMB_CAP_PIDFILTER_MAP_START, 169 // descrambler mapping, end tsp pid filter 170 E_HAL_DSCMB_CAP_PIDFILTER_MAP_END, 171 // share key slot max number 172 E_HAL_DSCMB_CAP_SHARE_KEY_SLOT_NUM, 173 // share key slot max number 174 E_HAL_DSCMB_CAP_SHARE_KEY_SLOT_MAX_NUM, 175 // share key region number 176 E_HAL_DSCMB_CAP_SHARE_KEY_REGION_NUM, 177 // share key region start 178 E_HAL_DSCMB_CAP_SHARE_KEY_REGION_START, 179 // share key region end 180 E_HAL_DSCMB_CAP_SHARE_KEY_REGION_END, 181 } HAL_DSCMB_Query_Type; 182 183 MS_BOOL HAL_DSCMB_SetBank(MS_VIRT u32Bank); 184 MS_BOOL HAL_DSCMB_Init(void); 185 MS_BOOL HAL_DSCMB_CheckShareConnect(MS_U32 u32EngId, MS_U32 u32FltId, DSCMB_SLOT_Type SlotType); 186 MS_BOOL HAL_DSCMB_GetCap(MS_U32 u32EngId, HAL_DSCMB_Query_Type eQueryType, void* pInData, void* pOutData); 187 MS_BOOL HAL_DSCMB_OptConfig(MS_U32 u32EngId, DSCMB_Option eOpt, void* pInput, void* pOutput, MS_BOOL bSet); 188 189 // MS_BOOL HAL_DSCMB_SlotAlloc(MS_U32 u32DscmbId, HAL_DscmbKey_Type DscmbKeyType, MS_U32* pu32SlotId); 190 // MS_BOOL HAL_DSCMB_SlotFree(MS_U32 u32DscmbId, HAL_DscmbKey_Type, MS_U32 u32SlotId); 191 MS_BOOL HAL_DSCMB_SlotConnectPidFltId(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type KeyType, MS_U32 u32SlotId, MS_U32 u32PidFltId); 192 MS_BOOL HAL_DSCMB_SlotDisconnectPidFltId(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type KeyType, MS_U32 u32SlotId, MS_U32 u32PidFltId); 193 MS_BOOL HAL_DSCMB_FltTypeSet(MS_U32 u32EngId, MS_U32 u32PidFltId, MS_U32 u32Slot, HAL_DSCMB_Type DscmbType, MS_BOOL bDscmb); 194 MS_BOOL HAL_DSCMB_FltKeySet(MS_U32 u32EngId, MS_U32 u32PidFltId, MS_U32 u32Slot, HAL_DSCMB_Type DscmbType, DSCMB_Key_Type, MS_U8* pu8Key); 195 MS_BOOL HAL_DSCMB_FltKeyReset(MS_U32 u32EngId, MS_U32 u32PidFltId, MS_U32 u32Slot, HAL_DSCMB_Type DscmbType, DSCMB_Key_Type eKeyType); 196 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); 197 198 MS_BOOL HAL_DSCMB_EcmCorruptSet(MS_U8 u8CorruptDataBytes, MS_U8 u8FromByte); 199 MS_BOOL HAL_DSCMB_EcmCorruptEnable(MS_U32 u32PidFltId, MS_BOOL bEnable); 200 201 MS_BOOL HAL_DSCMB_PidFlt_ScmbStatus(MS_U32 u32EngId, MS_U32 u32PidFltId, HAL_Scmb_Level* pScmbLevel); 202 203 MS_BOOL HAL_DSCMB_KLadder_Reset(void); 204 MS_BOOL HAL_DSCMB_KLadder_SetInput(MS_U32 u32Level, MS_U8* pu8In, MS_U32 u32InLen); 205 MS_BOOL HAL_DSCMB_KLadder_SetKey(HAL_DscmbKLadderSrc KLSrc, MS_U8* pu8Key, MS_U32 u32KeyLen); 206 MS_BOOL HAL_DSCMB_KLadder_SetDst(HAL_DscmbKLadderDst KLDst); 207 void HAL_DSCMB_KLadder_Decrypt(MS_BOOL bDecrypt); 208 void HAL_DSCMB_KLadder_ByteInv(MS_BOOL bInverse); 209 void HAL_DSCMB_KLadder_KeepRound(MS_BOOL bKeepRound); 210 void HAL_DSCMB_KLadder_Round(MS_U32 u32Round); 211 void HAL_DSCMB_KLadder_EngMode(MS_U32 u32Mode); 212 MS_BOOL HAL_DSCMB_KLadder_Start(void); 213 MS_BOOL HAL_DSCMB_KLadder_IsComplete(void); 214 MS_BOOL HAL_DSCMB_KLadder_Stop(void); 215 MS_BOOL HAL_DSCMB_KLadder_Output_Start(MS_U32 u32PidFltId, MS_U32 u32Slot, HAL_DSCMB_Type DscmbType, DSCMB_Key_Type eKeyType); 216 MS_BOOL HAL_DSCMB_KLadder_Output_IsComplete(void); 217 MS_BOOL HAL_DSCMB_KLadder_Output_Stop(void); 218 219 MS_BOOL HAL_DSCMB_KLadder_Acpu_Data(MS_U8* pu8Out); 220 MS_BOOL HAL_DSCMB_KLadder_Acpu_Ack(MS_BOOL bEn); 221 222 MS_BOOL HAL_DSCMB_HDCP2_SetRiv(MS_U32 u32EngId, MS_U8* pu8RIV); 223 // Only for scramble 224 MS_BOOL HAL_DSCMB_2ndarySet(MS_U32 u32PidPrim, MS_U32 u32Pid2ndary); 225 MS_BOOL HAL_DSCMB_2ndaryReset(MS_U32 u32PidPrim); 226 227 MS_BOOL HAL_DSCMB_Multi2_SetRound(MS_U32 u32EngId, MS_U32 u32Round); 228 MS_BOOL HAL_DSCMB_Multi2_SetSystemKey(MS_U32 u32EngId, MS_U8* u8SysKey); 229 230 #endif 231