xref: /utopia/UTPA2-700.0.x/mxlib/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 DLL_PACKED
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 DLL_PACKED
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     E_DSCMB_FLT_SECURE_KEYS_ENABLE   = 1 << 7, // enable Secure pid slot
218 } DSCMB_Flt_Type;
219 
220 /// Descrambler algorithm type
221 typedef enum
222 {
223     /// Descrambler algorithm : CSA
224     E_DSCMB_TYPE_CSA = 0,    // CSA
225     /// Descrambler algorithm : NSA as ESA
226     E_DSCMB_TYPE_NSA_AS_ESA, // NSA as ESA
227     /// Descrambler algorithm : CI+ DES
228     E_DSCMB_TYPE_DES,        // CI+ DES
229     /// Descrambler algorithm : CI+ AES
230     E_DSCMB_TYPE_AES,        // CI+ AES
231     // E_DSCMB_TYPE_ESA,       // ESA
232     // E_DSCMB_TYPE_NSAS,      // NSAS
233     E_DSCMB_TYPE_AES_ECB,
234     E_DSCMB_TYPE_AES_SCTE52,  // Descrambler algorithm : DBook, AES+CBC, S8 new, not support for all chips
235     E_DSCMB_TYPE_AES_CTR,     // AES Counter mode
236     E_DSCMB_TYPE_TDES_ECB,
237     E_DSCMB_TYPE_TDES_SCTE52,
238 
239     // Synamedia AES
240     E_DSCMB_TYPE_SYN_AES,    // AES Leading CLR EBC
241 
242     E_DSCMB_TYPE_MULTI2,    // Multi2
243 
244     /// Descrambler algorithm : CSA3
245     E_DSCMB_TYPE_CSA3,    // CSA3
246 
247     /// Descrambler algorithm : CSA conformance mode
248     E_DSCMB_TYPE_CSA_CONF,    // CSA conformance mode
249 
250     E_DSCMB_TYPE_OC,    // Open Cable
251 } DSCMB_Type;
252 
253 /// Descrambler key type
254 typedef enum
255 {
256     /// Descrambler key type : clear
257     E_DSCMB_KEY_CLEAR = 0,
258     /// Descrambler key type : even
259     E_DSCMB_KEY_EVEN,
260     /// Descrambler key type : odd
261     E_DSCMB_KEY_ODD,
262 
263     /// Enable FSCB
264     E_DSCMB_KEY_FSCB_ENABLE =   1 << 4,
265     /// Enable KL Key
266     E_DSCMB_KEY_TO_KL_ENABLE =  1 << 5,
267     /// Enable Secure Key
268     E_DSCMB_KEY_SECURE_KEYS_ENABLE =   1 << 7,
269 } DSCMB_Key_Type;
270 
271 /// Scramble level
272 typedef enum
273 {
274     /// Descrambler level : none
275     E_DSCMB_NONE                    =   0x00000000,
276     /// Descrambler level : TS level
277     E_DSCMB_TS                      =   0x00000001,
278     /// Descrambler level : PES level
279     E_DSCMB_PES                     =   0x00000002,
280     /// Descrambler level : TS and PES level
281     E_DSCMB_TS_PES                  =   (E_DSCMB_TS | E_DSCMB_PES),
282 } SCMB_Level;
283 
284 // Descrambler Engine Type //
285 typedef enum
286 {
287     E_DSCMB_ENG_LSAS = 0x1,
288     E_DSCMB_ENG_ESA  = 0x2,
289     E_DSCMB_ENG_LSAD = 0x4,
290 } DSCMB_Eng_Type;
291 
292 /// Key ladder input source
293 typedef enum
294 {
295     /// Key ladder source from ACPU/SCPU
296     E_DSCMB_KL_SRC_ACPU             =   0,
297     /// Key ladder source from SECRET_1
298     E_DSCMB_KL_SRC_SECRET_1         =   1,
299     /// Key ladder source from SECRET_2
300     E_DSCMB_KL_SRC_SECRET_2         =   2,
301     /// Key ladder source from SECRET_3
302     E_DSCMB_KL_SRC_SECRET_3         =   3,
303     /// Key ladder source from SECRET_4
304     E_DSCMB_KL_SRC_SECRET_4         =   4,
305     /// Key ladder source from SECRET_5
306     E_DSCMB_KL_SRC_SECRET_5         =   5,
307     /// Key ladder source from SECRET_6
308     E_DSCMB_KL_SRC_SECRET_6         =   6,
309     /// Key ladder source from SECRET_7
310     E_DSCMB_KL_SRC_SECRET_7         =   7,
311     /// Key ladder source from SECRET_8
312     E_DSCMB_KL_SRC_SECRET_8         =   8,
313     /// Key ladder source from SECRET_9
314     E_DSCMB_KL_SRC_SECRET_9         =   16,
315     /// Key ladder source from SECRET_10
316     E_DSCMB_KL_SRC_SECRET_10        =   10,
317     /// Key ladder source from SECRET_11
318     E_DSCMB_KL_SRC_SECRET_11        =   11,
319     /// Key ladder source from SECRET_12
320     E_DSCMB_KL_SRC_SECRET_12        =   12,
321     /// Key ladder source from SECRET_13
322     E_DSCMB_KL_SRC_SECRET_13        =   13,
323     /// Key ladder source from SECRET_14
324     E_DSCMB_KL_SRC_SECRET_14        =   14,
325     /// Key ladder source from SECRET_15
326     E_DSCMB_KL_SRC_SECRET_15        =   15,
327 
328     /// Key ladder source from Private_0, only for K3S, K5X, K7
329     E_DSCMB_KL_SRC_PRIVATE_0        =   5,
330     /// Key ladder source from Private_1, only for K3S, K5X, K7
331     E_DSCMB_KL_SRC_PRIVATE_1        =   6,
332     /// Key ladder source from Private_2, only for K3S, K5X, K7
333     E_DSCMB_KL_SRC_PRIVATE_2        =   7,
334     /// Key ladder source from Private_3, only for K3S, K5X, K7
335     E_DSCMB_KL_SRC_PRIVATE_3        =   8,
336 
337     /// Key ladder source from Private_0
338     E_DSCMB_KL_SRC_PRIVATE_EX_0        =   0x40,
339     /// Key ladder source from Private_1
340     E_DSCMB_KL_SRC_PRIVATE_EX_1        =   0x41,
341     /// Key ladder source from Private_2
342     E_DSCMB_KL_SRC_PRIVATE_EX_2        =   0x42,
343     /// Key ladder source from Private_3
344     E_DSCMB_KL_SRC_PRIVATE_EX_3        =   0x43,
345 
346     /// Key ladder source from VGK
347     E_DSCMB_KL_SRC_VGK              =   9,
348     /// Key ladder source go through KDF
349     E_DSCMB_KL_SRC_KDF_ENABLE       =   1 << 8,
350 } DSCMB_KLSrc;
351 
352 /// Key ladder output destination
353 typedef enum
354 {
355     E_DSCMB_KL_DST_ACPU             =   0x1,
356     E_DSCMB_KL_DST_KT_NSA           =   0x3,
357     E_DSCMB_KL_DST_DMA_AES          =   0x4,
358     E_DSCMB_KL_DST_DMA_TDES         =   0x5,
359     E_DSCMB_KL_DST_PRIVATE0         =   0x6,
360     E_DSCMB_KL_DST_PRIVATE1         =   0x7,
361     E_DSCMB_KL_DST_PRIVATE2         =   0x8,
362 
363 
364     /// Key ladder destination to ACPU
365     E_DSCMB_KL_DST_CPU_ACPU         =   0x00000080,
366     /// Key ladder destination to Secure CPU
367     E_DSCMB_KL_DST_CPU_SCPU         =   0x00000081,
368     /// Key ladder destination to TSIO
369     E_DSCMB_KL_DST_TSIO             =   0x00000800,
370     /// Key ladder destination to DSCMB (KeyTable)
371     E_DSCMB_KL_DST_KT_LSAD          =   0x00008000,
372     E_DSCMB_KL_DST_KT_ESA           =   0x00008100,
373     E_DSCMB_KL_DST_KT_LSAS          =   0x00008200,
374     E_DSCMB_KL_DST_KT_PIDSLOTMAP_ENABLE  = (1 << 14),
375     /// Key ladder destination to CFB
376     E_DSCMB_KL_DST_CFB              =   0x00080000,
377     /// Key ladder destination to DMA
378     E_DSCMB_KL_DST_DMA_SK0         =    0x00800000,
379     E_DSCMB_KL_DST_DMA_SK1         =    0x00810000,
380     E_DSCMB_KL_DST_DMA_SK2         =    0x00820000,
381     E_DSCMB_KL_DST_DMA_SK3         =    0x00830000,
382     E_DSCMB_KL_DST_DMA_PVRLUT0     =    0x00840000,
383     E_DSCMB_KL_DST_DMA_PVRLUT1     =    0x00850000,
384     E_DSCMB_KL_DST_DMA_PVRLUT2     =    0x00860000,
385     E_DSCMB_KL_DST_DMA_PVRLUT3     =    0x00870000,
386     E_DSCMB_KL_DST_DMA_SPS0        =    0x00880000 ,
387     E_DSCMB_KL_DST_DMA_SPS1        =    0x00890000 ,
388     E_DSCMB_KL_DST_DMA_SPS2        =    0x008A0000 ,
389     E_DSCMB_KL_DST_DMA_SPS3        =    0x008B0000 ,
390     E_DSCMB_KL_DST_DMA_SPD0        =    0x008C0000 ,
391     E_DSCMB_KL_DST_DMA_SPD1        =    0x008D0000 ,
392     E_DSCMB_KL_DST_DMA_SPD2        =    0x008E0000 ,
393     E_DSCMB_KL_DST_DMA_SPD3        =    0x008F0000 ,
394     /// Key ladder destination to PRIVATE KEY
395     E_DSCMB_KL_DST_PRIVATE_0       =(int)0x81000000   ,
396     E_DSCMB_KL_DST_PRIVATE_1       =(int)0x82000000   ,
397     E_DSCMB_KL_DST_PRIVATE_2       =(int)0x83000000   ,
398     E_DSCMB_KL_DST_PRIVATE_3       =(int)0x84000000   ,
399 } DSCMB_KLDst;
400 
401 typedef enum
402 {
403     // descrambler engine
404     E_DSCMB_CAP_ENGINE_NUM,
405     // descrambler slot
406     E_DSCMB_CAP_FLT_NUM,
407     // descrambler type supported
408     E_DSCMB_CAP_SUPPORT_ALGORITHM,
409     // descrambler key type supported
410     E_DSCMB_CAP_SUPPORT_KEY_TYPE,
411     // descrambler mapping, start tsp pid filter
412     E_DSCMB_CAP_PIDFILTER_MAP_START,
413     // descrambler mapping, end tsp pid filter
414     E_DSCMB_CAP_PIDFILTER_MAP_END,
415     // share key slot max number
416     E_DSCMB_CAP_SHARE_KEY_SLOT_MAX_NUM,
417     // share key region number
418     E_DSCMB_CAP_SHARE_KEY_REGION_NUM,
419     // share key region start
420     E_DSCMB_CAP_SHARE_KEY_REGION_START,
421     // share key region end
422     E_DSCMB_CAP_SHARE_KEY_REGION_END,
423 } DSCMB_Query_Type;
424 
425 typedef enum
426 {
427     // HDCP2.2 Errata
428     E_DSCMB_CFG_HDCP2_TX_CONTENT_CATEGORY_SUPPORT,
429 
430     // update scramble bit @ PUSI packet
431     E_DSCMB_CFG_SCMB_STATUS_PUSI_ONLY,
432 
433 } DSCMB_Option;
434 
435 typedef enum
436 {
437     E_DSCMB_KL_TDES                 =   0x00000000,
438     E_DSCMB_KL_AES                  =   0x0000003F,
439 } DSCMB_KLEng;
440 
441 typedef enum
442 {
443     E_DSCMB_KL_SEL_DEFAULT = 0, //Backward compatible, actual default value is chosen in HAL driver
444     E_DSCMB_KL_SEL_CW      , //CWKL
445     E_DSCMB_KL_SEL_PVR     , //PVRKL
446 } DSCMB_KL_SelEng;
447 
448 /// Key ladder configurations
449 typedef enum
450 {
451     E_DSCMB_KL_TYPE_LV0 = 0,
452     E_DSCMB_KL_TYPE_LV1 ,
453     E_DSCMB_KL_TYPE_LV2 ,
454     E_DSCMB_KL_TYPE_LV3 ,
455     E_DSCMB_KL_TYPE_LV4 ,
456     E_DSCMB_KL_TYPE_LV5 ,
457     E_DSCMB_KL_TYPE_INF = 9 ,
458     E_DSCMB_KL_TYPE_S5  = 0xD,
459 } DSCMB_KLType;
460 
461 typedef enum
462 {
463     E_DSCMB_KL_128_BITS   ,
464     E_DSCMB_KL_64_BITS  ,
465 } DSCMB_KL_OutputSize;
466 
467 /// Key ladder configurations
468 typedef struct DLL_PACKED
469 {
470     MS_BOOL         bDecrypt;
471     MS_BOOL         bInverse;
472     MS_BOOL         bKeepRound;
473     MS_U32          u32Round;
474     MS_U32          u32EngMode;
475     DSCMB_KLType         eKLType;
476     DSCMB_KL_OutputSize  eOutsize;
477 
478 } DSCMB_KLCfg;
479 
480 typedef enum
481 {
482     E_KDF_HASH_SHA1,
483     E_KDF_HASH_SHA256,
484 } KDF_TYPE;
485 
486 
487 typedef enum
488 {
489     E_KDF_HW_KEY1,
490     E_KDF_HW_KEY2,
491     E_KDF_HW_KEY3,
492     E_KDF_HW_KEY4,
493     E_KDF_HW_KEY_NUM,
494 } KDF_HW_KEY_SEL;
495 
496 /// Key ladder KDF configuration
497 typedef struct DLL_PACKED
498 {
499     MS_U16             u16AppId;
500     KDF_TYPE           eKDFType;
501     KDF_HW_KEY_SEL     eHWKeyId;
502 } DSCMB_KL_KDF;
503 
504 typedef enum
505 {
506     DSCMB_FSCB_UNCHG = 0,
507     DSCMB_FSCB_CLEAR,
508     DSCMB_FSCB_EVEN,
509     DSCMB_FSCB_ODD,
510 } DSCMB_FSCB;
511 
512 ///New  Key ladder configurations for Keyladder run all.
513 typedef struct DLL_PACKED
514 {
515     DSCMB_KLEng          eAlgo;
516     DSCMB_KLSrc          eSrc;   // Select KL root key source //
517     DSCMB_KLDst          eDst;   // Select KL output Key destination //
518     DSCMB_KL_OutputSize  eOutsize;  // Select ouput Key size. ex: Key size of CSA and DES are E_DSCMB_KL_64_BITS//
519     DSCMB_Key_Type       eKeyType;
520     // Key ladder running level, support level 0 ~ 3 // [NOTE] Level 0 is only supported when destination is CryptoDMA
521     MS_U32               u32Level;
522     MS_U32               u32EngID;  // Select ESA/NSA as KL destination, Dscmb engine ID //
523     MS_U32               u32DscID;  // Select ESA/NSA as KL destination, Dscmb ID. Select TSIO as KL destination, Tsio ID //
524     MS_U8                *u8KeyACPU;  // Select ACPU as KL root Key, KL root key //
525     // KL inputs, pointer of bytes array for each level input, every input contains 16 bytes //
526     // ex: MS_U8 input[48]: input[0-15] Level1 , input[16-31] Level2, input[32-47] Level3
527     MS_U8                *pu8KeyKLIn;
528     MS_BOOL              bDecrypt;
529     MS_BOOL              bInverse;
530 
531     // New data member
532     DSCMB_KL_SelEng      eKLSel;   //Select KeyLadder
533     MS_U32               u32CAVid; //Set CAVid
534     DSCMB_KL_KDF         stKDF;
535     DSCMB_FSCB           eFSCB; // Key-specific FSCB
536 } DSCMB_KLCfg_All;
537 
538 
539 typedef enum
540 {
541     E_DSCMB_MAIN_ALGO_AES       ,
542     E_DSCMB_MAIN_ALGO_CSA2      ,
543     E_DSCMB_MAIN_ALGO_DES       ,
544     E_DSCMB_MAIN_ALGO_TDES      ,
545     E_DSCMB_MAIN_ALGO_MULTI2    ,
546     E_DSCMB_MAIN_ALGO_CSA2_CONF ,
547     E_DSCMB_MAIN_ALGO_CSA3      ,
548     E_DSCMB_MAIN_ALGO_ASA       ,
549     E_DSCMB_MAIN_ALGO_TCSA3     ,
550     E_DSCMB_MAIN_ALGO_ESSA      ,
551     E_DSCMB_MAIN_ALGO_DEFAULT = 0xF,
552     E_DSCMB_MAIN_ALGO_NUM,
553 } DSCMB_MainAlgo_Type;
554 
555 
556 typedef enum
557 {
558     E_DSCMB_SUB_ALGO_NONE = 0   ,
559     E_DSCMB_SUB_ALGO_MDI_CBC = 0,
560     E_DSCMB_SUB_ALGO_MDI_RCBC  ,
561     E_DSCMB_SUB_ALGO_MDD_CBC   ,
562     E_DSCMB_SUB_ALGO_MDD_RCBC  ,
563     E_DSCMB_SUB_ALGO_LEADING_CLEAR ,
564     E_DSCMB_SUB_ALGO_ECB ,
565     E_DSCMB_SUB_ALGO_CBC ,
566     E_DSCMB_SUB_ALGO_CTR ,
567     E_DSCMB_SUB_ALGO_OFB ,
568     E_DSCMB_SUB_ALGO_DEFAULT = 0xF,
569     E_DSCMB_SUB_ALGO_NUM,
570 } DSCMB_SubAlgo_Type;
571 
572 
573 typedef enum
574 {
575     E_DSCMB_RESSB_ALGO_NONE = 0,
576     E_DSCMB_RESSB_ALGO_CLR = 0,
577     E_DSCMB_RESSB_ALGO_CTS,
578     E_DSCMB_RESSB_ALGO_SCTE52,
579     E_DSCMB_RESSB_ALGO_XORIV1,
580     E_DSCMB_RESSB_ALGO_OC_M,
581     E_DSCMB_RESSB_ALGO_XORIV2,
582     E_DSCMB_RESSB_ALGO_CTR,
583     E_DSCMB_RESSB_ALGO_DEFAULT = 0x7,
584     E_DSCMB_RESSB_ALGO_NUM,
585 } DSCMB_ResSBAlgo_Type;
586 
587 
588 typedef struct DLL_PACKED
589 {
590     DSCMB_MainAlgo_Type   eMainAlgo;
591     DSCMB_SubAlgo_Type    eSubAlgo;
592     DSCMB_ResSBAlgo_Type  eResAlgo;
593     DSCMB_ResSBAlgo_Type  eSBAlgo;
594     MS_BOOL               bDecrypt;
595 } DSCMB_Algo_Cfg;
596 
597 typedef enum
598 {
599     E_DSCMB_CAPVR_PROG0 = 1 ,
600     E_DSCMB_CAPVR_PROG1 = 2 ,
601 } DSCMB_CAPVR_MODE;
602 
603 typedef enum
604 {
605     E_DSCMB_TSIF_LIVE0,
606     E_DSCMB_TSIF_LIVE1,
607     E_DSCMB_TSIF_LIVE2,
608     E_DSCMB_TSIF_LIVE3,
609     E_DSCMB_TSIF_FILE0,
610     E_DSCMB_TSIF_FILE1,
611     E_DSCMB_TSIF_FILE2,
612     E_DSCMB_TSIF_FILE3,
613     E_DSCMB_TSIF_NUM,
614 } DSCMB_TSIF;
615 
616 // Error Status for KL //s
617 #define DSCMB_KL_Status MS_U32
618 
619 #define    KL_STATUS_KEY_OK                            0x0000
620 #define    KL_STATUS_ACPU_KEY_NULL                     0x0001
621 #define    KL_STATUS_ACPU_OUTKEY_NULL                  0x0002
622 #define    KL_STATUS_INVALID_KEYROUND_PARAMETER        0x0004
623 #define    KL_STATUS_INVALID_INPUT_LEVEL               0x0008
624 #define    KL_STATUS_IVALID_DSCMB_ID                   0x0010
625 #define    KL_STATUS_WAIT_CW_READY_TIMEOUT             0x0020
626 #define    KL_STATUS_WAIT_KL_READY_TIMEOUT             0x0040
627 #define    KL_STATUS_KL_INPUT_NULL                     0x0080
628 
629 #define    KL_STATUS_BAD_KEY                           0x0100
630 #define    KL_STATUS_INVALID_FUNCTION                  0x0200
631 #define    KL_STATUS_MULTI_FUNCTION                    0x0400
632 #define    KL_STATUS_ZERO_ORDER                        0x0800
633 #define    KL_STATUS_INTERNAL_BAD_KEY                  0x1000
634 #define    KL_STATUS_INVALID_KL_SEL                    0x2000
635 
636 
637 
638 // Backward compatible
639 typedef DSCMB_KLSrc          DSCMB_KLadderSrc;
640 #define E_DSCMB_KLAD_SRC_ACPU               E_DSCMB_KL_SRC_ACPU
641 #define E_DSCMB_KLAD_SRC_SECRET_KEY1        E_DSCMB_KL_SRC_SECRET_1
642 #define E_DSCMB_KLAD_SRC_SECRET_KEY2        E_DSCMB_KL_SRC_SECRET_2
643 #define E_DSCMB_KLAD_SRC_SECRET_KEY3        E_DSCMB_KL_SRC_SECRET_3
644 #define E_DSCMB_KLAD_SRC_SECRET_KEY4        E_DSCMB_KL_SRC_SECRET_4
645 #define E_DSCMB_KLAD_SRC_VGK                E_DSCMB_KL_SRC_VGK
646 
647 typedef DSCMB_KLDst          DSCMB_KLadderDst;
648 #define E_DSCMB_KLAD_DST_KTAB_ESA           E_DSCMB_KL_DST_KT_ESA
649 #define E_DSCMB_KLAD_DST_KTAB_NSA =         E_DSCMB_KL_DST_KT_NSA
650 #define E_DSCMB_KLAD_DST_AESDMA_AES =       E_DSCMB_KL_DST_DMA_AES
651 #define E_DSCMB_KLAD_DST_AESDMA_TDES =      E_DSCMB_KL_DST_DMA_TDES
652 #define E_DSCMB_KLAD_DST_ACPU =             E_DSCMB_KL_DST_ACPU
653 
654 typedef DSCMB_KLCfg          DSCMB_KLadderConfig;
655 
656 // wrapper function
657 #define MDrv_DSCMB_FltAlloc(void)   \
658     MDrv_DSCMB2_FltAlloc(0)
659 #define MDrv_DSCMB_FltAlloc_Ex(eFltType)   \
660     MDrv_DSCMB2_FltAlloc_Ex(0, eFltType)
661 #define MDrv_DSCMB_FltFree(u32DscmbId)   \
662     MDrv_DSCMB2_FltFree(0, u32DscmbId)
663 #define MDrv_DSCMB_FltConnectPid(u32DscmbId, u32Pid)  \
664     MDrv_DSCMB2_FltConnectPid(0, u32DscmbId, u32Pid)
665 #define MDrv_DSCMB_FltDisconnectPid(u32DscmbId, u32Pid) \
666     MDrv_DSCMB2_FltDisconnectPid(0, u32DscmbId, u32Pid)
667 #define MDrv_DSCMB_FltConnectFltId(u32DscmbId, u32FltId)    \
668     MDrv_DSCMB2_FltConnectFltId(0, u32DscmbId, u32FltId)
669 #define MDrv_DSCMB_FltDisconnectPid_Ex(u32DscmbId, u32Pid) \
670     MDrv_DSCMB2_FltDisconnectPid_Ex(0, u32DscmbId, u32Pid)
671 #define MDrv_DSCMB_FltDisconnectFltId(u32DscmbId, u32FltId)    \
672     MDrv_DSCMB2_FltDisconnectFltId(0, u32DscmbId, u32FltId)
673 #define MDrv_DSCMB_FltDscmb(u32DscmbId, bDscmb) \
674     MDrv_DSCMB2_FltDscmb(0, u32DscmbId, bDscmb)
675 #define MDrv_DSCMB_FltTypeSet(u32DscmbId, eType)    \
676     MDrv_DSCMB2_FltTypeSet(0, u32DscmbId, eType)
677 #define MDrv_DSCMB_Multi2_SetRound(u32Round)    \
678     MDrv_DSCMB2_Multi2_SetRound(0, u32Round)
679 #define MDrv_DSCMB_Multi2_SetSystemKey(u8Syskey)    \
680     MDrv_DSCMB2_Multi2_SetSystemKey(0, u8Syskey)
681 #define MDrv_DSCMB_FltKeySet(u32DscmbId, eKeyType, pu8Key)  \
682     MDrv_DSCMB2_FltKeySet(0, u32DscmbId, eKeyType, pu8Key)
683 #define MDrv_DSCMB_FltKeyReset(u32DscmbId, eKeyType)    \
684     MDrv_DSCMB2_FltKeyReset(0, u32DscmbId, eKeyType)
685 #define MDrv_DSCMB_FltIVSet(u32DscmbId, eKeyType, pu8IV)    \
686     MDrv_DSCMB2_FltIVSet(0, u32DscmbId, eKeyType, pu8IV)
687 #define MDrv_DSCMB_PidFlt_ScmbStatus(u32PidFltId, pScmbLevel)    \
688     MDrv_DSCMB2_PidFlt_ScmbStatus(0, u32PidFltId, pScmbLevel)
689 #define MDrv_DSCMB_FltKeyReset(u32DscmbId, eKeyType)    \
690     MDrv_DSCMB2_FltKeyReset(0, u32DscmbId, eKeyType)
691 
692 //-------------------------------------------------------------------------------------------------
693 //  Functions
694 //-------------------------------------------------------------------------------------------------
695 
696 // descrambler initial function
697 //-----------------
698 // DSCMB_General
699 //-----------------
700 //-------------------------------------------------------------------------------------------------
701 /// Initialize DSCMB module
702 /// @ingroup DSCMB_General
703 /// @return TRUE  : Succeed
704 /// @return FALSE : Fail
705 //-------------------------------------------------------------------------------------------------
706 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_Init(void);
707 
708 //-------------------------------------------------------------------------------------------------
709 /// Finalize DSCMB module
710 /// @ingroup DSCMB_General
711 /// @return TRUE  : Succeed
712 /// @return FALSE : Fail
713 //-------------------------------------------------------------------------------------------------
714 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_Exit(void);
715 //-----------------
716 // DSCMB_STB
717 //-----------------
718 //-------------------------------------------------------------------------------------------------
719 /// Set DSCMB CA VID
720 /// @ingroup DSCMB_STB_General
721 /// @param  u32EngId   \b IN: DSCMB engine id.
722 /// @param  u32CAVid  \b IN: CA VID.
723 /// @return TRUE  : Succeed
724 /// @return FALSE : Fail
725 //-------------------------------------------------------------------------------------------------
726 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_SetDefaultCAVid(MS_U32 u32EngId, MS_U32 u32CAVid);
727 
728 //-----------------
729 // DSCMB_ToBeModified: Slot_Ctrl
730 //-----------------
731 //-------------------------------------------------------------------------------------------------
732 /// Allocate a dscrambler filter (Slot). (Update to support share key case)
733 /// @ingroup DSCMB_ToBeModified_Slot_Ctrl
734 /// @return TRUE  : Succeed - Descrambler filter slot
735 /// @return FALSE : Fail - DRV_DSCMB_FLT_NULL
736 //-------------------------------------------------------------------------------------------------
737 DLL_PUBLIC MS_U32  MDrv_DSCMB2_FltAlloc(MS_U32 u32EngId);
738 
739 //-------------------------------------------------------------------------------------------------
740 /// Allocate a dscrambler filter (Slot). (Only this function can allocate share key slot).
741 /// (Just keep MDrv_DSCMB2_FltAlloc and refine it)
742 /// @ingroup DSCMB_ToBeRemove
743 /// @param u32EngId  \b IN: DSCMB engine id.
744 /// @param eFltType    \b IN: Type for descramber filter.
745 /// @return TRUE  : Succeed - Descrambler filter slot.
746 /// @return FALSE : Fail - DRV_DSCMB_FLT_NULL
747 //-------------------------------------------------------------------------------------------------
748 DLL_PUBLIC MS_U32  MDrv_DSCMB2_FltAlloc_Ex(MS_U32 u32EngId, DSCMB_Flt_Type eFltType);
749 //-----------------
750 // DSCMB_Slot_Control
751 //-----------------
752 //-------------------------------------------------------------------------------------------------
753 /// Free a dscrambler slot.
754 /// @ingroup DSCMB_Slot_Control
755 /// @param u32EngId        \b IN: DSCMB engine id.
756 /// @param u32DscmbId    \b IN: DSCMB slot.
757 /// @return TRUE  : Succeed
758 /// @return FALSE : Fail
759 //-------------------------------------------------------------------------------------------------
760 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltFree(MS_U32 u32EngId, MS_U32 u32DscmbId);
761 
762 //-------------------------------------------------------------------------------------------------
763 /// Change descrambler filter type.
764 /// @ingroup DSCMB_STB_General
765 /// @param u32EngId        \b IN: DSCMB engine id.
766 /// @param u32DscmbId    \b IN: DSCMB slot.
767 /// @param eFltType    \b IN: Type for descramber filter.
768 /// @return TRUE  : Succeed
769 /// @return FALSE : Fail
770 //-------------------------------------------------------------------------------------------------
771 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltSwitchType(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Flt_Type eFltType);
772 
773 //-------------------------------------------------------------------------------------------------
774 /// Connect DSCMB slot with DMX PID filter by filter index for Enc/Dec used.
775 /// @ingroup DSCMB_Slot_Control
776 /// @param u32EngId        \b IN: DSCMB engine id.
777 /// @param u32DscmbId    \b IN: DSCMB slot.
778 /// @param u32FltId          \b IN: DMX PID filter index.
779 /// @return TRUE  : Succeed
780 /// @return FALSE : Fail
781 //-------------------------------------------------------------------------------------------------
782 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltConnectFltId(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32FltId);
783 //-------------------------------------------------------------------------------------------------
784 /// Dis-connect DSCMB slot with DMX PID filter by filter index.
785 /// @ingroup DSCMB_Slot_Control
786 /// @param u32EngId        \b IN: DSCMB engine id.
787 /// @param u32DscmbId    \b IN: DSCMB slot.
788 /// @param u32FltId          \b IN: DMX PID filter index.
789 /// @return TRUE  : Succeed
790 /// @return FALSE : Fail
791 //-------------------------------------------------------------------------------------------------
792 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltDisconnectFltId(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32FltId);
793 
794 // descrambler filter maps to TSP pid
795 #if !(defined(MSOS_TYPE_OPTEE) || defined(MSOS_TYPE_NUTTX))
796 //-------------------------------------------------------------------------------------------------
797 /// Connect DSCMB slot with DMX PID filter by PID for Enc/Dec used.
798 /// @ingroup DSCMB_Slot_Control
799 /// @param u32EngId        \b IN: DSCMB engine id.
800 /// @param u32DscmbId    \b IN: DSCMB slot.
801 /// @param u32Pid            \b IN: PID.
802 /// @return TRUE  : Succeed
803 /// @return FALSE : Fail
804 //-------------------------------------------------------------------------------------------------
805 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltConnectPid(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32Pid);
806 //-------------------------------------------------------------------------------------------------
807 /// Dis-connect DSCMB slot with DMX PID filter by PID. (Refine for multi dis-connect case)
808 /// @ingroup DSCMB_ToBeModified_Slot_Ctrl
809 /// @param u32EngId        \b IN: DSCMB engine id.
810 /// @param u32DscmbId    \b IN: DSCMB slot.
811 /// @param u32Pid            \b IN: PID.
812 /// @return TRUE  : Succeed
813 /// @return FALSE : Fail
814 //-------------------------------------------------------------------------------------------------
815 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltDisconnectPid(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32Pid);
816 //-------------------------------------------------------------------------------------------------
817 /// Dis-connect DSCMB slot with DMX PID filter by PID. (It will check this PID exist on DMX side or not)
818 /// @ingroup DSCMB_STB_General
819 /// @param u32EngId        \b IN: DSCMB engine id.
820 /// @param u32DscmbId    \b IN: DSCMB slot.
821 /// @param u32Pid            \b IN: PID.
822 /// @return TRUE  : Succeed
823 /// @return FALSE : Fail
824 //-------------------------------------------------------------------------------------------------
825 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltDisconnectPid_Ex(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32Pid);
826 #endif
827 
828 //--------------------------------------------------------------------------------------------------
829 /// Set descrambler filter as scrambling/decrambling mode
830 /// @ingroup DSCMB_STB_General
831 /// @param u32EngId        \b IN: DSCMB engine id.
832 /// @param u32DscmbId    \b IN: DSCMB slot.
833 /// @param eEngType        \b IN: DSCMB engine type.
834 /// @param stConfig          \b IN: DSCMB algo.
835 /// @return TRUE - Success
836 /// @return FALSE - Failure
837 //--------------------------------------------------------------------------------------------------
838 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetAlgo(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Algo_Cfg stConfig);
839 
840 //--------------------------------------------------------------------------------------------------
841 /// Set descrambler key FSCB
842 /// @ingroup DSCMB_STB_General
843 /// @param u32EngId        \b IN: DSCMB engine id.
844 /// @param u32DscmbId    \b IN: DSCMB slot.
845 /// @param eEngType        \b IN: DSCMB engine type.
846 /// @param eKeyType       \b IN: Descrambler key type
847 /// @param eForceSCB     \b IN: FSCB type.
848 /// @return TRUE - Success
849 /// @return FALSE - Failure
850 //--------------------------------------------------------------------------------------------------
851 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetKeyFSCB(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Key_Type eKeyType, DSCMB_FSCB eForceSCB);
852 
853 //--------------------------------------------------------------------------------------------------
854 /// Set descrambler key
855 /// @ingroup DSCMB_STB_General
856 /// @param u32EngId        \b IN: DSCMB engine id.
857 /// @param u32DscmbId   \b IN: DSCMB slot.
858 /// @param eEngType       \b IN: DSCMB engine type.
859 /// @param eKeyType       \b IN: Descrambler key type
860 /// @param pu8Key          \b IN: pointer to the key (Array)
861 /// @return TRUE - Success
862 /// @return FALSE - Failure
863 //--------------------------------------------------------------------------------------------------
864 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetKey(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Key_Type eKeyType, MS_U8* pu8Key);
865 
866 //--------------------------------------------------------------------------------------------------
867 /// Reset descrambler key
868 /// @ingroup DSCMB_STB_General
869 /// @param u32EngId        \b IN: DSCMB engine id.
870 /// @param u32DscmbId   \b IN: DSCMB slot.
871 /// @param eEngType       \b IN: DSCMB engine type.
872 /// @param eKeyType      \b IN: Descrambler key type
873 /// @return TRUE - Success
874 /// @return FALSE - Failure
875 //--------------------------------------------------------------------------------------------------
876 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngResetKey(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Key_Type eKeyType);
877 
878 //--------------------------------------------------------------------------------------------------
879 /// Set descrambler IV key
880 /// @ingroup DSCMB_STB_General
881 /// @param u32EngId       \b IN: DSCMB engine id
882 /// @param u32DscmbId   \b IN: DSCMB slot.
883 /// @param eKeyType      \b IN: Descrambler key type
884 /// @param pu8IV            \b IN: pointer to the key. (Instruction Vector)
885 /// @return TRUE - Success
886 /// @return FALSE - Failure
887 //--------------------------------------------------------------------------------------------------
888 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetIV(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType, MS_U8* pu8IV);
889 
890 //--------------------------------------------------------------------------------------------------
891 /// Set descrambler IV key by engine type
892 /// @ingroup DSCMB_STB_General
893 /// @param u32EngId       \b IN: DSCMB engine id
894 /// @param u32DscmbId   \b IN: DSCMB slot.
895 /// @param eEngType       \b IN: DSCMB engine type.
896 /// @param eKeyType      \b IN: Descrambler key type
897 /// @param pu8IV            \b IN: pointer to the key. (Instruction Vector)
898 /// @return TRUE - Success
899 /// @return FALSE - Failure
900 //--------------------------------------------------------------------------------------------------
901 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetIV_Ex(MS_U32 u32EngId, MS_U32 u32DscmbId,  DSCMB_Eng_Type eEngType, DSCMB_Key_Type eKeyType, MS_U8* pu8IV);
902 
903 //--------------------------------------------------------------------------------------------------
904 /// Set Riv of HDCP2, which is 64-bits number generated from transmitter
905 /// @ingroup DSCMB_STB_General
906 /// @param u32EngId   \b IN: DSCMB engine id
907 /// @param u32DscmbId   \b IN: DSCMB slot
908 /// @param pu8RIV      \b IN: pointer to 64bit Riv buffer in BIG ENDIAN order
909 /// @return TRUE  - Success
910 /// @return FALSE - Failure
911 //--------------------------------------------------------------------------------------------------
912 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetRIV(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U8* pu8RIV);
913 
914 //--------------------------------------------------------------------------------------------------
915 /// Switch descrambler engine type
916 /// @ingroup DSCMB_STB_General
917 /// @param u32EngId       \b IN: DSCMB engine id
918 /// @param u32DscmbId   \b IN: DSCMB slot.
919 /// @param eUppSwitch    \b IN: Up: Engine type.
920 /// @param eLowSwitch    \b IN: Low: Engine type.
921 /// @return TRUE - Success
922 /// @return FALSE - Failure
923 //--------------------------------------------------------------------------------------------------
924 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetSwitch(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eUppSwitch, DSCMB_Eng_Type eLowSwitch);
925 
926 //--------------------------------------------------------------------------------------------------
927 /// Set descrambler engine FSCB
928 /// @ingroup DSCMB_STB_General
929 /// @param u32EngId       \b IN: DSCMB engine id
930 /// @param u32DscmbId   \b IN: DSCMB slot.
931 /// @param eForceSCB     \b IN: FSCB type.
932 /// @return TRUE - Success
933 /// @return FALSE - Failure
934 //--------------------------------------------------------------------------------------------------
935 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngSetFSCB(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_FSCB eForceSCB );
936 
937 //--------------------------------------------------------------------------------------------------
938 /// Enable/disable descrambler key
939 /// @ingroup DSCMB_STB_General
940 /// @param u32EngId        \b IN: DSCMB engine id.
941 /// @param u32DscmbId   \b IN: DSCMB slot.
942 /// @param eEngType       \b IN: DSCMB engine type.
943 /// @param eKeyType      \b IN: Descrambler key type
944 /// @param bEN      \b IN: enable or disable
945 /// @return TRUE - Success
946 /// @return FALSE - Failure
947 //--------------------------------------------------------------------------------------------------
948 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_EngEnableKey(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Key_Type eKeyType, MS_BOOL bEn);
949 //--------------------------------------------------------------------------------------------------
950 /// Set descrambler dual path flow
951 /// @ingroup DSCMB_STB_General
952 /// @param u32EngId       \b IN: DSCMB engine id
953 /// @param eCaMode   \b IN: DSCMB CA mode.
954 /// @param ePvrSrcTsif     \b IN: PVR source.
955 /// @return TRUE - Success
956 /// @return FALSE - Failure
957 //--------------------------------------------------------------------------------------------------
958 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_CAPVR_FlowSet(MS_U32 u32EngId, DSCMB_CAPVR_MODE eCaMode, DSCMB_TSIF ePvrSrcTsif);
959 //--------------------------------------------------------------------------------------------------
960 /// Disable stream dual path
961 /// @ingroup DSCMB_STB_General
962 /// @param u32EngId       \b IN: DSCMB engine id
963 /// @param u32FltId          \b IN: DMX PID filter index.
964 /// @return TRUE - Success
965 /// @return FALSE - Failure
966 //--------------------------------------------------------------------------------------------------
967 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_DualPath_Enable(MS_U32 u32EngId, MS_U32 u32FltId);
968 //--------------------------------------------------------------------------------------------------
969 /// Enable stream dual path
970 /// @ingroup DSCMB_STB_General
971 /// @param u32EngId       \b IN: DSCMB engine id
972 /// @param u32FltId          \b IN: DMX PID filter index.
973 /// @return TRUE - Success
974 /// @return FALSE - Failure
975 //--------------------------------------------------------------------------------------------------
976 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_DualPath_Disable(MS_U32 u32EngId, MS_U32 u32FltId);
977 
978 
979 //--------------------------------------------------------------------------------------------------
980 /// Set descrambler filter as scrambling/decrambling mode.
981 /// Default filter mode is descrambling if this function is not specified.
982 /// This function should be invoked before MDrv_DSCMB_FltTypeSet.
983 /// @ingroup DSCMB_STB_General
984 /// @param u32DscmbId \b IN: Descrambler filter ID obtained from MDrv_DSCMB_FltAlloc
985 /// @param DscmbType \b IN: The descrambler algorithm
986 /// @return TRUE - Success
987 /// @return FALSE - Failure
988 //--------------------------------------------------------------------------------------------------
989 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltDscmb(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_BOOL bDscmb);
990 //-----------------
991 // DSCMB_Key
992 //-----------------
993 //--------------------------------------------------------------------------------------------------
994 /// Set descrambler algorithm by common predefined descramble type.
995 /// @ingroup DSCMB_Key
996 /// @param u32EngId       \b IN: DSCMB engine id
997 /// @param u32DscmbId   \b IN: DSCMB slot.
998 /// @param DscmbType    \b IN: The descrambler algorithm
999 /// @return TRUE  - Success
1000 /// @return FALSE - Failure
1001 //--------------------------------------------------------------------------------------------------
1002 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltTypeSet(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Type DscmbType);
1003 //--------------------------------------------------------------------------------------------------
1004 /// Set descrambler key of the Dscmb ID
1005 /// @ingroup DSCMB_Key
1006 /// @param u32EngId       \b IN: DSCMB engine id
1007 /// @param u32DscmbId   \b IN: DSCMB slot.
1008 /// @param eKeyType      \b IN: Descrambler key type
1009 /// @param pu8Key         \b IN: pointer to the key (Array)
1010 /// @return TRUE - Success
1011 /// @return FALSE - Failure
1012 //--------------------------------------------------------------------------------------------------
1013 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltKeySet(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType, MS_U8* pu8Key);
1014 //--------------------------------------------------------------------------------------------------
1015 /// Reset descrambler key of the Dscmb ID. (It will set key to 0)
1016 /// @ingroup DSCMB_Key
1017 /// @param u32EngId       \b IN: DSCMB engine id
1018 /// @param u32DscmbId   \b IN: DSCMB slot.
1019 /// @param eKeyType      \b IN: Descrambler key type
1020 /// @return TRUE - Success
1021 /// @return FALSE - Failure
1022 //--------------------------------------------------------------------------------------------------
1023 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltKeyReset(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType);
1024 
1025 //--------------------------------------------------------------------------------------------------
1026 /// Set descrambler initial vector of the Dscmb ID
1027 /// @ingroup DSCMB_Key
1028 /// @param u32EngId       \b IN: DSCMB engine id
1029 /// @param u32DscmbId   \b IN: DSCMB slot.
1030 /// @param eKeyType      \b IN: Descrambler key type
1031 /// @param pu8IV            \b IN: pointer to the key. (Instruction Vector)
1032 /// @return TRUE - Success
1033 /// @return FALSE - Failure
1034 //--------------------------------------------------------------------------------------------------
1035 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_FltIVSet(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType, MS_U8* pu8IV);
1036 
1037 //--------------------------------------------------------------------------------------------------
1038 /// Get / Set dscrambler miscellaneous options
1039 /// @ingroup DSCMB_General
1040 /// @param u32EngId      \b IN: DSCMB engine id.
1041 /// @param Option Type  \b IN: Option type
1042 /// @param pInput          \b IN: intput parameter
1043 /// @param pOutput        \b OUT: result for the query type
1044 /// @param bSet           \b IN : Set or Get
1045 /// @return TRUE - Success
1046 /// @return FALSE - Failure
1047 //--------------------------------------------------------------------------------------------------
1048 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_OptConfig(MS_U32 u32EngId, DSCMB_Option eOpt, void* pInput, void* pOutput, MS_BOOL bSet);
1049 
1050 //--------------------------------------------------------------------------------------------------
1051 /// Query dscrambler capability information
1052 /// @ingroup DSCMB_General
1053 /// @param u32EngId      \b IN: DSCMB engine id.
1054 /// @param eQueryType  \b IN: type for query
1055 /// @param pInput          \b IN: intput parameter
1056 /// @param pOutput        \b OUT: result for the query type
1057 /// @return TRUE - Success
1058 /// @return FALSE - Failure
1059 //--------------------------------------------------------------------------------------------------
1060 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_GetCap(MS_U32 u32EngId, DSCMB_Query_Type eQueryType, void* pInput, void* pOutput);
1061 //--------------------------------------------------------------------------------------------------
1062 /// Get DSCMB driver library information
1063 /// @ingroup DSCMB_General
1064 /// @param ppVersion \b OUT: Descrambler library version infomation
1065 /// @return TRUE - Success
1066 /// @return FALSE - Failure
1067 //--------------------------------------------------------------------------------------------------
1068 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_GetLibVer(const MSIF_Version **ppVersion);
1069 //-------------------------------------------------------------------------------------------------
1070 /// Set DSCMB Debug Level.
1071 /// @ingroup DSCMB_General
1072 /// @param  u32Level  \b IN: debug level.
1073 /// @return TRUE  : Succeed
1074 /// @return FALSE : Fail
1075 //-------------------------------------------------------------------------------------------------
1076 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_SetDBGLevel(MS_U32 u32Level);
1077 //--------------------------------------------------------------------------------------------------
1078 /// Check the status between DSCMB slot and DMX PID filter.
1079 /// @ingroup DSCMB_STB_General
1080 /// @param  u32EngId      \b IN: DSCMB engine id.
1081 /// @param u32DscmbId   \b IN: descramble id
1082 /// @param u32TspFltId    \b IN: tsp filter id
1083 /// @return TRUE  - Success (connect)
1084 /// @return FALSE - Failure (not connect)
1085 //--------------------------------------------------------------------------------------------------
1086 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_GetConnectStatus(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32TspFltId);
1087 //--------------------------------------------------------------------------------------------------
1088 /// Get a valid PID slot map index
1089 /// @ingroup DSCMB_STB_General
1090 /// @param  u32EngId      \b IN: DSCMB engine id.
1091 /// @param u32DscmbId   \b IN: descramble id
1092 /// @return TRUE  : Succeed - Descrambler PID slot map index.
1093 /// @return FALSE : Fail - DRV_DSCMB_FLT_NULL
1094 //--------------------------------------------------------------------------------------------------
1095 DLL_PUBLIC MS_U32  MDrv_DSCMB2_GetPidSlotMapIndex(MS_U32 u32EngId, MS_U32 u32DscmbId);
1096 
1097 
1098 //--------------------------------------------------------------------------------------------------
1099 /// Set rounds of descrambler algorithm MULTI2
1100 /// @ingroup DSCMB_Key
1101 /// @param u32EngId     \b IN: DSCMB engine id
1102 /// @param u32Round    \b IN: # rounds to apply, multiple of 4 and maximum value is 252
1103 /// @return TRUE  - Success
1104 /// @return FALSE - Failure
1105 //--------------------------------------------------------------------------------------------------
1106 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_Multi2_SetRound(MS_U32 u32EngId, MS_U32 u32Round);
1107 //--------------------------------------------------------------------------------------------------
1108 /// Set system key of descrambler algorithm MULTI2
1109 /// @ingroup DSCMB_Key
1110 /// @param u32EngId     \b IN: DSCMB engine id
1111 /// @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.
1112 /// @[0-31][32-63][64-95][96-127][128-159][160-191][192-223][224-255] and the bit order is MSB.
1113 /// @return TRUE  - Success
1114 /// @return FALSE - Failure
1115 //--------------------------------------------------------------------------------------------------
1116 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_Multi2_SetSystemKey(MS_U32 u32EngId, MS_U8* u8Syskey);
1117 //--------------------------------------------------------------------------------------------------
1118 /// Set Riv of HDCP2, which is 64-bits number generated from transmitter
1119 /// @ingroup DSCMB_Key
1120 /// @param u32EngId   \b IN: DSCMB engine id
1121 /// @param pu8RIV      \b IN: pointer to 64bit Riv buffer in BIG ENDIAN order
1122 /// @return TRUE  - Success
1123 /// @return FALSE - Failure
1124 //--------------------------------------------------------------------------------------------------
1125 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_HDCP2_SetRIV(MS_U32 u32EngId, MS_U8* pu8RIV);
1126 //--------------------------------------------------------------------------------------------------
1127 /// Set Riv of HDCP2, which is 64-bits number generated from transmitter
1128 /// @ingroup DSCMB_Key
1129 /// @param u32EngId   \b IN: DSCMB engine id
1130 /// @param u32EngId   \b IN: DSCMB slot
1131 /// @param pu8RIV      \b IN: pointer to 64bit Riv buffer in BIG ENDIAN order
1132 /// @return TRUE  - Success
1133 /// @return FALSE - Failure
1134 //--------------------------------------------------------------------------------------------------
1135 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_HDCP2_SetRIV_Ex(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U8* pu8RIV);
1136 //--------------------------------------------------------------------------------------------------
1137 /// Enable Record stream after stream is descrambled, only supported when CA venders do not prohibat this feature.
1138 /// @ingroup DSCMB_STB_General
1139 /// @param u32EngId  \b IN: DSCMB engine id
1140 /// @param Enable      \b IN: for enabe/disable record mechanism.
1141 /// @return TRUE  - Success
1142 /// @return FALSE - Failure
1143 /// @Note: Function can only be called before any record function is called.
1144 //--------------------------------------------------------------------------------------------------
1145 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_PVR_RecCtrl(MS_U32 u32EngId, MS_BOOL Enable);
1146 //-----------------
1147 // DSCMB_STR
1148 //-----------------
1149 //-------------------------------------------------------------------------------------------------
1150 /// Control DSCMB STR functions.
1151 /// @ingroup DSCMB_STR
1152 /// @param  u16PowerState  \b IN: STR power mode. (to control STR suspend & resume case.)
1153 /// @return : Utopia status - UTOPIA_STATUS_SUCCESS (Succeed) or UTOPIA_STATUS_FAIL (Fail)
1154 //-------------------------------------------------------------------------------------------------
1155 DLL_PUBLIC MS_U32  MDrv_DSCMB2_SetPowerState(EN_POWER_MODE u16PowerState);
1156 
1157 //--------------------------------------------------------------------------------------------------
1158 /// Get scrambler level of a pid filter ID
1159 /// @ingroup DSCMB_General
1160 /// @param u32EngId      \b IN: DSCMB engine id.
1161 /// @param u32PidFltId    \b IN: Pid filter ID obtained from MApi_DMX_Open/MDrv_TSP_PidFlt_Alloc
1162 /// @param pScmbLevel   \b OUT: The output scrambler level
1163 /// @return TRUE - Success
1164 /// @return FALSE - Failure
1165 //--------------------------------------------------------------------------------------------------
1166 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_PidFlt_ScmbStatus(MS_U32 u32EngId, MS_U32 u32PidFltId, SCMB_Level* pScmbLevel);
1167 
1168 //--------------------------------------------------------------------------------------------------
1169 /// Get Dscmb driver status (There is no any code use this parameter)
1170 /// @ingroup DSCMB_ToBeRemove
1171 /// @param pStatus   \b OUT: Descrambler status
1172 /// @return TRUE - Success
1173 /// @return FALSE - Failure
1174 //--------------------------------------------------------------------------------------------------
1175 DLL_PUBLIC MS_BOOL MDrv_DSCMB_GetStatus(DSCMB_Status *pStatus);
1176 //--------------------------------------------------------------------------------------------------
1177 /// Get Dscmb driver information
1178 /// @ingroup DSCMB_General
1179 /// @return DSCMB_Info
1180 //--------------------------------------------------------------------------------------------------
1181 DLL_PUBLIC const DSCMB_Info* MDrv_DSCMB_GetInfo(void);
1182 
1183 
1184 //-----------------
1185 // DSCMB_STB_Kladder
1186 //-----------------
1187 //--------------------------------------------------------------------------------------------------
1188 /// KLadder_ETSI
1189 /// @ingroup DSCMB_STB_Kladder
1190 /// @return TRUE  - Success
1191 /// @return FALSE - Failure
1192 //--------------------------------------------------------------------------------------------------
1193 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 );
1194 //--------------------------------------------------------------------------------------------------
1195 /// KLadder_AtomicExec
1196 /// @ingroup DSCMB_STB_Kladder
1197 /// @return TRUE  - Success
1198 /// @return FALSE - Failure
1199 //--------------------------------------------------------------------------------------------------
1200 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_KLadder_AtomicExec(DSCMB_KLCfg_All* KLCfg , MS_U8 *ACPU_Out, DSCMB_KL_Status* u32Status );
1201 
1202 
1203 //-----------------
1204 // DSCMB_ToBeRemove
1205 //-----------------
1206 //-------------------------------------------------------------------------------------------------
1207 /// Initialize DSCMB module. (Already have another function: DSCMB2_Init)
1208 /// @ingroup DSCMB_ToBeRemove
1209 /// @return TRUE  : Succeed
1210 /// @return FALSE : Fail
1211 //-------------------------------------------------------------------------------------------------
1212 DLL_PUBLIC MS_BOOL MDrv_DSCMB_Init(void);
1213 //-------------------------------------------------------------------------------------------------
1214 /// Finalize DSCMB module. (Already have another function: DSCMB2_Exit)
1215 /// @ingroup DSCMB_ToBeRemove
1216 /// @return TRUE  : Succeed
1217 /// @return FALSE : Fail
1218 //-------------------------------------------------------------------------------------------------
1219 DLL_PUBLIC MS_BOOL MDrv_DSCMB_Exit(void);
1220 //--------------------------------------------------------------------------------------------------
1221 /// Get Dscmb driver library information. (Already have another function: DSCMB2_GetLibVer)
1222 /// @ingroup DSCMB_ToBeRemove
1223 /// @param ppVersion \b OUT: Descrambler library version infomation
1224 /// @return TRUE - Success
1225 /// @return FALSE - Failure
1226 //--------------------------------------------------------------------------------------------------
1227 DLL_PUBLIC MS_BOOL MDrv_DSCMB_GetLibVer(const MSIF_Version **ppVersion);
1228 //-------------------------------------------------------------------------------------------------
1229 /// Set DSCMB Debug Level. (Already have another function: DSCMB2_SetDBGLevel)
1230 /// @ingroup DSCMB_ToBeRemove
1231 /// @param  u32Level  \b IN: debug level.
1232 /// @return TRUE  : Succeed
1233 /// @return FALSE : Fail
1234 //-------------------------------------------------------------------------------------------------
1235 DLL_PUBLIC MS_BOOL MDrv_DSCMB_SetDBGLevel(MS_U32 u32Level);
1236 
1237 //--------------------------------------------------------------------------------------------------
1238 /// Check the status between DSCMB slot and DMX PID filter.
1239 /// @ingroup DSCMB_STB_General
1240 /// @param  u32EngId      \b IN: DSCMB engine id.
1241 /// @param u32DscmbId   \b IN: descramble id
1242 /// @param u32TspFltId    \b IN: tsp filter id
1243 /// @return TRUE  - Success (connect)
1244 /// @return FALSE - Failure (not connect)
1245 //--------------------------------------------------------------------------------------------------
1246 DLL_PUBLIC MS_BOOL MDrv_DSCMB_GetConnectStatus(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32TspFltId);
1247 //--------------------------------------------------------------------------------------------------
1248 /// KLadder_AtomicExec
1249 /// @ingroup DSCMB_STB_Kladder
1250 /// @return TRUE  - Success
1251 /// @return FALSE - Failure
1252 //--------------------------------------------------------------------------------------------------
1253 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_AtomicExec(DSCMB_KLCfg_All* KLCfg , MS_U8 *ACPU_Out, DSCMB_KL_Status* u32Status);
1254 //--------------------------------------------------------------------------------------------------
1255 /// KLadder_Reset
1256 /// @ingroup DSCMB_STB_Kladder
1257 /// @return TRUE  - Success
1258 /// @return FALSE - Failure
1259 //--------------------------------------------------------------------------------------------------
1260 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Reset(void);
1261 //--------------------------------------------------------------------------------------------------
1262 /// KLadder_SetInput
1263 /// @ingroup DSCMB_STB_Kladder
1264 /// @return TRUE  - Success
1265 /// @return FALSE - Failure
1266 //--------------------------------------------------------------------------------------------------
1267 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_SetInput(MS_U32 u32Level, MS_U8* pu8In, MS_U32 u32InLen);
1268 //--------------------------------------------------------------------------------------------------
1269 /// KLadder_SetKey
1270 /// @ingroup DSCMB_STB_Kladder
1271 /// @return TRUE  - Success
1272 /// @return FALSE - Failure
1273 //--------------------------------------------------------------------------------------------------
1274 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_SetKey(DSCMB_KLSrc KLSrc, MS_U8* pu8Key, MS_U32 u32KeyLen);
1275 //--------------------------------------------------------------------------------------------------
1276 /// KLadder_SetDst
1277 /// @ingroup DSCMB_STB_Kladder
1278 /// @return TRUE  - Success
1279 /// @return FALSE - Failure
1280 //--------------------------------------------------------------------------------------------------
1281 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_SetDst(DSCMB_KLDst KLDst);
1282 
1283 //--------------------------------------------------------------------------------------------------
1284 /// KLadder_SetConfig
1285 /// @ingroup DSCMB_STB_Kladder
1286 /// @return TRUE  - Success
1287 /// @return FALSE - Failure
1288 //--------------------------------------------------------------------------------------------------
1289 DLL_PUBLIC void    MDrv_DSCMB_KLadder_SetConfig(DSCMB_KLCfg *KLCfg);
1290 
1291 //--------------------------------------------------------------------------------------------------
1292 /// KLadder_Start
1293 /// @ingroup DSCMB_STB_Kladder
1294 /// @return TRUE  - Success
1295 /// @return FALSE - Failure
1296 //--------------------------------------------------------------------------------------------------
1297 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Start(void);
1298 
1299 //--------------------------------------------------------------------------------------------------
1300 /// KLadder_IsComplete
1301 /// @ingroup DSCMB_STB_Kladder
1302 /// @return TRUE  - Success
1303 /// @return FALSE - Failure
1304 //--------------------------------------------------------------------------------------------------
1305 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_IsComplete(void);
1306 
1307 //--------------------------------------------------------------------------------------------------
1308 /// KLadder_Output_Start
1309 /// @ingroup DSCMB_STB_Kladder
1310 /// @return TRUE  - Success
1311 /// @return FALSE - Failure
1312 //--------------------------------------------------------------------------------------------------
1313 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Output_Start(MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType);
1314 
1315 //--------------------------------------------------------------------------------------------------
1316 /// KLadder_Output_IsComplete
1317 /// @ingroup DSCMB_STB_Kladder
1318 /// @return TRUE  - Success
1319 /// @return FALSE - Failure
1320 //--------------------------------------------------------------------------------------------------
1321 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Output_IsComplete(void);
1322 
1323 //--------------------------------------------------------------------------------------------------
1324 /// KLadder_Output_Stop
1325 /// @ingroup DSCMB_STB_Kladder
1326 /// @return TRUE  - Success
1327 /// @return FALSE - Failure
1328 //--------------------------------------------------------------------------------------------------
1329 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Output_Stop(void);
1330 
1331 //--------------------------------------------------------------------------------------------------
1332 /// KLadder_ResetAcpuAck
1333 /// @ingroup DSCMB_STB_Kladder
1334 /// @return TRUE  - Success
1335 /// @return FALSE - Failure
1336 //--------------------------------------------------------------------------------------------------
1337 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_ResetAcpuAck(void);
1338 
1339 //--------------------------------------------------------------------------------------------------
1340 /// KLadder_ReadDataFromAcpu
1341 /// @ingroup DSCMB_STB_Kladder
1342 /// @return TRUE  - Success
1343 /// @return FALSE - Failure
1344 //--------------------------------------------------------------------------------------------------
1345 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_ReadDataFromAcpu(MS_U8* pu8Out);
1346 
1347 //--------------------------------------------------------------------------------------------------
1348 /// KLadder_Stop
1349 /// @ingroup DSCMB_STB_Kladder
1350 /// @return TRUE  - Success
1351 /// @return FALSE - Failure
1352 //--------------------------------------------------------------------------------------------------
1353 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Stop(void); // write KTE
1354 
1355 //--------------------------------------------------------------------------------------------------
1356 /// KLadder_Lock
1357 /// @ingroup DSCMB_STB_Kladder
1358 /// @return TRUE  - Success
1359 /// @return FALSE - Failure
1360 //--------------------------------------------------------------------------------------------------
1361 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Lock(void);
1362 
1363 //--------------------------------------------------------------------------------------------------
1364 /// KLadder_Unlock
1365 /// @ingroup DSCMB_STB_Kladder
1366 /// @return TRUE  - Success
1367 /// @return FALSE - Failure
1368 //--------------------------------------------------------------------------------------------------
1369 DLL_PUBLIC MS_BOOL MDrv_DSCMB_KLadder_Unlock(void);
1370 
1371 //--------------------------------------------------------------------------------------------------
1372 /// Set the PID to be replaced
1373 /// @ingroup DSCMB_STB_General
1374 /// @param u32PidPrim     \b IN: The packet with this target PID(u32PidPrim) will be replaced in the field of PID by u32Pid2ndary
1375 /// @param u32Pid2ndary  \b IN: The packet with this target PID(u32PidPrim) will be replaced in the field of PID by u32Pid2ndary
1376 /// @return TRUE  - Success
1377 /// @return FALSE - Failure
1378 //--------------------------------------------------------------------------------------------------
1379 DLL_PUBLIC MS_BOOL MDrv_DSCMB_2ndarySet(MS_U32 u32PidPrim, MS_U32 u32Pid2ndary);
1380 //--------------------------------------------------------------------------------------------------
1381 /// Reset the PID to be replaced
1382 /// @ingroup DSCMB_STB_General
1383 /// @param u32PidPrim\b   IN: Reset the replacement of PID (u32PidPrim) set by MDrv_DSCMB_2ndarySet
1384 /// @return TRUE  - Success
1385 /// @return FALSE - Failure
1386 //--------------------------------------------------------------------------------------------------
1387 DLL_PUBLIC MS_BOOL MDrv_DSCMB_2ndaryReset(MS_U32 u32PidPrim);
1388 //--------------------------------------------------------------------------------------------------
1389 /// The low-level implementation of @ref MDrv_DSCMB_FltTypeSet [RESERVED]
1390 /// @ingroup DSCMB_STB_General
1391 /// @param u32DscmbId \b IN: descrambler filter ID obtained from MDrv_DSCMB_FltAlloc
1392 /// @param eKeyType \b IN: key type for this setting
1393 /// @param u32SW0 \b IN: The descramlber switch configuration
1394 /// @param u32SW1 \b IN: reserved
1395 /// @param u32SW2 \b IN: reserved
1396 /// @return TRUE  - Success
1397 /// @return FALSE - Failure
1398 //--------------------------------------------------------------------------------------------------
1399 DLL_PUBLIC MS_BOOL MDrv_DSCMB_SlotSwitchWrite(MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType, MS_U32 u32SW0, MS_U32 u32SW1, MS_U32 u32SW2);
1400 
1401 //--------------------------------------------------------------------------------------------------
1402 /// Set record buffer
1403 /// @ingroup DSCMB_STB_General
1404 /// @return TRUE - Success
1405 /// @return FALSE - Failure
1406 //--------------------------------------------------------------------------------------------------
1407 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_SetRecBuf(MS_U32 u32EngId , MS_U32 u32Start, MS_U32 u32Size);
1408 
1409 //--------------------------------------------------------------------------------------------------
1410 /// Record control
1411 /// @ingroup DSCMB_STB_General
1412 /// @return TRUE - Success
1413 /// @return FALSE - Failure
1414 //--------------------------------------------------------------------------------------------------
1415 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_RecCtrl(MS_U32 u32EngId, MS_BOOL bEnable);
1416 
1417 //--------------------------------------------------------------------------------------------------
1418 /// Get record write pointer
1419 /// @ingroup DSCMB_STB_General
1420 /// @return TRUE - Success
1421 /// @return FALSE - Failure
1422 //--------------------------------------------------------------------------------------------------
1423 DLL_PUBLIC MS_BOOL MDrv_DSCMB2_GetRecWptr(MS_U32 u32EngId, MS_U32* pu32Write);
1424 
1425 //-------------------------------------------------------------------------------------------------
1426 /// Control DSCMB STR functions. (Already have another function: DSCMB2_SetPowerState)
1427 /// @ingroup DSCMB_ToBeRemove
1428 /// @param  u16PowerState  \b IN: STR power mode. (to control STR suspend & resume case.)
1429 /// @return : Utopia status - UTOPIA_STATUS_SUCCESS (Succeed) or UTOPIA_STATUS_FAIL (Fail)
1430 //-------------------------------------------------------------------------------------------------
1431 DLL_PUBLIC MS_U32  MApi_DSCMB_SetPowerState(EN_POWER_MODE u16PowerState);
1432 
1433 
1434 #ifdef __cplusplus
1435 }
1436 #endif
1437 
1438 #endif
1439