xref: /utopia/UTPA2-700.0.x/modules/xc/api/ace/apiXC_Ace.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 //    Software and any modification/derivatives thereof.
18 //    No right, ownership, or interest to MStar Software and any
19 //    modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 //    supplied together with third party`s software and the use of MStar
23 //    Software may require additional licenses from third parties.
24 //    Therefore, you hereby agree it is your sole responsibility to separately
25 //    obtain any and all third party right and license necessary for your use of
26 //    such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 //    MStar`s confidential information and you agree to keep MStar`s
30 //    confidential information in strictest confidence and not disclose to any
31 //    third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 //    kind. Any warranties are hereby expressly disclaimed by MStar, including
35 //    without limitation, any warranties of merchantability, non-infringement of
36 //    intellectual property rights, fitness for a particular purpose, error free
37 //    and in conformity with any international standard.  You agree to waive any
38 //    claim against MStar for any loss, damage, cost or expense that you may
39 //    incur related to your use of MStar Software.
40 //    In no event shall MStar be liable for any direct, indirect, incidental or
41 //    consequential damages, including without limitation, lost of profit or
42 //    revenues, lost or damage of data, and unauthorized system use.
43 //    You agree that this Section 4 shall still apply without being affected
44 //    even if MStar Software has been modified by MStar in accordance with your
45 //    request or instruction for your use, except otherwise agreed by both
46 //    parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 //    services in relation with MStar Software to you for your use of
50 //    MStar Software in conjunction with your or your customer`s product
51 //    ("Services").
52 //    You understand and agree that, except otherwise agreed by both parties in
53 //    writing, Services are provided on an "AS IS" basis and the warranty
54 //    disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 //    or otherwise:
58 //    (a) conferring any license or right to use MStar name, trademark, service
59 //        mark, symbol or any other identification;
60 //    (b) obligating MStar or any of its affiliates to furnish any person,
61 //        including without limitation, you and your customers, any assistance
62 //        of any kind whatsoever, or any information; or
63 //    (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 //    of Taiwan, R.O.C., excluding its conflict of law rules.
67 //    Any and all dispute arising out hereof or related hereto shall be finally
68 //    settled by arbitration referred to the Chinese Arbitration Association,
69 //    Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 //    Rules of the Association by three (3) arbitrators appointed in accordance
71 //    with the said Rules.
72 //    The place of arbitration shall be in Taipei, Taiwan and the language shall
73 //    be English.
74 //    The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 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 /// This file contains MStar ACE Application Interface.
98 /// brief API for Advanced Color Engine Control
99 /// author MStar Semiconductor, Inc.
100 //
101 ////////////////////////////////////////////////////////////////////////////////
102 
103 
104 #ifndef _API_XC_ACE_C_
105 #define _API_XC_ACE_C_
106 
107 /******************************************************************************/
108 /*                    Header Files                                            */
109 /* ****************************************************************************/
110 
111 // Need to remove
112 //#include "msAPI_Timer.h"
113 
114 
115 // Must have
116 #ifdef MSOS_TYPE_LINUX_KERNEL
117 #include <linux/string.h>
118 #else
119 #include <string.h>
120 #endif
121 // Common Definition
122 #include "MsCommon.h"
123 #include "MsVersion.h"
124 #include "MsIRQ.h"
125 #include "MsOS.h"
126 #include "utopia.h"
127 #include "utopia_dapi.h"
128 
129 
130 #include "apiXC_Ace.h"
131 #include "drvACE.h"
132 // Internal Definition
133 #include "drvMMIO.h"
134 #include "apiXC_Ace_v2.h"
135 #include "ACE_private.h"
136 #include "apiXC.h"
137 #include "mvideo_context.h"
138 
139 extern void MDrv_XC_SetMWEStatus(void *pInstance, MS_BOOL bMWEStatus);
140 extern MS_BOOL MDrv_XC_GetMWEStatus(void *pInstance);
141 //-------------------------------------------------------------------------------------------------
142 //  Local Defines
143 //-------------------------------------------------------------------------------------------------
144 
145 #define MAIN_WINDOW     0
146 #define SUB_WINDOW      1
147 
148 /******************************************************************************/
149 /*                      Debug information                                      */
150 /******************************************************************************/
151 #ifdef CONFIG_MS_DEBUG_XC_LOG
152 #ifndef XC_ACE_DBG
153 #define XC_ACE_DBG
154 #endif
155 #endif
156 
157 //#define XC_ACE_DBG  0
158 #define XC_ACE_MUTEX_DBG 0
159 
160 #if (defined CONFIG_MLOG)
161 #define ACE_PRINTF(fmt,_args...) \
162         {\
163             ULOGD("ACE_DBG_MSG","[%s,%5d] ",__FUNCTION__,__LINE__);\
164             ULOGD("ACE_DBG_MSG",fmt,##_args);\
165         }
166 #else
167 #define ACE_PRINTF(fmt,...) \
168         {\
169             printf("[ACE_DBG_MSG]:"); \
170             printf("%s: %d \n"  fmt, __FUNCTION__, __LINE__, ## __VA_ARGS__);\
171         }
172 #endif
173 
174 #ifdef XC_ACE_DBG
175 #define XC_ACE_DBG_MSG(fmt,_args...) \
176     do{\
177         ACE_PRINTF(fmt,##_args);\
178     } while(0)
179 
180 #define XC_ACE_PRINT_VAR(var)  \
181     do{\
182         XC_ACE_DBG_MSG("%30s: %d\n", #var, (var));\
183         }while(0)
184 
185 #define XC_ACE_PRINT_FUN(fun)  \
186     do{\
187         XC_ACE_DBG_MSG("\n");\
188         XC_ACE_DBG_MSG("**************************************************\n");\
189         XC_ACE_DBG_MSG("*\t\t%s \t\t\n", #fun);\
190         XC_ACE_DBG_MSG("**************************************************\n");\
191         fun;\
192         XC_ACE_DBG_MSG("*                                                *\n");\
193         XC_ACE_DBG_MSG("*                                                *\n");\
194         XC_ACE_DBG_MSG("**************************************************\n");\
195         }while(0)
196 
197 #define ACE_DBG_MSG(fmt,_args...)                                                                 \
198     do{                                                                         \
199         if(_u16XC_ACEDbgSwitch){                                                             \
200            ACE_PRINTF(fmt,##_args); \
201           }                                                                                  \
202       } while(0)
203 
204 #else
205   #define XC_ACE_DBG_MSG(str, ...)
206   #define XC_ACE_PRINT_VAR(var)
207   #define XC_ACE_PRINT_FUN(fun) fun
208   #define ACE_DBG_MSG(fmt,...)
209 #endif
210 
211 #define MWE_TIMER           60
212 #define MWE_H_STEP          6
213 #define MWE_MOVE_RIGHT      1
214 #define MWE_MOVE_LEFT       0
215 
216 #if 0
217 static E_XC_ACE_MWE_FUNC  _MWEFunc = E_XC_ACE_MWE_MODE_OFF;
218 static MS_U32       _MWETimer = 0;
219 static MS_U32       _MWEFlag = MWE_MOVE_LEFT;
220 static MS_BOOL bMWEStatus = FALSE;
221 static MWE_RECT gMWERect;
222 
223 static XC_ACE_InitData g_XC_ACE_InitData;
224 static const XC_ACE_ApiInfo _stXC_ACE_ApiInfo = {};
225 #if XC_ACE_DBG
226 static MS_U16 _u16XC_ACEDbgSwitch = 0;
227 #endif
228 static MS_BOOL _bMWESkipDriverSetting = FALSE;
229 static E_XC_ACE_MWE_MIRROR_TYPE _enMirrorMode = E_XC_ACE_MWE_MIRROR_NORMAL;
230 #else
231 #define _MWEFunc psACEResPri->stapiACE._MWEFunc
232 #define _MWETimer psACEResPri->stapiACE._MWETimer
233 #define _MWEFlag psACEResPri->stapiACE._MWEFlag
234 //#define bMWEStatus psACEResPri->stapiACE.bMWEStatus
235 #define gMWERect psACEResPri->stapiACE.gMWERect
236 #define g_XC_ACE_InitData psACEResPri->stapiACE.g_XC_ACE_InitData
237 #define _bMWESkipDriverSetting psACEResPri->stapiACE._bMWESkipDriverSetting
238 #define _enMirrorMode psACEResPri->stapiACE._enMirrorMode
239 #define g_u8MotionStableCnt psACEResPri->stapiACE.g_u8MotionStableCnt
240 #define g_u8LumaStableCnt psACEResPri->stapiACE.g_u8LumaStableCnt
241 #define g_u8FlickStableCnt psACEResPri->stapiACE.g_u8FlickStableCnt
242 #define g_bACEModuleInited psACEResPri->stapiACE.g_bACEModuleInited
243 
244 static const XC_ACE_ApiInfo _stXC_ACE_ApiInfo = {};
245 #ifdef XC_ACE_DBG
246 static MS_U16 _u16XC_ACEDbgSwitch = 0;
247 #endif
248 
249 #endif
250 
251 // OS related
252 #define XC_ACE_WAIT_MUTEX              (TICK_PER_ONE_MS * 50)              // 50 ms
253 
254 // Mutex & Lock
255 static MS_S32 _s32XC_ACEMutex = -1;
256 
257 #if XC_ACE_MUTEX_DBG
258 #define XC_ACE_ENTRY()      if(!MsOS_ObtainMutex(_s32XC_ACEMutex, MSOS_WAIT_FOREVER))                     \
259                             {                                                                        \
260                                 printf("==========================\n");                              \
261                                 printf("[%s][%s][%06d] Mutex taking timeout\n",__FILE__,__FUNCTION__,__LINE__);    \
262                             }
263 #else
264 #define XC_ACE_ENTRY()      if(!MsOS_ObtainMutex(_s32XC_ACEMutex, MSOS_WAIT_FOREVER))                     \
265                             {                                                                        \
266                             }
267 #endif
268 
269 #define XC_ACE_RETURN()     MsOS_ReleaseMutex(_s32XC_ACEMutex);
270 
271 
272 static MSIF_Version _api_xc_ace_version = {
273     .DDI = { XC_ACE_API_VERSION },
274 };
275 
276 // for Utopia 2.0 to Utopia 1.0 compatibility.
277 
278 void* pu32ACEInst = NULL;
279 void* pu32ACERes[E_ACE_POOL_ID_MAX];
280 
281 void* pu32ACE_XCInst = NULL;
282 
MDrv_ACE_Get_Semaphore(void * pInstance)283 MS_U32 MDrv_ACE_Get_Semaphore(void *pInstance)
284 {
285     MS_U32 u32Return = UTOPIA_STATUS_FAIL;
286 
287     if (pInstance == NULL)
288     {
289         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
290         return u32Return;
291     }
292 
293     ACE_INSTANCE_PRIVATE *psACEInstPri = NULL;
294     UtopiaInstanceGetPrivate(pInstance, (void**)&psACEInstPri);
295 
296     if (psACEInstPri->u32DeviceID >= E_ACE_POOL_ID_MAX)
297     {
298         printf("[%s,%5d] Unknown ACE Pool ID\n",__func__, __LINE__);
299         return u32Return;
300     }
301 
302     void* pModule = NULL;
303     UtopiaInstanceGetModule(pInstance, &pModule);
304     if(UtopiaResourceObtain(pModule, psACEInstPri->u32DeviceID, &pu32ACERes[psACEInstPri->u32DeviceID]) != UTOPIA_STATUS_SUCCESS)
305     {
306         printf("UtopiaResourceObtain fail\n");
307         return UTOPIA_STATUS_ERR_RESOURCE;
308     }
309     u32Return = UTOPIA_STATUS_SUCCESS;
310     return u32Return;
311 }
312 
MDrv_ACE_Release_Semaphore(void * pInstance)313 MS_U32 MDrv_ACE_Release_Semaphore(void *pInstance)
314 {
315     MS_U32 u32Return = UTOPIA_STATUS_FAIL;
316 
317     ACE_INSTANCE_PRIVATE *psACEInstPri = NULL;
318     UtopiaInstanceGetPrivate(pInstance, (void**)&psACEInstPri);
319     if (psACEInstPri->u32DeviceID >= E_ACE_POOL_ID_MAX)
320     {
321         printf("[%s,%5d] Unknown ACE Pool ID\n",__func__, __LINE__);
322         return u32Return;
323     }
324 
325     u32Return = UtopiaResourceRelease(pu32ACERes[psACEInstPri->u32DeviceID]);
326     return u32Return;
327 }
328 
329 
330 //******************************************************************************
331 ///-initialize ACE
332 //*************************************************************************
333 
_MApi_XC_ACE_Init_WithoutCreateMutex(void * pInstance,XC_ACE_InitData * pstXC_ACE_InitData,MS_BOOL bSkipInitVar)334 static MS_BOOL _MApi_XC_ACE_Init_WithoutCreateMutex(void *pInstance, XC_ACE_InitData *pstXC_ACE_InitData, MS_BOOL bSkipInitVar)
335 {
336     MS_S16 s16HShiftStep = 0;
337     _ACE_GET_VARIABLE();
338 
339     if(pstXC_ACE_InitData->S16ColorCorrectionMatrix == NULL ||
340        pstXC_ACE_InitData->S16RGB == NULL)
341     {
342         return FALSE;
343     }
344     else
345     {
346         //STR case can not set var again
347         if(!bSkipInitVar)
348             MDrv_ACE_Init(pInstance, pstXC_ACE_InitData->eWindow, pstXC_ACE_InitData->S16ColorCorrectionMatrix, pstXC_ACE_InitData->S16RGB );
349     }
350     MDrv_ACE_SetColorCorrectionTable(pInstance,  pstXC_ACE_InitData->eWindow);
351     MDrv_ACE_SetPCsRGBTable(pInstance,  pstXC_ACE_InitData->eWindow);
352 
353     if(pstXC_ACE_InitData->bMWE_Enable)
354     {
355         XC_ACE_ENTRY();
356 
357         MDrv_XC_ACE_MWEinit(pInstance, pstXC_ACE_InitData->u16MWEHstart, pstXC_ACE_InitData->u16MWEVstart, pstXC_ACE_InitData->u16MWEWidth, pstXC_ACE_InitData->u16MWEHeight);
358 
359         gMWERect.Xpos = 0;
360         gMWERect.Ypos = 0;
361         //for fix H shift step when Display is 1/2.
362         s16HShiftStep = g_XC_ACE_InitData.u16MWE_Disp_Width - g_XC_ACE_InitData.u16MWEWidth;
363 
364         //w and h size
365         if(_enMirrorMode == E_XC_ACE_MWE_MIRROR_HV)
366         {
367             //for fix screen shift function in contrast expander function
368             if((abs(g_XC_ACE_InitData.u16MWE_Disp_Width - g_XC_ACE_InitData.u16MWEWidth)) <= 10)
369             {
370                 if (g_XC_ACE_InitData.u16MWE_Disp_Hstart == 0)
371                     gMWERect.Xsize = g_XC_ACE_InitData.u16MWEWidth/2;
372                 else
373                     gMWERect.Xsize = g_XC_ACE_InitData.u16MWEWidth/2 + s16HShiftStep;
374             }
375             else
376                 gMWERect.Xsize = g_XC_ACE_InitData.u16MWE_Disp_Width/2;
377         }
378         else
379         {
380             //for fix screen shift function in contrast expander function
381             if((abs(g_XC_ACE_InitData.u16MWE_Disp_Width - g_XC_ACE_InitData.u16MWEWidth)) <= 10)
382                 gMWERect.Xsize = g_XC_ACE_InitData.u16MWEWidth/2 + s16HShiftStep;
383             else
384                 gMWERect.Xsize = g_XC_ACE_InitData.u16MWE_Disp_Width/2;
385         }
386 
387         gMWERect.Ysize = g_XC_ACE_InitData.u16MWE_Disp_Height;
388 
389         //x and y start position
390         if(_enMirrorMode == E_XC_ACE_MWE_MIRROR_NORMAL || _enMirrorMode == E_XC_ACE_MWE_MIRROR_V_ONLY)
391         {
392             gMWERect.Ypos = g_XC_ACE_InitData.u16MWE_Disp_Vstart+g_XC_ACE_InitData.u16MWE_Disp_Height - gMWERect.Ysize;
393             //for patch 4:3 in contrast expander function
394             if (g_XC_ACE_InitData.u16MWEWidth > g_XC_ACE_InitData.u16MWE_Disp_Hstart)
395                 gMWERect.Xpos = g_XC_ACE_InitData.u16MWEWidth/2;
396             else
397                 gMWERect.Xpos = g_XC_ACE_InitData.u16MWE_Disp_Hstart + g_XC_ACE_InitData.u16MWEWidth/2;
398         }
399         else if(_enMirrorMode == E_XC_ACE_MWE_MIRROR_HV)
400         {
401 
402             if( g_XC_ACE_InitData.u16MWEWidth > ( g_XC_ACE_InitData.u16MWE_Disp_Hstart + g_XC_ACE_InitData.u16MWE_Disp_Width) )
403             {
404                 //for patch 4:3 in contrast expander function
405                 if (g_XC_ACE_InitData.u16MWEWidth > g_XC_ACE_InitData.u16MWE_Disp_Hstart)
406                     gMWERect.Xpos = g_XC_ACE_InitData.u16MWEWidth - ( gMWERect.Xpos + g_XC_ACE_InitData.u16MWE_Disp_Width ) - g_XC_ACE_InitData.u16MWE_Disp_Hstart;
407                 else
408                     gMWERect.Xpos = g_XC_ACE_InitData.u16MWEWidth - ( gMWERect.Xpos + g_XC_ACE_InitData.u16MWE_Disp_Width );
409             }
410             else
411             {
412                 gMWERect.Xpos = 0;
413             }
414 
415             if( g_XC_ACE_InitData.u16MWEHeight > ( g_XC_ACE_InitData.u16MWE_Disp_Vstart + g_XC_ACE_InitData.u16MWE_Disp_Height) )
416             {
417                 //for patch smart view in contrast expander function
418                 if ((g_XC_ACE_InitData.u16MWE_Disp_Vstart != 0) && (g_XC_ACE_InitData.u16MWE_Disp_Height != g_XC_ACE_InitData.u16MWEHeight))
419                     gMWERect.Ypos = g_XC_ACE_InitData.u16MWEHeight- ( gMWERect.Ypos + g_XC_ACE_InitData.u16MWE_Disp_Height ) - g_XC_ACE_InitData.u16MWE_Disp_Vstart;
420                 else
421                     gMWERect.Ypos = g_XC_ACE_InitData.u16MWEHeight - ( gMWERect.Ypos + g_XC_ACE_InitData.u16MWE_Disp_Height );
422             }
423             else
424             {
425                 gMWERect.Ypos = 0;
426             }
427         }
428         else
429         {
430             gMWERect.Xpos = g_XC_ACE_InitData.u16MWE_Disp_Hstart+g_XC_ACE_InitData.u16MWE_Disp_Width - gMWERect.Xsize;
431             gMWERect.Ypos = g_XC_ACE_InitData.u16MWE_Disp_Vstart+g_XC_ACE_InitData.u16MWE_Disp_Height - gMWERect.Ysize;
432         }
433 
434         MDrv_XC_ACE_MWESetWin(pInstance, &gMWERect);
435         MDrv_XC_ACE_MWESetBorder(pInstance, SUB_WINDOW, ENABLE, MWE_BORDER_COLOR_BLUE,
436                 0x02, 0x11, 0x11, 0x11);
437 
438         MDrv_XC_SetMWEStatus(pInstance, FALSE);
439         MDrv_XC_ACE_MWEEnable(pInstance, FALSE, _bMWESkipDriverSetting);
440 
441         XC_ACE_RETURN();
442     }
443 
444     return TRUE;
445 }
446 
MApi_XC_ACE_Init_U2(void * pInstance,XC_ACE_InitData * pstXC_ACE_InitData,MS_U32 u32InitDataLen)447 MS_BOOL MApi_XC_ACE_Init_U2(void *pInstance, XC_ACE_InitData *pstXC_ACE_InitData, MS_U32 u32InitDataLen)
448 {
449     MS_PHY u32NonPMBankSize;
450 	MS_VIRT ptrACERiuBaseAddr = 0;
451     char word[] = {"_ACE_Mutex"};
452     MS_BOOL bRet = TRUE;
453     //if(u32InitDataLen != sizeof(XC_ACE_InitData) || pstXC_ACE_InitData == NULL)
454     //{
455     //    return FALSE;
456     //}
457 
458 #if 0
459     if (_s32XC_ACEMutex != -1)
460     {
461         (printf("[MAPI ACE][%06d] Initialization more than once\n", __LINE__));
462         return FALSE;
463     }
464 
465     _s32XC_ACEMutex = MsOS_CreateMutex(E_MSOS_FIFO, word, MSOS_PROCESS_SHARED);
466     if (_s32XC_ACEMutex == -1)
467     {
468         //(printf("[MAPI ACE][%06d] create mutex fail\n", __LINE__));
469         return FALSE;
470     }
471 #else
472     if (_s32XC_ACEMutex == -1)
473     {
474         _s32XC_ACEMutex = MsOS_CreateMutex(E_MSOS_FIFO, word, MSOS_PROCESS_SHARED);
475         if (_s32XC_ACEMutex == -1)
476         {
477             (printf("[MAPI ACE][%06d] create mutex fail\n", __LINE__));
478             return FALSE;
479         }
480     }
481 #endif
482 
483     // get MMIO base
484     if(MDrv_MMIO_GetBASE( &ptrACERiuBaseAddr, &u32NonPMBankSize, MS_MODULE_PM ) != TRUE)
485     {
486         //OS_DELETE_MUTEX(_s32ACEMutex);
487         //PNL_ASSERT(0, "%s\n", "Get base address failed\n");
488         //(printf("XC_ACE GetBase failed\n"));
489         return FALSE;
490     }
491     else
492     {
493     }
494     MDrv_ACE_init_riu_base( ptrACERiuBaseAddr);
495 
496     _ACE_SEMAPHORE_ENTRY(pInstance);
497     _ACE_GET_VARIABLE();
498 
499     // MWE init start
500     memcpy(&g_XC_ACE_InitData, pstXC_ACE_InitData, u32InitDataLen);
501     _bMWESkipDriverSetting = FALSE;
502 
503     bRet = _MApi_XC_ACE_Init_WithoutCreateMutex(pInstance, &g_XC_ACE_InitData, FALSE);
504     g_bACEModuleInited[pstXC_ACE_InitData->eWindow] = TRUE;
505 
506     _ACE_SEMAPHORE_RETURN(pInstance);
507 
508     return bRet;
509 }
510 
MApi_XC_ACE_Init(XC_ACE_InitData * pstXC_ACE_InitData,MS_U32 u32InitDataLen)511 MS_BOOL MApi_XC_ACE_Init(XC_ACE_InitData *pstXC_ACE_InitData, MS_U32 u32InitDataLen)
512 {
513     if (pu32ACEInst == NULL)
514     {
515         if(UtopiaOpen(MODULE_ACE, &pu32ACEInst, 0, NULL) != UTOPIA_STATUS_SUCCESS)
516         {
517             printf("UtopiaOpen ACE failed\n");
518             return E_XC_ACE_FAIL;
519         }
520     }
521     if (pu32ACE_XCInst == NULL)
522     {
523         XC_INSTANT_ATTRIBUTE stXCInstantAttribute;
524         memset(&stXCInstantAttribute, 0, sizeof(stXCInstantAttribute));
525         stXCInstantAttribute.u32DeviceID = 0;
526         stXCInstantAttribute.eXCType     = E_XC_INSTANT_TYPE_ACE;
527         if(UtopiaOpen(MODULE_XC, &pu32ACE_XCInst, 0, &stXCInstantAttribute) != UTOPIA_STATUS_SUCCESS)
528         {
529             printf("UtopiaOpen pu32ACE_XCInst failed\n");
530             return E_XC_ACE_FAIL;
531         }
532     }
533 
534     stACE_Init ACEArgs;
535     ACEArgs.pstXC_ACE_InitData = pstXC_ACE_InitData;
536     ACEArgs.u32InitDataLen = u32InitDataLen;
537     ACEArgs.bReturn = FALSE;
538     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_INIT, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
539     {
540         printf("Obtain ACE engine fail\n");
541         return FALSE;
542     }
543     else
544     {
545         return ACEArgs.bReturn;
546     }
547 }
548 
MApi_XC_ACE_Exit_U2(void * pInstance)549 MS_BOOL MApi_XC_ACE_Exit_U2(void *pInstance)
550 {
551     _ACE_SEMAPHORE_ENTRY(pInstance);
552     _ACE_GET_VARIABLE();
553     memset(&g_XC_ACE_InitData, 0 , sizeof(XC_ACE_InitData) );
554     _bMWESkipDriverSetting = FALSE;
555     _ACE_SEMAPHORE_RETURN(pInstance);
556     //_s32XC_ACEMutex = -1;
557         MsOS_DeleteMutex(_s32XC_ACEMutex);
558         _s32XC_ACEMutex = -1;
559     return TRUE;
560 }
561 
MApi_XC_ACE_Exit(void)562 MS_BOOL MApi_XC_ACE_Exit(void)
563 {
564     if (pu32ACEInst == NULL)
565     {
566         printf("ACE not initialized!\n");
567         return FALSE;
568     }
569 
570     stACE_Exit ACEArgs;
571     ACEArgs.bReturn = FALSE;
572     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_EXIT, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
573     {
574         printf("Obtain ACE engine fail\n");
575         ACEArgs.bReturn = FALSE;
576     }
577 
578     if(UtopiaClose(pu32ACEInst) != UTOPIA_STATUS_SUCCESS)
579     {
580         printf("UtopiaClose ACE failed\n");
581         return FALSE;
582     }
583     pu32ACEInst = NULL;
584 
585     if(UtopiaClose(pu32ACE_XCInst) != UTOPIA_STATUS_SUCCESS)
586     {
587         printf("UtopiaClose ACE failed\n");
588         return FALSE;
589     }
590     pu32ACE_XCInst = NULL;
591 
592     return ACEArgs.bReturn;
593 }
594 
MApi_XC_ACE_DMS_U2(void * pInstance,MS_BOOL eWindow,MS_BOOL bisATV)595 void MApi_XC_ACE_DMS_U2(void *pInstance, MS_BOOL eWindow, MS_BOOL bisATV)
596 {
597     XC_ACE_ENTRY();
598     MDrv_ACE_DMS(pInstance, eWindow, bisATV);
599     XC_ACE_RETURN();
600 }
601 
MApi_XC_ACE_DMS(MS_BOOL eWindow,MS_BOOL bisATV)602 void MApi_XC_ACE_DMS(MS_BOOL eWindow, MS_BOOL bisATV)
603 {
604     if (pu32ACEInst == NULL)
605     {
606         printf("ACE not initialized!\n");
607         return;
608     }
609 
610     stACE_DMS ACEArgs;
611     ACEArgs.eWindow = eWindow;
612     ACEArgs.bisATV = bisATV;
613     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DMS, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
614     {
615         printf("Obtain ACE engine fail\n");
616     }
617     return;
618 }
619 
MApi_XC_ACE_SetPCYUV2RGB_U2(void * pInstance,MS_BOOL eWindow,MS_BOOL bEnable)620 void MApi_XC_ACE_SetPCYUV2RGB_U2(void *pInstance, MS_BOOL eWindow, MS_BOOL bEnable)
621 {
622 #ifdef MSOS_TYPE_LINUX_KERNEL
623     /*
624     ** Save setwindow info for str
625     */
626     void *pModule;
627     UtopiaInstanceGetModule(pInstance, &pModule);
628     ACE_REGS_SAVE_AREA *pACEResourceStr = NULL;
629     UtopiaModuleGetSTRPrivate(pModule, (void**)&pACEResourceStr);
630     pACEResourceStr->bSetPCYUV2RGB_Enable = bEnable;
631 #endif
632     _ACE_SEMAPHORE_ENTRY(pInstance);
633     XC_ACE_ENTRY();
634     MDrv_ACE_PCForceYUVtoRGB(pInstance, eWindow , bEnable);
635     XC_ACE_RETURN();
636     _ACE_SEMAPHORE_RETURN(pInstance);
637 }
638 
MApi_XC_ACE_SetPCYUV2RGB(MS_BOOL eWindow,MS_BOOL bEnable)639 void MApi_XC_ACE_SetPCYUV2RGB(MS_BOOL eWindow, MS_BOOL bEnable)
640 {
641     if (pu32ACEInst == NULL)
642     {
643         printf("ACE not initialized!\n");
644         return;
645     }
646 
647     stACE_SetPCYUV2RGB ACEArgs;
648     ACEArgs.eWindow = eWindow;
649     ACEArgs.bEnable = bEnable;
650     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETPCYUV2RGB, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
651     {
652         printf("Obtain ACE engine fail\n");
653     }
654     return;
655 }
656 
MApi_XC_ACE_SelectYUVtoRGBMatrix_U2(void * pInstance,MS_BOOL eWindow,MS_U8 ucMatrix,MS_S16 * psUserYUVtoRGBMatrix)657 void MApi_XC_ACE_SelectYUVtoRGBMatrix_U2(void *pInstance, MS_BOOL eWindow, MS_U8 ucMatrix, MS_S16* psUserYUVtoRGBMatrix)
658 {
659     _ACE_SEMAPHORE_ENTRY(pInstance);
660     XC_ACE_ENTRY();
661     MDrv_ACE_SelectYUVtoRGBMatrix(pInstance, eWindow, ucMatrix, psUserYUVtoRGBMatrix );
662     XC_ACE_RETURN();
663     _ACE_SEMAPHORE_RETURN(pInstance);
664 }
665 
MApi_XC_ACE_SelectYUVtoRGBMatrix(MS_BOOL eWindow,MS_U8 ucMatrix,MS_S16 * psUserYUVtoRGBMatrix)666 void MApi_XC_ACE_SelectYUVtoRGBMatrix(MS_BOOL eWindow, MS_U8 ucMatrix, MS_S16* psUserYUVtoRGBMatrix)
667 {
668     if (pu32ACEInst == NULL)
669     {
670         printf("ACE not initialized!\n");
671         return;
672     }
673 
674     stACE_SelectYUVtoRGBMatrix ACEArgs;
675     ACEArgs.eWindow = eWindow;
676     ACEArgs.ucMatrix = ucMatrix;
677     ACEArgs.psUserYUVtoRGBMatrix = psUserYUVtoRGBMatrix;
678     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SELECTYUVTORGBMATRIX, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
679     {
680         printf("Obtain ACE engine fail\n");
681     }
682     return;
683 }
684 
685 
MApi_XC_ACE_SetColorCorrectionTable_U2(void * pInstance,MS_BOOL bScalerWin)686 void MApi_XC_ACE_SetColorCorrectionTable_U2(void *pInstance, MS_BOOL bScalerWin)
687 {
688     _ACE_SEMAPHORE_ENTRY(pInstance);
689     XC_ACE_ENTRY();
690     MDrv_ACE_SetColorCorrectionTable(pInstance, bScalerWin );
691     XC_ACE_RETURN();
692     _ACE_SEMAPHORE_RETURN(pInstance);
693 }
694 
MApi_XC_ACE_SetColorCorrectionTable(MS_BOOL bScalerWin)695 void MApi_XC_ACE_SetColorCorrectionTable(MS_BOOL bScalerWin)
696 {
697     if (pu32ACEInst == NULL)
698     {
699         printf("ACE not initialized!\n");
700         return;
701     }
702 
703     stACE_SetColorCorrectionTable ACEArgs;
704     ACEArgs.bScalerWin = bScalerWin;
705     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETCOLORCORRECTIONTABLE, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
706     {
707         printf("Obtain ACE engine fail\n");
708     }
709     return;
710 }
711 
MApi_XC_ACE_SetPCsRGBTable_U2(void * pInstance,MS_BOOL bScalerWin)712 void MApi_XC_ACE_SetPCsRGBTable_U2(void *pInstance, MS_BOOL bScalerWin)
713 {
714     MS_BOOL bSettingByCFD = FALSE;
715 #if defined(UFO_XC_HDR) && defined(UFO_XC_HDR_VERSION) && (UFO_XC_HDR_VERSION == 2) && !defined(ACE_NOT_IN_KERNEL)
716     XC_HDR_SUPPORTED_CAPS stHdrSupportedCaps;
717     stHdrSupportedCaps.enHDRType = E_XC_HDR_TYPE_DOLBY;
718     stHdrSupportedCaps.bSupported = FALSE;
719     MApi_XC_GetChipCaps(E_XC_SUPPORT_HDR, (MS_U32*)&stHdrSupportedCaps, sizeof(XC_HDR_SUPPORTED_CAPS));
720     bSettingByCFD = stHdrSupportedCaps.bSupported;
721 
722     stHdrSupportedCaps.enHDRType = E_XC_HDR_TYPE_OPEN;
723     stHdrSupportedCaps.bSupported = FALSE;
724     MApi_XC_GetChipCaps(E_XC_SUPPORT_HDR, (MS_U32*)&stHdrSupportedCaps, sizeof(XC_HDR_SUPPORTED_CAPS));
725     bSettingByCFD |= stHdrSupportedCaps.bSupported;
726 
727 #endif
728 
729     if (bSettingByCFD == FALSE)
730     {
731         _ACE_SEMAPHORE_ENTRY(pInstance);
732         XC_ACE_ENTRY();
733         MDrv_ACE_SetPCsRGBTable(pInstance, bScalerWin);
734         XC_ACE_RETURN();
735         _ACE_SEMAPHORE_RETURN(pInstance);
736     }
737 }
738 
MApi_XC_ACE_SetPCsRGBTable(MS_BOOL bScalerWin)739 void MApi_XC_ACE_SetPCsRGBTable(MS_BOOL bScalerWin)
740 {
741     if (pu32ACEInst == NULL)
742     {
743         printf("ACE not initialized!\n");
744         return;
745     }
746 
747     stACE_SetPCsRGBTable ACEArgs;
748     ACEArgs.bScalerWin = bScalerWin;
749     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETPCSRGBTABLE, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
750     {
751         printf("Obtain ACE engine fail\n");
752     }
753     return;
754 }
755 
MApi_XC_ACE_GetColorMatrix_U2(void * pInstance,MS_BOOL eWindow,MS_U16 * pu16Matrix)756 void MApi_XC_ACE_GetColorMatrix_U2(void *pInstance, MS_BOOL eWindow, MS_U16* pu16Matrix)
757 {
758     XC_ACE_ENTRY();
759     MDrv_ACE_GetColorMatrix(pInstance, eWindow, pu16Matrix);
760     XC_ACE_RETURN();
761 }
762 
MApi_XC_ACE_GetColorMatrix(MS_BOOL eWindow,MS_U16 * pu16Matrix)763 void MApi_XC_ACE_GetColorMatrix(MS_BOOL eWindow, MS_U16* pu16Matrix)
764 {
765     if (pu32ACEInst == NULL)
766     {
767         printf("ACE not initialized!\n");
768         return;
769     }
770 
771     stACE_ColorMatrix ACEArgs;
772     ACEArgs.eWindow = eWindow;
773     ACEArgs.pu16Matrix = pu16Matrix;
774     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_GETCOLORMATRIX, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
775     {
776         printf("Obtain ACE engine fail\n");
777     }
778     return;
779 }
780 
MApi_XC_ACE_SetColorMatrix_U2(void * pInstance,MS_BOOL eWindow,MS_U16 * pu16Matrix)781 void MApi_XC_ACE_SetColorMatrix_U2(void *pInstance, MS_BOOL eWindow, MS_U16* pu16Matrix)
782 {
783     XC_ACE_ENTRY();
784     MDrv_ACE_SetColorMatrix(pInstance, eWindow, pu16Matrix);
785     XC_ACE_RETURN();
786 }
787 
MApi_XC_ACE_SetColorMatrix(MS_BOOL eWindow,MS_U16 * pu16Matrix)788 void MApi_XC_ACE_SetColorMatrix( MS_BOOL eWindow, MS_U16* pu16Matrix)
789 {
790     if (pu32ACEInst == NULL)
791     {
792         printf("ACE not initialized!\n");
793         return;
794     }
795 
796     stACE_ColorMatrix ACEArgs;
797     ACEArgs.eWindow = eWindow;
798     ACEArgs.pu16Matrix = pu16Matrix;
799     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETCOLORMATRIX, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
800     {
801         printf("Obtain ACE engine fail\n");
802     }
803     return;
804 }
805 
MApi_XC_ACE_SetBypassColorMatrix_U2(void * pInstance,MS_BOOL bEnable)806 E_XC_ACE_RESULT MApi_XC_ACE_SetBypassColorMatrix_U2(void *pInstance, MS_BOOL bEnable)
807 {
808     _ACE_SEMAPHORE_ENTRY(pInstance);
809     MDrv_ACE_SetBypassColorMatrix(pInstance, bEnable );
810     _ACE_SEMAPHORE_RETURN(pInstance);
811     return E_XC_ACE_OK;
812 }
813 
MApi_XC_ACE_SetBypassColorMatrix(MS_BOOL bEnable)814 E_XC_ACE_RESULT MApi_XC_ACE_SetBypassColorMatrix(MS_BOOL bEnable)
815 {
816     if (pu32ACEInst == NULL)
817     {
818         if(UtopiaOpen(MODULE_ACE, &pu32ACEInst, 0, NULL) != UTOPIA_STATUS_SUCCESS)
819         {
820             printf("UtopiaOpen ACE failed\n");
821             return E_XC_ACE_FAIL;
822         }
823     }
824 
825     stACE_SetBypassColorMatrix ACEArgs;
826     ACEArgs.bEnable = bEnable;
827     ACEArgs.eResult = E_XC_ACE_FAIL;
828     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETBYPASSCOLORMATRIX, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
829     {
830         printf("Obtain ACE engine fail\n");
831         return E_XC_ACE_FAIL;
832     }
833     else
834     {
835         return ACEArgs.eResult;
836     }
837 }
838 
MApi_XC_ACE_SetIHC_U2(void * pInstance,MS_BOOL bScalerWin,XC_ACE_IHC_COLOR_TYPE eIHC,MS_U8 u8Val)839 MS_BOOL MApi_XC_ACE_SetIHC_U2(void *pInstance, MS_BOOL bScalerWin, XC_ACE_IHC_COLOR_TYPE eIHC, MS_U8 u8Val)
840 {
841     MS_BOOL bRet = FALSE;
842     XC_ACE_ENTRY();
843     bRet = MDrv_ACE_SetIHC(pInstance, bScalerWin, eIHC, u8Val);
844     XC_ACE_RETURN();
845     return bRet;
846 }
847 
MApi_XC_ACE_SetIHC(MS_BOOL bScalerWin,XC_ACE_IHC_COLOR_TYPE eIHC,MS_U8 u8Val)848 MS_BOOL MApi_XC_ACE_SetIHC(MS_BOOL bScalerWin, XC_ACE_IHC_COLOR_TYPE eIHC, MS_U8 u8Val)
849 {
850     if (pu32ACEInst == NULL)
851     {
852         printf("ACE not initialized!\n");
853         return FALSE;
854     }
855 
856     stACE_SetIHC ACEArgs;
857     ACEArgs.bScalerWin = bScalerWin;
858     ACEArgs.eIHC = eIHC;
859     ACEArgs.u8Val = u8Val;
860     ACEArgs.bReturn = FALSE;
861     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETIHC, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
862     {
863         printf("Obtain ACE engine fail\n");
864         return FALSE;
865     }
866     else
867     {
868         return ACEArgs.bReturn;
869     }
870 }
871 
MApi_XC_ACE_SetICC_U2(void * pInstance,MS_BOOL bScalerWin,XC_ACE_ICC_COLOR_TYPE eICC,MS_U8 u8Val)872 MS_BOOL MApi_XC_ACE_SetICC_U2(void *pInstance, MS_BOOL bScalerWin, XC_ACE_ICC_COLOR_TYPE eICC, MS_U8 u8Val)
873 {
874     MS_BOOL bRet = FALSE;
875     XC_ACE_ENTRY();
876     bRet = MDrv_ACE_SetICC(pInstance, bScalerWin, eICC, u8Val);
877     XC_ACE_RETURN();
878     return bRet;
879 }
880 
MApi_XC_ACE_SetICC(MS_BOOL bScalerWin,XC_ACE_ICC_COLOR_TYPE eICC,MS_U8 u8Val)881 MS_BOOL SYMBOL_WEAK MApi_XC_ACE_SetICC(MS_BOOL bScalerWin, XC_ACE_ICC_COLOR_TYPE eICC, MS_U8 u8Val)
882 {
883     if (pu32ACEInst == NULL)
884     {
885         printf("ACE not initialized!\n");
886         return FALSE;
887     }
888 
889     stACE_SetICC ACEArgs;
890     ACEArgs.bScalerWin = bScalerWin;
891     ACEArgs.eICC = eICC;
892     ACEArgs.u8Val = u8Val;
893     ACEArgs.bReturn = FALSE;
894     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETICC, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
895     {
896         printf("Obtain ACE engine fail\n");
897         return FALSE;
898     }
899     else
900     {
901         return ACEArgs.bReturn;
902     }
903 }
904 
MApi_XC_ACE_SetIBC_U2(void * pInstance,MS_BOOL bScalerWin,XC_ACE_IBC_COLOR_TYPE eIBC,MS_U8 u8Val)905 MS_BOOL MApi_XC_ACE_SetIBC_U2(void *pInstance, MS_BOOL bScalerWin, XC_ACE_IBC_COLOR_TYPE eIBC, MS_U8 u8Val)
906 {
907     MS_BOOL bRet = FALSE;
908     XC_ACE_ENTRY();
909     bRet = MDrv_ACE_SetIBC(pInstance, bScalerWin, eIBC, u8Val);
910     XC_ACE_RETURN();
911     return bRet;
912 }
913 
MApi_XC_ACE_SetIBC(MS_BOOL bScalerWin,XC_ACE_IBC_COLOR_TYPE eIBC,MS_U8 u8Val)914 MS_BOOL SYMBOL_WEAK MApi_XC_ACE_SetIBC(MS_BOOL bScalerWin, XC_ACE_IBC_COLOR_TYPE eIBC, MS_U8 u8Val)
915 {
916     if (pu32ACEInst == NULL)
917     {
918         printf("ACE not initialized!\n");
919         return FALSE;
920     }
921 
922     stACE_SetIBC ACEArgs;
923     ACEArgs.bScalerWin = bScalerWin;
924     ACEArgs.eIBC = eIBC;
925     ACEArgs.u8Val = u8Val;
926     ACEArgs.bReturn = FALSE;
927     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETIBC, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
928     {
929         printf("Obtain ACE engine fail\n");
930         return FALSE;
931     }
932     else
933     {
934         return ACEArgs.bReturn;
935     }
936 }
937 
MApi_XC_ACE_PatchDTGColorChecker_U2(void * pInstance,MS_U8 u8Mode)938 void MApi_XC_ACE_PatchDTGColorChecker_U2(void *pInstance, MS_U8 u8Mode)
939 {
940     XC_ACE_ENTRY();
941     MDrv_ACE_PatchDTGColorChecker(pInstance, u8Mode);
942     XC_ACE_RETURN();
943 }
944 
MApi_XC_ACE_PatchDTGColorChecker(MS_U8 u8Mode)945 void MApi_XC_ACE_PatchDTGColorChecker(MS_U8 u8Mode)
946 {
947     if (pu32ACEInst == NULL)
948     {
949         printf("ACE not initialized!\n");
950         return;
951     }
952 
953     stACE_PatchDTGColorChecker ACEArgs;
954     ACEArgs.u8Mode = u8Mode;
955     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PATCHDTGCOLORCHECKER, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
956     {
957         printf("Obtain ACE engine fail\n");
958     }
959     return;
960 }
961 
MApi_XC_ACE_GetACEInfo_U2(void * pInstance,MS_BOOL bWindow,E_XC_ACE_INFOTYPE eXCACEInfoType)962 MS_U16 MApi_XC_ACE_GetACEInfo_U2(void *pInstance, MS_BOOL bWindow, E_XC_ACE_INFOTYPE eXCACEInfoType)
963 {
964     MS_U16 u16ACEinfo;
965     u16ACEinfo = eXCACEInfoType;
966     _ACE_SEMAPHORE_ENTRY(pInstance);
967     XC_ACE_ENTRY();
968     u16ACEinfo = MDrv_ACE_GetACEInfo(pInstance, bWindow, u16ACEinfo);
969     XC_ACE_RETURN();
970     _ACE_SEMAPHORE_RETURN(pInstance);
971 
972     return u16ACEinfo;
973 }
974 
MApi_XC_ACE_GetACEInfo(MS_BOOL bWindow,E_XC_ACE_INFOTYPE eXCACEInfoType)975 MS_U16 MApi_XC_ACE_GetACEInfo(MS_BOOL bWindow, E_XC_ACE_INFOTYPE eXCACEInfoType)
976 {
977     if (pu32ACEInst == NULL)
978     {
979         printf("ACE not initialized!\n");
980         return 0;
981     }
982 
983     stACE_GetACEInfo ACEArgs;
984     ACEArgs.bWindow = bWindow;
985     ACEArgs.eXCACEInfoType = eXCACEInfoType;
986     ACEArgs.u16Return = 0;
987     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_GETACEINFO, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
988     {
989         printf("Obtain ACE engine fail\n");
990         return 0;
991     }
992     else
993     {
994         return ACEArgs.u16Return;
995     }
996 }
997 
MApi_XC_ACE_GetACEInfoEx_U2(void * pInstance,MS_BOOL bWindow,XC_ACE_InfoEx * pInfoEx)998 void MApi_XC_ACE_GetACEInfoEx_U2(void *pInstance, MS_BOOL bWindow, XC_ACE_InfoEx *pInfoEx)
999 {
1000     memset(pInfoEx, 0, sizeof(XC_ACE_InfoEx));
1001 
1002     XC_ACE_ENTRY();
1003 
1004     if (MDrv_ACE_IsPostRGBGain(pInstance, bWindow))
1005     {
1006         pInfoEx->u32Mode |= ACE_INFOEX_MODE_POST_RGB_GAIN;
1007     }
1008 
1009     if (MDrv_ACE_IsPostRGBOffset(pInstance, bWindow))
1010     {
1011         pInfoEx->u32Mode |= ACE_INFOEX_MODE_POST_RGB_OFFSET;
1012     }
1013 
1014     XC_ACE_RETURN();
1015 }
1016 
MApi_XC_ACE_GetACEInfoEx(MS_BOOL bWindow,XC_ACE_InfoEx * pInfoEx)1017 void MApi_XC_ACE_GetACEInfoEx( MS_BOOL bWindow, XC_ACE_InfoEx *pInfoEx)
1018 {
1019     if (pu32ACEInst == NULL)
1020     {
1021         printf("ACE not initialized!\n");
1022         return;
1023     }
1024 
1025     stACE_GetACEInfoEx ACEArgs;
1026     ACEArgs.bWindow = bWindow;
1027     ACEArgs.pInfoEx = pInfoEx;
1028     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_GETACEINFOEX, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1029     {
1030         printf("Obtain ACE engine fail\n");
1031     }
1032     return;
1033 }
1034 
1035 /********************************************************************************/
1036 /*                   msAPI_ACE_Ext.c                   */
1037 /********************************************************************************/
1038 
1039 /********************************************************************************/
1040 /*                   Functions                      */
1041 /********************************************************************************/
1042 
1043 
1044 /******************************************************************************/
1045 ///-This function will set up brightness for YPbPr and digital port
1046 ///@param eWindow        \b IN: Window type
1047 ///@param u8Brightness_R \b IN: brightness R value
1048 ///@param u8Brightness_G \b IN: brightness G value
1049 ///@param u8Brightness_B \b IN: brightness B value
1050 /******************************************************************************/
MApi_XC_ACE_PicSetBrightness_U2(void * pInstance,MS_BOOL eWindow,MS_U8 u8Brightness_R,MS_U8 u8Brightness_G,MS_U8 u8Brightness_B)1051 void MApi_XC_ACE_PicSetBrightness_U2(void *pInstance, MS_BOOL eWindow, MS_U8 u8Brightness_R, MS_U8 u8Brightness_G, MS_U8 u8Brightness_B)
1052 {
1053 #ifdef MSOS_TYPE_LINUX_KERNEL
1054     void *pModule;
1055     UtopiaInstanceGetModule(pInstance, &pModule);
1056     ACE_REGS_SAVE_AREA *pACEResourceStr = NULL;
1057     UtopiaModuleGetSTRPrivate(pModule, (void**)&pACEResourceStr);
1058     pACEResourceStr->u8Brightness_R = u8Brightness_R;
1059     pACEResourceStr->u8Brightness_G = u8Brightness_G;
1060     pACEResourceStr->u8Brightness_B = u8Brightness_B;
1061 #endif
1062     _ACE_SEMAPHORE_ENTRY(pInstance);
1063     XC_ACE_ENTRY();
1064     MDrv_ACE_SetBrightness(pInstance, eWindow, u8Brightness_R, u8Brightness_G, u8Brightness_B);
1065     XC_ACE_RETURN();
1066     _ACE_SEMAPHORE_RETURN(pInstance);
1067 }
1068 
MApi_XC_ACE_PicSetBrightness(MS_BOOL eWindow,MS_U8 u8Brightness_R,MS_U8 u8Brightness_G,MS_U8 u8Brightness_B)1069 void MApi_XC_ACE_PicSetBrightness( MS_BOOL eWindow, MS_U8 u8Brightness_R, MS_U8 u8Brightness_G, MS_U8 u8Brightness_B)
1070 {
1071     if (pu32ACEInst == NULL)
1072     {
1073         printf("ACE not initialized!\n");
1074         return;
1075     }
1076 
1077     stACE_PicSetBrightness ACEArgs;
1078     ACEArgs.eWindow = eWindow;
1079     ACEArgs.u8Brightness_R = u8Brightness_R;
1080     ACEArgs.u8Brightness_G = u8Brightness_G;
1081     ACEArgs.u8Brightness_B = u8Brightness_B;
1082     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETBRIGHTNESS, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1083     {
1084         printf("Obtain ACE engine fail\n");
1085     }
1086     return;
1087 }
1088 
1089 /******************************************************************************/
1090 ///-This function will set up Precise brightness for YPbPr and digital port
1091 ///@param eWindow        \b IN: Window type
1092 ///@param u16Brightness_R \b IN: brightness R value
1093 ///@param u16Brightness_G \b IN: brightness G value
1094 ///@param u16Brightness_B \b IN: brightness B value
1095 /******************************************************************************/
MApi_XC_ACE_PicSetBrightnessPrecise_U2(void * pInstance,MS_BOOL eWindow,MS_U16 u16Brightness_R,MS_U16 u16Brightness_G,MS_U16 u16Brightness_B)1096 void MApi_XC_ACE_PicSetBrightnessPrecise_U2(void *pInstance, MS_BOOL eWindow, MS_U16 u16Brightness_R, MS_U16 u16Brightness_G, MS_U16 u16Brightness_B)
1097 {
1098     XC_ACE_ENTRY();
1099     MDrv_ACE_SetBrightnessPrecise(pInstance, eWindow, u16Brightness_R, u16Brightness_G, u16Brightness_B);
1100     XC_ACE_RETURN();
1101 }
1102 
MApi_XC_ACE_PicSetBrightnessPrecise(MS_BOOL eWindow,MS_U16 u16Brightness_R,MS_U16 u16Brightness_G,MS_U16 u16Brightness_B)1103 void MApi_XC_ACE_PicSetBrightnessPrecise(MS_BOOL eWindow, MS_U16 u16Brightness_R, MS_U16 u16Brightness_G, MS_U16 u16Brightness_B)
1104 {
1105     if (pu32ACEInst == NULL)
1106     {
1107         printf("ACE not initialized!\n");
1108         return;
1109     }
1110 
1111     stACE_PicSetBrightnessPrecise ACEArgs;
1112     ACEArgs.eWindow = eWindow;
1113     ACEArgs.u16Brightness_R = u16Brightness_R;
1114     ACEArgs.u16Brightness_G = u16Brightness_G;
1115     ACEArgs.u16Brightness_B = u16Brightness_B;
1116     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETBRIGHTNESSPRECISE, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1117     {
1118         printf("Obtain ACE engine fail\n");
1119     }
1120     return;
1121 }
1122 
1123 /******************************************************************************/
1124 ///-This function will set Pre Y Offset
1125 ///@param eWindow        \b IN: Window type
1126 ///@param u8PreYOffset \b IN: Pre Y Offset value
1127 /// @return @ref MS_BOOL
1128 /******************************************************************************/
MApi_XC_ACE_PicSetPreYOffset_U2(void * pInstance,MS_BOOL eWindow,MS_U8 u8PreYOffset)1129 MS_BOOL MApi_XC_ACE_PicSetPreYOffset_U2(void *pInstance, MS_BOOL eWindow, MS_U8 u8PreYOffset)
1130 {
1131     MS_BOOL bResult = FALSE;
1132     _ACE_SEMAPHORE_ENTRY(pInstance);
1133     XC_ACE_ENTRY();
1134     bResult = MDrv_ACE_SetPreYOffset(pInstance, eWindow, u8PreYOffset);
1135     XC_ACE_RETURN();
1136     _ACE_SEMAPHORE_RETURN(pInstance);
1137     return bResult;
1138 }
1139 
MApi_XC_ACE_PicSetPreYOffset(MS_BOOL eWindow,MS_U8 u8PreYOffset)1140 E_XC_ACE_RESULT MApi_XC_ACE_PicSetPreYOffset(MS_BOOL eWindow, MS_U8 u8PreYOffset)
1141 {
1142     if (pu32ACEInst == NULL)
1143     {
1144         printf("[%s]:ACE not initialized!\n", __FUNCTION__);
1145         return E_XC_ACE_FAIL;
1146     }
1147 
1148     stACE_PreYOffset stACEArgs;
1149     stACEArgs.eWindow = eWindow;
1150     stACEArgs.u8PreYOffset = u8PreYOffset;
1151     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSET_PRE_Y_OFFSET, (void*)&stACEArgs) != UTOPIA_STATUS_SUCCESS)
1152     {
1153         printf("Obtain ACE engine fail\n");
1154         return E_XC_ACE_OBTAIN_RESOURCE_FAIL;
1155     }
1156 
1157     return E_XC_ACE_OK;
1158 }
1159 
1160 /******************************************************************************/
1161 ///-This function will get Pre Y Offset
1162 ///@param eWindow        \b IN: Window type
1163 /// @return @ref MS_U8
1164 /******************************************************************************/
MApi_XC_ACE_PicGetPreYOffset_U2(void * pInstance,MS_BOOL eWindow)1165 MS_U8 MApi_XC_ACE_PicGetPreYOffset_U2(void *pInstance, MS_BOOL eWindow)
1166 {
1167     MS_U8 u8PreYOffset = 0;
1168     _ACE_SEMAPHORE_ENTRY(pInstance);
1169     XC_ACE_ENTRY();
1170     u8PreYOffset = MDrv_ACE_GetPreYOffset(pInstance, eWindow);
1171     XC_ACE_RETURN();
1172     _ACE_SEMAPHORE_RETURN(pInstance);
1173     return u8PreYOffset;
1174 }
1175 
MApi_XC_ACE_PicGetPreYOffset(MS_BOOL eWindow)1176 MS_U8 MApi_XC_ACE_PicGetPreYOffset(MS_BOOL eWindow)
1177 {
1178     if (pu32ACEInst == NULL)
1179     {
1180         printf("[%s]:ACE not initialized!\n", __FUNCTION__);
1181         return E_XC_ACE_FAIL;
1182     }
1183 
1184     stACE_PreYOffset stACEArgs;
1185     stACEArgs.eWindow = eWindow;
1186     stACEArgs.u8PreYOffset = 0;
1187     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICGET_PRE_Y_OFFSET, (void*)&stACEArgs) != UTOPIA_STATUS_SUCCESS)
1188     {
1189         printf("Obtain ACE engine fail\n");
1190         return E_XC_ACE_OBTAIN_RESOURCE_FAIL;
1191     }
1192 
1193     return stACEArgs.u8PreYOffset;
1194 
1195 }
1196 
1197 /******************************************************************************/
1198 //-Adjust sharpness
1199 ///@param eWindow        \b IN: Window type
1200 ///@param u8Sharpness    \b IN: sharpness value
1201 //- 0 -0x3f
1202 /******************************************************************************/
MApi_XC_ACE_PicSetSharpness_U2(void * pInstance,MS_BOOL eWindow,MS_U8 u8Sharpness)1203 void MApi_XC_ACE_PicSetSharpness_U2(void *pInstance, MS_BOOL eWindow, MS_U8 u8Sharpness )
1204 {
1205 #ifdef MSOS_TYPE_LINUX_KERNEL
1206     void *pModule;
1207     UtopiaInstanceGetModule(pInstance, &pModule);
1208     ACE_REGS_SAVE_AREA *pACEResourceStr = NULL;
1209     UtopiaModuleGetSTRPrivate(pModule, (void**)&pACEResourceStr);
1210     pACEResourceStr->u8Sharpness = u8Sharpness;
1211 #endif
1212     _ACE_SEMAPHORE_ENTRY(pInstance);
1213     XC_ACE_ENTRY();
1214     MDrv_ACE_SetSharpness(pInstance, eWindow, u8Sharpness);
1215     XC_ACE_RETURN();
1216     _ACE_SEMAPHORE_RETURN(pInstance);
1217 }
1218 
MApi_XC_ACE_PicSetSharpness(MS_BOOL eWindow,MS_U8 u8Sharpness)1219 void MApi_XC_ACE_PicSetSharpness( MS_BOOL eWindow, MS_U8 u8Sharpness )
1220 {
1221     if (pu32ACEInst == NULL)
1222     {
1223         printf("ACE not initialized!\n");
1224         return;
1225     }
1226 
1227     stACE_PicSetSharpness ACEArgs;
1228     ACEArgs.eWindow = eWindow;
1229     ACEArgs.u8Sharpness = u8Sharpness;
1230     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETSHARPNESS, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1231     {
1232         printf("Obtain ACE engine fail\n");
1233     }
1234     return;
1235 }
1236 
1237 /******************************************************************************/
1238 //-Adjust contrast for YPbPr and digital port
1239 //@param u8Contrast \b IN:
1240 //- video color Contrast setting 0 -0xff
1241 //@param u8SubContrast \b IN:
1242 //- video color SubContrast setting 0 -0xff
1243 /******************************************************************************/
1244 
MApi_XC_ACE_PicSetContrast_U2(void * pInstance,MS_BOOL eWindow,MS_BOOL bUseYUVSpace,MS_U8 u8Contrast)1245 void MApi_XC_ACE_PicSetContrast_U2(void *pInstance, MS_BOOL eWindow, MS_BOOL bUseYUVSpace, MS_U8 u8Contrast)
1246 {
1247     MS_BOOL bIgnoreColorSpace = FALSE;
1248 #if defined(UFO_XC_HDR) && defined(UFO_XC_HDR_VERSION) && (UFO_XC_HDR_VERSION == 2)
1249     XC_HDR_SUPPORTED_CAPS stHdrSupportedCaps;
1250     stHdrSupportedCaps.enHDRType = E_XC_HDR_TYPE_DOLBY;
1251     stHdrSupportedCaps.bSupported = FALSE;
1252     MApi_XC_GetChipCaps(E_XC_SUPPORT_HDR, (MS_U32*)&stHdrSupportedCaps, sizeof(XC_HDR_SUPPORTED_CAPS));
1253     bIgnoreColorSpace = stHdrSupportedCaps.bSupported;
1254 
1255     stHdrSupportedCaps.enHDRType = E_XC_HDR_TYPE_OPEN;
1256     stHdrSupportedCaps.bSupported = FALSE;
1257     MApi_XC_GetChipCaps(E_XC_SUPPORT_HDR, (MS_U32*)&stHdrSupportedCaps, sizeof(XC_HDR_SUPPORTED_CAPS));
1258     bIgnoreColorSpace |= stHdrSupportedCaps.bSupported;
1259 #endif
1260 
1261 #ifdef MSOS_TYPE_LINUX_KERNEL
1262     void *pModule;
1263     UtopiaInstanceGetModule(pInstance, &pModule);
1264     ACE_REGS_SAVE_AREA *pACEResourceStr = NULL;
1265     UtopiaModuleGetSTRPrivate(pModule, (void**)&pACEResourceStr);
1266     pACEResourceStr->bUseYUVSpace = bUseYUVSpace;
1267     pACEResourceStr->u8Contrast = u8Contrast;
1268 #endif
1269     if (bIgnoreColorSpace == TRUE)
1270     {
1271         _ACE_SEMAPHORE_ENTRY(pInstance);
1272         XC_ACE_ENTRY();
1273         MDrv_ACE_PicSetContrast(pInstance, eWindow, bUseYUVSpace, u8Contrast);
1274         XC_ACE_RETURN();
1275         _ACE_SEMAPHORE_RETURN(pInstance);
1276     }
1277     else
1278     {
1279         if (bUseYUVSpace)
1280         {
1281             _ACE_SEMAPHORE_ENTRY(pInstance);
1282             XC_ACE_ENTRY();
1283             MDrv_ACE_PicSetContrast(pInstance, eWindow, bUseYUVSpace, u8Contrast);
1284             XC_ACE_RETURN();
1285             _ACE_SEMAPHORE_RETURN(pInstance);
1286         }
1287         else
1288         {
1289             ;
1290         }
1291     }
1292 
1293 }
1294 
MApi_XC_ACE_PicSetContrast(MS_BOOL eWindow,MS_BOOL bUseYUVSpace,MS_U8 u8Contrast)1295 void MApi_XC_ACE_PicSetContrast( MS_BOOL eWindow, MS_BOOL bUseYUVSpace, MS_U8 u8Contrast)
1296 {
1297     if (pu32ACEInst == NULL)
1298     {
1299         printf("ACE not initialized!\n");
1300         return;
1301     }
1302 
1303     stACE_PicSetContrast ACEArgs;
1304     ACEArgs.eWindow = eWindow;
1305     ACEArgs.bUseYUVSpace = bUseYUVSpace;
1306     ACEArgs.u8Contrast = u8Contrast;
1307     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETCONTRAST, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1308     {
1309         printf("Obtain ACE engine fail\n");
1310     }
1311     return;
1312 }
1313 
1314 /******************************************************************************/
1315 ///-Adjust Hue for YPbPr and digital port
1316 ///@param eWindow \b IN: Enable Hue
1317 ///@param bUseYUVSpace \b IN: Is Yuv space
1318 ///@param u8Hue \b IN: Hue value
1319 /******************************************************************************/
MApi_XC_ACE_PicSetHue_U2(void * pInstance,MS_BOOL eWindow,MS_BOOL bUseYUVSpace,MS_U8 u8Hue)1320 void MApi_XC_ACE_PicSetHue_U2(void *pInstance, MS_BOOL eWindow, MS_BOOL bUseYUVSpace, MS_U8 u8Hue )
1321 {
1322 
1323     MS_BOOL bIgnoreColorSpace = FALSE;
1324 #if defined(UFO_XC_HDR) && defined(UFO_XC_HDR_VERSION) && (UFO_XC_HDR_VERSION == 2)
1325     XC_HDR_SUPPORTED_CAPS stHdrSupportedCaps;
1326     stHdrSupportedCaps.enHDRType = E_XC_HDR_TYPE_DOLBY;
1327     stHdrSupportedCaps.bSupported = FALSE;
1328     MApi_XC_GetChipCaps(E_XC_SUPPORT_HDR, (MS_U32*)&stHdrSupportedCaps, sizeof(XC_HDR_SUPPORTED_CAPS));
1329     bIgnoreColorSpace = stHdrSupportedCaps.bSupported;
1330 
1331     stHdrSupportedCaps.enHDRType = E_XC_HDR_TYPE_OPEN;
1332     stHdrSupportedCaps.bSupported = FALSE;
1333     MApi_XC_GetChipCaps(E_XC_SUPPORT_HDR, (MS_U32*)&stHdrSupportedCaps, sizeof(XC_HDR_SUPPORTED_CAPS));
1334     bIgnoreColorSpace |= stHdrSupportedCaps.bSupported;
1335 #endif
1336 
1337 #ifdef MSOS_TYPE_LINUX_KERNEL
1338     void *pModule;
1339     UtopiaInstanceGetModule(pInstance, &pModule);
1340     ACE_REGS_SAVE_AREA *pACEResourceStr = NULL;
1341     UtopiaModuleGetSTRPrivate(pModule, (void**)&pACEResourceStr);
1342     pACEResourceStr->bUseYUVSpace = bUseYUVSpace;
1343     pACEResourceStr->u8Hue = u8Hue;
1344 #endif
1345     if (bIgnoreColorSpace == TRUE)
1346     {
1347         _ACE_SEMAPHORE_ENTRY(pInstance);
1348         XC_ACE_ENTRY();
1349         MDrv_ACE_SetHue(pInstance, eWindow, u8Hue);
1350         XC_ACE_RETURN();
1351         _ACE_SEMAPHORE_RETURN(pInstance);
1352     }
1353     else
1354     {
1355         if(bUseYUVSpace)
1356         {
1357             _ACE_SEMAPHORE_ENTRY(pInstance);
1358             XC_ACE_ENTRY();
1359             MDrv_ACE_SetHue(pInstance, eWindow, u8Hue);
1360             XC_ACE_RETURN();
1361             _ACE_SEMAPHORE_RETURN(pInstance);
1362         }
1363         else
1364         {
1365             ;
1366         }
1367     }
1368 }
1369 
MApi_XC_ACE_PicSetHue(MS_BOOL eWindow,MS_BOOL bUseYUVSpace,MS_U8 u8Hue)1370 void MApi_XC_ACE_PicSetHue(MS_BOOL eWindow, MS_BOOL bUseYUVSpace, MS_U8 u8Hue)
1371 {
1372     if (pu32ACEInst == NULL)
1373     {
1374         printf("ACE not initialized!\n");
1375         return;
1376     }
1377 
1378     stACE_PicSetHue ACEArgs;
1379     ACEArgs.eWindow = eWindow;
1380     ACEArgs.bUseYUVSpace = bUseYUVSpace;
1381     ACEArgs.u8Hue = u8Hue;
1382     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETHUE, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1383     {
1384         printf("Obtain ACE engine fail\n");
1385     }
1386     return;
1387 }
1388 
1389 //-------------------------------------------------------------------------------------------------
1390 // Skip Wait Vsync
1391 /// @param eWindow               \b IN: Enable
1392 /// @param Skip wait Vsync      \b IN: Disable wait Vsync
1393 //-------------------------------------------------------------------------------------------------
MApi_XC_ACE_SkipWaitVsync_U2(void * pInstance,MS_BOOL eWindow,MS_BOOL bIsSkipWaitVsyn)1394 E_XC_ACE_RESULT MApi_XC_ACE_SkipWaitVsync_U2(void *pInstance, MS_BOOL eWindow, MS_BOOL bIsSkipWaitVsyn)
1395 {
1396     _ACE_SEMAPHORE_ENTRY(pInstance);
1397     MDrv_ACE_SetSkipWaitVsync(pInstance, eWindow, bIsSkipWaitVsyn);
1398     _ACE_SEMAPHORE_RETURN(pInstance);
1399     return E_XC_ACE_OK;
1400 }
1401 
MApi_XC_ACE_SkipWaitVsync(MS_BOOL eWindow,MS_BOOL bIsSkipWaitVsyn)1402 E_XC_ACE_RESULT MApi_XC_ACE_SkipWaitVsync( MS_BOOL eWindow, MS_BOOL bIsSkipWaitVsyn)
1403 {
1404     if (pu32ACEInst == NULL)
1405     {
1406         printf("ACE not initialized!\n");
1407         return E_XC_ACE_FAIL;
1408     }
1409 
1410     stACE_SkipWaitVsync ACEArgs;
1411     ACEArgs.eWindow = eWindow;
1412     ACEArgs.bIsSkipWaitVsyn = bIsSkipWaitVsyn;
1413     ACEArgs.eResult = E_XC_ACE_FAIL;
1414     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SKIPWAITVSYNC, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1415     {
1416         printf("Obtain ACE engine fail\n");
1417         return E_XC_ACE_FAIL;
1418     }
1419     else
1420     {
1421         return  ACEArgs.eResult;
1422     }
1423 }
1424 
1425 /******************************************************************************/
1426 //-Adjust Saturation for YPbPr and digital port
1427 //@param u8Saturation \b IN:
1428 //- video color setting 0 -100
1429 /******************************************************************************/
MApi_XC_ACE_PicSetSaturation_U2(void * pInstance,MS_BOOL eWindow,MS_BOOL bUseYUVSpace,MS_U8 u8Saturation)1430 void MApi_XC_ACE_PicSetSaturation_U2(void *pInstance, MS_BOOL eWindow, MS_BOOL bUseYUVSpace, MS_U8 u8Saturation)
1431 {
1432     MS_BOOL bIgnoreColorSpace = FALSE;
1433 #if defined(UFO_XC_HDR) && defined(UFO_XC_HDR_VERSION) && (UFO_XC_HDR_VERSION == 2)
1434     XC_HDR_SUPPORTED_CAPS stHdrSupportedCaps;
1435     stHdrSupportedCaps.enHDRType = E_XC_HDR_TYPE_DOLBY;
1436     stHdrSupportedCaps.bSupported = FALSE;
1437     MApi_XC_GetChipCaps(E_XC_SUPPORT_HDR, (MS_U32*)&stHdrSupportedCaps, sizeof(XC_HDR_SUPPORTED_CAPS));
1438     bIgnoreColorSpace = stHdrSupportedCaps.bSupported;
1439 
1440     stHdrSupportedCaps.enHDRType = E_XC_HDR_TYPE_OPEN;
1441     stHdrSupportedCaps.bSupported = FALSE;
1442     MApi_XC_GetChipCaps(E_XC_SUPPORT_HDR, (MS_U32*)&stHdrSupportedCaps, sizeof(XC_HDR_SUPPORTED_CAPS));
1443     bIgnoreColorSpace |= stHdrSupportedCaps.bSupported;
1444 #endif
1445 
1446 #ifdef MSOS_TYPE_LINUX_KERNEL
1447     void *pModule;
1448     UtopiaInstanceGetModule(pInstance, &pModule);
1449     ACE_REGS_SAVE_AREA *pACEResourceStr = NULL;
1450     UtopiaModuleGetSTRPrivate(pModule, (void**)&pACEResourceStr);
1451     pACEResourceStr->bUseYUVSpace = bUseYUVSpace;
1452     pACEResourceStr->u8Saturation = u8Saturation;
1453 #endif
1454 
1455     if (bIgnoreColorSpace == TRUE)
1456     {
1457         _ACE_SEMAPHORE_ENTRY(pInstance);
1458         XC_ACE_ENTRY();
1459         MDrv_ACE_SetSaturation(pInstance, eWindow, u8Saturation);
1460         XC_ACE_RETURN();
1461         _ACE_SEMAPHORE_RETURN(pInstance);
1462     }
1463     else
1464     {
1465         if(bUseYUVSpace)
1466         {
1467             _ACE_SEMAPHORE_ENTRY(pInstance);
1468             XC_ACE_ENTRY();
1469             MDrv_ACE_SetSaturation(pInstance, eWindow, u8Saturation);
1470             XC_ACE_RETURN();
1471             _ACE_SEMAPHORE_RETURN(pInstance);
1472         }
1473         else
1474         {
1475             ;
1476         }
1477     }
1478 
1479 }
1480 
MApi_XC_ACE_PicSetSaturation(MS_BOOL eWindow,MS_BOOL bUseYUVSpace,MS_U8 u8Saturation)1481 void MApi_XC_ACE_PicSetSaturation(MS_BOOL eWindow, MS_BOOL bUseYUVSpace, MS_U8 u8Saturation )
1482 {
1483     if (pu32ACEInst == NULL)
1484     {
1485         printf("ACE not initialized!\n");
1486         return;
1487     }
1488 
1489     stACE_PicSetSaturation ACEArgs;
1490     ACEArgs.eWindow = eWindow;
1491     ACEArgs.bUseYUVSpace = bUseYUVSpace;
1492     ACEArgs.u8Saturation = u8Saturation;
1493     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETSATURATION, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1494     {
1495         printf("Obtain ACE engine fail\n");
1496     }
1497     return;
1498 }
1499 
MApi_XC_ACE_SetFleshTone_U2(void * pInstance,MS_BOOL eWindow,MS_BOOL bEn,MS_U8 u8FleshTone)1500 void MApi_XC_ACE_SetFleshTone_U2(void *pInstance, MS_BOOL eWindow, MS_BOOL bEn, MS_U8 u8FleshTone)
1501 {
1502     XC_ACE_ENTRY();
1503     MDrv_ACE_SetFleshTone(pInstance, eWindow, bEn, u8FleshTone);
1504     XC_ACE_RETURN();
1505 }
1506 
MApi_XC_ACE_SetFleshTone(MS_BOOL eWindow,MS_BOOL bEn,MS_U8 u8FleshTone)1507 void MApi_XC_ACE_SetFleshTone(MS_BOOL eWindow, MS_BOOL bEn, MS_U8 u8FleshTone)
1508 {
1509     if (pu32ACEInst == NULL)
1510     {
1511         printf("ACE not initialized!\n");
1512         return;
1513     }
1514 
1515     stACE_SetFleshTone ACEArgs;
1516     ACEArgs.eWindow = eWindow;
1517     ACEArgs.bEn = bEn;
1518     ACEArgs.u8FleshTone = u8FleshTone;
1519     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETFLESHTONE, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1520     {
1521         printf("Obtain ACE engine fail\n");
1522     }
1523     return;
1524 }
1525 
MApi_XC_ACE_SetBlackAdjust_U2(void * pInstance,MS_BOOL eWindow,MS_U8 u8BlackAdjust)1526 void MApi_XC_ACE_SetBlackAdjust_U2(void *pInstance, MS_BOOL eWindow, MS_U8 u8BlackAdjust)
1527 {
1528     XC_ACE_ENTRY();
1529     MDrv_ACE_SetBlackAdjust(pInstance, eWindow, u8BlackAdjust);
1530     XC_ACE_RETURN();
1531 }
1532 
MApi_XC_ACE_SetBlackAdjust(MS_BOOL eWindow,MS_U8 u8BlackAdjust)1533 void MApi_XC_ACE_SetBlackAdjust(MS_BOOL eWindow, MS_U8 u8BlackAdjust)
1534 {
1535     if (pu32ACEInst == NULL)
1536     {
1537         printf("ACE not initialized!\n");
1538         return;
1539     }
1540 
1541     stACE_SetBlackAdjust ACEArgs;
1542     ACEArgs.eWindow = eWindow;
1543     ACEArgs.u8BlackAdjust = u8BlackAdjust;
1544     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETBLACKADJUST, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1545     {
1546         printf("Obtain ACE engine fail\n");
1547     }
1548     return;
1549 }
1550 
1551 //*************************************************************************
1552 ///-set video color
1553 ///@param eWindow \b IN: Enable Color temp
1554 ///@param bUseYUVSpace \b IN: Is in YUV space
1555 ///@param pstColorTemp \b IN: Color temp need to be set
1556 //*************************************************************************
MApi_XC_ACE_PicSetColorTemp_U2(void * pInstance,MS_BOOL eWindow,MS_BOOL bUseYUVSpace,XC_ACE_color_temp * pstColorTemp)1557 void MApi_XC_ACE_PicSetColorTemp_U2(void *pInstance, MS_BOOL eWindow, MS_BOOL bUseYUVSpace, XC_ACE_color_temp* pstColorTemp)
1558 {
1559     _ACE_SEMAPHORE_ENTRY(pInstance);
1560     XC_ACE_ENTRY();
1561     MDrv_ACE_PicSetRGB(pInstance, eWindow, bUseYUVSpace , pstColorTemp->cRedColor, pstColorTemp->cGreenColor, pstColorTemp->cBlueColor );
1562     XC_ACE_RETURN();
1563     _ACE_SEMAPHORE_RETURN(pInstance);
1564 }
1565 
MApi_XC_ACE_PicSetColorTemp(MS_BOOL eWindow,MS_BOOL bUseYUVSpace,XC_ACE_color_temp * pstColorTemp)1566 void MApi_XC_ACE_PicSetColorTemp(MS_BOOL eWindow, MS_BOOL bUseYUVSpace, XC_ACE_color_temp* pstColorTemp)
1567 {
1568     if (pu32ACEInst == NULL)
1569     {
1570         printf("ACE not initialized!\n");
1571         return;
1572     }
1573 
1574     stACE_PicSetColorTemp ACEArgs;
1575     ACEArgs.eWindow = eWindow;
1576     ACEArgs.bUseYUVSpace = bUseYUVSpace;
1577     ACEArgs.pstColorTemp = pstColorTemp;
1578     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETCOLORTEMP, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1579     {
1580         printf("Obtain ACE engine fail\n");
1581     }
1582     return;
1583 }
1584 
1585 //*************************************************************************
1586 ///-set video color ex
1587 ///@param eWindow \b IN: Enable Color temp
1588 ///@param bUseYUVSpace \b IN: Is in YUV space
1589 ///@param pstColorTemp \b IN: Color temp need to be set
1590 //*************************************************************************
MApi_XC_ACE_PicSetColorTempEx_U2(void * pInstance,MS_BOOL eWindow,MS_BOOL bUseYUVSpace,XC_ACE_color_temp_ex * pstColorTemp)1591 void MApi_XC_ACE_PicSetColorTempEx_U2(void *pInstance, MS_BOOL eWindow, MS_BOOL bUseYUVSpace, XC_ACE_color_temp_ex* pstColorTemp)
1592 {
1593     _ACE_SEMAPHORE_ENTRY(pInstance);
1594     XC_ACE_ENTRY();
1595     MDrv_ACE_PicSetRGB(pInstance, eWindow, bUseYUVSpace , pstColorTemp->cRedColor, pstColorTemp->cGreenColor, pstColorTemp->cBlueColor );
1596     XC_ACE_RETURN();
1597     _ACE_SEMAPHORE_RETURN(pInstance);
1598 }
1599 
MApi_XC_ACE_PicSetColorTempEx(MS_BOOL eWindow,MS_BOOL bUseYUVSpace,XC_ACE_color_temp_ex * pstColorTemp)1600 void MApi_XC_ACE_PicSetColorTempEx( MS_BOOL eWindow, MS_BOOL bUseYUVSpace, XC_ACE_color_temp_ex* pstColorTemp)
1601 {
1602     if (pu32ACEInst == NULL)
1603     {
1604         printf("ACE not initialized!\n");
1605         return;
1606     }
1607 
1608     stACE_PicSetColorTempEx ACEArgs;
1609     ACEArgs.eWindow = eWindow;
1610     ACEArgs.bUseYUVSpace = bUseYUVSpace;
1611     ACEArgs.pstColorTemp = pstColorTemp;
1612     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETCOLORTEMPEX, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1613     {
1614         printf("Obtain ACE engine fail\n");
1615     }
1616     return;
1617 }
1618 
1619 //*************************************************************************
1620 ///-set video color 10Bits step length
1621 ///@param eWindow \b IN: Enable Color temp
1622 ///@param bUseYUVSpace \b IN: Is in YUV space
1623 ///@param pstColorTemp \b IN: Color temp need to be set
1624 //*************************************************************************
MApi_XC_ACE_PicSetColorTemp_10Bits_U2(void * pInstance,MS_BOOL eWindow,MS_BOOL bUseYUVSpace,XC_ACE_color_temp_ex * pstColorTemp)1625 void MApi_XC_ACE_PicSetColorTemp_10Bits_U2(void *pInstance,MS_BOOL eWindow, MS_BOOL bUseYUVSpace, XC_ACE_color_temp_ex* pstColorTemp)
1626 {
1627     _ACE_SEMAPHORE_ENTRY(pInstance);
1628     XC_ACE_ENTRY();
1629     MDrv_ACE_PicSetRGB_10Bits(pInstance, eWindow, bUseYUVSpace , pstColorTemp->cRedColor, pstColorTemp->cGreenColor, pstColorTemp->cBlueColor );
1630     XC_ACE_RETURN();
1631     _ACE_SEMAPHORE_RETURN(pInstance);
1632 }
1633 
MApi_XC_ACE_PicSetColorTemp_10Bits(MS_BOOL eWindow,MS_BOOL bUseYUVSpace,XC_ACE_color_temp_ex * pstColorTemp)1634 void MApi_XC_ACE_PicSetColorTemp_10Bits( MS_BOOL eWindow, MS_BOOL bUseYUVSpace, XC_ACE_color_temp_ex* pstColorTemp)
1635 {
1636     if (pu32ACEInst == NULL)
1637     {
1638         printf("ACE not initialized!\n");
1639         return;
1640     }
1641 
1642     stACE_PicSetColorTempEx ACEArgs;
1643     ACEArgs.eWindow = eWindow;
1644     ACEArgs.bUseYUVSpace = bUseYUVSpace;
1645     ACEArgs.pstColorTemp = pstColorTemp;
1646     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETCOLORTEMP_10BITS, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1647     {
1648         printf("Obtain ACE engine fail\n");
1649     }
1650     return;
1651 }
1652 
1653 //*************************************************************************
1654 ///- set post color temp Version 2
1655 ///@param eWindow \b IN: Enable Color temp
1656 ///@param pstColorTemp \b IN: Color temp need to be set
1657 //*************************************************************************
MApi_XC_ACE_PicSetPostColorTemp_V02_U2(void * pInstance,MS_BOOL eWindow,XC_ACE_color_temp_ex2 * pstColorTemp)1658 void MApi_XC_ACE_PicSetPostColorTemp_V02_U2(void *pInstance, MS_BOOL eWindow, XC_ACE_color_temp_ex2* pstColorTemp)
1659 {
1660 #ifdef MSOS_TYPE_LINUX_KERNEL
1661     void *pModule;
1662     UtopiaInstanceGetModule(pInstance, &pModule);
1663     ACE_REGS_SAVE_AREA *pACEResourceStr = NULL;
1664     UtopiaModuleGetSTRPrivate(pModule, (void**)&pACEResourceStr);
1665     memcpy(&(pACEResourceStr->stColorTemp),pstColorTemp,sizeof(XC_ACE_color_temp_ex2));
1666 #endif
1667     _ACE_SEMAPHORE_ENTRY(pInstance);
1668     XC_ACE_ENTRY();
1669     MDrv_ACE_PicSetPostRGBGainOffset(pInstance, eWindow,
1670                                      pstColorTemp->cRedColor,  pstColorTemp->cGreenColor,  pstColorTemp->cBlueColor,
1671                                      pstColorTemp->cRedOffset, pstColorTemp->cGreenOffset, pstColorTemp->cBlueOffset, 0);
1672     XC_ACE_RETURN();
1673     _ACE_SEMAPHORE_RETURN(pInstance);
1674 }
1675 
MApi_XC_ACE_PicSetPostColorTemp_V02(MS_BOOL eWindow,XC_ACE_color_temp_ex2 * pstColorTemp)1676 void MApi_XC_ACE_PicSetPostColorTemp_V02(MS_BOOL eWindow, XC_ACE_color_temp_ex2* pstColorTemp)
1677 {
1678     if (pu32ACEInst == NULL)
1679     {
1680         printf("ACE not initialized!\n");
1681         return;
1682     }
1683 
1684     stACE_PicSetPostColorTemp_V02 ACEArgs;
1685     ACEArgs.eWindow = eWindow;
1686     ACEArgs.pstColorTemp = pstColorTemp;
1687     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETPOSTCOLORTEMP_V02, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1688     {
1689         printf("Obtain ACE engine fail\n");
1690     }
1691     return;
1692 }
1693 
1694 //*************************************************************************
1695 ///-obosolte!! use MApi_XC_ACE_PicSetPostColorTemp_V02 instead
1696 //*************************************************************************
MApi_XC_ACE_PicSetPostColorTemp_U2(void * pInstance,MS_BOOL eWindow,XC_ACE_color_temp * pstColorTemp)1697 void MApi_XC_ACE_PicSetPostColorTemp_U2(void *pInstance, MS_BOOL eWindow, XC_ACE_color_temp* pstColorTemp)
1698 {
1699     XC_ACE_color_temp_ex2 stColorTemp2;
1700     stColorTemp2.cRedOffset = pstColorTemp->cRedOffset<<3 ;
1701     stColorTemp2.cGreenOffset= pstColorTemp->cGreenOffset<<3;
1702     stColorTemp2.cBlueOffset= pstColorTemp->cBlueOffset<<3;
1703 
1704     stColorTemp2.cRedColor= pstColorTemp->cRedColor << 3;
1705     stColorTemp2.cGreenColor= pstColorTemp->cGreenColor << 3;
1706     stColorTemp2.cBlueColor= pstColorTemp->cBlueColor << 3;
1707 
1708     stColorTemp2.cRedScaleValue= pstColorTemp->cRedScaleValue;
1709     stColorTemp2.cGreenScaleValue= pstColorTemp->cGreenScaleValue;
1710     stColorTemp2.cBlueScaleValue= pstColorTemp->cBlueScaleValue;
1711 
1712     _ACE_SEMAPHORE_ENTRY(pInstance);
1713     XC_ACE_ENTRY();
1714     MDrv_ACE_PicSetPostRGBGain(pInstance, eWindow, stColorTemp2.cRedColor, stColorTemp2.cGreenColor, stColorTemp2.cBlueColor);
1715     MDrv_ACE_PicSetPostRGBOffset(pInstance, eWindow, stColorTemp2.cRedOffset, stColorTemp2.cGreenOffset, stColorTemp2.cBlueOffset, 0);
1716     XC_ACE_RETURN();
1717     _ACE_SEMAPHORE_RETURN(pInstance);
1718 }
1719 
MApi_XC_ACE_PicSetPostColorTemp(MS_BOOL eWindow,XC_ACE_color_temp * pstColorTemp)1720 void MApi_XC_ACE_PicSetPostColorTemp(MS_BOOL eWindow, XC_ACE_color_temp* pstColorTemp)
1721 {
1722     if (pu32ACEInst == NULL)
1723     {
1724         printf("ACE not initialized!\n");
1725         return;
1726     }
1727 
1728     stACE_PicSetPostColorTemp ACEArgs;
1729     ACEArgs.eWindow = eWindow;
1730     ACEArgs.pstColorTemp = pstColorTemp;
1731     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETPOSTCOLORTEMP, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1732     {
1733         printf("Obtain ACE engine fail\n");
1734     }
1735     return;
1736 }
1737 
1738 //*************************************************************************
1739 ///-obosolte!! use MApi_XC_ACE_PicSetPostColorTemp_V02 instead
1740 //*************************************************************************
MApi_XC_ACE_PicSetPostColorTempEx_U2(void * pInstance,MS_BOOL eWindow,XC_ACE_color_temp_ex * pstColorTemp)1741 void MApi_XC_ACE_PicSetPostColorTempEx_U2(void *pInstance, MS_BOOL eWindow, XC_ACE_color_temp_ex* pstColorTemp)
1742 {
1743     XC_ACE_color_temp_ex2 stColorTemp2;
1744     stColorTemp2.cRedOffset = pstColorTemp->cRedOffset ;
1745     stColorTemp2.cGreenOffset= pstColorTemp->cGreenOffset;
1746     stColorTemp2.cBlueOffset= pstColorTemp->cBlueOffset;
1747 
1748     stColorTemp2.cRedColor= pstColorTemp->cRedColor << 3 ;
1749     stColorTemp2.cGreenColor= pstColorTemp->cGreenColor << 3;
1750     stColorTemp2.cBlueColor= pstColorTemp->cBlueColor << 3;
1751 
1752     stColorTemp2.cRedScaleValue= pstColorTemp->cRedScaleValue;
1753     stColorTemp2.cGreenScaleValue= pstColorTemp->cGreenScaleValue;
1754     stColorTemp2.cBlueScaleValue= pstColorTemp->cBlueScaleValue;
1755 
1756     _ACE_SEMAPHORE_ENTRY(pInstance);
1757     XC_ACE_ENTRY();
1758     MDrv_ACE_PicSetPostRGBGain(pInstance, eWindow, stColorTemp2.cRedColor, stColorTemp2.cGreenColor, stColorTemp2.cBlueColor);
1759     MDrv_ACE_PicSetPostRGBOffset(pInstance, eWindow, stColorTemp2.cRedOffset, stColorTemp2.cGreenOffset, stColorTemp2.cBlueOffset, 0);
1760     XC_ACE_RETURN();
1761     _ACE_SEMAPHORE_RETURN(pInstance);
1762 }
1763 
MApi_XC_ACE_PicSetPostColorTempEx(MS_BOOL eWindow,XC_ACE_color_temp_ex * pstColorTemp)1764 void MApi_XC_ACE_PicSetPostColorTempEx(MS_BOOL eWindow, XC_ACE_color_temp_ex* pstColorTemp)
1765 {
1766     if (pu32ACEInst == NULL)
1767     {
1768         printf("ACE not initialized!\n");
1769         return;
1770     }
1771 
1772     stACE_PicSetPostColorTempEx ACEArgs;
1773     ACEArgs.eWindow = eWindow;
1774     ACEArgs.pstColorTemp = pstColorTemp;
1775     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETPOSTCOLORTEMPEX, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1776     {
1777         printf("Obtain ACE engine fail\n");
1778     }
1779     return;
1780 }
1781 
1782 //*************************************************************************
1783 ///-set video color
1784 ///@param eWindow \b IN: Enable Color temp
1785 ///@param bUseYUVSpace \b IN: Is in YUV space
1786 ///@param pstColorTemp \b IN: Color temp need to be set
1787 //*************************************************************************
MApi_XC_ACE_PicSetPostColorTemp2_U2(void * pInstance,MS_BOOL eWindow,MS_BOOL bUseYUVSpace,XC_ACE_color_temp * pstColorTemp)1788 void MApi_XC_ACE_PicSetPostColorTemp2_U2(void *pInstance, MS_BOOL eWindow, MS_BOOL bUseYUVSpace, XC_ACE_color_temp* pstColorTemp)
1789 {
1790     XC_ACE_color_temp_ex2 stColorTemp2;
1791 
1792     // error handle & data prepare
1793     if(pstColorTemp == NULL)
1794         return;
1795 
1796     stColorTemp2.cRedOffset = pstColorTemp->cRedOffset<<3 ;
1797     stColorTemp2.cGreenOffset= pstColorTemp->cGreenOffset<<3;
1798     stColorTemp2.cBlueOffset= pstColorTemp->cBlueOffset<<3;
1799 
1800     stColorTemp2.cRedColor= pstColorTemp->cRedColor << 3;
1801     stColorTemp2.cGreenColor= pstColorTemp->cGreenColor << 3;
1802     stColorTemp2.cBlueColor= pstColorTemp->cBlueColor << 3;
1803 
1804     stColorTemp2.cRedScaleValue= pstColorTemp->cRedScaleValue;
1805     stColorTemp2.cGreenScaleValue= pstColorTemp->cGreenScaleValue;
1806     stColorTemp2.cBlueScaleValue= pstColorTemp->cBlueScaleValue;
1807 
1808     _ACE_SEMAPHORE_ENTRY(pInstance);
1809 
1810     XC_ACE_ENTRY();
1811     // bypass ACE color setting
1812     MDrv_ACE_PicSetRGB(pInstance, eWindow, bUseYUVSpace , XC_ACE_BYPASS_COLOR_GAIN, XC_ACE_BYPASS_COLOR_GAIN, XC_ACE_BYPASS_COLOR_GAIN );
1813 
1814     // use HW color gain setting
1815     MDrv_ACE_PicSetPostRGBGain(pInstance, eWindow, stColorTemp2.cRedColor, stColorTemp2.cGreenColor, stColorTemp2.cBlueColor);
1816     MDrv_ACE_PicSetPostRGBOffset(pInstance, eWindow, stColorTemp2.cRedOffset, stColorTemp2.cGreenOffset, stColorTemp2.cBlueOffset, 0);
1817     XC_ACE_RETURN();
1818     _ACE_SEMAPHORE_RETURN(pInstance);
1819 }
1820 
MApi_XC_ACE_PicSetPostColorTemp2(MS_BOOL eWindow,MS_BOOL bUseYUVSpace,XC_ACE_color_temp * pstColorTemp)1821 void MApi_XC_ACE_PicSetPostColorTemp2(MS_BOOL eWindow, MS_BOOL bUseYUVSpace, XC_ACE_color_temp* pstColorTemp)
1822 {
1823     if (pu32ACEInst == NULL)
1824     {
1825         printf("ACE not initialized!\n");
1826         return;
1827     }
1828 
1829     stACE_PicSetPostColorTemp ACEArgs;
1830     ACEArgs.eWindow = eWindow;
1831     ACEArgs.pstColorTemp = pstColorTemp;
1832     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETPOSTCOLORTEMP2, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1833     {
1834         printf("Obtain ACE engine fail\n");
1835     }
1836     return;
1837 }
1838 
1839 //*************************************************************************
1840 ///-set video color ex
1841 ///@param eWindow \b IN: Enable Color temp
1842 ///@param bUseYUVSpace \b IN: Is in YUV space
1843 ///@param pstColorTemp \b IN: Color temp need to be set
1844 //*************************************************************************
MApi_XC_ACE_PicSetPostColorTemp2Ex_U2(void * pInstance,MS_BOOL eWindow,MS_BOOL bUseYUVSpace,XC_ACE_color_temp_ex * pstColorTemp)1845 void MApi_XC_ACE_PicSetPostColorTemp2Ex_U2(void *pInstance, MS_BOOL eWindow, MS_BOOL bUseYUVSpace, XC_ACE_color_temp_ex* pstColorTemp)
1846 {
1847     XC_ACE_color_temp_ex2 stColorTemp2;
1848 
1849     // error handle & data prepare
1850     if(pstColorTemp == NULL)
1851         return;
1852 
1853     stColorTemp2.cRedOffset = pstColorTemp->cRedOffset ;
1854     stColorTemp2.cGreenOffset= pstColorTemp->cGreenOffset;
1855     stColorTemp2.cBlueOffset= pstColorTemp->cBlueOffset;
1856 
1857     stColorTemp2.cRedColor= pstColorTemp->cRedColor << 3 ;
1858     stColorTemp2.cGreenColor= pstColorTemp->cGreenColor << 3;
1859     stColorTemp2.cBlueColor= pstColorTemp->cBlueColor << 3;
1860 
1861     stColorTemp2.cRedScaleValue= pstColorTemp->cRedScaleValue;
1862     stColorTemp2.cGreenScaleValue= pstColorTemp->cGreenScaleValue;
1863     stColorTemp2.cBlueScaleValue= pstColorTemp->cBlueScaleValue;
1864 
1865     _ACE_SEMAPHORE_ENTRY(pInstance);
1866     XC_ACE_ENTRY();
1867     // bypass ACE color setting
1868     MDrv_ACE_PicSetRGB(pInstance, eWindow, bUseYUVSpace , XC_ACE_BYPASS_COLOR_GAIN, XC_ACE_BYPASS_COLOR_GAIN, XC_ACE_BYPASS_COLOR_GAIN );
1869 
1870     // use HW color gain setting
1871     MDrv_ACE_PicSetPostRGBGain(pInstance, eWindow, stColorTemp2.cRedColor, stColorTemp2.cGreenColor, stColorTemp2.cBlueColor);
1872     MDrv_ACE_PicSetPostRGBOffset(pInstance, eWindow, stColorTemp2.cRedOffset, stColorTemp2.cGreenOffset, stColorTemp2.cBlueOffset, 0);
1873     XC_ACE_RETURN();
1874     _ACE_SEMAPHORE_RETURN(pInstance);
1875 }
1876 
MApi_XC_ACE_PicSetPostColorTemp2Ex(MS_BOOL eWindow,MS_BOOL bUseYUVSpace,XC_ACE_color_temp_ex * pstColorTemp)1877 void MApi_XC_ACE_PicSetPostColorTemp2Ex(MS_BOOL eWindow, MS_BOOL bUseYUVSpace, XC_ACE_color_temp_ex* pstColorTemp)
1878 {
1879     if (pu32ACEInst == NULL)
1880     {
1881         printf("ACE not initialized!\n");
1882         return;
1883     }
1884 
1885     stACE_PicSetPostColorTempEx ACEArgs;
1886     ACEArgs.eWindow = eWindow;
1887     ACEArgs.bUseYUVSpace = bUseYUVSpace;
1888     ACEArgs.pstColorTemp = pstColorTemp;
1889     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_PICSETPOSTCOLORTEMP2EX, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1890     {
1891         printf("Obtain ACE engine fail\n");
1892     }
1893     return;
1894 }
1895 
1896 /******************************************************************************/
1897 /*                     Local                                                  */
1898 /* ****************************************************************************/
1899 
MApi_XC_ACE_GetLibVer_U2(void * pInstance,const MSIF_Version ** ppVersion)1900 E_XC_ACE_RESULT MApi_XC_ACE_GetLibVer_U2(void *pInstance, const MSIF_Version **ppVersion)              // Get version
1901 {
1902     if (!ppVersion)
1903     {
1904         return E_XC_ACE_FAIL;
1905     }
1906 
1907     *ppVersion = &_api_xc_ace_version;
1908     return E_XC_ACE_OK;
1909 }
1910 
MApi_XC_ACE_GetLibVer(const MSIF_Version ** ppVersion)1911 E_XC_ACE_RESULT MApi_XC_ACE_GetLibVer(const MSIF_Version **ppVersion)              // Get version
1912 {
1913     if (pu32ACEInst == NULL)
1914     {
1915         printf("ACE not initialized!\n");
1916         return E_XC_ACE_FAIL;
1917     }
1918 
1919     stACE_GetLibVer ACEArgs;
1920     ACEArgs.ppVersion = ppVersion;
1921     ACEArgs.eResult = E_XC_ACE_FAIL;
1922     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_GETLIBVER, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1923     {
1924         printf("Obtain ACE engine fail\n");
1925         return E_XC_ACE_FAIL;
1926     }
1927     else
1928     {
1929         return  ACEArgs.eResult;
1930     }
1931 }
1932 
MApi_XC_ACE_GetInfo_U2(void * pInstance)1933 const XC_ACE_ApiInfo * MApi_XC_ACE_GetInfo_U2(void *pInstance)          // Get info from driver
1934 {
1935     return &_stXC_ACE_ApiInfo;
1936 }
1937 
MApi_XC_ACE_GetInfo(void)1938 const XC_ACE_ApiInfo * MApi_XC_ACE_GetInfo(void)          // Get info from driver
1939 {
1940     if (pu32ACEInst == NULL)
1941     {
1942         printf("ACE not initialized!\n");
1943         return NULL;
1944     }
1945 
1946     stACE_GetInfo ACEArgs;
1947     ACEArgs.pstApiInfo = NULL;
1948     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_GETINFO, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1949     {
1950         printf("Obtain ACE engine fail\n");
1951         return NULL;
1952     }
1953     else
1954     {
1955         return ACEArgs.pstApiInfo;
1956     }
1957 }
1958 
MApi_XC_ACE_GetStatus_U2(void * pInstance,XC_ACE_ApiStatus * pDrvStatus,MS_BOOL bWindow)1959 MS_BOOL MApi_XC_ACE_GetStatus_U2(void *pInstance, XC_ACE_ApiStatus *pDrvStatus, MS_BOOL bWindow)    // Get DLC current status
1960 {
1961     if(bWindow == 0)
1962     {
1963         _ACE_SEMAPHORE_ENTRY(pInstance);
1964         _ACE_GET_VARIABLE();
1965         pDrvStatus->ACEinit = g_XC_ACE_InitData;
1966         _ACE_SEMAPHORE_RETURN(pInstance);
1967     }
1968     return TRUE;
1969 }
1970 
MApi_XC_ACE_GetStatus(XC_ACE_ApiStatus * pDrvStatus,MS_BOOL bWindow)1971 MS_BOOL MApi_XC_ACE_GetStatus(XC_ACE_ApiStatus *pDrvStatus, MS_BOOL bWindow)    // Get DLC current status
1972 {
1973     if (pu32ACEInst == NULL)
1974     {
1975         printf("ACE not initialized!\n");
1976         return FALSE;
1977     }
1978 
1979     stACE_GetStatus ACEArgs;
1980     ACEArgs.pDrvStatus = pDrvStatus;
1981     ACEArgs.bWindow = bWindow;
1982     ACEArgs.bReturn = FALSE;
1983     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_GETSTATUS, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
1984     {
1985         printf("Obtain ACE engine fail\n");
1986         return FALSE;
1987     }
1988     else
1989     {
1990         return ACEArgs.bReturn;
1991     }
1992 }
1993 
MApi_XC_ACE_SetDbgLevel_U2(void * pInstance,MS_U16 u16DbgSwitch)1994 MS_BOOL MApi_XC_ACE_SetDbgLevel_U2(void *pInstance, MS_U16 u16DbgSwitch)
1995 {
1996 #ifdef XC_ACE_DBG
1997     _u16XC_ACEDbgSwitch = u16DbgSwitch;
1998 #endif
1999     return TRUE;
2000 }
2001 
MApi_XC_ACE_SetDbgLevel(MS_U16 u16DbgSwitch)2002 MS_BOOL MApi_XC_ACE_SetDbgLevel(MS_U16 u16DbgSwitch)
2003 {
2004     if (pu32ACEInst == NULL)
2005     {
2006         if(UtopiaOpen(MODULE_ACE, &pu32ACEInst, 0, NULL) != UTOPIA_STATUS_SUCCESS)
2007         {
2008             printf("ACE not initialized!\n");
2009             return FALSE;
2010         }
2011     }
2012     stACE_SetDbgLevel ACEArgs;
2013     ACEArgs.u16DbgSwitch = u16DbgSwitch;
2014     ACEArgs.bReturn = FALSE;
2015     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETDBGLEVEL, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2016     {
2017         printf("Obtain ACE engine fail\n");
2018         return FALSE;
2019     }
2020     else
2021     {
2022         return ACEArgs.bReturn;
2023     }
2024 }
2025 
2026 /******************************************************************************/
2027 /*                   Functions                                                */
2028 /******************************************************************************/
2029 
MApi_XC_ACE_EnableMWE_U2(void * pInstance,MS_BOOL bEnable)2030 void MApi_XC_ACE_EnableMWE_U2(void *pInstance, MS_BOOL bEnable)
2031 {
2032     _ACE_SEMAPHORE_ENTRY(pInstance);
2033     _ACE_GET_VARIABLE();
2034     MDrv_XC_SetMWEStatus(pInstance, bEnable);
2035     XC_ACE_ENTRY();
2036     MDrv_XC_ACE_MWEEnable(pInstance, bEnable, _bMWESkipDriverSetting);
2037     XC_ACE_RETURN();
2038     _ACE_SEMAPHORE_RETURN(pInstance);
2039 }
2040 
MApi_XC_ACE_EnableMWE(MS_BOOL bEnable)2041 void MApi_XC_ACE_EnableMWE(MS_BOOL bEnable)
2042 {
2043     if (pu32ACEInst == NULL)
2044     {
2045         printf("ACE not initialized!\n");
2046         return;
2047     }
2048 
2049     stACE_EnableMWE ACEArgs;
2050     ACEArgs.bEnable = bEnable;
2051     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_ENABLEMWE, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2052     {
2053         printf("Obtain ACE engine fail\n");
2054     }
2055     return;
2056 }
2057 
MApi_XC_ACE_MWESetMirrorMode_U2(void * pInstance,E_XC_ACE_MWE_MIRROR_TYPE eMirrorMode)2058 void MApi_XC_ACE_MWESetMirrorMode_U2(void *pInstance, E_XC_ACE_MWE_MIRROR_TYPE eMirrorMode)
2059 {
2060     _ACE_SEMAPHORE_ENTRY(pInstance);
2061     _ACE_GET_VARIABLE();
2062     _enMirrorMode = eMirrorMode;
2063     _ACE_SEMAPHORE_RETURN(pInstance);
2064 
2065 }
2066 
MApi_XC_ACE_MWESetMirrorMode(E_XC_ACE_MWE_MIRROR_TYPE eMirrorMode)2067 void MApi_XC_ACE_MWESetMirrorMode( E_XC_ACE_MWE_MIRROR_TYPE eMirrorMode )
2068 {
2069     if (pu32ACEInst == NULL)
2070     {
2071         printf("ACE not initialized!\n");
2072         return;
2073     }
2074 
2075     stACE_MWESetMirrorMode ACEArgs;
2076     ACEArgs.eMirrorMode = eMirrorMode;
2077     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_MWESETMIRRORMODE, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2078     {
2079         printf("Obtain ACE engine fail\n");
2080     }
2081     return;
2082 }
2083 
MApi_XC_ACE_MWECloneVisualEffect_U2(void * pInstance)2084 void MApi_XC_ACE_MWECloneVisualEffect_U2(void *pInstance)
2085 {
2086     _ACE_SEMAPHORE_ENTRY(pInstance);
2087     XC_ACE_ENTRY();
2088     _ACE_GET_VARIABLE();
2089     if(!_bMWESkipDriverSetting)
2090     {
2091         MDrv_XC_ACE_MWECloneVisualEffect(pInstance);
2092     }
2093     XC_ACE_RETURN();
2094     _ACE_SEMAPHORE_RETURN(pInstance);
2095 }
2096 
MApi_XC_ACE_MWECloneVisualEffect(void)2097 void MApi_XC_ACE_MWECloneVisualEffect(void)
2098 {
2099     if (pu32ACEInst == NULL)
2100     {
2101         printf("ACE not initialized!\n");
2102         return;
2103     }
2104 
2105     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_MWECLONEVISUALEFFECT, (void*)NULL) != UTOPIA_STATUS_SUCCESS)
2106     {
2107         printf("Obtain ACE engine fail\n");
2108     }
2109     return;
2110 }
2111 
MApi_XC_ACE_3DClonePQMap_U2(void * pInstance,XC_ACE_WEAVETYPE enWeaveType)2112 void MApi_XC_ACE_3DClonePQMap_U2(void *pInstance, XC_ACE_WEAVETYPE enWeaveType)
2113 {
2114     XC_ACE_ENTRY();
2115     MDrv_ACE_3DClonePQMap(pInstance, enWeaveType);
2116     XC_ACE_RETURN();
2117 }
2118 
MApi_XC_ACE_3DClonePQMap(XC_ACE_WEAVETYPE enWeaveType)2119 void MApi_XC_ACE_3DClonePQMap(XC_ACE_WEAVETYPE enWeaveType)
2120 {
2121     if (pu32ACEInst == NULL)
2122     {
2123         printf("ACE not initialized!\n");
2124         return;
2125     }
2126 
2127     stACE_3DClonePQMap ACEArgs;
2128     ACEArgs.enWeaveType = enWeaveType;
2129     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_3DCLONEPQMAP, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2130     {
2131         printf("Obtain ACE engine fail\n");
2132     }
2133     return;
2134 }
2135 
MApi_XC_ACE_MWESetRegTable_U2(void * pInstance,XC_ACE_TAB_Info * pMWETable)2136 MS_BOOL MApi_XC_ACE_MWESetRegTable_U2(void *pInstance, XC_ACE_TAB_Info *pMWETable)
2137 {
2138     MS_U32 u32Addr;
2139     MS_U8  u8Mask;
2140     MS_U8  u8Value;
2141     MS_U16 i;
2142     MS_U8  u8DoNotSet;
2143     if((NULL == pMWETable->pTable) || (pMWETable->u8TabRows < 2))
2144     {
2145         XC_ACE_DBG_MSG("Invalid Table Format!\n");
2146         return FALSE;
2147     }
2148 
2149     if((ACE_TABINFO_REG_ADDR_SIZE + ACE_TABINFO_REG_MASK_SIZE + pMWETable->u8TabIdx * ACE_TABINFO_REG_DATA_SIZE) >= pMWETable->u8TabCols)
2150     {
2151         XC_ACE_DBG_MSG("Invalid Table Format!\n");
2152         return FALSE;
2153     }
2154 
2155     for(i=0; i < pMWETable->u8TabRows - 1; i++)
2156     {
2157         u32Addr = (MS_U32)((pMWETable->pTable[0] << 8) + pMWETable->pTable[1]);
2158         u8Mask  = pMWETable->pTable[ACE_TABINFO_REG_ADDR_SIZE];
2159         u8DoNotSet = pMWETable->pTable[ACE_TABINFO_REG_ADDR_SIZE + ACE_TABINFO_REG_MASK_SIZE + pMWETable->u8TabIdx * ACE_TABINFO_REG_DATA_SIZE];
2160         u8Value = pMWETable->pTable[ACE_TABINFO_REG_ADDR_SIZE + ACE_TABINFO_REG_MASK_SIZE + pMWETable->u8TabIdx * ACE_TABINFO_REG_DATA_SIZE + 1];
2161         XC_ACE_DBG_MSG("[addr=%04x, msk=%02x, enb=%02x, val=%02x]\n", u32Addr, u8Mask, u8DoNotSet, u8Value);
2162         if(u32Addr == 0xFFFF) //check end of table
2163         {
2164             XC_ACE_DBG_MSG("end of table!\n");
2165             break;
2166         }
2167         if(!u8DoNotSet)
2168         {
2169             XC_ACE_ENTRY();
2170             MDrv_XC_ACE_MWESetRegRow(pInstance, u32Addr, u8Value, u8Mask);
2171             XC_ACE_RETURN();
2172         }
2173         pMWETable->pTable += pMWETable->u8TabCols; //next
2174     }
2175     _ACE_SEMAPHORE_ENTRY(pInstance);
2176     _ACE_GET_VARIABLE();
2177     _bMWESkipDriverSetting = TRUE;
2178     _ACE_SEMAPHORE_RETURN(pInstance);
2179     return TRUE;
2180 }
2181 
MApi_XC_ACE_MWESetRegTable(XC_ACE_TAB_Info * pMWETable)2182 MS_BOOL MApi_XC_ACE_MWESetRegTable(XC_ACE_TAB_Info *pMWETable)
2183 {
2184     if (pu32ACEInst == NULL)
2185     {
2186         printf("ACE not initialized!\n");
2187         return FALSE;
2188     }
2189 
2190     stACE_MWESetRegTable ACEArgs;
2191     ACEArgs.pMWETable = pMWETable;
2192     ACEArgs.bReturn = FALSE;
2193     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_MWESETREGTABLE, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2194     {
2195         printf("Obtain ACE engine fail\n");
2196         return FALSE;
2197     }
2198     else
2199     {
2200         return ACEArgs.bReturn;
2201     }
2202 }
2203 
MApi_XC_ACE_SetMWELoadFromPQ_U2(void * pInstance,MS_BOOL bEnable)2204 MS_BOOL MApi_XC_ACE_SetMWELoadFromPQ_U2(void *pInstance, MS_BOOL bEnable)
2205 {
2206     _ACE_SEMAPHORE_ENTRY(pInstance);
2207     _ACE_GET_VARIABLE();
2208     _bMWESkipDriverSetting = bEnable;
2209     _ACE_SEMAPHORE_RETURN(pInstance);
2210     return TRUE;
2211 }
2212 
MApi_XC_ACE_SetMWELoadFromPQ(MS_BOOL bEnable)2213 MS_BOOL MApi_XC_ACE_SetMWELoadFromPQ(MS_BOOL bEnable)
2214 {
2215     if (pu32ACEInst == NULL)
2216     {
2217         printf("ACE not initialized!\n");
2218         return FALSE;
2219     }
2220 
2221     stACE_SetMWELoadFromPQ ACEArgs;
2222     ACEArgs.bEnable = bEnable;
2223     ACEArgs.bReturn = FALSE;
2224     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETMWELOADFROMPQ, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2225     {
2226         printf("Obtain ACE engine fail\n");
2227         return FALSE;
2228     }
2229     else
2230     {
2231         return ACEArgs.bReturn;
2232     }
2233 }
2234 
MApi_XC_ACE_MWESetDispWin_U2(void * pInstance,MS_U16 u16MWE_Disp_Hstart,MS_U16 u16MWE_Disp_Vstart,MS_U16 u16MWE_Disp_Width,MS_U16 u16MWE_Disp_Height)2235 void MApi_XC_ACE_MWESetDispWin_U2(void *pInstance, MS_U16 u16MWE_Disp_Hstart, MS_U16 u16MWE_Disp_Vstart, MS_U16 u16MWE_Disp_Width, MS_U16 u16MWE_Disp_Height)
2236 {
2237     _ACE_SEMAPHORE_ENTRY(pInstance);
2238     _ACE_GET_VARIABLE();
2239     g_XC_ACE_InitData.u16MWE_Disp_Hstart = u16MWE_Disp_Hstart;
2240     g_XC_ACE_InitData.u16MWE_Disp_Vstart = u16MWE_Disp_Vstart;
2241     g_XC_ACE_InitData.u16MWE_Disp_Width  = u16MWE_Disp_Width;
2242     g_XC_ACE_InitData.u16MWE_Disp_Height = u16MWE_Disp_Height;
2243     _ACE_SEMAPHORE_RETURN(pInstance);
2244 }
2245 
MApi_XC_ACE_MWESetDispWin(MS_U16 u16MWE_Disp_Hstart,MS_U16 u16MWE_Disp_Vstart,MS_U16 u16MWE_Disp_Width,MS_U16 u16MWE_Disp_Height)2246 void MApi_XC_ACE_MWESetDispWin(MS_U16 u16MWE_Disp_Hstart, MS_U16 u16MWE_Disp_Vstart, MS_U16 u16MWE_Disp_Width, MS_U16 u16MWE_Disp_Height)
2247 {
2248     if (pu32ACEInst == NULL)
2249     {
2250         printf("ACE not initialized!\n");
2251         return;
2252     }
2253 
2254     stACE_MWESetDispWin ACEArgs;
2255     ACEArgs.u16MWE_Disp_Hstart = u16MWE_Disp_Hstart;
2256     ACEArgs.u16MWE_Disp_Vstart = u16MWE_Disp_Vstart;
2257     ACEArgs.u16MWE_Disp_Width = u16MWE_Disp_Width;
2258     ACEArgs.u16MWE_Disp_Height = u16MWE_Disp_Height;
2259 
2260     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_MWESETDISPWIN, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2261     {
2262         printf("Obtain ACE engine fail\n");
2263     }
2264     return;
2265 }
2266 
MApi_XC_ACE_MWEStatus_U2(void * pInstance)2267 MS_BOOL MApi_XC_ACE_MWEStatus_U2(void *pInstance)
2268 {
2269     _ACE_SEMAPHORE_ENTRY(pInstance);
2270     _ACE_GET_VARIABLE();
2271 
2272     MS_BOOL bMWEStatusRet = MDrv_XC_GetMWEStatus(pInstance);
2273     _ACE_SEMAPHORE_RETURN(pInstance);
2274     return bMWEStatusRet;
2275 }
2276 
MApi_XC_ACE_MWEStatus(void)2277 MS_BOOL MApi_XC_ACE_MWEStatus(void)
2278 {
2279     if (pu32ACEInst == NULL)
2280     {
2281         printf("ACE not initialized!\n");
2282         return FALSE;
2283     }
2284 
2285     stACE_MWEStatus ACEArgs;
2286     ACEArgs.bReturn = FALSE;
2287     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_MWESTATUS, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2288     {
2289         printf("Obtain ACE engine fail\n");
2290         return FALSE;
2291     }
2292     else
2293     {
2294         return ACEArgs.bReturn;
2295     }
2296 }
2297 
MApi_XC_ACE_MWEFuncSel_U2(void * pInstance,MS_BOOL eWindow,E_XC_ACE_MWE_FUNC mwe_func)2298 void MApi_XC_ACE_MWEFuncSel_U2(void *pInstance, MS_BOOL eWindow, E_XC_ACE_MWE_FUNC  mwe_func)
2299 {
2300     MS_U8 u8border_color;
2301     MS_U16 u16border_l, u16border_r, u16border_t, u16border_d;
2302     MS_BOOL border_en;
2303     MS_S16 s16HShiftStep;
2304     _ACE_SEMAPHORE_ENTRY(pInstance);
2305     _ACE_GET_VARIABLE();
2306 
2307     if (mwe_func == E_XC_ACE_MWE_MODE_OFF && _MWEFunc == E_XC_ACE_MWE_MODE_OFF)
2308     {
2309         _ACE_SEMAPHORE_RETURN(pInstance);
2310         return;
2311     }
2312 
2313     XC_ACE_ENTRY();
2314 
2315     _MWEFunc = mwe_func;
2316     u16border_l = 0x00;
2317     u16border_r = 0x00;
2318     u16border_t = 0x00;
2319     u16border_d = 0x00;
2320 
2321     switch (_MWEFunc)
2322     {
2323     default:
2324     case E_XC_ACE_MWE_MODE_OFF:
2325         gMWERect.Xsize = 0xFFF;
2326         gMWERect.Ysize = 0xFFF;
2327         gMWERect.Xpos = 0;
2328         gMWERect.Ypos = 0;
2329         u8border_color = MWE_BORDER_COLOR_BLACK;
2330         border_en = DISABLE;
2331         break;
2332 
2333     case E_XC_ACE_MWE_MODE_H_SCAN:
2334     case E_XC_ACE_MWE_MODE_H_SPLIT:
2335 
2336         if( _MWEFunc == E_XC_ACE_MWE_MODE_H_SPLIT )
2337         {
2338             gMWERect.Xpos = 0;
2339             gMWERect.Ypos = 0;
2340         }
2341 
2342         XC_ACE_DBG_MSG(" [MWE] H-SPLIT-RIGHT/H-SCAN Function \n");
2343         XC_ACE_DBG_MSG("[MWE]_in_panel;_enMirrorMode=%u,Ds-x[%u],Ds-y[%u],Ds-w[%u],Ds-h[%u].\n",_enMirrorMode,
2344             g_XC_ACE_InitData.u16MWEHstart,g_XC_ACE_InitData.u16MWEVstart,    g_XC_ACE_InitData.u16MWEWidth,g_XC_ACE_InitData.u16MWEHeight);
2345         XC_ACE_DBG_MSG("[MWE]_in_buffer;_enMirrorMode=%u,Ds-x[%u],Ds-y[%u],Ds-w[%u],Ds-h[%u].\n",_enMirrorMode,
2346                                     gMWERect.Xpos,gMWERect.Ypos,gMWERect.Xsize,gMWERect.Ysize);
2347         XC_ACE_DBG_MSG("[MWE]_in_disp;_enMirrorMode=%u,Ds-x[%u],Ds-y[%u],Ds-w[%u],Ds-h[%u].\n",_enMirrorMode,
2348                                     g_XC_ACE_InitData.u16MWE_Disp_Hstart,g_XC_ACE_InitData.u16MWE_Disp_Vstart,g_XC_ACE_InitData.u16MWE_Disp_Width/2,g_XC_ACE_InitData.u16MWE_Disp_Height);
2349 
2350         //for fix H shift step when Display is 1/2.
2351         s16HShiftStep = g_XC_ACE_InitData.u16MWE_Disp_Width - g_XC_ACE_InitData.u16MWEWidth;
2352 
2353 
2354         //w and h size
2355         if(_enMirrorMode == E_XC_ACE_MWE_MIRROR_HV)
2356         {
2357             //for fix screen shift function in contrast expander function
2358             if((abs(g_XC_ACE_InitData.u16MWE_Disp_Width - g_XC_ACE_InitData.u16MWEWidth)) <= 10)
2359             {
2360                 if (g_XC_ACE_InitData.u16MWE_Disp_Hstart == 0)
2361                     gMWERect.Xsize = g_XC_ACE_InitData.u16MWEWidth/2;
2362                 else
2363                     gMWERect.Xsize = g_XC_ACE_InitData.u16MWEWidth/2 + s16HShiftStep;
2364             }
2365             else
2366                 gMWERect.Xsize = g_XC_ACE_InitData.u16MWE_Disp_Width/2;
2367         }
2368         else
2369         {
2370             //for fix screen shift function in contrast expander function
2371             if((abs(g_XC_ACE_InitData.u16MWE_Disp_Width - g_XC_ACE_InitData.u16MWEWidth)) <= 10)
2372                 gMWERect.Xsize = g_XC_ACE_InitData.u16MWEWidth/2 + s16HShiftStep;
2373             else
2374                 gMWERect.Xsize = g_XC_ACE_InitData.u16MWE_Disp_Width/2;
2375         }
2376 
2377         gMWERect.Ysize = g_XC_ACE_InitData.u16MWE_Disp_Height;
2378 
2379         //x and y start position
2380         if(_enMirrorMode == E_XC_ACE_MWE_MIRROR_NORMAL || _enMirrorMode == E_XC_ACE_MWE_MIRROR_V_ONLY)
2381         {
2382             gMWERect.Ypos = g_XC_ACE_InitData.u16MWE_Disp_Vstart+g_XC_ACE_InitData.u16MWE_Disp_Height - gMWERect.Ysize;
2383             //for patch 4:3 in contrast expander function
2384             if (g_XC_ACE_InitData.u16MWEWidth > g_XC_ACE_InitData.u16MWE_Disp_Hstart)
2385                 gMWERect.Xpos = g_XC_ACE_InitData.u16MWEWidth/2;
2386             else
2387                 gMWERect.Xpos = g_XC_ACE_InitData.u16MWE_Disp_Hstart + g_XC_ACE_InitData.u16MWEWidth/2;
2388         }
2389         else if(_enMirrorMode == E_XC_ACE_MWE_MIRROR_HV)
2390         {
2391             if( g_XC_ACE_InitData.u16MWEWidth > ( g_XC_ACE_InitData.u16MWE_Disp_Hstart + g_XC_ACE_InitData.u16MWE_Disp_Width) )
2392             {
2393                 //for patch 4:3 in contrast expander function
2394                 if (g_XC_ACE_InitData.u16MWEWidth > g_XC_ACE_InitData.u16MWE_Disp_Hstart)
2395                     gMWERect.Xpos = g_XC_ACE_InitData.u16MWEWidth - ( gMWERect.Xpos + g_XC_ACE_InitData.u16MWE_Disp_Width ) - g_XC_ACE_InitData.u16MWE_Disp_Hstart;
2396                 else
2397                     gMWERect.Xpos = g_XC_ACE_InitData.u16MWEWidth - ( gMWERect.Xpos + g_XC_ACE_InitData.u16MWE_Disp_Width );
2398             }
2399             else
2400             {
2401                 gMWERect.Xpos = 0;
2402             }
2403 
2404             if( g_XC_ACE_InitData.u16MWEHeight > ( g_XC_ACE_InitData.u16MWE_Disp_Vstart + g_XC_ACE_InitData.u16MWE_Disp_Height) )
2405             {
2406                 //for patch smart view in contrast expander function
2407                 if ((g_XC_ACE_InitData.u16MWE_Disp_Vstart != 0) && (g_XC_ACE_InitData.u16MWE_Disp_Height != g_XC_ACE_InitData.u16MWEHeight))
2408                     gMWERect.Ypos = g_XC_ACE_InitData.u16MWEHeight- ( gMWERect.Ypos + g_XC_ACE_InitData.u16MWE_Disp_Height ) - g_XC_ACE_InitData.u16MWE_Disp_Vstart;
2409                 else
2410                     gMWERect.Ypos = g_XC_ACE_InitData.u16MWEHeight - ( gMWERect.Ypos + g_XC_ACE_InitData.u16MWE_Disp_Height );
2411             }
2412             else
2413             {
2414                 gMWERect.Ypos = 0;
2415             }
2416         }
2417         else
2418         {
2419             gMWERect.Xpos = g_XC_ACE_InitData.u16MWE_Disp_Hstart+g_XC_ACE_InitData.u16MWE_Disp_Width - gMWERect.Xsize;
2420             gMWERect.Ypos = g_XC_ACE_InitData.u16MWE_Disp_Vstart+g_XC_ACE_InitData.u16MWE_Disp_Height - gMWERect.Ysize;
2421         }
2422 
2423         XC_ACE_DBG_MSG("[MWE]_out2;_enMirrorMode=%u,Ds-x[%u],Ds-y[%u],Ds-w[%u],Ds-h[%u].\n",_enMirrorMode,gMWERect.Xpos,gMWERect.Ypos,
2424                                                     gMWERect.Xsize,gMWERect.Ysize);
2425 
2426         u8border_color = MWE_BORDER_COLOR_BLUE;
2427         u16border_l = 0x02;
2428         border_en = ENABLE;
2429         break;
2430 
2431     case E_XC_ACE_MWE_MODE_H_SPLIT_LEFT:
2432         ACE_DBG_MSG(" [MWE] H-SPLIT-LEFT\n");
2433         gMWERect.Xsize = g_XC_ACE_InitData.u16MWE_Disp_Width / 2;
2434         gMWERect.Ysize = g_XC_ACE_InitData.u16MWE_Disp_Height;
2435         gMWERect.Xpos = g_XC_ACE_InitData.u16MWE_Disp_Hstart;
2436         gMWERect.Ypos = g_XC_ACE_InitData.u16MWE_Disp_Vstart;
2437         u8border_color = MWE_BORDER_COLOR_BLUE;
2438         u16border_l = 0x02;
2439         border_en = ENABLE;
2440         break;
2441 
2442     case E_XC_ACE_MWE_MODE_MOVE:
2443         gMWERect.Xsize = g_XC_ACE_InitData.u16MWE_Disp_Width/3;
2444         gMWERect.Ysize =g_XC_ACE_InitData.u16MWE_Disp_Height/3;
2445         gMWERect.Xpos = g_XC_ACE_InitData.u16MWE_Disp_Hstart+g_XC_ACE_InitData.u16MWE_Disp_Width - gMWERect.Xsize;
2446         gMWERect.Ypos = g_XC_ACE_InitData.u16MWE_Disp_Vstart+g_XC_ACE_InitData.u16MWE_Disp_Height - gMWERect.Ysize;
2447         u8border_color = MWE_BORDER_COLOR_BLUE;
2448         u16border_l = 0x11;
2449         u16border_r = 0x11;
2450         u16border_t = 0x11;
2451         u16border_d = 0x11;
2452         border_en = ENABLE;
2453         break;
2454 
2455     case E_XC_ACE_MWE_MODE_ZOOM:
2456         gMWERect.Xsize = g_XC_ACE_InitData.u16MWE_Disp_Width/2;
2457         gMWERect.Ysize = g_XC_ACE_InitData.u16MWE_Disp_Height/2;
2458         gMWERect.Xpos = g_XC_ACE_InitData.u16MWE_Disp_Hstart+g_XC_ACE_InitData.u16MWE_Disp_Width - gMWERect.Xsize;
2459         gMWERect.Ypos = g_XC_ACE_InitData.u16MWE_Disp_Vstart+g_XC_ACE_InitData.u16MWE_Disp_Height - gMWERect.Ysize;
2460         u8border_color = MWE_BORDER_COLOR_BLUE;
2461         border_en = DISABLE;
2462         break;
2463     }
2464 
2465     //ToDo: need to use drvPQ to adjsut picture quality
2466     MDrv_XC_ACE_MWESetWin(pInstance, &gMWERect);
2467     MDrv_XC_ACE_MWESetBorder(pInstance, eWindow, border_en, u8border_color,
2468         u16border_l, u16border_r, u16border_t, u16border_d);
2469     _ACE_SEMAPHORE_RETURN(pInstance);
2470 
2471     XC_ACE_RETURN();
2472 }
2473 
MApi_XC_ACE_MWEFuncSel(MS_BOOL eWindow,E_XC_ACE_MWE_FUNC mwe_func)2474 void MApi_XC_ACE_MWEFuncSel( MS_BOOL eWindow, E_XC_ACE_MWE_FUNC  mwe_func)
2475 {
2476     if (pu32ACEInst == NULL)
2477     {
2478         printf("ACE not initialized!\n");
2479         return;
2480     }
2481 
2482     stACE_MWEFuncSel ACEArgs;
2483     ACEArgs.eWindow = eWindow;
2484     ACEArgs.mwe_func = mwe_func;
2485     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_MWEFUNCSEL, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2486     {
2487         printf("Obtain ACE engine fail\n");
2488     }
2489     return;
2490 }
2491 
MApi_XC_ACE_MWEScan(void * pInstance)2492 static void MApi_XC_ACE_MWEScan(void *pInstance)
2493 {
2494     MS_U32 xpos;
2495     MS_U32 MWE_MAX_XPOS, MWE_MIN_XPOS;
2496     MWE_RECT *pRect;
2497     _ACE_GET_VARIABLE();
2498 
2499     pRect = &gMWERect;
2500 
2501     MWE_MIN_XPOS = g_XC_ACE_InitData.u16MWE_Disp_Hstart;
2502     MWE_MAX_XPOS = MWE_MIN_XPOS + g_XC_ACE_InitData.u16MWE_Disp_Width -1;
2503     xpos  = pRect->Xpos;
2504 
2505     if(_MWEFlag& MWE_MOVE_RIGHT)
2506     {
2507         if( (xpos  + MWE_H_STEP) > ((MS_U32)MWE_MAX_XPOS))
2508         {
2509             xpos = MWE_MAX_XPOS;
2510             _MWEFlag &= ~MWE_MOVE_RIGHT;
2511         }
2512         else
2513         {
2514             xpos += MWE_H_STEP;
2515         }
2516     }
2517     else
2518     {
2519         if(xpos > MWE_H_STEP)
2520         {
2521             if ( (xpos - MWE_H_STEP) > ((MS_U32)MWE_MIN_XPOS))
2522             {
2523                 xpos -= MWE_H_STEP;
2524             }
2525             else
2526             {
2527                 xpos = MWE_MIN_XPOS;
2528                 _MWEFlag |= MWE_MOVE_RIGHT;
2529             }
2530         }
2531         else
2532         {
2533             _MWEFlag |= MWE_MOVE_RIGHT;
2534         }
2535     }
2536 
2537     if (xpos > pRect->Xpos)
2538     {
2539         pRect->Xsize -= (xpos-pRect->Xpos);
2540     }
2541     else
2542     {
2543         pRect->Xsize += (pRect->Xpos-xpos);
2544     }
2545     pRect->Xpos = xpos;
2546 
2547     ACE_DBG_MSG(" HScan %u, %u\n", pRect->Xpos, pRect->Xsize);
2548 
2549 }
2550 
MApi_XC_ACE_MWEHandle_U2(void * pInstance)2551 void MApi_XC_ACE_MWEHandle_U2(void *pInstance)
2552 {
2553     _ACE_SEMAPHORE_ENTRY(pInstance);
2554     _ACE_GET_VARIABLE();
2555 
2556     if (_MWEFunc != E_XC_ACE_MWE_MODE_H_SCAN)
2557         return;
2558 
2559     if ((MsOS_GetSystemTime()-_MWETimer) < MWE_TIMER)
2560         return;
2561     _MWETimer = MsOS_GetSystemTime();
2562 
2563     switch (_MWEFunc)
2564     {
2565     case E_XC_ACE_MWE_MODE_H_SCAN:
2566         MApi_XC_ACE_MWEScan(pInstance);
2567         break;
2568     case E_XC_ACE_MWE_MODE_MOVE:
2569     case E_XC_ACE_MWE_MODE_ZOOM:
2570     default:
2571         return;
2572     }
2573 
2574     XC_ACE_ENTRY();
2575 
2576     //MApi_XC_WaitOutputVSync(1, 50);
2577     MDrv_XC_ACE_MWESetWin(pInstance, &gMWERect);
2578 
2579     XC_ACE_RETURN();
2580 
2581     _ACE_SEMAPHORE_RETURN(pInstance);
2582 
2583 }
2584 
MApi_XC_ACE_MWEHandle(void)2585 void MApi_XC_ACE_MWEHandle( void )
2586 {
2587     if (pu32ACEInst == NULL)
2588     {
2589         printf("ACE not initialized!\n");
2590         return;
2591     }
2592 
2593     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_MWEHANDLE, (void*)NULL) != UTOPIA_STATUS_SUCCESS)
2594     {
2595         printf("Obtain ACE engine fail\n");
2596     }
2597     return;
2598 }
2599 
MApi_XC_ACE_Set_IHC_SRAM_U2(void * pInstance,MS_U16 * pBuf,MS_U16 u16ByteSize)2600 MS_BOOL MApi_XC_ACE_Set_IHC_SRAM_U2(void *pInstance, MS_U16 *pBuf, MS_U16 u16ByteSize)
2601 {
2602     MS_BOOL bRet;
2603     XC_ACE_ENTRY();
2604 
2605     bRet = MDrv_XC_ACE_Set_IHC_SRAM(pInstance, pBuf, u16ByteSize);
2606 
2607     XC_ACE_RETURN();
2608 
2609     return  bRet;
2610 }
2611 
MApi_XC_ACE_Set_IHC_SRAM(MS_U16 * pBuf,MS_U16 u16ByteSize)2612 MS_BOOL MApi_XC_ACE_Set_IHC_SRAM(MS_U16 *pBuf, MS_U16 u16ByteSize)
2613 {
2614     if (pu32ACEInst == NULL)
2615     {
2616         printf("ACE not initialized!\n");
2617         return FALSE;
2618     }
2619 
2620     stACE_Set_IHC_SRAM ACEArgs;
2621     ACEArgs.pBuf = pBuf;
2622     ACEArgs.u16ByteSize = u16ByteSize;
2623     ACEArgs.bReturn = FALSE;
2624     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SET_IHC_SRAM, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2625     {
2626         printf("Obtain ACE engine fail\n");
2627         return FALSE;
2628     }
2629     else
2630     {
2631         return ACEArgs.bReturn;
2632     }
2633 }
2634 
MApi_XC_ACE_Set_ICC_SRAM_U2(void * pInstance,MS_U16 * pBuf,MS_U16 u16ByteSize)2635 MS_BOOL MApi_XC_ACE_Set_ICC_SRAM_U2(void *pInstance, MS_U16 *pBuf, MS_U16 u16ByteSize)
2636 {
2637     MS_BOOL bRet;
2638     XC_ACE_ENTRY();
2639 
2640     bRet = MDrv_XC_ACE_Set_ICC_SRAM(pInstance, pBuf, u16ByteSize);
2641 
2642     XC_ACE_RETURN();
2643 
2644     return  bRet;
2645 }
2646 
MApi_XC_ACE_Set_ICC_SRAM(MS_U16 * pBuf,MS_U16 u16ByteSize)2647 MS_BOOL MApi_XC_ACE_Set_ICC_SRAM(MS_U16 *pBuf, MS_U16 u16ByteSize)
2648 {
2649     if (pu32ACEInst == NULL)
2650     {
2651         printf("ACE not initialized!\n");
2652         return FALSE;
2653     }
2654 
2655     stACE_Set_ICC_SRAM ACEArgs;
2656     ACEArgs.pBuf = pBuf;
2657     ACEArgs.u16ByteSize = u16ByteSize;
2658     ACEArgs.bReturn = FALSE;
2659     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SET_ICC_SRAM, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2660     {
2661         printf("Obtain ACE engine fail\n");
2662         return FALSE;
2663     }
2664     else
2665     {
2666         return ACEArgs.bReturn;
2667     }
2668 }
2669 
2670 ////////////////////////////////////////////////////////////////////////////////
2671 //
2672 //  DynamicNR start
2673 //
2674 ////////////////////////////////////////////////////////////////////////////////
2675 #define NR_DBG(x)   //x
2676 
2677 #define DYNAMIC_NR_TBL_REG_NUM                  8
2678 #define DYNAMICNR_DEFLICKER_PRECISION_SHFIT     64UL
2679 #define DYNAMICNR_DEFLICK_TOTAL                 32UL
2680 #define DYNAMICNR_DEFLICK_STABLE_CNT            0x10
2681 
2682 #if 0
2683 MS_U8  g_u8MotionStableCnt;
2684 MS_U8  g_u8LumaStableCnt;
2685 MS_U8  g_u8FlickStableCnt;
2686 #endif
2687 
MApi_XC_ACE_DNR_Get_PrecisionShift_U2(void * pInstance)2688 MS_U16 MApi_XC_ACE_DNR_Get_PrecisionShift_U2(void *pInstance)
2689 {
2690     return DYNAMICNR_DEFLICKER_PRECISION_SHFIT;
2691 }
2692 
MApi_XC_ACE_DNR_Get_PrecisionShift(void)2693 MS_U16 MApi_XC_ACE_DNR_Get_PrecisionShift(void)
2694 {
2695     if (pu32ACEInst == NULL)
2696     {
2697         printf("ACE not initialized!\n");
2698         return 0;
2699     }
2700 
2701     stACE_DNR_Get_PrecisionShift ACEArgs;
2702     ACEArgs.u16Return = 0;
2703     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_GET_PRECISIONSHIFT, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2704     {
2705         printf("Obtain ACE engine fail\n");
2706         return 0;
2707     }
2708     else
2709     {
2710         return ACEArgs.u16Return;
2711     }
2712 }
2713 
MApi_XC_ACE_DNR_Blending_NRTbl_U2(void * pInstance,MS_U8 * pu8NewNR,MS_U8 u8Weight,MS_U8 u8Step,MS_U16 * pu16PreY0,MS_U16 * pu16PreY1,MS_U8 * pu8NRTBL)2714 void MApi_XC_ACE_DNR_Blending_NRTbl_U2(
2715     void *pInstance,
2716     MS_U8 *pu8NewNR,
2717     MS_U8 u8Weight,
2718     MS_U8 u8Step,
2719     MS_U16 *pu16PreY0,
2720     MS_U16 *pu16PreY1,
2721     MS_U8 *pu8NRTBL)
2722 {
2723     MS_U8 i;
2724     MS_U16 u16TmpBlend[2];
2725 
2726     NR_DBG(printk("CurNR:"));
2727     for(i=0; i<DYNAMIC_NR_TBL_REG_NUM; i++)
2728     {
2729         u16TmpBlend[0] = (MS_U16)(((((MS_U32)u8Weight * ((MS_U32)pu8NewNR[i] & 0x0FL)) * DYNAMICNR_DEFLICKER_PRECISION_SHFIT) +
2730                     ((MS_U32)DYNAMICNR_DEFLICK_TOTAL - (MS_U32)u8Weight) * (MS_U32)pu16PreY0[i]) / DYNAMICNR_DEFLICK_TOTAL);
2731 
2732         u16TmpBlend[1] = (MS_U16)(((((MS_U32)u8Weight * (((MS_U32)pu8NewNR[i] & 0xF0L)>>4)) * DYNAMICNR_DEFLICKER_PRECISION_SHFIT) +
2733                     ((MS_U32)DYNAMICNR_DEFLICK_TOTAL - (MS_U32)u8Weight) * (MS_U32)pu16PreY1[i]) / DYNAMICNR_DEFLICK_TOTAL);
2734 
2735 
2736         if(u16TmpBlend[0] > pu16PreY0[i])
2737         {
2738             if( (u16TmpBlend[0] - (MS_U16)pu16PreY0[i]) > ((MS_U16)DYNAMICNR_DEFLICKER_PRECISION_SHFIT * (MS_U16) u8Step))
2739                 u16TmpBlend[0]  = pu16PreY0[i] + ((MS_U16)DYNAMICNR_DEFLICKER_PRECISION_SHFIT * (MS_U16) u8Step);
2740         }
2741         else if(u16TmpBlend[0] < (MS_U16)pu16PreY0[i])
2742         {
2743             if( ((MS_U16)pu16PreY0[i] - u16TmpBlend[0]) > ((MS_U16)DYNAMICNR_DEFLICKER_PRECISION_SHFIT * (MS_U16) u8Step))
2744                 u16TmpBlend[0]  = pu16PreY0[i] - ((MS_U16)DYNAMICNR_DEFLICKER_PRECISION_SHFIT * (MS_U16) u8Step);
2745         }
2746         pu16PreY0[i] = u16TmpBlend[0];
2747 
2748         if(u16TmpBlend[1] > pu16PreY1[i])
2749         {
2750             if( (u16TmpBlend[1] - (MS_U16)pu16PreY1[i]) > ((MS_U16)DYNAMICNR_DEFLICKER_PRECISION_SHFIT * (MS_U16) u8Step))
2751                 u16TmpBlend[1]  = pu16PreY1[i] + ((MS_U16)DYNAMICNR_DEFLICKER_PRECISION_SHFIT * (MS_U16) u8Step);
2752         }
2753         else if(u16TmpBlend[1] < (MS_U16)pu16PreY1[i])
2754         {
2755             if( ((MS_U16)pu16PreY1[i] - u16TmpBlend[1]) > ((MS_U16)DYNAMICNR_DEFLICKER_PRECISION_SHFIT * (MS_U16) u8Step))
2756                 u16TmpBlend[1]  = pu16PreY1[i] - ((MS_U16)DYNAMICNR_DEFLICKER_PRECISION_SHFIT * (MS_U16) u8Step);
2757         }
2758         pu16PreY1[i] = u16TmpBlend[1];
2759         pu8NRTBL[i] = (MS_U8)(((u16TmpBlend[1] / DYNAMICNR_DEFLICKER_PRECISION_SHFIT)<<4) | (u16TmpBlend[0] / DYNAMICNR_DEFLICKER_PRECISION_SHFIT));
2760 
2761         NR_DBG(printk(" %02bx, ", pu8NRTBL[i]));
2762     }
2763     NR_DBG(printk("\n"));
2764 }
2765 
MApi_XC_ACE_DNR_Blending_NRTbl(MS_U8 * pu8NewNR,MS_U8 u8Weight,MS_U8 u8Step,MS_U16 * pu16PreY0,MS_U16 * pu16PreY1,MS_U8 * pu8NRTBL)2766 void MApi_XC_ACE_DNR_Blending_NRTbl(
2767     MS_U8 *pu8NewNR,
2768     MS_U8 u8Weight,
2769     MS_U8 u8Step,
2770     MS_U16 *pu16PreY0,
2771     MS_U16 *pu16PreY1,
2772     MS_U8 *pu8NRTBL)
2773 {
2774     if (pu32ACEInst == NULL)
2775     {
2776         printf("ACE not initialized!\n");
2777         return;
2778     }
2779 
2780     stACE_DNR_Blending_NRTbl ACEArgs;
2781     ACEArgs.pu8NewNR = pu8NewNR;
2782     ACEArgs.u8Weight = u8Weight;
2783     ACEArgs.pu16PreY0 = pu16PreY0;
2784     ACEArgs.pu16PreY1 = pu16PreY1;
2785     ACEArgs.pu8NRTBL = pu8NRTBL;
2786     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_BLENDING_NRTBL, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2787     {
2788         printf("Obtain ACE engine fail\n");
2789     }
2790     return;
2791 }
2792 
MApi_XC_ACE_DNR_Blending_U2(void * pInstance,MS_U8 u8NewItem,MS_U16 u16PreItem,MS_U8 u8Weight)2793 MS_U8 MApi_XC_ACE_DNR_Blending_U2(void *pInstance, MS_U8 u8NewItem, MS_U16 u16PreItem, MS_U8 u8Weight)
2794 {
2795     MS_U8 u8Blend;
2796 
2797     u8Blend = (MS_U8)(((((MS_U32)u8Weight * (MS_U32)u8NewItem)) +
2798                 ((MS_U32)DYNAMICNR_DEFLICK_TOTAL - (MS_U32)u8Weight) * (MS_U32)u16PreItem) / DYNAMICNR_DEFLICK_TOTAL);
2799     return u8Blend;
2800 }
2801 
MApi_XC_ACE_DNR_Blending(MS_U8 u8NewItem,MS_U16 u16PreItem,MS_U8 u8Weight)2802 MS_U8 MApi_XC_ACE_DNR_Blending(MS_U8 u8NewItem, MS_U16 u16PreItem, MS_U8 u8Weight)
2803 {
2804     if (pu32ACEInst == NULL)
2805     {
2806         printf("ACE not initialized!\n");
2807         return 0;
2808     }
2809 
2810     stACE_DNR_Blending ACEArgs;
2811     ACEArgs.u8NewItem = u8NewItem;
2812     ACEArgs.u16PreItem = u16PreItem;
2813     ACEArgs.u8Weight = u8Weight;
2814     ACEArgs.u8Return = 0;
2815     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_BLENDING, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2816     {
2817         printf("Obtain ACE engine fail\n");
2818         return 0;
2819     }
2820     else
2821     {
2822         return  ACEArgs.u8Return;
2823     }
2824 }
2825 
MApi_XC_ACE_DNR_Blending_MISC_U2(void * pInstance,MS_U8 u8NewItem,MS_U16 u16PreItem,MS_U8 u8Weight,MS_U8 u8Step)2826 MS_U16 MApi_XC_ACE_DNR_Blending_MISC_U2(
2827     void *pInstance,
2828     MS_U8 u8NewItem,
2829     MS_U16 u16PreItem,
2830     MS_U8 u8Weight,
2831     MS_U8 u8Step)
2832 {
2833     MS_U16 u16Blend;
2834 
2835     u16Blend = ((((MS_U32)u8Weight * (MS_U32)u8NewItem) * DYNAMICNR_DEFLICKER_PRECISION_SHFIT) +
2836                 ((MS_U32)DYNAMICNR_DEFLICK_TOTAL - (MS_U32)u8Weight) * (MS_U32)u16PreItem) / DYNAMICNR_DEFLICK_TOTAL;
2837 
2838 
2839     if(u16Blend > u16PreItem)
2840     {
2841         if( (u16Blend - u16PreItem) > ((MS_U16)DYNAMICNR_DEFLICKER_PRECISION_SHFIT * (MS_U16) u8Step))
2842             u16Blend  = u16PreItem + ((MS_U16)DYNAMICNR_DEFLICKER_PRECISION_SHFIT * (MS_U16) u8Step);
2843     }
2844     else if(u16Blend < u16PreItem)
2845     {
2846         if( ((MS_U16)u16PreItem - u16Blend) > ((MS_U16)DYNAMICNR_DEFLICKER_PRECISION_SHFIT * (MS_U16) u8Step))
2847             u16Blend  = u16PreItem - ((MS_U16)DYNAMICNR_DEFLICKER_PRECISION_SHFIT * (MS_U16) u8Step);
2848     }
2849 
2850     return u16Blend;
2851 }
2852 
MApi_XC_ACE_DNR_Blending_MISC(MS_U8 u8NewItem,MS_U16 u16PreItem,MS_U8 u8Weight,MS_U8 u8Step)2853 MS_U16 MApi_XC_ACE_DNR_Blending_MISC(
2854     MS_U8 u8NewItem,
2855     MS_U16 u16PreItem,
2856     MS_U8 u8Weight,
2857     MS_U8 u8Step)
2858 {
2859     if (pu32ACEInst == NULL)
2860     {
2861         printf("ACE not initialized!\n");
2862         return 0;
2863     }
2864 
2865     stACE_DNR_Blending_MISC ACEArgs;
2866     ACEArgs.u8NewItem = u8NewItem;
2867     ACEArgs.u16PreItem = u16PreItem;
2868     ACEArgs.u8Weight = u8Weight;
2869     ACEArgs.u8Step = u8Step;
2870     ACEArgs.u16Return = 0;
2871     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_BLENDING_MISC, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2872     {
2873         printf("Obtain ACE engine fail\n");
2874         return 0;
2875     }
2876     else
2877     {
2878         return  ACEArgs.u16Return;
2879     }
2880 }
2881 
MApi_XC_ACE_DNR_GetMotion_U2(void * pInstance)2882 MS_U8 MApi_XC_ACE_DNR_GetMotion_U2(void *pInstance)
2883 {
2884     MS_U8 u8Ret;
2885 
2886     XC_ACE_ENTRY();
2887 
2888     u8Ret =  MDrv_XC_ACE_DNR_GetMotion(pInstance);
2889 
2890     XC_ACE_RETURN();
2891 
2892     return u8Ret;
2893 }
2894 
MApi_XC_ACE_DNR_GetMotion(void)2895 MS_U8 MApi_XC_ACE_DNR_GetMotion(void)
2896 {
2897     if (pu32ACEInst == NULL)
2898     {
2899         printf("ACE not initialized!\n");
2900         return 0;
2901     }
2902 
2903     stACE_DNR_GetMotion ACEArgs;
2904     ACEArgs.u8Return = 0;
2905     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_GETMOTION, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
2906     {
2907         printf("Obtain ACE engine fail\n");
2908         return 0;
2909     }
2910     else
2911     {
2912         return  ACEArgs.u8Return;
2913     }
2914 }
2915 
MApi_XC_ACE_DNR_GetMotion_Weight_U2(void * pInstance,MS_U8 u8CurMotion,MS_U8 u8PreMotion,MS_U8 u8CurMotionLvl,MS_U8 u8PreMotionLvl,MS_U8 u8DeFlick_Thre,MS_U8 u8DeFilick_Step)2916 MS_U8 MApi_XC_ACE_DNR_GetMotion_Weight_U2(
2917     void *pInstance,
2918     MS_U8 u8CurMotion,
2919     MS_U8 u8PreMotion,
2920     MS_U8 u8CurMotionLvl,
2921     MS_U8 u8PreMotionLvl,
2922     MS_U8 u8DeFlick_Thre,
2923     MS_U8 u8DeFilick_Step)
2924 {
2925     MS_U8 u8Weight;
2926     _ACE_SEMAPHORE_ENTRY(pInstance);
2927     _ACE_GET_VARIABLE();
2928 
2929     if(u8CurMotion > u8PreMotion)
2930     {
2931         if((u8CurMotion - u8PreMotion) < u8DeFlick_Thre)
2932         {
2933             if((u8CurMotionLvl - u8PreMotionLvl) <= 1)
2934             {
2935                 if(g_u8MotionStableCnt != 0xFF)
2936                     g_u8MotionStableCnt++;
2937             }
2938             else
2939             {
2940                 g_u8MotionStableCnt = 0;
2941             }
2942             u8Weight = (g_u8MotionStableCnt > DYNAMICNR_DEFLICK_STABLE_CNT) ?
2943                        DYNAMICNR_DEFLICK_TOTAL : u8DeFlick_Thre;
2944         }
2945         else
2946         {
2947             g_u8MotionStableCnt = 0;
2948             u8Weight = DYNAMICNR_DEFLICK_TOTAL;
2949         }
2950     }
2951     else
2952     {
2953         if((u8PreMotion - u8CurMotion) < u8DeFilick_Step)
2954         {
2955             if((u8CurMotionLvl - u8PreMotionLvl) <= 1)
2956             {
2957                 if(g_u8MotionStableCnt != 0xFF)
2958                     g_u8MotionStableCnt++;
2959             }
2960             else
2961             {
2962                 g_u8MotionStableCnt = 0;
2963             }
2964             u8Weight = (g_u8MotionStableCnt > DYNAMICNR_DEFLICK_STABLE_CNT) ?
2965                        DYNAMICNR_DEFLICK_TOTAL : u8DeFilick_Step;
2966         }
2967         else
2968         {
2969             g_u8MotionStableCnt = 0;
2970             u8Weight = DYNAMICNR_DEFLICK_TOTAL;
2971         }
2972     }
2973 
2974     if(u8Weight > DYNAMICNR_DEFLICK_TOTAL)
2975         u8Weight = DYNAMICNR_DEFLICK_TOTAL;
2976     _ACE_SEMAPHORE_RETURN(pInstance);
2977 
2978     return u8Weight;
2979 }
2980 
MApi_XC_ACE_DNR_GetMotion_Weight(MS_U8 u8CurMotion,MS_U8 u8PreMotion,MS_U8 u8CurMotionLvl,MS_U8 u8PreMotionLvl,MS_U8 u8DeFlick_Thre,MS_U8 u8DeFilick_Step)2981 MS_U8 MApi_XC_ACE_DNR_GetMotion_Weight(
2982     MS_U8 u8CurMotion,
2983     MS_U8 u8PreMotion,
2984     MS_U8 u8CurMotionLvl,
2985     MS_U8 u8PreMotionLvl,
2986     MS_U8 u8DeFlick_Thre,
2987     MS_U8 u8DeFilick_Step)
2988 {
2989     if (pu32ACEInst == NULL)
2990     {
2991         printf("ACE not initialized!\n");
2992         return 0;
2993     }
2994 
2995     stACE_DNR_GetMotion_Weight ACEArgs;
2996     ACEArgs.u8CurMotion = u8CurMotion;
2997     ACEArgs.u8PreMotion = u8PreMotion;
2998     ACEArgs.u8CurMotionLvl = u8CurMotionLvl;
2999     ACEArgs.u8PreMotionLvl = u8CurMotionLvl;
3000     ACEArgs.u8DeFlick_Thre = u8DeFlick_Thre;
3001     ACEArgs.u8DeFilick_Step = u8DeFilick_Step;
3002     ACEArgs.u8Return = 0;
3003     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_GETMOTION_WEIGHT, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
3004     {
3005         printf("Obtain ACE engine fail\n");
3006         return 0;
3007     }
3008     else
3009     {
3010         return  ACEArgs.u8Return;
3011     }
3012 }
3013 
MApi_XC_ACE_DNR_GetLuma_Weight_U2(void * pInstance,MS_U8 u8CurAvgLuma,MS_U8 u8PreAvgLuam,MS_U8 u8CurLumaLvl,MS_U8 u8PreLumaLvl,MS_U8 u8DeFlick_Th,MS_U8 u8DeFlick_Step)3014 MS_U8  MApi_XC_ACE_DNR_GetLuma_Weight_U2(
3015     void *pInstance,
3016     MS_U8 u8CurAvgLuma,
3017     MS_U8 u8PreAvgLuam,
3018     MS_U8 u8CurLumaLvl,
3019     MS_U8 u8PreLumaLvl,
3020     MS_U8 u8DeFlick_Th,
3021     MS_U8 u8DeFlick_Step)
3022 {
3023     MS_U8 u8Weight;
3024     _ACE_SEMAPHORE_ENTRY(pInstance);
3025     _ACE_GET_VARIABLE();
3026 
3027     // Blending for Coring and SNR
3028     if(u8CurAvgLuma > u8PreAvgLuam)
3029     {
3030         if((u8CurAvgLuma - u8PreAvgLuam) < u8DeFlick_Th)
3031         {
3032             if((u8CurLumaLvl - u8PreLumaLvl)<=1)
3033             {
3034                 if(g_u8LumaStableCnt != 0xFF)
3035                     g_u8LumaStableCnt++;
3036             }
3037             else
3038             {
3039                 g_u8LumaStableCnt = 0;
3040             }
3041             u8Weight = (g_u8LumaStableCnt > DYNAMICNR_DEFLICK_STABLE_CNT) ?
3042                        DYNAMICNR_DEFLICK_TOTAL :
3043                        u8DeFlick_Step;
3044         }
3045         else
3046         {
3047             g_u8LumaStableCnt = 0;
3048             u8Weight = DYNAMICNR_DEFLICK_TOTAL;
3049         }
3050     }
3051     else
3052     {
3053         if((u8PreAvgLuam - u8CurAvgLuma) < u8DeFlick_Th)
3054         {
3055             if((u8CurLumaLvl - u8PreLumaLvl)<=1)
3056             {
3057                 if(g_u8LumaStableCnt != 0xFF)
3058                     g_u8LumaStableCnt++;
3059             }
3060             else
3061             {
3062                 g_u8LumaStableCnt = 0;
3063             }
3064             u8Weight = (g_u8LumaStableCnt > DYNAMICNR_DEFLICK_STABLE_CNT) ?
3065                        DYNAMICNR_DEFLICK_TOTAL :
3066                        u8DeFlick_Step;
3067         }
3068         else
3069         {
3070             g_u8LumaStableCnt = 0;
3071             u8Weight = DYNAMICNR_DEFLICK_TOTAL;
3072         }
3073     }
3074     _ACE_SEMAPHORE_RETURN(pInstance);
3075 
3076     return u8Weight;
3077 }
3078 
MApi_XC_ACE_DNR_GetLuma_Weight(MS_U8 u8CurAvgLuma,MS_U8 u8PreAvgLuam,MS_U8 u8CurLumaLvl,MS_U8 u8PreLumaLvl,MS_U8 u8DeFlick_Th,MS_U8 u8DeFlick_Step)3079 MS_U8  MApi_XC_ACE_DNR_GetLuma_Weight(
3080     MS_U8 u8CurAvgLuma,
3081     MS_U8 u8PreAvgLuam,
3082     MS_U8 u8CurLumaLvl,
3083     MS_U8 u8PreLumaLvl,
3084     MS_U8 u8DeFlick_Th,
3085     MS_U8 u8DeFlick_Step)
3086 {
3087     if (pu32ACEInst == NULL)
3088     {
3089         printf("ACE not initialized!\n");
3090         return 0;
3091     }
3092 
3093     stACE_DNR_GetLuma_Weight ACEArgs;
3094     ACEArgs.u8CurAvgLuma = u8CurAvgLuma;
3095     ACEArgs.u8PreAvgLuam = u8PreAvgLuam;
3096     ACEArgs.u8CurLumaLvl = u8CurLumaLvl;
3097     ACEArgs.u8PreLumaLvl = u8PreLumaLvl;
3098     ACEArgs.u8DeFlick_Th = u8DeFlick_Th;
3099     ACEArgs.u8DeFlick_Step = u8DeFlick_Step;
3100     ACEArgs.u8Return = 0;
3101     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_GETLUMA_WEIGHT, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
3102     {
3103         printf("Obtain ACE engine fail\n");
3104         return 0;
3105     }
3106     else
3107     {
3108         return  ACEArgs.u8Return;
3109     }
3110 }
3111 
MApi_XC_ACE_DNR_GetNoise_Weight_U2(void * pInstance,MS_U8 u8CurNoise,MS_U8 u8PreNoise,MS_U8 u8Range,MS_U8 u8DeFlick_Th,MS_U8 u8DeFlick_Step)3112 MS_U8 MApi_XC_ACE_DNR_GetNoise_Weight_U2(
3113     void *pInstance,
3114     MS_U8 u8CurNoise,
3115     MS_U8 u8PreNoise,
3116     MS_U8 u8Range,
3117     MS_U8 u8DeFlick_Th,
3118     MS_U8 u8DeFlick_Step)
3119 {
3120     MS_U8 u8Weight;
3121     _ACE_SEMAPHORE_ENTRY(pInstance);
3122     _ACE_GET_VARIABLE();
3123 
3124     if(u8CurNoise > u8PreNoise)
3125     {
3126         if((u8CurNoise - u8PreNoise) < (u8DeFlick_Th))
3127         {
3128             g_u8FlickStableCnt =
3129                 ((u8CurNoise - u8PreNoise) < u8Range) ?
3130                 g_u8FlickStableCnt + 1 : 0;
3131 
3132             u8Weight = (g_u8FlickStableCnt == DYNAMICNR_DEFLICK_STABLE_CNT) ?
3133                         DYNAMICNR_DEFLICK_TOTAL :
3134                         u8DeFlick_Step;
3135         }
3136         else
3137         {
3138             g_u8FlickStableCnt = 0;
3139             u8Weight = DYNAMICNR_DEFLICK_TOTAL;
3140         }
3141     }
3142     else
3143     {
3144         if((u8PreNoise - u8CurNoise) < (u8DeFlick_Th))
3145         {
3146             g_u8FlickStableCnt =
3147                 ((u8CurNoise - u8PreNoise) < u8Range) ?
3148                 g_u8FlickStableCnt + 1 : 0;
3149             u8Weight = (g_u8FlickStableCnt == DYNAMICNR_DEFLICK_STABLE_CNT) ?
3150                         DYNAMICNR_DEFLICK_TOTAL :
3151                         u8DeFlick_Step;
3152         }
3153         else
3154         {
3155             g_u8FlickStableCnt = 0;
3156             u8Weight = DYNAMICNR_DEFLICK_TOTAL;
3157         }
3158     }
3159 
3160     if(u8Weight > DYNAMICNR_DEFLICK_TOTAL)
3161         u8Weight = DYNAMICNR_DEFLICK_TOTAL;
3162     if(u8Weight == 0)
3163         u8Weight = 1;
3164     _ACE_SEMAPHORE_RETURN(pInstance);
3165 
3166     return u8Weight;
3167 }
3168 
MApi_XC_ACE_DNR_GetNoise_Weight(MS_U8 u8CurNoise,MS_U8 u8PreNoise,MS_U8 u8Range,MS_U8 u8DeFlick_Th,MS_U8 u8DeFlick_Step)3169 MS_U8 MApi_XC_ACE_DNR_GetNoise_Weight(
3170     MS_U8 u8CurNoise,
3171     MS_U8 u8PreNoise,
3172     MS_U8 u8Range,
3173     MS_U8 u8DeFlick_Th,
3174     MS_U8 u8DeFlick_Step)
3175 {
3176     if (pu32ACEInst == NULL)
3177     {
3178         printf("ACE not initialized!\n");
3179         return 0;
3180     }
3181 
3182     stACE_DNR_GetNoise_Weight ACEArgs;
3183     ACEArgs.u8CurNoise = u8CurNoise;
3184     ACEArgs.u8PreNoise = u8PreNoise;
3185     ACEArgs.u8Range = u8Range;
3186     ACEArgs.u8Range = u8Range;
3187     ACEArgs.u8DeFlick_Th = u8DeFlick_Th;
3188     ACEArgs.u8DeFlick_Step = u8DeFlick_Step;
3189     ACEArgs.u8Return = 0;
3190     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_GETNOISE_WEIGHT, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
3191     {
3192         printf("Obtain ACE engine fail\n");
3193         return 0;
3194     }
3195     else
3196     {
3197         return  ACEArgs.u8Return;
3198     }
3199 }
3200 
MApi_XC_ACE_DNR_Init_Motion_U2(void * pInstance)3201 void MApi_XC_ACE_DNR_Init_Motion_U2(void *pInstance)
3202 {
3203     _ACE_SEMAPHORE_ENTRY(pInstance);
3204     _ACE_GET_VARIABLE();
3205     g_u8MotionStableCnt = 0;
3206     _ACE_SEMAPHORE_RETURN(pInstance);
3207 }
3208 
MApi_XC_ACE_DNR_Init_Motion(void)3209 void MApi_XC_ACE_DNR_Init_Motion(void)
3210 {
3211     if (pu32ACEInst == NULL)
3212     {
3213         printf("ACE not initialized!\n");
3214         return;
3215     }
3216 
3217     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_INIT_MOTION, (void*)NULL) != UTOPIA_STATUS_SUCCESS)
3218     {
3219         printf("Obtain ACE engine fail\n");
3220     }
3221     return;
3222 }
3223 
MApi_XC_ACE_DNR_Init_Luma_U2(void * pInstance)3224 void MApi_XC_ACE_DNR_Init_Luma_U2(void *pInstance)
3225 {
3226     _ACE_SEMAPHORE_ENTRY(pInstance);
3227     _ACE_GET_VARIABLE();
3228     g_u8LumaStableCnt = 0;
3229     _ACE_SEMAPHORE_RETURN(pInstance);
3230 }
3231 
MApi_XC_ACE_DNR_Init_Luma(void)3232 void MApi_XC_ACE_DNR_Init_Luma(void)
3233 {
3234     if (pu32ACEInst == NULL)
3235     {
3236         printf("ACE not initialized!\n");
3237         return;
3238     }
3239 
3240     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_INIT_LUMA, (void*)NULL) != UTOPIA_STATUS_SUCCESS)
3241     {
3242         printf("Obtain ACE engine fail\n");
3243     }
3244     return;
3245 }
3246 
MApi_XC_ACE_DNR_Init_Noise_U2(void * pInstance)3247 void MApi_XC_ACE_DNR_Init_Noise_U2(void *pInstance)
3248 {
3249     _ACE_SEMAPHORE_ENTRY(pInstance);
3250     _ACE_GET_VARIABLE();
3251     g_u8FlickStableCnt = 0;
3252     _ACE_SEMAPHORE_RETURN(pInstance);
3253 }
3254 
MApi_XC_ACE_DNR_Init_Noise(void)3255 void MApi_XC_ACE_DNR_Init_Noise(void)
3256 {
3257     if (pu32ACEInst == NULL)
3258     {
3259         printf("ACE not initialized!\n");
3260         return;
3261     }
3262 
3263     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_INIT_NOISE, (void*)NULL) != UTOPIA_STATUS_SUCCESS)
3264     {
3265         printf("Obtain ACE engine fail\n");
3266     }
3267     return;
3268 }
3269 
MApi_XC_ACE_DNR_GetParam_U2(void * pInstance,MS_BOOL eWindow,XC_ACE_DNR_Param eParam)3270 MS_U8 MApi_XC_ACE_DNR_GetParam_U2(void *pInstance, MS_BOOL eWindow, XC_ACE_DNR_Param eParam)
3271 {
3272     MS_U8 u8val;
3273 
3274     XC_ACE_ENTRY();
3275 
3276     switch(eParam)
3277     {
3278     case E_ACE_DNR_PEAKING_CORING_THRESHOLD:
3279         u8val = MDrv_ACE_DNR_GetCoringThreshold(pInstance, eWindow);
3280         break;
3281 
3282     case E_ACE_DNR_SHARPNESS_ADJUST:
3283         u8val = MDrv_ACE_DNR_GetSharpnessAdjust(pInstance, eWindow);
3284         break;
3285 
3286     case E_ACE_DNR_GUASSIN_SNR_THRESHOLD:
3287         u8val = MDrv_ACE_DNR_GetGuassin_SNR_Threshold(pInstance, eWindow);
3288         break;
3289 
3290     default:
3291         ACE_DBG_MSG("XC_ACE_DNR: unknown get param %u\n", eParam);
3292         u8val = 0;
3293         break;
3294     }
3295 
3296     XC_ACE_RETURN();
3297 
3298     return u8val;
3299 }
3300 
MApi_XC_ACE_DNR_GetParam(MS_BOOL eWindow,XC_ACE_DNR_Param eParam)3301 MS_U8 MApi_XC_ACE_DNR_GetParam(MS_BOOL eWindow, XC_ACE_DNR_Param eParam)
3302 {
3303     if (pu32ACEInst == NULL)
3304     {
3305         printf("ACE not initialized!\n");
3306         return 0;
3307     }
3308 
3309     stACE_DNR_GetParam ACEArgs;
3310     ACEArgs.eWindow = eWindow;
3311     ACEArgs.eParam = eParam;
3312     ACEArgs.u8Return = 0;
3313     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_GETPARAM, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
3314     {
3315         printf("Obtain ACE engine fail\n");
3316         return 0;
3317     }
3318     else
3319     {
3320         return  ACEArgs.u8Return;
3321     }
3322 }
3323 
MApi_XC_ACE_DNR_SetParam_U2(void * pInstance,MS_BOOL eWindow,XC_ACE_DNR_Param eParam,MS_U16 u16val)3324 void MApi_XC_ACE_DNR_SetParam_U2(void *pInstance, MS_BOOL eWindow, XC_ACE_DNR_Param eParam, MS_U16 u16val)
3325 {
3326     XC_ACE_ENTRY();
3327 
3328     switch(eParam)
3329     {
3330     case E_ACE_DNR_PEAKING_BANK_CORING:
3331         MDrv_ACE_DNR_SetBank_Coring(pInstance, eWindow, u16val);
3332         break;
3333 
3334     case E_ACE_DNR_GUASSIN_SNR_THRESHOLD:
3335         MDrv_ACE_DNR_SetGuassin_SNR_Threshold(pInstance, eWindow, u16val);
3336         break;
3337 
3338     case E_ACE_DNR_PEAKING_CORING_THRESHOLD:
3339         MDrv_ACE_DNR_SetCoringThreshold(pInstance, eWindow, u16val);
3340         break;
3341 
3342     case E_ACE_DNR_SHARPNESS_ADJUST:
3343         MDrv_ACE_DNR_SetSharpnessAdjust(pInstance, eWindow, u16val);
3344         break;
3345 
3346     case E_ACE_DNR_NM_V:
3347         MDrv_ACE_DNR_SetNM_V(pInstance, eWindow, u16val);
3348         break;
3349 
3350     case E_ACE_DNR_GNR_0:
3351         MDrv_ACE_DNR_SetGNR_0(pInstance, eWindow, u16val);
3352         break;
3353 
3354     case E_ACE_DNR_GNR_1:
3355         MDrv_ACE_DNR_SetGNR_1(pInstance, eWindow, u16val);
3356         break;
3357 
3358     case E_ACE_DNR_CP:
3359         MDrv_ACE_DNR_SetCP(pInstance, eWindow, u16val);
3360         break;
3361 
3362     case E_ACE_DNR_DP:
3363         MDrv_ACE_DNR_SetDP(pInstance, eWindow, u16val);
3364         break;
3365 
3366     case E_ACE_DNR_NM_H_0:
3367         MDrv_ACE_DNR_SetNM_H_0(pInstance, eWindow, u16val);
3368         break;
3369 
3370     case E_ACE_DNR_NM_H_1:
3371         MDrv_ACE_DNR_SetNM_H_1(pInstance, eWindow, u16val);
3372         break;
3373 
3374     case E_ACE_DNR_GRAY_GROUND_GAIN:
3375         MDrv_ACE_DNR_SetGray_Ground_Gain(pInstance, u16val);
3376         break;
3377 
3378     case E_ACE_DNR_GRAY_GROUND_EN:
3379         MDrv_ACE_DNR_SetGray_Ground_En(pInstance, eWindow, u16val);
3380         break;
3381 
3382     case E_ACE_DNR_SC_CORING:
3383         MDrv_ACE_DNR_SetSC_Coring(pInstance, eWindow, u16val);
3384         break;
3385 
3386     case E_ACE_DNR_SPIKE_NR_0:
3387         MDrv_ACE_DNR_SetSpikeNR_0(pInstance, u16val);
3388         break;
3389 
3390     case E_ACE_DNR_SPIKE_NR_1:
3391         MDrv_ACE_DNR_SetSpikeNR_1(pInstance, u16val);
3392         break;
3393 
3394     case E_ACE_DNR_SNR_NM:
3395         MDrv_ACE_DNR_SetSNR_NM(pInstance, u16val);
3396         break;
3397 
3398     default:
3399         ACE_DBG_MSG("XC_ACE_DNR: unknown set Param %u\n", eParam);
3400         break;
3401     }
3402 
3403     XC_ACE_RETURN();
3404 }
3405 
MApi_XC_ACE_DNR_SetParam(MS_BOOL eWindow,XC_ACE_DNR_Param eParam,MS_U16 u16val)3406 void MApi_XC_ACE_DNR_SetParam(MS_BOOL eWindow, XC_ACE_DNR_Param eParam, MS_U16 u16val)
3407 {
3408     if (pu32ACEInst == NULL)
3409     {
3410         printf("ACE not initialized!\n");
3411         return;
3412     }
3413 
3414     stACE_DNR_SetParam ACEArgs;
3415     ACEArgs.eWindow = eWindow;
3416     ACEArgs.eParam = eParam;
3417     ACEArgs.u16val = u16val;
3418     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_SETPARAM, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
3419     {
3420         printf("Obtain ACE engine fail\n");
3421     }
3422     return;
3423 }
3424 
MApi_XC_ACE_DNR_SetNRTbl_U2(void * pInstance,MS_U8 * pu8Tbl)3425 void MApi_XC_ACE_DNR_SetNRTbl_U2(void *pInstance, MS_U8 *pu8Tbl)
3426 {
3427     _ACE_SEMAPHORE_ENTRY(pInstance);
3428     XC_ACE_ENTRY();
3429     MDrv_ACE_DNR_SetNRTable(pInstance, pu8Tbl);
3430     XC_ACE_RETURN();
3431     _ACE_SEMAPHORE_RETURN(pInstance);
3432 }
3433 
MApi_XC_ACE_DNR_SetNRTbl(MS_U8 * pu8Tbl)3434 void MApi_XC_ACE_DNR_SetNRTbl(MS_U8 *pu8Tbl)
3435 {
3436     if (pu32ACEInst == NULL)
3437     {
3438         printf("ACE not initialized!\n");
3439         return;
3440     }
3441 
3442     stACE_DNR_SetNRTbl ACEArgs;
3443     ACEArgs.pu8Tbl = pu8Tbl;
3444     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_DNR_SETNRTBL, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
3445     {
3446         printf("Obtain ACE engine fail\n");
3447     }
3448     return;
3449 }
3450 
MApi_XC_ACE_ColorCorrectionTable_U2(void * pInstance,MS_BOOL bScalerWin,MS_S16 * psColorCorrectionTable)3451 void MApi_XC_ACE_ColorCorrectionTable_U2(void *pInstance, MS_BOOL bScalerWin, MS_S16 *psColorCorrectionTable)
3452 {
3453     _ACE_SEMAPHORE_ENTRY(pInstance);
3454     XC_ACE_ENTRY();
3455     MDrv_ACE_ColorCorrectionTable(pInstance, bScalerWin, psColorCorrectionTable );
3456     XC_ACE_RETURN();
3457     _ACE_SEMAPHORE_RETURN(pInstance);
3458 }
3459 
MApi_XC_ACE_ColorCorrectionTable(MS_BOOL bScalerWin,MS_S16 * psColorCorrectionTable)3460 void MApi_XC_ACE_ColorCorrectionTable( MS_BOOL bScalerWin, MS_S16 *psColorCorrectionTable )
3461 {
3462     if (pu32ACEInst == NULL)
3463     {
3464         printf("ACE not initialized!\n");
3465         return;
3466     }
3467 
3468     stACE_ColorCorrectionTable ACEArgs;
3469     ACEArgs.bScalerWin = bScalerWin;
3470     ACEArgs.psColorCorrectionTable = psColorCorrectionTable;
3471     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_COLORCORRECTIONTABLE, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
3472     {
3473         printf("Obtain ACE engine fail\n");
3474     }
3475     return;
3476 }
3477 
MApi_XC_ACE_SetColorMatrixControl_U2(void * pInstance,MS_BOOL bScalerWin,MS_BOOL bEnable)3478 void MApi_XC_ACE_SetColorMatrixControl_U2(void *pInstance, MS_BOOL bScalerWin, MS_BOOL bEnable)
3479 {
3480     _ACE_SEMAPHORE_ENTRY(pInstance);
3481     XC_ACE_ENTRY();
3482     MDrv_ACE_SetColorMatrixControl(pInstance, bScalerWin, bEnable );
3483     XC_ACE_RETURN();
3484     _ACE_SEMAPHORE_RETURN(pInstance);
3485 }
3486 
MApi_XC_ACE_SetColorMatrixControl(MS_BOOL bScalerWin,MS_BOOL bEnable)3487 void MApi_XC_ACE_SetColorMatrixControl( MS_BOOL bScalerWin, MS_BOOL bEnable )
3488 {
3489     if (pu32ACEInst == NULL)
3490     {
3491         printf("ACE not initialized!\n");
3492         return;
3493     }
3494 
3495     stACE_SetColorMatrixControl ACEArgs;
3496     ACEArgs.bScalerWin = bScalerWin;
3497     ACEArgs.bEnable = bEnable;
3498     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETCOLORMATRIXCONTROL, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
3499     {
3500         printf("Obtain ACE engine fail\n");
3501     }
3502     return;
3503 }
3504 
MApi_XC_ACE_SetRBChannelRange_U2(void * pInstance,MS_BOOL bScalerWin,MS_BOOL bRange)3505 void MApi_XC_ACE_SetRBChannelRange_U2(void *pInstance, MS_BOOL bScalerWin, MS_BOOL bRange)
3506 {
3507     _ACE_SEMAPHORE_ENTRY(pInstance);
3508     XC_ACE_ENTRY();
3509     MDrv_ACE_SetRBChannelRange(pInstance, bScalerWin, bRange );
3510     XC_ACE_RETURN();
3511     _ACE_SEMAPHORE_RETURN(pInstance);
3512 }
3513 
MApi_XC_ACE_SetRBChannelRange(MS_BOOL bScalerWin,MS_BOOL bRange)3514 void MApi_XC_ACE_SetRBChannelRange( MS_BOOL bScalerWin, MS_BOOL bRange )
3515 {
3516     if (pu32ACEInst == NULL)
3517     {
3518         printf("ACE not initialized!\n");
3519         return;
3520     }
3521 
3522     stACE_SetRBChannelRange ACEArgs;
3523     ACEArgs.bScalerWin = bScalerWin;
3524     ACEArgs.bRange = bRange;
3525     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SETRBCHANNELRANGE, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
3526     {
3527         printf("Obtain ACE engine fail\n");
3528     }
3529     return;
3530 }
3531 
3532 #define LOGTIMECOST  FALSE
MApi_XC_ACE_SetPowerState_U2(void * pInstance,EN_POWER_MODE enPowerState)3533 MS_U32 MApi_XC_ACE_SetPowerState_U2(void* pInstance, EN_POWER_MODE enPowerState)
3534 {
3535     static EN_POWER_MODE _enPrevPowerState = E_POWER_MECHANICAL;
3536     MS_U32 u32Ret = UTOPIA_STATUS_FAIL;
3537 
3538 #if LOGTIMECOST
3539     MS_U32 u32Begin = MsOS_GetSystemTime();
3540 #endif
3541 #ifdef MSOS_TYPE_LINUX_KERNEL
3542     void *pModule;
3543     UtopiaInstanceGetModule(pInstance, &pModule);
3544     ACE_REGS_SAVE_AREA *pACEResourceStr = NULL;
3545     UtopiaModuleGetSTRPrivate(pModule, (void**)&pACEResourceStr);
3546 #endif
3547 
3548     if (enPowerState == E_POWER_SUSPEND)
3549     {
3550         _enPrevPowerState = enPowerState;
3551         u32Ret = UTOPIA_STATUS_SUCCESS;
3552     }
3553     else if (enPowerState == E_POWER_RESUME)
3554     {
3555         if (_enPrevPowerState == E_POWER_SUSPEND)
3556         {
3557             _ACE_SEMAPHORE_ENTRY(pInstance);
3558             MDrv_ACE_SetSkipWaitVsync(pInstance,MAIN_WINDOW, TRUE);
3559             MDrv_ACE_SetSkipWaitVsync(pInstance,SUB_WINDOW, TRUE);
3560             _ACE_GET_VARIABLE();
3561             MS_BOOL bRet = _MApi_XC_ACE_Init_WithoutCreateMutex(pInstance, &g_XC_ACE_InitData, TRUE);
3562 #ifdef MSOS_TYPE_LINUX_KERNEL
3563             XC_ACE_ENTRY();
3564             //arbiter STR
3565             //E_ACE_CMD_COLORCORRECTIONTABLE
3566             MDrv_ACE_ColorCorrectionTable(pInstance, MAIN_WINDOW, psACEResPri->stdrvACE.s_AceInfo[MAIN_WINDOW].psColorCorrectionMatrix);
3567             //E_ACE_CMD_SETPCYUV2RGB
3568             MDrv_ACE_PCForceYUVtoRGB(pInstance, MAIN_WINDOW , pACEResourceStr->bSetPCYUV2RGB_Enable);
3569             //E_ACE_CMD_PICSETPOSTCOLORTEMP_V02
3570             MDrv_ACE_PicSetPostRGBGainOffset(pInstance, MAIN_WINDOW,
3571                                      pACEResourceStr->stColorTemp.cRedColor,  pACEResourceStr->stColorTemp.cGreenColor,
3572                                      pACEResourceStr->stColorTemp.cBlueColor, pACEResourceStr->stColorTemp.cRedOffset,
3573                                      pACEResourceStr->stColorTemp.cGreenOffset, pACEResourceStr->stColorTemp.cBlueOffset, 0);
3574             if(pACEResourceStr->bUseYUVSpace)
3575             {
3576                 //E_ACE_CMD_PICSETCONTRAST
3577                 MDrv_ACE_PicSetContrast(pInstance, MAIN_WINDOW, pACEResourceStr->bUseYUVSpace, pACEResourceStr->u8Contrast);
3578             }
3579             //E_ACE_CMD_PICSETBRIGHTNESS
3580             MDrv_ACE_SetBrightness(pInstance, MAIN_WINDOW, pACEResourceStr->u8Brightness_R, pACEResourceStr->u8Brightness_G, pACEResourceStr->u8Brightness_B);
3581             //E_ACE_CMD_PICSETHUE
3582             //E_ACE_CMD_PICSETSATURATION
3583             if(pACEResourceStr->bUseYUVSpace)
3584             {
3585                 MDrv_ACE_SetHue(pInstance, MAIN_WINDOW, pACEResourceStr->u8Hue);
3586                 MDrv_ACE_SetSaturation(pInstance, MAIN_WINDOW, pACEResourceStr->u8Saturation);
3587             }
3588             //E_ACE_CMD_PICSETSHARPNESS
3589             MDrv_ACE_SetSharpness(pInstance, MAIN_WINDOW, pACEResourceStr->u8Sharpness);
3590             XC_ACE_RETURN();
3591 #endif
3592             MDrv_ACE_SetSkipWaitVsync(pInstance,MAIN_WINDOW, FALSE);
3593             MDrv_ACE_SetSkipWaitVsync(pInstance,SUB_WINDOW, FALSE);
3594             _ACE_SEMAPHORE_RETURN(pInstance);
3595             if(bRet == TRUE)
3596             {
3597                 u32Ret = UTOPIA_STATUS_SUCCESS;
3598             }
3599             else
3600             {
3601                 printf("[%s,%5d]ACE init fail!\n",__FUNCTION__,__LINE__);
3602                 u32Ret = UTOPIA_STATUS_FAIL;
3603             }
3604             _enPrevPowerState = enPowerState;
3605         }
3606         else
3607         {
3608             printf("[%s,%5d]It is not suspended yet. We shouldn't resume\n",__FUNCTION__,__LINE__);
3609             u32Ret = UTOPIA_STATUS_FAIL;
3610         }
3611     }
3612     else
3613     {
3614         printf("[%s,%5d]Do Nothing: %u\n",__FUNCTION__,__LINE__,enPowerState);
3615         u32Ret = UTOPIA_STATUS_FAIL;
3616     }
3617 
3618 
3619 #if LOGTIMECOST
3620     printf("=========[%s,%5d] cost %lu ms========\n", __FUNCTION__, __LINE__, MsOS_GetSystemTime() - u32Begin);
3621 #endif
3622 
3623     return u32Ret;
3624 }
3625 
MApi_XC_ACE_SetPowerState(EN_POWER_MODE enPowerState)3626 MS_U32 MApi_XC_ACE_SetPowerState(EN_POWER_MODE enPowerState)
3627 {
3628     if (pu32ACEInst == NULL)
3629     {
3630         printf("ACE not initialized!\n");
3631         return UTOPIA_STATUS_FAIL;
3632     }
3633 
3634     stACE_Set_PowerState ACEArgs;
3635     ACEArgs.enPowerState = enPowerState;
3636     ACEArgs.u32Return = UTOPIA_STATUS_FAIL;
3637     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SET_POWERSTATE, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
3638     {
3639         printf("Obtain ACE engine fail\n");
3640     }
3641     return ACEArgs.u32Return;
3642 }
3643 
_XC_ACE_GET_DEVICE_NUM(void)3644 MS_U32 _XC_ACE_GET_DEVICE_NUM(void)
3645 {
3646     return MDrv_ACE_GetDeviceNum();
3647 }
3648 
MApi_XC_ACE_SetHDRInit_U2(void * pInstance,XC_ACE_HDRinit * pstACE_HDRInitData)3649 MS_BOOL MApi_XC_ACE_SetHDRInit_U2(void * pInstance ,XC_ACE_HDRinit * pstACE_HDRInitData)
3650 {
3651     MS_BOOL bReturn=FALSE;
3652     MS_U16 u16CopiedLength = sizeof(XC_ACE_HDRinit);
3653 
3654     if((NULL == pstACE_HDRInitData) || (pstACE_HDRInitData->u16HDRInitLength == 0))
3655     {
3656         //We cosider compatible operation form version2 , so reject the info init when version invalid
3657         printf("MApi_XC_ACE_SetHDRInit: Null paramter or Wrong u16HDRInitLength!!\n");
3658         return bReturn;
3659     }
3660 
3661     // the version control is coming in with version 1
3662     if(pstACE_HDRInitData->u16HDRVerInfo < 1)
3663     {
3664         //We cosider compatible operation form version1 , so reject the info init when version invalid
3665         printf("MApi_XC_ACE_SetHDRInit: please check your u16HDRVerInfo, it should not set to 0!!\n");
3666         return bReturn;
3667     }
3668 
3669     if(pstACE_HDRInitData->u16HDRVerInfo > XC_ACE_HDR_VERSION)
3670     {
3671         //We cosider compatible operation form version1 , so reject the info init when version invalid
3672 #if defined (__aarch64__)
3673         printf("MApi_XC_ACE_SetHDRInit: this old version ACE lib has only length:%lu driver status!!\n",sizeof(XC_ACE_HDRinit));
3674 #else
3675         printf("MApi_XC_ACE_SetHDRInit: this old version ACE lib has only length:%u driver status!!\n",sizeof(XC_ACE_HDRinit));
3676 #endif
3677         //we still copy the min size of both structure, but AP should take care of it.
3678         u16CopiedLength = sizeof(XC_ACE_HDRinit);
3679     }
3680 
3681     //old AP + new lib, driver shouldn't access to the space which doesn't exist in old structure
3682     if((pstACE_HDRInitData->u16HDRVerInfo < XC_ACE_HDR_VERSION) || (pstACE_HDRInitData->u16HDRInitLength < sizeof(XC_ACE_HDRinit)))
3683     {
3684         //We cosider compatible operation form version1 , so reject the info init when version invalid
3685         printf("MApi_XC_ACE_SetHDRInit : new version ACE lib shouldn't access to the space which doesn't exist in old structure!!\n");
3686         u16CopiedLength = pstACE_HDRInitData->u16HDRInitLength;
3687     }
3688 
3689     ACE_DRV_HDRinit ACE_HDRInitInfo;
3690     memset(&ACE_HDRInitInfo, 0 , sizeof(ACE_DRV_HDRinit));
3691     memcpy(&ACE_HDRInitInfo, pstACE_HDRInitData, u16CopiedLength);
3692     ACE_HDRInitInfo.u16HDRInitLength = u16CopiedLength;
3693 
3694     bReturn=MDrv_ACE_SetHDRInit(pInstance ,&ACE_HDRInitInfo);
3695 
3696     return bReturn;
3697 }
3698 
MApi_XC_ACE_SetHDRInit(XC_ACE_HDRinit * pstACE_HDRInitData)3699 MS_BOOL SYMBOL_WEAK MApi_XC_ACE_SetHDRInit(XC_ACE_HDRinit *pstACE_HDRInitData)
3700 {
3701     if (pu32ACEInst == NULL)
3702     {
3703         printf("ACE not initialized!\n");
3704         return FALSE;
3705     }
3706 
3707     stACE_SetHDRInitData ACEArgs;
3708     ACEArgs.pstHDRInitData = pstACE_HDRInitData;
3709 
3710      ACEArgs.bReturn = FALSE ;
3711 
3712     // wait until Jesse.Huang set the definition of return value, I will exchange this with another return value
3713     // instead of 0
3714     if(UtopiaIoctl(pu32ACEInst, E_ACE_CMD_SET_HDR_INFO, (void*)&ACEArgs) != UTOPIA_STATUS_SUCCESS)
3715     {
3716         printf("Obtain ACE engine fail\n");
3717         return FALSE ;
3718     }
3719     else
3720     {
3721         return ACEArgs.bReturn;
3722     }
3723 }
3724 
3725 
3726 #undef _API_XC_ACE_C_
3727 #endif  // _API_XC_ACE_C_
3728 
3729