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 if(!u32entype)
176 {
177 printf("[MMFI_ERR][%s][%d] Wrong filter destination !!!\n", __FUNCTION__, __LINE__);
178 return;
179 }
180
181 u32data = _HAL_REG32_R(&(_MFCtrl[u8Eng].PidFlt[u8Idx])) & ~MMFI_PIDFLT_EN_MASK;
182
183 if(benable)
184 u32data |= u32entype;
185
186 _HAL_REG32_W(&(_MFCtrl[u8Eng].PidFlt[u8Idx]), u32data);
187 }
188
HAL_MMFI_PidFlt_Reset(MS_U8 u8Eng,MS_U8 u8Idx)189 void HAL_MMFI_PidFlt_Reset(MS_U8 u8Eng, MS_U8 u8Idx)
190 {
191 _HAL_REG32_W(&(_MFCtrl[u8Eng].PidFlt[u8Idx]), MMFI_PID_NULL);
192 }
193
HAL_MMFI_Set_Filein_ReadAddr(MS_U8 u8Eng,MS_U32 u32Addr)194 void HAL_MMFI_Set_Filein_ReadAddr(MS_U8 u8Eng, MS_U32 u32Addr)
195 {
196 MS_U8 u8MiuSel = 0;
197 MS_PHY phyMiuOffsetMMFiBuf = 0;
198 _phy_to_miu_offset(u8MiuSel, phyMiuOffsetMMFiBuf, u32Addr);
199
200 _HAL_REG32_W(&(_MFCtrl[u8Eng].FileIn_RAddr), phyMiuOffsetMMFiBuf);
201 }
202
HAL_MMFI_Set_Filein_ReadLen(MS_U8 u8Eng,MS_U32 u32len)203 void HAL_MMFI_Set_Filein_ReadLen(MS_U8 u8Eng, MS_U32 u32len)
204 {
205 _HAL_REG32_W(&(_MFCtrl[u8Eng].FileIn_RNum), u32len);
206 }
207
HAL_MMFI_Set_Filein_Ctrl(MS_U8 u8Eng,MS_U16 u16ctrl,MS_BOOL bEnable)208 void HAL_MMFI_Set_Filein_Ctrl(MS_U8 u8Eng, MS_U16 u16ctrl, MS_BOOL bEnable)
209 {
210 if(bEnable)
211 {
212 _HAL_REG16_W(&(_MFCtrl[u8Eng].FileIn_Ctrl), _HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) | u16ctrl);
213 }
214 else
215 {
216 _HAL_REG16_W(&(_MFCtrl[u8Eng].FileIn_Ctrl), _HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) & ~u16ctrl);
217 }
218 }
219
HAL_MMFI_Get_Filein_Ctrl(MS_U8 u8Eng)220 MS_U16 HAL_MMFI_Get_Filein_Ctrl(MS_U8 u8Eng)
221 {
222 return (_HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) & MMFI_FILEIN_CTRL_MASK);
223 }
224
HAL_MMFI_Filein_Pause(MS_U8 u8Eng)225 MS_BOOL HAL_MMFI_Filein_Pause(MS_U8 u8Eng)
226 {
227 _HAL_REG16_W(&(_MFCtrl1->CFG2[u8Eng]), _HAL_REG16_R(&(_MFCtrl1->CFG2[u8Eng])) | MMFI_CFG2_FILEIN_PAUSE);
228
229 return TRUE;
230 }
231
HAL_MMFI_Filein_Resume(MS_U8 u8Eng)232 MS_BOOL HAL_MMFI_Filein_Resume(MS_U8 u8Eng)
233 {
234 _HAL_REG16_W(&(_MFCtrl1->CFG2[u8Eng]), _HAL_REG16_R(&(_MFCtrl1->CFG2[u8Eng])) & ~MMFI_CFG2_FILEIN_PAUSE);
235
236 return TRUE;
237 }
238
HAL_MMFI_Set_FileinTimer(MS_U8 u8Eng,MS_U8 u8timer)239 void HAL_MMFI_Set_FileinTimer(MS_U8 u8Eng, MS_U8 u8timer)
240 {
241 MS_U16 u16data = (_HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) & ~MMFI_FILEIN_TIMER_MASK) | ((MS_U16)(u8timer&0xFF) << MMFI_FILEIN_TIMER_SHIFT);
242 _HAL_REG16_W(&(_MFCtrl[u8Eng].FileIn_Ctrl), u16data);
243 }
244
HAL_MMFI_Get_Filein_WriteAddr(MS_U8 u8Eng)245 MS_U32 HAL_MMFI_Get_Filein_WriteAddr(MS_U8 u8Eng)
246 {
247 MS_U32 u32addr = 0;
248
249 HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_RADDR_READ, FALSE);
250 u32addr = _HAL_REG32_R(&(_MFCtrl[u8Eng].RAddr));
251 HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_RADDR_READ, TRUE);
252
253 return u32addr;
254 }
255
HAL_MMFI_CmdQ_FIFO_Get_WRCnt(MS_U8 u8Eng)256 MS_U16 HAL_MMFI_CmdQ_FIFO_Get_WRCnt(MS_U8 u8Eng)
257 {
258 return (_HAL_REG16_R(&(_MFCtrl[u8Eng].CmdQSts)) & MMFI_CMDQSTS_WRCNT_MASK);
259 }
260
HAL_MMFI_CmdQ_FIFO_IsFull(MS_U8 u8Eng)261 MS_BOOL HAL_MMFI_CmdQ_FIFO_IsFull(MS_U8 u8Eng)
262 {
263 return (MS_BOOL)(_HAL_REG16_R(&(_MFCtrl[u8Eng].CmdQSts)) & MMFI_CMDQSTS_FIFO_FULL);
264 }
265
HAL_MMFI_CmdQ_FIFO_IsEmpty(MS_U8 u8Eng)266 MS_BOOL HAL_MMFI_CmdQ_FIFO_IsEmpty(MS_U8 u8Eng)
267 {
268 return (MS_BOOL)(_HAL_REG16_R(&(_MFCtrl[u8Eng].CmdQSts)) & MMFI_CMDQSTS_FIFO_EMPTY);
269 }
270
HAL_MMFI_CmdQ_FIFO_Get_WRLevel(MS_U8 u8Eng)271 MS_U16 HAL_MMFI_CmdQ_FIFO_Get_WRLevel(MS_U8 u8Eng)
272 {
273 return ((_HAL_REG16_R(&(_MFCtrl[u8Eng].CmdQSts)) & MMFI_CMDQSTS_FIFO_WRLEVEL_MASK) >> MMFI_CMDQSTS_FIFO_WRLEVEL_SHIFT);
274 }
275
HAL_MMFI_Cfg_Enable(MS_U8 u8Eng,MS_U32 u32CfgItem,MS_BOOL benable)276 void HAL_MMFI_Cfg_Enable(MS_U8 u8Eng, MS_U32 u32CfgItem, MS_BOOL benable)
277 {
278 if(benable)
279 {
280 _HAL_REG32_W(&(_MFCtrl[u8Eng].Cfg), (_HAL_REG32_R(&(_MFCtrl[u8Eng].Cfg)) | u32CfgItem));
281 }
282 else
283 {
284 _HAL_REG32_W(&(_MFCtrl[u8Eng].Cfg), (_HAL_REG32_R(&(_MFCtrl[u8Eng].Cfg)) & ~u32CfgItem));
285 }
286 }
287
HAL_MMFI_Cfg_Set(MS_U8 u8Eng,MS_U32 u32CfglItem)288 void HAL_MMFI_Cfg_Set(MS_U8 u8Eng, MS_U32 u32CfglItem)
289 {
290 _HAL_REG32_W(&(_MFCtrl[u8Eng].Cfg), u32CfglItem);
291 }
292
HAL_MMFI_Cfg_Get(MS_U8 u8Eng)293 MS_U32 HAL_MMFI_Cfg_Get(MS_U8 u8Eng)
294 {
295 return (_HAL_REG32_R(&(_MFCtrl[u8Eng].Cfg)));
296 }
297
HAL_MMFI_Cfg2_Enable(MS_U8 u8Eng,MS_U16 u16CfgItem,MS_BOOL benable)298 void HAL_MMFI_Cfg2_Enable(MS_U8 u8Eng, MS_U16 u16CfgItem, MS_BOOL benable)
299 {
300 if(benable)
301 {
302 _HAL_REG16_W(&(_MFCtrl1->CFG2[u8Eng]), (_HAL_REG16_R(&(_MFCtrl1->CFG2[u8Eng])) | u16CfgItem));
303 }
304 else
305 {
306 _HAL_REG16_W(&(_MFCtrl1->CFG2[u8Eng]), (_HAL_REG16_R(&(_MFCtrl1->CFG2[u8Eng])) & ~u16CfgItem));
307 }
308 }
309
HAL_MMFI_Cfg2_Set(MS_U8 u8Eng,MS_U16 u16CfglItem)310 void HAL_MMFI_Cfg2_Set(MS_U8 u8Eng, MS_U16 u16CfglItem)
311 {
312 _HAL_REG16_W(&(_MFCtrl1->CFG2[u8Eng]), u16CfglItem);
313 }
314
HAL_MMFI_Cfg3_Enable(MS_U8 u8Eng,MS_U16 u16CfgItem,MS_BOOL benable)315 void HAL_MMFI_Cfg3_Enable(MS_U8 u8Eng, MS_U16 u16CfgItem, MS_BOOL benable)
316 {
317 if(benable)
318 {
319 _HAL_REG16_W(&(_MFCtrl1->CFG3[u8Eng]), (_HAL_REG16_R(&(_MFCtrl1->CFG3[u8Eng])) | u16CfgItem));
320 }
321 else
322 {
323 _HAL_REG16_W(&(_MFCtrl1->CFG3[u8Eng]), (_HAL_REG16_R(&(_MFCtrl1->CFG3[u8Eng])) & ~u16CfgItem));
324 }
325 }
326
HAL_MMFI_Cfg3_Set(MS_U8 u8Eng,MS_U16 u16CfglItem)327 void HAL_MMFI_Cfg3_Set(MS_U8 u8Eng, MS_U16 u16CfglItem)
328 {
329 _HAL_REG16_W(&(_MFCtrl1->CFG3[u8Eng]), u16CfglItem);
330 }
331
HAL_MMFI_Cfg3_Get(MS_U8 u8Eng)332 MS_U16 HAL_MMFI_Cfg3_Get(MS_U8 u8Eng)
333 {
334 return (_HAL_REG16_R(&(_MFCtrl1->CFG3[u8Eng])));
335 }
336
HAL_MMFI_Cfg2_Get(MS_U8 u8Eng)337 MS_U16 HAL_MMFI_Cfg2_Get(MS_U8 u8Eng)
338 {
339 return (_HAL_REG16_R(&(_MFCtrl1->CFG2[u8Eng])));
340 }
341
HAL_MMFI_Get_TsHeaderInfo(MS_U8 u8Eng,MS_U32 * pu32header)342 void HAL_MMFI_Get_TsHeaderInfo(MS_U8 u8Eng, MS_U32 *pu32header)
343 {
344 *pu32header = _HAL_REG32_R(&(_MFCtrl[u8Eng].TsHeader));
345 }
346
HAL_MMFI_Get_APid_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)347 void HAL_MMFI_Get_APid_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
348 {
349 MS_U16 u16temp;
350
351 u16temp = (MS_U16)_HAL_REG16_R(&(_MFCtrl[u8Eng].APid_Status));
352
353 *pu16pid = u16temp & MMFI_APID_MATCHED_MASK;
354 *pbchanged = (MS_BOOL)(u16temp & MMFI_APID_CHANGE);
355 }
356
HAL_MMFI_Get_APidB_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)357 void HAL_MMFI_Get_APidB_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
358 {
359 MS_U16 u16temp;
360
361 u16temp = _HAL_REG16_R(&(_MFCtrl[u8Eng].APidB_Status));
362
363 *pu16pid = u16temp & MMFI_APIDB_MATCHED_MASK;
364 *pbchanged = (MS_BOOL)(u16temp & MMFI_APIDB_CHANGE);
365 }
366
HAL_MMFI_Get_VPid_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)367 void HAL_MMFI_Get_VPid_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
368 {
369 MS_U16 u16temp;
370
371 u16temp = _HAL_REG16_R(&(_MFCtrl[u8Eng].VPID_Status));
372
373 *pu16pid = u16temp & MMFI_VPID_MATCHED_MASK;
374 *pbchanged = (MS_BOOL)(u16temp & MMFI_VPID_CHANGE);
375 }
376
HAL_MMFI_Get_VPid3D_Status(MS_U8 u8Eng,MS_U16 * pu16pid,MS_BOOL * pbchanged)377 void HAL_MMFI_Get_VPid3D_Status(MS_U8 u8Eng, MS_U16 *pu16pid, MS_BOOL *pbchanged)
378 {
379 MS_U16 u16temp;
380
381 u16temp = _HAL_REG16_R(&(_MFCtrl[u8Eng].VPID3D_Status));
382
383 *pu16pid = u16temp & MMFI_VPID3D_MATCHED_MASK;
384 *pbchanged = (MS_BOOL)(u16temp & MMFI_VPID3D_CHANGE);
385 }
386
HAL_MMFI_LPcr2_Set(MS_U8 u8Eng,MS_U32 u32lpcr2)387 void HAL_MMFI_LPcr2_Set(MS_U8 u8Eng, MS_U32 u32lpcr2)
388 {
389 HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_LPCR2_WLD, TRUE);
390 _HAL_REG32_W(&(_MFCtrl[u8Eng].LPcr2_Buf), u32lpcr2);
391 HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_LPCR2_WLD, FALSE);
392 }
393
HAL_MMFI_LPcr2_Get(MS_U8 u8Eng)394 MS_U32 HAL_MMFI_LPcr2_Get(MS_U8 u8Eng)
395 {
396 MS_U32 u32value;
397
398 HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_LPCR2_LD, TRUE);
399 u32value = _HAL_REG32_R(&(_MFCtrl[u8Eng].LPcr2_Buf));
400 HAL_MMFI_Cfg_Enable(u8Eng, MMFI_CFG_LPCR2_LD, FALSE);
401
402 return u32value;
403 }
404
HAL_MMFI_TimeStamp_Get(MS_U8 u8Eng)405 MS_U32 HAL_MMFI_TimeStamp_Get(MS_U8 u8Eng)
406 {
407 return _HAL_REG32_R(&(_MFCtrl[u8Eng].TimeStamp_FIn));
408 }
409
HAL_MMFI_PktChkSize_Set(MS_U8 u8Eng,MS_U16 u16size)410 void HAL_MMFI_PktChkSize_Set(MS_U8 u8Eng, MS_U16 u16size)
411 {
412 _HAL_REG16_W(&(_MFCtrl[u8Eng].PktChkSize), (_HAL_REG16_R(&(_MFCtrl[u8Eng].PktChkSize)) & ~MMFI_PKTCHK_SIZE_MASK) | u16size);
413 }
414
HAL_MMFI_MOBF_Set_FileinKey(MS_U8 u8Eng,MS_U16 u16KeyIndex)415 void HAL_MMFI_MOBF_Set_FileinKey(MS_U8 u8Eng, MS_U16 u16KeyIndex)
416 {
417 _HAL_REG16_W(&(_MFCtrl[u8Eng].MOBFKey), u16KeyIndex);
418 }
419
HAL_MMFI_MOBF_Enable(MS_U8 u8Eng,MS_BOOL bEnable)420 void HAL_MMFI_MOBF_Enable(MS_U8 u8Eng, MS_BOOL bEnable)
421 {
422 MS_U16 u16data = _HAL_REG16_R(&(_MFCtrl[u8Eng].FileIn_Ctrl)) & ~MMFI_FILEIN_CTRL_MOBF_EN;
423
424 if(bEnable)
425 {
426 u16data |= MMFI_FILEIN_CTRL_MOBF_EN;
427 }
428
429 _HAL_REG16_W(&(_MFCtrl[u8Eng].FileIn_Ctrl), u16data);
430 }
431
HAL_MMFI_AU_RemoveDupPkt(MS_U8 u8Eng,MS_BOOL bEnable)432 void HAL_MMFI_AU_RemoveDupPkt(MS_U8 u8Eng, MS_BOOL bEnable)
433 {
434 MS_U32 u32data = _HAL_REG32_R(&(_MFCtrl[u8Eng].Cfg)) & ~MMFI_CFG_DUP_PKT_SKIP;
435
436 if(bEnable)
437 u32data |= MMFI_CFG_DUP_PKT_SKIP;
438
439 _HAL_REG32_W(&(_MFCtrl[u8Eng].Cfg), u32data);
440 }
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
HAL_MMFI_HWInt_Enable(MS_BOOL benable,MS_U16 u16init)465 void HAL_MMFI_HWInt_Enable(MS_BOOL benable, MS_U16 u16init)
466 {
467 MS_U16 u16data = _HAL_REG16_R(&(_MFCtrl[0].HWInt)) & ~u16init;
468
469 if(benable)
470 {
471 _HAL_REG16_W(&(_MFCtrl[0].HWInt), (u16data | u16init));
472 }
473 else
474 {
475 _HAL_REG16_W(&(_MFCtrl[0].HWInt), u16data);
476 }
477 }
478
HAL_MMFI_HWInt_Clear(MS_U16 u16Int)479 void HAL_MMFI_HWInt_Clear(MS_U16 u16Int)
480 {
481 _HAL_REG16_W(&(_MFCtrl[0].HWInt), (_HAL_REG16_R(&(_MFCtrl[0].HWInt)) & ~u16Int));
482 }
483
HAL_MMFI_HWInt_Status(void)484 MS_U32 HAL_MMFI_HWInt_Status(void)
485 {
486 return (MS_U32)(_HAL_REG16_R(&(_MFCtrl[0].HWInt)) & MMFI_HWINT_STS_MASK);
487 }
488
HAL_MMFI_TimeStampClk_Set(MS_U8 u8Eng,MS_U32 u32ClkSrc)489 void HAL_MMFI_TimeStampClk_Set(MS_U8 u8Eng, MS_U32 u32ClkSrc)
490 {
491 MS_U16 u16Mask = (u8Eng)? MMFI_RST_LPCR_27M_EN_MMFI1 : MMFI_RST_LPCR_27M_EN_MMFI0;
492
493 if(u32ClkSrc == 0x0UL) // 90k
494 {
495 _HAL_REG16_W(&(_MFCtrl[0].SWRst), (_HAL_REG16_R(&(_MFCtrl[0].SWRst)) & ~u16Mask));
496 }
497 else // 27M
498 {
499 _HAL_REG16_W(&(_MFCtrl[0].SWRst), (_HAL_REG16_R(&(_MFCtrl[0].SWRst)) | u16Mask));
500 }
501 }
502
HAL_MMFI_RVU_Enable(MS_U8 u8Eng,MS_BOOL bEnable)503 MS_BOOL HAL_MMFI_RVU_Enable(MS_U8 u8Eng, MS_BOOL bEnable)
504 {
505 if(bEnable)
506 {
507 _HAL_REG16_W(&(_MFCtrl1->CFG3[u8Eng]), _HAL_REG16_R(&(_MFCtrl1->CFG2[u8Eng])) | MMFI_CFG3_RVU_EN);
508 }
509 else
510 {
511 _HAL_REG16_W(&(_MFCtrl1->CFG3[u8Eng]), _HAL_REG16_R(&(_MFCtrl1->CFG2[u8Eng])) & ~MMFI_CFG3_RVU_EN);
512 }
513
514 return TRUE;
515 }
516
HAL_MMFI_RVU_Timestamp_Enable(MS_U8 u8Eng,MS_BOOL bEnable)517 MS_BOOL HAL_MMFI_RVU_Timestamp_Enable(MS_U8 u8Eng, MS_BOOL bEnable)
518 {
519 if(bEnable)
520 {
521 _HAL_REG16_W(&(_MFCtrl1->CFG3[u8Eng]), _HAL_REG16_R(&(_MFCtrl1->CFG3[u8Eng])) | MMFI_CFG3_RVU_TIMESTAMP_EN);
522 }
523 else
524 {
525 _HAL_REG16_W(&(_MFCtrl1->CFG3[u8Eng]), _HAL_REG16_R(&(_MFCtrl1->CFG3[u8Eng])) & ~MMFI_CFG3_RVU_TIMESTAMP_EN);
526 }
527
528 return TRUE;
529 }
530
531 // Not implement
HAL_MMFI_SaveRegs(void)532 void HAL_MMFI_SaveRegs(void)
533 {
534
535 }
536
537 // Not implement
HAL_MMFI_RestoreRegs(void)538 void HAL_MMFI_RestoreRegs(void)
539 {
540
541 }