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) 2008-2009 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 /// @file drvmvd_cc.h
94 /// @brief Driver interface for accessing the MPEG Closed Caption decoder.
95 /// @author MStar Semiconductor Inc.
96 ///
97 ///- Providing MPEG Closed Caption decoder command functions for controlling firmware.
98 ///- MPEG Closed Caption decoder provides Digital 608 & 708 CC Data via accessing Ring Buffer
99 ///
100 ////////////////////////////////////////////////////////////////////////////////
101
102 //--------------------------------------------------------------------------------------------------
103 // Include Files
104 //--------------------------------------------------------------------------------------------------
105 // Common Definition
106 #ifdef REDLION_LINUX_KERNEL_ENVI
107 #include "drvMVD_Common.h"
108 #else
109 #include "MsCommon.h"
110 #endif
111 #include "drvMVD_EX.h"
112
113 // Internal Definition
114 #include "halMVD_EX.h"
115 #include "drvmvd_cc.h"
116 #include "mvd4_interface.h" //firmware header
117 #ifdef MSOS_TYPE_LINUX_KERNEL
118 #include <linux/string.h>
119 #else
120 #include <string.h>
121 #endif
122 #include "halCHIP.h"
123 #if (!defined(MSOS_TYPE_NUTTX) && !defined(MSOS_TYPE_OPTEE)) || defined(SUPPORT_X_MODEL_FEATURE)
124
125 //--------------------------------------------------------------------------------------------------
126 // Local Defines
127 //--------------------------------------------------------------------------------------------------
128 #define MVDCC_EXHANDLE(y) y
129
130 //----------------------------------------------------------------------------
131 /* MVD Command register - Command Definitions */
132 //----------------------------------------------------------------------------
133 #define CMD_SET_CCBUF_STARTHWADDR CMD_USER_BUF_START
134 #define CMD_SET_CCBUF_TOTALSIZE CMD_USER_BUF_SIZE
135 #define CMD_SET_CCTYPE_PARSING CMD_USER_BUF_SIZE
136 #define CMD_GET_CCBUF_HWADDR CMD_RD_USER_WP
137 #define CMD_GET_CCBUF_WRAPCOUNT CMD_RD_USER_WP
138
139 #define CMD_SET_CCBUF_SWADDR CMD_WD_USER_RP
140 #define CMD_GET_CCBUF_PACKETCOUNT CMD_RD_CC_PKTCNT
141 #define CMD_GET_OVERFLOW_STATUS CMD_RD_CC_OV
142
143 void MDrv_CC_CM_SetMVDRB_SWAddr(MS_U32 u32Id, MS_U32 u32ReadAddress, MS_U8 u8CC608);
144 MS_U32 MDrv_CC_CM_GetMVDRB_HWAddr(MS_U32 u32Id, MS_U8 u8CC608);
145 extern MS_U8 MVD_GetHalIdx(MS_U32 u32Id);
146
147 //******************************************************************************/
148 //* Local definition
149 //******************************************************************************/
150 #define MVD_READY_TEST_COUNT 10000
151 #define MVD_CCRB_PACKET_LENGTH 8
152
153 //******************************************************************************/
154 //* Declaring Variable
155 //******************************************************************************/
156 MS_U32 CCMVD_RINGBUFFER_START_ADR[2];
157 MS_U32 CCMVD_RINGBUFFER_LEN[2];
158
159 static MS_U32 volatile u32SW_Address[2], u32HW_Address[2];
160 static MS_U8 u8ParsingStatus = 0xff;
161
162 static MS_BOOL bCC708Enable; //fixme
163
164 // SH@20110111, Fixed the issues that move CC buffer from MIU0 to MIU1
165 // MIU1: buffer to MVD IP, don't need to add the MIU1's offset(512 Mb), but to CC flow's buffer, need to add up
166
167 #if defined(CHIP_MONACO)
168 static MS_U8 u8BufSelMiu = 0xff;
169 #define MVD_ON_MIU HAL_MVD_GetFWSelMiu()
170 #else
171 static MS_BOOL bBufMiu0 = 0xff;
172 #define MIU1_BASEADDR HAL_MVD_GetMiu1BaseAdd()
173 #define MVD_ON_MIU1 HAL_MVD_GetFWSelMiu1()
174 #endif
175
176 #define _IS_MSTAR_CC(x) ((0==(x)) || (1==(x)))
177 ///////////////////////////////////////////////////////////////////////////////
178 /// Closed Caption Driver Initialization
179 ///////////////////////////////////////////////////////////////////////////////
MDrv_CC_Init(MS_U32 u32Id)180 void MDrv_CC_Init(MS_U32 u32Id)
181 {
182 if (u8ParsingStatus == 0xff)
183 u8ParsingStatus = 0x00;
184 }
185
186 ///////////////////////////////////////////////////////////////////////////////
187 /// Set MVD Ring Buffer's Address
188 /// @param u32StartAddress \b IN Ring Buffer's Address
189 /// @param u8CC608 \b IN
190 /// - # TRUE for CC608 parser
191 /// - # FALSE for CC708 parser
192 ///////////////////////////////////////////////////////////////////////////////
193 #if defined(CHIP_MONACO)
MDrv_CC_CM_SetMVDRB_HWAddr(MS_U32 u32Id,MS_U32 u32StartAddress,MS_U8 u8CC608)194 void MDrv_CC_CM_SetMVDRB_HWAddr(MS_U32 u32Id, MS_U32 u32StartAddress, MS_U8 u8CC608)
195 {
196 MS_U8 u8HalIdx = MVD_GetHalIdx(u32Id);
197 MS_U32 u32MVDCC_Temp1 = 0;
198 MVD_CmdArg mvdcmd;
199 MS_U32 u32StartOffset;
200 MS_U8 u8MiuSel;
201
202 MS_U32 u32Miu1_base = 0;
203 MS_U32 u32Miu2_base = 0;
204 MS_U32 u32Miu3_base = 0;
205
206 _miu_offset_to_phy(E_CHIP_MIU_1,0,u32Miu1_base);
207 _miu_offset_to_phy(E_CHIP_MIU_2,0,u32Miu2_base);
208 _miu_offset_to_phy(E_CHIP_MIU_3,0,u32Miu3_base);
209
210 memset((void *)&mvdcmd, 0, sizeof(MVD_CmdArg));
211
212 // SH@20110111, get the first HW buffer to determine the MIU0 or MIU1 for CC buffer. Only once
213 if(u8BufSelMiu == 0xff)
214 {
215 _phy_to_miu_offset(u8MiuSel, u32StartOffset, u32StartAddress);
216
217 u8BufSelMiu = u8MiuSel;
218 }
219
220 if(MVD_ON_MIU == E_CHIP_MIU_0)
221 {
222 if(u8BufSelMiu == E_CHIP_MIU_0)
223 {
224 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress;
225 }
226 else if(u8BufSelMiu == E_CHIP_MIU_1)
227 {
228 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress;
229 }
230 else if(u8BufSelMiu == E_CHIP_MIU_2)
231 {
232 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress;
233 }
234 else if(u8BufSelMiu == E_CHIP_MIU_3)
235 {
236 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress;
237 }
238 }
239 else if(MVD_ON_MIU == E_CHIP_MIU_1) // SH@20110111, mvd code binary in MIU1
240 {
241 if(u8BufSelMiu == E_CHIP_MIU_0)
242 {
243 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress | u32Miu1_base;
244 }
245 else if(u8BufSelMiu == E_CHIP_MIU_1)
246 {
247 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress;
248 }
249 else if(u8BufSelMiu == E_CHIP_MIU_2)
250 {
251 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress | u32Miu1_base;
252 }
253 else if(u8BufSelMiu == E_CHIP_MIU_3)
254 {
255 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress | u32Miu1_base;
256 }
257 }
258 else if(MVD_ON_MIU == E_CHIP_MIU_2) // SH@20110111, mvd code binary in MIU1
259 {
260 if(u8BufSelMiu == E_CHIP_MIU_0)
261 {
262 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress | u32Miu2_base;
263 }
264 else if(u8BufSelMiu == E_CHIP_MIU_1)
265 {
266 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress | u32Miu2_base;
267 }
268 else if(u8BufSelMiu == E_CHIP_MIU_2)
269 {
270 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress ;
271 }
272 else if(u8BufSelMiu == E_CHIP_MIU_3)
273 {
274 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress | u32Miu2_base;
275 }
276 }
277 else if(MVD_ON_MIU == E_CHIP_MIU_3) // SH@20110111, mvd code binary in MIU1
278 {
279 if(u8BufSelMiu == E_CHIP_MIU_0)
280 {
281 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress | u32Miu3_base;
282 }
283 else if(u8BufSelMiu == E_CHIP_MIU_1)
284 {
285 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress | u32Miu3_base;
286 }
287 else if(u8BufSelMiu == E_CHIP_MIU_2)
288 {
289 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress | u32Miu3_base;
290 }
291 else if(u8BufSelMiu == E_CHIP_MIU_3)
292 {
293 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress ;
294 }
295 }
296
297 if(u8BufSelMiu == E_CHIP_MIU_0)
298 {
299 u32MVDCC_Temp1 = (u32StartAddress >> 3);
300 }
301 else if(u8BufSelMiu == E_CHIP_MIU_1)
302 {
303 u32MVDCC_Temp1 = u32StartAddress - u32Miu1_base ;
304 u32MVDCC_Temp1 = (u32MVDCC_Temp1 >> 3);
305 }
306 else if(u8BufSelMiu == E_CHIP_MIU_2)
307 {
308 u32MVDCC_Temp1 = u32StartAddress - u32Miu2_base ;
309 u32MVDCC_Temp1 = (u32MVDCC_Temp1 >> 3);
310 }
311 else if(u8BufSelMiu == E_CHIP_MIU_3)
312 {
313 u32MVDCC_Temp1 = u32StartAddress - u32Miu3_base ;
314 u32MVDCC_Temp1 = (u32MVDCC_Temp1 >> 3);
315 }
316
317
318 mvdcmd.Arg4 = H_DWORD(u32MVDCC_Temp1);
319 mvdcmd.Arg3 = (MS_U8)u8CC608;
320 mvdcmd.Arg2 = L_DWORD(u32MVDCC_Temp1);
321 mvdcmd.Arg1 = H_WORD(u32MVDCC_Temp1);
322 mvdcmd.Arg0 = L_WORD(u32MVDCC_Temp1);
323 SET_DECNUM(mvdcmd, u8HalIdx);
324 if (HAL_MVD_MVDCommand(CMD_SET_CCBUF_STARTHWADDR, &mvdcmd)== TRUE)
325 {
326 u32SW_Address[u8CC608] = u32StartAddress;
327 u32HW_Address[u8CC608] = u32StartAddress;
328 MDrv_CC_CM_SetMVDRB_SWAddr(u32Id, u32StartAddress, u8CC608);
329 }
330 else
331 {
332 MVDCC_EXHANDLE(MVD_PRINT("%s: cmd 0x%x fail!!\n", __FUNCTION__, CMD_SET_CCBUF_STARTHWADDR));
333 MVDCC_EXHANDLE(MVD_PRINT("\nF:S-HA"));
334 }
335 }
336 #else
MDrv_CC_CM_SetMVDRB_HWAddr(MS_U32 u32Id,MS_U32 u32StartAddress,MS_U8 u8CC608)337 void MDrv_CC_CM_SetMVDRB_HWAddr(MS_U32 u32Id, MS_U32 u32StartAddress, MS_U8 u8CC608)
338 {
339 MS_U8 u8HalIdx = MVD_GetHalIdx(u32Id);
340 MS_U32 u32MVDCC_Temp1 = 0;
341 MVD_CmdArg mvdcmd;
342 memset((void *)&mvdcmd, 0, sizeof(MVD_CmdArg));
343
344 // SH@20110111, get the first HW buffer to determine the MIU0 or MIU1 for CC buffer. Only once
345 if(bBufMiu0 == 0xff)
346 {
347 if((u32StartAddress&MIU1_BASEADDR) == MIU1_BASEADDR)
348 {
349 bBufMiu0 = false;
350 }
351 else
352 {
353 bBufMiu0 = true;
354 }
355 }
356
357 if(MVD_ON_MIU1) // SH@20110111, mvd code binary in MIU1
358 {
359 if(bBufMiu0) // SH@20110111, if CC buffer in MIU0, enable here
360 {
361 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress | MIU1_BASEADDR;
362 }
363 else // CC buffer in MIU1
364 {
365 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress;
366 }
367 }
368 else
369 {
370 CCMVD_RINGBUFFER_START_ADR[u8CC608] = u32StartAddress;
371 }
372
373 if(bBufMiu0)
374 {
375 u32MVDCC_Temp1 = (u32StartAddress >> 3);
376 }
377 else // CC buffer in MIU1
378 {
379 u32MVDCC_Temp1 = u32StartAddress - MIU1_BASEADDR ;
380 u32MVDCC_Temp1 = (u32MVDCC_Temp1 >> 3);
381 }
382
383 mvdcmd.Arg4 = H_DWORD(u32MVDCC_Temp1);
384 mvdcmd.Arg3 = (MS_U8)u8CC608;
385 mvdcmd.Arg2 = L_DWORD(u32MVDCC_Temp1);
386 mvdcmd.Arg1 = H_WORD(u32MVDCC_Temp1);
387 mvdcmd.Arg0 = L_WORD(u32MVDCC_Temp1);
388 SET_DECNUM(mvdcmd, u8HalIdx);
389 if (HAL_MVD_MVDCommand(CMD_SET_CCBUF_STARTHWADDR, &mvdcmd)== TRUE)
390 {
391 u32SW_Address[u8CC608] = u32StartAddress;
392 u32HW_Address[u8CC608] = u32StartAddress;
393 MDrv_CC_CM_SetMVDRB_SWAddr(u32Id, u32StartAddress, u8CC608);
394 }
395 else
396 {
397 MVDCC_EXHANDLE(MVD_PRINT("%s: cmd 0x%x fail!!\n", __FUNCTION__, CMD_SET_CCBUF_STARTHWADDR));
398 MVDCC_EXHANDLE(MVD_PRINT("\nF:S-HA"));
399 }
400 }
401 #endif
402 ///////////////////////////////////////////////////////////////////////////////
403 /// Set MVD Ring Buffer's SW Address as HW Address
404 /// @param u8CC608 \b IN
405 /// - # TRUE for CC608 parser
406 /// - # FALSE for CC708 parser
407 ///////////////////////////////////////////////////////////////////////////////
MDrv_CC_CM_SyncMVDRB_SWAddr2HWAddr(MS_U32 u32Id,MS_U8 u8CC608)408 void MDrv_CC_CM_SyncMVDRB_SWAddr2HWAddr(MS_U32 u32Id, MS_U8 u8CC608)
409 {
410 MDrv_CC_CM_SetMVDRB_SWAddr(u32Id, u32HW_Address[u8CC608], u8CC608);
411 }
412
413 ///////////////////////////////////////////////////////////////////////////////
414 /// Set CC Type to MVD CC FW Driver
415 /// @param u8Operation \b IN Digital Closed Caption Type
416 /// @param u16BufferSize \b IN buffer size of the given hardware parser
417 /// @param u8CC608 \b IN
418 /// - # TRUE for CC608 parser
419 /// - # FALSE for CC708 parser
420 ///////////////////////////////////////////////////////////////////////////////
MDrv_CC_CM_SetParsingType(MS_U32 u32Id,MS_U8 u8Operation,MS_U16 u16BufferSize,MS_U8 u8CC608)421 void MDrv_CC_CM_SetParsingType(MS_U32 u32Id, MS_U8 u8Operation, MS_U16 u16BufferSize, MS_U8 u8CC608)
422 {
423 MS_U8 u8HalIdx = MVD_GetHalIdx(u32Id);
424 MS_U16 u16MVDCC_Temp1 = 0;
425 MVD_CmdArg mvdcmd;
426 memset((void *)&mvdcmd, 0, sizeof(MVD_CmdArg));
427 CCMVD_RINGBUFFER_LEN[u8CC608] = u16BufferSize;
428 u16MVDCC_Temp1 = (u16BufferSize >> 3);
429
430 u8ParsingStatus |= u8Operation;
431 u8ParsingStatus &= 0x07;
432 mvdcmd.Arg1 = H_WORD(u16MVDCC_Temp1);
433 mvdcmd.Arg0 = L_WORD(u16MVDCC_Temp1);
434 mvdcmd.Arg2 = (MS_U8)(u8ParsingStatus);
435 mvdcmd.Arg3 = (MS_U8)u8CC608;
436 SET_DECNUM(mvdcmd, u8HalIdx);
437 if (HAL_MVD_MVDCommand(CMD_SET_CCTYPE_PARSING, &mvdcmd) != TRUE)
438 {
439 MVDCC_EXHANDLE(MVD_PRINT("%s: cmd 0x%x fail!!\n", __FUNCTION__, CMD_SET_CCTYPE_PARSING));
440 MVDCC_EXHANDLE(MVD_PRINT("\nF:SPT"));
441 }
442 else
443 {
444 if (u8CC608==0x00)
445 {
446 bCC708Enable = TRUE;
447 }
448 }
449 }
450
451 ///////////////////////////////////////////////////////////////////////////////
452 /// Stop MVD CC FW Driver
453 /// @param u8CC608 \b IN
454 /// - # TRUE for CC608 parser
455 /// - # FALSE for CC708 parser
456 ///////////////////////////////////////////////////////////////////////////////
MDrv_CC_CM_DisableParsing(MS_U32 u32Id,MS_U8 u8CC608)457 void MDrv_CC_CM_DisableParsing(MS_U32 u32Id, MS_U8 u8CC608)
458 {
459 MS_U8 u8HalIdx = MVD_GetHalIdx(u32Id);
460 MS_U16 u16MVDCC_Temp1 = 0;
461 MVD_CmdArg mvdcmd;
462 memset((void *)&mvdcmd, 0, sizeof(MVD_CmdArg));
463 u16MVDCC_Temp1 = CCMVD_RINGBUFFER_LEN[u8CC608];
464 u16MVDCC_Temp1 = (u16MVDCC_Temp1 >> 3);
465
466 mvdcmd.Arg1 = H_WORD(u16MVDCC_Temp1);
467 mvdcmd.Arg0 = L_WORD(u16MVDCC_Temp1);
468
469 if (u8CC608==0)
470 {
471 u8ParsingStatus &= ~0x04;
472 bCC708Enable = FALSE;
473 }
474 else
475 u8ParsingStatus &= ~0x03;
476
477 u8ParsingStatus &= 0x07;
478 mvdcmd.Arg3 = (MS_U8)u8CC608;
479 mvdcmd.Arg2 = (MS_U8)(u8ParsingStatus);
480 SET_DECNUM(mvdcmd, u8HalIdx);
481 if (HAL_MVD_MVDCommand(CMD_SET_CCTYPE_PARSING, &mvdcmd) != TRUE)
482 {
483 MVDCC_EXHANDLE(MVD_PRINT("%s: cmd 0x%x fail!!\n", __FUNCTION__, CMD_SET_CCTYPE_PARSING));
484 MVDCC_EXHANDLE(MVD_PRINT("\nF:DisP"));
485 }
486 }
487
488 ///////////////////////////////////////////////////////////////////////////////
489 /// Get Hardware Pointer of MVD CC Ring Buffer
490 /// Return value:: The HW Pointer Address of MVD CC Ring Buffer
491 /// @param u8CC608 \b IN
492 /// - # TRUE for CC608 parser
493 /// - # FALSE for CC708 parser
494 ///////////////////////////////////////////////////////////////////////////////
495 #if defined(CHIP_MONACO)
MDrv_CC_CM_GetMVDRB_HWAddr(MS_U32 u32Id,MS_U8 u8CC608)496 MS_U32 MDrv_CC_CM_GetMVDRB_HWAddr(MS_U32 u32Id, MS_U8 u8CC608)
497 {
498 MS_U32 u32MVDCC_Temp1 = 0;
499 MS_U8 u8HalIdx = MVD_GetHalIdx(u32Id);
500 MVD_CmdArg mvdcmd;
501 MS_U32 u32Miu1_base = 0;
502 MS_U32 u32Miu2_base = 0;
503 MS_U32 u32Miu3_base = 0;
504
505 _miu_offset_to_phy(E_CHIP_MIU_1,0,u32Miu1_base);
506 _miu_offset_to_phy(E_CHIP_MIU_2,0,u32Miu2_base);
507 _miu_offset_to_phy(E_CHIP_MIU_3,0,u32Miu3_base);
508
509 memset((void *)&mvdcmd, 0, sizeof(MVD_CmdArg));
510 mvdcmd.Arg3 = (MS_U8)u8CC608;
511 SET_DECNUM(mvdcmd, u8HalIdx);
512 if (HAL_MVD_MVDCommand(CMD_GET_CCBUF_HWADDR, &mvdcmd)== TRUE)
513 {
514 if (_IS_MSTAR_CC(u8CC608))
515 {
516 u32MVDCC_Temp1 = COMBU32(mvdcmd.Arg4, mvdcmd.Arg2, mvdcmd.Arg1, mvdcmd.Arg0);
517 }
518 else //u8CC608 is 2 or 3
519 {
520 u32MVDCC_Temp1 = COMBU32(mvdcmd.Arg3, mvdcmd.Arg2, mvdcmd.Arg1, mvdcmd.Arg0);
521 }
522 u32MVDCC_Temp1 = (u32MVDCC_Temp1 << 3);
523
524 if(u8BufSelMiu == E_CHIP_MIU_0) // SH@20110111, if CC buffer in MIU0, enable here
525 {
526 return (u32MVDCC_Temp1);
527 }
528 else if(u8BufSelMiu == E_CHIP_MIU_1) // SH@20110111, if CC buffer in MIU0, enable here
529 {
530 return (u32MVDCC_Temp1|u32Miu1_base);
531 }
532 else if(u8BufSelMiu == E_CHIP_MIU_2) // SH@20110111, if CC buffer in MIU0, enable here
533 {
534 return (u32MVDCC_Temp1|u32Miu2_base);
535 }
536 else if(u8BufSelMiu == E_CHIP_MIU_3) // SH@20110111, if CC buffer in MIU0, enable here
537 {
538 return (u32MVDCC_Temp1|u32Miu3_base);
539 }
540 }
541 else
542 {
543 MVDCC_EXHANDLE(MVD_PRINT("%s: cmd 0x%x fail!!\n", __FUNCTION__, CMD_GET_CCBUF_HWADDR));
544 MVDCC_EXHANDLE(MVD_PRINT("\nF:GHAV"));
545 }
546
547 return 0xffffffff;
548 }
549 #else
MDrv_CC_CM_GetMVDRB_HWAddr(MS_U32 u32Id,MS_U8 u8CC608)550 MS_U32 MDrv_CC_CM_GetMVDRB_HWAddr(MS_U32 u32Id, MS_U8 u8CC608)
551 {
552 MS_U32 u32MVDCC_Temp1 = 0;
553 MS_U8 u8HalIdx = MVD_GetHalIdx(u32Id);
554 MVD_CmdArg mvdcmd;
555 memset((void *)&mvdcmd, 0, sizeof(MVD_CmdArg));
556 mvdcmd.Arg3 = (MS_U8)u8CC608;
557 SET_DECNUM(mvdcmd, u8HalIdx);
558 if (HAL_MVD_MVDCommand(CMD_GET_CCBUF_HWADDR, &mvdcmd)== TRUE)
559 {
560 if (_IS_MSTAR_CC(u8CC608))
561 {
562 u32MVDCC_Temp1 = COMBU32(mvdcmd.Arg4, mvdcmd.Arg2, mvdcmd.Arg1, mvdcmd.Arg0);
563 }
564 else //u8CC608 is 2 or 3
565 {
566 u32MVDCC_Temp1 = COMBU32(mvdcmd.Arg3, mvdcmd.Arg2, mvdcmd.Arg1, mvdcmd.Arg0);
567 }
568 u32MVDCC_Temp1 = (u32MVDCC_Temp1 << 3);
569 if(bBufMiu0) // SH@20110111, if CC buffer in MIU0, enable here
570 {
571 return (u32MVDCC_Temp1);
572 }
573 else // CC buffer in MIU1
574 {
575 return (u32MVDCC_Temp1|MIU1_BASEADDR);
576 }
577 }
578 else
579 {
580 MVDCC_EXHANDLE(MVD_PRINT("%s: cmd 0x%x fail!!\n", __FUNCTION__, CMD_GET_CCBUF_HWADDR));
581 MVDCC_EXHANDLE(MVD_PRINT("\nF:GHAV"));
582 }
583
584 return 0xffffffff;
585 }
586 #endif
587 ///////////////////////////////////////////////////////////////////////////////
588 /// Get Overflow Status of MVD CC FW Driver
589 /// @param u8CC608 \b IN
590 /// - # TRUE for CC608 parser
591 /// - # FALSE for CC708 parser
592 /// Return value:: Overflow Status Flag
593 ////////////////////////////////////////////////////////////////////////////////
MDrv_CC_CM_GetOverflowStatus(MS_U32 u32Id,MS_U8 u8CC608)594 MS_U8 MDrv_CC_CM_GetOverflowStatus(MS_U32 u32Id, MS_U8 u8CC608)
595 {
596 MS_U8 u8HalIdx = MVD_GetHalIdx(u32Id);
597 MVD_CmdArg mvdcmd;
598 memset((void *)&mvdcmd, 0, sizeof(MVD_CmdArg));
599 mvdcmd.Arg3 = (MS_U8)u8CC608;
600 SET_DECNUM(mvdcmd, u8HalIdx);
601 if (HAL_MVD_MVDCommand(CMD_GET_OVERFLOW_STATUS, &mvdcmd) == TRUE)
602 {
603 if ((mvdcmd.Arg0& 0x01) == 0)
604 return (FALSE);
605 else
606 return (TRUE);
607 }
608 else
609 {
610 MVDCC_EXHANDLE(MVD_PRINT("%s: cmd 0x%x fail!!\n", __FUNCTION__, CMD_GET_OVERFLOW_STATUS));
611 MVDCC_EXHANDLE(MVD_PRINT("\nF:GOV"));
612 }
613 return (FALSE);
614 }
615
616 ///////////////////////////////////////////////////////////////////////////////
617 /// Set Software Pointer of MVD CC Ring Buffer
618 /// @param u32ReadAddress \b IN SW Pointer Address
619 /// @param u8CC608 \b IN
620 /// - # TRUE for CC608 parser
621 /// - # FALSE for CC708 parser
622 ///////////////////////////////////////////////////////////////////////////////
623 #if defined(CHIP_MONACO)
MDrv_CC_CM_SetMVDRB_SWAddr(MS_U32 u32Id,MS_U32 u32ReadAddress,MS_U8 u8CC608)624 void MDrv_CC_CM_SetMVDRB_SWAddr(MS_U32 u32Id, MS_U32 u32ReadAddress, MS_U8 u8CC608)
625 {
626 MS_U8 u8HalIdx = MVD_GetHalIdx(u32Id);
627 MS_U32 u32MVDCC_Temp1 = 0;
628 MVD_CmdArg mvdcmd;
629 MS_U32 u32Miu1_base = 0;
630 MS_U32 u32Miu2_base = 0;
631 MS_U32 u32Miu3_base = 0;
632
633 _miu_offset_to_phy(E_CHIP_MIU_1,0,u32Miu1_base);
634 _miu_offset_to_phy(E_CHIP_MIU_2,0,u32Miu2_base);
635 _miu_offset_to_phy(E_CHIP_MIU_3,0,u32Miu3_base);
636
637 memset((void *)&mvdcmd, 0, sizeof(MVD_CmdArg));
638
639 u32SW_Address[u8CC608] = u32ReadAddress;
640
641 if(u8BufSelMiu == E_CHIP_MIU_0) // SH@20110111, if CC buffer in MIU0, enable here
642 {
643 u32MVDCC_Temp1 = (u32ReadAddress >> 3);
644 }
645 else if(u8BufSelMiu == E_CHIP_MIU_1) // SH@20110111, if CC buffer in MIU0, enable here
646 {
647 u32MVDCC_Temp1 = u32ReadAddress - u32Miu1_base;
648 u32MVDCC_Temp1 = (u32MVDCC_Temp1 >> 3);
649 }
650 else if(u8BufSelMiu == E_CHIP_MIU_2) // SH@20110111, if CC buffer in MIU0, enable here
651 {
652 u32MVDCC_Temp1 = u32ReadAddress - u32Miu2_base;
653 u32MVDCC_Temp1 = (u32MVDCC_Temp1 >> 3);
654 }
655 else if(u8BufSelMiu == E_CHIP_MIU_3) // SH@20110111, if CC buffer in MIU0, enable here
656 {
657 u32MVDCC_Temp1 = u32ReadAddress - u32Miu3_base;
658 u32MVDCC_Temp1 = (u32MVDCC_Temp1 >> 3);
659 }
660
661 mvdcmd.Arg3 = (MS_U8)u8CC608;
662 mvdcmd.Arg2 = L_DWORD(u32MVDCC_Temp1);
663 mvdcmd.Arg1 = H_WORD(u32MVDCC_Temp1);
664 mvdcmd.Arg0 = L_WORD(u32MVDCC_Temp1);
665 SET_DECNUM(mvdcmd, u8HalIdx);
666 if (HAL_MVD_MVDCommand(CMD_SET_CCBUF_SWADDR, &mvdcmd) != TRUE)
667 {
668 MVDCC_EXHANDLE(MVD_PRINT("%s: cmd 0x%x fail!!\n", __FUNCTION__, CMD_SET_CCBUF_SWADDR));
669 MVDCC_EXHANDLE(MVD_PRINT("\nF:SSA"));
670 }
671 }
672 #else
MDrv_CC_CM_SetMVDRB_SWAddr(MS_U32 u32Id,MS_U32 u32ReadAddress,MS_U8 u8CC608)673 void MDrv_CC_CM_SetMVDRB_SWAddr(MS_U32 u32Id, MS_U32 u32ReadAddress, MS_U8 u8CC608)
674 {
675 MS_U8 u8HalIdx = MVD_GetHalIdx(u32Id);
676 MS_U32 u32MVDCC_Temp1 = 0;
677 MVD_CmdArg mvdcmd;
678 memset((void *)&mvdcmd, 0, sizeof(MVD_CmdArg));
679
680 u32SW_Address[u8CC608] = u32ReadAddress;
681
682 if(bBufMiu0) // SH@20110111, if CC buffer in MIU0, enable here
683 {
684 u32MVDCC_Temp1 = (u32ReadAddress >> 3);
685 }
686 else // CC buffer in MIU1
687 {
688 u32MVDCC_Temp1 = u32ReadAddress - MIU1_BASEADDR;
689 u32MVDCC_Temp1 = (u32MVDCC_Temp1 >> 3);
690 }
691
692 mvdcmd.Arg3 = (MS_U8)u8CC608;
693 mvdcmd.Arg2 = L_DWORD(u32MVDCC_Temp1);
694 mvdcmd.Arg1 = H_WORD(u32MVDCC_Temp1);
695 mvdcmd.Arg0 = L_WORD(u32MVDCC_Temp1);
696 SET_DECNUM(mvdcmd, u8HalIdx);
697 if (HAL_MVD_MVDCommand(CMD_SET_CCBUF_SWADDR, &mvdcmd) != TRUE)
698 {
699 MVDCC_EXHANDLE(MVD_PRINT("%s: cmd 0x%x fail!!\n", __FUNCTION__, CMD_SET_CCBUF_SWADDR));
700 MVDCC_EXHANDLE(MVD_PRINT("\nF:SSA"));
701 }
702 }
703 #endif
704
705 #if defined(CHIP_MONACO)
706 #else
707 #define __Offset2PA(x) ((MVD_ON_MIU1)?((x)|MIU1_BASEADDR):(x))
708 #endif
709 ///////////////////////////////////////////////////////////////////////////////
710 /// Get HW Pointer Address of MVD CC FW Driver
711 /// @param u8CC608 \b IN
712 /// - # TRUE for CC608 parser
713 /// - # FALSE for CC708 parser
714 /// Return value:: HW Pointer Address
715 ///////////////////////////////////////////////////////////////////////////////
716
717 #if defined(CHIP_MONACO)
MDrv_CC_PM_GetMVDRB_WriteAddr(MS_U32 u32Id,MS_U8 u8CC608)718 MS_U32 MDrv_CC_PM_GetMVDRB_WriteAddr(MS_U32 u32Id, MS_U8 u8CC608)
719 {
720 MS_U32 u32Miu1_base = 0;
721 MS_U32 u32Miu2_base = 0;
722 MS_U32 u32Miu3_base = 0;
723
724 _miu_offset_to_phy(E_CHIP_MIU_1,0,u32Miu1_base);
725 _miu_offset_to_phy(E_CHIP_MIU_2,0,u32Miu2_base);
726 _miu_offset_to_phy(E_CHIP_MIU_3,0,u32Miu3_base);
727
728 u32HW_Address[u8CC608] = MDrv_CC_CM_GetMVDRB_HWAddr(u32Id, u8CC608);
729
730 if(u8BufSelMiu == E_CHIP_MIU_0) // SH@20110111, if CC buffer in MIU0, enable here
731 {
732 if(MVD_ON_MIU == E_CHIP_MIU_0)
733 {
734 return (MS_U32)(u32HW_Address[u8CC608]);
735 }
736 else if(MVD_ON_MIU == E_CHIP_MIU_1)
737 {
738 return (MS_U32)(u32HW_Address[u8CC608]|u32Miu1_base);
739 }
740 else if(MVD_ON_MIU == E_CHIP_MIU_2)
741 {
742 return (MS_U32)(u32HW_Address[u8CC608]|u32Miu2_base);
743 }
744 else if(MVD_ON_MIU == E_CHIP_MIU_3)
745 {
746 return (MS_U32)(u32HW_Address[u8CC608]|u32Miu3_base);
747 }
748 else
749 {
750 return 0;
751 }
752 }
753 else if(u8BufSelMiu == E_CHIP_MIU_1) // SH@20110111, if CC buffer in MIU0, enable here
754 {
755 if(MVD_ON_MIU == E_CHIP_MIU_0)
756 {
757 return (MS_U32)(u32HW_Address[u8CC608]);
758 }
759 else if(MVD_ON_MIU == E_CHIP_MIU_1)
760 {
761 return (MS_U32)(u32HW_Address[u8CC608]);
762 }
763 else if(MVD_ON_MIU == E_CHIP_MIU_2)
764 {
765 return (MS_U32)(u32HW_Address[u8CC608]|u32Miu2_base);
766 }
767 else if(MVD_ON_MIU == E_CHIP_MIU_3)
768 {
769 return (MS_U32)(u32HW_Address[u8CC608]|u32Miu3_base);
770 }
771 else
772 {
773 return 0;
774 }
775 }
776 else if(u8BufSelMiu == E_CHIP_MIU_2) // SH@20110111, if CC buffer in MIU0, enable here
777 {
778 if(MVD_ON_MIU == E_CHIP_MIU_0)
779 {
780 return (MS_U32)(u32HW_Address[u8CC608]);
781 }
782 else if(MVD_ON_MIU == E_CHIP_MIU_1)
783 {
784 return (MS_U32)(u32HW_Address[u8CC608]|u32Miu1_base);
785 }
786 else if(MVD_ON_MIU == E_CHIP_MIU_2)
787 {
788 return (MS_U32)(u32HW_Address[u8CC608]);
789 }
790 else if(MVD_ON_MIU == E_CHIP_MIU_3)
791 {
792 return (MS_U32)(u32HW_Address[u8CC608]|u32Miu3_base);
793 }
794 else
795 {
796 return 0;
797 }
798 }
799 else if(u8BufSelMiu == E_CHIP_MIU_3) // SH@20110111, if CC buffer in MIU0, enable here
800 {
801 if(MVD_ON_MIU == E_CHIP_MIU_0)
802 {
803 return (MS_U32)(u32HW_Address[u8CC608]);
804 }
805 else if(MVD_ON_MIU == E_CHIP_MIU_1)
806 {
807 return (MS_U32)(u32HW_Address[u8CC608]|u32Miu1_base);
808 }
809 else if(MVD_ON_MIU == E_CHIP_MIU_2)
810 {
811 return (MS_U32)(u32HW_Address[u8CC608]|u32Miu2_base);
812 }
813 else if(MVD_ON_MIU == E_CHIP_MIU_3)
814 {
815 return (MS_U32)(u32HW_Address[u8CC608]);
816 }
817 else
818 {
819 return 0;
820 }
821 }
822 else
823 {
824 return 0;
825 }
826 }
827 #else
MDrv_CC_PM_GetMVDRB_WriteAddr(MS_U32 u32Id,MS_U8 u8CC608)828 MS_U32 MDrv_CC_PM_GetMVDRB_WriteAddr(MS_U32 u32Id, MS_U8 u8CC608)
829 {
830 u32HW_Address[u8CC608] = MDrv_CC_CM_GetMVDRB_HWAddr(u32Id, u8CC608);
831
832 if(bBufMiu0)
833 {
834 return (MS_U32)__Offset2PA(u32HW_Address[u8CC608]);
835 }
836 else
837 {
838 return (MS_U32)(u32HW_Address[u8CC608]);
839 }
840 }
841 #endif
842 ///////////////////////////////////////////////////////////////////////////////
843 /// Get SW Pointer Address of MVD CC FW Driver
844 /// @param u8CC608 \b IN
845 /// - # TRUE for CC608 parser
846 /// - # FALSE for CC708 parser
847 /// Return value:: SW Pointer Address
848 ///////////////////////////////////////////////////////////////////////////////
849
850 #if defined(CHIP_MONACO)
MDrv_CC_PM_GetMVDRB_ReadAddr(MS_U32 u32Id,MS_U8 u8CC608)851 MS_U32 MDrv_CC_PM_GetMVDRB_ReadAddr(MS_U32 u32Id, MS_U8 u8CC608)
852 {
853 MS_U32 u32Miu1_base = 0;
854 MS_U32 u32Miu2_base = 0;
855 MS_U32 u32Miu3_base = 0;
856
857 _miu_offset_to_phy(E_CHIP_MIU_1,0,u32Miu1_base);
858 _miu_offset_to_phy(E_CHIP_MIU_2,0,u32Miu2_base);
859 _miu_offset_to_phy(E_CHIP_MIU_3,0,u32Miu3_base);
860
861 if(u8BufSelMiu == E_CHIP_MIU_0) // SH@20110111, if CC buffer in MIU0, enable here
862 {
863 if(MVD_ON_MIU == E_CHIP_MIU_0)
864 {
865 return (MS_U32)(u32SW_Address[u8CC608]);
866 }
867 else if(MVD_ON_MIU == E_CHIP_MIU_1)
868 {
869 return (MS_U32)(u32SW_Address[u8CC608]|u32Miu1_base);
870 }
871 else if(MVD_ON_MIU == E_CHIP_MIU_2)
872 {
873 return (MS_U32)(u32SW_Address[u8CC608]|u32Miu2_base);
874 }
875 else if(MVD_ON_MIU == E_CHIP_MIU_3)
876 {
877 return (MS_U32)(u32SW_Address[u8CC608]|u32Miu3_base);
878 }
879 else
880 {
881 return 0;
882 }
883 }
884 else if(u8BufSelMiu == E_CHIP_MIU_1) // SH@20110111, if CC buffer in MIU0, enable here
885 {
886 if(MVD_ON_MIU == E_CHIP_MIU_0)
887 {
888 return (MS_U32)(u32SW_Address[u8CC608]);
889 }
890 else if(MVD_ON_MIU == E_CHIP_MIU_1)
891 {
892 return (MS_U32)(u32SW_Address[u8CC608]);
893 }
894 else if(MVD_ON_MIU == E_CHIP_MIU_2)
895 {
896 return (MS_U32)(u32SW_Address[u8CC608]|u32Miu2_base);
897 }
898 else if(MVD_ON_MIU == E_CHIP_MIU_3)
899 {
900 return (MS_U32)(u32SW_Address[u8CC608]|u32Miu3_base);
901 }
902 else
903 {
904 return 0;
905 }
906 }
907 else if(u8BufSelMiu == E_CHIP_MIU_2) // SH@20110111, if CC buffer in MIU0, enable here
908 {
909 if(MVD_ON_MIU == E_CHIP_MIU_0)
910 {
911 return (MS_U32)(u32SW_Address[u8CC608]);
912 }
913 else if(MVD_ON_MIU == E_CHIP_MIU_1)
914 {
915 return (MS_U32)(u32SW_Address[u8CC608]|u32Miu1_base);
916 }
917 else if(MVD_ON_MIU == E_CHIP_MIU_2)
918 {
919 return (MS_U32)(u32SW_Address[u8CC608]);
920 }
921 else if(MVD_ON_MIU == E_CHIP_MIU_3)
922 {
923 return (MS_U32)(u32SW_Address[u8CC608]|u32Miu3_base);
924 }
925 else
926 {
927 return 0;
928 }
929 }
930 else if(u8BufSelMiu == E_CHIP_MIU_3) // SH@20110111, if CC buffer in MIU0, enable here
931 {
932 if(MVD_ON_MIU == E_CHIP_MIU_0)
933 {
934 return (MS_U32)(u32SW_Address[u8CC608]);
935 }
936 else if(MVD_ON_MIU == E_CHIP_MIU_1)
937 {
938 return (MS_U32)(u32SW_Address[u8CC608]|u32Miu1_base);
939 }
940 else if(MVD_ON_MIU == E_CHIP_MIU_2)
941 {
942 return (MS_U32)(u32SW_Address[u8CC608]|u32Miu2_base);
943 }
944 else if(MVD_ON_MIU == E_CHIP_MIU_3)
945 {
946 return (MS_U32)(u32SW_Address[u8CC608]);
947 }
948 else
949 {
950 return 0;
951 }
952
953 }
954 else
955 {
956 return 0;
957 }
958 }
959 #else
MDrv_CC_PM_GetMVDRB_ReadAddr(MS_U32 u32Id,MS_U8 u8CC608)960 MS_U32 MDrv_CC_PM_GetMVDRB_ReadAddr(MS_U32 u32Id, MS_U8 u8CC608)
961 {
962 if(bBufMiu0)
963 {
964 return (MS_U32)__Offset2PA(u32SW_Address[u8CC608]);
965 }
966 else
967 {
968 return (MS_U32)(u32SW_Address[u8CC608]);
969 }
970 }
971 #endif
972 ///////////////////////////////////////////////////////////////////////////////
973 /// Set Software Pointer of MVD CC Ring Buffer to MVD CC FW Driver
974 /// @param u32EachPacketSize \b IN SW Pointer Address
975 /// @param u8CC608 \b IN
976 /// - # TRUE for CC608 parser
977 /// - # FALSE for CC708 parser
978 ///////////////////////////////////////////////////////////////////////////////
979 #if defined(CHIP_MONACO)
MDrv_CC_PM_SetMVDRB_ReadAddr(MS_U32 u32Id,MS_U32 u32EachPacketSize,MS_U8 u8CC608)980 void MDrv_CC_PM_SetMVDRB_ReadAddr(MS_U32 u32Id, MS_U32 u32EachPacketSize, MS_U8 u8CC608)
981 {
982 MS_U32 u32MVDCC_Temp1 = 0;
983 MS_U32 u32ParsedDataSize;
984 MS_U32 u32Miu1_base = 0;
985 MS_U32 u32Miu2_base = 0;
986 MS_U32 u32Miu3_base = 0;
987
988 _miu_offset_to_phy(E_CHIP_MIU_1,0,u32Miu1_base);
989 _miu_offset_to_phy(E_CHIP_MIU_2,0,u32Miu2_base);
990 _miu_offset_to_phy(E_CHIP_MIU_3,0,u32Miu3_base);
991
992 // Get the Parsed Data Size
993 if ((u32EachPacketSize % MVD_CCRB_PACKET_LENGTH) != 0)
994 {
995 u32ParsedDataSize = MVD_CCRB_PACKET_LENGTH * ((u32EachPacketSize / MVD_CCRB_PACKET_LENGTH)+1);
996 }
997 else
998 {
999 u32ParsedDataSize = u32EachPacketSize;
1000 }
1001
1002 // Add the SW Address
1003 if(MVD_ON_MIU == E_CHIP_MIU_0)
1004 {
1005 if(u8BufSelMiu == E_CHIP_MIU_0) // SH@20110111, if CC buffer in MIU0, enable here
1006 {
1007 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] ;//& (MIU1_BASEADDR - 1); // to Phy address
1008 }
1009 else if(u8BufSelMiu == E_CHIP_MIU_1) // SH@20110111, if CC buffer in MIU0, enable here
1010 {
1011 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] ;//& (MIU1_BASEADDR - 1); // to Phy address
1012 }
1013 else if(u8BufSelMiu == E_CHIP_MIU_2) // SH@20110111, if CC buffer in MIU0, enable here
1014 {
1015 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] ;//& (MIU1_BASEADDR - 1); // to Phy address
1016 }
1017 else if(u8BufSelMiu == E_CHIP_MIU_3) // SH@20110111, if CC buffer in MIU0, enable here
1018 {
1019 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] ;//& (MIU1_BASEADDR - 1); // to Phy address
1020 }
1021 }
1022 else if(MVD_ON_MIU == E_CHIP_MIU_1)
1023 {
1024 if(u8BufSelMiu == E_CHIP_MIU_0) // SH@20110111, if CC buffer in MIU0, enable here
1025 {
1026 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] & (u32Miu1_base - 1); // to Phy address
1027 }
1028 else if(u8BufSelMiu == E_CHIP_MIU_1) // SH@20110111, if CC buffer in MIU0, enable here
1029 {
1030 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] ;//& (MIU1_BASEADDR - 1); // to Phy address
1031 }
1032 else if(u8BufSelMiu == E_CHIP_MIU_2) // SH@20110111, if CC buffer in MIU0, enable here
1033 {
1034 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] & (u32Miu1_base - 1); // to Phy address
1035 }
1036 else if(u8BufSelMiu == E_CHIP_MIU_3) // SH@20110111, if CC buffer in MIU0, enable here
1037 {
1038 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] & (u32Miu1_base - 1); // to Phy address
1039 }
1040 }
1041 else if(MVD_ON_MIU == E_CHIP_MIU_2)
1042 {
1043 if(u8BufSelMiu == E_CHIP_MIU_0) // SH@20110111, if CC buffer in MIU0, enable here
1044 {
1045 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] & (u32Miu2_base - 1); // to Phy address
1046 }
1047 else if(u8BufSelMiu == E_CHIP_MIU_1) // SH@20110111, if CC buffer in MIU0, enable here
1048 {
1049 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] & (u32Miu2_base - 1); // to Phy address
1050 }
1051 else if(u8BufSelMiu == E_CHIP_MIU_2) // SH@20110111, if CC buffer in MIU0, enable here
1052 {
1053 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] ;//& (MIU1_BASEADDR - 1); // to Phy address
1054 }
1055 else if(u8BufSelMiu == E_CHIP_MIU_3) // SH@20110111, if CC buffer in MIU0, enable here
1056 {
1057 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] & (u32Miu2_base - 1); // to Phy address
1058 }
1059 }
1060 else if(MVD_ON_MIU == E_CHIP_MIU_3)
1061 {
1062 if(u8BufSelMiu == E_CHIP_MIU_0) // SH@20110111, if CC buffer in MIU0, enable here
1063 {
1064 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] & (u32Miu3_base - 1); // to Phy address
1065 }
1066 else if(u8BufSelMiu == E_CHIP_MIU_1) // SH@20110111, if CC buffer in MIU0, enable here
1067 {
1068 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] & (u32Miu3_base - 1); // to Phy address
1069 }
1070 else if(u8BufSelMiu == E_CHIP_MIU_2) // SH@20110111, if CC buffer in MIU0, enable here
1071 {
1072 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] & (u32Miu3_base - 1); // to Phy address
1073 }
1074 else if(u8BufSelMiu == E_CHIP_MIU_3) // SH@20110111, if CC buffer in MIU0, enable here
1075 {
1076 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] ;//& (MIU1_BASEADDR - 1); // to Phy address
1077 }
1078 }
1079
1080 if ((u32SW_Address[u8CC608] + u32ParsedDataSize) < (u32MVDCC_Temp1 + CCMVD_RINGBUFFER_LEN[u8CC608]))
1081 {
1082 u32SW_Address[u8CC608] += u32ParsedDataSize;
1083 }
1084 else
1085 {
1086 u32SW_Address[u8CC608] = (u32ParsedDataSize + u32SW_Address[u8CC608] - CCMVD_RINGBUFFER_LEN[u8CC608]);
1087 }
1088
1089 #if 0
1090 if(u32HW_Address - u32SW_Address >= 512)
1091 {
1092 MVD_PRINT("Sync:0x%08Lx", u32SW_Address);
1093 u32SW_Address = u32HW_Address;
1094 MVD_PRINT("-->0x%08Lx\n", u32SW_Address);
1095 }
1096 #endif
1097
1098 MDrv_CC_CM_SetMVDRB_SWAddr(u32Id, u32SW_Address[u8CC608], u8CC608);
1099 }
1100 #else
MDrv_CC_PM_SetMVDRB_ReadAddr(MS_U32 u32Id,MS_U32 u32EachPacketSize,MS_U8 u8CC608)1101 void MDrv_CC_PM_SetMVDRB_ReadAddr(MS_U32 u32Id, MS_U32 u32EachPacketSize, MS_U8 u8CC608)
1102 {
1103 MS_U32 u32MVDCC_Temp1 = 0;
1104 MS_U32 u32ParsedDataSize;
1105
1106 // Get the Parsed Data Size
1107 if ((u32EachPacketSize % MVD_CCRB_PACKET_LENGTH) != 0)
1108 {
1109 u32ParsedDataSize = MVD_CCRB_PACKET_LENGTH * ((u32EachPacketSize / MVD_CCRB_PACKET_LENGTH)+1);
1110 }
1111 else
1112 {
1113 u32ParsedDataSize = u32EachPacketSize;
1114 }
1115
1116 // Add the SW Address
1117 if(MVD_ON_MIU1)
1118 {
1119 if(bBufMiu0) // SH@20110111, if CC buffer in MIU0, enable here
1120 {
1121 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] & (MIU1_BASEADDR - 1); // to Phy address
1122 }
1123 else // CC buffer in MIU1
1124 {
1125 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608] ;//& (MIU1_BASEADDR - 1); // to Phy address
1126 }
1127 }
1128 else
1129 {
1130 u32MVDCC_Temp1 = CCMVD_RINGBUFFER_START_ADR[u8CC608];
1131 }
1132
1133 if ((u32SW_Address[u8CC608] + u32ParsedDataSize) < (u32MVDCC_Temp1 + CCMVD_RINGBUFFER_LEN[u8CC608]))
1134 {
1135 u32SW_Address[u8CC608] += u32ParsedDataSize;
1136 }
1137 else
1138 {
1139 u32SW_Address[u8CC608] = (u32ParsedDataSize + u32SW_Address[u8CC608] - CCMVD_RINGBUFFER_LEN[u8CC608]);
1140 }
1141
1142 #if 0
1143 if(u32HW_Address - u32SW_Address >= 512)
1144 {
1145 MVD_PRINT("Sync:0x%08Lx", u32SW_Address);
1146 u32SW_Address = u32HW_Address;
1147 MVD_PRINT("-->0x%08Lx\n", u32SW_Address);
1148 }
1149 #endif
1150
1151 MDrv_CC_CM_SetMVDRB_SWAddr(u32Id, u32SW_Address[u8CC608], u8CC608);
1152 }
1153 #endif
MDrv_CC_CM_GetInfo(MS_U32 u32Id,MS_U32 selector,MS_U8 type,MS_U32 * p1,MS_U32 * p2)1154 void MDrv_CC_CM_GetInfo(MS_U32 u32Id, MS_U32 selector, MS_U8 type, MS_U32 *p1, MS_U32 *p2)
1155 {
1156 // Functionality select
1157 switch (selector)
1158 {
1159 case CC_SELECTOR_708_SW:
1160 *p1 = (MS_U32)bCC708Enable;
1161 break;
1162
1163 #if defined( MSOS_TYPE_LINUX )
1164 case CC_SELECTOR_CCMVD_RINGBUFFER:
1165 *p1 = (MS_U32)CCMVD_RINGBUFFER_START_ADR[type];
1166 *p2 = (MS_U32)CCMVD_RINGBUFFER_LEN[type];
1167 break;
1168 #endif
1169
1170 default:
1171 *p1 = *p2 = 0;
1172 break;
1173 }
1174 }
1175
MDrv_CC_CM_Get708Sw(MS_U32 u32Id)1176 MS_BOOL MDrv_CC_CM_Get708Sw(MS_U32 u32Id)
1177 {
1178 return bCC708Enable;
1179 }
1180
MDrv_CC_CM_IsMvdRstDone(MS_U32 u32Id,MS_U8 type)1181 MS_BOOL MDrv_CC_CM_IsMvdRstDone(MS_U32 u32Id, MS_U8 type)
1182 {
1183 MS_BOOL bRet = FALSE;
1184 MS_U8 u8HalIdx = MVD_GetHalIdx(u32Id);
1185
1186 if(type == E_CC_MVD_TYPE_608) // CC608
1187 {
1188 if(!HAL_MVD_IsCmdFinished(u8HalIdx, MVD_HANDSHAKE_RST_CC608))
1189 {
1190 bRet = TRUE;
1191 }
1192 }
1193 else // CC708
1194 {
1195 if(!HAL_MVD_IsCmdFinished(u8HalIdx, MVD_HANDSHAKE_RST_CC708))
1196 {
1197 bRet = TRUE;
1198 }
1199 }
1200
1201 return bRet;
1202 }
1203
1204
1205 ///////////////////////////////////////////////////////////////////////////////
1206 /// Enhance CC info mode, only support cc608
1207 /// @param bEnable \b IN
1208 /// - # TRUE for enhance to dump the pts/tmp_ref info
1209 /// - # FALSE for original
1210 ///////////////////////////////////////////////////////////////////////////////
MDrv_CC_InfoEnhanceMode(MS_U32 u32Id,MS_BOOL bEnable)1211 MS_BOOL MDrv_CC_InfoEnhanceMode(MS_U32 u32Id,MS_BOOL bEnable)
1212 {
1213 MS_U8 u8HalIdx = MVD_GetHalIdx(u32Id);
1214 MS_U8 u8Type = E_CC_MVD_TYPE_608;
1215 MVD_CmdArg mvdcmd;
1216 memset((void *)&mvdcmd, 0, sizeof(MVD_CmdArg));
1217
1218 mvdcmd.Arg0 = bEnable;
1219 mvdcmd.Arg3 = u8Type;
1220 SET_DECNUM(mvdcmd, u8HalIdx);
1221
1222 if (HAL_MVD_MVDCommand(CMD_EN_CC_INFO_ENHANCE, &mvdcmd) != TRUE)
1223 {
1224 MVDCC_EXHANDLE(MVD_PRINT("%s: cmd 0x%x fail!!\n", __FUNCTION__, CMD_EN_CC_INFO_ENHANCE));
1225 return FALSE;
1226 }
1227
1228 return TRUE;
1229 }
1230 #endif
1231