1 /*
2 * Copyright (c) 2014-2020, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 
23 //! \file     mhw_vdbox_hcp_interface.h
24 //! \brief    MHW interface for constructing HCP commands for the Vdbox engine
25 //! \details  Defines the interfaces for constructing MHW Vdbox HCP commands across all platforms
26 //!
27 
28 #ifndef _MHW_VDBOX_HCP_INTERFACE_H_
29 #define _MHW_VDBOX_HCP_INTERFACE_H_
30 
31 #include "mhw_vdbox.h"
32 #include "mhw_mi.h"
33 #include "codec_def_encode_hevc.h"
34 #include "mhw_vdbox_hcp_def.h"
35 
36 #define MHW_HCP_WORST_CASE_LCU_CU_TU_INFO        (26 * MHW_CACHELINE_SIZE) // 18+4+4
37 #define MHW_HCP_WORST_CASE_LCU_CU_TU_INFO_REXT   (35 * MHW_CACHELINE_SIZE) // 27+4+4
38 
39 struct MHW_VDBOX_HEVC_PIC_STATE
40 {
41     // Decode
42     PCODEC_HEVC_PIC_PARAMS                  pHevcPicParams = nullptr;
43 
44     // Encode
45     PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS      pHevcEncSeqParams = nullptr;
46     PCODEC_HEVC_ENCODE_PICTURE_PARAMS       pHevcEncPicParams = nullptr;
47     bool                                    bSAOEnable = false;
48     bool                                    bNotFirstPass = false;
49     bool                                    bHevcRdoqEnabled = false;
50     bool                                    bUseVDEnc = false;
51     bool                                    sseEnabledInVmeEncode = false;
52     PMHW_BATCH_BUFFER                       pBatchBuffer = nullptr;
53     bool                                    bBatchBufferInUse = false;
54     bool                                    bRDOQIntraTUDisable = false;
55     uint16_t                                wRDOQIntraTUThreshold = 0;
56     uint32_t                                brcNumPakPasses = 0;
57     bool                                    rhodomainRCEnable = false;
58     bool                                    bTransformSkipEnable = false;
59 
60     //FEI multiple passes PAK ---max frame size
61     uint16_t                                currPass = 0;
62     uint8_t                                *deltaQp = nullptr;
63     uint32_t                                maxFrameSize = 0;
~MHW_VDBOX_HEVC_PIC_STATEMHW_VDBOX_HEVC_PIC_STATE64     virtual ~MHW_VDBOX_HEVC_PIC_STATE(){}
65 };
66 using PMHW_VDBOX_HEVC_PIC_STATE = MHW_VDBOX_HEVC_PIC_STATE * ;
67 
68 typedef struct _MHW_VDBOX_HEVC_TILE_STATE
69 {
70     PCODEC_HEVC_PIC_PARAMS          pHevcPicParams;
71     uint16_t                       *pTileColWidth;
72     uint16_t                       *pTileRowHeight;
73 } MHW_VDBOX_HEVC_TILE_STATE, *PMHW_VDBOX_HEVC_TILE_STATE;
74 
75 typedef struct _MHW_VDBOX_HCP_BUFFER_SIZE_PARAMS
76 {
77     uint8_t    ucMaxBitDepth;
78     uint8_t    ucChromaFormat;
79     uint32_t   dwCtbLog2SizeY;
80     uint32_t   dwPicWidth;
81     uint32_t   dwPicHeight;
82     uint32_t   dwBufferSize;
83     uint32_t   dwMaxFrameSize;
84 }MHW_VDBOX_HCP_BUFFER_SIZE_PARAMS, *PMHW_VDBOX_HCP_BUFFER_SIZE_PARAMS;
85 
86 typedef struct _MHW_VDBOX_HCP_BUFFER_REALLOC_PARAMS
87 {
88     uint8_t    ucMaxBitDepth;
89     uint8_t    ucChromaFormat;
90     uint32_t   dwPicWidth;
91     uint32_t   dwPicHeight;
92     uint32_t   dwPicWidthAlloced;
93     uint32_t   dwPicHeightAlloced;
94     uint32_t   dwCtbLog2SizeY;
95     uint32_t   dwCtbLog2SizeYMax;
96     uint32_t   dwFrameSize;
97     uint32_t   dwFrameSizeAlloced;
98     bool       bNeedBiggerSize;
99 }MHW_VDBOX_HCP_BUFFER_REALLOC_PARAMS, *PMHW_VDBOX_HCP_BUFFER_REALLOC_PARAMS;
100 
101 struct MHW_VDBOX_HEVC_REF_IDX_PARAMS
102 {
103     CODEC_PICTURE                   CurrPic = {};
104     bool                            isEncode = false;
105     uint8_t                         ucList = 0;
106     uint8_t                         ucNumRefForList = 0;
107     CODEC_PICTURE                   RefPicList[2][CODEC_MAX_NUM_REF_FRAME_HEVC] = {};
108     void                            **hevcRefList = nullptr;
109     int32_t                         poc_curr_pic = 0;
110     int32_t                         poc_list[CODEC_MAX_NUM_REF_FRAME_HEVC] = {};
111     int8_t                         *pRefIdxMapping = 0;
112     uint16_t                        RefFieldPicFlag = 0;
113     uint16_t                        RefBottomFieldFlag = 0;
114     bool                            bDummyReference = false;
~MHW_VDBOX_HEVC_REF_IDX_PARAMSMHW_VDBOX_HEVC_REF_IDX_PARAMS115     virtual ~MHW_VDBOX_HEVC_REF_IDX_PARAMS(){}
116 };
117 using PMHW_VDBOX_HEVC_REF_IDX_PARAMS = MHW_VDBOX_HEVC_REF_IDX_PARAMS * ;
118 
119 typedef struct _MHW_VDBOX_HEVC_WEIGHTOFFSET_PARAMS
120 {
121     uint8_t                         ucList;
122     char                            LumaWeights[2][15];
123     int16_t                         LumaOffsets[2][15];
124     char                            ChromaWeights[2][15][2];
125     int16_t                         ChromaOffsets[2][15][2];
126 } MHW_VDBOX_HEVC_WEIGHTOFFSET_PARAMS, *PMHW_VDBOX_HEVC_WEIGHTOFFSET_PARAMS;
127 
128 typedef struct _MHW_VDBOX_ENCODE_HEVC_TRANSFORM_SKIP_PARAMS
129 {
130     bool     Transformskip_enabled;
131     uint16_t Transformskip_lambda;
132     uint8_t  Transformskip_Numzerocoeffs_Factor0;
133     uint8_t  Transformskip_Numnonzerocoeffs_Factor0;
134     uint8_t  Transformskip_Numzerocoeffs_Factor1;
135     uint8_t  Transformskip_Numnonzerocoeffs_Factor1;
136 }MHW_VDBOX_ENCODE_HEVC_TRANSFORM_SKIP_PARAMS, *PMHW_VDBOX_ENCODE_HEVC_TRANSFORM_SKIP_PARAMS;
137 
138 struct MHW_VDBOX_HEVC_SLICE_STATE
139 {
140     PCODEC_PIC_ID                   pHevcPicIdx = nullptr;
141     PMOS_RESOURCE                   presDataBuffer = nullptr;
142     uint32_t                        dwDataBufferOffset = 0;
143     uint32_t                        dwOffset = 0;
144     uint32_t                        dwLength = 0;
145     uint32_t                        dwSliceIndex = 0;
146     bool                            bLastSlice = false;
147     bool                            bLastSliceInTile = false;
148     bool                            bLastSliceInTileColumn = false;
149     bool                            bHucStreamOut = false;
150     int8_t                         *pRefIdxMapping = nullptr;
151     bool                            bSaoLumaFlag = false;
152     bool                            bSaoChromaFlag = false;
153 
154     PCODEC_HEVC_SLICE_PARAMS        pHevcSliceParams = nullptr;
155     PCODEC_HEVC_PIC_PARAMS          pHevcPicParams = nullptr;
156 
157     // Encoding Only
158     PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS      pEncodeHevcSeqParams = nullptr;
159     PCODEC_HEVC_ENCODE_PICTURE_PARAMS       pEncodeHevcPicParams = nullptr;
160     PCODEC_HEVC_ENCODE_SLICE_PARAMS         pEncodeHevcSliceParams = nullptr;
161     PBSBuffer                               pBsBuffer = nullptr;
162     PCODECHAL_NAL_UNIT_PARAMS              *ppNalUnitParams = nullptr;
163     bool                                    bFirstPass = false;
164     bool                                    bLastPass = false;
165     bool                                    bIntraRefFetchDisable = false;
166     bool                                    bBrcEnabled = false;
167     uint32_t                                dwHeaderBytesInserted = 0;
168     uint32_t                                dwHeaderDummyBytes = 0;
169     uint32_t                                uiSkipEmulationCheckCount = 0;
170     bool                                    bInsertBeforeSliceHeaders = false;
171     bool                                    bIsLowDelay = false;
172     // Encoding + BRC only
173     PMHW_BATCH_BUFFER                       pBatchBufferForPakSlices = nullptr;
174     bool                                    bSingleTaskPhaseSupported = false;
175     uint32_t                                dwBatchBufferForPakSlicesStartOffset = 0;
176     bool                                    bVdencInUse = false;
177     bool                                    bVdencHucInUse = false;
178     bool                                    bWeightedPredInUse = false;
179     PMHW_BATCH_BUFFER                       pVdencBatchBuffer = nullptr;
180 
181     //Pak related params
182     MHW_VDBOX_ENCODE_HEVC_TRANSFORM_SKIP_PARAMS EncodeHevcTransformSkipParams = {};
183     bool                                    DeblockingFilterDisable = false;
184     char                                    TcOffsetDiv2 = 0;
185     char                                    BetaOffsetDiv2 = 0;
186 
187     uint8_t                                 RoundingIntra = 0;
188     uint8_t                                 RoundingInter = 0;
~MHW_VDBOX_HEVC_SLICE_STATEMHW_VDBOX_HEVC_SLICE_STATE189     virtual ~MHW_VDBOX_HEVC_SLICE_STATE(){}
190 };
191 using PMHW_VDBOX_HEVC_SLICE_STATE = MHW_VDBOX_HEVC_SLICE_STATE * ;
192 
193 typedef struct _MHW_VDBOX_VP9_ENCODE_PIC_STATE
194 {
195     PCODEC_VP9_ENCODE_PIC_PARAMS        pVp9PicParams;
196     PCODEC_REF_LIST                    *ppVp9RefList;
197     PCODEC_VP9_ENCODE_SEQUENCE_PARAMS   pVp9SeqParams;
198 
199     union
200     {
201         struct
202         {
203             uint8_t                    KeyFrame : 1;        // [0..1]
204             uint8_t                    IntraOnly : 1;        // [0..1]
205             uint8_t                    Display : 1;        // [0..1]
206             uint8_t                    ReservedField : 5;        // [0]
207         } fields;
208         uint8_t                        value;
209     } PrevFrameParams;
210 
211     uint32_t                        dwPrevFrmWidth;
212     uint32_t                        dwPrevFrmHeight;
213     uint8_t                         ucTxMode;
214     bool                            bUseDysRefSurface;
215     bool                            bNonFirstPassFlag;
216     bool                            bSSEEnable;
217     bool                            bVdencPakOnlyPassFlag;
218     uint32_t                        uiMaxBitRate;
219     uint32_t                        uiMinBitRate;
220 
221 } MHW_VDBOX_VP9_ENCODE_PIC_STATE, *PMHW_VDBOX_VP9_ENCODE_PIC_STATE;
222 
223 typedef struct _MHW_VDBOX_VP9_PIC_STATE
224 {
225     // Decode
226     PCODEC_VP9_PIC_PARAMS              pVp9PicParams;
227     PCODEC_REF_LIST                   *ppVp9RefList;
228 
229     union
230     {
231         struct
232         {
233             uint8_t                    KeyFrame : 1;        // [0..1]
234             uint8_t                    IntraOnly : 1;        // [0..1]
235             uint8_t                    Display : 1;        // [0..1]
236             uint8_t                    ReservedField : 5;        // [0]
237         } fields;
238         uint8_t                        value;
239     } PrevFrameParams;
240 
241     uint32_t                           dwPrevFrmWidth;
242     uint32_t                           dwPrevFrmHeight;
243 
244 } MHW_VDBOX_VP9_PIC_STATE, *PMHW_VDBOX_VP9_PIC_STATE;
245 
246 typedef struct _MHW_VDBOX_IMAGE_STATUS_CONTROL
247 {
248     union
249     {
250         struct
251         {
252             uint32_t   MaxMbConformanceFlag : 1;
253             uint32_t   FrameBitcountFlag : 1;
254             uint32_t   Panic : 1;
255             uint32_t   MissingHuffmanCode : 1; // new addition for JPEG encode
256             uint32_t   : 4;
257             uint32_t   TotalNumPass : 4;
258             uint32_t   VDENCSliceOverflowErrorOccurred : 1;
259             uint32_t   NumPassPolarityChange : 2;
260             uint32_t   CumulativeSliceQpPolarityChange : 1;
261             uint32_t   SuggestedSliceQPDelta : 8;
262             uint32_t   CumulativeSliceDeltaQP : 8;
263         };
264 
265         struct
266         {
267             uint32_t   hcpLCUMaxSizeViolate : 1;
268             uint32_t   hcpFrameBitCountViolateOverRun : 1;
269             uint32_t   hcpFrameBitCountViolateUnderRun : 1;
270             uint32_t   : 5;
271             uint32_t   hcpTotalPass : 4;
272             uint32_t   : 4;
273             uint32_t   hcpCumulativeFrameDeltaLF : 7;
274             uint32_t   : 1;
275             uint32_t   hcpCumulativeFrameDeltaQp : 8;
276         };
277 
278         struct
279         {
280             uint32_t   Value;
281         };
282     };
283 }MHW_VDBOX_IMAGE_STATUS_CONTROL, *PMHW_VDBOX_IMAGE_STATUS_CONTROL;
284 
285 typedef struct _MHW_VDBOX_PAK_NUM_OF_SLICES
286 {
287     // Num Slices
288     union
289     {
290         struct
291         {
292             uint32_t   NumberOfSlices : 16;
293             uint32_t   Reserved : 16;
294         };
295 
296         struct
297         {
298             uint32_t   Value;
299         };
300     };
301 }MHW_VDBOX_PAK_NUM_OF_SLICES, *PMHW_VDBOX_PAK_NUM_OF_SLICES;
302 
303 // definition for HEVC/VP9 internal buffer type
304 typedef enum _MHW_VDBOX_HCP_INTERNAL_BUFFER_TYPE
305 {
306     MHW_VDBOX_HCP_INTERNAL_BUFFER_DBLK_LINE = 0x0,
307     MHW_VDBOX_HCP_INTERNAL_BUFFER_DBLK_TILE_LINE,
308     MHW_VDBOX_HCP_INTERNAL_BUFFER_DBLK_TILE_COL,
309     MHW_VDBOX_HCP_INTERNAL_BUFFER_MV_UP_RT_COL,
310     MHW_VDBOX_HCP_INTERNAL_BUFFER_META_LINE,
311     MHW_VDBOX_HCP_INTERNAL_BUFFER_META_TILE_LINE,
312     MHW_VDBOX_HCP_INTERNAL_BUFFER_META_TILE_COL,
313     MHW_VDBOX_HCP_INTERNAL_BUFFER_TR_NBR,
314     MHW_VDBOX_HCP_INTERNAL_BUFFER_SAO_LINE,
315     MHW_VDBOX_HCP_INTERNAL_BUFFER_SAO_TILE_LINE,
316     MHW_VDBOX_HCP_INTERNAL_BUFFER_SAO_TILE_COL,
317     MHW_VDBOX_HCP_INTERNAL_BUFFER_HSSE_RS,
318     MHW_VDBOX_HCP_INTERNAL_BUFFER_HSAO_RS,
319     MHW_VDBOX_HCP_INTERNAL_BUFFER_CURR_MV_TEMPORAL,
320     MHW_VDBOX_HCP_INTERNAL_BUFFER_COLL_MV_TEMPORAL,
321     MHW_VDBOX_HCP_INTERNAL_BUFFER_SLC_STATE_STREAMOUT,
322     MHW_VDBOX_HCP_INTERNAL_BUFFER_CABAC_STREAMOUT,
323     MHW_VDBOX_HCP_INTERNAL_BUFFER_MV_UP_RIGHT_COL,
324     MHW_VDBOX_HCP_INTERNAL_BUFFER_INTRA_PRED_UP_RIGHT_COL,
325     MHW_VDBOX_HCP_INTERNAL_BUFFER_INTRA_PRED_LFT_RECON_COL,
326     MHW_VDBOX_VP9_INTERNAL_BUFFER_SEGMENT_ID,
327     MHW_VDBOX_VP9_INTERNAL_BUFFER_HVD_LINE,
328     MHW_VDBOX_VP9_INTERNAL_BUFFER_HVD_TILE
329 } MHW_VDBOX_HCP_INTERNAL_BUFFER_TYPE;
330 
331 
332 
333 //!  MHW Vdbox Hcp interface
334 /*!
335 This class defines the interfaces for constructing Vdbox Hcp commands across all platforms
336 */
337 class MhwVdboxHcpInterface
338 {
339 public:
340     //!
341     //! \enum     HevcSliceType
342     //! \brief    HEVC slice type
343     //!
344     enum HevcSliceType
345     {
346         hevcSliceB  = 0,
347         hevcSliceP  = 1,
348         hevcSliceI  = 2
349     };
350     //!
351     //! \brief    Get max vdbox index
352     //!
353     //! \return   MHW_VDBOX_NODE_IND
354     //!           max vdbox index got
355     //!
GetMaxVdboxIndex()356     inline MHW_VDBOX_NODE_IND GetMaxVdboxIndex()
357     {
358         return MEDIA_IS_SKU(m_skuTable, FtrVcs2) ? MHW_VDBOX_NODE_2 : MHW_VDBOX_NODE_1;
359     }
360 
361 protected:
362     PMOS_INTERFACE              m_osInterface = nullptr; //!< Pointer to OS interface
363     MhwMiInterface              *m_miInterface = nullptr; //!< Pointer to MI interface
364     MhwCpInterface              *m_cpInterface = nullptr; //!< Pointer to CP interface
365     MEDIA_FEATURE_TABLE         *m_skuTable = nullptr; //!< Pointer to SKU table
366     MEDIA_WA_TABLE              *m_waTable = nullptr; //!< Pointer to WA table
367     bool                        m_decodeInUse = false; //!< Flag to indicate if the interface is for decoder or encoder use
368 
369     MHW_MEMORY_OBJECT_CONTROL_PARAMS m_cacheabilitySettings[MOS_CODEC_RESOURCE_USAGE_END_CODEC] = {}; //!< Cacheability settings
370 
371     bool                        m_rhoDomainStatsEnabled = false; //!< Flag to indicate if Rho domain stats is enabled
372     bool                        m_rowstoreCachingSupported = false; //!< Flag to indicate if row store cache is supported
373     uint32_t                    m_brcNumPakPasses = 4; //!< Number of brc pak passes
374 
375     MHW_VDBOX_ROWSTORE_CACHE    m_hevcDatRowStoreCache = {};
376     MHW_VDBOX_ROWSTORE_CACHE    m_hevcDfRowStoreCache = {};
377     MHW_VDBOX_ROWSTORE_CACHE    m_hevcSaoRowStoreCache = {};
378     MHW_VDBOX_ROWSTORE_CACHE    m_hevcHSaoRowStoreCache = {};
379     MHW_VDBOX_ROWSTORE_CACHE    m_vp9HvdRowStoreCache = {};
380     MHW_VDBOX_ROWSTORE_CACHE    m_vp9DfRowStoreCache = {};
381     MHW_VDBOX_ROWSTORE_CACHE    m_vp9DatRowStoreCache = {};
382 
383     uint32_t                    m_hevcEncCuRecordSize = 0; //!< size of hevc enc cu record
384     uint32_t                    m_pakHWTileSizeRecordSize = 0; //! pak HW tile size recored size
385 
386     static const uint32_t       m_timeStampCountsPerMillisecond = (12000048 / 1000);  //<! Time stamp coounts per millisecond
387     static const uint32_t       m_hcpCabacErrorFlagsMask = 0x0879; //<! Hcp CABAC error flags mask
388 
389     MmioRegistersHcp            m_mmioRegisters[MHW_VDBOX_NODE_MAX] = {};  //!< hcp mmio registers
390 
391     static const HevcSliceType  m_hevcBsdSliceType[3]; //!< HEVC Slice Types for Long Format
392 
393     std::shared_ptr<void> m_hcpItfNew = nullptr;
394 
395 #if MOS_EVENT_TRACE_DUMP_SUPPORTED
396     bool bMMCReported = false;
397 #endif
398 
399     //!
400     //! \brief    Constructor
401     //!
402     MhwVdboxHcpInterface(
403         PMOS_INTERFACE osInterface,
404         MhwMiInterface *miInterface,
405         MhwCpInterface *cpInterface,
406         bool decodeInUse);
407 
408     //!
409     //! \brief    Add a resource to the command buffer
410     //! \details  Internal function to add either a graphics address of a resource or
411     //!           add the resource to the patch list for the requested buffer
412     //!
413     //! \param    [in] osInterface
414     //!           OS interface
415     //! \param    [in] cmdBuffer
416     //!           Command buffer to which resource is added
417     //! \param    [in] params
418     //!           Parameters necessary to add the resource
419     //!
420     //! \return   MOS_STATUS
421     //!           MOS_STATUS_SUCCESS if success, else fail reason
422     //!
423     MOS_STATUS(*pfnAddResourceToCmd) (
424         PMOS_INTERFACE osInterface,
425         PMOS_COMMAND_BUFFER cmdBuffer,
426         PMHW_RESOURCE_PARAMS params);
427 
428     //!
429     //! \brief    Convert to Sign Magnitude
430     //! \details  Implementation of signed bitfield as specified
431     //!
432     //! \param    [in] val
433     //!           Input value to calculate
434     //! \param    [in] signBitPos
435     //!           The position of sign bit
436     //!
437     //! \return   uint16_t
438     //!           value calculated
439     //!
440     uint16_t Convert2SignMagnitude(
441         int32_t val,
442         uint32_t signBitPos);
443 
444 public:
445 
446     //!
447     //! \brief    Destructor
448     //!
~MhwVdboxHcpInterface()449     virtual ~MhwVdboxHcpInterface() {}
450 
451     //!
452     //! \brief    Get new HCP interface, temporal solution before switching from
453     //!           old interface to new one
454     //!
455     //! \return   pointer to new HCP interface
456     //!
GetNewHcpInterface()457     virtual std::shared_ptr<void> GetNewHcpInterface() { return nullptr; }
458 
459     //!
460     //! \brief    Get OS interface
461     //!
462     //! \return   [out] PMOS_INTERFACE
463     //!           Pointer to the OS interface.
464     //!
GetOsInterface()465     inline PMOS_INTERFACE GetOsInterface()
466     {
467         return m_osInterface;
468     }
469 
470     //!
471     //! \brief    Get mmio registers
472     //!
473     //! \param    [in] index
474     //!           mmio registers index.
475     //!
476     //! \return   [out] MmioRegistersHcp*
477     //!           mmio registers got.
478     //!
GetMmioRegisters(MHW_VDBOX_NODE_IND index)479     inline MmioRegistersHcp* GetMmioRegisters(MHW_VDBOX_NODE_IND index)
480     {
481         if (index < MHW_VDBOX_NODE_MAX)
482         {
483             return &m_mmioRegisters[index];
484         }
485         else
486         {
487             MHW_ASSERT("index is out of range!");
488             return &m_mmioRegisters[MHW_VDBOX_NODE_1];
489         }
490     }
491 
492     //!
493     //! \brief    Get Hcp Cabac Error Flags Mask
494     //!
495     //! \return   [out] uint32_t
496     //!           Mask got.
497     //!
GetHcpCabacErrorFlagsMask()498     virtual inline uint32_t GetHcpCabacErrorFlagsMask()
499     {
500         return m_hcpCabacErrorFlagsMask;
501     }
502 
503     //!
504     //! \brief    Get Watch Dog Timer Threhold
505     //!
506     //! \return   [out] uint32_t
507     //!           Threhold got.
508     //!
GetWatchDogTimerThrehold()509     virtual inline uint32_t GetWatchDogTimerThrehold()
510     {
511         return 0;
512     }
513 
514     //!
515     //! \brief    Get Time Stamp Counts Per Millisecond
516     //!
517     //! \return   [out] uint32_t
518     //!           Counts got.
519     //!
GetTimeStampCountsPerMillisecond()520     inline uint32_t GetTimeStampCountsPerMillisecond()
521     {
522         return m_timeStampCountsPerMillisecond;
523     }
524 
525     //!
526     //! \brief    Get hevc enc cu record size
527     //! \return   [out] uint32_t
528     //!           Brc pak passes num.
529     //!
GetHevcEncCuRecordSize()530     inline uint32_t GetHevcEncCuRecordSize()
531     {
532         return m_hevcEncCuRecordSize;
533     }
534 
535     //!
536     //! \brief    Get pak HW tile size record size
537     //! \return   [out] uint32_t
538     //!           Brc pak passes num.
539     //!
GetPakHWTileSizeRecordSize()540     inline uint32_t GetPakHWTileSizeRecordSize()
541     {
542         return m_pakHWTileSizeRecordSize;
543     }
544 
545     //!
546     //! \brief    Judge if row store caching supported
547     //!
548     //! \return   bool
549     //!           true if supported, else false
550     //!
IsRowStoreCachingSupported()551     inline bool IsRowStoreCachingSupported()
552     {
553         return m_rowstoreCachingSupported;
554     }
555 
556     //!
557     //! \brief    Judge if hevc dat store caching enabled
558     //!
559     //! \return   bool
560     //!           true if enabled, else false
561     //!
IsHevcDatRowstoreCacheEnabled()562     inline bool IsHevcDatRowstoreCacheEnabled()
563     {
564         return m_hevcDatRowStoreCache.bEnabled ? true : false;
565     }
566 
567     //!
568     //! \brief    Judge if hevc df row store caching enabled
569     //!
570     //! \return   bool
571     //!           true if enabled, else false
572     //!
IsHevcDfRowstoreCacheEnabled()573     inline bool IsHevcDfRowstoreCacheEnabled()
574     {
575         return m_hevcDfRowStoreCache.bEnabled ? true : false;
576     }
577 
578     //!
579     //! \brief    Judge if hevc sao row store caching enabled
580     //!
581     //! \return   bool
582     //!           true if enabled, else false
583     //!
IsHevcSaoRowstoreCacheEnabled()584     inline bool IsHevcSaoRowstoreCacheEnabled()
585     {
586         return m_hevcSaoRowStoreCache.bEnabled ? true : false;
587     }
588 
589     //!
590     //! \brief    Judge if vp9 hvd row store caching enabled
591     //!
592     //! \return   bool
593     //!           true if enabled, else false
594     //!
IsVp9HvdRowstoreCacheEnabled()595     inline bool IsVp9HvdRowstoreCacheEnabled()
596     {
597         return m_vp9HvdRowStoreCache.bEnabled ? true : false;
598     }
599 
600     //!
601     //! \brief    Judge if vp9 df row store caching enabled
602     //!
603     //! \return   bool
604     //!           true if enabled, else false
605     //!
IsVp9DfRowstoreCacheEnabled()606     inline bool IsVp9DfRowstoreCacheEnabled()
607     {
608         return m_vp9DfRowStoreCache.bEnabled ? true : false;
609     }
610 
611     //!
612     //! \brief    Judge if vp9 dat row store caching enabled
613     //!
614     //! \return   bool
615     //!           true if enabled, else false
616     //!
IsVp9DatRowstoreCacheEnabled()617     inline bool IsVp9DatRowstoreCacheEnabled()
618     {
619         return m_vp9DatRowStoreCache.bEnabled ? true : false;
620     }
621 
622     //!
623     //! \brief    Set cacheability settings
624     //!
625     //! \param    [in] cacheabilitySettings
626     //!           Cacheability settings
627     //!
628     //! \return   MOS_STATUS
629     //!           MOS_STATUS_SUCCESS if success, else fail reason
630     //!
SetCacheabilitySettings(MHW_MEMORY_OBJECT_CONTROL_PARAMS cacheabilitySettings[MOS_CODEC_RESOURCE_USAGE_END_CODEC])631     MOS_STATUS SetCacheabilitySettings(
632         MHW_MEMORY_OBJECT_CONTROL_PARAMS cacheabilitySettings[MOS_CODEC_RESOURCE_USAGE_END_CODEC])
633     {
634         MHW_FUNCTION_ENTER;
635 
636         uint32_t size = MOS_CODEC_RESOURCE_USAGE_END_CODEC * sizeof(MHW_MEMORY_OBJECT_CONTROL_PARAMS);
637         MOS_STATUS eStatus = MOS_SecureMemcpy(m_cacheabilitySettings, size,
638             cacheabilitySettings, size);
639 
640         return eStatus;
641     }
642 
643     //!
644     //! \brief    Determines if the slice is P slice
645     //! \param    [in] sliceType
646     //!           slice type
647     //! \return   bool
648     //!           True if it's P slice, otherwise return false
649     //!
IsHevcPSlice(uint8_t sliceType)650     inline bool IsHevcPSlice(uint8_t sliceType)
651     {
652         return (sliceType < MHW_ARRAY_SIZE(m_hevcBsdSliceType)) ?
653             (m_hevcBsdSliceType[sliceType] == hevcSliceP) : false;
654     }
655 
656     //!
657     //! \brief    Determines if the slice is B slice
658     //! \param    [in] sliceType
659     //!           slice type
660     //! \return   bool
661     //!           True if it's B slice, otherwise return false
662     //!
IsHevcBSlice(uint8_t sliceType)663     inline bool IsHevcBSlice(uint8_t sliceType)
664     {
665         return (sliceType < MHW_ARRAY_SIZE(m_hevcBsdSliceType)) ?
666             (m_hevcBsdSliceType[sliceType] == hevcSliceB) : false;
667     }
668 
669     //!
670     //! \brief    Determines if the slice is I slice
671     //! \param    [in] sliceType
672     //!           slice type
673     //! \return   bool
674     //!           True if it's I slice, otherwise return false
675     //!
IsHevcISlice(uint8_t sliceType)676     inline bool IsHevcISlice(uint8_t sliceType)
677     {
678         return (sliceType < MHW_ARRAY_SIZE(m_hevcBsdSliceType)) ?
679             (m_hevcBsdSliceType[sliceType] == hevcSliceI) : false;
680     }
681 
682     //!
683     //! \brief    Get pak object size
684     //!
685     //! \return   uint32_t
686     //!           The size got
687     //!
688     virtual uint32_t GetHcpPakObjSize() = 0;
689 
690     //!
691     //! \brief    Calculates the maximum size for HCP picture level commands
692     //! \details  Client facing function to calculate the maximum size for HCP picture level commands
693     //! \param    [in] mode
694     //!           Indicate the codec mode
695     //! \param    [out] commandsSize
696     //!           The maximum command buffer size
697     //! \param    [out] patchListSize
698     //!           The maximum command patch list size
699     //! \param    [in] params
700     //!           Indicate the command size parameters
701     //! \return   MOS_STATUS
702     //!           MOS_STATUS_SUCCESS if success, else fail reason
703     //!
704     virtual MOS_STATUS GetHcpStateCommandSize(
705         uint32_t                        mode,
706         uint32_t                        *commandsSize,
707         uint32_t                        *patchListSize,
708         PMHW_VDBOX_STATE_CMDSIZE_PARAMS params) = 0;
709 
710     //!
711     //! \brief    Calculates maximum size for HCP slice/MB level commands
712     //! \details  Client facing function to calculate maximum size for HCP slice/MB level commands
713     //! \param    [in] mode
714     //!           Indicate the codec mode
715     //! \param    [out] commandsSize
716     //!            The maximum command buffer size
717     //! \param    [out] patchListSize
718     //!           The maximum command patch list size
719     //! \param    [in] modeSpecific
720     //!           Indicate the long or short format
721     //! \return   MOS_STATUS
722     //!           MOS_STATUS_SUCCESS if success, else fail reason
723     //!
724     virtual MOS_STATUS GetHcpPrimitiveCommandSize(
725         uint32_t                        mode,
726         uint32_t                        *commandsSize,
727         uint32_t                        *patchListSize,
728         bool                            modeSpecific) = 0;
729 
730     //!
731     //! \brief    get the size of hw command
732     //! \details  Internal function to get the size of HEVC_VP9_RDOQ_STATE_CMD
733     //! \return   commandSize
734     //!           The command size
735     //!
736     virtual uint32_t GetHcpHevcVp9RdoqStateCommandSize() = 0;
737 
738     //!
739     //! \brief    get the size of hw command
740     //! \details  Internal function to get the size of HCP_VP9_PIC_STATE_CMD
741     //! \return   commandSize
742     //!           The command size
743     //!
744     virtual uint32_t GetHcpVp9PicStateCommandSize() = 0;
745 
746     //!
747     //! \brief    get the size of hw command
748     //! \details  Internal function to get the size of HCP_VP9_SEGMENT_STATE_CMD
749     //! \return   commandSize
750     //!           The command size
751     //!
752     virtual uint32_t GetHcpVp9SegmentStateCommandSize() = 0;
753 
754     //!
755     //! \brief    Get the required buffer size for VDBOX
756     //! \details  Internal function to get required buffer size for HEVC codec (both dual pipe and vdenc, enc and dec)
757     //!
758     //! \param    [in] bufferType
759     //!           HEVC Buffer type
760     //! \param    [in, out] hcpBufSizeParam
761     //!           HCP buffer size parameters
762     //!
763     //! \return   MOS_STATUS
764     //!           MOS_STATUS_SUCCESS if success, else fail reason
765     //!
766     virtual MOS_STATUS GetHevcBufferSize(
767         MHW_VDBOX_HCP_INTERNAL_BUFFER_TYPE  bufferType,
768         PMHW_VDBOX_HCP_BUFFER_SIZE_PARAMS   hcpBufSizeParam) = 0;
769 
770     //!
771     //! \brief    Get the required buffer size for VDBOX
772     //! \details  Internal function to get required buffer size for VP9 codec
773     //!
774     //! \param    [in] bufferType
775     //!           HEVC Buffer type
776     //! \param    [in, out] hcpBufSizeParam
777     //!           HCP buffer size parameters
778     //!
779     //! \return   MOS_STATUS
780     //!           MOS_STATUS_SUCCESS if success, else fail reason
781     //!
782     virtual MOS_STATUS GetVp9BufferSize(
783         MHW_VDBOX_HCP_INTERNAL_BUFFER_TYPE  bufferType,
784         PMHW_VDBOX_HCP_BUFFER_SIZE_PARAMS   hcpBufSizeParam) = 0;
785 
786     //!
787     //! \brief    Get the required buffer size for VDBOX
788     //! \details  Internal function to judge if buffer realloc is needed for HEVC codec
789     //!
790     //! \param    [in] bufferType
791     //!          HEVC Buffer type
792     //! \param    [in, out] reallocParam
793     //!          HCP Re-allocate parameters
794     //!
795     //! \return   MOS_STATUS
796     //!           MOS_STATUS_SUCCESS if success, else fail reason
797     //!
798     virtual MOS_STATUS IsHevcBufferReallocNeeded(
799         MHW_VDBOX_HCP_INTERNAL_BUFFER_TYPE   bufferType,
800         PMHW_VDBOX_HCP_BUFFER_REALLOC_PARAMS reallocParam) = 0;
801 
802     //!
803     //! \brief    Get the required buffer size for VDBOX
804     //! \details  Internal function to judge if buffer realloc is needed for VP9 codec
805     //!
806     //! \param    [in] bufferType
807     //!           HEVC Buffer type
808     //! \param    [in, out] reallocParam
809     //!           HCP Re-allocate parameters
810     //!
811     //! \return   MOS_STATUS
812     //!           MOS_STATUS_SUCCESS if success, else fail reason
813     //!
814     virtual MOS_STATUS IsVp9BufferReallocNeeded(
815         MHW_VDBOX_HCP_INTERNAL_BUFFER_TYPE   bufferType,
816         PMHW_VDBOX_HCP_BUFFER_REALLOC_PARAMS reallocParam) = 0;
817 
818     //!
819     //! \brief    Adds HCP Pipe Pipe Mode Select command in command buffer
820     //! \details  Client facing function to add HCP Pipe Mode Select command in command buffer
821     //!
822     //! \param    [in] cmdBuffer
823     //!           Command buffer to which HW command is added
824     //! \param    [in] params
825     //!           Params structure used to populate the HW command
826     //!
827     //! \return   MOS_STATUS
828     //!           MOS_STATUS_SUCCESS if success, else fail reason
829     //!
830     MOS_STATUS AddHcpSurfaceCmd(
831         PMOS_COMMAND_BUFFER                  cmdBuffer,
832         PMHW_VDBOX_SURFACE_PARAMS            params);
833 
834     //!
835     //! \brief    Adds HCP slice state command in command buffer
836     //! \details  Client facing function to add HCP slice state command in command buffer
837     //!
838     //! \param    [in] cmdBuffer
839     //!           Command buffer to which HW command is added
840     //! \param    [in] hevcSliceState
841     //!           Params structure used to populate the HW command
842     //!
843     //! \return   MOS_STATUS
844     //!           MOS_STATUS_SUCCESS if success, else fail reason
845     //!
846     MOS_STATUS AddHcpSliceStateCmd(
847         PMOS_COMMAND_BUFFER              cmdBuffer,
848         PMHW_VDBOX_HEVC_SLICE_STATE      hevcSliceState);
849 
850     //!
851     //! \brief    Adds HCP picture State command in command buffer
852     //! \details  Client facing function to add HCP picture State command for encode in command buffer
853     //!
854     //! \param    [in] cmdBuffer
855     //!           Command buffer to which HW command is added
856     //! \param    [in] params
857     //!           Params structure used to populate the HW command
858     //!
859     //! \return   MOS_STATUS
860     //!           MOS_STATUS_SUCCESS if success, else fail reason
861     //!
862     MOS_STATUS AddHcpPicStateCmd(
863         PMOS_COMMAND_BUFFER              cmdBuffer,
864         PMHW_VDBOX_HEVC_PIC_STATE        params);
865 
866     //!
867     //! \brief    Adds HCP Protect State command in command buffer
868     //! \details  Client facing function to add HCP picture State command for encode in command buffer
869     //!
870     //! \param    [in] cmdBuffer
871     //!           Command buffer to which HW command is added
872     //! \param    [in] hevcSliceState
873     //!           Params structure used to populate the HW command
874     //!
875     //! \return   MOS_STATUS
876     //!           MOS_STATUS_SUCCESS if success, else fail reason
877     //!
878     MOS_STATUS AddHcpProtectStateCmd(
879         PMOS_COMMAND_BUFFER              cmdBuffer,
880         PMHW_VDBOX_HEVC_SLICE_STATE      hevcSliceState);
881 
882     //!
883     //! \brief    Programs base address of rowstore scratch buffers
884     //! \details  Internal function to get base address of rowstore scratch buffers
885     //!
886     //! \param    [in] rowstoreParams
887     //!           Rowstore parameters
888     //!
889     //! \return   MOS_STATUS
890     //!           MOS_STATUS_SUCCESS if success, else fail reason
891     //!
892     virtual MOS_STATUS GetRowstoreCachingAddrs(
893         PMHW_VDBOX_ROWSTORE_PARAMS rowstoreParams) = 0;
894 
895     //!
896     //! \brief    Adds HCP Pipe Pipe Mode Select command in command buffer
897     //!
898     //! \param    [in] cmdBuffer
899     //!           Command buffer to which HW command is added
900     //! \param    [in] params
901     //!           Params structure used to populate the HW command
902     //!
903     //! \return   MOS_STATUS
904     //!           MOS_STATUS_SUCCESS if success, else fail reason
905     //!
906     virtual MOS_STATUS AddHcpPipeModeSelectCmd(
907         PMOS_COMMAND_BUFFER                  cmdBuffer,
908         PMHW_VDBOX_PIPE_MODE_SELECT_PARAMS   params) = 0;
909 
910     //!
911     //! \brief    Adds HCP Surface State command for decode in command buffer
912     //!
913     //! \param    [in] cmdBuffer
914     //!           Command buffer to which HW command is added
915     //! \param    [in] params
916     //!           Params structure used to populate the HW command
917     //!
918     //! \return   MOS_STATUS
919     //!           MOS_STATUS_SUCCESS if success, else fail reason
920     //!
921     virtual MOS_STATUS AddHcpDecodeSurfaceStateCmd(
922         PMOS_COMMAND_BUFFER                  cmdBuffer,
923         PMHW_VDBOX_SURFACE_PARAMS            params) = 0;
924 
925     //!
926     //! \brief    Adds HCP Surface State command for encode in command buffer
927     //!
928     //! \param    [in] cmdBuffer
929     //!           Command buffer to which HW command is added
930     //! \param    [in] params
931     //!           Params structure used to populate the HW command
932     //!
933     //! \return   MOS_STATUS
934     //!           MOS_STATUS_SUCCESS if success, else fail reason
935     //!
936     virtual MOS_STATUS AddHcpEncodeSurfaceStateCmd(
937         PMOS_COMMAND_BUFFER                  cmdBuffer,
938         PMHW_VDBOX_SURFACE_PARAMS            params) = 0;
939 
940     //!
941     //! \brief    Adds HCP Pipe Buffer Address State command in command buffer
942     //!
943     //! \param    [in] cmdBuffer
944     //!           Command buffer to which HW command is added
945     //! \param    [in] params
946     //!           Params structure used to populate the HW command
947     //!
948     //! \return   MOS_STATUS
949     //!           MOS_STATUS_SUCCESS if success, else fail reason
950     //!
951     virtual MOS_STATUS AddHcpPipeBufAddrCmd(
952         PMOS_COMMAND_BUFFER                  cmdBuffer,
953         PMHW_VDBOX_PIPE_BUF_ADDR_PARAMS      params) = 0;
954 
955     //!
956     //! \brief    Adds HCP Indirect Object Base Address State command in command buffer
957     //!
958     //! \param    [in] cmdBuffer
959     //!           Command buffer to which HW command is added
960     //! \param    [in] params
961     //!           Params structure used to populate the HW command
962     //!
963     //! \return   MOS_STATUS
964     //!           MOS_STATUS_SUCCESS if success, else fail reason
965     //!
966     virtual MOS_STATUS AddHcpIndObjBaseAddrCmd(
967         PMOS_COMMAND_BUFFER                  cmdBuffer,
968         PMHW_VDBOX_IND_OBJ_BASE_ADDR_PARAMS  params) = 0;
969 
970     //!
971     //! \brief    Adds HCP QM State command in command buffer
972     //!
973     //! \param    [in] cmdBuffer
974     //!          Command buffer to which HW command is added
975     //! \param    [in] params
976     //!          Params structure used to populate the HW command
977     //! \return   MOS_STATUS
978     //!           MOS_STATUS_SUCCESS if success, else fail reason
979     //!
980     virtual MOS_STATUS AddHcpQmStateCmd(
981         PMOS_COMMAND_BUFFER                  cmdBuffer,
982         PMHW_VDBOX_QM_PARAMS                 params) = 0;
983 
984     //!
985     //! \brief    Adds HCP FQM State command in command buffer
986     //!
987     //! \param    [in] cmdBuffer
988     //!           Command buffer to which HW command is added
989     //! \param    [in] params
990     //!           Params structure used to populate the HW command
991     //!
992     //! \return   MOS_STATUS
993     //!           MOS_STATUS_SUCCESS if success, else fail reason
994     //!
995     virtual MOS_STATUS AddHcpFqmStateCmd(
996         PMOS_COMMAND_BUFFER                  cmdBuffer,
997         PMHW_VDBOX_QM_PARAMS                 params) = 0;
998 
999     //!
1000     //! \brief    Adds HCP picture State command for decode in command buffer
1001     //!
1002     //! \param    [in] cmdBuffer
1003     //!           Command buffer to which HW command is added
1004     //! \param    [in] params
1005     //!           Params structure used to populate the HW command
1006     //!
1007     //! \return   MOS_STATUS
1008     //!           MOS_STATUS_SUCCESS if success, else fail reason
1009     //!
1010     virtual MOS_STATUS AddHcpDecodePicStateCmd(
1011         PMOS_COMMAND_BUFFER              cmdBuffer,
1012         PMHW_VDBOX_HEVC_PIC_STATE        params) = 0;
1013 
1014     //!
1015     //! \brief    Adds HCP picture State command for encode in command buffer
1016     //!
1017     //! \param    [in] cmdBuffer
1018     //!           Command buffer to which HW command is added
1019     //! \param    [in] params
1020     //!           Params structure used to populate the HW command
1021     //!
1022     //! \return   MOS_STATUS
1023     //!           MOS_STATUS_SUCCESS if success, else fail reason
1024     //!
1025     virtual MOS_STATUS AddHcpEncodePicStateCmd(
1026         PMOS_COMMAND_BUFFER              cmdBuffer,
1027         PMHW_VDBOX_HEVC_PIC_STATE        params) = 0;
1028 
1029     //!
1030     //! \brief    Adds HCP tile State command in command buffer
1031     //!
1032     //! \param    [in] cmdBuffer
1033     //!           Command buffer to which HW command is added
1034     //! \param    [in] params
1035     //!           Params structure used to populate the HW command
1036     //!
1037     //! \return   MOS_STATUS
1038     //!           MOS_STATUS_SUCCESS if success, else fail reason
1039     //!
1040     virtual MOS_STATUS AddHcpTileStateCmd(
1041         PMOS_COMMAND_BUFFER              cmdBuffer,
1042         PMHW_VDBOX_HEVC_TILE_STATE       params) = 0;
1043 
1044     //!
1045     //! \brief    Adds HCP reference frame index command in command buffer
1046     //!
1047     //! \param    [in] cmdBuffer
1048     //!           Command buffer to which HW command is added
1049     //! \param    [in] batchBuffer
1050     //!           Batch buffer to add to VDBOX_BUFFER_START
1051     //! \param    [in] params
1052     //!           Params structure used to populate the HW command
1053     //!
1054     //! \return   MOS_STATUS
1055     //!           MOS_STATUS_SUCCESS if success, else fail reason
1056     //!
1057     virtual MOS_STATUS AddHcpRefIdxStateCmd(
1058         PMOS_COMMAND_BUFFER              cmdBuffer,
1059         PMHW_BATCH_BUFFER                batchBuffer,
1060         PMHW_VDBOX_HEVC_REF_IDX_PARAMS   params) = 0;
1061 
1062     //!
1063     //! \brief    Adds HCP weight offset state command in command buffer
1064     //!
1065     //! \param    [in] cmdBuffer
1066     //!           Command buffer to which HW command is added
1067     //! \param    [in] batchBuffer
1068     //!           Batch buffer to add to VDBOX_BUFFER_START
1069     //! \param    [in] params
1070     //!           Params structure used to populate the HW command
1071     //!
1072     //! \return   MOS_STATUS
1073     //!           MOS_STATUS_SUCCESS if success, else fail reason
1074     //!
1075     virtual MOS_STATUS AddHcpWeightOffsetStateCmd(
1076         PMOS_COMMAND_BUFFER                  cmdBuffer,
1077         PMHW_BATCH_BUFFER                    batchBuffer,
1078         PMHW_VDBOX_HEVC_WEIGHTOFFSET_PARAMS  params) = 0;
1079 
1080     //!
1081     //! \brief    Adds HCP slice state command for decode in command buffer
1082     //!
1083     //! \param    [in] cmdBuffer
1084     //!           Command buffer to which HW command is added
1085     //! \param    [in] hevcSliceState
1086     //!           Params structure used to populate the HW command
1087     //!
1088     //! \return   MOS_STATUS
1089     //!           MOS_STATUS_SUCCESS if success, else fail reason
1090     //!
1091     virtual MOS_STATUS AddHcpDecodeSliceStateCmd(
1092         PMOS_COMMAND_BUFFER              cmdBuffer,
1093         PMHW_VDBOX_HEVC_SLICE_STATE      hevcSliceState) = 0;
1094 
1095     //!
1096     //! \brief    Adds HCP slice state command for encode in command buffer
1097     //!
1098     //! \param    [in] cmdBuffer
1099     //!           Command buffer to which HW command is added
1100     //! \param    [in] hevcSliceState
1101     //!           Params structure used to populate the HW command
1102     //!
1103     //! \return   MOS_STATUS
1104     //!           MOS_STATUS_SUCCESS if success, else fail reason
1105     //!
1106     virtual MOS_STATUS AddHcpEncodeSliceStateCmd(
1107         PMOS_COMMAND_BUFFER              cmdBuffer,
1108         PMHW_VDBOX_HEVC_SLICE_STATE      hevcSliceState) = 0;
1109 
1110     //!
1111     //! \brief    Adds HCP Protect state command for decode in command buffer
1112     //!
1113     //! \param    [in] cmdBuffer
1114     //!           Command buffer to which HW command is added
1115     //! \param    [in] hevcSliceState
1116     //!           Params structure used to populate the HW command
1117     //!
1118     //! \return   MOS_STATUS
1119     //!           MOS_STATUS_SUCCESS if success, else fail reason
1120     //!
1121     virtual MOS_STATUS AddHcpDecodeProtectStateCmd(
1122         PMOS_COMMAND_BUFFER              cmdBuffer,
1123         PMHW_VDBOX_HEVC_SLICE_STATE      hevcSliceState) = 0;
1124 
1125     //!
1126     //! \brief    Adds HCP BSD object state command in command buffer
1127     //!
1128     //! \param    [in] cmdBuffer
1129     //!           Command buffer to which HW command is added
1130     //! \param    [in] params
1131     //!           Params structure used to populate the HW command
1132     //!
1133     //! \return   MOS_STATUS
1134     //!           MOS_STATUS_SUCCESS if success, else fail reason
1135     //!
1136     virtual MOS_STATUS AddHcpBsdObjectCmd(
1137         PMOS_COMMAND_BUFFER              cmdBuffer,
1138         PMHW_VDBOX_HCP_BSD_PARAMS        params) = 0;
1139 
1140     //!
1141     //! \brief    Adds HCP Pak insert object State command foe encode in command buffer
1142     //!
1143     //! \param    [in] cmdBuffer
1144     //!           Command buffer to which HW command is added
1145     //! \param    [in] params
1146     //!           Params structure used to populate the HW command
1147     //!
1148     //! \return   MOS_STATUS
1149     //!           MOS_STATUS_SUCCESS if success, else fail reason
1150     //!
1151     virtual MOS_STATUS AddHcpPakInsertObject(
1152         PMOS_COMMAND_BUFFER              cmdBuffer,
1153         PMHW_VDBOX_PAK_INSERT_PARAMS     params) = 0;
1154 
1155     //!
1156     //! \brief    Adds VP9 picture state command for decode in command buffer
1157     //!
1158     //! \param    [in]  cmdBuffer
1159     //!           Command buffer to which HW command is added
1160     //! \param    [in]  batchBuffer
1161     //!           Batch buffer to which HW command is added
1162     //! \param    [in]  params
1163     //!           Params structure used to populate the HW command
1164     //!
1165     //! \return   MOS_STATUS
1166     //!           MOS_STATUS_SUCCESS if success, else fail reason
1167     //!
1168     virtual MOS_STATUS AddHcpVp9PicStateCmd(
1169         PMOS_COMMAND_BUFFER              cmdBuffer,
1170         PMHW_BATCH_BUFFER                batchBuffer,
1171         PMHW_VDBOX_VP9_PIC_STATE         params) = 0;
1172 
1173     //!
1174     //! \brief    Adds VP9 picture state command for encode in command buffer
1175     //!
1176     //! \param    [in] cmdBuffer
1177     //!           Command buffer to which HW command is added
1178     //! \param    [in] batchBuffer
1179     //!           Batch buffer to which HW command is added
1180     //! \param    [in] params
1181     //!           Params structure used to populate the HW command
1182     //! \return   MOS_STATUS
1183     //!           MOS_STATUS_SUCCESS if success, else fail reason
1184     //!
1185     virtual MOS_STATUS AddHcpVp9PicStateEncCmd(
1186         PMOS_COMMAND_BUFFER              cmdBuffer,
1187         PMHW_BATCH_BUFFER                batchBuffer,
1188         PMHW_VDBOX_VP9_ENCODE_PIC_STATE  params) = 0;
1189 
1190     //!
1191     //! \brief    Adds VP9 segment state command for decode in command buffer
1192     //!
1193     //! \param    [in] cmdBuffer
1194     //!           Command buffer to which HW command is added
1195     //! \param    [in] batchBuffer
1196     //!           Batch buffer to which HW command is added
1197     //! \param    [in] params
1198     //!           Params structure used to populate the HW command
1199     //!
1200     //! \return   MOS_STATUS
1201     //!           MOS_STATUS_SUCCESS if success, else fail reason
1202     //!
1203     virtual MOS_STATUS AddHcpVp9SegmentStateCmd(
1204         PMOS_COMMAND_BUFFER              cmdBuffer,
1205         PMHW_BATCH_BUFFER                batchBuffer,
1206         PMHW_VDBOX_VP9_SEGMENT_STATE     params) = 0;
1207 
1208     //!
1209     //! \brief    Adds VP9 RDOQ state command for encode in command buffer
1210     //!
1211     //! \param    [in] cmdBuffer
1212     //!           Command buffer to which HW command is added
1213     //! \param    [in] params
1214     //!           Params structure used to populate the HW command
1215     //!
1216     //! \return   MOS_STATUS
1217     //!           MOS_STATUS_SUCCESS if success, else fail reason
1218     //!
1219     virtual MOS_STATUS AddHcpHevcVp9RdoqStateCmd(
1220         PMOS_COMMAND_BUFFER              cmdBuffer,
1221         PMHW_VDBOX_HEVC_PIC_STATE        params) = 0;
1222 
1223     //!
1224     //! \brief    Adds HEVC Brc buffer
1225     //!
1226     //! \param    [in] hcpImgStates
1227     //!           Resource to which Brc buffer is added
1228     //! \param    [in] hevcPicState
1229     //!           Params structure used to add the Brc buffer
1230     //!
1231     //! \return   MOS_STATUS
1232     //!           MOS_STATUS_SUCCESS if success, else fail reason
1233     //!
1234     virtual MOS_STATUS AddHcpHevcPicBrcBuffer(
1235         PMOS_RESOURCE                    hcpImgStates,
1236         PMHW_VDBOX_HEVC_PIC_STATE         hevcPicState) = 0;
1237 
1238     //!
1239     //! \brief    Get OsResLaceOrAceOrRgbHistogramBuffer Size
1240     //!
1241     //! \param    [in] width
1242     //!           Width of Surface
1243     //! \param    [in] height
1244     //!           Height of Surface
1245     //! \param    [out] size
1246     //!           Size of OsResLaceOrAceOrRgbHistogramBuffer
1247     //!
1248     //! \return   MOS_STATUS
1249     //!           MOS_STATUS_SUCCESS if success, else fail reason
1250     //!
1251     virtual MOS_STATUS GetOsResLaceOrAceOrRgbHistogramBufferSize(
1252         uint32_t                         width,
1253         uint32_t                         height,
1254         uint32_t                        *size) = 0;
1255 
1256     //!
1257     //! \brief    Get OsResStatisticsOutputBuffer Size
1258     //!
1259     //! \param    [in] width
1260     //!           Width of Surface
1261     //! \param    [in] height
1262     //!           Height of Surface
1263     //! \param    [out] size
1264     //!           Size of OsResStatisticsOutputBuffer
1265     //!
1266     //! \return   MOS_STATUS
1267     //!           MOS_STATUS_SUCCESS if success, else fail reason
1268     //!
1269     virtual MOS_STATUS GetOsResStatisticsOutputBufferSize(
1270         uint32_t                         width,
1271         uint32_t                         height,
1272         uint32_t                        *size) = 0;
1273 };
1274 
1275 #endif
1276