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