1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 // Software and any modification/derivatives thereof.
18 // No right, ownership, or interest to MStar Software and any
19 // modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 // supplied together with third party`s software and the use of MStar
23 // Software may require additional licenses from third parties.
24 // Therefore, you hereby agree it is your sole responsibility to separately
25 // obtain any and all third party right and license necessary for your use of
26 // such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 // MStar`s confidential information and you agree to keep MStar`s
30 // confidential information in strictest confidence and not disclose to any
31 // third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 // kind. Any warranties are hereby expressly disclaimed by MStar, including
35 // without limitation, any warranties of merchantability, non-infringement of
36 // intellectual property rights, fitness for a particular purpose, error free
37 // and in conformity with any international standard. You agree to waive any
38 // claim against MStar for any loss, damage, cost or expense that you may
39 // incur related to your use of MStar Software.
40 // In no event shall MStar be liable for any direct, indirect, incidental or
41 // consequential damages, including without limitation, lost of profit or
42 // revenues, lost or damage of data, and unauthorized system use.
43 // You agree that this Section 4 shall still apply without being affected
44 // even if MStar Software has been modified by MStar in accordance with your
45 // request or instruction for your use, except otherwise agreed by both
46 // parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 // services in relation with MStar Software to you for your use of
50 // MStar Software in conjunction with your or your customer`s product
51 // ("Services").
52 // You understand and agree that, except otherwise agreed by both parties in
53 // writing, Services are provided on an "AS IS" basis and the warranty
54 // disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 // or otherwise:
58 // (a) conferring any license or right to use MStar name, trademark, service
59 // mark, symbol or any other identification;
60 // (b) obligating MStar or any of its affiliates to furnish any person,
61 // including without limitation, you and your customers, any assistance
62 // of any kind whatsoever, or any information; or
63 // (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 // of Taiwan, R.O.C., excluding its conflict of law rules.
67 // Any and all dispute arising out hereof or related hereto shall be finally
68 // settled by arbitration referred to the Chinese Arbitration Association,
69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 // Rules of the Association by three (3) arbitrators appointed in accordance
71 // with the said Rules.
72 // The place of arbitration shall be in Taipei, Taiwan and the language shall
73 // be English.
74 // The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // ("MStar Confidential Information") by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 //
93 /// file drv_ACE.c
94 /// @brief Driver Interface
95 /// @author MStar Semiconductor Inc.
96 ///////////////////////////////////////////////////////////////////////////////////////////////////
97
98
99 #define _MDRV_ACE_C_
100 #ifdef MSOS_TYPE_LINUX_KERNEL
101 #include <linux/string.h>
102 #else
103 #include <string.h>
104 #endif
105 #include "MsCommon.h"
106 #include "apiXC_Ace.h"
107 #include "drvACE.h"
108 #include "mhal_ace.h"
109 #include "hwreg_ace.h"
110 #include "ace_hwreg_utility2.h"
111 #include "MsAce_LIB.h"
112
113 ////////////////////////////////////////////////////////////////////////////////
114 //
115 // ACE library function start
116 //
117 ////////////////////////////////////////////////////////////////////////////////
118
119 MS_U8 ACE_VBuf[32] = {
120 'M','S','V','C','0','0', //0,0 fixed
121 'A','4', //LIB ID
122 '0','0', //Interface
123 '0','1','0','4', //Build number
124 '0','0','0','8','9','9','8','3', // Change List
125 'A','E','0','0','0','0','0','0','0', // AE:Saturn4LE 0: MStar Trunk
126 'T' // check sum
127 };
128
129 //-------------------------------------------------------------------------------------------------
130 // Local Defines
131 //-------------------------------------------------------------------------------------------------
132 #define MAIN_WINDOW 0
133 #define SUB_WINDOW 1
134
135 // for Utopia 2.0 to Utopia 1.0 compatibility.
136 #include "ACE_private.h"
137 #include "utopia_dapi.h"
138 #include "utopia.h"
139
140 extern void* pu32ACEInst;
141 extern void* pu32ACERes[E_ACE_POOL_ID_MAX];
142 extern ACE_DRV_HDRinit g_ACEinitParameters;
143 #if 0
144 typedef struct
145 {
146 MS_U16 u16RedGain;
147 MS_U16 u16GreenGain;
148 MS_U16 u16BlueGain;
149 } ACE_PostRGBGainSetting;
150
151 static ACE_PostRGBGainSetting stACEPostGainSetting[XC_ACE_EX_MAX_DEVICE_NUM][2];
152 #else
153 #define stACEPostGainSetting psACEResPri->stdrvACE.stACEPostGainSetting
154 #define MWEPanel psACEResPri->stdrvACE.MWEPanel
155 #endif
156 /******************************************************************************/
157 /* Function Prototypes */
158 /******************************************************************************/
159 ////////////////////////////////////////////////////////////////////////////////
160 /// @brief \b Function \b Name: MDrv_ACE_GetVersion()
161 /// @brief \b Function \b Description: Get version of ACE library
162 /// @param <IN> \b None
163 /// @param <OUT> \b None
164 /// @param <RET> \b Version
165 /// @param <GLOBAL> \b None
166 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_GetVersion(void)167 MS_U16 MDrv_ACE_GetVersion(void)
168 {
169 return msACE_GetVersion();
170 }
171
172 ////////////////////////////////////////////////////////////////////////////////
173 /// @brief \b Function \b Name: void MDrv_ACE_Init( MS_BOOL bScalerWin, MS_S16* psColorCorrectionTable, MS_S16* psPCsRGBTable )
174 /// @brief \b Function \b Description: Initialize ACE varible
175 /// @param <IN> \b None
176 /// @param <OUT> \b None
177 /// @param <RET> \b None
178 /// @param <GLOBAL> \b None
179 ////////////////////////////////////////////////////////////////////////////////
180
MDrv_ACE_Init(void * pInstance,MS_BOOL bScalerWin,MS_S16 * psColorCorrectionTable,MS_S16 * psPCsRGBTable)181 void MDrv_ACE_Init(void* pInstance, MS_BOOL bScalerWin, MS_S16* psColorCorrectionTable, MS_S16* psPCsRGBTable )
182 {
183 _ACE_GET_VARIABLE();
184 memset(stACEPostGainSetting, 0, sizeof(stACEPostGainSetting));
185
186 if(psACEResPri->stapiACE.g_bACEModuleInited[bScalerWin] == FALSE)
187 {
188 InitACEVar(pInstance);
189 msACEPCForceYUVtoRGB(pInstance, bScalerWin, TRUE);
190 }
191 msACESetColorCorrectionTable(pInstance, bScalerWin, psColorCorrectionTable);
192 msACESetPCsRGBTable(pInstance, bScalerWin, psPCsRGBTable);
193 Hal_ACE_Set_Device_Bank_Offset();
194 }
195
196 ////////////////////////////////////////////////////////////////////////////////
197 /// @brief \b Function \b Name: MDrv_ACE_PCForceYUVtoRGB()
198 /// @brief \b Function \b Description: Force transfer YUV to RGB
199 /// @param <IN> \b bScalerWin
200 /// @param <IN> \b bEnable
201 /// @param <OUT> \b None
202 /// @param <RET> \b None
203 /// @param <GLOBAL> \b None
204 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_PCForceYUVtoRGB(void * pInstance,MS_BOOL bScalerWin,MS_BOOL bEnable)205 void MDrv_ACE_PCForceYUVtoRGB(void* pInstance, MS_BOOL bScalerWin, MS_BOOL bEnable )
206 {
207 msACEPCForceYUVtoRGB(pInstance, bScalerWin, bEnable);
208 }
209
210 ////////////////////////////////////////////////////////////////////////////////
211 /// @brief \b Function \b Name: MDrv_ACE_PicSetContrast()
212 /// @brief \b Function \b Description: Adjust Contrast
213 /// @param <IN> \b bScalerWin
214 /// @param <IN> \b u8Contrast
215 /// @param <OUT> \b None
216 /// @param <RET> \b None
217 /// @param <GLOBAL> \b None
218 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_PicSetContrast(void * pInstance,MS_BOOL bScalerWin,MS_BOOL bUseYUVSpace,MS_U8 u8Contrast)219 void MDrv_ACE_PicSetContrast(void* pInstance, MS_BOOL bScalerWin, MS_BOOL bUseYUVSpace, MS_U8 u8Contrast )
220 {
221 msAdjustVideoContrast(pInstance, bScalerWin, u8Contrast);
222 }
223
224 ////////////////////////////////////////////////////////////////////////////////
225 /// @brief \b Function \b Name: MDrv_ACE_PicSetRGB()
226 /// @brief \b Function \b Description: Adjust RGB
227 /// @param <IN> \b bScalerWin
228 /// @param <IN> \b u8Red
229 /// @param <IN> \b u8Green
230 /// @param <IN> \b u8Blue
231 /// @param <OUT> \b None
232 /// @param <RET> \b None
233 /// @param <GLOBAL> \b None
234 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_PicSetRGB(void * pInstance,MS_BOOL bScalerWin,MS_BOOL bUseYUVSpace,MS_U8 u8Red,MS_U8 u8Green,MS_U8 u8Blue)235 void MDrv_ACE_PicSetRGB(void* pInstance, MS_BOOL bScalerWin, MS_BOOL bUseYUVSpace, MS_U8 u8Red, MS_U8 u8Green, MS_U8 u8Blue )
236 {
237 if(bUseYUVSpace)
238 {
239 msAdjustVideoRGB(pInstance, bScalerWin, u8Red, u8Green, u8Blue);
240 }
241 else
242 {
243 msAdjustPCRGB(pInstance, bScalerWin, u8Red, u8Green, u8Blue);
244 }
245 }
246
247 ////////////////////////////////////////////////////////////////////////////////
248 /// @brief \b Function \b Name: MDrv_ACE_PicSetRGB_10Bits()
249 /// @brief \b Function \b Description: Adjust RGB
250 /// @param <IN> \b bScalerWin
251 /// @param <IN> \b u16Red
252 /// @param <IN> \b u16Green
253 /// @param <IN> \b u16Blue
254 /// @param <OUT> \b None
255 /// @param <RET> \b None
256 /// @param <GLOBAL> \b None
257 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_PicSetRGB_10Bits(void * pInstance,MS_BOOL bScalerWin,MS_BOOL bUseYUVSpace,MS_U16 u16Red,MS_U16 u16Green,MS_U16 u16Blue)258 void MDrv_ACE_PicSetRGB_10Bits( void* pInstance, MS_BOOL bScalerWin, MS_BOOL bUseYUVSpace, MS_U16 u16Red, MS_U16 u16Green, MS_U16 u16Blue )
259 {
260 if(bUseYUVSpace)
261 {
262 msAdjustVideoRGB_10Bits(pInstance, bScalerWin, u16Red, u16Green, u16Blue);
263 }
264 else
265 {
266 msAdjustPCRGB_10Bits(pInstance, bScalerWin, u16Red, u16Red, u16Red);
267 }
268 }
269
270 ////////////////////////////////////////////////////////////////////////////////
271 /// @brief \b Function \b Name: MDrv_ACE_PicSetPostRGBGainOffset()
272 /// @brief \b Function \b Description: Adjust Post RGB Gain and Offset simultaneously
273 /// @param <IN> \b bScalerWin
274 /// @param <IN> \b u8RedGain
275 /// @param <IN> \b u8GreenGain
276 /// @param <IN> \b u8BlueGain
277 /// @param <IN> \b u16RedOffset
278 /// @param <IN> \b u16GreenOffset
279 /// @param <IN> \b u16BlueOffset
280 /// @param <OUT> \b None
281 /// @param <RET> \b None
282 /// @param <GLOBAL> \b None
283 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_PicSetPostRGBGainOffset(void * pInstance,MS_BOOL bScalerWin,MS_U16 u8RedGain,MS_U16 u8GreenGain,MS_U16 u8BlueGain,MS_U16 u16RedOffset,MS_U16 u16GreenOffset,MS_U16 u16BlueOffset,MS_U8 u8Step)284 void MDrv_ACE_PicSetPostRGBGainOffset(void* pInstance, MS_BOOL bScalerWin,
285 MS_U16 u8RedGain, MS_U16 u8GreenGain, MS_U16 u8BlueGain,
286 MS_U16 u16RedOffset, MS_U16 u16GreenOffset, MS_U16 u16BlueOffset, MS_U8 u8Step)
287 {
288 MS_U8 u8Idx;
289
290 u8Idx = (bScalerWin == TRUE) ? 1 : 0;
291 _ACE_GET_VARIABLE();
292
293 stACEPostGainSetting[u8Idx].u16RedGain = u8RedGain ;
294 stACEPostGainSetting[u8Idx].u16GreenGain = u8GreenGain ;
295 stACEPostGainSetting[u8Idx].u16BlueGain = u8BlueGain ;
296
297 Hal_ACE_SetPostRGBGainOffsetTogether(pInstance, bScalerWin,
298 stACEPostGainSetting[u8Idx].u16RedGain,
299 stACEPostGainSetting[u8Idx].u16GreenGain,
300 stACEPostGainSetting[u8Idx].u16BlueGain,
301 u16RedOffset << u8Step,
302 u16GreenOffset << u8Step,
303 u16BlueOffset << u8Step);
304 }
305
306 ////////////////////////////////////////////////////////////////////////////////
307 /// @brief \b Function \b Name: MDrv_ACE_PicSetPostRGBGain()
308 /// @brief \b Function \b Description: Adjust Post RGB Gain
309 /// @param <IN> \b bScalerWin
310 /// @param <IN> \b u8RedGain
311 /// @param <IN> \b u8GreenGain
312 /// @param <IN> \b u8BlueGain
313 /// @param <OUT> \b None
314 /// @param <RET> \b None
315 /// @param <GLOBAL> \b None
316 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_PicSetPostRGBGain(void * pInstance,MS_BOOL bScalerWin,MS_U16 u8RedGain,MS_U16 u8GreenGain,MS_U16 u8BlueGain)317 void MDrv_ACE_PicSetPostRGBGain(void* pInstance, MS_BOOL bScalerWin, MS_U16 u8RedGain, MS_U16 u8GreenGain, MS_U16 u8BlueGain)
318 {
319 MS_U8 u8Idx;
320
321 u8Idx = (bScalerWin == TRUE) ? 1 : 0;
322 _ACE_GET_VARIABLE();
323
324 stACEPostGainSetting[u8Idx].u16RedGain = u8RedGain ;
325 stACEPostGainSetting[u8Idx].u16GreenGain = u8GreenGain ;
326 stACEPostGainSetting[u8Idx].u16BlueGain = u8BlueGain ;
327
328 Hal_ACE_SetPostRGBGain(pInstance, bScalerWin,
329 stACEPostGainSetting[u8Idx].u16RedGain,
330 stACEPostGainSetting[u8Idx].u16GreenGain,
331 stACEPostGainSetting[u8Idx].u16BlueGain);
332 }
333
334 ////////////////////////////////////////////////////////////////////////////////
335 /// @brief \b Function \b Name: MDrv_ACE_PicGetPostRGBGain()
336 /// @brief \b Function \b Description: Get ACE Post RGB Gain Info
337 /// @param <IN> \b bScalerWin
338 /// @param <IN> \b ucInfoType
339 /// @param <OUT> \b None
340 /// @param <RET> \b wReturnValue
341 /// @param <GLOBAL> \b None
342 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_PicGetPostRGBGain(void * pInstance,MS_BOOL bWindow,MS_U16 u16ACEinfo)343 MS_U16 MDrv_ACE_PicGetPostRGBGain(void* pInstance, MS_BOOL bWindow, MS_U16 u16ACEinfo)
344 {
345 EnuACEInfoType eACEInfoType = (EnuACEInfoType) u16ACEinfo;
346 MS_U16 u16ReturnValue = 0;
347 MS_U8 u8Idx;
348 _ACE_GET_VARIABLE();
349
350 u8Idx = (bWindow == TRUE) ? 1 : 0;
351
352 switch( eACEInfoType )
353 {
354 case ACE_INFO_TYPE_R_GAIN:
355 u16ReturnValue = stACEPostGainSetting[u8Idx].u16RedGain;
356 break;
357
358 case ACE_INFO_TYPE_G_GAIN:
359 u16ReturnValue = stACEPostGainSetting[u8Idx].u16GreenGain;
360 break;
361
362 case ACE_INFO_TYPE_B_GAIN:
363 u16ReturnValue = stACEPostGainSetting[u8Idx].u16BlueGain;
364 break;
365
366 default:
367 {
368 MS_DEBUG_MSG(printf("Get Post RGB Gain fails\n"));
369 u16ReturnValue = 0;
370 break;
371 }
372 }
373 return u16ReturnValue;
374 }
375
376 ////////////////////////////////////////////////////////////////////////////////
377 /// @brief \b Function \b Name: MDrv_ACE_PicSetPostRGBOffset()
378 /// @brief \b Function \b Description: Adjust Post RGB Offset
379 /// @param <IN> \b bScalerWin
380 /// @param <IN> \b u16RedOffset
381 /// @param <IN> \b u16GreenOffset
382 /// @param <IN> \b u16BlueOffset
383 /// @param <IN> \b u8Step
384 /// @param <OUT> \b None
385 /// @param <RET> \b None
386 /// @param <GLOBAL> \b None
387 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_PicSetPostRGBOffset(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16RedOffset,MS_U16 u16GreenOffset,MS_U16 u16BlueOffset,MS_U8 u8Step)388 void MDrv_ACE_PicSetPostRGBOffset(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16RedOffset, MS_U16 u16GreenOffset, MS_U16 u16BlueOffset, MS_U8 u8Step)
389 {
390 Hal_ACE_SetPostRGBOffset(pInstance, bScalerWin, u16RedOffset << u8Step, u16GreenOffset << u8Step, u16BlueOffset << u8Step);
391 }
392
393 ////////////////////////////////////////////////////////////////////////////////
394 /// @brief \b Function \b Name: MDrv_ACE_PicGetPostRGBGain()
395 /// @brief \b Function \b Description: Get ACE Post RGB Gain Info
396 /// @param <IN> \b bScalerWin
397 /// @param <IN> \b ucInfoType
398 /// @param <OUT> \b None
399 /// @param <RET> \b wReturnValue
400 /// @param <GLOBAL> \b None
401 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_PicGetPostRGBOffset(void * pInstance,MS_BOOL bWindow,MS_U16 u16ACEinfo)402 MS_U16 MDrv_ACE_PicGetPostRGBOffset(void* pInstance, MS_BOOL bWindow, MS_U16 u16ACEinfo)
403 {
404 EnuACEInfoType eACEInfoType = (EnuACEInfoType) u16ACEinfo;
405 MS_U16 u16ReturnValue = 0;
406 _ACE_GET_INST_PRIVATE();
407
408 switch( eACEInfoType )
409 {
410 case ACE_INFO_TYPE_COLOR_CORRECTION_OFFSET_R:
411 {
412 if(MAIN_WINDOW == bWindow)
413 {
414 u16ReturnValue = SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK25_21_L, 0x07FF);
415 }
416 else
417 {
418 u16ReturnValue = SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK25_27_L, 0x07FF);
419 }
420 break;
421 }
422 case ACE_INFO_TYPE_COLOR_CORRECTION_OFFSET_G:
423 {
424 if(MAIN_WINDOW == bWindow)
425 {
426 u16ReturnValue = SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK25_22_L, 0x07FF);
427 }
428 else
429 {
430 u16ReturnValue = SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK25_28_L, 0x07FF);
431 }
432 break;
433 }
434 case ACE_INFO_TYPE_COLOR_CORRECTION_OFFSET_B:
435 {
436 if(MAIN_WINDOW == bWindow)
437 {
438 u16ReturnValue = SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK25_23_L, 0x07FF);
439 }
440 else
441 {
442 u16ReturnValue = SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK25_29_L, 0x07FF);
443 }
444 break;
445 }
446 default:
447 {
448 MS_DEBUG_MSG(printf("Get Post RGB Offset fails\n"));
449 u16ReturnValue = 0;
450 break;
451 }
452 }
453 return u16ReturnValue;
454 }
455
MDrv_ACE_GetPostRGBGain(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16ACEinfo)456 MS_U8 MDrv_ACE_GetPostRGBGain(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16ACEinfo)
457 {
458 EnuACEInfoType eACEInfoType;
459 eACEInfoType = (EnuACEInfoType) u16ACEinfo;
460 MS_U8 ret = 0;
461 _ACE_GET_INST_PRIVATE();
462
463 if(MAIN_WINDOW == bScalerWin)
464 {
465 switch(eACEInfoType)
466 {
467 case ACE_INFO_TYPE_R_GAIN:
468 ret = (MS_U8)(SC_R2BYTEMSK(psACEInstPri->u32DeviceID, POST_R_CHANNEL_GAIN_MAIN, POST_R_CHANNEL_GAIN_MASK)>> 3);
469 break;
470 case ACE_INFO_TYPE_G_GAIN:
471 ret = (MS_U8)(SC_R2BYTEMSK(psACEInstPri->u32DeviceID, POST_G_CHANNEL_GAIN_MAIN, POST_G_CHANNEL_GAIN_MASK)>> 3);
472 break;
473 case ACE_INFO_TYPE_B_GAIN:
474 ret = (MS_U8)(SC_R2BYTEMSK(psACEInstPri->u32DeviceID, POST_B_CHANNEL_GAIN_MAIN, POST_B_CHANNEL_GAIN_MASK)>> 3);
475 break;
476 default:
477 ret = 0;
478 break;
479 }
480 }
481 else
482 #if (MAX_WINDOW_NUM > 1)
483 {
484 switch(eACEInfoType)
485 {
486 case ACE_INFO_TYPE_R_GAIN:
487 ret = (MS_U8)(SC_R2BYTEMSK(psACEInstPri->u32DeviceID, POST_R_CHANNEL_GAIN_SUB, POST_R_CHANNEL_GAIN_MASK)>>3);
488 break;
489 case ACE_INFO_TYPE_G_GAIN:
490 ret = (MS_U8)(SC_R2BYTEMSK(psACEInstPri->u32DeviceID, POST_G_CHANNEL_GAIN_SUB, POST_G_CHANNEL_GAIN_MASK)>>3);
491 break;
492 case ACE_INFO_TYPE_B_GAIN:
493 ret = (MS_U8)(SC_R2BYTEMSK(psACEInstPri->u32DeviceID, POST_B_CHANNEL_GAIN_SUB, POST_B_CHANNEL_GAIN_MASK)>>3);
494 break;
495 default:
496 ret = 0;
497 break;
498 }
499 }
500 #else
501 {
502 ret = 0;
503 }
504 #endif
505 MS_DEBUG_MSG(printf("[MDrv_ACE_GetPostRGBGain] ret = %d\n", ret));
506 return ret;
507 }
508
509 ////////////////////////////////////////////////////////////////////////////////
510 /// @brief \b Function \b Name: MDrv_ACE_SelectYUVtoRGBMatrix()
511 /// @brief \b Function \b Description: Select YUV to RGB Matrix
512 /// @param <IN> \b bScalerWin
513 /// @param <IN> \b ucMatrix
514 /// @param <IN> \b psUserYUVtoRGBMatrix
515 /// @param <OUT> \b None
516 /// @param <RET> \b None
517 /// @param <GLOBAL> \b None
518 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_SelectYUVtoRGBMatrix(void * pInstance,MS_BOOL bScalerWin,MS_U8 ucMatrix,MS_S16 * psUserYUVtoRGBMatrix)519 void MDrv_ACE_SelectYUVtoRGBMatrix(void* pInstance, MS_BOOL bScalerWin, MS_U8 ucMatrix, MS_S16* psUserYUVtoRGBMatrix )
520 {
521 msACESelectYUVtoRGBMatrix(pInstance, bScalerWin, ucMatrix, psUserYUVtoRGBMatrix);
522 }
523
524 ////////////////////////////////////////////////////////////////////////////////
525 /// @brief \b Function \b Name: MDrv_ACE_SetColorCorrectionTable()
526 /// @brief \b Function \b Description: Set Color Correction Table
527 /// @param <IN> \b bScalerWin
528 /// @param <IN> \b psColorCorrectionTable
529 /// @param <OUT> \b None
530 /// @param <RET> \b None
531 /// @param <GLOBAL> \b None
532 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_SetColorCorrectionTable(void * pInstance,MS_BOOL bScalerWin)533 void MDrv_ACE_SetColorCorrectionTable(void* pInstance, MS_BOOL bScalerWin)
534 {
535 msSetVideoColorMatrix(pInstance, bScalerWin );
536 }
537
538 ////////////////////////////////////////////////////////////////////////////////
539 /// @brief \b Function \b Name: MDrv_ACE_SetPCsRGBTable()
540 /// @brief \b Function \b Description: Set PCs RGB Table
541 /// @param <IN> \b bScalerWin
542 /// @param <IN> \b psPCsRGBTable
543 /// @param <OUT> \b None
544 /// @param <RET> \b None
545 /// @param <GLOBAL> \b None
546 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_SetPCsRGBTable(void * pInstance,MS_BOOL bScalerWin)547 void MDrv_ACE_SetPCsRGBTable(void* pInstance, MS_BOOL bScalerWin)
548 {
549 msSetPCColorMatrix(pInstance, bScalerWin);
550 }
551
552 ////////////////////////////////////////////////////////////////////////////////
553 /// @brief \b Function \b Name: MDrv_ACE_SetSaturation()
554 /// @brief \b Function \b Description: Adjust Video Saturation
555 /// @param <IN> \b bScalerWin
556 /// @param <IN> \b u8Saturation
557 /// @param <OUT> \b None
558 /// @param <RET> \b None
559 /// @param <GLOBAL> \b None
560 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_SetSaturation(void * pInstance,MS_BOOL bScalerWin,MS_U8 u8Saturation)561 void MDrv_ACE_SetSaturation(void* pInstance, MS_BOOL bScalerWin, MS_U8 u8Saturation )
562 {
563 msAdjustVideoSaturation(pInstance, bScalerWin, u8Saturation);
564 }
565
566 ////////////////////////////////////////////////////////////////////////////////
567 /// @brief \b Function \b Name: MDrv_ACE_SetHue()
568 /// @brief \b Function \b Description: Adjust Video Hue
569 /// @param <IN> \b bScalerWin
570 /// @param <IN> \b u8Hue
571 /// @param <OUT> \b None
572 /// @param <RET> \b None
573 /// @param <GLOBAL> \b None
574 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_SetHue(void * pInstance,MS_BOOL bScalerWin,MS_U8 u8Hue)575 void MDrv_ACE_SetHue(void* pInstance, MS_BOOL bScalerWin, MS_U8 u8Hue )
576 {
577 msAdjustVideoHue(pInstance, bScalerWin, u8Hue);
578 }
579
MDrv_ACE_IsPostRGBGain(void * pInstance,MS_BOOL bWindow)580 MS_BOOL MDrv_ACE_IsPostRGBGain(void* pInstance, MS_BOOL bWindow)
581 {
582 MS_BOOL bRet;
583 _ACE_GET_INST_PRIVATE();
584
585 if (MAIN_WINDOW == bWindow)
586 {
587 bRet = SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK25_01_L, BIT(5)) ? TRUE: FALSE;
588 }
589 else
590 {
591 bRet = SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK25_11_L, BIT(5)) ? TRUE: FALSE;
592 }
593 return bRet;
594 }
595
MDrv_ACE_IsPostRGBOffset(void * pInstance,MS_BOOL bWindow)596 MS_BOOL MDrv_ACE_IsPostRGBOffset(void* pInstance, MS_BOOL bWindow)
597 {
598 MS_BOOL bRet = FALSE;
599 _ACE_GET_INST_PRIVATE();
600
601 if (MAIN_WINDOW == bWindow)
602 {
603 bRet = SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK25_01_L, BIT(4)) ? TRUE: FALSE;
604 }
605 else
606 {
607 bRet = SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK25_11_L, BIT(4)) ? TRUE: FALSE;
608 }
609 return bRet;
610 }
611
612 ////////////////////////////////////////////////////////////////////////////////
613 /// @brief \b Function \b Name: MDrv_ACE_GetInfo()
614 /// @brief \b Function \b Description: Get ACE Info
615 /// @param <IN> \b bScalerWin
616 /// @param <IN> \b ucInfoType
617 /// @param <OUT> \b None
618 /// @param <RET> \b wReturnValue
619 /// @param <GLOBAL> \b None
620 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_GetACEInfo(void * pInstance,MS_BOOL bWindow,MS_U16 u16ACEinfo)621 MS_U16 MDrv_ACE_GetACEInfo(void* pInstance, MS_BOOL bWindow, MS_U16 u16ACEinfo )
622 {
623 EnuACEInfoType eACEInfoType;
624 eACEInfoType = (EnuACEInfoType) u16ACEinfo;
625 _ACE_GET_INST_PRIVATE();
626
627 if(SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK25_01_L, BIT(5)) && ((eACEInfoType == ACE_INFO_TYPE_R_GAIN) || (eACEInfoType == ACE_INFO_TYPE_G_GAIN) || (eACEInfoType == ACE_INFO_TYPE_B_GAIN)))
628 {
629 return MDrv_ACE_PicGetPostRGBGain(pInstance, bWindow, u16ACEinfo);
630 }
631 else if ((eACEInfoType == ACE_INFO_TYPE_BRIGHTNESS_R) || (eACEInfoType == ACE_INFO_TYPE_BRIGHTNESS_G) || (eACEInfoType == ACE_INFO_TYPE_BRIGHTNESS_B))
632 {
633 return MDrv_ACE_GetBrightness(pInstance, bWindow, eACEInfoType);
634 }
635 else
636 return msACE_GetInfo(pInstance, bWindow, eACEInfoType);
637 }
638
639 ////////////////////////////////////////////////////////////////////////////////
640 //
641 // ACE library function end
642 //
643 ////////////////////////////////////////////////////////////////////////////////
644
645
646 ////////////////////////////////////////////////////////////////////////////////
647 //
648 // DrvACE.c start
649 //
650 ////////////////////////////////////////////////////////////////////////////////
MDrv_ACE_DMS(void * pInstance,MS_BOOL bScalerWin,MS_BOOL bisATV)651 void MDrv_ACE_DMS(void* pInstance, MS_BOOL bScalerWin, MS_BOOL bisATV )
652 {
653 Hal_ACE_DMS(pInstance, bScalerWin, bisATV);
654 }
655
MDrv_ACE_GetColorMatrix(void * pInstance,MS_BOOL bScalerWin,MS_U16 * pu16Matrix)656 void MDrv_ACE_GetColorMatrix(void* pInstance, MS_BOOL bScalerWin, MS_U16* pu16Matrix )
657 {
658 Hal_ACE_GetColorMatrix(pInstance, bScalerWin, pu16Matrix);
659 }
660
MDrv_ACE_SetColorMatrix(void * pInstance,MS_BOOL bScalerWin,MS_U16 * pu16Matrix)661 void MDrv_ACE_SetColorMatrix(void* pInstance, MS_BOOL bScalerWin, MS_U16* pu16Matrix )
662 {
663 Hal_ACE_SetColorMatrix(pInstance, bScalerWin, pu16Matrix);
664 }
665
MDrv_ACE_SetBypassColorMatrix(void * pInstance,MS_BOOL bEnable)666 MS_BOOL MDrv_ACE_SetBypassColorMatrix(void* pInstance, MS_BOOL bEnable )
667 {
668 msACESetBypassColorMatrix(pInstance, bEnable);
669 return TRUE;
670 }
671
MDrv_ACE_PatchDTGColorChecker(void * pInstance,MS_U8 u8Mode)672 void MDrv_ACE_PatchDTGColorChecker(void* pInstance, MS_U8 u8Mode)
673 {
674 Hal_ACE_PatchDTGColorChecker(pInstance, u8Mode);
675 }
676
677
MDrv_ACE_SetFleshTone(void * pInstance,MS_BOOL bScalerWin,MS_BOOL bEn,MS_U8 u8FleshTone)678 void MDrv_ACE_SetFleshTone(void* pInstance, MS_BOOL bScalerWin, MS_BOOL bEn, MS_U8 u8FleshTone)
679 {
680 Hal_ACE_SetFCC_En(pInstance, bScalerWin, 0, bEn);
681 Hal_ACE_SetFCC_Cb(pInstance, 0, u8FleshTone);
682 }
683
MDrv_ACE_SetBlackAdjust(void * pInstance,MS_BOOL bScalerWin,MS_U8 u8BlackAdjust)684 void MDrv_ACE_SetBlackAdjust(void* pInstance, MS_BOOL bScalerWin, MS_U8 u8BlackAdjust)
685 {
686 Hal_ACE_SetSlopValue(pInstance, bScalerWin, u8BlackAdjust);
687 }
688
MDrv_ACE_init_riu_base(MS_VIRT ptr_riu_base)689 void MDrv_ACE_init_riu_base(MS_VIRT ptr_riu_base )
690 {
691 Hal_ACE_init_riu_base(ptr_riu_base);
692 }
693
MDrv_ACE_SetSharpness(void * pInstance,MS_BOOL bScalerWin,MS_U8 u8Sharpness)694 void MDrv_ACE_SetSharpness(void* pInstance, MS_BOOL bScalerWin, MS_U8 u8Sharpness )
695 {
696 Hal_ACE_SetSharpness(pInstance, bScalerWin, u8Sharpness);
697 }
698
699 /******************************************************************************/
700 ///Set brightness
701 ///@param u8Brightness \b IN
702 ///- brightness value from 0 -0xff
703 /******************************************************************************/
MDrv_ACE_SetBrightness(void * pInstance,MS_BOOL bScalerWin,MS_U8 u8RedBrightness,MS_U8 u8GreenBrightness,MS_U8 u8BlueBrightness)704 void MDrv_ACE_SetBrightness (void* pInstance, MS_BOOL bScalerWin, MS_U8 u8RedBrightness, MS_U8 u8GreenBrightness, MS_U8 u8BlueBrightness )
705 {
706 Hal_ACE_SetBrightness(pInstance, bScalerWin, u8RedBrightness, u8GreenBrightness, u8BlueBrightness);
707 }
708
709 /******************************************************************************/
710 ///Set brightness
711 ///@param u16Brightness \b IN
712 ///- brightness value from 0-0x7ff
713 /******************************************************************************/
MDrv_ACE_SetBrightnessPrecise(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16RedBrightness,MS_U16 u16GreenBrightness,MS_U16 u16BlueBrightness)714 void MDrv_ACE_SetBrightnessPrecise(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16RedBrightness, MS_U16 u16GreenBrightness, MS_U16 u16BlueBrightness)
715 {
716 Hal_ACE_SetBrightnessPrecise(pInstance, bScalerWin, u16RedBrightness, u16GreenBrightness, u16BlueBrightness);
717 }
718
719 ////////////////////////////////////////////////////////////////////////////////
720 /// @brief \b Function \b Name: MDrv_ACE_GetBrightness()
721 /// @brief \b Function \b Description: Get ACE brightness
722 /// @param <IN> \b pInstance pInstance
723 /// @param <IN> \b bScalerWin bScalerWin
724 /// @param <IN> \b eACEInfoType
725 /// @param <OUT> \b None
726 /// @param <RET> \b u16Val Brightness value from 0-0xff
727 /// @param <GLOBAL> \b None
728 ////////////////////////////////////////////////////////////////////////////////
729
MDrv_ACE_GetBrightness(void * pInstance,MS_BOOL bScalerWin,EnuACEInfoType eACEInfoType)730 MS_U16 MDrv_ACE_GetBrightness(void* pInstance, MS_BOOL bScalerWin, EnuACEInfoType eACEInfoType)
731 {
732 MS_U16 u16Val = 0;
733 MS_U8 u8RedBrightness = 0;
734 MS_U8 u8GreenBrightness = 0;
735 MS_U8 u8BlueBrightness = 0;
736
737 Hal_ACE_GetBrightness(pInstance, bScalerWin, &u8RedBrightness, &u8GreenBrightness, &u8BlueBrightness);
738
739 switch(eACEInfoType)
740 {
741 case ACE_INFO_TYPE_BRIGHTNESS_R:
742 u16Val = (MS_U16) u8RedBrightness;
743 break;
744
745 case ACE_INFO_TYPE_BRIGHTNESS_G:
746 u16Val = (MS_U16) u8GreenBrightness;
747 break;
748
749 case ACE_INFO_TYPE_BRIGHTNESS_B:
750 u16Val = (MS_U16) u8BlueBrightness;
751 break;
752
753 default:
754 u16Val = 0;
755 break;
756 }
757
758 return u16Val;
759 }
760
761
762 #ifdef ENABLE_SET_PRE_Y_OFFSET
763 extern void* pu32ACE_XCInst;
764 extern MLOAD_TYPE MApi_XC_MLoad_GetStatus_U2(void *pInstance);
765 extern MS_BOOL MApi_XC_MLoad_Fire(void *pInstance, MS_BOOL bImmediate);
766 extern MS_BOOL MApi_XC_MLoad_WriteCmd(void *pInstance, MS_U32 u32Addr, MS_U16 u16Data, MS_U16 u16Mask);
767 #endif
768 /******************************************************************************/
769 ///Set Pre Y offset
770 ///@param bScalerMainWin \b IN
771 ///@param u8PreYOffset \b IN
772 ///- u16PreYOffset value from 0 -0xff
773 /// @return @ref MS_BOOL
774 /******************************************************************************/
MDrv_ACE_SetPreYOffset(void * pInstance,MS_BOOL bScalerWin,MS_U8 u8PreYOffset)775 MS_BOOL MDrv_ACE_SetPreYOffset(void* pInstance, MS_BOOL bScalerWin, MS_U8 u8PreYOffset)
776 {
777 #ifdef ENABLE_SET_PRE_Y_OFFSET
778 ACE_INSTANCE_PRIVATE *psACEInstPri = NULL;
779 UtopiaInstanceGetPrivate(pInstance, (void**)&psACEInstPri);
780 if((MApi_XC_MLoad_GetStatus_U2(pu32ACE_XCInst) == E_MLOAD_ENABLED) && (!Hal_ACE_GetSkipWaitVsync(pInstance, bScalerWin)))
781 {
782 if (bScalerWin == MAIN_WINDOW)
783 {
784 MApi_XC_MLoad_WriteCmd(pu32ACE_XCInst, REG_SC_BK1A_0F_L, ((MS_U16)u8PreYOffset), 0xFF);
785 }
786 else
787 {
788 MApi_XC_MLoad_WriteCmd(pu32ACE_XCInst, REG_SC_BK1A_0F_L, ((MS_U16)u8PreYOffset<<8), 0xFF00);
789 }
790
791 MApi_XC_MLoad_Fire(pInstance, TRUE);
792
793 }
794 else
795 {
796 if (bScalerWin == MAIN_WINDOW)
797 {
798 SC_W2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK1A_0F_L, ((MS_U16)u8PreYOffset), 0xFF);
799 }
800 else
801 {
802 SC_W2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK1A_0F_L, ((MS_U16)u8PreYOffset<<8), 0xFF00);
803 }
804 }
805 return TRUE;
806 #else
807 return FALSE;
808 #endif
809 }
810
811 /******************************************************************************/
812 ///Get Pre Y offset
813 ///@param bScalerMainWin \b IN
814 ///@param pu8PreYOffset \b OUT
815 ///- pu8PreYOffset value from 0 -0xff
816 /// @return @ref MS_U8
817 /******************************************************************************/
MDrv_ACE_GetPreYOffset(void * pInstance,MS_BOOL bScalerWin)818 MS_U8 MDrv_ACE_GetPreYOffset(void* pInstance, MS_BOOL bScalerWin)
819 {
820 MS_U8 u8PreYOffset= 0;
821 #ifdef ENABLE_SET_PRE_Y_OFFSET
822 ACE_INSTANCE_PRIVATE *psACEInstPri = NULL;
823 UtopiaInstanceGetPrivate(pInstance, (void**)&psACEInstPri);
824 if (bScalerWin == MAIN_WINDOW)
825 {
826 u8PreYOffset = SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK1A_0F_L, 0xFF);
827 }
828 else
829 {
830 u8PreYOffset = (MS_U8)(SC_R2BYTEMSK(psACEInstPri->u32DeviceID, REG_SC_BK1A_0F_L, 0xFF00) >> 8);
831 }
832 #endif
833 return u8PreYOffset;
834 }
835
836 ////////////////////////////////////////////////////////////////////////////////
837 //
838 // MWE start
839 //
840 ////////////////////////////////////////////////////////////////////////////////
841
842
843 MS_U8 MWE_Border_Color[] =
844 {
845 0x00, // E_XC_FREE_RUN_COLOR_BLACK
846 0xFF, // E_XC_FREE_RUN_COLOR_WHITE
847 0x03, // E_XC_FREE_RUN_COLOR_BLUE
848 0xE0, // E_XC_FREE_RUN_COLOR_RED
849 0x1C, // E_XC_FREE_RUN_COLOR_GREEN
850 };
851
MDrv_XC_ACE_MWEinit(void * pInstance,MS_U16 u16MWEHstart,MS_U16 u16MWEVstart,MS_U16 u16MWEWidth,MS_U16 u16MWEHeight)852 void MDrv_XC_ACE_MWEinit(void* pInstance, MS_U16 u16MWEHstart, MS_U16 u16MWEVstart, MS_U16 u16MWEWidth, MS_U16 u16MWEHeight)
853 {
854 _ACE_GET_VARIABLE();
855 MWEPanel.u16Pnl_Height = u16MWEHeight;
856 MWEPanel.u16Pnl_Width = u16MWEWidth;
857 MWEPanel.u16Pnl_Hstart = u16MWEHstart;
858 MWEPanel.u16Pnl_Vstart = u16MWEVstart;
859 }
860
861 //===============================================================================
862
MDrv_XC_ACE_MWESetWin(void * pInstance,MWE_RECT * pRect)863 void MDrv_XC_ACE_MWESetWin(void* pInstance, MWE_RECT *pRect)
864 {
865 MS_U16 u16hstart, u16hend, u16vstart, u16vend;
866 _ACE_GET_VARIABLE();
867
868 u16hstart = pRect->Xpos + MWEPanel.u16Pnl_Hstart;
869 u16hend = u16hstart + pRect->Xsize - 1;
870 u16vstart = pRect->Ypos + MWEPanel.u16Pnl_Vstart;
871 u16vend = u16vstart + pRect->Ysize - 1;
872
873 if(u16hend > MWEPanel.u16Pnl_Hstart + MWEPanel.u16Pnl_Width - 1)
874 u16hend = MWEPanel.u16Pnl_Hstart + MWEPanel.u16Pnl_Width - 1;
875
876 if(u16vend > MWEPanel.u16Pnl_Vstart + MWEPanel.u16Pnl_Height - 1)
877 u16vend = MWEPanel.u16Pnl_Vstart + MWEPanel.u16Pnl_Height - 1;
878 MS_DEBUG_MSG(printf("[MWE] Hstart %4x Hend %4x Vstart %4x Vend %4x \n",
879 u16hstart, u16hend, u16vstart, u16vend));
880 Hal_ACE_MWESetWin(pInstance, u16hstart, u16hend, u16vstart, u16vend);
881 }
882
MDrv_XC_ACE_MWECloneVisualEffect(void * pInstance)883 void MDrv_XC_ACE_MWECloneVisualEffect(void* pInstance)
884 {
885 Hal_ACE_MWECloneVisualEffect(pInstance);
886 }
887
MDrv_ACE_3DClonePQMap(void * pInstance,XC_ACE_WEAVETYPE enWeaveType)888 void MDrv_ACE_3DClonePQMap(void* pInstance, XC_ACE_WEAVETYPE enWeaveType)
889 {
890 Hal_ACE_3DClonePQMap(pInstance, enWeaveType);
891 }
892
MDrv_XC_ACE_MWESetRegRow(void * pInstance,MS_U32 u32Addr,MS_U8 u8Value,MS_U8 u8Mask)893 void MDrv_XC_ACE_MWESetRegRow(void* pInstance, MS_U32 u32Addr, MS_U8 u8Value, MS_U8 u8Mask)
894 {
895 _ACE_GET_INST_PRIVATE();
896 if(u32Addr & 0x1)
897 {
898 SC_W2BYTEMSK(psACEInstPri->u32DeviceID, (MS_U32)(u32Addr & 0xFFFFFE), (MS_U16)u8Value << 8, (MS_U16)u8Mask << 8);
899 }
900 else
901 {
902 SC_W2BYTEMSK(psACEInstPri->u32DeviceID, (MS_U32)u32Addr, (MS_U16)u8Value, (MS_U16)u8Mask);
903 }
904 }
905
906 //===============================================================================
907
MDrv_XC_ACE_MWESetBorder(void * pInstance,MS_BOOL bScalerWin,MS_BOOL ben,MS_U8 u8color,MS_U16 u16_l,MS_U16 u16_r,MS_U16 u16_t,MS_U16 u16_d)908 void MDrv_XC_ACE_MWESetBorder(void* pInstance, MS_BOOL bScalerWin, MS_BOOL ben, MS_U8 u8color, MS_U16 u16_l, MS_U16 u16_r, MS_U16 u16_t, MS_U16 u16_d)
909 {
910 MS_U16 u16color = (u8color >= MWE_BORDER_COLOR_MAX)
911 ? MWE_Border_Color[MWE_BORDER_COLOR_BLACK]
912 : MWE_Border_Color[u8color];
913
914 if(ben)
915 {
916 Hal_ACE_MWESetBorder(pInstance, bScalerWin, u16color, u16_l, u16_r, u16_t, u16_d);
917 }
918
919 }
920
921 //===============================================================================
922
923
MDrv_XC_ACE_MWEEnable(void * pInstance,MS_BOOL bEnable,MS_BOOL bLoadFromTable)924 void MDrv_XC_ACE_MWEEnable(void* pInstance, MS_BOOL bEnable, MS_BOOL bLoadFromTable)
925 {
926 Hal_ACE_MWEEnable(pInstance, bEnable, bLoadFromTable);
927 }
928
929 ////////////////////////////////////////////////////////////////////////////////
930 //
931 // MWE end
932 //
933 ////////////////////////////////////////////////////////////////////////////////
934
MDrv_XC_ACE_Set_ICC_SRAM(void * pInstance,MS_U16 * pBuf,MS_U16 u16ByteSize)935 MS_BOOL MDrv_XC_ACE_Set_ICC_SRAM(void* pInstance, MS_U16 *pBuf, MS_U16 u16ByteSize)
936 {
937 if(u16ByteSize > 256*2)
938 return FALSE;
939
940 Hal_ACE_Set_ICC_SRAM(pInstance, pBuf, u16ByteSize/2);
941 return TRUE;
942 }
943
MDrv_XC_ACE_Set_IHC_SRAM(void * pInstance,MS_U16 * pBuf,MS_U16 u16ByteSize)944 MS_BOOL MDrv_XC_ACE_Set_IHC_SRAM(void* pInstance, MS_U16 *pBuf, MS_U16 u16ByteSize)
945 {
946 #define H_SIZE 17
947 #define V_SIZE 17
948 #define MAX_SRAM_SIZE 0x100
949 #define BUF_BYTE_SIZE 17*17
950
951 MS_U8 v_idx, h_idx;
952 MS_U8 row, col;
953 MS_U16 data;
954 MS_U16 cont1, cont2, cont3, cont4;
955 MS_U16 SRAM1_IHC[MAX_SRAM_SIZE];
956 MS_U16 SRAM2_IHC[MAX_SRAM_SIZE];
957 MS_U16 SRAM3_IHC[MAX_SRAM_SIZE];
958 MS_U16 SRAM4_IHC[MAX_SRAM_SIZE];
959
960 memset(SRAM1_IHC, 0, sizeof(SRAM1_IHC));
961 memset(SRAM2_IHC, 0, sizeof(SRAM2_IHC));
962 memset(SRAM3_IHC, 0, sizeof(SRAM3_IHC));
963 memset(SRAM4_IHC, 0, sizeof(SRAM4_IHC));
964
965 if(u16ByteSize > BUF_BYTE_SIZE)
966 return FALSE;
967
968 cont1 = cont2 = cont3 = cont4 = 0;
969
970 for (v_idx=1; v_idx <= V_SIZE; v_idx++)
971 for (h_idx=1; h_idx <= H_SIZE-1; h_idx++)
972 {
973 data = pBuf[(v_idx-1)*H_SIZE + h_idx-1]; //pBuf[v_idx-1][h_idx-1]
974
975 row = (int)(v_idx-(v_idx/2)*2);
976 col = (int)(h_idx-(h_idx/2)*2);
977
978 if ( (row==1) & (col==1) )
979 {
980 SRAM1_IHC[cont1]=data;
981 cont1 = cont1 < MAX_SRAM_SIZE-1 ? cont1+1 : MAX_SRAM_SIZE-1;
982 }
983
984 if ( (row==1) & (col==0) )
985 {
986 SRAM2_IHC[cont2]=data;
987 cont2 = cont2 < MAX_SRAM_SIZE-1 ? cont2+1 : MAX_SRAM_SIZE-1;
988 }
989
990 if ( (row==0) & (col==1) )
991 {
992 SRAM3_IHC[cont3]=data;
993 cont3 = cont3 < MAX_SRAM_SIZE-1 ? cont3+1 : MAX_SRAM_SIZE-1;
994 }
995
996 if ( (row==0) & (col==0) )
997 {
998 SRAM4_IHC[cont4]=data;
999 cont4 = cont4 < MAX_SRAM_SIZE-1 ? cont4+1 : MAX_SRAM_SIZE-1;
1000 }
1001
1002 }
1003
1004 for (v_idx=1; v_idx <= V_SIZE; v_idx++)
1005 {
1006 row = (v_idx-(v_idx/2)*2);
1007
1008 data = pBuf[(v_idx-1)*H_SIZE+16];
1009
1010 if (row==1)
1011 {
1012 SRAM1_IHC[cont1]=data;
1013 cont1 = cont1 < MAX_SRAM_SIZE-1 ? cont1+1 : MAX_SRAM_SIZE-1;
1014 }
1015 else
1016 {
1017 SRAM3_IHC[cont3]=data;
1018 cont3 = cont3 < MAX_SRAM_SIZE-1 ? cont3+1 : MAX_SRAM_SIZE-1;
1019 }
1020 }
1021
1022 Hal_ACE_Set_IHC_SRAM(pInstance, &SRAM1_IHC[0], 0, cont1);
1023 Hal_ACE_Set_IHC_SRAM(pInstance, &SRAM2_IHC[0], 1, cont2);
1024 Hal_ACE_Set_IHC_SRAM(pInstance, &SRAM3_IHC[0], 2, cont3);
1025 Hal_ACE_Set_IHC_SRAM(pInstance, &SRAM4_IHC[0], 3, cont4);
1026
1027 return TRUE;
1028 }
1029
MDrv_XC_ACE_DNR_GetMotion(void * pInstance)1030 MS_U8 MDrv_XC_ACE_DNR_GetMotion(void* pInstance)
1031 {
1032 MS_U8 u8Ret;
1033 DECLARA_BANK_VARIABLE
1034 BACKUP_SC_BANK
1035
1036 u8Ret = Hal_ACE_DNR_GetMotion(pInstance);
1037
1038 RECOVER_SC_BANK
1039
1040 return u8Ret;
1041 }
1042
MDrv_ACE_DNR_GetCoringThreshold(void * pInstance,MS_BOOL bScalerWin)1043 MS_U8 MDrv_ACE_DNR_GetCoringThreshold(void* pInstance, MS_BOOL bScalerWin)
1044 {
1045 return Hal_ACE_DNR_GetCoringThreshold(pInstance, bScalerWin);
1046 }
1047
MDrv_ACE_DNR_GetSharpnessAdjust(void * pInstance,MS_BOOL bScalerWin)1048 MS_U8 MDrv_ACE_DNR_GetSharpnessAdjust(void* pInstance, MS_BOOL bScalerWin)
1049 {
1050 return Hal_ACE_DNR_GetSharpnessAdjust(pInstance, bScalerWin);
1051 }
1052
MDrv_ACE_DNR_GetGuassin_SNR_Threshold(void * pInstance,MS_BOOL bScalerWin)1053 MS_U8 MDrv_ACE_DNR_GetGuassin_SNR_Threshold(void* pInstance, MS_BOOL bScalerWin)
1054 {
1055 return Hal_ACE_DNR_GetGuassin_SNR_Threshold(pInstance, bScalerWin);
1056 }
1057
MDrv_ACE_DNR_SetCoringThreshold(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1058 void MDrv_ACE_DNR_SetCoringThreshold(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1059 {
1060 DECLARA_BANK_VARIABLE
1061 BACKUP_SC_BANK
1062
1063 Hal_ACE_DNR_SetCoringThreshold(pInstance, bScalerWin, u16val);
1064
1065 RECOVER_SC_BANK
1066 }
1067
MDrv_ACE_DNR_SetSharpnessAdjust(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1068 void MDrv_ACE_DNR_SetSharpnessAdjust(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1069 {
1070 DECLARA_BANK_VARIABLE
1071 BACKUP_SC_BANK
1072
1073 Hal_ACE_DNR_SetSharpnessAdjust(pInstance, bScalerWin, u16val);
1074
1075 RECOVER_SC_BANK
1076
1077 }
1078
MDrv_ACE_DNR_SetNM_V(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1079 void MDrv_ACE_DNR_SetNM_V(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1080 {
1081 DECLARA_BANK_VARIABLE
1082 BACKUP_SC_BANK
1083
1084 Hal_ACE_DNR_SetNM_V(pInstance, bScalerWin, u16val);
1085
1086 RECOVER_SC_BANK
1087 }
1088
MDrv_ACE_DNR_SetGNR_0(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1089 void MDrv_ACE_DNR_SetGNR_0(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1090 {
1091 DECLARA_BANK_VARIABLE
1092 BACKUP_SC_BANK
1093
1094 Hal_ACE_DNR_SetGNR_0(pInstance, bScalerWin, u16val);
1095
1096 RECOVER_SC_BANK
1097 }
1098
MDrv_ACE_DNR_SetGNR_1(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1099 void MDrv_ACE_DNR_SetGNR_1(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1100 {
1101 DECLARA_BANK_VARIABLE
1102 BACKUP_SC_BANK
1103
1104 Hal_ACE_DNR_SetGNR_1(pInstance, bScalerWin, u16val);
1105
1106 RECOVER_SC_BANK
1107 }
1108
MDrv_ACE_DNR_SetCP(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1109 void MDrv_ACE_DNR_SetCP(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1110 {
1111 DECLARA_BANK_VARIABLE
1112 BACKUP_SC_BANK
1113
1114 Hal_ACE_DNR_SetCP(pInstance, bScalerWin, u16val);
1115
1116 RECOVER_SC_BANK
1117 }
1118
MDrv_ACE_DNR_SetDP(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1119 void MDrv_ACE_DNR_SetDP(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1120 {
1121 DECLARA_BANK_VARIABLE
1122 BACKUP_SC_BANK
1123
1124 Hal_ACE_DNR_SetDP(pInstance, bScalerWin, u16val);
1125
1126 RECOVER_SC_BANK
1127 }
1128
MDrv_ACE_DNR_SetNM_H_0(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1129 void MDrv_ACE_DNR_SetNM_H_0(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1130 {
1131 DECLARA_BANK_VARIABLE
1132 BACKUP_SC_BANK
1133
1134 Hal_ACE_DNR_SetNM_H_0(pInstance, bScalerWin, u16val);
1135 }
1136
MDrv_ACE_DNR_SetNM_H_1(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1137 void MDrv_ACE_DNR_SetNM_H_1(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1138 {
1139 DECLARA_BANK_VARIABLE
1140 BACKUP_SC_BANK
1141
1142 Hal_ACE_DNR_SetNM_H_1(pInstance, bScalerWin, u16val);
1143
1144 RECOVER_SC_BANK
1145 }
1146
MDrv_ACE_DNR_SetGray_Ground_Gain(void * pInstance,MS_U16 u16val)1147 void MDrv_ACE_DNR_SetGray_Ground_Gain(void* pInstance, MS_U16 u16val)
1148 {
1149 DECLARA_BANK_VARIABLE
1150 BACKUP_SC_BANK
1151
1152 Hal_ACE_DNR_SetGray_Ground_Gain(pInstance, u16val);
1153
1154 RECOVER_SC_BANK
1155 }
1156
MDrv_ACE_DNR_SetGray_Ground_En(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1157 void MDrv_ACE_DNR_SetGray_Ground_En(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1158 {
1159 DECLARA_BANK_VARIABLE
1160 BACKUP_SC_BANK
1161
1162 Hal_ACE_DNR_SetGray_Ground_En(pInstance, bScalerWin, u16val);
1163
1164 RECOVER_SC_BANK
1165 }
1166
1167
MDrv_ACE_DNR_SetSC_Coring(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1168 void MDrv_ACE_DNR_SetSC_Coring(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1169 {
1170 DECLARA_BANK_VARIABLE
1171 BACKUP_SC_BANK
1172
1173 Hal_ACE_DNR_SetSC_Coring(pInstance, bScalerWin, u16val);
1174
1175 RECOVER_SC_BANK
1176 }
1177
1178
MDrv_ACE_DNR_SetSpikeNR_0(void * pInstance,MS_U16 u16val)1179 void MDrv_ACE_DNR_SetSpikeNR_0(void* pInstance, MS_U16 u16val)
1180 {
1181 DECLARA_BANK_VARIABLE
1182 BACKUP_SC_BANK
1183
1184 Hal_ACE_DNR_SetSpikeNR_0(pInstance, u16val);
1185 }
1186
MDrv_ACE_DNR_SetSpikeNR_1(void * pInstance,MS_U16 u16val)1187 void MDrv_ACE_DNR_SetSpikeNR_1(void* pInstance, MS_U16 u16val)
1188 {
1189 DECLARA_BANK_VARIABLE
1190 BACKUP_SC_BANK
1191
1192 Hal_ACE_DNR_SetSpikeNR_1(pInstance, u16val);
1193
1194 RECOVER_SC_BANK
1195 }
1196
MDrv_ACE_DNR_SetSNR_NM(void * pInstance,MS_U16 u16val)1197 void MDrv_ACE_DNR_SetSNR_NM(void* pInstance, MS_U16 u16val)
1198 {
1199 DECLARA_BANK_VARIABLE
1200 BACKUP_SC_BANK
1201
1202 Hal_ACE_DNR_SetSNR_NM(pInstance, u16val);
1203
1204 RECOVER_SC_BANK
1205 }
1206
1207
MDrv_ACE_DNR_SetBank_Coring(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1208 void MDrv_ACE_DNR_SetBank_Coring(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1209 {
1210 DECLARA_BANK_VARIABLE
1211 BACKUP_SC_BANK
1212
1213 Hal_ACE_DNR_SetBank_Coring(pInstance, bScalerWin, u16val);
1214
1215 RECOVER_SC_BANK
1216 }
1217
MDrv_ACE_DNR_SetGuassin_SNR_Threshold(void * pInstance,MS_BOOL bScalerWin,MS_U16 u16val)1218 void MDrv_ACE_DNR_SetGuassin_SNR_Threshold(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val)
1219 {
1220 DECLARA_BANK_VARIABLE
1221 BACKUP_SC_BANK
1222
1223 Hal_ACE_DNR_SetGuassin_SNR_Threshold(pInstance, bScalerWin, u16val);
1224
1225 RECOVER_SC_BANK
1226
1227 }
1228
MDrv_ACE_DNR_SetNRTable(void * pInstance,MS_U8 * pTbl)1229 void MDrv_ACE_DNR_SetNRTable(void* pInstance, MS_U8 *pTbl)
1230 {
1231 MS_U8 i;
1232 MS_U16 u16val;
1233
1234 DECLARA_BANK_VARIABLE
1235
1236 for(i=0; i<8; i=i+2)
1237 {
1238 u16val = ((MS_U16)pTbl[i+1]<<8) | (MS_U16) pTbl[i];
1239
1240 BACKUP_SC_BANK
1241
1242 Hal_ACE_DNR_SetNRTbl_Y(pInstance, i, u16val);
1243 Hal_ACE_DNR_SetNRTbl_C(pInstance, i, u16val);
1244
1245 RECOVER_SC_BANK
1246
1247 }
1248 }
1249
MDrv_ACE_ColorCorrectionTable(void * pInstance,MS_BOOL bScalerWin,MS_S16 * psColorCorrectionTable)1250 void MDrv_ACE_ColorCorrectionTable(void* pInstance, MS_BOOL bScalerWin, MS_S16 *psColorCorrectionTable )
1251 {
1252 msACESetColorCorrectionTable(pInstance, bScalerWin, psColorCorrectionTable);
1253 }
1254
MDrv_ACE_SetColorMatrixControl(void * pInstance,MS_BOOL bScalerWin,MS_BOOL bEnable)1255 void MDrv_ACE_SetColorMatrixControl(void* pInstance, MS_BOOL bScalerWin, MS_BOOL bEnable )
1256 {
1257 msACE_SetColorMatrixControl(pInstance, bScalerWin, bEnable);
1258 }
1259
MDrv_ACE_SetRBChannelRange(void * pInstance,MS_BOOL bScalerWin,MS_BOOL bRange)1260 void MDrv_ACE_SetRBChannelRange(void* pInstance, MS_BOOL bScalerWin, MS_BOOL bRange)
1261 {
1262 msACE_SetRBChannelRange(pInstance, bScalerWin, bRange);
1263 HAL_ACE_Set_RBChannelOffset(pInstance, bScalerWin, bRange);
1264 }
1265
MDrv_ACE_WriteColorMatrixBurst(void * pInstance,MS_BOOL bWindow,MS_U16 * psMatrix)1266 void MDrv_ACE_WriteColorMatrixBurst(void* pInstance, MS_BOOL bWindow, MS_U16* psMatrix )
1267 {
1268 Hal_ACE_Write_Color_Matrix_Burst(pInstance, bWindow,psMatrix);
1269 }
1270
MDrv_ACE_IsSupportMLoad(void * pInstance)1271 MS_BOOL MDrv_ACE_IsSupportMLoad(void* pInstance)
1272 {
1273 return Hal_ACE_Is_Support_MLoad(pInstance);
1274 }
1275
1276 //-------------------------------------------------------------------------------------------------
1277 ///Set HDR Init
1278 /// @param pstDLC_HDRInitData \b IN: the HDR Init Data
1279 /// @return TRUE: DDI call success
1280 /// @attention
1281 //-------------------------------------------------------------------------------------------------
MDrv_ACE_SetHDRInit(void * pInstance,ACE_DRV_HDRinit * pstACE_HDRInitData)1282 MS_BOOL MDrv_ACE_SetHDRInit(void* pInstance,ACE_DRV_HDRinit * pstACE_HDRInitData)
1283 {
1284 memset(&g_ACEinitParameters, 0 , sizeof(ACE_DRV_HDRinit));
1285 memcpy(&g_ACEinitParameters, pstACE_HDRInitData, sizeof(ACE_DRV_HDRinit));
1286
1287 msACE_HDR_Main(pInstance);
1288
1289 return TRUE;
1290 }
1291
1292 //-------------------------------------------------------------------------------------------------
1293 /// Skip Wait Vsync
1294 /// @param eWindow \b IN: Enable
1295 /// @param Skip wait Vsync \b IN: Disable wait Vsync
1296 //-------------------------------------------------------------------------------------------------
MDrv_ACE_SetSkipWaitVsync(void * pInstance,MS_BOOL eWindow,MS_BOOL bIsSkipWaitVsyn)1297 void MDrv_ACE_SetSkipWaitVsync(void* pInstance, MS_BOOL eWindow,MS_BOOL bIsSkipWaitVsyn)
1298 {
1299 Hal_ACE_SetSkipWaitVsync(pInstance, eWindow, bIsSkipWaitVsyn);
1300 }
1301
MDrv_ACE_GetSkipWaitVsync(void * pInstance,MS_BOOL bScalerWin)1302 MS_BOOL MDrv_ACE_GetSkipWaitVsync(void* pInstance, MS_BOOL bScalerWin)
1303 {
1304 return Hal_ACE_GetSkipWaitVsync(pInstance, bScalerWin);
1305 }
1306
MDrv_ACE_SetIHC(void * pInstance,MS_BOOL bScalerWin,XC_ACE_IHC_COLOR_TYPE eIHC,MS_U8 u8Val)1307 MS_BOOL MDrv_ACE_SetIHC(void* pInstance, MS_BOOL bScalerWin, XC_ACE_IHC_COLOR_TYPE eIHC, MS_U8 u8Val)
1308 {
1309 return Hal_ACE_SetIHC(pInstance, bScalerWin, eIHC, u8Val);
1310 }
1311
MDrv_ACE_GetIHC(void * pInstance,MS_BOOL bScalerWin,XC_ACE_IHC_COLOR_TYPE eIHC,MS_U8 * pu8Val)1312 MS_BOOL MDrv_ACE_GetIHC(void* pInstance, MS_BOOL bScalerWin, XC_ACE_IHC_COLOR_TYPE eIHC, MS_U8* pu8Val)
1313 {
1314 return Hal_ACE_GetIHC(pInstance, bScalerWin, eIHC, pu8Val);
1315 }
1316
MDrv_ACE_SetICC(void * pInstance,MS_BOOL bScalerWin,XC_ACE_ICC_COLOR_TYPE eICC,MS_U8 u8Val)1317 MS_BOOL MDrv_ACE_SetICC(void* pInstance, MS_BOOL bScalerWin, XC_ACE_ICC_COLOR_TYPE eICC, MS_U8 u8Val)
1318 {
1319 return Hal_ACE_SetICC(pInstance, bScalerWin, eICC, u8Val);
1320 }
1321
MDrv_ACE_GetICC(void * pInstance,MS_BOOL bScalerWin,XC_ACE_ICC_COLOR_TYPE eICC,MS_U8 * pu8Val)1322 MS_BOOL MDrv_ACE_GetICC(void* pInstance, MS_BOOL bScalerWin, XC_ACE_ICC_COLOR_TYPE eICC, MS_U8* pu8Val)
1323 {
1324 return Hal_ACE_GetICC(pInstance, bScalerWin, eICC, pu8Val);
1325 }
1326
MDrv_ACE_SetIBC(void * pInstance,MS_BOOL bScalerWin,XC_ACE_IBC_COLOR_TYPE eIBC,MS_U8 u8Val)1327 MS_BOOL MDrv_ACE_SetIBC(void* pInstance, MS_BOOL bScalerWin, XC_ACE_IBC_COLOR_TYPE eIBC, MS_U8 u8Val)
1328 {
1329 return Hal_ACE_SetIBC(pInstance, bScalerWin, eIBC, u8Val);
1330 }
1331
MDrv_ACE_GetIBC(void * pInstance,MS_BOOL bScalerWin,XC_ACE_IBC_COLOR_TYPE eIBC,MS_U8 * pu8Val)1332 MS_BOOL MDrv_ACE_GetIBC(void* pInstance, MS_BOOL bScalerWin, XC_ACE_IBC_COLOR_TYPE eIBC, MS_U8* pu8Val)
1333 {
1334 return Hal_ACE_GetIBC(pInstance, bScalerWin, eIBC, pu8Val);
1335 }
1336
MDrv_ACE_GetDeviceNum(void)1337 MS_U32 MDrv_ACE_GetDeviceNum(void)
1338 {
1339 return XC_ACE_SUPPORT_DEVICE_NUM;
1340 }
1341
1342 #undef _MDRV_ACE_C_
1343
1344