| 1 |
/* |
| 2 |
* Copyright (c) 2021-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 |
|
| 24 |
//! \file media_libva_common_next.h |
| 25 |
//! \brief libva common next head file |
| 26 |
//! |
| 27 |
|
| 28 |
#ifndef __MEDIA_LIBVA_COMMON_NEXT_H__ |
| 29 |
#define __MEDIA_LIBVA_COMMON_NEXT_H__ |
| 30 |
|
| 31 |
#include <va/va.h> |
| 32 |
#include <va/va_backend.h> |
| 33 |
#include <semaphore.h> |
| 34 |
#include "GmmLib.h" |
| 35 |
#include "mos_bufmgr_api.h" |
| 36 |
#include "mos_defs_specific.h" |
| 37 |
|
| 38 |
#define DDI_MEDIA_MAX_SURFACE_NUMBER_CONTEXT 127 |
| 39 |
#define DDI_MEDIA_MAX_INSTANCE_NUMBER 0x0FFFFFFF |
| 40 |
|
| 41 |
#define DDI_MEDIA_VACONTEXTID_OFFSET_DECODER 0x10000000 |
| 42 |
#define DDI_MEDIA_VACONTEXTID_OFFSET_ENCODER 0x20000000 |
| 43 |
#define DDI_MEDIA_VACONTEXTID_OFFSET_PROT 0x30000000 |
| 44 |
#define DDI_MEDIA_VACONTEXTID_OFFSET_VP 0x40000000 |
| 45 |
#define DDI_MEDIA_VACONTEXTID_BASE 0x90000000 |
| 46 |
#define DDI_MEDIA_MASK_VACONTEXT_TYPE 0xF0000000 |
| 47 |
|
| 48 |
#define DDI_MEDIA_SOFTLET_VACONTEXTID_DECODER_OFFSET (DDI_MEDIA_VACONTEXTID_BASE + DDI_MEDIA_VACONTEXTID_OFFSET_DECODER) |
| 49 |
#define DDI_MEDIA_SOFTLET_VACONTEXTID_ENCODER_OFFSET (DDI_MEDIA_VACONTEXTID_BASE + DDI_MEDIA_VACONTEXTID_OFFSET_ENCODER) |
| 50 |
#define DDI_MEDIA_SOFTLET_VACONTEXTID_CP_OFFSET (DDI_MEDIA_VACONTEXTID_BASE + DDI_MEDIA_VACONTEXTID_OFFSET_PROT) |
| 51 |
#define DDI_MEDIA_SOFTLET_VACONTEXTID_VP_OFFSET (DDI_MEDIA_VACONTEXTID_BASE + DDI_MEDIA_VACONTEXTID_OFFSET_VP) |
| 52 |
|
| 53 |
#define DDI_MEDIA_MASK_VACONTEXTID 0x0FFFFFFF |
| 54 |
|
| 55 |
#define DDI_MEDIA_CONTEXT_TYPE_DECODER 1 |
| 56 |
#define DDI_MEDIA_CONTEXT_TYPE_ENCODER 2 |
| 57 |
#define DDI_MEDIA_CONTEXT_TYPE_VP 3 |
| 58 |
#define DDI_MEDIA_CONTEXT_TYPE_MEDIA 4 |
| 59 |
#define DDI_MEDIA_CONTEXT_TYPE_CM 5 |
| 60 |
#define DDI_MEDIA_CONTEXT_TYPE_PROTECTED 6 |
| 61 |
#define DDI_MEDIA_CONTEXT_TYPE_MFE 7 |
| 62 |
#define DDI_MEDIA_CONTEXT_TYPE_NONE 0 |
| 63 |
#define DDI_MEDIA_INVALID_VACONTEXTID 0 |
| 64 |
|
| 65 |
#define DDI_MEDIA_MAX_COLOR_PLANES 4 //Maximum color planes supported by media driver, like (A/R/G/B in different planes) |
| 66 |
|
| 67 |
#define DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE 0 // Dec config_id starts at this value |
| 68 |
#define DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_MAX 1023 |
| 69 |
#define DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE 1024 // Enc config_id starts at this value |
| 70 |
#define DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_MAX 2047 |
| 71 |
#define DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE 2048 // VP config_id starts at this value |
| 72 |
#define DDI_VP_GEN_CONFIG_ATTRIBUTES_MAX 4091 |
| 73 |
#define DDI_CP_GEN_CONFIG_ATTRIBUTES_BASE 4092 // CP config_id starts at this value |
| 74 |
|
| 75 |
//codec specific defination |
| 76 |
#define DDI_CODEC_LEFT_SHIFT_FOR_REFLIST1 16 |
| 77 |
#define DDI_CODEC_GEN_MAX_SURFACE_ATTRIBUTES 40 |
| 78 |
|
| 79 |
#define DDI_CODEC_VDENC_MAX_L0_REF_FRAMES_LDB 3 |
| 80 |
#define DDI_CODEC_VDENC_MAX_L1_REF_FRAMES_LDB 3 |
| 81 |
#define DDI_CODEC_VDENC_MAX_L0_REF_FRAMES 3 |
| 82 |
#define DDI_CODEC_VDENC_MAX_L1_REF_FRAMES 0 |
| 83 |
#define DDI_CODEC_VDENC_MAX_L1_REF_FRAMES_RAB_AVC 1 |
| 84 |
|
| 85 |
#define DDI_CODEC_FEI_MAX_NUM_MVPREDICTOR 4 |
| 86 |
typedef pthread_mutex_t MEDIA_MUTEX_T, *PMEDIA_MUTEX_T; |
| 87 |
#define MEDIA_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER |
| 88 |
typedef sem_t MEDIA_SEM_T, *PMEDIA_SEM_T; |
| 89 |
|
| 90 |
typedef enum _DDI_MEDIA_FORMAT |
| 91 |
{ |
| 92 |
Media_Format_NV12 , |
| 93 |
Media_Format_NV21 , |
| 94 |
Media_Format_Buffer , |
| 95 |
Media_Format_2DBuffer , |
| 96 |
Media_Format_Perf_Buffer , |
| 97 |
Media_Format_X8R8G8B8 , |
| 98 |
Media_Format_A8R8G8B8 , |
| 99 |
Media_Format_X8B8G8R8 , |
| 100 |
Media_Format_A8B8G8R8 , |
| 101 |
Media_Format_R8G8B8A8 , |
| 102 |
Media_Format_R5G6B5 , |
| 103 |
Media_Format_R10G10B10A2 , |
| 104 |
Media_Format_B10G10R10A2 , |
| 105 |
Media_Format_R10G10B10X2 , |
| 106 |
Media_Format_B10G10R10X2 , |
| 107 |
Media_Format_CPU , |
| 108 |
|
| 109 |
Media_Format_YUY2 , |
| 110 |
Media_Format_UYVY , |
| 111 |
Media_Format_YV12 , |
| 112 |
Media_Format_IYUV , |
| 113 |
Media_Format_I420 , |
| 114 |
|
| 115 |
Media_Format_422H , |
| 116 |
Media_Format_444P , |
| 117 |
Media_Format_411P , |
| 118 |
Media_Format_400P , |
| 119 |
Media_Format_422V , |
| 120 |
Media_Format_IMC3 , |
| 121 |
|
| 122 |
Media_Format_P010 , |
| 123 |
Media_Format_R8G8B8 , |
| 124 |
Media_Format_RGBP , |
| 125 |
Media_Format_BGRP , |
| 126 |
|
| 127 |
Media_Format_P016 , |
| 128 |
Media_Format_Y210 , |
| 129 |
Media_Format_Y216 , |
| 130 |
Media_Format_AYUV , |
| 131 |
#if VA_CHECK_VERSION(1, 13, 0) |
| 132 |
Media_Format_XYUV , |
| 133 |
#endif |
| 134 |
Media_Format_Y410 , |
| 135 |
Media_Format_Y416 , |
| 136 |
Media_Format_Y8 , |
| 137 |
Media_Format_Y16S , |
| 138 |
Media_Format_Y16U , |
| 139 |
Media_Format_VYUY , |
| 140 |
Media_Format_YVYU , |
| 141 |
Media_Format_A16R16G16B16, |
| 142 |
Media_Format_A16B16G16R16, |
| 143 |
Media_Format_P012 , |
| 144 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 145 |
Media_Format_Y212 , |
| 146 |
Media_Format_Y412 , |
| 147 |
#endif |
| 148 |
Media_Format_Count |
| 149 |
} DDI_MEDIA_FORMAT; |
| 150 |
|
| 151 |
typedef enum _DDI_MEDIA_STATUS_REPORT_QUERY_STATE |
| 152 |
{ |
| 153 |
DDI_MEDIA_STATUS_REPORT_QUERY_STATE_INIT, |
| 154 |
DDI_MEDIA_STATUS_REPORT_QUERY_STATE_PENDING, |
| 155 |
DDI_MEDIA_STATUS_REPORT_QUERY_STATE_COMPLETED, |
| 156 |
DDI_MEDIA_STATUS_REPORT_QUERY_STATE_RELEASED |
| 157 |
} DDI_MEDIA_STATUS_REPORT_QUERY_STATE; |
| 158 |
|
| 159 |
//! |
| 160 |
//! \brief Surface descriptor for external DRM buffer |
| 161 |
//! |
| 162 |
typedef struct _DDI_MEDIA_SURFACE_DESCRIPTOR |
| 163 |
{ |
| 164 |
uint32_t uiPlanes; // brief number of planes for planar layout |
| 165 |
uint32_t uiPitches[DDI_MEDIA_MAX_COLOR_PLANES]; // pitch for each plane in bytes |
| 166 |
uint32_t uiOffsets[DDI_MEDIA_MAX_COLOR_PLANES]; // offset for each plane in bytes |
| 167 |
uintptr_t ulBuffer; // buffer handle or user pointer |
| 168 |
uint32_t uiSize; // buffer size |
| 169 |
uint32_t uiFlags; // See "Surface external buffer descriptor flags" |
| 170 |
uint32_t uiVaMemType; // VA Mem type |
| 171 |
uint32_t uiTile; // Used for user pointer |
| 172 |
uint32_t uiBuffserSize; // Used for user pointer |
| 173 |
bool bIsGralloc; // buffer allocated by Gralloc |
| 174 |
void *pPrivateData; // brief reserved for passing private data |
| 175 |
GMM_RESCREATE_PARAMS GmmParam; // GMM Params for Gralloc buffer |
| 176 |
uint64_t modifier; // used for VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 or VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_3 |
| 177 |
} DDI_MEDIA_SURFACE_DESCRIPTOR,*PDDI_MEDIA_SURFACE_DESCRIPTOR; |
| 178 |
|
| 179 |
typedef union _DDI_MEDIA_SURFACE_STATUS_REPORT |
| 180 |
{ |
| 181 |
//! |
| 182 |
//! \struct _DDI_MEDIA_SURFACE_DECODE_STATUS |
| 183 |
//! \brief Ddi media surface decode status |
| 184 |
//! |
| 185 |
struct _DDI_MEDIA_SURFACE_DECODE_STATUS |
| 186 |
{ |
| 187 |
uint32_t status; // indicate latest decode status for current surface, refer to CODECHAL_STATUS in CodechalDecodeStatusReport. |
| 188 |
uint32_t errMbNum; // indicate number of MB s with decode error, refer to NumMbsAffected in CodechalDecodeStatusReport |
| 189 |
uint32_t crcValue; // indicate the CRC value of the decoded data |
| 190 |
} decode; |
| 191 |
//! |
| 192 |
//! \struct _DDI_MEDIA_SURFACE_CENC_STATUS |
| 193 |
//! \brief Ddi media surface cenc status |
| 194 |
//! |
| 195 |
struct _DDI_MEDIA_SURFACE_CENC_STATUS |
| 196 |
{ |
| 197 |
uint32_t status; // indicate latest cenc status for current surface, refer to CODECHAL_STATUS in CodechalDecodeStatusReport. |
| 198 |
uint32_t reserved; // reserved |
| 199 |
} cenc; |
| 200 |
//! |
| 201 |
//! \struct _DDI_MEDIA_SURFACE_VPP_STATUS |
| 202 |
//! \brief Ddi media surface vpp status |
| 203 |
//! |
| 204 |
struct _DDI_MEDIA_SURFACE_VPP_STATUS |
| 205 |
{ |
| 206 |
uint32_t status; // indicate latest vpp status for current surface. |
| 207 |
uint32_t reserved; // reserved. |
| 208 |
} vpp; |
| 209 |
} DDI_MEDIA_SURFACE_STATUS_REPORT, *PDDI_MEDIA_SURFACE_STATUS_REPORT; |
| 210 |
//! |
| 211 |
//! \struct DDI_MEDIA_CONTEXT |
| 212 |
//! \brief Ddi media context |
| 213 |
//! |
| 214 |
struct DDI_MEDIA_CONTEXT; |
| 215 |
typedef struct DDI_MEDIA_CONTEXT *PDDI_MEDIA_CONTEXT; |
| 216 |
|
| 217 |
struct _DDI_MEDIA_BUFFER; |
| 218 |
typedef struct _DDI_MEDIA_SURFACE |
| 219 |
{ |
| 220 |
// for hwcomposer, remove this after we have a solution |
| 221 |
uint32_t base; |
| 222 |
int32_t iWidth; |
| 223 |
int32_t iHeight; // allocate height after alignment |
| 224 |
int32_t iRealHeight; // real height before alignment |
| 225 |
int32_t iPitch; |
| 226 |
uint32_t uiOffset; |
| 227 |
DDI_MEDIA_FORMAT format; |
| 228 |
uint32_t uiLockedBufID; |
| 229 |
uint32_t uiLockedImageID; |
| 230 |
int32_t iRefCount; |
| 231 |
uint8_t *pData; |
| 232 |
uint32_t data_size; |
| 233 |
uint32_t isTiled; |
| 234 |
uint32_t TileType; |
| 235 |
uint32_t bMapped; |
| 236 |
MOS_LINUX_BO *bo; |
| 237 |
uint32_t name; |
| 238 |
uint32_t surfaceUsageHint; |
| 239 |
PDDI_MEDIA_SURFACE_DESCRIPTOR pSurfDesc; // nullptr means surface was allocated by media driver |
| 240 |
// !nullptr means surface was allocated by Application |
| 241 |
GMM_RESOURCE_INFO *pGmmResourceInfo; // GMM resource descriptor |
| 242 |
uint32_t frame_idx; |
| 243 |
void *pDecCtx; |
| 244 |
void *pVpCtx; |
| 245 |
|
| 246 |
uint32_t curCtxType; // indicate current surface is using in which context type. |
| 247 |
DDI_MEDIA_STATUS_REPORT_QUERY_STATE curStatusReportQueryState; // indicate status report is queried or not. |
| 248 |
DDI_MEDIA_SURFACE_STATUS_REPORT curStatusReport; // union for both decode and vpp status. |
| 249 |
|
| 250 |
PDDI_MEDIA_CONTEXT pMediaCtx; // Media driver Context |
| 251 |
PMEDIA_SEM_T pCurrentFrameSemaphore; // to sync render target for hybrid decoding multi-threading mode |
| 252 |
PMEDIA_SEM_T pReferenceFrameSemaphore; // to sync reference frame surface. when this semaphore is posted, the surface is not used as reference frame, and safe to be destroied |
| 253 |
|
| 254 |
uint8_t *pSystemShadow; // Shadow surface in system memory |
| 255 |
_DDI_MEDIA_BUFFER *pShadowBuffer; |
| 256 |
|
| 257 |
uint32_t uiMapFlag; |
| 258 |
|
| 259 |
uint32_t uiVariantFlag; |
| 260 |
int memType; |
| 261 |
} DDI_MEDIA_SURFACE, *PDDI_MEDIA_SURFACE; |
| 262 |
|
| 263 |
typedef struct _DDI_MEDIA_BUFFER |
| 264 |
{ |
| 265 |
uint32_t iSize = 0; |
| 266 |
uint32_t uiWidth = 0; |
| 267 |
uint32_t uiHeight = 0; |
| 268 |
uint32_t uiPitch = 0; |
| 269 |
uint32_t uiNumElements = 0; |
| 270 |
uint32_t uiOffset = 0; |
| 271 |
// vaBuffer type |
| 272 |
uint32_t uiType = 0; |
| 273 |
DDI_MEDIA_FORMAT format = Media_Format_Count; |
| 274 |
uint32_t uiLockedBufID = 0; |
| 275 |
uint32_t uiLockedImageID = 0; |
| 276 |
int32_t iRefCount = 0; |
| 277 |
uint32_t TileType = 0; |
| 278 |
uint8_t *pData = nullptr; |
| 279 |
uint32_t bMapped = 0; |
| 280 |
MOS_LINUX_BO *bo = nullptr; |
| 281 |
uint32_t name = 0; |
| 282 |
uint32_t uiMemtype = 0; |
| 283 |
uint32_t uiExportcount = 0; |
| 284 |
uintptr_t handle = 0; |
| 285 |
bool bPostponedBufFree = false; |
| 286 |
|
| 287 |
bool bCFlushReq = false; // No LLC between CPU & GPU, requries to call CPU Flush for CPU mapped buffer |
| 288 |
bool bUseSysGfxMem = false; |
| 289 |
PDDI_MEDIA_SURFACE pSurface = nullptr; |
| 290 |
GMM_RESOURCE_INFO *pGmmResourceInfo = nullptr; // GMM resource descriptor |
| 291 |
PDDI_MEDIA_CONTEXT pMediaCtx = nullptr; // Media driver Context |
| 292 |
} DDI_MEDIA_BUFFER, *PDDI_MEDIA_BUFFER; |
| 293 |
|
| 294 |
typedef struct _DDI_MEDIA_SURFACE_HEAP_ELEMENT |
| 295 |
{ |
| 296 |
PDDI_MEDIA_SURFACE pSurface; |
| 297 |
uint32_t uiVaSurfaceID; |
| 298 |
struct _DDI_MEDIA_SURFACE_HEAP_ELEMENT *pNextFree; |
| 299 |
}DDI_MEDIA_SURFACE_HEAP_ELEMENT, *PDDI_MEDIA_SURFACE_HEAP_ELEMENT; |
| 300 |
|
| 301 |
typedef struct _DDI_MEDIA_BUFFER_HEAP_ELEMENT |
| 302 |
{ |
| 303 |
PDDI_MEDIA_BUFFER pBuffer; |
| 304 |
void *pCtx; |
| 305 |
uint32_t uiCtxType; |
| 306 |
uint32_t uiVaBufferID; |
| 307 |
struct _DDI_MEDIA_BUFFER_HEAP_ELEMENT *pNextFree; |
| 308 |
}DDI_MEDIA_BUFFER_HEAP_ELEMENT, *PDDI_MEDIA_BUFFER_HEAP_ELEMENT; |
| 309 |
|
| 310 |
typedef struct _DDI_MEDIA_IMAGE_HEAP_ELEMENT |
| 311 |
{ |
| 312 |
VAImage *pImage; |
| 313 |
uint32_t uiVaImageID; |
| 314 |
struct _DDI_MEDIA_IMAGE_HEAP_ELEMENT *pNextFree; |
| 315 |
}DDI_MEDIA_IMAGE_HEAP_ELEMENT, *PDDI_MEDIA_IMAGE_HEAP_ELEMENT; |
| 316 |
|
| 317 |
typedef struct _DDI_MEDIA_VACONTEXT_HEAP_ELEMENT |
| 318 |
{ |
| 319 |
void *pVaContext; |
| 320 |
uint32_t uiVaContextID; |
| 321 |
struct _DDI_MEDIA_VACONTEXT_HEAP_ELEMENT *pNextFree; |
| 322 |
}DDI_MEDIA_VACONTEXT_HEAP_ELEMENT, *PDDI_MEDIA_VACONTEXT_HEAP_ELEMENT; |
| 323 |
|
| 324 |
typedef struct _DDI_MEDIA_HEAP |
| 325 |
{ |
| 326 |
void *pHeapBase; |
| 327 |
uint32_t uiHeapElementSize; |
| 328 |
uint32_t uiAllocatedHeapElements; |
| 329 |
void *pFirstFreeHeapElement; |
| 330 |
}DDI_MEDIA_HEAP, *PDDI_MEDIA_HEAP; |
| 331 |
|
| 332 |
#ifndef ANDROID |
| 333 |
typedef struct _DDI_X11_FUNC_TABLE |
| 334 |
{ |
| 335 |
HMODULE pX11LibHandle; // handle to dlopen libX11 |
| 336 |
|
| 337 |
// 5 functions from libX11 used by vpgPutSurface (Linux) so far |
| 338 |
void *pfnDefaultVisual; |
| 339 |
void *pfnXCreateGC; |
| 340 |
void *pfnXFreeGC; |
| 341 |
void *pfnXCreateImage; |
| 342 |
void *pfnXDestroyImage; |
| 343 |
void *pfnXPutImage; |
| 344 |
}DDI_X11_FUNC_TABLE, *PDDI_X11_FUNC_TABLE; |
| 345 |
#endif |
| 346 |
|
| 347 |
#include "media_libva_common.h" |
| 348 |
|
| 349 |
static __inline PDDI_MEDIA_CONTEXT GetMediaContext (VADriverContextP ctx) |
| 350 |
{ |
| 351 |
return (PDDI_MEDIA_CONTEXT)ctx->pDriverData; |
| 352 |
} |
| 353 |
|
| 354 |
#ifndef CONTEXT_PRIORITY_MAX |
| 355 |
#define CONTEXT_PRIORITY_MAX 1024 |
| 356 |
#endif |
| 357 |
|
| 358 |
class MediaLibvaCommonNext |
| 359 |
{ |
| 360 |
public: |
| 361 |
//! |
| 362 |
//! \brief Get surface from VA surface ID |
| 363 |
//! |
| 364 |
//! \param [in] mediaCtx |
| 365 |
//! Pointer to ddi media context |
| 366 |
//! \param [in] surfaceID |
| 367 |
//! VA surface ID |
| 368 |
//! |
| 369 |
//! \return DDI_MEDIA_SURFACE* |
| 370 |
//! Pointer to ddi media surface |
| 371 |
//! |
| 372 |
static DDI_MEDIA_SURFACE *GetSurfaceFromVASurfaceID(PDDI_MEDIA_CONTEXT mediaCtx, VASurfaceID surfaceID); |
| 373 |
|
| 374 |
//! |
| 375 |
//! \brief Get VA surface ID from surface |
| 376 |
//! |
| 377 |
//! \param [in] surface |
| 378 |
//! surface |
| 379 |
//! |
| 380 |
//! \return VASurfaceID |
| 381 |
//! VA Surface ID |
| 382 |
//! |
| 383 |
static VASurfaceID GetVASurfaceIDFromSurface(PDDI_MEDIA_SURFACE surface); |
| 384 |
|
| 385 |
//! |
| 386 |
//! \brief Replace the surface with given format |
| 387 |
//! |
| 388 |
//! \param [in] surface |
| 389 |
//! Pointer to the old surface |
| 390 |
//! \param [in] expectedFormat |
| 391 |
//! VA surface ID |
| 392 |
//! |
| 393 |
//! \return DDI_MEDIA_SURFACE* |
| 394 |
//! Pointer to new ddi media surface |
| 395 |
//! |
| 396 |
static PDDI_MEDIA_SURFACE ReplaceSurfaceWithNewFormat(PDDI_MEDIA_SURFACE surface, DDI_MEDIA_FORMAT expectedFormat); |
| 397 |
|
| 398 |
//! |
| 399 |
//! \brief replace the surface with correlation variant format |
| 400 |
//! |
| 401 |
//! \param [in] surface |
| 402 |
//! Pointer to the old surface |
| 403 |
//! |
| 404 |
//! \return DDI_MEDIA_SURFACE* |
| 405 |
//! Pointer to new ddi media surface |
| 406 |
//! |
| 407 |
static PDDI_MEDIA_SURFACE ReplaceSurfaceWithVariant(PDDI_MEDIA_SURFACE surface, VAEntrypoint entrypoint); |
| 408 |
|
| 409 |
//! |
| 410 |
//! \brief Get buffer from VA buffer ID |
| 411 |
//! |
| 412 |
//! \param [in] mediaCtx |
| 413 |
//! Pointer to ddi media context |
| 414 |
//! \param [in] bufferID |
| 415 |
//! VA buffer ID |
| 416 |
//! |
| 417 |
//! \return DDI_MEDIA_BUFFER* |
| 418 |
//! Pointer to ddi media buffer |
| 419 |
//! |
| 420 |
static DDI_MEDIA_BUFFER* GetBufferFromVABufferID( |
| 421 |
PDDI_MEDIA_CONTEXT mediaCtx, |
| 422 |
VABufferID bufferID); |
| 423 |
|
| 424 |
//! |
| 425 |
//! \brief Media buffer to mos resource |
| 426 |
//! |
| 427 |
//! \param [in] mediaBuffer |
| 428 |
//! Ddi media buffer |
| 429 |
//! \param [in] mhalOsResource |
| 430 |
//! Mos resource |
| 431 |
//! |
| 432 |
static void MediaBufferToMosResource(DDI_MEDIA_BUFFER *mediaBuffer, MOS_RESOURCE *mhalOsResource); |
| 433 |
|
| 434 |
//! |
| 435 |
//! \brief Media surface to mos resource |
| 436 |
//! |
| 437 |
//! \param [in] mediaSurface |
| 438 |
//! Ddi media surface |
| 439 |
//! \param [in] mhalOsResource |
| 440 |
//! Mos resource |
| 441 |
//! |
| 442 |
static void MediaSurfaceToMosResource(DDI_MEDIA_SURFACE *mediaSurface, MOS_RESOURCE *mhalOsResource); |
| 443 |
|
| 444 |
//! |
| 445 |
//! \brief Get PVA context from heap |
| 446 |
//! |
| 447 |
//! \param [in] mediaHeap |
| 448 |
//! Pointer to ddi media heap |
| 449 |
//! \param [in] index |
| 450 |
//! the index |
| 451 |
//! \param [in] mutex |
| 452 |
//! the mutex |
| 453 |
//! |
| 454 |
static void* GetVaContextFromHeap(PDDI_MEDIA_HEAP mediaHeap, uint32_t index, PMOS_MUTEX mutex); |
| 455 |
|
| 456 |
//! |
| 457 |
//! \brief Get context from context ID |
| 458 |
//! |
| 459 |
//! \param [in] ctx |
| 460 |
//! Pointer to VA driver context |
| 461 |
//! \param [in] vaCtxID |
| 462 |
//! VA context ID |
| 463 |
//! \param [in] ctxType |
| 464 |
//! Ctx type |
| 465 |
//! |
| 466 |
static void* GetContextFromContextID(VADriverContextP ctx, VAContextID vaCtxID, uint32_t *ctxType); |
| 467 |
|
| 468 |
//! |
| 469 |
//! \brief Get ctx type from VA buffer ID |
| 470 |
//! |
| 471 |
//! \param [in] mediaCtx |
| 472 |
//! Pointer to ddi media context |
| 473 |
//! \param [in] bufferID |
| 474 |
//! VA buffer ID |
| 475 |
//! |
| 476 |
//! \return uint32_t |
| 477 |
//1 Context type |
| 478 |
//! |
| 479 |
static uint32_t GetCtxTypeFromVABufferID (PDDI_MEDIA_CONTEXT mediaCtx, VABufferID bufferID); |
| 480 |
|
| 481 |
//! |
| 482 |
//! \brief Get ctx from VA buffer ID |
| 483 |
//! |
| 484 |
//! \param [in] mediaCtx |
| 485 |
//! pddi media context |
| 486 |
//! \param [in] bufferID |
| 487 |
//! VA Buffer ID |
| 488 |
//! |
| 489 |
//! \return void* |
| 490 |
//! Pointer to buffer heap element context |
| 491 |
//! |
| 492 |
static void* GetCtxFromVABufferID (PDDI_MEDIA_CONTEXT mediaCtx, VABufferID bufferID); |
| 493 |
|
| 494 |
//! |
| 495 |
//! \brief Get gpu priority |
| 496 |
//! |
| 497 |
//! \param [in] ctx |
| 498 |
//! Pointer to VA driver context |
| 499 |
//! \param [in] buffers |
| 500 |
//! VA buffer ID |
| 501 |
//! \param [in] numBuffers |
| 502 |
//! Number of buffers |
| 503 |
//! \param [out] updatePriority |
| 504 |
//! Update priority |
| 505 |
//! \param [out] priority |
| 506 |
//! Priority value |
| 507 |
//! \return int32_t |
| 508 |
//! |
| 509 |
static int32_t GetGpuPriority(VADriverContextP ctx, VABufferID *buffers, int32_t numBuffers, bool *updatePriority, int32_t *priority); |
| 510 |
|
| 511 |
//! |
| 512 |
//! \brief Move the priority bufferID to the end of buffers |
| 513 |
//! |
| 514 |
//! \param [in] buffers |
| 515 |
//! VA buffer ID |
| 516 |
//! \param [in] priorityIndexInBuf |
| 517 |
//! the priority VA buffer ID |
| 518 |
//! \param [in] numBuffers |
| 519 |
//! Number of buffers |
| 520 |
//! |
| 521 |
static void MovePriorityBufferIdToEnd (VABufferID *buffers, int32_t priorityIndexInBuf, int32_t numBuffers); |
| 522 |
MEDIA_CLASS_DEFINE_END(MediaLibvaCommonNext) |
| 523 |
}; |
| 524 |
|
| 525 |
#endif //__MEDIA_LIBVA_COMMON_NEXT_H__ |