1 /* 2 * Copyright (c) 2009 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 25 #ifndef VA_TRACE_H 26 #define VA_TRACE_H 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 extern int va_trace_flag; 33 34 #define VA_TRACE_FLAG_LOG 0x1 35 #define VA_TRACE_FLAG_BUFDATA 0x2 36 #define VA_TRACE_FLAG_CODEDBUF 0x4 37 #define VA_TRACE_FLAG_SURFACE_DECODE 0x8 38 #define VA_TRACE_FLAG_SURFACE_ENCODE 0x10 39 #define VA_TRACE_FLAG_SURFACE_JPEG 0x20 40 #define VA_TRACE_FLAG_SURFACE (VA_TRACE_FLAG_SURFACE_DECODE | \ 41 VA_TRACE_FLAG_SURFACE_ENCODE | \ 42 VA_TRACE_FLAG_SURFACE_JPEG) 43 #define VA_TRACE_FLAG_FTRACE 0x40 44 #define VA_TRACE_FLAG_FTRACE_BUFDATA (VA_TRACE_FLAG_FTRACE | \ 45 VA_TRACE_FLAG_BUFDATA) 46 47 #define VA_TRACE_LOG(trace_func,...) \ 48 if (va_trace_flag & VA_TRACE_FLAG_LOG) { \ 49 trace_func(__VA_ARGS__); \ 50 } 51 #define VA_TRACE_ALL(trace_func,...) \ 52 if (va_trace_flag) { \ 53 trace_func(__VA_ARGS__); \ 54 } 55 #define VA_TRACE_RET(dpy,ret) \ 56 if (va_trace_flag){ \ 57 va_TraceStatus(dpy, __func__, ret); \ 58 } 59 60 /** \brief event id definition 61 * identifier of trace event, coresponding the task value in the manifest, located in libva-util/tracetool 62 * the trace tool will translate this id to event name, also the trace data carried along. 63 * Note: make sure event id definition backward compatible */ 64 enum { 65 INVALIDE_ID = 0, 66 CREATE_CONFIG = 1, 67 DESTROY_CONFIG, 68 CREATE_CONTEXT, 69 DESTROY_CONTEXT, 70 CREATE_BUFFER, 71 DESTROY_BUFFER, 72 CREATE_SURFACE, 73 DESTROY_SURFACE, 74 BEGIN_PICTURE, 75 RENDER_PICTURE, 76 END_PICTURE, 77 BUFFER_DATA, 78 SYNC_SURFACE, 79 SYNC_SURFACE2, 80 QUERY_SURFACE_ATTR, 81 }; 82 83 /** \brief event opcode definition 84 * identifier of trace event operation, coresponding the opcode value in the manifest. 85 * 4 predefined opcode */ 86 #define TRACE_INFO 0 87 #define TRACE_BEGIN 1 88 #define TRACE_END 2 89 #define TRACE_DATA 3 90 91 /** \brief event data structure 92 * structure list to pass event data without copy, each entry contain the event data address and size. 93 * va_TraceEvent will write these raw data into ftrace entry */ 94 typedef struct va_event_data { 95 void *buf; 96 unsigned int size; 97 } VAEventData; 98 99 100 /** \brief VA_TRACE 101 * trace interface to send out trace event with empty event data. */ 102 #define VA_TRACE(dpy,id,op) do { \ 103 if (va_trace_flag & VA_TRACE_FLAG_FTRACE) { \ 104 va_TraceEvent(dpy, id, op, 0, NULL); \ 105 } \ 106 } while (0) 107 /** \brief VA_TRACE_V 108 * trace interface to send out trace event with 1 data element from variable. the variable data type could be 8/16/32/64 bitsize */ 109 #define VA_TRACE_V(dpy,id,op,v) do { \ 110 if (va_trace_flag & VA_TRACE_FLAG_FTRACE) { \ 111 VAEventData desc[1] = {{&v, sizeof(v)}}; \ 112 va_TraceEvent(dpy, id, op, 1, desc); \ 113 } \ 114 } while (0) 115 /** \brief VA_TRACE_PV 116 * trace interface to send out trace event with 2 data element, from pointer and variable. their data size could be 8/16/32/64 bitsize */ 117 #define VA_TRACE_PV(dpy,id,op,p,v) do { \ 118 if (va_trace_flag & VA_TRACE_FLAG_FTRACE) { \ 119 VAEventData desc[2] = {{p, sizeof(*p)}, \ 120 {&v, sizeof(v)}}; \ 121 va_TraceEvent(dpy, id, op, 2, desc); \ 122 } \ 123 } while (0) 124 /** \brief VA_TRACE_VV 125 * trace interface to send out trace event with 2 data element, both from variable. their data size could be 8/16/32/64 bitsize */ 126 #define VA_TRACE_VV(dpy,id,op,v1,v2) do { \ 127 if (va_trace_flag & VA_TRACE_FLAG_FTRACE) { \ 128 VAEventData desc[2] = {{&v1, sizeof(v1)}, \ 129 {&v2, sizeof(v2)}}; \ 130 va_TraceEvent(dpy, id, op, 2, desc); \ 131 } \ 132 } while (0) 133 /** \brief VA_TRACE_VVVV 134 * trace interface to send out trace event with 4 data element, all from variable. their data size could be 8/16/32/64 bitsize */ 135 #define VA_TRACE_VVVV(dpy,id,op,v1,v2,v3,v4) do { \ 136 if (va_trace_flag & VA_TRACE_FLAG_FTRACE) { \ 137 VAEventData desc[4] = { {&v1, sizeof(v1)}, \ 138 {&v2, sizeof(v2)}, \ 139 {&v3, sizeof(v3)}, \ 140 {&v4, sizeof(v4)}}; \ 141 va_TraceEvent(dpy, id, op, 4, desc); \ 142 } \ 143 } while (0) 144 /** \brief VA_TRACE_VA 145 * trace interface to send out trace event with a dynamic length array data element, array length from variable. 146 * high 16bits of array length is used to set bitssize of array element. */ 147 #define VA_TRACE_VA(dpy,id,op,n,a) do { \ 148 if (va_trace_flag & VA_TRACE_FLAG_FTRACE) { \ 149 int num = n | sizeof(*a) << 16; \ 150 VAEventData desc[2] = {{&num, sizeof(num)}, \ 151 {a, n * sizeof(*a)}}; \ 152 va_TraceEvent(dpy, id, op, 2, desc); \ 153 } \ 154 } while (0) 155 /** \brief VA_TRACE_PA 156 * trace interface to send out trace event with a dynamic length array data element, array length from pointer. need check null before set. 157 * high 16bits of array length is used to set bitssize of array element. */ 158 #define VA_TRACE_PA(dpy,id,op,pn,a) do { \ 159 if (va_trace_flag & VA_TRACE_FLAG_FTRACE) { \ 160 int num = sizeof(*a) << 16; \ 161 VAEventData desc[2] = {{&num, sizeof(num)}, \ 162 {a, 0}}; \ 163 if (pn) { \ 164 num |= *pn; \ 165 desc[1].size = (*pn) * sizeof(*a); \ 166 } \ 167 va_TraceEvent(dpy, id, op, 2, desc); \ 168 } \ 169 } while (0) 170 /** \brief VA_TRACE_VVA 171 * trace interface to send out trace event with 1 data element and a dynamic length array data element, array length from variable. 172 * high 16bits of array length is used to set bitssize of array element. */ 173 #define VA_TRACE_VVA(dpy,id,op,v,n,a) do { \ 174 if (va_trace_flag & VA_TRACE_FLAG_FTRACE) { \ 175 int num = n | (sizeof(*a) << 16); \ 176 VAEventData desc[3] = {{&v, sizeof(v)}, \ 177 {&num, sizeof(num)}, \ 178 {a, n*sizeof(*a)}}; \ 179 va_TraceEvent(dpy, id, op, 3, desc); \ 180 } \ 181 } while (0) 182 /** \brief VA_TRACE_VVVA 183 * trace interface to send out trace event with 2 data element and a dynamic length array data element, array length from variable. 184 * high 16bits of array length is used to set bitssize of array element. */ 185 #define VA_TRACE_VVVA(dpy,id,op,v1,v2,n,a) do { \ 186 if (va_trace_flag & VA_TRACE_FLAG_FTRACE) { \ 187 int num = n | (sizeof(*a) << 16); \ 188 VAEventData desc[4] = {{&v1, sizeof(v1)}, \ 189 {&v2, sizeof(v2)}, \ 190 {&num, sizeof(num)}, \ 191 {a, n*sizeof(*a)}}; \ 192 va_TraceEvent(dpy, id, op, 4, desc); \ 193 } \ 194 } while (0) 195 /** \brief VA_TRACE_VVVVA 196 * trace interface to send out trace event with 3 data element and a dynamic length array data element, array length from variable. 197 * high 16bits of array length is used to set bitssize of array element. */ 198 #define VA_TRACE_VVVVA(dpy,id,op,v1,v2,v3,n,a) do { \ 199 if (va_trace_flag & VA_TRACE_FLAG_FTRACE) { \ 200 int num = n | (sizeof(*a) << 16); \ 201 VAEventData desc[5] = {{&v1, sizeof(v1)}, \ 202 {&v2, sizeof(v2)}, \ 203 {&v3, sizeof(v3)}, \ 204 {&num, sizeof(num)}, \ 205 {a, n*sizeof(*a)}}; \ 206 va_TraceEvent(dpy, id, op, 5, desc); \ 207 } \ 208 } while (0) 209 /** \brief VA_TRACE_VVVVVA 210 * trace interface to send out trace event with 4 data elsement and a dynamic length array data element, array length from variable. 211 * high 16bits of array length is used to set bitssize of array element. */ 212 #define VA_TRACE_VVVVVA(dpy,id,op,v1,v2,v3,v4,n,a) do { \ 213 if (va_trace_flag & VA_TRACE_FLAG_FTRACE) { \ 214 int num = n | (sizeof(*a) << 16); \ 215 VAEventData desc[6] = {{&v1, sizeof(v1)}, \ 216 {&v2, sizeof(v2)}, \ 217 {&v3, sizeof(v3)}, \ 218 {&v4, sizeof(v4)}, \ 219 {&num, sizeof(num)}, \ 220 {a, n*sizeof(*a)}}; \ 221 va_TraceEvent(dpy, id, op, 6, desc); \ 222 } \ 223 } while (0) 224 225 /* add macro interface to support new data type combination */ 226 227 228 /** \brief VA_TRACE_BUFFERS 229 * trace interface to dump all data in va buffer ids into trace. 230 * libva-utils will parse buffer into fields according to buffer type */ 231 #define VA_TRACE_BUFFERS(dpy,ctx,num,buffers) do { \ 232 if ((va_trace_flag & VA_TRACE_FLAG_FTRACE_BUFDATA) == VA_TRACE_FLAG_FTRACE_BUFDATA) { \ 233 va_TraceEventBuffers(dpy, ctx, num, buffers); \ 234 } \ 235 } while (0) 236 237 DLL_HIDDEN 238 void va_TraceInit(VADisplay dpy); 239 DLL_HIDDEN 240 void va_TraceEnd(VADisplay dpy); 241 242 DLL_HIDDEN 243 void va_TraceInitialize( 244 VADisplay dpy, 245 int *major_version, /* out */ 246 int *minor_version /* out */ 247 ); 248 249 DLL_HIDDEN 250 void va_TraceTerminate( 251 VADisplay dpy 252 ); 253 254 DLL_HIDDEN 255 void va_TraceCreateConfig( 256 VADisplay dpy, 257 VAProfile profile, 258 VAEntrypoint entrypoint, 259 VAConfigAttrib *attrib_list, 260 int num_attribs, 261 VAConfigID *config_id /* out */ 262 ); 263 264 DLL_HIDDEN 265 void va_TraceDestroyConfig( 266 VADisplay dpy, 267 VAConfigID config_id 268 ); 269 270 DLL_HIDDEN 271 void va_TraceCreateSurfaces( 272 VADisplay dpy, 273 int width, 274 int height, 275 int format, 276 int num_surfaces, 277 VASurfaceID *surfaces, /* out */ 278 VASurfaceAttrib *attrib_list, 279 unsigned int num_attribs 280 ); 281 282 DLL_HIDDEN 283 void va_TraceDestroySurfaces( 284 VADisplay dpy, 285 VASurfaceID *surface_list, 286 int num_surfaces 287 ); 288 289 DLL_HIDDEN 290 void va_TraceCreateContext( 291 VADisplay dpy, 292 VAConfigID config_id, 293 int picture_width, 294 int picture_height, 295 int flag, 296 VASurfaceID *render_targets, 297 int num_render_targets, 298 VAContextID *context /* out */ 299 ); 300 301 DLL_HIDDEN 302 void va_TraceDestroyContext( 303 VADisplay dpy, 304 VAContextID context 305 ); 306 307 DLL_HIDDEN 308 void va_TraceCreateMFContext( 309 VADisplay dpy, 310 VAContextID *mf_context /* out */ 311 ); 312 313 DLL_HIDDEN 314 void va_TraceMFAddContext( 315 VADisplay dpy, 316 VAMFContextID mf_context, 317 VAContextID context 318 ); 319 320 DLL_HIDDEN 321 void va_TraceMFReleaseContext( 322 VADisplay dpy, 323 VAMFContextID mf_context, 324 VAContextID context 325 ); 326 327 DLL_HIDDEN 328 void va_TraceMFSubmit( 329 VADisplay dpy, 330 VAMFContextID mf_context, 331 VAContextID *contexts, 332 int num_contexts 333 ); 334 335 DLL_HIDDEN 336 void va_TraceCreateBuffer( 337 VADisplay dpy, 338 VAContextID context, /* in */ 339 VABufferType type, /* in */ 340 unsigned int size, /* in */ 341 unsigned int num_elements, /* in */ 342 void *data, /* in */ 343 VABufferID *buf_id /* out */ 344 ); 345 346 DLL_HIDDEN 347 void va_TraceDestroyBuffer( 348 VADisplay dpy, 349 VABufferID buf_id /* in */ 350 ); 351 352 DLL_HIDDEN 353 void va_TraceMapBuffer( 354 VADisplay dpy, 355 VABufferID buf_id, /* in */ 356 void **pbuf, /* out */ 357 uint32_t flags /* in */ 358 ); 359 360 361 DLL_HIDDEN 362 void va_TraceBeginPicture( 363 VADisplay dpy, 364 VAContextID context, 365 VASurfaceID render_target 366 ); 367 368 DLL_HIDDEN 369 void va_TraceRenderPicture( 370 VADisplay dpy, 371 VAContextID context, 372 VABufferID *buffers, 373 int num_buffers 374 ); 375 376 DLL_HIDDEN 377 void va_TraceEndPicture( 378 VADisplay dpy, 379 VAContextID context, 380 int endpic_done 381 ); 382 383 DLL_HIDDEN 384 void va_TraceEndPictureExt( 385 VADisplay dpy, 386 VAContextID context, 387 int endpic_done 388 ); 389 390 DLL_HIDDEN 391 void va_TraceSyncSurface( 392 VADisplay dpy, 393 VASurfaceID render_target 394 ); 395 396 DLL_HIDDEN 397 void va_TraceSyncSurface2( 398 VADisplay dpy, 399 VASurfaceID surface, 400 uint64_t timeout_ns 401 ); 402 403 DLL_HIDDEN 404 void va_TraceQuerySurfaceAttributes( 405 VADisplay dpy, 406 VAConfigID config, 407 VASurfaceAttrib *attrib_list, 408 unsigned int *num_attribs 409 ); 410 411 DLL_HIDDEN 412 void va_TraceQuerySurfaceStatus( 413 VADisplay dpy, 414 VASurfaceID render_target, 415 VASurfaceStatus *status /* out */ 416 ); 417 418 DLL_HIDDEN 419 void va_TraceQuerySurfaceError( 420 VADisplay dpy, 421 VASurfaceID surface, 422 VAStatus error_status, 423 void **error_info /*out*/ 424 ); 425 426 DLL_HIDDEN 427 void va_TraceSyncBuffer( 428 VADisplay dpy, 429 VABufferID buf_id, 430 uint64_t timeout_ns 431 ); 432 433 DLL_HIDDEN 434 void va_TraceMaxNumDisplayAttributes( 435 VADisplay dpy, 436 int number 437 ); 438 439 DLL_HIDDEN 440 void va_TraceQueryDisplayAttributes( 441 VADisplay dpy, 442 VADisplayAttribute *attr_list, /* out */ 443 int *num_attributes /* out */ 444 ); 445 446 DLL_HIDDEN 447 void va_TraceGetDisplayAttributes( 448 VADisplay dpy, 449 VADisplayAttribute *attr_list, 450 int num_attributes 451 ); 452 453 DLL_HIDDEN 454 void va_TraceSetDisplayAttributes( 455 VADisplay dpy, 456 VADisplayAttribute *attr_list, 457 int num_attributes 458 ); 459 460 /* extern function called by display side */ 461 void va_TracePutSurface( 462 VADisplay dpy, 463 VASurfaceID surface, 464 void *draw, /* the target Drawable */ 465 short srcx, 466 short srcy, 467 unsigned short srcw, 468 unsigned short srch, 469 short destx, 470 short desty, 471 unsigned short destw, 472 unsigned short desth, 473 VARectangle *cliprects, /* client supplied clip list */ 474 unsigned int number_cliprects, /* number of clip rects in the clip list */ 475 unsigned int flags /* de-interlacing flags */ 476 ); 477 478 void va_TraceStatus(VADisplay dpy, const char * funcName, VAStatus status); 479 480 /** \brief va_TraceEvent 481 * common trace interface to send out trace event with scatterd event data. */ 482 DLL_HIDDEN 483 void va_TraceEvent( 484 VADisplay dpy, 485 unsigned short id, 486 unsigned short opcode, 487 unsigned int num, 488 VAEventData *desc); 489 490 /** \brief va_TraceEventBuffers 491 * trace buffer interface to send out data in buffers. */ 492 DLL_HIDDEN 493 void va_TraceEventBuffers( 494 VADisplay dpy, 495 VAContextID context, 496 int num_buffers, 497 VABufferID *buffers); 498 499 /** \brief va_TraceExportSurfaceHandle 500 * trace exported surface handle. */ 501 DLL_HIDDEN 502 void va_TraceExportSurfaceHandle( 503 VADisplay dpy, 504 VASurfaceID surfaceId, 505 uint32_t memType, 506 uint32_t flags, 507 void *descriptor); 508 509 #ifdef __cplusplus 510 } 511 #endif 512 513 514 #endif /* VA_TRACE_H */ 515