xref: /utopia/UTPA2-700.0.x/modules/xc/hal/k6lite/ace/include/mhal_ace.h (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!�L) 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 #ifndef MHAL_ACE_H
96 #define MHAL_ACE_H
97 
98 /// Define XC ACE device number
99 typedef enum
100 {
101     XC_ACE_DEVICE0 = 0,
102     XC_ACE_DEVICE1 = 1,
103     XC_ACE_MAX_DEVICE_NUM
104 } XC_ACE_DEVICE_NUM;
105 
106 #define XC_ACE_SUPPORT_DEVICE_NUM XC_ACE_MAX_DEVICE_NUM
107 #define ACE_NOT_IN_KERNEL
108 
109 typedef enum
110 {
111     E_HALACE_DEVICE0_XC_BANK_OFFSET    = 0,
112     E_HALACE_DEVICE1_XC_BANK_OFFSET    = 0x80,
113 } ACE_HAL_DEVICE_XC_BANK_OFFSET;
114 
115 void Hal_ACE_DMS( void* pInstance, MS_BOOL bScalerWin, MS_BOOL bisATV );
116 void Hal_ACE_GetColorMatrix( void* pInstance, MS_BOOL bScalerWin, MS_U16* pu16Matrix);
117 void Hal_ACE_SetColorMatrix( void* pInstance, MS_BOOL bScalerWin, MS_U16* pu16Matrix);
118 MS_BOOL Hal_ACE_SetIHC(void* pInstance, MS_BOOL bScalerWin, XC_ACE_IHC_COLOR_TYPE eIHC, MS_U8 u8Val);
119 MS_BOOL Hal_ACE_GetIHC(void* pInstance, MS_BOOL bScalerWin, XC_ACE_IHC_COLOR_TYPE eIHC, MS_U8* pu8Val);
120 MS_BOOL Hal_ACE_SetICC(void* pInstance, MS_BOOL bScalerWin, XC_ACE_ICC_COLOR_TYPE eICC, MS_U8 u8Val);
121 MS_BOOL Hal_ACE_GetICC(void* pInstance, MS_BOOL bScalerWin, XC_ACE_ICC_COLOR_TYPE eIHC, MS_U8* pu8Val);
122 MS_BOOL Hal_ACE_SetIBC(void* pInstance, MS_BOOL bScalerWin, XC_ACE_IBC_COLOR_TYPE eIBC, MS_U8 u8Val);
123 MS_BOOL Hal_ACE_GetIBC(void* pInstance, MS_BOOL bScalerWin, XC_ACE_IBC_COLOR_TYPE eIHC, MS_U8* pu8Val);
124 
125 void Hal_ACE_PatchDTGColorChecker(void* pInstance, MS_U8 u8Mode);
126 void Hal_ACE_SetSlopValue( void* pInstance, MS_BOOL bScalerWin, MS_U8 u8SlopValue);
127 void Hal_ACE_SetFCC_En( void* pInstance, MS_BOOL bScalerWin, MS_U8 u8Reg, MS_BOOL bEn);
128 void Hal_ACE_SetFCC_Cb(void* pInstance, MS_U8 u8Reg, MS_U8 u8value);
129 void Hal_ACE_init_riu_base(MS_VIRT ptr_riu_base);
130 void Hal_ACE_SetSharpness(void* pInstance, MS_BOOL bScalerWin, MS_U8 u8Sharpness);
131 void Hal_ACE_SetSkipWaitVsync( void* pInstance, MS_BOOL bIsMainSkipWaitVsyn,MS_BOOL bIsSubSkipWaitVsyn);
132 MS_BOOL Hal_ACE_GetSkipWaitVsync( void* pInstance, MS_BOOL bScalerWin);
133 
134 void Hal_ACE_SetBrightness( void* pInstance, MS_BOOL bScalerWin, MS_U8 u8RedBrightness, MS_U8 u8GreenBrightness, MS_U8 u8BlueBrightness );
135 void Hal_ACE_SetBrightnessPrecise(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16RedBrightness, MS_U16 u16GreenBrightness, MS_U16 u16BlueBrightness);
136 void Hal_ACE_GetBrightness(void* pInstance, MS_BOOL bScalerWin, MS_U8* u8RedBrightness, MS_U8* u8GreenBrightness, MS_U8* u8BlueBrightness);
137 void Hal_ACE_SetPostRGBGain(void* pInstance, MS_BOOL bScalerWin, MS_U16 u8RedGain, MS_U16 u8GreenGain, MS_U16 u8BlueGain);
138 void Hal_ACE_SetPostRGBOffset(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16RedOffset, MS_U16 u16GreenOffset, MS_U16 u16BlueOffset);
139 void Hal_ACE_SetPostRGBGainOffsetTogether(void* pInstance, MS_BOOL bScalerWin,
140                                           MS_U16 u16RedGain,   MS_U16 u16GreenGain,   MS_U16 u16BlueGain,
141                                           MS_U16 u16RedOffset, MS_U16 u16GreenOffset, MS_U16 u16BlueOffset);
142 void Hal_ACE_Set_IHC_SRAM(void* pInstance, MS_U16 *pBuf, MS_U8 u8SRAM_Idx, MS_U16 u16Cnt);
143 void Hal_ACE_Set_ICC_SRAM(void* pInstance, MS_U16 *pBuf, MS_U16 u16Cnt);
144 void Hal_ACE_Write_Color_Matrix_Burst( void* pInstance, MS_BOOL bWindow, MS_U16* psMatrix );
145 MS_BOOL Hal_ACE_Is_Support_MLoad( void* pInstance );
146 
147 void Hal_ACE_MWESetWin(void* pInstance, MS_U16 u16hstart, MS_U16 u16hend, MS_U16 u16vstart, MS_U16 u16vend);
148 void Hal_ACE_MWEEnable(void* pInstance, MS_BOOL ben, MS_BOOL bLoadFromTable);
149 void Hal_ACE_MWESetBorder( void* pInstance, MS_BOOL bScalerWin, MS_U16 u16color, MS_U16 u16_l, MS_U16 u16_r, MS_U16 u16_t, MS_U16 u16_d);
150 void Hal_ACE_MWECloneVisualEffect(void* pInstance);
151 void Hal_ACE_3DClonePQMap(void* pInstance, XC_ACE_WEAVETYPE enWeaveType);
152 
153 MS_U8 Hal_ACE_DNR_GetMotion(void* pInstance);
154 MS_U8 Hal_ACE_DNR_GetCoringThreshold(void* pInstance, MS_BOOL bScalerWin);
155 MS_U8 Hal_ACE_DNR_GetSharpnessAdjust(void* pInstance, MS_BOOL bScalerWin);
156 MS_U8 Hal_ACE_DNR_GetGuassin_SNR_Threshold(void* pInstance, MS_BOOL bScalerWin);
157 
158 
159 void Hal_ACE_DNR_SetCoringThreshold(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
160 void Hal_ACE_DNR_SetSharpnessAdjust(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
161 void Hal_ACE_DNR_SetNM_V(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
162 void Hal_ACE_DNR_SetGNR_0(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
163 void Hal_ACE_DNR_SetGNR_1(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
164 void Hal_ACE_DNR_SetCP(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
165 void Hal_ACE_DNR_SetDP(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
166 void Hal_ACE_DNR_SetNM_H_0(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
167 void Hal_ACE_DNR_SetNM_H_1(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
168 void Hal_ACE_DNR_SetGray_Ground_Gain(void* pInstance, MS_U16 u16val);
169 void Hal_ACE_DNR_SetGray_Ground_En(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
170 void Hal_ACE_DNR_SetSC_Coring(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
171 void Hal_ACE_DNR_SetSpikeNR_0(void* pInstance, MS_U16 u16val);
172 void Hal_ACE_DNR_SetSpikeNR_1(void* pInstance, MS_U16 u16val);
173 void Hal_ACE_DNR_SetSNR_NM(void* pInstance, MS_U16 u16val);
174 void Hal_ACE_DNR_SetBank_Coring(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
175 void Hal_ACE_DNR_SetGuassin_SNR_Threshold(void* pInstance, MS_BOOL bScalerWin, MS_U16 u16val);
176 void Hal_ACE_DNR_SetNRTbl_Y(void* pInstance, MS_U8 u8Idx, MS_U16 u16val);
177 void Hal_ACE_DNR_SetNRTbl_C(void* pInstance, MS_U8 u8Idx, MS_U16 u16val);
178 void HAL_ACE_Set_RBChannelOffset(void* pInstance, MS_BOOL bScalerWin, MS_BOOL bEnable);
179 void Hal_ACE_Set_Device_Bank_Offset(void);
180 
181 // Function in mdrv_xc_menuload.c
182 typedef enum
183 {
184     E_MLOAD_UNSUPPORTED = 0,
185     E_MLOAD_DISABLED    = 1,
186     E_MLOAD_ENABLED     = 2,
187 }MLOAD_TYPE;
188 
189 typedef enum
190 {
191     E_MLG_UNSUPPORTED = 0,
192     E_MLG_DISABLED    = 1,
193     E_MLG_ENABLED     = 2,
194 }MLG_TYPE;
195 
196 /// Define mute type
197 typedef enum
198 {
199     E_MAIN_WINDOW_MUTE =0,          ///< main window mute
200     E_SUB_WINDOW_MUTE =1,           ///< sub window mute
201     E_PANEL_MUTE = 2            ///< panel mute
202 }EN_MUTE_TYPE;
203 
204 extern MS_BOOL MApi_XC_MLoad_Fire(void* pInstance, MS_BOOL bImmediate);
205 extern MS_BOOL MApi_XC_MLoad_WriteCmd(void* pInstance, MS_U32 u32Addr, MS_U16 u16Data, MS_U16 u16Mask);
206 extern MS_BOOL MApi_XC_MLoad_WriteCmds_And_Fire(void* pInstance, MS_U32 *pu32Addr, MS_U16 *pu16Data, MS_U16 *pu16Mask, MS_U16 u16CmdCnt);
207 extern MS_BOOL MApi_XC_MLoad_WriteCmd_And_Fire(void* pInstance, MS_U32 u32Addr, MS_U16 u16Data, MS_U16 u16Mask);
208 extern MLOAD_TYPE MApi_XC_MLoad_GetStatus_U2(void *pInstance);
209 extern MS_BOOL MApi_XC_GetForceWrite( EN_MUTE_TYPE enMuteType);
210 
211 
212 extern MS_S32 _MLOAD_MUTEX;
213 
214 #define MLOAD_MUTEX
215 #define MLOAD_MUTEX_DBG 0
216 
217 #ifdef MLOAD_MUTEX
218     #if(MLOAD_MUTEX_DBG)
219         #define _MLOAD_ENTRY()                                                         \
220                 printf("1,==========================\n");                              \
221                 printf("[%s][%s][%06d]\n",__FILE__,__FUNCTION__,__LINE__);    \
222                 if(!MsOS_ObtainMutex(_MLOAD_MUTEX, MSOS_WAIT_FOREVER))                 \
223                 {                                                                       \
224                     printf("==========================\n");                             \
225                     printf("[%s][%s][%06d] Mutex taking timeout\n",__FILE__,__FUNCTION__,__LINE__);    \
226                 }
227         #define _MLOAD_RETURN()                                                       \
228                 printf("0,==========================\n");                              \
229                 printf("[%s][%s][%06d] \n",__FILE__,__FUNCTION__,__LINE__);    \
230                 MsOS_ReleaseMutex(_MLOAD_MUTEX);
231                                     //return _ret;
232     #else
233         #define _MLOAD_ENTRY()                                               \
234                 if(!MsOS_ObtainMutex(_MLOAD_MUTEX, MSOS_WAIT_FOREVER))      \
235                 {                                                            \
236                 }
237         #define _MLOAD_RETURN()    MsOS_ReleaseMutex(_MLOAD_MUTEX);
238                                     //return _ret;
239     #endif
240 #else // #if not def MLOAD_MUTEX
241     #define _MLOAD_ENTRY()         while(0)
242     #define _MLOAD_RETURN()    while(0)
243 #endif // #ifdef _MLOAD_MUTEX
244 
245 #endif
246 
247 
248