Debian Codegraph @

media_common/agnostic/common/hw/mhw_vebox.h

raw
1 /*
2 * Copyright (c) 2014-2022, 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_vebox.h
24 //! \brief MHW interface for constructing commands for the VEBOX
25 //! \details Impelements the functionalities common across all platforms for MHW_VEBOX
26 //!
27
28 #ifndef __MHW_VEBOX_H__
29 #define __MHW_VEBOX_H__
30
31 #include "mos_os.h"
32 #include "mhw_utilities.h"
33 #include "mhw_cp_interface.h"
34 #include "mhw_mi.h"
35 #include <math.h>
36
37 #define MHW_FORWARD_GAMMA_SEGMENT_COUNT 1024 //!< Forward Gamma Correction MAX Control Points
38
39 //!
40 //! \brief VEBOX constants
41 //!
42 #define MHW_VEBOX_MIN_HEIGHT 16
43 #define MHW_VEBOX_MIN_WIDTH 64
44 #define MHW_VEBOX_LINEAR_PITCH 64
45 //!
46 //! \brief ACE constants
47 //!
48 #define MHW_NUM_ACE_PWLF_COEFF 5
49
50 //!
51 //! \brief Vebox DNDI constants
52 //!
53 #define DNDI_HISTORY_INITVALUE 0xFF
54
55 //!
56 //! \brief Vebox Denoise pixel range threshold numbers
57 //!
58 #define MHW_PIXRANGETHRES_NUM 6
59
60 //!
61 //! \brief STE Parameters
62 //!
63 #define MHW_STE_OPTIMAL 3 // for perfect HD-HQV Score
64
65 //!
66 //! \brief Default size of area for sync, debugging, performance collecting
67 //!
68 #define MHW_SYNC_SIZE 128 // range: (128 ... 4096)
69
70 //!
71 //! \brief Default number of media states (Dynamic GSH mode)
72 //!
73 #define MHW_MAX_VEBOX_STATES 16
74
75 //!
76 //! \brief Vebox engine class ID value from https://gfxspecs.intel.com/Predator/Home/Index/60421
77 //!
78 #define MHW_VEBOX_ENGINE_CLASS_ID 2
79
80 #define MHW_PI 3.14159265358979324f //!< Definition the const pi
81
82 //!
83 //! \def MHW_DEGREE_TO_RADIAN(degree)
84 //! Convert \a degree value to \a radian value.
85 //!
86 #define MHW_DEGREE_TO_RADIAN(degree) (degree) * (MHW_PI) / 180
87 #define AVS_TBL_COEF_PREC 6 //!< Table coef precision (after decimal point
88 #define SAME_SAMPLE_THRESHOLD 1000 //!< When checking whether 2 timestamps are the same, leave room for some error
89
90 #define MHW_VEBOX_WATCHDOG_ENABLE_COUNTER 0x0
91 #define MHW_VEBOX_WATCHDOG_DISABLE_COUNTER 0xFFFFFFFF
92 #define MHW_VEBOX_TIMEOUT_MS 60
93
94 #define HDR_OETF_1DLUT_POINT_NUMBER 256
95 #define MHW_FORWARD_GAMMA_SEGMENT_CONTROL_POINT 1024
96 #define MHW_VEBOX_STARTING_INDEX 0
97
98 typedef MhwMiInterface *PMHW_MI_INTERFACE;
99
100 //!
101 //! \brief Color Spaces enum
102 //!
103 typedef enum _MHW_CSPACE
104 {
105 MHW_CSpace_None = -5 , //!< Unidentified
106 MHW_CSpace_Source = -4 , //!< Current source Color Space
107
108 // Groups of Color Spaces
109 MHW_CSpace_RGB = -3 , //!< sRGB
110 MHW_CSpace_YUV = -2 , //!< YUV BT601 or BT709 - non xvYCC
111 MHW_CSpace_Gray = -1 , //!< Gray scale image with only Y component
112 MHW_CSpace_Any = 0 , //!< Any
113
114 // Specific Color Spaces
115 MHW_CSpace_sRGB , //!< RGB - sRGB - RGB[0,255]
116 MHW_CSpace_stRGB , //!< RGB - stRGB - RGB[16,235]
117 MHW_CSpace_BT601 , //!< YUV BT.601 Y[16,235] UV[16,240]
118 MHW_CSpace_BT601_FullRange , //!< YUV BT.601 Y[0,255] UV[-128,+127]
119 MHW_CSpace_BT709 , //!< YUV BT.709 Y[16,235] UV[16,240]
120 MHW_CSpace_BT709_FullRange , //!< YUV BT.709 Y[0,255] UV[-128,+127]
121 MHW_CSpace_xvYCC601 , //!< xvYCC 601 Y[16,235] UV[16,240]
122 MHW_CSpace_xvYCC709 , //!< xvYCC 709 Y[16,235] UV[16,240]
123 MHW_CSpace_BT601Gray , //!< BT.601 Y[16,235]
124 MHW_CSpace_BT601Gray_FullRange , //!< BT.601 Y[0,255]
125 MHW_CSpace_BT2020 , //!< BT.2020 YUV Limited Range 10bit Y[64, 940] UV[64, 960]
126 MHW_CSpace_BT2020_FullRange , //!< BT.2020 YUV Full Range 10bit [0, 1023]
127 MHW_CSpace_BT2020_RGB , //!< BT.2020 RGB Full Range 10bit [0, 1023]
128 MHW_CSpace_BT2020_stRGB , //!< BT.2020 RGB Studio Range 10bit [64, 940]
129 MHW_CSpace_Count //!< Keep this at the end
130 } MHW_CSPACE;
131 C_ASSERT(MHW_CSpace_Count == 15);
132
133 //!
134 //! \brief Gamut Mode enum
135 //!
136 typedef enum _MHW_GAMUT_MODE
137 {
138 MHW_GAMUT_MODE_NONE,
139 MHW_GAMUT_MODE_BASIC,
140 MHW_GAMUT_MODE_ADVANCED,
141 MHW_GAMUT_MODE_CUSTOMIZED
142 } MHW_GAMUT_MODE;
143 C_ASSERT(MHW_GAMUT_MODE_CUSTOMIZED == 3);
144
145 //!
146 //! \brief Gamma Values configuration enum
147 //!
148 typedef enum _MHW_GAMMA_VALUE
149 {
150 MHW_GAMMA_1P0 = 0,
151 MHW_GAMMA_2P2,
152 MHW_GAMMA_2P6
153 } MHW_GAMMA_VALUE;
154 C_ASSERT(MHW_GAMMA_2P6 == 2);
155
156 //!
157 //! \brief Structure to Vebox Mode
158 //!
159 typedef struct _MHW_VEBOX_MODE
160 {
161 uint32_t ColorGamutExpansionEnable : 1;
162 uint32_t ColorGamutCompressionEnable : 1;
163 uint32_t GlobalIECPEnable : 1;
164 uint32_t DNEnable : 1;
165 uint32_t DIEnable : 1;
166 uint32_t DNDIFirstFrame : 1;
167 uint32_t DIOutputFrames : 2;
168 uint32_t PipeSynchronizeDisable : 1;
169 uint32_t DemosaicEnable : 1; // Gen8+
170 uint32_t VignetteEnable : 1; // Gen8+
171 uint32_t AlphaPlaneEnable : 1;
172 uint32_t HotPixelFilteringEnable : 1; // Gen8+
173 uint32_t SingleSliceVeboxEnable : 2; // Gen9+
174 uint32_t LACECorrectionEnable : 1; // Gen9+
175 uint32_t DisableEncoderStatistics : 1; // Gen9+
176 uint32_t DisableTemporalDenoiseFilter : 1; // Gen9+
177 uint32_t SinglePipeIECPEnable : 1; // Gen9+
178 uint32_t SFCParallelWriteEnable : 1; // Gen9+
179 uint32_t ScalarMode : 1; // Gen10+
180 uint32_t ForwardGammaCorrectionEnable : 1; // Gen9+
181 uint32_t Hdr1DLutEnable : 1;
182 uint32_t Fp16ModeEnable : 1;
183 uint32_t Hdr1K1DLut : 1;
184 uint32_t GamutExpansionPosition : 1;
185 uint32_t EotfPrecision : 1;
186 uint32_t BypassCcm : 1;
187 uint32_t BypassOetf : 1;
188 uint32_t Eotf16LayoutMode : 1; // EOTF16 layout mode: 0=ARGB legacy, 1=RGBA new
189 uint32_t : 2; // Reserved
190 } MHW_VEBOX_MODE, *PMHW_VEBOX_MODE;
191
192 typedef enum _MHW_VEBOX_ADDRESS_SHIFT
193 {
194 MHW_VEBOX_DI_IECP_SHIFT = 12,
195 } MHW_VEBOX_ADDRESS_SHIFT;
196
197 //!
198 //! \brief Structure to Chroma Sampling to handle VEBOX_STATE_CMD Command
199 //!
200 typedef struct _MHW_VEBOX_CHROMA_SAMPLING
201 {
202 uint32_t ChromaUpsamplingCoSitedHorizontalOffset : 2;
203 uint32_t ChromaUpsamplingCoSitedVerticalOffset : 3;
204 uint32_t ChromaDownsamplingCoSitedHorizontalOffset : 2;
205 uint32_t ChromaDownsamplingCoSitedVerticalOffset : 3;
206 uint32_t BypassChromaUpsampling : 1;
207 uint32_t BypassChromaDownsampling : 1;
208 uint32_t : 20; // Reserved
209 } MHW_VEBOX_CHROMA_SAMPLING, *PMHW_VEBOX_CHROMA_SAMPLING;
210
211 typedef struct _MHW_VEBOX_3D_LUT
212 {
213 uint32_t ArbitrationPriorityControl : 2;
214 uint32_t Lut3dEnable : 1;
215 uint32_t Lut3dSize : 2;
216 uint32_t ChannelMappingSwapForLut3D : 1;
217 uint32_t InterpolationMethod : 1;
218 uint32_t Lut3DLoopingOrder : 1; // 0=B-major(legacy), 1=R-major
219 uint32_t : 24; // Reserved
220 } MHW_VEBOX_3D_LUT, *PMHW_VEBOX_3D_LUT;
221
222 typedef struct _MHW_VEBOX_FP16_INPUT
223 {
224 uint32_t VeboxFp16InputEnable : 1;
225 uint32_t RgbSwapForFp16Input : 1;
226 uint32_t HdrGainFactor : 8;
227 uint32_t : 22; // Reserved
228 } MHW_VEBOX_FP16_INPUT, *PMHW_VEBOX_FP16_INPUT;
229
230 //!
231 //! \brief Structure to handle VEBOX_STATE_CMD Command
232 //!
233 typedef struct _MHW_VEBOX_STATE_CMD_PARAMS
234 {
235 MHW_VEBOX_MODE VeboxMode;
236 MHW_VEBOX_CHROMA_SAMPLING ChromaSampling;
237 MHW_VEBOX_3D_LUT LUT3D;
238 MHW_VEBOX_FP16_INPUT FP16Input;
239 bool bUseVeboxHeapKernelResource;
240 PMOS_RESOURCE pLaceLookUpTables;
241 PMOS_RESOURCE pVeboxParamSurf;
242 PMOS_RESOURCE pVebox3DLookUpTables;
243 PMOS_RESOURCE pVebox1DLookUpTables;
244 MOS_RESOURCE DummyIecpResource;
245 MHW_MEMORY_OBJECT_CONTROL_PARAMS LaceLookUpTablesSurfCtrl;
246 MHW_MEMORY_OBJECT_CONTROL_PARAMS Vebox3DLookUpTablesSurfCtrl;
247 bool bNoUseVeboxHeap;
248 bool isTlbPrefetchDisable;
249 } MHW_VEBOX_STATE_CMD_PARAMS, *PMHW_VEBOX_STATE_CMD_PARAMS;
250
251 //!
252 //! \brief VEBOX DNDI parameters
253 //!
254 typedef struct _MHW_VEBOX_DNDI_PARAMS
255 {
256 // DI and Luma Denoise Params
257 uint32_t dwDenoiseASDThreshold = 0;
258 uint32_t dwDenoiseHistoryDelta = 0;
259 uint32_t dwDenoiseMaximumHistory = 0;
260 uint32_t dwDenoiseSTADThreshold = 0;
261 uint32_t dwDenoiseSCMThreshold = 0;
262 uint32_t dwDenoiseMPThreshold = 0;
263 uint32_t dwLTDThreshold = 0;
264 uint32_t dwTDThreshold = 0;
265 uint32_t dwGoodNeighborThreshold = 0;
266 bool bDNDITopFirst = false;
267 bool bProgressiveDN = false;
268 uint32_t dwFMDFirstFieldCurrFrame = 0;
269 uint32_t dwFMDSecondFieldPrevFrame = 0;
270
271 // Pixel Range Threshold Array for 5x5 Spatial Filter
272 uint32_t dwPixRangeThreshold[MHW_PIXRANGETHRES_NUM] = {};
273 uint32_t dwPixRangeWeight[MHW_PIXRANGETHRES_NUM] = {};
274
275 // Chroma Denoise Params
276 uint32_t dwHistoryInitUV = 0;
277 uint32_t dwChromaSTADThreshold = 0;
278 uint32_t dwChromaLTDThreshold = 0;
279 uint32_t dwChromaTDThreshold = 0;
280 bool bChromaDNEnable = false;
281
282 // Hot Pixel Params
283 uint32_t dwHotPixelThreshold = 0;
284 uint32_t dwHotPixelCount = 0;
285
286 // CNL New DI
287 uint32_t dwLumaTDMWeight = 0;
288 uint32_t dwChromaTDMWeight = 0;
289 uint32_t dwSHCMDelta = 0;
290 uint32_t dwSHCMThreshold = 0;
291 uint32_t dwSVCMDelta = 0;
292 uint32_t dwSVCMThreshold = 0;
293 bool bFasterConvergence = false;
294 bool bTDMLumaSmallerWindow = false;
295 bool bTDMChromaSmallerWindow = false;
296 uint32_t dwLumaTDMCoringThreshold = 0;
297 uint32_t dwChromaTDMCoringThreshold = 0;
298 bool bBypassDeflickerFilter = false;
299 bool bUseSyntheticContentMedian = false;
300 bool bLocalCheck = false;
301 bool bSyntheticContentCheck = false;
302 bool bSyntheticFrame = false;
303 bool bSCDEnable = false;
304 uint32_t dwDirectionCheckThreshold = 0;
305 uint32_t dwTearingLowThreshold = 0;
306 uint32_t dwTearingHighThreshold = 0;
307 uint32_t dwDiffCheckSlackThreshold = 0;
308 uint32_t dwSADWT0 = 0;
309 uint32_t dwSADWT1 = 0;
310 uint32_t dwSADWT2 = 0;
311 uint32_t dwSADWT3 = 0;
312 uint32_t dwSADWT4 = 0;
313 uint32_t dwSADWT6 = 0;
314 uint32_t dwLPFWtLUT0 = 0;
315 uint32_t dwLPFWtLUT1 = 0;
316 uint32_t dwLPFWtLUT2 = 0;
317 uint32_t dwLPFWtLUT3 = 0;
318 uint32_t dwLPFWtLUT4 = 0;
319 uint32_t dwLPFWtLUT5 = 0;
320 uint32_t dwLPFWtLUT6 = 0;
321 uint32_t dwLPFWtLUT7 = 0;
322
323 //for SlimIPUDenoise
324 void * pSystemMem = nullptr;
325 uint32_t MemSizeInBytes = 0;
326 bool bEnableSlimIPUDenoise = false;
327
328 // FDFB
329 bool dndistateforFDFB = false;
330 } MHW_VEBOX_DNDI_PARAMS, *PMHW_VEBOX_DNDI_PARAMS;
331
332 //!
333 //! \brief VEBOX Chroma parameters
334 //!
335 typedef struct _MHW_VEBOX_CHROMA_PARAMS
336 {
337 uint32_t dwPixRangeThresholdChromaU[MHW_PIXRANGETHRES_NUM];
338 uint32_t dwPixRangeWeightChromaU[MHW_PIXRANGETHRES_NUM];
339 uint32_t dwPixRangeThresholdChromaV[MHW_PIXRANGETHRES_NUM];
340 uint32_t dwPixRangeWeightChromaV[MHW_PIXRANGETHRES_NUM];
341 uint32_t dwHotPixelThresholdChromaU;
342 uint32_t dwHotPixelCountChromaU;
343 uint32_t dwHotPixelThresholdChromaV;
344 uint32_t dwHotPixelCountChromaV;
345 } MHW_VEBOX_CHROMA_PARAMS;
346
347 //!
348 //! Structure MHW_STE_PARAMS
349 //! \brief STE parameters - Skin Tone Enhancement
350 //!
351 typedef struct _MHW_STE_PARAMS
352 {
353 uint32_t dwSTEFactor;
354 uint32_t satP1;
355 uint32_t satS0;
356 uint32_t satS1;
357 } MHW_STE_PARAMS, *PMHW_STE_PARAMS;
358
359
360 //!
361 //! Structure MHW_STD_PARAMS
362 //! \brief STD parameters - Skin Tone Detection
363 //!
364 typedef struct _MHW_STD_PARAMS
365 {
366 uint32_t paraSizeInBytes;
367 void *param;
368 } MHW_STD_PARAMS, *PMHW_STD_PARAMS;
369
370
371 //!
372 //! Structure MHW_TCC_PARAMS
373 //! \brief TCC parameters - Total Color Control
374 //!
375 typedef struct _MHW_TCC_PARAMS
376 {
377 uint8_t Red;
378 uint8_t Green;
379 uint8_t Blue;
380 uint8_t Cyan;
381 uint8_t Magenta;
382 uint8_t Yellow;
383 } MHW_TCC_PARAMS, *PMHW_TCC_PARAMS;
384
385 //!
386 //! Structure MHW_LACE_PARAMS
387 //! \brief LACE parameters - Local Adaptive Contrast Enhancement
388 //!
389 typedef struct _MHW_LACE_PARAMS
390 {
391 bool bSTD; // To enable Skin Tone Special handling
392 uint32_t dwStrength; // LACE strength
393 uint16_t wMinAceLuma; // Minimum Luma for which ACE has to be applied
394 uint16_t wMaxAceLuma; // Maximum Luma for which ACE has to be applied
395 } MHW_LACE_PARAMS, *PMHW_LACE_PARAMS;
396
397 //!
398 //! Structure MHW_COLORPIPE_PARAMS
399 //! \brief IECP Parameters - Color Pipe
400 //!
401 typedef struct _MHW_COLORPIPE_PARAMS
402 {
403 uint32_t bActive; //!< Active or not
404 bool bEnableACE;
405 bool bEnableSTE;
406 bool bEnableSTD; // vebox STD alone enabled or not
407 bool bEnableTCC;
408 bool bAceLevelChanged;
409 uint32_t dwAceLevel;
410 uint32_t dwAceStrength;
411 bool bEnableLACE;
412 MHW_STE_PARAMS SteParams;
413 MHW_STD_PARAMS StdParams;
414 MHW_TCC_PARAMS TccParams;
415 MHW_LACE_PARAMS LaceParams;
416 } MHW_COLORPIPE_PARAMS, *PMHW_COLORPIPE_PARAMS;
417
418 //!
419 //! \brief Adaptive Contrast Enhancement (ACE) Params
420 //!
421 typedef struct _MHW_ACE_PARAMS
422 {
423 uint32_t bActive;
424 uint16_t wACEPWLF_X[MHW_NUM_ACE_PWLF_COEFF]; // Piece-wise linear function x
425 uint16_t wACEPWLF_Y[MHW_NUM_ACE_PWLF_COEFF]; // Piece-wise linear function y
426 uint16_t wACEPWLF_S[MHW_NUM_ACE_PWLF_COEFF]; // Piece-wise linear function slope
427 uint16_t wACEPWLF_B[MHW_NUM_ACE_PWLF_COEFF]; // Piece-wise linear function bias
428 } MHW_ACE_PARAMS, *PMHW_ACE_PARAMS;
429
430 //!
431 //! Structure MHW_PROCAMP_PARAMS
432 //! \brief Procamp parameters
433 //!
434 typedef struct _MHW_PROCAMP_PARAMS
435 {
436 uint32_t bActive; //!< Active or not
437 bool bEnabled;
438 uint32_t brightness;
439 uint32_t contrast;
440 uint32_t sinCS;
441 uint32_t cosCS;
442 } MHW_PROCAMP_PARAMS, *PMHW_PROCAMP_PARAMS;
443
444 //!
445 //! Structure MHW_HOTPIXEL_PARAMS
446 //! \brief Hotpixel Parameters
447 //!
448 typedef struct _MHW_HOTPIXEL_PARAMS
449 {
450 uint32_t bActive;
451 uint32_t PixelThreshold;
452 uint32_t PixelCount;
453 } MHW_HOTPIXEL_PARAMS, *PMHW_HOTPIXEL_PARAMS;
454
455 //!
456 //! Structure MHW_VIGNETTE_PARAMS
457 //! \brief Vignette Parameters
458 //!
459 typedef struct _MHW_VIGNETTE_PARAMS
460 {
461 uint32_t bActive;
462 uint32_t Width;
463 uint32_t Height;
464 uint32_t Stride;
465 uint8_t *pCorrectionMap;
466 } MHW_VIGNETTE_PARAMS, *PMHW_VIGNETTE_PARAMS;
467
468 //!
469 //! Structure MHW_BLACK_LEVEL_PARAMS
470 //! \brief Black Level Parameters
471 //!
472 typedef struct _MHW_BLACK_LEVEL_PARAMS
473 {
474 uint32_t bActive;
475 uint32_t R;
476 uint32_t G0;
477 uint32_t B;
478 uint32_t G1;
479 } MHW_BLACK_LEVEL_PARAMS, *PMHW_BLACK_LEVEL_PARAMS;
480
481 //!
482 //! Structure MHW_WB_MODE
483 //! \brief WB Parameters
484 //!
485 typedef enum _MHW_WB_MODE
486 {
487 MHW_WB_NONE,
488 MHW_WB_MANUAL,
489 MHW_WB_AUTO_IMAGE,
490 MHW_WB_COUNT
491 } MHW_WB_MODE;
492
493 //!
494 //! Structure MHW_3DLUT_INTERPOLATION
495 //! \brief 3DLut interpolation method
496 //!
497 typedef enum _MHW_3DLUT_INTERPOLATION
498 {
499 MHW_3DLUT_INTERPOLATION_TRILINEAR = 0, //!< 3DLUT Trilinear interpolation method.
500 MHW_3DLUT_INTERPOLATION_TETRAHEDRAL = 1 //!< 3DLUT Tetrahedral interpolation method.
501 } MHW_3DLUT_INTERPOLATION;
502
503 //!
504 //! Structure MHW_WHITE_BALANCE_PARAMS
505 //! \brief White Balance Parameters
506 //!
507 typedef struct _MHW_WHITE_BALANCE_PARAMS
508 {
509 uint32_t bActive;
510 MHW_WB_MODE Mode;
511 float RedCorrection;
512 float GreenTopCorrection;
513 float BlueCorrection;
514 float GreenBottomCorrection;
515 } MHW_WHITE_BALANCE_PARAMS, *PMHW_WHITE_BALANCE_PARAMS;
516
517 //!
518 //! Structure MHW_COLOR_CORRECTION_PARAMS
519 //! \brief Color Correction Parameters
520 //!
521 typedef struct _MHW_COLOR_CORRECTION_PARAMS
522 {
523 uint32_t bActive;
524 float CCM[3][3];
525 } MHW_COLOR_CORRECTION_PARAMS, *PMHW_COLOR_CORRECTION_PARAMS;
526
527 //!
528 //! Structure MHW_FORWARD_GAMMA_SEG
529 //! \brief Forward Gamma SEG Parameters
530 //!
531 typedef struct _MHW_FORWARD_GAMMA_SEG
532 {
533 uint16_t PixelValue; //!< SKL+ U16 Range=[0, 65535]
534 uint16_t RedChannelCorrectedValue; //!< SKL+ U16 Range=[0, 65535]
535 uint16_t GreenChannelCorrectedValue; //!< SKL+ U16 Range=[0, 65535]
536 uint16_t BlueChannelCorrectedValue; //!< SKL+ U16 Range=[0, 65535]
537 } MHW_FORWARD_GAMMA_SEG, *PMHW_FORWARD_GAMMA_SEG;
538
539 //!
540 //! Structure MHW_FWD_GAMMA_PARAMS
541 //! \brief Forward Gamma Parameters
542 //!
543 typedef struct _MHW_FWD_GAMMA_PARAMS
544 {
545 uint32_t bActive;
546 MHW_FORWARD_GAMMA_SEG Segment[MHW_FORWARD_GAMMA_SEGMENT_COUNT];
547 } MHW_FWD_GAMMA_PARAMS, *PMHW_FWD_GAMMA_PARAMS;
548
549 //!
550 //! Structure MHW_FECSC_PARAMS
551 //! \brief Front End CSC Parameters
552 //!
553 typedef struct _MHW_FECSC_PARAMS
554 {
555 uint32_t bActive;
556 float PreOffset[3];
557 float Matrix[3][3];
558 float PostOffset[3];
559 } MHW_FECSC_PARAMS, *PMHW_FECSC_PARAMS;
560
561 //!
562 //! Structure MHW_BECSC_PARAMS
563 //! \brief Back End CSC Parameters
564 //!
565 typedef struct _MHW_BECSC_PARAMS
566 {
567 uint32_t bActive;
568 float PreOffset[3];
569 float Matrix[3][3];
570 float PostOffset[3];
571 } MHW_BECSC_PARAMS, *PMHW_BECSC_PARAMS;
572
573 //!
574 //! Structure MHW_LGCA_PARAMS
575 //! \brief Geometric Lens Correction and Chorma Aberration parameters
576 //!
577 typedef struct _MHW_LENS_CORRECTION_PARAMS
578 {
579 uint32_t bActive; //!< Active or not
580 float a[3]; //!< Array (red, green, blue) of values for "a"
581 float b[3]; //!< Array (red, green, blue) of values for "b"
582 float c[3]; //!< Array (red, green, blue) of values for "c"
583 float d[3]; //!< Array (red, green, blue) of values for "d"
584 } MHW_LENS_CORRECTION_PARAMS, *PMHW_LENS_CORRECTION_PARAMS;
585
586 //!
587 //! Structure MHW_ICC_COLOR_CONVERSION_PARAMS
588 //! \brief ICC Color Conversion
589 //!
590 typedef struct _MHW_ICC_COLOR_CONVERSION_PARAMS
591 {
592 uint32_t bActive; //!< Active or not
593 uint32_t LUTSize; //!< Size (one dimensions) of the LUT
594 uint32_t LUTLength; //!< Length of the LUT, in unit of bit
595 uint8_t *pLUT; //!< Pointer to the LUT value
596 } MHW_ICC_COLOR_CONVERSION_PARAMS, *PMHW_ICC_COLOR_CONVERSION_PARAMS;
597
598 typedef struct _MHW_DEBAYER_PARAMS
599 {
600 uint32_t BayerInput; //!< 0: MSB (default); 1: LSB
601 uint32_t LSBBayerBitDepth; //!< 10, 12 or 14 for varies bayer input
602 } MHW_DEBAYER_PARAMS, *PMHW_DEBAYER_PARAMS;
603
604 //!
605 //! Structure MHW_CAPPIPE_PARAMS
606 //! \brief Capture Pipe Parameters
607 //!
608 typedef struct _MHW_CAPPIPE_PARAMS
609 {
610 uint32_t bActive;
611 MHW_HOTPIXEL_PARAMS HotPixelParams;
612 MHW_VIGNETTE_PARAMS VignetteParams;
613 MHW_BLACK_LEVEL_PARAMS BlackLevelParams;
614 MHW_WHITE_BALANCE_PARAMS WhiteBalanceParams;
615 MHW_COLOR_CORRECTION_PARAMS ColorCorrectionParams;
616 MHW_FWD_GAMMA_PARAMS FwdGammaParams;
617 MHW_FECSC_PARAMS FECSCParams;
618 MHW_BECSC_PARAMS BECSCParams;
619 MHW_LENS_CORRECTION_PARAMS LensCorrectionParams;
620 MHW_ICC_COLOR_CONVERSION_PARAMS ICCColorConversionParams;
621 MHW_DEBAYER_PARAMS DebayerParams;
622 } MHW_CAPPIPE_PARAMS, *PMHW_CAPPIPE_PARAMS;
623
624 //!
625 //! Structure MHW_3DLUT_PARAMS
626 //! \details No pre-si version for MHW_VEBOX_IECP_PARAMS, just leave it now and handle it later
627 //!
628 typedef struct _MHW_3DLUT_PARAMS
629 {
630 uint32_t bActive; //!< Active or not
631 uint32_t LUTSize; //!< Size (one dimensions) of the LUT
632 uint32_t LUTLength; //!< Length of the LUT, in unit of bit
633 uint8_t *pLUT; //!< Pointer to the LUT value
634 MHW_3DLUT_INTERPOLATION InterpolationMethod; //!< Vebox 3DLut interpolation method
635 } MHW_3DLUT_PARAMS, *PMHW_3DLUT_PARAMS;
636
637 //!
638 //! \brief VEBOX HDR PARAMS
639 //! \details For CCM settings, move 1DLut to here later
640 typedef struct _MHW_1DLUT_PARAMS
641 {
642 uint32_t bActive;
643 void *p1DLUT;
644 uint32_t LUTSize;
645 int32_t *pCCM;
646 uint32_t CCMSize;
647 uint32_t eotf16LayoutMode; // EOTF16 layout mode: 0=ARGB legacy (Y/Z/W), 1=RGBA new (X/Y/Z)
648 } MHW_1DLUT_PARAMS, *PMHW_1DLUT_PARAMS;
649
650 //!
651 //! Structure MHW_3DLUT_PARAMS
652 //! \details No pre-si version for MHW_VEBOX_IECP_PARAMS, just leave it now and handle it later
653 //!
654 typedef struct _MHW_FP16_PARAMS
655 {
656 uint32_t isActive = false; //!< Active or not
657 uint32_t OETFLutY[256] = {};
658 uint32_t OETFLutX[256] = {};
659 } MHW_FP16_PARAMS, *PMHW_FP16_PARAMS;
660
661 //!
662 //! \brief VEBOX IECP parameters
663 //!
664 typedef struct _MHW_VEBOX_IECP_PARAMS
665 {
666 MHW_COLORPIPE_PARAMS ColorPipeParams;
667 MHW_ACE_PARAMS AceParams;
668 MHW_PROCAMP_PARAMS ProcAmpParams;
669 MHW_CAPPIPE_PARAMS CapPipeParams;
670 MOS_FORMAT dstFormat;
671 MOS_FORMAT srcFormat;
672 MHW_CSPACE ColorSpace; // ColorSpace of the input surface
673
674 // CSC params
675 bool bCSCEnable; // Enable CSC transform
676 float *pfCscCoeff; // [3x3] CSC Coeff matrix
677 float *pfCscInOffset; // [3x1] CSC Input Offset matrix
678 float *pfCscOutOffset; // [3x1] CSC Output Offset matrix
679 bool bAlphaEnable; // Alpha Enable Param
680 uint16_t wAlphaValue; // Color Pipe Alpha Value
681
682 bool bAce;
683
684 MHW_3DLUT_PARAMS s3DLutParams;
685 MHW_1DLUT_PARAMS s1DLutParams;
686 MHW_FP16_PARAMS fp16Params;
687
688 // Front End CSC params
689 bool bFeCSCEnable; // Enable Front End CSC transform
690 float *pfFeCscCoeff; // [3x3] Front End CSC Coeff matrix
691 float *pfFeCscInOffset; // [3x1] Front End CSC Input Offset matrix
692 float *pfFeCscOutOffset; // [3x1] Front End CSC Output Offset matrix
693
694 // FDFB
695 bool iecpstateforFDFB;
696 // CSC via CCM for float 16bit output
697 bool bCcmCscEnable;
698 } MHW_VEBOX_IECP_PARAMS, *PMHW_VEBOX_IECP_PARAMS;
699
700 //!
701 //! \brief VEBOX CH_DIR_FILTER_COEFFICIENT parameters
702 //!
703 typedef struct _MHW_VEBOX_CH_DIR_FILTER_COEFFICIENT
704 {
705 uint32_t FilterCoefficient0;
706 uint32_t FilterCoefficient1;
707 uint32_t FilterCoefficient2;
708 uint32_t FilterCoefficient3;
709 uint32_t FilterCoefficient4;
710 uint32_t FilterCoefficient5;
711 uint32_t FilterCoefficient6;
712 uint32_t FilterCoefficient7;
713 } MHW_VEBOX_CH_DIR_FILTER_COEFFICIENT, *PMHW_VEBOX_CH_DIR_FILTER_COEFFICIENT;
714
715 //!
716 //! \brief VEBOX Scalar parameters
717 //!
718 typedef struct _MHW_VEBOX_SCALAR_PARAMS
719 {
720 bool bDisableChromaChannelDiagonalInterpolation;
721 MHW_VEBOX_CH_DIR_FILTER_COEFFICIENT UVChCoefficient0;
722 MHW_VEBOX_CH_DIR_FILTER_COEFFICIENT UVChCoefficient1;
723 MHW_VEBOX_CH_DIR_FILTER_COEFFICIENT UVChCoefficient2;
724 MHW_VEBOX_CH_DIR_FILTER_COEFFICIENT UVChCoefficient3;
725 uint32_t dwSADWT0;
726 uint32_t dwSADWT1;
727 uint32_t dwSADWT2;
728 uint32_t dwSADWT3;
729 uint32_t dwSADWT4;
730 uint32_t dwSADWT5;
731 } MHW_VEBOX_SCALAR_PARAMS, *PMHW_VEBOX_SCALAR_PARAMS;
732
733 //!
734 //! \brief VEBOX Gamut parameters
735 //!
736 typedef struct _MHW_VEBOX_GAMUT_PARAMS
737 {
738 MHW_CSPACE ColorSpace; // ColorSpace of the input surface
739 MHW_CSPACE dstColorSpace; // ColorSpace of the output surface
740 MOS_FORMAT srcFormat; // Input surface format
741 MOS_FORMAT dstFormat; // output surface format
742 // GComp
743 MHW_GAMUT_MODE GCompMode;
744 // Basic mode params
745 uint32_t GCompBasicMode;
746 int32_t iBasicModeScalingFactor;
747 // Advanced mode params
748 int32_t iDin;
749 int32_t iDinDefault;
750 int32_t iDout;
751 int32_t iDoutDefault;
752
753 // GExp
754 MHW_GAMUT_MODE GExpMode;
755 uint32_t *pFwdGammaBias;
756 uint32_t *pInvGammaBias;
757 int32_t Matrix[3][3];
758
759 // Gamma correction
760 bool bGammaCorr;
761 MHW_GAMMA_VALUE InputGammaValue;
762 MHW_GAMMA_VALUE OutputGammaValue;
763
764 // HDR
765 bool bH2S;
766 uint16_t uiMaxCLL;
767
768 // FDFB
769 bool gamutstateforFDFB;
770
771 // Segmentation
772 bool bColorBalance;
773
774 } MHW_VEBOX_GAMUT_PARAMS, *PMHW_VEBOX_GAMUT_PARAMS;
775
776 //!
777 //! \brief Structure to handle VEBOX_DI_IECP_CMD Command
778 //!
779 typedef struct _MHW_VEBOX_DI_IECP_CMD_PARAMS
780 {
781 uint32_t dwEndingX;
782 uint32_t dwStartingX;
783 uint32_t dwEndingY;
784 uint32_t dwStartingY;
785 uint32_t dwCurrInputSurfOffset;
786 uint32_t dwPrevInputSurfOffset;
787 uint32_t dwCurrOutputSurfOffset;
788 uint32_t dwStreamID; // Stream ID for input surface
789 uint32_t dwStreamIDOutput; // Stream ID for output surface
790
791 PMOS_RESOURCE pOsResCurrInput;
792 PMOS_RESOURCE pOsResPrevInput;
793 PMOS_RESOURCE pOsResStmmInput;
794 PMOS_RESOURCE pOsResStmmOutput;
795 PMOS_RESOURCE pOsResDenoisedCurrOutput;
796 PMOS_RESOURCE pOsResCurrOutput;
797 PMOS_RESOURCE pOsResPrevOutput;
798 PMOS_RESOURCE pOsResStatisticsOutput;
799 PMOS_RESOURCE pOsResAlphaOrVignette;
800 PMOS_RESOURCE pOsResLaceOrAceOrRgbHistogram;
801 PMOS_RESOURCE pOsResSkinScoreSurface;
802
803 MHW_MEMORY_OBJECT_CONTROL_PARAMS CurrInputSurfCtrl;//can be removed after VPHAL moving to new cmd definition
804 MHW_MEMORY_OBJECT_CONTROL_PARAMS PrevInputSurfCtrl;
805 MHW_MEMORY_OBJECT_CONTROL_PARAMS StmmInputSurfCtrl;
806 MHW_MEMORY_OBJECT_CONTROL_PARAMS StmmOutputSurfCtrl;
807 MHW_MEMORY_OBJECT_CONTROL_PARAMS DenoisedCurrOutputSurfCtrl;
808 MHW_MEMORY_OBJECT_CONTROL_PARAMS CurrOutputSurfCtrl;
809 MHW_MEMORY_OBJECT_CONTROL_PARAMS PrevOutputSurfCtrl;
810 MHW_MEMORY_OBJECT_CONTROL_PARAMS StatisticsOutputSurfCtrl;
811 MHW_MEMORY_OBJECT_CONTROL_PARAMS AlphaOrVignetteSurfCtrl;
812 MHW_MEMORY_OBJECT_CONTROL_PARAMS LaceOrAceOrRgbHistogramSurfCtrl;
813 MHW_MEMORY_OBJECT_CONTROL_PARAMS SkinScoreSurfaceSurfCtrl;
814
815 MOS_MEMCOMP_STATE CurInputSurfMMCState;
816 } MHW_VEBOX_DI_IECP_CMD_PARAMS, *PMHW_VEBOX_DI_IECP_CMD_PARAMS;
817
818 //!
819 //! \brief Structure to VEBOX SURFACE PARAMETERS for VEBOX_SURFACE_STATE_CMD Command
820 //!
821 typedef struct _MHW_VEBOX_SURFACE_PARAMS
822 {
823 uint32_t bActive = 0;
824 bool bIsCompressed = false;
825 MOS_FORMAT Format = Format_None; //!< Surface format
826 MOS_RESOURCE_MMC_MODE CompressionMode = MOS_MMC_DISABLED; //!< Surface Compression Mode
827 uint32_t dwCompressionFormat = 0; //!< Surface Compression Format
828 uint32_t dwWidth = 0; //!< Surface width
829 uint32_t dwHeight = 0; //!< Surface height
830 uint32_t dwPitch = 0; //!< Surface pitch
831 uint32_t dwBitDepth = 0; //!< Surface bitdepth
832 uint32_t dwStreamID = 0; //!< Surface StreamID
833 uint32_t dwYoffset = 0; //!< Surface Yoffset in Vertical
834 uint32_t dwUYoffset = 0; //!< Surface Uoffset in Vertical
835 uint32_t dwOffset = 0; //!< Surface Offset from Start Point
836 MOS_TILE_TYPE TileType = MOS_TILE_X; //!< Tile Type
837 MOS_TILE_MODE_GMM TileModeGMM = MOS_TILE_LINEAR_GMM; //!< Tile Mode from GMM Definition
838 bool bGMMTileEnabled = false; //!< GMM defined tile mode flag
839 RECT rcSrc = {0, 0, 0, 0}; //!< Source rectangle
840 RECT rcMaxSrc = {0, 0, 0, 0}; //!< Max source rectangle
841 bool bVEBOXCroppingUsed = false; //!<Vebox crop case need use rcSrc as vebox input.
842 PMOS_RESOURCE pOsResource = nullptr; //!< Surface resource
843 } MHW_VEBOX_SURFACE_PARAMS, *PMHW_VEBOX_SURFACE_PARAMS;
844
845 //!
846 //! \brief Structure to handle VEBOX_SURFACE_STATE_CMD Command
847 //!
848 typedef struct _MHW_VEBOX_SURFACE_STATE_CMD_PARAMS
849 {
850 MHW_VEBOX_SURFACE_PARAMS SurfInput = {};
851 MHW_VEBOX_SURFACE_PARAMS SurfOutput = {};
852 MHW_VEBOX_SURFACE_PARAMS SurfSTMM = {};
853 MHW_VEBOX_SURFACE_PARAMS SurfDNOutput = {};
854 MHW_VEBOX_SURFACE_PARAMS SurfSkinScoreOutput = {};
855 bool bDIEnable = false;
856 bool b3DlutEnable = false;
857 bool bOutputValid = false;
858 } MHW_VEBOX_SURFACE_STATE_CMD_PARAMS, *PMHW_VEBOX_SURFACE_STATE_CMD_PARAMS;
859
860 //!
861 //! \brief VEBOX input surface control bits params
862 //!
863 typedef struct _MHW_VEBOX_SURFACE_CNTL_PARAMS
864 {
865 bool bIsCompressed;
866 MOS_RESOURCE_MMC_MODE CompressionMode;
867 } MHW_VEBOX_SURFACE_CNTL_PARAMS, *PMHW_VEBOX_SURFACE_CNTL_PARAMS;
868
869 //!
870 //! \brief VEBOX Engine ID data struct in accordance with CommandStreamEngineIDDefintionRegister
871 //!
872 typedef struct _MHW_VEBOX_ENGINE_DATA
873 {
874 uint32_t classId : 3;
875 uint32_t reserved1 : 1;
876 uint32_t instanceId : 6;
877 uint32_t reserved2 : 22;
878 } MHW_VEBOX_ENGINE_DATA, *PMHW_VEBOX_ENGINE_DATA;
879
880 //!
881 //! \brief VEBOX Heap State Structure
882 //!
883 typedef struct _MHW_VEBOX_HEAP_STATE
884 {
885 bool bBusy; // true if the state is in use (must sync before use)
886 uint32_t dwSyncTag; // Vebox heap state sync tag
887 #if (_DEBUG || _RELEASE_INTERNAL)
888 volatile MHW_VEBOX_ENGINE_DATA *engineData; // Pointer to EngineIDDefintion Register data
889 #endif
890 } MHW_VEBOX_HEAP_STATE, *PMHW_VEBOX_HEAP_STATE;
891
892 //!
893 //! \brief VEBOX Heap Structure
894 //!
895 typedef struct _MHW_VEBOX_HEAP
896 {
897 uint32_t uiCurState; // Current VEBOX State
898 uint32_t uiNextState; // Next VEBOX State
899 uint32_t uiOffsetSync; // Offset of sync data in VeboxHeap
900 uint32_t uiDndiStateOffset; // DNDI or Scalar state offset
901 uint32_t uiIecpStateOffset; // IECP state offset
902 uint32_t uiGamutStateOffset; // Gamut state offset
903 uint32_t uiVertexTableOffset; // Vertex Table offset
904 uint32_t uiCapturePipeStateOffset; // Capture Pipe state offset
905 uint32_t uiGammaCorrectionStateOffset; // Gamma Correction state offset
906 uint32_t uiHdrStateOffset; // Hdr State offset
907 #if (_DEBUG || _RELEASE_INTERNAL)
908 uint32_t uiEngineDataOffset; // Engine data Offset
909 #endif
910 uint32_t uiInstanceSize; // Size of single instance of VEBOX states
911 uint32_t uiStateHeapSize; // Total size of VEBOX States heap
912 PMHW_VEBOX_HEAP_STATE pStates; // Array of VEBOX Heap States
913 MOS_RESOURCE DriverResource; // Graphics memory for Driver access
914 MOS_RESOURCE KernelResource; // Graphics memory for Kernel access
915 uint8_t *pLockedDriverResourceMem; // Locked Driver resource memory
916
917 // Synchronization
918 volatile uint32_t *pSync; // Pointer to sync area (when locked)
919 uint32_t dwNextTag; // Next sync tag value to use
920 uint32_t dwSyncTag; // Last sync tag completed
921 } MHW_VEBOX_HEAP, *PMHW_VEBOX_HEAP;
922
923 //!
924 //! \brief VEBOX settings Structure
925 //!
926 typedef struct
927 {
928 uint32_t uiNumInstances; // Number of VEBOX instances to create
929 uint32_t uiSyncSize; // Sync Data Size
930 uint32_t uiDndiStateSize; // DNDI State Size
931 uint32_t uiIecpStateSize; // IECP State Size
932 uint32_t uiGamutStateSize; // Gamut State Size
933 uint32_t uiVertexTableSize; // Vertex Table Size
934 uint32_t uiCapturePipeStateSize; // Capture Pipe State Size (Gen8+)
935 uint32_t uiGammaCorrectionStateSize; // Gamma Correction State Size (Gen9+)
936 uint32_t uiHdrStateSize; // HDR State Size
937 #if (_DEBUG || _RELEASE_INTERNAL)
938 uint32_t uiEngineDataSize; // Engine data Size
939 #endif
940 } MHW_VEBOX_SETTINGS, *PMHW_VEBOX_SETTINGS;
941 typedef const MHW_VEBOX_SETTINGS CMHW_VEBOX_SETTINGS, *PCMHW_VEBOX_SETTINGS;
942
943 //!
944 //! \brief MHW VEBOX GPUNODE Structure
945 //!
946 typedef struct _MHW_VEBOX_GPUNODE_LIMIT
947 {
948 bool bSfcInUse;
949 bool bCpEnabled;
950 uint32_t dwGpuNodeToUse;
951 } MHW_VEBOX_GPUNODE_LIMIT, *PMHW_VEBOX_GPUNODE_LIMIT;
952
953
954
955 class MhwVeboxInterface
956 {
957 public:
958 virtual ~MhwVeboxInterface()
959 {
960 MHW_FUNCTION_ENTER;
961 }
962
963 //!
964 //! \brief Add VEBOX Vertex Table
965 //! \details Add Vebox vertex table based on color space
966 //! \param [in] ColorSpace
967 //! ColorSpace of the source surface
968 //! \return MOS_STATUS
969 //!
970 virtual MOS_STATUS AddVeboxVertexTable(
971 MHW_CSPACE ColorSpace) = 0;
972
973 //!
974 //! \brief Add Vebox State
975 //! \details Add Vebox State commands
976 //! \param [in] pCmdBuffer
977 //! Pointer to Command Buffer
978 //! \param [in] pVeboxStateCmdParams
979 //! Pointer to Vebox State Params
980 //! \return MOS_STATUS
981 //!
982 virtual MOS_STATUS AddVeboxState(
983 PMOS_COMMAND_BUFFER pCmdBuffer,
984 PMHW_VEBOX_STATE_CMD_PARAMS pVeboxStateCmdParams,
985 bool bUseCmBuffer) = 0;
986
987 //!
988 //! \brief Send Vebox Surface State commands
989 //! \details Set surface state for input and output surfaces
990 //! \param [in] pCmdBuffer
991 //! Pointer to command buffer
992 //! \param [in] pVeboxSurfaceStateCmdParams
993 //! Pointer to surface state params
994 //! \return MOS_STATUS
995 //!
996 virtual MOS_STATUS AddVeboxSurfaces(
997 PMOS_COMMAND_BUFFER pCmdBuffer,
998 PMHW_VEBOX_SURFACE_STATE_CMD_PARAMS pVeboxSurfaceStateCmdParams) = 0;
999
1000 //!
1001 //! \brief Send Vebox Di Iecp
1002 //! \details Send Vebox DI IECP commands
1003 //! \param [in] pCmdBuffer
1004 //! Pointer to Command Buffer
1005 //! \param [in] pVeboxDiIecpCmdParams
1006 //! Pointer to DI IECP Params
1007 //! \return MOS_STATUS
1008 //!
1009 virtual MOS_STATUS AddVeboxDiIecp(
1010 PMOS_COMMAND_BUFFER pCmdBuffer,
1011 PMHW_VEBOX_DI_IECP_CMD_PARAMS pVeboxDiIecpCmdParams) = 0;
1012
1013 //!
1014 //! \brief Add VEBOX DNDI States
1015 //! \details Add vebox dndi states
1016 //! \param [in] pVeboxDndiParams
1017 //! Pointer to VEBOX DNDI State Params
1018 //! \return MOS_STATUS
1019 //!
1020 virtual MOS_STATUS AddVeboxDndiState(
1021 PMHW_VEBOX_DNDI_PARAMS pVeboxDndiParams) = 0;
1022
1023 //!
1024 //! \brief Add VEBOX Gamut States
1025 //! \details Add Vebox Gamut states
1026 //! \param [in] pVeboxIecpParams
1027 //! Pointer to VEBOX IECP State Params
1028 //! \param [in] pVeboxGamutParams
1029 //! Pointer to VEBOX Gamut State Params
1030 //! \return MOS_STATUS
1031 //!
1032 virtual MOS_STATUS AddVeboxGamutState(
1033 PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams,
1034 PMHW_VEBOX_GAMUT_PARAMS pVeboxGamutParams) = 0;
1035
1036 virtual MOS_STATUS AddVeboxHdrState(PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams) { return MOS_STATUS_SUCCESS;}
1037
1038 //!
1039 //! \brief Add VEBOX IECP States
1040 //! \details Add Vebox IECP states STD/E, ACE, TCC, FECSC, BLC, ProcAmp, also add CapPipe state
1041 //! \param [in, out] pVeboxIecpParams
1042 //! Pointer to VEBOX IECP State Params
1043 //! \return MOS_STATUS
1044 //!
1045 virtual MOS_STATUS AddVeboxIecpState(
1046 PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams) = 0;
1047
1048 //!
1049 //! \brief Add VEBOX IECP ACE State
1050 //! \details Add vebox IECP ACE State
1051 //! \param [in] pVeboxIecpParams
1052 //! Pointer to VEBOX IECP State Params
1053 //! \return MOS_STATUS
1054 //!
1055 virtual MOS_STATUS AddVeboxIecpAceState(
1056 PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams) = 0;
1057
1058 //!
1059 //! \brief Vebox adjust boundary
1060 //! \details Adjust the width and height of the surface for Vebox
1061 //! \param [in] pSurfaceParam
1062 //! pointer to input Surface
1063 //! \param [out] pdwSurfaceWidth
1064 //! Adjusted surface width
1065 //! \param [out] pdwSurfaceHeight
1066 //! Adjusted surface height
1067 //! \param [in] bDIEnable
1068 //! identify if DI is enabled
1069 //! \return MOS_STATUS
1070 //!
1071 virtual MOS_STATUS VeboxAdjustBoundary(
1072 PMHW_VEBOX_SURFACE_PARAMS pSurfaceParam,
1073 uint32_t *pdwSurfaceWidth,
1074 uint32_t *pdwSurfaceHeight,
1075 bool bDIEnable) = 0;
1076
1077 //! \brief Get Full Image Histogram
1078 //! \details Get VEBOX IECP ACE State inforation about Full Image Histogram
1079 //! \param [in, out] pFullImageHistogram
1080 //! Pointer to Full Image Histogram Param
1081 //! \return MOS_STATUS
1082 //! MOS_STATUS_SUCCESS if success, else fail reason
1083 //!
1084 virtual MOS_STATUS GetVeboxAce_FullImageHistogram(
1085 uint32_t *pFullImageHistogram)
1086 {
1087 MOS_STATUS eStatus = MOS_STATUS_UNKNOWN;
1088 return eStatus;
1089 }
1090 //!
1091 //! \brief Add Vebox Surface Controls Bits
1092 //! \details Add Vebox Surface Control Bits for input surface
1093 //! \param [in] pVeboxSurfCntlParams
1094 //! Pointer to VEBOX Surface control parameters
1095 //! \param [out] pSurfCtrlBits
1096 //! Pointer to surface control bits
1097 //! \return MOS_STATUS
1098 //!
1099 virtual MOS_STATUS AddVeboxSurfaceControlBits(
1100 PMHW_VEBOX_SURFACE_CNTL_PARAMS pVeboxSurfCntlParams,
1101 uint32_t *pSurfCtrlBits) = 0;
1102
1103 //!
1104 //! \brief Add Vebox Tiling Convert Control Bits
1105 //! \details Add Vebox Tiling Convert Control Bits
1106 //! \param [in] cmdBuffer
1107 //! Pointers to the HW Cmd buffer
1108 //! \param [in] inSurParams
1109 //! Pointer to input vebox surface params
1110 //! \param [in] outSurParams
1111 //! Pointer to output vebox surface params
1112 //! \return MOS_STATUS
1113 //! MOS_STATUS_SUCCESS if success, else fail reason
1114 virtual MOS_STATUS AddVeboxTilingConvert(
1115 PMOS_COMMAND_BUFFER cmdBuffer,
1116 PMHW_VEBOX_SURFACE_PARAMS inSurParams,
1117 PMHW_VEBOX_SURFACE_PARAMS outSurParams) = 0;
1118
1119 //!
1120 //! \brief Decide Which GPU Node to use for Vebox
1121 //! \details Client facing function to create gpu context used by Vebox
1122 //! \param [out] pVEGpuNodeLimit
1123 //! VEGpuNode Limitation
1124 //! \return MOS_STATUS
1125 //! MOS_STATUS_SUCCESS if success, else fail reason
1126 //!
1127 virtual MOS_STATUS FindVeboxGpuNodeToUse(
1128 PMHW_VEBOX_GPUNODE_LIMIT pVeboxGpuNodeLimit)
1129 {
1130 MOS_GPU_NODE VeboxGpuNode = MOS_GPU_NODE_VE;
1131 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
1132
1133 MHW_CHK_NULL(pVeboxGpuNodeLimit);
1134
1135 pVeboxGpuNodeLimit->dwGpuNodeToUse = VeboxGpuNode;
1136
1137 finish:
1138 return eStatus;
1139 }
1140
1141 //!
1142 //! \brief Create Gpu Context for Vebox
1143 //! \details Create Gpu Context for Vebox
1144 //! \param [in] pOsInterface
1145 //! OS interface
1146 //! \param [in] VeboxGpuContext
1147 //! Vebox Gpu Context
1148 //! \param [in] VeboxGpuNode
1149 //! Vebox Gpu Node
1150 //! \return MOS_STATUS
1151 //! MOS_STATUS_SUCCESS if success, else fail reason
1152 //!
1153 virtual MOS_STATUS CreateGpuContext(
1154 PMOS_INTERFACE pOsInterface,
1155 MOS_GPU_CONTEXT VeboxGpuContext,
1156 MOS_GPU_NODE VeboxGpuNode)
1157 {
1158 MOS_GPUCTX_CREATOPTIONS createOption;
1159 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
1160
1161 MHW_CHK_NULL(pOsInterface);
1162
1163 MHW_CHK_STATUS(pOsInterface->pfnCreateGpuContext(
1164 pOsInterface,
1165 VeboxGpuContext,
1166 VeboxGpuNode,
1167 &createOption));
1168
1169 finish:
1170 return eStatus;
1171 }
1172
1173 virtual MOS_STATUS setVeboxPrologCmd(
1174 PMHW_MI_INTERFACE mhwMiInterface,
1175 PMOS_COMMAND_BUFFER cmdBuffer) = 0;
1176
1177 virtual MOS_STATUS Add1DLutState(void *&surface, PMHW_1DLUT_PARAMS p1DLutParams) { return MOS_STATUS_SUCCESS; }
1178
1179 //!
1180 //! \brief Get new vebox interface, temporal solution before switching from
1181 //! old interface to new one
1182 //!
1183 //! \return pointer to new render interface
1184 //!
1185 virtual std::shared_ptr<void> GetNewVeboxInterface() { return nullptr; }
1186
1187 protected:
1188 MhwVeboxInterface(PMOS_INTERFACE pOsInterface);
1189
1190 //!
1191 //! \brief Trace indirect state info by OCA
1192 //! \details Trace which resource being used to store indirect state by OCA.
1193 //! \param [in] cmdBuffer
1194 //! Command buffer of current vebox workload.
1195 //! \param [in] mosContext
1196 //! mos context
1197 //! \param [in] isCmBuffer
1198 //! true if CM buffer being used for indirect state, otherwise, vebox heap is used.
1199 //! \param [in] useVeboxHeapKernelResource
1200 //! true if kernel copy needed for indirect state.
1201 //! \return void
1202 //!
1203 void TraceIndirectStateInfo(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT &mosContext, bool isCmBuffer, bool useVeboxHeapKernelResource);
1204
1205 public:
1206 //!
1207 //! \brief Adds a resource to the command buffer or indirect state (SSH)
1208 //! \details Internal MHW function to add either a graphics address of a resource or
1209 //! add the resource to the patch list for the requested buffer or state
1210 //! \param [in] pOsInterface
1211 //! OS interface
1212 //! \param [in] pCmdBuffer
1213 //! If adding a resource to the command buffer, the buffer to which the resource
1214 //! is added
1215 //! \param [in] pParams
1216 //! Parameters necessary to add the graphics address
1217 //! \return MOS_STATUS
1218 //! MOS_STATUS_SUCCESS if success, else fail reason
1219 //!
1220 MOS_STATUS(*pfnAddResourceToCmd)(
1221 PMOS_INTERFACE pOsInterface,
1222 PMOS_COMMAND_BUFFER pCmdBuffer,
1223 PMHW_RESOURCE_PARAMS pParams);
1224
1225 //! \brief VEBOX Heap management functions
1226 //!
1227 //! \brief Create Vebox Heap
1228 //! \details Create Vebox Heap
1229 //! VPHAL_VEBOX (CPU)
1230 //! -------------------
1231 //! | DriverResource |
1232 //! -------------------
1233 //! | KernelResource |
1234 //! -------------------
1235 //!
1236 //! GPU (Driver Resource) GPU (Kernel Resource) VEBOX State (in Graphics Memory)
1237 //! ------------------- ------------------- ---------------------
1238 //! | VEBOX State 0 | | VEBOX State 0 | | DNDI State |
1239 //! ------------------- ------------------- --------------------
1240 //! | VEBOX State 1 | | VEBOX State 1 | | IECP State |
1241 //! ------------------- ------------------- --------------------
1242 //! | VEBOX State N | | VEBOX State N | | Gamut |
1243 //! ------------------- ------------------- --------------------
1244 //! | VEBOX Sync Data | | VEBOX Sync Data | | Vertex State |
1245 //! ------------------- --------------------
1246 //! | CapturePipe State |
1247 //! --------------------
1248 //! | Gamma Correction State |
1249 //! ------------------------
1250 //! | HDR State |
1251 //! ------------------------
1252 //! \return MOS_STATUS
1253 //!
1254 MOS_STATUS CreateHeap();
1255
1256 //!
1257 //! \brief Destroy Vebox Heap
1258 //! \details Destroy Vebox Heap
1259 //! \return MOS_STATUS
1260 //!
1261 MOS_STATUS DestroyHeap();
1262
1263 //!
1264 //! \brief Assign Vebox State
1265 //! \details Gets a pointer to the next available vebox heap instance
1266 //! \return MOS_STATUS
1267 //! MOS_STATUS_SUCCESS: if vebox heap avalible, sets pVeboxHeap->uiCurState
1268 //! pointer to avalible vebox heap instance index and clear
1269 //! bBusy flag for it
1270 //! MOS_STATUS_UNKNOWN: invalid, no available vebox heap instance available + timeout
1271 //!
1272 MOS_STATUS AssignVeboxState();
1273
1274 //!
1275 //! \brief Get Vebox Heap Information
1276 //! \details Get Vebox Heap pointer to access Vebox Heap information
1277 //! \param [out] ppVeboxHeap
1278 //! Pointer to const Vebox Heap Structure
1279 //! \return MOS_STATUS
1280 //!
1281 MOS_STATUS GetVeboxHeapInfo(
1282 const MHW_VEBOX_HEAP **ppVeboxHeap);
1283
1284 //!
1285 //! \brief Update Vebox Sync tag info
1286 //! \details Update Vebox Heap Sync tag info
1287 //! \return MOS_STATUS
1288 //!
1289 MOS_STATUS UpdateVeboxSync();
1290
1291 //!
1292 //! \brief Set which vebox can be used by HW
1293 //! \details VPHAL set which VEBOX can be use by HW
1294 //! \param [in] dwVeboxIndex
1295 //! set which Vebox can be used by HW
1296 //! \param [in] dwVeboxCount
1297 //! set Vebox Count
1298 //! \param [in] dwUsingSFC
1299 //! set whether using SFC
1300 //! \return MOS_STATUS
1301 //! MOS_STATUS_SUCCESS if success, else fail reason
1302 virtual MOS_STATUS SetVeboxIndex(
1303 uint32_t dwVeboxIndex,
1304 uint32_t dwVeboxCount,
1305 uint32_t dwUsingSFC)
1306 {
1307 MOS_UNUSED(dwVeboxIndex);
1308 MOS_UNUSED(dwVeboxCount);
1309 MOS_UNUSED(dwUsingSFC);
1310 return MOS_STATUS_SUCCESS;
1311 }
1312
1313 private:
1314 //!
1315 //! \brief Refresh Vebox Sync
1316 //! \details Update Vebox Heap Sync tags and clear bBusy flag in availble
1317 //! pVeboxHeap->pStates
1318 //! \return void
1319 //!
1320 void RefreshVeboxSync();
1321
1322 //! \brief Vebox heap instance in use
1323 int m_veboxHeapInUse = 0;
1324
1325 public:
1326 PMOS_INTERFACE m_osInterface = nullptr;
1327 PMHW_VEBOX_HEAP m_veboxHeap = nullptr;
1328 MHW_VEBOX_SETTINGS m_veboxSettings;
1329 bool m_veboxScalabilitywith4K = false;
1330 std::shared_ptr<void> m_veboxItfNew = nullptr;
1331 };
1332
1333 #endif // __MHW_VEBOX_H__