psb_drv_video.h revision 4985c4c7c4894dc1feb6b8d678e2f9b9d2f05543
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 37#include <va/va_vpp.h> 38 39#include "object_heap.h" 40#include "psb_def.h" 41//#include "psb_drv_debug.h" 42#include "xf86drm.h" 43#ifdef ANDROID 44#ifdef BAYTRAIL 45#include <linux/vxd_drm.h> 46#else 47#include <linux/psb_drm.h> 48#endif 49#endif 50#include "psb_overlay.h" 51#include "psb_texture.h" 52#include <stdint.h> 53#ifndef ANDROID 54#include <psb_drm.h> 55#include <X11/Xlibint.h> 56#include <X11/X.h> 57#include <X11/extensions/Xv.h> 58#include <X11/extensions/Xvlib.h> 59#include <X11/Xlib.h> 60#else 61#define XID unsigned int 62#define INT16 unsigned int 63#include <cutils/log.h> 64#include <system/window.h> 65#undef LOG_TAG 66#define LOG_TAG "pvr_drv_video" 67#endif 68#include "hwdefs/dxva_fw_flags.h" 69#include <wsbm/wsbm_pool.h> 70 71#ifndef min 72#define min(a, b) ((a) < (b)) ? (a) : (b) 73#endif 74 75#ifndef max 76#define max(a, b) ((a) > (b)) ? (a) : (b) 77#endif 78 79//#define _TOPAZHP_PDUMP_ 80#define TOPAZHP_PIPE_NUM 2 81 82#define _TNG_RELOC_ 83//#define _TNG_FRAMES_ 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#define IS_BAYTRAIL(driver_data) ((driver_data->dev_id & 0xFFFF) == 0x0F31) 334#endif 335 336struct object_config_s { 337 struct object_base_s base; 338 VAProfile profile; 339 VAEntrypoint entrypoint; 340 VAConfigAttrib attrib_list[PSB_MAX_CONFIG_ATTRIBUTES]; 341 int attrib_count; 342 format_vtable_p format_vtable; 343}; 344 345struct object_context_s { 346 struct object_base_s base; 347 VAContextID context_id; 348 VAConfigID config_id; 349 VAProfile profile; 350 VAEntrypoint entry_point; 351 int picture_width; 352 int picture_height; 353 int num_render_targets; 354 VASurfaceID *render_targets; 355 int va_flags; 356 357 object_surface_p current_render_target; 358 object_surface_p ec_target; 359 object_surface_p ec_candidate; 360 VASurfaceID current_render_surface_id; 361 psb_driver_data_p driver_data; 362 format_vtable_p format_vtable; 363 unsigned char *format_data; 364 struct psb_cmdbuf_s *cmdbuf_list[PSB_MAX_CMDBUFS]; 365 struct lnc_cmdbuf_s *lnc_cmdbuf_list[LNC_MAX_CMDBUFS_ENCODE]; 366 struct pnw_cmdbuf_s *pnw_cmdbuf_list[PNW_MAX_CMDBUFS_ENCODE]; 367 struct tng_cmdbuf_s *tng_cmdbuf_list[TNG_MAX_CMDBUFS_ENCODE]; 368#ifdef PSBVIDEO_MRFL_VPP 369 struct vsp_cmdbuf_s *vsp_cmdbuf_list[VSP_MAX_CMDBUFS]; 370#endif 371 372 struct psb_cmdbuf_s *cmdbuf; /* Current cmd buffer */ 373 struct lnc_cmdbuf_s *lnc_cmdbuf; 374 struct pnw_cmdbuf_s *pnw_cmdbuf; 375 struct tng_cmdbuf_s *tng_cmdbuf; 376#ifdef PSBVIDEO_MRFL_VPP 377 struct vsp_cmdbuf_s *vsp_cmdbuf; 378#endif 379 380 int cmdbuf_current; 381 382 /* Buffers */ 383 object_buffer_p buffers_unused[PSB_MAX_BUFFERTYPES]; /* Linked lists (HEAD) of unused buffers for each buffer type */ 384 int buffers_unused_count[PSB_MAX_BUFFERTYPES]; /* Linked lists (HEAD) of unused buffers for each buffer type */ 385 object_buffer_p buffers_unused_tail[PSB_MAX_BUFFERTYPES]; /* Linked lists (TAIL) of unused buffers for each buffer type */ 386 object_buffer_p buffers_active[PSB_MAX_BUFFERTYPES]; /* Linked lists of active buffers for each buffer type */ 387 388 object_buffer_p *buffer_list; /* for vaRenderPicture */ 389 int num_buffers; 390 391 enum { 392 psb_video_none = 0, 393 psb_video_mc, 394 psb_video_vld, 395 psb_video_deblock 396 } video_op; 397 398 uint32_t operating_mode; 399 uint32_t flags; /* See render flags below */ 400 uint32_t first_mb; 401 uint32_t last_mb; 402 403 int is_oold; 404 int msvdx_rotate; 405 int msvdx_scaling; 406 int interlaced_stream; 407 unsigned long ctp_type; 408 unsigned long msvdx_tile; /* normal tile | (rotate tile << 4) */ 409 410 uint32_t msvdx_context; 411 412 /* Debug */ 413 uint32_t frame_count; 414 uint32_t slice_count; 415}; 416 417#define ROTATE_VA2MSVDX(va_rotate) (va_rotate) 418#define CONTEXT_ROTATE(obj_context) (obj_context->msvdx_rotate != ROTATE_VA2MSVDX(VA_ROTATION_NONE)) 419/* #define CONTEXT_SCALING(obj_context) (obj_context->msvdx_scaling) */ 420#define CONTEXT_SCALING(obj_context) (0) 421#define CONTEXT_ALTERNATIVE_OUTPUT(obj_context) (CONTEXT_ROTATE(obj_context) || CONTEXT_SCALING(obj_context)) 422 423enum force_output_method_t { 424 OUTPUT_FORCE_NULL = 0, 425 OUTPUT_FORCE_GPU, 426 OUTPUT_FORCE_OVERLAY, 427}; 428 429#define MAX_SHARE_INFO_KHANDLES 32 430struct psb_surface_share_info_s { 431 //int rotation_sf; /*rotaion degree from surface flinger.*/ 432 int surface_rotate; /*rotation degree of current rotation surface*/ 433 int metadata_rotate; /*rotation degree of meta data*/ 434 int width_r; 435 int height_r; 436 int surface_protected; /*whether this surface need be protected*/ 437 /*Force render path. 438 0 : no fore. 439 1 : force gpu render; 440 2 : force overlay render.*/ 441 int force_output_method; 442 unsigned int rotate_khandle; 443 unsigned int renderStatus; 444 unsigned int used_by_widi; 445 int bob_deinterlace; 446 int tiling; 447 unsigned int width; 448 unsigned int height; 449 unsigned int luma_stride; 450 unsigned int chroma_u_stride; 451 unsigned int chroma_v_stride; 452 unsigned int format; 453 unsigned int khandle; 454 long long timestamp; 455 456 unsigned int rotate_luma_stride; 457 unsigned int rotate_chroma_u_stride; 458 unsigned int rotate_chroma_v_stride; 459 void *native_window; 460}; 461 462struct object_surface_s { 463 struct object_base_s base; 464 VASurfaceID surface_id; 465 VAContextID context_id; 466 int width; 467 int height; 468 int height_origin; 469 int width_r; 470 int height_r; 471 struct psb_surface_s *psb_surface; 472 struct psb_surface_s *psb_surface_rotate; /* Alternative output surface for rotation */ 473 void *subpictures;/* if not NULL, have subpicture information */ 474 unsigned int subpic_count; /* to ensure output have enough space for PDS & RAST */ 475 unsigned int derived_imgcnt; /* is the surface derived by a VAImage? */ 476 unsigned long display_timestamp; /* record the time point of put surface*/ 477 void *rotate_vaddr; 478 struct psb_surface_share_info_s *share_info; 479}; 480 481#define PSB_CODEDBUF_SLICE_NUM_MASK (0xff) 482#define PSB_CODEDBUF_SLICE_NUM_SHIFT (0) 483 484#define PSB_CODEDBUF_NONE_VCL_NUM_MASK (0xff) 485#define PSB_CODEDBUF_NONE_VCL_NUM_SHIFT (8) 486 487#define SET_CODEDBUF_INFO(flag, aux_info, slice_num) \ 488 do {\ 489 (aux_info) &= ~(PSB_CODEDBUF_##flag##_MASK<<PSB_CODEDBUF_##flag##_SHIFT);\ 490 (aux_info) |= ((slice_num) & PSB_CODEDBUF_##flag##_MASK)\ 491 <<PSB_CODEDBUF_##flag##_SHIFT;\ 492 } while (0) 493 494#define CLEAR_CODEDBUF_INFO(flag, aux_info) \ 495 do {\ 496 (aux_info) &= ~(PSB_CODEDBUF_##flag##_MASK<<PSB_CODEDBUF_##flag##_SHIFT);\ 497 } while (0) 498 499#define GET_CODEDBUF_INFO(flag, aux_info) \ 500 (((aux_info)>>PSB_CODEDBUF_##flag##_SHIFT) & PSB_CODEDBUF_##flag##_MASK) 501 502 503#define PSB_CODEDBUF_SEGMENT_MAX (9) 504 505struct object_buffer_s { 506 struct object_base_s base; 507 object_buffer_p ptr_next; /* Generic ptr for linked list */ 508 object_buffer_p *pptr_prev_next; /* Generic ptr for linked list */ 509 struct psb_buffer_s *psb_buffer; 510 unsigned char *buffer_data; 511 unsigned int size; 512 unsigned int alloc_size; 513 unsigned int max_num_elements; 514 unsigned int num_elements; 515 object_context_p context; 516 VABufferType type; 517 uint32_t last_used; 518 519 /* for VAEncCodedBufferType */ 520 VACodedBufferSegment codedbuf_mapinfo[PSB_CODEDBUF_SEGMENT_MAX]; 521 uint32_t codedbuf_aux_info; 522}; 523 524struct object_image_s { 525 struct object_base_s base; 526 VAImage image; 527 unsigned int palette[16]; 528 int subpic_ref; 529 VASurfaceID derived_surface; 530}; 531 532struct object_subpic_s { 533 struct object_base_s base; 534 VASubpictureID subpic_id; 535 536 VAImageID image_id; 537 538 /* chromakey range */ 539 unsigned int chromakey_min; 540 unsigned int chromakey_max; 541 unsigned int chromakey_mask; 542 543 /* global alpha */ 544 unsigned int global_alpha; 545 546 /* flags */ 547 unsigned int flags; /* see below */ 548 549 unsigned char *surfaces; /* surfaces, associated with this subpicture */ 550}; 551 552#define MEMSET_OBJECT(ptr, data_struct) \ 553 memset((unsigned char *)ptr + sizeof(struct object_base_s),\ 554 0, \ 555 sizeof(data_struct) - sizeof(struct object_base_s)) 556 557struct format_vtable_s { 558 void (*queryConfigAttributes)( 559 VAProfile profile, 560 VAEntrypoint entrypoint, 561 VAConfigAttrib *attrib_list, 562 int num_attribs 563 ); 564 VAStatus(*validateConfig)( 565 object_config_p obj_config 566 ); 567 VAStatus(*createContext)( 568 object_context_p obj_context, 569 object_config_p obj_config 570 ); 571 void (*destroyContext)( 572 object_context_p obj_context 573 ); 574 VAStatus(*beginPicture)( 575 object_context_p obj_context 576 ); 577 VAStatus(*renderPicture)( 578 object_context_p obj_context, 579 object_buffer_p *buffers, 580 int num_buffers 581 ); 582 VAStatus(*endPicture)( 583 object_context_p obj_context 584 ); 585}; 586 587#ifdef ANDROID 588typedef struct IMG_native_handle 589{ 590 native_handle_t base; 591 int fd; 592 unsigned long long ui64Stamp; 593 int usage; 594 int width; 595 int height; 596 unsigned int bpp; 597 int format; 598} IMG_native_handle_t; 599#endif 600 601#define psb__bounds_check(x, max) \ 602 do { ASSERT(x < max); if (x >= max) x = max - 1; } while(0); 603 604static inline unsigned long GetTickCount() 605{ 606 struct timeval tv; 607 if (gettimeofday(&tv, NULL)) 608 return 0; 609 return tv.tv_usec / 1000 + tv.tv_sec * 1000; 610} 611 612inline static char * buffer_type_to_string(int type) 613{ 614 switch (type) { 615 case VAPictureParameterBufferType: 616 return "VAPictureParameterBufferType"; 617 case VAIQMatrixBufferType: 618 return "VAIQMatrixBufferType"; 619 case VABitPlaneBufferType: 620 return "VABitPlaneBufferType"; 621 case VASliceGroupMapBufferType: 622 return "VASliceGroupMapBufferType"; 623 case VASliceParameterBufferType: 624 return "VASliceParameterBufferType"; 625 case VASliceDataBufferType: 626 return "VASliceDataBufferType"; 627 case VAProtectedSliceDataBufferType: 628 return "VAProtectedSliceDataBufferType"; 629 case VAMacroblockParameterBufferType: 630 return "VAMacroblockParameterBufferType"; 631 case VAResidualDataBufferType: 632 return "VAResidualDataBufferType"; 633 case VADeblockingParameterBufferType: 634 return "VADeblockingParameterBufferType"; 635 case VAImageBufferType: 636 return "VAImageBufferType"; 637 case VAEncCodedBufferType: 638 return "VAEncCodedBufferType"; 639 case VAEncSequenceParameterBufferType: 640 return "VAEncSequenceParameterBufferType"; 641 case VAEncPictureParameterBufferType: 642 return "VAEncPictureParameterBufferType"; 643 case VAEncSliceParameterBufferType: 644 return "VAEncSliceParameterBufferType"; 645 case VAEncMiscParameterBufferType: 646 return "VAEncMiscParameterBufferType"; 647 case VAProbabilityBufferType: 648 return "VAProbabilityBufferType"; 649 case VAHuffmanTableBufferType: 650 return "VAHuffmanTableBufferType"; 651 case VAQMatrixBufferType: 652 return "VAQMatrixBufferType"; 653 default: 654 return "UnknowBuffer"; 655 } 656} 657 658inline static int Angle2Rotation(int angle) 659{ 660 angle %= 360; 661 switch (angle) { 662 case 0: 663 return VA_ROTATION_NONE; 664 case 90: 665 return VA_ROTATION_90; 666 case 180: 667 return VA_ROTATION_180; 668 case 270: 669 return VA_ROTATION_270; 670 default: 671 return -1; 672 } 673} 674 675inline static int Rotation2Angle(int rotation) 676{ 677 switch (rotation) { 678 case VA_ROTATION_NONE: 679 return 0; 680 case VA_ROTATION_90: 681 return 90; 682 case VA_ROTATION_180: 683 return 180; 684 case VA_ROTATION_270: 685 return 270; 686 default: 687 return -1; 688 } 689} 690 691int psb_parse_config(char *env, char *env_value); 692void psb__destroy_surface(psb_driver_data_p driver_data, object_surface_p obj_surface); 693unsigned long psb_tile_stride_mode(int w); 694 695int LOCK_HARDWARE(psb_driver_data_p driver_data); 696int UNLOCK_HARDWARE(psb_driver_data_p driver_data); 697 698#define CHECK_SURFACE(obj_surface) \ 699 do { \ 700 if (NULL == obj_surface) { \ 701 vaStatus = VA_STATUS_ERROR_INVALID_SURFACE; \ 702 DEBUG_FAILURE; \ 703 return vaStatus; \ 704 } \ 705 } while (0) 706 707#define CHECK_CONFIG(obj_config) \ 708 do { \ 709 if (NULL == obj_config) { \ 710 vaStatus = VA_STATUS_ERROR_INVALID_CONFIG; \ 711 DEBUG_FAILURE; \ 712 return vaStatus; \ 713 } \ 714 } while (0) 715 716#define CHECK_CONTEXT(obj_context) \ 717 do { \ 718 if (NULL == obj_context) { \ 719 vaStatus = VA_STATUS_ERROR_INVALID_CONTEXT; \ 720 DEBUG_FAILURE; \ 721 return vaStatus; \ 722 } \ 723 } while (0) 724 725#define CHECK_BUFFER(obj_buffer) \ 726 do { \ 727 if (NULL == obj_buffer) { \ 728 vaStatus = VA_STATUS_ERROR_INVALID_BUFFER; \ 729 DEBUG_FAILURE; \ 730 return vaStatus; \ 731 } \ 732 } while (0) 733 734#define CHECK_IMAGE(obj_image) \ 735 do { \ 736 if (NULL == obj_image) { \ 737 vaStatus = VA_STATUS_ERROR_INVALID_IMAGE; \ 738 DEBUG_FAILURE; \ 739 return vaStatus; \ 740 } \ 741 } while (0) 742 743#define CHECK_SUBPICTURE(obj_subpic) \ 744 do { \ 745 if (NULL == obj_subpic) { \ 746 vaStatus = VA_STATUS_ERROR_INVALID_SUBPICTURE; \ 747 DEBUG_FAILURE; \ 748 return vaStatus; \ 749 } \ 750 } while (0) 751 752#define CHECK_ALLOCATION(buf) \ 753 do { \ 754 if (buf == NULL) { \ 755 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; \ 756 DEBUG_FAILURE; \ 757 return vaStatus; \ 758 } \ 759 } while (0) 760 761#define CHECK_VASTATUS() \ 762 do { \ 763 if (VA_STATUS_SUCCESS != vaStatus) { \ 764 DEBUG_FAILURE; \ 765 return vaStatus; \ 766 } \ 767 } while (0) 768 769#define CHECK_INVALID_PARAM(param) \ 770 do { \ 771 if (param) { \ 772 vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; \ 773 DEBUG_FAILURE; \ 774 return vaStatus; \ 775 } \ 776 } while (0) 777 778#endif /* _PSB_DRV_VIDEO_H_ */ 779