xref: /utopia/UTPA2-700.0.x/projects/tmplib/include/drvDSCMB.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 // 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 ////////////////////////////////////////////////////////////////////////////////////////////////////
101 //-------------------------------------------------
102 /*! \defgroup DSCMB DSCMB interface
103 
104   MSTAR DESCRAMBLE(abbr. DSCMB) engine is used to decrypt the payload of Transport stream packet (ISO 13818-1).
105   The design of descramble engine must corporate with DEMUX engine to accomplish decryption process, which including TS packet filtering and TS payload descrambling.
106 
107   <b> DSCMB engine support following cipher algorithms. </b> \n
108   -# CSA :  Common Scrambling Algorithm, ETSI TS 100 289
109   -# DES :  Data Encryption Standard, U.S. FIPS PUB 46-2
110   -# AES :  Advanced Encryption Standard, U.S. FIPS PUB 197 (FIPS 197)
111   -# AES-CTR :   High-Bandwidth Digital Content Protection (HDCP2.x)
112   -# SCTE52 (DVS042) :   Data Encryption Standard �V Cipher Block Chaining Packet Encryption Specification
113   -# MULTI2 :   ISO/IEC 9979 and assigned registration number 9
114 
115   <b> API call flow: </b> \n
116    \image html drvDSCMB_pic.png
117 
118   *! \defgroup DSCMB_General DSCMB general functions
119   *   \ingroup   DSCMB
120 
121   *! \defgroup DSCMB_Slot_Control DSCMB alloc/free/connect/disconnect functions.
122   *   \ingroup   DSCMB
123 
124   *! \defgroup DSCMB_Key DSCMB set type/key related functions.
125   *   \ingroup   DSCMB
126 
127   *! \defgroup DSCMB_STR DSCMB STR related functions
128   *   \ingroup   DSCMB
129 
130   *! \defgroup DSCMB_ToBeModified DSCMB api to be modified
131   *   \ingroup   DSCMB
132 
133   *! \defgroup DSCMB_ToBeModified_Slot_Ctrl DSCMB slot control functions. (To be modified)
134   *   \ingroup   DSCMB_ToBeModified
135 
136   *! \defgroup DSCMB_ToBeRemove DSCMB api to be removed
137   *   \ingroup   DSCMB
138 
139   *! \defgroup DSCMB_STB DSCMB functions for STB.
140   *   \ingroup   DSCMB
141 
142   *! \defgroup DSCMB_STB_General DSCMB general functions for STB.
143   *   \ingroup   DSCMB_STB
144 
145   *! \defgroup DSCMB_STB_Kladder DSCMB Kladder functions for STB.
146   *   \ingroup   DSCMB_STB
147 
148   */
149 //-------------------------------------------------
150 
151 
152 #ifndef __DRV_DSCMB_H__
153 #define __DRV_DSCMB_H__
154 
155 #include "MsTypes.h"
156 #include "MsCommon.h"
157 
158 #include "ULog.h"
159 
160 #ifdef __cplusplus
161 extern "C"
162 {
163 #endif
164 
165 #define MSIF_DSMB_LIB_CODE              {'D','S','M','B'}    //Lib code
166 #define MSIF_DSMB_LIBVER                {'0','2'}            //LIB version
167 #define MSIF_DSMB_BUILDNUM              {'1','8'}            //Build Number
168 #define MSIF_DSMB_CHANGELIST            {'0','0','5','6','5','9','8','0'} //P4 ChangeList Number
169 
170 #define DSCMB_DRV_VERSION               /* Character String for DRV/API version             */  \
171     MSIF_TAG,                           /* 'MSIF'                                           */  \
172     MSIF_CLASS,                         /* '00'                                             */  \
173     MSIF_CUS,                           /* 0x0000                                           */  \
174     MSIF_MOD,                           /* 0x0000                                           */  \
175     MSIF_CHIP,                                                                                  \
176     MSIF_CPU,                                                                                   \
177     MSIF_DSMB_LIB_CODE,                 /* IP__                                             */  \
178     MSIF_DSMB_LIBVER,                   /* 0.0 ~ Z.Z                                        */  \
179     MSIF_DSMB_BUILDNUM,                 /* 00 ~ 99                                          */  \
180     MSIF_DSMB_CHANGELIST,               /* CL#                                              */  \
181     MSIF_OS
182 
183 
184 #define DSCMB_ASSERT_AND_RETURN(x)             if (!(x)){printf ("ASSERT FAIL: %s %s %d\n", __FILE__, __FUNCTION__, __LINE__); return FALSE;}
185 #define DSCMB_ASSERT_NO_RETURN(x)             if (!(x)){printf ("ASSERT FAIL: %s %s %d\n", __FILE__, __FUNCTION__, __LINE__);}
186 
187 #define DSCMB_LIB_TIME_MAX          16      ///< Maximum length of time
188 #define DSCMB_LIB_DATE_MAX          16      ///< Maximum length of date
189 
190 typedef struct
191 {
192     MS_U8   Time[DSCMB_LIB_TIME_MAX];       ///< Library Built Time
193     MS_U8   Date[DSCMB_LIB_DATE_MAX];       ///< Library Built Date
194 } DSCMB_Info;
195 
196 typedef struct
197 {
198     MS_U32 u32Status;
199 } DSCMB_Status;
200 
201 /// Descrambler null filter ID
202 #define DRV_DSCMB_FLT_NULL          0xFFFFFFFF
203 
204 typedef enum
205 {
206     /// Descrambler Slot Type :
207     E_SLOT_TYPE_NORMAL = 0,  // Normal
208     E_SLOT_TYPE_SHARE,       // Share
209 } DSCMB_SLOT_Type;
210 
211 typedef enum
212 {
213     E_DSCMB_FLT_3_KEYS        = 0x00000000, // Odd, Even, and Clear Key
214     E_DSCMB_FLT_2_KEYS        = 0x00000001, // Odd and Even Key
215     E_DSCMB_FLT_2_KEYS_SHARE  = 0x00000002, // Odd and Even Key (share key)
216     E_DSCMB_FLT_1_KEYS        = 0x00000003, // Always use the Key
217 } DSCMB_Flt_Type;
218 
219 /// Descrambler algorithm type
220 typedef enum
221 {
222     /// Descrambler algorithm : CSA
223     E_DSCMB_TYPE_CSA = 0,    // CSA
224     /// Descrambler algorithm : NSA as ESA
225     E_DSCMB_TYPE_NSA_AS_ESA, // NSA as ESA
226     /// Descrambler algorithm : CI+ DES
227     E_DSCMB_TYPE_DES,        // CI+ DES
228     /// Descrambler algorithm : CI+ AES
229     E_DSCMB_TYPE_AES,        // CI+ AES
230     // E_DSCMB_TYPE_ESA,       // ESA
231     // E_DSCMB_TYPE_NSAS,      // NSAS
232     E_DSCMB_TYPE_AES_ECB,
233     E_DSCMB_TYPE_AES_SCTE52,  // Descrambler algorithm : DBook, AES+CBC, S8 new, not support for all chips
234     E_DSCMB_TYPE_AES_CTR,     // AES Counter mode
235     E_DSCMB_TYPE_TDES_ECB,
236     E_DSCMB_TYPE_TDES_SCTE52,
237 
238     // Synamedia AES
239     E_DSCMB_TYPE_SYN_AES,    // AES Leading CLR EBC
240 
241     E_DSCMB_TYPE_MULTI2,    // Multi2
242 
243     /// Descrambler algorithm : CSA3
244     E_DSCMB_TYPE_CSA3,    // CSA3
245 
246     /// Descrambler algorithm : CSA conformance mode
247     E_DSCMB_TYPE_CSA_CONF,    // CSA conformance mode
248 
249     E_DSCMB_TYPE_OC,    // Open Cable
250 } DSCMB_Type;
251 
252 /// Descrambler key type
253 typedef enum
254 {
255     /// Descrambler key type : clear
256     E_DSCMB_KEY_CLEAR = 0,
257     /// Descrambler key type : even
258     E_DSCMB_KEY_EVEN,
259     /// Descrambler key type : odd
260     E_DSCMB_KEY_ODD,
261 } DSCMB_Key_Type;
262 
263 /// Scramble level
264 typedef enum
265 {
266     /// Descrambler level : none
267     E_DSCMB_NONE                    =   0x00000000,
268     /// Descrambler level : TS level
269     E_DSCMB_TS                      =   0x00000001,
270     /// Descrambler level : PES level
271     E_DSCMB_PES                     =   0x00000002,
272     /// Descrambler level : TS and PES level
273     E_DSCMB_TS_PES                  =   (E_DSCMB_TS | E_DSCMB_PES),
274 } SCMB_Level;
275 
276 // Descrambler Engine Type //
277 typedef enum
278 {
279     E_DSCMB_ENG_LSAS = 0x1,
280     E_DSCMB_ENG_ESA  = 0x2,
281     E_DSCMB_ENG_LSAD = 0x4,
282 } DSCMB_Eng_Type;
283 
284 /// Key ladder input source
285 typedef enum
286 {
287     /// Key ladder source from ACPU/SCPU
288     E_DSCMB_KL_SRC_ACPU             =   0,
289     /// Key ladder source from SECRET_1
290     E_DSCMB_KL_SRC_SECRET_1         =   1,
291     /// Key ladder source from SECRET_2
292     E_DSCMB_KL_SRC_SECRET_2         =   2,
293     /// Key ladder source from SECRET_3
294     E_DSCMB_KL_SRC_SECRET_3         =   3,
295     /// Key ladder source from SECRET_4
296     E_DSCMB_KL_SRC_SECRET_4         =   4,
297     /// Key ladder source from SECRET_5
298     E_DSCMB_KL_SRC_SECRET_5         =   5,
299     /// Key ladder source from SECRET_6
300     E_DSCMB_KL_SRC_SECRET_6         =   6,
301     /// Key ladder source from SECRET_7
302     E_DSCMB_KL_SRC_SECRET_7         =   7,
303     /// Key ladder source from SECRET_8
304     E_DSCMB_KL_SRC_SECRET_8         =   8,
305 
306     /// Key ladder source from Private_0
307     E_DSCMB_KL_SRC_PRIVATE_0        =   5,
308     /// Key ladder source from Private_1
309     E_DSCMB_KL_SRC_PRIVATE_1        =   6,
310     /// Key ladder source from Private_2
311     E_DSCMB_KL_SRC_PRIVATE_2        =   7,
312     /// Key ladder source from Private_3
313     E_DSCMB_KL_SRC_PRIVATE_3        =   8,
314 
315     /// Key ladder source from VGK
316     E_DSCMB_KL_SRC_VGK              =   9,
317 } DSCMB_KLSrc;
318 
319 /// Key ladder output destination
320 typedef enum
321 {
322     E_DSCMB_KL_DST_ACPU             =   0x1,
323     E_DSCMB_KL_DST_KT_NSA           =   0x3,
324     E_DSCMB_KL_DST_DMA_AES          =   0x4,
325     E_DSCMB_KL_DST_DMA_TDES         =   0x5,
326     E_DSCMB_KL_DST_PRIVATE0         =   0x6,
327     E_DSCMB_KL_DST_PRIVATE1         =   0x7,
328     E_DSCMB_KL_DST_PRIVATE2         =   0x8,
329 
330 
331     /// Key ladder destination to ACPU
332     E_DSCMB_KL_DST_CPU_ACPU         =   0x00000080,
333     /// Key ladder destination to Secure CPU
334     E_DSCMB_KL_DST_CPU_SCPU         =   0x00000081,
335     /// Key ladder destination to DSCMB (KeyTable)
336     E_DSCMB_KL_DST_KT_LSAD          =   0x00008000,
337     E_DSCMB_KL_DST_KT_ESA           =   0x00008100,
338     E_DSCMB_KL_DST_KT_LSAS          =   0x00008200,
339     /// Key ladder destination to DMA
340     E_DSCMB_KL_DST_DMA_SK0         =    0x00800000,
341     E_DSCMB_KL_DST_DMA_SK1         =    0x00810000,
342     E_DSCMB_KL_DST_DMA_SK2         =    0x00820000,
343     E_DSCMB_KL_DST_DMA_SPS0        =    0x00880000 ,
344     E_DSCMB_KL_DST_DMA_SPS1        =    0x00890000 ,
345     E_DSCMB_KL_DST_DMA_SPS2        =    0x008A0000 ,
346     E_DSCMB_KL_DST_DMA_SPS3        =    0x008B0000 ,
347     E_DSCMB_KL_DST_DMA_SPD0        =    0x008C0000 ,
348     E_DSCMB_KL_DST_DMA_SPD1        =    0x008D0000 ,
349     E_DSCMB_KL_DST_DMA_SPD2        =    0x008E0000 ,
350     E_DSCMB_KL_DST_DMA_SPD3        =    0x008F0000 ,
351     /// Key ladder destination to PRIVATE KEY
352     E_DSCMB_KL_DST_PRIVATE_0       =    0x81000000   ,
353     E_DSCMB_KL_DST_PRIVATE_1       =    0x82000000   ,
354     E_DSCMB_KL_DST_PRIVATE_2       =    0x83000000   ,
355     E_DSCMB_KL_DST_PRIVATE_3       =    0x84000000   ,
356 } DSCMB_KLDst;
357 
358 typedef enum
359 {
360     // descrambler engine
361     E_DSCMB_CAP_ENGINE_NUM,
362     // descrambler slot
363     E_DSCMB_CAP_FLT_NUM,
364     // descrambler type supported
365     E_DSCMB_CAP_SUPPORT_ALGORITHM,
366     // descrambler key type supported
367     E_DSCMB_CAP_SUPPORT_KEY_TYPE,
368     // descrambler mapping, start tsp pid filter
369     E_DSCMB_CAP_PIDFILTER_MAP_START,
370     // descrambler mapping, end tsp pid filter
371     E_DSCMB_CAP_PIDFILTER_MAP_END,
372     // share key slot max number
373     E_DSCMB_CAP_SHARE_KEY_SLOT_MAX_NUM,
374     // share key region number
375     E_DSCMB_CAP_SHARE_KEY_REGION_NUM,
376     // share key region start
377     E_DSCMB_CAP_SHARE_KEY_REGION_START,
378     // share key region end
379     E_DSCMB_CAP_SHARE_KEY_REGION_END,
380 } DSCMB_Query_Type;
381 
382 typedef enum
383 {
384     E_DSCMB_KL_TDES                 =   0x00000000,
385     E_DSCMB_KL_AES                  =   0x0000003F,
386 } DSCMB_KLEng;
387 
388 typedef enum
389 {
390     E_DSCMB_KL_SEL_DEFAULT = 0, //Backward compatible, actual default value is chosen in HAL driver
391     E_DSCMB_KL_SEL_CW      , //CWKL
392     E_DSCMB_KL_SEL_PVR     , //PVRKL
393 } DSCMB_KL_SelEng;
394 
395 /// Key ladder configurations
396 typedef enum
397 {
398     E_DSCMB_KL_LVL_0 = 0,
399     E_DSCMB_KL_LVL_1 ,
400     E_DSCMB_KL_LVL_2 ,
401     E_DSCMB_KL_LVL_3 ,
402     E_DSCMB_KL_LVL_9 = 9 ,
403     E_DSCMB_KL_LVL_D = 0xD ,
404 } DSCMB_KLType;
405 
406 typedef enum
407 {
408     E_DSCMB_KL_128_BITS   ,
409     E_DSCMB_KL_64_BITS  ,
410 } DSCMB_KL_OutputSize;
411 
412 /// Key ladder configurations
413 typedef struct
414 {
415     MS_BOOL         bDecrypt;
416     MS_BOOL         bInverse;
417     MS_BOOL         bKeepRound;
418     MS_U32          u32Round;
419     MS_U32          u32EngMode;
420     DSCMB_KLType         eKLType;
421     DSCMB_KL_OutputSize  eOutsize;
422 
423 } DSCMB_KLCfg;
424 
425 
426 ///New  Key ladder configurations for Keyladder run all.
427 typedef struct
428 {
429     DSCMB_KLEng          eAlgo;
430     DSCMB_KLSrc          eSrc;   // Select KL root key source //
431     DSCMB_KLDst          eDst;   // Select KL output Key destination //
432     DSCMB_KL_OutputSize  eOutsize;  // Select ouput Key size. ex: Key size of CSA and DES are E_DSCMB_KL_64_BITS//
433     DSCMB_Key_Type       eKeyType;
434     // Key ladder running level, support level 0 ~ 3 // [NOTE] Level 0 is only supported when destination is CryptoDMA
435     MS_U32               u32Level;
436     MS_U32               u32EngID;  // Select ESA/NSA as KL destination, Dscmb engine ID //
437     MS_U32               u32DscID;  // Select ESA/NSA as KL destination, Dscmb ID //
438     MS_U8                *u8KeyACPU;  // Select ACPU as KL root Key, KL root key //
439     // KL inputs, pointer of bytes array for each level input, every input contains 16 bytes //
440     // ex: MS_U8 input[48]: input[0-15] Level1 , input[16-31] Level2, input[32-47] Level3
441     MS_U8                *pu8KeyKLIn;
442     MS_BOOL              bDecrypt;
443     MS_BOOL              bInverse;
444 
445     // New data member
446     DSCMB_KL_SelEng      eKLSel;   //Select KeyLadder
447     MS_U32               u32CAVid; //Set CAVid
448 
449     //TODO: Add Key property
450 } DSCMB_KLCfg_All;
451 
452 
453 typedef enum
454 {
455     E_DSCMB_MAIN_ALGO_AES       ,
456     E_DSCMB_MAIN_ALGO_CSA2      ,
457     E_DSCMB_MAIN_ALGO_DES       ,
458     E_DSCMB_MAIN_ALGO_TDES      ,
459     E_DSCMB_MAIN_ALGO_MULTI2    ,
460     E_DSCMB_MAIN_ALGO_CSA2_CONF ,
461     E_DSCMB_MAIN_ALGO_CSA3      ,
462     E_DSCMB_MAIN_ALGO_DEFAULT = 0xF,
463     E_DSCMB_MAIN_ALGO_NUM,
464 } DSCMB_MainAlgo_Type;
465 
466 
467 typedef enum
468 {
469     E_DSCMB_SUB_ALGO_NONE = 0   ,
470     E_DSCMB_SUB_ALGO_MDI_CBC = 0,
471     E_DSCMB_SUB_ALGO_MDI_RCBC  ,
472     E_DSCMB_SUB_ALGO_MDD_CBC   ,
473     E_DSCMB_SUB_ALGO_MDD_RCBC  ,
474     E_DSCMB_SUB_ALGO_LEADING_CLEAR ,
475     E_DSCMB_SUB_ALGO_ECB ,
476     E_DSCMB_SUB_ALGO_CBC ,
477     E_DSCMB_SUB_ALGO_CTR ,
478     E_DSCMB_SUB_ALGO_OFB ,
479     E_DSCMB_SUB_ALGO_DEFAULT = 0xF,
480     E_DSCMB_SUB_ALGO_NUM,
481 } DSCMB_SubAlgo_Type;
482 
483 
484 typedef enum
485 {
486     E_DSCMB_RESSB_ALGO_NONE = 0,
487     E_DSCMB_RESSB_ALGO_CLR = 0,
488     E_DSCMB_RESSB_ALGO_CTS,
489     E_DSCMB_RESSB_ALGO_SCTE52,
490     E_DSCMB_RESSB_ALGO_XORIV1,
491     E_DSCMB_RESSB_ALGO_OC_M,
492     E_DSCMB_RESSB_ALGO_XORIV2,
493     E_DSCMB_RESSB_ALGO_DEFAULT = 0x7,
494     E_DSCMB_RESSB_ALGO_NUM,
495 } DSCMB_ResSBAlgo_Type;
496 
497 
498 typedef struct
499 {
500     DSCMB_MainAlgo_Type   eMainAlgo;
501     DSCMB_SubAlgo_Type    eSubAlgo;
502     DSCMB_ResSBAlgo_Type  eResAlgo;
503     DSCMB_ResSBAlgo_Type  eSBAlgo;
504     MS_BOOL               bDecrypt;
505 } DSCMB_Algo_Cfg;
506 
507 // Error Status for KL //s
508 #define DSCMB_KL_Status MS_U32
509 
510 #define    KL_STATUS_KEY_OK                            0x0000
511 #define    KL_STATUS_ACPU_KEY_NULL                     0x0001
512 #define    KL_STATUS_ACPU_OUTKEY_NULL                  0x0002
513 #define    KL_STATUS_INVALID_KEYROUND_PARAMETER        0x0004
514 #define    KL_STATUS_INVALID_INPUT_LEVEL               0x0008
515 #define    KL_STATUS_IVALID_DSCMB_ID                   0x0010
516 #define    KL_STATUS_WAIT_CW_READY_TIMEOUT             0x0020
517 #define    KL_STATUS_WAIT_KL_READY_TIMEOUT             0x0040
518 #define    KL_STATUS_KL_INPUT_NULL                     0x0080
519 
520 #define    KL_STATUS_BAD_KEY                           0x0100
521 #define    KL_STATUS_INVALID_FUNCTION                  0x0200
522 #define    KL_STATUS_MULTI_FUNCTION                    0x0400
523 #define    KL_STATUS_ZERO_ORDER                        0x0800
524 #define    KL_STATUS_INTERNAL_BAD_KEY                  0x1000
525 #define    KL_STATUS_INVALID_KL_SEL                    0x2000
526 
527 
528 
529 // Backward compatible
530 typedef DSCMB_KLSrc          DSCMB_KLadderSrc;
531 #define E_DSCMB_KLAD_SRC_ACPU               E_DSCMB_KL_SRC_ACPU
532 #define E_DSCMB_KLAD_SRC_SECRET_KEY1        E_DSCMB_KL_SRC_SECRET_1
533 #define E_DSCMB_KLAD_SRC_SECRET_KEY2        E_DSCMB_KL_SRC_SECRET_2
534 #define E_DSCMB_KLAD_SRC_SECRET_KEY3        E_DSCMB_KL_SRC_SECRET_3
535 #define E_DSCMB_KLAD_SRC_SECRET_KEY4        E_DSCMB_KL_SRC_SECRET_4
536 #define E_DSCMB_KLAD_SRC_VGK                E_DSCMB_KL_SRC_VGK
537 
538 typedef DSCMB_KLDst          DSCMB_KLadderDst;
539 #define E_DSCMB_KLAD_DST_KTAB_ESA           E_DSCMB_KL_DST_KT_ESA
540 #define E_DSCMB_KLAD_DST_KTAB_NSA =         E_DSCMB_KL_DST_KT_NSA
541 #define E_DSCMB_KLAD_DST_AESDMA_AES =       E_DSCMB_KL_DST_DMA_AES
542 #define E_DSCMB_KLAD_DST_AESDMA_TDES =      E_DSCMB_KL_DST_DMA_TDES
543 #define E_DSCMB_KLAD_DST_ACPU =             E_DSCMB_KL_DST_ACPU
544 
545 typedef DSCMB_KLCfg          DSCMB_KLadderConfig;
546 
547 
548 typedef enum
549 {
550     DSCMB_FSCB_UNCHG = 0,
551     DSCMB_FSCB_CLEAR,
552     DSCMB_FSCB_EVEN,
553     DSCMB_FSCB_ODD,
554 } DSCMB_FSCB;
555 
556 // wrapper function
557 #define MDrv_DSCMB_FltAlloc(void)   \
558     MDrv_DSCMB2_FltAlloc(0)
559 #define MDrv_DSCMB_FltAlloc_Ex(eFltType)   \
560     MDrv_DSCMB2_FltAlloc_Ex(0, eFltType)
561 #define MDrv_DSCMB_FltFree(u32DscmbId)   \
562     MDrv_DSCMB2_FltFree(0, u32DscmbId)
563 #define MDrv_DSCMB_FltConnectPid(u32DscmbId, u32Pid)  \
564     MDrv_DSCMB2_FltConnectPid(0, u32DscmbId, u32Pid)
565 #define MDrv_DSCMB_FltDisconnectPid(u32DscmbId, u32Pid) \
566     MDrv_DSCMB2_FltDisconnectPid(0, u32DscmbId, u32Pid)
567 #define MDrv_DSCMB_FltConnectFltId(u32DscmbId, u32FltId)    \
568     MDrv_DSCMB2_FltConnectFltId(0, u32DscmbId, u32FltId)
569 #define MDrv_DSCMB_FltDisconnectPid_Ex(u32DscmbId, u32Pid) \
570     MDrv_DSCMB2_FltDisconnectPid_Ex(0, u32DscmbId, u32Pid)
571 #define MDrv_DSCMB_FltDisconnectFltId(u32DscmbId, u32FltId)    \
572     MDrv_DSCMB2_FltDisconnectFltId(0, u32DscmbId, u32FltId)
573 #define MDrv_DSCMB_FltDscmb(u32DscmbId, bDscmb) \
574     MDrv_DSCMB2_FltDscmb(0, u32DscmbId, bDscmb)
575 #define MDrv_DSCMB_FltTypeSet(u32DscmbId, eType)    \
576     MDrv_DSCMB2_FltTypeSet(0, u32DscmbId, eType)
577 #define MDrv_DSCMB_Multi2_SetRound(u32Round)    \
578     MDrv_DSCMB2_Multi2_SetRound(0, u32Round)
579 #define MDrv_DSCMB_Multi2_SetSystemKey(u8Syskey)    \
580     MDrv_DSCMB2_Multi2_SetSystemKey(0, u8Syskey)
581 #define MDrv_DSCMB_FltKeySet(u32DscmbId, eKeyType, pu8Key)  \
582     MDrv_DSCMB2_FltKeySet(0, u32DscmbId, eKeyType, pu8Key)
583 #define MDrv_DSCMB_FltKeyReset(u32DscmbId, eKeyType)    \
584     MDrv_DSCMB2_FltKeyReset(0, u32DscmbId, eKeyType)
585 #define MDrv_DSCMB_FltIVSet(u32DscmbId, eKeyType, pu8IV)    \
586     MDrv_DSCMB2_FltIVSet(0, u32DscmbId, eKeyType, pu8IV)
587 #define MDrv_DSCMB_PidFlt_ScmbStatus(u32PidFltId, pScmbLevel)    \
588     MDrv_DSCMB2_PidFlt_ScmbStatus(0, u32PidFltId, pScmbLevel)
589 #define MDrv_DSCMB_FltKeyReset(u32DscmbId, eKeyType)    \
590     MDrv_DSCMB2_FltKeyReset(0, u32DscmbId, eKeyType)
591 
592 //-------------------------------------------------------------------------------------------------
593 //  Functions
594 //-------------------------------------------------------------------------------------------------
595 
596 // descrambler initial function
597 //-----------------
598 // DSCMB_General
599 //-----------------
600 //-------------------------------------------------------------------------------------------------
601 /// Initialize DSCMB module
602 /// @ingroup DSCMB_General
603 /// @return TRUE  : Succeed
604 /// @return FALSE : Fail
605 //-------------------------------------------------------------------------------------------------
606 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_Init(void);
607 
608 //-------------------------------------------------------------------------------------------------
609 /// Finalize DSCMB module
610 /// @ingroup DSCMB_General
611 /// @return TRUE  : Succeed
612 /// @return FALSE : Fail
613 //-------------------------------------------------------------------------------------------------
614 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_Exit(void);
615 //-----------------
616 // DSCMB_STB
617 //-----------------
618 //-------------------------------------------------------------------------------------------------
619 /// Set DSCMB CA VID
620 /// @ingroup DSCMB_STB_General
621 /// @param  u32EngId   \b IN: DSCMB engine id.
622 /// @param  u32CAVid  \b IN: CA VID.
623 /// @return TRUE  : Succeed
624 /// @return FALSE : Fail
625 //-------------------------------------------------------------------------------------------------
626 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_SetDefaultCAVid(MS_U32 u32EngId, MS_U32 u32CAVid);
627 
628 //-----------------
629 // DSCMB_ToBeModified: Slot_Ctrl
630 //-----------------
631 //-------------------------------------------------------------------------------------------------
632 /// Allocate a dscrambler filter (Slot). (Update to support share key case)
633 /// @ingroup DSCMB_ToBeModified_Slot_Ctrl
634 /// @return TRUE  : Succeed - Descrambler filter slot
635 /// @return FALSE : Fail - DRV_DSCMB_FLT_NULL
636 //-------------------------------------------------------------------------------------------------
637 DLL_PUBLIC MS_U32  MDrv_DSCMB2_FltAlloc(MS_U32 u32EngId);
638 
639 //-------------------------------------------------------------------------------------------------
640 /// Allocate a dscrambler filter (Slot). (Only this function can allocate share key slot).
641 /// (Just keep MDrv_DSCMB2_FltAlloc and refine it)
642 /// @ingroup DSCMB_ToBeRemove
643 /// @param u32EngId  \b IN: DSCMB engine id.
644 /// @param eFltType    \b IN: Type for descramber filter.
645 /// @return TRUE  : Succeed - Descrambler filter slot.
646 /// @return FALSE : Fail - DRV_DSCMB_FLT_NULL
647 //-------------------------------------------------------------------------------------------------
648 DLL_PUBLIC MS_U32  MDrv_DSCMB2_FltAlloc_Ex(MS_U32 u32EngId, DSCMB_Flt_Type eFltType);
649 //-----------------
650 // DSCMB_Slot_Control
651 //-----------------
652 //-------------------------------------------------------------------------------------------------
653 /// Free a dscrambler slot.
654 /// @ingroup DSCMB_Slot_Control
655 /// @param u32EngId        \b IN: DSCMB engine id.
656 /// @param u32DscmbId    \b IN: DSCMB slot.
657 /// @return TRUE  : Succeed
658 /// @return FALSE : Fail
659 //-------------------------------------------------------------------------------------------------
660 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltFree(MS_U32 u32EngId, MS_U32 u32DscmbId);
661 
662 //-------------------------------------------------------------------------------------------------
663 /// Connect DSCMB slot with DMX PID filter by filter index for Enc/Dec used.
664 /// @ingroup DSCMB_Slot_Control
665 /// @param u32EngId        \b IN: DSCMB engine id.
666 /// @param u32DscmbId    \b IN: DSCMB slot.
667 /// @param u32FltId          \b IN: DMX PID filter index.
668 /// @return TRUE  : Succeed
669 /// @return FALSE : Fail
670 //-------------------------------------------------------------------------------------------------
671 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltConnectFltId(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32FltId);
672 //-------------------------------------------------------------------------------------------------
673 /// Dis-connect DSCMB slot with DMX PID filter by filter index.
674 /// @ingroup DSCMB_Slot_Control
675 /// @param u32EngId        \b IN: DSCMB engine id.
676 /// @param u32DscmbId    \b IN: DSCMB slot.
677 /// @param u32FltId          \b IN: DMX PID filter index.
678 /// @return TRUE  : Succeed
679 /// @return FALSE : Fail
680 //-------------------------------------------------------------------------------------------------
681 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltDisconnectFltId(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32FltId);
682 
683 // descrambler filter maps to TSP pid
684 #ifndef MSOS_TYPE_NUTTX
685 //-------------------------------------------------------------------------------------------------
686 /// Connect DSCMB slot with DMX PID filter by PID for Enc/Dec used.
687 /// @ingroup DSCMB_Slot_Control
688 /// @param u32EngId        \b IN: DSCMB engine id.
689 /// @param u32DscmbId    \b IN: DSCMB slot.
690 /// @param u32Pid            \b IN: PID.
691 /// @return TRUE  : Succeed
692 /// @return FALSE : Fail
693 //-------------------------------------------------------------------------------------------------
694 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltConnectPid(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32Pid);
695 //-------------------------------------------------------------------------------------------------
696 /// Dis-connect DSCMB slot with DMX PID filter by PID. (Refine for multi dis-connect case)
697 /// @ingroup DSCMB_ToBeModified_Slot_Ctrl
698 /// @param u32EngId        \b IN: DSCMB engine id.
699 /// @param u32DscmbId    \b IN: DSCMB slot.
700 /// @param u32Pid            \b IN: PID.
701 /// @return TRUE  : Succeed
702 /// @return FALSE : Fail
703 //-------------------------------------------------------------------------------------------------
704 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltDisconnectPid(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32Pid);
705 //-------------------------------------------------------------------------------------------------
706 /// Dis-connect DSCMB slot with DMX PID filter by PID. (It will check this PID exist on DMX side or not)
707 /// @ingroup DSCMB_STB_General
708 /// @param u32EngId        \b IN: DSCMB engine id.
709 /// @param u32DscmbId    \b IN: DSCMB slot.
710 /// @param u32Pid            \b IN: PID.
711 /// @return TRUE  : Succeed
712 /// @return FALSE : Fail
713 //-------------------------------------------------------------------------------------------------
714 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltDisconnectPid_Ex(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32Pid);
715 #endif
716 
717 //--------------------------------------------------------------------------------------------------
718 /// Set descrambler filter as scrambling/decrambling mode
719 /// @ingroup DSCMB_STB_General
720 /// @param u32EngId        \b IN: DSCMB engine id.
721 /// @param u32DscmbId    \b IN: DSCMB slot.
722 /// @param eEngType        \b IN: DSCMB engine type.
723 /// @param stConfig          \b IN: DSCMB algo.
724 /// @return TRUE - Success
725 /// @return FALSE - Failure
726 //--------------------------------------------------------------------------------------------------
727 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetAlgo(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Algo_Cfg stConfig);
728 
729 //--------------------------------------------------------------------------------------------------
730 /// Set descrambler key
731 /// @ingroup DSCMB_STB_General
732 /// @param u32EngId        \b IN: DSCMB engine id.
733 /// @param u32DscmbId   \b IN: DSCMB slot.
734 /// @param eEngType       \b IN: DSCMB engine type.
735 /// @param eKeyType       \b IN: Descrambler key type
736 /// @param pu8Key          \b IN: pointer to the key (Array)
737 /// @return TRUE - Success
738 /// @return FALSE - Failure
739 //--------------------------------------------------------------------------------------------------
740 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetKey(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Key_Type eKeyType, MS_U8* pu8Key);
741 
742 //--------------------------------------------------------------------------------------------------
743 /// Reset descrambler key
744 /// @ingroup DSCMB_STB_General
745 /// @param u32EngId        \b IN: DSCMB engine id.
746 /// @param u32DscmbId   \b IN: DSCMB slot.
747 /// @param eEngType       \b IN: DSCMB engine type.
748 /// @param eKeyType      \b IN: Descrambler key type
749 /// @return TRUE - Success
750 /// @return FALSE - Failure
751 //--------------------------------------------------------------------------------------------------
752 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngResetKey(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Key_Type eKeyType);
753 
754 //--------------------------------------------------------------------------------------------------
755 /// Set descrambler IV key
756 /// @ingroup DSCMB_STB_General
757 /// @param u32EngId       \b IN: DSCMB engine id
758 /// @param u32DscmbId   \b IN: DSCMB slot.
759 /// @param eKeyType      \b IN: Descrambler key type
760 /// @param pu8IV            \b IN: pointer to the key. (Instruction Vector)
761 /// @return TRUE - Success
762 /// @return FALSE - Failure
763 //--------------------------------------------------------------------------------------------------
764 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetIV(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType, MS_U8* pu8IV);
765 
766 //--------------------------------------------------------------------------------------------------
767 /// Switch descrambler engine type
768 /// @ingroup DSCMB_STB_General
769 /// @param u32EngId       \b IN: DSCMB engine id
770 /// @param u32DscmbId   \b IN: DSCMB slot.
771 /// @param eUppSwitch    \b IN: Up: Engine type.
772 /// @param eLowSwitch    \b IN: Low: Engine type.
773 /// @return TRUE - Success
774 /// @return FALSE - Failure
775 //--------------------------------------------------------------------------------------------------
776 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetSwitch(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eUppSwitch, DSCMB_Eng_Type eLowSwitch);
777 
778 //--------------------------------------------------------------------------------------------------
779 /// Set descrambler engine FSCB
780 /// @ingroup DSCMB_STB_General
781 /// @param u32EngId       \b IN: DSCMB engine id
782 /// @param u32DscmbId   \b IN: DSCMB slot.
783 /// @param eForceSCB     \b IN: FSCB type.
784 /// @return TRUE - Success
785 /// @return FALSE - Failure
786 //--------------------------------------------------------------------------------------------------
787 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetFSCB(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_FSCB eForceSCB );
788 
789 
790 
791 //--------------------------------------------------------------------------------------------------
792 /// Set descrambler filter as scrambling/decrambling mode.
793 /// Default filter mode is descrambling if this function is not specified.
794 /// This function should be invoked before MDrv_DSCMB_FltTypeSet.
795 /// @ingroup DSCMB_STB_General
796 /// @param u32DscmbId \b IN: Descrambler filter ID obtained from MDrv_DSCMB_FltAlloc
797 /// @param DscmbType \b IN: The descrambler algorithm
798 /// @return TRUE - Success
799 /// @return FALSE - Failure
800 //--------------------------------------------------------------------------------------------------
801 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltDscmb(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_BOOL bDscmb);
802 //-----------------
803 // DSCMB_Key
804 //-----------------
805 //--------------------------------------------------------------------------------------------------
806 /// Set descrambler algorithm by common predefined descramble type.
807 /// @ingroup DSCMB_Key
808 /// @param u32EngId       \b IN: DSCMB engine id
809 /// @param u32DscmbId   \b IN: DSCMB slot.
810 /// @param DscmbType    \b IN: The descrambler algorithm
811 /// @return TRUE  - Success
812 /// @return FALSE - Failure
813 //--------------------------------------------------------------------------------------------------
814 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltTypeSet(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Type DscmbType);
815 //--------------------------------------------------------------------------------------------------
816 /// Set descrambler key of the Dscmb ID
817 /// @ingroup DSCMB_Key
818 /// @param u32EngId       \b IN: DSCMB engine id
819 /// @param u32DscmbId   \b IN: DSCMB slot.
820 /// @param eKeyType      \b IN: Descrambler key type
821 /// @param pu8Key         \b IN: pointer to the key (Array)
822 /// @return TRUE - Success
823 /// @return FALSE - Failure
824 //--------------------------------------------------------------------------------------------------
825 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltKeySet(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType, MS_U8* pu8Key);
826 //--------------------------------------------------------------------------------------------------
827 /// Reset descrambler key of the Dscmb ID. (It will set key to 0)
828 /// @ingroup DSCMB_Key
829 /// @param u32EngId       \b IN: DSCMB engine id
830 /// @param u32DscmbId   \b IN: DSCMB slot.
831 /// @param eKeyType      \b IN: Descrambler key type
832 /// @return TRUE - Success
833 /// @return FALSE - Failure
834 //--------------------------------------------------------------------------------------------------
835 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltKeyReset(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType);
836 
837 //--------------------------------------------------------------------------------------------------
838 /// Set descrambler initial vector of the Dscmb ID
839 /// @ingroup DSCMB_Key
840 /// @param u32EngId       \b IN: DSCMB engine id
841 /// @param u32DscmbId   \b IN: DSCMB slot.
842 /// @param eKeyType      \b IN: Descrambler key type
843 /// @param pu8IV            \b IN: pointer to the key. (Instruction Vector)
844 /// @return TRUE - Success
845 /// @return FALSE - Failure
846 //--------------------------------------------------------------------------------------------------
847 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltIVSet(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType, MS_U8* pu8IV);
848 
849 //--------------------------------------------------------------------------------------------------
850 /// Query dscrambler capability information
851 /// @ingroup DSCMB_General
852 /// @param u32EngId      \b IN: DSCMB engine id.
853 /// @param eQueryType  \b IN: type for query
854 /// @param pInput          \b IN: intput parameter
855 /// @param pOutput        \b OUT: result for the query type
856 /// @return TRUE - Success
857 /// @return FALSE - Failure
858 //--------------------------------------------------------------------------------------------------
859 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_GetCap(MS_U32 u32EngId, DSCMB_Query_Type eQueryType, void* pInput, void* pOutput);
860 //--------------------------------------------------------------------------------------------------
861 /// Get DSCMB driver library information
862 /// @ingroup DSCMB_General
863 /// @param ppVersion \b OUT: Descrambler library version infomation
864 /// @return TRUE - Success
865 /// @return FALSE - Failure
866 //--------------------------------------------------------------------------------------------------
867 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_GetLibVer(const MSIF_Version **ppVersion);
868 //-------------------------------------------------------------------------------------------------
869 /// Set DSCMB Debug Level.
870 /// @ingroup DSCMB_General
871 /// @param  u32Level  \b IN: debug level.
872 /// @return TRUE  : Succeed
873 /// @return FALSE : Fail
874 //-------------------------------------------------------------------------------------------------
875 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_SetDBGLevel(MS_U32 u32Level);
876 //--------------------------------------------------------------------------------------------------
877 /// Check the status between DSCMB slot and DMX PID filter.
878 /// @ingroup DSCMB_STB_General
879 /// @param  u32EngId      \b IN: DSCMB engine id.
880 /// @param u32DscmbId   \b IN: descramble id
881 /// @param u32TspFltId    \b IN: tsp filter id
882 /// @return TRUE  - Success (connect)
883 /// @return FALSE - Failure (not connect)
884 //--------------------------------------------------------------------------------------------------
885 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_GetConnectStatus(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32TspFltId);
886 
887 
888 //--------------------------------------------------------------------------------------------------
889 /// Set rounds of descrambler algorithm MULTI2
890 /// @ingroup DSCMB_Key
891 /// @param u32EngId     \b IN: DSCMB engine id
892 /// @param u32Round    \b IN: # rounds to apply, multiple of 4 and maximum value is 252
893 /// @return TRUE  - Success
894 /// @return FALSE - Failure
895 //--------------------------------------------------------------------------------------------------
896 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_Multi2_SetRound(MS_U32 u32EngId, MS_U32 u32Round);
897 //--------------------------------------------------------------------------------------------------
898 /// Set system key of descrambler algorithm MULTI2
899 /// @ingroup DSCMB_Key
900 /// @param u32EngId     \b IN: DSCMB engine id
901 /// @param u32SysKey  \b IN: the array of system key (u8SysKey[32]): there are 32 group system key(8-bit should be 32 group) should be set.
902 /// @[0-31][32-63][64-95][96-127][128-159][160-191][192-223][224-255] and the bit order is MSB.
903 /// @return TRUE  - Success
904 /// @return FALSE - Failure
905 //--------------------------------------------------------------------------------------------------
906 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_Multi2_SetSystemKey(MS_U32 u32EngId, MS_U8* u8Syskey);
907 //--------------------------------------------------------------------------------------------------
908 /// Set Riv of HDCP2, which is 64-bits number generated from transmitter
909 /// @ingroup DSCMB_Key
910 /// @param u32EngId   \b IN: DSCMB engine id
911 /// @param pu8RIV      \b IN: pointer to 64bit Riv buffer in BIG ENDIAN order
912 /// @return TRUE  - Success
913 /// @return FALSE - Failure
914 //--------------------------------------------------------------------------------------------------
915 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_HDCP2_SetRIV(MS_U32 u32EngId, MS_U8* pu8RIV);
916 //--------------------------------------------------------------------------------------------------
917 /// Set Riv of HDCP2, which is 64-bits number generated from transmitter
918 /// @ingroup DSCMB_Key
919 /// @param u32EngId   \b IN: DSCMB engine id
920 /// @param u32EngId   \b IN: DSCMB slot
921 /// @param pu8RIV      \b IN: pointer to 64bit Riv buffer in BIG ENDIAN order
922 /// @return TRUE  - Success
923 /// @return FALSE - Failure
924 //--------------------------------------------------------------------------------------------------
925 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_HDCP2_SetRIV_Ex(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U8* pu8RIV);
926 //--------------------------------------------------------------------------------------------------
927 /// Enable Record stream after stream is descrambled, only supported when CA venders do not prohibat this feature.
928 /// @ingroup DSCMB_STB_General
929 /// @param u32EngId  \b IN: DSCMB engine id
930 /// @param Enable      \b IN: for enabe/disable record mechanism.
931 /// @return TRUE  - Success
932 /// @return FALSE - Failure
933 /// @Note: Function can only be called before any record function is called.
934 //--------------------------------------------------------------------------------------------------
935 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_PVR_RecCtrl(MS_U32 u32EngId, MS_BOOL Enable);
936 //-----------------
937 // DSCMB_STR
938 //-----------------
939 //-------------------------------------------------------------------------------------------------
940 /// Control DSCMB STR functions.
941 /// @ingroup DSCMB_STR
942 /// @param  u16PowerState  \b IN: STR power mode. (to control STR suspend & resume case.)
943 /// @return : Utopia status - UTOPIA_STATUS_SUCCESS (Succeed) or UTOPIA_STATUS_FAIL (Fail)
944 //-------------------------------------------------------------------------------------------------
945 // DLL_PUBLIC MS_U32  MDrv_DSCMB2_SetPowerState(EN_POWER_MODE u16PowerState);
946 
947 //--------------------------------------------------------------------------------------------------
948 /// Get scrambler level of a pid filter ID
949 /// @ingroup DSCMB_General
950 /// @param u32EngId      \b IN: DSCMB engine id.
951 /// @param u32PidFltId    \b IN: Pid filter ID obtained from MApi_DMX_Open/MDrv_TSP_PidFlt_Alloc
952 /// @param pScmbLevel   \b OUT: The output scrambler level
953 /// @return TRUE - Success
954 /// @return FALSE - Failure
955 //--------------------------------------------------------------------------------------------------
956 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_PidFlt_ScmbStatus(MS_U32 u32EngId, MS_U32 u32PidFltId, SCMB_Level* pScmbLevel);
957 
958 //--------------------------------------------------------------------------------------------------
959 /// Get Dscmb driver status (There is no any code use this parameter)
960 /// @ingroup DSCMB_ToBeRemove
961 /// @param pStatus   \b OUT: Descrambler status
962 /// @return TRUE - Success
963 /// @return FALSE - Failure
964 //--------------------------------------------------------------------------------------------------
965 // DLL_PUBLIC MS_BOOL MDrv_DSCMB_GetStatus(DSCMB_Status *pStatus);
966 //--------------------------------------------------------------------------------------------------
967 /// Get Dscmb driver information
968 /// @ingroup DSCMB_General
969 /// @return DSCMB_Info
970 //--------------------------------------------------------------------------------------------------
971 // DLL_PUBLIC const DSCMB_Info* MDrv_DSCMB_GetInfo(void);
972 
973 
974 //-----------------
975 // DSCMB_STB_Kladder
976 //-----------------
977 //--------------------------------------------------------------------------------------------------
978 /// KLadder_ETSI
979 /// @ingroup DSCMB_STB_Kladder
980 /// @return TRUE  - Success
981 /// @return FALSE - Failure
982 //--------------------------------------------------------------------------------------------------
983 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_KLadder_ETSI(DSCMB_KLCfg_All* KLCfg , MS_U8 *ACPU_Out, MS_U8 *pu8Nonce, MS_U8 * pu8Response, DSCMB_KL_Status* u32Status );
984 //--------------------------------------------------------------------------------------------------
985 /// KLadder_AtomicExec
986 /// @ingroup DSCMB_STB_Kladder
987 /// @return TRUE  - Success
988 /// @return FALSE - Failure
989 //--------------------------------------------------------------------------------------------------
990 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_KLadder_AtomicExec(DSCMB_KLCfg_All* KLCfg , MS_U8 *ACPU_Out, DSCMB_KL_Status* u32Status );
991 
992 
993 //-----------------
994 // DSCMB_ToBeRemove
995 //-----------------
996 //-------------------------------------------------------------------------------------------------
997 /// Initialize DSCMB module. (Already have another function: DSCMB2_Init)
998 /// @ingroup DSCMB_ToBeRemove
999 /// @return TRUE  : Succeed
1000 /// @return FALSE : Fail
1001 //-------------------------------------------------------------------------------------------------
1002 DLL_PUBLIC MS_BOOL MDrv_DSCMB_Init(void);
1003 //-------------------------------------------------------------------------------------------------
1004 /// Finalize DSCMB module. (Already have another function: DSCMB2_Exit)
1005 /// @ingroup DSCMB_ToBeRemove
1006 /// @return TRUE  : Succeed
1007 /// @return FALSE : Fail
1008 //-------------------------------------------------------------------------------------------------
1009 DLL_PUBLIC MS_BOOL MDrv_DSCMB_Exit(void);
1010 //--------------------------------------------------------------------------------------------------
1011 /// Get Dscmb driver library information. (Already have another function: DSCMB2_GetLibVer)
1012 /// @ingroup DSCMB_ToBeRemove
1013 /// @param ppVersion \b OUT: Descrambler library version infomation
1014 /// @return TRUE - Success
1015 /// @return FALSE - Failure
1016 //--------------------------------------------------------------------------------------------------
1017 // DLL_PUBLIC MS_BOOL MDrv_DSCMB_GetLibVer(const MSIF_Version **ppVersion);
1018 //-------------------------------------------------------------------------------------------------
1019 /// Set DSCMB Debug Level. (Already have another function: DSCMB2_SetDBGLevel)
1020 /// @ingroup DSCMB_ToBeRemove
1021 /// @param  u32Level  \b IN: debug level.
1022 /// @return TRUE  : Succeed
1023 /// @return FALSE : Fail
1024 //-------------------------------------------------------------------------------------------------
1025 // DLL_PUBLIC MS_BOOL MDrv_DSCMB_SetDBGLevel(MS_U32 u32Level);
1026 
1027 //--------------------------------------------------------------------------------------------------
1028 /// Check the status between DSCMB slot and DMX PID filter.
1029 /// @ingroup DSCMB_STB_General
1030 /// @param  u32EngId      \b IN: DSCMB engine id.
1031 /// @param u32DscmbId   \b IN: descramble id
1032 /// @param u32TspFltId    \b IN: tsp filter id
1033 /// @return TRUE  - Success (connect)
1034 /// @return FALSE - Failure (not connect)
1035 //--------------------------------------------------------------------------------------------------
1036 // DLL_PUBLIC MS_BOOL MDrv_DSCMB_GetConnectStatus(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32TspFltId);
1037 //--------------------------------------------------------------------------------------------------
1038 /// KLadder_AtomicExec
1039 /// @ingroup DSCMB_STB_Kladder
1040 /// @return TRUE  - Success
1041 /// @return FALSE - Failure
1042 //--------------------------------------------------------------------------------------------------
1043 // DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_AtomicExec(DSCMB_KLCfg_All* KLCfg , MS_U8 *ACPU_Out, DSCMB_KL_Status* u32Status);
1044 //--------------------------------------------------------------------------------------------------
1045 /// KLadder_Reset
1046 /// @ingroup DSCMB_STB_Kladder
1047 /// @return TRUE  - Success
1048 /// @return FALSE - Failure
1049 //--------------------------------------------------------------------------------------------------
1050 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Reset(void);
1051 //--------------------------------------------------------------------------------------------------
1052 /// KLadder_SetInput
1053 /// @ingroup DSCMB_STB_Kladder
1054 /// @return TRUE  - Success
1055 /// @return FALSE - Failure
1056 //--------------------------------------------------------------------------------------------------
1057 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_SetInput(MS_U32 u32Level, MS_U8* pu8In, MS_U32 u32InLen);
1058 //--------------------------------------------------------------------------------------------------
1059 /// KLadder_SetKey
1060 /// @ingroup DSCMB_STB_Kladder
1061 /// @return TRUE  - Success
1062 /// @return FALSE - Failure
1063 //--------------------------------------------------------------------------------------------------
1064 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_SetKey(DSCMB_KLSrc KLSrc, MS_U8* pu8Key, MS_U32 u32KeyLen);
1065 //--------------------------------------------------------------------------------------------------
1066 /// KLadder_SetDst
1067 /// @ingroup DSCMB_STB_Kladder
1068 /// @return TRUE  - Success
1069 /// @return FALSE - Failure
1070 //--------------------------------------------------------------------------------------------------
1071 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_SetDst(DSCMB_KLDst KLDst);
1072 
1073 //--------------------------------------------------------------------------------------------------
1074 /// KLadder_SetConfig
1075 /// @ingroup DSCMB_STB_Kladder
1076 /// @return TRUE  - Success
1077 /// @return FALSE - Failure
1078 //--------------------------------------------------------------------------------------------------
1079 DLL_PUBLIC void    MDrv_DSCMB_KLadder_SetConfig(DSCMB_KLCfg *KLCfg);
1080 
1081 //--------------------------------------------------------------------------------------------------
1082 /// KLadder_Start
1083 /// @ingroup DSCMB_STB_Kladder
1084 /// @return TRUE  - Success
1085 /// @return FALSE - Failure
1086 //--------------------------------------------------------------------------------------------------
1087 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Start(void);
1088 
1089 //--------------------------------------------------------------------------------------------------
1090 /// KLadder_IsComplete
1091 /// @ingroup DSCMB_STB_Kladder
1092 /// @return TRUE  - Success
1093 /// @return FALSE - Failure
1094 //--------------------------------------------------------------------------------------------------
1095 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_IsComplete(void);
1096 
1097 //--------------------------------------------------------------------------------------------------
1098 /// KLadder_Output_Start
1099 /// @ingroup DSCMB_STB_Kladder
1100 /// @return TRUE  - Success
1101 /// @return FALSE - Failure
1102 //--------------------------------------------------------------------------------------------------
1103 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Output_Start(MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType);
1104 
1105 //--------------------------------------------------------------------------------------------------
1106 /// KLadder_Output_IsComplete
1107 /// @ingroup DSCMB_STB_Kladder
1108 /// @return TRUE  - Success
1109 /// @return FALSE - Failure
1110 //--------------------------------------------------------------------------------------------------
1111 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Output_IsComplete(void);
1112 
1113 //--------------------------------------------------------------------------------------------------
1114 /// KLadder_Output_Stop
1115 /// @ingroup DSCMB_STB_Kladder
1116 /// @return TRUE  - Success
1117 /// @return FALSE - Failure
1118 //--------------------------------------------------------------------------------------------------
1119 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Output_Stop(void);
1120 
1121 //--------------------------------------------------------------------------------------------------
1122 /// KLadder_ResetAcpuAck
1123 /// @ingroup DSCMB_STB_Kladder
1124 /// @return TRUE  - Success
1125 /// @return FALSE - Failure
1126 //--------------------------------------------------------------------------------------------------
1127 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_ResetAcpuAck(void);
1128 
1129 //--------------------------------------------------------------------------------------------------
1130 /// KLadder_ReadDataFromAcpu
1131 /// @ingroup DSCMB_STB_Kladder
1132 /// @return TRUE  - Success
1133 /// @return FALSE - Failure
1134 //--------------------------------------------------------------------------------------------------
1135 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_ReadDataFromAcpu(MS_U8* pu8Out);
1136 
1137 //--------------------------------------------------------------------------------------------------
1138 /// KLadder_Stop
1139 /// @ingroup DSCMB_STB_Kladder
1140 /// @return TRUE  - Success
1141 /// @return FALSE - Failure
1142 //--------------------------------------------------------------------------------------------------
1143 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Stop(void); // write KTE
1144 
1145 //--------------------------------------------------------------------------------------------------
1146 /// KLadder_Lock
1147 /// @ingroup DSCMB_STB_Kladder
1148 /// @return TRUE  - Success
1149 /// @return FALSE - Failure
1150 //--------------------------------------------------------------------------------------------------
1151 // DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Lock(void);
1152 
1153 //--------------------------------------------------------------------------------------------------
1154 /// KLadder_Unlock
1155 /// @ingroup DSCMB_STB_Kladder
1156 /// @return TRUE  - Success
1157 /// @return FALSE - Failure
1158 //--------------------------------------------------------------------------------------------------
1159 // DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Unlock(void);
1160 //--------------------------------------------------------------------------------------------------
1161 /// Set the PID to be replaced
1162 /// @ingroup DSCMB_STB_General
1163 /// @param u32PidPrim     \b IN: The packet with this target PID(u32PidPrim) will be replaced in the field of PID by u32Pid2ndary
1164 /// @param u32Pid2ndary  \b IN: The packet with this target PID(u32PidPrim) will be replaced in the field of PID by u32Pid2ndary
1165 /// @return TRUE  - Success
1166 /// @return FALSE - Failure
1167 //--------------------------------------------------------------------------------------------------
1168 // DLL_PUBLIC MS_BOOL MDrv_DSCMB_2ndarySet(MS_U32 u32PidPrim, MS_U32 u32Pid2ndary);
1169 //--------------------------------------------------------------------------------------------------
1170 /// Reset the PID to be replaced
1171 /// @ingroup DSCMB_STB_General
1172 /// @param u32PidPrim\b   IN: Reset the replacement of PID (u32PidPrim) set by MDrv_DSCMB_2ndarySet
1173 /// @return TRUE  - Success
1174 /// @return FALSE - Failure
1175 //--------------------------------------------------------------------------------------------------
1176 // DLL_PUBLIC MS_BOOL MDrv_DSCMB_2ndaryReset(MS_U32 u32PidPrim);
1177 //--------------------------------------------------------------------------------------------------
1178 /// The low-level implementation of @ref MDrv_DSCMB_FltTypeSet [RESERVED]
1179 /// @ingroup DSCMB_STB_General
1180 /// @param u32DscmbId \b IN: descrambler filter ID obtained from MDrv_DSCMB_FltAlloc
1181 /// @param eKeyType \b IN: key type for this setting
1182 /// @param u32SW0 \b IN: The descramlber switch configuration
1183 /// @param u32SW1 \b IN: reserved
1184 /// @param u32SW2 \b IN: reserved
1185 /// @return TRUE  - Success
1186 /// @return FALSE - Failure
1187 //--------------------------------------------------------------------------------------------------
1188 // DLL_PUBLIC MS_BOOL MDrv_DSCMB_SlotSwitchWrite(MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType, MS_U32 u32SW0, MS_U32 u32SW1, MS_U32 u32SW2);
1189 
1190 //--------------------------------------------------------------------------------------------------
1191 /// Set record buffer
1192 /// @ingroup DSCMB_STB_General
1193 /// @return TRUE - Success
1194 /// @return FALSE - Failure
1195 //--------------------------------------------------------------------------------------------------
1196 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_SetRecBuf(MS_U32 u32EngId , MS_U32 u32Start, MS_U32 u32Size);
1197 
1198 //--------------------------------------------------------------------------------------------------
1199 /// Record control
1200 /// @ingroup DSCMB_STB_General
1201 /// @return TRUE - Success
1202 /// @return FALSE - Failure
1203 //--------------------------------------------------------------------------------------------------
1204 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_RecCtrl(MS_U32 u32EngId, MS_BOOL bEnable);
1205 
1206 //--------------------------------------------------------------------------------------------------
1207 /// Get record write pointer
1208 /// @ingroup DSCMB_STB_General
1209 /// @return TRUE - Success
1210 /// @return FALSE - Failure
1211 //--------------------------------------------------------------------------------------------------
1212 // DLL_PUBLIC MS_BOOL MDrv_DSCMB2_GetRecWptr(MS_U32 u32EngId, MS_U32* pu32Write);
1213 
1214 //-------------------------------------------------------------------------------------------------
1215 /// Control DSCMB STR functions. (Already have another function: DSCMB2_SetPowerState)
1216 /// @ingroup DSCMB_ToBeRemove
1217 /// @param  u16PowerState  \b IN: STR power mode. (to control STR suspend & resume case.)
1218 /// @return : Utopia status - UTOPIA_STATUS_SUCCESS (Succeed) or UTOPIA_STATUS_FAIL (Fail)
1219 //-------------------------------------------------------------------------------------------------
1220 DLL_PUBLIC MS_U32  MApi_DSCMB_SetPowerState(EN_POWER_MODE u16PowerState);
1221 
1222 
1223 #ifdef __cplusplus
1224 }
1225 #endif
1226 
1227 #endif
1228