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 #include "UFO.h" 136 137 #define MSIF_GPD_LIB_CODE {'G','P','D','_'} 138 #define MSIF_GPD_LIBVER {'0','1'} 139 #define MSIF_GPD_BUILDNUM {'0','3'} 140 #define MSIF_GPD_CHANGELIST {'0','0','6','1','4','5','9','5'} 141 142 /// Version string. 143 #define GPD_API_VERSION /* Character String for DRV/API version */ \ 144 MSIF_TAG, /* 'MSIF' */ \ 145 MSIF_CLASS, /* '00' */ \ 146 MSIF_CUS, /* 0x0000 */ \ 147 MSIF_MOD, /* 0x0000 */ \ 148 MSIF_CHIP, \ 149 MSIF_CPU, \ 150 MSIF_GPD_LIB_CODE, /* IP__ */ \ 151 MSIF_GPD_LIBVER, /* 0.0 ~ Z.Z */ \ 152 MSIF_GPD_BUILDNUM, /* 00 ~ 99 */ \ 153 MSIF_GPD_CHANGELIST, /* CL# */ \ 154 MSIF_OS 155 156 157 158 #if !defined(U8) 159 #define U8 MS_U8 160 #endif 161 #if !defined(U16) 162 #define U16 MS_U16 163 #endif 164 #if !defined(U32) 165 #define U32 MS_U32 166 #endif 167 #if !defined(S8) 168 #define S8 MS_S8 169 #endif 170 #if !defined(S16) 171 #define S16 MS_S16 172 #endif 173 #if !defined(S32) 174 #define S32 MS_S32 175 #endif 176 177 178 179 #if !defined(TRUE) && !defined(FALSE) 180 #define TRUE 1 181 #define FALSE 0 182 #endif 183 184 #define ARGB8888 0 185 #define YUV422 1 186 #define RGB565 2 187 #define YVYU422 3 188 #define GRAY 4 189 #define GRAY_ALPHA 5 190 191 #ifndef GPD_SUPPORT_MGIF 192 #define GPD_SUPPORT_MGIF 1 193 #endif 194 195 #ifndef GPD_NO_SUPPORT_MGIF 196 #define GPD_NO_SUPPORT_MGIF 0 197 #endif 198 199 #define GPD_VERSION 0x12062516 200 #define WORDALIGN 0x3 201 #define GPD_CLOCK_OFFSET (0x50 << 1) 202 203 #define GPD_UTOPIA20 (1) 204 205 typedef struct DLL_PACKED 206 { 207 MS_PHY u32PA_ReadBufferAddr; 208 MS_VIRT u32VA_ReadBufferAddr; 209 MS_U32 u32ReadBufferSize; 210 MS_PHY u32PA_WriteBufferAddr; 211 MS_VIRT u32VA_WriteBufferAddr; 212 MS_U32 u32WriteBufferSize; 213 MS_PHY u32PA_DepthBufferAddr; 214 MS_VIRT u32VA_DepthBufferAddr; 215 MS_PHY u32PA_ColorBufferAddr; 216 MS_VIRT u32VA_ColorBufferAddr; 217 MS_VIRT RegBaseAddr; 218 MS_VIRT ReadBitBaseAddr; 219 } gpd_addr_info; 220 221 222 typedef struct DLL_PACKED 223 { 224 char *filename; 225 MS_U32 u32Width; 226 MS_U32 u32Height; 227 MS_U8 u8BitPP; 228 MS_U8 u8Interlace; 229 MS_S32 enGPDStatus; //Error Code 230 MS_U8 u8MGIF; 231 } gpd_pic_info; 232 233 234 typedef struct DLL_PACKED 235 { 236 MS_U32 hstart; 237 MS_U32 vstart; 238 MS_U32 width; 239 MS_U32 height; 240 241 } gpd_roi_info; 242 243 typedef struct DLL_PACKED 244 { 245 MS_PHY u32PA_StartAddr; 246 MS_PHY u32PA_EndAddr; 247 248 } gpd_access_region; 249 250 typedef struct DLL_PACKED 251 { 252 MS_U32 u32Width; // input parameter 253 MS_U32 ocolor; // input parameter 254 MS_U32 u32Pitch; // output parameter 255 } gpd_get_pitch_info; 256 257 typedef enum { 258 GPD_STATE_MGIF_TERMINATE, 259 GPD_STATE_GIF_ERROR, 260 GPD_STATE_MGIF_WAIT_BUFFFER, 261 GPD_STATE_GIF_SUCCESS 262 } gpd_state; 263 264 265 typedef enum 266 { 267 E_GPD_USER_CMD_SET_ACCESS_REGION = 0, 268 E_GPD_USER_CMD_SET_CACHEABLE, 269 E_GPD_USER_CMD_SET_DEBUG_LEVEL, 270 271 } gpd_user_cmd; 272 273 typedef enum 274 { 275 E_GPD_GET_CMD_GET_PITCH = 0, 276 277 } gpd_get_cmd; 278 279 typedef enum 280 { 281 E_GPD_SCALE_ONE_TO_TWO, 282 E_GPD_SCALE_ONE_TO_FOUR, 283 E_GPD_SCALE_ONE_TO_EIGHT, 284 E_GPD_SCALE_ONE_TO_SIXTEEN, 285 } gpd_scale_mode; 286 287 #if 1 288 //------------------------------------------------------------------------------------------------- 289 /// This function will initialize the parameters of Mstar GPD 290 /// @ingroup GPD_Basic 291 /// @param SrcBuf \b IN : internal use buffer 292 /// @return void 293 //------------------------------------------------------------------------------------------------- 294 void *MApi_GPD_Init(MS_PHY SrcBuf); 295 //------------------------------------------------------------------------------------------------- 296 /// This function will setup the GPD input picture 297 /// @ingroup GPD_Basic 298 /// @param param \b IN : input pic info 299 /// @param InputBuf \b IN : input pic address 300 /// @param Size \b IN : input Size 301 /// @return S32 302 //------------------------------------------------------------------------------------------------- 303 MS_S32 MApi_GPD_InputSource(gpd_pic_info* param, MS_PHY InputBuf, MS_U32 Size); 304 //------------------------------------------------------------------------------------------------- 305 /// This function will decode the GPD file 306 /// @ingroup GPD_Basic 307 /// @param DecodeBuf \b IN : output buffer address 308 /// @param ocolor \b IN : output color format 309 /// @param Size \b IN : output buffer Size 310 /// @return S32 311 //------------------------------------------------------------------------------------------------- 312 MS_S32 MApi_GPD_OutputDecode(MS_PHY DecodeBuf, MS_U32 ocolor, MS_U32 Size); 313 //------------------------------------------------------------------------------------------------- 314 /// This function will decode the GPD file with ROI 315 /// @ingroup GPD_Basic 316 /// @param DecodeBuf \b IN : output buffer address 317 /// @param ocolor \b IN : output color format 318 /// @param Size \b IN : output buffer Size 319 /// @param roi \b IN : output buffer ROI 320 /// @return S32 321 //------------------------------------------------------------------------------------------------- 322 MS_S32 MApi_GPD_OutputDecodeROI(MS_PHY DecodeBuf, MS_U32 ocolor, MS_U32 Size, gpd_roi_info *roi); 323 //------------------------------------------------------------------------------------------------- 324 /// This function will decode the motion GIF file (to be removed) 325 /// @ingroup GPD_to_be_removed 326 /// @param DecodeBuf \b IN : output buffer address 327 /// @param ocolor \b IN : output color format 328 /// @param Size \b IN : output buffer Size 329 /// @return S32 330 //------------------------------------------------------------------------------------------------- 331 MS_S32 MApi_GPD_OutputDecodeMGIF(MS_PHY DecodeBuf, MS_U32 ocolor, MS_U32 Size); 332 333 //------------------------------------------------------------------------------------------------- 334 /// This function will get the GIF duration (to be removed) 335 /// @ingroup GPD_to_be_removed 336 /// @param void 337 /// @return S32 338 //------------------------------------------------------------------------------------------------- 339 MS_S32 MApi_GPD_GetDuration(void); 340 //------------------------------------------------------------------------------------------------- 341 /// This function will set the MGIF mode (to be removed) 342 /// @ingroup GPD_to_be_removed 343 /// @param void 344 /// @return S32 345 //------------------------------------------------------------------------------------------------- 346 #if defined(UFO_PUBLIC_HEADER_300) || defined(UFO_PUBLIC_HEADER_212) 347 void MApi_GPD_SetGIFMode(int mode); 348 #else 349 void MApi_GPD_SetGIFMode(MS_U32 mode); 350 #endif 351 352 #else 353 354 MS_S32 MAdp_GPD_Init(void); 355 MS_S32 MAdp_GPD_Play(gpd_pic_info* param, MS_U32 ocolor, MS_U8 *srcbuffer, MS_U32 size); 356 MS_S32 MAdp_GPD_Compare(MS_U32 ocolor_typ); 357 #endif 358 359 //------------------------------------------------------------------------------------------------- 360 /// This function will enable the scaling function 361 /// @ingroup GPD_Basic 362 /// @param mode \b IN : scaling mode 363 /// @return void 364 //------------------------------------------------------------------------------------------------- 365 void MApi_GPD_ScalingEnable(MS_U32 mode); 366 //------------------------------------------------------------------------------------------------- 367 /// This function will disable the scaling function 368 /// @ingroup GPD_Basic 369 /// @param void 370 /// @return void 371 //------------------------------------------------------------------------------------------------- 372 void MApi_GPD_ScalingDisable(void); 373 //------------------------------------------------------------------------------------------------- 374 /// This function will set the gpd information 375 /// @ingroup GPD_Basic 376 /// @cmd_id \b IN : control ID 377 /// @param param \b IN : control info 378 /// @return S32 379 //------------------------------------------------------------------------------------------------- 380 MS_U32 MApi_GPD_SetControl(gpd_user_cmd cmd_id, MS_VIRT param); 381 //------------------------------------------------------------------------------------------------- 382 /// This function will get the gpd information 383 /// @ingroup GPD_Basic 384 /// @cmd_id \b IN : control ID 385 /// @param param \b IN : control info 386 /// @return S32 387 //------------------------------------------------------------------------------------------------- 388 #if defined(UFO_PUBLIC_HEADER_300) || defined(UFO_PUBLIC_HEADER_212) 389 U32 MApi_GPD_GetControl(gpd_get_cmd cmd_id, U32* param); 390 #else 391 MS_U32 MApi_GPD_GetControl(gpd_get_cmd cmd_id, MS_VIRT param); 392 #endif 393 394 //------------------------------------------------------------------------------------------------- 395 /// This function will get the crc information 396 /// @ingroup GPD_Debug 397 /// @param pu8Data \b IN : address 398 /// @param u32Size \b IN : size 399 /// @param u32Width \b IN : width 400 /// @param ocolor \b IN : color format 401 /// @return S32 402 //------------------------------------------------------------------------------------------------- 403 #if defined(UFO_PUBLIC_HEADER_300) || defined(UFO_PUBLIC_HEADER_212) 404 U32 MApi_GPD_GetCRCResult(const MS_U8 *pu8Data, MS_U32 u32Size, MS_U32 u32Width, unsigned int ocolor); 405 #else 406 MS_U32 MApi_GPD_GetCRCResult(const MS_U8 *pu8Data, MS_U32 u32Size, MS_U32 u32Width, MS_U32 ocolor); 407 #endif 408 409 #ifdef __cplusplus 410 } 411 #endif 412 413 414 #endif 415 416