Debian Codegraph @

va/va_trace.h

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