1 /*
2 * Copyright (c) 2020-2021 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 //!
24 //! \file     vp_feature_caps.h
25 //! \brief    Defines the common interface for vp features caps on diff engines
26 //! \details  The vp feature caps is designed based on vp engines
27 //!           this file is for the base interface which is shared by all components.
28 //!
29 #ifndef __VP_FEATURE_CAPS_H__
30 #define __VP_FEATURE_CAPS_H__
31 #include "vp_utils.h"
32 #include "mos_resource_defs.h"
33 
34 #define SUPPORTED 1
35 #define UNSUPPORTED 0
36 
37 #define VP_SFC_RESOLUTION_FEASIBLE(_InputWidth, _InputHeight, _OutputWidth, _OutputHeight, _90D_Rotation)    \
38 
39 
40 #define VP_FF_SFC_FORMAT(SurfaceFormat, bInput, bOutput, _MaxResolution, _InputMinResolution, _OutputMinResolution, _HorizUnit, _VertUnit, _RotationSupported, _MirrorSupported, _CscSupported, _ScalingSupported, \
41                       _SrcAlphaSupported, _ConstAlphaSupported, _IScalingSupported, _DetheringSupported, _IefSupported, _Max_ScalingRatio, _Min_ScalingRatio)     \
42         {                                                                                                                   \
43             sfcHwEntry[SurfaceFormat].inputSupported                            = bInput;                                   \
44             sfcHwEntry[SurfaceFormat].outputSupported                           = bOutput;                                  \
45             sfcHwEntry[SurfaceFormat].maxResolution                             = _MaxResolution;                           \
46             sfcHwEntry[SurfaceFormat].inputMinResolution                        = _InputMinResolution;                      \
47             sfcHwEntry[SurfaceFormat].outputMinResolution                       = _OutputMinResolution;                     \
48             sfcHwEntry[SurfaceFormat].horizontalAlignUnit                       = _HorizUnit;                               \
49             sfcHwEntry[SurfaceFormat].verticalAlignUnit                         = _VertUnit;                                \
50             sfcHwEntry[SurfaceFormat].rotationSupported                         = _RotationSupported;                       \
51             sfcHwEntry[SurfaceFormat].mirrorSupported                           = _MirrorSupported;                         \
52             sfcHwEntry[SurfaceFormat].cscSupported                              = _CscSupported;                            \
53             sfcHwEntry[SurfaceFormat].scalingSupported                          = _ScalingSupported;                        \
54             sfcHwEntry[SurfaceFormat].sourceAlphaSupported                      = _SrcAlphaSupported;                       \
55             sfcHwEntry[SurfaceFormat].constAlphaSupported                       = _ConstAlphaSupported;                     \
56             sfcHwEntry[SurfaceFormat].iScalingSupported                         = _IScalingSupported;                       \
57             sfcHwEntry[SurfaceFormat].detheringSupported                        = _DetheringSupported;                      \
58             sfcHwEntry[SurfaceFormat].minScalingRatio                           = _Min_ScalingRatio;                        \
59             sfcHwEntry[SurfaceFormat].maxScalingRatio                           = _Max_ScalingRatio;                        \
60             sfcHwEntry[SurfaceFormat].iefSupported                              = _IefSupported;                            \
61         }                                                                                                                   \
62 
63 enum VP_TILE_MODE_MASK
64 {
65     VP_TILE_MODE_MASK_UNUSED = 0,  // 000
66     VP_TILE_MODE_MASK_TILE4  = 1,  // 001 1st bit: tile4
67     VP_TILE_MODE_MASK_TILE64 = 2,  // 010 2nd bit: tile64
68     VP_TILE_MODE_MASK_LINEAR = 4   // 100 3rd bit linear
69 };
70 
71 //!
72 //! \ brief VP SFC Tile Mode Format support
73 //!
74 enum VP_SFC_OUTUT_SUPPORT
75 {
76     VP_SFC_OUTPUT_SUPPORT_NONE      = 0,
77     VP_SFC_OUTPUT_SUPPORT_TILE_ONLY = (VP_TILE_MODE_MASK_TILE4 | VP_TILE_MODE_MASK_TILE64),
78     VP_SFC_OUTPUT_SUPPORT_ALL       = (VP_TILE_MODE_MASK_TILE4 | VP_TILE_MODE_MASK_TILE64 | VP_TILE_MODE_MASK_LINEAR)
79 };
80 
VpGetFormatTileSupport(MOS_TILE_MODE_GMM tileMode)81 inline uint32_t VpGetFormatTileSupport(MOS_TILE_MODE_GMM tileMode)
82 {
83     switch (tileMode)
84     {
85     case MOS_TILE_64_GMM:      //tile64
86         return VP_TILE_MODE_MASK_TILE64;
87     case MOS_TILE_LINEAR_GMM:  //tilelinear
88         return VP_TILE_MODE_MASK_LINEAR;
89     case MOS_TILE_4_GMM:       // tile4
90     default:
91         return VP_TILE_MODE_MASK_TILE4;
92     }
93 }
94 
95 typedef struct VP_SFC_ENTRY_REC
96 {
97     bool                          inputSupported;
98     VP_SFC_OUTUT_SUPPORT          outputSupported;  // 1st bit: tile4, 2nd bit: tile64, 3rd bit linear
99     uint32_t                      maxResolution;
100     uint32_t                      inputMinResolution;
101     uint32_t                      outputMinResolution;
102     float                         maxScalingRatio;
103     float                         minScalingRatio;
104     uint32_t                      horizontalAlignUnit;
105     uint32_t                      verticalAlignUnit;
106     bool                          rotationSupported;
107     bool                          mirrorSupported;
108     bool                          cscSupported;
109     bool                          scalingSupported;
110     bool                          sourceAlphaSupported;
111     bool                          constAlphaSupported;
112     bool                          iScalingSupported;
113     bool                          detheringSupported;
114     bool                          iefSupported;
115 }VP_SFC_ENTRY_REC;
116 
117 #define VP_FF_VEBOX_FORMAT(SurfaceFormat, bInput, bOutput, _MaxWidth, _MaxHeight, _MinWidth, _MinHeight, _HorizUnit, _VertUnit, _HdrSupported, _CapturePipeSupported, \
118                            _DNSupported, _DISupported, _LACESupported, _FrontCscSupported, _BackEndCscSupported, _3DLutSupported, _IecpSupported, _bHsbMode, \
119                            _TCCSupported, _ACESupported, _STESupported, _CGCSupported)     \
120         {                                                                                                                   \
121             veboxHwEntry[SurfaceFormat].inputSupported                          = bInput;                                   \
122             veboxHwEntry[SurfaceFormat].outputSupported                         = bOutput;                                  \
123             veboxHwEntry[SurfaceFormat].maxWidth                                = _MaxWidth;                           \
124             veboxHwEntry[SurfaceFormat].maxHeight                               = _MaxHeight;                           \
125             veboxHwEntry[SurfaceFormat].minWidth                                = _MinWidth;                           \
126             veboxHwEntry[SurfaceFormat].minHeight                               = _MinHeight;                           \
127             veboxHwEntry[SurfaceFormat].horizontalAlignUnit                     = _HorizUnit;                               \
128             veboxHwEntry[SurfaceFormat].verticalAlignUnit                       = _VertUnit;                                \
129             veboxHwEntry[SurfaceFormat].hdrSupported                            = _HdrSupported;                            \
130             veboxHwEntry[SurfaceFormat].capturePipeSupported                    = _CapturePipeSupported;                    \
131             veboxHwEntry[SurfaceFormat].denoiseSupported                        = _DNSupported;                             \
132             veboxHwEntry[SurfaceFormat].deinterlaceSupported                    = _DISupported;                             \
133             veboxHwEntry[SurfaceFormat].laceSupported                           = _LACESupported;                           \
134             veboxHwEntry[SurfaceFormat].frontCscSupported                       = _FrontCscSupported;                       \
135             veboxHwEntry[SurfaceFormat].backEndCscSupported                     = _BackEndCscSupported;                     \
136             veboxHwEntry[SurfaceFormat].b3dLutSupported                         = _3DLutSupported;                          \
137             veboxHwEntry[SurfaceFormat].iecp                                    = _IecpSupported;                           \
138             veboxHwEntry[SurfaceFormat].hsb                                     = _bHsbMode;                                \
139             veboxHwEntry[SurfaceFormat].tccSupported                            = _TCCSupported;                            \
140             veboxHwEntry[SurfaceFormat].aceSupported                            = _ACESupported;                            \
141             veboxHwEntry[SurfaceFormat].tccSupported                            = _TCCSupported;                            \
142             veboxHwEntry[SurfaceFormat].steSupported                            = _STESupported;                            \
143             veboxHwEntry[SurfaceFormat].cgcSupported                            = _CGCSupported;                            \
144         }                                                                                                                   \
145 
146 typedef struct VP_VEBOX_ENTRY_REC
147 {
148     bool                          inputSupported;
149     bool                          outputSupported;
150     uint32_t                      maxWidth;
151     uint32_t                      maxHeight;
152     uint32_t                      minWidth;
153     uint32_t                      minHeight;
154     float                         maxScalingRatio;
155     float                         minScalingRatio;
156     uint32_t                      horizontalAlignUnit;
157     uint32_t                      verticalAlignUnit;
158     bool                          hdrSupported; // Gamut Expansion, HDR and Forward Gamma Correction are mutually exclusive.
159     bool                          capturePipeSupported;
160     bool                          denoiseSupported;
161     bool                          deinterlaceSupported;
162     bool                          laceSupported;
163     bool                          frontCscSupported;
164     bool                          backEndCscSupported;
165     bool                          b3dLutSupported;
166     bool                          iecp;// all IECP features like procamp/STD/Gamut etc
167     bool                          hsb;// high speed bypass mode
168     bool                          tccSupported;
169     bool                          aceSupported;
170     bool                          steSupported;
171     bool                          cgcSupported;
172 }VP_VEBOX_ENTRY_REC;
173 
174 struct VP_POLICY_RULES
175 {
176     struct
177     {
178         struct
179         {
180             bool enable = false;                            // true if enable 2 pass scaling.
181             struct
182             {
183                 float ratioFor1stPass  = 0;                 // scaling ratio for 1st pass when 2 pass downscaling needed. valid value in [minSfcScalingRatio, 1).
184                 float minRatioEnlarged = 0;                 // min ratio enlarged according to minSfcScalingRatio. valid value is [ratioFor1stPass, 1).
185                                                             // minRatio for 2 pass upscaling is minSfcScalingRatio * minRatioEnlarged.
186                 bool scalingIn1stPassIf1PassEnough = false; // For 1 pass enough case, if true, do scaling in 1st pass, otherwise, do scaling in 2nd pass.
187                                                             // e.g. ratioX being 1/2 and ratioY being 1/16, if true, width will do scaling in 1st pass,
188                                                             // otherwise, width will do scaling in 2nd pass
189             } downScaling;
190             struct
191             {
192                 float ratioFor1stPass  = 0;                 // scaling ratio for 1st pass when 2 pass upscaling needed. valid value in (1, maxSfcScalingRatio].
193                 float maxRatioEnlarged = 0;                 // Max ratio enlarged according to maxSfcScalingRatio. valid value is (1, ratioFor1stPass].
194                                                             // maxRatio for 2 pass upscaling is maxSfcScalingRatio * maxRatioEnlarged.
195                 bool scalingIn1stPassIf1PassEnough = false; // For 1 pass enough case, if true, do scaling in 1st pass, otherwise, do scaling in 2nd pass.
196                                                             // e.g. ratioX being 2 and ratioY being 16, if true, width will do scaling in 1st pass,
197                                                             // otherwise, width will do scaling in 2nd pass
198             } upScaling;
199         } scaling;
200         struct
201         {
202             bool enable = false;
203         } csc;
204     } sfcMultiPassSupport;
205 
206     bool isAvsSamplerSupported;
207     bool isHDR3DLutKernelEnabled;
208     bool is1K1DLutSurfaceInUse;
209     bool isHDR33LutSizeEnabled = false;
210 };
211 
212 struct VP_HW_CAPS
213 {
214     VP_SFC_ENTRY_REC    m_sfcHwEntry[Format_Count] = {};
215     VP_VEBOX_ENTRY_REC  m_veboxHwEntry[Format_Count] = {};
216     VP_POLICY_RULES     m_rules = {};
217 };
218 
219 #endif// __VP_FEATURE_CAPS_H__