xref: /utopia/UTPA2-700.0.x/modules/dmx/utopia_adaption/dmx/DMX_adp.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2014 - 2016 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) 2014-2016 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  DMX_adp.c
98 /// @brief  Demux adaption API
99 /// @author MStar Semiconductor,Inc.
100 ////////////////////////////////////////////////////////////////////////////////////////////////////
101 #ifdef MSOS_TYPE_LINUX_KERNEL
102 #include <linux/uaccess.h>
103 #include <linux/kernel.h>
104 #include <linux/compat.h>
105 
106 #include "apiDMX.h"
107 #include "apiDMX_tsio.h"
108 #include "apiDMX_private.h"
109 #include "DMX_adp.h"
110 
111 #include "utopia.h"
112 #include "utopia_adp.h"
113 
114 extern UADP_STRUCT_POINTER_TABLE spt_MS_NULL[];
115 //-------------------------------------------------------------------------------------------------
116 //  Driver Compiler Options
117 //-------------------------------------------------------------------------------------------------
118 
119 //-------------------------------------------------------------------------------------------------
120 //  Global Variables
121 //-------------------------------------------------------------------------------------------------
122 
123 // MApi_CMD_DMX_TSPInit_GetConfig
124 UADP_SDT_NAMEn_DEF(DMX_TSPParam, 0);
125 
126 // MApi_CMD_DMX_Info_Ex
127 UADP_SDT_NAMEn_DEF(DMX_FLT_INFO_PARAM_Ex, 1);
128 UADP_SDT_NAMEn_DEF(DMX_Flt_info_Ex, 1);
129 UADP_SDT_NAMEn_DEF(DMX_Sect_info_Ex, 2);
130 UADP_SDT_NAMEn_DEF(DMX_Sect_info, 2);
131 //-------------------------------------------------------------------------------------------------
132 //  Local Defines
133 //-------------------------------------------------------------------------------------------------
134 #ifdef MSOS_TYPE_LINUX_KERNEL
135 #define CPY_FROM_USER(a,b,c)                                    if(copy_from_user(a,b,c) != 0) { return UTOPIA_STATUS_FAIL; }
136 #define CPY_to_USER(a,b,c)                                      if(copy_to_user(a,b,c) != 0) { return UTOPIA_STATUS_FAIL; }
137 #else
138 #define CPY_FROM_USER                                           memcpy
139 #define CPY_to_USER                                             memcpy
140 #endif  //MSOS_TYPE_LINUX_KERNEL
141 
142 #if (defined(MSOS_TYPE_LINUX_KERNEL) && defined(CONFIG_COMPAT))
143 #define COMPAT_PTR(a)                                           compat_ptr(a)
144 #define IS_CMP_TASK()                                           is_compat_task()
145 #define CMP_CPY_FROM_USER(a,b,c)                                if(copy_from_user(a, compat_ptr((unsigned long)b), c) != 0)  {  return UTOPIA_STATUS_FAIL; }
146 #define CMP_CPY_TO_USER(a,b,c)                                  if(copy_to_user(compat_ptr((unsigned long)a), b, c) != 0) { return UTOPIA_STATUS_FAIL;  }
147 
148 #else
149 #define COMPAT_PTR(a)                                           (a)
150 #define IS_CMP_TASK()                                           (FALSE)
151 #define CMP_CPY_FROM_USER                                       CPY_FROM_USER
152 #define CMP_CPY_TO_USER                                         CPY_to_USER
153 #endif //CONFIG_COMPAT
154 
155 
156 #define DMX_ADP_MSG(_f, _a...)                                  //printf(_f, ##_a)
157 
158 #define LEN_U32_X1                                              4UL
159 #define LEN_U32_X2                                              8UL
160 #define LEN_U32_X3                                              12UL
161 #define LEN_U32_X4                                              16UL
162 
163 #ifdef BIFROST_32BIT_MODE
164 #define LEN_MSPHY                                               4UL
165 #else
166 #define LEN_MSPHY                                               sizeof(MS_PHY)
167 #endif
168 
169 //-------------------------------------------------------------------------------------------------
170 //  Local Structures
171 //-------------------------------------------------------------------------------------------------
172 
173 //-------------------------------------------------------------------------------------------------
174 //  Local Variables
175 //-------------------------------------------------------------------------------------------------
176 
177 
178 //-------------------------------------------------------------------------------------------------
179 //  Local Functions
180 //-------------------------------------------------------------------------------------------------
181 
182 
183 //-------------------------------------------------------------------------------------------------
184 //  Global Functions
185 //-------------------------------------------------------------------------------------------------
DMX_adp_Init(FUtopiaIOctl * pIoctl)186 MS_U32 DMX_adp_Init(FUtopiaIOctl *pIoctl)
187 {
188     //MApi_CMD_DMX_TSPInit_GetConfig
189     UADP_SPT_BGN(&spt_DMX_TSPParam[0], sizeof(DMX_TSPParam));
190     UADP_SPT_FIN(&spt_DMX_TSPParam[1]);
191 
192     //MApi_CMD_DMX_Info_Ex
193     //MApi_CMD_DMX_Open_Ex
194 
195     UADP_SPT_BGN(&spt_DMX_Sect_info[0], sizeof(DMX_Sect_info));
196     UADP_SDT_KIND(&spt_DMX_Sect_info[1], DMX_Sect_info, UADP_SDT_AT, pNotify, spt_MS_NULL);
197     UADP_SDT_KIND(&spt_DMX_Sect_info[2], DMX_Sect_info, UADP_SDT_AT, pType2Notify, spt_MS_NULL);
198     UADP_SPT_FIN(&spt_DMX_Sect_info[3]);
199 
200     UADP_SPT_BGN(&spt_DMX_Sect_info_Ex[0], sizeof(DMX_Sect_info_Ex));
201     //UADP_SDT_KIND(&spt_DMX_Sect_info_Ex[1], DMX_Sect_info_Ex, UADP_SDT_ES, Info, spt_DMX_Sect_info);
202     UADP_SDT_KIND(&spt_DMX_Sect_info_Ex[1], DMX_Sect_info_Ex, UADP_SDT_AT, pType2Notify_Ex, spt_MS_NULL);
203     UADP_SDT_KIND(&spt_DMX_Sect_info_Ex[2], DMX_Sect_info_Ex, UADP_SDT_AT, pType2NotifyParamEx, spt_MS_NULL);
204     UADP_SPT_FIN(&spt_DMX_Sect_info_Ex[3]);
205 
206     UADP_SPT_BGN(&spt_DMX_Flt_info_Ex[0], sizeof(DMX_Flt_info_Ex));
207     UADP_SDT_KIND(&spt_DMX_Flt_info_Ex[1], DMX_Flt_info_Ex, UADP_SDT_ES, SectInfoEx, spt_DMX_Sect_info_Ex);
208     UADP_SPT_FIN(&spt_DMX_Flt_info_Ex[2]);
209 
210     UADP_SPT_BGN(&spt_DMX_FLT_INFO_PARAM_Ex[0], sizeof(DMX_FLT_INFO_PARAM_Ex));
211     UADP_SDT_KIND(&spt_DMX_FLT_INFO_PARAM_Ex[1], DMX_FLT_INFO_PARAM_Ex, UADP_SDT_P2N, pDmxFltInfo, spt_DMX_Flt_info_Ex);
212     UADP_SPT_FIN(&spt_DMX_FLT_INFO_PARAM_Ex[2]);
213 
214     //MApi_CMD_DMX_Open_Ex
215     *pIoctl= (FUtopiaIOctl)DMX_adp_Ioctl;
216     return 0;
217 }
218 
DMX_adp_Ioctl(void * pInstanceTmp,MS_U32 u32Cmd,void * const pArgs)219 MS_U32 DMX_adp_Ioctl(void* pInstanceTmp, MS_U32 u32Cmd, void* const pArgs)
220 {
221     MS_S8*                          ps8AdpSrc = (MS_S8*)pArgs;
222 
223     MS_U32                          u32ii = 0, u32Ret = UTOPIA_STATUS_FAIL, u32data = 1;
224     MS_U32                          u32InSize = 0, u32OutSize = 0;
225 
226     MS_S8                           buffer_arg[640];
227     MS_S8                           buffer_array0[320];
228     MS_S8                           buffer_array1[320];
229     MS_S8                           buffer_array2[64];
230     MS_S8                           buffer_array3[16];
231     MS_S8                           buffer_array4[16];
232     MS_U32                          u32NextPtr = 0, u32NextPtrOut = 0, u32NextPtr1 = 0, u32NextPtr2 = 0, u32NextPtr3 = 0;
233     void                            *pNxtPtr = 0, *pNxtPtrOut = 0, *pNxtPtr1 = 0;
234 
235     DMX_CAP_PARAM                   stCapParam;
236     PDMX_TSO_OUTCLK_PARAM           pstTsoOutClkDes     = NULL;
237 
238     DMX_TSPParam                    *pTspParamDec       = NULL;
239     PDMX_WP_PARAM                   pstWPParamDes       = NULL;
240     PDMX_CAP_PARAM                  pstCapParamDes      = NULL;
241     PDMX_CAP_EX_PARAM               pstCapExParamDes    = NULL;
242     PDMX_FLT_INFO_PARAM             pstFltInfoDes       = NULL;
243     PDMX_FLT_EVENT_PARAM            pFltEventDes        = NULL;
244     PDMX_FLT_SEC_PAT_PARAM          pFltSecPatDes       = NULL;
245     PDMX_CMDRUN_PARAM               pstCmdRunDes        = NULL;
246     PDMX_PKT_DISCONCNT_PARAM        pstDicConCntDes     = NULL;
247     PDMX_PKT_DROPCNT_PARAM          pstDropCntDes       = NULL;
248     PDMX_PKT_LOCKCNT_PARAM          pstLockCntDes       = NULL;
249     PDMX_PKT_AVCNT_PARAM            pstAVPktCntDes      = NULL;
250     PDMX_TSO_LOCSTRID_PARAM         pstTsoLocStrIdDes   = NULL;
251     PDMX_FQ_INIT_PARAM              pstFqInitDes        = NULL;
252     PDMX_MSTR_SYNCBY_PARAM          pstMstrSynByDes     = NULL;
253     PDMX_POWSTATE_PARAM             pstPowerStateDes    = NULL;
254     PDMX_PVR_INFO_PARAM             pstPvrInfoDes       = NULL;
255     PDMX_FILE_START_PARAM           pstFileStartDes     = NULL;
256     PDMX_FILE_INFO_PARAM            pstFileInfoDes      = NULL;
257     PDMX_MMFI_START_PARAM           pstMMFIStartDes     = NULL;
258     DMX_OutputPad_Cfg               *pstOutPadCfgDes    = NULL;
259     PDMX_FLT_COPY_PARAM             pstDmxFltCpyDes     = NULL;
260     DMX_TSO_Cfg                     *pstTSOCfg          = NULL;
261     DMX_FQ_Cfg                      *pstFqCfg           = NULL;
262     PDMX_TSIO_Service_SetDMAoutVC_PARAM         pstTsioDoutDes      = NULL;
263     PDMX_TSIO_Service_SetDMAinVC_PARAM          pstTsioDinDes       = NULL;
264     PDMX_TSIO_Service_SetLocdecKey_PARAM        pstTsioLocDes       = NULL;
265     PDMX_TSIO_Service_PidOpen_PARAM             pstTsioPidDes       = NULL;
266     PDMX_TSIO_Service_Alloc_PARAM               pstTsioAlcDes       = NULL;
267     PDMX_TSIO_RegisterIntCb_PARAM               pstTsioCbDes        = NULL;
268     PDMX_TSIO_Init_PARAM                        pstTsioInitDes      = NULL;
269     PDMX_TSIO_CC_PARAM                          pstTsioCcDes        = NULL;
270     PDMX_TSIO_GetInfo_PARAM                     pstTsioGetInfoDes   = NULL;
271     PDMX_TSIO_Service_DMAout_WriteGet_PARAM     pstTsioDWriteDes    = NULL;
272 
273     //printf("[DMX] S %d\n", (int)u32Cmd);
274 
275     switch(u32Cmd)
276     {
277         // General API
278         case MApi_CMD_DMX_Init:
279         case MApi_CMD_DMX_Resume:
280             pTspParamDec = (DMX_TSPParam*)buffer_arg;
281 
282             if(IS_CMP_TASK())
283             {
284                 pTspParamDec->phyFWAddr = 0;
285                 CMP_CPY_FROM_USER((void*)&(pTspParamDec->phyFWAddr), ps8AdpSrc, LEN_MSPHY);
286                 ps8AdpSrc += LEN_MSPHY;
287                 CMP_CPY_FROM_USER((void*)&(pTspParamDec->u32FWSize), ps8AdpSrc, LEN_U32_X1);
288                 ps8AdpSrc += LEN_U32_X1;
289                 pTspParamDec->phyVQAddr = 0;
290                 CMP_CPY_FROM_USER((void*)&(pTspParamDec->phyVQAddr), ps8AdpSrc, LEN_MSPHY);
291                 ps8AdpSrc += LEN_MSPHY;
292                 CMP_CPY_FROM_USER((void*)&(pTspParamDec->u32VQSize), ps8AdpSrc, 20);  //U32 x 5
293                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
294                 ps8AdpSrc += LEN_U32_X2;
295                 CMP_CPY_TO_USER(ps8AdpSrc, (void*)&(pTspParamDec->u32Res), LEN_U32_X1);
296             }
297             else
298             {
299                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSPParam));
300                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
301                 CPY_to_USER(pArgs, (void*)buffer_arg, sizeof(DMX_TSPParam));
302             }
303             break;
304 
305         case MApi_CMD_DMX_WProtectEnable:
306             pstWPParamDes = (PDMX_WP_PARAM)buffer_arg;
307 
308             stCapParam.Quetype = DMX_CAP_TSP_HWWP_SET_NUM;
309             stCapParam.pdata = (void*)&u32data;
310             u32Ret = UtopiaIoctl(pInstanceTmp,MApi_CMD_DMX_GetCap,(void*)&stCapParam);
311 
312             if(IS_CMP_TASK())
313             {
314                 MS_PHY* pphy = (MS_PHY*)buffer_array0;
315                 MS_PHY* pphy1 = (MS_PHY*)buffer_array1;
316 
317                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, 1);
318                 ps8AdpSrc += 1;
319                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
320                 ps8AdpSrc += LEN_U32_X1;
321                 CMP_CPY_FROM_USER(&u32NextPtr1, ps8AdpSrc, LEN_U32_X1);
322                 for(u32ii = 0; u32ii < u32data; u32ii++, pphy++, pphy1++)
323                 {
324                     *pphy = 0;  *pphy1 = 0;
325                     CMP_CPY_FROM_USER((void*)pphy, u32NextPtr, LEN_MSPHY);
326                     CMP_CPY_FROM_USER((void*)pphy1, u32NextPtr1, LEN_MSPHY);
327                     u32NextPtr += LEN_MSPHY;
328                     u32NextPtr1 += LEN_MSPHY;
329                 }
330             }
331             else
332             {
333                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_WP_PARAM));
334                 CPY_FROM_USER((void*)buffer_array0, (void*)pstWPParamDes->pu32StartAddr, sizeof(MS_PHY) * u32data);
335                 CPY_FROM_USER((void*)buffer_array1, (void*)pstWPParamDes->pu32EndAddr, sizeof(MS_PHY) * u32data);
336             }
337             pstWPParamDes->pu32StartAddr = (MS_PHY*)buffer_array0;
338             pstWPParamDes->pu32EndAddr = (MS_PHY*)buffer_array1;
339             u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
340             break;
341 
342         case MApi_CMD_DMX_SetPowerState:
343             pstPowerStateDes = (PDMX_POWSTATE_PARAM)buffer_arg;
344 
345             if(IS_CMP_TASK())
346             {
347                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X2);
348                 ps8AdpSrc += LEN_U32_X2;
349                 pstPowerStateDes->u32FWAddr = 0;
350                 CMP_CPY_FROM_USER((void*)&(pstPowerStateDes->u32FWAddr), ps8AdpSrc, LEN_MSPHY);
351                 ps8AdpSrc += LEN_MSPHY;
352                 CMP_CPY_FROM_USER((void*)&(pstPowerStateDes->u32FWSize), ps8AdpSrc, LEN_U32_X1);
353                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
354                 CMP_CPY_TO_USER(pArgs, (void*)&(pstPowerStateDes->u32Res), LEN_U32_X1);
355             }
356             else
357             {
358                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_POWSTATE_PARAM));
359                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
360                 CPY_to_USER(pArgs, buffer_arg, sizeof(DMX_POWSTATE_PARAM));
361             }
362             break;
363 
364         case MApi_CMD_DMX_GetCap:
365             pstCapParamDes = (PDMX_CAP_PARAM)buffer_arg;
366 
367             if(IS_CMP_TASK())
368             {
369                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X2);
370                 ps8AdpSrc += LEN_U32_X2;
371                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
372                 if((pstCapParamDes->Quetype >= DMX_CAP_SHAREKEY_FLT_RANGE) && (pstCapParamDes->Quetype <= DMX_CAP_SHAREKEY_FLT2_RANGE))
373                 {
374                     u32data = 2;
375                 }
376                 pstCapParamDes->pdata = (void*)buffer_array0;
377                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
378                 CMP_CPY_TO_USER(u32NextPtr, buffer_array0, sizeof(MS_U32) * u32data);
379                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
380             }
381             else
382             {
383                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_CAP_PARAM));
384                 if((pstCapParamDes->Quetype >= DMX_CAP_SHAREKEY_FLT_RANGE) && (pstCapParamDes->Quetype <= DMX_CAP_SHAREKEY_FLT2_RANGE))
385                 {
386                     u32data = 2;
387                 }
388                 pNxtPtr = pstCapParamDes->pdata;
389                 pstCapParamDes->pdata = (void*)buffer_array0;
390                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
391                 CPY_to_USER(pNxtPtr, pstCapParamDes->pdata, sizeof(MS_U32) * u32data);
392                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
393             }
394             break;
395 
396         case MApi_CMD_DMX_GetCapEx:
397             pstCapExParamDes = (PDMX_CAP_EX_PARAM)buffer_arg;
398 
399             if(IS_CMP_TASK())
400             {
401                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X3);
402                 ps8AdpSrc += LEN_U32_X3;
403                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
404                 ps8AdpSrc += LEN_U32_X1;
405                 CMP_CPY_FROM_USER(&u32NextPtr1, ps8AdpSrc, LEN_U32_X1);
406                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, pstCapExParamDes->InputStrLen);
407                 pstCapExParamDes->StrQuetype = (char*)buffer_array0;
408                 pstCapExParamDes->pdata = (void*)buffer_array1;
409                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
410                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X3);
411                 CMP_CPY_TO_USER(u32NextPtr1, pstCapExParamDes->pdata, pstCapExParamDes->OutputSize);
412             }
413             else
414             {
415                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_CAP_EX_PARAM));
416                 CPY_FROM_USER((void*)buffer_array0, pstCapExParamDes->StrQuetype, pstCapExParamDes->InputStrLen);
417                 pNxtPtr = pstCapExParamDes->pdata;
418                 pstCapExParamDes->StrQuetype = (char*)buffer_array0;
419                 pstCapExParamDes->pdata = (void*)buffer_array1;
420                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
421                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X3);
422                 CPY_to_USER(pNxtPtr, pstCapExParamDes->pdata, pstCapExParamDes->OutputSize);
423             }
424             break;
425 
426         case MApi_CMD_DMX_OutPadCfg:
427             pstOutPadCfgDes = (DMX_OutputPad_Cfg*)buffer_arg;
428 
429             if(IS_CMP_TASK())
430             {
431                 pstOutPadCfgDes->pu32Resv = (void*)buffer_array0;
432 
433                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, 17);
434                 ps8AdpSrc += 17;
435                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
436                 CMP_CPY_FROM_USER((void*)pstOutPadCfgDes->pu32Resv, u32NextPtr, LEN_U32_X1);
437                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
438                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
439             }
440             else
441             {
442                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_OutputPad_Cfg));
443                 CPY_FROM_USER((void*)buffer_array0, (void*)pstOutPadCfgDes->pu32Resv, LEN_U32_X1);
444                 pstOutPadCfgDes->pu32Resv = (void*)buffer_array0;
445                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
446                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
447             }
448             break;
449 
450         case MApi_CMD_DMX_Info:
451             pstFltInfoDes = (PDMX_FLT_INFO_PARAM)buffer_arg;
452 
453             if(IS_CMP_TASK())
454             {
455                 pstFltInfoDes->pDmxFltInfo = (DMX_Flt_info*)buffer_array0;
456                 pstFltInfoDes->pDmxFltType = (DMX_FILTER_TYPE*)buffer_array1;
457 
458                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X2);
459                 ps8AdpSrc += LEN_U32_X2;
460                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
461                 ps8AdpSrc += LEN_U32_X1;
462                 CMP_CPY_FROM_USER(&u32NextPtr1, ps8AdpSrc, LEN_U32_X1);
463                 ps8AdpSrc += LEN_U32_X1;
464                 CMP_CPY_FROM_USER((void*)&(pstFltInfoDes->bSet), ps8AdpSrc, 1);
465                 if(pstFltInfoDes->bSet == TRUE)
466                 {
467                     CMP_CPY_FROM_USER((void*)buffer_array1, u32NextPtr1, LEN_U32_X1);
468                     if((*(pstFltInfoDes->pDmxFltType) == DMX_FILTER_TYPE_VIDEO) || (*(pstFltInfoDes->pDmxFltType) == DMX_FILTER_TYPE_AUDIO) ||
469                         (*(pstFltInfoDes->pDmxFltType) == DMX_FILTER_TYPE_AUDIO2) || (*(pstFltInfoDes->pDmxFltType) == DMX_FILTER_TYPE_VIDEO3D) ||
470                         (*(pstFltInfoDes->pDmxFltType) == DMX_FILTER_TYPE_AUDIO3) || (*(pstFltInfoDes->pDmxFltType) == DMX_FILTER_TYPE_AUDIO4))
471                     {
472                         CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, LEN_U32_X1);
473                     }
474                     else
475                     {
476                         DMX_Sect_info* pinfo = &(pstFltInfoDes->pDmxFltInfo->Info.SectInfo);
477 
478                         pinfo->SectBufAddr = 0;
479                         CMP_CPY_FROM_USER((void*)&(pinfo->SectBufAddr), u32NextPtr, LEN_MSPHY);
480                         u32NextPtr += LEN_MSPHY;
481                         CMP_CPY_FROM_USER((void*)&(pinfo->SectBufSize), u32NextPtr, LEN_U32_X3);
482                         u32NextPtr += LEN_U32_X3;
483                         pinfo->pNotify = 0;
484                         CMP_CPY_FROM_USER((void*)&(pinfo->pNotify), u32NextPtr, LEN_U32_X1);
485                         u32NextPtr += LEN_U32_X1;
486                         pinfo->pType2Notify = 0;
487                         CMP_CPY_FROM_USER((void*)&(pinfo->pType2Notify), u32NextPtr, LEN_U32_X1);
488                         u32NextPtr += LEN_U32_X1;
489                         CMP_CPY_FROM_USER((void*)&(pinfo->Type2NotifyParam1), u32NextPtr, LEN_U32_X1);
490                     }
491                 }
492                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
493                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
494                 if(pstFltInfoDes->bSet == FALSE)
495                 {
496                     CMP_CPY_TO_USER(u32NextPtr1, (void*)buffer_array1, LEN_U32_X1);
497                     if((*(pstFltInfoDes->pDmxFltType) == DMX_FILTER_TYPE_VIDEO) || (*(pstFltInfoDes->pDmxFltType) == DMX_FILTER_TYPE_AUDIO) ||
498                         (*(pstFltInfoDes->pDmxFltType) == DMX_FILTER_TYPE_AUDIO2) || (*(pstFltInfoDes->pDmxFltType) == DMX_FILTER_TYPE_VIDEO3D) ||
499                         (*(pstFltInfoDes->pDmxFltType) == DMX_FILTER_TYPE_AUDIO3) || (*(pstFltInfoDes->pDmxFltType) == DMX_FILTER_TYPE_AUDIO4))
500                     {
501                         CMP_CPY_TO_USER(u32NextPtr, (void*)buffer_array0, LEN_U32_X1);
502                     }
503                     else
504                     {
505                         DMX_Sect_info* pinfo = &(pstFltInfoDes->pDmxFltInfo->Info.SectInfo);
506 
507                         pinfo->SectBufAddr = 0;
508                         CMP_CPY_TO_USER(u32NextPtr, &(pinfo->SectBufAddr), LEN_MSPHY);
509                         u32NextPtr += LEN_MSPHY;
510                         CMP_CPY_TO_USER(u32NextPtr, &(pinfo->SectBufSize), LEN_U32_X3);
511                         u32NextPtr += LEN_U32_X3;
512                         CMP_CPY_TO_USER(u32NextPtr, (void*)&(pinfo->pNotify), LEN_U32_X1);
513                         u32NextPtr += LEN_U32_X1;
514                         CMP_CPY_TO_USER(u32NextPtr, (void*)&(pinfo->pType2Notify), LEN_U32_X1);
515                         u32NextPtr += LEN_U32_X1;
516                         CMP_CPY_TO_USER(u32NextPtr, &(pinfo->Type2NotifyParam1), LEN_U32_X1);
517                     }
518                 }
519             }
520             else
521             {
522                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_FLT_INFO_PARAM));
523                 if(pstFltInfoDes->bSet == TRUE)
524                 {
525                     CPY_FROM_USER((void*)buffer_array0, (void*)pstFltInfoDes->pDmxFltInfo, sizeof(DMX_Flt_info));
526                     CPY_FROM_USER((void*)buffer_array1, (void*)pstFltInfoDes->pDmxFltType, sizeof(DMX_FILTER_TYPE));
527                 }
528                 pNxtPtr = (void*)pstFltInfoDes->pDmxFltInfo;
529                 pNxtPtr1 = (void*)pstFltInfoDes->pDmxFltType;
530                 pstFltInfoDes->pDmxFltInfo = (DMX_Flt_info*)buffer_array0;
531                 pstFltInfoDes->pDmxFltType = (DMX_FILTER_TYPE*)buffer_array1;
532                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
533 
534                 if(pstFltInfoDes->bSet == FALSE)
535                 {
536                     CPY_to_USER(pNxtPtr, (void*)buffer_array0, sizeof(DMX_Flt_info));
537                     CPY_to_USER(pNxtPtr1, (void*)buffer_array1, sizeof(DMX_FILTER_TYPE));
538                 }
539                 CPY_to_USER(pArgs, (void*)&(pstFltInfoDes->u32Res), LEN_U32_X1);
540             }
541             break;
542 
543         case MApi_CMD_DMX_Info_Ex:
544             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_DMX_FLT_INFO_PARAM_Ex,spt_DMX_FLT_INFO_PARAM_Ex,NULL,0);
545             break;
546 
547         case MApi_CMD_DMX_CopyData:  //core function must do copy_to_user for mem copy
548             pstDmxFltCpyDes = (PDMX_FLT_COPY_PARAM)buffer_arg;
549             if(IS_CMP_TASK())
550             {
551                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, 20);
552                 ps8AdpSrc += 20;
553                 pstDmxFltCpyDes->pfCheckCB = 0;
554                 CMP_CPY_FROM_USER((void*)&(pstDmxFltCpyDes->pfCheckCB), ps8AdpSrc, LEN_U32_X1);
555                 ps8AdpSrc += LEN_U32_X1;
556                 pstDmxFltCpyDes->pu8Buf = 0;
557                 CMP_CPY_FROM_USER((void*)&(pstDmxFltCpyDes->pu8Buf), ps8AdpSrc, LEN_U32_X1);
558                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
559                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, 20);
560             }
561             else
562             {
563                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_FLT_COPY_PARAM));
564                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
565                 CPY_to_USER((void*)pArgs, (void*)buffer_arg, sizeof(DMX_FLT_COPY_PARAM));
566             }
567             break;
568 
569         case MApi_CMD_DMX_Proc:
570             pFltEventDes = (PDMX_FLT_EVENT_PARAM)buffer_arg;
571 
572             if(IS_CMP_TASK())
573             {
574                 pFltEventDes->pEvent = (DMX_EVENT*)buffer_array0;
575                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X2);
576                 ps8AdpSrc += LEN_U32_X2;
577                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
578                 u32NextPtrOut = u32NextPtr;
579                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(DMX_EVENT));
580                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
581                 CMP_CPY_TO_USER(u32NextPtrOut, (void*)buffer_array0, sizeof(DMX_EVENT));
582                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
583             }
584             else
585             {
586                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_FLT_EVENT_PARAM));
587                 CPY_FROM_USER((void*)buffer_array0, (void*)pFltEventDes->pEvent, sizeof(DMX_EVENT));
588                 pNxtPtrOut = pFltEventDes->pEvent;
589                 pFltEventDes->pEvent = (DMX_EVENT*)buffer_array0;
590                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
591                 CPY_to_USER(pNxtPtrOut, (void*)pFltEventDes->pEvent, sizeof(DMX_EVENT));
592                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
593             }
594             break;
595 
596         case MApi_CMD_DMX_Sec_SetPattern:
597             pFltSecPatDes = (PDMX_FLT_SEC_PAT_PARAM)buffer_arg;
598 
599             if(IS_CMP_TASK())
600             {
601                 pFltSecPatDes->pu8Pattern   = (MS_U8*)buffer_array0;
602                 pFltSecPatDes->pu8Mask      = (MS_U8*)buffer_array1;
603                 pFltSecPatDes->pu8NotMask   = (MS_U8*)buffer_array2;
604 
605                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X3);
606                 ps8AdpSrc += LEN_U32_X3;
607                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
608                 ps8AdpSrc += LEN_U32_X1;
609                 CMP_CPY_FROM_USER(&u32NextPtr1, ps8AdpSrc, LEN_U32_X1);
610                 ps8AdpSrc += LEN_U32_X1;
611                 CMP_CPY_FROM_USER(&u32NextPtr2, ps8AdpSrc, LEN_U32_X1);
612                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, pFltSecPatDes->u32MatchSize);
613                 CMP_CPY_FROM_USER((void*)buffer_array1, u32NextPtr1, pFltSecPatDes->u32MatchSize);
614                 CMP_CPY_FROM_USER((void*)buffer_array2, u32NextPtr2, pFltSecPatDes->u32MatchSize);
615                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
616                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
617             }
618             else
619             {
620                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_FLT_SEC_PAT_PARAM));
621                 CPY_FROM_USER(buffer_array0, pFltSecPatDes->pu8Pattern, pFltSecPatDes->u32MatchSize);
622                 CPY_FROM_USER(buffer_array1, pFltSecPatDes->pu8Mask, pFltSecPatDes->u32MatchSize);
623                 CPY_FROM_USER(buffer_array2, pFltSecPatDes->pu8NotMask, pFltSecPatDes->u32MatchSize);
624                 pFltSecPatDes->pu8Pattern   = (MS_U8*)buffer_array0;
625                 pFltSecPatDes->pu8Mask      = (MS_U8*)buffer_array1;
626                 pFltSecPatDes->pu8NotMask   = (MS_U8*)buffer_array2;
627                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
628                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
629             }
630             break;
631 
632         case MApi_CMD_DMX_Pvr_Open:
633             pstPvrInfoDes = (PDMX_PVR_INFO_PARAM)buffer_arg;
634 
635             if(IS_CMP_TASK())
636             {
637                 pstPvrInfoDes->pPvrInfo = (DMX_Pvr_info*)buffer_array0;
638                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X2);
639                 ps8AdpSrc += LEN_U32_X2;
640                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X2);
641                 u32NextPtrOut = u32NextPtr;
642                 pstPvrInfoDes->pPvrInfo->pPvrBuf0 = 0;
643                 CMP_CPY_FROM_USER((void*)&(pstPvrInfoDes->pPvrInfo->pPvrBuf0), u32NextPtr, LEN_MSPHY);
644                 u32NextPtr += LEN_MSPHY;
645                 pstPvrInfoDes->pPvrInfo->pPvrBuf1 = 0;
646                 CMP_CPY_FROM_USER((void*)&(pstPvrInfoDes->pPvrInfo->pPvrBuf1), u32NextPtr, LEN_MSPHY);
647                 u32NextPtr += LEN_MSPHY;
648                 CMP_CPY_FROM_USER((void*)&(pstPvrInfoDes->pPvrInfo->PvrBufSize0), u32NextPtr, LEN_U32_X3);
649                 u32NextPtr += LEN_U32_X3;
650                 CMP_CPY_FROM_USER((void*)&(pstPvrInfoDes->pPvrInfo->pNotify), u32NextPtr, LEN_U32_X1);
651                 u32NextPtr += LEN_U32_X1;
652                 CMP_CPY_FROM_USER((void*)&(pstPvrInfoDes->pPvrInfo->u16CaPvrModel), u32NextPtr, 3);
653                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
654                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
655                 if(pstPvrInfoDes->u32Res == DMX_FILTER_STATUS_OK)
656                 {
657                     CMP_CPY_TO_USER(u32NextPtrOut, (void*)&(pstPvrInfoDes->pPvrInfo->pPvrBuf0), LEN_MSPHY);
658                     u32NextPtrOut += LEN_MSPHY;
659                     CMP_CPY_TO_USER(u32NextPtrOut, (void*)&(pstPvrInfoDes->pPvrInfo->pPvrBuf1), LEN_MSPHY);
660                     u32NextPtrOut += LEN_MSPHY;
661                     CMP_CPY_TO_USER(u32NextPtrOut, (void*)&(pstPvrInfoDes->pPvrInfo->PvrBufSize0), LEN_U32_X2);
662                 }
663             }
664             else
665             {
666                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_PVR_INFO_PARAM));
667                 CPY_FROM_USER((void*)buffer_array0, (void*)pstPvrInfoDes->pPvrInfo, sizeof(DMX_Pvr_info));
668                 pNxtPtr = (void*)pstPvrInfoDes->pPvrInfo;
669                 pstPvrInfoDes->pPvrInfo = (DMX_Pvr_info*)buffer_array0;
670                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
671                 CPY_to_USER((void*)pNxtPtr, (void*)buffer_array0, sizeof(DMX_Pvr_info));
672                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
673             }
674             break;
675 
676         case MApi_CMD_DMX_FI_Start:
677             pstFileStartDes = (PDMX_FILE_START_PARAM)buffer_arg;
678 
679             if(IS_CMP_TASK())
680             {
681                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X3);
682                 ps8AdpSrc += LEN_U32_X3;
683                 pstFileStartDes->pBuf = 0;
684                 CMP_CPY_FROM_USER((void*)&(pstFileStartDes->pBuf), ps8AdpSrc, LEN_MSPHY);
685                 ps8AdpSrc += LEN_MSPHY;
686                 CMP_CPY_FROM_USER((void*)&(pstFileStartDes->u32BufSize), ps8AdpSrc, LEN_U32_X1);
687                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
688                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
689                 if(pstFileStartDes->u32Res == DMX_FILTER_STATUS_OK)
690                 {
691                     ps8AdpSrc = (MS_S8*)pArgs;
692                     ps8AdpSrc += LEN_U32_X3;
693                     CMP_CPY_TO_USER(ps8AdpSrc, (void*)&(pstFileStartDes->pBuf), LEN_MSPHY);
694                     ps8AdpSrc += LEN_MSPHY;
695                     CMP_CPY_TO_USER(ps8AdpSrc, (void*)&(pstFileStartDes->u32BufSize), LEN_U32_X1);
696                 }
697             }
698             else
699             {
700                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_FILE_START_PARAM));
701                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
702                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
703             }
704             break;
705 
706         case MApi_CMD_DMX_FI_Info:
707         case MApi_CMD_DMX_FI_Eng_Info:
708             pstFileInfoDes = (PDMX_FILE_INFO_PARAM)buffer_arg;
709 
710             if(IS_CMP_TASK())
711             {
712                 pstFileInfoDes->pFileinInfo = (DMX_Filein_info*)buffer_array0;
713                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X2);
714                 ps8AdpSrc += LEN_U32_X2;
715                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
716                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(DMX_Filein_info));
717                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
718                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
719             }
720             else
721             {
722                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_FILE_INFO_PARAM));
723                 CPY_FROM_USER((void*)buffer_array0, pstFileInfoDes->pFileinInfo, sizeof(DMX_Filein_info));
724                 pstFileInfoDes->pFileinInfo = (DMX_Filein_info*)buffer_array0;
725                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
726                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
727             }
728             break;
729 
730         case MApi_CMD_DMX_MMFI_Start:
731             pstMMFIStartDes = (PDMX_MMFI_START_PARAM)buffer_arg;
732 
733             if(IS_CMP_TASK())
734             {
735                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X3);
736                 ps8AdpSrc += LEN_U32_X3;
737                 pstMMFIStartDes->pBuf = 0;
738                 CMP_CPY_FROM_USER((void*)&(pstMMFIStartDes->pBuf), ps8AdpSrc, LEN_MSPHY);
739                 ps8AdpSrc += LEN_MSPHY;
740                 CMP_CPY_FROM_USER((void*)&(pstMMFIStartDes->u32BufSize), ps8AdpSrc, LEN_U32_X1);
741                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
742                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
743                 if(pstMMFIStartDes->u32Res == DMX_FILTER_STATUS_OK)
744                 {
745                     ps8AdpSrc = (MS_S8*)pArgs;
746                     ps8AdpSrc += LEN_U32_X3;
747                     CMP_CPY_TO_USER(ps8AdpSrc, (void*)&(pstMMFIStartDes->pBuf), LEN_MSPHY);
748                     ps8AdpSrc += LEN_MSPHY;
749                     CMP_CPY_TO_USER(ps8AdpSrc, (void*)&(pstMMFIStartDes->u32BufSize), LEN_U32_X1);
750                 }
751             }
752             else
753             {
754                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_MMFI_START_PARAM));
755                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
756                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
757             }
758             break;
759 
760         case MApi_CMD_DMX_CmdRun:
761             pstCmdRunDes = (PDMX_CMDRUN_PARAM)buffer_arg;
762 
763             if(IS_CMP_TASK())
764             {
765                 pstCmdRunDes->pData = (void*)buffer_array0;
766                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X4);
767                 ps8AdpSrc += LEN_U32_X4;
768                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
769                 if(pstCmdRunDes->u32DataNum > 0)
770                 {
771                     CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(MS_U32) * pstCmdRunDes->u32DataNum);
772                 }
773                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
774                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
775             }
776             else
777             {
778                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_CMDRUN_PARAM));
779                 if(pstCmdRunDes->u32DataNum > 0)
780                 {
781                     CPY_FROM_USER((void*)buffer_array0, pstCmdRunDes->pData, sizeof(MS_U32) * pstCmdRunDes->u32DataNum);
782                 }
783                 pstCmdRunDes->pData = (void*)buffer_array0;
784                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
785                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
786             }
787             break;
788 
789         case MApi_CMD_DMX_TSPInit_1_0:
790             pTspParamDec = (DMX_TSPParam*)buffer_arg;
791 
792             if(IS_CMP_TASK())
793             {
794                 pTspParamDec->phyFWAddr = 0;
795                 CMP_CPY_FROM_USER((void*)&(pTspParamDec->phyFWAddr), ps8AdpSrc, LEN_MSPHY);
796                 ps8AdpSrc += LEN_MSPHY;
797                 CMP_CPY_FROM_USER((void*)&(pTspParamDec->u32FWSize), ps8AdpSrc, LEN_U32_X1);
798                 ps8AdpSrc += LEN_U32_X1;
799                 pTspParamDec->phyVQAddr = 0;
800                 CMP_CPY_FROM_USER((void*)&(pTspParamDec->phyVQAddr), ps8AdpSrc, LEN_MSPHY);
801                 ps8AdpSrc += LEN_MSPHY;
802                 CMP_CPY_FROM_USER((void*)&(pTspParamDec->u32VQSize), ps8AdpSrc, 20);
803                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
804                 ps8AdpSrc += LEN_U32_X2;
805                 CMP_CPY_TO_USER(ps8AdpSrc, (void*)&(pTspParamDec->u32Res), LEN_U32_X1);
806             }
807             else
808             {
809                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSPParam));
810                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
811                 CPY_to_USER(pArgs, (void*)buffer_arg, sizeof(DMX_TSPParam));
812             }
813             break;
814 
815         case MApi_CMD_DMX_TSPInit_GetConfig:
816             u32Ret = UADPBypassIoctl(pInstanceTmp, u32Cmd, pArgs, spt_DMX_TSPParam, spt_DMX_TSPParam, buffer_arg, sizeof(buffer_arg));
817             break;
818 
819         case MApi_CMD_DMX_TSO_FileInfo:
820             pstFileInfoDes = (PDMX_FILE_INFO_PARAM)buffer_arg;
821 
822             if(IS_CMP_TASK())
823             {
824                 pstFileInfoDes->pFileinInfo = (DMX_Filein_info*)buffer_array0;
825                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X2);
826                 ps8AdpSrc += LEN_U32_X2;
827                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
828                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(DMX_Filein_info));
829                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
830                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
831             }
832             else
833             {
834                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_FILE_INFO_PARAM));
835                 CPY_FROM_USER((void*)buffer_array0, pstFileInfoDes->pFileinInfo, sizeof(DMX_Filein_info));
836                 pstFileInfoDes->pFileinInfo = (DMX_Filein_info*)buffer_array0;
837                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
838                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
839             }
840             break;
841 
842         // DBG INFO API
843         case MApi_CMD_DMX_DBG_GET_DISCONCNT:
844             pstDicConCntDes = (PDMX_PKT_DISCONCNT_PARAM)buffer_arg;
845 
846             if(IS_CMP_TASK())
847             {
848                 pstDicConCntDes->pInfo = (DMX_DisContiCnt_info*)buffer_array0;
849                 ps8AdpSrc += LEN_U32_X1;
850                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
851                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(DMX_DisContiCnt_info));
852                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
853                 ps8AdpSrc = (MS_S8*)pArgs;
854                 CMP_CPY_TO_USER(ps8AdpSrc, (void*)buffer_arg, LEN_U32_X1);
855                 ps8AdpSrc += LEN_U32_X2;
856                 CMP_CPY_TO_USER(ps8AdpSrc, (void*)&(pstDicConCntDes->u32Cnt), LEN_U32_X1);
857             }
858             else
859             {
860                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_PKT_DISCONCNT_PARAM));
861                 CPY_FROM_USER((void*)buffer_array0, (void*)(pstDicConCntDes->pInfo), sizeof(DMX_DisContiCnt_info));
862                 pstDicConCntDes->pInfo = (DMX_DisContiCnt_info*)buffer_array0;
863                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
864                 CPY_to_USER(pArgs, (void*)buffer_arg, sizeof(DMX_PKT_DISCONCNT_PARAM));
865             }
866             break;
867 
868         case MApi_CMD_DMX_DBG_GET_DROPPKTCNT:
869             pstDropCntDes = (PDMX_PKT_DROPCNT_PARAM)buffer_arg;
870 
871             if(IS_CMP_TASK())
872             {
873                 pstDropCntDes->pInfo = (DMX_DropPktCnt_info*)buffer_array0;
874                 ps8AdpSrc += LEN_U32_X1;
875                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
876                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(DMX_DropPktCnt_info));
877                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
878                 ps8AdpSrc = (MS_S8*)pArgs;
879                 CMP_CPY_TO_USER(ps8AdpSrc, (void*)buffer_arg, LEN_U32_X1);
880                 ps8AdpSrc += LEN_U32_X2;
881                 CMP_CPY_TO_USER(ps8AdpSrc, (void*)&(pstDropCntDes->u32Cnt), LEN_U32_X1);
882             }
883             else
884             {
885                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_PKT_DROPCNT_PARAM));
886                 CPY_FROM_USER((void*)buffer_array0, (void*)(pstDropCntDes->pInfo), sizeof(DMX_DropPktCnt_info));
887                 pstDropCntDes->pInfo = (DMX_DropPktCnt_info*)buffer_array0;
888                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
889                 CPY_to_USER(pArgs, (void*)buffer_arg, sizeof(DMX_PKT_DROPCNT_PARAM));
890             }
891             break;
892 
893         case MApi_CMD_DMX_DBG_GET_LOCKPKTCNT:
894             pstLockCntDes = (PDMX_PKT_LOCKCNT_PARAM)buffer_arg;
895 
896             if(IS_CMP_TASK())
897             {
898                 pstLockCntDes->pInfo = (DMX_LockPktCnt_info*)buffer_array0;
899                 ps8AdpSrc += LEN_U32_X1;
900                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
901                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(DMX_LockPktCnt_info));
902                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
903                 ps8AdpSrc = (MS_S8*)pArgs;
904                 CMP_CPY_TO_USER(ps8AdpSrc, (void*)buffer_arg, LEN_U32_X1);
905                 ps8AdpSrc += LEN_U32_X2;
906                 CMP_CPY_TO_USER(ps8AdpSrc, (void*)&(pstLockCntDes->u32Cnt), LEN_U32_X1);
907             }
908             else
909             {
910                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_PKT_LOCKCNT_PARAM));
911                 CPY_FROM_USER((void*)buffer_array0, (void*)(pstLockCntDes->pInfo), sizeof(DMX_LockPktCnt_info));
912                 pstLockCntDes->pInfo = (DMX_LockPktCnt_info*)buffer_array0;
913                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
914                 ps8AdpSrc = (MS_S8*)pArgs;
915                 CPY_to_USER((void*)ps8AdpSrc, (void*)buffer_arg, LEN_U32_X1);
916                 ps8AdpSrc += LEN_U32_X2;
917                 CPY_to_USER((void*)ps8AdpSrc, (void*)&(pstLockCntDes->u32Cnt), LEN_U32_X1);
918             }
919             break;
920 
921         case MApi_CMD_DMX_DBG_GET_AVPKTCNT:
922             pstAVPktCntDes = (PDMX_PKT_AVCNT_PARAM)buffer_arg;
923 
924             if(IS_CMP_TASK())
925             {
926                 pstAVPktCntDes->pInfo = (DMX_AVPktCnt_info*)buffer_array0;
927                 ps8AdpSrc += LEN_U32_X1;
928                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
929                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(DMX_AVPktCnt_info));
930                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
931                 ps8AdpSrc = (MS_S8*)pArgs;
932                 CMP_CPY_TO_USER(ps8AdpSrc, (void*)buffer_arg, LEN_U32_X1);
933                 ps8AdpSrc += LEN_U32_X2;
934                 CMP_CPY_TO_USER(ps8AdpSrc, (void*)&(pstAVPktCntDes->u32Cnt), LEN_U32_X1);
935             }
936             else
937             {
938                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_PKT_AVCNT_PARAM));
939                 CPY_FROM_USER((void*)buffer_array0, (void*)(pstAVPktCntDes->pInfo), sizeof(DMX_AVPktCnt_info));
940                 pstAVPktCntDes->pInfo = (DMX_AVPktCnt_info*)buffer_array0;
941                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
942                 ps8AdpSrc = (MS_S8*)pArgs;
943                 CPY_to_USER((void*)ps8AdpSrc, (void*)buffer_arg, LEN_U32_X1);
944                 ps8AdpSrc += LEN_U32_X2;
945                 CPY_to_USER((void*)ps8AdpSrc, (void*)&(pstAVPktCntDes->u32Cnt), LEN_U32_X1);
946             }
947             break;
948 
949         case MApi_CMD_DMX_TSO_LocStrId:
950             pstTsoLocStrIdDes = (PDMX_TSO_LOCSTRID_PARAM)buffer_arg;
951 
952             if(IS_CMP_TASK())
953             {
954                 pstTsoLocStrIdDes->pu8StrId = (MS_U8*)buffer_array0;
955                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, 9);
956                 ps8AdpSrc += 9;
957                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
958                 ps8AdpSrc += LEN_U32_X1;
959                 CMP_CPY_FROM_USER((void*)&(pstTsoLocStrIdDes->bSet), ps8AdpSrc, 1);
960                 if(pstTsoLocStrIdDes->bSet == TRUE)
961                 {
962                     CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, 1);
963                 }
964                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
965                 if(pstTsoLocStrIdDes->bSet == FALSE)
966                 {
967                     CMP_CPY_TO_USER(u32NextPtr, (void*)buffer_array0, 1);
968                 }
969                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
970             }
971             else
972             {
973                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSO_LOCSTRID_PARAM));
974                 if(pstTsoLocStrIdDes->bSet == TRUE)
975                 {
976                     CPY_FROM_USER((void*)buffer_array0, (void*)(pstTsoLocStrIdDes->pu8StrId), sizeof(MS_U8));
977                 }
978                 pNxtPtr = (void*)pstTsoLocStrIdDes->pu8StrId;
979                 pstTsoLocStrIdDes->pu8StrId = (MS_U8*)buffer_array0;
980                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
981 
982                 if(pstTsoLocStrIdDes->bSet == FALSE)
983                 {
984                     CPY_to_USER(pNxtPtr, (void*)(pstTsoLocStrIdDes->pu8StrId),sizeof(MS_U8));
985                 }
986                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
987             }
988             break;
989 
990         case MApi_CMD_DMX_FQ_Init:
991             pstFqInitDes = (PDMX_FQ_INIT_PARAM)buffer_arg;
992 
993             if(IS_CMP_TASK())
994             {
995                 pstFqInitDes->pInfo = (DMX_FQ_Info*)buffer_array0;
996 
997                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X2);
998                 ps8AdpSrc += LEN_U32_X2;
999                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
1000                 CMP_CPY_FROM_USER((void*)&(pstFqInitDes->pInfo->u8AddrMode), u32NextPtr, 1);
1001                 u32NextPtr += 1;
1002                 pstFqInitDes->pInfo->u32BufStart = 0;
1003                 CMP_CPY_FROM_USER((void*)&(pstFqInitDes->pInfo->u32BufStart), u32NextPtr, LEN_MSPHY);
1004                 u32NextPtr += LEN_MSPHY;
1005                 CMP_CPY_FROM_USER((void*)&(pstFqInitDes->pInfo->u32BufSize), u32NextPtr, LEN_U32_X1);
1006                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1007                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1008             }
1009             else
1010             {
1011                 CPY_FROM_USER((void*)pstFqInitDes, pArgs, sizeof(DMX_FQ_INIT_PARAM));
1012                 CPY_FROM_USER((void*)buffer_array0, (void*)(pstFqInitDes->pInfo), sizeof(DMX_FQ_Info));
1013                 pstFqInitDes->pInfo = (DMX_FQ_Info*)buffer_array0;
1014                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1015                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1016             }
1017             break;
1018 
1019         case MApi_CMD_DMX_MStr_SyncBy:
1020             pstMstrSynByDes = (PDMX_MSTR_SYNCBY_PARAM)buffer_arg;
1021 
1022             if(IS_CMP_TASK())
1023             {
1024                 pstMstrSynByDes->pu8SyncByte = (MS_U8*)buffer_array0;
1025                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, 9);
1026                 ps8AdpSrc += 9;
1027                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
1028                 ps8AdpSrc += LEN_U32_X1;
1029                 CMP_CPY_FROM_USER((void*)&(pstMstrSynByDes->bSet), ps8AdpSrc, 1);
1030                 if(pstMstrSynByDes->bSet == TRUE)
1031                 {
1032                     CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, 1);
1033                 }
1034                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1035                 if(pstMstrSynByDes->bSet == FALSE)
1036                 {
1037                     CMP_CPY_TO_USER(u32NextPtr, (void*)buffer_array0, 1);
1038                 }
1039                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1040             }
1041             else
1042             {
1043                 CPY_FROM_USER((void*)pstMstrSynByDes, pArgs, sizeof(DMX_MSTR_SYNCBY_PARAM));
1044                 if(pstMstrSynByDes->bSet == TRUE)
1045                 {
1046                     CPY_FROM_USER((void*)buffer_array0, (void*)pstMstrSynByDes->pu8SyncByte, sizeof(MS_U8));
1047                 }
1048                 pNxtPtr = (void*)pstMstrSynByDes->pu8SyncByte;
1049                 pstMstrSynByDes->pu8SyncByte = (MS_U8*)buffer_array0;
1050                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1051                 if(pstMstrSynByDes->bSet == FALSE)
1052                 {
1053                     CPY_to_USER(pNxtPtr, (void*)pstMstrSynByDes->pu8SyncByte,sizeof(MS_U8));
1054                 }
1055                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1056             }
1057             break;
1058 
1059         case MApi_CMD_DMX_MMFI_Info:
1060             pstFileInfoDes = (PDMX_FILE_INFO_PARAM)buffer_arg;
1061 
1062             if(IS_CMP_TASK())
1063             {
1064                 pstFileInfoDes->pFileinInfo = (DMX_Filein_info*)buffer_array0;
1065                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X2);
1066                 ps8AdpSrc += LEN_U32_X2;
1067                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X2);
1068                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(DMX_Filein_info));
1069                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1070                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1071             }
1072             else
1073             {
1074                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_FILE_INFO_PARAM));
1075                 CPY_FROM_USER((void*)buffer_array0, (void*)pstFileInfoDes->pFileinInfo, sizeof(DMX_Filein_info));
1076                 pstFileInfoDes->pFileinInfo = (DMX_Filein_info*)buffer_array0;
1077                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1078                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1079             }
1080             break;
1081 
1082         case MApi_CMD_DMX_TSO_Configure:
1083             pstTSOCfg = (DMX_TSO_Cfg*)buffer_arg;
1084             u32data = sizeof(DMX_TSO_Cfg);
1085 
1086             if(IS_CMP_TASK())
1087             {
1088                 CMP_CPY_FROM_USER((void*)buffer_arg, pArgs, LEN_U32_X4 + 1);
1089             }
1090             else
1091             {
1092                 CPY_FROM_USER((void*)buffer_arg, pArgs, LEN_U32_X4 + 1);
1093             }
1094             if((pstTSOCfg->u32TsoCfgDataSize > 0) && (pstTSOCfg->u32TsoCfgDataSize <= u32data))
1095                 u32data = pstTSOCfg->u32TsoCfgDataSize;
1096             u32InSize = u32data;
1097             u32OutSize = u32data;
1098             break;
1099 
1100         case MApi_CMD_DMX_FQ_Configure:
1101             pstFqCfg = (DMX_FQ_Cfg*)pArgs;
1102             u32data = sizeof(DMX_FQ_Cfg);
1103 
1104             if(IS_CMP_TASK())
1105             {
1106                 CMP_CPY_FROM_USER((void*)buffer_arg, pArgs, LEN_U32_X4 + 1);
1107             }
1108             else
1109             {
1110                 CPY_FROM_USER((void*)buffer_arg, pArgs, LEN_U32_X4 + 1);
1111             }
1112             if((pstFqCfg->u32CfgDataSize > 0) && (pstFqCfg->u32CfgDataSize <= u32data))
1113                 u32data = pstFqCfg->u32CfgDataSize;
1114             u32InSize = u32data;
1115             u32OutSize = u32data;
1116             break;
1117 
1118         case MApi_CMD_DMX_MMFI_BypassStamp:
1119         case MApi_CMD_DMX_FI_BypassFileTimestamp:
1120             u32InSize = LEN_U32_X2;
1121             break;
1122 
1123         case MApi_CMD_DMX_OrzWProtectEnable:
1124             u32InSize = 20;
1125             break;
1126 
1127         case MApi_CMD_DMX_Exit:
1128         case MApi_CMD_DMX_ForceExit:
1129         case MApi_CMD_DMX_Suspend:
1130         case MApi_CMD_DMX_ChkFwAlive:
1131         case MApi_CMD_DMX_Reset:
1132         case MApi_CMD_DMX_ReleaseAccess:
1133         case MApi_CMD_DMX_GetFwVer:
1134         case MApi_CMD_DMX_Init_1_0:
1135         case MApi_CMD_DMX_ReleseHWSemp:
1136         case MApi_CMD_DMX_GetLibVer:
1137             u32OutSize = LEN_U32_X1;
1138             break;
1139 
1140         case MApi_CMD_DMX_Close:
1141         case MApi_CMD_DMX_Start:
1142         case MApi_CMD_DMX_Stop:
1143         case MApi_CMD_DMX_SetDbgLevel:
1144         case MApi_CMD_DMX_DropEn:
1145         case MApi_CMD_DMX_File_PVR_Stop:
1146         case MApi_CMD_DMX_Sec_Reset:
1147         case MApi_CMD_DMX_TSO_FileStop:
1148         case MApi_CMD_DMX_GetAccess:
1149         case MApi_CMD_DMX_AUBD_Enable:
1150         case MApi_CMD_DMX_Pvr_Close:
1151         case MApi_CMD_DMX_FI_Stop:
1152         case MApi_CMD_DMX_FI_Pause:
1153         case MApi_CMD_DMX_FI_Resume:
1154         case MApi_CMD_DMX_FI_IsIdle:
1155         case MApi_CMD_DMX_FI_IsBusy:
1156         case MApi_CMD_DMX_FI_IsPause:
1157         case MApi_CMD_DMX_FI_CmdQReset:
1158         case MApi_CMD_DMX_MMFI_IsIdle:
1159         case MApi_CMD_DMX_MMFI_IsBusy:
1160         case MApi_CMD_DMX_MMFI_CmdQReset:
1161         case MApi_CMD_DMX_SetHK:
1162         case MApi_CMD_DMX_STC64ModeEnable:
1163         case MApi_CMD_DMX_RESET_SECDISCON_PKTCNT:
1164         case MApi_CMD_DMX_TSO_CmdQReset:
1165         case MApi_CMD_DMX_GetIntCnt:
1166         case MApi_CMD_DMX_RESET_SECTEI_PKTCNT:
1167         case MApi_CMD_DMX_TSO_FileIsIdle:
1168             u32InSize = LEN_U32_X2;
1169             u32OutSize = u32InSize;
1170             break;
1171 
1172         case MApi_CMD_DMX_ReadDropCount:
1173         case MApi_CMD_DMX_TSO_OutputEn:
1174         case MApi_CMD_DMX_FI_CmdQGetEmptyNum:
1175         case MApi_CMD_DMX_FI_CmdQGetFifoLevel:
1176         case MApi_CMD_DMX_FI_GetFileTimeStamp:
1177         case MApi_CMD_DMX_Flow_ParlInvert:
1178         case MApi_CMD_DMX_Flow_ENABLE:
1179         case MApi_CMD_DMX_Pvr_IsStart:
1180         case MApi_CMD_DMX_IsStart:
1181         case MApi_CMD_DMX_GetOwner:
1182         case MApi_CMD_DMX_GetPESScmbSts:
1183         case MApi_CMD_DMX_GetTsScmbSts:
1184         case MApi_CMD_DMX_MMFI_Timestamp_En:
1185         case MApi_CMD_DMX_TSO_FileGetTimeStamp:
1186         case MApi_CMD_DMX_TSO_FileBypassStamp:
1187         case MApi_CMD_DMX_TSO_FileTimeStampEnable:
1188         case MApi_CMD_DMX_GET_SECDISCON_PKTCNT:
1189         case MApi_CMD_DMX_STCEng_Sel:
1190         case MApi_CMD_DMX_File_PVR_PidClose:
1191         case MApi_CMD_DMX_File_PVR_Start:
1192         case MApi_CMD_DMX_FI_TimestampMode:
1193         case MApi_CMD_DMX_Pvr_Stop:
1194         case MApi_CMD_DMX_Pvr_SetPktMode:
1195         case MApi_CMD_DMX_Pvr_SetRecordStamp:
1196         case MApi_CMD_DMX_Pvr_GetRecordStamp:
1197         case MApi_CMD_DMX_MMFI_GetEmptyNum:
1198         case MApi_CMD_DMX_MMFI_GetFileTimeStamp:
1199         case MApi_CMD_DMX_MMFI_PidClose:
1200         case MApi_CMD_DMX_MMFI_GetFifoLevel:
1201         case MApi_CMD_DMX_MMFI_PlayStamp_Set:
1202         case MApi_CMD_DMX_MMFI_PlayStamp_Get:
1203         case MApi_CMD_DMX_MMFI_SetTimeStampClk:
1204         case MApi_CMD_DMX_SetMergeStrSync:
1205         case MApi_CMD_DMX_TSO_FileGetCmdQEmptyNum:
1206         case MApi_CMD_DMX_TSO_PidClose:
1207         case MApi_CMD_DMX_FQ_Exit:
1208         case MApi_CMD_DMX_FQ_RushEnable:
1209         case MApi_CMD_DMX_TeiRmErrPkt:
1210         case MApi_CMD_DMX_Get_DbgPortInfo:
1211         case MApi_CMD_DMX_Pvr_Pause:
1212         case MApi_CMD_DMX_Stc_UpdateCtrl:
1213         case MApi_CMD_DMX_RES_ALLOC:
1214         case MApi_CMD_DMX_RES_FREE:
1215         case MApi_CMD_DMX_PCR_GET_MAP_STC:
1216             u32InSize = LEN_U32_X3;
1217             u32OutSize = u32InSize;
1218             break;
1219 
1220         case MApi_CMD_DMX_SetFwMiuDataAddr:
1221         case MApi_CMD_DMX_MMFI_SetMOBFKey:
1222         case MApi_CMD_DMX_TSO_FI_GetReadAddr:
1223         case MApi_CMD_DMX_Open_MultiFlt:
1224         case MApi_CMD_DMX_SetOwner:
1225         case MApi_CMD_DMX_FQ_SetFltRushPass:
1226         case MApi_CMD_DMX_TsOutPhase:
1227         case MApi_CMD_DMX_GetPcr:
1228         case MApi_CMD_DMX_Stc_Get:
1229         case MApi_CMD_DMX_Stc_Set:
1230         case MApi_CMD_DMX_Stc_SetOffset:
1231         case MApi_CMD_DMX_Stc_ClkAdjust:
1232         case MApi_CMD_DMX_Pvr_CBSize:
1233         case MApi_CMD_DMX_Pvr_SetCaMode:
1234         case MApi_CMD_DMX_Pid:
1235         case MApi_CMD_DMX_Sec_GetWriteAddr:
1236         case MApi_CMD_DMX_Sec_GetStartAddr:
1237         case MApi_CMD_DMX_Sec_GetEndAddr:
1238         case MApi_CMD_DMX_GetTTXWrite:
1239         case MApi_CMD_DMX_FI_PlayStamp:
1240         case MApi_CMD_DMX_Pvr_PidClose:
1241         case MApi_CMD_DMX_Pvr_Start:
1242         case MApi_CMD_DMX_Pvr_GetWriteAddr:
1243         case MApi_CMD_DMX_FI_GetReadAddr:
1244         case MApi_CMD_DMX_FI_SetMobfKey:
1245         case MApi_CMD_DMX_SetFw:
1246         case MApi_CMD_DMX_TSO_FilePlayStamp:
1247         case MApi_CMD_DMX_PVR_MOBFEn:
1248         case MApi_CMD_DMX_Get_PipeId:
1249             u32InSize = LEN_U32_X4;
1250             u32OutSize = u32InSize;
1251             break;
1252 
1253         case MApi_CMD_DMX_GetFltScmbSts:
1254         case MApi_CMD_DMX_Sec_ReadAddr:
1255         case MApi_CMD_DMX_Pvr_SetMobfKey:
1256         case MApi_CMD_DMX_TSO_FileStart:
1257         case MApi_CMD_DMX_TSO_PidOpen:
1258         case MApi_CMD_DMX_TSO_SvqBufSet:
1259         case MApi_CMD_DMX_SetFwDbgParam:
1260         case MApi_CMD_DMX_File_PVR_PidOpen:
1261         case MApi_CMD_DMX_Pvr_Pid:
1262             u32InSize = 20;
1263             u32OutSize = u32InSize;
1264             break;
1265 
1266         case MApi_CMD_DMX_SetBurstLen:
1267             u32InSize = sizeof(DMX_BURSTTYPE);
1268             break;
1269 
1270         case MApi_CMD_DMX_SetPktMode:
1271             u32InSize = sizeof(DMX_PKT_MODE_PARAM);
1272             u32OutSize = u32InSize;
1273             break;
1274 
1275         case MApi_CMD_DMX_FQ_SkipRushData:
1276             u32InSize = sizeof(DMX_FQ_SKIP_RUSH_DATA_PARAM);
1277             u32OutSize = u32InSize;
1278             break;
1279 
1280         case MApi_CMD_DMX_Flow:
1281             u32InSize = sizeof(DMX_FLOW_PARAM);
1282             u32OutSize = u32InSize;
1283             break;
1284 
1285         case MApi_CMD_DMX_PVR_Flow:
1286             u32InSize = sizeof(DMX_PVRFLOWPARAM);
1287             u32OutSize = u32InSize;
1288             break;
1289 
1290         case MApi_CMD_DMX_FlowDscmbEng:
1291             u32InSize = sizeof(DMX_FLOW_DSCMBENG_PARAM);
1292             u32OutSize = u32InSize;
1293             break;
1294 
1295         case MApi_CMD_DMX_DropScmbPkt:
1296             u32InSize = sizeof(DMX_DROP_SCMB_PKT_PARAM);
1297             u32OutSize = u32InSize;
1298             break;
1299 
1300         case MApi_CMD_DMX_Open:
1301         case MApi_CMD_DMX_Open_Ex:
1302         case MApi_CMD_DMX_ChangeFltSrc:
1303             u32InSize =  sizeof(DMX_FLT_TYPE_PARAM);
1304             u32OutSize = u32InSize;
1305             break;
1306 
1307         case MApi_CMD_DMX_AVFIFO_Reset:
1308         case MApi_CMD_DMX_AVFIFO_Status:
1309         case MApi_CMD_DMX_MMFI_RemoveDupAVPkt:
1310             u32InSize = sizeof(DMX_AVFIFO_PARAM);
1311             u32OutSize = u32InSize;
1312             break;
1313 
1314         case MApi_CMD_DMX_RemoveDupAVFifoPkt:
1315             u32InSize = sizeof(DMX_AVFIFO_DROP_PARAM);
1316             u32OutSize = u32InSize;
1317             break;
1318 
1319         case MApi_CMD_DMX_MMFI_PidOpen:
1320             u32InSize = sizeof(DMX_MMFI_FLT_PARAM);
1321             u32OutSize = u32InSize;
1322             break;
1323 
1324         case MApi_CMD_DMX_FI_SetPlaybackStampClk:
1325         case MApi_CMD_DMX_Pvr_SetRecordStampClk:
1326             u32InSize = sizeof(DMX_TIMESTAMP_CLK_PARAM);
1327             break;
1328 
1329         case MApi_CMD_DMX_Pvr_PidOpen:
1330             u32InSize = sizeof(DMX_PVR_FLTTYPE_PARAM);
1331             u32OutSize = u32InSize;
1332             break;
1333 
1334         case MApi_CMD_DMX_GET_SECTEI_PKTCNT:
1335             u32InSize = sizeof(DMX_PKT_SECTEI_PARAM);
1336             u32OutSize = u32InSize;
1337             break;
1338 
1339         case MApi_CMD_DMX_TSO_OutClk:
1340             u32InSize = sizeof(DMX_TSO_OUTCLK_PARAM);
1341             u32OutSize = u32InSize;
1342             break;
1343 
1344         case MApi_CMD_DMX_WaitTspCbEvt:
1345             u32InSize = sizeof(DMX_TSP_IOSIGNAL);
1346             u32OutSize = u32InSize;
1347             break;
1348         case MApi_CMD_DMX_TSO_InputCfg:
1349             u32InSize = sizeof(DMX_TSO_InputCfg);
1350             u32OutSize = u32InSize;
1351             break;
1352 
1353         case MApi_CMD_DMX_TSO_OutputCfg:
1354             u32InSize = sizeof(DMX_TSO_OutputCfg);
1355             u32OutSize = u32InSize;
1356             break;
1357 
1358         case MApi_CMD_DMX_TSIO_Service_SetDMAoutVC:
1359             pstTsioDoutDes = (PDMX_TSIO_Service_SetDMAoutVC_PARAM)buffer_arg;
1360             if(IS_CMP_TASK())
1361             {
1362                 pstTsioDoutDes->eSet = (TSIO_DMAOUT_SET *)buffer_array0;
1363                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, 6);
1364                 ps8AdpSrc += 6;
1365                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
1366                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(TSIO_DMAOUT_SET));
1367                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1368                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1369             }
1370             else
1371             {
1372                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSIO_Service_SetDMAoutVC_PARAM));
1373                 CPY_FROM_USER((void*)buffer_array0, (void*)pstTsioDoutDes->eSet, sizeof(TSIO_DMAOUT_SET));
1374                 pstTsioDoutDes->eSet = (TSIO_DMAOUT_SET*)buffer_array0;
1375                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1376                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1377             }
1378             break;
1379 
1380         case MApi_CMD_DMX_TSIO_Service_SetDestination:
1381             u32InSize = sizeof(DMX_TSIO_Service_SetDestination_PARAM);
1382             u32OutSize = u32InSize;
1383             break;
1384 
1385         case MApi_CMD_DMX_TSIO_Service_SetDMAinVC:
1386             pstTsioDinDes = (PDMX_TSIO_Service_SetDMAinVC_PARAM)buffer_arg;
1387             if(IS_CMP_TASK())
1388             {
1389                 pstTsioDinDes->eSet = (TSIO_DMAIN_SET *)buffer_array0;
1390                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, 6);
1391                 ps8AdpSrc += 6;
1392                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
1393                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(TSIO_DMAIN_SET));
1394                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1395                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1396             }
1397             else
1398             {
1399                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSIO_Service_SetDMAinVC_PARAM));
1400                 CPY_FROM_USER((void*)buffer_array0, (void*)pstTsioDinDes->eSet, sizeof(TSIO_DMAIN_SET));
1401                 pstTsioDinDes->eSet = (TSIO_DMAIN_SET*)buffer_array0;
1402                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1403                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1404             }
1405             break;
1406 
1407         case MApi_CMD_DMX_TSIO_Service_SetLocdecKey:
1408             pstTsioLocDes = (PDMX_TSIO_Service_SetLocdecKey_PARAM)buffer_arg;
1409             if(IS_CMP_TASK())
1410             {
1411                 pstTsioLocDes->eSet = (TSIO_LOCKEY_SET *)buffer_array0;
1412                 pstTsioLocDes->eSet->u8Evenkey = (MS_U8 *)buffer_array1;
1413                 pstTsioLocDes->eSet->u8Oddkey = (MS_U8 *)buffer_array2;
1414 
1415                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, 6);
1416                 ps8AdpSrc += 6;
1417                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
1418                 CMP_CPY_FROM_USER((void *)&(pstTsioLocDes->eSet->bEnable), u32NextPtr, sizeof(MS_BOOL));
1419                 u32NextPtr+=sizeof(MS_BOOL);
1420                 CMP_CPY_FROM_USER((void *)&(pstTsioLocDes->eSet->bEvenkeyenable), u32NextPtr, sizeof(MS_BOOL));
1421                 u32NextPtr+=3;
1422                 CMP_CPY_FROM_USER(&u32NextPtr1, u32NextPtr, LEN_U32_X1);
1423                 u32NextPtr+=LEN_U32_X1;
1424                 CMP_CPY_FROM_USER((void *)&(pstTsioLocDes->eSet->u16Evenkeylen), u32NextPtr, sizeof(MS_U16));
1425                 u32NextPtr+=sizeof(MS_U16);
1426                 CMP_CPY_FROM_USER((void *)&(pstTsioLocDes->eSet->bOddkeyenable), u32NextPtr, sizeof(MS_BOOL));
1427                 u32NextPtr+=2;
1428                 CMP_CPY_FROM_USER(&u32NextPtr2, u32NextPtr, LEN_U32_X1);
1429                 u32NextPtr+=LEN_U32_X1;
1430                 CMP_CPY_FROM_USER((void *)&(pstTsioLocDes->eSet->u16Oddkeylen), u32NextPtr, sizeof(MS_U16));
1431                 CMP_CPY_FROM_USER((void *)buffer_array1, u32NextPtr1, pstTsioLocDes->eSet->u16Evenkeylen);
1432                 CMP_CPY_FROM_USER((void *)buffer_array2, u32NextPtr2, pstTsioLocDes->eSet->u16Oddkeylen);
1433                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1434                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1435             }
1436             else
1437             {
1438                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSIO_Service_SetLocdecKey_PARAM));
1439                 CPY_FROM_USER((void*)buffer_array0, (void*)pstTsioLocDes->eSet, sizeof(TSIO_LOCKEY_SET));
1440                 pstTsioLocDes->eSet = (TSIO_LOCKEY_SET *)buffer_array0;
1441 
1442                 if (pstTsioLocDes->eSet->bEvenkeyenable == TRUE)
1443                 {
1444                     CPY_FROM_USER((void*)buffer_array1, (void*)pstTsioLocDes->eSet->u8Evenkey,pstTsioLocDes->eSet->u16Evenkeylen);
1445                     pstTsioLocDes->eSet->u8Evenkey = (MS_U8 *)buffer_array1;
1446                 }
1447 
1448                 if (pstTsioLocDes->eSet->bOddkeyenable == TRUE)
1449                 {
1450                     CPY_FROM_USER((void*)buffer_array2, (void*)pstTsioLocDes->eSet->u8Oddkey, pstTsioLocDes->eSet->u16Oddkeylen);
1451                     pstTsioLocDes->eSet->u8Oddkey = (MS_U8 *)buffer_array2;
1452                 }
1453                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1454                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1455             }
1456             break;
1457 
1458         case MApi_CMD_DMX_TSIO_Service_PidOpen:
1459             pstTsioPidDes = (PDMX_TSIO_Service_PidOpen_PARAM)buffer_arg;
1460             if(IS_CMP_TASK())
1461             {
1462                 pstTsioPidDes->pu16DmxId = (MS_U16 *)buffer_array0;
1463                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X3);
1464                 ps8AdpSrc += LEN_U32_X3;
1465                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
1466                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(MS_U16));
1467                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1468                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1469                 CMP_CPY_TO_USER(u32NextPtr, (void*)buffer_array0, sizeof(MS_U16));
1470             }
1471             else
1472             {
1473                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSIO_Service_PidOpen_PARAM));
1474                 CPY_FROM_USER((void*)buffer_array0, (void*)pstTsioPidDes->pu16DmxId, sizeof(MS_U16));
1475                 pNxtPtr = (void *)pstTsioPidDes->pu16DmxId;
1476                 pstTsioPidDes->pu16DmxId = (MS_U16*)buffer_array0;
1477                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1478                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1479                 CMP_CPY_TO_USER(pNxtPtr, (void*)buffer_array0, sizeof(MS_U16));
1480             }
1481             break;
1482 
1483         case MApi_CMD_DMX_TSIO_Service_PidClose:
1484             u32InSize = sizeof(DMX_TSIO_Service_PidClose_PARAM);
1485             u32OutSize = u32InSize;
1486             break;
1487 
1488         case MApi_CMD_DMX_TSIO_Service_Alloc:
1489             pstTsioAlcDes = (PDMX_TSIO_Service_Alloc_PARAM)buffer_arg;
1490             if(IS_CMP_TASK())
1491             {
1492                 pstTsioAlcDes->u16Handle = (MS_U16 *)buffer_array0;
1493                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, 5);
1494                 ps8AdpSrc += 5;
1495                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
1496                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(MS_U16));
1497                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1498                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1499                 CMP_CPY_TO_USER(u32NextPtr, (void*)buffer_array0, sizeof(MS_U16));
1500             }
1501             else
1502             {
1503                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSIO_Service_Alloc_PARAM));
1504                 CPY_FROM_USER((void*)buffer_array0, (void*)pstTsioAlcDes->u16Handle, sizeof(MS_U16));
1505                 pNxtPtr = (void *)pstTsioAlcDes->u16Handle;
1506                 pstTsioAlcDes->u16Handle = (MS_U16*)buffer_array0;
1507                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1508                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1509                 CPY_to_USER(pNxtPtr, (void*)buffer_array0, sizeof(MS_U16));
1510             }
1511             break;
1512 
1513         case MApi_CMD_DMX_TSIO_Service_Free:
1514             u32InSize = sizeof(DMX_TSIO_Service_Free_PARAM);
1515             u32OutSize = u32InSize;
1516             break;
1517 
1518         case MApi_CMD_DMX_TSIO_RegisterIntCb: // not ready
1519             pstTsioCbDes = (PDMX_TSIO_RegisterIntCb_PARAM)buffer_arg;
1520             if(IS_CMP_TASK())
1521             {
1522                 pstTsioCbDes->efn = NULL;//(TSIOIntTypeCB)buffer_array0;
1523                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X1);
1524                 ps8AdpSrc += LEN_U32_X1;
1525                 //CMP_CPY_FROM_USER((void*)(buffer_array0), ps8AdpSrc, sizeof(TSIOIntTypeCB));
1526                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1527                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1528             }
1529             else
1530             {
1531                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSIO_RegisterIntCb_PARAM));
1532                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1533                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1534             }
1535             break;
1536 
1537          case MApi_CMD_DMX_TSIO_Init:
1538              pstTsioInitDes = (PDMX_TSIO_Init_PARAM)buffer_arg;
1539              if(IS_CMP_TASK())
1540              {
1541                  pstTsioInitDes->eParm = (TSIO_Init_Set *)buffer_array0;
1542                  CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X1);
1543                  ps8AdpSrc += LEN_U32_X1;
1544                  CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
1545                  CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(TSIO_Init_Set));
1546                  u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1547                  CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1548              }
1549              else
1550              {
1551                  CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSIO_Init_PARAM));
1552                  CPY_FROM_USER((void*)buffer_array0, (void*)pstTsioInitDes->eParm, sizeof(TSIO_Init_Set));
1553                  pstTsioInitDes->eParm = (TSIO_Init_Set*)buffer_array0;
1554                  u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1555                  CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1556              }
1557              break;
1558 
1559         case MApi_CMD_DMX_TSIO_Cmd:
1560             u32InSize = sizeof(DMX_TSIO_Cmd_PARAM);
1561             u32OutSize = u32InSize;
1562             break;
1563 
1564         case MApi_CMD_DMX_TSIO_Exit:
1565             u32InSize = sizeof(MS_U32);
1566             u32OutSize = u32InSize;
1567             break;
1568 
1569         case MApi_CMD_DMX_TSIO_CC:
1570             pstTsioCcDes = (PDMX_TSIO_CC_PARAM)buffer_arg;
1571             if(IS_CMP_TASK())
1572             {
1573                 pstTsioCcDes->Parm = (TSIO_CC_Set *)buffer_array2;
1574                 pstTsioCcDes->pResult = (TSIO_CC_RESULT *)buffer_array3;
1575                 pstTsioCcDes->Parm->pIn = (MS_U8 *)buffer_array0;
1576                 pstTsioCcDes->Parm->pOut = (MS_U8 *)buffer_array1;
1577                 pstTsioCcDes->Parm->pOutLen= (MS_U16 *)buffer_array4;
1578                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X1);
1579                 ps8AdpSrc += LEN_U32_X1;
1580                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
1581                 ps8AdpSrc += LEN_U32_X1;
1582                 CMP_CPY_FROM_USER(&u32NextPtrOut, ps8AdpSrc, LEN_U32_X1);
1583                 CMP_CPY_FROM_USER((void *)&u32NextPtr1, u32NextPtr, LEN_U32_X1);
1584                 u32NextPtr+=LEN_U32_X1;
1585                 CMP_CPY_FROM_USER((void *)&(pstTsioCcDes->Parm->u16InLen), u32NextPtr, sizeof(MS_U16));
1586                 u32NextPtr+=LEN_U32_X1;
1587                 CMP_CPY_FROM_USER((void *)&u32NextPtr2, u32NextPtr, LEN_U32_X1);
1588                 u32NextPtr+=LEN_U32_X1;
1589                 CMP_CPY_FROM_USER((void *)&u32NextPtr3, u32NextPtr, LEN_U32_X1);
1590                 u32NextPtr+=LEN_U32_X1;
1591                 CMP_CPY_FROM_USER((void *)buffer_array0, u32NextPtr1, pstTsioCcDes->Parm->u16InLen);
1592                 CMP_CPY_FROM_USER((void *)buffer_array1, u32NextPtr2, sizeof(MS_U8));
1593                 CMP_CPY_FROM_USER((void *)buffer_array4, u32NextPtr3, sizeof(MS_U16));
1594                 CMP_CPY_FROM_USER((void *)&(pstTsioCcDes->Parm->u32Timeout), u32NextPtr, sizeof(MS_U32));
1595                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1596                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1597                 if (*pstTsioCcDes->pResult == TSIO_CC_RESULT_OK)
1598                 {
1599                     CMP_CPY_TO_USER(u32NextPtr2, (void*)buffer_array1, *pstTsioCcDes->Parm->pOutLen);
1600                     CMP_CPY_TO_USER(u32NextPtr3, (void*)buffer_array4, sizeof(MS_U16));
1601                 }
1602             }
1603             else
1604             {
1605                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSIO_CC_PARAM));
1606                 CPY_FROM_USER((void*)buffer_array2, (void*)pstTsioCcDes->Parm, sizeof(TSIO_CC_Set));
1607                 pstTsioCcDes->Parm = (TSIO_CC_Set *)buffer_array2;
1608                 if (pstTsioCcDes->Parm->pIn != NULL)
1609                 {
1610                     CPY_FROM_USER((void*)buffer_array0, pstTsioCcDes->Parm->pIn, pstTsioCcDes->Parm->u16InLen);
1611                     pstTsioCcDes->Parm->pIn = (MS_U8 *)buffer_array0;
1612                 }
1613                 if (pstTsioCcDes->Parm->pOut != NULL)
1614                     pstTsioCcDes->Parm->pOut = (MS_U8 *)buffer_array1;
1615 
1616                 if (pstTsioCcDes->Parm->pOutLen != NULL)
1617                     pstTsioCcDes->Parm->pOut = (MS_U8 *)buffer_array4;
1618                 pstTsioCcDes->pResult = (TSIO_CC_RESULT *)buffer_array3;
1619                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1620                 CPY_to_USER(pArgs, (void*)buffer_arg, sizeof(DMX_TSIO_CC_PARAM));
1621             }
1622             break;
1623 
1624         case MApi_CMD_DMX_TSIO_GetInfo:
1625             pstTsioGetInfoDes = (PDMX_TSIO_GetInfo_PARAM)buffer_arg;
1626             if(IS_CMP_TASK())
1627             {
1628                 pstTsioGetInfoDes->u32Retinfo = (MS_U32 *)buffer_array0;
1629                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, LEN_U32_X3);
1630                 ps8AdpSrc += LEN_U32_X3;
1631                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
1632                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(MS_U32));
1633                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1634                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1635                 CMP_CPY_TO_USER(u32NextPtr, (void*)buffer_array0, sizeof(MS_U32));
1636             }
1637             else
1638             {
1639                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSIO_GetInfo_PARAM));
1640                 CPY_FROM_USER((void*)buffer_array0, (void*)pstTsioGetInfoDes->u32Retinfo, sizeof(MS_U32));
1641                 pNxtPtr = (void *)pstTsioGetInfoDes->u32Retinfo;
1642                 pstTsioGetInfoDes->u32Retinfo = (MS_U32 *)buffer_array0;
1643                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1644                 CPY_to_USER(pNxtPtr, (void*)buffer_array0, sizeof(MS_U32*));
1645                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1646             }
1647             break;
1648 
1649         case MApi_CMD_DMX_TSIO_Service_DMAinVC_Start:
1650             u32InSize = sizeof(DMX_TSIO_Service_DMAinVC_Start_PARAM);
1651             u32OutSize = u32InSize;
1652             break;
1653 
1654         case MApi_CMD_DMX_TSIO_Service_LocdecKeyEnable:
1655             u32InSize = sizeof(DMX_TSIO_Service_LocdecKeyEnable_PARAM);
1656             u32OutSize = u32InSize;
1657             break;
1658 
1659         case MApi_CMD_DMX_TSIO_Service_DMAout_WriteGet:
1660             pstTsioDWriteDes = (PDMX_TSIO_Service_DMAout_WriteGet_PARAM)buffer_arg;
1661             if(IS_CMP_TASK())
1662             {
1663                 pstTsioDWriteDes->pphyWrite = (MS_PHY *)buffer_array0;
1664                 CMP_CPY_FROM_USER((void*)buffer_arg, ps8AdpSrc, 6);
1665                 ps8AdpSrc += 6;
1666                 CMP_CPY_FROM_USER(&u32NextPtr, ps8AdpSrc, LEN_U32_X1);
1667                 CMP_CPY_FROM_USER((void*)buffer_array0, u32NextPtr, sizeof(MS_PHY*));
1668                 u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1669                 CMP_CPY_TO_USER(pArgs, buffer_arg, LEN_U32_X1);
1670                 CMP_CPY_TO_USER(u32NextPtr, buffer_array0, sizeof(MS_PHY*));
1671             }
1672             else
1673             {
1674                 CPY_FROM_USER((void*)buffer_arg, pArgs, sizeof(DMX_TSIO_Service_DMAout_WriteGet_PARAM));
1675                 CPY_FROM_USER((void*)buffer_array0, (void*)pstTsioDWriteDes->pphyWrite, sizeof(MS_PHY));
1676                 pNxtPtr = (void *)pstTsioDWriteDes->pphyWrite;
1677                 pstTsioDWriteDes->pphyWrite = (MS_PHY *)buffer_array0;
1678                 u32Ret = UtopiaIoctl(pInstanceTmp, u32Cmd, (void*)buffer_arg);
1679                 CPY_to_USER(pNxtPtr, (void*)buffer_array0, sizeof(MS_PHY*));
1680                 CPY_to_USER(pArgs, (void*)buffer_arg, LEN_U32_X1);
1681             }
1682             break;
1683 
1684         case MApi_CMD_DMX_TSIO_Open:
1685             u32InSize = sizeof(DMX_TSIO_Open_PARAM);
1686             u32OutSize = u32InSize;
1687             break;
1688 
1689         case MApi_CMD_DMX_TSIO_Close:
1690             u32InSize = sizeof(MS_U32);
1691             u32OutSize = u32InSize;
1692             break;
1693 
1694         case MApi_CMD_DMX_TSIO_WaitCbEvt:
1695             u32InSize = sizeof(DMX_TSIO_IOSIGNAL);
1696             u32OutSize = u32InSize;
1697             break;
1698 
1699         default:
1700             DMX_ADP_MSG("DMXADP - Unknown commend!!!\n");
1701             break;
1702     }
1703 
1704     if((u32InSize > 0) || (u32OutSize > 0))
1705     {
1706         if(u32InSize > 0)
1707         {
1708             if(IS_CMP_TASK())
1709             {
1710                 CMP_CPY_FROM_USER((void*)buffer_arg, pArgs, u32InSize);
1711             }
1712             else
1713             {
1714                 CPY_FROM_USER((void*)buffer_arg, pArgs, u32InSize);
1715             }
1716         }
1717         u32Ret = UtopiaIoctl(pInstanceTmp,u32Cmd,(void*)buffer_arg);
1718         if(u32OutSize > 0)
1719         {
1720             if(IS_CMP_TASK())
1721             {
1722                 CMP_CPY_TO_USER(pArgs, (void*)buffer_arg, u32OutSize);
1723             }
1724             else
1725             {
1726                 CPY_to_USER(pArgs, (void*)buffer_arg, u32OutSize);
1727             }
1728         }
1729     }
1730     //printf("[DMX] E %d\n", (int)u32Ret);
1731 
1732     return u32Ret;
1733 
1734 }
1735 
1736 #endif
1737 
1738 
1739