xref: /utopia/UTPA2-700.0.x/modules/dmx/hal/maldives/mmfi/halMMFilein.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 //    Software and any modification/derivatives thereof.
18 //    No right, ownership, or interest to MStar Software and any
19 //    modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 //    supplied together with third party`s software and the use of MStar
23 //    Software may require additional licenses from third parties.
24 //    Therefore, you hereby agree it is your sole responsibility to separately
25 //    obtain any and all third party right and license necessary for your use of
26 //    such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 //    MStar`s confidential information and you agree to keep MStar`s
30 //    confidential information in strictest confidence and not disclose to any
31 //    third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 //    kind. Any warranties are hereby expressly disclaimed by MStar, including
35 //    without limitation, any warranties of merchantability, non-infringement of
36 //    intellectual property rights, fitness for a particular purpose, error free
37 //    and in conformity with any international standard.  You agree to waive any
38 //    claim against MStar for any loss, damage, cost or expense that you may
39 //    incur related to your use of MStar Software.
40 //    In no event shall MStar be liable for any direct, indirect, incidental or
41 //    consequential damages, including without limitation, lost of profit or
42 //    revenues, lost or damage of data, and unauthorized system use.
43 //    You agree that this Section 4 shall still apply without being affected
44 //    even if MStar Software has been modified by MStar in accordance with your
45 //    request or instruction for your use, except otherwise agreed by both
46 //    parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 //    services in relation with MStar Software to you for your use of
50 //    MStar Software in conjunction with your or your customer`s product
51 //    ("Services").
52 //    You understand and agree that, except otherwise agreed by both parties in
53 //    writing, Services are provided on an "AS IS" basis and the warranty
54 //    disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 //    or otherwise:
58 //    (a) conferring any license or right to use MStar name, trademark, service
59 //        mark, symbol or any other identification;
60 //    (b) obligating MStar or any of its affiliates to furnish any person,
61 //        including without limitation, you and your customers, any assistance
62 //        of any kind whatsoever, or any information; or
63 //    (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 //    of Taiwan, R.O.C., excluding its conflict of law rules.
67 //    Any and all dispute arising out hereof or related hereto shall be finally
68 //    settled by arbitration referred to the Chinese Arbitration Association,
69 //    Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 //    Rules of the Association by three (3) arbitrators appointed in accordance
71 //    with the said Rules.
72 //    The place of arbitration shall be in Taipei, Taiwan and the language shall
73 //    be English.
74 //    The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 2010-2012 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 // file   halMMFilein.c
97 // @brief  Multimedia File In (MMFILEIN) HAL
98 // @author MStar Semiconductor,Inc.
99 ////////////////////////////////////////////////////////////////////////////////////////////////////
100 #include "MsCommon.h"
101 #include "regMMFilein.h"
102 #include "halMMFilein.h"
103 
104 //--------------------------------------------------------------------------------------------------
105 //  Driver Compiler Option
106 //--------------------------------------------------------------------------------------------------
107 #define MIU_BUS                     4
108 
109 //--------------------------------------------------------------------------------------------------
110 //  TSP Hardware Abstraction Layer
111 //--------------------------------------------------------------------------------------------------
112 static REG_Ctrl_MMFI* _MFCtrl= NULL;
113 static REG_Ctrl_MMFI2* _MFCtrl2 = NULL;
114 
115 static MS_U32   _u32MMFIRegBase = 0;
116 
117 //[NOTE] Jerry
118 // Some register has write order, for example, writing PCR_L will disable PCR counter
119 // writing PCR_M trigger nothing, writing PCR_H will enable PCR counter
120 #define _HAL_REG32_W(reg, value)    do { (reg)->L = ((value) & 0x0000FFFF);                          \
121                                     (reg)->H = ((value) >> 16); } while(0)
122 
123 #define _HAL_REG16_W(reg, value)    do { (reg)->data = (MS_U16)((value) & 0xFFFF);} while(0)
124 //--------------------------------------------------------------------------------------------------
125 //  Macro of bit operations
126 //--------------------------------------------------------------------------------------------------
127 
128 //--------------------------------------------------------------------------------------------------
129 //  Implementation
130 //--------------------------------------------------------------------------------------------------
_HAL_REG32_R(REG32 * reg)131 static MS_U32 _HAL_REG32_R(REG32 *reg)
132 {
133     MS_U32     value = 0;
134     value  = (reg)->H << 16;
135     value |= (reg)->L;
136     return value;
137 }
138 
_HAL_REG16_R(REG16 * reg)139 static MS_U16 _HAL_REG16_R(REG16 *reg)
140 {
141     MS_U16              value = 0;
142     value = (reg)->data;
143     return value;
144 }
145 
HAL_MMFI_SetBank(MS_U32 u32BankAddr)146 void HAL_MMFI_SetBank(MS_U32 u32BankAddr)
147 {
148     _u32MMFIRegBase = u32BankAddr;
149     _MFCtrl = (REG_Ctrl_MMFI*)(_u32MMFIRegBase+ REG_CTRL_BASE_MMFI0);
150     _MFCtrl2 = (REG_Ctrl_MMFI2*)(_u32MMFIRegBase + REG_CTRL2);
151 }
152 
153 // ------------------------------------------------------
154 //   APIs
155 //-------------------------------------------------------
HAL_MMFI_PidFlt_Set(MS_U8 u8Eng,MS_U8 u8Idx,MS_U16 u16PID,MS_U32 u32entype)156 void HAL_MMFI_PidFlt_Set(MS_U8 u8Eng, MS_U8 u8Idx, MS_U16 u16PID, MS_U32 u32entype)
157 {
158     REG32* Reg = NULL;
159 
160     if(u8Idx < MMFI_PIDFLT_GROUP0)
161     {
162         Reg = &(_MFCtrl[u8Eng].PidFlt[u8Idx]);
163     }
164     else
165     {
166         Reg = &(_MFCtrl2[0].PidFlt[u8Eng][u8Idx - MMFI_PIDFLT_GROUP0]);
167     }
168 
169     _HAL_REG32_W(Reg, (MS_U32)u16PID | u32entype);
170 }
171 
HAL_MMFI_PidFlt_SetPid(MS_U8 u8Eng,MS_U8 u8Idx,MS_U16 u16PID)172 void HAL_MMFI_PidFlt_SetPid(MS_U8 u8Eng, MS_U8 u8Idx, MS_U16 u16PID)
173 {
174     MS_U32 u32data;
175     REG32* Reg = NULL;
176 
177     if(u8Idx < MMFI_PIDFLT_GROUP0)
178     {
179         Reg = &(_MFCtrl[u8Eng].PidFlt[u8Idx]);
180     }
181     else
182     {
183         Reg = &(_MFCtrl2[0].PidFlt[u8Eng][u8Idx - MMFI_PIDFLT_GROUP0]);
184     }
185 
186     u32data = (_HAL_REG32_R(Reg) & ~MMFI_PIDFLT_PID_MASK) | (MS_U32)u16PID;
187     _HAL_REG32_W(Reg, u32data);
188 }
189 
HAL_MMFI_PidFlt_Enable(MS_U8 u8Eng,MS_U8 u8Idx,MS_U32 u32entype,MS_BOOL benable)190 void HAL_MMFI_PidFlt_Enable(MS_U8 u8Eng, MS_U8 u8Idx, MS_U32 u32entype, MS_BOOL benable)
191 {
192     MS_U32 u32data;
193     REG32* Reg = NULL;
194 
195     if(u8Idx < MMFI_PIDFLT_GROUP0)
196     {
197         Reg = &(_MFCtrl[u8Eng].PidFlt[u8Idx]);
198     }
199     else
200     {
201         Reg = &(_MFCtrl2[0].PidFlt[u8Eng][u8Idx - MMFI_PIDFLT_GROUP0]);
202     }
203 
204     u32data = _HAL_REG32_R(Reg) & ~MMFI_PIDFLT_EN_MASK;
205 
206     if(benable)
207         u32data |= u32entype;
208 
209     _HAL_REG32_W(Reg, u32data);
210 }
211 
HAL_MMFI_PidFlt_Reset(MS_U8 u8Eng,MS_U8 u8Idx)212 void HAL_MMFI_PidFlt_Reset(MS_U8 u8Eng, MS_U8 u8Idx)
213 {
214     REG32* Reg = NULL;
215 
216     if(u8Idx < MMFI_PIDFLT_GROUP0)
217     {
218         Reg = &(_MFCtrl[u8Eng].PidFlt[u8Idx]);
219     }
220     else
221     {
222         Reg = &(_MFCtrl2[0].PidFlt[u8Eng][u8Idx - MMFI_PIDFLT_GROUP0]);
223     }
224 
225     _HAL_REG32_W(Reg, MMFI_PID_NULL);
226 }
227 
HAL_MMFI_Set_Filein_ReadAddr(MS_U8 u8Eng,MS_U32 u32Addr)228 void HAL_MMFI_Set_Filein_ReadAddr(MS_U8 u8Eng, MS_U32 u32Addr)
229 {
230     _HAL_REG32_W(&(_MFCtrl[u8Eng].FileIn_RAddr), u32Addr);
231 }
232 
HAL_MMFI_Set_Filein_ReadLen(MS_U8 u8Eng,MS_U32 u32len)233 void HAL_MMFI_Set_Filein_ReadLen(MS_U8 u8Eng, MS_U32 u32len)
234 {
235     _HAL_REG32_W(&(_MFCtrl[u8Eng].FileIn_RNum), u32len);
236 }
237 
HAL_MMFI_Set_Filein_Ctrl(MS_U8 u8Eng,MS_U16 u16ctrl,MS_BOOL bEnable)238 void HAL_MMFI_Set_Filein_Ctrl(MS_U8 u8Eng, MS_U16 u16ctrl, MS_BOOL bEnable)
239 {
240     if(bEnable)
241     {
242         _HAL_REG16_W(&(_MFCtrl[u8Eng].FileIn_Ctrl), _HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) | u16ctrl);
243     }
244     else
245     {
246         _HAL_REG16_W(&(_MFCtrl[u8Eng].FileIn_Ctrl), _HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) & ~u16ctrl);
247     }
248 }
249 
HAL_MMFI_Get_Filein_Ctrl(MS_U8 u8Eng)250 MS_U16 HAL_MMFI_Get_Filein_Ctrl(MS_U8 u8Eng)
251 {
252     return (_HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) & MMFI_FILEIN_CTRL_MASK);
253 }
254 
HAL_MMFI_Set_FileinTimer(MS_U8 u8Eng,MS_U8 u8timer)255 void HAL_MMFI_Set_FileinTimer(MS_U8 u8Eng, MS_U8 u8timer)
256 {
257     MS_U16 u16data = (_HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) & ~MMFI_FILEIN_TIMER_MASK) | ((MS_U16)(u8timer&0xFF) << MMFI_FILEIN_TIMER_SHIFT);
258     _HAL_REG16_W(&(_MFCtrl[u8Eng].FileIn_Ctrl), u16data);
259 }
260 
HAL_MMFI_Get_Filein_WriteAddr(MS_U8 u8Eng)261 MS_U32 HAL_MMFI_Get_Filein_WriteAddr(MS_U8 u8Eng)
262 {
263     MS_U32 u32addr = 0;
264 
265     HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_RADDR_READ, FALSE);
266     u32addr = _HAL_REG32_R(&(_MFCtrl[u8Eng].RAddr));
267     HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_RADDR_READ, TRUE);
268 
269     return u32addr;
270 }
271 
HAL_MMFI_CmdQ_FIFO_Get_WRCnt(MS_U8 u8Eng)272 MS_U16 HAL_MMFI_CmdQ_FIFO_Get_WRCnt(MS_U8 u8Eng)
273 {
274     return (_HAL_REG16_R(&(_MFCtrl[u8Eng].CmdQSts)) & MMFI_CMDQSTS_WRCNT_MASK);
275 }
276 
HAL_MMFI_CmdQ_FIFO_IsFull(MS_U8 u8Eng)277 MS_BOOL HAL_MMFI_CmdQ_FIFO_IsFull(MS_U8 u8Eng)
278 {
279     return (MS_BOOL)(_HAL_REG16_R(&(_MFCtrl[u8Eng].CmdQSts)) & MMFI_CMDQSTS_FIFO_FULL);
280 }
281 
HAL_MMFI_CmdQ_FIFO_IsEmpty(MS_U8 u8Eng)282 MS_BOOL HAL_MMFI_CmdQ_FIFO_IsEmpty(MS_U8 u8Eng)
283 {
284     return (MS_BOOL)(_HAL_REG16_R(&(_MFCtrl[u8Eng].CmdQSts)) & MMFI_CMDQSTS_FIFO_EMPTY);
285 }
286 
HAL_MMFI_CmdQ_FIFO_Get_WRLevel(MS_U8 u8Eng)287 MS_U16 HAL_MMFI_CmdQ_FIFO_Get_WRLevel(MS_U8 u8Eng)
288 {
289     return ((_HAL_REG16_R(&(_MFCtrl[u8Eng].CmdQSts)) & MMFI_CMDQSTS_FIFO_WRLEVEL_MASK) >> MMFI_CMDQSTS_FIFO_WRLEVEL_SHIFT);
290 }
291 
HAL_MMFI_Cfg_Enable(MS_U8 u8Eng,MS_U32 u32CfgItem,MS_BOOL benable)292 void HAL_MMFI_Cfg_Enable(MS_U8 u8Eng, MS_U32 u32CfgItem, MS_BOOL benable)
293 {
294     if(benable)
295     {
296         _HAL_REG32_W(&(_MFCtrl[u8Eng].Cfg), (_HAL_REG32_R(&(_MFCtrl[u8Eng].Cfg)) | u32CfgItem));
297     }
298     else
299     {
300         _HAL_REG32_W(&(_MFCtrl[u8Eng].Cfg), (_HAL_REG32_R(&(_MFCtrl[u8Eng].Cfg)) & ~u32CfgItem));
301     }
302 }
303 
HAL_MMFI_Cfg_Set(MS_U8 u8Eng,MS_U32 u32CfglItem)304 void   HAL_MMFI_Cfg_Set(MS_U8 u8Eng, MS_U32 u32CfglItem)
305 {
306     _HAL_REG32_W(&(_MFCtrl[u8Eng].Cfg), u32CfglItem);
307 }
308 
HAL_MMFI_Cfg_Get(MS_U8 u8Eng)309 MS_U32 HAL_MMFI_Cfg_Get(MS_U8 u8Eng)
310 {
311     return (_HAL_REG32_R(&(_MFCtrl[u8Eng].Cfg)));
312 }
313 
HAL_MMFI_Cfg2_Enable(MS_U8 u8Eng,MS_U16 u16CfgItem,MS_BOOL benable)314 void HAL_MMFI_Cfg2_Enable(MS_U8 u8Eng, MS_U16 u16CfgItem, MS_BOOL benable)
315 {
316     if(benable)
317     {
318         _HAL_REG16_W(&(_MFCtrl2[0].Cfg2[u8Eng]), (_HAL_REG16_R(&(_MFCtrl2[0].Cfg2[u8Eng])) | u16CfgItem));
319     }
320     else
321     {
322         _HAL_REG16_W(&(_MFCtrl2[0].Cfg2[u8Eng]), (_HAL_REG16_R(&(_MFCtrl2[0].Cfg2[u8Eng])) & ~u16CfgItem));
323     }
324 }
325 
HAL_MMFI_Cfg2_Set(MS_U8 u8Eng,MS_U16 u16CfglItem)326 void   HAL_MMFI_Cfg2_Set(MS_U8 u8Eng, MS_U16 u16CfglItem)
327 {
328     _HAL_REG16_W(&(_MFCtrl2[0].Cfg2[u8Eng]), u16CfglItem);
329 }
330 
HAL_MMFI_Cfg2_Get(MS_U8 u8Eng)331 MS_U16 HAL_MMFI_Cfg2_Get(MS_U8 u8Eng)
332 {
333     return (_HAL_REG16_R(&(_MFCtrl2[0].Cfg2[u8Eng])));
334 }
335 
336 
HAL_MMFI_Get_TsHeaderInfo(MS_U8 u8Eng,MS_U32 * pu32header)337 void HAL_MMFI_Get_TsHeaderInfo(MS_U8 u8Eng, MS_U32 *pu32header)
338 {
339     *pu32header = _HAL_REG32_R(&(_MFCtrl[u8Eng].TsHeader));
340 }
341 
HAL_MMFI_Get_APid_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)342 void HAL_MMFI_Get_APid_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
343 {
344     MS_U16 u16temp;
345 
346     u16temp = (MS_U16)_HAL_REG16_R(&(_MFCtrl[u8Eng].APid_Status));
347 
348     *pu16pid = u16temp & MMFI_APID_MATCHED_MASK;
349     *pbchanged = (MS_BOOL)(u16temp & MMFI_APID_CHANGE);
350 }
351 
HAL_MMFI_Get_APidB_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)352 void HAL_MMFI_Get_APidB_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
353 {
354     MS_U16 u16temp;
355 
356     u16temp = _HAL_REG16_R(&(_MFCtrl[u8Eng].APidB_Status));
357 
358     *pu16pid = u16temp & MMFI_APIDB_MATCHED_MASK;
359     *pbchanged = (MS_BOOL)(u16temp & MMFI_APIDB_CHANGE);
360 }
361 
HAL_MMFI_Get_VPid_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)362 void HAL_MMFI_Get_VPid_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
363 {
364     MS_U16 u16temp;
365 
366     u16temp = _HAL_REG16_R(&(_MFCtrl[u8Eng].VPID_Status));
367 
368     *pu16pid = u16temp & MMFI_VPID_MATCHED_MASK;
369     *pbchanged = (MS_BOOL)(u16temp & MMFI_VPID_CHANGE);
370 }
371 
HAL_MMFI_Get_VPid3D_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)372 void HAL_MMFI_Get_VPid3D_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
373 {
374     MS_U16 u16temp;
375 
376     u16temp = _HAL_REG16_R(&(_MFCtrl[u8Eng].VPID3D_Status));
377 
378     *pu16pid = u16temp & MMFI_VPID3D_MATCHED_MASK;
379     *pbchanged = (MS_BOOL)(u16temp & MMFI_VPID3D_CHANGE);
380 }
381 
HAL_MMFI_LPcr2_Set(MS_U8 u8Eng,MS_U32 u32lpcr2)382 void HAL_MMFI_LPcr2_Set(MS_U8 u8Eng, MS_U32 u32lpcr2)
383 {
384     HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_LPCR2_WLD, TRUE);
385     _HAL_REG32_W(&(_MFCtrl[u8Eng].LPcr2_Buf), u32lpcr2);
386     HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_LPCR2_WLD, FALSE);
387 }
388 
HAL_MMFI_LPcr2_Get(MS_U8 u8Eng)389 MS_U32 HAL_MMFI_LPcr2_Get(MS_U8 u8Eng)
390 {
391     MS_U32 u32value;
392 
393     HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_LPCR2_LD, TRUE);
394     u32value = _HAL_REG32_R(&(_MFCtrl[u8Eng].LPcr2_Buf));
395     HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_LPCR2_LD, FALSE);
396 
397     return u32value;
398 }
399 
HAL_MMFI_TimeStamp_Get(MS_U8 u8Eng)400 MS_U32 HAL_MMFI_TimeStamp_Get(MS_U8 u8Eng)
401 {
402     return _HAL_REG32_R(&(_MFCtrl[u8Eng].TimeStamp_FIn));
403 }
404 
HAL_MMFI_PktChkSize_Set(MS_U8 u8Eng,MS_U16 u16size)405 void HAL_MMFI_PktChkSize_Set(MS_U8 u8Eng, MS_U16 u16size)
406 {
407     _HAL_REG16_W(&(_MFCtrl[u8Eng].PktChkSize), (_HAL_REG16_R(&(_MFCtrl[u8Eng].PktChkSize)) & ~MMFI_PKTCHK_SIZE_MASK) | u16size);
408 }
409 
HAL_MMFI_MOBF_Set_FileinKey(MS_U8 u8Eng,MS_U16 u16KeyIndex)410 void HAL_MMFI_MOBF_Set_FileinKey(MS_U8 u8Eng, MS_U16 u16KeyIndex)
411 {
412     _HAL_REG16_W(&(_MFCtrl[u8Eng].MOBFKey), u16KeyIndex);
413 }
414 
HAL_MMFI_MOBF_Enable(MS_U8 u8Eng,MS_BOOL bEnable)415 void HAL_MMFI_MOBF_Enable(MS_U8 u8Eng, MS_BOOL bEnable)
416 {
417     return;
418 }
419 
HAL_MMFI_AU_RemoveDupPkt(MS_U8 u8Eng,MS_BOOL bEnable)420 void HAL_MMFI_AU_RemoveDupPkt(MS_U8 u8Eng, MS_BOOL bEnable)
421 {
422     MS_U32 u32data = _HAL_REG32_R(&(_MFCtrl[u8Eng].Cfg)) & ~MMFI_CFG_DUP_PKT_SKIP;
423 
424     if(bEnable)
425         u32data |= MMFI_CFG_DUP_PKT_SKIP;
426 
427     _HAL_REG32_W(&(_MFCtrl[u8Eng].Cfg), u32data);
428 }
429 
HAL_MMFI_TimeStampClk_Set(MS_U8 u8Eng,MS_U32 u32ClkSrc)430 void HAL_MMFI_TimeStampClk_Set(MS_U8 u8Eng, MS_U32 u32ClkSrc)
431 {
432     if(u32ClkSrc == 0x0) // 90k
433     {
434         _HAL_REG16_W(&(_MFCtrl2[0].Cfg2[u8Eng]), _HAL_REG16_R(&(_MFCtrl2[0].Cfg2[u8Eng])) & ~MMFI_CFG2_MMFI_27M_EN);
435     }
436     else
437     {
438         _HAL_REG16_W(&(_MFCtrl2[0].Cfg2[u8Eng]), _HAL_REG16_R(&(_MFCtrl2[0].Cfg2[u8Eng])) | MMFI_CFG2_MMFI_27M_EN);
439     }
440     return;
441 }
442 //
443 // General API
444 //
HAL_MMFI_Reset(void)445 void HAL_MMFI_Reset(void)
446 {
447     _HAL_REG16_W(&(_MFCtrl[0].SWRst), (_HAL_REG16_R(&(_MFCtrl[0].SWRst)) &~ MMFI_SW_RSTZ_MMFILEIN_DISABLE));
448     _HAL_REG16_W(&(_MFCtrl[0].SWRst), (_HAL_REG16_R(&(_MFCtrl[0].SWRst)) | MMFI_SW_RSTZ_MMFILEIN_DISABLE));
449 }
450 
HAL_MMFI_Reset_SubItem(MS_U16 u16RstItem)451 void HAL_MMFI_Reset_SubItem(MS_U16 u16RstItem)
452 {
453     _HAL_REG16_W(&(_MFCtrl[0].SWRst), (_HAL_REG16_R(&(_MFCtrl[0].SWRst)) | u16RstItem));
454     _HAL_REG16_W(&(_MFCtrl[0].SWRst), (_HAL_REG16_R(&(_MFCtrl[0].SWRst)) & ~u16RstItem));
455 }
456 
HAL_MMFI_Reset_All(void)457 void HAL_MMFI_Reset_All(void)
458 {
459     MS_U16 u16data = _HAL_REG16_R(&(_MFCtrl[0].SWRst)) & ~MMFI_SWRST_MASK;
460 
461     _HAL_REG16_W(&(_MFCtrl[0].SWRst), u16data | MMFI_RST_ALL);
462     _HAL_REG16_W(&(_MFCtrl[0].SWRst), (u16data & ~MMFI_SWRST_MASK) | MMFI_SW_RSTZ_MMFILEIN_DISABLE);
463 
464 }
465 
HAL_MMFI_HWInt_Enable(MS_BOOL benable,MS_U16 u16init)466 void HAL_MMFI_HWInt_Enable(MS_BOOL benable, MS_U16 u16init)
467 {
468     MS_U16 u16data = _HAL_REG16_R(&(_MFCtrl[0].HWInt)) & ~u16init;
469 
470     if(benable)
471     {
472         _HAL_REG16_W(&(_MFCtrl[0].HWInt), (u16data | u16init));
473     }
474     else
475     {
476         _HAL_REG16_W(&(_MFCtrl[0].HWInt), u16data);
477     }
478 }
479 
HAL_MMFI_HWInt_Clear(MS_U16 u16Int)480 void HAL_MMFI_HWInt_Clear(MS_U16 u16Int)
481 {
482     _HAL_REG16_W(&(_MFCtrl[0].HWInt), (_HAL_REG16_R(&(_MFCtrl[0].HWInt)) & ~u16Int));
483 }
484 
HAL_MMFI_HWInt_Status(void)485 MS_U32 HAL_MMFI_HWInt_Status(void)
486 {
487     return (MS_U32)(_HAL_REG16_R(&(_MFCtrl[0].HWInt)) & MMFI_HWINT_STS_MASK);
488 }
489 
490