xref: /utopia/UTPA2-700.0.x/modules/dscmb/drv/dscmb2/drvDSCMB_private.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 #ifndef __DSCMB_PRIVATE__
2 #define __DSCMB_PRIVATE__
3 
4 #include "halDSCMB.h"
5 
6 #define MAGIC_NUM 0x12345678
7 
8 typedef enum {
9     E_DSCMB_RESOURCE,
10 } eDscmbResourceId;
11 
12 typedef struct
13 {
14     MS_U32 u32SlotIdOdd;
15     MS_U32 u32SlotIdEven;
16     MS_U32 u32SlotIdClear;
17     MS_U32 u32PidFltIdNum;
18     MS_BOOL bUsed;
19     MS_BOOL bDscmb;
20     MS_U32 u32Tsid;
21     DSCMB_Flt_Type eFltType;
22     MS_U32 u32CAVid;
23     MS_U32 u32RIVIdx;
24     MS_BOOL bSecure;
25 } stDscmbTspMap;
26 
27 typedef struct
28 {
29     MS_U32 u8DscmbId;
30     MS_U8 u8TsId;
31     MS_U8 u8CaVid;
32     MS_U8 u8CaDestUpp;
33     MS_U8 u8CaDestLow;
34 } stTspFltInfo;
35 
36 typedef struct _DSCMB_RESOURCE_PRIVATE
37 {
38     stTspFltInfo  u32PidFlt2Dscmb[HAL_DSCMB_PIDFLT_NUM];
39     stDscmbTspMap DscmbTspMap[HAL_DSCMB_ENG_NUM][HAL_DSCMB_KTE_MAX];
40     MS_BOOL       bFreeSlot[HAL_DSCMB_KTE_MAX];
41     MS_BOOL       bFreeRIVSlot[HAL_DSCMB_RIV_MAX];
42 
43     MS_U32        u32Cavid;
44     MS_BOOL       bInited_Drv;
45     MS_U32        u32Magic;
46 
47 } DSCMB_RESOURCE_PRIVATE;
48 
49 
50 typedef struct _DSCMB_INSTANT_PRIVATE
51 {
52 
53 } DSCMB_INSTANT_PRIVATE;
54 
55 
56 // descrambler initial function
57 MS_BOOL _MDrv_DSCMB2_Init(void);
58 MS_BOOL _MDrv_DSCMB2_InitBySWFlag(MS_BOOL bSWInit);
59 MS_BOOL _MDrv_DSCMB2_Exit(void);
60 
61 // descrambler filter management
62 MS_U32  _MDrv_DSCMB2_FltAlloc_Ex(MS_U32 u32EngId, DSCMB_Flt_Type eFltType);
63 MS_BOOL _MDrv_DSCMB2_FltFree(MS_U32 u32EngId, MS_U32 u32DscmbId);
64 
65 // descrambler filter maps to TSP pid
66 #if !(defined(MSOS_TYPE_OPTEE) || defined(MSOS_TYPE_NUTTX))
67 MS_BOOL _MDrv_DSCMB2_FltConnectPid(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32Pid);
68 MS_BOOL _MDrv_DSCMB2_FltDisconnectPid_Ex(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32Pid);
69 #endif
70 
71 // descrambler filter maps to TSP filter id
72 MS_BOOL _MDrv_DSCMB2_FltConnectFltId(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32FltId);
73 MS_BOOL _MDrv_DSCMB2_FltDisconnectFltId(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32FltId);
74 
75 MS_BOOL _MDrv_DSCMB2_SetDefaultCAVid(MS_U32 u32EngId, MS_U32 u32CAVid);
76 MS_BOOL _MDrv_DSCMB2_EngSetAlgo(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Algo_Cfg stConfig);
77 MS_BOOL _MDrv_DSCMB2_EngSetKeyFSCB(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Key_Type eKeyType, DSCMB_FSCB eForceSCB);
78 MS_BOOL _MDrv_DSCMB2_EngSetKey(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Key_Type eKeyType, MS_U8* pu8Key);
79 MS_BOOL _MDrv_DSCMB2_EngResetKey(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Key_Type eKeyType);
80 MS_BOOL _MDrv_DSCMB2_EngSetIV(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType, MS_U8* pu8IV);
81 MS_BOOL _MDrv_DSCMB2_EngSetIV_Ex(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eEngType, DSCMB_Key_Type eKeyType, MS_U8* pu8IV);
82 MS_BOOL _MDrv_DSCMB2_EngSetFSCB(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_FSCB eForceSCB );
83 MS_BOOL _MDrv_DSCMB2_EngSetSwitch(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Eng_Type eUppSwitch ,DSCMB_Eng_Type eLowSwitch);
84 
85 // descrambler for enable dual path
86 MS_BOOL _MDrv_DSCMB2_CAPVR_FlowSet(MS_U32 u32EngId, DSCMB_CAPVR_MODE eCaMode, DSCMB_TSIF ePvrSrcTSIf);
87 MS_BOOL _MDrv_DSCMB2_DualPath_Enable(MS_U32 u32EngId, MS_U32 u32FltId);
88 MS_BOOL _MDrv_DSCMB2_DualPath_Disable(MS_U32 u32EngId, MS_U32 u32FltId);
89 
90 // Set descrambler filter as scrambling/decrambling mode
91 // Default filter mode is descrambling if this function is not specified
92 // This function should be invoked before MDrv_DSCMB_FltTypeSet
93 MS_BOOL _MDrv_DSCMB2_FltDscmb(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_BOOL bDscmb);
94 MS_BOOL _MDrv_DSCMB2_FltTypeSet(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Type);
95 MS_BOOL _MDrv_DSCMB2_FltKeySet(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType, MS_U8* pu8Key);
96 MS_BOOL _MDrv_DSCMB2_FltKeyReset(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType);
97 MS_BOOL _MDrv_DSCMB2_FltIVSet(MS_U32 u32EngId, MS_U32 u32DscmbId, DSCMB_Key_Type eKeyType, MS_U8* pu8IV);
98 
99 
100 // descrambler query function
101 MS_BOOL _MDrv_DSCMB2_GetLibVer(const MSIF_Version **ppVersion);
102 MS_BOOL _MDrv_DSCMB2_SetDBGLevel(MS_U32 u32Level);
103 MS_BOOL _MDrv_DSCMB2_GetCap(MS_U32 u32EngId, DSCMB_Query_Type eQueryType, void* pInput, void* pOutput);
104 MS_BOOL _MDrv_DSCMB2_GetConnectStatus(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U32 u32TspFltId);
105 
106 // descrambler altorithm related
107 MS_BOOL _MDrv_DSCMB2_Multi2_SetRound(MS_U32 u32EngId, MS_U32 u32Round);
108 MS_BOOL _MDrv_DSCMB2_Multi2_SetSystemKey(MS_U32 u32EngId, MS_U8* pu8Syskey);
109 MS_BOOL _MDrv_DSCMB2_ES_SetStaticKey(MS_U32 u32EngId, MS_U8* pu8Statickey);
110 MS_BOOL _MDrv_DSCMB2_HDCP2_SetRIV(MS_U32 u32EngId, MS_U8* pu8RIV);
111 MS_BOOL _MDrv_DSCMB2_HDCP2_SetRIV_Ex(MS_U32 u32EngId, MS_U32 u32DscmbId, MS_U8* pu8RIV);
112 
113 MS_BOOL _MDrv_DSCMB2_PVR_RecCtrl(MS_U32 u32EngId, MS_BOOL Enable);
114 MS_U32  _MDrv_DSCMB2_SetPowerState(EN_POWER_MODE u16PowerState);
115 MS_BOOL _MDrv_DSCMB2_PidFlt_ScmbStatus(MS_U32 u32EngId, MS_U32 u32PidFltId, SCMB_Level* pScmbLevel);
116 
117 
118 // key ladder
119 MS_BOOL _MDrv_DSCMB2_KLadder_AtomicExec(DSCMB_KLCfg_All* KLCfg , MS_U8 *ACPU_Out, DSCMB_KL_Status* u32Status );
120 MS_BOOL _MDrv_DSCMB2_KLadder_ETSI(DSCMB_KLCfg_All* KLCfg , MS_U8 *ACPU_Out, MS_U8 *pu8Nonce, MS_U8 *pu8Response, DSCMB_KL_Status* u32Status);
121 
122 
123 #endif // __DSCMB_PRIVATE__
124 
125