1 /*
2 * Copyright (c) 2014-2017, 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_sfc.h
24 //! \brief    MHW interface for constructing commands for the SFC
25 //! \details  Impelements the functionalities common across all platforms for MHW_SFC
26 //!
27 #ifndef __MHW_SFC_H__
28 #define __MHW_SFC_H__
29 
30 #include "mhw_cp_interface.h"
31 #include "mhw_state_heap.h"
32 #include "mhw_utilities.h"
33 #include "mos_os.h"
34 #include "codec_def_common.h"
35 #include "codec_def_decode_jpeg.h"
36 
37 static const int   MHW_SFC_CACHELINE_SIZE    = 64;
38 static const int   MHW_SFC_MIN_HEIGHT        = 128;
39 static const int   MHW_SFC_MIN_WIDTH         = 128;
40 static const int   MHW_SFC_MAX_HEIGHT        = 4096;
41 static const int   MHW_SFC_MAX_WIDTH         = 4096;
42 static const int   MHW_SFC_VE_HEIGHT_ALIGN   = 4;
43 static const int   MHW_SFC_VE_WIDTH_ALIGN    = 16;
44 static const float MHW_SFC_MIN_SCALINGFACTOR = (1.0F / 8.0F);
45 static const float MHW_SFC_MAX_SCALINGFACTOR = 8.0F;
46 // After resuming from S3/S4, SFD surface is also need even scaled height smaller than 4160, such as 4154.
47 // Lower the MHW_SFC_SFD_BUFF_HEIGHT_BAR from 4160 to 4000 to ensure SFD surface can be allocated for such case.
48 static const uint32_t MHW_SFC_SFD_BUFF_HEIGHT_BAR = 4000;
49 
50 #define NEED_SFD_LINE_BUFFER(_SURFACE_HEIGHT) ((_SURFACE_HEIGHT) > MHW_SFC_SFD_BUFF_HEIGHT_BAR)
51 #define SFD_LINE_BUFFER_SIZE(_SURFACE_HEIGHT) (NEED_SFD_LINE_BUFFER(_SURFACE_HEIGHT) ? (uint32_t)ceil((_SURFACE_HEIGHT) * MHW_SFC_CACHELINE_SIZE / 10) : 0)
52 
53 typedef class MhwSfcInterface MHW_SFC_INTERFACE, *PMHW_SFC_INTERFACE;
54 
55 typedef enum _SFC_AVS_INPUT_SITING_COEF
56 {
57     SFC_AVS_INPUT_SITING_COEF_0_OVER_8 = 0x0,
58     SFC_AVS_INPUT_SITING_COEF_1_OVER_8 = 0x1,
59     SFC_AVS_INPUT_SITING_COEF_2_OVER_8 = 0x2,
60     SFC_AVS_INPUT_SITING_COEF_3_OVER_8 = 0x3,
61     SFC_AVS_INPUT_SITING_COEF_4_OVER_8 = 0x4,
62     SFC_AVS_INPUT_SITING_COEF_5_OVER_8 = 0x5,
63     SFC_AVS_INPUT_SITING_COEF_6_OVER_8 = 0x6,
64     SFC_AVS_INPUT_SITING_COEF_7_OVER_8 = 0x7,
65     SFC_AVS_INPUT_SITING_COEF_8_OVER_8 = 0x8
66 } SFC_AVS_INPUT_SITING_COEF, *PSFC_AVS_INPUT_SITING_COEF;
67 
68 //!
69 //! \brief  Structure to hold AVS Luma Filter Coeff, same as SFC_AVS_LUMA_FILTER_COEFF_G9
70 //!
71 typedef struct _SFC_AVS_LUMA_FILTER_COEFF
72 {
73     // DWORD 0
74     union
75     {
76         struct
77         {
78             uint32_t    Table0XFilterCoefficient0   : MHW_BITFIELD_RANGE(0,7);
79             uint32_t    Table0YFilterCoefficient0   : MHW_BITFIELD_RANGE(8,15);
80             uint32_t    Table0XFilterCoefficient1   : MHW_BITFIELD_RANGE(16,23);
81             uint32_t    Table0YFilterCoefficient1   : MHW_BITFIELD_RANGE(24,31);
82         };
83         struct
84         {
85             uint32_t    Value;
86         };
87     } DW0;
88 
89     // DWORD 1
90     union
91     {
92         struct
93         {
94             uint32_t    Table0XFilterCoefficient2   : MHW_BITFIELD_RANGE(0,7);
95             uint32_t    Table0YFilterCoefficient2   : MHW_BITFIELD_RANGE(8,15);
96             uint32_t    Table0XFilterCoefficient3   : MHW_BITFIELD_RANGE(16,23);
97             uint32_t    Table0YFilterCoefficient3   : MHW_BITFIELD_RANGE(24,31);
98         };
99         struct
100         {
101             uint32_t    Value;
102         };
103     } DW1;
104 
105     // DWORD 2
106     union
107     {
108         struct
109         {
110             uint32_t    Table0XFilterCoefficient4   : MHW_BITFIELD_RANGE(0,7);
111             uint32_t    Table0YFilterCoefficient4   : MHW_BITFIELD_RANGE(8,15);
112             uint32_t    Table0XFilterCoefficient5   : MHW_BITFIELD_RANGE(16,23);
113             uint32_t    Table0YFilterCoefficient5   : MHW_BITFIELD_RANGE(24,31);
114         };
115         struct
116         {
117             uint32_t    Value;
118         };
119     } DW2;
120 
121     // DWORD 3
122     union
123     {
124         struct
125         {
126             uint32_t    Table0XFilterCoefficient6   : MHW_BITFIELD_RANGE(0,7);
127             uint32_t    Table0YFilterCoefficient6   : MHW_BITFIELD_RANGE(8,15);
128             uint32_t    Table0XFilterCoefficient7   : MHW_BITFIELD_RANGE(16,23);
129             uint32_t    Table0YFilterCoefficient7   : MHW_BITFIELD_RANGE(24,31);
130         };
131         struct
132         {
133             uint32_t    Value;
134         };
135     } DW3;
136 } SFC_AVS_LUMA_FILTER_COEFF, *PSFC_AVS_LUMA_FILTER_COEFF;
137 
138 //!
139 //! \brief  Structure to hold AVS Chroma Filter Coeff, same as SFC_AVS_CHROMA_FILTER_COEFF_G9
140 //!
141 typedef struct _SFC_AVS_CHROMA_FILTER_COEFF
142 {
143     // DWORD 0
144     union
145     {
146         struct
147         {
148             uint32_t    Table1XFilterCoefficient2   : MHW_BITFIELD_RANGE(0,7);
149             uint32_t    Table1YFilterCoefficient2   : MHW_BITFIELD_RANGE(8,15);
150             uint32_t    Table1XFilterCoefficient3   : MHW_BITFIELD_RANGE(16,23);
151             uint32_t    Table1YFilterCoefficient3   : MHW_BITFIELD_RANGE(24,31);
152         };
153         struct
154         {
155             uint32_t    Value;
156         };
157     } DW0;
158 
159     // DWORD 1
160     union
161     {
162         struct
163         {
164             uint32_t    Table1XFilterCoefficient4   : MHW_BITFIELD_RANGE(0,7);
165             uint32_t    Table1YFilterCoefficient4   : MHW_BITFIELD_RANGE(8,15);
166             uint32_t    Table1XFilterCoefficient5   : MHW_BITFIELD_RANGE(16,23);
167             uint32_t    Table1YFilterCoefficient5   : MHW_BITFIELD_RANGE(24,31);
168         };
169         struct
170         {
171             uint32_t    Value;
172         };
173     } DW1;
174 } SFC_AVS_CHROMA_FILTER_COEFF, *PSFC_AVS_CHROMA_FILTER_COEFF;
175 
176 //!
177 //! \brief  Structure to hold AVS Luma Coeff tables
178 //!
179 typedef struct _MHW_SFC_AVS_LUMA_TABLE
180 {
181     uint8_t                      sfcPipeMode;                           //!< SFC Pipe Mode
182     SFC_AVS_LUMA_FILTER_COEFF    LumaTable[NUM_HW_POLYPHASE_TABLES];
183 } MHW_SFC_AVS_LUMA_TABLE, *PMHW_SFC_AVS_LUMA_TABLE;
184 
185 //!
186 //! \brief  Structure to hold AVS Chroma Coeff tables
187 //!
188 typedef struct _MHW_SFC_AVS_CHROMA_TABLE
189 {
190     uint8_t                      sfcPipeMode;                           //!< SFC Pipe Mode
191     SFC_AVS_CHROMA_FILTER_COEFF  ChromaTable[NUM_HW_POLYPHASE_TABLES];
192 } MHW_SFC_AVS_CHROMA_TABLE, *PMHW_SFC_AVS_CHROMA_TABLE;
193 
194 //!
195 //! \brief  Structure to hold AVS State
196 //!
197 typedef struct _MHW_SFC_AVS_STATE
198 {
199     uint8_t                         sfcPipeMode;                        //!< SFC Pipe Mode
200     uint32_t                        dwInputHorizontalSiting;
201     uint32_t                        dwInputVerticalSitting;
202     uint32_t                        dwAVSFilterMode;                   // Bilinear, 5x5 or 8x8
203 } MHW_SFC_AVS_STATE, *PMHW_SFC_AVS_STATE;
204 
205 //!
206 //! \brief  SFC State Command parameters
207 //!
208 typedef struct _MHW_SFC_STATE_PARAMS
209 {
210     uint8_t                         sfcPipeMode;                                //!< SFC Pipe Mode: VD-to-SFC or VE-to-SFC
211     uint32_t                        dwVDVEInputOrderingMode;
212     uint32_t                        dwInputChromaSubSampling;                   // Chroma subsampling at SFC input
213     float                           fAlphaPixel;                                // Alpha pixel
214     float                           fChromaSubSamplingXSiteOffset;              // Chroma siting X offset
215     float                           fChromaSubSamplingYSiteOffset;              // Chroma siting Y offset
216     uint32_t                        dwChromaDownSamplingMode;                   // Chroma Downsampling Mode
217     uint32_t                        dwChromaDownSamplingVerticalCoef;           // Chomra Downsampling Vertical Coef
218     uint32_t                        dwChromaDownSamplingHorizontalCoef;         // Chomra Downsampling Horizontal Coef
219 
220     uint32_t                        dwOutputFrameHeight;                        // Output Frame Height
221     uint32_t                        dwOutputFrameWidth;                         // Output Frame Width
222     MOS_FORMAT                      OutputFrameFormat;                          // Output Frame Format
223     uint32_t                        dwInputFrameHeight;                         // Input Frame Height
224     uint32_t                        dwInputFrameWidth;                          // Input Frame Width
225     MOS_FORMAT                      InputFrameFormat;                           // Input Frame Format
226 
227     // Scaling parameters
228     uint32_t                        dwAVSFilterMode;                            // Bilinear, 5x5 or 8x8
229     uint32_t                        dwSourceRegionHeight;                       // Source/Crop region height
230     uint32_t                        dwSourceRegionWidth;                        // Source/Crop region width
231     uint32_t                        dwSourceRegionVerticalOffset;               // Source/Crop region vertical offset
232     uint32_t                        dwSourceRegionHorizontalOffset;             // Source/Crop region horizontal offset
233     uint32_t                        dwScaledRegionHeight;                       // Scaled region height
234     uint32_t                        dwScaledRegionWidth;                        // Scaled region width
235     uint32_t                        dwScaledRegionVerticalOffset;               // Scaled region vertical offset
236     uint32_t                        dwScaledRegionHorizontalOffset;             // Scaled region horizontal offset
237     float                           fAVSXScalingRatio;                          // X Scaling Ratio
238     float                           fAVSYScalingRatio;                          // Y Scaling Ratio
239     bool                            bBypassXAdaptiveFilter;                     // If true, X direction will use Default Sharpness level to blend
240                                                                                 // b/w smooth and sharp filters rather than the calculated value
241     bool                            bBypassYAdaptiveFilter;                     // If true, Y direction will use Default Sharpness level to blend
242                                                                                 // b/w smooth and sharp filters rather than the calculated value
243     bool                            bRGBAdaptive;                               // If true, Enable the RGB Adaptive filter
244     // IEF params
245     bool                            bIEFEnable;                                 // IEF Filter enable
246     bool                            bSkinToneTunedIEFEnable;                    // Skin Tone Tuned IEF enable
247     bool                            bAVSChromaUpsamplingEnable;                 // Up sample chroma prior to IEF filter
248     bool                            b8tapChromafiltering;                       // This bit enables 8 tap filtering for Chroma Channels
249 
250     // Rotation Params
251     MHW_ROTATION                    RotationMode;                               // Rotation mode -- 0, 90, 180 or 270
252     uint32_t                        dwMirrorType;                               // Mirror Type -- vert/horiz
253     bool                            bMirrorEnable;                              // Mirror mode -- enable/disable
254 
255     // ColorFill params
256     bool                            bColorFillEnable;                           // ColorFill enable
257     float                           fColorFillYRPixel;                          // ColorFill Y/R pixel
258     float                           fColorFillUGPixel;                          // ColorFill U/G pixel
259     float                           fColorFillVBPixel;                          // ColorFill V/B pixel
260     float                           fColorFillAPixel;                           // ColorFill A pixel
261 
262     // CSC Params
263     bool                            bCSCEnable;                                 // YUV->RGB/YUV->YUV CSC enable
264     bool                            bRGBASwapEnable;                            // R, B Channel Swap enable
265     bool                            bInputColorSpace;                           //0: YUV color space, 1:RGB color space
266 
267     // Memory compression Enable Flag
268     bool                            bMMCEnable;                                 // Flag used to decide whether sfc output should be compressed
269     MOS_RESOURCE_MMC_MODE           MMCMode;                                    // Memory compression mode
270 
271     // Resources used by SFC
272     PMOS_RESOURCE                   pOsResOutputSurface;                        // Output Frame written by SFC
273     PMOS_RESOURCE                   pOsResAVSLineBuffer;                        // AVS Line buffer used by SFC
274     PMOS_RESOURCE                   pOsResIEFLineBuffer;                        // IEF Line buffer used by SFC
275 
276     uint32_t                        dwOutputSurfaceOffset;                      // Output Frame offset (page based offset)
277     uint16_t                        wOutputSurfaceUXOffset;                     // Output Frame offset (page internal U offset for X axis)
278     uint16_t                        wOutputSurfaceUYOffset;                     // Output Frame offset (page internal U offset for Y axis)
279     uint16_t                        wOutputSurfaceVXOffset;                     // Output Frame offset (page internal V offset for X axis)
280     uint16_t                        wOutputSurfaceVYOffset;                     // Output Frame offset (page internal V offset for Y axis)
281 
282 } MHW_SFC_STATE_PARAMS, *PMHW_SFC_STATE_PARAMS;
283 
284 //!
285 //! \brief  SFC Output Surface Command parameters
286 //!
287 typedef struct _MHW_SFC_OUT_SURFACE_PARAMS
288 {
289     uint32_t                    ChromaSiting;       //!<  Chroma siting
290     MOS_FORMAT                  Format;             //!<  Surface format
291     uint32_t                    dwWidth;            //!<  Surface width
292     uint32_t                    dwHeight;           //!<  Surface height
293     uint32_t                    dwPitch;            //!<  Surface pitch
294     MOS_TILE_TYPE               TileType;           //!<  Tile Type
295     MOS_TILE_MODE_GMM           TileModeGMM;        //!<  Tile Type from GMM Definition
296     bool                        bGMMTileEnabled;    //!<  GMM defined tile mode flag
297     uint32_t                    dwStreamID;         //!<  Surface StreamID
298     uint32_t                    dwSurfaceXOffset;   //!<  Surface X offset
299     uint32_t                    dwSurfaceYOffset;   //!<  Surface Y offset
300     uint32_t                    dwUYoffset;         //!<  Surface Uoffset in Vertical
301     uint32_t                    dwVUoffset;         //!<  Surface Voffset in Vertical, named by Vplane relative to Uplane
302     PMOS_RESOURCE               pOsResource;        //!<  Surface resource
303     bool                        bCompressible;      //!<  Surface can be compressed
304     uint32_t                    dwCompressionFormat;//!< Surface Compression format
305 } MHW_SFC_OUT_SURFACE_PARAMS, *PMHW_SFC_OUT_SURFACE_PARAMS;
306 
307 //!
308 //! \brief  SFC Lock Command parameters
309 //!
310 typedef struct _MHW_SFC_LOCK_PARAMS
311 {
312     uint8_t  sfcPipeMode;                                                        //!< SFC Pipe Mode
313     uint32_t dwGaClientId;                                                       // Ga Client Id
314     bool     bOutputToMemory;                                                    // Write Vebox or Vdbox o/p to memory
315 } MHW_SFC_LOCK_PARAMS, *PMHW_SFC_LOCK_PARAMS;
316 
317 //!
318 //! \brief  SFC IEF State parameters
319 //!
320 typedef struct _MHW_SFC_IEF_STATE_PARAMS
321 {
322     uint8_t                             sfcPipeMode;                            //!< SFC Pipe Mode
323 
324     // IEF params
325     bool                                bSkinDetailFactor;                      // Skin Detail Factor
326     bool                                bVYSTDEnable;                           // Enable STD in VY subspace
327     bool                                bIEFEnable;                             // Enable IEF
328     uint8_t                             StrongEdgeWeight;
329     uint8_t                             RegularWeight;
330     uint8_t                             StrongEdgeThreshold;
331     uint32_t                            dwGainFactor;
332     uint32_t                            dwR5xCoefficient;
333     uint32_t                            dwR5cxCoefficient;
334     uint32_t                            dwR5cCoefficient;
335     uint32_t                            dwR3xCoefficient;
336     uint32_t                            dwR3cCoefficient;
337 
338     // CSC params
339     bool                                bCSCEnable;                             // Enable CSC transform
340     float                               *pfCscCoeff;                             // [3x3] CSC Coeff matrix
341     float                               *pfCscInOffset;                          // [3x1] CSC Input Offset matrix
342     float                               *pfCscOutOffset;                         // [3x1] CSC Output Offset matrix
343 } MHW_SFC_IEF_STATE_PARAMS, *PMHW_SFC_IEF_STATE_PARAMS;
344 
345 class MhwSfcInterface
346 {
347 public:
~MhwSfcInterface()348     virtual ~MhwSfcInterface()
349     {
350     }
351 
352     //!
353     //! \brief    Adds a resource to the command buffer or indirect state (SSH)
354     //! \details  Internal MHW function to add either a graphics address of a resource or
355     //!           add the resource to the patch list for the requested buffer or state
356     //! \param    [in] pOsInterface
357     //!           OS interface
358     //! \param    [in] pCmdBuffer
359     //!           If adding a resource to the command buffer, the buffer to which the resource
360     //!           is added
361     //! \param    [in] pParams
362     //!           Parameters necessary to add the graphics address
363     //! \return   MOS_STATUS
364     //!           MOS_STATUS_SUCCESS if success, else fail reason
365     //!
366     MOS_STATUS(*pfnAddResourceToCmd) (
367         PMOS_INTERFACE                 pOsInterface,
368         PMOS_COMMAND_BUFFER            pCmdBuffer,
369         PMHW_RESOURCE_PARAMS           pParams);
370 
371     //!
372     //! \brief      Add SFC Lock
373     //! \param      [in] pCmdBuffer
374     //!             Pointer to Command buffer
375     //! \param      [in] pSfcLockParams
376     //!              Pointer to SFC_LOCK params
377     //! \return     MOS_STATUS
378     //!
379     virtual MOS_STATUS AddSfcLock (
380         PMOS_COMMAND_BUFFER            pCmdBuffer,
381         PMHW_SFC_LOCK_PARAMS           pSfcLockParams) = 0;
382 
383     //!
384     //! \brief    Add SFC State
385     //! \param    [in] pCmdBuffer
386     //!           Pointer to Command Buffer
387     //! \param    [in] pSfcStateParams
388     //!           Pointer to SFC_STATE params
389     //! \param    [in] pOutSurface
390     //!           Pointer to Output surface params
391     //! \return   MOS_STATUS
392     //!
393     virtual MOS_STATUS AddSfcState(
394         PMOS_COMMAND_BUFFER            pCmdBuffer,
395         PMHW_SFC_STATE_PARAMS          pSfcStateParams,
396         PMHW_SFC_OUT_SURFACE_PARAMS    pOutSurface) = 0;
397 
398     //!
399     //! \brief      Add SFC AVS State command
400     //! \param      [in] pCmdBuffer
401     //!             Pointer to Command Buffer
402     //! \param      [in] pSfcAvsState
403     //!             Pointer to SFC AVS State
404     //! \return     MOS_STATUS
405     //!
406     virtual MOS_STATUS AddSfcAvsState(
407         PMOS_COMMAND_BUFFER            pCmdBuffer,
408         PMHW_SFC_AVS_STATE             pSfcAvsState) = 0;
409 
410     //!
411     //! \brief      Add SFC Frame Start command
412     //! \param      [in] pCmdBuffer
413     //!             Pointer to Command Buffer
414     //! \param      [in] sfcPipeMode
415     //!             SFC pipe mode
416     //! \return     MOS_STATUS
417     //!
418     virtual MOS_STATUS AddSfcFrameStart (
419         PMOS_COMMAND_BUFFER            pCmdBuffer,
420         uint8_t                        sfcPipeMode) = 0;
421 
422     //!
423     //! \brief      Add SFC IEF State command
424     //! \param      [in] pCmdBuffer
425     //!             Pointer to Command Buffer
426     //! \param      [in] pSfcIefStateParams
427     //!             Pointer to IEF State params
428     //! \return     MOS_STATUS
429     //!
430     virtual MOS_STATUS AddSfcIefState(
431         PMOS_COMMAND_BUFFER            pCmdBuffer,
432         PMHW_SFC_IEF_STATE_PARAMS      pSfcIefStateParams) = 0;
433 
434     //!
435     //! \brief      Add SFC AVS Chroma Table command
436     //! \param      [in] pCmdBuffer
437     //!             Pointer to Command Buffer
438     //! \param      [in] pChromaTable
439     //!             Pointer to Chroma Coefficient table
440     //! \return     MOS_STATUS
441     //!
442     virtual MOS_STATUS AddSfcAvsChromaTable (
443         PMOS_COMMAND_BUFFER            pCmdBuffer,
444         PMHW_SFC_AVS_CHROMA_TABLE      pChromaTable) = 0;
445 
446     //!
447     //! \brief      Add SFC AVS Chroma Table command
448     //! \param      [in] pCmdBuffer
449     //!             Pointer to Command Buffer
450     //! \param      [in] pChromaTable
451     //!             Pointer to Chroma Coefficient table
452     //! \return     MOS_STATUS
453     //!
454     virtual MOS_STATUS AddSfcAvsLumaTable (
455         PMOS_COMMAND_BUFFER            pCmdBuffer,
456         PMHW_SFC_AVS_LUMA_TABLE        pLumaTable) = 0;
457 
458     //!
459     //! \brief      Set Sfc Sampler8x8 Table
460     //! \details    Set Sfc AVS Luma and Chroma table
461     //! \param      [out] pLumaTable
462     //!             Pointer to AVS luma table
463     //! \param      [out] pChromaTable
464     //!             Pointer to AVS chroma table
465     //! \param      [in] pAvsParams
466     //!             Pointer to AVS params
467     //! \param      [in] SrcFormat
468     //!             Input Source Format
469     //! \param      [in] fScaleX
470     //!             Scaling ratio in width
471     //! \param      [in] fScaleY
472     //!             Scaling ratio in height
473     //! \param      [in] dwChromaSiting
474     //!             Chroma Siting info
475     //! \return     MOS_STATUS
476     //!
477     virtual MOS_STATUS SetSfcSamplerTable (
478         PMHW_SFC_AVS_LUMA_TABLE         pLumaTable,
479         PMHW_SFC_AVS_CHROMA_TABLE       pChromaTable,
480         PMHW_AVS_PARAMS                 pAvsParams,
481         MOS_FORMAT                      SrcFormat,
482         float                           fScaleX,
483         float                           fScaleY,
484         uint32_t                        dwChromaSiting,
485         bool                            bUse8x8Filter,
486         float                           fHPStrength,
487         float                           fLanczosT);
488 
489     //!
490     //! \brief      Sets AVS Scaling Mode. Will configure the different coefficients of 8-Tap polyphase filter according to scaling mode.
491     //! \param      [in] ScalingMode
492     //!             AVS scaling mode e.g. Nearest, 8-Tap polyphase etc.
493     //! \return     MOS_STATUS
494     //!
SetSfcAVSScalingMode(MHW_SCALING_MODE ScalingMode)495     virtual MOS_STATUS SetSfcAVSScalingMode(
496         MHW_SCALING_MODE  ScalingMode)
497     {
498         m_scalingMode = ScalingMode;
499         return MOS_STATUS_SUCCESS;
500     }
501 
502     virtual MOS_STATUS GetInputFrameWidthHeightAlignUnit(uint32_t &widthAlignUnit, uint32_t &heightAlignUnit,
503         bool bVdbox, CODECHAL_STANDARD codecStandard, CodecDecodeJpegChromaType jpegChromaType);
504 
505     //!
506     //! \brief    Set Sfc Index
507     //! \details  Set Sfc Index
508     //! \param    [in] dwSfcIndex
509     //!           set Sfc Index
510     //! \param    [in] dwSfcCount
511     //!           set Sfc Count
512     //! \return   MOS_STATUS
513     //!           MOS_STATUS_SUCCESS if success, else fail reason
SetSfcIndex(uint32_t dwSfcIndex,uint32_t dwSfcCount)514     virtual MOS_STATUS SetSfcIndex(
515         uint32_t dwSfcIndex,
516         uint32_t dwSfcCount)
517     {
518         MOS_UNUSED(dwSfcIndex);
519         MOS_UNUSED(dwSfcCount);
520         return MOS_STATUS_SUCCESS;
521     }
522 
523 protected:
524 
525     MhwSfcInterface(PMOS_INTERFACE pOsInterface);
526 
527     //!
528     //! \brief      Sets AVS Luma Coefficient table
529     //! \param      [in] SrcFormat
530     //!             Source format
531     //! \param      [in] pCoeffTable
532     //!             Pointer to coefficient table
533     //! \param      [in] piYCoefsX
534     //!             Pointer to Y coefficients X
535     //! \param      [in] piYCoefsY
536     //!             Pointer to Y coefficients Y
537     //! \param      [in] bUse8x8Filter
538     //!             Is 8x8 Filter used
539     //! \return     void
540     //!
541     void SetSfcAVSLumaTable(
542         MOS_FORMAT                      SrcFormat,
543         PSFC_AVS_LUMA_FILTER_COEFF      pCoeffTable,
544         int32_t                         *piYCoefsX,
545         int32_t                         *piYCoefsY,
546         bool                            bUse8x8Filter);
547     //!
548     //! \brief      Sets AVS Chroma Coefficient table
549     //! \param      [in] pUVCoeffTable
550     //!             Pointer to UV coefficient table
551     //! \param      [in] piUVCoefsX
552     //!             Pointer to UV coefficients X
553     //! \param      [in] piUVCoefsY
554     //!             Pointer to UV coefficients Y
555     //! \return     void
556     //!
557     void SetSfcAVSChromaTable(
558         PSFC_AVS_CHROMA_FILTER_COEFF        pUVCoeffTable,
559         int32_t                             *piUVCoefsX,
560         int32_t                             *piUVCoefsY);
561 
562 public:
563     enum SFC_PIPE_MODE
564     {
565         SFC_PIPE_MODE_VDBOX = 0,
566         SFC_PIPE_MODE_VEBOX = 1
567     };
568 
569     enum SfcScalabMode
570     {
571         sfcScalabModeSingle = 0, //!< 0 - single pipe
572         sfcScalabModeLeftCol,    //!< 1 - left most column
573         sfcScalabModeRightCol,   //!< 2 - right most column
574         sfcScalabModeMiddleCol   //!< 3 - middle column
575     };
576 
577     enum SfcScalabTileType
578     {
579         sfcScalabRealTile = 0, //!< 0 - real tile
580         sfcScalabVirtualTile   //!< 1 - virtual tile
581     };
582 
583 public:
584     PMOS_INTERFACE                             m_osInterface       = nullptr;
585 
586     uint16_t                                   m_veWidthAlignment  = MHW_SFC_VE_WIDTH_ALIGN;
587     uint16_t                                   m_veHeightAlignment = MHW_SFC_VE_HEIGHT_ALIGN;
588     uint32_t                                   m_maxWidth          = MHW_SFC_MAX_WIDTH;
589     uint32_t                                   m_maxHeight         = MHW_SFC_MAX_HEIGHT;
590     uint32_t                                   m_minWidth          = MHW_SFC_MIN_WIDTH;
591     uint32_t                                   m_minHeight         = MHW_SFC_MIN_HEIGHT;
592 
593     float                                      m_maxScalingRatio   = MHW_SFC_MAX_SCALINGFACTOR;
594     float                                      m_minScalingRatio   = MHW_SFC_MIN_SCALINGFACTOR;
595 
596     MHW_MEMORY_OBJECT_CONTROL_PARAMS           m_outputSurfCtrl;          // Output Frame caching control bits
597     MHW_MEMORY_OBJECT_CONTROL_PARAMS           m_avsLineBufferCtrl;       // AVS Line Buffer caching control bits
598     MHW_MEMORY_OBJECT_CONTROL_PARAMS           m_iefLineBufferCtrl;       // IEF Line Buffer caching control bits
599     MHW_MEMORY_OBJECT_CONTROL_PARAMS           m_sfdLineBufferCtrl;       // SFD Line Buffer caching control bits
600     MHW_MEMORY_OBJECT_CONTROL_PARAMS           m_avsLineTileBufferCtrl;   // AVS Line Tile Buffer caching control bits
601     MHW_MEMORY_OBJECT_CONTROL_PARAMS           m_iefLineTileBufferCtrl;   // IEF Line Tile Buffer caching control bits
602     MHW_MEMORY_OBJECT_CONTROL_PARAMS           m_sfdLineTileBufferCtrl;   // SFD Line Tile Buffer caching control bits
603     MHW_MEMORY_OBJECT_CONTROL_PARAMS           m_histogramBufferCtrl;     // Histogram Buffer caching control bits
604 
605     MHW_SCALING_MODE                           m_scalingMode;
606 };
607 
608 #endif // __MHW_SFC_H__
609