xref: /utopia/UTPA2-700.0.x/modules/dlc/hal/maxim/dlc/include/MsDlc_LIB_Group_DTV3.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") 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 #ifndef _MSDLC_LIB_GROUP_DTV2_H_
95 #define _MSDLC_LIB_GROUP_DTV2_H_
96 
97 
98 #ifdef IOUTIL_C
99 #define INTERFACE
100 #else
101 #define    INTERFACE extern
102 #endif
103 
104 #include "drvDLC.h"
105 #include "dlc_hwreg_utility2.h"
106 #include "MsCommon.h"
107 #include "MsIRQ.h"
108 #include "MsOS.h"
109 #include "drvDLC_Cus.h"
110 
111 /////////////// Chakra2 define start
112 
113 #define BOOL    MS_BOOL
114 #define BYTE    MS_U8
115 #define WORD    MS_U16
116 #define DWORD   MS_U32
117 #define XDATA
118 #define code
119 
120 #define MAIN_WINDOW     0
121 #define SUB_WINDOW      1
122 
123 
124 #define REG_BANK_VOP                0x10
125 #define REG_BANK_ACE                0x18
126 #define REG_BANK_DLC                0x1A
127 #define REG_BANK_OP                 0x20
128 
129 #define BK_REG_L( x, y )            (REG_SCALER_BASE + ((x) | (((y) << 1))))
130 #define BK_REG_H( x, y )            (REG_SCALER_BASE +(((x) | (((y) << 1))) + 1))
131 #if SCALER_REGISTER_SPREAD
132 #define L_BK_VOP(x)                 BK_REG_L((REG_BANK_VOP << 8),x)
133 #define L_BK_ACE(x)                 BK_REG_L((REG_BANK_ACE << 8),x)
134 #define L_BK_DLC(x)                 BK_REG_L((REG_BANK_DLC << 8),x)
135 #define H_BK_DLC(x)                 BK_REG_H((REG_BANK_DLC << 8),x)
136 #define L_BK_OP(x)                  BK_REG_L((REG_BANK_OP << 8),x)
137 
138 #else
139 #define L_BK_VOP(x)                 BK_REG_L(BK_SCALER_BASE,x)
140 #define L_BK_ACE(x)                 BK_REG_L(BK_SCALER_BASE,x)
141 #define L_BK_DLC(x)                 BK_REG_L(BK_SCALER_BASE,x)
142 #define H_BK_DLC(x)                 BK_REG_H(BK_SCALER_BASE,x)
143 #define L_BK_OP(x)                  BK_REG_L(BK_SCALER_BASE,x)
144 
145 #endif
146 //////////////// Chakra2 define end
147 
148 #define _END_OF_TBL_    0xFFFF
149 
150 #define _BIT0           0x0001
151 #define _BIT1           0x0002
152 #define _BIT2           0x0004
153 #define _BIT3           0x0008
154 #define _BIT4           0x0010
155 #define _BIT5           0x0020
156 #define _BIT6           0x0040
157 #define _BIT7           0x0080
158 #define _ENABLE             1
159 #define _DISABLE            0
160 #define BYTE            MS_U8
161 //////////////////////////////////////////////////////////////////////////
162 // Common Definition
163 typedef struct _DlcRegUnitType
164 {
165     WORD wReg;
166     BYTE ucValue;
167 }DlcRegUnitType;
168 
169 
170 //#define BOOL    BOOLEAN
171 
172 #define msReadByte(_reg_)                   MDrv_ReadByte(_reg_)
173 #define msWriteByte(_reg_, _val_)           MDrv_WriteByte(_reg_, _val_)
174 #define msWriteBit(_reg_, _val_, _pos_)     MDrv_WriteRegBit(_reg_, _val_, _pos_)
175 #define msDlc_Delay1ms(x)                   MsOS_DelayTask(x)
176 
177 #define REG_NULL        0xFF // empty register
178 
179 
180 //////////////////////////////////////////////////////////////////////////
181 #define REG_ADDR_HISTOGRAM_RANGE_M_HST      L_BK_DLC(0x1A)
182 #define REG_ADDR_HISTOGRAM_RANGE_M_HEN      H_BK_DLC(0x1A)
183 #define REG_ADDR_HISTOGRAM_RANGE_M_VST      L_BK_DLC(0x01)
184 #define REG_ADDR_HISTOGRAM_RANGE_M_VEN      H_BK_DLC(0x01)
185 #define REG_ADDR_HISTOGRAM_RANGE_S_HST      L_BK_DLC(0x1B)
186 #define REG_ADDR_HISTOGRAM_RANGE_S_HEN      H_BK_DLC(0x1B)
187 #define REG_ADDR_HISTOGRAM_RANGE_S_VST      L_BK_DLC(0x03)
188 #define REG_ADDR_HISTOGRAM_RANGE_S_VEN      H_BK_DLC(0x03)
189 #define REG_ADDR_DLC_HANDSHAKE              L_BK_DLC(0x04)
190 #define REG_ADDR_HISTOGRAM_TOTAL_SUM_L      L_BK_DLC(0x06)
191 #define REG_ADDR_HISTOGRAM_TOTAL_SUM_H      H_BK_DLC(0x06)
192 #define REG_ADDR_HISTOGRAM_TOTAL_COUNT_L    L_BK_DLC(0x07)
193 #define REG_ADDR_HISTOGRAM_TOTAL_COUNT_H    H_BK_DLC(0x07)
194 #define REG_ADDR_HISTOGRAM_RANGE_ENABLE     L_BK_DLC(0x08)
195 #define REG_ADDR_HISTOGRAM_8_RANGE_START    L_BK_DLC(0x1C)
196 #define REG_ADDR_BLE_UPPER_BOND             L_BK_DLC(0x09)
197 #define REG_ADDR_BLE_LOWER_BOND             H_BK_DLC(0x09)
198 #define REG_ADDR_WLE_UPPER_BOND             L_BK_DLC(0x0A)
199 #define REG_ADDR_WLE_LOWER_BOND             H_BK_DLC(0x0A)
200 #define REG_ADDR_MAIN_MAX_VALUE             L_BK_DLC(0x0B)
201 #define REG_ADDR_MAIN_MIN_VALUE             H_BK_DLC(0x0B)
202 #define REG_ADDR_SUB_MAX_VALUE              L_BK_DLC(0x0C)
203 #define REG_ADDR_SUB_MIN_VALUE              H_BK_DLC(0x0C)
204 #define REG_ADDR_DLC_DATA_START_MAIN        L_BK_DLC(0x30)
205 #define REG_ADDR_DLC_DATA_START_SUB         L_BK_DLC(0x38)
206 #define REG_ADDR_HISTOGRAM_SUB_TOTAL_COUNT_L   L_BK_DLC(0x72)
207 #define REG_ADDR_HISTOGRAM_SUB_TOTAL_COUNT_H   H_BK_DLC(0x72)
208 #define REG_ADDR_HISTOGRAM_SUB_TOTAL_SUM_L     L_BK_DLC(0x73)
209 #define REG_ADDR_HISTOGRAM_SUB_TOTAL_SUM_H     H_BK_DLC(0x73)
210 #define REG_ADDR_DLC_DATA_EXTEND_N0_MAIN    L_BK_DLC(0x76)
211 #define REG_ADDR_DLC_DATA_EXTEND_16_MAIN    L_BK_DLC(0x77)
212 #define REG_ADDR_DLC_DATA_EXTEND_N0_SUB     L_BK_DLC(0x7E)
213 #define REG_ADDR_DLC_DATA_EXTEND_16_SUB     L_BK_DLC(0x7F)
214 #define REG_ADDR_DLC_DATA_LSB_START_MAIN    L_BK_DLC(0x78)
215 #define REG_ADDR_DLC_DATA_LSB_START_SUB     L_BK_DLC(0x7B)
216 #define REG_ADDR_HISTOGRAM_DATA_32          L_BK_DLC(0x40)
217 #define REG_ADDR_DLC_Y_GAIN                 L_BK_DLC(0x14)
218 #define REG_ADDR_DLC_C_GAIN                 H_BK_DLC(0x14)
219 #define REG_ADDR_VOP_SCREEN_CONTROL         L_BK_VOP(0x19)
220 #define REG_ADDR_VIP_HISTOGRAM_4K2K_MODE    L_BK_ACE(0x75)
221 #define REG_ADDR_OP_SW_SUB_ENABLE           L_BK_OP(0x10)
222 
223 #if SCALER_REGISTER_SPREAD
224 #define msDlc_FunctionEnter()
225 
226 #define msDlc_FunctionExit()
227 
228 #define msVop_FunctionEnter()
229 
230 #define msVop_FunctionExit()
231 #else
232 #define msDlc_FunctionEnter()               BYTE  u8Bank; \
233                                             u8Bank = msReadByte(BK_SCALER_BASE); \
234                                             msWriteByte(BK_SCALER_BASE, REG_BANK_DLC);// for register bank switch...
235 
236 #define msDlc_FunctionExit()                msWriteByte(BK_SCALER_BASE, u8Bank)// for register bank switch...
237 
238 #define msVop_FunctionEnter()               BYTE  u8Bank; \
239                                             u8Bank = msReadByte(BK_SCALER_BASE); \
240                                             msWriteByte(BK_SCALER_BASE, REG_BANK_VOP);// for register bank switch...
241 
242 #define msVop_FunctionExit()                msWriteByte(BK_SCALER_BASE, u8Bank)// for register bank switch...
243 #endif
244 
245 #ifdef _MSDLC_C_
246 code DlcRegUnitType tDLC_Initialize[] =
247 {
248     {_END_OF_TBL_, 0x00}
249 };
250 #else
251 extern code DlcRegUnitType tDLC_Initialize[];
252 #endif
253 
254 //////////////////////////////////////////////////////////////////////////
255 // Align to msdlc library
256 #ifdef _MSDLC_C_
257     typedef void   (*MApi_XC_DLC_Print_Callback)(MS_U8 /*PWM_VALUE*/);
258 
259     extern  MS_U16                       gu16PNL_Width;
260     extern  MS_U16                       gu16PNL_Height;
261     extern  MApi_XC_DLC_Print_Callback   gfnPutchar;
262     extern  StuDbc_CAPTURE_Range         g_DlcCapRange;
263 
264     #ifdef  putchar
265     #undef  putchar
266     #endif
267 
268     #define putchar(x)                   (gfnPutchar(x))
269     #define msDlc_AP_ReinitWithoutPara() msDlcInitWithCurve( g_DlcCapRange.wHStart, g_DlcCapRange.wHEnd, gu16PNL_Height*1/8, gu16PNL_Height*7/8)//g_DlcCapRange.wVStart, g_DlcCapRange.wVEnd )
270     #define Delay1ms(x)                  (MsOS_DelayTask(x))
271 #endif //_MSDLC_C_
272 
273 #endif
274 
275