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