1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943
|
/*
* Copyright (c) 2009-2020, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file mos_os_specific.h
//! \brief Common interface and structure used in MOS LINUX OS
//!
#ifndef __MOS_OS_SPECIFIC_H__
#define __MOS_OS_SPECIFIC_H__
#include "media_skuwa_specific.h"
#include "GmmLib.h"
#include "mos_resource_defs.h"
#include "mos_defs.h"
#include "mos_os_cp_interface_specific.h"
#ifdef ANDROID
#include <utils/Log.h>
#endif
#include "i915_drm.h"
#include "mos_bufmgr.h"
#include "xf86drm.h"
#include <vector>
typedef unsigned int MOS_OS_FORMAT;
class GraphicsResource;
class GraphicsResourceNext;
class AuxTableMgr;
class MosOcaInterface;
class GraphicsResourceNext;
////////////////////////////////////////////////////////////////////
typedef void* HINSTANCE;
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
#define GMM_LIBVA_LINUX 3
enum DdiSurfaceFormat
{
DDI_FORMAT_UNKNOWN = 0,
DDI_FORMAT_A8B8G8R8 = 32,
DDI_FORMAT_X8B8G8R8 = 33,
DDI_FORMAT_A8R8G8B8 = 21,
DDI_FORMAT_X8R8G8B8 = 22,
DDI_FORMAT_R5G6B5 = 23,
DDI_FORMAT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'),
DDI_FORMAT_P8 = 41,
DDI_FORMAT_A8P8 = 40,
DDI_FORMAT_A8 = 28,
DDI_FORMAT_L8 = 50,
DDI_FORMAT_L16 = 81,
DDI_FORMAT_A4L4 = 52,
DDI_FORMAT_A8L8 = 51,
DDI_FORMAT_R32F = 114,
DDI_FORMAT_V8U8 = 60,
DDI_FORMAT_UYVY = MAKEFOURCC('U', 'Y', 'V', 'Y'),
DDI_FORMAT_NV12 = MAKEFOURCC('N', 'V', '1', '2'),
DDI_FORMAT_A16B16G16R16 = 36,
DDI_FORMAT_R32G32B32A32F = 115,
};
#define INDIRECT_HEAP_SIZE_UNITS (1024)
/* copy from intcver.h */
#ifndef BUILD_NUMBER
#define BUILD_NUMBER 9034
#endif
#define COMMAND_BUFFER_RESERVED_SPACE 0x80
#define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
////////////////////////////////////////////////////////////////////
//!
//! \brief Definitions specific to Linux
//!
#define COMMAND_BUFFER_SIZE 32768
#define MAX_CMD_BUF_NUM 30
#define MOS_LOCKFLAG_WRITEONLY OSKM_LOCKFLAG_WRITEONLY
#define MOS_LOCKFLAG_READONLY OSKM_LOCKFLAG_READONLY
#define MOS_LOCKFLAG_NOOVERWRITE OSKM_LOCKFLAG_NOOVERWRITE
#define MOS_LOCKFLAG_NO_SWIZZLE OSKM_LOCKFLAG_NO_SWIZZLE
#define MOS_DIR_SEPERATOR '/'
#define MOS_INVALID_ALLOC_INDEX -1
#define MOS_MAX_REGS 128 //32
#ifdef ANDROID
#define MOS_STATUS_REPORT_DEFAULT 0
#else
#define MOS_STATUS_REPORT_DEFAULT 1
#endif
#define OSKM_LOCKFLAG_WRITEONLY 0x00000001
#define OSKM_LOCKFLAG_READONLY 0x00000002
#define OSKM_LOCKFLAG_NOOVERWRITE 0x00000004
#define OSKM_LOCKFLAG_NO_SWIZZLE 0x00000008
// should be defined in libdrm, this is a temporary solution to pass QuickBuild
#define I915_EXEC_VEBOX (4<<0)
#define I915_EXEC_VCS2 (7<<0)
// I915_EXEC_BSD_* -- Attempt to provide backwards and forwards
// compatibility with versions of include/drm/i915_drm.h that do not
// have these definitions or that have them with the same values but
// different textual representations. This will help avoid compiler
// warnings about macro redefinitions.
#if !defined I915_EXEC_BSD_MASK
#define I915_EXEC_BSD_MASK (3<<13)
#endif
#if !defined I915_EXEC_BSD_DEFAULT
#define I915_EXEC_BSD_DEFAULT (0<<13) /* default ping-pong mode */
#endif
#if !defined I915_EXEC_BSD_RING1
#define I915_EXEC_BSD_RING1 (1<<13)
#endif
#if !defined I915_EXEC_BSD_RING2
#define I915_EXEC_BSD_RING2 (2<<13)
#endif
#define I915_PARAM_HAS_BSD2 31
#define I915_EXEC_ENABLE_WATCHDOG_LINUX (1<<18)
//!
//! \brief Forward declarations
//!
typedef struct _MOS_SPECIFIC_RESOURCE MOS_RESOURCE, *PMOS_RESOURCE;
typedef struct _MOS_INTERFACE *PMOS_INTERFACE;
typedef struct _MOS_COMMAND_BUFFER *PMOS_COMMAND_BUFFER;
typedef struct _MOS_LOCK_PARAMS *PMOS_LOCK_PARAMS;
//!
//! \brief enum to video device operations
//!
typedef enum _MOS_MEDIA_OPERATION
{
MOS_MEDIA_OPERATION_NONE = 0,
MOS_MEDIA_OPERATION_DECODE,
MOS_MEDIA_OPERATION_ENCODE,
MOS_MEDIA_OPERATION_MAX
} MOS_MEDIA_OPERATION, *PMOS_MEDIA_OPERATION;
//!
//! \brief ENum to GPU nodes
//!
typedef enum _MOS_GPU_NODE
{
MOS_GPU_NODE_3D = I915_EXEC_RENDER,
MOS_GPU_NODE_COMPUTE = (5<<0), //To change to compute CS later when linux define the name
MOS_GPU_NODE_VE = I915_EXEC_VEBOX,
MOS_GPU_NODE_VIDEO = I915_EXEC_BSD,
MOS_GPU_NODE_VIDEO2 = I915_EXEC_VCS2,
MOS_GPU_NODE_BLT = I915_EXEC_BLT,
MOS_GPU_NODE_MAX = 7,//GFX_MAX(I915_EXEC_RENDER, I915_EXEC_VEBOX, I915_EXEC_BSD, I915_EXEC_VCS2, I915_EXEC_BLT) + 1
} MOS_GPU_NODE, *PMOS_GPU_NODE;
//!
//! \brief Inline function to get GPU node
//!
static inline MOS_GPU_NODE OSKMGetGpuNode(MOS_GPU_CONTEXT uiGpuContext)
{
switch (uiGpuContext)
{
case MOS_GPU_CONTEXT_RENDER:
case MOS_GPU_CONTEXT_RENDER2:
case MOS_GPU_CONTEXT_RENDER3:
case MOS_GPU_CONTEXT_RENDER4:
case MOS_GPU_CONTEXT_COMPUTE: //change this context mapping to Compute Node instead of 3D node after the node name is defined in linux.
return MOS_GPU_NODE_3D;
break;
case MOS_GPU_CONTEXT_VEBOX:
return MOS_GPU_NODE_VE;
break;
case MOS_GPU_CONTEXT_VIDEO:
case MOS_GPU_CONTEXT_VIDEO2:
case MOS_GPU_CONTEXT_VIDEO3:
case MOS_GPU_CONTEXT_VIDEO4:
case MOS_GPU_CONTEXT_VIDEO5:
case MOS_GPU_CONTEXT_VIDEO6:
case MOS_GPU_CONTEXT_VIDEO7:
return MOS_GPU_NODE_VIDEO;
break;
case MOS_GPU_CONTEXT_VDBOX2_VIDEO:
case MOS_GPU_CONTEXT_VDBOX2_VIDEO2:
case MOS_GPU_CONTEXT_VDBOX2_VIDEO3:
return MOS_GPU_NODE_VIDEO2;
break;
case MOS_GPU_CONTEXT_BLT:
return MOS_GPU_NODE_BLT;
break;
default:
return MOS_GPU_NODE_MAX ;
break;
}
}
//!
//! \brief enum to Intel bo map operations
//!
typedef enum _MOS_MMAP_OPERATION
{
MOS_MMAP_OPERATION_NONE = 0,
MOS_MMAP_OPERATION_MMAP,
MOS_MMAP_OPERATION_MMAP_GTT,
MOS_MMAP_OPERATION_MMAP_WC
} MOS_MMAP_OPERATION, *PMOS_MMAP_OPERATION;
//!
//! \brief Structure to Linux resource
//!
struct _MOS_SPECIFIC_RESOURCE
{
int32_t iWidth;
int32_t iHeight;
int32_t iSize;
int32_t iPitch;
int32_t iDepth; //!< for 3D surface
MOS_FORMAT Format;
int32_t iCount;
int32_t iAllocationIndex[MOS_GPU_CONTEXT_MAX];
uint32_t dwGfxAddress;
uint8_t *pData;
const char *bufname;
uint32_t isTiled;
MOS_TILE_TYPE TileType;
uint32_t bMapped;
MOS_LINUX_BO *bo;
uint32_t name;
GMM_RESOURCE_INFO *pGmmResInfo; //!< GMM resource descriptor
MOS_MMAP_OPERATION MmapOperation;
uint8_t *pSystemShadow;
MOS_PLANE_OFFSET YPlaneOffset; //!< Y surface plane offset
MOS_PLANE_OFFSET UPlaneOffset; //!< U surface plane offset
MOS_PLANE_OFFSET VPlaneOffset; //!< V surface plane offset
//!< to sync render target for multi-threading decoding mode
struct
{
int32_t bSemInitialized;
PMOS_SEMAPHORE *ppCurrentFrameSemaphore; //!< Semaphore queue for hybrid decoding multi-threading case
PMOS_SEMAPHORE *ppReferenceFrameSemaphore; //!< Semaphore queue for hybrid decoding multi-threading case; post when a surface is not used as reference frame
};
#if MOS_MEDIASOLO_SUPPORTED
//!< these fields are only used while MediaSolo is enabled(bSoloInUse of OS_Interface is true).
uint32_t dwOffset;
FILE* pFile;
char *pcFilePath;
int32_t bManualSwizzlingInUse;
// used for AubCapture mode
int32_t bAubGttUpdate;
int32_t bAubMemUpdate;
int32_t bInterestedRes;
int32_t bPermaLocked;
#endif // MOS_MEDIASOLO_SUPPORTED
// 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
uint64_t user_provided_va;
// for MODS Wrapper
GraphicsResource* pGfxResource;
GraphicsResourceNext* pGfxResourceNext;
bool bConvertedFromDDIResource;
uint32_t dwResourceOffset;
bool bExternalSurface; //!< indicate the surface not allocated by media
// Tile switch
MOS_TILE_MODE_GMM TileModeGMM;
bool bGMMTileEnabled;
};
//!
//! \brief Structure to MOS_SURFACE
//!
struct MOS_SURFACE
{
MOS_RESOURCE OsResource; //Surface Resource
uint32_t dwArraySlice; //!< [in]
uint32_t dwMipSlice; //!< [in]
MOS_S3D_CHANNEL S3dChannel; //!< [in]
MOS_GFXRES_TYPE Type; //!< [out] Basic resource geometry
int32_t bOverlay;
int32_t bFlipChain;
uint32_t dwWidth; //!< [out] Type == 2D || VOLUME, width in pixels.
uint32_t dwHeight; //!< [out] Type == 2D || VOLUME, height in rows. Type == BUFFER, n/a
uint32_t dwSize; //!< [out] Type == 2D || VOLUME, the size of surface
uint32_t dwDepth; //!< [out] 0: Implies 2D resource. >=1: volume resource
uint32_t dwArraySize; //!< [out] 0,1: 1 element. >1: N elements
uint32_t dwLockPitch; //!< [out] pitch in bytes used for locking
uint32_t dwPitch; //!< [out] < RenderPitch > pitch in bytes used for programming HW
uint32_t dwSlicePitch; //!< [out] Type == VOLUME, byte offset to next slice. Type != VOLUME, n/a
uint32_t dwQPitch; //!< [out] QPitch - distance in rows between R-Planes used for programming HW
MOS_TILE_TYPE TileType; //!< [out] Defines the layout of a physical page. Optimal choice depends on usage model.
MOS_FORMAT Format; //!< [out] Pixel format
int32_t bArraySpacing; //!< [out] Array spacing
int32_t bCompressible; //!< [out] Memory compression
uint32_t dwOffset; // Surface Offset (Y/Base)
MOS_PLANE_OFFSET YPlaneOffset; // Y surface plane offset
MOS_PLANE_OFFSET UPlaneOffset; // U surface plane offset
MOS_PLANE_OFFSET VPlaneOffset; // V surface plane
union
{
struct
{
MOS_RESOURCE_OFFSETS Y;
MOS_RESOURCE_OFFSETS U;
MOS_RESOURCE_OFFSETS V;
} YUV; //!< [out] Valid for YUV & planar RGB formats. Invalid for RGB formats.
MOS_RESOURCE_OFFSETS RGB; //!< [out] Valid non planar RGB formats. Invalid for YUV and planar RGB formats.
} RenderOffset; //!< [out] Offsets request by input parameters. Used to program HW.
union
{
struct
{
uint32_t Y;
uint32_t U;
uint32_t V;
} YUV; //!< [out] Valid for YUV & planar RGB formats. Invalid for RGB formats.
uint32_t RGB; //!< [out] Valid non planar RGB formats. Invalid for YUV and planar RGB formats.
} LockOffset; //!< [out] Offset in bytes used for locking
// Surface compression mode, enable flags
int32_t bIsCompressed; //!< [out] Memory compression flag
MOS_RESOURCE_MMC_MODE CompressionMode; //!< [out] Memory compression mode
uint32_t CompressionFormat; //!< [out] Memory compression format
// deprecated: not to use MmcState
MOS_MEMCOMP_STATE MmcState; // Memory compression state
// Tile Switch
MOS_TILE_MODE_GMM TileModeGMM; //!< [out] Transparent GMM Tiletype specifying in hwcmd finally
bool bGMMTileEnabled; //!< [out] GMM defined tile mode flag
uint32_t YoffsetForUplane; //!< [out] Y offset from U plane to Y plane.
uint32_t YoffsetForVplane; //!< [out] Y offset from V plane to Y plane.
};
typedef MOS_SURFACE *PMOS_SURFACE;
//!
//! \brief Structure to MOS_BUFFER
//!
struct MOS_BUFFER
{
MOS_RESOURCE OsResource; //!< Buffer resource
uint32_t size; //!< Buffer size
const char* name; //!< Buffer name
bool initOnAllocate; //!< Flag to indicate whether initialize when allocate
uint8_t initValue; //!< Initialize value when initOnAllocate is set
bool bPersistent; //!< Persistent flag
};
typedef MOS_BUFFER *PMOS_BUFFER;
//!
//! \brief Structure to patch location list
//!
typedef struct _PATCHLOCATIONLIST
{
uint32_t AllocationIndex;
uint32_t AllocationOffset;
uint32_t PatchOffset;
uint32_t cpCmdProps;
int32_t uiRelocFlag;
uint32_t uiWriteOperation;
MOS_LINUX_BO *cmdBo;
} PATCHLOCATIONLIST, *PPATCHLOCATIONLIST;
//#define PATCHLOCATIONLIST_SIZE 25
#define CODECHAL_MAX_REGS 256
#define PATCHLOCATIONLIST_SIZE CODECHAL_MAX_REGS
//!
//! \brief Structure to Allocation List
//!
typedef struct _ALLOCATION_LIST
{
HANDLE hAllocation;
uint32_t WriteOperation;
} ALLOCATION_LIST, *PALLOCATION_LIST;
//#define ALLOCATIONLIST_SIZE MOS_MAX_REGS
#define ALLOCATIONLIST_SIZE CODECHAL_MAX_REGS //!< use the large value
//!
//! \brief Structure to command buffer
//!
typedef struct _COMMAND_BUFFER
{
// Double linked list
struct _COMMAND_BUFFER *pNext;
struct _COMMAND_BUFFER *pPrev;
int64_t *pSyncTag;
int64_t qSyncTag;
// Status
int32_t bActive; //!< Active / Inactive flag
int32_t bRunning; //!< CB is running in Gfx Device
LARGE_INTEGER TimeStart; //!< Start timestamp
LARGE_INTEGER TimeEnd; //!< End timestamp
// Buffer information
uint8_t *pCmdBase; //!< Pointer to buffer data
uint8_t *pCmdCurrent; //!< Current pointer
int32_t iSize; //!< Buffer Size
int32_t iCurrent; //!< Current offset
int32_t iRemaining; //!< Remaining
} COMMAND_BUFFER, *PCOMMAND_BUFFER;
typedef struct _MOS_GPU_STATUS_DATA
{
uint32_t GPUTag;
uint32_t ReservedForGPUTag; //!< Reserved for gpu tag uint64_t write back by gpu but we only use the low uint32_t above.
uint32_t Reserved[6]; //!< Padding to 32 byte-aligned for future use.
} MOS_GPU_STATUS_DATA;
//!
//! \brief Structure to Gpu context
//!
typedef struct _CODECHAL_OS_GPU_CONTEXT
{
volatile int32_t bCBFlushed; //!< if CB not flushed, re-use
PMOS_COMMAND_BUFFER pCB;
uint32_t uiCommandBufferSize;
// Allcoation List
ALLOCATION_LIST *pAllocationList;
uint32_t uiNumAllocations;
uint32_t uiMaxPatchLocationsize;
// Patch List
PATCHLOCATIONLIST *pPatchLocationList;
uint32_t uiCurrentNumPatchLocations;
uint32_t uiMaxNumAllocations;
// OS command buffer
PCOMMAND_BUFFER pStartCB;
PCOMMAND_BUFFER pCurrentCB;
// Resource registrations
uint32_t uiResCount; //!< # of resources registered
int32_t iResIndex[CODECHAL_MAX_REGS]; //!< Resource indices
PMOS_RESOURCE pResources; //!< Pointer to resources list
int32_t *pbWriteMode; //!< Write mode
// GPU Status
uint32_t uiGPUStatusTag;
} MOS_OS_GPU_CONTEXT, *PMOS_OS_GPU_CONTEXT;
//!
//! \brief Structure to buffer pool
//!
typedef struct _CMD_BUFFER_BO_POOL
{
int32_t iFetch;
MOS_LINUX_BO *pCmd_bo[MAX_CMD_BUF_NUM];
}CMD_BUFFER_BO_POOL;
struct MOS_CONTEXT_OFFSET
{
MOS_LINUX_CONTEXT *intel_context;
MOS_LINUX_BO *target_bo;
uint64_t offset64;
};
// APO related
#define FUTURE_PLATFORM_MOS_APO 1234
bool SetupApoMosSwitch(int32_t fd);
enum OS_SPECIFIC_RESOURCE_TYPE
{
OS_SPECIFIC_RESOURCE_INVALID = 0,
OS_SPECIFIC_RESOURCE_SURFACE = 1,
OS_SPECIFIC_RESOURCE_BUFFER = 2,
OS_SPECIFIC_RESOURCE_MAX
};
class OsContextNext;
typedef OsContextNext OsDeviceContext;
typedef OsDeviceContext *MOS_DEVICE_HANDLE;
typedef struct _MOS_OS_CONTEXT MOS_CONTEXT, *PMOS_CONTEXT, MOS_OS_CONTEXT, *PMOS_OS_CONTEXT, MOS_DRIVER_CONTEXT,*PMOS_DRIVER_CONTEXT;
//!
//! \brief Structure to OS context
//!
struct _MOS_OS_CONTEXT
{
// Context must be freed by os emul layer
int32_t bFreeContext;
uint32_t uIndirectStateSize;
MOS_OS_GPU_CONTEXT OsGpuContext[MOS_GPU_CONTEXT_MAX];
// Buffer rendering
LARGE_INTEGER Frequency; //!< Frequency
LARGE_INTEGER LastCB; //!< End time for last CB
CMD_BUFFER_BO_POOL CmdBufferPool;
// Emulated platform, sku, wa tables
PLATFORM platform;
MEDIA_FEATURE_TABLE SkuTable;
MEDIA_WA_TABLE WaTable;
MEDIA_SYSTEM_INFO gtSystemInfo;
// Controlled OS resources (for analysis)
MOS_BUFMGR *bufmgr;
MOS_LINUX_CONTEXT *intel_context;
int32_t submit_fence;
uint32_t uEnablePerfTag; //!< 0: Do not pass PerfTag to KMD, perf data collection disabled;
//!< 1: Pass PerfTag to MVP driver, perf data collection enabled;
//!< 2: Pass PerfTag to DAPC driver, perf data collection enabled;
int32_t bDisableKmdWatchdog; //!< 0: Do not disable kmd watchdog, that is to say, pass I915_EXEC_ENABLE_WATCHDOG flag to KMD;
//!< 1: Disable kmd watchdog, that is to say, DO NOT pass I915_EXEC_ENABLE_WATCHDOG flag to KMD;
PERF_DATA *pPerfData; //!< Add Perf Data for KMD to capture perf tag
int32_t bHybridDecoderRunningFlag; //!< Flag to indicate if hybrid decoder is running
int iDeviceId;
int wRevision;
int32_t bIsAtomSOC;
int fd; //!< handle for /dev/dri/card0
int32_t bUse64BitRelocs;
bool bUseSwSwizzling;
bool bTileYFlag;
void **ppMediaMemDecompState; //!<Media memory decompression data structure
void **ppMediaCopyState; //!<Media memory copy data structure
// For modulized GPU context
void* m_gpuContextMgr;
void* m_cmdBufMgr;
MOS_DEVICE_HANDLE m_osDeviceContext = nullptr;
//For 2VD box
int32_t bKMDHasVCS2;
bool bPerCmdBufferBalancing;
int32_t semid;
int32_t shmid;
void *pShm;
uint32_t *pTranscryptedKernels; //!< The cached version for current set of transcrypted and authenticated kernels
uint32_t uiTranscryptedKernelsSize; //!< Size in bytes of the cached version of transcrypted and authenticated kernels
void *pLibdrmHandle;
GMM_CLIENT_CONTEXT *pGmmClientContext; //UMD specific ClientContext object in GMM
GmmExportEntries GmmFuncs;
AuxTableMgr *m_auxTableMgr;
// GPU Status Buffer
PMOS_RESOURCE pGPUStatusBuffer;
std::vector< struct MOS_CONTEXT_OFFSET> contextOffsetList;
bool bSimIsActive; //!< To indicate if simulation environment
bool m_apoMosEnabled; //!< apo mos or not
// Media memory decompression function
void (* pfnMemoryDecompress)(
PMOS_CONTEXT pOsContext,
PMOS_RESOURCE pOsResource);
//!
//! \brief the function ptr for surface copy function
//!
void (* pfnMediaMemoryCopy )(
PMOS_CONTEXT pOsContext,
PMOS_RESOURCE pInputResource,
PMOS_RESOURCE pOutputResource,
bool bOutputCompressed);
//!
//! \brief the function ptr for Media Memory 2D copy function
//!
void (* pfnMediaMemoryCopy2D)(
PMOS_CONTEXT pOsContext,
PMOS_RESOURCE pInputResource,
PMOS_RESOURCE pOutputResource,
uint32_t copyWidth,
uint32_t copyHeight,
uint32_t copyInputOffset,
uint32_t copyOutputOffset,
uint32_t bpp,
bool bOutputCompressed);
//!
//! \brief the function ptr for Media copy function
//!
// Os Context interface functions
void (* pfnDestroy)(
struct _MOS_OS_CONTEXT *pOsContext,
int32_t MODSEnabled,
int32_t MODSForGpuContext);
int32_t (* pfnRefresh)(
struct _MOS_OS_CONTEXT *pOsContext);
int32_t (* pfnGetCommandBuffer)(
struct _MOS_OS_CONTEXT *pOsContext,
PMOS_COMMAND_BUFFER pCmdBuffer,
int32_t iSize);
void (* pfnReturnCommandBuffer)(
struct _MOS_OS_CONTEXT *pOsContext,
MOS_GPU_CONTEXT GpuContext,
PMOS_COMMAND_BUFFER pCmdBuffer);
int32_t (* pfnFlushCommandBuffer)(
struct _MOS_OS_CONTEXT *pOsContext,
MOS_GPU_CONTEXT GpuContext);
MOS_STATUS (* pfnInsertCmdBufferToPool)(
struct _MOS_OS_CONTEXT *pOsContext,
PMOS_COMMAND_BUFFER pCmdBuffer);
MOS_STATUS (* pfnWaitAndReleaseCmdBuffer)(
struct _MOS_OS_CONTEXT *pOsContext,
int32_t index);
uint32_t (* GetDmaBufID ) (
struct _MOS_OS_CONTEXT *pOsContext);
void (* SetDmaBufID ) (
struct _MOS_OS_CONTEXT *pOsContext,
uint32_t dwDmaBufID);
void (* SetPerfHybridKernelID ) (
struct _MOS_OS_CONTEXT *pOsContext,
uint32_t KernelID);
uint32_t (* pfnGetGpuCtxBufferTag)(
PMOS_CONTEXT pOsContext,
MOS_GPU_CONTEXT GpuContext);
void (* pfnIncGpuCtxBufferTag)(
PMOS_CONTEXT pOsContext,
MOS_GPU_CONTEXT GpuContext);
uint32_t (* GetGPUTag)(
PMOS_INTERFACE pOsInterface,
MOS_GPU_CONTEXT GpuContext);
GMM_CLIENT_CONTEXT* (* GetGmmClientContext)(
PMOS_CONTEXT pOsContext);
MosOcaInterface* (*GetOcaInterface)();
};
//!
//! \brief Structure to VDBOX Workload Type
//!
typedef struct _VDBOX_WORKLOAD
{
uint32_t uiVDBoxCount[2]; // VDBox workloads
uint32_t uiRingIndex; // ping-pong when vdbox1 count equals vdbox2 count
}VDBOX_WORKLOAD, *PVDBOX_WORKLOAD;
//!
//! \brief Structure to Android Resource Type
//!
//!
//! \brief Structure to Android Resource structure
//!
typedef struct _MOS_OS_ALLOCATION
{
PMOS_RESOURCE pOsResource; //!< Resource Info
int32_t bWriteMode; //!< Read/Write Mode
} MOS_OS_ALLOCATION, *PMOS_OS_ALLOCATION;
//!
//! \brief Structure to Buffer structure
//!
typedef struct _MOS_SPECIFIC_BUFFER
{
uint32_t dwHandle; //!< Buffer Handle
int32_t iAllocationIndex; //!< Allocation Index
} MOS_SPECIFIC_BUFFER_ANDROID, *PMOS_SPECIFIC_BUFFER;
#ifdef __cplusplus
extern "C" {
#endif
//!
//! \brief Check if OS resource is nullptr
//! \details Check if OS resource is nullptr
//! \param PMOS_RESOURCE pOsResource
//! [in] Pointer to OS Resource
//! \return int32_t
//! Return true if nullptr, otherwise false
//!
int32_t Mos_ResourceIsNull(
PMOS_RESOURCE pOsResource);
//!
//! \brief Get Buffer Type
//! \details Returns the type of buffer, 1D, 2D or volume
//! \param PMOS_RESOURCE pOsResource
//! [in] Pointer to OS Resource
//! \return GFX resource Type
//!
MOS_GFXRES_TYPE GetResType(
PMOS_RESOURCE pOsResource);
//!
//! \brief OS reset resource
//! \details Resets the OS resource
//! \param PMOS_RESOURCE pOsResource
//! [in] Pointer to OS Resource
//! \return void
//! Return NONE
//!
void Mos_ResetResource(
PMOS_RESOURCE pOsResource);
//!
//! \brief Convert to MOS tile type
//! \details Convert from Linux to MOS tile type
//! \param uint32_t type
//! [in] tile type
//! \return MOS_TILE_TYPE
//! Return MOS tile type
//!
MOS_TILE_TYPE LinuxToMosTileType(
uint32_t type);
//!
//! \brief Linux OS initilization
//! \details Linux OS initilization
//! \param PMOS_INTERFACE pOsInterface
//! [in] Pointer to OS Interface
//! \param PMOS_CONTEXT pOsDriverContext
//! [in] Pointer to OS Driver context
//! \return MOS_STATUS
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed
//!
MOS_STATUS Mos_Specific_InitInterface(
PMOS_INTERFACE pOsInterface,
PMOS_CONTEXT pOsDriverContext);
//!
//! \brief Lock resource
//! \details Lock allocated resource
//! \param PMOS_INTERFACE pOsInterface
//! [in] Pointer to OS interface structure
//! \param PMOS_RESOURCE pOsResource
//! [in] Pointer to input OS resource
//! \param PMOS_LOCK_PARAMS pLockFlags
//! [in] Lock Flags - MOS_LOCKFLAG_* flags
//! \return void *
//!
void *Mos_Specific_LockResource(
PMOS_INTERFACE pOsInterface,
PMOS_RESOURCE pOsResource,
PMOS_LOCK_PARAMS pLockFlags);
//!
//! \brief Destroys OS specific allocations
//! \details Destroys OS specific allocations including destroying OS context
//! \param PMOS_INTERFACE pOsInterface
//! [in] Pointer to OS Interface
//! \param int32_t bDestroyVscVppDeviceTag
//! [in] Destroy VscVppDeviceTagId Flag, no use in Linux
//! \return void
//!
void Mos_Specific_Destroy(
PMOS_INTERFACE pOsInterface,
int32_t bDestroyVscVppDeviceTag);
//!
//! \brief Resets OS States
//! \details Resets OS States for linux
//! \param PMOS_INTERFACE pOsInterface
//! [in] Pointer to OS Interface
//! \return void
//!
void Mos_Specific_ResetOsStates(
PMOS_INTERFACE pOsInterface);
//!
//! \brief Resizes the buffer to be used for rendering GPU commands
//! \details Resizes the buffer to be used for rendering GPU commands
//! \param PMOS_INTERFACE pOsInterface
//! [in] OS Interface
//! \param uint32_t dwRequestedCommandBufferSize
//! [in] Requested command buffer size
//! \param uint32_t dwRequestedPatchListSize
//! [in] Requested patch list size
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if succeeded, otherwise error code
//!
MOS_STATUS Mos_Specific_ResizeCommandBufferAndPatchList(
PMOS_INTERFACE pOsInterface,
uint32_t dwRequestedCommandBufferSize,
uint32_t dwRequestedPatchListSize,
uint32_t dwFlags);
//!
//! \brief Unlock resource
//! \details Unlock the locked resource
//! \param PMOS_INTERFACE pOsInterface
//! [in] Pointer to OS interface structure
//! \param PMOS_RESOURCE pOsResource
//! [in] Pointer to input OS resource
//! \return MOS_STATUS
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed
//!
MOS_STATUS Mos_Specific_UnlockResource(
PMOS_INTERFACE pOsInterface,
PMOS_RESOURCE pOsResource);
//!
//! \brief Get Resource Information
//! \details Linux get resource info
//! \param PMOS_INTERFACE pOsInterface
//! [in] Pointer to OS interface structure
//! \param PMOS_RESOURCE pOsResource
//! [in] Pointer to input OS resource
//! \param PMOS_SURFACE pResDetails
//! [out] Pointer to output resource information details
//! \return MOS_STATUS
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed
//!
MOS_STATUS Mos_Specific_GetResourceInfo(
PMOS_INTERFACE pOsInterface,
PMOS_RESOURCE pOsResource,
PMOS_SURFACE pResDetails);
//!
//! \brief Get resource index
//! \details Get resource index of MOS_RESOURCE
//! \param PMOS_RESOURCE osResource
//! [in] Pointer to OS resource
//! \return uint32_t
//! Resource index
//!
uint32_t Mos_Specific_GetResourceIndex(
PMOS_RESOURCE osResource);
uint32_t Mos_Specific_GetResourcePitch(
PMOS_RESOURCE pOsResource);
void Mos_Specific_SetResourceWidth(
PMOS_RESOURCE pOsResource,
uint32_t dwWidth);
void Mos_Specific_SetResourceFormat(
PMOS_RESOURCE pOsResource,
MOS_FORMAT mosFormat);
//!
//! \brief Get SetMarker enabled flag
//! \details Get SetMarker enabled flag from OsInterface
//! \param PMOS_INTERFACE pOsInterface
//! [in] OS Interface
//! \return bool
//! SetMarker enabled flag
//!
bool Mos_Specific_IsSetMarkerEnabled(
PMOS_INTERFACE pOsInterface);
//!
//! \brief Get SetMarker resource address
//! \details Get SetMarker resource address from OsInterface
//! \param PMOS_INTERFACE pOsInterface
//! [in] OS Interface
//! \return PMOS_RESOURCE
//! SetMarker resource address
//!
PMOS_RESOURCE Mos_Specific_GetMarkerResource(
PMOS_INTERFACE pOsInterface);
//!
//! \brief Get TimeStamp frequency base
//! \details Get TimeStamp frequency base from OsInterface
//! \param PMOS_INTERFACE pOsInterface
//! [in] OS Interface
//! \return uint32_t
//! time stamp frequency base
//!
uint32_t Mos_Specific_GetTsFrequency(
PMOS_INTERFACE pOsInterface);
//!
//! \brief Checks whether the requested resource is releasable
//! \param PMOS_INTERFACE pOsInterface
//! [in] OS Interface
//! \param PMOS_RESOURCE pOsResource
//! [in] Pointer to OS Resource
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if requested can be released, otherwise MOS_STATUS_UNKNOWN
//!
MOS_STATUS Mos_Specific_IsResourceReleasable(
PMOS_INTERFACE pOsInterface,
PMOS_RESOURCE pOsResource);
#if (_DEBUG || _RELEASE_INTERNAL)
MOS_LINUX_BO * Mos_GetNopCommandBuffer_Linux(
PMOS_INTERFACE pOsInterface);
MOS_LINUX_BO * Mos_GetBadCommandBuffer_Linux(
PMOS_INTERFACE pOsInterface);
#endif
#ifdef __cplusplus
}
#endif
#endif // __MOS_OS_SPECIFIC_H__
|