psb_drv_video.h revision 81826d3ab4c9cf28ea853f1545042aa53a0f0abf
1/* 2 * Copyright (c) 2011 Intel Corporation. All Rights Reserved. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the 6 * "Software"), to deal in the Software without restriction, including 7 * without limitation the rights to use, copy, modify, merge, publish, 8 * distribute, sub license, and/or sell copies of the Software, and to 9 * permit persons to whom the Software is furnished to do so, subject to 10 * the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the 13 * next paragraph) shall be included in all copies or substantial portions 14 * of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 * 24 * Authors: 25 * Waldo Bastian <waldo.bastian@intel.com> 26 * 27 */ 28 29#ifndef _PSB_DRV_VIDEO_H_ 30#define _PSB_DRV_VIDEO_H_ 31 32#include <pthread.h> /* POSIX threads headers */ 33 34#include <va/va_backend.h> 35#include <va/va.h> 36#ifdef PSBVIDEO_MRFL_VPP 37#include <va/va_vpp.h> 38#endif 39#ifdef PSBVIDEO_MFLD 40#include <va/va_vpp.h> 41#endif 42#include "object_heap.h" 43#include "psb_def.h" 44//#include "psb_drv_debug.h" 45#include "xf86drm.h" 46#ifdef ANDROID 47#include <linux/psb_drm.h> 48#endif 49#include "psb_overlay.h" 50#include "psb_texture.h" 51#include <stdint.h> 52#ifndef ANDROID 53#include <psb_drm.h> 54#include <X11/Xlibint.h> 55#include <X11/X.h> 56#include <X11/extensions/Xv.h> 57#include <X11/extensions/Xvlib.h> 58#include <X11/Xlib.h> 59#else 60#define XID unsigned int 61#define INT16 unsigned int 62#include <cutils/log.h> 63#include <system/window.h> 64#undef LOG_TAG 65#define LOG_TAG "pvr_drv_video" 66#endif 67#include "hwdefs/dxva_fw_flags.h" 68#include <wsbm/wsbm_pool.h> 69 70#ifndef min 71#define min(a, b) ((a) < (b)) ? (a) : (b) 72#endif 73 74#ifndef max 75#define max(a, b) ((a) > (b)) ? (a) : (b) 76#endif 77 78//#define _TOPAZHP_VIRTUAL_ 79#define _TOPAZHP_VIR_ADDR_ 80#define _TOPAZHP_SLICE_PARAM_ 81#define _TOPAZHP_PDUMP_ 82//#define _TOPAZHP_PDUMP_ALL_ 83#define _TOPAZHP_OLD_LIBVA_ 84#define FORCED_REFERENCE 1 85#define LTREFHEADER 1 86//#define _TP_DEBUG_MMU_ 87//#define _TOPAZHP_REC_ 88 89/* 90 * WORKAROUND_DMA_OFF_BY_ONE: LLDMA requests may access one additional byte which can cause 91 * a MMU fault if the next byte after the buffer end is on a different page that isn't mapped. 92 */ 93#define WORKAROUND_DMA_OFF_BY_ONE 94#define FOURCC_XVVA (('A' << 24) + ('V' << 16) + ('V' << 8) + 'X') 95 96#ifdef PSBVIDEO_MRFL_VPP 97#define PSB_MAX_PROFILES VAProfileMax 98#define PSB_MAX_ENTRYPOINTS VAEntrypointMax 99#define PSB_MAX_CONFIG_ATTRIBUTES VAConfigAttribTypeMax 100#define PSB_MAX_BUFFERTYPES VABufferTypeMax 101#else 102#define PSB_MAX_PROFILES 18 103#define PSB_MAX_ENTRYPOINTS VAEntrypointMax 104#define PSB_MAX_CONFIG_ATTRIBUTES 10 105#define PSB_MAX_BUFFERTYPES VABufferTypeMax 106#endif 107 108/* Max # of command submission buffers */ 109#define PSB_MAX_CMDBUFS 10 110#define LNC_MAX_CMDBUFS_ENCODE 4 111#define PNW_MAX_CMDBUFS_ENCODE 4 112#define TNG_MAX_CMDBUFS_ENCODE 4 113#define VSP_MAX_CMDBUFS 10 114 115#define PSB_SURFACE_DISPLAYING_F (0x1U<<0) 116#define PSB_SURFACE_IS_FLAG_SET(flags, mask) (((flags)& PSB_SURFACE_DISPLAYING_F) != 0) 117 118#define PSB_CTX_TILING_MASK 0x00FF0000 119 120/*xrandr dirty flag*/ 121#define PSB_NEW_ROTATION 1 122#define PSB_NEW_EXTVIDEO 2 123 124#define PSB_NEW_VA_ROTATION 1 << 0 125#define PSB_NEW_WM_ROTATION 1 << 1 126 127#define MAX_SLICES_PER_PICTURE 72 128#define MAX_MB_ERRORS 72 129 130/* Some funtions aren't used but we'd like to keep them as reference code in future */ 131#define PSB_MFLD_DUMMY_CODE 0 132 133typedef struct object_config_s *object_config_p; 134typedef struct object_context_s *object_context_p; 135typedef struct object_surface_s *object_surface_p; 136typedef struct object_buffer_s *object_buffer_p; 137typedef struct object_image_s *object_image_p; 138typedef struct object_subpic_s *object_subpic_p; 139typedef struct format_vtable_s *format_vtable_p; 140typedef struct psb_driver_data_s *psb_driver_data_p; 141 142typedef struct psb_surface_share_info_s psb_surface_share_info_t, *psb_surface_share_info_p; 143/* post-processing data structure */ 144enum psb_output_method_t { 145 PSB_PUTSURFACE_NONE = 0, 146 PSB_PUTSURFACE_X11,/* use x11 method */ 147 PSB_PUTSURFACE_TEXTURE,/* texture xvideo */ 148 PSB_PUTSURFACE_OVERLAY,/* overlay xvideo */ 149 PSB_PUTSURFACE_COVERLAY,/* client overlay */ 150 PSB_PUTSURFACE_CTEXTURE,/* client textureblit */ 151 PSB_PUTSURFACE_TEXSTREAMING,/* texsteaming */ 152 PSB_PUTSURFACE_FORCE_TEXTURE,/* force texture xvideo */ 153 PSB_PUTSURFACE_FORCE_OVERLAY,/* force overlay xvideo */ 154 PSB_PUTSURFACE_FORCE_CTEXTURE,/* force client textureblit */ 155 PSB_PUTSURFACE_FORCE_COVERLAY,/* force client overlay */ 156 PSB_PUTSURFACE_FORCE_TEXSTREAMING,/* force texstreaming */ 157}; 158 159typedef struct psb_decode_info { 160 uint32_t num_surface; 161 uint32_t surface_id; 162} psb_decode_info_t; 163typedef struct msvdx_decode_info *psb_decode_info_p; 164 165#define CSC_MATRIX_X (3) 166#define CSC_MATRIX_Y (3) 167 168struct psb_driver_data_s { 169 struct object_heap_s config_heap; 170 struct object_heap_s context_heap; 171 struct object_heap_s surface_heap; 172 struct object_heap_s buffer_heap; 173 struct object_heap_s image_heap; 174 struct object_heap_s subpic_heap; 175 char * bus_id; 176 uint32_t dev_id; 177 int drm_fd; 178 int dup_drm_fd; 179 180 /* PM_QoS */ 181 int pm_qos_fd; 182 int dri2; 183 int dri_dummy; 184 XID context_id; 185 drm_context_t drm_context; 186 drmLock *drm_lock; 187 int contended_lock; 188 pthread_mutex_t drm_mutex; 189 format_vtable_p profile2Format[PSB_MAX_PROFILES][PSB_MAX_ENTRYPOINTS]; 190#ifdef PSBVIDEO_MRFL_VPP 191 format_vtable_p vpp_profile; 192#endif 193#ifdef PSBVIDEO_MFLD 194 format_vtable_p vpp_profile; 195#endif 196 uint32_t msvdx_context_base; 197 int video_sd_disabled; 198 int video_hd_disabled; 199 unsigned char * camera_bo; 200 uint32_t camera_phyaddr; 201 uint32_t camera_size; 202 unsigned char * rar_bo; 203 uint32_t rar_phyaddr; 204 uint32_t rar_size; 205 206 int encode_supported; 207 int decode_supported; 208 int hd_encode_supported; 209 int hd_decode_supported; 210 211 int execIoctlOffset; 212 int getParamIoctlOffset; 213 214 struct _WsbmBufferPool *main_pool; 215 struct _WsbmFenceMgr *fence_mgr; 216 217 enum psb_output_method_t output_method; 218 219 /* whether the post-processing use client overlay or not */ 220 int coverlay; 221 int coverlay_init; 222 PsbPortPrivRec coverlay_priv; 223 224 225 /* whether the post-processing use client textureblit or not */ 226 int ctexture; 227 struct psb_texture_s ctexture_priv; 228 229 /* 230 //whether the post-processing use texstreaing or not 231 int ctexstreaing; 232 struct psb_texstreaing ctexstreaing_priv; 233 */ 234 235 unsigned char *ws_priv; /* window system related data structure */ 236 237 238 VASurfaceID cur_displaying_surface; 239 VASurfaceID last_displaying_surface; 240 241 VADisplayAttribute ble_black_mode; 242 VADisplayAttribute ble_white_mode; 243 244 VADisplayAttribute blueStretch_gain; 245 VADisplayAttribute skinColorCorrection_gain; 246 247 VADisplayAttribute brightness; 248 VADisplayAttribute hue; 249 VADisplayAttribute contrast; 250 VADisplayAttribute saturation; 251 /*Save RenderMode and RenderRect attribute 252 * for medfield android extend video mode.*/ 253 uint32_t render_device; 254 uint32_t render_mode; 255 VARectangle render_rect; 256 257 unsigned int clear_color; 258 259 int is_oold; 260 261 unsigned int load_csc_matrix; 262 signed int csc_matrix[CSC_MATRIX_X][CSC_MATRIX_Y]; 263 264 /* subpic number current buffers support */ 265 unsigned int max_subpic; 266 267 /* for multi-thread safe */ 268 int use_xrandr_thread; 269 pthread_mutex_t output_mutex; 270 pthread_t xrandr_thread_id; 271 int extend_fullscreen; 272 273 int drawable_info; 274 int dummy_putsurface; 275 int fixed_fps; 276 unsigned int frame_count; 277 278 uint32_t blend_mode; 279 uint32_t blend_color; 280 uint32_t overlay_auto_paint_color_key; 281 uint32_t color_key; 282 283 /*output rotation info*/ 284 int disable_msvdx_rotate; 285 int disable_msvdx_rotate_backup; 286 int msvdx_rotate_want; /* msvdx rotate info programed to msvdx */ 287 int va_rotate; /* VA rotate passed from APP */ 288 int mipi0_rotation; /* window manager rotation */ 289 int mipi1_rotation; /* window manager rotation */ 290 int hdmi_rotation; /* window manager rotation */ 291 int local_rotation; /* final device rotate: VA rotate+wm rotate */ 292 int extend_rotation; /* final device rotate: VA rotate+wm rotate */ 293 int rotation_dirty; /*flag for recaculate final rotation*/ 294 295 unsigned int outputmethod_checkinterval; 296 297 uint32_t xrandr_dirty; 298 uint32_t xrandr_update; 299 /*only VAProfileH264ConstrainedBaseline profile enable error concealment*/ 300 uint32_t ec_enabled; 301 302 uint32_t pre_surfaceid; 303 psb_decode_info_t decode_info; 304 drm_psb_msvdx_decode_status_t *msvdx_decode_status; 305 VASurfaceDecodeMBErrors *surface_mb_error; 306 307 unsigned char *hPVR2DContext; 308 309 VAGenericID wrapped_surface_id[VIDEO_BUFFER_NUM]; 310 VAGenericID wrapped_subpic_id[VIDEO_BUFFER_NUM]; 311 PVR2DMEMINFO *videoBuf[VIDEO_BUFFER_NUM]; 312 PVR2DMEMINFO *subpicBuf[VIDEO_BUFFER_NUM]; 313 void *native_window; 314 int is_android; 315 /* VA_RT_FORMAT_PROTECTED is set to protected for Widevine case */ 316 int protected; 317}; 318 319 320#ifdef _FOR_FPGA_ 321#define IS_CTP(driver_data) 0 322#define IS_MFLD(driver_data) 0 323#define IS_MRFL(driver_data) 1 324#define IS_MRST(driver_data) 0 325#else 326#define IS_CTP(driver_data) (((driver_data->dev_id & 0xffff) == 0x08c0) || \ 327 ((driver_data->dev_id & 0xffff) == 0x08c7) || \ 328 ((driver_data->dev_id & 0xffff) == 0x08c8)) 329#define IS_MRST(driver_data) ((driver_data->dev_id & 0xFFFC) == 0x4100) 330#define IS_MFLD(driver_data) (((driver_data->dev_id & 0xFFFC) == 0x0130) || ((driver_data->dev_id & 0xFFFF) == 0x08C0) || ((driver_data->dev_id & 0xFFFF) == 0x08C7) || ((driver_data->dev_id & 0xFFFF) == 0x01FF) || ((driver_data->dev_id & 0xFFFF) == 0x08C8)) 331#define IS_MRFL(driver_data) ((driver_data->dev_id & 0xFFFC) == 0x1180) 332#define IS_LEXINGTON(driver_data) ((driver_data->dev_id & 0xFFFF) == 0x01FF) 333#endif 334 335struct object_config_s { 336 struct object_base_s base; 337 VAProfile profile; 338 VAEntrypoint entrypoint; 339 VAConfigAttrib attrib_list[PSB_MAX_CONFIG_ATTRIBUTES]; 340 int attrib_count; 341 format_vtable_p format_vtable; 342}; 343 344struct object_context_s { 345 struct object_base_s base; 346 VAContextID context_id; 347 VAConfigID config_id; 348 VAProfile profile; 349 VAEntrypoint entry_point; 350 int picture_width; 351 int picture_height; 352 int num_render_targets; 353 VASurfaceID *render_targets; 354 int va_flags; 355 356 object_surface_p current_render_target; 357 object_surface_p ec_target; 358 object_surface_p ec_candidate; 359 VASurfaceID current_render_surface_id; 360 psb_driver_data_p driver_data; 361 format_vtable_p format_vtable; 362 unsigned char *format_data; 363 struct psb_cmdbuf_s *cmdbuf_list[PSB_MAX_CMDBUFS]; 364 struct lnc_cmdbuf_s *lnc_cmdbuf_list[LNC_MAX_CMDBUFS_ENCODE]; 365 struct pnw_cmdbuf_s *pnw_cmdbuf_list[PNW_MAX_CMDBUFS_ENCODE]; 366 struct tng_cmdbuf_s *tng_cmdbuf_list[TNG_MAX_CMDBUFS_ENCODE]; 367#ifdef PSBVIDEO_MRFL_VPP 368 struct vsp_cmdbuf_s *vsp_cmdbuf_list[VSP_MAX_CMDBUFS]; 369#endif 370 371 struct psb_cmdbuf_s *cmdbuf; /* Current cmd buffer */ 372 struct lnc_cmdbuf_s *lnc_cmdbuf; 373 struct pnw_cmdbuf_s *pnw_cmdbuf; 374 struct tng_cmdbuf_s *tng_cmdbuf; 375#ifdef PSBVIDEO_MRFL_VPP 376 struct vsp_cmdbuf_s *vsp_cmdbuf; 377#endif 378 379 int cmdbuf_current; 380 381 /* Buffers */ 382 object_buffer_p buffers_unused[PSB_MAX_BUFFERTYPES]; /* Linked lists (HEAD) of unused buffers for each buffer type */ 383 int buffers_unused_count[PSB_MAX_BUFFERTYPES]; /* Linked lists (HEAD) of unused buffers for each buffer type */ 384 object_buffer_p buffers_unused_tail[PSB_MAX_BUFFERTYPES]; /* Linked lists (TAIL) of unused buffers for each buffer type */ 385 object_buffer_p buffers_active[PSB_MAX_BUFFERTYPES]; /* Linked lists of active buffers for each buffer type */ 386 387 object_buffer_p *buffer_list; /* for vaRenderPicture */ 388 int num_buffers; 389 390 enum { 391 psb_video_none = 0, 392 psb_video_mc, 393 psb_video_vld, 394 psb_video_deblock 395 } video_op; 396 397 uint32_t operating_mode; 398 uint32_t flags; /* See render flags below */ 399 uint32_t first_mb; 400 uint32_t last_mb; 401 402 int is_oold; 403 int msvdx_rotate; 404 int interlaced_stream; 405 unsigned long ctp_type; 406 unsigned long msvdx_tile; /* normal tile | (rotate tile << 4) */ 407 408 uint32_t msvdx_context; 409 410 /* Debug */ 411 uint32_t frame_count; 412 uint32_t slice_count; 413}; 414 415#define ROTATE_VA2MSVDX(va_rotate) (va_rotate) 416#define CONTEXT_ROTATE(obj_context) (obj_context->msvdx_rotate != ROTATE_VA2MSVDX(VA_ROTATION_NONE)) 417 418enum force_output_method_t { 419 OUTPUT_FORCE_NULL = 0, 420 OUTPUT_FORCE_GPU, 421 OUTPUT_FORCE_OVERLAY, 422}; 423 424#define MAX_SHARE_INFO_KHANDLES 32 425struct psb_surface_share_info_s { 426 //int rotation_sf; /*rotaion degree from surface flinger.*/ 427 int surface_rotate; /*rotation degree of current rotation surface*/ 428 int metadata_rotate; /*rotation degree of meta data*/ 429 int width_r; 430 int height_r; 431 int surface_protected; /*whether this surface need be protected*/ 432 /*Force render path. 433 0 : no fore. 434 1 : force gpu render; 435 2 : force overlay render.*/ 436 int force_output_method; 437 unsigned int rotate_khandle; 438 unsigned int renderStatus; 439 unsigned int used_by_widi; 440 int bob_deinterlace; 441 int tiling; 442 unsigned int width; 443 unsigned int height; 444 unsigned int luma_stride; 445 unsigned int chroma_u_stride; 446 unsigned int chroma_v_stride; 447 unsigned int format; 448 unsigned int khandle; 449 long long timestamp; 450 451 unsigned int rotate_luma_stride; 452 unsigned int rotate_chroma_u_stride; 453 unsigned int rotate_chroma_v_stride; 454 void *native_window; 455}; 456 457struct object_surface_s { 458 struct object_base_s base; 459 VASurfaceID surface_id; 460 VAContextID context_id; 461 int width; 462 int height; 463 int height_origin; 464 int width_r; 465 int height_r; 466 struct psb_surface_s *psb_surface; 467 struct psb_surface_s *psb_surface_rotate; /* Alternative output surface for rotation */ 468 void *subpictures;/* if not NULL, have subpicture information */ 469 unsigned int subpic_count; /* to ensure output have enough space for PDS & RAST */ 470 unsigned int derived_imgcnt; /* is the surface derived by a VAImage? */ 471 unsigned long display_timestamp; /* record the time point of put surface*/ 472 void *rotate_vaddr; 473 struct psb_surface_share_info_s *share_info; 474}; 475 476#define PSB_CODEDBUF_SLICE_NUM_MASK (0xff) 477#define PSB_CODEDBUF_SLICE_NUM_SHIFT (0) 478 479#define PSB_CODEDBUF_NONE_VCL_NUM_MASK (0xff) 480#define PSB_CODEDBUF_NONE_VCL_NUM_SHIFT (8) 481 482#define SET_CODEDBUF_INFO(flag, aux_info, slice_num) \ 483 do {\ 484 (aux_info) &= ~(PSB_CODEDBUF_##flag##_MASK<<PSB_CODEDBUF_##flag##_SHIFT);\ 485 (aux_info) |= ((slice_num) & PSB_CODEDBUF_##flag##_MASK)\ 486 <<PSB_CODEDBUF_##flag##_SHIFT;\ 487 } while (0) 488 489#define CLEAR_CODEDBUF_INFO(flag, aux_info) \ 490 do {\ 491 (aux_info) &= ~(PSB_CODEDBUF_##flag##_MASK<<PSB_CODEDBUF_##flag##_SHIFT);\ 492 } while (0) 493 494#define GET_CODEDBUF_INFO(flag, aux_info) \ 495 (((aux_info)>>PSB_CODEDBUF_##flag##_SHIFT) & PSB_CODEDBUF_##flag##_MASK) 496 497 498#define PSB_CODEDBUF_SEGMENT_MAX (8) 499 500struct object_buffer_s { 501 struct object_base_s base; 502 object_buffer_p ptr_next; /* Generic ptr for linked list */ 503 object_buffer_p *pptr_prev_next; /* Generic ptr for linked list */ 504 struct psb_buffer_s *psb_buffer; 505 unsigned char *buffer_data; 506 unsigned int size; 507 unsigned int alloc_size; 508 unsigned int max_num_elements; 509 unsigned int num_elements; 510 object_context_p context; 511 VABufferType type; 512 uint32_t last_used; 513 514 /* for VAEncCodedBufferType */ 515 VACodedBufferSegment codedbuf_mapinfo[PSB_CODEDBUF_SEGMENT_MAX]; 516 uint32_t codedbuf_aux_info; 517}; 518 519struct object_image_s { 520 struct object_base_s base; 521 VAImage image; 522 unsigned int palette[16]; 523 int subpic_ref; 524 VASurfaceID derived_surface; 525}; 526 527struct object_subpic_s { 528 struct object_base_s base; 529 VASubpictureID subpic_id; 530 531 VAImageID image_id; 532 533 /* chromakey range */ 534 unsigned int chromakey_min; 535 unsigned int chromakey_max; 536 unsigned int chromakey_mask; 537 538 /* global alpha */ 539 unsigned int global_alpha; 540 541 /* flags */ 542 unsigned int flags; /* see below */ 543 544 unsigned char *surfaces; /* surfaces, associated with this subpicture */ 545}; 546 547#define MEMSET_OBJECT(ptr, data_struct) \ 548 memset((unsigned char *)ptr + sizeof(struct object_base_s),\ 549 0, \ 550 sizeof(data_struct) - sizeof(struct object_base_s)) 551 552struct format_vtable_s { 553 void (*queryConfigAttributes)( 554 VAProfile profile, 555 VAEntrypoint entrypoint, 556 VAConfigAttrib *attrib_list, 557 int num_attribs 558 ); 559 VAStatus(*validateConfig)( 560 object_config_p obj_config 561 ); 562 VAStatus(*createContext)( 563 object_context_p obj_context, 564 object_config_p obj_config 565 ); 566 void (*destroyContext)( 567 object_context_p obj_context 568 ); 569 VAStatus(*beginPicture)( 570 object_context_p obj_context 571 ); 572 VAStatus(*renderPicture)( 573 object_context_p obj_context, 574 object_buffer_p *buffers, 575 int num_buffers 576 ); 577 VAStatus(*endPicture)( 578 object_context_p obj_context 579 ); 580}; 581 582#ifdef ANDROID 583typedef struct IMG_native_handle 584{ 585 native_handle_t base; 586 int fd; 587 unsigned long long ui64Stamp; 588 int usage; 589 int width; 590 int height; 591 unsigned int bpp; 592 int format; 593} IMG_native_handle_t; 594#endif 595 596#define psb__bounds_check(x, max) \ 597 do { ASSERT(x < max); if (x >= max) x = max - 1; } while(0); 598 599static inline unsigned long GetTickCount() 600{ 601 struct timeval tv; 602 if (gettimeofday(&tv, NULL)) 603 return 0; 604 return tv.tv_usec / 1000 + tv.tv_sec * 1000; 605} 606 607inline static char * buffer_type_to_string(int type) 608{ 609 switch (type) { 610 case VAPictureParameterBufferType: 611 return "VAPictureParameterBufferType"; 612 case VAIQMatrixBufferType: 613 return "VAIQMatrixBufferType"; 614 case VABitPlaneBufferType: 615 return "VABitPlaneBufferType"; 616 case VASliceGroupMapBufferType: 617 return "VASliceGroupMapBufferType"; 618 case VASliceParameterBufferType: 619 return "VASliceParameterBufferType"; 620 case VASliceDataBufferType: 621 return "VASliceDataBufferType"; 622 case VAProtectedSliceDataBufferType: 623 return "VAProtectedSliceDataBufferType"; 624 case VAMacroblockParameterBufferType: 625 return "VAMacroblockParameterBufferType"; 626 case VAResidualDataBufferType: 627 return "VAResidualDataBufferType"; 628 case VADeblockingParameterBufferType: 629 return "VADeblockingParameterBufferType"; 630 case VAImageBufferType: 631 return "VAImageBufferType"; 632 case VAEncCodedBufferType: 633 return "VAEncCodedBufferType"; 634 case VAEncSequenceParameterBufferType: 635 return "VAEncSequenceParameterBufferType"; 636 case VAEncPictureParameterBufferType: 637 return "VAEncPictureParameterBufferType"; 638 case VAEncSliceParameterBufferType: 639 return "VAEncSliceParameterBufferType"; 640 case VAEncMiscParameterBufferType: 641 return "VAEncMiscParameterBufferType"; 642 case VAProbabilityBufferType: 643 return "VAProbabilityBufferType"; 644 case VAHuffmanTableBufferType: 645 return "VAHuffmanTableBufferType"; 646 default: 647 return "UnknowBuffer"; 648 } 649} 650 651inline static int Angle2Rotation(int angle) 652{ 653 angle %= 360; 654 switch (angle) { 655 case 0: 656 return VA_ROTATION_NONE; 657 case 90: 658 return VA_ROTATION_90; 659 case 180: 660 return VA_ROTATION_180; 661 case 270: 662 return VA_ROTATION_270; 663 default: 664 return -1; 665 } 666} 667 668inline static int Rotation2Angle(int rotation) 669{ 670 switch (rotation) { 671 case VA_ROTATION_NONE: 672 return 0; 673 case VA_ROTATION_90: 674 return 90; 675 case VA_ROTATION_180: 676 return 180; 677 case VA_ROTATION_270: 678 return 270; 679 default: 680 return -1; 681 } 682} 683 684int psb_parse_config(char *env, char *env_value); 685void psb__destroy_surface(psb_driver_data_p driver_data, object_surface_p obj_surface); 686unsigned long psb_tile_stride_mode(int w); 687 688int LOCK_HARDWARE(psb_driver_data_p driver_data); 689int UNLOCK_HARDWARE(psb_driver_data_p driver_data); 690 691#define CHECK_SURFACE(obj_surface) \ 692 do { \ 693 if (NULL == obj_surface) { \ 694 vaStatus = VA_STATUS_ERROR_INVALID_SURFACE; \ 695 DEBUG_FAILURE; \ 696 return vaStatus; \ 697 } \ 698 } while (0) 699 700#define CHECK_CONFIG(obj_config) \ 701 do { \ 702 if (NULL == obj_config) { \ 703 vaStatus = VA_STATUS_ERROR_INVALID_CONFIG; \ 704 DEBUG_FAILURE; \ 705 return vaStatus; \ 706 } \ 707 } while (0) 708 709#define CHECK_CONTEXT(obj_context) \ 710 do { \ 711 if (NULL == obj_context) { \ 712 vaStatus = VA_STATUS_ERROR_INVALID_CONTEXT; \ 713 DEBUG_FAILURE; \ 714 return vaStatus; \ 715 } \ 716 } while (0) 717 718#define CHECK_BUFFER(obj_buffer) \ 719 do { \ 720 if (NULL == obj_buffer) { \ 721 vaStatus = VA_STATUS_ERROR_INVALID_BUFFER; \ 722 DEBUG_FAILURE; \ 723 return vaStatus; \ 724 } \ 725 } while (0) 726 727#define CHECK_IMAGE(obj_image) \ 728 do { \ 729 if (NULL == obj_image) { \ 730 vaStatus = VA_STATUS_ERROR_INVALID_IMAGE; \ 731 DEBUG_FAILURE; \ 732 return vaStatus; \ 733 } \ 734 } while (0) 735 736#define CHECK_SUBPICTURE(obj_subpic) \ 737 do { \ 738 if (NULL == obj_subpic) { \ 739 vaStatus = VA_STATUS_ERROR_INVALID_SUBPICTURE; \ 740 DEBUG_FAILURE; \ 741 return vaStatus; \ 742 } \ 743 } while (0) 744 745#define CHECK_ALLOCATION(buf) \ 746 do { \ 747 if (buf == NULL) { \ 748 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; \ 749 DEBUG_FAILURE; \ 750 return vaStatus; \ 751 } \ 752 } while (0) 753 754#define CHECK_VASTATUS() \ 755 do { \ 756 if (VA_STATUS_SUCCESS != vaStatus) { \ 757 DEBUG_FAILURE; \ 758 return vaStatus; \ 759 } \ 760 } while (0) 761 762#define CHECK_INVALID_PARAM(param) \ 763 do { \ 764 if (param) { \ 765 vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; \ 766 DEBUG_FAILURE; \ 767 return vaStatus; \ 768 } \ 769 } while (0) 770 771#endif /* _PSB_DRV_VIDEO_H_ */ 772