| 1 |
/* |
| 2 |
* Copyright (c) 2021, 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 media_libva_interface_next.h |
| 24 |
//! \brief libva interface next head file |
| 25 |
//! |
| 26 |
|
| 27 |
#ifndef __MEDIA_LIBVA_INTERFACE_NEXT_H__ |
| 28 |
#define __MEDIA_LIBVA_INTERFACE_NEXT_H__ |
| 29 |
|
| 30 |
#include <va/va.h> |
| 31 |
#include <va/va_backend.h> |
| 32 |
#include <va/va_drmcommon.h> |
| 33 |
#include "media_libva_common_next.h" |
| 34 |
#include "ddi_media_functions.h" |
| 35 |
|
| 36 |
class MediaLibvaInterfaceNext |
| 37 |
{ |
| 38 |
public: |
| 39 |
|
| 40 |
//! |
| 41 |
//! \brief Init component list |
| 42 |
//! |
| 43 |
//! \param [in] mediaCtx |
| 44 |
//! Pointer to ddi media context |
| 45 |
//! |
| 46 |
//! \return VAStatus |
| 47 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 48 |
//! |
| 49 |
static VAStatus InitCompList(PDDI_MEDIA_CONTEXT mediaCtx); |
| 50 |
|
| 51 |
//! |
| 52 |
//! \brief Release component list |
| 53 |
//! |
| 54 |
//! \param [in] mediaCtx |
| 55 |
//! Pointer to ddi media context |
| 56 |
//! |
| 57 |
static void ReleaseCompList(PDDI_MEDIA_CONTEXT mediaCtx); |
| 58 |
|
| 59 |
//! |
| 60 |
//! \brief Initialize |
| 61 |
//! |
| 62 |
//! \param [in] ctx |
| 63 |
//! Pointer to VA driver context |
| 64 |
//! \param [in] devicefd |
| 65 |
//! Devoce fd |
| 66 |
//! \param [out] major_version |
| 67 |
//! Major version |
| 68 |
//! \param [out] minor_version |
| 69 |
//! Minor version |
| 70 |
//! |
| 71 |
//! \return VAStatus |
| 72 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 73 |
//! |
| 74 |
static VAStatus Initialize ( |
| 75 |
VADriverContextP ctx, |
| 76 |
int32_t devicefd, |
| 77 |
int32_t *major_version, /* out */ |
| 78 |
int32_t *minor_version /* out */ |
| 79 |
); |
| 80 |
|
| 81 |
//! |
| 82 |
//! \brief clean up all library internal resources |
| 83 |
//! |
| 84 |
//! \param [in] ctx |
| 85 |
//! Pointer to VA driver context |
| 86 |
//! |
| 87 |
//! \return VAStatus |
| 88 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 89 |
//! |
| 90 |
static VAStatus Terminate(VADriverContextP ctx); |
| 91 |
|
| 92 |
//! |
| 93 |
//! \brief Create context |
| 94 |
//! |
| 95 |
//! \param [in] ctx |
| 96 |
//! Pointer to VA driver context |
| 97 |
//! \param [in] configId |
| 98 |
//! VA config id |
| 99 |
//! \param [in] pictureWidth |
| 100 |
//! Picture width |
| 101 |
//! \param [in] pictureHeight |
| 102 |
//! Picture height |
| 103 |
//! \param [out] flag |
| 104 |
//! Create flag |
| 105 |
//! \param [in] renderTargets |
| 106 |
//! VA render traget |
| 107 |
//! \param [in] renderTargetsNum |
| 108 |
//! Number of render targets |
| 109 |
//! \param [out] context |
| 110 |
//! VA created context |
| 111 |
//! |
| 112 |
//! \return VAStatus |
| 113 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 114 |
//! |
| 115 |
static VAStatus CreateContext ( |
| 116 |
VADriverContextP ctx, |
| 117 |
VAConfigID configId, |
| 118 |
int32_t pictureWidth, |
| 119 |
int32_t pictureHeight, |
| 120 |
int32_t flag, |
| 121 |
VASurfaceID *renderTargets, |
| 122 |
int32_t rendertargetsNum, |
| 123 |
VAContextID *context |
| 124 |
); |
| 125 |
|
| 126 |
//! |
| 127 |
//! \brief Destroy context |
| 128 |
//! |
| 129 |
//! \param [in] ctx |
| 130 |
//! Pointer to VA driver context |
| 131 |
//! \param [in] context |
| 132 |
//! VA context to destroy |
| 133 |
//! |
| 134 |
//! \return VAStatus |
| 135 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 136 |
//! |
| 137 |
static VAStatus DestroyContext ( |
| 138 |
VADriverContextP ctx, |
| 139 |
VAContextID context |
| 140 |
); |
| 141 |
|
| 142 |
//! |
| 143 |
//! \brief Create buffer |
| 144 |
//! |
| 145 |
//! \param [in] ctx |
| 146 |
//! Pointer to VA driver context |
| 147 |
//! \param [in] context |
| 148 |
//! VA context id |
| 149 |
//! \param [in] type |
| 150 |
//! VA buffer type |
| 151 |
//! \param [in] size |
| 152 |
//! Buffer size |
| 153 |
//! \param [out] elementsNum |
| 154 |
//! Number of elements |
| 155 |
//! \param [in] data |
| 156 |
//! Buffer data |
| 157 |
//! \param [out] bufId |
| 158 |
//! VA buffer id |
| 159 |
//! |
| 160 |
//! \return VAStatus |
| 161 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 162 |
//! |
| 163 |
static VAStatus CreateBuffer ( |
| 164 |
VADriverContextP ctx, |
| 165 |
VAContextID context, |
| 166 |
VABufferType type, |
| 167 |
uint32_t size, |
| 168 |
uint32_t elementsNum, |
| 169 |
void *data, |
| 170 |
VABufferID *bufId |
| 171 |
); |
| 172 |
|
| 173 |
//! |
| 174 |
//! \brief Destroy buffer |
| 175 |
//! |
| 176 |
//! \param [in] ctx |
| 177 |
//! Pointer to VA driver context |
| 178 |
//! \param [in] buf_id |
| 179 |
//! VA buffer ID |
| 180 |
//! |
| 181 |
//! \return VAStatus |
| 182 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 183 |
//! |
| 184 |
static VAStatus DestroyBuffer( |
| 185 |
VADriverContextP ctx, |
| 186 |
VABufferID buf_id |
| 187 |
); |
| 188 |
|
| 189 |
//! |
| 190 |
//! \brief Get ready to decode a picture to a target surface |
| 191 |
//! |
| 192 |
//! \param [in] ctx |
| 193 |
//! Pointer to VA driver context |
| 194 |
//! \param [in] context |
| 195 |
//! VA context id |
| 196 |
//! \param [in] renderTarget |
| 197 |
//! VA render target surface |
| 198 |
//! |
| 199 |
//! \return VAStatus |
| 200 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 201 |
//! |
| 202 |
static VAStatus BeginPicture ( |
| 203 |
VADriverContextP ctx, |
| 204 |
VAContextID context, |
| 205 |
VASurfaceID renderTarget |
| 206 |
); |
| 207 |
|
| 208 |
//! |
| 209 |
//! \brief Send decode buffers to the server |
| 210 |
//! \details Buffers are automatically destroyed afterwards |
| 211 |
//! \param [in] ctx |
| 212 |
//! Pointer to VA driver context |
| 213 |
//! \param [in] context |
| 214 |
//! VA buffer id |
| 215 |
//! \param [in] buffer |
| 216 |
//! Pointer to VA buffer id |
| 217 |
//! \param [in] buffersNum |
| 218 |
//! number of buffers |
| 219 |
//! |
| 220 |
//! \return VAStatus |
| 221 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 222 |
//! |
| 223 |
static VAStatus RenderPicture ( |
| 224 |
VADriverContextP ctx, |
| 225 |
VAContextID context, |
| 226 |
VABufferID *buffers, |
| 227 |
int32_t buffersNum |
| 228 |
); |
| 229 |
|
| 230 |
//! |
| 231 |
//! \brief Make the end of rendering for a picture |
| 232 |
//! \details The server should start processing all pending operations for this |
| 233 |
//! surface. This call is non-blocking. The client can start another |
| 234 |
//! Begin/Render/End sequence on a different render target |
| 235 |
//! \param [in] ctx |
| 236 |
//! Pointer to VA driver context |
| 237 |
//! \param [in] context |
| 238 |
//! VA buffer id |
| 239 |
//! |
| 240 |
//! \return VAStatus |
| 241 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 242 |
//! |
| 243 |
static VAStatus EndPicture ( |
| 244 |
VADriverContextP ctx, |
| 245 |
VAContextID context |
| 246 |
); |
| 247 |
|
| 248 |
//! |
| 249 |
//! \brief Query supported entrypoints for a given profile |
| 250 |
//! |
| 251 |
//! \param [in] ctx |
| 252 |
//! Pointer to VA driver context |
| 253 |
//! \param [in] profile |
| 254 |
//! VA profile |
| 255 |
//! \param [in] entrypointList |
| 256 |
//! Pointer to VAEntrypoint array that can hold at least vaMaxNumEntrypoints() entries |
| 257 |
//! \param [out] numEntryPoints |
| 258 |
//! It returns the actual number of supported VAEntrypoints. |
| 259 |
//! |
| 260 |
//! \return VAStatus |
| 261 |
//! VA_STATUS_SUCCESS if success |
| 262 |
//! |
| 263 |
static VAStatus QueryConfigEntrypoints( |
| 264 |
VADriverContextP ctx, |
| 265 |
VAProfile profile, |
| 266 |
VAEntrypoint *entrypointList, |
| 267 |
int32_t *entrypointsNum); |
| 268 |
|
| 269 |
//! |
| 270 |
//! \brief Query supported profiles |
| 271 |
//! |
| 272 |
//! \param [in] ctx |
| 273 |
//! Pointer to VA driver context |
| 274 |
//! \param [in] profileList |
| 275 |
//! Pointer to VAProfile array that can hold at least vaMaxNumProfile() entries |
| 276 |
//! \param [out] numProfiles |
| 277 |
//! Pointer to int32_t. It returns the actual number of supported profiles. |
| 278 |
//! |
| 279 |
//! \return VAStatus |
| 280 |
//! VA_STATUS_SUCCESS if success |
| 281 |
//! |
| 282 |
static VAStatus QueryConfigProfiles( |
| 283 |
VADriverContextP ctx, |
| 284 |
VAProfile *profileList, |
| 285 |
int32_t *profilesNum); |
| 286 |
|
| 287 |
//! |
| 288 |
//! \brief Query all attributes for a given configuration |
| 289 |
//! |
| 290 |
//! \param [in] ctx |
| 291 |
//! Pointer to VA driver context |
| 292 |
//! \param [in] configId |
| 293 |
//! VA configuration |
| 294 |
//! \param [in,out] profile |
| 295 |
//! Pointer to VAProfile of the configuration |
| 296 |
//! \param [in,out] entrypoint |
| 297 |
//! Pointer to VAEntrypoint of the configuration |
| 298 |
//! \param [in,out] attribList |
| 299 |
//! Pointer to VAConfigAttrib array that can hold at least |
| 300 |
//! vaMaxNumConfigAttributes() entries. |
| 301 |
//! \param [in,out] numAttribs |
| 302 |
//! The actual number of VAConfigAttrib returned in the array attribList |
| 303 |
//! |
| 304 |
//! \return VAStatus |
| 305 |
//! VA_STATUS_SUCCESS if success |
| 306 |
//! |
| 307 |
static VAStatus QueryConfigAttributes( |
| 308 |
VADriverContextP ctx, |
| 309 |
VAConfigID configId, |
| 310 |
VAProfile *profile, |
| 311 |
VAEntrypoint *entrypoint, |
| 312 |
VAConfigAttrib *attribList, |
| 313 |
int32_t *numAttribs); |
| 314 |
|
| 315 |
//! |
| 316 |
//! \brief Create a configuration |
| 317 |
//! \details It passes in the attribute list that specifies the attributes it |
| 318 |
//! cares about, with the rest taking default values. |
| 319 |
//! |
| 320 |
//! \param [in] ctx |
| 321 |
//! Pointer to VA driver context |
| 322 |
//! \param [in] profile |
| 323 |
//! VA profile |
| 324 |
//! \param [in] entrypoint |
| 325 |
//! VA entrypoint |
| 326 |
//! \param [in] attribList |
| 327 |
//! Pointer to VAConfigAttrib array that specifies the attributes |
| 328 |
//! \param [in] numAttribs |
| 329 |
//! Number of VAConfigAttrib in the array attribList |
| 330 |
//! \param [out] configId |
| 331 |
//! Pointer to returned VAConfigID if success |
| 332 |
//! |
| 333 |
//! \return VAStatus |
| 334 |
//! VA_STATUS_SUCCESS if success |
| 335 |
//! |
| 336 |
static VAStatus CreateConfig( |
| 337 |
VADriverContextP ctx, |
| 338 |
VAProfile profile, |
| 339 |
VAEntrypoint entrypoint, |
| 340 |
VAConfigAttrib *attribList, |
| 341 |
int32_t numAttribs, |
| 342 |
VAConfigID *configId); |
| 343 |
|
| 344 |
//! |
| 345 |
//! \brief Destory the VAConfigID |
| 346 |
//! |
| 347 |
//! \param [in] ctx |
| 348 |
//! Pointer to VA driver context |
| 349 |
//! \param [in] configId |
| 350 |
//! Specify the VAConfigID |
| 351 |
//! |
| 352 |
//! \return VAStatus |
| 353 |
//! VA_STATUS_SUCCESS if succeed |
| 354 |
//! VA_STATUS_ERROR_INVALID_CONFIG if the conifgId is invalid |
| 355 |
//! |
| 356 |
static VAStatus DestroyConfig( |
| 357 |
VADriverContextP ctx, |
| 358 |
VAConfigID configId); |
| 359 |
|
| 360 |
//! |
| 361 |
//! \brief Get attributes for a given profile/entrypoint pair |
| 362 |
//! \details The caller must provide an "attribList" with all attributes to be |
| 363 |
//! retrieved. Upon return, the attributes in "attribList" have been |
| 364 |
//! updated with their value. Unknown attributes or attributes that are |
| 365 |
//! not supported for the given profile/entrypoint pair will have their |
| 366 |
//! value set to VA_ATTRIB_NOT_SUPPORTED. |
| 367 |
//! |
| 368 |
//! \param [in] ctx |
| 369 |
//! Pointer to VA driver context |
| 370 |
//! \param [in] profile |
| 371 |
//! VA profile |
| 372 |
//! \param [in] entrypoint |
| 373 |
//! VA entrypoint |
| 374 |
//! \param [in,out] attribList |
| 375 |
//! Pointer to VAConfigAttrib array. The attribute type is set by caller and |
| 376 |
//! attribute value is set by this function. |
| 377 |
//! \param [in] numAttribs |
| 378 |
//! Number of VAConfigAttrib in the array attribList |
| 379 |
//! |
| 380 |
//! \return VAStatus |
| 381 |
//! VA_STATUS_SUCCESS if success |
| 382 |
//! |
| 383 |
static VAStatus GetConfigAttributes( |
| 384 |
VADriverContextP ctx, |
| 385 |
VAProfile profile, |
| 386 |
VAEntrypoint entrypoint, |
| 387 |
VAConfigAttrib *attribList, |
| 388 |
int32_t numAttribs); |
| 389 |
|
| 390 |
//! |
| 391 |
//! \brief Get surface attributes for a given config ID |
| 392 |
//! |
| 393 |
//! \param [in] ctx |
| 394 |
//! Pointer to VA driver context |
| 395 |
//! \param [in] configId |
| 396 |
//! VA configuration |
| 397 |
//! \param [in,out] attribList |
| 398 |
//! Pointer to VASurfaceAttrib array. It returns |
| 399 |
//! the supported surface attributes |
| 400 |
//! \param [in,out] numAttribs |
| 401 |
//! The number of elements allocated on input |
| 402 |
//! Return the number of elements actually filled in output |
| 403 |
//! |
| 404 |
//! \return VAStatus |
| 405 |
//! VA_STATUS_SUCCESS if success |
| 406 |
//! VA_STATUS_ERROR_MAX_NUM_EXCEEDED if size of attribList is too small |
| 407 |
//! |
| 408 |
static VAStatus QuerySurfaceAttributes( |
| 409 |
VADriverContextP ctx, |
| 410 |
VAConfigID configId, |
| 411 |
VASurfaceAttrib *attribList, |
| 412 |
uint32_t *numAttribs); |
| 413 |
|
| 414 |
//! |
| 415 |
//! \brief Query the suppported image formats |
| 416 |
//! |
| 417 |
//! \param [in] ctx |
| 418 |
//! Pointer to VA driver context |
| 419 |
//! \param [in,out] formatList |
| 420 |
//! Pointer to a VAImageFormat array. The array size shouldn't be less than vaMaxNumImageFormats |
| 421 |
//! It will return the supported image formats. |
| 422 |
//! \param [in,out] num_formats |
| 423 |
//! Pointer to a integer that will return the real size of formatList. |
| 424 |
//! |
| 425 |
//! \return VAStatus |
| 426 |
//! VA_STATUS_SUCCESS if succeed |
| 427 |
//! |
| 428 |
static VAStatus QueryImageFormats( |
| 429 |
VADriverContextP ctx, |
| 430 |
VAImageFormat *formatList, |
| 431 |
int32_t *numFormats); |
| 432 |
|
| 433 |
//! |
| 434 |
//! \brief Set image palette |
| 435 |
//! |
| 436 |
//! \param [in] ctx |
| 437 |
//! Pointer to VA driver context |
| 438 |
//! \param [in] image |
| 439 |
//! VA image ID |
| 440 |
//! \param [in] palette |
| 441 |
//! Palette |
| 442 |
//! |
| 443 |
//! \return VAStatus |
| 444 |
//! VA_STATUS_ERROR_UNIMPLEMENTED if call success, else fail reason |
| 445 |
//! |
| 446 |
static VAStatus SetImagePalette( |
| 447 |
VADriverContextP ctx, |
| 448 |
VAImageID image, |
| 449 |
unsigned char *palette); |
| 450 |
|
| 451 |
//! |
| 452 |
//! \brief Query subpicture formats |
| 453 |
//! |
| 454 |
//! \param [in] ctx |
| 455 |
//! Pointer to VA driver context |
| 456 |
//! \param [in] formatList |
| 457 |
//! VA image format |
| 458 |
//! \param [in] flags |
| 459 |
//! Flags |
| 460 |
//! \param [in] formatsNum |
| 461 |
//! Number of formats |
| 462 |
//! |
| 463 |
//! \return VAStatus |
| 464 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 465 |
//! |
| 466 |
static VAStatus QuerySubpictureFormats( |
| 467 |
VADriverContextP ctx, |
| 468 |
VAImageFormat *formatList, |
| 469 |
uint32_t *flags, |
| 470 |
uint32_t *formatsNum); |
| 471 |
|
| 472 |
//! |
| 473 |
//! \brief Create subpicture |
| 474 |
//! |
| 475 |
//! \param [in] ctx |
| 476 |
//! Pointer to VA driver context |
| 477 |
//! \param [in] image |
| 478 |
//! VA image ID |
| 479 |
//! \param [out] subpicture |
| 480 |
//! VA subpicture ID |
| 481 |
//! |
| 482 |
//! \return VAStatus |
| 483 |
//! VA_STATUS_ERROR_UNIMPLEMENTED |
| 484 |
//! |
| 485 |
static VAStatus CreateSubpicture( |
| 486 |
VADriverContextP ctx, |
| 487 |
VAImageID image, |
| 488 |
VASubpictureID *subpicture); |
| 489 |
|
| 490 |
//! |
| 491 |
//! \brief Destroy subpicture |
| 492 |
//! |
| 493 |
//! \param [in] ctx |
| 494 |
//! Pointer to VA driver context |
| 495 |
//! \param [in] subpicture |
| 496 |
//! VA subpicture ID |
| 497 |
//! |
| 498 |
//! \return VAStatus |
| 499 |
//! VA_STATUS_ERROR_UNIMPLEMENTED |
| 500 |
//! |
| 501 |
static VAStatus DestroySubpicture( |
| 502 |
VADriverContextP ctx, |
| 503 |
VASubpictureID subpicture); |
| 504 |
|
| 505 |
//! |
| 506 |
//! \brief Set subpicture image |
| 507 |
//! |
| 508 |
//! \param [in] ctx |
| 509 |
//! Pointer to VA driver context |
| 510 |
//! \param [in] subpicture |
| 511 |
//! VA subpicture ID |
| 512 |
//! \param [in] image |
| 513 |
//! VA image ID |
| 514 |
//! |
| 515 |
//! \return VAStatus |
| 516 |
//! VA_STATUS_ERROR_UNIMPLEMENTED |
| 517 |
//! |
| 518 |
static VAStatus SetSubpictureImage( |
| 519 |
VADriverContextP ctx, |
| 520 |
VASubpictureID subpicture, |
| 521 |
VAImageID image); |
| 522 |
|
| 523 |
//! |
| 524 |
//! \brief Set subpicture chrome key |
| 525 |
//! |
| 526 |
//! \param [in] ctx |
| 527 |
//! Pointer to VA driver context |
| 528 |
//! \param [in] subpicture |
| 529 |
//! VA subpicture ID |
| 530 |
//! \param [in] chromakeyMin |
| 531 |
//! Minimum chroma key |
| 532 |
//! \param [in] chromakeyMax |
| 533 |
//! Maximum chroma key |
| 534 |
//! \param [in] chromakeyMask |
| 535 |
//! Chromakey mask |
| 536 |
//! |
| 537 |
//! \return VAStatus |
| 538 |
//! VA_STATUS_ERROR_UNIMPLEMENTED |
| 539 |
//! |
| 540 |
static VAStatus SetSubpictureChromakey( |
| 541 |
VADriverContextP ctx, |
| 542 |
VASubpictureID subpicture, |
| 543 |
uint32_t chromakeyMin, |
| 544 |
uint32_t chromakeyMax, |
| 545 |
uint32_t chromakeyMask); |
| 546 |
|
| 547 |
//! |
| 548 |
//! \brief set subpicture global alpha |
| 549 |
//! |
| 550 |
//! \param [in] ctx |
| 551 |
//! Pointer to VA driver context |
| 552 |
//! \param [in] subpicture |
| 553 |
//! VA subpicture ID |
| 554 |
//! \param [in] globalAlpha |
| 555 |
//! Global alpha |
| 556 |
//! |
| 557 |
//! \return VAStatus |
| 558 |
//! VA_STATUS_ERROR_UNIMPLEMENTED |
| 559 |
//! |
| 560 |
static VAStatus SetSubpictureGlobalAlpha( |
| 561 |
VADriverContextP ctx, |
| 562 |
VASubpictureID subpicture, |
| 563 |
float globalAlpha); |
| 564 |
|
| 565 |
//! |
| 566 |
//! \brief Associate subpicture |
| 567 |
//! |
| 568 |
//! \param [in] ctx |
| 569 |
//! Pointer to VA driver context |
| 570 |
//! \param [in] subpicture |
| 571 |
//! VA subpicture ID |
| 572 |
//! \param [in] targetSurfaces |
| 573 |
//! VA surface ID |
| 574 |
//! \param [in] surfacesNum |
| 575 |
//! Number of surfaces |
| 576 |
//! \param [in] srcX |
| 577 |
//! Source x of the region |
| 578 |
//! \param [in] srcY |
| 579 |
//! Source y of the region |
| 580 |
//! \param [in] srcWidth |
| 581 |
//! Source width of the region |
| 582 |
//! \param [in] srcHeight |
| 583 |
//! Source height of the region |
| 584 |
//! \param [in] destX |
| 585 |
//! Destination x |
| 586 |
//! \param [in] destY |
| 587 |
//! Destination y |
| 588 |
//! \param [in] destWidth |
| 589 |
//! Destination width |
| 590 |
//! \param [in] destHeight |
| 591 |
//! Destination height |
| 592 |
//! \param [in] flags |
| 593 |
//! Flags |
| 594 |
//! |
| 595 |
//! \return VAStatus |
| 596 |
//! VA_STATUS_ERROR_UNIMPLEMENTED |
| 597 |
//! |
| 598 |
static VAStatus AssociateSubpicture( |
| 599 |
VADriverContextP ctx, |
| 600 |
VASubpictureID subpicture, |
| 601 |
VASurfaceID *targetSurfaces, |
| 602 |
int32_t surfacesNum, |
| 603 |
int16_t srcX, /* upper left offset in subpicture */ |
| 604 |
int16_t srcY, |
| 605 |
uint16_t srcWidth, |
| 606 |
uint16_t srcHeight, |
| 607 |
int16_t destX, /* upper left offset in surface */ |
| 608 |
int16_t destY, |
| 609 |
uint16_t destWidth, |
| 610 |
uint16_t destHeight, |
| 611 |
uint32_t flags); |
| 612 |
|
| 613 |
//! |
| 614 |
//! \brief Deassociate subpicture |
| 615 |
//! |
| 616 |
//! \param [in] ctx |
| 617 |
//! Pointer to VA driver context |
| 618 |
//! \param [in] subpicture |
| 619 |
//! VA subpicture ID |
| 620 |
//! \param [in] targetSurfaces |
| 621 |
//! VA surface ID |
| 622 |
//! \param [in] surfacesNum |
| 623 |
//! Number of surfaces |
| 624 |
//! |
| 625 |
//! \return VAStatus |
| 626 |
//! VA_STATUS_ERROR_UNIMPLEMENTED |
| 627 |
//! |
| 628 |
static VAStatus DeassociateSubpicture( |
| 629 |
VADriverContextP ctx, |
| 630 |
VASubpictureID subpicture, |
| 631 |
VASurfaceID *targetSurfaces, |
| 632 |
int32_t surfacesNum); |
| 633 |
|
| 634 |
//! |
| 635 |
//! \brief Set display attributes |
| 636 |
//! \details Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field |
| 637 |
//! from vaQueryDisplayAttributes() can be set. If the attribute is not settable or |
| 638 |
//! the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED |
| 639 |
//! |
| 640 |
//! \param [in] ctx |
| 641 |
//! Pointer to VA driver context |
| 642 |
//! \param [in] attrList |
| 643 |
//! VA display attribute |
| 644 |
//! \param [in] attributesNum |
| 645 |
//! Number of attributes |
| 646 |
//! |
| 647 |
//! \return VAStatus |
| 648 |
//! VA_STATUS_ERROR_UNIMPLEMENTED |
| 649 |
//! |
| 650 |
static VAStatus SetDisplayAttributes( |
| 651 |
VADriverContextP ctx, |
| 652 |
VADisplayAttribute *attrList, |
| 653 |
int32_t attributesNum); |
| 654 |
|
| 655 |
//! |
| 656 |
//! \brief Query display attributes |
| 657 |
//! |
| 658 |
//! \param [in] ctx |
| 659 |
//! Pointer to VA driver context |
| 660 |
//! \param [in] attrList |
| 661 |
//! VA display attribute |
| 662 |
//! \param [in] attributesNum |
| 663 |
//! Number of attributes |
| 664 |
//! |
| 665 |
//! \return VAStatus |
| 666 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 667 |
//! |
| 668 |
static VAStatus QueryDisplayAttributes( |
| 669 |
VADriverContextP ctx, |
| 670 |
VADisplayAttribute *attrList, |
| 671 |
int32_t *attributesNum); |
| 672 |
|
| 673 |
//! |
| 674 |
//! \brief Get display attributes |
| 675 |
//! \details This function returns the current attribute values in "attr_list". |
| 676 |
//! Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field |
| 677 |
//! from vaQueryDisplayAttributes() can have their values retrieved. |
| 678 |
//! |
| 679 |
//! \param [in] ctx |
| 680 |
//! Pointer to VA driver context |
| 681 |
//! \param [in] attrList |
| 682 |
//! VA display attribute |
| 683 |
//! \param [in] attributesNum |
| 684 |
//! Number of attributes |
| 685 |
//! |
| 686 |
//! \return VAStatus |
| 687 |
//! VA_STATUS_ERROR_UNIMPLEMENTED |
| 688 |
//! |
| 689 |
static VAStatus GetDisplayAttributes( |
| 690 |
VADriverContextP ctx, |
| 691 |
VADisplayAttribute *attrList, |
| 692 |
int32_t attributesNum); |
| 693 |
|
| 694 |
//! |
| 695 |
//! \brief Convey to the server how many valid elements are in the buffer |
| 696 |
//! \details e.g. if multiple slice parameters are being held in a single buffer, |
| 697 |
//! this will communicate to the server the number of slice parameters |
| 698 |
//! that are valid in the buffer. |
| 699 |
//! |
| 700 |
//! \param [in] ctx |
| 701 |
//! Pointer to VA driver context |
| 702 |
//! \param [in] bufId |
| 703 |
//! VA buffer id |
| 704 |
//! \param [in] elementsNum |
| 705 |
//! Number of elements in buffer |
| 706 |
//! |
| 707 |
//! \return VAStatus |
| 708 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 709 |
//! |
| 710 |
static VAStatus BufferSetNumElements( |
| 711 |
VADriverContextP ctx, |
| 712 |
VABufferID bufId, |
| 713 |
uint32_t elementsNum); |
| 714 |
|
| 715 |
//! |
| 716 |
//! \brief Get process rate for a given config ID |
| 717 |
//! |
| 718 |
//! \param [in] ctx |
| 719 |
//! Pointer to VA driver context |
| 720 |
//! \param [in] configId |
| 721 |
//! VA configuration |
| 722 |
//! \param [in,out] procBuf |
| 723 |
//! Pointer to VAProcessingRateParameter |
| 724 |
//! \param [in,out] processingRate |
| 725 |
//! Return the process rate |
| 726 |
//! |
| 727 |
//! \return VAStatus |
| 728 |
//! VA_STATUS_SUCCESS if success |
| 729 |
//! |
| 730 |
static VAStatus QueryProcessingRate( |
| 731 |
VADriverContextP ctx, |
| 732 |
VAConfigID configId, |
| 733 |
VAProcessingRateParameter *procBuf, |
| 734 |
uint32_t *processingRate); |
| 735 |
|
| 736 |
//! |
| 737 |
//! \brief Query video proc filters |
| 738 |
//! |
| 739 |
//! \param [in] ctx |
| 740 |
//! Pointer to VA driver context |
| 741 |
//! \param [in] context |
| 742 |
//! VA context ID |
| 743 |
//! \param [in] filters |
| 744 |
//! VA proc filter type |
| 745 |
//! \param [in] filtersNum |
| 746 |
//! Number of filters |
| 747 |
//! |
| 748 |
//! \return VAStatus |
| 749 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 750 |
//! |
| 751 |
static VAStatus QueryVideoProcFilters ( |
| 752 |
VADriverContextP ctx, |
| 753 |
VAContextID context, |
| 754 |
VAProcFilterType *filters, |
| 755 |
uint32_t *filtersNum |
| 756 |
); |
| 757 |
|
| 758 |
//! |
| 759 |
//! \brief Query video processing filter capabilities. |
| 760 |
//! The real implementation is in media_libva_vp.c, since it needs to use some definitions in vphal.h. |
| 761 |
//! |
| 762 |
//! \param [in] ctx |
| 763 |
//! Pointer to VA driver context |
| 764 |
//! \param [in] context |
| 765 |
//! VA context ID |
| 766 |
//! \param [in] type |
| 767 |
//! VA proc filter type |
| 768 |
//! \param [inout] filterCaps |
| 769 |
//! FIlter caps |
| 770 |
//! \param [inout] filterCapsNum |
| 771 |
//! Number of filter caps |
| 772 |
//! |
| 773 |
//! \return VAStatus |
| 774 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 775 |
//! |
| 776 |
static VAStatus QueryVideoProcFilterCaps ( |
| 777 |
VADriverContextP ctx, |
| 778 |
VAContextID context, |
| 779 |
VAProcFilterType type, |
| 780 |
void *filterCaps, |
| 781 |
uint32_t *filterCapsNum |
| 782 |
); |
| 783 |
|
| 784 |
//! |
| 785 |
//! \brief Query video proc pipeline caps |
| 786 |
//! |
| 787 |
//! \param [in] ctx |
| 788 |
//! Pointer to VA driver context |
| 789 |
//! \param [in] context |
| 790 |
//! VA context ID |
| 791 |
//! \param [in] filters |
| 792 |
//! VA buffer ID |
| 793 |
//! \param [in] filtersNum |
| 794 |
//! Number of filters |
| 795 |
//! \param [in] pipelineCaps |
| 796 |
//! VA proc pipeline caps |
| 797 |
//! |
| 798 |
//! \return VAStatus |
| 799 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 800 |
//! |
| 801 |
static VAStatus QueryVideoProcPipelineCaps ( |
| 802 |
VADriverContextP ctx, |
| 803 |
VAContextID context, |
| 804 |
VABufferID *filters, |
| 805 |
uint32_t filtersNum, |
| 806 |
VAProcPipelineCaps *pipelineCaps |
| 807 |
); |
| 808 |
|
| 809 |
//! |
| 810 |
//! \brief Create an image |
| 811 |
//! |
| 812 |
//! \param [in] ctx |
| 813 |
//! Driver context |
| 814 |
//! \param [in] format |
| 815 |
//! The format of image |
| 816 |
//! \param [in] width |
| 817 |
//! The width of the image |
| 818 |
//! \param [in] height |
| 819 |
//! The height of the image |
| 820 |
//! \param [out] image |
| 821 |
//! The generated image |
| 822 |
//! |
| 823 |
//! \return VAStatus |
| 824 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 825 |
//! |
| 826 |
static VAStatus CreateImage ( |
| 827 |
VADriverContextP ctx, |
| 828 |
VAImageFormat *format, |
| 829 |
int32_t width, |
| 830 |
int32_t height, |
| 831 |
VAImage *image |
| 832 |
); |
| 833 |
|
| 834 |
//! |
| 835 |
//! \brief Derive image |
| 836 |
//! |
| 837 |
//! \param [in] ctx |
| 838 |
//! Pointer to VA driver context |
| 839 |
//! \param [in] surface |
| 840 |
//! VA surface ID |
| 841 |
//! \param [in] image |
| 842 |
//! VA image |
| 843 |
//! |
| 844 |
//! \return VAStatus |
| 845 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 846 |
//! |
| 847 |
static VAStatus DeriveImage ( |
| 848 |
VADriverContextP ctx, |
| 849 |
VASurfaceID surface, |
| 850 |
VAImage *image |
| 851 |
); |
| 852 |
|
| 853 |
//! |
| 854 |
//! \brief Create surfaces |
| 855 |
//! |
| 856 |
//! \param [in] ctx |
| 857 |
//! Pointer to VA driver context |
| 858 |
//! \param [in] width |
| 859 |
//! Surface width |
| 860 |
//! \param [in] height |
| 861 |
//! Surface height |
| 862 |
//! \param [in] format |
| 863 |
//! Surface format |
| 864 |
//! \param [in] surfacesNum |
| 865 |
//! Number of surfaces |
| 866 |
//! \param [out] surfaces |
| 867 |
//! VA created surfaces |
| 868 |
//! |
| 869 |
//! \return VAStatus |
| 870 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 871 |
//! |
| 872 |
static VAStatus CreateSurfaces ( |
| 873 |
VADriverContextP ctx, |
| 874 |
int32_t width, |
| 875 |
int32_t height, |
| 876 |
int32_t format, |
| 877 |
int32_t surfacesNum, |
| 878 |
VASurfaceID *surfaces |
| 879 |
); |
| 880 |
|
| 881 |
//! |
| 882 |
//! \brief Destroy resources associated with surfaces. |
| 883 |
//! \details Surfaces can only be destroyed after the context associated has been |
| 884 |
//! destroyed |
| 885 |
//! |
| 886 |
//! \param [in] ctx |
| 887 |
//! Pointer to VA driver context |
| 888 |
//! \param [in] surfaces |
| 889 |
//! VA array of surfaces to destroy |
| 890 |
//! \param [in] surfacesNum |
| 891 |
//! Number of surfaces in the array to be destroyed |
| 892 |
//! |
| 893 |
//! \return VAStatus |
| 894 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 895 |
//! |
| 896 |
static VAStatus DestroySurfaces ( |
| 897 |
VADriverContextP ctx, |
| 898 |
VASurfaceID *surfaces, |
| 899 |
int32_t surfacesNum |
| 900 |
); |
| 901 |
|
| 902 |
//! |
| 903 |
//! \brief Create surfaces2 |
| 904 |
//! |
| 905 |
//! \param [in] ctx |
| 906 |
//! Pointer to VA driver context |
| 907 |
//! \param [in] format |
| 908 |
//! Surface format |
| 909 |
//! \param [in] width |
| 910 |
//! Surface width |
| 911 |
//! \param [in] height |
| 912 |
//! Surface height |
| 913 |
//! \param [out] surfaces |
| 914 |
//! VA created surfaces |
| 915 |
//! \param [in] surfacesNum |
| 916 |
//! Number of surfaces |
| 917 |
//! \param [out] attribList |
| 918 |
//! VA attrib list |
| 919 |
//! \param [in] attribsNum |
| 920 |
//! Number of attribs |
| 921 |
//! |
| 922 |
//! \return VAStatus |
| 923 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 924 |
//! |
| 925 |
static VAStatus CreateSurfaces2 ( |
| 926 |
VADriverContextP ctx, |
| 927 |
uint32_t format, |
| 928 |
uint32_t width, |
| 929 |
uint32_t height, |
| 930 |
VASurfaceID *surfaces, |
| 931 |
uint32_t surfacesNum, |
| 932 |
VASurfaceAttrib *attribList, |
| 933 |
uint32_t attribsNum |
| 934 |
); |
| 935 |
|
| 936 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 937 |
//! |
| 938 |
//! \brief Sync Surface |
| 939 |
//! \details Sync surface |
| 940 |
//! \param [in] ctx |
| 941 |
//! Pointer to VA driver context |
| 942 |
//! \param [in] surfaceId |
| 943 |
//! VA surface id |
| 944 |
//! \param [in] timeoutNs |
| 945 |
//! time out period |
| 946 |
//! |
| 947 |
//! \return VAStatus |
| 948 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 949 |
//! |
| 950 |
static VAStatus SyncSurface2 ( |
| 951 |
VADriverContextP ctx, |
| 952 |
VASurfaceID surfaceId, |
| 953 |
uint64_t timeoutNs |
| 954 |
); |
| 955 |
|
| 956 |
//! |
| 957 |
//! \brief Sync buffer |
| 958 |
//! \details This function blocks until all pending operations on the render target |
| 959 |
//! have been completed. Upon return it is safe to use the render target for a |
| 960 |
//! different picture |
| 961 |
//! \param [in] ctx |
| 962 |
//! Pointer to VA driver context |
| 963 |
//! \param [in] bufId |
| 964 |
//! VA buffer id |
| 965 |
//! \param [in] timeoutNs |
| 966 |
//! time out period |
| 967 |
//! |
| 968 |
//! \return VAStatus |
| 969 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 970 |
//! |
| 971 |
static VAStatus SyncBuffer ( |
| 972 |
VADriverContextP ctx, |
| 973 |
VABufferID bufId, |
| 974 |
uint64_t timeoutNs |
| 975 |
); |
| 976 |
#endif |
| 977 |
|
| 978 |
//! |
| 979 |
//! \brief Check for buffer info |
| 980 |
//! |
| 981 |
//! \param [in] ctx |
| 982 |
//! Pointer to VA driver context |
| 983 |
//! \param [in] buf_id |
| 984 |
//! VA buffer ID |
| 985 |
//! \param [out] type |
| 986 |
//! VA buffer type |
| 987 |
//! \param [out] size |
| 988 |
//! Size |
| 989 |
//! \param [out] num_elements |
| 990 |
//! Number of elements |
| 991 |
//! |
| 992 |
//! \return VAStatus |
| 993 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 994 |
//! |
| 995 |
static VAStatus BufferInfo ( |
| 996 |
VADriverContextP ctx, |
| 997 |
VABufferID bufId, |
| 998 |
VABufferType *type, |
| 999 |
uint32_t *size, |
| 1000 |
uint32_t *elementsNum); |
| 1001 |
|
| 1002 |
//! |
| 1003 |
//! \brief Query surface status |
| 1004 |
//! |
| 1005 |
//! \param [in] ctx |
| 1006 |
//! Pointer to VA driver context |
| 1007 |
//! \param [in] renderTarget |
| 1008 |
//! VA surface ID |
| 1009 |
//! \param [out] status |
| 1010 |
//! VA surface status |
| 1011 |
static VAStatus QuerySurfaceStatus ( |
| 1012 |
VADriverContextP ctx, |
| 1013 |
VASurfaceID renderTarget, |
| 1014 |
VASurfaceStatus *status); |
| 1015 |
|
| 1016 |
//! |
| 1017 |
//! \brief Get surface attributes for the supplied config. |
| 1018 |
//! |
| 1019 |
//! This function retrieves the surface attributes matching the supplied |
| 1020 |
//! config. The caller shall provide an \c attrib_list with all attributes |
| 1021 |
//! to be retrieved. Upon successful return, the attributes in \c attrib_list |
| 1022 |
//! are updated with the requested value. Unknown attributes or attributes |
| 1023 |
//! that are not supported for the given config will have their \c flags |
| 1024 |
//! field set to \c VA_SURFACE_ATTRIB_NOT_SUPPORTED. |
| 1025 |
//! |
| 1026 |
//! \param [in] ctx |
| 1027 |
//! VA display |
| 1028 |
//! \param [in] config |
| 1029 |
//! the config identifying a codec or a video processing pipeline |
| 1030 |
//! \param [out] attribList |
| 1031 |
//! the list of attributes on output, with at least \c type fields filled in, |
| 1032 |
//! and possibly \c value fields whenever necessary.The updated list of attributes and flags on output |
| 1033 |
//! \param [in] attribsNum |
| 1034 |
//! the number of attributes supplied in the \c attrib_list array |
| 1035 |
//! |
| 1036 |
//! \return VAStatus |
| 1037 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1038 |
//! |
| 1039 |
static VAStatus GetSurfaceAttributes ( |
| 1040 |
VADriverContextP ctx, |
| 1041 |
VAConfigID config, |
| 1042 |
VASurfaceAttrib *attribList, |
| 1043 |
uint32_t attribsNum); |
| 1044 |
|
| 1045 |
//! |
| 1046 |
//! \brief Aquire buffer handle |
| 1047 |
//! |
| 1048 |
//! \param [in] ctx |
| 1049 |
//! Pointer to VA driver context |
| 1050 |
//! \param [in] bufId |
| 1051 |
//! VA buffer ID |
| 1052 |
//! \param [in] bufInfo |
| 1053 |
//! VA buffer Info |
| 1054 |
//! |
| 1055 |
//! \return VAStatus |
| 1056 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1057 |
//! |
| 1058 |
static VAStatus AcquireBufferHandle ( |
| 1059 |
VADriverContextP ctx, |
| 1060 |
VABufferID bufId, |
| 1061 |
VABufferInfo *bufInfo); |
| 1062 |
|
| 1063 |
//! |
| 1064 |
//! \brief Release buffer handle |
| 1065 |
//! |
| 1066 |
//! \param [in] ctx |
| 1067 |
//! Pointer to VA driver context |
| 1068 |
//! \param [in] bufId |
| 1069 |
//! VA bufferID |
| 1070 |
//! |
| 1071 |
//! \return VAStatus |
| 1072 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1073 |
//! |
| 1074 |
static VAStatus ReleaseBufferHandle( |
| 1075 |
VADriverContextP ctx, |
| 1076 |
VABufferID bufId); |
| 1077 |
|
| 1078 |
//! |
| 1079 |
//! \brief API for export surface handle to other component |
| 1080 |
//! |
| 1081 |
//! \param [in] dpy |
| 1082 |
//! VA display. |
| 1083 |
//! \param [in] surfaceId |
| 1084 |
//! Surface to export. |
| 1085 |
//! \param [in] memType |
| 1086 |
//! Memory type to export to. |
| 1087 |
//! \param [in] flags |
| 1088 |
//! Combination of flags to apply |
| 1089 |
//! \param [out] descriptor |
| 1090 |
//! Pointer to the descriptor structure to fill |
| 1091 |
//! with the handle details. The type of this structure depends on |
| 1092 |
//! the value of mem_type. |
| 1093 |
//! |
| 1094 |
//! \return VAStatus |
| 1095 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1096 |
//! |
| 1097 |
static VAStatus ExportSurfaceHandle( |
| 1098 |
VADriverContextP ctx, |
| 1099 |
VASurfaceID surfaceId, |
| 1100 |
uint32_t memType, |
| 1101 |
uint32_t flags, |
| 1102 |
void *descriptor); |
| 1103 |
|
| 1104 |
//! |
| 1105 |
//! \brief media copy internal |
| 1106 |
//! |
| 1107 |
//! \param [in] mosCtx |
| 1108 |
//! Pointer to mos context |
| 1109 |
//! \param [in] src |
| 1110 |
//! VA copy mos resource src. |
| 1111 |
//! \param [in] dst |
| 1112 |
//! VA copy mos resrouce dst. |
| 1113 |
//! \param [in] option |
| 1114 |
//! VA copy option, copy mode. |
| 1115 |
//! |
| 1116 |
//! \return VAStatus |
| 1117 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1118 |
//! |
| 1119 |
static VAStatus CopyInternal( |
| 1120 |
PMOS_CONTEXT mosCtx, |
| 1121 |
PMOS_RESOURCE src, |
| 1122 |
PMOS_RESOURCE dst, |
| 1123 |
uint32_t copy_mode |
| 1124 |
); |
| 1125 |
|
| 1126 |
#if VA_CHECK_VERSION(1,10,0) |
| 1127 |
//! |
| 1128 |
//! \brief media copy |
| 1129 |
//! |
| 1130 |
//! \param [in] ctx |
| 1131 |
//! Pointer to VA driver context |
| 1132 |
//! \param [in] dst_obj |
| 1133 |
//! VA copy object dst. |
| 1134 |
//! \param [in] src_obj |
| 1135 |
//! VA copy object src. |
| 1136 |
//! \param [in] option |
| 1137 |
//! VA copy option, copy mode. |
| 1138 |
//! \param [in] sync_handle |
| 1139 |
//! VA copy sync handle |
| 1140 |
//! |
| 1141 |
//! \return VAStatus |
| 1142 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1143 |
//! |
| 1144 |
static VAStatus Copy ( |
| 1145 |
VADriverContextP ctx, |
| 1146 |
VACopyObject *dst_obj, |
| 1147 |
VACopyObject *src_obj, |
| 1148 |
VACopyOption option |
| 1149 |
); |
| 1150 |
#endif |
| 1151 |
|
| 1152 |
#if VA_CHECK_VERSION(1,11,0) |
| 1153 |
|
| 1154 |
//! |
| 1155 |
//! \brief Create protected session |
| 1156 |
//! |
| 1157 |
//! \param [in] ctx |
| 1158 |
//! Pointer to VA driver context |
| 1159 |
//! \param [in] configId |
| 1160 |
//! VA configuration ID |
| 1161 |
//! \param [out] protectedSession |
| 1162 |
//! VA protected session ID |
| 1163 |
//! |
| 1164 |
//! \return VAStatus |
| 1165 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1166 |
//! |
| 1167 |
static VAStatus CreateProtectedSession ( |
| 1168 |
VADriverContextP ctx, |
| 1169 |
VAConfigID configId, |
| 1170 |
VAProtectedSessionID *protectedSession |
| 1171 |
); |
| 1172 |
|
| 1173 |
//! |
| 1174 |
//! \brief Destroy protected session |
| 1175 |
//! |
| 1176 |
//! \param [in] ctx |
| 1177 |
//! Pointer to VA driver context |
| 1178 |
//! \param [in] protectedSession |
| 1179 |
//! VA protected session ID |
| 1180 |
//! |
| 1181 |
//! \return VAStatus |
| 1182 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1183 |
//! |
| 1184 |
static VAStatus DestroyProtectedSession ( |
| 1185 |
VADriverContextP ctx, |
| 1186 |
VAProtectedSessionID protectedSession |
| 1187 |
); |
| 1188 |
|
| 1189 |
//! |
| 1190 |
//! \brief Attach protected session to display or context |
| 1191 |
//! |
| 1192 |
//! \param [in] ctx |
| 1193 |
//! Pointer to VA driver context |
| 1194 |
//! \param [in] context |
| 1195 |
//! VA context ID to be attached if not 0. |
| 1196 |
//! \param [in] protectedSession |
| 1197 |
//! VA protected session ID |
| 1198 |
//! |
| 1199 |
//! \return VAStatus |
| 1200 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1201 |
//! |
| 1202 |
static VAStatus AttachProtectedSession ( |
| 1203 |
VADriverContextP ctx, |
| 1204 |
VAContextID context, |
| 1205 |
VAProtectedSessionID protectedSession |
| 1206 |
); |
| 1207 |
|
| 1208 |
//! |
| 1209 |
//! \brief Detach protected session from display or context |
| 1210 |
//! |
| 1211 |
//! \param [in] ctx |
| 1212 |
//! Pointer to VA driver context |
| 1213 |
//! \param [in] context |
| 1214 |
//! VA context ID to be Detached if not 0. |
| 1215 |
//! |
| 1216 |
//! \return VAStatus |
| 1217 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1218 |
//! |
| 1219 |
static VAStatus DetachProtectedSession ( |
| 1220 |
VADriverContextP ctx, |
| 1221 |
VAContextID context |
| 1222 |
); |
| 1223 |
|
| 1224 |
//! |
| 1225 |
//! \brief TEE execution for the particular protected session |
| 1226 |
//! |
| 1227 |
//! \param [in] ctx |
| 1228 |
//! Pointer to VA driver context |
| 1229 |
//! \param [in] protectedSession |
| 1230 |
//! VA protected session ID |
| 1231 |
//! \param [in] data |
| 1232 |
//! VA buffer ID |
| 1233 |
//! |
| 1234 |
//! \return VAStatus |
| 1235 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1236 |
//! |
| 1237 |
static VAStatus ProtectedSessionExecute ( |
| 1238 |
VADriverContextP ctx, |
| 1239 |
VAProtectedSessionID protectedSession, |
| 1240 |
VABufferID data |
| 1241 |
); |
| 1242 |
#endif |
| 1243 |
|
| 1244 |
//! |
| 1245 |
//! \brief Convert media format to OS format |
| 1246 |
//! |
| 1247 |
//! \param [in] format |
| 1248 |
//! Ddi media format |
| 1249 |
//! |
| 1250 |
//! \return Os format if call sucesss,else |
| 1251 |
//! VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT if fail |
| 1252 |
//! |
| 1253 |
static int32_t MediaFormatToOsFormat(DDI_MEDIA_FORMAT format); |
| 1254 |
|
| 1255 |
//! |
| 1256 |
//! \brief Destroy buffer from VA buffer ID |
| 1257 |
//! |
| 1258 |
//! \param [in] mediaCtx |
| 1259 |
//! Pointer to ddi media context |
| 1260 |
//! \param [in] bufferID |
| 1261 |
//! VA buffer ID |
| 1262 |
//! |
| 1263 |
//! \return bool |
| 1264 |
//! true if destroy buffer from VA buffer ID, else false |
| 1265 |
//! |
| 1266 |
static bool DestroyBufFromVABufferID( |
| 1267 |
PDDI_MEDIA_CONTEXT mediaCtx, |
| 1268 |
VABufferID bufferID); |
| 1269 |
|
| 1270 |
//! |
| 1271 |
//! \brief Sync Surface |
| 1272 |
//! \details Sync surface |
| 1273 |
//! \param [in] ctx |
| 1274 |
//! Pointer to VA driver context |
| 1275 |
//! \param [in] surfaceId |
| 1276 |
//! VA surface id |
| 1277 |
//! \param [in] timeoutNs |
| 1278 |
//! time out period |
| 1279 |
//! |
| 1280 |
//! \return VAStatus |
| 1281 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1282 |
//! |
| 1283 |
static VAStatus SyncSurface( |
| 1284 |
VADriverContextP ctx, |
| 1285 |
VASurfaceID renderTarget); |
| 1286 |
|
| 1287 |
//! |
| 1288 |
//! \brief Query Surface Error |
| 1289 |
//! |
| 1290 |
//! \param [in] ctx |
| 1291 |
//! Pointer to VA driver context |
| 1292 |
//! \param [in] renderTarget |
| 1293 |
//! VASurfaceID |
| 1294 |
//! \param [in] errorStatus |
| 1295 |
//! error Status |
| 1296 |
//! \param [in] errorInfo |
| 1297 |
//! error info |
| 1298 |
//! |
| 1299 |
//! \return VAStatus |
| 1300 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1301 |
//! |
| 1302 |
static VAStatus QuerySurfaceError( |
| 1303 |
VADriverContextP ctx, |
| 1304 |
VASurfaceID renderTarget, |
| 1305 |
VAStatus errorStatus, |
| 1306 |
void **errorInfo); |
| 1307 |
|
| 1308 |
//! |
| 1309 |
//! \brief Copy data from a VAImage to a surface |
| 1310 |
//! \details Image must be in a format supported by the implementation |
| 1311 |
//! |
| 1312 |
//! \param [in] ctx |
| 1313 |
//! Input driver context |
| 1314 |
//! \param [in] surface |
| 1315 |
//! Surface ID of destination |
| 1316 |
//! \param [in] draw |
| 1317 |
//! Drawable of window system |
| 1318 |
//! \param [in] image |
| 1319 |
//! The image ID of the destination image |
| 1320 |
//! \param [in] srcx |
| 1321 |
//! Source x offset of the image region |
| 1322 |
//! \param [in] srcy |
| 1323 |
//! Source y offset of the image region |
| 1324 |
//! \param [in] srcw |
| 1325 |
//! Source width offset of the image region |
| 1326 |
//! \param [in] srch |
| 1327 |
//! Source height offset of the image region |
| 1328 |
//! \param [in] destx |
| 1329 |
//! Destination x offset of the surface region |
| 1330 |
//! \param [in] desty |
| 1331 |
//! Destination y offset of the surface region |
| 1332 |
//! \param [in] destw |
| 1333 |
//! Destination width offset of the surface region |
| 1334 |
//! \param [in] desth |
| 1335 |
//! Destination height offset of the surface region |
| 1336 |
//! \param [in] cliprects |
| 1337 |
//! client supplied clip list |
| 1338 |
//! \param [in] numberCliprects |
| 1339 |
//! number of clip rects in the clip list |
| 1340 |
//! \param [in] flags |
| 1341 |
//! de-interlacing flags |
| 1342 |
//! |
| 1343 |
//! \return VAStatus |
| 1344 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1345 |
//! |
| 1346 |
static VAStatus PutSurface( |
| 1347 |
VADriverContextP ctx, |
| 1348 |
VASurfaceID surface, |
| 1349 |
void *draw, |
| 1350 |
int16_t srcx, |
| 1351 |
int16_t srcy, |
| 1352 |
uint16_t srcw, |
| 1353 |
uint16_t srch, |
| 1354 |
int16_t destx, |
| 1355 |
int16_t desty, |
| 1356 |
uint16_t destw, |
| 1357 |
uint16_t desth, |
| 1358 |
VARectangle *cliprects, /* client supplied clip list */ |
| 1359 |
uint32_t numberCliprects, /* number of clip rects in the clip list */ |
| 1360 |
uint32_t flags /* de-interlacing flags */ |
| 1361 |
); |
| 1362 |
|
| 1363 |
//! |
| 1364 |
//! \brief Destroy Image |
| 1365 |
//! \details Destroy VA Image |
| 1366 |
//! |
| 1367 |
//! \param [in] ctx |
| 1368 |
//! Input driver context |
| 1369 |
//! \param [in] image |
| 1370 |
//! VA image ID |
| 1371 |
//! |
| 1372 |
//! \return VAStatus |
| 1373 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1374 |
//! |
| 1375 |
static VAStatus DestroyImage( |
| 1376 |
VADriverContextP ctx, |
| 1377 |
VAImageID image); |
| 1378 |
|
| 1379 |
//! |
| 1380 |
//! \brief Retrive surface data into a VAImage |
| 1381 |
//! \details Image must be in a format supported by the implementation |
| 1382 |
//! |
| 1383 |
//! \param [in] ctx |
| 1384 |
//! Input driver context |
| 1385 |
//! \param [in] surface |
| 1386 |
//! Input surface ID of source |
| 1387 |
//! \param [in] x |
| 1388 |
//! X offset of the wanted region |
| 1389 |
//! \param [in] y |
| 1390 |
//! Y offset of the wanted region |
| 1391 |
//! \param [in] width |
| 1392 |
//! Width of the wanted region |
| 1393 |
//! \param [in] height |
| 1394 |
//! Height of the wanted region |
| 1395 |
//! \param [in] image |
| 1396 |
//! The image ID of the source image |
| 1397 |
//! |
| 1398 |
//! \return VAStatus |
| 1399 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1400 |
//! |
| 1401 |
static VAStatus GetImage( |
| 1402 |
VADriverContextP ctx, |
| 1403 |
VASurfaceID surface, |
| 1404 |
int32_t x, /* coordinates of the upper left source pixel */ |
| 1405 |
int32_t y, |
| 1406 |
uint32_t width, /* width and height of the region */ |
| 1407 |
uint32_t height, |
| 1408 |
VAImageID image |
| 1409 |
); |
| 1410 |
|
| 1411 |
//! |
| 1412 |
//! \brief Copy data from a VAImage to a surface |
| 1413 |
//! \details Image must be in a format supported by the implementation |
| 1414 |
//! |
| 1415 |
//! \param [in] ctx |
| 1416 |
//! Input driver context |
| 1417 |
//! \param [in] surface |
| 1418 |
//! Surface ID of destination |
| 1419 |
//! \param [in] image |
| 1420 |
//! The image ID of the destination image |
| 1421 |
//! \param [in] srcX |
| 1422 |
//! Source x offset of the image region |
| 1423 |
//! \param [in] srcY |
| 1424 |
//! Source y offset of the image region |
| 1425 |
//! \param [in] srcWidth |
| 1426 |
//! Source width offset of the image region |
| 1427 |
//! \param [in] srcHeight |
| 1428 |
//! Source height offset of the image region |
| 1429 |
//! \param [in] destX |
| 1430 |
//! Destination x offset of the surface region |
| 1431 |
//! \param [in] destY |
| 1432 |
//! Destination y offset of the surface region |
| 1433 |
//! \param [in] destWidth |
| 1434 |
//! Destination width offset of the surface region |
| 1435 |
//! \param [in] destHeight |
| 1436 |
//! Destination height offset of the surface region |
| 1437 |
//! |
| 1438 |
//! \return VAStatus |
| 1439 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1440 |
//! |
| 1441 |
static VAStatus PutImage( |
| 1442 |
VADriverContextP ctx, |
| 1443 |
VASurfaceID surface, |
| 1444 |
VAImageID image, |
| 1445 |
int32_t srcX, |
| 1446 |
int32_t srcY, |
| 1447 |
uint32_t srcWidth, |
| 1448 |
uint32_t srcHeight, |
| 1449 |
int32_t destX, |
| 1450 |
int32_t destY, |
| 1451 |
uint32_t destWidth, |
| 1452 |
uint32_t destHeight |
| 1453 |
); |
| 1454 |
|
| 1455 |
//! |
| 1456 |
//! \brief Lock surface |
| 1457 |
//! |
| 1458 |
//! \param [in] ctx |
| 1459 |
//! Pointer to VA driver context |
| 1460 |
//! \param [in] surface |
| 1461 |
//! VA surface ID |
| 1462 |
//! \param [out] fourcc |
| 1463 |
//! FourCC |
| 1464 |
//! \param [out] lumaStride |
| 1465 |
//! Luma stride |
| 1466 |
//! \param [out] chromaUStride |
| 1467 |
//! Chroma U stride |
| 1468 |
//! \param [out] chromaVStride |
| 1469 |
//! Chroma V stride |
| 1470 |
//! \param [out] lumaOffset |
| 1471 |
//! Luma offset |
| 1472 |
//! \param [out] chromaUOffset |
| 1473 |
//! Chroma U offset |
| 1474 |
//! \param [out] chromaVOffset |
| 1475 |
//! Chroma V offset |
| 1476 |
//! \param [out] bufferName |
| 1477 |
//! Buffer name |
| 1478 |
//! \param [out] buffer |
| 1479 |
//! Buffer |
| 1480 |
//! |
| 1481 |
//! \return VAStatus |
| 1482 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1483 |
//! |
| 1484 |
static VAStatus LockSurface( |
| 1485 |
VADriverContextP ctx, |
| 1486 |
VASurfaceID surface, |
| 1487 |
uint32_t *fourcc, |
| 1488 |
uint32_t *lumaStride, |
| 1489 |
uint32_t *chromaUStride, |
| 1490 |
uint32_t *chromaVStride, |
| 1491 |
uint32_t *lumaOffset, |
| 1492 |
uint32_t *chromaUOffset, |
| 1493 |
uint32_t *chromaVOffset, |
| 1494 |
uint32_t *bufferName, |
| 1495 |
void **buffer); |
| 1496 |
|
| 1497 |
//! |
| 1498 |
//! \brief Unlock surface |
| 1499 |
//! |
| 1500 |
//! \param [in] ctx |
| 1501 |
//! Pointer to VA driver context |
| 1502 |
//! \param [in] surface |
| 1503 |
//! VA surface ID |
| 1504 |
//! |
| 1505 |
//! \return VAStatus |
| 1506 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1507 |
//! |
| 1508 |
static VAStatus UnlockSurface( |
| 1509 |
VADriverContextP ctx, |
| 1510 |
VASurfaceID surface); |
| 1511 |
private: |
| 1512 |
|
| 1513 |
//! |
| 1514 |
//! \brief Copy Surface To Image |
| 1515 |
//! |
| 1516 |
//! \param [in] ctx |
| 1517 |
//! Pointer to VA driver context |
| 1518 |
//! \param [in] surface |
| 1519 |
//! Input surface |
| 1520 |
//! \param [in] image |
| 1521 |
//! Output image |
| 1522 |
//! |
| 1523 |
//! \return VAStatus |
| 1524 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1525 |
//! |
| 1526 |
static VAStatus CopySurfaceToImage( |
| 1527 |
VADriverContextP ctx, |
| 1528 |
DDI_MEDIA_SURFACE *surface, |
| 1529 |
VAImage *image); |
| 1530 |
|
| 1531 |
//! |
| 1532 |
//! \brief Copy plane from src to dst row by row when src and dst strides are different |
| 1533 |
//! |
| 1534 |
//! \param [in] dst |
| 1535 |
//! Destination plane |
| 1536 |
//! \param [in] dstPitch |
| 1537 |
//! Destination plane pitch |
| 1538 |
//! \param [in] src |
| 1539 |
//! Source plane |
| 1540 |
//! \param [in] srcPitch |
| 1541 |
//! Source plane pitch |
| 1542 |
//! \param [in] height |
| 1543 |
//! Plane hight |
| 1544 |
//! |
| 1545 |
static void CopyPlane( |
| 1546 |
uint8_t *dst, |
| 1547 |
uint32_t dstPitch, |
| 1548 |
uint8_t *src, |
| 1549 |
uint32_t srcPitch, |
| 1550 |
uint32_t height); |
| 1551 |
|
| 1552 |
//! |
| 1553 |
//! \brief Map CompType from entrypoint |
| 1554 |
//! |
| 1555 |
//! \param [in] entrypoint |
| 1556 |
//! VAEntrypoint |
| 1557 |
//! |
| 1558 |
//! \return CompType |
| 1559 |
//! |
| 1560 |
static CompType MapCompTypeFromEntrypoint(VAEntrypoint entrypoint); |
| 1561 |
|
| 1562 |
//! |
| 1563 |
//! \brief Map CompType from CtxType |
| 1564 |
//! |
| 1565 |
//! \param [in] ctxType |
| 1566 |
//! context type |
| 1567 |
//! |
| 1568 |
//! \return CompType |
| 1569 |
//! |
| 1570 |
static CompType MapComponentFromCtxType(uint32_t ctxType); |
| 1571 |
|
| 1572 |
//! |
| 1573 |
//! \brief Load DDI function pointer |
| 1574 |
//! |
| 1575 |
//! \param [in] ctx |
| 1576 |
//! Pointer to VA driver context |
| 1577 |
//! |
| 1578 |
//! \return VAStatus |
| 1579 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1580 |
//! |
| 1581 |
static VAStatus LoadFunction(VADriverContextP ctx); |
| 1582 |
|
| 1583 |
//! |
| 1584 |
//! \brief Free for media context |
| 1585 |
//! |
| 1586 |
//! \param [in] mediaCtx |
| 1587 |
//! Pointer to ddi media context |
| 1588 |
//! |
| 1589 |
static void FreeForMediaContext(PDDI_MEDIA_CONTEXT mediaCtx); |
| 1590 |
|
| 1591 |
//! |
| 1592 |
//! \brief Free for media context |
| 1593 |
//! |
| 1594 |
//! \param [in] mediaCtx |
| 1595 |
//! Pointer to ddi media context mutex |
| 1596 |
//! |
| 1597 |
static void DestroyMediaContextMutex(PDDI_MEDIA_CONTEXT mediaCtx); |
| 1598 |
|
| 1599 |
//! |
| 1600 |
//! \brief Create media context |
| 1601 |
//! |
| 1602 |
//! |
| 1603 |
static PDDI_MEDIA_CONTEXT CreateMediaDriverContext(); |
| 1604 |
|
| 1605 |
//! |
| 1606 |
//! \brief Initialize |
| 1607 |
//! |
| 1608 |
//! \param [in] mediaCtx |
| 1609 |
//! Pointer to DDI media driver context |
| 1610 |
//! |
| 1611 |
//! \return VAStatus |
| 1612 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1613 |
//! |
| 1614 |
static VAStatus HeapInitialize(PDDI_MEDIA_CONTEXT mediaCtx); |
| 1615 |
|
| 1616 |
//! |
| 1617 |
//! \brief Get Plane Num |
| 1618 |
//! |
| 1619 |
//! \param [in] mediaSurface |
| 1620 |
//! Pointer to DDI media surface |
| 1621 |
//! \param [in] hasAuxPlane |
| 1622 |
//! if has Aus Plane |
| 1623 |
//! |
| 1624 |
//! \return uint32_t |
| 1625 |
//! Plane num |
| 1626 |
//! |
| 1627 |
static uint32_t GetPlaneNum(PDDI_MEDIA_SURFACE mediaSurface, bool hasAuxPlane); |
| 1628 |
|
| 1629 |
//! |
| 1630 |
//! \brief Get Drm Format Of Separate Plane |
| 1631 |
//! |
| 1632 |
//! \param [in] fourcc |
| 1633 |
//! Format |
| 1634 |
//! \param [in] plane |
| 1635 |
//! Plane |
| 1636 |
//! |
| 1637 |
//! \return uint32_t |
| 1638 |
//! Drmformat |
| 1639 |
//! |
| 1640 |
static uint32_t GetDrmFormatOfSeparatePlane(uint32_t fourcc, int plane); |
| 1641 |
|
| 1642 |
//! |
| 1643 |
//! \brief Get Drm Format Of Separate Plane |
| 1644 |
//! |
| 1645 |
//! \param [in] fourcc |
| 1646 |
//! Format |
| 1647 |
//! |
| 1648 |
//! \return uint32_t |
| 1649 |
//! Drmformat |
| 1650 |
//! |
| 1651 |
static uint32_t GetDrmFormatOfCompositeObject(uint32_t fourcc); |
| 1652 |
|
| 1653 |
//! |
| 1654 |
//! \brief Get Chroma Pitch and Height |
| 1655 |
//! |
| 1656 |
//! \param [in] fourcc |
| 1657 |
//! Format |
| 1658 |
//! \param [in] pitch |
| 1659 |
//! Pitch |
| 1660 |
//! \param [in] height |
| 1661 |
//! Height |
| 1662 |
//! \param [out] chromaPitch |
| 1663 |
//! ChromaPitch |
| 1664 |
//! \param [out] chromaHeight |
| 1665 |
//! ChromaHeight |
| 1666 |
//! |
| 1667 |
//! \return VAStatus |
| 1668 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1669 |
//! |
| 1670 |
static VAStatus GetChromaPitchHeight( |
| 1671 |
uint32_t fourcc, |
| 1672 |
uint32_t pitch, |
| 1673 |
uint32_t height, |
| 1674 |
uint32_t *chromaPitch, |
| 1675 |
uint32_t *chromaHeight); |
| 1676 |
|
| 1677 |
//! |
| 1678 |
//! \brief Get VA image from VA image ID |
| 1679 |
//! |
| 1680 |
//! \param [in] mediaCtx |
| 1681 |
//! Pointer to ddi media context |
| 1682 |
//! \param [in] imageID |
| 1683 |
//! VA image ID |
| 1684 |
//! |
| 1685 |
//! \return VAImage* |
| 1686 |
//! Pointer to VAImage |
| 1687 |
//! |
| 1688 |
static VAImage* GetVAImageFromVAImageID (PDDI_MEDIA_CONTEXT mediaCtx, VAImageID imageID); |
| 1689 |
|
| 1690 |
//! |
| 1691 |
//! \brief Destroy image from VA image ID |
| 1692 |
//! |
| 1693 |
//! \param [in] mediaCtx |
| 1694 |
//! Pointer to ddi media context |
| 1695 |
//! \param [in] imageID |
| 1696 |
//! VA image ID |
| 1697 |
//! |
| 1698 |
//! \return bool |
| 1699 |
//! True if destroy image from VA image ID, else fail |
| 1700 |
//! |
| 1701 |
static bool DestroyImageFromVAImageID (PDDI_MEDIA_CONTEXT mediaCtx, VAImageID imageID); |
| 1702 |
|
| 1703 |
//! |
| 1704 |
//! \brief Decompress internal media memory |
| 1705 |
//! |
| 1706 |
//! \param [in] mosCtx |
| 1707 |
//! Pointer to mos context |
| 1708 |
//! \param [in] osResource |
| 1709 |
//! Pointer mos resource |
| 1710 |
//! |
| 1711 |
static void MediaMemoryDecompressInternal( |
| 1712 |
PMOS_CONTEXT mosCtx, |
| 1713 |
PMOS_RESOURCE osResource); |
| 1714 |
|
| 1715 |
//! |
| 1716 |
//! \brief copy internal media surface to another surface |
| 1717 |
//! |
| 1718 |
//! \param [in] mosCtx |
| 1719 |
//! Pointer to mos context |
| 1720 |
//! \param [in] inputOsResource |
| 1721 |
//! Pointer input mos resource |
| 1722 |
//! \param [in] outputOsResource |
| 1723 |
//! Pointer output mos resource |
| 1724 |
//! \param [in] boutputcompressed |
| 1725 |
//! output can be compressed or not |
| 1726 |
//! |
| 1727 |
static void MediaMemoryCopyInternal( |
| 1728 |
PMOS_CONTEXT mosCtx, |
| 1729 |
PMOS_RESOURCE inputOsResource, |
| 1730 |
PMOS_RESOURCE outputOsResource, |
| 1731 |
bool boutputcompressed); |
| 1732 |
|
| 1733 |
//! |
| 1734 |
//! \brief copy internal media surface/buffer to another surface/buffer |
| 1735 |
//! |
| 1736 |
//! \param [in] mosCtx |
| 1737 |
//! Pointer to mos context |
| 1738 |
//! \param [in] inputOsResource |
| 1739 |
//! Pointer input mos resource |
| 1740 |
//! \param [in] outputOsResource |
| 1741 |
//! Pointer output mos resource |
| 1742 |
//! \param [in] boutputcompressed |
| 1743 |
//! output can be compressed or not |
| 1744 |
//! \param [in] copyWidth |
| 1745 |
//! The 2D surface Width |
| 1746 |
//! \param [in] copyHeight |
| 1747 |
//! The 2D surface height |
| 1748 |
//! \param [in] copyInputOffset |
| 1749 |
//! The offset of copied surface from |
| 1750 |
//! \param [in] copyOutputOffset |
| 1751 |
//! The offset of copied to |
| 1752 |
//! |
| 1753 |
static void MediaMemoryCopy2DInternal( |
| 1754 |
PMOS_CONTEXT mosCtx, |
| 1755 |
PMOS_RESOURCE inputOsResource, |
| 1756 |
PMOS_RESOURCE outputOsResource, |
| 1757 |
uint32_t copyWidth, |
| 1758 |
uint32_t copyHeight, |
| 1759 |
uint32_t copyInputOffset, |
| 1760 |
uint32_t copyOutputOffset, |
| 1761 |
uint32_t bpp, |
| 1762 |
bool boutputcompressed); |
| 1763 |
|
| 1764 |
//! |
| 1765 |
//! \brief Tile/Linear format conversion for media surface/buffer |
| 1766 |
//! |
| 1767 |
//! \param [in] mosCtx |
| 1768 |
//! Pointer to mos context |
| 1769 |
//! \param [in] inputOsResource |
| 1770 |
//! Pointer input mos resource |
| 1771 |
//! \param [in] outputOsResource |
| 1772 |
//! Pointer output mos resource |
| 1773 |
//! \param [in] copyWidth |
| 1774 |
//! The 2D surface Width |
| 1775 |
//! \param [in] copyHeight |
| 1776 |
//! The 2D surface height |
| 1777 |
//! \param [in] copyInputOffset |
| 1778 |
//! The offset of copied surface from |
| 1779 |
//! \param [in] copyOutputOffset |
| 1780 |
//! The offset of copied to |
| 1781 |
//! \param [in] isTileToLinear |
| 1782 |
//! Convertion direction, true: tile->linear, false: linear->tile |
| 1783 |
//! \param [in] outputCompressed |
| 1784 |
//! output can be compressed or not |
| 1785 |
//! |
| 1786 |
static VAStatus MediaMemoryTileConvertInternal( |
| 1787 |
PMOS_CONTEXT mosCtx, |
| 1788 |
PMOS_RESOURCE inputOsResource, |
| 1789 |
PMOS_RESOURCE outputOsResource, |
| 1790 |
uint32_t copyWidth, |
| 1791 |
uint32_t copyHeight, |
| 1792 |
uint32_t copyInputOffset, |
| 1793 |
uint32_t copyOutputOffset, |
| 1794 |
bool isTileToLinear, |
| 1795 |
bool outputCompressed); |
| 1796 |
|
| 1797 |
|
| 1798 |
#if defined(X11_FOUND) |
| 1799 |
#define X11_LIB_NAME "libX11.so.6" |
| 1800 |
//! |
| 1801 |
//! \brief Close opened libX11.so lib, free related function table. |
| 1802 |
//! |
| 1803 |
//! \param [in] mediaCtx |
| 1804 |
//! Pointer to media context |
| 1805 |
//! |
| 1806 |
static void DestroyX11Connection( |
| 1807 |
PDDI_MEDIA_CONTEXT mediaCtx); |
| 1808 |
|
| 1809 |
//! |
| 1810 |
//! \brief dlopen libX11.so, setup the function table |
| 1811 |
//! |
| 1812 |
//! \param [in] mediaCtx |
| 1813 |
//! Pointer to media context |
| 1814 |
//! |
| 1815 |
static VAStatus ConnectX11( |
| 1816 |
PDDI_MEDIA_CONTEXT mediaCtx); |
| 1817 |
|
| 1818 |
//! |
| 1819 |
//! \brief Output driver initialization |
| 1820 |
//! |
| 1821 |
//! \param [in] ctx |
| 1822 |
//! Pointer to VA driver context |
| 1823 |
//! |
| 1824 |
//! \return bool |
| 1825 |
//! true if call success, else false |
| 1826 |
//! |
| 1827 |
static bool OutputDriInit(VADriverContextP ctx); |
| 1828 |
|
| 1829 |
//! |
| 1830 |
//! \brief Get dso symbols |
| 1831 |
//! |
| 1832 |
//! \param [in] h |
| 1833 |
//! Pointer dso handle |
| 1834 |
//! \param [in] vtable |
| 1835 |
//! Pointer to VA driver table |
| 1836 |
//! \param [in] vtable_length |
| 1837 |
//! VA driver table length |
| 1838 |
//! \param [in] symbols |
| 1839 |
//! dso symbols |
| 1840 |
//! |
| 1841 |
//! \return bool |
| 1842 |
//! true if call success, else false |
| 1843 |
//! |
| 1844 |
static bool DsoGetSymbols( |
| 1845 |
struct dso_handle *h, |
| 1846 |
void *vtable, |
| 1847 |
uint32_t vtable_length, |
| 1848 |
const struct dso_symbol *symbols); |
| 1849 |
|
| 1850 |
//! |
| 1851 |
//! \brief Open dso |
| 1852 |
//! |
| 1853 |
//! \param [in] path |
| 1854 |
//! dso path |
| 1855 |
//! |
| 1856 |
//! \return dso_handle |
| 1857 |
//! dso handle struct |
| 1858 |
//! |
| 1859 |
static struct dso_handle* DsoOpen(const char *path); |
| 1860 |
|
| 1861 |
//! |
| 1862 |
//! \brief Get symbol |
| 1863 |
//! |
| 1864 |
//! \param [in] h |
| 1865 |
//! Pointer dso handle |
| 1866 |
//! \param [in] func_vptr |
| 1867 |
//! Pointer to function |
| 1868 |
//! \param [in] name |
| 1869 |
//! Functions name |
| 1870 |
//! |
| 1871 |
//! \return bool |
| 1872 |
//! true if call success, else false |
| 1873 |
//! |
| 1874 |
static bool GetSymbol( |
| 1875 |
struct dso_handle *h, |
| 1876 |
void *func_vptr, |
| 1877 |
const char *name); |
| 1878 |
#endif |
| 1879 |
|
| 1880 |
//! |
| 1881 |
//! \brief Free allocated surfaceheap elements |
| 1882 |
//! |
| 1883 |
//! \param [in] mediaCtx |
| 1884 |
//! Pointer to media context |
| 1885 |
//! |
| 1886 |
static void FreeSurfaceHeapElements(PDDI_MEDIA_CONTEXT mediaCtx); |
| 1887 |
|
| 1888 |
//! |
| 1889 |
//! \brief Free allocated bufferheap elements |
| 1890 |
//! |
| 1891 |
//! \param [in] ctx |
| 1892 |
//! VA Driver Context |
| 1893 |
//! |
| 1894 |
static void FreeBufferHeapElements(VADriverContextP ctx); |
| 1895 |
|
| 1896 |
//! |
| 1897 |
//! \brief Free allocated Imageheap elements |
| 1898 |
//! |
| 1899 |
//! \param [in] ctx |
| 1900 |
//! VA Driver Context |
| 1901 |
//! |
| 1902 |
static void FreeImageHeapElements(VADriverContextP ctx); |
| 1903 |
|
| 1904 |
//! |
| 1905 |
//! \brief Free allocated contextheap elements |
| 1906 |
//! |
| 1907 |
//! \param [in] ctx |
| 1908 |
//! VA Driver Context |
| 1909 |
//! |
| 1910 |
static void FreeContextHeapElements(VADriverContextP ctx); |
| 1911 |
|
| 1912 |
//! |
| 1913 |
//! \brief Free allocated ContextCM elements |
| 1914 |
//! |
| 1915 |
//! \param [in] ctx |
| 1916 |
//! VA Driver Context |
| 1917 |
//! |
| 1918 |
static void FreeContextCMElements(VADriverContextP ctx); |
| 1919 |
|
| 1920 |
//! |
| 1921 |
//! \brief Free allocated heap elements |
| 1922 |
//! |
| 1923 |
//! \param [in] mediaCtx |
| 1924 |
//! Pointer to media context |
| 1925 |
//! \return VAStatus |
| 1926 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1927 |
//! |
| 1928 |
static VAStatus HeapDestroy(PDDI_MEDIA_CONTEXT mediaCtx); |
| 1929 |
|
| 1930 |
//! |
| 1931 |
//! \brief Execute free allocated bufferheap elements for FreeContextHeapElements function |
| 1932 |
//! |
| 1933 |
//! \param [in] ctx |
| 1934 |
//! VA Driver Context |
| 1935 |
//! \param [in] contextHeap |
| 1936 |
//! context heap |
| 1937 |
//! \param [in] vaContextOffset |
| 1938 |
//! context heap |
| 1939 |
//! \param [in] ctxNums |
| 1940 |
//! context numbers |
| 1941 |
//! |
| 1942 |
static void FreeContextHeap( |
| 1943 |
VADriverContextP ctx, |
| 1944 |
PDDI_MEDIA_HEAP contextHeap, |
| 1945 |
int32_t vaContextOffset, |
| 1946 |
int32_t ctxNums); |
| 1947 |
|
| 1948 |
//! |
| 1949 |
//! \brief DestroyCMContext |
| 1950 |
//! |
| 1951 |
//! \param [in] ctx |
| 1952 |
//! VA Driver Context |
| 1953 |
//! \param [in] ctxID |
| 1954 |
//! context ID |
| 1955 |
//! |
| 1956 |
//! \return VAStatus |
| 1957 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1958 |
//! |
| 1959 |
static VAStatus DestroyContextCM( |
| 1960 |
VADriverContextP ctx, |
| 1961 |
VAContextID ctxID); |
| 1962 |
|
| 1963 |
//! |
| 1964 |
//! \brief Init SurfaceDescriptor Without AuxTableMgr |
| 1965 |
//! |
| 1966 |
//! \param [out] desc |
| 1967 |
//! SurfaceDescriptor |
| 1968 |
//! \param [in] formats |
| 1969 |
//! DRM format |
| 1970 |
//! \param [in] compositeObject |
| 1971 |
//! compostie layer flag |
| 1972 |
//! \param [in] planesNum |
| 1973 |
//! planes num |
| 1974 |
//! \param [in] offsetY |
| 1975 |
//! Y channel offset |
| 1976 |
//! \param [in] offsetU |
| 1977 |
//! U channel offset |
| 1978 |
//! \param [in] offsetV |
| 1979 |
//! V channel offset |
| 1980 |
//! \param [in] pitch |
| 1981 |
//! surface pitch |
| 1982 |
//! \param [in] chromaPitch |
| 1983 |
//! chromaPitch pitch |
| 1984 |
//! |
| 1985 |
//! \return VAStatus |
| 1986 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 1987 |
//! |
| 1988 |
static VAStatus InitSurfaceDescriptorWithoutAuxTableMgr( |
| 1989 |
VADRMPRIMESurfaceDescriptor *desc, |
| 1990 |
uint32_t *formats, |
| 1991 |
int compositeObject, |
| 1992 |
uint32_t planesNum, |
| 1993 |
uint32_t offsetY, |
| 1994 |
uint32_t offsetU, |
| 1995 |
uint32_t offsetV, |
| 1996 |
uint32_t pitch, |
| 1997 |
uint32_t chromaPitch); |
| 1998 |
|
| 1999 |
//! |
| 2000 |
//! \brief Init SurfaceDescriptor With AuxTableMgr |
| 2001 |
//! |
| 2002 |
//! \param [out] desc |
| 2003 |
//! SurfaceDescriptor |
| 2004 |
//! \param [in] formats |
| 2005 |
//! DRM format |
| 2006 |
//! \param [in] compositeObject |
| 2007 |
//! compostie layer flag |
| 2008 |
//! \param [in] planesNum |
| 2009 |
//! planes num |
| 2010 |
//! \param [in] offsetY |
| 2011 |
//! Y channel offset |
| 2012 |
//! \param [in] offsetU |
| 2013 |
//! U channel offset |
| 2014 |
//! \param [in] offsetv |
| 2015 |
//! U channel offset |
| 2016 |
//! \param [in] auxOffsetY |
| 2017 |
//! Y channel aux offset |
| 2018 |
//! \param [in] auxOffsetUV |
| 2019 |
//! UV channel aux offset |
| 2020 |
//! \param [in] pitch |
| 2021 |
//! surface pitch |
| 2022 |
//! |
| 2023 |
//! \return VAStatus |
| 2024 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 2025 |
//! |
| 2026 |
static VAStatus InitSurfaceDescriptorWithAuxTableMgr( |
| 2027 |
VADRMPRIMESurfaceDescriptor *desc, |
| 2028 |
uint32_t *formats, |
| 2029 |
int compositeObject, |
| 2030 |
uint32_t planesNum, |
| 2031 |
uint32_t offsetY, |
| 2032 |
uint32_t offsetU, |
| 2033 |
uint32_t offsetV, |
| 2034 |
uint32_t auxOffsetY, |
| 2035 |
uint32_t auxOffsetUV, |
| 2036 |
int32_t pitch); |
| 2037 |
|
| 2038 |
//! |
| 2039 |
//! \brief Generate Vaimg From input Media format |
| 2040 |
//! |
| 2041 |
//! \param [in] mediaSurface |
| 2042 |
//! Media surface |
| 2043 |
//! \param [in] mediaCtx |
| 2044 |
//! Media context |
| 2045 |
//! \param [out] vaimg |
| 2046 |
//! vaimg |
| 2047 |
//! |
| 2048 |
//! \return VAStatus |
| 2049 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 2050 |
//! |
| 2051 |
static VAStatus GenerateVaImgFromMediaFormat( |
| 2052 |
DDI_MEDIA_SURFACE *mediaSurface, |
| 2053 |
PDDI_MEDIA_CONTEXT mediaCtx, |
| 2054 |
VAImage *vaimg); |
| 2055 |
|
| 2056 |
//! |
| 2057 |
//! \brief Generate Vaimg From input OS format |
| 2058 |
//! |
| 2059 |
//! \param [in] format |
| 2060 |
//! Os format type |
| 2061 |
//! \param [out] vaimg |
| 2062 |
//! vaimg |
| 2063 |
//! |
| 2064 |
//! \return VAStatus |
| 2065 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 2066 |
//! |
| 2067 |
static VAStatus GenerateVaImgFromOsFormat( |
| 2068 |
VAImageFormat format, |
| 2069 |
int32_t width, |
| 2070 |
int32_t height, |
| 2071 |
GMM_RESOURCE_INFO *gmmResourceInfo, |
| 2072 |
VAImage *vaimg); |
| 2073 |
|
| 2074 |
//! |
| 2075 |
//! \brief Convert Rt format to OS format |
| 2076 |
//! |
| 2077 |
//! \param [in] format |
| 2078 |
//! RT format type |
| 2079 |
//! \param [out] expectedFourcc |
| 2080 |
//! Os format type |
| 2081 |
//! |
| 2082 |
//! \return VAStatus |
| 2083 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 2084 |
//! |
| 2085 |
static VAStatus RtFormatToOsFormat(uint32_t format, int32_t &expectedFourcc); |
| 2086 |
|
| 2087 |
//! |
| 2088 |
//! \brief Convert Os format to media format |
| 2089 |
//! |
| 2090 |
//! \param [in] fourcc |
| 2091 |
//! FourCC |
| 2092 |
//! \param [in] rtformatType |
| 2093 |
//! Rt format type |
| 2094 |
//! |
| 2095 |
//! \return DDI_MEDIA_FORMAT |
| 2096 |
//! Ddi media format |
| 2097 |
//! |
| 2098 |
static DDI_MEDIA_FORMAT OsFormatToMediaFormat(int32_t fourcc, int32_t rtformatType); |
| 2099 |
|
| 2100 |
//! |
| 2101 |
//! \brief create render target |
| 2102 |
//! |
| 2103 |
//! \param [in] mediaDrvCtx |
| 2104 |
//! Pointer to media context |
| 2105 |
//! \param [in] mediaFormat |
| 2106 |
//! media format |
| 2107 |
//! \param [in] width |
| 2108 |
//! width |
| 2109 |
//! \param [in] height |
| 2110 |
//! height |
| 2111 |
//! \param [in] surfDesc |
| 2112 |
//! media surface descriptor |
| 2113 |
//! \param [in] surfaceUsageHint |
| 2114 |
//! surface usage hint |
| 2115 |
//! \param [in] memType |
| 2116 |
//! memory type |
| 2117 |
//! \return uint_32 |
| 2118 |
//! surface ID |
| 2119 |
//! |
| 2120 |
static uint32_t CreateRenderTarget( |
| 2121 |
PDDI_MEDIA_CONTEXT mediaDrvCtx, |
| 2122 |
DDI_MEDIA_FORMAT mediaFormat, |
| 2123 |
uint32_t width, |
| 2124 |
uint32_t height, |
| 2125 |
DDI_MEDIA_SURFACE_DESCRIPTOR *surfDesc, |
| 2126 |
uint32_t surfaceUsageHint, |
| 2127 |
int memType); |
| 2128 |
|
| 2129 |
public: |
| 2130 |
//! |
| 2131 |
//! \brief Map buffer |
| 2132 |
//! |
| 2133 |
//! \param [in] ctx |
| 2134 |
//! Pointer to VA driver context |
| 2135 |
//! \param [in] buf_id |
| 2136 |
//! VA buffer id |
| 2137 |
//! \param [in] pbuf |
| 2138 |
//! Address of buffer |
| 2139 |
//! |
| 2140 |
//! \return VAStatus |
| 2141 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 2142 |
//! |
| 2143 |
static VAStatus MapBuffer( |
| 2144 |
VADriverContextP ctx, |
| 2145 |
VABufferID buf_id, |
| 2146 |
void **pbuf); |
| 2147 |
|
| 2148 |
//! |
| 2149 |
//! \brief Map data store of the buffer into the client's address space |
| 2150 |
//! vaCreateBuffer() needs to be called with "data" set to nullptr before calling vaMapBuffer() |
| 2151 |
//! |
| 2152 |
//! \param [in] ctx |
| 2153 |
//! Pointer to VA driver context |
| 2154 |
//! \param [in] bufId |
| 2155 |
//! VA buffer ID |
| 2156 |
//! \param [out] buf |
| 2157 |
//! Pointer to buffer |
| 2158 |
//! \param [in] flag |
| 2159 |
//! Flag |
| 2160 |
//! |
| 2161 |
//! \return VAStatus |
| 2162 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 2163 |
//! |
| 2164 |
static VAStatus MapBufferInternal( |
| 2165 |
VADriverContextP ctx, |
| 2166 |
VABufferID bufId, |
| 2167 |
void **buf, |
| 2168 |
uint32_t flag); |
| 2169 |
|
| 2170 |
//! \brief Unmap buffer |
| 2171 |
//! |
| 2172 |
//! \param [in] ctx |
| 2173 |
//! Pointer to VA driver context |
| 2174 |
//! \param [in] bufId |
| 2175 |
//! VA buffer ID |
| 2176 |
//! |
| 2177 |
//! \return VAStatus |
| 2178 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 2179 |
//! |
| 2180 |
static VAStatus UnmapBuffer( |
| 2181 |
VADriverContextP ctx, |
| 2182 |
VABufferID bufId); |
| 2183 |
|
| 2184 |
//! |
| 2185 |
//! \brief Decompress a compressed surface. |
| 2186 |
//! |
| 2187 |
//! \param [in] mediaCtx |
| 2188 |
//! Pointer to ddi media context |
| 2189 |
//! \param [in] mediaSurface |
| 2190 |
//! Ddi media surface |
| 2191 |
//! |
| 2192 |
//! \return VAStatus |
| 2193 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 2194 |
//! |
| 2195 |
static VAStatus MediaMemoryDecompress( |
| 2196 |
PDDI_MEDIA_CONTEXT mediaCtx, |
| 2197 |
DDI_MEDIA_SURFACE *mediaSurface); |
| 2198 |
|
| 2199 |
public: |
| 2200 |
// Global mutex |
| 2201 |
static MEDIA_MUTEX_T m_GlobalMutex; |
| 2202 |
MEDIA_CLASS_DEFINE_END(MediaLibvaInterfaceNext) |
| 2203 |
}; |
| 2204 |
|
| 2205 |
#endif //__MEDIA_LIBVA_INTERFACE_NEXT_H__ |