xref: /utopia/UTPA2-700.0.x/modules/vdec_v3/hal/mooney/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 0x00001500
103 #define HVD_FW_IF_VERSION 0x00790200
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  (sizeof(HVD_MasteringDisplayColourVolume))
174 #define HVD_DisplayColourVolume_SEI_NUM   (2)
175 #define HVD_ContentLightLevel_SEI_SIZE    (sizeof(HVD_ContentLightLevelInfo))
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 #ifdef LIGHTWEIGHT  //FW31_1.8M
204 #define HVD_SHARE_MEM_ST_OFFSET         0xC0000
205 #else
206 #if defined(SUPPORT_EVD) && (SUPPORT_EVD==1)
207 #define HVD_SHARE_MEM_ST_OFFSET        0x100000
208 #else
209 #define HVD_SHARE_MEM_ST_OFFSET         0xA0000
210 #endif
211 #endif
212 
213 #define HVD_DYNAMIC_SCALING_SIZE         0x1F00
214 #define HVD_DYNAMIC_SCALING_SIZE_3K       0xC00 // allocate 6k.   actually use: 16 align => 3k
215 #define HVD_DYNAMIC_SCALING_SIZE_6K      0x1800 // allocate 6k.   actually use: 32 align => 6k
216 #define HVD_DYNAMIC_SCALING_SIZE_8K      0x1F00
217 #define HVD_DYNAMIC_SCALING_DEPTH          0x10
218 #define HVD_DYNAMIC_SCALING_3D_DEPTH       0x18 /// 3D Dynamic scaling use 24.
219 #define HVD_SCALER_INFO_SIZE              0x100
220 
221 #define HVD_AVC_FRAME_PACKING_SEI_SIZE  0x100
222 #define HVD_AVC_FRAME_PACKING_SEI_NUM   2
223 
224 //DBG
225 #define HVD_DBG_DUMP_SIZE                0x6500
226 #define HVD_DUMMY_WRITE_MAX_SIZE          0x200
227 
228 #define MAX_VSYNC_BRIDGE_DISPQ_NUM      8
229 #define HVD_DISP_QUEUE_MAX_SIZE         42
230 #define FRAMEQ_SIZE                      16
231 
232 // AVC
233 #define HVD_FW_AVC_DUMMY_FIFO                 256  // bytes
234 #define HVD_FW_AVC_MAX_DECODE_TICK         100000  // tick ???
235 #define HVD_FW_AVC_MAX_VIDEO_DELAY           1000  // ms ; based on ???
236 #define HVD_FW_AVC_ES_MIN_TSP_DATA_SIZE     0x100
237 #define HVD_FW_AVC_ES_MIN_TSP_DATA_SIZE2   0x1800
238 #define HVD_FW_BROKEN_BY_US_MIN_DATA_SIZE  0x1800
239 
240 #define HVD_FW_AVC_ES_UNDER_THRESHOLD     0x800   // 2048
241 #define HVD_FW_AVC_ES_OVER_THRESHOLD    0x40000 // 256*1024
242 
243 // User CC
244 #define USER_CC_DATA_SIZE               38
245 #define USER_CC_IDX_SIZE                12
246 
247 // AVS
248 #define HVD_FW_AVS_DUMMY_FIFO           2048 //BYTES
249 
250 // RM
251 #define HVD_FW_RM_DUMMY_FIFO            256  // ??
252 #define HVD_RM_INIT_PICTURE_SIZE_NUMBER 8
253 
254 #define EXT_CC_INFO_LENGTH            16
255 #define EXT_608_CC_PACKET_LENGTH      16
256 #define EXT_608_CC_DATA_ALIGN   EXT_608_CC_PACKET_LENGTH
257 #define EXT_708_CC_PACKET_LENGTH     128
258 #define EXT_708_CC_DATA_ALIGN   EXT_708_CC_PACKET_LENGTH
259 
260 
261 
262 // Debug
263 #define HVD_FW_AVS_OUTPUT_INFO_ADDR     0x20001F00UL
264 #define HVD_FW_AVC_OUTPUT_INFO_ADDR     0x20001F00UL
265 
266 #define HVD_HW_PREFETCH_SIZE            128
267 #define HVD_DUMMY_PACKET_SIZE           (HVD_HW_PREFETCH_SIZE << 1)
268 #define HVD_DUMMY_PACKET_DATA           0x0
269 #define HVD_DUMMY_PACKET_OFFSET         0x0
270 
271 #define PRESET_ONE_PENDING_BUFFER       (1 << 0)  /// For AVC, one pending buffer mode, reduce from two to one
272 #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
273 #define PRESET_DUMMY_PACKET_READY       (1 << 2)  /// For checking HW BBU status after filling nal table
274 #define PRESET_4K2K_CHECK               (1 << 3)  /// For checking 4k2k need support or not
275 #define PRESET_FORCE_START_NON_I_SLICE  (1 << 4)  /// For force start decode frame when 1st slice is not I slice.
276 #define PRESET_CONNECT_DISPLAY_PATH     (1 << 5)  ///
277 #define PRESET_CAL_FRAMERATE            (1 << 6)  /// For HVD,calculate framerate
278 #define PRESET_CONNECT_INPUT_TSP        (1 << 7)  ///
279 #define PRESET_VP9_4K2K_CHECK           (1 << 8)  /// For checking VP9 4k2k need support or not
280 
281 #define MFCODEC_INFO_VP9_MODE_OFFSET    29
282 #define MFCODEC_INFO_UNCOMPRESS_OFFSET  28
283 #define MFCODEC_INFO_MIU_SELECT_OFFSET  24
284 #define MFCODEC_INFO_PITCH_OFFSET       16
285 #define MFCODEC_INFO_MFDEC_ID_OFFSET    8
286 
287 // For Git Changes
288 #define GIT_TIMESTAMP 1481641990
289 
290 typedef enum
291 {
292     E_HVD_IQMEM_INIT_NONE = 0,
293     E_HVD_IQMEM_INIT_LOADING,   //HK -> FW
294     E_HVD_IQMEM_INIT_LOADED,    //FW -> HK
295     E_HVD_IQMEM_INIT_FINISH     //HK -> FW
296 
297 }HVD_IQMEM_INIT_STATUS;
298 
299 
300 
301 typedef enum
302 {
303     E_HVD_FLUSH_NONE = 0,
304     E_HVD_FLUSH_RUNNING,     //HK -> FW
305     E_HVD_FLUSH_DONE         //FW -> HK
306 
307 }HVD_FLUSH_STATUS;
308 
309 typedef enum
310 {
311     E_HVD_ISR_EVENT_NONE = 0,                        ///< disable ISR
312     E_HVD_ISR_EVENT_DISP_ONE = BIT(0),               ///< HVD display one frame on screen.
313     E_HVD_ISR_EVENT_DISP_REPEAT = BIT(1),            ///< The current displayed frame is repeated frame.
314     E_HVD_ISR_EVENT_DISP_WITH_CC = BIT(2),           ///< Current displayed frame should be displayed with user data.
315     E_HVD_ISR_EVENT_DISP_FIRST_FRM = BIT(3),         ///< HVD display first frame on screen.
316     E_HVD_ISR_EVENT_DISP_FINISH = BIT(4),            ///< HVD display finish event.
317 
318     E_HVD_ISR_EVENT_DEC_CMA_ACTION = BIT(7),         ///< HVD CMA allocate/release memory ISR
319     E_HVD_ISR_EVENT_DEC_ONE = BIT(8),                ///< HVD decoded one frame done.
320     E_HVD_ISR_EVENT_DEC_I = BIT(9),                  ///< HVD decoded one I frame done.
321     E_HVD_ISR_EVENT_DEC_HW_ERR = BIT(10),            ///< HVD HW found decode error.
322     E_HVD_ISR_EVENT_DEC_CC_FOUND = BIT(11),          ///< HVD found one user data with decoded frame(with display order).
323     E_HVD_ISR_EVENT_DEC_DISP_INFO_CHANGE = BIT(12),  ///< HVD found display information change.
324     E_HVD_ISR_EVENT_DEC_DATA_ERR = BIT(13),          ///< HVD HW found decode error.
325     E_HVD_ISR_EVENT_DEC_FIRST_FRM = BIT(14),         ///< HVD decode first frame.
326     E_HVD_ISR_EVENT_DEC_SEQ_HDR_FOUND = BIT(15),     ///< HVD found sequence header.
327 } HVD_ISR_Event_Type;
328 
329 typedef enum
330 {
331     E_HVD_USER_DATA_MODE_DVB_NORMAL                 = 0x00,
332     E_HVD_USER_DATA_MODE_DIRECTTV_CC                = 0x01,
333     E_HVD_USER_DATA_MODE_FRM_PACKING_ARRANGEMENT    = 0x02,
334     E_HVD_USER_DATA_MODE_ATSC_CC_RAW                = 0x04,
335     E_HVD_USER_DATA_MODE_CC_UNTIL_START_CODE        = 0x08
336 } HVD_USER_DATA_MODE;
337 
338 
339 typedef enum
340 {
341     E_HVD_DRV_AUTO_BBU_MODE = 0x00,
342     E_HVD_FW_AUTO_BBU_MODE  = 0x01,
343 } HVD_BBU_MODE;
344 
345 typedef enum
346 {
347     E_HVD_FW_STATUS_NONE = 0,               ///< NONE Flag
348     E_HVD_FW_STATUS_SEEK_TO_I = BIT(0),     ///< Seek to I slice/frame flag
349 } HVD_FW_STATUS_FLAG;
350 
351 typedef enum
352 {
353     //sharemem u32CodecMiscInfo bit assignment
354     E_VIDEO_FULL_RANGE = BIT(0),
355 } CODEC_MISC_INFO;
356 
357 typedef enum
358 {
359     E_DIVX_PROFILE_NONE = 0,
360     E_DIVX_PROFILE_DIVX_PLUS,
361     E_DIVX_PROFILE_DIVX_HEVC
362 } DIVX_PROFILE;
363 
364 /*
365 //interupt flag  , value is in VPU RISC MBOX 1 ( for LG GP DTV only)
366 #define HVD_ISR_USER_DATA               (1 << 0)
367 #define HVD_ISR_DATA_ERR                (1 << 1)
368 #define HVD_ISR_PIC_DEC_ERR             (1 << 2)
369 #define HVD_ISR_DEC_OVER                (1 << 3)
370 #define HVD_ISR_DEC_UNDER               (1 << 4)
371 #define HVD_ISR_DEC_I                   (1 << 5)
372 #define HVD_ISR_DIS_READY               (1 << 6)
373 #define HVD_ISR_SEQ_INFO                (1 << 7)
374 #define HVD_ISR_VIDEO_SKIP              (1 << 8)
375 #define HVD_ISR_VIDEO_REPEAT            (1 << 9)
376 #define HVD_ISR_VIDEO_FREERUN           (1 << 10)
377 #define HVD_ISR_INVALID_STREAM          (1 << 11)
378 #define HVD_ISR_VIDEO_AVSYNC_DONE       (1 << 12)
379 #define HVD_ISR_VIDEO_VSYNC             (1 << 31)
380 */
381 
382 //-------------------------------------------------------------------------------------------------
383 //  Type and Structure
384 //-------------------------------------------------------------------------------------------------
385 // User CC
386 #define USR_BUF_SIZE (256)
387 
388 typedef struct _DTV_BUF_type
389 {
390     MS_U8 type;                 // 0xCC:continue, 0:P 1:B 2:I
391     MS_U8 len;                  // size byte of buf
392     MS_U8 active;               // 0:free 1:already dma out or not assign 2:assign
393     MS_U8 pic_struct;           // pic_struct, Reserved when 0, Top Field when 1, Bottom Field when 2, and Frame picture when 3.
394     MS_U32 pts;
395     MS_U16 u16TempRefCnt;       // Temp Ref Count for UserData ,Value that increases by 1 for each frame (like time stamp)
396     MS_U16 u16Res;              // Reserved
397     MS_U32 u32Res;              // Reserved
398     MS_U8 buf[USR_BUF_SIZE];       //user data
399 } DTV_BUF_type;                 //size must <= 276, currently only use 272
400 
401 #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
402 
403 typedef struct
404 {
405     MS_BOOL bUsed;
406     MS_BOOL bvaild;
407     MS_U8   u8Frm_packing_arr_cnl_flag;         // u(1)
408     MS_U8   u8Frm_packing_arr_type;             // u(7)
409     MS_U8   u8content_interpretation_type;      // u(6)
410     MS_U8   u1Quincunx_sampling_flag:1;         // u(1)
411     MS_U8   u1Spatial_flipping_flag:1;          // u(1)
412     MS_U8   u1Frame0_flipping_flag:1;           // u(1)
413     MS_U8   u1Field_views_flag:1;               // u(1)
414     MS_U8   u1Current_frame_is_frame0_flag:1;   // u(1)
415     MS_U8   u1Frame0_self_contained_flag:1;     // u(1)
416     MS_U8   u1Frame1_self_contained_flag:1;     // u(1)
417     MS_U8   u1Reserved1:1;                      // u(1)
418     MS_U8   u4Frame0_grid_position_x:4;         // u(4)
419     MS_U8   u4Frame0_grid_position_y:4;         // u(4)
420     MS_U8   u4Frame1_grid_position_x:4;         // u(4)
421     MS_U8   u4Frame1_grid_position_y:4;         // u(4)
422     MS_U16  u16CropRight;
423     MS_U16  u16CropLeft;
424     MS_U16  u16CropBottom;
425     MS_U16  u16CropTop;
426     MS_U8   u8payload_len;
427     MS_U8   u8WaitSPS;
428     MS_U8   u8Reserved[2];
429     MS_U8   u8payload[HVD_FRM_PACKIMG_PAYLOAD_SIZE];
430 } HVD_Frame_packing_SEI;
431 
432 typedef struct
433 {
434     MS_BOOL bUsed;
435     MS_BOOL colourVolumeSEIEnabled;
436     MS_U32 maxLuminance;
437     MS_U32 minLuminance;
438     MS_U16 primaries[3][2];
439     MS_U16 whitePoint[2];
440 } HVD_MasteringDisplayColourVolume;
441 
442 typedef struct
443 {
444     MS_BOOL bUsed;
445     MS_BOOL ContentLightLevelEnabled;
446     MS_U16  maxContentLightLevel;
447     MS_U16  maxPicAverageLightLevel;
448 } HVD_ContentLightLevelInfo;
449 
450 // stuct
451 typedef struct
452 {
453     MS_U16 u16HorSize;
454     MS_U16 u16VerSize;
455     MS_U32 u32FrameRate;                // Unit: ms
456     MS_U8 u8AspectRate;                 // aspect ration ID; for AVC only
457     MS_U8 u8Interlace;
458     MS_U8 u8AFD;
459     //MS_U8 u8par_width;
460     //MS_U8 u8par_height;
461     MS_U8 bChroma_idc_Mono;             // 1: mono 0: colorful, not mono ; AVC only currently. AVS,RM??
462     MS_U16 u16DispWidth;                // Display width or aspect ratio width
463     MS_U16 u16DispHeight;               // Display height or aspect ratio height
464     MS_U16 u16CropRight;
465     MS_U16 u16CropLeft;
466     MS_U16 u16CropBottom;
467     MS_U16 u16CropTop;
468     MS_U16 u16Pitch;                    // ???
469     MS_U8  u8ColourPrimaries;           // Color Primaries in VUI
470     //****************************
471     MS_U8 u8IsOriginInterlace;          // Is Original Interlace mode
472     //******************************
473     // MS_U16 u16PTSInterval;           // ??? not fill
474     // MS_U8 u8MPEG1;                   // may be removed
475     // MS_U8 u8PlayMode;                // ??? not fill
476     // MS_U8 u8FrcMode;                 // may be removed
477 } HVD_Display_Info;                     //  bytes
478 
479 typedef struct
480 {
481     MS_U8 bIsShowErrFrm;
482     MS_U8 bIsRepeatLastField;
483     MS_U8 bIsErrConceal;
484     MS_U8 bIsSyncOn;
485     MS_U8 bIsPlaybackFinish;
486     MS_U8 u8SyncType;                   // HVD_Sync_Tbl_Type
487     MS_U8 u8SkipMode;                   // HVD_Skip_Decode_Type
488     MS_U8 u8DropMode;                   // HVD_Drop_Disp_Type
489     MS_S8 s8DisplaySpeed;               // HVD_Disp_Speed
490     MS_U8 u8FrcMode;                    // HVD_FRC_Mode
491     MS_U8 bIsBlueScreen;
492     MS_U8 bIsFreezeImg;
493     MS_U8 bShowOneField;
494     //*****************************
495     MS_U8 u8reserve8_1;
496     MS_U16 u16reserve16_1;
497     //*****************************
498 } HVD_Mode_Status;                      // 12 bytes
499 
500 typedef struct
501 {
502     MS_U16 u16Width;
503     MS_U16 u16Height;
504 } HVD_PictureSize;
505 
506 typedef enum
507 {
508     E_HVD_PP_FD_NONE = 0,                  ///< NONE Flag
509     E_HVD_PP_FD_DONE = BIT(0) ,            ///< Field Detector: process done? (0: not done; 1: done)
510     E_HVD_PP_FD_NEED_REVERSE = BIT(1) ,    ///< Field Detector: need reverse? (0: no need; 1: need)
511 } HVD_Frm_Info_Mode_Flag;
512 
513 
514 typedef struct
515 {
516     MS_U32 u32LumaAddr;                 ///< The start offset of luma data. Unit: byte.
517     MS_U32 u32ChromaAddr;               ///< The start offset of chroma data. Unit: byte.
518     MS_U32 u32PpInLumaAddr;             ///< Luma address (For post-process use)
519     MS_U32 u32PpInChromaAddr;           ///< Chroma address (For post-process use)
520     MS_U32 u32TimeStamp;                ///< Time stamp(DTS, PTS) of current displayed frame. Unit: 90khz.
521     MS_U32 u32ID_L;                     ///< low part of ID number decided by MDrv_HVD_PushQueue().
522     MS_U32 u32ID_H;                     ///< high part of ID number decided by MDrv_HVD_PushQueue().
523     MS_U8  u8FrmType;                   ///< HVD_Picture_Type, picture type: I, P, B frame
524     MS_U8  u8FieldType;                 ///< HVD_Field_Type, none, top , bottom, both field
525     MS_U16 u16Pitch;
526     MS_U16 u16Width;
527     MS_U16 u16Height;
528     MS_U32 u32Status;                   ///< 0:None, 1:Init, 2:View, 3:Disp, 4:Free
529     MS_U32 u32PrivateData;              ///[STB]only for AVC
530     MS_U32 u32LumaAddr_2bit;            ///< The start offset of 2bit luma data. Unit: byte.
531     MS_U32 u32ChromaAddr_2bit;          ///< The start offset of 2bit chroma data. Unit: byte.
532     MS_U16 u16Pitch_2bit;
533     MS_U8  u8LumaBitdepth;
534     MS_U8  u8ChromaBitdepth;
535     MS_U8  u2Luma0Miu:2;
536     MS_U8  u2Luma1Miu:2;
537     MS_U8  u2Chroma0Miu:2;
538     MS_U8  u2Chroma1Miu:2;
539     MS_U8  u8FbIndex;
540     MS_U8  u8ModeFlag;                  /// use HVD_Frm_Info_Mode_Flag
541     MS_U8  reserved8;
542 } HVD_Frm_Information;
543 
544 typedef enum
545 {
546     HVD_FRM_INFO_EXT_TYPE_10BIT,           // 2bits in 10 bits case
547     HVD_FRM_INFO_EXT_TYPE_INTERLACE,       // 2nd field 8bits in interlace case
548     HVD_FRM_INFO_EXT_TYPE_10BIT_INTERLACE, // 2nd field 2bits in 10bits interlace case
549     HVD_FRM_INFO_EXT_TYPE_MFCBITLEN,       // bit length in MFC case
550     HVD_FRM_INFO_EXT_TYPE_MAX,
551 } HVD_FRM_INFO_EXT_TYPE;
552 
553 typedef enum
554 {
555     E_DISP_PATH_DEFAULT = 0,
556     E_DISP_PATH_DYNMC_DISCONNECT,
557     E_DISP_PATH_DYNMC_HANDLING,
558     E_DISP_PATH_DYNMC_CONNECTTED
559 
560 }DISP_PATH_CONNECT_STATUS;
561 
562 
563 typedef enum _HVD_COMPLEXITY_LEVEL
564 {
565     HVD_COMPLEXITY_LEVEL1 = 1,             // lower than level 2
566     HVD_COMPLEXITY_LEVEL2,                 // higher than avg avg BW of 4k30p 8bit
567     HVD_COMPLEXITY_LEVEL3,                 // higher than avg avg BW of 4k30p 10bit
568     HVD_COMPLEXITY_LEVEL4,                 // higher than avg BW of 4k60p 8bit
569     HVD_COMPLEXITY_LEVEL5,                 // higher than avg BW of 4k60p 10bit
570 } HVD_COMPLEXITY_LEVEL;
571 
572 typedef enum
573 {
574     E_HVD_HDR_METATYPE_VUI_OFFSET                 = 0, ///< HVD display one frame on screen.
575     E_HVD_HDR_METATYPE_SEI_MASTERING_COLOR_OFFSET = 1, ///< The current displayed frame is repeated frame.
576     E_HVD_HDR_METATYPE_DOLBY_VISION_OFFSET        = 2, ///< Current displayed frame should be displayed with user data.
577     E_HVD_HDR_METATYPE_TCH_OFFSET                 = 3,
578     E_HVD_HDR_METATYPE_DOLBY_HDR10_VISION_OFFSET  = 4,
579 } HVD_HDR_EXT_META_TYPE_OFFSET;
580 
581 /****************************************************************************************
582                                   MFCodecInfo
583           +---------------------------------------------------------------+
584           |Uncompress|BitLen Miu Select|  Pitch  |   MFCodec Version      |
585           |   4 bits |      4 bits     |  8 bits |       16 bits          |
586           +---------------------------------------------------------------+
587 ***************************************************************************************/
588 typedef struct
589 {
590     MS_U32 u32LumaAddrExt[HVD_FRM_INFO_EXT_TYPE_MAX];
591     MS_U32 u32ChromaAddrExt[HVD_FRM_INFO_EXT_TYPE_MAX];
592 
593     MS_U32 MFCodecInfo;
594         // bit[29]     MFCodec 3.0 vp9 mode (1: vp9, 0: h26x)
595         // bit[28]     MFCodec uncompress mode
596         // bits[27:24] MFCodec blens buffer miu sel
597         // bit[23:16]  MFCodec pitch setting
598         // bit[8]      MFDec ID
599         // bits[7:0]   MFCodec mode
600 
601     // SEI start //
602     MS_U32 maxLuminance;
603     MS_U32 minLuminance;
604     MS_U16 primaries[3][2];
605     MS_U16 whitePoint[2];
606     // SEI end //
607     MS_U8 Frm_Info_Ext_avail; ///bit[2]: DV_Enabled, bit[1]: SEI_Enabled,  bit[0]: colur_description_present_flag
608     // colour_description start //
609     MS_U8 colour_primaries;                            // u(8)
610     MS_U8 transfer_characteristics;                    // u(8)
611     MS_U8 matrix_coefficients;                         // u(8)
612     ////Dolby_Vision////////////
613     MS_U8 u8DVMode; // bit[0:1] 0: Disable 1:Single layer 2: Dual layer, bit[2] 0:Base Layer 1:Enhance Layer
614     MS_U8 u8CurrentIndex;
615     MS_U8 bDMEnable;
616     MS_U8 bCompEnable;
617     MS_U32 u32DVMetadataAddr;
618     MS_U32 u32DVDMSize;
619 
620     MS_U32 u32DVCompSize;
621     MS_U32 u32DVRegAddr;
622     MS_U32 u32DVRegSize;
623     MS_U32 u32DVLutAddr;
624     MS_U32 u32DVLutSize;
625     // Other
626     MS_U8  u8ComplexityLevel; // from HVD_COMPLEXITY_LEVEL1 to HVD_COMPLEXITY_LEVEL5. Higher level means more complexity
627     MS_U8  u8TileMode;
628     MS_U8  u8Reserve[2];
629     // Pixel aspect ratio info, crop info
630     MS_U32 u32ParWidth;
631     MS_U32 u32ParHeight;
632     MS_U16 u16CropRight;
633     MS_U16 u16CropLeft;
634     MS_U16 u16CropBottom;
635     MS_U16 u16CropTop;
636     // Profiling / benchmark
637     MS_U16 u16MIUBandwidth;
638     MS_U16 u16Bitrate;
639     // HTLB
640     MS_U8  u8HTLBTableId;
641     MS_U8  u8HTLBEntriesSize;
642     MS_U32 u32HTLBEntriesAddr;
643     MS_U8  u8Reserve1[2];
644 
645     //qos
646     MS_S16 s16MinQp;
647     MS_S16 s16AvgQp;
648     MS_S16 s16MaxQp;
649     MS_S16 s16MinMV;
650     MS_S16 s16AvgMV;
651     MS_S16 s16MaxMV;
652     MS_U32 u32SkipMV;
653     MS_U32 u32NonSkipMV;
654 } 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
655 
656 typedef struct
657 {
658     HVD_Frm_Information_EXT_Entry stEntry[HVD_DISP_QUEUE_MAX_SIZE];
659 } HVD_Frm_Information_EXT; // size must be smaller than HVD_DISP_FRM_INFO_EXT_ST_SIZE
660 
661 typedef struct
662 {
663     MS_BOOL aspect_ratio_info_present_flag;            // u(1)
664     MS_U8 aspect_ratio_idc;                            // u(8)
665     MS_U16 sar_width;                                  // u(16)
666     MS_U16 sar_height;                                 // u(16)
667     MS_BOOL overscan_info_present_flag;                // u(1)
668     MS_BOOL overscan_appropriate_flag;                 // u(1)
669     MS_BOOL video_signal_type_present_flag;            // u(1)
670     MS_U8 video_format;                                // u(3)
671     MS_BOOL video_full_range_flag;                     // u(1)
672     MS_BOOL colour_description_present_flag;           // u(1)
673     MS_U8 colour_primaries;                            // u(8)
674     MS_U8 transfer_characteristics;                    // u(8)
675     MS_U8 matrix_coefficients;                         // u(8)
676     MS_BOOL chroma_location_info_present_flag;         // u(1)
677     MS_U8 chroma_sample_loc_type_top_field;            // ue(v) 0~5
678     MS_U8 chroma_sample_loc_type_bottom_field;         // ue(v) 0~5
679     MS_BOOL timing_info_present_flag;                  // u(1)
680     MS_BOOL fixed_frame_rate_flag;                     // u(1)
681     MS_U32 num_units_in_tick;                          // u(32)
682     MS_U32 time_scale;                                 // u(32)
683 } HVD_AVC_VUI_DISP_INFO;
684 
685 typedef struct
686 {
687     MS_U32 u32FrmrateUpBound;       //Framerate filter upper bound
688     MS_U32 u32FrmrateLowBound;      //Framerate filter lower bound
689     MS_U32 u32MvopUpBound;          //mvop filter upper bound
690     MS_U32 u32MvopLowBound;         //mvop filter lower bound
691 } HVD_DISP_THRESHOLD;
692 
693 typedef struct tDynmcDispPath
694 {
695     MS_U8 u8Connect; //TRUE: connect , FALSE: disconnect
696     /*CTL_DISPLAY_PATH*/
697     MS_U8 u8DispPath;
698     /*DISP_PATH_CONNECT_STATUS*/
699     MS_U8 u8ConnectStatus;
700 } DynmcDispPath;
701 
702 typedef struct
703 {
704     MS_U32  u32Version;
705     MS_U8   u8MatrixCoefficients;
706     MS_U8   u8BitsPerChannel;
707     MS_U8   u8ChromaSubsamplingHorz;
708     MS_U8   u8ChromaSubsamplingVert;
709     MS_U8   u8CbSubsamplingHorz;
710     MS_U8   u8CbSubsamplingVert;
711     MS_U8   u8ChromaSitingHorz;
712     MS_U8   u8ChromaSitingVert;
713     MS_U8   u8ColorRange;
714     MS_U8   u8TransferCharacteristics;
715     MS_U8   u8ColourPrimaries;
716     MS_U8   reserved;
717     MS_U16  u16MaxCLL;          //Max Content Light Level
718     MS_U16  u16MaxFALL;         //Max Frame Average Light Level
719     MS_U16  u16Primaries[3][2];
720     MS_U16  u16WhitePoint[2];
721     MS_U32  u32MaxLuminance;
722     MS_U32  u32MinLuminance;
723 } HVD_Config_VP9HDR10;
724 
725 typedef struct
726 {
727     MS_U8 u8ProfileIdc;
728     MS_U8 u8LevelIdc;
729     union
730     {
731         struct
732         {
733             MS_U16 constraint_set0_flag:1;
734             MS_U16 constraint_set1_flag:1;
735             MS_U16 constraint_set2_flag:1;
736             MS_U16 constraint_set3_flag:1;
737             MS_U16 constraint_set4_flag:1;
738             MS_U16 constraint_set5_flag:1;
739             MS_U16 constraint_set6_flag:1;
740             MS_U16 constraint_set7_flag:1;
741             MS_U16 constraint_set8_flag:1;
742             MS_U16 constraint_set9_flag:1;
743             MS_U16 constraint_reserved_zero_bits1:6;
744         };
745         MS_U16 constraint_set;
746     };
747 } HVD_Extend_Display_Info;                  // 4 Bytes
748 
749 typedef struct
750 {
751     // switch
752     MS_U32 u32CodecType;                //0x0000
753     MS_U32 u32FrameBufAddr;             //0x0004
754     MS_U32 u32FrameBufSize;             //0x0008
755     MS_U32 u32CPUClock;                 //0x000C
756     HVD_Display_Info DispInfo;          //0x0010
757 
758     // FW -> HK
759     // report info
760     //AFD_Info AFDInfo;
761     MS_U32 u32DispSTC;                  //0x002C // Current Display Frame STC
762     MS_U32 u32DecodeCnt;                //0x0030 // Decoded picture count
763     MS_U32 u32DecErrCnt;                //0x0034 // HW decode err or not finish.
764     MS_U32 u32DataErrCnt;               //0x0038 // FW process data error, like SPS, slice header .etc.
765     MS_U16 u16ErrCode;                  //0x003C // Drv/FW error code ; HVD_Err_Code
766     MS_U8  u8FrameMbsOnlyFlag;          //0x003E // frame_mbs_only_flag of AVC SPS.
767     MS_U8  u8ForceBreakCnt;             //0x003F //
768     MS_U32 u32VPUIdleCnt;               //0x0040 // VPU idle count
769     MS_U32 u32FrameRate;                //0x0044 // Input Frame Rate
770     MS_U32 u32FrameRateBase;            //0x0048 // Input Frame Rate Base
771     HVD_Mode_Status ModeStatus;         //0x004C // FW mode
772     HVD_Frm_Information DispFrmInfo;    //0x005C // current displayed frame information.
773     HVD_Frm_Information DecoFrmInfo;    //0x0098 // specified decoded frame information.
774     //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)
775 #if defined(INTERLEAVE_SW_SEEK) || defined(SW_GETBITS) || defined(INTERLEAVE_SW_PARSE)
776     MS_U32 u32BBUReadPtr;
777 #endif
778     // internal control info
779     MS_U8 bInitDone;                    //0x00D4
780     MS_U8 bIs1stFrameRdy;               //0x00D5 // first frame are showed on screen
781     MS_U8 bIsIFrmFound;                 //0x00D6 // 1: First I frame found. 0: fw should set to zero after user cmd, "Flush"
782     MS_U8 bIsSyncStart;                 //0x00D7 // under sync mode, 1: FW start doing sync action. 0: FW freerun or freerun mode.
783     MS_U8 bIsSyncReach;                 //0x00D8 // under sync mode, 1: FW sync reach. 0: FW freerun or sync not reach.
784 
785     //****************************************
786 
787     MS_U8 u8SrcMode;                    //0x00D9
788     MS_U8 bEnableDispQueue;             //0x00DA
789     MS_U8 bEnableDispOutSide;           //0x00DB
790     //****************************************
791     MS_U32 u32FWVersionID;              //0x00DC // FW version ID
792     MS_U32 u32FWIfVersionID;            //0x00E0 // FW IF version ID
793     MS_U32 u32ESWritePtr;               //0x00E4 // the write pointer of bitstream buffer.
794     MS_U16 u16DecQNumb;                 //0x00E8 // current decoded queue total entry number. old oq size
795     MS_U16 u16DispQNumb;                //0x00EA // current display queue total entry number. old Used Size
796     MS_U32 u32PTStableWptrAddr;         //0x00EC // The address of PTS table write pointer.
797     MS_U32 u32PTStableRptrAddr;         //0x00F0 // The address of PTS table read pointer.
798     MS_U32 u32PTStableByteCnt;          //0x00F4 // The value of byte count of TSP. FW update it after init() and flush().
799 
800     // debug info
801     MS_U32 u32SkipCnt;                  //0x00F8 // skipped picture count count by command: E_HVD_DECODE_ALL, E_HVD_DECODE_I, E_HVD_DECODE_IP
802     MS_U32 u32DropCnt;                  //0x00FC // dorpped decoded picture counter by command: drop_auto or drop_once
803     MS_U32 u32CCBase;                   //0x0100 // CC Ring Base Address
804     MS_U32 u32CCSize;                   //0x0104 // CC Ring Size
805     MS_U32 u32CCWrtPtr;                 //0x0108 // CC Ring Write Pointer
806     MS_U32 u32NtscCCBase;               //0x010C // NTSC CC Ring Base Address
807     MS_U32 u32NtscCCSize;               //0x0110 // NTSC CC Ring Size
808     MS_U32 u32NtscCCWrtPtr;             //0x0114 // NTSC CC Ring Write Pointer
809     //****************************************
810     MS_U32 u32CurrentPts;               //0x0118 // only useful when Jump to pts command is activated
811     MS_U32 u32DispCnt;                  //0x011C // Display picture count
812     MS_U32 u32FWBaseAddr;               //0x0120
813     //****************************************
814     MS_U32 u32UserCCBase;               //0x0124 // User CC Base Address
815     MS_U32 u32UserCCIdxWrtPtr;          //0x0128 // User CC Idx Write Pointer
816     MS_U8 u8UserCCIdx[USER_CC_IDX_SIZE];//0x012C // User CC Idx
817     //****************************************
818     MS_U32 u32VirtualBoxWidth;          //0x0138 // Dynamic Scale: DRV -> FW
819     MS_U32 u32VirtualBoxHeight;         //0x013C // Dynamic Scale: DRV -> FW
820     MS_U32 u32SrcWidth;                 //0x0140 // Dynamic Scale: Source Width
821     MS_U32 u32SrcHeight;                //0x0144 // Dynamic Scale: Source Height
822     //****************************************
823     MS_U8 u8DivxProfile;                //0x0148  // see DIVX_PROFILE, E_DIVX_PROFILE_NONE is not a DivX stream
824     //****************************************
825 
826     // -------- AVC info --------
827     //MS_U32 u32AVC_NalCnt;             // Decoded nal count >> change to SRAM
828     MS_U8  u8AVC_SPS_LowDelayHrdFlag;   //0x0149 // VUI low_delay_hrd_flag
829     MS_U16 u16AVC_SPS_LevelIDC;         //0x014A // sps level idc
830     MS_U32 u32AVC_VUIDispInfo_Addr;     //0x014C // VUI Display Info Address
831     //MS_U32 u32AVC_SPS_Addr;           // FW sps structure start address
832 
833     // -------- AVS info --------
834     // .....
835     //MS_U32 u32AVS_xxx;
836 
837     // -------- RM info --------
838     // HK -> FW
839     MS_U8 u8RM_Version;                 //0x0150
840     MS_U8 u8RM_NumSizes;                //0x0151
841     MS_U8 u8BitDepth;                   //0x0152 Bit0~3 Y bitdepth, Bit4~7 UV bitdepth
842     //****************************************
843     MS_U8 reserved8_2;                  //0x0153
844     //****************************************
845     HVD_PictureSize  pRM_PictureSize[HVD_RM_INIT_PICTURE_SIZE_NUMBER];  //0x0154
846     MS_U32 u32RM_VLCTableAddr;          //0x0174
847 
848     // -------- common info --------
849     MS_U32 u32MainLoopCnt;              //0x0178
850     MS_U32 u32VsyncCnt;                 //0x017C
851     HVD_DISP_THRESHOLD DispThreshold;   //0x0180
852     MS_U32 u32ESReadPtr;                //0x0190 // the read pointer of bitstream buffer.
853     MS_U32 u32SeqChangeInfo;            //0x0194
854     MS_S64 s64PtsStcDiff;               //0x0198 // 90Khz
855     MS_U16 u16ChipID;                   //0x01A0 // enum MSTAR_CHIP_ID
856     MS_U16 u16ChipECONum;               //0x01A2 // ECO num of chip
857     MS_U32 u32NextPTS;                  //0x01A4 // ms
858 
859 
860     MS_U16 u16DispQSize;                //0x01A8
861     MS_U16 u16DispQPtr;                 //0x01AA
862     HVD_Frm_Information DispQueue[HVD_DISP_QUEUE_MAX_SIZE];   //0x01AC
863     //----------------------------------------------------------------------
864     MS_U32 u32RealFrameRate;            //0x0B84
865 
866     MS_U8 bSpsChange;                   //0x0B88
867     MS_U8 bEnableDispCtrl;              //0x0B89
868     MS_U8 bIsTrigDisp;                  //0x0B8A
869     MS_U8 bHVDUseTlbMode;               //0x0B8B //0: default to disable TLB , 1: use TLB (HK->FW)
870     MS_U32 u32FwState;                  //0x0B8C
871     MS_U32 u32FwInfo;                   //0x0B90
872     MS_U32 u32IntCount;                 //0x0B94
873 
874     //----------------------------------------------------------------------
875     MS_U16 u16FreeQWtPtr;              //0x0B98
876     MS_U16 u16FreeQRdPtr;              //0x0B9A
877     MS_U32 FreeQueue[HVD_DISP_QUEUE_MAX_SIZE];  //0x0B9C
878 
879     // --------- MVC info (Sub view buffer and 2nd input pointer) ---------
880     HVD_Frm_Information DispFrmInfo_Sub;    //0x0C44  // current displayed Sub frame information.
881     HVD_Frm_Information DecoFrmInfo_Sub;    //0x0C80  // specified decoded Sub frame information.
882     MS_U32 u32ES2WritePtr;              //0x0CBC
883     MS_U32 u32ES2ReadPtr;               //0x0C08
884 
885     // --------- MJPEG share memory ------------------------------------------
886     MS_U32 u32MJPEGFrameBuffIdx;        //0x0CC4 <----LOUIS DONE
887     MS_U32 u32MJPEGTimeStamp;           //0x0CC8
888     MS_U32 u32MJPEGID_L;                //0x0CCC
889     MS_U32 u32MJPEGID_H;                //0x0CD0
890     MS_U32 u32MJPEG_NextFrameBuffIdx;   //0x0CD4
891     MS_U8 u8MJPEG_bStepPlay;            //0x0CD8
892     MS_U8 u8MJPEG_bPlaying;             //0x0CD9
893     MS_U8 u8MJPEG_bIsAVSyncOn;          //0x0CDA
894     MS_U8 u8MJPEG_bIsReachAVSync;       //0x0CDB
895     MS_U8 u8MJPEG_bFlushQueue;          //0x0CDC
896     MS_U8 u8MJPEG_bIsDispFinish;        //0x0CDD
897     MS_U8 u8MJPEG_bQueueFull;           //0x0CDE
898     MS_U8 bIsLeastDispQSize;            //0x0CDF
899 
900     // --------- SEI: frame packing ------------------------------------------
901     MS_U32 u32Frm_packing_arr_data_addr;  //0x0CE0
902 
903     //---------- report 3k/6k for 16/32 Mem-Align DS --------------------------
904     MS_U32 u32DSBuffSize;               //0x0CE4  // Dynamic Scale Buffer Size actually used for different DS Mem Align
905     MS_U8 bDSIsRunning;                 //0x0CE8
906     MS_U8 reserved8_3;                  //0x0CE9
907     MS_U8 reserved8_4;                  //0x0CEA
908     MS_U8 reserved8_5;                  //0x0CEB
909     MS_U8 u8FlushStatus;                //0x0CEC
910     MS_U8 u8DSBufferDepth;              //0x0CED
911 
912     //---------- TemporalScalability -----------------------------------------
913     MS_U8 u8TemporalScalabilty;         //0x0CEE
914     MS_U8 u8MaxTemporalLayer;           //0x0CEF
915 
916     MS_U16 u16DispQWptr[2];             //0x0CF0
917     MS_U8 u8ESBufStatus;                //0x0CF4
918     MS_U8 u8FieldPicFlag;               //0x0CF5
919     MS_U8 u8CMAAllocationStatus;        //0x0CF6
920     MS_U8 u8CMAReleaseStatus;           //0x0CF7
921 
922     // reserved for MJPEG
923     MS_U32 u32MJPEGDbg_DispStatus;      //0x0CF8
924     MS_U8 u8MJPEGDbg_ReadFbIdx;         //0x0CFC
925     MS_U8 u8MJPEGDbg_WriteFbIdx;        //0x0CFD
926     MS_U8 u8MJPEGDbg_SkipRepeat;        //0x0CFE
927     MS_U8 u8MJPEGDbg_reserved8_1;       //0x0CFF
928     MS_U32 u32MJPEGDbg_SysTime;         //0x0D00
929     MS_U32 u32MJPEGDbg_VideoPts;        //0x0D04
930     MS_U32 u32MJPEGDbg_SkipRepeatTime;  //0x0D08
931 
932     MS_U32 u32DSbufferAddr;             //0x0D0C
933     MS_U32 u32DispRepeatCnt;            //0x0D10
934 
935     MS_U32 u32ColocateBBUReadPtr;       //0x0D14 FW->HK
936     MS_U32 u32ColocateBBUWritePtr;      //0x0D18 HK->FW
937     MS_U8  u8BBUMode;                   //0x0D1C  0: driver auto bbu mode, 1: fw auto bbu mode(colocate bbu mode)
938     MS_U8  bUseTSPInBBUMode;            //0x0D1D  0: disable, 1: enable
939     MS_U8  bUseWbMvop;                  //0x0D1E  0: use original MVOP, 1: use WB MVOP (HK->FW)
940     MS_U8  bHVDIMIEnable;               //0x0D1F
941 
942     MS_U32 u32DmxFrameRate;             //0x0D20 // Demuxer Prefered Input Frame Rate
943     MS_U32 u32DmxFrameRateBase;         //0x0D24 // Demuxer Prefered Input Frame Rate Base
944     MS_U32 u32PTSTblRd;                 //0x0D28 // PTS table read ptr
945     MS_U32 u32PTSTblWr;                 //0x0D2C // PTS table write ptr
946     MS_U32 u32PreSetControl;            //0x0D30 // PreSetControl
947     MS_U32 u32IapGnBufAddr;             //0x0D34
948     MS_U32 u32IapGnBufSize;             //0x0D38
949     MS_U32 u32SeamlessTSStatus;         //0x0D3C
950     MS_U32 u32FWStatusFlag;             //0x0D40
951     MS_U32 u32ESBufLevel;               //0x0D44
952     MS_U32 u32ESBuf2Level;              //0x0D48
953     MS_U32 u32FrameBuf2Addr;            //0x0D4C
954     MS_U32 u32FrameBuf2Size;            //0x0D50
955     MS_U8  bCMA_Use;                    //0x0D54
956     MS_U8  bCMA_AllocDone;              //0x0D55
957     MS_U8  bCMA_TwoMIU;                 //0x0D56
958     MS_U8  u8FrmPostProcSupport;        //0x0D57
959     MS_U8  u8PpQueueSize;               //0x0D58
960     MS_U8  u8PpQueueWPtr;               //0x0D59
961     MS_U8  u8PpQueueRPtr;               //0x0D5A
962     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
963     MS_U32 u32DISPQUEUE_EXT_ST_ADDR;    //0x0D5C
964     MS_U64 u64SeamlessTargetPTS;        //0x0D60
965     MS_U32 u32SeamlessTargetPOC;        //0x0D68
966     MS_U32 u32CodecMiscInfo;            //0x0D6C //Bit0: video full range bit
967     MS_U32 u32RDPTR_PTS_LOW;            //0x0D70
968     MS_U32 u32RDPTR_PTS_HIGH;           //0x0D74
969     MS_U32 u32WRPTR_PTS_LOW;            //0x0D78
970     MS_U32 u32WRPTR_PTS_HIGH;           //0x0D7C
971     MS_U32 u32DisplayColourVolume_addr;    //0x0D80
972     MS_U32 u32HVD_DisplayColourVolume_SEI; //0x0D84
973     MS_U32 u32ContentLightLevel_addr;    //0x0D88
974     MS_U32 u32HVD_ContentLightLevel_SEI;    //0x0D8C
975     MS_U32 u32AllocateCMABuffAddr[2];      //0x0D90
976     MS_U32 u32AllocateCMABuffSize[2];      //0x0D98
977     PENDING_RELEASE_QUEUE pending_release_queue[2][2]; //0x0DA0~0x0DD0
978     MS_U32 u32MaxCMAFrameBufSize;          //0x0DD0
979     MS_U32 u32MaxCMAFrameBuf2Size;         //0x0DD4
980     MS_U32 u32DirectStcInMs;               //0x0DD8
981 
982     //vdec plus info
983     MS_U32 u32VdecPlusDecCnt;           //0x0DDC
984     MS_U32 u32VdecPlusDropCnt;          //0x0DE0
985     MS_U32 u32VdecPlusDispPicCnt;       //0x0DE4
986     MS_U8  u8VdecPlusDropRatio;         //0x0DE8
987     MS_U8  u8LowMemMode;                //0x0DE9
988     MS_U8  bIsTSPIn;                    //0x0DEA
989     MS_U8  u8ExternalHeapIdx;           //0x0DEB
990     MS_U8  bUseCorrectVlcAddr;          //0x0DEC
991     MS_U8  bSingleLayer;                //0x0DED
992     MS_U8  u8DVProfileFromDriverAPI;    //0x0DEE
993     MS_U8  u8DVLevelFromDriverAPI;      //0x0DEF
994     DynmcDispPath    stDynmcDispPath;   //0x0DF0
995     MS_U8  u8DolbyMetaReorder;          //0x0DF3
996     MS_U32 u32FrameWrtPtr;              //0x0DF4
997     MS_U32 u32FrameReadPtr;             //0x0DF8
998     MS_U8  u8FrameType[FRAMEQ_SIZE];    //0x0DFC
999     MS_U32 u32DecTimeStamp[FRAMEQ_SIZE];  //0x0E0C
1000     MS_U32 u32NotSupportInfo;           //0x0E4C
1001     MS_U32 u32DolbyVisionXCShmSize;     //0x0E50
1002     MS_U8  u8InputTSP;                  //0x0E54
1003     MS_U8  u8VP9HDR10InfoVaild;         //0x0E55
1004     MS_U8  u8IsDoblyHDR10;              //0x0E56
1005     MS_U8  reserved8_6;                 //0x0E57
1006     MS_U32 u32CurMinTspDataSize;        //0x0E58 //byte
1007     HVD_Config_VP9HDR10 VP9HDR10Info;   //0x0E5C
1008     MS_U32 u32FirstPts_H;               //0x0E88
1009     MS_U32 u32FirstPts_L;               //0x0E8C
1010     HVD_Extend_Display_Info ExtendDispInfo;//0x0E90
1011     MS_U8  bAVCFastFlush;              //0x0E94
1012     MS_U8  reserved8_8[3];            //0x0E95
1013     MS_U8  reserved8_9[0xF9C-0x0E98];   //0x0E98
1014 
1015     MS_U32 u32VDEC_MIU_SEL;             //0x0F9C
1016     MS_U32 u32MaxVideoWidth;            //0x0FA0 // for VDEC3_FB usage
1017     MS_U32 u32MaxVideoHeight;           //0x0FA4 // for VDEC3_FB usage
1018     CMD_QUEUE cmd_queue;                //0x0FA8~0x0FBC DISPCMDQ and normal CMDQ
1019     MS_U32 u32HVD_VBBU_DRAM_ST_ADDR;    //0x0FC0
1020     MS_U32 u32HVD_PTS_TABLE_ST_OFFSET;  //0x0FC4
1021     MS_U32 u32HVD_BBU_DRAM_ST_ADDR;     //0x0FC8
1022     MS_U32 u32HVD_BBU2_DRAM_ST_ADDR;    //0x0FCC
1023     MS_U32 u32HVD_DYNAMIC_SCALING_ADDR; //0x0FD0
1024     MS_U32 u32HVD_SCALER_INFO_ADDR;     //0x0FD4
1025     MS_U32 u32HVD_AVC_DTVINFO;          //0x0FD8
1026     MS_U32 u32HVD_AVC_INFO608;          //0x0FDC
1027     MS_U32 u32HVD_AVC_INFO708;          //0x0FE0
1028     MS_U32 u32HVD_AVC_USERDATA;         //0x0FE4
1029     MS_U32 u32HVD_AVC_FRAME_PACKING_SEI;//0x0FE8
1030     MS_U32 u32HVD_DBG_DUMP_ADDR;        //0x0FEC
1031     MS_U32 u32HVD_DUMMY_WRITE_ADDR;     //0x0FF0
1032     MS_U16 u16EngineClock;              //0x0FF4
1033     MS_U16 u16PPUClock;                 //0x0FF6
1034     MS_U32 u32COMPARE_INFO_ADDR;        //0x0FF8
1035     MS_U32 u32COMPARE_MD5_ADDR;         //0x0FFC
1036 } HVD_ShareMem;
1037 
1038 typedef struct
1039 {
1040     MS_U32 u32LumaAddr0;                 ///< The start offset of luma data. Unit: byte.
1041     MS_U32 u32ChromaAddr0;               ///< The start offset of chroma data. Unit: byte.
1042     MS_U32 u32LumaAddr1;                 ///< The start offset of luma data. Unit: byte.
1043     MS_U32 u32ChromaAddr1;               ///< The start offset of chroma data. Unit: byte.
1044     MS_U32 u32PriData;                   ///< Index for SEC release frame buffer
1045     MS_U32 u32PriData1;                  ///< Index for SEC release frame buffer
1046     MS_U32 u32Status;
1047     MS_U16 u16Pitch;
1048     MS_U16 u16Width;
1049     MS_U16 u16Height;
1050     MS_U16 u16CropLeft;
1051     MS_U16 u16CropRight;
1052     MS_U16 u16CropBottom;
1053     MS_U16 u16CropTop;
1054     MS_U8  u1BottomFieldFirst:1;
1055     MS_U8  u1DSIndex1Valid:1;
1056     MS_U8  u2Reserved:6;
1057     MS_U8  u8FieldType;                 ///< HVD_Field_Type, none, top , bottom, both field
1058     MS_U8  u8Interlace;
1059     MS_U8  u8ColorFormat;               // 0 -> 420, 1 -> 422, 2 -> 420 10 bit
1060     MS_U8  u8FrameNum;                  // if 2, u32LumaAddr1 and u32ChromaAddr1 should be use
1061     MS_U8  u8RangeMapY;                 // for VC1 or 10 BIT frame, 2 bit Y depth
1062     MS_U8  u8RangeMapUV;                // for VC1 or 10 BIT frame, 2 bit UV depth
1063     MS_U8  u8TB_toggle;                 // 0 -> TOP then BOTTOM
1064     MS_U8  u8Tog_Time;
1065     MS_U8  u2Luma0Miu:2;
1066     MS_U8  u2Luma1Miu:2;
1067     MS_U8  u2Chroma0Miu:2;
1068     MS_U8  u2Chroma1Miu:2;
1069     MS_U8  u8FieldCtrl;                 // 0-> Normal, 1->always top, 2->always bot
1070     union {
1071         MS_U8 u8DSIndex;
1072         struct
1073         {
1074             MS_U8 u4DSIndex0:4;
1075             MS_U8 u4DSIndex1:4;         // it is DS index for sFrames[1] (HEVC Dolby EL frame)
1076         };
1077     };
1078     union {
1079         MS_U16 u16Pitch1;               // for 10 BIT, the 2 bit frame buffer pitch
1080         MS_U16 u16DispCnt;              // when this display queue is show finish, record the display conut for debug if frame repeat
1081     };
1082 } DISP_FRM_INFO;
1083 
1084 typedef struct
1085 {
1086     // for vsync bridge dispQ bridge
1087     MS_U8  u8DispQueNum;
1088     MS_U8  u8McuDispSwitch;
1089     MS_U8  u8McuDispQWPtr;
1090     MS_U8  u8McuDispQRPtr;
1091     DISP_FRM_INFO McuDispQueue[MAX_VSYNC_BRIDGE_DISPQ_NUM];
1092     MS_U8  u8DisableFDMask;
1093     MS_U8  u8FdMaskField;
1094     MS_U8  u8ToggledTime;
1095     MS_U8  u8ToggleMethod;
1096     MS_U8  u8Reserve[2];
1097     MS_U8  u5FRCMode:5;
1098     MS_U8  u1FBLMode:1;
1099     MS_U8  u2MirrorMode:2;
1100     MS_U8  u8Reserve2;
1101 } MCU_DISPQ_INFO;
1102 
1103 typedef enum
1104 {
1105     MS_DISP_FRM_INFO_EXT_TYPE_10BIT,
1106     MS_DISP_FRM_INFO_EXT_TYPE_INTERLACE = 1, // interlace bottom 8bit will share the same enum value
1107     MS_DISP_FRM_INFO_EXT_TYPE_DOLBY_EL = 1,  // with dolby enhance layer 8bit
1108     MS_DISP_FRM_INFO_EXT_TYPE_10BIT_INTERLACE = 2, // interlace bottom 2bit will share the same enum
1109     MS_DISP_FRM_INFO_EXT_TYPE_10BIT_DOLBY_EL = 2,  // value with dolby enhance layer 2bit
1110     MS_DISP_FRM_INFO_EXT_TYPE_10BIT_MVC,
1111     MS_DISP_FRM_INFO_EXT_TYPE_DOLBY_MODE = 4,
1112     MS_DISP_FRM_INFO_EXT_TYPE_INTERLACE_MVC = 4,
1113     MS_DISP_FRM_INFO_EXT_TYPE_10BIT_INTERLACE_MVC = 5, // MVC interlace R-View 2bit will share the
1114     MS_DISP_FRM_INFO_EXT_TYPE_DOLBY_META = 5,          // same enum with dolby meta data
1115     MS_DISP_FRM_INFO_EXT_TYPE_MFCBITLEN,
1116     MS_DISP_FRM_INFO_EXT_TYPE_MFCBITLEN_MVC,
1117     MS_DISP_FRM_INFO_EXT_TYPE_MAX,
1118 } DISP_FRM_INFO_EXT_TYPE;
1119 
1120 /****************************************************************************************
1121                                   MFCodecInfo
1122           +---------------------------------------------------------------+
1123           |Uncompress|BitLen Miu Select|  Pitch  |   MFCodec Version      |
1124           |   4 bits |      4 bits     |  8 bits |       16 bits          |
1125           +---------------------------------------------------------------+
1126 ***************************************************************************************/
1127 typedef struct
1128 {
1129     MS_U32 u32LumaAddrExt[MS_DISP_FRM_INFO_EXT_TYPE_MAX];
1130     MS_U32 u32ChromaAddrExt[MS_DISP_FRM_INFO_EXT_TYPE_MAX];
1131     MS_U32 MFCodecInfo;
1132     MS_U16 u16Width;      // the width of second frame
1133     MS_U16 u16Height;     // the height of second frame
1134     MS_U16 u16Pitch[2];   // the pitch of second frame
1135 } DISP_FRM_INFO_EXT;
1136 
1137 typedef struct
1138 {
1139     MS_U8 u8Pattern[4];
1140     MS_U32 u32Version;
1141     MS_U32 u32Debug;
1142     MS_U16 u16VsyncCnt;
1143     MS_U16 u16Debug;
1144     DISP_FRM_INFO_EXT McuDispQueue[MAX_VSYNC_BRIDGE_DISPQ_NUM];
1145 } MCU_DISPQ_INFO_EXT;
1146 
1147 typedef struct
1148 {
1149     MS_U32 u32ByteCnt;
1150     MS_U32 u32PTS;
1151     MS_U32 u32ID_L;
1152     MS_U32 u32ID_H;
1153 } HVD_PTS_Entry;
1154 
1155 // enum
1156 typedef enum
1157 {
1158     E_MSTAR_CHIP_NONE = 0,
1159     E_MSTAR_CHIP_U3,        //remove
1160     E_MSTAR_CHIP_T3,        //remove
1161     E_MSTAR_CHIP_T4,        //remove
1162     E_MSTAR_CHIP_JANUS,     //remove
1163     E_MSTAR_CHIP_U4,        //remove
1164     E_MSTAR_CHIP_T8,        //remove
1165     E_MSTAR_CHIP_T9,        //remove
1166     E_MSTAR_CHIP_M10,       //remove
1167     E_MSTAR_CHIP_T12,       //remove
1168     E_MSTAR_CHIP_T13,       //remove
1169     E_MSTAR_CHIP_J2,        //remove
1170     E_MSTAR_CHIP_K1,
1171     E_MSTAR_CHIP_A1,        //remove
1172     E_MSTAR_CHIP_A5,        //remove
1173     E_MSTAR_CHIP_A7,        //remove
1174     E_MSTAR_CHIP_K2,
1175     E_MSTAR_CHIP_A3,        //remove
1176     E_MSTAR_CHIP_A7P,       //remove
1177     E_MSTAR_CHIP_AGATE,     //remove
1178     E_MSTAR_CHIP_M12,
1179     E_MSTAR_CHIP_EAGLE,
1180     E_MSTAR_CHIP_EMERALD,
1181     E_MSTAR_CHIP_EDISON,
1182     E_MSTAR_CHIP_EIFFEL,
1183     E_MSTAR_CHIP_CEDRIC,
1184     E_MSTAR_CHIP_NUGGET,
1185     E_MSTAR_CHIP_KAISER,
1186     E_MSTAR_CHIP_NIKE,
1187     E_MSTAR_CHIP_KENYA,
1188     E_MSTAR_CHIP_EINSTEIN,
1189     E_MSTAR_CHIP_NIKON,
1190     E_MSTAR_CHIP_NAPOLI,
1191     E_MSTAR_CHIP_MADISON,
1192     E_MSTAR_CHIP_MONACO,
1193     E_MSTAR_CHIP_KERES,
1194     E_MSTAR_CHIP_CLIPPERS,
1195     E_MSTAR_CHIP_MUJI,
1196     E_MSTAR_CHIP_MUNICH,
1197     E_MSTAR_CHIP_MONET,
1198     E_MSTAR_CHIP_MULAN,
1199     E_MSTAR_CHIP_MANHATTAN,
1200     E_MSTAR_CHIP_KRATOS,
1201     E_MSTAR_CHIP_KANO,
1202     E_MSTAR_CHIP_MESSI,
1203     E_MSTAR_CHIP_MILAN,
1204     E_MSTAR_CHIP_MASERATI,
1205     E_MSTAR_CHIP_MACAN,
1206     E_MSTAR_CHIP_KIWI,
1207     E_MSTAR_CHIP_CURRY,
1208     E_MSTAR_CHIP_KAYLA,
1209     E_MSTAR_CHIP_K6,
1210     E_MSTAR_CHIP_MUSTANG,
1211     E_MSTAR_CHIP_MAXIM,
1212     E_MSTAR_CHIP_K6LITE,
1213     E_MSTAR_CHIP_MATISSE,
1214     E_MSTAR_CHIP_MOONEY,
1215     E_MSTAR_CHIP_MARLON,
1216     E_MSTAR_CHIP_K5TN, // Kentucky
1217     E_MSTAR_CHIP_MAINZ,
1218     E_MSTAR_CHIP_OTHER = 0xFF,
1219 } MSTAR_CHIP_ID;
1220 
1221 typedef enum
1222 {
1223     E_HVD_SRC_MODE_DTV = 0,
1224     E_HVD_SRC_MODE_TS_FILE,
1225     E_HVD_SRC_MODE_FILE,
1226     E_HVD_SRC_MODE_TS_FILE_DUAL_ES,
1227     E_HVD_SRC_MODE_FILE_DUAL_ES,
1228 } HVD_SRC_MODE;
1229 
1230 typedef enum
1231 {
1232     E_VDEC_FORCE_8BITS_MASK          = BMASK(0:0),       ///< 8BITS YUV Mode
1233     E_VDEC_FORCE_8BITS_MODE          = BIT(0),
1234     E_VDEC_MFCODEC_MASK              = BMASK(2:1),       ///< MFCodec Mode
1235         E_VDEC_MFCODEC_DEFAULT       = BITS(2:1, 0),     ///< deflaut: 0x00
1236         E_VDEC_MFCODEC_FORCE_ENABLE  = BITS(2:1, 1),     ///< force enable: 0x01
1237         E_VDEC_MFCODEC_FORCE_DISABLE = BITS(2:1, 2),     ///< force disable:0x10
1238     E_VDEC_MFCODEC_UNCOMPRESS_MODE   = BIT(3),
1239     E_VDEC_FORCE_MAIN_PROFILE_MASK = BMASK(4:4),
1240     E_VDEC_FORCE_MAIN_PROFILE   = BIT(4),     // HEVC: Only Support Main profile even this chip support Main10
1241     E_VDEC_DYNAMIC_CMA_MODE     = BIT(5),     // Enable Dynamic CMA mechanism
1242     E_VDEC_TEMPORAL_SCALABILITY_MODE = BIT(6),   //Enable/Disable Temporal Scalability Mode
1243     E_VDEC_DOLBY_VISION_SINGLE_LAYER_MODE = BIT(7)   //Enable/Disable dolby vision single layer Mode
1244 } VDEC_CODEC_FEATURE;
1245 
1246 typedef enum
1247 {
1248     E_HVD_DV_ENABLE_MASK             = BMASK(1:0),       /// Is Dolby vision enable
1249     E_HVD_DV_SINGLE_LAYER_MODE       = BIT(0),
1250     E_HVD_DV_DUAL_LAYER_MODE         = BIT(1),
1251     E_HVD_DV_CURRENT_LAYER           = BIT(2),           /// 1: enhance layer 0: base layer
1252     E_HVD_DV_METADATA_MIUSEL_MASK    = BMASK(4:3),       /// meta data miu select(2bits)
1253         E_HVD_DV_METADATA_MIU0       = BITS(4:3, 0),
1254         E_HVD_DV_METADATA_MIU1       = BITS(4:3, 1),
1255         E_HVD_DV_METADATA_MIU2       = BITS(4:3, 2),
1256 } HVD_DOLBY_VISION_MODE;
1257 
1258 typedef enum
1259 {
1260     E_HVD_Codec_AVC = 0,
1261     E_HVD_Codec_AVS,
1262     E_HVD_Codec_RM,
1263     E_HVD_Codec_MVC,
1264     E_HVD_Codec_VP8,
1265     E_HVD_Codec_MJPEG,
1266     E_HVD_Codec_VP6,
1267     E_HVD_Codec_HEVC,
1268     E_HVD_Codec_VP9,
1269     E_HVD_Codec_HEVC_DV,
1270     E_HVD_Codec_UNKNOWN
1271 } HVD_Codec_Type;
1272 
1273 typedef enum
1274 {
1275     E_HVD_PICT_TYPE_I,
1276     E_HVD_PICT_TYPE_P,
1277     E_HVD_PICT_TYPE_B,
1278 } HVD_Picture_Type;
1279 
1280 typedef enum
1281 {
1282     E_HVD_FIELD_TYPE_NONE = 0,
1283     E_HVD_FIELD_TYPE_TOP,
1284     E_HVD_FIELD_TYPE_BOTTOM,
1285     E_HVD_FIELD_TYPE_BOTH,
1286 } HVD_Field_Type;
1287 
1288 typedef enum
1289 {
1290     EVD_TOP_FIELD = 1,
1291     EVD_BOTTOM_FIELD = 2,
1292     EVD_TOP_BOTTOM_ORDER = 3,
1293     EVD_BOTTOM_TOP_ORDER = 4,
1294     EVD_TOP_WITH_PREV = 9,
1295     EVD_BOTTOM_WITH_PREV = 10,
1296     EVD_TOP_WITH_NEXT = 11,
1297     EVD_BOTTOM_WITH_NEXT = 12,
1298     EVD_UNKNOWN_TYPE = 0xFF,
1299 } HEVC_PIC_STRUCT;
1300 
1301 typedef enum
1302 {
1303     E_HVD_DECODE_ALL,
1304     E_HVD_DECODE_I,
1305     E_HVD_DECODE_IP,
1306 } HVD_Skip_Decode_Type;
1307 
1308 typedef enum
1309 {
1310     E_HVD_CMA_ALLOCATION_NONE,
1311     E_HVD_CMA_ALLOCATION_WAITING,
1312     E_HVD_CMA_ALLOCATION_DONE,
1313     E_HVD_CMA_ALLOCATION_FAILED,
1314 } HVD_CMA_Allocation_Status;
1315 
1316 typedef enum
1317 {
1318     E_HVD_CMA_RELEASE_NONE,
1319     E_HVD_CMA_RELEASE_WAITING,
1320     E_HVD_CMA_RELEASE_DONE,
1321 } HVD_CMA_Release_Status;
1322 
1323 typedef enum
1324 {
1325     E_HVD_DROP_DISP_AUTO = (1<<0),
1326     E_HVD_DROP_DISP_ONCE = (1<<1),
1327 } HVD_Drop_Disp_Type;
1328 
1329 typedef enum
1330 {
1331     E_HVD_FRC_NORMAL = 0,
1332     E_HVD_FRC_32PULLDOWN,               //3:2 pulldown mode (ex. 24p a 60i or 60p)
1333     E_HVD_FRC_PAL2NTSC ,                //PALaNTSC conversion (50i a 60i)
1334     E_HVD_FRC_NTSC2PAL,                 //NTSCaPAL conversion (60i a 50i)
1335     E_HVD_FRC_DISP_2X,                  //output rate is twice of input rate (ex. 30p a 60p)
1336     E_HVD_FRC_24_50,                    //output rate 24P->50P 48I->50I
1337     E_HVD_FRC_50P_60P,                  //output rate 50P ->60P
1338     E_HVD_FRC_60P_50P,                  //output rate 60P ->50P
1339     E_HVD_FRC_HALF_I,                   //output rate 120i -> 60i, 100i -> 50i
1340     E_HVD_FRC_120I_50I,                 //output rate 120i -> 60i
1341     E_HVD_FRC_100I_60I,                 //output rate 100i -> 60i
1342     E_HVD_FRC_DISP_4X,                  //output rate is four times of input rate (ex. 15P a 60P)
1343     E_HVD_FRC_15_50,                    //output rate 15P->50P, 30i -> 50i
1344     E_HVD_FRC_30_50,                    //output rate  30p->50p, 60i->50i
1345     E_HVD_FRC_30_24,                    //output rate 30p->24p, 60i->24i
1346     E_HVD_FRC_60_24,                    //output rate 60p->24p, 120i -> 24i
1347     E_HVD_FRC_60_25,                    //output rate 60p->25p , 120i -> 50i
1348     E_HVD_FRC_HALF_P,                   //output rate 60p-> 30p, 50p -> 25p
1349     E_HVD_FRC_25_30,                    //output rate 25p->30p , 50 i-> 30i
1350     E_HVD_FRC_50_30,                    //output rate 25p->30p ,  100i -> 30i
1351     E_HVD_FRC_24_30,                    //output rate 24p->30p , 48i -> 30i
1352 } HVD_FRC_Mode;
1353 
1354 typedef enum
1355 {
1356     E_HVD_FRC_DROP_FRAME = 0,
1357     E_HVD_FRC_DROP_FIELD = 1,
1358 } HVD_FRC_Drop_Mode;
1359 
1360 typedef enum
1361 {
1362     E_HVD_DISP_SPEED_F_32X = 32,
1363     E_HVD_DISP_SPEED_F_16X = 16,
1364     E_HVD_DISP_SPEED_F_8X = 8,
1365     E_HVD_DISP_SPEED_F_4X = 4,
1366     E_HVD_DISP_SPEED_F_2X = 2,
1367     E_HVD_DISP_SPEED_1X = 1,
1368     E_HVD_DISP_SPEED_S_2X = -2,
1369     E_HVD_DISP_SPEED_S_4X = -4,
1370     E_HVD_DISP_SPEED_S_8X = -8,
1371     E_HVD_DISP_SPEED_S_16X = -16,
1372     E_HVD_DISP_SPEED_S_32X = -32,
1373 } HVD_Disp_Speed;
1374 
1375 typedef enum
1376 {
1377     E_HVD_SYNC_TBL_TYPE_NON,
1378     E_HVD_SYNC_TBL_TYPE_PTS,
1379     E_HVD_SYNC_TBL_TYPE_DTS,
1380     E_HVD_SYNC_TBL_TYPE_STS,            //Sorted TimeStamp
1381 } HVD_Sync_Tbl_Type;                    //only for file mode. Ts , ts file mode always has PTS table
1382 
1383 typedef enum
1384 {
1385     E_HVD_FIELD_CTRL_OFF=0,
1386     E_HVD_FIELD_CTRL_TOP,       // Always Show Top Field
1387     E_HVD_FIELD_CTRL_BOTTOM,    // Always Show Bottom Field
1388 } HVD_Field_Ctrl;
1389 
1390 typedef enum
1391 {
1392     E_HVD_BURST_CNT_LV0 = 0,  // U3,T3:32 cycle  T4~U4: 16 cycle
1393     E_HVD_BURST_CNT_LV1 = 1,  // U3,T3:64 cycle  T4~U4: 32 cycle
1394     E_HVD_BURST_CNT_LV2 = 2,  // U3,T3:96 cycle  T4~U4: 48 cycle
1395     E_HVD_BURST_CNT_LV3 = 3,  // U3,T3:128 cycle  T4~U4: 64 cycle
1396     E_HVD_BURST_CNT_LV4 = 4,  // U3,T3:160 cycle  T4~U4: 80 cycle
1397     E_HVD_BURST_CNT_LV5 = 5,  // U3,T3:192 cycle  T4~U4: 96 cycle
1398     E_HVD_BURST_CNT_LV6 = 6,  // U3,T3:224 cycle  T4~U4: 112 cycle
1399     E_HVD_BURST_CNT_LV7 = 7,  // U3,T3:256 cycle  T4~U4: 128 cycle
1400     E_HVD_BURST_CNT_DISABLE = 0xFFFFFFFF,
1401 } HVD_MIU_Burst_Cnt_Ctrl;
1402 
1403 typedef enum
1404 {
1405     E_HVD_DISPQ_STATUS_NONE = 0,            //FW
1406     E_HVD_DISPQ_STATUS_INIT,                //FW
1407     E_HVD_DISPQ_STATUS_VIEW,                //HK
1408     E_HVD_DISPQ_STATUS_DISP,                //HK
1409     E_HVD_DISPQ_STATUS_FREE,                //HK
1410 } HVD_DISPQ_STATUS;
1411 
1412 typedef enum
1413 {
1414     E_HVD_EX_DV_STREAM_PROFILE_ID_DVAV_PER    = 0x1,
1415     E_HVD_EX_DV_STREAM_PROFILE_ID_DVAV_PEN    = 0x2,
1416     E_HVD_EX_DV_STREAM_PROFILE_ID_DVHE_DER    = 0x4,
1417     E_HVD_EX_DV_STREAM_PROFILE_ID_DVHE_DEN    = 0x8,
1418     E_HVD_EX_DV_STREAM_PROFILE_ID_DVHE_DTR    = 0x10,
1419     E_HVD_EX_DV_STREAM_PROFILE_ID_DVHE_STN    = 0x20,
1420     E_HVD_EX_DV_STREAM_PROFILE_ID_DVHE_DTH    = 0x40,
1421     E_HVD_EX_DV_STREAM_PROFILE_ID_UNSUPPORTED = 0x0,
1422 } HVD_EX_DV_Stream_Profile;
1423 
1424 typedef enum
1425 {
1426     E_HVD_EX_DV_META_REORDER_DEFAULT,
1427     E_HVD_EX_DV_META_REORDER_FOLLOW_BL,
1428     E_HVD_EX_DV_META_REORDER_FOLLOW_EL,
1429 } HVD_EX_DV_Metadata_Reorder;
1430 
1431 typedef enum
1432 {
1433     E_HVD_EX_DV_STREAM_LEVEL_ID_HD24 = 0,
1434     E_HVD_EX_DV_STREAM_LEVEL_ID_HD30,
1435     E_HVD_EX_DV_STREAM_LEVEL_ID_FHD24,
1436     E_HVD_EX_DV_STREAM_LEVEL_ID_FHD30,
1437     E_HVD_EX_DV_STREAM_LEVEL_ID_FHD60,
1438     E_HVD_EX_DV_STREAM_LEVEL_ID_UHD24,
1439     E_HVD_EX_DV_STREAM_LEVEL_ID_UHD30,
1440     E_HVD_EX_DV_STREAM_LEVEL_ID_UHD48,
1441     E_HVD_EX_DV_STREAM_LEVEL_ID_UHD60,
1442     E_HVD_EX_DV_STREAM_LEVEL_ID_UNSUPPORTED,
1443 } HVD_EX_DV_Stream_Highest_Level;
1444 
1445 typedef enum
1446 {
1447     E_HVD_DECODER_FREQUENCY_DOWN = 0, // Scale decoder frequency down
1448     E_HVD_DECODER_FREQUENCY_UP,       // Scale decoder frequency up
1449     E_HVD_DECODER_FREQUENCY_MIN,      // Scale decoder frequency to minimum
1450     E_HVD_DECODER_FREQUENCY_MAX,      // Scale decoder frequency to maximum
1451 } HVD_Decoder_Frequency;
1452 
1453 typedef enum
1454 {
1455     // invalid cmd
1456     E_HVD_CMD_INVALID_CMD = 0xFFFFFFFFUL,
1457 
1458     // SVD old cmd
1459     E_HVD_CMD_SVD_BASE = 0x00010000,
1460     /*0x10001*/E_HVD_CMD_PARSER_BYPASS,             // 1 : on :for raw file mode; AVCHVD_CMD_PARSER_BYPASS ; 0: off: TS file mode and live stream
1461     /*0x10002*/E_HVD_CMD_BBU_RESIZE,                // svd only;  AVCHVD_CMD_BBU_SIZE
1462     /*0x10003*/E_HVD_CMD_FRAME_BUF_RESIZE,          // svd only; AVCHVD_CMD_RESIZE_MEM
1463     /*0x10004*/E_HVD_CMD_IGNORE_ERR_REF,            // 1: ignore ref error, 0: enable ref error handle; AVCHVD_CMD_IGNORE_LIST + AVCHVD_CMD_OPEN_GOP
1464     /*0x10005*/E_HVD_CMD_ES_FULL_STOP,              // ES auto stop: 1: AVCHVD_CMD_ES_STOP; ES not stop 0: AVCHVD_CMD_HANDSHAKE
1465     /*0x10006*/E_HVD_CMD_DROP_DISP_AUTO,            // 1:on AVCHVD_CMD_DISP_DROP, 0:off AVCHVD_CMD_DIS_DISP_DROP
1466     /*0x10007*/E_HVD_CMD_DROP_DISP_ONCE,            // AVCHVD_CMD_DROP_CNT
1467     /*0x10008*/E_HVD_CMD_FLUSH_DEC_Q,               // AVCHVD_CMD_FLUSH_QUEUE
1468 
1469     // HVD new cmd
1470     E_HVD_CMD_NEW_BASE = 0x00020000,
1471     // Action
1472     E_HVD_CMD_TYPE_ACTION_MASK = (0x0100|E_HVD_CMD_NEW_BASE),
1473 
1474     // state machine action
1475     /*0x20101*/E_HVD_CMD_INIT ,                     // Init FW type: E_HVD_Codec_AVC ; E_HVD_Codec_AVS;  E_HVD_Codec_RM
1476     /*0x20102*/E_HVD_CMD_PLAY,                      // AVCHVD_CMD_GO
1477     /*0x20103*/E_HVD_CMD_PAUSE,                     // AVCHVD_CMD_PAUSE
1478     /*0x20104*/E_HVD_CMD_STOP,                      // AVCHVD_CMD_STOP
1479     // run-time action
1480     /*0x20105*/E_HVD_CMD_STEP_DECODE,               // AVCHVD_CMD_STEP
1481     /*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
1482     /*0x20107*/E_HVD_CMD_BLUE_SCREEN,               // only for AVC. remove auto blue screen before show first frame on screen
1483     /*0x20108*/E_HVD_CMD_RESET_PTS,                 // reset PTS table for TS file mode. AVCHVD_CMD_RE_SYNC
1484     /*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
1485     /*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.
1486     /*0x2010B*/E_HVD_CMD_SYNC_TOLERANCE,            // Arg: any not zero number(unit: 90kHz). AVCHVD_CMD_SLOW_SYNC
1487     /*0x2010C*/E_HVD_CMD_SYNC_VIDEO_DELAY,          // Arg: 0~MAX_VIDEO_DELAY(unit: 90kHz): use Arg of video delay. AVCHVD_CMD_AVSYNC
1488     /*0x2010D*/E_HVD_CMD_DISP_ONE_FIELD,            // for AVS, AVC only, Arg: HVD_Field_Ctrl. AVCH264_CMD_ONE_FIELD
1489     /*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.
1490     /*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.
1491     /*0x20110*/E_HVD_CMD_SYNC_THRESHOLD,            // Arg: 0x01~0xFF , frame repeat time. If arg == 0xFF, fw will always repeat last frame when PTS > STC.
1492     /*0x20111*/E_HVD_CMD_FREERUN_THRESHOLD,         // Arg: (unit: 90KHz) 0: use default 5 sec (90000 x 5).
1493     /*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.
1494     /*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)
1495                                                     // Arg: 2; Force interlace support DTV and TS file mode with framerate 25 or 30,but only works on 1080P (width large less 1920)
1496                                                     // Arg: 3; Force interlace support DTV and TS file mode with framerate 23 to 30 and all resolution.
1497                                                     // Arg: 4; Force interlace support DTV and TS file mode with under 30 fps and all resolution.
1498                                                     // Arg: 5; Force interlace support DTV and TS file mode with with framerate 25 or 30 (under FHD and width large less 720)
1499                                                     // Arg: 6: Force interlace support all mode with under all fps and all resolution.
1500     /*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
1501     /*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;
1502     /*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.
1503 
1504     // internal control action
1505 
1506     // FW settings ( only for driver init)
1507     E_HVD_CMD_SETTINGS_MASK = (0x0200|E_HVD_CMD_NEW_BASE),
1508     /*0x20201*/E_HVD_CMD_PITCH,                     // Arg:any non-zero number. AVCHVD_CMD_PITCH_1952, AVCHVD_CMD_PITCH_1984
1509     /*0x20202*/E_HVD_CMD_SYNC_EACH_FRM,             // 1: TS file mode: on ; 0: live mode: off AVCHVD_CMD_SYNC
1510     /*0x20203*/E_HVD_CMD_MAX_DEC_TICK,              // 0: off ; not 0 : in fw.h  new value AVCHVD_CMD_MAXT
1511     /*0x20204*/E_HVD_CMD_AUTO_FREE_ES,              // 1: on ; 0: off ; for live stream only AVCHVD_CMD_AUTO_FREE
1512     /*0x20205*/E_HVD_CMD_DIS_VDEAD,                 // 1: on :For PVR , file mode only ; 0 : off: AVCHVD_CMD_DIS_VDEAD
1513     /*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
1514     /*0x20207*/E_HVD_CMD_SYNC_TYPE,                 // Arg: HVD_Sync_Tbl_Type. //only for file mode. Ts , ts file mode always has PTS table
1515     /*0x20208*/E_HVD_CMD_TIME_UNIT_TYPE,            // Set Time unit: 0: 90Khz, 1: 1ms
1516     /*0x20209*/E_HVD_CMD_ISR_TYPE,                  // Add ISR trigger timing.
1517     /*0x2020A*/E_HVD_CMD_DYNAMIC_SCALE,             // 0: disable; 1: enable
1518     /*0x2020B*/E_HVD_CMD_SCALER_INFO_NOTIFY,
1519     /*0x2020C*/E_HVD_CMD_MIU_BURST_CNT,             // Arg 0~7 burst cnt level , 0xFFFFFFFF = Disable
1520     /*0x2020D*/E_HVD_CMD_FDMASK_DELAY_CNT,          // Arg: 0~0xFF, Fdmask delay count, arg >= 0xFF -> use default.
1521     /*0x2020E*/E_HVD_CMD_FRC_OUTPUT_FRAMERATE,      // unit: vsync cnt
1522     /*0x2020F*/E_HVD_CMD_FRC_OUTPUT_INTERLACE,      // 0: progressive; 1: interlace
1523     /*0x20210*/E_HVD_CMD_ENABLE_DISP_QUEUE,         // 0: Disable; 1:Enable
1524     /*0x20211*/E_HVD_CMD_FORCE_DTV_SPEC,            // 0: Disable; 1:Enable, Force to follow H264 DTV Spec, if res>720p && framerate>50, force progessive
1525                                                        // 2: Disable, if frame_mbs_only_flag == TRUE, it's progressive.
1526     /*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
1527                                                     // 0x02: FPA CallBack, 0x04: ATSC_CC_RAW mode
1528     /*0x20213*/E_HVD_CMD_ENABLE_DISP_OUTSIDE,       // 0: Disable; 1:Enable
1529     /*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,
1530     /*0x20215*/E_HVD_CMD_ENABLE_NEW_SLOW_MOTION,    // Arg: 0: Disable New Slow Motion, 1: Enable New Slow Motion.
1531     /*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.
1532     /*0x20217*/E_HVD_CMD_PUSH_DISPQ_WITH_REF_NUM,   // Arg: 0: Disable; 1:Enable
1533     /*0x20218*/E_HVD_CMD_GET_MORE_FRM_BUF,          // Arg: 0: Disable; 1:Enable. If buffer size is enough, intial more frame buffer to use.
1534     /*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
1535     /*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
1536     /*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.
1537     /*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.
1538     /*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.
1539     /*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
1540     /*0x2021F*/E_HVD_CMD_RETURN_INVALID_AFD,        // Arg, 0: Disable, 1:enable, return 0 when AFD is invalid
1541                                                     // Arg, 2: Enable, return 0 when AFD is invalid at I frame. (GOP)
1542     /*0x20220*/E_HVD_CMD_AVC_FORCE_BROKEN_BY_US,    // Arg, 0: Disable, 1:enable, force enable broken by us mode, FW does not need it anymore.
1543     /*0x20221*/E_HVD_CMD_EXTERNAL_DS_BUF,           // Arg, 0: Disable, 1:Enable.
1544     /*0x20222*/E_HVD_CMD_SHOW_FIRST_FRAME_DIRECT,   // Arg: 0: Disable; 1:Enable. Push first I frame to display queue directly..
1545     /*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
1546     /*0x20224*/E_HVD_CMD_SET_MIN_TSP_DATA_SIZE,         //Arg: Resize HVD_FW_AVC_ES_MIN_TSP_DATA_SIZE
1547     /*0x20225*/E_HVD_CMD_DYNAMIC_SCALE_ENHANCE_SETTINGS,    //Arg: 0:None, 1:MHP,...
1548     /*0x20226*/E_HVD_CMD_ONE_PENDING_BUFFER_MODE,   // Arg: 0: Disable; 1:Enable. Use only one pending buffer instead of two.
1549     /*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
1550     /*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
1551     /*0x20229*/E_HVD_CMD_SET_DISP_ERROR_TOLERANCE,   // Arg: //[15:8]+[7:0] = (err_tolerance(0%~100%)+enable or disable)
1552     /*0x2022A*/E_HVD_CMD_SET_PTS_US_MODE,            // Arg: //0: Disable; 1:Enable. return micro seconds PTS in PTS mode
1553     /*0x2022B*/E_HVD_CMD_SET_HDR_XC_SHM_ADDR,         // Arg, address for dolby vision xc DM/composer shm
1554 
1555     // Mode ( for AP run-time)
1556     E_HVD_CMD_MODE_MASK = (0x0300|E_HVD_CMD_NEW_BASE),
1557     /*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
1558     /*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
1559     /*0x20303*/E_HVD_CMD_DISP_ERR_FRM,              // True: display and error frame; FALSE: not show error frame ; AVCHVD_CMD_ERR_TH
1560     /*0x20304*/E_HVD_CMD_ERR_CONCEAL,               // 1: on ; 0: off ; AVCHVD_CMD_PASTE
1561     /*0x20305*/E_HVD_CMD_REPEAT_LAST_FIELD,         // 1: ON ; 0: OFF
1562     /*0x20306*/E_HVD_CMD_FRC_MODE,                  // Arg:HVD_FRC_Mode. AVCHVD_CMD_FRAME_CVT
1563     /*0x20307*/E_HVD_CMD_SYNC_ACTIVE,               // Arg: 0: sync off. AVCHVD_CMD_FREE_RUN ;  1: sync on. AVCHVD_CMD_AVSYNC
1564     /*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.
1565     /*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.
1566     /*0x2030A*/E_HVD_CMD_POWER_SAVING,              // Arg: 0: Power Saving Off, 1: Power Saving On
1567     /*0x2030B*/E_HVD_CMD_DIS_DBF,                   // Disable deblock, Arg: 0: off, 1: disable all frame, 2: only disable non-ref frame
1568     /*0x2030C*/E_HVD_CMD_DIS_QUART_PIXEL,           // Disable quarter pixel, Arg: 0: off, 1: disable for all frame, 2: only dsiable non-ref frame
1569     /*0x2030D*/E_HVD_CMD_DPO_CC,                    // Display Order User Data Command, Arg: 0: off, 1: on.
1570     /*0x2030E*/E_HVD_CMD_DISP_I_DIRECT,             // Display I directly, Arg: 0: off, 1: on
1571     /*0x2030F*/E_HVD_CMD_FORCE_RESET_HW,            // Arg, 0:disable, 1:enable. Force reset hw when frame start
1572     /*0x20310*/E_HVD_CMD_UPDATE_DISP_THRESHOLD,     // Arg, none
1573     /*0x20311*/E_HVD_CMD_FRC_DROP_MODE,             // Arg, E_HVD_FRC_DROP_FRAME (0), E_HVD_FRC_DROP_FIELD (1)
1574     /*0x20312*/E_HVD_CMD_UPDATE_DISPQ,              // Arg, none. Update Frame Status in Display Queue
1575     /*0x20313*/E_HVD_CMD_SHOW_DECODE_ORDER,         // Arg, 0:disable, 1:enable. Show decoder order or display order
1576     /*0x20314*/E_HVD_CMD_3DLR_VIEW_EXCHANGE,        // Arg, 0: off, do not thing. 1: on, exchange the L/R views
1577     /*0x20315*/E_HVD_CMD_DISP_IGNORE_CROP,          // Arg, 0:disable, 1:enable. Ignore crop information when set V-sync to display
1578     /*0x20316*/E_HVD_CMD_STOP_MVD_PARSER,           // Arg, 1:stop mvd parser
1579     /*0x20317*/E_HVD_CMD_SUSPEND_DYNAMIC_SCALE,     // Arg, 0:disable, 1:enable. Suspend dynamic scale and raise interrupt.
1580     /*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.
1581     /*0x20319*/E_HVD_CMD_IGNORE_PIC_OVERRUN,        // Arg, 0:disable, 1:enable. Ignore hw error: PIC overrun error.
1582     /*0x2031A*/E_HVD_CMD_RVU_SETTING_MODE,          // Arg, 0:disable, 1:Drop B frame and force IDR.
1583     /*0x2031B*/E_HVD_CMD_RELEASE_DISPQ,             // Arg, none. Unlock frame status.
1584     /*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.
1585     /*0x2031D*/E_HVD_CMD_IGNORE_PIC_STRUCT_DISPLAY, // Arg, 0:disable, 1:Ignore Pic_struct when display progressive frame.
1586     /*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)
1587     /*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%.
1588     /*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)
1589     /*0x20321*/E_HVD_CMD_USE_CPB_REMOVAL_DEALY,     // Arg, 0:disable, 1:enable. Use Cpb_Removal_Delay of Picture timing SEI to control PTS.
1590     /*0x20322*/E_HVD_CMD_SKIP_N_FRAME,              // Arg, 0:disable, N = 1~63. Skip N frame.
1591     /*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
1592     /*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.
1593     /*0x20325*/E_HVD_CMD_INC_DISPQ_NUM,             // Arg, none. Increase DispQ Num (SW detile case)
1594     /*0x20326*/E_HVD_CMD_THUMBNAIL_MODE,            // Arg, 0:disable, 1:enable. Use small frame buffer to decode thumbnail
1595     /*0x20327*/E_HVD_CMD_CMA_FRMBUFF_ALLOCATE_STATUS,
1596     /*0x20328*/E_HVD_CMD_CMA_FRMBUFF_RELEASE_STATUS,
1597     /*0x20329*/E_HVD_CMD_FRC_ONLY_SHOW_TOP_FIELD,   // Arg, 0:disable, 1:enable. only show top filed for FRC mode
1598     /*0x2032A*/E_HVD_CMD_DIRECT_STC_MODE,           // Arg, 0:disable, 1:enable. vdec fw use g_shm->u32DirectStcInMs as stc
1599     /*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.
1600     /*0x2032C*/E_HVD_CMD_SET_ENABLE_HDR,            // Arg, 0:disable, 1:enable. Suspend HDR decode/transfer HDR data.
1601     /*0x2032D*/E_HVD_CMD_DYNAMIC_CONNECT_DISP_PATH, // Arg, bit[0]: connect/disconnect, bit[4:1]: display path, [31:5]: reserved.
1602     /*0x2032E*/E_HVD_CMD_AVSYNC_DISP_AUTO_DROP,     // Arg, 0:disable, 1:enable.
1603     /*0x2032F*/E_HVD_CMD_SET_SLOW_SYNC,                  // Arg, bits[31:16]: reserved, bits[15:8]: slow repeat frequency (0: disable slow repeat), bits[7:0]: slow drop frequency (0: disable slow drop).
1604     /*0x20330*/E_HVD_CMD_ENABLE_QOS_INFO,           // Arg, 0:disable, 1:enable. report qos info
1605     /*0x20331*/E_HVD_CMD_ADJUST_DECODER_FREQUENCY,  // HVD_Decoder_Frequency;  E_HVD_DECODER_FREQUENCY_DOWN, E_HVD_DECODER_FREQUENCY_UP, E_HVD_DECODER_FREQUENCY_MAX, E_HVD_DECODER_FREQUENCY_MIN
1606 
1607     // test cmd
1608     E_HVD_CMD_TEST_MASK = (0x0400|E_HVD_CMD_NEW_BASE),
1609     /*0x20401*/E_HVD_CMD_INIT_STREAM,               // Initialize this stream
1610     /*0x20402*/E_HVD_CMD_RELEASE_STREAM,            // Release this stream
1611 
1612     // HVD new cmd Max
1613     E_HVD_CMD_NEW_MAX = (0xFFFF|E_HVD_CMD_NEW_BASE),
1614 
1615 
1616     // Dual Stream Command
1617     E_DUAL_CMD_BASE = 0x00030000,             // pass the DRAM offset from argument
1618 
1619     E_DUAL_CMD_MODE_MASK = (0x0100|E_DUAL_CMD_BASE),
1620     /*0x30101*/E_DUAL_CMD_TASK0_HVD_TSP,
1621     /*0x30102*/E_DUAL_CMD_TASK0_HVD_BBU,
1622     /*0x30103*/E_DUAL_CMD_TASK0_MVD_TSP,
1623     /*0x30104*/E_DUAL_CMD_TASK0_MVD_SLQ,
1624 
1625     /*0x30105*/E_DUAL_CMD_TASK1_HVD_TSP,
1626     /*0x30106*/E_DUAL_CMD_TASK1_HVD_BBU,
1627     /*0x30107*/E_DUAL_CMD_TASK1_MVD_TSP,
1628     /*0x30108*/E_DUAL_CMD_TASK1_MVD_SLQ,
1629 
1630     /*0x30109*/E_DUAL_CMD_SINGLE_TASK,      //argument: 0:multi(default) 1:single // first cmd
1631 
1632     /*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
1633                                             //          5:switch target STC , main view sync sub stc and sub view sync main stc //first cmd
1634 
1635     /*0x3010B*/E_DUAL_BURST_MODE,           //argument: 0:normal(default) 1:burst command to controller(lots of cmd)
1636 
1637     /*0x3010C*/E_DUAL_VERSION,              //argument: 0:controller 1:mvd fw 2:hvd fw 3:mvd interface 4:hvd interface
1638     /*0x3010D*/E_DUAL_R2_CMD_EXIT,          //for WIN32 testing and let R2 FW return directly.
1639     /*0x3010E*/E_DUAL_R2_CMD_FBADDR,        //frame buffer address
1640     /*0x3010F*/E_DUAL_R2_CMD_FBSIZE,        //frame buffer size
1641     /*0x30110*/E_DUAL_R2_CMD_FB2ADDR,       //frame buffer2 address
1642     /*0x30111*/E_DUAL_R2_CMD_FB2SIZE,       //frame buffer2 size
1643     /*0x30112*/E_DUAL_CMD_COMMON,           //argument: 0:dymanic fb management
1644     /*0x30113*/E_DUAL_CMD_STC_MODE,         //set STC index
1645     E_DUAL_CMD_CTL_MASK = (0x0200|E_DUAL_CMD_BASE), // argument is the id : 0 or 1
1646     /*0x30201*/E_DUAL_CMD_DEL_TASK,
1647 
1648     // Dual Stream cmd Max
1649     E_DUAL_CMD_MAX = (0xFFFF|E_DUAL_CMD_BASE),
1650 
1651     // N Stream Command
1652     E_NST_CMD_BASE = 0x00040000,  // pass the DRAM offset from argument
1653 
1654     E_NST_CMD_MODE_MASK = (0x0100|E_NST_CMD_BASE),
1655 #ifdef VDEC3
1656     /*0x40101*/E_NST_CMD_TASK_HVD_TSP,
1657     /*0x40102*/E_NST_CMD_TASK_HVD_BBU,
1658     /*0x40103*/E_NST_CMD_TASK_MVD_TSP,
1659     /*0x40104*/E_NST_CMD_TASK_MVD_SLQ,
1660 #endif
1661 
1662     E_NST_CMD_CTL_MASK = (0x0200|E_NST_CMD_BASE),  // argument is the id : 0 ,1 or 2
1663     /*0x40201*/E_NST_CMD_DEL_TASK,
1664 
1665     E_NST_CMD_COMMON_MASK = (0x0300|E_NST_CMD_BASE),
1666     /*0x40301*/E_NST_CMD_COMMON_CMD1,
1667     /*0x40302*/E_NST_CMD_COMMON_CMD2,
1668 
1669     // N Stream cmd Max
1670     E_NST_CMD_MAX = (0xFFFF|E_NST_CMD_BASE),
1671 
1672     // CMD MASK
1673     E_CMD_MASK = 0x00FFFFFF,
1674 
1675     // TASK ID MASK
1676     E_ID_CMD_MASK = 0xFF000000,
1677 
1678 } HVD_User_Cmd;
1679 
1680 #define E_HVD_CMD_SET_DV_XC_SHM_ADDR E_HVD_CMD_SET_HDR_XC_SHM_ADDR
1681 
1682 // Command
1683 typedef enum
1684 {
1685     // Invalid cmd
1686     E_JPD_CMD_INVALID                        = 0xffffffffUL,
1687 
1688     E_JPD_CMD_GO                             = 0x00, // Start to show
1689     E_JPD_CMD_SET_FRAME_BUFF_START_ADDR      = 0x01, // Set frame buffer address
1690     E_JPD_CMD_SET_FRAME_BUFF_UNIT_SIZE       = 0x02, // Set frame buffer size
1691     E_JPD_CMD_SET_FRAME_BUFF_TOTAL_NUM       = 0x03, // Set total number of frame buffer
1692     E_JPD_CMD_SET_FRAME_BUFF_IDX             = 0x04, // Set frame buffer index
1693     E_JPD_CMD_SET_FRAME_BUFF_IDX_READY       = 0x05, // Set frame buffer index ready for display
1694     E_JPD_CMD_SET_WIDTH                      = 0x06, // Set frame width
1695     E_JPD_CMD_SET_HEIGHT                     = 0x07, // Set frame height
1696     E_JPD_CMD_SET_PITCH                      = 0x08, // Set pitch
1697     E_JPD_CMD_SET_FRAME_ID_L                 = 0x09, // Set frame ID_L
1698     E_JPD_CMD_SET_FRAME_ID_H                 = 0x0A, // Set frame ID_H
1699     E_JPD_CMD_SET_TIMESTAMP                  = 0x0B, // Set Time Stamp
1700     E_JPD_CMD_SET_FRAMERATE                  = 0x0C, // Set FrameRate
1701     E_JPD_CMD_SET_FRAMERATE_BASE             = 0x0D, // Set FrameRate Base
1702     E_JPD_CMD_SET_FRAME_BUFF_IDX_VALID       = 0x0E, // Set frame buffer index available
1703     E_JPD_CMD_SET_CHIP_ID                    = 0x0F, // Set Chip ID
1704 
1705     E_JPD_CMD_PLAY                           = 0x20, // Play
1706     E_JPD_CMD_PAUSE                          = 0x21, // Pause
1707     E_JPD_CMD_RESUME                         = 0x22, // Resume
1708     E_JPD_CMD_STEP_PLAY                      = 0x23, // Step play
1709     E_JPD_CMD_SET_SPEED_TYPE                 = 0x24, // Set play speed type: default, fast, slow
1710     E_JPD_CMD_SET_SPEED                      = 0x25, // Set play speed
1711     E_JPD_CMD_FLUSH_DISP_QUEUE               = 0X26, // Flush display queue
1712     E_JPD_CMD_FREEZE_DISP                    = 0x27, // Freeze display
1713     E_JPD_CMD_ENABLE_AVSYNC                  = 0x28, // Enable AV Sync
1714     E_JPD_CMD_SET_AVSYNC_DELAY               = 0x29, // Set AV sync delay
1715     E_JPD_CMD_SET_AVSYNC_TOLERENCE           = 0x2A, // Set AV sync tolerence
1716     E_JPD_CMD_SET_PTS_BASE                   = 0x2B, // Set PTS base
1717     E_JPD_CMD_SET_STC_BASE                   = 0x2C, // Set STC base
1718     E_JPD_CMD_SET_BLUE_SCREEN                = 0x2D, // Set Blue Screen
1719     E_JPD_CMD_PUSH_QUEUE_PARA_SETTING        = 0x2E,
1720     E_JPD_CMD_SET_DISPLAY_OUTSIDE_MODE       = 0x2F,
1721 
1722     E_JPD_CMD_GET_NEXT_FREE_FRAME_BUFF_IDX   = 0x40, // Get next free frame buffer index
1723     E_JPD_CMD_COMPENSATE_PTS                 = 0x41, // Ask firmware to compensate PTS
1724 
1725 
1726 #ifdef VDEC3
1727     E_JPD_CMD_GET_FRAME_BUFFER               = 0x50, // Ask firmware to get frame buffer
1728     E_JPD_CMD_FREE_FRAME_BUFFER              = 0x51, // Ask firmware to free frame buffer
1729 #endif
1730     E_JPD_CMD_DYNAMIC_CONNECT_DISP_PATH      = 0x61, // Arg, bit[0]: connect/disconnect, bit[4:1]: display path, [31:5]: reserved.
1731 
1732     // Display Command Queue
1733     E_JPD_CMD_ENABLE_DISP_CMD_QUEUE          = 0x80, // Enable Display Command Queue
1734     E_JPD_CMD_PUSH_DISP_CMD                  = 0x81, // Push Display Command
1735     E_JPD_CMD_GET_DISP_CMD_Q_VACANCY         = 0x82, // Check if the display command queue full or not
1736 
1737     E_JPD_CMD_IS_STEP_PLAY_DONE              = 0xFF, //
1738     E_JPD_CMD_IS_DISP_FINISH                 = 0xFE, //
1739     E_JPD_CMD_IS_PLAYING                     = 0xFC, //
1740     E_JPD_CMD_IS_DISPLAY_QUEUE_FULL          = 0xFB, //
1741     E_JPD_CMD_IS_AVSYNC_ON                   = 0xFA, //
1742     E_JPD_CMD_IS_REACH_AVSYNC                = 0xF9, //
1743     E_JPD_CMD_IS_FLUSH_DONE                  = 0xF8, // Check if flush done
1744 
1745 } JPD_User_Cmd;
1746 
1747 // Firmware State
1748 typedef enum
1749 {
1750     E_JPD_FW_STATE_MASK = 0xF000,
1751 } JPD_FW_State;
1752 
1753 // Error Code
1754 typedef enum
1755 {
1756     // Error code base
1757     E_JPD_ERR_BASE= 0x01000000,
1758 } JPD_Err_Code;
1759 
1760 typedef enum
1761 {
1762     E_HVD_FW_STATE_MASK = 0xF000,
1763 
1764     // state: INIT
1765     E_HVD_FW_INIT = 0x1000,
1766     E_HVD_FW_INIT_START,
1767     E_HVD_FW_INIT_DONE,
1768 
1769     // state: PLAY
1770     E_HVD_FW_PLAY = 0x2000,
1771     E_HVD_FW_PLAY_TYPE_MASK = 0x0C00,
1772 
1773     // AVC
1774     E_HVD_FW_PLAY_AVC = (0x0000|E_HVD_FW_PLAY),
1775     E_HVD_FW_AVC_READ_NAL,
1776     E_HVD_FW_AVC_READ_NEW_SLICE,
1777     E_HVD_FW_AVC_PREPARE_SLICE_HEADER,
1778     E_HVD_FW_AVC_DECODE_ONE_SLICE,
1779     E_HVD_FW_AVC_EXIT_PICTURE,
1780 
1781     // AVS
1782     E_HVD_FW_PLAY_AVS = (0x0400|E_HVD_FW_PLAY),
1783 
1784     // RM
1785     E_HVD_FW_PLAY_RM = (0x0800|E_HVD_FW_PLAY),
1786 
1787     // state: PAUSE
1788     E_HVD_FW_PAUSE = 0x3000,
1789 
1790     // state: STOP
1791     E_HVD_FW_STOP = 0x4000,
1792     E_HVD_FW_STOP_START,
1793     E_HVD_FW_STOP_DONE,
1794 } HVD_FW_State;
1795 
1796 
1797 typedef enum
1798 {
1799     // Error code base
1800     E_HVD_ERR_BASE = 0x0000,
1801 
1802     // General
1803     E_HVD_ERR_GENERAL_BASE = (0x0000|E_HVD_ERR_BASE),
1804     E_HVD_ERR_OUT_OF_SPEC,
1805     E_HVD_ERR_UNKNOW_ERR,
1806     E_HVD_ERR_HW_BREAK_DOWN,
1807     // TIMEOUT
1808     E_HVD_ERR_HW_DEC_TIMEOUT,
1809     // NOT SUPPORT
1810     E_HVD_ERR_OUT_OF_MEMORY,        // required memory size is over frame buffer size.
1811     E_HVD_ERR_UNKNOWN_CODEC,        // unknown media codec
1812     E_HVD_ERR_CMA_FAILED,
1813     E_HVD_ERR_RES_NOT_SUPPORT,      // out of supported resolution
1814 
1815     // AVC
1816     E_HVD_ERR_AVC_BASE = (0x1000|E_HVD_ERR_BASE),
1817     // decode error
1818     E_HVD_ERR_AVC_SPS_BROKEN,           // SPS is not valid
1819     E_HVD_ERR_AVC_SPS_NOT_IN_SPEC,
1820     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
1821     E_HVD_ERR_AVC_PPS_BROKEN,           // PPS is not valid
1822     E_HVD_ERR_AVC_REF_LIST,
1823     E_HVD_ERR_AVC_NO_REF,
1824     E_HVD_ERR_AVC_RES,                  // out of supported resolution
1825 
1826     // AVS
1827     E_HVD_ERR_AVS_BASE = (0x2000|E_HVD_ERR_BASE),
1828     E_HVD_ERR_AVS_RES,                  // out of supported resolution
1829 
1830     // RM
1831     E_HVD_ERR_RM_BASE = (0x3000|E_HVD_ERR_BASE),
1832     E_HVD_ERR_RM_PACKET_HEADER,
1833     E_HVD_ERR_RM_FRAME_HEADER,
1834     E_HVD_ERR_RM_SLICE_HEADER,
1835     E_HVD_ERR_RM_BYTE_CNT,
1836     E_HVD_ERR_RM_DISP_TIMEOUT,
1837     E_HVD_ERR_RM_NO_REF,
1838     E_HVD_ERR_RM_RES,                   // out of supported resolution
1839     E_HVD_ERR_RM_VLC,
1840     E_HVD_ERR_RM_SIZE_OUT_FB_LAYOUT,
1841 
1842     // VP8
1843     E_HVD_ERR_VP8_BASE = (0x4000|E_HVD_ERR_BASE),
1844     E_HVD_ERR_VP8_RES,                  // out of supported resolution
1845 
1846     // HEVC
1847     E_HVD_ERR_HEVC_BASE = (0x5000|E_HVD_ERR_BASE),
1848     E_HVD_ERR_HEVC_RES,                  // out of supported resolution
1849 
1850     // VP9
1851     E_HVD_ERR_VP9_BASE = (0x6000|E_HVD_ERR_BASE),
1852     E_HVD_ERR_VP9_RES,                  // out of supported resolution
1853 
1854     // Display
1855     E_HVD_ERR_DISPLAY_BASE = (0x7000|E_HVD_ERR_BASE),
1856     E_HVD_ERR_DISLPAY_MVOP_WITHOUT_MFDEC,    // [K6] MVOP and corresponding MFDEC share sram.
1857                                              //      MVOP cannot function if corresponding MFDEC is being used by DIP.
1858 } HVD_Err_Code;
1859 
1860 typedef enum
1861 {
1862     E_HVD_ES_BUF_STATUS_UNKNOWN   = 0,
1863     E_HVD_ES_BUF_STATUS_UNDERFLOW = 1,
1864     E_HVD_ES_BUF_STATUS_OVERFLOW  = 2,
1865     E_HVD_ES_BUF_STATUS_NORMAL    = 3,
1866 
1867 }HVD_ES_Buf_Status;
1868 
1869 typedef enum {
1870     E_PVR_SEAMLESS_TIMESHIFT_NONE = 0,
1871     E_PVR_SEAMLESS_TIMESHIFT_PAUSE_DECODE,          // initialize timeshift record, pause decode and set target POC/pts
1872     E_PVR_SEAMLESS_TIMESHIFT_RESET_AND_FINE_TARGET, // resume and try to find picture with target POC/pts, drop before we find it
1873     E_PVR_SEAMLESS_TIMESHIFT_SEEK_TO_I              // stop finding target, decode from next I
1874 } HVD_Seamless_Mode;
1875 
1876 typedef enum
1877 {
1878     E_HVD_FREEZE_AT_CUR_PIC = 1,
1879     E_HVD_FREEZE_AT_LAST_PIC = 2,
1880     E_HVD_FREEZE_AT_CUR_PIC_AND_CLEAR_DECODE_INFO = 3,
1881 }HVD_Flush_Mode;
1882 
1883 typedef enum
1884 {
1885     E_HVD_SEAMLESS_PAUSE_DECODE      = BIT(0),
1886     E_HVD_SEAMLESS_DISPLAY_REPEATING = BIT(1),
1887     E_HVD_SEAMLESS_RESET_HW_DONE     = BIT(2),
1888     E_HVD_SEAMLESS_TARGET_FRM_FOUND  = BIT(3),
1889     E_HVD_SEAMLESS_DISPLAY_RESUME    = BIT(4),
1890 }HVD_Seamless_Status;
1891 
1892 typedef enum
1893 {
1894     E_HVD_POST_PROC_NONE     = 0,
1895     E_HVD_POST_PROC_DETILE   = BIT(0),
1896     E_HVD_POST_PROC_FIELD_DETECT   = BIT(1),
1897 } HVD_Post_Process;
1898 
1899 typedef enum
1900 {
1901     E_HVD_CHIP_U01   = 0,
1902     E_HVD_CHIP_U02   = 1,
1903 } HVD_CHIP_ECO_NUM;
1904 
1905 typedef enum
1906 {
1907     // unknown sequence change info
1908     VDEC_SEQ_CHANGE_NONE              = 0x00,
1909     // sequence chagne first time
1910     VDEC_SEQ_CHANGE_FIRST_TIME        = BIT(0),
1911     // sequence chagne due to resolution
1912     VDEC_SEQ_CHANGE_RESOLUTION        = BIT(1),
1913     // sequence chagne due to picture type
1914     VDEC_SEQ_CHANGE_PICTURE_TYPE      = BIT(2),
1915     // sequence chagne due to aspect ratio
1916     VDEC_SEQ_CHANGE_ASPECT_RATIO      = BIT(3),
1917     // sequence chagne due to frame rate
1918     VDEC_SEQ_CHANGE_FRAME_RATE        = BIT(4),
1919     // sequence chagne due to HDR info
1920     VDEC_SEQ_CHANGE_HDR_INFO          = BIT(5),
1921 } VDEC_SeqChangeInfo;
1922 
1923 typedef enum
1924 {
1925     // Not support profile
1926     E_HVD_NOT_SUPPORT_PROFILE      = BIT(0),
1927     // Not support SPS ID
1928     E_HVD_NOT_SUPPORT_SPS_ID        = BIT(1),
1929     // Not support chroma format
1930     E_HVD_NOT_SUPPORT_CHROMA_FORMAT = BIT(2),
1931     // Mot support max frame number
1932     E_HVD_NOT_SUPPORT_MAX_FRAME_NUM = BIT(3),
1933 } HVD_NOT_SUPPORT_INFO;
1934 
1935 typedef enum
1936 {
1937   E_VDEC_TILE_NONE = 0,
1938   E_VDEC_TILE_16X16,
1939   E_VDEC_TILE_16X32,
1940   E_VDEC_TILE_32X16,
1941   E_VDEC_TILE_32X32,
1942   E_VDEC_TILE_MAX,
1943 } VDEC_TILE_MODE;
1944 
1945 #endif // _FW_HVD_IF_H_
1946 
1947