xref: /utopia/UTPA2-700.0.x/modules/dscmb/utopia_adaption/dscmb2/DSCMB_adp.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 #include <linux/kernel.h>
2 #include <linux/string.h>
3 #include <linux/slab.h>
4 
5 #include "MsTypes.h"
6 #include "utopia.h"
7 #include "drvDSCMB.h"
8 #include "drvDSCMB_v2.h"
9 #include "DSCMB_adp.h"
10 
11 #include <linux/uaccess.h>
12 #include <linux/kernel.h>
13 #include <linux/compat.h>
14 
15 #include "utopia_adp.h"
16 
17 #ifdef MSOS_TYPE_LINUX_KERNEL
18 #define CPY_FROM_USER(a,b,c)                                    if(copy_from_user(a,b,c) != 0) { return UTOPIA_STATUS_FAIL; }
19 #define CPY_to_USER(a,b,c)                                      if(copy_to_user(a,b,c) != 0) { return UTOPIA_STATUS_FAIL; }
20 #else
21 #define CPY_FROM_USER                                           memcpy
22 #define CPY_to_USER                                             memcpy
23 #endif  //MSOS_TYPE_LINUX_KERNEL
24 
25 #if (defined(MSOS_TYPE_LINUX_KERNEL) && defined(CONFIG_COMPAT))
26 #define COMPAT_PTR(a)                                           compat_ptr(a)
27 #define IS_CMP_TASK()                                           is_compat_task()
28 #define CMP_CPY_FROM_USER(a,b,c)                                if(copy_from_user(a, compat_ptr((unsigned long)b), c) != 0)  {  return UTOPIA_STATUS_FAIL; }
29 #define CMP_CPY_TO_USER(a,b,c)                                  if(copy_to_user(compat_ptr((unsigned long)a), b, c) != 0) { return UTOPIA_STATUS_FAIL;  }
30 
31 #else
32 #define COMPAT_PTR(a)                                           (a)
33 #define IS_CMP_TASK()                                           (FALSE)
34 #define CMP_CPY_FROM_USER                                       CPY_FROM_USER
35 #define CMP_CPY_TO_USER                                         CPY_to_USER
36 #endif //CONFIG_COMPAT
37 
38 #define SPT_TYPE_A_SIZE 2
39 #define SPT_TYPE_B_SIZE 3
40 #define SPT_TYPE_C_SIZE 4
41 #define SPT_TYPE_D_SIZE 5
42 #define SPT_TYPE_E_SIZE 6
43 #define SPT_TYPE_F_SIZE 7
44 
45 #define UADP_SPT_NAME0NXT_SIZE(NAME,SIZE) \
46             UADP_SPT_BGN(&NAME [0],SIZE); \
47             UADP_SPT_FIN(&NAME [1]);
48 
49 #define UADP_SPT_NAME0NXT_TYPE(NAME,TYPE) \
50             UADP_SPT_BGN(&NAME [0],sizeof(TYPE)); \
51             UADP_SPT_FIN(&NAME [1]);
52 
53 #define UADP_SPT_NAME1NXT_TYPE(NAME,TYPE,MB1,MB1NAME) \
54             UADP_SPT_BGN(&NAME [0],sizeof(TYPE)); \
55             UADP_SPT_NXT(&NAME [1],TYPE,MB1,MB1NAME); \
56             UADP_SPT_FIN(&NAME [2]);
57 
58 #define UADP_SPT_NAME2NXT_TYPE(NAME,TYPE,MB1,MB1NAME,MB2,MB2NAME) \
59             UADP_SPT_BGN(&NAME [0],sizeof(TYPE)); \
60             UADP_SPT_NXT(&NAME [1],TYPE,MB1,MB1NAME); \
61             UADP_SPT_NXT(&NAME [2],TYPE,MB2,MB2NAME); \
62             UADP_SPT_FIN(&NAME [3]);
63 
64 #define UADP_SPT_NAME3NXT_TYPE(NAME,TYPE,MB1,MB1NAME,MB2,MB2NAME,MB3,MB3NAME) \
65             UADP_SPT_BGN(&NAME [0],sizeof(TYPE)); \
66             UADP_SPT_NXT(&NAME [1],TYPE,MB1,MB1NAME); \
67             UADP_SPT_NXT(&NAME [2],TYPE,MB2,MB2NAME); \
68             UADP_SPT_NXT(&NAME [3],TYPE,MB3,MB3NAME); \
69             UADP_SPT_FIN(&NAME [4]);
70 
71 #define UADP_SPT_NAME5NXT_TYPE(NAME,TYPE,MB1,MB1NAME,MB2,MB2NAME,MB3,MB3NAME,MB4,MB4NAME,MB5,MB5NAME) \
72             UADP_SPT_BGN(&NAME [0],sizeof(TYPE)); \
73             UADP_SPT_NXT(&NAME [1],TYPE,MB1,MB1NAME); \
74             UADP_SPT_NXT(&NAME [2],TYPE,MB2,MB2NAME); \
75             UADP_SPT_NXT(&NAME [3],TYPE,MB3,MB3NAME); \
76             UADP_SPT_NXT(&NAME [4],TYPE,MB4,MB4NAME); \
77             UADP_SPT_NXT(&NAME [5],TYPE,MB5,MB5NAME); \
78             UADP_SPT_FIN(&NAME [6]);
79 
80 //TOP
81 UADP_STRUCT_POINTER_TABLE spt_DSCMB_FltAlloc[SPT_TYPE_A_SIZE];
82 UADP_STRUCT_POINTER_TABLE spt_DSCMB_FltFree[SPT_TYPE_A_SIZE];
83 UADP_STRUCT_POINTER_TABLE spt_DSCMB_FltConnectFltId[SPT_TYPE_A_SIZE];
84 UADP_STRUCT_POINTER_TABLE spt_DSCMB_FltDisconnectFltId[SPT_TYPE_A_SIZE];
85 UADP_STRUCT_POINTER_TABLE spt_DSCMB_FltConnectPid[SPT_TYPE_A_SIZE];
86 UADP_STRUCT_POINTER_TABLE spt_DSCMB_FltDisconnectPid[SPT_TYPE_A_SIZE];
87 UADP_STRUCT_POINTER_TABLE spt_DSCMB_FltDscmb[SPT_TYPE_A_SIZE];
88 UADP_STRUCT_POINTER_TABLE spt_DSCMB_FltIVSet[SPT_TYPE_B_SIZE];
89 UADP_STRUCT_POINTER_TABLE spt_DSCMB_FltKeySet[SPT_TYPE_B_SIZE];
90 UADP_STRUCT_POINTER_TABLE spt_DSCMB_FltKeyReset[SPT_TYPE_A_SIZE];
91 UADP_STRUCT_POINTER_TABLE spt_DSCMB_FltTypeSet[SPT_TYPE_A_SIZE];
92 
93 UADP_STRUCT_POINTER_TABLE spt_DSCMB_EngSetAlgo[SPT_TYPE_A_SIZE];
94 UADP_STRUCT_POINTER_TABLE spt_DSCMB_EngSetKey[SPT_TYPE_B_SIZE];
95 UADP_STRUCT_POINTER_TABLE spt_DSCMB_EngResetKey[SPT_TYPE_A_SIZE];
96 UADP_STRUCT_POINTER_TABLE spt_DSCMB_EngSetKeyFSCB[SPT_TYPE_A_SIZE];
97 UADP_STRUCT_POINTER_TABLE spt_DSCMB_EngSetIV[SPT_TYPE_B_SIZE];
98 UADP_STRUCT_POINTER_TABLE spt_DSCMB_EngSetIV_Ex[SPT_TYPE_B_SIZE];
99 UADP_STRUCT_POINTER_TABLE spt_DSCMB_EngSetSwitch[SPT_TYPE_A_SIZE];
100 UADP_STRUCT_POINTER_TABLE spt_DSCMB_EngSetFSCB[SPT_TYPE_A_SIZE];
101 
102 UADP_STRUCT_POINTER_TABLE spt_DSCMB_SetDefaultCAVid[SPT_TYPE_A_SIZE];
103 UADP_STRUCT_POINTER_TABLE spt_DSCMB_HDCP2_SetRiv[SPT_TYPE_B_SIZE];
104 UADP_STRUCT_POINTER_TABLE spt_DSCMB_HDCP2_SetRiv_Ex[SPT_TYPE_B_SIZE];
105 UADP_STRUCT_POINTER_TABLE spt_DSCMB_Multi2_SetRound[SPT_TYPE_A_SIZE];
106 UADP_STRUCT_POINTER_TABLE spt_DSCMB_Multi2_SetSysKey[SPT_TYPE_B_SIZE];
107 UADP_STRUCT_POINTER_TABLE spt_DSCMB_CAPVR_FlowSet[SPT_TYPE_A_SIZE];
108 UADP_STRUCT_POINTER_TABLE spt_DSCMB_DualPath_Enable[SPT_TYPE_A_SIZE];
109 UADP_STRUCT_POINTER_TABLE spt_DSCMB_DualPath_Disable[SPT_TYPE_A_SIZE];
110 UADP_STRUCT_POINTER_TABLE spt_DSCMB_SetPowerState[SPT_TYPE_A_SIZE];
111 UADP_STRUCT_POINTER_TABLE spt_DSCMB_QueryCap[SPT_TYPE_C_SIZE];
112 UADP_STRUCT_POINTER_TABLE spt_DSCMB_SetDBGLevel[SPT_TYPE_A_SIZE];
113 UADP_STRUCT_POINTER_TABLE spt_DSCMB_GetConnectStatus[SPT_TYPE_A_SIZE];
114 UADP_STRUCT_POINTER_TABLE spt_DSCMB_PVR_RecCtrl[SPT_TYPE_A_SIZE];
115 UADP_STRUCT_POINTER_TABLE spt_DSCMB_PidFlt_ScmbStatus[SPT_TYPE_B_SIZE];
116 
117 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_AtomicExec[SPT_TYPE_D_SIZE];
118 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_AtomicExec_Lv2[SPT_TYPE_D_SIZE];
119 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_AtomicExec_Lv3[SPT_TYPE_D_SIZE];
120 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_AtomicExec_Lv4[SPT_TYPE_D_SIZE];
121 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_AtomicExec_Lv5[SPT_TYPE_D_SIZE];
122 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_ETSI[SPT_TYPE_F_SIZE];
123 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_ETSI_Lv2[SPT_TYPE_F_SIZE];
124 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_ETSI_Lv3[SPT_TYPE_F_SIZE];
125 
126 
127 //BOTTOM
128 UADP_STRUCT_POINTER_TABLE spt_DSCMB_PidFlt_ScmbStatus_pScmbLevel[SPT_TYPE_A_SIZE];
129 UADP_STRUCT_POINTER_TABLE spt_DSCMB_QueryCap_InOut[SPT_TYPE_A_SIZE];
130 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_KLCfg[SPT_TYPE_C_SIZE];
131 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_KLCfg_Lv2[SPT_TYPE_C_SIZE];
132 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_KLCfg_Lv3[SPT_TYPE_C_SIZE];
133 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_KLCfg_Lv4[SPT_TYPE_C_SIZE];
134 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_KLCfg_Lv5[SPT_TYPE_C_SIZE];
135 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_u32Status[SPT_TYPE_A_SIZE];
136 
137 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_ACPU_Out[SPT_TYPE_A_SIZE];
138 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_u8KeyACPU[SPT_TYPE_A_SIZE];
139 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_pu8KeyKLIn80[SPT_TYPE_A_SIZE];
140 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_pu8KeyKLIn64[SPT_TYPE_A_SIZE];
141 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_pu8KeyKLIn48[SPT_TYPE_A_SIZE];
142 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_pu8KeyKLIn32[SPT_TYPE_A_SIZE];
143 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_pu8KeyKLIn16[SPT_TYPE_A_SIZE];
144 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_pu8Nonse[SPT_TYPE_A_SIZE];
145 UADP_STRUCT_POINTER_TABLE spt_DSCMB_KLadder_pu8Response[SPT_TYPE_A_SIZE];
146 
147 UADP_STRUCT_POINTER_TABLE spt_DSCMB_pu8Buf80[SPT_TYPE_A_SIZE];
148 UADP_STRUCT_POINTER_TABLE spt_DSCMB_pu8Buf64[SPT_TYPE_A_SIZE];
149 UADP_STRUCT_POINTER_TABLE spt_DSCMB_pu8Buf48[SPT_TYPE_A_SIZE];
150 UADP_STRUCT_POINTER_TABLE spt_DSCMB_pu8Buf32[SPT_TYPE_A_SIZE];
151 UADP_STRUCT_POINTER_TABLE spt_DSCMB_pu8Buf16[SPT_TYPE_A_SIZE];
152 UADP_STRUCT_POINTER_TABLE spt_DSCMB_pu8Buf8[SPT_TYPE_A_SIZE];
153 
154 
DSCMB_adp_Init(FUtopiaIOctl * pIoctl)155 MS_U32 DSCMB_adp_Init(FUtopiaIOctl* pIoctl)
156 {
157     //TOP
158     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_SetPowerState, EN_POWER_MODE);
159     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_FltAlloc, DSCMB_FLTALLOC);
160     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_FltFree, DSCMB_FLTFREE);
161     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_FltConnectFltId, DSCMB_CONNECTFLT);
162     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_FltConnectPid, DSCMB_CONNECTPID);
163     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_FltDisconnectFltId, DSCMB_DISCONNECTFLT);
164     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_FltDisconnectPid, DSCMB_DISCONNECTPID);
165     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_FltDscmb, DSCMB_FLTDSCMB);
166     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_FltTypeSet, DSCMB_TYPESET);
167     UADP_SPT_NAME1NXT_TYPE(spt_DSCMB_FltKeySet, DSCMB_FLTKEYSET, pu8Key, spt_DSCMB_pu8Buf16);
168     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_FltKeyReset, DSCMB_FLTKEYRESET);
169     UADP_SPT_NAME1NXT_TYPE(spt_DSCMB_FltIVSet, DSCMB_FLTIVSET, pu8IV, spt_DSCMB_pu8Buf16);
170     UADP_SPT_NAME1NXT_TYPE(spt_DSCMB_HDCP2_SetRiv, DSCMB_HDCP2_SETRIV, pu8Riv, spt_DSCMB_pu8Buf8);
171     UADP_SPT_NAME1NXT_TYPE(spt_DSCMB_HDCP2_SetRiv_Ex, DSCMB_HDCP2_SETRIV_EX, pu8Riv, spt_DSCMB_pu8Buf8);
172     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_Multi2_SetRound, DSCMB_MULTI2_SETROUND);
173     UADP_SPT_NAME1NXT_TYPE(spt_DSCMB_Multi2_SetSysKey, DSCMB_MULTI2_SETSYSKEY, pu8SysKey, spt_DSCMB_pu8Buf32);
174     UADP_SPT_NAME1NXT_TYPE(spt_DSCMB_PidFlt_ScmbStatus, DSCMB_DSCMBSTATUS, pScmbLevel, spt_DSCMB_PidFlt_ScmbStatus_pScmbLevel);
175     UADP_SPT_NAME2NXT_TYPE(spt_DSCMB_QueryCap, DSCMB_QUERYCAP, pInput, spt_DSCMB_QueryCap_InOut, pOutput, spt_DSCMB_QueryCap_InOut);
176     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_PVR_RecCtrl, DSCMB_PVR_RECCTRL);
177     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_SetDefaultCAVid, DSCMB_DEFAULT_CAVID);
178     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_EngSetAlgo, DSCMB_ENGALGO);
179     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_EngSetKeyFSCB, DSCMB_ENGKEYFSCB);
180     UADP_SPT_NAME1NXT_TYPE(spt_DSCMB_EngSetKey, DSCMB_ENGKEY, pu8Key, spt_DSCMB_pu8Buf16);
181     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_EngResetKey, DSCMB_ENGRESETKEY);
182     UADP_SPT_NAME1NXT_TYPE(spt_DSCMB_EngSetIV, DSCMB_ENGIV, pu8IV, spt_DSCMB_pu8Buf16);
183     UADP_SPT_NAME1NXT_TYPE(spt_DSCMB_EngSetIV_Ex, DSCMB_ENGIV_EX, pu8IV, spt_DSCMB_pu8Buf16);
184     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_EngSetSwitch, DSCMB_ENGSWITCH);
185     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_EngSetFSCB, DSCMB_ENGFSCB);
186     UADP_SPT_NAME3NXT_TYPE(spt_DSCMB_KLadder_AtomicExec, DSCMB_KL_ATOMICEXEC,
187                            KLCfg,     spt_DSCMB_KLadder_KLCfg,
188                            ACPU_Out,  spt_DSCMB_KLadder_ACPU_Out,
189                            u32Status, spt_DSCMB_KLadder_u32Status);
190     UADP_SPT_NAME3NXT_TYPE(spt_DSCMB_KLadder_AtomicExec_Lv2, DSCMB_KL_ATOMICEXEC,
191                            KLCfg,     spt_DSCMB_KLadder_KLCfg_Lv2,
192                            ACPU_Out,  spt_DSCMB_KLadder_ACPU_Out,
193                            u32Status, spt_DSCMB_KLadder_u32Status);
194     UADP_SPT_NAME3NXT_TYPE(spt_DSCMB_KLadder_AtomicExec_Lv3, DSCMB_KL_ATOMICEXEC,
195                            KLCfg,     spt_DSCMB_KLadder_KLCfg_Lv3,
196                            ACPU_Out,  spt_DSCMB_KLadder_ACPU_Out,
197                            u32Status, spt_DSCMB_KLadder_u32Status);
198     UADP_SPT_NAME3NXT_TYPE(spt_DSCMB_KLadder_AtomicExec_Lv4, DSCMB_KL_ATOMICEXEC,
199                            KLCfg,     spt_DSCMB_KLadder_KLCfg_Lv4,
200                            ACPU_Out,  spt_DSCMB_KLadder_ACPU_Out,
201                            u32Status, spt_DSCMB_KLadder_u32Status);
202     UADP_SPT_NAME3NXT_TYPE(spt_DSCMB_KLadder_AtomicExec_Lv5, DSCMB_KL_ATOMICEXEC,
203                            KLCfg,     spt_DSCMB_KLadder_KLCfg_Lv5,
204                            ACPU_Out,  spt_DSCMB_KLadder_ACPU_Out,
205                            u32Status, spt_DSCMB_KLadder_u32Status);
206 
207     UADP_SPT_NAME5NXT_TYPE(spt_DSCMB_KLadder_ETSI, DSCMB_KL_ETSI,
208                            KLCfg,       spt_DSCMB_KLadder_KLCfg,
209                            ACPU_Out,    spt_DSCMB_KLadder_ACPU_Out,
210                            pu8Nonce,    spt_DSCMB_KLadder_pu8Nonse,
211                            pu8Response, spt_DSCMB_KLadder_pu8Response,
212                            u32Status,   spt_DSCMB_KLadder_u32Status);
213 
214     UADP_SPT_NAME5NXT_TYPE(spt_DSCMB_KLadder_ETSI_Lv2, DSCMB_KL_ETSI,
215                            KLCfg,       spt_DSCMB_KLadder_KLCfg_Lv2,
216                            ACPU_Out,    spt_DSCMB_KLadder_ACPU_Out,
217                            pu8Nonce,    spt_DSCMB_KLadder_pu8Nonse,
218                            pu8Response, spt_DSCMB_KLadder_pu8Response,
219                            u32Status,   spt_DSCMB_KLadder_u32Status);
220 
221     UADP_SPT_NAME5NXT_TYPE(spt_DSCMB_KLadder_ETSI_Lv3, DSCMB_KL_ETSI,
222                            KLCfg,       spt_DSCMB_KLadder_KLCfg_Lv3,
223                            ACPU_Out,    spt_DSCMB_KLadder_ACPU_Out,
224                            pu8Nonce,    spt_DSCMB_KLadder_pu8Nonse,
225                            pu8Response, spt_DSCMB_KLadder_pu8Response,
226                            u32Status,   spt_DSCMB_KLadder_u32Status);
227 
228     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_SetDBGLevel, MS_U32);
229     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_GetConnectStatus, DSCMB_CONNECTSTATUS);
230     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_CAPVR_FlowSet, DSCMB_CAPVR_FLOWSET);
231     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_DualPath_Enable, DSCMB_DUALPATH);
232     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_DualPath_Disable, DSCMB_DUALPATH);
233 
234 
235 
236     //BOTTOM
237     UADP_SPT_NAME2NXT_TYPE(spt_DSCMB_KLadder_KLCfg, DSCMB_KLCfg_All,
238                            u8KeyACPU,  spt_DSCMB_KLadder_u8KeyACPU,
239                            pu8KeyKLIn, spt_DSCMB_KLadder_pu8KeyKLIn16);
240     UADP_SPT_NAME2NXT_TYPE(spt_DSCMB_KLadder_KLCfg_Lv2, DSCMB_KLCfg_All,
241                            u8KeyACPU,  spt_DSCMB_KLadder_u8KeyACPU,
242                            pu8KeyKLIn, spt_DSCMB_KLadder_pu8KeyKLIn32);
243     UADP_SPT_NAME2NXT_TYPE(spt_DSCMB_KLadder_KLCfg_Lv3, DSCMB_KLCfg_All,
244                            u8KeyACPU,  spt_DSCMB_KLadder_u8KeyACPU,
245                            pu8KeyKLIn, spt_DSCMB_KLadder_pu8KeyKLIn48);
246     UADP_SPT_NAME2NXT_TYPE(spt_DSCMB_KLadder_KLCfg_Lv4, DSCMB_KLCfg_All,
247                            u8KeyACPU,  spt_DSCMB_KLadder_u8KeyACPU,
248                            pu8KeyKLIn, spt_DSCMB_KLadder_pu8KeyKLIn64);
249     UADP_SPT_NAME2NXT_TYPE(spt_DSCMB_KLadder_KLCfg_Lv5, DSCMB_KLCfg_All,
250                            u8KeyACPU,  spt_DSCMB_KLadder_u8KeyACPU,
251                            pu8KeyKLIn, spt_DSCMB_KLadder_pu8KeyKLIn80);
252     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_KLadder_u32Status, DSCMB_KL_Status);
253 
254     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_KLadder_ACPU_Out, sizeof(MS_U8)*16);
255     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_KLadder_u8KeyACPU, sizeof(MS_U8)*16);
256     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_KLadder_pu8KeyKLIn16, sizeof(MS_U8)*16);
257     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_KLadder_pu8KeyKLIn32, sizeof(MS_U8)*32);
258     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_KLadder_pu8KeyKLIn48, sizeof(MS_U8)*48);
259     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_KLadder_pu8KeyKLIn64, sizeof(MS_U8)*64);
260     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_KLadder_pu8KeyKLIn80, sizeof(MS_U8)*80);
261 
262     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_PidFlt_ScmbStatus_pScmbLevel, SCMB_Level);
263     UADP_SPT_NAME0NXT_TYPE(spt_DSCMB_QueryCap_InOut, MS_U32);
264 
265     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_pu8Buf80, sizeof(MS_U8)*80);
266     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_pu8Buf64, sizeof(MS_U8)*64);
267     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_pu8Buf48, sizeof(MS_U8)*48);
268     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_pu8Buf32, sizeof(MS_U8)*32);
269     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_pu8Buf16, sizeof(MS_U8)*16);
270     UADP_SPT_NAME0NXT_SIZE(spt_DSCMB_pu8Buf8, sizeof(MS_U8)*8);
271 
272     *pIoctl = (FUtopiaIOctl)DSCMB_adp_Ioctl;
273 
274     return 0;
275 
276 }
277 
278 
DSCMB_adp_Ioctl(void * pInstanceTmp,MS_U32 u32Cmd,void * const pArgs)279 MS_U32 DSCMB_adp_Ioctl(void* pInstanceTmp, MS_U32 u32Cmd, void* const pArgs)
280 {
281     MS_U32 u32Ret = 0;
282     char buffer_arg[128];
283     char buffer_array0[128];
284     UADP_STRUCT_POINTER_TABLE* sptPtr=NULL;
285     DSCMB_KL_ATOMICEXEC* pKLAtomicArgs=NULL;
286     DSCMB_KL_ETSI* pKLETSIArgs=NULL;
287     DSCMB_KLCfg_All*   KLCfg=NULL;
288 
289     switch(u32Cmd)
290     {
291         case E_MDRV_CMD_DSCMB_Init:
292             u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, pArgs);
293             break;
294         case E_MDRV_CMD_DSCMB_Exit:
295             u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, pArgs);
296             break;
297         case E_MDRV_CMD_DSCMB_SetPowerState:
298             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_SetPowerState, NULL, buffer_arg, sizeof(buffer_arg));
299             break;
300         case E_MDRV_CMD_DSCMB_FltAlloc:
301             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_FltAlloc, spt_DSCMB_FltAlloc, buffer_arg, sizeof(buffer_arg));
302             break;
303         case E_MDRV_CMD_DSCMB_FltFree:
304             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_FltFree, NULL, buffer_arg, sizeof(buffer_arg));
305             break;
306         case E_MDRV_CMD_DSCMB_FltConnectFltId:
307             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_FltConnectFltId, NULL, buffer_arg, sizeof(buffer_arg));
308             break;
309         case E_MDRV_CMD_DSCMB_FltConnectPid:
310             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_FltConnectPid, NULL, buffer_arg, sizeof(buffer_arg));
311             break;
312         case E_MDRV_CMD_DSCMB_FltDisconnectFltId:
313             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_FltDisconnectFltId, NULL, buffer_arg, sizeof(buffer_arg));
314             break;
315         case E_MDRV_CMD_DSCMB_FltDisconnectPid:
316             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_FltDisconnectPid, NULL, buffer_arg, sizeof(buffer_arg));
317             break;
318         case E_MDRV_CMD_DSCMB_FltDscmb:
319             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_FltDscmb, NULL, buffer_arg, sizeof(buffer_arg));
320             break;
321         case E_MDRV_CMD_DSCMB_FltTypeSet:
322             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_FltTypeSet, NULL, buffer_arg, sizeof(buffer_arg));
323             break;
324         case E_MDRV_CMD_DSCMB_FltKeySet:
325             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_FltKeySet, NULL, buffer_arg, sizeof(buffer_arg));
326             break;
327         case E_MDRV_CMD_DSCMB_FltKeyReset:
328             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_FltKeyReset, NULL, buffer_arg, sizeof(buffer_arg));
329             break;
330         case E_MDRV_CMD_DSCMB_FltIVSet:
331             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_FltIVSet, NULL, buffer_arg, sizeof(buffer_arg));
332             break;
333         case E_MDRV_CMD_DSCMB_HDCP2_SetRiv:
334             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_HDCP2_SetRiv, NULL, buffer_arg, sizeof(buffer_arg));
335             break;
336         case E_MDRV_CMD_DSCMB_Multi2_SetRound:
337             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_Multi2_SetRound, NULL, buffer_arg, sizeof(buffer_arg));
338             break;
339         case E_MDRV_CMD_DSCMB_Multi2_SetSysKey:
340             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_Multi2_SetSysKey, NULL, buffer_arg, sizeof(buffer_arg));
341             break;
342         case E_MDRV_CMD_DSCMB_PidFlt_ScmbStatus:
343             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_PidFlt_ScmbStatus, spt_DSCMB_PidFlt_ScmbStatus, buffer_arg, sizeof(buffer_arg));
344             break;
345         case E_MDRV_CMD_DSCMB_PVR_RecCtrl:
346             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_PVR_RecCtrl, NULL, buffer_arg, sizeof(buffer_arg));
347             break;
348         case E_MDRV_CMD_DSCMB_SetDefaultCAVid:
349             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_SetDefaultCAVid, NULL, buffer_arg, sizeof(buffer_arg));
350             break;
351         case E_MDRV_CMD_DSCMB_EngSetAlgo:
352             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_EngSetAlgo, NULL, buffer_arg, sizeof(buffer_arg));
353             break;
354         case E_MDRV_CMD_DSCMB_EngSetKeyFSCB:
355             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_EngSetKeyFSCB, NULL, buffer_arg, sizeof(buffer_arg));
356             break;
357         case E_MDRV_CMD_DSCMB_EngSetKey:
358             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_EngSetKey, NULL, buffer_arg, sizeof(buffer_arg));
359             break;
360         case E_MDRV_CMD_DSCMB_EngResetKey:
361             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_EngResetKey, NULL, buffer_arg, sizeof(buffer_arg));
362             break;
363         case E_MDRV_CMD_DSCMB_EngSetIV:
364             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_EngSetIV, NULL, buffer_arg, sizeof(buffer_arg));
365             break;
366         case E_MDRV_CMD_DSCMB_EngSetSwitch:
367             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_EngSetSwitch, NULL, buffer_arg, sizeof(buffer_arg));
368             break;
369         case E_MDRV_CMD_DSCMB_EngSetFSCB:
370             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_EngSetFSCB, NULL, buffer_arg, sizeof(buffer_arg));
371             break;
372         case E_MDRV_CMD_DSCMB_KLadder_AtomicExec:
373             pKLAtomicArgs = (DSCMB_KL_ATOMICEXEC*)buffer_arg;
374 
375             if (IS_CMP_TASK())
376             {
377                 CMP_CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DSCMB_KL_ATOMICEXEC));
378                 CMP_CPY_FROM_USER((void*)buffer_array0, (void*)pKLAtomicArgs->KLCfg, sizeof(DSCMB_KLCfg_All));
379                 pKLAtomicArgs->KLCfg = (DSCMB_KLCfg_All*)buffer_array0;
380             }
381             else
382             {
383                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DSCMB_KL_ATOMICEXEC));
384                 CPY_FROM_USER((void*)buffer_array0, (void*)pKLAtomicArgs->KLCfg, sizeof(DSCMB_KLCfg_All));
385                 pKLAtomicArgs->KLCfg = (DSCMB_KLCfg_All*)buffer_array0;
386             }
387 
388             sptPtr  = spt_DSCMB_KLadder_AtomicExec;
389             if(pKLAtomicArgs->KLCfg->u32Level == 1)
390             {
391                 sptPtr = spt_DSCMB_KLadder_AtomicExec;
392             }
393             else if(pKLAtomicArgs->KLCfg->u32Level == 2)
394             {
395                 sptPtr = spt_DSCMB_KLadder_AtomicExec_Lv2;
396             }
397             else if(pKLAtomicArgs->KLCfg->u32Level == 3)
398             {
399                 sptPtr = spt_DSCMB_KLadder_AtomicExec_Lv3;
400             }
401             else if(pKLAtomicArgs->KLCfg->u32Level == 4)
402             {
403                 sptPtr = spt_DSCMB_KLadder_AtomicExec_Lv4;
404             }
405             else if(pKLAtomicArgs->KLCfg->u32Level == 5)
406             {
407                 sptPtr = spt_DSCMB_KLadder_AtomicExec_Lv5;
408             }
409 
410             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, sptPtr, sptPtr, buffer_arg, sizeof(buffer_arg));
411             break;
412         case E_MDRV_CMD_DSCMB_KLadder_ETSI:
413             pKLETSIArgs = (DSCMB_KL_ETSI*)buffer_arg;
414 
415             if (IS_CMP_TASK())
416             {
417                 CMP_CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DSCMB_KL_ETSI));
418                 CMP_CPY_FROM_USER((void*)buffer_array0, (void*)pKLETSIArgs->KLCfg, sizeof(DSCMB_KLCfg_All));
419                 pKLETSIArgs->KLCfg = (DSCMB_KLCfg_All*)buffer_array0;
420             }
421             else
422             {
423                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DSCMB_KL_ETSI));
424                 CPY_FROM_USER((void*)buffer_array0, (void*)pKLETSIArgs->KLCfg, sizeof(DSCMB_KLCfg_All));
425                 pKLETSIArgs->KLCfg = (DSCMB_KLCfg_All*)buffer_array0;
426             }
427             sptPtr  = spt_DSCMB_KLadder_ETSI;
428 
429             if(pKLETSIArgs->KLCfg->u32Level == 1)
430             {
431                 sptPtr = spt_DSCMB_KLadder_ETSI;
432             }
433             else if(pKLETSIArgs->KLCfg->u32Level == 2)
434             {
435                 sptPtr = spt_DSCMB_KLadder_ETSI_Lv2;
436             }
437             else if(pKLETSIArgs->KLCfg->u32Level == 3)
438             {
439                 sptPtr = spt_DSCMB_KLadder_ETSI_Lv3;
440             }
441 
442             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, sptPtr, sptPtr, buffer_arg, sizeof(buffer_arg));
443             break;
444         case E_MDRV_CMD_DSCMB_QueryCap:
445             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_QueryCap, spt_DSCMB_QueryCap, buffer_arg, sizeof(buffer_arg));
446             break;
447         case E_MDRV_CMD_DSCMB_SetDBGLevel:
448             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_SetDBGLevel, NULL, buffer_arg, sizeof(buffer_arg));
449             break;
450         //case E_MDRV_CMD_DSCMB_GetLibVer:
451         //    u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs, , NULL,buffer_arg,sizeof(buffer_arg));
452         //    break;
453         case E_MDRV_CMD_DSCMB_GetConnectStatus:
454             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_GetConnectStatus, NULL, buffer_arg, sizeof(buffer_arg));
455             break;
456         case E_MDRV_CMD_DSCMB_HDCP2_SetRiv_Ex:
457             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_HDCP2_SetRiv_Ex, NULL, buffer_arg, sizeof(buffer_arg));
458             break;
459         case E_MDRV_CMD_DSCMB_CAPVR_FlowSet:
460             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_CAPVR_FlowSet, NULL, buffer_arg, sizeof(buffer_arg));
461             break;
462         case E_MDRV_CMD_DSCMB_DualPath_Enable:
463             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_DualPath_Enable, NULL, buffer_arg, sizeof(buffer_arg));
464             break;
465         case E_MDRV_CMD_DSCMB_DualPath_Disable:
466             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_DualPath_Disable, NULL, buffer_arg, sizeof(buffer_arg));
467             break;
468         case E_MDRV_CMD_DSCMB_EngSetIV_Ex:
469             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DSCMB_EngSetIV_Ex, NULL, buffer_arg, sizeof(buffer_arg));
470             break;
471         default:
472             break;
473     };
474 
475     return u32Ret;
476 }
477