xref: /utopia/UTPA2-700.0.x/projects/tmplib/include/drv_mfe_st.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 // (uMStar Confidential Informationv) 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 #ifndef _DRV_MFE_ST_H_
97 #define _DRV_MFE_ST_H_
98 
99 #ifdef __cplusplus
100 extern "C"
101 {
102 #endif
103 
104 
105 #define MFE_SUPPORT_REDUCE_MODE
106 // This version of MFE driver supports "reduce mode" which includes
107 // two flags that can be turned on/off seperately. Refer to
108 // 'enableReduceBW' and 'enableFastMode' in struct PVR_Info below.
109 
110 
111 typedef enum {
112     MFE_Invalid            = 0x00,
113     MFE_Init                 = 0x20,
114     MFE_Idle                =0x30,
115     MFE_Busy               =0x40,
116     MFE_DeInit             =0x50,
117     MFE_Error               =0x60
118  } MFE_STATE;
119 
120 typedef enum
121 {
122 MFE_CLK_VERY_SLOW = 0,
123 MFE_CLK_SLOW = 1,
124 MFE_CLK_MEDIUM = 2,
125 MFE_CLK_FAST = 3,
126 } MFE_CLK_LEVEL;
127 
128 
129 typedef enum
130 {
131 BITS_INFO_ZERO = 0,
132 BITS_INFO_UNKNOW,
133 BITS_INFO_FRAMEDONE,
134 BITS_INFO_BUFFULL,
135 BITS_INFO_IMG_BUFFULL,
136 } BITS_STATUS_INFO;
137 
138 typedef enum
139 {
140 GETBITS_NOT_READY=0,
141 GETBITS_READY=1,
142 } MFE_HW_STATUS;
143 
144 typedef enum
145 {
146 PROGRESSIVE = 0,
147 INTERLACE_SPLITED,
148 INTERLACE_NONSPLITED,
149 } MFE_INTERLACE_INFO;
150 
151 typedef enum
152 {
153 YUVTILE = 0,
154 MSTTILE = 1,
155 MFE_YUYV = 2,
156 MFE_YVYU = 3,
157 MFE_UYVY = 4,
158 MFE_VYUY = 5,
159 } MFE_COLOR_FORMAT_INFO;
160 
161 #define MAX_OUTBUFFER 10UL
162 
163 typedef struct {
164     MS_PHY miuAddress;    //hardware physical
165     MS_VIRT miuPointer;    //need to OR 0xA0000000
166     MS_VIRT virtual_addr;
167     MS_S32 size;
168     BITS_STATUS_INFO status;    // 1: frame_done. 2: buffer full,3: image buffer full.
169     MS_S32 is_more_bits; //1: there are more bitstream packet;  0: this is the last bitstream packet
170     MS_U8  voptype;
171     MS_PHY IVOP_address;
172     MS_S32 stuffing_bytes;     //CABAC stuffing byte
173 } BITSFRAME_INFO;
174 
175 /* Linear memory area descriptor */
176 typedef struct MEMMAP
177 {
178     //MS_U32 *miuPointer;
179     MS_U8 *miuPointer;
180     MS_PHY miuAddress;
181     MS_U32 size;
182 } MEMMAP_t;
183 
184 typedef struct MEMMAP_CUR
185 {
186     MEMMAP_t Cur_Y0;
187     MEMMAP_t Cur_C0;
188     MEMMAP_t Cur_Y1;
189     MEMMAP_t Cur_C1;
190 } MEMMAP_CUR_t;
191 
192 /* madp_mfe crop info */
193 typedef struct _MFE_CROP_INFO
194 {
195     MS_BOOL crop_en;
196     MS_U32 crop_top;
197     MS_U32 crop_bottom;
198     MS_U32 crop_left;
199     MS_U32 crop_right;
200 } MFE_CROP_INFO_t;
201 
202 /* madp_mfe api info */
203 typedef struct _MFE_API_INFO
204 {
205     MS_PHY miu_offset;
206     MS_PHY mfe_phy_buf_addr;
207     MS_VIRT mfe_vir_buf_ptr;
208     MS_U32 mfe_phy_buf_size;
209     MS_U32 Encode_stop;
210 } MFE_API_INFO_t;
211 
212 typedef struct _MFE_ADV_INFO
213 {
214     MS_U32 low_bandwidth_en;
215     MS_U32 input_imi_en;
216     MEMMAP_t imi_buf_addr;
217 } MFE_ADV_INFO_t;
218 
219 typedef struct{
220     MS_U32 is_off;
221     MFE_CLK_LEVEL clock_level;
222 } POWERON_t;
223 
224 typedef struct _SPSPPS_INFO
225 {
226     MS_U8* pHeaderSPS;
227     MS_U32 SPSLen;
228     MS_U8* pHeaderPPS;
229     MS_U32 PPSLen;
230 } SPSPPS_INFO_t;
231 
232 typedef struct _VOL_INFO
233 {
234     MS_U8* pHeader;
235     MS_U32 Len;
236 } VOL_INFO_t;
237 
238 // bFirst_or_last_byte_of_Frame: 0x00 error state, 0x10 first , 0x01 last at frame, 0x11 one frame
239 typedef void (*StreamCallback)(void *pCtx, MS_S32 s32FrameType, void *pStreamData, MS_U32 u32DataLen, MS_U32 bFirstOrLastByteOfFrame);
240 
241 typedef void (*CleanCallback)(MS_U32 u32FrameCoded, MS_VIRT u32YUVPlane);
242 
243 
244 // MADP-layer "simplified" encoder configuration
245 // NOTE: "Advanced" configurations are hidden inside DRV-layer.
246 typedef struct{
247     // MFE-compliant
248     MS_S32 width;
249     MS_S32 height;
250     MS_PHY BitsBuffStart;
251     MS_U32 BitsBuffSize;
252     MS_S32 nOutBuffer;
253     MS_S32 OutBufferSize;
254     MEMMAP_t InBuffer;
255     MEMMAP_t BitstreamOutBuffer;
256     MS_S32 BitstreamOutBufferSize;
257 
258     // MFE new settings
259     //MFE_COLOR_FORMAT_INFO nColorFormat;
260     MS_S32 nCodecType;
261     MS_S32 nDispWidth, nDispHeight;    // Display resolution
262     MS_S32 nBufWidth, nBufHeight;        // Image buffer resolution (aligned to 16 or 32 byte, depends on nCodecType)
263     MFE_INTERLACE_INFO bInterlace;
264     MFE_COLOR_FORMAT_INFO bColorFormat;
265     // GOP
266     MS_S32 nPbetweenI;
267     MS_S32 nBbetweenP;
268     MS_S32 nP_is_infinite;
269     // Rate control
270     MS_S32 FrameRatex100;
271     MS_S32 nBitrate;
272     MS_S32 m_bFrameMode;
273     MS_S32 out_frametag_top;
274     // Video length
275     MS_S32 nTotalFrames;    // -1 means infinite. 0 is not allowed.
276     MS_S32 TimeIncreamentRes;              // [IN] frame rate
277     MS_S32 VopTimeIncreament;              // [IN] frame rate
278     //jpeg parameter
279     MS_S32 quality;
280     MS_S32 fdc_mode;
281     MS_S32 exif_enable;
282     MFE_CLK_LEVEL MFEClk;
283 
284     MFE_API_INFO_t MfeApiInfo;
285     MFE_ADV_INFO_t MfeAdvInfo;
286 
287     MS_U32 nDropFlag;
288     MS_U32 nSkipFlag;
289     MS_U32 enableVTRateControl;
290     MS_U32 enableSecurityMode;
291     MS_U32 enableISR;
292     MS_U32 enableCABAC; //main profile
293 
294     MFE_CROP_INFO_t  MfeCropInfo;
295     MS_U32 enableReduceBW; //Memory BW reduced mode
296     MS_U32 enableFastMode; //intra mode inly 0~2, drop i16 and disable fme.
297     MFE_STATE mfe_state;
298     void* g_pCustomCtx;
299     StreamCallback g_StreamCallBackFunc;
300     CleanCallback g_CleanCallBackFunc;
301 
302     void* mfe_drvHandle;
303 
304     MS_S32 reserved0;
305     MS_S32 reserved1;
306     MS_S32 reserved2;
307     MS_S32 reserved3;
308     MS_S32 reserved4;
309     MS_S32 reserved5;
310 }PVR_Info;
311 
312 #define API_HWCAP_VERSION0 1UL
313 
314 typedef struct{
315     MS_U32 u32ApiHW_Version;   //<Version of current structure>
316     MS_U16 u16ApiHW_Length;    //<Length of this structure>
317     MS_BOOL bIsSupportEncoder;
318     MS_U8 u8MaxEncodeFrame;
319     MS_U16 u16MaxEncodeWidth;
320     MS_U16 u16MaxEncodeHeight;
321     MS_BOOL bSupportSubVidWin;
322     MS_BOOL bSupportMpeg4;
323     MS_BOOL bSupportH264;
324     /*New Cap add in struct add at the end*/
325 }MFE_HwCapV0;
326 
327 #ifdef __cplusplus
328 }
329 #endif
330 
331 #endif
332