xref: /utopia/UTPA2-700.0.x/projects/tmplib/include/apiGPD.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-2007 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // (��MStar Confidential Information��) by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 //
93 ////////////////////////////////////////////////////////////////////////////////
94 
95 
96 /////////////////////////////////////////////////////////////////////////////////////////////////
97 /// @file   apiGPD.h
98 /// @brief  GPD driver
99 /// @author MStar Semiconductor Inc.
100 /// @version 1.0
101 ////////////////////////////////////////////////////////////////////////////////////////////////
102 
103 /*! \defgroup GPD GPD interface (apiGPD.h)
104     \ingroup VDEC
105 
106    <b> The supporting features of Mstar GPD HW IP are listed in the following: </b>
107    -# GIF/PNG decoder (GPD)
108    -# Support up to 8192 x 8192 pixel image(per channel 8 bits), or 4096 x 8192(per channel 16 bits)pixel image
109    -# Original png format 1bpp/2bpp/4bpp/8bpp index(palette) mode support
110    -# Original png format ARGB8888, RGB565, gray, gray with alpha mode support
111    -# Transparency mode support on png (alpha=0)
112    -# ARGB8888, RGB565, YUV422(YUYV),YUV422(YVYU),gray, gray with alpha output format support
113    -# gif support
114    -# scaling down mode on X/Y both directions (1/2,1/4,1/8,1/16) for PNG progressive mode, and (1/8,1/16) for PNG interlace mode and GIF
115 
116     <b> Operation Code Flow: </b> \n
117     check flow chart directly.
118     \image html GPD_decode_flow.png
119 
120 *! \defgroup GPD_Basic GPD Basic APIs
121 *  \ingroup GPD
122 *! \defgroup GPD_Debug GPD Debug APIs
123 *  \ingroup GPD
124 *! \defgroup GPD_to_be_removed GPD_to_be_removed (to be removed)
125 *  \ingroup GPD
126 */
127 
128 #ifndef _API_GPD_H_
129 #define _API_GPD_H_
130 
131 #ifdef __cplusplus
132 extern "C" {
133 #endif
134 
135 #define MSIF_GPD_LIB_CODE      {'G','P','D','_'}
136 #define MSIF_GPD_LIBVER        {'0','1'}
137 #define MSIF_GPD_BUILDNUM      {'0','3'}
138 #define MSIF_GPD_CHANGELIST    {'0','0','6','1','4','5','9','5'}
139 
140 /// Version string.
141 #define GPD_API_VERSION                /* Character String for DRV/API version             */  \
142     MSIF_TAG,                           /* 'MSIF'                                           */  \
143     MSIF_CLASS,                         /* '00'                                             */  \
144     MSIF_CUS,                           /* 0x0000                                           */  \
145     MSIF_MOD,                           /* 0x0000                                           */  \
146     MSIF_CHIP,                                                                                  \
147     MSIF_CPU,                                                                                   \
148     MSIF_GPD_LIB_CODE,                 /* IP__                                             */  \
149     MSIF_GPD_LIBVER,                   /* 0.0 ~ Z.Z                                        */  \
150     MSIF_GPD_BUILDNUM,                 /* 00 ~ 99                                          */  \
151     MSIF_GPD_CHANGELIST,               /* CL#                                              */  \
152     MSIF_OS
153 
154 
155 
156 
157 #if !defined(TRUE) && !defined(FALSE)
158 #define TRUE 1
159 #define FALSE 0
160 #endif
161 
162 #define ARGB8888 0
163 #define YUV422   1
164 #define RGB565   2
165 #define YVYU422  3
166 #define GRAY     4
167 #define GRAY_ALPHA 5
168 
169 #ifndef GPD_SUPPORT_MGIF
170 #define GPD_SUPPORT_MGIF 1
171 #endif
172 
173 #ifndef GPD_NO_SUPPORT_MGIF
174 #define GPD_NO_SUPPORT_MGIF 0
175 #endif
176 
177 #define GPD_VERSION 0x12062516
178 #define WORDALIGN  0x3
179 #define GPD_CLOCK_OFFSET (0x50 << 1)
180 
181 #define GPD_UTOPIA20       (1)
182 
183 typedef struct
184 {
185     MS_PHY    u32PA_ReadBufferAddr;
186     MS_VIRT    u32VA_ReadBufferAddr;
187     MS_U32    u32ReadBufferSize;
188     MS_PHY    u32PA_WriteBufferAddr;
189     MS_VIRT    u32VA_WriteBufferAddr;
190     MS_U32    u32WriteBufferSize;
191     MS_PHY       u32PA_DepthBufferAddr;
192     MS_VIRT    u32VA_DepthBufferAddr;
193     MS_PHY       u32PA_ColorBufferAddr;
194     MS_VIRT       u32VA_ColorBufferAddr;
195     MS_VIRT    RegBaseAddr;
196     MS_VIRT    ReadBitBaseAddr;
197 } gpd_addr_info;
198 
199 
200 typedef struct
201 {
202     char   *filename;
203     MS_U32    u32Width;
204     MS_U32    u32Height;
205     MS_U8     u8BitPP;
206     MS_U8     u8Interlace;
207     MS_S32    enGPDStatus;    //Error Code
208     MS_U8     u8MGIF;
209 } gpd_pic_info;
210 
211 
212 typedef struct
213 {
214     MS_U32    hstart;
215     MS_U32    vstart;
216     MS_U32    width;
217     MS_U32    height;
218 
219 } gpd_roi_info;
220 
221 typedef struct
222 {
223     MS_PHY u32PA_StartAddr;
224     MS_PHY u32PA_EndAddr;
225 
226 } gpd_access_region;
227 
228 typedef struct
229 {
230     MS_U32    u32Width;    // input parameter
231     MS_U32    ocolor;      // input parameter
232     MS_U32    u32Pitch;    // output parameter
233 } gpd_get_pitch_info;
234 
235 typedef enum {
236     GPD_STATE_MGIF_TERMINATE,
237     GPD_STATE_GIF_ERROR,
238     GPD_STATE_MGIF_WAIT_BUFFFER,
239     GPD_STATE_GIF_SUCCESS
240 } gpd_state;
241 
242 
243 typedef enum
244 {
245     E_GPD_USER_CMD_SET_ACCESS_REGION = 0,
246     E_GPD_USER_CMD_SET_CACHEABLE,
247 
248 } gpd_user_cmd;
249 
250 typedef enum
251 {
252     E_GPD_GET_CMD_GET_PITCH = 0,
253 
254 } gpd_get_cmd;
255 
256 typedef enum
257 {
258     E_GPD_SCALE_ONE_TO_TWO,
259     E_GPD_SCALE_ONE_TO_FOUR,
260     E_GPD_SCALE_ONE_TO_EIGHT,
261     E_GPD_SCALE_ONE_TO_SIXTEEN,
262 } gpd_scale_mode;
263 
264 #if 1
265 //-------------------------------------------------------------------------------------------------
266 /// This function will initialize the parameters of Mstar GPD
267 /// @ingroup GPD_Basic
268 /// @param SrcBuf \b IN : internal use buffer
269 /// @return void
270 //-------------------------------------------------------------------------------------------------
271 void *MApi_GPD_Init(MS_PHY SrcBuf);
272 //-------------------------------------------------------------------------------------------------
273 /// This function will setup the GPD input picture
274 /// @ingroup GPD_Basic
275 /// @param param \b IN : input pic info
276 /// @param InputBuf \b IN : input pic address
277 /// @param Size \b IN : input Size
278 /// @return S32
279 //-------------------------------------------------------------------------------------------------
280 MS_S32 MApi_GPD_InputSource(gpd_pic_info* param, MS_PHY InputBuf, MS_U32 Size);
281 //-------------------------------------------------------------------------------------------------
282 /// This function will decode the GPD file
283 /// @ingroup GPD_Basic
284 /// @param DecodeBuf \b IN : output buffer address
285 /// @param ocolor \b IN : output color format
286 /// @param Size \b IN : output buffer Size
287 /// @return S32
288 //-------------------------------------------------------------------------------------------------
289 MS_S32 MApi_GPD_OutputDecode(MS_PHY DecodeBuf, MS_U32 ocolor, MS_U32 Size);
290 //-------------------------------------------------------------------------------------------------
291 /// This function will decode the GPD file with ROI
292 /// @ingroup GPD_Basic
293 /// @param DecodeBuf \b IN : output buffer address
294 /// @param ocolor \b IN : output color format
295 /// @param Size \b IN : output buffer Size
296 /// @param roi \b IN : output buffer ROI
297 /// @return S32
298 //-------------------------------------------------------------------------------------------------
299 MS_S32 MApi_GPD_OutputDecodeROI(MS_PHY DecodeBuf, MS_U32 ocolor, MS_U32 Size, gpd_roi_info *roi);
300 //-------------------------------------------------------------------------------------------------
301 /// This function will decode the motion GIF file (to be removed)
302 /// @ingroup GPD_to_be_removed
303 /// @param DecodeBuf \b IN : output buffer address
304 /// @param ocolor \b IN : output color format
305 /// @param Size \b IN : output buffer Size
306 /// @return S32
307 //-------------------------------------------------------------------------------------------------
308 MS_S32 MApi_GPD_OutputDecodeMGIF(MS_PHY DecodeBuf, MS_U32 ocolor, MS_U32 Size);
309 
310 //-------------------------------------------------------------------------------------------------
311 /// This function will get the GIF duration (to be removed)
312 /// @ingroup GPD_to_be_removed
313 /// @param void
314 /// @return S32
315 //-------------------------------------------------------------------------------------------------
316 MS_S32 MApi_GPD_GetDuration(void);
317 //-------------------------------------------------------------------------------------------------
318 /// This function will set  the MGIF mode (to be removed)
319 /// @ingroup GPD_to_be_removed
320 /// @param void
321 /// @return S32
322 //-------------------------------------------------------------------------------------------------
323 void MApi_GPD_SetGIFMode(MS_U32 mode);
324 
325 
326 #else
327 
328 MS_S32 MAdp_GPD_Init(void);
329 MS_S32 MAdp_GPD_Play(gpd_pic_info* param, MS_U32 ocolor, MS_U8 *srcbuffer, MS_U32 size);
330 MS_S32 MAdp_GPD_Compare(MS_U32 ocolor_typ);
331 #endif
332 
333 //-------------------------------------------------------------------------------------------------
334 /// This function will enable the scaling function
335 /// @ingroup GPD_Basic
336 /// @param mode \b IN : scaling mode
337 /// @return void
338 //-------------------------------------------------------------------------------------------------
339 // void MApi_GPD_ScalingEnable(MS_U32 mode);
340 //-------------------------------------------------------------------------------------------------
341 /// This function will disable the scaling function
342 /// @ingroup GPD_Basic
343 /// @param void
344 /// @return void
345 //-------------------------------------------------------------------------------------------------
346 // void MApi_GPD_ScalingDisable(void);
347 //-------------------------------------------------------------------------------------------------
348 /// This function will set the gpd information
349 /// @ingroup GPD_Basic
350 /// @cmd_id \b IN : control ID
351 /// @param param \b IN : control info
352 /// @return S32
353 //-------------------------------------------------------------------------------------------------
354 MS_U32 MApi_GPD_SetControl(gpd_user_cmd cmd_id, MS_VIRT param);
355 //-------------------------------------------------------------------------------------------------
356 /// This function will get the gpd information
357 /// @ingroup GPD_Basic
358 /// @cmd_id \b IN : control ID
359 /// @param param \b IN : control info
360 /// @return S32
361 //-------------------------------------------------------------------------------------------------
362 // MS_U32 MApi_GPD_GetControl(gpd_get_cmd cmd_id, MS_VIRT param);
363 //-------------------------------------------------------------------------------------------------
364 /// This function will get the crc information
365 /// @ingroup GPD_Debug
366 /// @param pu8Data \b IN : address
367 /// @param u32Size \b IN : size
368 /// @param u32Width \b IN : width
369 /// @param ocolor \b IN : color format
370 /// @return S32
371 //-------------------------------------------------------------------------------------------------
372 // MS_U32 MApi_GPD_GetCRCResult(const MS_U8 *pu8Data, MS_U32 u32Size, MS_U32 u32Width, MS_U32 ocolor);
373 
374 #ifdef __cplusplus
375 }
376 #endif
377 
378 
379 #endif
380 
381