xref: /utopia/UTPA2-700.0.x/modules/dmx/hal/k7u/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 #include "halCHIP.h"
104 
105 //--------------------------------------------------------------------------------------------------
106 //  Driver Compiler Option
107 //--------------------------------------------------------------------------------------------------
108 #define MIU_BUS                     4
109 
110 //--------------------------------------------------------------------------------------------------
111 //  TSP Hardware Abstraction Layer
112 //--------------------------------------------------------------------------------------------------
113 static REG_Ctrl_MMFI*  _MFCtrl= NULL;
114 static REG_Ctrl_MMFI1* _MFCtrl1= NULL;
115 
116 
117 static MS_VIRT   _u32MMFIRegBase = 0;
118 
119 //[NOTE] Jerry
120 // Some register has write order, for example, writing PCR_L will disable PCR counter
121 // writing PCR_M trigger nothing, writing PCR_H will enable PCR counter
122 #define _HAL_REG32_W(reg, value)    do { (reg)->L = ((value) & 0x0000FFFF);                          \
123                                     (reg)->H = ((value) >> 16); } while(0)
124 
125 #define _HAL_REG16_W(reg, value)    do { (reg)->data = (MS_U16)((value) & 0xFFFF);} while(0)
126 //--------------------------------------------------------------------------------------------------
127 //  Macro of bit operations
128 //--------------------------------------------------------------------------------------------------
129 
130 //--------------------------------------------------------------------------------------------------
131 //  Implementation
132 //--------------------------------------------------------------------------------------------------
_HAL_REG32_R(REG32_MM * reg)133 static MS_U32 _HAL_REG32_R(REG32_MM *reg)
134 {
135     MS_U32     value = 0;
136     value  = (reg)->H << 16;
137     value |= (reg)->L;
138     return value;
139 }
140 
_HAL_REG16_R(REG16_MM * reg)141 static MS_U16 _HAL_REG16_R(REG16_MM *reg)
142 {
143     MS_U16              value = 0;
144     value = (reg)->data;
145     return value;
146 }
147 
HAL_MMFI_SetBank(MS_VIRT u32BankAddr)148 void HAL_MMFI_SetBank(MS_VIRT u32BankAddr)
149 {
150     _u32MMFIRegBase = u32BankAddr;
151     _MFCtrl = (REG_Ctrl_MMFI*)(_u32MMFIRegBase + REG_CTRL_BASE_MMFI0);
152     _MFCtrl1 = (REG_Ctrl_MMFI1*)(_u32MMFIRegBase + REG_CTRL_BASE_MMFI1);
153 }
154 
155 // ------------------------------------------------------
156 //   APIs
157 //-------------------------------------------------------
HAL_MMFI_PidFlt_Set(MS_U8 u8Eng,MS_U8 u8Idx,MS_U16 u16PID,MS_U32 u32entype)158 void HAL_MMFI_PidFlt_Set(MS_U8 u8Eng, MS_U8 u8Idx, MS_U16 u16PID, MS_U32 u32entype)
159 {
160     _HAL_REG32_W(&(_MFCtrl[u8Eng].PidFlt[u8Idx]), (MS_U32)u16PID | u32entype);
161 }
162 
HAL_MMFI_PidFlt_SetPid(MS_U8 u8Eng,MS_U8 u8Idx,MS_U16 u16PID)163 void HAL_MMFI_PidFlt_SetPid(MS_U8 u8Eng, MS_U8 u8Idx, MS_U16 u16PID)
164 {
165     MS_U32 u32data;
166 
167     u32data = (_HAL_REG32_R(&(_MFCtrl[u8Eng].PidFlt[u8Idx])) & ~MMFI_PIDFLT_PID_MASK) | (MS_U32)u16PID;
168     _HAL_REG32_W(&(_MFCtrl[u8Eng].PidFlt[u8Idx]), u32data);
169 }
170 
HAL_MMFI_PidFlt_Enable(MS_U8 u8Eng,MS_U8 u8Idx,MS_U32 u32entype,MS_BOOL benable)171 void HAL_MMFI_PidFlt_Enable(MS_U8 u8Eng, MS_U8 u8Idx, MS_U32 u32entype, MS_BOOL benable)
172 {
173     MS_U32 u32data;
174 
175     u32data = _HAL_REG32_R(&(_MFCtrl[u8Eng].PidFlt[u8Idx])) & ~MMFI_PIDFLT_EN_MASK;
176 
177     if(benable)
178         u32data |= u32entype;
179 
180     _HAL_REG32_W(&(_MFCtrl[u8Eng].PidFlt[u8Idx]), u32data);
181 }
182 
HAL_MMFI_PidFlt_Reset(MS_U8 u8Eng,MS_U8 u8Idx)183 void HAL_MMFI_PidFlt_Reset(MS_U8 u8Eng, MS_U8 u8Idx)
184 {
185     _HAL_REG32_W(&(_MFCtrl[u8Eng].PidFlt[u8Idx]), MMFI_PID_NULL);
186 }
187 
HAL_MMFI_Set_Filein_ReadAddr(MS_U8 u8Eng,MS_U32 u32Addr)188 void HAL_MMFI_Set_Filein_ReadAddr(MS_U8 u8Eng, MS_U32 u32Addr)
189 {
190     MS_U8 u8MiuSel = 0;
191     MS_PHY phyMiuOffsetMMFiBuf = 0;
192     _phy_to_miu_offset(u8MiuSel, phyMiuOffsetMMFiBuf, u32Addr);
193 
194     _HAL_REG32_W(&(_MFCtrl[u8Eng].FileIn_RAddr), phyMiuOffsetMMFiBuf);
195 }
196 
HAL_MMFI_Set_Filein_ReadLen(MS_U8 u8Eng,MS_U32 u32len)197 void HAL_MMFI_Set_Filein_ReadLen(MS_U8 u8Eng, MS_U32 u32len)
198 {
199     _HAL_REG32_W(&(_MFCtrl[u8Eng].FileIn_RNum), u32len);
200 }
201 
HAL_MMFI_Set_Filein_Ctrl(MS_U8 u8Eng,MS_U16 u16ctrl,MS_BOOL bEnable)202 void HAL_MMFI_Set_Filein_Ctrl(MS_U8 u8Eng, MS_U16 u16ctrl, MS_BOOL bEnable)
203 {
204     if(bEnable)
205     {
206         _HAL_REG16_W(&(_MFCtrl[u8Eng].FileIn_Ctrl), _HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) | u16ctrl);
207     }
208     else
209     {
210         _HAL_REG16_W(&(_MFCtrl[u8Eng].FileIn_Ctrl), _HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) & ~u16ctrl);
211     }
212 }
213 
HAL_MMFI_Get_Filein_Ctrl(MS_U8 u8Eng)214 MS_U16 HAL_MMFI_Get_Filein_Ctrl(MS_U8 u8Eng)
215 {
216     return (_HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) & MMFI_FILEIN_CTRL_MASK);
217 }
218 
HAL_MMFI_Filein_Pause(MS_U8 u8Eng)219 MS_BOOL HAL_MMFI_Filein_Pause(MS_U8 u8Eng)
220 {
221     _HAL_REG16_W(&(_MFCtrl[u8Eng].CFG2), _HAL_REG16_R(&(_MFCtrl[u8Eng].CFG2)) | MMFI_CFG2_FILEIN_PAUSE);
222 
223     return TRUE;
224 }
225 
HAL_MMFI_Filein_Resume(MS_U8 u8Eng)226 MS_BOOL HAL_MMFI_Filein_Resume(MS_U8 u8Eng)
227 {
228     _HAL_REG16_W(&(_MFCtrl[u8Eng].CFG2), _HAL_REG16_R(&(_MFCtrl[u8Eng].CFG2)) & ~MMFI_CFG2_FILEIN_PAUSE);
229 
230     return TRUE;
231 }
232 
HAL_MMFI_Set_FileinTimer(MS_U8 u8Eng,MS_U8 u8timer)233 void HAL_MMFI_Set_FileinTimer(MS_U8 u8Eng, MS_U8 u8timer)
234 {
235     MS_U16 u16data = (_HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Timer)) & ~MMFI_FILEIN_TIMER_MASK) | ((MS_U16)(u8timer&0xFF) << MMFI_FILEIN_TIMER_SHIFT);
236     _HAL_REG16_W(&(_MFCtrl[u8Eng].FileIn_Timer), u16data);
237 }
238 
HAL_MMFI_Get_Filein_WriteAddr(MS_U8 u8Eng)239 MS_U32 HAL_MMFI_Get_Filein_WriteAddr(MS_U8 u8Eng)
240 {
241     MS_U32 u32addr = 0;
242 
243     HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_RADDR_READ, FALSE);
244     u32addr = _HAL_REG32_R(&(_MFCtrl[u8Eng].RAddr));
245     HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_RADDR_READ, TRUE);
246 
247     return u32addr;
248 }
249 
HAL_MMFI_CmdQ_FIFO_Get_WRCnt(MS_U8 u8Eng)250 MS_U16 HAL_MMFI_CmdQ_FIFO_Get_WRCnt(MS_U8 u8Eng)
251 {
252     return (_HAL_REG16_R(&(_MFCtrl[u8Eng].CmdQSts)) & MMFI_CMDQSTS_WRCNT_MASK);
253 }
254 
HAL_MMFI_CmdQ_FIFO_IsFull(MS_U8 u8Eng)255 MS_BOOL HAL_MMFI_CmdQ_FIFO_IsFull(MS_U8 u8Eng)
256 {
257     return (MS_BOOL)(_HAL_REG16_R(&(_MFCtrl[u8Eng].CmdQSts)) & MMFI_CMDQSTS_FIFO_FULL);
258 }
259 
HAL_MMFI_CmdQ_FIFO_IsEmpty(MS_U8 u8Eng)260 MS_BOOL HAL_MMFI_CmdQ_FIFO_IsEmpty(MS_U8 u8Eng)
261 {
262     return (MS_BOOL)(_HAL_REG16_R(&(_MFCtrl[u8Eng].CmdQSts)) & MMFI_CMDQSTS_FIFO_EMPTY);
263 }
264 
HAL_MMFI_CmdQ_FIFO_Get_WRLevel(MS_U8 u8Eng)265 MS_U16 HAL_MMFI_CmdQ_FIFO_Get_WRLevel(MS_U8 u8Eng)
266 {
267     return ((_HAL_REG16_R(&(_MFCtrl[u8Eng].CmdQSts)) & MMFI_CMDQSTS_FIFO_WRLEVEL_MASK) >> MMFI_CMDQSTS_FIFO_WRLEVEL_SHIFT);
268 }
269 
HAL_MMFI_Cfg_Enable(MS_U8 u8Eng,MS_U32 u32CfgItem,MS_BOOL benable)270 void HAL_MMFI_Cfg_Enable(MS_U8 u8Eng, MS_U32 u32CfgItem, MS_BOOL benable)
271 {
272     if(benable)
273     {
274         _HAL_REG32_W(&(_MFCtrl[u8Eng].Cfg), (_HAL_REG32_R(&(_MFCtrl[u8Eng].Cfg)) | u32CfgItem));
275     }
276     else
277     {
278         _HAL_REG32_W(&(_MFCtrl[u8Eng].Cfg), (_HAL_REG32_R(&(_MFCtrl[u8Eng].Cfg)) & ~u32CfgItem));
279     }
280 }
281 
HAL_MMFI_Cfg_Set(MS_U8 u8Eng,MS_U32 u32CfglItem)282 void HAL_MMFI_Cfg_Set(MS_U8 u8Eng, MS_U32 u32CfglItem)
283 {
284     _HAL_REG32_W(&(_MFCtrl[u8Eng].Cfg), u32CfglItem);
285 }
286 
HAL_MMFI_Cfg_Get(MS_U8 u8Eng)287 MS_U32 HAL_MMFI_Cfg_Get(MS_U8 u8Eng)
288 {
289     return (_HAL_REG32_R(&(_MFCtrl[u8Eng].Cfg)));
290 }
291 
HAL_MMFI_Cfg2_Enable(MS_U8 u8Eng,MS_U16 u16CfgItem,MS_BOOL benable)292 void HAL_MMFI_Cfg2_Enable(MS_U8 u8Eng, MS_U16 u16CfgItem, MS_BOOL benable)
293 {
294     if(benable)
295     {
296         _HAL_REG16_W(&(_MFCtrl[u8Eng].CFG2), (_HAL_REG16_R(&(_MFCtrl[u8Eng].CFG2)) | u16CfgItem));
297     }
298     else
299     {
300         _HAL_REG16_W(&(_MFCtrl[u8Eng].CFG2), (_HAL_REG16_R(&(_MFCtrl[u8Eng].CFG2)) & ~u16CfgItem));
301     }
302 }
303 
HAL_MMFI_Cfg2_Set(MS_U8 u8Eng,MS_U16 u16CfglItem)304 void HAL_MMFI_Cfg2_Set(MS_U8 u8Eng, MS_U16 u16CfglItem)
305 {
306     _HAL_REG16_W(&(_MFCtrl[u8Eng].CFG2), u16CfglItem);
307 }
308 
HAL_MMFI_Cfg2_Get(MS_U8 u8Eng)309 MS_U16 HAL_MMFI_Cfg2_Get(MS_U8 u8Eng)
310 {
311     return (_HAL_REG16_R(&(_MFCtrl[u8Eng].CFG2)));
312 }
313 
HAL_MMFI_Cfg3_Enable(MS_U8 u8Eng,MS_U16 u16CfgItem,MS_BOOL benable)314 void HAL_MMFI_Cfg3_Enable(MS_U8 u8Eng, MS_U16 u16CfgItem, MS_BOOL benable)
315 {
316     if(benable)
317     {
318         _HAL_REG16_W(&(_MFCtrl[u8Eng].CFG3), (_HAL_REG16_R(&(_MFCtrl[u8Eng].CFG3)) | u16CfgItem));
319     }
320     else
321     {
322         _HAL_REG16_W(&(_MFCtrl[u8Eng].CFG3), (_HAL_REG16_R(&(_MFCtrl[u8Eng].CFG3)) & ~u16CfgItem));
323     }
324 }
325 
HAL_MMFI_Cfg3_Set(MS_U8 u8Eng,MS_U16 u16CfglItem)326 void HAL_MMFI_Cfg3_Set(MS_U8 u8Eng, MS_U16 u16CfglItem)
327 {
328     _HAL_REG16_W(&(_MFCtrl[u8Eng].CFG3), u16CfglItem);
329 }
330 
HAL_MMFI_Cfg3_Get(MS_U8 u8Eng)331 MS_U16 HAL_MMFI_Cfg3_Get(MS_U8 u8Eng)
332 {
333     return (_HAL_REG16_R(&(_MFCtrl[u8Eng].CFG3)));
334 }
335 
HAL_MMFI_Get_TsHeaderInfo(MS_U8 u8Eng,MS_U32 * pu32header)336 void HAL_MMFI_Get_TsHeaderInfo(MS_U8 u8Eng, MS_U32 *pu32header)
337 {
338     *pu32header = _HAL_REG32_R(&(_MFCtrl[u8Eng].TsHeader));
339 }
340 
HAL_MMFI_Get_APid_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)341 void HAL_MMFI_Get_APid_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
342 {
343     //@NOTE: need to delete
344 }
345 
HAL_MMFI_Get_APidB_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)346 void HAL_MMFI_Get_APidB_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
347 {
348     //@NOTE: need to delete
349 }
350 
HAL_MMFI_Get_APidC_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)351 void HAL_MMFI_Get_APidC_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
352 {
353     //@NOTE: need to delete
354 }
355 
HAL_MMFI_Get_APidD_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)356 void HAL_MMFI_Get_APidD_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
357 {
358     //@NOTE: need to delete
359 }
360 
HAL_MMFI_Get_VPid_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)361 void HAL_MMFI_Get_VPid_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
362 {
363     //@NOTE: need to delete
364 }
365 
HAL_MMFI_Get_VPid3D_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)366 void HAL_MMFI_Get_VPid3D_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
367 {
368     //@NOTE: need to delete
369 }
370 
HAL_MMFI_Get_VPid3_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)371 void HAL_MMFI_Get_VPid3_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
372 {
373     //@NOTE: need to delete
374 }
375 
HAL_MMFI_Get_VPid4_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)376 void HAL_MMFI_Get_VPid4_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
377 {
378     //@NOTE: need to delete
379 }
380 
HAL_MMFI_LPcr2_Set(MS_U8 u8Eng,MS_U32 u32lpcr2)381 void HAL_MMFI_LPcr2_Set(MS_U8 u8Eng, MS_U32 u32lpcr2)
382 {
383     HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_LPCR2_WLD, TRUE);
384     _HAL_REG32_W(&(_MFCtrl[u8Eng].LPcr2_Buf), u32lpcr2);
385     HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_LPCR2_WLD, FALSE);
386 }
387 
HAL_MMFI_LPcr2_Get(MS_U8 u8Eng)388 MS_U32 HAL_MMFI_LPcr2_Get(MS_U8 u8Eng)
389 {
390     MS_U32 u32value;
391 
392     HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_LPCR2_LD, TRUE);
393     u32value = _HAL_REG32_R(&(_MFCtrl[u8Eng].LPcr2_Buf));
394     HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_LPCR2_LD, FALSE);
395 
396     return u32value;
397 }
398 
HAL_MMFI_TimeStamp_Get(MS_U8 u8Eng)399 MS_U32 HAL_MMFI_TimeStamp_Get(MS_U8 u8Eng)
400 {
401     return _HAL_REG32_R(&(_MFCtrl[u8Eng].TimeStamp_FIn));
402 }
403 
HAL_MMFI_PktChkSize_Set(MS_U8 u8Eng,MS_U16 u16size)404 void HAL_MMFI_PktChkSize_Set(MS_U8 u8Eng, MS_U16 u16size)
405 {
406     _HAL_REG16_W(&(_MFCtrl[u8Eng].PktChkSize), (_HAL_REG16_R(&(_MFCtrl[u8Eng].PktChkSize)) & ~MMFI_PKTCHK_SIZE_MASK) | u16size);
407 }
408 
HAL_MMFI_MOBF_Set_FileinKey(MS_U8 u8Eng,MS_U16 u16KeyIndex)409 void HAL_MMFI_MOBF_Set_FileinKey(MS_U8 u8Eng, MS_U16 u16KeyIndex)
410 {
411     _HAL_REG16_W(&(_MFCtrl[u8Eng].MOBFKey), u16KeyIndex);
412 }
413 
HAL_MMFI_MOBF_Enable(MS_U8 u8Eng,MS_BOOL bEnable)414 void HAL_MMFI_MOBF_Enable(MS_U8 u8Eng, MS_BOOL bEnable)
415 {
416     MS_U16 u16data = _HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) & ~MMFI_FILEIN_CTRL_MOBF_EN;
417 
418     if(bEnable)
419     {
420         u16data |= MMFI_FILEIN_CTRL_MOBF_EN;
421     }
422 
423     _HAL_REG16_W(&(_MFCtrl[u8Eng].FileIn_Ctrl), u16data);
424 }
425 
426 //
427 // General API
428 //
HAL_MMFI_Reset(void)429 void HAL_MMFI_Reset(void)
430 {
431     _HAL_REG16_W(&(_MFCtrl1[0].SWRst), (_HAL_REG16_R(&(_MFCtrl1[0].SWRst)) & ~MMFI_SW_RSTZ_MMFILEIN_DISABLE));
432     _HAL_REG16_W(&(_MFCtrl1[0].SWRst), (_HAL_REG16_R(&(_MFCtrl1[0].SWRst)) | MMFI_SW_RSTZ_MMFILEIN_DISABLE));
433 }
434 
HAL_MMFI_Reset_SubItem(MS_U16 u16RstItem)435 void HAL_MMFI_Reset_SubItem(MS_U16 u16RstItem)
436 {
437     _HAL_REG16_W(&(_MFCtrl1[0].SWRst), (_HAL_REG16_R(&(_MFCtrl1[0].SWRst)) | u16RstItem));
438     _HAL_REG16_W(&(_MFCtrl1[0].SWRst), (_HAL_REG16_R(&(_MFCtrl1[0].SWRst)) & ~u16RstItem));
439 }
440 
HAL_MMFI_Reset_All(void)441 void HAL_MMFI_Reset_All(void)
442 {
443     MS_U16 u16data = _HAL_REG16_R(&(_MFCtrl1[0].SWRst)) & ~MMFI_SWRST_MASK;
444 
445     _HAL_REG16_W(&(_MFCtrl1[0].SWRst), u16data | MMFI_RST_ALL);
446     _HAL_REG16_W(&(_MFCtrl1[0].SWRst), (u16data & ~MMFI_SWRST_MASK) | MMFI_SW_RSTZ_MMFILEIN_DISABLE);
447 }
448 
HAL_MMFI_HWInt_Enable(MS_BOOL benable,MS_U16 u16init)449 void HAL_MMFI_HWInt_Enable(MS_BOOL benable, MS_U16 u16init)
450 {
451     MS_U16 u16data = _HAL_REG16_R(&(_MFCtrl1[0].HWInt)) & ~u16init;
452 
453     if(benable)
454     {
455         _HAL_REG16_W(&(_MFCtrl1[0].HWInt), (u16data | u16init));
456     }
457     else
458     {
459         _HAL_REG16_W(&(_MFCtrl1[0].HWInt), u16data);
460     }
461 }
462 
HAL_MMFI_HWInt_Clear(MS_U16 u16Int)463 void HAL_MMFI_HWInt_Clear(MS_U16 u16Int)
464 {
465     _HAL_REG16_W(&(_MFCtrl1[0].HWInt), (_HAL_REG16_R(&(_MFCtrl1[0].HWInt)) | u16Int));
466     _HAL_REG16_W(&(_MFCtrl1[0].HWInt), (_HAL_REG16_R(&(_MFCtrl1[0].HWInt)) & ~u16Int));
467 }
468 
HAL_MMFI_HWInt_Status(void)469 MS_U32 HAL_MMFI_HWInt_Status(void)
470 {
471     return (MS_U32)(_HAL_REG16_R(&(_MFCtrl1[0].HWInt)) & MMFI_HWINT_STS_MASK);
472 }
473 
HAL_MMFI_TimeStampClk_Set(MS_U8 u8Eng,MS_U32 u32ClkSrc)474 void HAL_MMFI_TimeStampClk_Set(MS_U8 u8Eng, MS_U32 u32ClkSrc)
475 {
476     MS_U16 u16Mask = (u8Eng)? MMFI_RST_LPCR_27M_EN_MMFI1 : MMFI_RST_LPCR_27M_EN_MMFI0;
477 
478     if(u32ClkSrc == 0x0UL) // 90k
479     {
480         _HAL_REG16_W(&(_MFCtrl1[0].SWRst), (_HAL_REG16_R(&(_MFCtrl1[0].SWRst)) & ~u16Mask));
481     }
482     else                   // 27M
483     {
484         _HAL_REG16_W(&(_MFCtrl1[0].SWRst), (_HAL_REG16_R(&(_MFCtrl1[0].SWRst)) | u16Mask));
485     }
486 }
487 
HAL_MMFI_RVU_Enable(MS_U8 u8Eng,MS_BOOL bEnable)488 MS_BOOL HAL_MMFI_RVU_Enable(MS_U8 u8Eng, MS_BOOL bEnable)
489 {
490     if(bEnable)
491     {
492         _HAL_REG16_W(&(_MFCtrl[u8Eng].RVU), _HAL_REG16_R(&(_MFCtrl[u8Eng].RVU)) | MMFI_RVU_EN);
493     }
494     else
495     {
496         _HAL_REG16_W(&(_MFCtrl[u8Eng].RVU), _HAL_REG16_R(&(_MFCtrl[u8Eng].RVU)) & ~MMFI_RVU_EN);
497     }
498 
499     return TRUE;
500 }
501 
HAL_MMFI_RVU_Timestamp_Enable(MS_U8 u8Eng,MS_BOOL bEnable)502 MS_BOOL HAL_MMFI_RVU_Timestamp_Enable(MS_U8 u8Eng, MS_BOOL bEnable)
503 {
504     if(bEnable)
505     {
506         _HAL_REG16_W(&(_MFCtrl[u8Eng].RVU), _HAL_REG16_R(&(_MFCtrl[u8Eng].RVU)) | MMFI_RVU_TIMESTAMP_EN);
507     }
508     else
509     {
510         _HAL_REG16_W(&(_MFCtrl[u8Eng].RVU), _HAL_REG16_R(&(_MFCtrl[u8Eng].RVU)) & ~MMFI_RVU_TIMESTAMP_EN);
511     }
512 
513     return TRUE;
514 }
515 
516 // Not implement
HAL_MMFI_SaveRegs(void)517 void HAL_MMFI_SaveRegs(void)
518 {
519 
520 }
521 
522 // Not implement
HAL_MMFI_RestoreRegs(void)523 void HAL_MMFI_RestoreRegs(void)
524 {
525 
526 }