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 ////////////////////////////////////////////////////////////////////////////////
94
95 ///////////////////////////////////////////////////////////////////////////////////////////////////
96 ///
97 /// file apiMJPEG.c
98 /// @brief MJPEG API
99 /// @author MStar Semiconductor Inc.
100 ///////////////////////////////////////////////////////////////////////////////////////////////////
101
102 //-------------------------------------------------------------------------------------------------
103 // Include Files
104 //-------------------------------------------------------------------------------------------------
105 #include "MsCommon.h"
106 // JPEG
107 #include "drvMJPEG.h"
108 #include "apiJPEG.h"
109 #include "apiMJPEG.h"
110 // RIU Base
111 #include "drvMMIO.h"
112
113
114 //-------------------------------------------------------------------------------------------------
115 // Local Compiler Options
116 //-------------------------------------------------------------------------------------------------
117
118 #define ENABLE_MJPEG_FIRMWARE 1
119
120 #define ENABLE_AVSYNC_ID_CHECK 0
121
122 #define ENABLE_DOUBLE_FRAMERATE 0
123
124 #if (defined(CHIP_T8))
125 #define DECODER_RENDER_ARCH 1
126 #else
127 #define DECODER_RENDER_ARCH 0
128 #endif
129 //-------------------------------------------------------------------------------------------------
130 // Local Defines
131 //-------------------------------------------------------------------------------------------------
132 #define JPEGBASEWIDTHMAX 1600
133 #define JPEGBASEHEIGHTMAX 1200
134 #define JPEGPROWIDTHMAX 1024
135 #define JPEGPROHEIGHTMAX 768
136
137 #define MJPEG_MAX_SUPPORT_WIDTH 640
138 #define MJPEG_MAX_SUPPORT_HEIGHT 480
139
140
141 #define DISPLAY_QUEUE_NUM 4
142
143
144
145 //-------------------------------------------------------------------------------------------------
146 // Local Structures
147 //-------------------------------------------------------------------------------------------------
148 #define _MJPEG_Memcpy(pDstAddr, pSrcAddr, u32Size) \
149 do { \
150 MS_U32 i = 0; \
151 volatile MS_U8 *dst = (volatile MS_U8 *)(pDstAddr); \
152 volatile MS_U8 *src = (volatile MS_U8 *)(pSrcAddr); \
153 for (i = 0; i < (u32Size); i++) \
154 { \
155 dst[i] = src[i]; \
156 } \
157 } while (0)
158
159 #ifndef UNUSED
160 #define UNUSED(x) ((x)=(x))
161 #endif
162
163 //-------------------------------------------------------------------------------------------------
164 // Global Variables
165 //-------------------------------------------------------------------------------------------------
166
167
168 //-------------------------------------------------------------------------------------------------
169 // Local Variables
170 //-------------------------------------------------------------------------------------------------
171 static MS_BOOL bEnableDispCmdQ = TRUE;
172
173 //static MS_U32 __u32FwAddr = 0xFFFFFFFF; // Address to load firmware
174 static MS_U32 __u32MRCBufAddr = 0;
175 //static MS_U32 __u32MRCBufSize = 0;
176 static MS_U32 __u32MWCBufAddr = 0;
177 #if defined(CHIP_MARIA10) || defined(CHIP_MACAW12) || defined(CHIP_EDEN) || defined(CHIP_EULER)
178 static MS_U32 __u32MWCBufSize = 0;
179 #endif
180 static MS_U32 __u32InternalBufAddr = 0;
181 static MS_U32 __u32InternalBufSize = 0;
182
183 static MS_U32 __u32ReadPtr = 0;
184 static MS_U32 __u32WritePtr = 0;
185
186 static MS_U32 __u32FrameCnt = 0;
187 static MS_U32 __u32FrameTime = 0;
188 static MS_U32 __u32FrameRate = 600;
189 static MS_U32 __u32FrameRateBase = 20;
190
191 static MS_U16 __u16Width = 0;
192 static MS_U16 __u16Height = 0;
193 static MS_U16 __u16Pitch = 0;
194
195 static MS_U8 __u8FrameBuffTotalNum = DISPLAY_QUEUE_NUM;
196 static MS_U32 __u32FrameBuffUnitSize = 0;
197
198 static MS_BOOL __bIsFirstFrameRdy = FALSE;
199
200 static MS_U8 PreVIdx = 0;
201 static MS_U16 ReCheckTime = 0;
202
203 static MS_BOOL __bIsDecodeDone = FALSE;
204 static MS_U32 __u32DropFrameCnt = 0;
205 static MS_U32 u32NextFrameBuffIdx = 0;
206 static MS_U32 u32EndAddr = 0;
207
208 // Speed Control
209 static MJPEG_SpeedType eCurSpeedType = E_MJPEG_SPEED_DEFAULT;
210 static MJPEG_DispSpeed eCurDispSpeed = E_MJPEG_DISP_SPEED_1X;
211 static MS_U32 __u32SpeedCtrlFrameCntBase = 0;
212
213 static MS_U8 _u8MJPEG_ApiDbgLevel = E_JPEG_DEBUG_NONE;
214
215
216 MJPEG_FrameInfo infoDecFrame;
217 static MS_BOOL isDecFrameInfoValid = FALSE;
218 static MS_BOOL bStepDec = FALSE;
219 static MS_BOOL bLstFrame = FALSE;
220
221 static MS_BOOL __bSkipToPts = FALSE;
222 static MS_BOOL __bSeekToPts = FALSE;
223 static MS_U32 __u32TargetPts = 0;
224 static MS_U32 __u32Skip2PtsBase = 0;
225
226 static MJPEG_ErrorCode eMJPEGErrCode;
227
228 #if defined(CHIP_MARIA10) || defined(CHIP_MACAW12) || defined(CHIP_EDEN) || defined(CHIP_EULER)
229 static MS_U32 _u32FramePitch = 0;
230 static MS_U32 _u32FrameHeight = 0;
231 #endif
232
233 //-------------------------------------------------------------------------------------------------
234 // Debug Functions
235 //-------------------------------------------------------------------------------------------------
236
237 #define MJPEG_DEBUG(format, args...) do{if(_u8MJPEG_ApiDbgLevel & E_JPEG_DEBUG_MJPEG) printf(format, ##args);}while(0)
238 #define MJPEG_DEBUG_API_MSG(format, args...) do{if(_u8MJPEG_ApiDbgLevel & E_JPEG_DEBUG_API) printf(format, ##args);}while(0)
239 #define MJPEG_DEBUG_API_ERR(format, args...) do{if(_u8MJPEG_ApiDbgLevel & E_JPEG_DEBUG_ERR) printf(format, ##args);}while(0)
240
241
242 //-------------------------------------------------------------------------------------------------
243 // Local Functions
244 //-------------------------------------------------------------------------------------------------
_MApi_MJPEG_SetErrCode(MJPEG_ErrorCode eErrorCode)245 void _MApi_MJPEG_SetErrCode(MJPEG_ErrorCode eErrorCode)
246 {
247 MJPEG_DEBUG_API_MSG("_MApi_MJPEG_SetErrCode() with eMJPEGErrCode=0x%x\n", eErrorCode);
248 eMJPEGErrCode = eErrorCode;
249 }
250
251 //-------------------------------------------------------------------------------------------------
252 // Global Functions
253 //-------------------------------------------------------------------------------------------------
254
255 /******************************************************************************/
256 ///Called only when video start
257 ///@param pInitParam \b IN initial paramters
258 ///@param pStream \b IN file system realted function pointers
259 ///@return true or false
260 /******************************************************************************/
MApi_MJPEG_Init(MJPEG_INIT_PARAM * pInitParam)261 MJPEG_Result MApi_MJPEG_Init(MJPEG_INIT_PARAM *pInitParam)//, PJPEG_FILE_FileSystem_t pStream)
262 {
263 JPEG_InitParam jpegInitParam;
264
265 // For register read/write
266 extern MS_U32 u32MJPEGRiuBaseAdd;
267 MS_U32 u32NonPMBankSize = 0;
268
269 if(FALSE == MDrv_MMIO_GetBASE( &u32MJPEGRiuBaseAdd, &u32NonPMBankSize, MS_MODULE_JPD))
270 {
271 MJPEG_DEBUG_API_MSG("MDrv_MMIO_GetBASE FAILED !! \n");
272 return E_MJPEG_RET_FAIL;
273 }
274
275 MJPEG_DEBUG_API_MSG("DRVreg base = 0x%lX, length = %lu\n", u32MJPEGRiuBaseAdd, u32NonPMBankSize);
276
277 #if defined(CHIP_MARIA10) || defined(CHIP_MACAW12) || defined(CHIP_EDEN) || defined(CHIP_EULER)
278 _u32FramePitch = (((pInitParam->u32Width + 7)>>3)<<3);
279 _u32FrameHeight = pInitParam->u32Height;
280 #endif
281
282 #if ENABLE_MJPEG_FIRMWARE
283 //
284 // Init Firmware
285 //
286 #if defined(CHIP_T2)
287 // Reset VPU
288 MDrv_JPD_RstVPU();
289 // Load JPD firmware
290 // __u32FwAddr = pInitParam->u32FwAddr;
291 MDrv_JPD_LoadCode(pInitParam->u32FwAddr, pInitParam->u32FwBinSize, pInitParam->u32FwBinAddr, pInitParam->eFwSrcType);
292 // Set VPU base and endian
293 MDrv_JPD_ConfigVPU(pInitParam->u32FwAddr, 1); // 1 for little endian
294
295 // Clear ShareMemory before releasing VPU
296 MDrv_JPD_ClearShareMemory();
297
298 // Release VPU
299 MDrv_JPD_ReleaseVPU();
300 #else
301 if(E_JPD_OK != MDrv_JPD_InitFw(pInitParam->u32FwAddr, pInitParam->u32FwBinSize, pInitParam->u32FwBinAddr, pInitParam->eFwSrcType))
302 {
303 MJPEG_DEBUG_API_ERR("MDrv_JPD_InitFw Failed~~~~\n");
304 }
305 // __u32FwAddr = pInitParam->u32FwAddr;
306 #endif
307
308 isDecFrameInfoValid = FALSE;
309 bStepDec = FALSE;
310
311 MJPEG_DEBUG_API_MSG("clear error code due to call MApi_MJPEG_Init()\n");
312 _MApi_MJPEG_SetErrCode(E_MJPEG_ERROR_CODE_NONE);
313 // Check if firmware is ready or not
314 if (MDrv_JPD_IsFirmwareReady() == FALSE)
315 return E_MJPEG_RET_FAIL;
316
317 if((pInitParam->u32MWCBufAddr)%8)
318 {
319 MJPEG_DEBUG_API_ERR("u32MWCBufAddr need 8 byte alignment~~~~0x%lx\n", pInitParam->u32MWCBufAddr);
320 }
321 else
322 {
323 MJPEG_DEBUG_API_ERR("u32MWCBufAddr don't need 8 byte alignment~~~~0x%lx\n", pInitParam->u32MWCBufAddr);
324 }
325
326 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_BUFF_START_ADDR, pInitParam->u32MWCBufAddr);
327 #if defined(CHIP_MARIA10) || defined(CHIP_MACAW12) || defined(CHIP_EDEN) || defined(CHIP_EULER)
328 __u32FrameBuffUnitSize = _u32FramePitch * _u32FrameHeight * 2;
329 printf("_u32FramePitch = %ld\n", _u32FramePitch);
330 printf("_u32FrameHeight = %ld\n", _u32FrameHeight);
331 printf("__u32FrameBuffUnitSize = 0x%lx\n", __u32FrameBuffUnitSize);
332 #else
333 __u32FrameBuffUnitSize = pInitParam->u32MWCBufSize/__u8FrameBuffTotalNum;
334 __u32FrameBuffUnitSize = (__u32FrameBuffUnitSize >> 3) << 3;//8 byte alignment
335 #endif
336 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_BUFF_UNIT_SIZE, __u32FrameBuffUnitSize);
337 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_BUFF_TOTAL_NUM, __u8FrameBuffTotalNum);
338 #if ENABLE_DOUBLE_FRAMERATE
339 printf (" frame rate base %ld\n", pInitParam->u32FrameRate);
340 pInitParam->u32FrameRate /= 2;
341 printf (" 1/2 frame rate base %ld\n", pInitParam->u32FrameRate);
342 #endif
343 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAMERATE, pInitParam->u32FrameRate);
344 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAMERATE_BASE, pInitParam->u32FrameRateBase);
345 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_CHIP_ID, MDrv_JPD_Get_Chip_ID());
346
347 if(pInitParam->u32FrameRate ==0)
348 {
349 MJPEG_DEBUG_API_ERR("Error!!! MJPEG Frame rate is 0\n");
350 pInitParam->u32FrameRate =30000;
351 }
352 __u32FrameRate = pInitParam->u32FrameRate;
353 __u32FrameRateBase = pInitParam->u32FrameRateBase;
354 __u32FrameTime = __u32FrameRateBase * 1000 / __u32FrameRate;
355 #endif // ENABLE_MJPEG_FIRMWARE
356
357 __u32FrameCnt = 0;
358 __u32DropFrameCnt = 0;
359
360 __u32MRCBufAddr = pInitParam->u32MRCBufAddr;
361 // __u32MRCBufSize = pInitParam->u32MRCBufSize;
362 __u32MWCBufAddr = pInitParam->u32MWCBufAddr;
363 #if defined(CHIP_MARIA10) || defined(CHIP_MACAW12) || defined(CHIP_EDEN) || defined(CHIP_EULER)
364 __u32MWCBufSize = __u32FrameBuffUnitSize * __u8FrameBuffTotalNum * 2;
365 #else
366 // __u32MWCBufSize = pInitParam->u32MWCBufSize;
367 #endif
368 __u32InternalBufAddr = pInitParam->u32InternalBufAddr;
369 __u32InternalBufSize = pInitParam->u32InternalBufSize;
370
371 jpegInitParam.u32MRCBufAddr = pInitParam->u32MRCBufAddr;
372 jpegInitParam.u32MRCBufSize = pInitParam->u32MRCBufSize;
373 jpegInitParam.u32MWCBufAddr = pInitParam->u32MWCBufAddr;
374 #if defined(CHIP_MARIA10) || defined(CHIP_MACAW12) || defined(CHIP_EDEN) || defined(CHIP_EULER)
375 jpegInitParam.u32MWCBufSize = __u32MWCBufSize;
376 #else
377 jpegInitParam.u32MWCBufSize = pInitParam->u32MWCBufSize;
378 #endif
379 jpegInitParam.u32InternalBufAddr = pInitParam->u32InternalBufAddr;
380 jpegInitParam.u32InternalBufSize = pInitParam->u32InternalBufSize;
381 jpegInitParam.u32DecByteRead = 0;
382 jpegInitParam.bEOF = TRUE;
383 jpegInitParam.u8DecodeType = E_JPEG_TYPE_MJPEG;
384 jpegInitParam.bInitMem = TRUE;
385 jpegInitParam.pFillHdrFunc = NULL;
386
387
388 // This is used to init memory
389 if (MApi_JPEG_Init(&jpegInitParam) == E_JPEG_FAILED)
390 return E_MJPEG_RET_FAIL;
391
392 // Make sure it's exited correctly
393 MApi_JPEG_Exit();
394
395 // Init Local Variables
396 PreVIdx = 0;
397 ReCheckTime = 0;
398 bLstFrame = FALSE;
399 __u32ReadPtr = 0;
400 __u32WritePtr =0;
401
402 return E_MJPEG_RET_SUCCESS;
403 }
404
405 /******************************************************************************/
406 ///Reset JPD
407 /******************************************************************************/
MApi_MJPEG_Rst(void)408 MJPEG_Result MApi_MJPEG_Rst(void)
409 {
410 //__u32FrameCnt = 0;
411 __bIsFirstFrameRdy = FALSE;
412
413 MApi_JPEG_Rst();
414 MJPEG_DEBUG_API_MSG("clear error code due to call MApi_MJPEG_Rst()\n");
415 _MApi_MJPEG_SetErrCode(E_MJPEG_ERROR_CODE_NONE);
416
417 // CHECK : reset firmware???
418
419 return E_MJPEG_RET_SUCCESS;
420 }
421
422 /******************************************************************************/
423 ///Turn off JPD clock
424 /******************************************************************************/
425 //extern void MApi_JPEG_DisableAddressConvert(void); // defined in apiJPEG.c
MApi_MJPEG_Stop(void)426 MJPEG_Result MApi_MJPEG_Stop(void)
427 {
428
429 //__u32FrameCnt = 0;
430 __bIsFirstFrameRdy = FALSE;
431 isDecFrameInfoValid = FALSE;
432 bStepDec = FALSE;
433
434 MDrv_JPD_StopVPU();
435
436 //MApi_JPEG_PowerOff() is called in MApi_JPEG_Exit()
437 MApi_JPEG_Exit();
438
439 MApi_JPEG_DisableAddressConvert();
440
441 // CHECK : stop firmware???
442
443 return E_MJPEG_RET_SUCCESS;
444 }
445
446 /******************************************************************************/
447 ///Check if first frame has been decoded
448 ///@return TRUE if first picture is decoded, else return FALSE
449 /******************************************************************************/
MApi_MJPEG_CheckDispInfoRdy(void)450 MJPEG_Result MApi_MJPEG_CheckDispInfoRdy(void)
451 {
452 if ((TRUE == __bIsFirstFrameRdy)
453 && (E_JPEG_EVENT_DEC_DONE & MApi_JPEG_GetJPDEventFlag()))
454 {
455 // Should use the width & height of 1st frame
456 //__u16Width = MApi_JPEG_GetWidth();
457 //__u16Height = MApi_JPEG_GetHeight();
458
459 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_CheckDispInfoRdy : E_MJPEG_RET_SUCCESS\n");
460 return E_MJPEG_RET_SUCCESS;
461 }
462
463 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_CheckDispInfoRdy : E_MJPEG_RET_FAIL\n");
464 return E_MJPEG_RET_FAIL;
465 }
466
467 /******************************************************************************/
468 ///Play
469 ///@param in \b IN in parameter
470 ///@param out \b OUT out parameter
471 ///@return status
472 /******************************************************************************/
MApi_MJPEG_Play(void)473 MJPEG_Result MApi_MJPEG_Play(void)
474 {
475 if (MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_PLAY, 0xFFFFFFFF) == 0)
476 {
477 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_Play : E_MJPEG_RET_FAIL\n");
478 return E_MJPEG_RET_FAIL;
479 }
480
481 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_Play : E_MJPEG_RET_SUCCESS\n");
482 return E_MJPEG_RET_SUCCESS;
483 }
484
485 /******************************************************************************/
486 ///Pause
487 ///@param in \b IN in parameter
488 ///@param out \b OUT out parameter
489 ///@return status
490 /******************************************************************************/
MApi_MJPEG_Pause(void)491 MJPEG_Result MApi_MJPEG_Pause(void)
492 {
493 if (MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_PAUSE, 0xFFFFFFFF) == 0)
494 {
495 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_Play : E_MJPEG_RET_FAIL\n");
496 return E_MJPEG_RET_FAIL;
497 }
498
499 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_Play : E_MJPEG_RET_SUCCESS\n");
500 return E_MJPEG_RET_SUCCESS;
501 }
502
503 /******************************************************************************/
504 ///Resume
505 ///@param in \b IN in parameter
506 ///@param out \b OUT out parameter
507 ///@return status
508 /******************************************************************************/
MApi_MJPEG_Resume(void)509 MJPEG_Result MApi_MJPEG_Resume(void)
510 {
511 if (MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_RESUME, 0xFFFFFFFF) == 0)
512 {
513 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_Resume : E_MJPEG_RET_FAIL\n");
514 return E_MJPEG_RET_FAIL;
515 }
516
517 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_Resume : E_MJPEG_RET_SUCCESS\n");
518 return E_MJPEG_RET_SUCCESS;
519 }
520
521 /******************************************************************************/
522 ///Step Play
523 ///@param in \b IN in parameter
524 ///@param out \b OUT out parameter
525 ///@return status
526 /******************************************************************************/
MApi_MJPEG_StepPlay(void)527 MJPEG_Result MApi_MJPEG_StepPlay(void)
528 {
529 if (MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_STEP_PLAY, 0xFFFFFFFF) == 0)
530 {
531 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_StepPlay : E_MJPEG_RET_FAIL\n");
532 return E_MJPEG_RET_FAIL;
533 }
534
535 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_StepPlay : E_MJPEG_RET_SUCCESS\n");
536 return E_MJPEG_RET_SUCCESS;
537 }
538
539 /******************************************************************************/
540 ///Check if step play is done or not
541 ///@return true or false
542 /******************************************************************************/
MApi_MJPEG_IsStepPlayDone(void)543 MS_BOOL MApi_MJPEG_IsStepPlayDone(void)
544 {
545 if (MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_IS_STEP_PLAY_DONE, 0xFFFFFFFF) == 0)
546 {
547 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_IsStepPlayDone : TRUE\n");
548 return TRUE;
549 }
550
551 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_IsStepPlayDone : FALSE\n");
552 return FALSE;
553 }
554
555 /******************************************************************************/
556 ///Description
557 ///@param in \b IN in parameter
558 ///@param out \b OUT out parameter
559 ///@return status
560 /******************************************************************************/
MApi_MJPEG_StepDecode(void)561 MJPEG_Result MApi_MJPEG_StepDecode(void)
562 {
563 bStepDec = FALSE;
564 return E_MJPEG_RET_SUCCESS;
565 }
566
567 /******************************************************************************/
568 ///Check if JPEG decode done
569 ///@return status
570 /******************************************************************************/
__MApi_MJPEG_CheckDecodeDone(void)571 MJPEG_Result __MApi_MJPEG_CheckDecodeDone(void)
572 {
573 MS_U16 cur_vidx = 0;
574
575
576 if (__bIsFirstFrameRdy)
577 {
578 JPEG_Event reg_val = MApi_JPEG_GetJPDEventFlag();
579 MJPEG_DEBUG_API_MSG(" EventFlag = %d\n", reg_val);
580
581 //For H/W bug, some cases can not exit after decode done. Check Vidx to exit.
582 if(PreVIdx != (cur_vidx = MApi_JPEG_GetCurVidx()))
583 {
584 PreVIdx = cur_vidx;
585 ReCheckTime = 0;
586 }
587 else
588 {
589 ReCheckTime++;
590 if(ReCheckTime >= 1000)
591 {
592 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_BUFF_IDX_VALID, u32NextFrameBuffIdx);
593 MJPEG_DEBUG_API_MSG("Set frame buffer index %ld as Valid", u32NextFrameBuffIdx);
594 __bIsDecodeDone = TRUE;
595 __u32DropFrameCnt++;
596
597 MJPEG_DEBUG_API_ERR("Decode timeout!!!!\n");
598 reg_val = E_JPEG_EVENT_DEC_ERROR_MASK;
599 return E_MJPEG_RET_FAIL;
600 }
601 }
602
603 if(E_JPEG_EVENT_DEC_DONE & reg_val)
604 {
605 ReCheckTime = 0;
606
607 MJPEG_DEBUG_API_MSG(" Decode Done -- ");
608 #if ENABLE_MJPEG_FIRMWARE
609 if (__bIsDecodeDone == FALSE)
610 {
611 if (__u32DropFrameCnt != 0)
612 { // Ask firmware to compensate PTS
613 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_COMPENSATE_PTS, __u32DropFrameCnt);
614 MJPEG_DEBUG_API_MSG("Compensate PTS for %ld dropped frames", __u32DropFrameCnt);
615 }
616 __u32DropFrameCnt = 0;
617
618 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_BUFF_IDX_READY, u32NextFrameBuffIdx);
619 MJPEG_DEBUG_API_MSG("Frame Buffer Index %ld", u32NextFrameBuffIdx);
620 __bIsDecodeDone = TRUE;
621 }
622 #endif
623 MJPEG_DEBUG_API_MSG("\n");
624 //__u32FrameCnt++;
625 //__u32ReadPtr = u32EndAddr;
626 MJPEG_DEBUG_API_MSG("Count %ld\n", __u32FrameCnt);
627 }
628 else
629 if(E_JPEG_EVENT_DEC_ERROR_MASK & reg_val)
630 {
631 MJPEG_DEBUG_API_ERR(" JPD Decode Error\n");
632
633 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_BUFF_IDX_VALID, u32NextFrameBuffIdx);
634 MJPEG_DEBUG_API_MSG("Set frame buffer index %ld as Valid", u32NextFrameBuffIdx);
635 __bIsDecodeDone = TRUE;
636 __u32DropFrameCnt++;
637 return E_MJPEG_RET_DECODE_ERROR;
638 }
639 else
640 {
641 MJPEG_DEBUG_API_MSG(" Still decoding previous JPEG ......\n");
642
643 return E_MJPEG_RET_DECODING;
644 }
645 }
646 else
647 {
648 return E_MJPEG_RET_FAIL;
649 }
650
651
652 return E_MJPEG_RET_SUCCESS;
653 }
654
655 /******************************************************************************/
656 ///Description
657 ///@param in \b IN in parameter
658 ///@param out \b OUT out parameter
659 ///@return status
660 /******************************************************************************/
MApi_MJPEG_IsStepDecodeDone(void)661 MS_BOOL MApi_MJPEG_IsStepDecodeDone(void)
662 {
663 if(FALSE == bStepDec)
664 return FALSE;
665
666 if (E_MJPEG_RET_SUCCESS == __MApi_MJPEG_CheckDecodeDone())
667 return TRUE;
668
669 return FALSE;
670 }
671
672 static MS_U16 u16NullCnt;
673
674 /******************************************************************************/
675 ///Issue full JPEG decode process
676 ///@param in \b IN in parameter
677 ///@param out \b OUT out parameter
678 ///@return status
679 /******************************************************************************/
680 //MJPEG_Result MApi_MJPEG_PushQueue(MS_PHYADDR u32StAddr, MS_U32 u32Size, MS_U32 u32TimeStamp)
MApi_MJPEG_PushQueue(MJPEG_Packet_Info * pInfo)681 MJPEG_Result MApi_MJPEG_PushQueue(MJPEG_Packet_Info *pInfo)
682 {
683 //
684 // There's no queue
685 //
686 JPEG_InitParam jpegInitParam;
687
688
689 if(pInfo->u32Size == 0)
690 {
691 u16NullCnt++;
692 MJPEG_DEBUG_API_MSG("%s: MJPEG NULL PACKET!!!!!!!!!!\n", __FUNCTION__);
693 return E_MJPEG_RET_SUCCESS;
694 }
695
696 MS_U16 u16DecodeCnt;
697 for(u16DecodeCnt=0; u16DecodeCnt<=u16NullCnt; u16DecodeCnt++)
698 {
699 if (E_MJPEG_RET_DECODING == __MApi_MJPEG_CheckDecodeDone())
700 {
701 u16NullCnt -=u16DecodeCnt;
702 MJPEG_DEBUG_API_MSG("%s: E_MJPEG_RET_DECODING with u16DecodeCnt=%d\n", __FUNCTION__, u16DecodeCnt);
703 return E_MJPEG_RET_DECODING;
704 }
705 #if 1
706 MJPEG_DEBUG("[MWC][%dx%d.yuyv]addr=0x%lx, size=0x%x\n",
707 MApi_JPEG_GetWidth(), MApi_JPEG_GetHeight(), infoDecFrame.u32LumaAddr,
708 MApi_JPEG_GetWidth()*MApi_JPEG_GetHeight()*2);
709 #endif
710 __u32FrameCnt++;
711 __u32ReadPtr = u32EndAddr;
712 MJPEG_DEBUG_API_MSG("%s: Count %ld, __bSkipToPts=%d, __bSeekToPts=%d, __u32Skip2PtsBase=%ld, __u32TargetPts=%ld\n",
713 __FUNCTION__, __u32FrameCnt, __bSkipToPts, __bSeekToPts, __u32Skip2PtsBase, __u32TargetPts);
714
715
716 __u32WritePtr = pInfo->u32StAddr + pInfo->u32Size - 1;
717
718
719 // Skip/Seek to PTS
720 if (__bSkipToPts || __bSeekToPts)
721 {
722 if (__u32Skip2PtsBase >= __u32TargetPts)
723 {
724 MJPEG_DEBUG_API_MSG("Skip/Seek to PTS done -- current PTS %ld\n", __u32Skip2PtsBase);
725 __bSkipToPts = FALSE;
726 __bSeekToPts = FALSE;
727 // Need to update firmware PTS base
728 MDrv_JPD_ResetPTS(__u32Skip2PtsBase);
729 }
730 else
731 {
732 MJPEG_DEBUG_API_MSG("Skip Frame -- PTS %ld\n", __u32Skip2PtsBase);
733 __u32Skip2PtsBase += __u32FrameTime;
734 __bIsDecodeDone = TRUE;
735 u32EndAddr = pInfo->u32StAddr + pInfo->u32Size - 1;
736 return E_MJPEG_RET_SUCCESS;
737 }
738 }
739
740 // Speed Control
741 if (__bIsFirstFrameRdy)
742 {
743 if (eCurSpeedType == E_MJPEG_SPEED_FAST)
744 {
745 if ((__u32FrameCnt - __u32SpeedCtrlFrameCntBase) % eCurDispSpeed)
746 {
747 MJPEG_DEBUG_API_MSG(" Skip frame %ld\n", (__u32FrameCnt - __u32SpeedCtrlFrameCntBase));
748 //__u32FrameCnt++;
749 __bIsDecodeDone = TRUE;
750 u16NullCnt=0;
751 return E_MJPEG_RET_SUCCESS;
752 }
753 }
754 else if (eCurSpeedType == E_MJPEG_SPEED_SLOW)
755 {
756 }
757 else // if (eCurSpeedType == E_MJPEG_SPEED_DEFAULT)
758 {
759 __u32SpeedCtrlFrameCntBase = __u32FrameCnt;
760 MJPEG_DEBUG_API_MSG(" Update Frame Count Base %ld\n", __u32SpeedCtrlFrameCntBase);
761 }
762 }
763
764
765 MApi_JPEG_SetMaxDecodeResolution(JPEGBASEWIDTHMAX, JPEGBASEHEIGHTMAX);
766 // Init
767 jpegInitParam.u32MRCBufAddr = pInfo->u32StAddr + __u32MRCBufAddr;
768 // Tricky code: let JPD decode only L buffer, then decode dne
769 jpegInitParam.u32MRCBufSize = pInfo->u32Size*2;
770 if (jpegInitParam.u32MRCBufSize < JPEG_DEFAULT_EXIF_SIZE)
771 { // Meet size check in MApi_JPEG_Init()
772 jpegInitParam.u32MRCBufSize = JPEG_DEFAULT_EXIF_SIZE;
773 }
774
775 // Ask firmware if there is any frame buffer available
776 u32NextFrameBuffIdx = MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_GET_NEXT_FREE_FRAME_BUFF_IDX, 0xFFFFFFFF);
777 MJPEG_DEBUG_API_MSG(" E_MJPEG_CMD_GET_NEXT_FREE_FRAME_BUFF_IDX %ld\n", u32NextFrameBuffIdx);
778 if (u32NextFrameBuffIdx >= 0xFF)// It may be 0xFF, 0xFFFF, 0xFFFFFF, or 0xFFFFFFFF
779 {
780 MJPEG_DEBUG_API_ERR(" !!! No frame buffer available !!!\n");
781 __bIsDecodeDone = TRUE;
782 __u32DropFrameCnt++;
783 u16NullCnt=0;
784 return E_MJPEG_RET_FAIL;
785 }
786 if (__bIsFirstFrameRdy == FALSE)
787 {
788 u32NextFrameBuffIdx = 0;
789 }
790 __bIsDecodeDone = FALSE;
791 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_BUFF_IDX, u32NextFrameBuffIdx);
792 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_TIMESTAMP, pInfo->u32TimeStamp);
793 MJPEG_DEBUG_API_MSG(" u32TimeStamp %ld", pInfo->u32TimeStamp);
794 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_ID_L, pInfo->u32ID_L);
795 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_ID_H, pInfo->u32ID_H);
796 MJPEG_DEBUG_API_MSG("Frame ID 0x%lx%lx", pInfo->u32ID_H, pInfo->u32ID_L);
797
798 jpegInitParam.u32MWCBufAddr = __u32MWCBufAddr + __u32FrameBuffUnitSize*u32NextFrameBuffIdx;
799 MJPEG_DEBUG_API_MSG(" Set Frame buffer addr 0x%lx\n", jpegInitParam.u32MWCBufAddr);
800 jpegInitParam.u32MWCBufSize = __u32FrameBuffUnitSize;
801
802 jpegInitParam.u32InternalBufAddr = __u32InternalBufAddr;
803 jpegInitParam.u32InternalBufSize = __u32InternalBufSize;
804 jpegInitParam.u32DecByteRead = pInfo->u32Size;
805 jpegInitParam.bEOF = TRUE; // Set to TRUE to disable read function
806 jpegInitParam.u8DecodeType = E_JPEG_TYPE_MAIN; // only set to E_JPEG_TYPE_MJPEG when 1st time
807 jpegInitParam.bInitMem = TRUE;
808 jpegInitParam.pFillHdrFunc = NULL;
809
810 #if ENABLE_AVSYNC_ID_CHECK
811 printf ("ID 0x%08lx%08lx PTS %ld\n", pInfo->u32ID_H, pInfo->u32ID_L, pInfo->u32TimeStamp);
812 #endif
813
814 // Make sure it's exited correctly
815 MApi_JPEG_Exit();
816
817
818 u32EndAddr = pInfo->u32StAddr + pInfo->u32Size - 1;
819
820
821 if (MApi_JPEG_Init(&jpegInitParam) == E_JPEG_FAILED)
822 {
823 MJPEG_DEBUG_API_ERR("MApi_JPEG_Init() FAIL\n");
824 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_BUFF_IDX_VALID, u32NextFrameBuffIdx);
825 MJPEG_DEBUG_API_MSG("Set frame buffer index %ld as Valid", u32NextFrameBuffIdx);
826 __bIsDecodeDone = TRUE;
827 __u32DropFrameCnt++;
828 u16NullCnt=0;
829 return E_MJPEG_RET_FAIL;
830 }
831
832 // Get width, height, & pitch of 1st frame
833 if (__bIsFirstFrameRdy == FALSE)
834 {
835 __u16Width = MApi_JPEG_GetWidth();
836 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_WIDTH, __u16Width);
837 __u16Height = MApi_JPEG_GetHeight();
838 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_HEIGHT, __u16Height);
839 __u16Pitch = MApi_JPEG_GetAlignedPitch();
840 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_PITCH, __u16Pitch);
841 MJPEG_DEBUG_API_MSG(" width %d, height %d, pitch %d\n", __u16Width, __u16Height, __u16Pitch);
842
843 if((__u16Width > MJPEG_MAX_SUPPORT_WIDTH) ||
844 (__u16Height>MJPEG_MAX_SUPPORT_HEIGHT))
845 {
846 MJPEG_DEBUG_API_MSG("Set MJPEG error code=E_MJPEG_ERR_CODE_RES \n");
847 _MApi_MJPEG_SetErrCode(E_MJPEG_ERR_CODE_RES);
848 }
849 #if defined(CHIP_MARIA10) || defined(CHIP_MACAW12) || defined(CHIP_EDEN) || defined(CHIP_EULER)
850 if((_u32FramePitch < __u16Width)
851 || (_u32FrameHeight < __u16Height))
852 {
853 _u32FramePitch = (((__u16Width + 7)>>3)<<3);
854 _u32FrameHeight = __u16Height;
855 __u32FrameBuffUnitSize = _u32FramePitch * _u32FrameHeight * 2;
856 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_BUFF_UNIT_SIZE, __u32FrameBuffUnitSize);
857 MJPEG_DEBUG_API_MSG("Change _u32FramePitch = %ld\n", _u32FramePitch);
858 MJPEG_DEBUG_API_MSG("Change _u32FrameHeight = %ld\n", _u32FrameHeight);
859 MJPEG_DEBUG_API_MSG("Change __u32FrameBuffUnitSize = 0x%lx\n", __u32FrameBuffUnitSize);
860 }
861 #endif
862 }
863
864 // Fill decode frame info
865 infoDecFrame.u32LumaAddr = jpegInitParam.u32MWCBufAddr;
866 infoDecFrame.u32ChromaAddr = infoDecFrame.u32LumaAddr;
867 infoDecFrame.u32TimeStamp = pInfo->u32TimeStamp;
868 infoDecFrame.u32ID_L = pInfo->u32ID_L;
869 infoDecFrame.u32ID_H = pInfo->u32ID_H;
870 infoDecFrame.u16Pitch = __u16Pitch;
871 infoDecFrame.u16Width = __u16Width;
872 infoDecFrame.u16Height = __u16Height;
873 isDecFrameInfoValid = TRUE;
874
875 // Decode header
876 if (MApi_JPEG_DecodeHdr() == E_JPEG_FAILED)
877 {
878 MJPEG_DEBUG_API_ERR("MApi_JPEG_DecodeHdr() FAIL\n");
879 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_BUFF_IDX_VALID, u32NextFrameBuffIdx);
880 MJPEG_DEBUG_API_MSG("Set frame buffer index %ld as Valid", u32NextFrameBuffIdx);
881 __bIsDecodeDone = TRUE;
882 __u32DropFrameCnt++;
883 u16NullCnt=0;
884
885 JPEG_ErrCode jpeg_errcode = MApi_JPEG_GetErrorCode();
886 if((E_JPEG_UNSUPPORTED_COLORSPACE == jpeg_errcode)
887 || (E_JPEG_UNSUPPORTED_SAMP_FACTORS == jpeg_errcode)
888 || (E_JPEG_UNSUPPORTED_HUFF_DECODE == jpeg_errcode))
889 {
890 MJPEG_DEBUG_API_ERR("Set MJPEG error code=E_MJPEG_ERR_CODE_RES for unsupport!!\n");
891 _MApi_MJPEG_SetErrCode(E_MJPEG_ERR_CODE_RES);
892 }
893
894 return E_MJPEG_RET_DECODE_HDR_ERROR;
895 }
896
897 bStepDec = TRUE;
898
899 // Decode
900 if (MApi_JPEG_Decode() == E_JPEG_FAILED)
901 {
902 MJPEG_DEBUG_API_ERR("MApi_JPEG_Decode() FAIL\n");
903 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_FRAME_BUFF_IDX_VALID, u32NextFrameBuffIdx);
904 MJPEG_DEBUG_API_MSG("Set frame buffer index %ld as Valid", u32NextFrameBuffIdx);
905 __bIsDecodeDone = TRUE;
906 __u32DropFrameCnt++;
907 u16NullCnt=0;
908 return E_MJPEG_RET_DECODE_ERROR;
909 }
910
911
912 // Moved Up
913 //u32EndAddr = pInfo->u32StAddr + pInfo->u32Size - 1;
914 __bIsFirstFrameRdy = TRUE;
915
916 // All done, wait for decoding finish
917 if(u16NullCnt ==u16DecodeCnt)
918 {
919 if(u16NullCnt!=0)
920 {
921 MJPEG_DEBUG_API_MSG("%s: Handle MJPEG NULL PACKET with u16DecodeCnt=%d\n", __FUNCTION__, u16DecodeCnt);
922 }
923 u16NullCnt=0;
924 return E_MJPEG_RET_SUCCESS;
925 }
926 else
927 {
928 MJPEG_DEBUG_API_MSG("%s: Duplicate PACKET with u16DecodeCnt=%d\n", __FUNCTION__, u16DecodeCnt);
929 }
930 }
931
932 // Only for compile ok, the code should not run to this place.
933 MJPEG_DEBUG_API_MSG("%s: Handle MJPEG NULL PACKET with u16DecodeCnt=%d\n", __FUNCTION__, u16DecodeCnt);
934 u16NullCnt=0;
935 return E_MJPEG_RET_SUCCESS;
936 }
937
938 /******************************************************************************/
939 ///Description
940 ///@param in \b IN in parameter
941 ///@param out \b OUT out parameter
942 ///@return status
943 /******************************************************************************/
MApi_MJPEG_GetQueueVacancy(void)944 MS_U32 MApi_MJPEG_GetQueueVacancy(void)
945 {
946 MS_U32 u32tmpcounter;
947 #if ENABLE_AVSYNC_ID_CHECK
948 MJPEG_FrameInfo info;
949 MApi_MJPEG_GetDispFrameInfo(&info);
950 #endif
951
952
953 if (__bIsFirstFrameRdy == FALSE)
954 {
955 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_GetQueueVacancy : 1\n");
956 return 1;
957 }
958 else
959 {
960 if (__MApi_MJPEG_CheckDecodeDone() != E_MJPEG_RET_DECODING)
961 {
962 if (MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_IS_DISPLAY_QUEUE_FULL, 0xFFFFFFFF) == 1)
963 {
964 MJPEG_DEBUG_API_MSG(" Display queue is full\n");
965 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_GetQueueVacancy : 0\n");
966 return 0;
967 }
968
969 u32tmpcounter = MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_GET_NEXT_FREE_FRAME_BUFF_IDX, 0xFFFFFFFF);
970 if ( u32tmpcounter>= 0xFF)
971 {
972 MJPEG_DEBUG_API_MSG("E_MJPEG_CMD_GET_NEXT_FREE_FRAME_BUFF_IDX %ld\n", u32tmpcounter);
973 return 0;
974 }
975 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_GetQueueVacancy : 1\n");
976 return 1;
977 }
978 }
979
980 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_GetQueueVacancy : 0\n");
981 return 0;
982 }
983
984 /******************************************************************************/
985 ///Description
986 ///@param in \b IN in parameter
987 ///@param out \b OUT out parameter
988 ///@return status
989 /******************************************************************************/
MApi_MJPEG_FlushQueue(void)990 MJPEG_Result MApi_MJPEG_FlushQueue(void)
991 {
992 // Wait current frame decode done
993 while (E_MJPEG_RET_DECODING == __MApi_MJPEG_CheckDecodeDone())
994 ;
995
996 // Stop firmware display to avoid display queue status overwritten
997 MApi_MJPEG_Pause();
998
999 isDecFrameInfoValid = FALSE;
1000 bStepDec = FALSE;
1001
1002 if (MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_FLUSH_DISP_QUEUE, 0xFFFFFFFF) == 0)
1003 {
1004 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_FlushQueue : E_MJPEG_RET_FAIL\n");
1005 return E_MJPEG_RET_FAIL;
1006 }
1007
1008 while (MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_IS_FLUSH_DONE, 0xFFFFFFFF) == 0)
1009 {
1010 printf ("Wait for flush done\n");
1011 }
1012
1013 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_FlushQueue : E_MJPEG_RET_SUCCESS\n");
1014 return E_MJPEG_RET_SUCCESS;
1015 }
1016
1017 /******************************************************************************/
1018 ///Description
1019 ///@param in \b IN in parameter
1020 ///@param out \b OUT out parameter
1021 ///@return status
1022 /******************************************************************************/
MApi_MJPEG_GetESWritePtr(void)1023 MS_U32 MApi_MJPEG_GetESWritePtr(void)
1024 {
1025 // return end of data
1026 return __u32WritePtr;
1027 }
1028
1029 /******************************************************************************/
1030 ///Description
1031 ///@param in \b IN in parameter
1032 ///@param out \b OUT out parameter
1033 ///@return status
1034 /******************************************************************************/
MApi_MJPEG_GetESReadPtr(void)1035 MS_U32 MApi_MJPEG_GetESReadPtr(void)
1036 {
1037 // return end of data
1038 return __u32ReadPtr;
1039 }
1040
1041 /******************************************************************************/
1042 ///Description
1043 ///@param in \b IN in parameter
1044 ///@param out \b OUT out parameter
1045 ///@return status
1046 /******************************************************************************/
MApi_MJPEG_EnableLastFrameShow(MS_BOOL bEnable)1047 MJPEG_Result MApi_MJPEG_EnableLastFrameShow(MS_BOOL bEnable)
1048 {
1049 bLstFrame = bEnable;
1050 // This function always returns true.
1051 // Because MJPEG firmware does not reserve any frame.
1052 return E_MJPEG_RET_SUCCESS;
1053 }
1054
1055 /******************************************************************************/
1056 ///Description
1057 ///@param in \b IN in parameter
1058 ///@param out \b OUT out parameter
1059 ///@return status
1060 /******************************************************************************/
MApi_MJPEG_IsDispFinish(void)1061 MS_BOOL MApi_MJPEG_IsDispFinish(void)
1062 {
1063 // Check if the last frame decode finish,
1064 // Call this function to set E_MJPEG_CMD_SET_FRAME_BUFF_IDX_READY
1065 // when decode done.
1066 // MJPEG_Result ret;
1067 if (bLstFrame == 0)
1068 {
1069 return FALSE;
1070 }
1071 // ret = __MApi_MJPEG_CheckDecodeDone();
1072
1073 if(E_MJPEG_RET_SUCCESS != __MApi_MJPEG_CheckDecodeDone())
1074 {
1075 MJPEG_DEBUG_API_MSG("MApi_MJPEG_IsDispFinish: MApi_MJPEG_CheckDecodeDone Fail!!\n");
1076 }
1077
1078
1079 if (MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_IS_DISP_FINISH, 0xFFFFFFFF) == 0)
1080 {
1081 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_IsDispFinish : FALSE\n");
1082 return FALSE;
1083 }
1084
1085 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_IsDispFinish : TRUE\n");
1086 return TRUE;
1087 }
1088
1089 /******************************************************************************/
1090 ///Description
1091 ///@param in \b IN in parameter
1092 ///@param out \b OUT out parameter
1093 ///@return status
1094 /******************************************************************************/
MApi_MJPEG_SetSpeed(MJPEG_SpeedType eSpeedType,MJPEG_DispSpeed eDispSpeed)1095 MJPEG_Result MApi_MJPEG_SetSpeed(MJPEG_SpeedType eSpeedType, MJPEG_DispSpeed eDispSpeed)
1096 {
1097 eCurSpeedType = eSpeedType;
1098 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_SPEED_TYPE, (MS_U32)eSpeedType);
1099
1100 eCurDispSpeed = eDispSpeed;
1101 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_SPEED, (MS_U32)eDispSpeed);
1102
1103 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_STC_BASE, 0xFFFFFFFF);
1104
1105 return E_MJPEG_RET_SUCCESS;
1106 }
1107
1108 /******************************************************************************/
1109 ///Description
1110 ///@param in \b IN in parameter
1111 ///@param out \b OUT out parameter
1112 ///@return status
1113 /******************************************************************************/
MApi_MJPEG_SetFreezeDisp(MS_BOOL bEnable)1114 MJPEG_Result MApi_MJPEG_SetFreezeDisp(MS_BOOL bEnable)
1115 {
1116 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_FREEZE_DISP, (MS_U32)bEnable);
1117
1118 return E_MJPEG_RET_SUCCESS;
1119 }
1120
1121 /******************************************************************************/
1122 ///Description
1123 ///@param in \b IN in parameter
1124 ///@param out \b OUT out parameter
1125 ///@return status
1126 /******************************************************************************/
MApi_MJPEG_SetBlueScreen(MS_BOOL bOn)1127 MJPEG_Result MApi_MJPEG_SetBlueScreen(MS_BOOL bOn)
1128 {
1129 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_BLUE_SCREEN, (MS_U32)bOn);
1130
1131 return E_MJPEG_RET_SUCCESS;
1132 }
1133
1134 /******************************************************************************/
1135 ///Reset PTS value
1136 ///@param u32Value \b IN new PTS value
1137 /******************************************************************************/
MApi_MJPEG_ResetPTS(MS_U32 u32PtsBase)1138 MJPEG_Result MApi_MJPEG_ResetPTS(MS_U32 u32PtsBase)
1139 {
1140 if (MDrv_JPD_ResetPTS(u32PtsBase))
1141 return E_MJPEG_RET_SUCCESS;
1142
1143 return E_MJPEG_RET_FAIL;
1144 }
1145
1146 /******************************************************************************/
1147 ///Return PTS of current displayed frame
1148 ///@return PTS
1149 /******************************************************************************/
MApi_MJPEG_GetPTS(void)1150 MS_U32 MApi_MJPEG_GetPTS(void)
1151 {
1152 return MDrv_JPD_GetPTS();
1153 }
1154
1155 /******************************************************************************/
1156 ///Description
1157 ///@param in \b IN in parameter
1158 ///@param out \b OUT out parameter
1159 ///@return status
1160 /******************************************************************************/
MApi_MJPEG_AVSyncOn(MS_BOOL bOn,MS_U32 u32SyncDelay,MS_U16 u16SyncTolerance)1161 MJPEG_Result MApi_MJPEG_AVSyncOn(MS_BOOL bOn, MS_U32 u32SyncDelay, MS_U16 u16SyncTolerance)
1162 {
1163 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_ENABLE_AVSYNC, (MS_U32)bOn);
1164 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_AVSYNC_DELAY, (MS_U32)u32SyncDelay);
1165 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_SET_AVSYNC_TOLERENCE, (MS_U32)u16SyncTolerance);
1166
1167 return E_MJPEG_RET_SUCCESS;
1168 }
1169
1170 /******************************************************************************/
1171 ///Description
1172 ///@param in \b IN in parameter
1173 ///@param out \b OUT out parameter
1174 ///@return status
1175 /******************************************************************************/
MApi_MJPEG_IsAVSyncOn(void)1176 MS_BOOL MApi_MJPEG_IsAVSyncOn(void)
1177 {
1178 return MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_IS_AVSYNC_ON, 0xFFFFFFFF);
1179 }
1180
1181 /******************************************************************************/
1182 ///Description
1183 ///@param in \b IN in parameter
1184 ///@param out \b OUT out parameter
1185 ///@return status
1186 /******************************************************************************/
MApi_MJPEG_IsReachSync(void)1187 MS_BOOL MApi_MJPEG_IsReachSync(void)
1188 {
1189 return MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_IS_REACH_AVSYNC, 0xFFFFFFFF);
1190 }
1191
1192 /******************************************************************************/
1193 ///Description
1194 ///@param in \b IN in parameter
1195 ///@param out \b OUT out parameter
1196 ///@return status
1197 /******************************************************************************/
MApi_MJPEG_GetStatus(MJPEG_Status * pStatus)1198 MS_BOOL MApi_MJPEG_GetStatus(MJPEG_Status *pStatus)
1199 {
1200 pStatus->bIdle = MApi_MJPEG_IsIdle();
1201 //pStatus->bInit
1202 //pStatus->eStage = E_MJPEG_STAGE_PLAY;
1203
1204 return FALSE;
1205 }
1206
1207 /******************************************************************************/
1208 ///Return JPD error code
1209 ///@return JPD error code
1210 /******************************************************************************/
MApi_MJPEG_GetErrCode(void)1211 MS_U32 MApi_MJPEG_GetErrCode(void)
1212 {
1213 // Per XDemux's request, this only returns critical error.
1214 // Since no error would prevent JPD from decoding next JPEG,
1215 // it always return 0 here.
1216 MJPEG_DEBUG_API_MSG("MApi_MJPEG_GetErrCode() with eMJPEGErrCode=0x%x\n", eMJPEGErrCode);
1217 return eMJPEGErrCode;
1218 }
1219
1220 /******************************************************************************/
1221 ///Description
1222 ///@param in \b IN in parameter
1223 ///@param out \b OUT out parameter
1224 ///@return status
1225 /******************************************************************************/
MApi_MJPEG_GetErrCnt(void)1226 MS_U32 MApi_MJPEG_GetErrCnt(void)
1227 {
1228 return 0;
1229 }
1230
1231 /******************************************************************************/
1232 ///Return count of current displayed frame
1233 ///@return frame count
1234 /******************************************************************************/
MApi_MJPEG_GetFrameCnt(void)1235 MS_U32 MApi_MJPEG_GetFrameCnt(void)
1236 {
1237 return __u32FrameCnt;
1238 }
1239
1240 /******************************************************************************/
1241 ///Return video information
1242 ///@param pInfo \b OUT video information: width & height
1243 /******************************************************************************/
MApi_MJPEG_GetDispInfo(MJPEG_DISP_INFO * pInfo)1244 MJPEG_Result MApi_MJPEG_GetDispInfo(MJPEG_DISP_INFO *pInfo)
1245 {
1246 // APP wants pitch to setup display
1247 // This should be used with crop information
1248 pInfo->u16Width = __u16Pitch;
1249 pInfo->u16Height = __u16Height;
1250 pInfo->u16Pitch = __u16Pitch;
1251 pInfo->u32FrameRate = __u32FrameRate * 1000 / __u32FrameRateBase;
1252
1253 pInfo->u16CropLeft = (pInfo->u16Width - __u16Width)/2;
1254 pInfo->u16CropRight = pInfo->u16Width - __u16Width - pInfo->u16CropLeft;
1255 pInfo->u16CropTop = (pInfo->u16Height - __u16Height)/2;
1256 pInfo->u16CropBottom = pInfo->u16Height - __u16Height - pInfo->u16CropTop;
1257 MJPEG_DEBUG_API_MSG(" Crop info right %d, left %d, bottom %d, top %d\n",
1258 pInfo->u16CropRight, pInfo->u16CropLeft, pInfo->u16CropBottom, pInfo->u16CropTop);
1259
1260 return E_MJPEG_RET_SUCCESS;
1261 }
1262
1263 /******************************************************************************/
1264 ///Description
1265 ///@param in \b IN in parameter
1266 ///@param out \b OUT out parameter
1267 ///@return status
1268 /******************************************************************************/
MApi_MJPEG_IsPlaying(void)1269 MS_BOOL MApi_MJPEG_IsPlaying(void)
1270 {
1271 if (MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_IS_PLAYING, 0xFFFFFFFF) == 0)
1272 {
1273 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_IsPlaying : FALSE\n");
1274 return FALSE;
1275 }
1276
1277 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_IsPlaying : TRUE\n");
1278 return TRUE;
1279 }
1280
1281 /******************************************************************************/
1282 ///Return true if idle, including decode done & error
1283 ///@return idle or not
1284 /******************************************************************************/
MApi_MJPEG_IsIdle(void)1285 MS_BOOL MApi_MJPEG_IsIdle(void)
1286 {
1287 JPEG_Event u16Value = MApi_JPEG_GetJPDEventFlag();
1288 if ((E_JPEG_EVENT_DEC_DONE & u16Value)
1289 || (E_JPEG_EVENT_DEC_ERROR_MASK & u16Value))
1290 {
1291 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_IsIdle : TRUE\n");
1292 return TRUE;
1293 }
1294
1295 MJPEG_DEBUG_API_MSG(" MApi_MJPEG_IsIdle : FALSE\n");
1296 return FALSE;
1297 }
1298
1299 /******************************************************************************/
1300 ///Description
1301 ///@param in \b IN in parameter
1302 ///@param out \b OUT out parameter
1303 ///@return status
1304 /******************************************************************************/
MApi_MJPEG_IsIFrameFound(void)1305 MS_BOOL MApi_MJPEG_IsIFrameFound(void)
1306 {
1307 return TRUE;
1308 }
1309
1310 /******************************************************************************/
1311 ///Description
1312 ///@param in \b IN in parameter
1313 ///@param out \b OUT out parameter
1314 ///@return status
1315 /******************************************************************************/
MApi_MJPEG_IsWithLowDelay(void)1316 MS_BOOL MApi_MJPEG_IsWithLowDelay(void)
1317 {
1318 return TRUE;
1319 }
1320
1321 /******************************************************************************/
1322 ///Description
1323 ///@param in \b IN in parameter
1324 ///@param out \b OUT out parameter
1325 ///@return status
1326 /******************************************************************************/
MApi_MJPEG_GetDecFrameInfo(MJPEG_FrameInfo * pFrmInfo)1327 MJPEG_Result MApi_MJPEG_GetDecFrameInfo(MJPEG_FrameInfo *pFrmInfo)
1328 {
1329 if(FALSE == isDecFrameInfoValid)
1330 return E_MJPEG_RET_FAIL;
1331
1332 pFrmInfo->u32LumaAddr = infoDecFrame.u32LumaAddr;
1333 pFrmInfo->u32ChromaAddr = infoDecFrame.u32ChromaAddr;
1334 pFrmInfo->u32TimeStamp = infoDecFrame.u32TimeStamp;
1335 pFrmInfo->u32ID_L = infoDecFrame.u32ID_L;
1336 pFrmInfo->u32ID_H = infoDecFrame.u32ID_H;
1337 pFrmInfo->u16Pitch = infoDecFrame.u16Pitch;
1338 pFrmInfo->u16Width = infoDecFrame.u16Width;
1339 pFrmInfo->u16Height = infoDecFrame.u16Height;
1340 pFrmInfo->eFrameType = E_MJPEG_FRM_TYPE_I;
1341
1342 return E_MJPEG_RET_SUCCESS;
1343 }
1344
1345 /******************************************************************************/
1346 ///Description
1347 ///@param in \b IN in parameter
1348 ///@param out \b OUT out parameter
1349 ///@return status
1350 /******************************************************************************/
MApi_MJPEG_GetDispFrameInfo(MJPEG_FrameInfo * pFrmInfo)1351 MJPEG_Result MApi_MJPEG_GetDispFrameInfo(MJPEG_FrameInfo *pFrmInfo)
1352 {
1353 #if ENABLE_AVSYNC_ID_CHECK
1354 static MS_U32 u32OldID_L = 0, u32OldID_H = 0, u32OldTimeStamp = 0;
1355 #endif
1356 MJPEG_FrameInfo info;
1357 MDrv_JPD_GetDispFrameInfo((void *)&info);
1358
1359 pFrmInfo->u32LumaAddr = info.u32LumaAddr;
1360 pFrmInfo->u32ChromaAddr = info.u32ChromaAddr;
1361 pFrmInfo->u32TimeStamp = info.u32TimeStamp;
1362 pFrmInfo->u32ID_L = info.u32ID_L;
1363 pFrmInfo->u32ID_H = info.u32ID_H;
1364 pFrmInfo->u16Pitch = __u16Pitch;
1365 pFrmInfo->u16Width = __u16Width;
1366 pFrmInfo->u16Height = __u16Height;
1367 pFrmInfo->eFrameType = E_MJPEG_FRM_TYPE_I;
1368
1369 #if ENABLE_AVSYNC_ID_CHECK
1370 if (u32OldID_H != pFrmInfo->u32ID_H || u32OldID_L != pFrmInfo->u32ID_L
1371 || u32OldTimeStamp != pFrmInfo->u32TimeStamp)
1372 {
1373 printf ("ID 0x%08lx%08lx PTS %ld addr 0x%lx\n",
1374 pFrmInfo->u32ID_H, pFrmInfo->u32ID_L, pFrmInfo->u32TimeStamp, pFrmInfo->u32LumaAddr);
1375 u32OldID_H = pFrmInfo->u32ID_H;
1376 u32OldID_L = pFrmInfo->u32ID_L;
1377 u32OldTimeStamp = pFrmInfo->u32TimeStamp;
1378 }
1379 #endif
1380
1381 return E_MJPEG_RET_SUCCESS;
1382 }
1383
1384 /******************************************************************************/
1385 ///Description
1386 ///@param in \b IN in parameter
1387 ///@param out \b OUT out parameter
1388 ///@return status
1389 /******************************************************************************/
MApi_MJPEG_DbgSetMsgLevel(MJPEG_DbgLevel eDbgLevel)1390 void MApi_MJPEG_DbgSetMsgLevel(MJPEG_DbgLevel eDbgLevel)
1391 {
1392 MS_U8 u8Level;
1393
1394 switch (eDbgLevel)
1395 {
1396 case E_MJPEG_DBG_LEVEL_ERR:
1397 u8Level = E_JPEG_DEBUG_ERR;
1398 _u8MJPEG_ApiDbgLevel = E_JPEG_DEBUG_ERR;
1399 break;
1400 case E_MJPEG_DBG_LEVEL_INFO:
1401 u8Level = E_JPEG_DEBUG_ERR;
1402 _u8MJPEG_ApiDbgLevel = E_JPEG_DEBUG_MJPEG | E_JPEG_DEBUG_ERR;
1403 break;
1404 case E_MJPEG_DBG_LEVEL_DBG:
1405 u8Level = E_JPEG_DEBUG_ALL;
1406 _u8MJPEG_ApiDbgLevel = E_JPEG_DEBUG_API | E_JPEG_DEBUG_ERR;
1407 break;
1408 case E_MJPEG_DBG_LEVEL_TRACE:
1409 u8Level = E_JPEG_DEBUG_ALL;
1410 _u8MJPEG_ApiDbgLevel = E_JPEG_DEBUG_API | E_JPEG_DEBUG_ERR;
1411 break;
1412 case E_MJPEG_DBG_LEVEL_FW:
1413 printf ("\n !!!Firmware debug message is not supported yet!!!\n\n");
1414 u8Level = E_JPEG_DEBUG_NONE;
1415 _u8MJPEG_ApiDbgLevel = E_JPEG_DEBUG_NONE;
1416 break;
1417 case E_MJPEG_DBG_LEVEL_NONE:
1418 default:
1419 u8Level = E_JPEG_DEBUG_NONE;
1420 _u8MJPEG_ApiDbgLevel = E_JPEG_DEBUG_NONE;
1421 break;
1422 }
1423
1424 MApi_JPEG_SetDbgLevel(u8Level);
1425 MDrv_MJPEG_SetDbgLevel(u8Level);
1426 }
1427
1428 /******************************************************************************/
1429 ///Description
1430 ///@param in \b IN in parameter
1431 ///@param out \b OUT out parameter
1432 ///@return status
1433 /******************************************************************************/
MApi_MJPEG_DbgSetData(MS_PHYADDR u32Addr,MS_U32 u32Data)1434 MJPEG_Result MApi_MJPEG_DbgSetData(MS_PHYADDR u32Addr, MS_U32 u32Data)
1435 {
1436 u32Addr = u32Addr;
1437 u32Data = u32Data;
1438 return E_MJPEG_RET_SUCCESS;
1439 }
1440
1441 /******************************************************************************/
1442 ///Description
1443 ///@param in \b IN in parameter
1444 ///@param out \b OUT out parameter
1445 ///@return status
1446 /******************************************************************************/
MApi_MJPEG_DbgGetData(MS_PHYADDR u32Addr,MS_U32 * u32Data)1447 MJPEG_Result MApi_MJPEG_DbgGetData(MS_PHYADDR u32Addr, MS_U32* u32Data)
1448 {
1449 u32Addr = u32Addr;
1450 *u32Data = 0;
1451
1452 return E_MJPEG_RET_SUCCESS;
1453 }
1454
1455 /******************************************************************************/
1456 ///Description
1457 ///@param in \b IN in parameter
1458 ///@param out \b OUT out parameter
1459 ///@return status
1460 /******************************************************************************/
1461 #if DECODER_RENDER_ARCH
MApi_MJPEG_DispFrame(MS_U32 u32DispIdx)1462 MJPEG_Result MApi_MJPEG_DispFrame(MS_U32 u32DispIdx)
1463 {
1464 MDrv_JPD_DispFrame(u32DispIdx);
1465 return E_MJPEG_RET_SUCCESS;
1466 }
1467
1468 /******************************************************************************/
1469 ///Description
1470 ///@param in \b IN in parameter
1471 ///@param out \b OUT out parameter
1472 ///@return status
1473 /******************************************************************************/
MApi_MJPEG_FreeFrame(MS_U32 u32DispIdx)1474 MJPEG_Result MApi_MJPEG_FreeFrame(MS_U32 u32DispIdx)
1475 {
1476 MDrv_JPD_FreeFrame(u32DispIdx);
1477 return E_MJPEG_RET_SUCCESS;
1478 }
1479
1480 /******************************************************************************/
1481 ///Description
1482 ///@param in \b IN in parameter
1483 ///@param out \b OUT out parameter
1484 ///@return status
1485 /******************************************************************************/
MApi_MJPEG_GetNextDispFrame(MJPEG_FrameInfo * pFrmInfo)1486 MJPEG_Result MApi_MJPEG_GetNextDispFrame(MJPEG_FrameInfo *pFrmInfo)
1487 {
1488 MJPEG_FrameInfo *pSrc = (MJPEG_FrameInfo*)MDrv_JPD_GetNextDispFrame();
1489 if (pSrc != NULL)
1490 {
1491 _MJPEG_Memcpy(pFrmInfo, pSrc, sizeof(MJPEG_FrameInfo));
1492 pFrmInfo->u16Width = __u16Pitch;
1493 pFrmInfo->u16Height = __u16Height;
1494 pFrmInfo->u16Pitch = __u16Pitch;
1495 pFrmInfo->eFrameType = E_MJPEG_FRM_TYPE_I;
1496 return E_MJPEG_RET_SUCCESS;
1497 }
1498 return E_MJPEG_RET_FAIL;
1499 }
1500
1501 /******************************************************************************/
1502 ///Description
1503 ///@param in \b IN in parameter
1504 ///@param out \b OUT out parameter
1505 ///@return status
1506 /******************************************************************************/
MApi_MJPEG_GetNextDispQPtr(void)1507 MS_U32 MApi_MJPEG_GetNextDispQPtr(void)
1508 {
1509 return MDrv_JPD_GetNextDispQPtr();
1510 }
1511
1512 /******************************************************************************/
1513 ///Description
1514 ///@param in \b IN in parameter
1515 ///@param out \b OUT out parameter
1516 ///@return status
1517 /******************************************************************************/
1518 #else
MApi_MJPEG_DispFrame(MS_U32 u32DispIdx)1519 MJPEG_Result MApi_MJPEG_DispFrame(MS_U32 u32DispIdx)
1520 {
1521 return E_MJPEG_RET_FAIL;
1522 }
1523
1524 /******************************************************************************/
1525 ///Description
1526 ///@param in \b IN in parameter
1527 ///@param out \b OUT out parameter
1528 ///@return status
1529 /******************************************************************************/
MApi_MJPEG_FreeFrame(MS_U32 u32DispIdx)1530 MJPEG_Result MApi_MJPEG_FreeFrame(MS_U32 u32DispIdx)
1531 {
1532 return E_MJPEG_RET_FAIL;
1533 }
1534
1535 /******************************************************************************/
1536 ///Description
1537 ///@param in \b IN in parameter
1538 ///@param out \b OUT out parameter
1539 ///@return status
1540 /******************************************************************************/
MApi_MJPEG_GetNextDispFrame(MJPEG_FrameInfo * pFrmInfo)1541 MJPEG_Result MApi_MJPEG_GetNextDispFrame(MJPEG_FrameInfo *pFrmInfo)
1542 {
1543 UNUSED(pFrmInfo);
1544 return E_MJPEG_RET_FAIL;
1545 }
1546
1547 /******************************************************************************/
1548 ///Description
1549 ///@param in \b IN in parameter
1550 ///@param out \b OUT out parameter
1551 ///@return status
1552 /******************************************************************************/
MApi_MJPEG_GetNextDispQPtr(void)1553 MS_U32 MApi_MJPEG_GetNextDispQPtr(void)
1554 {
1555 return E_MJPEG_RET_FAIL;
1556 }
1557 #endif
MApi_MJPEG_EnableDispCmdQ(MS_BOOL bEnable)1558 MJPEG_Result MApi_MJPEG_EnableDispCmdQ(MS_BOOL bEnable)
1559 {
1560 bEnableDispCmdQ = bEnable;
1561
1562 MDrv_JPD_SendVPUCommand(E_MJPEG_CMD_ENABLE_DISP_CMD_QUEUE, bEnable);
1563
1564 return E_MJPEG_RET_SUCCESS;
1565 }
1566
1567 /******************************************************************************/
1568 ///Description
1569 ///@param in \b IN in parameter
1570 ///@param out \b OUT out parameter
1571 ///@return status
1572 /******************************************************************************/
MApi_MJPEG_PushDispCmdQ(void)1573 MJPEG_Result MApi_MJPEG_PushDispCmdQ(void)
1574 {
1575 if (bEnableDispCmdQ)
1576 {
1577 }
1578
1579 return E_MJPEG_RET_FAIL;
1580 }
1581
1582 /******************************************************************************/
1583 ///Description
1584 ///@param in \b IN in parameter
1585 ///@param out \b OUT out parameter
1586 ///@return status
1587 /******************************************************************************/
MApi_MJPEG_GetDispCmdQVacancy(void)1588 MS_U32 MApi_MJPEG_GetDispCmdQVacancy(void)
1589 {
1590 if (bEnableDispCmdQ)
1591 {
1592 }
1593
1594 return 0;
1595 }
1596
1597 /******************************************************************************/
1598 ///Description
1599 ///@param in \b IN in parameter
1600 ///@param out \b OUT out parameter
1601 ///@return status
1602 /******************************************************************************/
MApi_MJPEG_SeekToPTS(MS_U32 u32PTS)1603 MJPEG_Result MApi_MJPEG_SeekToPTS(MS_U32 u32PTS)
1604 {
1605 __bSeekToPts = TRUE;
1606 __u32Skip2PtsBase = MApi_MJPEG_GetPTS();
1607 __u32TargetPts = u32PTS;
1608 MJPEG_DEBUG_API_MSG(" Seek from PTS %ld to %ld\n", __u32Skip2PtsBase, __u32TargetPts);
1609
1610 return E_MJPEG_RET_SUCCESS;
1611 }
1612
1613 /******************************************************************************/
1614 ///Description
1615 ///@param in \b IN in parameter
1616 ///@param out \b OUT out parameter
1617 ///@return status
1618 /******************************************************************************/
MApi_MJPEG_SkipToPTS(MS_U32 u32PTS)1619 MJPEG_Result MApi_MJPEG_SkipToPTS(MS_U32 u32PTS)
1620 {
1621 __bSkipToPts = TRUE;
1622 __u32Skip2PtsBase = MApi_MJPEG_GetPTS();
1623 __u32TargetPts = u32PTS;
1624 MJPEG_DEBUG_API_MSG(" Skip from PTS %ld to %ld\n", __u32Skip2PtsBase, __u32TargetPts);
1625
1626 return E_MJPEG_RET_SUCCESS;
1627 }
1628
1629 /******************************************************************************/
1630 ///Description : Enable/Disable FW turbo mode
1631 ///@param bEnable \b IN enable or not.
1632 ///@return NONE
1633 /******************************************************************************/
MApi_MJPEG_EnableTurboFWMode(MS_BOOL bEnable)1634 void MApi_MJPEG_EnableTurboFWMode(MS_BOOL bEnable)
1635 {
1636 MDrv_JPD_EnableTurboFWMode(bEnable);
1637 }
1638
1639