xref: /aosp_15_r20/external/intel-media-driver/media_common/linux/common/os/mos_os_specific.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2009-2023, 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      mos_os_specific.h
24 //! \brief     Common interface and structure used in MOS LINUX OS
25 //!
26 
27 #ifndef __MOS_OS_SPECIFIC_H__
28 #define __MOS_OS_SPECIFIC_H__
29 #include "mos_defs.h"
30 #include "media_fourcc.h"
31 #include "media_skuwa_specific.h"
32 #include "GmmLib.h"
33 #include "mos_resource_defs.h"
34 #include "mos_os_hw.h"
35 #include "mos_utilities.h"
36 #ifdef ANDROID
37 #include <utils/Log.h>
38 #endif
39 #include "mos_bufmgr.h"
40 #include <vector>
41 
42 typedef unsigned int MOS_OS_FORMAT;
43 
44 class GraphicsResource;
45 class GraphicsResourceNext;
46 class AuxTableMgr;
47 class MosOcaInterface;
48 class GraphicsResourceNext;
49 
50 ////////////////////////////////////////////////////////////////////
51 extern PerfUtility *g_perfutility;
52 
53 #define PERF_DECODE "DECODE"
54 #define PERF_ENCODE "ENCODE"
55 #define PERF_VP "VP"
56 #define PERF_CP "CP"
57 #define PERF_MOS "MOS"
58 
59 #define PERF_LEVEL_DDI "DDI"
60 #define PERF_LEVEL_HAL "HAL"
61 
62 #define DECODE_DDI (1)
63 #define DECODE_HAL (1 << 1)
64 #define ENCODE_DDI (1 << 4)
65 #define ENCODE_HAL (1 << 5)
66 #define VP_DDI     (1 << 8)
67 #define VP_HAL     (1 << 9)
68 #define CP_DDI     (1 << 12)
69 #define CP_HAL     (1 << 13)
70 #define MOS_DDI    (1 << 16)
71 #define MOS_HAL    (1 << 17)
72 
73 #define PERFUTILITY_IS_ENABLED(sCOMP,sLEVEL)                                                              \
74     (((sCOMP == "DECODE" && sLEVEL == "DDI") && (g_perfutility->dwPerfUtilityIsEnabled & DECODE_DDI)) ||  \
75      ((sCOMP == "DECODE" && sLEVEL == "HAL") && (g_perfutility->dwPerfUtilityIsEnabled & DECODE_HAL)) ||  \
76      ((sCOMP == "ENCODE" && sLEVEL == "DDI") && (g_perfutility->dwPerfUtilityIsEnabled & ENCODE_DDI)) ||  \
77      ((sCOMP == "ENCODE" && sLEVEL == "HAL") && (g_perfutility->dwPerfUtilityIsEnabled & ENCODE_HAL)) ||  \
78      ((sCOMP == "VP" && sLEVEL == "DDI") && (g_perfutility->dwPerfUtilityIsEnabled & VP_DDI)) ||          \
79      ((sCOMP == "VP" && sLEVEL == "HAL") && (g_perfutility->dwPerfUtilityIsEnabled & VP_HAL)) ||          \
80      ((sCOMP == "CP" && sLEVEL == "DDI") && (g_perfutility->dwPerfUtilityIsEnabled & CP_DDI)) ||          \
81      ((sCOMP == "CP" && sLEVEL == "HAL") && (g_perfutility->dwPerfUtilityIsEnabled & CP_HAL)) ||          \
82      ((sCOMP == "MOS" && sLEVEL == "DDI") && (g_perfutility->dwPerfUtilityIsEnabled & MOS_DDI)) ||        \
83      ((sCOMP == "MOS" && sLEVEL == "HAL") && (g_perfutility->dwPerfUtilityIsEnabled & MOS_HAL)))
84 
85 #define PERF_UTILITY_START(TAG,COMP,LEVEL)                                 \
86     do                                                                     \
87     {                                                                      \
88         if (PERFUTILITY_IS_ENABLED((std::string)COMP,(std::string)LEVEL))  \
89         {                                                                  \
90             g_perfutility->startTick(TAG);                                 \
91         }                                                                  \
92     } while(0)
93 
94 #define PERF_UTILITY_STOP(TAG, COMP, LEVEL)                                \
95     do                                                                     \
96     {                                                                      \
97         if (PERFUTILITY_IS_ENABLED((std::string)COMP,(std::string)LEVEL))  \
98         {                                                                  \
99             g_perfutility->stopTick(TAG);                                  \
100         }                                                                  \
101     } while (0)
102 
103 static int perf_count_start = 0;
104 static int perf_count_stop = 0;
105 
106 #define PERF_UTILITY_START_ONCE(TAG, COMP,LEVEL)                           \
107     do                                                                     \
108     {                                                                      \
109         if (perf_count_start == 0                                          \
110             && PERFUTILITY_IS_ENABLED((std::string)COMP,(std::string)LEVEL))  \
111         {                                                                  \
112                 g_perfutility->startTick(TAG);                             \
113         }                                                                  \
114         perf_count_start++;                                                \
115     } while(0)
116 
117 #define PERF_UTILITY_STOP_ONCE(TAG, COMP, LEVEL)                           \
118     do                                                                     \
119     {                                                                      \
120         if (perf_count_stop == 0                                           \
121             && PERFUTILITY_IS_ENABLED((std::string)COMP,(std::string)LEVEL))  \
122         {                                                                  \
123             g_perfutility->stopTick(TAG);                                  \
124         }                                                                  \
125         perf_count_stop++;                                                 \
126     } while (0)
127 
128 #define PERF_UTILITY_AUTO(TAG,COMP,LEVEL) AutoPerfUtility apu(TAG,COMP,LEVEL)
129 
130 #define PERF_UTILITY_PRINT                         \
131     do                                             \
132     {                                              \
133         if (g_perfutility->dwPerfUtilityIsEnabled && MosUtilities::MosIsProfilerDumpEnabled()) \
134         {                                          \
135             g_perfutility->savePerfData();         \
136         }                                          \
137     } while(0)
138 
139 class AutoPerfUtility
140 {
141 public:
AutoPerfUtility(std::string tag,std::string comp,std::string level)142     AutoPerfUtility(std::string tag, std::string comp, std::string level)
143     {
144         if (PERFUTILITY_IS_ENABLED(comp, level))
145         {
146             g_perfutility->startTick(tag);
147             autotag = tag;
148             bEnable = true;
149         }
150     }
~AutoPerfUtility()151     ~AutoPerfUtility()
152     {
153         if (bEnable)
154         {
155             g_perfutility->stopTick(autotag);
156         }
157     }
158 
159 private:
160     bool bEnable = false;
161     std::string autotag ="intialized";
162 };
163 
164 ////////////////////////////////////////////////////////////////////
165 
166 typedef void* HINSTANCE;
167 
168 #define Mos_InitInterface(osInterface, osDriverContext, component)                 \
169     Mos_InitOsInterface(osInterface, osDriverContext, component)
170 
171 #define Mos_ResourceIsNull(resource)    MosInterface::MosResourceIsNull(resource)
172 
173 #define GMM_LIBVA_LINUX 3
174 
175 enum DdiSurfaceFormat
176 {
177     DDI_FORMAT_UNKNOWN      = 0,
178     DDI_FORMAT_A8B8G8R8     = 32,
179     DDI_FORMAT_X8B8G8R8     = 33,
180     DDI_FORMAT_A8R8G8B8     = 21,
181     DDI_FORMAT_X8R8G8B8     = 22,
182     DDI_FORMAT_R5G6B5       = 23,
183     DDI_FORMAT_YUY2         = MAKEFOURCC('Y', 'U', 'Y', '2'),
184     DDI_FORMAT_P8           = 41,
185     DDI_FORMAT_A8P8         = 40,
186     DDI_FORMAT_A8           = 28,
187     DDI_FORMAT_L8           = 50,
188     DDI_FORMAT_L16          = 81,
189     DDI_FORMAT_A4L4         = 52,
190     DDI_FORMAT_A8L8         = 51,
191     DDI_FORMAT_R32F         = 114,
192     DDI_FORMAT_V8U8         = 60,
193     DDI_FORMAT_UYVY         = MAKEFOURCC('U', 'Y', 'V', 'Y'),
194     DDI_FORMAT_NV12         = MAKEFOURCC('N', 'V', '1', '2'),
195     DDI_FORMAT_A16B16G16R16 = 36,
196     DDI_FORMAT_R32G32B32A32F = 115,
197 };
198 
199 #define INDIRECT_HEAP_SIZE_UNITS    (1024)
200 
201 /* copy from intcver.h  */
202 #ifndef BUILD_NUMBER
203 #define BUILD_NUMBER       9034
204 #endif
205 
206 #define COMMAND_BUFFER_RESERVED_SPACE                      0x80
207 
208 #define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
209 
210 ////////////////////////////////////////////////////////////////////
211 
212 //!
213 //! \brief Definitions specific to Linux
214 //!
215 #define COMMAND_BUFFER_SIZE                       32768
216 
217 #define MAX_CMD_BUF_NUM                           30
218 
219 #define MOS_LOCKFLAG_WRITEONLY                    OSKM_LOCKFLAG_WRITEONLY
220 #define MOS_LOCKFLAG_READONLY                     OSKM_LOCKFLAG_READONLY
221 #define MOS_LOCKFLAG_NOOVERWRITE                  OSKM_LOCKFLAG_NOOVERWRITE
222 #define MOS_LOCKFLAG_NO_SWIZZLE                   OSKM_LOCKFLAG_NO_SWIZZLE
223 
224 #define MOS_DIR_SEPERATOR                         '/'
225 
226 #define MOS_INVALID_ALLOC_INDEX                         -1
227 #define MOS_MAX_REGS                              128 //32
228 #ifdef ANDROID
229 #define MOS_STATUS_REPORT_DEFAULT                 0
230 #else
231 #define MOS_STATUS_REPORT_DEFAULT                 1
232 #endif
233 
234 #define OSKM_LOCKFLAG_WRITEONLY                   0x00000001
235 #define OSKM_LOCKFLAG_READONLY                    0x00000002
236 #define OSKM_LOCKFLAG_NOOVERWRITE                 0x00000004
237 #define OSKM_LOCKFLAG_NO_SWIZZLE                  0x00000008
238 
239 // should be defined in libdrm, this is a temporary solution to pass QuickBuild
240 #define I915_EXEC_VEBOX                  (4<<0)
241 #define I915_EXEC_VCS2                   (6<<0)
242 
243 // I915_EXEC_BSD_* -- Attempt to provide backwards and forwards
244 // compatibility with versions of include/drm/i915_drm.h that do not
245 // have these definitions or that have them with the same values but
246 // different textual representations.  This will help avoid compiler
247 // warnings about macro redefinitions.
248 
249 #if !defined I915_EXEC_BSD_MASK
250 #define I915_EXEC_BSD_MASK               (3<<13)
251 #endif
252 #if !defined I915_EXEC_BSD_DEFAULT
253 #define I915_EXEC_BSD_DEFAULT            (0<<13) /* default ping-pong mode */
254 #endif
255 #if !defined I915_EXEC_BSD_RING1
256 #define I915_EXEC_BSD_RING1              (1<<13)
257 #endif
258 #if !defined I915_EXEC_BSD_RING2
259 #define I915_EXEC_BSD_RING2              (2<<13)
260 #endif
261 
262 #define I915_PARAM_HAS_BSD2               31
263 #define I915_EXEC_ENABLE_WATCHDOG_LINUX  (1<<18)
264 
265 //!
266 //! \brief Forward declarations
267 //!
268 typedef struct _MOS_SPECIFIC_RESOURCE  MOS_RESOURCE, *PMOS_RESOURCE;
269 typedef struct _MOS_INTERFACE      *PMOS_INTERFACE;
270 typedef struct _MOS_COMMAND_BUFFER *PMOS_COMMAND_BUFFER;
271 typedef struct _MOS_LOCK_PARAMS    *PMOS_LOCK_PARAMS;
272 
273 typedef void *MEDIAUMD_RESOURCE;
274 
275 //!
276 //! \brief enum to video device operations
277 //!
278 typedef enum _MOS_MEDIA_OPERATION
279 {
280     MOS_MEDIA_OPERATION_NONE    = 0,
281     MOS_MEDIA_OPERATION_DECODE,
282     MOS_MEDIA_OPERATION_ENCODE,
283     MOS_MEDIA_OPERATION_MAX
284 } MOS_MEDIA_OPERATION, *PMOS_MEDIA_OPERATION;
285 
286 //!
287 //! \brief ENum to GPU nodes
288 //!
289 typedef enum _MOS_GPU_NODE
290 {
291     MOS_GPU_NODE_3D      = DRM_EXEC_RENDER,
292     MOS_GPU_NODE_COMPUTE = DRM_EXEC_COMPUTE,
293     MOS_GPU_NODE_VE      = DRM_EXEC_VEBOX,
294     MOS_GPU_NODE_VIDEO   = DRM_EXEC_BSD,
295     MOS_GPU_NODE_VIDEO2  = DRM_EXEC_VCS2,
296     MOS_GPU_NODE_BLT     = DRM_EXEC_BLT,
297     MOS_GPU_NODE_MAX     = 7//GFX_MAX(DRM_EXEC_RENDER, DRM_EXEC_COMPUTE, DRM_EXEC_VEBOX, DRM_EXEC_BSD, DRM_EXEC_VCS2, DRM_EXEC_BLT) + 1
298 } MOS_GPU_NODE, *PMOS_GPU_NODE;
299 
300 //!
301 //! \brief Inline function to get GPU node
302 //!
OSKMGetGpuNode(MOS_GPU_CONTEXT uiGpuContext)303 static inline MOS_GPU_NODE OSKMGetGpuNode(MOS_GPU_CONTEXT uiGpuContext)
304 {
305     switch (uiGpuContext)
306     {
307         case MOS_GPU_CONTEXT_RENDER:
308         case MOS_GPU_CONTEXT_RENDER2:
309         case MOS_GPU_CONTEXT_RENDER3:
310         case MOS_GPU_CONTEXT_RENDER4:
311         case MOS_GPU_CONTEXT_COMPUTE: //change this context mapping to Compute Node instead of 3D node after the node name is defined in linux.
312             return  MOS_GPU_NODE_3D;
313             break;
314         case MOS_GPU_CONTEXT_VEBOX:
315             return  MOS_GPU_NODE_VE;
316             break;
317         case MOS_GPU_CONTEXT_VIDEO:
318         case MOS_GPU_CONTEXT_VIDEO2:
319         case MOS_GPU_CONTEXT_VIDEO3:
320         case MOS_GPU_CONTEXT_VIDEO4:
321         case MOS_GPU_CONTEXT_VIDEO5:
322         case MOS_GPU_CONTEXT_VIDEO6:
323         case MOS_GPU_CONTEXT_VIDEO7:
324             return MOS_GPU_NODE_VIDEO;
325             break;
326         case MOS_GPU_CONTEXT_VDBOX2_VIDEO:
327         case MOS_GPU_CONTEXT_VDBOX2_VIDEO2:
328         case MOS_GPU_CONTEXT_VDBOX2_VIDEO3:
329             return MOS_GPU_NODE_VIDEO2;
330             break;
331         case MOS_GPU_CONTEXT_BLT:
332             return MOS_GPU_NODE_BLT;
333             break;
334         default:
335             return MOS_GPU_NODE_MAX ;
336             break;
337     }
338 }
339 
340 //!
341 //! \brief enum to Intel bo map operations
342 //!
343 typedef enum _MOS_MMAP_OPERATION
344 {
345     MOS_MMAP_OPERATION_NONE    = 0,
346     MOS_MMAP_OPERATION_MMAP,
347     MOS_MMAP_OPERATION_MMAP_GTT,
348     MOS_MMAP_OPERATION_MMAP_WC
349 } MOS_MMAP_OPERATION, *PMOS_MMAP_OPERATION;
350 
351 //!
352 //! \brief Structure to Linux resource
353 //!
354 struct _MOS_SPECIFIC_RESOURCE
355 {
356     int32_t             iWidth;
357     int32_t             iHeight;
358     int32_t             iSize;
359     int32_t             iPitch;
360     int32_t             iDepth;             //!< for 3D surface
361     MOS_FORMAT          Format;
362     int32_t             iCount;
363     int32_t             iAllocationIndex[MOS_GPU_CONTEXT_MAX];
364     uint64_t            dwGfxAddress;
365     uint8_t             *pData;
366     const char          *bufname;
367     uint32_t            isTiled;
368     MOS_TILE_TYPE       TileType;
369     uint32_t            bMapped;
370     MOS_LINUX_BO        *bo;
371     uint32_t            name;
372     GMM_RESOURCE_INFO   *pGmmResInfo;        //!< GMM resource descriptor
373     MOS_MMAP_OPERATION  MmapOperation;
374     uint8_t             *pSystemShadow;
375     MOS_PLANE_OFFSET    YPlaneOffset;       //!< Y surface plane offset
376     MOS_PLANE_OFFSET    UPlaneOffset;       //!< U surface plane offset
377     MOS_PLANE_OFFSET    VPlaneOffset;       //!< V surface plane offset
378     uint32_t            dwOffsetForMono;    // This filed is used for mono surface only. DO NOT USE IT FOR OTHER USAGE.
379 
380     //!< to sync render target for multi-threading decoding mode
381     struct
382     {
383         int32_t         bSemInitialized;
384         PMOS_SEMAPHORE  *ppCurrentFrameSemaphore;   //!< Semaphore queue for hybrid decoding multi-threading case
385         PMOS_SEMAPHORE  *ppReferenceFrameSemaphore; //!< Semaphore queue for hybrid decoding multi-threading case; post when a surface is not used as reference frame
386     };
387 
388 #if MOS_MEDIASOLO_SUPPORTED
389     //!< these fields are only used while MediaSolo is enabled(bSoloInUse of OS_Interface is true).
390     uint32_t            dwOffset;
391     FILE*               pFile;
392     char                *pcFilePath;
393     int32_t             bManualSwizzlingInUse;
394     // used for AubCapture mode
395     int32_t                 bAubGttUpdate;
396     int32_t                 bAubMemUpdate;
397     int32_t                 bInterestedRes;
398     int32_t                 bPermaLocked;
399 #endif // MOS_MEDIASOLO_SUPPORTED
400 
401     // This is used by MDF when a wrapper/virtual MOS Resource is used to set surface state for a given VA, not necessary from start, in an actual MOS resource
402     uint64_t                user_provided_va;
403     // for MODS Wrapper
404     GraphicsResource*       pGfxResource;
405     GraphicsResourceNext*   pGfxResourceNext;
406     bool                    bConvertedFromDDIResource;
407     uint32_t                dwResourceOffset;
408     bool                    bExternalSurface;    //!< indicate the surface not allocated by media
409 
410     // Tile switch
411     MOS_TILE_MODE_GMM   TileModeGMM;
412     bool                bGMMTileEnabled;
413 
414     // Compression track
415     bool                bUncompressedWriteNeeded; //!< set uncompressed write flag to trace media uncomrpessedwrite request
416 
417     MEMORY_OBJECT_CONTROL_STATE memObjCtrlState;
418     MOS_HW_RESOURCE_DEF         mocsMosResUsageType;
419 };
420 
421 //!
422 //! \brief Structure to MOS_SURFACE
423 //!
424 struct MOS_SURFACE
425 {
426     MOS_RESOURCE        OsResource;                                             //Surface Resource
427 
428     uint32_t            dwArraySlice;                                           //!< [in]
429     uint32_t            dwMipSlice;                                             //!< [in]
430     MOS_S3D_CHANNEL     S3dChannel;                                             //!< [in]
431 
432     MOS_GFXRES_TYPE     Type;                                                   //!< [out] Basic resource geometry
433     int32_t             bOverlay;
434     int32_t             bFlipChain;
435 
436     uint32_t            dwWidth;                                                //!< [out] Type == 2D || VOLUME, width in pixels.
437     uint32_t            dwHeight;                                               //!< [out] Type == 2D || VOLUME, height in rows. Type == BUFFER, n/a
438     uint32_t            dwSize;                                                 //!< [out] Type == 2D || VOLUME, the size of surface
439     uint32_t            dwDepth;                                                //!< [out] 0: Implies 2D resource. >=1: volume resource
440     uint32_t            dwArraySize;                                            //!< [out] 0,1: 1 element. >1: N elements
441     uint32_t            dwLockPitch;                                            //!< [out] pitch in bytes used for locking
442     uint32_t            dwPitch;                                                //!< [out] < RenderPitch > pitch in bytes used for programming HW
443     uint32_t            dwSlicePitch;                                           //!< [out] Type == VOLUME, byte offset to next slice. Type != VOLUME, n/a
444     uint32_t            dwQPitch;                                               //!< [out] QPitch - distance in rows between R-Planes used for programming HW
445     MOS_TILE_TYPE       TileType;                                               //!< [out] Defines the layout of a physical page. Optimal choice depends on usage model.
446     MOS_FORMAT          Format;                                                 //!< [out] Pixel format
447     int32_t             bArraySpacing;                                          //!< [out] Array spacing
448     int32_t             bCompressible;                                          //!< [out] Memory compression
449 
450     uint32_t            dwOffset;                                               // Surface Offset (Y/Base)
451     MOS_PLANE_OFFSET    YPlaneOffset;                                           // Y surface plane offset
452     MOS_PLANE_OFFSET    UPlaneOffset;                                           // U surface plane offset
453     MOS_PLANE_OFFSET    VPlaneOffset;                                           // V surface plane offset
454     uint32_t            dwYPitch;                                               // Y surface plane pitch
455     uint32_t            dwUPitch;                                               // U surface plane pitch
456     uint32_t            dwVPitch;                                               // V surface plane pitch
457 
458     union
459     {
460         struct
461         {
462             MOS_RESOURCE_OFFSETS Y;
463             MOS_RESOURCE_OFFSETS U;
464             MOS_RESOURCE_OFFSETS V;
465         } YUV;                                                                  //!< [out] Valid for YUV & planar RGB formats. Invalid for RGB formats.
466 
467         MOS_RESOURCE_OFFSETS RGB;                                               //!< [out] Valid non planar RGB formats. Invalid for YUV and planar RGB formats.
468     } RenderOffset;                                                             //!< [out] Offsets request by input parameters. Used to program HW.
469 
470     union
471     {
472         struct
473         {
474             uint32_t Y;
475             uint32_t U;
476             uint32_t V;
477         } YUV;                                                                   //!< [out] Valid for YUV & planar RGB formats. Invalid for RGB formats.
478 
479         uint32_t RGB;                                                             //!< [out] Valid non planar RGB formats. Invalid for YUV and planar RGB formats.
480     } LockOffset;                                                                //!< [out] Offset in bytes used for locking
481 
482     // Surface compression mode, enable flags
483     int32_t                 bIsCompressed;                                       //!< [out] Memory compression flag
484     MOS_RESOURCE_MMC_MODE   CompressionMode;                                     //!< [out] Memory compression mode
485     uint32_t                CompressionFormat;                                   //!< [out] Memory compression format
486     // deprecated: not to use MmcState
487     MOS_MEMCOMP_STATE       MmcState;                                            // Memory compression state
488     // Tile Switch
489     MOS_TILE_MODE_GMM   TileModeGMM;                                            //!< [out] Transparent GMM Tiletype specifying in hwcmd finally
490     bool                bGMMTileEnabled;                                        //!< [out] GMM defined tile mode flag
491     uint32_t            YoffsetForUplane;                                       //!< [out] Y offset from U plane to Y plane.
492     uint32_t            YoffsetForVplane;                                       //!< [out] Y offset from V plane to Y plane.
493     // Surface cache Usage
494     uint32_t CacheSetting;
495 #if (_DEBUG || _RELEASE_INTERNAL)
496     uint32_t oldCacheSetting;
497 #endif
498 };
499 typedef MOS_SURFACE *PMOS_SURFACE;
500 
501 //!
502 //! \brief Structure to MOS_BUFFER
503 //!
504 struct MOS_BUFFER
505 {
506     MOS_RESOURCE    OsResource; //!< Buffer resource
507     uint32_t        size;       //!< Buffer size
508     const char*     name;           //!< Buffer name
509     bool            initOnAllocate; //!< Flag to indicate whether initialize when allocate
510     uint8_t         initValue;      //!< Initialize value when initOnAllocate is set
511     bool            bPersistent;    //!< Persistent flag
512 };
513 typedef MOS_BUFFER *PMOS_BUFFER;
514 
515 //!
516 //! \brief Structure to patch location list
517 //!
518 typedef struct _PATCHLOCATIONLIST
519 {
520     uint32_t                    AllocationIndex;
521     uint32_t                    AllocationOffset;
522     uint32_t                    PatchOffset;
523     uint32_t                    cpCmdProps;
524     int32_t                     uiRelocFlag;
525     uint32_t                    uiWriteOperation;
526     MOS_LINUX_BO                *cmdBo;
527 } PATCHLOCATIONLIST, *PPATCHLOCATIONLIST;
528 
529 //#define PATCHLOCATIONLIST_SIZE 25
530 #define CODECHAL_MAX_REGS  256
531 #define PATCHLOCATIONLIST_SIZE CODECHAL_MAX_REGS
532 
533 //!
534 //! \brief Structure to Allocation List
535 //!
536 typedef struct _ALLOCATION_LIST
537 {
538     HANDLE      hAllocation;
539     uint32_t    WriteOperation;
540 } ALLOCATION_LIST, *PALLOCATION_LIST;
541 
542 //#define ALLOCATIONLIST_SIZE MOS_MAX_REGS
543 #define ALLOCATIONLIST_SIZE CODECHAL_MAX_REGS  //!< use the large value
544 
545 //!
546 //! \brief Structure to command buffer
547 //!
548 typedef struct _COMMAND_BUFFER
549 {
550     // Double linked list
551     struct _COMMAND_BUFFER     *pNext;
552     struct _COMMAND_BUFFER     *pPrev;
553 
554     int64_t             *pSyncTag;
555     int64_t             qSyncTag;
556 
557     // Status
558     int32_t             bActive;        //!< Active / Inactive flag
559     int32_t             bRunning;       //!< CB is running in Gfx Device
560     LARGE_INTEGER       TimeStart;      //!< Start timestamp
561     LARGE_INTEGER       TimeEnd;        //!< End timestamp
562 
563     // Buffer information
564     uint8_t             *pCmdBase;       //!< Pointer to buffer data
565     uint8_t             *pCmdCurrent;    //!< Current pointer
566     int32_t             iSize;          //!< Buffer Size
567     int32_t             iCurrent;       //!< Current offset
568     int32_t             iRemaining;     //!< Remaining
569 } COMMAND_BUFFER, *PCOMMAND_BUFFER;
570 
571 typedef struct _MOS_GPU_STATUS_DATA
572 {
573     uint32_t    GPUTag;
574     uint32_t    ReservedForGPUTag;      //!< Reserved for gpu tag uint64_t write back by gpu but we only use the low uint32_t above.
575     uint32_t    Reserved[6];            //!< Padding to 32 byte-aligned for future use.
576 } MOS_GPU_STATUS_DATA;
577 
578 //!
579 //! \brief Structure to Gpu context
580 //!
581 typedef struct _CODECHAL_OS_GPU_CONTEXT
582 {
583     volatile int32_t            bCBFlushed; //!< if CB not flushed, re-use
584     PMOS_COMMAND_BUFFER         pCB;
585     uint32_t                    uiCommandBufferSize;
586 
587     // Allcoation List
588     ALLOCATION_LIST             *pAllocationList;
589     uint32_t                    uiNumAllocations;
590     uint32_t                    uiMaxPatchLocationsize;
591 
592     // Patch List
593     PATCHLOCATIONLIST           *pPatchLocationList;
594     uint32_t                    uiCurrentNumPatchLocations;
595     uint32_t                    uiMaxNumAllocations;
596 
597     // OS command buffer
598     PCOMMAND_BUFFER             pStartCB;
599     PCOMMAND_BUFFER             pCurrentCB;
600 
601     // Resource registrations
602     uint32_t                    uiResCount;                    //!< # of resources registered
603     int32_t                     iResIndex[CODECHAL_MAX_REGS];  //!< Resource indices
604     PMOS_RESOURCE                pResources;                   //!< Pointer to resources list
605     int32_t                     *pbWriteMode;                  //!< Write mode
606 
607     // GPU Status
608     uint32_t                    uiGPUStatusTag;
609 } MOS_OS_GPU_CONTEXT, *PMOS_OS_GPU_CONTEXT;
610 
611 //!
612 //! \brief Structure to buffer pool
613 //!
614 typedef struct _CMD_BUFFER_BO_POOL
615 {
616     int32_t             iFetch;
617     MOS_LINUX_BO        *pCmd_bo[MAX_CMD_BUF_NUM];
618 }CMD_BUFFER_BO_POOL;
619 
620 struct MOS_CONTEXT_OFFSET
621 {
622     MOS_LINUX_CONTEXT *intel_context;
623     MOS_LINUX_BO      *target_bo;
624     uint64_t          offset64;
625 };
626 
627 // APO related
628 #define FUTURE_PLATFORM_MOS_APO   1234
629 bool SetupApoMosSwitch(int32_t fd, MediaUserSettingSharedPtr userSettingPtr);
630 bool SetupApoDdiSwitch(int32_t fd, MediaUserSettingSharedPtr userSettingPtr);
631 bool SetupMediaSoloSwitch();
632 
633 enum OS_SPECIFIC_RESOURCE_TYPE
634 {
635     OS_SPECIFIC_RESOURCE_INVALID = 0,
636     OS_SPECIFIC_RESOURCE_SURFACE = 1,
637     OS_SPECIFIC_RESOURCE_BUFFER = 2,
638     OS_SPECIFIC_RESOURCE_MAX
639 };
640 
641 class OsContextNext;
642 typedef OsContextNext    OsDeviceContext;
643 typedef OsDeviceContext *MOS_DEVICE_HANDLE;
644 
645 typedef struct _MOS_OS_CONTEXT MOS_CONTEXT, *PMOS_CONTEXT, MOS_OS_CONTEXT, *PMOS_OS_CONTEXT, MOS_DRIVER_CONTEXT,*PMOS_DRIVER_CONTEXT;
646 //!
647 //! \brief Structure to OS context
648 //!
649 struct _MOS_OS_CONTEXT
650 {
651     // Context must be freed by os emul layer
652     int32_t             bFreeContext        = 0;
653 
654     uint32_t            uIndirectStateSize  = 0;
655 
656     MOS_OS_GPU_CONTEXT OsGpuContext[MOS_GPU_CONTEXT_MAX] = {};
657 
658     // Buffer rendering
659     LARGE_INTEGER       Frequency   = {};                //!< Frequency
660     LARGE_INTEGER       LastCB      = {};                   //!< End time for last CB
661 
662     CMD_BUFFER_BO_POOL CmdBufferPool = {};
663 
664     // Emulated platform, sku, wa tables
665     PLATFORM                  m_platform    = {};
666     MEDIA_FEATURE_TABLE       m_skuTable    = {};
667     MEDIA_WA_TABLE            m_waTable     = {};
668     MEDIA_SYSTEM_INFO         m_gtSystemInfo = {};
669 
670     // Controlled OS resources (for analysis)
671     MOS_BUFMGR          *bufmgr             = nullptr;
672     MOS_LINUX_CONTEXT   *intel_context      = nullptr;
673     int32_t             submit_fence        = 0;
674     uint32_t            uEnablePerfTag      = 0;        //!< 0: Do not pass PerfTag to KMD, perf data collection disabled;
675                                                         //!< 1: Pass PerfTag to MVP driver, perf data collection enabled;
676                                                         //!< 2: Pass PerfTag to DAPC driver, perf data collection enabled;
677     int32_t             bDisableKmdWatchdog = 0;        //!< 0: Do not disable kmd watchdog, that is to say, pass I915_EXEC_ENABLE_WATCHDOG flag to KMD;
678                                                         //!< 1: Disable kmd watchdog, that is to say, DO NOT pass I915_EXEC_ENABLE_WATCHDOG flag to KMD;
679     PERF_DATA           *pPerfData          = nullptr;  //!< Add Perf Data for KMD to capture perf tag
680 
681     int32_t             bHybridDecoderRunningFlag = 0;  //!< Flag to indicate if hybrid decoder is running
682 
683     int                 iDeviceId   = 0;
684     int                 wRevision   = 0;
685     int32_t             bIsAtomSOC  = 0;
686     int                 fd          = 0;                //!< handle for /dev/dri/card0
687 
688     int32_t             bUse64BitRelocs = 0;
689     bool                bUseSwSwizzling = false;
690     bool                bTileYFlag      = false;
691 
692     void                **ppMediaMemDecompState = nullptr;      //!<Media memory decompression data structure
693     void                **ppMediaCopyState      = nullptr;      //!<Media memory copy data structure
694 
695     // For modulized GPU context
696     void*               m_gpuContextMgr         = nullptr;
697     void*               m_cmdBufMgr             = nullptr;
698     MOS_DEVICE_HANDLE   m_osDeviceContext       = nullptr;
699 
700     //For 2VD box
701     int32_t             bKMDHasVCS2             = 0;
702     bool                bPerCmdBufferBalancing  = false;
703     int32_t             semid                   = 0;
704     int32_t             shmid                   = 0;
705     void                *pShm                   = nullptr;
706 
707     uint32_t            *pTranscryptedKernels   = nullptr;     //!< The cached version for current set of transcrypted and authenticated kernels
708     uint32_t            uiTranscryptedKernelsSize   = 0;       //!< Size in bytes of the cached version of transcrypted and authenticated kernels
709     void                *pLibdrmHandle          = nullptr;
710 
711     GMM_CLIENT_CONTEXT  *pGmmClientContext      = nullptr;   //UMD specific ClientContext object in GMM
712     AuxTableMgr         *m_auxTableMgr          = nullptr;
713 
714     // GPU Status Buffer
715     PMOS_RESOURCE       pGPUStatusBuffer        = nullptr;
716 
717     std::vector<struct MOS_CONTEXT_OFFSET> contextOffsetList = {};
718 
719     bool                bSimIsActive            = false;   //!< To indicate if simulation environment
720     bool                m_apoMosEnabled         = false;   //!< apo mos or not
721     bool                m_protectedGEMContext   = false;   //!< Indicates to create protected GEM content
722 
723     MediaUserSettingSharedPtr m_userSettingPtr  = nullptr;  // used to save user setting instance
724 
725     // Media memory decompression function
726     void (* pfnMemoryDecompress)(
727         PMOS_CONTEXT                pOsContext,
728         PMOS_RESOURCE               pOsResource) = nullptr;
729 
730     //!
731     //! \brief  the function ptr for surface copy function
732     //!
733     void  (* pfnMediaMemoryCopy )(
734         PMOS_CONTEXT       pOsContext,
735         PMOS_RESOURCE      pInputResource,
736         PMOS_RESOURCE      pOutputResource,
737         bool               bOutputCompressed) = nullptr;
738 
739     //!
740     //! \brief  the function ptr for Media Memory 2D copy function
741     //!
742     void (* pfnMediaMemoryCopy2D)(
743         PMOS_CONTEXT       pOsContext,
744         PMOS_RESOURCE      pInputResource,
745         PMOS_RESOURCE      pOutputResource,
746         uint32_t           copyWidth,
747         uint32_t           copyHeight,
748         uint32_t           copyInputOffset,
749         uint32_t           copyOutputOffset,
750         uint32_t           bpp,
751         bool               bOutputCompressed) = nullptr;
752 
753     //!
754     //! \brief  the function ptr for Media copy function
755     //!
756 
757     // Os Context interface functions
758     void (* pfnDestroy)(
759         struct _MOS_OS_CONTEXT      *pOsContext,
760         int32_t                     MODSEnabled,
761         int32_t                     MODSForGpuContext) = nullptr;
762 
763     int32_t (* pfnRefresh)(
764         struct _MOS_OS_CONTEXT      *pOsContext) = nullptr;
765 
766     int32_t (* pfnGetCommandBuffer)(
767         struct _MOS_OS_CONTEXT      *pOsContext,
768         PMOS_COMMAND_BUFFER         pCmdBuffer,
769         int32_t                     iSize) = nullptr;
770 
771     void (* pfnReturnCommandBuffer)(
772         struct _MOS_OS_CONTEXT      *pOsContext,
773         MOS_GPU_CONTEXT             GpuContext,
774         PMOS_COMMAND_BUFFER         pCmdBuffer) = nullptr;
775 
776     int32_t (* pfnFlushCommandBuffer)(
777         struct _MOS_OS_CONTEXT      *pOsContext,
778         MOS_GPU_CONTEXT             GpuContext) = nullptr;
779 
780     MOS_STATUS (* pfnInsertCmdBufferToPool)(
781         struct _MOS_OS_CONTEXT      *pOsContext,
782         PMOS_COMMAND_BUFFER         pCmdBuffer) = nullptr;
783 
784     MOS_STATUS (* pfnWaitAndReleaseCmdBuffer)(
785         struct _MOS_OS_CONTEXT      *pOsContext,
786         int32_t                     index) = nullptr;
787 
788     uint32_t (* GetDmaBufID ) (
789         struct _MOS_OS_CONTEXT      *pOsContext) = nullptr;
790 
791     void (* SetDmaBufID ) (
792         struct _MOS_OS_CONTEXT      *pOsContext,
793         uint32_t                    dwDmaBufID) = nullptr;
794 
795     void (* SetPerfHybridKernelID ) (
796         struct _MOS_OS_CONTEXT      *pOsContext,
797         uint32_t                    KernelID) = nullptr;
798 
799     uint32_t (* pfnGetGpuCtxBufferTag)(
800         PMOS_CONTEXT               pOsContext,
801         MOS_GPU_CONTEXT            GpuContext) = nullptr;
802 
803     void (* pfnIncGpuCtxBufferTag)(
804         PMOS_CONTEXT               pOsContext,
805         MOS_GPU_CONTEXT            GpuContext) = nullptr;
806 
807     uint32_t (* GetGPUTag)(
808         PMOS_INTERFACE             pOsInterface,
809         MOS_GPU_CONTEXT            GpuContext) = nullptr;
810 
811     GMM_CLIENT_CONTEXT* (* GetGmmClientContext)(
812         PMOS_CONTEXT               pOsContext) = nullptr;
813 
814 };
815 
816 //!
817 //! \brief Structure to VDBOX Workload Type
818 //!
819 typedef struct _VDBOX_WORKLOAD
820 {
821     uint32_t         uiVDBoxCount[2];    // VDBox workloads
822     uint32_t         uiRingIndex;        // ping-pong when vdbox1 count equals vdbox2 count
823 }VDBOX_WORKLOAD, *PVDBOX_WORKLOAD;
824 
825 //!
826 //! \brief Structure to Android Resource Type
827 //!
828 
829 //!
830 //! \brief Structure to Android Resource structure
831 //!
832 typedef struct _MOS_OS_ALLOCATION
833 {
834     PMOS_RESOURCE           pOsResource;                                        //!< Resource Info
835     int32_t                 bWriteMode;                                         //!< Read/Write Mode
836 } MOS_OS_ALLOCATION, *PMOS_OS_ALLOCATION;
837 
838 //!
839 //! \brief Structure to Buffer structure
840 //!
841 typedef struct _MOS_SPECIFIC_BUFFER
842 {
843     uint32_t dwHandle;                                                           //!< Buffer Handle
844     int32_t iAllocationIndex;                                                   //!< Allocation Index
845 } MOS_SPECIFIC_BUFFER_ANDROID, *PMOS_SPECIFIC_BUFFER;
846 
847 #ifdef __cplusplus
848 extern "C" {
849 #endif
850 
851 //!
852 //! \brief    Get Buffer Type
853 //! \details  Returns the type of buffer, 1D, 2D or volume
854 //! \param    PMOS_RESOURCE pOsResource
855 //!           [in] Pointer to OS Resource
856 //! \return   GFX resource Type
857 //!
858 MOS_GFXRES_TYPE GetResType(
859     PMOS_RESOURCE pOsResource);
860 
861 //!
862 //! \brief    Convert to MOS tile type
863 //! \details  Convert from Linux to MOS tile type
864 //! \param    uint32_t type
865 //!           [in] tile type
866 //! \return   MOS_TILE_TYPE
867 //!           Return MOS tile type
868 //!
869 MOS_TILE_TYPE LinuxToMosTileType(
870     uint32_t type);
871 
872 //!
873 //! \brief    Linux OS initilization
874 //! \details  Linux OS initilization
875 //! \param    PMOS_INTERFACE pOsInterface
876 //!           [in] Pointer to OS Interface
877 //! \param    PMOS_CONTEXT pOsDriverContext
878 //!           [in] Pointer to OS Driver context
879 //! \return   MOS_STATUS
880 //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
881 //!
882 MOS_STATUS Mos_Specific_InitInterface(
883     PMOS_INTERFACE     pOsInterface,
884     PMOS_CONTEXT       pOsDriverContext);
885 
886 //!
887 //! \brief    Lock resource
888 //! \details  Lock allocated resource
889 //! \param    PMOS_INTERFACE pOsInterface
890 //!           [in] Pointer to OS interface structure
891 //! \param    PMOS_RESOURCE pOsResource
892 //!           [in] Pointer to input OS resource
893 //! \param    PMOS_LOCK_PARAMS pLockFlags
894 //!           [in] Lock Flags - MOS_LOCKFLAG_* flags
895 //! \return   void *
896 //!
897 void  *Mos_Specific_LockResource(
898     PMOS_INTERFACE        pOsInterface,
899     PMOS_RESOURCE         pOsResource,
900     PMOS_LOCK_PARAMS      pLockFlags);
901 
902 //!
903 //! \brief    Destroys OS specific allocations
904 //! \details  Destroys OS specific allocations including destroying OS context
905 //! \param    PMOS_INTERFACE pOsInterface
906 //!           [in] Pointer to OS Interface
907 //! \param    int32_t bDestroyVscVppDeviceTag
908 //!           [in] Destroy VscVppDeviceTagId Flag, no use in Linux
909 //! \return   void
910 //!
911 void Mos_Specific_Destroy(
912     PMOS_INTERFACE     pOsInterface,
913     int32_t            bDestroyVscVppDeviceTag);
914 
915 //!
916 //! \brief    Resets OS States
917 //! \details  Resets OS States for linux
918 //! \param    PMOS_INTERFACE pOsInterface
919 //!           [in] Pointer to OS Interface
920 //! \return   void
921 //!
922 void Mos_Specific_ResetOsStates(
923     PMOS_INTERFACE pOsInterface);
924 
925 //!
926 //! \brief    Resizes the buffer to be used for rendering GPU commands
927 //! \details  Resizes the buffer to be used for rendering GPU commands
928 //! \param    PMOS_INTERFACE pOsInterface
929 //!           [in] OS Interface
930 //! \param    uint32_t dwRequestedCommandBufferSize
931 //!           [in] Requested command buffer size
932 //! \param    uint32_t dwRequestedPatchListSize
933 //!           [in] Requested patch list size
934 //! \return   MOS_STATUS
935 //!           MOS_STATUS_SUCCESS if succeeded, otherwise error code
936 //!
937 MOS_STATUS Mos_Specific_ResizeCommandBufferAndPatchList(
938     PMOS_INTERFACE          pOsInterface,
939     uint32_t                dwRequestedCommandBufferSize,
940     uint32_t                dwRequestedPatchListSize,
941     uint32_t                dwFlags);
942 
943 //!
944 //! \brief    Unlock resource
945 //! \details  Unlock the locked resource
946 //! \param    PMOS_INTERFACE pOsInterface
947 //!           [in] Pointer to OS interface structure
948 //! \param    PMOS_RESOURCE pOsResource
949 //!           [in] Pointer to input OS resource
950 //! \return   MOS_STATUS
951 //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
952 //!
953 MOS_STATUS Mos_Specific_UnlockResource(
954     PMOS_INTERFACE        pOsInterface,
955     PMOS_RESOURCE         pOsResource);
956 
957 //!
958 //! \brief    Get Resource Information
959 //! \details  Linux get resource info
960 //! \param    PMOS_INTERFACE pOsInterface
961 //!           [in] Pointer to OS interface structure
962 //! \param    PMOS_RESOURCE pOsResource
963 //!           [in] Pointer to input OS resource
964 //! \param    PMOS_SURFACE pResDetails
965 //!           [out] Pointer to output resource information details
966 //! \return   MOS_STATUS
967 //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
968 //!
969 MOS_STATUS Mos_Specific_GetResourceInfo(
970     PMOS_INTERFACE              pOsInterface,
971     PMOS_RESOURCE               pOsResource,
972     PMOS_SURFACE                pResDetails);
973 
974 //!
975 //! \brief    Get resource index
976 //! \details  Get resource index of MOS_RESOURCE
977 //! \param    PMOS_RESOURCE osResource
978 //!           [in] Pointer to OS resource
979 //! \return   uint32_t
980 //!           Resource index
981 //!
982 uint32_t Mos_Specific_GetResourceIndex(
983     PMOS_RESOURCE               osResource);
984 
985 uint32_t Mos_Specific_GetResourcePitch(
986     PMOS_RESOURCE               pOsResource);
987 
988 void Mos_Specific_SetResourceWidth(
989     PMOS_RESOURCE               pOsResource,
990     uint32_t                    dwWidth);
991 
992 void Mos_Specific_SetResourceFormat(
993     PMOS_RESOURCE               pOsResource,
994     MOS_FORMAT                  mosFormat);
995 
996 //!
997 //! \brief    Get SetMarker enabled flag
998 //! \details  Get SetMarker enabled flag from OsInterface
999 //! \param    PMOS_INTERFACE pOsInterface
1000 //!           [in] OS Interface
1001 //! \return   bool
1002 //!           SetMarker enabled flag
1003 //!
1004 bool Mos_Specific_IsSetMarkerEnabled(
1005     PMOS_INTERFACE         pOsInterface);
1006 
1007 //!
1008 //! \brief    Get SetMarker resource address
1009 //! \details  Get SetMarker resource address from OsInterface
1010 //! \param    PMOS_INTERFACE pOsInterface
1011 //!           [in] OS Interface
1012 //! \return   PMOS_RESOURCE
1013 //!           SetMarker resource address
1014 //!
1015 PMOS_RESOURCE Mos_Specific_GetMarkerResource(
1016     PMOS_INTERFACE         pOsInterface);
1017 
1018 //!
1019 //! \brief    Get TimeStamp frequency base
1020 //! \details  Get TimeStamp frequency base from OsInterface
1021 //! \param    PMOS_INTERFACE pOsInterface
1022 //!           [in] OS Interface
1023 //! \return   uint32_t
1024 //!           time stamp frequency base
1025 //!
1026 uint32_t Mos_Specific_GetTsFrequency(
1027     PMOS_INTERFACE         pOsInterface);
1028 
1029 //!
1030 //! \brief    Checks whether the requested resource is releasable
1031 //! \param    PMOS_INTERFACE pOsInterface
1032 //!           [in] OS Interface
1033 //! \param    PMOS_RESOURCE pOsResource
1034 //!           [in] Pointer to OS Resource
1035 //! \return   MOS_STATUS
1036 //!           MOS_STATUS_SUCCESS if requested can be released, otherwise MOS_STATUS_UNKNOWN
1037 //!
1038 MOS_STATUS Mos_Specific_IsResourceReleasable(
1039     PMOS_INTERFACE         pOsInterface,
1040     PMOS_RESOURCE          pOsResource);
1041 
1042 struct _MOS_SPECIFIC_VE_HINT_PARAMS;
1043 typedef struct _MOS_SPECIFIC_VE_HINT_PARAMS *PMOS_VIRTUALENGINE_HINT_PARAMS;
1044 struct _MOS_VIRTUALENGINE_INIT_PARAMS;
1045 typedef struct _MOS_VIRTUALENGINE_INIT_PARAMS MOS_VIRTUALENGINE_INIT_PARAMS, *PMOS_VIRTUALENGINE_INIT_PARAMS;
1046 
1047 //!
1048 //! \brief    Virtual Engine Init for media Scalability
1049 //! \details
1050 //! \param    PMOS_INTERFACE pOsInterface
1051 //!           [in] Pointer to OS interface structure
1052 //! \param    MOS_VE_HANDLE pVeState
1053 //!           [out] Virtual Engine State
1054 //! \param    PMOS_VIRTUALENGINE_HINT_PARAMS veHitParams
1055 //!           [out] Pointer to Virtual Engine hint parameters
1056 //! \param    PMOS_VIRTUALENGINE_INTERFACE veInterface
1057 //!           [out] Pointer to Virtual Engine Interface
1058 //! \return   MOS_STATUS
1059 //!           MOS_STATUS_SUCCESS if succeeded, otherwise error code
1060 //!
1061 MOS_STATUS Mos_Specific_Virtual_Engine_Init(
1062     PMOS_INTERFACE                  pOsInterface,
1063     PMOS_VIRTUALENGINE_HINT_PARAMS* veHitParams,
1064     MOS_VIRTUALENGINE_INIT_PARAMS&  veInParams);
1065 
1066 struct _MOS_VIRTUALENGINE_SET_PARAMS;
1067 typedef struct _MOS_VIRTUALENGINE_SET_PARAMS  MOS_VIRTUALENGINE_SET_PARAMS, *PMOS_VIRTUALENGINE_SET_PARAMS;
1068 
1069 //!
1070 //! \brief    Set hint parameters
1071 //! \details
1072 //! \param    PMOS_INTERFACE pOsInterface
1073 //!           [in] Pointer to OS interface structure
1074 //! \param    MOS_VIRTUALENGINE_SET_PARAMS veParams
1075 //!           [out] VIRTUALENGINE SET PARAMS
1076 //! \return   MOS_STATUS
1077 //!           MOS_STATUS_SUCCESS if succeeded, otherwise error code
1078 //!
1079 MOS_STATUS Mos_Specific_SetHintParams(
1080     PMOS_INTERFACE               pOsInterface,
1081     PMOS_VIRTUALENGINE_SET_PARAMS veParams);
1082 
1083 typedef struct _MOS_VIRTUALENGINE_INTERFACE *PMOS_VIRTUALENGINE_INTERFACE;
1084 
1085 //!
1086 //! \brief    Destroy veInterface
1087 //! \details
1088 //! \param    PMOS_VIRTUALENGINE_INTERFACE *veInterface
1089 //!           [in] Pointer to PMOS_VIRTUALENGINE_INTERFACE
1090 //! \return   MOS_STATUS
1091 //!           MOS_STATUS_SUCCESS if succeeded, otherwise error code
1092 //!
1093 MOS_STATUS Mos_Specific_DestroyVeInterface(
1094     PMOS_VIRTUALENGINE_INTERFACE *veInterface);
1095 
1096 #if (_DEBUG || _RELEASE_INTERNAL)
1097 MOS_LINUX_BO * Mos_GetNopCommandBuffer_Linux(
1098     PMOS_INTERFACE        pOsInterface);
1099 
1100 MOS_LINUX_BO * Mos_GetBadCommandBuffer_Linux(
1101     PMOS_INTERFACE        pOsInterface);
1102 
1103 //!
1104 //! \brief    gpuCtxCreateOption Init for media Scalability
1105 //! \details
1106 //! \param    PMOS_INTERFACE pOsInterface
1107 //!           [in] Pointer to OS interface structure
1108 //! \param    uint8_t id
1109 //!           [out] EngineLogicId
1110 //! \return   MOS_STATUS
1111 //!           MOS_STATUS_SUCCESS if succeeded, otherwise error code
1112 //!
1113 MOS_STATUS Mos_Specific_GetEngineLogicId(
1114     PMOS_INTERFACE                 pOsInterface,
1115     uint8_t&                       id);
1116 #endif
1117 
1118 #ifdef __cplusplus
1119 }
1120 #endif
1121 
1122 #endif // __MOS_OS_SPECIFIC_H__
1123