xref: /utopia/UTPA2-700.0.x/mxlib/include/apiXC_ModeParse.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) 2006-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  apiXC_ModeParse.h
94 /// @brief MIU header file
95 /// @author MStar Semiconductor Inc.
96 ///
97 ////////////////////////////////////////////////////////////////////////////////
98 
99 /*! \defgroup Video Video modules
100 
101  *  \defgroup XC_FE XC_FE modules
102  *  \ingroup Video
103 
104 	Mode Parse mechanism is a fast and easy way to look up input timing according to different timing characteristics.\n
105 	For more information,see \link MODE_Parse MODE_Parse interface (apiXC_ModeParse.h) \endlink
106 
107  *  \defgroup MODE_Parse MODE_Parse interface (apiXC_ModeParse.h)
108  *  \ingroup XC_FE
109 
110     Mode Parse mechanism is a fast and easy way to look up input timing according to
111     different timing characteristics listed here
112     - input source type : Component / HDMI / DVI / VGA
113     - input horizontal frequency
114     - input vertical frequency
115     - input vertical total
116     - input sync detection : H/V polarity, scan type
117     - HDMI/DVI only : Data Enable section detection result
118     - Euro HDTV detection result
119 
120     <b>Features</b> \n
121     - Customizable : User can customized their database by passing their own data base and the driver will help to do the matching tasks.
122     - Supports multiple input source types : Component / HDMI / DVI / VGA
123 
124     <b> Operation Code Flow: </b> \n
125     1. calls MApi_XC_ModeParse_Init for internal initilizations
126     2. prepare MS_PCADC_MODETABLE_TYPE_EX structure type timing database.
127     3. User switch input source to whatever the system is going to show. For example : Main or Sub window
128     4. read sync detection info from scaler and stores it in XC_MODEPARSE_INPUT_INFO structure type
129     5. calls MApi_XC_ModeParse_MatchModeEx with timing database and the information you just got from scaler
130     6. wait for the result of matching timing.
131 
132  *  \defgroup MODE_Parse_INIT MODE_Parse init control
133  *  \ingroup MODE_Parse
134 
135  *! \defgroup MODE_Parse_FEATURE MODE_Parse feature operation
136  *  \ingroup MODE_Parse
137 
138  *! \defgroup MODE_Parse_INFO MODE_Parse Infomation pool
139  *  \ingroup MODE_Parse
140 
141  *! \defgroup MODE_Parse_ToBeModified MODE_Parse api to be modified
142  *  \ingroup MODE_Parse
143 
144  *! \defgroup MODE_Parse_ToBeRemove MODE_Parse api to be removed
145  *  \ingroup MODE_Parse
146  */
147 
148 
149 #ifndef _API_XC_MODEPARSE_H_
150 #define _API_XC_MODEPARSE_H_
151 #ifdef __cplusplus
152 extern "C"
153 {
154 #endif
155 #include "UFO.h"
156 //-------------------------------------------------------------------------------------------------
157 //  Include Files
158 //-------------------------------------------------------------------------------------------------
159 
160 //-------------------------------------------------------------------------------------------------
161 //  Macro and Define
162 //-------------------------------------------------------------------------------------------------
163 
164 //------------------------------
165 // Mode Detect & Search
166 //------------------------------
167 #define MD_FLAG_NULL            0x00
168 
169 #define MD_FLAG_POR_HPVP        0x01
170 #define MD_FLAG_POR_HPVN        0x02
171 #define MD_FLAG_POR_HNVP        0x04
172 #define MD_FLAG_POR_HNVN        0x08
173 #define MD_FLAG_INTERLACE       0x10
174 
175 #define MD_FLAG_EURO_HDTV_BIT   0x20
176 
177 #define MD_FLAG_YPBPR_BIT       0x40
178 #define MD_FLAG_HDTV_BIT        0x80
179 
180 
181 //-------------------------------------------------------------------------------------------------
182 //  Type and Structure
183 //-------------------------------------------------------------------------------------------------
184 
185 /// The type of result after mode searching.
186 typedef enum
187 {
188     XC_MODEPARSE_NOT_PARSED = 0,        ///< timing not stable or stable no sync, not parse yet
189     XC_MODEPARSE_OUT_OF_RANGE,          ///< out of spec.
190     XC_MODEPARSE_UNSUPPORT_MODE,        ///< can't find in mode tables
191     XC_MODEPARSE_SUPPORT_MODE,          ///< support mode
192 } XC_MODEPARSE_RESULT;
193 
194 typedef struct DLL_PACKED
195 {
196     // mode parse result
197     MS_U8  u8ModeIndex;                    ///< OUT: mode parse will return the mode index by this variable
198     MS_U16 u16ResWidth;                    ///< OUT: indicate the resolution -> width
199     MS_U16 u16ResHeight;                   ///< OUT: indicate the resolution -> height
200 
201     // src type
202     INPUT_SOURCE_TYPE_t eSrcType;       ///< IN: input source type
203 
204     // Analog
205     MS_U16 u16HFreqx10;                    ///< IN: HFreq x 10, unit KHz after / 10
206     MS_U16 u16VFreqx10;                    ///< IN: VFreq x 10, unit Hz after / 10
207     MS_U16 u16Vtotal;                      ///< IN: Vertical total
208     MS_U8  u8SyncStatus;                   ///< IN: from XC driver, including H/V sync polarity, interlaced or progressive, mode parse will or XC_MD_USER_MODE_BIT if new mode found
209 
210     // Digital
211     MS_WINDOW_TYPE sDVI_HDMI_DE_Info;   ///< IN: DVI/HDMI input DE information
212 
213     // EuroHDTV detected or not
214     MS_DETECT_EURO_HDTV_STATUS_TYPE eEuroHDTVStatus;    ///< IN: timing monitor detect Euro/Aus HDTV status
215 } XC_MODEPARSE_INPUT_INFO;  ///< the neccesary input timing information for mode search
216 
217 typedef enum
218 {
219     RES_640X350,     // 00
220     RES_640X400,     // 01
221     RES_720X400,     // 02
222     RES_640X480,     // 03
223     RES_800X600,     // 04
224     RES_832X624,     // 05
225     RES_1024X768,    // 06
226     RES_1280X1024,   // 07
227     RES_1600X1200,   // 08
228     RES_1152X864,    // 09
229     RES_1152X870,    // 10
230     RES_1280X768,    // 11
231     RES_1280X960,    // 12
232     RES_720X480,     // 13
233     RES_1920X1080,   // 14
234     RES_1280X720,    // 15
235     RES_720X576,     // 16
236     RES_1920X1200,   // 17
237     RES_1400X1050,   // 18
238     RES_1440X900,    // 19
239     RES_1680X1050,   // 20
240     RES_1280X800,    // 21
241     RES_1600X1024,   // 22
242     RES_1600X900,    // 23
243     RES_1360X768,    // 24
244     RES_848X480,     // 25
245     RES_1920X1080P,  // 26
246     RES_1366X768,    // 27
247     RES_864X648,     // 28
248     RES_1280X1470,   // 29
249     RES_1920X2205,   // 30
250     RES_720X240,     // 31
251     RES_720x288,     // 32
252     RES_1152X900,    // 33
253     RES_856x480,     // 34
254     RES_1536X960,    // 35
255     RES_1600X1000,   // 36
256     RES_1704X960,    // 37
257     RES_1728X1080,   // 38
258     RES_1864X1050,   // 39
259     RES_MAXIMUM
260 }EN_RESOLUTION_TYPE;
261 
262 typedef struct DLL_PACKED
263 {
264     EN_RESOLUTION_TYPE enResolutionIndex;   ///< resolution
265 
266     MS_U16 u16HorizontalFrequency;             ///< Horizontal frequency
267     MS_U16 u16VerticalFrequency;               ///< Vertical frequency
268 
269     MS_U16 u16HorizontalStart;                 ///< Horizontal start
270     MS_U16 u16VerticalStart;                   ///< Vertical start
271 
272     MS_U16 u16HorizontalTotal;                 ///< Horizontal Total
273     MS_U16 u16VerticalTotal;                   ///< Vertical Total
274     MS_U8 u8VTotalTolerance;                   ///< VTotal tolerance
275 
276     MS_U8 u8AdcPhase;                          ///< ADC phase
277 
278     MS_U8 u8StatusFlag; ///< flags
279     // b0: VSync polarity(1/0 = positive/negative)
280     // b1: HSync polarity(1/0 = positive/negative)
281     // b2: Sync polarity care bit
282     // b4: interlace mode
283 }MS_PCADC_MODETABLE_TYPE;
284 
285 typedef struct DLL_PACKED
286 {
287     EN_RESOLUTION_TYPE enResolutionIndex;   ///< resolution
288 
289     MS_U16 u16HorizontalFrequency;             ///< Horizontal frequency
290     MS_U16 u16VerticalFrequency;               ///< Vertical frequency
291 
292     MS_U16 u16HorizontalStart;                 ///< Horizontal start
293     MS_U16 u16VerticalStart;                   ///< Vertical start
294 
295     MS_U16 u16HorizontalTotal;                 ///< Horizontal Total
296     MS_U16 u16VerticalTotal;                   ///< Vertical Total
297     MS_U16 u16VTotalTolerance;                   ///< VTotal tolerance
298 
299     MS_U16 u16AdcPhase;                          ///< adc phase
300 
301     MS_U8 u8StatusFlag; ///< flags
302     // b0: VSync polarity(1/0 = positive/negative)
303     // b1: HSync polarity(1/0 = positive/negative)
304     // b2: Sync polarity care bit
305     // b4: interlace mode
306 }MS_PCADC_MODETABLE_TYPE_EX;
307 
308 #if defined(UFO_PUBLIC_HEADER_300)
309 typedef struct
310 {
311     MS_U16 u16DisplayWidth;  // width
312     MS_U16 u16DisplayHeight; // height
313 
314 }MS_MODE_RESOLUTION;
315 #endif
316 
317 //-------------------------------------------------------------------------------------------------
318 //  Function and Variable
319 //-------------------------------------------------------------------------------------------------
320 
321 //-------------------------------------------------------------------------------------------------
322 /// XC Mode Parse initilization
323 /// @ingroup MODE_Parse_INIT
324 /// @return @ref MS_BOOL
325 //-------------------------------------------------------------------------------------------------
326 MS_BOOL MApi_XC_ModeParse_Init(void);
327 // mode search
328 
329 //-------------------------------------------------------------------------------------------------
330 /// XC Mode Parse Match Mode
331 /// @ingroup MODE_Parse_FEATURE
332 /// @param  ModeDB                             \b IN: the mode table
333 /// @param  u16NumberOfItems             \b IN: the item number
334 /// @param  psInputInfo                         \b IN: the Input source information
335 /// @return @ref XC_MODEPARSE_RESULT
336 //-------------------------------------------------------------------------------------------------
337 XC_MODEPARSE_RESULT MApi_XC_ModeParse_MatchMode(MS_PCADC_MODETABLE_TYPE* ModeDB, MS_U8 u16NumberOfItems , XC_MODEPARSE_INPUT_INFO *psInputInfo);
338 
339 //-------------------------------------------------------------------------------------------------
340 /// XC Mode Parse Match Mode EX
341 /// @ingroup MODE_Parse_FEATURE
342 /// @param  ModeDB                             \b IN: the EX mode table
343 /// @param  u16NumberOfItems             \b IN: the item number
344 /// @param  psInputInfo                         \b IN: the Input source information
345 /// @return @ref XC_MODEPARSE_RESULT
346 //-------------------------------------------------------------------------------------------------
347 XC_MODEPARSE_RESULT MApi_XC_ModeParse_MatchModeEx(MS_PCADC_MODETABLE_TYPE_EX* ModeDB, MS_U8 u16NumberOfItems , XC_MODEPARSE_INPUT_INFO *psInputInfo);
348 #ifdef __cplusplus
349 }
350 #endif
351 
352 #endif /* _API_XC_MODEPARSE_H_ */
353