xref: /utopia/UTPA2-700.0.x/modules/vdec_v3/hal/manhattan/hvd_v3/fwHVD_if.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 
95 #ifndef _FW_HVD_IF_H_
96 #define _FW_HVD_IF_H_
97 
98 #include "controller.h"
99 //-------------------------------------------------------------------------------------------------
100 //  Hardware Capability
101 //-------------------------------------------------------------------------------------------------
102 #define HVD_FW_VERSION 0x00001491
103 #define HVD_FW_IF_VERSION 0x00750191
104 
105 //-------------------------------------------------------------------------------------------------
106 //  Macro and Define
107 //-------------------------------------------------------------------------------------------------
108 // TOP
109 //#if (!(defined( MSOS_TYPE_NOS) ||defined( MSOS_TYPE_ECOS) || defined( MSOS_TYPE_LINUX)))
110 #if (!defined( _MS_TYPES_H_)  && (!defined(_DRVHVD_COMMON_H_)))
111 typedef unsigned char               MS_BOOL;                            // 1 byte
112 /// data type unsigned char, data length 1 byte
113 typedef unsigned char               MS_U8;                              // 1 byte
114 /// data type unsigned short, data length 2 byte
115 typedef unsigned short              MS_U16;                             // 2 bytes
116 /// data type unsigned int, data length 4 byte
117 typedef unsigned long               MS_U32;                             // 4 bytes
118 /// data type unsigned int64, data length 8 byte
119 typedef unsigned long long          MS_U64;                             // 8 bytes
120 /// data type signed char, data length 1 byte
121 typedef signed char                 MS_S8;                              // 1 byte
122 /// data type signed short, data length 2 byte
123 typedef signed short                MS_S16;                             // 2 bytes
124 /// data type signed int, data length 4 byte
125 typedef signed long                 MS_S32;                             // 4 bytes
126 /// data type signed int64, data length 8 byte
127 typedef signed long long            MS_S64;                             // 8 bytes
128 #endif
129 
130 
131 
132 #define HVD_DRAM_CMDQ_CMD_SIZE 4
133 #define HVD_DRAM_CMDQ_ARG_SIZE 4
134 
135 
136 
137 #define HVD_DRAM_SIZE    0x40000       // Default HVD DRAM heap size, 256k
138 #define EVD_DRAM_SIZE    0xD0000       // Default EVD DRAM heap size, 832k
139 #define EVD_DV_DRAM_SIZE 0x1A0000      // Default Dolby vision EVD DRAM heap size, 1664k
140 
141 #define TEE_ONE_TASK_SHM_SIZE           (0x30000)  // 192K
142 
143 #define HVD_SHARE_MEM_ST_SIZE           (0x1000)
144 
145 #define HVD_VBBU_DRAM_ST_SIZE           (0x2000)
146 #define HVD_DISP_FRM_INFO_EXT_ST_SIZE   (0x1D00)
147 #define HVD_CMDQ_DRAM_ST_SIZE           (0x100) //Command Queue must align (CMD + ARG) length, ex. 8 bytes, or will encounter bug when use circular buff
148 #define HVD_DISPCMDQ_DRAM_ST_SIZE       (0x200) //Command Queue must align (CMD + ARG) length, ex. 8 bytes, or will encounter bug when use circular buff
149 #define HVD_PTS_TABLE_ST_SIZE           (0x4000)
150 
151 #define HVD_BBU_DRAM_ST_SIZE            (0x2000)
152 #define HVD_BBU2_DRAM_ST_SIZE           (0x3000)
153 #define HVD_AVC_DTVINFO_SIZE            (0x1000)
154 #define HVD_AVC_INFO608_SIZE            (0x1000)
155 #define HVD_AVC_INFO708_SIZE            (0x4800)
156 #define HVD_AVC_USERDATA_SIZE           (0x2900)
157 
158 #define MIN_4K2K_WIDTH  3800
159 #define MIN_4K2K_HEIGHT 2000
160 
161 #define VDEC_MIUSEL_MASK                  (0x3)
162 #define VDEC_BS_MIUSEL                    (0)
163 #define VDEC_LUMA8_MIUSEL                 (2)
164 #define VDEC_LUMA2_MIUSEL                 (4)
165 #define VDEC_CHROMA8_MIUSEL               (6)
166 #define VDEC_CHROMA2_MIUSEL               (8)
167 #define VDEC_HWBUF_MIUSEL                 (10)
168 #define VDEC_BUF1_MIUSEL                  (12)
169 #define VDEC_BUF2_MIUSEL                  (14)
170 #define VDEC_PPIN_MIUSEL                  (16)
171 #define VDEC_XCSHM_MIUSEL                 (18)
172 
173 #define HVD_DisplayColourVolume_SEI_SIZE  (0x10)
174 #define HVD_DisplayColourVolume_SEI_NUM   (2)
175 #define HVD_ContentLightLevel_SEI_SIZE    (0x8)
176 #define HVD_ContentLightLevel_SEI_NUM     (0x2)
177 
178 
179 //========= HW settings (Offset base is code buffer address.) =========
180 
181 #define MAX_PTS_TABLE_SIZE              1024 // 1024 * 16 = 0x4000
182 
183 #define AVOID_PTS_TABLE_OVERFLOW_THRESHOLD   24
184 #define HVD_BYTE_COUNT_MASK             0x1FFFFFFF // hvd fw reg_byte_pos 29bit
185 
186 // bbu entry. 64bits(8 bytes) every entry.
187 #define HVD_BBU_DRAM_TBL_ENTRY          (HVD_BBU_TBL_SIZE/8)
188 #define HVD_BBU_DRAM_TBL_ENTRY_TH       (HVD_BBU_DRAM_TBL_ENTRY-4)
189 #define HVD_BBU2_DRAM_TBL_ENTRY         (HVD_BBU_TBL_SIZE/8)
190 #define HVD_BBU2_DRAM_TBL_ENTRY_TH      (HVD_BBU2_DRAM_TBL_ENTRY-4)
191 
192 #define MVC_BBU_DRAM_TBL_ENTRY          (HVD_BBU_TBL_SIZE/8)
193 #define MVC_BBU_DRAM_TBL_ENTRY_TH       (MVC_BBU_DRAM_TBL_ENTRY-4)
194 #define MVC_BBU2_DRAM_TBL_ENTRY         (HVD_BBU_TBL_SIZE/8)
195 #define MVC_BBU2_DRAM_TBL_ENTRY_TH      (MVC_BBU2_DRAM_TBL_ENTRY-4)
196 
197 #define RVD_BBU_DRAM_TBL_ENTRY          (HVD_BBU_TBL_SIZE/8)
198 #define RVD_BBU_DRAM_TBL_ENTRY_TH       (RVD_BBU_DRAM_TBL_ENTRY-4)
199 
200 #define VP8_BBU_DRAM_TBL_ENTRY          (VP8_BBU_TBL_SIZE/8)
201 #define VP8_BBU_DRAM_TBL_ENTRY_TH       (VP8_BBU_DRAM_TBL_ENTRY-4)
202 
203 #if defined(SUPPORT_EVD) && (SUPPORT_EVD==1)
204 #define HVD_SHARE_MEM_ST_OFFSET        0x100000
205 #else
206 #define HVD_SHARE_MEM_ST_OFFSET         0xA0000
207 #endif
208 
209 #define HVD_DYNAMIC_SCALING_SIZE         0x1F00
210 #define HVD_DYNAMIC_SCALING_SIZE_3K       0xC00 // allocate 6k.   actually use: 16 align => 3k
211 #define HVD_DYNAMIC_SCALING_SIZE_6K      0x1800 // allocate 6k.   actually use: 32 align => 6k
212 #define HVD_DYNAMIC_SCALING_DEPTH          0x10
213 #define HVD_DYNAMIC_SCALING_3D_DEPTH       0x18 /// 3D Dynamic scaling use 24.
214 #define HVD_SCALER_INFO_SIZE              0x100
215 
216 #define HVD_AVC_FRAME_PACKING_SEI_SIZE  0x100
217 #define HVD_AVC_FRAME_PACKING_SEI_NUM   2
218 
219 //DBG
220 #define HVD_DBG_DUMP_SIZE                0x6500
221 #define HVD_DUMMY_WRITE_MAX_SIZE          0x200
222 
223 #define MAX_VSYNC_BRIDGE_DISPQ_NUM      8
224 #define HVD_DISP_QUEUE_MAX_SIZE         42
225 
226 // AVC
227 #define HVD_FW_AVC_DUMMY_FIFO                 256  // bytes
228 #define HVD_FW_AVC_MAX_DECODE_TICK         100000  // tick ???
229 #define HVD_FW_AVC_MAX_VIDEO_DELAY           1000  // ms ; based on ???
230 #define HVD_FW_AVC_ES_MIN_TSP_DATA_SIZE     0x100
231 #define HVD_FW_AVC_ES_MIN_TSP_DATA_SIZE2   0x1800
232 #define HVD_FW_BROKEN_BY_US_MIN_DATA_SIZE  0x1800
233 
234 #define HVD_FW_AVC_ES_UNDER_THRESHOLD     0x800   // 2048
235 #define HVD_FW_AVC_ES_OVER_THRESHOLD    0x40000 // 256*1024
236 
237 // User CC
238 #define USER_CC_DATA_SIZE               38
239 #define USER_CC_IDX_SIZE                12
240 
241 // AVS
242 #define HVD_FW_AVS_DUMMY_FIFO           2048 //BYTES
243 
244 // RM
245 #define HVD_FW_RM_DUMMY_FIFO            256  // ??
246 #define HVD_RM_INIT_PICTURE_SIZE_NUMBER 8
247 
248 #define EXT_CC_INFO_LENGTH            16
249 #define EXT_608_CC_PACKET_LENGTH      16
250 #define EXT_608_CC_DATA_ALIGN   EXT_608_CC_PACKET_LENGTH
251 #define EXT_708_CC_PACKET_LENGTH     128
252 #define EXT_708_CC_DATA_ALIGN   EXT_708_CC_PACKET_LENGTH
253 
254 
255 
256 // Debug
257 #define HVD_FW_AVS_OUTPUT_INFO_ADDR     0x20001F00UL
258 #define HVD_FW_AVC_OUTPUT_INFO_ADDR     0x20001F00UL
259 
260 #define HVD_HW_PREFETCH_SIZE            128
261 #define HVD_DUMMY_PACKET_SIZE           (HVD_HW_PREFETCH_SIZE << 1)
262 #define HVD_DUMMY_PACKET_DATA           0x0
263 #define HVD_DUMMY_PACKET_OFFSET         0x0
264 
265 #define PRESET_ONE_PENDING_BUFFER       (1 << 0)  /// For AVC, one pending buffer mode, reduce from two to one
266 #define PRESET_IAP_GN_SHARE_BW_MODE     (1 << 1)  /// For AVC 4K2K, move IAP GN buffer to another miu to share BW mode  //johnny.ko
267 #define PRESET_DUMMY_PACKET_READY       (1 << 2)  /// For checking HW BBU status after filling nal table
268 #define PRESET_4K2K_CHECK               (1 << 3)  /// For checking 4k2k need support or not
269 #define PRESET_FORCE_START_NON_I_SLICE  (1 << 4)  /// For force start decode frame when 1st slice is not I slice.
270 
271 #define MFCODEC_INFO_UNCOMPRESS_OFFSET  28
272 #define MFCODEC_INFO_MIU_SELECT_OFFSET  24
273 #define MFCODEC_INFO_PITCH_OFFSET       16
274 
275 // For Git Changes
276 #define GIT_TIMESTAMP 1457445222
277 
278 typedef enum
279 {
280     E_HVD_IQMEM_INIT_NONE = 0,
281     E_HVD_IQMEM_INIT_LOADING,   //HK -> FW
282     E_HVD_IQMEM_INIT_LOADED,    //FW -> HK
283     E_HVD_IQMEM_INIT_FINISH     //HK -> FW
284 
285 }HVD_IQMEM_INIT_STATUS;
286 
287 
288 
289 typedef enum
290 {
291     E_HVD_FLUSH_NONE = 0,
292     E_HVD_FLUSH_RUNNING,     //HK -> FW
293     E_HVD_FLUSH_DONE         //FW -> HK
294 
295 }HVD_FLUSH_STATUS;
296 
297 typedef enum
298 {
299     E_HVD_ISR_EVENT_NONE = 0,                        ///< disable ISR
300     E_HVD_ISR_EVENT_DISP_ONE = BIT(0),               ///< HVD display one frame on screen.
301     E_HVD_ISR_EVENT_DISP_REPEAT = BIT(1),            ///< The current displayed frame is repeated frame.
302     E_HVD_ISR_EVENT_DISP_WITH_CC = BIT(2),           ///< Current displayed frame should be displayed with user data.
303     E_HVD_ISR_EVENT_DISP_FIRST_FRM = BIT(3),         ///< HVD display first frame on screen.
304 
305     E_HVD_ISR_EVENT_DEC_CMA_ACTION = BIT(7),         ///< HVD CMA allocate/release memory ISR
306     E_HVD_ISR_EVENT_DEC_ONE = BIT(8),                ///< HVD decoded one frame done.
307     E_HVD_ISR_EVENT_DEC_I = BIT(9),                  ///< HVD decoded one I frame done.
308     E_HVD_ISR_EVENT_DEC_HW_ERR = BIT(10),            ///< HVD HW found decode error.
309     E_HVD_ISR_EVENT_DEC_CC_FOUND = BIT(11),          ///< HVD found one user data with decoded frame(with display order).
310     E_HVD_ISR_EVENT_DEC_DISP_INFO_CHANGE = BIT(12),  ///< HVD found display information change.
311     E_HVD_ISR_EVENT_DEC_DATA_ERR = BIT(13),          ///< HVD HW found decode error.
312     E_HVD_ISR_EVENT_DEC_FIRST_FRM = BIT(14),         ///< HVD decode first frame.
313     E_HVD_ISR_EVENT_DEC_SEQ_HDR_FOUND = BIT(15),     ///< HVD found sequence header.
314 } HVD_ISR_Event_Type;
315 
316 typedef enum
317 {
318     E_HVD_USER_DATA_MODE_DVB_NORMAL                 = 0x00,
319     E_HVD_USER_DATA_MODE_DIRECTTV_CC                = 0x01,
320     E_HVD_USER_DATA_MODE_FRM_PACKING_ARRANGEMENT    = 0x02,
321     E_HVD_USER_DATA_MODE_ATSC_CC_RAW                = 0x04,
322     E_HVD_USER_DATA_MODE_CC_UNTIL_START_CODE        = 0x08
323 } HVD_USER_DATA_MODE;
324 
325 
326 typedef enum
327 {
328     E_HVD_DRV_AUTO_BBU_MODE = 0x00,
329     E_HVD_FW_AUTO_BBU_MODE  = 0x01,
330 } HVD_BBU_MODE;
331 
332 typedef enum
333 {
334     E_HVD_FW_STATUS_NONE = 0,               ///< NONE Flag
335     E_HVD_FW_STATUS_SEEK_TO_I = BIT(0),     ///< Seek to I slice/frame flag
336 } HVD_FW_STATUS_FLAG;
337 
338 typedef enum
339 {
340     //sharemem u32CodecMiscInfo bit assignment
341     E_VIDEO_FULL_RANGE = BIT(0),
342 } CODEC_MISC_INFO;
343 
344 typedef enum
345 {
346     E_DIVX_PROFILE_NONE = 0,
347     E_DIVX_PROFILE_DIVX_PLUS,
348     E_DIVX_PROFILE_DIVX_HEVC
349 } DIVX_PROFILE;
350 
351 /*
352 //interupt flag  , value is in VPU RISC MBOX 1 ( for LG GP DTV only)
353 #define HVD_ISR_USER_DATA               (1 << 0)
354 #define HVD_ISR_DATA_ERR                (1 << 1)
355 #define HVD_ISR_PIC_DEC_ERR             (1 << 2)
356 #define HVD_ISR_DEC_OVER                (1 << 3)
357 #define HVD_ISR_DEC_UNDER               (1 << 4)
358 #define HVD_ISR_DEC_I                   (1 << 5)
359 #define HVD_ISR_DIS_READY               (1 << 6)
360 #define HVD_ISR_SEQ_INFO                (1 << 7)
361 #define HVD_ISR_VIDEO_SKIP              (1 << 8)
362 #define HVD_ISR_VIDEO_REPEAT            (1 << 9)
363 #define HVD_ISR_VIDEO_FREERUN           (1 << 10)
364 #define HVD_ISR_INVALID_STREAM          (1 << 11)
365 #define HVD_ISR_VIDEO_AVSYNC_DONE       (1 << 12)
366 #define HVD_ISR_VIDEO_VSYNC             (1 << 31)
367 */
368 
369 //-------------------------------------------------------------------------------------------------
370 //  Type and Structure
371 //-------------------------------------------------------------------------------------------------
372 // User CC
373 #define USR_BUF_SIZE (256)
374 
375 typedef struct _DTV_BUF_type
376 {
377     MS_U8 type;                 // 0xCC:continue, 0:P 1:B 2:I
378     MS_U8 len;                  // size byte of buf
379     MS_U8 active;               // 0:free 1:already dma out or not assign 2:assign
380     MS_U8 pic_struct;           // pic_struct, Reserved when 0, Top Field when 1, Bottom Field when 2, and Frame picture when 3.
381     MS_U32 pts;
382     MS_U16 u16TempRefCnt;       // Temp Ref Count for UserData ,Value that increases by 1 for each frame (like time stamp)
383     MS_U16 u16Res;              // Reserved
384     MS_U32 u32Res;              // Reserved
385     MS_U8 buf[USR_BUF_SIZE];       //user data
386 } DTV_BUF_type;                 //size must <= 276, currently only use 272
387 
388 #define HVD_FRM_PACKIMG_PAYLOAD_SIZE ((HVD_AVC_FRAME_PACKING_SEI_SIZE/HVD_AVC_FRAME_PACKING_SEI_NUM)-20)  /// 20: HVD_Frame_packing_SEI size expect payload data
389 
390 typedef struct
391 {
392     MS_BOOL bUsed;
393     MS_BOOL bvaild;
394     MS_U8   u8Frm_packing_arr_cnl_flag;         // u(1)
395     MS_U8   u8Frm_packing_arr_type;             // u(7)
396     MS_U8   u8content_interpretation_type;      // u(6)
397     MS_U8   u1Quincunx_sampling_flag:1;         // u(1)
398     MS_U8   u1Spatial_flipping_flag:1;          // u(1)
399     MS_U8   u1Frame0_flipping_flag:1;           // u(1)
400     MS_U8   u1Field_views_flag:1;               // u(1)
401     MS_U8   u1Current_frame_is_frame0_flag:1;   // u(1)
402     MS_U8   u1Frame0_self_contained_flag:1;     // u(1)
403     MS_U8   u1Frame1_self_contained_flag:1;     // u(1)
404     MS_U8   u1Reserved1:1;                      // u(1)
405     MS_U8   u4Frame0_grid_position_x:4;         // u(4)
406     MS_U8   u4Frame0_grid_position_y:4;         // u(4)
407     MS_U8   u4Frame1_grid_position_x:4;         // u(4)
408     MS_U8   u4Frame1_grid_position_y:4;         // u(4)
409     MS_U16  u16CropRight;
410     MS_U16  u16CropLeft;
411     MS_U16  u16CropBottom;
412     MS_U16  u16CropTop;
413     MS_U8   u8payload_len;
414     MS_U8   u8WaitSPS;
415     MS_U8   u8Reserved[2];
416     MS_U8   u8payload[HVD_FRM_PACKIMG_PAYLOAD_SIZE];
417 } HVD_Frame_packing_SEI;
418 
419 typedef struct
420 {
421     MS_BOOL bUsed;
422     MS_BOOL colourVolumeSEIEnabled;
423     MS_U32 maxLuminance;
424     MS_U32 minLuminance;
425     MS_U16 primaries[3][2];
426     MS_U16 whitePoint[2];
427 } HVD_MasteringDisplayColourVolume;
428 
429 typedef struct
430 {
431     MS_BOOL bUsed;
432     MS_BOOL ContentLightLevelEnabled;
433     MS_U16  maxContentLightLevel;
434     MS_U16  maxPicAverageLightLevel;
435 } HVD_ContentLightLevelInfo;
436 
437 // stuct
438 typedef struct
439 {
440     MS_U16 u16HorSize;
441     MS_U16 u16VerSize;
442     MS_U32 u32FrameRate;                // Unit: ms
443     MS_U8 u8AspectRate;                 // aspect ration ID; for AVC only
444     MS_U8 u8Interlace;
445     MS_U8 u8AFD;
446     //MS_U8 u8par_width;
447     //MS_U8 u8par_height;
448     MS_U8 bChroma_idc_Mono;             // 1: mono 0: colorful, not mono ; AVC only currently. AVS,RM??
449     MS_U16 u16DispWidth;                // Display width or aspect ratio width
450     MS_U16 u16DispHeight;               // Display height or aspect ratio height
451     MS_U16 u16CropRight;
452     MS_U16 u16CropLeft;
453     MS_U16 u16CropBottom;
454     MS_U16 u16CropTop;
455     MS_U16 u16Pitch;                    // ???
456     MS_U8  u8ColourPrimaries;           // Color Primaries in VUI
457     //****************************
458     MS_U8 u8IsOriginInterlace;          // Is Original Interlace mode
459     //******************************
460     // MS_U16 u16PTSInterval;           // ??? not fill
461     // MS_U8 u8MPEG1;                   // may be removed
462     // MS_U8 u8PlayMode;                // ??? not fill
463     // MS_U8 u8FrcMode;                 // may be removed
464 } HVD_Display_Info;                     //  bytes
465 
466 typedef struct
467 {
468     MS_U8 bIsShowErrFrm;
469     MS_U8 bIsRepeatLastField;
470     MS_U8 bIsErrConceal;
471     MS_U8 bIsSyncOn;
472     MS_U8 bIsPlaybackFinish;
473     MS_U8 u8SyncType;                   // HVD_Sync_Tbl_Type
474     MS_U8 u8SkipMode;                   // HVD_Skip_Decode_Type
475     MS_U8 u8DropMode;                   // HVD_Drop_Disp_Type
476     MS_S8 s8DisplaySpeed;               // HVD_Disp_Speed
477     MS_U8 u8FrcMode;                    // HVD_FRC_Mode
478     MS_U8 bIsBlueScreen;
479     MS_U8 bIsFreezeImg;
480     MS_U8 bShowOneField;
481     //*****************************
482     MS_U8 u8reserve8_1;
483     MS_U16 u16reserve16_1;
484     //*****************************
485 } HVD_Mode_Status;                      // 12 bytes
486 
487 typedef struct
488 {
489     MS_U16 u16Width;
490     MS_U16 u16Height;
491 } HVD_PictureSize;
492 
493 typedef struct
494 {
495     MS_U32 u32LumaAddr;                 ///< The start offset of luma data. Unit: byte.
496     MS_U32 u32ChromaAddr;               ///< The start offset of chroma data. Unit: byte.
497     MS_U32 u32PpInLumaAddr;             ///< Luma address (For post-process use)
498     MS_U32 u32PpInChromaAddr;           ///< Chroma address (For post-process use)
499     MS_U32 u32TimeStamp;                ///< Time stamp(DTS, PTS) of current displayed frame. Unit: 90khz.
500     MS_U32 u32ID_L;                     ///< low part of ID number decided by MDrv_HVD_PushQueue().
501     MS_U32 u32ID_H;                     ///< high part of ID number decided by MDrv_HVD_PushQueue().
502     MS_U8  u8FrmType;                   ///< HVD_Picture_Type, picture type: I, P, B frame
503     MS_U8  u8FieldType;                 ///< HVD_Field_Type, none, top , bottom, both field
504     MS_U16 u16Pitch;
505     MS_U16 u16Width;
506     MS_U16 u16Height;
507     MS_U32 u32Status;                   ///< 0:None, 1:Init, 2:View, 3:Disp, 4:Free
508     MS_U32 u32PrivateData;              ///[STB]only for AVC
509     MS_U32 u32LumaAddr_2bit;            ///< The start offset of 2bit luma data. Unit: byte.
510     MS_U32 u32ChromaAddr_2bit;          ///< The start offset of 2bit chroma data. Unit: byte.
511     MS_U16 u16Pitch_2bit;
512     MS_U8  u8LumaBitdepth;
513     MS_U8  u8ChromaBitdepth;
514     MS_U8  u2Luma0Miu:2;
515     MS_U8  u2Luma1Miu:2;
516     MS_U8  u2Chroma0Miu:2;
517     MS_U8  u2Chroma1Miu:2;
518     MS_U8  u8FbIndex;
519     MS_U8  reserved8[2];
520 } HVD_Frm_Information;
521 
522 typedef enum
523 {
524     HVD_FRM_INFO_EXT_TYPE_10BIT,           // 2bits in 10 bits case
525     HVD_FRM_INFO_EXT_TYPE_INTERLACE,       // 2nd field 8bits in interlace case
526     HVD_FRM_INFO_EXT_TYPE_10BIT_INTERLACE, // 2nd field 2bits in 10bits interlace case
527     HVD_FRM_INFO_EXT_TYPE_MFCBITLEN,       // bit length in MFC case
528     HVD_FRM_INFO_EXT_TYPE_MAX,
529 } HVD_FRM_INFO_EXT_TYPE;
530 
531 typedef enum _HVD_COMPLEXITY_LEVEL
532 {
533     HVD_COMPLEXITY_LEVEL1 = 1,             // lower than level 2
534     HVD_COMPLEXITY_LEVEL2,                 // higher than avg avg BW of 4k30p 8bit
535     HVD_COMPLEXITY_LEVEL3,                 // higher than avg avg BW of 4k30p 10bit
536     HVD_COMPLEXITY_LEVEL4,                 // higher than avg BW of 4k60p 8bit
537     HVD_COMPLEXITY_LEVEL5,                 // higher than avg BW of 4k60p 10bit
538 } HVD_COMPLEXITY_LEVEL;
539 
540 /****************************************************************************************
541                                   MFCodecInfo
542           +---------------------------------------------------------------+
543           |Uncompress|BitLen Miu Select|  Pitch  |   MFCodec Version      |
544           |   4 bits |      4 bits     |  8 bits |       16 bits          |
545           +---------------------------------------------------------------+
546 ***************************************************************************************/
547 typedef struct
548 {
549     MS_U32 u32LumaAddrExt[HVD_FRM_INFO_EXT_TYPE_MAX];
550     MS_U32 u32ChromaAddrExt[HVD_FRM_INFO_EXT_TYPE_MAX];
551     MS_U32 MFCodecInfo;
552     // SEI start //
553     MS_U32 maxLuminance;
554     MS_U32 minLuminance;
555     MS_U16 primaries[3][2];
556     MS_U16 whitePoint[2];
557     // SEI end //
558     MS_U8 Frm_Info_Ext_avail; ///bit[2]: DV_Enabled, bit[1]: SEI_Enabled,  bit[0]: colur_description_present_flag
559     // colour_description start //
560     MS_U8 colour_primaries;                            // u(8)
561     MS_U8 transfer_characteristics;                    // u(8)
562     MS_U8 matrix_coefficients;                         // u(8)
563     ////Dolby_Vision////////////
564     MS_U8 u8DVMode; // bit[0:1] 0: Disable 1:Single layer 2: Dual layer, bit[2] 0:Base Layer 1:Enhance Layer
565     MS_U8 u8CurrentIndex;
566     MS_U8 bDMEnable;
567     MS_U8 bCompEnable;
568     MS_U32 u32DVMetadataAddr;
569     MS_U32 u32DVDMSize;
570 
571     MS_U32 u32DVCompSize;
572     MS_U32 u32DVRegAddr;
573     MS_U32 u32DVRegSize;
574     MS_U32 u32DVLutAddr;
575     MS_U32 u32DVLutSize;
576     // Other
577     MS_U8  u8ComplexityLevel; // from HVD_COMPLEXITY_LEVEL1 to HVD_COMPLEXITY_LEVEL5. Higher level means more complexity
578     MS_U8  u8Reserve[3];
579 } HVD_Frm_Information_EXT_Entry; // sizeof(HVD_Frm_Information_EXT_Entry) * HVD_DISP_QUEUE_MAX_SIZE must be smaller than HVD_DISP_FRM_INFO_EXT_ST_SIZE
580 
581 typedef struct
582 {
583     HVD_Frm_Information_EXT_Entry stEntry[HVD_DISP_QUEUE_MAX_SIZE];
584 } HVD_Frm_Information_EXT; // size must be smaller than HVD_DISP_FRM_INFO_EXT_ST_SIZE
585 
586 typedef struct
587 {
588     MS_BOOL aspect_ratio_info_present_flag;            // u(1)
589     MS_U8 aspect_ratio_idc;                            // u(8)
590     MS_U16 sar_width;                                  // u(16)
591     MS_U16 sar_height;                                 // u(16)
592     MS_BOOL overscan_info_present_flag;                // u(1)
593     MS_BOOL overscan_appropriate_flag;                 // u(1)
594     MS_BOOL video_signal_type_present_flag;            // u(1)
595     MS_U8 video_format;                                // u(3)
596     MS_BOOL video_full_range_flag;                     // u(1)
597     MS_BOOL colour_description_present_flag;           // u(1)
598     MS_U8 colour_primaries;                            // u(8)
599     MS_U8 transfer_characteristics;                    // u(8)
600     MS_U8 matrix_coefficients;                         // u(8)
601     MS_BOOL chroma_location_info_present_flag;         // u(1)
602     MS_U8 chroma_sample_loc_type_top_field;            // ue(v) 0~5
603     MS_U8 chroma_sample_loc_type_bottom_field;         // ue(v) 0~5
604     MS_BOOL timing_info_present_flag;                  // u(1)
605     MS_BOOL fixed_frame_rate_flag;                     // u(1)
606     MS_U32 num_units_in_tick;                          // u(32)
607     MS_U32 time_scale;                                 // u(32)
608 } HVD_AVC_VUI_DISP_INFO;
609 
610 typedef struct
611 {
612     MS_U32 u32FrmrateUpBound;       //Framerate filter upper bound
613     MS_U32 u32FrmrateLowBound;      //Framerate filter lower bound
614     MS_U32 u32MvopUpBound;          //mvop filter upper bound
615     MS_U32 u32MvopLowBound;         //mvop filter lower bound
616 } HVD_DISP_THRESHOLD;
617 
618 typedef struct
619 {
620     // switch
621     MS_U32 u32CodecType;                //0x0000
622     MS_U32 u32FrameBufAddr;             //0x0004
623     MS_U32 u32FrameBufSize;             //0x0008
624     MS_U32 u32CPUClock;                 //0x000C
625     HVD_Display_Info DispInfo;          //0x0010
626 
627     // FW -> HK
628     // report info
629     //AFD_Info AFDInfo;
630     MS_U32 u32DispSTC;                  //0x002C // Current Display Frame STC
631     MS_U32 u32DecodeCnt;                //0x0030 // Decoded picture count
632     MS_U32 u32DecErrCnt;                //0x0034 // HW decode err or not finish.
633     MS_U32 u32DataErrCnt;               //0x0038 // FW process data error, like SPS, slice header .etc.
634     MS_U16 u16ErrCode;                  //0x003C // Drv/FW error code ; HVD_Err_Code
635     MS_U8  u8FrameMbsOnlyFlag;          //0x003E // frame_mbs_only_flag of AVC SPS.
636     MS_U8  u8ForceBreakCnt;             //0x003F //
637     MS_U32 u32VPUIdleCnt;               //0x0040 // VPU idle count
638     MS_U32 u32FrameRate;                //0x0044 // Input Frame Rate
639     MS_U32 u32FrameRateBase;            //0x0048 // Input Frame Rate Base
640     HVD_Mode_Status ModeStatus;         //0x004C // FW mode
641     HVD_Frm_Information DispFrmInfo;    //0x005C // current displayed frame information.
642     HVD_Frm_Information DecoFrmInfo;    //0x0098 // specified decoded frame information.
643     //MS_U8 u8DecPictType;                // Current decode picture type: E_HVD_PICT_TYPE_I: I frm, E_HVD_PICT_TYPE_P: ref(P) , E_HVD_PICT_TYPE_B: non-ref(B) (GP2 need only)
644 #if defined(INTERLEAVE_SW_SEEK) || defined(SW_GETBITS) || defined(INTERLEAVE_SW_PARSE)
645     MS_U32 u32BBUReadPtr;
646 #endif
647     // internal control info
648     MS_U8 bInitDone;                    //0x00D4
649     MS_U8 bIs1stFrameRdy;               //0x00D5 // first frame are showed on screen
650     MS_U8 bIsIFrmFound;                 //0x00D6 // 1: First I frame found. 0: fw should set to zero after user cmd, "Flush"
651     MS_U8 bIsSyncStart;                 //0x00D7 // under sync mode, 1: FW start doing sync action. 0: FW freerun or freerun mode.
652     MS_U8 bIsSyncReach;                 //0x00D8 // under sync mode, 1: FW sync reach. 0: FW freerun or sync not reach.
653 
654     //****************************************
655 
656     MS_U8 u8SrcMode;                    //0x00D9
657     MS_U8 bEnableDispQueue;             //0x00DA
658     MS_U8 bEnableDispOutSide;           //0x00DB
659     //****************************************
660     MS_U32 u32FWVersionID;              //0x00DC // FW version ID
661     MS_U32 u32FWIfVersionID;            //0x00E0 // FW IF version ID
662     MS_U32 u32ESWritePtr;               //0x00E4 // the write pointer of bitstream buffer.
663     MS_U16 u16DecQNumb;                 //0x00E8 // current decoded queue total entry number. old oq size
664     MS_U16 u16DispQNumb;                //0x00EA // current display queue total entry number. old Used Size
665     MS_U32 u32PTStableWptrAddr;         //0x00EC // The address of PTS table write pointer.
666     MS_U32 u32PTStableRptrAddr;         //0x00F0 // The address of PTS table read pointer.
667     MS_U32 u32PTStableByteCnt;          //0x00F4 // The value of byte count of TSP. FW update it after init() and flush().
668 
669     // debug info
670     MS_U32 u32SkipCnt;                  //0x00F8 // skipped picture count count by command: E_HVD_DECODE_ALL, E_HVD_DECODE_I, E_HVD_DECODE_IP
671     MS_U32 u32DropCnt;                  //0x00FC // dorpped decoded picture counter by command: drop_auto or drop_once
672     MS_U32 u32CCBase;                   //0x0100 // CC Ring Base Address
673     MS_U32 u32CCSize;                   //0x0104 // CC Ring Size
674     MS_U32 u32CCWrtPtr;                 //0x0108 // CC Ring Write Pointer
675     MS_U32 u32NtscCCBase;               //0x010C // NTSC CC Ring Base Address
676     MS_U32 u32NtscCCSize;               //0x0110 // NTSC CC Ring Size
677     MS_U32 u32NtscCCWrtPtr;             //0x0114 // NTSC CC Ring Write Pointer
678     //****************************************
679     MS_U32 u32CurrentPts;               //0x0118 // only useful when Jump to pts command is activated
680     MS_U32 u32DispCnt;                  //0x011C // Display picture count
681     MS_U32 u32FWBaseAddr;               //0x0120
682     //****************************************
683     MS_U32 u32UserCCBase;               //0x0124 // User CC Base Address
684     MS_U32 u32UserCCIdxWrtPtr;          //0x0128 // User CC Idx Write Pointer
685     MS_U8 u8UserCCIdx[USER_CC_IDX_SIZE];//0x012C // User CC Idx
686     //****************************************
687     MS_U32 u32VirtualBoxWidth;          //0x0138 // Dynamic Scale: DRV -> FW
688     MS_U32 u32VirtualBoxHeight;         //0x013C // Dynamic Scale: DRV -> FW
689     MS_U32 u32SrcWidth;                 //0x0140 // Dynamic Scale: Source Width
690     MS_U32 u32SrcHeight;                //0x0144 // Dynamic Scale: Source Height
691     //****************************************
692     MS_U8 u8DivxProfile;                //0x0148  // see DIVX_PROFILE, E_DIVX_PROFILE_NONE is not a DivX stream
693     //****************************************
694 
695     // -------- AVC info --------
696     //MS_U32 u32AVC_NalCnt;             // Decoded nal count >> change to SRAM
697     MS_U8  u8AVC_SPS_LowDelayHrdFlag;   //0x0149 // VUI low_delay_hrd_flag
698     MS_U16 u16AVC_SPS_LevelIDC;         //0x014A // sps level idc
699     MS_U32 u32AVC_VUIDispInfo_Addr;     //0x014C // VUI Display Info Address
700     //MS_U32 u32AVC_SPS_Addr;           // FW sps structure start address
701 
702     // -------- AVS info --------
703     // .....
704     //MS_U32 u32AVS_xxx;
705 
706     // -------- RM info --------
707     // HK -> FW
708     MS_U8 u8RM_Version;                 //0x0150
709     MS_U8 u8RM_NumSizes;                //0x0151
710     MS_U8 u8BitDepth;                   //0x0152 Bit0~3 Y bitdepth, Bit4~7 UV bitdepth
711     //****************************************
712     MS_U8 reserved8_2;                  //0x0153
713     //****************************************
714     HVD_PictureSize  pRM_PictureSize[HVD_RM_INIT_PICTURE_SIZE_NUMBER];  //0x0154
715     MS_U32 u32RM_VLCTableAddr;          //0x0174
716 
717     // -------- common info --------
718     MS_U32 u32MainLoopCnt;              //0x0178
719     MS_U32 u32VsyncCnt;                 //0x017C
720     HVD_DISP_THRESHOLD DispThreshold;   //0x0180
721     MS_U32 u32ESReadPtr;                //0x0190 // the read pointer of bitstream buffer.
722     MS_U32 reserved32_0;                //0x0194
723     MS_S64 s64PtsStcDiff;               //0x0198 // 90Khz
724     MS_U16 u16ChipID;                   //0x01A0 // enum MSTAR_CHIP_ID
725     MS_U16 u16ChipECONum;               //0x01A2 // ECO num of chip
726     MS_U32 u32NextPTS;                  //0x01A4 // ms
727 
728 
729     MS_U16 u16DispQSize;                //0x01A8
730     MS_U16 u16DispQPtr;                 //0x01AA
731     HVD_Frm_Information DispQueue[HVD_DISP_QUEUE_MAX_SIZE];   //0x01AC
732     //----------------------------------------------------------------------
733     MS_U32 u32RealFrameRate;            //0x0B84
734 
735     MS_U8 bSpsChange;                   //0x0B88
736     MS_U8 bEnableDispCtrl;              //0x0B89
737     MS_U8 bIsTrigDisp;                  //0x0B8A
738     MS_U8 bHVDUseTlbMode;               //0x0B8B //0: default to disable TLB , 1: use TLB (HK->FW)
739     MS_U32 u32FwState;                  //0x0B8C
740     MS_U32 u32FwInfo;                   //0x0B90
741     MS_U32 u32IntCount;                 //0x0B94
742 
743     //----------------------------------------------------------------------
744     MS_U16 u16FreeQWtPtr;              //0x0B98
745     MS_U16 u16FreeQRdPtr;              //0x0B9A
746     MS_U32 FreeQueue[HVD_DISP_QUEUE_MAX_SIZE];  //0x0B9C
747 
748     // --------- MVC info (Sub view buffer and 2nd input pointer) ---------
749     HVD_Frm_Information DispFrmInfo_Sub;    //0x0C44  // current displayed Sub frame information.
750     HVD_Frm_Information DecoFrmInfo_Sub;    //0x0C80  // specified decoded Sub frame information.
751     MS_U32 u32ES2WritePtr;              //0x0CBC
752     MS_U32 u32ES2ReadPtr;               //0x0C08
753 
754     // --------- MJPEG share memory ------------------------------------------
755     MS_U32 u32MJPEGFrameBuffIdx;        //0x0CC4 <----LOUIS DONE
756     MS_U32 u32MJPEGTimeStamp;           //0x0CC8
757     MS_U32 u32MJPEGID_L;                //0x0CCC
758     MS_U32 u32MJPEGID_H;                //0x0CD0
759     MS_U32 u32MJPEG_NextFrameBuffIdx;   //0x0CD4
760     MS_U8 u8MJPEG_bStepPlay;            //0x0CD8
761     MS_U8 u8MJPEG_bPlaying;             //0x0CD9
762     MS_U8 u8MJPEG_bIsAVSyncOn;          //0x0CDA
763     MS_U8 u8MJPEG_bIsReachAVSync;       //0x0CDB
764     MS_U8 u8MJPEG_bFlushQueue;          //0x0CDC
765     MS_U8 u8MJPEG_bIsDispFinish;        //0x0CDD
766     MS_U8 u8MJPEG_bQueueFull;           //0x0CDE
767     MS_U8 bIsLeastDispQSize;            //0x0CDF
768 
769     // --------- SEI: frame packing ------------------------------------------
770     MS_U32 u32Frm_packing_arr_data_addr;  //0x0CE0
771 
772     //---------- report 3k/6k for 16/32 Mem-Align DS --------------------------
773     MS_U32 u32DSBuffSize;               //0x0CE4  // Dynamic Scale Buffer Size actually used for different DS Mem Align
774     MS_U8 bDSIsRunning;                 //0x0CE8
775     volatile MS_U8 u8IQmemCtrl;         //0x0CE9
776     MS_U8 bIsIQMEMSupport;              //0x0CEA
777     MS_U8 bIQmemEnableIfSupport;        //0x0CEB
778     MS_U8 u8FlushStatus;                //0x0CEC
779     MS_U8 u8DSBufferDepth;              //0x0CED
780 
781     //---------- TemporalScalability -----------------------------------------
782     MS_U8 u8TemporalScalabilty;         //0x0CEE
783     MS_U8 u8MaxTemporalLayer;           //0x0CEF
784 
785     MS_U16 u16DispQWptr[2];             //0x0CF0
786     MS_U8 u8ESBufStatus;                //0x0CF4
787     MS_U8 u8FieldPicFlag;               //0x0CF5
788     MS_U8 u8CMAAllocationStatus;        //0x0CF6
789     MS_U8 u8CMAReleaseStatus;           //0x0CF7
790 
791     // reserved for MJPEG
792     MS_U32 u32MJPEGDbg_DispStatus;      //0x0CF8
793     MS_U8 u8MJPEGDbg_ReadFbIdx;         //0x0CFC
794     MS_U8 u8MJPEGDbg_WriteFbIdx;        //0x0CFD
795     MS_U8 u8MJPEGDbg_SkipRepeat;        //0x0CFE
796     MS_U8 u8MJPEGDbg_reserved8_1;       //0x0CFF
797     MS_U32 u32MJPEGDbg_SysTime;         //0x0D00
798     MS_U32 u32MJPEGDbg_VideoPts;        //0x0D04
799     MS_U32 u32MJPEGDbg_SkipRepeatTime;  //0x0D08
800 
801     MS_U32 u32DSbufferAddr;             //0x0D0C
802     MS_U32 u32DispRepeatCnt;            //0x0D10
803 
804     MS_U32 u32ColocateBBUReadPtr;       //0x0D14 FW->HK
805     MS_U32 u32ColocateBBUWritePtr;      //0x0D18 HK->FW
806     MS_U8  u8BBUMode;                   //0x0D1C  0: driver auto bbu mode, 1: fw auto bbu mode(colocate bbu mode)
807     MS_U8  bUseTSPInBBUMode;            //0x0D1D  0: disable, 1: enable
808     MS_U8  bUseWbMvop;                  //0x0D1E  0: use original MVOP, 1: use WB MVOP (HK->FW)
809     MS_U8  bHVDIMIEnable;               //0x0D1F
810 
811     MS_U32 u32DmxFrameRate;             //0x0D20 // Demuxer Prefered Input Frame Rate
812     MS_U32 u32DmxFrameRateBase;         //0x0D24 // Demuxer Prefered Input Frame Rate Base
813     MS_U32 u32PTSTblRd;                 //0x0D28 // PTS table read ptr
814     MS_U32 u32PTSTblWr;                 //0x0D2C // PTS table write ptr
815     MS_U32 u32PreSetControl;            //0x0D30 // PreSetControl
816     MS_U32 u32IapGnBufAddr;             //0x0D34
817     MS_U32 u32IapGnBufSize;             //0x0D38
818     MS_U32 u32SeamlessTSStatus;         //0x0D3C
819     MS_U32 u32FWStatusFlag;             //0x0D40
820     MS_U32 u32ESBufLevel;               //0x0D44
821     MS_U32 u32ESBuf2Level;              //0x0D48
822     MS_U32 u32FrameBuf2Addr;            //0x0D4C
823     MS_U32 u32FrameBuf2Size;            //0x0D50
824     MS_U8  bCMA_Use;                    //0x0D54
825     MS_U8  bCMA_AllocDone;              //0x0D55
826     MS_U8  bCMA_TwoMIU;                 //0x0D56
827     MS_U8  u8FrmPostProcSupport;        //0x0D57
828     MS_U8  u8PpQueueSize;               //0x0D58
829     MS_U8  u8PpQueueWPtr;               //0x0D59
830     MS_U8  u8PpQueueRPtr;               //0x0D5A
831     MS_U8  u8CodecFeature;              //0x0D5B // Bit0: For AP to force vdec allocate 8bit framebuffer even decoding 10bit stream Bit1: Enable MFCODEC Bit2: Force MFCODEC nncompress mode
832     MS_U32 u32DISPQUEUE_EXT_ST_ADDR;    //0x0D5C
833     MS_U64 u64SeamlessTargetPTS;        //0x0D60
834     MS_U32 u32SeamlessTargetPOC;        //0x0D68
835     MS_U32 u32CodecMiscInfo;            //0x0D6C //Bit0: video full range bit
836     MS_U32 u32RDPTR_PTS_LOW;            //0x0D70
837     MS_U32 u32RDPTR_PTS_HIGH;           //0x0D74
838     MS_U32 u32WRPTR_PTS_LOW;            //0x0D78
839     MS_U32 u32WRPTR_PTS_HIGH;           //0x0D7C
840     MS_U32 u32DisplayColourVolume_addr;    //0x0D80
841     MS_U32 u32HVD_DisplayColourVolume_SEI; //0x0D84
842     MS_U32 u32ContentLightLevel_addr;    //0x0D88
843     MS_U32 u32HVD_ContentLightLevel_SEI;    //0x0D8C
844     MS_U32 u32AllocateCMABuffAddr[2];      //0x0D90
845     MS_U32 u32AllocateCMABuffSize[2];      //0x0D98
846     PENDING_RELEASE_QUEUE pending_release_queue[2][2]; //0x0DA0~0x0DD0
847     MS_U32 u32MaxCMAFrameBufSize;          //0x0DD0
848     MS_U32 u32MaxCMAFrameBuf2Size;         //0x0DD4
849     MS_U32 u32DirectStcInMs;               //0x0DD8
850 
851     //vdec plus info
852     MS_U32 u32VdecPlusDecCnt;           //0x0DDC
853     MS_U32 u32VdecPlusDropCnt;          //0x0DE0
854     MS_U32 u32VdecPlusDispPicCnt;       //0x0DE4
855     MS_U8  u8VdecPlusDropRatio;         //0x0DE8
856     MS_U8  u8LowMemMode;                //0x0DE9
857     MS_U8  bIsTSPIn;                    //0x0DEA
858     MS_U8  u8ExternalHeapIdx;           //0x0DEB
859     MS_U8  bUseCorrectVlcAddr;          //0x0DEC
860     MS_U8  bSingleLayer;                //0x0DED
861     MS_U8  reserved8_9[0xF9C-0xDEE];    //0x0DEE
862 
863     MS_U32 u32VDEC_MIU_SEL;             //0x0F9C
864     MS_U32 u32MaxVideoWidth;            //0x0FA0 // for VDEC3_FB usage
865     MS_U32 u32MaxVideoHeight;           //0x0FA4 // for VDEC3_FB usage
866     CMD_QUEUE cmd_queue;                //0x0FA8~0x0FBC DISPCMDQ and normal CMDQ
867     MS_U32 u32HVD_VBBU_DRAM_ST_ADDR;    //0x0FC0
868     MS_U32 u32HVD_PTS_TABLE_ST_OFFSET;  //0x0FC4
869     MS_U32 u32HVD_BBU_DRAM_ST_ADDR;     //0x0FC8
870     MS_U32 u32HVD_BBU2_DRAM_ST_ADDR;    //0x0FCC
871     MS_U32 u32HVD_DYNAMIC_SCALING_ADDR; //0x0FD0
872     MS_U32 u32HVD_SCALER_INFO_ADDR;     //0x0FD4
873     MS_U32 u32HVD_AVC_DTVINFO;          //0x0FD8
874     MS_U32 u32HVD_AVC_INFO608;          //0x0FDC
875     MS_U32 u32HVD_AVC_INFO708;          //0x0FE0
876     MS_U32 u32HVD_AVC_USERDATA;         //0x0FE4
877     MS_U32 u32HVD_AVC_FRAME_PACKING_SEI;//0x0FE8
878     MS_U32 u32HVD_DBG_DUMP_ADDR;        //0x0FEC
879     MS_U32 u32HVD_DUMMY_WRITE_ADDR;     //0x0FF0
880     MS_U32 reserved32_1;                //0x0FF4
881     MS_U32 u32COMPARE_INFO_ADDR;        //0x0FF8
882     MS_U32 u32COMPARE_MD5_ADDR;         //0x0FFC
883 } HVD_ShareMem;
884 
885 typedef struct
886 {
887     MS_U32 u32LumaAddr0;                 ///< The start offset of luma data. Unit: byte.
888     MS_U32 u32ChromaAddr0;               ///< The start offset of chroma data. Unit: byte.
889     MS_U32 u32LumaAddr1;                 ///< The start offset of luma data. Unit: byte.
890     MS_U32 u32ChromaAddr1;               ///< The start offset of chroma data. Unit: byte.
891     MS_U32 u32PriData;                   ///< Index for SEC release frame buffer
892     MS_U32 u32PriData1;                  ///< Index for SEC release frame buffer
893     MS_U32 u32Status;
894     MS_U16 u16Pitch;
895     MS_U16 u16Width;
896     MS_U16 u16Height;
897     MS_U16 u16CropLeft;
898     MS_U16 u16CropRight;
899     MS_U16 u16CropBottom;
900     MS_U16 u16CropTop;
901     MS_U8  u1BottomFieldFirst:1;
902     MS_U8  u1DSIndex1Valid:1;
903     MS_U8  u2Reserved:6;
904     MS_U8  u8FieldType;                 ///< HVD_Field_Type, none, top , bottom, both field
905     MS_U8  u8Interlace;
906     MS_U8  u8ColorFormat;               // 0 -> 420, 1 -> 422, 2 -> 420 10 bit
907     MS_U8  u8FrameNum;                  // if 2, u32LumaAddr1 and u32ChromaAddr1 should be use
908     MS_U8  u8RangeMapY;                 // for VC1 or 10 BIT frame, 2 bit Y depth
909     MS_U8  u8RangeMapUV;                // for VC1 or 10 BIT frame, 2 bit UV depth
910     MS_U8  u8TB_toggle;                 // 0 -> TOP then BOTTOM
911     MS_U8  u8Tog_Time;
912     MS_U8  u2Luma0Miu:2;
913     MS_U8  u2Luma1Miu:2;
914     MS_U8  u2Chroma0Miu:2;
915     MS_U8  u2Chroma1Miu:2;
916     MS_U8  u8FieldCtrl;                 // 0-> Normal, 1->always top, 2->always bot
917     union {
918         MS_U8 u8DSIndex;
919         struct
920         {
921             MS_U8 u4DSIndex0:4;
922             MS_U8 u4DSIndex1:4;         // it is DS index for sFrames[1] (HEVC Dolby EL frame)
923         };
924     };
925     union {
926         MS_U16 u16Pitch1;               // for 10 BIT, the 2 bit frame buffer pitch
927         MS_U16 u16DispCnt;              // when this display queue is show finish, record the display conut for debug if frame repeat
928     };
929 } DISP_FRM_INFO;
930 
931 typedef struct
932 {
933     // for vsync bridge dispQ bridge
934     MS_U8  u8DispQueNum;
935     MS_U8  u8McuDispSwitch;
936     MS_U8  u8McuDispQWPtr;
937     MS_U8  u8McuDispQRPtr;
938     DISP_FRM_INFO McuDispQueue[MAX_VSYNC_BRIDGE_DISPQ_NUM];
939     MS_U8  u8DisableFDMask;
940     MS_U8  u8FdMaskField;
941     MS_U8  u8ToggledTime;
942     MS_U8  u8ToggleMethod;
943     MS_U8  u8Reserve[2];
944     MS_U8  u5FRCMode:5;
945     MS_U8  u1FBLMode:1;
946     MS_U8  u2MirrorMode:2;
947     MS_U8  u8Reserve2;
948 } MCU_DISPQ_INFO;
949 
950 typedef enum
951 {
952     MS_DISP_FRM_INFO_EXT_TYPE_10BIT,
953     MS_DISP_FRM_INFO_EXT_TYPE_INTERLACE = 1, // interlace bottom 8bit will share the same enum value
954     MS_DISP_FRM_INFO_EXT_TYPE_DOLBY_EL = 1,  // with dolby enhance layer 8bit
955     MS_DISP_FRM_INFO_EXT_TYPE_10BIT_INTERLACE = 2, // interlace bottom 2bit will share the same enum
956     MS_DISP_FRM_INFO_EXT_TYPE_10BIT_DOLBY_EL = 2,  // value with dolby enhance layer 2bit
957     MS_DISP_FRM_INFO_EXT_TYPE_10BIT_MVC,
958     MS_DISP_FRM_INFO_EXT_TYPE_DOLBY_MODE = 4,
959     MS_DISP_FRM_INFO_EXT_TYPE_INTERLACE_MVC = 4,
960     MS_DISP_FRM_INFO_EXT_TYPE_10BIT_INTERLACE_MVC = 5, // MVC interlace R-View 2bit will share the
961     MS_DISP_FRM_INFO_EXT_TYPE_DOLBY_META = 5,          // same enum with dolby meta data
962     MS_DISP_FRM_INFO_EXT_TYPE_MFCBITLEN,
963     MS_DISP_FRM_INFO_EXT_TYPE_MFCBITLEN_MVC,
964     MS_DISP_FRM_INFO_EXT_TYPE_MAX,
965 } DISP_FRM_INFO_EXT_TYPE;
966 
967 /****************************************************************************************
968                                   MFCodecInfo
969           +---------------------------------------------------------------+
970           |Uncompress|BitLen Miu Select|  Pitch  |   MFCodec Version      |
971           |   4 bits |      4 bits     |  8 bits |       16 bits          |
972           +---------------------------------------------------------------+
973 ***************************************************************************************/
974 typedef struct
975 {
976     MS_U32 u32LumaAddrExt[MS_DISP_FRM_INFO_EXT_TYPE_MAX];
977     MS_U32 u32ChromaAddrExt[MS_DISP_FRM_INFO_EXT_TYPE_MAX];
978     MS_U32 MFCodecInfo;
979     MS_U16 u16Width;      // the width of second frame
980     MS_U16 u16Height;     // the height of second frame
981     MS_U16 u16Pitch[2];   // the pitch of second frame
982 } DISP_FRM_INFO_EXT;
983 
984 typedef struct
985 {
986     MS_U8 u8Pattern[4];
987     MS_U32 u32Version;
988     MS_U32 u32Debug;
989     MS_U16 u16VsyncCnt;
990     MS_U16 u16Debug;
991     DISP_FRM_INFO_EXT McuDispQueue[MAX_VSYNC_BRIDGE_DISPQ_NUM];
992 } MCU_DISPQ_INFO_EXT;
993 
994 typedef struct
995 {
996     MS_U32 u32ByteCnt;
997     MS_U32 u32PTS;
998     MS_U32 u32ID_L;
999     MS_U32 u32ID_H;
1000 } HVD_PTS_Entry;
1001 
1002 // enum
1003 typedef enum
1004 {
1005     E_MSTAR_CHIP_NONE = 0,
1006     E_MSTAR_CHIP_U3,
1007     E_MSTAR_CHIP_T3,
1008     E_MSTAR_CHIP_T4,
1009     E_MSTAR_CHIP_JANUS,
1010     E_MSTAR_CHIP_U4,
1011     E_MSTAR_CHIP_T8,
1012     E_MSTAR_CHIP_T9,
1013     E_MSTAR_CHIP_M10,
1014     E_MSTAR_CHIP_T12,
1015     E_MSTAR_CHIP_T13,
1016     E_MSTAR_CHIP_J2,
1017     E_MSTAR_CHIP_K1,
1018     E_MSTAR_CHIP_A1,
1019     E_MSTAR_CHIP_A5,
1020     E_MSTAR_CHIP_A7,
1021     E_MSTAR_CHIP_K2,
1022     E_MSTAR_CHIP_A3,
1023     E_MSTAR_CHIP_A7P,
1024     E_MSTAR_CHIP_AGATE,
1025     E_MSTAR_CHIP_M12,
1026     E_MSTAR_CHIP_EAGLE,
1027     E_MSTAR_CHIP_EMERALD,
1028     E_MSTAR_CHIP_EDISON,
1029     E_MSTAR_CHIP_EIFFEL,
1030     E_MSTAR_CHIP_CEDRIC,
1031     E_MSTAR_CHIP_NUGGET,
1032     E_MSTAR_CHIP_KAISER,
1033     E_MSTAR_CHIP_NIKE,
1034     E_MSTAR_CHIP_KENYA,
1035     E_MSTAR_CHIP_EINSTEIN,
1036     E_MSTAR_CHIP_NIKON,
1037     E_MSTAR_CHIP_NAPOLI,
1038     E_MSTAR_CHIP_MADISON,
1039     E_MSTAR_CHIP_MONACO,
1040     E_MSTAR_CHIP_KERES,
1041     E_MSTAR_CHIP_CLIPPERS,
1042     E_MSTAR_CHIP_MUJI,
1043     E_MSTAR_CHIP_MUNICH,
1044     E_MSTAR_CHIP_MONET,
1045     E_MSTAR_CHIP_MULAN,
1046     E_MSTAR_CHIP_MANHATTAN,
1047     E_MSTAR_CHIP_KRATOS,
1048     E_MSTAR_CHIP_KANO,
1049     E_MSTAR_CHIP_MESSI,
1050     E_MSTAR_CHIP_MILAN,
1051     E_MSTAR_CHIP_MASERATI,
1052     E_MSTAR_CHIP_MACAN,
1053     E_MSTAR_CHIP_KIWI,
1054     E_MSTAR_CHIP_CURRY,
1055     E_MSTAR_CHIP_KAYLA,
1056     E_MSTAR_CHIP_KASTOR,
1057     E_MSTAR_CHIP_OTHER = 0xFF,
1058 } MSTAR_CHIP_ID;
1059 
1060 typedef enum
1061 {
1062     E_HVD_SRC_MODE_DTV = 0,
1063     E_HVD_SRC_MODE_TS_FILE,
1064     E_HVD_SRC_MODE_FILE,
1065     E_HVD_SRC_MODE_TS_FILE_DUAL_ES,
1066     E_HVD_SRC_MODE_FILE_DUAL_ES,
1067 } HVD_SRC_MODE;
1068 
1069 typedef enum
1070 {
1071     E_VDEC_FORCE_8BITS_MASK          = BMASK(0:0),       ///< 8BITS YUV Mode
1072     E_VDEC_FORCE_8BITS_MODE          = BIT(0),
1073     E_VDEC_MFCODEC_MASK              = BMASK(2:1),       ///< MFCodec Mode
1074         E_VDEC_MFCODEC_DEFAULT       = BITS(2:1, 0),     ///< deflaut: 0x00
1075         E_VDEC_MFCODEC_FORCE_ENABLE  = BITS(2:1, 1),     ///< force enable: 0x01
1076         E_VDEC_MFCODEC_FORCE_DISABLE = BITS(2:1, 2),     ///< force disable:0x10
1077     E_VDEC_MFCODEC_UNCOMPRESS_MODE   = BIT(3),
1078     E_VDEC_FORCE_MAIN_PROFILE_MASK = BMASK(4:4),
1079     E_VDEC_FORCE_MAIN_PROFILE   = BIT(4),     // HEVC: Only Support Main profile even this chip support Main10
1080     E_VDEC_DYNAMIC_CMA_MODE     = BIT(5),     // Enable Dynamic CMA mechanism
1081     E_VDEC_TEMPORAL_SCALABILITY_MODE = BIT(6),   //Enable/Disable Temporal Scalability Mode
1082     E_VDEC_DOLBY_VISION_SINGLE_LAYER_MODE = BIT(7)   //Enable/Disable dolby vision single layer Mode
1083 } VDEC_CODEC_FEATURE;
1084 
1085 typedef enum
1086 {
1087     E_HVD_DV_ENABLE_MASK             = BMASK(1:0),       /// Is Dolby vision enable
1088     E_HVD_DV_SINGLE_LAYER_MODE       = BIT(0),
1089     E_HVD_DV_DUAL_LAYER_MODE         = BIT(1),
1090     E_HVD_DV_CURRENT_LAYER           = BIT(2),           /// 1: enhance layer 0: base layer
1091     E_HVD_DV_METADATA_MIUSEL_MASK    = BMASK(4:3),       /// meta data miu select(2bits)
1092         E_HVD_DV_METADATA_MIU0       = BITS(4:3, 0),
1093         E_HVD_DV_METADATA_MIU1       = BITS(4:3, 1),
1094         E_HVD_DV_METADATA_MIU2       = BITS(4:3, 2),
1095 } HVD_DOLBY_VISION_MODE;
1096 
1097 typedef enum
1098 {
1099     E_HVD_Codec_AVC = 0,
1100     E_HVD_Codec_AVS,
1101     E_HVD_Codec_RM,
1102     E_HVD_Codec_MVC,
1103     E_HVD_Codec_VP8,
1104     E_HVD_Codec_MJPEG,
1105     E_HVD_Codec_VP6,
1106     E_HVD_Codec_HEVC,
1107     E_HVD_Codec_VP9,
1108     E_HVD_Codec_HEVC_DV,
1109     E_HVD_Codec_UNKNOWN
1110 } HVD_Codec_Type;
1111 
1112 typedef enum
1113 {
1114     E_HVD_PICT_TYPE_I,
1115     E_HVD_PICT_TYPE_P,
1116     E_HVD_PICT_TYPE_B,
1117 } HVD_Picture_Type;
1118 
1119 typedef enum
1120 {
1121     E_HVD_FIELD_TYPE_NONE = 0,
1122     E_HVD_FIELD_TYPE_TOP,
1123     E_HVD_FIELD_TYPE_BOTTOM,
1124     E_HVD_FIELD_TYPE_BOTH,
1125 } HVD_Field_Type;
1126 
1127 typedef enum
1128 {
1129     EVD_TOP_FIELD = 1,
1130     EVD_BOTTOM_FIELD = 2,
1131     EVD_TOP_BOTTOM_ORDER = 3,
1132     EVD_BOTTOM_TOP_ORDER = 4,
1133     EVD_TOP_WITH_PREV = 9,
1134     EVD_BOTTOM_WITH_PREV = 10,
1135     EVD_TOP_WITH_NEXT = 11,
1136     EVD_BOTTOM_WITH_NEXT = 12,
1137     EVD_UNKNOWN_TYPE = 0xFF,
1138 } HEVC_PIC_STRUCT;
1139 
1140 typedef enum
1141 {
1142     E_HVD_DECODE_ALL,
1143     E_HVD_DECODE_I,
1144     E_HVD_DECODE_IP,
1145 } HVD_Skip_Decode_Type;
1146 
1147 typedef enum
1148 {
1149     E_HVD_CMA_ALLOCATION_NONE,
1150     E_HVD_CMA_ALLOCATION_WAITING,
1151     E_HVD_CMA_ALLOCATION_DONE,
1152     E_HVD_CMA_ALLOCATION_FAILED,
1153 } HVD_CMA_Allocation_Status;
1154 
1155 typedef enum
1156 {
1157     E_HVD_CMA_RELEASE_NONE,
1158     E_HVD_CMA_RELEASE_WAITING,
1159     E_HVD_CMA_RELEASE_DONE,
1160 } HVD_CMA_Release_Status;
1161 
1162 typedef enum
1163 {
1164     E_HVD_DROP_DISP_AUTO = (1<<0),
1165     E_HVD_DROP_DISP_ONCE = (1<<1),
1166 } HVD_Drop_Disp_Type;
1167 
1168 typedef enum
1169 {
1170     E_HVD_FRC_NORMAL = 0,
1171     E_HVD_FRC_32PULLDOWN,               //3:2 pulldown mode (ex. 24p a 60i or 60p)
1172     E_HVD_FRC_PAL2NTSC ,                //PALaNTSC conversion (50i a 60i)
1173     E_HVD_FRC_NTSC2PAL,                 //NTSCaPAL conversion (60i a 50i)
1174     E_HVD_FRC_DISP_2X,                  //output rate is twice of input rate (ex. 30p a 60p)
1175     E_HVD_FRC_24_50,                    //output rate 24P->50P 48I->50I
1176     E_HVD_FRC_50P_60P,                  //output rate 50P ->60P
1177     E_HVD_FRC_60P_50P,                  //output rate 60P ->50P
1178     E_HVD_FRC_HALF_I,                   //output rate 120i -> 60i, 100i -> 50i
1179     E_HVD_FRC_120I_50I,                 //output rate 120i -> 60i
1180     E_HVD_FRC_100I_60I,                 //output rate 100i -> 60i
1181     E_HVD_FRC_DISP_4X,                  //output rate is four times of input rate (ex. 15P a 60P)
1182     E_HVD_FRC_15_50,                    //output rate 15P->50P, 30i -> 50i
1183     E_HVD_FRC_30_50,                    //output rate  30p->50p, 60i->50i
1184     E_HVD_FRC_30_24,                    //output rate 30p->24p, 60i->24i
1185     E_HVD_FRC_60_24,                    //output rate 60p->24p, 120i -> 24i
1186     E_HVD_FRC_60_25,                    //output rate 60p->25p , 120i -> 50i
1187     E_HVD_FRC_HALF_P,                   //output rate 60p-> 30p, 50p -> 25p
1188     E_HVD_FRC_25_30,                    //output rate 25p->30p , 50 i-> 30i
1189     E_HVD_FRC_50_30,                    //output rate 25p->30p ,  100i -> 30i
1190     E_HVD_FRC_24_30,                    //output rate 24p->30p , 48i -> 30i
1191 } HVD_FRC_Mode;
1192 
1193 typedef enum
1194 {
1195     E_HVD_FRC_DROP_FRAME = 0,
1196     E_HVD_FRC_DROP_FIELD = 1,
1197 } HVD_FRC_Drop_Mode;
1198 
1199 typedef enum
1200 {
1201     E_HVD_DISP_SPEED_F_32X = 32,
1202     E_HVD_DISP_SPEED_F_16X = 16,
1203     E_HVD_DISP_SPEED_F_8X = 8,
1204     E_HVD_DISP_SPEED_F_4X = 4,
1205     E_HVD_DISP_SPEED_F_2X = 2,
1206     E_HVD_DISP_SPEED_1X = 1,
1207     E_HVD_DISP_SPEED_S_2X = -2,
1208     E_HVD_DISP_SPEED_S_4X = -4,
1209     E_HVD_DISP_SPEED_S_8X = -8,
1210     E_HVD_DISP_SPEED_S_16X = -16,
1211     E_HVD_DISP_SPEED_S_32X = -32,
1212 } HVD_Disp_Speed;
1213 
1214 typedef enum
1215 {
1216     E_HVD_SYNC_TBL_TYPE_NON,
1217     E_HVD_SYNC_TBL_TYPE_PTS,
1218     E_HVD_SYNC_TBL_TYPE_DTS,
1219     E_HVD_SYNC_TBL_TYPE_STS,            //Sorted TimeStamp
1220 } HVD_Sync_Tbl_Type;                    //only for file mode. Ts , ts file mode always has PTS table
1221 
1222 typedef enum
1223 {
1224     E_HVD_FIELD_CTRL_OFF=0,
1225     E_HVD_FIELD_CTRL_TOP,       // Always Show Top Field
1226     E_HVD_FIELD_CTRL_BOTTOM,    // Always Show Bottom Field
1227 } HVD_Field_Ctrl;
1228 
1229 typedef enum
1230 {
1231     E_HVD_BURST_CNT_LV0 = 0,  // U3,T3:32 cycle  T4~U4: 16 cycle
1232     E_HVD_BURST_CNT_LV1 = 1,  // U3,T3:64 cycle  T4~U4: 32 cycle
1233     E_HVD_BURST_CNT_LV2 = 2,  // U3,T3:96 cycle  T4~U4: 48 cycle
1234     E_HVD_BURST_CNT_LV3 = 3,  // U3,T3:128 cycle  T4~U4: 64 cycle
1235     E_HVD_BURST_CNT_LV4 = 4,  // U3,T3:160 cycle  T4~U4: 80 cycle
1236     E_HVD_BURST_CNT_LV5 = 5,  // U3,T3:192 cycle  T4~U4: 96 cycle
1237     E_HVD_BURST_CNT_LV6 = 6,  // U3,T3:224 cycle  T4~U4: 112 cycle
1238     E_HVD_BURST_CNT_LV7 = 7,  // U3,T3:256 cycle  T4~U4: 128 cycle
1239     E_HVD_BURST_CNT_DISABLE = 0xFFFFFFFF,
1240 } HVD_MIU_Burst_Cnt_Ctrl;
1241 
1242 typedef enum
1243 {
1244     E_HVD_DISPQ_STATUS_NONE = 0,            //FW
1245     E_HVD_DISPQ_STATUS_INIT,                //FW
1246     E_HVD_DISPQ_STATUS_VIEW,                //HK
1247     E_HVD_DISPQ_STATUS_DISP,                //HK
1248     E_HVD_DISPQ_STATUS_FREE,                //HK
1249 } HVD_DISPQ_STATUS;
1250 
1251 typedef enum
1252 {
1253     // invalid cmd
1254     E_HVD_CMD_INVALID_CMD = 0xFFFFFFFFUL,
1255 
1256     // SVD old cmd
1257     E_HVD_CMD_SVD_BASE = 0x00010000,
1258     /*0x10001*/E_HVD_CMD_PARSER_BYPASS,             // 1 : on :for raw file mode; AVCHVD_CMD_PARSER_BYPASS ; 0: off: TS file mode and live stream
1259     /*0x10002*/E_HVD_CMD_BBU_RESIZE,                // svd only;  AVCHVD_CMD_BBU_SIZE
1260     /*0x10003*/E_HVD_CMD_FRAME_BUF_RESIZE,          // svd only; AVCHVD_CMD_RESIZE_MEM
1261     /*0x10004*/E_HVD_CMD_IGNORE_ERR_REF,            // 1: ignore ref error, 0: enable ref error handle; AVCHVD_CMD_IGNORE_LIST + AVCHVD_CMD_OPEN_GOP
1262     /*0x10005*/E_HVD_CMD_ES_FULL_STOP,              // ES auto stop: 1: AVCHVD_CMD_ES_STOP; ES not stop 0: AVCHVD_CMD_HANDSHAKE
1263     /*0x10006*/E_HVD_CMD_DROP_DISP_AUTO,            // 1:on AVCHVD_CMD_DISP_DROP, 0:off AVCHVD_CMD_DIS_DISP_DROP
1264     /*0x10007*/E_HVD_CMD_DROP_DISP_ONCE,            // AVCHVD_CMD_DROP_CNT
1265     /*0x10008*/E_HVD_CMD_FLUSH_DEC_Q,               // AVCHVD_CMD_FLUSH_QUEUE
1266 
1267     // HVD new cmd
1268     E_HVD_CMD_NEW_BASE = 0x00020000,
1269     // Action
1270     E_HVD_CMD_TYPE_ACTION_MASK = (0x0100|E_HVD_CMD_NEW_BASE),
1271 
1272     // state machine action
1273     /*0x20101*/E_HVD_CMD_INIT ,                     // Init FW type: E_HVD_Codec_AVC ; E_HVD_Codec_AVS;  E_HVD_Codec_RM
1274     /*0x20102*/E_HVD_CMD_PLAY,                      // AVCHVD_CMD_GO
1275     /*0x20103*/E_HVD_CMD_PAUSE,                     // AVCHVD_CMD_PAUSE
1276     /*0x20104*/E_HVD_CMD_STOP,                      // AVCHVD_CMD_STOP
1277     // run-time action
1278     /*0x20105*/E_HVD_CMD_STEP_DECODE,               // AVCHVD_CMD_STEP
1279     /*0x20106*/E_HVD_CMD_FLUSH,                     // Arg: 1 show last decode, 0 show current diaplay.FW need to clear read pointer of PTS table under SYNC_PTS, SYNC_DTS. ; BBU: AVCHVD_CMD_DROP ,  DISP: AVCHVD_CMD_FLUSH_DISPLAY , AVCHVD_CMD_SKIPTOI
1280     /*0x20107*/E_HVD_CMD_BLUE_SCREEN,               // only for AVC. remove auto blue screen before show first frame on screen
1281     /*0x20108*/E_HVD_CMD_RESET_PTS,                 // reset PTS table for TS file mode. AVCHVD_CMD_RE_SYNC
1282     /*0x20109*/E_HVD_CMD_FREEZE_IMG,                // FW showes the same frame at every Vsync, but background decode process can not stop. 1: freeze image; 0: normal diaplay
1283     /*0x2010A*/E_HVD_CMD_JUMP_TO_PTS,               // Arg: PTS(unit: 90kHz). 0: disable this mode. Any not zero value: enable. FW decode to specified PTS by using full speed. During the decoding, FW need not show any decoded frames, just maitain the last frame before get this command.
1284     /*0x2010B*/E_HVD_CMD_SYNC_TOLERANCE,            // Arg: any not zero number(unit: 90kHz). AVCHVD_CMD_SLOW_SYNC
1285     /*0x2010C*/E_HVD_CMD_SYNC_VIDEO_DELAY,          // Arg: 0~MAX_VIDEO_DELAY(unit: 90kHz): use Arg of video delay. AVCHVD_CMD_AVSYNC
1286     /*0x2010D*/E_HVD_CMD_DISP_ONE_FIELD,            // for AVS, AVC only, Arg: HVD_Field_Ctrl. AVCH264_CMD_ONE_FIELD
1287     /*0x2010E*/E_HVD_CMD_FAST_DISP,                 // Arg: 0: disable, Any not zero value: enable. Always return first frame ready. Don't care the first frame av-sync.
1288     /*0x2010F*/E_HVD_CMD_SKIP_TO_PTS,               // Arg: PTS(unit: 90kHz). 0: disable this mode. Any not zero value: enable. FW decode to specified PTS by using full speed. FW need not to decode frame until the first I after the specified PTS.
1289     /*0x20110*/E_HVD_CMD_SYNC_THRESHOLD,            // Arg: 0x01~0xFF , frame repeat time. If arg == 0xFF, fw will always repeat last frame when PTS > STC.
1290     /*0x20111*/E_HVD_CMD_FREERUN_THRESHOLD,         // Arg: (unit: 90KHz) 0: use default 5 sec (90000 x 5).
1291     /*0x20112*/E_HVD_CMD_FLUSH_FRM_BUF,             // Arg: 1 show last decode frame, 0 show current diaplay frame. FW will clear all frame buffer then skip to next I frame.
1292     /*0x20113*/E_HVD_CMD_FORCE_INTERLACE,           // Arg: 0; Diable. Arg: 1; Force interlace only support DTV and TS file mode with framerate 25 or 30 (all resolution, under FHD)
1293                                                     // Arg: 2; Force interlace support DTV and TS file mode with framerate 25 or 30,but only works on 1080P (width large less 1920)
1294                                                     // Arg: 3; Force interlace support DTV and TS file mode with framerate 23 to 30 and all resolution.
1295                                                     // Arg: 4; Force interlace support DTV and TS file mode with under 30 fps and all resolution.
1296                                                     // Arg: 5; Force interlace support DTV and TS file mode with with framerate 25 or 30 (under FHD and width large less 720)
1297     /*0x20114*/E_HVD_CMD_DUAL_NON_BLOCK_MODE,       // Arg: 0 disable Arg:1 For dual decode case, force switch to another task when current task is idle
1298     /*0x20115*/E_HVD_CMD_INPUT_PTS_FREERUN_MODE,    // Arg: 0 disable. Arg:1, video free run when the difference between input PTS and current STC is large than E_HVD_CMD_FREERUN_THRESHOLD + 1s;
1299     /*0x20116*/E_HVD_CMD_FREEZE_TO_CHASE,           // Arg: 1 enable, 0 disable. Freeze current image when PTS < STC and decode drop / skip frame to sync stc.
1300 
1301     // internal control action
1302 
1303     // FW settings ( only for driver init)
1304     E_HVD_CMD_SETTINGS_MASK = (0x0200|E_HVD_CMD_NEW_BASE),
1305     /*0x20201*/E_HVD_CMD_PITCH,                     // Arg:any non-zero number. AVCHVD_CMD_PITCH_1952, AVCHVD_CMD_PITCH_1984
1306     /*0x20202*/E_HVD_CMD_SYNC_EACH_FRM,             // 1: TS file mode: on ; 0: live mode: off AVCHVD_CMD_SYNC
1307     /*0x20203*/E_HVD_CMD_MAX_DEC_TICK,              // 0: off ; not 0 : in fw.h  new value AVCHVD_CMD_MAXT
1308     /*0x20204*/E_HVD_CMD_AUTO_FREE_ES,              // 1: on ; 0: off ; for live stream only AVCHVD_CMD_AUTO_FREE
1309     /*0x20205*/E_HVD_CMD_DIS_VDEAD,                 // 1: on :For PVR , file mode only ; 0 : off: AVCHVD_CMD_DIS_VDEAD
1310     /*0x20206*/E_HVD_CMD_MIN_FRAME_GAP,             // Arg: 0~n, 0xFFFFFFFF: don't care frame gap; For file mode only; AVCHVD_CMD_MIN_FRAME_GAP
1311     /*0x20207*/E_HVD_CMD_SYNC_TYPE,                 // Arg: HVD_Sync_Tbl_Type. //only for file mode. Ts , ts file mode always has PTS table
1312     /*0x20208*/E_HVD_CMD_TIME_UNIT_TYPE,            // Set Time unit: 0: 90Khz, 1: 1ms
1313     /*0x20209*/E_HVD_CMD_ISR_TYPE,                  // Add ISR trigger timing.
1314     /*0x2020A*/E_HVD_CMD_DYNAMIC_SCALE,             // 0: disable; 1: enable
1315     /*0x2020B*/E_HVD_CMD_SCALER_INFO_NOTIFY,
1316     /*0x2020C*/E_HVD_CMD_MIU_BURST_CNT,             // Arg 0~7 burst cnt level , 0xFFFFFFFF = Disable
1317     /*0x2020D*/E_HVD_CMD_FDMASK_DELAY_CNT,          // Arg: 0~0xFF, Fdmask delay count, arg >= 0xFF -> use default.
1318     /*0x2020E*/E_HVD_CMD_FRC_OUTPUT_FRAMERATE,      // unit: vsync cnt
1319     /*0x2020F*/E_HVD_CMD_FRC_OUTPUT_INTERLACE,      // 0: progressive; 1: interlace
1320     /*0x20210*/E_HVD_CMD_ENABLE_DISP_QUEUE,         // 0: Disable; 1:Enable
1321     /*0x20211*/E_HVD_CMD_FORCE_DTV_SPEC,            // 0: Disable; 1:Enable, Force to follow H264 DTV Spec, if res>720p && framerate>50, force progessive
1322                                                        // 2: Disable, if frame_mbs_only_flag == TRUE, it's progressive.
1323     /*0x20212*/E_HVD_CMD_SET_USERDATA_MODE,         // Arg: HVD_USER_DATA_MODE, use "OR", 0x00: Normal DVB user_data mode; 0x01: ATSC DirectTV CC mode
1324                                                     // 0x02: FPA CallBack, 0x04: ATSC_CC_RAW mode
1325     /*0x20213*/E_HVD_CMD_ENABLE_DISP_OUTSIDE,       // 0: Disable; 1:Enable
1326     /*0x20214*/E_HVD_CMD_SUPPORT_AVC_TO_MVC,        // Arg: 0: Disable AVC to MVC, 1: Enable AVC to MVC but non-support DS, 2:Enable AVC to MVC and support DS,
1327     /*0x20215*/E_HVD_CMD_ENABLE_NEW_SLOW_MOTION,    // Arg: 0: Disable New Slow Motion, 1: Enable New Slow Motion.
1328     /*0x20216*/E_HVD_CMD_FORCE_ALIGN_VSIZE,         // Arg: 0: Disable and 3D ouput is frame packing mode. 1: Enable VSIZE would be 4 align and Crop Botton would be additional size; 3D output would not be frame packing mode.
1329     /*0x20217*/E_HVD_CMD_PUSH_DISPQ_WITH_REF_NUM,   // Arg: 0: Disable; 1:Enable
1330     /*0x20218*/E_HVD_CMD_GET_MORE_FRM_BUF,          // Arg: 0: Disable; 1:Enable. If buffer size is enough, intial more frame buffer to use.
1331     /*0x20219*/E_HVD_CMD_RM_ENABLE_PTS_TBL,         // Arg, 0:disable, 1:enable. this command is only used by RM, when enable==1, RM will search pts table and return matched u32ID_L
1332     /*0x2021A*/E_HVD_CMD_DYNAMIC_SCALE_RESV_N_BUFFER,   // Arg, 0:disable, 1:enable. use init_dpb_and_frame_buffer_layout_3 to do dynamic layout other than fixed layout
1333     /*0x2021B*/E_HVD_CMD_DS_RESET_XC_DISP_WIN,      // Arg, 0: Disable, 1:enable. When Dynamic scaling enable, report the display information change and re-set XC display window.
1334     /*0x2021C*/E_HVD_CMD_AVC_SUPPORT_REF_NUM_OVER_MAX_DPB_SIZE,     /// Arg, 0: Disable; 1:enable. AVC support reference number is more than maximum DPB size when frame buffer size was enough.
1335     /*0x2021D*/E_HVD_CMD_FRAMERATE_HANDLING,        // Arg 0~60000, 0: Disable, 1000 ~ 60000: Used the arg to set frame rate when the sequence did not have frame rate info. and arg is not zero. (The frame unit is (arg/1000)fps, Exp: 30000 = 30.000 fps), others: Do not thing.
1336     /*0x2021E*/E_HVD_CMD_AUTO_EXHAUST_ES_MODE,      // Arg, 0: disable, [31:16]= Upper bound, [15:0] = Lower bound, Unit is 1KBytes, // Auto drop display to consume ES data as soon as possible when ES level is higher than upper bound
1337     /*0x2021F*/E_HVD_CMD_RETURN_INVALID_AFD,        // Arg, 0: Disable, 1:enable, return 0 when AFD is invalid
1338                                                     // Arg, 2: Enable, return 0 when AFD is invalid at I frame. (GOP)
1339     /*0x20220*/E_HVD_CMD_AVC_FORCE_BROKEN_BY_US,    // Arg, 0: Disable, 1:enable, force enable broken by us mode,
1340     /*0x20221*/E_HVD_CMD_EXTERNAL_DS_BUF,           // Arg, 0: Disable, 1:Enable.
1341     /*0x20222*/E_HVD_CMD_SHOW_FIRST_FRAME_DIRECT,   // Arg: 0: Disable; 1:Enable. Push first I frame to display queue directly..
1342     /*0x20223*/E_HVD_CMD_AVC_RESIZE_DOS_DISP_PEND_BUF,  //Arg: Resize disp pending buffer size for display outside mode(dos), default dos disp pending buf size = 4
1343     /*0x20224*/E_HVD_CMD_SET_MIN_TSP_DATA_SIZE,         //Arg: Resize HVD_FW_AVC_ES_MIN_TSP_DATA_SIZE
1344     /*0x20225*/E_HVD_CMD_DYNAMIC_SCALE_ENHANCE_SETTINGS,    //Arg: 0:None, 1:MHP,...
1345     /*0x20226*/E_HVD_CMD_ONE_PENDING_BUFFER_MODE,   // Arg: 0: Disable; 1:Enable. Use only one pending buffer instead of two.
1346     /*0x20227*/E_HVD_CMD_ENABLE_EXTERNAL_CC_608_BUF, // Arg: [7:0] =size, [31:8]= start address,  unit =1k bytes , Enable: length/address != 0, Disable: length/address == 0
1347     /*0x20228*/E_HVD_CMD_ENABLE_EXTERNAL_CC_708_BUF, // Arg: [7:0] =size, [31:8]= start address,  unit =1k bytes , Enable: length/address != 0, Disable: length/address == 0
1348     /*0x20229*/E_HVD_CMD_SET_DISP_ERROR_TOLERANCE,   // Arg: //[15:8]+[7:0] = (err_tolerance(0%~100%)+enable or disable)
1349     /*0x2022A*/E_HVD_CMD_SET_PTS_US_MODE,            // Arg: //0: Disable; 1:Enable. return micro seconds PTS in PTS mode
1350     /*0x2022B*/E_HVD_CMD_SET_DV_XC_SHM_ADDR,         // Arg, address for dolby vision xc DM/composer shm
1351 
1352     // Mode ( for AP run-time)
1353     E_HVD_CMD_MODE_MASK = (0x0300|E_HVD_CMD_NEW_BASE),
1354     /*0x20301*/E_HVD_CMD_SKIP_DEC,                  // E_HVD_DECODE_ALL ;E_HVD_DECODE_I;E_HVD_DECODE_IP; AVCHVD_CMD_DEC_I , AVCHVD_CMD_SKIP_NONREF
1355     /*0x20302*/E_HVD_CMD_DISP_SPEED,                // HVD_Disp_Speed  ;  AVCHVD_CMD_TRICKY  0,1: normal speed N(>0): show N times, slow motion Nx(-2,-4...) ; N(<0): FF speed Nx(2,4,...) AVCHVD_CMD_2X_SPEED
1356     /*0x20303*/E_HVD_CMD_DISP_ERR_FRM,              // True: display and error frame; FALSE: not show error frame ; AVCHVD_CMD_ERR_TH
1357     /*0x20304*/E_HVD_CMD_ERR_CONCEAL,               // 1: on ; 0: off ; AVCHVD_CMD_PASTE
1358     /*0x20305*/E_HVD_CMD_REPEAT_LAST_FIELD,         // 1: ON ; 0: OFF
1359     /*0x20306*/E_HVD_CMD_FRC_MODE,                  // Arg:HVD_FRC_Mode. AVCHVD_CMD_FRAME_CVT
1360     /*0x20307*/E_HVD_CMD_SYNC_ACTIVE,               // Arg: 0: sync off. AVCHVD_CMD_FREE_RUN ;  1: sync on. AVCHVD_CMD_AVSYNC
1361     /*0x20308*/E_HVD_CMD_PLAYBACK_FINISH,           // 1: no more input data, FW need to show frame by itself until all buffers being empty. 0: close this mode.
1362     /*0x20309*/E_HVD_CMD_BALANCE_BW,                // Arg: Byte0: Quarter Pixel Off Level, Byte1: Deblock Off Level >> 0: off, 1~255: count threshold to enter, Byte2: Upper Bound value. i.e.: Byte0: 1,Byte1: 10,Byte2: 20.
1363     /*0x2030A*/E_HVD_CMD_POWER_SAVING,              // Arg: 0: Power Saving Off, 1: Power Saving On
1364     /*0x2030B*/E_HVD_CMD_DIS_DBF,                   // Disable deblock, Arg: 0: off, 1: disable all frame, 2: only disable non-ref frame
1365     /*0x2030C*/E_HVD_CMD_DIS_QUART_PIXEL,           // Disable quarter pixel, Arg: 0: off, 1: disable for all frame, 2: only dsiable non-ref frame
1366     /*0x2030D*/E_HVD_CMD_DPO_CC,                    // Display Order User Data Command, Arg: 0: off, 1: on.
1367     /*0x2030E*/E_HVD_CMD_DISP_I_DIRECT,             // Display I directly, Arg: 0: off, 1: on
1368     /*0x2030F*/E_HVD_CMD_FORCE_RESET_HW,            // Arg, 0:disable, 1:enable. Force reset hw when frame start
1369     /*0x20310*/E_HVD_CMD_UPDATE_DISP_THRESHOLD,     // Arg, none
1370     /*0x20311*/E_HVD_CMD_FRC_DROP_MODE,             // Arg, E_HVD_FRC_DROP_FRAME (0), E_HVD_FRC_DROP_FIELD (1)
1371     /*0x20312*/E_HVD_CMD_UPDATE_DISPQ,              // Arg, none. Update Frame Status in Display Queue
1372     /*0x20313*/E_HVD_CMD_SHOW_DECODE_ORDER,         // Arg, 0:disable, 1:enable. Show decoder order or display order
1373     /*0x20314*/E_HVD_CMD_3DLR_VIEW_EXCHANGE,        // Arg, 0: off, do not thing. 1: on, exchange the L/R views
1374     /*0x20315*/E_HVD_CMD_DISP_IGNORE_CROP,          // Arg, 0:disable, 1:enable. Ignore crop information when set V-sync to display
1375     /*0x20316*/E_HVD_CMD_STOP_MVD_PARSER,           // Arg, 1:stop mvd parser
1376     /*0x20317*/E_HVD_CMD_SUSPEND_DYNAMIC_SCALE,     // Arg, 0:disable, 1:enable. Suspend dynamic scale and raise interrupt.
1377     /*0x20318*/E_HVD_CMD_AVOID_PTS_TBL_OVERFLOW,    // Arg, 0:disable, 1:enable. for hw tsp mode, mvd parser will stop when pts table is close to overflow and restart when enough pts is consumed.
1378     /*0x20319*/E_HVD_CMD_IGNORE_PIC_OVERRUN,        // Arg, 0:disable, 1:enable. Ignore hw error: PIC overrun error.
1379     /*0x2031A*/E_HVD_CMD_RVU_SETTING_MODE,          // Arg, 0:disable, 1:Drop B frame and force IDR.
1380     /*0x2031B*/E_HVD_CMD_RELEASE_DISPQ,             // Arg, none. Unlock frame status.
1381     /*0x2031C*/E_HVD_CMD_CTRL_SPEED_IN_DISP_ONLY,   // Arg, 0:disable, control in decoding and displaying time; 1:enable, control speed in displaying time only.
1382     /*0x2031D*/E_HVD_CMD_IGNORE_PIC_STRUCT_DISPLAY, // Arg, 0:disable, 1:Ignore Pic_struct when display progressive frame.
1383     /*0x2031E*/E_HVD_CMD_ERR_CONCEAL_SLICE_1ST_MB,  // Arg, 0:disable, Error concealment from current/last MB position; 1:enale, Error concealment from current slice first MB.(Need enable E_HVD_CMD_ERR_CONCEAL)
1384     /*0x2031F*/E_HVD_CMD_AUTO_DROP_ES_DATA,         // Arg, 0:disable, [31:16]= Upper bound, [15:0] = Lower bound; Unit is 1%~100%: Drop ES data when ES buffer threshold more than 1%~100%.
1385     /*0x20320*/E_HVD_CMD_AUTO_DROP_DISP_QUEUE,      // Arg, 0:disable, N = 1~16: Drop display queue when display queue above than N frames. It only support Display Queue mode. (bEnableDispQueue = TRUE)
1386     /*0x20321*/E_HVD_CMD_USE_CPB_REMOVAL_DEALY,     // Arg, 0:disable, 1:enable. Use Cpb_Removal_Delay of Picture timing SEI to control PTS.
1387     /*0x20322*/E_HVD_CMD_SKIP_N_FRAME,              // Arg, 0:disable, N = 1~63. Skip N frame.
1388     /*0x20323*/E_HVD_CMD_PVR_SEAMLESS_TIMESHIFT,    // Arg, 0:disable, 1:pause decode, 2:reset hw and wait for playback with target data, 3:seek_to_I after play
1389     /*0x20324*/E_HVD_CMD_STOP_PARSER_BY_PTS_TABLE_LEVEL,    // Arg, 0:disable, [31:16]= Upper bound, [15:0] = Lower bound; Stop parser when PTS table size is more than upper bound. Resume parser when PTS table size is less than low bound.
1390     /*0x20325*/E_HVD_CMD_INC_DISPQ_NUM,             // Arg, none. Increase DispQ Num (SW detile case)
1391     /*0x20326*/E_HVD_CMD_THUMBNAIL_MODE,            // Arg, 0:disable, 1:enable. Use small frame buffer to decode thumbnail
1392     /*0x20327*/E_HVD_CMD_CMA_FRMBUFF_ALLOCATE_STATUS,
1393     /*0x20328*/E_HVD_CMD_CMA_FRMBUFF_RELEASE_STATUS,
1394     /*0x20329*/E_HVD_CMD_FRC_ONLY_SHOW_TOP_FIELD,   // Arg, 0:disable, 1:enable. only show top filed for FRC mode
1395     /*0x2032A*/E_HVD_CMD_DIRECT_STC_MODE,           // Arg, 0:disable, 1:enable. vdec fw use g_shm->u32DirectStcInMs as stc
1396     /*0x2032B*/E_HVD_CMD_DROP_ONLY_FIELD_FRAME,     // Arg, 0:disable, 1:enable. Drop only field frame when insert to display queue and enable drop error frame.
1397     /*0x2032C*/E_HVD_CMD_SET_ENABLE_HDR,            // Arg, 0:disable, 1:enable. Suspend HDR decode/transfer HDR data.
1398 
1399     // test cmd
1400     E_HVD_CMD_TEST_MASK = (0x0400|E_HVD_CMD_NEW_BASE),
1401     /*0x20401*/E_HVD_CMD_INIT_STREAM,               // Initialize this stream
1402     /*0x20402*/E_HVD_CMD_RELEASE_STREAM,            // Release this stream
1403 
1404     // HVD new cmd Max
1405     E_HVD_CMD_NEW_MAX = (0xFFFF|E_HVD_CMD_NEW_BASE),
1406 
1407 
1408     // Dual Stream Command
1409     E_DUAL_CMD_BASE = 0x00030000,             // pass the DRAM offset from argument
1410 
1411     E_DUAL_CMD_MODE_MASK = (0x0100|E_DUAL_CMD_BASE),
1412     /*0x30101*/E_DUAL_CMD_TASK0_HVD_TSP,
1413     /*0x30102*/E_DUAL_CMD_TASK0_HVD_BBU,
1414     /*0x30103*/E_DUAL_CMD_TASK0_MVD_TSP,
1415     /*0x30104*/E_DUAL_CMD_TASK0_MVD_SLQ,
1416 
1417     /*0x30105*/E_DUAL_CMD_TASK1_HVD_TSP,
1418     /*0x30106*/E_DUAL_CMD_TASK1_HVD_BBU,
1419     /*0x30107*/E_DUAL_CMD_TASK1_MVD_TSP,
1420     /*0x30108*/E_DUAL_CMD_TASK1_MVD_SLQ,
1421 
1422     /*0x30109*/E_DUAL_CMD_SINGLE_TASK,      //argument: 0:multi(default) 1:single // first cmd
1423 
1424     /*0x3010A*/E_DUAL_CMD_MODE,             //argument: 0:normal(default) 1:3D wmv 2:Korea 3D 3:Korea 3D Progressive 4:sub view sync main STC
1425                                             //          5:switch target STC , main view sync sub stc and sub view sync main stc //first cmd
1426 
1427     /*0x3010B*/E_DUAL_BURST_MODE,           //argument: 0:normal(default) 1:burst command to controller(lots of cmd)
1428 
1429     /*0x3010C*/E_DUAL_VERSION,              //argument: 0:controller 1:mvd fw 2:hvd fw 3:mvd interface 4:hvd interface
1430     /*0x3010D*/E_DUAL_R2_CMD_EXIT,          //for WIN32 testing and let R2 FW return directly.
1431     /*0x3010E*/E_DUAL_R2_CMD_FBADDR,        //frame buffer address
1432     /*0x3010F*/E_DUAL_R2_CMD_FBSIZE,        //frame buffer size
1433     /*0x30110*/E_DUAL_R2_CMD_FB2ADDR,       //frame buffer2 address
1434     /*0x30111*/E_DUAL_R2_CMD_FB2SIZE,       //frame buffer2 size
1435     /*0x30112*/E_DUAL_CMD_COMMON,           //argument: 0:dymanic fb management
1436     /*0x30113*/E_DUAL_CMD_STC_MODE,         //set STC index
1437     E_DUAL_CMD_CTL_MASK = (0x0200|E_DUAL_CMD_BASE), // argument is the id : 0 or 1
1438     /*0x30201*/E_DUAL_CMD_DEL_TASK,
1439 
1440     // Dual Stream cmd Max
1441     E_DUAL_CMD_MAX = (0xFFFF|E_DUAL_CMD_BASE),
1442 
1443     // N Stream Command
1444     E_NST_CMD_BASE = 0x00040000,  // pass the DRAM offset from argument
1445 
1446     E_NST_CMD_MODE_MASK = (0x0100|E_NST_CMD_BASE),
1447 #ifdef VDEC3
1448     /*0x40101*/E_NST_CMD_TASK_HVD_TSP,
1449     /*0x40102*/E_NST_CMD_TASK_HVD_BBU,
1450     /*0x40103*/E_NST_CMD_TASK_MVD_TSP,
1451     /*0x40104*/E_NST_CMD_TASK_MVD_SLQ,
1452 #endif
1453 
1454     E_NST_CMD_CTL_MASK = (0x0200|E_NST_CMD_BASE),  // argument is the id : 0 ,1 or 2
1455     /*0x40201*/E_NST_CMD_DEL_TASK,
1456 
1457     // N Stream cmd Max
1458     E_NST_CMD_MAX = (0xFFFF|E_NST_CMD_BASE),
1459 
1460     // CMD MASK
1461     E_CMD_MASK = 0x00FFFFFF,
1462 
1463     // TASK ID MASK
1464     E_ID_CMD_MASK = 0xFF000000,
1465 
1466 } HVD_User_Cmd;
1467 
1468 // Command
1469 typedef enum
1470 {
1471     // Invalid cmd
1472     E_JPD_CMD_INVALID                        = 0xffffffffUL,
1473 
1474     E_JPD_CMD_GO                             = 0x00, // Start to show
1475     E_JPD_CMD_SET_FRAME_BUFF_START_ADDR      = 0x01, // Set frame buffer address
1476     E_JPD_CMD_SET_FRAME_BUFF_UNIT_SIZE       = 0x02, // Set frame buffer size
1477     E_JPD_CMD_SET_FRAME_BUFF_TOTAL_NUM       = 0x03, // Set total number of frame buffer
1478     E_JPD_CMD_SET_FRAME_BUFF_IDX             = 0x04, // Set frame buffer index
1479     E_JPD_CMD_SET_FRAME_BUFF_IDX_READY       = 0x05, // Set frame buffer index ready for display
1480     E_JPD_CMD_SET_WIDTH                      = 0x06, // Set frame width
1481     E_JPD_CMD_SET_HEIGHT                     = 0x07, // Set frame height
1482     E_JPD_CMD_SET_PITCH                      = 0x08, // Set pitch
1483     E_JPD_CMD_SET_FRAME_ID_L                 = 0x09, // Set frame ID_L
1484     E_JPD_CMD_SET_FRAME_ID_H                 = 0x0A, // Set frame ID_H
1485     E_JPD_CMD_SET_TIMESTAMP                  = 0x0B, // Set Time Stamp
1486     E_JPD_CMD_SET_FRAMERATE                  = 0x0C, // Set FrameRate
1487     E_JPD_CMD_SET_FRAMERATE_BASE             = 0x0D, // Set FrameRate Base
1488     E_JPD_CMD_SET_FRAME_BUFF_IDX_VALID       = 0x0E, // Set frame buffer index available
1489     E_JPD_CMD_SET_CHIP_ID                    = 0x0F, // Set Chip ID
1490 
1491     E_JPD_CMD_PLAY                           = 0x20, // Play
1492     E_JPD_CMD_PAUSE                          = 0x21, // Pause
1493     E_JPD_CMD_RESUME                         = 0x22, // Resume
1494     E_JPD_CMD_STEP_PLAY                      = 0x23, // Step play
1495     E_JPD_CMD_SET_SPEED_TYPE                 = 0x24, // Set play speed type: default, fast, slow
1496     E_JPD_CMD_SET_SPEED                      = 0x25, // Set play speed
1497     E_JPD_CMD_FLUSH_DISP_QUEUE               = 0X26, // Flush display queue
1498     E_JPD_CMD_FREEZE_DISP                    = 0x27, // Freeze display
1499     E_JPD_CMD_ENABLE_AVSYNC                  = 0x28, // Enable AV Sync
1500     E_JPD_CMD_SET_AVSYNC_DELAY               = 0x29, // Set AV sync delay
1501     E_JPD_CMD_SET_AVSYNC_TOLERENCE           = 0x2A, // Set AV sync tolerence
1502     E_JPD_CMD_SET_PTS_BASE                   = 0x2B, // Set PTS base
1503     E_JPD_CMD_SET_STC_BASE                   = 0x2C, // Set STC base
1504     E_JPD_CMD_SET_BLUE_SCREEN                = 0x2D, // Set Blue Screen
1505     E_JPD_CMD_PUSH_QUEUE_PARA_SETTING        = 0x2E,
1506     E_JPD_CMD_SET_DISPLAY_OUTSIDE_MODE       = 0x2F,
1507 
1508     E_JPD_CMD_GET_NEXT_FREE_FRAME_BUFF_IDX   = 0x40, // Get next free frame buffer index
1509     E_JPD_CMD_COMPENSATE_PTS                 = 0x41, // Ask firmware to compensate PTS
1510 
1511 
1512 #ifdef VDEC3
1513     E_JPD_CMD_GET_FRAME_BUFFER               = 0x50, // Ask firmware to get frame buffer
1514     E_JPD_CMD_FREE_FRAME_BUFFER              = 0x51, // Ask firmware to free frame buffer
1515 #endif
1516 
1517     // Display Command Queue
1518     E_JPD_CMD_ENABLE_DISP_CMD_QUEUE          = 0x80, // Enable Display Command Queue
1519     E_JPD_CMD_PUSH_DISP_CMD                  = 0x81, // Push Display Command
1520     E_JPD_CMD_GET_DISP_CMD_Q_VACANCY         = 0x82, // Check if the display command queue full or not
1521 
1522     E_JPD_CMD_IS_STEP_PLAY_DONE              = 0xFF, //
1523     E_JPD_CMD_IS_DISP_FINISH                 = 0xFE, //
1524     E_JPD_CMD_IS_PLAYING                     = 0xFC, //
1525     E_JPD_CMD_IS_DISPLAY_QUEUE_FULL          = 0xFB, //
1526     E_JPD_CMD_IS_AVSYNC_ON                   = 0xFA, //
1527     E_JPD_CMD_IS_REACH_AVSYNC                = 0xF9, //
1528     E_JPD_CMD_IS_FLUSH_DONE                  = 0xF8, // Check if flush done
1529 
1530 } JPD_User_Cmd;
1531 
1532 // Firmware State
1533 typedef enum
1534 {
1535     E_JPD_FW_STATE_MASK = 0xF000,
1536 } JPD_FW_State;
1537 
1538 // Error Code
1539 typedef enum
1540 {
1541     // Error code base
1542     E_JPD_ERR_BASE= 0x01000000,
1543 } JPD_Err_Code;
1544 
1545 typedef enum
1546 {
1547     E_HVD_FW_STATE_MASK = 0xF000,
1548 
1549     // state: INIT
1550     E_HVD_FW_INIT = 0x1000,
1551     E_HVD_FW_INIT_START,
1552     E_HVD_FW_INIT_DONE,
1553 
1554     // state: PLAY
1555     E_HVD_FW_PLAY = 0x2000,
1556     E_HVD_FW_PLAY_TYPE_MASK = 0x0C00,
1557 
1558     // AVC
1559     E_HVD_FW_PLAY_AVC = (0x0000|E_HVD_FW_PLAY),
1560     E_HVD_FW_AVC_READ_NAL,
1561     E_HVD_FW_AVC_READ_NEW_SLICE,
1562     E_HVD_FW_AVC_PREPARE_SLICE_HEADER,
1563     E_HVD_FW_AVC_DECODE_ONE_SLICE,
1564     E_HVD_FW_AVC_EXIT_PICTURE,
1565 
1566     // AVS
1567     E_HVD_FW_PLAY_AVS = (0x0400|E_HVD_FW_PLAY),
1568 
1569     // RM
1570     E_HVD_FW_PLAY_RM = (0x0800|E_HVD_FW_PLAY),
1571 
1572     // state: PAUSE
1573     E_HVD_FW_PAUSE = 0x3000,
1574 
1575     // state: STOP
1576     E_HVD_FW_STOP = 0x4000,
1577     E_HVD_FW_STOP_START,
1578     E_HVD_FW_STOP_DONE,
1579 } HVD_FW_State;
1580 
1581 
1582 typedef enum
1583 {
1584     // Error code base
1585     E_HVD_ERR_BASE = 0x0000,
1586 
1587     // General
1588     E_HVD_ERR_GENERAL_BASE = (0x0000|E_HVD_ERR_BASE),
1589     E_HVD_ERR_OUT_OF_SPEC,
1590     E_HVD_ERR_UNKNOW_ERR,
1591     E_HVD_ERR_HW_BREAK_DOWN,
1592     // TIMEOUT
1593     E_HVD_ERR_HW_DEC_TIMEOUT,
1594     // NOT SUPPORT
1595     E_HVD_ERR_OUT_OF_MEMORY,        // required memory size is over frame buffer size.
1596     E_HVD_ERR_UNKNOWN_CODEC,        // unknown media codec
1597     E_HVD_ERR_CMA_FAILED,
1598 
1599     // AVC
1600     E_HVD_ERR_AVC_BASE = (0x1000|E_HVD_ERR_BASE),
1601     // decode error
1602     E_HVD_ERR_AVC_SPS_BROKEN,           // SPS is not valid
1603     E_HVD_ERR_AVC_SPS_NOT_IN_SPEC,
1604     E_HVD_ERR_AVC_SPS_NOT_ENOUGH_FRM,   // DPB size at specified level is smaller than the specified number of reference frames. This is not allowed
1605     E_HVD_ERR_AVC_PPS_BROKEN,           // PPS is not valid
1606     E_HVD_ERR_AVC_REF_LIST,
1607     E_HVD_ERR_AVC_NO_REF,
1608     E_HVD_ERR_AVC_RES,                  // out of supported resolution
1609 
1610     // AVS
1611     E_HVD_ERR_AVS_BASE = (0x2000|E_HVD_ERR_BASE),
1612     E_HVD_ERR_AVS_RES,                  // out of supported resolution
1613 
1614     // RM
1615     E_HVD_ERR_RM_BASE = (0x3000|E_HVD_ERR_BASE),
1616     E_HVD_ERR_RM_PACKET_HEADER,
1617     E_HVD_ERR_RM_FRAME_HEADER,
1618     E_HVD_ERR_RM_SLICE_HEADER,
1619     E_HVD_ERR_RM_BYTE_CNT,
1620     E_HVD_ERR_RM_DISP_TIMEOUT,
1621     E_HVD_ERR_RM_NO_REF,
1622     E_HVD_ERR_RM_RES,                   // out of supported resolution
1623     E_HVD_ERR_RM_VLC,
1624     E_HVD_ERR_RM_SIZE_OUT_FB_LAYOUT,
1625 
1626     // VP8
1627     E_HVD_ERR_VP8_BASE = (0x4000|E_HVD_ERR_BASE),
1628     E_HVD_ERR_VP8_RES,                  // out of supported resolution
1629 
1630     // HEVC
1631     E_HVD_ERR_HEVC_BASE = (0x5000|E_HVD_ERR_BASE),
1632     E_HVD_ERR_HEVC_RES,                  // out of supported resolution
1633 
1634     // VP9
1635     E_HVD_ERR_VP9_BASE = (0x6000|E_HVD_ERR_BASE),
1636     E_HVD_ERR_VP9_RES,                  // out of supported resolution
1637 } HVD_Err_Code;
1638 
1639 typedef enum
1640 {
1641     E_HVD_ES_BUF_STATUS_UNKNOWN   = 0,
1642     E_HVD_ES_BUF_STATUS_UNDERFLOW = 1,
1643     E_HVD_ES_BUF_STATUS_OVERFLOW  = 2,
1644     E_HVD_ES_BUF_STATUS_NORMAL    = 3,
1645 
1646 }HVD_ES_Buf_Status;
1647 
1648 typedef enum {
1649     E_PVR_SEAMLESS_TIMESHIFT_NONE = 0,
1650     E_PVR_SEAMLESS_TIMESHIFT_PAUSE_DECODE,          // initialize timeshift record, pause decode and set target POC/pts
1651     E_PVR_SEAMLESS_TIMESHIFT_RESET_AND_FINE_TARGET, // resume and try to find picture with target POC/pts, drop before we find it
1652     E_PVR_SEAMLESS_TIMESHIFT_SEEK_TO_I              // stop finding target, decode from next I
1653 } HVD_Seamless_Mode;
1654 
1655 typedef enum
1656 {
1657     E_HVD_FREEZE_AT_CUR_PIC = 1,
1658     E_HVD_FREEZE_AT_LAST_PIC = 2,
1659     E_HVD_FREEZE_AT_CUR_PIC_AND_CLEAR_DECODE_INFO = 3,
1660 }HVD_Flush_Mode;
1661 
1662 typedef enum
1663 {
1664     E_HVD_SEAMLESS_PAUSE_DECODE      = BIT(0),
1665     E_HVD_SEAMLESS_DISPLAY_REPEATING = BIT(1),
1666     E_HVD_SEAMLESS_RESET_HW_DONE     = BIT(2),
1667     E_HVD_SEAMLESS_TARGET_FRM_FOUND  = BIT(3),
1668     E_HVD_SEAMLESS_DISPLAY_RESUME    = BIT(4),
1669 }HVD_Seamless_Status;
1670 
1671 typedef enum
1672 {
1673     E_HVD_POST_PROC_NONE     = 0,
1674     E_HVD_POST_PROC_DETILE   = BIT(0),
1675 } HVD_Post_Process;
1676 
1677 typedef enum
1678 {
1679     E_HVD_CHIP_U01   = 0,
1680     E_HVD_CHIP_U02   = 1,
1681 } HVD_CHIP_ECO_NUM;
1682 
1683 #endif // _FW_HVD_IF_H_
1684 
1685