xref: /aosp_15_r20/external/intel-media-driver/media_common/agnostic/common/renderhal/renderhal.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2009-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      renderhal.h
24 //! \brief
25 //!
26 //!
27 //! \file     renderhal.h
28 //! \brief    Render Engine Interfaces shared across platforms
29 //! \details  Platform Independent Hardware Interfaces
30 //!
31 #ifndef __RENDERHAL_H__
32 #define __RENDERHAL_H__
33 
34 #include "mos_os.h"                     // Interface to OS functions
35 #include "mhw_state_heap.h"
36 #include "mhw_render.h"
37 #include "mhw_memory_pool.h"
38 #include "media_perf_profiler.h"
39 #include "frame_tracker.h"
40 #include "media_common_defs.h"
41 #include "surface_state_heap_mgr.h"
42 
43 class XRenderHal_Platform_Interface;
44 
45 //------------------------------------------------------------------------------
46 // Macros specific to RenderHal sub-comp
47 //------------------------------------------------------------------------------
48 #define MHW_RENDERHAL_ASSERT(_expr)                                                       \
49     MOS_ASSERT(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, _expr)
50 
51 #define MHW_RENDERHAL_ASSERTMESSAGE(_message, ...)                                        \
52     MOS_ASSERTMESSAGE(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, _message, ##__VA_ARGS__)
53 
54 #define MHW_RENDERHAL_NORMALMESSAGE(_message, ...)                                        \
55     MOS_NORMALMESSAGE(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, _message, ##__VA_ARGS__)
56 
57 #define MHW_RENDERHAL_VERBOSEMESSAGE(_message, ...)                                       \
58     MOS_VERBOSEMESSAGE(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, _message, ##__VA_ARGS__)
59 
60 #define MHW_RENDERHAL_FUNCTION_ENTER                                                      \
61     MOS_FUNCTION_ENTER(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL)
62 
63 #define MHW_RENDERHAL_FUNCTION_EXIT                                                      \
64     MOS_FUNCTION_EXIT(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, eStatus)
65 
66 #define MHW_RENDERHAL_CHK_STATUS(_stmt)                                                   \
67     MOS_CHK_STATUS(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, _stmt)
68 
69 #define MHW_RENDERHAL_CHK_STATUS_RETURN(_stmt)                                        \
70     MOS_CHK_STATUS_RETURN(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_PUBLIC, _stmt)
71 
72 #define MHW_RENDERHAL_CHK_STATUS_MESSAGE(_stmt, _message, ...)                        \
73     MOS_CHK_STATUS_MESSAGE(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, _stmt, _message, ##__VA_ARGS__)
74 
75 #define MHW_RENDERHAL_CHK_NULL(_ptr)                                                      \
76     MOS_CHK_NULL(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, _ptr)
77 
78 #define MHW_RENDERHAL_CHK_NULL_NO_STATUS(_ptr)                                            \
79     MOS_CHK_NULL_NO_STATUS(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, _ptr)
80 
81 #define MHW_RENDERHAL_CHK_NULL_NO_STATUS_RETURN(_ptr)                                            \
82     MOS_CHK_NULL_NO_STATUS_RETURN(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, _ptr)
83 
84 #define MHW_RENDERHAL_CHK_NULL_RETURN(_ptr)                                            \
85     MOS_CHK_NULL_RETURN(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, _ptr)
86 
87 
88 #define MHW_RENDERHAL_UNUSED(x)                                                         \
89     MOS_UNUSED(x)
90 
91 //!
92 //! \brief  Kernel allocation control
93 //!
94 #define RENDERHAL_KERNEL_LOAD_FAIL         -1
95 #define RENDERHAL_KERNEL_ALLOCATION_FREE    0   // Kernel entry free
96 #define RENDERHAL_KERNEL_ALLOCATION_USED    1   // Kernel entry in use
97 #define RENDERHAL_KERNEL_ALLOCATION_LOCKED  2   // Kernel entry locked (no garbage collection)
98 #define RENDERHAL_KERNEL_ALLOCATION_REMOVED 3   // Kernel entry in use, but no longer loaded in ISH to make room for others
99 #define RENDERHAL_KERNEL_ALLOCATION_LOADING 4   // Kernel selected to be loaded (was stale or used)
100 #define RENDERHAL_KERNEL_ALLOCATION_STALE   5   // Kernel memory block became invalid, needs to be reloaded
101 
102 //!
103 //! \brief  SSH defaults and limits
104 //!
105 #define RENDERHAL_SSH_INSTANCES            16
106 #define RENDERHAL_SSH_INSTANCES_MAX        64
107 
108 #define RENDERHAL_SSH_BINDING_TABLES        1
109 #define RENDERHAL_SSH_BINDING_TABLES_MIN    1
110 #define RENDERHAL_SSH_BINDING_TABLES_MAX   16
111 #define RENDERHAL_SSH_BINDING_TABLE_ALIGN  64
112 
113 #define RENDERHAL_SSH_SURFACE_STATES       40
114 #define RENDERHAL_SSH_SURFACE_STATES_MIN   16
115 #define RENDERHAL_SSH_SURFACE_STATES_MAX   256
116 
117 #define RENDERHAL_SSH_SURFACES_PER_BT      64
118 #define RENDERHAL_SSH_SURFACES_PER_BT_MIN  4
119 #define RENDERHAL_SSH_SURFACES_PER_BT_MAX  256
120 
121 //!
122 //! \brief  Default size of area for sync, debugging, performance collecting
123 //!
124 #define RENDERHAL_SYNC_SIZE_MIN             128
125 #define RENDERHAL_SYNC_SIZE_MAX             4096
126 #define RENDERHAL_SYNC_SIZE                 128
127 
128 //!
129 //! \brief  Default number of media states (Dynamic GSH mode)
130 //!
131 #define RENDERHAL_MEDIA_STATES              16
132 
133 //!
134 //! \brief  Default number of media IDs
135 //!
136 #define RENDERHAL_MEDIA_IDS                 16
137 
138 //!
139 //! \brief  Max URB Size
140 //!
141 #define RENDERHAL_URB_SIZE_MAX              2048
142 
143 //!
144 //! \brief  Interface Descriptor Entries
145 //!
146 #define RENDERHAL_INTERFACE_DESCRIPTOR_ENTRIES_MAX  64
147 
148 //!
149 //! \brief  Max URB Entry Size
150 //!
151 #define RENDERHAL_URB_ENTRY_SIZE_MAX        (RENDERHAL_URB_SIZE_MAX - RENDERHAL_INTERFACE_DESCRIPTOR_ENTRIES_MAX)
152 
153 //!
154 //! \brief  Max CURBE Allocation Size
155 //!
156 #define RENDERHAL_CURBE_SIZE_MAX            (RENDERHAL_URB_SIZE_MAX - RENDERHAL_INTERFACE_DESCRIPTOR_ENTRIES_MAX)
157 
158 //!
159 //! \brief  Max Samplers
160 //!
161 #define RENDERHAL_SAMPLERS_AVS_MAX          8
162 
163 //!
164 //! \brief  Default Samplers
165 //!
166 #define RENDERHAL_SAMPLERS                  16
167 #define RENDERHAL_SAMPLERS_VA               8
168 
169 //!
170 //! \brief  Default CURBE size in GSH
171 //!         Use the size of composition kernel static param since it's the largest of all
172 //!
173 #define RENDERHAL_CURBE_SIZE                832  // MOS ALIGN CEIL(sizeof(GPGPU_WALKER_ISTAB_GMC_STATIC_DATA_G8), RENDERHAL_URB_BLOCK_ALIGN)
174 
175 //!
176 //! \brief  Default number of kernels that may be cached in GSH
177 //!
178 #define RENDERHAL_KERNEL_COUNT             32
179 
180 //!
181 //! \brief  Max number of kernels cached in GSH
182 //!
183 #define RENDERHAL_KERNEL_COUNT_MIN          2
184 
185 //!
186 //! \brief  Default kernel heap size
187 //!
188 #define RENDERHAL_KERNEL_HEAP               2097152
189 
190 //!
191 //! \brief  Min kernel heap size
192 //!
193 #define RENDERHAL_KERNEL_HEAP_MIN           65536
194 #define RENDERHAL_KERNEL_HEAP_MAX           2097152
195 
196 //!
197 //! \brief  Default kernel block size (granularity for kernel allocation)
198 //!
199 #define RENDERHAL_KERNEL_BLOCK_SIZE         65536
200 
201 //!
202 //! \brief  Default ISA ASM Debug Surface BTI
203 //!
204 #define RENDERHAL_ISA_ASM_SURFACE_BTI_DEFAULT   39
205 
206 //!
207 //! \brief  Min kernel block size
208 //!
209 #define RENDERHAL_KERNEL_BLOCK_MIN          1024
210 #define RENDERHAL_KERNEL_BLOCK_MAX          65536
211 
212 //!
213 //! \brief  Max number of Media Threads
214 //!
215 #define RENDERHAL_USE_MEDIA_THREADS_MAX     0
216 
217 //!
218 //! \brief  Number and size of palettes
219 //!
220 #define RENDERHAL_PALETTE_COUNT             2
221 #define RENDERHAL_PALETTE_MAX               2
222 
223 #define RENDERHAL_PALETTE_ENTRIES           256
224 #define RENDERHAL_PALETTE_ENTRIES_MAX       256
225 
226 //!
227 //! \brief  SIP Size
228 //!
229 #define RENDERHAL_MAX_SIP_SIZE              0x4000
230 
231 //!
232 //! \brief  Number of chroma keys
233 //!
234 #define RENDERHAL_CHROMA_KEY_COUNT          4
235 #define RENDERHAL_CHROMA_KEY_MAX            4
236 
237 //!
238 //! \brief  Alignment
239 //!
240 #define RENDERHAL_KERNEL_BLOCK_ALIGN        64
241 #define RENDERHAL_URB_BLOCK_ALIGN           64
242 #define RENDERHAL_SYNC_BLOCK_ALIGN          128
243 #define RENDERHAL_CURBE_BLOCK_ALIGN         64
244 
245 //!
246 //! \brief  Max number of Y_Uoffset size
247 //!
248 #define RENDERHAL_MAX_YV12_PLANE_Y_U_OFFSET_G9          16383
249 
250 //!
251 //! \brief  Palette allocation id
252 //!
253 #define RENDERHAL_PALETTE_ID_ALLOCATE_ONLY  -2  // Allocate but don't load palette
254 #define RENDERHAL_PALETTE_ID_ALLOCATE_LOAD  -1  // Allocate and load palette
255 
256 //!
257 //! \brief  Hw Interface defaults
258 //!
259 #define RENDERHAL_TIMEOUT_MS_DEFAULT        100
260 #define RENDERHAL_EVENT_TIMEOUT_MS          5
261 
262 //!
263 //! \brief  Sampler State Indices
264 //!
265 #define RENDERHAL_SAMPLER_Y                 1
266 #define RENDERHAL_SAMPLER_U                 2
267 #define RENDERHAL_SAMPLER_V                 3
268 #define RENDERHAL_SAMPLER_8x8_AVS_Y         4
269 #define RENDERHAL_SAMPLER_8x8_AVS_U         8
270 #define RENDERHAL_SAMPLER_8x8_AVS_V         12
271 
272 //*-----------------------------------------------------------------------------
273 //| MMIO register offsets used for the EU debug support
274 //*-----------------------------------------------------------------------------
275 
276 
277 
278 #define MEDIASTATE_AVS_MAX_DERIVATIVE_4_PIXELS  7
279 #define MEDIASTATE_AVS_MAX_DERIVATIVE_8_PIXELS  20
280 #define MEDIASTATE_AVS_TRANSITION_AREA_4_PIXELS 4
281 #define MEDIASTATE_AVS_TRANSITION_AREA_8_PIXELS 5
282 
283 enum GFX_COMMON_TOKEN_SUBOPCODE
284 {
285     GFXSUBOP_BINDING_TABLE_STATE_TOKEN  = 0xFE,
286     GFXSUBOP_SURFACE_STATE_TOKEN        = 0xFF
287 };
288 
289 enum MEDIASTATE_AVS_SHARPNESS_LEVEL
290 {
291     MEDIASTATE_AVS_SHARPNESS_LEVEL_SMOOTH = 0,
292     MEDIASTATE_AVS_SHARPNESS_LEVEL_SHARP  = 255
293 };
294 
295 // Render chroma siting vertical value
296 enum CHROMA_SITING_VDIRECTION
297 {
298     CHROMA_SITING_VDIRECTION_0   = 0x0,
299     CHROMA_SITING_VDIRECTION_1_4 = 0x1,
300     CHROMA_SITING_VDIRECTION_1_2 = 0x2,
301     CHROMA_SITING_VDIRECTION_3_4 = 0x3,
302     CHROMA_SITING_VDIRECTION_1   = 0x4
303 };
304 
305 // Render chroma siting horizontal value
306 enum CHROMA_SITING_UDIRECTION
307 {
308     CHROMA_SITING_UDIRECTION_LEFT   = 0x0,
309     CHROMA_SITING_UDIRECTION_CENTER = 0x1
310 };
311 
312 enum GFX3DSTATE_TILEWALK
313 {
314     GFX3DSTATE_TILEWALK_XMAJOR                 = 0,
315     GFX3DSTATE_TILEWALK_YMAJOR                 = 1
316 };
317 
318 enum MEDIA_STATE_DEBUG_COUNTER_CONTROL
319 {
320     MEDIASTATE_DEBUG_COUNTER_FREE_RUNNING       = 0,
321     MEDIASTATE_DEBUG_COUNTER_FROZEN             = 1,
322     MEDIASTATE_DEBUG_COUNTER_INITIALIZED_ONCE   = 2,
323     MEDIASTATE_DEBUG_COUNTER_INITIALIZED_ALWAYS = 3
324 };
325 
326 enum MEDIASTATE_BINDING_TABLE_STATE_TYPE
327 {
328     MEDIASTATE_BTS_DEFAULT_TYPE             = 0,
329     MEDIASTATE_BTS_DI_SAMPLE8x8_VME_TYPE    = 1
330 };
331 
332 struct SURFACE_STATE_TOKEN_COMMON
333 {
334     // DWORD 0
335     union
336     {
337         struct
338         {
339             uint32_t   Length                  : 8;    // OP_LENGTH
340             uint32_t                           : 8;
341             uint32_t   InstructionSubOpcode    : 8;    // GFX3DSTATE_PIPELINED_SUBOPCODE
342             uint32_t   InstructionOpcode       : 3;    // GFX_OPCODE
343             uint32_t   InstructionPipeLine     : 2;    // INSTRUCTION_PIPELINE
344             uint32_t   InstructionType         : 2;    // INSTRUCTION_TYPE
345             uint32_t   Token                   : 1;    // bool
346         };
347 
348         // DriverID for IMOLA patching
349         struct
350         {
351             uint32_t   DriverID;
352         };
353 
354         struct
355         {
356             uint32_t   Value;
357         };
358     } DW0;
359 
360     // DWORD 1
361     union
362     {
363         struct
364         {
365             uint32_t   SurfaceStateHeapOffset  : 16;  // U16 32-byte aligned
366             uint32_t   SurfaceAllocationIndex  : 16;  // U16
367         };
368         struct
369         {
370             uint32_t   Value;
371         };
372     } DW1;
373 
374     // DWORD 2
375     union
376     {
377         struct
378         {
379             uint32_t   SurfaceOffset           : 32;
380         };
381         struct
382         {
383             uint32_t   Value;
384         };
385     } DW2;
386 
387     // DWORD 3
388     union
389     {
390         struct
391         {
392             uint32_t   RenderTargetEnable      : 1;  // bool
393             uint32_t   YUVPlane                : 2;  // U2
394             uint32_t   SurfaceStateType        : 1;  // U1
395         uint32_t: 28;
396         };
397         struct
398         {
399             uint32_t   Value;
400         };
401     } DW3;
402 
403     // DWORD 4
404     union
405     {
406         struct
407         {
408             uint32_t   SurfaceBaseAddress;                                 // SurfaceBaseAddress[31:12]
409         };
410         struct
411         {
412             uint32_t   Value;
413         };
414     } DW4;
415 
416     // DWORD 5
417     union
418     {
419         struct
420         {
421             uint32_t   SurfaceBaseAddress64    : BITFIELD_RANGE(0, 15);    // SurfaceBaseAddress[47:32]
422             uint32_t                           : BITFIELD_RANGE(16, 31);
423         };
424         struct
425         {
426             uint32_t   Value;
427         };
428     } DW5;
429 
430     void*   pResourceInfo;
431 
432 };
433 
434 // Forward declarations
435 typedef struct _RENDERHAL_SURFACE    RENDERHAL_SURFACE, *PRENDERHAL_SURFACE;
436 typedef struct _RENDERHAL_INTERFACE  RENDERHAL_INTERFACE, *PRENDERHAL_INTERFACE;
437 typedef struct _RENDERHAL_SURFACE_STATE_ENTRY *PRENDERHAL_SURFACE_STATE_ENTRY;
438 typedef const struct _RENDERHAL_KERNEL_PARAM CRENDERHAL_KERNEL_PARAM, *PCRENDERHAL_KERNEL_PARAM;
439 
440 //!
441 //! Structure RENDERHAL_SETTINGS
442 //! \brief RenderHal Settings - creation parameters for RenderHal
443 //!
444 typedef struct _RENDERHAL_SETTINGS
445 {
446     int32_t iMediaStates;
447 } RENDERHAL_SETTINGS, *PRENDERHAL_SETTINGS;
448 
449 //!
450 //! Enum RENDERHAL_COMPONENT
451 //! \brief RenderHal client component ID (for debugging/timing)
452 //!
453 typedef enum _RENDERHAL_COMPONENT
454 {
455     RENDERHAL_COMPONENT_UNKNOWN = 0,
456     RENDERHAL_COMPONENT_COMP,
457     RENDERHAL_COMPONENT_DNDI,
458     RENDERHAL_COMPONENT_VEBOX,
459     RENDERHAL_COMPONENT_CM,
460     RENDERHAL_COMPONENT_PACKET,
461     RENDERHAL_COMPONENT_16ALIGN,
462     RENDERHAL_COMPONENT_FAST1TON,
463     RENDERHAL_COMPONENT_HDR,
464     RENDERHAL_COMPONENT_COUNT_BASE,
465     RENDERHAL_COMPONENT_RENDER_COPY,
466     RENDERHAL_COMPONENT_RESERVED_NUM = 16,
467     RENDERHAL_COMPONENT_COUNT
468 } RENDERHAL_COMPONENT;
469 
470 //!
471 //! \brief Scaling Mode enum
472 //!
473 typedef enum _RENDERHAL_SCALING_MODE
474 {
475     RENDERHAL_SCALING_NEAREST,
476     RENDERHAL_SCALING_BILINEAR,
477     RENDERHAL_SCALING_AVS
478 } RENDERHAL_SCALING_MODE;
479 
480 //!
481 //! \brief Surface types enum
482 //!        IMPORTANT : SurfaceType_Layer[] must be updated to match this enum type
483 //!
484 typedef enum _RENDERHAL_SURFACE_TYPE
485 {
486     RENDERHAL_SURF_NONE = 0,
487     RENDERHAL_SURF_IN_BACKGROUND,
488     RENDERHAL_SURF_IN_PRIMARY,
489     RENDERHAL_SURF_IN_SUBSTREAM,
490     RENDERHAL_SURF_IN_REFERENCE,
491     RENDERHAL_SURF_OUT_RENDERTARGET,
492     RENDERHAL_SURF_TYPE_COUNT                 //!< Keep this line at the end
493 } RENDERHAL_SURFACE_TYPE;
494 
495 //!
496 //! \brief Batch buffer types enum
497 //!
498 typedef enum _RENDERHAL_BB_TYPE
499 {
500     RENDERHAL_BB_TYPE_UNKNOWN        = 0, // Batch Buffer created by unknown client
501     RENDERHAL_BB_TYPE_CM             = 6, // Batch Buffer created by Media Development Framework (CM) component
502     RENDERHAL_BB_TYPE_COUNT
503 } RENDERHAL_BB_TYPE;
504 
505 //!
506 //! \brief Sample Type enum
507 //!
508 typedef enum _RENDERHAL_SAMPLE_TYPE
509 {
510     RENDERHAL_SAMPLE_PROGRESSIVE,
511     RENDERHAL_SAMPLE_SINGLE_TOP_FIELD,
512     RENDERHAL_SAMPLE_SINGLE_BOTTOM_FIELD,
513     RENDERHAL_SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD,
514     RENDERHAL_SAMPLE_INTERLEAVED_EVEN_FIRST_BOTTOM_FIELD,
515     RENDERHAL_SAMPLE_INTERLEAVED_ODD_FIRST_TOP_FIELD,
516     RENDERHAL_SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD,
517     RENDERHAL_SAMPLE_INVALID                            //!< Keep this line at the end
518 } RENDERHAL_SAMPLE_TYPE;
519 
520 //!
521 //! Structure RENDERHAL_GET_SURFACE_INFO
522 //! \brief Structure to retrieve Surface Infomation Parameters
523 //!
524 typedef struct _RENDERHAL_GET_SURFACE_INFO
525 {
526     uint32_t          ArraySlice;
527     uint32_t          MipSlice;
528     MOS_S3D_CHANNEL   S3dChannel;
529 } RENDERHAL_GET_SURFACE_INFO, *PRENDERHAL_GET_SURFACE_INFO;
530 
531 //!
532 //! \brief  Structure of power control info
533 //!
534 typedef struct _RENDERHAL_POWEROPTION
535 {
536     uint16_t nSlice;                      //!< Number of slices to use: 0 (default), 1, 2...
537     uint16_t nSubSlice;                   //!< Number of subslices to use: 0 (default), 1, 2...
538     uint16_t nEU;                         //!< Number of EUs to use: 0 (default), 1, 2...
539 } RENDERHAL_POWEROPTION, *PRENDERHAL_POWEROPTION;
540 
541 //!
542 //! Structure RENDERHAL_SURFACE
543 //! \brief RENDERHAL surface definition
544 //!
545 typedef struct _RENDERHAL_SURFACE
546 {
547     MOS_SURFACE                 OsSurface;          //!< Surface provided by the client
548 
549     // Auxiliary rendering parameters
550     RENDERHAL_SURFACE_TYPE      SurfType;           //!< Surface Type (context)
551     RENDERHAL_SCALING_MODE      ScalingMode;        //!< Scaling Mode
552     MHW_ROTATION                Rotation;           //!< Rotation Mode
553     uint32_t                    ChromaSiting;       //!< Chroma Siting
554 
555     // Src/Dst rectangles
556     RECT                        rcSrc;              //!< Source rectangle
557     RECT                        rcDst;              //!< Destination rectangle
558     RECT                        rcMaxSrc;           //!< Max source rectangle
559 
560     // Auxiliary VP parameters provided by client
561     bool                        bDeinterlaceEnable; //!< Active Deinterlace messages
562     bool                        bQueryVariance;     //!< enable variance query
563     bool                        bInterlacedScaling; //!< Interlaced scaling
564     void                        *pDeinterlaceParams; //!< Pointer to Deinterlacing parameters
565     RENDERHAL_SAMPLE_TYPE       SampleType;         //!< Interlaced/Progressive sample type
566     int32_t                     iPaletteID;         //!<Palette ID
567 
568     uint32_t                    dwWidthInUse;       //!< the actual width in use
569     uint32_t                    dwHeightInUse;      //!< the actual height in use
570 } RENDERHAL_SURFACE , *PRENDERHAL_SURFACE;
571 
572 //!
573 //! Structure RENDERHAL_OFFSET_OVERRIDE
574 //! \brief structure used to alloce Surface State overrides for Kernel
575 //!
576 typedef struct _RENDERHAL_OFFSET_OVERRIDE
577 {
578     // Y plane adjustment
579     int32_t iYOffsetAdjust;             //!< Surface Offset adjustment for Y plane
580     int32_t iYOffsetX;                  //!< X-Offset override for Y plane
581     int32_t iYOffsetY;                  //!< Y-Offset override for Y plane
582 
583     // UV plane overrides/adjustmenty
584     int32_t iUVOffsetAdjust;            //!< Surface Offset adjustment for UV plane
585     int32_t iUVOffsetX;                 //!< X-Offset override for UV plane
586     int32_t iUVOffsetY;                 //!< Y-Offset override for UV plane
587 } RENDERHAL_OFFSET_OVERRIDE, *PRENDERHAL_OFFSET_OVERRIDE;
588 
589 typedef enum _RENDERHAL_SURFACE_STATE_TYPE
590 {
591     RENDERHAL_SURFACE_TYPE_INVALID  = 0,
592     RENDERHAL_SURFACE_TYPE_G8       ,
593     RENDERHAL_SURFACE_TYPE_G9       ,
594     RENDERHAL_SURFACE_TYPE_G10      ,
595     RENDERHAL_SURFACE_TYPE_ADV_G8   ,
596     RENDERHAL_SURFACE_TYPE_ADV_G9   ,
597     RENDERHAL_SURFACE_TYPE_ADV_G10
598 } RENDERHAL_SURFACE_STATE_TYPE, *PRENDERHAL_SURFACE_STATE_TYPE;
599 
600 typedef enum _RENDERHAL_PLANE_DEFINITION
601 {
602     RENDERHAL_PLANES_PL3            = 0,
603     RENDERHAL_PLANES_NV12              ,
604     RENDERHAL_PLANES_YUY2              ,
605     RENDERHAL_PLANES_UYVY              ,
606     RENDERHAL_PLANES_YVYU              ,
607     RENDERHAL_PLANES_VYUY              ,
608     RENDERHAL_PLANES_ARGB              ,
609     RENDERHAL_PLANES_XRGB              ,
610     RENDERHAL_PLANES_ABGR              ,
611     RENDERHAL_PLANES_XBGR              ,
612     RENDERHAL_PLANES_RGB16             ,
613     RENDERHAL_PLANES_RGB24             ,
614     RENDERHAL_PLANES_R16U              ,
615     RENDERHAL_PLANES_R16S              ,
616     RENDERHAL_PLANES_R32U              ,
617     RENDERHAL_PLANES_R32S              ,
618     RENDERHAL_PLANES_R32F              ,
619     RENDERHAL_PLANES_V8U8              ,
620     RENDERHAL_PLANES_R8G8_UNORM        ,
621     RENDERHAL_PLANES_411P              ,
622     RENDERHAL_PLANES_411R              ,
623     RENDERHAL_PLANES_422H              ,
624     RENDERHAL_PLANES_422V              ,
625     RENDERHAL_PLANES_444P              ,
626     RENDERHAL_PLANES_RGBP              ,
627     RENDERHAL_PLANES_BGRP              ,
628 
629     RENDERHAL_PLANES_AI44_PALLETE_0    ,
630     RENDERHAL_PLANES_IA44_PALLETE_0    ,
631     RENDERHAL_PLANES_P8_PALLETE_0      ,
632     RENDERHAL_PLANES_A8P8_PALLETE_0    ,
633     RENDERHAL_PLANES_AI44_PALLETE_1    ,
634     RENDERHAL_PLANES_IA44_PALLETE_1    ,
635     RENDERHAL_PLANES_P8_PALLETE_1      ,
636     RENDERHAL_PLANES_A8P8_PALLETE_1    ,
637 
638     RENDERHAL_PLANES_AYUV              ,
639     RENDERHAL_PLANES_STMM              ,
640     RENDERHAL_PLANES_L8                ,
641 
642     RENDERHAL_PLANES_PL3_ADV           ,
643     RENDERHAL_PLANES_NV12_ADV          ,
644     RENDERHAL_PLANES_YUY2_ADV          ,
645     RENDERHAL_PLANES_UYVY_ADV          ,
646     RENDERHAL_PLANES_YVYU_ADV          ,
647     RENDERHAL_PLANES_VYUY_ADV          ,
648     RENDERHAL_PLANES_ARGB_ADV          ,
649     RENDERHAL_PLANES_ABGR_ADV          ,
650     RENDERHAL_PLANES_AYUV_ADV           ,
651     RENDERHAL_PLANES_STMM_ADV          ,
652     RENDERHAL_PLANES_L8_ADV            ,
653     RENDERHAL_PLANES_A8_ADV            ,
654     RENDERHAL_PLANES_A8                ,
655     RENDERHAL_PLANES_R8                ,
656     RENDERHAL_PLANES_NV12_2PLANES      ,
657     RENDERHAL_PLANES_NV12_2PLANES_ADV  ,
658     RENDERHAL_PLANES_411P_ADV          ,
659     RENDERHAL_PLANES_411R_ADV          ,
660     RENDERHAL_PLANES_422H_ADV          ,
661     RENDERHAL_PLANES_422V_ADV          ,
662     RENDERHAL_PLANES_444P_ADV          ,
663     RENDERHAL_PLANES_RGBP_ADV          ,
664     RENDERHAL_PLANES_BGRP_ADV          ,
665     RENDERHAL_PLANES_R16_UNORM         ,
666     RENDERHAL_PLANES_Y8                ,
667     RENDERHAL_PLANES_Y1                ,
668     RENDERHAL_PLANES_Y16U              ,
669     RENDERHAL_PLANES_Y16S              ,
670     RENDERHAL_PLANES_A16B16G16R16      ,
671     RENDERHAL_PLANES_A16B16G16R16_ADV  ,
672     RENDERHAL_PLANES_R10G10B10A2       ,
673     RENDERHAL_PLANES_R10G10B10A2_ADV   ,
674     RENDERHAL_PLANES_B10G10R10A2       ,
675     RENDERHAL_PLANES_L16               ,
676     RENDERHAL_PLANES_NV21              ,
677     RENDERHAL_PLANES_YV12              ,
678     RENDERHAL_PLANES_P016              ,
679     RENDERHAL_PLANES_P016_2PLANES_ADV  ,
680     RENDERHAL_PLANES_P010              ,
681     RENDERHAL_PLANES_P010_1PLANE       ,
682     RENDERHAL_PLANES_P010_1PLANE_ADV   ,
683     RENDERHAL_PLANES_IRW0              ,
684     RENDERHAL_PLANES_IRW1              ,
685     RENDERHAL_PLANES_IRW2              ,
686     RENDERHAL_PLANES_IRW3              ,
687     RENDERHAL_PLANES_A16B16G16R16F     ,
688     RENDERHAL_PLANES_R16G16_UNORM      ,
689     RENDERHAL_PLANES_R16_FLOAT         ,
690     RENDERHAL_PLANES_A16R16G16B16F     ,
691     RENDERHAL_PLANES_YUY2_2PLANES      ,
692     RENDERHAL_PLANES_Y210_ADV          ,
693     RENDERHAL_PLANES_Y210_RT           ,
694     RENDERHAL_PLANES_Y210              ,
695     RENDERHAL_PLANES_Y210_1PLANE_ADV   ,
696     RENDERHAL_PLANES_R16G16_SINT       ,
697     RENDERHAL_PLANES_R24_UNORM_X8_TYPELESS,
698     RENDERHAL_PLANES_R32_FLOAT_X8X24_TYPELESS,
699     RENDERHAL_PLANES_P208,
700     RENDERHAL_PLANES_P208_1PLANE_ADV,
701     RENDERHAL_PLANES_Y416_RT,
702     RENDERHAL_PLANES_R32G32B32A32F,
703     RENDERHAL_PLANES_Y8_ADV,
704     RENDERHAL_PLANES_G32R32F,
705     RENDERHAL_PLANES_NV12_2PLANES_COMBINED,
706     RENDERHAL_PLANES_P016_2PLANES_COMBINED,
707     RENDERHAL_PLANES_YUY2_2PLANES_WIDTH_UNALIGNED,
708 
709     RENDERHAL_PLANES_DEFINITION_COUNT
710 } RENDERHAL_PLANE_DEFINITION, *PRENDERHAL_PLANE_DEFINITION;
711 
712 typedef enum _RENDERHAL_SS_BOUNDARY
713 {
714     RENDERHAL_SS_BOUNDARY_SRCRECT = 0,                                                    // use for sources read via sampler
715     RENDERHAL_SS_BOUNDARY_DSTRECT ,                                                       // use for RT by default
716     RENDERHAL_SS_BOUNDARY_MAXSRCRECT,                                                     // use max source rect
717     RENDERHAL_SS_BOUNDARY_ORIGINAL,                                                       // use for surfs that are not source or RT
718 } RENDERHAL_SS_BOUNDARY;
719 
720 //!
721 //! \brief  Surface cache attributes
722 //!
723 #define RENDERHAL_MEMORY_OBJECT_CONTROL     uint32_t
724 
725 typedef struct _RENDERHAL_KERNEL_PARAM
726 {
727     int32_t             GRF_Count;                                              // Number of registers
728     int32_t             BT_Count;                                               // Number of BT entries
729     int32_t             Sampler_Count;                                          // Number of samplers
730     int32_t             Thread_Count;                                           // Number of threads (max)
731     int32_t             GRF_Start_Register;                                     // Start register
732     int32_t             CURBE_Length;                                           // Constant URB length (in 256-bits)
733     int32_t             block_width;                                            // Block width
734     int32_t             block_height;                                           // Block height
735     int32_t             blocks_x;                                               // Blocks in x
736     int32_t             blocks_y;                                               // Blocks in y
737 } RENDERHAL_KERNEL_PARAM, *PRENDERHAL_KERNEL_PARAM;
738 
739 typedef struct _RENDERHAL_CLONE_KERNEL_PARAM
740 {
741     bool                isClone;                                                // If kernel has been cloned from another kernel (i.e. share same kernel binary)
742     bool                isHeadKernel;                                           // If kernel is the "head" kernel (i.e. this allocation contains the kernel binary)
743     int32_t             referenceCount;                                         // Number of cloned kernels currently pointing to the head kernel
744     int32_t             cloneKernelID;                                          // Kernel ID of source kernel (i.e. kernel used to clone)
745     int32_t             kernelBinaryAllocID;                                    // Allocation ID of the head kernel that contains the actual kernel binary
746     uint32_t            dwOffsetForAllocID;                                     // Save the offset for this allocation ID, if clone using a different offset to point to head kernel binary
747 }RENDERHAL_CLONE_KERNEL_PARAM, *PRENDERHAL_CLONE_KERNEL_PARAM;
748 
749 typedef struct tagKdll_CacheEntry Kdll_CacheEntry;
750 typedef struct _RENDERHAL_KRN_ALLOCATION *PRENDERHAL_KRN_ALLOCATION;
751 typedef struct _RENDERHAL_KRN_ALLOC_LIST *PRENDERHAL_KRN_ALLOC_LIST;
752 
753 typedef struct _RENDERHAL_KRN_ALLOCATION
754 {
755     int32_t                      iKID;                                          // Interface descriptor ID for the kernel (for 2nd level buffer)
756     int32_t                      iKUID;                                         // Kernel Unique ID
757     int32_t                      iKCID;                                         // Kernel Cache ID
758     uint32_t                     dwSync;                                        // Kernel last sync (used to determine whether the kernel may be unloaded)
759     FrameTrackerTokenFlat        trackerToken;                                  // Kernel last sync with multiple trackers
760     uint32_t                     dwOffset;                                      // Kernel offset in GSH (from GSH base, 0 is KAC entry is available)
761     int32_t                      iSize;                                         // Kernel block size in GSH (0 if not loaded)
762     uint32_t                     dwFlags : 4;                                   // Kernel allocation flag
763     uint32_t                     dwCount : 28;                                  // Kernel refresh counter
764     RENDERHAL_KERNEL_PARAM       Params;                                        // Kernel parameters for RenderHal (states, rendering, etc)
765     PMHW_KERNEL_PARAM            pMhwKernelParam;                               // Pointer to Kernel parameters for MHW
766     Kdll_CacheEntry             *pKernelEntry;                                  // Pointer to Kernel entry for VP/KDLL
767     RENDERHAL_CLONE_KERNEL_PARAM cloneKernelParams;                             // CM - Clone kernel information
768     int32_t                 iAllocIndex;                                        // Kernel allocation index (index in kernel allocation table)
769 
770     // DSH - Dynamic list of kernel allocations
771     PMHW_STATE_HEAP_MEMORY_BLOCK pMemoryBlock;                                  // Memory block in ISH
772     PRENDERHAL_KRN_ALLOCATION    pNext;                                         // Next kernel in list
773     PRENDERHAL_KRN_ALLOCATION    pPrev;                                         // Prev kernel in list
774     PRENDERHAL_KRN_ALLOC_LIST    pList;                                         // Points to current list, regardless of flag
775     uint32_t                     Reserved    : 16;                              // Reserved    - used for debugging
776     uint32_t                                 : 16;                              //
777     char                         *szKernelName;                                  // Kernel name - used for debugging
778 } RENDERHAL_KRN_ALLOCATION, *PRENDERHAL_KRN_ALLOCATION;
779 
780 typedef struct _RENDERHAL_KRN_ALLOC_LIST
781 {
782     PRENDERHAL_KRN_ALLOCATION pHead;                                            // Head of the list
783     PRENDERHAL_KRN_ALLOCATION pTail;                                            // Tail of the list
784     int32_t                   iCount;                                           // Number of objects
785 } RENDERHAL_KRN_ALLOC_LIST, *PRENDERHAL_KRN_ALLOC_LIST;
786 
787 typedef struct _RENDERHAL_MEDIA_STATE *PRENDERHAL_MEDIA_STATE;
788 
789 typedef struct _RENDERHAL_MEDIA_STATE
790 {
791     // set at creation time
792     uint32_t            dwOffset;                                               // Media State Base Address (from GSH base) - VFE
793     int32_t             *piAllocation;                                           // Kernel allocation table
794 
795     // set at runtime
796     uint32_t            dwSyncTag;                                              // Sync Tag
797     FrameTrackerTokenFlat trackerToken;
798     uint32_t            dwSyncCount;                                            // Number of sync tags
799     int32_t             iCurbeOffset;                                           // Current CURBE Offset
800     uint32_t            bBusy   : 1;                                            // 1 if the state is in use (must sync before use)
801     uint32_t                    : 15;
802     uint32_t            Reserved: 16;
803 
804     PRENDERHAL_MEDIA_STATE      pPrev;                                          // Next Media State
805     PRENDERHAL_MEDIA_STATE      pNext;                                          // Previous Media State
806 } RENDERHAL_MEDIA_STATE, *PRENDERHAL_MEDIA_STATE;
807 
808 typedef struct _RENDERHAL_MEDIA_STATE_LIST
809 {
810     PRENDERHAL_MEDIA_STATE  pHead;                                              // Head of the list
811     PRENDERHAL_MEDIA_STATE  pTail;                                              // Tail of the list
812     int32_t                 iCount;                                             // Number of objects
813 } RENDERHAL_MEDIA_STATE_LIST, *PRENDERHAL_MEDIA_STATE_LIST;
814 
815 struct RENDERHAL_TR_RESOURCE {
816     MOS_RESOURCE    osResource;
817     bool            locked;
818     uint32_t        *data;
819     uint32_t        currentTrackerId;
820 };
821 
822 typedef struct _RENDERHAL_STATE_HEAP_SETTINGS
823 {
824     // Global GSH Allocation parameters
825     int32_t             iSyncSize;                                              // Sync area for sync, perf, debug
826 
827     // Media State Allocation parameters
828     int32_t             iMediaStateHeaps;                                       // Number of Media State heaps
829     int32_t             iMediaIDs;                                              // Number of Media Interface Descriptors
830     int32_t             iCurbeSize;                                             // Size of CURBE area
831     int32_t             iSamplers;                                              // Number of Samplers/ID
832     int32_t             iSamplersAVS;                                           // Number of AVS Samplers/ID
833     int32_t             iSamplersVA;                                            // Number of Video Analytics Samplers/ID
834     int32_t             iKernelCount;                                           // Number of Kernels that can be loaded
835     int32_t             iKernelHeapSize;                                        // Size of GSH block for kernels
836     int32_t             iKernelBlockSize;                                       // Kernel allocation block
837 
838     // Media VFE/ID configuration, limits
839     int32_t             iPerThreadScratchSize;                                  // Size of the Scratch memory per Thread
840     int32_t             iSipSize;                                               // SIP size
841 
842     // Surface State Heap Settings
843     int32_t             iSurfaceStateHeaps;                                     // Number of SSH instances (same as iMediaStateHeaps)
844     int32_t             iBindingTables;                                         // Number of BT per SSH instance
845     int32_t             iSurfaceStates;                                         // Number of Surfaces per SSH
846     int32_t             iSurfacesPerBT;                                         // Number of Surfaces per BT
847     int32_t             iBTAlignment;                                           // BT Alignment size
848     MOS_HW_RESOURCE_DEF heapUsageType;
849 } RENDERHAL_STATE_HEAP_SETTINGS, *PRENDERHAL_STATE_HEAP_SETTINGS;
850 
851 typedef struct _RENDERHAL_STATE_HEAP
852 {
853     //---------------------------
854     // General State Heap
855     //---------------------------
856     uint32_t                dwSizeGSH;                                          // GSH size
857     MOS_RESOURCE            GshOsResource;                                      // GSH OS Buffer
858     bool                    bGshLocked;                                         // GSH is locked
859     uint8_t                 *pGshBuffer;                                         // Pointer to GSH buffer data
860 
861     // Dynamic GSH sync
862     uint32_t                dwOffsetSync;                                       // Offset of sync/perf data in GSH
863     uint32_t                dwSizeSync;                                         // Size of sync data
864 
865     // Synchronization / Performance / Statistics
866     volatile uint32_t       *pSync;                                              // Pointer to sync area (when locked)
867     uint32_t                dwNextTag;                                          // Next sync tag value to use
868     uint32_t                dwSyncTag;                                          // Last sync tag completed
869     uint32_t                dwFrameId;                                          // Last frame id completed
870 
871     // Media states
872     int32_t                 iCurMediaState;                                     // Current Media State Index
873     int32_t                 iNextMediaState;                                    // Next Media State Index
874     PRENDERHAL_MEDIA_STATE  pCurMediaState;                                     // Current Media state in use
875     uint32_t                dwSizeMediaState;                                   // Size of Media state
876 
877     uint32_t                dwOffsetMediaID;                                    // Offset to Media IDs from Media State Base
878     uint32_t                dwSizeMediaID;                                      // Size of each Media ID
879 
880     MHW_ID_ENTRY_PARAMS     CurIDEntryParams = {};                              // Parameters for current Interface Descriptor Entry
881 
882     // Performance capture
883     uint32_t                dwOffsetStartTime;                                  // Offset to the start time of the media state
884     uint32_t                dwStartTimeSize;                                    // Size of Start time
885     uint32_t                dwOffsetEndTime;                                    // Offset to the end time of the media state
886     uint32_t                dwEndTimeSize;                                      // Size of end time
887     uint32_t                dwOffsetComponentID;                                // Render Component
888     uint32_t                dwComponentIDSize;                                  // Render ComponentID size
889     uint32_t                dwOffsetReserved;                                   // Reserved (Curbe should be 64 aligned)
890     uint32_t                dwReservedSize;                                     // 64 - (start time + end time + component)
891 
892     uint32_t                dwOffsetCurbe;                                      // Offset to Media CURBE data from Media State Base
893     uint32_t                dwSizeCurbe;                                        // Size of CURBE area
894 
895     uint32_t                dwOffsetSampler;                                    // Offset to Media Samplers from Media State Base
896     uint32_t                dwSizeSampler;                                      // Size of Samplers
897 
898     uint32_t                dwOffsetSamplerIndirect;                            // Offset to Media Samplers Indirect State from Media State Base
899     uint32_t                dwSizeSamplerIndirect;                              // Size of Samplers Indirect State
900 
901     uint32_t                dwOffsetSampler8x8Table;                            // Offset to Media Sampler State Table for AVS from Media State Base
902     uint32_t                dwSizeSampler8x8Table;                              // Size of Sampler State Table for AVS
903 
904     uint32_t                dwOffsetSamplerVA;                                  // Offset to Video Analytics Samplers from Media State Base
905     uint32_t                dwSizeSamplerVA;                                    // Size of VA Samplers
906 
907     uint32_t                dwOffsetSamplerAVS;                                 // Offset to 8x8 Samplers from Media State Base
908     uint32_t                dwSizeSamplerAVS;                                   // Size of 8x8 Samplers
909 
910     uint32_t                dwSizeSamplers;                                     // Size of All Samplers
911 
912     PRENDERHAL_MEDIA_STATE  pMediaStates;                                       // Media state table
913 
914     // Dynamic Media states
915     PMHW_MEMORY_POOL            pMediaStatesMemPool;                            // Media state memory allocations
916     RENDERHAL_MEDIA_STATE_LIST  FreeStates;                                     // Free media state objects (pool)
917     RENDERHAL_MEDIA_STATE_LIST  ReservedStates;                                 // Reserved media states
918     RENDERHAL_MEDIA_STATE_LIST  SubmittedStates;                                // Submitted media states
919 
920     //---------------------------
921     // Surface State Heap
922     //---------------------------
923     uint32_t                dwSizeSSH;                                          // SSH size
924     MOS_RESOURCE            SshOsResource;                                      // SSH OS Buffer
925     bool                    bSshLocked;                                         // SSH is locked
926     uint8_t                 *pSshBuffer;                                         // Pointer to SSH buffer base
927     uint32_t                dwSshIntanceSize;                                   // SSH instance size
928 
929     // BT size, offsets to BT/SS entries in SSH
930     int32_t                 iBindingTableSize;                                  // Size of each BT (in bytes)
931     int32_t                 iBindingTableOffset;                                // First BT offset in SSH buffer
932     int32_t                 iSurfaceStateOffset;                                // First SS offset in SSH buffer
933 
934     // Array of Surface State control structures
935     PRENDERHAL_SURFACE_STATE_ENTRY  pSurfaceEntry;
936 
937     // Current allocations
938     int32_t                 iCurSshBufferIndex;                                 // Current SSH Buffer instance in the SSH heap
939     int32_t                 iCurrentBindingTable;                               // Current BT
940     int32_t                 iCurrentSurfaceState;                               // Current SS
941 
942     //---------------------------
943     // Instruction State Heap
944     //---------------------------
945     uint32_t                dwSizeISH;                                          // ISH size
946     MOS_RESOURCE            IshOsResource;                                      // ISH OS Buffer
947     bool                    bIshLocked;                                         // ISH is locked
948     uint8_t                 *pIshBuffer;                                         // Pointer to ISH buffer data
949     uint32_t                dwKernelBase;                                       // Offset of kernels in ISH
950 
951     // Kernel Allocation
952     int32_t                 iKernelSize;                                        // Kernel heap size
953     int32_t                 iKernelUsed;                                        // Kernel heap used size
954     uint8_t                 *pKernelLoadMap;                                     // Kernel load map
955     uint32_t                dwAccessCounter;                                    // Incremented when a kernel is loaded/used, for dynamic allocation
956     int32_t                 iKernelUsedForDump;                                 // The kernel size to be dumped in oca buffer.
957 
958     // Kernel Spill Area
959     uint32_t                dwScratchSpaceSize;                                 // Size of the Scratch Area
960     uint32_t                dwScratchSpaceBase;                                 // Base of the Scratch area
961 
962     // System Routine
963     uint32_t                dwSipBase;                                          // Base of the System Routine
964 
965     // Arrays created dynamically
966     PRENDERHAL_KRN_ALLOCATION   pKernelAllocation;                              // Kernel allocation table (or linked list)
967 
968     // Dynamic Kernel States
969     PMHW_MEMORY_POOL               pKernelAllocMemPool;                         // Kernel states memory pool (mallocs)
970     RENDERHAL_KRN_ALLOC_LIST       KernelAllocationPool;                        // Pool of kernel allocation objects
971     RENDERHAL_KRN_ALLOC_LIST       KernelsSubmitted;                            // Kernel submission list
972     RENDERHAL_KRN_ALLOC_LIST       KernelsAllocated;                            // kernel allocation list (kernels in ISH not currently being executed)
973     SurfaceStateHeapManager       *surfaceStateMgr;                             // Surface state manager
974 } RENDERHAL_STATE_HEAP, *PRENDERHAL_STATE_HEAP;
975 
976 typedef struct _RENDERHAL_DYNAMIC_MEDIA_STATE_PARAMS
977 {
978     int32_t             iMaxMediaIDs;               // Maximum number of media interface descriptors
979     int32_t             iMaxThreads;                // Maximum number of threads to be executed (0 = limited to HW threads) - for scratch space allocation
980     int32_t             iMaxSpillSize;              // Maximum spill sizes among all kernels to be executed - used for scratch space allocation
981     int32_t             iMaxCurbeOffset;            // Maximum offset reserved for CURBE
982     int32_t             iMaxCurbeSize;              // Maximum size reserved for CURBE
983     int32_t             iMaxSamplerIndex3D;         // Maximum 3D sampler index
984     int32_t             iMaxSamplerIndexAVS;        // Maximum AVS sampler index
985     int32_t             iMaxSamplerIndexConv;       // Maximum Conv sampler index
986     int32_t             iMaxSamplerIndexMisc;       // Maximum Misc (VA) sampler index
987     int32_t             iMax8x8Tables;              // Maximum Number of 8x8 tables per MediaID
988 } RENDERHAL_DYNAMIC_MEDIA_STATE_PARAMS, *PRENDERHAL_DYNAMIC_MEDIA_STATE_PARAMS;
989 
990 typedef struct _RENDERHAL_INTERFACE_DESCRIPTOR_PARAMS
991 {
992     int32_t             iMediaID;
993     int32_t             iBindingTableID;
994     int32_t             iCurbeOffset;
995     int32_t             iCurbeLength;
996     int32_t             iCrsThrdConstDataLn;
997     int32_t             iNumberThreadsInGroup;
998     bool                blGlobalBarrierEnable;
999     bool                blBarrierEnable;
1000     int32_t             iSLMSize;
1001 } RENDERHAL_INTERFACE_DESCRIPTOR_PARAMS, *PRENDERHAL_INTERFACE_DESCRIPTOR_PARAMS;
1002 
1003 //!
1004 //! \brief  ======== HW Abstraction Params ===================================
1005 //!
1006 
1007 typedef struct _RENDERHAL_SURFACE_STATE_PARAMS
1008 {
1009     RENDERHAL_SURFACE_STATE_TYPE    Type                      : 5;              // Type of surface state
1010     uint32_t                        isOutput                  : 1;              // Render output flag
1011     uint32_t                        bVertStride               : 1;              // VL Stride
1012     uint32_t                        bVertStrideOffs           : 1;              // VL Stride Offset
1013     uint32_t                        bWidthInDword_Y           : 1;              // Width in dwords
1014     uint32_t                        bWidthInDword_UV          : 1;
1015     uint32_t                        bAVS                      : 1;              // AVS scaling
1016     RENDERHAL_SS_BOUNDARY           Boundary                  : 3;              // boundary to be aligned to rcSrc/rcDst/actual wd/ht
1017     uint32_t                        bWidth16Align             : 1;              // When VDI Walker is enabled, input surface width must be 16 aligned
1018     uint32_t                        b2PlaneNV12NeededByKernel : 1;              // Kernel needs surface state for both Y and UV
1019     uint32_t                        bForceNV12                : 1;              // Forces format to be treated as NV12. Only used in FRC.
1020     uint32_t                        bUseSinglePlane           : 1;              // 1 indicates using one plane only
1021     uint32_t                        b32MWColorFillKern        : 1;              // Flag for 32x32 Media walker + ColorFill kernel case
1022     uint32_t                        bVASurface                : 1;              // Value is 1 if VA surface, 0 if AVS surface
1023     uint32_t                        AddressControl            : 2;              // 0 clamp, 1 mirror, 2, 3 reserved
1024     uint32_t                        bWAUseSrcHeight           : 1;              // Surface state height use src height or surface height
1025     uint32_t                        bWAUseSrcWidth            : 1;              // Surface state width use src width or surface width
1026     uint32_t                        bForce3DLUTR16G16         : 1;              // Flag for 3D LUT source and targetsurface
1027     uint32_t                        bChromasiting             : 1;              // Flag for chromasiting use
1028     uint32_t                        bVmeUse                   : 1;              // Flag for VME use
1029     uint32_t                        bBufferUse                : 1;              // Flags for 1D buffer use
1030     uint32_t                        bSurfaceTypeDefined       : 1;
1031     uint32_t                        forceCommonSurfaceMessage : 1;
1032     uint32_t                        surfaceType               : 11;
1033     MOS_COMPONENT                   Component                 : 4;
1034     uint32_t                        combineChannelY           : 1;              // Combine 2 Luma Channel pixels into 1 pixel, so that kernel can reduce write times
1035     RENDERHAL_MEMORY_OBJECT_CONTROL MemObjCtl;                                  // Caching attributes
1036 } RENDERHAL_SURFACE_STATE_PARAMS, *PRENDERHAL_SURFACE_STATE_PARAMS;
1037 
1038 typedef struct _RENDERHAL_SURFACE_STATE_ENTRY
1039 {
1040     RENDERHAL_SURFACE_STATE_TYPE    Type;                                           // Type of surface state
1041     PMOS_SURFACE                    pSurface;                                       // Pointer to OS surface
1042     uint8_t                         *pSurfaceState;                                 // Pointer to Surface State
1043     SURFACE_STATE_TOKEN_COMMON      SurfaceToken;                                   // SurfaceS Token
1044     int32_t                         iSurfStateID;                                   // Surface state ID
1045     uint32_t                        dwSurfStateOffset;                              // Surface state offset (SSH)
1046     uint32_t                        dwFormat;                                       // Surface format
1047     uint32_t                        dwWidth;                                        // Surface width
1048     uint32_t                        dwHeight;                                       // Surface heigth
1049     uint32_t                        dwPitch;                                        // Surface pitch
1050     uint32_t                        dwQPitch;                                       // Surface qpitch
1051     uint32_t                        YUVPlane         :  2;                          // Plane
1052     uint32_t                        bAVS             :  1;                          // AVS scaling
1053     uint32_t                        isOutput         :  1;                          // Render output flag
1054     uint32_t                        bVertStride      :  1;                          // VL Stride
1055     uint32_t                        bVertStrideOffs  :  1;                          // VL Stride Offset
1056     uint32_t                        bWidthInDword    :  1;                          // Width in dwords
1057     uint32_t                        bTiledSurface    :  1;                          // Tiled surface
1058     uint32_t                        bTileWalk        :  1;                          // Walk 0-X; 1-Y
1059     uint32_t                        bHalfPitchChroma :  1;                          // Half pitch for choma (AVS)
1060     uint32_t                        bInterleaveChroma:  1;                          // Interleaved chroma (AVS)
1061     uint32_t                        DirectionV       :  3;                          // UV direction         (AVS)
1062     uint32_t                        DirectionU       :  1;                          // UV direction         (AVS)
1063     uint32_t                        AddressControl   :  2;                          // 0 Clamp, 1 Mirror, 2, 3 resserved
1064     uint32_t                                         : 15;                          // RESERVED
1065     uint16_t                        wUXOffset;                                      // (X,Y) offset U (AVS/ADI)
1066     uint16_t                        wUYOffset;                                      //
1067     uint16_t                        wVXOffset;                                      // (X,Y) offset V (AVS/ADI)
1068     uint16_t                        wVYOffset;                                      //
1069 } RENDERHAL_SURFACE_STATE_ENTRY, *PRENDERHAL_SURFACE_STATE_ENTRY;
1070 
1071 //!
1072 // \brief   Helper parameters used by Mhw_SendGenericPrologCmd and to initiate command buffer attributes
1073 //!
1074 typedef struct _RENDERHAL_GENERIC_PROLOG_PARAMS
1075 {
1076     bool                            bMmcEnabled = 0;
1077     bool                            bEnableMediaFrameTracking = 0;
1078     uint32_t                        dwMediaFrameTrackingTag = 0;
1079     uint32_t                        dwMediaFrameTrackingAddrOffset = 0;
1080     PMOS_RESOURCE                   presMediaFrameTrackingSurface = nullptr;
~_RENDERHAL_GENERIC_PROLOG_PARAMS_RENDERHAL_GENERIC_PROLOG_PARAMS1081     virtual ~_RENDERHAL_GENERIC_PROLOG_PARAMS() {}
1082 } RENDERHAL_GENERIC_PROLOG_PARAMS, *PRENDERHAL_GENERIC_PROLOG_PARAMS;
1083 
1084 //!
1085 // \brief   Settings help to decide the value of L3 cache enabling register used for renderhal
1086 //!
1087 typedef struct _RENDERHAL_L3_CACHE_SETTINGS
1088 {
1089     bool    bEnableSLM;     // Enable SLM cache configuration
1090     bool    bOverride;      // Override cache settings
1091 
1092     // Override values
1093     bool    bL3CachingEnabled;
1094 
1095     bool    bCntlRegOverride;
1096     bool    bCntlReg2Override;
1097     bool    bCntlReg3Override;
1098     bool    bSqcReg1Override;
1099     bool    bSqcReg4Override;
1100     bool    bLra1RegOverride;
1101 
1102     uint32_t dwCntlReg;
1103     uint32_t dwCntlReg2;
1104     uint32_t dwCntlReg3;
1105     uint32_t dwSqcReg1;
1106     uint32_t dwSqcReg4;
1107     uint32_t dwLra1Reg;
1108 } RENDERHAL_L3_CACHE_SETTINGS, *PRENDERHAL_L3_CACHE_SETTINGS;
1109 
1110 //!
1111 // \brief   Settings of Predication
1112 //!
1113 typedef struct _RENDERHAL_PREDICATION_SETTINGS
1114 {
1115     MOS_RESOURCE            *pPredicationResource;    // Resource for predication
1116     MOS_RESOURCE            *ptempPredicationBuffer;  // Additional temp buffer for Predication due to the limitation of Cond_BB_End
1117     uint64_t                predicationResOffset;     // Offset for Predication resource
1118     bool                    predicationNotEqualZero;  // Predication mode
1119     bool                    predicationEnabled;       // Indicates whether or not Predication is enabled
1120 } RENDERHAL_PREDICATION_SETTINGS;
1121 
1122 //!
1123 // \brief   Settings of SetMarker
1124 //!
1125 typedef struct _RENDERHAL_SETMARKER_SETTINGS
1126 {
1127     MOS_RESOURCE            *pSetMarkerResource;      // Resource for SetMarker
1128     bool                    setMarkerEnabled;         // Indicates whether or not SetMarker is enabled
1129     uint32_t                setMarkerNumTs;           // Number Timestamp for SetMarker
1130 } RENDERHAL_SETMARKER_SETTINGS;
1131 
1132 typedef MhwMiInterface *PMHW_MI_INTERFACE;
1133 
1134 typedef struct _RENDERHAL_ENLARGE_PARAMS
1135 {
1136     //for ReAllocateStateHeapsforAdvFeatureWithSshEnlarged and ReAllocateStateHeapsforAdvFeatureWithAllHeapsEnlarged
1137     int32_t iBindingTables;   // Number of BT per SSH instance
1138     int32_t iSurfaceStates;   // Number of Surfaces per SSH
1139     int32_t  iSurfacesPerBT;   // Size of BT
1140     //for ReAllocateStateHeapsforAdvFeatureWithAllHeapsEnlarged only
1141     int32_t iKernelCount;     // Number of Kernels that can be loaded
1142     int32_t iKernelHeapSize;  // Size of GSH block for kernels
1143     int32_t iCurbeSize;       // Size of CURBE area
1144 } RENDERHAL_ENLARGE_PARAMS, *PRENDERHAL_ENLARGE_PARAMS;
1145 
1146 //!
1147 // \brief   Hardware dependent render engine interface
1148 //!
1149 typedef struct _RENDERHAL_INTERFACE
1150 {
1151     // MOS/MHW Interfaces
1152     PMOS_INTERFACE               pOsInterface;
1153     MhwCpInterface               *pCpInterface;
1154     PXMHW_STATE_HEAP_INTERFACE   pMhwStateHeap;
1155     PMHW_MI_INTERFACE            pMhwMiInterface;
1156 
1157     // RenderHal State Heap
1158     PRENDERHAL_STATE_HEAP        pStateHeap;
1159     uint32_t                     dwStateHeapSize;
1160 
1161     // Linked list of batch buffers for synchronization
1162     PMHW_BATCH_BUFFER            pBatchBufferList;                              // List of BB submitted
1163 
1164     PMHW_MEMORY_POOL             pBatchBufferMemPool;                           // Batch Buffer memory allocations (malloc)
1165     PMHW_BATCH_BUFFER_LIST       BatchBufferPool;                               // Pool of BB objects   (no GFX buffer)
1166     PMHW_BATCH_BUFFER_LIST       BatchBuffersAllocated;                         // List of BB allocated (not executing, backed by GFX buffer)
1167 
1168     // Auxiliary
1169     PLATFORM                     Platform;
1170     MEDIA_FEATURE_TABLE          *pSkuTable;
1171     MEDIA_WA_TABLE               *pWaTable;
1172 
1173     // Hardware dependent parameters
1174     MHW_VFE_SCOREBOARD           VfeScoreboard;
1175     PCMHW_SURFACE_PLANES         pPlaneDefinitions;
1176 
1177     // Settings and capabilities
1178     PMHW_RENDER_ENGINE_CAPS       pHwCaps;                                      // HW Capabilities
1179     PMHW_RENDER_STATE_SIZES       pHwSizes;                                     // Sizes of HW commands/states
1180     RENDERHAL_STATE_HEAP_SETTINGS StateHeapSettings;                            // State Heap Settings
1181     RENDERHAL_ENLARGE_PARAMS      enlargeStateHeapSettingsForAdv;               // State Heap Settings for Adv Feature
1182 
1183     // MHW parameters
1184     MHW_STATE_BASE_ADDR_PARAMS   StateBaseAddressParams;
1185     MHW_SIP_STATE_PARAMS         SipStateParams;
1186     MHW_WALKER_MODE              MediaWalkerMode;                               // Media object walker mode from Regkey: repel, dual mode, quad mode
1187     uint32_t                     euThreadSchedulingMode;
1188 
1189     RENDERHAL_SURFACE_STATE_TYPE SurfaceTypeDefault;                            // Surface State type default
1190     RENDERHAL_SURFACE_STATE_TYPE SurfaceTypeAdvanced;                           // Surface State type advanced
1191 
1192     RENDERHAL_L3_CACHE_SETTINGS  L3CacheSettings;                               // L3 Cache settings
1193 
1194     bool                        bEnableYV12SinglePass;                          // Enabled YV12 single pass in 3D sampler
1195     bool                        bEnableP010SinglePass;                          // Enabled P010 single pass in sampler
1196     bool                        bSIPKernel;                                     // SIP loaded
1197     bool                        bCSRKernel;                                     // CSR loaded
1198     bool                        bTurboMode;                                     // Turbo mode info to pass in cmdBuf
1199     bool                        bVDIWalker;                                     // VDI Walker info from Regkey
1200     bool                        bRequestSingleSlice;                            // Single Slice Request flag
1201     bool                        bEUSaturationNoSSD;                             // No slice shutdown, must request 2 slices [CM EU saturation on]
1202     bool                        bEnableGpgpuMidBatchPreEmption;                 // Middle Batch Buffer Preemption
1203     bool                        bEnableGpgpuMidThreadPreEmption;                // Middle Thread Preemption
1204     bool                        bComputeContextInUse;                           // Compute Context use for media
1205     bool                        isBindlessHeapInUse;                            // Bindless Heap Mode use
1206 
1207     uint32_t                    dwMaskCrsThdConDataRdLn;                        // Unifies pfnSetupInterfaceDescriptor for g75,g8,...
1208     uint32_t                    dwMinNumberThreadsInGroup;                      // Unifies pfnSetupInterfaceDescriptor for g75,g8,...
1209     uint32_t                    dwCurbeBlockAlign;                              // Unifies pfnLoadCurbeData - Curbe Block Alignment
1210     uint32_t                    dwScratchSpaceMaxThreads;                       // Unifies pfnGetScratchSpaceSize - Threads used for scratch space calculation
1211     uint32_t                    dwSamplerAvsIncrement;                          // Unifies pfnSetSamplerStates
1212 
1213     const void                  *sseuTable;                                     // pointer of const VphalSseuSetting table on a platform
1214 
1215     uint32_t                    dwIndirectHeapSize;
1216     uint32_t                    dwTimeoutMs;
1217     int32_t                     iMaxPalettes;
1218     int32_t                     iMaxPaletteEntries;
1219     MHW_PALETTE_PARAMS          Palette[RENDERHAL_PALETTE_MAX];
1220 
1221     int32_t                     iMaxChromaKeys;
1222     int32_t                     iChromaKeyCount;
1223     MHW_CHROMAKEY_PARAMS        ChromaKey[RENDERHAL_CHROMA_KEY_MAX];
1224 
1225     bool                        bHasCombinedAVSSamplerState;
1226 
1227     // GD2 kernel debugging
1228     bool                        bIsaAsmDebugEnable;
1229     uint8_t                     cIsaAsmDebugSurfaceBTI;
1230     RENDERHAL_SURFACE           IsaAsmDebugSurface;
1231 
1232     // Performance collection
1233     bool                        bKerneltimeDump;
1234     double                      kernelTime[RENDERHAL_COMPONENT_COUNT];
1235 
1236     // Auxiliary data - for debugging purposes
1237     int32_t                     iMediaStatesInUse;  // Media states in use
1238     int32_t                     iKernelsInUse;      // Kernels in use
1239     int32_t                     iBuffersInUse;      // BB in use
1240 
1241     // Power option to control slice/subslice/EU shutdown
1242     RENDERHAL_POWEROPTION       PowerOption;
1243 
1244     // Indicates whether it's MDF load or not
1245     bool                        IsMDFLoad;
1246 
1247     bool                        bDynamicStateHeap;        //!< Indicates that DSH is in use
1248 
1249 
1250     FrameTrackerProducer        trackerProducer;        // Resource to mark command buffer completion
1251     RENDERHAL_TR_RESOURCE       veBoxTrackerRes;        // Resource to mark command buffer completion
1252     uint32_t                    currentTrackerIndex;    // Record the tracker index
1253 
1254     HeapManager                 *dgsheapManager;        // Dynamic general state heap manager
1255 
1256 #if (_DEBUG || _RELEASE_INTERNAL)
1257     // Dump state for VP debugging
1258     void                        *pStateDumper;
1259 #endif
1260 
1261     // Pointer to vphal oca dumper object to dump vphal parameters.
1262     void                        *pVphalOcaDumper;
1263 
1264     // Predication
1265     RENDERHAL_PREDICATION_SETTINGS PredicationParams;   //!< Predication
1266     MOS_RESOURCE                   PredicationBuffer;   //!< Predication buffer
1267 
1268     // CSC Coefficient
1269     bool                           bCmfcCoeffUpdate;    //!< CMFC CSC Coefficient Surface update flag
1270     int32_t                        iKernelAllocationID; //!< CMFC CSC Kernel Allocation ID
1271     PMOS_RESOURCE                  pCmfcCoeffSurface;   //!< CMFC CSC Coefficient Surface
1272 
1273     // SetMarker
1274     RENDERHAL_SETMARKER_SETTINGS SetMarkerParams;   //!< SetMarker
1275 
1276     // Indicates whether it's AVS or not
1277     bool                        bIsAVS;
1278 
1279     bool                        isMMCEnabled;
1280 #if (_DEBUG || _RELEASE_INTERNAL)
1281     // RT Old cacheSetting
1282     uint32_t                    oldCacheSettingForTargetSurface = 0;
1283 #endif
1284 
1285     MediaPerfProfiler           *pPerfProfiler = nullptr; //!< Performance data profiler
1286     bool                        eufusionBypass = false;
1287     MediaUserSettingSharedPtr   userSettingPtr = nullptr; //!< Shared pointer to User Setting instance
1288 
1289     // if it's true, will disable preemption by setting NeedsMidBatchPreEmptionSupport flag in command buffer attribute as false;
1290     // will also skip preemption control bits configure.
1291     bool                        forceDisablePreemption = false;
1292     //---------------------------
1293     // HW interface functions
1294     //---------------------------
1295     MOS_STATUS (* pfnInitialize)(
1296                 PRENDERHAL_INTERFACE     pRenderHal,
1297                 PRENDERHAL_SETTINGS      pSettings);
1298 
1299     MOS_STATUS (* pfnDestroy) (
1300                 PRENDERHAL_INTERFACE     pRenderHal);
1301 
1302     MOS_STATUS (* pfnReset) (
1303                 PRENDERHAL_INTERFACE     pRenderHal);
1304 
1305     //---------------------------
1306     // State Heap Functions
1307     //---------------------------
1308     MOS_STATUS (* pfnAllocateStateHeaps) (
1309                 PRENDERHAL_INTERFACE            pRenderHal,
1310                 PRENDERHAL_STATE_HEAP_SETTINGS  pSettings);
1311 
1312     MOS_STATUS (* pfnReAllocateStateHeapsforAdvFeatureWithSshEnlarged)(
1313                 PRENDERHAL_INTERFACE            pRenderHal,
1314                 bool                            &bAllocated);
1315 
1316     MOS_STATUS (*pfnReAllocateStateHeapsforAdvFeatureWithAllHeapsEnlarged)(
1317         PRENDERHAL_INTERFACE                    pRenderHal,
1318         bool                                    &bAllocated);
1319 
1320     MOS_STATUS (* pfnFreeStateHeaps) (
1321                 PRENDERHAL_INTERFACE     pRenderHal);
1322 
1323     MOS_STATUS (* pfnRefreshSync) (
1324                 PRENDERHAL_INTERFACE     pRenderHal);
1325 
1326     //---------------------------
1327     // SSH, surface states
1328     //---------------------------
1329     MOS_STATUS (* pfnAssignSshInstance) (
1330                 PRENDERHAL_INTERFACE    pRenderHal);
1331 
1332     MOS_STATUS (* pfnGetSurfaceStateEntries) (
1333                 PRENDERHAL_INTERFACE            pRenderHal,
1334                 PRENDERHAL_SURFACE              pRenderHalSurface,
1335                 PRENDERHAL_SURFACE_STATE_PARAMS pParams,
1336                 int32_t                         *piNumEntries,
1337                 PRENDERHAL_SURFACE_STATE_ENTRY  *ppSurfaceEntries);
1338 
1339     MOS_STATUS (* pfnSetupSurfaceState) (
1340                 PRENDERHAL_INTERFACE            pRenderHal,
1341                 PRENDERHAL_SURFACE              pRenderHalSurface,
1342                 PRENDERHAL_SURFACE_STATE_PARAMS pParams,
1343                 int32_t                         *piNumEntries,
1344                 PRENDERHAL_SURFACE_STATE_ENTRY  *ppSurfaceEntries,
1345                 PRENDERHAL_OFFSET_OVERRIDE      pOffsetOverride);
1346 
1347     MOS_STATUS (*pfnSetupBufferSurfaceState) (
1348                 PRENDERHAL_INTERFACE            pRenderHal,
1349                 PRENDERHAL_SURFACE              pRenderHalSurface,
1350                 PRENDERHAL_SURFACE_STATE_PARAMS pParams,
1351                 PRENDERHAL_SURFACE_STATE_ENTRY  *ppSurfaceEntry);
1352 
1353     MOS_STATUS (* pfnAssignSurfaceState) (
1354                 PRENDERHAL_INTERFACE            pRenderHal,
1355                 RENDERHAL_SURFACE_STATE_TYPE    Type,
1356                 PRENDERHAL_SURFACE_STATE_ENTRY  *ppSurfaceEntry);
1357 
1358     void (* pfnGetAlignUnit) (
1359                 uint16_t                        *pwWidthAlignUnit,
1360                 uint16_t                        *pwHeightAlignUnit,
1361                 PRENDERHAL_SURFACE              pRenderHalSurface);
1362 
1363     void (* pfnAdjustBoundary) (
1364                 PRENDERHAL_INTERFACE            pRenderHal,
1365                 PRENDERHAL_SURFACE              pRenderHalSurface,
1366                 RENDERHAL_SS_BOUNDARY           Boundary,
1367                 uint32_t                        *pdwSurfaceWidth,
1368                 uint32_t                        *pdwSurfaceHeight);
1369 
1370     uint32_t (* pfnSetSurfacesPerBT) (
1371                 PRENDERHAL_INTERFACE            pRenderHal,
1372                 uint32_t                        dwSurfacesPerBT);
1373 
1374     uint16_t (* pfnCalculateYOffset) (
1375                 PMOS_INTERFACE                  pOsInterface,
1376                 PMOS_RESOURCE                   pOsResource);
1377 
1378     MOS_STATUS (* pfnAssignBindingTable) (
1379                 PRENDERHAL_INTERFACE            pRenderHal,
1380                 int32_t                         *piBindingTable);
1381 
1382     MOS_STATUS (* pfnAssignBindlessSurfaceStates) (
1383                 PRENDERHAL_INTERFACE            pRenderHal);
1384 
1385     MOS_STATUS (*pfnSendBindlessSurfaceStates) (
1386                 PRENDERHAL_INTERFACE            pRenderHal,
1387                 bool                            bNeedNullPatch);
1388 
1389     MOS_STATUS (* pfnBindSurfaceState) (
1390                 PRENDERHAL_INTERFACE            pRenderHal,
1391                 int32_t                         iBindingTableIndex,
1392                 int32_t                         iBindingTableEntry,
1393                 PRENDERHAL_SURFACE_STATE_ENTRY  pSurfaceEntry);
1394 
1395     uint32_t (* pfnGetSurfaceMemoryObjectControl) (
1396                 PRENDERHAL_INTERFACE            pRenderHal,
1397                 PRENDERHAL_SURFACE_STATE_PARAMS pParams);
1398 
1399     MOS_STATUS (*pfnGetPlaneDefinitionForCommonMessage) (
1400         PRENDERHAL_INTERFACE             pRenderHal,
1401         MOS_FORMAT                       format,
1402         PRENDERHAL_SURFACE_STATE_PARAMS &pParam,
1403         bool                             isRenderTarget,
1404         RENDERHAL_PLANE_DEFINITION      &planeDefinition);
1405 
1406     //---------------------------
1407     // State Setup - HW + OS Specific
1408     //---------------------------
1409     MOS_STATUS (* pfnSetupSurfaceStatesOs) (
1410                 PRENDERHAL_INTERFACE            pRenderHal,
1411                 PRENDERHAL_SURFACE_STATE_PARAMS pParams,
1412                 PRENDERHAL_SURFACE_STATE_ENTRY  pSurfaceStateEntry);
1413 
1414     //---------------------------
1415     // Batch Buffer
1416     //---------------------------
1417     MOS_STATUS (* pfnAllocateBB) (
1418                 PRENDERHAL_INTERFACE        pRenderHal,
1419                 PMHW_BATCH_BUFFER           pBatchBuffer,
1420                 int32_t                     iSize);
1421 
1422     MOS_STATUS (* pfnFreeBB) (
1423                 PRENDERHAL_INTERFACE        pRenderHal,
1424                 PMHW_BATCH_BUFFER           pBatchBuffer);
1425 
1426     MOS_STATUS (* pfnLockBB) (
1427                 PRENDERHAL_INTERFACE        pRenderHal,
1428                 PMHW_BATCH_BUFFER           pBatchBuffer);
1429 
1430     MOS_STATUS (* pfnUnlockBB) (
1431                 PRENDERHAL_INTERFACE        pRenderHal,
1432                 PMHW_BATCH_BUFFER           pBatchBuffer);
1433 
1434     //---------------------------
1435     // Media State
1436     //---------------------------
1437     PRENDERHAL_MEDIA_STATE (* pfnAssignMediaState) (
1438                 PRENDERHAL_INTERFACE        pRenderHal,
1439                 RENDERHAL_COMPONENT         componentID);
1440 
1441     //---------------------------
1442     // Allocation
1443     //---------------------------
1444     MOS_STATUS (* pfnEnablePalette) (
1445                 PRENDERHAL_INTERFACE        pRenderHal,
1446                 int32_t                     iPaletteID,
1447                 int32_t                     iPaletteSize);
1448 
1449     MOS_STATUS (* pfnAllocatePaletteID) (
1450                 PRENDERHAL_INTERFACE        pRenderHal,
1451                 int32_t                     *pPaletteID);
1452 
1453     MOS_STATUS (* pfnFreePaletteID) (
1454                 PRENDERHAL_INTERFACE        pRenderHal,
1455                 int32_t                     *pPaletteID);
1456 
1457     MOS_STATUS (* pfnGetPaletteEntry) (
1458                 PRENDERHAL_INTERFACE        pRenderHal,
1459                 int32_t                     iPaletteID,
1460                 int32_t                     iInNumEntries,
1461                 int32_t                     *piOutNumEntries,
1462                 void                        **pPaletteData);
1463 
1464     int32_t (* pfnAllocateChromaKey) (
1465                 PRENDERHAL_INTERFACE        pRenderHal,
1466                 uint32_t                    dwLow,
1467                 uint32_t                    dwHigh);
1468 
1469     int32_t (* pfnLoadCurbeData) (
1470                 PRENDERHAL_INTERFACE        pRenderHal,
1471                 PRENDERHAL_MEDIA_STATE      pMediaState,
1472                 void                        *pData,
1473                 int32_t                     iSize);
1474 
1475     MOS_STATUS (* pfnSetSamplerStates) (
1476                 PRENDERHAL_INTERFACE        pRenderHal,
1477                 int32_t                     iMediaID,
1478                 PMHW_SAMPLER_STATE_PARAM    pSamplerParams,
1479                 int32_t                     iSamplers);
1480 
1481     MOS_STATUS (*pfnSetAndGetSamplerStates) (
1482                 PRENDERHAL_INTERFACE     pRenderHal,
1483                 int32_t                  iMediaID,
1484                 PMHW_SAMPLER_STATE_PARAM pSamplerParams,
1485                 int32_t                  iSamplers,
1486                 std::map<uint32_t, uint32_t> &samplerMap);
1487 
1488     int32_t (* pfnAllocateMediaID) (
1489                 PRENDERHAL_INTERFACE        pRenderHal,
1490                 int32_t                     iKernelAllocationID,
1491                 int32_t                     iBindingTableID,
1492                 int32_t                     iCurbeOffset,
1493                 int32_t                     iCurbeLength,
1494                 int32_t                     iCrsThrdConstDataLn,
1495                 PMHW_GPGPU_WALKER_PARAMS    pGpGpuWalkerParams);
1496 
1497     int32_t (* pfnGetMediaID) (
1498                 PRENDERHAL_INTERFACE        pRenderHal,
1499                 PRENDERHAL_MEDIA_STATE      pMediaState,
1500                 PRENDERHAL_KRN_ALLOCATION   pKernelAllocation);
1501 
1502     MOS_STATUS (* pfnSetupInterfaceDescriptor) (
1503                 PRENDERHAL_INTERFACE                   pRenderHal,
1504                 PRENDERHAL_MEDIA_STATE                 pMediaState,
1505                 PRENDERHAL_KRN_ALLOCATION              pKernelAllocation,
1506                 PRENDERHAL_INTERFACE_DESCRIPTOR_PARAMS pInterfaceDescriptorParams);
1507 
1508     uint32_t (* pfnEncodeSLMSize)(PRENDERHAL_INTERFACE pRenderHal, uint32_t SLMSize);
1509 
1510     //---------------------------
1511     // Kernels
1512     //---------------------------
1513     int32_t (* pfnLoadKernel) (
1514                 PRENDERHAL_INTERFACE        pRenderHal,
1515                 PCRENDERHAL_KERNEL_PARAM    pParameters,
1516                 PMHW_KERNEL_PARAM           pKernel,
1517                 Kdll_CacheEntry             *pKernelEntry);
1518 
1519     MOS_STATUS (* pfnUnloadKernel) (
1520                 PRENDERHAL_INTERFACE        pRenderHal,
1521                 int32_t                     iKernelAllocationID);
1522 
1523     void (* pfnResetKernels) (
1524                 PRENDERHAL_INTERFACE        pRenderHal);
1525 
1526     void (* pfnTouchKernel) (
1527                 PRENDERHAL_INTERFACE        pRenderHal,
1528                 int32_t                     iKernelAllocationID);
1529 
1530     int32_t (* pfnGetKernelOffset) (
1531                 PRENDERHAL_INTERFACE        pRenderHal,
1532                 int32_t                     iKernelAllocationIndex);
1533 
1534     MOS_STATUS (* pfnUnregisterKernel) (
1535                 PRENDERHAL_INTERFACE        pRenderHal,
1536                 PRENDERHAL_KRN_ALLOCATION   pKernelAllocation);
1537 
1538     //---------------------------
1539     // New Dynamic State Heap interfaces
1540     //---------------------------
1541     MOS_STATUS(*pfnAssignSpaceInStateHeap)(
1542         uint32_t              trackerIndex,
1543         FrameTrackerProducer  *trackerProducer,
1544         HeapManager           *heapManager,
1545         MemoryBlock           *block,
1546         uint32_t               size);
1547 
1548     PRENDERHAL_MEDIA_STATE (* pfnAssignDynamicState) (
1549                 PRENDERHAL_INTERFACE                  pRenderHal,
1550                 PRENDERHAL_DYNAMIC_MEDIA_STATE_PARAMS pParams,
1551                 RENDERHAL_COMPONENT                   componentID);
1552 
1553     MOS_STATUS (* pfnReleaseDynamicState) (
1554                 PRENDERHAL_INTERFACE                  pRenderHal,
1555                 PRENDERHAL_MEDIA_STATE                pMediaState);
1556 
1557     MOS_STATUS (* pfnSubmitDynamicState) (
1558                 PRENDERHAL_INTERFACE                  pRenderHal,
1559                 PRENDERHAL_MEDIA_STATE                pMediaState);
1560 
1561     int32_t (* pfnAllocateDynamicMediaID) (
1562                 PRENDERHAL_INTERFACE        pRenderHal,
1563                 PRENDERHAL_KRN_ALLOCATION   pKernelAllocation,
1564                 int32_t                     iBindingTableID,
1565                 int32_t                     iCurbeOffset,
1566                 int32_t                     iCurbeLength,
1567                 int32_t                     iCrsThrdConstDataLn,
1568                 PMHW_GPGPU_WALKER_PARAMS    pGpGpuWalkerParams);
1569 
1570     PRENDERHAL_KRN_ALLOCATION (* pfnLoadDynamicKernel) (
1571                 PRENDERHAL_INTERFACE        pRenderHal,
1572                 PCRENDERHAL_KERNEL_PARAM    pParameters,
1573                 PMHW_KERNEL_PARAM           pKernel,
1574                 uint32_t                    *pdwLoaded);
1575 
1576     PRENDERHAL_KRN_ALLOCATION (* pfnSearchDynamicKernel) (
1577                 PRENDERHAL_INTERFACE        pRenderHal,
1578                 int32_t                     iKernelUniqueID,
1579                 int32_t                     iCacheID);
1580 
1581     PRENDERHAL_KRN_ALLOCATION (* pfnAllocateDynamicKernel) (
1582                 PRENDERHAL_INTERFACE        pRenderHal,
1583                 int32_t                     iKernelUniqueID,
1584                 int32_t                     iCacheID);
1585 
1586     MOS_STATUS (* pfnUnloadDynamicKernel) (
1587                 PRENDERHAL_INTERFACE        pRenderHal,
1588                 PRENDERHAL_KRN_ALLOCATION   pKernelAllocation);
1589 
1590     MOS_STATUS (* pfnRefreshDynamicKernels) (
1591                 PRENDERHAL_INTERFACE        pRenderHal,
1592                 uint32_t                    dwSpaceNeeded,
1593                 uint32_t                    *pdwSizes,
1594                 int32_t                     iCount);
1595 
1596     void (* pfnResetDynamicKernels) (
1597                 PRENDERHAL_INTERFACE        pRenderHal);
1598 
1599     void (* pfnTouchDynamicKernel) (
1600                 PRENDERHAL_INTERFACE        pRenderHal,
1601                 PRENDERHAL_KRN_ALLOCATION   pKernelAllocation);
1602 
1603     MOS_STATUS (* pfnExpandKernelStateHeap)(
1604                 PRENDERHAL_INTERFACE        pRenderHal,
1605         uint32_t                            dwAdditionalKernelSpaceNeeded);
1606 
1607     //---------------------------
1608     // HW interface configuration functions
1609     //---------------------------
1610     MOS_STATUS (* pfnSetVfeStateParams) (
1611                 PRENDERHAL_INTERFACE        pRenderHal,
1612                 uint32_t                    dwDebugCounterControl,
1613                 uint32_t                    dwMaximumNumberofThreads,
1614                 uint32_t                    dwCURBEAllocationSize,
1615                 uint32_t                    dwURBEntryAllocationSize,
1616                 PMHW_VFE_SCOREBOARD         pScoreboardParams);
1617 
1618     bool (* pfnGetMediaWalkerStatus) (
1619                 PRENDERHAL_INTERFACE        pRenderHal);
1620 
1621     //---------------------------
1622     // Command buffer programming functions
1623     //---------------------------
1624     MOS_STATUS (* pfnSendStateBaseAddress) (
1625                 PRENDERHAL_INTERFACE        pRenderHal,
1626                 PMOS_COMMAND_BUFFER         pCmdBuffer);
1627 
1628     MOS_STATUS (* pfnSendMediaStates) (
1629                 PRENDERHAL_INTERFACE        pRenderHal,
1630                 PMOS_COMMAND_BUFFER         pCmdBuffer,
1631                 PMHW_WALKER_PARAMS          pWalkerParams,
1632                 PMHW_GPGPU_WALKER_PARAMS    pGpGpuWalkerParams);
1633 
1634     MOS_STATUS (* pfnInitCommandBuffer) (
1635                 PRENDERHAL_INTERFACE                pRenderHal,
1636                 PMOS_COMMAND_BUFFER                 pCmdBuffer,
1637                 PRENDERHAL_GENERIC_PROLOG_PARAMS    pGenericPrologParams);
1638 
1639     MOS_STATUS (* pfnSendSurfaces) (
1640                 PRENDERHAL_INTERFACE        pRenderHal,
1641                 PMOS_COMMAND_BUFFER         pCmdBuffer);
1642 
1643     MOS_STATUS (* pfnSendSyncTag) (
1644                 PRENDERHAL_INTERFACE        pRenderHal,
1645                 PMOS_COMMAND_BUFFER         pCmdBuffer);
1646 
1647     MOS_STATUS (*pfnSendCscCoeffSurface) (
1648                 PRENDERHAL_INTERFACE        pRenderHal,
1649                 PMOS_COMMAND_BUFFER         pCmdBuffer,
1650                 PMOS_RESOURCE               presCscCoeff,
1651                 Kdll_CacheEntry             *pKernelEntry);
1652 
1653     // Samplers and other states
1654     MOS_STATUS (*pfnGetSamplerOffsetAndPtr) (
1655                 PRENDERHAL_INTERFACE        pRenderHal,
1656                 int32_t                     iMediaID,
1657                 int32_t                     iSamplerID,
1658                 PMHW_SAMPLER_STATE_PARAM    pSamplerParams,
1659                 uint32_t                    *pdwSamplerOffset,
1660                 void                        **ppSampler);
1661 
1662     MOS_STATUS (* pfnSendCurbeLoad) (
1663                 PRENDERHAL_INTERFACE        pRenderHal,
1664                 PMOS_COMMAND_BUFFER         pCmdBuffer);
1665 
1666     MOS_STATUS (* pfnSendMediaIdLoad) (
1667                 PRENDERHAL_INTERFACE        pRenderHal,
1668                 PMOS_COMMAND_BUFFER         pCmdBuffer);
1669 
1670     MOS_STATUS (* pfnSendChromaKey) (
1671                 PRENDERHAL_INTERFACE        pRenderHal,
1672                 PMOS_COMMAND_BUFFER         pCmdBuffer);
1673 
1674     MOS_STATUS (* pfnSendPalette) (
1675                 PRENDERHAL_INTERFACE        pRenderHal,
1676                 PMOS_COMMAND_BUFFER         pCmdBuffer);
1677 
1678     MOS_STATUS (* pfnSendSurfaceStateEntry) (
1679                 PRENDERHAL_INTERFACE            pRenderHal,
1680                 PMOS_COMMAND_BUFFER             pCmdBuffer,
1681                 PMHW_SURFACE_STATE_SEND_PARAMS  pParams);
1682 
1683     MOS_STATUS (* pfnSetSurfaceStateToken)(
1684                 PRENDERHAL_INTERFACE        pRenderHal,
1685                 PMHW_SURFACE_TOKEN_PARAMS   pParams,
1686                 void                        *pSurfaceStateToken);
1687 
1688     MOS_STATUS (* pfnSetSurfaceStateBuffer)(
1689                 PRENDERHAL_INTERFACE        pRenderHal,
1690                 PMHW_RCS_SURFACE_PARAMS     pParams,
1691                 void                        *pSurfaceState);
1692 
1693     //-----------------------------
1694     // Slice Shutdown Mode function
1695     //-----------------------------
1696     void (* pfnSetSliceShutdownMode) (
1697                 PRENDERHAL_INTERFACE        pRenderHal,
1698                 bool                        bMode);
1699 
1700     //-----------------------------
1701     // General Slice Shut Down Mode function
1702     //-----------------------------
1703     void( *pfnSetPowerOptionMode ) (
1704         PRENDERHAL_INTERFACE                pRenderHal,
1705         PRENDERHAL_POWEROPTION              pMode);
1706 
1707     //-----------------------------
1708     // Enable Middle Batch Buffer Preemption
1709     //-----------------------------
1710     void (* pfnEnableGpgpuMiddleBatchBufferPreemption) (
1711                 PRENDERHAL_INTERFACE        pRenderHal);
1712 
1713     //-----------------------------
1714     // Enable Middle Thread Preemption
1715     //-----------------------------
1716     void (* pfnEnableGpgpuMiddleThreadPreemption) (
1717                 PRENDERHAL_INTERFACE        pRenderHal);
1718 
1719     //---------------------------
1720     // Generic HAL Layer Commands and State Functions
1721     //---------------------------
1722     void (* pfnConvertToNanoSeconds) (
1723                 PRENDERHAL_INTERFACE        pRenderHal,
1724                 uint64_t                    iTicks,
1725                 uint64_t                    *piNs);
1726 
1727     MOS_STATUS (* pfnSendRcsStatusTag) (
1728                PRENDERHAL_INTERFACE         pRenderHal,                                             // [in] Hardware interface
1729                PMOS_COMMAND_BUFFER          pCmdBuffer);                                            // [in] Command Buffer
1730 
1731     MOS_STATUS (* pfnSendTimingData) (
1732                 PRENDERHAL_INTERFACE        pRenderHal,                                             // [in] Hardware interface
1733                 PMOS_COMMAND_BUFFER         pCmdBuffer,                                             // [in] Command Buffer
1734                 bool                        bStartTime);                                            // [in] Start Timestamp flag
1735 
1736     uint32_t (* pfnGetScratchSpaceSize)(
1737                PRENDERHAL_INTERFACE         pRenderHal,                                             // [in] Hardware interface
1738                uint32_t                     iPerThreadScratchSpaceSize);                            // [in] Per thread scrach space size
1739 
1740     bool (* pfnIs2PlaneNV12Needed) (
1741                 PRENDERHAL_INTERFACE        pRenderHal,
1742                 PRENDERHAL_SURFACE          pRenderHalSurface,
1743                 RENDERHAL_SS_BOUNDARY       Boundary);
1744 
1745     uint8_t (* pfnSetChromaDirection) (
1746                 PRENDERHAL_INTERFACE        pRenderHal,
1747                 PRENDERHAL_SURFACE          pRenderHalSurface);
1748 
1749     bool(*pfnPerThreadScratchSpaceStart2K) (
1750                 PRENDERHAL_INTERFACE        pRenderHal);
1751 
1752     //---------------------------
1753     // Overwrite L3 Cache control register
1754     //---------------------------
1755     MOS_STATUS (* pfnEnableL3Caching) (
1756                 PRENDERHAL_INTERFACE            pRenderHal,
1757                 PRENDERHAL_L3_CACHE_SETTINGS    pCacheSettings);
1758 
1759     MOS_STATUS(*pfnSetCacheOverrideParams) (
1760                 PRENDERHAL_INTERFACE            pRenderHal,
1761                 PRENDERHAL_L3_CACHE_SETTINGS    pCacheSettings,
1762                 bool                            bEnableSLM);
1763 
1764     //!
1765     //! \brief    Get mmio registers address
1766     //! \details  Get mmio registers address
1767     //! \return   [out] PMHW_MI_MMIOREGISTERS*
1768     //!           mmio registers got.
1769     //!
1770     PMHW_MI_MMIOREGISTERS GetMmioRegisters();
1771 
1772     //-----------------------------
1773     //Platform related interface
1774     XRenderHal_Platform_Interface           *pRenderHalPltInterface;
1775 } RENDERHAL_INTERFACE;
1776 
1777 //!
1778 //! \brief   Functions
1779 //!
1780 
1781 //!
1782 //! \brief    Init Interface
1783 //! \details  Initializes Render Hal Interface structure, responsible for HW
1784 //!           abstraction of Render Engine for MDF/VP
1785 //! \param    PRENDERHAL_INTERFACE pRenderHal
1786 //!           [in] Pointer to Hardware Interface Structure
1787 //! \param    MhwCpInterface** ppCpInterface
1788 //!           [in/out] Pointer of pointer to MHW CP Interface Structure, which
1789 //!           is created during renderhal initialization
1790 //! \param    PMOS_INTERFACE pOsInterface
1791 //!           [in] Pointer to OS Interface Structure
1792 //! \return   MOS_STATUS
1793 //!           MOS_STATUS_UNKNOWN : Invalid parameters
1794 //!
1795 MOS_STATUS RenderHal_InitInterface(
1796     PRENDERHAL_INTERFACE        pRenderHal,
1797     MhwCpInterface              **ppCpInterface,
1798     PMOS_INTERFACE              pOsInterface);
1799 
1800 //!
1801 //! \brief    Get Pixels Per Sample
1802 //! \details  Get Number of Pixels per Dataport Sample
1803 //! \param    MOS_FORMAT format
1804 //!           [in] Surface Format
1805 //! \param    uint32_t *pdwPixelsPerSampleUV
1806 //!           [in] Pointer to dwPixelsPerSampleUV
1807 //! \return   void
1808 //!
1809 void RenderHal_GetPixelsPerSample(
1810     MOS_FORMAT                  format,
1811     uint32_t                    *pdwPixelsPerSampleUV);
1812 
1813 //!
1814 //! \brief    Set Surface for HW Access
1815 //! \details  Common Function for setting up surface state
1816 //! \param    PRENDERHAL_INTERFACE pRenderHal
1817 //!           [in] Pointer to Hardware Interface Structure
1818 //! \param    PRENDERHAL_SURFACE pRenderHalSurface
1819 //!           [in] Pointer to Render Hal Surface
1820 //! \param    PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams
1821 //!           [in] Pointer to Surface Params
1822 //! \param    int32_t iBindingTable
1823 //!           [in] Binding Table to bind surface
1824 //! \param    int32_t iBTEntry
1825 //!           [in] Binding Table Entry index
1826 //! \param    bool bWrite
1827 //!           [in] Write mode flag
1828 //! \return   MOS_STATUS
1829 //!           MOS_STATUS_SUCCESS if success. Error code otherwise
1830 //!
1831 MOS_STATUS RenderHal_SetSurfaceForHwAccess(
1832     PRENDERHAL_INTERFACE            pRenderHal,
1833     PRENDERHAL_SURFACE              pRenderHalSurface,
1834     PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams,
1835     int32_t                         iBindingTable,
1836     int32_t                         iBTEntry,
1837     bool                            bWrite);
1838 
1839 //!
1840 //! \brief    Set Buffer Surface for HW Access
1841 //! \details  Common Function for setting up buffer surface state
1842 //! \param    PRENDERHAL_INTERFACE pRenderHal
1843 //!           [in] Pointer to Hardware Interface Structure
1844 //! \param    PRENDERHAL_SURFACE pRenderHalSurface
1845 //!           [in] Pointer to Render Hal Surface
1846 //! \param    PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams
1847 //!           [in] Pointer to Surface Params
1848 //! \param    int32_t iBindingTable
1849 //!           [in] Binding Table to Bind Surface
1850 //! \param    int32_t iBTEntry
1851 //!           [in] Binding Table Entry index
1852 //! \param    bool bWrite
1853 //!           Write mode flag
1854 //! \return   MOS_STATUS
1855 //!           MOS_STATUS_SUCCESS if success. Error code otherwise
1856 //!
1857 MOS_STATUS RenderHal_SetBufferSurfaceForHwAccess(
1858     PRENDERHAL_INTERFACE            pRenderHal,
1859     PRENDERHAL_SURFACE              pRenderHalSurface,
1860     PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams,
1861     int32_t                         iBindingTable,
1862     int32_t                         iBTEntry,
1863     bool                            bWrite);
1864 
1865 //!
1866 //! \brief    Get Surface Info from OsResource
1867 //! \details  Update surface info in PRENDERHAL_SURFACE based on allocated OsResource
1868 //! \param    PMOS_INTERFACE pOsInterface
1869 //!           [in] Pointer to MOS_INTERFACE
1870 //! \param    PRENDERHAL_GET_SURFACE_INFO pInfo
1871 //!           [in] Pointer to RENDERHAL_GET_SURFACE_INFO
1872 //! \param    PMOS_SURFACE pSurface
1873 //!           [in/out] Pointer to PMOS_SURFACE
1874 //! \return   MOS_STATUS
1875 //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
1876 //!
1877 MOS_STATUS RenderHal_GetSurfaceInfo(
1878     PMOS_INTERFACE              pOsInterface,
1879     PRENDERHAL_GET_SURFACE_INFO pInfo,
1880     PMOS_SURFACE                pSurface);
1881 
1882 //!
1883 //! \brief    Send Media States
1884 //! \details  Send Media States
1885 //! \param    PRENDERHAL_INTERFACE pRenderHal
1886 //!           [in] Pointer to Hardware Interface Structure
1887 //! \param    PMOS_COMMAND_BUFFER pCmdBuffer
1888 //!           [in] Pointer to Command Buffer
1889 //! \param    PRENDERHAL_GPGPU_WALKER_PARAMS pGpGpuWalkerParams
1890 //!           [in]    Pointer to GPGPU walker parameters
1891 //! \return   MOS_STATUS
1892 //!
1893 MOS_STATUS RenderHal_SendMediaStates(
1894     PRENDERHAL_INTERFACE      pRenderHal,
1895     PMOS_COMMAND_BUFFER       pCmdBuffer,
1896     PMHW_WALKER_PARAMS        pWalkerParams,
1897     PMHW_GPGPU_WALKER_PARAMS  pGpGpuWalkerParams);
1898 
1899 //!
1900 //! \brief    Issue command to write timestamp
1901 //! \param    [in] pRenderHal
1902 //! \param    [in] pCmdBuffer
1903 //! \param    [in] bStartTime
1904 //! \return   MOS_STATUS
1905 //!
1906 MOS_STATUS RenderHal_SendTimingData(
1907     PRENDERHAL_INTERFACE         pRenderHal,
1908     PMOS_COMMAND_BUFFER          pCmdBuffer,
1909     bool                         bStartTime);
1910 
1911 //!
1912 //! \brief    Get Y Offset according to the planeOffset struct and surface pitch
1913 //! \details  Get Y Offset according to the planeOffset struct and surface pitch
1914 //! \param    pOsInterface
1915 //!           [in] pointer to OS Interface
1916 //! \param    pOsResource
1917 //!           [in] Pointers to Surface OsResource
1918 //! \return   uint16_t
1919 //!           [out] the plane Y offset
1920 //!
1921 uint16_t RenderHal_CalculateYOffset(
1922     PMOS_INTERFACE      pOsInterface,
1923     PMOS_RESOURCE       pOsResource);
1924 
1925 MOS_STATUS RenderHal_AllocateDebugSurface(
1926     PRENDERHAL_INTERFACE    pRenderHal);
1927 
1928 MOS_STATUS RenderHal_SetupDebugSurfaceState(
1929     PRENDERHAL_INTERFACE    pRenderHal);
1930 
1931 void RenderHal_FreeDebugSurface(
1932     PRENDERHAL_INTERFACE    pRenderHal);
1933 
1934 MOS_STATUS RenderHal_AddDebugControl(
1935     PRENDERHAL_INTERFACE    pRenderHal,
1936     PMOS_COMMAND_BUFFER     pCmdBuffer);
1937 
1938 
1939 MOS_STATUS RenderHal_SetSurfaceStateToken(
1940     PRENDERHAL_INTERFACE        pRenderHal,
1941     PMHW_SURFACE_TOKEN_PARAMS   pParams,
1942     void                        *pSurfaceStateToken);
1943 
1944 //!
1945 //! \brief    Send Surfaces PatchList
1946 //! \details  Send Surface State commands
1947 //! \param    PRENDERHAL_INTERFACE pRenderHal
1948 //!           [in] Pointer to Hardware Interface Structure
1949 //! \param    PMOS_COMMAND_BUFFER pCmdBuffer
1950 //!           [in] Pointer to Command Buffer
1951 //! \return   MOS_STATUS
1952 //!
1953 MOS_STATUS RenderHal_SendSurfaces_PatchList(
1954     PRENDERHAL_INTERFACE    pRenderHal,
1955     PMOS_COMMAND_BUFFER     pCmdBuffer);
1956 
1957 //!
1958 //! \brief    Init Special Interface
1959 //! \details  Initializes RenderHal Interface structure, responsible for HW
1960 //!           abstraction of HW Rendering Engine for CM(MDF) and VP.
1961 //! \param    PRENDERHAL_INTERFACE pRenderHal
1962 //!           [in] Pointer to RenderHal Interface Structure
1963 //!
1964 void RenderHal_InitInterfaceEx(
1965     PRENDERHAL_INTERFACE    pRenderHal);
1966 
1967 // Constants defined in RenderHal interface
1968 extern const SURFACE_STATE_TOKEN_COMMON   g_cInit_SURFACE_STATE_TOKEN_COMMON;
1969 extern const MHW_PIPE_CONTROL_PARAMS      g_cRenderHal_InitPipeControlParams;
1970 extern const MHW_VFE_PARAMS               g_cRenderHal_InitVfeParams;
1971 extern const MHW_MEDIA_STATE_FLUSH_PARAM  g_cRenderHal_InitMediaStateFlushParams;
1972 extern const RENDERHAL_KERNEL_PARAM       g_cRenderHal_InitKernelParams;
1973 
1974 #endif // __RENDERHAL_H__
1975